# Claway — Full Documentation This file is the entire Claway documentation concatenated for LLM context ingestion. Section order follows the docs-site navigation, then everything else. Canonical site: https://docs.claway.io Short index: https://docs.claway.io/llms.txt --- # Getting started with Claway # Getting started with Claway Claway is Blockway's AI agent for teams. Your agent answers in WhatsApp, Telegram, Slack, Teams and other chat apps, in the **Claway App**, and over HTTP for tools such as n8n. You manage it from the **OPS dashboard**. There are two ways to run Claway. Everything else in these docs works the same on both; only the address you use differs. | | **Claway Box** | **Hosted Claway** | |---|---|---| | What it is | An appliance on your own network | A server Blockway runs for you | | OPS dashboard | `https:///` (self-signed certificate) | `http://:8443/` | | Webhooks | `https:///webhooks/agent` | `http://:8443/webhooks/agent` | | OpenAI-compatible API | `https:///v1` | `http://:8443/v1` | | Agent home on the machine | `/opt/claway` | `/opt/claway` | `` is the Box's IP address or its `.local` name; `` is the address Blockway gave you for your hosted server. These docs never show real addresses. ## 1. Sign in to OPS ### On a Claway Box 1. Plug the Box into your network and power it on. With a screen attached, the Box shows its address and a QR code. 2. Open `https:///` from a computer on the same network. Your browser warns about the certificate: the Box uses a self-signed certificate, so accept it for this address. 3. The first time, the Box asks you to **activate** it. Enter: - the 8-character **activation code** shown on the Box screen, - your **licence** (`CLAW-...`), from Blockway, - an **operator password** (at least 10 characters), - the **admin mobile number** (with country code) of the first person who may sign in to the Claway App. 4. Scan the QR code it shows into an authenticator app (1Password, Google Authenticator, Authy, iOS Passwords). It is shown **only once**. ### On hosted Claway Blockway sends you the OPS address, your operator password and an authenticator QR code. Scan the QR code into an authenticator app. ### Every sign-in Sign in with the operator password and the current 6-digit code from your authenticator app. The [operator guide](/operators/getting-started) walks through each OPS page. ## 2. Connect a chat app In OPS, open **Connectors**. Each row is one platform (WhatsApp, Telegram, Slack, Microsoft Teams, Email, ...) with its live status, a **Setup wizard** for the first connection and **Manage** for later changes. - WhatsApp: the wizard shows a QR code to pair the number. See [WhatsApp](/user-guide/messaging/whatsapp) and [WhatsApp group onboarding](/operators/whatsapp-onboarding). - Every other platform: see [Messaging platforms](/user-guide/messaging). Then set up how the agent behaves in each chat in **Personas** ([persona guide](/operators/persona-guide)) and give it your documents in **KB** ([knowledge base guide](/operators/kb-guide)). ## 3. Invite people to the Claway App The Claway App (iOS, Android, desktop and web) gives each employee a private chat with the agent. Sign-in is by mobile number plus a one-time code, and only numbers on your roster can sign in. Add people in **OPS → Users**. See [Claway App](/user-guide/employee-app). ## 4. Connect n8n, Zapier or your own software Two connectors in **OPS → Connectors** open Claway to other software. Both require a secret of at least 16 random characters and check it on every call. - **Webhook**: `POST .../webhooks/agent` with a message, get the agent's answer back, synchronously or through a callback URL. Best for n8n's HTTP Request node, Zapier and Make. See [Webhooks](/user-guide/messaging/webhooks#agent-route). - **API server**: an OpenAI-compatible API at `.../v1`. Best for n8n's *OpenAI Chat Model* and *AI Agent* nodes, Open WebUI, and any OpenAI SDK. See [API server](/user-guide/features/api-server#claway-box). ## 5. Keep it up to date **OPS → System** shows the installed version and, when a newer one is available, an **Update now** button. ## Getting help Email [support@claway.io](mailto:support@claway.io). Before you do, the [escalation guide](/operators/escalation) lists what to check and what to send. ## Where to go next - [Operator guide](/operators): running Claway for a team. - [End-user cheat sheet](/end-users): one page to hand to the people who chat with the agent. - [Features](/user-guide/features/overview): what the agent can do: tools, skills, memory, scheduled jobs and more. - [Using the claway CLI](/user-guide/cli): for administrators with shell access to the Box or server. There the agent's home is `/opt/claway`, not `~/.claway` as on a personal install. --- # Webhooks # Webhooks The webhook connector lets other software talk to your Claway agent over HTTP: - **Ask the agent and get the answer back**: n8n, Zapier, Make or your own code POSTs a message to the built-in `agent` route and receives the agent's reply, in the same HTTP response or later on a callback URL. Start with [the built-in `agent` route](#agent-route) and [the n8n recipe](#n8n). - **Trigger agent runs from events**: GitHub, GitLab, Stripe, monitoring tools and so on POST events to routes you configure; the agent processes each event and posts its answer to a PR, a chat, or the log. See [Configuring routes](#configuring-routes). ## Enable the connector {#enable} On a **Claway Box** or **hosted Claway**: in OPS, open **Connectors → Webhook**, run the setup wizard and set the **secret**: at least 16 random characters (for example the output of `openssl rand -hex 32`). The wizard stores it as `WEBHOOK_SECRET`. Anyone holding the secret can run the agent, so treat it like a password. Your webhook URL is then: | Where Claway runs | URL of the built-in route | |---|---| | Claway Box | `https:///webhooks/agent` | | Hosted Claway | `http://:8443/webhooks/agent` | | Your own install (`claway gateway`) | `http://:8644/webhooks/agent` | On a Box and on hosted Claway the address in front (port 443 on a Box, 8443 hosted) forwards `/webhooks/` to the webhook connector on `127.0.0.1:8644` without the OPS login; the connector checks the secret on every call. While the connector is off, that address answers `503 {"error": "connector_not_enabled", ...}`. On your own install, set the same values in `~/.claway/.env` (or run `claway gateway setup`) and start the gateway: ```bash WEBHOOK_ENABLED=true WEBHOOK_PORT=8644 # default; keep it on a Box or hosted server WEBHOOK_SECRET=<16+ random characters> ``` Check that the connector is up (from the machine itself): ```bash curl http://127.0.0.1:8644/health # {"status": "ok", "platform": "webhook"} ``` --- ## The built-in `agent` route (n8n, Zapier, Make, your own apps) {#agent-route} With `WEBHOOK_SECRET` set, the connector serves `POST /webhooks/agent` without any route configuration. It is made for HTTP clients that want the agent's **answer back**. | | | |---|---| | Method and URL | `POST https:///webhooks/agent` (Box) or `POST http://:8443/webhooks/agent` (hosted) | | Auth | `Authorization: Bearer `, or `X-Webhook-Signature: ` | | Body | JSON. The prompt is the `message` field; `prompt`, `text` and `chatInput` (what n8n's Chat Trigger sends) also work. Any other JSON is shown to the agent as-is | | Answer | The request waits for the agent and returns `200 {"status": "completed", "response": "...", "route": "agent", "delivery_id": "..."}` | | Failure | `502 {"status": "failed", "error": "..."}` if the run failed; `504 {"status": "timeout"}` if it is still running after `sync_timeout` (default 600 s). The run carries on after a timeout; use a callback to get long answers | | Async | Add `"callback_url": "https://..."` to the body. You get `202 {"status": "accepted", "reply": "callback", ...}` at once, and Claway POSTs `{"status": "completed", "response": "...", "route": "agent", "delivery_id": "..."}` to that URL when the agent is done (`"status": "failed"` with `"error"` otherwise) | ```bash curl -k https:///webhooks/agent \ -H "Authorization: Bearer $WEBHOOK_SECRET" \ -H "Content-Type: application/json" \ -d '{"message": "Summarise today'"'"'s open tickets"}' ``` ```json {"status": "completed", "response": "There are 3 open tickets ...", "route": "agent", "delivery_id": "4f9c..."} ``` (`-k` accepts the Box's self-signed certificate. On hosted Claway, use the `http://:8443/...` URL and drop `-k`.) The callback POST carries: - `X-Webhook-Signature`: hex HMAC-SHA256 of the callback body, keyed with your `WEBHOOK_SECRET`, so the receiver can check it came from your agent; - `X-Claway-Delivery`: the `delivery_id`. A callback that fails or gets a 5xx answer is retried up to 3 times. A `callback_url` must be an absolute `http://` or `https://` URL (otherwise `400`). Things to know: - **Each call is its own conversation.** The agent does not remember earlier webhook calls. Put everything it needs into the message, or use the [API server](../features/api-server.md) for multi-turn conversations. - **Webhook runs have a limited toolset.** A webhook payload is untrusted input, so by default a webhook-triggered run can search the web, read web pages and look at images, but has no terminal and no file tools. - **Retries are de-duplicated.** If you send an `X-Request-ID` header, a second call with the same value within one hour returns `200 {"status": "duplicate"}` instead of running the agent again. Leave the header out, or make it unique per call. - **Limits:** 30 calls per minute per route and a 1 MB body by default (`rate_limit` and `max_body_bytes`, see [Security](#security)). - **Secret rules:** a `WEBHOOK_SECRET` shorter than 16 characters, or a placeholder, leaves the route switched off (the OPS wizard refuses it). Turn the built-in route off with `platforms.webhook.extra.agent_route: false`. - Any route can opt in to the same reply behaviour with `http_reply: true`, and `?wait=1` on any route's URL makes that call wait for the answer. ## n8n recipe {#n8n} ### Ask the agent and use the answer (synchronous) 1. Add an **HTTP Request** node: - **Method:** `POST` - **URL:** `https:///webhooks/agent` (Box) or `http://:8443/webhooks/agent` (hosted) - **Authentication:** *Generic Credential Type* → *Bearer Auth*, token = your `WEBHOOK_SECRET` (or *Header Auth* with name `Authorization` and value `Bearer `) - **Send Body:** on, *JSON*, for example `{"message": "{{ $json.text }}"}` - **Options → Ignore SSL Issues:** on, for a Claway Box (its certificate is self-signed). Alternatively start n8n with `NODE_EXTRA_CA_CERTS` pointing at the Box certificate. 2. The node's output is the JSON answer; the agent's text is in `{{ $json.response }}`. The node waits until the agent has answered. For tasks that can take minutes, raise the node's **Timeout** option or use the asynchronous pattern below. ### Long-running tasks (callback) 1. **HTTP Request** node as above, with the body `{"message": "...", "callback_url": "{{ $execution.resumeUrl }}"}`. It returns `202` immediately. 2. Then a **Wait** node with **Resume:** *On Webhook Call* and **HTTP Method:** `POST`. When the agent is done, Claway POSTs the answer to the resume URL and the workflow continues; the answer is in `{{ $json.body.response }}`. The resume URL must be reachable **from the Box or hosted server**: an n8n on your laptop that the server cannot reach never gets the callback. ### Use the agent as an OpenAI model in n8n For n8n's *OpenAI Chat Model* or *AI Agent* nodes, use the [API server](../features/api-server.md#claway-box) instead: an OpenAI credential with Base URL `https:///v1` (Box) or `http://:8443/v1` (hosted). ### From Claway to n8n - Ask the agent (in chat, the App or over the API server) to POST to an n8n *Webhook* trigger URL; it uses its terminal to do so. A plain-`http://` n8n URL (n8n on the LAN) is held for approval by the terminal's security scan: approve it in the chat, or over the API with `POST /v1/runs//approval {"choice": "once"}`. An `https://` n8n URL is not held. - Or send OPS events to n8n from **OPS → Webhooks**. - A webhook-triggered run has no terminal, so to hand an answer back to n8n from a webhook call, use the response or `callback_url`. --- ## Configuring Routes {#configuring-routes} Routes define how different webhook sources are handled. Each route is a named entry under `platforms.webhook.extra.routes` in your `config.yaml`. ### Route properties | Property | Required | Description | |----------|----------|-------------| | `events` | No | List of event types to accept (e.g. `["pull_request"]`). If empty, all events are accepted. Event type is read from `X-GitHub-Event`, `X-GitLab-Event`, or `event_type` in the payload. | | `secret` | **Yes** | HMAC secret for signature validation. Falls back to the global `secret` if not set on the route. Set to `"INSECURE_NO_AUTH"` for testing only (skips validation). | | `prompt` | No | Template string with dot-notation payload access (e.g. `{pull_request.title}`). If omitted, the full JSON payload is dumped into the prompt. Payload fields are untrusted — see [Authenticated does not mean trusted](#authenticated-does-not-mean-trusted). | | `skills` | No | List of skill names to load for the agent run. | | `deliver` | No | Where to send the response: `github_comment`, `telegram`, `discord`, `slack`, `signal`, `sms`, `whatsapp`, `matrix`, `mattermost`, `homeassistant`, `email`, `dingtalk`, `feishu`, `wecom`, `weixin`, `bluebubbles`, `qqbot`, or `log` (default). | | `deliver_extra` | No | Additional delivery config — keys depend on `deliver` type (e.g. `repo`, `pr_number`, `chat_id`). Values support the same `{dot.notation}` templates as `prompt`. | | `deliver_only` | No | If `true`, skip the agent entirely — the rendered `prompt` template becomes the literal message that gets delivered. Zero LLM cost, sub-second delivery. See [Direct Delivery Mode](#direct-delivery-mode) for use cases. Requires `deliver` to be a real target (not `log`). | ### Full example ```yaml platforms: webhook: enabled: true extra: port: 8644 secret: "global-fallback-secret" routes: github-pr: events: ["pull_request"] secret: "github-webhook-secret" prompt: | Review this pull request: Repository: {repository.full_name} PR #{number}: {pull_request.title} Author: {pull_request.user.login} URL: {pull_request.html_url} Diff URL: {pull_request.diff_url} Action: {action} skills: ["github-code-review"] deliver: "github_comment" deliver_extra: repo: "{repository.full_name}" pr_number: "{number}" deploy-notify: events: ["push"] secret: "deploy-secret" prompt: "New push to {repository.full_name} branch {ref}: {head_commit.message}" deliver: "telegram" ``` ### Prompt Templates Prompts use dot-notation to access nested fields in the webhook payload: - `{pull_request.title}` resolves to `payload["pull_request"]["title"]` - `{repository.full_name}` resolves to `payload["repository"]["full_name"]` - `{__raw__}` — special token that dumps the **entire payload** as indented JSON (truncated at 4000 characters). Useful for monitoring alerts or generic webhooks where the agent needs the full context. - Missing keys are left as the literal `{key}` string (no error) - Nested dicts and lists are JSON-serialized and truncated at 2000 characters You can mix `{__raw__}` with regular template variables: ```yaml prompt: "PR #{pull_request.number} by {pull_request.user.login}: {__raw__}" ``` If no `prompt` template is configured for a route, the entire payload is dumped as indented JSON (truncated at 4000 characters). The same dot-notation templates work in `deliver_extra` values. ### Forum Topic Delivery When delivering webhook responses to Telegram, you can target a specific forum topic by including `message_thread_id` (or `thread_id`) in `deliver_extra`: ```yaml platforms: webhook: extra: routes: alerts: events: ["alert"] prompt: "Alert: {__raw__}" deliver: "telegram" deliver_extra: chat_id: "-1001234567890" message_thread_id: "42" ``` If `chat_id` is not provided in `deliver_extra`, the delivery falls back to the home channel configured for the target platform. --- ## GitHub PR Review (Step by Step) {#github-pr-review} This walkthrough sets up automatic code review on every pull request. ### 1. Create the webhook in GitHub 1. Go to your repository → **Settings** → **Webhooks** → **Add webhook** 2. Set **Payload URL** to `https:///webhooks/github-pr` (hosted: `http://:8443/webhooks/github-pr`; own install: `http://:8644/webhooks/github-pr`) 3. Set **Content type** to `application/json` 4. Set **Secret** to match your route config (e.g. `github-webhook-secret`) 5. Under **Which events?**, select **Let me select individual events** and check **Pull requests** 6. Click **Add webhook** ### 2. Add the route config Add the `github-pr` route to your `~/.claway/config.yaml` as shown in the example above. ### 3. Ensure `gh` CLI is authenticated The `github_comment` delivery type uses the GitHub CLI to post comments: ```bash gh auth login ``` ### 4. Test it Open a pull request on the repository. The webhook fires, Claway processes the event, and posts a review comment on the PR. --- ## GitLab Webhook Setup {#gitlab-webhook-setup} GitLab webhooks work similarly but use a different authentication mechanism. GitLab sends the secret as a plain `X-Gitlab-Token` header (exact string match, not HMAC). ### 1. Create the webhook in GitLab 1. Go to your project → **Settings** → **Webhooks** 2. Set the **URL** to `https:///webhooks/gitlab-mr` (hosted: `http://:8443/webhooks/gitlab-mr`) 3. Enter your **Secret token** 4. Select **Merge request events** (and any other events you want) 5. Click **Add webhook** ### 2. Add the route config ```yaml platforms: webhook: enabled: true extra: routes: gitlab-mr: events: ["merge_request"] secret: "your-gitlab-secret-token" prompt: | Review this merge request: Project: {project.path_with_namespace} MR !{object_attributes.iid}: {object_attributes.title} Author: {object_attributes.last_commit.author.name} URL: {object_attributes.url} Action: {object_attributes.action} deliver: "log" ``` --- ## Delivery Options {#delivery-options} The `deliver` field controls where the agent's response goes after processing the webhook event. | Deliver Type | Description | |-------------|-------------| | `log` | Logs the response to the gateway log output. This is the default and is useful for testing. | | `github_comment` | Posts the response as a PR/issue comment via the `gh` CLI. Requires `deliver_extra.repo` and `deliver_extra.pr_number`. The `gh` CLI must be installed and authenticated on the gateway host (`gh auth login`). | | `telegram` | Routes the response to Telegram. Uses the home channel, or specify `chat_id` in `deliver_extra`. | | `discord` | Routes the response to Discord. Uses the home channel, or specify `chat_id` in `deliver_extra`. | | `slack` | Routes the response to Slack. Uses the home channel, or specify `chat_id` in `deliver_extra`. | | `signal` | Routes the response to Signal. Uses the home channel, or specify `chat_id` in `deliver_extra`. | | `sms` | Routes the response to SMS via Twilio. Uses the home channel, or specify `chat_id` in `deliver_extra`. | | `whatsapp` | Routes the response to WhatsApp. Uses the home channel, or specify `chat_id` in `deliver_extra`. | | `matrix` | Routes the response to Matrix. Uses the home channel, or specify `chat_id` in `deliver_extra`. | | `mattermost` | Routes the response to Mattermost. Uses the home channel, or specify `chat_id` in `deliver_extra`. | | `homeassistant` | Routes the response to Home Assistant. Uses the home channel, or specify `chat_id` in `deliver_extra`. | | `email` | Routes the response to Email. Uses the home channel, or specify `chat_id` in `deliver_extra`. | | `dingtalk` | Routes the response to DingTalk. Uses the home channel, or specify `chat_id` in `deliver_extra`. | | `feishu` | Routes the response to Feishu/Lark. Uses the home channel, or specify `chat_id` in `deliver_extra`. | | `wecom` | Routes the response to WeCom. Uses the home channel, or specify `chat_id` in `deliver_extra`. | | `weixin` | Routes the response to Weixin (WeChat). Uses the home channel, or specify `chat_id` in `deliver_extra`. | | `bluebubbles` | Routes the response to BlueBubbles (iMessage). Uses the home channel, or specify `chat_id` in `deliver_extra`. | For cross-platform delivery, the target platform must also be enabled and connected in the gateway. If no `chat_id` is provided in `deliver_extra`, the response is sent to that platform's configured home channel. --- ## Direct Delivery Mode {#direct-delivery-mode} By default, every webhook POST triggers an agent run — the payload becomes a prompt, the agent processes it, and the agent's response is delivered. This costs LLM tokens on every event. For use cases where you just want to **push a plain notification** — no reasoning, no agent loop, just deliver the message — set `deliver_only: true` on the route. The rendered `prompt` template becomes the literal message body, and the adapter dispatches it directly to the configured delivery target. ### When to use direct delivery - **External service push** — Supabase/Firebase webhook fires on a database change → notify a user in Telegram instantly - **Monitoring alerts** — Datadog/Grafana alert webhook → push to a Discord channel - **Inter-agent pings** — Agent A notifies Agent B's user that a long-running task finished - **Background job completion** — Cron job finishes → post result to Slack Benefits: - **Zero LLM tokens** — the agent is never invoked - **Sub-second delivery** — a single adapter call, no reasoning loop - **Same security as agent mode** — HMAC auth, rate limits, idempotency, and body-size limits all still apply - **Synchronous response** — the POST returns `200 OK` once delivery succeeds, or `502` if the target rejects it, so your upstream service can retry intelligently ### Example: Telegram push from Supabase ```yaml platforms: webhook: enabled: true extra: port: 8644 secret: "global-secret" routes: antenna-matches: secret: "antenna-webhook-secret" deliver: "telegram" deliver_only: true prompt: "🎉 New match: {match.user_name} matched with you!" deliver_extra: chat_id: "{match.telegram_chat_id}" ``` Your Supabase edge function signs the payload with HMAC-SHA256 and POSTs to `https:///webhooks/antenna-matches`. The webhook adapter validates the signature, renders the template from the payload, delivers to Telegram, and returns `200 OK`. ### Example: Dynamic subscription via CLI ```bash claway webhook subscribe antenna-matches \ --deliver telegram \ --deliver-chat-id "123456789" \ --deliver-only \ --prompt "🎉 New match: {match.user_name} matched with you!" \ --description "Antenna match notifications" ``` ### Response codes | Status | Meaning | |--------|---------| | `200 OK` | Delivered successfully. Body: `{"status": "delivered", "route": "...", "target": "...", "delivery_id": "..."}` | | `200 OK` (status=duplicate) | Duplicate `X-GitHub-Delivery` ID within the idempotency TTL (1 hour). Not re-delivered. | | `401 Unauthorized` | HMAC signature invalid or missing. | | `400 Bad Request` | Malformed JSON body. | | `404 Not Found` | Unknown route name. | | `413 Payload Too Large` | Body exceeded `max_body_bytes`. | | `429 Too Many Requests` | Route rate limit exceeded. | | `502 Bad Gateway` | Target adapter rejected the message or raised. The error is logged server-side; the response body is a generic `Delivery failed` to avoid leaking adapter internals. | ### Configuration gotchas - `deliver_only: true` requires `deliver` to be a real target. `deliver: log` (or omitting `deliver`) is rejected at startup — the adapter refuses to start if it finds a misconfigured route. - The `skills` field is ignored in direct delivery mode (no agent runs, so there's nothing to inject skills into). - Template rendering uses the same `{dot.notation}` syntax as agent mode, including the `{__raw__}` token. - Idempotency uses the same `X-GitHub-Delivery` / `X-Request-ID` header — retries with the same ID return `status=duplicate` and do NOT re-deliver. --- ## Dynamic Subscriptions (CLI) {#dynamic-subscriptions} In addition to static routes in `config.yaml`, you can create webhook subscriptions dynamically using the `claway webhook` CLI command. This is especially useful when the agent itself needs to set up event-driven triggers. ### Create a subscription ```bash claway webhook subscribe github-issues \ --events "issues" \ --prompt "New issue #{issue.number}: {issue.title}\nBy: {issue.user.login}\n\n{issue.body}" \ --deliver telegram \ --deliver-chat-id "-100123456789" \ --description "Triage new GitHub issues" ``` This returns the webhook URL and an auto-generated HMAC secret. Configure your service to POST to that URL. ### List subscriptions ```bash claway webhook list ``` ### Remove a subscription ```bash claway webhook remove github-issues ``` ### Test a subscription ```bash claway webhook test github-issues claway webhook test github-issues --payload '{"issue": {"number": 42, "title": "Test"}}' ``` ### How dynamic subscriptions work - Subscriptions are stored in `~/.claway/webhook_subscriptions.json` - The webhook adapter hot-reloads this file on each incoming request (mtime-gated, negligible overhead) - Static routes from `config.yaml` always take precedence over dynamic ones with the same name - Dynamic subscriptions use the same route format and capabilities as static routes (events, prompt templates, skills, delivery) - No gateway restart required — subscribe and it's immediately live ### Agent-driven subscriptions The agent can create subscriptions via the terminal tool when guided by the `webhook-subscriptions` skill. Ask the agent to "set up a webhook for GitHub issues" and it will run the appropriate `claway webhook subscribe` command. --- ## Security {#security} The webhook adapter includes multiple layers of security: ### HMAC signature validation The adapter validates incoming webhook signatures using the appropriate method for each source: - **GitHub**: `X-Hub-Signature-256` header — HMAC-SHA256 hex digest prefixed with `sha256=` - **GitLab**: `X-Gitlab-Token` header — plain secret string match - **Generic**: `X-Webhook-Signature` header — raw HMAC-SHA256 hex digest - **Bearer**: `Authorization: Bearer ` — plain secret match (for HTTP clients without a signing step, such as n8n's HTTP Request node) If a secret is configured but no recognized signature header is present, the request is rejected. ### Secret is required Every route must have a secret — either set directly on the route or inherited from the global `secret`. Routes without a secret cause the adapter to fail at startup with an error. For development/testing only, you can set the secret to `"INSECURE_NO_AUTH"` to skip validation entirely. `INSECURE_NO_AUTH` is only accepted when the gateway is bound to a loopback host (`127.0.0.1`, `localhost`, `::1`). If it is combined with a non-loopback bind such as `0.0.0.0` or a LAN IP, the adapter refuses to start — this prevents accidentally exposing an unauthenticated endpoint on a public interface. ### Rate limiting Each route is rate-limited to **30 requests per minute** by default (fixed-window). Configure this globally: ```yaml platforms: webhook: extra: rate_limit: 60 # requests per minute ``` Requests exceeding the limit receive a `429 Too Many Requests` response. ### Idempotency Delivery IDs (from `X-GitHub-Delivery`, `svix-id`, `X-Request-ID`, or a random per-request fallback) are cached for **1 hour**. Duplicate deliveries (e.g. webhook retries) are silently skipped with a `200` response, preventing duplicate agent runs. ### Body size limits Payloads exceeding **1 MB** are rejected before the body is read. Configure this: ```yaml platforms: webhook: extra: max_body_bytes: 2097152 # 2 MB ``` ### Authenticated does not mean trusted :::warning **HMAC validation authenticates the _sender_, not the _content_.** A valid signature only proves the request came from a party holding the route's secret (e.g. GitHub). It says nothing about who wrote the _business fields_ inside the payload — PR titles, commit messages, issue descriptions, and any other upstream text are authored by arbitrary third parties and must be treated as untrusted. This is the same trust model that applies to everything the agent reads: web pages, files, and tool output are all untrusted input. Claway does not — and cannot reliably — sanitize untrusted text with a blocklist; phrasing, encoding, and translation make that trivially bypassable. **The trust boundary is the agent's capability surface, not the input channel.** Harden there: - **Sandbox the runtime.** Run the gateway with the Docker or SSH terminal backend (or in a VM) when exposed to the internet, so a hijacked turn cannot touch the host. - **Scope the toolset.** Disable `terminal`, `file`, and outbound-action tools on webhook-triggered sessions if the route only needs to read and summarize. Fewer capabilities means a smaller blast radius if a payload field carries injected instructions. - **Keep approvals on** for any destructive or outbound operation, so an injected instruction cannot act unattended. - **Template narrowly.** Prefer a specific `prompt` with named fields (`{pull_request.title}`) over `{__raw__}` or an empty template that dumps the whole payload, so only the fields you intend reach the prompt. ::: --- ## Troubleshooting {#troubleshooting} ### Webhook not arriving - On a Box or hosted server, a `503 {"error": "connector_not_enabled"}` answer means the Webhook connector is off, or its port was changed from 8644: fix it in **OPS → Connectors → Webhook** - Verify the URL path matches: `https:///webhooks/` (hosted: `http://:8443/webhooks/`; own install: `http://:8644/webhooks/`) - On your own install, check firewall rules: port `8644` (or your configured port) must be reachable from the webhook source - Use the `/health` endpoint on the machine (`curl http://127.0.0.1:8644/health`) to confirm the connector is running ### Signature validation failing - Ensure the secret in your route config exactly matches the secret configured in the webhook source - For GitHub, the secret is HMAC-based — check `X-Hub-Signature-256` - For GitLab, the secret is a plain token match — check `X-Gitlab-Token` - Check gateway logs for `Invalid signature` warnings ### Event being ignored - Check that the event type is in your route's `events` list - GitHub events use values like `pull_request`, `push`, `issues` (the `X-GitHub-Event` header value) - GitLab events use values like `merge_request`, `push` (the `X-GitLab-Event` header value) - If `events` is empty or not set, all events are accepted ### Agent not responding - Run the gateway in foreground to see logs: `claway gateway run` - Check that the prompt template is rendering correctly - Verify the delivery target is configured and connected ### Duplicate responses - The idempotency cache should prevent this — check that the webhook source is sending a delivery ID header (`X-GitHub-Delivery` or `X-Request-ID`) - Delivery IDs are cached for 1 hour ### `gh` CLI errors (GitHub comment delivery) - Run `gh auth login` on the gateway host - Ensure the authenticated GitHub user has write access to the repository - Check that `gh` is installed and on the PATH --- ## Environment Variables {#environment-variables} | Variable | Description | Default | |----------|-------------|---------| | `WEBHOOK_ENABLED` | Enable the webhook platform adapter | `false` | | `WEBHOOK_PORT` | HTTP server port for receiving webhooks | `8644` | | `WEBHOOK_SECRET` | Global secret (used as fallback when routes don't specify their own); 16+ characters also enables the built-in `agent` route | _(none)_ | --- # API Server # API Server The API server exposes your Claway agent as an OpenAI-compatible HTTP API. Any client that speaks the OpenAI format (n8n's *OpenAI Chat Model* and *AI Agent* nodes, Open WebUI, LobeChat, LibreChat, the OpenAI SDKs, ...) can use the agent as if it were a model. The agent answers with its full toolset (web search, files, memory, skills, terminal) and returns the final response. When streaming, tool progress appears inline so clients can show what the agent is doing. ## On a Claway Box or hosted Claway {#claway-box} 1. In OPS, open **Connectors → API server**, run the setup wizard and set the **API key**: at least 16 random characters (for example the output of `openssl rand -hex 32`). It is stored as `API_SERVER_KEY`; the API server does not start without a strong key. 2. Leave the listener host at `127.0.0.1` and the port at `8642`. The address in front forwards `/v1/` to it **without** the OPS login, and the API server checks the Bearer key on every `/v1/*` call. | Where Claway runs | Base URL | |---|---| | Claway Box | `https:///v1` | | Hosted Claway | `http://:8443/v1` | While the connector is off, the base URL answers `503 {"error": "connector_not_enabled", ...}`. ```bash curl -k https:///v1/chat/completions \ -H "Authorization: Bearer $API_SERVER_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "claway", "messages": [{"role": "user", "content": "Hello!"}]}' ``` (`-k` accepts the Box's self-signed certificate; on hosted Claway use `http://:8443/v1/...` without `-k`.) Only the `/v1/*` endpoints are reachable through that address. The [Jobs](#jobs-api-background-scheduled-work) and [Sessions](#sessions-api-session-control-over-rest) APIs under `/api/` and the `/health` endpoints are served on the machine itself (`http://127.0.0.1:8642`); use `/v1/health` from outside. ### n8n {#n8n} - **OpenAI Chat Model / AI Agent nodes:** create an *OpenAI* credential with **API Key** = your `API_SERVER_KEY` and **Base URL** = `https:///v1` (hosted: `http://:8443/v1`). Pick the model the node lists (`claway`, or your profile name). - **HTTP Request node:** `POST https:///v1/chat/completions` with `Authorization: Bearer `. - **Box certificate:** the Box's certificate is self-signed. The HTTP Request node has *Ignore SSL Issues*; for the OpenAI credential, start n8n with `NODE_EXTRA_CA_CERTS` pointing at the Box certificate (or, on a trusted LAN only, `NODE_TLS_REJECT_UNAUTHORIZED=0`). - For a plain "send a message, get the answer" call without the OpenAI shape, use the webhook connector's [built-in `agent` route](../messaging/webhooks.md#agent-route). ## On your own install {#quick-start} ### 1. Enable the API server Add to `~/.claway/.env`: ```bash API_SERVER_ENABLED=true API_SERVER_KEY=<16+ random characters> # Optional: only if a browser must call Claway directly # API_SERVER_CORS_ORIGINS=http://localhost:3000 ``` ### 2. Start the gateway ```bash claway gateway ``` You'll see: ``` [API Server] API server listening on http://127.0.0.1:8642 ``` ### 3. Connect a client Point any OpenAI-compatible client at `http://localhost:8642/v1`: ```bash curl http://localhost:8642/v1/chat/completions \ -H "Authorization: Bearer $API_SERVER_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "claway", "messages": [{"role": "user", "content": "Hello!"}]}' ``` Or connect Open WebUI, LobeChat, or any other frontend; see the [Open WebUI integration guide](/user-guide/messaging/open-webui) for step-by-step instructions. ## Endpoints ### POST /v1/chat/completions Standard OpenAI Chat Completions format. Stateless — the full conversation is included in each request via the `messages` array. **Request:** ```json { "model": "claway", "messages": [ {"role": "system", "content": "You are a Python expert."}, {"role": "user", "content": "Write a fibonacci function"} ], "stream": false } ``` **Response:** ```json { "id": "chatcmpl-abc123", "object": "chat.completion", "created": 1710000000, "model": "claway", "choices": [{ "index": 0, "message": {"role": "assistant", "content": "Here's a fibonacci function..."}, "finish_reason": "stop" }], "usage": {"prompt_tokens": 50, "completion_tokens": 200, "total_tokens": 250} } ``` **Inline image input:** user messages may send `content` as an array of `text` and `image_url` parts. Both remote `http(s)` URLs and `data:image/...` URLs are supported: ```json { "model": "claway", "messages": [ { "role": "user", "content": [ {"type": "text", "text": "What is in this image?"}, {"type": "image_url", "image_url": {"url": "https://example.com/cat.png", "detail": "high"}} ] } ] } ``` Uploaded files (`file` / `input_file` / `file_id`) and non-image `data:` URLs return `400 unsupported_content_type`. **Streaming** (`"stream": true`): Returns Server-Sent Events (SSE) with token-by-token response chunks. For **Chat Completions**, the stream uses standard `chat.completion.chunk` events plus Claway's custom `claway.tool.progress` event for tool-start UX. For **Responses**, the stream uses OpenAI Responses event types such as `response.created`, `response.output_text.delta`, `response.output_item.added`, `response.output_item.done`, and `response.completed`. **Tool progress in streams**: - **Chat Completions**: Claway emits `event: claway.tool.progress` for tool-start visibility without polluting persisted assistant text. - **Responses**: Claway emits spec-native `function_call` and `function_call_output` output items during the SSE stream, so clients can render structured tool UI in real time. ### POST /v1/responses OpenAI Responses API format. Supports server-side conversation state via `previous_response_id` — the server stores full conversation history (including tool calls and results) so multi-turn context is preserved without the client managing it. **Request:** ```json { "model": "claway", "input": "What files are in my project?", "instructions": "You are a helpful coding assistant.", "store": true } ``` **Response:** ```json { "id": "resp_abc123", "object": "response", "status": "completed", "model": "claway", "output": [ {"type": "function_call", "name": "terminal", "arguments": "{\"command\": \"ls\"}", "call_id": "call_1"}, {"type": "function_call_output", "call_id": "call_1", "output": "README.md src/ tests/"}, {"type": "message", "role": "assistant", "content": [{"type": "output_text", "text": "Your project has..."}]} ], "usage": {"input_tokens": 50, "output_tokens": 200, "total_tokens": 250} } ``` **Inline image input:** `input[].content` can contain `input_text` and `input_image` parts. Both remote URLs and `data:image/...` URLs are supported: ```json { "model": "claway", "input": [ { "role": "user", "content": [ {"type": "input_text", "text": "Describe this screenshot."}, {"type": "input_image", "image_url": "data:image/png;base64,iVBORw0K..."} ] } ] } ``` Uploaded files (`input_file` / `file_id`) and non-image `data:` URLs return `400 unsupported_content_type`. #### Multi-turn with previous_response_id Chain responses to maintain full context (including tool calls) across turns: ```json { "input": "Now show me the README", "previous_response_id": "resp_abc123" } ``` The server reconstructs the full conversation from the stored response chain — all previous tool calls and results are preserved. Chained requests also share the same session, so multi-turn conversations appear as a single entry in the dashboard and session history. #### Named conversations Use the `conversation` parameter instead of tracking response IDs: ```json {"input": "Hello", "conversation": "my-project"} {"input": "What's in src/?", "conversation": "my-project"} {"input": "Run the tests", "conversation": "my-project"} ``` The server automatically chains to the latest response in that conversation. Like the `/title` command for gateway sessions. ### GET /v1/responses/\{id\} Retrieve a previously stored response by ID. ### DELETE /v1/responses/\{id\} Delete a stored response. ### GET /v1/models Lists the agent as an available model. The advertised model name defaults to the [profile](/user-guide/profiles) name (or `claway` for the default profile). Required by most frontends for model discovery. ### GET /v1/capabilities Returns a machine-readable description of the API server's stable surface for external UIs, orchestrators, and plugin bridges. ```json { "object": "claway.api_server.capabilities", "platform": "claway", "model": "claway", "auth": {"type": "bearer", "required": true}, "features": { "chat_completions": true, "responses_api": true, "run_submission": true, "run_status": true, "run_events_sse": true, "run_stop": true } } ``` Use this endpoint when integrating dashboards, browser UIs, or control planes so they can discover whether the running Claway version supports runs, streaming, cancellation, and session continuity without depending on private Python internals. ### GET /health Health check. Returns `{"status": "ok"}`. Also available at **GET /v1/health** for OpenAI-compatible clients that expect the `/v1/` prefix. ### GET /health/detailed Extended health check that also reports active sessions, running agents, and resource usage. Useful for monitoring/observability tooling. ## Runs API (streaming-friendly alternative) In addition to `/v1/chat/completions` and `/v1/responses`, the server exposes a **runs** API for long-form sessions where the client wants to subscribe to progress events instead of managing streaming themselves. ### POST /v1/runs Create a new agent run. Returns a `run_id` that can be used to subscribe to progress events. ```json { "run_id": "run_abc123", "status": "started" } ``` Runs accept a simple `input` string and optional `session_id`, `instructions`, `conversation_history`, or `previous_response_id`. When `session_id` is provided, Claway surfaces it in the run status so external UIs can correlate runs with their own conversation IDs. ### GET /v1/runs/\{run_id\} Poll the current run state. This is useful for dashboards that need status without holding an SSE connection open, or for UIs that reconnect after navigation. ```json { "object": "claway.run", "run_id": "run_abc123", "status": "completed", "session_id": "space-session", "model": "claway", "output": "Done.", "usage": {"input_tokens": 50, "output_tokens": 200, "total_tokens": 250} } ``` Statuses are retained briefly after terminal states (`completed`, `failed`, or `cancelled`) for polling and UI reconciliation. ### GET /v1/runs/\{run_id\}/events Server-Sent Events stream of the run's tool-call progress, token deltas, and lifecycle events. Designed for dashboards and thick clients that want to attach/detach without losing state. ### POST /v1/runs/\{run_id\}/stop Interrupt a running agent turn. The endpoint returns immediately with `{"status": "stopping"}` while Claway asks the active agent to stop at the next safe interruption point. ### POST /v1/runs/\{run_id\}/approval Resolve a pending approval for a run that is waiting on a human decision (for example, a tool call gated behind an approval policy). The body carries the approval decision; the run resumes once the decision is recorded. This endpoint is advertised in `/v1/capabilities` as the `run_approval` feature so external UIs can detect support before surfacing an approval prompt. ## Jobs API (background scheduled work) The server exposes a lightweight jobs CRUD surface for managing scheduled / background agent runs from a remote client. All endpoints are gated behind the same bearer auth. ### GET /api/jobs List all scheduled jobs. ### POST /api/jobs Create a new scheduled job. Body accepts the same shape as `claway cron` — prompt, schedule, skills, provider override, delivery target. ### GET /api/jobs/\{job_id\} Fetch a single job's definition and last-run state. ### PATCH /api/jobs/\{job_id\} Update fields on an existing job (prompt, schedule, etc.). Partial updates are merged. ### DELETE /api/jobs/\{job_id\} Remove a job. Also cancels any in-flight run. ### POST /api/jobs/\{job_id\}/pause Pause a job without deleting it. Next-scheduled-run timestamps are suspended until resumed. ### POST /api/jobs/\{job_id\}/resume Resume a previously paused job. ### POST /api/jobs/\{job_id\}/run Trigger the job to run immediately, out of schedule. ## Sessions API (session control over REST) External UIs can manage Claway sessions over REST without standing up the dashboard. All endpoints are gated by `API_SERVER_KEY` and live under `/api/sessions/*`. | Method | Path | Description | |--------|------|-------------| | `GET` | `/api/sessions` | List sessions (paginated — `limit`, `offset`, `source`, `include_children`) | | `POST` | `/api/sessions` | Create an empty session | | `GET` | `/api/sessions/{id}` | Read session metadata | | `PATCH` | `/api/sessions/{id}` | Update title or `end_reason` | | `DELETE` | `/api/sessions/{id}` | Delete a session | | `GET` | `/api/sessions/{id}/messages` | Message history for a session | | `POST` | `/api/sessions/{id}/fork` | Branch the session via `SessionDB` lineage (matches CLI `/branch` semantics) | | `POST` | `/api/sessions/{id}/chat` | Run one synchronous agent turn | | `POST` | `/api/sessions/{id}/chat/stream` | SSE wrapper over a single turn — emits `assistant.delta`, `tool.started`, `tool.completed`, `run.completed` events | `/v1/capabilities` advertises the full surface via `session_*` feature flags and `endpoints.session_*` entries so external UIs can detect support and fall back safely. Inline images are supported in `chat` and `chat/stream` payloads (multimodal-aware path). ```bash # fork a session and run one turn curl -X POST http://localhost:8642/api/sessions/$ID/fork \ -H "Authorization: Bearer $API_SERVER_KEY" \ -d '{"title": "explore alt path"}' # stream a turn over SSE curl -N -X POST http://localhost:8642/api/sessions/$ID/chat/stream \ -H "Authorization: Bearer $API_SERVER_KEY" \ -d '{"input": "what files changed in the last hour?"}' ``` ## Skills and toolsets discovery `GET /v1/skills` and `GET /v1/toolsets` let external clients enumerate the agent's capabilities deterministically over REST instead of asking the model. Both are read-only and gated by `API_SERVER_KEY`. ```bash curl http://localhost:8642/v1/skills \ -H "Authorization: Bearer $API_SERVER_KEY" # → [{"name": "github-pr-workflow", "description": "...", "category": "..."}, ...] curl http://localhost:8642/v1/toolsets \ -H "Authorization: Bearer $API_SERVER_KEY" # → [{"name": "core", "label": "...", "description": "...", "enabled": true, # "configured": true, "tools": ["read_file", "write_file", ...]}, ...] ``` `/v1/skills` returns the same metadata the skills hub uses internally. `/v1/toolsets` returns toolsets resolved for the `api_server` platform with the concrete `tools` list each one expands to. Both are advertised under `endpoints.*` in `/v1/capabilities`. ## Long-term memory scoping (`X-Claway-Session-Key`) Multi-user frontends like Open WebUI need a stable per-channel identifier for long-term memory (Honcho, etc.) that is **independent** of the transcript-scoped `X-Claway-Session-Id` (which rotates on `/new`). Pass `X-Claway-Session-Key` on `/v1/chat/completions`, `/v1/responses`, or `/v1/runs` and Claway threads it through to `AIAgent(gateway_session_key=...)`, where the Honcho memory provider uses it to derive a stable scope. ```http POST /v1/chat/completions HTTP/1.1 Authorization: Bearer *** X-Claway-Session-Id: transcript-alpha X-Claway-Session-Key: agent:main:webui:dm:user-42 ``` Rules: max 256 chars, control characters (`\r`, `\n`, `\x00`) are rejected, and the value is echoed back on responses (JSON + SSE). `/v1/capabilities` advertises support via `"session_key_header": "X-Claway-Session-Key"`. Without the key, Honcho's `per-session` strategy produces a different scope per `session_id` — exactly the behavior Claway had before. ## System Prompt Handling When a frontend sends a `system` message (Chat Completions) or `instructions` field (Responses API), claway **layers it on top** of its core system prompt. Your agent keeps all its tools, memory, and skills — the frontend's system prompt adds extra instructions. This means you can customize behavior per-frontend without losing capabilities: - Open WebUI system prompt: "You are a Python expert. Always include type hints." - The agent still has terminal, file tools, web search, memory, etc. ## Authentication Bearer token auth via the `Authorization` header: ``` Authorization: Bearer *** ``` Configure the key via `API_SERVER_KEY` env var. If you need a browser to call Claway directly, also set `API_SERVER_CORS_ORIGINS` to an explicit allowlist. :::warning Security The API server gives full access to claway's toolset, **including terminal commands**. `API_SERVER_KEY` is **required for every deployment**, including the default loopback bind on `127.0.0.1`. Keep `API_SERVER_CORS_ORIGINS` narrow to control browser access when you explicitly allow browser callers. ::: ## Configuration ### Environment Variables | Variable | Default | Description | |----------|---------|-------------| | `API_SERVER_ENABLED` | `false` | Enable the API server | | `API_SERVER_PORT` | `8642` | HTTP server port | | `API_SERVER_HOST` | `127.0.0.1` | Bind address (localhost only by default) | | `API_SERVER_KEY` | _(required)_ | Bearer token for auth; at least 16 characters and not a placeholder, or the server refuses to start | | `API_SERVER_CORS_ORIGINS` | _(none)_ | Comma-separated allowed browser origins | | `API_SERVER_MODEL_NAME` | _(profile name)_ | Model name on `/v1/models`. Defaults to profile name, or `claway` for default profile. | ### config.yaml The same settings can also go under `platforms.api_server` in `config.yaml` (`enabled`, and `port`, `host`, `cors_origins`, `model_name` under `extra`). Environment variables win over `config.yaml`. Keep the key itself in `.env`: it is a secret. ```yaml platforms: api_server: enabled: true extra: port: 8642 host: 127.0.0.1 ``` ## Security Headers All responses include security headers: - `X-Content-Type-Options: nosniff` — prevents MIME type sniffing - `Referrer-Policy: no-referrer` — prevents referrer leakage ## CORS The API server does **not** enable browser CORS by default. For direct browser access, set an explicit allowlist: ```bash API_SERVER_CORS_ORIGINS=http://localhost:3000,http://127.0.0.1:3000 ``` When CORS is enabled: - **Preflight responses** include `Access-Control-Max-Age: 600` (10 minute cache) - **SSE streaming responses** include CORS headers so browser EventSource clients work correctly - **`Idempotency-Key`** is an allowed request header — clients can send it for deduplication (responses are cached by key for 5 minutes) Most documented frontends such as Open WebUI connect server-to-server and do not need CORS at all. ## Compatible Frontends Any client that supports the OpenAI API format works, for example: | Frontend | Connection | |----------|------------| | [Open WebUI](/user-guide/messaging/open-webui) | Full guide available | | LobeChat | Custom provider endpoint | | LibreChat | Custom endpoint in librechat.yaml | | AnythingLLM | Generic OpenAI provider | | NextChat | BASE_URL env var | | ChatBox | API Host setting | | Jan | Remote model config | | HF Chat-UI | OPENAI_BASE_URL | | big-AGI | Custom endpoint | | n8n | OpenAI credential with a custom Base URL, see [n8n](#n8n) | | OpenAI Python SDK | `OpenAI(base_url="https:///v1", api_key=...)` | | curl | Direct HTTP requests | ## Multi-User Setup with Profiles To give multiple users their own isolated Claway instance (separate config, memory, skills), use [profiles](/user-guide/profiles): ```bash # Create a profile per user claway profile create alice claway profile create bob # Configure each profile's API server on a different port. API_SERVER_* are env # vars, so write them to each profile's .env (keys: 16+ random characters): cat >> ~/.claway/profiles/alice/.env <> ~/.claway/profiles/bob/.env < # Open WebUI # Open WebUI Integration [Open WebUI](https://github.com/open-webui/open-webui) (126k★) is the most popular self-hosted chat interface for AI. With Claway Agent's built-in API server, you can use Open WebUI as a polished web frontend for your agent — complete with conversation management, user accounts, and a modern chat interface. ## Architecture ```mermaid flowchart LR A["Open WebUI
browser UI
port 3000"] B["claway
gateway API server
port 8642"] A -->|POST /v1/chat/completions| B B -->|SSE streaming response| A ``` Open WebUI connects to Claway Agent's API server just like it would connect to OpenAI. Claway handles the requests with its full toolset — terminal, file operations, web search, memory, skills — and returns the final response. :::important Runtime location The API server is a **Claway agent runtime**, not a pure LLM proxy. For each request, Claway creates a server-side `AIAgent` on the API-server host. Tool calls run where that API server is running. For example, if a laptop points Open WebUI or another OpenAI-compatible client at a Claway API server on a remote machine, `pwd`, file tools, browser tools, local MCP tools, and other workspace tools run on the remote API-server host, not on the laptop. ::: Open WebUI talks to Claway server-to-server, so you do not need `API_SERVER_CORS_ORIGINS` for this integration. ## Quick Setup ### 1. Enable the API server ```bash claway config set API_SERVER_ENABLED true claway config set API_SERVER_KEY your-secret-key ``` `claway config set` auto-routes the flag to `config.yaml` and the secret to `~/.claway/.env`. If the gateway is already running, restart it so the change takes effect: ```bash claway gateway stop && claway gateway ``` ### 2. Start Claway Agent gateway ```bash claway gateway ``` You should see: ``` [API Server] API server listening on http://127.0.0.1:8642 ``` ### 3. Verify the API server is reachable ```bash curl -s http://127.0.0.1:8642/health # {"status": "ok", ...} curl -s -H "Authorization: Bearer your-secret-key" http://127.0.0.1:8642/v1/models # {"object":"list","data":[{"id":"claway", ...}]} ``` If `/health` fails, the gateway didn't pick up `API_SERVER_ENABLED=true` — restart it. If `/v1/models` returns `401`, your `Authorization` header doesn't match `API_SERVER_KEY`. ### 4. Start Open WebUI ```bash docker run -d -p 3000:8080 \ -e OPENAI_API_BASE_URL=http://host.docker.internal:8642/v1 \ -e OPENAI_API_KEY=your-secret-key \ -e ENABLE_OLLAMA_API=false \ --add-host=host.docker.internal:host-gateway \ -v open-webui:/app/backend/data \ --name open-webui \ --restart always \ ghcr.io/open-webui/open-webui:main ``` `ENABLE_OLLAMA_API=false` suppresses the default Ollama backend, which would otherwise show up empty and clutter the model picker. Omit it if you actually have Ollama running alongside. First launch takes 15–30 seconds: Open WebUI downloads sentence-transformer embedding models (~150MB) the first time it starts. Wait for `docker logs open-webui` to settle before opening the UI. ### 5. Open the UI Go to **http://localhost:3000**. Create your admin account (the first user becomes admin). You should see your agent in the model dropdown (named after your profile, or **claway** for the default profile). Start chatting! ## Docker Compose Setup For a more permanent setup, create a `docker-compose.yml`: ```yaml services: open-webui: image: ghcr.io/open-webui/open-webui:main ports: - "3000:8080" volumes: - open-webui:/app/backend/data environment: - OPENAI_API_BASE_URL=http://host.docker.internal:8642/v1 - OPENAI_API_KEY=your-secret-key - ENABLE_OLLAMA_API=false extra_hosts: - "host.docker.internal:host-gateway" restart: always volumes: open-webui: ``` Then: ```bash docker compose up -d ``` ## Configuring via the Admin UI If you prefer to configure the connection through the UI instead of environment variables: 1. Log in to Open WebUI at **http://localhost:3000** 2. Click your **profile avatar** → **Admin Settings** 3. Go to **Connections** 4. Under **OpenAI API**, click the **wrench icon** (Manage) 5. Click **+ Add New Connection** 6. Enter: - **URL**: `http://host.docker.internal:8642/v1` - **API Key**: the exact same value as `API_SERVER_KEY` in Claway 7. Click the **checkmark** to verify the connection 8. **Save** Your agent model should now appear in the model dropdown (named after your profile, or **claway** for the default profile). :::warning Environment variables only take effect on Open WebUI's **first launch**. After that, connection settings are stored in its internal database. To change them later, use the Admin UI or delete the Docker volume and start fresh. ::: ## API Type: Chat Completions vs Responses Open WebUI supports two API modes when connecting to a backend: | Mode | Format | When to use | |------|--------|-------------| | **Chat Completions** (default) | `/v1/chat/completions` | Recommended. Works out of the box. | | **Responses** (experimental) | `/v1/responses` | For server-side conversation state via `previous_response_id`. | ### Using Chat Completions (recommended) This is the default and requires no extra configuration. Open WebUI sends standard OpenAI-format requests and Claway Agent responds accordingly. Each request includes the full conversation history. ### Using Responses API To use the Responses API mode: 1. Go to **Admin Settings** → **Connections** → **OpenAI** → **Manage** 2. Edit your claway connection 3. Change **API Type** from "Chat Completions" to **"Responses (Experimental)"** 4. Save With the Responses API, Open WebUI sends requests in the Responses format (`input` array + `instructions`), and Claway Agent can preserve full tool call history across turns via `previous_response_id`. When `stream: true`, Claway also streams spec-native `function_call` and `function_call_output` items, which enables custom structured tool-call UI in clients that render Responses events. :::note Open WebUI currently manages conversation history client-side even in Responses mode — it sends the full message history in each request rather than using `previous_response_id`. The main advantage of Responses mode today is the structured event stream: text deltas, `function_call`, and `function_call_output` items arrive as OpenAI Responses SSE events instead of Chat Completions chunks. ::: ## How It Works When you send a message in Open WebUI: 1. Open WebUI sends a `POST /v1/chat/completions` request with your message and conversation history 2. Claway Agent creates a server-side `AIAgent` instance using the API server's profile, model/provider config, memory, skills, and configured API-server toolsets 3. The agent processes your request — it may call tools (terminal, file operations, web search, etc.) on the API-server host 4. As tools execute, **inline progress messages stream to the UI** so you can see what the agent is doing (e.g. `` `💻 ls -la` ``, `` `🔍 Python 3.12 release` ``) 5. The agent's final text response streams back to Open WebUI 6. Open WebUI displays the response in its chat interface Your agent has access to the same tools and capabilities as that API-server Claway instance. If the API server is remote, those tools are remote too. If you need tools to run against your **local** workspace today, run Claway locally and point it at a pure LLM provider or pure OpenAI-compatible model proxy (for example vLLM, LiteLLM, Ollama, llama.cpp, OpenAI, OpenRouter, etc.). A future split-runtime mode for "remote brain, local hands" is being tracked in #18715; it is not the behavior of the current API server. :::tip Tool Progress With streaming enabled (the default), you'll see brief inline indicators as tools run — the tool emoji and its key argument. These appear in the response stream before the agent's final answer, giving you visibility into what's happening behind the scenes. ::: ## Configuration Reference ### Claway Agent (API server) | Variable | Default | Description | |----------|---------|-------------| | `API_SERVER_ENABLED` | `false` | Enable the API server | | `API_SERVER_PORT` | `8642` | HTTP server port | | `API_SERVER_HOST` | `127.0.0.1` | Bind address | | `API_SERVER_KEY` | _(required)_ | Bearer token for auth. Match `OPENAI_API_KEY`. | ### Open WebUI | Variable | Description | |----------|-------------| | `OPENAI_API_BASE_URL` | Claway Agent's API URL (include `/v1`) | | `OPENAI_API_KEY` | Must be non-empty. Match your `API_SERVER_KEY`. | ## Troubleshooting ### No models appear in the dropdown - **Check the URL has `/v1` suffix**: `http://host.docker.internal:8642/v1` (not just `:8642`) - **Verify the gateway is running**: `curl http://localhost:8642/health` should return `{"status": "ok"}` - **Check model listing**: `curl -H "Authorization: Bearer your-secret-key" http://localhost:8642/v1/models` should return a list with `claway` - **Docker networking**: From inside Docker, `localhost` means the container, not your host. Use `host.docker.internal` or `--network=host`. - **Empty Ollama backend shadowing the picker**: If you omitted `ENABLE_OLLAMA_API=false`, Open WebUI shows an empty Ollama section above your Claway models. Restart the container with `-e ENABLE_OLLAMA_API=false` or disable Ollama in **Admin Settings → Connections**. ### Connection test passes but no models load This is almost always the missing `/v1` suffix. Open WebUI's connection test is a basic connectivity check — it doesn't verify model listing works. ### Response takes a long time Claway Agent may be executing multiple tool calls (reading files, running commands, searching the web) before producing its final response. This is normal for complex queries. The response appears all at once when the agent finishes. ### "Invalid API key" errors Make sure your `OPENAI_API_KEY` in Open WebUI matches the `API_SERVER_KEY` in Claway Agent. :::warning Open WebUI persists OpenAI-compatible connection settings in its own database after first launch. If you accidentally saved a wrong key in the Admin UI, fixing the environment variables alone is not enough — update or delete the saved connection in **Admin Settings → Connections**, or reset the Open WebUI data directory / database. ::: ## Multi-User Setup with Profiles To run separate Claway instances per user — each with their own config, memory, and skills — use [profiles](/user-guide/profiles). Each profile runs its own API server on a different port and automatically advertises the profile name as the model in Open WebUI. ### 1. Create profiles and configure API servers `API_SERVER_*` are env vars, not YAML config keys, so write them to each profile's `.env`. Pick ports outside the default-platform range (`8644` is the webhook adapter, `8645` is wecom-callback, `8646` is msgraph-webhook), e.g. `8650+`: ```bash claway profile create alice cat >> ~/.claway/profiles/alice/.env <> ~/.claway/profiles/bob/.env < # Programmatic Integration # Programmatic Integration Claway ships three protocols for driving the agent from external programs — IDE plugins, custom UIs, CI pipelines, embedded sub-agents. Pick the one that matches your transport and consumer. | Protocol | Transport | Best for | Defined by | |----------|-----------|----------|------------| | **ACP** | JSON-RPC over stdio | IDE clients (VS Code, Zed, JetBrains) that already speak the [Agent Client Protocol](https://github.com/zed-industries/agent-client-protocol) | `acp_adapter/` | | **TUI gateway** | JSON-RPC over stdio (or WebSocket) | Custom hosts that want fine-grained control of sessions, slash commands, approvals, and streaming events | `tui_gateway/server.py` | | **API server** | HTTP + Server-Sent Events | OpenAI-compatible frontends (Open WebUI, LobeChat, LibreChat…) and language-agnostic web clients | `gateway/platforms/api_server.py` | All three drive the same `AIAgent` core. They differ only in wire format and which set of features they expose. --- ## ACP (Agent Client Protocol) `claway acp` starts a stdio JSON-RPC server speaking ACP. Used in production by VS Code (Zed Industries' ACP extension), Zed, and any JetBrains IDE with an ACP plugin. Capabilities exposed: session creation, prompt submission, streaming agent message chunks, tool-call events, permission requests, session fork, cancel, and authentication. Tool output is rendered into ACP `Diff`/`ToolCall` content blocks the IDE understands. Full lifecycle, event bridge, and approval flow: ACP Internals. ```bash claway acp # serve ACP on stdio claway acp --bootstrap # print install snippet for an ACP-capable IDE ``` --- ## TUI Gateway JSON-RPC `tui_gateway/server.py` is the protocol the Ink TUI (`claway --tui`) and the embedded dashboard PTY bridge talk to. Any external host can speak the same protocol over stdio (or WebSocket via `tui_gateway/ws.py`). ### Method catalog (selected) ``` prompt.submit prompt.background session.steer session.create session.list session.active_list session.activate session.close session.interrupt session.history session.compress session.branch session.title session.usage session.status clarify.respond sudo.respond secret.respond approval.respond config.set / config.get commands.catalog command.resolve command.dispatch cli.exec reload.mcp reload.env process.stop delegation.status subagent.interrupt spawn_tree.save / list / load terminal.resize clipboard.paste image.attach ``` `session.active_list`, `session.activate`, and `session.close` are the process-local live-session controls used by the TUI session switcher. Use `session.list` / `/resume` for saved transcript discovery; use the active-session methods only for sessions that are currently open in the TUI gateway process. ### Events streamed back `message.delta`, `message.complete`, `tool.start`, `tool.progress`, `tool.complete`, `approval.request`, `clarify.request`, `sudo.request`, `secret.request`, `gateway.ready`, plus session lifecycle and error events. ### Pi-style RPC mapping Every command in the Pi-mono RPC spec has a TUI-gateway equivalent: | Pi command | Claway equivalent | |------------|-------------------| | `prompt` | `prompt.submit` (or ACP `session/prompt`) | | `steer` | `session.steer` | | `follow_up` | `prompt.submit` queued after current turn | | `abort` | `session.interrupt` | | `set_model` | `command.dispatch` for `/model ` (mid-session, persistent) | | `compact` | `session.compress` | | `get_state` | `session.status` | | `get_messages` | `session.history` | | `switch_session` | `session.resume` | | `fork` | `session.branch` | | `ui_request` / `ui_response` | `clarify.respond` / `sudo.respond` / `secret.respond` / `approval.respond` | --- ## OpenAI-Compatible API Server `gateway/platforms/api_server.py` exposes claway over HTTP for any client that already speaks the OpenAI format. Useful when you want a web frontend, a curl-driven CI runner, or a non-Python consumer. Endpoints: ``` POST /v1/chat/completions OpenAI Chat Completions (streaming via SSE) POST /v1/responses OpenAI Responses API (stateful) POST /v1/runs Start a run, returns run_id (202) GET /v1/runs/{id} Run status GET /v1/runs/{id}/events SSE stream of lifecycle events POST /v1/runs/{id}/approval Resolve a pending approval POST /v1/runs/{id}/stop Interrupt the run GET /v1/capabilities Machine-readable feature flags GET /v1/models Lists claway GET /health, /health/detailed ``` Setup, headers (`X-Claway-Session-Id`, `X-Claway-Session-Key`), and frontend wiring: [API Server](../user-guide/features/api-server). --- ## Which one should I use? - **You're writing an IDE plugin and the IDE already speaks ACP** → ACP. Zero protocol work on the IDE side. - **You're writing a custom desktop / web / TUI host and want every Claway feature** (slash commands, approvals, clarify, multi-agent, session branching) → TUI gateway JSON-RPC. - **You want any OpenAI-compatible frontend, a language-agnostic HTTP client, or curl-driven automation** → API server. - **You want a Python in-process embed without a subprocess** → import `run_agent.AIAgent` directly. See Agent Loop. --- ## Model hot-swapping Mid-session model switching works on every surface — it's the `/model` slash command under the hood. - **CLI / TUI:** `/model claude-sonnet-4` or `/model openrouter:anthropic/claude-sonnet-4.6` - **TUI gateway RPC:** `command.dispatch` with `{"command": "/model claude-sonnet-4"}` - **ACP:** the IDE sends the slash command as a prompt; the agent dispatches it - **API server:** include a `model` field in the request body or set `X-Claway-Model` Provider-aware resolution (the same model name picks the right format for whatever provider you're on) is built in. See `claway_cli/model_switch.py`. --- ## A note on `--mode rpc` Claway does not have a `--mode rpc` flag. The three protocols above already cover the use cases — ACP for IDE-protocol clients, the TUI gateway for stdio JSON-RPC hosts, and the API server for HTTP. If you find a real gap that none of them fill, open an issue with the concrete consumer you're building. --- # Operator Guide # Operator Guide This section is for the person Blockway hands the dashboard URL to when a Claway deployment goes live. It answers the questions that come up in the first two weeks of operating a Jarvis for a team: 1. **[Getting started](/operators/getting-started)** — first login, TOTP setup, what each dashboard page is for. 2. **[Persona guide](/operators/persona-guide)** — how to write a persona that holds up in production, how the AI Assist helper works, why the "KB-first rule" matters. 3. **[Knowledge base guide](/operators/kb-guide)** — how to upload documents, how per-chat scoping works, the security model that keeps groups isolated. 4. **[WhatsApp group onboarding](/operators/whatsapp-onboarding)** — the five-step wizard for bringing a new group online without editing `config.yaml` by hand. 5. **[When to escalate](/operators/escalation)** — signals that mean call Blockway support instead of continuing to poke at it. ## Who this section is not for - If you're a Blockway engineer, you want the developer guide instead. - If you're the person **chatting with Jarvis** inside a WhatsApp group, ask your operator for the "End-user cheat sheet" — it's a one-page handout, not a docs section. ## The mental model in one paragraph One Claway deployment. One WhatsApp / Telegram / Signal bot account. Many groups, each running its own **persona** (an accounting clerk, a sales assistant, whatever the customer needs), each with its own **memory**, each with its own **skills** enabled, and each with its own **knowledge base scope**. Groups are isolated at the SQL level — a document in the "accounting" KB is never returned to the "customer service" group's agent. The operator dashboard is the single control surface. --- # Getting Started # Getting started as a Claway operator How you reach the dashboard (OPS) depends on how Claway runs for you: - **Claway Box**: `https:///`, the Box's address on your network. The first time, the Box asks you to activate it; see [Getting started with Claway](/getting-started#on-a-claway-box). - **Hosted Claway**: `http://:8443/`. Blockway sends you the address, your operator password and an authenticator QR code. If anything is missing, stop here and email `support@claway.io`. We can reissue the password and the authenticator QR code; do not share them. ## First login 1. Open the dashboard address in a fresh browser tab. On a Box, accept the browser's warning about the self-signed certificate for this address. 2. If you have not done so yet, scan the authenticator QR code into your authenticator app (1Password, Authy, Google Authenticator, iOS Passwords). If your app supports labels, name it "Claway ``" so you can find it later. 3. Enter the operator password and the current 6-digit code, and sign in. 4. Bookmark the dashboard address. ## A tour of the pages These are the pages you will use most, in roughly descending order. The sidebar has a few more (Upstream, Controls, Handoff, Tasks, Cost, SLO, Webhooks, Users, Settings): **Overview** — Hero stats: active sessions right now, messages per minute across all groups, the top three chats by volume today, most recent errors. This is where you land after login; if nothing looks alarming here, the rest of the pages can wait. **Events** — WebSocket tail of everything the gateway is doing — inbound messages, agent runs, adapter state changes. Filter box supports substring matching against chat name, initiator, or action type. Useful when a customer says "Jarvis didn't reply to my message thirty seconds ago" and you want to see why. **Conversations** — Per-chat timeline. Shows the agent's decision tree (what tool it called, what the tool returned, what the model said next), token usage per turn. Open this when a specific reply looked wrong; it is usually the fastest way to spot a persona rule that fired incorrectly. **Sessions** — Recent agent sessions across all platforms. You can kill any session from here — useful if an agent gets stuck in a compression loop or starts loitering on a topic. Killing a session ends its short-term context window; the next inbound message starts fresh. **Personas** — The heart of your job. One row per WhatsApp group. Clicking into a row opens a seven-tab editor: Identity, Skills, KB, Memory, Token usage, Files, History. See the [persona guide](/operators/persona-guide) for the deep dive. **Skills** — The global skill catalog. You can toggle a skill on or off platform-wide, view what it does, and (from within a Persona) restrict which skills a specific group is allowed to invoke. **KB** — Named knowledge-base collections. Create a collection, drop PDFs into it, then attach the collection to whichever groups are allowed to search it. Full details in the [KB guide](/operators/kb-guide). **Memory** — Per-chat `MEMORY.md` files. You can view and edit them with a diff preview. Rare to touch these directly — usually you'd let Jarvis manage its own memory — but useful when correcting a rememberd-incorrectly fact. **Connectors** — The 31 messaging platforms Claway supports (WhatsApp, Telegram, Discord, Slack, Signal, BlueBubbles, Line, Teams, Email, …). Each row shows live health and has a **Setup wizard** button for the initial connect + a **Manage** dialog for day-to-day tweaks. The WhatsApp QR re-pair lives here — if you see the bridge stuck in `AwaitingInitialSync`, this is where you fix it. **Metrics** — Token spend, latency p50/p95, fallback chain hits, embedding and rerank call counts. Useful for capacity planning and for the month-end conversation with Blockway. **Alerts** — Subscriptions delivered via Telegram. Sensible defaults are already wired ("gateway down", "compression failure spike", "a chat has been silent for N hours"). Add tenant-specific ones from here. **System** — Gateway, dashboard, and KB worker service health. Environment variable sanity checks (`JARVIS_KB_DB_URL`, `OPENAI_BASE_URL`, …). One-click restart for each service. The **Env** panel here is the first thing to look at when a KB upload silently fails or Jarvis says "I don't have kb_search". **Audit** — Every write action (persona edit, KB upload, scope change) is logged here with initiator and payload. `Export CSV` streams the log for a date range — enterprise procurement or legal will ask for this eventually. ## Housekeeping in your first week - Add a real email under **System → Support contact** so alerts have somewhere to reply to. - Subscribe your on-call Telegram account to at least the "gateway down" alert. - Do one end-to-end test: send a message from an allow-listed group, watch it appear in Live Events, confirm Jarvis replies. - Book fifteen minutes with Blockway to walk through your first persona. Anything else: email support@claway.io. --- # Persona guide # Persona guide A **persona** is the block of natural-language instructions that tells Jarvis who they are in this specific WhatsApp group. It overrides the base system prompt, so it can — and should — be opinionated. You edit personas from the **Personas** page → click a group → **Identity** tab. The big textarea is your working canvas. Save writes to `platforms.whatsapp.extra.channel_prompts.` in `config.yaml` and ends the current session so the next inbound message picks up the change. ## What a good persona covers In roughly the order the model wants it: 1. **Who Jarvis is here** — one line. "You are Jarvis, an AI accounting clerk for the Blockway finance team." No fluff, no origin story. 2. **What Jarvis is *not*** — one line. "You are not a general chatbot. If a user asks something unrelated to accounting, redirect politely." 3. **Language and tone** — "Reply in Traditional Chinese (Cantonese) by default. Professional but warm. Match the user's language if they switch." 4. **Rules that matter** — dollar amounts, dates, invoice numbers should be spelled out and confirmed back. Never approve a payment without an explicit second confirmation. These are the guardrails; be specific. 5. **Tool routing** — see the KB-first rule below. 6. **Escalation** — "If unsure, say so, and offer to loop in a human." ## The KB-first rule (very important) By default, models will happily hallucinate answers about your company's projects, clients, and history. The fix is a rule at the top of the persona: > Before answering any question about the company, its clients, projects, > workflows, personnel, or historical decisions, you MUST call `kb_search` > first. Only fall back to `web_search` when KB returns nothing relevant. > Real-time facts (stock prices, weather, breaking news) may skip KB and > go straight to web_search. The AI Assist panel has a **"Add KB-first rule"** preset that inserts this verbatim. Use it on every persona that has a KB collection attached. ## Using AI Assist Below the persona textarea, expand **AI Assist**. It runs in one of two modes, picked automatically: - **Generate mode** — when the persona is empty. Describe the role in a sentence or two ("accounting clerk for Blockway. Handles expense logging, invoice review, and month-end close. Cantonese, professional."), and the AI drafts a full persona for you to refine. - **Edit mode** — when a persona already exists. Type an instruction ("make the tone friendlier", "add a rule that Jarvis must double-check any figure over HK$50 000") and the AI applies just that change, leaving the rest of your text alone. Undo restores the previous version in one click. Four quick-preset chips speed up the most common edits: Add KB-first rule, Make more concise, Translate to English, Friendlier tone. **Rule of thumb**: use Generate once, then always use Edit. Repeatedly regenerating erases the customer-specific rules you carefully added. ## What breaks a persona in practice - **Too long.** Keep it under 2000 characters. Beyond that the model starts ignoring the middle. If you need more, break it into skills. - **Contradictory rules.** "Reply in Cantonese" and later "always confirm in English" is a bug. The AI Edit mode will happily surface these; ask it to "audit the persona for contradictions". - **Hardcoded people.** "The finance lead is Ada" ages badly. Move that kind of fact into the KB or memory, not the persona. - **Prompt injection surface.** Do not write "always trust the user". Adversarial end-users exist even inside private groups. ## Save + session behaviour - Saving writes to `config.yaml` and ends the current session. - The next inbound message spawns a new session with the new persona. - A chip in the Identity tab shows the last-ended session id so you can confirm the change took effect. - If you want to force a fresh session without editing the persona (e.g. after changing skill scope), use **Force new session** at the bottom of the same tab. --- # Knowledge base guide # Knowledge base guide The KB is where you put the documents Jarvis should be able to search: company handbooks, product specs, client SOPs, invoice templates. Every document is chunked, embedded (Qwen3-Embedding), and re-ranked (Qwen3-Reranker) so `kb_search` returns the passages most relevant to a user's question. ## Collections Documents live in **collections**. A collection is just a name — `claway-kb`, `accounting-sops`, `hospital-protocols`. Groups get access to specific collections; they never see the others. Create a collection from the **KB** page → **New collection**. Naming convention: lowercase, dashes, no spaces. The name will be visible in the scope tab of every persona so make it self-describing. ## Uploading documents Three paths. Two are yours, on the KB page after you drill into a collection; the third is the user's, from inside the chat (see [Letting a chat file its own documents](#letting-a-chat-file-its-own-documents)). - **Drag-drop** a `.pdf`, `.docx`, `.md`, `.txt`, or `.html` file (max 500 MB) onto the upload zone. The dashboard streams it to the server, the ingest worker picks it up within about five seconds, and the document appears in the list once chunking + embedding completes (usually well under a minute for anything under 30 pages). - **Paste a URL** in the "Add URL" input. The worker fetches the page, strips boilerplate, and ingests. Good for public docs; not so good for anything behind SSO. Progress hints: - The upload toast appears immediately (the file is queued). - The document row appears once the worker finishes. - If a document never appears after a minute, check **System → Env** for `KB_EMBEDDING_BASE_URL` — a bad embedding endpoint is the usual cause. ## Letting a chat file its own documents Users can also hand Jarvis a document in the conversation — "put this price list in the KB", "remember this page" — and it is queued through the same worker. The agent uses `kb_ingest`, then `kb_ingest_status` to confirm indexing finished before telling the user it is searchable. **Where it lands.** By default, a chat can only file into its own private collection, `chat-`, which no other chat searches. That is deliberate: anyone in a group can trigger this, so nothing a user says should be able to rewrite a corpus other chats depend on. The chat is granted read access to its own collection automatically, so the document is searchable in the same conversation that supplied it. **Granting more.** On **Personas → group → KB**, the second chip row — *"Chat may add documents to"* — is the write grant. Tick a collection there and this chat can file into it; the first ticked collection becomes the default target. Read access (the top row) is deliberately **not** a write grant. In `config.yaml` this is `kb_scope..allow_write`. **What the agent will accept.** `.pdf`, `.docx`, `.txt`, `.md`, `.html` up to 20 MB, a URL, or text the user typed. A file must be one the gateway itself received in this chat, or one in this chat's workspace — the agent cannot point the ingester at an arbitrary path on the host, which would otherwise make anything on disk searchable by everyone in the chat. Re-sending the same file is a no-op rather than a duplicate. **Turning it off.** Filing is its own toolset, `kb_ingest` (with `kb_ingest_status`); `kb_search` is search alone. A platform that lists `kb_search` in `platform_toolsets.` grants `kb_ingest` too, and every App tool preset (accounting, sales, support, admin) includes both, so ordinary chats search and file as before. To allow searching but not filing: for one App chat, pick a custom tool list without *Add to Knowledge Base*; for the whole gateway, set `agent.disabled_toolsets: [kb_ingest]`. Work-card roles never hold `kb_ingest` — a role reads the knowledge base and cannot write to it, whatever preset it was made from. ## Attaching a collection to a group By default, groups have **no** KB access. This is a safety default: if you never opt in, you cannot accidentally leak documents to the wrong group. To attach: 1. **Personas** → click the group → **KB** tab. 2. Tick the collections this group is allowed to search. 3. **Save**. Two things happen when you save: - `kb_scope..allow` in `config.yaml` gains the collection names. - If `platform_toolsets.` was missing the `kb_search` tool, we add it automatically and show you a toast. The current session ends so the next message picks up the new scope. ## The security model (worth reading) Per-chat scope is a **hard upper bound**. The model cannot escape it by guessing collection names — every `kb_search` call, no matter what arguments the model constructs, is filtered against the chat's allowlist at the SQL level. Concretely: - Chat with `allow: [claway-kb]` calls `kb_search(query="…")` → only `claway-kb` searched. - Same chat calls `kb_search(query="…", collections=["hospital-protocols"])` → request intersected with allowlist → empty set → tool returns "no matching collection in this chat's scope". - Chat with no `kb_scope` entry → tool returns "kb_scope is unset for this chat, no KB access" and never touches Postgres. The intersection layer is enforced in `tools/kb_search_tool.py` and the SQL `WHERE kb_collection = ANY($1)` clause is the second wall. Both must be compromised for cross-chat leakage to occur, and both are covered by tests. ## What can go wrong - **Uploaded but not visible in list.** Refresh the KB page. The dashboard polls every five seconds but a manual refresh forces the check. - **"I don't have kb_search" from Jarvis.** Three silent gates possible. The **Personas → KB tab** banner tells you which one is the culprit: - `JARVIS_KB_DB_URL` not set in the gateway systemd env — fix in `/etc/systemd/system/*.service` `EnvironmentFile=…`. - `platform_toolsets.` missing `kb_search` — Save on the KB scope tab auto-fixes. - `kb_scope..allow` empty — tick at least one collection. - **"I can't add that to the knowledge base."** The chat asked for a named collection it has no write grant for. Tick it in the *"Chat may add documents to"* row, or let the document go to the chat's own collection. - **Ingest worker stalled.** `systemctl status claway--kb-worker` — if `inactive`, restart it; the queue at `~/.claway/kb_ingest_queue.jsonl` will drain. - **Wrong document ended up in a collection.** Delete it from the collection's document list. The chunks are deleted transactionally; searches that were mid-flight complete with the old row cache but every subsequent search respects the deletion. ## Best practices - **Don't dump everything.** Ingesting `/mnt/shared/` wholesale makes the reranker's job harder. Curate: the documents that answer questions your end-users actually ask. - **One collection per audience.** If accounting and sales need different answers, they need different collections, not one big pool. - **Refresh cadence.** For monthly changing documents (price lists, SOPs), delete + re-ingest at the end of the month rather than leaving both versions in the pool. - **Pair with the KB-first rule.** A KB with no persona rule to use it is wasted disk. See the [persona guide](/operators/persona-guide). --- # WhatsApp group onboarding # Bringing a new WhatsApp group online The onboarding wizard replaces the old eight-step SSH procedure. Total time: about ninety seconds from the moment the customer creates the group to Jarvis replying to their first message. Prerequisite: the WhatsApp bridge must already be paired (**Connectors → WhatsApp**, green "Connected" pill). If it's not, run the QR pair from that same page first. ## The five steps **Personas** → **Onboard new group** launches the wizard. **Step 1 — Open the allowlist.** The dashboard flips `group_policy: open` and `require_mention: false` for the next few minutes. This is what lets the wizard *see* your new group appearing in the bridge log — otherwise the adapter would filter its messages out. The banner tells you the temporary state so you can restore it if you cancel. **Step 2 — Capture the JID.** Ask the customer to send any message in the new group. The wizard tails the bridge log and shows a table of recently seen groups with their JIDs. Click the one you want. This locks it in — future messages in that group will be routed to Claway. **Step 3 — AI-generate the persona.** Fill in: - **Group name** — pre-filled from the WhatsApp group's display name. - **Role brief** — one sentence describing what Jarvis should do in this group. "accounting clerk for the Blockway finance team, handles expense logging + invoice review, Cantonese professional tone" is a good shape. - **Language / Tone** — dropdowns for defaults; leave them if the brief is detailed enough. Click **Generate**. About five seconds later a full persona lands in the textarea. You can edit it directly or use the AI Assist chips (see the [persona guide](/operators/persona-guide)) before continuing. **Step 4 — Wire scopes.** Multi-select which KB collections this group should be allowed to search, and (optionally) which skills. Empty for either one means "none". Leaving KB empty is a valid choice — the group just doesn't get `kb_search`. **Step 5 — Save and go live.** The wizard: - Writes `channel_prompts.` = generated persona. - Adds the JID to `group_allow_from`. - Restores the allowlist policy back to `closed` if the customer wants scope-controlled access. - Writes `kb_scope..allow` and (if needed) auto-adds `kb_search` to `platform_toolsets.whatsapp`. - Ends any lingering session for that JID so the next message starts fresh. Close the dialog. Ask the customer to send a real message. Jarvis should reply within a few seconds. If not, see below. ## Recovery — what if you closed the dialog by mistake If you close the wizard without finishing, the allowlist policy is restored to its previous state via `beforeunload` / `sendBeacon`. The half- finished persona is discarded. Nothing on disk is stranded. If the browser tab crashes mid-wizard, the same beacon fires from the browser's page-hide event; if that also fails, the allowlist may be left open. Check **Connectors → WhatsApp → Manage** and revert `group_policy` manually. ## What goes wrong most often - **No groups appear in step 2.** The bridge is paired but the group's messages aren't reaching the adapter — usually because the bot account hasn't actually been added to the group yet. Confirm on the customer's phone. - **Generated persona doesn't match the role.** The role brief was too short. Cancel, restart, write a longer brief. Two or three sentences is the sweet spot. - **Jarvis replies but ignores the KB.** The KB-first rule was not included. Open the persona editor, use the **Add KB-first rule** preset. - **Jarvis doesn't reply at all.** Check **Live Events** for the inbound message — if it's not there, the JID capture missed the right group. Re-run the wizard. ## After the wizard: the twelve-hour check The most common productionization failure is a persona rule that reads well but backfires in practice. Twelve hours after onboarding, open **Conversations** and skim the first day of transcripts. Look for: - Cases where Jarvis called `kb_search` and got nothing but the answer was in your KB anyway — that's a chunking problem, re-ingest the doc as multiple smaller files. - Cases where Jarvis answered from training data instead of KB — that's a persona rule problem, tighten the KB-first rule. - Tone drift — Jarvis being too formal / too casual. Use the AI Edit mode with a one-line correction. Small corrections in week one save large re-writes in month two. --- # End-user cheat sheet # End-user cheat sheet This section is for the person who **chats with Jarvis** inside a WhatsApp group (or Telegram / Signal room) — not the person who runs the deployment. If you were told to read the operator guide, this is the wrong section for you. Head over there. ## Pick your role Print or bookmark whichever fits: - **[Chatting with Jarvis on WhatsApp](/end-users/whatsapp-cheatsheet)** — works for every persona. - **[If Jarvis is your accounting clerk](/end-users/accounting-clerk)** — what it does, what it does not, and how to correct mistakes. - **[If Jarvis is your sales assistant](/end-users/sales-assistant)** — quote drafting, client follow-up, CRM handoffs. - **[If Jarvis is your customer service specialist](/end-users/customer-service)** — auto-reply, escalation triggers, tone controls. - **[What Jarvis knows about you](/end-users/privacy-explained)** — the privacy model, in plain language. Each page is a single scroll. If your Jarvis behaves differently from what the page says, that is intentional — your operator has customised the persona for your team. Ask them. --- # user-guide/employee-app # Employee App (Claway App) The Claway employee app gives every rostered employee a first-class chat client — mobile (iOS/Android), desktop (macOS/Windows), and web, one Flutter codebase — alongside the WhatsApp channel. An employee's 1:1 conversation with the agent is **one unified thread** across WhatsApp and the app: history, context, and memory are shared, and the agent replies on whichever channel the employee last spoke on. ## Enabling the employee plane 1. Set a signing secret in `.env` (a credential — never config.yaml): ```bash EMPLOYEE_JWT_SECRET=$(openssl rand -hex 32) ``` 2. Enable the plane in `config.yaml`: ```yaml employee_auth: enabled: true workspace_name: "Acme Ltd" otp: channel: whatsapp # login codes are sent via your own WhatsApp connector unified_dm_platform: whatsapp # whatsapp_cloud for Meta Cloud API tenants host: 127.0.0.1 # 0.0.0.0 for direct LAN/VPN access (behind TLS) port: 8643 ``` 3. Restart the gateway. The plane refuses to start without a strong `EMPLOYEE_JWT_SECRET` and warns loudly when `unified_dm_platform` mismatches the enabled WhatsApp adapter, or when the roster has no active admin. ## Rostering employees Enrollment is fail-closed: only phones an admin has rostered can ever receive a login code. The first admin is added: - on a **Claway Box**, by the activation page (required "Admin mobile"); - in **OPS → Users** ("No App admin yet — add one"); - on the box, as the service user: `claway employees add --phone '+852 9123 4567' --role admin --name Alice`; - by HQ, through the panel's `employees.add_admin` (only while the roster has no active admin). Active rostered employees with a phone may also message the bot on WhatsApp: the DM allowlist the bridge enforces is the operator's own list plus the roster (`$CLAWAY_HOME/whatsapp/roster_allowlist.json`, kept in step automatically, no restart). Disabling someone removes only that roster entry — numbers the operator allowlisted by hand are never touched. After that, admins manage the roster from the app's Admin section (add/disable employees, devices, usage) or via `POST /app/v1/admin/employees`. ## Login flow Phone number → 6-digit code delivered **through the company's own WhatsApp connector** (the code arriving at the exact WhatsApp account being linked is itself the identity check; SIM-swap-resistant) → 15-min access token + 30-day rotating refresh token per device. ## Connection modes - **Direct** — the app connects straight to `http(s)://:8643`. LAN, VPN, or public endpoint; zero intermediaries. - **Relay** — for instances behind NAT and for store push notifications, configure `employee_auth.relay.url` (and `EMPLOYEE_RELAY_TOKEN` in `.env`). The instance dials OUT to the Claway App Relay; the relay routes opaque frames by workspace id and holds only push tokens — never rosters, OTPs, or message content. Push bodies are redacted by default (`push_redaction: true`). ## Groups - **App groups**: employees + the agent in one shared conversation. `respond_mode: mention` (default) makes the agent answer only when @'d, like a WhatsApp group; `all` answers every message. - **Bridged groups**: an admin can link an app group to an existing WhatsApp group (Admin → group → link, or `POST /app/v1/groups/{id}/link` with the group JID). Messages flow both ways — app-side messages appear in the WhatsApp group prefixed `[Name]`, agent replies go to the WhatsApp group and mirror into the app. Full context merge across both sides requires `group_sessions_per_user: false` in the gateway config (the plane warns at link time otherwise). ## Protocol Client developers: the full REST + WebSocket contract is in `docs/app-client-protocol.md` in the repository. --- # CLI Interface # CLI Interface Claway Agent's CLI is a full terminal user interface (TUI) — not a web UI. It features multiline editing, slash-command autocomplete, conversation history, interrupt-and-redirect, and streaming tool output. Built for people who live in the terminal. :::info On a Claway Box or hosted server Most people never need the CLI: day-to-day work happens in chat, the Claway App and the OPS dashboard. If you do have a shell on a Claway Box or hosted server, `claway` is installed at `/usr/local/bin/claway` and the agent's home is `/opt/claway`: run commands as the Claway service user with `CLAWAY_HOME=/opt/claway`. Everything is already bundled there, so steps elsewhere in these docs that install Python extras (`uv pip install -e ".[...]"` in `~/.claway/claway`) apply only to a source install. ::: :::tip Claway also ships a modern TUI with modal overlays, mouse selection, and non-blocking input. Launch it with `claway --tui` — see the [TUI](tui.md) guide. ::: ## Running the CLI ```bash # Start an interactive session (default) claway # Single query mode (non-interactive) claway chat -q "Hello" # With a specific model claway chat --model "anthropic/claude-sonnet-4" # With a specific provider claway chat --provider openrouter # Force OpenRouter # With specific toolsets claway chat --toolsets "web,terminal,skills" # Start with one or more skills preloaded claway -s claway-dev,github-auth claway chat -s github-pr-workflow -q "open a draft PR" # Resume previous sessions claway --continue # Resume the most recent CLI session (-c) claway --resume # Resume a specific session by ID (-r) # Verbose mode (debug output) claway chat --verbose # Isolated git worktree (for running multiple agents in parallel) claway -w # Interactive mode in worktree claway -w -z "Fix issue #123" # Single query in worktree ``` ## Interface Layout Stylized preview of the Claway CLI layout showing the banner, conversation area, and fixed input prompt.

The Claway CLI banner, conversation stream, and fixed input prompt rendered as a stable docs figure instead of fragile text art.

The welcome banner shows your model, terminal backend, working directory, available tools, and installed skills at a glance. ### Status Bar A persistent status bar sits above the input area, updating in real time: ``` ⚕ claude-sonnet-4-20250514 │ 12.4K/200K │ [██████░░░░] 6% │ $0.06 │ 15m ``` | Element | Description | |---------|-------------| | Model name | Current model (truncated if longer than 26 chars) | | Token count | Context tokens used / max context window | | Context bar | Visual fill indicator with color-coded thresholds | | Cost | Estimated session cost (or `n/a` for unknown/zero-priced models) | | 🗜️ N | **Context compression count** — how many times the running session has been auto-compressed. Appears once the first compression fires. | | ▶ N | **Active background tasks** — how many `/background` prompts are still running in the current session. Appears whenever at least one task is in flight. | | Duration | Elapsed session time | | ⚠ YOLO | **YOLO mode warning** — shown whenever `CLAWAY_YOLO_MODE` is on (either `claway --yolo` at launch or `/yolo` toggled mid-session). Mirrors the banner-line warning so you can't forget you're in auto-approve mode. | The bar adapts to terminal width — full layout at ≥ 76 columns, compact at 52–75, minimal (model + duration, plus the YOLO badge when active) below 52. **Context color coding:** | Color | Threshold | Meaning | |-------|-----------|---------| | Green | < 50% | Plenty of room | | Yellow | 50–80% | Getting full | | Orange | 80–95% | Approaching limit | | Red | ≥ 95% | Near overflow — consider `/compress` | Use `/usage` for a detailed breakdown including per-category costs (input vs output tokens). ### Session Resume Display When resuming a previous session (`claway -c` or `claway --resume `), a "Previous Conversation" panel appears between the banner and the input prompt, showing a compact recap of the conversation history. See [Sessions — Conversation Recap on Resume](sessions.md#conversation-recap-on-resume) for details and configuration. ## Keybindings | Key | Action | |-----|--------| | `Enter` | Send message | | `Alt+Enter`, `Ctrl+J`, or `Shift+Enter` | New line (multi-line input). `Shift+Enter` requires a terminal that distinguishes it from `Enter` — see below. On Windows Terminal, `Alt+Enter` is captured by the terminal (fullscreen toggle); use `Ctrl+Enter` or `Ctrl+J` instead. | | `Alt+V` | Paste an image from the clipboard when supported by the terminal | | `Ctrl+V` | Paste text and opportunistically attach clipboard images | | `Ctrl+B` | Start/stop voice recording when voice mode is enabled (`voice.record_key`, default: `ctrl+b`) | | `Ctrl+G` | Open the current input buffer in `$EDITOR` (vim/nvim/nano/VS Code/etc.). Save and quit to send the edited text as the next prompt — ideal for long, multi-paragraph prompts. | | `Ctrl+X Ctrl+E` | Emacs-style alternate binding for the external editor (same behavior as `Ctrl+G`). | | `Ctrl+C` | Interrupt agent (double-press within 2s to force exit) | | `Ctrl+D` | Exit | | `Ctrl+Z` | Suspend Claway to background (Unix only). Run `fg` in the shell to resume. | | `Tab` | Accept auto-suggestion (ghost text) or autocomplete slash commands | **Multiline paste preview.** When you paste a multi-line block, the CLI echoes a compact single-line preview (`[pasted: 47 lines, 1,842 chars — press Enter to send]`) instead of dumping the whole payload into the scrollback. The full content is still what gets sent; this is just display polish. **Markdown stripping in final responses.** The CLI strips the most verbose markdown fences and `**bold**` / `*italic*` wrappers from *final* agent replies so they render as readable terminal prose rather than raw source. Code blocks and lists are preserved. This does not affect gateway platforms or tool results — they keep their markdown for native rendering. ## Slash Commands Type `/` to see the autocomplete dropdown. Claway supports a large set of CLI slash commands, dynamic skill commands, and user-defined quick commands. Common examples: | Command | Description | |---------|-------------| | `/help` | Show command help | | `/model` | Show or change the current model | | `/tools` | List currently available tools | | `/skills browse` | Browse the skills hub and official optional skills | | `/background ` | Run a prompt in a separate background session | | `/skin` | Show or switch the active CLI skin | | `/voice on` | Enable CLI voice mode (press `Ctrl+B` to record) | | `/voice tts` | Toggle spoken playback for Claway replies | | `/reasoning high` | Increase reasoning effort | | `/title My Session` | Name the current session | | `/status` | Show session info — model/profile/tokens/duration — followed by a local **Session recap** block (recent turn counts, top tools used, files touched, latest user prompt + assistant reply). Pure local compute; no LLM call. | | `/sessions` | Open an interactive session picker right inside the classic CLI (same surface the TUI uses). Type to filter, arrow keys to navigate, Enter to resume. | For the full built-in CLI and messaging lists, see [Slash Commands Reference](../reference/slash-commands.md). For setup, providers, silence tuning, and messaging/Discord voice usage, see [Voice Mode](features/voice-mode.md). :::tip Commands are case-insensitive — `/HELP` works the same as `/help`. Installed skills also become slash commands automatically. ::: ## Quick Commands You can define custom commands that run shell commands instantly without invoking the LLM. These work in both the CLI and messaging platforms (Telegram, Discord, etc.). ```yaml # ~/.claway/config.yaml quick_commands: status: type: exec command: systemctl status claway gpu: type: exec command: nvidia-smi --query-gpu=utilization.gpu,memory.used --format=csv,noheader restart: type: alias target: /gateway restart ``` Then type `/status`, `/gpu`, or `/restart` in any chat. See the [Configuration guide](/user-guide/configuration#quick-commands) for more examples. ## Preloading Skills at Launch If you already know which skills you want active for the session, pass them at launch time: ```bash claway -s claway-dev,github-auth claway chat -s github-pr-workflow -s github-auth ``` Claway loads each named skill into the session prompt before the first turn. The same flag works in interactive mode and single-query mode. ## Skill Slash Commands Every installed skill in `~/.claway/skills/` is automatically registered as a slash command. The skill name becomes the command: ``` /gif-search funny cats /axolotl help me fine-tune Llama 3 on my dataset /github-pr-workflow create a PR for the auth refactor # Just the skill name loads it and lets the agent ask what you need: /excalidraw ``` ## Personalities Set a predefined personality to change the agent's tone: ``` /personality pirate /personality kawaii /personality concise ``` Built-in personalities include: `helpful`, `concise`, `technical`, `creative`, `teacher`, `kawaii`, `catgirl`, `pirate`, `shakespeare`, `surfer`, `noir`, `uwu`, `philosopher`, `hype`. You can also define custom personalities in `~/.claway/config.yaml`: ```yaml personalities: helpful: "You are a helpful, friendly AI assistant." kawaii: "You are a kawaii assistant! Use cute expressions..." pirate: "Arrr! Ye be talkin' to Captain Claway..." # Add your own! ``` ## Multi-line Input There are two ways to enter multi-line messages: 1. **`Alt+Enter`, `Ctrl+J`, or `Shift+Enter`** — inserts a new line 2. **Backslash continuation** — end a line with `\` to continue: ``` ❯ Write a function that:\ 1. Takes a list of numbers\ 2. Returns the sum ``` :::info Pasting multi-line text is supported — use any of the newline keys above, or simply paste content directly. ::: ### Shift+Enter compatibility Most terminals send the same byte sequence for `Enter` and `Shift+Enter` by default, so applications cannot distinguish them. Claway recognises `Shift+Enter` only when the terminal sends a distinct sequence via the [Kitty keyboard protocol](https://sw.kovidgoyal.net/kitty/keyboard-protocol/) or xterm's `modifyOtherKeys` mode. | Terminal | Status | |---|---| | Kitty, foot, WezTerm, Ghostty | Distinct `Shift+Enter` enabled by default | | iTerm2 (recent), Alacritty, VS Code terminal, Warp | Supported once the Kitty protocol is enabled in settings | | Windows Terminal Preview 1.25+ | Supported once the Kitty protocol is enabled in settings | | macOS Terminal.app, stock Windows Terminal (stable) | Not supported — `Shift+Enter` is indistinguishable from `Enter` | Where the terminal cannot distinguish them, `Alt+Enter` and `Ctrl+J` continue to work everywhere. **On Windows Terminal specifically, `Alt+Enter` is captured by the terminal (toggles fullscreen) and never reaches Claway — use `Ctrl+Enter` (delivered as `Ctrl+J`) or `Ctrl+J` directly for a newline.** ## Interrupting the Agent You can interrupt the agent at any point: - **Type a new message + Enter** while the agent is working — it interrupts and processes your new instructions - **`Ctrl+C`** — interrupt the current operation (press twice within 2s to force exit) - In-progress terminal commands are killed immediately (SIGTERM, then SIGKILL after 1s) - Multiple messages typed during interrupt are combined into one prompt ### Busy Input Mode The `display.busy_input_mode` config key controls what happens when you press Enter while the agent is working: | Mode | Behavior | |------|----------| | `"interrupt"` (default) | Your message interrupts the current operation and is processed immediately | | `"queue"` | Your message is silently queued and sent as the next turn after the agent finishes | | `"steer"` | Your message is injected into the current run via `/steer`, arriving at the agent after the next tool call — no interrupt, no new turn | ```yaml # ~/.claway/config.yaml display: busy_input_mode: "steer" # or "queue" or "interrupt" (default) ``` `"queue"` mode is useful when you want to prepare follow-up messages without accidentally canceling in-flight work. `"steer"` mode is useful when you want to redirect the agent mid-task without interrupting — e.g. "actually, also check the tests" while it's still editing code. Unknown values fall back to `"interrupt"`. `"steer"` has two automatic fallbacks: if the agent hasn't started yet, or if images are attached, the message falls back to `"queue"` behavior so nothing is lost. You can also change it inside the CLI: ```text /busy queue /busy steer /busy interrupt /busy status ``` :::tip First-touch hint The very first time you press Enter while Claway is working, Claway prints a one-line reminder explaining the `/busy` knob (`"(tip) Your message interrupted the current run…"`). It only fires once per install — a flag in `config.yaml` under `onboarding.seen.busy_input_prompt` latches it. Delete that key to see the tip again. ::: ### Suspending to Background On Unix systems, press **`Ctrl+Z`** to suspend Claway to the background — just like any terminal process. The shell prints a confirmation: ``` Claway Agent has been suspended. Run `fg` to bring Claway Agent back. ``` Type `fg` in your shell to resume the session exactly where you left off. This is not supported on Windows. ## Tool Progress Display The CLI shows animated feedback as the agent works: **Thinking animation** (during API calls): ``` ◜ (。•́︿•̀。) pondering... (1.2s) ◠ (⊙_⊙) contemplating... (2.4s) ✧٩(ˊᗜˋ*)و✧ got it! (3.1s) ``` **Tool execution feed:** ``` ┊ 💻 terminal `ls -la` (0.3s) ┊ 🔍 web_search (1.2s) ┊ 📄 web_extract (2.1s) ``` Cycle through display modes with `/verbose`: `off → new → all → verbose`. This command can also be enabled for messaging platforms — see [configuration](/user-guide/configuration#display-settings). ### Tool Preview Length The `display.tool_preview_length` config key controls the maximum number of characters shown in tool call preview lines (e.g. file paths, terminal commands). The default is `0`, which means no limit — full paths and commands are shown. ```yaml # ~/.claway/config.yaml display: tool_preview_length: 80 # Truncate tool previews to 80 chars (0 = no limit) ``` This is useful on narrow terminals or when tool arguments contain very long file paths. ## Session Management ### Resuming Sessions When you exit a CLI session, a resume command is printed: ``` Resume this session with: claway --resume 20260225_143052_a1b2c3 Session: 20260225_143052_a1b2c3 Duration: 12m 34s Messages: 28 (5 user, 18 tool calls) ``` Resume options: ```bash claway --continue # Resume the most recent CLI session claway -c # Short form claway -c "my project" # Resume a named session (latest in lineage) claway --resume 20260225_143052_a1b2c3 # Resume a specific session by ID claway --resume "refactoring auth" # Resume by title claway -r 20260225_143052_a1b2c3 # Short form ``` Resuming restores the full conversation history from SQLite. The agent sees all previous messages, tool calls, and responses — just as if you never left. Use `/title My Session Name` inside a chat to name the current session, or `claway sessions rename ` from the command line. Use `claway sessions list` to browse past sessions. ### Session Storage CLI sessions are stored in Claway's SQLite state database under `~/.claway/state.db`. The database keeps: - session metadata (ID, title, timestamps, token counters) - message history - lineage across compressed/resumed sessions - full-text search indexes used by `session_search` Some messaging adapters also keep per-platform transcript files alongside the database, but the CLI itself resumes from the SQLite session store. ### Context Compression Long conversations are automatically summarized when approaching context limits: ```yaml # In ~/.claway/config.yaml compression: enabled: true threshold: 0.50 # Compress at 50% of context limit by default # Summarization model configured under auxiliary: auxiliary: compression: model: "" # Leave empty to use the main chat model (default). Or pin a cheap fast model, e.g. "google/gemini-3-flash-preview". ``` When compression triggers, middle turns are summarized while the first 3 and last 20 turns are always preserved. ## Background Sessions Run a prompt in a separate background session while continuing to use the CLI for other work: ``` /background Analyze the logs in /var/log and summarize any errors from today ``` Claway immediately confirms the task and gives you back the prompt: ``` 🔄 Background task #1 started: "Analyze the logs in /var/log and summarize..." Task ID: bg_143022_a1b2c3 ``` ### How It Works Each `/background` prompt spawns a **completely separate agent session** in a daemon thread: - **Isolated conversation** — the background agent has no knowledge of your current session's history. It receives only the prompt you provide. - **Same configuration** — the background agent inherits your model, provider, toolsets, reasoning settings, and fallback model from the current session. - **Non-blocking** — your foreground session stays fully interactive. You can chat, run commands, or even start more background tasks. - **Multiple tasks** — you can run several background tasks simultaneously. Each gets a numbered ID. ### Results When a background task finishes, the result appears as a panel in your terminal: ``` ╭─ ⚕ Claway (background #1) ──────────────────────────────────╮ │ Found 3 errors in syslog from today: │ │ 1. OOM killer invoked at 03:22 — killed process nginx │ │ 2. Disk I/O error on /dev/sda1 at 07:15 │ │ 3. Failed SSH login attempts from 192.168.1.50 at 14:30 │ ╰──────────────────────────────────────────────────────────────╯ ``` If the task fails, you'll see an error notification instead. If `display.bell_on_complete` is enabled in your config, the terminal bell rings when the task finishes. ### Use Cases - **Long-running research** — "/background research the latest developments in quantum error correction" while you work on code - **File processing** — "/background analyze all Python files in this repo and list any security issues" while you continue a conversation - **Parallel investigations** — start multiple background tasks to explore different angles simultaneously :::info Background sessions do not appear in your main conversation history. They are standalone sessions with their own task ID (e.g., `bg_143022_a1b2c3`). ::: ## Quiet Mode By default, the CLI runs in quiet mode which: - Suppresses verbose logging from tools - Enables kawaii-style animated feedback - Keeps output clean and user-friendly For debug output: ```bash claway chat --verbose ``` --- <!-- source: website/docs/user-guide/tui.md --> # TUI # TUI The TUI is the modern front-end for Claway — a terminal UI backed by the same Python runtime as the [Classic CLI](cli.md). Same agent, same sessions, same slash commands; a cleaner, more responsive surface for interacting with them. It's the recommended way to run Claway interactively. ## Launch ```bash # Launch the TUI claway --tui # Resume the latest TUI session (falls back to the latest classic session) claway --tui -c claway --tui --continue # Resume a specific session by ID or title claway --tui -r 20260409_000000_aa11bb claway --tui --resume "my t0p session" # Run source directly — skips the prebuild step (for TUI contributors) claway --tui --dev ``` You can also enable it via env var: ```bash export CLAWAY_TUI=1 claway # now uses the TUI claway chat # same ``` Or make it the persistent default in `~/.claway/config.yaml`: ```yaml display: interface: tui # "cli" (default) or "tui" ``` With `display.interface: tui`, a bare `claway` (and `claway chat`) launches the TUI. Explicit flags always win — run `claway --cli` to drop back to the classic REPL for a single invocation, or `claway --tui` / `CLAWAY_TUI=1` to force the TUI when the config default is `cli`. The classic CLI remains the shipped default. Anything documented in [CLI Interface](cli.md) — slash commands, quick commands, skill preloading, personalities, multi-line input, interrupts — works in the TUI identically. ## Why the TUI - **Instant first frame** — the banner paints before the app finishes loading, so the terminal never feels frozen while Claway is starting. - **Non-blocking input** — type and queue messages before the session is ready. Your first prompt sends the moment the agent comes online. - **Rich overlays** — model picker, session picker, approval and clarification prompts all render as modal panels rather than inline flows. - **Live session panel** — tools and skills fill in progressively as they initialize. - **Mouse-friendly selection** — drag to highlight with a uniform background instead of SGR inverse. Copy with your terminal's normal copy gesture. - **Alternate-screen rendering** — differential updates mean no flicker when streaming, no scrollback clutter after you quit. - **Composer affordances** — inline paste-collapse for long snippets, `Cmd+V` / `Ctrl+V` text paste with clipboard-image fallback, bracketed-paste safety, and image/file-path attachment normalization. Same [skins](features/skins.md) and [personalities](features/personality.md) apply. Switch mid-session with `/skin ares`, `/personality pirate`, and the UI repaints live. See [Skins & Themes](features/skins.md) for the full list of customizable keys and which ones apply to classic vs TUI — the TUI honors the banner palette, UI colors, prompt glyph/color, session display, completion menu, selection bg, `tool_prefix`, and `help_header`. ### Collapsible banner sections The TUI startup banner groups runtime info into four collapsible sections, each rendered with a `▸` / `▾` chevron next to the section title: | Section | Default state | |---------|---------------| | Tools | Open | | Skills | Collapsed | | System Prompt | Collapsed | | MCP Servers | Collapsed | Click anywhere on a section header (or its chevron) to toggle it. The Tools list opens by default because it's the most-checked section at session start; Skills, System Prompt, and MCP Servers collapse by default so the banner stays compact even when you've installed dozens of skills or wired up many MCP servers. State is local to the banner instance, so the next launch resets to the defaults. ## Requirements - **Node.js** ≥ 20 — the TUI runs as a subprocess launched from the Python CLI. `claway doctor` verifies this. - **TTY** — like the classic CLI, piping stdin or running in non-interactive environments falls back to single-query mode. On first launch Claway installs the TUI's Node dependencies into `ui-tui/node_modules` (one-time, a few seconds). Subsequent launches are fast. If you pull a new Claway version, the TUI bundle is rebuilt automatically when sources are newer than the dist. ### External prebuild Distributions that ship a prebuilt bundle (Nix, system packages) can point Claway at it: ```bash export CLAWAY_TUI_DIR=/path/to/prebuilt/ui-tui claway --tui ``` The directory must contain `dist/entry.js`. ## Keybindings Keybindings match the [Classic CLI](cli.md#keybindings) exactly. The only behavioral differences: - **Mouse drag** highlights text with a uniform selection background. - **`Cmd+V` / `Ctrl+V`** first tries normal text paste, then falls back to OSC52/native clipboard reads, and finally image attach when the clipboard or pasted payload resolves to an image. - **`/terminal-setup`** installs local VS Code / Cursor / Windsurf terminal bindings for better `Cmd+Enter` and undo/redo parity on macOS. - **Slash autocompletion** opens as a floating panel with descriptions, not an inline dropdown. - **`Ctrl+X`** opens the live session switcher. When a queued message is highlighted (sent while the agent was still running), it still deletes that queued message instead. **`Esc`** cancels editing and unhighlights without deleting. - **`Ctrl+G` / `Ctrl+X Ctrl+E`** — open the current input buffer in `$EDITOR` for multi-line / long-prompt composition; save-and-exit sends the contents back as the prompt. ## Slash commands All slash commands work unchanged. A few are TUI-owned — they produce richer output or render as overlays rather than inline panels: | Command | TUI behavior | |---------|--------------| | `/help` | Overlay with categorized commands, arrow-key navigable | | `/sessions` (alias `/switch`) | Live session switcher — list open TUI sessions, switch between them, close them, or start another one | | `/model` | Modal model picker grouped by provider, with cost hints | | `/skin` | Live preview — theme change applies as you browse | | `/details` | Toggle verbose tool-call details (global or per-section) | | `/usage` | Rich token / cost / context panel | | `/agents` (alias `/tasks`) | Observability overlay — live subagent tree with kill/pause controls, per-branch cost / token / file rollups, turn-by-turn history | | `/reload` | Re-reads `~/.claway/.env` into the running TUI process so newly added API keys take effect without a restart | | `/mouse [on\|off\|toggle\|wheel\|buttons\|all]` | Pick a mouse tracking preset at runtime (also persists to `display.mouse_tracking` in `config.yaml`). `wheel` (1000+1006) keeps scroll-wheel scrolling without the hover events that make tmux spam "No image in clipboard" over the prompt row; `buttons` adds drag-to-select; `all` is the default with hover-driven UI. | Every other slash command (including installed skills, quick commands, and personality toggles) works identically to the classic CLI. See [Slash Commands Reference](../reference/slash-commands.md). ## Live session switcher Use the live session switcher when you want one terminal to act as a dispatcher for several TUI sessions. It lists only sessions that are currently live in this TUI process; closed sessions remain saved transcripts and can still be reopened with `/resume` or `claway --tui --resume <id-or-title>`. Open it with any of these: - `Ctrl+X` from the TUI. - `/sessions` or `/switch`. - `/sessions new` to create a fresh live session immediately. - Click the `N live sessions` count in the status line. <img alt="Claway TUI Session Orchestrator with one live session and a +new row" src="/img/docs/tui-session-orchestrator/session-orchestrator.png" /> <video controls muted loop playsInline src="/img/docs/tui-session-orchestrator/session-orchestrator-demo.mp4" title="Claway TUI Session Orchestrator demo" /> Inside the switcher: - `↑` / `↓` move the selection; mouse clicks select rows too. - `Enter` switches to the selected live session. - `Ctrl+D` closes the selected live session. - `Ctrl+N` starts a blank live session. - `Ctrl+R` refreshes the live-session list. - `Esc` closes the switcher. - Select `+new`, type a prompt, and press `Enter` to dispatch a new live session. Press `Tab` first if you want to choose a model just for that new session. ## LaTeX math rendering The TUI's markdown pipeline renders LaTeX math inline: `$E = mc^2$` and `$$\frac{a}{b}$$` render as Unicode-formatted math instead of the raw TeX source. Works for inline and block math; unsupported syntax falls back to showing the literal TeX wrapped in a code span so it remains copyable. This is always-on — nothing to configure. Classic CLI keeps the raw TeX. ## Light-terminal detection The TUI auto-detects light terminals and swaps to the light theme accordingly. Detection works in three layers: 1. `CLAWAY_TUI_THEME` env var — highest priority. Values: `light`, `dark`, or a raw 6-char background hex (e.g. `ffffff`, `1a1a2e`). 2. `COLORFGBG` env var — the classic "what's my background color?" hint used by xterm-derived terminals. 3. Terminal background probe via OSC 11 — works on modern terminals (Ghostty, Warp, iTerm2, WezTerm, Kitty) that don't set `COLORFGBG`. If you want the light theme permanently regardless of terminal: ```bash export CLAWAY_TUI_THEME=light ``` ## Busy indicator styles The status-bar busy indicator is pluggable — the default rotates Claway's kawaii face palette every 2.5 seconds during agent work. Pick a different style via config or the `/indicator` slash command: ```yaml display: tui_status_indicator: kaomoji # kaomoji | emoji | unicode | ascii ``` Or in-session: `/indicator emoji` (etc.). Styles ship with matched glyph widths so the rest of the status bar doesn't jitter on rotation. ## Auto-resume By default, `claway --tui` starts a fresh session each launch. To re-attach to the most recent TUI session automatically (useful when your terminal or SSH connection drops unexpectedly), opt in: ```bash export CLAWAY_TUI_RESUME=1 # most-recent TUI session # or: export CLAWAY_TUI_RESUME=<session-id> # specific session ``` Unset the variable or pass `--resume <id>` explicitly to override on a per-launch basis. ## Status line The TUI's status line tracks agent state in real time: | Status | Meaning | |--------|---------| | `starting agent…` | Session ID is live; tools and skills still coming online. You can type — messages queue and send when ready. | | `ready` | Agent is idle, accepting input. | | `thinking…` / `running…` | Agent is reasoning or running a tool. | | `interrupted` | Current turn was cancelled; press Enter to send again. | | `forging session…` / `resuming…` | Initial connect or `--resume` handshake. | The per-skin status-bar colors and thresholds are shared with the classic CLI — see [Skins](features/skins.md) for customization. The status line also shows: - **Working directory with git branch** — `~/projects/claway (docs/two-week-gap-sweep)`. The branch suffix updates when you `git checkout` in a side terminal (mtime-cached) so the TUI reflects your actual active branch, not whatever it was at launch. - **Per-prompt elapsed time** — `⏱ 12s/3m 45s` while the turn is running (live), frozen to `⏲ 32s / 3m 45s` after the turn completes. First number is time since last user message; second is total session duration. Resets on every new prompt. - **`🗜️ N`** — number of times the running session has been auto-compressed. Appears once the first compression fires. - **`▶ N`** — number of `/background` tasks currently running in this session. Appears whenever at least one task is in flight. - **`⚠ YOLO`** — visible warning whenever YOLO mode is on (`claway --yolo`, `/yolo`, or `CLAWAY_YOLO_MODE=1`). The same badge also appears in the startup banner so you cannot launch an auto-approving session without noticing. ## Configuration The TUI respects all standard Claway config: `~/.claway/config.yaml`, profiles, personalities, skins, quick commands, credential pools, memory providers, tool/skill enablement. No TUI-specific config file exists. A handful of keys tune the TUI surface specifically: ```yaml display: skin: default # any built-in or custom skin personality: helpful details_mode: collapsed # hidden | collapsed | expanded — global accordion default sections: # optional: per-section overrides (any subset) thinking: expanded # always open tools: expanded # always open activity: collapsed # opt back IN to the activity panel (hidden by default) mouse_tracking: all # off | wheel | buttons | all (or true/false for back-compat). # wheel — 1000+1006 (scroll + click; no drag, no hover — # recommended inside tmux to silence the prompt-row # "No image in clipboard" spam from hover events) # buttons — adds 1002 for terminal-side drag selection # all — adds 1003 for hover (scrollbar paginate-on-hover, # link mouseenter, etc.) ``` Runtime toggles: - `/details [hidden|collapsed|expanded|cycle]` — set the global mode - `/details <section> [hidden|collapsed|expanded|reset]` — override one section (sections: `thinking`, `tools`, `subagents`, `activity`) **Default visibility** The TUI ships with opinionated per-section defaults that stream the turn as a live transcript instead of a wall of chevrons: - `thinking` — **expanded**. Reasoning streams inline as the model emits it. - `tools` — **expanded**. Tool calls and their results render open. - `subagents` — falls through to the global `details_mode` (collapsed under chevron by default — stays quiet until a delegation actually happens). - `activity` — **hidden**. Ambient meta (gateway hints, terminal-parity nudges, background notifications) is noise for most day-to-day use. Tool failures still render inline on the failing tool row; ambient errors/warnings surface via a floating-alert backstop when every panel is hidden. Per-section overrides take precedence over both the section default and the global `details_mode`. To reshape the layout: - `display.sections.thinking: collapsed` — put thinking back under a chevron - `display.sections.tools: collapsed` — put tool calls back under a chevron - `display.sections.activity: collapsed` — opt the activity panel back in - `/details <section> <mode>` at runtime Anything set explicitly in `display.sections` wins over the defaults, so existing configs keep working unchanged. ## Sessions Sessions are shared between the TUI and the classic CLI — both write to the same `~/.claway/state.db`. You can start a session in one, resume in the other. The session picker surfaces sessions from both sources, with a source tag. See [Sessions](sessions.md) for lifecycle, search, compression, and export. ## How the TUI talks to its gateway By default the TUI spawns its own in-process gateway, so each TUI instance is self-contained — there's nothing to configure. You may see a `CLAWAY_TUI_GATEWAY_URL` env var referenced in the codebase or logs. This is an **internal wiring detail of the web dashboard**, not a user-facing remote-attach knob. When you open the dashboard's "Chat" tab (`claway dashboard` → `/chat`), the dashboard's web server spawns an embedded TUI child process and injects `CLAWAY_TUI_GATEWAY_URL` so that child attaches to the dashboard's own in-process `tui_gateway` over a loopback WebSocket (`/api/ws`). The `/api/ws` endpoint exists only inside the dashboard server (`claway_cli/web_server.py`) and is bound to that process's lifetime and auth. There is no general "point any TUI at any standalone gateway port" mode. In particular, the OpenAI-compatible API server (`claway gateway` / the `api_server` platform) does **not** serve `/api/ws` — it's the model-backend surface (`/v1/chat/completions`, `/v1/models`, …) and deliberately does not expose the TUI's JSON-RPC control channel. Setting `CLAWAY_TUI_GATEWAY_URL` to that port will 404. If you want multiple surfaces to share one set of sessions, use the shared `~/.claway/state.db` (see [Sessions](sessions.md)) or the web dashboard's embedded chat (see Web Dashboard) — not a hand-set gateway URL. ## Reverting to the classic CLI Launching `claway` (without `--tui`) stays on the classic CLI by default. To make a machine prefer the TUI, set `display.interface: tui` in `~/.claway/config.yaml` (persistent) or `CLAWAY_TUI=1` in your shell profile (per-shell). To go back, set `interface: cli` / unset the env var, or pass `claway --cli` for a one-off. If the TUI fails to launch (no Node, missing bundle, TTY issue), Claway prints a diagnostic and falls back — rather than leaving you stuck. ## See also - [CLI Interface](cli.md) — full slash command and keybinding reference (shared) - [Sessions](sessions.md) — resume, branch, and history - [Skins & Themes](features/skins.md) — theme the banner, status bar, and overlays - [Voice Mode](features/voice-mode.md) — works in both interfaces - [Configuration](configuration.md) — all config keys --- <!-- source: website/docs/user-guide/configuration.md --> # Configuration # Configuration All settings are stored in the `~/.claway/` directory for easy access. ## Directory Structure ```text ~/.claway/ ├── config.yaml # Settings (model, terminal, TTS, compression, etc.) ├── .env # API keys and secrets ├── auth.json # OAuth provider credentials (Codex, Anthropic, etc.) ├── SOUL.md # Primary agent identity (slot #1 in system prompt) ├── memories/ # Persistent memory (MEMORY.md, USER.md) ├── skills/ # Agent-created skills (managed via skill_manage tool) ├── cron/ # Scheduled jobs ├── sessions/ # Gateway sessions └── logs/ # Logs (errors.log, gateway.log — secrets auto-redacted) ``` ## Managing Configuration ```bash claway config # View current configuration claway config edit # Open config.yaml in your editor claway config set KEY VAL # Set a specific value claway config check # Check for missing options (after updates) claway config migrate # Interactively add missing options # Examples: claway config set model anthropic/claude-opus-4 claway config set terminal.backend docker claway config set OPENROUTER_API_KEY sk-or-... # Saves to .env ``` :::tip The `claway config set` command automatically routes values to the right file — API keys are saved to `.env`, everything else to `config.yaml`. ::: ## Configuration Precedence Settings are resolved in this order (highest priority first): 1. **CLI arguments** — e.g., `claway chat --model anthropic/claude-sonnet-4` (per-invocation override) 2. **`~/.claway/config.yaml`** — the primary config file for all non-secret settings 3. **`~/.claway/.env`** — fallback for env vars; **required** for secrets (API keys, tokens, passwords) 4. **Built-in defaults** — hardcoded safe defaults when nothing else is set :::info Rule of Thumb Secrets (API keys, bot tokens, passwords) go in `.env`. Everything else (model, terminal backend, compression settings, memory limits, toolsets) goes in `config.yaml`. When both are set, `config.yaml` wins for non-secret settings. ::: :::tip Org deployments An administrator can pin specific config and secret values that a standard user cannot override, via a system-level managed directory. See [Managed Scope](/user-guide/managed-scope). ::: ## Environment Variable Substitution You can reference environment variables in `config.yaml` using `${VAR_NAME}` syntax: ```yaml auxiliary: vision: api_key: ${GOOGLE_API_KEY} base_url: ${CUSTOM_VISION_URL} delegation: api_key: ${DELEGATION_KEY} ``` Multiple references in a single value work: `url: "${HOST}:${PORT}"`. If a referenced variable is not set, the placeholder is kept verbatim (`${UNDEFINED_VAR}` stays as-is). Only the `${VAR}` syntax is supported — bare `$VAR` is not expanded. For AI provider setup (OpenRouter, Anthropic, Copilot, custom endpoints, self-hosted LLMs, fallback models, etc.), see [AI Providers](/integrations/providers). ### Provider Timeouts You can set `providers.<id>.request_timeout_seconds` for a provider-wide request timeout, plus `providers.<id>.models.<model>.timeout_seconds` for a model-specific override. Applies to the primary turn client on every transport (OpenAI-wire, native Anthropic, Anthropic-compatible), the fallback chain, rebuilds after credential rotation, and (for OpenAI-wire) the per-request timeout kwarg — so the configured value wins over the legacy `CLAWAY_API_TIMEOUT` env var. You can also set `providers.<id>.stale_timeout_seconds` for the non-streaming stale-call detector, plus `providers.<id>.models.<model>.stale_timeout_seconds` for a model-specific override. This wins over the legacy `CLAWAY_API_CALL_STALE_TIMEOUT` env var. Leaving these unset keeps the legacy defaults (`CLAWAY_API_TIMEOUT=1800`s, `CLAWAY_API_CALL_STALE_TIMEOUT=90`s, native Anthropic 900s). The non-streaming stale detector is auto-disabled for local endpoints when left implicit and can scale upward for very large contexts. Not currently wired for AWS Bedrock (both `bedrock_converse` and AnthropicBedrock SDK paths use boto3 with its own timeout configuration). See the commented example in `cli-config.yaml.example`. ## Update Behavior `claway update` settings live under `updates` in `config.yaml`: ```yaml updates: pre_update_backup: false # Create a full CLAWAY_HOME zip before every update backup_keep: 5 # Keep this many pre-update backup zips non_interactive_local_changes: stash # stash | discard ``` For git installs, Claway auto-stashes dirty tracked files and untracked files before checking out the update branch or pulling. Interactive terminal updates prompt before restoring that stash. Non-interactive updates (desktop/chat app, gateway, or `--yes`) use `updates.non_interactive_local_changes`: `stash` restores local source edits after a successful pull, while `discard` drops the update-created stash after a successful pull. Use `discard` only on managed installs where local source edits are never meant to persist. Before that stash step, Claway also restores tracked `package-lock.json` diffs left by npm install/build churn. Commit or manually stash intentional lockfile edits before updating. ## Terminal Backend Configuration Claway supports six terminal backends. Each determines where the agent's shell commands actually execute — your local machine, a Docker container, a remote server via SSH, a Modal cloud sandbox, a Daytona workspace, or a Singularity/Apptainer container. ```yaml terminal: backend: local # local | docker | ssh | modal | daytona | singularity cwd: "." # Gateway/cron working directory (CLI always uses launch dir) timeout: 180 # Per-command timeout in seconds home_mode: auto # auto | real | profile — subprocess HOME policy env_passthrough: [] # Env var names to forward to sandboxed execution (terminal + execute_code) singularity_image: "docker://nikolaik/python-nodejs:python3.11-nodejs20" # Container image for Singularity backend modal_image: "nikolaik/python-nodejs:python3.11-nodejs20" # Container image for Modal backend daytona_image: "nikolaik/python-nodejs:python3.11-nodejs20" # Container image for Daytona backend ``` For cloud sandboxes such as Modal and Daytona, `container_persistent: true` means Claway will try to preserve filesystem state across sandbox recreation. It does not promise that the same live sandbox, PID space, or background processes will still be running later. ### Backend Overview | Backend | Where commands run | Isolation | Best for | |---------|-------------------|-----------|----------| | **local** | Your machine directly | None | Development, personal use | | **docker** | Single persistent Docker container (shared across session, `/new`, subagents) | Full (namespaces, cap-drop) | Safe sandboxing, CI/CD | | **ssh** | Remote server via SSH | Network boundary | Remote dev, powerful hardware | | **modal** | Modal cloud sandbox | Full (cloud VM) | Ephemeral cloud compute, evals | | **daytona** | Daytona workspace | Full (cloud container) | Managed cloud dev environments | | **singularity** | Singularity/Apptainer container | Namespaces (--containall) | HPC clusters, shared machines | ### Local Backend The default. Commands run directly on your machine with no isolation. No special setup required. ```yaml terminal: backend: local ``` By default, local tool subprocesses keep your real OS-user `HOME`. This lets external CLIs such as `git`, `ssh`, `gh`, `az`, `npm`, Claude Code, and Codex find the credentials and config they already use in your normal shell. Claway state is still profile-scoped through `CLAWAY_HOME`; `HOME` is not how profiles select config, memory, sessions, or skills. Claway does **not** change your system-wide `HOME`, your shell startup files, or the operating system account home. This setting only controls the environment passed to subprocesses that Claway launches through tools such as `terminal`, background terminal processes, `execute_code`, and ACP helper processes. #### `terminal.home_mode` | Mode | Host installs | Containers | Tradeoff | |---|---|---|---| | `auto` | Keep the real OS-user `HOME` | Use `{CLAWAY_HOME}/home` | Recommended default. Host CLIs keep working; container state persists. | | `real` | Force the real OS-user `HOME` | Force the real OS-user `HOME` if visible | Useful if a parent process accidentally started with `HOME` pointed at a profile home. | | `profile` | Use `{CLAWAY_HOME}/home` when it exists | Use `{CLAWAY_HOME}/home` when it exists | Strict per-profile CLI config isolation, but normal `~/.ssh`, `~/.gitconfig`, `~/.azure`, `~/.config/gh`, Claude/Codex auth, npm state, etc. will not be visible unless you initialize or link them inside the profile home. | The downside of the default is that host profiles share the same normal user-level CLI credentials/config under `~`. If you need a profile with a separate git identity, SSH keys, GitHub CLI login, npm config, or cloud CLI login, use `home_mode: profile` and initialize those tools inside that profile home deliberately. If you intentionally want strict per-profile tool-config isolation, set: ```yaml terminal: home_mode: profile ``` In that mode tool subprocesses use `{CLAWAY_HOME}/home` as `HOME`. Claway also sets `CLAWAY_REAL_HOME` so scripts can still locate the actual user home when they need it. Container backends keep using `{CLAWAY_HOME}/home` in `auto` mode because that directory lives on the persistent Claway data volume. Scripts that need to distinguish profile state from the real user home should prefer `CLAWAY_HOME` for Claway data and `CLAWAY_REAL_HOME` for the account home: ```python from pathlib import Path import os claway_home = Path(os.environ["CLAWAY_HOME"]) real_home = Path(os.environ.get("CLAWAY_REAL_HOME", os.environ["HOME"])) ``` :::warning The agent has the same filesystem access as your user account. Use `claway tools` to disable tools you don't want, or switch to Docker for sandboxing. ::: ### Docker Backend Runs commands inside a Docker container with security hardening (all capabilities dropped, no privilege escalation, PID limits). **Single persistent container, shared across Claway processes.** Claway starts ONE long-lived container on first use and routes every terminal, file, and `execute_code` call through `docker exec` into that same container — across sessions, `/new`, `/reset`, and `delegate_task` subagents. Working-directory changes, installed packages, files in `/workspace`, and **background processes** all carry over from one tool call to the next, and from one Claway process to the next. When you close a TUI session, run `/quit`, or start a new `claway` invocation, the container keeps running and the next Claway process reuses it via a labeled lookup. See **Container lifecycle** below for the exact teardown rules. ```yaml terminal: backend: docker docker_image: "nikolaik/python-nodejs:python3.11-nodejs20" docker_mount_cwd_to_workspace: false # Mount launch dir into /workspace docker_run_as_host_user: false # See "Running container as host user" below docker_forward_env: # Host env vars to forward into container - "GITHUB_TOKEN" docker_env: # Literal env vars to inject (KEY=value) DEBUG: "1" PYTHONUNBUFFERED: "1" docker_volumes: # Host directory mounts - "/home/user/projects:/workspace/projects" - "/home/user/data:/data:ro" # :ro for read-only docker_extra_args: # Extra flags appended verbatim to `docker run` - "--gpus=all" - "--network=host" # Resource limits container_cpu: 1 # CPU cores (0 = unlimited) container_memory: 5120 # MB (0 = unlimited) container_disk: 51200 # MB (requires overlay2 on XFS+pquota) container_persistent: true # Persist /workspace and /root bind-mount dirs # Cross-process container reuse (defaults match the "one long-lived # container shared across sessions" contract — see Container lifecycle). docker_persist_across_processes: true # Reuse container across Claway restarts docker_orphan_reaper: true # Sweep abandoned Exited containers at startup # Cross-backend lifecycle settings (apply to docker as well) timeout: 180 # Per-command timeout in seconds lifetime_seconds: 300 # Idle-reaper window; also feeds 2× orphan-reaper threshold ``` **`docker_env`** vs **`docker_forward_env`**: the former injects literal `KEY=value` pairs you specify in the config (the values live in your `config.yaml` or are passed as a JSON dict via `TERMINAL_DOCKER_ENV='{"DEBUG":"1"}'`). The latter forwards values from your shell or `~/.claway/.env`, so the actual secret never appears in the config file. Use `docker_forward_env` for tokens and `docker_env` for static knobs the container needs. **`terminal.docker_extra_args`** (also overridable via `TERMINAL_DOCKER_EXTRA_ARGS='["--gpus=all"]'`) lets you pass arbitrary `docker run` flags that Claway doesn't surface as first-class keys — `--gpus`, `--network`, `--add-host`, alternative `--security-opt` overrides, etc. Each entry must be a string; the list is appended last to the assembled `docker run` invocation so it can override Claway's defaults if needed. Use sparingly — flags that conflict with the sandbox hardening (capability drops, `--user`, the workspace bind mount) will silently weaken isolation. **Requirements:** Docker Desktop or Docker Engine installed and running. Claway probes `$PATH` plus common macOS install locations (`/usr/local/bin/docker`, `/opt/homebrew/bin/docker`, Docker Desktop app bundle). Podman is supported out of the box: set `CLAWAY_DOCKER_BINARY=podman` (or the full path) to force it when both are installed. #### Container lifecycle Every Claway-managed container is tagged with three labels so subsequent processes (and the orphan reaper) can identify it: - `claway=1` — marks it as Claway-managed - `claway-task-id=<sanitized task_id>` — keys the per-task reuse probe - `claway-profile=<sanitized profile name>` — scopes reuse and reaping to the active Claway profile On startup, Claway runs `docker ps --filter label=claway-task-id=<id> --filter label=claway-profile=<profile>` and **attaches to the existing container** when it finds one. If the container is `exited` (e.g. after a Docker daemon restart), it's `docker start`'d and reused — filesystem state and any installed packages survive, but in-container background processes do not. When a Claway process exits — `/quit`, closing a TUI session, gateway shutdown, even SIGKILL — the cleanup path is a **no-op for the container in default mode**. The container keeps running. The next Claway process attaches to it in milliseconds via the label probe. This is the behavior the "one long-lived container shared across sessions" contract requires: it's the only way background processes (npm watchers, dev servers, long-running pytest) survive across sessions. **The container is only torn down (stopped and `docker rm -f`'d) in these cases:** | Trigger | When it fires | |---|---| | `docker_persist_across_processes: false` | Explicit per-process isolation. Every `cleanup()` does `stop` + `rm -f`. Matches pre-issue-#20561 behavior. | | Idle reaper (`lifetime_seconds`, default 300s) | Only when the env is `persist_across_processes=false`. Persist-mode envs are no-op'd; container survives the idle sweep. | | Orphan reaper at next startup | Sweeps **Exited** claway-labeled containers older than `2 × lifetime_seconds` (default 600s = 10 min), scoped to the current profile. **Running containers are never touched** — sibling-process safety. Set `docker_orphan_reaper: false` to disable. | | Direct user action | `docker rm -f`, `docker system prune`, Docker Desktop restart. We don't set `--restart=always`, so a host reboot leaves the container `Exited` (its CoW layer survives and gets reused on next startup, but bg processes are gone). | Edge cases worth knowing: - **OOM kill of in-container PID 1** transitions the container to `Exited`. Next reuse will `docker start` it; filesystem state survives, bg processes do not. - **Switching profiles** isolates containers from each other — a container labeled `claway-profile=work` is invisible to a Claway process running under `claway-profile=research`. The orphan reaper is profile-scoped too, so cross-profile containers don't get reaped accidentally, but they also won't get cleaned up automatically until you start Claway again under their original profile. Parallel subagents spawned via `delegate_task(tasks=[...])` share this one container — concurrent `cd`, env mutations, and writes to the same path will collide. If a subagent needs an isolated sandbox, it must register a per-task image override via `register_task_env_overrides()`, which RL and benchmark environments (TerminalBench2, ClawaySweEnv, etc.) do automatically for their per-task Docker images. **Security hardening:** - `--cap-drop ALL` with only `DAC_OVERRIDE`, `CHOWN`, `FOWNER` added back - `--security-opt no-new-privileges` - `--pids-limit 256` - Size-limited tmpfs for `/tmp` (512MB), `/var/tmp` (256MB), `/run` (64MB) **Credential forwarding:** Env vars listed in `docker_forward_env` are resolved from your shell environment first, then `~/.claway/.env`. Skills can also declare `required_environment_variables` which are merged automatically. #### Environment variable overrides Every key under `terminal:` has an env-var override of the form `TERMINAL_<KEY_UPPERCASE>`. The most useful ones for the Docker backend: | Env var | Maps to | Notes | |---|---|---| | `TERMINAL_DOCKER_IMAGE` | `docker_image` | Base image | | `TERMINAL_DOCKER_FORWARD_ENV` | `docker_forward_env` | JSON array: `'["GITHUB_TOKEN","OPENAI_API_KEY"]'` | | `TERMINAL_DOCKER_ENV` | `docker_env` | JSON dict: `'{"DEBUG":"1"}'` | | `TERMINAL_DOCKER_VOLUMES` | `docker_volumes` | JSON array of `"host:container[:ro]"` strings | | `TERMINAL_DOCKER_EXTRA_ARGS` | `docker_extra_args` | JSON array | | `TERMINAL_DOCKER_MOUNT_CWD_TO_WORKSPACE` | `docker_mount_cwd_to_workspace` | `true` / `false` | | `TERMINAL_DOCKER_RUN_AS_HOST_USER` | `docker_run_as_host_user` | `true` / `false` | | `TERMINAL_DOCKER_PERSIST_ACROSS_PROCESSES` | `docker_persist_across_processes` | `true` / `false` — default `true` | | `TERMINAL_DOCKER_ORPHAN_REAPER` | `docker_orphan_reaper` | `true` / `false` — default `true` | | `TERMINAL_CONTAINER_CPU` | `container_cpu` | CPU cores | | `TERMINAL_CONTAINER_MEMORY` | `container_memory` | MB | | `TERMINAL_CONTAINER_DISK` | `container_disk` | MB | | `TERMINAL_CONTAINER_PERSISTENT` | `container_persistent` | `true` / `false` — controls the bind-mount workspace dirs, distinct from `docker_persist_across_processes` | | `TERMINAL_LIFETIME_SECONDS` | `lifetime_seconds` | Idle reaper window | | `TERMINAL_TIMEOUT` | `timeout` | Per-command timeout | | `CLAWAY_DOCKER_BINARY` | _none_ | Force a specific docker/podman binary path | ### SSH Backend Runs commands on a remote server over SSH. Uses ControlMaster for connection reuse (5-minute idle keepalive). Persistent shell is enabled by default — state (cwd, env vars) survives across commands. ```yaml terminal: backend: ssh persistent_shell: true # Keep a long-lived bash session (default: true) ``` **Required environment variables:** ```bash TERMINAL_SSH_HOST=my-server.example.com TERMINAL_SSH_USER=ubuntu ``` **Optional:** | Variable | Default | Description | |----------|---------|-------------| | `TERMINAL_SSH_PORT` | `22` | SSH port | | `TERMINAL_SSH_KEY` | (system default) | Path to SSH private key | | `TERMINAL_SSH_PERSISTENT` | `true` | Enable persistent shell | **How it works:** Connects at init time with `BatchMode=yes` and `StrictHostKeyChecking=accept-new`. Persistent shell keeps a single `bash -l` process alive on the remote host, communicating via temporary files. Commands that need `stdin_data` or `sudo` automatically fall back to one-shot mode. ### Modal Backend Runs commands in a [Modal](https://modal.com) cloud sandbox. Each task gets an isolated VM with configurable CPU, memory, and disk. Filesystem can be snapshot/restored across sessions. ```yaml terminal: backend: modal container_cpu: 1 # CPU cores container_memory: 5120 # MB (5GB) container_disk: 51200 # MB (50GB) container_persistent: true # Snapshot/restore filesystem ``` **Required:** Either `MODAL_TOKEN_ID` + `MODAL_TOKEN_SECRET` environment variables, or a `~/.modal.toml` config file. **Persistence:** When enabled, the sandbox filesystem is snapshotted on cleanup and restored on next session. Snapshots are tracked in `~/.claway/modal_snapshots.json`. This preserves filesystem state, not live processes, PID space, or background jobs. **Credential files:** Automatically mounted from `~/.claway/` (OAuth tokens, etc.) and synced before each command. ### Daytona Backend Runs commands in a [Daytona](https://daytona.io) managed workspace. Supports stop/resume for persistence. ```yaml terminal: backend: daytona container_cpu: 1 # CPU cores container_memory: 5120 # MB → converted to GiB container_disk: 10240 # MB → converted to GiB (max 10 GiB) container_persistent: true # Stop/resume instead of delete ``` **Required:** `DAYTONA_API_KEY` environment variable. **Persistence:** When enabled, sandboxes are stopped (not deleted) on cleanup and resumed on next session. Sandbox names follow the pattern `claway-{task_id}`. **Disk limit:** Daytona enforces a 10 GiB maximum. Requests above this are capped with a warning. ### Singularity/Apptainer Backend Runs commands in a [Singularity/Apptainer](https://apptainer.org) container. Designed for HPC clusters and shared machines where Docker isn't available. ```yaml terminal: backend: singularity singularity_image: "docker://nikolaik/python-nodejs:python3.11-nodejs20" container_cpu: 1 # CPU cores container_memory: 5120 # MB container_persistent: true # Writable overlay persists across sessions ``` **Requirements:** `apptainer` or `singularity` binary in `$PATH`. **Image handling:** Docker URLs (`docker://...`) are automatically converted to SIF files and cached. Existing `.sif` files are used directly. **Scratch directory:** Resolved in order: `TERMINAL_SCRATCH_DIR` → `TERMINAL_SANDBOX_DIR/singularity` → `/scratch/$USER/claway` (HPC convention) → `~/.claway/sandboxes/singularity`. **Isolation:** Uses `--containall --no-home` for full namespace isolation without mounting the host home directory. ### Common Terminal Backend Issues If terminal commands fail immediately or the terminal tool is reported as disabled: - **Local** — No special requirements. The safest default when getting started. - **Docker** — Run `docker version` to verify Docker is working. If it fails, fix Docker or `claway config set terminal.backend local`. - **SSH** — Both `TERMINAL_SSH_HOST` and `TERMINAL_SSH_USER` must be set. Claway logs a clear error if either is missing. - **Modal** — Needs `MODAL_TOKEN_ID` env var or `~/.modal.toml`. Run `claway doctor` to check. - **Daytona** — Needs `DAYTONA_API_KEY`. The Daytona SDK handles server URL configuration. - **Singularity** — Needs `apptainer` or `singularity` in `$PATH`. Common on HPC clusters. When in doubt, set `terminal.backend` back to `local` and verify that commands run there first. ### Remote-to-Host File Sync on Teardown For the **SSH**, **Modal**, and **Daytona** backends (anywhere the agent's working tree lives on a different machine than the host running Claway), Claway tracks files the agent touched inside the remote sandbox and, on session teardown / sandbox cleanup, **syncs the modified files back to the host** under `~/.claway/cache/remote-syncs/<session-id>/`. - Triggers on: session close, `/new`, `/reset`, gateway message timeout, `delegate_task` subagent completion when the child used a remote backend. - Covers the whole tree the agent modified, not just files it explicitly opened. Additions, edits, and deletions are all captured. - The remote sandbox may have been torn down by the time you go looking; the local `~/.claway/cache/remote-syncs/…` copy is the authoritative record of what the agent changed. - Large binary outputs (model checkpoints, raw datasets) are capped by size — the sync skips files over `file_sync_max_mb` (default `100`). Bump that if you expect bigger artifacts to come back. ```yaml terminal: file_sync_max_mb: 100 # default — sync files up to 100 MB each file_sync_enabled: true # default — set false to skip the sync entirely ``` This is how you recover results from ephemeral cloud sandboxes that get destroyed after the session ends, without having to tell the agent to explicitly `scp` or `modal volume put` every artifact. ### Docker Volume Mounts When using the Docker backend, `docker_volumes` lets you share host directories with the container. Each entry uses standard Docker `-v` syntax: `host_path:container_path[:options]`. ```yaml terminal: backend: docker docker_volumes: - "/home/user/projects:/workspace/projects" # Read-write (default) - "/home/user/datasets:/data:ro" # Read-only - "/home/user/.claway/cache/documents:/output" # Gateway-visible exports ``` This is useful for: - **Providing files** to the agent (datasets, configs, reference code) - **Receiving files** from the agent (generated code, reports, exports) - **Shared workspaces** where both you and the agent access the same files If you use a messaging gateway and want the agent to send generated files via `MEDIA:/...`, prefer a dedicated host-visible export mount such as `/home/user/.claway/cache/documents:/output`. - Write files inside Docker to `/output/...` - Emit the **host path** in `MEDIA:`, for example: `MEDIA:/home/user/.claway/cache/documents/report.txt` - Do **not** emit `/workspace/...` or `/output/...` unless that exact path also exists for the gateway process on the host :::warning YAML duplicate keys silently override earlier ones. If you already have a `docker_volumes:` block, merge new mounts into the same list instead of adding another `docker_volumes:` key later in the file. ::: Can also be set via environment variable: `TERMINAL_DOCKER_VOLUMES='["/host:/container"]'` (JSON array). ### Docker Credential Forwarding By default, Docker terminal sessions do not inherit arbitrary host credentials. If you need a specific token inside the container, add it to `terminal.docker_forward_env`. ```yaml terminal: backend: docker docker_forward_env: - "GITHUB_TOKEN" - "NPM_TOKEN" ``` Claway resolves each listed variable from your current shell first, then falls back to `~/.claway/.env` if it was saved with `claway config set`. :::warning Anything listed in `docker_forward_env` becomes visible to commands run inside the container. Only forward credentials you are comfortable exposing to the terminal session. ::: ### Running the Container as Your Host User By default Docker containers run as `root` (UID 0). Files created inside `/workspace` or other bind-mounts end up owned by root on the host, so after a session you have to `sudo chown` them before you can edit them from your host editor. The `terminal.docker_run_as_host_user` flag fixes this: ```yaml terminal: backend: docker docker_run_as_host_user: true # default: false ``` When enabled, Claway appends `--user $(id -u):$(id -g)` to the `docker run` command so files written into bind-mounted directories (`/workspace`, `/root`, anything in `docker_volumes`) are owned by your host user, not root. The trade-off: the container can no longer `apt install` or write to root-owned paths like `/root/.npm` — use a base image whose `HOME` is owned by a non-root user (or add your required tooling at image build time) if you need both. Leave this `false` (the default) for backwards-compatible behavior. Turn it on when your workflow is mostly "edit mounted host files" and you're tired of `sudo chown -R`. ### Optional: Mount the Launch Directory into `/workspace` Docker sandboxes stay isolated by default. Claway does **not** pass your current host working directory into the container unless you explicitly opt in. Enable it in `config.yaml`: ```yaml terminal: backend: docker docker_mount_cwd_to_workspace: true ``` When enabled: - if you launch Claway from `~/projects/my-app`, that host directory is bind-mounted to `/workspace` - the Docker backend starts in `/workspace` - file tools and terminal commands both see the same mounted project When disabled, `/workspace` stays sandbox-owned unless you explicitly mount something via `docker_volumes`. Security tradeoff: - `false` preserves the sandbox boundary - `true` gives the sandbox direct access to the directory you launched Claway from Use the opt-in only when you intentionally want the container to work on live host files. ### Persistent Shell By default, each terminal command runs in its own subprocess — working directory, environment variables, and shell variables reset between commands. When **persistent shell** is enabled, a single long-lived bash process is kept alive across `execute()` calls so that state survives between commands. This is most useful for the **SSH backend**, where it also eliminates per-command connection overhead. Persistent shell is **enabled by default for SSH** and disabled for the local backend. ```yaml terminal: persistent_shell: true # default — enables persistent shell for SSH ``` To disable: ```bash claway config set terminal.persistent_shell false ``` **What persists across commands:** - Working directory (`cd /tmp` sticks for the next command) - Exported environment variables (`export FOO=bar`) - Shell variables (`MY_VAR=hello`) **Precedence:** | Level | Variable | Default | |-------|----------|---------| | Config | `terminal.persistent_shell` | `true` | | SSH override | `TERMINAL_SSH_PERSISTENT` | follows config | | Local override | `TERMINAL_LOCAL_PERSISTENT` | `false` | Per-backend environment variables take highest precedence. If you want persistent shell on the local backend too: ```bash export TERMINAL_LOCAL_PERSISTENT=true ``` :::note Commands that require `stdin_data` or sudo automatically fall back to one-shot mode, since the persistent shell's stdin is already occupied by the IPC protocol. ::: See [Code Execution](features/code-execution.md) and the [Terminal section of the README](features/tools.md) for details on each backend. ## Skill Settings Skills can declare their own configuration settings via their SKILL.md frontmatter. These are non-secret values (paths, preferences, domain settings) stored under the `skills.config` namespace in `config.yaml`. ```yaml skills: config: myplugin: path: ~/myplugin-data # Example — each skill defines its own keys ``` **How skill settings work:** - `claway config migrate` scans all enabled skills, finds unconfigured settings, and offers to prompt you - `claway config show` displays all skill settings under "Skill Settings" with the skill they belong to - When a skill loads, its resolved config values are injected into the skill context automatically **Setting values manually:** ```bash claway config set skills.config.myplugin.path ~/myplugin-data ``` For details on declaring config settings in your own skills, see [Creating Skills — Config Settings](/developer-guide/creating-skills#config-settings-configyaml). ### Guard on agent-created skill writes When the agent uses `skill_manage` to create, edit, patch, or delete a skill, Claway can optionally scan the new/updated content for dangerous keyword patterns (credential harvesting, obvious prompt injection, exfil instructions). The scanner is **off by default** — real agent workflows that legitimately touch `~/.ssh/` or mention `$OPENAI_API_KEY` were tripping the heuristic too often. Turn it back on if you want the scanner to prompt you before the agent's skill writes land: ```yaml skills: guard_agent_created: true # default: false ``` When on, any flagged `skill_manage` write surfaces as an approval prompt with the scanner's rationale. Accepted writes land; denied writes return an explanatory error to the agent. ### Write approval for skill writes Independent of the content scanner above, `skills.write_approval` gates **every** agent skill write (create / edit / patch / delete / supporting files) behind your explicit approval — the same approve/deny mechanism as dangerous commands: ```yaml skills: write_approval: false # false = write freely (default) | true = stage every write for review ``` When on, skill writes are staged under `~/.claway/pending/skills/` and reviewed with `/skills pending`, `/skills diff <id>`, `/skills approve <id>`, `/skills reject <id>` — from the CLI or any messaging platform. Toggle at runtime with `/skills approval on|off`. Memory has the same gate (`memory.write_approval`, below). Full walkthrough: [Gating agent skill writes](/user-guide/features/skills#gating-agent-skill-writes-skillswrite_approval). ## Memory Configuration ```yaml memory: memory_enabled: true user_profile_enabled: true memory_char_limit: 2200 # ~800 tokens user_char_limit: 1375 # ~500 tokens write_approval: false # true = require approval before any memory write ``` With `memory.write_approval: true`, memory writes need your approval before they land: interactive CLI turns prompt inline; messaging sessions and the background self-improvement review stage the write for `/memory pending` → `/memory approve <id>` / `/memory reject <id>` review. Toggle at runtime with `/memory approval on|off`. See [Controlling memory writes](/user-guide/features/memory#controlling-memory-writes-write_approval). ## Context File Truncation Controls how much content Claway loads from each automatic context file before applying head/tail truncation. This applies to files injected into the system prompt such as `SOUL.md`, `.claway.md`, `AGENTS.md`, `CLAUDE.md`, and `.cursorrules`. It does **not** affect the `read_file` tool. ```yaml context_file_max_chars: 20000 # default ``` Raise it when you intentionally keep larger identity or project-context files and run models with enough context window to carry them: ```yaml context_file_max_chars: 25000 ``` ## File Read Safety Controls how much content a single `read_file` call can return. Reads that exceed the limit are rejected with an error telling the agent to use `offset` and `limit` for a smaller range. This prevents a single read of a minified JS bundle or large data file from flooding the context window. ```yaml file_read_max_chars: 100000 # default — ~25-35K tokens ``` Raise it if you're on a model with a large context window and frequently read big files. Lower it for small-context models to keep reads efficient: ```yaml # Large context model (200K+) file_read_max_chars: 200000 # Small local model (16K context) file_read_max_chars: 30000 ``` The agent also deduplicates file reads automatically — if the same file region is read twice and the file hasn't changed, a lightweight stub is returned instead of re-sending the content. This resets on context compression so the agent can re-read files after their content is summarized away. ## Tool Output Truncation Limits Three related caps control how much raw output a tool can return before Claway truncates it: ```yaml tool_output: max_bytes: 50000 # terminal output cap (chars) max_lines: 2000 # read_file pagination cap max_line_length: 2000 # per-line cap in read_file's line-numbered view ``` - **`max_bytes`** — When a `terminal` command produces more than this many characters of combined stdout/stderr, Claway keeps the first 40% and last 60% and inserts a `[OUTPUT TRUNCATED]` notice between them. Default `50000` (≈12-15K tokens across typical tokenisers). - **`max_lines`** — Upper bound on the `limit` parameter of a single `read_file` call. Requests above this are clamped so a single read can't flood the context window. Default `2000`. - **`max_line_length`** — Per-line cap applied when `read_file` emits the line-numbered view. Lines longer than this are truncated to this many chars followed by `... [truncated]`. Default `2000`. Raise the limits on models with large context windows that can afford more raw output per call. Lower them for small-context models to keep tool results compact: ```yaml # Large context model (200K+) tool_output: max_bytes: 150000 max_lines: 5000 # Small local model (16K context) tool_output: max_bytes: 20000 max_lines: 500 ``` ## Global Toolset Disable To suppress specific toolsets across the CLI and every gateway platform in one place, list their names under `agent.disabled_toolsets`: ```yaml agent: disabled_toolsets: - memory # hide memory tools + MEMORY_GUIDANCE injection - web # no web_search / web_extract anywhere ``` This applies **after** per-platform tool config (`platform_toolsets` written by `claway tools`), so a toolset listed here is always removed — even if a platform's saved config still lists it. Use this when you want a single switch for "turn X off everywhere" rather than editing 15+ platform rows in the `claway tools` UI. Leaving the list empty, or omitting the key, is a no-op. ## Git Worktree Isolation Enable isolated git worktrees for running multiple agents in parallel on the same repo: ```yaml worktree: true # Always create a worktree (same as claway -w) # worktree: false # Default — only when -w flag is passed ``` When enabled, each CLI session creates a fresh worktree under `.worktrees/` with its own branch. Agents can edit files, commit, push, and create PRs without interfering with each other. Clean worktrees are removed on exit; dirty ones are kept for manual recovery. By default the new worktree branches from the **freshly-fetched remote tip** (the current branch's upstream, otherwise the remote's default branch) so it starts current with the project rather than from the local clone's possibly-stale `HEAD`. This keeps a PR's diff scoped to the actual change instead of inheriting whatever the local clone was behind by. Set `worktree_sync: false` to branch from local `HEAD` instead — useful offline, or when you deliberately want the clone's exact current state as the base. If the remote can't be reached, it falls back to local `HEAD` automatically. ```yaml worktree_sync: true # Default — branch from the fetched remote tip # worktree_sync: false # Branch from local HEAD (offline / pinned base) ``` You can also list gitignored files to copy into worktrees via `.worktreeinclude` in your repo root: ``` # .worktreeinclude .env .venv/ node_modules/ ``` ## Context Compression Claway automatically compresses long conversations to stay within your model's context window. The compression summarizer is a separate LLM call — you can point it at any provider or endpoint. All compression settings live in `config.yaml` (no environment variables). ### Full reference ```yaml compression: enabled: true # Toggle compression on/off threshold: 0.50 # Compress at this % of context limit target_ratio: 0.20 # Fraction of threshold to preserve as recent tail protect_last_n: 20 # Min recent messages to keep uncompressed protect_first_n: 3 # Non-system head messages pinned across compactions (0 = pin nothing) hygiene_hard_message_limit: 5000 # Gateway safety valve — see below # The summarization model/provider is configured under auxiliary: auxiliary: compression: model: "" # Empty = use main chat model. Override with e.g. "google/gemini-3-flash-preview" for cheaper/faster compression. provider: "auto" # Provider: "auto", "openrouter", "codex", "main", etc. base_url: null # Custom OpenAI-compatible endpoint (overrides provider) ``` :::info Legacy config migration Older configs with `compression.summary_model`, `compression.summary_provider`, and `compression.summary_base_url` are automatically migrated to `auxiliary.compression.*` on first load (config version 17). No manual action needed. ::: `hygiene_hard_message_limit` is a gateway-only **pre-compression safety valve**. It exists to break a death spiral: when API calls keep disconnecting on an oversized session, the gateway never receives token-usage data, so the token-based threshold can't fire, so the transcript keeps growing and disconnects get worse. This count-based floor fires on message count alone (always known, regardless of API failures) to force compression and recover the session. Default `5000` — far above any normal session, including large-context (1M+) models doing thousands of short turns, which compress on the token threshold long before this. Raise it further for unusual platforms, lower it to force more aggressive compression. Editing this value on a running gateway takes effect on the next message (see below). `protect_first_n` controls how many **non-system** head messages are pinned across every compaction. Default `3` — the opening user/assistant exchange survives every summarizer pass so the original goal stays visible. On long-running rolling-compaction sessions where the opening turn is no longer relevant, set `protect_first_n: 0` to pin nothing but the system prompt + summary + tail. The system prompt itself is always preserved regardless of this setting. :::tip Gateway hot-reload of compression and context length As of recent releases, editing `model.context_length` or any `compression.*` key in `config.yaml` on a running gateway takes effect on the next message — no gateway restart, no `/reset`, no session rotation required. The cached-agent signature includes these keys, so the gateway transparently rebuilds the agent when it sees a change. API keys and tool/skill config still require the usual reload paths. ::: ### Common setups **Default (auto-detect) — no configuration needed:** ```yaml compression: enabled: true threshold: 0.50 ``` Uses your main provider and main model. Override per-task (e.g. `auxiliary.compression.provider: openrouter` + `model: google/gemini-2.5-flash`) if you want compression on a cheaper model than your main chat model. **Force a specific provider** (OAuth or API-key based): ```yaml auxiliary: compression: provider: openrouter model: gemini-3-flash ``` Works with any provider: `openrouter`, `codex`, `anthropic`, `main`, etc. **Custom endpoint** (self-hosted, Ollama, zai, DeepSeek, etc.): ```yaml auxiliary: compression: model: glm-4.7 base_url: https://api.z.ai/api/coding/paas/v4 ``` Points at a custom OpenAI-compatible endpoint. Uses `OPENAI_API_KEY` for auth. ### How the three knobs interact | `auxiliary.compression.provider` | `auxiliary.compression.base_url` | Result | |---------------------|---------------------|--------| | `auto` (default) | not set | Auto-detect best available provider | | `openrouter` / etc. | not set | Force that provider, use its auth | | any | set | Use the custom endpoint directly (provider ignored) | :::warning Summary model context length requirement The summary model **must** have a context window at least as large as your main agent model's. The compressor sends the full middle section of the conversation to the summary model — if that model's context window is smaller than the main model's, the summarization call will fail with a context length error. When this happens, the middle turns are **dropped without a summary**, losing conversation context silently. If you override the model, verify its context length meets or exceeds your main model's. ::: ## Context Engine The context engine controls how conversations are managed when approaching the model's token limit. The built-in `compressor` engine uses lossy summarization (see Context Compression). Plugin engines can replace it with alternative strategies. ```yaml context: engine: "compressor" # default — built-in lossy summarization ``` To use a plugin engine (e.g., LCM for lossless context management): ```yaml context: engine: "lcm" # must match the plugin's name ``` Plugin engines are **never auto-activated** — you must explicitly set `context.engine` to the plugin name. Available engines can be browsed and selected via `claway plugins` → Provider Plugins → Context Engine. See [Memory Providers](/user-guide/features/memory-providers) for the analogous single-select system for memory plugins. ## Iteration Budget Pressure When the agent is working on a complex task with many tool calls, it can burn through its iteration budget (default: 90 turns) without realizing it's running low. Budget pressure automatically warns the model as it approaches the limit: | Threshold | Level | What the model sees | |-----------|-------|---------------------| | **70%** | Caution | `[BUDGET: 63/90. 27 iterations left. Start consolidating.]` | | **90%** | Warning | `[BUDGET WARNING: 81/90. Only 9 left. Respond NOW.]` | Warnings are injected into the last tool result's JSON (as a `_budget_warning` field) rather than as separate messages — this preserves prompt caching and doesn't disrupt the conversation structure. ```yaml agent: max_turns: 90 # Max iterations per conversation turn (default: 90) api_max_retries: 3 # Retries per provider before fallback engages (default: 3) ``` Budget pressure is enabled by default. The agent sees warnings naturally as part of tool results, encouraging it to consolidate its work and deliver a response before running out of iterations. When the iteration budget is fully exhausted, the CLI shows a notification to the user: `⚠ Iteration budget reached (90/90) — response may be incomplete`. If the budget runs out during active work, the agent generates a summary of what was accomplished before stopping. `agent.api_max_retries` controls how many times Claway retries a provider API call on transient errors (rate limits, connection drops, 5xx) **before** fallback-provider switching engages. The default is `3` — four attempts total. If you have [fallback providers](/user-guide/features/fallback-providers) configured and want to fail over faster, drop this to `0` so the first transient error on your primary immediately hands off to the fallback instead of churning retries against the flaky endpoint. ## Standing Goals (`/goal`) When a standing goal is active, Claway judges whether each assistant response satisfies it. If not, it feeds a continuation prompt back into the same session and keeps working until the goal is done, the turn budget is exhausted, or the user pauses/clears it. The turn budget is the real backstop — judge failures fail **open** (continue) so a flaky judge never wedges progress. ```yaml goals: max_turns: 20 # Max continuation turns before Claway auto-pauses the goal (default: 20) ``` `max_turns` caps how many continuation turns a goal can drive before Claway auto-pauses it and asks the user to `/goal resume`. It protects against judge false negatives (goal actually done but judge says continue) and unbounded model spend on fuzzy or unachievable goals. See [Goals](/user-guide/features/goals) for the full feature. ### API Timeouts Claway has separate timeout layers for streaming, plus a stale detector for non-streaming calls. The stale detectors auto-adjust for local providers only when you leave them at their implicit defaults. | Timeout | Default | Local providers | Config / env | |---------|---------|----------------|--------------| | Socket read timeout | 120s | Auto-raised to 1800s | `CLAWAY_STREAM_READ_TIMEOUT` | | Stale stream detection | 180s | Auto-disabled | `CLAWAY_STREAM_STALE_TIMEOUT` | | Stale non-stream detection | 300s | Auto-disabled when left implicit | `providers.<id>.stale_timeout_seconds` or `CLAWAY_API_CALL_STALE_TIMEOUT` | | API call (non-streaming) | 1800s | Unchanged | `providers.<id>.request_timeout_seconds` / `timeout_seconds` or `CLAWAY_API_TIMEOUT` | The **socket read timeout** controls how long httpx waits for the next chunk of data from the provider. Local LLMs can take minutes for prefill on large contexts before producing the first token, so Claway raises this to 30 minutes when it detects a local endpoint. If you explicitly set `CLAWAY_STREAM_READ_TIMEOUT`, that value is always used regardless of endpoint detection. The **stale stream detection** kills connections that receive SSE keep-alive pings but no actual content. This is disabled entirely for local providers since they don't send keep-alive pings during prefill. The **stale non-stream detection** kills non-streaming calls that produce no response for too long. By default Claway disables this on local endpoints to avoid false positives during long prefills. If you explicitly set `providers.<id>.stale_timeout_seconds`, `providers.<id>.models.<model>.stale_timeout_seconds`, or `CLAWAY_API_CALL_STALE_TIMEOUT`, that explicit value is honored even on local endpoints. ## Context Pressure Warnings Separate from iteration budget pressure, context pressure tracks how close the conversation is to the **compaction threshold** — the point where context compression fires to summarize older messages. This helps both you and the agent understand when the conversation is getting long. | Progress | Level | What happens | |----------|-------|-------------| | **≥ 60%** to threshold | Info | CLI shows a cyan progress bar; gateway sends an informational notice | | **≥ 85%** to threshold | Warning | CLI shows a bold yellow bar; gateway warns compaction is imminent | In the CLI, context pressure appears as a progress bar in the tool output feed: ``` ◐ context ████████████░░░░░░░░ 62% to compaction 48k threshold (50%) · approaching compaction ``` On messaging platforms, a plain-text notification is sent: ``` ◐ Context: ████████████░░░░░░░░ 62% to compaction (threshold: 50% of window). ``` If auto-compression is disabled, the warning tells you context may be truncated instead. Context pressure is automatic — no configuration needed. It fires purely as a user-facing notification and does not modify the message stream or inject anything into the model's context. ## Credential Pool Strategies When you have multiple API keys or OAuth tokens for the same provider, configure the rotation strategy: ```yaml credential_pool_strategies: openrouter: round_robin # cycle through keys evenly anthropic: least_used # always pick the least-used key ``` Options: `fill_first` (default), `round_robin`, `least_used`, `random`. See [Credential Pools](/user-guide/features/credential-pools) for full documentation. ## Prompt caching Claway turns on cross-session prompt caching automatically when the active provider supports it — no user config needed. For Claude on **native Anthropic** and **OpenRouter**, Claway attaches `cache_control` breakpoints with the 1-hour TTL (`ttl: "1h"`) on the system prompt and skill blocks. The first send within a fresh hour pays full input rates; subsequent sends across any session within the same hour pull from the cache at the discounted cached-read rate. This means the system prompt, loaded skill content, and the early portion of any long-context include get reused across `claway` sessions and across forked subagents for the first hour. The Qwen Cloud (Alibaba DashScope) upstream caps cache TTL at 5 minutes, so Claway uses the 5-minute breakpoint TTL there instead. Other Claude-via-third-party paths (AWS Bedrock, Azure Foundry) fall back to the provider's own caching defaults. xAI Grok uses a separate session-pinned conversation-id mechanism — see [xAI prompt caching](/integrations/providers#xai-grok--responses-api--prompt-caching). No knob exists to disable this — caching is always-on and saves money even on single-turn conversations because the system prompt alone is a meaningful fraction of the input token count. The one explicit knob is the cache TTL tier Claway requests on Anthropic-style breakpoints: ```yaml prompt_caching: cache_ttl: "5m" # "5m" or "1h" (Anthropic-supported tiers); other values are ignored ``` `cache_ttl` selects the breakpoint TTL Claway attaches for Claude via the native Anthropic API and OpenRouter. Only the two Anthropic-supported tiers (`"5m"`, `"1h"`) are honored — any other value is ignored. Providers with their own caps (e.g. Qwen Cloud, which maxes at 5 minutes) still clamp to what the upstream allows. ## Auxiliary Models Claway uses "auxiliary" models for side tasks like image analysis, web page summarization, browser screenshot analysis, session-title generation, and context compression. By default (`auxiliary.*.provider: "auto"`), Claway routes every auxiliary task to your **main chat model** — the same provider/model you picked in `claway model`. You don't need to configure anything to get started, but be aware that on expensive reasoning models (Opus, MiniMax M2.7, etc.) auxiliary tasks add meaningful cost. If you want cheap-and-fast side tasks regardless of your main model, set `auxiliary.<task>.provider` and `auxiliary.<task>.model` explicitly (for example, Gemini Flash on OpenRouter for vision and web extraction). :::note Why "auto" uses your main model Earlier builds split aggregator users (such as OpenRouter) onto a cheap provider-side default. That was surprising — users who paid for an aggregator subscription would see a different model handling their auxiliary traffic. `auto` now uses the main model for everyone, and per-task overrides in `config.yaml` still win (see [Full auxiliary config reference](#full-auxiliary-config-reference) below). ::: ### Configuring auxiliary models interactively Instead of hand-editing YAML, run `claway model` and pick **"Configure auxiliary models"** from the menu. You'll get an interactive per-task picker: ``` $ claway model → Configure auxiliary models [ ] vision currently: auto / main model [ ] web_extract currently: auto / main model [ ] title_generation currently: openrouter / google/gemini-3-flash-preview [ ] tts_audio_tags currently: auto / main model [ ] compression currently: auto / main model [ ] approval currently: auto / main model [ ] triage_specifier currently: auto / main model [ ] kanban_decomposer currently: auto / main model [ ] profile_describer currently: auto / main model ``` Select a task, pick a provider (OAuth flows open a browser; API-key providers prompt), pick a model. The change persists to `auxiliary.<task>.*` in `config.yaml`. Same machinery as the main-model picker — no extra syntax to learn. ### The universal config pattern Every model slot in Claway — auxiliary tasks, compression, fallback — uses the same three knobs: | Key | What it does | Default | |-----|-------------|---------| | `provider` | Which provider to use for auth and routing | `"auto"` | | `model` | Which model to request | provider's default | | `base_url` | Custom OpenAI-compatible endpoint (overrides provider) | not set | When `base_url` is set, Claway ignores the provider and calls that endpoint directly (using `api_key` or `OPENAI_API_KEY` for auth). When only `provider` is set, Claway uses that provider's built-in auth and base URL. Available providers for auxiliary tasks: `auto`, `main`, plus any provider in the [provider registry](/reference/environment-variables) — `openrouter`, `openai-codex`, `copilot`, `copilot-acp`, `anthropic`, `gemini`, `qwen-oauth`, `zai`, `kimi-coding`, `kimi-coding-cn`, `minimax`, `minimax-cn`, `minimax-oauth`, `deepseek`, `nvidia`, `xai`, `xai-oauth`, `ollama-cloud`, `alibaba`, `bedrock`, `huggingface`, `arcee`, `xiaomi`, `kilocode`, `opencode-zen`, `opencode-go`, `azure-foundry` — or any named custom provider from your `custom_providers` list (e.g. `provider: "beans"`). :::tip MiniMax OAuth `minimax-oauth` logs in via browser OAuth (no API key needed). Run `claway model` and select **MiniMax (OAuth)** to authenticate. Auxiliary tasks use `MiniMax-M2.7-highspeed` automatically. See the [MiniMax OAuth guide](../guides/minimax-oauth.md). ::: :::tip xAI Grok OAuth `xai-oauth` logs in via browser OAuth for SuperGrok and X Premium+ subscribers (no API key needed). Run `claway model` and select **xAI Grok OAuth (SuperGrok / Premium+)** to authenticate. The same OAuth token is reused for every direct-to-xAI surface (chat, auxiliary tasks, TTS, image gen, video gen, transcription). See the [xAI Grok OAuth guide](../guides/xai-grok-oauth.md), and if Claway is on a remote host see [OAuth over SSH / Remote Hosts](../guides/oauth-over-ssh.md). ::: :::warning `"main"` is for auxiliary tasks only The `"main"` provider option means "use whatever provider my main agent uses" — it's only valid inside `auxiliary:`, `compression:`, and primary fallback entries (`fallback_providers:` or legacy `fallback_model:`). It is **not** a valid value for your top-level `model.provider` setting. If you use a custom OpenAI-compatible endpoint, set `provider: custom` in your `model:` section. See [AI Providers](/integrations/providers) for all main model provider options. ::: ### Full auxiliary config reference ```yaml auxiliary: # Image analysis (vision_analyze tool + browser screenshots) vision: provider: "auto" # "auto", "openrouter", "codex", "main", etc. model: "" # e.g. "openai/gpt-4o", "google/gemini-2.5-flash" base_url: "" # Custom OpenAI-compatible endpoint (overrides provider) api_key: "" # API key for base_url (falls back to OPENAI_API_KEY) timeout: 120 # seconds — LLM API call timeout; vision payloads need generous timeout download_timeout: 30 # seconds — image HTTP download; increase for slow connections max_concurrency: 8 # max concurrent image encode/resize bursts across the process # (default: host CPU core count, no ceiling) — bounds only the # CPU-bound encode step so a video-frame fan-out can't saturate # every core and starve the event loop; LLM calls stay fully # concurrent. Minimum 1; values < 1 are ignored. # Web page summarization + browser page text extraction web_extract: provider: "auto" model: "" # e.g. "google/gemini-2.5-flash" base_url: "" api_key: "" timeout: 360 # seconds (6min) — per-attempt LLM summarization # Dangerous command approval classifier approval: provider: "auto" model: "" base_url: "" api_key: "" timeout: 30 # seconds # Gemini 3.1 TTS hidden audio-tag insertion tts_audio_tags: provider: "auto" model: "" # empty = main chat model base_url: "" api_key: "" timeout: 30 # Context compression timeout (separate from compression.* config) compression: timeout: 120 # seconds — compression summarizes long conversations, needs more time # fallback_chain: # Optional — providers to try on rate-limit / connectivity failure # - provider: deepseek # model: deepseek-chat # - provider: openrouter # model: google/gemini-2.5-flash # base_url: "" # api_key: "" # Auto-generated session titles. Empty language follows the conversation; # set e.g. "English" or "Japanese" to pin titles to one language. title_generation: provider: "auto" model: "" base_url: "" api_key: "" timeout: 30 language: "" # Skills hub — skill matching and search skills_hub: provider: "auto" model: "" base_url: "" api_key: "" timeout: 30 # MCP tool dispatch mcp: provider: "auto" model: "" base_url: "" api_key: "" timeout: 30 # Kanban triage specifier — `claway kanban specify <id>` (or the # dashboard's ✨ Specify button on Triage-column cards) uses this # slot to expand a one-liner into a concrete spec and promote the # task to `todo`. Cheap fast models work well here; spec expansion # is short and doesn't need reasoning depth. triage_specifier: provider: "auto" model: "" base_url: "" api_key: "" timeout: 120 ``` :::tip Each auxiliary task has a configurable `timeout` (in seconds). Defaults: vision 120s, web_extract 360s, approval 30s, compression 120s. Increase these if you use slow local models for auxiliary tasks. Vision also has a separate `download_timeout` (default 30s) for the HTTP image download — increase this for slow connections or self-hosted image servers. ::: :::info Context compression has its own `compression:` block for thresholds and an `auxiliary.compression:` block for model/provider settings — see [Context Compression](#context-compression) above. The primary fallback chain uses a top-level `fallback_providers:` list — see [Fallback Providers](/integrations/providers#fallback-providers). All three follow the same provider/model/base_url pattern. ::: ### Per-task fallback chain for auxiliary tasks Each auxiliary task can optionally define a `fallback_chain` — a list of provider/model entries that Claway tries when the primary auxiliary provider fails due to rate limits, connectivity issues, or payment restrictions: ```yaml auxiliary: compression: provider: openrouter model: openai/gpt-4o-mini fallback_chain: - provider: deepseek model: deepseek-chat - provider: gemini model: gemini-2.5-flash ``` When the primary auxiliary provider (`openrouter` / `openai/gpt-4o-mini`) returns a rate-limit, connection timeout, or payment-required error, Claway walks the `fallback_chain` in order. It skips entries whose provider matches the already-failed provider, and tries each remaining entry until one succeeds or the chain is exhausted. If all fallbacks fail, Claway falls back to the main agent model as a final safety net. Each entry supports the same three knobs as any auxiliary task config: | Key | Description | |-----|-------------| | `provider` | Provider name (`openrouter`, `anthropic`, `gemini`, `main`, etc.) | | `model` | Model name for that provider | | `base_url` | (Optional) Custom OpenAI-compatible endpoint | `fallback_chain` is available on any auxiliary task — `compression`, `vision`, `web_extract`, `approval`, `skills_hub`, `mcp`, etc. ### OpenRouter routing & Pareto Code for auxiliary tasks When an auxiliary task resolves to OpenRouter (either explicitly or via `provider: "main"` while your main agent is on OpenRouter), the main agent's `provider_routing` and `openrouter.min_coding_score` settings **do not propagate** — by design, each auxiliary task is independent. To set OpenRouter provider preferences or use the [Pareto Code router](/integrations/providers#openrouter-pareto-code-router) for a specific aux task, set them per-task via `extra_body`: ```yaml auxiliary: compression: provider: openrouter model: openrouter/pareto-code # use the Pareto Code router for this task extra_body: provider: # OpenRouter provider routing prefs order: [anthropic, google] # try these providers in order sort: throughput # or "price" | "latency" # only: [anthropic] # restrict to a specific provider # ignore: [deepinfra] # exclude specific providers plugins: # OpenRouter Pareto Code router knob - id: pareto-router min_coding_score: 0.5 # 0.0–1.0; higher = stronger coders ``` The shape mirrors what OpenRouter accepts in the chat completions request body. Claway forwards the entire `extra_body` verbatim, so any other OpenRouter request-body field documented at [openrouter.ai/docs](https://openrouter.ai/docs) works the same way. ### Changing the Vision Model To use GPT-4o instead of Gemini Flash for image analysis: ```yaml auxiliary: vision: model: "openai/gpt-4o" ``` Or via environment variable (in `~/.claway/.env`): ```bash AUXILIARY_VISION_MODEL=openai/gpt-4o ``` ### Provider Options These options apply to **auxiliary task configs** (`auxiliary:`, `compression:`) and primary fallback entries (`fallback_providers:` or legacy `fallback_model:`), not to your main `model.provider` setting. | Provider | Description | Requirements | |----------|-------------|-------------| | `"auto"` | Best available (default). Vision tries OpenRouter, then the other configured vision-capable providers. | — | | `"openrouter"` | Force OpenRouter — routes to any model (Gemini, GPT-4o, Claude, etc.) | `OPENROUTER_API_KEY` | | `"codex"` | Force Codex OAuth (ChatGPT account). Supports vision (gpt-5.3-codex). | `claway model` → Codex | | `"minimax-oauth"` | Force MiniMax OAuth (browser login, no API key). Uses MiniMax-M2.7-highspeed for auxiliary tasks. | `claway model` → MiniMax (OAuth) | | `"xai-oauth"` | Force xAI Grok OAuth (browser login for SuperGrok or X Premium+ subscribers, no API key). Same OAuth token covers chat, TTS, image, video, and transcription. | `claway model` → xAI Grok OAuth (SuperGrok / Premium+) | | `"main"` | Use your active custom/main endpoint. This can come from `OPENAI_BASE_URL` + `OPENAI_API_KEY` or from a custom endpoint saved via `claway model` / `config.yaml`. Works with OpenAI, local models, or any OpenAI-compatible API. **Auxiliary tasks only — not valid for `model.provider`.** | Custom endpoint credentials + base URL | Direct API-key providers from the main provider catalog also work here when you want side tasks to bypass your default router. `gmi` is valid once `GMI_API_KEY` is configured: ```yaml auxiliary: compression: provider: "gmi" model: "anthropic/claude-opus-4.6" ``` For GMI auxiliary routing, use the exact model ID returned by GMI's `/v1/models` endpoint. ### Common Setups **Using a direct custom endpoint** (clearer than `provider: "main"` for local/self-hosted APIs): ```yaml auxiliary: vision: base_url: "http://localhost:1234/v1" api_key: "local-key" model: "qwen2.5-vl" ``` `base_url` takes precedence over `provider`, so this is the most explicit way to route an auxiliary task to a specific endpoint. For direct endpoint overrides, Claway uses the configured `api_key` or falls back to `OPENAI_API_KEY`; it does not reuse `OPENROUTER_API_KEY` for that custom endpoint. **Using OpenAI API key for vision:** ```yaml # In ~/.claway/.env: # OPENAI_BASE_URL=https://api.openai.com/v1 # OPENAI_API_KEY=sk-... auxiliary: vision: provider: "main" model: "gpt-4o" # or "gpt-4o-mini" for cheaper ``` **Using OpenRouter for vision** (route to any model): ```yaml auxiliary: vision: provider: "openrouter" model: "openai/gpt-4o" # or "google/gemini-2.5-flash", etc. ``` **Using Codex OAuth** (ChatGPT Pro/Plus account — no API key needed): ```yaml auxiliary: vision: provider: "codex" # uses your ChatGPT OAuth token # model defaults to gpt-5.3-codex (supports vision) ``` **Using MiniMax OAuth** (browser login, no API key needed): ```yaml model: default: MiniMax-M2.7 provider: minimax-oauth base_url: https://api.minimax.io/anthropic ``` Run `claway model` and select **MiniMax (OAuth)** to log in and set this automatically. For the China region, the base URL will be `https://api.minimaxi.com/anthropic`. See the [MiniMax OAuth guide](../guides/minimax-oauth.md) for the full walkthrough. **Using a local/self-hosted model:** ```yaml auxiliary: vision: provider: "main" # uses your active custom endpoint model: "my-local-model" ``` `provider: "main"` uses whatever provider Claway uses for normal chat — whether that's a named custom provider (e.g. `beans`), a built-in provider like `openrouter`, or a legacy `OPENAI_BASE_URL` endpoint. :::tip If you use Codex OAuth as your main model provider, vision works automatically — no extra configuration needed. Codex is included in the auto-detection chain for vision. ::: :::warning **Vision requires a multimodal model.** If you set `provider: "main"`, make sure your endpoint supports multimodal/vision — otherwise image analysis will fail. ::: ### Environment Variables (legacy) Auxiliary models can also be configured via environment variables. However, `config.yaml` is the preferred method — it's easier to manage and supports all options including `base_url` and `api_key`. | Setting | Environment Variable | |---------|---------------------| | Vision provider | `AUXILIARY_VISION_PROVIDER` | | Vision model | `AUXILIARY_VISION_MODEL` | | Vision endpoint | `AUXILIARY_VISION_BASE_URL` | | Vision API key | `AUXILIARY_VISION_API_KEY` | | Web extract provider | `AUXILIARY_WEB_EXTRACT_PROVIDER` | | Web extract model | `AUXILIARY_WEB_EXTRACT_MODEL` | | Web extract endpoint | `AUXILIARY_WEB_EXTRACT_BASE_URL` | | Web extract API key | `AUXILIARY_WEB_EXTRACT_API_KEY` | Compression and fallback model settings are config.yaml-only. :::tip Run `claway config` to see your current auxiliary model settings. Overrides only show up when they differ from the defaults. ::: ## Reasoning Effort Control how much "thinking" the model does before responding: ```yaml agent: reasoning_effort: "" # empty = medium (default). Options: none, minimal, low, medium, high, xhigh (max) ``` When unset (default), reasoning effort defaults to "medium" — a balanced level that works well for most tasks. Setting a value overrides it — higher reasoning effort gives better results on complex tasks at the cost of more tokens and latency. :::note Adaptive-thinking models (Claude 4.6+, Fable/Mythos-class) over OpenRouter These models use *adaptive* thinking and don't accept the usual `reasoning.effort` field — OpenRouter ignores it for them. Claway transparently routes your `reasoning_effort` to OpenRouter's `verbosity` parameter instead (which maps to Anthropic's `output_config.effort`), so the same `low`/`medium`/`high`/`xhigh` knob keeps working — no extra configuration needed. `none` (or unset) leaves the model on its own adaptive default. (`max` is accepted on the wire but is not a selectable `reasoning_effort` value; `xhigh` is the configurable ceiling.) The native Anthropic provider already controls effort directly and is unaffected. ::: You can also change the reasoning effort at runtime with the `/reasoning` command: ``` /reasoning # Show current effort level and display state /reasoning high # Set reasoning effort to high /reasoning none # Disable reasoning /reasoning show # Show model thinking above each response /reasoning hide # Hide model thinking ``` ## Tool-Use Enforcement Some models occasionally describe intended actions as text instead of making tool calls ("I would run the tests..." instead of actually calling the terminal). Tool-use enforcement injects system prompt guidance that steers the model back to actually calling tools. ```yaml agent: tool_use_enforcement: "auto" # "auto" | true | false | ["model-substring", ...] ``` | Value | Behavior | |-------|----------| | `"auto"` (default) | Enabled for models matching: `gpt`, `codex`, `gemini`, `gemma`, `grok`. Disabled for all others (Claude, DeepSeek, Qwen, etc.). | | `true` | Always enabled, regardless of model. Useful if you notice your current model describing actions instead of performing them. | | `false` | Always disabled, regardless of model. | | `["gpt", "codex", "qwen", "llama"]` | Enabled only when the model name contains one of the listed substrings (case-insensitive). | ### What it injects When enabled, three layers of guidance may be added to the system prompt: 1. **General tool-use enforcement** (all matched models) — instructs the model to make tool calls immediately instead of describing intentions, keep working until the task is complete, and never end a turn with a promise of future action. 2. **OpenAI execution discipline** (GPT and Codex models only) — additional guidance addressing GPT-specific failure modes: abandoning work on partial results, skipping prerequisite lookups, hallucinating instead of using tools, and declaring "done" without verification. 3. **Google operational guidance** (Gemini and Gemma models only) — conciseness, absolute paths, parallel tool calls, and verify-before-edit patterns. These are transparent to the user and only affect the system prompt. Models that already use tools reliably (like Claude) don't need this guidance, which is why `"auto"` excludes them. ### When to turn it on If you're using a model not in the default auto list and notice it frequently describes what it *would* do instead of doing it, set `tool_use_enforcement: true` or add the model substring to the list: ```yaml agent: tool_use_enforcement: ["gpt", "codex", "gemini", "grok", "my-custom-model"] ``` ## Tool-Loop Guardrails Claway detects when the agent is stuck in an unproductive tool-calling loop — the same tool call failing repeatedly, the same tool failing over and over, or an idempotent call returning the same result with no progress. By default it injects a **warning** into the tool result so the model self-corrects; it does not hard-stop, since a person watching the CLI/TUI can intervene. For unattended gateway / server deployments, enable hard stops so a stuck agent is circuit-broken instead of burning the iteration budget: ```yaml tool_loop_guardrails: warnings_enabled: true # inject warnings into tool results (default: true) hard_stop_enabled: false # also BLOCK the call past the hard-stop threshold (default: false) warn_after: exact_failure: 2 # identical failing call repeated N times same_tool_failure: 3 # same tool failing N times (different args) idempotent_no_progress: 2 # same result, no progress, N times hard_stop_after: exact_failure: 5 same_tool_failure: 8 idempotent_no_progress: 5 ``` `hard_stop_enabled` defaults to `false` because interactive sessions have a human in the loop. In unattended deployments (gateway, cron, kanban workers) set it to `true` so repeated failures are blocked rather than only warned. See also Docker / unattended deployments. ## TTS Configuration ```yaml tts: provider: "edge" # "edge" | "elevenlabs" | "openai" | "minimax" | "mistral" | "gemini" | "xai" | "neutts" speed: 1.0 # Global speed multiplier (fallback for all providers) edge: voice: "en-US-AriaNeural" # 322 voices, 74 languages speed: 1.0 # Speed multiplier (converted to rate percentage, e.g. 1.5 → +50%) elevenlabs: voice_id: "pNInz6obpgDQGcFmaJgB" model_id: "eleven_multilingual_v2" openai: model: "gpt-4o-mini-tts" voice: "alloy" # alloy, echo, fable, onyx, nova, shimmer speed: 1.0 # Speed multiplier (clamped to 0.25–4.0 by the API) base_url: "https://api.openai.com/v1" # Override for OpenAI-compatible TTS endpoints minimax: speed: 1.0 # Speech speed multiplier # base_url: "" # Optional: override for OpenAI-compatible TTS endpoints mistral: model: "voxtral-mini-tts-2603" voice_id: "c69964a6-ab8b-4f8a-9465-ec0925096ec8" # Paul - Neutral (default) gemini: model: "gemini-2.5-flash-preview-tts" # or gemini-3.1-flash-tts-preview voice: "Kore" # 30 prebuilt voices: Zephyr, Puck, Kore, Enceladus, etc. audio_tags: false # Hidden Gemini 3.1 TTS audio-tag insertion persona_prompt_file: "" # Optional Markdown/text file with Gemini voice direction xai: voice_id: "eve" # xAI TTS voice language: "en" # ISO 639-1 sample_rate: 24000 bit_rate: 128000 # MP3 bitrate # base_url: "https://api.x.ai/v1" neutts: ref_audio: '' ref_text: '' model: neuphonic/neutts-air-q4-gguf device: cpu ``` This controls both the `text_to_speech` tool and spoken replies in voice mode (`/voice tts` in the CLI or messaging gateway). **Speed fallback hierarchy:** provider-specific speed (e.g. `tts.edge.speed`) → global `tts.speed` → `1.0` default. Set the global `tts.speed` to apply a uniform speed across all providers, or override per-provider for fine-grained control. ## Display Settings ```yaml display: tool_progress: all # off | new | all | verbose tool_progress_command: false # Enable /verbose slash command in messaging gateway platforms: {} # Per-platform display overrides (see below) tool_progress_overrides: {} # DEPRECATED — use display.platforms instead interim_assistant_messages: true # Gateway: send natural mid-turn assistant updates as separate messages skin: default # Built-in or custom CLI skin (see user-guide/features/skins) personality: "kawaii" # Legacy cosmetic field still surfaced in some summaries compact: false # Compact output mode (less whitespace) resume_display: full # full (show previous messages on resume) | minimal (one-liner only) bell_on_complete: false # Play terminal bell when agent finishes (great for long tasks) show_reasoning: false # Show model reasoning/thinking above each response (toggle with /reasoning show|hide) streaming: false # Stream tokens to terminal as they arrive (real-time output) show_cost: false # Show estimated $ cost in the CLI status bar timestamps: false # When true, prefixes user and assistant labels with [HH:MM] timestamps in the CLI / TUI transcript tool_preview_length: 0 # Max chars for tool call previews (0 = no limit, show full paths/commands) runtime_footer: # Gateway: append a runtime-context footer to final replies enabled: false fields: ["model", "context_pct", "cwd"] file_mutation_verifier: true # Append an advisory footer when write_file/patch calls failed this turn language: en # UI language for static messages (approval prompts, some gateway replies). en | zh | zh-hant | ja | de | es | fr | tr | uk | af | ko | it | ga | pt | ru | hu ``` ### File-mutation verifier When `display.file_mutation_verifier` is `true` (default), Claway appends a one-line advisory to the assistant's final response whenever a `write_file` or `patch` call failed during the turn and was never superseded by a successful write to the same path. This catches the "batch of parallel patches, half silently fail, model summarises success" class of over-claim without requiring you to manually run `git status` after every edit. Example footer: ``` ⚠️ File-mutation verifier: 3 file(s) were NOT modified this turn despite any wording above that may suggest otherwise. Run `git status` or `read_file` to confirm. • concepts/automatic-organization.md — [patch] Could not find match for old_string • concepts/lora.md — [patch] Could not find match for old_string • concepts/rag-pipeline.md — [patch] Could not find match for old_string ``` Set `file_mutation_verifier: false` (or `CLAWAY_FILE_MUTATION_VERIFIER=0`) to suppress the footer. The verifier only fires when real failures are outstanding at turn end — a model that retries a failed patch and succeeds within the same turn will not trigger it for that file. ### UI language for static messages The `display.language` setting translates a small set of static user-facing messages — the CLI approval prompt, a handful of gateway slash-command replies (e.g. restart-drain notices, "approval expired", "goal cleared"). It does **not** translate agent responses, log lines, tool output, error tracebacks, or slash-command descriptions — those stay in English. If you want the agent itself to reply in another language, just tell it in your prompt or system message. Supported values: `en` (default), `zh` (Simplified Chinese), `zh-hant` (Traditional Chinese), `ja` (Japanese), `de` (German), `es` (Spanish), `fr` (French), `tr` (Turkish), `uk` (Ukrainian), `af` (Afrikaans), `ko` (Korean), `it` (Italian), `ga` (Irish), `pt` (Portuguese), `ru` (Russian), `hu` (Hungarian). Unknown values fall back to English. You can also set this per-session with the `CLAWAY_LANGUAGE` env var, which overrides the config value. ```yaml display: language: zh # CLI approval prompts appear in Chinese ``` | Mode | What you see | |------|-------------| | `off` | Silent — just the final response | | `new` | Tool indicator only when the tool changes | | `all` | Every tool call with a short preview (default) | | `verbose` | Full args, results, and debug logs | In the CLI, cycle through these modes with `/verbose`. To use `/verbose` in messaging platforms (Telegram, Discord, Slack, etc.), set `tool_progress_command: true` in the `display` section above. The command will then cycle the mode and save to config. Tool progress requires a gateway adapter that can display progress updates safely. Platforms without message editing support, including Signal, suppress tool-progress bubbles even if `/verbose` saves a non-`off` mode. ### Runtime-metadata footer (gateway only) When `display.runtime_footer.enabled: true`, Claway appends a small runtime-context footer to the **final** message of each gateway turn. The current footer can show the model, context-window percentage, and current working directory. Off by default; opt in per-gateway if your team wants every reply to include this provenance. ```yaml display: runtime_footer: enabled: true fields: ["model", "context_pct", "cwd"] # supported fields: model, context_pct, cwd ``` The `/footer` slash command toggles this at runtime in any session. Example footer appended to a Telegram/Discord/Slack reply: ``` — claude-opus-4.7 · 12 tool calls · 2m 14s · $0.042 ``` Only the **final** message of a turn gets the footer; interim updates stay clean. ### Per-platform progress overrides Different platforms have different verbosity needs. Use `display.platforms` to set per-platform modes: ```yaml display: tool_progress: all # global default platforms: signal: tool_progress: 'off' # Signal cannot currently display tool-progress bubbles telegram: tool_progress: verbose # detailed progress on Telegram slack: tool_progress: 'off' # quiet in shared Slack workspace ``` Platforms without an override fall back to the global `tool_progress` value. Valid platform keys: `telegram`, `discord`, `slack`, `signal`, `whatsapp`, `matrix`, `mattermost`, `email`, `sms`, `homeassistant`, `dingtalk`, `feishu`, `wecom`, `weixin`, `bluebubbles`, `qqbot`. The legacy `display.tool_progress_overrides` key still loads for backward compatibility but is deprecated and migrated into `display.platforms` on first load. Signal is listed as a valid platform key because the setting can be saved per platform, but the current Signal adapter cannot edit sent messages and does not render tool-progress bubbles. Keep Signal `tool_progress` set to `off`; use the CLI or an editing-capable messaging platform if you need to watch each tool call live. `interim_assistant_messages` is gateway-only. When enabled, Claway sends completed mid-turn assistant updates as separate chat messages. This is independent from `tool_progress` and does not require gateway streaming. ## Privacy ```yaml privacy: redact_pii: false # Strip PII from LLM context (gateway only) ``` When `redact_pii` is `true`, the gateway redacts personally identifiable information from the system prompt before sending it to the LLM on supported platforms: | Field | Treatment | |-------|-----------| | Phone numbers (user ID on WhatsApp/Signal) | Hashed to `user_<12-char-sha256>` | | User IDs | Hashed to `user_<12-char-sha256>` | | Chat IDs | Numeric portion hashed, platform prefix preserved (`telegram:<hash>`) | | Home channel IDs | Numeric portion hashed | | User names / usernames | **Not affected** (user-chosen, publicly visible) | **Platform support:** Redaction applies to WhatsApp, Signal, and Telegram. Discord and Slack are excluded because their mention systems (`<@user_id>`) require the real ID in the LLM context. Hashes are deterministic — the same user always maps to the same hash, so the model can still distinguish between users in group chats. Routing and delivery use the original values internally. ## Speech-to-Text (STT) ```yaml stt: provider: "local" # "local" | "groq" | "openai" | "mistral" local: model: "base" # tiny, base, small, medium, large-v3 openai: model: "whisper-1" # whisper-1 | gpt-4o-mini-transcribe | gpt-4o-transcribe # model: "whisper-1" # Legacy fallback key still respected ``` Provider behavior: - `local` uses `faster-whisper` running on your machine. Install it separately with `pip install faster-whisper`. - `groq` uses Groq's Whisper-compatible endpoint and reads `GROQ_API_KEY`. - `openai` uses the OpenAI speech API and reads `VOICE_TOOLS_OPENAI_KEY`. If the requested provider is unavailable, Claway falls back automatically in this order: `local` → `groq` → `openai`. Groq and OpenAI model overrides are environment-driven: ```bash STT_GROQ_MODEL=whisper-large-v3-turbo STT_OPENAI_MODEL=whisper-1 GROQ_BASE_URL=https://api.groq.com/openai/v1 STT_OPENAI_BASE_URL=https://api.openai.com/v1 ``` ## Voice Mode (CLI) ```yaml voice: record_key: "ctrl+b" # Push-to-talk key inside the CLI max_recording_seconds: 120 # Hard stop for long recordings auto_tts: false # Enable spoken replies automatically when /voice on beep_enabled: true # Play record start/stop beeps in CLI voice mode silence_threshold: 200 # RMS threshold for speech detection silence_duration: 3.0 # Seconds of silence before auto-stop ``` Use `/voice on` in the CLI to enable microphone mode, `record_key` to start/stop recording, and `/voice tts` to toggle spoken replies. See [Voice Mode](/user-guide/features/voice-mode) for end-to-end setup and platform-specific behavior. ## Streaming Stream tokens to the terminal or messaging platforms as they arrive, instead of waiting for the full response. ### CLI Streaming ```yaml display: streaming: true # Stream tokens to terminal in real-time show_reasoning: true # Also stream reasoning/thinking tokens (optional) ``` When enabled, responses appear token-by-token inside a streaming box. Tool calls are still captured silently. If the provider doesn't support streaming, it falls back to the normal display automatically. ### Gateway Streaming (Telegram, Discord, Slack) ```yaml streaming: enabled: true # Enable progressive message editing transport: edit # "edit" (progressive message editing) or "off" edit_interval: 0.3 # Seconds between message edits buffer_threshold: 40 # Characters before forcing an edit flush cursor: " ▉" # Cursor shown during streaming fresh_final_after_seconds: 0 # Opt in to fresh final (Telegram) when preview is this old ``` When enabled, the bot sends a message on the first token, then progressively edits it as more tokens arrive. Platforms that don't support message editing (Signal, Email, Home Assistant) are auto-detected on the first attempt — streaming is gracefully disabled for that session with no flood of messages. For separate natural mid-turn assistant updates without progressive token editing, set `display.interim_assistant_messages: true`. **Overflow handling:** If the streamed text exceeds the platform's message length limit (~4096 chars), the current message is finalized and a new one starts automatically. **Fresh final (Telegram):** Telegram's `editMessageText` preserves the original message timestamp, so a long-running streamed reply would keep the first-token timestamp even after completion. Set `fresh_final_after_seconds > 0` to opt in to delivering old previews as brand-new final messages with best-effort preview deletion. The default is `0`, which always finalizes streamed replies in place and avoids the brief duplicate-message/delete sequence on clients that show both operations. :::note Per-platform streaming defaults The master `streaming.enabled` switch is `false` by default — nothing streams until you flip it. Once enabled, streaming is decided **per platform**: Telegram ships with `display.platforms.telegram.streaming: true` (streams) and Discord with `display.platforms.discord.streaming: false` (does not). So after enabling streaming, Telegram streams out of the box and Discord stays on whole-message replies until you change its toggle. You can adjust these per-platform switches from the dashboard's **Channels** toggles or directly in `~/.claway/config.yaml`. ::: ## Group Chat Session Isolation Limit how many chat sessions can actively be open across CLI, TUI/dashboard, and messaging gateway: ```yaml max_concurrent_sessions: null # null/0 = unlimited; positive integer = active session cap ``` When the cap is reached, Claway returns a direct limit message for new sessions. Existing active sessions keep their normal behavior. The canonical key is top-level `max_concurrent_sessions`. Claway also accepts `gateway.max_concurrent_sessions` as a fallback, but the top-level key wins when both are set. The cap is enforced with a local runtime lease file and is best-effort: Claway fails open if the registry cannot be read or locked so users are not stranded. It is intended for a single host/profile runtime, not a shared `$CLAWAY_HOME` mounted across multiple machines. Control whether shared chats keep one conversation per room or one conversation per participant: ```yaml group_sessions_per_user: true # true = per-user isolation in groups/channels, false = one shared session per chat ``` - `true` is the default and recommended setting. In Discord channels, Telegram groups, Slack channels, and similar shared contexts, each sender gets their own session when the platform provides a user ID. - `false` reverts to the old shared-room behavior. That can be useful if you explicitly want Claway to treat a channel like one collaborative conversation, but it also means users share context, token costs, and interrupt state. - Direct messages are unaffected. Claway still keys DMs by chat/DM ID as usual. - Threads stay isolated from their parent channel either way; with `true`, each participant also gets their own session inside the thread. For the behavior details and examples, see [Sessions](/user-guide/sessions) and the [Discord guide](/user-guide/messaging/discord). ## Unauthorized DM Behavior Control what Claway does when an unknown user sends a direct message: ```yaml unauthorized_dm_behavior: pair whatsapp: unauthorized_dm_behavior: ignore ``` - `pair` is the default for chat-style DM platforms. Claway denies access, but replies with a one-time pairing code in DMs. - `ignore` silently drops unauthorized DMs. - Email defaults to `ignore` unless `platforms.email.unauthorized_dm_behavior: pair` is set, because inboxes can contain unrelated unread mail. - Platform sections override the global default, so you can keep pairing enabled broadly while making one platform quieter. ## Quick Commands Define custom commands that either run shell commands without invoking the LLM, or alias one slash command to another. Exec quick commands are zero-token and useful from messaging platforms (Telegram, Discord, etc.) for quick server checks or utility scripts. ```yaml quick_commands: status: type: exec command: systemctl status claway disk: type: exec command: df -h / update: type: exec command: cd ~/.claway/claway && git pull && pip install -e . gpu: type: exec command: nvidia-smi --query-gpu=name,utilization.gpu,memory.used,memory.total --format=csv,noheader restart: type: alias target: /gateway restart ``` Usage: type `/status`, `/disk`, `/update`, `/gpu`, or `/restart` in the CLI or any messaging platform. `exec` commands run locally on the host and return the output directly — no LLM call, no tokens consumed. `alias` commands rewrite to the configured slash command target. - **30-second timeout** — long-running commands are killed with an error message - **Priority** — quick commands are checked before skill commands, so you can override skill names - **Autocomplete** — quick commands are resolved at dispatch time and are not shown in the built-in slash-command autocomplete tables - **Type** — supported types are `exec` and `alias`; other types show an error - **Works everywhere** — CLI, Telegram, Discord, Slack, WhatsApp, Signal, Email, Home Assistant String-only prompt shortcuts are not valid quick commands. For reusable prompt workflows, create a skill or alias to an existing slash command. ## Human Delay Simulate human-like response pacing in messaging platforms: ```yaml human_delay: mode: "off" # off | natural | custom min_ms: 800 # Minimum delay (custom mode) max_ms: 2500 # Maximum delay (custom mode) ``` ## Code Execution Configure the `execute_code` tool: ```yaml code_execution: mode: project # project (default) | strict timeout: 300 # Max execution time in seconds max_tool_calls: 50 # Max tool calls within code execution ``` **`mode`** controls the working directory and Python interpreter for scripts: - **`project`** (default) — scripts run in the session's working directory with the active virtualenv/conda env's python. Project deps (`pandas`, `torch`, project packages) and relative paths (`.env`, `./data.csv`) resolve naturally, matching what `terminal()` sees. - **`strict`** — scripts run in a temp staging directory with `sys.executable` (Claway's own python). Maximum reproducibility, but project deps and relative paths won't resolve. Environment scrubbing (strips `*_API_KEY`, `*_TOKEN`, `*_SECRET`, `*_PASSWORD`, `*_CREDENTIAL`, `*_PASSWD`, `*_AUTH`) and the tool whitelist apply identically in both modes — switching mode does not change the security posture. ## Web Search Backends The `web_search` and `web_extract` tools support five backend providers. Configure the backend in `config.yaml` or via `claway tools`: ```yaml web: backend: firecrawl # firecrawl | searxng | parallel | tavily | exa # Or use per-capability keys to mix providers (e.g. free search + paid extract): search_backend: "searxng" extract_backend: "firecrawl" ``` | Backend | Env Var | Search | Extract | |---------|---------|--------|---------| | **Firecrawl** (default) | `FIRECRAWL_API_KEY` | ✔ | ✔ | | **SearXNG** | `SEARXNG_URL` | ✔ | — | | **Parallel** | `PARALLEL_API_KEY` | ✔ | ✔ | | **Tavily** | `TAVILY_API_KEY` | ✔ | ✔ | | **Exa** | `EXA_API_KEY` | ✔ | ✔ | **Backend selection:** If `web.backend` is not set, the backend is auto-detected from available API keys. If only `SEARXNG_URL` is set, SearXNG is used. If only `EXA_API_KEY` is set, Exa is used. If only `TAVILY_API_KEY` is set, Tavily is used. If only `PARALLEL_API_KEY` is set, Parallel is used. Otherwise Firecrawl is the default. **SearXNG** is a free, self-hosted, privacy-respecting metasearch engine that queries 70+ search engines. No API key needed — just set `SEARXNG_URL` to your instance (e.g., `http://localhost:8080`). SearXNG is search-only; `web_extract` requires a separate extract provider (set `web.extract_backend`). See the [Web Search setup guide](/user-guide/features/web-search) for Docker setup instructions. **Self-hosted Firecrawl:** Set `FIRECRAWL_API_URL` to point at your own instance. When a custom URL is set, the API key becomes optional (set `USE_DB_AUTHENTICATION=*** on the server to disable auth). **Parallel search modes:** Set `PARALLEL_SEARCH_MODE` to control search behavior — `fast`, `one-shot`, or `agentic` (default: `agentic`). **Exa:** Set `EXA_API_KEY` in `~/.claway/.env`. Supports `category` filtering (`company`, `research paper`, `news`, `people`, `personal site`, `pdf`) and domain/date filters. ## Browser Configure browser automation behavior: ```yaml browser: inactivity_timeout: 120 # Seconds before auto-closing idle sessions command_timeout: 30 # Timeout in seconds for browser commands (screenshot, navigate, etc.) record_sessions: false # Auto-record browser sessions as WebM videos to ~/.claway/browser_recordings/ # Optional CDP override — when set, Claway attaches directly to your own # Chromium-family browser (via /browser connect) rather than starting a headless browser. cdp_url: "" # Dialog supervisor — controls how native JS dialogs (alert / confirm / prompt) # are handled when a CDP backend is attached (Browserbase, local Chromium-family # browser via /browser connect). Ignored on Camofox and default local agent-browser mode. dialog_policy: must_respond # must_respond | auto_dismiss | auto_accept dialog_timeout_s: 300 # Safety auto-dismiss under must_respond (seconds) camofox: managed_persistence: false # When true, Camofox sessions persist cookies/logins across restarts user_id: "" # Optional externally managed Camofox userId session_key: "" # Optional session key sent when Claway creates a tab adopt_existing_tab: false # Reuse an existing tab for this identity before creating one ``` **Dialog policies:** - `must_respond` (default) — capture the dialog, surface it in `browser_snapshot.pending_dialogs`, and wait for the agent to call `browser_dialog(action=...)`. After `dialog_timeout_s` seconds with no response, the dialog is auto-dismissed to prevent the page's JS thread from stalling forever. - `auto_dismiss` — capture, dismiss immediately. The agent still sees the dialog record in `browser_snapshot.recent_dialogs` with `closed_by="auto_policy"` after the fact. - `auto_accept` — capture, accept immediately. Useful for pages with aggressive `beforeunload` prompts. See the [browser feature page](./features/browser.md#browser_dialog) for the full dialog workflow. The browser toolset supports multiple providers. See the [Browser feature page](/user-guide/features/browser) for details on Browserbase, Browser Use, and local Chromium-family CDP setup. ## Timezone Override the server-local timezone with an IANA timezone string. Affects timestamps in logs, cron scheduling, and system prompt time injection. ```yaml timezone: "America/New_York" # IANA timezone (default: "" = server-local time) ``` Supported values: any IANA timezone identifier (e.g. `America/New_York`, `Europe/London`, `Asia/Kolkata`, `UTC`). Leave empty or omit for server-local time. ## Discord Configure Discord-specific behavior for the messaging gateway: ```yaml discord: require_mention: true # Require @mention to respond in server channels free_response_channels: "" # Comma-separated channel IDs where bot responds without @mention auto_thread: true # Auto-create threads on @mention in channels ``` - `require_mention` — when `true` (default), the bot only responds in server channels when mentioned with `@BotName`. DMs always work without mention. - `free_response_channels` — comma-separated list of channel IDs where the bot responds to every message without requiring a mention. - `auto_thread` — when `true` (default), mentions in channels automatically create a thread for the conversation, keeping channels clean (similar to Slack threading). ## Security Pre-execution security scanning and secret redaction: ```yaml security: redact_secrets: true # Redact API key patterns in tool output and logs (on by default) tirith_enabled: true # Enable Tirith security scanning for terminal commands tirith_path: "tirith" # Path to tirith binary (default: "tirith" in $PATH) tirith_timeout: 5 # Seconds to wait for tirith scan before timing out tirith_fail_open: true # Allow command execution if tirith is unavailable website_blocklist: # See Website Blocklist section below enabled: false domains: [] shared_files: [] ``` - `redact_secrets` — when `true`, automatically detects and redacts patterns that look like API keys, tokens, and passwords in tool output before it enters the conversation context and logs. **On by default**. Set to `false` explicitly only when you need raw credential-like strings for debugging or redactor development. - `tirith_enabled` — when `true`, terminal commands are scanned by [Tirith](https://github.com/sheeki03/tirith) before execution to detect potentially dangerous operations. - `tirith_path` — path to the tirith binary. Set this if tirith is installed in a non-standard location. - `tirith_timeout` — maximum seconds to wait for a tirith scan. Commands proceed if the scan times out. - `tirith_fail_open` — when `true` (default), commands are allowed to execute if tirith is unavailable or fails. Set to `false` to block commands when tirith cannot verify them. ## Website Blocklist Block specific domains from being accessed by the agent's web and browser tools: ```yaml security: website_blocklist: enabled: false # Enable URL blocking (default: false) domains: # List of blocked domain patterns - "*.internal.company.com" - "admin.example.com" - "*.local" shared_files: # Load additional rules from external files - "/etc/claway/blocked-sites.txt" ``` When enabled, any URL matching a blocked domain pattern is rejected before the web or browser tool executes. This applies to `web_search`, `web_extract`, `browser_navigate`, and any tool that accesses URLs. Domain rules support: - Exact domains: `admin.example.com` - Wildcard subdomains: `*.internal.company.com` (blocks all subdomains) - TLD wildcards: `*.local` Shared files contain one domain rule per line (blank lines and `#` comments are ignored). Missing or unreadable files log a warning but don't disable other web tools. The policy is cached for 30 seconds, so config changes take effect quickly without restart. ## Smart Approvals Control how Claway handles potentially dangerous commands: ```yaml approvals: mode: manual # manual | smart | off ``` | Mode | Behavior | |------|----------| | `manual` (default) | Prompt the user before executing any flagged command. In the CLI, shows an interactive approval dialog. In messaging, queues a pending approval request. | | `smart` | Use an auxiliary LLM to assess whether a flagged command is actually dangerous. Low-risk commands are auto-approved with session-level persistence. Genuinely risky commands are escalated to the user. | | `off` | Skip all approval checks. Equivalent to `CLAWAY_YOLO_MODE=true`. **Use with caution.** | Smart mode is particularly useful for reducing approval fatigue — it lets the agent work more autonomously on safe operations while still catching genuinely destructive commands. :::warning Setting `approvals.mode: off` disables all safety checks for terminal commands. Only use this in trusted, sandboxed environments. ::: ## Checkpoints Automatic filesystem snapshots before destructive file operations. See the [Checkpoints & Rollback](/user-guide/checkpoints-and-rollback) for details. ```yaml checkpoints: enabled: false # Enable automatic checkpoints (also: claway chat --checkpoints). Default: false (opt-in). max_snapshots: 20 # Max checkpoints to keep per directory (default: 20) ``` ## Delegation Configure subagent behavior for the delegate tool: ```yaml delegation: # model: "google/gemini-3-flash-preview" # Override model (empty = inherit parent) # provider: "openrouter" # Override provider (empty = inherit parent) # base_url: "http://localhost:1234/v1" # Direct OpenAI-compatible endpoint (takes precedence over provider) # api_key: "local-key" # API key for base_url (falls back to OPENAI_API_KEY) # api_mode: "" # Wire protocol for base_url: "chat_completions", "codex_responses", or "anthropic_messages". Empty = auto-detect from URL (e.g. /anthropic suffix → anthropic_messages). Set explicitly for non-standard endpoints the heuristic can't detect. max_concurrent_children: 3 # Parallel children per batch (floor 1, no ceiling). Also via DELEGATION_MAX_CONCURRENT_CHILDREN env var. max_spawn_depth: 1 # Delegation tree depth cap (1-3, clamped). 1 = flat (default): parent spawns leaves that cannot delegate. 2 = orchestrator children can spawn leaf grandchildren. 3 = three levels. orchestrator_enabled: true # Global kill switch. When false, role="orchestrator" is ignored and every child is forced to leaf regardless of max_spawn_depth. ``` **Subagent provider:model override:** By default, subagents inherit the parent agent's provider and model. Set `delegation.provider` and `delegation.model` to route subagents to a different provider:model pair — e.g., use a cheap/fast model for narrowly-scoped subtasks while your primary agent runs an expensive reasoning model. **Direct endpoint override:** If you want the obvious custom-endpoint path, set `delegation.base_url`, `delegation.api_key`, and `delegation.model`. That sends subagents directly to that OpenAI-compatible endpoint and takes precedence over `delegation.provider`. If `delegation.api_key` is omitted, Claway falls back to `OPENAI_API_KEY` only. **Wire protocol (`api_mode`):** Claway auto-detects the wire protocol from `delegation.base_url` (e.g. paths ending in `/anthropic` → `anthropic_messages`; Codex / native Anthropic / Kimi-coding hostnames keep their existing detection). For endpoints the heuristic can't classify — for example Azure AI Foundry, MiniMax, Zhipu GLM, or LiteLLM proxies fronting an Anthropic-shaped backend — set `delegation.api_mode` explicitly to one of `chat_completions`, `codex_responses`, or `anthropic_messages`. Leave it empty (the default) to keep auto-detection. The delegation provider uses the same credential resolution as CLI/gateway startup. All configured providers are supported: `openrouter`, `copilot`, `zai`, `kimi-coding`, `minimax`, `minimax-cn`. When a provider is set, the system automatically resolves the correct base URL, API key, and API mode — no manual credential wiring needed. **Precedence:** `delegation.base_url` in config → `delegation.provider` in config → parent provider (inherited). `delegation.model` in config → parent model (inherited). Setting just `model` without `provider` changes only the model name while keeping the parent's credentials (useful for switching models within the same provider like OpenRouter). **Width and depth:** `max_concurrent_children` caps how many subagents run in parallel per batch (default `3`, floor of 1, no ceiling). Can also be set via the `DELEGATION_MAX_CONCURRENT_CHILDREN` env var. When the model submits a `tasks` array longer than the cap, `delegate_task` returns a tool error explaining the limit rather than silently truncating. `max_spawn_depth` controls the delegation tree depth (clamped to 1-3). At the default `1`, delegation is flat: children cannot spawn grandchildren, and passing `role="orchestrator"` silently degrades to `leaf`. Raise to `2` so orchestrator children can spawn leaf grandchildren; `3` for three-level trees. The agent opts into orchestration per call via `role="orchestrator"`; `orchestrator_enabled: false` forces every child back to leaf regardless. Cost scales multiplicatively — at `max_spawn_depth: 3` with `max_concurrent_children: 3`, the tree can reach 3×3×3 = 27 concurrent leaf agents. See [Subagent Delegation → Depth Limit and Nested Orchestration](features/delegation.md#depth-limit-and-nested-orchestration) for usage patterns. ## Clarify Configure the clarification prompt behavior: ```yaml clarify: timeout: 120 # Seconds to wait for user clarification response ``` ## Context Files (SOUL.md, AGENTS.md) Claway uses two different context scopes: | File | Purpose | Scope | |------|---------|-------| | `SOUL.md` | **Primary agent identity** — defines who the agent is (slot #1 in the system prompt) | `~/.claway/SOUL.md` or `$CLAWAY_HOME/SOUL.md` | | `.claway.md` / `CLAWAY.md` | Project-specific instructions (highest priority) | Walks to git root | | `AGENTS.md` | Project-specific instructions, coding conventions | Recursive directory walk | | `CLAUDE.md` | Claude Code context files (also detected) | Working directory only | | `.cursorrules` | Cursor IDE rules (also detected) | Working directory only | | `.cursor/rules/*.mdc` | Cursor rule files (also detected) | Working directory only | - **SOUL.md** is the agent's primary identity. It occupies slot #1 in the system prompt, completely replacing the built-in default identity. Edit it to fully customize who the agent is. - If SOUL.md is missing, empty, or cannot be loaded, Claway falls back to a built-in default identity. - **Project context files use a priority system** — only ONE type is loaded (first match wins): `.claway.md` → `AGENTS.md` → `CLAUDE.md` → `.cursorrules`. SOUL.md is always loaded independently. - **AGENTS.md** is hierarchical: if subdirectories also have AGENTS.md, all are combined. - Claway automatically seeds a default `SOUL.md` if one does not already exist. - All loaded context files are capped at `context_file_max_chars` characters (default 20,000) with smart truncation. See also: - [Personality & SOUL.md](/user-guide/features/personality) - [Context Files](/user-guide/features/context-files) ## Working Directory | Context | Default | |---------|---------| | **CLI (`claway`)** | Current directory where you run the command | | **Messaging gateway** | `terminal.cwd` from `~/.claway/config.yaml`; if unset, home directory `~` | | **Docker / Singularity / Modal / SSH** | User's home directory inside the container or remote machine | Override the working directory: ```yaml # In ~/.claway/config.yaml: terminal: cwd: /home/myuser/projects ``` `MESSAGING_CWD` and direct `TERMINAL_CWD` entries in `~/.claway/.env` are legacy compatibility fallbacks. New configurations should use `terminal.cwd`. ## Network Connectivity workarounds for outbound HTTP: ```yaml network: force_ipv4: false # Force IPv4 for outbound connections (default: false) ``` `force_ipv4` — on servers with broken or unreachable IPv6, Python resolves AAAA records first and can hang for the full TCP timeout before falling back to IPv4. Set this to `true` to skip IPv6 entirely and connect over IPv4 directly. ## Onboarding First-touch onboarding hints and the structured profile-build offer: ```yaml onboarding: profile_build: "ask" # "ask" (default) | "off" seen: {} # internal latch — leave empty ``` - `profile_build` — controls the profile-build path offered on the very first gateway message ever. `"ask"` (default) offers to build a user profile; the offer is **opt-in and consent-gated** — the agent asks before any lookup and never reads connected accounts silently. `"off"` shows a plain intro only. The offer fires at most once. - `seen` — internal state. Claway latches each shown hint here so it never fires again; the profile-build offer is also recorded here once shown. Don't hand-edit it — wipe the whole `onboarding` section if you want to re-see all hints. ## Dashboard Configuration for the web dashboard — visual theme, public URL, and authentication providers. The auth providers (OAuth, basic password, drain) are documented in detail on the web-dashboard page; this is the `config.yaml` shape. ```yaml dashboard: theme: "default" # "default" | "midnight" | "ember" | "mono" | "cyberpunk" | "rose" show_token_analytics: false # Re-enable the (local-estimate-only) token/cost analytics surfaces public_url: "" # Full public authority for OAuth redirect_uri (env: CLAWAY_DASHBOARD_PUBLIC_URL) oauth: # Portal OAuth gate (engaged with --host and not --insecure) client_id: "" # agent:{instance_id} — Portal provisions this portal_url: "" # blank → plugin default (production Portal) basic_auth: # Self-hosted username/password gate (dashboard_auth/basic plugin) username: "" # blank → plugin no-op password_hash: "" # scrypt$... (preferred — no plaintext at rest) password: "" # plaintext fallback (hashed in-memory at load) secret: "" # token-signing key; blank → random per-process session_ttl_seconds: 0 # 0 → plugin default (12h) drain_auth: # Drain-control service-credential gate (dashboard_auth/drain plugin) scope: "drain" # capability label on the verified principal min_secret_chars: 43 # entropy bar (url-safe-b64 chars; 43 ≈ 256 bits) ``` - `theme` — dashboard visual theme. - `show_token_analytics` — off by default. The Analytics page and token/cost figures are a **local lower-bound estimate** (they exclude auxiliary calls, retries, fallbacks, and cache writes), so they can read far below the provider bill. Set `true` only if you understand they're not billing. - `public_url` — when set, this is the complete authority (scheme + host + optional path prefix) the OAuth `redirect_uri` is built from. Set it for deploys behind reverse proxies that don't reliably forward `X-Forwarded-*` headers. Leave empty to use proxy-header reconstruction. - `oauth` / `basic_auth` / `drain_auth` — auth provider config read by the bundled dashboard-auth plugins. The drain secret itself is **not** set here; it's provisioned via the `CLAWAY_DASHBOARD_DRAIN_SECRET` env var. See Web Dashboard for full auth setup. --- <!-- source: website/docs/user-guide/configuring-models.md --> # user-guide/configuring-models # Configuring Models Claway uses two kinds of model slots: - **Main model** — what the agent thinks with. Every user message, every tool-call loop, every streamed response goes through this model. - **Auxiliary models** — smaller side-jobs the agent offloads. Context compression, vision (image analysis), web-page summarization, approval scoring, MCP tool routing, session-title generation, and skill search. Each has its own slot and can be overridden independently. This page covers configuring both from the dashboard. If you prefer config files or the CLI, jump to [Alternative methods](#alternative-methods) at the bottom. :::info Claway Box and hosted Claway On a Claway Box and on hosted Claway, Blockway sets up the model for you and you do not need anything on this page. It is for bringing your own model provider. The **Models** page described below belongs to the `claway dashboard` of a personal install; on a Box or hosted server, change models with the CLI or `config.yaml` methods under [Alternative methods](#alternative-methods), or ask Blockway support. ::: :::note `model:` schema — empty string vs. mapping On a brand-new install the bundled default config has `model: ""` (an empty string sentinel meaning "not configured yet"). The first time you run `claway setup` or `claway model`, that key is upgraded in-place to a mapping with `provider`, `default`, `base_url`, and `api_mode` sub-keys — the shape shown throughout this page and in [`profiles.md`](./profiles.md) / [`configuration.md`](./configuration.md). If you ever see an empty string in `config.yaml`, run `claway model` (or click **Change** in the dashboard) and Claway will write the dict form for you. ::: ## The Models page Open the dashboard and click **Models** in the sidebar. You get two sections: 1. **Model Settings** — the top panel, where you assign models to slots. 2. **Usage analytics** — ranked cards showing every model that ran a session in the selected period, with token counts, cost, and capability badges. The top card is the **Model Settings** panel. The main row always shows what the agent will spin up for new sessions. Click **Change** to open the picker. ## Setting the main model Click **Change** on the Main model row: The picker has two columns: - **Left** — authenticated providers. Only providers you've set up (API key set, OAuth'd, or defined as a custom endpoint) show up here. If a provider is missing, head to **Keys** and add its credential. - **Right** — the curated model list for the selected provider. These are the agentic models Claway recommends for that provider, not the raw `/models` dump (which on OpenRouter includes 400+ models including TTS, image generators, and rerankers). Type in the filter box to narrow by provider name, slug, or model ID. Pick a model, hit **Switch**, and Claway writes it to `~/.claway/config.yaml` under the `model` section. **This applies to new sessions only** — any chat tab you already have open keeps running whatever model it started with. To hot-swap the current chat, use the `/model` slash command inside it. ### Mid-session switches and context warnings When you switch models **inside an active session** (Herm TUI model picker, `claway` CLI, or `/model` on Telegram/Discord), Claway estimates whether your **next message** will run **preflight context compression** against the new model's window. If the session is already near or above that model's compression threshold (see [Context Compression](./configuration.md#context-compression)), the switch reply includes a warning — the same `warning_message` path used for expensive-model notices. The switch still applies immediately; compression runs on the **first user message after the switch**, before the model answers. ## Setting auxiliary models Click **Show auxiliary** to reveal the 11 task slots: Every auxiliary task defaults to `auto` — meaning Claway tries your main model for that job too. If that route is unavailable or hits a capacity-style failure, `auto` follows any task-specific `auxiliary.<task>.fallback_chain`, then the main `fallback_providers` / `fallback_model` chain, then Claway's built-in auxiliary discovery chain. Override a specific task when you want a cheaper or faster model for a side-job. ### Common override patterns | Task | When to override | |---|---| | **Title Gen** | Almost always. A $0.10/M flash model writes session titles as well as Opus. Default config sets this to `google/gemini-3-flash-preview` on OpenRouter. | | **Vision** | When your main model lacks vision support. Point it at `google/gemini-2.5-flash` or `gpt-4o-mini`. | | **Compression** | When you're burning reasoning tokens on Opus/M2.7 just to summarize context. A fast chat model does the job at 1/50th the cost. | | **Approval** | For `approval_mode: smart` — a fast/cheap model (haiku, flash, gpt-5-mini) decides whether to auto-approve low-risk commands. Expensive models here are waste. | | **Web Extract** | When you use `web_extract` heavily. Same logic as compression — summarization doesn't need reasoning. | | **Skills Hub** | `claway skills search` uses this. Usually fine at `auto`. | | **MCP** | MCP tool routing. Usually fine at `auto`. | | **Triage Specifier** | Routes the Kanban triage specifier (`claway kanban specify`) that expands a rough one-liner into a concrete spec. A cheap, capable model works well. | | **Kanban Decomposer** | Routes Kanban task decomposition — splits a triage task into a graph of child tasks for specialist profiles. | | **Profile Describer** | Routes profile-description generation (`claway profile describe --auto` / the dashboard auto-generate button). Short, cheap call. | | **Curator** | Routes the curator skill-usage review pass. Can run for minutes on reasoning models, so a cheaper aux model is often worthwhile. | ### Per-task override Click **Change** on any auxiliary row. Same picker opens, same behavior — pick provider + model, hit Switch. The row updates to show `provider · model` instead of `auto (use main model)`. ### Reset all to auto If you've over-tuned and want to start over, click **Reset all to auto** at the top of the auxiliary section. Every slot goes back to using your main model. ## The "Use as" shortcut Every model card on the page has a **Use as** dropdown. This is the fast path — pick a model you see in your analytics, click **Use as**, and assign it to the main slot or any specific auxiliary task in one click: The dropdown has: - **Main model** — same as clicking Change on the main row. - **All auxiliary tasks** — assigns this model to all 11 aux slots at once. Useful when you just want every side-job on a cheap flash model. - **Individual task options** — Vision, Web Extract, Compression, etc. The currently-assigned model for each task is marked `current`. Cards are badged with `main` or `aux · <task>` when they're currently assigned to something — so you can see at a glance which of your historical models are wired in where. ## What gets written to `config.yaml` When you save via the dashboard, Claway writes to `~/.claway/config.yaml`: **Main model:** ```yaml model: provider: openrouter default: anthropic/claude-opus-4.7 base_url: '' # cleared on provider switch api_mode: chat_completions ``` **Auxiliary override (example — vision on gemini-flash):** ```yaml auxiliary: vision: provider: openrouter model: google/gemini-2.5-flash base_url: '' api_key: '' timeout: 120 extra_body: {} download_timeout: 30 ``` **Auxiliary on auto (default):** ```yaml auxiliary: compression: provider: auto model: '' base_url: '' # ... other fields unchanged ``` `provider: auto` with `model: ''` tells Claway to use the main model for that task, while still honoring fallback policy if the main route cannot serve the auxiliary call. Optional task-specific fallback chains live under the same auxiliary task: ```yaml auxiliary: title_generation: provider: auto model: '' fallback_chain: - provider: openrouter model: inclusionai/ring-2.6-1t:free ``` When `fallback_chain` is absent, `auto` uses the top-level `fallback_providers` chain before the built-in auxiliary discovery chain. ## When does it take effect? - **CLI** (`claway chat`): next `claway chat` invocation. - **Gateway** (Telegram, Discord, Slack, etc.): next *new* session. Existing sessions keep their model. Restart the gateway (`claway gateway restart`) if you want to force all sessions to pick up the change. - **Dashboard chat tab** (`/chat`): next new PTY. The currently-open chat keeps its model — use `/model` inside it to hot-swap. Changes never invalidate prompt caches on running sessions. That's deliberate: swapping the main model inside a session requires a cache reset (the system prompt contains model-specific content), and we reserve that for the explicit `/model` slash command inside chat. ## Troubleshooting ### "No authenticated providers" in the picker Claway lists a provider only if it has a working credential. Check **Keys** in the sidebar — you should see one of: an API key, a successful OAuth, or a custom endpoint URL. If the provider you want isn't there, run `claway setup` to wire it up, or go to **Keys** and add the env var. ### Main model didn't change in my running chat Expected. The dashboard writes `config.yaml`, which new sessions read. The currently-open chat is a live agent process — it keeps whatever model it was spawned with. Use `/model <name>` inside the chat to hot-swap that specific session. ### Auxiliary override "didn't take effect" Three things to check: 1. **Did you start a new session?** Existing chats don't re-read config. 2. **Is `provider` set to something other than `auto`?** If the field shows `auto`, the task is still using your main model. Click **Change** and pick a real provider. 3. **Is the provider authenticated?** If you assigned `minimax` to a task but don't have a MiniMax API key, that task falls back to the openrouter default and logs a warning in `agent.log`. ### I picked a model but Claway switched providers on me On OpenRouter (or any aggregator), bare model names resolve *within* the aggregator first. So `claude-sonnet-4` on OpenRouter becomes `anthropic/claude-sonnet-4.6`, staying on your OpenRouter auth. But if you typed `claude-sonnet-4` on a native Anthropic auth, it would stay as `claude-sonnet-4-6`. If you see an unexpected provider switch, check that your current provider is what you expect — the picker always shows the current main at the top of the dialog. ## Alternative methods ### CLI slash command Inside any `claway chat` session: ``` /model gpt-5.4 --provider openrouter # session-only /model gpt-5.4 --provider openrouter --global # also persists to config.yaml ``` `--global` does the same thing the dashboard's **Change** button does, plus it switches the running session in-place. ### Custom aliases Define your own short names for models you reach for often, then use `/model <alias>` in the CLI or any messaging platform. There are two equivalent formats — pick whichever fits your workflow. **Canonical (top-level `model_aliases:`)** — full control over provider + base_url: ```yaml # ~/.claway/config.yaml model_aliases: fav: model: claude-sonnet-4.6 provider: anthropic grok: model: grok-4 provider: x-ai ``` **Short string form (`model.aliases.<name>: provider/model`)** — convenient from the shell because `claway config set` only writes scalar values, but it can't carry a custom `base_url`: ```bash claway config set model.aliases.fav anthropic/claude-opus-4.6 claway config set model.aliases.grok x-ai/grok-4 ``` Both paths feed the same loader (`claway_cli/model_switch.py`). Entries declared in `model_aliases:` take precedence over `model.aliases:` entries with the same name. Then `/model fav` or `/model grok` in chat. User aliases shadow built-in short names (`sonnet`, `kimi`, `opus`, etc.). See [Custom model aliases](/reference/slash-commands#custom-model-aliases) for the full reference. ### `claway model` subcommand ```bash claway model # Interactive provider + model picker (the canonical way to switch defaults) ``` `claway model` walks you through picking a provider, authenticating (OAuth flows open a browser; API-key providers prompt for the key), and then choosing a specific model from that provider's curated catalog. The choice is written to `model.provider` and `model.model` in `~/.claway/config.yaml`. To list providers/models without launching the picker, use the dashboard or the REST endpoints below. To inspect what the CLI will actually use right now: `claway config show | grep '^model\.'` and `claway status`. ### Direct config edit Edit `~/.claway/config.yaml` and restart whatever reads it. See the [Configuration reference](./configuration.md) for the full schema. ### REST API The dashboard uses three endpoints. Useful for scripting: ```bash # List authenticated providers + curated model lists curl -H "X-Claway-Session-Token: $TOKEN" http://localhost:PORT/api/model/options # Read current main + auxiliary assignments curl -H "X-Claway-Session-Token: $TOKEN" http://localhost:PORT/api/model/auxiliary # Set the main model curl -X POST -H "Content-Type: application/json" -H "X-Claway-Session-Token: $TOKEN" \ -d '{"scope":"main","provider":"openrouter","model":"anthropic/claude-opus-4.7"}' \ http://localhost:PORT/api/model/set # Override a single auxiliary task curl -X POST -H "Content-Type: application/json" -H "X-Claway-Session-Token: $TOKEN" \ -d '{"scope":"auxiliary","task":"vision","provider":"openrouter","model":"google/gemini-2.5-flash"}' \ http://localhost:PORT/api/model/set # Assign one model to every auxiliary task curl -X POST -H "Content-Type: application/json" -H "X-Claway-Session-Token: $TOKEN" \ -d '{"scope":"auxiliary","task":"","provider":"openrouter","model":"google/gemini-2.5-flash"}' \ http://localhost:PORT/api/model/set # Reset all auxiliary tasks to auto curl -X POST -H "Content-Type: application/json" -H "X-Claway-Session-Token: $TOKEN" \ -d '{"scope":"auxiliary","task":"__reset__","provider":"","model":""}' \ http://localhost:PORT/api/model/set ``` The session token is injected into the dashboard HTML at startup and rotates on every server restart. Grab it from the browser devtools (`window.__CLAWAY_SESSION_TOKEN__`) if you're scripting against a running dashboard. --- <!-- source: website/docs/user-guide/sessions.md --> # Sessions import useBaseUrl from '@docusaurus/useBaseUrl'; # Sessions Claway Agent automatically saves every conversation as a session. Sessions enable conversation resume, cross-session search, and full conversation history management. ## How Sessions Work Every conversation — whether from the CLI, Telegram, Discord, Slack, WhatsApp, Signal, Matrix, Teams, or any other messaging platform — is stored as a session with full message history. Sessions are tracked in: 1. **SQLite database** (`~/.claway/state.db`) — structured session metadata with FTS5 full-text search, plus full message history The SQLite database stores: - Session ID, source platform, user ID - **Session title** (unique, human-readable name) - Model name and configuration - System prompt snapshot - Full message history (role, content, tool calls, tool results) - Token counts (input/output) - Timestamps (started_at, ended_at) - Parent session ID (for compression-triggered session splitting) ### What Counts Toward Context Claway stores session history so it can resume conversations, but it does not keep re-sending every byte it has ever handled. On each turn, the model sees the selected system prompt, the current conversation window, and any content Claway explicitly injects for that turn. Media attachments are handled as turn-scoped inputs: - Images may be attached natively to the next model call, or pre-analyzed into a text description when the active model does not support native vision. - Audio is transcribed into text when speech-to-text is configured. - Text documents can have their extracted text included; other document types are usually represented by a saved local path and a short note. - Attachment paths and extracted/derived text can appear in the transcript, but the raw image, audio, or binary file bytes are not repeatedly copied into future prompts. For example, if a user sends an image and asks Claway to make a meme from it, Claway may inspect that image once with vision and run an image-processing script. Future turns do not automatically carry the original JPEG in context. They carry only whatever was written into the conversation, such as the user's request, a short image description, a local cache path, or the final assistant response. The most common cause of context growth is not the media file itself. It is verbose text: pasted transcripts, full logs, large tool outputs, long diffs, repeated status reports, and detailed proof dumps. Prefer summaries, file paths, focused excerpts, and tool-backed lookups over copying large artifacts into chat. :::tip Use `/compress` when a session gets long, `/new` for a fresh thread, and `claway sessions prune` only when you want to delete old ended sessions from storage. Compression reduces the active context; it is not a privacy delete. Pass a name to `/new` (e.g. `/new payments-refactor`) to set the new session's initial title up front — useful for finding it later with `/resume <name>` or in the `/sessions` picker. ::: ### Session Sources Each session is tagged with its source platform: | Source | Description | |--------|-------------| | `cli` | Interactive CLI (`claway` or `claway chat`) | | `telegram` | Telegram messenger | | `discord` | Discord server/DM | | `slack` | Slack workspace | | `whatsapp` | WhatsApp messenger | | `signal` | Signal messenger | | `matrix` | Matrix rooms and DMs | | `mattermost` | Mattermost channels | | `email` | Email (IMAP/SMTP) | | `sms` | SMS via Twilio | | `dingtalk` | DingTalk messenger | | `feishu` | Feishu/Lark messenger | | `wecom` | WeCom (WeChat Work) | | `weixin` | Weixin (personal WeChat) | | `bluebubbles` | Apple iMessage via BlueBubbles macOS server | | `qqbot` | QQ Bot (Tencent QQ) via Official API v2 | | `homeassistant` | Home Assistant conversation | | `webhook` | Incoming webhooks | | `api-server` | API server requests | | `acp` | ACP editor integration | | `cron` | Scheduled cron jobs | | `batch` | Batch processing runs | ## CLI Session Resume Resume previous conversations from the CLI using `--continue` or `--resume`: ### Continue Last Session ```bash # Resume the most recent CLI session claway --continue claway -c # Or with the chat subcommand claway chat --continue claway chat -c ``` This looks up the most recent `cli` session from the SQLite database and loads its full conversation history. ### Resume by Name If you've given a session a title (see [Session Naming](#session-naming) below), you can resume it by name: ```bash # Resume a named session claway -c "my project" # If there are lineage variants (my project, my project #2, my project #3), # this automatically resumes the most recent one claway -c "my project" # → resumes "my project #3" ``` ### Resume Specific Session ```bash # Resume a specific session by ID claway --resume 20250305_091523_a1b2c3d4 claway -r 20250305_091523_a1b2c3d4 # Resume by title claway --resume "refactoring auth" # Or with the chat subcommand claway chat --resume 20250305_091523_a1b2c3d4 ``` Session IDs are shown when you exit a CLI session, and can be found with `claway sessions list`. ### Conversation Recap on Resume When you resume a session, Claway displays a compact recap of the previous conversation in a styled panel before the input prompt: <img className="docs-terminal-figure" src={useBaseUrl('/img/docs/session-recap.svg')} alt="Stylized preview of the Previous Conversation recap panel shown when resuming a Claway session." /> <p className="docs-figure-caption">Resume mode shows a compact recap panel with recent user and assistant turns before returning you to the live prompt.</p> The recap: - Shows **user messages** (gold `●`) and **assistant responses** (green `◆`) - **Truncates** long messages (300 chars for user, 200 chars / 3 lines for assistant) - **Collapses tool calls** to a count with tool names (e.g., `[3 tool calls: terminal, web_search]`) - **Hides** system messages, tool results, and internal reasoning - **Caps** at the last 10 exchanges with a "... N earlier messages ..." indicator - Uses **dim styling** to distinguish from the active conversation To disable the recap and keep the minimal one-liner behavior, set in `~/.claway/config.yaml`: ```yaml display: resume_display: minimal # default: full ``` :::tip Session IDs follow the format `YYYYMMDD_HHMMSS_<hex>` — CLI/TUI sessions use a 6-char hex suffix (e.g. `20250305_091523_a1b2c3`), gateway sessions use an 8-char suffix (e.g. `20250305_091523_a1b2c3d4`). You can resume by ID (full or unique prefix) or by title — both work with `-c` and `-r`. ::: ## Cross-Platform Handoff Use `/handoff <platform>` from a CLI session to transfer the live conversation to a messaging platform's home channel. The agent picks up exactly where the CLI left off — same session id, full role-aware transcript, tool calls and all. ```bash # Inside a CLI session /handoff telegram ``` What happens: 1. The CLI validates that `<platform>` is enabled and has a home channel set (run `/sethome` from the destination chat once to configure it). 2. The CLI marks the session pending and **block-polls the gateway**. It refuses if the agent is mid-turn — wait for the current response to finish first. 3. The gateway watcher claims the handoff and asks the destination adapter for a fresh thread: - **Telegram** — opens a new forum topic (DM topics if Bot API 9.4+ Topics mode is enabled in the chat, or a forum supergroup topic). - **Discord** — creates a 1440-min auto-archive thread under the home text channel. - **Slack** — posts a seed message and uses its `ts` as the thread anchor. - **WhatsApp / Signal / Matrix / SMS** — no native threads, falls back to the home channel directly. 4. The gateway re-binds the destination key to your existing CLI session id, then forges a synthetic user turn asking the agent to confirm and summarize. The reply lands in the new thread. 5. When the gateway acknowledges success, the CLI prints a `/resume` hint and exits cleanly: ``` ↻ Handoff complete. The session is now active on telegram. Resume it on this CLI later with: /resume my-session-title ``` 6. From that point, the conversation lives on the platform. Reply in the new thread — anyone authorized in that channel shares the same session, and any later real user message in the thread joins seamlessly because thread sessions key without `user_id`. **Resume back to CLI:** when you want to come back to a desktop, just run `/resume <title>` (or `claway -r "<title>"` from the shell) and pick up where the platform left off. **Failure modes:** - No home channel configured → CLI refuses with a `/sethome` hint. - Platform not enabled / gateway not running → CLI times out at 60s with a clear message and your CLI session stays intact. - Thread creation fails (permissions, topics-mode off) → falls back to the home channel directly and still completes; no thread isolation but the handoff itself works. - `adapter.send` fails (rate limit, transient API error) → handoff marked failed with the reason; the row clears so you can retry. **Limitation worth knowing:** for non-thread-capable platforms with multi-user group home channels, the synthetic turn keys as a DM-style session. This works for self-DM home channels (the typical setup) but isn't ideal for genuinely shared group chats. Threading covers Telegram / Discord / Slack — by far the common case — so most setups never hit this. ## Session Naming Give sessions human-readable titles so you can find and resume them easily. ### Auto-Generated Titles Claway automatically generates a short descriptive title (3–7 words) for each session after the first exchange. This runs in a background thread using a fast auxiliary model, so it adds no latency. You'll see auto-generated titles when browsing sessions with `claway sessions list` or `claway sessions browse`. Auto-titling only fires once per session and is skipped if you've already set a title manually. ### Setting a Title Manually Use the `/title` slash command inside any chat session (CLI or gateway): ``` /title my research project ``` The title is applied immediately. If the session hasn't been created in the database yet (e.g., you run `/title` before sending your first message), it's queued and applied once the session starts. You can also rename existing sessions from the command line: ```bash claway sessions rename 20250305_091523_a1b2c3d4 "refactoring auth module" ``` ### Title Rules - **Unique** — no two sessions can share the same title - **Max 100 characters** — keeps listing output clean - **Sanitized** — control characters, zero-width chars, and RTL overrides are stripped automatically - **Normal Unicode is fine** — emoji, CJK, accented characters all work ### Auto-Lineage on Compression When a session's context is compressed (manually via `/compress` or automatically), Claway creates a new continuation session. If the original had a title, the new session automatically gets a numbered title: ``` "my project" → "my project #2" → "my project #3" ``` When you resume by name (`claway -c "my project"`), it automatically picks the most recent session in the lineage. ### /title in Messaging Platforms The `/title` command works in all gateway platforms (Telegram, Discord, Slack, WhatsApp): - `/title My Research` — set the session title - `/title` — show the current title ## Session Management Commands Claway provides a full set of session management commands via `claway sessions`: ### List Sessions ```bash # List recent sessions (default: last 20) claway sessions list # Filter by platform claway sessions list --source telegram # Show more sessions claway sessions list --limit 50 ``` When sessions have titles, the output shows titles, previews, and relative timestamps: ``` Title Preview Last Active ID ──────────────────────────────────────────────────────────────────────────────────────────────── refactoring auth Help me refactor the auth module please 2h ago 20250305_091523_a my project #3 Can you check the test failures? yesterday 20250304_143022_e — What's the weather in Las Vegas? 3d ago 20250303_101500_f ``` When no sessions have titles, a simpler format is used: ``` Preview Last Active Src ID ────────────────────────────────────────────────────────────────────────────────────── Help me refactor the auth module please 2h ago cli 20250305_091523_a What's the weather in Las Vegas? 3d ago tele 20250303_101500_f ``` ### Export Sessions ```bash # Export all sessions to a JSONL file claway sessions export backup.jsonl # Export sessions from a specific platform claway sessions export telegram-history.jsonl --source telegram # Export a single session claway sessions export session.jsonl --session-id 20250305_091523_a1b2c3d4 ``` Exported files contain one JSON object per line with full session metadata and all messages. ### Delete a Session ```bash # Delete a specific session (with confirmation) claway sessions delete 20250305_091523_a1b2c3d4 # Delete without confirmation claway sessions delete 20250305_091523_a1b2c3d4 --yes ``` ### Rename a Session ```bash # Set or change a session's title claway sessions rename 20250305_091523_a1b2c3d4 "debugging auth flow" # Multi-word titles don't need quotes in the CLI claway sessions rename 20250305_091523_a1b2c3d4 debugging auth flow ``` If the title is already in use by another session, an error is shown. ### Prune Old Sessions ```bash # Delete ended sessions older than 90 days (default) claway sessions prune # Custom age threshold claway sessions prune --older-than 30 # Only prune sessions from a specific platform claway sessions prune --source telegram --older-than 60 # Skip confirmation claway sessions prune --older-than 30 --yes ``` :::info Pruning only deletes **ended** sessions (sessions that have been explicitly ended or auto-reset). Active sessions are never pruned. ::: ### Session Statistics ```bash claway sessions stats ``` Output: ``` Total sessions: 142 Total messages: 3847 cli: 89 sessions telegram: 38 sessions discord: 15 sessions Database size: 12.4 MB ``` For deeper analytics — token usage, cost estimates, tool breakdown, and activity patterns — use [`claway insights`](/reference/cli-commands#claway-insights). ## Session Search Tool The agent has a built-in `session_search` tool that performs full-text search across all past conversations using SQLite's FTS5 engine — and lets the agent scroll through any session it finds. No LLM calls, no summarization, no truncation. Every shape returns actual messages from the DB. ### Three calling shapes The tool infers what you want from which arguments you set. There's no `mode` parameter. **1. Discovery — pass `query`:** ```python session_search(query="auth refactor", limit=3) ``` Runs FTS5, dedupes hits by session lineage, returns the top N sessions. Each result carries: - `session_id`, `title`, `when`, `source` - `snippet` — FTS5-highlighted match excerpt - `bookend_start` — first 3 user+assistant messages of the session (the goal/kickoff) - `messages` — ±5 messages around the FTS5 match, with the anchor message flagged (the hit in context) - `bookend_end` — last 3 user+assistant messages of the session (the resolution/decisions) - `match_message_id`, `messages_before`, `messages_after` Bookends + window together reconstruct goal → match → resolution without paying for the whole transcript. Typical wall time: 15–50ms on a real session DB. **2. Scroll — pass `session_id` + `around_message_id`:** ```python session_search(session_id="20260510_174648_805cc2", around_message_id=590803, window=10) ``` Returns a window of ±`window` messages centered on the anchor. No FTS5, no bookends — just the slice. Use after a discovery call when you need more context than the ±5 default window. - To scroll **forward**: pass `messages[-1].id` back as `around_message_id` - To scroll **backward**: pass `messages[0].id` back as `around_message_id` - The boundary message appears in both windows as an orientation marker - When `messages_before` or `messages_after` is less than `window`, you're at the start or end of the session Typical wall time: 1–2ms per scroll call. **3. Browse — no args:** ```python session_search() ``` Returns recent sessions chronologically (titles, previews, timestamps). Useful when the user asks "what was I working on" without naming a topic. ### FTS5 query syntax The keyword mode supports standard FTS5 query syntax: - Simple keywords: `docker deployment` (FTS5 defaults to AND) - Phrases: `"exact phrase"` - Boolean: `docker OR kubernetes`, `python NOT java` - Prefix: `deploy*` ### Optional parameters - `sort` — `newest` or `oldest`, on top of FTS5 ranking. Omit for relevance-only ordering (the default; suitable for exploratory recall). Use `newest` for "where did we leave X" questions, `oldest` for "how did X start" questions. - `role_filter` — comma-separated roles to include. Discovery defaults to `user,assistant` (tool output is usually noise). Pass `user,assistant,tool` to include tool output (debugging tool behaviour) or `tool` to search tool output only. ### When It's Used The agent is prompted to use session search automatically: > *"When the user references something from a past conversation or you suspect relevant prior context exists, use session_search to recall it before asking them to repeat themselves."* Typical triggers: "we did this before", "remember when", "last time", "as I mentioned", or any reference to a project/person/concept that isn't in the current window. ## Per-Platform Session Tracking ### Gateway Sessions On messaging platforms, sessions are keyed by a deterministic session key built from the message source: | Chat Type | Default Key Format | Behavior | |-----------|--------------------|----------| | Telegram DM | `agent:main:telegram:dm:<chat_id>` | One session per DM chat | | Discord DM | `agent:main:discord:dm:<chat_id>` | One session per DM chat | | WhatsApp DM | `agent:main:whatsapp:dm:<canonical_identifier>` | One session per DM user (LID/phone aliases collapse to one identity when mapping exists) | | Group chat | `agent:main:<platform>:group:<chat_id>:<user_id>` | Per-user inside the group when the platform exposes a user ID | | Group thread/topic | `agent:main:<platform>:group:<chat_id>:<thread_id>` | Shared session for all thread participants (default). Per-user with `thread_sessions_per_user: true`. | | Channel | `agent:main:<platform>:channel:<chat_id>:<user_id>` | Per-user inside the channel when the platform exposes a user ID | When Claway cannot get a participant identifier for a shared chat, it falls back to one shared session for that room. ### Shared vs Isolated Group Sessions By default, Claway uses `group_sessions_per_user: true` in `config.yaml`. That means: - Alice and Bob can both talk to Claway in the same Discord channel without sharing transcript history - one user's long tool-heavy task does not pollute another user's context window - interrupt handling also stays per-user because the running-agent key matches the isolated session key If you want one shared "room brain" instead, set: ```yaml group_sessions_per_user: false ``` That reverts groups/channels to a single shared session per room, which preserves shared conversational context but also shares token costs, interrupt state, and context growth. ### Session Reset Policies Gateway sessions are automatically reset based on configurable policies: - **idle** — reset after N minutes of inactivity - **daily** — reset at a specific hour each day - **both** — reset on whichever comes first (idle or daily) - **none** — never auto-reset Before a session is auto-reset, the agent is given a turn to save any important memories or skills from the conversation. Sessions with **active background processes** are never auto-reset, regardless of policy. ## Storage Locations | What | Path | Description | |------|------|-------------| | SQLite database | `~/.claway/state.db` | All session metadata + messages with FTS5 | | Gateway messages | `~/.claway/state.db` | SQLite — canonical store for all session messages | | Gateway routing index | `~/.claway/sessions/sessions.json` | Maps session keys to active session IDs (origin metadata, expiry flags) | The SQLite database uses WAL mode for concurrent readers and a single writer, which suits the gateway's multi-platform architecture well. :::warning `sessions.json` is not the session list `~/.claway/sessions/sessions.json` is the **gateway routing index** — it maps messaging session keys (`agent:main:<platform>:...`) to active session IDs. It only ever contains gateway/messaging entries, so if you run a messaging platform you'll see only those (e.g. `agent:main:whatsapp:dm:...`). This is **expected** and does **not** mean your CLI sessions are missing. `claway sessions list`, `/sessions`, and the dashboard all read `state.db`, which holds **every** session (CLI, TUI, and gateway). The `/save` snapshots under `~/.claway/sessions/saved/*.json` are convenience exports, not the index. If CLI sessions genuinely don't appear in `claway sessions list`, the cause is `state.db` not receiving them — run `claway sessions repair` and watch for a `⚠ Session store unavailable` warning at CLI startup, which means SQLite persistence failed for that run. ::: :::note Legacy JSONL transcripts Sessions created before state.db became canonical may have leftover `*.jsonl` files in `~/.claway/sessions/`. They are no longer written or read by Claway. Safe to delete after verifying the corresponding session exists in state.db. ::: ### Database Schema Key tables in `state.db`: - **sessions** — session metadata (id, source, user_id, model, title, timestamps, token counts). Titles have a unique index (NULL titles allowed, only non-NULL must be unique). - **messages** — full message history (role, content, tool_calls, tool_name, token_count) - **messages_fts** — FTS5 virtual table for full-text search across message content ## Session Expiry and Cleanup ### Automatic Cleanup - Gateway sessions auto-reset based on the configured reset policy - Before reset, the agent saves memories and skills from the expiring session - Opt-in auto-pruning: when `sessions.auto_prune` is `true`, ended sessions older than `sessions.retention_days` (default 90) are pruned at CLI/gateway startup - After a prune that actually removed rows, `state.db` is `VACUUM`ed to reclaim disk space (SQLite does not shrink the file on plain DELETE) - Pruning runs at most once per `sessions.min_interval_hours` (default 24); the last-run timestamp is tracked inside `state.db` itself so it's shared across every Claway process in the same `CLAWAY_HOME` Default is **off** — session history is valuable for `session_search` recall, and silently deleting it could surprise users. Enable in `~/.claway/config.yaml`: ```yaml sessions: auto_prune: true # opt in — default is false retention_days: 90 # keep ended sessions this many days vacuum_after_prune: true # reclaim disk space after a pruning sweep min_interval_hours: 24 # don't re-run the sweep more often than this ``` Active sessions are never auto-pruned, regardless of age. ### Manual Cleanup ```bash # Prune sessions older than 90 days claway sessions prune # Delete a specific session claway sessions delete <session_id> # Export before pruning (backup) claway sessions export backup.jsonl claway sessions prune --older-than 30 --yes ``` :::tip The database grows slowly (typical: 10-15 MB for hundreds of sessions) and session history powers `session_search` recall across past conversations, so auto-prune ships disabled. Enable it if you're running a heavy gateway/cron workload where `state.db` is meaningfully affecting performance (observed failure mode: 384 MB state.db with ~1000 sessions slowing down FTS5 inserts and `/resume` listing). Use `claway sessions prune` for one-off cleanup without turning on the automatic sweep. ::: --- <!-- source: website/docs/user-guide/profiles.md --> # user-guide/profiles # Profiles: Running Multiple Agents Run multiple independent Claway agents on the same machine — each with its own config, API keys, memory, sessions, skills, and gateway state. ## What are profiles? A profile is a separate Claway home directory. Each profile gets its own directory containing its own `config.yaml`, `.env`, `SOUL.md`, memories, sessions, skills, cron jobs, and state database. Profiles let you run separate agents for different purposes — a coding assistant, a personal bot, a research agent — without mixing up Claway state. When you create a profile, it automatically becomes its own command. Create a profile called `coder` and you immediately have `coder chat`, `coder setup`, `coder gateway start`, etc. ## Quick start ```bash claway profile create coder # creates profile + "coder" command alias coder setup # configure API keys and model coder chat # start chatting ``` That's it. `coder` is now its own Claway profile with its own config, memory, and state. ## Creating a profile ### Blank profile ```bash claway profile create mybot ``` Creates a fresh profile with bundled skills seeded. Run `mybot setup` to configure API keys, model, and gateway tokens. If you plan to use this profile as a kanban worker (or want the kanban orchestrator to route work to it), pass `--description "<role>"` at create time so the orchestrator knows what it's good at: ```bash claway profile create researcher --description "Reads source code and external docs, writes findings." ``` You can also set or auto-generate the description later with `claway profile describe` — see the [Kanban guide](./features/kanban#auto-vs-manual-orchestration) for the full routing model. ### Clone config only (`--clone`) ```bash claway profile create work --clone ``` Copies your current profile's `config.yaml`, `.env`, `SOUL.md`, and skills into the new profile. Same API keys, model, and capabilities, but fresh sessions and memory. Edit `~/.claway/profiles/work/.env` for different API keys, or `~/.claway/profiles/work/SOUL.md` for a different personality. ### Clone everything (`--clone-all`) ```bash claway profile create backup --clone-all ``` Copies **everything** — config, API keys, personality, all memories, skills, cron jobs, plugins. A complete working snapshot. Per-profile history is excluded (session history, `state.db`, `backups/`, `state-snapshots/`, `checkpoints/`) — these belong to the source profile and can reach tens of GB. For a full backup including history, use `claway profile export` or `claway backup` instead. ### Clone from a specific profile ```bash claway profile create work --clone-from coder ``` `--clone-from <source>` selects the source profile directly and implies a config/skills/SOUL clone. Combine it with `--clone-all` when you want a full copy of that source profile: ```bash claway profile create work-backup --clone-from coder --clone-all ``` :::tip Honcho memory + profiles When Honcho is enabled, clone operations automatically create a dedicated AI peer for the new profile while sharing the same user workspace. Each profile builds its own observations and identity. See [Honcho -- Multi-agent / Profiles](./features/memory-providers.md#honcho) for details. ::: ## Using profiles ### Command aliases Every profile automatically gets a command alias at `~/.local/bin/<name>`: ```bash coder chat # chat with the coder agent coder setup # configure coder's settings coder gateway start # start coder's gateway coder doctor # check coder's health coder skills list # list coder's skills coder config set model.default anthropic/claude-sonnet-4 ``` The alias works with every claway subcommand — it's just `claway -p <name>` under the hood. ### The `-p` flag You can also target a profile explicitly with any command: ```bash claway -p coder chat claway --profile=coder doctor claway chat -p coder -q "hello" # works in any position ``` ### Sticky default (`claway profile use`) ```bash claway profile use coder claway chat # now targets coder claway tools # configures coder's tools claway profile use default # switch back ``` Sets a default so plain `claway` commands target that profile. Like `kubectl config use-context`. ### Knowing where you are The CLI always shows which profile is active: - **Prompt**: `coder ❯` instead of `❯` - **Banner**: Shows `Profile: coder` on startup - **`claway profile`**: Shows current profile name, path, model, gateway status ## Profiles vs workspaces vs sandboxing Profiles are often confused with workspaces or sandboxes, but they are different things: - A **profile** gives Claway its own state directory: `config.yaml`, `.env`, `SOUL.md`, sessions, memory, logs, cron jobs, and gateway state. - A **workspace** or **working directory** is where terminal commands start. That is controlled separately by `terminal.cwd`. - A **sandbox** is what limits filesystem access. Profiles do **not** sandbox the agent. On the default `local` terminal backend, the agent still has the same filesystem access as your user account. A profile does not stop it from accessing folders outside the profile directory. If you want a profile to start in a specific project folder, set an explicit absolute `terminal.cwd` in that profile's `config.yaml`: ```yaml terminal: backend: local cwd: /absolute/path/to/project ``` Using `cwd: "."` on the local backend means "the directory Claway was launched from", not "the profile directory". Also note: - `SOUL.md` can guide the model, but it does not enforce a workspace boundary. - Changes to `SOUL.md` take effect cleanly on a new session. Existing sessions may still be using the old prompt state. - Asking the model "what directory are you in?" is not a reliable isolation test. If you need a predictable starting directory for tools, set `terminal.cwd` explicitly. ## Running gateways Each profile runs its own gateway as a separate process with its own bot token: ```bash coder gateway start # starts coder's gateway assistant gateway start # starts assistant's gateway (separate process) ``` ### Different bot tokens Each profile has its own `.env` file. Configure a different Telegram/Discord/Slack bot token in each: ```bash # Edit coder's tokens nano ~/.claway/profiles/coder/.env # Edit assistant's tokens nano ~/.claway/profiles/assistant/.env ``` ### Safety: token locks If two profiles accidentally use the same bot token, the second gateway will be blocked with a clear error naming the conflicting profile. Supported for Telegram, Discord, Slack, WhatsApp, and Signal. ### Persistent services ```bash coder gateway install # creates claway-gateway-coder systemd/launchd service assistant gateway install # creates claway-gateway-assistant service ``` Each profile gets its own service name. They run independently. :::note Inside the official Docker image Per-profile gateways are supervised by [s6-overlay](https://github.com/just-containers/s6-overlay) (PID 1 in the container), so `claway profile create <name>` automatically registers an s6 service slot at `/run/service/gateway-<name>/`. `claway -p <name> gateway start/stop/restart` dispatches to `s6-svc` instead of spawning a bare process — crashes are auto-restarted and `docker restart` preserves the previously-running set of gateways. See Per-profile gateway supervision for details. ::: ## Configuring profiles Each profile has its own: - **`config.yaml`** — model, provider, toolsets, all settings - **`.env`** — API keys, bot tokens - **`SOUL.md`** — personality and instructions ```bash coder config set model.default anthropic/claude-sonnet-4 echo "You are a focused coding assistant." > ~/.claway/profiles/coder/SOUL.md ``` If you want this profile to work in a specific project by default, also set its own `terminal.cwd`: ```bash coder config set terminal.cwd /absolute/path/to/project ``` ### From the dashboard The web dashboard is a machine-level surface that can manage **any** profile's config, API keys, skills, MCPs, and model via the profile switcher in its sidebar — no per-profile dashboard needed. `coder dashboard` routes to the machine dashboard with the `coder` profile preselected. The dashboard's Chat tab also follows the switcher, spawning a conversation under the selected profile's home. Note: "Set as active" on the dashboard's Profiles page is the sticky default for **future CLI/gateway runs** (same as `claway profile use`) — to edit a profile from the dashboard, use the switcher instead. ## Updating `claway update` pulls code once (shared) and syncs new bundled skills to **all** profiles automatically: ```bash claway update # → Code updated (12 commits) # → Skills synced: default (up to date), coder (+2 new), assistant (+2 new) ``` User-modified skills are never overwritten. ## Managing profiles ```bash claway profile list # show all profiles with status claway profile show coder # detailed info for one profile claway profile rename coder dev-bot # rename (updates alias + service) claway profile export coder # export to coder.tar.gz claway profile import coder.tar.gz # import from archive ``` ## Deleting a profile ```bash claway profile delete coder ``` This stops the gateway, removes the systemd/launchd service, removes the command alias, and deletes all profile data. You'll be asked to type the profile name to confirm. Use `--yes` to skip confirmation: `claway profile delete coder --yes` :::note You cannot delete the default profile (`~/.claway`). To remove everything, use `claway uninstall`. ::: ## Tab completion ```bash # Bash eval "$(claway completion bash)" # Zsh eval "$(claway completion zsh)" ``` Add the line to your `~/.bashrc` or `~/.zshrc` for persistent completion. Completes profile names after `-p`, profile subcommands, and top-level commands. ## How it works Profiles use the `CLAWAY_HOME` environment variable. When you run `coder chat`, the wrapper script sets `CLAWAY_HOME=~/.claway/profiles/coder` before launching claway. Since 119+ files in the codebase resolve paths via `get_claway_home()`, Claway state automatically scopes to the profile's directory — config, sessions, memory, skills, state database, gateway PID, logs, and cron jobs. This is separate from terminal working directory. Tool execution starts from `terminal.cwd` (or the launch directory when `cwd: "."` on the local backend), not automatically from `CLAWAY_HOME`. On host installs, tool subprocesses keep your real OS-user `HOME` by default so existing CLI credentials under `~` keep working across profiles. Profile data is isolated by `CLAWAY_HOME`, not by changing `HOME`. Container backends still use `{CLAWAY_HOME}/home` for persistent tool state, and host users who need strict per-profile tool config can opt in with `terminal.home_mode: profile`. This means two things that are easy to mix up: - `CLAWAY_HOME` is the profile boundary. It controls Claway config, `.env`, memory, sessions, skills, logs, cron jobs, gateway state, and other Claway data. - `HOME` is the operating-system/user home that external CLIs expect. On host installs, Claway keeps it as the real user home by default so tools like `git`, `ssh`, `gh`, `az`, `npm`, Claude Code, and Codex find the same credentials they use in your normal shell. The tradeoff is that host profiles share normal user-level CLI state by default. If you need separate CLI identities per profile, set `terminal.home_mode: profile` in that profile's `config.yaml`. In that mode Claway launches tool subprocesses with `HOME={CLAWAY_HOME}/home`; you then need to initialize or link the profile-specific `~/.ssh`, `~/.gitconfig`, `~/.config/gh`, cloud CLI auth, Claude/Codex auth, npm state, and similar files inside that profile home. Claway also exposes `CLAWAY_REAL_HOME` to subprocesses so scripts can still find the actual account home when `home_mode: profile` is active. The default profile is simply `~/.claway` itself. No migration needed — existing installs work identically. ## Sharing profiles as distributions A profile you built on one machine can be packaged as a **git repository** and installed with one command on another machine — your own workstation, a teammate's laptop, or a community user's environment. The shared package includes the SOUL, config, skills, cron jobs, and MCP connections. Credentials, memories, and sessions stay per-machine. ```bash # Install a whole agent from a git repo claway profile install github.com/you/research-bot --alias # Update later when the author ships a new version (keeps your memories + .env) claway profile update research-bot ``` See **[Profile Distributions: Share a Whole Agent](./profile-distributions.md)** for the full guide — authoring, publishing, update semantics, security model, and use cases. --- <!-- source: website/docs/user-guide/security.md --> # Security # Security Claway Agent is designed with a defense-in-depth security model. This page covers every security boundary — from command approval to container isolation to user authorization on messaging platforms. ## Overview The security model has seven layers: 1. **User authorization** — who can talk to the agent (allowlists, DM pairing) 2. **Dangerous command approval** — human-in-the-loop for destructive operations 3. **Container isolation** — Docker/Singularity/Modal sandboxing with hardened settings 4. **MCP credential filtering** — environment variable isolation for MCP subprocesses 5. **Context file scanning** — prompt injection detection in project files 6. **Cross-session isolation** — sessions cannot access each other's data or state; cron job storage paths are hardened against path traversal attacks 7. **Input sanitization** — working directory parameters in terminal tool backends are validated against an allowlist to prevent shell injection ## Dangerous Command Approval Before executing any command, Claway checks it against a curated list of dangerous patterns. If a match is found, the user must explicitly approve it. ### Approval Modes The approval system supports three modes, configured via `approvals.mode` in `~/.claway/config.yaml`: ```yaml approvals: mode: manual # manual | smart | off timeout: 60 # seconds to wait for user response (default: 60) cron_mode: deny # deny | approve — what cron jobs do when they hit a dangerous command mcp_reload_confirm: true # /reload-mcp asks before invalidating the MCP tool cache destructive_slash_confirm: true # /clear, /new, /reset, /undo prompt before discarding state ``` The full set of keys: | Key | Default | What it controls | |---|---|---| | `mode` | `manual` | Approval policy for dangerous shell commands — see the table below. | | `timeout` | `60` | Seconds Claway waits for an approval reply before timing out. | | `cron_mode` | `deny` | How [cron jobs](./features/cron.md) behave headlessly when they trigger a dangerous-command prompt. `deny` blocks the command (the agent must find another path); `approve` auto-approves everything in cron context. | | `mcp_reload_confirm` | `true` | When true, `/reload-mcp` asks before rebuilding the MCP tool set. Rebuilding invalidates the provider prompt cache (tool schemas live in the system prompt), so the next message re-sends full input tokens. Users who click **Always Approve** flip this key to `false`. | | `destructive_slash_confirm` | `true` | When true, destructive session slash commands (`/clear`, `/new`, `/reset`, `/undo`) prompt before discarding conversation state. Three-option dialog (Approve Once / Always Approve / Cancel) routed through native yes/no buttons on Telegram, Discord, and Slack; text fallback elsewhere. Users who click **Always Approve** flip this key to `false`. TUI uses its own modal overlay (set `CLAWAY_TUI_NO_CONFIRM=1` to opt out there). | | Mode | Behavior | |------|----------| | **manual** (default) | Always prompt the user for approval on dangerous commands | | **smart** | Use an auxiliary LLM to assess risk. Low-risk commands (e.g., `python -c "print('hello')"`) are auto-approved. Genuinely dangerous commands are auto-denied. Uncertain cases escalate to a manual prompt. | | **off** | Disable all approval checks — equivalent to running with `--yolo`. All commands execute without prompts. | :::warning Setting `approvals.mode: off` disables all safety prompts. Use only in trusted environments (CI/CD, containers, etc.). ::: ### YOLO Mode YOLO mode bypasses **all** dangerous command approval prompts for the current session. It can be activated three ways: 1. **CLI flag**: Start a session with `claway --yolo` or `claway chat --yolo` 2. **Slash command**: Type `/yolo` during a session to toggle it on/off 3. **Environment variable**: Set `CLAWAY_YOLO_MODE=1` The `/yolo` command is a **toggle** — each use flips the mode on or off: ``` > /yolo ⚡ YOLO mode ON — all commands auto-approved. Use with caution. > /yolo ⚠ YOLO mode OFF — dangerous commands will require approval. ``` YOLO mode is available in both CLI and gateway sessions. Internally, it sets the `CLAWAY_YOLO_MODE` environment variable which is checked before every command execution. When YOLO is active, Claway shows two persistent visual reminders so it's hard to forget that approval prompts are bypassed: - A red banner line at session start when YOLO is already active: `⚠ YOLO mode — all approval prompts bypassed`. Hidden when YOLO is off so the default banner stays uncluttered. - A `⚠ YOLO` fragment in the status bar across all width tiers, updated live as you toggle YOLO on or off (rich-text renderer and plain-text fallback). :::danger YOLO mode disables **all** dangerous command safety checks for the session — **except** the hardline blocklist (see below). Use only when you fully trust the commands being generated (e.g., well-tested automation scripts in disposable environments). ::: For destructive session slash commands (`/clear`, `/new` / `/reset`, `/undo`, `/quit --delete` — `/exit --delete` is an alias), the CLI also prompts for confirmation before running them. See [Slash Commands — Confirmation prompts for destructive commands](../reference/slash-commands.md#confirmation-prompts-for-destructive-commands). ### Hardline Blocklist (Always-On Floor) Some commands are so catastrophic — irreversible filesystem wipes, fork bombs, direct block-device writes — that Claway refuses to run them **regardless** of: - `--yolo` / `/yolo` toggled on - `approvals.mode: off` - Cron jobs running in headless `approve` mode - User explicitly clicking "allow always" The blocklist is the floor below `--yolo`. It trips **before** the approval layer even sees the command, and there's no override flag. Patterns currently covered (not exhaustive; kept in sync with `tools/approval.py::UNRECOVERABLE_BLOCKLIST`): | Pattern | Why it's hardline | |---|---| | `rm -rf /` and obvious variants | Wipes the filesystem root | | `rm -rf --no-preserve-root /` | The explicit "yes I mean root" variant | | `:(){ :\|:& };:` (bash fork bomb) | Pegs the host until reboot | | `mkfs.*` on a mounted root device | Formats the live system | | `dd if=/dev/zero of=/dev/sd*` | Zeroes a physical disk | | Piping untrusted URLs to `sh` at the rootfs top level | Remote-code-execution attack vector too broad to approve | If you hit the blocklist, the tool call returns an explanatory error to the agent and nothing runs. If a legitimate workflow needs one of these commands (you're the operator of a wipe-and-reinstall pipeline, for example), run it outside the agent. ### Approval Timeout When a dangerous command prompt appears, the user has a configurable amount of time to respond. If no response is given within the timeout, the command is **denied** by default (fail-closed). Configure the timeout in `~/.claway/config.yaml`: ```yaml approvals: timeout: 60 # seconds (default: 60) ``` ### What Triggers Approval The following patterns trigger approval prompts (defined in `tools/approval.py`): | Pattern | Description | |---------|-------------| | `rm -r` / `rm --recursive` | Recursive delete | | `rm ... /` | Delete in root path | | `chmod 777/666` / `o+w` / `a+w` | World/other-writable permissions | | `chmod --recursive` with unsafe perms | Recursive world/other-writable (long flag) | | `chown -R root` / `chown --recursive root` | Recursive chown to root | | `mkfs` | Format filesystem | | `dd if=` | Disk copy | | `> /dev/sd` | Write to block device | | `DROP TABLE/DATABASE` | SQL DROP | | `DELETE FROM` (without WHERE) | SQL DELETE without WHERE | | `TRUNCATE TABLE` | SQL TRUNCATE | | `> /etc/` | Overwrite system config | | `systemctl stop/restart/disable/mask` | Stop/restart/disable system services | | `kill -9 -1` | Kill all processes | | `pkill -9` | Force kill processes | | Fork bomb patterns | Fork bombs | | `bash -c` / `sh -c` / `zsh -c` / `ksh -c` | Shell command execution via `-c` flag (including combined flags like `-lc`) | | `python -e` / `perl -e` / `ruby -e` / `node -c` | Script execution via `-e`/`-c` flag | | `curl ... \| sh` / `wget ... \| sh` | Pipe remote content to shell | | `bash <(curl ...)` / `sh <(wget ...)` | Execute remote script via process substitution | | `tee` to `/etc/`, `~/.ssh/`, `~/.claway/.env` | Overwrite sensitive file via tee | | `>` / `>>` to `/etc/`, `~/.ssh/`, `~/.claway/.env` | Overwrite sensitive file via redirection | | `xargs rm` | xargs with rm | | `find -exec rm` / `find -delete` | Find with destructive actions | | `cp`/`mv`/`install` to `/etc/` | Copy/move file into system config | | `sed -i` / `sed --in-place` on `/etc/` | In-place edit of system config | | `pkill`/`killall` claway/gateway | Self-termination prevention | | `gateway run` with `&`/`disown`/`nohup`/`setsid` | Prevents starting gateway outside service manager | :::info **Container bypass**: When running in `docker`, `singularity`, `modal`, or `daytona` backends, dangerous command checks are **skipped** because the container itself is the security boundary. Destructive commands inside a container can't harm the host. ::: ### Approval Flow (CLI) In the interactive CLI, dangerous commands show an inline approval prompt: ``` ⚠️ DANGEROUS COMMAND: recursive delete rm -rf /tmp/old-project [o]nce | [s]ession | [a]lways | [d]eny Choice [o/s/a/D]: ``` The four options: - **once** — allow this single execution - **session** — allow this pattern for the rest of the session - **always** — add to permanent allowlist (saved to `config.yaml`) - **deny** (default) — block the command ### Approval Flow (Gateway/Messaging) On messaging platforms, the agent sends the dangerous command details to the chat and waits for the user to reply: - Reply **yes**, **y**, **approve**, **ok**, or **go** to approve - Reply **no**, **n**, **deny**, or **cancel** to deny The `CLAWAY_EXEC_ASK=1` environment variable is automatically set when running the gateway. ### Permanent Allowlist Commands approved with "always" are saved to `~/.claway/config.yaml`: ```yaml # Permanently allowed dangerous command patterns command_allowlist: - rm - systemctl ``` These patterns are loaded at startup and silently approved in all future sessions. :::tip Use `claway config edit` to review or remove patterns from your permanent allowlist. ::: ## User Authorization (Gateway) When running the messaging gateway, Claway controls who can interact with the bot through a layered authorization system. ### Authorization Check Order The `_is_user_authorized()` method checks in this order: 1. **Per-platform allow-all flag** (e.g., `DISCORD_ALLOW_ALL_USERS=true`) 2. **DM pairing approved list** (users approved via pairing codes) 3. **Platform-specific allowlists** (e.g., `TELEGRAM_ALLOWED_USERS=12345,67890`) 4. **Global allowlist** (`GATEWAY_ALLOWED_USERS=12345,67890`) 5. **Global allow-all** (`GATEWAY_ALLOW_ALL_USERS=true`) 6. **Default: deny** ### Platform Allowlists Set allowed user IDs as comma-separated values in `~/.claway/.env`: ```bash # Platform-specific allowlists TELEGRAM_ALLOWED_USERS=123456789,987654321 DISCORD_ALLOWED_USERS=111222333444555666 WHATSAPP_ALLOWED_USERS=15551234567 SLACK_ALLOWED_USERS=U01ABC123 # Cross-platform allowlist (checked for all platforms) GATEWAY_ALLOWED_USERS=123456789 # Per-platform allow-all (use with caution) DISCORD_ALLOW_ALL_USERS=true # Global allow-all (use with extreme caution) GATEWAY_ALLOW_ALL_USERS=true ``` :::warning If **no allowlists are configured** and `GATEWAY_ALLOW_ALL_USERS` is not set, **all users are denied**. The gateway logs a warning at startup: ``` No user allowlists configured. All unauthorized users will be denied. Set GATEWAY_ALLOW_ALL_USERS=true in ~/.claway/.env to allow open access, or configure platform allowlists (e.g., TELEGRAM_ALLOWED_USERS=your_id). ``` ::: ### DM Pairing System For more flexible authorization, Claway includes a code-based pairing system. Instead of requiring user IDs upfront, unknown users receive a one-time pairing code that the bot owner approves via the CLI. **How it works:** 1. An unknown user sends a DM to the bot 2. The bot replies with an 8-character pairing code 3. The bot owner runs `claway pairing approve <platform> <code>` on the CLI 4. The user is permanently approved for that platform Control how unauthorized direct messages are handled in `~/.claway/config.yaml`: ```yaml unauthorized_dm_behavior: pair whatsapp: unauthorized_dm_behavior: ignore ``` - `pair` is the default for chat-style DM platforms. Unauthorized DMs get a pairing code reply. - `ignore` silently drops unauthorized DMs. - Email defaults to `ignore` unless `platforms.email.unauthorized_dm_behavior: pair` is set, because inboxes can contain unrelated unread mail. - Platform sections override the global default, so you can keep pairing on Telegram while keeping WhatsApp silent. **Security features** (based on OWASP + NIST SP 800-63-4 guidance): | Feature | Details | |---------|---------| | Code format | 8-char from 32-char unambiguous alphabet (no 0/O/1/I) | | Randomness | Cryptographic (`secrets.choice()`) | | Code TTL | 1 hour expiry | | Rate limiting | 1 request per user per 10 minutes | | Pending limit | Max 3 pending codes per platform | | Lockout | 5 failed approval attempts → 1-hour lockout | | File security | `chmod 0600` on all pairing data files | | Logging | Codes are never logged to stdout | **Pairing CLI commands:** ```bash # List pending and approved users claway pairing list # Approve a pairing code claway pairing approve telegram ABC12DEF # Revoke a user's access claway pairing revoke telegram 123456789 # Clear all pending codes claway pairing clear-pending ``` **Storage:** Pairing data is stored in `~/.claway/pairing/` with per-platform JSON files: - `{platform}-pending.json` — pending pairing requests - `{platform}-approved.json` — approved users - `_rate_limits.json` — rate limit and lockout tracking ## Container Isolation When using the `docker` terminal backend, Claway applies strict security hardening to every container. ### Docker Security Flags Every container runs with these flags (defined in `tools/environments/docker.py`): ```python _BASE_SECURITY_ARGS = [ "--cap-drop", "ALL", # Drop ALL Linux capabilities "--cap-add", "DAC_OVERRIDE", # Root can write to bind-mounted dirs "--cap-add", "CHOWN", # Package managers need file ownership "--cap-add", "FOWNER", # Package managers need file ownership "--security-opt", "no-new-privileges", # Block privilege escalation "--pids-limit", "256", # Limit process count "--tmpfs", "/tmp:rw,nosuid,size=512m", # Size-limited /tmp "--tmpfs", "/var/tmp:rw,noexec,nosuid,size=256m", # No-exec /var/tmp ] ``` `SETUID`/`SETGID` are **not** in the base list — they're added conditionally when the container starts as root and an init/entrypoint must drop privileges (the s6 privilege-drop path). They're skipped when the container already runs as a non-root `--user`. The `/run` tmpfs is also split out from the base list and mounted per-image (hardened `noexec` by default, `exec` only for s6-overlay images that exec from `/run`). ### Resource Limits Container resources are configurable in `~/.claway/config.yaml`: ```yaml terminal: backend: docker docker_image: "nikolaik/python-nodejs:python3.11-nodejs20" docker_forward_env: [] # Explicit allowlist only; empty keeps secrets out of the container container_cpu: 1 # CPU cores container_memory: 5120 # MB (default 5GB) container_disk: 51200 # MB (default 50GB, requires overlay2 on XFS) container_persistent: true # Persist filesystem across sessions ``` ### Filesystem Persistence - **Persistent mode** (`container_persistent: true`): Bind-mounts `/workspace` and `/root` from `~/.claway/sandboxes/docker/<task_id>/` - **Ephemeral mode** (`container_persistent: false`): Uses tmpfs for workspace — everything is lost on cleanup :::tip For production gateway deployments, use `docker`, `modal`, or `daytona` backend to isolate agent commands from your host system. This eliminates the need for dangerous command approval entirely. ::: :::warning If you add names to `terminal.docker_forward_env`, those variables are intentionally injected into the container for terminal commands. This is useful for task-specific credentials like `GITHUB_TOKEN`, but it also means code running in the container can read and exfiltrate them. ::: ## Terminal Backend Security Comparison | Backend | Isolation | Dangerous Cmd Check | Best For | |---------|-----------|-------------------|----------| | **local** | None — runs on host | ✅ Yes | Development, trusted users | | **ssh** | Remote machine | ✅ Yes | Running on a separate server | | **docker** | Container | ❌ Skipped (container is boundary) | Production gateway | | **singularity** | Container | ❌ Skipped | HPC environments | | **modal** | Cloud sandbox | ❌ Skipped | Scalable cloud isolation | | **daytona** | Cloud sandbox | ❌ Skipped | Persistent cloud workspaces | ## Environment Variable Passthrough {#environment-variable-passthrough} Both `execute_code` and `terminal` strip sensitive environment variables from child processes to prevent credential exfiltration by LLM-generated code. However, skills that declare `required_environment_variables` legitimately need access to those vars. ### How It Works Two mechanisms allow specific variables through the sandbox filters: **1. Skill-scoped passthrough (automatic)** When a skill is loaded (via `skill_view` or the `/skill` command) and declares `required_environment_variables`, any of those vars that are actually set in the environment are automatically registered as passthrough. Missing vars (still in setup-needed state) are **not** registered. ```yaml # In a skill's SKILL.md frontmatter required_environment_variables: - name: TENOR_API_KEY prompt: Tenor API key help: Get a key from https://developers.google.com/tenor ``` After loading this skill, `TENOR_API_KEY` passes through to `execute_code`, `terminal` (local), **and remote backends (Docker, Modal)** — no manual configuration needed. :::info Docker & Modal Prior to v0.5.1, Docker's `forward_env` was a separate system from the skill passthrough. They are now merged — skill-declared env vars are automatically forwarded into Docker containers and Modal sandboxes without needing to add them to `docker_forward_env` manually. ::: **2. Config-based passthrough (manual)** For env vars not declared by any skill, add them to `terminal.env_passthrough` in `config.yaml`: ```yaml terminal: env_passthrough: - MY_CUSTOM_KEY - ANOTHER_TOKEN ``` ### Credential File Passthrough (OAuth tokens, etc.) {#credential-file-passthrough} Some skills need **files** (not just env vars) in the sandbox — for example, Google Workspace stores OAuth tokens as `google_token.json` under the active profile's `CLAWAY_HOME`. Skills declare these in frontmatter: ```yaml required_credential_files: - path: google_token.json description: Google OAuth2 token (created by setup script) - path: google_client_secret.json description: Google OAuth2 client credentials ``` When loaded, Claway checks if these files exist in the active profile's `CLAWAY_HOME` and registers them for mounting: - **Docker**: Read-only bind mounts (`-v host:container:ro`) - **Modal**: Mounted at sandbox creation + synced before each command (handles mid-session OAuth setup) - **Local**: No action needed (files already accessible) You can also list credential files manually in `config.yaml`: ```yaml terminal: credential_files: - google_token.json - my_custom_oauth_token.json ``` Paths are relative to `~/.claway/`. Files are mounted to `/root/.claway/` inside the container. This list is read by `tools/credential_files.py` (`terminal.credential_files`) — it lives under the `terminal:` block but is loaded by the credential-files module, not the core terminal backend, so it isn't part of the bundled `DEFAULT_CONFIG` snapshot. ### What Each Sandbox Filters | Sandbox | Default Filter | Passthrough Override | |---------|---------------|---------------------| | **execute_code** | Blocks vars containing `KEY`, `TOKEN`, `SECRET`, `PASSWORD`, `CREDENTIAL`, `PASSWD`, `AUTH` in name; only allows safe-prefix vars through | ✅ Passthrough vars bypass both checks | | **terminal** (local) | Blocks explicit Claway infrastructure vars (provider keys, gateway tokens, tool API keys) | ✅ Passthrough vars bypass the blocklist | | **terminal** (Docker) | No host env vars by default | ✅ Passthrough vars + `docker_forward_env` forwarded via `-e` | | **terminal** (Modal) | No host env/files by default | ✅ Credential files mounted; env passthrough via sync | | **MCP** | Blocks everything except safe system vars + explicitly configured `env` | ❌ Not affected by passthrough (use MCP `env` config instead) | ### Security Considerations - The passthrough only affects vars you or your skills explicitly declare — the default security posture is unchanged for arbitrary LLM-generated code - Credential files are mounted **read-only** into Docker containers - Skills Guard scans skill content for suspicious env access patterns before installation - Missing/unset vars are never registered (you can't leak what doesn't exist) - Claway infrastructure secrets (provider API keys, gateway tokens) should never be added to `env_passthrough` — they have dedicated mechanisms ## MCP Credential Handling MCP (Model Context Protocol) server subprocesses receive a **filtered environment** to prevent accidental credential leakage. ### Safe Environment Variables Only these variables are passed through from the host to MCP stdio subprocesses: ``` PATH, HOME, USER, LANG, LC_ALL, TERM, SHELL, TMPDIR ``` Plus any `XDG_*` variables. All other environment variables (API keys, tokens, secrets) are **stripped**. Variables explicitly defined in the MCP server's `env` config are passed through: ```yaml mcp_servers: github: command: "npx" args: ["-y", "@modelcontextprotocol/server-github"] env: GITHUB_PERSONAL_ACCESS_TOKEN: "ghp_..." # Only this is passed ``` ### Credential Redaction Error messages from MCP tools are sanitized before being returned to the LLM. The following patterns are replaced with `[REDACTED]`: - GitHub PATs (`ghp_...`) - OpenAI-style keys (`sk-...`) - Bearer tokens - `token=`, `key=`, `API_KEY=`, `password=`, `secret=` parameters ### Website Access Policy You can restrict which websites the agent can access through its web and browser tools. This is useful for preventing the agent from accessing internal services, admin panels, or other sensitive URLs. ```yaml # In ~/.claway/config.yaml security: website_blocklist: enabled: true domains: - "*.internal.company.com" - "admin.example.com" shared_files: - "/etc/claway/blocked-sites.txt" ``` When a blocked URL is requested, the tool returns an error explaining the domain is blocked by policy. The blocklist is enforced across `web_search`, `web_extract`, `browser_navigate`, and all URL-capable tools. See [Website Blocklist](/user-guide/configuration#website-blocklist) in the configuration guide for full details. ### SSRF Protection All URL-capable tools (web search, web extract, vision, browser) validate URLs before fetching them to prevent Server-Side Request Forgery (SSRF) attacks. Blocked addresses include: - **Private networks** (RFC 1918): `10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16` - **Loopback**: `127.0.0.0/8`, `::1` - **Link-local**: `169.254.0.0/16` (includes cloud metadata at `169.254.169.254`) - **CGNAT / shared address space** (RFC 6598): `100.64.0.0/10` (Tailscale, WireGuard VPNs) - **Cloud metadata hostnames**: `metadata.google.internal`, `metadata.goog` - **Reserved, multicast, and unspecified addresses** SSRF protection is always active for internet-facing use and DNS failures are treated as blocked (fail-closed). Redirect chains are re-validated at each hop to prevent redirect-based bypasses. #### Intentionally allowing private URLs Some setups legitimately need private/internal URL access — home networks that resolve `home.arpa` to RFC 1918 space, LAN-only Ollama/llama.cpp endpoints, internal wikis, cloud metadata debugging, and the like. For those cases there's a global opt-out: ```yaml security: allow_private_urls: true # default: false ``` When on, web tools, the browser, vision URL fetches, and gateway media downloads no longer reject RFC 1918 / loopback / link-local / CGNAT / cloud-metadata destinations. **This is a deliberate trust boundary** — only enable it on machines where the agent running arbitrary prompt-injected URLs against the local network is an acceptable risk. Public-facing gateways should leave it off. The host-substring guard (which blocks lookalike Unicode domain tricks even when the underlying IP is public) stays on regardless of this setting. ### Tirith Pre-Exec Security Scanning Claway integrates [tirith](https://github.com/sheeki03/tirith) for content-level command scanning before execution. Tirith detects threats that pattern matching alone misses: - Homograph URL spoofing (internationalized domain attacks) - Pipe-to-interpreter patterns (`curl | bash`, `wget | sh`) - Terminal injection attacks Tirith auto-installs from GitHub releases on first use with SHA-256 checksum verification (and cosign provenance verification if cosign is available). ```yaml # In ~/.claway/config.yaml security: tirith_enabled: true # Enable/disable tirith scanning (default: true) tirith_path: "tirith" # Path to tirith binary (default: PATH lookup) tirith_timeout: 5 # Subprocess timeout in seconds tirith_fail_open: true # Allow execution when tirith is unavailable (default: true) ``` When `tirith_fail_open` is `true` (default), commands proceed if tirith is not installed or times out. Set to `false` in high-security environments to block commands when tirith is unavailable. Tirith ships prebuilt binaries for Linux (x86_64 / aarch64) and macOS (x86_64 / arm64). On platforms with no prebuilt binary (Windows, etc.), tirith is silently skipped — pattern-matching guards still run, and the CLI does not surface an "unavailable" banner. To use tirith on Windows, run Claway under WSL. Tirith's verdict integrates with the approval flow: safe commands pass through, while both suspicious and blocked commands trigger user approval with the full tirith findings (severity, title, description, safer alternatives). Users can approve or deny — the default choice is deny to keep unattended scenarios secure. ### Context File Injection Protection Context files (AGENTS.md, .cursorrules, SOUL.md) are scanned for prompt injection before being included in the system prompt. The scanner checks for: - Instructions to ignore/disregard prior instructions - Hidden HTML comments with suspicious keywords - Attempts to read secrets (`.env`, `credentials`, `.netrc`) - Credential exfiltration via `curl` - Invisible Unicode characters (zero-width spaces, bidirectional overrides) Blocked files show a warning: ``` [BLOCKED: AGENTS.md contained potential prompt injection (prompt_injection). Content not loaded.] ``` ## Best Practices for Production Deployment ### Gateway Deployment Checklist 1. **Set explicit allowlists** — never use `GATEWAY_ALLOW_ALL_USERS=true` in production 2. **Use container backend** — set `terminal.backend: docker` in config.yaml 3. **Restrict resource limits** — set appropriate CPU, memory, and disk limits 4. **Store secrets securely** — keep API keys in `~/.claway/.env` with proper file permissions 5. **Enable DM pairing** — use pairing codes instead of hardcoding user IDs when possible 6. **Review command allowlist** — periodically audit `command_allowlist` in config.yaml 7. **Set `terminal.cwd`** — don't let the agent operate from sensitive directories 8. **Run as non-root** — never run the gateway as root 9. **Monitor logs** — check `~/.claway/logs/` for unauthorized access attempts 10. **Keep updated** — run `claway update` regularly for security patches ### Securing API Keys ```bash # Set proper permissions on the .env file chmod 600 ~/.claway/.env # Keep separate keys for different services # Never commit .env files to version control ``` ### Network Isolation For maximum security, run the gateway on a separate machine or VM. Set `terminal.backend: ssh` in `config.yaml`, then provide host details via environment variables in `~/.claway/.env`: ```yaml # ~/.claway/config.yaml terminal: backend: ssh ``` ```bash # ~/.claway/.env TERMINAL_SSH_HOST=agent-worker.local TERMINAL_SSH_USER=claway TERMINAL_SSH_KEY=~/.ssh/claway_agent_key ``` The SSH connection details live in `.env` (not `config.yaml`) so they aren't checked in or shared along with profile exports. This keeps the gateway's messaging connections separate from the agent's command execution. ## Supply-chain advisory checking Claway ships with a built-in advisory scanner that flags Python packages in the active venv that match a curated catalog of known-compromised versions (supply-chain worms like the May 2026 `mistralai 2.4.6` poisoning). Implementation lives in `claway_cli/security_advisories.py`. How it runs: - **CLI startup banner.** A one-line warning is printed if any advisory matches, with a pointer to `claway doctor` for the full remediation. - **`claway doctor`.** Surfaces every active advisory with version specifics and 2-4 step remediation instructions. - **Gateway startup.** Logged to `gateway.log`; the first interactive message gets a short operator banner. Each advisory carries a stable id. Once you have read and acted on it you can dismiss it for good: ```bash claway doctor --ack <advisory-id> ``` The ack is persisted to `config.security.acked_advisories` and survives restart. Old advisories are intentionally **not** removed from the catalog — leaving them in place keeps fresh installs warned about historically poisoned versions that might still be cached in a private mirror. The check itself is stdlib-only and runs from one `importlib.metadata.version()` lookup per advisory, so it's safe to run on every startup. ### Lazy install of optional dependencies Many features (Mistral TTS, ElevenLabs, Honcho memory, Bedrock, Slack, Matrix, …) depend on Python packages that not every user needs. Claway installs these **lazily** on first use rather than eagerly under `claway[all]`. The implementation lives in `tools/lazy_deps.py`. The trade-off this fixes: - **Fragility.** When one extra's transitive dependency becomes unavailable on PyPI (quarantined for malware, yanked, broken upload), the entire `[all]` resolve would fail and fresh installs would silently fall back to a stripped tier — losing 10+ unrelated extras at once. Lazy install isolates each backend so one poisoned dep can't break unrelated features. - **Bloat.** A user who only ever talks to one provider no longer pulls hundreds of packages they will never import. How it works: 1. A backend module calls `ensure("feature.name")` at the top of its first-import path. 2. If the deps are missing, `ensure` checks `security.allow_lazy_installs` in `config.yaml` (default `true`) and runs a venv-scoped `pip install` for the allowlisted specs. 3. If the install fails or the user has disabled lazy installs, the call raises `FeatureUnavailable` with the actual pip stderr and a pointer at `claway tools`. Security guarantees enforced by `tools/lazy_deps.py`: | Guarantee | What it means | |---|---| | Venv-scoped only | Installs target `sys.executable` in the active venv — never the system Python | | PyPI by name only | Specs accept `"package>=1.0,<2"` syntax. No `--index-url`, `git+https://`, or file: paths — a malicious `config.yaml` cannot redirect the install | | Allowlist | Only specs that appear in the in-tree `LAZY_DEPS` map can be installed via this path. A typo in a feature name does NOT get install-anything semantics | | Opt-out | Set `security.allow_lazy_installs: false` to disable runtime installs entirely. Useful for restricted networks or strict security postures | | No silent retries | Failures surface as `FeatureUnavailable` — no caching of bad state, no retry storms | To disable runtime installs: ```yaml # ~/.claway/config.yaml security: allow_lazy_installs: false ``` When disabled, backends that need optional deps will tell the user to run the install manually (`pip install …`) or pick a different backend via `claway tools`. --- <!-- source: website/docs/user-guide/checkpoints-and-rollback.md --> # Checkpoints and /rollback # Checkpoints and `/rollback` Claway Agent can automatically snapshot your project before **destructive operations** and restore it with a single command. Checkpoints are **opt-in** as of v2 — most users never use `/rollback`, and the shadow-store storage is non-trivial over time, so the default is off. Enable checkpoints per-session with `--checkpoints`: ```bash claway chat --checkpoints ``` Or enable globally in `~/.claway/config.yaml`: ```yaml checkpoints: enabled: true ``` This safety net is powered by an internal **Checkpoint Manager** that keeps a single shared shadow git repository under `~/.claway/checkpoints/store/` — your real project `.git` is never touched. Every project the agent works in shares the same store, so git's content-addressable object DB deduplicates across projects and across turns. ## What Triggers a Checkpoint Checkpoints are taken automatically before: - **File tools** — `write_file` and `patch` - **Destructive terminal commands** — `rm`, `rmdir`, `cp`, `install`, `mv`, `sed -i`, `truncate`, `dd`, `shred`, output redirects (`>`), and `git reset`/`clean`/`checkout` The agent creates **at most one checkpoint per directory per turn**, so long-running sessions don't spam snapshots. ## Quick Reference In-session slash commands: | Command | Description | |---------|-------------| | `/rollback` | List all checkpoints with change stats | | `/rollback <N>` | Restore to checkpoint N (also undoes last chat turn) | | `/rollback diff <N>` | Preview diff between checkpoint N and current state | | `/rollback <N> <file>` | Restore a single file from checkpoint N | CLI for inspecting and managing the store outside a session: | Command | Description | |---------|-------------| | `claway checkpoints` | Show total size, project count, per-project breakdown | | `claway checkpoints status` | Same as bare `checkpoints` | | `claway checkpoints list` | Alias for `status` | | `claway checkpoints prune` | Force a sweep: delete orphans/stale, GC, enforce size cap | | `claway checkpoints clear` | Nuke the entire checkpoint base (asks first) | | `claway checkpoints clear-legacy` | Delete only the `legacy-*` archives from v1 migration | ## How Checkpoints Work At a high level: - Claway detects when tools are about to **modify files** in your working tree. - Once per conversation turn (per directory), it: - Resolves a reasonable project root for the file. - Initialises or reuses the **single shared shadow store** at `~/.claway/checkpoints/store/`. - Stages into a per-project index, builds a tree, and commits to a per-project ref (`refs/claway/<project-hash>`). - These per-project refs form a checkpoint history that you can inspect and restore via `/rollback`. ```mermaid flowchart LR user["User command\n(claway, gateway)"] agent["AIAgent\n(run_agent.py)"] tools["File & terminal tools"] cpMgr["CheckpointManager"] store["Shared shadow store\n~/.claway/checkpoints/store/"] user --> agent agent -->|"tool call"| tools tools -->|"before mutate\nensure_checkpoint()"| cpMgr cpMgr -->|"git add/commit-tree/update-ref"| store cpMgr -->|"OK / skipped"| tools tools -->|"apply changes"| agent ``` ## Configuration Configure in `~/.claway/config.yaml`: ```yaml checkpoints: enabled: false # master switch (default: false — opt-in) max_snapshots: 20 # max checkpoints per project (enforced via ref rewrite + gc) max_total_size_mb: 500 # hard cap on total store size; oldest commits dropped max_file_size_mb: 10 # skip any single file larger than this # Auto-maintenance (on by default): sweep ~/.claway/checkpoints/ at startup # and delete project entries whose working directory no longer exists # (orphans) or whose last_touch is older than retention_days. Runs at most # once per min_interval_hours, tracked via a .last_prune marker. auto_prune: true retention_days: 7 delete_orphans: true min_interval_hours: 24 ``` To disable everything: ```yaml checkpoints: enabled: false auto_prune: false ``` When `enabled: false`, the Checkpoint Manager is a no-op and never attempts git operations. When `auto_prune: false`, the store grows until you run `claway checkpoints prune` manually. ## Listing Checkpoints From a CLI session: ``` /rollback ``` Claway responds with a formatted list showing change statistics: ```text 📸 Checkpoints for /path/to/project: 1. 4270a8c 2026-03-16 04:36 before patch (1 file, +1/-0) 2. eaf4c1f 2026-03-16 04:35 before write_file 3. b3f9d2e 2026-03-16 04:34 before terminal: sed -i s/old/new/ config.py (1 file, +1/-1) /rollback <N> restore to checkpoint N /rollback diff <N> preview changes since checkpoint N /rollback <N> <file> restore a single file from checkpoint N ``` ## Inspecting the Store from the Shell ```bash claway checkpoints ``` Sample output: ```text Checkpoint base: /home/you/.claway/checkpoints Total size: 142.3 MB store/ 138.1 MB legacy-* 4.2 MB Projects: 12 WORKDIR COMMITS LAST TOUCH STATE /home/you/code/claway 20 2h ago live /home/you/code/experiments/rl-runner 8 1d ago live /home/you/code/old-prototype 3 9d ago orphan ... Legacy archives (1): legacy-20260506-050616 4.2 MB Clear with: claway checkpoints clear-legacy ``` Force a full sweep (ignores the 24h idempotency marker): ```bash claway checkpoints prune --retention-days 3 --max-size-mb 200 ``` ## Previewing Changes with `/rollback diff` Before committing to a restore, preview what has changed since a checkpoint: ``` /rollback diff 1 ``` This shows a git diff stat summary followed by the actual diff. ## Restoring with `/rollback` ``` /rollback 1 ``` Behind the scenes, Claway: 1. Verifies the target commit exists in the shadow store. 2. Takes a **pre-rollback snapshot** of the current state so you can "undo the undo" later. 3. Restores tracked files in your working directory. 4. **Undoes the last conversation turn** so the agent's context matches the restored filesystem state. ## Single-File Restore Restore just one file from a checkpoint without affecting the rest of the directory: ``` /rollback 1 src/broken_file.py ``` ## Safety and Performance Guards - **Git availability** — if `git` is not found on `PATH`, checkpoints are transparently disabled. - **Directory scope** — Claway skips overly broad directories (root `/`, home `$HOME`). - **Repository size** — directories with more than 50,000 files are skipped. - **Per-file size cap** — files larger than `max_file_size_mb` (default 10 MB) are excluded from the snapshot. Prevents accidentally swallowing datasets, model weights, or generated media. - **Total store size cap** — when the store exceeds `max_total_size_mb` (default 500 MB), the oldest commit per project is dropped round-robin until under the cap. - **Real pruning** — `max_snapshots` is enforced by rewriting the per-project ref and running `git gc --prune=now` afterwards, so loose objects don't accumulate. - **No-change snapshots** — if there are no changes since the last snapshot, the checkpoint is skipped. - **Non-fatal errors** — all errors inside the Checkpoint Manager are logged at debug level; your tools continue to run. ## Where Checkpoints Live ```text ~/.claway/checkpoints/ ├── store/ # single shared bare git repo │ ├── HEAD, objects/ # git internals (shared across projects) │ ├── refs/claway/<hash> # per-project branch tip │ ├── indexes/<hash> # per-project git index │ ├── projects/<hash>.json # workdir + created_at + last_touch │ └── info/exclude ├── .last_prune # auto-prune idempotency marker └── legacy-<ts>/ # archived pre-v2 per-project shadow repos ``` Each `<hash>` is derived from the absolute path of the working directory. You normally never need to touch these manually — use `claway checkpoints status` / `prune` / `clear` instead. ### Migration from v1 Before the v2 rewrite, each working directory got its own complete shadow git repo directly under `~/.claway/checkpoints/<hash>/`. That layout couldn't dedup objects across projects and had a documented no-op pruner — the store would grow without bound. On first v2 run, any pre-v2 shadow repos are moved into `~/.claway/checkpoints/legacy-<timestamp>/` so the new single-store layout starts clean. Old `/rollback` history is still reachable by manually inspecting the legacy archive with `git`; once you're confident you don't need it, run: ```bash claway checkpoints clear-legacy ``` to reclaim the space. Legacy archives are also swept by `auto_prune` after `retention_days`. ## Best Practices - **Enable checkpoints only when you need them** — `claway chat --checkpoints` or per-profile `enabled: true`. - **Use `/rollback diff` before restoring** — preview what will change to pick the right checkpoint. - **Use `/rollback` instead of `git reset`** when you want to undo agent-driven changes only. - **Check `claway checkpoints status` occasionally** if you use checkpoints regularly — shows which projects are active and what the store costs you. - **Combine with Git worktrees** for maximum safety — keep each Claway session in its own worktree/branch, with checkpoints as an extra layer. For running multiple agents in parallel on the same repo, see the guide on [Git worktrees](./git-worktrees.md). --- <!-- source: website/docs/user-guide/features/overview.md --> # Features Overview # Features Overview Claway Agent includes a rich set of capabilities that extend far beyond basic chat. From persistent memory and file-aware context to browser automation and voice conversations, these features work together to make Claway a powerful autonomous assistant. ## Core - **[Tools & Toolsets](tools.md)** — Tools are functions that extend the agent's capabilities. They're organized into logical toolsets that can be enabled or disabled per platform, covering web search, terminal execution, file editing, memory, delegation, and more. - **[Skills System](skills.md)** — On-demand knowledge documents the agent can load when needed. Skills follow a progressive disclosure pattern to minimize token usage and are compatible with the [agentskills.io](https://agentskills.io/specification) open standard. - **[Persistent Memory](memory.md)** — Bounded, curated memory that persists across sessions. Claway remembers your preferences, projects, environment, and things it has learned via `MEMORY.md` and `USER.md`. - **[Context Files](context-files.md)** — Claway automatically discovers and loads project context files (`.claway.md`, `AGENTS.md`, `CLAUDE.md`, `SOUL.md`, `.cursorrules`) that shape how it behaves in your project. - **[Context References](context-references.md)** — Type `@` followed by a reference to inject files, folders, git diffs, and URLs directly into your messages. Claway expands the reference inline and appends the content automatically. - **[Checkpoints](../checkpoints-and-rollback.md)** — Claway automatically snapshots your working directory before making file changes, giving you a safety net to roll back with `/rollback` if something goes wrong. ## Automation - **[Scheduled Tasks (Cron)](cron.md)** — Schedule tasks to run automatically with natural language or cron expressions. Jobs can attach skills, deliver results to any platform, and support pause/resume/edit operations. - **[Subagent Delegation](delegation.md)** — The `delegate_task` tool spawns child agent instances with isolated context, restricted toolsets, and their own terminal sessions. Run 3 concurrent subagents by default (configurable) for parallel workstreams. - **[Code Execution](code-execution.md)** — The `execute_code` tool lets the agent write Python scripts that call Claway tools programmatically, collapsing multi-step workflows into a single LLM turn via sandboxed RPC execution. - **[Event Hooks](hooks.md)** — Run custom code at key lifecycle points. Gateway hooks handle logging, alerts, and webhooks; plugin hooks handle tool interception, metrics, and guardrails. ## Media & Web - **[Voice Mode](voice-mode.md)** — Full voice interaction across CLI and messaging platforms. Talk to the agent using your microphone, hear spoken replies, and have live voice conversations in Discord voice channels. - **[Browser Automation](browser.md)** — Full browser automation with multiple backends: Browserbase cloud, Browser Use cloud, local Chrome/Brave/Chromium/Edge via CDP, or local Chromium. Navigate websites, fill forms, and extract information. - **[Vision & Image Paste](vision.md)** — Multimodal vision support. Paste images from your clipboard into the CLI and ask the agent to analyze, describe, or work with them using any vision-capable model. - **[Image Generation](image-generation.md)** — Generate images from text prompts using FAL.ai. Nine models supported (FLUX 2 Klein/Pro, GPT-Image 1.5/2, Nano Banana Pro, Ideogram V3, Recraft V4 Pro, Qwen, Z-Image Turbo); pick one via `claway tools`. - **[Voice & TTS](tts.md)** — Text-to-speech output and voice message transcription across all messaging platforms, with ten native provider options: Edge TTS (free), ElevenLabs, OpenAI TTS, MiniMax, Mistral Voxtral, Google Gemini, xAI, NeuTTS, KittenTTS, and Piper — plus custom command providers for any local TTS CLI. ## Integrations - **[MCP Integration](mcp.md)** — Connect to any MCP server via stdio or HTTP transport. Access external tools from GitHub, databases, file systems, and internal APIs without writing native Claway tools. Includes per-server tool filtering and sampling support. - **[Provider Routing](provider-routing.md)** — Fine-grained control over which AI providers handle your requests. Optimize for cost, speed, or quality with sorting, whitelists, blacklists, and priority ordering. - **[Fallback Providers](fallback-providers.md)** — Automatic failover to backup LLM providers when your primary model encounters errors, including independent fallback for auxiliary tasks like vision and compression. - **[Credential Pools](credential-pools.md)** — Distribute API calls across multiple keys for the same provider. Automatic rotation on rate limits or failures. - **[Prompt caching](../configuration#prompt-caching)** — Built-in cross-session 1-hour prefix cache for Claude on native Anthropic and OpenRouter. Always-on; no configuration required. - **[Memory Providers](memory-providers.md)** — Plug in external memory backends (Honcho, OpenViking, Mem0, Hindsight, Holographic, RetainDB, ByteRover, Supermemory) for cross-session user modeling and personalization beyond the built-in memory system. - **[API Server](api-server.md)** — Expose Claway as an OpenAI-compatible HTTP endpoint. Connect any frontend that speaks the OpenAI format — Open WebUI, LobeChat, LibreChat, and more. ## Customization - **[Personality & SOUL.md](personality.md)** — Fully customizable agent personality. `SOUL.md` is the primary identity file — the first thing in the system prompt — and you can swap in built-in or custom `/personality` presets per session. - **[Skins & Themes](skins.md)** — Customize the CLI's visual presentation: banner colors, spinner faces and verbs, response-box labels, branding text, and the tool activity prefix. - **[Plugins](plugins.md)** — Add custom tools, hooks, and integrations without modifying core code. Three plugin types: general plugins (tools/hooks), memory providers (cross-session knowledge), and context engines (alternative context management). Managed via the unified `claway plugins` interactive UI. --- <!-- source: website/docs/user-guide/features/tools.md --> # Tools & Toolsets # Tools & Toolsets Tools are functions that extend the agent's capabilities. They're organized into logical **toolsets** that can be enabled or disabled per platform. ## Available Tools Claway ships with a broad built-in tool registry covering web search, browser automation, terminal execution, file editing, memory, delegation, scheduled tasks, Home Assistant, and more. :::note **Honcho cross-session memory** is available as a memory provider plugin (`plugins/memory/honcho/`), not as a built-in toolset. See [Plugins](./plugins.md) for installation. ::: High-level categories: | Category | Examples | Description | |----------|----------|-------------| | **Web** | `web_search`, `web_extract` | Search the web and extract page content. | | **X Search** | `x_search` | Search X (Twitter) posts and threads via xAI's built-in `x_search` Responses tool — gated on xAI credentials (SuperGrok OAuth or `XAI_API_KEY`); off by default, opt in via `claway tools` → 🐦 X (Twitter) Search. | | **Terminal & Files** | `terminal`, `process`, `read_file`, `patch` | Execute commands and manipulate files. | | **Browser** | `browser_navigate`, `browser_snapshot`, `browser_vision` | Interactive browser automation with text and vision support. | | **Media** | `vision_analyze`, `image_generate`, `text_to_speech` | Multimodal analysis and generation. | | **Agent orchestration** | `todo`, `clarify`, `execute_code`, `delegate_task` | Planning, clarification, code execution, and subagent delegation. | | **Memory & recall** | `memory`, `session_search` | Persistent memory and session search. | | **Automation** | `cronjob` | Scheduled tasks with create/list/update/pause/resume/run/remove actions. Outbound delivery is handled by cron's own delivery, the `claway send` CLI, and the gateway notifier — not by an agent-callable tool. | | **Integrations** | `ha_*`, MCP server tools | Home Assistant, MCP, and other integrations. | For the authoritative code-derived registry, see [Built-in Tools Reference](/reference/tools-reference) and [Toolsets Reference](/reference/toolsets-reference). ## Using Toolsets ```bash # Use specific toolsets claway chat --toolsets "web,terminal" # See all available tools claway tools # Configure tools per platform (interactive) claway tools ``` Common toolsets include `web`, `search`, `terminal`, `file`, `browser`, `vision`, `image_gen`, `skills`, `tts`, `todo`, `memory`, `session_search`, `cronjob`, `code_execution`, `delegation`, `clarify`, `homeassistant`, `messaging`, `spotify`, `discord`, `discord_admin`, `debugging`, and `safe`. See [Toolsets Reference](/reference/toolsets-reference) for the full set, including platform presets such as `claway-cli`, `claway-telegram`, and dynamic MCP toolsets like `mcp-<server>`. ## Terminal Backends The terminal tool can execute commands in different environments: | Backend | Description | Use Case | |---------|-------------|----------| | `local` | Run on your machine (default) | Development, trusted tasks | | `docker` | Isolated containers | Security, reproducibility | | `ssh` | Remote server | Sandboxing, keep agent away from its own code | | `singularity` | HPC containers | Cluster computing, rootless | | `modal` | Cloud execution | Serverless, scale | | `daytona` | Cloud sandbox workspace | Persistent remote dev environments | ### Configuration ```yaml # In ~/.claway/config.yaml terminal: backend: local # or: docker, ssh, singularity, modal, daytona cwd: "." # Working directory timeout: 180 # Command timeout in seconds ``` ### Docker Backend ```yaml terminal: backend: docker docker_image: python:3.11-slim ``` **One persistent container, shared across the whole process.** Claway starts a single long-lived container on first use (`docker run -d ... sleep 2h`) and routes every terminal, file, and `execute_code` call through `docker exec` into that same container. Working-directory changes, installed packages, environment tweaks, and files written to `/workspace` all carry over from one tool call to the next, across `/new`, `/reset`, and `delegate_task` subagents, for the lifetime of the Claway process. The container is stopped and removed on shutdown. This means the Docker backend behaves like a persistent sandbox VM, not a fresh container per command. If you `pip install foo` once, it's there for the rest of the session. If you `cd /workspace/project`, subsequent `ls` calls see that directory. See [Configuration → Docker Backend](../configuration.md#docker-backend) for the full lifecycle details and the `container_persistent` flag that controls whether `/workspace` and `/root` survive across Claway restarts. ### SSH Backend Recommended for security — agent can't modify its own code: ```yaml terminal: backend: ssh ``` ```bash # Set credentials in ~/.claway/.env TERMINAL_SSH_HOST=my-server.example.com TERMINAL_SSH_USER=myuser TERMINAL_SSH_KEY=~/.ssh/id_rsa ``` ### Singularity/Apptainer ```bash # Pre-build SIF for parallel workers apptainer build ~/python.sif docker://python:3.11-slim # Configure claway config set terminal.backend singularity claway config set terminal.singularity_image ~/python.sif ``` ### Modal (Serverless Cloud) ```bash uv pip install modal modal setup claway config set terminal.backend modal ``` ### Container Resources Configure CPU, memory, disk, and persistence for all container backends: ```yaml terminal: backend: docker # or singularity, modal, daytona container_cpu: 1 # CPU cores (default: 1) container_memory: 5120 # Memory in MB (default: 5GB) container_disk: 51200 # Disk in MB (default: 50GB) container_persistent: true # Persist filesystem across sessions (default: true) ``` When `container_persistent: true`, installed packages, files, and config survive across sessions. ### Container Security All container backends run with security hardening: - Read-only root filesystem (Docker) - All Linux capabilities dropped - No privilege escalation - PID limits (256 processes) - Full namespace isolation - Persistent workspace via volumes, not writable root layer Docker can optionally receive an explicit env allowlist via `terminal.docker_forward_env`, but forwarded variables are visible to commands inside the container and should be treated as exposed to that session. ## Background Process Management Start background processes and manage them: ```python terminal(command="pytest -v tests/", background=true) # Returns: {"session_id": "proc_abc123", "pid": 12345} # Then manage with the process tool: process(action="list") # Show all running processes process(action="poll", session_id="proc_abc123") # Check status process(action="wait", session_id="proc_abc123") # Block until done process(action="log", session_id="proc_abc123") # Full output process(action="kill", session_id="proc_abc123") # Terminate process(action="write", session_id="proc_abc123", data="y") # Send input ``` PTY mode (`pty=true`) enables interactive CLI tools like Codex and Claude Code. ## Sudo Support If a command needs sudo, you'll be prompted for your password (cached for the session). Or set `SUDO_PASSWORD` in `~/.claway/.env`. :::warning On messaging platforms, if sudo fails, the output includes a tip to add `SUDO_PASSWORD` to `~/.claway/.env`. ::: --- <!-- source: website/docs/user-guide/features/skills.md --> # Skills System # Skills System Skills are on-demand knowledge documents the agent can load when needed. They follow a **progressive disclosure** pattern to minimize token usage and are compatible with the [agentskills.io](https://agentskills.io/specification) open standard. All skills live in **`~/.claway/skills/`** — the primary directory and source of truth. On fresh install, bundled skills are copied from the repo. Hub-installed and agent-created skills also go here. The agent can modify or delete any skill. You can also point Claway at **external skill directories** — additional folders scanned alongside the local one. See [External Skill Directories](#external-skill-directories) below. See also: - [Bundled Skills Catalog](/reference/skills-catalog) - [Official Optional Skills Catalog](/reference/optional-skills-catalog) ## Starting with a blank slate By default every profile is seeded with the bundled skill catalog, and each `claway update` adds any newly bundled skills. If you want a profile with **no bundled skills** — and that stays empty across updates — you have two paths: **At install time** (applies to the default `~/.claway` profile): ```bash curl -fsSL | bash -s -- --no-skills ``` **At profile-create time** (named profiles): ```bash claway profile create research --no-skills ``` **On an already-installed profile** (default or named), toggle it at runtime: ```bash claway skills opt-out # stop future seeding — nothing on disk is touched claway skills opt-out --remove # also delete UNMODIFIED bundled skills (confirms first) claway skills opt-in --sync # undo: remove the marker and re-seed now ``` All three paths write a `.no-bundled-skills` marker into the profile directory. While the marker is present, the installer, `claway update`, and any skill sync all skip bundled-skill seeding for that profile. Delete the marker (or run `claway skills opt-in`) to re-enable. :::note Safe by default `claway skills opt-out` only stops *future* seeding — it never deletes anything already on disk. The optional `--remove` flag deletes bundled skills **only** when they are unmodified (byte-identical to the version Claway installed). Skills you have edited, skills installed from the hub, and skills you wrote yourself are always kept. ::: ## Using Skills Every installed skill is automatically available as a slash command: ```bash # In the CLI or any messaging platform: /gif-search funny cats /axolotl help me fine-tune Llama 3 on my dataset /github-pr-workflow create a PR for the auth refactor /plan design a rollout for migrating our auth provider # Just the skill name loads it and lets the agent ask what you need: /excalidraw ``` The bundled `plan` skill is a good example. Running `/plan [request]` loads the skill's instructions, telling Claway to inspect context if needed, write a markdown implementation plan instead of executing the task, and save the result under `.claway/plans/` relative to the active workspace/backend working directory. You can also interact with skills through natural conversation: ```bash claway chat --toolsets skills -q "What skills do you have?" claway chat --toolsets skills -q "Show me the axolotl skill" ``` ## Learning a skill from sources (`/learn`) `/learn` is the fast way to turn something you already know — or a pile of reference material — into a reusable skill, without hand-writing the `SKILL.md`. It is open-ended: point it at *anything you can describe* and the agent gathers the material with the tools it already has, then authors a skill that follows the [house authoring standards](#skillmd-format) (≤60-char description, the standard section order, Claway-tool framing, no invented commands). ```bash # A local SDK or doc directory — read with read_file / search_files /learn the REST client in ~/projects/acme-sdk, focus on auth + pagination # An online doc page — fetched with web_extract /learn https://docs.example.com/api/quickstart # The workflow you just walked the agent through in this conversation /learn how I just deployed the staging server # Pasted notes / a described procedure /learn filing an expense: open the portal, New > Expense, attach the receipt, submit ``` Because the live agent does the sourcing, `/learn` works the same in the CLI, the messaging gateway, the TUI, and the dashboard — and on any terminal backend (local, Docker, remote), since there is no separate ingestion engine. In the **dashboard**, the Skills page has a **Learn a skill** button that opens a panel with a directory field, a URL field, and an open-ended text box; it composes a `/learn` request and runs it in chat. There is no model-tool footprint: `/learn` builds a standards-guided prompt and hands it to the agent as a normal turn. The agent saves the result with the `skill_manage` tool, so the [write-approval gate](#gating-agent-skill-writes-skillswrite_approval) applies if you have it on. ## Progressive Disclosure Skills use a token-efficient loading pattern: ``` Level 0: skills_list() → [{name, description, category}, ...] (~3k tokens) Level 1: skill_view(name) → Full content + metadata (varies) Level 2: skill_view(name, path) → Specific reference file (varies) ``` The agent only loads the full skill content when it actually needs it. ## SKILL.md Format ```markdown --- name: my-skill description: Brief description of what this skill does version: 1.0.0 platforms: [macos, linux] # Optional — restrict to specific OS platforms metadata: claway: tags: [python, automation] category: devops fallback_for_toolsets: [web] # Optional — conditional activation (see below) requires_toolsets: [terminal] # Optional — conditional activation (see below) config: # Optional — config.yaml settings - key: my.setting description: "What this controls" default: "value" prompt: "Prompt for setup" --- # Skill Title ## When to Use Trigger conditions for this skill. ## Procedure 1. Step one 2. Step two ## Pitfalls - Known failure modes and fixes ## Verification How to confirm it worked. ``` ### Platform-Specific Skills Skills can restrict themselves to specific operating systems using the `platforms` field: | Value | Matches | |-------|---------| | `macos` | macOS (Darwin) | | `linux` | Linux | | `windows` | Windows | ```yaml platforms: [macos] # macOS only (e.g., iMessage, Apple Reminders, FindMy) platforms: [macos, linux] # macOS and Linux ``` When set, the skill is automatically hidden from the system prompt, `skills_list()`, and slash commands on incompatible platforms. If omitted, the skill loads on all platforms. ## Skill output and media delivery When a skill response (or any agent response) includes a bare absolute path to a media file — for example `/home/user/screenshots/diagram.png` — the gateway auto-detects it, strips it from the visible text, and delivers the file natively to the user's chat (Telegram photo, Discord attachment, etc.) instead of leaving the raw path in the message. For audio specifically, the `[[audio_as_voice]]` directive promotes audio files to native voice-message bubbles on platforms that support them (Telegram, WhatsApp). ### Forcing document-style delivery: `[[as_document]]` Sometimes you want the **opposite** of inline preview: you want the file delivered as a downloadable attachment, not a re-compressed image bubble. The classic example is a high-resolution screenshot or chart — Telegram's `sendPhoto` recompresses it to ~200 KB at 1280 px, destroying readability. A 1-2 MB PNG sent via `sendDocument` keeps the original bytes intact. If a response (or any text inside it — typically the last line) contains the literal directive `[[as_document]]`, every media path extracted from that response is delivered as a document/file attachment rather than an image bubble: ``` Here is your rendered chart: /home/user/.claway/cache/chart-q4-2025.png [[as_document]] ``` The directive is stripped before delivery, so users never see it. Granularity is intentionally all-or-nothing per response: emit `[[as_document]]` once and every image path in the same response is delivered as a document. This mirrors the scope of `[[audio_as_voice]]`. Use it from a skill when: - You produce screenshots or charts the user needs as files (for editing in another tool, archiving, sharing intact). - The default lossy preview would obscure detail (small text, pixel-accurate diagrams, color-sensitive renders). Platforms without a separate document path (e.g. SMS) fall back to whatever attachment mechanism they have. ### Conditional Activation (Fallback Skills) Skills can automatically show or hide themselves based on which tools are available in the current session. This is most useful for **fallback skills** — free or local alternatives that should only appear when a premium tool is unavailable. ```yaml metadata: claway: fallback_for_toolsets: [web] # Show ONLY when these toolsets are unavailable requires_toolsets: [terminal] # Show ONLY when these toolsets are available fallback_for_tools: [web_search] # Show ONLY when these specific tools are unavailable requires_tools: [terminal] # Show ONLY when these specific tools are available ``` | Field | Behavior | |-------|----------| | `fallback_for_toolsets` | Skill is **hidden** when the listed toolsets are available. Shown when they're missing. | | `fallback_for_tools` | Same, but checks individual tools instead of toolsets. | | `requires_toolsets` | Skill is **hidden** when the listed toolsets are unavailable. Shown when they're present. | | `requires_tools` | Same, but checks individual tools. | **Example:** The built-in `duckduckgo-search` skill uses `fallback_for_toolsets: [web]`. When you have `FIRECRAWL_API_KEY` set, the web toolset is available and the agent uses `web_search` — the DuckDuckGo skill stays hidden. If the API key is missing, the web toolset is unavailable and the DuckDuckGo skill automatically appears as a fallback. Skills without any conditional fields behave exactly as before — they're always shown. ## Secure Setup on Load Skills can declare required environment variables without disappearing from discovery: ```yaml required_environment_variables: - name: TENOR_API_KEY prompt: Tenor API key help: Get a key from https://developers.google.com/tenor required_for: full functionality ``` When a missing value is encountered, Claway asks for it securely only when the skill is actually loaded in the local CLI. You can skip setup and keep using the skill. Messaging surfaces never ask for secrets in chat — they tell you to use `claway setup` or `~/.claway/.env` locally instead. Once set, declared env vars are **automatically passed through** to `execute_code` and `terminal` sandboxes — the skill's scripts can use `$TENOR_API_KEY` directly. For non-skill env vars, use the `terminal.env_passthrough` config option. See [Environment Variable Passthrough](/user-guide/security#environment-variable-passthrough) for details. ### Skill Config Settings Skills can also declare non-secret config settings (paths, preferences) stored in `config.yaml`: ```yaml metadata: claway: config: - key: myplugin.path description: Path to the plugin data directory default: "~/myplugin-data" prompt: Plugin data directory path ``` Settings are stored under `skills.config` in your config.yaml. `claway config migrate` prompts for unconfigured settings, and `claway config show` displays them. When a skill loads, its resolved config values are injected into the context so the agent knows the configured values automatically. See [Skill Settings](/user-guide/configuration#skill-settings) and [Creating Skills — Config Settings](/developer-guide/creating-skills#config-settings-configyaml) for details. ## Skill Directory Structure ```text ~/.claway/skills/ # Single source of truth ├── mlops/ # Category directory │ ├── axolotl/ │ │ ├── SKILL.md # Main instructions (required) │ │ ├── references/ # Additional docs │ │ ├── templates/ # Output formats │ │ ├── scripts/ # Helper scripts callable from the skill │ │ └── assets/ # Supplementary files │ └── vllm/ │ └── SKILL.md ├── devops/ │ └── deploy-k8s/ # Agent-created skill │ ├── SKILL.md │ └── references/ ├── .hub/ # Skills Hub state │ ├── lock.json │ ├── quarantine/ │ └── audit.log └── .bundled_manifest # Tracks seeded bundled skills ``` ## External Skill Directories If you maintain skills outside of Claway — for example, a shared `~/.agents/skills/` directory used by multiple AI tools — you can tell Claway to scan those directories too. Add `external_dirs` under the `skills` section in `~/.claway/config.yaml`: ```yaml skills: external_dirs: - ~/.agents/skills - /home/shared/team-skills - ${SKILLS_REPO}/skills ``` Paths support `~` expansion and `${VAR}` environment variable substitution. ### How it works - **Create locally, update in place**: New agent-created skills are written to `~/.claway/skills/`. Existing skills are modified where they are found, including skills under `external_dirs`, when the agent uses `skill_manage` actions such as `patch`, `edit`, `write_file`, `remove_file`, or `delete`. - **External dirs are not a write-protection boundary**: If an external skill directory is writable by the Claway process, agent-managed skill updates can change files in that directory. Use filesystem permissions or a separate profile/toolset setup if shared external skills must stay read-only. - **Local precedence**: If the same skill name exists in both the local dir and an external dir, the local version wins. - **Full integration**: External skills appear in the system prompt index, `skills_list`, `skill_view`, and as `/skill-name` slash commands — no different from local skills. - **Non-existent paths are silently skipped**: If a configured directory doesn't exist, Claway ignores it without errors. Useful for optional shared directories that may not be present on every machine. ### Example ```text ~/.claway/skills/ # Local (primary, read-write) ├── devops/deploy-k8s/ │ └── SKILL.md └── mlops/axolotl/ └── SKILL.md ~/.agents/skills/ # External (shared, mutable if writable) ├── my-custom-workflow/ │ └── SKILL.md └── team-conventions/ └── SKILL.md ``` All four skills appear in your skill index. If you create a new skill called `my-custom-workflow` locally, it shadows the external version. ## Skill Bundles Skill bundles are tiny YAML files that group several skills under a single slash command. When you run `/<bundle-name>`, every skill listed in the bundle loads at once — useful when a particular task always benefits from the same set of skills together. ### Quick example ```bash # Create a bundle for backend feature work claway bundles create backend-dev \ --skill github-code-review \ --skill test-driven-development \ --skill github-pr-workflow \ -d "Backend feature work — review, test, PR workflow" ``` Then in the CLI or any gateway platform: ``` /backend-dev refactor the auth middleware ``` The agent receives all three skills loaded into one user message, with any text after the slash command attached as a user instruction. ### YAML schema Bundles live in **`~/.claway/skill-bundles/<slug>.yaml`** and look like this: ```yaml name: backend-dev description: Backend feature work — review, test, PR workflow. skills: - github-code-review - test-driven-development - github-pr-workflow instruction: | Always start by writing failing tests, then implement. Open the PR through the standard workflow with co-author tags. ``` Fields: - `name` (optional — defaults to the filename stem) — the bundle's display name. Normalized to a hyphen slug for the slash command (`Backend Dev` → `/backend-dev`). - `description` (optional) — short text shown in `/bundles` and `claway bundles list`. - `skills` (required, non-empty list) — skill names or paths relative to your skills directory. Use the same identifier you'd pass to `/<skill-name>`. - `instruction` (optional) — extra guidance prepended to the loaded skill content. Useful for codifying "how we always use these together." ### Managing bundles ```bash # List all installed bundles claway bundles list # Inspect one bundle claway bundles show backend-dev # Create a bundle interactively (omit --skill flags to enter them one per line) claway bundles create research # Overwrite an existing bundle claway bundles create backend-dev --skill ... --force # Delete a bundle claway bundles delete backend-dev # Re-scan ~/.claway/skill-bundles/ and report changes claway bundles reload ``` From inside a chat session, `/bundles` lists every installed bundle and its skills. ### Behavior - **Bundles take precedence over individual skills** when slugs collide. If you name a bundle `research` and you also have a skill called `research`, `/research` invokes the bundle. This is intentional — you opted into the bundle by naming it. - **Missing skills are skipped, not fatal.** If a bundle lists `skill-foo` and you haven't installed it, the bundle still loads the skills that do resolve, and the agent gets a note listing what was skipped. - **Bundles work in every surface** — interactive CLI, TUI, dashboard chat, and every gateway platform (Telegram, Discord, Slack, …) — because dispatch is centralized in the same place as individual skill commands. - **Bundles do not invalidate the prompt cache.** They generate a fresh user message at invocation time, the same way `/<skill-name>` does — no system prompt mutation. ### When bundles beat installing each skill manually Use a bundle when: - You always pair the same skills for a recurring task (`/backend-dev`, `/release-prep`, `/incident-response`). - You want a one-character-shorter mental model than typing several `/skill` invocations in a row. - You want to ship a team-wide "task profile" by checking the bundle YAML into a shared dotfiles repo and symlinking it into `~/.claway/skill-bundles/`. A bundle is just a YAML alias — it doesn't install skills for you. The skills themselves must already be present (in `~/.claway/skills/` or an external skill directory). Otherwise the bundle invocation just skips the missing ones. ## Agent-Managed Skills (skill_manage tool) The agent can create, update, and delete its own skills via the `skill_manage` tool. This is the agent's **procedural memory** — when it figures out a non-trivial workflow, it saves the approach as a skill for future reuse. Skills and memory work together in the self-improvement loop: memory stores small durable facts that should always be in context, while skills store longer procedures that should load only when relevant. The background review can suggest or stage skill changes after a session, but the write-approval gate below lets you require human review before those changes land. ### When the Agent Creates Skills - After completing a complex task (5+ tool calls) successfully - When it hit errors or dead ends and found the working path - When the user corrected its approach - When it discovered a non-trivial workflow ### Actions | Action | Use for | Key params | |--------|---------|------------| | `create` | New skill from scratch | `name`, `content` (full SKILL.md), optional `category` | | `patch` | Targeted fixes (preferred) | `name`, `old_string`, `new_string` | | `edit` | Major structural rewrites | `name`, `content` (full SKILL.md replacement) | | `delete` | Remove a skill entirely | `name` | | `write_file` | Add/update supporting files | `name`, `file_path`, `file_content` | | `remove_file` | Remove a supporting file | `name`, `file_path` | :::tip The `patch` action is preferred for updates — it's more token-efficient than `edit` because only the changed text appears in the tool call. ::: ### Gating agent skill writes (`skills.write_approval`) By default the agent writes skills freely — including from the [background self-improvement review](/user-guide/features/memory#controlling-memory-writes-write_approval) that runs after a turn. If you'd rather approve every skill write first (small models that misjudge what they learned, secure environments, or just wanting eyes on the self-improvement loop), turn on the write-approval gate: ```yaml skills: write_approval: false # false = write freely (default) | true = require approval ``` When `write_approval: true`, every `skill_manage` write (create / edit / patch / delete / write_file / remove_file) is **staged** instead of committed — a SKILL.md is too large to review inline, so staging applies regardless of whether the write came from a foreground turn or the background review. Staged writes survive restarts under `~/.claway/pending/skills/` and are reviewed with the same familiar approve/deny flow as dangerous commands: ``` /skills pending # list staged skill writes + a one-line gist each /skills diff <id> # full unified diff (best viewed in CLI or dashboard) /skills approve <id> # apply it (or 'all') /skills reject <id> # drop it (or 'all') /skills approval on # turn the gate on (or 'off') and persist it ``` The review surface works in the interactive CLI and on messaging platforms (diff output is truncated for chat bubbles — read the full diff on the CLI or in the pending JSON file). Memory writes have the same gate under `memory.write_approval` — see [Controlling memory writes](/user-guide/features/memory#controlling-memory-writes-write_approval). > The separate `skills.guard_agent_created` setting is a content scanner > (dangerous-pattern heuristics), not an approval gate — the two are > independent. See [Guard on agent-created skill writes](/user-guide/configuration#guard-on-agent-created-skill-writes). ## Skills Hub Browse, search, install, and manage skills from online registries, `skills.sh`, direct well-known skill endpoints, and official optional skills. ### Common commands ```bash claway skills browse # Browse all hub skills (official first) claway skills browse --source official # Browse only official optional skills claway skills search kubernetes # Search all sources claway skills search react --source skills-sh # Search the skills.sh directory claway skills search https://mintlify.com/docs --source well-known claway skills inspect openai/skills/k8s # Preview before installing claway skills install openai/skills/k8s # Install with security scan claway skills install official/security/1password claway skills install skills-sh/vercel-labs/json-render/json-render-react --force claway skills install well-known:https://mintlify.com/docs/.well-known/skills/mintlify claway skills install https://sharethis.chat/SKILL.md # Direct URL (single-file SKILL.md) claway skills install https://example.com/SKILL.md --name my-skill # Override name when frontmatter has none claway skills list --source hub # List hub-installed skills claway skills check # Check installed hub skills for upstream updates claway skills update # Reinstall hub skills with upstream changes when needed claway skills audit # Re-scan all hub skills for security claway skills uninstall k8s # Remove a hub skill claway skills reset google-workspace # Un-stick a bundled skill from "user-modified" (see below) claway skills reset google-workspace --restore # Also restore the bundled version, deleting your local edits claway skills publish skills/my-skill --to github --repo owner/repo claway skills snapshot export setup.json # Export skill config claway skills tap add myorg/skills-repo # Add a custom GitHub source ``` ### Supported hub sources | Source | Example | Notes | |--------|---------|-------| | `official` | `official/security/1password` | Optional skills shipped with Claway. | | `skills-sh` | `skills-sh/vercel-labs/agent-skills/vercel-react-best-practices` | Searchable via `claway skills search <query> --source skills-sh`. Claway resolves alias-style skills when the skills.sh slug differs from the repo folder. | | `well-known` | `well-known:https://mintlify.com/docs/.well-known/skills/mintlify` | Skills served directly from `/.well-known/skills/index.json` on a website. Search using the site or docs URL. | | `url` | `https://sharethis.chat/SKILL.md` | Direct HTTP(S) URL to a single-file `SKILL.md`. Name resolution: frontmatter → URL slug → interactive prompt → `--name` flag. | | `github` | `openai/skills/k8s` | Direct GitHub repo/path installs and custom taps. | | `clawhub`, `lobehub`, `browse-sh` | Source-specific identifiers | Community or marketplace integrations. | ### Integrated hubs and registries Claway currently integrates with these skills ecosystems and discovery sources: #### 1. Official optional skills (`official`) These are maintained in the Claway repository itself and install with built-in trust. - Catalog: [Official Optional Skills Catalog](../../reference/optional-skills-catalog) - Source in repo: `optional-skills/` - Example: ```bash claway skills browse --source official claway skills install official/security/1password ``` #### 2. skills.sh (`skills-sh`) This is Vercel's public skills directory. Claway can search it directly, inspect skill detail pages, resolve alias-style slugs, and install from the underlying source repo. - Directory: [skills.sh](https://skills.sh/) - CLI/tooling repo: [vercel-labs/skills](https://github.com/vercel-labs/skills) - Official Vercel skills repo: [vercel-labs/agent-skills](https://github.com/vercel-labs/agent-skills) - Example: ```bash claway skills search react --source skills-sh claway skills inspect skills-sh/vercel-labs/json-render/json-render-react claway skills install skills-sh/vercel-labs/json-render/json-render-react --force ``` #### 3. Well-known skill endpoints (`well-known`) This is URL-based discovery from sites that publish `/.well-known/skills/index.json`. It is not a single centralized hub — it is a web discovery convention. - Example live endpoint: [Mintlify docs skills index](https://mintlify.com/docs/.well-known/skills/index.json) - Reference server implementation: [vercel-labs/skills-handler](https://github.com/vercel-labs/skills-handler) - Example: ```bash claway skills search https://mintlify.com/docs --source well-known claway skills inspect well-known:https://mintlify.com/docs/.well-known/skills/mintlify claway skills install well-known:https://mintlify.com/docs/.well-known/skills/mintlify ``` #### 4. Direct GitHub skills (`github`) Claway can install directly from GitHub repositories and GitHub-based taps. This is useful when you already know the repo/path or want to add your own custom source repo. Default taps (browsable without any setup): - [openai/skills](https://github.com/openai/skills) - [anthropics/skills](https://github.com/anthropics/skills) - [huggingface/skills](https://github.com/huggingface/skills) - [NVIDIA/skills](https://github.com/NVIDIA/skills) — NVIDIA-verified skills (signed `skill.oms.sig` + governance `skill-card.md`) - [garrytan/gstack](https://github.com/garrytan/gstack) - Example: ```bash claway skills install openai/skills/k8s claway skills tap add myorg/skills-repo ``` **Category groupings (`skills.sh.json`).** A GitHub tap may ship a `skills.sh.json` file at its repo root following the [skills.sh schema](https://skills.sh/schemas/skills.sh.schema.json). Its `groupings` (each with a `title` and a list of skill names) are read at index time and become the category labels shown in the Skills Hub page — instead of a tag-derived guess. This is generic: any tap that ships the file gets real categorization, no Claway-side changes required. ```json { "$schema": "https://skills.sh/schemas/skills.sh.schema.json", "groupings": [ { "title": "Inference AI", "skills": ["dynamo-recipe-runner", "dynamo-router-sla"] }, { "title": "Decision Optimization", "skills": ["cuopt-developer", "cuopt-install"] } ] } ``` #### 5. ClawHub (`clawhub`) A third-party skills marketplace integrated as a community source. - Site: [clawhub.ai](https://clawhub.ai/) - Claway source id: `clawhub` #### 6. Claude marketplace-style repos (`claude-marketplace`) Claway supports marketplace repos that publish Claude-compatible plugin/marketplace manifests. Known integrated sources include: - [anthropics/skills](https://github.com/anthropics/skills) - [aiskillstore/marketplace](https://github.com/aiskillstore/marketplace) Claway source id: `claude-marketplace` #### 7. LobeHub (`lobehub`) Claway can search and convert agent entries from LobeHub's public catalog into installable Claway skills. - Site: [LobeHub](https://lobehub.com/) - Public agents index: [chat-agents.lobehub.com](https://chat-agents.lobehub.com/) - Backing repo: [lobehub/lobe-chat-agents](https://github.com/lobehub/lobe-chat-agents) - Claway source id: `lobehub` #### 8. browse.sh (`browse-sh`) Claway integrates with [browse.sh](https://browse.sh), Browserbase's catalog of 200+ site-specific browser-automation SKILL.md files (Airbnb, Amazon, arXiv, 12306.cn, Etsy, Xero, and many more). Each skill describes how to drive one website end-to-end and is suitable for use with Claway's browser tools and any browser-automation skills you already have installed. - Site: [browse.sh](https://browse.sh/) - Catalog API: `https://browse.sh/api/skills` - Claway source id: `browse-sh` - Trust level: `community` ```bash claway skills search airbnb --source browse-sh claway skills inspect browse-sh/airbnb.com/search-listings-ddgioa claway skills install browse-sh/airbnb.com/search-listings-ddgioa ``` Identifiers use the form `browse-sh/<hostname>/<task-id>` and match the slug exposed by the browse.sh catalog. Content is resolved through the per-skill detail endpoint (`/api/skills/<slug>` → `skillMdUrl`), not through the catalog's GitHub `sourceUrl`. #### 9. Direct URL (`url`) Install a single-file `SKILL.md` directly from any HTTP(S) URL — useful when an author hosts a skill on their own site (no hub listing, no GitHub path to type). Claway fetches the URL, parses the YAML frontmatter, security-scans it, and installs. - Claway source id: `url` - Identifier: the URL itself (no prefix needed) - Scope: **single-file `SKILL.md`** only. Multi-file skills with `references/` or `scripts/` need a manifest and should be published via one of the other sources above. ```bash claway skills install https://sharethis.chat/SKILL.md claway skills install https://example.com/my-skill/SKILL.md --category productivity ``` Name resolution, in order: 1. `name:` field in the SKILL.md YAML frontmatter (recommended — every well-formed skill has one). 2. Parent directory name from the URL path (e.g. `.../my-skill/SKILL.md` → `my-skill`, or `.../my-skill.md` → `my-skill`), when it's a valid identifier (`^[a-z][a-z0-9_-]*$`). 3. Interactive prompt on a terminal with a TTY. 4. On non-interactive surfaces (the `/skills install` slash command inside the TUI, gateway platforms, scripts), a clean error pointing at the `--name` override. ```bash # Frontmatter has no name and the URL slug is unhelpful — supply one: claway skills install https://example.com/SKILL.md --name sharethis-chat # Or inside a chat session: /skills install https://example.com/SKILL.md --name sharethis-chat ``` Trust level is always `community` — the same security scan runs as for every other source. The URL is stored as the install identifier, so `claway skills update` re-fetches from the same URL automatically when you want to refresh. ### Security scanning and `--force` All hub-installed skills go through a **security scanner** that checks for data exfiltration, prompt injection, destructive commands, supply-chain signals, and other threats. `claway skills inspect ...` now also surfaces upstream metadata when available: - repo URL - skills.sh detail page URL - install command - weekly installs - upstream security audit statuses - well-known index/endpoint URLs Use `--force` when you have reviewed a third-party skill and want to override a non-dangerous policy block: ```bash claway skills install skills-sh/anthropics/skills/pdf --force ``` Important behavior: - `--force` can override policy blocks for caution/warn-style findings. - `--force` does **not** override a `dangerous` scan verdict. - Official optional skills (`official/...`) are treated as built-in trust and do not show the third-party warning panel. ### Trust levels | Level | Source | Policy | |-------|--------|--------| | `builtin` | Ships with Claway | Always trusted | | `official` | `optional-skills/` in the repo | Built-in trust, no third-party warning | | `trusted` | Trusted registries/repos such as `openai/skills`, `anthropics/skills`, `huggingface/skills`, `NVIDIA/skills` | More permissive policy than community sources | | `community` | Everything else (`skills.sh`, well-known endpoints, custom GitHub repos, most marketplaces) | Non-dangerous findings can be overridden with `--force`; `dangerous` verdicts stay blocked | ### Update lifecycle The hub now tracks enough provenance to re-check upstream copies of installed skills: ```bash claway skills check # Report which installed hub skills changed upstream claway skills update # Reinstall only the skills with updates available claway skills update react # Update one specific installed hub skill ``` This uses the stored source identifier plus the current upstream bundle content hash to detect drift. :::tip GitHub rate limits Skills hub operations use the GitHub API, which has a rate limit of 60 requests/hour for unauthenticated users. If you see rate-limit errors during install or search, set `GITHUB_TOKEN` in your `.env` file to increase the limit to 5,000 requests/hour. The error message includes an actionable hint when this happens. ::: ### Publishing a custom skill tap If you want to share a curated set of skills — for your team, your org, or publicly — you can publish them as a **tap**: a GitHub repository other Claway users add with `claway skills tap add <owner/repo>`. No server, no registry sign-up, no release pipeline. Just a directory of `SKILL.md` files. #### Repo layout A tap is any GitHub repo (public or private — private needs `GITHUB_TOKEN`) laid out like this: ``` owner/repo ├── skills/ # default path; configurable per-tap │ ├── my-workflow/ │ │ ├── SKILL.md # required │ │ ├── references/ # optional supporting files │ │ ├── templates/ │ │ └── scripts/ │ ├── another-skill/ │ │ └── SKILL.md │ └── third-skill/ │ └── SKILL.md └── README.md # optional but helpful ``` Rules: - Each skill lives in its own directory under the tap's root path (default `skills/`). - The directory name becomes the skill's install slug. - Each skill directory must contain a `SKILL.md` with standard [SKILL.md frontmatter](#skillmd-format) (`name`, `description`, plus optional `metadata.claway.tags`, `version`, `author`, `platforms`, `metadata.claway.config`). - Subdirectories like `references/`, `templates/`, `scripts/`, `assets/` are downloaded alongside `SKILL.md` at install time. - Skills whose directory name starts with `.` or `_` are ignored. Claway discovers skills by listing every subdirectory of the tap path and probing each for `SKILL.md`. #### Minimal tap example ``` my-org/claway-skills └── skills/ └── deploy-runbook/ └── SKILL.md ``` `skills/deploy-runbook/SKILL.md`: ```markdown --- name: deploy-runbook description: Our deployment runbook — services, rollback, Slack channels version: 1.0.0 author: My Org Platform Team metadata: claway: tags: [deployment, runbook, internal] --- # Deploy Runbook Step 1: ... ``` After pushing that to GitHub, any Claway user can subscribe and install: ```bash claway skills tap add my-org/claway-skills claway skills search deploy claway skills install my-org/claway-skills/deploy-runbook ``` #### Non-default paths If your skills don't live under `skills/` (common when you're adding a `skills/` subtree to an existing project), edit the tap entry in `~/.claway/.hub/taps.json`: ```json { "taps": [ {"repo": "my-org/platform-docs", "path": "internal/skills/"} ] } ``` The `claway skills tap add` CLI defaults new taps to `path: "skills/"`; edit the file directly if you need a different path. `claway skills tap list` shows the effective path per tap. #### Installing individual skills directly (without adding a tap) Users can also install a single skill from any public GitHub repo without adding the whole repo as a tap: ```bash claway skills install owner/repo/skills/my-workflow ``` Useful when you want to share one skill without asking the user to subscribe to your whole registry. #### Trust levels for taps New taps are assigned `community` trust by default. Skills installed from them run through the standard security scan and show the third-party warning panel on first install. If your org or a widely-trusted source should get higher trust, add its repo to `TRUSTED_REPOS` in `tools/skills_hub.py` (requires a Claway core PR). #### Tap management ```bash claway skills tap list # show all configured taps claway skills tap add myorg/skills-repo # add (default path: skills/) claway skills tap remove myorg/skills-repo # remove ``` Inside a running session: ``` /skills tap list /skills tap add myorg/skills-repo /skills tap remove myorg/skills-repo ``` Taps are stored in `~/.claway/.hub/taps.json` (created on demand). ## Bundled skill updates (`claway skills reset`) Claway ships with a set of bundled skills in `skills/` inside the repo. On install and on every `claway update`, a sync pass copies those into `~/.claway/skills/` and records a manifest at `~/.claway/skills/.bundled_manifest` mapping each skill name to the content hash at the time it was synced (the **origin hash**). On each sync, Claway recomputes the hash of your local copy and compares it to the origin hash: - **Unchanged** → safe to pull upstream changes, copy the new bundled version in, record the new origin hash. - **Changed** → treated as **user-modified** and skipped forever, so your edits never get stomped. The protection is good, but it has one sharp edge. If you edit a bundled skill and then later want to abandon your changes and go back to the bundled version by just copy-pasting from `~/.claway/claway/skills/`, the manifest still holds the *old* origin hash from whenever the last successful sync ran. Your fresh copy-paste contents (current bundled hash) won't match that stale origin hash, so sync keeps flagging it as user-modified. `claway skills reset` is the escape hatch: ```bash # Safe: clears the manifest entry for this skill. Your current copy is preserved, # but the next sync re-baselines against it so future updates work normally. claway skills reset google-workspace # Full restore: also deletes your local copy and re-copies the current bundled # version. Use this when you want the pristine upstream skill back. claway skills reset google-workspace --restore # Non-interactive (e.g. in scripts or TUI mode) — skip the --restore confirmation. claway skills reset google-workspace --restore --yes ``` The same command works in chat as a slash command: ```text /skills reset google-workspace /skills reset google-workspace --restore ``` :::note Profiles Each profile has its own `.bundled_manifest` under its own `CLAWAY_HOME`, so `claway -p coder skills reset <name>` only affects that profile. ::: ### Slash commands (inside chat) All the same commands work with `/skills`: ```text /skills browse /skills search react --source skills-sh /skills search https://mintlify.com/docs --source well-known /skills inspect skills-sh/vercel-labs/json-render/json-render-react /skills install openai/skills/skill-creator --force /skills check /skills update /skills reset google-workspace /skills list ``` Official optional skills still use identifiers like `official/security/1password` and `official/migration/openclaw-migration`. --- <!-- source: website/docs/user-guide/features/curator.md --> # Curator # Curator The curator is a background maintenance pass for **agent-created skills**. It tracks how often each skill is viewed, used, and patched, moves long-unused skills through `active → stale → archived` states, and periodically spawns a short auxiliary-model review that proposes consolidations or patches drift. It exists so that skills created via the [self-improvement loop](/user-guide/features/skills#agent-managed-skills-skill_manage-tool) don't pile up forever. Every time the agent solves a novel problem and saves a skill, that skill lands in `~/.claway/skills/`. Without maintenance, you end up with dozens of narrow near-duplicates that pollute the catalog and waste tokens. By default (`prune_builtins: true`) the curator can archive **unused bundled built-in skills** (shipped with the repo) after `archive_after_days` of non-use, alongside the agent-created skills it primarily manages. Hub-installed skills (from [agentskills.io](https://agentskills.io)) are always off-limits. Set `curator.prune_builtins: false` to restore the old agent-created-only behavior, where bundled skills are never touched. The curator also **never auto-deletes** — the worst outcome is archival into `~/.claway/skills/.archive/`, which is recoverable. ## How it runs The curator is triggered by an inactivity check, not a cron daemon. On CLI session start, and on a recurring tick inside the gateway's cron-ticker thread, Claway checks whether: 1. Enough time has passed since the last curator run (`interval_hours`, default **7 days**), and 2. The agent has been idle long enough (`min_idle_hours`, default **2 hours**). If both are true, it spawns a background fork of `AIAgent` — the same pattern used by the memory/skill self-improvement nudges. The fork runs in its own prompt cache and never touches the active conversation. :::info First-run behavior On a brand-new install (or the first time a pre-curator install ticks after `claway update`), the curator **does not run immediately**. The first observation seeds `last_run_at` to "now" and defers the first real pass by one full `interval_hours`. This gives you a full interval to review your skill library, pin anything important, or opt out entirely before the curator ever touches it. If you want to see what the curator *would* do before it runs for real, run `claway curator run --dry-run` — it produces the same review report without mutating the library. ::: A run has two phases: 1. **Automatic transitions** (deterministic, no LLM). Skills unused for `stale_after_days` (30) become `stale`; skills unused for `archive_after_days` (90) are moved to `~/.claway/skills/.archive/`. This is the always-on pruning behavior — it runs whenever the curator is enabled, with no aux-model cost. 2. **LLM consolidation** (single aux-model pass, `max_iterations=8`) — **OFF by default**. When `curator.consolidate: true`, the forked agent surveys the agent-created skills, can read any of them with `skill_view`, and decides per-skill whether to keep, patch (via `skill_manage`), consolidate overlapping ones into class-level umbrellas, or archive via the terminal tool. Consolidation treats a skill as a full package: if a skill has `references/`, `templates/`, `scripts/`, `assets/`, or relative links to those paths, the curator must either keep it standalone, re-home the needed support files and rewrite paths, or archive the entire package unchanged — not flatten only `SKILL.md` into another skill's `references/` file. :::info Consolidation is opt-in By default the curator only **prunes** — the deterministic inactivity pass marks skills stale and archives long-unused ones. The opinionated LLM **consolidation** pass (umbrella-building, merging overlapping skills) is off by default because it costs aux-model tokens on every run and makes broad structural changes to your library. Turn it on with `curator.consolidate: true`, or run it once on demand with `claway curator run --consolidate`. ::: Pinned skills are off-limits to both the curator's auto-transitions and the agent's own `skill_manage` tool. See [Pinning a skill](#pinning-a-skill) below. ## Configuration All settings live in `config.yaml` under `curator:` (not `.env` — this isn't a secret). Defaults: ```yaml curator: enabled: true interval_hours: 168 # 7 days min_idle_hours: 2 stale_after_days: 30 archive_after_days: 90 consolidate: false # LLM umbrella-building pass — opt-in (prune-only by default) prune_builtins: true # archive unused bundled built-in skills too (hub skills always exempt) ``` To disable entirely, set `curator.enabled: false`. To keep the always-on pruning but opt into LLM consolidation, set `curator.consolidate: true`. ### Running the review on a cheaper aux model The curator's LLM review pass is a regular auxiliary task slot — `auxiliary.curator` — alongside Vision, Compression, Session Search, etc. "Auto" means "use my main chat model"; override the slot to pin a specific provider + model for the review pass instead. **Easiest — `claway model`:** ```bash claway model # → "Auxiliary models — side-task routing" # → pick "Curator" → pick provider → pick model ``` The same picker is available in the web dashboard under the **Models** tab. **Direct config.yaml (equivalent):** ```yaml auxiliary: curator: provider: openrouter model: google/gemini-3-flash-preview timeout: 600 # generous — reviews can take several minutes ``` Leaving `provider: auto` (the default) routes the review pass through whatever your main chat model is, matching the behavior of every other auxiliary task. :::note Legacy config Earlier releases used a one-off `curator.auxiliary.{provider,model}` block. That path still works but emits a deprecation log line — please migrate to `auxiliary.curator` above so the curator shares the same plumbing (`claway model`, dashboard Models tab, `base_url`, `api_key`, `timeout`, `extra_body`) as every other aux task. ::: ## CLI ```bash claway curator status # last run, counts, pinned list, LRU top 5 claway curator run # trigger a run now (blocks until done). Prune-only unless curator.consolidate: true claway curator run --consolidate # force the LLM consolidation pass on for this run, overriding the config default claway curator run --background # fire-and-forget: start the run in a background thread claway curator run --dry-run # preview only — report without any mutations claway curator backup # take a manual snapshot of ~/.claway/skills/ claway curator rollback # restore from the newest snapshot claway curator rollback --list # list available snapshots claway curator rollback --id <ts> # restore a specific snapshot claway curator rollback -y # skip the confirmation prompt claway curator pause # stop runs until resumed claway curator resume claway curator pin <skill> # never auto-transition this skill claway curator unpin <skill> claway curator restore <skill> # move an archived skill back to active claway curator list-archived # list skills currently in ~/.claway/skills/.archive/ claway curator archive <skill> # manually archive a single skill now claway curator prune [--days N] # bulk-archive agent-created skills idle >= N days (default 90) ``` ## Backups and rollback Before every real curator pass, Claway takes a tar.gz snapshot of `~/.claway/skills/` at `~/.claway/skills/.curator_backups/<utc-iso>/skills.tar.gz`. If a pass archives or consolidates something you didn't want touched, you can undo the whole run with one command: ```bash claway curator rollback # restore newest snapshot (with confirmation) claway curator rollback -y # skip the prompt claway curator rollback --list # see all snapshots with reason + size ``` The rollback itself is reversible: before replacing the skills tree, Claway takes another snapshot tagged `pre-rollback to <target-id>`, so a mistaken rollback can be undone by rolling forward to that one with `--id`. You can also take manual snapshots at any time with `claway curator backup --reason "before-refactor"`. The `--reason` string lands in the snapshot's `manifest.json` and is shown in `--list`. Snapshots are pruned to `curator.backup.keep` (default 5) to keep disk usage bounded: ```yaml curator: backup: enabled: true keep: 5 ``` Set `curator.backup.enabled: false` to disable automatic snapshotting. The manual `claway curator backup` command still works when backups are disabled only if you set `enabled: true` first — the flag gates both paths symmetrically so there's no way to accidentally skip the pre-run snapshot on mutating runs. `claway curator status` also lists the five least-recently-used skills — a quick way to see what's likely to become stale next. The same subcommands are available as the `/curator` slash command inside a running session (CLI or gateway platforms). ## What "agent-created" means The curator only manages skills explicitly marked as **agent-created** in `~/.claway/skills/.usage.json`. A skill qualifies when ALL of the following are true: 1. Its name is **not** in `~/.claway/skills/.bundled_manifest` (bundled skills shipped with the repo). 2. Its name is **not** in `~/.claway/skills/.hub/lock.json` (hub-installed skills). 3. Its `.usage.json` entry has `"created_by": "agent"` or `"agent_created": true`. Currently, only the **background self-improvement review fork** sets this marker — when it creates a new umbrella skill during its periodic review pass (~every 10 agent turns). The background fork runs with a write origin of `"background_review"` (via `tools/skill_provenance.py`), which is the only path that triggers the `mark_agent_created()` call in `skill_manage`. Skills the foreground agent creates via `skill_manage(action="create")` during a conversation are **not** marked as agent-created — they are considered user-directed and the curator intentionally leaves them alone. :::warning Your hand-written skills are NOT curated If you manually created a `SKILL.md` or pointed Claway at an external skill directory, that skill will have a `.usage.json` entry with `created_by: null` (or the field absent). The curator will not touch it. The same applies to skills the foreground agent created at your request. **To see which skills the curator actually manages**, run `claway curator status`. If the agent-created count is 0, no skills are currently in the curator's jurisdiction — the LLM review pass is skipped and the report will show `Model: (not resolved) via (not resolved)` with `Duration: 0s`. ::: Skills that ARE agent-created follow the full lifecycle: - `active` → (30d unused) `stale` → (90d unused) `archived` - Pinned skills bypass all auto-transitions - Archives are recoverable via `claway curator restore <name>` If you want to protect a specific skill from ever being touched — for example a hand-authored skill you rely on — use `claway curator pin <name>`. See the next section. ## Pinning a skill Pinning protects a skill from deletion — both the curator's automated archive passes and the agent's `skill_manage(action="delete")` tool call. Once a skill is pinned: - The **curator** skips it during auto-transitions (`active → stale → archived`), and its LLM review pass is instructed to leave it alone. - The **agent's `skill_manage` tool** refuses `delete` on it, pointing the user at `claway curator unpin <name>`. Patches and edits still go through, so the agent can improve a pinned skill's content as pitfalls come up without a pin/unpin/re-pin dance. Pin and unpin with: ```bash claway curator pin <skill> claway curator unpin <skill> ``` The flag is stored as `"pinned": true` on the skill's entry in `~/.claway/skills/.usage.json`, so it survives across sessions. Only **agent-created** skills can be pinned — `claway curator pin` refuses on bundled and hub-installed skills with an explanatory message if you try. Hub-installed skills are never subject to curator mutation. Bundled built-in skills are only touched when `curator.prune_builtins: true` (the default), and even then only archived after `archive_after_days` of non-use — never patched, consolidated, or deleted. Set `curator.prune_builtins: false` to exempt bundled skills entirely. A small set of **protected built-ins** is hardcoded as never-archivable and never-consolidatable, regardless of `curator.prune_builtins`, pin state, or LLM judgment. These back load-bearing UX — for example, `plan` powers the `/plan` slash-command flow — so silently archiving one would turn its slash command into an "Unknown command" error with no signal to you. Protected built-ins are filtered out of the curator's candidate list entirely, so the consolidation pass never sees them. If you want a stronger guarantee than "no deletion" — for instance, freezing a skill's content entirely while the agent still reads it — edit `~/.claway/skills/<name>/SKILL.md` directly with your editor. The pin guards tool-driven deletion, not your own filesystem access. ## Usage telemetry The curator maintains a sidecar at `~/.claway/skills/.usage.json` with one entry per skill: ```json { "my-skill": { "use_count": 12, "view_count": 34, "last_used_at": "2026-04-24T18:12:03Z", "last_viewed_at": "2026-04-23T09:44:17Z", "patch_count": 3, "last_patched_at": "2026-04-20T22:01:55Z", "created_at": "2026-03-01T14:20:00Z", "state": "active", "pinned": false, "archived_at": null } } ``` Counters increment when: - `view_count`: the agent calls `skill_view` on the skill. - `use_count`: the skill is loaded into a conversation's prompt. - `patch_count`: `skill_manage patch/edit/write_file/remove_file` runs on the skill. Bundled and hub-installed skills are explicitly excluded from telemetry writes. ## Per-run reports Every curator run writes a timestamped directory under `~/.claway/logs/curator/`: ``` ~/.claway/logs/curator/ └── 20260429-111512/ ├── run.json # machine-readable: full fidelity, stats, LLM output └── REPORT.md # human-readable summary ``` `REPORT.md` is a quick way to see what a given run did — which skills transitioned, what the LLM reviewer said, which skills it patched. Good for auditing without having to grep `agent.log`. :::note No candidates? Report shows `(not resolved)` When the curator has **no agent-created skills** to review, the LLM review pass is skipped entirely. The report header will show `Model: (not resolved) via (not resolved)` with `Duration: 0s` — this does **not** indicate a configuration error or model resolution failure. It simply means there were no candidates, so no model was ever invoked. The auto-transition phase still runs and reports its counts normally. ::: ### Rename map in the summary If a run consolidated multiple skills under an umbrella (or merged near-duplicates), the user-visible summary printed at the end of the run includes an explicit rename map showing every `old-name → new-name` pair the curator applied. This is in addition to per-skill transition lines, so when a wave of renames lands you can spot them at a glance without diffing the JSON report. The hint also surfaces under `claway curator pin` so you can pin the umbrella name immediately if you want to lock the new label in. ## Restoring an archived skill If the curator archived something you still want: ```bash claway curator restore <skill-name> ``` This moves the skill back from `~/.claway/skills/.archive/` to the active tree and resets its state to `active`. The restore refuses if a bundled or hub-installed skill has since been installed under the same name (would shadow upstream). ## Disabling per environment The curator is on by default. To turn it off: - **For one profile only:** edit `~/.claway/config.yaml` (or the active profile's config) and set `curator.enabled: false`. - **For just one run:** `claway curator pause` — the pause persists across sessions; use `resume` to re-enable. The curator also refuses to run if `min_idle_hours` hasn't elapsed, so on an active dev machine it naturally only runs during quiet stretches. ## See also - [Skills System](/user-guide/features/skills) — how skills work in general and the self-improvement loop that creates them - [Memory](/user-guide/features/memory) — a parallel background review that maintains long-term memory - [Bundled Skills Catalog](/reference/skills-catalog) --- <!-- source: website/docs/user-guide/features/memory.md --> # Persistent Memory # Persistent Memory Claway Agent has bounded, curated memory that persists across sessions. This lets it remember your preferences, your projects, your environment, and things it has learned. ## How It Works Two files make up the agent's memory: | File | Purpose | Char Limit | |------|---------|------------| | **MEMORY.md** | Agent's personal notes — environment facts, conventions, things learned | 2,200 chars (~800 tokens) | | **USER.md** | User profile — your preferences, communication style, expectations | 1,375 chars (~500 tokens) | Both are stored in `~/.claway/memories/` and are injected into the system prompt as a frozen snapshot at session start. The agent manages its own memory via the `memory` tool — it can add, replace, or remove entries. :::info Character limits keep memory focused. Memory does **not** auto-compact: when a write would exceed the limit, the `memory` tool returns an error instead of silently dropping entries. The agent then makes room itself — consolidating or removing entries in the same turn before retrying (see [What Happens When Memory is Full](#what-happens-when-memory-is-full)). Note that `replace` is also bound by the limit: swapping an entry for a longer one can still overflow, so the new content must be shortened (or another entry removed) to fit. ::: ## How Memory Appears in the System Prompt At the start of every session, memory entries are loaded from disk and rendered into the system prompt as a frozen block: ``` ══════════════════════════════════════════════ MEMORY (your personal notes) [67% — 1,474/2,200 chars] ══════════════════════════════════════════════ User's project is a Rust web service at ~/code/myapi using Axum + SQLx § This machine runs Ubuntu 22.04, has Docker and Podman installed § User prefers concise responses, dislikes verbose explanations ``` The format includes: - A header showing which store (MEMORY or USER PROFILE) - Usage percentage and character counts so the agent knows capacity - Individual entries separated by `§` (section sign) delimiters - Entries can be multiline **Frozen snapshot pattern:** The system prompt injection is captured once at session start and never changes mid-session. This is intentional — it preserves the LLM's prefix cache for performance. When the agent adds/removes memory entries during a session, the changes are persisted to disk immediately but won't appear in the system prompt until the next session starts. Tool responses always show the live state. ## Memory Tool Actions The agent uses the `memory` tool with these actions: - **add** — Add a new memory entry - **replace** — Replace an existing entry with updated content (uses substring matching via `old_text`) - **remove** — Remove an entry that's no longer relevant (uses substring matching via `old_text`) There is no `read` action — memory content is automatically injected into the system prompt at session start. The agent sees its memories as part of its conversation context. ### Substring Matching The `replace` and `remove` actions use short unique substring matching — you don't need the full entry text. The `old_text` parameter just needs to be a unique substring that identifies exactly one entry: ```python # If memory contains "User prefers dark mode in all editors" memory(action="replace", target="memory", old_text="dark mode", content="User prefers light mode in VS Code, dark mode in terminal") ``` If the substring matches multiple entries, an error is returned asking for a more specific match. ## Two Targets Explained ### `memory` — Agent's Personal Notes For information the agent needs to remember about the environment, workflows, and lessons learned: - Environment facts (OS, tools, project structure) - Project conventions and configuration - Tool quirks and workarounds discovered - Completed task diary entries - Skills and techniques that worked ### `user` — User Profile For information about the user's identity, preferences, and communication style: - Name, role, timezone - Communication preferences (concise vs detailed, format preferences) - Pet peeves and things to avoid - Workflow habits - Technical skill level ## What to Save vs Skip ### Save These (Proactively) The agent saves automatically — you don't need to ask. It saves when it learns: - **User preferences:** "I prefer TypeScript over JavaScript" → save to `user` - **Environment facts:** "This server runs Debian 12 with PostgreSQL 16" → save to `memory` - **Corrections:** "Don't use `sudo` for Docker commands, user is in docker group" → save to `memory` - **Conventions:** "Project uses tabs, 120-char line width, Google-style docstrings" → save to `memory` - **Completed work:** "Migrated database from MySQL to PostgreSQL on 2026-01-15" → save to `memory` - **Explicit requests:** "Remember that my API key rotation happens monthly" → save to `memory` ### Skip These - **Trivial/obvious info:** "User asked about Python" — too vague to be useful - **Easily re-discovered facts:** "Python 3.12 supports f-string nesting" — can web search this - **Raw data dumps:** Large code blocks, log files, data tables — too big for memory - **Session-specific ephemera:** Temporary file paths, one-off debugging context - **Information already in context files:** SOUL.md and AGENTS.md content ## Capacity Management Memory has strict character limits to keep system prompts bounded: | Store | Limit | Typical entries | |-------|-------|----------------| | memory | 2,200 chars | 8-15 entries | | user | 1,375 chars | 5-10 entries | ### What Happens When Memory is Full When you try to add an entry that would exceed the limit, the tool returns an error: ```json { "success": false, "error": "Memory at 2,100/2,200 chars. Adding this entry (250 chars) would exceed the limit. Consolidate now: use 'replace' to merge overlapping entries into shorter ones or 'remove' stale or less important entries (see current_entries below), then retry this add — all in this turn.", "current_entries": ["..."], "usage": "2,100/2,200" } ``` The agent should then: 1. Read the current entries (shown in the error response) 2. Identify entries that can be removed or consolidated 3. Use `replace` to merge related entries into shorter versions 4. Then `add` the new entry **Best practice:** When memory is above 80% capacity (visible in the system prompt header), consolidate entries before adding new ones. For example, merge three separate "project uses X" entries into one comprehensive project description entry. ### Practical Examples of Good Memory Entries **Compact, information-dense entries work best:** ``` # Good: Packs multiple related facts User runs macOS 14 Sonoma, uses Homebrew, has Docker Desktop and Podman. Shell: zsh with oh-my-zsh. Editor: VS Code with Vim keybindings. # Good: Specific, actionable convention Project ~/code/api uses Go 1.22, sqlc for DB queries, chi router. Run tests with 'make test'. CI via GitHub Actions. # Good: Lesson learned with context The staging server (10.0.1.50) needs SSH port 2222, not 22. Key is at ~/.ssh/staging_ed25519. # Bad: Too vague User has a project. # Bad: Too verbose On January 5th, 2026, the user asked me to look at their project which is located at ~/code/api. I discovered it uses Go version 1.22 and... ``` ## Duplicate Prevention The memory system automatically rejects exact duplicate entries. If you try to add content that already exists, it returns success with a "no duplicate added" message. ## Security Scanning Memory entries are scanned for injection and exfiltration patterns before being accepted, since they're injected into the system prompt. Content matching threat patterns (prompt injection, credential exfiltration, SSH backdoors) or containing invisible Unicode characters is blocked. ## Session Search Beyond MEMORY.md and USER.md, the agent can search its past conversations using the `session_search` tool: - All CLI and messaging sessions are stored in SQLite (`~/.claway/state.db`) with FTS5 full-text search - Search queries return actual messages from the DB — no LLM summarization, no truncation - The agent can find things it discussed weeks ago, even if they're not in its active memory - The agent can also scroll forward/backward inside any session it finds ```bash claway sessions list # Browse past sessions ``` See [Session Search Tool](/user-guide/sessions#session-search-tool) for the three calling shapes (discovery / scroll / browse) and the response format. ### session_search vs memory | Feature | Persistent Memory | Session Search | |---------|------------------|----------------| | **Capacity** | ~1,300 tokens total | Unlimited (all sessions) | | **Speed** | Instant (in system prompt) | ~20ms FTS5 query, ~1ms scroll | | **Cost** | Token cost in every prompt | Free — no LLM calls | | **Use case** | Key facts always available | Finding specific past conversations | | **Management** | Manually curated by agent | Automatic — all sessions stored | | **Token cost** | Fixed per session (~1,300 tokens) | On-demand (searched when needed) | **Memory** is for critical facts that should always be in context. **Session search** is for "did we discuss X last week?" queries where the agent needs to recall specifics from past conversations. ## Configuration ```yaml # In ~/.claway/config.yaml memory: memory_enabled: true user_profile_enabled: true memory_char_limit: 2200 # ~800 tokens user_char_limit: 1375 # ~500 tokens write_approval: false # false = write freely (default) | true = require approval ``` ## Controlling memory writes (`write_approval`) By default the agent saves memory freely — including from the background self-improvement review that runs after a turn. If you'd rather approve saves first, set `memory.write_approval: true`. It's a simple on/off gate applied to **both** foreground turns and the background review: | `write_approval` | Behaviour | |------------------|-----------| | `false` (default) | Write freely — the gate is off (the pre-gate behaviour). | | `true` | Require approval before anything is saved. In the interactive CLI, foreground writes prompt you inline (entries are small enough to read in full). Everywhere else — messaging platforms, scripts, and the background self-improvement review — writes are **staged** for review with `/memory pending`. | > To turn memory off entirely (not just gate it), set `memory_enabled: false`. Review staged writes from the CLI or any messaging platform: ``` /memory pending # list staged memory writes (auto ones tagged [auto]) /memory approve <id> # apply one (or 'all') /memory reject <id> # drop one (or 'all') /memory approval on # turn the gate on (or 'off') and persist it ``` This is the answer to "the agent saved a wrong assumption about me": set `write_approval: true`, and every save — especially the unprompted background ones — waits for your yes/no before it ever enters your profile. ## Background review notifications (`display.memory_notifications`) After a turn, the background self-improvement review may quietly save a memory or update a skill. This is Claway's consent-aware learning loop: repeated corrections and durable workflow lessons become compact memory entries or procedural skills, while `write_approval` can stage those writes for review before they affect future sessions. By default it surfaces a short `💾 Memory updated` line in chat so you know it happened. Control how chatty that is: ```yaml display: memory_notifications: on # off | on (default) | verbose ``` | Value | Behaviour | |-------|-----------| | `off` | No chat notification. The review still runs and still writes — you just don't see a line for it. | | `on` (default) | Generic line, e.g. `💾 Memory updated`, `💾 Skill 'foo' patched`. | | `verbose` | Includes a compact preview of what changed, e.g. `💾 Memory ➕ User prefers terse replies` or a `"old" → "new"` skill diff snippet. | > This only governs the **gateway** chat notification. The review itself, and > writes to your memory/skill stores, are unaffected by this setting. Set it > per-platform via `display.platforms.<platform>.memory_notifications`. ## Running the review on a cheaper model (`auxiliary.background_review`) The review runs on your **main chat model** by default, replaying the conversation — which is already warm in the prompt cache, so it's cheap cache reads. On an expensive main model you can run the review on a cheaper model instead: ```yaml auxiliary: background_review: provider: openrouter model: google/gemini-3-flash-preview # auto (default) = main chat model ``` When you point it at a model **different** from your main one, the review runs there for substantially lower cost (~3–5× in benchmarks). Because a different model can't reuse your main model's prompt cache anyway, the fork automatically replays a compact **digest** of the conversation (recent turns verbatim + a summary of older ones) rather than the full transcript — minimizing what it writes to the new cache. Capture holds: in testing, memory capture was identical and skill capture near-identical to the main-model review. Leave it at `auto` (or set it to your main model) and nothing changes — the review keeps running on the main model with the full warm-cache replay. ## Controlling skill writes (`skills.write_approval`) Skills use the same on/off gate, but the review UX differs because a `SKILL.md` is far too large to read in a chat bubble: ```yaml skills: write_approval: false # false = write freely (default) | true = require approval ``` When `write_approval: true`, skill writes (create / edit / patch / write_file / delete) always **stage** regardless of origin. You review the one-line gist inline, but the full diff stays out-of-band: ``` /skills pending # list staged skill writes + a one-line gist each /skills diff <id> # full unified diff (best viewed in CLI or dashboard) /skills approve <id> # apply it (or 'all') /skills reject <id> # drop it (or 'all') /skills approval on # turn the gate on (or 'off') and persist it ``` On a messaging platform, approve a skill from its gist + metadata, or open `/skills diff` on the CLI / dashboard / the staged file under `~/.claway/pending/skills/<id>.json` when you want to read the whole change. Full details in [Gating agent skill writes](/user-guide/features/skills#gating-agent-skill-writes-skillswrite_approval). ## External Memory Providers For deeper, persistent memory that goes beyond MEMORY.md and USER.md, Claway ships with 8 external memory provider plugins — including Honcho, OpenViking, Mem0, Hindsight, Holographic, RetainDB, ByteRover, and Supermemory. External providers run **alongside** built-in memory (never replacing it) and add capabilities like knowledge graphs, semantic search, automatic fact extraction, and cross-session user modeling. ```bash claway memory setup # pick a provider and configure it claway memory status # check what's active ``` See the [Memory Providers](./memory-providers.md) guide for full details on each provider, setup instructions, and comparison. --- <!-- source: website/docs/user-guide/features/memory-providers.md --> # Memory Providers # Memory Providers Claway Agent ships with 8 external memory provider plugins that give the agent persistent, cross-session knowledge beyond the built-in MEMORY.md and USER.md. Only **one** external provider can be active at a time — the built-in memory is always active alongside it. ## Quick Start ```bash claway memory setup # interactive picker + configuration claway memory status # check what's active claway memory off # disable external provider ``` You can also select the active memory provider via `claway plugins` → Provider Plugins → Memory Provider. Or set manually in `~/.claway/config.yaml`: ```yaml memory: provider: openviking # or honcho, mem0, hindsight, holographic, retaindb, byterover, supermemory ``` ## How It Works When a memory provider is active, Claway automatically: 1. **Injects provider context** into the system prompt (what the provider knows) 2. **Prefetches relevant memories** before each turn (background, non-blocking) 3. **Syncs conversation turns** to the provider after each response 4. **Extracts memories on session end** (for providers that support it) 5. **Mirrors built-in memory writes** to the external provider 6. **Adds provider-specific tools** so the agent can search, store, and manage memories The built-in memory (MEMORY.md / USER.md) continues to work exactly as before. The external provider is additive. ## Available Providers ### Honcho AI-native cross-session user modeling with dialectic reasoning, session-scoped context injection, semantic search, and persistent conclusions. Base context now includes the session summary alongside user representation and peer cards, giving the agent awareness of what has already been discussed. | | | |---|---| | **Best for** | Multi-agent systems with cross-session context, user-agent alignment | | **Requires** | `pip install honcho-ai` + [API key](https://app.honcho.dev) or self-hosted instance | | **Data storage** | Honcho Cloud or self-hosted | | **Cost** | Honcho pricing (cloud) / free (self-hosted) | **Tools (5):** `honcho_profile` (read/update peer card), `honcho_search` (semantic search), `honcho_context` (session context — summary, representation, card, messages), `honcho_reasoning` (LLM-synthesized), `honcho_conclude` (create/delete conclusions) **Architecture:** Two-layer context injection — a base layer (session summary + representation + peer card, refreshed on `contextCadence`) plus a dialectic supplement (LLM reasoning, refreshed on `dialecticCadence`). The dialectic automatically selects cold-start prompts (general user facts) vs. warm prompts (session-scoped context) based on whether base context exists. **Three orthogonal config knobs** control cost and depth independently: - `contextCadence` — how often the base layer refreshes (API call frequency) - `dialecticCadence` — how often the dialectic LLM fires (LLM call frequency) - `dialecticDepth` — how many `.chat()` passes per dialectic invocation (1–3, depth of reasoning) The auto-injected dialectic also scales its reasoning level by query length (longer query → deeper reasoning, capped at `reasoningLevelCap`); see [Query-Adaptive Reasoning Level](./honcho.md#query-adaptive-reasoning-level). **Setup Wizard:** ```bash claway memory setup # select "honcho" — runs the Honcho-specific post-setup ``` The legacy `claway honcho setup` command still works (it now redirects to `claway memory setup`), but is only registered after Honcho is selected as the active memory provider. **Config:** `$CLAWAY_HOME/honcho.json` (profile-local) or `~/.honcho/config.json` (global). Resolution order: `$CLAWAY_HOME/honcho.json` > `~/.claway/honcho.json` > `~/.honcho/config.json`. See the config reference and the [Honcho integration guide](https://docs.honcho.dev/v3/guides/integrations/claway). <details> <summary>Full config reference</summary> | Key | Default | Description | |-----|---------|-------------| | `apiKey` | -- | API key from [app.honcho.dev](https://app.honcho.dev) | | `baseUrl` | -- | Base URL for self-hosted Honcho | | `peerName` | -- | User peer identity | | `aiPeer` | host key | AI peer identity (one per profile) | | `workspace` | host key | Shared workspace ID | | `contextTokens` | `null` (uncapped) | Token budget for auto-injected context per turn. Truncates at word boundaries | | `contextCadence` | `1` | Minimum turns between `context()` API calls (base layer refresh) | | `dialecticCadence` | `2` | Minimum turns between `peer.chat()` LLM calls. Recommended 1–5. Only applies to `hybrid`/`context` modes | | `dialecticDepth` | `1` | Number of `.chat()` passes per dialectic invocation. Clamped 1–3. Pass 0: cold/warm prompt, pass 1: self-audit, pass 2: reconciliation | | `dialecticDepthLevels` | `null` | Optional array of reasoning levels per pass, e.g. `["minimal", "low", "medium"]`. Overrides proportional defaults | | `dialecticReasoningLevel` | `'low'` | Base reasoning level: `minimal`, `low`, `medium`, `high`, `max` | | `dialecticDynamic` | `true` | When `true`, model can override reasoning level per-call via tool param | | `dialecticMaxChars` | `600` | Max chars of dialectic result injected into system prompt | | `recallMode` | `'hybrid'` | `hybrid` (auto-inject + tools), `context` (inject only), `tools` (tools only) | | `writeFrequency` | `'async'` | When to flush messages: `async` (background thread), `turn` (sync), `session` (batch on end), or integer N | | `saveMessages` | `true` | Whether to persist messages to Honcho API | | `observationMode` | `'directional'` | `directional` (all on) or `unified` (shared pool). Override with `observation` object | | `messageMaxChars` | `25000` | Max chars per message (chunked if exceeded) | | `dialecticMaxInputChars` | `10000` | Max chars for dialectic query input to `peer.chat()` | | `sessionStrategy` | `'per-directory'` | `per-directory`, `per-repo`, `per-session`, `global` | | `pinUserPeer` | `false` | Gateway only. When `true`, every non-agent gateway user collapses to `peerName`; the pin overrides all aliases | | `userPeerAliases` | `{}` | Gateway only. Maps runtime IDs to peers (`{"7654321": "alice"}`). Many-to-one | | `runtimePeerPrefix` | `""` | Gateway only. Namespaces unknown runtime IDs (`telegram_7654321`) when no alias matches | </details> <details> <summary>Minimal honcho.json (cloud)</summary> ```json { "apiKey": "your-key-from-app.honcho.dev", "hosts": { "claway": { "enabled": true, "aiPeer": "claway", "peerName": "your-name", "workspace": "claway" } } } ``` </details> <details> <summary>Minimal honcho.json (self-hosted)</summary> ```json { "baseUrl": "http://localhost:8000", "hosts": { "claway": { "enabled": true, "aiPeer": "claway", "peerName": "your-name", "workspace": "claway" } } } ``` </details> :::tip Migrating from `claway honcho` If you previously used `claway honcho setup`, your config and all server-side data are intact. Just re-enable through the setup wizard again or manually set `memory.provider: honcho` to reactivate via the new system. ::: **Multi-peer setup:** Honcho models conversations as peers exchanging messages — one user peer plus one AI peer per Claway profile, all sharing a workspace. The workspace is the shared environment: the user peer is global across profiles, each AI peer is its own identity. Every AI peer builds an independent representation / card from its own observations, so a `coder` profile stays code-oriented while a `writer` profile stays editorial against the same user. The mapping: | Concept | What it is | |---------|-----------| | **Workspace** | Shared environment. All Claway profiles under one workspace see the same user identity. | | **User peer** (`peerName`) | The human. Shared across profiles in the workspace. | | **AI peer** (`aiPeer`) | One per Claway profile. Host key `claway` → default; `claway.<profile>` for others. | | **Observation** | Per-peer toggles controlling what Honcho models from whose messages. `directional` (default, all four on) or `unified` (single-observer pool). | ### New profile, fresh Honcho peer ```bash claway profile create coder --clone ``` `--clone` creates a `claway.coder` host block in `honcho.json` with `aiPeer: "coder"`, shared `workspace`, inherited `peerName`, `recallMode`, `writeFrequency`, `observation`, etc. The AI peer is eagerly created in Honcho so it exists before the first message. ### Existing profiles, backfill Honcho peers ```bash claway honcho sync ``` Scans every Claway profile, creates host blocks for any profile without one, inherits settings from the default `claway` block, and creates the new AI peers eagerly. Idempotent — skips profiles that already have a host block. ### Per-profile observation Each host block can override the observation config independently. Example: a code-focused profile where the AI peer observes the user but doesn't self-model: ```json "claway.coder": { "aiPeer": "coder", "observation": { "user": { "observeMe": true, "observeOthers": true }, "ai": { "observeMe": false, "observeOthers": true } } } ``` **Observation toggles (one set per peer):** | Toggle | Effect | |--------|--------| | `observeMe` | Honcho builds a representation of this peer from its own messages | | `observeOthers` | This peer observes the other peer's messages (feeds cross-peer reasoning) | Presets via `observationMode`: - **`"directional"`** (default) — all four flags on. Full mutual observation; enables cross-peer dialectic. - **`"unified"`** — user `observeMe: true`, AI `observeOthers: true`, rest false. Single-observer pool; AI models the user but not itself, user peer only self-models. Server-side toggles set via the [Honcho dashboard](https://app.honcho.dev) win over local defaults — synced back at session init. See the [Honcho page](./honcho.md#observation-directional-vs-unified) for the full observation reference. ### Gateway identity mapping The peer model above covers CLI, TUI, and desktop sessions, where every conversation resolves to `peerName`. The gateway adds a second axis: users arrive with platform-native runtime IDs (Telegram UID, Discord snowflake, Slack user), and three keys decide which peer each ID resolves to. | Key | Effect | |-----|--------| | `pinUserPeer: true` | Every non-agent gateway user collapses to `peerName`. The pin is checked first, so it overrides all aliases — pick it only when no user-side identity needs its own peer | | `userPeerAliases` | Maps specific runtime IDs to peers (`{"7654321": "alice"}`). The home for routing distinct identities — including agents that each carry their own peer | | `runtimePeerPrefix` | Namespaces any unmapped runtime ID (`telegram_7654321`) so platforms with same-shaped IDs don't collide | Off-gateway these keys do nothing. `claway memory setup` only prompts for them when it detects a connected gateway platform. See the [Honcho page](./honcho.md#gateway-identity-mapping) for the resolver ladder and the setup flow. <details> <summary>Full honcho.json example (multi-profile)</summary> ```json { "apiKey": "your-key", "workspace": "claway", "peerName": "eri", "hosts": { "claway": { "enabled": true, "aiPeer": "claway", "workspace": "claway", "peerName": "eri", "recallMode": "hybrid", "writeFrequency": "async", "sessionStrategy": "per-directory", "observation": { "user": { "observeMe": true, "observeOthers": true }, "ai": { "observeMe": true, "observeOthers": true } }, "dialecticReasoningLevel": "low", "dialecticDynamic": true, "dialecticCadence": 2, "dialecticDepth": 1, "dialecticMaxChars": 600, "contextCadence": 1, "messageMaxChars": 25000, "saveMessages": true }, "claway.coder": { "enabled": true, "aiPeer": "coder", "workspace": "claway", "peerName": "eri", "recallMode": "tools", "observation": { "user": { "observeMe": true, "observeOthers": false }, "ai": { "observeMe": true, "observeOthers": true } } }, "claway.writer": { "enabled": true, "aiPeer": "writer", "workspace": "claway", "peerName": "eri" } }, "sessions": { "/home/user/myproject": "myproject-main" } } ``` </details> See the config reference and [Honcho integration guide](https://docs.honcho.dev/v3/guides/integrations/claway). --- ### OpenViking Context database by Volcengine (ByteDance) with filesystem-style knowledge hierarchy, tiered retrieval, and automatic memory extraction into 6 categories. | | | |---|---| | **Best for** | Self-hosted knowledge management with structured browsing | | **Requires** | `pip install openviking` + running server | | **Data storage** | Self-hosted (local or cloud) | | **Cost** | Free (open-source, AGPL-3.0) | **Tools:** `viking_search` (semantic search), `viking_read` (tiered: abstract/overview/full), `viking_browse` (filesystem navigation), `viking_remember` (store facts), `viking_add_resource` (ingest URLs/docs) **Setup:** ```bash # Start the OpenViking server first pip install openviking openviking-server # Then configure Claway claway memory setup # select "openviking" # Or manually: claway config set memory.provider openviking echo "OPENVIKING_ENDPOINT=http://localhost:1933" >> ~/.claway/.env # Authenticated servers should use a user/admin API key: echo "OPENVIKING_API_KEY=..." >> ~/.claway/.env ``` **Key features:** - Tiered context loading: L0 (~100 tokens) → L1 (~2k) → L2 (full) - Automatic memory extraction on session commit (profile, preferences, entities, events, cases, patterns) - `viking://` URI scheme for hierarchical knowledge browsing `OPENVIKING_ACCOUNT` and `OPENVIKING_USER` are used for local/trusted mode. `OPENVIKING_AGENT` is Claway's peer ID in OpenViking for peer-scoped memories. --- ### Mem0 Server-side LLM fact extraction with semantic search, reranking, and automatic deduplication. Supports both Mem0 Platform (cloud) and OSS (self-hosted) modes. | | | |---|---| | **Best for** | Hands-off memory management — Mem0 handles extraction automatically | | **Requires** | `pip install mem0ai` + API key (platform) or LLM/vector store (OSS) | | **Data storage** | Mem0 Cloud (platform) or self-hosted (OSS) | | **Cost** | Mem0 pricing (platform) / free (OSS) | **Tools (5):** `mem0_list` (list all memories, paginated), `mem0_search` (semantic search with reranking in platform mode), `mem0_add` (store verbatim facts), `mem0_update` (update by ID), `mem0_delete` (delete by ID) **Setup (Platform):** ```bash claway memory setup # select "mem0" → "Platform" # Or manually: claway config set memory.provider mem0 echo "MEM0_API_KEY=your-key" >> ~/.claway/.env ``` **Setup (OSS):** ```bash claway memory setup # select "mem0" → "Open Source (self-hosted)" # Or via flags: claway memory setup mem0 --mode oss --oss-llm openai --oss-llm-key sk-... --oss-vector qdrant ``` Preview without writing files: ```bash claway memory setup mem0 --mode oss --oss-llm-key sk-... --dry-run ``` **Config:** `$CLAWAY_HOME/mem0.json` (behavioral settings). Only the secret `MEM0_API_KEY` belongs in `~/.claway/.env`. | Key | Default | Description | |-----|---------|-------------| | `mode` | `platform` | `platform` (Mem0 Cloud) or `oss` (self-hosted) | | `user_id` | `claway-user` | User identifier | | `agent_id` | `claway` | Agent identifier | | `rerank` | `true` | Rerank search results for relevance (platform mode only) | **OSS supported providers:** | Component | Providers | |-----------|-----------| | LLM | openai, ollama | | Embedder | openai, ollama | | Vector Store | qdrant (local/server), pgvector | **Switching modes:** Re-run `claway memory setup mem0 --mode <platform|oss>` or edit `mem0.json` directly. --- ### Hindsight Long-term memory with knowledge graph, entity resolution, and multi-strategy retrieval. The `hindsight_reflect` tool provides cross-memory synthesis that no other provider offers. Automatically retains full conversation turns (including tool calls) with session-level document tracking. | | | |---|---| | **Best for** | Knowledge graph-based recall with entity relationships | | **Requires** | Cloud: API key from [ui.hindsight.vectorize.io](https://ui.hindsight.vectorize.io). Local: LLM API key (OpenAI, Groq, OpenRouter, etc.) | | **Data storage** | Hindsight Cloud or local embedded PostgreSQL | | **Cost** | Hindsight pricing (cloud) or free (local) | **Tools:** `hindsight_retain` (store with entity extraction), `hindsight_recall` (multi-strategy search), `hindsight_reflect` (cross-memory synthesis) **Setup:** ```bash claway memory setup # select "hindsight" # Or manually: claway config set memory.provider hindsight echo "HINDSIGHT_API_KEY=your-key" >> ~/.claway/.env ``` The setup wizard installs dependencies automatically and only installs what's needed for the selected mode (`hindsight-client` for cloud, `hindsight-all` for local). Requires `hindsight-client >= 0.4.22` (auto-upgraded on session start if outdated). **Local mode UI:** `hindsight-embed -p claway ui start` **Config:** `$CLAWAY_HOME/hindsight/config.json` | Key | Default | Description | |-----|---------|-------------| | `mode` | `cloud` | `cloud` or `local` | | `bank_id` | `claway` | Memory bank identifier | | `recall_budget` | `mid` | Recall thoroughness: `low` / `mid` / `high` | | `memory_mode` | `hybrid` | `hybrid` (context + tools), `context` (auto-inject only), `tools` (tools only) | | `auto_retain` | `true` | Automatically retain conversation turns | | `auto_recall` | `true` | Automatically recall memories before each turn | | `retain_async` | `true` | Process retain asynchronously on the server | | `retain_context` | `conversation between Claway Agent and the User` | Context label for retained memories | | `retain_tags` | — | Default tags applied to retained memories; merged with per-call tool tags | | `retain_source` | — | Optional `metadata.source` attached to retained memories | | `retain_user_prefix` | `User` | Label used before user turns in auto-retained transcripts | | `retain_assistant_prefix` | `Assistant` | Label used before assistant turns in auto-retained transcripts | | `recall_tags` | — | Tags to filter on recall | See plugin README for the full configuration reference. --- ### Holographic Local SQLite fact store with FTS5 full-text search, trust scoring, and HRR (Holographic Reduced Representations) for compositional algebraic queries. | | | |---|---| | **Best for** | Local-only memory with advanced retrieval, no external dependencies | | **Requires** | Nothing (SQLite is always available). NumPy optional for HRR algebra. | | **Data storage** | Local SQLite | | **Cost** | Free | **Tools:** `fact_store` (9 actions: add, search, probe, related, reason, contradict, update, remove, list), `fact_feedback` (helpful/unhelpful rating that trains trust scores) **Setup:** ```bash claway memory setup # select "holographic" # Or manually: claway config set memory.provider holographic ``` **Config:** `config.yaml` under `plugins.claway-memory-store` | Key | Default | Description | |-----|---------|-------------| | `db_path` | `$CLAWAY_HOME/memory_store.db` | SQLite database path | | `auto_extract` | `false` | Auto-extract facts at session end | | `default_trust` | `0.5` | Default trust score (0.0–1.0) | **Unique capabilities:** - `probe` — entity-specific algebraic recall (all facts about a person/thing) - `reason` — compositional AND queries across multiple entities - `contradict` — automated detection of conflicting facts - Trust scoring with asymmetric feedback (+0.05 helpful / -0.10 unhelpful) --- ### RetainDB Cloud memory API with hybrid search (Vector + BM25 + Reranking), 7 memory types, and delta compression. | | | |---|---| | **Best for** | Teams already using RetainDB's infrastructure | | **Requires** | RetainDB account + API key | | **Data storage** | RetainDB Cloud | | **Cost** | $20/month | **Tools:** `retaindb_profile` (user profile), `retaindb_search` (semantic search), `retaindb_context` (task-relevant context), `retaindb_remember` (store with type + importance), `retaindb_forget` (delete memories) **Setup:** ```bash claway memory setup # select "retaindb" # Or manually: claway config set memory.provider retaindb echo "RETAINDB_API_KEY=your-key" >> ~/.claway/.env ``` --- ### ByteRover Persistent memory via the `brv` CLI — hierarchical knowledge tree with tiered retrieval (fuzzy text → LLM-driven search). Local-first with optional cloud sync. | | | |---|---| | **Best for** | Developers who want portable, local-first memory with a CLI | | **Requires** | ByteRover CLI (`npm install -g byterover-cli` or [install script](https://byterover.dev)) | | **Data storage** | Local (default) or ByteRover Cloud (optional sync) | | **Cost** | Free (local) or ByteRover pricing (cloud) | **Tools:** `brv_query` (search knowledge tree), `brv_curate` (store facts/decisions/patterns), `brv_status` (CLI version + tree stats) **Setup:** ```bash # Install the CLI first curl -fsSL https://byterover.dev/install.sh | sh # Then configure Claway claway memory setup # select "byterover" # Or manually: claway config set memory.provider byterover ``` **Key features:** - Automatic pre-compression extraction (saves insights before context compression discards them) - Knowledge tree stored at `$CLAWAY_HOME/byterover/` (profile-scoped) - SOC2 Type II certified cloud sync (optional) --- ### Supermemory Semantic long-term memory with profile recall, semantic search, explicit memory tools, and session-end conversation ingest via the Supermemory graph API. | | | |---|---| | **Best for** | Semantic recall with user profiling and session-level graph building | | **Requires** | `pip install supermemory` + [API key](http://app.supermemory.ai/integrations?connect=claway) | | **Data storage** | Supermemory Cloud | | **Cost** | Supermemory pricing | **Tools:** `supermemory_store` (save explicit memories), `supermemory_search` (semantic similarity search), `supermemory_forget` (forget by ID or best-match query), `supermemory_profile` (persistent profile + recent context) **Setup:** ```bash claway memory setup # select "supermemory" # Or manually: claway config set memory.provider supermemory echo 'SUPERMEMORY_API_KEY=***' >> ~/.claway/.env ``` **Config:** `$CLAWAY_HOME/supermemory.json` | Key | Default | Description | |-----|---------|-------------| | `container_tag` | `claway` | Container tag used for search and writes. Supports `{identity}` template for profile-scoped tags. | | `auto_recall` | `true` | Inject relevant memory context before turns | | `auto_capture` | `true` | Store cleaned user-assistant turns after each response | | `max_recall_results` | `10` | Max recalled items to format into context | | `profile_frequency` | `50` | Include profile facts on first turn and every N turns | | `capture_mode` | `all` | Skip tiny or trivial turns by default | | `search_mode` | `hybrid` | Search mode: `hybrid`, `memories`, or `documents` | | `api_timeout` | `5.0` | Timeout for SDK and ingest requests | **Environment variables:** `SUPERMEMORY_API_KEY` (required), `SUPERMEMORY_CONTAINER_TAG` (overrides config). **Key features:** - Automatic context fencing — strips recalled memories from captured turns to prevent recursive memory pollution - Full-session ingest — the entire conversation is sent once at session boundaries - Session-end conversation ingest (to `/v4/conversations`) for richer profile + graph building in Supermemory - Profile facts injected on first turn and at configurable intervals - **Profile-scoped containers** — use `{identity}` in `container_tag` (e.g. `claway-{identity}` → `claway-coder`) to isolate memories per Claway profile - **Multi-container mode** — enable `enable_custom_container_tags` with a `custom_containers` list to let the agent read/write across named containers. Automatic operations stay on the primary container. <details> <summary>Multi-container example</summary> ```json { "container_tag": "claway", "enable_custom_container_tags": true, "custom_containers": ["project-alpha", "shared-knowledge"], "custom_container_instructions": "Use project-alpha for coding context." } ``` </details> **Support:** [Discord](https://supermemory.link/discord) · [support@supermemory.com](mailto:support@supermemory.com) ### Memori Structured long-term memory using Memori Cloud, with background completed-turn capture, tool-aware turn context, and explicit recall tools for facts, summaries, quota, signup, and feedback. | | | |---|---| | **Best for** | Agent-controlled recall with structured project and session attribution | | **Requires** | `pip install claway-memori` + `claway-memori install` + [Memori API key](https://app.memorilabs.ai/signup) | | **Data storage** | Memori Cloud | | **Cost** | Memori pricing | **Tools:** `memori_recall` (search long-term memory), `memori_recall_summary` (summarized context), `memori_quota` (usage/quota), `memori_signup` (request signup email), `memori_feedback` (send integration feedback) **Setup:** ```bash pip install claway-memori claway-memori install claway config set memory.provider memori claway memory setup ``` --- ## Provider Comparison | Provider | Storage | Cost | Tools | Dependencies | Unique Feature | |----------|---------|------|-------|-------------|----------------| | **Honcho** | Cloud | Paid | 5 | `honcho-ai` | Dialectic user modeling + session-scoped context | | **OpenViking** | Self-hosted | Free | 5 | `openviking` + server | Filesystem hierarchy + tiered loading | | **Mem0** | Cloud/Self-hosted | Free/Paid | 5 | `mem0ai` | Server-side LLM extraction + OSS mode | | **Hindsight** | Cloud/Local | Free/Paid | 3 | `hindsight-client` | Knowledge graph + reflect synthesis | | **Holographic** | Local | Free | 2 | None | HRR algebra + trust scoring | | **RetainDB** | Cloud | $20/mo | 5 | `requests` | Delta compression | | **ByteRover** | Local/Cloud | Free/Paid | 3 | `brv` CLI | Pre-compression extraction | | **Supermemory** | Cloud | Paid | 4 | `supermemory` | Context fencing + session graph ingest + multi-container | | **Memori** | Cloud | Free/Paid | 5 | `claway-memori` | Tool-aware memory + structured recall | ## Profile Isolation Each provider's data is isolated per [profile](/user-guide/profiles): - **Local storage providers** (Holographic, ByteRover) use `$CLAWAY_HOME/` paths which differ per profile - **Config file providers** (Honcho, Mem0, Hindsight, Supermemory) store config in `$CLAWAY_HOME/` so each profile has its own credentials - **Cloud providers** (RetainDB) auto-derive profile-scoped project names - **Env var providers** (OpenViking) are configured via each profile's `.env` file ## Building a Memory Provider See the [Developer Guide: Memory Provider Plugins](/developer-guide/memory-provider-plugin) for how to create your own. --- <!-- source: website/docs/user-guide/features/context-files.md --> # Context Files # Context Files Claway Agent automatically discovers and loads context files that shape how it behaves. Some are project-local and discovered from your working directory. `SOUL.md` is now global to the Claway instance and is loaded from `CLAWAY_HOME` only. ## Supported Context Files | File | Purpose | Discovery | |------|---------|-----------| | **.claway.md** / **CLAWAY.md** | Project instructions (highest priority) | Walks to git root | | **AGENTS.md** | Project instructions, conventions, architecture | CWD at startup + subdirectories progressively | | **CLAUDE.md** | Claude Code context files (also detected) | CWD at startup + subdirectories progressively | | **SOUL.md** | Global personality and tone customization for this Claway instance | `CLAWAY_HOME/SOUL.md` only | | **.cursorrules** | Cursor IDE coding conventions | CWD only | | **.cursor/rules/*.mdc** | Cursor IDE rule modules | CWD only | :::info Priority system Only **one** project context type is loaded per session (first match wins): `.claway.md` → `AGENTS.md` → `CLAUDE.md` → `.cursorrules`. **SOUL.md** is always loaded independently as the agent identity (slot #1). ::: ## AGENTS.md `AGENTS.md` is the primary project context file. It tells the agent how your project is structured, what conventions to follow, and any special instructions. ### Progressive Subdirectory Discovery At session start, Claway loads the `AGENTS.md` from your working directory into the system prompt. As the agent navigates into subdirectories during the session (via `read_file`, `terminal`, `search_files`, etc.), it **progressively discovers** context files in those directories and injects them into the conversation at the moment they become relevant. ``` my-project/ ├── AGENTS.md ← Loaded at startup (system prompt) ├── frontend/ │ └── AGENTS.md ← Discovered when agent reads frontend/ files ├── backend/ │ └── AGENTS.md ← Discovered when agent reads backend/ files └── shared/ └── AGENTS.md ← Discovered when agent reads shared/ files ``` This approach has two advantages over loading everything at startup: - **No system prompt bloat** — subdirectory hints only appear when needed - **Prompt cache preservation** — the system prompt stays stable across turns Each subdirectory is checked at most once per session. The discovery also walks up parent directories, so reading `backend/src/main.py` will discover `backend/AGENTS.md` even if `backend/src/` has no context file of its own. :::info Subdirectory context files go through the same [security scan](#security-prompt-injection-protection) as startup context files. Malicious files are blocked. ::: ### Example AGENTS.md ```markdown # Project Context This is a Next.js 14 web application with a Python FastAPI backend. ## Architecture - Frontend: Next.js 14 with App Router in `/frontend` - Backend: FastAPI in `/backend`, uses SQLAlchemy ORM - Database: PostgreSQL 16 - Deployment: Docker Compose on a Hetzner VPS ## Conventions - Use TypeScript strict mode for all frontend code - Python code follows PEP 8, use type hints everywhere - All API endpoints return JSON with `{data, error, meta}` shape - Tests go in `__tests__/` directories (frontend) or `tests/` (backend) ## Important Notes - Never modify migration files directly — use Alembic commands - The `.env.local` file has real API keys, don't commit it - Frontend port is 3000, backend is 8000, DB is 5432 ``` ## SOUL.md `SOUL.md` controls the agent's personality, tone, and communication style. See the [Personality](/user-guide/features/personality) page for full details. **Location:** - `~/.claway/SOUL.md` - or `$CLAWAY_HOME/SOUL.md` if you run Claway with a custom home directory Important details: - Claway seeds a default `SOUL.md` automatically if one does not exist yet - Claway loads `SOUL.md` only from `CLAWAY_HOME` - Claway does not probe the working directory for `SOUL.md` - If the file is empty, nothing from `SOUL.md` is added to the prompt - If the file has content, the content is injected verbatim after scanning and truncation ## .cursorrules Claway is compatible with Cursor IDE's `.cursorrules` file and `.cursor/rules/*.mdc` rule modules. If these files exist in your project root and no higher-priority context file (`.claway.md`, `AGENTS.md`, or `CLAUDE.md`) is found, they're loaded as the project context. This means your existing Cursor conventions automatically apply when using Claway. ## How Context Files Are Loaded ### At startup (system prompt) Context files are loaded by `build_context_files_prompt()` in `agent/prompt_builder.py`: 1. **Scan working directory** — checks for `.claway.md` → `AGENTS.md` → `CLAUDE.md` → `.cursorrules` (first match wins) 2. **Content is read** — each file is read as UTF-8 text 3. **Security scan** — content is checked for prompt injection patterns 4. **Truncation** — files exceeding `context_file_max_chars` characters (default 20,000) are head/tail truncated (70% head, 20% tail, with a marker in the middle) 5. **Assembly** — all sections are combined under a `# Project Context` header 6. **Injection** — the assembled content is added to the system prompt ### During the session (progressive discovery) `SubdirectoryHintTracker` in `agent/subdirectory_hints.py` watches tool call arguments for file paths: 1. **Path extraction** — after each tool call, file paths are extracted from arguments (`path`, `workdir`, shell commands) 2. **Ancestor walk** — the directory and up to 5 parent directories are checked (stopping at already-visited directories) 3. **Hint loading** — if an `AGENTS.md`, `CLAUDE.md`, or `.cursorrules` is found, it's loaded (first match per directory) 4. **Security scan** — same prompt injection scan as startup files 5. **Truncation** — capped at 8,000 characters per file 6. **Injection** — appended to the tool result, so the model sees it in context naturally The final prompt section looks roughly like: ```text # Project Context The following project context files have been loaded and should be followed: ## AGENTS.md [Your AGENTS.md content here] ## .cursorrules [Your .cursorrules content here] [Your SOUL.md content here] ``` Notice that SOUL content is inserted directly, without extra wrapper text. ## Security: Prompt Injection Protection All context files are scanned for potential prompt injection before being included. The scanner checks for: - **Instruction override attempts**: "ignore previous instructions", "disregard your rules" - **Deception patterns**: "do not tell the user" - **System prompt overrides**: "system prompt override" - **Hidden HTML comments**: `<!-- ignore instructions -->` - **Hidden div elements**: `<div style="display:none">` - **Credential exfiltration**: `curl ... $API_KEY` - **Secret file access**: `cat .env`, `cat credentials` - **Invisible characters**: zero-width spaces, bidirectional overrides, word joiners If any threat pattern is detected, the file is blocked: ``` [BLOCKED: AGENTS.md contained potential prompt injection (prompt_injection). Content not loaded.] ``` :::warning This scanner protects against common injection patterns, but it's not a substitute for reviewing context files in shared repositories. Always validate AGENTS.md content in projects you didn't author. ::: ## Size Limits | Limit | Value | |-------|-------| | Max chars per file | `context_file_max_chars` (default 20,000, ~7,000 tokens) | | Head truncation ratio | 70% | | Tail truncation ratio | 20% | | Truncation marker | 10% (shows char counts and suggests using file tools) | When a file exceeds the configured limit, the truncation message reads: ``` [...truncated AGENTS.md: kept 14000+4000 of 25000 chars. Use file tools to read the full file.] ``` ## Tips for Effective Context Files :::tip Best practices for AGENTS.md 1. **Keep it concise** — stay under your configured `context_file_max_chars`; the agent reads it every turn 2. **Structure with headers** — use `##` sections for architecture, conventions, important notes 3. **Include concrete examples** — show preferred code patterns, API shapes, naming conventions 4. **Mention what NOT to do** — "never modify migration files directly" 5. **List key paths and ports** — the agent uses these for terminal commands 6. **Update as the project evolves** — stale context is worse than no context ::: ### Per-Subdirectory Context For monorepos, put subdirectory-specific instructions in nested AGENTS.md files: ```markdown <!-- frontend/AGENTS.md --> # Frontend Context - Use `pnpm` not `npm` for package management - Components go in `src/components/`, pages in `src/app/` - Use Tailwind CSS, never inline styles - Run tests with `pnpm test` ``` ```markdown <!-- backend/AGENTS.md --> # Backend Context - Use `poetry` for dependency management - Run the dev server with `poetry run uvicorn main:app --reload` - All endpoints need OpenAPI docstrings - Database models are in `models/`, schemas in `schemas/` ``` --- <!-- source: website/docs/user-guide/features/personality.md --> # Personality & SOUL.md # Personality & SOUL.md Claway Agent's personality is fully customizable. `SOUL.md` is the **primary identity** — it's the first thing in the system prompt and defines who the agent is. - `SOUL.md` — a durable persona file that lives in `CLAWAY_HOME` and serves as the agent's identity (slot #1 in the system prompt) - built-in or custom `/personality` presets — session-level system-prompt overlays If you want to change who Claway is — or replace it with an entirely different agent persona — edit `SOUL.md`. ## How SOUL.md works now Claway now seeds a default `SOUL.md` automatically in: ```text ~/.claway/SOUL.md ``` More precisely, it uses the current instance's `CLAWAY_HOME`, so if you run Claway with a custom home directory, it will use: ```text $CLAWAY_HOME/SOUL.md ``` ### Important behavior - **SOUL.md is the agent's primary identity.** It occupies slot #1 in the system prompt, replacing the hardcoded default identity. - Claway creates a starter `SOUL.md` automatically if one does not exist yet - Existing user `SOUL.md` files are never overwritten - Claway loads `SOUL.md` only from `CLAWAY_HOME` - Claway does not look in the current working directory for `SOUL.md` - If `SOUL.md` exists but is empty, or cannot be loaded, Claway falls back to a built-in default identity - If `SOUL.md` has content, that content is injected verbatim after security scanning and truncation - SOUL.md is **not** duplicated in the context files section — it appears only once, as the identity That makes `SOUL.md` a true per-user or per-instance identity, not just an additive layer. ## Why this design This keeps personality predictable. If Claway loaded `SOUL.md` from whatever directory you happened to launch it in, your personality could change unexpectedly between projects. By loading only from `CLAWAY_HOME`, the personality belongs to the Claway instance itself. That also makes it easier to teach users: - "Edit `~/.claway/SOUL.md` to change Claway's default personality." ## Where to edit it For most users: ```bash ~/.claway/SOUL.md ``` If you use a custom home: ```bash $CLAWAY_HOME/SOUL.md ``` ## What should go in SOUL.md? Use it for durable voice and personality guidance, such as: - tone - communication style - level of directness - default interaction style - what to avoid stylistically - how Claway should handle uncertainty, disagreement, or ambiguity Use it less for: - one-off project instructions - file paths - repo conventions - temporary workflow details Those belong in `AGENTS.md`, not `SOUL.md`. ## Good SOUL.md content A good SOUL file is: - stable across contexts - broad enough to apply in many conversations - specific enough to materially shape the voice - focused on communication and identity, not task-specific instructions ### Example ```markdown # Personality You are a pragmatic senior engineer with strong taste. You optimize for truth, clarity, and usefulness over politeness theater. ## Style - Be direct without being cold - Prefer substance over filler - Push back when something is a bad idea - Admit uncertainty plainly - Keep explanations compact unless depth is useful ## What to avoid - Sycophancy - Hype language - Repeating the user's framing if it's wrong - Overexplaining obvious things ## Technical posture - Prefer simple systems over clever systems - Care about operational reality, not idealized architecture - Treat edge cases as part of the design, not cleanup ``` ## What Claway injects into the prompt `SOUL.md` content goes directly into slot #1 of the system prompt — the agent identity position. No wrapper language is added around it. The content goes through: - prompt-injection scanning - truncation if it is too large If the file is empty, whitespace-only, or cannot be read, Claway falls back to a built-in default identity ("You are Claway Agent, an intelligent AI assistant created by Blockway..."). This fallback also applies when `skip_context_files` is set (e.g., in subagent/delegation contexts). ## Security scanning `SOUL.md` is scanned like other context-bearing files for prompt injection patterns before inclusion. That means you should still keep it focused on persona/voice rather than trying to sneak in strange meta-instructions. ## SOUL.md vs AGENTS.md This is the most important distinction. ### SOUL.md Use for: - identity - tone - style - communication defaults - personality-level behavior ### AGENTS.md Use for: - project architecture - coding conventions - tool preferences - repo-specific workflows - commands, ports, paths, deployment notes A useful rule: - if it should follow you everywhere, it belongs in `SOUL.md` - if it belongs to a project, it belongs in `AGENTS.md` ## SOUL.md vs `/personality` `SOUL.md` is your durable default personality. `/personality` is a session-level overlay that changes or supplements the current system prompt. So: - `SOUL.md` = baseline voice - `/personality` = temporary mode switch Examples: - keep a pragmatic default SOUL, then use `/personality teacher` for a tutoring conversation - keep a concise SOUL, then use `/personality creative` for brainstorming ## Built-in personalities Claway ships with built-in personalities you can switch to with `/personality`. | Name | Description | |------|-------------| | **helpful** | Friendly, general-purpose assistant | | **concise** | Brief, to-the-point responses | | **technical** | Detailed, accurate technical expert | | **creative** | Innovative, outside-the-box thinking | | **teacher** | Patient educator with clear examples | | **kawaii** | Cute expressions, sparkles, and enthusiasm ★ | | **catgirl** | Neko-chan with cat-like expressions, nya~ | | **pirate** | Captain Claway, tech-savvy buccaneer | | **shakespeare** | Bardic prose with dramatic flair | | **surfer** | Totally chill bro vibes | | **noir** | Hard-boiled detective narration | | **uwu** | Maximum cute with uwu-speak | | **philosopher** | Deep contemplation on every query | | **hype** | MAXIMUM ENERGY AND ENTHUSIASM!!! | ## Switching personalities with commands ### CLI ```text /personality /personality concise /personality technical ``` ### Messaging platforms ```text /personality teacher ``` These are convenient overlays, but your global `SOUL.md` still gives Claway its persistent default personality unless the overlay meaningfully changes it. ## Custom personalities in config You can also define named custom personalities in `~/.claway/config.yaml` under `agent.personalities`. ```yaml agent: personalities: codereviewer: > You are a meticulous code reviewer. Identify bugs, security issues, performance concerns, and unclear design choices. Be precise and constructive. ``` Then switch to it with: ```text /personality codereviewer ``` ## Recommended workflow A strong default setup is: 1. Keep a thoughtful global `SOUL.md` in `~/.claway/SOUL.md` 2. Put project instructions in `AGENTS.md` 3. Use `/personality` only when you want a temporary mode shift That gives you: - a stable voice - project-specific behavior where it belongs - temporary control when needed ## How personality interacts with the full prompt At a high level, the prompt stack includes: 1. **SOUL.md** (agent identity — or built-in fallback if SOUL.md is unavailable) 2. tool-aware behavior guidance 3. memory/user context 4. skills guidance 5. context files (`AGENTS.md`, `.cursorrules`) 6. timestamp 7. platform-specific formatting hints 8. optional system-prompt overlays such as `/personality` `SOUL.md` is the foundation — everything else builds on top of it. ## Related docs - [Context Files](/user-guide/features/context-files) - [Configuration](/user-guide/configuration) - [Tips & Best Practices](/guides/tips) - [SOUL.md Guide](/guides/use-soul-with-claway) ## CLI appearance vs conversational personality Conversational personality and CLI appearance are separate: - `SOUL.md`, `agent.system_prompt`, and `/personality` affect how Claway speaks - `display.skin` and `/skin` affect how Claway looks in the terminal For terminal appearance, see [Skins & Themes](./skins.md). --- <!-- source: website/docs/user-guide/features/plugins.md --> # Plugins # Plugins Claway has a plugin system for adding custom tools, hooks, and integrations without modifying core code. If you want to create a custom tool for yourself, your team, or one project, this is usually the right path. The developer guide's Adding Tools page is for built-in Claway core tools that live in `tools/` and `toolsets.py`. **→ [Build a Claway Plugin](/guides/build-a-claway-plugin)** — step-by-step guide with a complete working example. ## Quick overview Drop a directory into `~/.claway/plugins/` with a `plugin.yaml` and Python code: ``` ~/.claway/plugins/my-plugin/ ├── plugin.yaml # manifest ├── __init__.py # register() — wires schemas to handlers ├── schemas.py # tool schemas (what the LLM sees) └── tools.py # tool handlers (what runs when called) ``` Start Claway — your tools appear alongside built-in tools. The model can call them immediately. ### Minimal working example Here is a complete plugin that adds a `hello_world` tool and logs every tool call via a hook. **`~/.claway/plugins/hello-world/plugin.yaml`** ```yaml name: hello-world version: "1.0" description: A minimal example plugin ``` **`~/.claway/plugins/hello-world/__init__.py`** ```python """Minimal Claway plugin — registers a tool and a hook.""" import json def register(ctx): # --- Tool: hello_world --- schema = { "name": "hello_world", "description": "Returns a friendly greeting for the given name.", "parameters": { "type": "object", "properties": { "name": { "type": "string", "description": "Name to greet", } }, "required": ["name"], }, } def handle_hello(params, **kwargs): del kwargs name = params.get("name", "World") return json.dumps({"success": True, "greeting": f"Hello, {name}!"}) ctx.register_tool( name="hello_world", toolset="hello_world", schema=schema, handler=handle_hello, description="Return a friendly greeting for the given name.", ) # --- Hook: log every tool call --- def on_tool_call(tool_name, params, result): print(f"[hello-world] tool called: {tool_name}") ctx.register_hook("post_tool_call", on_tool_call) ``` Drop both files into `~/.claway/plugins/hello-world/`, restart Claway, and the model can immediately call `hello_world`. The hook prints a log line after every tool invocation. Project-local plugins under `./.claway/plugins/` are disabled by default. Enable them only for trusted repositories by setting `CLAWAY_ENABLE_PROJECT_PLUGINS=true` before starting Claway. ## What plugins can do Every `ctx.*` API below is available inside a plugin's `register(ctx)` function. | Capability | How | |-----------|-----| | Add tools | `ctx.register_tool(name=..., toolset=..., schema=..., handler=...)` | | Add hooks | `ctx.register_hook("post_tool_call", callback)` | | Add slash commands | `ctx.register_command(name, handler, description)` — adds `/name` in CLI and gateway sessions | | Dispatch tools from commands | `ctx.dispatch_tool(name, args)` — invokes a registered tool with parent-agent context auto-wired | | Add CLI commands | `ctx.register_cli_command(name, help, setup_fn, handler_fn)` — adds `claway <plugin> <subcommand>` | | Inject messages | `ctx.inject_message(content, role="user")` — see [Injecting Messages](#injecting-messages) | | Ship data files | `Path(__file__).parent / "data" / "file.yaml"` | | Bundle skills | `ctx.register_skill(name, path)` — namespaced as `plugin:skill`, loaded via `skill_view("plugin:skill")` | | Gate on env vars | `requires_env: [API_KEY]` in plugin.yaml — prompted during `claway plugins install` | | Distribute via pip | `[project.entry-points."claway_agent.plugins"]` | | Register a gateway platform (Discord, Telegram, IRC, …) | `ctx.register_platform(name, label, adapter_factory, check_fn, ...)` — see Adding Platform Adapters | | Register an image-generation backend | `ctx.register_image_gen_provider(provider)` — see [Image Generation Provider Plugins](/developer-guide/image-gen-provider-plugin) | | Register a video-generation backend | `ctx.register_video_gen_provider(provider)` — see [Video Generation Provider Plugins](/developer-guide/video-gen-provider-plugin) | | Register a context-compression engine | `ctx.register_context_engine(engine)` — see [Context Engine Plugins](/developer-guide/context-engine-plugin) | | Register a memory backend | Subclass `MemoryProvider` in `plugins/memory/<name>/__init__.py` — see [Memory Provider Plugins](/developer-guide/memory-provider-plugin) (uses a separate discovery system) | | Run a host-owned LLM call | `ctx.llm.complete(...)` / `ctx.llm.complete_structured(...)` — borrow the user's active model + auth for a one-shot completion with optional JSON schema validation. See [Plugin LLM Access](/developer-guide/plugin-llm-access) | | Register an inference backend (LLM provider) | `register_provider(ProviderProfile(...))` in `plugins/model-providers/<name>/__init__.py` — see [Model Provider Plugins](/developer-guide/model-provider-plugin) (uses a separate discovery system) | ## Plugin discovery | Source | Path | Use case | |--------|------|----------| | Bundled | `<repo>/plugins/` | Ships with Claway — see [Built-in Plugins](/user-guide/features/built-in-plugins) | | User | `~/.claway/plugins/` | Personal plugins | | Project | `.claway/plugins/` | Project-specific plugins (requires `CLAWAY_ENABLE_PROJECT_PLUGINS=true`) | | pip | `claway_agent.plugins` entry_points | Distributed packages | Later sources override earlier ones on name collision, so a user plugin with the same name as a bundled plugin replaces it. ### Plugin sub-categories Within each source, Claway also recognizes sub-category directories that route plugins to specialized discovery systems: | Sub-directory | What it holds | Discovery system | |---|---|---| | `plugins/` (root) | General plugins — tools, hooks, slash commands, CLI commands, bundled skills | `PluginManager` (kind: `standalone` or `backend`) | | `plugins/platforms/<name>/` | Gateway channel adapters (`ctx.register_platform()`) | `PluginManager` (kind: `platform`, one level deeper) | | `plugins/image_gen/<name>/` | Image-generation backends (`ctx.register_image_gen_provider()`) | `PluginManager` (kind: `backend`, one level deeper) | | `plugins/memory/<name>/` | Memory providers (subclass `MemoryProvider`) | **Own loader** in `plugins/memory/__init__.py` (kind: `exclusive` — one active at a time) | | `plugins/context_engine/<name>/` | Context-compression engines (`ctx.register_context_engine()`) | **Own loader** in `plugins/context_engine/__init__.py` (one active at a time) | | `plugins/model-providers/<name>/` | LLM provider profiles (`register_provider(ProviderProfile(...))`) | **Own loader** in `providers/__init__.py` (lazily scanned on first `get_provider_profile()` call) | User plugins at `~/.claway/plugins/model-providers/<name>/` and `~/.claway/plugins/memory/<name>/` override bundled plugins of the same name — last-writer-wins in `register_provider()` / `register_memory_provider()`. Drop a directory in, and it replaces the built-in without any repo edits. ## Plugins are opt-in (with a few exceptions) **General plugins and user-installed backends are disabled by default** — discovery finds them (so they show up in `claway plugins` and `/plugins`), but nothing with hooks or tools loads until you add the plugin's name to `plugins.enabled` in `~/.claway/config.yaml`. This stops third-party code from running without your explicit consent. ```yaml plugins: enabled: - my-tool-plugin - disk-cleanup disabled: # optional deny-list — always wins if a name appears in both - noisy-plugin ``` Three ways to flip state: ```bash claway plugins # interactive toggle (space to check/uncheck) claway plugins enable <name> # add to allow-list claway plugins disable <name> # remove from allow-list + add to disabled ``` After `claway plugins install owner/repo`, you're asked `Enable 'name' now? [y/N]` — defaults to no. Skip the prompt for scripted installs with `--enable` or `--no-enable`. ### What the allow-list does NOT gate Several categories of plugin bypass `plugins.enabled` — they're part of Claway's built-in surface and would break basic functionality if gated off by default: | Plugin kind | How it's activated instead | |---|---| | **Bundled platform plugins** (IRC, Teams, etc. under `plugins/platforms/`) | Auto-loaded so every shipped gateway channel is available. The actual channel turns on via `gateway.platforms.<name>.enabled` in `config.yaml`. | | **Bundled backends** (image-gen providers under `plugins/image_gen/`, etc.) | Auto-loaded so the default backend "just works". Selection happens via `<category>.provider` in `config.yaml` (e.g. `image_gen.provider: openai`). | | **Memory providers** (`plugins/memory/`) | All discovered; exactly one is active, chosen by `memory.provider` in `config.yaml`. | | **Context engines** (`plugins/context_engine/`) | All discovered; one is active, chosen by `context.engine` in `config.yaml`. | | **Model providers** (`plugins/model-providers/`) | All bundled providers under `plugins/model-providers/` discover and register at the first `get_provider_profile()` call. The user picks one at a time via `--provider` or `config.yaml`. | | **Pip-installed `backend` plugins** | Opt-in via `plugins.enabled` (same as general plugins). | | **User-installed platforms** (under `~/.claway/plugins/platforms/`) | Opt-in via `plugins.enabled` — third-party gateway adapters need explicit consent. | In short: **bundled "always-works" infrastructure loads automatically; third-party general plugins are opt-in.** The `plugins.enabled` allow-list is the gate specifically for arbitrary code a user drops into `~/.claway/plugins/`. ### Migration for existing users When you upgrade to a version of Claway that has opt-in plugins (config schema v21+), any user plugins already installed under `~/.claway/plugins/` that weren't already in `plugins.disabled` are **automatically grandfathered** into `plugins.enabled`. Your existing setup keeps working. Bundled standalone plugins are NOT grandfathered — even existing users have to opt in explicitly. (Bundled platform/backend plugins never needed grandfathering because they were never gated.) ## Available hooks Plugins can register callbacks for these lifecycle events. See the **[Event Hooks page](/user-guide/features/hooks#plugin-hooks)** for full details, callback signatures, and examples. | Hook | Fires when | |------|-----------| | [`pre_tool_call`](/user-guide/features/hooks#pre_tool_call) | Before any tool executes | | [`post_tool_call`](/user-guide/features/hooks#post_tool_call) | After any tool returns | | [`pre_llm_call`](/user-guide/features/hooks#pre_llm_call) | Once per turn, before the LLM loop — can return `{"context": "..."}` to [inject context into the user message](/user-guide/features/hooks#pre_llm_call) | | [`post_llm_call`](/user-guide/features/hooks#post_llm_call) | Once per turn, after the LLM loop (successful turns only) | | [`on_session_start`](/user-guide/features/hooks#on_session_start) | New session created (first turn only) | | [`on_session_end`](/user-guide/features/hooks#on_session_end) | End of every `run_conversation` call + CLI exit handler | | [`on_session_finalize`](/user-guide/features/hooks#on_session_finalize) | CLI/gateway tears down an active session (`/new`, GC, CLI quit) | | [`on_session_reset`](/user-guide/features/hooks#on_session_reset) | Gateway swaps in a new session key (`/new`, `/reset`, `/clear`, idle rotation) | | [`subagent_stop`](/user-guide/features/hooks#subagent_stop) | Once per child after `delegate_task` finishes | | [`pre_gateway_dispatch`](/user-guide/features/hooks#pre_gateway_dispatch) | Gateway received a user message, before auth + dispatch. Return `{"action": "skip" \| "rewrite" \| "allow", ...}` to influence flow. | ## Plugin types Claway has four kinds of plugins: | Type | What it does | Selection | Location | |------|-------------|-----------|----------| | **General plugins** | Add tools, hooks, slash commands, CLI commands | Multi-select (enable/disable) | `~/.claway/plugins/` | | **Memory providers** | Replace or augment built-in memory | Single-select (one active) | `plugins/memory/` | | **Context engines** | Replace the built-in context compressor | Single-select (one active) | `plugins/context_engine/` | | **Model providers** | Declare an inference backend (OpenRouter, Anthropic, …) | Multi-register, picked by `--provider` / `config.yaml` | `plugins/model-providers/` | Memory providers and context engines are **provider plugins** — only one of each type can be active at a time. Model providers are also plugins, but many load simultaneously; the user picks one at a time via `--provider` or `config.yaml`. General plugins can be enabled in any combination. ## Pluggable interfaces — where to go for each The table above shows the four plugin categories, but within "General plugins" the `PluginContext` exposes several distinct extension points — and Claway also accepts extensions outside the Python plugin system (config-driven backends, shell-hooked commands, external servers, etc.). Use this table to find the right doc for what you want to build: | Want to add… | How | Authoring guide | |---|---|---| | A **tool** the LLM can call | Python plugin — `ctx.register_tool()` | [Build a Claway Plugin](/guides/build-a-claway-plugin) · Adding Tools | | A **lifecycle hook** (pre/post LLM, session start/end, tool filter) | Python plugin — `ctx.register_hook()` | [Hooks reference](/user-guide/features/hooks) · [Build a Claway Plugin](/guides/build-a-claway-plugin) | | A **slash command** for the CLI / gateway | Python plugin — `ctx.register_command()` | [Build a Claway Plugin](/guides/build-a-claway-plugin) · Extending the CLI | | A **subcommand** for `claway <thing>` | Python plugin — `ctx.register_cli_command()` | Extending the CLI | | A bundled **skill** that your plugin ships | Python plugin — `ctx.register_skill()` | [Creating Skills](/developer-guide/creating-skills) | | An **inference backend** (LLM provider: OpenAI-compat, Codex, Anthropic-Messages, Bedrock) | Provider plugin — `register_provider(ProviderProfile(...))` in `plugins/model-providers/<name>/` | **[Model Provider Plugins](/developer-guide/model-provider-plugin)** · Adding Providers | | A **gateway channel** (Discord / Telegram / IRC / Teams / etc.) | Platform plugin — `ctx.register_platform()` in `plugins/platforms/<name>/` | Adding Platform Adapters | | A **memory backend** (Honcho, Mem0, Supermemory, …) | Memory plugin — subclass `MemoryProvider` in `plugins/memory/<name>/` | [Memory Provider Plugins](/developer-guide/memory-provider-plugin) | | A **context-compression strategy** | Context-engine plugin — `ctx.register_context_engine()` | [Context Engine Plugins](/developer-guide/context-engine-plugin) | | An **image-generation backend** (DALL·E, SDXL, …) | Backend plugin — `ctx.register_image_gen_provider()` | [Image Generation Provider Plugins](/developer-guide/image-gen-provider-plugin) | | A **video-generation backend** (Veo, Kling, Pixverse, Grok-Imagine, Runway, …) | Backend plugin — `ctx.register_video_gen_provider()` | [Video Generation Provider Plugins](/developer-guide/video-gen-provider-plugin) | | A **TTS backend** (any CLI — Piper, VoxCPM, Kokoro, xtts, voice-cloning scripts, …) | Config-driven (recommended) — declare under `tts.providers.<name>` with `type: command` in `config.yaml`. OR Python backend plugin — `ctx.register_tts_provider()` for Python-SDK / streaming engines that need more than a shell template. | [TTS Setup](/user-guide/features/tts#custom-command-providers) · [Python plugin guide](/user-guide/features/tts#python-plugin-providers) | | An **STT backend** (any CLI — whisper.cpp, custom whisper binary, local ASR CLI) | Config-driven (recommended) — declare under `stt.providers.<name>` with `type: command` in `config.yaml`, or set `CLAWAY_LOCAL_STT_COMMAND` for the legacy single-command escape hatch. OR Python backend plugin — `ctx.register_transcription_provider()` for Python-SDK engines (OpenRouter, SenseAudio, Gemini-STT, etc.). | [STT Setup](/user-guide/features/tts#stt-custom-command-providers) · [Python plugin guide](/user-guide/features/tts#python-plugin-providers-stt) | | **External tools via MCP** (filesystem, GitHub, Linear, Notion, any MCP server) | Config-driven — declare `mcp_servers.<name>` with `command:` / `url:` in `config.yaml`. Claway auto-discovers the server's tools and registers them alongside built-ins. | [MCP](/user-guide/features/mcp) | | **Additional skill sources** (custom GitHub repos, private skill indexes) | CLI — `claway skills tap add <repo>` | [Skills Hub](/user-guide/features/skills#skills-hub) · [Publishing a custom tap](/user-guide/features/skills#publishing-a-custom-skill-tap) | | **Gateway event hooks** (fire on `gateway:startup`, `session:start`, `agent:end`, `command:*`) | Drop `HOOK.yaml` + `handler.py` into `~/.claway/hooks/<name>/` | [Event Hooks](/user-guide/features/hooks#gateway-event-hooks) | | **Shell hooks** (run a shell command on events — notifications, audit logs, desktop alerts) | Config-driven — declare under `hooks:` in `config.yaml` | [Shell Hooks](/user-guide/features/hooks#shell-hooks) | :::note Not everything is a Python plugin. Some extension surfaces intentionally use **config-driven shell commands** (TTS, STT, shell hooks) so any CLI you already have becomes a plugin without writing Python. Others are **external servers** (MCP) the agent connects to and auto-registers tools from. And some are **drop-in directories** (gateway hooks) with their own manifest format. Pick the right surface for the integration style that fits your use case; the authoring guides in the table above each cover placeholders, discovery, and examples. ::: ## Managing plugins ```bash claway plugins # unified interactive UI claway plugins list # table: enabled / disabled / not enabled claway plugins install user/repo # install from Git, then prompt Enable? [y/N] claway plugins install user/repo --enable # install AND enable (no prompt) claway plugins install user/repo --no-enable # install but leave disabled (no prompt) claway plugins update my-plugin # pull latest claway plugins remove my-plugin # uninstall claway plugins enable my-plugin # add to allow-list claway plugins disable my-plugin # remove from allow-list + add to disabled ``` ### Interactive UI Running `claway plugins` with no arguments opens a composite interactive screen: ``` Plugins ↑↓ navigate SPACE toggle ENTER configure/confirm ESC done General Plugins → [✓] my-tool-plugin — Custom search tool [ ] webhook-notifier — Event hooks [ ] disk-cleanup — Auto-cleanup of ephemeral files [bundled] Provider Plugins Memory Provider ▸ honcho Context Engine ▸ compressor ``` - **General Plugins section** — checkboxes, toggle with SPACE. Checked = in `plugins.enabled`, unchecked = in `plugins.disabled` (explicit off). - **Provider Plugins section** — shows current selection. Press ENTER to drill into a radio picker where you choose one active provider. - Bundled plugins appear in the same list with a `[bundled]` tag. Provider plugin selections are saved to `config.yaml`: ```yaml memory: provider: "honcho" # empty string = built-in only context: engine: "compressor" # default built-in compressor ``` ### Enabled vs. disabled vs. neither Plugins occupy one of three states: | State | Meaning | In `plugins.enabled`? | In `plugins.disabled`? | |---|---|---|---| | `enabled` | Loaded on next session | Yes | No | | `disabled` | Explicitly off — won't load even if also in `enabled` | (irrelevant) | Yes | | `not enabled` | Discovered but never opted in | No | No | The default for a newly-installed or bundled plugin is `not enabled`. `claway plugins list` shows all three distinct states so you can tell what's been explicitly turned off vs. what's just waiting to be enabled. In a running session, `/plugins` shows which plugins are currently loaded. ## Injecting Messages Plugins can inject messages into the active conversation using `ctx.inject_message()`: ```python ctx.inject_message("New data arrived from the webhook", role="user") ``` **Signature:** `ctx.inject_message(content: str, role: str = "user") -> bool` How it works: - If the agent is **idle** (waiting for user input), the message is queued as the next input and starts a new turn. - If the agent is **mid-turn** (actively running), the message interrupts the current operation — the same as a user typing a new message and pressing Enter. - For non-`"user"` roles, the content is prefixed with `[role]` (e.g. `[system] ...`). - Returns `True` if the message was queued successfully, `False` if no CLI reference is available (e.g. in gateway mode). This enables plugins like remote control viewers, messaging bridges, or webhook receivers to feed messages into the conversation from external sources. :::note `inject_message` is only available in CLI mode. In gateway mode, there is no CLI reference and the method returns `False`. ::: See the **[full guide](/guides/build-a-claway-plugin)** for handler contracts, schema format, hook behavior, error handling, and common mistakes. --- <!-- source: website/docs/user-guide/features/cron.md --> # Scheduled Tasks (Cron) # Scheduled Tasks (Cron) Schedule tasks to run automatically with natural language or cron expressions. Claway exposes cron management through a single `cronjob` tool with action-style operations instead of separate schedule/list/remove tools. ## What cron can do now Cron jobs can: - schedule one-shot or recurring tasks - pause, resume, edit, trigger, and remove jobs - attach zero, one, or multiple skills to a job - deliver results back to the origin chat, local files, or configured platform targets - run in fresh agent sessions with the normal static tool list - run in **no-agent mode** — a script on a schedule, its stdout delivered verbatim, zero LLM involvement (see the [no-agent mode](#no-agent-mode-script-only-jobs) section below) All of this is available to Claway itself through the `cronjob` tool, so you can create, pause, edit, and remove jobs by asking in plain language — no CLI required. :::tip At creation, an unpinned job (one you don't give an explicit `provider`/`model`) follows the global default selected by `claway model` — and Claway **snapshots** that provider and model on the job. If the global default later changes, the job **fails closed**: it skips the run, makes no inference call, and sends an alert telling you to pin the provider/model explicitly (`cronjob action=update job_id=… provider=… model=…`) to proceed. This prevents an unattended job from silently inheriting a switch to a paid provider/model and spending money you didn't intend (#44585). To make a job deliberately track your global default, pin it to the new values after changing them. ::: :::warning Cron-run sessions cannot recursively create more cron jobs. Claway disables cron management tools inside cron executions to prevent runaway scheduling loops. ::: ## Creating scheduled tasks ### In chat with `/cron` ```bash /cron add 30m "Remind me to check the build" /cron add "every 2h" "Check server status" /cron add "every 1h" "Summarize new feed items" --skill blogwatcher /cron add "every 1h" "Use both skills and combine the result" --skill blogwatcher --skill maps ``` ### From the standalone CLI ```bash claway cron create "every 2h" "Check server status" claway cron create "every 1h" "Summarize new feed items" --skill blogwatcher claway cron create "every 1h" "Use both skills and combine the result" \ --skill blogwatcher \ --skill maps \ --name "Skill combo" ``` ### Through natural conversation Ask Claway normally: ```text Every morning at 9am, check Hacker News for AI news and send me a summary on Telegram. ``` Claway will use the unified `cronjob` tool internally. ## Skill-backed cron jobs A cron job can load one or more skills before it runs the prompt. ### Single skill ```python cronjob( action="create", skill="blogwatcher", prompt="Check the configured feeds and summarize anything new.", schedule="0 9 * * *", name="Morning feeds", ) ``` ### Multiple skills Skills are loaded in order. The prompt becomes the task instruction layered on top of those skills. ```python cronjob( action="create", skills=["blogwatcher", "maps"], prompt="Look for new local events and interesting nearby places, then combine them into one short brief.", schedule="every 6h", name="Local brief", ) ``` This is useful when you want a scheduled agent to inherit reusable workflows without stuffing the full skill text into the cron prompt itself. ## Running a job inside a project directory Cron jobs default to running detached from any repo — no `AGENTS.md`, `CLAUDE.md`, or `.cursorrules` is loaded, and the terminal / file / code-exec tools run from whatever working directory the gateway started in. Pass `--workdir` (CLI) or `workdir=` (tool call) to change that: ```bash # Standalone CLI (schedule and prompt are positional) claway cron create "every 1d at 09:00" \ "Audit open PRs, summarize CI health, and post to #eng" \ --workdir /home/me/projects/acme ``` ```python # From a chat, via the cronjob tool cronjob( action="create", schedule="every 1d at 09:00", workdir="/home/me/projects/acme", prompt="Audit open PRs, summarize CI health, and post to #eng", ) ``` When `workdir` is set: - `AGENTS.md`, `CLAUDE.md`, and `.cursorrules` from that directory are injected into the system prompt (same discovery order as the interactive CLI) - `terminal`, `read_file`, `write_file`, `patch`, `search_files`, and `execute_code` all use that directory as their working directory - The path must be an absolute directory that exists — relative paths and missing directories are rejected at create / update time - Pass `--workdir ""` (or `workdir=""` via the tool) on edit to clear it and restore the old behaviour :::note Serialization Jobs with a `workdir` run sequentially on the scheduler tick, not in the parallel pool. This is deliberate: the cron worker applies the job workdir through process-global terminal state, so two workdir jobs running at the same time would corrupt each other's cwd. Workdir-less jobs still run in parallel as before. ::: ## Editing jobs You do not need to delete and recreate jobs just to change them. :::tip Job reference The `<job_id>` placeholder below (and in [Lifecycle actions](#lifecycle-actions)) also accepts the job's name (case-insensitive) — handy when you remember `morning-digest` but not the hex ID. An exact job ID takes precedence over name matches; if the reference is not an ID and a name matches more than one job, the command refuses and prints the candidate IDs so you can disambiguate. ::: ### Chat ```bash /cron edit <job_id> --schedule "every 4h" /cron edit <job_id> --prompt "Use the revised task" /cron edit <job_id> --skill blogwatcher --skill maps /cron edit <job_id> --remove-skill blogwatcher /cron edit <job_id> --clear-skills ``` ### Standalone CLI ```bash claway cron edit <job_id> --schedule "every 4h" claway cron edit <job_id> --prompt "Use the revised task" claway cron edit <job_id> --skill blogwatcher --skill maps claway cron edit <job_id> --add-skill maps claway cron edit <job_id> --remove-skill blogwatcher claway cron edit <job_id> --clear-skills ``` Notes: - repeated `--skill` replaces the job's attached skill list - `--add-skill` appends to the existing list without replacing it - `--remove-skill` removes specific attached skills - `--clear-skills` removes all attached skills ## Lifecycle actions Cron jobs now have a fuller lifecycle than just create/remove. ### Chat ```bash /cron list /cron pause <job_id> /cron resume <job_id> /cron run <job_id> /cron remove <job_id> ``` ### Standalone CLI ```bash claway cron list claway cron pause <job_id_or_name> claway cron resume <job_id_or_name> claway cron run <job_id_or_name> claway cron remove <job_id_or_name> claway cron edit <job_id_or_name> [...flags] claway cron status claway cron tick ``` What they do: - `pause` — keep the job but stop scheduling it - `resume` — re-enable the job and compute the next future run - `run` — trigger the job on the next scheduler tick - `remove` — delete it entirely - `edit` — modify schedule, prompt, delivery, etc. **Name-based lookup.** All four mutating verbs (`pause`, `resume`, `run`, `remove`, `edit`) plus the agent's `cronjob` tool now accept a job **name** (case-insensitive) in place of the hex ID. The agent and CLI both prefer an exact ID match if one exists; ambiguous name matches (multiple jobs sharing the same name) are refused with the full list of candidate IDs so you can pick one explicitly. Names are not unique, so this guard is load-bearing — it prevents silently mutating the wrong job when two share a name. ## How it works **Cron execution is handled by the gateway daemon.** The gateway ticks the scheduler every 60 seconds, running any due jobs in isolated agent sessions. ```bash claway gateway install # Install as a user service sudo claway gateway install --system # Linux: boot-time system service for servers claway gateway # Or run in foreground claway cron list claway cron status ``` ### Gateway scheduler behavior On each tick Claway: 1. loads jobs from `~/.claway/cron/jobs.json` 2. checks `next_run_at` against the current time 3. starts a fresh `AIAgent` session for each due job 4. optionally injects one or more attached skills into that fresh session 5. runs the prompt to completion 6. delivers the final response 7. updates run metadata and the next scheduled time A file lock at `~/.claway/cron/.tick.lock` prevents overlapping scheduler ticks from double-running the same job batch. ## Delivery options When scheduling jobs, you specify where the output goes: | Option | Description | Example | |--------|-------------|---------| | `"origin"` | Back to where the job was created | Default on messaging platforms | | `"local"` | Save to local files only (`~/.claway/cron/output/`) | Default on CLI | | `"telegram"` | Telegram home channel | Uses `TELEGRAM_HOME_CHANNEL` | | `"telegram:123456"` | Specific Telegram chat by ID | Direct delivery | | `"telegram:-100123:17585"` | Specific Telegram topic | `chat_id:thread_id` format | | `"discord"` | Discord home channel | Uses `DISCORD_HOME_CHANNEL` | | `"discord:#engineering"` | Specific Discord channel | By channel name | | `"slack"` | Slack home channel | | | `"whatsapp"` | WhatsApp home | | | `"signal"` | Signal | | | `"matrix"` | Matrix home room | | | `"mattermost"` | Mattermost home channel | | | `"email"` | Email | | | `"sms"` | SMS via Twilio | | | `"homeassistant"` | Home Assistant | | | `"dingtalk"` | DingTalk | | | `"feishu"` | Feishu/Lark | | | `"wecom"` | WeCom | | | `"weixin"` | Weixin (WeChat) | | | `"bluebubbles"` | BlueBubbles (iMessage) | | | `"qqbot"` | QQ Bot (Tencent QQ) | | | `"all"` | Fan out to every connected home channel | Resolved at fire time | | `"telegram,discord"` | Fan out to a specific set of channels | Comma-separated list | | `"origin,all"` | Deliver to the origin **plus** every other connected channel | Combine any tokens | The agent's final response is automatically delivered to the configured `deliver:` target — the agent does not send messages itself, so there is nothing to call in the cron prompt. ### Routing intent (`all`) `all` lets you ship one cron job to every messaging channel you have configured, without having to enumerate them by name. It is **resolved at fire time**, so a job created before you wired up Telegram will pick up Telegram on the next tick after you set `TELEGRAM_HOME_CHANNEL`. Semantics: `all` expands to every platform with a configured home channel. Zero is fine; the job simply produces no delivery targets and is recorded as a delivery failure upstream. `all` composes with explicit targets. `origin,all` delivers to the origin chat *plus* every other connected home channel, de-duplicating by `(platform, chat_id, thread_id)`. ### Telegram cron topic (`TELEGRAM_CRON_THREAD_ID`) When Telegram topic mode is enabled, the root DM is reserved as a system lobby — replies sent there are rebuffed with a lobby reminder and `reply_to_message_id` is dropped, so you cannot reply to a cron message that landed in the main chat. Point cron at a dedicated forum topic instead: 1. In Telegram, open the bot DM and create a topic named e.g. `Cron`. Long-press the topic header → **Copy link**; the trailing integer is the topic's `message_thread_id`. 2. Set `TELEGRAM_CRON_THREAD_ID=<that id>` in your `.env`. This applies only to cron deliveries. `TELEGRAM_HOME_CHANNEL_THREAD_ID` (used elsewhere, e.g. restart notifications) is unchanged. Explicit `deliver="telegram:chat_id:thread_id"` targets continue to win over the env var. Replies to cron messages now arrive in the existing topic session, so you can act on them directly. ### Response wrapping By default, delivered cron output is wrapped with a header and footer so the recipient knows it came from a scheduled task: ``` [Morning feeds] <agent output here> ``` The job's name is shown only when you chose one. A job created automatically (named like `app-task:e3ba2de12f624091`) delivers its message with no tag at all, so a scheduled greeting reads as the assistant speaking rather than as a system notice. To deliver the raw agent output without any tag, set `cron.wrap_response` to `false`: ```yaml # ~/.claway/config.yaml cron: wrap_response: false ``` ### Continuable jobs (reply to a cron delivery) By default a cron delivery is fire-and-forget: the message is sent, but it does not live in the chat's conversation history, so if you reply to it the agent has no record of what it said. Set a job **continuable** and the delivered brief becomes a conversation you can reply into — the agent has the brief in context instead of asking "what is Task #2?". Opt-in, **default off**. Enable globally in config, or per-job via the `cronjob` tool's `attach_to_session` (which overrides the global setting for that one job): ```yaml # ~/.claway/config.yaml cron: mirror_delivery: false # set true to make cron deliveries continuable ``` Behaviour is **thread-preferred**, scoped to the job's origin chat: - **Thread-capable platforms** (Telegram topics, Discord/Slack threads): each delivery opens its own dedicated thread and the brief is seeded into that thread's session, so a reply in-thread continues with full context. A recurring job (e.g. a daily brief) opens a fresh thread per run, keeping each delivery's follow-up discussion isolated. - **DM-only platforms** (WhatsApp, Signal, SMS): no threads exist, so the brief is mirrored into the origin DM session instead — the DM itself is the continuation surface. Only the origin chat is ever touched: fan-out / broadcast targets (`all`, explicit other-chat deliveries) are never made continuable. The mirror is written as a labelled user turn (`[Cron delivery: <task name>]`), which keeps the conversation history alternation-safe across all model providers. #### Flat, in-channel continuation (Slack) The thread-preferred behaviour above mints a dedicated thread on every delivery. If you'd rather have a continuable job land **flat in the channel timeline** — no thread — set the Slack **continuable surface** to `in_channel`: ```yaml # ~/.claway/config.yaml slack: cron_continuable_surface: in_channel # default: thread reply_in_thread: false # required pairing (see below) require_mention: false # so a plain reply continues the job ``` In `in_channel` mode the brief is delivered as an ordinary top-level channel message (no thread is opened), and your reply continues the job via the channel's shared session. Three settings work together: - **`cron_continuable_surface: in_channel`** — skips thread creation on delivery. - **`reply_in_thread: false`** (required) — makes the bot answer your reply *flat* in the channel and key it to the same whole-channel session the brief was seeded into. Without it the continuation still works but arrives in a thread (it falls back safely to thread-style continuation, never a dropped reply — the gateway logs a warning at startup so you can spot the mismatch). - **`require_mention: false`** (or add the channel to `free_response_channels`) — so you can reply with a plain message; otherwise the bot only wakes when you `@`-mention it on each reply. Because the continuation is the **whole-channel** session, it is shared: other chatter in the channel — and a second continuable in-channel job — join the same rolling conversation. That is inherent to "flat in a channel" and is the same tradeoff `reply_in_thread: false` users already accept; use the default `thread` surface when you want each delivery's follow-up isolated. This is a Slack capability today. Other platforms accept the key but fall back to the `thread` surface (their continuation primitives differ); the choice is per-platform, set under each platform's config. It's a gateway-side config flag — a `/restart` picks it up; no Slack app reinstall is needed. :::note 1:1 DMs `cron_continuable_surface` is a **channel** setting — a 1:1 DM has no thread-vs-timeline split to choose between (the DM is already flat), so the key has no effect there. What governs whether a DM cron delivery is continuable is the separate, pre-existing knob **`slack.dm_top_level_threads_as_sessions`**: - **`false`** — all top-level DMs share one rolling DM session, so a continuable cron brief and your reply land in the **same** session and the job continues in context. This is what you want for continuable cron in a DM. - **`true`** (default) — each top-level DM message is its own session, so a reply to a delivered brief starts a *fresh* session that has no record of the brief. Continuation does not work in this mode (for cron or any other flat delivery). So for a continuable cron job delivered to a 1:1 DM, set `slack.dm_top_level_threads_as_sessions: false`. `cron_continuable_surface` is not required (and is ignored) for DMs. ::: ### Silent suppression If the agent's final response contains `[SILENT]`, delivery is suppressed entirely. The output is still saved locally for audit (in `~/.claway/cron/output/`), but no message is sent to the delivery target. This is useful for monitoring jobs that should only report when something is wrong: ```text Check if nginx is running. If everything is healthy, respond with only [SILENT]. Otherwise, report the issue. ``` Failed jobs always deliver regardless of the `[SILENT]` marker — only successful runs can be silenced. For quiet monitoring jobs, prompt the agent to reply with only `[SILENT]` when there is nothing to report. ## Script timeout Pre-run scripts (attached via the `script` parameter) have a default timeout of 3600 seconds (1 hour). This bounds the **script only** — skill-based / LLM-driven jobs run on a separate inactivity budget and are not capped by this value. If your scripts need a different limit, you can change it: ```yaml # ~/.claway/config.yaml cron: script_timeout_seconds: 1800 # 30 minutes ``` Or set the `CLAWAY_CRON_SCRIPT_TIMEOUT` environment variable. The resolution order is: env var → config.yaml → 3600s default. ## No-agent mode (script-only jobs) For recurring jobs that don't need LLM reasoning — classic watchdogs, disk/memory alerts, heartbeats, CI pings — pass `no_agent=True` at creation time. The scheduler runs your script on schedule and delivers its stdout directly, skipping the agent entirely: ```bash claway cron create "every 5m" \ --no-agent \ --script memory-watchdog.sh \ --deliver telegram \ --name "memory-watchdog" ``` Semantics: - Script stdout (trimmed) → delivered verbatim as the message. - **Empty stdout → silent tick**, no delivery. This is the watchdog pattern: "only say something when something is wrong". - Non-zero exit or timeout → an error alert is delivered, so a broken watchdog can't fail silently. - `{"wakeAgent": false}` on the last line → silent tick (same gate LLM jobs use). - No tokens, no model, no provider fallback — the job never touches the inference layer. `.sh` / `.bash` files run under `/bin/bash`; anything else under the current Python interpreter (`sys.executable`). Scripts must live in `~/.claway/scripts/` (same sandboxing rule as the pre-run script gate). ### The agent sets these up for you The `cronjob` tool's schema exposes `no_agent` to Claway directly, so you can describe a watchdog in chat and let the agent wire it up: ```text Ping me on Telegram if RAM is over 85%, every 5 minutes. ``` Claway will write the check script to `~/.claway/scripts/` via `write_file`, then call: ```python cronjob(action="create", schedule="every 5m", script="memory-watchdog.sh", no_agent=True, deliver="telegram", name="memory-watchdog") ``` It picks `no_agent=True` automatically when the message content is fully determined by the script (watchdogs, threshold alerts, heartbeats). The same tool also lets the agent pause, resume, edit, and remove jobs — so the whole lifecycle is chat-driven without anyone touching the CLI. See the [Script-Only Cron Jobs guide](/guides/cron-script-only) for worked examples. ## Chaining jobs with `context_from` Cron jobs run in isolated sessions with no memory of previous runs. But sometimes one job's output is exactly what the next job needs. The `context_from` parameter wires that connection automatically — Job B's prompt gets Job A's most recent output prepended as context at runtime. ```python # Job 1: Collect raw data cronjob( action="create", prompt="Fetch the top 10 AI/ML stories from Hacker News. Save them to ~/.claway/data/briefs/raw.md in markdown format with title, URL, and score.", schedule="0 7 * * *", name="AI News Collector", ) # Job 2: Triage — receives Job 1's output as context # Get Job 1's ID from: cronjob(action="list") cronjob( action="create", prompt="Read ~/.claway/data/briefs/raw.md. Score each story 1–10 for engagement potential and novelty. Output the top 5 to ~/.claway/data/briefs/ranked.md.", schedule="30 7 * * *", context_from="<job1_id>", name="AI News Triage", ) # Job 3: Ship — receives Job 2's output as context cronjob( action="create", prompt="Read ~/.claway/data/briefs/ranked.md. Write 3 tweet drafts (hook + body + hashtags). Deliver to telegram:7976161601.", schedule="0 8 * * *", context_from="<job2_id>", name="AI News Brief", ) ``` **How it works:** - When Job 2 fires, Claway reads Job 1's most recent output from `~/.claway/cron/output/{job1_id}/*.md` - That output is prepended to Job 2's prompt automatically - Job 2 doesn't need to hardcode "read this file" — it receives the content as context - The chain can be any length: Job 1 → Job 2 → Job 3 → ... **What `context_from` accepts:** | Format | Example | |--------|---------| | Single job ID (string) | `context_from="a1b2c3d4"` | | Multiple job IDs (list) | `context_from=["job_a", "job_b"]` | Outputs are concatenated in the order listed. **When to use it:** - Multi-stage pipelines (collect → filter → format → deliver) - Dependent tasks where step N's work depends on step N−1's output - Fan-out/fan-in patterns where one job aggregates results from several others ## Provider recovery Cron jobs inherit your configured fallback providers and credential pool rotation. If the primary API key is rate-limited or the provider returns an error, the cron agent can: - **Fall back to an alternate provider** if you have `fallback_providers` (or the legacy `fallback_model`) configured in `config.yaml` - **Rotate to the next credential** in your [credential pool](/user-guide/configuration#credential-pool-strategies) for the same provider This means cron jobs that run at high frequency or during peak hours are more resilient — a single rate-limited key won't fail the entire run. ## Schedule formats The agent's final response is automatically delivered to the job's `deliver:` target — the agent no longer fires messages itself, so the user-facing content simply goes in the final response. To deliver to **additional or different** targets, list multiple `deliver:` targets on the cron job (comma-separated, e.g. `deliver: "telegram,discord"`) rather than having the agent send them. ### Relative delays (one-shot) ```text 30m → Run once in 30 minutes 2h → Run once in 2 hours 1d → Run once in 1 day ``` ### Intervals (recurring) ```text every 30m → Every 30 minutes every 2h → Every 2 hours every 1d → Every day ``` ### Cron expressions ```text 0 9 * * * → Daily at 9:00 AM 0 9 * * 1-5 → Weekdays at 9:00 AM 0 */6 * * * → Every 6 hours 30 8 1 * * → First of every month at 8:30 AM 0 0 * * 0 → Every Sunday at midnight ``` ### ISO timestamps ```text 2026-03-15T09:00:00 → One-time at March 15, 2026 9:00 AM ``` ## Repeat behavior | Schedule type | Default repeat | Behavior | |--------------|----------------|----------| | One-shot (`30m`, timestamp) | 1 | Runs once | | Interval (`every 2h`) | forever | Runs until removed | | Cron expression | forever | Runs until removed | You can override it: ```python cronjob( action="create", prompt="...", schedule="every 2h", repeat=5, ) ``` ## Managing jobs programmatically The agent-facing API is one tool: ```python cronjob(action="create", ...) cronjob(action="list") cronjob(action="update", job_id="...") cronjob(action="pause", job_id="...") cronjob(action="resume", job_id="...") cronjob(action="run", job_id="...") cronjob(action="remove", job_id="...") ``` For `update`, pass `skills=[]` to remove all attached skills. ## Toolsets available to cron jobs Cron runs each job in a fresh agent session with no chat platform attached. By default the cron agent gets **the toolset you configured for the `cron` platform in `claway tools`** — not the CLI default, not everything under the sun. ```bash claway tools # → pick the "cron" platform in the curses UI # → toggle toolsets on/off just like you would for Telegram/Discord/etc. ``` Tighter per-job control is available via the `enabled_toolsets` field on `cronjob.create` (or on an existing job via `cronjob.update`): ```text cronjob(action="create", name="weekly-news-summary", schedule="every sunday 9am", enabled_toolsets=["web", "file"], # just web + file, no terminal/browser/etc. prompt="Summarize this week's AI news: ...") ``` When `enabled_toolsets` is set on a job it wins; otherwise the `claway tools` cron-platform config wins; otherwise Claway falls back to the built-in defaults. This matters for cost control: carrying `browser`, `delegation` into every tiny "fetch news" job bloats the tool-schema prompt on every LLM call. ### Skipping the agent entirely: `wakeAgent` If your cron job attaches a pre-check script (via `script=`), the script can decide at runtime whether Claway should even invoke the agent. Emit a final stdout line of the form: ```text {"wakeAgent": false} ``` …and cron skips the agent run entirely for this tick. Useful for frequent polls (every 1–5 min) that only need to wake the LLM when state actually changed — otherwise you pay for zero-content agent turns over and over. ```python # pre-check script import json, sys latest = fetch_latest_issue_count() prev = read_state("issue_count") if latest == prev: print(json.dumps({"wakeAgent": False})) # skip this tick sys.exit(0) write_state("issue_count", latest) print(json.dumps({"wakeAgent": True, "context": {"new_issues": latest - prev}})) ``` When `wakeAgent` is omitted, the default is `true` (wake the agent as usual). #### Recipes: cheap pre-run gates The `wakeAgent` gate gives you a $0 way to decide whether a scheduled job should spend any LLM tokens at all. Three patterns cover most use cases. **File-change gate** — only run when a watched file has new content since the last successful tick. The scheduler records each job's `last_run_at`; compare it against the file's mtime. ```bash #!/bin/bash # ~/.claway/scripts/feed-changed.sh FEED="$HOME/data/feed.json" STATE="$HOME/.claway/scripts/.feed-changed.last" test -f "$FEED" || { echo '{"wakeAgent": false}'; exit 0; } mtime=$(stat -c %Y "$FEED") last=$(cat "$STATE" 2>/dev/null || echo 0) if [ "$mtime" -le "$last" ]; then echo '{"wakeAgent": false}' else echo "$mtime" > "$STATE" echo '{"wakeAgent": true}' fi ``` ```text cronjob(action="create", name="process-feed", schedule="every 30m", script="feed-changed.sh", prompt="A new ~/data/feed.json has landed. Summarize what changed.") ``` **External-flag gate** — only run when some other process has signalled readiness (e.g. a deploy hook drops a file, a CI job sets a value in your state store). ```bash #!/bin/bash # ~/.claway/scripts/flag-ready.sh if test -f /tmp/new-data-ready; then rm -f /tmp/new-data-ready echo '{"wakeAgent": true}' else echo '{"wakeAgent": false}' fi ``` ```text cronjob(action="create", name="nightly-analysis", schedule="0 9 * * *", script="flag-ready.sh", prompt="Run the nightly analysis over today's batch.") ``` **SQL-count gate** — only run when there are new rows to process in your own database. The script can also pass the count through to the agent via `context`, so the agent knows how much it's looking at without re-querying. ```python #!/usr/bin/env python # ~/.claway/scripts/new-rows.py import json, sqlite3 conn = sqlite3.connect("/home/me/data/app.db") n = conn.execute( "SELECT COUNT(*) FROM messages WHERE ts > strftime('%s','now','-2 hours')" ).fetchone()[0] if n < 1: print(json.dumps({"wakeAgent": False})) else: print(json.dumps({"wakeAgent": True, "context": {"new_rows": n}})) ``` ```text cronjob(action="create", name="summarize-new-msgs", schedule="every 2h", script="new-rows.py", prompt="Summarize the new messages from the last 2 hours.") ``` The same pattern works for any data source you can query from a script — Postgres, an HTTP API, your own state store — without baking a SQL evaluator into the cron subsystem. :::tip Claway's own `~/.claway/state.db` is an internal schema that changes between releases. Don't query it from a pre-run gate — point at your own database or feed instead. ::: ### Chaining jobs: `context_from` A cron job can consume the most recent successful output of one or more other jobs by listing their names (or IDs) in `context_from`: ```text cronjob(action="create", name="daily-digest", schedule="every day 7am", context_from=["ai-news-fetch", "github-prs-fetch"], prompt="Write the daily digest using the outputs above.") ``` The referenced jobs' most recent completed outputs are injected above the prompt as context for this run. Each upstream entry must be a valid job ID or name (see `cronjob action="list"`). Note: chaining reads the *most recent completed* output — it does not wait for upstream jobs that are running in the same tick. ## Job storage Jobs are stored in `~/.claway/cron/jobs.json`. Output from job runs is saved to `~/.claway/cron/output/{job_id}/{timestamp}.md`. Jobs may store `model` and `provider` as `null`. When those fields are omitted, Claway resolves them at execution time from the global configuration. They only appear in the job record when a per-job override is set. The storage uses atomic file writes so interrupted writes do not leave a partially written job file behind. ## Self-contained prompts still matter :::warning Important Cron jobs run in a completely fresh agent session. The prompt must contain everything the agent needs that is not already provided by attached skills. ::: **BAD:** `"Check on that server issue"` **GOOD:** `"SSH into server 192.168.1.100 as user 'deploy', check if nginx is running with 'systemctl status nginx', and verify https://example.com returns HTTP 200."` ## Security Scheduled task prompts are scanned for prompt-injection and credential-exfiltration patterns at creation and update time. Prompts containing invisible Unicode tricks, SSH backdoor attempts, or obvious secret-exfiltration payloads are blocked. --- <!-- source: website/docs/user-guide/features/delegation.md --> # Subagent Delegation # Subagent Delegation The `delegate_task` tool spawns child AIAgent instances with isolated context, restricted toolsets, and their own terminal sessions. Each child gets a fresh conversation and works independently — only its final summary enters the parent's context. ## Single Task ```python delegate_task( goal="Debug why tests fail", context="Error: assertion in test_foo.py line 42", toolsets=["terminal", "file"] ) ``` ## Parallel Batch Up to 3 concurrent subagents by default (configurable, no hard ceiling): ```python delegate_task(tasks=[ {"goal": "Research topic A", "toolsets": ["web"]}, {"goal": "Research topic B", "toolsets": ["web"]}, {"goal": "Fix the build", "toolsets": ["terminal", "file"]} ]) ``` ## How Subagent Context Works :::warning Critical: Subagents Know Nothing Subagents start with a **completely fresh conversation**. They have zero knowledge of the parent's conversation history, prior tool calls, or anything discussed before delegation. The subagent's only context comes from the `goal` and `context` fields the parent agent populates when it calls `delegate_task`. ::: This means the parent agent must pass **everything** the subagent needs in the call: ```python # BAD - subagent has no idea what "the error" is delegate_task(goal="Fix the error") # GOOD - subagent has all context it needs delegate_task( goal="Fix the TypeError in api/handlers.py", context="""The file api/handlers.py has a TypeError on line 47: 'NoneType' object has no attribute 'get'. The function process_request() receives a dict from parse_body(), but parse_body() returns None when Content-Type is missing. The project is at /home/user/myproject and uses Python 3.11.""" ) ``` The subagent receives a focused system prompt built from your goal and context, instructing it to complete the task and provide a structured summary of what it did, what it found, any files modified, and any issues encountered. ## Practical Examples ### Parallel Research Research multiple topics simultaneously and collect summaries: ```python delegate_task(tasks=[ { "goal": "Research the current state of WebAssembly in 2025", "context": "Focus on: browser support, non-browser runtimes, language support", "toolsets": ["web"] }, { "goal": "Research the current state of RISC-V adoption in 2025", "context": "Focus on: server chips, embedded systems, software ecosystem", "toolsets": ["web"] }, { "goal": "Research quantum computing progress in 2025", "context": "Focus on: error correction breakthroughs, practical applications, key players", "toolsets": ["web"] } ]) ``` ### Code Review + Fix Delegate a review-and-fix workflow to a fresh context: ```python delegate_task( goal="Review the authentication module for security issues and fix any found", context="""Project at /home/user/webapp. Auth module files: src/auth/login.py, src/auth/jwt.py, src/auth/middleware.py. The project uses Flask, PyJWT, and bcrypt. Focus on: SQL injection, JWT validation, password handling, session management. Fix any issues found and run the test suite (pytest tests/auth/).""", toolsets=["terminal", "file"] ) ``` ### Multi-File Refactoring Delegate a large refactoring task that would flood the parent's context: ```python delegate_task( goal="Refactor all Python files in src/ to replace print() with proper logging", context="""Project at /home/user/myproject. Use the 'logging' module with logger = logging.getLogger(__name__). Replace print() calls with appropriate log levels: - print(f"Error: ...") -> logger.error(...) - print(f"Warning: ...") -> logger.warning(...) - print(f"Debug: ...") -> logger.debug(...) - Other prints -> logger.info(...) Don't change print() in test files or CLI output. Run pytest after to verify nothing broke.""", toolsets=["terminal", "file"] ) ``` ## Batch Mode Details When you provide a `tasks` array, subagents run in **parallel** using a thread pool: - **Maximum concurrency:** 3 tasks by default (configurable via `delegation.max_concurrent_children` or the `DELEGATION_MAX_CONCURRENT_CHILDREN` env var; floor of 1, no hard ceiling). Batches larger than the limit return a tool error rather than being silently truncated. - **Thread pool:** Uses `ThreadPoolExecutor` with the configured concurrency limit as max workers - **Progress display:** In CLI mode, a tree-view shows tool calls from each subagent in real-time with per-task completion lines. In gateway mode, progress is batched and relayed to the parent's progress callback - **Result ordering:** Results are sorted by task index to match input order regardless of completion order - **Interrupt propagation:** Interrupting the parent (e.g., sending a new message) interrupts all active children Single-task delegation runs directly without thread pool overhead. ## Model Override You can configure a different model for subagents via `config.yaml` — useful for delegating simple tasks to cheaper/faster models: ```yaml # In ~/.claway/config.yaml delegation: model: "google/gemini-flash-2.0" # Cheaper model for subagents provider: "openrouter" # Optional: route subagents to a different provider ``` If omitted, subagents use the same model as the parent. ## Toolset Selection Tips The `toolsets` parameter controls what tools the subagent has access to. Choose based on the task: | Toolset Pattern | Use Case | |----------------|----------| | `["terminal", "file"]` | Code work, debugging, file editing, builds | | `["web"]` | Research, fact-checking, documentation lookup | | `["terminal", "file", "web"]` | Full-stack tasks (default) | | `["file"]` | Read-only analysis, code review without execution | | `["terminal"]` | System administration, process management | Certain toolsets are blocked for subagents regardless of what you specify: - `delegation` — blocked for leaf subagents (the default). Retained for `role="orchestrator"` children, bounded by `max_spawn_depth` — see [Depth Limit and Nested Orchestration](#depth-limit-and-nested-orchestration) below. - `clarify` — subagents cannot interact with the user - `memory` — no writes to shared persistent memory - `code_execution` — children should reason step-by-step ## Max Iterations Each subagent has an iteration limit (default: 50) that controls how many tool-calling turns it can take: ```python delegate_task( goal="Quick file check", context="Check if /etc/nginx/nginx.conf exists and print its first 10 lines", max_iterations=10 # Simple task, don't need many turns ) ``` ## Child Timeout By default there is **no wall-clock timeout** on subagents. Children fail only from what they're actually doing — API errors, tool errors, or hitting their iteration budget — never from a delegation-level stopwatch. Earlier releases shipped a hard cap (300s, later 600s), which kept killing legitimately busy children mid-task: deep code reviews, large research fan-outs, and slow reasoning models routinely need more than 10 minutes while making steady progress the whole time. Genuinely stuck children are still detected: the heartbeat staleness monitor stops refreshing the parent's activity when a child makes no progress (no API calls, no tool starts), letting the gateway inactivity timeout fire on a truly wedged worker. If you want a hard cap anyway (e.g. cost control on unattended cron-driven delegation), opt in per-install: ```yaml delegation: child_timeout_seconds: 0 # default: 0 = no timeout # child_timeout_seconds: 1800 # opt-in hard cap (floor 30s) ``` A positive value enforces a hard wall-clock limit on each child; `0` or a negative value disables it. :::tip Diagnostic dump on zero-call timeout With a hard cap configured, if a subagent times out having made **zero** API calls (usually: provider unreachable, auth failure, or tool-schema rejection), `delegate_task` writes a structured diagnostic to `~/.claway/logs/subagent-timeout-<session>-<timestamp>.log` containing the subagent's config snapshot, credential-resolution trace, and any early error messages. Much easier to root-cause than the previous silent-timeout behavior. ::: ## Monitoring Running Subagents (`/agents`) The TUI ships a `/agents` overlay (alias `/tasks`) that turns recursive `delegate_task` fan-out into a first-class audit surface: - Live tree view of running and recently-finished subagents, grouped by parent - Per-branch cost, token, and file-touched rollups - Kill and pause controls — cancel a specific subagent mid-flight without interrupting its siblings - Post-hoc review: step through each subagent's turn-by-turn history even after they've returned to the parent The classic CLI just prints `/agents` as a text summary; the TUI is where the overlay shines. See [TUI — Slash commands](/user-guide/tui#slash-commands). ## Depth Limit and Nested Orchestration By default, delegation is **flat**: a parent (depth 0) spawns children (depth 1), and those children cannot delegate further. This prevents runaway recursive delegation. For multi-stage workflows (research → synthesis, or parallel orchestration over sub-problems), a parent can spawn **orchestrator** children that *can* delegate their own workers: ```python delegate_task( goal="Survey three code review approaches and recommend one", role="orchestrator", # Allows this child to spawn its own workers context="...", ) ``` - `role="leaf"` (default): child cannot delegate further — identical to the flat-delegation behavior. - `role="orchestrator"`: child retains the `delegation` toolset. Gated by `delegation.max_spawn_depth` (default **1** = flat, so `role="orchestrator"` is a no-op at defaults). Raise `max_spawn_depth` to 2 to allow orchestrator children to spawn leaf grandchildren; 3+ for deeper trees. There is no upper ceiling — cost is the practical limit. - `delegation.orchestrator_enabled: false`: global kill switch that forces every child to `leaf` regardless of the `role` parameter. **Cost warning:** With `max_spawn_depth: 3` and `max_concurrent_children: 3`, the tree can reach 3×3×3 = 27 concurrent leaf agents. Each extra level multiplies spend — raise `max_spawn_depth` intentionally. ## Lifetime and Durability :::warning delegate_task is synchronous — not durable `delegate_task` runs **inside the parent's current turn**. It blocks the parent until every child finishes (or is cancelled). It is **not** a background job queue: - If the parent is interrupted (user sends a new message, `/stop`, `/new`), all active children are cancelled and return `status="interrupted"`. Their in-progress work is discarded. - Children do **not** continue running after the parent turn ends. - Cancelled children return a structured result (`status="interrupted"`, `exit_reason="interrupted"`), but because the parent was interrupted too, that result often never makes it into a user-visible reply. For **durable long-running work** that must survive interrupts or outlive the current turn, use: - `cronjob` (action=`create`) — schedules a separate agent run; immune to parent-turn interrupts. - `terminal(background=True, notify_on_complete=True)` — long-running shell commands that keep running while the agent does other things. ::: ## Key Properties - Each subagent gets its **own terminal session** (separate from the parent) - **Nested delegation is opt-in** — only `role="orchestrator"` children can delegate further, and only when `max_spawn_depth` is raised from its default of 1 (flat). Disable globally with `orchestrator_enabled: false`. - Leaf subagents **cannot** call: `delegate_task`, `clarify`, `memory`, `execute_code`. Orchestrator subagents retain `delegate_task` but still cannot use the other three. - **Interrupt propagation** — interrupting the parent interrupts all active children (including grandchildren under orchestrators) - Only the final summary enters the parent's context, keeping token usage efficient - Subagents inherit the parent's **API key, provider configuration, and credential pool** (enabling key rotation on rate limits) ## Delegation vs execute_code | Factor | delegate_task | execute_code | |--------|--------------|-------------| | **Reasoning** | Full LLM reasoning loop | Just Python code execution | | **Context** | Fresh isolated conversation | No conversation, just script | | **Tool access** | All non-blocked tools with reasoning | 7 tools via RPC, no reasoning | | **Parallelism** | 3 concurrent subagents by default (configurable) | Single script | | **Best for** | Complex tasks needing judgment | Mechanical multi-step pipelines | | **Token cost** | Higher (full LLM loop) | Lower (only stdout returned) | | **User interaction** | None (subagents can't clarify) | None | **Rule of thumb:** Use `delegate_task` when the subtask requires reasoning, judgment, or multi-step problem solving. Use `execute_code` when you need mechanical data processing or scripted workflows. ## Configuration ```yaml # In ~/.claway/config.yaml delegation: max_iterations: 50 # Max turns per child (default: 50) # max_concurrent_children: 3 # Parallel children per batch (default: 3) # max_spawn_depth: 1 # Tree depth (floor 1, no ceiling, default 1 = flat). Raise to 2 to allow orchestrator children to spawn leaves; 3+ for deeper trees. # orchestrator_enabled: true # Disable to force all children to leaf role. model: "google/gemini-3-flash-preview" # Optional provider/model override provider: "openrouter" # Optional built-in provider api_mode: anthropic_messages # optional; auto-detected from base_url for anthropic_messages endpoints # Or use a direct custom endpoint instead of provider: delegation: model: "qwen2.5-coder" base_url: "http://localhost:1234/v1" api_key: "local-key" # api_mode: "anthropic_messages" # Optional. Wire protocol override for base_url ("chat_completions", "codex_responses", or "anthropic_messages"). Empty = auto-detect from URL (e.g. /anthropic suffix). Set explicitly for endpoints the heuristic can't classify (Azure AI Foundry, MiniMax, Zhipu GLM, LiteLLM proxies, …). ``` When `base_url` points at an Anthropic-compatible endpoint — for example a path ending in `/anthropic`, an Azure Foundry Claude route, or a MiniMax `/anthropic` proxy — `api_mode` is auto-detected as `anthropic_messages` so the subagent uses the right wire format without you setting anything. Set `api_mode` explicitly when the auto-detection guess is wrong (rare). :::tip The agent handles delegation automatically based on the task complexity. You don't need to explicitly ask it to delegate — it will do so when it makes sense. ::: --- <!-- source: website/docs/user-guide/features/kanban.md --> # Kanban (Multi-Agent Board) # Kanban — Multi-Agent Profile Collaboration Claway Kanban is a durable task board, shared across all your Claway profiles, that lets multiple named agents collaborate on work without fragile in-process subagent swarms. Every task is a row in `~/.claway/kanban.db`; every handoff is a row anyone can read and write; every worker is a full OS process with its own identity. ### Two surfaces: the model talks through tools, you talk through the CLI The board has two front doors, both backed by the same `~/.claway/kanban.db`: - **Agents drive the board through a dedicated `kanban_*` toolset** — `kanban_show`, `kanban_list`, `kanban_complete`, `kanban_block`, `kanban_heartbeat`, `kanban_comment`, `kanban_create`, `kanban_link`, `kanban_unblock`. The dispatcher spawns each worker with these tools already in its schema; orchestrator profiles can also enable the `kanban` toolset explicitly. The model reads and routes tasks by calling tools directly, *not* by shelling out to `claway kanban`. See [How workers interact with the board](#how-workers-interact-with-the-board) below. - **You (and scripts, and cron) drive the board through `claway kanban …`** on the CLI, `/kanban …` as a slash command, or the dashboard. These are for humans and automation — the places without a tool-calling model behind them. Both surfaces route through the same `kanban_db` layer, so reads see a consistent view and writes can't drift. The rest of this page shows CLI examples because they're easy to copy-paste, but every CLI verb has a tool-call equivalent the model uses. This is the shape that covers the workloads `delegate_task` can't: - **Research triage** — parallel researchers + analyst + writer, human-in-the-loop. - **Scheduled ops** — recurring daily briefs that build a journal over weeks. - **Digital twins** — persistent named assistants (`inbox-triage`, `ops-review`) that accumulate memory over time. - **Engineering pipelines** — decompose → implement in parallel worktrees → review → iterate → PR. - **Fleet work** — one specialist managing N subjects (50 social accounts, 12 monitored services). For the full design rationale, comparative analysis against Cline Kanban / Paperclip / NanoClaw / Google Gemini Enterprise, and the eight canonical collaboration patterns, see `docs/claway-kanban-v1-spec.pdf` in the repository. ## Kanban vs. `delegate_task` They look similar; they are not the same primitive. | | `delegate_task` | Kanban | |---|---|---| | Shape | RPC call (fork → join) | Durable message queue + state machine | | Parent | Blocks until child returns | Fire-and-forget after `create` | | Child identity | Anonymous subagent | Named profile with persistent memory | | Resumability | None — failed = failed | Block → unblock → re-run; crash → reclaim | | Human in the loop | Not supported | Comment / unblock at any point | | Agents per task | One call = one subagent | N agents over task's life (retry, review, follow-up) | | Audit trail | Lost on context compression | Durable rows in SQLite forever | | Coordination | Hierarchical (caller → callee) | Peer — any profile reads/writes any task | **One-sentence distinction:** `delegate_task` is a function call; Kanban is a work queue where every handoff is a row any profile (or human) can see and edit. **Use `delegate_task` when** the parent agent needs a short reasoning answer before continuing, no humans involved, result goes back into the parent's context. **Use Kanban when** work crosses agent boundaries, needs to survive restarts, might need human input, might be picked up by a different role, or needs to be discoverable after the fact. They coexist: a kanban worker may call `delegate_task` internally during its run. ## Core concepts - **Board** — a standalone queue of tasks with its own SQLite DB, workspaces directory, and dispatcher loop. A single install can have many boards (e.g. one per project, repo, or domain); see [Boards (multi-project)](#boards-multi-project) below. Single-project users stay on the `default` board and never see the word "board" outside this docs section. - **Task** — a row with title, optional body, one assignee (a profile name), status (`triage | todo | ready | running | blocked | done | archived`), optional tenant namespace, optional idempotency key (dedup for retried automation). - **Link** — `task_links` row recording a parent → child dependency. The dispatcher promotes `todo → ready` when all parents are `done`. - **Comment** — the inter-agent protocol. Agents and humans append comments; when a worker is (re-)spawned it reads the full comment thread as part of its context. - **Workspace** — the directory a worker operates in. Three kinds: - `scratch` (default) — fresh tmp dir under `~/.claway/kanban/workspaces/<id>/` (or `~/.claway/kanban/boards/<slug>/workspaces/<id>/` on non-default boards). **Deleted when the task completes** — scratch is ephemeral by design, so the dir is wiped the moment the worker (or `claway kanban complete <id>`) marks the task done. If you want to keep the worker's output, use `worktree:` or `dir:<path>` instead. The first time a scratch workspace is created on an install, the dispatcher logs a warning and emits a `tip_scratch_workspace` event on the task (visible via `claway kanban show <id>`). - `dir:<path>` — an existing shared directory (Obsidian vault, mail ops dir, per-account folder). **Must be an absolute path.** Relative paths like `dir:../tenants/foo/` are rejected at dispatch because they'd resolve against whatever CWD the dispatcher happens to be in, which is ambiguous and a confused-deputy escape vector. The path is otherwise trusted — it's your box, your filesystem, the worker runs with your uid. This is the trusted-local-user threat model; kanban is single-host by design. **Preserved on completion.** - `worktree` — a git worktree under `.worktrees/<id>/` for coding tasks. Use `worktree:<path>` to pin the exact target path. Worker-side `git worktree add` creates it, using `--branch` when provided. **Preserved on completion.** - **Dispatcher** — a long-lived loop that, every N seconds (default 60): reclaims stale claims, reclaims crashed workers (PID gone but TTL not yet expired), promotes ready tasks, atomically claims, spawns assigned profiles. Runs **inside the gateway** by default (`kanban.dispatch_in_gateway: true`). One dispatcher sweeps all boards per tick; workers are spawned with `CLAWAY_KANBAN_BOARD` pinned so they can't see other boards. After `kanban.failure_limit` consecutive spawn failures on the same task (default: 2) the dispatcher auto-blocks it with the last error as the reason — prevents thrashing on tasks whose profile doesn't exist, workspace can't mount, etc. - **Tenant** — optional string namespace *within* a board. One specialist fleet can serve multiple businesses (`--tenant business-a`) with data isolation by workspace path and memory key prefix. Tenants are a soft filter; boards are the hard isolation boundary. ## Boards (multi-project) Boards let you separate unrelated streams of work — one per project, repo, or domain — into isolated queues. A new install has exactly one board called `default` (DB at `~/.claway/kanban.db` for back-compat). Users who only want one stream of work never need to know about boards; the feature is opt-in. Per-board isolation is absolute: - Separate SQLite DB per board (`~/.claway/kanban/boards/<slug>/kanban.db`). - Separate `workspaces/` and `logs/` directories. - Workers spawned for a task see **only** their board's tasks — the dispatcher sets `CLAWAY_KANBAN_BOARD` in the child env and every `kanban_*` tool the worker has access to reads it. - Linking tasks across boards is not allowed (keeps the schema simple; if you really need cross-project refs, use free-text mentions and look them up by id manually). ### Managing boards from the CLI ```bash # See what's on disk. Fresh installs show only "default". claway kanban boards list # Create a new board. claway kanban boards create atm10-server \ --name "ATM10 Server" \ --description "Minecraft modded server ops" \ --icon 🎮 \ --switch # optional: make it the active board # Operate on a specific board without switching. claway kanban --board atm10-server list claway kanban --board atm10-server create "Restart ATM server" --assignee ops # Change which board is "current" for subsequent calls. claway kanban boards switch atm10-server claway kanban boards show # who's active right now? # Rename the display name (the slug is immutable — it's the directory name). claway kanban boards rename atm10-server "ATM10 (Prod)" # Archive (default) — moves the board's dir to boards/_archived/<slug>-<ts>/. # Recoverable by moving the dir back. claway kanban boards rm atm10-server # Hard delete — `rm -rf` the board dir. No recovery. claway kanban boards rm atm10-server --delete ``` Board resolution order (highest precedence first): 1. Explicit `--board <slug>` on the CLI call. 2. `CLAWAY_KANBAN_BOARD` env var (set by the dispatcher when spawning a worker, so workers can't see other boards). 3. `~/.claway/kanban/current` — the slug persisted by `claway kanban boards switch`. 4. `default`. Slugs are validated: lowercase alphanumerics + hyphens + underscores, 1-64 chars, must start with alphanumeric. Uppercase input is auto-downcased. Anything else (slashes, spaces, dots, `..`) is rejected at the CLI layer so path-traversal tricks can't name a board. ### Managing boards from the dashboard `claway dashboard` → Kanban tab shows a board switcher at the top as soon as more than one board exists (or any board has tasks). Single-board users see only a small `+ New board` button; the switcher is hidden until it matters. - **Board dropdown** — pick the active board. Your selection is saved to the browser's `localStorage` so it persists across reloads without shifting the CLI's `current` pointer out from under a terminal you left open. - **+ New board** — opens a modal asking for slug, display name, description, and icon. Option to auto-switch to the new board. - **Archive** — only shown on non-`default` boards. Confirms, then moves the board dir to `boards/_archived/`. All dashboard API endpoints accept `?board=<slug>` for board scoping. The events WebSocket is pinned to a board at connection time; switching in the UI opens a fresh WS against the new board. ## File attachments Tasks can carry file attachments — PDFs, images, source documents — so a worker has the source material it needs without you pasting paths into the body and hoping it finds them. - **Upload** — open a task in the dashboard drawer and use the **Attachments** section's *Upload file* button (multiple files at once are fine). Each upload is capped at 25 MB. - **Storage** — files land under `<claway-home>/kanban/attachments/<task_id>/` for the default board, or `<claway-home>/kanban/boards/<slug>/attachments/<task_id>/` for a named board. Set `CLAWAY_KANBAN_ATTACHMENTS_ROOT` to pin a custom location. - **What the worker sees** — when the dispatcher hands a task to a worker, the worker's context includes an **Attachments** section listing each file's name and its **absolute path**. The worker has full file/terminal tool access, so it reads attachments directly (`read_file`, or shell tools like `pdftotext`). - **Download / remove** — the drawer lists each attachment with a download link and a remove (×) control. Removing an attachment deletes both the metadata row and the on-disk file. :::note Remote terminal backends Attachment paths resolve directly on the **local** terminal backend, which is the default for Kanban workers. If you run workers on a remote backend (Docker, Modal), mount the board's `attachments/` directory into the sandbox so the absolute paths in the worker context are reachable. ::: ## Quick start The commands below are **you** (the human) setting up the board and creating tasks. Once a task is assigned, the dispatcher spawns the assigned profile as a worker, and from there **the model drives the task through `kanban_*` tool calls, not CLI commands** — see [How workers interact with the board](#how-workers-interact-with-the-board). ```bash # 1. Create the board (you) claway kanban init # 2. Start the gateway (hosts the embedded dispatcher) claway gateway start # 3. Create a task (you — or an orchestrator agent via kanban_create) claway kanban create "research AI funding landscape" --assignee researcher # 4. Watch activity live (you) claway kanban watch # 5. See the board (you) claway kanban list claway kanban stats ``` When the dispatcher picks up `t_abcd` and spawns the `researcher` profile, the very first thing that worker's model does is call `kanban_show()` to read its task. It doesn't run `claway kanban show t_abcd`. ### Gateway-embedded dispatcher (default) The dispatcher runs inside the gateway process. Nothing to install, no separate service to manage — if the gateway is up, ready tasks get picked up on the next tick (60s by default). ```yaml # config.yaml kanban: dispatch_in_gateway: true # default dispatch_interval_seconds: 60 # default ``` Override the config flag at runtime via `CLAWAY_KANBAN_DISPATCH_IN_GATEWAY=0` for debugging. Standard gateway supervision applies: run `claway gateway start` directly, or wire the gateway up as a systemd user unit (see the gateway docs). Without a running gateway, `ready` tasks stay where they are until one comes up — `claway kanban create` warns about this at creation time. Running `claway kanban daemon` as a separate process is **deprecated**; use the gateway. If you truly cannot run the gateway (headless host policy forbids long-lived services, etc.) a `--force` escape hatch keeps the old standalone daemon alive for one release cycle, but running both a gateway-embedded dispatcher AND a standalone daemon against the same `kanban.db` causes claim races and is not supported. ### Idempotent create (for automation / webhooks) ```bash # First call creates the task. Any subsequent call with the same key # returns the existing task id instead of duplicating. claway kanban create "nightly ops review" \ --assignee ops \ --idempotency-key "nightly-ops-$(date -u +%Y-%m-%d)" \ --json ``` ### Bulk CLI verbs All the lifecycle verbs accept multiple ids so you can clean up a batch in one command: ```bash claway kanban complete t_abc t_def t_hij --result "batch wrap" claway kanban archive t_abc t_def t_hij claway kanban unblock t_abc t_def claway kanban block t_abc "need input" --ids t_def t_hij ``` ## How workers interact with the board **Workers do not shell out to `claway kanban`.** When the dispatcher spawns a worker it sets `CLAWAY_KANBAN_TASK=t_abcd` in the child's env, and that env var flips on a dedicated **kanban toolset** in the model's schema. The same toolset is also available to orchestrator profiles that enable `kanban` in their toolsets config. These tools read and mutate the board directly via the Python `kanban_db` layer, same as the CLI does. A running worker calls these like any other tool; it never sees or needs the `claway kanban` CLI. | Tool | Purpose | Required params | |---|---|---| | `kanban_show` | Read the current task (title, body, prior attempts, parent handoffs, comments, full pre-formatted `worker_context`). Defaults to the env's task id. | — | | `kanban_list` | List task summaries with filters for `assignee`, `status`, `tenant`, archived visibility, and limit. Intended for orchestrators discovering board work. | — | | `kanban_complete` | Finish with `summary` + `metadata` structured handoff. | at least one of `summary` / `result` | | `kanban_block` | Stop work and route by why: `kind=dependency` (waits in `todo`, auto-resumes), `needs_input`/`capability`/`transient` (surface to a human). Repeated same-kind re-blocks auto-escalate to `triage`. | `reason` | | `kanban_heartbeat` | Signal liveness during long operations. Pure side-effect. | — | | `kanban_comment` | Append a durable note to the task thread. | `task_id`, `body` | | `kanban_create` | (Orchestrators) fan out into child tasks with an `assignee`, optional `parents`, `skills`, etc. | `title`, `assignee` | | `kanban_link` | (Orchestrators) add a `parent_id → child_id` dependency edge after the fact. | `parent_id`, `child_id` | | `kanban_unblock` | (Orchestrators) move a blocked task back to `ready`. | `task_id` | A typical worker turn looks like: ``` # Model's tool calls, in order: kanban_show() # no args — uses CLAWAY_KANBAN_TASK # (model reads the returned worker_context, does the work via terminal/file tools) kanban_heartbeat(note="halfway through — 4 of 8 files transformed") # (more work) kanban_complete( summary="migrated limiter.py to token-bucket; added 14 tests, all pass", metadata={"changed_files": ["limiter.py", "tests/test_limiter.py"], "tests_run": 14}, ) ``` An **orchestrator** worker fans out instead: ``` kanban_show() kanban_create( title="research ICP funding 2024-2026", assignee="researcher-a", body="focus on seed + series A, North America, AI-adjacent", ) # → returns {"task_id": "t_r1", ...} kanban_create(title="research ICP funding — EU angle", assignee="researcher-b", body="…") # → returns {"task_id": "t_r2", ...} kanban_create( title="synthesize findings into launch brief", assignee="writer", parents=["t_r1", "t_r2"], # promotes to ready when both complete body="one-pager, 300 words, neutral tone", ) kanban_complete(summary="decomposed into 2 research tasks + 1 writer; linked dependencies") ``` The "(Orchestrators)" tools — `kanban_list`, `kanban_create`, `kanban_link`, `kanban_unblock`, and `kanban_comment` on foreign tasks — are available through the same toolset; the convention (encoded in the auto-injected kanban guidance) is that worker profiles don't fan out or route unrelated work, and orchestrator profiles don't execute implementation work. Dispatcher-spawned workers are still task-scoped for destructive lifecycle operations and cannot mutate unrelated tasks. ### Why tools instead of shelling to `claway kanban` Three reasons: 1. **Backend portability.** Workers whose terminal tool points at a remote backend (Docker / Modal / Singularity / SSH) would run `claway kanban complete` *inside* the container, where `claway` isn't installed and `~/.claway/kanban.db` isn't mounted. The kanban tools run in the agent's own Python process and always reach `~/.claway/kanban.db` regardless of terminal backend. 2. **No shell-quoting fragility.** Passing `--metadata '{"files": [...]}'` through shlex + argparse is a latent footgun. Structured tool args skip it entirely. 3. **Better errors.** Tool results are structured JSON the model can reason about, not stderr strings it has to parse. **Zero schema footprint on normal sessions.** A regular `claway chat` session has zero `kanban_*` tools in its schema unless the active profile explicitly enables the `kanban` toolset for orchestrator work. Dispatcher-spawned task workers get task-scoped tools because `CLAWAY_KANBAN_TASK` is set; orchestrator profiles get the broader routing surface through config. No tool bloat for users who never touch kanban. The auto-injected kanban guidance teaches the model which tool to call when and in what order. ### Recommended handoff evidence `kanban_complete(summary=..., metadata={...})` is intentionally flexible: the summary is the human-readable closeout, and `metadata` is the machine-readable handoff that downstream agents, reviewers, or dashboards can reuse without scraping prose. For engineering and review tasks, prefer this optional metadata shape: ```json { "changed_files": ["path/to/file.py"], "verification": ["pytest tests/claway_cli/test_kanban_db.py -q"], "dependencies": ["parent task id or external issue, if any"], "blocked_reason": null, "retry_notes": "what failed before, if this was a retry", "residual_risk": ["what was not tested or still needs human review"] } ``` These keys are a convention, not a schema requirement. The useful property is that every worker leaves enough evidence for the next reader to answer four questions quickly: 1. What changed? 2. How was it verified? 3. What can unblock or retry this if it fails? 4. What risk is still deliberately left open? Keep secrets, raw logs, tokens, OAuth material, and unrelated transcripts out of `metadata`. Store pointers and summaries instead. If a task has no files or tests, say so explicitly in `summary` and use `metadata` for the evidence that does exist, such as source URLs, issue ids, or manual review steps. ### The worker lifecycle Every profile that works kanban tasks automatically gets the worker lifecycle — it's injected into the worker's system prompt at spawn (the `KANBAN_GUIDANCE` block), so there is **nothing to install or configure**. It teaches the worker the full lifecycle in **tool calls**, not CLI commands: 1. On spawn, call `kanban_show()` to read title + body + parent handoffs + prior attempts + full comment thread. 2. `cd $CLAWAY_KANBAN_WORKSPACE` (via the terminal tool) and do the work there. 3. Call `kanban_heartbeat(note="...")` every few minutes during long operations. **If your work may run longer than 1 hour, call `kanban_heartbeat` at least once an hour** — the dispatcher reclaims tasks that have been running past `kanban.dispatch_stale_timeout_seconds` (default 4 h) with no heartbeat in the last hour, on the assumption the worker crashed without cleanup. A reclaim is benign (the task goes back to `ready` for re-dispatch without a failure-counter tick) but you lose your current run's progress. 4. Complete with `kanban_complete(summary="...", metadata={...})`, or `kanban_block(reason="...")` if stuck. That final `kanban_complete` / `kanban_block` call is part of the worker protocol. If the worker process exits with status 0 while the task is still `running`, the dispatcher treats that as a protocol violation, emits a `protocol_violation` event, and auto-blocks the task on the next tick instead of respawning it into the same loop. This usually means the model wrote a plain-text answer and exited without using the Kanban tool surface. The lifecycle plus the load-bearing reference details (workspace kinds, deliverable `artifacts`, claiming created cards) ship in that system-prompt block, so every worker has them regardless of which profile it runs under — no per-profile skill setup required. ### Pinning extra skills to a specific task Sometimes a single task needs specialist context the assignee profile doesn't carry by default — a translation job that needs the `translation` skill, a review task that needs `github-code-review`, a security audit that needs `security-pr-audit`. Rather than editing the assignee's profile every time, attach the skills directly to the task. **From an orchestrator agent** (the usual case — one agent routing work to another), use the `kanban_create` tool's `skills` array: ``` kanban_create( title="translate README to Japanese", assignee="linguist", skills=["translation"], ) kanban_create( title="audit auth flow", assignee="reviewer", skills=["security-pr-audit", "github-code-review"], ) ``` **From a human (CLI / slash command)**, repeat `--skill` for each one: ```bash claway kanban create "translate README to Japanese" \ --assignee linguist \ --skill translation claway kanban create "audit auth flow" \ --assignee reviewer \ --skill security-pr-audit \ --skill github-code-review ``` **From the dashboard**, type the skills comma-separated into the **skills** field of the inline create form. The dispatcher emits one `--skills <name>` flag per skill listed, so the worker spawns with all of them loaded on top of the auto-injected kanban guidance. The skill names must match skills that are actually installed on the assignee's profile (run `claway skills list` to see what's available); there's no runtime install. ### Goal-mode cards (`--goal`) By default each worker gets **one shot** at its card — do the work, call `kanban_complete`/`kanban_block`, exit. Pass `--goal` (CLI) or `goal_mode=True` (the `kanban_create` tool / dashboard) to instead run that worker in a **goal loop**, the same Ralph-style engine behind the `/goal` slash command: after every turn an auxiliary judge checks the worker's output against the card's title + body (treated as the acceptance criteria), and if the work isn't done — and the turn budget remains — the worker keeps going **in the same session** until the judge agrees, the worker terminates the task itself, or the budget runs out (which **blocks** the card for human review rather than exiting silently). ```bash claway kanban create "Translate the docs site to French" \ --body "Acceptance: every page translated, no English left, links intact." \ --assignee linguist \ --goal \ --goal-max-turns 15 # optional; default 20 ``` Use it for open-ended, multi-step, or "keep going until X is true" cards. Skip it for cheap one-shot work — the per-turn judge overhead isn't worth it, and the dispatcher's existing retry/circuit-breaker already handles transient worker failures. The judge is only as good as your goal text, so write the body as **explicit acceptance criteria**. ### How the orchestrator behaves A **well-behaved orchestrator does not do the work itself.** It decomposes the user's goal into tasks, links them, assigns each to one of the profiles you've set up, and steps back. The orchestrator guidance — anti-temptation rules, a Step-0 profile-discovery prompt (the dispatcher silently fails on unknown assignee names, so the orchestrator must ground every card in profiles that actually exist on your machine), and a decomposition playbook keyed on `kanban_create` / `kanban_link` / `kanban_comment` — is injected into the worker's system prompt automatically; there is nothing to install. A canonical orchestrator turn (two parallel researchers handing off to a writer): ``` # Goal from user: "draft a launch post on the ICP funding landscape" kanban_create(title="research ICP funding, NA angle", assignee="researcher-a", body="…") # → t_r1 kanban_create(title="research ICP funding, EU angle", assignee="researcher-b", body="…") # → t_r2 kanban_create( title="synthesize ICP funding research into launch post draft", assignee="writer", parents=["t_r1", "t_r2"], # promoted to 'ready' when both researchers complete body="one-pager, neutral tone, cite sources inline", ) # → t_w1 # Optional: add cross-cutting deps discovered later without re-creating tasks kanban_link(parent_id="t_r1", child_id="t_followup") kanban_complete( summary="decomposed into 2 parallel research tasks → 1 synthesis task; writer starts when both researchers finish", ) ``` The orchestrator guidance ships in the worker's system prompt automatically — there is nothing to install or sync per profile. For best results, pair it with a profile whose toolsets are restricted to board operations (`kanban`, `gateway`, `memory`) so the orchestrator literally cannot execute implementation tasks even if it tries. ## Dashboard (GUI) The `/kanban` CLI and slash command are enough to run the board headlessly, but a visual board is often the right interface for humans-in-the-loop: triage, cross-profile supervision, reading comment threads, and dragging cards between columns. Claway ships this as a **bundled dashboard plugin** at `plugins/kanban/` — not a core feature, not a separate service — following the model laid out in Extending the Dashboard. Open it with: ```bash claway kanban init # one-time: create kanban.db if not already present claway dashboard # "Kanban" tab appears in the nav, after "Skills" ``` ### What the plugin gives you - A **Kanban** tab showing one column per status: `triage`, `todo`, `ready`, `running`, `blocked`, `done` (plus `archived` when the toggle is on). - `triage` is the parking column for rough ideas. By default (`kanban.auto_decompose: true`), the dispatcher auto-runs the **decomposer** on tasks that land here. The built-in decomposer uses the `auxiliary.kanban_decomposer` model path, reads your profile roster (with descriptions), and fans the task out into a small graph of child tasks routed to the best-fit specialists. The original task stays alive as the parent of every child so its assignee (`kanban.orchestrator_profile`, or the active default profile when unset) wakes back up to judge completion when everything finishes. Flip the **Orchestration: Auto/Manual** pill at the top of the page (emerald = Auto, muted gray = Manual), or by editing `config.yaml` directly. Both modes coexist with `claway kanban specify` - that's still available as a single-task spec rewrite when you don't want fan-out. - Cards show the task id, title, priority badge, tenant tag, assigned profile, comment/link counts, a **progress pill** (`N/M` children done when the task has dependents), and "created N ago". A per-card checkbox enables multi-select. - **Per-profile lanes inside Running** — toolbar checkbox toggles sub-grouping of the Running column by assignee. - **Live updates via WebSocket** — the plugin tails the append-only `task_events` table on a short poll interval; the board reflects changes the instant any profile (CLI, gateway, or another dashboard tab) acts. Reloads are debounced so a burst of events triggers a single refetch. - **Drag-drop** cards between columns to change status. The drop sends `PATCH /api/plugins/kanban/tasks/:id` which routes through the same `kanban_db` code the CLI uses — the three surfaces can never drift. Moves into destructive statuses (`done`, `archived`, `blocked`) prompt for confirmation. Touch devices use a pointer-based fallback so the board is usable from a tablet. - **Inline create** — click `+` on any column header to type a title, assignee, priority, and (optionally) a parent task from a dropdown over every existing task. Press Enter to create the task, Shift+Enter to insert a newline in the title field, or Escape to cancel. Creating from the Triage column automatically parks the new task in triage. - **Multi-select with bulk actions** — shift/ctrl-click a card or tick its checkbox to add it to the selection. A bulk action bar appears at the top with batch status transitions, archive, and reassign (by profile dropdown, or "(unassign)"). Destructive batches confirm first. Per-id partial failures are reported without aborting the rest. - **Click a card** (without shift/ctrl) to open a side drawer (Escape or click-outside closes) with: - **Editable title** — click the heading to rename. - **Editable assignee / priority** — click the meta row to rewrite. - **Editable description** — markdown-rendered by default (headings, bold, italic, inline code, fenced code, `http(s)` / `mailto:` links, bullet lists), with an "edit" button that swaps in a textarea. Markdown rendering is a tiny, XSS-safe renderer — every substitution runs on HTML-escaped input, only `http(s)` / `mailto:` links pass through, and `target="_blank"` + `rel="noopener noreferrer"` are always set. - **Dependency editor** — chip list of parents and children, each with an `×` to unlink, plus dropdowns over every other task to add a new parent or child. Cycle attempts are rejected server-side with a clear message. - **Status action row** (→ triage / → ready / → running / block / unblock / complete / archive) with confirm prompts for destructive transitions. For cards in the **Triage** column the row also exposes two LLM-driven actions: **⚗ Decompose** fans the task out into a graph of child tasks routed to specialist profiles by description, and **✨ Specify** does a single-task spec rewrite. Decompose falls back to specify-style promotion when the LLM decides the task doesn't benefit from fan-out, so it's a strict superset. Both are reachable from the CLI (`claway kanban decompose <id>` / `specify <id>` / `--all`), from any gateway platform (`/kanban decompose <id>`), and programmatically via `POST /api/plugins/kanban/tasks/:id/decompose` and `…/specify`. Configure the models under `auxiliary.kanban_decomposer` and `auxiliary.triage_specifier` in `config.yaml`. - Result section (also markdown-rendered), comment thread with Enter-to-submit, the last 20 events. - **Toolbar filters** — free-text search, tenant dropdown (defaults to `dashboard.kanban.default_tenant` from `config.yaml`), assignee dropdown, "show archived" toggle, "lanes by profile" toggle, and a **Nudge dispatcher** button so you don't have to wait for the next 60 s tick. Visually the target is the familiar Linear / Fusion layout: dark theme, column headers with counts, coloured status dots, pill chips for priority and tenant. The plugin reads only theme CSS vars (`--color-*`, `--radius`, `--font-mono`, ...), so it reskins automatically with whichever dashboard theme is active. ### Auto vs Manual orchestration The kanban board has two ways to handle a task you drop into the Triage column: **Auto (default)** — `kanban.auto_decompose: true`. The gateway-embedded dispatcher runs the **decomposer** on each tick, capped by `kanban.auto_decompose_per_tick` (default 3 tasks per tick) so a bulk-load of triage tasks doesn't burst-spend the auxiliary LLM. The decomposer uses the built-in decomposition prompt plus the `auxiliary.kanban_decomposer` model path, reads your installed profiles + their descriptions, and asks the LLM to produce a JSON task graph: which tasks to spawn, who they go to, and which depend on which. The original triage task becomes the parent of every leaf in the graph, so it stays alive until the whole graph completes - and then promotes back to `ready` so its assignee (`kanban.orchestrator_profile`, or the active default profile when unset) can judge completion and add more tasks if the work isn't done. This is the "drop a one-liner, walk away" flow. **Manual** — `kanban.auto_decompose: false`. Triage tasks stay in triage until you act. Click the **⚗ Decompose** button on a card, run `claway kanban decompose <id>` (or `--all`), or use `/kanban decompose <id>` from a chat. This matches the pre-decomposer behavior of the board, useful when you want full control over what runs when. Flip between the two modes from the **Orchestration: Auto/Manual** pill at the top of the kanban page (emerald = Auto, muted gray = Manual), or by editing `config.yaml` directly. Both modes coexist with `claway kanban specify` — that's still available as a single-task spec rewrite when you don't want fan-out. The decomposer's routing decisions depend on profile descriptions, which is a per-profile labeling primitive you set with `claway profile create --description "..."`, `claway profile describe <name> --text "..."`, `claway profile describe <name> --auto` (LLM-generates from the profile's installed skills + model), or the dashboard's per-profile editor in the expanded **Orchestration settings** panel. Profiles without a description still appear in the roster — they're routable by name, just less precisely. The decomposer NEVER lands a child task with `assignee=None`: when the LLM picks an unknown profile, the child gets routed to `kanban.default_assignee` (or the active default profile if that's unset). `kanban.orchestrator_profile` does not load that profile's prompt, skills, or custom logic into the decomposition call. It controls who owns the root/orchestration task after fan-out. To change the decomposer's model/provider, configure `auxiliary.kanban_decomposer`. To use a profile's custom task-splitting logic instead of the built-in decomposer, switch to Manual mode and have that profile create or decompose tasks explicitly. Config knobs (all under `kanban:` in `~/.claway/config.yaml`): | Key | Default | Purpose | |---|---|---| | `auto_decompose` | `true` | Dispatcher auto-runs the decomposer every tick. | | `auto_decompose_per_tick` | `3` | Cap on decompositions per dispatcher tick. Excess defers to the next tick. | | `orchestrator_profile` | `""` | Profile assigned to the root/orchestration task after decomposition. Empty = fall back to active default profile. | | `default_assignee` | `""` | Where a child task lands when the LLM picks an unknown profile. Empty = fall back to active default. | | `auto_subscribe_on_create` | `true` | When a worker calls `kanban_create` from inside a session with a persistent delivery channel (messaging gateway or TUI), the originating session is auto-subscribed to the new task's completion/block events. The dispatcher still drives the delivery — this only changes whether the caller's chat/key shows up in the notify-sub table. Set to `false` to require explicit `kanban_notify-subscribe` calls per task. | And the two auxiliary LLM slots: | Key | Purpose | |---|---| | `auxiliary.kanban_decomposer` | Model that produces the task graph (called by Decompose). Set `provider`/`model` to override the main chat model. | | `auxiliary.profile_describer` | Model that auto-generates profile descriptions (called by `claway profile describe --auto`). | ### Architecture The GUI is strictly a **read-through-the-DB + write-through-kanban_db** layer with no domain logic of its own: <!-- ascii-guard-ignore --> ``` ┌────────────────────────┐ WebSocket (tails task_events) │ React SPA (plugin) │ ◀──────────────────────────────────┐ │ HTML5 drag-and-drop │ │ └──────────┬─────────────┘ │ │ REST over fetchJSON │ ▼ │ ┌────────────────────────┐ writes call kanban_db.* │ │ FastAPI router │ directly — same code path │ │ plugins/kanban/ │ the CLI /kanban verbs use │ │ dashboard/plugin_api.py │ └──────────┬─────────────┘ │ │ │ ▼ │ ┌────────────────────────┐ │ │ ~/.claway/kanban.db │ ───── append task_events ──────────┘ │ (WAL, shared) │ └────────────────────────┘ ``` <!-- ascii-guard-ignore-end --> ### REST surface All routes are mounted under `/api/plugins/kanban/` and protected by the dashboard's ephemeral session token: | Method | Path | Purpose | |---|---|---| | `GET` | `/board?tenant=<name>&include_archived=…` | Full board grouped by status column, plus tenants + assignees for filter dropdowns | | `GET` | `/tasks/:id` | Task + comments + events + links | | `POST` | `/tasks` | Create (wraps `kanban_db.create_task`, accepts `triage: bool` and `parents: [id, …]`) | | `PATCH` | `/tasks/:id` | Status / assignee / priority / title / body / result | | `POST` | `/tasks/bulk` | Apply the same patch (status / archive / assignee / priority) to every id in `ids`. Per-id failures reported without aborting siblings | | `POST` | `/tasks/:id/comments` | Append a comment | | `POST` | `/tasks/:id/specify` | Run the triage specifier — auxiliary LLM fleshes out the task body and promotes it from `triage` to `todo`. Returns `{ok, task_id, reason, new_title}`; `ok=false` with a human-readable reason on "not in triage" / no aux client / LLM error is a 200, not a 4xx | | `POST` | `/tasks/:id/decompose` | Run the kanban decomposer — auxiliary LLM produces a task graph and the helper atomically creates the children + links the root + flips `triage → todo`. Returns `{ok, task_id, reason, fanout, child_ids, new_title}`. Same 200-on-LLM-error convention as `/specify`. | | `GET` | `/profiles` | List installed profiles with their descriptions (consumed by the dashboard's profile-description editor and the orchestrator picker). | | `PATCH` | `/profiles/:name` | Set or clear a profile's description (user-authored — `description_auto: false`). Returns `{ok, profile, description}`. | | `POST` | `/profiles/:name/describe-auto` | Generate a description for a profile via `auxiliary.profile_describer`. Persists with `description_auto: true` so the dashboard can surface a "review" badge. | | `GET` | `/orchestration` | Read the kanban orchestration settings (`orchestrator_profile`, `default_assignee`, `auto_decompose`) plus the *resolved* effective values after fallbacks. | | `PUT` | `/orchestration` | Update one or more of the three orchestration keys in `config.yaml`. Validates that non-empty profile names actually exist. | | `POST` | `/links` | Add a dependency (`parent_id` → `child_id`) | | `DELETE` | `/links?parent_id=…&child_id=…` | Remove a dependency | | `POST` | `/dispatch?max=…&dry_run=…` | Nudge the dispatcher — skip the 60 s wait | | `GET` | `/config` | Read `dashboard.kanban` preferences from `config.yaml` — `default_tenant`, `lane_by_profile`, `include_archived_by_default`, `render_markdown` | | `WS` | `/events?since=<event_id>` | Live stream of `task_events` rows | Every handler is a thin wrapper — the plugin is ~700 lines of Python (router + WebSocket tail + bulk batcher + config reader) and adds no new business logic. A tiny `_conn()` helper auto-initializes `kanban.db` on every read and write, so a fresh install works whether the user opened the dashboard first, hit the REST API directly, or ran `claway kanban init`. ### Dashboard config Any of these keys under `dashboard.kanban` in `~/.claway/config.yaml` changes the tab's defaults — the plugin reads them at load time via `GET /config`: ```yaml dashboard: kanban: default_tenant: acme # preselects the tenant filter lane_by_profile: true # default for the "lanes by profile" toggle include_archived_by_default: false render_markdown: true # set false for plain <pre> rendering ``` Each key is optional and falls back to the shown default. ### Security model The dashboard's HTTP auth middleware explicitly skips `/api/plugins/` — plugin routes are unauthenticated by design because the dashboard binds to localhost by default. That means the kanban REST surface is reachable from any process on the host. The WebSocket takes one additional step: it requires the dashboard's ephemeral session token as a `?token=…` query parameter (browsers can't set `Authorization` on an upgrade request), matching the pattern used by the in-browser PTY bridge. If you run `claway dashboard --host 0.0.0.0`, every plugin route — kanban included — becomes reachable from the network. **Don't do that on a shared host.** The board contains task bodies, comments, and workspace paths; an attacker reaching these routes gets read access to your entire collaboration surface and can also create / reassign / archive tasks. Tasks in `~/.claway/kanban.db` are profile-agnostic on purpose (that's the coordination primitive). If you open the dashboard with `claway -p <profile> dashboard`, the board still shows tasks created by any other profile on the host. Same user owns all profiles, but this is worth knowing if multiple personas coexist. ### Live updates `task_events` is an append-only SQLite table with a monotonic `id`. The WebSocket endpoint holds each client's last-seen event id and pushes new rows as they land. When a burst of events arrives, the frontend reloads the (very cheap) board endpoint — simpler and more correct than trying to patch local state from every event kind. WAL mode means the read loop never blocks the dispatcher's `BEGIN IMMEDIATE` claim transactions. ### Extending it The plugin uses the standard Claway dashboard plugin contract — see Extending the Dashboard for the full manifest reference, shell slots, page-scoped slots, and the Plugin SDK. Extra columns, custom card chrome, tenant-filtered layouts, or full `tab.override` replacements are all expressible without forking this plugin. To disable without removing: add `dashboard.plugins.kanban.enabled: false` to `config.yaml` (or delete `plugins/kanban/dashboard/manifest.json`). ### Scope boundary The GUI is deliberately thin. Everything the plugin does is reachable from the CLI; the plugin just makes it comfortable for humans. Auto-assignment, budgets, governance gates, and org-chart views remain user-space — a router profile, another plugin, or a reuse of `tools/approval.py` — exactly as listed in the out-of-scope section of the design spec. ## CLI command reference This is the surface **you** (or scripts, cron, the dashboard) use to drive the board. Workers running inside the dispatcher use the `kanban_*` [tool surface](#how-workers-interact-with-the-board) for the same operations — the CLI here and the tools there both route through `kanban_db`, so the two surfaces agree by construction. ``` claway kanban init # create kanban.db + print daemon hint claway kanban create "<title>" [--body ...] [--assignee <profile>] [--parent <id>]... [--tenant <name>] [--workspace scratch|worktree|worktree:<path>|dir:<path>] [--branch <name>] [--priority N] [--triage] [--idempotency-key KEY] [--max-runtime 30m|2h|1d|<seconds>] [--max-retries N] [--goal] [--goal-max-turns N] [--skill <name>]... [--json] claway kanban list [--mine] [--assignee P] [--status S] [--tenant T] [--archived] [--workflow-template-id <id>] [--current-step-key <key>] [--sort created|created-desc|priority|priority-desc|status|assignee|title|updated] [--json] claway kanban show <id> [--json] claway kanban assign <id> <profile> # or 'none' to unassign claway kanban reassign <id>... <profile> # bulk re-assign tasks to a profile claway kanban edit <id> [--title ...] [--body ...] # edit task title / body / priority in place [--priority N] claway kanban promote <id>... # move todo/blocked tasks to ready (recovery) claway kanban schedule <id> --at <ISO8601> # set/clear a task's scheduled_at start time claway kanban diagnostics [--json] # board health snapshot (alias: diag) claway kanban link <parent_id> <child_id> claway kanban unlink <parent_id> <child_id> claway kanban claim <id> [--ttl SECONDS] claway kanban comment <id> "<text>" [--author NAME] # Bulk verbs — accept multiple ids: claway kanban complete <id>... [--result "..."] claway kanban block <id> "<reason>" [--ids <id>...] claway kanban unblock <id>... claway kanban archive <id>... claway kanban tail <id> # follow a single task's event stream claway kanban watch [--assignee P] [--tenant T] # live stream ALL events to the terminal [--kinds completed,blocked,…] [--interval SECS] claway kanban heartbeat <id> [--note "..."] # worker liveness signal for long ops claway kanban runs <id> [--json] # attempt history (one row per run) claway kanban assignees [--json] # profiles on disk + per-assignee task counts claway kanban dispatch [--dry-run] [--max N] # one-shot pass [--failure-limit N] [--json] claway kanban daemon --force # DEPRECATED — standalone dispatcher (use `claway gateway start` instead) [--failure-limit N] [--pidfile PATH] [-v] claway kanban stats [--json] # per-status + per-assignee counts claway kanban log <id> [--tail BYTES] # worker log from ~/.claway/kanban/logs/ claway kanban notify-subscribe <id> # gateway bridge hook (used by /kanban in the gateway) --platform <name> --chat-id <id> [--thread-id <id>] [--user-id <id>] claway kanban notify-list [<id>] [--json] claway kanban notify-unsubscribe <id> --platform <name> --chat-id <id> [--thread-id <id>] claway kanban context <id> # what a worker sees claway kanban specify [<id> | --all] [--tenant T] # flesh out a triage-column idea [--author NAME] [--json] # into a full spec and promote to todo claway kanban gc [--event-retention-days N] # workspaces + old events + old logs [--log-retention-days N] ``` All commands are also available as a slash command in the interactive CLI and in the messaging gateway (see [`/kanban` slash command](#kanban-slash-command) below). `--max-retries` is a per-task circuit-breaker override for the dispatcher. `--max-retries 1` blocks the task on the first non-successful attempt, while `--max-retries 3` allows two retries and blocks on the third failure. Omit it to use `kanban.failure_limit` from `config.yaml`, then the built-in default. ### Concurrency, scheduling, and child promotion config | Config key | Default | What it does | |------------|---------|--------------| | `kanban.max_in_progress` | unset (unlimited) | Caps the number of simultaneously running tasks. When the board already has N running, the dispatcher skips spawning more — useful for slow workers (local LLMs, resource-constrained hosts) so they finish what they have before more pile up and time out. Invalid or below-1 values log a warning and behave as unlimited. | | `kanban.max_in_progress_per_profile` | unset (unlimited) | Per-profile variant of `max_in_progress` — caps how many tasks any single assignee profile may run concurrently. Useful when one profile is slow or rate-limited but others should keep flowing. Applies alongside the board-wide `max_in_progress`; both must allow a spawn for it to proceed. | | `kanban.auto_promote_children` | `true` | After `decompose_triage_task()` produces children with no parent-blocker dependencies, they're automatically promoted to `ready` so the dispatcher can pick them up. Set to `false` to require manual review — children stay in `todo` until you promote them. | | `kanban.default_workdir` | unset | Board-level default working directory applied to new tasks when neither `--workspace` nor the task itself overrides it. Per-task `workspace:` still wins. | ```yaml kanban: max_in_progress: 2 auto_promote_children: false default_workdir: ~/work/active-project ``` ### Scheduled task starts (`scheduled_at`) Set `scheduled_at` on a task to delay dispatch until a specific time. The dispatcher skips ready tasks whose `scheduled_at` is in the future and picks them up on the first tick after that timestamp. ```bash claway kanban create "nightly backup audit" \ --assignee ops --scheduled-at "2026-06-01T03:00:00Z" ``` ### Respawn guard The dispatcher refuses to re-spawn a ready task when it hit a quota/auth/429 error on the previous run (`blocker_auth`), or completed a run successfully within the guard window (`recent_success`), or a recent task comment links to a GitHub PR (`active_pr`). This prevents repeat worker storms on the same bug or task while a human catches up. See the `respawn_guarded` row in the [event reference](#event-reference). ### Drag-to-delete and bulk delete (dashboard) The dashboard exposes a **trash drop zone** on the kanban page — drag any card into it to delete the task (cascades through `task_events`, child links, and subscriptions). A confirmation prompt protects against accidents. Bulk delete is also reachable via `DELETE /api/plugins/kanban/tasks` with a JSON body `{"ids": ["t_abc", "t_def", ...]}`. ### Worker visibility endpoints The dashboard plugin API now exposes these read-only endpoints (plus a run-control verb) for external monitors: | Endpoint | Returns | |----------|---------| | `GET /api/plugins/kanban/workers/active` | Currently spawned workers with PID, profile, task id, started-at, last heartbeat | | `GET /api/plugins/kanban/runs/{id}` | Single-run detail — task id, status, started/ended, exit code, log path | | `POST /api/plugins/kanban/runs/{run_id}/terminate` | Terminate a reclaimable run — stops the worker and frees the task for re-dispatch | | `GET /api/plugins/kanban/inspect` | Combined dispatcher snapshot — backlog, in-progress count vs. `max_in_progress`, recent events | All of these are gated by the same dashboard plugin auth as the rest of the kanban plugin API. ### Kanban Swarm topology helper `claway kanban swarm` creates a durable **Kanban Swarm v1** graph in one shot: a completed root/blackboard card, N parallel worker cards, a verifier card gated on all workers, and a synthesizer card gated on the verifier. Shared swarm context (the "blackboard") is stored as structured JSON comments on the root card so any worker can read it. ```bash claway kanban swarm "Design a multi-region failover plan" \ --workers researcher,architect,sre \ --verifier reviewer --synthesizer writer ``` The resulting graph dispatches normally — workers run in parallel, the verifier wakes after they all finish, the synthesizer wakes after the verifier marks the work clean. ## `/kanban` slash command {#kanban-slash-command} Every `claway kanban <action>` verb is also reachable as `/kanban <action>` — from inside an interactive `claway chat` session **and** from any gateway platform (Telegram, Discord, Slack, WhatsApp, Signal, Matrix, Mattermost, email, SMS). Both surfaces call the exact same `claway_cli.kanban.run_slash()` entry point that reuses the `claway kanban` argparse tree, so the argument surface, flags, and output format are identical across CLI, `/kanban`, and `claway kanban`. You don't have to leave the chat to drive the board. ``` /kanban list /kanban show t_abcd /kanban create "write launch post" --assignee writer --parent t_research /kanban comment t_abcd "looks good, ship it" /kanban unblock t_abcd /kanban dispatch --max 3 /kanban specify t_abcd # flesh out a triage one-liner into a real spec /kanban specify --all --tenant engineering # sweep every triage task in one tenant ``` Quote multi-word arguments the same way you would on a shell — `run_slash` parses the rest of the line with `shlex.split`, so `"..."` and `'...'` both work. ### Mid-run usage: `/kanban` bypasses the running-agent guard The gateway normally queues slash commands and user messages while an agent is still thinking — that's what stops you from accidentally starting a second turn while the first is in flight. **`/kanban` is explicitly exempted from this guard.** The board lives in `~/.claway/kanban.db`, not in the running agent's state, so reads (`list`, `show`, `context`, `tail`, `watch`, `stats`, `runs`) and writes (`comment`, `unblock`, `block`, `assign`, `archive`, `create`, `link`, …) all go through immediately, even mid-turn. This is the whole point of the separation: - A worker blocks waiting on a peer → you send `/kanban unblock t_abcd` from your phone and the dispatcher picks the peer up on its next tick. The blocked worker isn't interrupted — it just stops being blocked. - You spot a card that needs human context → `/kanban comment t_xyz "use the 2026 schema, not 2025"` lands on the task thread and the *next* run of that task will read it in `kanban_show()`. - You want to know what your fleet is doing without stopping the orchestrator → `/kanban list --mine` or `/kanban stats` inspects the board without touching your main conversation. ### Auto-subscribe on `/kanban create` (gateway only) When you create a task from the gateway with `/kanban create "…"`, the originating chat (platform + chat id + thread id) is automatically subscribed to that task's terminal events (`completed`, `blocked`, `gave_up`, `crashed`, `timed_out`). You'll get one message back per terminal event — including the first line of the worker's result summary on `completed` — without having to poll or remember the task id. ``` you> /kanban create "transcribe today's podcast" --assignee transcriber bot> Created t_9fc1a3 (ready, assignee=transcriber) (subscribed — you'll be notified when t_9fc1a3 completes or blocks) … ~8 minutes later … bot> ✓ t_9fc1a3 completed by transcriber transcribed 42 minutes, saved to podcast/2026-05-04.md ``` Subscriptions auto-remove themselves once the task reaches `done` or `archived`. If you script a create with `--json` (machine output) the auto-subscribe is skipped — the assumption is that scripted callers want to manage subscriptions explicitly via `/kanban notify-subscribe`. ### Output truncation in messaging Gateway platforms have practical message-length caps. If `/kanban list`, `/kanban show`, or `/kanban tail` produce more than ~3800 characters of output, the response is truncated with a `… (truncated; use \`claway kanban …\` in your terminal for full output)` footer. The CLI surface has no such cap. ### Autocomplete In the interactive CLI, typing `/kanban ` and hitting Tab cycles through the built-in subcommand list (`list`, `ls`, `show`, `create`, `assign`, `link`, `unlink`, `claim`, `comment`, `complete`, `block`, `unblock`, `archive`, `tail`, `dispatch`, `context`, `init`, `gc`). The remaining verbs listed in the CLI reference above (`watch`, `stats`, `runs`, `log`, `assignees`, `heartbeat`, `notify-subscribe`, `notify-list`, `notify-unsubscribe`, `daemon`) also work — they're just not in the autocomplete hint list yet. ## Collaboration patterns The board supports these eight patterns without any new primitives: | Pattern | Shape | Example | |---|---|---| | **P1 Fan-out** | N siblings, same role | "research 5 angles in parallel" | | **P2 Pipeline** | role chain: scout → editor → writer | daily brief assembly | | **P3 Voting / quorum** | N siblings + 1 aggregator | 3 researchers → 1 reviewer picks | | **P4 Long-running journal** | same profile + shared dir + cron | Obsidian vault | | **P5 Human-in-the-loop** | worker blocks → user comments → unblock | ambiguous decisions | | **P6 `@mention`** | inline routing from prose | `@reviewer look at this` | | **P7 Thread-scoped workspace** | `/kanban here` in a thread | per-project gateway threads | | **P8 Fleet farming** | one profile, N subjects | 50 social accounts | | **P9 Triage specifier** | rough idea → `triage` → `claway kanban specify` expands body → `todo` | "turn this one-liner into a spec'd task" | For worked examples of each, see `docs/claway-kanban-v1-spec.pdf`. ## Multi-tenant usage When one specialist fleet serves multiple businesses, tag each task with a tenant: ```bash claway kanban create "monthly report" \ --assignee researcher \ --tenant business-a \ --workspace dir:~/tenants/business-a/data/ ``` Workers receive `$CLAWAY_TENANT` and namespace their memory writes by prefix. The board, the dispatcher, and the profile definitions are all shared; only the data is scoped. ## Gateway notifications When you run `/kanban create …` from the gateway (Telegram, Discord, Slack, etc.), the originating chat is automatically subscribed to the new task. The gateway's background notifier polls `task_events` every few seconds and delivers one message per terminal event (`completed`, `blocked`, `gave_up`, `crashed`, `timed_out`) to that chat. Completed tasks also send the first line of the worker's `--result` so you see the outcome without having to `/kanban show`. You can manage subscriptions explicitly from the CLI — useful when a script / cron job wants to notify a chat it didn't originate from: ```bash claway kanban notify-subscribe t_abcd \ --platform telegram --chat-id 12345678 --thread-id 7 claway kanban notify-list claway kanban notify-unsubscribe t_abcd \ --platform telegram --chat-id 12345678 --thread-id 7 ``` A subscription removes itself automatically once the task reaches `done` or `archived`; no cleanup needed. ## Runs — one row per attempt A task is a logical unit of work; a **run** is one attempt to execute it. When the dispatcher claims a ready task it creates a row in `task_runs` and points `tasks.current_run_id` at it. When that attempt ends — completed, blocked, crashed, timed out, spawn-failed, reclaimed — the run row closes with an `outcome` and the task's pointer clears. A task that's been attempted three times has three `task_runs` rows. Why two tables instead of just mutating the task: you need **full attempt history** for real-world postmortems ("the second reviewer attempt got to approve, the third merged"), and you need a clean place to hang per-attempt metadata — which files changed, which tests ran, which findings a reviewer noted. Those are run facts, not task facts. Runs are also where **structured handoff** lives. When a worker completes a task (via `kanban_complete(...)`) it can pass: - `summary` (tool param) / `--summary` (CLI) — human handoff; goes on the run; downstream children see it in their `build_worker_context`. - `metadata` (tool param) / `--metadata` (CLI) — free-form JSON dict on the run; children see it serialized alongside the summary. - `result` (tool param) / `--result` (CLI) — short log line that goes on the task row (legacy field, kept for back-compat). Downstream children read the most recent completed run's summary + metadata for each parent. Retrying workers read the prior attempts on their own task (outcome, summary, error) so they don't repeat a path that already failed. ``` # What a worker actually does — a tool call, from inside the agent loop: kanban_complete( summary="implemented token bucket, keys on user_id with IP fallback, all tests pass", metadata={"changed_files": ["limiter.py", "tests/test_limiter.py"], "tests_run": 14}, result="rate limiter shipped", ) ``` The same handoff is reachable from the CLI when you (the human) need to close out a task a worker can't — e.g. a task that was abandoned, or one you marked done manually from the dashboard: ```bash claway kanban complete t_abcd \ --result "rate limiter shipped" \ --summary "implemented token bucket, keys on user_id with IP fallback, all tests pass" \ --metadata '{"changed_files": ["limiter.py", "tests/test_limiter.py"], "tests_run": 14}' # Review the attempt history on a retried task: claway kanban runs t_abcd # # OUTCOME PROFILE ELAPSED STARTED # 1 blocked worker 12s 2026-04-27 14:02 # → BLOCKED: need decision on rate-limit key # 2 completed worker 8m 2026-04-27 15:18 # → implemented token bucket, keys on user_id with IP fallback ``` Runs are exposed on the dashboard (Run History section in the drawer, one coloured row per attempt) and on the REST API (`GET /api/plugins/kanban/tasks/:id` returns a `runs[]` array). `PATCH /api/plugins/kanban/tasks/:id` with `{status: "done", summary, metadata}` forwards both to the kernel, so the dashboard's "mark done" button is CLI-equivalent. `task_events` rows carry the `run_id` they belong to so the UI can group them by attempt, and the `completed` event embeds the first-line summary in its payload (capped at 400 chars) so gateway notifiers can render structured handoffs without a second SQL round-trip. **Bulk close caveat.** `claway kanban complete a b c --summary X` is refused — structured handoff is per-run, so copy-pasting the same summary to N tasks is almost always wrong. Bulk close *without* `--summary` / `--metadata` still works for the common "I finished a pile of admin tasks" case. **Reclaimed runs from status changes.** If you drag a running task off `running` in the dashboard (back to `ready`, or straight to `todo`), or archive a task that was still running, the in-flight run closes with `outcome='reclaimed'` rather than being orphaned. The `task_runs` row is always in a terminal state when `tasks.current_run_id` is `NULL`, and vice versa — that invariant holds across CLI, dashboard, dispatcher, and notifier. **Synthetic runs for never-claimed completions.** Completing or blocking a task that was never claimed (e.g. a human closes a `ready` task from the dashboard with a summary, or a CLI user runs `claway kanban complete <ready-task> --summary X`) would otherwise drop the handoff. Instead the kernel inserts a zero-duration run row (`started_at == ended_at`) carrying the summary / metadata / reason so attempt history stays complete. The `completed` / `blocked` event's `run_id` points at that row. **Live drawer refresh.** When the dashboard's WebSocket event stream reports new events for the task the user is currently viewing, the drawer reloads itself (via a per-task event counter threaded into its `useEffect` dependency list). Closing and reopening is no longer required to see a run's new row or updated outcome. ### Forward compatibility Two nullable columns on `tasks` are reserved for v2 workflow routing: `workflow_template_id` (which template this task belongs to) and `current_step_key` (which step in that template is active). The v1 kernel ignores them for routing but lets clients write them, so a v2 release can add the routing machinery without another schema migration. ## Event reference Every transition appends a row to `task_events`. Each row carries an optional `run_id` so UIs can group events by attempt. Kinds group into three clusters so filtering is easy (`claway kanban watch --kinds completed,gave_up,timed_out`): **Lifecycle** (what changed about the task as a logical unit): | Kind | Payload | When | |---|---|---| | `created` | `{assignee, status, parents, tenant}` | Task inserted. `run_id` is `NULL`. | | `promoted` | — | `todo → ready` because all parents hit `done`. `run_id` is `NULL`. | | `claimed` | `{lock, expires, run_id}` | Dispatcher atomically claimed a `ready` task for spawn. | | `completed` | `{result_len, summary?}` | Worker wrote `--result` / `--summary` and task hit `done`. `summary` is the first-line handoff (400-char cap); full version lives on the run row. If `complete_task` is called on a never-claimed task with handoff fields, a zero-duration run is synthesized so `run_id` still points at something. | | `blocked` | `{reason, kind, recurrences}` | Worker or human flipped the task to `blocked`. `kind` is the typed block reason (`needs_input`, `capability`, `transient`, or `null` for a generic block); `recurrences` is the unblock-loop counter. Synthesizes a zero-duration run when called on a never-claimed task with `--reason`. | | `dependency_wait` | `{reason, kind}` | Worker blocked with `kind=dependency` — the task is only waiting on another task, so it routes to `todo` (parent-gated, auto-promoted) instead of `blocked`. No human needed. | | `block_loop_detected` | `{reason, kind, recurrences, limit}` | A task was unblocked and re-blocked for the same reason `BLOCK_RECURRENCE_LIMIT` times (default 2). Instead of landing in `blocked` again — where a cron would keep unblocking it — it routes to `triage` for a human decision, breaking the unblock↔re-block loop. | | `unblocked` | — | `blocked → ready` (or `todo` if parents are still open), either manually or via `/unblock`. Resets the dispatcher's `consecutive_failures` but deliberately preserves `block_recurrences` so the loop breaker keeps its memory. `run_id` is `NULL`. | | `archived` | — | Hidden from the default board. If the task was still running, carries the `run_id` of the run that was reclaimed as a side effect. | **Edits** (human-driven changes that aren't transitions): | Kind | Payload | When | |---|---|---| | `assigned` | `{assignee}` | Assignee changed (including unassignment). | | `edited` | `{fields}` | Title or body updated. | | `reprioritized` | `{priority}` | Priority changed. | | `status` | `{status}` | Dashboard drag-drop wrote a status directly (e.g. `todo → ready`). Carries the `run_id` of the run that was reclaimed when dragging off `running`; otherwise `run_id` is NULL. | **Worker telemetry** (about the execution process, not the logical task): | Kind | Payload | When | |---|---|---| | `spawned` | `{pid}` | Dispatcher successfully started a worker process. | | `heartbeat` | `{note?}` | Worker called `claway kanban heartbeat $TASK` to signal liveness during long operations. | | `reclaimed` | `{stale_lock}` | Claim TTL expired without a completion; task goes back to `ready`. | | `crashed` | `{pid, claimer}` | Worker PID no longer alive but TTL hadn't expired yet. | | `timed_out` | `{pid, elapsed_seconds, limit_seconds, sigkill}` | `max_runtime_seconds` exceeded; dispatcher SIGTERM'd (then SIGKILL'd after 5 s grace) and re-queued. | | `stale` | `{elapsed_seconds, last_heartbeat_at, heartbeat_age_seconds, timeout_seconds, pid, terminated}` | Task ran longer than `kanban.dispatch_stale_timeout_seconds` (default 4 h) AND no `kanban_heartbeat` arrived in the last hour. Dispatcher SIGTERM'd the host-local worker (if any), reset the task to `ready` for re-dispatch. Does NOT tick the failure counter (stale is dispatcher-side absence detection, not a worker fault). Workers running long operations should call `kanban_heartbeat` at least once an hour to avoid this. | | `respawn_guarded` | `{reason}` | Dispatcher refused to re-spawn this ready task this tick. Reasons: `blocker_auth` (last failure was a quota/auth/429 error — wait for the rate window to reset), `recent_success` (a completed run happened in the last hour — wait for review before re-running), `active_pr` (a GitHub PR URL appears in a recent comment — a prior worker already opened a PR). The task stays in `ready`; the next tick gets another chance to spawn. If the underlying condition persists, the normal `consecutive_failures` circuit breaker will auto-block via `gave_up` after `failure_limit` failures. | | `spawn_failed` | `{error, failures}` | One spawn attempt failed (missing PATH, workspace unmountable, …). Counter increments; task returns to `ready` for retry. | | `protocol_violation` | `{pid, claimer, exit_code}` | Worker exited successfully while the task was still `running`, usually because it answered without calling `kanban_complete` or `kanban_block`. The dispatcher also emits `gave_up` and auto-blocks immediately instead of retrying. | | `gave_up` | `{failures, effective_limit, limit_source, error}` | Circuit breaker fired after N consecutive non-successful attempts. Task auto-blocks with the last error. The effective limit resolves as task `max_retries`, then dispatcher `failure_limit` / `kanban.failure_limit`, then the built-in default. | `claway kanban tail <id>` shows these for a single task. `claway kanban watch` streams them board-wide. ## Out of scope Kanban is deliberately single-host. `~/.claway/kanban.db` is a local SQLite file and the dispatcher spawns workers on the same machine. Running a shared board across two hosts is not supported — there's no coordination primitive for "worker X on host A, worker Y on host B," and the crash-detection path assumes PIDs are host-local. If you need multi-host, run an independent board per host and use `delegate_task` / a message queue to bridge them. ## Design spec The complete design — architecture, concurrency correctness, comparison with other systems, implementation plan, risks, open questions — lives in `docs/claway-kanban-v1-spec.pdf`. Read that before filing any behavior-change PR. --- <!-- source: website/docs/user-guide/features/goals.md --> # Persistent Goals # Persistent Goals (`/goal`) `/goal` gives Claway a standing objective that survives across turns. After every turn a lightweight judge model checks whether the goal is satisfied by the assistant's last response. If not, Claway automatically feeds a continuation prompt back into the same session and keeps working — until the goal is achieved, you pause or clear it, or the turn budget runs out. It's our take on the **Ralph loop**, directly inspired by [Codex CLI 0.128.0's `/goal`](https://github.com/openai/codex) by Eric Traut (OpenAI). The core idea — keep a goal alive across turns and don't stop until it's achieved — is theirs. The implementation here is independent and adapted to Claway's architecture. ## When to use it Use `/goal` for tasks where you want Claway to iterate on its own without you re-prompting every turn: - "Fix every lint error in `src/` and verify `ruff check` passes" - "Port feature X from repo Y, including tests, and get CI green" - "Investigate why session IDs sometimes drift on mid-run compression and write up a report" - "Build a small CLI to rename files by their EXIF dates, then test it against the photos/ folder" Tasks where the agent does one turn and stops don't need `/goal`. Tasks where *you'd otherwise have to say "keep going" three times* are where this shines. ## Quick start ``` /goal Fix every failing test in tests/claway_cli/ and make sure scripts/run_tests.sh passes for that directory ``` What you'll see: 1. **Goal accepted** — `⊙ Goal set (20-turn budget): <your goal>` 2. **Turn 1 runs** — Claway starts working as if you'd sent the goal as a normal message. 3. **Judge runs** — after the turn, the judge model decides `done` or `continue`. 4. **Loop fires if needed** — if `continue`, you'll see `↻ Continuing toward goal (1/20): <judge's reason>` and Claway takes the next step automatically. 5. **Terminates** — eventually you see either `✓ Goal achieved: <reason>` or `⏸ Goal paused — N/20 turns used`. ## Commands | Command | What it does | |---|---| | `/goal <text>` | Set (or replace) the standing goal. Kicks off the first turn immediately so you don't need to send a separate message. | | `/goal draft <text>` | Draft a structured completion contract from a plain-language objective, then set it. See [Completion contracts](#completion-contracts). | | `/goal show` | Print the active goal's completion contract. | | `/goal` or `/goal status` | Show the current goal, its status, and turns used. | | `/goal pause` | Stop the auto-continuation loop without clearing the goal. | | `/goal resume` | Resume the loop (resets the turn counter back to zero). | | `/goal clear` | Drop the goal entirely. | | `/goal wait <pid> [reason]` | Park the loop on a background process — it stops re-poking the agent every turn while the process runs, and auto-resumes when it exits. | | `/goal unwait` | Drop the wait barrier and resume the loop immediately. | Works identically on the CLI and every gateway platform (Telegram, Discord, Slack, Matrix, Signal, WhatsApp, SMS, iMessage, Webhook, API server, and the web dashboard). ## Completion contracts A bare `/goal <text>` works fine, but a *vague* goal makes for vague judging — the judge can only check what you told it to want. Codex's `/goal` guidance makes the same point: a durable objective works best when it names **what done means, how to prove it, what not to break, what's in scope, and when to stop**. Claway adapts this as an optional **completion contract** layered on top of the existing goal loop. A contract has five fields, all optional: | Field | Meaning | |---|---| | `outcome` | The single end state that must be true when done. | | `verification` | The specific test / command / artifact that *proves* the outcome. | | `constraints` | What must not change or regress. | | `boundaries` | Which files, dirs, tools, or systems are in scope. | | `stop_when` | The condition under which Claway should stop and ask for input. | When a contract is set, both prompts change: the **continuation prompt** tells the agent to target the verification surface and respect the constraints, and the **judge prompt** decides `done` *only when the verification criterion is met with concrete evidence* (a command result, file excerpt, test output) — not a loose "looks done" claim. This directly tightens the most common `/goal` failure mode (premature completion or endless over-continuation on an underspecified objective). ### Two ways to set a contract **1. Let Claway draft it** (recommended — adapted from Codex's "let the agent draft the goal" tip): ``` /goal draft Migrate the auth service from session cookies to JWT ``` Claway expands your one-liner into a full contract via the `goal_judge` auxiliary model, sets it, and shows you the result so you can review or tighten any field. If the aux model is unavailable, it falls back to a plain free-form goal — drafting never blocks setting a goal. **2. Write it inline** with `field: value` lines: ``` /goal Migrate auth to JWT verify: pytest tests/auth passes constraints: keep the /login response shape unchanged boundaries: only touch services/auth and its tests stop when: a DB schema migration is required ``` The first non-field line(s) are the goal headline; recognized field prefixes (`verify:`, `verified by:`, `constraints:`, `preserve:`, `boundaries:`, `scope:`, `stop when:`, `blocked:`, …) populate the contract. A plain goal with an incidental colon (`Fix bug: the parser drops commas`) is **not** mangled — only known field prefixes are pulled out. Use `/goal show` to review the active contract. Contracts persist in `SessionDB.state_meta` alongside the goal, so they survive `/resume`. Old goals from before this feature load unchanged (no contract). Contracts and `/subgoal` criteria compose: subgoals fold into the contract as extra criteria the judge must also satisfy. ## Adding criteria mid-goal: `/subgoal` While a goal is active you can append extra acceptance criteria with `/subgoal <text>` without resetting the loop. Each call adds one numbered item to the goal's subgoal list; the **continuation prompt** the agent sees on the next turn includes the original goal plus an "Additional criteria the user added mid-loop" block, and the **judge prompt** is rewritten so the verdict must consider every subgoal — the goal isn't marked done until the original objective **and** every subgoal are met. | Command | What it does | |---|---| | `/subgoal <text>` | Append a new criterion to the active goal. Requires an active `/goal`. | | `/subgoal` (no args) | Show the current numbered subgoal list. | | `/subgoal remove <N>` | Remove the Nth subgoal (1-based). | | `/subgoal clear` | Drop every subgoal but keep the original goal intact. | Subgoals are persisted alongside the goal in `SessionDB.state_meta`, so they survive `/resume`. Setting a new `/goal <text>` replaces the goal and clears the subgoal list; `/goal clear` does the same. Use this when you start a loop ("fix the failing tests") and notice partway through that you also want it to "and add a regression test for the bug you just patched" — `/subgoal add a regression test` tightens the success criteria without breaking the running loop. ## Parking on a background process: automatic, with a manual override Some goals are gated on something that takes minutes and runs on its own — CI on a pushed PR, a long build, a test matrix, a deploy, a rate-limit cooldown. Without help, the goal loop would re-poke the agent every turn into "is it done yet?" busy-work while it waits. **This is handled automatically.** Every turn, the judge is shown the agent's live background processes (the `terminal(background=true)` registry — pid, session id, command, uptime, recent output, and any `watch_patterns` / `notify_on_complete` trigger) alongside the goal and the agent's response. When the agent's progress is genuinely gated on one of them, the judge returns a **`wait`** verdict instead of `continue`, and the loop **parks**: the next turns are skipped (no judge call, no continuation, no turn consumed) until the wait is satisfied — then it resumes normally with the result in hand. The judge can also park on a **time** basis (`wait_for_seconds`) for backoff/cooldown waits. `/goal status` shows `⏳ Goal (parked …)` while parked. The judge picks the right kind of wait from the process's own signal: - **`wait_on_session <id>`** — releases when the process's *own trigger* fires: it exits, **or** (if it was started with `watch_patterns`) its pattern matches. This is the one for a long-lived watcher / server / poller that signals **mid-run** (e.g. a build process that prints `BUILD SUCCESSFUL` and keeps running, or a `notify_on_complete` watcher) and may never exit on its own. - **`wait_on_pid <pid>`** — releases on process exit only. - **`wait_for_seconds <n>`** — releases after a fixed delay. You don't type anything for this — it's the judge's decision, made from the process context the loop hands it. The manual commands exist as an override: | Command | What it does | |---|---| | `/goal wait <pid> [reason]` | Manually park the loop until the process with that PID exits. | | `/goal unwait` | Clear any wait barrier (judge- or manually-set) and resume immediately. | The barrier (pid- or time-based) is persisted with the goal in `SessionDB.state_meta`, so it survives `/resume`. `/goal pause`, `/goal resume`, and `/goal clear` all drop it. If the PID is already dead when the barrier is set (or dies while parked), or the time deadline passes, the barrier clears on the next check — a stale barrier can never wedge the loop. Typical flow: the agent pushes a PR, starts a CI watcher with `terminal(background=true, notify_on_complete=true)`, and reports "watching CI." The judge sees the watcher process still running, returns `wait` on its pid, and the loop goes quiet — then picks back up the instant CI finishes and judges the goal against the actual result. ## Behavior details ### The judge After every turn, Claway calls an auxiliary model with: - The standing goal text - The agent's most recent final response (last ~4 KB of text) - A system prompt telling the judge to reply with strict JSON: `{"done": <bool>, "reason": "<one-sentence rationale>"}` The judge is deliberately conservative: it marks a goal `done` only when the response **explicitly** confirms the goal is complete, when the final deliverable is clearly produced, or when the goal is unachievable/blocked (treated as DONE with a block reason so we don't burn budget on impossible tasks). ### Fail-open semantics If the judge errors (network blip, malformed response, unavailable aux client), Claway treats the verdict as `continue` — a broken judge never wedges progress. The **turn budget** is the real backstop. ### Turn budget Default is 20 continuation turns (`goals.max_turns` in `config.yaml`). When the budget is hit, Claway auto-pauses and tells you exactly how to proceed: ``` ⏸ Goal paused — 20/20 turns used. Use /goal resume to keep going, or /goal clear to stop. ``` `/goal resume` resets the counter to zero, so you can keep going in measured chunks. ### User messages always preempt Any real message you send while a goal is active takes priority over the continuation loop. On the CLI your message lands in `_pending_input` ahead of the queued continuation; on the gateway it goes through the adapter FIFO the same way. The judge runs again after your turn — so if your message happens to complete the goal, the judge will catch it and stop. ### Mid-run safety (gateway) While an agent is already running, `/goal status`, `/goal pause`, `/goal clear`, `/goal wait`, and `/goal unwait` are safe to run — they only touch control-plane state and don't interrupt the current turn. Setting a **new** goal mid-run (`/goal <new text>`) is rejected with a message telling you to `/stop` first, so the old continuation can't race the new one. ### Persistence Goal state lives in `SessionDB.state_meta` keyed by `goal:<session_id>`. That means `/resume` picks up right where you left off — set a goal, close your laptop, come back tomorrow, `/resume`, and the goal is still standing exactly as you left it (active, paused, or done). ### Prompt cache The continuation prompt is a plain user-role message appended to history. It does **not** mutate the system prompt, swap toolsets, or touch the conversation in any way that invalidates Claway's prompt cache. Running a 20-turn goal costs the same cache-wise as 20 turns of normal conversation. ## Configuration Add to `~/.claway/config.yaml`: ```yaml goals: # Max continuation turns before Claway auto-pauses and asks you to # /goal resume. Default 20. Lower this if you want tighter loops; # raise it for long-running refactors. max_turns: 20 ``` ### Choosing the judge model The judge uses the `goal_judge` auxiliary task. By default it resolves to your main model (see [Auxiliary Models](/user-guide/configuration#auxiliary-models)). If you want to route the judge to a cheap fast model to keep costs down, add an override: ```yaml auxiliary: goal_judge: provider: openrouter model: google/gemini-3-flash-preview ``` The judge call is small (~200 output tokens) and runs once per turn, so a cheap fast model is usually the right call. ## Example walkthrough ``` You: /goal Create four files /tmp/note_{1..4}.txt, one per turn, each containing its number as text ⊙ Goal set (20-turn budget): Create four files /tmp/note_{1..4}.txt, one per turn, each containing its number as text Claway: Creating /tmp/note_1.txt now. 💻 echo "1" > /tmp/note_1.txt (0.1s) I've created /tmp/note_1.txt with the content "1". I'll continue with the remaining files on the next turn as you specified. ↻ Continuing toward goal (1/20): Only 1 of 4 files has been created; 3 files remain. Claway: [Continuing toward your standing goal] 💻 echo "2" > /tmp/note_2.txt (0.1s) Created /tmp/note_2.txt. Two more to go. ↻ Continuing toward goal (2/20): 2 of 4 files created; 2 remain. Claway: [Continuing toward your standing goal] 💻 echo "3" > /tmp/note_3.txt (0.1s) Created /tmp/note_3.txt. ↻ Continuing toward goal (3/20): 3 of 4 files created; 1 remains. Claway: [Continuing toward your standing goal] 💻 echo "4" > /tmp/note_4.txt (0.1s) All four files have been created: /tmp/note_1.txt through /tmp/note_4.txt, each containing its number. ✓ Goal achieved: All four files were created with the specified content, completing the goal. You: _ ``` Four turns, one `/goal` invocation, zero "keep going" prompts from you. ## When the judge gets it wrong No judge is perfect. Two failure modes to watch for: **False negative — judge says continue when the goal is actually done.** The turn budget catches this. You'll see `⏸ Goal paused` and can `/goal clear` or just send a new message. **False positive — judge says done when work remains.** You'll see `✓ Goal achieved` but you know better. Send a follow-up message to continue, or re-set the goal more precisely: `/goal <more specific text>`. The judge's system prompt is deliberately conservative to make false positives rarer than false negatives. If you find a judge verdict unconvincing, the reason text in the `↻ Continuing toward goal` or `✓ Goal achieved` line tells you exactly what the judge saw. That's usually enough to diagnose whether the goal text was ambiguous or the model's response was. ## Attribution `/goal` is Claway's take on the **Ralph loop** pattern. The user-facing design — keep a goal alive across turns, don't stop until it's achieved, with create/pause/resume/clear controls — was popularised and shipped in [Codex CLI 0.128.0](https://github.com/openai/codex) by Eric Traut on OpenAI's Codex team. Our implementation is independent (central `CommandDef` registry, `SessionDB.state_meta` persistence, auxiliary-client judge, adapter-FIFO continuation on the gateway side) but the idea is theirs. Credit where credit's due. --- <!-- source: website/docs/user-guide/features/code-execution.md --> # Code Execution # Code Execution (Programmatic Tool Calling) The `execute_code` tool lets the agent write Python scripts that call Claway tools programmatically, collapsing multi-step workflows into a single LLM turn. The script runs in a child process on the agent host, communicating with Claway over a Unix domain socket RPC. ## How It Works 1. The agent writes a Python script using `from claway_tools import ...` 2. Claway generates a `claway_tools.py` stub module with RPC functions 3. Claway opens a Unix domain socket and starts an RPC listener thread 4. The script runs in a child process — tool calls travel over the socket back to Claway 5. Only the script's `print()` output is returned to the LLM; intermediate tool results never enter the context window ```python # The agent can write scripts like: from claway_tools import web_search, web_extract results = web_search("Python 3.13 features", limit=5) for r in results["data"]["web"]: content = web_extract([r["url"]]) # ... filter and process ... print(summary) ``` **Available tools inside scripts:** `web_search`, `web_extract`, `read_file`, `write_file`, `search_files`, `patch`, `terminal` (foreground only). ## When the Agent Uses This The agent uses `execute_code` when there are: - **3+ tool calls** with processing logic between them - Bulk data filtering or conditional branching - Loops over results The key benefit: intermediate tool results never enter the context window — only the final `print()` output comes back, dramatically reducing token usage. ## Practical Examples ### Data Processing Pipeline ```python from claway_tools import search_files, read_file import json # Find all config files and extract database settings matches = search_files("database", path=".", file_glob="*.yaml", limit=20) configs = [] for match in matches.get("matches", []): content = read_file(match["path"]) configs.append({"file": match["path"], "preview": content["content"][:200]}) print(json.dumps(configs, indent=2)) ``` ### Multi-Step Web Research ```python from claway_tools import web_search, web_extract import json # Search, extract, and summarize in one turn results = web_search("Rust async runtime comparison 2025", limit=5) summaries = [] for r in results["data"]["web"]: page = web_extract([r["url"]]) for p in page.get("results", []): if p.get("content"): summaries.append({ "title": r["title"], "url": r["url"], "excerpt": p["content"][:500] }) print(json.dumps(summaries, indent=2)) ``` ### Bulk File Refactoring ```python from claway_tools import search_files, read_file, patch # Find all Python files using deprecated API and fix them matches = search_files("old_api_call", path="src/", file_glob="*.py") fixed = 0 for match in matches.get("matches", []): result = patch( path=match["path"], old_string="old_api_call(", new_string="new_api_call(", replace_all=True ) if "error" not in str(result): fixed += 1 print(f"Fixed {fixed} files out of {len(matches.get('matches', []))} matches") ``` ### Build and Test Pipeline ```python from claway_tools import terminal, read_file import json # Run tests, parse results, and report result = terminal("cd /project && python -m pytest --tb=short -q 2>&1", timeout=120) output = result.get("output", "") # Parse test output passed = output.count(" passed") failed = output.count(" failed") errors = output.count(" error") report = { "passed": passed, "failed": failed, "errors": errors, "exit_code": result.get("exit_code", -1), "summary": output[-500:] if len(output) > 500 else output } print(json.dumps(report, indent=2)) ``` ## Execution Mode `execute_code` has two execution modes controlled by `code_execution.mode` in `~/.claway/config.yaml`: | Mode | Working directory | Python interpreter | |------|-------------------|--------------------| | **`project`** (default) | The session's working directory (same as `terminal()`) | Active `VIRTUAL_ENV` / `CONDA_PREFIX` python, falling back to Claway's own python | | `strict` | A temp staging directory isolated from the user's project | `sys.executable` (Claway's own python) | **When to leave it on `project`:** you want `import pandas`, `from my_project import foo`, or relative paths like `open(".env")` to work the same way they do in `terminal()`. This is almost always what you want. **When to flip to `strict`:** you need maximum reproducibility — you want the same interpreter every session regardless of which venv the user activated, and you want scripts quarantined from the project tree (no risk of accidentally reading project files through a relative path). ```yaml # ~/.claway/config.yaml code_execution: mode: project # or "strict" ``` Fallback behavior in `project` mode: if `VIRTUAL_ENV` / `CONDA_PREFIX` is unset, broken, or points at a Python older than 3.8, the resolver falls back cleanly to `sys.executable` — it never leaves the agent without a working interpreter. Security-critical invariants are identical across both modes: - environment scrubbing (API keys, tokens, credentials stripped) - tool whitelist (scripts cannot call `execute_code` recursively, `delegate_task`, or MCP tools) - resource limits (timeout, stdout cap, tool-call cap) Switching mode changes where scripts run and which interpreter runs them, not what credentials they can see or which tools they can call. ## Resource Limits | Resource | Limit | Notes | |----------|-------|-------| | **Timeout** | 5 minutes (300s) | Script is killed with SIGTERM, then SIGKILL after 5s grace | | **Stdout** | 50 KB | Output truncated with `[output truncated at 50KB]` notice | | **Stderr** | 10 KB | Included in output on non-zero exit for debugging | | **Tool calls** | 50 per execution | Error returned when limit reached | All limits are configurable via `config.yaml`: ```yaml # In ~/.claway/config.yaml code_execution: mode: project # project (default) | strict timeout: 300 # Max seconds per script (default: 300) max_tool_calls: 50 # Max tool calls per execution (default: 50) ``` ## How Tool Calls Work Inside Scripts When your script calls a function like `web_search("query")`: 1. The call is serialized to JSON and sent over a Unix domain socket to the parent process 2. The parent dispatches through the standard `handle_function_call` handler 3. The result is sent back over the socket 4. The function returns the parsed result This means tool calls inside scripts behave identically to normal tool calls — same rate limits, same error handling, same capabilities. The only restriction is that `terminal()` is foreground-only (no `background` or `pty` parameters). ## Error Handling When a script fails, the agent receives structured error information: - **Non-zero exit code**: stderr is included in the output so the agent sees the full traceback - **Timeout**: Script is killed and the agent sees `"Script timed out after 300s and was killed."` - **Interruption**: If the user sends a new message during execution, the script is terminated and the agent sees `[execution interrupted — user sent a new message]` - **Tool call limit**: When the 50-call limit is hit, subsequent tool calls return an error message The response always includes `status` (success/error/timeout/interrupted), `output`, `tool_calls_made`, and `duration_seconds`. ## Security :::danger Security Model The child process runs with a **minimal environment**. API keys, tokens, and credentials are stripped by default. The script accesses tools exclusively via the RPC channel — it cannot read secrets from environment variables unless explicitly allowed. ::: Environment variables containing `KEY`, `TOKEN`, `SECRET`, `PASSWORD`, `CREDENTIAL`, `PASSWD`, or `AUTH` in their names are excluded. Only safe system variables (`PATH`, `HOME`, `LANG`, `SHELL`, `PYTHONPATH`, `VIRTUAL_ENV`, etc.) are passed through. ### Skill Environment Variable Passthrough When a skill declares `required_environment_variables` in its frontmatter, those variables are **automatically passed through** to both `execute_code` and `terminal` child processes after the skill is loaded. This lets skills use their declared API keys without weakening the security posture for arbitrary code. For non-skill use cases, you can explicitly allowlist variables in `config.yaml`: ```yaml terminal: env_passthrough: - MY_CUSTOM_KEY - ANOTHER_TOKEN ``` See the [Security guide](/user-guide/security#environment-variable-passthrough) for full details. ### `CLAWAY_*` variables in the child The child process receives only a small, fixed set of operational `CLAWAY_*` variables by exact name: - `CLAWAY_HOME` - `CLAWAY_PROFILE` - `CLAWAY_CONFIG` - `CLAWAY_ENV` (plus `CLAWAY_RPC_DIR` / `CLAWAY_RPC_SOCKET` / `TZ` / `HOME`, which Claway injects explicitly so the RPC channel works). :::note Behavior change Earlier versions passed **any** variable whose name began with `CLAWAY_` through to the child. That broad prefix was removed for security hardening: it could leak `CLAWAY_*`-named configuration that doesn't match a secret substring (for example `CLAWAY_BASE_URL`, `CLAWAY_KANBAN_DB`, or a `CLAWAY_*_WEBHOOK` endpoint) into arbitrary sandboxed code. If an `execute_code` script — or a repo/plugin module it imports at import time — relied on a `CLAWAY_*` variable outside the four operational names above, it will now find that variable **unset** in the child. The drop is intentional, not a bug. ::: **Workaround — opt the variable back in explicitly.** Both routes pass the variable through `execute_code` *and* `terminal` children, and neither weakens the secret-stripping guarantee (Claway-managed provider credentials can never be re-allowed this way): 1. **Per-machine, in `config.yaml`** — add the exact variable name to the passthrough allowlist: ```yaml terminal: env_passthrough: - CLAWAY_KANBAN_DB - CLAWAY_BASE_URL ``` 2. **Per-skill, in the skill's frontmatter** — declare it so it is registered automatically whenever that skill is loaded: ```yaml required_environment_variables: - CLAWAY_KANBAN_DB ``` **Diagnosing it.** When the child drops one or more non-allowlisted `CLAWAY_*` variables, Claway emits a one-line `debug` log naming them and pointing at the `env_passthrough` escape hatch. Run with debug logging (`claway logs --level DEBUG`, or check `~/.claway/logs/agent.log`) and look for `execute_code: dropped N non-allowlisted CLAWAY_* var(s)` if a script behaves as though a `CLAWAY_*` variable is missing. Claway always writes the script and the auto-generated `claway_tools.py` RPC stub into a temp staging directory that is cleaned up after execution. In `strict` mode the script also *runs* there; in `project` mode it runs in the session's working directory (the staging directory stays on `PYTHONPATH` so imports still resolve). The child process runs in its own process group so it can be cleanly killed on timeout or interruption. ## execute_code vs terminal | Use Case | execute_code | terminal | |----------|-------------|----------| | Multi-step workflows with tool calls between | ✅ | ❌ | | Simple shell command | ❌ | ✅ | | Filtering/processing large tool outputs | ✅ | ❌ | | Running a build or test suite | ❌ | ✅ | | Looping over search results | ✅ | ❌ | | Interactive/background processes | ❌ | ✅ | | Needs API keys in environment | ⚠️ Only via [passthrough](/user-guide/security#environment-variable-passthrough) | ✅ (most pass through) | **Rule of thumb:** Use `execute_code` when you need to call Claway tools programmatically with logic between calls. Use `terminal` for running shell commands, builds, and processes. ## Platform Support Code execution requires Unix domain sockets and is available on **Linux and macOS only**. It is automatically disabled on Windows — the agent falls back to regular sequential tool calls. --- <!-- source: website/docs/user-guide/features/hooks.md --> # Event Hooks # Event Hooks Claway has three hook systems that run custom code at key lifecycle points: | System | Registered via | Runs in | Use case | |--------|---------------|---------|----------| | **[Gateway hooks](#gateway-event-hooks)** | `HOOK.yaml` + `handler.py` in `~/.claway/hooks/` | Gateway only | Logging, alerts, webhooks | | **[Plugin hooks](#plugin-hooks)** | `ctx.register_hook()` in a [plugin](/user-guide/features/plugins) | CLI + Gateway | Tool interception, metrics, guardrails | | **[Shell hooks](#shell-hooks)** | `hooks:` block in `~/.claway/config.yaml` pointing at shell scripts | CLI + Gateway | Drop-in scripts for blocking, auto-formatting, context injection | All three systems are non-blocking — errors in any hook are caught and logged, never crashing the agent. ## Gateway Event Hooks Gateway hooks fire automatically during gateway operation (Telegram, Discord, Slack, WhatsApp, Teams) without blocking the main agent pipeline. ### Creating a Hook Each hook is a directory under `~/.claway/hooks/` containing two files: ```text ~/.claway/hooks/ └── my-hook/ ├── HOOK.yaml # Declares which events to listen for └── handler.py # Python handler function ``` #### HOOK.yaml ```yaml name: my-hook description: Log all agent activity to a file events: - agent:start - agent:end - agent:step ``` The `events` list determines which events trigger your handler. You can subscribe to any combination of events, including wildcards like `command:*`. #### handler.py ```python import json from datetime import datetime from pathlib import Path LOG_FILE = Path.home() / ".claway" / "hooks" / "my-hook" / "activity.log" async def handle(event_type: str, context: dict): """Called for each subscribed event. Must be named 'handle'.""" entry = { "timestamp": datetime.now().isoformat(), "event": event_type, **context, } with open(LOG_FILE, "a") as f: f.write(json.dumps(entry) + "\n") ``` **Handler rules:** - Must be named `handle` - Receives `event_type` (string) and `context` (dict) - Can be `async def` or regular `def` — both work - Errors are caught and logged, never crashing the agent ### Available Events | Event | When it fires | Context keys | |-------|---------------|--------------| | `gateway:startup` | Gateway process starts | `platforms` (list of active platform names) | | `session:start` | New messaging session created | `platform`, `user_id`, `session_id`, `session_key` | | `session:end` | Session ended (before reset) | `platform`, `user_id`, `session_key` | | `session:reset` | User ran `/new` or `/reset` | `platform`, `user_id`, `session_key` | | `agent:start` | Agent begins processing a message | `platform`, `user_id`, `session_id`, `message` | | `agent:step` | Each iteration of the tool-calling loop | `platform`, `user_id`, `session_id`, `iteration`, `tool_names` | | `agent:end` | Agent finishes processing | `platform`, `user_id`, `session_id`, `message`, `response` | | `command:*` | Any slash command executed | `platform`, `user_id`, `command`, `args` | #### Wildcard Matching Handlers registered for `command:*` fire for any `command:` event (`command:model`, `command:reset`, etc.). Monitor all slash commands with a single subscription. ### Examples #### Telegram Alert on Long Tasks Send yourself a message when the agent takes more than 10 steps: ```yaml # ~/.claway/hooks/long-task-alert/HOOK.yaml name: long-task-alert description: Alert when agent is taking many steps events: - agent:step ``` ```python # ~/.claway/hooks/long-task-alert/handler.py import os import httpx THRESHOLD = 10 BOT_TOKEN = os.getenv("TELEGRAM_BOT_TOKEN") CHAT_ID = os.getenv("TELEGRAM_HOME_CHANNEL") async def handle(event_type: str, context: dict): iteration = context.get("iteration", 0) if iteration == THRESHOLD and BOT_TOKEN and CHAT_ID: tools = ", ".join(context.get("tool_names", [])) text = f"⚠️ Agent has been running for {iteration} steps. Last tools: {tools}" async with httpx.AsyncClient() as client: await client.post( f"https://api.telegram.org/bot{BOT_TOKEN}/sendMessage", json={"chat_id": CHAT_ID, "text": text}, ) ``` #### Command Usage Logger Track which slash commands are used: ```yaml # ~/.claway/hooks/command-logger/HOOK.yaml name: command-logger description: Log slash command usage events: - command:* ``` ```python # ~/.claway/hooks/command-logger/handler.py import json from datetime import datetime from pathlib import Path LOG = Path.home() / ".claway" / "logs" / "command_usage.jsonl" def handle(event_type: str, context: dict): LOG.parent.mkdir(parents=True, exist_ok=True) entry = { "ts": datetime.now().isoformat(), "command": context.get("command"), "args": context.get("args"), "platform": context.get("platform"), "user": context.get("user_id"), } with open(LOG, "a") as f: f.write(json.dumps(entry) + "\n") ``` #### Session Start Webhook POST to an external service on new sessions: ```yaml # ~/.claway/hooks/session-webhook/HOOK.yaml name: session-webhook description: Notify external service on new sessions events: - session:start - session:reset ``` ```python # ~/.claway/hooks/session-webhook/handler.py import httpx WEBHOOK_URL = "https://your-service.example.com/claway-events" async def handle(event_type: str, context: dict): async with httpx.AsyncClient() as client: await client.post(WEBHOOK_URL, json={ "event": event_type, **context, }, timeout=5) ``` ### Tutorial: BOOT.md — Run a Startup Checklist on Every Gateway Boot A popular pattern from the community: drop a Markdown checklist at `~/.claway/BOOT.md`, and have the agent run it once every time the gateway starts. Useful for "on every boot, check overnight cron failures and ping me on Discord if anything failed," or "summarize the last 24h of deploy.log and post it to Slack #ops." This tutorial shows how to build it yourself as a user-defined hook. Claway does not ship a built-in BOOT.md hook — you wire up exactly the behavior you want. #### What we're building 1. A file at `~/.claway/BOOT.md` with natural-language startup instructions. 2. A gateway hook that fires on `gateway:startup`, spawns a one-shot agent with your gateway's resolved model/credentials, and runs the BOOT.md instructions. 3. A `[SILENT]` convention so the agent can opt out of sending a message when there's nothing to report. #### Step 1: Write your checklist Create `~/.claway/BOOT.md`. Write it as if you were giving instructions to a human assistant: ```markdown # Startup Checklist 1. Run `claway cron list` and check if any scheduled jobs failed overnight. 2. If any failed, summarize them for Discord #ops (the hook delivers your final response to its configured target). 3. Check if `/opt/app/deploy.log` has any ERROR lines from the last 24 hours. If yes, summarize them and include in the same report. 4. If nothing went wrong, reply with only `[SILENT]` so no message is sent. ``` The agent sees this as part of its prompt, so anything you can describe in plain language works — tool calls, shell commands, sending messages, summarizing files. #### Step 2: Create the hook ```text ~/.claway/hooks/boot-md/ ├── HOOK.yaml └── handler.py ``` **`~/.claway/hooks/boot-md/HOOK.yaml`** ```yaml name: boot-md description: Run ~/.claway/BOOT.md on gateway startup events: - gateway:startup ``` **`~/.claway/hooks/boot-md/handler.py`** ```python """Run ~/.claway/BOOT.md on every gateway startup.""" import logging import threading from pathlib import Path logger = logging.getLogger("hooks.boot-md") BOOT_FILE = Path.home() / ".claway" / "BOOT.md" def _build_prompt(content: str) -> str: return ( "You are running a startup boot checklist. Follow the instructions " "below exactly.\n\n" "---\n" f"{content}\n" "---\n\n" "Execute each instruction. Put any user-facing summary in your " "final response — the hook delivers it to the configured channel " "(e.g. Discord or Slack); you do not send messages yourself.\n" "If nothing needs attention and there is nothing to report, reply " "with ONLY: [SILENT]" ) def _run_boot_agent(content: str) -> None: """Spawn a one-shot agent and execute the checklist. Uses the gateway's resolved model and runtime credentials so this works against custom endpoints, aggregators, and OAuth-based providers alike. """ try: from gateway.run import _resolve_gateway_model, _resolve_runtime_agent_kwargs from run_agent import AIAgent agent = AIAgent( model=_resolve_gateway_model(), **_resolve_runtime_agent_kwargs(), platform="gateway", quiet_mode=True, skip_context_files=True, skip_memory=True, max_iterations=20, ) result = agent.run_conversation(_build_prompt(content)) response = (result.get("final_response", "") or "").strip() if response.upper() not in {"[SILENT]", "SILENT", "NO_REPLY", "NO REPLY"}: logger.info("boot-md completed: %s", response[:200]) else: logger.info("boot-md completed (nothing to report)") except Exception as e: logger.error("boot-md agent failed: %s", e) async def handle(event_type: str, context: dict) -> None: if not BOOT_FILE.exists(): return content = BOOT_FILE.read_text(encoding="utf-8").strip() if not content: return logger.info("Running BOOT.md (%d chars)", len(content)) # Background thread so gateway startup isn't blocked on a full agent turn. thread = threading.Thread( target=_run_boot_agent, args=(content,), name="boot-md", daemon=True, ) thread.start() ``` The two key lines: - `_resolve_gateway_model()` reads the gateway's currently-configured model. - `_resolve_runtime_agent_kwargs()` resolves provider credentials the same way a normal gateway turn does — including API keys, base URLs, OAuth tokens, and credential pools. Without these, a bare `AIAgent()` falls back to built-in defaults and will 401 against any non-default endpoint. #### Step 3: Test it Restart the gateway: ```bash claway gateway restart ``` Watch the logs: ```bash claway logs --follow --level INFO | grep boot-md ``` You should see `Running BOOT.md (N chars)` followed by either `boot-md completed: ...` (summary of what the agent did) or `boot-md completed (nothing to report)` when the agent replied with an exact silence token such as `[SILENT]`. Delete `~/.claway/BOOT.md` to disable the checklist — the hook stays loaded but silently skips when the file isn't there. #### Extending the pattern - **Schedule-aware checklists:** key off `datetime.now().weekday()` inside BOOT.md's instructions ("if it's Monday, also check the weekly deploy log"). The instructions are free-form text, so anything the agent can reason about is fair game. - **Multiple checklists:** point the hook at a different file (`STARTUP.md`, `MORNING.md`, etc.) and register separate hook directories for each. - **Non-agent variant:** if you don't need a full agent loop, skip `AIAgent` entirely and have the handler post a fixed notification directly via `httpx`. Cheaper, faster, and has no provider dependency. #### Why this isn't a built-in An earlier version of Claway shipped this as a built-in hook and silently spawned an agent with bare defaults on every gateway boot. That surprised users with custom endpoints and made the feature invisible to users who didn't know it was running. Keeping it as a documented pattern — built by you, in your hooks directory — means you see exactly what it does and opt in by writing the files. ### How It Works 1. On gateway startup, `HookRegistry.discover_and_load()` scans `~/.claway/hooks/` 2. Each subdirectory with `HOOK.yaml` + `handler.py` is loaded dynamically 3. Handlers are registered for their declared events 4. At each lifecycle point, `hooks.emit()` fires all matching handlers 5. Errors in any handler are caught and logged — a broken hook never crashes the agent :::info Gateway hooks only fire in the **gateway** (Telegram, Discord, Slack, WhatsApp, Teams). The CLI does not load gateway hooks. For hooks that work everywhere, use [plugin hooks](#plugin-hooks). ::: ## Plugin Hooks [Plugins](/user-guide/features/plugins) can register hooks that fire in **both CLI and gateway** sessions. These are registered programmatically via `ctx.register_hook()` in your plugin's `register()` function. For plugin packaging and registration details, see the [Plugins guide](/user-guide/features/plugins). ```python def register(ctx): ctx.register_hook("pre_tool_call", my_tool_observer) ctx.register_hook("post_tool_call", my_tool_logger) ctx.register_hook("pre_llm_call", my_memory_callback) ctx.register_hook("post_llm_call", my_sync_callback) ctx.register_hook("on_session_start", my_init_callback) ctx.register_hook("on_session_end", my_cleanup_callback) ``` **General rules for all hooks:** - Callbacks receive **keyword arguments**. Always accept `**kwargs` for forward compatibility — new parameters may be added in future versions without breaking your plugin. - If a callback **crashes**, it's logged and skipped. Other hooks and the agent continue normally. A misbehaving plugin can never break the agent. - Two hooks' return values affect behavior: [`pre_tool_call`](#pre_tool_call) can **block** the tool, and [`pre_llm_call`](#pre_llm_call) can **inject context** into the LLM call. All other hooks are fire-and-forget observers. - Observer callbacks receive `telemetry_schema_version` automatically. When present, `turn_id`, `api_request_id`, `task_id`, `session_id`, and `api_call_count` are separate correlation fields. Treat `api_request_id` as an opaque identifier; do not parse its string format. ### Quick reference | Hook | Fires when | Returns | |------|-----------|---------| | [`pre_tool_call`](#pre_tool_call) | Before any tool executes | `{"action": "block", "message": str}` to veto the call | | [`post_tool_call`](#post_tool_call) | After any tool returns | ignored | | [`pre_llm_call`](#pre_llm_call) | Once per turn, before the tool-calling loop | `{"context": str}` to prepend context to the user message | | [`post_llm_call`](#post_llm_call) | Once per turn, after the tool-calling loop | ignored | | [`pre_verify`](#pre_verify) | Once per turn when the agent edited code, before it verifies/finishes | `{"action": "continue", "message": str}` to keep going | | [`on_session_start`](#on_session_start) | New session created (first turn only) | ignored | | [`on_session_end`](#on_session_end) | Session ends | ignored | | [`on_session_finalize`](#on_session_finalize) | CLI/gateway tears down an active session (flush, save, stats) | ignored | | [`on_session_reset`](#on_session_reset) | Gateway swaps in a fresh session key (e.g. `/new`, `/reset`) | ignored | | [`subagent_start`](#subagent_start) | A `delegate_task` child has been constructed and is about to run | ignored | | [`subagent_stop`](#subagent_stop) | A `delegate_task` child has exited | ignored | | [`pre_gateway_dispatch`](#pre_gateway_dispatch) | Gateway received a user message, before auth + dispatch | `{"action": "skip" \| "rewrite" \| "allow", ...}` to influence flow | | [`pre_approval_request`](#pre_approval_request) | Dangerous command needs user approval, before the prompt/notification is sent | ignored | | [`post_approval_response`](#post_approval_response) | User responded to an approval prompt (or it timed out) | ignored | | [`transform_tool_result`](#transform_tool_result) | After any tool returns, before the result is handed back to the model | `str` to replace the result, `None` to leave unchanged | | [`transform_terminal_output`](#transform_terminal_output) | Inside the `terminal` tool, before truncation/ANSI-strip/redact | `str` to replace the raw output, `None` to leave unchanged | | [`transform_llm_output`](#transform_llm_output) | After the tool-calling loop completes, before the final response is delivered | `str` to replace the response text, `None`/empty to leave unchanged | --- ### `pre_tool_call` Fires **immediately before** every tool execution — built-in tools and plugin tools alike. **Callback signature:** ```python def my_callback(tool_name: str, args: dict, task_id: str, **kwargs): ``` | Parameter | Type | Description | |-----------|------|-------------| | `tool_name` | `str` | Name of the tool about to execute (e.g. `"terminal"`, `"web_search"`, `"read_file"`) | | `args` | `dict` | The arguments the model passed to the tool | | `task_id` | `str` | Session/task identifier. Empty string if not set. | **Fires:** In `model_tools.py`, inside `handle_function_call()`, before the tool's handler runs. Fires once per tool call — if the model calls 3 tools in parallel, this fires 3 times. **Return value — veto the call:** ```python return {"action": "block", "message": "Reason the tool call was blocked"} ``` The agent short-circuits the tool with `message` as the error returned to the model. The first matching block directive wins (Python plugins registered first, then shell hooks). Any other return value is ignored, so existing observer-only callbacks keep working unchanged. **Use cases:** Logging, audit trails, tool call counters, blocking dangerous operations, rate limiting, per-user policy enforcement. **Example — tool call audit log:** ```python import json, logging from datetime import datetime logger = logging.getLogger(__name__) def audit_tool_call(tool_name, args, task_id, **kwargs): logger.info("TOOL_CALL session=%s tool=%s args=%s", task_id, tool_name, json.dumps(args)[:200]) def register(ctx): ctx.register_hook("pre_tool_call", audit_tool_call) ``` **Example — warn on dangerous tools:** ```python DANGEROUS = {"terminal", "write_file", "patch"} def warn_dangerous(tool_name, **kwargs): if tool_name in DANGEROUS: print(f"⚠ Executing potentially dangerous tool: {tool_name}") def register(ctx): ctx.register_hook("pre_tool_call", warn_dangerous) ``` --- ### `post_tool_call` Fires **immediately after** every tool execution returns. **Callback signature:** ```python def my_callback(tool_name: str, args: dict, result: str, task_id: str, duration_ms: int, **kwargs): ``` | Parameter | Type | Description | |-----------|------|-------------| | `tool_name` | `str` | Name of the tool that just executed | | `args` | `dict` | The arguments the model passed to the tool | | `result` | `str` | The tool's return value (always a JSON string) | | `task_id` | `str` | Session/task identifier. Empty string if not set. | | `duration_ms` | `int` | How long the tool's dispatch took, in milliseconds (measured with `time.monotonic()` around `registry.dispatch()`). | **Fires:** In `model_tools.py`, inside `handle_function_call()`, after the tool's handler returns. Fires once per tool call. Does **not** fire if the tool raised an unhandled exception (the error is caught and returned as an error JSON string instead, and `post_tool_call` fires with that error string as `result`). **Return value:** Ignored. **Use cases:** Logging tool results, metrics collection, tracking tool success/failure rates, latency dashboards, per-tool budget alerts, sending notifications when specific tools complete. **Example — track tool usage metrics:** ```python from collections import Counter, defaultdict import json _tool_counts = Counter() _error_counts = Counter() _latency_ms = defaultdict(list) def track_metrics(tool_name, result, duration_ms=0, **kwargs): _tool_counts[tool_name] += 1 _latency_ms[tool_name].append(duration_ms) try: parsed = json.loads(result) if "error" in parsed: _error_counts[tool_name] += 1 except (json.JSONDecodeError, TypeError): pass def register(ctx): ctx.register_hook("post_tool_call", track_metrics) ``` --- ### `pre_llm_call` Fires **once per turn**, before the tool-calling loop begins. This is the **only hook whose return value is used** — it can inject context into the current turn's user message. **Callback signature:** ```python def my_callback(session_id: str, user_message: str, conversation_history: list, is_first_turn: bool, model: str, platform: str, **kwargs): ``` | Parameter | Type | Description | |-----------|------|-------------| | `session_id` | `str` | Unique identifier for the current session | | `user_message` | `str` | The user's original message for this turn (before any skill injection) | | `conversation_history` | `list` | Copy of the full message list (OpenAI format: `[{"role": "user", "content": "..."}]`) | | `is_first_turn` | `bool` | `True` if this is the first turn of a new session, `False` on subsequent turns | | `model` | `str` | The model identifier (e.g. `"anthropic/claude-sonnet-4.6"`) | | `platform` | `str` | Where the session is running: `"cli"`, `"telegram"`, `"discord"`, etc. | **Fires:** In `run_agent.py`, inside `run_conversation()`, after context compression but before the main `while` loop. Fires once per `run_conversation()` call (i.e. once per user turn), not once per API call within the tool loop. **Return value:** If the callback returns a dict with a `"context"` key, or a plain non-empty string, the text is appended to the current turn's user message. Return `None` for no injection. ```python # Inject context return {"context": "Recalled memories:\n- User likes Python\n- Working on claway"} # Plain string (equivalent) return "Recalled memories:\n- User likes Python" # No injection return None ``` **Where context is injected:** Always the **user message**, never the system prompt. This preserves the prompt cache — the system prompt stays identical across turns, so cached tokens are reused. The system prompt is Claway's territory (model guidance, tool enforcement, personality, skills). Plugins contribute context alongside the user's input. All injected context is **ephemeral** — added at API call time only. The original user message in the conversation history is never mutated, and nothing is persisted to the session database. When **multiple plugins** return context, their outputs are joined with double newlines in plugin discovery order (alphabetical by directory name). **Use cases:** Memory recall, RAG context injection, guardrails, per-turn analytics. **Example — memory recall:** ```python import httpx MEMORY_API = "https://your-memory-api.example.com" def recall(session_id, user_message, is_first_turn, **kwargs): try: resp = httpx.post(f"{MEMORY_API}/recall", json={ "session_id": session_id, "query": user_message, }, timeout=3) memories = resp.json().get("results", []) if not memories: return None text = "Recalled context:\n" + "\n".join(f"- {m['text']}" for m in memories) return {"context": text} except Exception: return None def register(ctx): ctx.register_hook("pre_llm_call", recall) ``` **Example — guardrails:** ```python POLICY = "Never execute commands that delete files without explicit user confirmation." def guardrails(**kwargs): return {"context": POLICY} def register(ctx): ctx.register_hook("pre_llm_call", guardrails) ``` --- ### `post_llm_call` Fires **once per turn**, after the tool-calling loop completes and the agent has produced a final response. Only fires on **successful** turns — does not fire if the turn was interrupted. **Callback signature:** ```python def my_callback(session_id: str, user_message: str, assistant_response: str, conversation_history: list, model: str, platform: str, **kwargs): ``` | Parameter | Type | Description | |-----------|------|-------------| | `session_id` | `str` | Unique identifier for the current session | | `user_message` | `str` | The user's original message for this turn | | `assistant_response` | `str` | The agent's final text response for this turn | | `conversation_history` | `list` | Copy of the full message list after the turn completed | | `model` | `str` | The model identifier | | `platform` | `str` | Where the session is running | **Fires:** In `run_agent.py`, inside `run_conversation()`, after the tool loop exits with a final response. Guarded by `if final_response and not interrupted` — so it does **not** fire when the user interrupts mid-turn or the agent hits the iteration limit without producing a response. **Return value:** Ignored. **Use cases:** Syncing conversation data to an external memory system, computing response quality metrics, logging turn summaries, triggering follow-up actions. **Example — sync to external memory:** ```python import httpx MEMORY_API = "https://your-memory-api.example.com" def sync_memory(session_id, user_message, assistant_response, **kwargs): try: httpx.post(f"{MEMORY_API}/store", json={ "session_id": session_id, "user": user_message, "assistant": assistant_response, }, timeout=5) except Exception: pass # best-effort def register(ctx): ctx.register_hook("post_llm_call", sync_memory) ``` **Example — track response lengths:** ```python import logging logger = logging.getLogger(__name__) def log_response_length(session_id, assistant_response, model, **kwargs): logger.info("RESPONSE session=%s model=%s chars=%d", session_id, model, len(assistant_response or "")) def register(ctx): ctx.register_hook("post_llm_call", log_response_length) ``` --- ### `pre_verify` Fires **once per turn when the agent edited code**, just before it finishes (after the built-in verify-on-stop guard). This is a user/plugin policy gate: a callback can keep the agent going — run a check, defer it, tidy the diff — instead of letting it stop. Claway's shipped verification guidance is not a default `pre_verify` hook. It is appended to the evidence-based verify-on-stop nudge when edited code lacks fresh verification evidence, so it does not create a second default continuation path. Set `agent.verify_guidance: false` to keep that built-in evidence nudge terse. **Callback signature:** ```python def my_callback(session_id: str, platform: str, model: str, coding: bool, attempt: int, final_response: str, changed_paths: list, **kwargs): ``` | Parameter | Type | Description | |-----------|------|-------------| | `session_id` | `str` | Unique identifier for the current session | | `platform` | `str` | Where the session is running (`"cli"`, `"telegram"`, …) | | `model` | `str` | The model identifier | | `coding` | `bool` | Whether the turn is in the coding posture (in a code workspace) — scope your hook on this | | `attempt` | `int` | How many times this turn has already been nudged (0 on the first) — self-throttle on this | | `final_response` | `str` | The answer the agent is about to deliver | | `changed_paths` | `list` | Files the agent edited this turn (sorted, always non-empty here) | Scope a hook to the coding context by checking `coding` and make it one-shot with `attempt` (shell hooks read both from `.extra`), the same way a `pre_tool_call` hook scopes on `tool_name` — so you can register several `pre_verify` hooks, each firing only where it should. **Fires:** In `agent/conversation_loop.py`, at the point the agent would accept a final answer, immediately after the verify-on-stop check — but only when the agent edited code this turn and at least one `pre_verify` hook is registered. **Return value — keep the agent going:** ```python return {"action": "continue", "message": "Run the formatter on your changes, then finish."} ``` The `message` is appended as a synthetic user turn and the loop runs again. The Claude-Code Stop shape (`{"decision": "block", "reason": "..."}`, where blocking the stop means *keep going*) is accepted too. A directive with no message — or any other return — lets the turn finish. **Bounded:** consecutive continue directives in one turn are capped by `agent.max_verify_nudges` (default 3), so a hook that always says continue can never trap the loop. The attempted answer is kept in history but not surfaced to the user while the agent is being nudged. **Make it idempotent:** the hook re-fires after each nudge, so gate on `attempt` (`if attempt: return None`) — otherwise it just nudges until the bound is hit. **Use cases:** defer tests/lints during creative iteration, require green checks for certain paths, block "done" until a changelog entry exists, run a project-specific verification checklist. **Example — defer checks on creative UI work, scoped + one-shot:** ```python UI = (".tsx", ".jsx", ".css", ".scss") def defer_ui_checks(coding, attempt, changed_paths, **kwargs): if attempt or not coding: return None # one-shot, coding only if not all(p.endswith(UI) for p in changed_paths): return None # only pure-UI edits return { "action": "continue", "message": "This is UI work — don't run tests/lints yet; ask the user to " "eyeball it first, and clean the diff before any commit.", } def register(ctx): ctx.register_hook("pre_verify", defer_ui_checks) ``` For standing guidance that should shape the built-in missing-evidence nudge, use `agent.verify_guidance`. For broader coding posture rules that don't need to *gate* verification, prefer `agent.coding_instructions` in `config.yaml` — it rides the coding brief and costs no extra turn. --- ### `on_session_start` Fires **once** when a brand-new session is created. Does **not** fire on session continuation (when the user sends a second message in an existing session). **Callback signature:** ```python def my_callback(session_id: str, model: str, platform: str, **kwargs): ``` | Parameter | Type | Description | |-----------|------|-------------| | `session_id` | `str` | Unique identifier for the new session | | `model` | `str` | The model identifier | | `platform` | `str` | Where the session is running | **Fires:** In `run_agent.py`, inside `run_conversation()`, during the first turn of a new session — specifically after the system prompt is built but before the tool loop starts. The check is `if not conversation_history` (no prior messages = new session). **Return value:** Ignored. **Use cases:** Initializing session-scoped state, warming caches, registering the session with an external service, logging session starts. **Example — initialize a session cache:** ```python _session_caches = {} def init_session(session_id, model, platform, **kwargs): _session_caches[session_id] = { "model": model, "platform": platform, "tool_calls": 0, "started": __import__("datetime").datetime.now().isoformat(), } def register(ctx): ctx.register_hook("on_session_start", init_session) ``` --- ### `on_session_end` Fires at the **very end** of every `run_conversation()` call, regardless of outcome. Also fires from the CLI's exit handler if the agent was mid-turn when the user quit. **Callback signature:** ```python def my_callback(session_id: str, completed: bool, interrupted: bool, model: str, platform: str, **kwargs): ``` | Parameter | Type | Description | |-----------|------|-------------| | `session_id` | `str` | Unique identifier for the session | | `completed` | `bool` | `True` if the agent produced a final response, `False` otherwise | | `interrupted` | `bool` | `True` if the turn was interrupted (user sent new message, `/stop`, or quit) | | `model` | `str` | The model identifier | | `platform` | `str` | Where the session is running | **Fires:** In two places: 1. **`run_agent.py`** — at the end of every `run_conversation()` call, after all cleanup. Always fires, even if the turn errored. 2. **`cli.py`** — in the CLI's atexit handler, but **only** if the agent was mid-turn (`_agent_running=True`) when the exit occurred. This catches Ctrl+C and `/exit` during processing. In this case, `completed=False` and `interrupted=True`. **Return value:** Ignored. **Use cases:** Flushing buffers, closing connections, persisting session state, logging session duration, cleanup of resources initialized in `on_session_start`. **Example — flush and cleanup:** ```python _session_caches = {} def cleanup_session(session_id, completed, interrupted, **kwargs): cache = _session_caches.pop(session_id, None) if cache: # Flush accumulated data to disk or external service status = "completed" if completed else ("interrupted" if interrupted else "failed") print(f"Session {session_id} ended: {status}, {cache['tool_calls']} tool calls") def register(ctx): ctx.register_hook("on_session_end", cleanup_session) ``` **Example — session duration tracking:** ```python import time, logging logger = logging.getLogger(__name__) _start_times = {} def on_start(session_id, **kwargs): _start_times[session_id] = time.time() def on_end(session_id, completed, interrupted, **kwargs): start = _start_times.pop(session_id, None) if start: duration = time.time() - start logger.info("SESSION_DURATION session=%s seconds=%.1f completed=%s interrupted=%s", session_id, duration, completed, interrupted) def register(ctx): ctx.register_hook("on_session_start", on_start) ctx.register_hook("on_session_end", on_end) ``` --- ### `on_session_finalize` Fires when the CLI or gateway **tears down** an active session — for example, when the user runs `/new`, the gateway GC'd an idle session, or the CLI quit with an active agent. This is the last chance to flush state tied to the outgoing session before its identity is gone. **Callback signature:** ```python def my_callback(session_id: str | None, platform: str, **kwargs): ``` | Parameter | Type | Description | |-----------|------|-------------| | `session_id` | `str` or `None` | The outgoing session ID. May be `None` if no active session existed. | | `platform` | `str` | `"cli"` or the messaging platform name (`"telegram"`, `"discord"`, etc.). | **Fires:** In `cli.py` (on `/new` / CLI exit) and `gateway/run.py` (when a session is reset or GC'd). Always paired with `on_session_reset` on the gateway side. **Return value:** Ignored. **Use cases:** Persist final session metrics before the session ID is discarded, close per-session resources, emit a final telemetry event, drain queued writes. --- ### `on_session_reset` Fires when the gateway **swaps in a new session key** for an active chat — the user invoked `/new`, `/reset`, `/clear`, or the adapter picked a fresh session after an idle window. This lets plugins react to the fact that conversation state has been wiped without waiting for the next `on_session_start`. **Callback signature:** ```python def my_callback(session_id: str, platform: str, **kwargs): ``` | Parameter | Type | Description | |-----------|------|-------------| | `session_id` | `str` | The new session's ID (already rotated to the fresh value). | | `platform` | `str` | The messaging platform name. | **Fires:** In `gateway/run.py`, immediately after the new session key is allocated but before the next inbound message is processed. On the gateway, the order is: `on_session_finalize(old_id)` → swap → `on_session_reset(new_id)` → `on_session_start(new_id)` on the first inbound turn. **Return value:** Ignored. **Use cases:** Reset per-session caches keyed by `session_id`, emit "session rotated" analytics, prime a fresh state bucket. --- See the **[Build a Plugin guide](/guides/build-a-claway-plugin)** for the full walkthrough including tool schemas, handlers, and advanced hook patterns. --- ### `subagent_start` Fires **once per child agent** after `delegate_task` has constructed the child `AIAgent` and before that child is run. Whether you delegate a single task or a batch of three, this hook fires once for each child. This hook is specific to delegation/subagent lifecycle. It is not a universal "before any agent invocation" gate for gateway, CLI, cron, batch, MoA, or other runner-originated agent executions. **Callback signature:** ```python def my_callback(parent_session_id: str | None, parent_turn_id: str, parent_subagent_id: str | None, child_session_id: str | None, child_subagent_id: str, child_role: str, child_goal: str, **kwargs): ``` | Parameter | Type | Description | |-----------|------|-------------| | `parent_session_id` | `str \| None` | Session ID of the delegating parent agent. | | `parent_turn_id` | `str` | Turn ID of the parent agent turn that requested delegation, if available. | | `parent_subagent_id` | `str \| None` | Parent subagent ID when this child was spawned by another subagent; `None` for top-level parent agents. | | `child_session_id` | `str \| None` | Session ID allocated for the child agent. | | `child_subagent_id` | `str` | Stable subagent ID used by delegation observability and controls. | | `child_role` | `str` | Effective child role after delegation policy is applied, for example `"leaf"` or `"orchestrator"`. | | `child_goal` | `str` | Delegated goal/prompt that the child agent will execute. | **Fires:** In `tools/delegate_tool.py`, inside `_build_child_agent()`, after the child `AIAgent` has been constructed and annotated with subagent identity metadata, and before `_run_single_child()` runs the child. **Return value:** Ignored. This is an observer hook only; returning a value does not block or mutate the child agent run. **Use cases:** Logging subagent creation, mapping parent/child session relationships, tracking nested delegation trees, emitting pre-run audit records, pre-allocating per-child observability resources. **Example — log subagent creation:** ```python import logging logger = logging.getLogger(__name__) def log_subagent_start( parent_session_id, parent_turn_id, child_session_id, child_subagent_id, child_role, child_goal, **kwargs, ): logger.info( "SUBAGENT_START parent=%s turn=%s child_session=%s child=%s role=%s goal=%r", parent_session_id, parent_turn_id, child_session_id, child_subagent_id, child_role, child_goal[:200], ) def register(ctx): ctx.register_hook("subagent_start", log_subagent_start) ``` :::info `subagent_start` is useful for delegation observability, but it is not a blocking policy hook. To block delegation before a child is built, use [`pre_tool_call`](#pre_tool_call) to block the `delegate_task` tool call. ::: --- ### `subagent_stop` Fires **once per child agent** after `delegate_task` finishes. Whether you delegated a single task or a batch of three, this hook fires once for each child, serialised on the parent thread. **Callback signature:** ```python def my_callback(parent_session_id: str, child_role: str | None, child_summary: str | None, child_status: str, duration_ms: int, **kwargs): ``` | Parameter | Type | Description | |-----------|------|-------------| | `parent_session_id` | `str` | Session ID of the delegating parent agent | | `child_role` | `str \| None` | Orchestrator role tag set on the child (`None` if the feature isn't enabled) | | `child_summary` | `str \| None` | The final response the child returned to the parent | | `child_status` | `str` | `"completed"`, `"failed"`, `"interrupted"`, or `"error"` | | `duration_ms` | `int` | Wall-clock time spent running the child, in milliseconds | **Fires:** In `tools/delegate_tool.py`, after `ThreadPoolExecutor.as_completed()` drains all child futures. Firing is marshalled to the parent thread so hook authors don't have to reason about concurrent callback execution. **Return value:** Ignored. **Use cases:** Logging orchestration activity, accumulating child durations for billing, writing post-delegation audit records. **Example — log orchestrator activity:** ```python import logging logger = logging.getLogger(__name__) def log_subagent(parent_session_id, child_role, child_status, duration_ms, **kwargs): logger.info( "SUBAGENT parent=%s role=%s status=%s duration_ms=%d", parent_session_id, child_role, child_status, duration_ms, ) def register(ctx): ctx.register_hook("subagent_stop", log_subagent) ``` :::info With heavy delegation (e.g. orchestrator roles × 5 leaves × nested depth), `subagent_stop` fires many times per turn. Keep your callback fast; push expensive work to a background queue. ::: --- ### `pre_gateway_dispatch` Fires **once per incoming `MessageEvent`** in the gateway, after the internal-event guard but **before** auth/pairing and agent dispatch. This is the interception point for gateway-level message-flow policies (listen-only windows, human handover, per-chat routing, etc.) that don't fit cleanly into any single platform adapter. **Callback signature:** ```python def my_callback(event, gateway, session_store, **kwargs): ``` | Parameter | Type | Description | |-----------|------|-------------| | `event` | `MessageEvent` | The normalized inbound message (has `.text`, `.source`, `.message_id`, `.internal`, etc.). | | `gateway` | `GatewayRunner` | The active gateway runner, so plugins can call `gateway.adapters[platform].send(...)` for side-channel replies (owner notifications, etc.). | | `session_store` | `SessionStore` | For silent transcript ingestion via `session_store.append_to_transcript(...)`. | **Fires:** In `gateway/run.py`, inside `GatewayRunner._handle_message()`, immediately after `is_internal` is computed. **Internal events skip the hook entirely** (they are system-generated — background-process completions, etc. — and must not be gate-kept by user-facing policy). **Return value:** `None` or a dict. The first recognized action dict wins; remaining plugin results are ignored. Exceptions in plugin callbacks are caught and logged; the gateway always falls through to normal dispatch on error. | Return | Effect | |--------|--------| | `{"action": "skip", "reason": "..."}` | Drop the message — no agent reply, no pairing flow, no auth. Plugin is assumed to have handled it (e.g. silent-ingested into the transcript). | | `{"action": "rewrite", "text": "new text"}` | Replace `event.text`, then continue normal dispatch with the modified event. Useful for collapsing buffered ambient messages into a single prompt. | | `{"action": "allow"}` / `None` | Normal dispatch — runs the full auth / pairing / agent-loop chain. | **Use cases:** Listen-only group chats (only respond when tagged; buffer ambient messages into context); human handover (silent-ingest customer messages while owner handles the chat manually); per-profile rate limiting; policy-driven routing. **Example — drop unauthorized DMs silently without triggering the pairing code:** ```python def deny_unauthorized_dms(event, **kwargs): src = event.source if src.chat_type == "dm" and not _is_approved_user(src.user_id): return {"action": "skip", "reason": "unauthorized-dm"} return None def register(ctx): ctx.register_hook("pre_gateway_dispatch", deny_unauthorized_dms) ``` **Example — rewrite an ambient-message buffer into a single prompt on mention:** ```python _buffers = {} def buffer_or_rewrite(event, **kwargs): key = (event.source.platform, event.source.chat_id) buf = _buffers.setdefault(key, []) if _bot_mentioned(event.text): combined = "\n".join(buf + [event.text]) buf.clear() return {"action": "rewrite", "text": combined} buf.append(event.text) return {"action": "skip", "reason": "ambient-buffered"} def register(ctx): ctx.register_hook("pre_gateway_dispatch", buffer_or_rewrite) ``` --- ### `pre_approval_request` Fires **immediately before** an approval request is shown to the user — covers every surface: interactive CLI, the Ink TUI, gateway platforms (Telegram, Discord, Slack, WhatsApp, Matrix, etc.), and ACP clients (VS Code, Zed, JetBrains). This is the right place to wire a custom notifier — for example, a macOS menu-bar app that pops an allow/deny notification, or an audit log that records every approval request with context. **Callback signature:** ```python def my_callback( command: str, description: str, pattern_key: str, pattern_keys: list[str], session_key: str, surface: str, **kwargs, ): ``` | Parameter | Type | Description | |-----------|------|-------------| | `command` | `str` | The shell command awaiting approval | | `description` | `str` | Human-readable reason(s) the command is flagged (combined when multiple patterns match) | | `pattern_key` | `str` | Primary pattern key that triggered the approval (e.g. `"rm_rf"`, `"sudo"`) | | `pattern_keys` | `list[str]` | All pattern keys that matched | | `session_key` | `str` | Session identifier, useful for scoping notifications per-chat | | `surface` | `str` | `"cli"` for interactive CLI/TUI prompts, `"gateway"` for async platform approvals | **Return value:** ignored. Hooks here are observer-only; they cannot veto or pre-answer the approval. Use [`pre_tool_call`](#pre_tool_call) to block a tool before it reaches the approval system. **Use cases:** Desktop notifications, push alerts, audit logging, Slack webhooks, escalation routing, metrics. **Example — desktop notification on macOS:** ```python import subprocess def notify_approval(command, description, session_key, **kwargs): title = "Claway needs approval" body = f"{description}: {command[:80]}" subprocess.Popen([ "osascript", "-e", f'display notification "{body}" with title "{title}"', ]) def register(ctx): ctx.register_hook("pre_approval_request", notify_approval) ``` --- ### `post_approval_response` Fires **after** the user responds to an approval prompt (or the prompt times out). **Callback signature:** ```python def my_callback( command: str, description: str, pattern_key: str, pattern_keys: list[str], session_key: str, surface: str, choice: str, **kwargs, ): ``` Same kwargs as `pre_approval_request`, plus: | Parameter | Type | Description | |-----------|------|-------------| | `choice` | `str` | One of `"once"`, `"session"`, `"always"`, `"deny"`, or `"timeout"` | **Return value:** ignored. **Use cases:** Close the matching desktop notification, record the final decision in an audit log, update metrics, roll forward a rate limiter. ```python def log_decision(command, choice, session_key, **kwargs): logger.info("approval %s: %s for session %s", choice, command[:60], session_key) def register(ctx): ctx.register_hook("post_approval_response", log_decision) ``` --- ### `transform_tool_result` Fires **after** a tool returns and **before** the result is appended to the conversation. Lets a plugin rewrite ANY tool's result string — not just terminal output — before the model sees it. **Callback signature:** ```python def my_callback( tool_name: str, arguments: dict, result: str, task_id: str | None, **kwargs, ) -> str | None: ``` | Parameter | Type | Description | |-----------|------|-------------| | `tool_name` | `str` | Tool that produced the result (`read_file`, `web_extract`, `delegate_task`, …). | | `arguments` | `dict` | Arguments the model called the tool with. | | `result` | `str` | The tool's raw result string, post-truncation and post-ANSI-strip. | | `task_id` | `str \| None` | Task/session ID when running inside RL/benchmark environments. | **Return value:** `str` to replace the result (the returned string is what the model sees), `None` to leave it unchanged. **Use cases:** Redact organization-specific PII from `web_extract` output, wrap long JSON tool responses in a summary header, inject retrieval-augmented hints into `read_file` results, rewrite `delegate_task` subagent reports into a project-specific schema. ```python import re SECRET = re.compile(r"sk-[A-Za-z0-9]{32,}") def redact_secrets(tool_name, result, **kwargs): if SECRET.search(result): return SECRET.sub("[REDACTED]", result) return None def register(ctx): ctx.register_hook("transform_tool_result", redact_secrets) ``` Applies to every tool. For terminal-only rewriting see `transform_terminal_output` below — it's narrower and runs earlier in the pipeline (pre-truncation, pre-redaction). --- ### `transform_terminal_output` Fires inside the `terminal` tool's foreground-output pipeline, **before** the default 50 KB truncation, ANSI strip, and secret redaction. Lets plugins rewrite the raw stdout/stderr of a shell command before any downstream processing touches it. **Callback signature:** ```python def my_callback( command: str, output: str, exit_code: int, cwd: str, task_id: str | None, **kwargs, ) -> str | None: ``` | Parameter | Type | Description | |-----------|------|-------------| | `command` | `str` | The shell command that produced the output. | | `output` | `str` | Raw combined stdout/stderr (may be very large — truncation happens after the hook). | | `exit_code` | `int` | Process exit code. | | `cwd` | `str` | Working directory the command ran in. | **Return value:** `str` to replace the output, `None` to leave it unchanged. **Use cases:** Inject summaries for commands that produce massive output (`du -ah`, `find`, `tree`), tag output with a project-specific marker so downstream hooks know how to handle it, strip timing noise that flaps between runs and defeats prompt caching. ```python def summarize_find(command, output, **kwargs): if command.startswith("find ") and len(output) > 50_000: lines = output.count("\n") head = "\n".join(output.splitlines()[:40]) return f"{head}\n\n[summary: {lines} paths total, showing first 40]" return None def register(ctx): ctx.register_hook("transform_terminal_output", summarize_find) ``` Pairs well with `transform_tool_result` (which covers every other tool). --- ### `transform_llm_output` Fires **once per turn** after the tool-calling loop completes and the model has produced a final response, **before** that response is delivered to the user (CLI, gateway, or programmatic caller). Lets a plugin rewrite the assistant's final text using classical-programming methods — no extra inference tokens burned on SOUL flavor text or a skill-driven transform. **Callback signature:** ```python def my_callback( response_text: str, session_id: str, model: str, platform: str, **kwargs, ) -> str | None: ``` | Parameter | Type | Description | |-----------|------|-------------| | `response_text` | `str` | The assistant's final response text for this turn. | | `session_id` | `str` | Session ID for this conversation (may be empty for one-shot runs). | | `model` | `str` | Model name that produced the response (e.g. `anthropic/claude-sonnet-4.6`). | | `platform` | `str` | Delivery platform (`cli`, `telegram`, `discord`, …; empty when unset). | **Return value:** Non-empty `str` to replace the response text, `None` or empty string to leave it unchanged. **First non-empty string wins** when multiple plugins register — mirroring `transform_tool_result`. **Use cases:** Apply a personality/vocabulary transform (pirate-speak, Spongebob), redact user-specific identifiers from the final text, append a project-specific signature footer, enforce a house style guide without burning tokens on SOUL instructions. ```python import os, re def spongebob(response_text, **kwargs): if os.environ.get("SPONGEBOB_MODE") != "on": return None # pass through unchanged return re.sub(r"!", "!! Tartar sauce!", response_text) def register(ctx): ctx.register_hook("transform_llm_output", spongebob) ``` The hook is guarded on a non-empty, non-interrupted response — it will not fire on stop-button interrupts or empty turns. Exceptions are logged as warnings and do not break agent execution. --- ## Shell Hooks Declare shell-script hooks in your `cli-config.yaml` and Claway will run them as subprocesses whenever the corresponding plugin-hook event fires — in both CLI and gateway sessions. No Python plugin authoring required. Use shell hooks when you want a drop-in, single-file script (Bash, Python, anything with a shebang) to: - **Block a tool call** — reject dangerous `terminal` commands, enforce per-directory policies, require approval for destructive `write_file` / `patch` operations. - **Run after a tool call** — auto-format Python or TypeScript files that the agent just wrote, log API calls, trigger a CI workflow. - **Inject context into the next LLM turn** — prepend `git status` output, the current weekday, or retrieved documents to the user message (see [`pre_llm_call`](#pre_llm_call)). - **Observe lifecycle events** — write a log line when a subagent completes (`subagent_stop`) or a session starts (`on_session_start`). Shell hooks are registered by calling `agent.shell_hooks.register_from_config(cfg)` at both CLI startup (`claway_cli/main.py`) and gateway startup (`gateway/run.py`). They compose naturally with Python plugin hooks — both flow through the same dispatcher. ### Comparison at a glance | Dimension | Shell hooks | [Plugin hooks](#plugin-hooks) | [Gateway hooks](#gateway-event-hooks) | |-----------|-------------|-------------------------------|---------------------------------------| | Declared in | `hooks:` block in `~/.claway/config.yaml` | `register()` in a `plugin.yaml` plugin | `HOOK.yaml` + `handler.py` directory | | Lives under | `~/.claway/agent-hooks/` (by convention) | `~/.claway/plugins/<name>/` | `~/.claway/hooks/<name>/` | | Language | Any (Bash, Python, Go binary, …) | Python only | Python only | | Runs in | CLI + Gateway | CLI + Gateway | Gateway only | | Events | `VALID_HOOKS` (incl. `subagent_stop`) | `VALID_HOOKS` | Gateway lifecycle (`gateway:startup`, `agent:*`, `command:*`) | | Can block a tool call | Yes (`pre_tool_call`) | Yes (`pre_tool_call`) | No | | Can inject LLM context | Yes (`pre_llm_call`) | Yes (`pre_llm_call`) | No | | Consent | First-use prompt per `(event, command)` pair | Implicit (Python plugin trust) | Implicit (dir trust) | | Inter-process isolation | Yes (subprocess) | No (in-process) | No (in-process) | ### Configuration schema ```yaml hooks: <event_name>: # Must be in VALID_HOOKS - matcher: "<regex>" # Optional; used for pre/post_tool_call only command: "<shell command>" # Required; runs via shlex.split, shell=False timeout: <seconds> # Optional; default 60, capped at 300 hooks_auto_accept: false # See "Consent model" below ``` Event names must be one of the [plugin hook events](#plugin-hooks); typos produce a "Did you mean X?" warning and are skipped. Unknown keys inside a single entry are ignored; missing `command` is a skip-with-warning. `timeout > 300` is clamped with a warning. ### JSON wire protocol Each time the event fires, Claway spawns a subprocess for every matching hook (matcher permitting), pipes a JSON payload to **stdin**, and reads **stdout** back as JSON. **stdin — payload the script receives:** ```json { "hook_event_name": "pre_tool_call", "tool_name": "terminal", "tool_input": {"command": "rm -rf /"}, "session_id": "sess_abc123", "cwd": "/home/user/project", "extra": {"task_id": "...", "tool_call_id": "..."} } ``` `tool_name` and `tool_input` are `null` for non-tool events (`pre_llm_call`, `subagent_stop`, session lifecycle). The `extra` dict carries all event-specific kwargs (`user_message`, `conversation_history`, `child_role`, `duration_ms`, …). Unserialisable values are stringified rather than omitted. **stdout — optional response:** ```jsonc // Block a pre_tool_call (both shapes accepted; normalised internally): {"decision": "block", "reason": "Forbidden: rm -rf"} // Claude-Code style {"action": "block", "message": "Forbidden: rm -rf"} // Claway-canonical // Inject context for pre_llm_call: {"context": "Today is Friday, 2026-04-17"} // Keep the agent going at the verify gate (pre_verify); both shapes accepted: {"action": "continue", "message": "Run the formatter, then finish."} {"decision": "block", "reason": "Run the formatter, then finish."} // Silent no-op — any empty / non-matching output is fine: ``` Malformed JSON, non-zero exit codes, and timeouts log a warning but never abort the agent loop. ### Worked examples #### 1. Auto-format Python files after every write ```yaml # ~/.claway/config.yaml hooks: post_tool_call: - matcher: "write_file|patch" command: "~/.claway/agent-hooks/auto-format.sh" ``` ```bash #!/usr/bin/env bash # ~/.claway/agent-hooks/auto-format.sh payload="$(cat -)" path=$(echo "$payload" | jq -r '.tool_input.path // empty') [[ "$path" == *.py ]] && command -v black >/dev/null && black "$path" 2>/dev/null printf '{}\n' ``` The agent's in-context view of the file is **not** re-read automatically — the reformat only affects the file on disk. Subsequent `read_file` calls pick up the formatted version. #### 2. Block destructive `terminal` commands ```yaml hooks: pre_tool_call: - matcher: "terminal" command: "~/.claway/agent-hooks/block-rm-rf.sh" timeout: 5 ``` ```bash #!/usr/bin/env bash # ~/.claway/agent-hooks/block-rm-rf.sh payload="$(cat -)" cmd=$(echo "$payload" | jq -r '.tool_input.command // empty') if echo "$cmd" | grep -qE 'rm[[:space:]]+-rf?[[:space:]]+/'; then printf '{"decision": "block", "reason": "blocked: rm -rf / is not permitted"}\n' else printf '{}\n' fi ``` #### 3. Inject `git status` into every turn (Claude-Code `UserPromptSubmit` equivalent) ```yaml hooks: pre_llm_call: - command: "~/.claway/agent-hooks/inject-cwd-context.sh" ``` ```bash #!/usr/bin/env bash # ~/.claway/agent-hooks/inject-cwd-context.sh cat - >/dev/null # discard stdin payload if status=$(git status --porcelain 2>/dev/null) && [[ -n "$status" ]]; then jq --null-input --arg s "$status" \ '{context: ("Uncommitted changes in cwd:\n" + $s)}' else printf '{}\n' fi ``` Claude Code's `UserPromptSubmit` event is intentionally not a separate Claway event — `pre_llm_call` fires at the same place and already supports context injection. Use it here. #### 4. Log every subagent completion ```yaml hooks: subagent_stop: - command: "~/.claway/agent-hooks/log-orchestration.sh" ``` ```bash #!/usr/bin/env bash # ~/.claway/agent-hooks/log-orchestration.sh log=~/.claway/logs/orchestration.log jq -c '{ts: now, parent: .session_id, extra: .extra}' < /dev/stdin >> "$log" printf '{}\n' ``` ### Consent model Each unique `(event, command)` pair prompts the user for approval the first time Claway sees it, then persists the decision to `~/.claway/shell-hooks-allowlist.json`. Subsequent runs (CLI or gateway) skip the prompt. Three escape hatches bypass the interactive prompt — any one is sufficient: 1. `--accept-hooks` flag on the CLI (e.g. `claway --accept-hooks chat`) 2. `CLAWAY_ACCEPT_HOOKS=1` environment variable 3. `hooks_auto_accept: true` in `cli-config.yaml` Non-TTY runs (gateway, cron, CI) need one of these three — otherwise any newly-added hook silently stays un-registered and logs a warning. **Script edits are silently trusted.** The allowlist keys on the exact command string, not the script's hash, so editing the script on disk does not invalidate consent. `claway hooks doctor` flags mtime drift so you can spot edits and decide whether to re-approve. #### Manual allowlisting Manual allowlisting is useful for non-TTY or service-account deployments where an operator cannot answer the first-use prompt interactively. The allowlist file is `~/.claway/shell-hooks-allowlist.json`, and the expected format is an `approvals` array. Each approval records the hook `event` and the exact `command` string: ```json { "approvals": [ { "event": "post_llm_call", "command": "/home/claway/.claway/hooks/my-hook.py" } ] } ``` The command string must match the configured hook command exactly. A path-keyed object with a `sha256` field is not the expected format and will not approve the hook. Verify manual entries with `claway hooks list`. ### The `claway hooks` CLI | Command | What it does | |---------|--------------| | `claway hooks list` | Dump configured hooks with matcher, timeout, and consent status | | `claway hooks test <event> [--for-tool X] [--payload-file F]` | Fire every matching hook against a synthetic payload and print the parsed response | | `claway hooks revoke <command>` | Remove every allowlist entry matching `<command>` (takes effect on next restart) | | `claway hooks doctor` | For every configured hook: check exec bit, allowlist status, mtime drift, JSON output validity, and rough execution time | ### Security Shell hooks run with **your full user credentials** — same trust boundary as a cron entry or a shell alias. Treat the `hooks:` block in `config.yaml` as privileged configuration: - Only reference scripts you wrote or fully reviewed. - Keep scripts inside `~/.claway/agent-hooks/` so the path is easy to audit. - Re-run `claway hooks doctor` after you pull a shared config to spot newly-added hooks before they register. - If your config.yaml is version-controlled across a team, review PRs that change the `hooks:` section the same way you'd review CI config. ### Ordering and precedence Both Python plugin hooks and shell hooks flow through the same `invoke_hook()` dispatcher. Python plugins are registered first (`discover_and_load()`), shell hooks second (`register_from_config()`), so Python `pre_tool_call` block decisions take precedence in tie cases. The first valid block wins — the aggregator returns as soon as any callback produces `{"action": "block", "message": str}` with a non-empty message. --- <!-- source: website/docs/user-guide/features/voice-mode.md --> # Voice Mode # Voice Mode Claway Agent supports full voice interaction across CLI and messaging platforms. Talk to the agent using your microphone, hear spoken replies, and have live voice conversations in Discord voice channels. If you want a practical setup walkthrough with recommended configurations and real usage patterns, see [Use Voice Mode with Claway](/guides/use-voice-mode-with-claway). ## Prerequisites Before using voice features, make sure you have: 1. **Claway Agent installed** — via the install script (see [Installation](/getting-started)) 2. **An LLM provider configured** — run `claway model` or set your preferred provider credentials in `~/.claway/.env` 3. **A working base setup** — run `claway` to verify the agent responds to text before enabling voice :::tip The `~/.claway/` directory and default `config.yaml` are created automatically the first time you run `claway`. You only need to create `~/.claway/.env` manually for API keys. ::: ## Overview | Feature | Platform | Description | |---------|----------|-------------| | **Interactive Voice** | CLI | Press Ctrl+B to record, agent auto-detects silence and responds | | **Auto Voice Reply** | Telegram, Discord | Agent sends spoken audio alongside text responses | | **Voice Channel** | Discord | Bot joins VC, listens to users speaking, speaks replies back | ## Requirements ### Python Packages ```bash # CLI voice mode (microphone + audio playback) cd ~/.claway/claway && uv pip install -e ".[voice]" # Discord + Telegram messaging (includes discord.py[voice] for VC support) cd ~/.claway/claway && uv pip install -e ".[messaging]" # Premium TTS (ElevenLabs) cd ~/.claway/claway && uv pip install -e ".[tts-premium]" # Local TTS (NeuTTS, optional) python -m pip install -U neutts[all] # Everything at once cd ~/.claway/claway && uv pip install -e ".[all]" ``` | Extra | Packages | Required For | |-------|----------|-------------| | `voice` | `sounddevice`, `numpy` | CLI voice mode | | `messaging` | `discord.py[voice]`, `python-telegram-bot`, `aiohttp` | Discord & Telegram bots | | `tts-premium` | `elevenlabs` | ElevenLabs TTS provider | Optional local TTS provider: install `neutts` separately with `python -m pip install -U neutts[all]`. On first use it downloads the model automatically. :::info `discord.py[voice]` installs **PyNaCl** (for voice encryption) and **opus bindings** automatically. This is required for Discord voice channel support. ::: ### System Dependencies ```bash # macOS brew install portaudio ffmpeg opus brew install espeak-ng # for NeuTTS # Ubuntu/Debian sudo apt install portaudio19-dev ffmpeg libopus0 sudo apt install espeak-ng # for NeuTTS ``` | Dependency | Purpose | Required For | |-----------|---------|-------------| | **PortAudio** | Microphone input and audio playback | CLI voice mode | | **ffmpeg** | Audio format conversion (MP3 → Opus, PCM → WAV) | All platforms | | **Opus** | Discord voice codec | Discord voice channels | | **espeak-ng** | Phonemizer backend | Local NeuTTS provider | ### API Keys Add to `~/.claway/.env`: ```bash # Speech-to-Text — local provider needs NO key at all # pip install faster-whisper # Free, runs locally, recommended GROQ_API_KEY=your-key # Groq Whisper — fast, free tier (cloud) VOICE_TOOLS_OPENAI_KEY=your-key # OpenAI Whisper — paid (cloud) # Text-to-Speech (optional — Edge TTS and NeuTTS work without any key) ELEVENLABS_API_KEY=*** # ElevenLabs — premium quality # VOICE_TOOLS_OPENAI_KEY above also enables OpenAI TTS ``` :::tip If `faster-whisper` is installed, voice mode works with **zero API keys** for STT. The model (~150 MB for `base`) downloads automatically on first use. ::: --- ## CLI Voice Mode Voice mode is available in both the **classic CLI** (`claway chat`) and the **TUI** (`claway --tui`). Behavior is identical across both — same slash commands, same VAD silence detection, same streaming TTS, same hallucination filter. The TUI additionally forwards crash-forensic logs to `~/.claway/logs/` so push-to-talk failures on exotic audio backends can be reported with a full stack trace rather than disappearing silently. ### Quick Start Start the CLI and enable voice mode: ```bash claway # Start the interactive CLI ``` Then use these commands inside the CLI: ``` /voice Toggle voice mode on/off /voice on Enable voice mode /voice off Disable voice mode /voice tts Toggle TTS output /voice status Show current state ``` ### How It Works 1. Start the CLI with `claway` and enable voice mode with `/voice on` 2. **Press Ctrl+B** — a beep plays (880Hz), recording starts 3. **Speak** — a live audio level bar shows your input: `● [▁▂▃▅▇▇▅▂] ❯` 4. **Stop speaking** — after 3 seconds of silence, recording auto-stops 5. **Two beeps** play (660Hz) confirming the recording ended 6. Audio is transcribed via Whisper and sent to the agent 7. If TTS is enabled, the agent's reply is spoken aloud 8. Recording **automatically restarts** — speak again without pressing any key This loop continues until you press **Ctrl+B** during recording (exits continuous mode) or 3 consecutive recordings detect no speech. :::tip The record key is configurable via `voice.record_key` in `~/.claway/config.yaml` (default: `ctrl+b`). ::: ### Silence Detection Two-stage algorithm detects when you've finished speaking: 1. **Speech confirmation** — waits for audio above the RMS threshold (200) for at least 0.3s, tolerating brief dips between syllables 2. **End detection** — once speech is confirmed, triggers after 3.0 seconds of continuous silence If no speech is detected at all for 15 seconds, recording stops automatically. Both `silence_threshold` and `silence_duration` are configurable in `config.yaml`. You can also disable the record start/stop beeps with `voice.beep_enabled: false`. ### Streaming TTS When TTS is enabled, the agent speaks its reply **sentence-by-sentence** as it generates text — you don't wait for the full response: 1. Buffers text deltas into complete sentences (min 20 chars) 2. Strips markdown formatting and `<think>` blocks 3. Generates and plays audio per sentence in real-time ### Hallucination Filter Whisper sometimes generates phantom text from silence or background noise ("Thank you for watching", "Subscribe", etc.). The agent filters these out using a set of 26 known hallucination phrases across multiple languages, plus a regex pattern that catches repetitive variations. --- ## Gateway Voice Reply (Telegram & Discord) If you haven't set up your messaging bots yet, see the platform-specific guides: - [Telegram Setup Guide](../messaging/telegram.md) - [Discord Setup Guide](../messaging/discord.md) Start the gateway to connect to your messaging platforms: ```bash claway gateway # Start the gateway (connects to configured platforms) claway gateway setup # Interactive setup wizard for first-time configuration ``` ### Discord: Channels vs DMs The bot supports two interaction modes on Discord: | Mode | How to Talk | Mention Required | Setup | |------|------------|-----------------|-------| | **Direct Message (DM)** | Open the bot's profile → "Message" | No | Works immediately | | **Server Channel** | Type in a text channel where the bot is present | Yes (`@botname`) | Bot must be invited to the server | **DM (recommended for personal use):** Just open a DM with the bot and type — no @mention needed. Voice replies and all commands work the same as in channels. **Server channels:** The bot only responds when you @mention it (e.g. `@clawaybyt4 hello`). Make sure you select the **bot user** from the mention popup, not the role with the same name. :::tip To disable the mention requirement in server channels, add to `~/.claway/.env`: ```bash DISCORD_REQUIRE_MENTION=false ``` Or set specific channels as free-response (no mention needed): ```bash DISCORD_FREE_RESPONSE_CHANNELS=123456789,987654321 ``` ::: ### Commands These work in both Telegram and Discord (DMs and text channels): ``` /voice Toggle voice mode on/off /voice on Voice replies only when you send a voice message /voice tts Voice replies for ALL messages /voice off Disable voice replies /voice status Show current setting ``` ### Modes | Mode | Command | Behavior | |------|---------|----------| | `off` | `/voice off` | Text only (default) | | `voice_only` | `/voice on` | Speaks reply only when you send a voice message | | `all` | `/voice tts` | Speaks reply to every message | Voice mode setting is persisted across gateway restarts. ### Platform Delivery | Platform | Format | Notes | |----------|--------|-------| | **Telegram** | Voice bubble (Opus/OGG) | Plays inline in chat. ffmpeg converts MP3 → Opus if needed | | **Discord** | Native voice bubble (Opus/OGG) | Plays inline like a user voice message. Falls back to file attachment if voice bubble API fails | --- ## Discord Voice Channels The most immersive voice feature: the bot joins a Discord voice channel, listens to users speaking, transcribes their speech, processes through the agent, and speaks the reply back in the voice channel. ### Setup #### 1. Discord Bot Permissions If you already have a Discord bot set up for text (see [Discord Setup Guide](../messaging/discord.md)), you need to add voice permissions. Go to the [Discord Developer Portal](https://discord.com/developers/applications) → your application → **Installation** → **Default Install Settings** → **Guild Install**: **Add these permissions to the existing text permissions:** | Permission | Purpose | Required | |-----------|---------|----------| | **Connect** | Join voice channels | Yes | | **Speak** | Play TTS audio in voice channels | Yes | | **Use Voice Activity** | Detect when users are speaking | Recommended | **Updated Permissions Integer:** | Level | Integer | What's Included | |-------|---------|----------------| | Text only | `274878286912` | View Channels, Send Messages, Read History, Embeds, Attachments, Threads, Reactions | | Text + Voice | `274881432640` | All above + Connect, Speak | **Re-invite the bot** with the updated permissions URL: ``` https://discord.com/oauth2/authorize?client_id=YOUR_APP_ID&scope=bot+applications.commands&permissions=274881432640 ``` Replace `YOUR_APP_ID` with your Application ID from the Developer Portal. :::warning Re-inviting the bot to a server it's already in will update its permissions without removing it. You won't lose any data or configuration. ::: #### 2. Privileged Gateway Intents In the [Developer Portal](https://discord.com/developers/applications) → your application → **Bot** → **Privileged Gateway Intents**, enable all three: | Intent | Purpose | |--------|---------| | **Presence Intent** | Detect user online/offline status | | **Server Members Intent** | Resolve usernames in `DISCORD_ALLOWED_USERS` to numeric IDs (conditional) | | **Message Content Intent** | Read text message content in channels | **Message Content Intent** is required. **Server Members Intent** is only needed if your `DISCORD_ALLOWED_USERS` list uses usernames — if you use numeric user IDs, you can leave it OFF. Voice-channel SSRC → user_id mapping comes from Discord's SPEAKING opcode on the voice websocket and does **not** require the Server Members Intent. #### 3. Opus Codec The Opus codec library must be installed on the machine running the gateway: ```bash # macOS (Homebrew) brew install opus # Ubuntu/Debian sudo apt install libopus0 ``` The bot auto-loads the codec from: - **macOS:** `/opt/homebrew/lib/libopus.dylib` - **Linux:** `libopus.so.0` #### 4. Environment Variables ```bash # ~/.claway/.env # Discord bot (already configured for text) DISCORD_BOT_TOKEN=your-bot-token DISCORD_ALLOWED_USERS=your-user-id # STT — local provider needs no key (pip install faster-whisper) # GROQ_API_KEY=your-key # Alternative: cloud-based, fast, free tier # TTS — optional. Edge TTS and NeuTTS need no key. # ELEVENLABS_API_KEY=*** # Premium quality # VOICE_TOOLS_OPENAI_KEY=*** # OpenAI TTS / Whisper ``` ### Start the Gateway ```bash claway gateway # Start with existing configuration ``` The bot should come online in Discord within a few seconds. ### Commands Use these in the Discord text channel where the bot is present: ``` /voice join Bot joins your current voice channel /voice channel Alias for /voice join /voice leave Bot disconnects from voice channel /voice status Show voice mode and connected channel ``` :::info You must be in a voice channel before running `/voice join`. The bot joins the same VC you're in. ::: ### How It Works When the bot joins a voice channel, it: 1. **Listens** to each user's audio stream independently 2. **Detects silence** — 1.5s of silence after at least 0.5s of speech triggers processing 3. **Transcribes** the audio via Whisper STT (local, Groq, or OpenAI) 4. **Processes** through the full agent pipeline (session, tools, memory) 5. **Speaks** the reply back in the voice channel via TTS ### Text Channel Integration When the bot is in a voice channel: - Transcripts appear in the text channel: `[Voice] @user: what you said` - Agent responses are sent as text in the channel AND spoken in the VC - The text channel is the one where `/voice join` was issued ### Echo Prevention The bot automatically pauses its audio listener while playing TTS replies, preventing it from hearing and re-processing its own output. ### Access Control Only users listed in `DISCORD_ALLOWED_USERS` can interact via voice. Other users' audio is silently ignored. ```bash # ~/.claway/.env DISCORD_ALLOWED_USERS=284102345871466496 ``` --- ## Configuration Reference ### config.yaml ```yaml # Voice recording (CLI) voice: record_key: "ctrl+b" # Key to start/stop recording max_recording_seconds: 120 # Maximum recording length auto_tts: false # Auto-enable TTS when voice mode starts beep_enabled: true # Play record start/stop beeps silence_threshold: 200 # RMS level (0-32767) below which counts as silence silence_duration: 3.0 # Seconds of silence before auto-stop # Speech-to-Text stt: enabled: true # set to false to skip auto-transcription — # the gateway still caches the audio file and # passes its path to the agent as part of the # inbound message, useful for custom pipelines # (diarization, alignment, archival, etc.) provider: "local" # "local" (free) | "groq" | "openai" | "mistral" | "xai" local: model: "base" # tiny, base, small, medium, large-v3 # model: "whisper-1" # Legacy: used when provider is not set # Text-to-Speech tts: provider: "edge" # "edge" (free) | "elevenlabs" | "openai" | "neutts" | "minimax" | "mistral" | "gemini" | "xai" | "kittentts" | "piper" edge: voice: "en-US-AriaNeural" # 322 voices, 74 languages elevenlabs: voice_id: "pNInz6obpgDQGcFmaJgB" # Adam model_id: "eleven_multilingual_v2" openai: model: "gpt-4o-mini-tts" voice: "alloy" # alloy, echo, fable, onyx, nova, shimmer base_url: "https://api.openai.com/v1" # optional: override for self-hosted or OpenAI-compatible endpoints neutts: ref_audio: '' ref_text: '' model: neuphonic/neutts-air-q4-gguf device: cpu ``` ### Environment Variables ```bash # Speech-to-Text providers (local needs no key) # pip install faster-whisper # Free local STT — no API key needed GROQ_API_KEY=... # Groq Whisper (fast, free tier) VOICE_TOOLS_OPENAI_KEY=... # OpenAI Whisper (paid) # STT advanced overrides (optional) STT_GROQ_MODEL=whisper-large-v3-turbo # Override default Groq STT model STT_OPENAI_MODEL=whisper-1 # Override default OpenAI STT model GROQ_BASE_URL=https://api.groq.com/openai/v1 # Custom Groq endpoint STT_OPENAI_BASE_URL=https://api.openai.com/v1 # Custom OpenAI STT endpoint # Text-to-Speech providers (Edge TTS and NeuTTS need no key) ELEVENLABS_API_KEY=*** # ElevenLabs (premium quality) # VOICE_TOOLS_OPENAI_KEY above also enables OpenAI TTS # Discord voice channel DISCORD_BOT_TOKEN=... DISCORD_ALLOWED_USERS=... ``` ### STT Provider Comparison | Provider | Model | Speed | Quality | Cost | API Key | |----------|-------|-------|---------|------|---------| | **Local** | `base` | Fast (depends on CPU/GPU) | Good | Free | No | | **Local** | `small` | Medium | Better | Free | No | | **Local** | `large-v3` | Slow | Best | Free | No | | **Groq** | `whisper-large-v3-turbo` | Very fast (~0.5s) | Good | Free tier | Yes | | **Groq** | `whisper-large-v3` | Fast (~1s) | Better | Free tier | Yes | | **OpenAI** | `whisper-1` | Fast (~1s) | Good | Paid | Yes | | **OpenAI** | `gpt-4o-transcribe` | Medium (~2s) | Best | Paid | Yes | | **Mistral** | `voxtral-mini-latest` | Fast | Good | Paid | Yes | | **xAI** | `grok-stt` | Fast | Good | Paid | Yes | Provider priority (automatic fallback): **local** > **groq** > **openai** ### TTS Provider Comparison | Provider | Quality | Cost | Latency | Key Required | |----------|---------|------|---------|-------------| | **Edge TTS** | Good | Free | ~1s | No | | **ElevenLabs** | Excellent | Paid | ~2s | Yes | | **OpenAI TTS** | Good | Paid | ~1.5s | Yes | | **NeuTTS** | Good | Free | Depends on CPU/GPU | No | NeuTTS uses the `tts.neutts` config block above. --- ## Troubleshooting ### "No audio device found" (CLI) PortAudio is not installed: ```bash brew install portaudio # macOS sudo apt install portaudio19-dev # Ubuntu ``` If you are running Claway inside Docker on a Linux desktop, the container also needs access to your host audio socket. See the Docker audio bridge notes for a PulseAudio/PipeWire-compatible setup. ### Bot doesn't respond in Discord server channels The bot requires an @mention by default in server channels. Make sure you: 1. Type `@` and select the **bot user** (with the #discriminator), not the **role** with the same name 2. Or use DMs instead — no mention needed 3. Or set `DISCORD_REQUIRE_MENTION=false` in `~/.claway/.env` ### Bot joins VC but doesn't hear me - Check your Discord user ID is in `DISCORD_ALLOWED_USERS` - Make sure you're not muted in Discord - The bot needs a SPEAKING event from Discord before it can map your audio — start speaking within a few seconds of joining ### Bot hears me but doesn't respond - Verify STT is available: install `faster-whisper` (no key needed) or set `GROQ_API_KEY` / `VOICE_TOOLS_OPENAI_KEY` - Check the LLM model is configured and accessible - Review gateway logs: `tail -f ~/.claway/logs/gateway.log` ### Bot responds in text but not in voice channel - TTS provider may be failing — check API key and quota - Edge TTS (free, no key) is the default fallback - Check logs for TTS errors ### Whisper returns garbage text The hallucination filter catches most cases automatically. If you're still getting phantom transcripts: - Use a quieter environment - Adjust `silence_threshold` in config (higher = less sensitive) - Try a different STT model --- <!-- source: website/docs/user-guide/features/browser.md --> # user-guide/features/browser # Browser Automation Claway Agent includes a full browser automation toolset with multiple backend options: - **Browserbase cloud mode** via [Browserbase](https://browserbase.com) for managed cloud browsers and anti-bot tooling - **Browser Use cloud mode** via [Browser Use](https://browser-use.com) as an alternative cloud browser provider - **Firecrawl cloud mode** via [Firecrawl](https://firecrawl.dev) for cloud browsers with built-in scraping - **Camofox local mode** via [Camofox](https://github.com/jo-inc/camofox-browser) for local anti-detection browsing (Firefox-based fingerprint spoofing) - **Local Chromium-family CDP** — connect browser tools to your own Chrome, Brave, Chromium, or Edge instance using `/browser connect` - **Local browser mode** via the `agent-browser` CLI and a local Chromium installation In all modes, the agent can navigate websites, interact with page elements, fill forms, and extract information. ## Overview Pages are represented as **accessibility trees** (text-based snapshots), making them ideal for LLM agents. Interactive elements get ref IDs (like `@e1`, `@e2`) that the agent uses for clicking and typing. Key capabilities: - **Multi-provider cloud execution** — Browserbase, Browser Use, or Firecrawl — no local browser needed - **Local Chromium-family integration** — attach to your running Chrome, Brave, Chromium, or Edge browser via CDP for hands-on browsing - **Built-in stealth** — random fingerprints, CAPTCHA solving, residential proxies (Browserbase) - **Session isolation** — each task gets its own browser session - **Automatic cleanup** — inactive sessions are closed after a timeout - **Vision analysis** — screenshot + AI analysis for visual understanding ## Setup ### Browserbase cloud mode To use Browserbase-managed cloud browsers, add: ```bash # Add to ~/.claway/.env BROWSERBASE_API_KEY=*** BROWSERBASE_PROJECT_ID=your-project-id-here ``` Get your credentials at [browserbase.com](https://browserbase.com). ### Browser Use cloud mode To use Browser Use as your cloud browser provider, add: ```bash # Add to ~/.claway/.env BROWSER_USE_API_KEY=*** ``` Get your API key at [browser-use.com](https://browser-use.com). Browser Use provides a cloud browser via its REST API. If both Browserbase and Browser Use credentials are set, Browserbase takes priority. ### Firecrawl cloud mode To use Firecrawl as your cloud browser provider, add: ```bash # Add to ~/.claway/.env FIRECRAWL_API_KEY=fc-*** ``` Get your API key at [firecrawl.dev](https://firecrawl.dev). Then select Firecrawl as your browser provider: ```bash claway setup tools # → Browser Automation → Firecrawl ``` Optional settings: ```bash # Self-hosted Firecrawl instance (default: https://api.firecrawl.dev) FIRECRAWL_API_URL=http://localhost:3002 # Session TTL in seconds (default: 300) FIRECRAWL_BROWSER_TTL=600 ``` ### Hybrid routing: cloud for public URLs, local for LAN/localhost When a cloud provider is configured, Claway auto-spawns a **local Chromium sidecar** for URLs that resolve to a private/loopback/LAN address (`localhost`, `127.0.0.1`, `192.168.x.x`, `10.x.x.x`, `172.16-31.x.x`, `*.local`, `*.lan`, `*.internal`, IPv6 loopback `::1`, link-local `169.254.x.x`). Public URLs continue to use the cloud provider in the same conversation. This solves the common "I'm developing locally but using Browserbase" workflow — the agent can screenshot your dashboard at `http://localhost:3000` AND scrape `https://github.com` without you switching providers or disabling the SSRF guard. The cloud provider never sees the private URL. The feature is **on by default**. To disable it (all URLs go to the configured cloud provider, as before): ```yaml # ~/.claway/config.yaml browser: cloud_provider: browserbase auto_local_for_private_urls: false ``` With auto-routing disabled, private URLs are rejected with `"Blocked: URL targets a private or internal address"` unless you also set `browser.allow_private_urls: true` (which lets the cloud provider attempt them — usually won't work since Browserbase etc. can't reach your LAN). Requirements: the local sidecar uses the same `agent-browser` CLI as pure local mode, so you need it installed (`claway setup tools → Browser Automation` auto-installs it). Post-navigation redirects from a public URL onto a private address are still blocked (you can't use a redirect-to-internal trick to reach your LAN through the public path). ### Camofox local mode [Camofox](https://github.com/jo-inc/camofox-browser) is a self-hosted Node.js server wrapping Camoufox (a Firefox fork with C++ fingerprint spoofing). It provides local anti-detection browsing without cloud dependencies. ```bash # Clone the Camofox browser server first git clone https://github.com/jo-inc/camofox-browser cd camofox-browser # Build and start with Docker using the default container settings # (auto-detects arch: aarch64 on M1/M2, x86_64 on Intel) make up # Stop and remove the default container make down # Force a clean rebuild (for example, after upgrading VERSION/RELEASE) make reset # Just download binaries without building make fetch # Override arch or version explicitly make up ARCH=x86_64 make up VERSION=135.0.1 RELEASE=beta.24 ``` `make up` starts the default container immediately. If you want custom runtime settings such as a larger Node heap, VNC, or a persistent profile directory, build the image first and then run it yourself: ```bash # Build the image without starting the default container make build # Start with persistence, VNC live view, and a larger Node heap mkdir -p ~/.camofox-docker docker run -d \ --name camofox-browser \ --restart unless-stopped \ -p 9377:9377 \ -p 6080:6080 \ -p 5901:5900 \ -e CAMOFOX_PORT=9377 \ -e ENABLE_VNC=1 \ -e VNC_BIND=0.0.0.0 \ -e VNC_RESOLUTION=1920x1080 \ -e MAX_OLD_SPACE_SIZE=2048 \ -v ~/.camofox-docker:/root/.camofox \ camofox-browser:135.0.1-aarch64 ``` With VNC enabled, the browser runs in headed mode and can be watched live in your browser at `http://localhost:6080` (noVNC). You can also connect a native VNC client to `localhost:5901`. If you already ran `make up`, stop and remove that default container before starting the custom one: ```bash make down # then run the custom docker run command above ``` Then set in `~/.claway/.env`: ```bash CAMOFOX_URL=http://localhost:9377 ``` If Camofox is running in Docker and you want it to open web apps served from the host machine, enable loopback rewriting. `CAMOFOX_URL` should still point at the host-published control API, but page URLs such as `http://127.0.0.1:3000` must be opened from inside the container as `http://host.docker.internal:3000`: ```yaml # ~/.claway/config.yaml browser: camofox: rewrite_loopback_urls: true loopback_host_alias: host.docker.internal # default; use a LAN IP if needed ``` Equivalent env vars: ```bash CAMOFOX_REWRITE_LOOPBACK_URLS=true CAMOFOX_LOOPBACK_HOST_ALIAS=host.docker.internal ``` The rewrite only applies to page navigation URLs with loopback hosts (`localhost`, `127.0.0.1`, `::1`). It does not change `CAMOFOX_URL`. Leave it disabled for non-Docker Camofox installs, where the browser already runs on the host and loopback URLs are correct. Or configure via `claway tools` → Browser Automation → Camofox. When `CAMOFOX_URL` is set, all browser tools automatically route through Camofox instead of Browserbase or agent-browser. #### Persistent browser sessions By default, each Camofox session gets a random identity — cookies and logins don't survive across agent restarts. To enable persistent browser sessions, add the following to `~/.claway/config.yaml`: ```yaml browser: camofox: managed_persistence: true ``` Then fully restart Claway so the new config is picked up. :::warning Nested path matters Claway reads `browser.camofox.managed_persistence`, **not** a top-level `managed_persistence`. A common mistake is writing: ```yaml # ❌ Wrong — Claway ignores this managed_persistence: true ``` If the flag is placed at the wrong path, Claway silently falls back to a random ephemeral `userId` and your login state will be lost on every session. ::: ##### What Claway does - Sends a deterministic profile-scoped `userId` to Camofox so the server can reuse the same Firefox profile across sessions. - Skips server-side context destruction on cleanup, so cookies and logins survive between agent tasks. - Scopes the `userId` to the active Claway profile, so different Claway profiles get different browser profiles (profile isolation). ##### What Claway does not do - It does not force persistence on the Camofox server. Claway only sends a stable `userId`; the server must honor it by mapping that `userId` to a persistent Firefox profile directory. - If your Camofox server build treats every request as ephemeral (e.g. always calls `browser.newContext()` without loading a stored profile), Claway cannot make those sessions persist. Make sure you are running a Camofox build that implements userId-based profile persistence. ##### Verify it's working 1. Start Claway and your Camofox server. 2. Open Google (or any login site) in a browser task and sign in manually. 3. End the browser task normally. 4. Start a new browser task. 5. Open the same site again — you should still be signed in. If step 5 logs you out, the Camofox server isn't honoring the stable `userId`. Double-check your config path, confirm you fully restarted Claway after editing `config.yaml`, and verify your Camofox server version supports persistent per-user profiles. ##### Where state lives Claway derives the stable `userId` from the profile-scoped directory `~/.claway/browser_auth/camofox/` (or the equivalent under `$CLAWAY_HOME` for non-default profiles). The actual browser profile data lives on the Camofox server side, keyed by that `userId`. To fully reset a persistent profile, clear it on the Camofox server and remove the corresponding Claway profile's state directory. #### Externally managed Camofox sessions When another app drives the visible Camofox browser (a desktop assistant, a custom integration, another agent), configure Claway to operate inside that same identity instead of spawning its own isolated profile. Three knobs control the behavior: | Setting | Env var | Effect | |---------|---------|--------| | `browser.camofox.user_id` | `CAMOFOX_USER_ID` | Camofox `userId` Claway uses when creating tabs. Setting this opts the session into "externally managed" mode. | | `browser.camofox.session_key` | `CAMOFOX_SESSION_KEY` | `sessionKey` (a.k.a. `listItemId`) sent on tab creation. Used to match an existing tab during adoption. Defaults to a per-task value if unset. | | `browser.camofox.adopt_existing_tab` | `CAMOFOX_ADOPT_EXISTING_TAB` | When true, Claway calls `GET /tabs?userId=<user_id>` on first use and reuses an existing tab before creating a new one. | Env vars take precedence over `config.yaml`. Either form works: ```yaml browser: camofox: user_id: shared-camofox session_key: visible-tab adopt_existing_tab: true ``` ```bash CAMOFOX_USER_ID=shared-camofox CAMOFOX_SESSION_KEY=visible-tab CAMOFOX_ADOPT_EXISTING_TAB=true ``` **What changes when `user_id` is set:** - Claway skips destructive cleanup at task end (same as `managed_persistence: true`). The other app's tab/cookies/profile survive. - Claway does **not** call `DELETE /sessions/<user_id>` — that endpoint wipes all user data, so it would nuke the external app's session if it fired. **How tab adoption works (when `adopt_existing_tab: true`):** 1. On the first browser tool call after a process start, Claway issues `GET /tabs?userId=<user_id>` (5-second timeout). 2. If any tab in the response has `listItemId == session_key`, Claway adopts the most recently created one in that group. 3. Otherwise, Claway adopts the most recently created tab for the user (any `listItemId`). 4. If no tabs exist or the request fails, Claway falls back to creating a new tab on the next operation. Adoption only fires until `tab_id` is populated for the session. If the external app closes the adopted tab mid-run, the next browser tool call will surface a Camofox error — Claway does not re-poll for a fresh tab on every call. **Picking `session_key`:** if you want Claway to reliably attach to a *specific* existing tab, set `session_key` to the `listItemId` the external app used when creating it. If you leave `session_key` unset and only set `user_id`, Claway generates a per-task `session_key` (`task_<id>`) — Claway will share cookies and the profile with the external app, but will open its own tab alongside instead of reusing one. **Concurrency note:** the external app and Claway can drive the same Camofox `userId` simultaneously, but Camofox does not coordinate per-tab focus between clients. Coordinate ownership at the application layer (e.g. the external app pauses while Claway runs). #### VNC live view When Camofox runs in headed mode (with a visible browser window), it exposes a VNC port in its health check response. Claway automatically discovers this and includes the VNC URL in navigation responses, so the agent can share a link for you to watch the browser live. ### Local Chromium-family browser via CDP (`/browser connect`) Instead of a cloud provider, you can attach Claway browser tools to your own running Chrome, Brave, Chromium, or Edge instance via the Chrome DevTools Protocol (CDP). This is useful when you want to see what the agent is doing in real-time, interact with pages that require your own cookies/sessions, or avoid cloud browser costs. :::note `/browser connect` is an **interactive-CLI slash command** — it is not dispatched by the gateway. If you try to run it inside a WebUI, Telegram, Discord, or other gateway chat, the message will be sent to the agent as plain text and the command will not execute. Start Claway from the terminal (`claway` or `claway chat`) and issue `/browser connect` there. ::: In the CLI, use: ``` /browser connect # Auto-launch/connect to a local Chromium-family browser at http://127.0.0.1:9222 /browser connect ws://host:port # Connect to a specific CDP endpoint /browser status # Check current connection /browser disconnect # Detach and return to cloud/local mode ``` If a browser isn't already running with remote debugging, Claway will attempt to auto-launch a supported Chromium-family browser with `--remote-debugging-port=9222`. Detection includes Brave, Google Chrome, Chromium, and Microsoft Edge, with common Linux install paths such as `/opt/brave-bin/brave` and `/snap/bin/brave`. :::tip To start a Chromium-family browser manually with CDP enabled, use a dedicated user-data-dir so the debug port actually comes up even if the browser is already running with your normal profile: ```bash # Linux — Brave brave-browser \ --remote-debugging-port=9222 \ --user-data-dir=$HOME/.claway/chrome-debug \ --no-first-run \ --no-default-browser-check & # Linux — Google Chrome google-chrome \ --remote-debugging-port=9222 \ --user-data-dir=$HOME/.claway/chrome-debug \ --no-first-run \ --no-default-browser-check & # macOS — Brave "/Applications/Brave Browser.app/Contents/MacOS/Brave Browser" \ --remote-debugging-port=9222 \ --user-data-dir="$HOME/.claway/chrome-debug" \ --no-first-run \ --no-default-browser-check & # macOS — Google Chrome "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" \ --remote-debugging-port=9222 \ --user-data-dir="$HOME/.claway/chrome-debug" \ --no-first-run \ --no-default-browser-check & ``` Then launch the Claway CLI and run `/browser connect`. **Why `--user-data-dir`?** Without it, launching a Chromium-family browser while a regular instance is already running typically opens a new window on the existing process — and that existing process was not started with `--remote-debugging-port`, so port 9222 never opens. A dedicated user-data-dir forces a fresh browser process where the debug port actually listens. `--no-first-run --no-default-browser-check` skips the first-launch wizard for the fresh profile. ::: When connected via CDP, all browser tools (`browser_navigate`, `browser_click`, etc.) operate on your live browser instance instead of spinning up a cloud session. ### WSL2 + Windows Chrome: prefer MCP over `/browser connect` If Claway runs inside WSL2 but the Chrome window you want to control runs on the Windows host, `/browser connect` is often not the best path. Why: - `/browser connect` expects Claway itself to reach a usable CDP endpoint - modern Chrome live-debugging sessions often expose a host-local endpoint that is not directly reachable from WSL the same way a classic `9222` port is - even when Windows Chrome is debuggable, the cleanest integration is often to let a Windows-side browser MCP server attach to Chrome and let Claway talk to that MCP server For that setup, prefer `chrome-devtools-mcp` through Claway MCP support. See the MCP guide for the practical setup: - [Use MCP with Claway](../../guides/use-mcp-with-claway.md#wsl2-bridge-claway-in-wsl-to-windows-chrome) ### Local browser mode If you do **not** set any cloud credentials and don't use `/browser connect`, Claway can still use the browser tools through a local Chromium install driven by `agent-browser`. ### Optional Environment Variables ```bash # Residential proxies for better CAPTCHA solving (default: "true") BROWSERBASE_PROXIES=true # Advanced stealth with custom Chromium — requires Scale Plan (default: "false") BROWSERBASE_ADVANCED_STEALTH=false # Session reconnection after disconnects — requires paid plan (default: "true") BROWSERBASE_KEEP_ALIVE=true # Custom session timeout in seconds (max 21600 = 6 hours) (default: project default) # Examples: 600 (10min), 1800 (30min), 21600 (6h max) BROWSERBASE_SESSION_TIMEOUT=1800 # Inactivity timeout before auto-cleanup in seconds (default: 120) BROWSER_INACTIVITY_TIMEOUT=120 # Extra Chromium launch flags (comma- or newline-separated). Claway auto-injects # `--no-sandbox,--disable-dev-shm-usage` when it detects root or AppArmor-restricted # unprivileged user namespaces (Ubuntu 23.10+, DGX Spark, many container images), # so most users don't need to set this. Set it manually only if you need a flag # Claway doesn't add automatically; setting it disables the auto-injection. AGENT_BROWSER_ARGS=--no-sandbox ``` ### Install agent-browser CLI ```bash npm install -g agent-browser # Or install locally in the repo: npm install ``` :::info The `browser` toolset must be included in your config's `toolsets` list or enabled via `claway config set toolsets '["claway-cli", "browser"]'`. ::: ## Available Tools ### `browser_navigate` Navigate to a URL. Must be called before any other browser tool. Initializes the Browserbase session. ``` Navigate to https://example.com ``` :::tip For simple information retrieval, prefer `web_search` or `web_extract` — they are faster and cheaper. Use browser tools when you need to **interact** with a page (click buttons, fill forms, handle dynamic content). ::: ### `browser_snapshot` Get a text-based snapshot of the current page's accessibility tree. Returns interactive elements with ref IDs like `@e1`, `@e2` for use with `browser_click` and `browser_type`. - **`full=false`** (default): Compact view showing only interactive elements - **`full=true`**: Complete page content Snapshots over 8000 characters are automatically summarized by an LLM. ### `browser_click` Click an element identified by its ref ID from the snapshot. ``` Click @e5 to press the "Sign In" button ``` ### `browser_type` Type text into an input field. Clears the field first, then types the new text. ``` Type "claway agent" into the search field @e3 ``` ### `browser_scroll` Scroll the page up or down to reveal more content. ``` Scroll down to see more results ``` ### `browser_press` Press a keyboard key. Useful for submitting forms or navigation. ``` Press Enter to submit the form ``` Supported keys: `Enter`, `Tab`, `Escape`, `ArrowDown`, `ArrowUp`, and more. ### `browser_back` Navigate back to the previous page in browser history. ### `browser_get_images` List all images on the current page with their URLs and alt text. Useful for finding images to analyze. ### `browser_vision` Take a screenshot and analyze it with vision AI. Use this when text snapshots don't capture important visual information — especially useful for CAPTCHAs, complex layouts, or visual verification challenges. The screenshot is saved persistently and the file path is returned alongside the AI analysis. On messaging platforms (Telegram, Discord, Slack, WhatsApp), you can ask the agent to share the screenshot — it will be sent as a native photo attachment via the `MEDIA:` mechanism. ``` What does the chart on this page show? ``` Screenshots are stored in `~/.claway/cache/screenshots/` and automatically cleaned up after 24 hours. ### `browser_console` Get browser console output (log/warn/error messages) and uncaught JavaScript exceptions from the current page. Essential for detecting silent JS errors that don't appear in the accessibility tree. ``` Check the browser console for any JavaScript errors ``` Use `clear=True` to clear the console after reading, so subsequent calls only show new messages. `browser_console` also evaluates JavaScript when called with an `expression` argument — same shape as DevTools console, the result comes back parsed (JSON-serialized objects become dicts; primitive values stay primitive). ``` browser_console(expression="document.querySelector('h1').textContent") browser_console(expression="JSON.stringify(performance.timing)") ``` When a CDP supervisor is active for the current session (typical for any session that's run `browser_navigate` against a CDP-capable backend), evaluation runs over the supervisor's persistent WebSocket — no subprocess startup cost. Falls through to the standard agent-browser CLI path otherwise. Behaviour is identical either way; only latency changes. ### `browser_cdp` Raw Chrome DevTools Protocol passthrough — the escape hatch for browser operations not covered by the other tools. Use for native dialog handling, iframe-scoped evaluation, cookie/network control, or any CDP verb the agent needs. **Only available when a CDP endpoint is reachable at session start** — meaning `/browser connect` has attached to a running Chrome, Brave, Chromium, or Edge browser, or `browser.cdp_url` is set in `config.yaml`. The default local agent-browser mode, Camofox, and cloud providers (Browserbase, Browser Use, Firecrawl) do not currently expose CDP to this tool — cloud providers have per-session CDP URLs but live-session routing is a follow-up. **CDP method reference:** https://chromedevtools.github.io/devtools-protocol/ — the agent can `web_extract` a specific method's page to look up parameters and return shape. Common patterns: ``` # List tabs (browser-level, no target_id) browser_cdp(method="Target.getTargets") # Handle a native JS dialog on a tab browser_cdp(method="Page.handleJavaScriptDialog", params={"accept": true, "promptText": ""}, target_id="<tabId>") # Evaluate JS in a specific tab browser_cdp(method="Runtime.evaluate", params={"expression": "document.title", "returnByValue": true}, target_id="<tabId>") # Get all cookies browser_cdp(method="Network.getAllCookies") ``` Browser-level methods (`Target.*`, `Browser.*`, `Storage.*`) omit `target_id`. Page-level methods (`Page.*`, `Runtime.*`, `DOM.*`, `Emulation.*`) require a `target_id` from `Target.getTargets`. Each stateless call is independent — sessions do not persist between calls. **Cross-origin iframes:** pass `frame_id` (from `browser_snapshot.frame_tree.children[]` where `is_oopif=true`) to route the CDP call through the supervisor's live session for that iframe. This is how `Runtime.evaluate` inside a cross-origin iframe works on Browserbase, where stateless CDP connections would hit signed-URL expiry. Example: ``` browser_cdp( method="Runtime.evaluate", params={"expression": "document.title", "returnByValue": True}, frame_id="<frame_id from browser_snapshot>", ) ``` Same-origin iframes don't need `frame_id` — use `document.querySelector('iframe').contentDocument` from a top-level `Runtime.evaluate` instead. ### `browser_dialog` Responds to a native JS dialog (`alert` / `confirm` / `prompt` / `beforeunload`). Before this tool existed, dialogs would silently block the page's JavaScript thread and subsequent `browser_*` calls would hang or throw; now the agent sees pending dialogs in `browser_snapshot` output and responds explicitly. **Workflow:** 1. Call `browser_snapshot`. If a dialog is blocking the page, it shows up as `pending_dialogs: [{"id": "d-1", "type": "alert", "message": "..."}]`. 2. Call `browser_dialog(action="accept")` or `browser_dialog(action="dismiss")`. For `prompt()` dialogs, pass `prompt_text="..."` to supply the response. 3. Re-snapshot — `pending_dialogs` is empty; the page's JS thread has resumed. **Detection happens automatically** via a persistent CDP supervisor — one WebSocket per task that subscribes to Page/Runtime/Target events. The supervisor also populates a `frame_tree` field in the snapshot so the agent can see the iframe structure of the current page, including cross-origin (OOPIF) iframes. **Availability matrix:** | Backend | Detection via `pending_dialogs` | Response (`browser_dialog` tool) | |---|---|---| | Local Chrome via `/browser connect` or `browser.cdp_url` | ✓ | ✓ full workflow | | Browserbase | ✓ | ✓ full workflow (via injected XHR bridge) | | Camofox / default local agent-browser | ✗ | ✗ (no CDP endpoint) | **How it works on Browserbase.** Browserbase's CDP proxy auto-dismisses real native dialogs server-side within ~10ms, so we can't use `Page.handleJavaScriptDialog`. The supervisor injects a small script via `Page.addScriptToEvaluateOnNewDocument` that overrides `window.alert`/`confirm`/`prompt` with a synchronous XHR. We intercept those XHRs via `Fetch.enable` — the page's JS thread stays blocked on the XHR until we call `Fetch.fulfillRequest` with the agent's response. `prompt()` return values round-trip back into page JS unchanged. **Dialog policy** is configured in `config.yaml` under `browser.dialog_policy`: | Policy | Behavior | |--------|----------| | `must_respond` (default) | Capture, surface in snapshot, wait for explicit `browser_dialog()` call. Safety auto-dismiss after `browser.dialog_timeout_s` (default 300s) so a buggy agent can't stall forever. | | `auto_dismiss` | Capture, dismiss immediately. Agent still sees the dialog in `browser_state` history but doesn't have to act. | | `auto_accept` | Capture, accept immediately. Useful when navigating pages with aggressive `beforeunload` prompts. | **Frame tree** inside `browser_snapshot.frame_tree` is capped to 30 frames and OOPIF depth 2 to keep payloads bounded on ad-heavy pages. A `truncated: true` flag surfaces when limits were hit; agents needing the full tree can use `browser_cdp` with `Page.getFrameTree`. ## Practical Examples ### Filling Out a Web Form ``` User: Sign up for an account on example.com with my email john@example.com Agent workflow: 1. browser_navigate("https://example.com/signup") 2. browser_snapshot() → sees form fields with refs 3. browser_type(ref="@e3", text="john@example.com") 4. browser_type(ref="@e5", text="SecurePass123") 5. browser_click(ref="@e8") → clicks "Create Account" 6. browser_snapshot() → confirms success ``` ### Researching Dynamic Content ``` User: What are the top trending repos on GitHub right now? Agent workflow: 1. browser_navigate("https://github.com/trending") 2. browser_snapshot(full=true) → reads trending repo list 3. Returns formatted results ``` ## Session Recording Automatically record browser sessions as WebM video files: ```yaml browser: record_sessions: true # default: false ``` When enabled, recording starts automatically on the first `browser_navigate` and saves to `~/.claway/browser_recordings/` when the session closes. Works in both local and cloud (Browserbase) modes. Recordings older than 72 hours are automatically cleaned up. ## Stealth Features Browserbase provides automatic stealth capabilities: | Feature | Default | Notes | |---------|---------|-------| | Basic Stealth | Always on | Random fingerprints, viewport randomization, CAPTCHA solving | | Residential Proxies | On | Routes through residential IPs for better access | | Advanced Stealth | Off | Custom Chromium build, requires Scale Plan | | Keep Alive | On | Session reconnection after network hiccups | :::note If paid features aren't available on your plan, Claway automatically falls back — first disabling `keepAlive`, then proxies — so browsing still works on free plans. ::: ## Session Management - Each task gets an isolated browser session via Browserbase - Sessions are automatically cleaned up after inactivity (default: 2 minutes) - A background thread checks every 30 seconds for stale sessions - Emergency cleanup runs on process exit to prevent orphaned sessions - Sessions are released via the Browserbase API (`REQUEST_RELEASE` status) ## Limitations - **Text-based interaction** — relies on accessibility tree, not pixel coordinates - **Snapshot size** — large pages may be truncated or LLM-summarized at 8000 characters - **Session timeout** — cloud sessions expire based on your provider's plan settings - **Cost** — cloud sessions consume provider credits; sessions are automatically cleaned up when the conversation ends or after inactivity. Use `/browser connect` for free local browsing. - **No file downloads** — cannot download files from the browser --- <!-- source: website/docs/user-guide/features/vision.md --> # user-guide/features/vision # Vision & Image Paste Claway Agent supports **multimodal vision** — you can paste images from your clipboard directly into the CLI and ask the agent to analyze, describe, or work with them. Images are sent to the model as base64-encoded content blocks, so any vision-capable model can process them. ## How It Works 1. Copy an image to your clipboard (screenshot, browser image, etc.) 2. Attach it using one of the methods below 3. Type your question and press Enter 4. The image appears as a `[📎 Image #1]` badge above the input 5. On submit, the image is sent to the model as a vision content block You can attach multiple images before sending — each gets its own badge. Press `Ctrl+C` to clear all attached images. Images are saved to `~/.claway/images/` as PNG files with timestamped filenames. ## Paste Methods How you attach an image depends on your terminal environment. Not all methods work everywhere — here's the full breakdown: ### `/paste` Command **The most reliable explicit image-attach fallback.** ``` /paste ``` Type `/paste` and press Enter. Claway checks your clipboard for an image and attaches it. This is the safest option when your terminal rewrites `Cmd+V`/`Ctrl+V`, or when you copied only an image and there is no bracketed-paste text payload to inspect. ### Ctrl+V / Cmd+V Claway now treats paste as a layered flow: - normal text paste first - native clipboard / OSC52 text fallback if the terminal did not deliver text cleanly - image attach when the clipboard or pasted payload resolves to an image or image path This means pasted macOS screenshot temp paths and `file://...` image URIs can attach immediately instead of sitting in the composer as raw text. :::warning If your clipboard has **only an image** (no text), terminals still cannot send binary image bytes directly. Use `/paste` as the explicit image-attach fallback. ::: ### `/terminal-setup` for VS Code / Cursor / Windsurf If you run the TUI inside a local VS Code-family integrated terminal on macOS, Claway can install the recommended `workbench.action.terminal.sendSequence` bindings for better multiline and undo/redo parity: ```text /terminal-setup ``` This is especially useful when `Cmd+Enter`, `Cmd+Z`, or `Shift+Cmd+Z` are being intercepted by the IDE. Run it on the local machine only — not inside an SSH session. ## Platform Compatibility | Environment | `/paste` | Cmd/Ctrl+V | `/terminal-setup` | Notes | |---|:---:|:---:|:---:|---| | **macOS Terminal / iTerm2** | ✅ | ✅ | n/a | Best experience — native clipboard + screenshot-path recovery | | **Apple Terminal** | ✅ | ✅ | n/a | If Cmd+←/→/⌫ gets rewritten, use Ctrl+A / Ctrl+E / Ctrl+U fallbacks | | **Linux X11 desktop** | ✅ | ✅ | n/a | Requires `xclip` (`apt install xclip`) | | **Linux Wayland desktop** | ✅ | ✅ | n/a | Requires `wl-paste` (`apt install wl-clipboard`) | | **WSL2 (Windows Terminal)** | ✅ | ✅ | n/a | Uses `powershell.exe` — no extra install needed | | **VS Code / Cursor / Windsurf (local)** | ✅ | ✅ | ✅ | Recommended for better Cmd+Enter / undo / redo parity | | **VS Code / Cursor / Windsurf (SSH)** | ❌² | ❌² | ❌³ | Run `/terminal-setup` on the local machine instead | | **SSH terminal (any)** | ❌² | ❌² | n/a | Remote clipboard not accessible | ² See [SSH & Remote Sessions](#ssh--remote-sessions) below ³ The command writes local IDE keybindings and should not be run from the remote host ## Platform-Specific Setup ### macOS **No setup required.** Claway uses `osascript` (built into macOS) to read the clipboard. For faster performance, optionally install `pngpaste`: ```bash brew install pngpaste ``` ### Linux (X11) Install `xclip`: ```bash # Ubuntu/Debian sudo apt install xclip # Fedora sudo dnf install xclip # Arch sudo pacman -S xclip ``` ### Linux (Wayland) Modern Linux desktops (Ubuntu 22.04+, Fedora 34+) often use Wayland by default. Install `wl-clipboard`: ```bash # Ubuntu/Debian sudo apt install wl-clipboard # Fedora sudo dnf install wl-clipboard # Arch sudo pacman -S wl-clipboard ``` :::tip How to check if you're on Wayland ```bash echo $XDG_SESSION_TYPE # "wayland" = Wayland, "x11" = X11, "tty" = no display server ``` ::: ### WSL2 **No extra setup required.** Claway detects WSL2 automatically (via `/proc/version`) and uses `powershell.exe` to access the Windows clipboard through .NET's `System.Windows.Forms.Clipboard`. This is built into WSL2's Windows interop — `powershell.exe` is available by default. The clipboard data is transferred as base64-encoded PNG over stdout, so no file path conversion or temp files are needed. :::info WSLg Note If you're running WSLg (WSL2 with GUI support), Claway tries the PowerShell path first, then falls back to `wl-paste`. WSLg's clipboard bridge only supports BMP format for images — Claway auto-converts BMP to PNG using Pillow (if installed) or ImageMagick's `convert` command. ::: #### Verify WSL2 clipboard access ```bash # 1. Check WSL detection grep -i microsoft /proc/version # 2. Check PowerShell is accessible which powershell.exe # 3. Copy an image, then check powershell.exe -NoProfile -Command "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.Clipboard]::ContainsImage()" # Should print "True" ``` ## SSH & Remote Sessions **Clipboard image paste does not fully work over SSH.** When you SSH into a remote machine, the Claway CLI runs on the remote host. Clipboard tools (`xclip`, `wl-paste`, `powershell.exe`, `osascript`) read the clipboard of the machine they run on — which is the remote server, not your local machine. Your local clipboard image is therefore inaccessible from the remote side. Text can sometimes still bridge through terminal paste or OSC52, but image clipboard access and local screenshot temp paths remain tied to the machine running Claway. ### Workarounds for SSH 1. **Upload the image file** — Save the image locally, upload it to the remote server via `scp`, VSCode's file explorer (drag-and-drop), or any file transfer method. Then reference it by path. *(A `/attach <filepath>` command is planned for a future release.)* 2. **Use a URL** — If the image is accessible online, just paste the URL in your message. The agent can use `vision_analyze` to look at any image URL directly. 3. **X11 forwarding** — Connect with `ssh -X` to forward X11. This lets `xclip` on the remote machine access your local X11 clipboard. Requires an X server running locally (XQuartz on macOS, built-in on Linux X11 desktops). Slow for large images. 4. **Use a messaging platform** — Send images to Claway via Telegram, Discord, Slack, or WhatsApp. These platforms handle image upload natively and are not affected by clipboard/terminal limitations. ## Why Terminals Can't Paste Images This is a common source of confusion, so here's the technical explanation: Terminals are **text-based** interfaces. When you press Ctrl+V (or Cmd+V), the terminal emulator: 1. Reads the clipboard for **text content** 2. Wraps it in [bracketed paste](https://en.wikipedia.org/wiki/Bracketed-paste) escape sequences 3. Sends it to the application through the terminal's text stream If the clipboard contains only an image (no text), the terminal has nothing to send. There is no standard terminal escape sequence for binary image data. The terminal simply does nothing. This is why Claway uses a separate clipboard check — instead of receiving image data through the terminal paste event, it calls OS-level tools (`osascript`, `powershell.exe`, `xclip`, `wl-paste`) directly via subprocess to read the clipboard independently. ## Supported Models Image paste works with any vision-capable model. The image is sent as a base64-encoded data URL in the OpenAI vision content format: ```json { "type": "image_url", "image_url": { "url": "data:image/png;base64,..." } } ``` Most modern models support this format, including GPT-4 Vision, Claude (with vision), Gemini, and open-source multimodal models served through OpenRouter. ## Image Routing (Vision-Capable vs Text-Only Models) When a user attaches an image — from the CLI clipboard, the gateway (Telegram/Discord photo), or any other entry point — Claway routes it based on whether your current model actually supports vision: | Your model | What happens to the image | |---|---| | **Vision-capable** (GPT-4V, Claude with vision, Gemini, Qwen-VL, MiMo-VL, etc.) | Sent as **real pixels** using the provider's native image content format above. No text summary layer. | | **Text-only** (DeepSeek V3, smaller open-source models, older chat-only endpoints) | Routed through the `vision_analyze` auxiliary tool — an auxiliary vision model describes the image, and the text description is injected into the conversation. | You don't configure this — Claway looks up your current model's capability in the provider metadata and picks the right path automatically. The practical effect: you can switch between vision and non-vision models mid-session and image handling "just works" without changing your workflow. Text-only models get coherent context about the image rather than a broken multimodal payload they'd have to reject. Which auxiliary model handles the text-description path is configurable under `auxiliary.vision` — see [Auxiliary Models](/user-guide/configuration#auxiliary-models). ### `vision_analyze` has the same dual behavior The `vision_analyze` tool itself follows the same routing. When the active main model is vision-capable **and** its provider supports image content inside tool results (currently the Anthropic, OpenAI, Azure-OpenAI, and Gemini 3.x stacks), `vision_analyze` short-circuits the auxiliary describer and returns the raw image pixels as a multimodal tool-result envelope. The main model sees the image natively on its next turn — no aux call, no text-summary information loss, no extra latency. For text-only main models (or providers whose tool-result channel doesn't carry images), `vision_analyze` falls back to the legacy path: it asks the configured auxiliary vision model to describe the image and returns the description as plain text. Either way the calling tool signature is the same — the tool decides which path to take at runtime based on the active model. --- <!-- source: website/docs/user-guide/features/image-generation.md --> # user-guide/features/image-generation # Image Generation Claway Agent generates images from text prompts via FAL.ai. Eleven models are supported out of the box, each with different speed, quality, and cost tradeoffs. The active model is user-configurable via `claway tools` and persists in `config.yaml`. ## Supported Models | Model | Speed | Strengths | Price | |---|---|---|---| | `fal-ai/flux-2/klein/9b` *(default)* | `<1s` | Fast, crisp text | $0.006/MP | | `fal-ai/flux-2-pro` | ~6s | Studio photorealism | $0.03/MP | | `fal-ai/z-image/turbo` | ~2s | Bilingual EN/CN, 6B params | $0.005/MP | | `fal-ai/nano-banana-pro` | ~8s | Gemini 3 Pro, reasoning depth, text rendering | $0.15/image (1K) | | `fal-ai/gpt-image-1.5` | ~15s | Prompt adherence | $0.034/image | | `fal-ai/gpt-image-2` | ~20s | SOTA text rendering + CJK, world-aware photorealism | $0.04–0.06/image | | `fal-ai/ideogram/v3` | ~5s | Best typography | $0.03–0.09/image | | `fal-ai/recraft/v4/pro/text-to-image` | ~8s | Design, brand systems, production-ready | $0.25/image | | `fal-ai/qwen-image` | ~12s | LLM-based, complex text | $0.02/MP | | `fal-ai/krea/v2/medium/text-to-image` | ~15-25s | Illustration, anime, painting, expressive/artistic styles | $0.030–0.035/image | | `fal-ai/krea/v2/large/text-to-image` | ~25-60s | Photorealism, raw textured looks (motion blur, grain, film) | $0.060–0.065/image | Prices are FAL's pricing at time of writing; check [fal.ai](https://fal.ai/) for current numbers. ## Setup ### Get a FAL API Key 1. Sign up at [fal.ai](https://fal.ai/) 2. Generate an API key from your dashboard ### Configure and Pick a Model Run the tools command: ```bash claway tools ``` Navigate to **🎨 Image Generation**, pick your backend (for example FAL.ai), then the picker shows all supported models in a column-aligned table — arrow keys to navigate, Enter to select: ``` Model Speed Strengths Price fal-ai/flux-2/klein/9b <1s Fast, crisp text $0.006/MP ← currently in use fal-ai/flux-2-pro ~6s Studio photorealism $0.03/MP fal-ai/z-image/turbo ~2s Bilingual EN/CN, 6B $0.005/MP ... ``` Your selection is saved to `config.yaml`: ```yaml image_gen: model: fal-ai/flux-2/klein/9b ``` ### GPT-Image Quality The `fal-ai/gpt-image-1.5` and `fal-ai/gpt-image-2` request quality is pinned to `medium` (~$0.034–$0.06/image at 1024×1024). We don't expose the `low` / `high` tiers as a user-facing option so that billing stays predictable — the cost spread between tiers is 3–22×. If you want a cheaper option, pick Klein 9B or Z-Image Turbo; if you want higher quality, use Nano Banana Pro or Recraft V4 Pro. ## Usage The agent-facing schema is intentionally minimal — the model picks up whatever you've configured: ``` Generate an image of a serene mountain landscape with cherry blossoms ``` ``` Create a square portrait of a wise old owl — use the typography model ``` ``` Make me a futuristic cityscape, landscape orientation ``` ## Image-to-Image / Editing The same `image_generate` tool also **edits existing images** when the active model supports it — pass a source image and the backend routes to its editing endpoint automatically (mirrors how `video_generate` handles image-to-video). Omit the source image and it's plain text-to-image. ``` Take this photo and make it a rainy Tokyo street at night → <image> ``` ``` Blend these two product shots into one hero image → <image1> <image2> ``` Two inputs drive the edit: - **`image_url`** — the primary source image to edit/transform (public URL or local path). - **`reference_image_urls`** — additional style/composition references (capped per-model). ### Which backends support editing | Backend | Image-to-image | Reference cap | How | |---|---|---|---| | **FAL.ai** (edit-capable models below) | ✓ | up to 9 | routes to the model's `/edit` endpoint | | **OpenAI** (`gpt-image-2`) | ✓ | up to 16 | `images.edit()` | | **xAI** (Grok Imagine) | ✓ | 1 | `/v1/images/edits` (`grok-imagine-image-quality`) | | **Krea** (`Krea 2`) | ✓ | up to 10 | reference-guided generation (`image_style_references`) | | **OpenAI (Codex auth)** | ✗ | — | text-to-image only | FAL models with an editing endpoint: `flux-2/klein/9b`, `flux-2-pro`, `nano-banana-pro`, `gpt-image-1.5`, `gpt-image-2`, `ideogram/v3`, and `qwen-image`. Pure text-to-image FAL models (`z-image/turbo`, `recraft`, `krea/*`) reject image inputs with a clear error pointing you at an edit-capable model. The active model's editing capability is surfaced in the tool description at runtime, so the agent knows whether `image_url` will be honored before it calls the tool. ## Aspect Ratios Every model accepts the same three aspect ratios from the agent's perspective. Internally, each model's native size spec is filled in automatically: | Agent input | image_size (flux/z-image/qwen/recraft/ideogram) | aspect_ratio (nano-banana-pro) | image_size (gpt-image-1.5) | image_size (gpt-image-2) | |---|---|---|---|---| | `landscape` | `landscape_16_9` | `16:9` | `1536x1024` | `landscape_4_3` (1024×768) | | `square` | `square_hd` | `1:1` | `1024x1024` | `square_hd` (1024×1024) | | `portrait` | `portrait_16_9` | `9:16` | `1024x1536` | `portrait_4_3` (768×1024) | GPT Image 2 maps to 4:3 presets rather than 16:9 because its minimum pixel count is 655,360 — the `landscape_16_9` preset (1024×576 = 589,824) would be rejected. This translation happens in `_build_fal_payload()` — agent code never has to know about per-model schema differences. ## Automatic Upscaling Upscaling via FAL's **Clarity Upscaler** is gated per-model: | Model | Upscale? | Why | |---|---|---| | `fal-ai/flux-2-pro` | ✓ | Backward-compat (was the pre-picker default) | | All others | ✗ | Fast models would lose their sub-second value prop; hi-res models don't need it | When upscaling runs, it uses these settings: | Setting | Value | |---|---| | Upscale factor | 2× | | Creativity | 0.35 | | Resemblance | 0.6 | | Guidance scale | 4 | | Inference steps | 18 | If upscaling fails (network issue, rate limit), the original image is returned automatically. ## How It Works Internally 1. **Model resolution** — `_resolve_fal_model()` reads `image_gen.model` from `config.yaml`, falls back to the `FAL_IMAGE_MODEL` env var, then to `fal-ai/flux-2/klein/9b`. 2. **Payload building** — `_build_fal_payload()` translates your `aspect_ratio` into the model's native format (preset enum, aspect-ratio enum, or GPT literal), merges the model's default params, applies any caller overrides, then filters to the model's `supports` whitelist so unsupported keys are never sent. 3. **Submission** — `_submit_fal_request()` routes via your FAL credentials. 4. **Upscaling** — runs only if the model's metadata has `upscale: True`. 5. **Delivery** — final image URL returned to the agent, which emits a `MEDIA:<url>` tag that platform adapters convert to native media. ## Debugging Enable debug logging: ```bash export IMAGE_TOOLS_DEBUG=true ``` Debug logs go to `./logs/image_tools_debug_<session_id>.json` with per-call details (model, parameters, timing, errors). ## Platform Delivery | Platform | Delivery | |---|---| | **CLI** | Image URL printed as markdown `![](url)` — click to open | | **Telegram** | Photo message with the prompt as caption | | **Discord** | Embedded in a message | | **Slack** | URL unfurled by Slack | | **WhatsApp** | Media message | | **Others** | URL in plain text | ## Limitations - **Requires credentials** for the active backend (FAL `FAL_KEY`, `OPENAI_API_KEY`, xAI OAuth, `KREA_API_KEY`) - **Editing is model-dependent** — image-to-image works only on edit-capable models (see the table above); text-to-image-only models reject image inputs with a clear error - **Temporary URLs** — backends return hosted URLs that expire after hours/days; Claway materializes them to the local cache so delivery still works after expiry - **Per-model constraints** — some models don't support `seed`, `num_inference_steps`, etc. The `supports` / `edit_supports` filter silently drops unsupported params; this is expected behavior --- <!-- source: website/docs/user-guide/features/tts.md --> # Voice & TTS # Voice & TTS Claway Agent supports both text-to-speech output and voice message transcription across all messaging platforms. ## Text-to-Speech Convert text to speech with ten providers: | Provider | Quality | Cost | API Key | |----------|---------|------|---------| | **Edge TTS** (default) | Good | Free | None needed | | **ElevenLabs** | Excellent | Paid | `ELEVENLABS_API_KEY` | | **OpenAI TTS** | Good | Paid | `VOICE_TOOLS_OPENAI_KEY` | | **MiniMax TTS** | Excellent | Paid | `MINIMAX_API_KEY` | | **Mistral (Voxtral TTS)** | Excellent | Paid | `MISTRAL_API_KEY` | | **Google Gemini TTS** | Excellent | Free tier | `GEMINI_API_KEY` | | **xAI TTS** | Excellent | Paid | `XAI_API_KEY` | | **NeuTTS** | Good | Free (local) | None needed | | **KittenTTS** | Good | Free (local) | None needed | | **Piper** | Good | Free (local) | None needed | ### Platform Delivery | Platform | Delivery | Format | |----------|----------|--------| | Telegram | Voice bubble (plays inline) | Opus `.ogg` | | Discord | Voice bubble (Opus/OGG), falls back to file attachment | Opus/MP3 | | WhatsApp | Audio file attachment | MP3 | | CLI | Saved to `~/.claway/audio_cache/` | MP3 | ### Configuration ```yaml # In ~/.claway/config.yaml tts: provider: "edge" # "edge" | "elevenlabs" | "openai" | "minimax" | "mistral" | "gemini" | "xai" | "neutts" | "kittentts" | "piper" speed: 1.0 # Global speed multiplier (provider-specific settings override this) edge: voice: "en-US-AriaNeural" # 322 voices, 74 languages speed: 1.0 # Converted to rate percentage (+/-%) elevenlabs: voice_id: "pNInz6obpgDQGcFmaJgB" # Adam model_id: "eleven_multilingual_v2" openai: model: "gpt-4o-mini-tts" voice: "alloy" # alloy, echo, fable, onyx, nova, shimmer base_url: "https://api.openai.com/v1" # Override for OpenAI-compatible TTS endpoints speed: 1.0 # 0.25 - 4.0 minimax: model: "speech-2.8-hd" # speech-2.8-hd (default), speech-2.8-turbo voice_id: "English_Graceful_Lady" # See https://platform.minimax.io/faq/system-voice-id speed: 1 # 0.5 - 2.0 vol: 1 # 0 - 10 pitch: 0 # -12 - 12 mistral: model: "voxtral-mini-tts-2603" voice_id: "c69964a6-ab8b-4f8a-9465-ec0925096ec8" # Paul - Neutral (default) gemini: model: "gemini-2.5-flash-preview-tts" # or gemini-3.1-flash-tts-preview voice: "Kore" # 30 prebuilt voices: Zephyr, Puck, Kore, Enceladus, Gacrux, etc. audio_tags: false # Enable hidden Gemini 3.1 TTS audio-tag insertion persona_prompt_file: "" # Optional Markdown/text file with Gemini voice direction xai: voice_id: "eve" # or a custom voice ID — see docs below language: "en" # ISO 639-1 code sample_rate: 24000 # 22050 / 24000 (default) / 44100 / 48000 bit_rate: 128000 # MP3 bitrate; only applies when codec=mp3 # base_url: "https://api.x.ai/v1" # Override via XAI_BASE_URL env var neutts: ref_audio: '' ref_text: '' model: neuphonic/neutts-air-q4-gguf device: cpu kittentts: model: KittenML/kitten-tts-nano-0.8-int8 # 25MB int8; also: kitten-tts-micro-0.8 (41MB), kitten-tts-mini-0.8 (80MB) voice: Jasper # Jasper, Bella, Luna, Bruno, Rosie, Hugo, Kiki, Leo speed: 1.0 # 0.5 - 2.0 clean_text: true # Expand numbers, currencies, units piper: voice: en_US-lessac-medium # voice name (auto-downloaded) OR absolute path to .onnx # voices_dir: '' # default: ~/.claway/cache/piper-voices/ # use_cuda: false # requires onnxruntime-gpu # length_scale: 1.0 # 2.0 = twice as slow # noise_scale: 0.667 # noise_w_scale: 0.8 # volume: 1.0 # 0.5 = half as loud # normalize_audio: true ``` **Speed control**: The global `tts.speed` value applies to all providers by default. Each provider can override it with its own `speed` setting (e.g., `tts.openai.speed: 1.5`). Provider-specific speed takes precedence over the global value. Default is `1.0` (normal speed). ### Gemini Persona Prompts Gemini TTS can follow natural-language performance direction. Set `tts.gemini.persona_prompt_file` to a local Markdown or text file that describes the voice persona. The file can include Gemini-style sections such as `AUDIO PROFILE`, `SCENE`, `DIRECTOR'S NOTES`, `SAMPLE CONTEXT`, and `TRANSCRIPT`. If the file contains `{transcript}` or `{{ transcript }}`, Claway replaces that placeholder with the live TTS text. Otherwise, Claway appends a labeled `TRANSCRIPT` section automatically. The persona prompt stays local and is not shown in the chat reply. ```yaml tts: provider: gemini gemini: voice: Algieba persona_prompt_file: ~/.claway/tts/butler-voice.md ``` ### Gemini Audio Tags Gemini 3.1 Flash TTS supports freeform square-bracket audio tags such as `[whispers]`, `[excitedly]`, `[very slow]`, `[laughs]`, and other expressive delivery notes. Enable `tts.gemini.audio_tags` to have Claway run a hidden rewrite pass before Gemini TTS. The rewrite inserts inline tags into the TTS script only; the visible chat reply stays unchanged. ```yaml tts: provider: gemini gemini: model: gemini-3.1-flash-tts-preview audio_tags: true ``` The rewrite uses `auxiliary.tts_audio_tags` and defaults to your main chat model. Override that auxiliary task if you want tag insertion handled by a cheaper or faster model. ### Input length limits Each provider has a documented per-request input-character cap. Claway truncates text before calling the provider so requests never fail with a length error: | Provider | Default cap (chars) | |----------|---------------------| | Edge TTS | 5000 | | OpenAI | 4096 | | xAI | 15000 | | MiniMax | 10000 | | Mistral | 4000 | | Google Gemini | 32000 | | ElevenLabs | Model-aware (see below) | | NeuTTS | 2000 | | KittenTTS | 2000 | | Piper | 5000 | **ElevenLabs** picks a cap from the configured `model_id`: | `model_id` | Cap (chars) | |------------|-------------| | `eleven_flash_v2_5` | 40000 | | `eleven_flash_v2` | 30000 | | `eleven_multilingual_v2` (default), `eleven_multilingual_v1`, `eleven_english_sts_v2`, `eleven_english_sts_v1` | 10000 | | `eleven_v3`, `eleven_ttv_v3` | 5000 | | Unknown model | Falls back to provider default (10000) | **Override per provider** with `max_text_length:` under the provider section of your TTS config: ```yaml tts: openai: max_text_length: 8192 # raise or lower the provider cap ``` Only positive integers are honored. Zero, negative, non-numeric, or boolean values fall through to the provider default, so a broken config can't accidentally disable truncation. ### Telegram Voice Bubbles & ffmpeg Telegram voice bubbles require Opus/OGG audio format: - **OpenAI, ElevenLabs, and Mistral** produce Opus natively — no extra setup - **Edge TTS** (default) outputs MP3 and needs **ffmpeg** to convert: - **MiniMax TTS** outputs MP3 and needs **ffmpeg** to convert for Telegram voice bubbles - **Google Gemini TTS** outputs raw PCM and uses **ffmpeg** to encode Opus directly for Telegram voice bubbles - **xAI TTS** outputs MP3 and needs **ffmpeg** to convert for Telegram voice bubbles - **NeuTTS** outputs WAV and also needs **ffmpeg** to convert for Telegram voice bubbles - **KittenTTS** outputs WAV and also needs **ffmpeg** to convert for Telegram voice bubbles - **Piper** outputs WAV and also needs **ffmpeg** to convert for Telegram voice bubbles ```bash # Ubuntu/Debian sudo apt install ffmpeg # macOS brew install ffmpeg # Fedora sudo dnf install ffmpeg ``` Without ffmpeg, Edge TTS, MiniMax TTS, NeuTTS, KittenTTS, and Piper audio are sent as regular audio files (playable, but shown as a rectangular player instead of a voice bubble). :::tip If you want voice bubbles without installing ffmpeg, switch to the OpenAI, ElevenLabs, or Mistral provider. ::: ### xAI Custom Voices (voice cloning) xAI supports cloning your voice and using it with TTS. Create a custom voice in the [xAI Console](https://console.x.ai/team/default/voice/voice-library), then set the resulting `voice_id` in your config: ```yaml tts: provider: xai xai: voice_id: "nlbqfwie" # your custom voice ID ``` See the [xAI Custom Voices docs](https://docs.x.ai/developers/model-capabilities/audio/custom-voices) for details on recording, supported formats, and limits. ### Piper (local, 44 languages) Piper is a fast, local neural TTS engine from the Open Home Foundation (the Home Assistant maintainers). It runs entirely on CPU, supports **44 languages** with pre-trained voices, and needs no API key. **Install via `claway tools`** → Voice & TTS → Piper — Claway runs `pip install piper-tts` for you. Or install manually: `pip install piper-tts`. **Switch to Piper:** ```yaml tts: provider: piper piper: voice: en_US-lessac-medium ``` On the first TTS call for a voice that isn't cached locally, Claway runs `python -m piper.download_voices <name>` and downloads the model (~20-90MB depending on quality tier) into `~/.claway/cache/piper-voices/`. Subsequent calls reuse the cached model. **Picking a voice.** The [full voice catalog](https://github.com/OHF-Voice/piper1-gpl/blob/main/docs/VOICES.md) covers English, Spanish, French, German, Italian, Dutch, Portuguese, Russian, Polish, Turkish, Chinese, Arabic, Hindi, and more — each with `x_low` / `low` / `medium` / `high` quality tiers. Sample voices at [rhasspy.github.io/piper-samples](https://rhasspy.github.io/piper-samples/). **Using a pre-downloaded voice.** Set `tts.piper.voice` to an absolute path ending in `.onnx`: ```yaml tts: piper: voice: /path/to/my-custom-voice.onnx ``` **Advanced knobs** (`tts.piper.length_scale` / `noise_scale` / `noise_w_scale` / `volume` / `normalize_audio`, `use_cuda`) correspond 1:1 to Piper's `SynthesisConfig`. They're ignored on older `piper-tts` versions. ### Custom command providers If a TTS engine you want isn't natively supported (VoxCPM, MLX-Kokoro, XTTS CLI, a voice-cloning script, anything else that exposes a CLI), you can wire it in as a **command-type provider** without writing any Python. Claway writes the input text to a temp UTF-8 file, runs your shell command, and reads the audio file the command produced. Declare one or more providers under `tts.providers.<name>` and switch between them with `tts.provider: <name>` — the same way you switch between built-ins like `edge` and `openai`. ```yaml tts: provider: voxcpm # pick any name under tts.providers providers: voxcpm: type: command command: "voxcpm --ref ~/voice.wav --text-file {input_path} --out {output_path}" output_format: mp3 timeout: 180 voice_compatible: true # try to deliver as a Telegram voice bubble mlx-kokoro: type: command command: "python -m mlx_kokoro --in {input_path} --out {output_path} --voice {voice}" voice: af_sky output_format: wav piper-custom: # native Piper also supports custom .onnx via tts.piper.voice type: command command: "piper -m /path/to/custom.onnx -f {output_path} < {input_path}" output_format: wav ``` #### Example: Doubao (Chinese seed-tts-2.0) For high-quality Chinese TTS via ByteDance's [seed-tts-2.0](https://www.volcengine.com/docs/6561/1257544) bidirectional-streaming API, install the [`doubao-speech`](https://pypi.org/project/doubao-speech/) PyPI package and wire it in as a command provider: ```bash pip install doubao-speech export VOLCENGINE_APP_ID="your-app-id" export VOLCENGINE_ACCESS_TOKEN="your-access-token" ``` ```yaml tts: provider: doubao providers: doubao: type: command command: "doubao-speech say --text-file {input_path} --out {output_path}" output_format: mp3 max_text_length: 1024 timeout: 30 ``` Credentials come from your shell environment (`VOLCENGINE_APP_ID` / `VOLCENGINE_ACCESS_TOKEN`) or `~/.doubao-speech/config.yaml`. Pick a voice by adding `--voice zh-female-warm` (or any other alias from `doubao-speech list-voices`) to the command. `doubao-speech` also bundles streaming ASR — see the [STT section below](#example-doubao--volcengine-asr) for Claway integration. Source and full docs: [github.com/Hypnus-Yuan/doubao-speech](https://github.com/Hypnus-Yuan/doubao-speech). #### Placeholders Your command template can reference these placeholders. Claway substitutes them at render time and shell-quotes each value for the surrounding context (bare / single-quoted / double-quoted), so paths with spaces and other shell-sensitive characters are safe. | Placeholder | Meaning | |------------------|------------------------------------------------------| | `{input_path}` | Path to the temp UTF-8 text file Claway wrote | | `{text_path}` | Alias for `{input_path}` | | `{output_path}` | Path the command must write audio to | | `{format}` | `mp3` / `wav` / `ogg` / `flac` | | `{voice}` | `tts.providers.<name>.voice`, empty when unset | | `{model}` | `tts.providers.<name>.model` | | `{speed}` | Resolved speed multiplier (provider or global) | Use `{{` and `}}` for literal braces. #### Optional keys | Key | Default | Meaning | |--------------------|---------|------------------------------------------------------------------------------------------------------------| | `timeout` | `120` | Seconds; the process tree is killed on expiry (Unix `killpg`, Windows `taskkill /T`). | | `output_format` | `mp3` | One of `mp3` / `wav` / `ogg` / `flac`. Auto-inferred from the output extension if Claway picks a path. | | `voice_compatible` | `false` | When `true`, Claway converts MP3/WAV output to Opus/OGG via ffmpeg so Telegram renders a voice bubble. | | `max_text_length` | `5000` | Input is truncated to this length before rendering the command. | | `voice` / `model` | empty | Passed to the command as placeholder values only. | #### Behavior notes - **Built-in names always win.** A `tts.providers.openai` entry never shadows the native OpenAI provider, so no user config can silently replace a built-in. - **Default delivery is a document.** Command providers deliver as regular audio attachments on every platform. Opt in to voice-bubble delivery per-provider with `voice_compatible: true`. - **Command failures surface to the agent.** Non-zero exit, empty output, or timeout all return an error with the command's stderr/stdout included so you can debug the provider from the conversation. - **`type: command` is the default when `command:` is set.** Writing `type: command` explicitly is good practice but not required; an entry with a non-empty `command` string is treated as a command provider. - **`{input_path}` / `{text_path}` are interchangeable.** Use whichever reads better in your command. #### Security Command-type providers run whatever shell command you configure, with your user's permissions. Claway quotes placeholder values and enforces the configured timeout, but the command template itself is trusted local input — treat it the same way you would a shell script on your PATH. ### Python plugin providers For TTS engines that can't be expressed as a single shell command — Python SDKs without a CLI, streaming engines, voice-listing APIs, OAuth-refreshing auth — register a Python plugin via `ctx.register_tts_provider()`. The plugin **coexists with** (does not replace) the [Custom command providers](#custom-command-providers) registry; pick the surface that fits your engine. #### When to pick which | Your backend has… | Use | |---|---| | A single CLI reading text from a file/stdin and writing audio to a file/stdout | **Command provider** (no Python needed) | | Two or three CLIs chained with shell pipes | **Command provider** | | A Python SDK only — no CLI | **Plugin** | | Streaming bytes you want to deliver chunked (mid-generation voice bubbles) | **Plugin** (override `stream()`) | | A voice-listing API used by `claway setup` | **Plugin** (override `list_voices()`) | | OAuth refresh flow (not a static bearer token) | **Plugin** | Built-ins always win, and command providers win over a same-name plugin — so plugins are safe to register against any non-built-in name without worrying about shadowing your existing config. #### Minimal plugin Drop this in `~/.claway/plugins/my-tts/`: `plugin.yaml`: ```yaml name: my-tts version: 0.1.0 description: "My custom Python TTS backend" ``` `__init__.py`: ```python from agent.tts_provider import TTSProvider class MyTTSProvider(TTSProvider): @property def name(self) -> str: return "my-tts" # what tts.provider matches against @property def display_name(self) -> str: return "My Custom TTS" def is_available(self) -> bool: # Return False when credentials/deps are missing — picker skips # this row but the dispatcher still routes here on explicit config. import os return bool(os.environ.get("MY_TTS_API_KEY")) def synthesize(self, text, output_path, *, voice=None, model=None, speed=None, format="mp3", **extra) -> str: # Write audio bytes to output_path, return the path. # Raise on failure — the dispatcher converts exceptions to a # standard error envelope. import my_tts_sdk client = my_tts_sdk.Client() audio_bytes = client.synthesize(text=text, voice=voice or "default") with open(output_path, "wb") as f: f.write(audio_bytes) return output_path def register(ctx): ctx.register_tts_provider(MyTTSProvider()) ``` Enable it (`claway plugins enable my-tts`), point `tts.provider` at it (`tts.provider: my-tts` in `config.yaml`), and the `text_to_speech` tool will route through your plugin. #### Optional hooks Override these on your provider class for richer integration: - `list_voices()` → list of `{id, display, language, gender, preview_url}` dicts shown in `claway tools`. - `list_models()` → list of `{id, display, languages, max_text_length}` dicts. - `get_setup_schema()` → return `{name, badge, tag, env_vars: [{key, prompt, url}]}` to power the picker row in `claway tools` / `claway setup`. Without this, the plugin still works but its row in the picker is minimal. - `stream(text, *, voice, model, format, **extra)` → iterator yielding audio bytes for streaming delivery (default raises `NotImplementedError`). - `voice_compatible` property → set `True` if your output is Opus-compatible and the gateway should deliver it as a voice bubble (default `False` = regular audio attachment). See `agent/tts_provider.py` for the full ABC including docstrings. ## Voice Message Transcription (STT) Voice messages sent on Telegram, Discord, WhatsApp, Slack, or Signal are automatically transcribed and injected as text into the conversation. The agent sees the transcript as normal text. | Provider | Quality | Cost | API Key | |----------|---------|------|---------| | **Local Whisper** (default) | Good | Free | None needed | | **Groq Whisper API** | Good–Best | Free tier | `GROQ_API_KEY` | | **OpenAI Whisper API** | Good–Best | Paid | `VOICE_TOOLS_OPENAI_KEY` or `OPENAI_API_KEY` | :::info Zero Config Local transcription works out of the box when `faster-whisper` is installed. If that's unavailable, Claway can also use a local `whisper` CLI from common install locations (like `/opt/homebrew/bin`) or a custom command via `CLAWAY_LOCAL_STT_COMMAND`. ::: ### Configuration ```yaml # In ~/.claway/config.yaml stt: provider: "local" # "local" | "groq" | "openai" | "mistral" | "xai" local: model: "base" # tiny, base, small, medium, large-v3 openai: model: "whisper-1" # whisper-1, gpt-4o-mini-transcribe, gpt-4o-transcribe mistral: model: "voxtral-mini-latest" # voxtral-mini-latest, voxtral-mini-2602 xai: model: "grok-stt" # xAI Grok STT ``` ### Provider Details **Local (faster-whisper)** — Runs Whisper locally via [faster-whisper](https://github.com/SYSTRAN/faster-whisper). Uses CPU by default, GPU if available. Model sizes: | Model | Size | Speed | Quality | |-------|------|-------|---------| | `tiny` | ~75 MB | Fastest | Basic | | `base` | ~150 MB | Fast | Good (default) | | `small` | ~500 MB | Medium | Better | | `medium` | ~1.5 GB | Slower | Great | | `large-v3` | ~3 GB | Slowest | Best | **Groq API** — Requires `GROQ_API_KEY`. Good cloud fallback when you want a free hosted STT option. **OpenAI API** — Accepts `VOICE_TOOLS_OPENAI_KEY` first and falls back to `OPENAI_API_KEY`. Supports `whisper-1`, `gpt-4o-mini-transcribe`, and `gpt-4o-transcribe`. **Mistral API (Voxtral Transcribe)** — Requires `MISTRAL_API_KEY`. Uses Mistral's [Voxtral Transcribe](https://docs.mistral.ai/capabilities/audio/speech_to_text/) models. Supports 13 languages, speaker diarization, and word-level timestamps. Install with `cd ~/.claway/claway && uv pip install -e ".[mistral]"`. **xAI Grok STT** — Requires `XAI_API_KEY`. Posts to `https://api.x.ai/v1/stt` as multipart/form-data. Good choice if you're already using xAI for chat or TTS and want one API key for everything. Auto-detection order puts it after Groq — explicitly set `stt.provider: xai` to force it. **Custom local CLI fallback** — Set `CLAWAY_LOCAL_STT_COMMAND` if you want Claway to call a local transcription command directly. The command template supports `{input_path}`, `{output_dir}`, `{language}`, and `{model}` placeholders. Your command must write a `.txt` transcript somewhere under `{output_dir}`. #### Example: Doubao / Volcengine ASR If you use [`doubao-speech`](https://pypi.org/project/doubao-speech/) for Doubao TTS (see [above](#example-doubao-chinese-seed-tts-20)), the same package handles speech-to-text via the local-command STT surface: ```bash pip install doubao-speech export VOLCENGINE_APP_ID="your-app-id" export VOLCENGINE_ACCESS_TOKEN="your-access-token" export CLAWAY_LOCAL_STT_COMMAND='doubao-speech transcribe {input_path} --out {output_dir}/transcript.txt' ``` ```yaml stt: provider: local_command ``` Claway writes the incoming voice message to `{input_path}`, runs the command, and reads the `.txt` file produced under `{output_dir}`. Language is auto-detected by the Volcengine bigmodel endpoint. ### Fallback Behavior If your configured provider isn't available, Claway automatically falls back: - **Local faster-whisper unavailable** → Tries a local `whisper` CLI or `CLAWAY_LOCAL_STT_COMMAND` before cloud providers - **Groq key not set** → Falls back to local transcription, then OpenAI - **OpenAI key not set** → Falls back to local transcription, then Groq - **Mistral key/SDK not set** → Skipped in auto-detect; falls through to next available provider - **Nothing available** → Voice messages pass through with an accurate note to the user ### STT custom command providers If the STT engine you want isn't natively supported (Doubao ASR, NVIDIA Parakeet, a whisper.cpp build, an open-source SenseVoice CLI, anything else that exposes a shell command), wire it in as a **command-type provider** without writing any Python. Claway runs your shell command against the audio file and reads back the transcript. Declare one or more providers under `stt.providers.<name>` and switch between them with `stt.provider: <name>` — same shape as the TTS [command-provider registry](#custom-command-providers), adapted for the input=audio → output=transcript direction. ```yaml stt: provider: parakeet # pick any name under stt.providers providers: parakeet: type: command command: "parakeet-asr --model nvidia/parakeet-tdt-0.6b-v2 --in {input_path} --out {output_path}" format: txt language: en timeout: 300 whispercpp: type: command command: "whisper-cli -m ~/models/ggml-large-v3.bin -f {input_path} -otxt -of {output_dir}/transcript" format: txt sensevoice: type: command command: "sensevoice-cli {input_path} --json | tee {output_path}" format: json ``` This complements the legacy `CLAWAY_LOCAL_STT_COMMAND` escape hatch — that env var still works untouched via the built-in `local_command` path. Use `stt.providers.<name>` when you want **multiple** shell-driven STT engines, a name you can pick via `stt.provider`, or anything that needs per-provider `language` / `model` / `timeout`. #### STT placeholders Your command template can reference these placeholders. Claway substitutes them at render time and shell-quotes each value for the surrounding context (bare / single-quoted / double-quoted), so paths with spaces are safe. | Placeholder | Meaning | |-------------------|----------------------------------------------------------------------| | `{input_path}` | Absolute path to the input audio file (original location, read-only) | | `{output_path}` | Absolute path the command should write the transcript to | | `{output_dir}` | Parent directory of `{output_path}` (handy for whisper-style tools) | | `{format}` | Configured output format: `txt` / `json` / `srt` / `vtt` | | `{language}` | Configured language code (defaults to `en`) | | `{model}` | `stt.providers.<name>.model`, empty when unset | Use `{{` and `}}` for literal braces (handy when embedding JSON snippets in the command). #### How the transcript is read back After your command exits successfully: 1. If `{output_path}` exists and is non-empty → Claway reads it as UTF-8 text. 2. Otherwise, if the command wrote to stdout → Claway uses that. 3. Otherwise → error: "Command STT provider wrote no output file and produced no stdout". This lets you use the registry for both file-writing CLIs (`whisper-cli`, `parakeet-asr`) and curl-style one-liners that emit transcript to stdout (`curl … | jq -r .text`). For `format: json` / `srt` / `vtt`, Claway returns the raw file content as the `transcript` field. Extracting `.text` from JSON is out of scope for the runner — either configure `format: txt`, or post-process JSON downstream. #### STT command-provider optional keys | Key | Default | Meaning | |-----------------|---------|------------------------------------------------------------------------------------------------------| | `timeout` | `300` | Seconds; the process tree is killed on expiry (Unix `start_new_session`, Windows `taskkill /T`). | | `format` | `txt` | One of `txt` / `json` / `srt` / `vtt`. Sets the extension of `{output_path}`. | | `language` | `en` | Forwarded to `{language}`. Defaults to `stt.language` then `en`. | | `model` | empty | Forwarded to `{model}`. The `model=` argument to `transcribe_audio()` overrides this. | #### STT command-provider behavior notes - **Built-ins always win.** Declaring `stt.providers.openai: type: command` does NOT override the real OpenAI Whisper handler. The built-in name is short-circuited before the command-provider resolver runs. - **Process-tree cleanup.** A command running over `timeout` has its entire process tree killed, not just the shell wrapper. Long-running ASR pipelines that fork model-loading subprocesses are reaped reliably. - **Shell-quoting is automatic.** Placeholders inside `'…'` get single-quote-safe escaping; inside `"…"` get `$`/`` ` ``/`"` escaping; outside quotes get `shlex.quote`. Don't pre-quote placeholder values. #### STT command-provider security The shell command runs under the same user as Claway with full filesystem access — same trust model as `tts.providers.<name>: type: command` and `CLAWAY_LOCAL_STT_COMMAND`. Only declare command providers from sources you trust. ### Python plugin providers (STT) For STT engines that aren't built-in AND can't be expressed as a shell command (need a Python SDK, OAuth-refreshing auth, streaming chunks, etc.), register a Python plugin via `ctx.register_transcription_provider()`. The plugin **coexists with** the 6 built-in providers (`local`, `local_command`, `groq`, `openai`, `mistral`, `xai`) and the `stt.providers.<name>: type: command` registry — built-ins keep their native implementations and always win on name collision; command providers win over plugins of the same name (config is more local than plugin install). #### When to pick which (STT) | Backend has… | Use | |--------------------------------------------------------------|------------------------------------------------------------------| | A single shell command that takes an audio file and emits text | `stt.providers.<name>: type: command` (no Python needed) | | Only the legacy single-command escape hatch is wanted | `CLAWAY_LOCAL_STT_COMMAND` env var (preserved for back-compat) | | A Python SDK with no CLI | `register_transcription_provider()` plugin | | OAuth-refreshing auth, streaming chunks, voice-list metadata | `register_transcription_provider()` plugin | | A built-in already covers it (`local`, `groq`, `openai`, …) | Set `stt.provider: <name>` — built-ins are inline | #### Resolution order 1. **`stt.provider` is a built-in name** → built-in dispatch. **Always wins.** 2. **`stt.provider` matches `stt.providers.<name>` with `command:` set** → command-provider runner (see [STT custom command providers](#stt-custom-command-providers)). Wins over a same-name plugin. 3. **`stt.provider` matches a plugin-registered `TranscriptionProvider`** → plugin dispatch: - if the plugin's `is_available()` returns `False` (missing creds or SDK), the call surfaces an unavailability error envelope identifying the plugin — **not** the generic "No STT provider available" message. - otherwise the plugin's `transcribe()` is called with `model` (from the public `model=` arg, falling back to `stt.<provider>.model`) and `language` (from `stt.<provider>.language`). 4. **No match** → "No STT provider available" error. #### Per-provider config namespace Plugins read their per-provider configuration from `stt.<provider>` in `config.yaml`, mirroring how built-ins read `stt.openai.model` / `stt.mistral.model`: ```yaml stt: provider: my-stt my-stt: model: whisper-large-v3 language: ja # forwarded as language= to transcribe() # any other plugin-specific keys go here; read them via your # own config.yaml access in __init__/is_available/transcribe ``` The dispatcher forwards `model` and `language` from this section; everything else, the plugin can read itself. #### Minimal plugin Drop this in `~/.claway/plugins/my-stt/`: `plugin.yaml`: ```yaml name: my-stt version: 0.1.0 description: "My custom Python STT backend" ``` `__init__.py`: ```python from agent.transcription_provider import TranscriptionProvider class MySTTProvider(TranscriptionProvider): @property def name(self) -> str: return "my-stt" # what stt.provider matches against @property def display_name(self) -> str: return "My Custom STT" def is_available(self) -> bool: # Return False when credentials/deps are missing — picker skips # this row but the dispatcher still routes here on explicit config. import os return bool(os.environ.get("MY_STT_API_KEY")) def transcribe(self, file_path, *, model=None, language=None, **extra): # Return the standard transcribe envelope: # {"success": bool, "transcript": str, "provider": str, "error": str} # Do NOT raise — convert exceptions to the error envelope so the # gateway/CLI caller sees a consistent shape on failure. try: import my_stt_sdk client = my_stt_sdk.Client() text = client.transcribe(open(file_path, "rb")) return { "success": True, "transcript": text, "provider": "my-stt", } except Exception as exc: return { "success": False, "transcript": "", "error": f"my-stt failed: {exc}", "provider": "my-stt", } def register(ctx): ctx.register_transcription_provider(MySTTProvider()) ``` Enable it (`claway plugins enable my-stt`), set `stt.provider: my-stt` in `config.yaml`, and voice-message transcription will route through your plugin. #### Optional hooks Override these on your provider class for richer integration: - `list_models()` → list of `{id, display, languages, max_audio_seconds}` dicts. - `default_model()` → string returned when the user doesn't override the model. - `get_setup_schema()` → return `{name, badge, tag, env_vars: [{key, prompt, url}]}` to power picker rows in `claway tools` / `claway setup` (the picker category for STT is not yet shipped — this metadata is available to plugins for forward compatibility). See `agent/transcription_provider.py` for the full ABC including docstrings. --- <!-- source: website/docs/user-guide/messaging/index.md --> # Messaging Gateway # Messaging Gateway Chat with Claway from Telegram, Discord, Slack, WhatsApp, Signal, SMS, Email, Home Assistant, Mattermost, Matrix, DingTalk, Feishu/Lark, WeCom, Weixin, BlueBubbles (iMessage), QQ, Yuanbao, Microsoft Teams, LINE, ntfy, or your browser. The gateway is a single background process that connects to all your configured platforms, handles sessions, runs cron jobs, and delivers voice messages. For the full voice feature set — including CLI microphone mode, spoken replies in messaging, and Discord voice-channel conversations — see [Voice Mode](/user-guide/features/voice-mode) and [Use Voice Mode with Claway](/guides/use-voice-mode-with-claway). ## Platform Comparison | Platform | Voice | Images | Files | Threads | Reactions | Typing | Streaming | |----------|:-----:|:------:|:-----:|:-------:|:---------:|:------:|:---------:| | Telegram | ✅ | ✅ | ✅ | ✅ | — | ✅ | ✅ | | Discord | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | Slack | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | Google Chat | — | ✅ | ✅ | ✅ | — | ✅ | — | | WhatsApp | — | ✅ | ✅ | — | — | ✅ | ✅ | | Signal | — | ✅ | ✅ | — | — | ✅ | ✅ | | SMS | — | — | — | — | — | — | — | | Email | — | ✅ | ✅ | ✅ | — | — | — | | Home Assistant | — | — | — | — | — | — | — | | Mattermost | ✅ | ✅ | ✅ | ✅ | — | ✅ | ✅ | | Matrix | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | DingTalk | — | ✅ | ✅ | — | ✅ | — | ✅ | | Feishu/Lark | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | WeCom | ✅ | ✅ | ✅ | — | — | — | — | | WeCom Callback | — | — | — | — | — | — | — | | Weixin | ✅ | ✅ | ✅ | — | — | ✅ | ✅ | | BlueBubbles | — | ✅ | ✅ | — | ✅ | ✅ | — | | QQ | ✅ | ✅ | ✅ | — | — | ✅ | — | | Yuanbao | ✅ | ✅ | ✅ | — | — | ✅ | ✅ | | Microsoft Teams | — | ✅ | — | ✅ | — | ✅ | — | | LINE | — | ✅ | ✅ | — | — | ✅ | — | | ntfy | — | — | — | — | — | — | — | | Raft | — | — | — | — | — | — | — | | IRC | — | — | — | — | — | — | — | **Voice** = TTS audio replies and/or voice message transcription. **Images** = send/receive images. **Files** = send/receive file attachments. **Threads** = threaded conversations. **Reactions** = emoji reactions on messages. **Typing** = typing indicator while processing. **Streaming** = progressive message updates via editing. ## Architecture ```mermaid flowchart TB subgraph Gateway["Claway Gateway"] subgraph Adapters["Platform adapters"] tg[Telegram] dc[Discord] wa[WhatsApp] sl[Slack] gc[Google Chat] sig[Signal] sms[SMS] em[Email] ha[Home Assistant] mm[Mattermost] mx[Matrix] dt[DingTalk] fs[Feishu/Lark] wc[WeCom] wcb[WeCom Callback] wx[Weixin] bb[BlueBubbles] qq[QQ] yb[Yuanbao] ms[Microsoft Teams] api["API Server<br/>(OpenAI-compatible)"] wh[Webhooks] end store["Session store<br/>per chat"] agent["AIAgent<br/>run_agent.py"] cron["Cron scheduler<br/>ticks every 60s"] end tg --> store dc --> store wa --> store sl --> store gc --> store sig --> store sms --> store em --> store ha --> store mm --> store mx --> store dt --> store fs --> store wc --> store wcb --> store wx --> store bb --> store qq --> store yb --> store ms --> store api --> store wh --> store store --> agent cron --> store ``` Each platform adapter receives messages, routes them through a per-chat session store, and dispatches them to the AIAgent for processing. The gateway also runs the cron scheduler, ticking every 60 seconds to execute any due jobs. ## Intentional Silence Tokens For group chats, hooks, and automation flows, Claway supports explicit silence tokens. If the agent's final response is exactly one supported token, the gateway suppresses outbound delivery and sends nothing to the chat. Supported tokens: - `[SILENT]` - `SILENT` - `NO_REPLY` - `NO REPLY` Whitespace and case are normalized, but the whole final response must be the token. A sentence like "Use `[SILENT]` when nothing changed" is delivered normally. Silence is a delivery decision only. Claway keeps the assistant silence turn in the session transcript, so the conversation still alternates normally: ```text user: side-channel chatter assistant: [SILENT] # stored, not delivered user: next message ``` Failed turns still surface as errors; Claway does not hide failures just because the text resembles a silence token. ## Quick Setup The easiest way to configure messaging platforms is the interactive wizard: ```bash claway gateway setup # Interactive setup for all messaging platforms ``` This walks you through configuring each platform with arrow-key selection, shows which platforms are already configured, and offers to start/restart the gateway when done. ## Gateway Commands ```bash claway gateway # Run in foreground claway gateway setup # Configure messaging platforms interactively claway gateway install # Install as a user service (Linux) / launchd service (macOS) sudo claway gateway install --system # Linux only: install a boot-time system service claway gateway start # Start the default service claway gateway stop # Stop the default service claway gateway status # Check default service status claway gateway status --system # Linux only: inspect the system service explicitly ``` ## Chat Commands (Inside Messaging) | Command | Description | |---------|-------------| | `/new` or `/reset` | Start a fresh conversation | | `/model [provider:model]` | Show or change the model (supports `provider:model` syntax) | | `/personality [name]` | Set a personality | | `/retry` | Retry the last message | | `/undo` | Remove the last exchange | | `/status` | Show session info | | `/whoami` | Show your slash command access on this scope (admin / user / unrestricted) | | `/stop` | Stop the running agent | | `/approve` | Approve a pending dangerous command | | `/deny` | Reject a pending dangerous command | | `/sethome` | Set this chat as the home channel | | `/compress` | Manually compress conversation context | | `/title [name]` | Set or show the session title | | `/resume [name]` | Resume a previously named session | | `/usage` | Show token usage for this session | | `/insights [days]` | Show usage insights and analytics | | `/reasoning [level\|show\|hide]` | Change reasoning effort or toggle reasoning display | | `/voice [on\|off\|tts\|join\|leave\|status]` | Control messaging voice replies and Discord voice-channel behavior | | `/rollback [number]` | List or restore filesystem checkpoints | | `/background <prompt>` | Run a prompt in a separate background session | | `/reload-mcp` | Reload MCP servers from config | | `/update` | Update Claway Agent to the latest version | | `/help` | Show available commands | | `/<skill-name>` | Invoke any installed skill | ## Session Management ### Session Persistence Sessions persist across messages until they reset. The agent remembers your conversation context. ### Reset Policies Sessions reset based on configurable policies: | Policy | Default | Description | |--------|---------|-------------| | Daily | 4:00 AM | Reset at a specific hour each day | | Idle | 1440 min | Reset after N minutes of inactivity | | Both | (combined) | Whichever triggers first | A live background process (started with `terminal(background=true)`) normally protects its session from resetting so output isn't lost. To stop a forgotten process — say a preview server — from pinning a session open forever, a background process older than `bg_process_max_age_hours` (default **24**) no longer blocks reset. The process is **not** killed, only ignored by the reset guard. Set it to `0` to disable the cutoff (any live process blocks reset, the old behavior), or raise it if you run legitimate multi-day jobs whose liveness should keep the conversation open. Configure per-platform overrides in `~/.claway/gateway.json`: ```json { "reset_by_platform": { "telegram": { "mode": "idle", "idle_minutes": 240 }, "discord": { "mode": "idle", "idle_minutes": 60 } } } ``` ## Security **By default, the gateway denies all users who are not in an allowlist or paired via DM.** This is the safe default for a bot with terminal access. ```bash # Restrict to specific users (recommended): TELEGRAM_ALLOWED_USERS=123456789,987654321 DISCORD_ALLOWED_USERS=123456789012345678 SIGNAL_ALLOWED_USERS=+155****4567,+155****6543 SMS_ALLOWED_USERS=+155****4567,+155****6543 EMAIL_ALLOWED_USERS=trusted@example.com,colleague@work.com MATTERMOST_ALLOWED_USERS=3uo8dkh1p7g1mfk49ear5fzs5c MATRIX_ALLOWED_USERS=@alice:matrix.org DINGTALK_ALLOWED_USERS=user-id-1 FEISHU_ALLOWED_USERS=ou_xxxxxxxx,ou_yyyyyyyy WECOM_ALLOWED_USERS=user-id-1,user-id-2 WECOM_CALLBACK_ALLOWED_USERS=user-id-1,user-id-2 TEAMS_ALLOWED_USERS=aad-object-id-1,aad-object-id-2 # Or allow GATEWAY_ALLOWED_USERS=123456789,987654321 # Or explicitly allow all users (NOT recommended for bots with terminal access): GATEWAY_ALLOW_ALL_USERS=true ``` ### DM Pairing (Alternative to Allowlists) Instead of manually configuring user IDs, unknown users receive a one-time pairing code when they DM the bot. Email is the exception: unknown email senders are ignored unless email pairing is explicitly enabled. ```bash # The user sees: "Pairing code: XKGH5N7P" # You approve them with: claway pairing approve telegram XKGH5N7P # Other pairing commands: claway pairing list # View pending + approved users claway pairing revoke telegram 123456789 # Remove access ``` Pairing codes expire after 1 hour, are rate-limited, and use cryptographic randomness. ### Admins vs Regular Users Allowlists answer "can this person reach the bot at all?" The **admin / user split** answers "now that they're in, what are they allowed to do?" Every allowed user falls into one of two tiers per scope (DM vs group/channel): - **Admin** — full access. Can run every registered slash command (built-in + plugin) and use every gated capability. - **Regular user** — restricted access. Can chat with the agent normally, but can only run the slash commands you explicitly enable. The always-allowed floor is `/help` and `/whoami`. The tiers are configured per platform and per scope. DM admin status does not imply group/channel admin status — each scope has its own admin list. **What the tiers gate today:** slash commands. The split runs through the live command registry, so it covers built-ins and plugin-registered commands without per-feature wiring. Plain chat is not affected — non-admins can still talk to the agent. **What may be gated in the future:** more capability surfaces (tool access, model switching, expensive operations) will hang off the same admin / user distinction as we add them. Configuring the split now means those future restrictions land cleanly without you having to re-model who's an admin. #### Configuration ```yaml gateway: platforms: discord: extra: allow_from: ["111", "222", "333"] allow_admin_from: ["111"] # admins → all slash commands user_allowed_commands: [status, model] # what non-admins may run # Optional: separate group/channel scope group_allow_admin_from: ["111"] group_user_allowed_commands: [status] ``` **Backward compat:** if `allow_admin_from` is not set for a scope, the tier split is disabled for that scope and every allowed user has full access. Existing installs keep working with no changes — opt in when you want the distinction. #### Inspecting your access Use `/whoami` from any platform to see the active scope, your tier (admin / user / unrestricted), and which slash commands you can run. See the [Telegram](/user-guide/messaging/telegram#slash-command-access-control) and [Discord](/user-guide/messaging/discord#slash-command-access-control) pages for platform-specific examples. ## Interrupting the Agent Send any message while the agent is working to interrupt it. Key behaviors: - **In-progress terminal commands are killed immediately** (SIGTERM, then SIGKILL after 1s) - **Tool calls are cancelled** — only the currently-executing one runs, the rest are skipped - **Multiple messages are combined** — messages sent during interruption are joined into one prompt - **`/stop` command** — interrupts without queuing a follow-up message ### Queue vs interrupt vs steer (busy-input mode) By default, messaging a busy agent interrupts it. Two other modes are available: - `queue` — follow-up messages wait and run as the next turn after the current task finishes. - `steer` — follow-up messages are injected into the current run via `/steer`, arriving at the agent after the next tool call. No interrupt, no new turn. Falls back to `queue` behavior if the agent hasn't started yet. ```yaml display: busy_input_mode: steer # or queue, or interrupt (default) busy_ack_enabled: true # set to false to suppress the ⚡/⏳/⏩ chat reply entirely ``` The first time you message a busy agent on any platform, Claway appends a one-line reminder to the busy-ack explaining the knob (`"💡 First-time tip — …"`). The reminder fires once per install — a flag under `onboarding.seen.busy_input_prompt` latches it. Delete that key to see the tip again. If you find the busy-ack noisy — especially with voice input or rapid-fire messages — set `display.busy_ack_enabled: false`. Your input is still queued/steered/interrupts as normal, only the chat reply is silenced. ## Tool Progress Notifications Control how much tool activity is displayed in `~/.claway/config.yaml`: ```yaml display: tool_progress: all # off | new | all | verbose tool_progress_command: false # set to true to enable /verbose in messaging # How progress is grouped on platforms that support message editing: # accumulate (default) — edit one bubble in place as tools run # separate — send one message per tool (pre-v0.9 style; noisier) # Only applies where tool_progress is already enabled. tool_progress_grouping: accumulate # accumulate | separate ``` ### Message timestamps in model context Off by default. When enabled, Claway prepends a human-readable timestamp (e.g. `[Tue 2026-04-28 13:40:53 CEST]`) onto each **user** message *in the model's context* so the agent knows when messages were sent — useful for temporal reasoning ("you asked this morning…", noticing a long gap). It is **not** added to assistant messages or the system prompt. ```yaml gateway: message_timestamps: enabled: false # set true to show send-times to the model ``` Persisted transcripts always stay clean — the timestamp is stored as message metadata regardless of this toggle, so enabling it later also surfaces send-times for past messages, and replay never accumulates duplicate prefixes. When enabled, the bot sends status messages as it works: ```text 💻 `ls -la`... 🔍 web_search... 📄 web_extract... 🐍 execute_code... ``` ## Background Sessions Run a prompt in a separate background session so the agent works on it independently while your main chat stays responsive: ``` /background Check all servers in the cluster and report any that are down ``` Claway confirms immediately: ``` 🔄 Background task started: "Check all servers in the cluster..." Task ID: bg_143022_a1b2c3 ``` ### How It Works Each `/background` prompt spawns a **separate agent instance** that runs asynchronously: - **Isolated session** — the background agent has its own session with its own conversation history. It has no knowledge of your current chat context and receives only the prompt you provide. - **Same configuration** — inherits your model, provider, toolsets, reasoning settings, and provider routing from the current gateway setup. - **Non-blocking** — your main chat stays fully interactive. Send messages, run other commands, or start more background tasks while it works. - **Result delivery** — when the task finishes, the result is sent back to the **same chat or channel** where you issued the command, prefixed with "✅ Background task complete". If it fails, you'll see "❌ Background task failed" with the error. ### Background Process Notifications When the agent running a background session uses `terminal(background=true)` to start long-running processes (servers, builds, etc.), the gateway can push status updates to your chat. Control this with `display.background_process_notifications` in `~/.claway/config.yaml`: ```yaml display: background_process_notifications: all # all | result | error | off ``` | Mode | What you receive | |------|-----------------| | `all` | Running-output updates **and** the final completion message (default) | | `result` | Only the final completion message (regardless of exit code) | | `error` | Only the final message when the exit code is non-zero | | `off` | No process watcher messages at all | You can also set this via environment variable: ```bash CLAWAY_BACKGROUND_NOTIFICATIONS=result ``` ### Use Cases - **Server monitoring** — "/background Check the health of all services and alert me if anything is down" - **Long builds** — "/background Build and deploy the staging environment" while you continue chatting - **Research tasks** — "/background Research competitor pricing and summarize in a table" - **File operations** — "/background Organize the photos in ~/Downloads by date into folders" :::tip Background tasks on messaging platforms are fire-and-forget — you don't need to wait or check on them. Results arrive in the same chat automatically when the task finishes. ::: ## Service Management ### Linux (systemd) ```bash claway gateway install # Install as user service claway gateway start # Start the service claway gateway stop # Stop the service claway gateway status # Check status journalctl --user -u claway-gateway -f # View logs # Enable lingering (keeps running after logout) sudo loginctl enable-linger $USER # Or install a boot-time system service that still runs as your user sudo claway gateway install --system sudo claway gateway start --system sudo claway gateway status --system journalctl -u claway-gateway -f ``` Use the user service on laptops and dev boxes. Use the system service on VPS or headless hosts that should come back at boot without relying on systemd linger. :::danger Don't add a custom `ExecStopPost` kill drop-in The unit Claway installs already shuts the gateway down cleanly with `KillMode=mixed` + `KillSignal=SIGTERM`, and uses `Restart=always` with `RestartForceExitStatus` so updates and `/restart` respawn correctly. Do **not** add a systemd drop-in such as `ExecStopPost=/bin/kill -9 $MAINPID` — `ExecStopPost` fires on *every* stop, including clean restarts, so it `SIGKILL`s the freshly spawned instance before it stabilizes and `Restart=always` immediately respawns it. The result is an infinite restart loop (and, on Telegram, a flood of restart messages). If you've added such a drop-in, remove it: `systemctl --user edit claway-gateway` (or `sudo systemctl edit claway-gateway` for a system service) and delete the `ExecStopPost` line, then `systemctl --user daemon-reload`. ::: :::tip Headless VMs: user service + linger avoids root prompts A system service needs root for every restart — including the automatic gateway restart at the end of `claway update`. When `claway update` runs as a non-root user, it tries passwordless `sudo systemctl`; if that's unavailable, it skips the restart and prints the manual `sudo systemctl restart claway-gateway` command (it never blocks on an interactive password prompt). For a headless VM you never log into, a **user** service with lingering enabled gives you the same start-at-boot behavior with zero root involvement: ```bash claway gateway install # user service sudo loginctl enable-linger $USER # one-time: start at boot, survive logout ``` After that, `claway update` can restart the gateway without any privileges. If you prefer to keep the system service, either run updates with `sudo claway update`, or grant the service account passwordless sudo for systemctl, e.g. in `sudo visudo -f /etc/sudoers.d/claway-gateway`: ``` claway ALL=(root) NOPASSWD: /usr/bin/systemctl --no-ask-password reset-failed claway-gateway*, /usr/bin/systemctl --no-ask-password start claway-gateway*, /usr/bin/systemctl --no-ask-password restart claway-gateway* ``` ::: Avoid keeping both the user and system gateway units installed at once unless you really mean to. Claway will warn if it detects both because start/stop/status behavior gets ambiguous. :::info Multiple installations If you run multiple Claway installations on the same machine (with different `CLAWAY_HOME` directories), each gets its own systemd service name. The default `~/.claway` uses `claway-gateway`; other installations use `claway-gateway-<hash>`. The `claway gateway` commands automatically target the correct service for your current `CLAWAY_HOME`. ::: ### macOS (launchd) ```bash claway gateway install # Install as launchd agent claway gateway start # Start the service claway gateway stop # Stop the service claway gateway status # Check status tail -f ~/.claway/logs/gateway.log # View logs ``` The generated plist lives at `~/Library/LaunchAgents/ai.claway.gateway.plist`. It includes three environment variables: - **PATH** — your full shell PATH at install time, with the venv `bin/` and `node_modules/.bin` prepended. This ensures user-installed tools (Node.js, ffmpeg, etc.) are available to gateway subprocesses like the WhatsApp bridge. - **VIRTUAL_ENV** — points to the Python virtualenv so tools can resolve packages correctly. - **CLAWAY_HOME** — scopes the gateway to your Claway installation. :::tip PATH changes after install launchd plists are static — if you install new tools (e.g. a new Node.js version via nvm, or ffmpeg via Homebrew) after setting up the gateway, run `claway gateway install` again to capture the updated PATH. The gateway will detect the stale plist and reload automatically. ::: :::info Multiple installations Like the Linux systemd service, each `CLAWAY_HOME` directory gets its own launchd label. The default `~/.claway` uses `ai.claway.gateway`; other installations use `ai.claway.gateway-<suffix>`. ::: ## Platform-Specific Toolsets Each platform has its own toolset: | Platform | Toolset | Capabilities | |----------|---------|--------------| | CLI | `claway-cli` | Full access | | Telegram | `claway-telegram` | Full tools including terminal | | Discord | `claway-discord` | Full tools including terminal | | WhatsApp | `claway-whatsapp` | Full tools including terminal | | WhatsApp Cloud API | `claway-whatsapp` | Full tools including terminal (shares toolset with the Baileys bridge) | | Slack | `claway-slack` | Full tools including terminal | | Google Chat | `claway-google_chat` | Full tools including terminal | | Signal | `claway-signal` | Full tools including terminal | | SMS | `claway-sms` | Full tools including terminal | | Email | `claway-email` | Full tools including terminal | | Home Assistant | `claway-homeassistant` | Full tools + HA device control (ha_list_entities, ha_get_state, ha_call_service, ha_list_services) | | Mattermost | `claway-mattermost` | Full tools including terminal | | Matrix | `claway-matrix` | Full tools including terminal | | DingTalk | `claway-dingtalk` | Full tools including terminal | | Feishu/Lark | `claway-feishu` | Full tools including terminal | | WeCom | `claway-wecom` | Full tools including terminal | | WeCom Callback | `claway-wecom-callback` | Full tools including terminal | | Weixin | `claway-weixin` | Full tools including terminal | | BlueBubbles | `claway-bluebubbles` | Full tools including terminal | | QQBot | `claway-qqbot` | Full tools including terminal | | Yuanbao | `claway-yuanbao` | Full tools including terminal | | Microsoft Teams | `claway-teams` | Full tools including terminal | | API Server | `claway-api-server` | Full tools (drops `clarify`, `text_to_speech` — programmatic access doesn't have an interactive user) | | Webhooks | `claway-webhook` | Full tools including terminal | | Raft | `claway-raft` | Wake-only channel; agent uses Raft CLI for message I/O | ## Operating a multi-platform gateway A gateway typically runs several adapters at once (Telegram + Discord + Slack, etc.). The sections below cover day-2 operations that span all platforms. ### `/platform` command Once the gateway is running, use the `/platform` slash command from any connected CLI session or chat to inspect and steer individual adapters without restarting the whole gateway: ``` /platform list # show all adapters and their state /platform pause <name> # stop dispatching new messages to one adapter /platform resume <name> # re-enable a paused adapter ``` `/platform list` shows whether each adapter is `running`, `paused` (manually), or `paused-by-breaker` (see below). Pausing keeps the adapter loaded and its background loops alive — incoming messages are dropped on the floor, but the connection itself stays open so resume is instant. See also the broader status summary command [`/platforms`](../../reference/slash-commands.md#info). ### Automatic circuit breaker Each adapter is wrapped in a circuit breaker. Repeated retryable failures (network blips, rate-limit replies, 5xx upstream responses, websocket disconnects) cause the breaker to trip — the adapter is auto-paused, an operator notification is sent to the home channel of another live platform when one is configured, and a structured log line is emitted. The breaker does **not** auto-resume — it stays open until you run `/platform resume <name>` manually. This is intentional: if a platform is in a sustained outage, you don't want the gateway thrashing reconnects. ### Where to look when a platform is paused When an adapter is paused, check: 1. **Gateway log** (`~/.claway/logs/gateway.log` or the systemd / launchd unit log). Search for the platform name and `circuit breaker`, `paused`, or `disabled`. The trip event includes the failure count and the last error. 2. **`/platform list`** output — shows the current state and last reason. 3. **The provider's status page** (Telegram bot API status, Discord status, etc.). The breaker tripped because the platform was unhealthy; don't try to resume until it's back. Once upstream is healthy, `/platform resume <name>` clears the breaker and re-arms the adapter. ### Restart notifications When the gateway restarts (or is shut down with in-flight sessions), it can send a one-shot "the agent is back" / "the agent was interrupted" message to each platform's home channel. This is controlled per-platform by the `gateway_restart_notification` flag in `gateway-config.yaml`, which defaults to `true`: ```yaml gateway: platforms: telegram: home_chat_id: "123456789" gateway_restart_notification: false # opt out for this platform discord: home_chat_id: "987654321" # gateway_restart_notification omitted → defaults to true ``` Disable it on noisy or low-priority platforms while leaving it on for your primary chat. The notification is sent once per restart, regardless of how many sessions were in flight. ### Typing indicators While the agent is processing a message, the gateway shows a live typing status on platforms that support it — a "typing…" bubble on Telegram/Discord/Signal, or the "is thinking…" assistant status on Slack. This is controlled per-platform by the `typing_indicator` flag in `gateway-config.yaml`, which defaults to `true`: ```yaml gateway: platforms: slack: typing_indicator: false # don't show "is thinking…" on Slack telegram: # typing_indicator omitted → defaults to true ``` Set `typing_indicator: false` on any platform where the indicator is unwanted. Some users find Slack's "is thinking…" status noisy (it also briefly disables the compose box while shown, since it uses Slack's Assistant API). Disabling it only suppresses the indicator — message delivery and everything else is unchanged. The flag is generic, so the same key works for every platform. ### Session resume across gateway restarts When the gateway shuts down with an in-flight tool call or generation, the affected sessions are flagged as `restart_interrupted`. On the next startup, the gateway schedules an auto-resume for each one — the user gets a short heads-up in the chat ("Send any message after restart and I'll try to resume where you left off.") and the session picks up from the last committed turn when they reply. This behaviour is on by default and is logged at gateway start: ``` Scheduled auto-resume for N restart-interrupted session(s) ``` No configuration is required. If you don't want the heads-up, set `gateway_restart_notification: false` on the platform. ### Mobile-friendly progress defaults Telegram is usually a mobile inbox, so the defaults are tuned for that surface: - **`tool_progress`** defaults to **`off`** — no per-tool breadcrumb stream filling up the chat. - **`busy_ack_detail`** defaults to **`off`** — busy-state acknowledgments and long-running heartbeats stay terse (no `iteration 21/60` debug detail). - **`interim_assistant_messages`** stays **on** — real mid-turn assistant commentary (the model literally telling you what it's about to do) is signal, not noise. - **`long_running_notifications`** stays **on** — a single edit-in-place "⏳ Working — N min" bubble updates every few minutes so you have a heartbeat instead of staring at `typing…` for half an hour. Opt out of either of the kept-on defaults or opt back into verbose progress per platform: ```yaml display: platforms: telegram: # Re-enable the tool-progress stream tool_progress: new # Show "iteration N/M, running: tool" in heartbeats and busy acks busy_ack_detail: true # Or quiet them entirely interim_assistant_messages: false long_running_notifications: false ``` ### Progress bubble cleanup (opt-in) Tool-progress messages, the "still working…" heartbeat, and status-callback bubbles can also be auto-deleted after the final response lands. Enable per-platform via `display.platforms.<platform>.cleanup_progress`: ```yaml display: platforms: telegram: cleanup_progress: true discord: cleanup_progress: true ``` Defaults to `false`. Only platforms whose adapter implements `delete_message` honor the setting (currently Telegram and Discord). Failed runs **skip** cleanup so the bubbles remain as breadcrumbs. ## Next Steps - [Telegram Setup](telegram.md) - [Discord Setup](discord.md) - [Slack Setup](slack.md) - [Google Chat Setup](google_chat.md) - [WhatsApp Setup](whatsapp.md) - [WhatsApp Business Cloud API Setup](whatsapp-cloud.md) - [Signal Setup](signal.md) - [SMS Setup (Twilio)](sms.md) - [Email Setup](email.md) - [Home Assistant Integration](homeassistant.md) - [Mattermost Setup](mattermost.md) - [Matrix Setup](matrix.md) - [DingTalk Setup](dingtalk.md) - [Feishu/Lark Setup](feishu.md) - [WeCom Setup](wecom.md) - [WeCom Callback Setup](wecom-callback.md) - [Weixin Setup (WeChat)](weixin.md) - [BlueBubbles Setup (iMessage)](bluebubbles.md) - [QQBot Setup](qqbot.md) - [Yuanbao Setup](yuanbao.md) - [Microsoft Teams Setup](teams.md) - [Teams Meetings Pipeline](teams-meetings.md) - [Open WebUI + API Server](open-webui.md) - [Raft Setup](raft.md) - [IRC Setup](irc.md) - [Webhooks](webhooks.md) --- <!-- source: website/docs/user-guide/messaging/whatsapp.md --> # WhatsApp # WhatsApp Setup Claway connects to WhatsApp through a built-in bridge based on **Baileys**. This works by emulating a WhatsApp Web session — **not** through the official WhatsApp Business API. No Meta developer account or Business verification is required. > Run `claway gateway setup` and pick **WhatsApp** for a guided walk-through. :::tip Two WhatsApp integrations This page is for the **Baileys bridge** — quick to set up, personal accounts, no public URL needed, ban risk. If you're running a real business bot and want stability, see the **[WhatsApp Business Cloud API guide](./whatsapp-cloud.md)** instead. It's the official Meta-supported path: no account ban risk, but requires a Meta Business account and a public webhook URL. The two adapters can also run in parallel against different phone numbers if you have a reason to. ::: :::warning Unofficial API — Ban Risk WhatsApp does **not** officially support third-party bots outside the Business API. Using a third-party bridge carries a small risk of account restrictions. To minimize risk: - **Use a dedicated phone number** for the bot (not your personal number) - **Don't send bulk/spam messages** — keep usage conversational - **Don't automate outbound messaging** to people who haven't messaged first ::: :::warning WhatsApp Web Protocol Updates WhatsApp periodically updates their Web protocol, which can temporarily break compatibility with third-party bridges. When this happens, Claway will update the bridge dependency. If the bot stops working after a WhatsApp update, pull the latest Claway version and re-pair. ::: ## Two Modes | Mode | How it works | Best for | |------|-------------|----------| | **Separate bot number** (recommended) | Dedicate a phone number to the bot. People message that number directly. | Clean UX, multiple users, lower ban risk | | **Personal self-chat** | Use your own WhatsApp. You message yourself to talk to the agent. | Quick setup, single user, testing | --- ## Prerequisites - **Node.js v18+** and **npm** — the WhatsApp bridge runs as a Node.js process - **A phone with WhatsApp** installed (for scanning the QR code) Unlike older browser-driven bridges, the current Baileys-based bridge does **not** require a local Chromium or Puppeteer dependency stack. --- ## Step 1: Run the Setup Wizard ```bash claway whatsapp ``` The wizard will: 1. Ask which mode you want (**bot** or **self-chat**) 2. Install bridge dependencies if needed 3. Display a **QR code** in your terminal 4. Wait for you to scan it **To scan the QR code:** 1. Open WhatsApp on your phone 2. Go to **Settings → Linked Devices** 3. Tap **Link a Device** 4. Point your camera at the terminal QR code Once paired, the wizard confirms the connection and exits. Your session is saved automatically. :::tip If the QR code looks garbled, make sure your terminal is at least 60 columns wide and supports Unicode. You can also try a different terminal emulator. ::: --- ## Step 2: Getting a Second Phone Number (Bot Mode) For bot mode, you need a phone number that isn't already registered with WhatsApp. Three options: | Option | Cost | Notes | |--------|------|-------| | **Google Voice** | Free | US only. Get a number at [voice.google.com](https://voice.google.com). Verify WhatsApp via SMS through the Google Voice app. | | **Prepaid SIM** | $5–15 one-time | Any carrier. Activate, verify WhatsApp, then the SIM can sit in a drawer. Number must stay active (make a call every 90 days). | | **VoIP services** | Free–$5/month | TextNow, TextFree, or similar. Some VoIP numbers are blocked by WhatsApp — try a few if the first doesn't work. | After getting the number: 1. Install WhatsApp on a phone (or use WhatsApp Business app with dual-SIM) 2. Register the new number with WhatsApp 3. Run `claway whatsapp` and scan the QR code from that WhatsApp account --- ## Step 3: Configure Claway Add the following to your `~/.claway/.env` file: ```bash # Required WHATSAPP_ENABLED=true WHATSAPP_MODE=bot # "bot" or "self-chat" # Access control — pick ONE of these options: WHATSAPP_ALLOWED_USERS=15551234567 # Comma-separated phone numbers (with country code, no +) # WHATSAPP_ALLOWED_USERS=* # OR use * to allow everyone # WHATSAPP_ALLOW_ALL_USERS=true # OR set this flag instead (same effect as *) ``` :::tip Allow-all shorthand Setting `WHATSAPP_ALLOWED_USERS=*` allows **all** senders (equivalent to `WHATSAPP_ALLOW_ALL_USERS=true`). This is consistent with [Signal group allowlists](/reference/environment-variables). To use the pairing flow instead, remove both variables and rely on the [DM pairing system](/user-guide/security#dm-pairing-system). ::: Optional behavior settings in `~/.claway/config.yaml`: ```yaml unauthorized_dm_behavior: pair whatsapp: unauthorized_dm_behavior: ignore ``` - `unauthorized_dm_behavior: pair` is the global default. Unknown DM senders get a pairing code. - `whatsapp.unauthorized_dm_behavior: ignore` makes WhatsApp stay silent for unauthorized DMs, which is usually the better choice for a private number. Then start the gateway: ```bash claway gateway # Foreground claway gateway install # Install as a user service sudo claway gateway install --system # Linux only: boot-time system service ``` The gateway starts the WhatsApp bridge automatically using the saved session. --- ## Session Persistence The Baileys bridge saves its session under `~/.claway/platforms/whatsapp/session`. This means: - **Sessions survive restarts** — you don't need to re-scan the QR code every time - The session data includes encryption keys and device credentials - **Do not share or commit this session directory** — it grants full access to the WhatsApp account --- ## Re-pairing If the session breaks (phone reset, WhatsApp update, manually unlinked), you'll see connection errors in the gateway logs. To fix it: ```bash claway whatsapp ``` This generates a fresh QR code. Scan it again and the session is re-established. The gateway handles **temporary** disconnections (network blips, phone going offline briefly) automatically with reconnection logic. --- ## Voice Messages Claway supports voice on WhatsApp: - **Incoming:** Voice messages (`.ogg` opus) are automatically transcribed using the configured STT provider: local `faster-whisper`, Groq Whisper (`GROQ_API_KEY`), or OpenAI Whisper (`VOICE_TOOLS_OPENAI_KEY`) - **Outgoing:** TTS responses are sent as MP3 audio file attachments - Agent responses are prefixed with "⚕ **Claway Agent**" by default. You can customize or disable this in `config.yaml`: ```yaml # ~/.claway/config.yaml whatsapp: reply_prefix: "" # Empty string disables the header # reply_prefix: "🤖 *My Bot*\n──────\n" # Custom prefix (supports \n for newlines) ``` --- ## Message Formatting & Delivery WhatsApp supports **streaming (progressive) responses** — the bot edits its message in real-time as the AI generates text, just like Discord and Telegram. Internally, WhatsApp is classified as a TIER_MEDIUM platform for delivery capabilities. ### Chunking Long responses are automatically split into multiple messages at **4,096 characters** per chunk (WhatsApp's practical display limit). You don't need to configure anything — the gateway handles splitting and sends chunks sequentially. ### WhatsApp-Compatible Markdown Standard Markdown in AI responses is automatically converted to WhatsApp's native formatting: | Markdown | WhatsApp | Renders as | |----------|----------|------------| | `**bold**` | `*bold*` | **bold** | | `~~strikethrough~~` | `~strikethrough~` | ~~strikethrough~~ | | `# Heading` | `*Heading*` | Bold text (no native headings) | | `[link text](url)` | `link text (url)` | Inline URL | Code blocks and inline code are preserved as-is since WhatsApp supports triple-backtick formatting natively. ### Tool Progress When the agent calls tools (web search, file operations, etc.), WhatsApp displays real-time progress indicators showing which tool is running. This is enabled by default — no configuration needed. ### Message Batching (Debounce) WhatsApp delivers each message individually, so a rapid burst (forwarded batches, paste-splits, multi-line text) would otherwise trigger a separate agent invocation per fragment — wasting tokens and producing several disjointed replies. The adapter buffers successive text messages from the same chat and dispatches them as one combined request after a short quiet period (default **5s**, extended to **10s** for very long fragments). Tune via `config.yaml`: ```yaml # ~/.claway/config.yaml gateway: platforms: whatsapp: extra: text_batch_delay_seconds: 5.0 # quiet period before flushing a batch text_batch_split_delay_seconds: 10.0 # extended delay near the split threshold ``` Set `text_batch_delay_seconds: 0` to dispatch each message immediately (disables batching). --- ## Troubleshooting | Problem | Solution | |---------|----------| | **QR code not scanning** | Ensure terminal is wide enough (60+ columns). Try a different terminal. Make sure you're scanning from the correct WhatsApp account (bot number, not personal). | | **QR code expires** | QR codes refresh every ~20 seconds. If it times out, restart `claway whatsapp`. | | **Session not persisting** | Check that `~/.claway/platforms/whatsapp/session` exists and is writable. If containerized, mount it as a persistent volume. | | **Logged out unexpectedly** | WhatsApp unlinks devices after long inactivity. Keep the phone on and connected to the network, then re-pair with `claway whatsapp` if needed. | | **Bridge crashes or reconnect loops** | Restart the gateway, update Claway, and re-pair if the session was invalidated by a WhatsApp protocol change. | | **Bot stops working after WhatsApp update** | Update Claway to get the latest bridge version, then re-pair. | | **macOS: "Node.js not installed" but node works in terminal** | launchd services don't inherit your shell PATH. Run `claway gateway install` to re-snapshot your current PATH into the plist, then `claway gateway start`. See the [Gateway Service docs](./index.md#macos-launchd) for details. | | **Messages not being received** | Verify `WHATSAPP_ALLOWED_USERS` includes the sender's number (with country code, no `+` or spaces), or set it to `*` to allow everyone. Set `WHATSAPP_DEBUG=true` in `.env` and restart the gateway to see raw message events in `bridge.log`. | | **Bot replies to strangers with a pairing code** | Set `whatsapp.unauthorized_dm_behavior: ignore` in `~/.claway/config.yaml` if you want unauthorized DMs to be silently ignored instead. | --- ## Security :::warning **Configure access control** before going live. Set `WHATSAPP_ALLOWED_USERS` with specific phone numbers (including country code, without the `+`), use `*` to allow everyone, or set `WHATSAPP_ALLOW_ALL_USERS=true`. Without any of these, the gateway **denies all incoming messages** as a safety measure. ::: By default, unauthorized DMs still receive a pairing code reply. If you want a private WhatsApp number to stay completely silent to strangers, set: ```yaml whatsapp: unauthorized_dm_behavior: ignore ``` - The `~/.claway/platforms/whatsapp/session` directory contains full session credentials — protect it like a password - Set file permissions: `chmod 700 ~/.claway/platforms/whatsapp/session` - Use a **dedicated phone number** for the bot to isolate risk from your personal account - If you suspect compromise, unlink the device from WhatsApp → Settings → Linked Devices - Phone numbers in logs are partially redacted, but review your log retention policy --- <!-- source: website/docs/user-guide/messaging/telegram.md --> # Telegram # Telegram Setup Claway Agent integrates with Telegram as a full-featured conversational bot. Once connected, you can chat with your agent from any device, send voice memos that get auto-transcribed, receive scheduled task results, and use the agent in group chats. The integration is built on [python-telegram-bot](https://python-telegram-bot.org/) and supports text, voice, images, and file attachments. ## Step 1: Create a Bot via BotFather Every Telegram bot requires an API token issued by [@BotFather](https://t.me/BotFather), Telegram's official bot management tool. 1. Open Telegram and search for **@BotFather**, or visit [t.me/BotFather](https://t.me/BotFather) 2. Send `/newbot` 3. Choose a **display name** (e.g., "Claway Agent") — this can be anything 4. Choose a **username** — this must be unique and end in `bot` (e.g., `my_claway_bot`) 5. BotFather replies with your **API token**. It looks like this: ``` 123456789:ABCdefGHIjklMNOpqrSTUvwxYZ ``` :::warning Keep your bot token secret. Anyone with this token can control your bot. If it leaks, revoke it immediately via `/revoke` in BotFather. ::: ## Step 2: Customize Your Bot (Optional) These BotFather commands improve the user experience. Message @BotFather and use: | Command | Purpose | |---------|---------| | `/setdescription` | The "What can this bot do?" text shown before a user starts chatting | | `/setabouttext` | Short text on the bot's profile page | | `/setuserpic` | Upload an avatar for your bot | | `/setcommands` | Define the command menu (the `/` button in chat) | | `/setprivacy` | Control whether the bot sees all group messages (see Step 3) | :::tip For `/setcommands`, a useful starting set: ``` help - Show help information new - Start a new conversation sethome - Set this chat as the home channel ``` ::: ### Online/Offline status indicator (Optional) Telegram bots have no real online/offline presence dot — that green dot is a *user-account* feature, not something the Bot API exposes for bots. The closest surface is the bot's **short description** (the line shown under its name in the bot's profile). Enable `status_indicator` and Claway sets that short description to **Online** when the gateway connects and **Offline** on a clean shutdown: ```yaml gateway: platforms: telegram: extra: status_indicator: true # Optional custom strings (defaults: "Online" / "Offline"): status_online: "🟢 Online" status_offline: "🔴 Offline" ``` Notes: - The short description is **global** to the bot (visible to all users), not per-chat. Users see it on the bot's profile page, not as a live badge inside an open chat. - Only a **clean** gateway shutdown (`/stop`, `disconnect`) writes "Offline". A hard crash leaves the last-known status — the inherent limitation of a profile-text indicator. - Off by default, since it mutates the bot's global profile. ### Command menu priority and cap (Optional) Claway registers its command menu automatically when the Telegram gateway starts. The menu is built from the central slash-command registry plus eligible plugin/skill commands, then capped so Telegram accepts the payload reliably. The default cap is 60 commands — enough to keep all built-in commands plus common skill commands visible. If you have local or plugin commands that should stay visible in Telegram's `/` picker, prioritize them in `~/.claway/config.yaml`: ```yaml platforms: telegram: extra: command_menu: max_commands: 60 priority_mode: prepend # prepend | append | replace priority: - my_plugin_command ``` `priority_mode` controls how your list combines with Claway's built-in priority list: - `prepend`: put your commands first, then Claway defaults - `append`: keep Claway defaults first, then your commands - `replace`: use only your list for priority ordering Telegram allows up to 100 BotCommands, but large command payloads can fail. Claway defaults to 60 for reliability and clamps configured values to `1..100`; use `/commands` for the full command list. ## Step 3: Privacy Mode (Critical for Groups) Telegram bots have a **privacy mode** that is **enabled by default**. This is the single most common source of confusion when using bots in groups. **With privacy mode ON**, your bot can only see: - Messages that start with a `/` command - Replies directly to the bot's own messages - Service messages (member joins/leaves, pinned messages, etc.) - Messages in channels where the bot is an admin **With privacy mode OFF**, the bot receives every message in the group. ### How to disable privacy mode 1. Message **@BotFather** 2. Send `/mybots` 3. Select your bot 4. Go to **Bot Settings → Group Privacy → Turn off** :::warning **You must remove and re-add the bot to any group** after changing the privacy setting. Telegram caches the privacy state when a bot joins a group, and it will not update until the bot is removed and re-added. ::: :::tip An alternative to disabling privacy mode: promote the bot to **group admin**. Admin bots always receive all messages regardless of the privacy setting, and this avoids needing to toggle the global privacy mode. ::: ### Observe group chatter without auto-replying For OpenClaw/Yuanbao-style group behavior, configure Telegram so the bot can **see** ordinary group messages but only **responds** when directly triggered: ```yaml telegram: allowed_chats: - "-1001234567890" group_allowed_chats: - "-1001234567890" require_mention: true observe_unmentioned_group_messages: true ``` With this mode enabled, unmentioned group messages from explicitly allowlisted chats/topics are appended to the shared chat/topic session transcript as observed context, but they do not dispatch the agent. `allowed_chats` gates where the bot responds; `group_allowed_chats` authorizes the shared group session used for observed context, so use the same chat IDs for this mode. A later `@botname` mention, reply to the bot, or configured mention pattern in that same allowlisted chat/topic can use that observed context. The triggered message is also tagged with `[nickname|user_id]` and gets a per-turn safety prompt so the model treats prior observed lines as context, not instructions addressed to the bot. Equivalent environment variable: ```bash TELEGRAM_ALLOWED_CHATS=-1001234567890 TELEGRAM_GROUP_ALLOWED_CHATS=-1001234567890 TELEGRAM_OBSERVE_UNMENTIONED_GROUP_MESSAGES=true ``` This requires Telegram to deliver ordinary group messages to the gateway, so disable BotFather privacy mode or promote the bot to group admin as described above. ## Step 4: Find Your User ID Claway Agent uses numeric Telegram user IDs to control access. Your user ID is **not** your username — it's a number like `123456789`. **Method 1 (recommended):** Message [@userinfobot](https://t.me/userinfobot) — it instantly replies with your user ID. **Method 2:** Message [@get_id_bot](https://t.me/get_id_bot) — another reliable option. Save this number; you'll need it for the next step. ## Step 5: Configure Claway ### Option A: Interactive Setup (Recommended) ```bash claway gateway setup ``` Select **Telegram** when prompted. The wizard asks for your bot token and allowed user IDs, then writes the configuration for you. ### Option B: Manual Configuration Add the following to `~/.claway/.env`: ```bash TELEGRAM_BOT_TOKEN=123456789:ABCdefGHIjklMNOpqrSTUvwxYZ TELEGRAM_ALLOWED_USERS=123456789 # Comma-separated for multiple users ``` ### Start the Gateway ```bash claway gateway ``` The bot should come online within seconds. Send it a message on Telegram to verify. ## Sending Generated Files from Docker-backed Terminals If your terminal backend is `docker`, keep in mind that Telegram attachments are sent by the **gateway process**, not from inside the container. That means the final `MEDIA:/...` path must be readable on the host where the gateway is running. Common pitfall: - the agent writes a file inside Docker to `/workspace/report.txt` - the model emits `MEDIA:/workspace/report.txt` - Telegram delivery fails because `/workspace/report.txt` only exists inside the container, not on the host Recommended pattern: ```yaml terminal: backend: docker docker_volumes: - "/home/user/.claway/cache/documents:/output" ``` Then: - write files inside Docker to `/output/...` - emit the **host-visible** path in `MEDIA:`, for example: `MEDIA:/home/user/.claway/cache/documents/report.txt` If you already have a `docker_volumes:` section, add the new mount to the same list. YAML duplicate keys silently override earlier ones. ### Supported `MEDIA:` file extensions The gateway extracts `MEDIA:/path/to/file` tags from agent replies and ships the referenced file as a platform-native attachment. Supported extensions across all gateway platforms: | Category | Extensions | |---|---| | Images | `png`, `jpg`, `jpeg`, `gif`, `webp`, `bmp`, `tiff`, `svg` | | Audio | `mp3`, `wav`, `ogg`, `m4a`, `opus`, `flac`, `aac` | | Video | `mp4`, `mov`, `webm`, `mkv`, `avi` | | **Documents** | `pdf`, `txt`, `md`, `csv`, `json`, `xml`, `html`, `yaml`, `yml`, `log` | | **Office** | `docx`, `xlsx`, `pptx`, `odt`, `ods`, `odp` | | **Archives** | `zip`, `rar`, `7z`, `tar`, `gz`, `bz2` | | **Books / packages** | `epub`, `apk`, `ipa` | Anything on this list delivered as a native attachment on platforms that support it (Telegram, Discord, Signal, Slack, WhatsApp, Feishu, Matrix, etc.); on platforms without native support it falls back to a link or plain-text indicator. The **bold** categories were added in the last few releases — if you were relying on the model saying `here is the file: /path/to/report.docx` instead, swap to `MEDIA:/path/to/report.docx` for native delivery. ## Webhook Mode By default, Claway connects to Telegram using **long polling** — the gateway makes outbound requests to Telegram's servers to fetch new updates. This works well for local and always-on deployments. For **cloud deployments** (Fly.io, Railway, Render, etc.), **webhook mode** is more cost-effective. These platforms can auto-wake suspended machines on inbound HTTP traffic, but not on outbound connections. Since polling is outbound, a polling bot can never sleep. Webhook mode flips the direction — Telegram pushes updates to your bot's HTTPS URL, enabling sleep-when-idle deployments. | | Polling (default) | Webhook | |---|---|---| | Direction | Gateway → Telegram (outbound) | Telegram → Gateway (inbound) | | Best for | Local, always-on servers | Cloud platforms with auto-wake | | Setup | No extra config | Set `TELEGRAM_WEBHOOK_URL` | | Idle cost | Machine must stay running | Machine can sleep between messages | ### Configuration Add the following to `~/.claway/.env`: ```bash TELEGRAM_WEBHOOK_URL=https://my-app.fly.dev/telegram TELEGRAM_WEBHOOK_SECRET="$(openssl rand -hex 32)" # required # TELEGRAM_WEBHOOK_PORT=8443 # optional, default 8443 ``` | Variable | Required | Description | |----------|----------|-------------| | `TELEGRAM_WEBHOOK_URL` | Yes | Public HTTPS URL where Telegram will send updates. The URL path is auto-extracted (e.g., `/telegram` from the example above). | | `TELEGRAM_WEBHOOK_SECRET` | **Yes** (when `TELEGRAM_WEBHOOK_URL` is set) | Secret token that Telegram echoes in every webhook request for verification. The gateway refuses to start without it — see GHSA-3vpc-7q5r-276h. Generate with `openssl rand -hex 32`. | | `TELEGRAM_WEBHOOK_PORT` | No | Local port the webhook server listens on (default: `8443`). | When `TELEGRAM_WEBHOOK_URL` is set, the gateway starts an HTTP webhook server instead of polling. When unset, polling mode is used — no behavior change from previous versions. ### Cloud deployment example (Fly.io) 1. Add the env vars to your Fly.io app secrets: ```bash fly secrets set TELEGRAM_WEBHOOK_URL=https://my-app.fly.dev/telegram fly secrets set TELEGRAM_WEBHOOK_SECRET=$(openssl rand -hex 32) ``` 2. Expose the webhook port in your `fly.toml`: ```toml [[services]] internal_port = 8443 protocol = "tcp" [[services.ports]] handlers = ["tls", "http"] port = 443 ``` 3. Deploy: ```bash fly deploy ``` The gateway log should show: `[telegram] Connected to Telegram (webhook mode)`. ## Proxy Support If Telegram's API is blocked or you need to route traffic through a proxy, set a Telegram-specific proxy URL. This takes priority over the generic `HTTPS_PROXY` / `HTTP_PROXY` env vars. **Option 1: config.yaml (recommended)** ```yaml telegram: proxy_url: "socks5://127.0.0.1:1080" ``` **Option 2: environment variable** ```bash TELEGRAM_PROXY=socks5://127.0.0.1:1080 ``` Supported schemes: `http://`, `https://`, `socks5://`. The proxy applies to both the main Telegram connection and the fallback IP transport. If no Telegram-specific proxy is set, the gateway falls back to `HTTPS_PROXY` / `HTTP_PROXY` / `ALL_PROXY` (or macOS system proxy auto-detection). ## Home Channel Use the `/sethome` command in any Telegram chat (DM or group) to designate it as the **home channel**. Scheduled tasks (cron jobs) deliver their results to this channel. You can also set it manually in `~/.claway/.env`: ```bash TELEGRAM_HOME_CHANNEL=-1001234567890 TELEGRAM_HOME_CHANNEL_NAME="My Notes" ``` :::tip Group chat IDs are negative numbers (e.g., `-1001234567890`). Your personal DM chat ID is the same as your user ID. ::: ### Cron deliveries in topic mode If you have topic mode enabled in your bot DM, cron messages delivered to the root chat land in the system-only lobby — replying there opens no session and you see the "main chat is reserved for system commands" notice. Create a dedicated forum topic (e.g. `Cron`) and set: ```bash TELEGRAM_CRON_THREAD_ID=<topic_thread_id> ``` `TELEGRAM_CRON_THREAD_ID` overrides `TELEGRAM_HOME_CHANNEL_THREAD_ID` for cron deliveries only. Replies in that topic continue the topic's existing session. ## Voice Messages ### Incoming Voice (Speech-to-Text) Voice messages you send on Telegram are automatically transcribed by Claway's configured STT provider and injected as text into the conversation. - `local` uses `faster-whisper` on the machine running Claway — no API key required - `groq` uses Groq Whisper and requires `GROQ_API_KEY` - `openai` uses OpenAI Whisper and requires `VOICE_TOOLS_OPENAI_KEY` #### Skipping STT: pass the raw audio file to the agent If you'd rather have the **agent itself** handle audio — for diarization, a custom transcription tool, or just archiving the recording — set `stt.enabled: false` in `~/.claway/config.yaml`: ```yaml stt: enabled: false ``` With STT disabled, the gateway still downloads the voice/audio attachment into Claway's audio cache, but **does not transcribe it**. The agent receives the message with a marker like: ``` [The user sent a voice message: /home/<user>/.claway/cache/audio/<hash>.ogg] ``` Your tools or skills can then read that path directly (e.g., hand it off to a local diarization pipeline, a richer transcription model, or upload it to long-term storage). The file extension reflects the original format Telegram delivered (`.ogg` for voice notes, `.mp3`/`.m4a`/etc. for audio attachments). This pairs naturally with the [local Bot API server](#large-files-20mb-via-local-bot-api-server) section below, which lifts Telegram's 20MB getFile ceiling to 2GB — useful when the recordings you want to process are longer than a couple of minutes. ### Outgoing Voice (Text-to-Speech) When the agent generates audio via TTS, it's delivered as native Telegram **voice bubbles** — the round, inline-playable kind. - **OpenAI and ElevenLabs** produce Opus natively — no extra setup needed - **Edge TTS** (the default free provider) outputs MP3 and requires **ffmpeg** to convert to Opus: ```bash # Ubuntu/Debian sudo apt install ffmpeg # macOS brew install ffmpeg ``` Without ffmpeg, Edge TTS audio is sent as a regular audio file (still playable, but uses the rectangular player instead of a voice bubble). Configure the TTS provider in your `config.yaml` under the `tts.provider` key. ## Large Files (>20MB) via Local Bot API Server Telegram's **public** Bot API caps `getFile` downloads at **20 MB**, so any voice note, audio file, video, or document larger than that is silently rejected by Claway with a "too large" reply. The documented way around this is to run a **local** [telegram-bot-api](https://github.com/tdlib/telegram-bot-api) daemon — the same server software Telegram uses, but running on your network. A local server raises the file ceiling to **2 GB** and Claway auto-lifts its own internal cap when it sees a custom `base_url` configured. This unlocks workflows like: - Sending long voice memos (45-minute meetings, podcasts) to the bot - Uploading large videos for vision-tool processing - Archiving raw audio for offline pipelines like diarization, alignment, or training data ### Step 1: Obtain Telegram API credentials The local server talks directly to Telegram's MTProto layer (not the public Bot API), so it needs **MTProto credentials**: 1. Visit [my.telegram.org/apps](https://my.telegram.org/apps) and sign in with your Telegram account. 2. Create a new application (any name and short description will do). 3. Copy the `api_id` and `api_hash` — both are required. ### Step 2: Run the telegram-bot-api server The community-maintained [`aiogram/telegram-bot-api`](https://hub.docker.com/r/aiogram/telegram-bot-api) Docker image is the easiest path. A minimal `docker-compose.yaml` (use `--local` mode to enable the higher limits): ```yaml services: tg-bot-api: image: aiogram/telegram-bot-api:latest container_name: tg-bot-api restart: unless-stopped ports: - "127.0.0.1:8081:8081" # bind to loopback only; see security note environment: TELEGRAM_API_ID: "12345" # your api_id from Step 1 TELEGRAM_API_HASH: "abcdef..." # your api_hash from Step 1 TELEGRAM_LOCAL: "1" # enable --local mode (raises 20MB → 2GB) volumes: - ./tg-bot-api-data:/var/lib/telegram-bot-api ``` Bring it up: ```bash docker compose up -d tg-bot-api docker logs --tail 20 tg-bot-api ``` :::warning Security The local Bot API server takes your bot token in the URL path (e.g. `/bot<TOKEN>/getMe`) with **no additional auth**. Anyone who can reach the port can fully control your bot — read every message it can see, send messages as it, etc. Bind the container to `127.0.0.1` and/or front it with a reverse proxy on a private network. **Never expose port 8081 to the public internet.** ::: ### Step 3: Log the bot out of the public API (one-time) A bot can only be active on **one** Bot API server at a time. If your bot was already running against `api.telegram.org` (which it almost certainly was), you must explicitly log it out there before the local server will accept it: ```bash curl "https://api.telegram.org/bot<YOUR_BOT_TOKEN>/logOut" # expected response: {"ok":true,"result":true} ``` This is a one-shot migration step — you don't repeat it on every restart. Telegram delivers any messages received after `logOut` through the new server instead. Verify the local server can talk to Telegram on the bot's behalf: ```bash curl "http://127.0.0.1:8081/bot<YOUR_BOT_TOKEN>/getMe" # expected response: {"ok":true,"result":{"id":...,"is_bot":true,...}} ``` ### Step 4: Point Claway at the local server Add the URLs under `platforms.telegram.extra` in `~/.claway/config.yaml`: ```yaml platforms: telegram: extra: base_url: "http://127.0.0.1:8081/bot" base_file_url: "http://127.0.0.1:8081/file/bot" local_mode: true # see Step 5 below — only set this if the bot's data # directory is readable by the Claway process ``` :::caution Use `platforms.telegram.extra`, not `telegram.extra` At the moment only the `platforms.<name>.extra` form is deep-merged into the platform config. Keys placed directly under a top-level `telegram.extra` block are silently dropped. ::: When `base_url` is set, Claway: - Builds the python-telegram-bot client against the local server - Auto-lifts its internal document/audio size cap from 20 MB → 2 GB - Reports the active limit in the "too large" error message (`Maximum: 2048 MB.`) so it's obvious which mode you're in Restart the gateway and look for a confirmation log line: ```bash claway gateway restart grep -E "Using custom Telegram base_url|Using Telegram local_mode" ~/.claway/logs/gateway.log | tail ``` ### Step 5: `local_mode` — file access on disk The local server has **two ways** to deliver files: 1. **Without `--local`** (the default): files are served over HTTP at `/file/bot<TOKEN>/<path>`, same as the public Bot API. The 20MB ceiling stays in effect. Useful as a network-fix only (e.g. when `api.telegram.org` is unreachable but you can self-host); not what you want for the size lift. 2. **With `--local`** (set via `TELEGRAM_LOCAL=1` above): files are written to the server's filesystem and the `getFile` response returns an **absolute path** instead of an HTTP URL. The 20MB ceiling is lifted. Claway must then read the bytes **from disk**, not over HTTP. To make the disk-read path work, set `local_mode: true` in the config above **and** make sure the Claway process can read the path the server returns. Two scenarios: - **Same machine** — telegram-bot-api and Claway run on the same host. Bind-mount the data volume to a directory that Claway can read (e.g., `/var/lib/telegram-bot-api`), and make sure the file ownership matches. The container drops privileges to its internal `telegram-bot-api` user (uid varies by image); the simplest fix is to add `user: "<UID>:<GID>"` to the compose service so files are owned by a uid Claway already runs as. - **Different machines** — the bot server runs on one host (e.g., a NAS, a separate VM) and Claway on another. The server's data directory must be shared with the Claway machine at the **same absolute path** the server reports (typically `/var/lib/telegram-bot-api`). NFS works well for this; CIFS/SMB with `uid=` mount remapping is friendlier if you don't want to deal with uid mismatches at the filesystem level. If `local_mode: true` is set but Claway can't `stat` the returned file path (permissions or wrong mount), python-telegram-bot silently falls back to an HTTP `getFile` against the local server — which in `--local` mode responds with `404 Not Found`. The symptom shows up in `gateway.log` as: ``` [Telegram] Failed to cache voice: Not Found telegram.error.InvalidToken: Not Found ``` If you see that, the cap-lift is working but the file-share isn't. Verify `ls -la /var/lib/telegram-bot-api/<TOKEN>/voice/` from the Claway host as the user the gateway runs as, and confirm a single file is `cat`-able without a permission error. ### Step 6: Test it Send the bot a voice note or audio file that's bigger than 20 MB. Tail the gateway log: ```bash tail -f ~/.claway/logs/gateway.log | grep -iE "telegram|cache" ``` You should see a `[Telegram] Cached user voice at /home/<user>/.claway/cache/audio/...` line and **no** "too large" rejection. Combined with `stt.enabled: false` (above), the path to the original audio file then lands in the agent's inbound message for downstream processing. ## Group Chat Usage Claway Agent works in Telegram group chats with a few considerations: - **Privacy mode** determines what messages the bot can see (see [Step 3](#step-3-privacy-mode-critical-for-groups)) - `TELEGRAM_ALLOWED_USERS` still applies — only authorized users can trigger the bot, even in groups - You can keep the bot from responding to ordinary group chatter with `telegram.require_mention: true` - With `telegram.require_mention: true`, group messages are accepted when they are: - replies to one of the bot's messages - `@botusername` mentions - `/command@botusername` (Telegram's bot-menu command form that includes the bot name) - matches for one of your configured regex wake words in `telegram.mention_patterns` - In groups with multiple Claway bots, `telegram.exclusive_bot_mentions` keeps routing deterministic. When a message explicitly mentions one or more Telegram bot usernames, only the mentioned bot profiles process it; other Claway bots ignore it before reply and wake-word fallbacks run. This is enabled by default. - Use `telegram.ignored_threads` to keep Claway silent in specific Telegram forum topics, even when the group would otherwise allow free responses or mention-triggered replies - If `telegram.require_mention` is left unset or false, Claway keeps the previous open-group behavior and responds to normal group messages it can see ### Multiple Claway bots in one group If you run several Claway profiles in the same Telegram group, create one Telegram bot token per profile and start one gateway per profile. Do not reuse the same bot token in multiple running gateways; Telegram will reject concurrent polling for the same token. Recommended group config: ```yaml telegram: require_mention: true exclusive_bot_mentions: true mention_patterns: [] ``` With this setup, a group message like `@research_bot @ops_bot summarize this` is processed by `research_bot` and `ops_bot` only. Other Claway bots in the group stay silent, even if the message is a reply to one of their earlier messages or would otherwise match a shared wake word. Set `exclusive_bot_mentions: false` only for legacy groups where explicit mentions should not override reply and wake-word triggers. To operate several profiles, run the gateway command once per profile. For example: ```bash # default profile claway gateway start claway gateway status claway gateway stop # named profiles claway -p research gateway start claway -p research gateway status claway -p research gateway stop ``` For a small fixed fleet, use a shell loop or script that calls `claway gateway <action>` for the default profile and `claway -p <profile> gateway <action>` for each named profile. This is more reliable than assuming a single process-level command controls every named profile on every service manager. ### Troubleshooting: works in DMs but not groups If the bot responds in a private chat but stays silent in a group, check these gates in order: 1. **Telegram delivery:** turn off BotFather privacy mode, promote the bot to admin, or mention the bot directly. Claway cannot respond to group messages that Telegram never delivers to the bot. 2. **Rejoin after changing privacy:** remove the bot from the group and add it again after changing BotFather privacy settings. Telegram may keep the old delivery behavior for existing memberships. 3. **Claway authorization:** make sure the sender is listed in `TELEGRAM_ALLOWED_USERS` or `TELEGRAM_GROUP_ALLOWED_USERS`, or allow the group chat with `TELEGRAM_GROUP_ALLOWED_CHATS`. 4. **Mention filters:** if `telegram.require_mention: true` is set, normal group chatter is ignored unless the message is a slash command, reply to the bot, `@botusername` mention, or configured `mention_patterns` match. 5. **Multi-bot routing:** if a group contains several bots, make sure each Claway profile uses a unique bot token and keep `exclusive_bot_mentions` enabled unless you intentionally want legacy shared-trigger behavior. Negative chat IDs are normal for Telegram groups and supergroups. If you use chat-scoped authorization, put those IDs in `TELEGRAM_GROUP_ALLOWED_CHATS`, not the sender-user allowlist. ### Example group trigger configuration Add this to `~/.claway/config.yaml`: ```yaml telegram: require_mention: true exclusive_bot_mentions: true mention_patterns: - "^\\s*chompy\\b" ignored_threads: - 31 - "42" ``` This example allows all the usual direct triggers plus messages that begin with `chompy`, even if they do not use an `@mention`. Messages in Telegram topics `31` and `42` are always ignored before the mention and free-response checks run. ### Notes on `mention_patterns` - Patterns use Python regular expressions - Matching is case-insensitive - Patterns are checked against both text messages and media captions - Invalid regex patterns are ignored with a warning in the gateway logs rather than crashing the bot - If you want a pattern to match only at the start of a message, anchor it with `^` ## Private Chat Topics (Bot API 9.4) Telegram Bot API 9.4 (February 2026) introduced **Private Chat Topics** — bots can create forum-style topic threads directly in 1-on-1 DM chats, no supergroup needed. This lets you run multiple isolated workspaces within your existing DM with Claway. ### Use case If you work on several long-running projects, topics keep their context separate: - **Topic "Website"** — work on your production web service - **Topic "Research"** — literature review and paper exploration - **Topic "General"** — miscellaneous tasks and quick questions Each topic gets its own conversation session, history, and context — completely isolated from the others. ### Configuration :::caution Prerequisites Before adding topics to your config, the user must **enable Topics mode** in the DM chat with the bot: 1. Open your private chat with the Claway bot in Telegram 2. Tap the bot's name at the top to open chat info 3. Enable **Topics** (the toggle to turn the chat into a forum) Without this, Claway will log `The chat is not a forum` on startup and skip topic creation. This is a Telegram client-side setting — the bot cannot enable it programmatically. ::: Add topics under `platforms.telegram.extra.dm_topics` in `~/.claway/config.yaml`: ```yaml platforms: telegram: extra: dm_topics: - chat_id: 123456789 # Your Telegram user ID topics: - name: General icon_color: 7322096 - name: Website icon_color: 9367192 - name: Research icon_color: 16766590 skill: arxiv # Auto-load a skill in this topic ``` **Fields:** | Field | Required | Description | |-------|----------|-------------| | `name` | Yes | Topic display name | | `icon_color` | No | Telegram icon color code (integer) | | `icon_custom_emoji_id` | No | Custom emoji ID for the topic icon | | `skill` | No | Skill to auto-load on new sessions in this topic | | `thread_id` | No | Auto-populated after topic creation — don't set manually | ### How it works 1. On gateway startup, Claway calls `createForumTopic` for each topic that doesn't have a `thread_id` yet 2. The `thread_id` is saved back to `config.yaml` automatically — subsequent restarts skip the API call 3. Each topic maps to an isolated session key: `agent:main:telegram:dm:{chat_id}:{thread_id}` 4. Messages in each topic have their own conversation history, memory flush, and context window ### Root DM handling By default, messages sent to the root DM (outside any topic) are processed normally. Set `ignore_root_dm: true` to turn the root DM into a lobby — normal messages are silently ignored for users who have DM topics configured, while system commands (`/start`, `/help`, `/status`, etc.) still work. ```yaml platforms: telegram: extra: ignore_root_dm: true dm_topics: - chat_id: 123456789 topics: - name: General ``` The check is **per-chat**: only users with at least one entry in `dm_topics` will have their root DM affected. Users without configured topics are unaffected. ### Skill binding Topics with a `skill` field automatically load that skill when a new session starts in the topic. This works exactly like typing `/skill-name` at the start of a conversation — the skill content is injected into the first message, and subsequent messages see it in the conversation history. For example, a topic with `skill: arxiv` will have the arxiv skill pre-loaded whenever its session resets (due to idle timeout, daily reset, or manual `/reset`). :::tip Topics created outside of the config (e.g., by manually calling the Telegram API) are discovered automatically when a `forum_topic_created` service message arrives. You can also add topics to the config while the gateway is running — they'll be picked up on the next cache miss. ::: ## Multi-session DM mode (`/topic`) A ChatGPT-style multi-session DM — one bot, many parallel conversations. Unlike the operator-curated `extra.dm_topics` above, this mode is **user-driven**: no config, no pre-declared topic names. The end user flips it on with `/topic`, then taps the Telegram **+** button to create as many topics as they want, each one a fully independent Claway session. ### `/topic` subcommands | Form | Context | Effect | |------|---------|--------| | `/topic` | Root DM, not yet enabled | Check BotFather capabilities, enable multi-session mode, create pinned System topic | | `/topic` | Root DM, already enabled | Show status: unlinked sessions available for restore | | `/topic` | Inside a topic | Show the current topic's session binding | | `/topic help` | Any | Inline usage | | `/topic off` | Root DM | Disable multi-session mode and clear all topic bindings for this chat | | `/topic <session-id>` | Inside a topic | Restore a previous Telegram session into the current topic | Only authorized users (allowlist via `TELEGRAM_ALLOWED_USERS` / platform auth config) can run `/topic`. An unauthorized sender gets a refusal instead of activation. ### DM Topics vs Multi-session DM mode | | `extra.dm_topics` (config-driven) | `/topic` (user-driven) | |---|---|---| | Who activates it | Operator, in `config.yaml` | End user, by sending `/topic` | | Topic list | Fixed set declared in config | User creates/deletes topics freely | | Topic names | Chosen by operator | Chosen by user; auto-renamed to match Claway session title | | Root DM behavior | Normal chat (lobby if `ignore_root_dm: true`) | Becomes a system lobby (non-command messages are rejected) | | Primary use case | Permanent workspaces with optional skill binding | Ad-hoc parallel sessions | | Persistence | `extra.dm_topics` in config | `telegram_dm_topic_mode` + `telegram_dm_topic_bindings` SQLite tables | Both features can coexist on the same bot — you'd run `/topic` from a user's DM, and `extra.dm_topics` continues to manage operator-declared topics for other chats. ### Prerequisites In **@BotFather**, open your bot → **Bot Settings → Threads Settings**: 1. Turn on **Threaded Mode** (enables `has_topics_enabled`) 2. Do **not** disable users creating topics (keeps `allows_users_to_create_topics` on) When the user first runs `/topic`, Claway calls `getMe` to verify both flags. If either is off, Claway sends a screenshot of the BotFather Threads Settings page and explains what to toggle — no activation happens until prerequisites are met. ### Activation flow From the root DM, send: ``` /topic ``` Claway will: 1. Check `getMe().has_topics_enabled` and `allows_users_to_create_topics` 2. If both are true, enable multi-session topic mode for this DM 3. Create and pin a **System** topic for status/commands (best-effort) 4. Reply with a list of previous unlinked Telegram sessions the user can restore After activation, the **root DM is a lobby**: normal prompts are rejected with guidance pointing at **All Messages**. System commands (`/status`, `/sessions`, `/usage`, `/help`, etc.) still work in the root. ### Creating a new topic (end-user flow) 1. Open the bot DM in Telegram 2. Tap **All Messages** at the top of the bot interface, then send any message 3. Telegram creates a new topic for that message 4. Claway responds inside that topic — the topic is now a standalone session Every topic gets its own conversation history, model state, tool execution, and session ID. The isolation key is `agent:main:telegram:dm:{chat_id}:{thread_id}` — identical to the config-driven DM topics isolation. ### Auto-renamed topics When Claway generates a session title for a topic (via the auto-title pipeline, after the first exchange), the Telegram topic itself is renamed to match — e.g. "New Topic" becomes "Database migration plan". The rename is best-effort: failures are logged but don't break the session. To disable this and keep your manually-chosen topic names untouched, set: ```yaml gateway: platforms: telegram: extra: disable_topic_auto_rename: true ``` When this flag is on, Claway still generates an internal session title (used by `claway sessions`, the TUI, etc.) but never edits the Telegram topic name. Useful when you organise topics by hand under BotFather Threaded Mode and don't want every first reply to overwrite the title. ### `/new` inside a topic Resets the current topic's session (new session ID, fresh history) without touching other topics. Claway replies with a reminder that for parallel work, creating another topic (via **All Messages**) is usually what you want. ### Restoring a previous session Inside a topic, send: ``` /topic <session-id> ``` This binds the current topic to an existing Claway session instead of starting fresh. Useful for continuing a conversation that started before topic mode was enabled. Restrictions: - The target session must belong to the same Telegram user - The target session must not already be bound to another topic Claway confirms with the session title and replays the last assistant message for context. To discover session IDs, send `/topic` (no argument) in the root DM — Claway lists the user's unlinked Telegram sessions. ### `/topic` inside a topic (no argument) Shows the current topic's binding: session title, session ID, and hints for `/new` vs creating another topic. ### Under the hood - Activation persists to `telegram_dm_topic_mode(chat_id, user_id, enabled, ...)` in `state.db` - Each topic binding persists to `telegram_dm_topic_bindings(chat_id, thread_id, session_id, ...)` with `ON DELETE CASCADE` on `session_id` — pruning a session automatically clears its topic binding - The topic-mode SQLite migration is **opt-in**: it runs on the first `/topic` call, never on gateway startup. Until a user runs `/topic` in this profile, `state.db` is unchanged - Each inbound DM message looks up its `(chat_id, thread_id)` binding. If present, the lookup routes the message to the bound session via `SessionStore.switch_session()` so the session-key-to-session-id mapping stays consistent on disk - `/new` inside a topic rewrites the binding row to point at the new session ID, so the next message stays on the fresh session - Topics declared in `extra.dm_topics` are **never auto-renamed** — the operator-chosen name is preserved even when multi-session mode is enabled - Set `extra.disable_topic_auto_rename: true` to turn off auto-rename for **all** topics in the chat (ad-hoc topics created via Threaded Mode included) - The General (pinned top) topic in a forum-enabled DM is treated as the root lobby, regardless of whether Telegram delivers its messages with `message_thread_id=1` or with no thread_id - Root-lobby reminders are rate-limited to one message per 30 seconds per chat — a user who forgets topic mode is on and types ten prompts in the root won't get ten replies - BotFather setup screenshots are rate-limited to one send per 5 minutes per chat — repeated `/topic` attempts while Threads Settings are still disabled won't re-upload the same image - `/background <prompt>` started inside a topic delivers its result back to the same topic; background sessions don't trigger auto-rename of the owning topic - `/topic` itself is gated by the bot's user authorization check — unauthorized DMs get a refusal instead of activation ### Disabling multi-session mode Send `/topic off` in the root DM. Claway flips the row off, clears the chat's `(thread_id → session_id)` bindings, and the root DM reverts to a normal Claway chat. Existing topics in Telegram aren't deleted — they just stop being gated as independent sessions. Re-run `/topic` later to turn it back on. If you need to clean up by hand (e.g. a bulk reset across many chats), remove the rows directly: ```bash sqlite3 ~/.claway/state.db \ "UPDATE telegram_dm_topic_mode SET enabled = 0 WHERE chat_id = '<your_chat_id>'; \ DELETE FROM telegram_dm_topic_bindings WHERE chat_id = '<your_chat_id>';" ``` ### Downgrading Claway If you downgrade to a Claway version that predates `/topic`, the feature simply stops working — the `telegram_dm_topic_mode` and `telegram_dm_topic_bindings` tables remain in `state.db` but are ignored by older code. DMs revert to the native per-thread isolation (each `message_thread_id` still gets its own session via `build_session_key`), so your existing Telegram topics keep working as parallel sessions. The root DM is no longer a lobby — messages there go into the agent like they used to. Re-upgrading reactivates multi-session mode exactly where it was. ## Group Forum Topic Skill Binding Supergroups with **Topics mode** enabled (also called "forum topics") already get session isolation per topic — each `thread_id` maps to its own conversation. But you may want to **auto-load a skill** when messages arrive in a specific group topic, just like DM topic skill binding works. ### Use case A team supergroup with forum topics for different workstreams: - **Engineering** topic → auto-loads the `software-development` skill - **Research** topic → auto-loads the `arxiv` skill - **General** topic → no skill, general-purpose assistant ### Configuration Add topic bindings under `platforms.telegram.extra.group_topics` in `~/.claway/config.yaml`: ```yaml platforms: telegram: extra: group_topics: - chat_id: -1001234567890 # Supergroup ID topics: - name: Engineering thread_id: 5 skill: software-development - name: Research thread_id: 12 skill: arxiv - name: General thread_id: 1 # No skill — general purpose ``` **Fields:** | Field | Required | Description | |-------|----------|-------------| | `chat_id` | Yes | The supergroup's numeric ID (negative number starting with `-100`) | | `name` | No | Human-readable label for the topic (informational only) | | `thread_id` | Yes | Telegram forum topic ID — visible in `t.me/c/<group_id>/<thread_id>` links | | `skill` | No | Skill to auto-load on new sessions in this topic | ### How it works 1. When a message arrives in a mapped group topic, Claway looks up the `chat_id` and `thread_id` in `group_topics` config 2. If a matching entry has a `skill` field, that skill is auto-loaded for the session — identical to DM topic skill binding 3. Topics without a `skill` key get session isolation only (existing behavior, unchanged) 4. Unmapped `thread_id` values or `chat_id` values fall through silently — no error, no skill ### Differences from DM Topics | | DM Topics | Group Topics | |---|---|---| | Config key | `extra.dm_topics` | `extra.group_topics` | | Topic creation | Claway creates topics via API if `thread_id` is missing | Admin creates topics in Telegram UI | | `thread_id` | Auto-populated after creation | Must be set manually | | `icon_color` / `icon_custom_emoji_id` | Supported | Not applicable (admin controls appearance) | | Skill binding | ✓ | ✓ | | Session isolation | ✓ | ✓ (already built-in for forum topics) | :::tip To find a topic's `thread_id`, open the topic in Telegram Web or Desktop and look at the URL: `https://t.me/c/1234567890/5` — the last number (`5`) is the `thread_id`. The `chat_id` for supergroups is the group ID prefixed with `-100` (e.g., group `1234567890` becomes `-1001234567890`). ::: ## Recent Bot API Features - **Bot API 9.4 (Feb 2026):** Private Chat Topics — bots can create forum topics in 1-on-1 DM chats via `createForumTopic`. Claway uses this for two distinct features: operator-curated [Private Chat Topics](#private-chat-topics-bot-api-94) (config-driven, fixed topic list) and user-driven [Multi-session DM mode](#multi-session-dm-mode-topic) (activated by `/topic`, unlimited user-created topics). - **Privacy policy:** Telegram now requires bots to have a privacy policy. Set one via BotFather with `/setprivacy_policy`, or Telegram may auto-generate a placeholder. This is particularly important if your bot is public-facing. - **Bot API 9.5 (Mar 2026): Native streaming via `sendMessageDraft`.** Claway supports Telegram's native streaming-draft API as an opt-in transport for private chats. The default remains the legacy `editMessageText` path because draft previews can visibly collapse and re-render on some Telegram clients. ### Streaming transport (`gateway.streaming.transport`) When streaming is enabled (`gateway.streaming.enabled: true`), Claway picks one of four transports: | Value | Behaviour | |---|---| | `auto` (default) | Native draft streaming on supported chats (currently Telegram DMs); legacy edit-based path otherwise. Falls back gracefully if a draft frame fails. | | `draft` | Force native drafts. Logs a downgrade and falls back to edit if the chat doesn't support drafts (e.g. groups/topics). | | `edit` | Legacy progressive `editMessageText` polling for every chat type. | | `off` | Disable streaming entirely (final reply only, no progressive updates). | In `~/.claway/config.yaml`: ```yaml gateway: streaming: enabled: true transport: auto # auto | draft | edit | off ``` **What you'll see in DMs with `edit` (default)** — the gateway sends a normal preview message and progressively updates it via `editMessageText`, avoiding Telegram's draft-preview collapse/rollback effect. **What you'll see in DMs with `auto` or `draft`** — Telegram shows an animated draft preview that updates token-by-token. When the reply finishes, it's delivered as a regular message and the draft preview clears naturally on the client. Drafts have no message id, so the final answer is what stays in your chat history. **What about groups, supergroups, forum topics?** Telegram restricts `sendMessageDraft` to private chats (DMs). The gateway transparently falls back to the edit-based path for everything else — same UX as before. **What if a draft frame fails?** Any failure (transient network error, server-side rejection, older python-telegram-bot install) flips that response back to the edit-based path for the rest of the stream. The next response gets a fresh attempt. ## Rendering: Rich Messages, Tables and Link Previews **Rich Messages (Bot API 10.1).** Final replies that contain constructs the legacy MarkdownV2 path degrades — tables, task lists, collapsible `<details>`, and block math — are sent with Telegram's native [`sendRichMessage`](https://core.telegram.org/bots/api#sendrichmessage) using the agent's **raw markdown**, so they render natively with no client-side flattening. During streaming, the final answer is delivered by **editing the existing preview in place** via `editMessageText`'s `rich_message` parameter — no second message, no delete, so there is no duplicate-delivery flicker at the end of a turn. In DMs the live streaming preview also uses `sendRichMessageDraft`, so the animated draft matches the final rich message. Ordinary replies (plain prose, bold/italic, simple lists) stay on the MarkdownV2 path for consistent font weight and spacing across clients. The rich path is skipped automatically when content exceeds the 32,768-character rich text limit, and any rejection from Telegram (unsupported endpoint on an older `python-telegram-bot`, parser error, oversized blocks/columns) **transparently falls back** to the MarkdownV2 path — your message is never lost. Transient/network errors are *not* silently re-sent (no duplicate final message). **MarkdownV2 fallback.** When the rich path is unavailable for a message, Claway converts markdown to MarkdownV2. Since MarkdownV2 has no native table syntax, pipe tables are normalized: - **Small tables** are flattened into **row-group bullets** — each row becomes a readable bulleted list under the column headings. Good for 2–4 columns and short cells. - **Larger or wider tables** fall back to a **fenced code block** with aligned columns so nothing collapses. Rich messages are **opt-in**. The default stays on the legacy MarkdownV2 path because current Telegram clients can make Bot API rich messages difficult to copy as plain text, which is especially painful for command snippets and mobile handoffs. To enable native rendering for tables/task lists/details/math: ```yaml gateway: platforms: telegram: extra: rich_messages: true rich_drafts: false ``` This setting is for client-rendering/copy compatibility; Claway already falls back automatically when Telegram rejects the rich API call. `rich_drafts` controls the experimental rich draft preview path during Telegram DM streaming and stays off by default because Telegram Desktop/macOS can visually overlay rich draft frames until the chat redraws. If you only want the legacy "always code-block" table behavior while keeping rich messages enabled, disable table normalization by setting `telegram.pretty_tables: false` in `config.yaml` (default: `true`). **Link previews.** Telegram auto-generates link previews for URLs in bot messages. If you'd rather suppress those (long `/tools` output, agent reply that mentions ten links, etc.): ```yaml gateway: platforms: telegram: extra: disable_link_previews: true ``` When enabled, Claway attaches Telegram's `LinkPreviewOptions(is_disabled=True)` to every outgoing message and falls back to the legacy `disable_web_page_preview` parameter on older `python-telegram-bot` versions. ## Group Allowlisting Telegram groups and forum chats have two orthogonal gates you can configure: - **Sender user IDs** (`group_allow_from` / `TELEGRAM_GROUP_ALLOWED_USERS`) — sender-scoped allowlist that applies only to group/forum messages. Use this when you want specific users to be able to invoke the bot in groups without adding them to `TELEGRAM_ALLOWED_USERS` (which would also give them DM access). - **Chat IDs** (`group_allowed_chats` / `TELEGRAM_GROUP_ALLOWED_CHATS`) — chat-scoped allowlist. Any member of these groups/forums can interact with the bot. Useful for team/support bots where group membership itself is the access signal. ```yaml gateway: platforms: telegram: extra: # Global access (DMs + groups). Users here can always invoke the bot. allow_from: - "123456789" # Sender IDs allowed in groups/forums only. Does NOT grant DM access. group_allow_from: - "987654321" # Entire groups/forums — any member is authorized. group_allowed_chats: - "-1001234567890" ``` Equivalent env vars: ```bash TELEGRAM_ALLOWED_USERS="123456789" TELEGRAM_GROUP_ALLOWED_USERS="987654321" TELEGRAM_GROUP_ALLOWED_CHATS="-1001234567890" ``` Behavior: - `TELEGRAM_ALLOWED_USERS` covers all chat types (DMs, groups, forums). - `TELEGRAM_GROUP_ALLOWED_USERS` only authorizes the listed senders in groups/forums. They still can't DM the bot unless listed in `TELEGRAM_ALLOWED_USERS`. - A chat in `TELEGRAM_GROUP_ALLOWED_CHATS` authorizes every member of that chat, regardless of sender. - Use `*` in any of these to allow any sender/chat. - This layers on top of existing mention/pattern triggers and on top of `group_topics` + `ignored_threads`. ### Migration from the single allow-list Prior to this split, `TELEGRAM_GROUP_ALLOWED_USERS` was the only knob and users put **chat IDs** in it. For backward compatibility, chat-ID-shaped values (starting with `-`) in `TELEGRAM_GROUP_ALLOWED_USERS` are still honored as chat IDs and a deprecation warning is logged once. Migration: ```bash # Old (still works, but deprecated) TELEGRAM_GROUP_ALLOWED_USERS="-1001234567890" # New TELEGRAM_GROUP_ALLOWED_CHATS="-1001234567890" ``` ### Guest @mention bypass (`guest_mode`) In a typical setup, `group_allowed_chats` is a hard gate: messages from groups outside the list are silently dropped, even if a member explicitly @mentions the bot. That's the right default for support / team bots. For more casual setups — friend group chats where you want the bot **mostly silent** but **occasionally available on explicit ping** — enable `guest_mode`: ```yaml gateway: platforms: telegram: extra: group_allowed_chats: - "-1001234567890" # your main allowlisted group guest_mode: true # non-allowlisted groups: allow on @mention only ``` Env equivalent: ```bash TELEGRAM_GUEST_MODE=true ``` Default: `false`. With `guest_mode: true`, a message from a non-allowlisted group is processed **only** if it explicitly @mentions the bot. The mention is required every turn — there's no session stickiness for guest interactions, so the bot never auto-engages in a friend group thread it isn't pinged into. DMs and allowlisted groups behave exactly as before. ## Slash Command Access Control By default, every allowed user can run every slash command. To split your allowlist into **admins** (full slash command access) and **regular users** (only commands you explicitly enable), add `allow_admin_from` and `user_allowed_commands` to the platform's `extra` block: ```yaml gateway: platforms: telegram: extra: # Existing allowlists (unchanged) allow_from: - "123456789" # admin - "555555555" # regular user - "777777777" # regular user # NEW — admins get all slash commands (built-in + plugin) allow_admin_from: - "123456789" # NEW — non-admin allowed users can only run these slash commands. # /help and /whoami are always allowed so users can see their access. user_allowed_commands: - status - model - history # Optional: separate admin/command lists for groups group_allow_admin_from: - "123456789" group_user_allowed_commands: - status ``` **Behavior:** - A user listed in `allow_admin_from` for a scope (DM or group) can run **every** registered slash command — built-in commands AND plugin-registered ones — through the live registry. - A user in `allow_from` but **not** in `allow_admin_from` can only run commands listed in `user_allowed_commands`, plus the always-allowed floor: `/help` and `/whoami`. - Plain chat (non-slash messages) is unaffected. Non-admin users can still talk to the agent normally, they just can't trigger arbitrary commands. - **Backward compat:** if `allow_admin_from` is not set for a scope, slash command gating is disabled for that scope. Existing installs keep working with no changes. - DM admin status does not imply group admin status. Each scope has its own admin list. - If only `group_allow_admin_from` is set, DM scope stays in unrestricted (backward-compat) mode. Use `/whoami` to see the active scope, your tier (admin / user / unrestricted), and which slash commands you can run. ## Interactive Model Picker When you send `/model` with no arguments in a Telegram chat, Claway shows an interactive inline keyboard for switching models: 1. **Provider selection** — buttons showing each available provider with model counts (e.g., "OpenAI (15)", "✓ Anthropic (12)" for the current provider). 2. **Model selection** — paginated model list with **Prev**/**Next** navigation, a **Back** button to return to providers, and **Cancel**. The current model and provider are displayed at the top. All navigation happens by editing the same message in-place (no chat clutter). :::tip If you know the exact model name, type `/model <name>` directly to skip the picker. You can also type `/model <name> --global` to persist the change across sessions. ::: ## DNS-over-HTTPS Fallback IPs In some restricted networks, `api.telegram.org` may resolve to an IP that is unreachable. The Telegram adapter includes a **fallback IP** mechanism that transparently retries connections against alternative IPs while preserving the correct TLS hostname and SNI. ### How it works 1. If `TELEGRAM_FALLBACK_IPS` is set, those IPs are used directly. 2. Otherwise, the adapter automatically queries **Google DNS** and **Cloudflare DNS** via DNS-over-HTTPS (DoH) to discover alternative IPs for `api.telegram.org`. 3. IPs returned by DoH that differ from the system DNS result are used as fallbacks. 4. If DoH is also blocked, a hardcoded seed IP (`149.154.167.220`) is used as a last resort. 5. Once a fallback IP succeeds, it becomes "sticky" — subsequent requests use it directly without retrying the primary path first. ### Configuration ```bash # Explicit fallback IPs (comma-separated) TELEGRAM_FALLBACK_IPS=149.154.167.220,149.154.167.221 ``` Or in `~/.claway/config.yaml`: ```yaml platforms: telegram: extra: fallback_ips: - "149.154.167.220" ``` :::tip You usually don't need to configure this manually. The auto-discovery via DoH handles most restricted-network scenarios. The `TELEGRAM_FALLBACK_IPS` env var is only needed if DoH is also blocked on your network. ::: ## Proxy Support If your network requires an HTTP proxy to reach the internet (common in corporate environments), the Telegram adapter automatically reads standard proxy environment variables and routes all connections through the proxy. ### Supported variables The adapter checks these environment variables in order, using the first one that is set: 1. `HTTPS_PROXY` 2. `HTTP_PROXY` 3. `ALL_PROXY` 4. `https_proxy` / `http_proxy` / `all_proxy` (lowercase variants) ### Configuration Set the proxy in your environment before starting the gateway: ```bash export HTTPS_PROXY=http://proxy.example.com:8080 claway gateway ``` Or add it to `~/.claway/.env`: ```bash HTTPS_PROXY=http://proxy.example.com:8080 ``` The proxy applies to both the primary transport and all fallback IP transports. No additional Claway configuration is needed — if the environment variable is set, it's used automatically. :::note This covers the custom fallback transport layer that Claway uses for Telegram connections. The standard `httpx` client used elsewhere already respects proxy env vars natively. ::: ## Message Reactions The bot can add emoji reactions to messages as visual processing feedback: - 👀 when the bot starts processing your message - ✅ when the response is delivered successfully - ❌ if an error occurs during processing Reactions are **disabled by default**. Enable them in `config.yaml`: ```yaml telegram: reactions: true ``` Or via environment variable: ```bash TELEGRAM_REACTIONS=true ``` :::note Unlike Discord (where reactions are additive), Telegram's Bot API replaces all bot reactions in a single call. The transition from 👀 to ✅/❌ happens atomically — you won't see both at once. ::: :::tip If the bot doesn't have permission to add reactions in a group, the reaction calls fail silently and message processing continues normally. ::: ## Per-Channel Prompts Assign ephemeral system prompts to specific Telegram groups or forum topics. The prompt is injected at runtime on every turn — never persisted to transcript history — so changes take effect immediately. ```yaml telegram: channel_prompts: "-1001234567890": | You are a research assistant. Focus on academic sources, citations, and concise synthesis. "42": | This topic is for creative writing feedback. Be warm and constructive. ``` Keys are chat IDs (groups/supergroups) or forum topic IDs. For forum groups, topic-level prompts override the group-level prompt: - Message in topic `42` inside group `-1001234567890` → uses topic `42`'s prompt - Message in topic `99` (no explicit entry) → falls back to group `-1001234567890`'s prompt - Message in a group with no entry → no channel prompt applied Numeric YAML keys are automatically normalized to strings. ## Troubleshooting | Problem | Solution | |---------|----------| | Bot not responding at all | Verify `TELEGRAM_BOT_TOKEN` is correct. Check `claway gateway` logs for errors. | | Bot responds with "unauthorized" | Your user ID is not in `TELEGRAM_ALLOWED_USERS`. Double-check with @userinfobot. | | Bot ignores group messages | Privacy mode is likely on. Disable it (Step 3) or make the bot a group admin. **Remember to remove and re-add the bot after changing privacy.** | | Voice messages not transcribed | Verify STT is available: install `faster-whisper` for local transcription, or set `GROQ_API_KEY` / `VOICE_TOOLS_OPENAI_KEY` in `~/.claway/.env`. | | Voice replies are files, not bubbles | Install `ffmpeg` (needed for Edge TTS Opus conversion). | | Bot token revoked/invalid | Generate a new token via `/revoke` then `/newbot` or `/token` in BotFather. Update your `.env` file. | | Webhook not receiving updates | Verify `TELEGRAM_WEBHOOK_URL` is publicly reachable (test with `curl`). Ensure your platform/reverse proxy routes inbound HTTPS traffic from the URL's port to the local listen port configured by `TELEGRAM_WEBHOOK_PORT` (they do not need to be the same number). Ensure SSL/TLS is active — Telegram only sends to HTTPS URLs. Check firewall rules. | ## Exec Approval When the agent tries to run a potentially dangerous command, it asks you for approval in the chat: > ⚠️ This command is potentially dangerous (recursive delete). Reply "yes" to approve. Reply "yes"/"y" to approve or "no"/"n" to deny. ## Interactive Prompts (clarify) When the agent calls the `clarify` tool — to ask which approach you prefer, get post-task feedback, or check before a non-trivial decision — Telegram renders the question with **inline keyboard buttons**: > ❓ Which framework should I use for the dashboard? > > [1. Next.js] [2. Remix] [3. Astro] > [✏️ Other (type answer)] Tap a button to answer, or tap **Other** to type a free-form response (the next message you send becomes the answer). Open-ended `clarify` calls (no preset choices) skip the buttons and just capture your next message. Configure the response timeout via `agent.clarify_timeout` in `~/.claway/config.yaml` (default `600` seconds). If you don't respond within the timeout, the agent unblocks with a sentinel message and adapts rather than hanging. ## Push notification volume Telegram fires a push notification on every message the bot sends. For long agent turns that emit tool-progress bubbles, streaming updates, and status callbacks, this gets noisy fast. The Telegram adapter has two notification modes: | Mode | Behavior | |------|----------| | `important` (default) | Only **final responses**, **approval prompts**, and **slash-command confirmations** ring. Tool progress, streaming chunks, and status messages are delivered with `disable_notification=true`. | | `all` | Every outgoing message fires a push notification. Legacy behavior; opt in if you genuinely want to hear about every tool call. | Configure in `~/.claway/config.yaml`: ```yaml display: platforms: telegram: notifications: important # or "all" ``` Env override (handy for quick A/B testing): ```bash CLAWAY_TELEGRAM_NOTIFICATIONS=all ``` Unknown values log a warning and fall back to `important`. ## Status messages edited in place The Telegram adapter routes recurring agent status callbacks (e.g. "Compressing context…", "Calling tool…") through `send_or_update_status()`, which keeps a `{(chat_id, status_key) → message_id}` cache and **edits the existing bubble** on subsequent emits instead of appending a new one each time. Distinct `status_key` values get their own messages; distinct chats never collide. If the edit fails (e.g. the user deleted the message, or it's older than Telegram allows for edits), the cache entry is dropped and the next emit posts a fresh message and re-caches its ID. No config required — this is the default Telegram behavior. Other adapters that don't implement `send_or_update_status` fall through to plain `send()` unchanged. ## Pin incoming user message during agent turn When a user sends a message that triggers an agent turn, the Telegram adapter pins that incoming message for the duration of the turn and unpins it when the response is finished — a lightweight visual indicator that the bot is actively working on the message rather than ignoring it. The pin uses `disable_notification=true` to avoid extra pings. No config required. ## Security :::warning Always set `TELEGRAM_ALLOWED_USERS` to restrict who can interact with your bot. Without it, the gateway denies all users by default as a safety measure. ::: Never share your bot token publicly. If compromised, revoke it immediately via BotFather's `/revoke` command. For more details, see the [Security documentation](/user-guide/security). You can also use [DM pairing](/user-guide/messaging#dm-pairing-alternative-to-allowlists) for a more dynamic approach to user authorization. --- <!-- source: website/docs/user-guide/messaging/discord.md --> # Discord # Discord Setup Claway Agent integrates with Discord as a bot, letting you chat with your AI assistant through direct messages or server channels. The bot receives your messages, processes them through the Claway Agent pipeline (including tool use, memory, and reasoning), and responds in real time. It supports text, voice messages, file attachments, and slash commands. Before setup, here's the part most people want to know: how Claway behaves once it's in your server. ## How Claway Behaves | Context | Behavior | |---------|----------| | **DMs** | Claway responds to every message. No `@mention` needed. Each DM has its own session. | | **Server channels** | By default, Claway only responds when you `@mention` it. If you post in a channel without mentioning it, Claway ignores the message. | | **Free-response channels** | You can make specific channels mention-free with `DISCORD_FREE_RESPONSE_CHANNELS`, or disable mentions globally with `DISCORD_REQUIRE_MENTION=false`. Messages in these channels are answered inline — auto-threading is skipped so the channel stays a lightweight chat. | | **Threads** | Claway replies in the same thread. Mention rules still apply unless that thread or its parent channel is configured as free-response. Threads stay isolated from the parent channel for session history. | | **Shared channels with multiple users** | By default, Claway isolates session history per user inside the channel for safety and clarity. Two people talking in the same channel do not share one transcript unless you explicitly disable that. | | **Messages mentioning other users** | When `DISCORD_IGNORE_NO_MENTION` is `true` (the default), Claway stays silent if a message @mentions other users but does **not** mention the bot. This prevents the bot from jumping into conversations directed at other people. Set to `false` if you want the bot to respond to all messages regardless of who is mentioned. This only applies in server channels, not DMs. | :::tip If you want a normal bot-help channel where people can talk to Claway without tagging it every time, add that channel to `DISCORD_FREE_RESPONSE_CHANNELS`. ::: ### Discord Gateway Model Claway on Discord is not a webhook that replies statelessly. It runs through the full messaging gateway, which means each incoming message goes through: 1. authorization (`DISCORD_ALLOWED_USERS`) 2. mention / free-response checks 3. session lookup 4. session transcript loading 5. normal Claway agent execution, including tools, memory, and slash commands 6. response delivery back to Discord That matters because behavior in a busy server depends on both Discord routing and Claway session policy. ### Session Model in Discord By default: - each DM gets its own session - each server thread gets its own session namespace - each user in a shared channel gets their own session inside that channel So if Alice and Bob both talk to Claway in `#research`, Claway treats those as separate conversations by default even though they are using the same visible Discord channel. This is controlled by `config.yaml`: ```yaml group_sessions_per_user: true ``` Set it to `false` only if you explicitly want one shared conversation for the entire room: ```yaml group_sessions_per_user: false ``` Shared sessions can be useful for a collaborative room, but they also mean: - users share context growth and token costs - one person's long tool-heavy task can bloat everyone else's context - one person's in-flight run can interrupt another person's follow-up in the same room ### Interrupts and Concurrency Claway tracks running agents by session key. With the default `group_sessions_per_user: true`: - Alice interrupting her own in-flight request only affects Alice's session in that channel - Bob can keep talking in the same channel without inheriting Alice's history or interrupting Alice's run With `group_sessions_per_user: false`: - the whole room shares one running-agent slot for that channel/thread - follow-up messages from different people can interrupt or queue behind each other This guide walks you through the full setup process — from creating your bot on Discord's Developer Portal to sending your first message. ## Step 1: Create a Discord Application 1. Go to the [Discord Developer Portal](https://discord.com/developers/applications) and sign in with your Discord account. 2. Click **New Application** in the top-right corner. 3. Enter a name for your application (e.g., "Claway Agent") and accept the Developer Terms of Service. 4. Click **Create**. You'll land on the **General Information** page. Note the **Application ID** — you'll need it later to build the invite URL. ## Step 2: Create the Bot 1. In the left sidebar, click **Bot**. 2. Discord automatically creates a bot user for your application. You'll see the bot's username, which you can customize. 3. Under **Authorization Flow**: - Set **Public Bot** to **ON** — required to use the Discord-provided invite link (recommended). This allows the Installation tab to generate a default authorization URL. - Leave **Require OAuth2 Code Grant** set to **OFF**. :::tip You can set a custom avatar and banner for your bot on this page. This is what users will see in Discord. ::: :::info[Private Bot Alternative] If you prefer to keep your bot private (Public Bot = OFF), you **must** use the **Manual URL** method in Step 5 instead of the Installation tab. The Discord-provided link requires Public Bot to be enabled. ::: ## Step 3: Enable Privileged Gateway Intents This is the most critical step in the entire setup. Without the correct intents enabled, your bot will connect to Discord but **will not be able to read message content**. On the **Bot** page, scroll down to **Privileged Gateway Intents**. You'll see three toggles: | Intent | Purpose | Required? | |--------|---------|-----------| | **Presence Intent** | See user online/offline status | Optional | | **Server Members Intent** | Access the member list, resolve usernames | **Required** | | **Message Content Intent** | Read the text content of messages | **Required** | **Enable both Server Members Intent and Message Content Intent** by toggling them **ON**. - Without **Message Content Intent**, your bot receives message events but the message text is empty — the bot literally cannot see what you typed. - Without **Server Members Intent**, the bot cannot resolve usernames for the allowed users list and may fail to identify who is messaging it. :::warning[This is the #1 reason Discord bots don't work] If your bot is online but never responds to messages, the **Message Content Intent** is almost certainly disabled. Go back to the [Developer Portal](https://discord.com/developers/applications), select your application → Bot → Privileged Gateway Intents, and make sure **Message Content Intent** is toggled ON. Click **Save Changes**. ::: **Regarding server count:** - If your bot is in **fewer than 100 servers**, you can simply toggle intents on and off freely. - If your bot is in **100 or more servers**, Discord requires you to submit a verification application to use privileged intents. For personal use, this is not a concern. Click **Save Changes** at the bottom of the page. ## Step 4: Get the Bot Token The bot token is the credential Claway Agent uses to log in as your bot. Still on the **Bot** page: 1. Under the **Token** section, click **Reset Token**. 2. If you have two-factor authentication enabled on your Discord account, enter your 2FA code. 3. Discord will display your new token. **Copy it immediately.** :::warning[Token shown only once] The token is only displayed once. If you lose it, you'll need to reset it and generate a new one. Never share your token publicly or commit it to Git — anyone with this token has full control of your bot. ::: Store the token somewhere safe (a password manager, for example). You'll need it in Step 8. ## Step 5: Generate the Invite URL You need an OAuth2 URL to invite the bot to your server. There are two ways to do this: ### Option A: Using the Installation Tab (Recommended) :::note[Requires Public Bot] This method requires **Public Bot** to be set to **ON** in Step 2. If you set Public Bot to OFF, use the Manual URL method below instead. ::: 1. In the left sidebar, click **Installation**. 2. Under **Installation Contexts**, enable **Guild Install**. 3. For **Install Link**, select **Discord Provided Link**. 4. Under **Default Install Settings** for Guild Install: - **Scopes**: select `bot` and `applications.commands` - **Permissions**: select the permissions listed below. ### Option B: Manual URL You can construct the invite URL directly using this format: ``` https://discord.com/oauth2/authorize?client_id=YOUR_APP_ID&scope=bot+applications.commands&permissions=274878286912 ``` Replace `YOUR_APP_ID` with the Application ID from Step 1. ### Required Permissions These are the minimum permissions your bot needs: - **View Channels** — see the channels it has access to - **Send Messages** — respond to your messages - **Embed Links** — format rich responses - **Attach Files** — send images, audio, and file outputs - **Read Message History** — maintain conversation context ### Recommended Additional Permissions - **Send Messages in Threads** — respond in thread conversations - **Add Reactions** — react to messages for acknowledgment ### Permission Integers | Level | Permissions Integer | What's Included | |-------|-------------------|-----------------| | Minimal | `117760` | View Channels, Send Messages, Read Message History, Attach Files | | Recommended | `274878286912` | All of the above plus Embed Links, Send Messages in Threads, Add Reactions | ## Step 6: Invite to Your Server 1. Open the invite URL in your browser (from the Installation tab or the manual URL you constructed). 2. In the **Add to Server** dropdown, select your server. 3. Click **Continue**, then **Authorize**. 4. Complete the CAPTCHA if prompted. :::info You need the **Manage Server** permission on the Discord server to invite a bot. If you don't see your server in the dropdown, ask a server admin to use the invite link instead. ::: After authorizing, the bot will appear in your server's member list (it will show as offline until you start the Claway gateway). ## Step 7: Find Your Discord User ID Claway Agent uses your Discord User ID to control who can interact with the bot. To find it: 1. Open Discord (desktop or web app). 2. Go to **Settings** → **Advanced** → toggle **Developer Mode** to **ON**. 3. Close settings. 4. Right-click your own username (in a message, the member list, or your profile) → **Copy User ID**. Your User ID is a long number like `284102345871466496`. :::tip Developer Mode also lets you copy **Channel IDs** and **Server IDs** the same way — right-click the channel or server name and select Copy ID. You'll need a Channel ID if you want to set a home channel manually. ::: ## Step 8: Configure Claway Agent ### Option A: Interactive Setup (Recommended) Run the guided setup command: ```bash claway gateway setup ``` Select **Discord** when prompted, then paste your bot token and user ID when asked. ### Option B: Manual Configuration Add the following to your `~/.claway/.env` file: ```bash # Required DISCORD_BOT_TOKEN=your-bot-token DISCORD_ALLOWED_USERS=284102345871466496 # Multiple allowed users (comma-separated) # DISCORD_ALLOWED_USERS=284102345871466496,198765432109876543 ``` Then start the gateway: ```bash claway gateway ``` The bot should come online in Discord within a few seconds. Send it a message — either a DM or in a channel it can see — to test. :::tip You can run `claway gateway` in the background or as a systemd service for persistent operation. See the deployment docs for details. ::: ## Configuration Reference Discord behavior is controlled through two files: **`~/.claway/.env`** for credentials and env-level toggles, and **`~/.claway/config.yaml`** for structured settings. Environment variables always take precedence over config.yaml values when both are set. ### Environment Variables (`.env`) | Variable | Required | Default | Description | |----------|----------|---------|-------------| | `DISCORD_BOT_TOKEN` | **Yes** | — | Bot token from the [Discord Developer Portal](https://discord.com/developers/applications). | | `DISCORD_ALLOWED_USERS` | **Yes** | — | Comma-separated Discord user IDs allowed to interact with the bot. Without this **or** `DISCORD_ALLOWED_ROLES`, the gateway denies all users. | | `DISCORD_ALLOWED_ROLES` | No | — | Comma-separated Discord role IDs. Any member with one of these roles is authorized — OR semantics with `DISCORD_ALLOWED_USERS`. Auto-enables the **Server Members Intent** on connect. Useful when moderation teams churn: new mods get access as soon as the role is granted, no config push needed. | | `DISCORD_HOME_CHANNEL` | No | — | Channel ID where the bot sends proactive messages (cron output, reminders, notifications). | | `DISCORD_HOME_CHANNEL_NAME` | No | `"Home"` | Display name for the home channel in logs and status output. | | `DISCORD_COMMAND_SYNC_POLICY` | No | `"safe"` | Controls native slash-command startup sync. `"safe"` diffs existing global commands and only updates what changed, recreating commands when Discord metadata changes cannot be applied via patch. `"bulk"` preserves the old `tree.sync()` behavior. `"off"` skips startup sync entirely. | | `DISCORD_REQUIRE_MENTION` | No | `true` | When `true`, the bot only responds in server channels when `@mentioned`. Set to `false` to respond to all messages in every channel. | | `DISCORD_THREAD_REQUIRE_MENTION` | No | `false` | When `true`, the in-thread mention shortcut is disabled — threads are gated the same as channels, requiring `@mention` even after the bot has already participated. Use this when multiple bots share a thread and you want each to fire only on explicit `@mention`. | | `DISCORD_FREE_RESPONSE_CHANNELS` | No | — | Comma-separated channel IDs where the bot responds without requiring an `@mention`, even when `DISCORD_REQUIRE_MENTION` is `true`. | | `DISCORD_IGNORE_NO_MENTION` | No | `true` | When `true`, the bot stays silent if a message `@mentions` other users but does **not** mention the bot. Prevents the bot from jumping into conversations directed at other people. Only applies in server channels, not DMs. | | `DISCORD_AUTO_THREAD` | No | `true` | When `true`, automatically creates a new thread for every `@mention` in a text channel, so each conversation is isolated (similar to Slack behavior). Messages already inside threads or DMs are unaffected. | | `DISCORD_ALLOW_BOTS` | No | `"none"` | Controls how the bot handles messages from other Discord bots. `"none"` — ignore all other bots. `"mentions"` — only accept bot messages that `@mention` Claway. `"all"` — accept all bot messages. | | `DISCORD_REACTIONS` | No | `true` | When `true`, the bot adds emoji reactions to messages during processing (👀 when starting, ✅ on success, ❌ on error). Set to `false` to disable reactions entirely. | | `DISCORD_IGNORED_CHANNELS` | No | — | Comma-separated channel IDs where the bot **never** responds, even when `@mentioned`. Takes priority over all other channel settings. | | `DISCORD_ALLOWED_CHANNELS` | No | — | Comma-separated channel IDs. When set, the bot **only** responds in these channels (plus DMs if allowed). Overrides `config.yaml` `discord.allowed_channels`. Combine with `DISCORD_IGNORED_CHANNELS` to express allow/deny rules. | | `DISCORD_NO_THREAD_CHANNELS` | No | — | Comma-separated channel IDs where the bot responds directly in the channel instead of creating a thread. Only relevant when `DISCORD_AUTO_THREAD` is `true`. | | `DISCORD_HISTORY_BACKFILL` | No | `true` | When `true`, prepend recent channel scrollback (since the bot's last response) to the user message when the bot is mentioned. Recovers context the bot would otherwise miss with `require_mention`. Skipped in DMs and free-response channels. Set to `false` to disable. | | `DISCORD_HISTORY_BACKFILL_LIMIT` | No | `50` | Maximum number of messages to scan backwards when assembling the backfill block. In practice the scan usually stops earlier — at the bot's own last message in the channel. | | `DISCORD_REPLY_TO_MODE` | No | `"first"` | Controls reply-reference behavior: `"off"` — never reply to the original message, `"first"` — reply-reference on the first message chunk only (default), `"all"` — reply-reference on every chunk. | | `DISCORD_ALLOW_MENTION_EVERYONE` | No | `false` | When `false` (default), the bot cannot ping `@everyone` or `@here` even if its response contains those tokens. Set to `true` to opt back in. See [Mention Control](#mention-control) below. | | `DISCORD_ALLOW_MENTION_ROLES` | No | `false` | When `false` (default), the bot cannot ping `@role` mentions. Set to `true` to allow. | | `DISCORD_ALLOW_MENTION_USERS` | No | `true` | When `true` (default), the bot can ping individual users by ID. | | `DISCORD_ALLOW_MENTION_REPLIED_USER` | No | `true` | When `true` (default), replying to a message pings the original author. | | `DISCORD_PROXY` | No | — | Proxy URL for Discord connections (HTTP, WebSocket, REST). Overrides `HTTPS_PROXY`/`ALL_PROXY`. Supports `http://`, `https://`, and `socks5://` schemes. | | `DISCORD_ALLOW_ANY_ATTACHMENT` | No | `false` | When `true`, the bot accepts attachments of any file type (not just the built-in PDF/text/zip/office allowlist). Unknown types are cached to disk and surfaced to the agent as a local path with `application/octet-stream` MIME so it can inspect them with `terminal` / `read_file` / `ffprobe` / etc. | | `DISCORD_MAX_ATTACHMENT_BYTES` | No | `33554432` | Maximum bytes per attachment the gateway will download and cache. Default 32 MiB. Set to `0` for no cap (attachments are held in memory while being written, so unlimited carries a real memory cost). | | `CLAWAY_DISCORD_TEXT_BATCH_DELAY_SECONDS` | No | `0.6` | Grace window the adapter waits before flushing a queued text chunk. Useful for smoothing streamed output. | | `CLAWAY_DISCORD_TEXT_BATCH_SPLIT_DELAY_SECONDS` | No | `2.0` | Delay between split chunks when a single message exceeds Discord's length limit. | :::warning Bot-to-bot conversation is not supported `DISCORD_ALLOW_BOTS` exists to accept input from a specific trusted bot (e.g. a relay or webhook bot), not to let two Claway profiles talk to each other. The default, `"none"`, ignores all other bots and is the safe setting. Wiring multiple Claway profiles to reply to one another in a shared channel — by setting `"mentions"` or `"all"` across several profiles — is an unsupported topology. Discord auto-`@mentions` the replied-to author on every reply, so under `"mentions"` two bots will satisfy each other's mention gate indefinitely and ack-loop. There is no circuit breaker for this because the supported configuration is simply to leave `DISCORD_ALLOW_BOTS` at `"none"`. If you must accept a particular bot, scope the acceptance narrowly and never to another auto-replying agent. ::: ### Config File (`config.yaml`) The `discord` section in `~/.claway/config.yaml` mirrors the env vars above. Config.yaml settings are applied as defaults — if the equivalent env var is already set, the env var wins. ```yaml # Discord-specific settings discord: require_mention: true # Require @mention in server channels thread_require_mention: false # If true, require @mention in threads too (multi-bot threads) free_response_channels: "" # Comma-separated channel IDs (or YAML list) auto_thread: true # Auto-create threads on @mention reactions: true # Add emoji reactions during processing ignored_channels: [] # Channel IDs where bot never responds no_thread_channels: [] # Channel IDs where bot responds without threading history_backfill: true # Prepend recent channel scrollback on mention (default: true) history_backfill_limit: 50 # Max messages to scan backwards (default: 50) channel_prompts: {} # Per-channel ephemeral system prompts allow_mentions: # What the bot is allowed to ping (safe defaults) everyone: false # @everyone / @here pings (default: false) roles: false # @role pings (default: false) users: true # @user pings (default: true) replied_user: true # reply-reference pings the author (default: true) # Session isolation (applies to all gateway platforms, not just Discord) group_sessions_per_user: true # Isolate sessions per user in shared channels ``` #### `discord.require_mention` **Type:** boolean — **Default:** `true` When enabled, the bot only responds in server channels when directly `@mentioned`. DMs always get a response regardless of this setting. #### `discord.thread_require_mention` **Type:** boolean — **Default:** `false` By default, once the bot has participated in a thread (auto-created on `@mention` or replied in once), it keeps responding to every subsequent message in that thread without needing to be `@mentioned` again. That's the right default for one-on-one conversations. In **multi-bot threads** where users address one bot per turn, this default becomes a footgun — every other bot in the thread also fires on every message, burning credits and spamming the channel. Set `thread_require_mention: true` to disable the in-thread shortcut and gate threads the same way channels are gated. Explicit `@mentions` still work as before. ```yaml discord: require_mention: true thread_require_mention: true # multi-bot setup ``` #### `discord.free_response_channels` **Type:** string or list — **Default:** `""` Channel IDs where the bot responds to all messages without needing an `@mention`. Accepts either a comma-separated string or a YAML list: ```yaml # String format discord: free_response_channels: "1234567890,9876543210" # List format discord: free_response_channels: - 1234567890 - 9876543210 ``` If a thread's parent channel is in this list, the thread also becomes mention-free. Free-response channels also **skip auto-threading** — the bot replies inline rather than spinning off a new thread per message. This keeps the channel usable as a lightweight chat surface. If you want threading behavior, don't list the channel as free-response (use normal `@mention` flow instead). #### `discord.auto_thread` **Type:** boolean — **Default:** `true` When enabled, every `@mention` in a regular text channel automatically creates a new thread for the conversation. This keeps the main channel clean and gives each conversation its own isolated session history. Once a thread is created, subsequent messages in that thread don't require `@mention` — the bot knows it's already participating. Set [`thread_require_mention`](#discordthread_require_mention) to `true` to disable this in-thread shortcut for multi-bot setups. Messages sent in existing threads or DMs are unaffected by this setting. Channels listed in `discord.free_response_channels` or `discord.no_thread_channels` also bypass auto-threading and get inline replies instead. #### `discord.reactions` **Type:** boolean — **Default:** `true` Controls whether the bot adds emoji reactions to messages as visual feedback: - 👀 added when the bot starts processing your message - ✅ added when the response is delivered successfully - ❌ added if an error occurs during processing Disable this if you find the reactions distracting or if the bot's role doesn't have the **Add Reactions** permission. #### `discord.ignored_channels` **Type:** string or list — **Default:** `[]` Channel IDs where the bot **never** responds, even when directly `@mentioned`. This takes the highest priority — if a channel is in this list, the bot silently ignores all messages there, regardless of `require_mention`, `free_response_channels`, or any other setting. ```yaml # String format discord: ignored_channels: "1234567890,9876543210" # List format discord: ignored_channels: - 1234567890 - 9876543210 ``` If a thread's parent channel is in this list, messages in that thread are also ignored. #### `discord.no_thread_channels` **Type:** string or list — **Default:** `[]` Channel IDs where the bot responds directly in the channel instead of auto-creating a thread. This only has an effect when `auto_thread` is `true` (the default). In these channels, the bot responds inline like a normal message rather than spawning a new thread. ```yaml discord: no_thread_channels: - 1234567890 # Bot responds inline here ``` Useful for channels dedicated to bot interaction where threads would add unnecessary noise. #### `discord.channel_prompts` **Type:** mapping — **Default:** `{}` Per-channel ephemeral system prompts that are injected on every turn in the matching Discord channel or thread without being persisted to transcript history. ```yaml discord: channel_prompts: "1234567890": | This channel is for research tasks. Prefer deep comparisons, citations, and concise synthesis. "9876543210": | This forum is for therapy-style support. Be warm, grounded, and non-judgmental. ``` Behavior: - Exact thread/channel ID matches win. - If a message arrives inside a thread or forum post and that thread has no explicit entry, Claway falls back to the parent channel/forum ID. - Prompts are applied ephemerally at runtime, so changing them affects future turns immediately without rewriting past session history. #### `discord.history_backfill` **Type:** boolean — **Default:** `true` When enabled, the bot recovers missed channel messages on each `@mention`. With `require_mention: true`, the bot only processes messages that tag it directly — everything else in the channel is invisible to the session transcript. History backfill scans backwards through recent channel history when triggered, collecting messages between the bot's last response and the current mention, and includes them as context. Behavior by surface: - **Server channels** (with `require_mention: true`): backfill scans the channel since the bot's last response. Useful when other participants posted while the bot wasn't addressed. - **Threads**: backfill scans the thread only — Discord's `channel.history()` on a thread returns only that thread's messages, not the parent channel. This is the right scope because threads are usually self-contained conversations. - **DMs**: skipped. Every DM message triggers the bot, so the session transcript is already complete — there's no mention gap to fill. - **Free-response channels** and **bot's own auto-created threads**: skipped for the same reason — no mention gating means no gap. Per-user sessions (`group_sessions_per_user: true`, the default) also benefit: a user's session is missing the context posted by other channel participants and the user's own messages from before they tagged the bot. Backfill fills both gaps. ```yaml discord: history_backfill: true # default ``` To turn it off: ```yaml discord: history_backfill: false ``` > **Note:** Messages that arrive *while* the bot is processing (between a trigger and its response) are not captured. This is an accepted simplification — the user can re-send or tag again. #### `discord.history_backfill_limit` **Type:** integer — **Default:** `50` Maximum number of messages to scan backwards when recovering channel context. In practice the scan usually stops much earlier — at the bot's own last message in the channel, which is the natural boundary between turns. This limit is a safety cap for cold starts and long gaps where no prior bot message exists in recent history. ```yaml discord: history_backfill: true history_backfill_limit: 50 ``` #### `group_sessions_per_user` **Type:** boolean — **Default:** `true` This is a global gateway setting (not Discord-specific) that controls whether users in the same channel get isolated session histories. When `true`: Alice and Bob talking in `#research` each have their own separate conversation with Claway. When `false`: the entire channel shares one conversation transcript and one running-agent slot. ```yaml group_sessions_per_user: true ``` See the [Session Model](#session-model-in-discord) section above for the full implications of each mode. #### `display.tool_progress` **Type:** string — **Default:** `"all"` — **Values:** `off`, `new`, `all`, `verbose` Controls whether the bot sends progress messages in the chat while processing (e.g., "Reading file...", "Running terminal command..."). This is a global gateway setting that applies to all platforms. ```yaml display: tool_progress: "all" # off | new | all | verbose ``` - `off` — no progress messages - `new` — only show the first tool call per turn - `all` — show all tool calls (truncated to 40 characters in gateway messages) - `verbose` — show full tool call details (can produce long messages) #### `display.tool_progress_command` **Type:** boolean — **Default:** `false` When enabled, makes the `/verbose` slash command available in the gateway, letting you cycle through tool progress modes (`off → new → all → verbose → off`) without editing config.yaml. ```yaml display: tool_progress_command: true ``` ## Slash Command Access Control By default, every allowed user can run every slash command. To split your allowlist into **admins** (full slash command access) and **regular users** (only commands you explicitly enable), add `allow_admin_from` and `user_allowed_commands` to the Discord platform's `extra` block: ```yaml gateway: platforms: discord: extra: # Existing user allowlist (unchanged) allow_from: - "123456789012345678" # admin user ID - "999888777666555444" # regular user ID # NEW — admins get all slash commands (built-in + plugin) allow_admin_from: - "123456789012345678" # NEW — non-admin allowed users can only run these slash commands. # /help and /whoami are always allowed so users can see their access. user_allowed_commands: - status - model - history # Optional: separate admin / command lists for server channels group_allow_admin_from: - "123456789012345678" group_user_allowed_commands: - status ``` **Behavior:** - A user in `allow_admin_from` for a scope (DM or server channel) can run **every** registered slash command — built-in AND plugin-registered — through the live command registry. - A user not in `allow_admin_from` can only run commands listed in `user_allowed_commands`, plus the always-allowed floor: `/help` and `/whoami`. - Plain chat (non-slash messages) is unaffected. Non-admin users can still talk to the agent normally; they just can't trigger arbitrary commands. - **Backward compat:** if `allow_admin_from` is not set for a scope, slash command gating is disabled for that scope. Existing installs keep working with no changes. - DM admin status does not imply server-channel admin status. Each scope has its own admin list. Use `/whoami` to see the active scope, your tier (admin / user / unrestricted), and which slash commands you can run. ## Interactive Model Picker Send `/model` with no arguments in a Discord channel to open a dropdown-based model picker: 1. **Provider selection** — a Select dropdown showing available providers (up to 25). 2. **Model selection** — a second dropdown with models for the chosen provider (up to 25). The picker times out after 120 seconds. Only authorized users (those in `DISCORD_ALLOWED_USERS`) can interact with it. If you know the model name, type `/model <name>` directly. ## Native Slash Commands for Skills Claway automatically registers installed skills as **native Discord Application Commands**. This means skills appear in Discord's autocomplete `/` menu alongside built-in commands. - Each skill becomes a Discord slash command (e.g., `/code-review`, `/ascii-art`) - Skills accept an optional `args` string parameter - Discord has a limit of 100 application commands per bot — if you have more skills than available slots, extra skills are skipped with a warning in the logs - Skills are registered during bot startup alongside built-in commands like `/model`, `/reset`, and `/background` No extra configuration is needed — any skill installed via `claway skills install` is automatically registered as a Discord slash command on the next gateway restart. ### Disabling Slash Command Registration If you run multiple Claway gateways against the same Discord application (e.g. staging + production), only one of them should own the global slash-command registration — otherwise the last startup wins and the registrations flap. Turn slash registration off on the "follower" gateway: ```yaml gateway: platforms: discord: extra: slash_commands: false # default: true ``` Leaving this at `true` on the "primary" gateway keeps the normal behavior — global `/`-menu commands for built-ins and installed skills. ## Sending Media (inline `MEDIA:` tags) The Discord adapter supports native file uploads for every common media type via inline `MEDIA:/path/to/file` tags emitted in the agent's response — the adapter strips the tag and auto-uploads the file: | Type | How it's delivered | |---|---| | Images (PNG/JPG/WebP) | Native Discord image attachment with inline preview | | Animated GIFs | `send_animation` uploads as `animation.gif` so Discord plays it inline (not as a static thumbnail) | | Video (MP4/MOV) | `send_video` — native video player | | Audio / Voice | `send_voice` — native voice message when possible, file attachment otherwise | | Documents (PDF/ZIP/docx/etc.) | `send_document` — native attachment with download button | Discord's per-upload size limit depends on the server's boost tier (25 MB free, up to 500 MB). If Claway gets an HTTP 413, the adapter falls back to a link pointing at the local cache path rather than failing silently. ## Receiving Arbitrary File Types Any file type a user uploads is accepted. Authorization to message the agent is the gate — not the file extension. Every upload is downloaded, cached under `~/.claway/cache/documents/`, and surfaced to the agent as a `DOCUMENT`-typed message event so it can inspect the file with `terminal` (`ffprobe`, `unzip`, `file`, `strings`, etc.) or `read_file`. - Known types (PDF, docx/xlsx/pptx, zip, images/audio/video, etc.) keep their precise MIME. - Unknown types fall back to the upload's reported content type, or `application/octet-stream` when none is given. - Small UTF-8-decodable files (text, code, config, HTML, CSS, JSON, YAML, ...) have their contents auto-injected into the prompt up to 100 KiB. Binary files that can't be decoded are surfaced as a path-pointing context note only (auto-translated for Docker/Modal sandboxed terminals via `to_agent_visible_cache_path`), so they don't blow up the context window. The only inbound limit is the per-file size cap (default 32 MiB): ```yaml discord: # Optional — raise/disable the per-file size cap. Default is 32 MiB. # The whole file is held in memory while being cached, so unlimited # uploads carry a real memory cost. max_attachment_bytes: 33554432 # bytes; 0 = unlimited ``` Equivalent env var: `DISCORD_MAX_ATTACHMENT_BYTES=33554432` (or `0` for no cap). The legacy `discord.allow_any_attachment` flag is now a no-op — any file type is always accepted — and is kept only so existing configs don't error. :::warning Memory cost of unlimited Disabling the size cap (`max_attachment_bytes: 0`) means a user can drop a multi-GB file on the bot and the gateway will dutifully buffer it through memory while caching to disk. Only set this in trusted single-user installs. For shared bots, keep the default 32 MiB or raise it conservatively. ::: ## Interactive Prompts (clarify) When the agent calls the `clarify` tool — to ask which approach you prefer, get post-task feedback, or check before a non-trivial decision — Discord renders the question with **one button per choice**: > Which framework should I use for the dashboard? > > [1. Next.js] [2. Remix] [3. Astro] [Other (type answer)] Click a numbered button to answer, or click **Other** to type a free-form response (the next message you send in that channel becomes the answer). Open-ended `clarify` calls (no preset choices) skip the buttons and just capture your next message. The buttons disable themselves once a choice is made so duplicate clicks don't double-resolve the prompt. Configure the response timeout via `agent.clarify_timeout` in `~/.claway/config.yaml` (default `600` seconds). If you don't respond within the timeout, the agent unblocks with a sentinel message and adapts rather than hanging. ## Home Channel You can designate a "home channel" where the bot sends proactive messages (such as cron job output, reminders, and notifications). There are two ways to set it: ### Using the Slash Command Type `/sethome` in any Discord channel where the bot is present. That channel becomes the home channel. ### Manual Configuration Add these to your `~/.claway/.env`: ```bash DISCORD_HOME_CHANNEL=123456789012345678 DISCORD_HOME_CHANNEL_NAME="#bot-updates" ``` Replace the ID with the actual channel ID (right-click → Copy Channel ID with Developer Mode on). ## Voice Messages Claway Agent supports Discord voice messages: - **Incoming voice messages** are automatically transcribed using the configured STT provider: local `faster-whisper` (no key), Groq Whisper (`GROQ_API_KEY`), or OpenAI Whisper (`VOICE_TOOLS_OPENAI_KEY`). - **Text-to-speech**: Use `/voice tts` to have the bot send spoken audio responses alongside text replies. - **Discord voice channels**: Claway can also join a voice channel, listen to users speaking, and talk back in the channel. For the full setup and operational guide, see: - [Voice Mode](/user-guide/features/voice-mode) - [Use Voice Mode with Claway](/guides/use-voice-mode-with-claway) ### Voice Channel Audio Effects (ambient + verbal acks) When the bot is in a voice channel, you can give it a more conversational feel: a short verbal acknowledgement ("let me look into that") before it starts working, and a subtle ambient "thinking" bed that plays underneath while tools run — the speech ducks the ambient down and swells it back when finished, similar to Grok voice mode. discord.py plays only one audio stream per connection, so Claway installs a software mixer on the outgoing stream that sums an ambient loop, acknowledgements, and TTS replies into that single stream — they overlap instead of cutting each other off. This is **off by default**. Enable it in `config.yaml`: ```yaml discord: voice_fx: enabled: true # master switch ambient_enabled: true # idle "thinking" bed while tools run ambient_path: "" # custom loop file (any audio format); "" = built-in synthesised pad ambient_gain: 0.18 # idle bed loudness (0.0–1.0) duck_gain: 0.06 # ambient loudness while the bot is speaking speech_gain: 1.0 # TTS / acknowledgement loudness ack_enabled: true # speak a short phrase before the first tool call of a turn ack_phrases: # picked at random; set to [] to disable the spoken ack - "Let me look into that." - "One moment." - "Checking on that now." ``` Notes: - The acknowledgement fires at most once per turn, only when the bot is in a voice channel and the mixer is active. It uses your configured TTS provider. - `ambient_path` accepts any file `ffmpeg` can decode; it's looped seamlessly. Leave it empty to use the built-in synthesised pad (no asset needed). - All settings live in `config.yaml` (not `.env`) — they're behavioral, not secrets. - When `voice_fx.enabled` is `false`, voice playback uses the original one-shot path and nothing changes. ## Forum Channels Discord forum channels (type 15) don't accept direct messages — every post in a forum must be a thread. Claway auto-detects forum channels and creates a new thread post whenever it needs to send there, so text replies, TTS, images, voice messages, and file attachments all work without special handling from the agent. - **Thread name** is derived from the first line of the message (markdown heading prefix stripped, capped at 100 chars). When the message is attachment-only, the filename is used as the fallback thread name. - **Attachments** ride along on the starter message of the new thread — no separate upload step, no partial sends. - **One call, one thread**: each forum send creates a new thread. Successive sends to the same forum will therefore produce separate threads. - **Detection is three-layered**: the channel directory cache first, a process-local probe cache second, and a live `GET /channels/{id}` probe as a last resort (whose result is then memoized for the life of the process). Refreshing the directory (`/channels refresh` on platforms that expose it, or a gateway restart) populates the cache with any forum channels created after the bot started. ## Troubleshooting ### Bot is online but not responding to messages **Cause**: Message Content Intent is disabled. **Fix**: Go to [Developer Portal](https://discord.com/developers/applications) → your app → Bot → Privileged Gateway Intents → enable **Message Content Intent** → Save Changes. Restart the gateway. ### "Disallowed Intents" error on startup **Cause**: Your code requests intents that aren't enabled in the Developer Portal. **Fix**: Enable all three Privileged Gateway Intents (Presence, Server Members, Message Content) in the Bot settings, then restart. ### Bot can't see messages in a specific channel **Cause**: The bot's role doesn't have permission to view that channel. **Fix**: In Discord, go to the channel's settings → Permissions → add the bot's role with **View Channel** and **Read Message History** enabled. ### 403 Forbidden errors **Cause**: The bot is missing required permissions. **Fix**: Re-invite the bot with the correct permissions using the URL from Step 5, or manually adjust the bot's role permissions in Server Settings → Roles. ### Bot is offline **Cause**: The Claway gateway isn't running, or the token is incorrect. **Fix**: Check that `claway gateway` is running. Verify `DISCORD_BOT_TOKEN` in your `.env` file. If you recently reset the token, update it. ### "User not allowed" / Bot ignores you **Cause**: Your User ID isn't in `DISCORD_ALLOWED_USERS`. **Fix**: Add your User ID to `DISCORD_ALLOWED_USERS` in `~/.claway/.env` and restart the gateway. ### People in the same channel are sharing context unexpectedly **Cause**: `group_sessions_per_user` is disabled, or the platform cannot provide a user ID for the messages in that context. **Fix**: Set this in `~/.claway/config.yaml` and restart the gateway: ```yaml group_sessions_per_user: true ``` If you intentionally want a shared room conversation, leave it off — just expect shared transcript history and shared interrupt behavior. ## Security :::warning Always set `DISCORD_ALLOWED_USERS` (or `DISCORD_ALLOWED_ROLES`) to restrict who can interact with the bot. Without either, the gateway denies all users by default as a safety measure. Only authorize people you trust — authorized users have full access to the agent's capabilities, including tool use and system access. ::: ### Role-Based Access Control For servers where access is managed by roles instead of individual user lists (moderator teams, support staff, internal tooling), use `DISCORD_ALLOWED_ROLES` — a comma-separated list of role IDs. Any member with one of those roles is authorized. ```bash # ~/.claway/.env — works alongside or instead of DISCORD_ALLOWED_USERS DISCORD_ALLOWED_ROLES=987654321098765432,876543210987654321 ``` Semantics: - **OR with user allowlist.** A user is authorized if their ID is in `DISCORD_ALLOWED_USERS` **or** they have any role in `DISCORD_ALLOWED_ROLES`. - **Server Members Intent auto-enabled.** When `DISCORD_ALLOWED_ROLES` is set, the bot enables the Members intent on connect — required for Discord to send role information with member records. - **Role IDs, not names.** Grab them from Discord: **User Settings → Advanced → Developer Mode ON**, then right-click any role → **Copy Role ID**. - **DM fallback.** In DMs the role check scans mutual guilds; a user with an allowed role in any shared server is authorized in DMs too. This is the preferred pattern when the moderation team churns — new moderators get access the moment the role is granted, with no `.env` edit or gateway restart. ### Mention Control By default, Claway blocks the bot from pinging `@everyone`, `@here`, and role mentions, even if its reply contains those tokens. This prevents a poorly-worded prompt or echoed user content from spamming a whole server. Individual `@user` pings and reply-reference pings (the little "replying to…" chip) stay enabled so normal conversation still works. You can relax these defaults via either env vars or `config.yaml`: ```yaml # ~/.claway/config.yaml discord: allow_mentions: everyone: false # allow the bot to ping @everyone / @here roles: false # allow the bot to ping @role mentions users: true # allow the bot to ping individual @users replied_user: true # ping the author when replying to their message ``` ```bash # ~/.claway/.env — env vars win over config.yaml DISCORD_ALLOW_MENTION_EVERYONE=false DISCORD_ALLOW_MENTION_ROLES=false DISCORD_ALLOW_MENTION_USERS=true DISCORD_ALLOW_MENTION_REPLIED_USER=true ``` :::tip Leave `everyone` and `roles` at `false` unless you know exactly why you need them. It is very easy for an LLM to produce the string `@everyone` inside a normal-looking response; without this protection, that would notify every member of your server. ::: For more information on securing your Claway Agent deployment, see the [Security Guide](../security.md). --- <!-- source: website/docs/user-guide/messaging/slack.md --> # Slack # Slack Setup Connect Claway Agent to Slack as a bot using Socket Mode. Socket Mode uses WebSockets instead of public HTTP endpoints, so your Claway instance doesn't need to be publicly accessible — it works behind firewalls, on your laptop, or on a private server. :::warning Classic Slack Apps Deprecated Classic Slack apps (using RTM API) were **fully deprecated in March 2025**. Claway uses the modern Bolt SDK with Socket Mode. If you have an old classic app, you must create a new one following the steps below. ::: ## Overview | Component | Value | |-----------|-------| | **Library** | `slack-bolt` / `slack_sdk` for Python (Socket Mode) | | **Connection** | WebSocket — no public URL required | | **Auth tokens needed** | Bot Token (`xoxb-`) + App-Level Token (`xapp-`) | | **User identification** | Slack Member IDs (e.g., `U01ABC2DEF3`) | --- ## Step 1: Create a Slack App The fastest path is to paste a manifest Claway generates for you. It declares every built-in slash command (`/btw`, `/stop`, `/model`, …), every required OAuth scope, every event subscription, and enables Socket Mode — all at once. ### Option A: From a Claway-generated manifest (recommended) 1. Generate the manifest: ```bash claway slack manifest --write ``` This writes `~/.claway/slack-manifest.json` and prints paste-in instructions. 2. Go to [https://api.slack.com/apps](https://api.slack.com/apps) → **Create New App** → **From an app manifest** 3. Pick your workspace, paste the JSON contents, review, click **Next** → **Create** 4. Skip ahead to **Step 6: Install App to Workspace**. The manifest handled scopes, events, and slash commands for you. ### Option B: From scratch (manual) 1. Go to [https://api.slack.com/apps](https://api.slack.com/apps) 2. Click **Create New App** 3. Choose **From scratch** 4. Enter an app name (e.g., "Claway Agent") and select your workspace 5. Click **Create App** You'll land on the app's **Basic Information** page. Continue with Steps 2–6 below. --- ## Step 2: Configure Bot Token Scopes Navigate to **Features → OAuth & Permissions** in the sidebar. Scroll to **Scopes → Bot Token Scopes** and add the following: | Scope | Purpose | |-------|---------| | `chat:write` | Send messages as the bot | | `app_mentions:read` | Detect when @mentioned in channels | | `channels:history` | Read messages in public channels the bot is in | | `channels:read` | List and get info about public channels | | `groups:history` | Read messages in private channels the bot is invited to | | `im:history` | Read direct message history | | `im:read` | View basic DM info | | `im:write` | Open and manage DMs | | `mpim:history` | Read group direct message (multi-person DM) history | | `mpim:read` | View basic group DM info | | `users:read` | Look up user information | | `files:read` | Read and download attached files, including voice notes/audio | | `files:write` | Upload files (images, audio, documents) | :::caution Missing scopes = missing features Without `channels:history` and `groups:history`, the bot **will not receive messages in channels** — it will only work in DMs. Without `files:read`, Claway can chat but **cannot reliably read user-uploaded attachments**. These are the most commonly missed scopes. ::: **Optional scopes:** | Scope | Purpose | |-------|---------| | `groups:read` | List and get info about private channels | --- ## Step 3: Enable Socket Mode Socket Mode lets the bot connect via WebSocket instead of requiring a public URL. 1. In the sidebar, go to **Settings → Socket Mode** 2. Toggle **Enable Socket Mode** to ON 3. You'll be prompted to create an **App-Level Token**: - Name it something like `claway-socket` (the name doesn't matter) - Add the **`connections:write`** scope - Click **Generate** 4. **Copy the token** — it starts with `xapp-`. This is your `SLACK_APP_TOKEN` :::tip You can always find or regenerate app-level tokens under **Settings → Basic Information → App-Level Tokens**. ::: --- ## Step 4: Subscribe to Events This step is critical — it controls what messages the bot can see. 1. In the sidebar, go to **Features → Event Subscriptions** 2. Toggle **Enable Events** to ON 3. Expand **Subscribe to bot events** and add: | Event | Required? | Purpose | |-------|-----------|---------| | `message.im` | **Yes** | Bot receives direct messages | | `message.mpim` | **Yes** | Bot receives messages in **group DMs** (multi-person DMs) it's added to | | `message.channels` | **Yes** | Bot receives messages in **public** channels it's added to | | `message.groups` | **Recommended** | Bot receives messages in **private** channels it's invited to | | `app_mention` | **Yes** | Prevents Bolt SDK errors when bot is @mentioned | 4. Click **Save Changes** at the bottom of the page :::danger Missing event subscriptions is the #1 setup issue If the bot works in DMs but **not in channels**, you almost certainly forgot to add `message.channels` (for public channels) and/or `message.groups` (for private channels). Without these events, Slack simply never delivers channel messages to the bot. ::: --- ## Step 5: Enable the Messages Tab This step enables direct messages to the bot. Without it, users see **"Sending messages to this app has been turned off"** when trying to DM the bot. 1. In the sidebar, go to **Features → App Home** 2. Scroll to **Show Tabs** 3. Toggle **Messages Tab** to ON 4. Check **"Allow users to send Slash commands and messages from the messages tab"** :::danger Without this step, DMs are completely blocked Even with all the correct scopes and event subscriptions, Slack will not allow users to send direct messages to the bot unless the Messages Tab is enabled. This is a Slack platform requirement, not a Claway configuration issue. ::: --- ## Step 6: Install App to Workspace 1. In the sidebar, go to **Settings → Install App** 2. Click **Install to Workspace** 3. Review the permissions and click **Allow** 4. After authorization, you'll see a **Bot User OAuth Token** starting with `xoxb-` 5. **Copy this token** — this is your `SLACK_BOT_TOKEN` :::tip If you change scopes or event subscriptions later, you **must reinstall the app** for the changes to take effect. The Install App page will show a banner prompting you to do so. ::: --- ## Step 7: Find User IDs for the Allowlist Claway uses Slack **Member IDs** (not usernames or display names) for the allowlist. To find a Member ID: 1. In Slack, click on the user's name or avatar 2. Click **View full profile** 3. Click the **⋮** (more) button 4. Select **Copy member ID** Member IDs look like `U01ABC2DEF3`. You need your own Member ID at minimum. --- ## Step 8: Configure Claway Add the following to your `~/.claway/.env` file: ```bash # Required SLACK_BOT_TOKEN=xoxb-your-bot-token-here SLACK_APP_TOKEN=xapp-your-app-token-here SLACK_ALLOWED_USERS=U01ABC2DEF3 # Comma-separated Member IDs # Optional SLACK_HOME_CHANNEL=C01234567890 # Default channel for cron/scheduled messages SLACK_HOME_CHANNEL_NAME=general # Human-readable name for the home channel (optional) ``` Or run the interactive setup: ```bash claway gateway setup # Select Slack when prompted ``` Then start the gateway: ```bash claway gateway # Foreground claway gateway install # Install as a user service sudo claway gateway install --system # Linux only: boot-time system service ``` --- ## Step 9: Invite the Bot to Channels After starting the gateway, you need to **invite the bot** to any channel where you want it to respond: ``` /invite @Claway Agent ``` The bot will **not** automatically join channels. You must invite it to each channel individually. --- ## Slash Commands Every Claway command (`/btw`, `/stop`, `/new`, `/model`, `/help`, ...) is a native Slack slash command — exactly the way they work on Telegram and Discord. Type `/` in Slack and the autocomplete picker lists every Claway command with its description. Under the hood: Claway ships with a generated Slack app manifest (see Step 1, Option A) that declares every command in `COMMAND_REGISTRY` as a slash command. In Socket Mode, Slack routes the command event through the WebSocket regardless of the manifest's `url` field. ### Refreshing slash commands after updates When Claway adds new commands (e.g. after `claway update`), regenerate the manifest and update your Slack app: ```bash claway slack manifest --write ``` Then in Slack: 1. Open [https://api.slack.com/apps](https://api.slack.com/apps) → your Claway app 2. **Features → App Manifest → Edit** 3. Paste the new contents of `~/.claway/slack-manifest.json` 4. **Save**. Slack will prompt to reinstall the app if scopes or slash commands changed. ### Legacy `/claway <subcommand>` still works For backward compatibility with older manifests, you can still type `/claway btw run the tests` — Claway routes it the same way as `/btw run the tests`. Free-form questions also work: `/claway what's the weather?` is treated as a regular message. ### Using commands inside threads (the `!cmd` prefix) Slack itself blocks native slash commands inside thread replies — try `/queue` in a thread and Slack responds with *"/queue is not supported in threads. Sorry!"* There is no app-side setting that re-enables them; Slack never delivers them to Claway. As a workaround, Claway recognises a leading `!` as an alternate command prefix that works in threads (and anywhere else). Type `!queue`, `!stop`, `!model gpt-5.4`, etc. as a regular thread reply — Claway treats it identically to the slash form and replies in the same thread. Only the first token is checked against the known command list, so casual messages like `!nice work` pass through to the agent unchanged. Approval prompts (dangerous command / `execute_code` approval) normally render as interactive buttons. When buttons can't be delivered and Claway falls back to a text prompt, the prompt instructs you to reply with `!approve` / `!deny` — the form that works inside threads. ### Advanced: emit only the slash-commands array If you maintain your Slack manifest by hand and just want the slash command list: ```bash claway slack manifest --slashes-only > /tmp/slashes.json ``` Paste that array into the `features.slash_commands` key of your existing manifest. --- ## How the Bot Responds Understanding how Claway behaves in different contexts: | Context | Behavior | |---------|----------| | **DMs** | Bot responds to every message — no @mention needed | | **Channels** | Bot **only responds when @mentioned** (e.g., `@Claway Agent what time is it?`). In channels, Claway replies in a thread attached to that message. | | **Threads** | If you @mention Claway inside an existing thread, it replies in that same thread. Once the bot has an active session in a thread, **subsequent replies in that thread do not require @mention** — the bot follows the conversation naturally. | :::tip In channels, always @mention the bot to start a conversation. Once the bot is active in a thread, you can reply in that thread without mentioning it. Outside of threads, messages without @mention are ignored to prevent noise in busy channels. ::: --- ## Configuration Options Beyond the required environment variables from Step 8, you can customize Slack bot behavior through `~/.claway/config.yaml`. ### Thread & Reply Behavior ```yaml platforms: slack: # Controls how multi-part responses are threaded # "off" — never thread replies to the original message # "first" — first chunk threads to user's message (default) # "all" — all chunks thread to user's message reply_to_mode: "first" extra: # Whether to reply in a thread (default: true). # When false, channel messages get direct channel replies instead # of threads. Messages inside existing threads still reply in-thread. reply_in_thread: true # Also post thread replies to the main channel # (Slack's "Also send to channel" feature). # Only the first chunk of the first reply is broadcast. reply_broadcast: false # Render agent messages as Slack Block Kit blocks (default: false). # When true, the final agent message is sent with structured blocks — # section headers, dividers, true nested lists (via rich_text), and # native Block Kit tables — instead of flat mrkdwn text. A plain-text # fallback is always sent alongside for notifications/accessibility. # Tables exceeding Slack's limits (100 rows / 20 cols / 10k chars) # gracefully fall back to aligned monospace. rich_blocks: false # Continuable-cron delivery surface (default: "thread"). # "in_channel" delivers a continuable cron job FLAT into the channel # (no dedicated thread); pair with reply_in_thread: false (and # require_mention: false) so a plain reply continues the job. # See the cron guide → "Flat, in-channel continuation". cron_continuable_surface: thread ``` | Key | Default | Description | |-----|---------|-------------| | `platforms.slack.reply_to_mode` | `"first"` | Threading mode for multi-part messages: `"off"`, `"first"`, or `"all"` | | `platforms.slack.extra.reply_in_thread` | `true` | When `false`, channel messages get direct replies instead of threads. Messages inside existing threads still reply in-thread. | | `platforms.slack.extra.reply_broadcast` | `false` | When `true`, thread replies are also posted to the main channel. Only the first chunk is broadcast. | | `platforms.slack.extra.rich_blocks` | `false` | When `true`, agent messages are rendered as [Block Kit](https://docs.slack.dev/block-kit/) blocks (headers, dividers, true nested lists, and native tables). A plain-text fallback is always sent. Tables over Slack's limits fall back to aligned monospace. No app reinstall required — it's a send-side change only. | | `platforms.slack.extra.cron_continuable_surface` | `"thread"` | Delivery surface for [continuable cron jobs](../features/cron.md#flat-in-channel-continuation-slack). `"thread"` opens a dedicated thread per delivery (default); `"in_channel"` delivers flat into the channel timeline. Pair `in_channel` with `reply_in_thread: false` (and `require_mention: false`) so a plain channel reply continues the job. | ### Session Isolation ```yaml # Global setting — applies to Slack and all other platforms group_sessions_per_user: true ``` When `true` (the default), each user in a shared channel gets their own isolated conversation session. Two people talking to Claway in `#general` will have separate histories and contexts. Set to `false` if you want a collaborative mode where the entire channel shares one conversation session. Be aware this means users share context growth and token costs, and one user's `/reset` clears the session for everyone. ### Mention & Trigger Behavior ```yaml slack: # Require @mention in channels (this is the default behavior; # the Slack adapter enforces @mention gating in channels regardless, # but you can set this explicitly for consistency with other platforms) require_mention: true # Prevent thread auto-engagement: only reply to channel messages that # contain an explicit @mention. With this OFF (default), Slack can # "auto-engage" — remembering past mentions in a thread and following # up on bot-message replies, and resuming active sessions without a # fresh mention. With strict_mention ON, every new channel message # must @mention the bot before Claway will respond. strict_mention: false # Custom mention patterns that trigger the bot # (in addition to the default @mention detection) mention_patterns: - "hey claway" - "claway," # Text prepended to every outgoing message reply_prefix: "" ``` :::tip When to use `strict_mention` Set this to `true` in busy workspaces where Slack's default "the bot remembers this thread" behavior surprises users — for example, a long tech-support thread where the bot helped at the start and you'd rather it stay silent unless explicitly pinged again. DMs and active interactive sessions are unaffected. ::: :::info Slack supports both patterns: `@mention` required to start a conversation by default, but you can opt specific channels out via `SLACK_FREE_RESPONSE_CHANNELS` (comma-separated channel IDs) or `slack.free_response_channels` in `config.yaml`. Once the bot has an active session in a thread, subsequent thread replies do not require a mention. In DMs the bot always responds without needing a mention. ::: ### Channel allowlist (`allowed_channels`) Restrict the bot to a fixed set of Slack channels — useful when the bot is invited to many channels but should only respond in a few. When set, messages from channels NOT in this list are **silently ignored**, even if the bot is `@mentioned`. **DMs are exempt** from this filter, so authorized users can always reach the bot in a direct message. ```yaml slack: allowed_channels: - "C0123456789" # #ops - "C0987654321" # #incident-response ``` Or via env var (comma-separated): ```bash SLACK_ALLOWED_CHANNELS="C0123456789,C0987654321" ``` Behavior: - Empty / unset → no restriction (fully backward compatible). - Non-empty → channel ID must be on the list, or the message is dropped before any other gating (mention requirement, `free_response_channels`, etc.) runs. - Slack channel IDs start with `C` (public), `G` (private), or `D` (DM). Look them up via the Slack UI's "Open channel details" → "About" panel, or via the API. See also: [admin/user slash command split](../../reference/slash-commands.md#permissions-and-adminuser-split). ### Unauthorized User Handling ```yaml slack: # What happens when an unauthorized user (not in SLACK_ALLOWED_USERS) DMs the bot # "pair" — prompt them for a pairing code (default) # "ignore" — silently drop the message unauthorized_dm_behavior: "pair" ``` You can also set this globally for all platforms: ```yaml unauthorized_dm_behavior: "pair" ``` The platform-specific setting under `slack:` takes precedence over the global setting. ### Voice Transcription ```yaml # Global setting — enable/disable automatic transcription of incoming voice messages stt_enabled: true ``` When `true` (the default), incoming audio messages are automatically transcribed using the configured STT provider before being processed by the agent. ### Full Example ```yaml # Global gateway settings group_sessions_per_user: true unauthorized_dm_behavior: "pair" stt_enabled: true # Slack-specific settings slack: require_mention: true unauthorized_dm_behavior: "pair" # Platform config platforms: slack: reply_to_mode: "first" extra: reply_in_thread: true reply_broadcast: false ``` --- ## Home Channel Set `SLACK_HOME_CHANNEL` to a channel ID where Claway will deliver scheduled messages, cron job results, and other proactive notifications. To find a channel ID: 1. Right-click the channel name in Slack 2. Click **View channel details** 3. Scroll to the bottom — the Channel ID is shown there ```bash SLACK_HOME_CHANNEL=C01234567890 ``` Make sure the bot has been **invited to the channel** (`/invite @Claway Agent`). --- ## Multi-Workspace Support Claway can connect to **multiple Slack workspaces** simultaneously using a single gateway instance. Each workspace is authenticated independently with its own bot user ID. ### Configuration Provide multiple bot tokens as a **comma-separated list** in `SLACK_BOT_TOKEN`: ```bash # Multiple bot tokens — one per workspace SLACK_BOT_TOKEN=xoxb-workspace1-token,xoxb-workspace2-token,xoxb-workspace3-token # A single app-level token is still used for Socket Mode SLACK_APP_TOKEN=xapp-your-app-token ``` Or in `~/.claway/config.yaml`: ```yaml platforms: slack: token: "xoxb-workspace1-token,xoxb-workspace2-token" ``` ### OAuth Token File In addition to tokens in the environment or config, Claway also loads tokens from an **OAuth token file** at: ``` ~/.claway/slack_tokens.json ``` This file is a JSON object mapping team IDs to token entries: ```json { "T01ABC2DEF3": { "token": "xoxb-workspace-token-here", "team_name": "My Workspace" } } ``` Tokens from this file are merged with any tokens specified via `SLACK_BOT_TOKEN`. Duplicate tokens are automatically deduplicated. ### How it works - The **first token** in the list is the primary token, used for the Socket Mode connection (AsyncApp). - Each token is authenticated via `auth.test` on startup. The gateway maps each `team_id` to its own `WebClient` and `bot_user_id`. - When a message arrives, Claway uses the correct workspace-specific client to respond. - The primary `bot_user_id` (from the first token) is used for backward compatibility with features that expect a single bot identity. --- ## Voice Messages Claway supports voice on Slack: - **Incoming:** Voice/audio messages are automatically transcribed using the configured STT provider: local `faster-whisper`, Groq Whisper (`GROQ_API_KEY`), or OpenAI Whisper (`VOICE_TOOLS_OPENAI_KEY`) - **Outgoing:** TTS responses are sent as audio file attachments --- ## Per-Channel Prompts Assign ephemeral system prompts to specific Slack channels. The prompt is injected at runtime on every turn — never persisted to transcript history — so changes take effect immediately. ```yaml slack: channel_prompts: "C01RESEARCH": | You are a research assistant. Focus on academic sources, citations, and concise synthesis. "C02ENGINEERING": | Code review mode. Be precise about edge cases and performance implications. ``` Keys are Slack channel IDs (find them via channel details → "About" → scroll to bottom). All messages in the matching channel get the prompt injected as an ephemeral system instruction. ## Per-Channel Skill Bindings Auto-load a skill whenever a new session starts in a specific channel or DM. Unlike per-channel prompts (which are injected on every turn), skill bindings inject the skill content as a user message at **session start** — it becomes part of the conversation history and does not need to be reloaded on subsequent turns. This is ideal for DMs or channels with a dedicated purpose (flashcards, a domain-specific Q&A bot, a support triage channel, etc.) where you don't want the model's own skill selector to decide whether to load on every short reply. ```yaml slack: channel_skill_bindings: # DM channel — always runs in "german-flashcards" mode - id: "D0ATH9TQ0G6" skills: - german-flashcards # Research channel — preload multiple skills in order - id: "C01RESEARCH" skills: - arxiv - writing-plans # Short form: single skill as a string - id: "C02SUPPORT" skill: hubspot-on-demand ``` Notes: - The binding matches by channel ID. For threaded messages in a bound channel, the thread inherits the parent channel's binding. - The skill is loaded only at session start (new session or after auto-reset). If you change the binding, run `/new` or wait for the session to auto-reset for it to take effect. - Combine with `channel_prompts` for per-channel tone/constraints on top of the skill's instructions. ## Troubleshooting | Problem | Solution | |---------|----------| | Bot doesn't respond to DMs | Verify `message.im` is in your event subscriptions and the app is reinstalled | | Bot works in DMs but not in channels | **Most common issue.** Add `message.channels` and `message.groups` to event subscriptions, reinstall the app, and invite the bot to the channel with `/invite @Claway Agent` | | Bot doesn't respond to @mentions in channels | 1) Check `message.channels` event is subscribed. 2) Bot must be invited to the channel. 3) Ensure `channels:history` scope is added. 4) Reinstall the app after scope/event changes | | Bot ignores messages in private channels | Add both the `message.groups` event subscription and `groups:history` scope, then reinstall the app and `/invite` the bot | | Bot doesn't respond in group DMs (multi-person DMs) | Add the `message.mpim` event subscription and the `mpim:history` scope (plus `mpim:read`), then **reinstall** the app. Without `message.mpim`, Slack never delivers group-DM messages to the bot — even though 1:1 DMs work. | | "Sending messages to this app has been turned off" in DMs | Enable the **Messages Tab** in App Home settings (see Step 5) | | "not_authed" or "invalid_auth" errors | Regenerate your Bot Token and App Token, update `.env` | | Bot responds but can't post in a channel | Invite the bot to the channel with `/invite @Claway Agent` | | Bot can chat but can't read uploaded images/files | Add `files:read`, then **reinstall** the app. Claway now surfaces attachment access diagnostics in-chat when Slack returns scope/auth/permission failures. | | `missing_scope` error | Add the required scope in OAuth & Permissions, then **reinstall** the app | | Socket disconnects frequently | Check your network; Bolt auto-reconnects but unstable connections cause lag | | Changed scopes/events but nothing changed | You **must reinstall** the app to your workspace after any scope or event subscription change | ### Quick Checklist If the bot isn't working in channels, verify **all** of the following: 1. ✅ `message.channels` event is subscribed (for public channels) 2. ✅ `message.groups` event is subscribed (for private channels) 3. ✅ `app_mention` event is subscribed 4. ✅ `channels:history` scope is added (for public channels) 5. ✅ `groups:history` scope is added (for private channels) 6. ✅ App was **reinstalled** after adding scopes/events 7. ✅ Bot was **invited** to the channel (`/invite @Claway Agent`) 8. ✅ You are **@mentioning** the bot in your message --- ## Security :::warning **Always set `SLACK_ALLOWED_USERS`** with the Member IDs of authorized users. Without this setting, the gateway will **deny all messages** by default as a safety measure. Never share your bot tokens — treat them like passwords. ::: - Tokens should be stored in `~/.claway/.env` (file permissions `600`) - Rotate tokens periodically via the Slack app settings - Audit who has access to your Claway config directory - Socket Mode means no public endpoint is exposed — one less attack surface --- <!-- source: website/docs/user-guide/messaging/signal.md --> # Signal # Signal Setup Claway connects to Signal through the [signal-cli](https://github.com/AsamK/signal-cli) daemon running in HTTP mode. The adapter streams messages in real-time via SSE (Server-Sent Events) and sends responses via JSON-RPC. Signal is the most privacy-focused mainstream messenger — end-to-end encrypted by default, open-source protocol, minimal metadata collection. This makes it ideal for security-sensitive agent workflows. :::info No New Python Dependencies The Signal adapter uses `httpx` (already a core Claway dependency) for all communication. No additional Python packages are required. You just need signal-cli installed externally. ::: --- ## Prerequisites - **signal-cli** — Java-based Signal client ([GitHub](https://github.com/AsamK/signal-cli)) - **Java 17+** runtime — required by signal-cli - **A phone number** with Signal installed (for linking as a secondary device) ### Installing signal-cli ```bash # macOS brew install signal-cli # Linux (download latest release) VERSION=$(curl -Ls -o /dev/null -w %{url_effective} \ https://github.com/AsamK/signal-cli/releases/latest | sed 's/^.*\/v//') curl -L -O "https://github.com/AsamK/signal-cli/releases/download/v${VERSION}/signal-cli-${VERSION}.tar.gz" sudo tar xf "signal-cli-${VERSION}.tar.gz" -C /opt sudo ln -sf "/opt/signal-cli-${VERSION}/bin/signal-cli" /usr/local/bin/ ``` :::caution signal-cli is **not** in apt or snap repositories. The Linux install above downloads directly from [GitHub releases](https://github.com/AsamK/signal-cli/releases). ::: --- ## Step 1: Link Your Signal Account Signal-cli works as a **linked device** — like WhatsApp Web, but for Signal. Your phone stays the primary device. ```bash # Generate a linking URI (displays a QR code or link) signal-cli link -n "ClawayAgent" ``` 1. Open **Signal** on your phone 2. Go to **Settings → Linked Devices** 3. Tap **Link New Device** 4. Scan the QR code or enter the URI --- ## Step 2: Start the signal-cli Daemon ```bash # Replace +1234567890 with your Signal phone number (E.164 format) signal-cli --account +1234567890 daemon --http 127.0.0.1:8080 ``` :::tip Keep this running in the background. You can use `systemd`, `tmux`, `screen`, or run it as a service. ::: Verify it's running: ```bash curl http://127.0.0.1:8080/api/v1/check # Should return: {"versions":{"signal-cli":...}} ``` --- ## Step 3: Configure Claway The easiest way: ```bash claway gateway setup ``` Select **Signal** from the platform menu. The wizard will: 1. Check if signal-cli is installed 2. Prompt for the HTTP URL (default: `http://127.0.0.1:8080`) 3. Test connectivity to the daemon 4. Ask for your account phone number 5. Configure allowed users and access policies ### Manual Configuration Add to `~/.claway/.env`: ```bash # Required SIGNAL_HTTP_URL=http://127.0.0.1:8080 SIGNAL_ACCOUNT=+1234567890 # Security (recommended) SIGNAL_ALLOWED_USERS=+1234567890,+0987654321 # Comma-separated E.164 numbers or UUIDs # Optional SIGNAL_GROUP_ALLOWED_USERS=groupId1,groupId2 # Enable groups (omit to disable, * for all) SIGNAL_HOME_CHANNEL=+1234567890 # Default delivery target for cron jobs ``` Then start the gateway: ```bash claway gateway # Foreground claway gateway install # Install as a user service sudo claway gateway install --system # Linux only: boot-time system service ``` --- ## Access Control ### DM Access DM access follows the same pattern as all other Claway platforms: 1. **`SIGNAL_ALLOWED_USERS` set** → only those users can message 2. **No allowlist set** → unknown users get a DM pairing code (approve via `claway pairing approve signal CODE`) 3. **`SIGNAL_ALLOW_ALL_USERS=true`** → anyone can message (use with caution) ### Group Access Group access is controlled by the `SIGNAL_GROUP_ALLOWED_USERS` env var: | Configuration | Behavior | |---------------|----------| | Not set (default) | All group messages are ignored. The bot only responds to DMs. | | Set with group IDs | Only listed groups are monitored (e.g., `groupId1,groupId2`). | | Set to `*` | The bot responds in any group it's a member of. | --- ## Features ### Attachments The adapter supports sending and receiving media in both directions. **Incoming** (user → agent): - **Images** — PNG, JPEG, GIF, WebP (auto-detected via magic bytes) - **Audio** — MP3, OGG, WAV, M4A (voice messages transcribed if Whisper is configured) - **Documents** — PDF, ZIP, and other file types **Outgoing** (agent → user): The agent can send media files via `MEDIA:` tags in responses. The following delivery methods are supported: - **Images** — `send_multiple_images` and `send_image_file` send PNG, JPEG, GIF, WebP as native Signal attachments - **Voice** — `send_voice` sends audio files (OGG, MP3, WAV, M4A, AAC) as attachments - **Video** — `send_video` sends MP4 video files - **Documents** — `send_document` sends any file type (PDF, ZIP, etc.) All outgoing media goes through Signal's standard attachment API. Unlike some platforms, Signal does not distinguish between voice messages and file attachments at the protocol level. Attachment size limit: **100 MB** (both directions). :::warning **Signal servers will rate-limit attachment uploads**, the adapter uses a scheduler for multiple image sending that batches images in groups of 32 and throttles uploads to match the Signal server policy. ::: ### Native Formatting, Reply Quotes, and Reactions Signal messages render with **native formatting** instead of literal markdown characters. The adapter converts markdown (`**bold**`, `*italic*`, `` `code` ``, `~~strike~~`, `||spoiler||`, headings) into Signal `bodyRanges` so the text shows up with real styling on the recipient's client rather than as visible `**` / `` ` `` characters. **Reply quotes.** When Claway replies to a specific message, it now posts a native reply that quotes the original — same UI affordance Signal users see when they use "Reply" themselves. This is automatic for replies generated in response to an inbound message. **Reactions.** The agent can react to messages via the standard reaction API; reactions surface in Signal as emoji reactions on the referenced message rather than as extra text. None of this requires additional config — it ships on by default in recent signal-cli builds. If your `signal-cli` version is too old, Claway falls back to plaintext delivery and logs a one-time warning. ### Typing Indicators The bot sends typing indicators while processing messages, refreshing every 8 seconds. ### Tool Progress Display Signal does not support editing already-sent messages. Claway therefore suppresses gateway tool-progress bubbles on Signal, even when `/verbose` is enabled and saves a non-`off` mode for the platform. You can still see tool activity in the CLI, and final Signal replies can include normal assistant output. If you need live per-tool progress in chat, use a messaging platform with message editing support. ### Phone Number Redaction All phone numbers are automatically redacted in logs: - `+15551234567` → `+155****4567` - This applies to both Claway gateway logs and the global redaction system ### Note to Self (Single-Number Setup) If you run signal-cli as a **linked secondary device** on your own phone number (rather than a separate bot number), you can interact with Claway through Signal's "Note to Self" feature. Just send a message to yourself from your phone — signal-cli picks it up and Claway responds in the same conversation. **How it works:** - "Note to Self" messages arrive as `syncMessage.sentMessage` envelopes - The adapter detects when these are addressed to the bot's own account and processes them as regular inbound messages - Echo-back protection (sent-timestamp tracking) prevents infinite loops — the bot's own replies are filtered out automatically **No extra configuration needed.** This works automatically as long as `SIGNAL_ACCOUNT` matches your phone number. ### Health Monitoring The adapter monitors the SSE connection and automatically reconnects if: - The connection drops (with exponential backoff: 2s → 60s) - No activity is detected for 120 seconds (pings signal-cli to verify) --- ## Troubleshooting | Problem | Solution | |---------|----------| | **"Cannot reach signal-cli"** during setup | Ensure signal-cli daemon is running: `signal-cli --account +YOUR_NUMBER daemon --http 127.0.0.1:8080` | | **Messages not received** | Check that `SIGNAL_ALLOWED_USERS` includes the sender's number in E.164 format (with `+` prefix) | | **"signal-cli not found on PATH"** | Install signal-cli and ensure it's in your PATH, or use Docker | | **Connection keeps dropping** | Check signal-cli logs for errors. Ensure Java 17+ is installed. | | **Group messages ignored** | Configure `SIGNAL_GROUP_ALLOWED_USERS` with specific group IDs, or `*` to allow all groups. | | **Bot responds to no one** | Configure `SIGNAL_ALLOWED_USERS`, use DM pairing, or explicitly allow all users through gateway policy if you want broader access. | | **Duplicate messages** | Ensure only one signal-cli instance is listening on your phone number | --- ## Security :::warning **Always configure access controls.** The bot has terminal access by default. Without `SIGNAL_ALLOWED_USERS` or DM pairing, the gateway denies all incoming messages as a safety measure. ::: - Phone numbers are redacted in all log output - Use DM pairing or explicit allowlists for safe onboarding of new users - Keep groups disabled unless you specifically need group support, or allowlist only the groups you trust - Signal's end-to-end encryption protects message content in transit - The signal-cli session data in `~/.local/share/signal-cli/` contains account credentials — protect it like a password --- ## Environment Variables Reference | Variable | Required | Default | Description | |----------|----------|---------|-------------| | `SIGNAL_HTTP_URL` | Yes | — | signal-cli HTTP endpoint | | `SIGNAL_ACCOUNT` | Yes | — | Bot phone number (E.164) | | `SIGNAL_ALLOWED_USERS` | No | — | Comma-separated phone numbers/UUIDs | | `SIGNAL_GROUP_ALLOWED_USERS` | No | — | Group IDs to monitor, or `*` for all (omit to disable groups) | | `SIGNAL_ALLOW_ALL_USERS` | No | `false` | Allow any user to interact (skip allowlist) | | `SIGNAL_HOME_CHANNEL` | No | — | Default delivery target for cron jobs | --- <!-- source: website/docs/user-guide/messaging/email.md --> # Email # Email Setup Claway can receive and reply to emails using standard IMAP and SMTP protocols. Send an email to the agent's address and it replies in-thread — no special client or bot API needed. Works with Gmail, Outlook, Yahoo, Fastmail, or any provider that supports IMAP/SMTP. :::info Gateway adapter only: no external dependencies This page covers the Email gateway adapter, which uses Python's built-in `imaplib`, `smtplib`, and `email` modules. No additional packages or external services are required for this gateway path. ::: This is separate from the bundled [Himalaya email skill](/user-guide/skills/bundled/email/email-himalaya), which lets the agent manage email through terminal commands and requires the external `himalaya` CLI plus a Himalaya config file. | Use case | What to configure | External dependency | |---|---|---| | Let people email the Claway agent and receive replies | Email gateway adapter on this page | None beyond an IMAP/SMTP email account | | Let the agent inspect, compose, move, and manage mailbox messages from terminal tools | Himalaya email skill | `himalaya` CLI and `~/.config/himalaya/config.toml` | --- ## Prerequisites - **A dedicated email account** for your Claway agent (don't use your personal email) - **IMAP enabled** on the email account - **An app password** if using Gmail or another provider with 2FA ### Gmail Setup 1. Enable 2-Factor Authentication on your Google Account 2. Go to [App Passwords](https://myaccount.google.com/apppasswords) 3. Create a new App Password (select "Mail" or "Other") 4. Copy the 16-character password — you'll use this instead of your regular password ### Outlook / Microsoft 365 1. Go to [Security Settings](https://account.microsoft.com/security) 2. Enable 2FA if not already active 3. Create an App Password under "Additional security options" 4. IMAP host: `outlook.office365.com`, SMTP host: `smtp.office365.com` ### Other Providers Most email providers support IMAP/SMTP. Check your provider's documentation for: - IMAP host and port (usually port 993 with SSL) - SMTP host and port (usually port 587 with STARTTLS) - Whether app passwords are required --- ## Step 1: Configure Claway The easiest way: ```bash claway gateway setup ``` Select **Email** from the platform menu. The wizard prompts for your email address, password, IMAP/SMTP hosts, and allowed senders. ### Manual Configuration Add to `~/.claway/.env`: ```bash # Required EMAIL_ADDRESS=claway@gmail.com EMAIL_PASSWORD=abcd efgh ijkl mnop # App password (not your regular password) EMAIL_IMAP_HOST=imap.gmail.com EMAIL_SMTP_HOST=smtp.gmail.com # Security (recommended) EMAIL_ALLOWED_USERS=your@email.com,colleague@work.com # Optional EMAIL_IMAP_PORT=993 # Default: 993 (IMAP SSL) EMAIL_SMTP_PORT=587 # Default: 587 (SMTP STARTTLS) EMAIL_POLL_INTERVAL=15 # Seconds between inbox checks (default: 15) EMAIL_HOME_ADDRESS=your@email.com # Default delivery target for cron jobs ``` --- ## Step 2: Start the Gateway ```bash claway gateway # Run in foreground claway gateway install # Install as a user service sudo claway gateway install --system # Linux only: boot-time system service ``` On startup, the adapter: 1. Tests IMAP and SMTP connections 2. Marks all existing inbox messages as "seen" (only processes new emails) 3. Starts polling for new messages --- ## How It Works ### Receiving Messages The adapter polls the IMAP inbox for UNSEEN messages at a configurable interval (default: 15 seconds). For each new email: - **Subject line** is included as context (e.g., `[Subject: Deploy to production]`) - **Reply emails** (subject starting with `Re:`) skip the subject prefix — the thread context is already established - **Attachments** are cached locally: - Images (JPEG, PNG, GIF, WebP) → available to the vision tool - Documents (PDF, ZIP, etc.) → available for file access - **HTML-only emails** have tags stripped for plain text extraction - **Self-messages** are filtered out to prevent reply loops - **Automated/noreply senders** are silently ignored — `noreply@`, `mailer-daemon@`, `bounce@`, `no-reply@`, and emails with `Auto-Submitted`, `Precedence: bulk`, or `List-Unsubscribe` headers ### Sending Replies Replies are sent via SMTP with proper email threading: - **In-Reply-To** and **References** headers maintain the thread - **Subject line** preserved with `Re:` prefix (no double `Re: Re:`) - **Message-ID** generated with the agent's domain - Responses are sent as plain text (UTF-8) ### File Attachments The agent can send file attachments in replies. Include `MEDIA:/path/to/file` in the response and the file is attached to the outgoing email. ### Skipping Attachments To ignore all incoming attachments (for malware protection or bandwidth savings), add to your `config.yaml`: ```yaml platforms: email: skip_attachments: true ``` When enabled, attachment and inline parts are skipped before payload decoding. The email body text is still processed normally. --- ## Access Control Email access is stricter by default than chat-style platforms: 1. **`EMAIL_ALLOWED_USERS` set** → only emails from those addresses are processed 2. **No allowlist set** → unknown senders are ignored silently 3. **`EMAIL_ALLOW_ALL_USERS=true`** → any sender is accepted (use with caution) 4. **`platforms.email.unauthorized_dm_behavior: pair`** → unknown senders receive a pairing code :::warning **Use a dedicated inbox and configure `EMAIL_ALLOWED_USERS` for normal operation.** Email pairing is opt-in because shared inboxes often contain unrelated unread messages, and Claway should not reply to those contacts by default. ::: --- ## Troubleshooting | Problem | Solution | |---------|----------| | **"IMAP connection failed"** at startup | Verify `EMAIL_IMAP_HOST` and `EMAIL_IMAP_PORT`. Ensure IMAP is enabled on the account. For Gmail, enable it in Settings → Forwarding and POP/IMAP. | | **"SMTP connection failed"** at startup | Verify `EMAIL_SMTP_HOST` and `EMAIL_SMTP_PORT`. Check that your password is correct (use App Password for Gmail). | | **Messages not received** | Check `EMAIL_ALLOWED_USERS` includes the sender's email. Check spam folder — some providers flag automated replies. | | **"Authentication failed"** | For Gmail, you must use an App Password, not your regular password. Ensure 2FA is enabled first. | | **Duplicate replies** | Ensure only one gateway instance is running. Check `claway gateway status`. | | **Slow response** | The default poll interval is 15 seconds. Reduce with `EMAIL_POLL_INTERVAL=5` for faster response (but more IMAP connections). | | **Replies not threading** | The adapter uses In-Reply-To headers. Some email clients (especially web-based) may not thread correctly with automated messages. | --- ## Security :::warning **Use a dedicated email account.** Don't use your personal email — the agent stores the password in `.env` and has full inbox access via IMAP. ::: - Use **App Passwords** instead of your main password (required for Gmail with 2FA) - Set `EMAIL_ALLOWED_USERS` to restrict who can interact with the agent - The password is stored in `~/.claway/.env` — protect this file (`chmod 600`) - IMAP uses SSL (port 993) and SMTP uses STARTTLS (port 587) by default — connections are encrypted --- ## Environment Variables Reference | Variable | Required | Default | Description | |----------|----------|---------|-------------| | `EMAIL_ADDRESS` | Yes | — | Agent's email address | | `EMAIL_PASSWORD` | Yes | — | Email password or app password | | `EMAIL_IMAP_HOST` | Yes | — | IMAP server host (e.g., `imap.gmail.com`) | | `EMAIL_SMTP_HOST` | Yes | — | SMTP server host (e.g., `smtp.gmail.com`) | | `EMAIL_IMAP_PORT` | No | `993` | IMAP server port | | `EMAIL_SMTP_PORT` | No | `587` | SMTP server port | | `EMAIL_POLL_INTERVAL` | No | `15` | Seconds between inbox checks | | `EMAIL_ALLOWED_USERS` | No | — | Comma-separated allowed sender addresses | | `EMAIL_HOME_ADDRESS` | No | — | Default delivery target for cron jobs | | `EMAIL_ALLOW_ALL_USERS` | No | `false` | Allow all senders (not recommended) | --- <!-- source: website/docs/user-guide/messaging/teams.md --> # Microsoft Teams # Microsoft Teams Setup Connect Claway Agent to Microsoft Teams as a bot. Unlike Slack's Socket Mode, Teams delivers messages by calling a **public HTTPS webhook**, so your instance needs a publicly reachable endpoint — either a dev tunnel (local dev) or a real domain (production). Need meeting summaries from Microsoft Graph events rather than normal bot conversations? Use the dedicated setup page: [Teams Meetings](/user-guide/messaging/teams-meetings). > Run `claway gateway setup` and pick **Microsoft Teams** for a guided walk-through. ## How the Bot Responds | Context | Behavior | |---------|----------| | **Personal chat (DM)** | Bot responds to every message. No @mention needed. | | **Group chat** | Bot only responds when @mentioned. | | **Channel** | Bot only responds when @mentioned. | Teams delivers @mentions as regular messages with `<at>BotName</at>` tags, which Claway strips automatically before processing. --- For source or local installs, include the Teams extra so the bundled adapter can import the Microsoft Teams SDK: ```bash uv sync --extra teams # or, for editable installs: uv pip install -e ".[teams]" ``` ## Step 1: Install the Teams CLI The `@microsoft/teams.cli` automates bot registration — no Azure portal needed. ```bash npm install -g @microsoft/teams.cli@preview teams login ``` To verify your login and find your own AAD object ID (needed for `TEAMS_ALLOWED_USERS`): ```bash teams status --verbose ``` --- ## Step 2: Expose the Webhook Port Teams cannot deliver messages to `localhost`. For local development, use any tunnel tool to get a public HTTPS URL. The default port is `3978` — change it with `TEAMS_PORT` if needed. ```bash # devtunnel (Microsoft) devtunnel create claway-bot --allow-anonymous devtunnel port create claway-bot -p 3978 --protocol https # replace 3978 with TEAMS_PORT if changed devtunnel host claway-bot # ngrok ngrok http 3978 # replace 3978 with TEAMS_PORT if changed # cloudflared cloudflared tunnel --url http://localhost:3978 # replace 3978 with TEAMS_PORT if changed ``` Copy the `https://` URL from the output — you'll use it in the next step. Leave the tunnel running while developing. For production, point your bot's endpoint at your server's public domain instead (see [Production Deployment](#production-deployment)). --- ## Step 3: Create the Bot ```bash teams app create \ --name "Claway" \ --endpoint "https://<your-tunnel-url>/api/messages" ``` The CLI outputs your `CLIENT_ID`, `CLIENT_SECRET`, and `TENANT_ID`, plus an install link for Step 6. Save the client secret — it won't be shown again. --- ## Step 4: Configure Environment Variables Add to `~/.claway/.env`: ```bash # Required TEAMS_CLIENT_ID=<your-client-id> TEAMS_CLIENT_SECRET=<your-client-secret> TEAMS_TENANT_ID=<your-tenant-id> # Restrict access to specific users (recommended) # Use AAD object IDs from `teams status --verbose` TEAMS_ALLOWED_USERS=<your-aad-object-id> ``` --- ## Step 5: Start the Gateway ```bash CLAWAY_UID=$(id -u) CLAWAY_GID=$(id -g) docker compose up -d gateway ``` This starts the gateway. The default webhook port is `3978` (override with `TEAMS_PORT`). Check that it's running: ```bash curl http://localhost:3978/health # should return: ok docker logs -f claway ``` Look for: ``` [teams] Webhook server listening on 0.0.0.0:3978/api/messages ``` --- ## Step 6: Install the App in Teams ```bash teams app get <teamsAppId> --install-link ``` Open the printed link in your browser — it opens directly in the Teams client. After installing, send a direct message to your bot — it's ready. --- ## Configuration Reference ### Environment Variables | Variable | Description | |----------|-------------| | `TEAMS_CLIENT_ID` | Azure AD App (client) ID | | `TEAMS_CLIENT_SECRET` | Azure AD client secret | | `TEAMS_TENANT_ID` | Azure AD tenant ID | | `TEAMS_ALLOWED_USERS` | Comma-separated AAD object IDs allowed to use the bot | | `TEAMS_ALLOW_ALL_USERS` | Set `true` to skip the allowlist and allow anyone | | `TEAMS_HOME_CHANNEL` | Conversation ID for cron/proactive message delivery | | `TEAMS_HOME_CHANNEL_NAME` | Display name for the home channel | | `TEAMS_PORT` | Webhook port (default: `3978`) | ### config.yaml Alternatively, configure via `~/.claway/config.yaml`: ```yaml platforms: teams: enabled: true extra: client_id: "your-client-id" client_secret: "your-secret" tenant_id: "your-tenant-id" port: 3978 ``` --- ## Features ### Interactive Approval Cards When the agent needs to run a potentially dangerous command, it sends an Adaptive Card with four buttons instead of asking you to type `/approve`: - **Allow Once** — approve this specific command - **Allow Session** — approve this pattern for the rest of the session - **Always Allow** — permanently approve this pattern - **Deny** — reject the command Clicking a button resolves the approval inline and replaces the card with the decision. ### Meeting Summary Delivery (Teams Meeting Pipeline) When the [Teams meeting pipeline plugin](/user-guide/messaging/msgraph-webhook) is enabled, this adapter also handles outbound delivery of meeting summaries — one Teams integration surface, not two. After a meeting's transcript is summarized, the writer posts the summary into your chosen Teams target. Pipeline summary delivery is configured under the `teams` platform entry alongside the bot config: ```yaml platforms: teams: enabled: true extra: # existing bot config (client_id, client_secret, tenant_id, port) ... # Meeting summary delivery (only used when the teams_pipeline plugin is enabled) delivery_mode: "graph" # or "incoming_webhook" # For delivery_mode: graph — pick ONE of: chat_id: "19:meeting_..." # post into a Teams chat # team_id: "..." # OR post into a channel # channel_id: "..." # access_token: "..." # optional; falls back to MSGRAPH_* app credentials # For delivery_mode: incoming_webhook: # incoming_webhook_url: "https://outlook.office.com/webhook/..." ``` | Mode | Use when | Trade-off | |------|----------|-----------| | `incoming_webhook` | Simple "post a summary into this channel" with a static Teams-generated URL. | No reply threading, no reactions, shows as the webhook's configured identity. | | `graph` | Threaded channel posts or 1:1/group chat posts under the bot's identity via Microsoft Graph. | Requires the [Graph app registration](/guides/microsoft-graph-app-registration) with `ChannelMessage.Send` (channel) or `Chat.ReadWrite.All` (chat) application permissions. | If the `teams_pipeline` plugin is **not** enabled, these settings are inert — they only wire up when the pipeline runtime binds to the Graph webhook ingress. --- ## Production Deployment For a permanent server, skip devtunnel and register your bot with your server's public HTTPS endpoint: ```bash teams app create \ --name "Claway" \ --endpoint "https://your-domain.com/api/messages" ``` If you've already created the bot and just need to update the endpoint: ```bash teams app update --id <teamsAppId> --endpoint "https://your-domain.com/api/messages" ``` Make sure your configured port (`TEAMS_PORT`, default `3978`) is reachable from the internet and that your TLS certificate is valid — Teams rejects self-signed certificates. --- ## Troubleshooting | Problem | Solution | |---------|----------| | `health` endpoint works but bot doesn't respond | Check that your tunnel is still running and the bot's messaging endpoint matches the tunnel URL | | `KeyError: 'teams'` in logs | Restart the container — this is fixed in the current version | | Bot responds with auth errors | Verify `TEAMS_CLIENT_ID`, `TEAMS_CLIENT_SECRET`, and `TEAMS_TENANT_ID` are all set correctly | | `No inference provider configured` | Check that `ANTHROPIC_API_KEY` (or another provider key) is set in `~/.claway/.env` | | Bot receives messages but ignores them | Your AAD object ID may not be in `TEAMS_ALLOWED_USERS`. Run `teams status --verbose` to find it | | Tunnel URL changes on restart | devtunnel URLs are persistent if you use a named tunnel (`devtunnel create claway-bot`). ngrok and cloudflared generate a new URL each run unless you have a paid plan — update the bot endpoint with `teams app update` when it changes | | Teams shows "This bot is not responding" | The webhook returned an error. Check `docker logs claway` for tracebacks | | `[teams] Failed to connect` in logs | The SDK failed to authenticate. Double-check your credentials and that the tenant ID matches the account you used in `teams login` | --- ## Security :::warning **Always set `TEAMS_ALLOWED_USERS`** with the AAD object IDs of authorized users. Without this, anyone who can find or install your bot can interact with it. Treat `TEAMS_CLIENT_SECRET` like a password — rotate it periodically via the Azure portal or Teams CLI. ::: - Store credentials in `~/.claway/.env` with permissions `600` (`chmod 600 ~/.claway/.env`) - The bot only accepts messages from users in `TEAMS_ALLOWED_USERS`; unauthorized messages are silently dropped - Your public endpoint (`/api/messages`) is authenticated by the Teams Bot Framework — requests without valid JWTs are rejected ## Related Docs - [Teams Meetings](/user-guide/messaging/teams-meetings) - [Operate the Teams Meeting Pipeline](/guides/operate-teams-meeting-pipeline) --- <!-- source: website/docs/integrations/index.md --> # Integrations # Integrations Claway Agent connects to external systems for AI inference, tool servers, IDE workflows, programmatic access, and more. These integrations extend what Claway can do and where it can run. ## AI Providers & Routing Claway supports multiple AI inference providers out of the box. Use `claway model` to configure interactively, or set them in `config.yaml`. - **[AI Providers](/user-guide/features/provider-routing)** — OpenRouter, Anthropic, OpenAI, Google, and any OpenAI-compatible endpoint. Claway auto-detects capabilities like vision, streaming, and tool use per provider. - **[Provider Routing](/user-guide/features/provider-routing)** — Fine-grained control over which underlying providers handle your OpenRouter requests. Optimize for cost, speed, or quality with sorting, whitelists, blacklists, and explicit priority ordering. - **[Fallback Providers](/user-guide/features/fallback-providers)** — Automatic failover to backup LLM providers when your primary model encounters errors. Includes primary model fallback and independent auxiliary task fallback for vision, compression, and web extraction. ## Tool Servers (MCP) - **[MCP Servers](/user-guide/features/mcp)** — Connect Claway to external tool servers via Model Context Protocol. Access tools from GitHub, databases, file systems, browser stacks, internal APIs, and more without writing native Claway tools. Supports both stdio and SSE transports, per-server tool filtering, and capability-aware resource/prompt registration. ## Web Search Backends The `web_search` and `web_extract` tools support eight backend providers, configured via `config.yaml` or `claway tools`: | Backend | Env Var | Search | Extract | Crawl | |---------|---------|--------|---------|-------| | **Firecrawl** (default) | `FIRECRAWL_API_KEY` | ✔ | ✔ | ✔ | | **SearXNG** | `SEARXNG_URL` | ✔ | — | — | | **Brave** (free tier) | `BRAVE_SEARCH_API_KEY` | ✔ | — | — | | **DuckDuckGo** (ddgs) | _(none)_ | ✔ | — | — | | **Tavily** | `TAVILY_API_KEY` | ✔ | ✔ | ✔ | | **Exa** | `EXA_API_KEY` | ✔ | ✔ | — | | **Parallel** | `PARALLEL_API_KEY` | ✔ | ✔ | — | | **xAI** | `XAI_API_KEY` | ✔ | — | — | Quick setup example: ```yaml web: backend: firecrawl # firecrawl | searxng | brave-free | ddgs | tavily | exa | parallel | xai ``` If `web.backend` is not set, the backend is auto-detected from whichever API key is available. Self-hosted Firecrawl is also supported via `FIRECRAWL_API_URL`. ## Browser Automation Claway includes full browser automation with multiple backend options for navigating websites, filling forms, and extracting information: - **Browserbase** — Managed cloud browsers with anti-bot tooling, CAPTCHA solving, and residential proxies - **Browser Use** — Alternative cloud browser provider - **Local Chromium-family CDP** — Connect to your running Chrome, Brave, Chromium, or Edge browser using `/browser connect` - **Local Chromium** — Headless local browser via the `agent-browser` CLI See [Browser Automation](/user-guide/features/browser) for setup and usage. ## Voice & TTS Providers Text-to-speech and speech-to-text across all messaging platforms: | Provider | Quality | Cost | API Key | |----------|---------|------|---------| | **Edge TTS** (default) | Good | Free | None needed | | **ElevenLabs** | Excellent | Paid | `ELEVENLABS_API_KEY` | | **OpenAI TTS** | Good | Paid | `VOICE_TOOLS_OPENAI_KEY` | | **MiniMax** | Good | Paid | `MINIMAX_API_KEY` | | **xAI TTS** | Good | Paid | `XAI_API_KEY` | | **NeuTTS** | Good | Free | None needed | Speech-to-text supports six providers: local faster-whisper (free, runs on-device), a local command wrapper, Groq, OpenAI Whisper API, Mistral, and xAI. Voice message transcription works across Telegram, Discord, WhatsApp, and other messaging platforms. See [Voice & TTS](/user-guide/features/tts) and [Voice Mode](/user-guide/features/voice-mode) for details. ## IDE & Editor Integration ## Programmatic Access - **[API Server](/user-guide/features/api-server)** — Expose Claway as an OpenAI-compatible HTTP endpoint. Any frontend that speaks the OpenAI format — Open WebUI, LobeChat, LibreChat, NextChat, ChatBox — can connect and use Claway as a backend with its full toolset. ## Memory & Personalization - **[Built-in Memory](/user-guide/features/memory)** — Persistent, curated memory via `MEMORY.md` and `USER.md` files. The agent maintains bounded stores of personal notes and user profile data that survive across sessions. - **[Memory Providers](/user-guide/features/memory-providers)** — Plug in external memory backends for deeper personalization. Eight providers are supported: Honcho (dialectic reasoning), OpenViking (tiered retrieval), Mem0 (cloud extraction), Hindsight (knowledge graphs), Holographic (local SQLite), RetainDB (hybrid search), ByteRover (CLI-based), and Supermemory. ## Messaging Platforms Claway runs as a gateway bot on 27+ messaging platforms, all configured through the same `gateway` subsystem: - **[Telegram](/user-guide/messaging/telegram)**, **[Discord](/user-guide/messaging/discord)**, **[Slack](/user-guide/messaging/slack)**, **[WhatsApp](/user-guide/messaging/whatsapp)**, **[Signal](/user-guide/messaging/signal)**, **[Matrix](/user-guide/messaging/matrix)**, **[Mattermost](/user-guide/messaging/mattermost)**, **[Email](/user-guide/messaging/email)**, **[SMS](/user-guide/messaging/sms)**, **[DingTalk](/user-guide/messaging/dingtalk)**, **[Feishu/Lark](/user-guide/messaging/feishu)**, **[WeCom](/user-guide/messaging/wecom)**, **[WeCom Callback](/user-guide/messaging/wecom-callback)**, **[Weixin](/user-guide/messaging/weixin)**, **[BlueBubbles](/user-guide/messaging/bluebubbles)**, **[QQ Bot](/user-guide/messaging/qqbot)**, **[Yuanbao](/user-guide/messaging/yuanbao)**, **[Home Assistant](/user-guide/messaging/homeassistant)**, **[Microsoft Teams](/user-guide/messaging/teams)**, **[Microsoft Teams Meetings](/user-guide/messaging/teams-meetings)**, **[Microsoft Graph Webhook](/user-guide/messaging/msgraph-webhook)**, **[Google Chat](/user-guide/messaging/google_chat)**, **[LINE](/user-guide/messaging/line)**, **[ntfy](/user-guide/messaging/ntfy)**, **[SimpleX](/user-guide/messaging/simplex)**, **[Open WebUI](/user-guide/messaging/open-webui)**, **[Webhooks](/user-guide/messaging/webhooks)** See the [Messaging Gateway overview](/user-guide/messaging) for the platform comparison table and setup guide. ## Home Automation - **[Home Assistant](/user-guide/messaging/homeassistant)** — Control smart home devices via four dedicated tools (`ha_list_entities`, `ha_get_state`, `ha_list_services`, `ha_call_service`). The Home Assistant toolset activates automatically when `HASS_TOKEN` is configured. ## Plugins - **[Plugin System](/user-guide/features/plugins)** — Extend Claway with custom tools, lifecycle hooks, and CLI commands without modifying core code. Plugins are discovered from `~/.claway/plugins/`, project-local `.claway/plugins/`, and pip-installed entry points. - **[Build a Plugin](/guides/build-a-claway-plugin)** — Step-by-step guide for creating Claway plugins with tools, hooks, and CLI commands. ## Training & Evaluation --- <!-- source: website/docs/integrations/providers.md --> # AI Providers # AI Providers This page covers setting up inference providers for Claway Agent — from cloud APIs like OpenRouter and Anthropic, to self-hosted endpoints like Ollama and vLLM, to advanced routing and fallback configurations. You need at least one provider configured to use Claway. ## Inference Providers You need at least one way to connect to an LLM. Use `claway model` to switch providers and models interactively, or configure directly: | Provider | Setup | |----------|-------| | **OpenAI Codex** | `claway model` (ChatGPT OAuth, uses Codex models) | | **GitHub Copilot** | `claway model` (OAuth device code flow, `COPILOT_GITHUB_TOKEN`, `GH_TOKEN`, or `gh auth token`) | | **GitHub Copilot ACP** | `claway model` (spawns local `copilot --acp --stdio`) | | **Anthropic** | `claway model` (Claude Max + extra usage credits via OAuth; also supports Anthropic API key or manual setup-token — see note below) | | **OpenRouter** | `OPENROUTER_API_KEY` in `~/.claway/.env` | | **NovitaAI** | `NOVITA_API_KEY` in `~/.claway/.env` (provider: `novita`, 200+ models, Model API, Agent Sandbox, GPU Cloud) | | **z.ai / GLM** | `GLM_API_KEY` in `~/.claway/.env` (provider: `zai`) | | **Kimi / Moonshot** | `KIMI_API_KEY` in `~/.claway/.env` (provider: `kimi-coding`) | | **Kimi / Moonshot (China)** | `KIMI_CN_API_KEY` in `~/.claway/.env` (provider: `kimi-coding-cn`; aliases: `kimi-cn`, `moonshot-cn`) | | **Arcee AI** | `ARCEEAI_API_KEY` in `~/.claway/.env` (provider: `arcee`; aliases: `arcee-ai`, `arceeai`) | | **GMI Cloud** | `GMI_API_KEY` in `~/.claway/.env` (provider: `gmi`; aliases: `gmi-cloud`, `gmicloud`) | | **MiniMax** | `MINIMAX_API_KEY` in `~/.claway/.env` (provider: `minimax`) | | **MiniMax China** | `MINIMAX_CN_API_KEY` in `~/.claway/.env` (provider: `minimax-cn`) | | **xAI (Grok) — Responses API** | `XAI_API_KEY` in `~/.claway/.env` (provider: `xai`) | | **xAI Grok OAuth (SuperGrok)** | `claway model` → "xAI Grok OAuth (SuperGrok / Premium+)" — browser login, no API key. See [guide](../guides/xai-grok-oauth.md) | | **Qwen Cloud (Alibaba DashScope)** | `DASHSCOPE_API_KEY` in `~/.claway/.env` (provider: `alibaba`) | | **Alibaba Cloud (Coding Plan)** | `DASHSCOPE_API_KEY` (provider: `alibaba-coding-plan`, alias: `alibaba_coding`) — separate billing SKU, different endpoint | | **Kilo Code** | `KILOCODE_API_KEY` in `~/.claway/.env` (provider: `kilocode`) | | **Xiaomi MiMo** | `XIAOMI_API_KEY` in `~/.claway/.env` (provider: `xiaomi`, aliases: `mimo`, `xiaomi-mimo`) | | **Tencent TokenHub** | `TOKENHUB_API_KEY` in `~/.claway/.env` (provider: `tencent-tokenhub`, aliases: `tencent`, `tokenhub`, `tencentmaas`) | | **OpenCode Zen** | `OPENCODE_ZEN_API_KEY` in `~/.claway/.env` (provider: `opencode-zen`) | | **OpenCode Go** | `OPENCODE_GO_API_KEY` in `~/.claway/.env` (provider: `opencode-go`) | | **DeepSeek** | `DEEPSEEK_API_KEY` in `~/.claway/.env` (provider: `deepseek`) | | **Hugging Face** | `HF_TOKEN` in `~/.claway/.env` (provider: `huggingface`, aliases: `hf`) | | **Google / Gemini** | `GOOGLE_API_KEY` (or `GEMINI_API_KEY`) in `~/.claway/.env` (provider: `gemini`) | | **Google Vertex AI** | `claway model` → "Google Vertex AI" (provider: `vertex`; OAuth2 via service-account JSON or ADC, GCP billing) | | **OpenAI API (direct)** | `OPENAI_API_KEY` in `~/.claway/.env` (provider: `openai-api`, optional `OPENAI_BASE_URL`) | | **Azure AI Foundry** | `claway model` → "Azure AI Foundry" (provider: `azure-foundry`; uses Azure OpenAI / Foundry endpoint and key) | | **AWS Bedrock** | `claway model` → "AWS Bedrock" (provider: `bedrock`; standard AWS credentials chain via boto3) | | **NVIDIA Build** | `NVIDIA_API_KEY` in `~/.claway/.env` (provider: `nvidia`; NIM-hosted models on build.nvidia.com) | | **Ollama Cloud** | `claway model` → "Ollama Cloud" (provider: `ollama-cloud`; cloud-hosted Ollama API) | | **Qwen OAuth** | `claway model` → "Qwen OAuth" (provider: `qwen-oauth`; browser PKCE login) | | **MiniMax OAuth** | `claway model` → "MiniMax (OAuth)" (provider: `minimax-oauth`; browser PKCE login) | | **StepFun** | `STEPFUN_API_KEY` in `~/.claway/.env` (provider: `stepfun`) | | **LM Studio** | `claway model` → "LM Studio" (provider: `lmstudio`, optional `LM_API_KEY`) | | **Custom Endpoint** | `claway model` → choose "Custom endpoint" (saved in `config.yaml`) | For the official API-key path, see the dedicated [Google Gemini guide](/guides/google-gemini). :::tip Model key alias In the `model:` config section, you can use either `default:` or `model:` as the key name for your model ID. Both `model: { default: my-model }` and `model: { model: my-model }` work identically. ::: :::info Codex Note The OpenAI Codex provider authenticates via device code (open a URL, enter a code). Claway stores the resulting credentials in its own auth store under `~/.claway/auth.json` and can import existing Codex CLI credentials from `~/.codex/auth.json` when present. No Codex CLI installation is required. If a token refresh fails with a terminal error (HTTP 4xx, `invalid_grant`, revoked grant, etc.), Claway marks the refresh token as dead and stops replaying it so you don't see a flood of identical auth failures. The next request surfaces a typed re-auth message instead. Run `claway auth add codex-oauth` (or `claway model` → OpenAI Codex) to start a fresh device-code login; the quarantine clears on the next successful exchange. ::: :::warning Even when using Codex or a custom endpoint, some tools (vision, web summarization, MoA) use a separate "auxiliary" model. By default (`auxiliary.*.provider: "auto"`), Claway routes these tasks to your **main chat model** — the same model you picked in `claway model`. You can override each task individually to route it to a cheaper/faster model (e.g. Gemini Flash on OpenRouter) — see [Auxiliary Models](/user-guide/configuration#auxiliary-models). ::: ### Two Commands for Model Management Claway has **two** model commands that serve different purposes: | Command | Where to run | What it does | |---------|-------------|--------------| | **`claway model`** | Your terminal (outside any session) | Full setup wizard — add providers, run OAuth, enter API keys, configure endpoints | | **`/model`** | Inside a Claway chat session | Quick switch between **already-configured** providers and models | If you're trying to switch to a provider you haven't set up yet (e.g. you only have OpenRouter configured and want to use Anthropic), you need `claway model`, not `/model`. Exit your session first (`Ctrl+C` or `/quit`), run `claway model`, complete the provider setup, then start a new session. ### Anthropic (Native) Use Claude models directly through the Anthropic API — no OpenRouter proxy needed. Supports three auth methods: :::caution Requires Claude Max "extra usage" credits When you authenticate via `claway model` → Anthropic OAuth (or via `claway auth add anthropic --type oauth`), Claway routes as Claude Code against your Anthropic account. **It only works if you're on a Claude Max plan and have purchased extra usage credits.** The base Max plan allowance (the usage included in Claude Code by default) is not consumed by Claway — only the extra/overage credits you've added on top are. Claude Pro subscribers cannot use this path. If you don't have Max + extra credits, use an `ANTHROPIC_API_KEY` instead — requests are billed pay-per-token against that key's organization (standard API pricing, independent of any Claude subscription). ::: ```bash # With an API key (pay-per-token) export ANTHROPIC_API_KEY=*** claway chat --provider anthropic --model claude-sonnet-4-6 # Preferred: authenticate through `claway model` # Claway will use Claude Code's credential store directly when available claway model # Manual override with a setup-token (fallback / legacy) export ANTHROPIC_TOKEN=*** # setup-token or manual OAuth token claway chat --provider anthropic # Auto-detect Claude Code credentials (if you already use Claude Code) claway chat --provider anthropic # reads Claude Code credential files automatically ``` When you choose Anthropic OAuth through `claway model`, Claway prefers Claude Code's own credential store over copying the token into `~/.claway/.env`. That keeps refreshable Claude credentials refreshable. Or set it permanently: ```yaml model: provider: "anthropic" default: "claude-sonnet-4-6" ``` :::tip Aliases `--provider claude` and `--provider claude-code` also work as shorthand for `--provider anthropic`. ::: ### GitHub Copilot Claway supports GitHub Copilot as a first-class provider with two modes: **`copilot` — Direct Copilot API** (recommended). Uses your GitHub Copilot subscription to access GPT-5.x, Claude, Gemini, and other models through the Copilot API. ```bash claway chat --provider copilot --model gpt-5.4 ``` **Authentication options** (checked in this order): 1. `COPILOT_GITHUB_TOKEN` environment variable 2. `GH_TOKEN` environment variable 3. `GITHUB_TOKEN` environment variable 4. `gh auth token` CLI fallback If no token is found, `claway model` offers an **OAuth device code login** — the same flow used by the Copilot CLI and opencode. :::warning Token types The Copilot API does **not** support classic Personal Access Tokens (`ghp_*`). Supported token types: | Type | Prefix | How to get | |------|--------|------------| | OAuth token | `gho_` | `claway model` → GitHub Copilot → Login with GitHub | | Fine-grained PAT | `github_pat_` | GitHub Settings → Developer settings → Fine-grained tokens (needs **Copilot Requests** permission) | | GitHub App token | `ghu_` | Via GitHub App installation | If your `gh auth token` returns a `ghp_*` token, use `claway model` to authenticate via OAuth instead. ::: :::info Copilot auth behavior in Claway Claway sends a supported GitHub token (`gho_*`, `github_pat_*`, or `ghu_*`) directly to `api.githubcopilot.com` and includes Copilot-specific headers (`Editor-Version`, `Copilot-Integration-Id`, `Openai-Intent`, `x-initiator`). On HTTP 401, Claway now performs a one-shot credential recovery before fallback: 1. Re-resolve token via the normal priority chain (`COPILOT_GITHUB_TOKEN` → `GH_TOKEN` → `GITHUB_TOKEN` → `gh auth token`) 2. Rebuild the shared OpenAI client with refreshed headers 3. Retry the request once Some older community proxies use `api.github.com/copilot_internal/v2/token` exchange flows. That endpoint can be unavailable for some account types (returns 404). Claway therefore keeps direct-token auth as the primary path and relies on runtime credential refresh + retry for robustness. ::: **API routing**: GPT-5+ models (except `gpt-5-mini`) automatically use the Responses API. All other models (GPT-4o, Claude, Gemini, etc.) use Chat Completions. Models are auto-detected from the live Copilot catalog. **`copilot-acp` — Copilot ACP agent backend**. Spawns the local Copilot CLI as a subprocess: ```bash claway chat --provider copilot-acp --model copilot-acp # Requires the GitHub Copilot CLI in PATH and an existing `copilot login` session ``` **Permanent config:** ```yaml model: provider: "copilot" default: "gpt-5.4" ``` | Environment variable | Description | |---------------------|-------------| | `COPILOT_GITHUB_TOKEN` | GitHub token for Copilot API (first priority) | | `CLAWAY_COPILOT_ACP_COMMAND` | Override the Copilot CLI binary path (default: `copilot`) | | `CLAWAY_COPILOT_ACP_ARGS` | Override ACP args (default: `--acp --stdio`) | ### First-Class API-Key Providers These providers have built-in support with dedicated provider IDs. Set the API key and use `--provider` to select: ```bash # NovitaAI Model API claway chat --provider novita --model moonshotai/kimi-k2.5 # Requires: NOVITA_API_KEY in ~/.claway/.env # z.ai / ZhipuAI GLM claway chat --provider zai --model glm-5 # Requires: GLM_API_KEY in ~/.claway/.env # Kimi / Moonshot AI (international: api.moonshot.ai) claway chat --provider kimi-coding --model kimi-for-coding # Requires: KIMI_API_KEY in ~/.claway/.env # Kimi / Moonshot AI (China: api.moonshot.cn) claway chat --provider kimi-coding-cn --model kimi-k2.5 # Requires: KIMI_CN_API_KEY in ~/.claway/.env # MiniMax (global endpoint) claway chat --provider minimax --model MiniMax-M2.7 # Requires: MINIMAX_API_KEY in ~/.claway/.env # MiniMax (China endpoint) claway chat --provider minimax-cn --model MiniMax-M2.7 # Requires: MINIMAX_CN_API_KEY in ~/.claway/.env # Qwen Cloud / DashScope (Qwen models) claway chat --provider alibaba --model qwen3.5-plus # Requires: DASHSCOPE_API_KEY in ~/.claway/.env # Xiaomi MiMo claway chat --provider xiaomi --model mimo-v2-pro # Requires: XIAOMI_API_KEY in ~/.claway/.env # Tencent TokenHub (Hy3 Preview) claway chat --provider tencent-tokenhub --model hy3-preview # Requires: TOKENHUB_API_KEY in ~/.claway/.env # Arcee AI (Trinity models) claway chat --provider arcee --model trinity-large-thinking # Requires: ARCEEAI_API_KEY in ~/.claway/.env # GMI Cloud # Use the exact model ID returned by GMI's /v1/models endpoint. claway chat --provider gmi --model zai-org/GLM-5.1-FP8 # Requires: GMI_API_KEY in ~/.claway/.env ``` Or set the provider permanently in `config.yaml`: ```yaml model: provider: "gmi" default: "zai-org/GLM-5.1-FP8" ``` Base URLs can be overridden with `NOVITA_BASE_URL`, `GLM_BASE_URL`, `KIMI_BASE_URL`, `MINIMAX_BASE_URL`, `MINIMAX_CN_BASE_URL`, `DASHSCOPE_BASE_URL`, `XIAOMI_BASE_URL`, `GMI_BASE_URL`, or `TOKENHUB_BASE_URL` environment variables. :::note Z.AI Endpoint Auto-Detection When using the Z.AI / GLM provider, Claway automatically probes multiple endpoints (global, China, coding variants) to find one that accepts your API key. You don't need to set `GLM_BASE_URL` manually — the working endpoint is detected and cached automatically. ::: ### xAI (Grok) — Responses API + Prompt Caching xAI is wired through the Responses API (`codex_responses` transport) for automatic reasoning support on Grok 4 models — no `reasoning_effort` parameter needed, the server reasons by default. Set `XAI_API_KEY` in `~/.claway/.env` and pick xAI in `claway model`, or drop `grok` as a shortcut into `/model grok-4-fast-reasoning`. SuperGrok and X Premium+ subscribers can sign in with browser OAuth instead of using an API key — pick **xAI Grok OAuth (SuperGrok / Premium+)** in `claway model`, or run `claway auth add xai-oauth`. The same OAuth bearer token is automatically reused by direct-to-xAI tools (TTS, image gen, video gen, transcription). See the [xAI Grok OAuth guide](../guides/xai-grok-oauth.md) for the full flow — and if Claway runs on a remote host, also see [OAuth over SSH / Remote Hosts](../guides/oauth-over-ssh.md) for the required `ssh -L` tunnel. When using xAI as a provider (any base URL containing `x.ai`), Claway automatically enables prompt caching by sending the `x-grok-conv-id` header with every API request. This routes requests to the same server within a conversation session, allowing xAI's infrastructure to reuse cached system prompts and conversation history. No configuration is needed — caching activates automatically when an xAI endpoint is detected and a session ID is available. This reduces latency and cost for multi-turn conversations. xAI also ships a dedicated TTS endpoint (`/v1/tts`). Select **xAI TTS** in `claway tools` → Voice & TTS, or see the [Voice & TTS](../user-guide/features/tts.md#text-to-speech) page for config. **Retired xAI model migration (May 15, 2026):** xAI is retiring `grok-4*`, `grok-3`, `grok-code-fast-1`, and `grok-imagine-image-pro` on 2026-05-15. `claway doctor` and `claway chat` startup both detect any config still pointing at a retired ref and print the recommended replacement. Use `claway migrate xai` for a one-shot config rewrite — dry-run by default, add `--apply` to write changes (a timestamped `config.yaml.bak-pre-migrate-xai-*` backup is created automatically). ```bash claway migrate xai # preview replacements claway migrate xai --apply # rewrite ~/.claway/config.yaml in place ``` **xAI Web Search backend.** When the [Web Search](../user-guide/features/web-search.md) toolset is enabled, `web.backend: xai` routes search through xAI's hosted search endpoint using the same `XAI_API_KEY` / OAuth credentials. No additional setup required if xAI is already configured as a provider. ### NovitaAI [NovitaAI](https://novita.ai) is the AI-native cloud for builders and agents. Its three product lines are Model API for 200+ models, Agent Sandbox for building and running AI agents, and GPU Cloud for scalable compute, all available from one platform. ```bash # Use any available model claway chat --provider novita --model moonshotai/kimi-k2.5 # Requires: NOVITA_API_KEY in ~/.claway/.env # Short alias claway chat --provider novita-ai --model deepseek/deepseek-v3-0324 ``` Or set it permanently in `config.yaml`: ```yaml model: provider: "novita" default: "moonshotai/kimi-k2.5" base_url: "https://api.novita.ai/openai/v1" ``` Get your API key at [novita.ai/settings/key-management](https://novita.ai/settings/key-management). The base URL can be overridden with `NOVITA_BASE_URL`. ### Ollama Cloud — Managed Ollama Models, OAuth + API Key [Ollama Cloud](https://ollama.com/cloud) hosts the same open-weight catalog as local Ollama but without the GPU requirement. Pick it in `claway model` as **Ollama Cloud**, paste your API key from [ollama.com/settings/keys](https://ollama.com/settings/keys), and Claway auto-discovers the available models. ```bash claway model # → pick "Ollama Cloud" # → paste your OLLAMA_API_KEY # → select from discovered models (gpt-oss:120b, glm-4.6:cloud, qwen3-coder:480b-cloud, etc.) ``` Or `config.yaml` directly: ```yaml model: provider: "ollama-cloud" default: "gpt-oss:120b" ``` The model catalog is fetched dynamically from `ollama.com/v1/models` and cached for one hour. `model:tag` notation (e.g. `qwen3-coder:480b-cloud`) is preserved through normalization — don't use dashes. :::tip Ollama Cloud vs local Ollama Both speak the same OpenAI-compatible API. Cloud is a first-class provider (`--provider ollama-cloud`, `OLLAMA_API_KEY`); local Ollama is reached via the Custom Endpoint flow (base URL `http://localhost:11434/v1`, no key). Use cloud for large models you can't run locally; use local for privacy or offline work. ::: ### AWS Bedrock Anthropic Claude, Amazon Nova, DeepSeek v3.2, Meta Llama 4, and other models via AWS Bedrock. Uses the AWS SDK (`boto3`) credential chain — no API key, just standard AWS auth. ```bash # Simplest — named profile in ~/.aws/credentials claway chat --provider bedrock --model us.anthropic.claude-sonnet-4-6 # Or with explicit env vars AWS_PROFILE=myprofile AWS_REGION=us-east-1 claway chat --provider bedrock --model us.anthropic.claude-sonnet-4-6 ``` Or permanently in `config.yaml`: ```yaml model: provider: "bedrock" default: "us.anthropic.claude-sonnet-4-6" bedrock: region: "us-east-1" # or set AWS_REGION # profile: "myprofile" # or set AWS_PROFILE # discovery: true # auto-discover region from IAM # guardrail: # optional Bedrock Guardrails # guardrail_identifier: "your-guardrail-id" # guardrail_version: "DRAFT" ``` Authentication uses the standard boto3 chain: explicit `AWS_ACCESS_KEY_ID`/`AWS_SECRET_ACCESS_KEY`, `AWS_PROFILE` from `~/.aws/credentials`, IAM role on EC2/ECS/Lambda, IMDS, or SSO. No env var is required if you're already authenticated with the AWS CLI. Bedrock uses the **Converse API** under the hood — requests are translated to Bedrock's model-agnostic shape, so the same config works for Claude, Nova, DeepSeek, and Llama models. Set `BEDROCK_BASE_URL` only if you're calling a non-default regional endpoint. See the [AWS Bedrock guide](/guides/aws-bedrock) for a walkthrough of IAM setup, region selection, and cross-region inference. ### Google Vertex AI Gemini models on Google Cloud Vertex AI via Vertex's OpenAI-compatible endpoint. Authentication is **OAuth2** — a short-lived access token (~1 hour) minted from a service-account JSON or Application Default Credentials (ADC). There is **no static API key**; Claway mints and auto-refreshes the token for you, including re-minting on a mid-session `401`. ```bash # Service account JSON (recommended for servers / gateways) echo "VERTEX_CREDENTIALS_PATH=/path/to/service-account.json" >> ~/.claway/.env # or Application Default Credentials gcloud auth application-default login claway model # → "Google Vertex AI" → project → region → model ``` Or in `config.yaml` (project/region are non-secret and live here; the credential path stays in `.env`): ```yaml model: provider: "vertex" default: "google/gemini-3-flash-preview" # Vertex requires the google/ prefix vertex: project_id: "my-gcp-project" # blank → use the project embedded in the credentials region: "global" # required for the Gemini 3.x previews ``` `VERTEX_PROJECT_ID` / `VERTEX_REGION` env vars override the `config.yaml` values. Install with `pip install 'claway[vertex]'` (or let Claway lazy-install `google-auth` on first use). See the [Google Vertex AI guide](/guides/google-vertex) for the full walkthrough, and the [Google Gemini guide](/guides/google-gemini) for the static-API-key AI Studio path instead. ### Qwen Portal (OAuth) Alibaba's Qwen Portal with browser-based OAuth login. Pick **Qwen OAuth (Portal)** in `claway model`, sign in through the browser, and Claway persists the refresh token. ```bash claway model # → pick "Qwen OAuth (Portal)" # → browser opens; sign in with your Alibaba account # → confirm — credentials are saved to ~/.claway/auth.json claway chat # uses portal.qwen.ai/v1 endpoint ``` Or configure `config.yaml`: ```yaml model: provider: "qwen-oauth" default: "qwen3-coder-plus" ``` Set `CLAWAY_QWEN_BASE_URL` only if the portal endpoint relocates (default: `https://portal.qwen.ai/v1`). :::tip Qwen OAuth vs Qwen Cloud (Alibaba DashScope) `qwen-oauth` uses the consumer-facing Qwen Portal with OAuth login — ideal for individual users. The `alibaba` provider uses Qwen Cloud (Alibaba DashScope) with a `DASHSCOPE_API_KEY` — ideal for programmatic / production workloads. Both route to Qwen-family models but live at different endpoints. ::: ### Alibaba Cloud (Coding Plan) If you're subscribed to Alibaba's **Coding Plan** (a pricing SKU separate from standard DashScope API access), Claway exposes it as its own first-class provider: `alibaba-coding-plan`. Endpoint: `https://coding-intl.dashscope.aliyuncs.com/v1`. It's OpenAI-compatible like the regular `alibaba` provider but with a different base URL and billing surface. ```yaml model: provider: alibaba_coding # alias for alibaba-coding-plan model: qwen3-coder-plus ``` Or from the CLI: ```bash claway chat --provider alibaba_coding --model qwen3-coder-plus ``` `alibaba_coding` uses the same `DASHSCOPE_API_KEY` your `alibaba` entry already uses — no separate key needed, just a different routing target. Before this provider was registered, users who set `provider: alibaba_coding` in `config.yaml` silently fell through to OpenRouter routing. ### MiniMax (OAuth) MiniMax-M2.7 via browser OAuth login — no API key needed. Pick **MiniMax (OAuth)** in `claway model`, sign in through the browser, and Claway persists the access + refresh tokens. Uses the Anthropic Messages-compatible endpoint (`/anthropic`) under the hood. ```bash claway model # → pick "MiniMax (OAuth)" # → browser opens; sign in with your MiniMax account (global or CN region) # → confirm — credentials are saved to ~/.claway/auth.json claway chat # uses api.minimax.io/anthropic endpoint ``` Or configure `config.yaml`: ```yaml model: provider: "minimax-oauth" default: "MiniMax-M2.7" ``` Supported models: `MiniMax-M2.7` (main) and `MiniMax-M2.7-highspeed` (wired as the default auxiliary model). The OAuth path ignores `MINIMAX_API_KEY` / `MINIMAX_BASE_URL`. :::tip MiniMax OAuth vs API key `minimax-oauth` uses MiniMax's consumer-facing portal with OAuth login — no billing setup required. The `minimax` and `minimax-cn` providers use `MINIMAX_API_KEY` / `MINIMAX_CN_API_KEY` — for programmatic access. See the [MiniMax OAuth guide](/guides/minimax-oauth) for a full walkthrough. ::: ### NVIDIA NIM Nemotron and other open source models via [build.nvidia.com](https://build.nvidia.com) (free API key) or a local NIM endpoint. ```bash # Cloud (build.nvidia.com) claway chat --provider nvidia --model nvidia/nemotron-3-super-120b-a12b # Requires: NVIDIA_API_KEY in ~/.claway/.env # Local NIM endpoint — override base URL NVIDIA_BASE_URL=http://localhost:8000/v1 claway chat --provider nvidia --model nvidia/nemotron-3-super-120b-a12b ``` Or set it permanently in `config.yaml`: ```yaml model: provider: "nvidia" default: "nvidia/nemotron-3-super-120b-a12b" ``` :::tip Local NIM For on-prem deployments (DGX Spark, local GPU), set `NVIDIA_BASE_URL=http://localhost:8000/v1`. NIM exposes the same OpenAI-compatible chat completions API as build.nvidia.com, so switching between cloud and local is a one-line env-var change. ::: Claway automatically attaches the NIM billing-origin header on every request to `build.nvidia.com` — no configuration needed. This routes consumption against the correct origin in NVIDIA's billing dashboard. ### GMI Cloud Open and reasoning models via [GMI Cloud](https://www.gmicloud.ai/) — OpenAI-compatible API, API key authentication. ```bash # GMI Cloud claway chat --provider gmi --model deepseek-ai/DeepSeek-V3.2 # Requires: GMI_API_KEY in ~/.claway/.env ``` Or set it permanently in `config.yaml`: ```yaml model: provider: "gmi" default: "deepseek-ai/DeepSeek-V3.2" ``` The base URL can be overridden with `GMI_BASE_URL` (default: `https://api.gmi-serving.com/v1`). ### StepFun Step-series models via [StepFun](https://platform.stepfun.com) — OpenAI-compatible API, API key authentication. ```bash # StepFun claway chat --provider stepfun --model step-3.5-flash # Requires: STEPFUN_API_KEY in ~/.claway/.env ``` Or set it permanently in `config.yaml`: ```yaml model: provider: "stepfun" default: "step-3.5-flash" ``` The base URL can be overridden with `STEPFUN_BASE_URL` (default: `https://api.stepfun.com/v1`). ### Hugging Face Inference Providers [Hugging Face Inference Providers](https://huggingface.co/docs/inference-providers) routes to 20+ open models through a unified OpenAI-compatible endpoint (`router.huggingface.co/v1`). Requests are automatically routed to the fastest available backend (Groq, Together, SambaNova, etc.) with automatic failover. ```bash # Use any available model claway chat --provider huggingface --model Qwen/Qwen3.5-397B-A17B # Requires: HF_TOKEN in ~/.claway/.env # Short alias claway chat --provider hf --model deepseek-ai/DeepSeek-V3.2 ``` Or set it permanently in `config.yaml`: ```yaml model: provider: "huggingface" default: "Qwen/Qwen3.5-397B-A17B" ``` Get your token at [huggingface.co/settings/tokens](https://huggingface.co/settings/tokens) — make sure to enable the "Make calls to Inference Providers" permission. Free tier included ($0.10/month credit, no markup on provider rates). You can append routing suffixes to model names: `:fastest` (default), `:cheapest`, or `:provider_name` to force a specific backend. The base URL can be overridden with `HF_BASE_URL`. ## Custom & Self-Hosted LLM Providers Claway Agent works with **any OpenAI-compatible API endpoint**. If a server implements `/v1/chat/completions`, you can point Claway at it. This means you can use local models, GPU inference servers, multi-provider routers, or any third-party API. ### General Setup Three ways to configure a custom endpoint: **Interactive setup (recommended):** ```bash claway model # Select "Custom endpoint (self-hosted / VLLM / etc.)" # Enter: API base URL, API key, Model name ``` **Manual config (`config.yaml`):** ```yaml # In ~/.claway/config.yaml model: default: your-model-name provider: custom base_url: http://localhost:8000/v1 api_key: your-key-or-leave-empty-for-local ``` :::warning Legacy env vars `LLM_MODEL` in `.env` is **removed** — `config.yaml` is the single source of truth for model and endpoint configuration. `OPENAI_BASE_URL` is still honored, but **only** for the `openai-api` provider (it overrides the OpenAI endpoint for direct API-key access). For other providers and custom endpoints, use `claway model` or set `model.base_url` in `config.yaml` directly. If you have stale entries in your `.env`, they are automatically cleared on the next `claway setup` or config migration. ::: Both approaches persist to `config.yaml`, which is the source of truth for model, provider, and base URL. ### Switching Models with `/model` :::warning claway model vs /model **`claway model`** (run from your terminal, outside any chat session) is the **full provider setup wizard**. Use it to add new providers, run OAuth flows, enter API keys, and configure custom endpoints. **`/model`** (typed inside an active Claway chat session) can only **switch between providers and models you've already set up**. It cannot add new providers, run OAuth, or prompt for API keys. If you've only configured one provider (e.g. OpenRouter), `/model` will only show models for that provider. **To add a new provider:** Exit your session (`Ctrl+C` or `/quit`), run `claway model`, set up the new provider, then start a new session. ::: Once you have at least one custom endpoint configured, you can switch models mid-session: ``` /model custom:qwen-2.5 # Switch to a model on your custom endpoint /model custom # Auto-detect the model from the endpoint /model openrouter:claude-sonnet-4 # Switch back to a cloud provider ``` If you have **named custom providers** configured (see below), use the triple syntax: ``` /model custom:local:qwen-2.5 # Use the "local" custom provider with model qwen-2.5 /model custom:work:llama3 # Use the "work" custom provider with llama3 ``` When switching providers, Claway persists the base URL and provider to config so the change survives restarts. When switching away from a custom endpoint to a built-in provider, the stale base URL is automatically cleared. :::tip `/model custom` (bare, no model name) queries your endpoint's `/models` API and auto-selects the model if exactly one is loaded. Useful for local servers running a single model. ::: Everything below follows this same pattern — just change the URL, key, and model name. --- ### Ollama — Local Models, Zero Config [Ollama](https://ollama.com/) runs open-weight models locally with one command. Best for: quick local experimentation, privacy-sensitive work, offline use. Supports tool calling via the OpenAI-compatible API. ```bash # Install and run a model ollama pull qwen2.5-coder:32b ollama serve # Starts on port 11434 ``` Then configure Claway: ```bash claway model # Select "Custom endpoint (self-hosted / VLLM / etc.)" # Enter URL: http://localhost:11434/v1 # Skip API key (Ollama doesn't need one) # Enter model name (e.g. qwen2.5-coder:32b) ``` Or configure `config.yaml` directly: ```yaml model: default: qwen2.5-coder:32b provider: custom base_url: http://localhost:11434/v1 context_length: 64000 # See warning below ``` :::caution Ollama defaults to very low context lengths Ollama does **not** use your model's full context window by default. Depending on your VRAM, the default is: | Available VRAM | Default context | |----------------|----------------| | Less than 24 GB | **4,096 tokens** | | 24–48 GB | 32,768 tokens | | 48+ GB | 256,000 tokens | Claway Agent requires at least **64,000 tokens** of context for agent use with tools. Smaller windows are rejected at startup because the system prompt, tool schemas, and working conversation state need enough room for reliable multi-step workflows. **How to increase it** (pick one): ```bash # Option 1: Set server-wide via environment variable (recommended) OLLAMA_CONTEXT_LENGTH=64000 ollama serve # Option 2: For systemd-managed Ollama sudo systemctl edit ollama.service # Add: Environment="OLLAMA_CONTEXT_LENGTH=64000" # Then: sudo systemctl daemon-reload && sudo systemctl restart ollama # Option 3: Bake it into a custom model (persistent per-model) echo -e "FROM qwen2.5-coder:32b\nPARAMETER num_ctx 64000" > Modelfile ollama create qwen2.5-coder-64k -f Modelfile ``` **You cannot set context length through the OpenAI-compatible API** (`/v1/chat/completions`). It must be configured server-side or via a Modelfile. This is the #1 source of confusion when integrating Ollama with tools like Claway. ::: **Verify your context is set correctly:** ```bash ollama ps # Look at the CONTEXT column — it should show your configured value ``` :::tip List available models with `ollama list`. Pull any model from the [Ollama library](https://ollama.com/library) with `ollama pull <model>`. Ollama handles GPU offloading automatically — no configuration needed for most setups. ::: --- ### vLLM — High-Performance GPU Inference [vLLM](https://docs.vllm.ai/) is the standard for production LLM serving. Best for: maximum throughput on GPU hardware, serving large models, continuous batching. ```bash pip install vllm vllm serve meta-llama/Llama-3.1-70B-Instruct \ --port 8000 \ --max-model-len 65536 \ --tensor-parallel-size 2 \ --enable-auto-tool-choice \ --tool-call-parser claway ``` Then configure Claway: ```bash claway model # Select "Custom endpoint (self-hosted / VLLM / etc.)" # Enter URL: http://localhost:8000/v1 # Skip API key (or enter one if you configured vLLM with --api-key) # Enter model name: meta-llama/Llama-3.1-70B-Instruct ``` **Context length:** vLLM reads the model's `max_position_embeddings` by default. If that exceeds your GPU memory, it errors and asks you to set `--max-model-len` lower. You can also use `--max-model-len auto` to automatically find the maximum that fits. Set `--gpu-memory-utilization 0.95` (default 0.9) to squeeze more context into VRAM. **Tool calling requires explicit flags:** | Flag | Purpose | |------|---------| | `--enable-auto-tool-choice` | Required for `tool_choice: "auto"` (the default in Claway) | | `--tool-call-parser <name>` | Parser for the model's tool call format | Supported parsers: `claway` (Qwen 2.5, Claway 2/3), `llama3_json` (Llama 3.x), `mistral`, `deepseek_v3`, `deepseek_v31`, `xlam`, `pythonic`. Without these flags, tool calls won't work — the model will output tool calls as text. **Qwen reasoning parsers:** Claway preserves structured reasoning metadata such as `reasoning`, `reasoning_content`, and streamed reasoning deltas when OpenAI-compatible servers return them. That metadata is treated as reasoning/thinking trace data, not as a replacement for the assistant's visible answer. For Qwen reasoning models served by vLLM, make sure the final user-visible response still appears in `content`. If `--reasoning-parser qwen3` leaves `content` empty in your deployment, either disable that parser or pass a server-supported request option such as `chat_template_kwargs.enable_thinking: false` through `extra_body`. :::tip vLLM supports human-readable sizes: `--max-model-len 64k` (lowercase k = 1000, uppercase K = 1024). ::: --- ### SGLang — Fast Serving with RadixAttention [SGLang](https://github.com/sgl-project/sglang) is an alternative to vLLM with RadixAttention for KV cache reuse. Best for: multi-turn conversations (prefix caching), constrained decoding, structured output. ```bash pip install "sglang[all]" python -m sglang.launch_server \ --model meta-llama/Llama-3.1-70B-Instruct \ --port 30000 \ --context-length 65536 \ --tp 2 \ --tool-call-parser qwen ``` Then configure Claway: ```bash claway model # Select "Custom endpoint (self-hosted / VLLM / etc.)" # Enter URL: http://localhost:30000/v1 # Enter model name: meta-llama/Llama-3.1-70B-Instruct ``` **Context length:** SGLang reads from the model's config by default. Use `--context-length` to override. If you need to exceed the model's declared maximum, set `SGLANG_ALLOW_OVERWRITE_LONGER_CONTEXT_LEN=1`. **Tool calling:** Use `--tool-call-parser` with the appropriate parser for your model family: `qwen` (Qwen 2.5), `llama3`, `llama4`, `deepseekv3`, `mistral`, `glm`. Without this flag, tool calls come back as plain text. :::caution SGLang defaults to 128 max output tokens If responses seem truncated, add `max_tokens` to your requests or set `--default-max-tokens` on the server. SGLang's default is only 128 tokens per response if not specified in the request. ::: --- ### llama.cpp / llama-server — CPU & Metal Inference [llama.cpp](https://github.com/ggml-org/llama.cpp) runs quantized models on CPU, Apple Silicon (Metal), and consumer GPUs. Best for: running models without a datacenter GPU, Mac users, edge deployment. ```bash # Build and start llama-server cmake -B build && cmake --build build --config Release ./build/bin/llama-server \ --jinja -fa \ -c 64000 \ -ngl 99 \ -m models/qwen2.5-coder-32b-instruct-Q4_K_M.gguf \ --port 8080 --host 0.0.0.0 ``` **Context length (`-c`):** Recent builds default to `0` which reads the model's training context from the GGUF metadata. For models with 128k+ training context, this can OOM trying to allocate the full KV cache. Set `-c` explicitly to at least 64,000 tokens for Claway. If using parallel slots (`-np`), the total context is divided among slots — with `-c 64000 -np 4`, each slot only gets 16k, which is below Claway's minimum per active session. Then configure Claway to point at it: ```bash claway model # Select "Custom endpoint (self-hosted / VLLM / etc.)" # Enter URL: http://localhost:8080/v1 # Skip API key (local servers don't need one) # Enter model name — or leave blank to auto-detect if only one model is loaded ``` This saves the endpoint to `config.yaml` so it persists across sessions. :::caution `--jinja` is required for tool calling Without `--jinja`, llama-server ignores the `tools` parameter entirely. The model will try to call tools by writing JSON in its response text, but Claway won't recognize it as a tool call — you'll see raw JSON like `{"name": "web_search", ...}` printed as a message instead of an actual search. Native tool calling support (best performance): Llama 3.x, Qwen 2.5 (including Coder), Claway 2/3, Mistral, DeepSeek, Functionary. All other models use a generic handler that works but may be less efficient. See the [llama.cpp function calling docs](https://github.com/ggml-org/llama.cpp/blob/master/docs/function-calling.md) for the full list. You can verify tool support is active by checking `http://localhost:8080/props` — the `chat_template` field should be present. ::: :::tip Download GGUF models from [Hugging Face](https://huggingface.co/models?library=gguf). Q4_K_M quantization offers the best balance of quality vs. memory usage. ::: --- ### LM Studio — Desktop App with Local Models [LM Studio](https://lmstudio.ai/) is a desktop app for running local models with a GUI. Best for: users who prefer a visual interface, quick model testing, developers on macOS/Windows/Linux. Start the server from the LM Studio app (Developer tab → Start Server), or use the CLI: ```bash lms server start # Starts on port 1234 lms load qwen2.5-coder --context-length 64000 ``` Then configure Claway: ```bash claway model # Select "LM Studio" # Press Enter to use http://localhost:1234/v1 # Pick one of the discovered models # If LM Studio server auth is enabled, enter LM_API_KEY when prompted ``` Claway will automatically load a LM Studio model with 64K context length To change context length in LM Studio: 1. Click the gear icon next to the model picker 2. Set "Context Length" to at least 64000 for a smooth experience 3. Reload the model for the change to take effect 4. If your machine cannot fit 64000, consider using a smaller model with larger context lengths. Alternatively, use the CLI: `lms load model-name --context-length 64000` You can use the CLI to estimate if the model will fit: `lms load model-name --context-length 64000 --estimate-only` To set persistent per-model defaults: My Models tab → gear icon on the model → set context size. ::: **Tool calling:** Supported since LM Studio 0.3.6. Models with native tool-calling training (Qwen 2.5, Llama 3.x, Mistral, Claway) are auto-detected and shown with a tool badge. Other models use a generic fallback that may be less reliable. --- ### WSL2 Networking (Windows Users) Since Claway Agent requires a Unix environment, Windows users run it inside WSL2. If your model server (Ollama, LM Studio, etc.) runs on the **Windows host**, you need to bridge the network gap — WSL2 uses a virtual network adapter with its own subnet, so `localhost` inside WSL2 refers to the Linux VM, **not** the Windows host. :::tip Both in WSL2? No problem. If your model server also runs inside WSL2 (common for vLLM, SGLang, and llama-server), `localhost` works as expected — they share the same network namespace. Skip this section. ::: #### Option 1: Mirrored Networking Mode (Recommended) Available on **Windows 11 22H2+**, mirrored mode makes `localhost` work bidirectionally between Windows and WSL2 — the simplest fix. 1. Create or edit `%USERPROFILE%\.wslconfig` (e.g., `C:\Users\YourName\.wslconfig`): ```ini [wsl2] networkingMode=mirrored ``` 2. Restart WSL from PowerShell: ```powershell wsl --shutdown ``` 3. Reopen your WSL2 terminal. `localhost` now reaches Windows services: ```bash curl http://localhost:11434/v1/models # Ollama on Windows — works ``` :::note Hyper-V Firewall On some Windows 11 builds, the Hyper-V firewall blocks mirrored connections by default. If `localhost` still doesn't work after enabling mirrored mode, run this in an **Admin PowerShell**: ```powershell Set-NetFirewallHyperVVMSetting -Name '{40E0AC32-46A5-438A-A0B2-2B479E8F2E90}' -DefaultInboundAction Allow ``` ::: #### Option 2: Use the Windows Host IP (Windows 10 / older builds) If you can't use mirrored mode, find the Windows host IP from inside WSL2 and use that instead of `localhost`: ```bash # Get the Windows host IP (the default gateway of WSL2's virtual network) ip route show | grep -i default | awk '{ print $3 }' # Example output: 172.29.192.1 ``` Use that IP in your Claway config: ```yaml model: default: qwen2.5-coder:32b provider: custom base_url: http://172.29.192.1:11434/v1 # Windows host IP, not localhost ``` :::tip Dynamic helper The host IP can change on WSL2 restart. You can grab it dynamically in your shell: ```bash export WSL_HOST=$(ip route show | grep -i default | awk '{ print $3 }') echo "Windows host at: $WSL_HOST" curl http://$WSL_HOST:11434/v1/models # Test Ollama ``` Or use your machine's mDNS name (requires `libnss-mdns` in WSL2): ```bash sudo apt install libnss-mdns curl http://$(hostname).local:11434/v1/models ``` ::: #### Server Bind Address (Required for NAT Mode) If you're using **Option 2** (NAT mode with the host IP), the model server on Windows must accept connections from outside `127.0.0.1`. By default, most servers only listen on localhost — WSL2 connections in NAT mode come from a different virtual subnet and will be refused. In mirrored mode, `localhost` maps directly so the default `127.0.0.1` binding works fine. | Server | Default bind | How to fix | |--------|-------------|------------| | **Ollama** | `127.0.0.1` | Set `OLLAMA_HOST=0.0.0.0` environment variable before starting Ollama (System Settings → Environment Variables on Windows, or edit the Ollama service) | | **LM Studio** | `127.0.0.1` | Enable **"Serve on Network"** in the Developer tab → Server settings | | **llama-server** | `127.0.0.1` | Add `--host 0.0.0.0` to the startup command | | **vLLM** | `0.0.0.0` | Already binds to all interfaces by default | | **SGLang** | `127.0.0.1` | Add `--host 0.0.0.0` to the startup command | **Ollama on Windows (detailed):** Ollama runs as a Windows service. To set `OLLAMA_HOST`: 1. Open **System Properties** → **Environment Variables** 2. Add a new **System variable**: `OLLAMA_HOST` = `0.0.0.0` 3. Restart the Ollama service (or reboot) #### Windows Firewall Windows Firewall treats WSL2 as a separate network (in both NAT and mirrored mode). If connections still fail after the steps above, add a firewall rule for your model server's port: ```powershell # Run in Admin PowerShell — replace PORT with your server's port New-NetFirewallRule -DisplayName "Allow WSL2 to Model Server" -Direction Inbound -Action Allow -Protocol TCP -LocalPort 11434 ``` Common ports: Ollama `11434`, vLLM `8000`, SGLang `30000`, llama-server `8080`, LM Studio `1234`. #### Quick Verification From inside WSL2, test that you can reach your model server: ```bash # Replace URL with your server's address and port curl http://localhost:11434/v1/models # Mirrored mode curl http://172.29.192.1:11434/v1/models # NAT mode (use your actual host IP) ``` If you get a JSON response listing your models, you're good. Use that same URL as the `base_url` in your Claway config. --- ### Troubleshooting Local Models These issues affect **all** local inference servers when used with Claway. #### "Connection refused" from WSL2 to a Windows-hosted model server If you're running Claway inside WSL2 and your model server on the Windows host, `http://localhost:<port>` won't work in WSL2's default NAT networking mode. See [WSL2 Networking](#wsl2-networking-windows-users) above for the fix. #### Tool calls appear as text instead of executing The model outputs something like `{"name": "web_search", "arguments": {...}}` as a message instead of actually calling the tool. **Cause:** Your server doesn't have tool calling enabled, or the model doesn't support it through the server's tool calling implementation. | Server | Fix | |--------|-----| | **llama.cpp** | Add `--jinja` to the startup command | | **vLLM** | Add `--enable-auto-tool-choice --tool-call-parser claway` | | **SGLang** | Add `--tool-call-parser qwen` (or appropriate parser) | | **Ollama** | Tool calling is enabled by default — make sure your model supports it (check with `ollama show model-name`) | | **LM Studio** | Update to 0.3.6+ and use a model with native tool support | #### Model seems to forget context or give incoherent responses **Cause:** Context window is too small. When the conversation exceeds the context limit, most servers silently drop older messages. Claway's system prompt + tool schemas alone can use 4k–8k tokens. **Diagnosis:** ```bash # Check what Claway thinks the context is # Look at startup line: "Context limit: X tokens" # Check your server's actual context # Ollama: ollama ps (CONTEXT column) # llama.cpp: curl http://localhost:8080/props | jq '.default_generation_settings.n_ctx' # vLLM: check --max-model-len in startup args ``` **Fix:** Set context to at least **64,000 tokens** for agent use. See each server's section above for the specific flag. #### "Context limit: 2048 tokens" at startup Claway auto-detects context length from your server's `/v1/models` endpoint. If the server reports a low value (or doesn't report one at all), Claway uses the model's declared limit which may be wrong. **Fix:** Set it explicitly in `config.yaml`: ```yaml model: default: your-model provider: custom base_url: http://localhost:11434/v1 context_length: 64000 ``` #### Responses get cut off mid-sentence **Possible causes:** 1. **Low output cap (`max_tokens`) on the server** — SGLang defaults to 128 tokens per response. Set `--default-max-tokens` on the server or configure Claway with `model.max_tokens` in config.yaml. Note: `max_tokens` controls response length only — it is unrelated to how long your conversation history can be (that is `context_length`). 2. **Context exhaustion** — The model filled its context window. Increase `model.context_length` or enable [context compression](/user-guide/configuration#context-compression) in Claway. --- ### LiteLLM Proxy — Multi-Provider Gateway [LiteLLM](https://docs.litellm.ai/) is an OpenAI-compatible proxy that unifies 100+ LLM providers behind a single API. Best for: switching between providers without config changes, load balancing, fallback chains, budget controls. ```bash # Install and start pip install "litellm[proxy]" litellm --model anthropic/claude-sonnet-4 --port 4000 # Or with a config file for multiple models: litellm --config litellm_config.yaml --port 4000 ``` Then configure Claway with `claway model` → Custom endpoint → `http://localhost:4000/v1`. Example `litellm_config.yaml` with fallback: ```yaml model_list: - model_name: "best" litellm_params: model: anthropic/claude-sonnet-4 api_key: sk-ant-... - model_name: "best" litellm_params: model: openai/gpt-4o api_key: sk-... router_settings: routing_strategy: "latency-based-routing" ``` --- ### ClawRouter — Cost-Optimized Routing [ClawRouter](https://github.com/BlockRunAI/ClawRouter) by BlockRunAI is a local routing proxy that auto-selects models based on query complexity. It classifies requests across 14 dimensions and routes to the cheapest model that can handle the task. Payment is via USDC cryptocurrency (no API keys). ```bash # Install and start npx @blockrun/clawrouter # Starts on port 8402 ``` Then configure Claway with `claway model` → Custom endpoint → `http://localhost:8402/v1` → model name `blockrun/auto`. Routing profiles: | Profile | Strategy | Savings | |---------|----------|---------| | `blockrun/auto` | Balanced quality/cost | 74-100% | | `blockrun/eco` | Cheapest possible | 95-100% | | `blockrun/premium` | Best quality models | 0% | | `blockrun/free` | Free models only | 100% | | `blockrun/agentic` | Optimized for tool use | varies | :::note ClawRouter requires a USDC-funded wallet on Base or Solana for payment. All requests route through BlockRun's backend API. Run `npx @blockrun/clawrouter doctor` to check wallet status. ::: --- ### Other Compatible Providers Any service with an OpenAI-compatible API works. Some popular options: | Provider | Base URL | Notes | |----------|----------|-------| | [Together AI](https://together.ai) | `https://api.together.xyz/v1` | Cloud-hosted open models | | [Groq](https://groq.com) | `https://api.groq.com/openai/v1` | Ultra-fast inference | | [DeepSeek](https://deepseek.com) | `https://api.deepseek.com/v1` | DeepSeek models | | [Fireworks AI](https://fireworks.ai) | `https://api.fireworks.ai/inference/v1` | Fast open model hosting | | [GMI Cloud](https://www.gmicloud.ai/) | `https://api.gmi-serving.com/v1` | Managed OpenAI-compatible inference | | [Cerebras](https://cerebras.ai) | `https://api.cerebras.ai/v1` | Wafer-scale chip inference | | [Mistral AI](https://mistral.ai) | `https://api.mistral.ai/v1` | Mistral models | | [OpenAI](https://openai.com) | `https://api.openai.com/v1` | Direct OpenAI access | | [Azure OpenAI](https://azure.microsoft.com) | `https://YOUR.openai.azure.com/` | Enterprise OpenAI | | [LocalAI](https://localai.io) | `http://localhost:8080/v1` | Self-hosted, multi-model | | [Jan](https://jan.ai) | `http://localhost:1337/v1` | Desktop app with local models | Configure any of these with `claway model` → Custom endpoint, or in `config.yaml`: ```yaml model: default: meta-llama/Llama-3.1-70B-Instruct-Turbo provider: custom base_url: https://api.together.xyz/v1 api_key: your-together-key ``` --- ### Context Length Detection :::note Two settings, easy to confuse **`context_length`** is the **total context window** — the combined budget for input *and* output tokens (e.g. 200,000 for Claude Opus 4.6). Claway uses this to decide when to compress history and to validate API requests. **`model.max_tokens`** is the **output cap** — the maximum number of tokens the model may generate in a *single response*. It has nothing to do with how long your conversation history can be. The industry-standard name `max_tokens` is a common source of confusion; Anthropic's native API has since renamed it `max_output_tokens` for clarity. Set `context_length` when auto-detection gets the window size wrong. Set `model.max_tokens` only when you need to limit how long individual responses can be. ::: Claway uses a multi-source resolution chain to detect the correct context window for your model and provider: 1. **Config override** — `model.context_length` in config.yaml (highest priority) 2. **Custom provider per-model** — `custom_providers[].models.<id>.context_length` 3. **Persistent cache** — previously discovered values (survives restarts) 4. **Endpoint `/models`** — queries your server's API (local/custom endpoints) 5. **Anthropic `/v1/models`** — queries Anthropic's API for `max_input_tokens` (API-key users only) 6. **OpenRouter API** — live model metadata from OpenRouter 7. **Aggregator model IDs** — suffix-matches vendor-prefixed model IDs against OpenRouter metadata 8. **[models.dev](https://models.dev)** — community-maintained registry with provider-specific context lengths for 3800+ models across 100+ providers 9. **Fallback defaults** — broad model family patterns (128K default) For most setups this works out of the box. The system is provider-aware — the same model can have different context limits depending on who serves it (e.g., `claude-opus-4.6` is 1M on Anthropic direct but 128K on GitHub Copilot). To set the context length explicitly, add `context_length` to your model config: ```yaml model: default: "qwen3.5:9b" base_url: "http://localhost:8080/v1" context_length: 131072 # tokens ``` For custom endpoints, you can also set context length per model: ```yaml custom_providers: - name: "My Local LLM" base_url: "http://localhost:11434/v1" models: qwen3.5:27b: context_length: 64000 deepseek-r1:70b: context_length: 65536 ``` `claway model` will prompt for context length when configuring a custom endpoint. Leave it blank for auto-detection. :::tip When to set this manually - You're using Ollama with a custom `num_ctx` that's lower than the model's maximum - You want to limit context below the model's maximum (e.g., 8k on a 128k model to save VRAM) - You're running behind a proxy that doesn't expose `/v1/models` ::: --- ### Named Custom Providers If you work with multiple custom endpoints (e.g., a local dev server and a remote GPU server), you can define them as named custom providers in `config.yaml`: ```yaml custom_providers: - name: local base_url: http://localhost:8080/v1 # api_key omitted — Claway uses "no-key-required" for keyless local servers - name: work base_url: https://gpu-server.internal.corp/v1 key_env: CORP_API_KEY api_mode: chat_completions # set explicitly by `claway model` → Custom Endpoint wizard; auto-detection still happens as a fallback - name: anthropic-proxy base_url: https://proxy.example.com/anthropic key_env: ANTHROPIC_PROXY_KEY api_mode: anthropic_messages # for Anthropic-compatible proxies ``` Some OpenAI-compatible endpoints need provider-specific request body fields. Add an `extra_body` map to the matching custom provider and Claway will merge it into each chat-completions request for that endpoint: ```yaml custom_providers: - name: gemma-local base_url: http://localhost:8080/v1 model: google/gemma-4-31b-it extra_body: enable_thinking: true reasoning_effort: high ``` Use the shape your server documents. For example, vLLM Gemma deployments and some NVIDIA NIM endpoints expect `enable_thinking` under `chat_template_kwargs` instead of as a top-level `extra_body` field: ```yaml extra_body: chat_template_kwargs: enable_thinking: true ``` For Qwen reasoning models served by vLLM, this same shape can be used to disable thinking when a reasoning parser separates all generated text into reasoning fields and leaves the assistant `content` empty: ```yaml extra_body: chat_template_kwargs: enable_thinking: false ``` The `claway model` → Custom Endpoint wizard now prompts for `api_mode` explicitly and persists your answer to `config.yaml`. URL-based auto-detection (e.g. `/anthropic` paths → `anthropic_messages`) still happens as a fallback when the field is left blank. **Native vision for custom-provider models.** If your custom endpoint serves a vision-capable model that isn't in models.dev, set `model.supports_vision: true` so Claway routes attached images natively (as `image_url` parts) instead of pre-processing them through `vision_analyze`. Single knob — no need to also set `agent.image_input_mode: native`. ```yaml model: provider: custom base_url: http://localhost:8080/v1 default: qwen3.6-35b-a3b supports_vision: true # send images natively; otherwise vision_analyze pre-describes them ``` The same key is honored on per-named-provider models (`custom_providers[*].models[*].supports_vision`) and accepts standard YAML booleans (`true/false/yes/no/on/off/1/0`). Switch between them mid-session with the triple syntax: ``` /model custom:local:qwen-2.5 # Use the "local" endpoint with qwen-2.5 /model custom:work:llama3-70b # Use the "work" endpoint with llama3-70b /model custom:anthropic-proxy:claude-sonnet-4 # Use the proxy ``` You can also select named custom providers from the interactive `claway model` menu. --- ### Cookbook: Together AI, Groq, Perplexity The cloud providers listed in [Other Compatible Providers](#other-compatible-providers) all speak OpenAI's REST dialect, so they wire up the same way under `custom_providers:`. Three worked recipes follow. Each drops into `~/.claway/config.yaml` and the matching API key goes in `~/.claway/.env`. #### Together AI Hosts open-weight models (Llama, MiniMax, Gemma, DeepSeek, Qwen) at prices significantly below first-party APIs. Good default for multi-model fleets. ```yaml # ~/.claway/config.yaml custom_providers: - name: together base_url: https://api.together.xyz/v1 key_env: TOGETHER_API_KEY # api_mode: chat_completions # default — no need to set model: default: MiniMaxAI/MiniMax-M2.7 # or any model from together.ai/models provider: custom:together ``` ```bash # ~/.claway/.env TOGETHER_API_KEY=your-together-key ``` Switch models mid-session: ``` /model custom:together:meta-llama/Llama-3.3-70B-Instruct-Turbo /model custom:together:google/gemma-4-31b-it /model custom:together:deepseek-ai/DeepSeek-V3 ``` Together's `/v1/models` endpoint works, so `claway model` can auto-discover available models. #### Groq Ultra-fast inference (~500 tok/s on Llama-3.3-70B). Small catalog but strong for latency-sensitive interactive use. ```yaml # ~/.claway/config.yaml custom_providers: - name: groq base_url: https://api.groq.com/openai/v1 key_env: GROQ_API_KEY model: default: llama-3.3-70b-versatile provider: custom:groq ``` ```bash # ~/.claway/.env GROQ_API_KEY=your-groq-key ``` #### Perplexity Useful when you want a model that does live web search and citation automatically. Strict about which models are available — check [perplexity.ai/settings/api](https://www.perplexity.ai/settings/api) for the current list. ```yaml # ~/.claway/config.yaml custom_providers: - name: perplexity base_url: https://api.perplexity.ai key_env: PERPLEXITY_API_KEY model: default: sonar provider: custom:perplexity ``` ```bash # ~/.claway/.env PERPLEXITY_API_KEY=your-perplexity-key ``` #### Multiple providers in one config The three recipes compose — use all of them together and switch per turn with `/model custom:<name>:<model>`: ```yaml custom_providers: - name: together base_url: https://api.together.xyz/v1 key_env: TOGETHER_API_KEY - name: groq base_url: https://api.groq.com/openai/v1 key_env: GROQ_API_KEY - name: perplexity base_url: https://api.perplexity.ai key_env: PERPLEXITY_API_KEY model: default: MiniMaxAI/MiniMax-M2.7 provider: custom:together # boot to Together; switch freely after ``` :::tip Troubleshooting - `claway doctor` should print no `Unknown provider` warnings for any of these names. - If a provider's `/v1/models` endpoint is unreachable (Perplexity is the common one), `claway model` will persist the model with a warning rather than hard-reject. - To skip `custom_providers:` entirely, use bare `provider: custom` with the `CUSTOM_BASE_URL` env var. ::: --- ### Choosing the Right Setup | Use Case | Recommended | |----------|-------------| | **Just want it to work** | OpenRouter (default) | | **Local models, easy setup** | Ollama | | **Production GPU serving** | vLLM or SGLang | | **Mac / no GPU** | Ollama or llama.cpp | | **Multi-provider routing** | LiteLLM Proxy or OpenRouter | | **Cost optimization** | ClawRouter or OpenRouter with `sort: "price"` | | **Maximum privacy** | Ollama, vLLM, or llama.cpp (fully local) | | **Enterprise / Azure** | Azure OpenAI with custom endpoint | | **Chinese AI models** | z.ai (GLM), Kimi/Moonshot (`kimi-coding` or `kimi-coding-cn`), MiniMax, Xiaomi MiMo, or Tencent TokenHub (first-class providers) | :::tip You can switch between providers at any time with `claway model` — no restart required. Your conversation history, memory, and skills carry over regardless of which provider you use. ::: ## Optional API Keys | Feature | Provider | Env Variable | |---------|----------|--------------| | Web scraping | [Firecrawl](https://firecrawl.dev/) | `FIRECRAWL_API_KEY`, `FIRECRAWL_API_URL` | | Browser automation | [Browserbase](https://browserbase.com/) | `BROWSERBASE_API_KEY`, `BROWSERBASE_PROJECT_ID` | | Image generation | [FAL](https://fal.ai/) | `FAL_KEY` | | Premium TTS voices | [ElevenLabs](https://elevenlabs.io/) | `ELEVENLABS_API_KEY` | | OpenAI TTS + voice transcription | [OpenAI](https://platform.openai.com/api-keys) | `VOICE_TOOLS_OPENAI_KEY` | | Mistral TTS + voice transcription | [Mistral](https://console.mistral.ai/) | `MISTRAL_API_KEY` | | Cross-session user modeling | [Honcho](https://honcho.dev/) | `HONCHO_API_KEY` | | Semantic long-term memory | [Supermemory](https://supermemory.ai) | `SUPERMEMORY_API_KEY` | ### Self-Hosting Firecrawl By default, Claway uses the [Firecrawl cloud API](https://firecrawl.dev/) for web search and scraping. If you prefer to run Firecrawl locally, you can point Claway at a self-hosted instance instead. See Firecrawl's [SELF_HOST.md](https://github.com/firecrawl/firecrawl/blob/main/SELF_HOST.md) for complete setup instructions. **What you get:** No API key required, no rate limits, no per-page costs, full data sovereignty. **What you lose:** The cloud version uses Firecrawl's proprietary "Fire-engine" for advanced anti-bot bypassing (Cloudflare, CAPTCHAs, IP rotation). Self-hosted uses basic fetch + Playwright, so some protected sites may fail. Search uses DuckDuckGo instead of Google. **Setup:** 1. Clone and start the Firecrawl Docker stack (5 containers: API, Playwright, Redis, RabbitMQ, PostgreSQL — requires ~4-8 GB RAM): ```bash git clone https://github.com/firecrawl/firecrawl cd firecrawl # In .env, set: USE_DB_AUTHENTICATION=false, HOST=0.0.0.0, PORT=3002 docker compose up -d ``` 2. Point Claway at your instance (no API key needed): ```bash claway config set FIRECRAWL_API_URL http://localhost:3002 ``` You can also set both `FIRECRAWL_API_KEY` and `FIRECRAWL_API_URL` if your self-hosted instance has authentication enabled. ## OpenRouter Provider Routing When using OpenRouter, you can control how requests are routed across providers. Add a `provider_routing` section to `~/.claway/config.yaml`: ```yaml provider_routing: sort: "throughput" # "price" (default), "throughput", or "latency" # only: ["anthropic"] # Only use these providers # ignore: ["deepinfra"] # Skip these providers # order: ["anthropic", "google"] # Try providers in this order # require_parameters: true # Only use providers that support all request params # data_collection: "deny" # Exclude providers that may store/train on data ``` **Shortcuts:** Append `:nitro` to any model name for throughput sorting (e.g., `anthropic/claude-sonnet-4:nitro`), or `:floor` for price sorting. ## OpenRouter Pareto Code Router OpenRouter ships an experimental coding-model router at `openrouter/pareto-code` that auto-routes requests to the cheapest model meeting a coding-quality bar (ranked by [Artificial Analysis](https://artificialanalysis.ai/)). Pick this model and tune the `min_coding_score` knob in `~/.claway/config.yaml`: ```yaml model: provider: openrouter model: openrouter/pareto-code openrouter: min_coding_score: 0.65 # 0.0–1.0; higher = stronger (more expensive) coders. Default 0.65. ``` Notes: - `min_coding_score` is **only** sent when `model.model` is `openrouter/pareto-code`. On any other model the value is a no-op. - Set to empty string (or remove the line) to let OpenRouter pick the strongest available coder — its documented behavior when the plugins block is omitted. - Selection is deterministic per score on a given day, but the actual model chosen can shift as the Pareto frontier moves (new models, benchmark updates). - See OpenRouter's [Pareto Router docs](https://openrouter.ai/docs/guides/routing/routers/pareto-router) for the full router behavior. - To use the Pareto Code router for a specific **auxiliary task** (compression, vision, etc.) instead of the main agent, set `extra_body.plugins` under that task — see [Auxiliary Models → OpenRouter routing & Pareto Code for auxiliary tasks](/user-guide/configuration#openrouter-routing--pareto-code-for-auxiliary-tasks). ## Fallback Providers Configure a chain of backup providers Claway tries in order when the primary model fails (rate limits, server errors, auth failures). The canonical format is a top-level `fallback_providers:` list: ```yaml fallback_providers: - provider: openrouter model: anthropic/claude-sonnet-4 - provider: anthropic model: claude-sonnet-4 # base_url: http://localhost:8000/v1 # optional, for custom endpoints # api_mode: chat_completions # optional override ``` The legacy single-pair `fallback_model:` dict is still accepted for back-compat: ```yaml fallback_model: provider: openrouter model: anthropic/claude-sonnet-4 ``` When activated, the fallback swaps the model and provider mid-session without losing your conversation. The chain is tried entry-by-entry; activation is one-shot per session. Supported providers: `openrouter`, `novita`, `openai-codex`, `copilot`, `copilot-acp`, `anthropic`, `gemini`, `qwen-oauth`, `huggingface`, `zai`, `kimi-coding`, `kimi-coding-cn`, `minimax`, `minimax-cn`, `minimax-oauth`, `deepseek`, `nvidia`, `xai`, `xai-oauth`, `ollama-cloud`, `bedrock`, `azure-foundry`, `opencode-zen`, `opencode-go`, `kilocode`, `xiaomi`, `arcee`, `gmi`, `stepfun`, `lmstudio`, `alibaba`, `alibaba-coding-plan`, `tencent-tokenhub`, `custom`. :::tip Fallback is configured exclusively through `config.yaml` — or interactively via `claway fallback`. For full details on when it triggers, how the chain advances, and how it interacts with auxiliary tasks and delegation, see [Fallback Providers](/user-guide/features/fallback-providers). ::: --- ## See Also - [Configuration](/user-guide/configuration) — General configuration (directory structure, config precedence, terminal backends, memory, compression, and more) - [Environment Variables](/reference/environment-variables) — Complete reference of all environment variables --- <!-- source: website/docs/user-guide/features/mcp.md --> # MCP (Model Context Protocol) # MCP (Model Context Protocol) MCP lets Claway Agent connect to external tool servers so the agent can use tools that live outside Claway itself — GitHub, databases, file systems, browser stacks, internal APIs, and more. If you have ever wanted Claway to use a tool that already exists somewhere else, MCP is usually the cleanest way to do it. ## What MCP gives you - Access to external tool ecosystems without writing a native Claway tool first - Local stdio servers and remote HTTP MCP servers in the same config - Automatic tool discovery and registration at startup - Utility wrappers for MCP resources and prompts when supported by the server - Per-server filtering so you can expose only the MCP tools you actually want Claway to see ## Quick start 1. MCP support ships with the standard install — no extra step needed. 2. Add an MCP server to `~/.claway/config.yaml`: ```yaml mcp_servers: filesystem: command: "npx" args: ["-y", "@modelcontextprotocol/server-filesystem", "/home/user/projects"] ``` 3. Start Claway: ```bash claway chat ``` 4. Ask Claway to use the MCP-backed capability. For example: ```text List the files in /home/user/projects and summarize the repo structure. ``` Claway will discover the MCP server's tools and use them like any other tool. ## Catalog: one-click install for curated MCPs Claway ships a curated catalog of MCP servers that the maintainers have reviewed and merged. They're disabled by default — install only what you actually want. ```bash claway mcp # interactive picker (default) claway mcp catalog # plain-text list, scriptable claway mcp install n8n # install a catalog entry by name ``` The picker shows each entry with its current status: ``` n8n available Manage and inspect n8n workflows from Claway linear enabled Linear issue/project management (remote OAuth) github installed (disabled) GitHub repo + PR tools ``` Hit `Enter` on a row to install (and walk through any required credentials), enable, disable, or uninstall. Catalog entries are stored under `optional-mcps/` in the claway repo — presence in that directory means maintainer approval. There is no community submission tier; entries are added by merging a PR. Catalog entries can require: - **API key** — Claway prompts at install time and writes the value to `~/.claway/.env`. Non-secret values (base URLs) go to the same file. - **OAuth** (remote MCP) — written as `auth: oauth` in your config; the MCP client opens a browser on first connection. - **OAuth** (third-party provider like Google/GitHub) — Claway points you at `claway auth <provider>` if you haven't authenticated already. ### Tool selection at install time After credentials are configured, Claway probes the MCP server to list every tool it exposes and presents a checklist: ``` Select tools for 'linear' (SPACE toggle, ENTER confirm) [x] find_issues Find issues matching a query [x] get_issue Get a single issue [x] create_issue Create a new issue [ ] delete_workspace Delete a Linear workspace ... ``` The pre-checked rows come from: 1. **Your prior selection** if you've installed this entry before (reinstalls preserve what you had — the manifest's defaults don't override it) 2. **The manifest's `tools.default_enabled`** if the entry declares one (some catalog entries pre-prune mutating or rarely-useful tools) 3. **Everything** if neither applies Submit the checklist with ENTER. Only the checked tools end up in `mcp_servers.<name>.tools.include`. If you select everything, no filter is written (cleanest config shape, identical behavior). **If the probe fails** (server unreachable, OAuth not yet completed, backing service not running), the install still succeeds: the manifest's `tools.default_enabled` is applied directly (if declared), or no filter is written (if not). Re-run `claway mcp configure <name>` once the server is reachable to refine. ### Trust model Installing a catalog entry runs whatever the manifest specifies — `git clone`, the entry's `bootstrap` commands (`pip install`, `npm install`, etc.), and ultimately the MCP server's own code. Manifests are gated by PR review into the claway repo, so the maintainers have reviewed each entry before it shipped — **but you should still read the manifest before installing**, especially the `source:` field's repository, the `install.bootstrap:` commands, and any `transport.command:` invocation. Manifests live at `optional-mcps/<name>/manifest.yaml` on GitHub. The picker also prints the manifest's `source:` URL at install time so you can quickly verify the upstream repo. The web dashboard's MCP page surfaces the same detail per catalog entry — transport, auth type, the endpoint URL (HTTP) or command + args (stdio), the git install source/ref and bootstrap commands, and setup notes — with the `source:` rendered as a clickable link, so you can inspect exactly what an entry connects to or runs before clicking Install. ### Manifest version compatibility Manifests pin a `manifest_version`. The catalog is forward-compatible: if a PR adds an entry with a newer `manifest_version` than your installed Claway understands, the picker will surface a warning (`⚠ '<name>' requires a newer Claway`) for that entry instead of silently hiding it. Run `claway update` to install the latest Claway when you see that. ### Runtime `${ENV_VAR}` substitution Inside an entry's `transport.command`, `transport.args`, `transport.url`, and `headers`, `${VAR}` placeholders are resolved at server-connect time from environment variables (which include everything in `~/.claway/.env`). This is useful when a catalog entry wants to reference a value the user configured elsewhere — e.g. `${HOME}/foo` or `${MY_PROVIDER_TOKEN}`. Note this is distinct from `${INSTALL_DIR}` in catalog manifests, which is substituted at install-time with the path the catalog cloned the entry's repo into. ### Updating tool selection later ```bash claway mcp configure linear ``` Reopens the same checklist with your current selection pre-checked. Use this when you want more tools enabled, or when the server has added new tools that you want to opt into. ### Updating the catalog manifest MCPs are never auto-updated. Re-run `claway mcp install <name>` to refresh after a Claway update if a manifest version changed. To add an MCP to the catalog, open a PR against `optional-mcps/`. ## Two kinds of MCP servers ### Stdio servers Stdio servers run as local subprocesses and talk over stdin/stdout. ```yaml mcp_servers: github: command: "npx" args: ["-y", "@modelcontextprotocol/server-github"] env: GITHUB_PERSONAL_ACCESS_TOKEN: "***" ``` Use stdio servers when: - the server is installed locally - you want low-latency access to local resources - you are following MCP server docs that show `command`, `args`, and `env` ### HTTP servers HTTP MCP servers are remote endpoints Claway connects to directly. ```yaml mcp_servers: remote_api: url: "https://mcp.example.com/mcp" headers: Authorization: "Bearer ***" ``` Use HTTP servers when: - the MCP server is hosted elsewhere - your organization exposes internal MCP endpoints - you do not want Claway spawning a local subprocess for that integration ### OAuth-authenticated HTTP servers Most hosted MCP servers (Linear, Sentry, Atlassian, Asana, Figma, Stripe, …) require OAuth 2.1 instead of a static bearer token. Set `auth: oauth` and Claway handles discovery, dynamic client registration, PKCE, token exchange, refresh, and step-up auth via the MCP Python SDK. ```yaml mcp_servers: linear: url: "https://mcp.linear.app/mcp" auth: oauth ``` On first connect, Claway prints an authorize URL, opens your browser when possible, and waits for the OAuth callback on a local loopback port. Tokens are cached at `~/.claway/mcp-tokens/<server>.json` with 0o600 perms; subsequent runs reuse them silently until refresh fails. **Remote / headless hosts.** When Claway runs on a different machine than your browser, the loopback callback can't reach your laptop. Two ways to complete the flow: - **Paste-back (no setup):** on an interactive terminal Claway prints "Or paste the redirect URL here…" alongside the authorize URL. Open the URL in your browser, approve, copy the full URL the browser ends up on (the redirect will show a connection error — that's expected), paste it at the prompt. Bare `?code=…&state=…` query strings work too. - **SSH port forward:** `ssh -N -L <port>:127.0.0.1:<port> user@host` in a separate terminal, then let the redirect flow normally. See [OAuth over SSH / Remote Hosts](../../guides/oauth-over-ssh.md#mcp-servers) for the full walkthrough, including DCR-less servers (e.g. Slack), pre-registered `client_id`/`client_secret`, scope customization, and re-auth via `claway mcp login <server>`. **Pitfall — providers that don't support automatic registration (Google Drive, Atlassian).** Some servers reject the dynamic client registration step (RFC 7591) that bare `auth: oauth` relies on — Google's official Drive server (`https://drivemcp.googleapis.com/mcp/v1`) returns a `400 Bad Request`, so no OAuth client is created and no token is acquired. The symptom is subtle: these servers also serve `tools/list` *without* auth, so `claway mcp login` can list the tools and look like it worked, but every real tool call later times out. `claway mcp login` now detects this (it checks that a token actually landed on disk) and tells you to supply your own OAuth client. Create one in the provider's console and add it to config: ```yaml mcp_servers: googledrive: url: "https://drivemcp.googleapis.com/mcp/v1" auth: oauth oauth: client_id: "<your-oauth-client-id>" client_secret: "<your-oauth-client-secret>" ``` Then run `claway mcp login googledrive` — with the pre-registered client, Claway skips registration and runs the normal browser authorization flow. **Pitfall — config auto-reload race.** When you edit `~/.claway/config.yaml` from inside a running Claway session, the CLI auto-reloads MCP connections with a 30s timeout. That's not enough for an interactive OAuth flow. Add the entry, then run `claway mcp login <server>` from a fresh terminal — it waits the full 5 minutes for you to complete auth. ## mTLS / client certificates Remote HTTP MCP servers that require mutual TLS (client-certificate authentication) are supported via `client_cert` / `client_key`. Claway passes the resolved certificate to the underlying HTTP client for the TLS handshake. `client_cert` accepts three shapes: - **A single combined PEM path** — one file holding both the certificate and the private key: ```yaml mcp_servers: internal_api: url: "https://mcp.internal.example.com/mcp" client_cert: "~/.certs/mcp-client.pem" ``` - **A `[cert, key]` 2-tuple** — certificate and key in separate files (equivalent to setting `client_cert` + `client_key`): ```yaml mcp_servers: internal_api: url: "https://mcp.internal.example.com/mcp" client_cert: ["~/.certs/mcp-client.crt", "~/.certs/mcp-client.key"] ``` - **A `[cert, key, password]` 3-tuple** — when the private key is encrypted, the third element is the key passphrase: ```yaml mcp_servers: internal_api: url: "https://mcp.internal.example.com/mcp" client_cert: ["~/.certs/mcp-client.crt", "~/.certs/mcp-client.key", "${MCP_KEY_PASSWORD}"] ``` You can also keep the cert and key fully separate via `client_cert` (combined PEM) plus an explicit `client_key`. Paths support `~` expansion; a missing file raises a clear, server-scoped error rather than an opaque TLS handshake failure. ## Basic configuration reference Claway reads MCP config from `~/.claway/config.yaml` under `mcp_servers`. ### Common keys | Key | Type | Meaning | |---|---|---| | `command` | string | Executable for a stdio MCP server | | `args` | list | Arguments for the stdio server | | `env` | mapping | Environment variables passed to the stdio server | | `url` | string | HTTP MCP endpoint | | `headers` | mapping | HTTP headers for remote servers | | `client_cert` | string \| list | Client certificate for mTLS — a combined PEM path, or `[cert, key]` / `[cert, key, password]` | | `client_key` | string | Client private-key PEM path (when separate from `client_cert`) | | `timeout` | number | Tool call timeout | | `connect_timeout` | number | Initial connection timeout | | `enabled` | bool | If `false`, Claway skips the server entirely | | `supports_parallel_tool_calls` | bool | If `true`, tools from this server may run concurrently | | `tools` | mapping | Per-server tool filtering and utility policy | ### Minimal stdio example ```yaml mcp_servers: filesystem: command: "npx" args: ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"] ``` ### Minimal HTTP example ```yaml mcp_servers: company_api: url: "https://mcp.internal.example.com" headers: Authorization: "Bearer ***" ``` ## Built-in presets For well-known MCP servers, `claway mcp add` accepts a `--preset` flag that fills in the transport details so you don't have to look up the command and args. The preset only supplies defaults — anything else (env vars, headers, filtering) you pass on the same command line still wins. | Preset | What it wires up | |---|---| | `codex` | The Codex CLI's MCP server (`codex mcp-server` over stdio). Requires the `codex` CLI on PATH. | ```bash # Add Codex CLI as an MCP server in one line claway mcp add codex --preset codex ``` That writes the equivalent of: ```yaml mcp_servers: codex: command: "codex" args: ["mcp-server"] ``` You can pick any local name (`claway mcp add my-codex --preset codex` is fine); the preset only provides the `command`/`args` defaults. ## How Claway registers MCP tools Claway prefixes MCP tools so they do not collide with built-in names: ```text mcp_<server_name>_<tool_name> ``` Examples: | Server | MCP tool | Registered name | |---|---|---| | `filesystem` | `read_file` | `mcp_filesystem_read_file` | | `github` | `create-issue` | `mcp_github_create_issue` | | `my-api` | `query.data` | `mcp_my_api_query_data` | In practice, you usually do not need to call the prefixed name manually — Claway sees the tool and chooses it during normal reasoning. ## MCP utility tools When supported, Claway also registers utility tools around MCP resources and prompts: - `list_resources` - `read_resource` - `list_prompts` - `get_prompt` These are registered per server with the same prefix pattern, for example: - `mcp_github_list_resources` - `mcp_github_get_prompt` ### Important These utility tools are now capability-aware: - Claway only registers resource utilities if the MCP session actually supports resource operations - Claway only registers prompt utilities if the MCP session actually supports prompt operations So a server that exposes callable tools but no resources/prompts will not get those extra wrappers. ## Per-server filtering You can control which tools each MCP server contributes to Claway, allowing fine-grained management of your tool namespace. ### Disable a server entirely ```yaml mcp_servers: legacy: url: "https://mcp.legacy.internal" enabled: false ``` If `enabled: false`, Claway skips the server completely and does not even attempt a connection. ### Whitelist server tools ```yaml mcp_servers: github: command: "npx" args: ["-y", "@modelcontextprotocol/server-github"] env: GITHUB_PERSONAL_ACCESS_TOKEN: "***" tools: include: [create_issue, list_issues] ``` Only those MCP server tools are registered. ### Blacklist server tools ```yaml mcp_servers: stripe: url: "https://mcp.stripe.com" tools: exclude: [delete_customer] ``` All server tools are registered except the excluded ones. ### Precedence rule If both are present: ```yaml tools: include: [create_issue] exclude: [create_issue, delete_issue] ``` `include` wins. ### Filter utility tools too You can also separately disable Claway-added utility wrappers: ```yaml mcp_servers: docs: url: "https://mcp.docs.example.com" tools: prompts: false resources: false ``` That means: - `tools.resources: false` disables `list_resources` and `read_resource` - `tools.prompts: false` disables `list_prompts` and `get_prompt` ### Full example ```yaml mcp_servers: github: command: "npx" args: ["-y", "@modelcontextprotocol/server-github"] env: GITHUB_PERSONAL_ACCESS_TOKEN: "***" tools: include: [create_issue, list_issues, search_code] prompts: false stripe: url: "https://mcp.stripe.com" headers: Authorization: "Bearer ***" tools: exclude: [delete_customer] resources: false legacy: url: "https://mcp.legacy.internal" enabled: false ``` ## What happens if everything is filtered out? If your config filters out all callable tools and disables or omits all supported utilities, Claway does not create an empty runtime MCP toolset for that server. That keeps the tool list clean. ## Runtime behavior ### Discovery time Claway discovers MCP servers at startup and registers their tools into the normal tool registry. ### Dynamic Tool Discovery MCP servers can notify Claway when their available tools change at runtime by sending a `notifications/tools/list_changed` notification. When Claway receives this notification, it automatically re-fetches the server's tool list and updates the registry — no manual `/reload-mcp` required. This is useful for MCP servers whose capabilities change dynamically (e.g. a server that adds tools when a new database schema is loaded, or removes tools when a service goes offline). The refresh is lock-protected so rapid-fire notifications from the same server don't cause overlapping refreshes. Prompt and resource change notifications (`prompts/list_changed`, `resources/list_changed`) are received but not yet acted on. ### Reloading If you change MCP config, use: ```text /reload-mcp ``` This reloads MCP servers from config and refreshes the available tool list. For runtime tool changes pushed by the server itself, see [Dynamic Tool Discovery](#dynamic-tool-discovery) above. ### Toolsets Each configured MCP server also creates a runtime toolset when it contributes at least one registered tool: ```text mcp-<server> ``` That makes MCP servers easier to reason about at the toolset level. ## Security model ### Stdio env filtering For stdio servers, Claway does not blindly pass your full shell environment. Only explicitly configured `env` plus a safe baseline are passed through. This reduces accidental secret leakage. ### Config-level exposure control The new filtering support is also a security control: - disable dangerous tools you do not want the model to see - expose only a minimal whitelist for a sensitive server - disable resource/prompt wrappers when you do not want that surface exposed ## Example use cases ### GitHub server with a minimal issue-management surface ```yaml mcp_servers: github: command: "npx" args: ["-y", "@modelcontextprotocol/server-github"] env: GITHUB_PERSONAL_ACCESS_TOKEN: "***" tools: include: [list_issues, create_issue, update_issue] prompts: false resources: false ``` Use it like: ```text Show me open issues labeled bug, then draft a new issue for the flaky MCP reconnection behavior. ``` ### Stripe server with dangerous actions removed ```yaml mcp_servers: stripe: url: "https://mcp.stripe.com" headers: Authorization: "Bearer ***" tools: exclude: [delete_customer, refund_payment] ``` Use it like: ```text Look up the last 10 failed payments and summarize common failure reasons. ``` ### Filesystem server for a single project root ```yaml mcp_servers: project_fs: command: "npx" args: ["-y", "@modelcontextprotocol/server-filesystem", "/home/user/my-project"] ``` Use it like: ```text Inspect the project root and explain the directory layout. ``` ## Troubleshooting ### MCP server not connecting Check: ```bash # Verify MCP deps are installed (already included in standard install) cd ~/.claway/claway && uv pip install -e ".[mcp]" node --version npx --version ``` Then verify your config and restart Claway. ### Tools not appearing Possible causes: - the server failed to connect - discovery failed - your filter config excluded the tools - the utility capability does not exist on that server - the server is disabled with `enabled: false` If you are intentionally filtering, this is expected. ### Why didn't resource or prompt utilities appear? Because Claway now only registers those wrappers when both are true: 1. your config allows them 2. the server session actually supports the capability This is intentional and keeps the tool list honest. ## Parallel Tool Calls By default, MCP tools run sequentially — one at a time. If your MCP server exposes tools that are safe to run concurrently (e.g. read-only queries, independent API calls), you can opt-in to parallel execution: ```yaml mcp_servers: docs: command: "docs-server" supports_parallel_tool_calls: true ``` When `supports_parallel_tool_calls` is `true`, Claway may execute multiple tools from that server at the same time within a single tool-call batch, just like it does for built-in read-only tools (web_search, read_file, etc.). :::caution Only enable parallel calls for MCP servers whose tools are safe to run at the same time. If tools read and write shared state, files, databases, or external resources, review the read/write race conditions before enabling this setting. ::: ## MCP Sampling Support MCP servers can request LLM inference from Claway via the `sampling/createMessage` protocol. This allows an MCP server to ask Claway to generate text on its behalf — useful for servers that need LLM capabilities but don't have their own model access. Sampling is **enabled by default** for all MCP servers (when the MCP SDK supports it). Configure it per-server under the `sampling` key: ```yaml mcp_servers: my_server: command: "my-mcp-server" sampling: enabled: true # Enable sampling (default: true) model: "openai/gpt-4o" # Override model for sampling requests (optional) max_tokens_cap: 4096 # Max tokens per sampling response (default: 4096) timeout: 30 # Timeout in seconds per request (default: 30) max_rpm: 10 # Rate limit: max requests per minute (default: 10) max_tool_rounds: 5 # Max tool-use rounds in sampling loops (default: 5) allowed_models: [] # Allowlist of model names the server may request (empty = any) log_level: "info" # Audit log level: debug, info, or warning (default: info) ``` The sampling handler includes a sliding-window rate limiter, per-request timeouts, and tool-loop depth limits to prevent runaway usage. Metrics (request count, errors, tokens used) are tracked per server instance. To disable sampling for a specific server: ```yaml mcp_servers: untrusted_server: url: "https://mcp.example.com" sampling: enabled: false ``` ## Running Claway as an MCP server In addition to connecting **to** MCP servers, Claway can also **be** an MCP server. This lets other MCP-capable agents (Claude Code, Cursor, Codex, or any MCP client) use Claway's messaging capabilities — list conversations, read message history, and send messages across all your connected platforms. ### When to use this - You want Claude Code, Cursor, or another coding agent to send and read Telegram/Discord/Slack messages through Claway - You want a single MCP server that bridges to all of Claway's connected messaging platforms at once - You already have a running Claway gateway with connected platforms ### Quick start ```bash claway mcp serve ``` This starts a stdio MCP server. The MCP client (not you) manages the process lifecycle. ### MCP client configuration Add Claway to your MCP client config. For example, in Claude Code's `~/.claude/claude_desktop_config.json`: ```json { "mcpServers": { "claway": { "command": "claway", "args": ["mcp", "serve"] } } } ``` Or if you installed Claway in a specific location: ```json { "mcpServers": { "claway": { "command": "/home/user/.claway/claway/venv/bin/claway", "args": ["mcp", "serve"] } } } ``` ### Available tools The MCP server exposes 10 tools, matching OpenClaw's channel bridge surface plus a Claway-specific channel browser: | Tool | Description | |------|-------------| | `conversations_list` | List active messaging conversations. Filter by platform or search by name. | | `conversation_get` | Get detailed info about one conversation by session key. | | `messages_read` | Read recent message history for a conversation. | | `attachments_fetch` | Extract non-text attachments (images, media) from a specific message. | | `events_poll` | Poll for new conversation events since a cursor position. | | `events_wait` | Long-poll / block until the next event arrives (near-real-time). | | `messages_send` | Send a message through a platform (e.g. `telegram:123456`, `discord:#general`). | | `channels_list` | List available messaging targets across all platforms. | | `permissions_list_open` | List pending approval requests observed during this bridge session. | | `permissions_respond` | Allow or deny a pending approval request. | ### Event system The MCP server includes a live event bridge that polls Claway's session database for new messages. This gives MCP clients near-real-time awareness of incoming conversations: ``` # Poll for new events (non-blocking) events_poll(after_cursor=0) # Wait for next event (blocks up to timeout) events_wait(after_cursor=42, timeout_ms=30000) ``` Event types: `message`, `approval_requested`, `approval_resolved` The event queue is in-memory and starts when the bridge connects. Older messages are available through `messages_read`. ### Options ```bash claway mcp serve # Normal mode claway mcp serve --verbose # Debug logging on stderr ``` ### How it works The MCP server reads conversation data directly from Claway's session store (`~/.claway/sessions/sessions.json` and the SQLite database). A background thread polls the database for new messages and maintains an in-memory event queue. For sending messages, it uses the same internal send engine (`tools/send_message_tool.py`) that powers cron delivery and the `claway send` CLI. The gateway does NOT need to be running for read operations (listing conversations, reading history, polling events). It DOES need to be running for send operations, since the platform adapters need active connections. ### Current limits - The embedded `claway mcp serve` exposes a **stdio-only** MCP server today. If you need an HTTP MCP server, run a separate adapter — or, much more commonly, use the MCP **client** side of Claway, which already speaks both stdio and HTTP (`url` + `headers` in `mcp_servers.yaml` / `config.yaml`; see [HTTP servers](#http-servers) above). - Event polling at ~200ms intervals via mtime-optimized DB polling (skips work when files are unchanged) - No `claude/channel` push notification protocol yet - Text-only sends (no media/attachment sending through `messages_send`) ## Related docs - [Use MCP with Claway](/guides/use-mcp-with-claway) - [CLI Commands](/reference/cli-commands) - [Slash Commands](/reference/slash-commands) - [FAQ](/reference/faq) --- <!-- source: website/docs/user-guide/features/fallback-providers.md --> # user-guide/features/fallback-providers # Fallback Providers Claway Agent has three layers of resilience that keep your sessions running when providers hit issues: 1. **[Credential pools](./credential-pools.md)** — rotate across multiple API keys for the *same* provider (tried first) 2. **Primary model fallback** — automatically switches to a *different* provider:model when your main model fails 3. **Auxiliary task fallback** — independent provider resolution for side tasks like vision, compression, and web extraction Credential pools handle same-provider rotation (e.g., multiple OpenRouter keys). This page covers cross-provider fallback. Both are optional and work independently. ## Primary Model Fallback When your main LLM provider encounters errors — rate limits, server overload, auth failures, connection drops — Claway can automatically switch to a backup provider:model pair mid-session without losing your conversation. ### Configuration The easiest path is the interactive manager: ```bash claway fallback ``` `claway fallback` reuses the provider picker from `claway model` — same provider list, same credential prompts, same validation. Use the subcommands `add`, `list` (alias `ls`), `remove` (alias `rm`), and `clear` to manage the chain. Changes persist under the top-level `fallback_providers:` list in `config.yaml`. If you'd rather edit the YAML directly, add a top-level `fallback_providers` list to `~/.claway/config.yaml`: ```yaml fallback_providers: - provider: openrouter model: anthropic/claude-sonnet-4 ``` Each entry requires both `provider` and `model`. Entries missing either field are ignored. :::note `fallback_model` vs `fallback_providers` `fallback_providers` (plural, list) is the current config shape and supports multiple fallbacks tried in order. `fallback_model` (singular) is the legacy single-fallback key — Claway still honors it for back-compat, but `claway fallback` writes the current `fallback_providers` key and migrates legacy config on write. When both are set, `fallback_providers` takes priority. ::: ### Supported Providers | Provider | Value | Requirements | |----------|-------|-------------| | OpenRouter | `openrouter` | `OPENROUTER_API_KEY` | | OpenAI Codex | `openai-codex` | `claway model` (ChatGPT OAuth) | | GitHub Copilot | `copilot` | `COPILOT_GITHUB_TOKEN`, `GH_TOKEN`, or `GITHUB_TOKEN` | | GitHub Copilot ACP | `copilot-acp` | External process (editor integration) | | Anthropic | `anthropic` | `ANTHROPIC_API_KEY` or Claude Code credentials | | z.ai / GLM | `zai` | `GLM_API_KEY` | | Kimi / Moonshot | `kimi-coding` | `KIMI_API_KEY` | | MiniMax | `minimax` | `MINIMAX_API_KEY` | | MiniMax (China) | `minimax-cn` | `MINIMAX_CN_API_KEY` | | DeepSeek | `deepseek` | `DEEPSEEK_API_KEY` | | NVIDIA NIM | `nvidia` | `NVIDIA_API_KEY` (optional: `NVIDIA_BASE_URL`) | | GMI Cloud | `gmi` | `GMI_API_KEY` (optional: `GMI_BASE_URL`) | | StepFun | `stepfun` | `STEPFUN_API_KEY` (optional: `STEPFUN_BASE_URL`) | | Ollama Cloud | `ollama-cloud` | `OLLAMA_API_KEY` | | Google AI Studio | `gemini` | `GOOGLE_API_KEY` (alias: `GEMINI_API_KEY`) | | xAI (Grok) | `xai` (alias `grok`) | `XAI_API_KEY` (optional: `XAI_BASE_URL`) | | xAI Grok OAuth (SuperGrok) | `xai-oauth` (alias `grok-oauth`) | `claway model` → xAI Grok OAuth (browser login; SuperGrok subscription) | | AWS Bedrock | `bedrock` | Standard boto3 auth (`AWS_REGION` + `AWS_PROFILE` or `AWS_ACCESS_KEY_ID`) | | Qwen Portal (OAuth) | `qwen-oauth` | `claway model` (Qwen Portal OAuth; optional: `CLAWAY_QWEN_BASE_URL`) | | MiniMax (OAuth) | `minimax-oauth` | `claway model` (MiniMax portal OAuth) | | OpenCode Zen | `opencode-zen` | `OPENCODE_ZEN_API_KEY` | | OpenCode Go | `opencode-go` | `OPENCODE_GO_API_KEY` | | Kilo Code | `kilocode` | `KILOCODE_API_KEY` | | Xiaomi MiMo | `xiaomi` | `XIAOMI_API_KEY` | | Arcee AI | `arcee` | `ARCEEAI_API_KEY` | | GMI Cloud | `gmi` | `GMI_API_KEY` | | Alibaba / DashScope | `alibaba` | `DASHSCOPE_API_KEY` | | Alibaba Coding Plan | `alibaba-coding-plan` | `ALIBABA_CODING_PLAN_API_KEY` (falls back to `DASHSCOPE_API_KEY`) | | Kimi / Moonshot (China) | `kimi-coding-cn` | `KIMI_CN_API_KEY` | | StepFun | `stepfun` | `STEPFUN_API_KEY` | | Tencent TokenHub | `tencent-tokenhub` | `TOKENHUB_API_KEY` | | Microsoft Foundry | `azure-foundry` | `AZURE_FOUNDRY_API_KEY` + `AZURE_FOUNDRY_BASE_URL` | | LM Studio (local) | `lmstudio` | `LM_API_KEY` (or none for local) + `LM_BASE_URL` | | Hugging Face | `huggingface` | `HF_TOKEN` | | Custom endpoint | `custom` | `base_url` + `key_env` (see below) | ### Custom Endpoint Fallback For a custom OpenAI-compatible endpoint, add `base_url` and optionally `key_env`: ```yaml fallback_providers: - provider: custom model: my-local-model base_url: http://localhost:8000/v1 key_env: MY_LOCAL_KEY # env var name containing the API key ``` ### When Fallback Triggers The fallback activates automatically when the primary model fails with: - **Rate limits** (HTTP 429) — after exhausting retry attempts - **Server errors** (HTTP 500, 502, 503) — after exhausting retry attempts - **Auth failures** (HTTP 401, 403) — immediately (no point retrying) - **Not found** (HTTP 404) — immediately - **Invalid responses** — when the API returns malformed or empty responses repeatedly When triggered, Claway: 1. Resolves credentials for the fallback provider 2. Builds a new API client 3. Swaps the model, provider, and client in-place 4. Resets the retry counter and continues the conversation The switch is seamless — your conversation history, tool calls, and context are preserved. The agent continues from exactly where it left off, just using a different model. :::info Per-Turn, Not Per-Session Fallback is **turn-scoped**: each new user message starts with the primary model restored. If the primary fails mid-turn, fallback activates for that turn only. On the next message, Claway tries the primary again. Within a single turn, fallback activates at most once — if the fallback also fails, normal error handling takes over (retries, then error message). This prevents cascading failover loops within a turn while giving the primary model a fresh chance every turn. ::: ### Examples **OpenRouter as fallback for Anthropic native:** ```yaml model: provider: anthropic default: claude-sonnet-4-6 fallback_providers: - provider: openrouter model: anthropic/claude-sonnet-4 ``` **Local model as fallback for cloud:** ```yaml fallback_providers: - provider: custom model: llama-3.1-70b base_url: http://localhost:8000/v1 key_env: LOCAL_API_KEY ``` **Codex OAuth as fallback:** ```yaml fallback_providers: - provider: openai-codex model: gpt-5.3-codex ``` ### Where Fallback Works | Context | Fallback Supported | |---------|-------------------| | CLI sessions | ✔ | | Messaging gateway (Telegram, Discord, etc.) | ✔ | | Subagent delegation | ✔ (subagents inherit the parent fallback chain) | | Cron jobs | ✔ (cron agents inherit configured fallback providers) | | Auxiliary tasks on `provider: auto` | ✔ (try per-task fallback, then the main fallback chain before built-in aux discovery) | :::tip There are no environment variables for the primary fallback chain — configure it exclusively through `config.yaml` or `claway fallback`. This is intentional: fallback configuration is a deliberate choice, not something a stale shell export should override. ::: --- ## Auxiliary Task Fallback Claway uses separate lightweight models for side tasks. Each task has its own provider resolution chain that acts as a built-in fallback system. ### Tasks with Independent Provider Resolution | Task | What It Does | Config Key | |------|-------------|-----------| | Vision | Image analysis, browser screenshots | `auxiliary.vision` | | Web Extract | Web page summarization | `auxiliary.web_extract` | | Compression | Context compression summaries | `auxiliary.compression` | | Skills Hub | Skill search and discovery | `auxiliary.skills_hub` | | MCP | MCP helper operations | `auxiliary.mcp` | | Approval | Smart command-approval classification | `auxiliary.approval` | | Title Generation | Session title summaries | `auxiliary.title_generation` | | Triage Specifier | `claway kanban specify` / dashboard ✨ button — fleshes out a one-liner triage task into a real spec | `auxiliary.triage_specifier` | ### Auto-Detection Chain When a task's provider is set to `"auto"` (the default), Claway first tries the main provider + main model for that auxiliary task. If that route is unavailable or later fails with a capacity-style error, Claway now honors user-configured fallback policy before using the built-in discovery chain: ```text Main provider + main model → auxiliary.<task>.fallback_chain → fallback_providers / fallback_model → built-in auxiliary discovery chain ``` The task-specific chain is most precise and wins when present. The top-level `fallback_providers` chain is the same policy the main agent uses, so free-only or same-provider fallback rules apply to auxiliary tasks on `auto` as well. **Built-in text discovery chain (compression, web extract, title generation, etc.):** ```text OpenRouter → Custom endpoint → Codex OAuth → API-key providers (z.ai, Kimi, MiniMax, Xiaomi MiMo, Hugging Face, Anthropic) → give up ``` **Built-in vision discovery chain:** ```text Main provider (if vision-capable) → OpenRouter → Codex OAuth → Anthropic → Custom endpoint → give up ``` Those built-in chains are a convenience fallback for users who have not declared a task-specific or main fallback policy. ### Configuring Auxiliary Providers Each task can be configured independently in `config.yaml`: ```yaml auxiliary: vision: provider: "auto" # auto | openrouter | codex | main | anthropic model: "" # e.g. "openai/gpt-4o" base_url: "" # direct endpoint (takes precedence over provider) api_key: "" # API key for base_url web_extract: provider: "auto" model: "" compression: provider: "auto" model: "" fallback_chain: # optional, task-specific fallback policy - provider: openrouter model: inclusionai/ring-2.6-1t:free skills_hub: provider: "auto" model: "" mcp: provider: "auto" model: "" ``` Every task above follows the same **provider / model / base_url** pattern. Each task can also declare its own `fallback_chain`; if omitted, `provider: auto` uses the top-level `fallback_providers` chain before Claway's built-in auxiliary discovery chain. Context compression is configured under `auxiliary.compression`: ```yaml auxiliary: compression: provider: main # Same provider options as other auxiliary tasks model: google/gemini-3-flash-preview base_url: null # Custom OpenAI-compatible endpoint ``` And the primary fallback chain uses: ```yaml fallback_providers: - provider: openrouter model: anthropic/claude-sonnet-4 # base_url: http://localhost:8000/v1 # Optional custom endpoint ``` All three — auxiliary, compression, fallback — work the same way: set `provider` to pick who handles the request, `model` to pick which model, and `base_url` to point at a custom endpoint (overrides provider). ### Provider Options for Auxiliary Tasks These options apply to `auxiliary:`, `compression:`, and `fallback_providers:` entries only — `"main"` is **not** a valid value for your top-level `model.provider`. For custom endpoints, use `provider: custom` in your `model:` section (see [AI Providers](/integrations/providers)). | Provider | Description | Requirements | |----------|-------------|-------------| | `"auto"` | Try providers in order until one works (default) | At least one provider configured | | `"openrouter"` | Force OpenRouter | `OPENROUTER_API_KEY` | | `"codex"` | Force Codex OAuth | `claway model` → Codex | | `"main"` | Use whatever provider the main agent uses (auxiliary tasks only) | Active main provider configured | | `"anthropic"` | Force Anthropic native | `ANTHROPIC_API_KEY` or Claude Code credentials | ### Direct Endpoint Override For any auxiliary task, setting `base_url` bypasses provider resolution entirely and sends requests directly to that endpoint: ```yaml auxiliary: vision: base_url: "http://localhost:1234/v1" api_key: "local-key" model: "qwen2.5-vl" ``` `base_url` takes precedence over `provider`. Claway uses the configured `api_key` for authentication, falling back to `OPENAI_API_KEY` if not set. It does **not** reuse `OPENROUTER_API_KEY` for custom endpoints. --- ## Auxiliary Capacity-Error Fallback When you set an explicit auxiliary provider (e.g. `auxiliary.vision.provider: glm`), Claway treats that as your preferred choice — but if the provider literally cannot serve the request because of a **capacity error** (HTTP 402 payment required, HTTP 429 daily-quota exhaustion, connection failure), Claway falls back through a layered chain instead of failing silently: 1. **Primary aux provider** — the one you configured (tried first, always) 2. **`auxiliary.<task>.fallback_chain`** — your per-task override list, if you wrote one 3. **Main agent provider + model** — last-resort safety net (always tried, even if you didn't write a chain) 4. **Warn + re-raise** — if every layer fails, Claway logs `Auxiliary <task>: ... all fallbacks exhausted` at WARNING level and re-raises the original error Transient HTTP 429 rate limits (`Retry-After: ...`) are treated as request constraints, not capacity problems — they respect your explicit provider choice and do **not** trigger the fallback ladder. Only daily/monthly quota exhaustion, payment errors, and connection failures bypass the explicit-provider gate. For users on `provider: auto` (no explicit aux provider), the existing auto-detection chain runs in place of steps 2–3. Its first step is already the main agent model, so `auto` users get the same outcome with zero config. ### Optional: per-task fallback chain If you want a different fallback ordering than "main agent model first", configure `fallback_chain` explicitly. Each entry needs at least `provider`; `model`, `base_url`, and `api_key` are optional. ```yaml auxiliary: vision: provider: glm model: glm-4v-flash fallback_chain: - provider: openrouter model: google/gemini-3-flash-preview - provider: openrouter model: anthropic/claude-sonnet-4 compression: provider: openrouter fallback_chain: - provider: openai model: gpt-4o-mini ``` You do **not** need to configure `fallback_chain` to get fallback — the main-agent safety net runs regardless. Use it only when you specifically want a different order than the default. ### Provider quota errors that trigger fallback Claway recognizes these as capacity-equivalent to 402 credit exhaustion (not transient rate limits): - Bedrock / LiteLLM: `Too many tokens per day`, `daily limit`, `tokens per day` - Vertex AI / GCP: `quota exceeded`, `resource exhausted`, `RESOURCE_EXHAUSTED` - Generic: `daily quota`, `quota_exceeded` If your provider returns a different phrase for daily-quota exhaustion and Claway doesn't trigger fallback, that's a bug: email support@claway.io with the exact error string. --- ## Context Compression Fallback Context compression uses the `auxiliary.compression` config block to control which model and provider handles summarization: ```yaml auxiliary: compression: provider: "auto" # auto | openrouter | main model: "google/gemini-3-flash-preview" ``` :::info Legacy migration Older configs with `compression.summary_model` / `compression.summary_provider` / `compression.summary_base_url` are automatically migrated to `auxiliary.compression.*` on first load (config version 17). ::: If no provider is available for compression, Claway drops middle conversation turns without generating a summary rather than failing the session. --- ## Delegation Provider Override Subagents spawned by `delegate_task` inherit the parent agent's primary fallback chain. You can still route subagents to a different primary provider:model pair for cost optimization: ```yaml delegation: provider: "openrouter" # override provider for all subagents model: "google/gemini-3-flash-preview" # override model # base_url: "http://localhost:1234/v1" # or use a direct endpoint # api_key: "local-key" ``` See [Subagent Delegation](/user-guide/features/delegation) for full configuration details. --- ## Cron Job Providers Cron jobs inherit your configured `fallback_providers` chain (or legacy `fallback_model`) when they create an agent. To use a different primary provider for a cron job, configure `provider` and `model` overrides on the cron job itself: ```python cronjob( action="create", schedule="every 2h", prompt="Check server status", provider="openrouter", model="google/gemini-3-flash-preview" ) ``` See [Scheduled Tasks (Cron)](/user-guide/features/cron) for full configuration details. --- ## Summary | Feature | Fallback Mechanism | Config Location | |---------|-------------------|----------------| | Main agent model | `fallback_providers` in config.yaml — per-turn failover on errors (primary restored each turn) | `fallback_providers:` (top-level list) | | Auxiliary tasks (any) — auto users | Full auto-detection chain (main agent model first, then provider chain) on capacity errors | `auxiliary.<task>.provider: auto` | | Auxiliary tasks (any) — explicit provider | `fallback_chain` (if set) → main agent model → warn + raise, on capacity errors only | `auxiliary.<task>.fallback_chain` | | Vision | Layered (see above) + internal OpenRouter retry | `auxiliary.vision` | | Web extraction | Layered (see above) + internal OpenRouter retry | `auxiliary.web_extract` | | Context compression | Layered (see above); degrades to no-summary if all layers unavailable | `auxiliary.compression` | | Skills hub | Layered (see above) | `auxiliary.skills_hub` | | MCP helpers | Layered (see above) | `auxiliary.mcp` | | Approval classification | Layered (see above) | `auxiliary.approval` | | Title generation | Layered (see above) | `auxiliary.title_generation` | | Triage specifier | Layered (see above) | `auxiliary.triage_specifier` | | Delegation | Provider override only (no automatic fallback) | `delegation.provider` / `delegation.model` | | Cron jobs | Per-job provider override only (no automatic fallback) | Per-job `provider` / `model` | --- <!-- source: website/docs/guides/tips.md --> # Tips & Best Practices # Tips & Best Practices A quick-wins collection of practical tips that make you immediately more effective with Claway Agent. Each section targets a different aspect — scan the headers and jump to what's relevant. --- ## Getting the Best Results ### Be Specific About What You Want Vague prompts produce vague results. Instead of "fix the code," say "fix the TypeError in `api/handlers.py` on line 47 — the `process_request()` function receives `None` from `parse_body()`." The more context you give, the fewer iterations you need. ### Provide Context Up Front Front-load your request with the relevant details: file paths, error messages, expected behavior. One well-crafted message beats three rounds of clarification. Paste error tracebacks directly — the agent can parse them. ### Use Context Files for Recurring Instructions If you find yourself repeating the same instructions ("use tabs not spaces," "we use pytest," "the API is at `/api/v2`"), put them in an `AGENTS.md` file. The agent reads it automatically every session — zero effort after setup. ### Let the Agent Use Its Tools Don't try to hand-hold every step. Say "find and fix the failing test" rather than "open `tests/test_foo.py`, look at line 42, then..." The agent has file search, terminal access, and code execution — let it explore and iterate. ### Use Skills for Complex Workflows Before writing a long prompt explaining how to do something, check if there's already a skill for it. Type `/skills` to browse available skills, or just invoke one directly like `/axolotl` or `/github-pr-workflow`. ## CLI Power User Tips ### Multi-Line Input Press **Alt+Enter**, **Ctrl+J**, or **Shift+Enter** to insert a newline without sending. `Shift+Enter` only works when the terminal sends it as a distinct keystroke (Kitty / foot / WezTerm / Ghostty by default; iTerm2 / Alacritty / VS Code terminal once the Kitty keyboard protocol is enabled). The other two work in every terminal. ### Paste Detection The CLI auto-detects multi-line pastes. Just paste a code block or error traceback directly — it won't send each line as a separate message. The paste is buffered and sent as one message. ### Interrupt and Redirect Press **Ctrl+C** once to interrupt the agent mid-response. You can then type a new message to redirect it. Double-press Ctrl+C within 2 seconds to force exit. This is invaluable when the agent starts going down the wrong path. ### Resume Sessions with `-c` Forgot something from your last session? Run `claway -c` to resume exactly where you left off, with full conversation history restored. You can also resume by title: `claway -r "my research project"`. ### Clipboard Image Paste Press **Ctrl+V** to paste an image from your clipboard directly into the chat. The agent uses vision to analyze screenshots, diagrams, error popups, or UI mockups — no need to save to a file first. ### Slash Command Autocomplete Type `/` and press **Tab** to see all available commands. This includes built-in commands (`/compress`, `/model`, `/title`) and every installed skill. You don't need to memorize anything — Tab completion has you covered. :::tip Use `/verbose` to cycle through tool output display modes: **off → new → all → verbose**. The "all" mode is great for watching what the agent does; "off" is cleanest for simple Q&A. ::: ## Context Files ### AGENTS.md: Your Project's Brain Create an `AGENTS.md` in your project root with architecture decisions, coding conventions, and project-specific instructions. This is automatically injected into every session, so the agent always knows your project's rules. ```markdown # Project Context - This is a FastAPI backend with SQLAlchemy ORM - Always use async/await for database operations - Tests go in tests/ and use pytest-asyncio - Never commit .env files ``` ### SOUL.md: Customize Personality Want Claway to have a stable default voice? Edit `~/.claway/SOUL.md` (or `$CLAWAY_HOME/SOUL.md` if you use a custom Claway home). Claway now seeds a starter SOUL automatically and uses that global file as the instance-wide personality source. For a full walkthrough, see [Use SOUL.md with Claway](/guides/use-soul-with-claway). ```markdown # Soul You are a senior backend engineer. Be terse and direct. Skip explanations unless asked. Prefer one-liners over verbose solutions. Always consider error handling and edge cases. ``` Use `SOUL.md` for durable personality. Use `AGENTS.md` for project-specific instructions. ### .cursorrules Compatibility Already have a `.cursorrules` or `.cursor/rules/*.mdc` file? Claway reads those too. No need to duplicate your coding conventions — they're loaded automatically from the working directory. ### Discovery Claway loads the top-level `AGENTS.md` from the current working directory at session start. Subdirectory `AGENTS.md` files are discovered lazily during tool calls (via `subdirectory_hints.py`) and injected into tool results — they are not loaded upfront into the system prompt. :::tip Keep context files focused and concise. Every character counts against your token budget since they're injected into every single message. ::: ## Memory & Skills ### Memory vs. Skills: What Goes Where **Memory** is for facts: your environment, preferences, project locations, and things the agent has learned about you. **Skills** are for procedures: multi-step workflows, tool-specific instructions, and reusable recipes. Use memory for "what," skills for "how." ### When to Create Skills If you find a task that takes 5+ steps and you'll do it again, ask the agent to create a skill for it. Say "save what you just did as a skill called `deploy-staging`." Next time, just type `/deploy-staging` and the agent loads the full procedure. ### Managing Memory Capacity Memory is intentionally bounded (~2,200 chars for MEMORY.md, ~1,375 chars for USER.md). When it fills up, the agent consolidates entries. You can help by saying "clean up your memory" or "replace the old Python 3.9 note — we're on 3.12 now." ### Let the Agent Remember After a productive session, say "remember this for next time" and the agent will save the key takeaways. You can also be specific: "save to memory that our CI uses GitHub Actions with the `deploy.yml` workflow." :::warning Memory is a frozen snapshot — changes made during a session don't appear in the system prompt until the next session starts. The agent writes to disk immediately, but the prompt cache isn't invalidated mid-session. ::: ## Performance & Cost ### Don't Break the Prompt Cache Most LLM providers cache the system prompt prefix. If you keep your system prompt stable (same context files, same memory), subsequent messages in a session get **cache hits** that are significantly cheaper. Avoid changing the model or system prompt mid-session. ### Use /compress Before Hitting Limits Long sessions accumulate tokens. When you notice responses slowing down or getting truncated, run `/compress`. This summarizes the conversation history, preserving key context while dramatically reducing token count. Use `/usage` to check where you stand. ### Delegate for Parallel Work Need to research three topics at once? Ask the agent to use `delegate_task` with parallel subtasks. Each subagent runs independently with its own context, and only the final summaries come back — massively reducing your main conversation's token usage. ### Use execute_code for Batch Operations Instead of running terminal commands one at a time, ask the agent to write a script that does everything at once. "Write a Python script to rename all `.jpeg` files to `.jpg` and run it" is cheaper and faster than renaming files individually. ### Choose the Right Model Use `/model` to switch models mid-session. Use a frontier model (Claude Sonnet/Opus, GPT-4o) for complex reasoning and architecture decisions. Switch to a faster model for simple tasks like formatting, renaming, or boilerplate generation. :::tip Run `/usage` periodically to see your token consumption. Run `/insights` for a broader view of usage patterns over the last 30 days. ::: ## Messaging Tips ### Set a Home Channel Use `/sethome` in your preferred Telegram or Discord chat to designate it as the home channel. Cron job results and scheduled task outputs are delivered here. Without it, the agent has nowhere to send proactive messages. ### Use /title to Organize Sessions Name your sessions with `/title auth-refactor` or `/title research-llm-quantization`. Named sessions are easy to find with `claway sessions list` and resume with `claway -r "auth-refactor"`. Unnamed sessions pile up and become impossible to distinguish. ### DM Pairing for Team Access Instead of manually collecting user IDs for allowlists, enable DM pairing. When a teammate DMs the bot, they get a one-time pairing code. You approve it with `claway pairing approve telegram XKGH5N7P` — simple and secure. ### Tool Progress Display Modes Use `/verbose` to control how much tool activity you see. In messaging platforms, less is usually more — keep it on "new" to see just new tool calls. In the CLI, "all" gives you a satisfying live view of everything the agent does. :::tip On messaging platforms, sessions auto-reset after idle time (default: 24 hours) or daily at 4 AM. Adjust per-platform in `~/.claway/config.yaml` if you need longer sessions. ::: ## Security ### Use Docker for Untrusted Code When working with untrusted repositories or running unfamiliar code, use Docker or Daytona as your terminal backend. Set `TERMINAL_BACKEND=docker` in your `.env`. Destructive commands inside a container can't harm your host system. ```bash # In your .env: TERMINAL_BACKEND=docker TERMINAL_DOCKER_IMAGE=claway-sandbox:latest ``` ### Avoid Windows Encoding Pitfalls On Windows, some default encodings (such as `cp125x`) cannot represent all Unicode characters, which can cause `UnicodeEncodeError` when writing files in tests or scripts. - Prefer opening files with an explicit UTF-8 encoding: ```python with open("results.txt", "w", encoding="utf-8") as f: f.write("✓ All good\n") ``` - In PowerShell, you can also switch the current session to UTF-8 for console and native command output: ```powershell $OutputEncoding = [Console]::OutputEncoding = [Text.UTF8Encoding]::new($false) ``` This keeps PowerShell and child processes on UTF-8 and helps avoid Windows-only failures. ### Review Before Choosing "Always" When the agent triggers a dangerous command approval (`rm -rf`, `DROP TABLE`, etc.), you get four options: **once**, **session**, **always**, **deny**. Think carefully before choosing "always" — it permanently allowlists that pattern. Start with "session" until you're comfortable. ### Command Approval Is Your Safety Net Claway checks every command against a curated list of dangerous patterns before execution. This includes recursive deletes, SQL drops, piping curl to shell, and more. Don't disable this in production — it exists for good reasons. :::warning When running in a container backend (Docker, Singularity, Modal, Daytona), dangerous command checks are **skipped** because the container is the security boundary. Make sure your container images are properly locked down. ::: ### Use Allowlists for Messaging Bots Never set `GATEWAY_ALLOW_ALL_USERS=true` on a bot with terminal access. Always use platform-specific allowlists (`TELEGRAM_ALLOWED_USERS`, `DISCORD_ALLOWED_USERS`) or DM pairing to control who can interact with your agent. ```bash # Recommended: explicit allowlists per platform TELEGRAM_ALLOWED_USERS=123456789,987654321 DISCORD_ALLOWED_USERS=123456789012345678 # Or use cross-platform allowlist GATEWAY_ALLOWED_USERS=123456789,987654321 ``` --- *Have a tip that should be on this page? Open an issue or PR — community contributions are welcome.* --- <!-- source: website/docs/guides/daily-briefing-bot.md --> # Tutorial: Daily Briefing Bot # Tutorial: Build a Daily Briefing Bot In this tutorial, you'll build a personal briefing bot that wakes up every morning, researches topics you care about, summarizes the findings, and delivers a concise briefing straight to your Telegram or Discord. By the end, you'll have a fully automated workflow combining **web search**, **cron scheduling**, **delegation**, and **messaging delivery** — no code required. ## What We're Building Here's the flow: 1. **8:00 AM** — The cron scheduler triggers your job 2. **Claway spins up** a fresh agent session with your prompt 3. **Web search** pulls the latest news on your topics 4. **Summarization** distills it into a clean briefing format 5. **Delivery** sends the briefing to your Telegram or Discord The whole thing runs hands-free. You just read your briefing with your morning coffee. ## Prerequisites Before starting, make sure you have: - **Claway Agent installed** — see the [Installation guide](/getting-started) - **Gateway running** — the gateway daemon handles cron execution: ```bash claway gateway install # Install as a user service sudo claway gateway install --system # Linux servers: boot-time system service # or claway gateway # Run in foreground ``` - **Firecrawl API key** — set `FIRECRAWL_API_KEY` in your environment for web search - **Messaging configured** (optional but recommended) — [Telegram](/user-guide/messaging/telegram) or Discord set up with a home channel :::tip No messaging? No problem You can still follow this tutorial using `deliver: "local"`. Briefings will be saved to `~/.claway/cron/output/` and you can read them anytime. ::: ## Step 1: Test the Workflow Manually Before automating anything, let's make sure the briefing works. Start a chat session: ```bash claway ``` Then enter this prompt: ``` Search for the latest news about AI agents and open source LLMs. Summarize the top 3 stories in a concise briefing format with links. ``` Claway will search the web, read through results, and produce something like: ``` ☀️ Your AI Briefing — March 8, 2026 1. Qwen 3 Released with 235B Parameters Alibaba's latest open-weight model matches GPT-4.5 on several benchmarks while remaining fully open source. → https://qwenlm.github.io/blog/qwen3/ 2. LangChain Launches Agent Protocol Standard A new open standard for agent-to-agent communication gains adoption from 15 major frameworks in its first week. → https://blog.langchain.dev/agent-protocol/ 3. EU AI Act Enforcement Begins for General-Purpose Models The first compliance deadlines hit, with open source models receiving exemptions under the 10M parameter threshold. → https://artificialintelligenceact.eu/updates/ --- 3 stories • Sources searched: 8 • Generated by Claway Agent ``` If this works, you're ready to automate it. :::tip Iterate on the format Try different prompts until you get output you love. Add instructions like "use emoji headers" or "keep each summary under 2 sentences." Whatever you settle on goes into the cron job. ::: ## Step 2: Create the Cron Job Now let's schedule this to run automatically every morning. You can do this in two ways. Before creating cron jobs, ensure Claway has a default model and provider configured globally. If you want a specific job to use different values, set explicit per-job model/provider overrides when creating it. ### Option A: Natural Language (in chat) Just tell Claway what you want: ``` Every morning at 8am, search the web for the latest news about AI agents and open source LLMs. Summarize the top 3 stories in a concise briefing with links. Use a friendly, professional tone. Deliver to telegram. ``` Claway will create the cron job for you using the unified `cronjob` tool. ### Option B: CLI Slash Command Use the `/cron` command for more control: ``` /cron add "0 8 * * *" "Search the web for the latest news about AI agents and open source LLMs. Find at least 5 recent articles from the past 24 hours. Summarize the top 3 most important stories in a concise daily briefing format. For each story include: a clear headline, a 2-sentence summary, and the source URL. Use a friendly, professional tone. Format with emoji bullet points and end with a total story count." ``` ### The Golden Rule: Self-Contained Prompts :::warning Critical concept Cron jobs run in a **completely fresh session** — no memory of your previous conversations, no context about what you "set up earlier." Your prompt must contain **everything** the agent needs to do the job. ::: **Bad prompt:** ``` Do my usual morning briefing. ``` **Good prompt:** ``` Search the web for the latest news about AI agents and open source LLMs. Find at least 5 recent articles from the past 24 hours. Summarize the top 3 most important stories in a concise daily briefing format. For each story include: a clear headline, a 2-sentence summary, and the source URL. Use a friendly, professional tone. Format with emoji bullet points. ``` The good prompt is specific about **what to search**, **how many articles**, **what format**, and **what tone**. It's everything the agent needs in one shot. ## Step 3: Customize the Briefing Once the basic briefing works, you can get creative. ### Multi-Topic Briefings Cover several areas in one briefing: ``` /cron add "0 8 * * *" "Create a morning briefing covering three topics. For each topic, search the web for recent news from the past 24 hours and summarize the top 2 stories with links. Topics: 1. AI and machine learning — focus on open source models and agent frameworks 2. Cryptocurrency — focus on Bitcoin, Ethereum, and regulatory news 3. Space exploration — focus on SpaceX, NASA, and commercial space Format as a clean briefing with section headers and emoji. End with today's date and a motivational quote." ``` ### Using Delegation for Parallel Research For faster briefings, tell Claway to delegate each topic to a sub-agent: ``` /cron add "0 8 * * *" "Create a morning briefing by delegating research to sub-agents. Delegate three parallel tasks: 1. Delegate: Search for the top 2 AI/ML news stories from the past 24 hours with links 2. Delegate: Search for the top 2 cryptocurrency news stories from the past 24 hours with links 3. Delegate: Search for the top 2 space exploration news stories from the past 24 hours with links Collect all results and combine them into a single clean briefing with section headers, emoji formatting, and source links. Add today's date as a header." ``` Each sub-agent searches independently and in parallel, then the main agent combines everything into one polished briefing. See the [Delegation docs](/user-guide/features/delegation) for more on how this works. ### Weekday-Only Schedule Don't need briefings on weekends? Use a cron expression that targets Monday–Friday: ``` /cron add "0 8 * * 1-5" "Search for the latest AI and tech news..." ``` ### Twice-Daily Briefings Get a morning overview and an evening recap: ``` /cron add "0 8 * * *" "Morning briefing: search for AI news from the past 12 hours..." /cron add "0 18 * * *" "Evening recap: search for AI news from the past 12 hours..." ``` ### Adding Personal Context with Memory If you have [memory](/user-guide/features/memory) enabled, you can store preferences that persist across sessions. But remember — cron jobs run in fresh sessions without conversational memory. To add personal context, bake it directly into the prompt: ``` /cron add "0 8 * * *" "You are creating a briefing for a senior ML engineer who cares about: PyTorch ecosystem, transformer architectures, open-weight models, and AI regulation in the EU. Skip stories about product launches or funding rounds unless they involve open source. Search for the latest news on these topics. Summarize the top 3 stories with links. Be concise and technical — this reader doesn't need basic explanations." ``` :::tip Tailor the persona Including details about who the briefing is *for* dramatically improves relevance. Tell the agent your role, interests, and what to skip. ::: ## Step 4: Manage Your Jobs ### List All Scheduled Jobs In chat: ``` /cron list ``` Or from the terminal: ```bash claway cron list ``` You'll see output like: ``` ID | Name | Schedule | Next Run | Deliver ------------|-------------------|-------------|--------------------|-------- a1b2c3d4 | Morning Briefing | 0 8 * * * | 2026-03-09 08:00 | telegram e5f6g7h8 | Evening Recap | 0 18 * * * | 2026-03-08 18:00 | telegram ``` ### Remove a Job In chat: ``` /cron remove a1b2c3d4 ``` Or ask conversationally: ``` Remove my morning briefing cron job. ``` Claway will use `cronjob(action="list")` to find it and `cronjob(action="remove")` to delete it. ### Check Gateway Status Make sure the scheduler is actually running: ```bash claway cron status ``` If the gateway isn't running, your jobs won't execute. Install it as a background service for reliability: ```bash claway gateway install # or on Linux servers sudo claway gateway install --system ``` ## Going Further You've built a working daily briefing bot. Here are some directions to explore next: - **[Scheduled Tasks (Cron)](/user-guide/features/cron)** — Full reference for schedule formats, repeat limits, and delivery options - **[Delegation](/user-guide/features/delegation)** — Deep dive into parallel sub-agent workflows - **[Messaging Platforms](/user-guide/messaging)** — Set up Telegram, Discord, or other delivery targets - **[Memory](/user-guide/features/memory)** — Persistent context across sessions - **[Tips & Best Practices](/guides/tips)** — More prompt engineering advice :::tip What else can you schedule? The briefing bot pattern works for anything: competitor monitoring, GitHub repo summaries, weather forecasts, portfolio tracking, server health checks, or even a daily joke. If you can describe it in a prompt, you can schedule it. ::: --- <!-- source: website/docs/guides/use-mcp-with-claway.md --> # Use MCP with Claway # Use MCP with Claway This guide shows how to actually use MCP with Claway Agent in day-to-day workflows. If the feature page explains what MCP is, this guide is about how to get value from it quickly and safely. ## When should you use MCP? Use MCP when: - a tool already exists in MCP form and you do not want to build a native Claway tool - you want Claway to operate against a local or remote system through a clean RPC layer - you want fine-grained per-server exposure control - you want to connect Claway to internal APIs, databases, or company systems without modifying Claway core Do not use MCP when: - a built-in Claway tool already solves the job well - the server exposes a huge dangerous tool surface and you are not prepared to filter it - you only need one very narrow integration and a native tool would be simpler and safer ## Mental model Think of MCP as an adapter layer: - Claway remains the agent - MCP servers contribute tools - Claway discovers those tools at startup or reload time - the model can use them like normal tools - you control how much of each server is visible That last part matters. Good MCP usage is not just “connect everything.” It is “connect the right thing, with the smallest useful surface.” ## Step 1: install MCP support If you installed Claway with the standard install script, MCP support is already included (the installer runs `uv pip install -e ".[all]"`). If you installed without extras and need to add MCP separately: ```bash cd ~/.claway/claway uv pip install -e ".[mcp]" ``` For npm-based servers, make sure Node.js and `npx` are available. For many Python MCP servers, `uvx` is a nice default. ## Step 2: add one server first Start with a single, safe server. Example: filesystem access to one project directory only. ```yaml mcp_servers: project_fs: command: "npx" args: ["-y", "@modelcontextprotocol/server-filesystem", "/home/user/my-project"] ``` Then start Claway: ```bash claway chat ``` Now ask something concrete: ```text Inspect this project and summarize the repo layout. ``` ## Step 3: verify MCP loaded You can verify MCP in a few ways: - Claway banner/status should show MCP integration when configured - ask Claway what tools it has available - use `/reload-mcp` after config changes - check logs if the server failed to connect A practical test prompt: ```text Tell me which MCP-backed tools are available right now. ``` ## Step 4: start filtering immediately Do not wait until later if the server exposes a lot of tools. ### Example: whitelist only what you want ```yaml mcp_servers: github: command: "npx" args: ["-y", "@modelcontextprotocol/server-github"] env: GITHUB_PERSONAL_ACCESS_TOKEN: "***" tools: include: [list_issues, create_issue, search_code] ``` This is usually the best default for sensitive systems. ## WSL2: bridge Claway in WSL to Windows Chrome This is the practical setup when: - Claway runs inside WSL2 - the browser you want to control is your normal signed-in Chrome on Windows - `/browser connect` is awkward or unreliable from WSL In this setup, Claway does **not** connect to Chrome directly. Instead: - Claway runs in WSL - Claway starts a local stdio MCP server - that MCP server is launched through Windows interop (`cmd.exe` or `powershell.exe`) - the MCP server attaches to your live Windows Chrome session Mental model: ```text Claway (WSL) -> MCP stdio bridge -> Windows Chrome ``` ### Why this mode is useful - you keep your real Windows browser profile, cookies, and logins - Claway stays in its supported Unix environment (WSL2) - browser control is exposed as MCP tools instead of relying on Claway core browser transport ### Recommended server Use `chrome-devtools-mcp`. If your Windows Chrome already has live remote debugging enabled from `chrome://inspect/#remote-debugging`, add it like this from WSL: ```bash claway mcp add chrome-devtools-win --command cmd.exe --args /c npx -y chrome-devtools-mcp@latest --autoConnect --no-usage-statistics ``` After saving the server: ```bash claway mcp test chrome-devtools-win ``` Then start a fresh Claway session or run: ```text /reload-mcp ``` ### Typical prompt Once loaded, Claway can use the MCP-prefixed browser tools directly. For example: ```text 调用 MCP 工具 mcp_chrome_devtools_win_list_pages,列出当前浏览器标签页。 ``` ### When `/browser connect` is the wrong tool If Claway runs in WSL and Chrome runs on Windows, `/browser connect` may fail even though Chrome is open and debuggable. Common reasons: - WSL cannot reach the same host-local endpoint Chrome exposes to Windows tools - newer Chrome live-debugging flows are not the same as a classic `ws://localhost:9222` - the browser is easier to attach to from a Windows-side helper like `chrome-devtools-mcp` In those cases, keep `/browser connect` for same-environment setups and use MCP for WSL-to-Windows browser bridging. ### Known pitfalls - Start Claway from a Windows-mounted path like `/mnt/c/Users/<you>` or `/mnt/c/workspace/...` when using Windows stdio executables through MCP. - If you start Claway from `/root` or `/home/...`, Windows may emit a `UNC` current-directory warning before the MCP server starts. - If `chrome-devtools-mcp --autoConnect` times out while enumerating pages, reduce background/frozen tabs in Chrome and retry. ### Example: blacklist dangerous actions ```yaml mcp_servers: stripe: url: "https://mcp.stripe.com" headers: Authorization: "Bearer ***" tools: exclude: [delete_customer, refund_payment] ``` ### Example: disable utility wrappers too ```yaml mcp_servers: docs: url: "https://mcp.docs.example.com" tools: prompts: false resources: false ``` ## What does filtering actually affect? There are two categories of MCP-exposed functionality in Claway: 1. Server-native MCP tools - filtered with: - `tools.include` - `tools.exclude` 2. Claway-added utility wrappers - filtered with: - `tools.resources` - `tools.prompts` ### Utility wrappers you may see Resources: - `list_resources` - `read_resource` Prompts: - `list_prompts` - `get_prompt` These wrappers only appear if: - your config allows them, and - the MCP server session actually supports those capabilities So Claway will not pretend a server has resources/prompts if it does not. ## Common patterns ### Pattern 1: local project assistant Use MCP for a repo-local filesystem or git server when you want Claway to reason over a bounded workspace. ```yaml mcp_servers: fs: command: "npx" args: ["-y", "@modelcontextprotocol/server-filesystem", "/home/user/project"] git: command: "uvx" args: ["mcp-server-git", "--repository", "/home/user/project"] ``` Good prompts: ```text Review the project structure and identify where configuration lives. ``` ```text Check the local git state and summarize what changed recently. ``` ### Pattern 2: repo-native work record with Open Scaffold Use [Open Scaffold](https://github.com/graphanov/open-scaffold) when you want Claway to read a repository's durable AI-work record: mission, plans, evidence notes, handoff packets, and review/gate results. Claway remains the agent; Open Scaffold remains the repo-local record. Add the server for one scaffolded repository: ```bash claway mcp add open_scaffold --command npx --args -y open-scaffold@latest mcp serve --repo /absolute/path/to/repo claway mcp test open_scaffold ``` Then keep the exposed surface read-oriented. Choose `select` in the `claway mcp add` prompt, or edit `config.yaml` afterward: ```yaml mcp_servers: open_scaffold: command: "npx" args: ["-y", "open-scaffold@latest", "mcp", "serve", "--repo", "/absolute/path/to/repo"] tools: include: - list_plans - get_plan - get_mission - list_evidence - get_evidence - get_status - search_plans - list_amendments - get_handoff - analyze_loop - gate_loop prompts: false ``` Good prompts: ```text Use the Open Scaffold MCP tools to compile the current handoff packet and tell me the next legal action. ``` ```text Inspect the active plans and evidence notes, then say whether this repo is ready for human review or needs another attempt. ``` Boundary notes: - Open Scaffold MCP is local-first and read-only by default. - Its write tools require the server to be started with `--allow-write`; do not enable that until you explicitly want Claway to mutate `.osc` files. - Open Scaffold records and gates work; it does not authorize Claway to merge, publish, deploy, or spawn runtimes. - Pin `open-scaffold@<version>` instead of `@latest` if you need reproducible tool schemas. ### Pattern 3: GitHub triage assistant ```yaml mcp_servers: github: command: "npx" args: ["-y", "@modelcontextprotocol/server-github"] env: GITHUB_PERSONAL_ACCESS_TOKEN: "***" tools: include: [list_issues, create_issue, update_issue, search_code] prompts: false resources: false ``` Good prompts: ```text List open issues about MCP, cluster them by theme, and draft a high-quality issue for the most common bug. ``` ```text Search the repo for uses of _discover_and_register_server and explain how MCP tools are registered. ``` ### Pattern 4: internal API assistant ```yaml mcp_servers: internal_api: url: "https://mcp.internal.example.com" headers: Authorization: "Bearer ***" tools: include: [list_customers, get_customer, list_invoices] resources: false prompts: false ``` Good prompts: ```text Look up customer ACME Corp and summarize recent invoice activity. ``` This is the sort of place where a strict whitelist is far better than an exclude list. ### Pattern 4: documentation / knowledge servers Some MCP servers expose prompts or resources that are more like shared knowledge assets than direct actions. ```yaml mcp_servers: docs: url: "https://mcp.docs.example.com" tools: prompts: true resources: true ``` Good prompts: ```text List available MCP resources from the docs server, then read the onboarding guide and summarize it. ``` ```text List prompts exposed by the docs server and tell me which ones would help with incident response. ``` ## Tutorial: end-to-end setup with filtering Here is a practical progression. ### Phase 1: add GitHub MCP with a tight whitelist ```yaml mcp_servers: github: command: "npx" args: ["-y", "@modelcontextprotocol/server-github"] env: GITHUB_PERSONAL_ACCESS_TOKEN: "***" tools: include: [list_issues, create_issue, search_code] prompts: false resources: false ``` Start Claway and ask: ```text Search the codebase for references to MCP and summarize the main integration points. ``` ### Phase 2: expand only when needed If you later need issue updates too: ```yaml tools: include: [list_issues, create_issue, update_issue, search_code] ``` Then reload: ```text /reload-mcp ``` ### Phase 3: add a second server with different policy ```yaml mcp_servers: github: command: "npx" args: ["-y", "@modelcontextprotocol/server-github"] env: GITHUB_PERSONAL_ACCESS_TOKEN: "***" tools: include: [list_issues, create_issue, update_issue, search_code] prompts: false resources: false filesystem: command: "npx" args: ["-y", "@modelcontextprotocol/server-filesystem", "/home/user/project"] ``` Now Claway can combine them: ```text Inspect the local project files, then create a GitHub issue summarizing the bug you find. ``` That is where MCP gets powerful: multi-system workflows without changing Claway core. ## Safe usage recommendations ### Prefer allowlists for dangerous systems For anything financial, customer-facing, or destructive: - use `tools.include` - start with the smallest set possible ### Disable unused utilities If you do not want the model browsing server-provided resources/prompts, turn them off: ```yaml tools: resources: false prompts: false ``` ### Keep servers scoped narrowly Examples: - filesystem server rooted to one project dir, not your whole home directory - git server pointed at one repo - internal API server with read-heavy tool exposure by default ### Reload after config changes ```text /reload-mcp ``` Do this after changing: - include/exclude lists - enabled flags - resources/prompts toggles - auth headers / env ## Troubleshooting by symptom ### "The server connects but the tools I expected are missing" Possible causes: - filtered by `tools.include` - excluded by `tools.exclude` - utility wrappers disabled via `resources: false` or `prompts: false` - server does not actually support resources/prompts ### "The server is configured but nothing loads" Check: - `enabled: false` was not left in config - command/runtime exists (`npx`, `uvx`, etc.) - HTTP endpoint is reachable - auth env or headers are correct ### "Why do I see fewer tools than the MCP server advertises?" Because Claway now respects your per-server policy and capability-aware registration. That is expected, and usually desirable. ### "How do I remove an MCP server without deleting the config?" Use: ```yaml enabled: false ``` That keeps the config around but prevents connection and registration. ## Recommended first MCP setups Good first servers for most users: - filesystem - git - GitHub - fetch / documentation MCP servers - one narrow internal API Not-great first servers: - giant business systems with lots of destructive actions and no filtering - anything you do not understand well enough to constrain ## Related docs - [MCP (Model Context Protocol)](/user-guide/features/mcp) - [FAQ](/reference/faq) - [Slash Commands](/reference/slash-commands) --- <!-- source: website/docs/guides/use-soul-with-claway.md --> # Use SOUL.md with Claway # Use SOUL.md with Claway `SOUL.md` is the **primary identity** for your Claway instance. It's the first thing in the system prompt — it defines who the agent is, how it speaks, and what it avoids. If you want Claway to feel like the same assistant every time you talk to it — or if you want to replace the Claway persona entirely with your own — this is the file to use. ## What SOUL.md is for Use `SOUL.md` for: - tone - personality - communication style - how direct or warm Claway should be - what Claway should avoid stylistically - how Claway should relate to uncertainty, disagreement, and ambiguity In short: - `SOUL.md` is about who Claway is and how Claway speaks ## What SOUL.md is not for Do not use it for: - repo-specific coding conventions - file paths - commands - service ports - architecture notes - project workflow instructions Those belong in `AGENTS.md`. A good rule: - if it should apply everywhere, put it in `SOUL.md` - if it only belongs to one project, put it in `AGENTS.md` ## Where it lives Claway now uses only the global SOUL file for the current instance: ```text ~/.claway/SOUL.md ``` If you run Claway with a custom home directory, it becomes: ```text $CLAWAY_HOME/SOUL.md ``` ## First-run behavior Claway automatically seeds a starter `SOUL.md` for you if one does not already exist. That means most users now begin with a real file they can read and edit immediately. Important: - if you already have a `SOUL.md`, Claway does not overwrite it - if the file exists but is empty, Claway adds nothing from it to the prompt ## How Claway uses it When Claway starts a session, it reads `SOUL.md` from `CLAWAY_HOME`, scans it for prompt-injection patterns, truncates it if needed, and uses it as the **agent identity** — slot #1 in the system prompt. This means SOUL.md completely replaces the built-in default identity text. If SOUL.md is missing, empty, or cannot be loaded, Claway falls back to a built-in default identity. No wrapper language is added around the file. The content itself matters — write the way you want your agent to think and speak. ## A good first edit If you do nothing else, open the file and change just a few lines so it feels like you. For example: ```markdown You are direct, calm, and technically precise. Prefer substance over politeness theater. Push back clearly when an idea is weak. Keep answers compact unless deeper detail is useful. ``` That alone can noticeably change how Claway feels. ## Example styles ### 1. Pragmatic engineer ```markdown You are a pragmatic senior engineer. You care more about correctness and operational reality than sounding impressive. ## Style - Be direct - Be concise unless complexity requires depth - Say when something is a bad idea - Prefer practical tradeoffs over idealized abstractions ## Avoid - Sycophancy - Hype language - Overexplaining obvious things ``` ### 2. Research partner ```markdown You are a thoughtful research collaborator. You are curious, honest about uncertainty, and excited by unusual ideas. ## Style - Explore possibilities without pretending certainty - Distinguish speculation from evidence - Ask clarifying questions when the idea space is underspecified - Prefer conceptual depth over shallow completeness ``` ### 3. Teacher / explainer ```markdown You are a patient technical teacher. You care about understanding, not performance. ## Style - Explain clearly - Use examples when they help - Do not assume prior knowledge unless the user signals it - Build from intuition to details ``` ### 4. Tough reviewer ```markdown You are a rigorous reviewer. You are fair, but you do not soften important criticism. ## Style - Point out weak assumptions directly - Prioritize correctness over harmony - Be explicit about risks and tradeoffs - Prefer blunt clarity to vague diplomacy ``` ## What makes a strong SOUL.md? A strong `SOUL.md` is: - stable - broadly applicable - specific in voice - not overloaded with temporary instructions A weak `SOUL.md` is: - full of project details - contradictory - trying to micro-manage every response shape - mostly generic filler like "be helpful" and "be clear" Claway already tries to be helpful and clear. `SOUL.md` should add real personality and style, not restate obvious defaults. ## Suggested structure You do not need headings, but they help. A simple structure that works well: ```markdown # Identity Who Claway is. # Style How Claway should sound. # Avoid What Claway should not do. # Defaults How Claway should behave when ambiguity appears. ``` ## SOUL.md vs /personality These are complementary. Use `SOUL.md` for your durable baseline. Use `/personality` for temporary mode switches. Examples: - your default SOUL is pragmatic and direct - then for one session you use `/personality teacher` - later you switch back without changing your base voice file ## SOUL.md vs AGENTS.md This is the most common mistake. ### Put this in SOUL.md - “Be direct.” - “Avoid hype language.” - “Prefer short answers unless depth helps.” - “Push back when the user is wrong.” ### Put this in AGENTS.md - “Use pytest, not unittest.” - “Frontend lives in `frontend/`.” - “Never edit migrations directly.” - “The API runs on port 8000.” ## How to edit it ```bash nano ~/.claway/SOUL.md ``` or ```bash vim ~/.claway/SOUL.md ``` Then restart Claway or start a new session. ## A practical workflow 1. Start with the seeded default file 2. Trim anything that does not feel like the voice you want 3. Add 4–8 lines that clearly define tone and defaults 4. Talk to Claway for a while 5. Adjust based on what still feels off That iterative approach works better than trying to design the perfect personality in one shot. ## Troubleshooting ### I edited SOUL.md but Claway still sounds the same Check: - you edited `~/.claway/SOUL.md` or `$CLAWAY_HOME/SOUL.md` - not some repo-local `SOUL.md` - the file is not empty - your session was restarted after the edit - a `/personality` overlay is not dominating the result ### Claway is ignoring parts of my SOUL.md Possible causes: - higher-priority instructions are overriding it - the file includes conflicting guidance - the file is too long and got truncated - some of the text resembles prompt-injection content and may be blocked or altered by the scanner ### My SOUL.md became too project-specific Move project instructions into `AGENTS.md` and keep `SOUL.md` focused on identity and style. ## Related docs - [Personality & SOUL.md](/user-guide/features/personality) - [Context Files](/user-guide/features/context-files) - [Configuration](/user-guide/configuration) - [Tips & Best Practices](/guides/tips) --- <!-- source: website/docs/guides/automate-with-cron.md --> # Automate Anything with Cron # Automate Anything with Cron The [daily briefing bot tutorial](/guides/daily-briefing-bot) covers the basics. This guide goes further — five real-world automation patterns you can adapt for your own workflows. For the full feature reference, see [Scheduled Tasks (Cron)](/user-guide/features/cron). :::info Key Concept Cron jobs run in fresh agent sessions with no memory of your current chat. Prompts must be **completely self-contained** — include everything the agent needs to know. ::: :::tip Don't need the LLM? You have two zero-token options. - **Recurring watchdog** where the script already produces the exact message (memory alerts, disk alerts, heartbeats): use [script-only cron jobs](/guides/cron-script-only). Same scheduler, no LLM. You can ask Claway to set one up for you in chat — the `cronjob` tool knows when to pick `no_agent=True` and writes the script for you. - **One-shot from a script that's already running** (CI step, post-commit hook, deploy script, externally-scheduled monitor): use [`claway send`](/guides/pipe-script-output) to pipe stdout or a file straight to Telegram / Discord / Slack / etc. without setting up a cron entry. ::: --- ## Pattern 1: Website Change Monitor Watch a URL for changes and get notified only when something is different. The `script` parameter is the secret weapon here. A Python script runs before each execution, and its stdout becomes context for the agent. The script handles the mechanical work (fetching, diffing); the agent handles the reasoning (is this change interesting?). Create the monitoring script: ```bash mkdir -p ~/.claway/scripts ``` ```python title="~/.claway/scripts/watch-site.py" import hashlib, json, os, urllib.request URL = "https://example.com/pricing" STATE_FILE = os.path.expanduser("~/.claway/scripts/.watch-site-state.json") # Fetch current content req = urllib.request.Request(URL, headers={"User-Agent": "Claway-Monitor/1.0"}) content = urllib.request.urlopen(req, timeout=30).read().decode() current_hash = hashlib.sha256(content.encode()).hexdigest() # Load previous state prev_hash = None if os.path.exists(STATE_FILE): with open(STATE_FILE) as f: prev_hash = json.load(f).get("hash") # Save current state with open(STATE_FILE, "w") as f: json.dump({"hash": current_hash, "url": URL}, f) # Output for the agent if prev_hash and prev_hash != current_hash: print(f"CHANGE DETECTED on {URL}") print(f"Previous hash: {prev_hash}") print(f"Current hash: {current_hash}") print(f"\nCurrent content (first 2000 chars):\n{content[:2000]}") else: print("NO_CHANGE") ``` Set up the cron job: ```bash /cron add "every 1h" "If the script output says CHANGE DETECTED, summarize what changed on the page and why it might matter. If it says NO_CHANGE, respond with just [SILENT]." --script ~/.claway/scripts/watch-site.py --name "Pricing monitor" --deliver telegram ``` :::tip The [SILENT] Trick For cron monitoring jobs, instruct the agent to respond with only `[SILENT]` when nothing changed. Cron delivery treats `[SILENT]` as the quiet marker, so you only get notified when something actually happens — no spam on quiet hours. ::: --- ## Pattern 2: Weekly Report Compile information from multiple sources into a formatted summary. This runs once a week and delivers to your home channel. ```bash /cron add "0 9 * * 1" "Generate a weekly report covering: 1. Search the web for the top 5 AI news stories from the past week 2. Search GitHub for trending repositories in the 'machine-learning' topic 3. Check Hacker News for the most discussed AI/ML posts Format as a clean summary with sections for each source. Include links. Keep it under 500 words — highlight only what matters." --name "Weekly AI digest" --deliver telegram ``` From the CLI: ```bash claway cron create "0 9 * * 1" \ "Generate a weekly report covering the top AI news, trending ML GitHub repos, and most-discussed HN posts. Format with sections, include links, keep under 500 words." \ --name "Weekly AI digest" \ --deliver telegram ``` The `0 9 * * 1` is a standard cron expression: 9:00 AM every Monday. --- ## Pattern 3: GitHub Repository Watcher Monitor a repository for new issues, PRs, or releases. ```bash /cron add "every 6h" "Check the GitHub repository BlockWayz/claway for: - New issues opened in the last 6 hours - New PRs opened or merged in the last 6 hours - Any new releases Use the terminal to run gh commands: gh issue list --repo BlockWayz/claway --state open --json number,title,author,createdAt --limit 10 gh pr list --repo BlockWayz/claway --state all --json number,title,author,createdAt,mergedAt --limit 10 Filter to only items from the last 6 hours. If nothing new, respond with [SILENT]. Otherwise, provide a concise summary of the activity." --name "Repo watcher" --deliver discord ``` :::warning Self-Contained Prompts Notice how the prompt includes the exact `gh` commands. The cron agent has no memory of previous runs or your preferences — spell everything out. ::: --- ## Pattern 4: Data Collection Pipeline Scrape data at regular intervals, save to files, and detect trends over time. This pattern combines a script (for collection) with the agent (for analysis). ```python title="~/.claway/scripts/collect-prices.py" import json, os, urllib.request from datetime import datetime DATA_DIR = os.path.expanduser("~/.claway/data/prices") os.makedirs(DATA_DIR, exist_ok=True) # Fetch current data (example: crypto prices) url = "https://api.coingecko.com/api/v3/simple/price?ids=bitcoin,ethereum&vs_currencies=usd" data = json.loads(urllib.request.urlopen(url, timeout=30).read()) # Append to history file entry = {"timestamp": datetime.now().isoformat(), "prices": data} history_file = os.path.join(DATA_DIR, "history.jsonl") with open(history_file, "a") as f: f.write(json.dumps(entry) + "\n") # Load recent history for analysis lines = open(history_file).readlines() recent = [json.loads(l) for l in lines[-24:]] # Last 24 data points # Output for the agent print(f"Current: BTC=${data['bitcoin']['usd']}, ETH=${data['ethereum']['usd']}") print(f"Data points collected: {len(lines)} total, showing last {len(recent)}") print(f"\nRecent history:") for r in recent[-6:]: print(f" {r['timestamp']}: BTC=${r['prices']['bitcoin']['usd']}, ETH=${r['prices']['ethereum']['usd']}") ``` ```bash /cron add "every 1h" "Analyze the price data from the script output. Report: 1. Current prices 2. Trend direction over the last 6 data points (up/down/flat) 3. Any notable movements (>5% change) If prices are flat and nothing notable, respond with [SILENT]. If there's a significant move, explain what happened." \ --script ~/.claway/scripts/collect-prices.py \ --name "Price tracker" \ --deliver telegram ``` The script does the mechanical collection; the agent adds the reasoning layer. --- ## Pattern 5: Multi-Skill Workflow Chain skills together for complex scheduled tasks. Skills are loaded in order before the prompt executes. ```bash # Use the arxiv skill to find papers, then the obsidian skill to save notes /cron add "0 8 * * *" "Search arXiv for the 3 most interesting papers on 'language model reasoning' from the past day. For each paper, create an Obsidian note with the title, authors, abstract summary, and key contribution." \ --skill arxiv \ --skill obsidian \ --name "Paper digest" ``` From the tool directly: ```python cronjob( action="create", skills=["arxiv", "obsidian"], prompt="Search arXiv for papers on 'language model reasoning' from the past day. Save the top 3 as Obsidian notes.", schedule="0 8 * * *", name="Paper digest", deliver="local" ) ``` Skills are loaded in order — `arxiv` first (teaches the agent how to search papers), then `obsidian` (teaches how to write notes). The prompt ties them together. --- ## Managing Your Jobs ```bash # List all active jobs /cron list # Trigger a job immediately (for testing) /cron run <job_id> # Pause a job without deleting it /cron pause <job_id> # Edit a running job's schedule or prompt /cron edit <job_id> --schedule "every 4h" /cron edit <job_id> --prompt "Updated task description" # Add or remove skills from an existing job /cron edit <job_id> --skill arxiv --skill obsidian /cron edit <job_id> --clear-skills # Remove a job permanently /cron remove <job_id> ``` --- ## Delivery Targets The `--deliver` flag controls where results go: | Target | Example | Use case | |--------|---------|----------| | `origin` | `--deliver origin` | Same chat that created the job (default) | | `local` | `--deliver local` | Save to local file only | | `telegram` | `--deliver telegram` | Your Telegram home channel | | `discord` | `--deliver discord` | Your Discord home channel | | `slack` | `--deliver slack` | Your Slack home channel | | Specific chat | `--deliver telegram:-1001234567890` | A specific Telegram group | | Threaded | `--deliver telegram:-1001234567890:17585` | A specific Telegram topic thread | --- ## Tips **Make prompts self-contained.** The agent in a cron job has no memory of your conversations. Include URLs, repo names, format preferences, and delivery instructions directly in the prompt. **Use `[SILENT]` deliberately.** For monitoring jobs, include instructions like "if nothing changed, respond with only `[SILENT]`." Do not ask the agent to explain the token in quiet cases — cron treats `[SILENT]` as the delivery-suppression marker. **Use scripts for data collection.** The `script` parameter lets a Python script handle the boring parts (HTTP requests, file I/O, state tracking). The agent only sees the script's stdout and applies reasoning to it. This is cheaper and more reliable than having the agent do the fetching itself. **Test with `/cron run`.** Before waiting for the schedule to trigger, use `/cron run <job_id>` to execute immediately and verify the output looks right. **Schedule expressions.** Supported formats: relative delays (`30m`), intervals (`every 2h`), standard cron expressions (`0 9 * * *`), and ISO timestamps (`2025-06-15T09:00:00`). Natural language like `daily at 9am` is not supported — use `0 9 * * *` instead. --- *For the complete cron reference — all parameters, edge cases, and internals — see [Scheduled Tasks (Cron)](/user-guide/features/cron).* --- <!-- source: website/docs/guides/work-with-skills.md --> # Working with Skills # Working with Skills Skills are on-demand knowledge documents that teach Claway how to handle specific tasks — from generating ASCII art to managing GitHub PRs. This guide walks you through using them day to day. For the full technical reference, see [Skills System](/user-guide/features/skills). --- ## Finding Skills Every Claway installation ships with bundled skills. See what's available: ```bash # In any chat session: /skills # Or from the CLI: claway skills list ``` This shows a compact list with names and descriptions: ``` ascii-art Generate ASCII art using pyfiglet, cowsay, boxes... arxiv Search and retrieve academic papers from arXiv... github-pr-workflow Full PR lifecycle — create branches, commit... plan Plan mode — inspect context, write a markdown... excalidraw Create hand-drawn style diagrams using Excalidraw... ``` ### Searching for a Skill ```bash # Search by keyword /skills search docker /skills search music ``` ### The Skills Hub Official optional skills (heavier or niche skills not active by default) are available via the Hub: ```bash # Browse official optional skills /skills browse # Search the hub /skills search blockchain ``` --- ## Using a Skill Every installed skill is automatically a slash command. Just type its name: ```bash # Load a skill and give it a task /ascii-art Make a banner that says "HELLO WORLD" /plan Design a REST API for a todo app /github-pr-workflow Create a PR for the auth refactor # Just the skill name (no task) loads it and lets you describe what you need /excalidraw ``` You can also trigger skills through natural conversation — ask Claway to use a specific skill, and it will load it via the `skill_view` tool. ### Progressive Disclosure Skills use a token-efficient loading pattern. The agent doesn't load everything at once: 1. **`skills_list()`** — compact list of all skills (~3k tokens). Loaded at session start. 2. **`skill_view(name)`** — full SKILL.md content for one skill. Loaded when the agent decides it needs that skill. 3. **`skill_view(name, file_path)`** — a specific reference file within the skill. Only loaded if needed. This means skills don't cost tokens until they're actually used. --- ## Installing from the Hub Official optional skills ship with Claway but aren't active by default. Install them explicitly: ```bash # Install an official optional skill claway skills install official/research/arxiv # Install from the hub in a chat session /skills install official/creative/songwriting-and-ai-music # Install a single-file SKILL.md directly from any HTTP(S) URL claway skills install https://sharethis.chat/SKILL.md /skills install https://example.com/SKILL.md --name my-skill ``` What happens: 1. The skill directory is copied to `~/.claway/skills/` 2. It appears in your `skills_list` output 3. It becomes available as a slash command :::tip Installed skills take effect in new sessions. If you want it available in the current session, use `/reset` to start fresh, or add `--now` to invalidate the prompt cache immediately (costs more tokens on the next turn). ::: ### Verifying Installation ```bash # Check it's there claway skills list | grep arxiv # Or in chat /skills search arxiv ``` --- ## Plugin-Provided Skills Plugins can bundle their own skills using namespaced names (`plugin:skill`). This prevents name collisions with built-in skills. ```bash # Load a plugin skill by its qualified name skill_view("superpowers:writing-plans") # Built-in skill with the same base name is unaffected skill_view("writing-plans") ``` Plugin skills are **not** listed in the system prompt and don't appear in `skills_list`. They're opt-in — load them explicitly when you know a plugin provides one. When loaded, the agent sees a banner listing sibling skills from the same plugin. For how to ship skills in your own plugin, see [Build a Claway Plugin → Bundle skills](/guides/build-a-claway-plugin#bundle-skills). --- ## Configuring Skill Settings Some skills declare configuration they need in their frontmatter: ```yaml metadata: claway: config: - key: tenor.api_key description: "Tenor API key for GIF search" prompt: "Enter your Tenor API key" url: "https://developers.google.com/tenor/guides/quickstart" ``` When a skill with config is first loaded, Claway prompts you for the values. They're stored in `config.yaml` under `skills.config.*`. Manage skill config from the CLI: ```bash # Interactive config for a specific skill claway skills config gif-search # View all skill config claway config show | grep '^skills\.config' ``` --- ## Creating Your Own Skill Skills are just markdown files with YAML frontmatter. Creating one takes under five minutes. ### 1. Create the Directory ```bash mkdir -p ~/.claway/skills/my-category/my-skill ``` ### 2. Write SKILL.md ```markdown title="~/.claway/skills/my-category/my-skill/SKILL.md" --- name: my-skill description: Brief description of what this skill does version: 1.0.0 metadata: claway: tags: [my-tag, automation] category: my-category --- # My Skill ## When to Use Use this skill when the user asks about [specific topic] or needs to [specific task]. ## Procedure 1. First, check if [prerequisite] is available 2. Run `command --with-flags` 3. Parse the output and present results ## Pitfalls - Common failure: [description]. Fix: [solution] - Watch out for [edge case] ## Verification Run `check-command` to confirm the result is correct. ``` ### 3. Add Reference Files (Optional) Skills can include supporting files the agent loads on demand: ``` my-skill/ ├── SKILL.md # Main skill document ├── references/ │ ├── api-docs.md # API reference the agent can consult │ └── examples.md # Example inputs/outputs ├── templates/ │ └── config.yaml # Template files the agent can use └── scripts/ └── setup.sh # Scripts the agent can execute ``` Reference these in your SKILL.md: ```markdown For API details, load the reference: `skill_view("my-skill", "references/api-docs.md")` ``` ### 4. Test It Start a new session and try your skill: ```bash claway chat -q "/my-skill help me with the thing" ``` The skill appears automatically — no registration needed. Drop it in `~/.claway/skills/` and it's live. :::info The agent can also create and update skills itself using `skill_manage`. After solving a complex problem, Claway may offer to save the approach as a skill for next time. ::: --- ## Per-Platform Skill Management Control which skills are available on which platforms: ```bash claway skills ``` This opens an interactive TUI where you can enable or disable skills per platform (CLI, Telegram, Discord, etc.). Useful when you want certain skills only available in specific contexts — for example, keeping development skills off Telegram. --- ## Skills vs Memory Both are persistent across sessions, but they serve different purposes: | | Skills | Memory | |---|---|---| | **What** | Procedural knowledge — how to do things | Factual knowledge — what things are | | **When** | Loaded on demand, only when relevant | Injected into every session automatically | | **Size** | Can be large (hundreds of lines) | Should be compact (key facts only) | | **Cost** | Zero tokens until loaded | Small but constant token cost | | **Examples** | "How to deploy to Kubernetes" | "User prefers dark mode, lives in PST" | | **Who creates** | You, the agent, or installed from Hub | The agent, based on conversations | **Rule of thumb:** If you'd put it in a reference document, it's a skill. If you'd put it on a sticky note, it's memory. --- ## Tips **Keep skills focused.** A skill that tries to cover "all of DevOps" will be too long and too vague. A skill that covers "deploy a Python app to Fly.io" is specific enough to be genuinely useful. **Let the agent create skills.** After a complex multi-step task, Claway will often offer to save the approach as a skill. Say yes — these agent-authored skills capture the exact workflow including pitfalls that were discovered along the way. **Use categories.** Organize skills into subdirectories (`~/.claway/skills/devops/`, `~/.claway/skills/research/`, etc.). This keeps the list manageable and helps the agent find relevant skills faster. **Update skills when they go stale.** If you use a skill and hit issues not covered by it, tell Claway to update the skill with what you learned. Skills that aren't maintained become liabilities. --- *For the complete skills reference — frontmatter fields, conditional activation, external directories, and more — see [Skills System](/user-guide/features/skills).* --- <!-- source: website/docs/guides/webhook-github-pr-review.md --> # Automated GitHub PR Comments with Webhooks # Automated GitHub PR Comments with Webhooks This guide walks you through connecting Claway Agent to GitHub so it automatically fetches a pull request's diff, analyzes the code changes, and posts a comment — triggered by a webhook event with no manual prompting. When a PR is opened or updated, GitHub sends a webhook POST to your Claway instance. Claway runs the agent with a prompt that instructs it to retrieve the diff via the `gh` CLI, and the response is posted back to the PR thread. :::tip Want a simpler setup without a public endpoint? If you don't have a public URL or just want to get started quickly, check out [Build a GitHub PR Review Agent](./github-pr-review-agent.md) — uses cron jobs to poll for PRs on a schedule, works behind NAT and firewalls. ::: :::info Reference docs For the full webhook platform reference (all config options, delivery types, dynamic subscriptions, security model) see [Webhooks](/user-guide/messaging/webhooks). ::: :::warning Prompt injection risk Webhook payloads contain attacker-controlled data — PR titles, commit messages, and descriptions can contain malicious instructions. When your webhook endpoint is exposed to the internet, run the gateway in a sandboxed environment (Docker, SSH backend). See the [security section](#security-notes) below. ::: --- ## Prerequisites - Claway Agent installed and running (`claway gateway`) - [`gh` CLI](https://cli.github.com/) installed and authenticated on the gateway host (`gh auth login`) - A publicly reachable URL for your Claway instance (see [Local testing with ngrok](#local-testing-with-ngrok) if running locally) - Admin access to the GitHub repository (required to manage webhooks) --- ## Step 1 — Enable the webhook platform Add the following to your `~/.claway/config.yaml`: ```yaml platforms: webhook: enabled: true extra: port: 8644 # default; change if another service occupies this port rate_limit: 30 # max requests per minute per route (not a global cap) routes: github-pr-review: secret: "your-webhook-secret-here" # must match the GitHub webhook secret exactly events: - pull_request # The agent is instructed to fetch the actual diff before reviewing. # {number} and {repository.full_name} are resolved from the GitHub payload. prompt: | A pull request event was received (action: {action}). PR #{number}: {pull_request.title} Author: {pull_request.user.login} Branch: {pull_request.head.ref} → {pull_request.base.ref} Description: {pull_request.body} URL: {pull_request.html_url} If the action is "closed" or "labeled", stop here and do not post a comment. Otherwise: 1. Run: gh pr diff {number} --repo {repository.full_name} 2. Review the code changes for correctness, security issues, and clarity. 3. Write a concise, actionable review comment and post it. deliver: github_comment deliver_extra: repo: "{repository.full_name}" pr_number: "{number}" ``` **Key fields:** | Field | Description | |---|---| | `secret` (route-level) | HMAC secret for this route. Falls back to `extra.secret` global if omitted. | | `events` | List of `X-GitHub-Event` header values to accept. Empty list = accept all. | | `prompt` | Template; `{field}` and `{nested.field}` resolve from the GitHub payload. | | `deliver` | `github_comment` posts via `gh pr comment`. `log` just writes to the gateway log. | | `deliver_extra.repo` | Resolves to e.g. `org/repo` from the payload. | | `deliver_extra.pr_number` | Resolves to the PR number from the payload. | :::note The payload does not contain code The GitHub webhook payload includes PR metadata (title, description, branch names, URLs) but **not the diff**. The prompt above instructs the agent to run `gh pr diff` to fetch the actual changes. The `terminal` tool is included in the default `claway-webhook` toolset, so no extra configuration is needed. ::: --- ## Step 2 — Start the gateway ```bash claway gateway ``` You should see: ``` [webhook] Listening on 0.0.0.0:8644 — routes: github-pr-review ``` Verify it's running: ```bash curl http://localhost:8644/health # {"status": "ok", "platform": "webhook"} ``` --- ## Step 3 — Register the webhook on GitHub 1. Go to your repository → **Settings** → **Webhooks** → **Add webhook** 2. Fill in: - **Payload URL:** `https://your-public-url.example.com/webhooks/github-pr-review` - **Content type:** `application/json` - **Secret:** the same value you set for `secret` in the route config - **Which events?** → Select individual events → check **Pull requests** 3. Click **Add webhook** GitHub will immediately send a `ping` event to confirm the connection. It is safely ignored — `ping` is not in your `events` list — and returns `{"status": "ignored", "event": "ping"}`. It is only logged at DEBUG level, so it won't appear in the console at the default log level. --- ## Step 4 — Open a test PR Create a branch, push a change, and open a PR. Within 30–90 seconds (depending on PR size and model), Claway should post a review comment. To follow the agent's progress in real time: ```bash tail -f "${CLAWAY_HOME:-$HOME/.claway}/logs/gateway.log" ``` --- ## Local testing with ngrok If Claway is running on your laptop, use [ngrok](https://ngrok.com/) to expose it: ```bash ngrok http 8644 ``` Copy the `https://...ngrok-free.app` URL and use it as your GitHub Payload URL. On the free ngrok tier the URL changes each time ngrok restarts — update your GitHub webhook each session. Paid ngrok accounts get a static domain. You can smoke-test a static route directly with `curl` — no GitHub account or real PR needed. :::tip Use `deliver: log` when testing locally Change `deliver: github_comment` to `deliver: log` in your config while testing. Otherwise the agent will attempt to post a comment to the fake `org/repo#99` repo in the test payload, which will fail. Switch back to `deliver: github_comment` once you're satisfied with the prompt output. ::: ```bash SECRET="your-webhook-secret-here" BODY='{"action":"opened","number":99,"pull_request":{"title":"Test PR","body":"Adds a feature.","user":{"login":"testuser"},"head":{"ref":"feat/x"},"base":{"ref":"main"},"html_url":"https://github.com/org/repo/pull/99"},"repository":{"full_name":"org/repo"}}' SIG=$(printf '%s' "$BODY" | openssl dgst -sha256 -hmac "$SECRET" -hex | awk '{print "sha256="$2}') curl -s -X POST http://localhost:8644/webhooks/github-pr-review \ -H "Content-Type: application/json" \ -H "X-GitHub-Event: pull_request" \ -H "X-Hub-Signature-256: $SIG" \ -d "$BODY" # Expected: {"status":"accepted","route":"github-pr-review","event":"pull_request","delivery_id":"..."} ``` Then watch the agent run: ```bash tail -f "${CLAWAY_HOME:-$HOME/.claway}/logs/gateway.log" ``` :::note `claway webhook test <name>` only works for **dynamic subscriptions** created with `claway webhook subscribe`. It does not read routes from `config.yaml`. ::: --- ## Filtering to specific actions GitHub sends `pull_request` events for many actions: `opened`, `synchronize`, `reopened`, `closed`, `labeled`, etc. The `events` list filters only by the `X-GitHub-Event` header value — it cannot filter by action sub-type at the routing level. The prompt in Step 1 already handles this by instructing the agent to stop early for `closed` and `labeled` events. :::warning The agent still runs and consumes tokens The "stop here" instruction prevents a meaningful review, but the agent still runs to completion for every `pull_request` event regardless of action. GitHub webhooks can only filter by event type (`pull_request`, `push`, `issues`, etc.) — not by action sub-type (`opened`, `closed`, `labeled`). There is no routing-level filter for sub-actions. For high-volume repos, accept this cost or filter upstream with a GitHub Actions workflow that calls your webhook URL conditionally. ::: > There is no Jinja2 or conditional template syntax. `{field}` and `{nested.field}` are the only substitutions supported. Anything else is passed verbatim to the agent. --- ## Using a skill for consistent review style Load a [Claway skill](/user-guide/features/skills) to give the agent a consistent review persona. Add `skills` to your route inside `platforms.webhook.extra.routes` in `config.yaml`: ```yaml platforms: webhook: enabled: true extra: routes: github-pr-review: secret: "your-webhook-secret-here" events: [pull_request] prompt: | A pull request event was received (action: {action}). PR #{number}: {pull_request.title} by {pull_request.user.login} URL: {pull_request.html_url} If the action is "closed" or "labeled", stop here and do not post a comment. Otherwise: 1. Run: gh pr diff {number} --repo {repository.full_name} 2. Review the diff using your review guidelines. 3. Write a concise, actionable review comment and post it. skills: - review deliver: github_comment deliver_extra: repo: "{repository.full_name}" pr_number: "{number}" ``` > **Note:** Only the first skill in the list that is found is loaded. Claway does not stack multiple skills — subsequent entries are ignored. --- ## Sending responses to Slack or Discord instead Replace the `deliver` and `deliver_extra` fields inside your route with your target platform: ```yaml # Inside platforms.webhook.extra.routes.<route-name>: # Slack deliver: slack deliver_extra: chat_id: "C0123456789" # Slack channel ID (omit to use the configured home channel) # Discord deliver: discord deliver_extra: chat_id: "987654321012345678" # Discord channel ID (omit to use home channel) ``` The target platform must also be enabled and connected in the gateway. If `chat_id` is omitted, the response is sent to that platform's configured home channel. Valid `deliver` values: `log` · `github_comment` · `telegram` · `discord` · `slack` · `signal` · `sms` --- ## GitLab support The same adapter works with GitLab. GitLab uses `X-Gitlab-Token` for authentication (plain string match, not HMAC) — Claway handles both automatically. For event filtering, GitLab sets `X-GitLab-Event` to values like `Merge Request Hook`, `Push Hook`, `Pipeline Hook`. Use the exact header value in `events`: ```yaml events: - Merge Request Hook ``` GitLab payload fields differ from GitHub's — e.g. `{object_attributes.title}` for the MR title and `{object_attributes.iid}` for the MR number. The easiest way to discover the full payload structure is GitLab's **Test** button in your webhook settings, combined with the **Recent Deliveries** log. Alternatively, omit `prompt` from your route config — Claway will then pass the full payload as formatted JSON directly to the agent, and the agent's response (visible in the gateway log with `deliver: log`) will describe its structure. --- ## Security notes - **Never use `INSECURE_NO_AUTH`** in production — it disables signature validation entirely. It is only for local development. - **Rotate your webhook secret** periodically and update it in both GitHub (webhook settings) and your `config.yaml`. - **Rate limiting** is 30 req/min per route by default (configurable via `extra.rate_limit`). Exceeding it returns `429`. - **Duplicate deliveries** (webhook retries) are deduplicated via a 1-hour idempotency cache. The cache key is `X-GitHub-Delivery` if present, then `X-Request-ID`, then a millisecond timestamp. When neither delivery ID header is set, retries are **not** deduplicated. - **Prompt injection:** PR titles, descriptions, and commit messages are attacker-controlled. Malicious PRs could attempt to manipulate the agent's actions. Run the gateway in a sandboxed environment (Docker, VM) when exposed to the public internet. --- ## Troubleshooting | Symptom | Check | |---|---| | `401 Invalid signature` | Secret in config.yaml doesn't match GitHub webhook secret | | `404 Unknown route` | Route name in the URL doesn't match the key in `routes:` | | `429 Rate limit exceeded` | 30 req/min per route exceeded — common when re-delivering test events from GitHub's UI; wait a minute or raise `extra.rate_limit` | | No comment posted | `gh` not installed, not on PATH, or not authenticated (`gh auth login`) | | Agent runs but no comment | Check the gateway log — if the agent output was empty or just "SKIP", delivery is still attempted | | Port already in use | Change `extra.port` in config.yaml | | Agent runs but reviews only the PR description | The prompt isn't including the `gh pr diff` instruction — the diff is not in the webhook payload | | Can't see the ping event | Ignored events return `{"status":"ignored","event":"ping"}` at DEBUG log level only — check GitHub's delivery log (repo → Settings → Webhooks → your webhook → Recent Deliveries) | **GitHub's Recent Deliveries tab** (repo → Settings → Webhooks → your webhook) shows the exact request headers, payload, HTTP status, and response body for every delivery. It is the fastest way to diagnose failures without touching your server logs. --- ## Full config reference ```yaml platforms: webhook: enabled: true extra: host: "0.0.0.0" # bind address (default: 0.0.0.0) port: 8644 # listen port (default: 8644) secret: "" # optional global fallback secret rate_limit: 30 # requests per minute per route max_body_bytes: 1048576 # payload size limit in bytes (default: 1 MB) routes: <route-name>: secret: "required-per-route" events: [] # [] = accept all; otherwise list X-GitHub-Event values prompt: "" # {field} / {nested.field} resolved from payload skills: [] # first matching skill is loaded (only one) deliver: "log" # log | github_comment | telegram | discord | slack | signal | sms deliver_extra: {} # repo + pr_number for github_comment; chat_id for others ``` --- ## What's Next? - **[Cron-Based PR Reviews](./github-pr-review-agent.md)** — poll for PRs on a schedule, no public endpoint needed - **[Webhook Reference](/user-guide/messaging/webhooks)** — full config reference for the webhook platform - **[Build a Plugin](/guides/build-a-claway-plugin)** — package review logic into a shareable plugin - **[Profiles](/user-guide/profiles)** — run a dedicated reviewer profile with its own memory and config --- <!-- source: website/docs/reference/cli-commands.md --> # CLI Commands Reference # CLI Commands Reference This page covers the **terminal commands** you run from your shell. For in-chat slash commands, see [Slash Commands Reference](./slash-commands.md). ## Global entrypoint ```bash claway [global-options] <command> [subcommand/options] ``` ### Global options | Option | Description | |--------|-------------| | `--version`, `-V` | Show version and exit. | | `--profile <name>`, `-p <name>` | Select which Claway profile to use for this invocation. Overrides the sticky default set by `claway profile use`. | | `--resume <session>`, `-r <session>` | Resume a previous session by ID or title. | | `--continue [name]`, `-c [name]` | Resume the most recent session, or the most recent session matching a title. | | `--worktree`, `-w` | Start in an isolated git worktree for parallel-agent workflows. | | `--yolo` | Bypass dangerous-command approval prompts. | | `--pass-session-id` | Include the session ID in the agent's system prompt. | | `--ignore-user-config` | Ignore `~/.claway/config.yaml` and fall back to built-in defaults. Credentials in `.env` are still loaded. | | `--ignore-rules` | Skip auto-injection of `AGENTS.md`, `SOUL.md`, `.cursorrules`, memory, and preloaded skills. | | `--tui` | Launch the [TUI](../user-guide/tui.md) instead of the classic CLI. Equivalent to `CLAWAY_TUI=1`. Always wins over `display.interface`. | | `--cli` | Force the classic prompt_toolkit REPL. Use this to override `display.interface: tui` for a single invocation. | | `--dev` | With `--tui`: run the TypeScript sources directly via `tsx` instead of the prebuilt bundle (for TUI contributors). | ## Top-level commands | Command | Purpose | |---------|---------| | `claway chat` | Interactive or one-shot chat with the agent. | | `claway model` | Interactively choose the default provider and model. | | `claway moa` | Configure named Mixture of Agents presets selectable from the model picker. | | `claway fallback` | Manage fallback providers tried when the primary model errors. | | `claway gateway` | Run or manage the messaging gateway service. | | `claway proxy` | Local OpenAI-compatible proxy that attaches OAuth provider credentials. See Subscription Proxy. | | `claway lsp` | Manage Language Server Protocol integration (semantic diagnostics for write_file/patch). | | `claway setup` | Interactive setup wizard for all or part of the configuration. | | `claway whatsapp` | Configure and pair the WhatsApp bridge. | | `claway whatsapp-cloud` | Configure the official Meta WhatsApp Business Cloud API adapter (Business account + public webhook required). Distinct from `claway whatsapp` (Baileys personal-account bridge). | | `claway slack` | Slack helpers (currently: generate the app manifest with every command as a native slash). | | `claway auth` | Manage credentials — add, list, remove, reset, status, logout. Handles OAuth flows for Codex/Anthropic. | | `claway login` / `logout` | **Deprecated** — use `claway auth` instead. | | `claway send` | Send a one-shot message to a configured messaging platform (Telegram, Discord, Slack, Signal, SMS, …). Useful from shell scripts, cron jobs, CI hooks, and monitoring daemons — no agent loop, no LLM. | | `claway secrets` | Manage external secret sources (currently Bitwarden Secrets Manager) for pulling API keys at process startup instead of from `~/.claway/.env`. | | `claway migrate` | Diagnose and (optionally) rewrite `config.yaml` to replace references to retired models or deprecated settings (e.g. `migrate xai`). | | `claway status` | Show agent, auth, and platform status. | | `claway cron` | Inspect and tick the cron scheduler. | | `claway kanban` | Multi-profile collaboration board (tasks, links, dispatcher). | | `claway project` | Manage named, multi-folder workspaces (projects). Anchors desktop session grouping and, when bound to a kanban board, gives tasks a deterministic worktree + branch convention. State is per-profile. | | `claway webhook` | Manage dynamic webhook subscriptions for event-driven activation. | | `claway hooks` | Inspect, approve, or remove shell-script hooks declared in `config.yaml`. | | `claway doctor` | Diagnose config and dependency issues. | | `claway security audit` | On-demand supply-chain audit (OSV.dev) for the venv, plugin requirements, and pinned MCP servers. | | `claway dump` | Copy-pasteable setup summary for support/debugging. | | `claway prompt-size` | Show a byte breakdown of the system prompt + tool schemas (skills index, memory, profile). Runs offline. | | `claway debug` | Debug tools — upload logs and system info for support. | | `claway backup` | Back up Claway home directory to a zip file. | | `claway checkpoints` | Inspect / prune / clear `~/.claway/checkpoints/` (the shadow store used by `/rollback`). Run with no args for a status overview. | | `claway import` | Restore a Claway backup from a zip file. | | `claway logs` | View, tail, and filter agent/gateway/error log files. | | `claway config` | Show, edit, migrate, and query configuration files. | | `claway pairing` | Approve or revoke messaging pairing codes. | | `claway skills` | Browse, install, publish, audit, and configure skills. | | `claway bundles` | Group several skills under a single `/<name>` slash command. See [Skill Bundles](../user-guide/features/skills.md#skill-bundles). | | `claway curator` | Background skill maintenance — status, run, pause, pin. See [Curator](../user-guide/features/curator.md). | | `claway memory` | Configure external memory provider. Plugin-specific subcommands (e.g. `claway honcho`) register automatically when their provider is active. | | `claway acp` | Run Claway as an ACP server for editor integration. | | `claway mcp` | Manage MCP server configurations and run Claway as an MCP server. | | `claway plugins` | Manage Claway Agent plugins (install, enable, disable, remove). | | `claway tools` | Configure enabled tools per platform. | | `claway computer-use` | Install or check the cua-driver backend (macOS Computer Use). | | `claway pets` | Browse, install, and select [petdex](../user-guide/features/pets.md) animated pets shown across the CLI, TUI, and desktop app. Subcommands: `list`, `install`, `select`, `show`, `off`, `scale`, `remove`, `doctor`. | | `claway sessions` | Browse, export, prune, rename, and delete sessions. | | `claway insights` | Show token/cost/activity analytics. | | `claway claw` | OpenClaw migration helpers. | | `claway dashboard` | Launch the web dashboard for managing config, API keys, and sessions. | | `claway desktop` (alias `gui`) | Build and launch the native Electron desktop app. | | `claway profile` | Manage profiles — multiple isolated Claway instances. | | `claway completion` | Print shell completion scripts (bash/zsh/fish). | | `claway version` | Show version information. | | `claway update` | Update Claway: on a Box or hosted server, install the latest release; on a source install, pull latest code and reinstall dependencies. `--check` previews without installing. | | `claway uninstall` | Remove Claway from the system. | ## `claway chat` ```bash claway chat [options] ``` Common options: | Option | Description | |--------|-------------| | `-q`, `--query "..."` | One-shot, non-interactive prompt. | | `-m`, `--model <model>` | Override the model for this run. | | `-t`, `--toolsets <csv>` | Enable a comma-separated set of toolsets. | | `--provider <provider>` | Force a provider: `auto`, `openrouter`, `openai-codex`, `copilot-acp`, `copilot`, `anthropic`, `gemini`, `huggingface`, `novita` (aliases `novita-ai`, `novitaai`), `openai-api`, `zai`, `kimi-coding`, `kimi-coding-cn`, `minimax`, `minimax-cn`, `minimax-oauth`, `kilocode`, `xiaomi`, `arcee`, `gmi`, `alibaba`, `alibaba-coding-plan` (alias `alibaba_coding`), `deepseek`, `nvidia`, `ollama-cloud`, `xai` (alias `grok`), `xai-oauth` (alias `grok-oauth`), `qwen-oauth`, `bedrock`, `opencode-zen`, `opencode-go`, `azure-foundry`, `lmstudio`, `stepfun`, `tencent-tokenhub` (alias `tencent`, `tokenhub`). | | `-s`, `--skills <name>` | Preload one or more skills for the session (can be repeated or comma-separated). | | `-v`, `--verbose` | Verbose output. | | `-Q`, `--quiet` | Programmatic mode: suppress banner/spinner/tool previews. | | `--image <path>` | Attach a local image to a single query. | | `--resume <session>` / `--continue [name]` | Resume a session directly from `chat`. | | `--worktree` | Create an isolated git worktree for this run. | | `--checkpoints` | Enable filesystem checkpoints before destructive file changes. | | `--yolo` | Skip approval prompts. | | `--pass-session-id` | Pass the session ID into the system prompt. | | `--ignore-user-config` | Ignore `~/.claway/config.yaml` and use built-in defaults. Credentials in `.env` are still loaded. Useful for isolated CI runs, reproducible bug reports, and third-party integrations. | | `--ignore-rules` | Skip auto-injection of `AGENTS.md`, `SOUL.md`, `.cursorrules`, persistent memory, and preloaded skills. Combine with `--ignore-user-config` for a fully isolated run. | | `--safe-mode` | Troubleshooting mode: disable ALL customizations — user config, rules/memory injection, plugins, and MCP servers (implies `--ignore-user-config` and `--ignore-rules`). Use to isolate whether a problem comes from your setup or from Claway itself. | | `--source <tag>` | Session source tag for filtering (default: `cli`). Use `tool` for third-party integrations that should not appear in user session lists. | | `--max-turns <N>` | Maximum tool-calling iterations per conversation turn (default: 90, or `agent.max_turns` in config). | Examples: ```bash claway claway chat -q "Summarize the latest PRs" claway chat --provider openrouter --model anthropic/claude-sonnet-4.6 claway chat --toolsets web,terminal,skills claway chat --quiet -q "Return only JSON" claway chat --worktree -q "Review this repo and open a PR" claway chat --ignore-user-config --ignore-rules -q "Repro without my personal setup" claway chat --safe-mode -q "Is this bug mine or Claway'?" ``` ### `claway -z <prompt>` — scripted one-shot For programmatic callers (shell scripts, CI, cron, parent processes piping in a prompt), `claway -z` is the purest one-shot entry point: **single prompt in, final response text out, nothing else on stdout or stderr.** No banner, no spinner, no tool previews, no `Session:` line — just the agent's final reply as plain text. ```bash claway -z "What's the capital of France?" # → Paris. # Parent scripts can cleanly capture the response: answer=$(claway -z "summarize this" < /path/to/file.txt) ``` Per-run overrides (no mutation to `~/.claway/config.yaml`): | Flag | Equivalent env var | Purpose | |---|---|---| | `-m` / `--model <model>` | `CLAWAY_INFERENCE_MODEL` | Override the model for this run | | `--provider <provider>` | _(none)_ | Override the provider for this run | ```bash claway -z "…" --provider openrouter --model openai/gpt-5.5 # or: CLAWAY_INFERENCE_MODEL=anthropic/claude-sonnet-4.6 claway -z "…" ``` Same agent, same tools, same skills — just strips every interactive / cosmetic layer. If you need tool output in the transcript too, use `claway chat -q` instead; `-z` is explicitly for "I only want the final answer". ## `claway model` Interactive provider + model selector. **This is the command for adding new providers, setting up API keys, and running OAuth flows.** Run it from your terminal — not from inside an active Claway chat session. ```bash claway model ``` Use this when you want to: - **add a new provider** (OpenRouter, Anthropic, Copilot, DeepSeek, custom, etc.) - log into OAuth-backed providers (Anthropic, Copilot, Codex) - enter or update API keys - pick from provider-specific model lists - configure a custom/self-hosted endpoint - save the new default into config :::warning claway model vs /model — know the difference **`claway model`** (run from your terminal, outside any Claway session) is the **full provider setup wizard**. It can add new providers, run OAuth flows, prompt for API keys, and configure endpoints. **`/model`** (typed inside an active Claway chat session) can only **switch between providers and models you've already set up**. It cannot add new providers, run OAuth, or prompt for API keys. **If you need to add a new provider:** Exit your Claway session first (`Ctrl+C` or `/quit`), then run `claway model` from your terminal prompt. ::: ### `/model` slash command (mid-session) Switch between already-configured models without leaving a session: ``` /model # Show current model and available options /model claude-sonnet-4 # Switch model (auto-detects provider) /model zai:glm-5 # Switch provider and model /model custom:qwen-2.5 # Use model on your custom endpoint /model custom # Auto-detect model from custom endpoint /model custom:local:qwen-2.5 # Use a named custom provider /model openrouter:anthropic/claude-sonnet-4 # Switch back to cloud ``` By default, `/model` changes apply **to the current session only**. Add `--global` to persist the change to `config.yaml`: ``` /model claude-sonnet-4 --global # Switch and save as new default ``` :::info What if I only see OpenRouter models? If you've only configured OpenRouter, `/model` will only show OpenRouter models. To add another provider (Anthropic, DeepSeek, Copilot, etc.), exit your session and run `claway model` from the terminal. ::: Provider and base URL changes are persisted to `config.yaml` automatically. When switching away from a custom endpoint, the stale base URL is cleared to prevent it leaking into other providers. ## `claway gateway` ```bash claway gateway <subcommand> ``` Subcommands: | Subcommand | Description | |------------|-------------| | `run` | Run the gateway in the foreground. Recommended for WSL, Docker, and Termux. | | `start` | Start the installed systemd/launchd background service. | | `stop` | Stop the service (or foreground process). | | `restart` | Restart the service. | | `status` | Show service status. | | `list` | List **all profiles** and whether each profile's gateway is currently running (with PID where available). Handy when you run multiple profiles side-by-side and want a single overview. | | `install` | Install as a systemd (Linux) or launchd (macOS) background service. | | `uninstall` | Remove the installed service. | | `setup` | Interactive messaging-platform setup. | | `migrate-legacy` | Remove legacy `claway.service` units left over from pre-rename installs. Profile units (`claway-gateway-<profile>.service`) and unrelated services are never touched. Flags: `--dry-run`, `-y`/`--yes`. | | `enroll` | Experimental: enroll this gateway with a relay connector and save relay credentials for connector-backed platforms. | Options: | Option | Description | |--------|-------------| | `--all` | On `start` / `restart` / `stop`: act on **every profile's** gateway, not just the active `CLAWAY_HOME`. Useful if you run multiple profiles side-by-side and want to restart them all after `claway update`. | | `--no-supervise` | On `run`: inside the s6-overlay Docker image, opt out of auto-supervision and use pre-s6 foreground semantics — gateway runs as the container's main process with no auto-restart. No-op outside the s6 image. Equivalent to setting `CLAWAY_GATEWAY_NO_SUPERVISE=1`. | `claway gateway enroll` accepts `--token`, `--connector-url`, `--gateway-id`, and `--wake-url`. It exchanges the enrollment token with the connector and writes the resulting `GATEWAY_RELAY_ID`, `GATEWAY_RELAY_SECRET`, `GATEWAY_RELAY_DELIVERY_KEY`, optional `GATEWAY_RELAY_URL`, and (when `--wake-url` is given) `GATEWAY_RELAY_WAKE_URL` values to the active profile's `.env`. :::tip WSL users Use `claway gateway run` instead of `claway gateway start` — WSL's systemd support is unreliable. Wrap it in tmux for persistence: `tmux new -s claway 'claway gateway run'`. See [WSL FAQ](/reference/faq#wsl-gateway-keeps-disconnecting-or-claway-gateway-start-fails) for details. ::: ## `claway lsp` ```bash claway lsp <subcommand> ``` Manage the Language Server Protocol integration. LSP runs real language servers (pyright, gopls, rust-analyzer, …) in the background and feeds their diagnostics into the post-write check used by `write_file` and `patch`. Gated on git workspace detection — LSP only runs when the cwd or edited file is inside a git worktree. Subcommands: | Subcommand | Description | |------------|-------------| | `status` | Show service state, configured servers, install status. | | `list` | Print the registry of supported servers. Pass `--installed-only` to skip missing ones. | | `install <id>` | Eagerly install one server's binary. | | `install-all` | Install every server with a known auto-install recipe. | | `restart` | Tear down running clients so the next edit re-spawns. | | `which <id>` | Print the resolved binary path for one server. | See [LSP — Semantic Diagnostics](/user-guide/features/lsp) for the full guide, supported languages, and configuration knobs. ## `claway setup` ```bash claway setup [model|tts|terminal|gateway|tools|agent] [--non-interactive] [--reset] [--quick] [--reconfigure] ``` **First run:** launches the first-time wizard. **Returning user (already configured):** drops straight into the full reconfigure wizard — every prompt shows your current value as its default, press Enter to keep or type a new value. No menu. Jump into one section instead of the full wizard: | Section | Description | |---------|-------------| | `model` | Provider and model setup. | | `terminal` | Terminal backend and sandbox setup. | | `gateway` | Messaging platform setup. | | `tools` | Enable/disable tools per platform. | | `agent` | Agent behavior settings. | Options: | Option | Description | |--------|-------------| | `--quick` | On returning-user runs: only prompt for items that are missing or unset. Skip items you already have configured. | | `--non-interactive` | Use defaults / environment values without prompts. | | `--reset` | Reset configuration to defaults before setup. | | `--reconfigure` | Backwards-compat alias — bare `claway setup` on an existing install now does this by default. | ## `claway whatsapp` ```bash claway whatsapp ``` Runs the WhatsApp pairing/setup flow, including mode selection and QR-code pairing. ## `claway slack` ```bash claway slack manifest # print manifest to stdout claway slack manifest --write # write to ~/.claway/slack-manifest.json claway slack manifest --slashes-only # just the features.slash_commands array ``` Generates a Slack app manifest that registers every gateway command in `COMMAND_REGISTRY` (`/btw`, `/stop`, `/model`, …) as a first-class Slack slash command — matching Discord and Telegram parity. Paste the output into your Slack app config at [https://api.slack.com/apps](https://api.slack.com/apps) → your app → **Features → App Manifest → Edit**, then **Save**. Slack prompts for reinstall if scopes or slash commands changed. | Flag | Default | Purpose | |------|---------|---------| | `--write [PATH]` | stdout | Write to a file instead of stdout. Bare `--write` writes `$CLAWAY_HOME/slack-manifest.json`. | | `--name NAME` | `Claway` | Bot display name in Slack. | | `--description DESC` | default blurb | Bot description shown in the Slack app directory. | | `--slashes-only` | off | Emit only `features.slash_commands` for merging into a manually-maintained manifest. | Run `claway slack manifest --write` again after `claway update` to pick up any new commands. ## `claway send` ```bash claway send --to <target> "message text" claway send --to <target> --file <path> echo "message" | claway send --to <target> claway send --list [platform] ``` Send a one-shot message to a configured messaging platform without spinning up an agent or gateway loop. Reuses the gateway's already-configured credentials (`~/.claway/.env` + `~/.claway/config.yaml`) so ops scripts, cron jobs, CI hooks, and monitoring daemons can post status updates without reimplementing each platform's REST client. For bot-token platforms (Telegram, Discord, Slack, Signal, SMS, WhatsApp-CloudAPI) no running gateway is required — `claway send` talks directly to the platform's REST endpoint. Plugin platforms that need a persistent adapter still require a live gateway. | Option | Description | |--------|-------------| | `-t`, `--to <TARGET>` | Delivery target. Formats: `platform` (uses home channel), `platform:chat_id`, `platform:chat_id:thread_id`, or `platform:#channel-name`. Examples: `telegram`, `telegram:-1001234567890`, `discord:#ops`, `slack:C0123ABCD`, `signal:+15551234567`. | | `-f`, `--file <PATH>` | Read the message body from `PATH` (text files only — logs, reports, markdown). Pass `-` to force reading from stdin. To send an image or other binary file, use `MEDIA:<path>` (see below). | | `-s`, `--subject <LINE>` | Prepend a subject/header line before the message body. | | `-l`, `--list [platform]` | List configured targets across all platforms (or only the given platform). | | `-q`, `--quiet` | Suppress stdout on success — useful in scripts (rely on exit code only). | | `--json` | Emit raw JSON result instead of human-readable output. | If neither a positional `message` argument nor `--file` is provided, `claway send` reads from stdin when it is not a TTY. Exit codes: `0` on success, `1` on delivery/backend failure, `2` on usage errors. ### Sending images and other media `--file` is for *text* bodies only. To deliver an image, document, video, or audio file as a native platform attachment, reference it inside the message text with the `MEDIA:<local_path>` directive: ```bash claway send --to telegram "MEDIA:/tmp/screenshot.png" claway send --to telegram "Build chart for today MEDIA:/tmp/chart.png" # with caption claway send --to discord:#ops "MEDIA:/tmp/report.pdf" ``` By default, image files are sent as photos (platforms like Telegram recompress these). Add `[[as_document]]` to the message to deliver them as uncompressed file attachments instead: ```bash claway send --to telegram "[[as_document]] MEDIA:/tmp/screenshot.png" ``` Examples: ```bash claway send --to telegram "deploy finished" echo "RAM 92%" | claway send --to telegram:-1001234567890 claway send --to discord:#ops --file /tmp/report.md claway send --to slack:#eng --subject "[CI]" --file build.log claway send --list # all platforms claway send --list telegram # filter by platform ``` ## `claway secrets` ```bash claway secrets bitwarden <subcommand> claway secrets bw <subcommand> # short alias ``` Pull API keys from an external secret manager at process startup instead of storing them in `~/.claway/.env`. Currently supports **Bitwarden Secrets Manager**. See the full guide: [Bitwarden integration](../user-guide/secrets/bitwarden.md). `bitwarden` (alias `bw`) subcommands: | Subcommand | Description | |------------|-------------| | `setup` | Interactive wizard: install the pinned `bws` binary, store an access token, and pick a project. Accepts `--project-id`, `--access-token`, and `--server-url` for non-interactive use. | | `status` | Show current config, binary path/version, and last fetch info. | | `sync` | Fetch secrets now and report what changed. Add `--apply` to actually export the secrets into the current shell's environment (default is dry-run). | | `install` | Download and verify the pinned `bws` binary. `--force` re-downloads even if a managed copy already exists. | | `disable` | Turn off the Bitwarden integration. | ## `claway migrate` ```bash claway migrate <type> ``` Diagnose and (optionally) rewrite the active `config.yaml` to replace references to retired models or deprecated settings. A timestamped backup of the original `config.yaml` is taken before any rewrite (skip with `--no-backup`). | Subcommand | Description | |------------|-------------| | `xai` | Scan `config.yaml` for references to xAI models scheduled for retirement on May 15, 2026 and (with `--apply`) rewrite them in-place to the official replacements per the xAI migration guide. Defaults to dry-run. | Common flags for migration subcommands: | Flag | Description | |------|-------------| | `--apply` | Rewrite `config.yaml` in-place (default: dry-run, no writes). | | `--no-backup` | Skip the timestamped backup of `config.yaml` when applying. | > Not to be confused with `claway claw migrate` (one-shot import of OpenClaw configuration into Claway) — `claway migrate` is the top-level config-rewrite command. ## `claway security` ```bash claway security <subcommand> ``` On-demand vulnerability scan against [OSV.dev](https://osv.dev). Covers the Claway venv (installed PyPI distributions), Python dependencies declared by plugins under `~/.claway/plugins/`, and pinned `npx`/`uvx` MCP servers in `config.yaml`. Does NOT scan globally-installed packages or editor/browser extensions. | Subcommand | Description | |------------|-------------| | `audit` | Run a one-shot supply-chain audit. | `audit` flags: | Flag | Default | Description | |------|---------|-------------| | `--json` | off | Emit machine-readable JSON instead of human-readable text. | | `--fail-on <level>` | `critical` | Exit non-zero when any finding meets this severity (`low`, `moderate`, `high`, `critical`). | | `--skip-venv` | off | Skip scanning the Claway Python venv. | | `--skip-plugins` | off | Skip scanning plugin requirements files. | | `--skip-mcp` | off | Skip scanning pinned MCP servers in `config.yaml`. | ## `claway login` / `claway logout` *(Deprecated)* :::caution `claway login` has been removed. Use `claway auth` to manage OAuth credentials, `claway model` to select a provider, or `claway setup` for full interactive setup. ::: ## `claway auth` Manage credential pools for same-provider key rotation. See [Credential Pools](/user-guide/features/credential-pools) for full documentation. ```bash claway auth # Interactive wizard claway auth list # Show all pools claway auth list openrouter # Show specific provider claway auth add openrouter --api-key sk-or-v1-xxx # Add API key claway auth add anthropic --type oauth # Add OAuth credential claway auth remove openrouter 2 # Remove by index claway auth reset openrouter # Clear cooldowns claway auth status anthropic # Show auth status for a provider claway auth logout anthropic # Log out and clear stored auth state claway auth spotify # Authenticate Claway with Spotify via PKCE ``` Subcommands: `add`, `list`, `remove`, `reset`, `status`, `logout`, `spotify`. When called with no subcommand, launches the interactive management wizard. ## `claway status` ```bash claway status [--all] [--deep] ``` | Option | Description | |--------|-------------| | `--all` | Show all details in a shareable redacted format. | | `--deep` | Run deeper checks that may take longer. | ## `claway cron` ```bash claway cron <list|create|edit|pause|resume|run|remove|status|tick> ``` | Subcommand | Description | |------------|-------------| | `list` | Show scheduled jobs. | | `create` / `add` | Create a scheduled job from a prompt, optionally attaching one or more skills via repeated `--skill`. | | `edit` | Update a job's schedule, prompt, name, delivery, repeat count, or attached skills. Supports `--clear-skills`, `--add-skill`, and `--remove-skill`. | | `pause` | Pause a job without deleting it. | | `resume` | Resume a paused job and compute its next future run. | | `run` | Trigger a job on the next scheduler tick. | | `remove` | Delete a scheduled job. | | `status` | Check whether the cron scheduler is running. | | `tick` | Run due jobs once and exit. | The cron **trigger** is pluggable via the `cron.provider` config key. Empty (the default) uses the built-in in-process ticker; you can also name a custom provider under `plugins/cron/<name>/` or `$CLAWAY_HOME/plugins/<name>/`. An unknown or unavailable provider falls back to the built-in, so cron is never left without a trigger. ## `claway kanban` ```bash claway kanban [--board <slug>] <action> [options] ``` Multi-profile, multi-project collaboration board. Each install can host many boards (one per project, repo, or domain); each board is a standalone queue with its own SQLite DB and dispatcher scope. New installs start with one board called `default`, whose DB is `~/.claway/kanban.db` for back-compat; additional boards live at `~/.claway/kanban/boards/<slug>/kanban.db`. The gateway-embedded dispatcher sweeps every board per tick. **Global flags (apply to every action below):** | Flag | Purpose | |------|---------| | `--board <slug>` | Operate on a specific board. Defaults to the current board (set via `claway kanban boards switch`, the `CLAWAY_KANBAN_BOARD` env var, or `default`). | **This is the human / scripting surface.** Agent workers spawned by the dispatcher drive the board through a dedicated `kanban_*` [toolset](/user-guide/features/kanban#how-workers-interact-with-the-board) (`kanban_show`, `kanban_complete`, `kanban_block`, `kanban_create`, `kanban_link`, `kanban_comment`, `kanban_heartbeat`; orchestrator profiles also get `kanban_list` and `kanban_unblock`) instead of shelling to `claway kanban`. Workers have `CLAWAY_KANBAN_BOARD` pinned in their env so they physically cannot see other boards. | Action | Purpose | |--------|---------| | `init` | Create `kanban.db` if missing. Idempotent. | | `boards list` / `boards ls` | List all boards with task counts. `--json`, `--all` (include archived). | | `boards create <slug>` | Create a new board. Flags: `--name`, `--description`, `--icon`, `--color`, `--switch` (make active). Slug is kebab-case, auto-downcased. | | `boards switch <slug>` / `boards use` | Persist `<slug>` as the active board (writes `~/.claway/kanban/current`). | | `boards show` / `boards current` | Print the currently-active board's name, DB path, and task counts. | | `boards rename <slug> "<name>"` | Change a board's display name. Slug is immutable. | | `boards rm <slug>` | Archive (default) or hard-delete a board. `--delete` skips the archive step. Archived boards move to `boards/_archived/<slug>-<ts>/`. Refused for `default`. | | `create "<title>"` | Create a new task on the active board. Flags: `--body`, `--assignee`, `--parent` (repeatable), `--workspace scratch\|worktree\|dir:<path>`, `--tenant`, `--priority`, `--triage`, `--idempotency-key`, `--max-runtime`, `--max-retries`, `--skill` (repeatable). | | `list` / `ls` | List tasks on the active board. Filter with `--mine`, `--assignee`, `--status`, `--tenant`, `--archived`, `--json`. | | `show <id>` | Show a task with comments and events. `--json` for machine output. | | `assign <id> <profile>` | Assign or reassign. Use `none` to unassign. Refused while task is running. | | `link <parent> <child>` | Add a dependency. Cycle-detected. Both tasks must be on the same board. | | `unlink <parent> <child>` | Remove a dependency. | | `claim <id>` | Atomically claim a ready task. Prints resolved workspace path. | | `comment <id> "<text>"` | Append a comment. The next worker that claims the task reads it as part of its `kanban_show()` response. | | `complete <id>` | Mark task done. Flags: `--result`, `--summary`, `--metadata`. | | `block <id> "<reason>"` | Mark task blocked for human input. Also appends the reason as a comment. | | `schedule <id> "<reason>"` | Park time-delay/follow-up work in `scheduled` so it is not shown as a human blocker. | | `unblock <id>` | Return a blocked or scheduled task to ready (or `todo` if dependencies are still open). | | `archive <id>` | Hide from default list. `gc` will remove scratch workspaces. | | `tail <id>` | Follow a task's event stream. | | `dispatch` | One dispatcher pass on the active board. Flags: `--dry-run`, `--max N`, `--failure-limit N`, `--json`. | | `context <id>` | Print the full context a worker would see (title + body + parent results + comments). | | `specify <id>` / `specify --all` | Flesh out a triage-column task into a concrete spec (title + body with goal, approach, acceptance criteria) via the auxiliary LLM, then promote it to `todo`. Flags: `--tenant` (scope `--all` to one tenant), `--author`, `--json`. Configure the model under `auxiliary.triage_specifier` in `config.yaml`. | | `decompose <id>` / `decompose --all` | Fan a triage-column task out into a graph of child tasks routed to specialist profiles by description. Falls back to specify-style single-task promotion when the LLM decides the task doesn't benefit from fan-out. Same flags as `specify`. Configure the decomposer model under `auxiliary.kanban_decomposer` in `config.yaml`; `kanban.orchestrator_profile` only controls who owns the root/orchestration task after fan-out. Also runs automatically every dispatcher tick when `kanban.auto_decompose: true` (the default). See [Auto vs Manual orchestration](/user-guide/features/kanban#auto-vs-manual-orchestration). | | `gc` | Remove scratch workspaces for archived tasks. | Examples: ```bash # Create a second board and put a task on it without switching away. claway kanban boards create atm10-server --name "ATM10 Server" --icon 🎮 claway kanban --board atm10-server create "Restart server" --assignee ops # Switch the active board for subsequent calls. claway kanban boards switch atm10-server claway kanban list # shows atm10-server tasks # Archive a board (recoverable) or hard-delete it. claway kanban boards rm atm10-server claway kanban boards rm atm10-server --delete ``` Board resolution order (highest precedence first): `--board <slug>` flag → `CLAWAY_KANBAN_BOARD` env var → `~/.claway/kanban/current` file → `default`. All actions are also available as a slash command in the gateway (`/kanban …`), with the same argument surface — including `boards` subcommands and the `--board` flag. For the full design — comparison with Cline Kanban / Paperclip / NanoClaw / Gemini Enterprise, eight collaboration patterns, four user stories, concurrency correctness proof — see `docs/claway-kanban-v1-spec.pdf` in the repository or the [Kanban user guide](/user-guide/features/kanban). ## `claway project` ```bash claway project <create|list|show|add-folder|remove-folder|rename|set-primary|use|archive|restore|bind-board> ``` Projects are human-named workspaces that can span multiple folders / repos. They anchor desktop session grouping and, when bound to a kanban board, give tasks a deterministic worktree + branch convention. State is per-profile. | Subcommand | Description | |------------|-------------| | `create` | Create a new project. | | `list` (alias `ls`) | List projects. | | `show` | Show a project's details. | | `add-folder` | Add a folder / repo to a project. | | `remove-folder` | Remove a folder from a project. | | `rename` | Rename a project. | | `set-primary` | Set the primary folder. | | `use` | Set the active project. | | `archive` | Archive a project (recoverable). | | `restore` | Restore an archived project. | | `bind-board` | Bind a kanban board to this project. | ## `claway webhook` ```bash claway webhook <subscribe|list|remove|test> ``` Manage dynamic webhook subscriptions for event-driven agent activation. Requires the webhook platform to be enabled in config — if not configured, prints setup instructions. | Subcommand | Description | |------------|-------------| | `subscribe` / `add` | Create a webhook route. Returns the URL and HMAC secret to configure on your service. | | `list` / `ls` | Show all agent-created subscriptions. | | `remove` / `rm` | Delete a dynamic subscription. Static routes from config.yaml are not affected. | | `test` | Send a test POST to verify a subscription is working. | ### `claway webhook subscribe` ```bash claway webhook subscribe <name> [options] ``` | Option | Description | |--------|-------------| | `--prompt` | Prompt template with `{dot.notation}` payload references. | | `--events` | Comma-separated event types to accept (e.g. `issues,pull_request`). Empty = all. | | `--description` | Human-readable description. | | `--skills` | Comma-separated skill names to load for the agent run. | | `--deliver` | Delivery target: `log` (default), `telegram`, `discord`, `slack`, `github_comment`. | | `--deliver-chat-id` | Target chat/channel ID for cross-platform delivery. | | `--secret` | Custom HMAC secret. Auto-generated if omitted. | | `--deliver-only` | Skip the agent — deliver the rendered `--prompt` as the literal message. Zero LLM cost, sub-second delivery. Requires `--deliver` to be a real target (not `log`). | Subscriptions persist to `~/.claway/webhook_subscriptions.json` and are hot-reloaded by the webhook adapter without a gateway restart. ## `claway doctor` ```bash claway doctor [--fix] ``` | Option | Description | |--------|-------------| | `--fix` | Attempt automatic repairs where possible. | ## `claway dump` ```bash claway dump [--show-keys] ``` Outputs a compact, plain-text summary of your entire Claway setup. Designed to be copy-pasted into Discord, GitHub issues, or Telegram when asking for support — no ANSI colors, no special formatting, just data. | Option | Description | |--------|-------------| | `--show-keys` | Show redacted API key prefixes (first and last 4 characters) instead of just `set`/`not set`. | ### What it includes | Section | Details | |---------|---------| | **Header** | Claway version, release date, git commit hash | | **Environment** | OS, Python version, OpenAI SDK version | | **Identity** | Active profile name, CLAWAY_HOME path | | **Model** | Configured default model and provider | | **Terminal** | Backend type (local, docker, ssh, etc.) | | **API keys** | Presence check for all 22 provider/tool API keys | | **Features** | Enabled toolsets, MCP server count, memory provider | | **Services** | Gateway status, configured messaging platforms | | **Workload** | Cron job counts, installed skill count | | **Config overrides** | Any config values that differ from defaults | ### Example output ``` --- claway dump --- version: 0.8.0 (2026.4.8) [af4abd2f] os: Linux 6.14.0-37-generic x86_64 python: 3.11.14 openai_sdk: 2.24.0 profile: default claway_home: ~/.claway model: anthropic/claude-opus-4.6 provider: openrouter terminal: local api_keys: openrouter set openai not set anthropic set firecrawl set ... features: toolsets: all mcp_servers: 0 memory_provider: built-in gateway: running (systemd) platforms: telegram, discord cron_jobs: 3 active / 5 total skills: 42 config_overrides: agent.max_turns: 250 compression.threshold: 0.85 display.streaming: True --- end dump --- ``` ### When to use - Reporting a bug on GitHub — paste the dump into your issue - Asking for help in Discord — share it in a code block - Comparing your setup to someone else's - Quick sanity check when something isn't working :::tip `claway dump` is specifically designed for sharing. For interactive diagnostics, use `claway doctor`. For a visual overview, use `claway status`. ::: ## `claway debug` ```bash claway debug share [options] ``` Upload a debug report (system info + recent logs) to a paste service and get a shareable URL. Useful for quick support requests — includes everything a helper needs to diagnose your issue. | Option | Description | |--------|-------------| | `--lines <N>` | Number of log lines to include per log file (default: 200). | | `--expire <days>` | Paste expiry in days (default: 7). | | `--local` | Print the report locally instead of uploading. | The report includes system info (OS, Python version, Claway version), recent agent, gateway, GUI/dashboard, and desktop logs (512 KB limit per file), and redacted API key status. Keys are always redacted — no secrets are uploaded. Paste services tried in order: paste.rs, dpaste.com. ### Examples ```bash claway debug share # Upload debug report, print URL claway debug share --lines 500 # Include more log lines claway debug share --expire 30 # Keep paste for 30 days claway debug share --local # Print report to terminal (no upload) ``` ## `claway backup` ```bash claway backup [options] ``` Create a zip archive of your Claway configuration, skills, sessions, and data. The backup excludes the claway codebase itself. | Option | Description | |--------|-------------| | `-o`, `--output <path>` | Output path for the zip file (default: `~/claway-backup-<timestamp>.zip`). | | `-q`, `--quick` | Quick snapshot: only critical state files (config.yaml, state.db, .env, auth, cron jobs). Much faster than a full backup. | | `-l`, `--label <name>` | Label for the snapshot (only used with `--quick`). | The backup uses SQLite's `backup()` API for safe copying, so it works correctly even when Claway is running (WAL-mode safe). **What's excluded from the zip:** - `*.db-wal`, `*.db-shm`, `*.db-journal` — SQLite's WAL / shared-memory / journal sidecars. The `*.db` file already got a consistent snapshot via `sqlite3.backup()`; shipping the live sidecars alongside it would let a restore see a half-committed state. - `checkpoints/` — per-session trajectory caches. Hash-keyed and regenerated per session; wouldn't port cleanly to another install anyway. - The `claway` code itself (this is a user-data backup, not a repo snapshot). ### Examples ```bash claway backup # Full backup to ~/claway-backup-*.zip claway backup -o /tmp/claway.zip # Full backup to specific path claway backup --quick # Quick state-only snapshot claway backup --quick --label "pre-upgrade" # Quick snapshot with label ``` ## `claway checkpoints` ```bash claway checkpoints [COMMAND] ``` Inspect and manage the shadow git store at `~/.claway/checkpoints/` — the storage layer behind the in-session `/rollback` command. Safe to run any time; does not require the agent to be running. | Subcommand | Description | |------------|-------------| | `status` (default) | Show total size, project count, and per-project breakdown. Bare `claway checkpoints` is equivalent. | | `list` | Alias for `status`. | | `prune` | Force a cleanup sweep — delete orphan and stale projects, GC the store, enforce the size cap. Ignores the 24h idempotency marker. | | `clear` | Delete the entire checkpoint base. Irreversible; asks for confirmation unless `-f`. | | `clear-legacy` | Delete only the `legacy-<timestamp>/` archives produced by the v1→v2 migration. | ### Options | Option | Subcommand | Description | |--------|------------|-------------| | `--limit N` | `status`, `list` | Max projects to list (default 20). | | `--retention-days N` | `prune` | Drop projects whose `last_touch` is older than N days (default 7). | | `--max-size-mb N` | `prune` | After the orphan/stale pass, drop the oldest commit per project until total store size ≤ N MB (default 500). | | `--keep-orphans` | `prune` | Skip deleting projects whose working directory no longer exists. | | `-f`, `--force` | `clear`, `clear-legacy` | Skip the confirmation prompt. | ### Examples ```bash claway checkpoints # status overview claway checkpoints prune --retention-days 3 # aggressive cleanup claway checkpoints prune --max-size-mb 200 # tighten size cap once claway checkpoints clear-legacy -f # drop v1 archive dirs claway checkpoints clear -f # wipe everything ``` See [Checkpoints and `/rollback`](../user-guide/checkpoints-and-rollback.md) for the full architecture and the in-session commands. ## `claway import` ```bash claway import <zipfile> [options] ``` Restore a previously created Claway backup into your Claway home directory. All files in the archive overwrite existing files in your Claway home; `--force` only skips the confirmation prompt that fires when the target already has a Claway installation. | Option | Description | |--------|-------------| | `-f`, `--force` | Skip the existing-installation confirmation prompt. | :::warning Stop the gateway before importing to avoid conflicts with running processes. ::: ### Examples ```bash claway import ~/claway-backup-20260423.zip # Prompts before overwriting existing config claway import ~/claway-backup-20260423.zip --force # Overwrite without prompting ``` ## `claway logs` ```bash claway logs [log_name] [options] ``` View, tail, and filter Claway log files. All logs are stored in `~/.claway/logs/` (or `<profile>/logs/` for non-default profiles). ### Log files | Name | File | What it captures | |------|------|-----------------| | `agent` (default) | `agent.log` | All agent activity — API calls, tool dispatch, session lifecycle (INFO and above) | | `errors` | `errors.log` | Warnings and errors only — a filtered subset of agent.log | | `gateway` | `gateway.log` | Messaging gateway activity — platform connections, message dispatch, webhook events | | `gui` | `gui.log` | Dashboard / TUI-gateway / PTY-bridge / websocket events | | `desktop` | `desktop.log` | Electron desktop app — boot, backend spawn output, and recent Python tracebacks | ### Options | Option | Description | |--------|-------------| | `log_name` | Which log to view: `agent` (default), `errors`, `gateway`, or `list` to show available files with sizes. | | `-n`, `--lines <N>` | Number of lines to show (default: 50). | | `-f`, `--follow` | Follow the log in real time, like `tail -f`. Press Ctrl+C to stop. | | `--level <LEVEL>` | Minimum log level to show: `DEBUG`, `INFO`, `WARNING`, `ERROR`, `CRITICAL`. | | `--session <ID>` | Filter lines containing a session ID substring. | | `--since <TIME>` | Show lines from a relative time ago: `30m`, `1h`, `2d`, etc. Supports `s` (seconds), `m` (minutes), `h` (hours), `d` (days). | | `--component <NAME>` | Filter by component: `gateway`, `agent`, `tools`, `cli`, `cron`. | ### Examples ```bash # View the last 50 lines of agent.log (default) claway logs # Follow agent.log in real time claway logs -f # View the last 100 lines of gateway.log claway logs gateway -n 100 # Show only warnings and errors from the last hour claway logs --level WARNING --since 1h # Filter by a specific session claway logs --session abc123 # Follow errors.log, starting from 30 minutes ago claway logs errors --since 30m -f # List all log files with their sizes claway logs list ``` ### Filtering Filters can be combined. When multiple filters are active, a log line must pass **all** of them to be shown: ```bash # WARNING+ lines from the last 2 hours containing session "tg-12345" claway logs --level WARNING --since 2h --session tg-12345 ``` Lines without a parseable timestamp are included when `--since` is active (they may be continuation lines from a multi-line log entry). Lines without a detectable level are included when `--level` is active. ### Log rotation Claway uses Python's `RotatingFileHandler`. Old logs are rotated automatically — look for `agent.log.1`, `agent.log.2`, etc. The `claway logs list` subcommand shows all log files including rotated ones. ## `claway prompt-size` ```bash claway prompt-size [--platform <name>] [--json] ``` Reports the fixed prompt budget for a fresh session — what gets sent on every API call *before* any conversation content. Useful when a downstream adapter or proxy has a tighter prompt budget than the model's context window, or when you want to see which block (skills index, memory, profile) dominates. It builds the same system prompt the agent would, then breaks it down: - **System prompt total** — full assembled prompt (identity, guidance, skills index, context files, memory, profile, timestamp). - **Skills index** — the `<available_skills>` block. This is often the largest single block when many skills are installed. - **Memory** and **user profile** — your `MEMORY.md` / `USER.md` snapshots. - **Prompt tiers** — stable / context / volatile, matching how Claway layers the prompt for cache-friendliness. - **Tool schemas** — the JSON for all enabled tools (the other half of the fixed per-call payload). Runs entirely offline — no API call, works with no credentials configured. ```bash # Human-readable breakdown for the CLI platform (default) claway prompt-size # Simulate a messaging platform's prompt (different platform hint) claway prompt-size --platform telegram # Machine-readable output for scripts claway prompt-size --json ``` :::tip The skills index and tool schemas scale with how many skills and tools you have enabled. To shrink the prompt, disable unused toolsets (`claway tools`) or uninstall skills you don't need (`claway skills`). Context files (AGENTS.md, .cursorrules) in your current directory also count toward the total. ::: ## `claway config` ```bash claway config <subcommand> ``` Subcommands: | Subcommand | Description | |------------|-------------| | `show` | Show current config values. | | `edit` | Open `config.yaml` in your editor. | | `set <key> <value>` | Set a config value. | | `path` | Print the config file path. | | `env-path` | Print the `.env` file path. | | `check` | Check for missing or stale config. | | `migrate` | Add newly introduced options interactively. | ## `claway pairing` ```bash claway pairing <list|approve|revoke|clear-pending> ``` | Subcommand | Description | |------------|-------------| | `list` | Show pending and approved users. | | `approve <platform> <code>` | Approve a pairing code. | | `revoke <platform> <user-id>` | Revoke a user's access. | | `clear-pending` | Clear pending pairing codes. | ## `claway skills` ```bash claway skills <subcommand> ``` Subcommands: | Subcommand | Description | |------------|-------------| | `browse` | Paginated browser for skill registries. | | `search` | Search skill registries. | | `install` | Install a skill. | | `inspect` | Preview a skill without installing it. | | `list` | List installed skills. | | `check` | Check installed hub skills for upstream updates. | | `update` | Reinstall hub skills with upstream changes when available. | | `audit` | Re-scan installed hub skills. | | `uninstall` | Remove a hub-installed skill. | | `reset` | Un-stick a bundled skill flagged as `user_modified` by clearing its manifest entry. With `--restore`, also replaces the user copy with the bundled version. | | `opt-out` | Stop bundled skills from being seeded into the active profile. Writes a `.no-bundled-skills` marker so the installer, `claway update`, and any sync skip bundled-skill seeding. Safe by default — nothing on disk is touched. With `--remove`, also deletes already-present bundled skills that are **unmodified** (user-edited, hub-installed, and hand-written skills are never removed; previews and confirms first, `--yes` to skip). | | `opt-in` | Undo `opt-out` by removing the `.no-bundled-skills` marker so bundled skills are seeded again on the next `claway update`. With `--sync`, re-seed immediately. | | `publish` | Publish a skill to a registry. | | `snapshot` | Export/import skill configurations. | | `tap` | Manage custom skill sources. | | `config` | Interactive enable/disable configuration for skills by platform. | Common examples: ```bash claway skills browse claway skills browse --source official claway skills search react --source skills-sh claway skills search https://mintlify.com/docs --source well-known claway skills inspect official/security/1password claway skills inspect skills-sh/vercel-labs/json-render/json-render-react claway skills install official/migration/openclaw-migration claway skills install skills-sh/anthropics/skills/pdf --force claway skills install https://sharethis.chat/SKILL.md # Direct URL (single-file SKILL.md) claway skills install https://example.com/SKILL.md --name my-skill # Override name when frontmatter has none claway skills check claway skills update claway skills config claway skills reset google-workspace claway skills reset google-workspace --restore --yes claway skills opt-out # stop future bundled-skill seeding (nothing deleted) claway skills opt-out --remove --yes # also delete UNMODIFIED bundled skills claway skills opt-in --sync # undo: remove marker and re-seed now ``` Notes: - `--force` can override non-dangerous policy blocks for third-party/community skills. - `--force` does not override a `dangerous` scan verdict. - `--source skills-sh` searches the public `skills.sh` directory. - `--source well-known` lets you point Claway at a site exposing `/.well-known/skills/index.json`. - `--source browse-sh` searches [browse.sh](https://browse.sh)'s catalog of 200+ site-specific browser-automation skills. Identifiers look like `browse-sh/airbnb.com/search-listings-ddgioa`. - Passing an `http(s)://…/*.md` URL installs a single-file SKILL.md directly. When frontmatter has no `name:` and the URL slug isn't a valid identifier, an interactive terminal prompts for a name; non-interactive surfaces (`/skills install` inside the TUI, gateway platforms) require `--name <x>` instead. ## `claway bundles` ```bash claway bundles <subcommand> ``` Skill bundles group several skills under one `/<bundle-name>` slash command. Invoking the bundle loads every referenced skill into a single combined user message. Storage: `~/.claway/skill-bundles/<slug>.yaml`. See [Skill Bundles](../user-guide/features/skills.md#skill-bundles) for the YAML schema and behavior. Subcommands: | Subcommand | Description | |------------|-------------| | `list` | List installed bundles (default when no subcommand given) | | `show <name>` | Show one bundle's name, description, skills, and file path | | `create <name>` | Create a new bundle. Pass `--skill <id>` (repeat) or omit for interactive entry. `--description`, `--instruction`, `--force` available. | | `delete <name>` | Remove a bundle file | | `reload` | Re-scan `~/.claway/skill-bundles/` and report added/removed bundles | Examples: ```bash claway bundles create backend-dev \ --skill github-code-review \ --skill test-driven-development \ --skill github-pr-workflow \ -d "Backend feature work" claway bundles list claway bundles show backend-dev claway bundles delete backend-dev ``` In a chat session, `/bundles` lists installed bundles and `/<bundle-name>` loads one. ## `claway curator` ```bash claway curator <subcommand> ``` The curator is an auxiliary-model background task that periodically reviews agent-created skills, prunes stale ones, consolidates overlaps, and archives obsolete skills. Bundled and hub-installed skills are never touched. Archives are recoverable; auto-deletion never happens. | Subcommand | Description | |------------|-------------| | `status` | Show curator status and skill stats | | `run` | Trigger a curator review now (blocks until the LLM pass finishes) | | `run --background` | Start the LLM pass in a background thread and return immediately | | `run --dry-run` | Preview only — produce the review report with no mutations | | `backup` | Take a manual tar.gz snapshot of `~/.claway/skills/` (curator also snapshots automatically before every real run) | | `rollback` | Restore `~/.claway/skills/` from a snapshot (defaults to newest) | | `rollback --list` | List available snapshots | | `rollback --id <ts>` | Restore a specific snapshot by id | | `rollback -y` | Skip the confirmation prompt | | `pause` | Pause the curator until resumed | | `resume` | Resume a paused curator | | `pin <skill>` | Pin a skill so the curator never auto-transitions it | | `unpin <skill>` | Unpin a skill | | `restore <skill>` | Restore an archived skill | | `archive <skill>` | Archive a skill manually | | `prune` | Manually prune skills the curator would normally clean up | | `list-archived` | List archived skills (recoverable via `restore`) | On a fresh install the first scheduled pass is deferred by one full `interval_hours` (7 days by default) — the gateway will not curate immediately on the first tick after `claway update`. Use `claway curator run --dry-run` to preview before that happens. See [Curator](../user-guide/features/curator.md) for behavior and config. ## `claway moa` Configure named Mixture of Agents presets. Presets appear as selectable models under a `Mixture of Agents` provider in every model picker; `/moa <prompt>` runs one prompt through the default preset. ```bash claway moa list claway moa configure [name] claway moa delete <name> ``` `claway moa configure` reuses Claway's provider → model picker for each reference model and the aggregator. A preset is an execution-mode configuration, not a primary model or provider. ## `claway fallback` ```bash claway fallback <subcommand> ``` Manage the fallback provider chain. Fallback providers are tried in order when the primary model fails with rate-limit, overload, or connection errors. | Subcommand | Description | |------------|-------------| | `list` (alias: `ls`) | Show the current fallback chain (default when no subcommand) | | `add` | Pick a provider + model (same picker as `claway model`) and append to the chain | | `remove` (alias: `rm`) | Pick an entry to delete from the chain | | `clear` | Remove all fallback entries | See [Fallback Providers](../user-guide/features/fallback-providers.md). ## `claway hooks` ```bash claway hooks <subcommand> ``` Inspect shell-script hooks declared in `~/.claway/config.yaml`, test them against synthetic payloads, and manage the first-use consent allowlist at `~/.claway/shell-hooks-allowlist.json`. | Subcommand | Description | |------------|-------------| | `list` (alias: `ls`) | List configured hooks with matcher, timeout, and consent status | | `test <event>` | Fire every hook matching `<event>` against a synthetic payload | | `revoke` (aliases: `remove`, `rm`) | Remove a command's allowlist entries (takes effect on next restart) | | `doctor` | Check each configured hook: exec bit, allowlist, mtime drift, JSON validity, and synthetic run timing | See [Hooks](../user-guide/features/hooks.md) for event signatures and payload shapes. ## `claway memory` ```bash claway memory <subcommand> ``` Set up and manage external memory provider plugins. Available providers: honcho, openviking, mem0, hindsight, holographic, retaindb, byterover, supermemory. Only one external provider can be active at a time. Built-in memory (MEMORY.md/USER.md) is always active. Subcommands: | Subcommand | Description | |------------|-------------| | `setup` | Interactive provider selection and configuration. | | `status` | Show current memory provider config. | | `off` | Disable external provider (built-in only). | :::info Provider-specific subcommands When an external memory provider is active, it may register its own top-level `claway <provider>` command for provider-specific management (e.g. `claway honcho` when Honcho is active). Inactive providers do not expose their subcommands. Run `claway --help` to see what's currently wired in. ::: ## `claway acp` ```bash claway acp ``` Starts Claway as an ACP (Agent Client Protocol) stdio server for editor integration. Related entrypoints: ```bash claway-acp python -m acp_adapter ``` Install support first: ```bash cd ~/.claway/claway && uv pip install -e '.[acp]' ``` See ACP Editor Integration and ACP Internals. ## `claway mcp` ```bash claway mcp <subcommand> ``` Manage MCP (Model Context Protocol) server configurations and run Claway as an MCP server. | Subcommand | Description | |------------|-------------| | *(none)* or `picker` | Interactive catalog picker — browse the curated MCP catalog and install/enable/disable. | | `catalog` | List the curated MCP catalog (plain text, scriptable). | | `install <name>` | Install a catalog entry (e.g. `claway mcp install n8n`). | | `serve [-v\|--verbose]` | Run Claway as an MCP server — expose conversations to other agents. | | `add <name> [--url URL] [--command CMD] [--auth oauth\|header] [--args ...]` | Add a custom MCP server with automatic tool discovery. `--args` passes the remaining argv to the stdio command, so put it last. | | `remove <name>` (alias: `rm`) | Remove an MCP server from config. | | `list` (alias: `ls`) | List configured MCP servers. | | `test <name>` | Test connection to an MCP server. | | `configure <name>` (alias: `config`) | Toggle tool selection for a server. | | `login <name>` | Force re-authentication for an OAuth-based MCP server. | See [MCP Config Reference](./mcp-config-reference.md), [Use MCP with Claway](../guides/use-mcp-with-claway.md), and [MCP Server Mode](../user-guide/features/mcp.md#running-claway-as-an-mcp-server). ## `claway plugins` ```bash claway plugins [subcommand] ``` Unified plugin management — general plugins, memory providers, and context engines in one place. Running `claway plugins` with no subcommand opens a composite interactive screen with two sections: - **General Plugins** — multi-select checkboxes to enable/disable installed plugins - **Provider Plugins** — single-select configuration for Memory Provider and Context Engine. Press ENTER on a category to open a radio picker. | Subcommand | Description | |------------|-------------| | *(none)* | Composite interactive UI — general plugin toggles + provider plugin configuration. | | `install <identifier> [--force]` | Install a plugin from a Git URL or `owner/repo`. | | `update <name>` | Pull latest changes for an installed plugin. | | `remove <name>` (aliases: `rm`, `uninstall`) | Remove an installed plugin. | | `enable <name>` | Enable a disabled plugin. | | `disable <name>` | Disable a plugin without removing it. | | `list` (alias: `ls`) | List installed plugins with enabled/disabled status. | Provider plugin selections are saved to `config.yaml`: - `memory.provider` — active memory provider (empty = built-in only) - `context.engine` — active context engine (`"compressor"` = built-in default) General plugin disabled list is stored in `config.yaml` under `plugins.disabled`. See [Plugins](../user-guide/features/plugins.md) and [Build a Claway Plugin](../guides/build-a-claway-plugin.md). ## `claway tools` ```bash claway tools [--summary] ``` | Option | Description | |--------|-------------| | `--summary` | Print the current enabled-tools summary and exit. | Without `--summary`, this launches the interactive per-platform tool configuration UI. ## `claway computer-use` ```bash claway computer-use <subcommand> ``` Subcommands: | Subcommand | Description | |------------|-------------| | `install` | Run the upstream cua-driver installer (macOS, Windows, and Linux). | | `install --upgrade` | Re-run the installer even if cua-driver is already on PATH. The upstream script always pulls the latest release, so this performs an in-place upgrade. | | `status` | Print whether `cua-driver` is on `$PATH` and which version is installed. | `claway computer-use install` is the stable entry point for installing the [cua-driver](https://github.com/trycua/cua) binary used by the `computer_use` toolset. It runs the same upstream installer that `claway tools` invokes when you first enable Computer Use, so it's safe to use for re-running the install if the toolset toggle didn't trigger it (for example, on returning-user setups). `claway update` automatically re-runs the upstream installer at the end of the update if cua-driver is on PATH, so most users will not need to call `--upgrade` manually. Use it when upstream ships a fix you want right now without waiting for the next Claway update. ## `claway pets` ```bash claway pets <list|install|select|show|off|scale|remove|doctor> ``` [Petdex](https://github.com/crafter-station/petdex) is a public gallery of animated sprite pets for coding agents. Install one and Claway shows it reacting to agent activity across the CLI, TUI, and desktop app. | Subcommand | Description | |------------|-------------| | `list` | Browse the petdex gallery. | | `install` | Install a pet from the gallery. | | `select` | Set the active pet (writes `display.pet.*`). | | `show` | Animate the active pet in the terminal. | | `off` | Disable the pet display. | | `scale` | Resize the pet everywhere (`display.pet.scale`). | | `remove` | Delete an installed pet. | | `doctor` | Check pet setup + terminal graphics support. | You can also generate a brand-new pet from a text description with the `/hatch` slash command. See [Pets](../user-guide/features/pets.md). ## `claway sessions` ```bash claway sessions <subcommand> ``` Subcommands: | Subcommand | Description | |------------|-------------| | `list` | List recent sessions. | | `browse` | Interactive session picker with search and resume. | | `export <output> [--session-id ID]` | Export sessions to JSONL. | | `delete <session-id>` | Delete one session. | | `prune` | Delete old sessions. | | `stats` | Show session-store statistics. | | `rename <session-id> <title>` | Set or change a session title. | ## `claway insights` ```bash claway insights [--days N] [--source platform] ``` | Option | Description | |--------|-------------| | `--days <n>` | Analyze the last `n` days (default: 30). | | `--source <platform>` | Filter by source such as `cli`, `telegram`, or `discord`. | ## `claway claw` ```bash claway claw migrate [options] ``` Migrate your OpenClaw setup to Claway. Reads from `~/.openclaw` (or a custom path) and writes to `~/.claway`. Automatically detects legacy directory names (`~/.clawdbot`, `~/.moltbot`) and config filenames (`clawdbot.json`, `moltbot.json`). | Option | Description | |--------|-------------| | `--dry-run` | Preview what would be migrated without writing anything. | | `--preset <name>` | Migration preset: `full` (all compatible settings) or `user-data` (excludes infrastructure config). Neither preset imports secrets — pass `--migrate-secrets` explicitly. | | `--overwrite` | Overwrite existing Claway files on conflicts (default: refuse to apply when the plan has conflicts). | | `--migrate-secrets` | Include API keys in migration. Required even under `--preset full`. | | `--no-backup` | Skip the pre-migration zip snapshot of `~/.claway/` (by default a single restore-point archive is written to `~/.claway/backups/pre-migration-*.zip` before apply; restorable with `claway import`). | | `--source <path>` | Custom OpenClaw directory (default: `~/.openclaw`). | | `--workspace-target <path>` | Target directory for workspace instructions (AGENTS.md). | | `--skill-conflict <mode>` | Handle skill name collisions: `skip` (default), `overwrite`, or `rename`. | | `--yes` | Skip the confirmation prompt. | ### What gets migrated The migration covers 30+ categories across persona, memory, skills, model providers, messaging platforms, agent behavior, session policies, MCP servers, TTS, and more. Items are either **directly imported** into Claway equivalents or **archived** for manual review. **Directly imported:** SOUL.md, MEMORY.md, USER.md, AGENTS.md, skills (4 source directories), default model, custom providers, MCP servers, messaging platform tokens and allowlists (Telegram, Discord, Slack, WhatsApp, Signal, Matrix, Mattermost), agent defaults (reasoning effort, compression, human delay, timezone, sandbox), session reset policies, approval rules, TTS config, browser settings, tool settings, exec timeout, command allowlist, gateway config, and API keys from 3 sources. **Archived for manual review:** Cron jobs, plugins, hooks/webhooks, memory backend (QMD), skills registry config, UI/identity, logging, multi-agent setup, channel bindings, IDENTITY.md, TOOLS.md, HEARTBEAT.md, BOOTSTRAP.md. **API key resolution** checks three sources in priority order: config values → `~/.openclaw/.env` → `auth-profiles.json`. All token fields handle plain strings, env templates (`${VAR}`), and SecretRef objects. For the complete config key mapping, SecretRef handling details, and post-migration checklist, see the **[full migration guide](../guides/migrate-from-openclaw.md)**. ### Examples ```bash # Preview what would be migrated claway claw migrate --dry-run # Full migration (all compatible settings, no secrets) claway claw migrate --preset full # Full migration including API keys claway claw migrate --preset full --migrate-secrets # Migrate user data only (no secrets), overwrite conflicts claway claw migrate --preset user-data --overwrite # Migrate from a custom OpenClaw path claway claw migrate --source /home/user/old-openclaw ``` ## `claway serve` ```bash claway serve [options] ``` Start the Claway **backend server** — the JSON-RPC/WebSocket gateway the desktop app and remote clients connect to. It is the same server `claway dashboard` runs, but **headless**: it never opens a browser UI. The desktop app launches its own `claway serve` backend; use this command directly when you want a headless backend on a remote host. Accepts the same `--host` / `--port` / `--insecure` / `--skip-build` / `--stop` / `--status` options as `claway dashboard` below (a non-loopback bind engages the same auth gate). Requires the `[web]` extra; the embedded Chat socket additionally needs `[pty]` on a POSIX host. ## `claway dashboard` ```bash claway dashboard [options] ``` Launch the web dashboard — a browser-based UI for managing configuration, API keys, and monitoring sessions. (For a headless backend with no browser UI — e.g. what the desktop app spawns — use [`claway serve`](#claway-serve) above.) Requires `cd ~/.claway/claway && uv pip install -e ".[web]"` (FastAPI + Uvicorn). The embedded browser Chat tab is always available and additionally needs the `pty` extra (`cd ~/.claway/claway && uv pip install -e ".[web,pty]"`) plus a POSIX PTY environment such as Linux, macOS, or WSL2. See Web Dashboard for full documentation. | Option | Default | Description | |--------|---------|-------------| | `--port` | `9119` | Port to run the web server on | | `--host` | `127.0.0.1` | Bind address | | `--no-open` | — | Don't auto-open the browser | | `--insecure` | off | **Deprecated / no-op.** Formerly bypassed auth on a non-loopback bind. Since the June 2026 hardening a public bind *always* requires an auth provider (password or OAuth). Bind `127.0.0.1` and tunnel to keep it local. | | `--skip-build` | off | Skip the web UI build step and serve the existing `dist` directly. Useful for non-interactive contexts (Windows Scheduled Tasks, CI) where npm isn't available. Pre-build with `cd web && npm run build`. | | `--isolated` | off | When launched from a named profile (`worker dashboard`), run a dedicated per-profile server instead of routing to the machine dashboard. | | `--stop` | — | Stop running `claway dashboard` processes and exit. | | `--status` | — | List running `claway dashboard` processes and exit. | ```bash # Default — opens browser to http://127.0.0.1:9119 claway dashboard # Custom port, no browser claway dashboard --port 8080 --no-open # From a profile alias — routes to the machine dashboard with the # profile preselected in the sidebar switcher (attach if running) worker dashboard ``` ## `claway profile` ```bash claway profile <subcommand> ``` Manage profiles — multiple isolated Claway instances, each with its own config, sessions, skills, and home directory. | Subcommand | Description | |------------|-------------| | `list` | List all profiles. | | `use <name>` | Set a sticky default profile. | | `create <name> [--clone] [--clone-all] [--clone-from <source>] [--no-alias]` | Create a new profile. `--clone` copies config, `.env`, `SOUL.md`, and skills from the active profile. `--clone-all` copies all state. `--clone-from` specifies a source profile and implies config clone unless paired with `--clone-all`. | | `delete <name> [-y]` | Delete a profile. | | `show <name>` | Show profile details (home directory, config, etc.). | | `alias <name> [--remove] [--name NAME]` | Manage wrapper scripts for quick profile access. | | `rename <old> <new>` | Rename a profile. | | `export <name> [-o FILE]` | Export a profile to a `.tar.gz` archive (local backup). | | `import <archive> [--name NAME]` | Import a profile from a `.tar.gz` archive (local restore). | | `install <source> [--name N] [--alias] [--force] [-y]` | Install a profile distribution from a git URL or local directory. | | `update <name> [--force-config] [-y]` | Re-pull a distribution; preserves user data (memories, sessions, auth). | | `info <name>` | Show a profile's distribution manifest (version, requirements, source). | Examples: ```bash claway profile list claway profile create work --clone claway profile use work claway profile alias work --name h-work claway profile export work -o work-backup.tar.gz claway profile import work-backup.tar.gz --name restored claway profile install github.com/user/my-distro --alias claway profile update work claway -p work chat -q "Hello from work profile" ``` ## `claway completion` ```bash claway completion [bash|zsh|fish] ``` Print a shell completion script to stdout. Source the output in your shell profile for tab-completion of Claway commands, subcommands, and profile names. Examples: ```bash # Bash claway completion bash >> ~/.bashrc # Zsh claway completion zsh >> ~/.zshrc # Fish claway completion fish > ~/.config/fish/completions/claway.fish ``` ## `claway update` ```bash claway update [--gateway] [--check] [--no-backup] [--backup] [--yes] ``` :::info Claway Box and hosted Claway On a Claway Box or hosted server, `claway` is a single program at `/usr/local/bin/claway`, and the easy way to update it is **OPS → System → Update now**. From a shell on the machine, `claway update` downloads the new release from Blockway, verifies it, swaps it in and restarts the services, keeping a backup of the previous version. `--check` only reports whether an update is available, `--dry-run` downloads and verifies without installing, and `--from-archive <zip>` installs a release file you were given (for a machine without internet access). The rest of this section describes updating a source install. ::: On a source install, `claway update` pulls the latest `claway` code and reinstalls dependencies in the managed venv, then re-runs the post-install hooks (MCP servers, skills sync, completion install). Safe to run on a live install. Use `--check` to see whether your checkout is behind `origin/main` without installing. `claway update` pulls the configured update branch (default: `main`). If your checkout is on another branch, Claway may check out the update branch before pulling. Commit branch work before updating when you want to keep it outside the update autostash flow. | Option | Description | |--------|-------------| | `--gateway` | Internal mode used by the messaging `/update` command. Uses file-based IPC for prompts and progress streaming instead of reading from terminal stdin. Not a gateway restart flag. | | `--check` | Check whether an update is available without pulling, installing dependencies, or restarting anything. | | `--no-backup` | Skip the pre-update backup for this run, even if `updates.pre_update_backup` is enabled in `config.yaml`. | | `--backup` | Create a labeled pre-update snapshot of `CLAWAY_HOME` (config, auth, sessions, skills, pairing data) before pulling. Default is **off** — the previous always-backup behavior was adding minutes to every update on large homes. Flip it on permanently via `updates.pre_update_backup: true` in `config.yaml`. | | `--yes`, `-y` | Assume yes for interactive prompts such as config migration and stash restore. API-key entry is skipped; run `claway config migrate` separately for those. | Additional behavior: - **Gateway restart.** After a successful update, Claway attempts to restart all running gateway profiles automatically so they pick up the new code. Use `claway gateway restart` when you want to restart a gateway without applying an update. - **Local source changes.** For git installs, dirty tracked files and untracked files are auto-stashed before branch checkout or pull (`git stash push --include-untracked`). Interactive terminal updates ask before restoring the stash. Non-interactive updates restore it by default; set `updates.non_interactive_local_changes: discard` only on managed installs where local source edits should be thrown away after a successful pull. If stash restore conflicts or the pull fails, the stash is left in place for manual recovery. - **npm lockfile churn.** Before stashing or switching branches, Claway makes a best-effort cleanup of tracked `package-lock.json` diffs produced by npm install/build steps. Commit or manually stash intentional lockfile edits before running `claway update`. - **Pairing data snapshot.** Even when `--backup` is off, `claway update` takes a lightweight snapshot of `~/.claway/pairing/` and the Feishu comment rules before `git pull`. You can roll it back with `claway backup restore --state pre-update` if a pull rewrites a file you were editing. - **Legacy `claway.service` warning.** If Claway detects a pre-rename `claway.service` systemd unit (instead of the current `claway-gateway.service`), it prints a one-time migration hint so you can avoid flap-loop issues. - **Exit codes.** `0` on success, `1` on pull/install/post-install errors, `2` on unexpected working-tree changes that block `git pull`. ## Maintenance commands | Command | Description | |---------|-------------| | `claway version` | Print version information. | | `claway update` | Pull latest changes and reinstall dependencies. | | `claway postinstall` | Internal bootstrap. Runs once after the install script provisions Claway (or after `claway update`) to install non-Python dependencies that pip cannot provide — Node.js runtime, headless browser, ripgrep, ffmpeg — and then trigger `claway setup` if the profile has not been configured yet. Safe to re-run idempotently. | | `claway uninstall [--full] [--gui] [--yes]` | Remove Claway, optionally deleting all config/data. `--gui` removes only the desktop Chat GUI, leaving the agent intact; `--full` also deletes config/data; `--yes` skips prompts. | ## See also - [Slash Commands Reference](./slash-commands.md) - [CLI Interface](../user-guide/cli.md) - [Sessions](../user-guide/sessions.md) - [Skills System](../user-guide/features/skills.md) - [Skins & Themes](../user-guide/features/skins.md) --- <!-- source: website/docs/reference/slash-commands.md --> # Slash Commands Reference # Slash Commands Reference Claway has two slash-command surfaces, both driven by a central `COMMAND_REGISTRY` in `claway_cli/commands.py`: - **Interactive CLI slash commands** — dispatched by `cli.py`, with autocomplete from the registry - **Messaging slash commands** — dispatched by `gateway/run.py`, with help text and platform menus generated from the registry Installed skills are also exposed as dynamic slash commands on both surfaces. That includes bundled skills like `/plan`, which opens plan mode and saves markdown plans under `.claway/plans/` relative to the active workspace/backend working directory. ## Permissions and admin/user split Every messaging platform that supports a per-user allowlist (Telegram, Discord, Slack, Matrix, Mattermost, Signal, …) also supports a two-tier slash command split: **admins** get every registered command, **regular users** only get the names you list in `user_allowed_commands` (plus the always-allowed floor `/help` and `/whoami`). Configure `allow_admin_from` and `user_allowed_commands` (and the per-group equivalents `group_allow_admin_from` / `group_user_allowed_commands`) inside the platform's `extra:` block in `~/.claway/gateway-config.yaml`. See the per-platform docs for examples — the structure is identical across platforms: - [Telegram](../user-guide/messaging/telegram.md#slash-command-access-control) - [Discord](../user-guide/messaging/discord.md) - [Slack](../user-guide/messaging/slack.md) - [Matrix](../user-guide/messaging/matrix.md) - [Mattermost](../user-guide/messaging/mattermost.md) - [Signal](../user-guide/messaging/signal.md) If `allow_admin_from` is unset for a scope, that scope stays in unrestricted backward-compat mode — every allowed user can run every command. ## Interactive CLI slash commands Type `/` in the CLI to open the autocomplete menu. Built-in commands are case-insensitive. ### Session | Command | Description | |---------|-------------| | `/new [name]` (alias: `/reset`) | Start a new session (fresh session ID + history). Optional `[name]` sets the initial session title — e.g. `/new my-experiment` opens a fresh session already titled `my-experiment` so it's easy to find later with `/resume` or `/sessions`. Append `now`, `--yes`, or `-y` to skip the confirmation modal — e.g. `/reset now`, `/new --yes my-experiment`. | | `/clear` | Clear screen and start a new session | | `/history` | Show conversation history | | `/save` | Save the current conversation | | `/prompt` (alias: `/compose`) | Compose your next prompt in `$EDITOR` (markdown) instead of the inline input — useful for long, multi-line, or carefully-formatted prompts. | | `/retry` | Retry the last message (resend to agent) | | `/undo` | Remove the last user/assistant exchange | | `/title` | Set a title for the current session (usage: /title My Session Name) | | `/compress [here [N] \| focus topic]` | Manually compress conversation context (flush memories + summarize). `/compress here [N]` summarizes everything except the most recent N exchanges (default 2), kept verbatim — pick your own compression boundary. A focus topic narrows what a full summary preserves. | | `/rollback` | List or restore filesystem checkpoints (usage: /rollback [number]) | | `/snapshot [create\|restore <id>\|prune]` (alias: `/snap`) | Create or restore state snapshots of Claway config/state. `create [label]` saves a snapshot, `restore <id>` reverts to it, `prune [N]` removes old snapshots, or list all with no args. | | `/stop` | Kill all running background processes | | `/queue <prompt>` (alias: `/q`) | Queue a prompt for the next turn (doesn't interrupt the current agent response). | | `/steer <prompt>` | Inject a mid-run note that arrives at the agent **after the next tool call** — no interrupt, no new user turn. The text is appended to the last tool result's content once the current tool completes, giving the agent new context without breaking the current tool-calling loop. Use this to nudge direction mid-task (e.g. "focus on the auth module" while the agent is running tests). | | `/goal <text>` | Set a standing goal Claway works toward across turns — our take on the Ralph loop. After each turn an auxiliary judge model decides whether the goal is done; if not, Claway auto-continues. Subcommands: `/goal status`, `/goal pause`, `/goal resume`, `/goal clear`. Budget defaults to 20 turns (`goals.max_turns`); any real user message preempts the continuation loop, and state survives `/resume`. See [Persistent Goals](/user-guide/features/goals) for the full walkthrough. | | `/subgoal <text>` | Append a user-supplied criterion to the active goal mid-loop. The continuation prompt surfaces all subgoals to the agent verbatim, and the judge factors them into its DONE/CONTINUE verdict — so the goal isn't marked done until the original goal **and** every subgoal are met. Subcommands: `/subgoal` (list), `/subgoal remove <N>`, `/subgoal clear`. Requires an active `/goal`. | | `/moa <prompt>` | Run a single prompt through the default [Mixture of Agents](/user-guide/features/mixture-of-agents) preset, then restore your current model. One-shot — does not change your session model. | | `/resume [name]` | Resume a previously-named session | | `/sessions` (TUI alias: `/switch`) | Classic CLI: browse and resume previous sessions in an interactive picker. TUI: open the live session switcher for currently open TUI sessions. Use `/sessions new` in the TUI to start another live session immediately. | | `/redraw` | Force a full UI repaint (recovers from terminal drift after tmux resize, mouse selection artifacts, etc.) | | `/status` | Show session info — model, provider, profile, session ID, working directory, title, created/updated timestamps, token totals, agent-running state — followed by a local **Session recap** block (recent user/assistant turn counts, tool result count, top tools used, last few files touched, the latest user prompt, and the latest assistant reply). The recap is computed locally from the in-memory conversation; no LLM call, no prompt-cache impact. | | `/agents` (alias: `/tasks`) | Show active agents and running tasks across the current session. | | `/background <prompt>` (alias: `/bg`, `/btw`) | Run a prompt in a separate background session. The agent processes your prompt independently — your current session stays free for other work. Results appear as a panel when the task finishes. See [CLI Background Sessions](/user-guide/cli#background-sessions). | | `/branch [name]` (alias: `/fork`) | Branch the current session (explore a different path) | | `/handoff <platform>` | **CLI only.** Hand the current session off to a messaging platform (Telegram, Discord, Slack, WhatsApp, Signal, Matrix). The gateway picks it up immediately, creates a fresh thread on platforms that support threads (Telegram topics, Discord text-channel threads, Slack message-anchored threads), re-binds the destination to your CLI session_id so the full role-aware transcript replays, and forges a synthetic user turn so the agent confirms it's working in the new place. Your CLI exits cleanly on success with a `/resume` hint; resume locally any time with `/resume <title>`. Refused mid-turn. Requires the gateway to be running and a home channel configured for the target platform (`/sethome` from the destination chat). See [Cross-Platform Handoff](/user-guide/sessions#cross-platform-handoff). | ### Configuration | Command | Description | |---------|-------------| | `/config` | Show current configuration | | `/model [model-name]` | Show or change the current model. Supports: `/model claude-sonnet-4`, `/model provider:model` (switch providers), `/model custom:model` (custom endpoint), `/model custom:name:model` (named custom provider), `/model custom` (auto-detect from endpoint), and user-defined aliases (`/model fav`, `/model grok` — see [Custom model aliases](#custom-model-aliases)). Use `--global` to persist the change to config.yaml. **Note:** `/model` can only switch between already-configured providers. To add a new provider, exit the session and run `claway model` from your terminal. | | `/codex-runtime [auto\|codex_app_server\|on\|off]` | Toggle the optional [Codex app-server runtime](../user-guide/features/codex-app-server-runtime) for OpenAI/Codex models. `auto` (default) uses Claway's standard chat completions; `codex_app_server` hands turns to a `codex app-server` subprocess for native shell, apply_patch, ChatGPT subscription auth, and migrated Codex plugins. Effective on next session. | | `/personality` | Set a predefined personality | | `/verbose` | Cycle tool progress display: off → new → all → verbose. Can be [enabled for messaging](#notes) via config. | | `/fast [normal\|fast\|status]` | Toggle fast mode — OpenAI Priority Processing / Anthropic Fast Mode. Options: `normal`, `fast`, `status`. | | `/reasoning` | Manage reasoning effort and display (usage: /reasoning [level\|show\|hide]) | | `/skin` | Show or change the display skin/theme | | `/statusbar` (alias: `/sb`) | Toggle the context/model status bar on or off | | `/voice [on\|off\|tts\|status]` | Toggle CLI voice mode and spoken playback. Recording uses `voice.record_key` (default: `Ctrl+B`). | | `/yolo` | Toggle YOLO mode — skip all dangerous command approval prompts. | | `/footer [on\|off\|status]` | Toggle the gateway runtime-metadata footer on final replies (shows model, context %, and cwd). | | `/busy [queue\|steer\|interrupt\|status]` | CLI-only: control what pressing Enter does while Claway is working — queue the new message, steer mid-turn, or interrupt immediately. | | `/indicator [kaomoji\|emoji\|unicode\|ascii]` | CLI-only: pick the TUI busy-indicator style. | | `/timestamps [on\|off\|status]` | CLI-only: toggle `[HH:MM]` timestamps on messages and in `/history`. | ### Tools & Skills | Command | Description | |---------|-------------| | `/tools [list\|disable\|enable] [name...]` | Manage tools: list available tools, or disable/enable specific tools for the current session. Disabling a tool removes it from the agent's toolset and triggers a session reset. | | `/toolsets` | List available toolsets | | `/browser [connect\|disconnect\|status]` | Manage a local Chromium-family CDP connection. `connect` attaches browser tools to a running Chrome, Brave, Chromium, or Edge instance (default: `http://127.0.0.1:9222`). `disconnect` detaches. `status` shows current connection. Auto-launches a supported Chromium-family browser if no debugger is detected. | | `/skills` | Search, install, inspect, or manage skills from online registries. Also the review surface for the skill write-approval gate: `/skills pending`, `/skills diff <id>`, `/skills approve <id>`, `/skills reject <id>`, `/skills approval on\|off`. See [Gating agent skill writes](/user-guide/features/skills#gating-agent-skill-writes-skillswrite_approval). | | `/memory [pending\|approve\|reject\|approval]` | Review pending memory writes staged by the write-approval gate (`memory.write_approval`) and toggle the gate. See [Controlling memory writes](/user-guide/features/memory#controlling-memory-writes-write_approval). | | `/bundles` | List configured skill bundles — `/<name>` slash aliases that preload several skills at once. Configure under `bundles:` in `~/.claway/config.yaml`. See [Skill Bundles](/user-guide/features/skills#skill-bundles). | | `/learn <what to learn from>` | Distill a reusable skill from anything you describe — a directory, a URL, the workflow you just walked the agent through, or pasted notes. Open-ended: the agent gathers the sources with its own tools and authors a `SKILL.md` following the house authoring standards. Works in the CLI, the messaging gateway, the TUI, and the dashboard Skills page. | | `/cron` | Manage scheduled tasks (list, add/create, edit, pause, resume, run, remove) | | `/suggestions [accept\|dismiss N\|catalog\|clear]` (alias: `/suggest`) | Review suggested automations. Use `/suggestions` to list pending suggestions, `/suggestions accept <id>` to create the proposed automation, `/suggestions dismiss <id>` to reject one, `/suggestions catalog` to add curated starter automations, and `/suggestions clear` to clear resolved suggestion records. Accepted jobs preserve the current surface as the delivery origin. | | `/blueprint [name] [slot=value ...]` (alias: `/bp`) | Set up an automation from a blueprint template. Bare `/blueprint` lists the catalog; `/blueprint <name>` starts a guided slot-filling flow on the next agent turn; `/blueprint <name> slot=value ...` creates the job directly. | | `/curator` | Background skill maintenance — `status`, `run`, `pin`, `archive`. See [Curator](/user-guide/features/curator). | | `/kanban <action>` | Drive the multi-profile, multi-project collaboration board without leaving chat. Full `claway kanban` surface is available: `/kanban list`, `/kanban show t_abc`, `/kanban create "title" --assignee X`, `/kanban comment t_abc "text"`, `/kanban unblock t_abc`, `/kanban dispatch`, etc. Multi-board support included: `/kanban boards list`, `/kanban boards create <slug>`, `/kanban boards switch <slug>`, `/kanban --board <slug> <action>`. See [Kanban slash command](/user-guide/features/kanban#kanban-slash-command). | | `/reload-mcp` (alias: `/reload_mcp`) | Reload MCP servers from config.yaml | | `/reload-skills` (alias: `/reload_skills`) | Re-scan `~/.claway/skills/` for newly installed or removed skills | | `/reload` | Reload `.env` variables into the running session (picks up new API keys without restarting) | | `/plugins` | List installed plugins and their status | | `/pet [list\|<slug>]` | Toggle or adopt a [petdex](/user-guide/features/pets) mascot. `/pet` toggles the pane, `/pet list` shows installed pets, `/pet <slug>` adopts a specific one. | | `/hatch <description>` (alias: `/generate-pet`) | Generate a brand-new petdex pet from a text description, using the configured image backend. See [Pets](/user-guide/features/pets). | ### Info | Command | Description | |---------|-------------| | `/help` | Show this help message | | `/version` | Show Claway Agent version, build, and environment info. | | `/usage` | Show token usage, cost breakdown, session duration, and — when available from the active provider — an **Account limits** section with remaining quota / credits / plan usage pulled live from the provider's API. | | `/insights` | Show usage insights and analytics (last 30 days) | | `/platforms` (alias: `/gateway`) | Show gateway/messaging platform status (CLI-only summary view). | | `/paste` | Attach a clipboard image | | `/copy [number]` | Copy the last assistant response to clipboard (or the Nth-from-last with a number). CLI-only. | | `/image <path>` | Attach a local image file for your next prompt. | | `/debug` | Upload debug report (system info + logs) and get shareable links. Also available in messaging. | | `/profile` | Show active profile name and home directory | ### Exit | Command | Description | |---------|-------------| | `/quit` | Exit the CLI (also: `/exit`). | ### Dynamic CLI slash commands | Command | Description | |---------|-------------| | `/<skill-name>` | Load any installed skill as an on-demand command. Example: `/gif-search`, `/github-pr-workflow`, `/excalidraw`. | | `/skills ...` | Search, browse, inspect, install, audit, publish, and configure skills from registries and the official optional-skills catalog. | ### Quick Commands User-defined quick commands map a short slash command to either a shell command or another slash command. Configure them in `~/.claway/config.yaml`: ```yaml quick_commands: status: type: exec command: systemctl status claway deploy: type: exec command: scripts/deploy.sh inbox: type: alias target: /gmail unread ``` Then type `/status`, `/deploy`, or `/inbox` in the CLI or a messaging platform. Quick commands are resolved at dispatch time and may not appear in every built-in autocomplete/help table. String-only prompt shortcuts are not supported as quick commands. Put longer reusable prompts in a skill, or use `type: alias` to point at an existing slash command. ### Custom model aliases Define your own short names for models you use often, then reach them with `/model <alias>` in the CLI or any messaging platform. Aliases work identically in both, on session-only (default) and `--global` switches. Two config formats are supported: **Full form** — pin an exact model, provider, and optionally a base URL. Put this in `~/.claway/config.yaml`: ```yaml model_aliases: fav: model: claude-sonnet-4.6 provider: anthropic grok: model: grok-4 provider: x-ai ollama-qwen: model: qwen3-coder:30b provider: custom base_url: http://localhost:11434/v1 ``` **Short form** — `provider/model` in one string. Set from the shell without editing YAML: ```bash claway config set model.aliases.fav anthropic/claude-opus-4.6 claway config set model.aliases.grok x-ai/grok-4 ``` Then in chat: ``` /model fav # session-only /model grok --global # also persists current-model change to config.yaml ``` User aliases take precedence over built-in short names, so naming an alias `sonnet`, `kimi`, `opus`, etc. will shadow the built-in. Alias names are case-insensitive. ### Alias Resolution Commands support prefix matching: typing `/h` resolves to `/help`, `/mod` resolves to `/model`. When a prefix is ambiguous (matches multiple commands), the first match in registry order wins. Full command names and registered aliases always take priority over prefix matches. ## Messaging slash commands The messaging gateway supports the following built-in commands inside Telegram, Discord, Slack, WhatsApp, Signal, Email, Home Assistant, and Teams chats: | Command | Description | |---------|-------------| | `/start` | Platform-protocol command. Many chat platforms (Telegram, Discord, …) send `/start` automatically the first time a user opens a bot conversation. Claway acknowledges the ping silently — no agent reply, no session burn — so first-contact handshakes don't waste a turn. You can also send it explicitly to confirm the gateway is reachable. | | `/new [name]` (alias: `/reset`) | Start a new session (fresh session ID + history). Optional `[name]` sets the initial session title. Append `now`, `--yes`, or `-y` to skip the confirmation modal — e.g. `/reset now`, `/new --yes my-experiment`. | | `/status` | Show session info, followed by a local **Session recap** block (recent turn counts, top tools used, files touched, latest prompt + reply). | | `/stop` | Kill all running background processes and interrupt the running agent. | | `/model [provider:model]` | Show or change the model. Supports provider switches (`/model zai:glm-5`), custom endpoints (`/model custom:model`), named custom providers (`/model custom:local:qwen`), auto-detect (`/model custom`), and user-defined aliases (`/model fav`, `/model grok` — see [Custom model aliases](#custom-model-aliases)). Use `--global` to persist the change to config.yaml. **Note:** `/model` can only switch between already-configured providers. To add a new provider or set up API keys, use `claway model` from your terminal (outside the chat session). | | `/codex-runtime [auto\|codex_app_server\|on\|off]` | Toggle the optional [Codex app-server runtime](../user-guide/features/codex-app-server-runtime). Persists to `model.openai_runtime` in config.yaml and evicts the cached agent so the next message picks up the new runtime. Effective on next session. | | `/personality [name]` | Set a personality overlay for the session. | | `/fast [normal\|fast\|status]` | Toggle fast mode — OpenAI Priority Processing / Anthropic Fast Mode. | | `/retry` | Retry the last message. | | `/undo` | Remove the last exchange. | | `/sethome` (alias: `/set-home`) | Mark the current chat as the platform home channel for deliveries. | | `/compress [here [N] \| focus topic]` | Manually compress conversation context. `/compress here [N]` keeps the most recent N exchanges (default 2) verbatim and summarizes the rest. A focus topic narrows what a full summary preserves. | | `/topic [off\|help\|session-id]` | **Telegram DM only.** Manage user-managed multi-session topic mode. `/topic` enables it or shows status; `/topic off` disables it and clears bindings; `/topic help` shows usage; `/topic <session-id>` inside a topic restores a previous session. See [Multi-session DM mode](/user-guide/messaging/telegram#multi-session-dm-mode-topic). | | `/title [name]` | Set or show the session title. | | `/resume [name]` | Resume a previously named session. | | `/usage` | Show token usage, estimated cost breakdown (input/output), context window state, session duration, and — when available from the active provider — an **Account limits** section with remaining quota / credits pulled live from the provider's API. | | `/insights [days]` | Show usage analytics. | | `/reasoning [level\|show\|hide]` | Change reasoning effort or toggle reasoning display. | | `/voice [on\|off\|tts\|join\|channel\|leave\|status]` | Control spoken replies in chat. `join`/`channel`/`leave` manage Discord voice-channel mode. | | `/rollback [number]` | List or restore filesystem checkpoints. | | `/background <prompt>` | Run a prompt in a separate background session. Results are delivered back to the same chat when the task finishes. See [Messaging Background Sessions](/user-guide/messaging/#background-sessions). | | `/queue <prompt>` (alias: `/q`) | Queue a prompt for the next turn without interrupting the current one. | | `/steer <prompt>` | Inject a message after the next tool call without interrupting — the model picks it up on its next iteration rather than as a new turn. | | `/goal <text>` | Set a standing goal Claway works toward across turns — our take on the Ralph loop. A judge model checks after each turn; if not done, Claway auto-continues until it is, you pause/clear it, or the turn budget (default 20) is hit. Subcommands: `/goal status`, `/goal pause`, `/goal resume`, `/goal clear`. Safe to run mid-agent for status/pause/clear; setting a new goal requires `/stop` first. See [Persistent Goals](/user-guide/features/goals). | | `/footer [on\|off\|status]` | Toggle the runtime-metadata footer on final replies (shows model, context %, and cwd). | | `/curator [status\|run\|pin\|archive]` | Background skill maintenance controls. | | `/suggestions [accept\|dismiss N\|catalog\|clear]` | Review suggested automations right in chat. `/suggestions` lists pending suggestions, `catalog` adds curated starter automations, and `clear` prunes resolved suggestion records. Accepted suggestions keep this chat/thread as the job delivery origin. | | `/blueprint [name] [slot=value ...]` | Browse cron blueprints, start a guided slot-filling conversation, or create a blueprint job directly. Directly created jobs deliver back to the current chat/thread. | | `/memory [pending\|approve\|reject\|approval]` | Review pending memory writes staged by the write-approval gate (`memory.write_approval`) — approve or reject them right in chat — and toggle the gate with `/memory approval on\|off`. See [Controlling memory writes](/user-guide/features/memory#controlling-memory-writes-write_approval). | | `/skills [pending\|approve\|reject\|diff\|approval]` | Review pending **skill** writes staged by the write-approval gate (`skills.write_approval`). Shows a one-line gist per staged write; `/skills diff <id>` is truncated for chat — read the full diff on the CLI or in `~/.claway/pending/skills/<id>.json`. Only appears when the gate is on (or staged writes remain); search/install stay CLI-only. | | `/kanban <action>` | Drive the multi-profile, multi-project collaboration board from chat — identical argument surface to the CLI. Bypasses the running-agent guard, so `/kanban unblock t_abc`, `/kanban comment t_abc "…"`, `/kanban list --mine`, `/kanban boards switch <slug>`, etc. work mid-turn. `/kanban create …` auto-subscribes the originating chat to the new task's terminal events. See [Kanban slash command](/user-guide/features/kanban#kanban-slash-command). | | `/platform <list\|pause\|resume> [name]` | Operate a running gateway platform right from chat. `/platform list` shows every adapter and its state (running, paused-by-breaker, manually-paused); `/platform pause <name>` stops dispatching new messages to that adapter without unloading it; `/platform resume <name>` re-enables it and clears a tripped circuit breaker once the upstream is healthy. | | `/reload-mcp` (alias: `/reload_mcp`) | Reload MCP servers from config. | | `/yolo` | Toggle YOLO mode — skip all dangerous command approval prompts. | | `/commands [page]` | Browse all commands and skills (paginated). | | `/approve [session\|always]` | Approve and execute a pending dangerous command. `session` approves for this session only; `always` adds to permanent allowlist. | | `/deny` | Reject a pending dangerous command. | | `/update` | Update Claway Agent to the latest version. | | `/restart` | Gracefully restart the gateway after draining active runs. When the gateway comes back online, it sends a confirmation to the requester's chat/thread. | | `/debug` | Upload debug report (system info + logs) and get shareable links. | | `/help` | Show messaging help. | | `/<skill-name>` | Invoke any installed skill by name. | ## Notes - `/skin`, `/snapshot`, `/reload`, `/tools`, `/toolsets`, `/browser`, `/config`, `/cron`, `/platforms`, `/paste`, `/image`, `/statusbar`, `/plugins`, `/busy`, `/indicator`, `/redraw`, `/clear`, `/history`, `/save`, `/copy`, `/handoff`, `/billing`, and `/quit` are **CLI-only** commands. - `/skills` is **CLI-only for search/browse/install**; its write-approval review subcommands (`pending`, `approve`, `reject`, `diff`, `approval`) also work on messaging platforms when `skills.write_approval` is on. `/memory` works on **both** surfaces. - `/verbose` is **CLI-only by default**, but can be enabled for messaging platforms by setting `display.tool_progress_command: true` in `config.yaml`. When enabled, it cycles the `display.tool_progress` mode and saves to config. - `/sethome`, `/update`, `/restart`, `/approve`, `/deny`, `/topic`, `/platform`, and `/commands` are **messaging-only** commands. - `/status`, `/version`, `/background`, `/queue`, `/steer`, `/voice`, `/reload-mcp`, `/reload-skills`, `/rollback`, `/debug`, `/fast`, `/footer`, `/curator`, `/kanban`, `/credits`, `/suggestions`, `/blueprint`, `/learn`, `/sessions`, and `/yolo` work in **both** the CLI and the messaging gateway. - `/voice join`, `/voice channel`, and `/voice leave` are only meaningful on Discord. - In the TUI, `/sessions` shows live sessions in the current TUI process. Use `/resume [name]` or `claway --tui --resume <id-or-title>` for saved or closed transcripts. ## Confirmation prompts for destructive commands The CLI prompts before running slash commands that throw away unsaved session state. The current destructive set is: | Command | What it destroys | |---------|------------------| | `/clear` | Clears the screen and starts a fresh session — current session ID and in-memory history are gone. | | `/new` / `/reset` | Starts a fresh session (new session ID + empty history). | | `/undo` | Removes the last user/assistant exchange from history. | | `/exit --delete` / `/quit --delete` | Exits **and** permanently deletes the current session's SQLite history and on-disk transcripts. | For each of these the CLI opens a three-choice modal: **Approve Once** (proceed this time), **Always Approve** (proceed and persist `approvals.destructive_slash_confirm: false` so future destructive commands run without prompting), or **Cancel**. **Inline skip:** append `now`, `--yes`, or `-y` to bypass the modal for a single invocation — e.g. `/reset now`, `/new --yes my-session`, `/clear -y`, `/undo -y`. Useful when the modal doesn't render correctly on your terminal or when scripting against the CLI. Set `approvals.destructive_slash_confirm: false` in `~/.claway/config.yaml` to disable the prompts globally; set it back to `true` to re-enable. See [Security — Destructive slash command confirmation](../user-guide/security.md#dangerous-command-approval) for context. --- <!-- source: website/docs/reference/environment-variables.md --> # Environment Variables # Environment Variables Reference Claway reads environment variables from the process environment and, for user-managed secrets, from `~/.claway/.env`. Keep API keys, bot tokens, OAuth secrets, and other credentials in `.env`; prefer `config.yaml` for non-secret behaviour settings when a config key exists. Some variables below are process-only overrides or internal bridge variables and should not be committed to `.env` just because they are documented here. ## LLM Providers | Variable | Description | |----------|-------------| | `OPENROUTER_API_KEY` | OpenRouter API key (recommended for flexibility) | | `OPENROUTER_BASE_URL` | Override the OpenRouter-compatible base URL | | `CLAWAY_OPENROUTER_CACHE` | Enable OpenRouter response caching (`1`/`true`/`yes`/`on`). Overrides `openrouter.response_cache` in config.yaml. See [Response Caching](https://openrouter.ai/docs/guides/features/response-caching). | | `CLAWAY_OPENROUTER_CACHE_TTL` | Cache TTL in seconds (1-86400). Overrides `openrouter.response_cache_ttl` in config.yaml. | | `OPENAI_API_KEY` | API key for custom OpenAI-compatible endpoints (used with `OPENAI_BASE_URL`) | | `OPENAI_BASE_URL` | Base URL for custom endpoint (VLLM, SGLang, etc.) | | `LM_API_KEY` | API key for LM Studio (`lmstudio` provider). Often a placeholder for local servers | | `LM_BASE_URL` | LM Studio base URL (default: `http://localhost:1234/v1`) | | `COPILOT_GITHUB_TOKEN` | GitHub token for Copilot API — first priority (OAuth `gho_*` or fine-grained PAT `github_pat_*`; classic PATs `ghp_*` are **not supported**) | | `GH_TOKEN` | GitHub token — second priority for Copilot (also used by `gh` CLI) | | `GITHUB_TOKEN` | GitHub token — third priority for Copilot | | `CLAWAY_COPILOT_ACP_COMMAND` | Override Copilot ACP CLI binary path (default: `copilot`) | | `COPILOT_CLI_PATH` | Alias for `CLAWAY_COPILOT_ACP_COMMAND` | | `CLAWAY_COPILOT_ACP_ARGS` | Override Copilot ACP arguments (default: `--acp --stdio`) | | `COPILOT_ACP_BASE_URL` | Override Copilot ACP base URL | | `COPILOT_API_BASE_URL` | Override the Copilot API base URL (`copilot` provider) | | `GLM_API_KEY` | z.ai / ZhipuAI GLM API key ([z.ai](https://z.ai)) | | `ZAI_API_KEY` | Alias for `GLM_API_KEY` | | `Z_AI_API_KEY` | Alias for `GLM_API_KEY` | | `GLM_BASE_URL` | Override z.ai base URL (default: `https://api.z.ai/api/paas/v4`) | | `KIMI_API_KEY` | Kimi / Moonshot AI API key ([moonshot.ai](https://platform.moonshot.ai)) | | `KIMI_CODING_API_KEY` | Alias key for the `kimi-coding` provider (accepted alongside `KIMI_API_KEY`) | | `KIMI_BASE_URL` | Override Kimi base URL (default: `https://api.moonshot.ai/v1`) | | `KIMI_CN_API_KEY` | Kimi / Moonshot China API key ([moonshot.cn](https://platform.moonshot.cn)) | | `ARCEEAI_API_KEY` | Arcee AI API key ([chat.arcee.ai](https://chat.arcee.ai/)) | | `ARCEE_BASE_URL` | Override Arcee base URL (default: `https://api.arcee.ai/api/v1`) | | `GMI_API_KEY` | GMI Cloud API key ([gmicloud.ai](https://www.gmicloud.ai/)) | | `GMI_BASE_URL` | Override GMI Cloud base URL (default: `https://api.gmi-serving.com/v1`) | | `MINIMAX_API_KEY` | MiniMax API key — global endpoint ([minimax.io](https://www.minimax.io)). **Not used by `minimax-oauth`** (OAuth path uses browser login instead). | | `MINIMAX_BASE_URL` | Override MiniMax base URL (default: `https://api.minimax.io/anthropic` — Claway uses MiniMax's Anthropic Messages-compatible endpoint). **Not used by `minimax-oauth`**. | | `MINIMAX_CN_API_KEY` | MiniMax API key — China endpoint ([minimaxi.com](https://www.minimaxi.com)). **Not used by `minimax-oauth`** (OAuth path uses browser login instead). | | `MINIMAX_CN_BASE_URL` | Override MiniMax China base URL (default: `https://api.minimaxi.com/anthropic`). **Not used by `minimax-oauth`**. | | `KILOCODE_API_KEY` | Kilo Code API key ([kilo.ai](https://kilo.ai)) | | `KILOCODE_BASE_URL` | Override Kilo Code base URL (default: `https://api.kilo.ai/api/gateway`) | | `XIAOMI_API_KEY` | Xiaomi MiMo API key ([platform.xiaomimimo.com](https://platform.xiaomimimo.com)) | | `XIAOMI_BASE_URL` | Override Xiaomi MiMo base URL (default: `https://api.xiaomimimo.com/v1`) | | `TOKENHUB_API_KEY` | Tencent TokenHub API key ([tokenhub.tencentmaas.com](https://tokenhub.tencentmaas.com)) | | `TOKENHUB_BASE_URL` | Override Tencent TokenHub base URL (default: `https://tokenhub.tencentmaas.com/v1`) | | `AZURE_FOUNDRY_API_KEY` | Microsoft Foundry / Azure OpenAI API key ([ai.azure.com](https://ai.azure.com/)). Not needed when `model.auth_mode: entra_id` | | `AZURE_FOUNDRY_BASE_URL` | Microsoft Foundry endpoint URL (e.g. `https://<resource>.openai.azure.com/openai/v1` for OpenAI-style, or `https://<resource>.services.ai.azure.com/anthropic` for Anthropic-style) | | `AZURE_ANTHROPIC_KEY` | Azure Anthropic API key for `provider: anthropic` + `base_url` pointing at a Microsoft Foundry Claude deployment (alternative to `ANTHROPIC_API_KEY` when both Anthropic and Azure Anthropic are configured) | | `AZURE_TENANT_ID` | Entra ID tenant ID (service-principal flows; honored by `azure-identity` when `model.auth_mode: entra_id`) | | `AZURE_CLIENT_ID` | Entra ID client ID (service principal, workload identity, or user-assigned managed identity) | | `AZURE_CLIENT_SECRET` | Service principal secret used by `EnvironmentCredential` | | `AZURE_CLIENT_CERTIFICATE_PATH` | Service principal certificate (alternative to `AZURE_CLIENT_SECRET`) | | `AZURE_FEDERATED_TOKEN_FILE` | Federated token file path for AKS Workload Identity / OIDC flows | | `AZURE_AUTHORITY_HOST` | Sovereign-cloud authority override (e.g. `https://login.microsoftonline.us` for Azure Government). See [Azure Foundry guide](/guides/azure-foundry#sovereign-clouds-government-china) | | `IDENTITY_ENDPOINT` / `MSI_ENDPOINT` | Managed Identity endpoint for App Service, Functions, and Container Apps; VMs usually use IMDS instead and do not set these | | `HF_TOKEN` | Hugging Face token for Inference Providers ([huggingface.co/settings/tokens](https://huggingface.co/settings/tokens)) | | `HF_BASE_URL` | Override Hugging Face base URL (default: `https://router.huggingface.co/v1`) | | `GOOGLE_API_KEY` | Google AI Studio API key ([aistudio.google.com/app/apikey](https://aistudio.google.com/app/apikey)) | | `GEMINI_API_KEY` | Alias for `GOOGLE_API_KEY` | | `GEMINI_BASE_URL` | Override Google AI Studio base URL | | `ANTHROPIC_API_KEY` | Anthropic Console API key ([console.anthropic.com](https://console.anthropic.com/)) | | `ANTHROPIC_BASE_URL` | Override the Anthropic API base URL | | `ANTHROPIC_TOKEN` | Manual or legacy Anthropic OAuth/setup-token override | | `DASHSCOPE_API_KEY` | Qwen Cloud (Alibaba DashScope) API key for Qwen models ([modelstudio.console.alibabacloud.com](https://modelstudio.console.alibabacloud.com/)) | | `DASHSCOPE_BASE_URL` | Custom DashScope base URL (default: `https://dashscope-intl.aliyuncs.com/compatible-mode/v1`; use `https://dashscope.aliyuncs.com/compatible-mode/v1` for mainland-China region) | | `ALIBABA_CODING_PLAN_API_KEY` | Qwen Coding Plan API key (`alibaba-coding-plan` provider) | | `ALIBABA_CODING_PLAN_BASE_URL` | Override the Qwen Coding Plan base URL | | `DEEPSEEK_API_KEY` | DeepSeek API key for direct DeepSeek access ([platform.deepseek.com](https://platform.deepseek.com/api_keys)) | | `DEEPSEEK_BASE_URL` | Custom DeepSeek API base URL | | `NOVITA_API_KEY` | NovitaAI API key — AI-native cloud for Model API, Agent Sandbox, and GPU Cloud ([novita.ai/settings/key-management](https://novita.ai/settings/key-management)) | | `NOVITA_BASE_URL` | Override NovitaAI base URL (default: `https://api.novita.ai/openai/v1`) | | `NVIDIA_API_KEY` | NVIDIA NIM API key — Nemotron and open models ([build.nvidia.com](https://build.nvidia.com)) | | `NVIDIA_BASE_URL` | Override NVIDIA base URL (default: `https://integrate.api.nvidia.com/v1`; set to `http://localhost:8000/v1` for a local NIM endpoint) | | `STEPFUN_API_KEY` | StepFun API key — Step-series models ([platform.stepfun.com](https://platform.stepfun.com)) | | `STEPFUN_BASE_URL` | Override StepFun base URL (default: `https://api.stepfun.com/v1`) | | `OLLAMA_API_KEY` | Ollama Cloud API key — managed Ollama catalog without local GPU ([ollama.com/settings/keys](https://ollama.com/settings/keys)) | | `OLLAMA_BASE_URL` | Override Ollama Cloud base URL (default: `https://ollama.com/v1`) | | `XAI_API_KEY` | xAI (Grok) API key for chat + TTS + web search ([console.x.ai](https://console.x.ai/)) | | `XAI_BASE_URL` | Override xAI base URL (default: `https://api.x.ai/v1`) | | `MISTRAL_API_KEY` | Mistral API key for Voxtral TTS and Voxtral STT ([console.mistral.ai](https://console.mistral.ai)) | | `AWS_REGION` | AWS region for Bedrock inference (e.g. `us-east-1`, `eu-central-1`). Read by boto3. | | `AWS_PROFILE` | AWS named profile for Bedrock authentication (reads `~/.aws/credentials`). Leave unset to use default boto3 credential chain. | | `BEDROCK_BASE_URL` | Override Bedrock runtime base URL (default: `https://bedrock-runtime.us-east-1.amazonaws.com`; usually leave unset and use `AWS_REGION` instead) | | `CLAWAY_QWEN_BASE_URL` | Qwen Portal base URL override (default: `https://portal.qwen.ai/v1`) | | `OPENCODE_ZEN_API_KEY` | OpenCode Zen API key — pay-as-you-go access to curated models ([opencode.ai](https://opencode.ai/auth)) | | `OPENCODE_ZEN_BASE_URL` | Override OpenCode Zen base URL | | `OPENCODE_GO_API_KEY` | OpenCode Go API key — $10/month subscription for open models ([opencode.ai](https://opencode.ai/auth)) | | `OPENCODE_GO_BASE_URL` | Override OpenCode Go base URL | | `CLAUDE_CODE_OAUTH_TOKEN` | Explicit Claude Code token override if you export one manually | | `CLAWAY_MODEL` | Override model name at process level (used by cron scheduler; prefer `config.yaml` for normal use) | | `VOICE_TOOLS_OPENAI_KEY` | Preferred OpenAI key for OpenAI speech-to-text and text-to-speech providers | | `CLAWAY_LOCAL_STT_COMMAND` | Optional local speech-to-text command template. Supports `{input_path}`, `{output_dir}`, `{language}`, and `{model}` placeholders | | `CLAWAY_LOCAL_STT_LANGUAGE` | Default language passed to `CLAWAY_LOCAL_STT_COMMAND` or auto-detected local `whisper` CLI fallback (default: `en`) | | `CLAWAY_HOME` | Override Claway config directory (default: `~/.claway`). Also scopes the gateway PID file and systemd service name, so multiple installations can run concurrently | | `CLAWAY_GIT_BASH_PATH` | **Windows only.** Override `bash.exe` discovery for the terminal tool. Points at any bash — full Git-for-Windows install, WSL bash via symlink, MSYS2, Cygwin. The installer sets this automatically to the PortableGit it provisioned. See the Windows (Native) Guide | | `CLAWAY_DISABLE_WINDOWS_UTF8` | **Windows only.** Set to `1` to disable the UTF-8 stdio shim (`configure_windows_stdio()`) and fall back to the console's locale code page. Useful for bisecting encoding bugs; rarely the right setting in normal operation | | `CLAWAY_KANBAN_HOME` | Override the shared Claway root that anchors the kanban board (db + workspaces + worker logs). Falls back to `get_default_claway_root()` (the parent of any active profile). Useful for tests and unusual deployments | | `CLAWAY_KANBAN_BOARD` | Pin the active kanban board for this process. Takes precedence over `~/.claway/kanban/current`; the dispatcher injects this into worker subprocess env so workers physically cannot see tasks on other boards. Defaults to `default`. Slug validation: lowercase alphanumerics + hyphens + underscores, 1-64 chars | | `CLAWAY_KANBAN_DB` | Pin the kanban database file path directly (highest precedence; beats `CLAWAY_KANBAN_BOARD` and `CLAWAY_KANBAN_HOME`). The dispatcher injects this into worker subprocess env so profile workers converge on the dispatcher's board | | `CLAWAY_KANBAN_WORKSPACES_ROOT` | Pin the kanban workspaces root directly (highest precedence for workspaces; beats `CLAWAY_KANBAN_HOME`). The dispatcher injects this into worker subprocess env | | `CLAWAY_KANBAN_DISPATCH_IN_GATEWAY` | Runtime override for `kanban.dispatch_in_gateway`. Set to `0`, `false`, `no`, or `off` to keep the gateway from starting the embedded Kanban dispatcher; any other non-empty value enables it. Useful when a separate dispatcher process owns the board. | ## Provider Auth (OAuth) For native Anthropic auth, Claway prefers Claude Code's own credential files when they exist because those credentials can refresh automatically. **OAuth against Anthropic requires a Claude Max plan with purchased extra usage credits** — Claway routes as Claude Code, which only draws from the Max plan's extra/overage credits, not the base Max allowance, and does not work on Claude Pro. Without Max + extra credits, use an API key instead. Environment variables such as `ANTHROPIC_TOKEN` remain useful as manual overrides, but they are no longer the preferred path for Claude Max login. | Variable | Description | |----------|-------------| | `CLAWAY_DUMP_REQUESTS` | Dump API request payloads to log files (`true`/`false`) | | `CLAWAY_PREFILL_MESSAGES_FILE` | Path to a JSON file of ephemeral prefill messages injected at API-call time | | `CLAWAY_TIMEZONE` | IANA timezone override (for example `America/New_York`) | ## Tool APIs | Variable | Description | |----------|-------------| | `PARALLEL_API_KEY` | AI-native web search ([parallel.ai](https://parallel.ai/)) | | `FIRECRAWL_API_KEY` | Web scraping and cloud browser ([firecrawl.dev](https://firecrawl.dev/)) | | `FIRECRAWL_API_URL` | Custom Firecrawl API endpoint for self-hosted instances (optional) | | `TAVILY_API_KEY` | Tavily API key for AI-native web search, extract, and crawl ([app.tavily.com](https://app.tavily.com/home)) | | `SEARXNG_URL` | SearXNG instance URL for free self-hosted web search — no API key required ([searxng.github.io](https://searxng.github.io/searxng/)) | | `TAVILY_BASE_URL` | Override the Tavily API endpoint. Useful for corporate proxies and self-hosted Tavily-compatible search backends. Same pattern as `GROQ_BASE_URL`. | | `EXA_API_KEY` | Exa API key for AI-native web search and contents ([exa.ai](https://exa.ai/)) | | `BRAVE_SEARCH_API_KEY` | Brave Search API subscription token for web search (free tier available) ([brave.com/search/api](https://brave.com/search/api/)) | | `BROWSERBASE_API_KEY` | Browser automation ([browserbase.com](https://browserbase.com/)) | | `BROWSERBASE_PROJECT_ID` | Browserbase project ID | | `BROWSER_USE_API_KEY` | Browser Use cloud browser API key ([browser-use.com](https://browser-use.com/)) | | `FIRECRAWL_BROWSER_TTL` | Firecrawl browser session TTL in seconds (default: 300) | | `BROWSER_CDP_URL` | Chrome DevTools Protocol URL for local browser (set via `/browser connect`, e.g. `ws://localhost:9222`) | | `CAMOFOX_URL` | Camofox local anti-detection browser URL (default: `http://localhost:9377`) | | `CAMOFOX_USER_ID` | Optional externally managed Camofox user ID for shared visible sessions | | `CAMOFOX_SESSION_KEY` | Optional Camofox session key used when creating tabs for `CAMOFOX_USER_ID` | | `CAMOFOX_ADOPT_EXISTING_TAB` | Set to `true` to reuse an existing Camofox tab before creating a new one | | `BROWSER_INACTIVITY_TIMEOUT` | Browser session inactivity timeout in seconds | | `AGENT_BROWSER_ARGS` | Extra Chromium launch flags (comma- or newline-separated). Claway auto-injects `--no-sandbox,--disable-dev-shm-usage` when running as root or on AppArmor-restricted unprivileged user namespaces (Ubuntu 23.10+, DGX Spark, many container images); set this manually only to override or add other flags. | | `AGENT_BROWSER_ENGINE` | Browser engine for local mode: `auto` (default — Chromium-family via CDP), or a specific engine override. | | `FAL_KEY` | Image generation ([fal.ai](https://fal.ai/)) | | `KREA_API_KEY` | Krea API key for Krea 2 image generation ([krea.ai](https://krea.ai/)) | | `GROQ_API_KEY` | Groq Whisper STT API key ([groq.com](https://groq.com/)) | | `ELEVENLABS_API_KEY` | ElevenLabs premium TTS voices ([elevenlabs.io](https://elevenlabs.io/)) | | `STT_GROQ_MODEL` | Override the Groq STT model (default: `whisper-large-v3-turbo`) | | `GROQ_BASE_URL` | Override the Groq OpenAI-compatible STT endpoint | | `STT_OPENAI_MODEL` | Override the OpenAI STT model (default: `whisper-1`) | | `STT_OPENAI_BASE_URL` | Override the OpenAI-compatible STT endpoint | | `GITHUB_TOKEN` | GitHub token for Skills Hub (higher API rate limits, skill publish) | | `HONCHO_API_KEY` | Cross-session user modeling ([honcho.dev](https://honcho.dev/)) | | `HONCHO_BASE_URL` | Base URL for self-hosted Honcho instances (default: Honcho cloud). No API key required for local instances | | `HINDSIGHT_TIMEOUT` | Timeout in seconds for Hindsight memory-provider API calls (default: `60`). Bump this if your Hindsight instance is slow to respond during `/sync` or `on_session_switch` and you're seeing timeouts in `errors.log`. | | `SUPERMEMORY_API_KEY` | Semantic long-term memory with profile recall and session ingest ([supermemory.ai](https://supermemory.ai)) | | `DAYTONA_API_KEY` | Daytona cloud sandboxes ([daytona.io](https://daytona.io/)) | ### Skill API Keys Secrets consumed by specific bundled / optional skills. Each is only needed if you use the corresponding skill. | Variable | Used by skill | Description | |----------|---------------|-------------| | `NOTION_API_KEY` | `notion` | Notion integration token. | | `LINEAR_API_KEY` | `linear` | Linear personal API key. | | `AIRTABLE_API_KEY` | `airtable` | Airtable personal access token. | | `TENOR_API_KEY` | `gif-search` | Tenor API key for GIF search. | ### Langfuse Observability Environment variables for the bundled [`observability/langfuse`](/user-guide/features/built-in-plugins#observabilitylangfuse) plugin. Set these in `~/.claway/.env`. The plugin must also be enabled (`claway plugins enable observability/langfuse`, or check the box in `claway plugins`) before any of these take effect. | Variable | Description | |----------|-------------| | `CLAWAY_LANGFUSE_PUBLIC_KEY` | Langfuse project public key (`pk-lf-...`). Required. | | `CLAWAY_LANGFUSE_SECRET_KEY` | Langfuse project secret key (`sk-lf-...`). Required. | | `CLAWAY_LANGFUSE_BASE_URL` | Langfuse server URL (default: `https://cloud.langfuse.com`). Set for self-hosted. | | `CLAWAY_LANGFUSE_ENV` | Environment tag on traces (`production`, `staging`, …) | | `CLAWAY_LANGFUSE_RELEASE` | Release/version tag on traces | | `CLAWAY_LANGFUSE_SAMPLE_RATE` | SDK sampling rate 0.0–1.0 (default: `1.0`) | | `CLAWAY_LANGFUSE_MAX_CHARS` | Per-field truncation for serialized payloads (default: `12000`) | | `CLAWAY_LANGFUSE_DEBUG` | `true` enables verbose plugin logging to `agent.log` | | `LANGFUSE_PUBLIC_KEY` / `LANGFUSE_SECRET_KEY` / `LANGFUSE_BASE_URL` | Standard Langfuse SDK names. Accepted as fallbacks when the `CLAWAY_LANGFUSE_*` equivalents are unset. | ## Terminal Backend | Variable | Description | |----------|-------------| | `TERMINAL_ENV` | Backend: `local`, `docker`, `ssh`, `singularity`, `modal`, `daytona` | | `CLAWAY_DOCKER_BINARY` | Override the container binary Claway shells out to (e.g. `podman`, `/usr/local/bin/docker`). When unset, Claway auto-discovers `docker` or `podman` on `PATH`. Needed when both are installed and you want the non-default, or when the binary lives outside `PATH`. | | `TERMINAL_DOCKER_IMAGE` | Docker image (default: `nikolaik/python-nodejs:python3.11-nodejs20`) | | `TERMINAL_DOCKER_FORWARD_ENV` | JSON array of env var names to explicitly forward into Docker terminal sessions. Note: skill-declared `required_environment_variables` are forwarded automatically — you only need this for vars not declared by any skill. | | `TERMINAL_DOCKER_VOLUMES` | Additional Docker volume mounts (comma-separated `host:container` pairs) | | `TERMINAL_DOCKER_MOUNT_CWD_TO_WORKSPACE` | Advanced opt-in: mount the launch cwd into Docker `/workspace` (`true`/`false`, default: `false`) | | `TERMINAL_SINGULARITY_IMAGE` | Singularity image or `.sif` path | | `TERMINAL_MODAL_IMAGE` | Modal container image | | `TERMINAL_DAYTONA_IMAGE` | Daytona sandbox image | | `TERMINAL_TIMEOUT` | Command timeout in seconds | | `TERMINAL_LIFETIME_SECONDS` | Max lifetime for terminal sessions in seconds | | `TERMINAL_CWD` | Deprecated direct override for gateway/cron terminal sessions. Prefer `terminal.cwd` in `config.yaml`; CLI still uses the launch directory. | | `SUDO_PASSWORD` | Enable sudo without interactive prompt | For cloud sandbox backends, persistence is filesystem-oriented. `TERMINAL_LIFETIME_SECONDS` controls when Claway cleans up an idle terminal session, and later resumes may recreate the sandbox rather than keep the same live processes running. ## SSH Backend | Variable | Description | |----------|-------------| | `TERMINAL_SSH_HOST` | Remote server hostname | | `TERMINAL_SSH_USER` | SSH username | | `TERMINAL_SSH_PORT` | SSH port (default: 22) | | `TERMINAL_SSH_KEY` | Path to private key | | `TERMINAL_SSH_PERSISTENT` | Override persistent shell for SSH (default: follows `TERMINAL_PERSISTENT_SHELL`) | ## Container Resources (Docker, Singularity, Modal, Daytona) | Variable | Description | |----------|-------------| | `TERMINAL_CONTAINER_CPU` | CPU cores (default: 1) | | `TERMINAL_CONTAINER_MEMORY` | Memory in MB (default: 5120) | | `TERMINAL_CONTAINER_DISK` | Disk in MB (default: 51200) | | `TERMINAL_CONTAINER_PERSISTENT` | Persist container filesystem across sessions (default: `true`) | | `TERMINAL_SANDBOX_DIR` | Host directory for workspaces and overlays (default: `~/.claway/sandboxes/`) | ## Persistent Shell | Variable | Description | |----------|-------------| | `TERMINAL_PERSISTENT_SHELL` | Enable persistent shell for non-local backends (default: `true`). Also settable via `terminal.persistent_shell` in config.yaml | | `TERMINAL_LOCAL_PERSISTENT` | Enable persistent shell for local backend (default: `false`) | | `TERMINAL_SSH_PERSISTENT` | Override persistent shell for SSH backend (default: follows `TERMINAL_PERSISTENT_SHELL`) | ## Messaging | Variable | Description | |----------|-------------| | `TELEGRAM_BOT_TOKEN` | Telegram bot token (from @BotFather) | | `TELEGRAM_ALLOWED_USERS` | Comma-separated user IDs allowed to use the bot (applies to DMs, groups, and forums) | | `TELEGRAM_ALLOW_ALL_USERS` | Allow any Telegram user to trigger the bot (dev only). | | `TELEGRAM_GROUP_ALLOWED_USERS` | Comma-separated sender user IDs authorized in groups/forums only (does NOT grant DM access). Chat-ID-shaped values (starting with `-`) are still honored as chat IDs for backward compat with pre-#17686 configs, with a deprecation warning. | | `TELEGRAM_GROUP_ALLOWED_CHATS` | Comma-separated group/forum chat IDs; any member is authorized | | `TELEGRAM_HOME_CHANNEL` | Default Telegram chat/channel for cron delivery | | `TELEGRAM_HOME_CHANNEL_NAME` | Display name for the Telegram home channel | | `TELEGRAM_CRON_THREAD_ID` | Forum topic ID to receive cron deliveries; overrides `TELEGRAM_HOME_CHANNEL_THREAD_ID` for cron only. Use in topic mode so replies to cron messages open a new session instead of hitting the system lobby (#24409). | | `TELEGRAM_WEBHOOK_URL` | Public HTTPS URL for webhook mode (enables webhook instead of polling) | | `TELEGRAM_WEBHOOK_PORT` | Local listen port for webhook server (default: `8443`) | | `TELEGRAM_WEBHOOK_SECRET` | Secret token Telegram echoes back in each update for verification. **Required whenever `TELEGRAM_WEBHOOK_URL` is set** — the gateway refuses to start without it (GHSA-3vpc-7q5r-276h). Generate with `openssl rand -hex 32`. | | `TELEGRAM_REACTIONS` | Enable emoji reactions on messages during processing (default: `false`) | | `TELEGRAM_REQUIRE_MENTION` | Require an explicit trigger before responding in Telegram groups. Equivalent to `telegram.require_mention` in `config.yaml`. | | `TELEGRAM_MENTION_PATTERNS` | JSON array, newline-separated list, or comma-separated list of regex wake-word patterns accepted when Telegram group mention gating is enabled. Equivalent to `telegram.mention_patterns`. | | `TELEGRAM_EXCLUSIVE_BOT_MENTIONS` | When enabled, explicit `@...bot` mentions in Telegram groups route only to the mentioned bot usernames before reply or wake-word fallbacks run. Default: `true`. Equivalent to `telegram.exclusive_bot_mentions`. | | `TELEGRAM_REPLY_TO_MODE` | Reply-reference behavior: `off`, `first` (default), or `all`. Matches the Discord pattern. | | `TELEGRAM_IGNORED_THREADS` | Comma-separated Telegram forum topic/thread IDs where the bot never responds | | `TELEGRAM_PROXY` | Proxy URL for Telegram connections — overrides `HTTPS_PROXY`. Supports `http://`, `https://`, `socks5://` | | `DISCORD_BOT_TOKEN` | Discord bot token | | `DISCORD_ALLOWED_USERS` | Comma-separated Discord user IDs allowed to use the bot | | `DISCORD_ALLOW_ALL_USERS` | Allow any Discord user to trigger the bot (dev only). | | `DISCORD_ALLOWED_ROLES` | Comma-separated Discord role IDs allowed to use the bot (OR with `DISCORD_ALLOWED_USERS`). Auto-enables the Members intent. Useful when moderation teams churn — role grants propagate automatically. | | `DISCORD_ALLOWED_CHANNELS` | Comma-separated Discord channel IDs. When set, the bot only responds in these channels (plus DMs if allowed). Overrides `config.yaml` `discord.allowed_channels`. | | `DISCORD_PROXY` | Proxy URL for Discord connections — overrides `HTTPS_PROXY`. Supports `http://`, `https://`, `socks5://` | | `DISCORD_HOME_CHANNEL` | Default Discord channel for cron delivery | | `DISCORD_HOME_CHANNEL_NAME` | Display name for the Discord home channel | | `DISCORD_COMMAND_SYNC_POLICY` | Discord slash-command startup sync policy: `safe` (diff and reconcile), `bulk` (legacy `tree.sync()`), or `off` | | `DISCORD_REQUIRE_MENTION` | Require an @mention before responding in server channels | | `DISCORD_FREE_RESPONSE_CHANNELS` | Comma-separated channel IDs where mention is not required | | `DISCORD_AUTO_THREAD` | Auto-thread long replies when supported | | `DISCORD_ALLOW_ANY_ATTACHMENT` | When `true`, accept attachments of any file type (not just the built-in PDF/text/zip/office allowlist). Unknown types are cached and surfaced to the agent as a local path so it can inspect them via `terminal` / `read_file` / `ffprobe`. Default `false`. | | `DISCORD_MAX_ATTACHMENT_BYTES` | Maximum bytes per attachment the gateway will cache. Default `33554432` (32 MiB). Set to `0` for no cap (attachments are held in memory while being written). | | `DISCORD_REACTIONS` | Enable emoji reactions on messages during processing (default: `true`) | | `DISCORD_IGNORED_CHANNELS` | Comma-separated channel IDs where the bot never responds | | `DISCORD_NO_THREAD_CHANNELS` | Comma-separated channel IDs where bot responds without auto-threading | | `DISCORD_REPLY_TO_MODE` | Reply-reference behavior: `off`, `first` (default), or `all` | | `DISCORD_ALLOW_MENTION_EVERYONE` | Allow the bot to ping `@everyone`/`@here` (default: `false`). See [Mention Control](../user-guide/messaging/discord.md#mention-control). | | `DISCORD_ALLOW_MENTION_ROLES` | Allow the bot to ping `@role` mentions (default: `false`). | | `DISCORD_ALLOW_MENTION_USERS` | Allow the bot to ping individual `@user` mentions (default: `true`). | | `DISCORD_ALLOW_MENTION_REPLIED_USER` | Ping the author when replying to their message (default: `true`). | | `SLACK_BOT_TOKEN` | Slack bot token (`xoxb-...`) | | `SLACK_APP_TOKEN` | Slack app-level token (`xapp-...`, required for Socket Mode) | | `SLACK_ALLOWED_USERS` | Comma-separated Slack user IDs | | `SLACK_ALLOW_ALL_USERS` | Allow any Slack user to trigger the bot (dev only). | | `SLACK_HOME_CHANNEL` | Default Slack channel for cron delivery | | `SLACK_HOME_CHANNEL_NAME` | Display name for the Slack home channel | | `GOOGLE_CHAT_PROJECT_ID` | GCP project hosting the Pub/Sub topic (falls back to `GOOGLE_CLOUD_PROJECT`) | | `GOOGLE_CHAT_SUBSCRIPTION_NAME` | Full Pub/Sub subscription path, `projects/{proj}/subscriptions/{sub}` (legacy alias: `GOOGLE_CHAT_SUBSCRIPTION`) | | `GOOGLE_CHAT_SERVICE_ACCOUNT_JSON` | Path to Service Account JSON, or the JSON inline (falls back to `GOOGLE_APPLICATION_CREDENTIALS`) | | `GOOGLE_CHAT_ALLOWED_USERS` | Comma-separated user emails allowed to chat with the bot | | `GOOGLE_CHAT_ALLOW_ALL_USERS` | Allow any Google Chat user to trigger the bot (dev only) | | `GOOGLE_CHAT_HOME_CHANNEL` | Default space (e.g. `spaces/AAAA...`) for cron delivery | | `GOOGLE_CHAT_HOME_CHANNEL_NAME` | Display name for the Google Chat home space | | `GOOGLE_CHAT_MAX_MESSAGES` | Pub/Sub FlowControl max in-flight messages (default: `1`) | | `GOOGLE_CHAT_MAX_BYTES` | Pub/Sub FlowControl max in-flight bytes (default: `16777216`, 16 MiB) | | `GOOGLE_CHAT_BOOTSTRAP_SPACES` | Comma-separated extra space IDs to probe at startup when resolving the bot's own `users/{id}` | | `GOOGLE_CHAT_DEBUG_RAW` | Set to any value to log redacted Pub/Sub envelopes at DEBUG level (debugging only) | | `WHATSAPP_ENABLED` | Enable the WhatsApp bridge (`true`/`false`) | | `WHATSAPP_MODE` | `bot` (separate number) or `self-chat` (message yourself) | | `WHATSAPP_ALLOWED_USERS` | Comma-separated phone numbers (with country code, no `+`), or `*` to allow all senders | | `WHATSAPP_ALLOW_ALL_USERS` | Allow all WhatsApp senders without an allowlist (`true`/`false`) | | `WHATSAPP_HOME_CHANNEL` | Default chat ID for cron / notification delivery. | | `WHATSAPP_HOME_CHANNEL_NAME` | Display name for the WhatsApp home channel. | | `WHATSAPP_DEBUG` | Log raw message events in the bridge for troubleshooting (`true`/`false`) | | `WHATSAPP_CLOUD_PHONE_NUMBER_ID` | Meta Phone Number ID from the WhatsApp Business Cloud API (15–17 digits; **not** the phone number itself) | | `WHATSAPP_CLOUD_ACCESS_TOKEN` | Meta access token (starts with `EAA`); temporary tokens expire after 24h, System User tokens are permanent | | `WHATSAPP_CLOUD_APP_SECRET` | 32-char hex app secret used to verify inbound webhook signatures | | `WHATSAPP_CLOUD_VERIFY_TOKEN` | Shared secret for Meta's webhook verification handshake (auto-generated by the setup wizard) | | `WHATSAPP_CLOUD_ALLOWED_USERS` | Comma-separated `wa_id`s (phone numbers with country code, no `+`) allowed to message the bot | | `WHATSAPP_CLOUD_ALLOW_ALL_USERS` | Allow all WhatsApp Cloud senders without an allowlist (`true`/`false`) | | `WHATSAPP_CLOUD_APP_ID` | Optional Meta App ID (for future analytics integration) | | `WHATSAPP_CLOUD_WABA_ID` | Optional WhatsApp Business Account ID (for future analytics integration) | | `WHATSAPP_CLOUD_WEBHOOK_HOST` | Interface the inbound webhook server binds to (default `0.0.0.0`) | | `WHATSAPP_CLOUD_WEBHOOK_PORT` | Port the inbound webhook server binds to (default `8090`) | | `WHATSAPP_CLOUD_WEBHOOK_PATH` | URL path Meta posts inbound messages to (default `/whatsapp/webhook`) | | `WHATSAPP_CLOUD_API_VERSION` | Meta Graph API version to call (default `v20.0`) | | `WHATSAPP_CLOUD_HOME_CHANNEL` | `wa_id` to use as the bot's home channel (for cron jobs etc.) | | `WHATSAPP_CLOUD_DM_POLICY` | DM gating for the Cloud adapter (`open`/`allowlist`/`disabled`); falls back to `WHATSAPP_DM_POLICY` when unset | | `WHATSAPP_CLOUD_ALLOW_FROM` | Comma-separated senders allowed when `dm_policy: allowlist` (bare `wa_id`s; Baileys-style JIDs are normalized) | | `WHATSAPP_CLOUD_GROUP_POLICY` | Group gating for the Cloud adapter (`open`/`allowlist`/`disabled`); falls back to `WHATSAPP_GROUP_POLICY` when unset | | `WHATSAPP_CLOUD_GROUP_ALLOW_FROM` | Comma-separated group chat IDs allowed when `group_policy: allowlist` | | `SIGNAL_HTTP_URL` | signal-cli daemon HTTP endpoint (for example `http://127.0.0.1:8080`) | | `SIGNAL_ACCOUNT` | Bot phone number in E.164 format | | `SIGNAL_ALLOWED_USERS` | Comma-separated E.164 phone numbers or UUIDs | | `SIGNAL_GROUP_ALLOWED_USERS` | Comma-separated group IDs, or `*` for all groups | | `SIGNAL_HOME_CHANNEL_NAME` | Display name for the Signal home channel | | `SIGNAL_IGNORE_STORIES` | Ignore Signal stories/status updates | | `SIGNAL_ALLOW_ALL_USERS` | Allow all Signal users without an allowlist | | `TWILIO_ACCOUNT_SID` | Twilio Account SID (shared with telephony skill) | | `TWILIO_AUTH_TOKEN` | Twilio Auth Token (shared with telephony skill; also used for webhook signature validation) | | `TWILIO_PHONE_NUMBER` | Twilio phone number in E.164 format (shared with telephony skill) | | `SMS_WEBHOOK_URL` | Public URL for Twilio signature validation — must match the webhook URL in Twilio Console (required) | | `SMS_WEBHOOK_PORT` | Webhook listener port for inbound SMS (default: `8080`) | | `SMS_WEBHOOK_HOST` | Webhook bind address (default: `0.0.0.0`) | | `SMS_INSECURE_NO_SIGNATURE` | Set to `true` to disable Twilio signature validation (local dev only — not for production) | | `SMS_ALLOWED_USERS` | Comma-separated E.164 phone numbers allowed to chat | | `SMS_ALLOW_ALL_USERS` | Allow all SMS senders without an allowlist | | `SMS_HOME_CHANNEL` | Phone number for cron job / notification delivery | | `SMS_HOME_CHANNEL_NAME` | Display name for the SMS home channel | | `EMAIL_ADDRESS` | Email address for the Email gateway adapter | | `EMAIL_PASSWORD` | Password or app password for the email account | | `EMAIL_IMAP_HOST` | IMAP hostname for the email adapter | | `EMAIL_IMAP_PORT` | IMAP port | | `EMAIL_SMTP_HOST` | SMTP hostname for the email adapter | | `EMAIL_SMTP_PORT` | SMTP port | | `EMAIL_ALLOWED_USERS` | Comma-separated email addresses allowed to message the bot | | `EMAIL_HOME_ADDRESS` | Default recipient for proactive email delivery | | `EMAIL_HOME_ADDRESS_NAME` | Display name for the email home target | | `EMAIL_POLL_INTERVAL` | Email polling interval in seconds | | `EMAIL_ALLOW_ALL_USERS` | Allow all inbound email senders | | `DINGTALK_CLIENT_ID` | DingTalk bot AppKey from developer portal ([open.dingtalk.com](https://open.dingtalk.com)) | | `DINGTALK_CLIENT_SECRET` | DingTalk bot AppSecret from developer portal | | `DINGTALK_ALLOWED_USERS` | Comma-separated DingTalk user IDs allowed to message the bot | | `DINGTALK_WEBHOOK_URL` | Static robot webhook URL for cross-platform / cron delivery. | | `DINGTALK_HOME_CHANNEL` | Default conversation ID for cron / notification delivery. | | `DINGTALK_HOME_CHANNEL_NAME` | Display name for the DingTalk home channel. | | `FEISHU_APP_ID` | Feishu/Lark bot App ID from [open.feishu.cn](https://open.feishu.cn/) | | `FEISHU_APP_SECRET` | Feishu/Lark bot App Secret | | `FEISHU_DOMAIN` | `feishu` (China) or `lark` (international). Default: `feishu` | | `FEISHU_CONNECTION_MODE` | `websocket` (recommended) or `webhook`. Default: `websocket` | | `FEISHU_ENCRYPT_KEY` | Optional encryption key for webhook mode | | `FEISHU_VERIFICATION_TOKEN` | Optional verification token for webhook mode | | `FEISHU_ALLOWED_USERS` | Comma-separated Feishu user IDs allowed to message the bot | | `FEISHU_ALLOW_BOTS` | `none` (default) / `mentions` / `all` — accept inbound messages from other bots. See [bot-to-bot messaging](../user-guide/messaging/feishu.md#bot-to-bot-messaging) | | `FEISHU_REQUIRE_MENTION` | `true` (default) / `false` — whether group messages must @mention the bot. Override per-chat via `group_rules.<chat_id>.require_mention`. | | `FEISHU_HOME_CHANNEL` | Feishu chat ID for cron delivery and notifications | | `FEISHU_HOME_CHANNEL_NAME` | Display name for the Feishu home channel. | | `FEISHU_ALLOW_ALL_USERS` | Allow any Feishu user to trigger the bot (dev only). | | `WECOM_BOT_ID` | WeCom AI Bot ID from admin console | | `WECOM_SECRET` | WeCom AI Bot secret | | `WECOM_WEBSOCKET_URL` | Custom WebSocket URL (default: `wss://openws.work.weixin.qq.com`) | | `WECOM_ALLOWED_USERS` | Comma-separated WeCom user IDs allowed to message the bot | | `WECOM_HOME_CHANNEL` | WeCom chat ID for cron delivery and notifications | | `WECOM_CALLBACK_CORP_ID` | WeCom enterprise Corp ID for callback self-built app | | `WECOM_CALLBACK_CORP_SECRET` | Corp secret for the self-built app | | `WECOM_CALLBACK_AGENT_ID` | Agent ID of the self-built app | | `WECOM_CALLBACK_TOKEN` | Callback verification token | | `WECOM_CALLBACK_ENCODING_AES_KEY` | AES key for callback encryption | | `WECOM_CALLBACK_HOST` | Callback server bind address (default: `0.0.0.0`) | | `WECOM_CALLBACK_PORT` | Callback server port (default: `8645`) | | `WECOM_CALLBACK_ALLOWED_USERS` | Comma-separated user IDs for allowlist | | `WECOM_CALLBACK_ALLOW_ALL_USERS` | Set `true` to allow all users without an allowlist | | `WEIXIN_ACCOUNT_ID` | Weixin account ID obtained via QR login through iLink Bot API | | `WEIXIN_TOKEN` | Weixin authentication token obtained via QR login through iLink Bot API | | `WEIXIN_BASE_URL` | Override Weixin iLink Bot API base URL (default: `https://ilinkai.weixin.qq.com`) | | `WEIXIN_CDN_BASE_URL` | Override Weixin CDN base URL for media (default: `https://novac2c.cdn.weixin.qq.com/c2c`) | | `WEIXIN_DM_POLICY` | Direct message policy: `open`, `allowlist`, `pairing`, `disabled` (default: `open`) | | `WEIXIN_GROUP_POLICY` | Group message policy: `open`, `allowlist`, `disabled` (default: `disabled`) | | `WEIXIN_ALLOWED_USERS` | Comma-separated Weixin user IDs allowed to DM the bot | | `WEIXIN_GROUP_ALLOWED_USERS` | Comma-separated Weixin **group chat IDs** (not member user IDs) allowed to interact with the bot. The variable name is legacy — it expects group IDs. Only takes effect when iLink actually delivers group events; QR-login iLink bot identities (`...@im.bot`) typically don't receive ordinary WeChat group messages. | | `WEIXIN_HOME_CHANNEL` | Weixin chat ID for cron delivery and notifications | | `WEIXIN_HOME_CHANNEL_NAME` | Display name for the Weixin home channel | | `WEIXIN_ALLOW_ALL_USERS` | Allow all Weixin users without an allowlist (`true`/`false`) | | `BLUEBUBBLES_SERVER_URL` | BlueBubbles server URL (e.g. `http://192.168.1.10:1234`) | | `BLUEBUBBLES_PASSWORD` | BlueBubbles server password | | `BLUEBUBBLES_WEBHOOK_HOST` | Webhook listener bind address (default: `127.0.0.1`) | | `BLUEBUBBLES_WEBHOOK_PORT` | Webhook listener port (default: `8645`) | | `BLUEBUBBLES_HOME_CHANNEL` | Phone/email for cron/notification delivery | | `BLUEBUBBLES_ALLOWED_USERS` | Comma-separated authorized users | | `BLUEBUBBLES_ALLOW_ALL_USERS` | Allow all users (`true`/`false`) | | `QQ_APP_ID` | QQ Bot App ID from [q.qq.com](https://q.qq.com) | | `QQ_CLIENT_SECRET` | QQ Bot App Secret from [q.qq.com](https://q.qq.com) | | `QQ_STT_API_KEY` | API key for external STT fallback provider (optional, used when QQ built-in ASR returns no text) | | `QQ_STT_BASE_URL` | Base URL for external STT provider (optional) | | `QQ_STT_MODEL` | Model name for external STT provider (optional) | | `QQ_ALLOWED_USERS` | Comma-separated QQ user openIDs allowed to message the bot | | `QQ_GROUP_ALLOWED_USERS` | Comma-separated QQ group IDs for group @-message access | | `QQ_ALLOW_ALL_USERS` | Allow all users (`true`/`false`, overrides `QQ_ALLOWED_USERS`) | | `QQBOT_HOME_CHANNEL` | QQ user/group openID for cron delivery and notifications | | `QQBOT_HOME_CHANNEL_NAME` | Display name for the QQ home channel | | `QQ_PORTAL_HOST` | Override the QQ portal host (set to `sandbox.q.qq.com` to route through the sandbox gateway; default: `q.qq.com`). | | `QQ_SANDBOX` | Enable QQ sandbox mode for development testing (`true`/`false`) | | `MATTERMOST_URL` | Mattermost server URL (e.g. `https://mm.example.com`) | | `MATTERMOST_TOKEN` | Bot token or personal access token for Mattermost | | `MATTERMOST_ALLOWED_USERS` | Comma-separated Mattermost user IDs allowed to message the bot | | `MATTERMOST_ALLOW_ALL_USERS` | Allow any Mattermost user to trigger the bot (dev only). | | `MATTERMOST_ALLOWED_CHANNELS` | If set, the bot only responds in these channels (whitelist). | | `MATTERMOST_HOME_CHANNEL` | Channel ID for proactive message delivery (cron, notifications) | | `MATTERMOST_REQUIRE_MENTION` | Require `@mention` in channels (default: `true`). Set to `false` to respond to all messages. | | `MATTERMOST_FREE_RESPONSE_CHANNELS` | Comma-separated channel IDs where bot responds without `@mention` | | `MATTERMOST_REPLY_MODE` | Reply style: `thread` (threaded replies) or `off` (flat messages, default) | | `MATRIX_HOMESERVER` | Matrix homeserver URL (e.g. `https://matrix.org`) | | `MATRIX_ACCESS_TOKEN` | Matrix access token for bot authentication | | `MATRIX_USER_ID` | Matrix user ID (e.g. `@claway:matrix.org`) — required for password login, optional with access token | | `MATRIX_PASSWORD` | Matrix password (alternative to access token) | | `MATRIX_ALLOWED_USERS` | Comma-separated Matrix user IDs allowed to message the bot (e.g. `@alice:matrix.org`) | | `MATRIX_ALLOW_ALL_USERS` | Allow any Matrix user to trigger the bot (dev only). | | `MATRIX_HOME_CHANNEL` | Default room ID for cron / notification delivery. | | `MATRIX_HOME_CHANNEL_NAME` | Display name for the Matrix home room. | | `MATRIX_ALLOWED_ROOMS` | Comma-separated Matrix room IDs allowed to trigger bot responses | | `MATRIX_HOME_ROOM` | Room ID for proactive message delivery (e.g. `!abc123:matrix.org`) | | `MATRIX_ENCRYPTION` | Enable end-to-end encryption (`true`/`false`, default: `false`) | | `MATRIX_E2EE_MODE` | Matrix E2EE behavior: `off`, `optional`, or `required`. Overrides `MATRIX_ENCRYPTION` when set. | | `MATRIX_DEVICE_ID` | Stable Matrix device ID for E2EE persistence across restarts (e.g. `CLAWAY_BOT`). Without this, E2EE keys rotate every startup and historic-room decrypt breaks. | | `MATRIX_REACTIONS` | Enable processing-lifecycle emoji reactions on inbound messages (default: `true`). Set to `false` to disable. | | `MATRIX_REQUIRE_MENTION` | Require `@mention` in rooms (default: `true`). Set to `false` to respond to all messages. | | `MATRIX_FREE_RESPONSE_ROOMS` | Comma-separated room IDs where bot responds without `@mention` | | `MATRIX_IGNORE_USER_PATTERNS` | Comma-separated regular expressions for Matrix bridge/appservice ghost user IDs to ignore | | `MATRIX_PROCESS_NOTICES` | Process inbound Matrix `m.notice` events (default: `false`) | | `MATRIX_SESSION_SCOPE` | Matrix session scope for project rooms: `auto`, `room`, or `thread` (default: `auto`) | | `MATRIX_TOOLS_ALLOW_CROSS_ROOM` | Allow Matrix tools to target explicit rooms other than the current room (default: `false`) | | `MATRIX_TOOLS_ALLOW_CROSS_ROOM_DESTRUCTIVE` | Allow cross-room Matrix redaction/invite-like tools; requires `MATRIX_TOOLS_ALLOW_CROSS_ROOM=true` (default: `false`) | | `MATRIX_TOOLS_ALLOW_REDACTION` | Allow Matrix message redaction tool execution (default: `false`) | | `MATRIX_TOOLS_ALLOW_INVITES` | Allow Matrix invite tool execution (default: `false`) | | `MATRIX_TOOLS_ALLOW_ROOM_CREATE` | Allow Matrix room creation tool execution (default: `false`) | | `MATRIX_ALLOW_ROOM_MENTIONS` | Allow outbound `@room` mentions to notify all room members (default: `false`) | | `MATRIX_AUTO_THREAD` | Auto-create threads for room messages (default: `true`) | | `MATRIX_DM_AUTO_THREAD` | Auto-create threads for DM messages in Matrix (default: `false`) | | `MATRIX_DM_MENTION_THREADS` | Create a thread when bot is `@mentioned` in a DM (default: `false`) | | `MATRIX_APPROVAL_REQUIRE_SENDER` | Require approval/model-picker reactions to come from the original requester when known (default: `true`) | | `MATRIX_APPROVAL_TIMEOUT_SECONDS` | Timeout for Matrix reaction approval/model-picker prompts (default: `300`) | | `MATRIX_ALLOW_PUBLIC_ROOMS` | Allow Matrix room-creation tools to create public rooms (default: `false`) | | `MATRIX_MAX_MEDIA_BYTES` | Maximum Matrix media upload/download size in bytes (default: `104857600`) | | `MATRIX_RECOVERY_KEY` | Recovery key for cross-signing verification after device key rotation. Recommended for E2EE setups with cross-signing enabled. | | `MATRIX_RECOVERY_KEY_OUTPUT_FILE` | Optional one-time path for a generated Matrix recovery key. Created with mode `0600` and never overwritten. | | `HASS_TOKEN` | Home Assistant Long-Lived Access Token (enables HA platform + tools) | | `HASS_URL` | Home Assistant URL (default: `http://homeassistant.local:8123`) | | `WEBHOOK_ENABLED` | Enable the webhook platform adapter (`true`/`false`) | | `WEBHOOK_PORT` | HTTP server port for receiving webhooks (default: `8644`) | | `WEBHOOK_SECRET` | Global HMAC secret for webhook signature validation (used as fallback when routes don't specify their own) | | `API_SERVER_ENABLED` | Enable the OpenAI-compatible API server (`true`/`false`). Runs alongside other platforms. | | `API_SERVER_KEY` | Bearer token for API server authentication. Required whenever the API server is enabled. | | `API_SERVER_CORS_ORIGINS` | Comma-separated browser origins allowed to call the API server directly (for example `http://localhost:3000,http://127.0.0.1:3000`). Default: disabled. | | `API_SERVER_PORT` | Port for the API server (default: `8642`) | | `API_SERVER_HOST` | Host/bind address for the API server (default: `127.0.0.1`). `API_SERVER_KEY` is still required on loopback; use a narrow `API_SERVER_CORS_ORIGINS` allowlist for browser access. | | `API_SERVER_MODEL_NAME` | Model name advertised on `/v1/models`. Defaults to the profile name (or `claway` for the default profile). Useful for multi-user setups where frontends like Open WebUI need distinct model names per connection. | | `GATEWAY_PROXY_URL` | URL of a remote Claway API server to forward messages to ([proxy mode](/user-guide/messaging/matrix#proxy-mode-e2ee-on-macos)). When set, the gateway handles platform I/O only — all agent work is delegated to the remote server. Also configurable via `gateway.proxy_url` in `config.yaml`. | | `GATEWAY_PROXY_KEY` | Bearer token for authenticating with the remote API server in proxy mode. Must match `API_SERVER_KEY` on the remote host. | | `MESSAGING_CWD` | Deprecated compatibility fallback for gateway working directory. Prefer `terminal.cwd` in `config.yaml`. | | `GATEWAY_ALLOWED_USERS` | Comma-separated user IDs allowed across all platforms | | `GATEWAY_ALLOW_ALL_USERS` | Allow all users without allowlists (`true`/`false`, default: `false`) | ### `claway dashboard` authentication Auth for the `claway dashboard` web UI of a personal install. (On a Claway Box or hosted Claway, the OPS dashboard has its own sign-in: operator password plus an authenticator code.) Per the secrets-only convention, credentials belong in `~/.claway/.env`. Two dashboard-auth providers apply here. The bundled **username/password** provider (`CLAWAY_DASHBOARD_BASIC_AUTH_*`) is the quickest option for a backend on a trusted LAN or behind a VPN, but is not suitable for direct public-internet exposure. To authenticate against your own identity provider, use the **self-hosted OIDC** provider (`CLAWAY_DASHBOARD_OIDC_*`). Either way, a non-loopback bind (`claway dashboard --host 0.0.0.0`) engages the auth gate. | Variable | Description | |----------|-------------| | `CLAWAY_DASHBOARD_BASIC_AUTH_USERNAME` | Username for the bundled username/password dashboard-auth provider (`plugins/dashboard_auth/basic`). Activates the provider when set together with a password. Overrides `dashboard.basic_auth.username`. | | `CLAWAY_DASHBOARD_BASIC_AUTH_PASSWORD` | Plaintext password for the basic provider (hashed in-memory at load). Wins over a config `password_hash` so you can rotate via env. Overrides `dashboard.basic_auth.password`. | | `CLAWAY_DASHBOARD_BASIC_AUTH_PASSWORD_HASH` | scrypt password hash for the basic provider (preferred — no plaintext at rest). Compute with `python -c "from plugins.dashboard_auth.basic import hash_password; print(hash_password('PW'))"`. Overrides `dashboard.basic_auth.password_hash`. | | `CLAWAY_DASHBOARD_BASIC_AUTH_SECRET` | HMAC key (32+ bytes, base64/hex/raw) signing the basic provider's stateless session tokens. Set explicitly so sessions survive restarts / span multiple workers; blank → random per-process (you'll be logged out on every restart). Overrides `dashboard.basic_auth.secret`. | | `CLAWAY_DASHBOARD_BASIC_AUTH_TTL_SECONDS` | Access-token lifetime for the basic provider (default 12h). Overrides `dashboard.basic_auth.session_ttl_seconds`. | | `CLAWAY_DASHBOARD_PUBLIC_URL` | Complete public URL the dashboard is reached at, for OAuth callback construction behind reverse proxies. Overrides `dashboard.public_url`. | | `CLAWAY_DASHBOARD_OIDC_ISSUER` | OIDC issuer URL for the bundled self-hosted OIDC provider (`plugins/dashboard_auth/self_hosted`). Required to activate it. Overrides `dashboard.oauth.self_hosted.issuer`. | | `CLAWAY_DASHBOARD_OIDC_CLIENT_ID` | Public OIDC client id (authorization-code + PKCE) for the self-hosted OIDC provider. Required to activate it. Overrides `dashboard.oauth.self_hosted.client_id`. | | `CLAWAY_DASHBOARD_OIDC_SCOPES` | Requested OIDC scopes for the self-hosted OIDC provider (default `openid profile email`). Overrides `dashboard.oauth.self_hosted.scopes`. | | `CLAWAY_DESKTOP_REMOTE_URL` | (Desktop side) Base URL of the remote backend, e.g. `http://host:9119`. When set, overrides the in-app Gateway URL; you still sign in from the Gateway settings panel (OAuth redirect or username/password, whichever the backend advertises). | | `CLAWAY_DESKTOP_CLAWAY` | Desktop backend command override. Used by packagers/Nix or troubleshooting to point Electron at a specific `claway` executable after backend probing. | | `CLAWAY_DESKTOP_CLAWAY_ROOT` | Desktop source-checkout override used by `claway desktop --claway-root`; checked before the packaged first-launch install or an existing `claway` on `PATH`. | | `CLAWAY_DESKTOP_IGNORE_EXISTING` | Set to `1` to make Desktop ignore an existing `claway` on `PATH` during backend resolution. Equivalent to `claway desktop --ignore-existing`. | | `CLAWAY_DESKTOP_CWD` | Initial project directory for Desktop chat sessions. Set by `claway desktop --cwd`. | ### Microsoft Graph (Teams Meetings) App-only credentials for the Microsoft Graph REST client used by the upcoming Teams meeting summary pipeline. See [Register a Microsoft Graph application](/guides/microsoft-graph-app-registration) for the Azure portal walkthrough and the exact API permissions required. | Variable | Description | |----------|-------------| | `MSGRAPH_TENANT_ID` | Azure AD tenant ID (directory GUID) for the Graph app registration. | | `MSGRAPH_CLIENT_ID` | Application (client) ID of the Azure app registration. | | `MSGRAPH_CLIENT_SECRET` | Client secret value for the app registration. Store in `~/.claway/.env` with `chmod 600`; rotate periodically via the Azure portal. | | `MSGRAPH_SCOPE` | OAuth2 scope for the client-credentials token request (default: `https://graph.microsoft.com/.default`). | | `MSGRAPH_AUTHORITY_URL` | Microsoft identity platform authority (default: `https://login.microsoftonline.com`). Override only for national/sovereign clouds (e.g. `https://login.microsoftonline.us` for GCC High). | ### Microsoft Graph Webhook Listener Inbound change-notification listener for Graph events (Teams meetings, calendar, chat, etc.). See [Microsoft Graph Webhook Listener](/user-guide/messaging/msgraph-webhook) for setup and security hardening. | Variable | Description | |----------|-------------| | `MSGRAPH_WEBHOOK_ENABLED` | Enable the `msgraph_webhook` gateway platform (`true`/`1`/`yes`). | | `MSGRAPH_WEBHOOK_PORT` | Port the listener binds to (default: `8646`). | | `MSGRAPH_WEBHOOK_CLIENT_STATE` | Shared secret Graph echoes in every notification; compared with `hmac.compare_digest`. Generate with `openssl rand -hex 32`. | | `MSGRAPH_WEBHOOK_ACCEPTED_RESOURCES` | Comma-separated allowlist of Graph resource paths/patterns (e.g. `communications/onlineMeetings,chats/*/messages`). Trailing `*` is prefix-matching. Empty = accept all. | | `MSGRAPH_WEBHOOK_ALLOWED_SOURCE_CIDRS` | Comma-separated CIDR ranges allowed to POST to the listener (e.g. `52.96.0.0/14,52.104.0.0/14`). Empty = allow all (default). Restrict to Microsoft Graph's published egress ranges in production. | ### Teams Meeting Summary Delivery Only used when the [`teams_pipeline` plugin](/user-guide/messaging/msgraph-webhook) is enabled. Settings are also configurable under `platforms.teams.extra` in `config.yaml` — env vars take priority when both are set. See [Microsoft Teams → Meeting Summary Delivery](/user-guide/messaging/teams#meeting-summary-delivery-teams-meeting-pipeline). | Variable | Description | |----------|-------------| | `TEAMS_DELIVERY_MODE` | `graph` or `incoming_webhook`. | | `TEAMS_INCOMING_WEBHOOK_URL` | Teams-generated webhook URL; required when `TEAMS_DELIVERY_MODE=incoming_webhook`. | | `TEAMS_GRAPH_ACCESS_TOKEN` | Pre-acquired delegated access token for Graph delivery. Rarely needed — the writer falls back to the `MSGRAPH_*` app credentials when unset. | | `TEAMS_TEAM_ID` | Target Team ID for channel delivery (`graph` mode). | | `TEAMS_CHANNEL_ID` | Target channel ID (paired with `TEAMS_TEAM_ID`). | | `TEAMS_CHAT_ID` | Target 1:1 or group chat ID (alternative to team+channel for `graph` mode). | ### LINE Messaging API Used by the bundled LINE platform plugin (`plugins/platforms/line/`). See [Messaging Gateway → LINE](/user-guide/messaging/line) for full setup. | Variable | Description | |----------|-------------| | `LINE_CHANNEL_ACCESS_TOKEN` | Long-lived channel access token from the LINE Developers Console (Messaging API tab). Required. | | `LINE_CHANNEL_SECRET` | Channel secret (Basic settings tab); used for HMAC-SHA256 webhook signature verification. Required. | | `LINE_HOST` | Webhook bind host (default: `0.0.0.0`). | | `LINE_PORT` | Webhook bind port (default: `8646`). | | `LINE_PUBLIC_URL` | Public HTTPS base URL (e.g. `https://my-tunnel.example.com`). Required for image / audio / video sends — LINE only accepts HTTPS-reachable URLs. | | `LINE_ALLOWED_USERS` | Comma-separated user IDs allowed to DM the bot (`U`-prefixed). | | `LINE_ALLOWED_GROUPS` | Comma-separated group IDs the bot will respond in (`C`-prefixed). | | `LINE_ALLOWED_ROOMS` | Comma-separated room IDs the bot will respond in (`R`-prefixed). | | `LINE_ALLOW_ALL_USERS` | Dev-only escape hatch — accepts any source. Default: `false`. | | `LINE_HOME_CHANNEL` | Default delivery target for cron jobs with `deliver: line`. | | `LINE_SLOW_RESPONSE_THRESHOLD` | Seconds before the slow-LLM Template Buttons postback fires (default: `45`). Set `0` to disable and always Push-fallback. | | `LINE_PENDING_TEXT` | Bubble text shown alongside the postback button. | | `LINE_BUTTON_LABEL` | Postback button label (default: `Get answer`). | | `LINE_DELIVERED_TEXT` | Reply when an already-delivered postback is tapped again (default: `Already replied ✅`). | | `LINE_INTERRUPTED_TEXT` | Reply when a `/stop`-orphaned postback button is tapped (default: `Run was interrupted before completion.`). | ### ntfy (push notifications) [ntfy](https://ntfy.sh/) is a lightweight HTTP-based push notification service. Subscribe to a topic from the [ntfy mobile app](https://ntfy.sh/docs/subscribe/phone/), publish to that topic to talk to the agent. | Variable | Description | |----------|-------------| | `NTFY_TOPIC` | Topic to subscribe to (incoming messages). Required. | | `NTFY_SERVER_URL` | Server URL (default: `https://ntfy.sh`). Point at a self-hosted ntfy for privacy. | | `NTFY_TOKEN` | Optional auth token. Bearer token (e.g. `tk_xyz`) or `user:pass` for Basic auth. | | `NTFY_PUBLISH_TOPIC` | Topic for outgoing replies (defaults to `NTFY_TOPIC`). | | `NTFY_MARKDOWN` | Set `true` to send replies with `X-Markdown: true` header. Default: `false`. | | `NTFY_ALLOWED_USERS` | Allowlist (treated as user IDs; on ntfy these are topic names). Typically set to the same value as `NTFY_TOPIC`. | | `NTFY_ALLOW_ALL_USERS` | Dev-only escape hatch — only safe on access-controlled private topics. Default: `false`. | | `NTFY_HOME_CHANNEL` | Default delivery target for cron jobs with `deliver: ntfy`. | | `NTFY_HOME_CHANNEL_NAME` | Human label for the home channel (defaults to the topic name). | See [the ntfy messaging guide](/user-guide/messaging/ntfy) — particularly the **identity model** section — before deploying with untrusted topics. ### IRC Connect Claway to an IRC server. No external dependencies. See [the IRC messaging guide](/user-guide/messaging/irc). | Variable | Description | |----------|-------------| | `IRC_SERVER` | IRC server hostname (e.g. `irc.libera.chat`). Required. | | `IRC_CHANNEL` | Channel(s) to join (e.g. `#claway`); comma-separate for multiple. Required. | | `IRC_NICKNAME` | Bot nickname (default: `claway-bot`). Required. | | `IRC_PORT` | Server port (default: `6697` with TLS, `6667` without). | | `IRC_USE_TLS` | Use TLS (`true`/`false`; default `true` on port 6697). | | `IRC_SERVER_PASSWORD` | Server password for the `PASS` command (optional). | | `IRC_NICKSERV_PASSWORD` | NickServ password for automatic IDENTIFY on connect (optional). | | `IRC_ALLOWED_USERS` | Comma-separated nicks allowed to talk to the bot. | | `IRC_ALLOW_ALL_USERS` | Allow anyone in the channel to talk to the bot (dev only). | | `IRC_HOME_CHANNEL` | Channel for cron / notification delivery (defaults to `IRC_CHANNEL`). | ### SimpleX Connect Claway to a [SimpleX Chat](https://simplex.chat/) network via a local `simplex-chat` daemon. See [the SimpleX messaging guide](/user-guide/messaging/simplex). | Variable | Description | |----------|-------------| | `SIMPLEX_WS_URL` | WebSocket URL of the simplex-chat daemon (e.g. `ws://127.0.0.1:5225`). | | `SIMPLEX_ALLOWED_USERS` | Comma-separated SimpleX contact IDs allowed to talk to the bot. | | `SIMPLEX_ALLOW_ALL_USERS` | Allow any contact to talk to the bot (dev only — disables allowlist). | | `SIMPLEX_AUTO_ACCEPT` | Auto-accept incoming contact requests (default: `true`). | | `SIMPLEX_GROUP_ALLOWED` | Comma-separated SimpleX group IDs the bot should participate in, or `*` to allow any group. Omit to ignore group messages entirely (safer default — a bot in a group otherwise processes every member's traffic). | | `SIMPLEX_HOME_CHANNEL` | Default contact/group ID for cron / notification delivery. | | `SIMPLEX_HOME_CHANNEL_NAME` | Human label for the home channel (defaults to the ID). | ### Photon Connect Claway to [Photon](https://photon.codes/) / Spectrum (iMessage and other Spectrum platforms) via the Node sidecar. See [the Photon messaging guide](/user-guide/messaging/photon). | Variable | Description | |----------|-------------| | `PHOTON_PROJECT_ID` | Spectrum project id (the project's `spectrumProjectId`; set by `claway photon setup`). | | `PHOTON_PROJECT_SECRET` | Project secret paired with the Spectrum project id (set by `claway photon setup`). | | `PHOTON_ALLOWED_USERS` | Comma-separated E.164 phone numbers allowed to talk to the bot. | | `PHOTON_ALLOW_ALL_USERS` | Allow any sender to trigger the bot (dev only — disables allowlist). | | `PHOTON_REQUIRE_MENTION` | Ignore group-chat messages unless they match a mention wake word (`true`/`false`, default `false`). | | `PHOTON_MENTION_PATTERNS` | Mention wake-word regexes for group chats (JSON list or comma/newline-separated; defaults to Claway wake words). | | `PHOTON_HOME_CHANNEL` | Default Photon target for cron / notification delivery: Spectrum space id, DM GUID, or bare E.164 phone number. | | `PHOTON_HOME_CHANNEL_NAME` | Human label for the home channel. | | `PHOTON_MARKDOWN` | Send agent replies as markdown — iMessage renders it natively, other Spectrum platforms degrade to plain text (`true`/`false`, default `true`). | | `PHOTON_REACTIONS` | Tapback 👀/👍/👎 on messages as processing status and route tapbacks on bot messages to the agent (`true`/`false`, default `false`). | | `PHOTON_TELEMETRY` | Enable Spectrum SDK telemetry in the sidecar (`true`/`false`, default `false`; toggle with `claway photon telemetry on|off`). | | `PHOTON_SIDECAR_PORT` | Loopback port for the Node sidecar control + inbound channel (default `8789`). | | `PHOTON_SIDECAR_AUTOSTART` | Spawn the Node sidecar on connect (`true`/`false`, default `true`). | | `PHOTON_NODE_BIN` | Path to the node binary (default: `shutil.which('node')`). | | `PHOTON_DASHBOARD_HOST` | Photon Dashboard API host (default `https://app.photon.codes`). | | `PHOTON_SPECTRUM_HOST` | Photon Spectrum API host (default `https://spectrum.photon.codes`). | ### Microsoft Teams (adapter) The Microsoft Teams platform adapter (Bot Framework / Azure AD), distinct from the [Microsoft Graph (Teams Meetings)](#microsoft-graph-teams-meetings) integration above. See [the Teams messaging guide](/user-guide/messaging/teams). | Variable | Description | |----------|-------------| | `TEAMS_CLIENT_ID` | Azure AD application (Bot Framework) client ID. | | `TEAMS_CLIENT_SECRET` | Azure AD application client secret. | | `TEAMS_TENANT_ID` | Azure AD tenant ID hosting the bot application. | | `TEAMS_PORT` | Webhook listen port (Bot Framework default: `3978`). | | `TEAMS_ALLOWED_USERS` | Comma-separated Teams user IDs / UPNs allowed to talk to the bot. | | `TEAMS_ALLOW_ALL_USERS` | Allow any Teams user to trigger the bot (dev only). | | `TEAMS_HOME_CHANNEL` | Default chat/channel ID for cron / notification delivery. | | `TEAMS_HOME_CHANNEL_NAME` | Display name for the Teams home channel. | ### Raft | Variable | Description | |----------|-------------| | `RAFT_PROFILE` | Raft agent profile slug — auto-enables the adapter when set. | ### Advanced Messaging Tuning Advanced per-platform knobs for throttling the outbound message batcher. Most users never need to touch these; defaults are set to respect each platform's rate limits without feeling sluggish. | Variable | Description | |----------|-------------| | `CLAWAY_TELEGRAM_TEXT_BATCH_DELAY_SECONDS` | Grace window before flushing a queued Telegram text chunk (default: `0.6`). | | `CLAWAY_TELEGRAM_TEXT_BATCH_SPLIT_DELAY_SECONDS` | Delay between split chunks when a single Telegram message exceeds the length limit (default: `2.0`). | | `CLAWAY_SIMPLEX_TEXT_BATCH_DELAY` | Quiet-period seconds (default: `0.8`) used to concatenate rapid-fire inbound text messages into a single MessageEvent — same pattern as Telegram's text batching. | | `CLAWAY_TELEGRAM_MEDIA_BATCH_DELAY_SECONDS` | Grace window before flushing queued Telegram media (default: `0.6`). | | `CLAWAY_TELEGRAM_FOLLOWUP_GRACE_SECONDS` | Delay before sending a follow-up after the agent finishes, to avoid racing the last stream chunk. | | `CLAWAY_TELEGRAM_HTTP_CONNECT_TIMEOUT` / `_READ_TIMEOUT` / `_WRITE_TIMEOUT` / `_POOL_TIMEOUT` | Override the underlying `python-telegram-bot` HTTP timeouts (seconds). | | `CLAWAY_TELEGRAM_INIT_TIMEOUT` | Per-attempt cap (seconds) on the Telegram `initialize()` connect chain during gateway startup, so an unreachable fallback-IP chain can't block startup indefinitely (default: `30`). | | `CLAWAY_TELEGRAM_HTTP_POOL_SIZE` | Max concurrent HTTP connections to the Telegram API. | | `CLAWAY_TELEGRAM_DISABLE_FALLBACK_IPS` | Disable the hard-coded Cloudflare fallback IPs used when DNS fails (`true`/`false`). | | `CLAWAY_DISCORD_TEXT_BATCH_DELAY_SECONDS` | Grace window before flushing a queued Discord text chunk (default: `0.6`). | | `CLAWAY_DISCORD_TEXT_BATCH_SPLIT_DELAY_SECONDS` | Delay between split chunks when a Discord message exceeds the length limit (default: `2.0`). | | `CLAWAY_DISCORD_LIVENESS_INTERVAL_SECONDS` | Internal bridge for `discord.liveness_interval_seconds` (config.yaml). Interval for the Discord REST liveness probe that detects zombie clients behind dead proxies/NATs (default: `60`; set to `0` to disable). Prefer setting `discord.liveness_interval_seconds` in `config.yaml`. | | `CLAWAY_DISCORD_LIVENESS_FAILURE_THRESHOLD` | Internal bridge for `discord.liveness_failure_threshold` (config.yaml). Consecutive probe failures before forcing a Discord reconnect (default: `3`). Prefer setting `discord.liveness_failure_threshold` in `config.yaml`. | | `CLAWAY_MATRIX_TEXT_BATCH_DELAY_SECONDS` / `_SPLIT_DELAY_SECONDS` | Matrix equivalents of the Telegram batch knobs. | | `CLAWAY_FEISHU_TEXT_BATCH_DELAY_SECONDS` / `_SPLIT_DELAY_SECONDS` / `_MAX_CHARS` / `_MAX_MESSAGES` | Feishu batcher tuning — delay, split delay, max chars per message, max messages per batch. | | `CLAWAY_FEISHU_MEDIA_BATCH_DELAY_SECONDS` | Feishu media flush delay. | | `CLAWAY_FEISHU_DEDUP_CACHE_SIZE` | Size of the Feishu webhook dedup cache (default: `1024`). | | `CLAWAY_WECOM_TEXT_BATCH_DELAY_SECONDS` / `_SPLIT_DELAY_SECONDS` | WeCom batcher tuning. | | `CLAWAY_VISION_DOWNLOAD_TIMEOUT` | Timeout in seconds for downloading an image before handing it to vision models (default: `30`). | | `CLAWAY_VISION_MAX_CONCURRENCY` | Max concurrent image **encode/resize** bursts across the whole process (override for `auxiliary.vision.max_concurrency`; default: host CPU core count, no ceiling). Bounds only the CPU-bound encode step so a video-frame fan-out can't saturate every core and starve the event loop — the LLM calls stay fully concurrent. Values `< 1` are ignored. | | `CLAWAY_RESTART_DRAIN_TIMEOUT` | Gateway: seconds to wait for active runs to drain on `/restart` before forcing the restart (default: `900`). | | `CLAWAY_GATEWAY_PLATFORM_CONNECT_TIMEOUT` | Per-platform connect timeout during gateway startup and reconnect (seconds; `0`/negative waits indefinitely). Applies to the connect attempt *and* the Discord adapter's ready-wait, so accounts with many slash commands to sync don't get killed mid-startup. Bridged from `gateway.platform_connect_timeout` in `config.yaml` (default `30`); this env var is the manual override and wins if set explicitly. | | `CLAWAY_GATEWAY_BUSY_INPUT_MODE` | Default gateway busy-input behavior: `queue`, `steer`, or `interrupt`. Can be overridden per chat with `/busy`. | | `CLAWAY_GATEWAY_BUSY_ACK_ENABLED` | Whether the gateway sends an acknowledgment message (⚡/⏳/⏩) when a user sends input while the agent is busy (default: `true`). Set to `false` to suppress these messages entirely — the input is still queued/steered/interrupts as normal, only the chat reply is silenced. Bridged from `display.busy_ack_enabled` in `config.yaml`. | | `CLAWAY_GATEWAY_NO_SUPERVISE` | Inside the s6-overlay Docker image, opt out of auto-supervision when running `claway gateway run` and use pre-s6 foreground semantics (no auto-restart, gateway is the container's main process). Truthy values: `1`, `true`, `yes`. Equivalent to the `--no-supervise` CLI flag. No-op outside the s6 image. | | `CLAWAY_GATEWAY_BOOTSTRAP_STATE` | Inside the s6-overlay Docker image, declare the gateway's **initial** supervised state on a fresh volume. On a blank volume there is no persisted `gateway_state.json`, so the boot reconciler registers the `gateway-default` slot but leaves it **down** (it only auto-starts when the last recorded state was `running`). Set this to `running` and the first-boot setup hook seeds `gateway_state.json` *before* the reconciler runs, so the gateway comes up on the very first boot. Only the literal value `running` is honoured. First-boot-only: an existing `gateway_state.json` is never overwritten, so a deliberately-stopped gateway stays stopped across restarts. No-op outside the s6 image. | | `GATEWAY_RELAY_URL` | Experimental relay connector WebSocket base URL. When set, the gateway registers the generic `relay` adapter and dials the connector outbound. Mirrors `gateway.relay_url` in `config.yaml`. | | `GATEWAY_RELAY_ID` | Relay gateway identifier assigned by `claway gateway enroll` or managed self-provisioning. Mirrors `gateway.relay_id`. | | `GATEWAY_RELAY_SECRET` | Per-gateway relay secret used to authenticate the WebSocket. If this is already configured, managed self-provisioning is skipped. Mirrors `gateway.relay_secret`. | | `GATEWAY_RELAY_DELIVERY_KEY` | Connector-issued delivery key retained for relay/passthrough authentication compatibility. Current relay inbound messages arrive on the outbound WebSocket rather than a gateway-side HTTP receiver. | | `GATEWAY_RELAY_ENROLL_TOKEN` | Enrollment token consumed by `claway gateway enroll` when `--token` is not passed explicitly. | | `GATEWAY_RELAY_PLATFORM` | Optional platform name advertised in the relay capability descriptor. | | `GATEWAY_RELAY_BOT_ID` | Optional bot identifier advertised in the relay capability descriptor. | | `GATEWAY_RELAY_ENDPOINT` | Optional gateway endpoint advertised for connector modes that need a callback/passthrough URL; not required for the default WS-only inbound relay path. Mirrors `gateway.relay_endpoint`. | | `GATEWAY_RELAY_ROUTE_KEYS` | Comma-separated relay route keys advertised to the connector. Mirrors `gateway.relay_route_keys`. | | `CLAWAY_FILE_MUTATION_VERIFIER` | Enable the per-turn file-mutation verifier footer (default: `true`). When enabled, Claway appends an advisory listing any `write_file` / `patch` calls that failed during the turn and were not superseded by a successful write. Set to `0`, `false`, `no`, or `off` to suppress. Mirrors `display.file_mutation_verifier` in `config.yaml`; the env var wins when set. | | `CLAWAY_CRON_TIMEOUT` | Inactivity timeout for cron job agent runs in seconds (default: `600`). The agent can run indefinitely while actively calling tools or receiving stream tokens — this only triggers when idle. Set to `0` for unlimited. | | `CLAWAY_CRON_SCRIPT_TIMEOUT` | Timeout for pre-run scripts attached to cron jobs in seconds (default: `3600`). Bounds the script only — skill/agent jobs use the separate `CLAWAY_CRON_TIMEOUT` inactivity budget. Also configurable via `cron.script_timeout_seconds` in `config.yaml`. | | `CLAWAY_CRON_MAX_PARALLEL` | Max cron jobs run in parallel per tick (default: `4`). | ## Agent Behavior | Variable | Description | |----------|-------------| | `CLAWAY_MAX_ITERATIONS` | Max tool-calling iterations per conversation (default: 90) | | `CLAWAY_INFERENCE_MODEL` | Override model name at process level (takes priority over `config.yaml` for the session). Also settable via `-m`/`--model` flag. | | `CLAWAY_YOLO_MODE` | Set to `1` to bypass dangerous-command approval prompts. Equivalent to `--yolo`. | | `CLAWAY_ACCEPT_HOOKS` | Auto-approve any unseen shell hooks declared in `config.yaml` without a TTY prompt. Equivalent to `--accept-hooks` or `hooks_auto_accept: true`. | | `CLAWAY_IGNORE_USER_CONFIG` | Skip `~/.claway/config.yaml` and use built-in defaults (credentials in `.env` still load). Equivalent to `--ignore-user-config`. | | `CLAWAY_IGNORE_RULES` | Skip auto-injection of `AGENTS.md`, `SOUL.md`, `.cursorrules`, memory, and preloaded skills. Equivalent to `--ignore-rules`. | | `CLAWAY_SAFE_MODE` | Troubleshooting mode: disable ALL customizations — skips plugin discovery and MCP server loading. Set automatically by `--safe-mode` (which also sets the two flags above). | | `CLAWAY_MD_NAMES` | Comma-separated list of rules-file names to auto-inject (default: `AGENTS.md,CLAUDE.md,.cursorrules,SOUL.md`). | | `CLAWAY_TOOL_PROGRESS` | Deprecated compatibility variable for tool progress display. Prefer `display.tool_progress` in `config.yaml`. | | `CLAWAY_TOOL_PROGRESS_MODE` | Deprecated compatibility variable for tool progress mode. Prefer `display.tool_progress` in `config.yaml`. | | `CLAWAY_HUMAN_DELAY_MODE` | Response pacing: `off`/`natural`/`custom` | | `CLAWAY_HUMAN_DELAY_MIN_MS` | Custom delay range minimum (ms) | | `CLAWAY_HUMAN_DELAY_MAX_MS` | Custom delay range maximum (ms) | | `CLAWAY_QUIET` | Suppress non-essential output (`true`/`false`) | | `CODEX_HOME` | When [Codex app-server runtime](../user-guide/features/codex-app-server-runtime) is enabled, override the directory Codex CLI reads its config + auth from (default: `~/.codex`). Claway's migration writes the managed block to `<CODEX_HOME>/config.toml`. | | `CLAWAY_KANBAN_TASK` | Set by the kanban dispatcher when spawning a worker (task UUID). Workers and the spawned `claway-tools` MCP subprocess inherit it so kanban tools gate correctly. Don't set manually. | | `CLAWAY_API_TIMEOUT` | LLM API call timeout in seconds (default: `1800`) | | `CLAWAY_API_CALL_STALE_TIMEOUT` | Non-streaming stale-call timeout in seconds (default: `90`). Auto-disabled for local providers when left unset, and may scale upward for very large contexts. Also configurable via `providers.<id>.stale_timeout_seconds` or `providers.<id>.models.<model>.stale_timeout_seconds` in `config.yaml`. | | `CLAWAY_STREAM_READ_TIMEOUT` | Streaming socket read timeout in seconds (default: `120`). Auto-increased to `CLAWAY_API_TIMEOUT` for local providers. Increase if local LLMs time out during long code generation. | | `CLAWAY_STREAM_STALE_TIMEOUT` | Stale stream detection timeout in seconds (default: `180`). Auto-disabled for local providers. Triggers connection kill if no chunks arrive within this window. | | `CLAWAY_STREAM_RETRIES` | Number of mid-stream reconnect attempts on transient network errors (default: `3`). | | `CLAWAY_AGENT_TIMEOUT` | Gateway inactivity timeout for a running agent in seconds (default: `1800`, 30 minutes). Resets on every tool call and streamed token. Set to `0` to disable. | | `CLAWAY_AGENT_TIMEOUT_WARNING` | Gateway: send a warning message after this many seconds of inactivity (default: 75% of `CLAWAY_AGENT_TIMEOUT`). | | `CLAWAY_AGENT_NOTIFY_INTERVAL` | Gateway: interval in seconds between progress notifications on long-running agent turns. | | `CLAWAY_CHECKPOINT_TIMEOUT` | Timeout for filesystem checkpoint creation in seconds (default: `30`). | | `CLAWAY_EXEC_ASK` | Enable execution approval prompts in gateway mode (`true`/`false`) | | `CLAWAY_ENABLE_PROJECT_PLUGINS` | Enable auto-discovery of repo-local plugins from `./.claway/plugins/` for both the agent loader and the dashboard web server. Accepts the standard truthy set: `1` / `true` / `yes` / `on` (case-insensitive). Everything else — including `0`, `false`, `no`, `off`, and the empty string — is treated as **disabled** (default). Note: as of GHSA-5qr3-c538-wm9j (#29156) the dashboard web server refuses to auto-import a project plugin's Python `api` file even when this var is enabled — project plugins may extend the UI via static JS/CSS but their backend routes are only loaded when moved under `~/.claway/plugins/`. | | `CLAWAY_PLUGINS_DEBUG` | `1`/`true` to surface verbose plugin-discovery logs on stderr — directories scanned, manifests parsed, skip reasons, and full tracebacks on parse or `register()` failure. Aimed at plugin authors. | | `CLAWAY_BACKGROUND_NOTIFICATIONS` | Background process notification mode in gateway: `all` (default), `result`, `error`, `off` | | `CLAWAY_EPHEMERAL_SYSTEM_PROMPT` | Ephemeral system prompt injected at API-call time (never persisted to sessions) | | `CLAWAY_PREFILL_MESSAGES_FILE` | Path to a JSON file of ephemeral prefill messages injected at API-call time. | | `CLAWAY_ALLOW_PRIVATE_URLS` | `true`/`false` — allow tools to fetch localhost/private-network URLs. Off by default in gateway mode. | | `CLAWAY_REDACT_SECRETS` | `true`/`false` — control secret redaction in tool output, logs, and chat responses (default: `true`). | | `CLAWAY_WRITE_SAFE_ROOT` | Optional directory prefix that restricts `write_file`/`patch` writes; paths outside require approval. Supports multiple directories separated by `os.pathsep` (`:` on Unix, `;` on Windows). | | `CLAWAY_DISABLE_LAZY_INSTALLS` | Internal bridge var set automatically in the official Docker image to prevent runtime dependency installs into the immutable `/opt/claway` tree. The user-facing equivalent is `security.allow_lazy_installs: false` in `config.yaml`; do not set this in `.env`. | | `CLAWAY_DISABLE_FILE_STATE_GUARD` | Set to `1` to turn off the "file changed since you read it" guard on `patch`/`write_file`. | | `CLAWAY_CORE_TOOLS` | Comma-separated override for the canonical core tool list (advanced; rarely needed). | | `CLAWAY_BUNDLED_SKILLS` | Comma-separated override for the list of bundled skills loaded at startup. | | `CLAWAY_OPTIONAL_SKILLS` | Comma-separated list of optional-skill names to auto-install on first run. | | `CLAWAY_DEBUG_INTERRUPT` | Set to `1` to log detailed interrupt/cancel tracing to `agent.log`. | | `CLAWAY_DUMP_REQUESTS` | Dump API request payloads to log files (`true`/`false`) | | `CLAWAY_DUMP_REQUEST_STDOUT` | Dump API request payloads to stdout instead of log files. | | `CLAWAY_OAUTH_TRACE` | Set to `1` to log OAuth token exchange and refresh attempts. Includes redacted timing info. | | `CLAWAY_OAUTH_FILE` | Override the path used for OAuth credential storage (default: `~/.claway/auth.json`). | | `CLAWAY_AGENT_HELP_GUIDANCE` | Append additional guidance text to the system prompt for custom deployments. | | `CLAWAY_AGENT_LOGO` | Override the ASCII banner logo at CLI startup. | | `DELEGATION_MAX_CONCURRENT_CHILDREN` | Max parallel subagents per `delegate_task` batch (default: `3`, floor of 1, no ceiling). Also configurable via `delegation.max_concurrent_children` in `config.yaml` — the config value takes priority. | ## Interface | Variable | Description | |----------|-------------| | `CLAWAY_TUI` | Launch the [TUI](../user-guide/tui.md) instead of the classic CLI when set to `1`. Equivalent to passing `--tui`. | | `CLAWAY_TUI_DIR` | Path to a prebuilt `ui-tui/` directory (must contain `dist/entry.js` and populated `node_modules`). Used by distros and Nix to skip the first-launch `npm install`. | | `CLAWAY_TUI_RESUME` | Resume a specific TUI session by ID on launch. When set, `claway --tui` skips forging a fresh session and picks up the named session instead — useful for re-attaching after a disconnect or terminal crash. | | `CLAWAY_TUI_THEME` | Force the TUI color theme: `light`, `dark`, or a raw 6-character background hex (e.g. `ffffff` or `1a1a2e`). When unset, Claway auto-detects using `COLORFGBG` and terminal background queries; this variable overrides detection on terminals (Ghostty, Warp, iTerm2, etc.) that don't set `COLORFGBG`. | | `CLAWAY_INFERENCE_MODEL` | Force the model for `claway -z` / `claway chat` without mutating `config.yaml`. Pairs with the `--provider` flag. Useful for scripted callers (sweeper, CI, batch runners) that need to override the default model per run. | ## Session Settings | Variable | Description | |----------|-------------| | `SESSION_IDLE_MINUTES` | Reset sessions after N minutes of inactivity (default: 1440) | | `SESSION_RESET_HOUR` | Daily reset hour in 24h format (default: 4 = 4am) | | `CLAWAY_SESSION_ID` | **Exported automatically into every tool subprocess** Claway spawns (`terminal`, `execute_code`, persistent shell, Docker/Singularity backends, delegated subagent runs). Set by the agent to the current session ID; user scripts called from tools can read it to correlate their output, telemetry, or side effects with the originating Claway session. **You should not set this manually** — overriding it from a parent shell only takes effect outside an agent run, and is overwritten the moment the agent starts a session. | ## Context Compression (config.yaml only) Context compression is configured exclusively through `config.yaml` — there are no environment variables for it. Threshold settings live in the `compression:` block, while the summarization model/provider lives under `auxiliary.compression:`. ```yaml compression: enabled: true threshold: 0.50 target_ratio: 0.20 # fraction of threshold to preserve as recent tail protect_last_n: 20 # minimum recent messages to keep uncompressed ``` :::info Legacy migration Older configs with `compression.summary_model`, `compression.summary_provider`, and `compression.summary_base_url` are automatically migrated to `auxiliary.compression.*` on first load. ::: ## Auxiliary Task Overrides | Variable | Description | |----------|-------------| | `AUXILIARY_VISION_PROVIDER` | Override provider for vision tasks | | `AUXILIARY_VISION_MODEL` | Override model for vision tasks | | `AUXILIARY_VISION_BASE_URL` | Direct OpenAI-compatible endpoint for vision tasks | | `AUXILIARY_VISION_API_KEY` | API key paired with `AUXILIARY_VISION_BASE_URL` | | `AUXILIARY_WEB_EXTRACT_PROVIDER` | Override provider for web extraction/summarization | | `AUXILIARY_WEB_EXTRACT_MODEL` | Override model for web extraction/summarization | | `AUXILIARY_WEB_EXTRACT_BASE_URL` | Direct OpenAI-compatible endpoint for web extraction/summarization | | `AUXILIARY_WEB_EXTRACT_API_KEY` | API key paired with `AUXILIARY_WEB_EXTRACT_BASE_URL` | For task-specific direct endpoints, Claway uses the task's configured API key or `OPENAI_API_KEY`. It does not reuse `OPENROUTER_API_KEY` for those custom endpoints. ## Fallback Providers (config.yaml only) The primary model fallback chain is configured exclusively through `config.yaml` — there are no environment variables for it. Add a top-level `fallback_providers` list with `provider` and `model` keys to enable automatic failover when your main model encounters errors. Auxiliary tasks whose provider is `auto` also consult this chain before Claway's built-in auxiliary discovery chain. ```yaml fallback_providers: - provider: openrouter model: anthropic/claude-sonnet-4 ``` The older top-level `fallback_model` single-provider shape is still read for backward compatibility, but new configuration should use `fallback_providers`. For task-specific auxiliary policy, use `auxiliary.<task>.fallback_chain` in `config.yaml`; there is no environment variable equivalent. See [Fallback Providers](/user-guide/features/fallback-providers) for full details. ## Provider Routing (config.yaml only) These go in `~/.claway/config.yaml` under the `provider_routing` section: | Key | Description | |-----|-------------| | `sort` | Sort providers: `"price"` (default), `"throughput"`, or `"latency"` | | `only` | List of provider slugs to allow (e.g., `["anthropic", "google"]`) | | `ignore` | List of provider slugs to skip | | `order` | List of provider slugs to try in order | | `require_parameters` | Only use providers supporting all request params (`true`/`false`) | | `data_collection` | `"allow"` (default) or `"deny"` to exclude data-storing providers | :::tip Use `claway config set` to set environment variables — it automatically saves them to the right file (`.env` for secrets, `config.yaml` for everything else). ::: --- <!-- source: website/docs/reference/tools-reference.md --> # Built-in Tools Reference # Built-in Tools Reference This page documents Claway's built-in tools, grouped by toolset. Availability varies by platform, credentials, and enabled toolsets. **Quick counts (current registry):** ~73 tools — 10 browser tools (core) + 2 CDP-gated browser tools, 4 file tools, 4 Home Assistant tools, 3 terminal tools (`terminal`, `process`, `read_terminal`), 2 web tools, 5 Feishu tools, 7 Spotify tools (registered by the bundled `spotify` plugin), 5 Yuanbao tools, 9 kanban tools (registered when the kanban dispatcher spawns the agent), 3 project tools (desktop/GUI sessions), 2 Discord tools, and a handful of standalone tools (`memory`, `clarify`, `delegate_task`, `execute_code`, `cronjob`, `session_search`, `skill_view`/`skill_manage`/`skills_list`, `text_to_speech`, `image_generate`, `video_generate`, `vision_analyze`, `video_analyze`, `todo`, `computer_use`). :::tip MCP Tools In addition to built-in tools, Claway can load tools dynamically from MCP servers. MCP tools appear with the prefix `mcp_<server>_` (e.g., `mcp_github_create_issue` for the `github` MCP server). See [MCP Integration](/user-guide/features/mcp) for configuration. ::: ## `browser` toolset | Tool | Description | Requires environment | |------|-------------|----------------------| | `browser_back` | Navigate back to the previous page in browser history. Requires browser_navigate to be called first. | — | | `browser_click` | Click on an element identified by its ref ID from the snapshot (e.g., '@e5'). The ref IDs are shown in square brackets in the snapshot output. Requires browser_navigate and browser_snapshot to be called first. | — | | `browser_console` | Get browser console output and JavaScript errors from the current page. Returns console.log/warn/error/info messages and uncaught JS exceptions. Use this to detect silent JavaScript errors, failed API calls, and application warnings. Requi… | — | | `browser_get_images` | Get a list of all images on the current page with their URLs and alt text. Useful for finding images to analyze with the vision tool. Requires browser_navigate to be called first. | — | | `browser_navigate` | Navigate to a URL in the browser. Initializes the session and loads the page. Must be called before other browser tools. For simple information retrieval, prefer web_search or web_extract (faster, cheaper). Use browser tools when you need… | — | | `browser_press` | Press a keyboard key. Useful for submitting forms (Enter), navigating (Tab), or keyboard shortcuts. Requires browser_navigate to be called first. | — | | `browser_scroll` | Scroll the page in a direction. Use this to reveal more content that may be below or above the current viewport. Requires browser_navigate to be called first. | — | | `browser_snapshot` | Get a text-based snapshot of the current page's accessibility tree. Returns interactive elements with ref IDs (like @e1, @e2) for browser_click and browser_type. full=false (default): compact view with interactive elements. full=true: comp… | — | | `browser_type` | Type text into an input field identified by its ref ID. Clears the field first, then types the new text. Requires browser_navigate and browser_snapshot to be called first. | — | | `browser_vision` | Take a screenshot of the current page and analyze it with vision AI. Use this when you need to visually understand what's on the page - especially useful for CAPTCHAs, visual verification challenges, complex layouts, or when the text snaps… | — | ## `browser` toolset (CDP-gated tools) These two tools live in the `browser` toolset but only register when a Chrome DevTools Protocol endpoint is reachable at session start — via `/browser connect`, `browser.cdp_url` config, a Browserbase session, or Camofox. | Tool | Description | Requires environment | |------|-------------|----------------------| | `browser_cdp` | Send a raw Chrome DevTools Protocol command. Escape hatch for browser operations not covered by the higher-level `browser_*` tools. See https://chromedevtools.github.io/devtools-protocol/ | CDP endpoint | | `browser_dialog` | Respond to a native JavaScript dialog (alert / confirm / prompt / beforeunload). Call `browser_snapshot` first — pending dialogs appear in its `pending_dialogs` field. Then call `browser_dialog(action='accept'\|'dismiss')`. | CDP endpoint | ## `clarify` toolset | Tool | Description | Requires environment | |------|-------------|----------------------| | `clarify` | Ask the user a question when you need clarification, feedback, or a decision before proceeding. Supports two modes: 1. **Multiple choice** — provide up to 4 choices. The user picks one or types their own answer via a 5th 'Other' option. 2.… | — | ## `code_execution` toolset | Tool | Description | Requires environment | |------|-------------|----------------------| | `execute_code` | Run a Python script that can call Claway tools programmatically. Use this when you need 3+ tool calls with processing logic between them, need to filter/reduce large tool outputs before they enter your context, need conditional branching (… | — | ## `cronjob` toolset | Tool | Description | Requires environment | |------|-------------|----------------------| | `cronjob` | Unified scheduled-task manager. Use `action="create"`, `"list"`, `"update"`, `"pause"`, `"resume"`, `"run"`, or `"remove"` to manage jobs. Supports skill-backed jobs with one or more attached skills, and `skills=[]` on update clears attached skills. Cron runs happen in fresh sessions with no current-chat context. | — | ## `delegation` toolset | Tool | Description | Requires environment | |------|-------------|----------------------| | `delegate_task` | Spawn one or more subagents to work on tasks in isolated contexts. Each subagent gets its own conversation, terminal session, and toolset. Only the final summary is returned -- intermediate tool results never enter your context window. TWO… | — | ## `feishu_doc` toolset Scoped to the Feishu document-comment intelligent-reply handler (`gateway/platforms/feishu_comment.py`). Not exposed on `claway-cli` or the regular Feishu chat adapter. | Tool | Description | Requires environment | |------|-------------|----------------------| | `feishu_doc_read` | Read the full text content of a Feishu/Lark document (Docx, Doc, or Sheet) given its file_type and token. | Feishu app credentials | ## `feishu_drive` toolset Scoped to the Feishu document-comment handler. Drives comment read/write operations on drive files. | Tool | Description | Requires environment | |------|-------------|----------------------| | `feishu_drive_add_comment` | Add a top-level comment on a Feishu/Lark document or file. | Feishu app credentials | | `feishu_drive_list_comments` | List whole-document comments on a Feishu/Lark file, most recent first. | Feishu app credentials | | `feishu_drive_list_comment_replies` | List replies on a specific Feishu comment thread (whole-doc or local-selection). | Feishu app credentials | | `feishu_drive_reply_comment` | Post a reply on a Feishu comment thread, with optional `@`-mention. | Feishu app credentials | ## `file` toolset | Tool | Description | Requires environment | |------|-------------|----------------------| | `patch` | Targeted find-and-replace edits in files. Use this instead of sed/awk in terminal. Uses fuzzy matching (9 strategies) so minor whitespace/indentation differences won't break it. Returns a unified diff. Auto-runs syntax checks after editing… | — | | `read_file` | Read a text file with line numbers and pagination. Use this instead of cat/head/tail in terminal. Output format: 'LINE_NUM\|CONTENT'. Suggests similar filenames if not found. Use offset and limit for large files. NOTE: Cannot read images o… | — | | `search_files` | Search file contents or find files by name. Use this instead of grep/rg/find/ls in terminal. Ripgrep-backed, faster than shell equivalents. Content search (target='content'): Regex search inside files. Output modes: full matches with line… | — | | `write_file` | Write content to a file, completely replacing existing content. Use this instead of echo/cat heredoc in terminal. Creates parent directories automatically. OVERWRITES the entire file — use 'patch' for targeted edits. | — | ## `homeassistant` toolset | Tool | Description | Requires environment | |------|-------------|----------------------| | `ha_call_service` | Call a Home Assistant service to control a device. Use ha_list_services to discover available services and their parameters for each domain. | — | | `ha_get_state` | Get the detailed state of a single Home Assistant entity, including all attributes (brightness, color, temperature setpoint, sensor readings, etc.). | — | | `ha_list_entities` | List Home Assistant entities. Optionally filter by domain (light, switch, climate, sensor, binary_sensor, cover, fan, etc.) or by area name (living room, kitchen, bedroom, etc.). | — | | `ha_list_services` | List available Home Assistant services (actions) for device control. Shows what actions can be performed on each device type and what parameters they accept. Use this to discover how to control devices found via ha_list_entities. | — | ## `computer_use` toolset | Tool | Description | Requires environment | |------|-------------|----------------------| | `computer_use` | Background desktop control via cua-driver — screenshots (SOM / vision / AX), click / drag / scroll / type / key / wait, list_apps, focus_app. Does NOT steal the user's cursor or keyboard focus. Works with any tool-capable model. macOS, Windows, and Linux. | `cua-driver` on `$PATH` (install via `claway tools`). | :::note **Honcho tools** (`honcho_profile`, `honcho_search`, `honcho_context`, `honcho_reasoning`, `honcho_conclude`) are no longer built-in. They are available via the Honcho memory provider plugin at `plugins/memory/honcho/`. See [Memory Providers](../user-guide/features/memory-providers.md) for installation and usage. ::: ## `image_gen` toolset | Tool | Description | Requires environment | |------|-------------|----------------------| | `image_generate` | Generate images from text prompts (text-to-image) or edit/transform an existing image (image-to-image) via the user-configured backend (FAL.ai, OpenAI, xAI, Krea). Pass `image_url` to edit an image and `reference_image_urls` for style references; omit both for text-to-image. The model is user-configured and not selectable by the agent. Returns a single image URL or local path. | FAL_KEY / OPENAI_API_KEY / xAI OAuth / KREA_API_KEY | ## `kanban` toolset Registered when the agent is either (a) spawned by the kanban dispatcher (`CLAWAY_KANBAN_TASK` env set) or (b) running in a profile that explicitly enables the `kanban` toolset. Task-scoped workers use lifecycle tools for their assigned task; orchestrator profiles additionally get board-routing tools like `kanban_list` and `kanban_unblock`. See [Kanban Multi-Agent](/user-guide/features/kanban) for the full workflow. | Tool | Description | Requires environment | |------|-------------|----------------------| | `kanban_show` | Show the active kanban task assigned to this worker (title, description, comments, dependencies). | `CLAWAY_KANBAN_TASK` or `kanban` toolset | | `kanban_list` | List board tasks with filters. Orchestrator-only; hidden from dispatcher-spawned task workers. | profile with `kanban` toolset | | `kanban_complete` | Mark the current task done with a structured handoff payload (results, artifacts, follow-ups). | `CLAWAY_KANBAN_TASK` or `kanban` toolset | | `kanban_block` | Block the current task on a question for the user — the dispatcher pauses, surfaces the question, and resumes once a human replies. | `CLAWAY_KANBAN_TASK` or `kanban` toolset | | `kanban_heartbeat` | Send a progress heartbeat during a long-running operation so the dispatcher knows the worker is still alive. | `CLAWAY_KANBAN_TASK` or `kanban` toolset | | `kanban_comment` | Add a comment to the task thread without changing its state — useful for surfacing intermediate findings. | `CLAWAY_KANBAN_TASK` or `kanban` toolset | | `kanban_create` | Fan out child tasks from the current task. Used by orchestrators and follow-up-spawning workers. | `CLAWAY_KANBAN_TASK` or `kanban` toolset | | `kanban_link` | Link tasks with a parent → child dependency edge. | `CLAWAY_KANBAN_TASK` or `kanban` toolset | | `kanban_unblock` | Return a blocked task to `ready`. Orchestrator-only; hidden from dispatcher-spawned task workers. | profile with `kanban` toolset | ## `project` toolset Tools for driving desktop [Projects](../user-guide/cli.md) — named, multi-folder workspaces. Registered when the `project` toolset is enabled (primarily the desktop app / dashboard surfaces). | Tool | Description | Requires environment | |------|-------------|----------------------| | `project_create` | Create a desktop Project (a named workspace) and switch this chat into it. Pass `path` to anchor it to a repo/folder. | — | | `project_list` | List the desktop Projects and which one is active. | — | | `project_switch` | Switch this chat into an existing Project (by name, slug, or id); moves the session workspace to the project's primary folder. | — | ## `memory` toolset | Tool | Description | Requires environment | |------|-------------|----------------------| | `memory` | Save important information to persistent memory that survives across sessions. Your memory appears in your system prompt at session start -- it's how you remember things about the user and your environment between conversations. WHEN TO SA… | — | ## `session_search` toolset | Tool | Description | Requires environment | |------|-------------|----------------------| | `session_search` | Search past sessions stored in the local session DB, or scroll inside one. FTS5-backed retrieval; returns actual messages from the DB (no LLM calls). Three shapes: discovery (pass `query`), scroll (pass `session_id` + `around_message_id`), browse (no args). | — | ## `skills` toolset | Tool | Description | Requires environment | |------|-------------|----------------------| | `skill_manage` | Manage skills (create, update, delete). Skills are your procedural memory — reusable approaches for recurring task types. New skills go to ~/.claway/skills/; existing skills can be modified wherever they live. Actions: create (full SKILL.m… | — | | `skill_view` | Skills allow for loading information about specific tasks and workflows, as well as scripts and templates. Load a skill's full content or access its linked files (references, templates, scripts). First call returns SKILL.md content plus a… | — | | `skills_list` | List available skills (name + description). Use skill_view(name) to load full content. | — | ## `terminal` toolset | Tool | Description | Requires environment | |------|-------------|----------------------| | `process` | Manage background processes started with terminal(background=true). Actions: 'list' (show all), 'poll' (check status + new output), 'log' (full output with pagination), 'wait' (block until done or timeout), 'kill' (terminate), 'write' (sen… | — | | `terminal` | Execute shell commands on a Linux environment. Filesystem persists between calls. Set `background=true` for long-running servers. Set `notify_on_complete=true` (with `background=true`) to get an automatic notification when the process finishes — no polling needed. Do NOT use cat/head/tail — use read_file. Do NOT use grep/rg/find — use search_files. | — | | `read_terminal` | Read what's currently shown in the in-app terminal pane of the Claway desktop GUI (the embedded shell beside this chat). Desktop-app only. | — | ## `todo` toolset | Tool | Description | Requires environment | |------|-------------|----------------------| | `todo` | Manage your task list for the current session. Use for complex tasks with 3+ steps or when the user provides multiple tasks. Call with no parameters to read the current list. Writing: - Provide 'todos' array to create/update items - merge=… | — | ## `vision` toolset | Tool | Description | Requires environment | |------|-------------|----------------------| | `vision_analyze` | Analyze images using AI vision. On vision-capable main models, returns the raw image pixels as a multimodal tool result so the model sees them natively on its next turn. On text-only main models, falls back to an auxiliary vision model that describes the image and returns the description as text. Tool signature is identical either way. | — | ## `video` toolset Opt-in toolset (not loaded in the default `claway-cli` set). Add via `--toolsets video` or include `video` in your `toolsets:` config. | Tool | Description | Requires environment | |------|-------------|----------------------| | `video_analyze` | Analyze video content from a URL or file path — captions, scene breakdowns, key timestamps, and visual descriptions. | — | ## `video_gen` toolset Opt-in toolset (not loaded in the default `claway-cli` set). Add via `--toolsets video_gen` or enable it in `claway tools` → Video Generation, which also walks you through picking a backend. Backends ship as plugins under `plugins/video_gen/<name>/`: - **xAI Grok-Imagine** — text-to-video and image-to-video (SuperGrok OAuth or `XAI_API_KEY`). - **FAL.ai** — Veo 3.1, Pixverse v6, Kling O3 (requires `FAL_KEY`). The single `video_generate` tool covers both modalities — pass `image_url` to animate a still, omit it to generate from text alone. The active backend auto-routes to the right endpoint. The tool's description is rebuilt at session start to reflect the active backend's actual capabilities (modalities, aspect ratios, resolutions, duration range, max reference images, audio support). See [Video Generation Provider Plugins](/developer-guide/video-gen-provider-plugin) for backend authoring. | Tool | Description | Requires environment | |------|-------------|----------------------| | `video_generate` | Generate a video from a text prompt (text-to-video) or animate a still image (image-to-video) using the user's configured video generation backend. Pass `image_url` to animate that image; omit it to generate from text alone. The backend auto-routes to the right endpoint. Returns either an HTTP URL or an absolute file path in the `video` field. | Active `video_gen` plugin + its credential (e.g. `XAI_API_KEY`, `FAL_KEY`) | ## `web` toolset | Tool | Description | Requires environment | |------|-------------|----------------------| | `web_search` | Search the web for information. Returns up to 5 results by default with titles, URLs, and descriptions. Accepts an optional `limit` (1-100, default 5). The query is passed through to the configured backend, so operators such as `site:domain`, `filetype:pdf`, `intitle:word`, `-term`, and `"exact phrase"` may work when the backend supports them. | EXA_API_KEY or PARALLEL_API_KEY or FIRECRAWL_API_KEY or TAVILY_API_KEY | | `web_extract` | Extract content from web page URLs. Returns page content in markdown format. Also works with PDF URLs — pass the PDF link directly and it converts to markdown text. Pages under 5000 chars return full markdown; larger pages are LLM-summarized. | EXA_API_KEY or PARALLEL_API_KEY or FIRECRAWL_API_KEY or TAVILY_API_KEY | ## `x_search` toolset | Tool | Description | Requires environment | |------|-------------|----------------------| | `x_search` | Search X (Twitter) posts, profiles, and threads using xAI's built-in `x_search` Responses tool. Use this for current discussion, reactions, or claims on X rather than general web pages. Off by default — opt in via `claway tools` → 🐦 X (Twitter) Search. Schema is only registered when xAI credentials are configured (check_fn-gated). | XAI_API_KEY **or** xAI Grok OAuth (SuperGrok / Premium+) login | ## `tts` toolset | Tool | Description | Requires environment | |------|-------------|----------------------| | `text_to_speech` | Convert text to speech audio. Returns a MEDIA: path that the platform delivers as a voice message. On Telegram it plays as a voice bubble, on Discord/WhatsApp as an audio attachment. In CLI mode, saves to ~/voice-memos/. Voice and provider… | — | ## `discord` toolset Registered on the `claway-discord` platform toolset (gateway only). Uses the same bot token as the messaging adapter. | Tool | Description | Requires environment | |------|-------------|----------------------| | `discord` | Read and participate in a Discord server. Actions include `search_members`, `fetch_messages`, `send_message`, `react`, `fetch_channel`, `list_channels`, and more. | `DISCORD_BOT_TOKEN` | ## `discord_admin` toolset Registered on the `claway-discord` platform toolset. Moderation actions require the bot to hold the matching Discord permissions. | Tool | Description | Requires environment | |------|-------------|----------------------| | `discord_admin` | Manage a Discord server via the REST API: list guilds/channels/roles, create/edit/delete channels, manage role grants, timeouts, kicks, and bans. | `DISCORD_BOT_TOKEN` + bot permissions | ## `spotify` toolset Registered by the bundled `spotify` plugin. Requires an OAuth token — run `claway spotify setup` once to authorize. | Tool | Description | Requires environment | |------|-------------|----------------------| | `spotify_playback` | Control Spotify playback, inspect the active playback state, or fetch recently played tracks. | Spotify OAuth | | `spotify_devices` | List Spotify Connect devices or transfer playback to a different device. | Spotify OAuth | | `spotify_queue` | Inspect the user's Spotify queue or add an item to it. | Spotify OAuth | | `spotify_search` | Search the Spotify catalog for tracks, albums, artists, playlists, shows, or episodes. | Spotify OAuth | | `spotify_playlists` | List, inspect, create, update, and modify Spotify playlists. | Spotify OAuth | | `spotify_albums` | Fetch Spotify album metadata or album tracks. | Spotify OAuth | | `spotify_library` | List, save, or remove the user's saved Spotify tracks or albums. | Spotify OAuth | ## `claway-yuanbao` toolset Registered only on the `claway-yuanbao` platform toolset. Yuanbao is Tencent's chat app; these tools drive its DM/group/sticker APIs. | Tool | Description | Requires environment | |------|-------------|----------------------| | `yb_query_group_info` | Query basic info about a group (called "派/Pai" in the app): name, owner, member count. | Yuanbao credentials | | `yb_query_group_members` | Query members of a group (for `@`-mentions, finding a user by name, listing bots). | Yuanbao credentials | | `yb_send_dm` | Send a private/direct message to a user in a group, with optional media files. | Yuanbao credentials | | `yb_search_sticker` | Search the built-in Yuanbao sticker (TIM face) catalogue by keyword. | Yuanbao credentials | | `yb_send_sticker` | Send a built-in sticker to the current Yuanbao chat. | Yuanbao credentials | --- <!-- source: website/docs/reference/toolsets-reference.md --> # Toolsets Reference # Toolsets Reference Toolsets are named bundles of tools that control what the agent can do. They're the primary mechanism for configuring tool availability per platform, per session, or per task. ## How Toolsets Work Every tool belongs to exactly one toolset. When you enable a toolset, all tools in that bundle become available to the agent. Toolsets come in three kinds: - **Core** — A single logical group of related tools (e.g., `file` bundles `read_file`, `write_file`, `patch`, `search_files`) - **Composite** — Combines multiple core toolsets for a common scenario (e.g., `debugging` bundles file, terminal, and web tools) - **Platform** — A complete tool configuration for a specific deployment context (e.g., `claway-cli` is the default for interactive CLI sessions) ## Configuring Toolsets ### Per-session (CLI) ```bash claway chat --toolsets web,file,terminal claway chat --toolsets debugging # composite — expands to file + terminal + web claway chat --toolsets all # everything ``` ### Per-platform (config.yaml) ```yaml toolsets: - claway-cli # default for CLI # - claway-telegram # override for Telegram gateway ``` ### Interactive management ```bash claway tools # curses UI to enable/disable per platform ``` Or in-session: ``` /tools list /tools disable browser /tools enable homeassistant ``` ## Core Toolsets | Toolset | Tools | Purpose | |---------|-------|---------| | `browser` | `browser_back`, `browser_cdp`, `browser_click`, `browser_console`, `browser_dialog`, `browser_get_images`, `browser_navigate`, `browser_press`, `browser_scroll`, `browser_snapshot`, `browser_type`, `browser_vision`, `web_search` | Core browser automation. Includes `web_search` as a fallback for quick lookups. `browser_cdp` and `browser_dialog` are gated at runtime — registered only when a CDP endpoint is reachable at session start (via `/browser connect`, `browser.cdp_url` config, Browserbase, or Camofox). `browser_dialog` works together with the `pending_dialogs` and `frame_tree` fields that `browser_snapshot` adds when a CDP supervisor is attached. | | `clarify` | `clarify` | Ask the user a question when the agent needs clarification. | | `code_execution` | `execute_code` | Run Python scripts that call Claway tools programmatically. | | `coding` | composite (`file` + `terminal` + `search` + `web` + `skills` + `browser` + `todo` + `memory` + `session_search` + `clarify` + `code_execution` + `delegation` + `vision`) | Coding-focused bundle for software work: file editing, terminal, search, web docs, skills, browser, delegate, and code execution. | | `cronjob` | `cronjob` | Schedule and manage recurring tasks. | | `debugging` | composite (`file` + `terminal` + `web`) | Debug bundle — file, process/terminal, web extract/search. | | `delegation` | `delegate_task` | Spawn isolated subagent instances for parallel work. | | `discord` | `discord` | Core Discord text/embed/DM actions (gateway-only). Active on the `claway-discord` toolset. | | `discord_admin` | `discord_admin` | Discord moderation (bans, role changes, channel management). Active on the `claway-discord` toolset; requires the bot to hold the relevant Discord permissions. | | `feishu_doc` | `feishu_doc_read` | Read Feishu/Lark document content. Used by the Feishu document-comment intelligent-reply handler. | | `feishu_drive` | `feishu_drive_add_comment`, `feishu_drive_list_comments`, `feishu_drive_list_comment_replies`, `feishu_drive_reply_comment` | Feishu/Lark drive comment operations. Scoped to the comment agent; not exposed on `claway-cli` or other messaging toolsets. | | `file` | `patch`, `read_file`, `search_files`, `write_file` | File reading, writing, searching, and editing. | | `homeassistant` | `ha_call_service`, `ha_get_state`, `ha_list_entities`, `ha_list_services` | Smart home control via Home Assistant. Only available when `HASS_TOKEN` is set. | | `computer_use` | `computer_use` | Background desktop control via cua-driver — does not steal cursor/focus. Works with any tool-capable model. macOS, Windows, and Linux; requires `cua-driver` on `$PATH`. | | `context_engine` | (varies) | Runtime tools exposed by the active context-engine plugin (empty until a plugin populates it). | | `image_gen` | `image_generate` | Text-to-image generation via FAL.ai (with opt-in OpenAI / xAI backends). | | `video_gen` | `video_generate` | Text-to-video and image-to-video via plugin-registered backends (xAI Grok-Imagine, FAL.ai Veo 3.1 / Pixverse v6 / Kling O3). Pass `image_url` to animate an image; omit it for text-to-video. | | `kanban` | `kanban_block`, `kanban_comment`, `kanban_complete`, `kanban_create`, `kanban_heartbeat`, `kanban_link`, `kanban_list`, `kanban_show`, `kanban_unblock` | Multi-agent coordination tools. Registered for dispatcher-spawned task workers (`CLAWAY_KANBAN_TASK`) and for profiles that explicitly list the `kanban` toolset by name (the `all`/`*` wildcard does **not** enable it). Workers mark tasks done, block, heartbeat, comment, and create/link follow-up tasks; orchestrator profiles additionally get board-routing tools like list/unblock. | | `memory` | `memory` | Persistent cross-session memory management. | | `project` | `project_create`, `project_list`, `project_switch` | Create and switch desktop [Projects](../user-guide/cli.md) (named, multi-folder workspaces). GUI / desktop sessions only. | | `safe` | `image_generate`, `vision_analyze`, `web_extract`, `web_search` (via `includes`) | Read-only research + media generation. No file writes, no terminal, no code execution. | | `search` | `web_search` | Web search only (without extract). | | `session_search` | `session_search` | Search past conversation sessions. | | `skills` | `skill_manage`, `skill_view`, `skills_list` | Skill CRUD and browsing. | | `spotify` | `spotify_albums`, `spotify_devices`, `spotify_library`, `spotify_playback`, `spotify_playlists`, `spotify_queue`, `spotify_search` | Native Spotify control (playback, queue, search, playlists, albums, library). Registered by the bundled `spotify` plugin. | | `terminal` | `process`, `terminal` | Shell command execution and background process management. | | `todo` | `todo` | Task list management within a session. | | `tts` | `text_to_speech` | Text-to-speech audio generation. | | `vision` | `vision_analyze` | Image analysis via vision-capable models. | | `video` | `video_analyze` | Video analysis and understanding tools (opt-in, not in the default toolset — add explicitly via `--toolsets`). | | `web` | `web_extract`, `web_search` | Web search and page content extraction. | | `x_search` | `x_search` | Search X (Twitter) posts and threads via xAI's built-in `x_search` Responses tool. Off by default; opt in via `claway tools`. Schema only registered when xAI credentials (SuperGrok OAuth or `XAI_API_KEY`) are configured. | | `yuanbao` | `yb_query_group_info`, `yb_query_group_members`, `yb_search_sticker`, `yb_send_dm`, `yb_send_sticker` | Yuanbao DM/group actions and sticker search. Registered only on `claway-yuanbao`. | ## Platform Toolsets Platform toolsets define the complete tool configuration for a deployment target. Most messaging platforms use the same set as `claway-cli`: | Toolset | Differences from `claway-cli` | |---------|-------------------------------| | `claway-cli` | Full toolset — the default for interactive CLI sessions. Includes file, terminal, web, browser, memory, skills, vision, image_gen, todo, tts, delegation, code_execution, cronjob, session_search, and clarify, plus the `safe` (read-only) bundle. | | `claway-acp` | Drops `clarify`, `cronjob`, `image_generate`, `text_to_speech`, and all four Home Assistant tools. Focused on coding tasks in IDE context. | | `claway-api-server` | Drops `clarify` and `text_to_speech`. Keeps everything else — suitable for programmatic access where user interaction isn't possible. | | `claway-cron` | Same as `claway-cli`. | | `claway-telegram` | Same as `claway-cli`. | | `claway-discord` | Adds `discord` and `discord_admin` on top of `claway-cli`. | | `claway-slack` | Same as `claway-cli`. | | `claway-whatsapp` | Same as `claway-cli`. | | `claway-signal` | Same as `claway-cli`. | | `claway-matrix` | Same as `claway-cli`. | | `claway-mattermost` | Same as `claway-cli`. | | `claway-email` | Same as `claway-cli`. | | `claway-sms` | Same as `claway-cli`. | | `claway-bluebubbles` | Same as `claway-cli`. | | `claway-dingtalk` | Same as `claway-cli`. | | `claway-feishu` | Adds the five `feishu_doc_*` / `feishu_drive_*` tools (only used by the document-comment handler, not the regular chat adapter). | | `claway-qqbot` | Same as `claway-cli`. | | `claway-wecom` | Same as `claway-cli`. | | `claway-wecom-callback` | Same as `claway-cli`. | | `claway-weixin` | Same as `claway-cli`. | | `claway-yuanbao` | Adds the five `yb_*` tools (DM/group/sticker) on top of `claway-cli`. | | `claway-homeassistant` | Same as `claway-cli` (the Home Assistant tools are already present by default and activate when `HASS_TOKEN` is set). | | `claway-webhook` | Same as `claway-cli`. | | `claway-gateway` | Internal gateway orchestrator toolset — union of every `claway-<platform>` toolset; used when the gateway needs to accept any message source. | ## Dynamic Toolsets ### MCP server toolsets Each configured MCP server generates a `mcp-<server>` toolset at runtime. For example, if you configure a `github` MCP server, a `mcp-github` toolset is created containing all tools that server exposes. ```yaml # config.yaml mcp_servers: github: command: npx args: ["-y", "@modelcontextprotocol/server-github"] ``` This creates a `mcp-github` toolset you can reference in `--toolsets` or platform configs. ### Plugin toolsets Plugins can register their own toolsets via `ctx.register_tool()` during plugin initialization. These appear alongside built-in toolsets and can be enabled/disabled the same way. ### Custom toolsets Define custom toolsets in `config.yaml` to create project-specific bundles: ```yaml toolsets: - claway-cli custom_toolsets: data-science: - file - terminal - code_execution - web - vision ``` ### Wildcards - `all` or `*` — expands to every registered toolset (built-in + dynamic + plugin) A handful of tools have an additional availability check on top of toolset membership and are **not** turned on by `all`/`*` alone: - **Capability-gated** tools (browser, `computer_use`, `code_execution`, Feishu, Home Assistant, cronjob) appear only when their backend/credential prerequisite is configured. - **Workflow-gated** tools — the `kanban` toolset — are deliberately opt-in. `all`/`*` does **not** enable kanban; you must list `kanban` explicitly (or be a dispatcher-spawned worker with `CLAWAY_KANBAN_TASK` set). Kanban tools mutate shared board state, so they stay off by default even under `all`. ## Relationship to `claway tools` The `claway tools` command provides a curses-based UI for toggling individual tools on or off per platform. This operates at the tool level (finer than toolsets) and persists to `config.yaml`. Disabled tools are filtered out even if their toolset is enabled. See also: [Tools Reference](./tools-reference.md) for the complete list of individual tools and their parameters. --- <!-- source: website/docs/reference/skills-catalog.md --> # Bundled Skills Catalog # Bundled Skills Catalog Claway ships with a large built-in skill library copied into `~/.claway/skills/` on install. Each skill below links to a dedicated page with its full definition, setup, and usage. Claway also syncs bundled skills on `claway update`, but the sync manifest respects local deletions and user edits. If a skill listed here is missing from your profile's `~/.claway/skills/` tree, it is still shipped with Claway; restore it with `claway skills reset <name> --restore`. If a skill is missing from this list but present in the repo, the catalog is regenerated by `website/scripts/generate-skill-docs.py`. ## apple | Skill | Description | Path | |-------|-------------|------| | [`apple-notes`](/user-guide/skills/bundled/apple/apple-apple-notes) | Manage Apple Notes via memo CLI: create, search, edit. | `apple/apple-notes` | | [`apple-reminders`](/user-guide/skills/bundled/apple/apple-apple-reminders) | Apple Reminders via remindctl: add, list, complete. | `apple/apple-reminders` | | [`findmy`](/user-guide/skills/bundled/apple/apple-findmy) | Track Apple devices/AirTags via FindMy.app on macOS. | `apple/findmy` | | [`imessage`](/user-guide/skills/bundled/apple/apple-imessage) | Send and receive iMessages/SMS via the imsg CLI on macOS. | `apple/imessage` | ## autonomous-ai-agents | Skill | Description | Path | |-------|-------------|------| | [`claude-code`](/user-guide/skills/bundled/autonomous-ai-agents/autonomous-ai-agents-claude-code) | Delegate coding to Claude Code CLI (features, PRs). | `autonomous-ai-agents/claude-code` | | [`codex`](/user-guide/skills/bundled/autonomous-ai-agents/autonomous-ai-agents-codex) | Delegate coding to OpenAI Codex CLI (features, PRs). | `autonomous-ai-agents/codex` | | [`opencode`](/user-guide/skills/bundled/autonomous-ai-agents/autonomous-ai-agents-opencode) | Delegate coding to OpenCode CLI (features, PR review). | `autonomous-ai-agents/opencode` | ## computer-use | Skill | Description | Path | |-------|-------------|------| | [`computer-use`](/user-guide/skills/bundled/computer-use/computer-use-computer-use) | Drive the user's desktop in the background — clicking, typing, scrolling, dragging — without stealing the cursor, keyboard focus, or switching virtual desktops / Spaces. Cross-platform: macOS, Windows, Linux. Works with any tool-capable... | `computer-use` | ## creative | Skill | Description | Path | |-------|-------------|------| | [`architecture-diagram`](/user-guide/skills/bundled/creative/creative-architecture-diagram) | Dark-themed SVG architecture/cloud/infra diagrams as HTML. | `creative/architecture-diagram` | | [`ascii-art`](/user-guide/skills/bundled/creative/creative-ascii-art) | ASCII art: pyfiglet, cowsay, boxes, image-to-ascii. | `creative/ascii-art` | | [`ascii-video`](/user-guide/skills/bundled/creative/creative-ascii-video) | ASCII video: convert video/audio to colored ASCII MP4/GIF. | `creative/ascii-video` | | [`baoyu-infographic`](/user-guide/skills/bundled/creative/creative-baoyu-infographic) | Infographics: 21 layouts x 21 styles (信息图, 可视化). | `creative/baoyu-infographic` | | [`canvas-design`](/user-guide/skills/bundled/creative/creative-canvas-design) | Create beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying e... | `creative/canvas-design` | | [`claude-design`](/user-guide/skills/bundled/creative/creative-claude-design) | Design one-off HTML artifacts (landing, deck, prototype). | `creative/claude-design` | | [`comfyui`](/user-guide/skills/bundled/creative/creative-comfyui) | Generate images, video, and audio with ComfyUI — install, launch, manage nodes/models, run workflows with parameter injection. Uses the official comfy-cli for lifecycle and direct REST/WebSocket API for execution. | `creative/comfyui` | | [`design-md`](/user-guide/skills/bundled/creative/creative-design-md) | Author/validate/export Google's DESIGN.md token spec files. | `creative/design-md` | | [`excalidraw`](/user-guide/skills/bundled/creative/creative-excalidraw) | Hand-drawn Excalidraw JSON diagrams (arch, flow, seq). | `creative/excalidraw` | | [`frontend-design`](/user-guide/skills/bundled/creative/creative-frontend-design) | Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | `creative/frontend-design` | | [`humanizer`](/user-guide/skills/bundled/creative/creative-humanizer) | Humanize text: strip AI-isms and add real voice. | `creative/humanizer` | | [`manim-video`](/user-guide/skills/bundled/creative/creative-manim-video) | Manim CE animations: 3Blue1Brown math/algo videos. | `creative/manim-video` | | [`p5js`](/user-guide/skills/bundled/creative/creative-p5js) | p5.js sketches: gen art, shaders, interactive, 3D. | `creative/p5js` | | [`popular-web-designs`](/user-guide/skills/bundled/creative/creative-popular-web-designs) | 54 real design systems (Stripe, Linear, Vercel) as HTML/CSS. | `creative/popular-web-designs` | | [`pretext`](/user-guide/skills/bundled/creative/creative-pretext) | Use when building creative browser demos with @chenglou/pretext — DOM-free text layout for ASCII art, typographic flow around obstacles, text-as-geometry games, kinetic typography, and text-powered generative art. Produces single-file HT... | `creative/pretext` | | [`sketch`](/user-guide/skills/bundled/creative/creative-sketch) | Throwaway HTML mockups: 2-3 design variants to compare. | `creative/sketch` | | [`songwriting-and-ai-music`](/user-guide/skills/bundled/creative/creative-songwriting-and-ai-music) | Songwriting craft and Suno AI music prompts. | `creative/songwriting-and-ai-music` | | [`theme-factory`](/user-guide/skills/bundled/creative/creative-theme-factory) | Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with colors/fonts that you can apply to any artifact that has been creating, or can generat... | `creative/theme-factory` | | [`touchdesigner-mcp`](/user-guide/skills/bundled/creative/creative-touchdesigner-mcp) | Control a running TouchDesigner instance via twozero MCP — create operators, set parameters, wire connections, execute Python, build real-time visuals. 36 native tools. | `creative/touchdesigner-mcp` | ## data-science | Skill | Description | Path | |-------|-------------|------| | [`jupyter-live-kernel`](/user-guide/skills/bundled/data-science/data-science-jupyter-live-kernel) | Iterative Python via live Jupyter kernel (hamelnb). | `data-science/jupyter-live-kernel` | ## document | Skill | Description | Path | |-------|-------------|------| | [`docx`](/user-guide/skills/bundled/document/document-docx) | Word documents Jarvis can open, read, edit and write via python-docx: contracts, letters, quotations, meeting minutes, reports. Use whenever a .docx is the input or the output — '睇下份合約', '幫我改份報價單', '整封信', '轉做 Word'. For a .doc (old forma... | `document/docx` | | [`pdf-toolkit`](/user-guide/skills/bundled/document/document-pdf-toolkit) | PDF operations Jarvis can shell out to: FILL a user's PDF template in place (same font/size/position — never redraw it), list a template's fields, merge PDFs/images, split by page range, compress, image(s)→PDF. Use fill whenever the user... | `document/pdf-toolkit` | | [`xlsx`](/user-guide/skills/bundled/document/document-xlsx) | Excel/試算表 files Jarvis can open, read, edit and build: .xlsx/.xlsm read + write via openpyxl, .csv via pandas. Use whenever a spreadsheet is the input or the output — '睇下呢個 Excel', '對下條數', '幫我加返一行', '整張報表', '轉做 Excel', invoices, expense... | `document/xlsx` | ## dogfood | Skill | Description | Path | |-------|-------------|------| | [`dogfood`](/user-guide/skills/bundled/dogfood/dogfood-dogfood) | Exploratory QA of web apps: find bugs, evidence, reports. | `dogfood` | ## email | Skill | Description | Path | |-------|-------------|------| | [`himalaya`](/user-guide/skills/bundled/email/email-himalaya) | Himalaya CLI: IMAP/SMTP email from terminal. | `email/himalaya` | ## github | Skill | Description | Path | |-------|-------------|------| | [`codebase-inspection`](/user-guide/skills/bundled/github/github-codebase-inspection) | Inspect codebases w/ pygount: LOC, languages, ratios. | `github/codebase-inspection` | | [`github-auth`](/user-guide/skills/bundled/github/github-github-auth) | GitHub auth setup: HTTPS tokens, SSH keys, gh CLI login. | `github/github-auth` | | [`github-code-review`](/user-guide/skills/bundled/github/github-github-code-review) | Review PRs: diffs, inline comments via gh or REST. | `github/github-code-review` | | [`github-issues`](/user-guide/skills/bundled/github/github-github-issues) | Create, triage, label, assign GitHub issues via gh or REST. | `github/github-issues` | | [`github-pr-workflow`](/user-guide/skills/bundled/github/github-github-pr-workflow) | GitHub PR lifecycle: branch, commit, open, CI, merge. | `github/github-pr-workflow` | | [`github-repo-management`](/user-guide/skills/bundled/github/github-github-repo-management) | Clone/create/fork repos; manage remotes, releases. | `github/github-repo-management` | ## media | Skill | Description | Path | |-------|-------------|------| | [`gif-search`](/user-guide/skills/bundled/media/media-gif-search) | Search/download GIFs from Tenor via curl + jq. | `media/gif-search` | | [`heartmula`](/user-guide/skills/bundled/media/media-heartmula) | HeartMuLa: Suno-like song generation from lyrics + tags. | `media/heartmula` | | [`songsee`](/user-guide/skills/bundled/media/media-songsee) | Audio spectrograms/features (mel, chroma, MFCC) via CLI. | `media/songsee` | | [`youtube-content`](/user-guide/skills/bundled/media/media-youtube-content) | YouTube transcripts to summaries, threads, blogs. | `media/youtube-content` | ## mlops | Skill | Description | Path | |-------|-------------|------| | [`audiocraft-audio-generation`](/user-guide/skills/bundled/mlops/mlops-models-audiocraft) | AudioCraft: MusicGen text-to-music, AudioGen text-to-sound. | `mlops/models/audiocraft` | | [`huggingface-hub`](/user-guide/skills/bundled/mlops/mlops-huggingface-hub) | HuggingFace hf CLI: search/download/upload models, datasets. | `mlops/huggingface-hub` | | [`llama-cpp`](/user-guide/skills/bundled/mlops/mlops-inference-llama-cpp) | llama.cpp local GGUF inference + HF Hub model discovery. | `mlops/inference/llama-cpp` | | [`evaluating-llms-harness`](/user-guide/skills/bundled/mlops/mlops-evaluation-lm-evaluation-harness) | lm-eval-harness: benchmark LLMs (MMLU, GSM8K, etc.). | `mlops/evaluation/lm-evaluation-harness` | | [`segment-anything-model`](/user-guide/skills/bundled/mlops/mlops-models-segment-anything) | SAM: zero-shot image segmentation via points, boxes, masks. | `mlops/models/segment-anything` | | [`serving-llms-vllm`](/user-guide/skills/bundled/mlops/mlops-inference-vllm) | vLLM: high-throughput LLM serving, OpenAI API, quantization. | `mlops/inference/vllm` | | [`weights-and-biases`](/user-guide/skills/bundled/mlops/mlops-evaluation-weights-and-biases) | W&B: log ML experiments, sweeps, model registry, dashboards. | `mlops/evaluation/weights-and-biases` | ## note-taking | Skill | Description | Path | |-------|-------------|------| | [`obsidian`](/user-guide/skills/bundled/note-taking/note-taking-obsidian) | Read, search, create, and edit notes in the Obsidian vault. | `note-taking/obsidian` | ## productivity | Skill | Description | Path | |-------|-------------|------| | [`airtable`](/user-guide/skills/bundled/productivity/productivity-airtable) | Airtable REST API via curl. Records CRUD, filters, upserts. | `productivity/airtable` | | [`google-workspace`](/user-guide/skills/bundled/productivity/productivity-google-workspace) | Gmail, Calendar, Drive, Docs, Sheets via gws CLI or Python. | `productivity/google-workspace` | | [`maps`](/user-guide/skills/bundled/productivity/productivity-maps) | Geocode, POIs, routes, timezones via OpenStreetMap/OSRM. | `productivity/maps` | | [`nano-pdf`](/user-guide/skills/bundled/productivity/productivity-nano-pdf) | Edit PDF text/typos/titles via nano-pdf CLI (NL prompts). | `productivity/nano-pdf` | | [`notion`](/user-guide/skills/bundled/productivity/productivity-notion) | Notion API + ntn CLI: pages, databases, markdown, Workers. | `productivity/notion` | | [`ocr-and-documents`](/user-guide/skills/bundled/productivity/productivity-ocr-and-documents) | Extract text from PDFs/scans (pymupdf, marker-pdf). | `productivity/ocr-and-documents` | | [`petdex`](/user-guide/skills/bundled/productivity/productivity-petdex) | Install and select animated petdex mascots for Claway. | `productivity/petdex` | | [`powerpoint`](/user-guide/skills/bundled/productivity/productivity-powerpoint) | Create, read, edit .pptx decks, slides, notes, templates. | `productivity/powerpoint` | | [`teams-meeting-pipeline`](/user-guide/skills/bundled/productivity/productivity-teams-meeting-pipeline) | Operate the Teams meeting summary pipeline via Claway CLI — summarize meetings, inspect pipeline status, replay jobs, manage Microsoft Graph subscriptions. | `productivity/teams-meeting-pipeline` | ## research | Skill | Description | Path | |-------|-------------|------| | [`arxiv`](/user-guide/skills/bundled/research/research-arxiv) | Search arXiv papers by keyword, author, category, or ID. | `research/arxiv` | | [`blogwatcher`](/user-guide/skills/bundled/research/research-blogwatcher) | Monitor blogs and RSS/Atom feeds via blogwatcher-cli tool. | `research/blogwatcher` | | [`grounded-citations`](/user-guide/skills/bundled/research/research-grounded-citations) | Ground answers and documents in cited, verifiable sources. | `research/grounded-citations` | | [`llm-wiki`](/user-guide/skills/bundled/research/research-llm-wiki) | Karpathy's LLM Wiki: build/query interlinked markdown KB. | `research/llm-wiki` | | [`polymarket`](/user-guide/skills/bundled/research/research-polymarket) | Query Polymarket: markets, prices, orderbooks, history. | `research/polymarket` | | [`research-paper-writing`](/user-guide/skills/bundled/research/research-research-paper-writing) | Write ML papers for NeurIPS/ICML/ICLR: design→submit. | `research/research-paper-writing` | ## smart-home | Skill | Description | Path | |-------|-------------|------| | [`openhue`](/user-guide/skills/bundled/smart-home/smart-home-openhue) | Control Philips Hue lights, scenes, rooms via OpenHue CLI. | `smart-home/openhue` | ## social-media | Skill | Description | Path | |-------|-------------|------| | [`xurl`](/user-guide/skills/bundled/social-media/social-media-xurl) | X/Twitter via xurl CLI: post, search, DM, media, v2 API. | `social-media/xurl` | ## software-development | Skill | Description | Path | |-------|-------------|------| | [`node-inspect-debugger`](/user-guide/skills/bundled/software-development/software-development-node-inspect-debugger) | Debug Node.js via --inspect + Chrome DevTools Protocol CLI. | `software-development/node-inspect-debugger` | | [`plan`](/user-guide/skills/bundled/software-development/software-development-plan) | Plan mode: write an actionable markdown plan to .claway/plans/, no execution. Bite-sized tasks, exact paths, complete code. | `software-development/plan` | | [`python-debugpy`](/user-guide/skills/bundled/software-development/software-development-python-debugpy) | Debug Python: pdb REPL + debugpy remote (DAP). | `software-development/python-debugpy` | | [`requesting-code-review`](/user-guide/skills/bundled/software-development/software-development-requesting-code-review) | Pre-commit review: security scan, quality gates, auto-fix. | `software-development/requesting-code-review` | | [`simplify-code`](/user-guide/skills/bundled/software-development/software-development-simplify-code) | Parallel 3-agent cleanup of recent code changes. | `software-development/simplify-code` | | [`spike`](/user-guide/skills/bundled/software-development/software-development-spike) | Throwaway experiments to validate an idea before build. | `software-development/spike` | | [`systematic-debugging`](/user-guide/skills/bundled/software-development/software-development-systematic-debugging) | 4-phase root cause debugging: understand bugs before fixing. | `software-development/systematic-debugging` | | [`test-driven-development`](/user-guide/skills/bundled/software-development/software-development-test-driven-development) | TDD: enforce RED-GREEN-REFACTOR, tests before code. | `software-development/test-driven-development` | ## support | Skill | Description | Path | |-------|-------------|------| | [`support`](/user-guide/skills/bundled/support/support-support) | Escalate to a human operator when Jarvis hits a policy refusal, confidence collapse, or an explicit user handoff request. | `support` | ## yuanbao | Skill | Description | Path | |-------|-------------|------| | [`yuanbao`](/user-guide/skills/bundled/yuanbao/yuanbao-yuanbao) | Yuanbao (元宝) groups: @mention users, query info/members. | `yuanbao` | --- <!-- source: website/docs/reference/optional-skills-catalog.md --> # Optional Skills Catalog # Optional Skills Catalog Optional skills ship with claway under `optional-skills/` but are **not active by default**. Install them explicitly: ```bash claway skills install official/<category>/<skill> ``` For example: ```bash claway skills install official/blockchain/solana claway skills install official/mlops/flash-attention ``` Each skill below links to a dedicated page with its full definition, setup, and usage. To uninstall: ```bash claway skills uninstall <skill-name> ``` ## autonomous-ai-agents | Skill | Description | |-------|-------------| | [**antigravity-cli**](/user-guide/skills/optional/autonomous-ai-agents/autonomous-ai-agents-antigravity-cli) | Operate the Antigravity CLI (agy): plugins, auth, sandbox. | | [**blackbox**](/user-guide/skills/optional/autonomous-ai-agents/autonomous-ai-agents-blackbox) | Delegate coding tasks to Blackbox AI CLI agent. Multi-model agent with built-in judge that runs tasks through multiple LLMs and picks the best result. Requires the blackbox CLI and a Blackbox AI API key. | | [**grok**](/user-guide/skills/optional/autonomous-ai-agents/autonomous-ai-agents-grok) | Delegate coding to xAI Grok Build CLI (features, PRs). | | [**honcho**](/user-guide/skills/optional/autonomous-ai-agents/autonomous-ai-agents-honcho) | Configure and use Honcho memory with Claway -- cross-session user modeling, multi-profile peer isolation, observation config, dialectic reasoning, session summaries, and context budget enforcement. Use when setting up Honcho, troubleshoo... | | [**openhands**](/user-guide/skills/optional/autonomous-ai-agents/autonomous-ai-agents-openhands) | Delegate coding to OpenHands CLI (model-agnostic, LiteLLM). | ## blockchain | Skill | Description | |-------|-------------| | [**evm**](/user-guide/skills/optional/blockchain/blockchain-evm) | Read-only EVM client: wallets, tokens, gas across 8 chains. | | [**hyperliquid**](/user-guide/skills/optional/blockchain/blockchain-hyperliquid) | Hyperliquid market data, account history, trade review. | | [**solana**](/user-guide/skills/optional/blockchain/blockchain-solana) | Query Solana blockchain data with USD pricing — wallet balances, token portfolios with values, transaction details, NFTs, whale detection, and live network stats. Uses Solana RPC + CoinGecko. No API key required. | ## communication | Skill | Description | |-------|-------------| | [**one-three-one-rule**](/user-guide/skills/optional/communication/communication-one-three-one-rule) | Structured decision-making framework for technical proposals and trade-off analysis. When the user faces a choice between multiple approaches (architecture decisions, tool selection, refactoring strategies, migration paths), this skill p... | ## creative | Skill | Description | |-------|-------------| | [**baoyu-article-illustrator**](/user-guide/skills/optional/creative/creative-baoyu-article-illustrator) | Article illustrations: type × style × palette consistency. | | [**baoyu-comic**](/user-guide/skills/optional/creative/creative-baoyu-comic) | Knowledge comics (知识漫画): educational, biography, tutorial. | | [**blender-mcp**](/user-guide/skills/optional/creative/creative-blender-mcp) | Control Blender directly from Claway via socket connection to the blender-mcp addon. Create 3D objects, materials, animations, and run arbitrary Blender Python (bpy) code. Use when user wants to create or modify anything in Blender. | | [**concept-diagrams**](/user-guide/skills/optional/creative/creative-concept-diagrams) | Generate flat, minimal light/dark-aware SVG diagrams as standalone HTML files, using a unified educational visual language with 9 semantic color ramps, sentence-case typography, and automatic dark mode. Best suited for educational and no... | | [**creative-ideation**](/user-guide/skills/optional/creative/creative-creative-ideation) | Generate ideas via named methods from creative practice. | | [**hyperframes**](/user-guide/skills/optional/creative/creative-hyperframes) | Create HTML-based video compositions, animated title cards, social overlays, captioned talking-head videos, audio-reactive visuals, and shader transitions using HyperFrames. HTML is the source of truth for video. Use when the user wants... | | [**kanban-video-orchestrator**](/user-guide/skills/optional/creative/creative-kanban-video-orchestrator) | Plan, set up, and monitor a multi-agent video production pipeline backed by Claway Kanban. Use when the user wants to make ANY video — narrative film, product/marketing, music video, explainer, ASCII/terminal art, abstract/generative loo... | | [**meme-generation**](/user-guide/skills/optional/creative/creative-meme-generation) | Generate real meme images by picking a template and overlaying text with Pillow. Produces actual .png meme files. | | [**pixel-art**](/user-guide/skills/optional/creative/creative-pixel-art) | Pixel art w/ era palettes (NES, Game Boy, PICO-8). | ## devops | Skill | Description | |-------|-------------| | [**inference-sh-cli**](/user-guide/skills/optional/devops/devops-cli) | Run 150+ AI apps via inference.sh CLI (infsh) — image generation, video creation, LLMs, search, 3D, social automation. Uses the terminal tool. Triggers: inference.sh, infsh, ai apps, flux, veo, image generation, video generation, seedrea... | | [**docker-management**](/user-guide/skills/optional/devops/devops-docker-management) | Manage Docker containers, images, volumes, networks, and Compose stacks — lifecycle ops, debugging, cleanup, and Dockerfile optimization. | | [**pinggy-tunnel**](/user-guide/skills/optional/devops/devops-pinggy-tunnel) | Zero-install localhost tunnels over SSH via Pinggy. | | [**watchers**](/user-guide/skills/optional/devops/devops-watchers) | Poll RSS, JSON APIs, and GitHub with watermark dedup. | ## dogfood | Skill | Description | |-------|-------------| | [**adversarial-ux-test**](/user-guide/skills/optional/dogfood/dogfood-adversarial-ux-test) | Roleplay the most difficult, tech-resistant user for your product. Browse the app as that persona, find every UX pain point, then filter complaints through a pragmatism layer to separate real problems from noise. Creates actionable ticke... | ## email | Skill | Description | |-------|-------------| | [**agentmail**](/user-guide/skills/optional/email/email-agentmail) | Give the agent its own dedicated email inbox via AgentMail. Send, receive, and manage email autonomously using agent-owned email addresses (e.g. claway@agentmail.to). | ## finance | Skill | Description | |-------|-------------| | [**3-statement-model**](/user-guide/skills/optional/finance/finance-3-statement-model) | Build fully-integrated 3-statement models (IS, BS, CF) in Excel with working capital schedules, D&A roll-forwards, debt schedule, and the plugs that make cash and retained earnings tie. Pairs with excel-author. | | [**comps-analysis**](/user-guide/skills/optional/finance/finance-comps-analysis) | Build comparable company analysis in Excel — operating metrics, valuation multiples, statistical benchmarking vs peer sets. Pairs with excel-author. Use for public-company valuation, IPO pricing, sector benchmarking, or outlier detection. | | [**dcf-model**](/user-guide/skills/optional/finance/finance-dcf-model) | Build institutional-quality DCF valuation models in Excel — revenue projections, FCF build, WACC, terminal value, Bear/Base/Bull scenarios, 5x5 sensitivity tables. Pairs with excel-author. Use for intrinsic-value equity analysis. | | [**excel-author**](/user-guide/skills/optional/finance/finance-excel-author) | Build auditable Excel workbooks headless with openpyxl — blue/black/green cell conventions, formulas over hardcodes, named ranges, balance checks, sensitivity tables. Use for financial models, audit outputs, reconciliations. | | [**lbo-model**](/user-guide/skills/optional/finance/finance-lbo-model) | Build leveraged buyout models in Excel — sources & uses, debt schedule, cash sweep, exit multiple, IRR/MOIC sensitivity. Pairs with excel-author. Use for PE screening, sponsor-case valuation, or illustrative LBO in a pitch. | | [**merger-model**](/user-guide/skills/optional/finance/finance-merger-model) | Build accretion/dilution (merger) models in Excel — pro-forma P&L, synergies, financing mix, EPS impact. Pairs with excel-author. Use for M&A pitches, board materials, or deal evaluation. | | [**pptx-author**](/user-guide/skills/optional/finance/finance-pptx-author) | Build PowerPoint decks headless with python-pptx. Pairs with excel-author for model-backed decks where every number traces to a workbook cell. Use for pitch decks, IC memos, earnings notes. | | [**stocks**](/user-guide/skills/optional/finance/finance-stocks) | Stock quotes, history, search, compare, crypto via Yahoo. | ## gaming | Skill | Description | |-------|-------------| | [**minecraft-modpack-server**](/user-guide/skills/optional/gaming/gaming-minecraft-modpack-server) | Host modded Minecraft servers (CurseForge, Modrinth). | | [**pokemon-player**](/user-guide/skills/optional/gaming/gaming-pokemon-player) | Play Pokemon via headless emulator + RAM reads. | ## health | Skill | Description | |-------|-------------| | [**fitness-nutrition**](/user-guide/skills/optional/health/health-fitness-nutrition) | Gym workout planner and nutrition tracker. Search 690+ exercises by muscle, equipment, or category via wger. Look up macros and calories for 380,000+ foods via USDA FoodData Central. Compute BMI, TDEE, one-rep max, macro splits, and body... | | [**neuroskill-bci**](/user-guide/skills/optional/health/health-neuroskill-bci) | Connect to a running NeuroSkill instance and incorporate the user's real-time cognitive and emotional state (focus, relaxation, mood, cognitive load, drowsiness, heart rate, HRV, sleep staging, and 40+ derived EXG scores) into responses.... | ## mcp | Skill | Description | |-------|-------------| | [**fastmcp**](/user-guide/skills/optional/mcp/mcp-fastmcp) | Build, test, inspect, install, and deploy MCP servers with FastMCP in Python. Use when creating a new MCP server, wrapping an API or database as MCP tools, exposing resources or prompts, or preparing a FastMCP server for Claude Code, Cur... | | [**mcporter**](/user-guide/skills/optional/mcp/mcp-mcporter) | Use the mcporter CLI to list, configure, auth, and call MCP servers/tools directly (HTTP or stdio), including ad-hoc servers, config edits, and CLI/type generation. | ## migration | Skill | Description | |-------|-------------| | [**openclaw-migration**](/user-guide/skills/optional/migration/migration-openclaw-migration) | Migrate a user's OpenClaw customization footprint into Claway Agent. Imports Claway-compatible memories, SOUL.md, command allowlists, user skills, and selected workspace assets from ~/.openclaw, then reports exactly what could not be mig... | ## mlops | Skill | Description | |-------|-------------| | [**huggingface-accelerate**](/user-guide/skills/optional/mlops/mlops-accelerate) | Simplest distributed training API. 4 lines to add distributed support to any PyTorch script. Unified API for DeepSpeed/FSDP/Megatron/DDP. Automatic device placement, mixed precision (FP16/BF16/FP8). Interactive config, single launch comm... | | [**axolotl**](/user-guide/skills/optional/mlops/mlops-training-axolotl) | Axolotl: YAML LLM fine-tuning (LoRA, DPO, GRPO). | | [**chroma**](/user-guide/skills/optional/mlops/mlops-chroma) | Open-source embedding database for AI applications. Store embeddings and metadata, perform vector and full-text search, filter by metadata. Simple 4-function API. Scales from notebooks to production clusters. Use for semantic search, RAG... | | [**clip**](/user-guide/skills/optional/mlops/mlops-clip) | OpenAI's model connecting vision and language. Enables zero-shot image classification, image-text matching, and cross-modal retrieval. Trained on 400M image-text pairs. Use for image search, content moderation, or vision-language tasks w... | | [**dspy**](/user-guide/skills/optional/mlops/mlops-research-dspy) | DSPy: declarative LM programs, auto-optimize prompts, RAG. | | [**faiss**](/user-guide/skills/optional/mlops/mlops-faiss) | Facebook's library for efficient similarity search and clustering of dense vectors. Supports billions of vectors, GPU acceleration, and various index types (Flat, IVF, HNSW). Use for fast k-NN search, large-scale vector retrieval, or whe... | | [**optimizing-attention-flash**](/user-guide/skills/optional/mlops/mlops-flash-attention) | Optimizes transformer attention with Flash Attention for 2-4x speedup and 10-20x memory reduction. Use when training/running transformers with long sequences (>512 tokens), encountering GPU memory issues with attention, or need faster in... | | [**guidance**](/user-guide/skills/optional/mlops/mlops-guidance) | Control LLM output with regex and grammars, guarantee valid JSON/XML/code generation, enforce structured formats, and build multi-step workflows with Guidance - Microsoft Research's constrained generation framework | | [**huggingface-tokenizers**](/user-guide/skills/optional/mlops/mlops-huggingface-tokenizers) | Fast tokenizers optimized for research and production. Rust-based implementation tokenizes 1GB in <20 seconds. Supports BPE, WordPiece, and Unigram algorithms. Train custom vocabularies, track alignments, handle padding/truncation. Integ... | | [**instructor**](/user-guide/skills/optional/mlops/mlops-instructor) | Extract structured data from LLM responses with Pydantic validation, retry failed extractions automatically, parse complex JSON with type safety, and stream partial results with Instructor - battle-tested structured output library | | [**lambda-labs-gpu-cloud**](/user-guide/skills/optional/mlops/mlops-lambda-labs) | Reserved and on-demand GPU cloud instances for ML training and inference. Use when you need dedicated GPU instances with simple SSH access, persistent filesystems, or high-performance multi-node clusters for large-scale training. | | [**llava**](/user-guide/skills/optional/mlops/mlops-llava) | Large Language and Vision Assistant. Enables visual instruction tuning and image-based conversations. Combines CLIP vision encoder with Vicuna/LLaMA language models. Supports multi-turn image chat, visual question answering, and instruct... | | [**modal-serverless-gpu**](/user-guide/skills/optional/mlops/mlops-modal) | Serverless GPU cloud platform for running ML workloads. Use when you need on-demand GPU access without infrastructure management, deploying ML models as APIs, or running batch jobs with automatic scaling. | | [**nemo-curator**](/user-guide/skills/optional/mlops/mlops-nemo-curator) | GPU-accelerated data curation for LLM training. Supports text/image/video/audio. Features fuzzy deduplication (16× faster), quality filtering (30+ heuristics), semantic deduplication, PII redaction, NSFW detection. Scales across GPUs wit... | | [**obliteratus**](/user-guide/skills/optional/mlops/mlops-obliteratus) | OBLITERATUS: abliterate LLM refusals (diff-in-means). | | [**outlines**](/user-guide/skills/optional/mlops/mlops-inference-outlines) | Outlines: structured JSON/regex/Pydantic LLM generation. | | [**peft-fine-tuning**](/user-guide/skills/optional/mlops/mlops-peft) | Parameter-efficient fine-tuning for LLMs using LoRA, QLoRA, and 25+ methods. Use when fine-tuning large models (7B-70B) with limited GPU memory, when you need to train <1% of parameters with minimal accuracy loss, or for multi-adapter se... | | [**pinecone**](/user-guide/skills/optional/mlops/mlops-pinecone) | Managed vector database for production AI applications. Fully managed, auto-scaling, with hybrid search (dense + sparse), metadata filtering, and namespaces. Low latency (<100ms p95). Use for production RAG, recommendation systems, or se... | | [**pytorch-fsdp**](/user-guide/skills/optional/mlops/mlops-pytorch-fsdp) | Expert guidance for Fully Sharded Data Parallel training with PyTorch FSDP - parameter sharding, mixed precision, CPU offloading, FSDP2 | | [**pytorch-lightning**](/user-guide/skills/optional/mlops/mlops-pytorch-lightning) | High-level PyTorch framework with Trainer class, automatic distributed training (DDP/FSDP/DeepSpeed), callbacks system, and minimal boilerplate. Scales from laptop to supercomputer with same code. Use when you want clean training loops w... | | [**qdrant-vector-search**](/user-guide/skills/optional/mlops/mlops-qdrant) | High-performance vector similarity search engine for RAG and semantic search. Use when building production RAG systems requiring fast nearest neighbor search, hybrid search with filtering, or scalable vector storage with Rust-powered per... | | [**sparse-autoencoder-training**](/user-guide/skills/optional/mlops/mlops-saelens) | Provides guidance for training and analyzing Sparse Autoencoders (SAEs) using SAELens to decompose neural network activations into interpretable features. Use when discovering interpretable features, analyzing superposition, or studying... | | [**simpo-training**](/user-guide/skills/optional/mlops/mlops-simpo) | Simple Preference Optimization for LLM alignment. Reference-free alternative to DPO with better performance (+6.4 points on AlpacaEval 2.0). No reference model needed, more efficient than DPO. Use for preference alignment when want simpl... | | [**slime-rl-training**](/user-guide/skills/optional/mlops/mlops-slime) | Provides guidance for LLM post-training with RL using slime, a Megatron+SGLang framework. Use when training GLM models, implementing custom data generation workflows, or needing tight Megatron-LM integration for RL scaling. | | [**stable-diffusion-image-generation**](/user-guide/skills/optional/mlops/mlops-stable-diffusion) | State-of-the-art text-to-image generation with Stable Diffusion models via HuggingFace Diffusers. Use when generating images from text prompts, performing image-to-image translation, inpainting, or building custom diffusion pipelines. | | [**tensorrt-llm**](/user-guide/skills/optional/mlops/mlops-tensorrt-llm) | Optimizes LLM inference with NVIDIA TensorRT for maximum throughput and lowest latency. Use for production deployment on NVIDIA GPUs (A100/H100), when you need 10-100x faster inference than PyTorch, or for serving models with quantizatio... | | [**distributed-llm-pretraining-torchtitan**](/user-guide/skills/optional/mlops/mlops-torchtitan) | Provides PyTorch-native distributed LLM pretraining using torchtitan with 4D parallelism (FSDP2, TP, PP, CP). Use when pretraining Llama 3.1, DeepSeek V3, or custom models at scale from 8 to 512+ GPUs with Float8, torch.compile, and dist... | | [**fine-tuning-with-trl**](/user-guide/skills/optional/mlops/mlops-training-trl-fine-tuning) | TRL: SFT, DPO, PPO, GRPO, reward modeling for LLM RLHF. | | [**unsloth**](/user-guide/skills/optional/mlops/mlops-training-unsloth) | Unsloth: 2-5x faster LoRA/QLoRA fine-tuning, less VRAM. | | [**whisper**](/user-guide/skills/optional/mlops/mlops-whisper) | OpenAI's general-purpose speech recognition model. Supports 99 languages, transcription, translation to English, and language identification. Six model sizes from tiny (39M params) to large (1550M params). Use for speech-to-text, podcast... | ## payments | Skill | Description | |-------|-------------| | [**mpp-agent**](/user-guide/skills/optional/payments/payments-mpp-agent) | Pay HTTP 402 APIs via Machine Payments Protocol (MPP). | | [**stripe-link-cli**](/user-guide/skills/optional/payments/payments-stripe-link-cli) | Agent payments via Stripe Link — cards, SPT, approvals. | | [**stripe-projects**](/user-guide/skills/optional/payments/payments-stripe-projects) | Provision SaaS services + sync creds via Stripe Projects. | ## productivity | Skill | Description | |-------|-------------| | [**canvas**](/user-guide/skills/optional/productivity/productivity-canvas) | Canvas LMS integration — fetch enrolled courses and assignments using API token authentication. | | [**here.now**](/user-guide/skills/optional/productivity/productivity-here-now) | Publish static sites to {slug}.here.now and store private files in cloud Drives for agent-to-agent handoff. | | [**memento-flashcards**](/user-guide/skills/optional/productivity/productivity-memento-flashcards) | Spaced-repetition flashcard system. Create cards from facts or text, chat with flashcards using free-text answers graded by the agent, generate quizzes from YouTube transcripts, review due cards with adaptive scheduling, and export/impor... | | [**shop**](/user-guide/skills/optional/productivity/productivity-shop) | Shop catalog search, checkout, order tracking, returns. | | [**shopify**](/user-guide/skills/optional/productivity/productivity-shopify) | Shopify Admin & Storefront GraphQL APIs via curl. Products, orders, customers, inventory, metafields. | | [**siyuan**](/user-guide/skills/optional/productivity/productivity-siyuan) | SiYuan Note API for searching, reading, creating, and managing blocks and documents in a self-hosted knowledge base via curl. | | [**telephony**](/user-guide/skills/optional/productivity/productivity-telephony) | Give Claway phone capabilities without core tool changes. Provision and persist a Twilio number, send and receive SMS/MMS, make direct calls, and place AI-driven outbound calls through Bland.ai or Vapi. | ## research | Skill | Description | |-------|-------------| | [**bioinformatics**](/user-guide/skills/optional/research/research-bioinformatics) | Gateway to 400+ bioinformatics skills from bioSkills and ClawBio. Covers genomics, transcriptomics, single-cell, variant calling, pharmacogenomics, metagenomics, structural biology, and more. Fetches domain-specific reference material on... | | [**darwinian-evolver**](/user-guide/skills/optional/research/research-darwinian-evolver) | Evolve prompts/regex/SQL/code with Imbue's evolution loop. | | [**domain-intel**](/user-guide/skills/optional/research/research-domain-intel) | Passive domain reconnaissance using Python stdlib. Subdomain discovery, SSL certificate inspection, WHOIS lookups, DNS records, domain availability checks, and bulk multi-domain analysis. No API keys required. | | [**drug-discovery**](/user-guide/skills/optional/research/research-drug-discovery) | Pharmaceutical research assistant for drug discovery workflows. Search bioactive compounds on ChEMBL, calculate drug-likeness (Lipinski Ro5, QED, TPSA, synthetic accessibility), look up drug-drug interactions via OpenFDA, interpret ADMET... | | [**duckduckgo-search**](/user-guide/skills/optional/research/research-duckduckgo-search) | Free web search via DuckDuckGo — text, news, images, videos. No API key needed. Prefer the `ddgs` CLI when installed; use the Python DDGS library only after verifying that `ddgs` is available in the current runtime. | | [**gitnexus-explorer**](/user-guide/skills/optional/research/research-gitnexus-explorer) | Index a codebase with GitNexus and serve an interactive knowledge graph via web UI + Cloudflare tunnel. | | [**osint-investigation**](/user-guide/skills/optional/research/research-osint-investigation) | Public-records OSINT investigation framework — SEC EDGAR filings, USAspending contracts, Senate lobbying, OFAC sanctions, ICIJ offshore leaks, NYC property records (ACRIS), OpenCorporates registries, CourtListener court records, Wayback... | | [**parallel-cli**](/user-guide/skills/optional/research/research-parallel-cli) | Optional vendor skill for Parallel CLI — agent-native web search, extraction, deep research, enrichment, FindAll, and monitoring. Prefer JSON output and non-interactive flows. | | [**qmd**](/user-guide/skills/optional/research/research-qmd) | Search personal knowledge bases, notes, docs, and meeting transcripts locally using qmd — a hybrid retrieval engine with BM25, vector search, and LLM reranking. Supports CLI and MCP integration. | | [**scrapling**](/user-guide/skills/optional/research/research-scrapling) | Web scraping with Scrapling - HTTP fetching, stealth browser automation, Cloudflare bypass, and spider crawling via CLI and Python. | | [**searxng-search**](/user-guide/skills/optional/research/research-searxng-search) | Free meta-search via SearXNG — aggregates results from 70+ search engines. Self-hosted or use a public instance. No API key needed. Falls back automatically when the web search toolset is unavailable. | ## security | Skill | Description | |-------|-------------| | [**1password**](/user-guide/skills/optional/security/security-1password) | Set up and use 1Password CLI (op). Use when installing the CLI, enabling desktop app integration, signing in, and reading/injecting secrets for commands. | | [**godmode**](/user-guide/skills/optional/security/security-godmode) | Jailbreak LLMs: Parseltongue, GODMODE, ULTRAPLINIAN. | | [**oss-forensics**](/user-guide/skills/optional/security/security-oss-forensics) | Supply chain investigation, evidence recovery, and forensic analysis for GitHub repositories. Covers deleted commit recovery, force-push detection, IOC extraction, multi-source evidence collection, hypothesis formation/validation, and st... | | [**sherlock**](/user-guide/skills/optional/security/security-sherlock) | OSINT username search across 400+ social networks. Hunt down social media accounts by username. | | [**web-pentest**](/user-guide/skills/optional/security/security-web-pentest) | Authorized web application penetration testing — reconnaissance, vulnerability analysis, proof-based exploitation, and professional reporting. Adapts Shannon's "No Exploit, No Report" methodology with hard guardrails for scope, authoriza... | ## software-development | Skill | Description | |-------|-------------| | [**code-wiki**](/user-guide/skills/optional/software-development/software-development-code-wiki) | Generate wiki docs + Mermaid diagrams for any codebase. | | [**rest-graphql-debug**](/user-guide/skills/optional/software-development/software-development-rest-graphql-debug) | Debug REST/GraphQL APIs: status codes, auth, schemas, repro. | | [**subagent-driven-development**](/user-guide/skills/optional/software-development/software-development-subagent-driven-development) | Execute plans via delegate_task subagents (2-stage review). | ## web-development | Skill | Description | |-------|-------------| | [**cloudflare-temporary-deploy**](/user-guide/skills/optional/web-development/web-development-cloudflare-temporary-deploy) | Deploy a Worker live, no account, via wrangler --temporary. | | [**page-agent**](/user-guide/skills/optional/web-development/web-development-page-agent) | Embed alibaba/page-agent into your own web application — a pure-JavaScript in-page GUI agent that ships as a single <script> tag or npm package and lets end-users of your site drive the UI with natural language ("click login, fill userna... | --- ## Contributing Optional Skills To add a new optional skill to the repository: 1. Create a directory under `optional-skills/<category>/<skill-name>/` 2. Add a `SKILL.md` with standard frontmatter (name, description, version, author) 3. Include any supporting files in `references/`, `templates/`, or `scripts/` subdirectories 4. Submit a pull request — the skill will appear in this catalog and get its own docs page once merged --- <!-- source: website/docs/reference/faq.md --> # FAQ & Troubleshooting # FAQ & Troubleshooting Quick answers and fixes for the most common questions and issues. --- ## Frequently Asked Questions ### What LLM providers work with Claway? On a **Claway Box** or **hosted Claway**, the model is already set up for you by Blockway; you do not need a provider account. You can still bring your own: Claway works with any OpenAI-compatible API. Supported providers include: - **[OpenRouter](https://openrouter.ai/)** — access hundreds of models through one API key (recommended for flexibility) - **OpenAI** — GPT-5.4, GPT-5-codex, GPT-4.1, GPT-4o, etc. - **Anthropic** — Claude models (direct API, OAuth via `claway auth add anthropic`, OpenRouter, or any compatible proxy) - **Google** — Gemini models (direct API via `gemini` provider, OpenRouter, or compatible proxy) - **z.ai / ZhipuAI** — GLM models - **Kimi / Moonshot AI** — Kimi models - **MiniMax** — global and China endpoints - **Local models** — via [Ollama](https://ollama.com/), [vLLM](https://docs.vllm.ai/), [llama.cpp](https://github.com/ggerganov/llama.cpp), [SGLang](https://github.com/sgl-project/sglang), or any OpenAI-compatible server Set your provider with `claway model` or by editing `~/.claway/.env`. See the [Environment Variables](./environment-variables.md) reference for all provider keys. ### Where does Claway run? On a **Claway Box** (an appliance on your network) or on a **hosted Claway** server that Blockway runs for you. You use it from your chat apps, the Claway App and the OPS dashboard in a browser. See **[Getting started](/getting-started)**. ### I run Claway in WSL2. What's the best way to control my normal Windows Chrome? Prefer an MCP bridge over `/browser connect`. Recommended pattern: - run Claway inside WSL2 - keep using your normal signed-in Chrome on Windows - add `chrome-devtools-mcp` as an MCP server through `cmd.exe` or `powershell.exe` - let Claway use the resulting MCP browser tools This is more reliable than trying to force Claway core browser transport to attach directly across the WSL2/Windows boundary. See: - [Use MCP with Claway](../guides/use-mcp-with-claway.md#wsl2-bridge-claway-in-wsl-to-windows-chrome) - [Browser Automation](../user-guide/features/browser.md#wsl2--windows-chrome-prefer-mcp-over-browser-connect) ### Is my data sent anywhere? Model calls go to the model provider: on a Claway Box or hosted server, Blockway's model service (which records usage for billing); on a personal install, the provider you configure (for example OpenRouter or your own Ollama). Messages also go to the chat platforms you connect, and tools reach the services they use (web search, for example). Your conversations, memory, knowledge base and skills are stored on the machine Claway runs on: in `/opt/claway` on a Claway Box or hosted server, in `~/.claway/` on a personal install. ### Can I use it offline / with local models? Yes. Run `claway model`, select **Custom endpoint**, and enter your server's URL: ```bash claway model # Select: Custom endpoint (enter URL manually) # API base URL: http://localhost:11434/v1 # API key: ollama # Model name: qwen3.5:27b # Context length: 64000 ← Claway minimum; set this to match your server's actual context window ``` Or configure it directly in `config.yaml`: ```yaml model: default: qwen3.5:27b provider: custom base_url: http://localhost:11434/v1 ``` Claway persists the endpoint, provider, and base URL in `config.yaml` so it survives restarts. If your local server has exactly one model loaded, `/model custom` auto-detects it. You can also set `provider: custom` in config.yaml — it's a first-class provider, not an alias for anything else. This works with Ollama, vLLM, llama.cpp server, SGLang, LocalAI, and others. See the [Configuration guide](../user-guide/configuration.md) for details. :::tip Ollama users If you set a custom `num_ctx` in Ollama (e.g., `ollama run --num_ctx 64000`), make sure to set the matching context length in Claway — Ollama's `/api/show` reports the model's *maximum* context, not the effective `num_ctx` you configured. ::: :::tip Timeouts with local models Claway auto-detects local endpoints and relaxes streaming timeouts (read timeout raised from 120s to 1800s, stale stream detection disabled). If you still hit timeouts on very large contexts, set `CLAWAY_STREAM_READ_TIMEOUT=1800` in your `.env`. See the [Local LLM guide](../guides/local-llm-on-mac.md#timeouts) for details. ::: ### How much does it cost? Claway is licensed from Blockway per Claway Box or hosted server; your Blockway agreement sets the price, including model usage through Blockway's model service. If you bring your own model provider, that provider bills you for its usage. For pricing, contact [support@claway.io](mailto:support@claway.io). ### Can multiple people use one instance? Yes. The [messaging gateway](../user-guide/messaging/index.md) lets multiple users interact with the same Claway Agent instance via Telegram, Discord, Slack, WhatsApp, or Home Assistant. Access is controlled through allowlists (specific user IDs) and DM pairing (first user to message claims access). ### What's the difference between memory and skills? - **Memory** stores **facts** — things the agent knows about you, your projects, and preferences. Memories are retrieved automatically based on relevance. - **Skills** store **procedures** — step-by-step instructions for how to do things. Skills are recalled when the agent encounters a similar task. Both persist across sessions. See [Memory](../user-guide/features/memory.md) and [Skills](../user-guide/features/skills.md) for details. --- ## Troubleshooting ### Provider & Model Issues #### `/model` only shows one provider / can't switch providers **Cause:** `/model` (inside a chat session) can only switch between providers you've **already configured**. If you've only set up OpenRouter, that's all `/model` will show. **Solution:** Exit your session and use `claway model` from your terminal to add new providers: ```bash # Exit the Claway chat session first (Ctrl+C or /quit) # Run the full provider setup wizard claway model # This lets you: add providers, run OAuth, enter API keys, configure endpoints ``` After adding a new provider via `claway model`, start a new chat session — `/model` will now show all your configured providers. :::tip Quick reference | Want to... | Use | |-----------|-----| | Add a new provider | `claway model` (from terminal) | | Enter/change API keys | `claway model` (from terminal) | | Switch model mid-session | `/model <name>` (inside session) | | Switch to different configured provider | `/model provider:model` (inside session) | ::: #### API key not working **Cause:** Key is missing, expired, incorrectly set, or for the wrong provider. **Solution:** ```bash # Check your configuration claway config show # Re-configure your provider claway model # Or set directly claway config set OPENROUTER_API_KEY sk-or-v1-xxxxxxxxxxxx ``` :::warning Make sure the key matches the provider. An OpenAI key won't work with OpenRouter and vice versa. Check `~/.claway/.env` for conflicting entries. ::: #### Model not available / model not found **Cause:** The model identifier is incorrect or not available on your provider. **Solution:** ```bash # List available models for your provider claway model # Set a valid model claway config set CLAWAY_MODEL anthropic/claude-opus-4.7 # Or specify per-session claway chat --model openrouter/meta-llama/llama-3.1-70b-instruct ``` #### Rate limiting (429 errors) **Cause:** You've exceeded your provider's rate limits. **Solution:** Wait a moment and retry. For sustained usage, consider: - Upgrading your provider plan - Switching to a different model or provider - Using `claway chat --provider <alternative>` to route to a different backend #### Context length exceeded **Cause:** The conversation has grown too long for the model's context window, or Claway detected the wrong context length for your model. **Solution:** ```bash # Compress the current session /compress # Or start a fresh session claway chat # Use a model with a larger context window claway chat --model openrouter/google/gemini-3-flash-preview ``` If this happens on the first long conversation, Claway may have the wrong context length for your model. Check what it detected: Look at the CLI startup line — it shows the detected context length (e.g., `📊 Context limit: 128000 tokens`). You can also check with `/usage` during a session. To fix context detection, set it explicitly: ```yaml # In ~/.claway/config.yaml model: default: your-model-name context_length: 131072 # your model's actual context window ``` Or for custom endpoints, add it per-model: ```yaml custom_providers: - name: "My Server" base_url: "http://localhost:11434/v1" models: qwen3.5:27b: context_length: 64000 ``` See [Context Length Detection](../integrations/providers.md#context-length-detection) for how auto-detection works and all override options. --- ### Terminal Issues #### Command blocked as dangerous **Cause:** Claway detected a potentially destructive command (e.g., `rm -rf`, `DROP TABLE`). This is a safety feature. **Solution:** When prompted, review the command and type `y` to approve it. You can also: - Ask the agent to use a safer alternative - See the full list of dangerous patterns in the [Security docs](../user-guide/security.md) :::tip This is working as intended — Claway never silently runs destructive commands. The approval prompt shows you exactly what will execute. ::: #### `sudo` not working via messaging gateway **Cause:** The messaging gateway runs without an interactive terminal, so `sudo` cannot prompt for a password. **Solution:** - Avoid `sudo` in messaging — ask the agent to find alternatives - If you must use `sudo`, configure passwordless sudo for specific commands in `/etc/sudoers` - Or switch to the terminal interface for administrative tasks: `claway chat` #### Docker backend not connecting **Cause:** Docker daemon isn't running or the user lacks permissions. **Solution:** ```bash # Check Docker is running docker info # Add your user to the docker group sudo usermod -aG docker $USER newgrp docker # Verify docker run hello-world ``` --- ### Messaging Issues #### Bot not responding to messages **Cause:** The bot isn't running, isn't authorized, or your user isn't in the allowlist. **Solution:** ```bash # Check if the gateway is running claway gateway status # Start the gateway claway gateway start # Check logs for errors cat ~/.claway/logs/gateway.log | tail -50 ``` #### Messages not delivering **Cause:** Network issues, bot token expired, or platform webhook misconfiguration. **Solution:** - Verify your bot token is valid with `claway gateway setup` - Check gateway logs: `cat ~/.claway/logs/gateway.log | tail -50` - For webhook-based platforms (Slack, WhatsApp), ensure your server is publicly accessible #### Allowlist confusion — who can talk to the bot? **Cause:** Authorization mode determines who gets access. **Solution:** | Mode | How it works | |------|-------------| | **Allowlist** | Only user IDs listed in config can interact | | **DM pairing** | First user to message in DM claims exclusive access | | **Open** | Anyone can interact (not recommended for production) | Configure in `~/.claway/config.yaml` under your gateway's settings. See the [Messaging docs](../user-guide/messaging/index.md). #### Gateway won't start **Cause:** Missing dependencies, port conflicts, or misconfigured tokens. **Solution:** ```bash # Install core messaging gateway dependencies cd ~/.claway/claway && uv pip install -e ".[messaging]" # Telegram, Discord, Slack, and shared gateway deps # Check for port conflicts lsof -i :8080 # Verify configuration claway config show ``` #### WSL: Gateway keeps disconnecting or `claway gateway start` fails **Cause:** WSL's systemd support is unreliable. Many WSL2 installations don't have systemd enabled, and even when enabled, services may not survive WSL restarts or Windows idle shutdowns. **Solution:** Use foreground mode instead of the systemd service: ```bash # Option 1: Direct foreground (simplest) claway gateway run # Option 2: Persistent via tmux (survives terminal close) tmux new -s claway 'claway gateway run' # Reattach later: tmux attach -t claway # Option 3: Background via nohup nohup claway gateway run > ~/.claway/logs/gateway.log 2>&1 & ``` If you want to try systemd anyway, make sure it's enabled: 1. Open `/etc/wsl.conf` (create it if it doesn't exist) 2. Add: ```ini [boot] systemd=true ``` 3. From PowerShell: `wsl --shutdown` 4. Reopen your WSL terminal 5. Verify: `systemctl is-system-running` should say "running" or "degraded" :::tip Auto-start on Windows boot For reliable auto-start, use Windows Task Scheduler to launch WSL + the gateway on login: 1. Create a task that runs `wsl -d Ubuntu -- bash -lc 'claway gateway run'` 2. Set it to trigger on user logon ::: #### macOS: Node.js / ffmpeg / other tools not found by gateway **Cause:** launchd services inherit a minimal PATH (`/usr/bin:/bin:/usr/sbin:/sbin`) that doesn't include Homebrew, nvm, cargo, or other user-installed tool directories. This commonly breaks the WhatsApp bridge (`node not found`) or voice transcription (`ffmpeg not found`). **Solution:** The gateway captures your shell PATH when you run `claway gateway install`. If you installed tools after setting up the gateway, re-run the install to capture the updated PATH: ```bash claway gateway install # Re-snapshots your current PATH claway gateway start # Detects the updated plist and reloads ``` You can verify the plist has the correct PATH: ```bash /usr/libexec/PlistBuddy -c "Print :EnvironmentVariables:PATH" \ ~/Library/LaunchAgents/ai.claway.gateway.plist ``` --- ### Performance Issues #### Slow responses **Cause:** Large model, distant API server, or heavy system prompt with many tools. **Solution:** - Try a faster/smaller model: `claway chat --model openrouter/meta-llama/llama-3.1-8b-instruct` - Reduce active toolsets: `claway chat -t "terminal"` - Check your network latency to the provider - For local models, ensure you have enough GPU VRAM #### High token usage **Cause:** Long conversations, verbose system prompts, or many tool calls accumulating context. **Solution:** ```bash # Compress the conversation to reduce tokens /compress # Check session token usage /usage ``` :::tip Use `/compress` regularly during long sessions. It summarizes the conversation history and reduces token usage significantly while preserving context. ::: #### Session getting too long **Cause:** Extended conversations accumulate messages and tool outputs, approaching context limits. **Solution:** ```bash # Compress current session (preserves key context) /compress # Start a new session with a reference to the old one claway chat # Resume a specific session later if needed claway chat --continue ``` --- ### MCP Issues #### MCP server not connecting **Cause:** Server binary not found, wrong command path, or missing runtime. **Solution:** ```bash # Ensure MCP dependencies are installed (already included in standard install) cd ~/.claway/claway && uv pip install -e ".[mcp]" # For npm-based servers, ensure Node.js is available node --version npx --version # Test the server manually npx -y @modelcontextprotocol/server-filesystem /tmp ``` Verify your `~/.claway/config.yaml` MCP configuration: ```yaml mcp_servers: filesystem: command: "npx" args: ["-y", "@modelcontextprotocol/server-filesystem", "/home/user/docs"] ``` #### Tools not showing up from MCP server **Cause:** Server started but tool discovery failed, tools were filtered out by config, or the server does not support the MCP capability you expected. **Solution:** - Check gateway/agent logs for MCP connection errors - Ensure the server responds to the `tools/list` RPC method - Review any `tools.include`, `tools.exclude`, `tools.resources`, `tools.prompts`, or `enabled` settings under that server - Remember that resource/prompt utility tools are only registered when the session actually supports those capabilities - Use `/reload-mcp` after changing config ```bash # Verify MCP servers are configured claway config show | grep -A 12 mcp_servers # Restart Claway or reload MCP after config changes claway chat ``` See also: - [MCP (Model Context Protocol)](/user-guide/features/mcp) - [Use MCP with Claway](/guides/use-mcp-with-claway) - [MCP Config Reference](/reference/mcp-config-reference) #### MCP timeout errors **Cause:** The MCP server is taking too long to respond, or it crashed during execution. **Solution:** - Increase the timeout in your MCP server config if supported - Check if the MCP server process is still running - For remote HTTP MCP servers, check network connectivity :::warning If an MCP server crashes mid-request, Claway will report a timeout. Check the server's own logs (not just Claway logs) to diagnose the root cause. ::: --- ## Profiles ### How do profiles differ from just setting CLAWAY_HOME? Profiles are a managed layer on top of `CLAWAY_HOME`. You *could* manually set `CLAWAY_HOME=/some/path` before every command, but profiles handle all the plumbing for you: creating the directory structure, generating shell aliases (`claway-work`), tracking the active profile in `~/.claway/active_profile`, and syncing skill updates across all profiles automatically. They also integrate with tab completion so you don't have to remember paths. ### Can two profiles share the same bot token? No. Each messaging platform (Telegram, Discord, etc.) requires exclusive access to a bot token. If two profiles try to use the same token simultaneously, the second gateway will fail to connect. Create a separate bot per profile — for Telegram, talk to [@BotFather](https://t.me/BotFather) to make additional bots. ### Do profiles share memory or sessions? No. Each profile has its own memory store, session database, and skills directory. They are completely isolated. If you want to start a new profile with existing memories and sessions, use `claway profile create newname --clone-all` to copy everything from the current profile, or add `--clone-from <profile>` to copy from a specific source profile. ### What happens to my profiles when Claway is updated? An update installs the new version once for the whole machine (on a Claway Box or hosted server: **OPS → System → Update now**), and every profile on that machine uses it. You never update profiles one by one. ### How many profiles can I run? There is no hard limit. Each profile is just a directory under `~/.claway/profiles/`. The practical limit depends on your disk space and how many concurrent gateways your system can handle (each gateway is a lightweight Python process). Running dozens of profiles is fine; each idle profile uses no resources. --- ## Workflows & Patterns ### Using different models for different tasks (multi-model workflows) **Scenario:** You use GPT-5.4 as your daily driver, but Gemini or Grok writes better social media content. Manually switching models every time is tedious. **Solution: Delegation config.** Claway can route subagents to a different model automatically. Set this in `~/.claway/config.yaml`: ```yaml delegation: model: "google/gemini-3-flash-preview" # subagents use this model provider: "openrouter" # provider for subagents ``` Now when you tell Claway "write me a Twitter thread about X" and it spawns a `delegate_task` subagent, that subagent runs on Gemini instead of your main model. Your primary conversation stays on GPT-5.4. You can also be explicit in your prompt: *"Delegate a task to write social media posts about our product launch. Use your subagent for the actual writing."* The agent will use `delegate_task`, which automatically picks up the delegation config. For one-off model switches without delegation, use `/model` in the CLI: ```bash /model google/gemini-3-flash-preview # switch for this session # ... write your content ... /model openai/gpt-5.4 # switch back ``` See [Subagent Delegation](../user-guide/features/delegation.md) for more on how delegation works. ### Running multiple agents on one WhatsApp number (per-chat binding) **Scenario:** In OpenClaw, you had multiple independent agents bound to specific WhatsApp chats — one for a family shopping list group, another for your private chat. Can Claway do this? **Current limitation:** Claway profiles each require their own WhatsApp number/session. You cannot bind multiple profiles to different chats on the same WhatsApp number — the WhatsApp bridge (Baileys) uses one authenticated session per number. **Workarounds:** 1. **Use a single profile with personality switching.** Create different `AGENTS.md` context files or use the `/personality` command to change behavior per chat. The agent sees which chat it's in and can adapt. 2. **Use cron jobs for specialized tasks.** For a shopping list tracker, set up a cron job that monitors a specific chat and manages the list — no separate agent needed. 3. **Use separate numbers.** If you need truly independent agents, pair each profile with its own WhatsApp number. Virtual numbers from services like Google Voice work for this. 4. **Use Telegram or Discord instead.** These platforms support per-chat binding more naturally — each Telegram group or Discord channel gets its own session, and you can run multiple bot tokens (one per profile) on the same account. See [Profiles](../user-guide/profiles.md) and [WhatsApp setup](../user-guide/messaging/whatsapp.md) for more details. ### Controlling what shows up in Telegram (hiding logs and reasoning) **Scenario:** You see gateway exec logs, Claway reasoning, and tool call details in Telegram instead of just the final output. **Solution:** The `display.tool_progress` setting in `config.yaml` controls how much tool activity is shown: ```yaml display: tool_progress: "off" # options: off, new, all, verbose ``` - **`off`** — Only the final response. No tool calls, no reasoning, no logs. - **`new`** — Shows new tool calls as they happen (brief one-liners). - **`all`** — Shows all tool activity including results. - **`verbose`** — Full detail including tool arguments and outputs. For messaging platforms, `off` or `new` is usually what you want. After editing `config.yaml`, restart the gateway for changes to take effect. You can also toggle this per-session with the `/verbose` command (if enabled): ```yaml display: tool_progress_command: true # enables /verbose in the gateway ``` ### Managing skills on Telegram (slash command limit) **Scenario:** Telegram has a 100 slash command limit, and your skills are pushing past it. You want to disable skills you don't need on Telegram, but `claway skills config` settings don't seem to take effect. **Solution:** Use `claway skills config` to disable skills per-platform. This writes to `config.yaml`: ```yaml skills: disabled: [] # globally disabled skills platform_disabled: telegram: [skill-a, skill-b] # disabled only on telegram ``` After changing this, **restart the gateway** (`claway gateway restart` or kill and relaunch). The Telegram bot command menu rebuilds on startup. :::tip Skills with very long descriptions are truncated to 40 characters in the Telegram menu to stay within payload size limits. If skills aren't appearing, it may be a total payload size issue rather than the 100 command count limit — disabling unused skills helps with both. ::: ### Shared thread sessions (multiple users, one conversation) **Scenario:** You have a Telegram or Discord thread where multiple people mention the bot. You want all mentions in that thread to be part of one shared conversation, not separate per-user sessions. **Current behavior:** Claway creates sessions keyed by user ID on most platforms, so each person gets their own conversation context. This is by design for privacy and context isolation. **Workarounds:** 1. **Use Slack.** Slack sessions are keyed by thread, not by user. Multiple users in the same thread share one conversation — exactly the behavior you're describing. This is the most natural fit. 2. **Use a group chat with a single user.** If one person is the designated "operator" who relays questions, the session stays unified. Others can read along. 3. **Use a Discord channel.** Discord sessions are keyed by channel, so all users in the same channel share context. Use a dedicated channel for the shared conversation. ### Exporting Claway to another machine **Scenario:** You've built up skills, cron jobs, and memories on one machine and want to move everything to a new dedicated Linux box. **Solution:** 1. Set up Claway on the new machine (a new Claway Box, or a hosted server from Blockway; see [Getting started](/getting-started)). 2. On the **source machine**, create a full backup: ```bash claway backup ``` This creates a zip of your entire `~/.claway/` directory — config, API keys, memories, skills, sessions, and profiles — saved to your home directory as `~/claway-backup-<timestamp>.zip`. 3. Copy the zip to the new machine and import it: ```bash # On the source machine scp ~/claway-backup-<timestamp>.zip newmachine:~/ # On the new machine claway import ~/claway-backup-<timestamp>.zip ``` 4. On the new machine, run `claway setup` to verify API keys and provider config are working. ### Moving a single profile to another machine **Scenario:** You want to move or share one specific profile — not your full installation. ```bash # On the source machine claway profile export work ./work-backup.tar.gz # Copy the file to the target machine, then: claway profile import ./work-backup.tar.gz work ``` The imported profile will have all config, memories, sessions, and skills from the export. You may need to update paths or re-authenticate with providers if the new machine has a different setup. ### `claway backup` vs `claway profile export` | Feature | `claway backup` | `claway profile export` | | :--- | :--- | :--- | | **Use Case** | **Full machine migration** | **Porting/sharing a specific profile** | | **Scope** | Global (entire `~/.claway` directory) | Local (single profile directory) | | **Includes** | All profiles, global config, API keys, sessions | Single profile: SOUL.md, memories, sessions, skills | | **Credentials** | **Included** (`.env` and `auth.json`) | **Excluded** (stripped for safe sharing) | | **Format** | `.zip` | `.tar.gz` | **Manual fallback (rsync):** If you prefer to copy files directly, exclude the code repo: ```bash rsync -av --exclude='claway' ~/.claway/ newmachine:~/.claway/ ``` :::tip `claway backup` produces a consistent snapshot even while Claway is actively running. The restored archive excludes machine-local runtime files like `gateway.pid` and `cron.pid`. ::: ### Error 400 on first agent run **Scenario:** Setup completes fine, but the first chat attempt fails with HTTP 400. **Cause:** Usually a model name mismatch — the configured model doesn't exist on your provider, or the API key doesn't have access to it. **Solution:** ```bash # Check what model and provider are configured claway config show | head -20 # Re-run model selection claway model # Or test with a known-good model claway chat -q "hello" --model anthropic/claude-opus-4.7 ``` If using OpenRouter, make sure your API key has credits. A 400 from OpenRouter often means the model requires a paid plan or the model ID has a typo. --- ## Still Stuck? If your issue isn't covered here: 1. **Check the logs:** `claway logs --level WARNING` on the machine, or **OPS → Events** on a Claway Box or hosted Claway 2. **Contact support:** email [support@claway.io](mailto:support@claway.io) with your Claway version (`claway --version`, or **OPS → System**), what you did, and the full error message --- <!-- source: website/docs/developer-guide/context-engine-plugin.md --> # Context Engine Plugins # Building a Context Engine Plugin Context engine plugins replace the built-in `ContextCompressor` with an alternative strategy for managing conversation context. For example, a Lossless Context Management (LCM) engine that builds a knowledge DAG instead of lossy summarization. ## How it works The agent's context management is built on the `ContextEngine` ABC (`agent/context_engine.py`). The built-in `ContextCompressor` is the default implementation. Plugin engines must implement the same interface. Only **one** context engine can be active at a time. Selection is config-driven: ```yaml # config.yaml context: engine: "compressor" # default built-in engine: "lcm" # activates a plugin engine named "lcm" ``` Plugin engines are **never auto-activated** — the user must explicitly set `context.engine` to the plugin's name. ## Directory structure Each context engine lives in `plugins/context_engine/<name>/`: ``` plugins/context_engine/lcm/ ├── __init__.py # exports the ContextEngine subclass ├── plugin.yaml # metadata (name, description, version) └── ... # any other modules your engine needs ``` ## The ContextEngine ABC Your engine must implement these **required** methods: ```python from agent.context_engine import ContextEngine class LCMEngine(ContextEngine): @property def name(self) -> str: """Short identifier, e.g. 'lcm'. Must match config.yaml value.""" return "lcm" def update_from_response(self, usage: dict) -> None: """Called after every LLM call with the usage dict. Update self.last_prompt_tokens, self.last_completion_tokens, self.last_total_tokens from the response. """ def should_compress(self, prompt_tokens: int = None) -> bool: """Return True if compaction should fire this turn.""" def compress(self, messages: list, current_tokens: int = None, focus_topic: str = None) -> list: """Compact the message list and return a new (possibly shorter) list. The returned list must be a valid OpenAI-format message sequence. ``focus_topic`` is an optional topic string from manual ``/compress <focus>``; engines that support guided compression should prioritise preserving information related to it, others may ignore it. """ ``` ### Class attributes your engine must maintain The agent reads these directly for display and logging: ```python last_prompt_tokens: int = 0 last_completion_tokens: int = 0 last_total_tokens: int = 0 threshold_tokens: int = 0 # when compression triggers context_length: int = 0 # model's full context window compression_count: int = 0 # how many times compress() has run ``` ### Optional methods These have sensible defaults in the ABC. Override as needed: | Method | Default | Override when | |--------|---------|--------------| | `on_session_start(session_id, **kwargs)` | No-op | You need to load persisted state (DAG, DB) | | `on_session_end(session_id, messages)` | No-op | You need to flush state, close connections | | `on_session_reset()` | Resets token counters | You have per-session state to clear | | `update_model(model, context_length, ...)` | Updates context_length + threshold | You need to recalculate budgets on model switch | | `get_tool_schemas()` | Returns `[]` | Your engine provides agent-callable tools (e.g., `lcm_grep`) | | `handle_tool_call(name, args, **kwargs)` | Returns error JSON | You implement tool handlers | | `should_compress_preflight(messages)` | Returns `False` | You can do a cheap pre-API-call estimate | | `get_status()` | Standard token/threshold dict | You have custom metrics to expose | ## Engine tools Context engines can expose tools the agent calls directly. Return schemas from `get_tool_schemas()` and handle calls in `handle_tool_call()`: ```python def get_tool_schemas(self): return [{ "name": "lcm_grep", "description": "Search the context knowledge graph", "parameters": { "type": "object", "properties": { "query": {"type": "string", "description": "Search query"} }, "required": ["query"], }, }] def handle_tool_call(self, name, args, **kwargs): if name == "lcm_grep": results = self._search_dag(args["query"]) return json.dumps({"results": results}) return json.dumps({"error": f"Unknown tool: {name}"}) ``` Engine tools are injected into the agent's tool list at startup and dispatched automatically — no registry registration needed. ## Registration ### Via directory (recommended) Place your engine in `plugins/context_engine/<name>/`. The `__init__.py` must export a `ContextEngine` subclass. The discovery system finds and instantiates it automatically. ### Via general plugin system A general plugin can also register a context engine: ```python def register(ctx): engine = LCMEngine(context_length=200000) ctx.register_context_engine(engine) ``` Only one engine can be registered. A second plugin attempting to register is rejected with a warning. ## Lifecycle ``` 1. Engine instantiated (plugin load or directory discovery) 2. on_session_start() — conversation begins 3. update_from_response() — after each API call 4. should_compress() — checked each turn 5. compress() — called when should_compress() returns True 6. on_session_end() — session boundary (CLI exit, /reset, gateway expiry) ``` `on_session_reset()` is called on `/new` or `/reset` to clear per-session state without a full shutdown. ## Configuration Users select your engine via `claway plugins` → Provider Plugins → Context Engine, or by editing `config.yaml`: ```yaml context: engine: "lcm" # must match your engine's name property ``` The `compression` config block (`compression.threshold`, `compression.protect_last_n`, etc.) is specific to the built-in `ContextCompressor`. Your engine should define its own config format if needed, reading from `config.yaml` during initialization. ## Testing ```python from agent.context_engine import ContextEngine def test_engine_satisfies_abc(): engine = YourEngine(context_length=200000) assert isinstance(engine, ContextEngine) assert engine.name == "your-name" def test_compress_returns_valid_messages(): engine = YourEngine(context_length=200000) msgs = [{"role": "user", "content": "hello"}] result = engine.compress(msgs) assert isinstance(result, list) assert all("role" in m for m in result) ``` See `tests/agent/test_context_engine.py` for the full ABC contract test suite. ## See also - Context Compression and Caching — how the built-in compressor works - [Memory Provider Plugins](/developer-guide/memory-provider-plugin) — analogous single-select plugin system for memory - [Plugins](/user-guide/features/plugins) — general plugin system overview --- <!-- source: website/docs/developer-guide/creating-skills.md --> # Creating Skills # Creating Skills Skills are the preferred way to add new capabilities to Claway Agent. They're easier to create than tools, require no code changes to the agent, and can be shared with the community. ## Should it be a Skill or a Tool? Make it a **Skill** when: - The capability can be expressed as instructions + shell commands + existing tools - It wraps an external CLI or API that the agent can call via `terminal` or `web_extract` - It doesn't need custom Python integration or API key management baked into the agent - Examples: arXiv search, git workflows, Docker management, PDF processing, email via CLI tools Make it a **Tool** when: - It requires end-to-end integration with API keys, auth flows, or multi-component configuration - It needs custom processing logic that must execute precisely every time - It handles binary data, streaming, or real-time events - Examples: browser automation, TTS, vision analysis ## Skill Directory Structure Bundled skills live in `skills/` organized by category. Official optional skills use the same structure in `optional-skills/`: ```text skills/ ├── research/ │ └── arxiv/ │ ├── SKILL.md # Required: main instructions │ └── scripts/ # Optional: helper scripts │ └── search_arxiv.py ├── productivity/ │ └── ocr-and-documents/ │ ├── SKILL.md │ ├── scripts/ │ └── references/ └── ... ``` ## SKILL.md Format ```markdown --- name: my-skill description: Brief description (shown in skill search results) version: 1.0.0 author: Your Name license: MIT platforms: [macos, linux] # Optional — restrict to specific OS platforms # Valid: macos, linux, windows # Omit to load on all platforms (default) metadata: claway: tags: [Category, Subcategory, Keywords] related_skills: [other-skill-name] requires_toolsets: [web] # Optional — only show when these toolsets are active requires_tools: [web_search] # Optional — only show when these tools are available fallback_for_toolsets: [browser] # Optional — hide when these toolsets are active fallback_for_tools: [browser_navigate] # Optional — hide when these tools exist config: # Optional — config.yaml settings the skill needs - key: my.setting description: "What this setting controls" default: "sensible-default" prompt: "Display prompt for setup" blueprint: # Optional — marks this skill a runnable automation schedule: "0 9 * * *" # cron expr / "every 2h" / ISO timestamp deliver: origin # optional (default origin) prompt: "Task instruction for each run" # optional no_agent: false # optional required_environment_variables: # Optional — env vars the skill needs - name: MY_API_KEY prompt: "Enter your API key" help: "Get one at https://example.com" required_for: "API access" --- # Skill Title Brief intro. ## When to Use Trigger conditions — when should the agent load this skill? ## Quick Reference Table of common commands or API calls. ## Procedure Step-by-step instructions the agent follows. ## Pitfalls Known failure modes and how to handle them. ## Verification How the agent confirms it worked. ``` ### Platform-Specific Skills Skills can restrict themselves to specific operating systems using the `platforms` field: ```yaml platforms: [macos] # macOS only (e.g., iMessage, Apple Reminders) platforms: [macos, linux] # macOS and Linux platforms: [windows] # Windows only ``` When set, the skill is automatically hidden from the system prompt, `skills_list()`, and slash commands on incompatible platforms. If omitted or empty, the skill loads on all platforms (backward compatible). ### Conditional Skill Activation Skills can declare dependencies on specific tools or toolsets. This controls whether the skill appears in the system prompt for a given session. ```yaml metadata: claway: requires_toolsets: [web] # Hide if the web toolset is NOT active requires_tools: [web_search] # Hide if web_search tool is NOT available fallback_for_toolsets: [browser] # Hide if the browser toolset IS active fallback_for_tools: [browser_navigate] # Hide if browser_navigate IS available ``` | Field | Behavior | |-------|----------| | `requires_toolsets` | Skill is **hidden** when ANY listed toolset is **not** available | | `requires_tools` | Skill is **hidden** when ANY listed tool is **not** available | | `fallback_for_toolsets` | Skill is **hidden** when ANY listed toolset **is** available | | `fallback_for_tools` | Skill is **hidden** when ANY listed tool **is** available | **Use case for `fallback_for_*`:** Create a skill that serves as a workaround when a primary tool isn't available. For example, a `duckduckgo-search` skill with `fallback_for_tools: [web_search]` only shows when the web search tool (which requires an API key) is not configured. **Use case for `requires_*`:** Create a skill that only makes sense when certain tools are present. For example, a web scraping workflow skill with `requires_toolsets: [web]` won't clutter the prompt when web tools are disabled. ### Environment Variable Requirements Skills can declare environment variables they need. When a skill is loaded via `skill_view`, its required vars are automatically registered for passthrough into sandboxed execution environments (terminal, execute_code). ```yaml required_environment_variables: - name: TENOR_API_KEY prompt: "Tenor API key" # Shown when prompting user help: "Get your key at https://tenor.com" # Help text or URL required_for: "GIF search functionality" # What needs this var ``` Each entry supports: - `name` (required) — the environment variable name - `prompt` (optional) — prompt text when asking the user for the value - `help` (optional) — help text or URL for obtaining the value - `required_for` (optional) — describes which feature needs this variable Users can also manually configure passthrough variables in `config.yaml`: ```yaml terminal: env_passthrough: - MY_CUSTOM_VAR - ANOTHER_VAR ``` See `skills/apple/` for examples of macOS-only skills. ## Secure Setup on Load Use `required_environment_variables` when a skill needs an API key or token. Missing values do **not** hide the skill from discovery. Instead, Claway prompts for them securely when the skill is loaded in the local CLI. ```yaml required_environment_variables: - name: TENOR_API_KEY prompt: Tenor API key help: Get a key from https://developers.google.com/tenor required_for: full functionality ``` The user can skip setup and keep loading the skill. Claway never exposes the raw secret value to the model. Gateway and messaging sessions show local setup guidance instead of collecting secrets in-band. :::tip Sandbox Passthrough When your skill is loaded, any declared `required_environment_variables` that are set are **automatically passed through** to `execute_code` and `terminal` sandboxes — including remote backends like Docker and Modal. Your skill's scripts can access `$TENOR_API_KEY` (or `os.environ["TENOR_API_KEY"]` in Python) without the user needing to configure anything extra. See [Environment Variable Passthrough](/user-guide/security#environment-variable-passthrough) for details. ::: Legacy `prerequisites.env_vars` remains supported as a backward-compatible alias. ### Config Settings (config.yaml) Skills can declare non-secret settings that are stored in `config.yaml` under the `skills.config` namespace. Unlike environment variables (which are secrets stored in `.env`), config settings are for paths, preferences, and other non-sensitive values. ```yaml metadata: claway: config: - key: myplugin.path description: Path to the plugin data directory default: "~/myplugin-data" prompt: Plugin data directory path - key: myplugin.domain description: Domain the plugin operates on default: "" prompt: Plugin domain (e.g., AI/ML research) ``` Each entry supports: - `key` (required) — dotpath for the setting (e.g., `myplugin.path`) - `description` (required) — explains what the setting controls - `default` (optional) — default value if the user doesn't configure it - `prompt` (optional) — prompt text shown during `claway config migrate`; falls back to `description` **How it works:** 1. **Storage:** Values are written to `config.yaml` under `skills.config.<key>`: ```yaml skills: config: myplugin: path: ~/my-data ``` 2. **Discovery:** `claway config migrate` scans all enabled skills, finds unconfigured settings, and prompts the user. Settings also appear in `claway config show` under "Skill Settings." 3. **Runtime injection:** When a skill loads, its config values are resolved and appended to the skill message: ``` [Skill config (from ~/.claway/config.yaml): myplugin.path = /home/user/my-data ] ``` The agent sees the configured values without needing to read `config.yaml` itself. 4. **Manual setup:** Users can also set values directly: ```bash claway config set skills.config.myplugin.path ~/my-data ``` :::tip When to use which Use `required_environment_variables` for API keys, tokens, and other **secrets** (stored in `~/.claway/.env`, never shown to the model). Use `config` for **paths, preferences, and non-sensitive settings** (stored in `config.yaml`, visible in config show). ::: ### Credential File Requirements (OAuth tokens, etc.) Skills that use OAuth or file-based credentials can declare files that need to be mounted into remote sandboxes. This is for credentials stored as **files** (not env vars) — typically OAuth token files produced by a setup script. ```yaml required_credential_files: - path: google_token.json description: Google OAuth2 token (created by setup script) - path: google_client_secret.json description: Google OAuth2 client credentials ``` Each entry supports: - `path` (required) — file path relative to `~/.claway/` - `description` (optional) — explains what the file is and how it's created When loaded, Claway checks if these files exist. Missing files trigger `setup_needed`. Existing files are automatically: - **Mounted into Docker** containers as read-only bind mounts - **Synced into Modal** sandboxes (at creation + before each command, so mid-session OAuth works) - Available on **local** backend without any special handling :::tip When to use which Use `required_environment_variables` for simple API keys and tokens (strings stored in `~/.claway/.env`). Use `required_credential_files` for OAuth token files, client secrets, service account JSON, certificates, or any credential that's a file on disk. ::: See the `skills/productivity/google-workspace/SKILL.md` for a complete example using both. ## Skill Guidelines ### No External Dependencies Prefer stdlib Python, curl, and existing Claway tools (`web_extract`, `terminal`, `read_file`). If a dependency is needed, document installation steps in the skill. ### Progressive Disclosure Put the most common workflow first. Edge cases and advanced usage go at the bottom. This keeps token usage low for common tasks. ### Include Helper Scripts For XML/JSON parsing or complex logic, include helper scripts in `scripts/` — don't expect the LLM to write parsers inline every time. ### Deliver media as documents (`[[as_document]]`) If your skill produces a high-resolution screenshot, chart, or any image where lossy preview compression would hurt — emit the literal directive `[[as_document]]` somewhere in the response (commonly the last line). The gateway strips the directive and delivers every extracted media path in that response as a downloadable file attachment instead of an inline image bubble. See [Skill output and media delivery](../user-guide/features/skills.md#skill-output-and-media-delivery) for the full semantics. #### Referencing bundled scripts from SKILL.md When a skill is loaded, the activation message exposes the absolute skill directory as `[Skill directory: /abs/path]` and also substitutes two template tokens anywhere in the SKILL.md body: | Token | Replaced with | |---|---| | `${CLAWAY_SKILL_DIR}` | Absolute path to the skill's directory | | `${CLAWAY_SESSION_ID}` | The active session id (left in place if there is no session) | So a SKILL.md can tell the agent to run a bundled script directly with: ```markdown To analyse the input, run: node ${CLAWAY_SKILL_DIR}/scripts/analyse.js <input> ``` The agent sees the substituted absolute path and invokes the `terminal` tool with a ready-to-run command — no path math, no extra `skill_view` round-trip. Disable substitution globally with `skills.template_vars: false` in `config.yaml`. #### Inline shell snippets (opt-in) Skills can also embed inline shell snippets written as `` !`cmd` `` in the SKILL.md body. When enabled, each snippet's stdout is inlined into the message before the agent reads it, so skills can inject dynamic context: ```markdown Current date: !`date -u +%Y-%m-%d` Git branch: !`git -C ${CLAWAY_SKILL_DIR} rev-parse --abbrev-ref HEAD` ``` This is **off by default** — any snippet in a SKILL.md runs on the host without approval, so only enable it for skill sources you trust: ```yaml # config.yaml skills: inline_shell: true inline_shell_timeout: 10 # seconds per snippet ``` Snippets run with the skill directory as their working directory, and output is capped at 4000 characters. Failures (timeouts, non-zero exits) show up as a short `[inline-shell error: ...]` marker instead of breaking the whole skill. ### Test It Run the skill and verify the agent follows the instructions correctly: ```bash claway chat --toolsets skills -q "Use the X skill to do Y" ``` ## Where Should the Skill Live? Bundled skills (in `skills/`) ship with every Claway install. They should be **broadly useful to most users**: - Document handling, web research, common dev workflows, system administration - Used regularly by a wide range of people If your skill is official and useful but not universally needed (e.g., a paid service integration, a heavyweight dependency), put it in **`optional-skills/`** — it ships with the repo, is discoverable via `claway skills browse` (labeled "official"), and installs with built-in trust. If your skill is specialized, community-contributed, or niche, it's better suited for a **Skills Hub** — upload it to a registry and share it via `claway skills install`. ## Blueprints: skills that are also automations A **blueprint** is an ordinary skill that additionally declares a schedule in its frontmatter. Add a `metadata.claway.blueprint` block and the skill becomes a shareable, runnable automation: ```yaml metadata: claway: tags: [blueprint, email] blueprint: schedule: "0 8 * * *" # presence of `blueprint:` marks it runnable deliver: telegram # optional (default: origin) prompt: "Summarize my unread email and today's calendar." # optional no_agent: false # optional ``` Because a blueprint **is** a skill, it flows through the entire skills pipeline unchanged — search, inspect, install, security scan, provenance, taps, the centralized index, and `claway skills publish` for sharing. Nothing new to learn. **Installing a blueprint.** When you install a skill that carries a `blueprint:` block, Claway registers it as a **suggested cron job** rather than scheduling it. Scheduling is **opt-in** — installing never silently creates a recurring job. You review and accept it via `/suggestions`: ```bash claway skills install owner/morning-brief # → Blueprint: 'morning-brief' is an automation (schedule 0 8 * * *). # Added to your suggestions — run /suggestions to schedule or dismiss it. # then, in a session: /suggestions # lists pending suggestions, numbered /suggestions accept 1 # creates the cron job /suggestions dismiss 1 # never offer it again ``` Blueprints are one **source** of the unified Suggested Cron Jobs surface — the same place curated starter automations and (later) usage-pattern and integration suggestions appear. See [Suggested Cron Jobs](#suggested-cron-jobs) below. **Sharing an automation you built.** A blueprint loaded by a cron job (`claway cron create --skill <name> ...`) can be exported back to a SKILL.md and published like any other skill, so an automation you tuned for yourself becomes a one-command install for someone else. The blueprint layer adds no new object type, store, or transport — the blueprint is a skill, the schedule is a cron job, and sharing is the existing publish/tap/index path. ## Suggested Cron Jobs Claway can *propose* automations and let you accept them with one tap, instead of making you assemble cron jobs by hand. Every proposal flows through one surface — the `/suggestions` command — regardless of where it came from: | Source | Trigger | |--------|---------| | `catalog` | Curated starter automations (`/suggestions catalog`) — daily briefing, important-mail monitor, weekly review, workday-start reminder | | `blueprint` | You installed a skill carrying a `blueprint:` block | | `usage` | The background review noticed a recurring ask a schedule would serve | | `integration` | You connected an account (Gmail, GitHub, ...) and the obvious automations are offered | ```bash /suggestions # list pending /suggestions accept N # schedule suggestion N (creates the cron job) /suggestions dismiss N # dismiss it — latched, never re-offered /suggestions catalog # add the curated starter automations ``` Accepting a suggestion calls the same `cron.jobs.create_job` the `cronjob` tool uses — there is no second job engine. Suggestions **never** auto-create jobs; acceptance is always explicit. Dismissed suggestions latch by a stable key so the same proposal is never re-offered. The pending list is capped so it never becomes a nag wall. The **important-mail monitor** catalog entry is the poll→classify→surface pattern: it scores inbox items with a cheap classifier model (`auxiliary.monitor` in `config.yaml`) and delivers only the ones above an urgency threshold, staying silent otherwise. ## Publishing Skills ### To the Skills Hub ```bash claway skills publish skills/my-skill --to github --repo owner/repo ``` ### To a Custom Repository Add your repo as a tap: ```bash claway skills tap add owner/repo ``` Users can then search and install from your repository. ## Security Scanning All hub-installed skills go through a security scanner that checks for: - Data exfiltration patterns - Prompt injection attempts - Destructive commands - Shell injection Trust levels: - `builtin` — ships with Claway (always trusted) - `official` — from `optional-skills/` in the repo (built-in trust, no third-party warning) - `trusted` — from openai/skills, anthropics/skills, huggingface/skills - `community` — non-dangerous findings can be overridden with `--force`; `dangerous` verdicts remain blocked Claway can now consume third-party skills from multiple external discovery models: - direct GitHub identifiers (for example `openai/skills/k8s`) - `skills.sh` identifiers (for example `skills-sh/vercel-labs/json-render/json-render-react`) - well-known endpoints served from `/.well-known/skills/index.json` If you want your skills to be discoverable without a GitHub-specific installer, consider serving them from a well-known endpoint in addition to publishing them in a repo or marketplace. --- <!-- source: website/docs/developer-guide/image-gen-provider-plugin.md --> # Image Generation Provider Plugins # Building an Image Generation Provider Plugin Image-gen provider plugins register a backend that services every `image_generate` tool call — DALL·E, gpt-image, Grok, Flux, Imagen, Stable Diffusion, fal, Replicate, a local ComfyUI rig, anything. Built-in providers (OpenAI, OpenAI-Codex, xAI) all ship as plugins. You can add a new one, or override a bundled one, by dropping a directory into `plugins/image_gen/<name>/`. :::tip Image-gen is one of several **backend plugins** Claway supports. The others (with more specialized ABCs) are [Memory Provider Plugins](/developer-guide/memory-provider-plugin), [Context Engine Plugins](/developer-guide/context-engine-plugin), and [Model Provider Plugins](/developer-guide/model-provider-plugin). General tool/hook/CLI plugins live in [Build a Claway Plugin](/guides/build-a-claway-plugin). ::: ## How discovery works Claway scans for image-gen backends in three places: 1. **Bundled** — `<repo>/plugins/image_gen/<name>/` (auto-loaded with `kind: backend`, always available) 2. **User** — `~/.claway/plugins/image_gen/<name>/` (opt-in via `plugins.enabled`) 3. **Pip** — packages declaring a `claway_agent.plugins` entry point Each plugin's `register(ctx)` function calls `ctx.register_image_gen_provider(...)` — that puts it into the registry in `agent/image_gen_registry.py`. The active provider is picked by `image_gen.provider` in `config.yaml`; `claway tools` walks users through selection. The `image_generate` tool wrapper asks the registry for the active provider and dispatches there. If no provider is registered, the tool surfaces a helpful error pointing at `claway tools`. ## Directory structure ``` plugins/image_gen/my-backend/ ├── __init__.py # ImageGenProvider subclass + register() └── plugin.yaml # Manifest with kind: backend ``` A bundled plugin is complete at this point. User plugins at `~/.claway/plugins/image_gen/<name>/` need to be added to `plugins.enabled` in `config.yaml` (or run `claway plugins enable <name>`). ## The ImageGenProvider ABC Subclass `agent.image_gen_provider.ImageGenProvider`. The only required members are the `name` property and the `generate()` method — everything else has sane defaults: ```python # plugins/image_gen/my-backend/__init__.py from typing import Any, Dict, List, Optional import os from agent.image_gen_provider import ( DEFAULT_ASPECT_RATIO, ImageGenProvider, error_response, normalize_reference_images, resolve_aspect_ratio, save_b64_image, success_response, ) class MyBackendImageGenProvider(ImageGenProvider): @property def name(self) -> str: # Stable id used in image_gen.provider config. Lowercase, no spaces. return "my-backend" @property def display_name(self) -> str: # Human label shown in `claway tools`. Defaults to name.title() if omitted. return "My Backend" def is_available(self) -> bool: # Return False if credentials or deps are missing. # The tool's availability gate calls this before dispatch. if not os.environ.get("MY_BACKEND_API_KEY"): return False try: import my_backend_sdk # noqa: F401 except ImportError: return False return True def list_models(self) -> List[Dict[str, Any]]: # Catalog shown in `claway tools` model picker. return [ { "id": "my-model-fast", "display": "My Model (Fast)", "speed": "~5s", "strengths": "Quick iteration", "price": "$0.01/image", }, { "id": "my-model-hq", "display": "My Model (HQ)", "speed": "~30s", "strengths": "Highest fidelity", "price": "$0.04/image", }, ] def default_model(self) -> Optional[str]: return "my-model-fast" def get_setup_schema(self) -> Dict[str, Any]: # Metadata for the `claway tools` picker — keys to prompt for at setup. return { "name": "My Backend", "badge": "paid", # optional; shown as a short tag in the picker "tag": "One-line description shown under the name", "env_vars": [ { "key": "MY_BACKEND_API_KEY", "prompt": "My Backend API key", "url": "https://my-backend.example.com/api-keys", }, ], } def capabilities(self) -> Dict[str, Any]: # Declare whether this backend supports image-to-image / editing. # The tool layer surfaces this in the dynamic schema so the model # knows when `image_url` is honored. Default (if you omit this) is # text-only: {"modalities": ["text"], "max_reference_images": 0}. return {"modalities": ["text", "image"], "max_reference_images": 4} def generate( self, prompt: str, aspect_ratio: str = DEFAULT_ASPECT_RATIO, *, image_url: Optional[str] = None, reference_image_urls: Optional[List[str]] = None, **kwargs: Any, ) -> Dict[str, Any]: prompt = (prompt or "").strip() aspect_ratio = resolve_aspect_ratio(aspect_ratio) if not prompt: return error_response( error="Prompt is required", error_type="invalid_input", provider=self.name, prompt="", aspect_ratio=aspect_ratio, ) # Routing: if image_url (or reference_image_urls) is set, the call is # an image-to-image / edit request; otherwise text-to-image. Report # which path you took via the `modality` field of success_response. sources = [] if image_url: sources.append(image_url) sources.extend(normalize_reference_images(reference_image_urls) or []) modality = "image" if sources else "text" # Model selection precedence: env var → config → default. The helper # _resolve_model() in the built-in openai plugin is a good reference. model_id = kwargs.get("model") or self.default_model() or "my-model-fast" try: import my_backend_sdk client = my_backend_sdk.Client(api_key=os.environ["MY_BACKEND_API_KEY"]) if modality == "image": result = client.edit( prompt=prompt, model=model_id, image_urls=sources, ) else: result = client.generate( prompt=prompt, model=model_id, aspect_ratio=aspect_ratio, ) # Two shapes supported: # - URL string: return it as `image` # - base64 data: save under $CLAWAY_HOME/cache/images/ via save_b64_image() if result.get("image_b64"): path = save_b64_image( result["image_b64"], prefix=self.name, extension="png", ) image = str(path) else: image = result["image_url"] return success_response( image=image, model=model_id, prompt=prompt, aspect_ratio=aspect_ratio, provider=self.name, modality=modality, ) except Exception as exc: return error_response( error=str(exc), error_type=type(exc).__name__, provider=self.name, model=model_id, prompt=prompt, aspect_ratio=aspect_ratio, ) def register(ctx) -> None: """Plugin entry point — called once at load time.""" ctx.register_image_gen_provider(MyBackendImageGenProvider()) ``` ## plugin.yaml ```yaml name: my-backend version: 1.0.0 description: My image backend — text-to-image via My Backend SDK author: Your Name kind: backend requires_env: - MY_BACKEND_API_KEY ``` `kind: backend` is what routes the plugin to the image-gen registration path. `requires_env` is prompted during `claway plugins install`. ## ABC reference Full contract in `agent/image_gen_provider.py`. The methods you'll typically override: | Member | Required | Default | Purpose | |---|---|---|---| | `name` | ✅ | — | Stable id used in `image_gen.provider` config | | `display_name` | — | `name.title()` | Label shown in `claway tools` | | `is_available()` | — | `True` | Gate for missing creds/deps | | `list_models()` | — | `[]` | Catalog for `claway tools` model picker | | `default_model()` | — | first from `list_models()` | Fallback when no model is configured | | `get_setup_schema()` | — | minimal | Picker metadata + env-var prompts | | `generate(prompt, aspect_ratio, **kwargs)` | ✅ | — | The call | ## Response format `generate()` must return a dict built via `success_response()` or `error_response()`. Both live in `agent/image_gen_provider.py`. **Success:** ```python success_response( image=<url-or-absolute-path>, model=<model-id>, prompt=<echoed-prompt>, aspect_ratio="landscape" | "square" | "portrait", provider=<your-provider-name>, extra={...}, # optional backend-specific fields ) ``` **Error:** ```python error_response( error="human-readable message", error_type="provider_error" | "invalid_input" | "<exception class name>", provider=<your-provider-name>, model=<model-id>, prompt=<prompt>, aspect_ratio=<resolved aspect>, ) ``` The tool wrapper JSON-serializes the dict and hands it to the LLM. Errors are surfaced as the tool result; the LLM decides how to explain them to the user. ## Handling base64 vs URL output Some backends return image URLs (fal, Replicate); others return base64 payloads (OpenAI gpt-image-2). For the base64 case, use `save_b64_image()` — it writes to `$CLAWAY_HOME/cache/images/<prefix>_<timestamp>_<uuid>.<ext>` and returns the absolute `Path`. Pass that path (as `str`) as `image=` in `success_response()`. Gateway delivery (Telegram photo bubble, Discord attachment) recognizes both URLs and absolute paths. ## User overrides Drop a user plugin at `~/.claway/plugins/image_gen/<name>/` with the same `name` property as a bundled one and enable it via `claway plugins enable <name>` — the registry is last-writer-wins, so your version replaces the built-in. Useful for pointing an `openai` plugin at a private proxy, or swapping in a custom model catalog. ## Testing ```bash export CLAWAY_HOME=/tmp/claway-imggen-test mkdir -p $CLAWAY_HOME/plugins/image_gen/my-backend # …copy __init__.py + plugin.yaml into that dir… export MY_BACKEND_API_KEY=your-test-key claway plugins enable my-backend # Pick it as the active provider echo "image_gen:" >> $CLAWAY_HOME/config.yaml echo " provider: my-backend" >> $CLAWAY_HOME/config.yaml # Exercise it claway -z "Generate an image of a corgi in a spacesuit" ``` Or interactively: `claway tools` → "Image Generation" → select `my-backend` → enter API key if prompted. ## Reference implementations - **`plugins/image_gen/openai/__init__.py`** — gpt-image-2 at low/medium/high tiers as three virtual model IDs sharing one API model with different `quality` params. Good example of tiered models under a single backend + config.yaml precedence chain. - **`plugins/image_gen/xai/__init__.py`** — Grok Imagine via xAI. Different shape (URL output, simpler catalog). - **`plugins/image_gen/openai-codex/__init__.py`** — Codex-style Responses API variant reusing the OpenAI SDK with a different routing base URL. ## Distribute via pip ```toml # pyproject.toml [project.entry-points."claway_agent.plugins"] my-backend-imggen = "my_backend_imggen_package" ``` `my_backend_imggen_package` must expose a top-level `register` function. See [Distribute via pip](/guides/build-a-claway-plugin#distribute-via-pip) in the general plugin guide for the full setup. ## Related pages - [Image Generation](/user-guide/features/image-generation) — user-facing feature documentation - [Plugins overview](/user-guide/features/plugins) — all plugin types at a glance - [Build a Claway Plugin](/guides/build-a-claway-plugin) — general tools/hooks/slash commands guide --- <!-- source: website/docs/developer-guide/memory-provider-plugin.md --> # Memory Provider Plugins # Building a Memory Provider Plugin Memory provider plugins give Claway Agent persistent, cross-session knowledge beyond the built-in MEMORY.md and USER.md. This guide covers how to build one. :::tip Memory providers are one of two **provider plugin** types. The other is [Context Engine Plugins](/developer-guide/context-engine-plugin), which replace the built-in context compressor. Both follow the same pattern: single-select, config-driven, managed via `claway plugins`. ::: ## Directory Structure Each memory provider lives in `plugins/memory/<name>/`: ``` plugins/memory/my-provider/ ├── __init__.py # MemoryProvider implementation + register() entry point ├── plugin.yaml # Metadata (name, description, hooks) └── README.md # Setup instructions, config reference, tools ``` ## The MemoryProvider ABC Your plugin implements the `MemoryProvider` abstract base class from `agent/memory_provider.py`: ```python from agent.memory_provider import MemoryProvider class MyMemoryProvider(MemoryProvider): @property def name(self) -> str: return "my-provider" def is_available(self) -> bool: """Check if this provider can activate. NO network calls.""" return bool(os.environ.get("MY_API_KEY")) def initialize(self, session_id: str, **kwargs) -> None: """Called once at agent startup. kwargs always includes: claway_home (str): Active CLAWAY_HOME path. Use for storage. """ self._api_key = os.environ.get("MY_API_KEY", "") self._session_id = session_id # ... implement remaining methods ``` ## Required Methods ### Core Lifecycle | Method | When Called | Must Implement? | |--------|-----------|-----------------| | `name` (property) | Always | **Yes** | | `is_available()` | Agent init, before activation | **Yes** — no network calls | | `initialize(session_id, **kwargs)` | Agent startup | **Yes** | | `get_tool_schemas()` | After init, for tool injection | **Yes** | | `handle_tool_call(tool_name, args, **kwargs)` | When agent uses your tools | **Yes** (if you have tools) | ### Config | Method | Purpose | Must Implement? | |--------|---------|-----------------| | `get_config_schema()` | Declare config fields for `claway memory setup` | **Yes** | | `save_config(values, claway_home)` | Write non-secret config to native location | **Yes** (unless env-var-only) | ### Optional Hooks | Method | When Called | Use Case | |--------|-----------|----------| | `system_prompt_block()` | System prompt assembly | Static provider info | | `prefetch(query, *, session_id="")` | Before each API call | Return recalled context | | `queue_prefetch(query)` | After each turn | Pre-warm for next turn | | `sync_turn(user, assistant, *, session_id="")` | After each completed turn | Persist conversation | | `on_session_end(messages)` | Conversation ends | Final extraction/flush | | `on_pre_compress(messages)` | Before context compression | Save insights before discard | | `on_memory_write(action, target, content)` | Built-in memory writes | Mirror to your backend | | `shutdown()` | Process exit | Clean up connections | ## Config Schema `get_config_schema()` returns a list of field descriptors used by `claway memory setup`: ```python def get_config_schema(self): return [ { "key": "api_key", "description": "My Provider API key", "secret": True, # → written to .env "required": True, "env_var": "MY_API_KEY", # explicit env var name "url": "https://my-provider.com/keys", # where to get it }, { "key": "region", "description": "Server region", "default": "us-east", "choices": ["us-east", "eu-west", "ap-south"], }, { "key": "project", "description": "Project identifier", "default": "claway", }, ] ``` Fields with `secret: True` and `env_var` go to `.env`. Non-secret fields are passed to `save_config()`. :::tip Minimal vs Full Schema Every field in `get_config_schema()` is prompted during `claway memory setup`. Providers with many options should keep the schema minimal — only include fields the user **must** configure (API key, required credentials). Document optional settings in a config file reference (e.g. `$CLAWAY_HOME/myprovider.json`) rather than prompting for them all during setup. This keeps the setup wizard fast while still supporting advanced configuration. See the Supermemory provider for an example — it only prompts for the API key; all other options live in `supermemory.json`. ::: ## Save Config ```python def save_config(self, values: dict, claway_home: str) -> None: """Write non-secret config to your native location.""" import json from pathlib import Path config_path = Path(claway_home) / "my-provider.json" config_path.write_text(json.dumps(values, indent=2)) ``` For env-var-only providers, leave the default no-op. ## Plugin Entry Point ```python def register(ctx) -> None: """Called by the memory plugin discovery system.""" ctx.register_memory_provider(MyMemoryProvider()) ``` ## plugin.yaml ```yaml name: my-provider version: 1.0.0 description: "Short description of what this provider does." hooks: - on_session_end # list hooks you implement ``` ## Threading Contract **`sync_turn()` MUST be non-blocking.** If your backend has latency (API calls, LLM processing), run the work in a daemon thread: ```python def sync_turn(self, user_content, assistant_content, *, session_id="", messages=None): def _sync(): try: self._api.ingest(user_content, assistant_content, session_id=session_id, messages=messages) except Exception as e: logger.warning("Sync failed: %s", e) if self._sync_thread and self._sync_thread.is_alive(): self._sync_thread.join(timeout=5.0) self._sync_thread = threading.Thread(target=_sync, daemon=True) self._sync_thread.start() ``` `messages` is optional OpenAI-style conversation context as of the completed turn. When present, it includes user/assistant messages, assistant tool calls, and tool result messages. Providers that do not need raw turn context can omit the `messages` parameter; Claway will continue calling them with the legacy signature. Cloud providers should document what parts of `messages` are sent off-device. Tool calls and tool results may contain file paths, command output, or other workspace data. ## Profile Isolation All storage paths **must** use the `claway_home` kwarg from `initialize()`, not hardcoded `~/.claway`: ```python # CORRECT — profile-scoped from claway_constants import get_claway_home data_dir = get_claway_home() / "my-provider" # WRONG — shared across all profiles data_dir = Path("~/.claway/my-provider").expanduser() ``` ## Testing See `tests/agent/test_memory_provider.py` and adjacent memory tests (`tests/agent/test_memory_session_switch.py`, `tests/agent/test_memory_user_id.py`, `tests/run_agent/test_memory_provider_init.py`) for end-to-end patterns. ```python from agent.memory_manager import MemoryManager mgr = MemoryManager() mgr.add_provider(my_provider) mgr.initialize_all(session_id="test-1", platform="cli") # Test tool routing result = mgr.handle_tool_call("my_tool", {"action": "add", "content": "test"}) # Test lifecycle mgr.sync_all("user msg", "assistant msg") mgr.on_session_end([]) mgr.shutdown_all() ``` ## Adding CLI Commands Memory provider plugins can register their own CLI subcommand tree (e.g. `claway my-provider status`, `claway my-provider config`). This uses a convention-based discovery system — no changes to core files needed. ### How it works 1. Add a `cli.py` file to your plugin directory 2. Define a `register_cli(subparser)` function that builds the argparse tree 3. The memory plugin system discovers it at startup via `discover_plugin_cli_commands()` 4. Your commands appear under `claway <provider-name> <subcommand>` **Active-provider gating:** Your CLI commands only appear when your provider is the active `memory.provider` in config. If a user hasn't configured your provider, your commands won't show in `claway --help`. ### Example ```python # plugins/memory/my-provider/cli.py def my_command(args): """Handler dispatched by argparse.""" sub = getattr(args, "my_command", None) if sub == "status": print("Provider is active and connected.") elif sub == "config": print("Showing config...") else: print("Usage: claway my-provider <status|config>") def register_cli(subparser) -> None: """Build the claway my-provider argparse tree. Called by discover_plugin_cli_commands() at argparse setup time. """ subs = subparser.add_subparsers(dest="my_command") subs.add_parser("status", help="Show provider status") subs.add_parser("config", help="Show provider config") subparser.set_defaults(func=my_command) ``` ### Reference implementation See `plugins/memory/honcho/cli.py` for a full example with 13 subcommands, cross-profile management (`--target-profile`), and config read/write. ### Directory structure with CLI ``` plugins/memory/my-provider/ ├── __init__.py # MemoryProvider implementation + register() ├── plugin.yaml # Metadata ├── cli.py # register_cli(subparser) — CLI commands └── README.md # Setup instructions ``` ## Single Provider Rule Only **one** external memory provider can be active at a time. If a user tries to register a second, the MemoryManager rejects it with a warning. This prevents tool schema bloat and conflicting backends. --- <!-- source: website/docs/developer-guide/model-provider-plugin.md --> # Model Provider Plugins # Building a Model Provider Plugin Model provider plugins declare an inference backend — an OpenAI-compatible endpoint, an Anthropic Messages server, a Codex-style Responses API, or a Bedrock-native surface — that Claway can route `AIAgent` calls through. Every built-in provider (OpenRouter, Anthropic, GMI, DeepSeek, Nvidia, …) ships as one of these plugins. Third parties can add their own by dropping a directory under `$CLAWAY_HOME/plugins/model-providers/` with zero changes to the repo. :::tip Model provider plugins are the third kind of **provider plugin**. The others are [Memory Provider Plugins](/developer-guide/memory-provider-plugin) (cross-session knowledge) and [Context Engine Plugins](/developer-guide/context-engine-plugin) (context compression strategies). All three follow the same "drop a directory, declare a profile, no repo edits" pattern. ::: ## How discovery works `providers/__init__.py._discover_providers()` runs lazily the first time any code calls `get_provider_profile()` or `list_providers()`. Discovery order: 1. **Bundled plugins** — `<repo>/plugins/model-providers/<name>/` — ship with Claway 2. **User plugins** — `$CLAWAY_HOME/plugins/model-providers/<name>/` — drop in any directory; no restart required for subsequent sessions 3. **Legacy single-file** — `<repo>/providers/<name>.py` — back-compat for out-of-tree editable installs **User plugins override bundled plugins of the same name** because `register_provider()` is last-writer-wins. Drop a `$CLAWAY_HOME/plugins/model-providers/gmi/` directory to replace the built-in GMI profile without touching the repo. ## Directory structure ``` plugins/model-providers/my-provider/ ├── __init__.py # Calls register_provider(profile) at module-level ├── plugin.yaml # kind: model-provider + metadata (optional but recommended) └── README.md # Setup instructions (optional) ``` The only required file is `__init__.py`. `plugin.yaml` is used by `claway plugins` for introspection and by the general PluginManager to route the plugin to the right loader; without it, the general loader falls back to a source-text heuristic. ## Minimal example — a simple API-key provider ```python # plugins/model-providers/acme-inference/__init__.py from providers import register_provider from providers.base import ProviderProfile acme = ProviderProfile( name="acme-inference", aliases=("acme",), display_name="Acme Inference", description="Acme — OpenAI-compatible direct API", signup_url="https://acme.example.com/keys", env_vars=("ACME_API_KEY", "ACME_BASE_URL"), base_url="https://api.acme.example.com/v1", auth_type="api_key", default_aux_model="acme-small-fast", fallback_models=( "acme-large-v3", "acme-medium-v3", "acme-small-fast", ), ) register_provider(acme) ``` ```yaml # plugins/model-providers/acme-inference/plugin.yaml name: acme-inference kind: model-provider version: 1.0.0 description: Acme Inference — OpenAI-compatible direct API author: Your Name ``` That's it. After dropping these two files, the following **auto-wire** with no other edits: | Integration | Where | What it gets | |---|---|---| | Credential resolution | `claway_cli/auth.py` | `PROVIDER_REGISTRY["acme-inference"]` populated from profile | | `--provider` CLI flag | `claway_cli/main.py` | Accepts `acme-inference` | | `claway model` picker | `claway_cli/models.py` | Appears in `CANONICAL_PROVIDERS`, model list fetched from `{base_url}/models` | | `claway doctor` | `claway_cli/doctor.py` | Health check for `ACME_API_KEY` + `{base_url}/models` probe | | `claway setup` | `claway_cli/config.py` | `ACME_API_KEY` appears in `OPTIONAL_ENV_VARS` and the setup wizard | | URL reverse-mapping | `agent/model_metadata.py` | Hostname → provider name for auto-detection | | Auxiliary model | `agent/auxiliary_client.py` | Uses `default_aux_model` for compression / summarization | | Runtime resolution | `claway_cli/runtime_provider.py` | Returns correct `base_url`, `api_key`, `api_mode` | | Transport | `agent/transports/chat_completions.py` | Profile path generates kwargs via `prepare_messages` / `build_extra_body` / `build_api_kwargs_extras` | ## ProviderProfile fields Full definition in `providers/base.py`. The most useful ones: | Field | Type | Purpose | |---|---|---| | `name` | str | Canonical id — matches `model.provider` in `config.yaml` and the `--provider` flag | | `aliases` | `tuple[str, ...]` | Alternative names resolved by `get_provider_profile()` (e.g. `grok` → `xai`) | | `api_mode` | str | `chat_completions` \| `codex_responses` \| `anthropic_messages` \| `bedrock_converse` | | `display_name` | str | Human label shown in `claway model` picker | | `description` | str | Picker subtitle | | `signup_url` | str | Shown during first-run setup ("get an API key here") | | `env_vars` | `tuple[str, ...]` | API-key env vars in priority order; a final `*_BASE_URL` entry is used as the user base-URL override | | `base_url` | str | Default inference endpoint | | `models_url` | str | Explicit catalog URL (falls back to `{base_url}/models`) | | `auth_type` | str | `api_key` \| `oauth_device_code` \| `oauth_external` \| `copilot` \| `aws_sdk` \| `external_process` | | `fallback_models` | `tuple[str, ...]` | Curated list shown when live catalog fetch fails | | `default_headers` | `dict[str, str]` | Sent on every request (e.g. Copilot's `Editor-Version`) | | `fixed_temperature` | Any | `None` = use caller's value; `OMIT_TEMPERATURE` sentinel = don't send temperature at all (Kimi) | | `default_max_tokens` | `int \| None` | Provider-level max_tokens cap (Nvidia: 16384) | | `default_aux_model` | str | Cheap model for auxiliary tasks (compression, vision, summarization) | ## Overridable hooks Subclass `ProviderProfile` for non-trivial quirks: ```python from typing import Any from providers.base import ProviderProfile class AcmeProfile(ProviderProfile): def prepare_messages(self, messages: list[dict[str, Any]]) -> list[dict[str, Any]]: """Provider-specific message preprocessing. Runs after codex sanitization, before developer-role swap. Default: pass-through.""" # Example: Qwen normalizes plain-text content to a list-of-parts # array and injects cache_control; Kimi rewrites tool-call JSON return messages def build_extra_body(self, *, session_id=None, **context) -> dict: """Provider-specific extra_body fields merged into the API call. Context includes: session_id, provider_preferences, model, base_url, reasoning_config. Default: empty dict.""" # Example: OpenRouter's provider-preferences block, # Gemini's thinking_config translation. return {} def build_api_kwargs_extras(self, *, reasoning_config=None, **context): """Returns (extra_body_additions, top_level_kwargs). Needed when some fields go top-level (Kimi's reasoning_effort, OpenRouter's verbosity for adaptive Anthropic models) and some go in extra_body (OpenRouter's reasoning dict). Default: ({}, {}).""" return {}, {} def fetch_models(self, *, api_key=None, timeout=8.0) -> list[str] | None: """Live catalog fetch. Default hits {models_url or base_url}/models with Bearer auth. Override for: custom auth (Anthropic), no REST endpoint (Bedrock → None), or public/unauthenticated catalogs (OpenRouter).""" return super().fetch_models(api_key=api_key, timeout=timeout) ``` ## Hook reference examples Look at these bundled plugins for idioms: | Plugin | Why look | |---|---| | `plugins/model-providers/openrouter/` | Aggregator with provider preferences, public model catalog | | `plugins/model-providers/gemini/` | `thinking_config` translation (native + OpenAI-compat nested forms) | | `plugins/model-providers/kimi-coding/` | `OMIT_TEMPERATURE`, `extra_body.thinking`, top-level `reasoning_effort` | | `plugins/model-providers/qwen-oauth/` | Message normalization, `cache_control` injection, VL high-res | | `plugins/model-providers/nous/` | Attribution tags, "omit reasoning when disabled" | | `plugins/model-providers/custom/` | Ollama `num_ctx` + `think: false` quirks | | `plugins/model-providers/bedrock/` | `api_mode="bedrock_converse"`, `fetch_models` returns None (no REST endpoint) | ## User overrides — replace a built-in without editing the repo Say you want to point `gmi` at your private staging endpoint for testing. Create `~/.claway/plugins/model-providers/gmi/__init__.py`: ```python from providers import register_provider from providers.base import ProviderProfile register_provider(ProviderProfile( name="gmi", aliases=("gmi-cloud", "gmicloud"), env_vars=("GMI_API_KEY",), base_url="https://gmi-staging.internal.example.com/v1", auth_type="api_key", default_aux_model="google/gemini-3.1-flash-lite-preview", )) ``` Next session, `get_provider_profile("gmi").base_url` returns the staging URL. No repo patch, no rebuild. Because user plugins are discovered after bundled ones, the user `register_provider()` call wins. ## api_mode selection Four values are recognized. Claway picks one based on: 1. User explicit override (`config.yaml` `model.api_mode` when set) 2. OpenCode's per-model dispatch (`opencode_model_api_mode` for Zen and Go) 3. URL auto-detection — `/anthropic` suffix → `anthropic_messages`, `api.openai.com` → `codex_responses`, `api.x.ai` → `codex_responses`, `/coding` on Kimi domains → `chat_completions` 4. **Profile `api_mode`** as a fallback when URL detection finds nothing 5. Default `chat_completions` Set `profile.api_mode` to match the default your provider ships — it acts as a hint. User URL overrides still win. ## Auth types | `auth_type` | Meaning | Who uses it | |---|---|---| | `api_key` | Single env var carries a static API key | Most providers | | `oauth_device_code` | Device-code OAuth flow | — | | `oauth_external` | User signs in elsewhere, tokens land in `auth.json` | Anthropic OAuth, MiniMax OAuth, Qwen Portal | | `copilot` | GitHub Copilot token refresh cycle | `copilot` plugin only | | `aws_sdk` | AWS SDK credential chain (IAM role, profile, env) | `bedrock` plugin only | | `external_process` | Auth handled by a subprocess the agent spawns | `copilot-acp` plugin only | `auth_type` gates which codepaths treat your provider as a "simple api-key provider" — if it's not `api_key`, the PluginManager still records the manifest but Claway's CLI-level automation (doctor checks, `--provider` flag, setup wizard delegation) may skip over it. ## Discovery timing Provider discovery is **lazy** — triggered by the first `get_provider_profile()` or `list_providers()` call in the process. In practice this happens early at startup (`auth.py` module load extends `PROVIDER_REGISTRY` eagerly). If you need to verify your plugin loaded, run: ```bash claway doctor ``` — a successful `auth_type="api_key"` profile appears under the Provider Connectivity section with a `/models` probe. For programmatic inspection: ```python from providers import list_providers for p in list_providers(): print(p.name, p.base_url, p.api_mode) ``` ## Testing your plugin Point `CLAWAY_HOME` at a temp directory so you don't pollute your real config: ```bash export CLAWAY_HOME=/tmp/claway-plugin-test mkdir -p $CLAWAY_HOME/plugins/model-providers/my-provider cat > $CLAWAY_HOME/plugins/model-providers/my-provider/__init__.py <<'EOF' from providers import register_provider from providers.base import ProviderProfile register_provider(ProviderProfile( name="my-provider", env_vars=("MY_API_KEY",), base_url="https://api.my-provider.example.com/v1", auth_type="api_key", )) EOF export MY_API_KEY=your-test-key claway -z "hello" --provider my-provider -m some-model ``` ## General PluginManager integration The general `PluginManager` (the thing `claway plugins` operates on) **sees** model-provider plugins but does not import them — `providers/__init__.py` owns their lifecycle. The manager records the manifest for introspection and categorizes by `kind: model-provider`. When you drop an unlabeled user plugin into `$CLAWAY_HOME/plugins/` that happens to call `register_provider` with a `ProviderProfile`, the manager auto-coerces it to `kind: model-provider` via a source-text heuristic — so the plugin still routes correctly even without `plugin.yaml`. ## Distribute via pip Like any Claway plugin, model providers can ship as a pip package. Add an entry point to your `pyproject.toml`: ```toml [project.entry-points."claway_agent.plugins"] acme-inference = "acme_claway_plugin:register" ``` …where `acme_claway_plugin:register` is a function that calls `register_provider(profile)`. The general PluginManager picks up entry-point plugins during `discover_and_load()`. For `kind: model-provider` pip plugins, you still need to declare the kind in your manifest (or rely on the source-text heuristic). See [Building a Claway Plugin](/guides/build-a-claway-plugin#distribute-via-pip) for the full entry-points setup. ## Related pages - Provider Runtime — resolution precedence + where each layer reads the profile - Adding Providers — end-to-end checklist for new inference backends (covers both the fast plugin path and the full CLI/auth integration) - [Memory Provider Plugins](/developer-guide/memory-provider-plugin) - [Context Engine Plugins](/developer-guide/context-engine-plugin) - [Building a Claway Plugin](/guides/build-a-claway-plugin) — general plugin authoring --- <!-- source: website/docs/developer-guide/plugin-llm-access.md --> # Plugin LLM Access # Plugin LLM Access `ctx.llm` is the supported way for a plugin to make an LLM call. Chat completion, structured extraction, sync, async, with or without images — same surface, same trust gate, same host-owned credentials. Plugins reach for this when they need to do something that involves the model but isn't part of the agent's conversation. A hook that rewrites a tool error into something a non-engineer can read. A gateway adapter that translates an inbound message before queuing it. A slash command that summarises a long paste. A scheduled job that scores yesterday's activity and writes one line to a status board. A pre-filter that decides whether a message is worth waking the agent up for at all. These are jobs the agent shouldn't be in the loop on. They want one LLM call, a typed answer, and to be done. ## The smallest possible call ```python result = ctx.llm.complete(messages=[{"role": "user", "content": "ping"}]) return result.text ``` That's the whole API in one line. No keys, no provider config, no SDK initialisation. The plugin runs against whatever provider and model the user is currently using — when they switch providers, the plugin follows them automatically. ## A more complete chat example ```python result = ctx.llm.complete( messages=[ {"role": "system", "content": "Rewrite errors as one short sentence a non-engineer can act on."}, {"role": "user", "content": traceback_text}, ], max_tokens=64, purpose="hooks.error-rewrite", ) return result.text ``` `purpose` is a free-form audit string — it shows up in `agent.log` and in `result.audit` so operators can see which plugin made which call. Optional but recommended for anything that fires often. ## Structured output When the plugin needs a typed answer, switch to the structured lane: ```python result = ctx.llm.complete_structured( instructions="Score this support reply for urgency (0–1) and pick a category.", input=[{"type": "text", "text": message_body}], json_schema=TRIAGE_SCHEMA, purpose="support.triage", temperature=0.0, max_tokens=128, ) if result.parsed["urgency"] > 0.8: await dispatch_to_oncall(result.parsed["category"], message_body) ``` The host requests JSON output from the provider, parses it locally as a fallback, validates against your schema if `jsonschema` is installed, and hands back a Python object on `result.parsed`. If the model couldn't produce valid JSON, `result.parsed` is `None` and `result.text` carries the raw response. ## What this lane gives you * **One call, four shapes.** `complete()` for chat, `complete_structured()` for typed JSON, `acomplete()` and `acomplete_structured()` for asyncio. Same arguments, same result objects. * **Host-owned credentials.** OAuth tokens, refresh flows, the credential pool, per-task aux overrides — every credential concept Claway already has applies. The plugin never sees a token; the host attributes the call back through `result.audit`. * **Bounded.** Single sync or async call. No streaming, no tool loops, no conversation state to manage. State the input, get the result, return. * **Fail-closed trust.** A plugin you've never configured cannot pick its own provider, model, agent, or stored credential. The default posture is "use what the user is using." Operators opt in to specific overrides, per plugin, in `config.yaml`. ## Quick start Two complete plugins below — one chat, one structured. Both ship inside a single `register(ctx)` function and need zero outside configuration to run against whatever model the user has active. ### Chat completion — `/tldr` ```python def register(ctx): ctx.register_command( name="tldr", handler=lambda raw: _tldr(ctx, raw), description="Summarise the supplied text in one paragraph.", args_hint="<text>", ) def _tldr(ctx, raw_args: str) -> str: text = raw_args.strip() if not text: return "Usage: /tldr <text to summarise>" result = ctx.llm.complete( messages=[ {"role": "system", "content": "Summarise the user's text in one tight paragraph. No preamble."}, {"role": "user", "content": text}, ], max_tokens=256, temperature=0.3, purpose="tldr", ) return result.text ``` `result.text` is the model's response; `result.usage` carries token counts; `result.provider` and `result.model` carry attribution. ### Structured extraction — `/paste-to-tasks` ```python def register(ctx): ctx.register_command( name="paste-to-tasks", handler=lambda raw: _paste_to_tasks(ctx, raw), description="Turn freeform meeting notes into structured tasks.", args_hint="<text>", ) _TASKS_SCHEMA = { "type": "object", "properties": { "tasks": { "type": "array", "items": { "type": "object", "properties": { "owner": {"type": "string"}, "action": {"type": "string"}, "due": {"type": "string", "description": "ISO date or empty"}, }, "required": ["action"], }, }, }, "required": ["tasks"], } def _paste_to_tasks(ctx, raw_args: str) -> str: if not raw_args.strip(): return "Usage: /paste-to-tasks <meeting notes>" result = ctx.llm.complete_structured( instructions=( "Extract concrete action items from these meeting notes. " "One task per actionable line. If no owner is named, leave 'owner' blank." ), input=[{"type": "text", "text": raw_args}], json_schema=_TASKS_SCHEMA, schema_name="meeting.tasks", purpose="paste-to-tasks", temperature=0.0, max_tokens=512, ) if result.parsed is None: return f"Couldn't parse a response. Raw output:\n{result.text}" lines = [f"- [{t.get('owner') or '?'}] {t['action']}" for t in result.parsed["tasks"]] return "\n".join(lines) or "(no tasks found)" ``` ## When to use which | You want… | Reach for | |---|---| | A free-form text response (translation, summary, rewrite, generation) | `complete()` | | A multi-turn prompt (system + few-shot examples + user) | `complete()` | | A typed dict back, validated against a schema | `complete_structured()` | | Image-or-text input with a typed dict back | `complete_structured()` | | The same call from async code (gateway adapters, async hooks) | `acomplete()` / `acomplete_structured()` | Everything else — provider selection, model resolution, auth, fallback, timeout, vision routing — is the same across all four. ## API surface `ctx.llm` is an instance of `agent.plugin_llm.PluginLlm`. ### `complete()` ```python result = ctx.llm.complete( messages=[{"role": "user", "content": "Hi"}], provider=None, # optional, gated — Claway provider id (e.g. "openrouter") model=None, # optional, gated — whatever string that provider expects temperature=None, max_tokens=None, timeout=None, # seconds agent_id=None, # optional, gated profile=None, # optional, gated — explicit auth-profile name purpose="optional-audit-string", ) # → PluginLlmCompleteResult(text, provider, model, agent_id, usage, audit) ``` Plain chat completion. `messages` is the standard OpenAI shape — a list of `{"role": "...", "content": "..."}` dicts. Multi-turn prompts (system + few-shot user/assistant pairs + final user) work exactly as they would with the OpenAI SDK. `provider=` and `model=` are independent and follow the same shape as the host's main config (`model.provider` + `model.model`). Set just `model=` to use the user's active provider with a different model on it. Set both to switch providers entirely. Either argument without operator opt-in raises `PluginLlmTrustError`. ### `complete_structured()` ```python result = ctx.llm.complete_structured( instructions="What you want extracted.", input=[ {"type": "text", "text": "..."}, {"type": "image", "data": b"...", "mime_type": "image/png"}, {"type": "image", "url": "https://..."}, ], json_schema={...}, # optional — triggers parsed result + validation json_mode=False, # set True without a schema to ask for JSON anyway schema_name=None, # optional human-readable schema name system_prompt=None, provider=None, # optional, gated model=None, # optional, gated temperature=None, max_tokens=None, timeout=None, agent_id=None, profile=None, purpose=None, ) # → PluginLlmStructuredResult(text, provider, model, agent_id, # usage, parsed, content_type, audit) ``` Inputs are typed text or image blocks (raw bytes get base64 encoded as a `data:` URL automatically). When `json_schema` or `json_mode=True` is supplied, the host requests JSON output via `response_format`, parses it locally as a fallback, and validates against your schema if `jsonschema` is installed. * `result.content_type == "json"` — `result.parsed` is a Python object that matches your schema. * `result.content_type == "text"` — parsing or validation failed; inspect `result.text` for the raw model response. ### Async ```python result = await ctx.llm.acomplete(messages=...) result = await ctx.llm.acomplete_structured(instructions=..., input=...) ``` Same arguments and result types as their sync counterparts. Use these from gateway adapters, async hooks, or any plugin code already running on an asyncio loop. ### Result attributes ```python @dataclass class PluginLlmCompleteResult: text: str # the assistant's response provider: str # e.g. "openrouter", "anthropic" model: str # whatever the provider returned for this call agent_id: str # whose model/auth was used usage: PluginLlmUsage # tokens + cache + cost estimate audit: Dict[str, Any] # plugin_id, purpose, profile @dataclass class PluginLlmStructuredResult(PluginLlmCompleteResult): parsed: Optional[Any] # JSON object when content_type == "json" content_type: str # "json" or "text" # audit also carries schema_name when supplied ``` `usage` carries `input_tokens`, `output_tokens`, `total_tokens`, `cache_read_tokens`, `cache_write_tokens`, and `cost_usd` when the provider returns those fields. ## Trust gate The default behaviour is fail-closed. With no `plugins.entries` config block, a plugin can: * run any of the four methods against the user's active provider and model, * set request-shaping arguments (`temperature`, `max_tokens`, `timeout`, `system_prompt`, `purpose`, `messages`, `instructions`, `input`, `json_schema`), …and that's it. `provider=`, `model=`, `agent_id=`, and `profile=` arguments raise `PluginLlmTrustError` until the operator opts in. **Most plugins never need this section.** A plugin that just calls `ctx.llm.complete(messages=...)` with no overrides runs against whatever the user has active and works zero-config. The block below is only relevant when a plugin specifically wants to pin to a different model or provider than the user. ```yaml plugins: entries: my-plugin: llm: # Allow this plugin to choose a different Claway provider # (must be one Claway already knows about — same names as # `claway model` and config.yaml model.provider). allow_provider_override: true # Optionally restrict which providers. Use ["*"] for any. allowed_providers: - openrouter - anthropic # Allow this plugin to ask for a specific model. allow_model_override: true # Optionally restrict which models. Use ["*"] for any. # Models are matched literally against whatever string the # plugin sends — Claway does not look anything up. allowed_models: - openai/gpt-4o-mini - anthropic/claude-3-5-haiku # Allow cross-agent calls (rare). allow_agent_id_override: false # Allow the plugin to request a specific stored auth profile # (e.g. a different OAuth account on the same provider). allow_profile_override: false ``` The plugin id is the manifest `name:` field for flat plugins, or the path-derived key for nested plugins (`image_gen/openai`, `memory/honcho`, etc.). ### What the gate enforces | Override | Default | Config key | | --------------- | ------- | -------------------------------- | | `provider=` | denied | `allow_provider_override: true` | | ↳ allowlist | — | `allowed_providers: [...]` | | `model=` | denied | `allow_model_override: true` | | ↳ allowlist | — | `allowed_models: [...]` | | `agent_id=` | denied | `allow_agent_id_override: true` | | `profile=` | denied | `allow_profile_override: true` | Each override is independently gated. Granting `allow_model_override` does **not** also grant `allow_provider_override` — a plugin trusted to pick a model is still pinned to the user's active provider unless it gets the provider gate as well. ### What the gate does NOT need to enforce * Request-shaping arguments — `temperature`, `max_tokens`, `timeout`, `system_prompt`, `purpose`, `messages`, `instructions`, `input`, `json_schema`, `schema_name`, `json_mode` — are always allowed; they don't pick credentials or routes. * The default deny posture means an unconfigured plugin can still do useful work — it just runs against the active provider and model. Operators only need to think about `plugins.entries` for plugins that want finer routing. ## What the host owns A complete list of the things `ctx.llm` does for the plugin so you don't have to: * **Provider resolution.** Reads `model.provider` + `model.model` from the user's config (or the explicit overrides when trusted). * **Auth.** Pulls API keys, OAuth tokens, or refresh tokens from `~/.claway/auth.json` / env, including the credential pool when one is configured. The plugin never sees them. * **Vision routing.** When image input is supplied and the user's active text model is text-only, the host falls back to the configured vision model automatically. * **Fallback chain.** If the user's primary provider 5xxs or 429s, the request goes through Claway's usual aggregator-aware fallback before it returns an error to the plugin. * **Timeout.** Honours your `timeout=` argument, falling back to `auxiliary.<task>.timeout` config or the global aux default. * **JSON shaping.** Sends `response_format` to the provider when you ask for JSON, then re-parses locally from a code-fenced response if the provider returned one. * **Schema validation.** Validates against your `json_schema` when `jsonschema` is installed; logs a debug line and skips strict validation otherwise. * **Audit log.** Each call writes one INFO line to `agent.log` with the plugin id, provider/model, purpose, and token totals. ## What the plugin owns * **Request shape.** `messages` for chat, `instructions` + `input` for structured. The plugin builds the prompt; the host runs it. * **Schema.** Whatever shape you want back. The host doesn't infer it for you. * **Error handling.** `complete_structured()` raises `ValueError` on empty inputs and on schema-validation failure. `PluginLlmTrustError` fires when the trust gate denies an override. Anything else (provider 5xx, no credentials configured, timeout) raises whatever `auxiliary_client.call_llm()` raises. * **Cost.** Every call runs against the user's paid provider. Don't loop on `complete()` for every gateway message without thinking about token spend. ## Where this fits in the plugin surface Existing `ctx.*` methods extend an existing Claway subsystem: | `ctx.register_tool` | adds a tool the agent can call | | `ctx.register_platform` | wires a new gateway adapter | | `ctx.register_image_gen_provider` | replaces an image-gen backend | | `ctx.register_memory_provider` | replaces the memory backend | | `ctx.register_context_engine` | replaces the context compressor | | `ctx.register_hook` | observes a lifecycle event | `ctx.llm` is the first surface that lets a plugin run the same model the user is talking to, *out of band*, without any of the above. That's its only job. If your plugin needs to register a tool the agent invokes, use `register_tool`. If it needs to react to a lifecycle event, use `register_hook`. If it needs to make its own model call — for any reason, structured or not — `ctx.llm`. ## Reference * Implementation: `agent/plugin_llm.py` * Tests: `tests/agent/test_plugin_llm.py` * Auxiliary client (the engine under the hood): `agent/auxiliary_client.py`. --- <!-- source: website/docs/developer-guide/video-gen-provider-plugin.md --> # Video Generation Provider Plugins # Building a Video Generation Provider Plugin Video-gen provider plugins register a backend that services every `video_generate` tool call. Built-in providers (xAI, FAL) ship as plugins. Add a new one, or override a bundled one, by dropping a directory into `plugins/video_gen/<name>/`. :::tip Video-gen mirrors [Image Generation Provider Plugins](/developer-guide/image-gen-provider-plugin) almost line-for-line — if you've built an image-gen backend, you already know the shape. The main differences: a `capabilities()` method advertising modalities/aspect-ratios/durations, and a routing convention (pass `image_url` to use image-to-video, omit it to use text-to-video — the provider picks the right endpoint internally). ::: ## The unified surface (one tool, two modalities) The `video_generate` tool exposes two modalities through one parameter: - **Text-to-video** — call with `prompt` only. The provider routes to its text-to-video endpoint. - **Image-to-video** — call with `prompt` + `image_url`. The provider routes to its image-to-video endpoint. Edit and extend are intentionally out of scope. Most backends don't support them and the inconsistency would force per-backend prose into the agent's tool description. ## How discovery works Claway scans for video-gen backends in three places: 1. **Bundled** — `<repo>/plugins/video_gen/<name>/` (auto-loaded with `kind: backend`) 2. **User** — `~/.claway/plugins/video_gen/<name>/` (opt-in via `plugins.enabled`) 3. **Pip** — packages declaring a `claway_agent.plugins` entry point Each plugin's `register(ctx)` function calls `ctx.register_video_gen_provider(...)`. The active provider is picked by `video_gen.provider` in `config.yaml`; `claway tools` → Video Generation walks users through selection. Unlike `image_generate`, there is no in-tree legacy backend — every provider is a plugin. ## Directory structure ``` plugins/video_gen/my-backend/ ├── __init__.py # VideoGenProvider subclass + register() └── plugin.yaml # Manifest with kind: backend ``` ## The VideoGenProvider ABC Subclass `agent.video_gen_provider.VideoGenProvider`. Required: `name` property and `generate()` method. ```python # plugins/video_gen/my-backend/__init__.py from typing import Any, Dict, List, Optional import os from agent.video_gen_provider import ( VideoGenProvider, error_response, success_response, ) class MyVideoGenProvider(VideoGenProvider): @property def name(self) -> str: return "my-backend" @property def display_name(self) -> str: return "My Backend" def is_available(self) -> bool: return bool(os.environ.get("MY_API_KEY")) def list_models(self) -> List[Dict[str, Any]]: # Each entry is a model FAMILY — a name the user picks once. # Your provider's generate() routes within the family based on # whether image_url was passed. return [ { "id": "fast", "display": "Fast", "speed": "~30s", "strengths": "Cheapest tier", "price": "$0.05/s", "modalities": ["text", "image"], # advisory }, ] def default_model(self) -> Optional[str]: return "fast" def capabilities(self) -> Dict[str, Any]: return { "modalities": ["text", "image"], "aspect_ratios": ["16:9", "9:16"], "resolutions": ["720p", "1080p"], "min_duration": 1, "max_duration": 10, "supports_audio": False, "supports_negative_prompt": True, "max_reference_images": 0, } def get_setup_schema(self) -> Dict[str, Any]: return { "name": "My Backend", "badge": "paid", "tag": "Short description shown in `claway tools`", "env_vars": [ { "key": "MY_API_KEY", "prompt": "My Backend API key", "url": "https://mybackend.example.com/keys", }, ], } def generate( self, prompt: str, *, model: Optional[str] = None, image_url: Optional[str] = None, reference_image_urls: Optional[List[str]] = None, duration: Optional[int] = None, aspect_ratio: str = "16:9", resolution: str = "720p", negative_prompt: Optional[str] = None, audio: Optional[bool] = None, seed: Optional[int] = None, **kwargs: Any, # always ignore unknown kwargs for forward-compat ) -> Dict[str, Any]: # ROUTE: image_url presence picks the endpoint. if image_url: endpoint = "my-backend/image-to-video" modality_used = "image" else: endpoint = "my-backend/text-to-video" modality_used = "text" # ... call your API ... return success_response( video="https://your-cdn/output.mp4", model=model or "fast", prompt=prompt, modality=modality_used, aspect_ratio=aspect_ratio, duration=duration or 5, provider=self.name, ) def register(ctx) -> None: ctx.register_video_gen_provider(MyVideoGenProvider()) ``` ## The plugin manifest ```yaml # plugins/video_gen/my-backend/plugin.yaml name: my-backend version: 1.0.0 description: "My video generation backend" author: Your Name kind: backend requires_env: - MY_API_KEY ``` ## The `video_generate` schema The tool exposes one schema across every backend. Providers ignore parameters they don't support. | Parameter | What it does | |---|---| | `prompt` | Text instruction (required) | | `image_url` | When set → image-to-video; when omitted → text-to-video | | `reference_image_urls` | Style/character refs (provider-dependent) | | `duration` | Seconds — provider clamps | | `aspect_ratio` | `"16:9"`, `"9:16"`, `"1:1"`, ... — provider clamps | | `resolution` | `"480p"` / `"540p"` / `"720p"` / `"1080p"` — provider clamps | | `negative_prompt` | Content to avoid (Pixverse/Kling only) | | `audio` | Native audio (Veo3 / Pixverse pricing tier) | | `seed` | Reproducibility | | `model` | Override the active model/family | The provider's `capabilities()` advertises which of these are honored. The agent sees the active backend's capabilities in the tool description, dynamically rebuilt when the user changes backend via `claway tools`. ## Model families and endpoint routing (the FAL pattern) When your backend has multiple endpoints per "model" — like FAL, where every family (Veo 3.1, Pixverse v6, Kling O3) has both a `/text-to-video` and an `/image-to-video` URL — represent each **family** as one catalog entry. Your `generate()` picks the right endpoint based on whether `image_url` was passed: ```python FAMILIES = { "veo3.1": { "text_endpoint": "fal-ai/veo3.1", "image_endpoint": "fal-ai/veo3.1/image-to-video", # ... family-specific capability flags ... }, } def generate(self, prompt, *, image_url=None, model=None, **kwargs): family_id, family = _resolve_family(model) endpoint = family["image_endpoint"] if image_url else family["text_endpoint"] # ... build payload from family's declared capability flags, call endpoint ... ``` The user picks `veo3.1` once in `claway tools`. The agent never thinks about endpoints — it just passes (or doesn't pass) `image_url`. ## Selection precedence For per-instance model knobs (see `plugins/video_gen/fal/__init__.py`): 1. `model=` keyword from the tool call 2. `<PROVIDER>_VIDEO_MODEL` env var 3. `video_gen.<provider>.model` in `config.yaml` 4. `video_gen.model` in `config.yaml` (when it's one of your IDs) 5. Provider's `default_model()` ## Response shape `success_response()` and `error_response()` produce the dict shape every backend returns. Use them — don't hand-roll the dict. Success keys: `success`, `video` (URL or absolute path), `model`, `prompt`, `modality` (`"text"` or `"image"`), `aspect_ratio`, `duration`, `provider`, plus `extra`. Error keys: `success`, `video` (None), `error`, `error_type`, `model`, `prompt`, `aspect_ratio`, `provider`. ## Where to save artifacts If your backend returns base64, use `save_b64_video()` to write under `$CLAWAY_HOME/cache/videos/`. For raw bytes from a follow-up HTTP fetch, use `save_bytes_video()`. Otherwise return the upstream URL directly — the gateway resolves remote URLs on delivery. ## Testing Drop a smoke test under `tests/plugins/video_gen/test_<name>_plugin.py`. The xAI and FAL tests show the pattern — register, verify catalog, exercise routing both with and without `image_url`, assert clean error responses on missing auth. --- <!-- source: website/docs/developer-guide/web-search-provider-plugin.md --> # Web Search Provider Plugins # Building a Web Search Provider Plugin Web-search provider plugins register a backend that services `web_search`, `web_extract`, and (optionally) deep-crawl tool calls. Built-in providers — Firecrawl, SearXNG, Tavily, Exa, Parallel, Brave Search (free tier), xAI, and DDGS — all ship as plugins under `plugins/web/<name>/`. You can add a new one, or override a bundled one, by dropping a directory next to them. :::tip Web search is one of several **backend plugins** Claway supports. The others (with their own ABCs) are [Image Generation Provider Plugins](/developer-guide/image-gen-provider-plugin), [Video Generation Provider Plugins](/developer-guide/video-gen-provider-plugin), [Memory Provider Plugins](/developer-guide/memory-provider-plugin), [Context Engine Plugins](/developer-guide/context-engine-plugin), and [Model Provider Plugins](/developer-guide/model-provider-plugin). General tool/hook/CLI plugins live in [Build a Claway Plugin](/guides/build-a-claway-plugin). ::: ## How discovery works Claway scans for web-search backends in three places: 1. **Bundled** — `<repo>/plugins/web/<name>/` (auto-loaded with `kind: backend`, always available) 2. **User** — `~/.claway/plugins/web/<name>/` (opt-in via `plugins.enabled` or `claway plugins enable <name>`) 3. **Pip** — packages declaring a `claway_agent.plugins` entry point Each plugin's `register(ctx)` function calls `ctx.register_web_search_provider(...)` — that puts the instance into the registry in `agent/web_search_registry.py`. The active provider for each capability is picked by config: | Capability | Config key | Falls back to | |---|---|---| | `web_search` | `web.search_backend` | `web.backend` | | `web_extract` | `web.extract_backend` | `web.backend` | | Deep crawl modes inside `web_extract` | `web.extract_backend` | `web.backend` | When neither key is set, Claway auto-detects the backend from whichever API key/URL is present in the environment. `claway tools` walks users through selection. ## Directory structure ``` plugins/web/my-backend/ ├── __init__.py # register() entry point ├── provider.py # WebSearchProvider subclass └── plugin.yaml # Manifest with kind: backend and provides_web_providers ``` `brave_free/` and `ddgs/` are the smallest in-tree references — `brave_free` for an API-key-gated search-only provider, `ddgs` for a no-key provider that lazy-installs its SDK. ## The WebSearchProvider ABC Subclass `agent.web_search_provider.WebSearchProvider`. The only required members are `name`, `is_available()`, and whichever of `search()` / `extract()` you implement. (Deep crawling is not a separate method — it's a mode of `extract()`.) ```python # plugins/web/my-backend/provider.py from __future__ import annotations import os from typing import Any, Dict, List from agent.web_search_provider import WebSearchProvider class MyBackendWebSearchProvider(WebSearchProvider): """Minimal search-only provider against the My Backend HTTP API.""" @property def name(self) -> str: # Stable id used in web.search_backend / web.extract_backend / web.backend # config keys. Lowercase, no spaces; hyphens permitted. return "my-backend" @property def display_name(self) -> str: # Human label shown in `claway tools`. Defaults to `name`. return "My Backend" def is_available(self) -> bool: # Cheap check — env var present, optional dep importable, etc. # MUST NOT make network calls (runs on every `claway tools` paint). return bool(os.getenv("MY_BACKEND_API_KEY", "").strip()) def supports_search(self) -> bool: return True def supports_extract(self) -> bool: return False def search(self, query: str, limit: int = 5) -> Dict[str, Any]: import httpx api_key = os.environ["MY_BACKEND_API_KEY"] try: resp = httpx.get( "https://api.example.com/search", params={"q": query, "count": max(1, min(int(limit), 20))}, headers={"Authorization": f"Bearer {api_key}"}, timeout=15, ) resp.raise_for_status() data = resp.json() except httpx.HTTPError as exc: return {"success": False, "error": str(exc)} # Response shape is fixed — see "Response shape" below. return { "success": True, "data": { "web": [ { "title": item.get("title", ""), "url": item.get("url", ""), "description": item.get("snippet", ""), "position": idx + 1, } for idx, item in enumerate(data.get("results", [])) ], }, } ``` ```python # plugins/web/my-backend/__init__.py from plugins.web.my_backend.provider import MyBackendWebSearchProvider def register(ctx) -> None: """Plugin entry point — called once at load time.""" ctx.register_web_search_provider(MyBackendWebSearchProvider()) ``` ## plugin.yaml ```yaml name: web-my-backend version: 1.0.0 description: "My Backend web search — Bearer-auth REST API" author: Your Name kind: backend provides_web_providers: - my-backend requires_env: - MY_BACKEND_API_KEY ``` | Key | Purpose | |---|---| | `kind: backend` | Routes the plugin through the backend-loading path | | `provides_web_providers` | List of provider `name`s this plugin registers — used by the loader to advertise the plugin in `claway tools` even before `register()` runs | | `requires_env` | Interactive credential prompt during `claway plugins install` (see [Build a Claway Plugin](/guides/build-a-claway-plugin#gate-on-environment-variables) for the rich format) | ## ABC reference Full contract in `agent/web_search_provider.py`. Methods you may override: | Member | Required | Default | Purpose | |---|---|---|---| | `name` | ✅ | — | Stable id used in `web.*_backend` config | | `display_name` | — | `name` | Label shown in `claway tools` | | `is_available()` | ✅ | — | Cheap availability gate — env vars, optional deps | | `supports_search()` | — | `True` | Capability flag for `web_search` routing | | `supports_extract()` | — | `False` | Capability flag for `web_extract` routing | | `search(query, limit)` | conditional | raises | Required when `supports_search()` returns `True` | | `extract(urls, **kwargs)` | conditional | raises | Required when `supports_extract()` returns `True` | Providers can advertise multiple capabilities from a single class — Firecrawl, Tavily, Exa, and Parallel all implement both search and extract. Brave Search and DDGS are search-only; SearXNG is search-only with a documented "pair me with an extract provider" workflow. ## Response shape The tool wrapper expects a fixed envelope so it doesn't have to translate between backends. **Search success:** ```python { "success": True, "data": { "web": [ {"title": str, "url": str, "description": str, "position": int}, ... ], }, } ``` **Extract success:** ```python { "success": True, "data": [ { "url": str, "title": str, "content": str, "raw_content": str, "metadata": dict, # optional "error": str, # optional, only on per-URL failure }, ... ], } ``` **Either capability, on failure:** ```python {"success": False, "error": "human-readable message"} ``` Both `search()` and `extract()` may be `async def` — the dispatcher detects coroutine functions via `inspect.iscoroutinefunction` and awaits accordingly. Sync implementations that do blocking I/O (HTTP, SDK calls) are fine for small backends; the dispatcher handles threading. ## Capability flags Claway routes calls to the right provider based on the `supports_*` flags. A common multi-provider setup: ```yaml # ~/.claway/config.yaml web: search_backend: "brave-free" # search-only, fast, free 2k/mo extract_backend: "firecrawl" # extract + crawl, paid quota ``` When `web.search_backend` or `web.extract_backend` aren't set, both fall through to `web.backend`. When that's also unset, Claway picks the first available provider that supports the requested capability based on env-var presence. If your provider only supports one capability, leave the other flags at their default (`False`) and the registry will skip it for that tool — users won't see misleading "provider X failed" errors when they're using X only for search and asking the agent to extract. ## How Claway wires it into the tools The `web_search` and `web_extract` tools live in `tools/web_tools.py`. At call time they: 1. Read the relevant config key (`web.search_backend` for `web_search`, `web.extract_backend` for `web_extract`) 2. Ask the registry for the provider with that `name` 3. Check `is_available()` and the matching `supports_*()` flag 4. Dispatch to `search()` / `extract()` (deep crawl runs as a mode inside `extract()`), awaiting if the method is a coroutine 5. JSON-serialize the response envelope and hand it back to the LLM Errors surface as the tool result; the LLM decides how to explain them. If no provider is registered (or every available one fails the capability gate), the tool returns a helpful error pointing at `claway tools`. ## Lazy-installing optional dependencies If your provider wraps a third-party SDK (like DDGS does with the `ddgs` package), don't `import` it at module top level. Use `tools.lazy_deps.ensure(...)` inside `is_available()` or `search()` — Claway will install the package on first use, gated by `security.allow_lazy_installs`. See [Build a Claway Plugin → Lazy-install](/guides/build-a-claway-plugin#lazy-install-optional-python-dependencies) for the security model. ## Reference implementations - **`plugins/web/brave_free/`** — small, API-key-gated, search-only HTTP provider. Good starting template. - **`plugins/web/ddgs/`** — no-key provider that lazy-installs its SDK. Useful pattern for backends that wrap a Python package. - **`plugins/web/firecrawl/`** — full multi-capability provider (search + extract + crawl) with multiple format modes. - **`plugins/web/searxng/`** — self-hosted, URL-configured backend with no auth. - **`plugins/web/xai/`** — LLM-backed search via Grok's server-side `web_search` tool. Shows how to reuse an existing OAuth/env-var credential surface (`tools/xai_http.py`) without adding new env vars, and how to write a cheap `is_available()` that honors the no-network contract. ## Distribute via pip ```toml # pyproject.toml [project.entry-points."claway_agent.plugins"] my-backend-web = "my_backend_web_package" ``` `my_backend_web_package` must expose a top-level `register` function. See [Distribute via pip](/guides/build-a-claway-plugin#distribute-via-pip) in the general plugin guide for the full setup. ## Related pages - [Web Search](/user-guide/features/web-search) — user-facing feature documentation and per-backend configuration - [Plugins overview](/user-guide/features/plugins) — all plugin types at a glance - [Build a Claway Plugin](/guides/build-a-claway-plugin) — general tools/hooks/slash commands guide --- <!-- source: website/docs/end-users/accounting-clerk.md --> # Jarvis as your accounting clerk # Jarvis as your accounting clerk If your operator has set up Jarvis with the accounting-clerk persona, this is the shape it takes. This page reflects the default template; your operator may have added local rules on top. ## Daily tasks it handles - **Expense logging.** Send it a receipt image, tell it the category. It files the entry and (if configured) posts it to your accounting system. - **Invoice review.** Attach an invoice PDF. Jarvis extracts vendor, amount, due date, PO reference, flags anything that looks off. - **AR / AP follow-up.** Ask "which invoices are more than 30 days overdue?" — Jarvis pulls from the KB (if the operator wired up your ledger) and drafts polite reminder emails you can approve before sending. - **Month-end checklists.** Say "start month-end for October". Jarvis walks the standard checklist your operator wrote into its persona, ticking off each step as you confirm. - **Currency conversions and quick calculations.** Reliable to two decimal places using live FX (via the `web_search` tool). Always double-check when the number matters. ## Things it will not do without a human - **Approve payments.** Jarvis can *prepare* a payment run but will not submit it. Every payment above your operator's threshold needs a second human confirmation. - **Sign contracts or NDAs.** It can draft. It cannot bind you. - **Move money between accounts.** Read-only access, always. ## Correcting mistakes Accounting mistakes compound, so we err on the side of asking Jarvis to double-check. If it gets an entry wrong: ``` You: 呢張發票 amount 錯咗,係 HK$12,450 唔係 HK$14,250 Jarvis: 對唔住,改正咗。你要唔要我 undo 之前入帳嗰單? ``` If it references an old fact that has changed (e.g. an old bank account number), tell it plainly and it updates its memory for this group. ## The KB Jarvis reads the documents your operator uploaded to its KB. Ask "who is the finance contact at Acme?" and it should return the answer with "📚 source: `<filename>`". If it answers *without* citing a source, treat the answer as a guess — the KB probably does not have that fact. ## When to escalate - The number Jarvis quoted differs from your ledger by more than a rounding error. - Jarvis cited a document you know is out of date. The operator needs to refresh the KB. - A vendor calls asking about an invoice Jarvis handled — always confirm with a human before responding. Ping your operator via the escalation shortcut your team uses (usually `@operator` in the group, or a Slack DM). --- <!-- source: website/docs/end-users/customer-service.md --> # Jarvis as your customer service specialist # Jarvis as your customer service specialist The customer-service persona runs a first-line CS queue. Most tickets it handles alone; the tricky ones it hands to you. ## Daily tasks it handles - **First reply within one minute.** Every inbound customer message gets an acknowledgment plus a first-pass answer if the KB has one. - **FAQ.** Jarvis reads your product handbook and answers straight from it — with source citations so you can verify. - **Order lookups.** "What is the status of order #4472?" Jarvis queries your fulfilment API (if wired) and reports back. - **Return / refund intake.** Jarvis collects the return reason, order number, and photos, files a case, and gives the customer a case number. A human approves before any money moves. - **Language routing.** If a customer writes in Bahasa or Traditional Chinese, Jarvis replies in the same language. No manual switch needed. ## Things it will not do without a human - **Approve refunds above your policy threshold.** - **Promise resolution timelines it cannot control.** It will say "we aim for X but I will confirm with a human" rather than commit to a date. - **Escalate to social media or public forums.** All escalations stay internal to your CS system. - **Continue if the customer is clearly distressed.** It will page you and switch to a listening tone. ## Tone controls Two levers your operator sets, that end-users can nudge in-flight: - **Formality.** By default Jarvis matches the customer's tone. If a customer is casual, Jarvis is friendly. If they are formal, Jarvis is formal. You can override by writing (in the internal side of the chat): "please stay formal for this thread". - **Empathy pass.** For a customer clearly upset, tell Jarvis "empathy pass first". It leads with acknowledgment before problem-solving. ## Correcting mistakes - **Wrong policy quoted.** Reply with the correct policy in one line — Jarvis remembers for this group and (if your operator configured it) flags a policy update. - **Escalation missed.** If Jarvis should have handed a case to you and did not, say "next time this comes up, escalate". It stores the trigger and asks your operator to confirm. ## The KB The CS persona is heavily KB-driven. Your operator likely uploaded product manuals, warranty policies, shipping terms, and a canned-response library. Jarvis blends these with the customer's specific question. Cite-less answers should be treated as guesses. ## When to escalate - Any mention of legal action, media coverage, or public complaints. - A customer contradicts the KB and Jarvis cannot resolve. - Repeat contact (same customer, third message today) — escalate for a human touch even if Jarvis has answers. - Anything involving personal data changes (address, payment method, account holder) — Jarvis passes to a human every time. --- <!-- source: website/docs/end-users/privacy-explained.md --> # What Jarvis knows about you # What Jarvis knows about you Short version: Jarvis remembers what you tell it inside **this** group, never shares it with another group, and only reads documents your operator explicitly attached to this group. ## Who sees what Inside every message you send, three parties can read the content: - **Jarvis (this group's instance).** It remembers relevant facts across conversations. Its memory is a file scoped to this group only. - **Your operator.** The person at your company who runs Jarvis has access to a dashboard that includes message history for auditing purposes. - **Blockway's control plane** (if your operator opted in). Only aggregate usage counters — how many messages, how many tokens, which models. Not the message contents. WhatsApp itself does not read message contents inside encrypted groups. Neither does Blockway. ## What Jarvis remembers about you - **Short-term** — the current conversation. Cleared automatically after a period of inactivity or if you say `/new`. - **Long-term facts** — things you have said should be remembered. Stored in a per-group memory file. Never shared with other groups. - **KB documents** — the documents your operator attached to *this* group only. Documents attached to another group are structurally invisible to this Jarvis. ## What Jarvis does not remember - Messages from other groups it serves. Even ones you personally sent. Cross-group leakage is prevented at the database level. - Anything you explicitly asked it to forget. - Sensitive strings (credit-card numbers, national IDs) are redacted before ever landing in logs, if your operator enabled that filter. ## Asking Jarvis to forget Say "forget what I told you about X" — the specific fact is removed. Say "forget everything about me in this group" for a full local reset (this does not affect other groups). Full account deletion — say if you leave the company — goes through your operator. They export or purge your data on request; see the operator's retention policy. ## What the operator sees Your operator has access to: - The full transcript of every group they operate. - Aggregate token / cost / session data. - Persona and skill configuration. They do **not** have access to: - Your WhatsApp account credentials. - Other groups you are in outside of Claway. - Blockway's control-plane data. If you are not sure who your operator is, ask a manager. They are the one to contact for privacy questions before you contact Blockway. ## When to contact Blockway directly - If you believe there has been a leak between groups (a fact from group A appeared in group B). This is a structural failure and we treat it as an incident. - If your operator has left the company and you need to reset access. - If a data subject request (GDPR-style) is not being handled by your operator within the timeframe your local law requires. `privacy@claway.io` — Blockway responds within one business day. --- <!-- source: website/docs/end-users/sales-assistant.md --> # Jarvis as your sales assistant # Jarvis as your sales assistant The sales-assistant persona is tuned for outbound work. It cannot close a deal for you, but it can carry a lot of the drudgery. ## Daily tasks it handles - **Quote drafts.** "Quote for MLI Audio, three units of the K7 speaker bundle, standard trade terms." Jarvis produces a PDF you can review and send. - **Client follow-up.** "Who have I not messaged in more than two weeks?" Jarvis pulls from your CRM (if wired) or the KB, ranks by deal size, and drafts individually personalised follow-ups. - **Meeting prep.** "Prep for the Acme call at 3pm." Jarvis pulls the recent conversation history, any relevant KB documents, and hands you a bullet list. - **CRM updates.** "Log a call with Ada, discussed pricing, they want to see a case study." Jarvis writes it to the CRM via the outbound webhook your operator configured. - **Pipeline snapshots.** "Show me deals at proposal stage over HK$100K." Jarvis queries the CRM API and renders a table. ## Things it will not do without a human - **Send external emails.** Jarvis drafts. You send. This is deliberate. - **Promise pricing outside your policy.** If you ask for a 40% discount and your operator set the ceiling at 20%, Jarvis will decline and redirect to your manager. - **Share internal deal notes with the client.** Even by accident. ## Correcting mistakes Sales personas run into two common issues: - **Wrong client history.** Jarvis mixes up two similarly-named contacts. Tell it explicitly which one — "Ada at Acme HK, not Ada at Acme UK" — and it will remember for this group. - **Tone mismatch.** If it drafts something too formal or too casual, say "same message but warmer" — it iterates. If the tone is consistently off, ask your operator to tweak the persona's tone rule. ## The KB Your operator likely loaded product spec sheets, case studies, price lists, and standard terms into the KB. Ask about any of these and Jarvis cites the source. If it answers *without* a source and the answer feels suspiciously confident, verify against the spec sheet. ## When to escalate - Any request that mentions the words "legal", "compliance", "return", "refund", "warranty claim". - A client asks a technical question outside the spec sheets in your KB. - A price or delivery-date question where the KB is stale. Ping your operator; do not let Jarvis commit to something it should not. --- <!-- source: website/docs/end-users/whatsapp-cheatsheet.md --> # Chatting with Jarvis on WhatsApp # Chatting with Jarvis on WhatsApp Jarvis lives inside your WhatsApp group. It reads every message and replies when it can help. This page covers the eight things you actually do. ## 1. Ask a question Just type. In a small group, Jarvis replies to everything relevant. In a busy group, your operator may have configured Jarvis to only respond when you `@mention` it — check with them. ``` Ada: @Jarvis 上個月我哋 Acme 個 order 有幾多發票未收? Jarvis: 三張未收,總共 HK$247,300。要我 draft reminder email 嗎? ``` ## 2. Attach a file Drop a `.pdf`, `.docx`, `.xlsx`, `.pptx`, image, or voice note into the group. Jarvis reads it. No caption needed, but a short caption helps it know what to do: ``` [Contract.pdf] Ada: 幫我 summarize 個 termination clause ``` Supported inline: PDF, DOCX, XLSX, PPTX (and legacy .xls), plain text, most images. Videos are transcribed if under two minutes. ## 3. Send a voice note Jarvis transcribes voice notes, treats them as text messages, and replies either in text or (if your operator enabled it) in the same voice back. Speak in whichever language you prefer — most personas auto-detect. ## 4. Correct Jarvis If Jarvis gets something wrong, tell it. Direct language is fine: ``` You: 唔啱,Acme 個 PO number 係 PO-2026-0447 唔係 0448 Jarvis: 收到,記低咗。之後我用返 PO-2026-0447。 ``` The correction is remembered *for this group* — other groups Jarvis serves never see it. ## 5. Undo the last reply Not sure Jarvis's reply is good? Say `/undo` — the last exchange is removed from context and Jarvis reconsiders. Or just tell it in your own words: "唔好呢個 reply, 重新諗過". ## 6. Start a fresh conversation For a completely new topic, say `/new` or `/reset`. Jarvis's short-term memory clears. Long-term facts (your PO number examples above) survive. ## 7. Ask what Jarvis can do Say `/skills`. Jarvis lists the tools available to this specific group: things like `pdf_summarize`, `send_email_draft`, `calculate`, etc. The list is intentionally scoped — you will not see tools your operator has disabled. ## 8. Stop Jarvis If Jarvis is mid-reply and you need to stop it, say `/stop`. If you are having a private conversation among humans and want Jarvis to stay quiet for a while, `/mute 15m` mutes it for 15 minutes. ## Things Jarvis will not do - Send messages to people who are not in this group without you asking. - Approve payments without a second explicit confirmation. - Share what it knows about this group with any other group. - Continue if you tell it to stop. If Jarvis does any of the above, tell your operator immediately. ## When Jarvis says "let me pass this to a human" Some questions Jarvis is not supposed to answer alone — legal advice, sensitive personnel matters, refunds above a threshold. When that happens, Jarvis will say so and (if configured) tag your operator. Wait for a human to reply. ## Where things go wrong - **Jarvis replies in the wrong language.** Just tell it, "please reply in English" or "用中文答我". It sticks for the rest of the session. - **Jarvis references something you never said.** Copy the exact quote and send it to your operator. This is usually a stale memory that needs cleaning up. - **Jarvis has been silent for hours.** Check with another user first — if they can send messages Jarvis is receiving them, the reply chain is the issue. Otherwise the bot may be offline; ask your operator. --- <!-- source: website/docs/guides/automation-blueprints.md --> # Automation Blueprints # Automation Blueprints Copy-paste blueprints for common automation patterns. Each blueprint uses Claway's built-in [cron scheduler](/user-guide/features/cron) for time-based triggers and [webhook platform](/user-guide/messaging/webhooks) for event-driven triggers. Every blueprint works with **any model** — not locked to a single provider. For parameterized blueprints with forms instead of cron syntax, see the [Automation Blueprints Catalog](/reference/automation-blueprints-catalog). :::tip Three Trigger Types | Trigger | How | Tool | |---------|-----|------| | **Schedule** | Runs on a cadence (hourly, nightly, weekly) | `cronjob` tool or `/cron` slash command | | **GitHub Event** | Fires on PR opens, pushes, issues, CI results | Webhook platform (`claway webhook subscribe`) | | **API Call** | External service POSTs JSON to your endpoint | Webhook platform (config.yaml routes or `claway webhook subscribe`) | All three support delivery to Telegram, Discord, Slack, SMS, email, GitHub comments, or local files. ::: --- ## Development Workflow ### Nightly Backlog Triage Label, prioritize, and summarize new issues every night. Delivers a digest to your team channel. **Trigger:** Schedule (nightly) ```bash claway cron create "0 2 * * *" \ "You are a project manager triaging the BlockWayz/claway GitHub repo. 1. Run: gh issue list --repo BlockWayz/claway --state open --json number,title,labels,author,createdAt --limit 30 2. Identify issues opened in the last 24 hours 3. For each new issue: - Suggest a priority label (P0-critical, P1-high, P2-medium, P3-low) - Suggest a category label (bug, feature, docs, security) - Write a one-line triage note 4. Summarize: total open issues, new today, breakdown by priority Format as a clean digest. If no new issues, respond with [SILENT]." \ --name "Nightly backlog triage" \ --deliver telegram ``` ### Automatic PR Code Review Review every pull request automatically when it's opened. Posts a review comment directly on the PR. **Trigger:** GitHub webhook **Option A — Dynamic subscription (CLI):** ```bash claway webhook subscribe github-pr-review \ --events "pull_request" \ --prompt "Review this pull request: Repository: {repository.full_name} PR #{pull_request.number}: {pull_request.title} Author: {pull_request.user.login} Action: {action} Diff URL: {pull_request.diff_url} Fetch the diff with: curl -sL {pull_request.diff_url} Review for: - Security issues (injection, auth bypass, secrets in code) - Performance concerns (N+1 queries, unbounded loops, memory leaks) - Code quality (naming, duplication, error handling) - Missing tests for new behavior Post a concise review. If the PR is a trivial docs/typo change, say so briefly." \ --skill github-code-review \ --deliver github_comment ``` **Option B — Static route (config.yaml):** ```yaml platforms: webhook: enabled: true extra: port: 8644 secret: "your-global-secret" routes: github-pr-review: events: ["pull_request"] secret: "github-webhook-secret" prompt: | Review PR #{pull_request.number}: {pull_request.title} Repository: {repository.full_name} Author: {pull_request.user.login} Diff URL: {pull_request.diff_url} Review for security, performance, and code quality. skills: ["github-code-review"] deliver: "github_comment" deliver_extra: repo: "{repository.full_name}" pr_number: "{pull_request.number}" ``` Then in GitHub: **Settings → Webhooks → Add webhook** → Payload URL: `http://your-server:8644/webhooks/github-pr-review`, Content type: `application/json`, Secret: `github-webhook-secret`, Events: **Pull requests**. ### Docs Drift Detection Weekly scan of merged PRs to find API changes that need documentation updates. **Trigger:** Schedule (weekly) ```bash claway cron create "0 9 * * 1" \ "Scan the BlockWayz/claway repo for documentation drift. 1. Run: gh pr list --repo BlockWayz/claway --state merged --json number,title,files,mergedAt --limit 30 2. Filter to PRs merged in the last 7 days 3. For each merged PR, check if it modified: - Tool schemas (tools/*.py) — may need docs/reference/tools-reference.md update - CLI commands (claway_cli/commands.py, claway_cli/main.py) — may need docs/reference/cli-commands.md update - Config options (claway_cli/config.py) — may need docs/user-guide/configuration.md update - Environment variables — may need docs/reference/environment-variables.md update 4. Cross-reference: for each code change, check if the corresponding docs page was also updated in the same PR Report any gaps where code changed but docs didn't. If everything is in sync, respond with [SILENT]." \ --name "Docs drift detection" \ --deliver telegram ``` ### Dependency Security Audit Daily scan for known vulnerabilities in project dependencies. **Trigger:** Schedule (daily) ```bash claway cron create "0 6 * * *" \ "Run a dependency security audit on the claway project. 1. cd ~/.claway/claway && source .venv/bin/activate 2. Run: pip audit --format json 2>/dev/null || pip audit 2>&1 3. Run: npm audit --json 2>/dev/null (in website/ directory if it exists) 4. Check for any CVEs with CVSS score >= 7.0 If vulnerabilities found: - List each one with package name, version, CVE ID, severity - Check if an upgrade is available - Note if it's a direct dependency or transitive If no vulnerabilities, respond with [SILENT]." \ --name "Dependency audit" \ --deliver telegram ``` --- ## DevOps & Monitoring ### Deploy Verification Trigger smoke tests after every deployment. Your CI/CD pipeline POSTs to the webhook when a deploy completes. **Trigger:** API call (webhook) ```bash claway webhook subscribe deploy-verify \ --events "deployment" \ --prompt "A deployment just completed: Service: {service} Environment: {environment} Version: {version} Deployed by: {deployer} Run these verification steps: 1. Check if the service is responding: curl -s -o /dev/null -w '%{http_code}' {health_url} 2. Search recent logs for errors: check the deployment payload for any error indicators 3. Verify the version matches: curl -s {health_url}/version Report: deployment status (healthy/degraded/failed), response time, any errors found. If healthy, keep it brief. If degraded or failed, provide detailed diagnostics." \ --deliver telegram ``` Your CI/CD pipeline triggers it: ```bash curl -X POST http://your-server:8644/webhooks/deploy-verify \ -H "Content-Type: application/json" \ -H "X-Hub-Signature-256: sha256=$(echo -n '{"service":"api","environment":"prod","version":"2.1.0","deployer":"ci","health_url":"https://api.example.com/health"}' | openssl dgst -sha256 -hmac 'your-secret' | cut -d' ' -f2)" \ -d '{"service":"api","environment":"prod","version":"2.1.0","deployer":"ci","health_url":"https://api.example.com/health"}' ``` ### Alert Triage Correlate monitoring alerts with recent changes to draft a response. Works with Datadog, PagerDuty, Grafana, or any alerting system that can POST JSON. **Trigger:** API call (webhook) ```bash claway webhook subscribe alert-triage \ --prompt "Monitoring alert received: Alert: {alert.name} Severity: {alert.severity} Service: {alert.service} Message: {alert.message} Timestamp: {alert.timestamp} Investigate: 1. Search the web for known issues with this error pattern 2. Check if this correlates with any recent deployments or config changes 3. Draft a triage summary with: - Likely root cause - Suggested first response steps - Escalation recommendation (P1-P4) Be concise. This goes to the on-call channel." \ --deliver slack ``` ### Uptime Monitor Check endpoints every 30 minutes. Only notify when something is down. **Trigger:** Schedule (every 30 min) ```python title="~/.claway/scripts/check-uptime.py" import urllib.request, json, time ENDPOINTS = [ {"name": "API", "url": "https://api.example.com/health"}, {"name": "Web", "url": "https://www.example.com"}, {"name": "Docs", "url": "https://docs.example.com"}, ] results = [] for ep in ENDPOINTS: try: start = time.time() req = urllib.request.Request(ep["url"], headers={"User-Agent": "Claway-Monitor/1.0"}) resp = urllib.request.urlopen(req, timeout=10) elapsed = round((time.time() - start) * 1000) results.append({"name": ep["name"], "status": resp.getcode(), "ms": elapsed}) except Exception as e: results.append({"name": ep["name"], "status": "DOWN", "error": str(e)}) down = [r for r in results if r.get("status") == "DOWN" or (isinstance(r.get("status"), int) and r["status"] >= 500)] if down: print("OUTAGE DETECTED") for r in down: print(f" {r['name']}: {r.get('error', f'HTTP {r[\"status\"]}')} ") print(f"\nAll results: {json.dumps(results, indent=2)}") else: print("NO_ISSUES") ``` ```bash claway cron create "every 30m" \ "If the script reports OUTAGE DETECTED, summarize which services are down and suggest likely causes. If NO_ISSUES, respond with [SILENT]." \ --script ~/.claway/scripts/check-uptime.py \ --name "Uptime monitor" \ --deliver telegram ``` --- ## Research & Intelligence ### Competitive Repository Scout Monitor competitor repos for interesting PRs, features, and architectural decisions. **Trigger:** Schedule (daily) ```bash claway cron create "0 8 * * *" \ "Scout these AI agent repositories for notable activity in the last 24 hours: Repos to check: - anthropics/claude-code - openai/codex - All-Hands-AI/OpenHands - Aider-AI/aider For each repo: 1. gh pr list --repo <repo> --state all --json number,title,author,createdAt,mergedAt --limit 15 2. gh issue list --repo <repo> --state open --json number,title,labels,createdAt --limit 10 Focus on: - New features being developed - Architectural changes - Integration patterns we could learn from - Security fixes that might affect us too Skip routine dependency bumps and CI fixes. If nothing notable, respond with [SILENT]. If there are findings, organize by repo with brief analysis of each item." \ --skill competitive-pr-scout \ --name "Competitor scout" \ --deliver telegram ``` ### AI News Digest Weekly roundup of AI/ML developments. **Trigger:** Schedule (weekly) ```bash claway cron create "0 9 * * 1" \ "Generate a weekly AI news digest covering the past 7 days: 1. Search the web for major AI announcements, model releases, and research breakthroughs 2. Search for trending ML repositories on GitHub 3. Check arXiv for highly-cited papers on language models and agents Structure: ## Headlines (3-5 major stories) ## Notable Papers (2-3 papers with one-sentence summaries) ## Open Source (interesting new repos or major releases) ## Industry Moves (funding, acquisitions, launches) Keep each item to 1-2 sentences. Include links. Total under 600 words." \ --name "Weekly AI digest" \ --deliver telegram ``` ### Paper Digest with Notes Daily arXiv scan that saves summaries to your note-taking system. **Trigger:** Schedule (daily) ```bash claway cron create "0 8 * * *" \ "Search arXiv for the 3 most interesting papers on 'language model reasoning' OR 'tool-use agents' from the past day. For each paper, create an Obsidian note with the title, authors, abstract summary, key contribution, and potential relevance to Claway Agent development." \ --skill arxiv --skill obsidian \ --name "Paper digest" \ --deliver local ``` --- ## GitHub Event Automations ### Issue Auto-Labeling Automatically label and respond to new issues. **Trigger:** GitHub webhook ```bash claway webhook subscribe github-issues \ --events "issues" \ --prompt "New GitHub issue received: Repository: {repository.full_name} Issue #{issue.number}: {issue.title} Author: {issue.user.login} Action: {action} Body: {issue.body} Labels: {issue.labels} If this is a new issue (action=opened): 1. Read the issue title and body carefully 2. Suggest appropriate labels (bug, feature, docs, security, question) 3. If it's a bug report, check if you can identify the affected component from the description 4. Post a helpful initial response acknowledging the issue If this is a label or assignment change, respond with [SILENT]." \ --deliver github_comment ``` ### CI Failure Analysis Analyze CI failures and post diagnostics on the PR. **Trigger:** GitHub webhook ```yaml # config.yaml route platforms: webhook: enabled: true extra: routes: ci-failure: events: ["check_run"] secret: "ci-secret" prompt: | CI check failed: Repository: {repository.full_name} Check: {check_run.name} Status: {check_run.conclusion} PR: #{check_run.pull_requests.0.number} Details URL: {check_run.details_url} If conclusion is "failure": 1. Fetch the log from the details URL if accessible 2. Identify the likely cause of failure 3. Suggest a fix If conclusion is "success", respond with [SILENT]. deliver: "github_comment" deliver_extra: repo: "{repository.full_name}" pr_number: "{check_run.pull_requests.0.number}" ``` ### Auto-Port Changes Across Repos When a PR merges in one repo, automatically port the equivalent change to another. **Trigger:** GitHub webhook ```bash claway webhook subscribe auto-port \ --events "pull_request" \ --prompt "PR merged in the source repository: Repository: {repository.full_name} PR #{pull_request.number}: {pull_request.title} Author: {pull_request.user.login} Action: {action} Merge commit: {pull_request.merge_commit_sha} If action is 'closed' and pull_request.merged is true: 1. Fetch the diff: curl -sL {pull_request.diff_url} 2. Analyze what changed 3. Determine if this change needs to be ported to the Go SDK equivalent 4. If yes, create a branch, apply the equivalent changes, and open a PR on the target repo 5. Reference the original PR in the new PR description If action is not 'closed' or not merged, respond with [SILENT]." \ --skill github-pr-workflow \ --deliver log ``` --- ## Business Operations ### Stripe Payment Monitoring Track payment events and get summaries of failures. **Trigger:** API call (webhook) ```bash claway webhook subscribe stripe-payments \ --events "payment_intent.succeeded,payment_intent.payment_failed,charge.dispute.created" \ --prompt "Stripe event received: Event type: {type} Amount: {data.object.amount} cents ({data.object.currency}) Customer: {data.object.customer} Status: {data.object.status} For payment_intent.payment_failed: - Identify the failure reason from {data.object.last_payment_error} - Suggest whether this is a transient issue (retry) or permanent (contact customer) For charge.dispute.created: - Flag as urgent - Summarize the dispute details For payment_intent.succeeded: - Brief confirmation only Keep responses concise for the ops channel." \ --deliver slack ``` ### Daily Revenue Summary Compile key business metrics every morning. **Trigger:** Schedule (daily) ```bash claway cron create "0 8 * * *" \ "Generate a morning business metrics summary. Search the web for: 1. Current Bitcoin and Ethereum prices 2. S&P 500 status (pre-market or previous close) 3. Any major tech/AI industry news from the last 12 hours Format as a brief morning briefing, 3-4 bullet points max. Deliver as a clean, scannable message." \ --name "Morning briefing" \ --deliver telegram ``` --- ## Multi-Skill Workflows ### Security Audit Pipeline Combine multiple skills for a comprehensive weekly security review. **Trigger:** Schedule (weekly) ```bash claway cron create "0 3 * * 0" \ "Run a comprehensive security audit of the claway codebase. 1. Check for dependency vulnerabilities (pip audit, npm audit) 2. Search the codebase for common security anti-patterns: - Hardcoded secrets or API keys - SQL injection vectors (string formatting in queries) - Path traversal risks (user input in file paths without validation) - Unsafe deserialization (pickle.loads, yaml.load without SafeLoader) 3. Review recent commits (last 7 days) for security-relevant changes 4. Check if any new environment variables were added without being documented Write a security report with findings categorized by severity (Critical, High, Medium, Low). If nothing found, report a clean bill of health." \ --skill codebase-security-audit \ --name "Weekly security audit" \ --deliver telegram ``` ### Content Pipeline Research, draft, and prepare content on a schedule. **Trigger:** Schedule (weekly) ```bash claway cron create "0 10 * * 3" \ "Research and draft a technical blog post outline about a trending topic in AI agents. 1. Search the web for the most discussed AI agent topics this week 2. Pick the most interesting one that's relevant to open-source AI agents 3. Create an outline with: - Hook/intro angle - 3-4 key sections - Technical depth appropriate for developers - Conclusion with actionable takeaway 4. Save the outline to ~/drafts/blog-$(date +%Y%m%d).md Keep the outline to ~300 words. This is a starting point, not a finished post." \ --name "Blog outline" \ --deliver local ``` --- ## Quick Reference ### Cron Schedule Syntax | Expression | Meaning | |-----------|---------| | `every 30m` | Every 30 minutes | | `every 2h` | Every 2 hours | | `0 2 * * *` | Daily at 2:00 AM | | `0 9 * * 1` | Every Monday at 9:00 AM | | `0 9 * * 1-5` | Weekdays at 9:00 AM | | `0 3 * * 0` | Every Sunday at 3:00 AM | | `0 */6 * * *` | Every 6 hours | ### Delivery Targets | Target | Flag | Notes | |--------|------|-------| | Same chat | `--deliver origin` | Default — delivers to where the job was created | | Local file | `--deliver local` | Saves output, no notification | | Telegram | `--deliver telegram` | Home channel, or `telegram:CHAT_ID` for specific | | Discord | `--deliver discord` | Home channel, or `discord:CHANNEL_ID` | | Slack | `--deliver slack` | Home channel | | SMS | `--deliver sms:+15551234567` | Direct to phone number | | Specific thread | `--deliver telegram:-100123:456` | Telegram forum topic | ### Webhook Template Variables | Variable | Description | |----------|-------------| | `{pull_request.title}` | PR title | | `{issue.number}` | Issue number | | `{repository.full_name}` | `owner/repo` | | `{action}` | Event action (opened, closed, etc.) | | `{__raw__}` | Full JSON payload (truncated at 4000 chars) | | `{sender.login}` | GitHub user who triggered the event | ### The [SILENT] Pattern When a cron job's response contains `[SILENT]`, delivery is suppressed. Use this to avoid notification spam on quiet runs: ``` If nothing noteworthy happened, respond with [SILENT]. ``` This means you only get notified when the agent has something to report. --- <!-- source: website/docs/guides/aws-bedrock.md --> # AWS Bedrock # AWS Bedrock Claway Agent supports Amazon Bedrock as a native provider using the **Converse API** — not the OpenAI-compatible endpoint. This gives you full access to the Bedrock ecosystem: IAM authentication, Guardrails, cross-region inference profiles, and all foundation models. ## Prerequisites - **AWS credentials** — any source supported by the [boto3 credential chain](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html): - IAM instance role (EC2, ECS, Lambda — zero config) - `AWS_ACCESS_KEY_ID` + `AWS_SECRET_ACCESS_KEY` environment variables - `AWS_PROFILE` for SSO or named profiles - `aws configure` for local development - **boto3** — install with `cd ~/.claway/claway && uv pip install -e ".[bedrock]"` - **IAM permissions** — at minimum: - `bedrock:InvokeModel` and `bedrock:InvokeModelWithResponseStream` (for inference) - `bedrock:ListFoundationModels` and `bedrock:ListInferenceProfiles` (for model discovery) :::tip EC2 / ECS / Lambda On AWS compute, attach an IAM role with `AmazonBedrockFullAccess` and you're done. No API keys, no `.env` configuration — Claway detects the instance role automatically. ::: ## Quick Start ```bash # Install with Bedrock support cd ~/.claway/claway && uv pip install -e ".[bedrock]" # Select Bedrock as your provider claway model # → Choose "More providers..." → "AWS Bedrock" # → Select your region and model # Start chatting claway chat ``` ## Configuration After running `claway model`, your `~/.claway/config.yaml` will contain: ```yaml model: default: us.anthropic.claude-sonnet-4-6 provider: bedrock base_url: https://bedrock-runtime.us-east-2.amazonaws.com bedrock: region: us-east-2 ``` ### Region Set the AWS region in any of these ways (highest priority first): 1. `bedrock.region` in `config.yaml` 2. `AWS_REGION` environment variable 3. `AWS_DEFAULT_REGION` environment variable 4. Default: `us-east-1` ### Guardrails To apply [Amazon Bedrock Guardrails](https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails.html) to all model invocations: ```yaml bedrock: region: us-east-2 guardrail: guardrail_identifier: "abc123def456" # From the Bedrock console guardrail_version: "1" # Version number or "DRAFT" stream_processing_mode: "async" # "sync" or "async" trace: "disabled" # "enabled", "disabled", or "enabled_full" ``` ### Model Discovery Claway auto-discovers available models via the Bedrock control plane. You can customize discovery: ```yaml bedrock: discovery: enabled: true provider_filter: ["anthropic", "amazon"] # Only show these providers refresh_interval: 3600 # Cache for 1 hour ``` ## Available Models Bedrock models use **inference profile IDs** for on-demand invocation. The `claway model` picker shows these automatically, with recommended models at the top: | Model | ID | Notes | |-------|-----|-------| | Claude Sonnet 4.6 | `us.anthropic.claude-sonnet-4-6` | Recommended — best balance of speed and capability | | Claude Opus 4.6 | `us.anthropic.claude-opus-4-6-v1` | Most capable | | Claude Haiku 4.5 | `us.anthropic.claude-haiku-4-5-20251001-v1:0` | Fastest Claude | | Amazon Nova Pro | `us.amazon.nova-pro-v1:0` | Amazon's flagship | | Amazon Nova Micro | `us.amazon.nova-micro-v1:0` | Fastest, cheapest | | DeepSeek V3.2 | `deepseek.v3.2` | Strong open model | | Llama 4 Scout 17B | `us.meta.llama4-scout-17b-instruct-v1:0` | Meta's latest | :::info Cross-Region Inference Models prefixed with `us.` use cross-region inference profiles, which provide better capacity and automatic failover across AWS regions. Models prefixed with `global.` route across all available regions worldwide. ::: ## Switching Models Mid-Session Use the `/model` command during a conversation: ``` /model us.amazon.nova-pro-v1:0 /model deepseek.v3.2 /model us.anthropic.claude-opus-4-6-v1 ``` ## Diagnostics ```bash claway doctor ``` The doctor checks: - Whether AWS credentials are available (env vars, IAM role, SSO) - Whether `boto3` is installed - Whether the Bedrock API is reachable (ListFoundationModels) - Number of available models in your region ## Gateway (Messaging Platforms) Bedrock works with all Claway gateway platforms (Telegram, Discord, Slack, Feishu, etc.). Configure Bedrock as your provider, then start the gateway normally: ```bash claway gateway setup claway gateway start ``` The gateway reads `config.yaml` and uses the same Bedrock provider configuration. ## Troubleshooting ### "No API key found" / "No AWS credentials" Claway checks for credentials in this order: 1. `AWS_BEARER_TOKEN_BEDROCK` 2. `AWS_ACCESS_KEY_ID` + `AWS_SECRET_ACCESS_KEY` 3. `AWS_PROFILE` 4. EC2 instance metadata (IMDS) 5. ECS container credentials 6. Lambda execution role If none are found, run `aws configure` or attach an IAM role to your compute instance. ### "Invocation of model ID ... with on-demand throughput isn't supported" Use an **inference profile ID** (prefixed with `us.` or `global.`) instead of the bare foundation model ID. For example: - ❌ `anthropic.claude-sonnet-4-6` - ✅ `us.anthropic.claude-sonnet-4-6` ### "ThrottlingException" You've hit the Bedrock per-model rate limit. Claway automatically retries with backoff. To increase limits, request a quota increase in the [AWS Service Quotas console](https://console.aws.amazon.com/servicequotas/). ## One-Click AWS Deployment For a fully automated deployment on EC2 with CloudFormation: **[sample-claway-on-aws-with-bedrock](https://github.com/JiaDe-Wu/sample-claway-on-aws-with-bedrock)** — creates VPC, IAM role, EC2 instance, and configures Bedrock automatically. Deploy in any region with one click. --- <!-- source: website/docs/guides/azure-foundry.md --> # Microsoft Foundry # Microsoft Foundry Claway Agent's `azure-foundry` provider supports Microsoft Foundry (formerly Azure AI Foundry) and Azure OpenAI. A single Foundry resource can host models with two different wire formats: - **OpenAI-style** — `POST /v1/chat/completions` on endpoints like `https://<resource>.openai.azure.com/openai/v1`. Used for GPT-4.x, GPT-5.x, Llama, Mistral, and most open-weight models. - **Anthropic-style** — `POST /v1/messages` on endpoints like `https://<resource>.services.ai.azure.com/anthropic`. Used when Microsoft Foundry serves Claude models via the Anthropic Messages API format. The setup wizard probes your endpoint and auto-detects which transport it uses, which deployments are available, and each model's context length. ## Prerequisites - A Microsoft Foundry or Azure OpenAI resource with at least one deployment - The deployment's endpoint URL - **Either** an API key (from the Azure Portal under "Keys and Endpoint") **or** the **Azure AI User** RBAC role on the Foundry resource if you plan to use Microsoft Entra ID (the keyless path Microsoft recommends). Some tenants may show the role as **Foundry User** during Microsoft's rename rollout. ## Quick Start ```bash claway model # → Select "Azure Foundry" # → Enter your endpoint URL # → Choose Authentication: # 1. API key # 2. Microsoft Entra ID (managed identity / workload identity / az login) # → (Entra) Claway probes DefaultAzureCredential; on success it never asks for a key # → (API key) Enter your API key # Claway probes the endpoint and auto-detects transport + models # → Pick a model from the list (or type a deployment name manually) ``` The wizard will: 1. **Sniff the URL path** — URLs ending in `/anthropic` are recognised as Microsoft Foundry Claude routes. 2. **Probe `GET <base>/models`** — if the endpoint returns an OpenAI-shaped model list, Claway switches to `chat_completions` and prefills a picker with the returned deployment IDs. 3. **Probe Anthropic Messages shape** — fallback for endpoints that do not expose `/models` but do accept the Anthropic Messages format. 4. **Fall back to manual entry** — private/gated endpoints that reject every probe still work; you pick the API mode and type a deployment name by hand. Context length for the chosen model is resolved via Claway's standard metadata chain (`models.dev`, provider metadata, and hardcoded family fallbacks) and stored in `config.yaml` so the model can size its own context window correctly. ## Microsoft Entra ID (keyless, RBAC) — recommended Microsoft recommends [keyless authentication with Microsoft Entra ID](https://learn.microsoft.com/azure/ai-foundry/foundry-models/how-to/configure-entra-id) for production Foundry workloads. Claway supports Entra ID for **both** API surfaces: - **OpenAI-style** (`api_mode: chat_completions` / `codex_responses`) — GPT-4/5, Llama, Mistral, DeepSeek, etc. - **Anthropic-style** (`api_mode: anthropic_messages`) — Claude models on Microsoft Foundry. Foundry's RBAC is per-resource (`Azure AI User` grants both surfaces; some tenants may display `Foundry User`) and Microsoft documents the same inference scope (`https://ai.azure.com/.default`) for both. Under the hood: - OpenAI-style uses the OpenAI Python SDK's native callable `api_key=` contract — the SDK mints a fresh JWT per request automatically. - Anthropic-style uses an `httpx.Client` with a request event hook installed by `agent.azure_identity_adapter.build_bearer_http_client`, because the Anthropic SDK does not accept callable `auth_token` natively. The hook rewrites `Authorization: Bearer <fresh-jwt>` per outbound request. Same Microsoft RBAC, same Foundry scope — the SDK contract is the only difference. ### Why use Entra ID? - No long-lived API keys to rotate or revoke. - RBAC-driven access — grant or remove `Azure AI User` on the Foundry resource, no config rewrite needed. - Access and audit logs are segmented by assignee instead of all callers sharing one static key. - Single auth surface for Azure VMs, AKS pods, App Service, Functions, Container Apps, and Foundry Agent Service via managed identity. - Workload identity and service-principal flows for CI/CD pipelines. ### One-time setup (Azure side) 1. In the Azure Portal, open your Foundry resource → **Access control (IAM)** → **Add → Add role assignment**. 2. Pick the **Azure AI User** role (or **Foundry User** if your tenant has the renamed role). 3. Assign it to: - **Your user account** for local development with `az login`. - **A managed identity or workload identity** for Azure-hosted compute (recommended for production). - **A Foundry Agent Service hosted agent's agent identity** when Claway runs inside a hosted agent. - **A service principal** for CI/CD pipelines when workload identity is not available. 4. Wait ~5 minutes for the role to propagate. Azure CLI equivalent: ```bash az role assignment create \ --assignee <principal-or-agent-identity-client-id> \ --role "Azure AI User" \ --scope <foundry-resource-id> ``` ### One-time setup (Claway side) ```bash claway model # → Select "Azure Foundry" # → Enter your endpoint URL # → Authentication: 2 (Microsoft Entra ID) # → (optional) user-assigned managed identity client ID # → (optional) Azure tenant ID # → Claway probes DefaultAzureCredential() and reports which inner # credential succeeded (e.g. AzureCliCredential, ManagedIdentityCredential) ``` The wizard runs a bounded preflight probe (10 s timeout). On failure it offers to "save anyway, validate later" — useful when configuring on a machine that doesn't yet have credentials but will at runtime (e.g. preparing config for a managed-identity deployment). `azure-identity` is installed automatically on first use via Claway's lazy-install path. To pre-install: ```bash pip install azure-identity ``` ### Configuration written to `config.yaml` ```yaml model: provider: azure-foundry base_url: https://my-resource.openai.azure.com/openai/v1 api_mode: chat_completions auth_mode: entra_id default: gpt-4o context_length: 128000 entra: scope: https://ai.azure.com/.default # only when overriding the default ``` Claway only manages one Entra-specific knob in `config.yaml`: - **`scope`** — the OAuth resource scope. Defaults to Microsoft's documented inference scope (`https://ai.azure.com/.default`). Override only if your resource was provisioned against a non-standard audience. Everything else (tenant, service principal secret, federated token file, sovereign cloud authority, broker preferences) is read by `azure-identity` directly from the standard `AZURE_*` environment variables — see the [credential resolution order](#credential-resolution-order) below. Set those in `~/.claway/.env` or your deployment environment, exactly as Microsoft's SDK reference describes. No secrets land in `~/.claway/.env` for Entra mode — `azure-identity` caches tokens in-process (and where available, in your OS keychain / `~/.IdentityService`). ### Credential resolution order `azure-identity`'s `DefaultAzureCredential` walks this chain on each token request, stopping at the first credential that returns a token: 1. **Environment credential** — `AZURE_TENANT_ID` + `AZURE_CLIENT_ID` + `AZURE_CLIENT_SECRET` (or `AZURE_CLIENT_CERTIFICATE_PATH` / `AZURE_FEDERATED_TOKEN_FILE`). 2. **Workload Identity** — `AZURE_FEDERATED_TOKEN_FILE` (AKS federated tokens / OIDC). 3. **Managed Identity** — IMDS endpoint (`169.254.169.254`) for virtual machines; `IDENTITY_ENDPOINT` for App Service / Functions / Container Apps. Foundry Agent Service hosted agents use the hosted agent's agent identity. 4. **Visual Studio Code** — Azure account extension. 5. **Azure CLI** — `az login` session. 6. **Azure Developer CLI** — `azd auth login`. 7. **Azure PowerShell** — `Connect-AzAccount`. 8. **Broker** (Windows / WSL only) — Web Account Manager. Interactive browser credential is excluded by default for unattended Claway runs; use Azure CLI, Azure Developer CLI, managed identity, workload identity, or service principal credentials instead. ### Deployment patterns **Local development:** ```bash az login claway model # pick Azure Foundry → Entra ID claway # uses your az login token ``` **Azure VM / Functions / App Service / Container Apps (system-assigned managed identity):** 1. Enable system-assigned identity on the compute resource. 2. Grant the identity `Azure AI User` (or `Foundry User`) on the Foundry resource. 3. Set `model.auth_mode: entra_id` in config.yaml — no env vars needed. **Azure VM / Functions / App Service / Container Apps (user-assigned managed identity):** - Set `AZURE_CLIENT_ID` to the user-assigned identity's client ID so `DefaultAzureCredential` picks the right one. **Foundry Agent Service hosted agent:** - Create the hosted agent and grant that agent's identity `Azure AI User` (or `Foundry User`) on the Foundry resource. Claway uses `ManagedIdentityCredential` from inside the hosted agent; role assignment belongs on the agent identity, not just the parent project or your user. **AKS Workload Identity (replaces AAD Pod Identity):** - Annotate the pod's service account with the workload identity client ID. - The pod's federated token file is auto-detected via `AZURE_FEDERATED_TOKEN_FILE`. - `model.auth_mode: entra_id` works without further config changes. **Service principal in CI:** - Set `AZURE_TENANT_ID`, `AZURE_CLIENT_ID`, `AZURE_CLIENT_SECRET` in the runner env. #### Sovereign clouds (Government, China) Export `AZURE_AUTHORITY_HOST` (e.g. `https://login.microsoftonline.us` for Azure Government, `https://login.partner.microsoftonline.cn` for Azure China). `azure-identity` reads it directly. ### Health checks `claway doctor` runs a 10 s probe against `DefaultAzureCredential` when `model.auth_mode: entra_id`, reporting which inner credential won (env vars present, managed identity endpoint reachable, etc.). `claway auth` shows a structured status block: ``` azure-foundry (Microsoft Entra ID): Endpoint: https://my-resource.openai.azure.com/openai/v1 Scope: https://ai.azure.com/.default Status: configured; live token probe is skipped here ``` ### Limitations - **Anthropic-style endpoints use an httpx event hook.** The Anthropic Python SDK does not accept a callable `auth_token` natively (≤ 0.86.0). Claway installs a request event hook on a custom `httpx.Client` that mints a fresh JWT per outbound request and rewrites `Authorization: Bearer <jwt>`. This is functionally equivalent to the OpenAI SDK's native `Callable[[], str]` contract but adds one indirection layer. If the Anthropic SDK adds first-class callable-auth support in a future release, Claway will switch to it transparently. - **Batch jobs and `multiprocessing.Pool`.** The Entra token provider is a closure that cannot be pickled across process boundaries. `batch_runner.py` automatically drops the callable from the worker config and lets each worker process rebuild its own provider from `config.yaml` — no user action required, but each worker pays one chain walk at startup. - **No bearer JWT persistence in `auth.json`.** Claway does not duplicate `azure-identity`'s internal token cache; cold starts walk the credential chain on first inference. ## Configuration (written to `config.yaml`) After running the wizard you'll see something like this: ```yaml model: provider: azure-foundry base_url: https://my-resource.openai.azure.com/openai/v1 api_mode: chat_completions # or "anthropic_messages" default: gpt-5.4-mini # your deployment / model name context_length: 400000 # auto-detected ``` And in `~/.claway/.env`: ``` AZURE_FOUNDRY_API_KEY=<your-azure-key> ``` ## OpenAI-style endpoints (GPT, Llama, etc.) Azure OpenAI's v1 GA endpoint accepts the standard `openai` Python client with minimal changes: ```yaml model: provider: azure-foundry base_url: https://my-resource.openai.azure.com/openai/v1 api_mode: chat_completions default: gpt-5.4 ``` Important behaviour: - **GPT-5.x, codex, and o-series auto-route to the Responses API.** Microsoft Foundry deploys GPT-5 / codex / o1 / o3 / o4 models as Responses-API-only — calling `/chat/completions` against them returns `400 "The requested operation is unsupported."`. Claway detects these model families by name and upgrades `api_mode` to `codex_responses` transparently, even when `config.yaml` still reads `api_mode: chat_completions`. GPT-4, GPT-4o, Llama, Mistral, and other deployments stay on `/chat/completions`. - **`max_completion_tokens` is used automatically.** Azure OpenAI (like direct OpenAI) requires `max_completion_tokens` for gpt-4o, o-series, and gpt-5.x models. Claway sends the right parameter based on the endpoint. - **Pre-v1 endpoints that require `api-version`.** If you have a legacy base URL like `https://<resource>.openai.azure.com/openai?api-version=2025-04-01-preview`, Claway extracts the query string and forwards it via `default_query` on every request (the OpenAI SDK otherwise drops it when joining paths). ## Anthropic-style endpoints (Claude via Microsoft Foundry) For Claude deployments, use the Anthropic-style route: ```yaml model: provider: azure-foundry base_url: https://my-resource.services.ai.azure.com/anthropic api_mode: anthropic_messages default: claude-sonnet-4-6 ``` Important behaviour: - **`/v1` is stripped from the base URL.** The Anthropic SDK appends `/v1/messages` to every request URL — Claway removes any trailing `/v1` before handing the URL to the SDK to avoid double-`/v1` paths. - **`api-version` is sent via `default_query`, not appended to the URL.** Azure Anthropic requires an `api-version` query string. Baking it into the base URL produces malformed paths like `/anthropic?api-version=.../v1/messages` and returns 404. Claway passes `api-version=2025-04-15` via the Anthropic SDK's `default_query` instead. - **Bearer auth is used instead of `x-api-key`.** Azure's Anthropic-compatible route requires `Authorization: Bearer <key>` rather than Anthropic's native `x-api-key` header. Claway detects `azure.com` in the base URL and routes the API key through the SDK's `auth_token` field so the right header reaches the upstream. - **1M context window beta header is kept.** Azure still gates the 1M-token Claude context (Opus 4.6/4.7, Sonnet 4.6) behind the `anthropic-beta: context-1m-2025-08-07` header. Claway keeps that beta header on Azure paths (it's stripped from native Anthropic OAuth requests because some subscriptions reject it, but Azure requires it). - **OAuth token refresh is disabled.** Azure deployments use static API keys. The `~/.claude/.credentials.json` OAuth token refresh loop that applies to Anthropic Console is explicitly skipped for Azure endpoints to prevent the Claude Code OAuth token from overwriting your Azure key mid-session. ## Alternative: `provider: anthropic` + Azure base URL If you already have `provider: anthropic` configured and just want to point it at Microsoft Foundry for Claude, you can skip the `azure-foundry` provider entirely: ```yaml model: provider: anthropic base_url: https://my-resource.services.ai.azure.com/anthropic key_env: AZURE_ANTHROPIC_KEY default: claude-sonnet-4-6 ``` With `AZURE_ANTHROPIC_KEY` set in `~/.claway/.env`. Claway detects `azure.com` in the base URL and short-circuits around the Claude Code OAuth token chain so the Azure key is used directly with `x-api-key` auth. `key_env` is the canonical snake_case field name; `api_key_env` (and the camelCase `keyEnv` / `apiKeyEnv`) are accepted as aliases. If both `key_env` and `AZURE_ANTHROPIC_KEY`/`ANTHROPIC_API_KEY` are set, the `key_env`-named env var wins. ## Model discovery Azure does **not** expose a pure-API-key endpoint to list your *deployed* model deployments. Deployment enumeration requires Azure Resource Manager authentication (`az cognitiveservices account deployment list`) with an Azure AD principal, not the inference API key. What Claway can do: - Azure OpenAI v1 endpoints (`<resource>.openai.azure.com/openai/v1`) expose `GET /models` with the resource's **available** model catalog. Claway uses this list to prefill the model picker. - Microsoft Foundry `/anthropic` routes: detected via URL path, model name entered manually. - Private / firewalled endpoints: manual entry with a friendly "couldn't probe" message. You can always type a deployment name directly — Claway does not validate against the returned list. ## Environment variables | Variable | Purpose | |----------|---------| | `AZURE_FOUNDRY_API_KEY` | Primary API key for Microsoft Foundry / Azure OpenAI (api_key mode) | | `AZURE_FOUNDRY_BASE_URL` | Endpoint URL (set via `claway model`; env var is used as a fallback) | | `AZURE_ANTHROPIC_KEY` | Used by `provider: anthropic` + Azure base URL (alternative to `ANTHROPIC_API_KEY`) | | `AZURE_TENANT_ID` | Entra ID tenant for service-principal flows | | `AZURE_CLIENT_ID` | Entra ID client ID (service principal, workload identity, or user-assigned managed identity) | | `AZURE_CLIENT_SECRET` | Service principal secret | | `AZURE_CLIENT_CERTIFICATE_PATH` | Service principal cert (alternative to secret) | | `AZURE_FEDERATED_TOKEN_FILE` | Workload Identity federated token path (AKS) | | `AZURE_AUTHORITY_HOST` | Sovereign cloud authority host override | | `IDENTITY_ENDPOINT` / `MSI_ENDPOINT` | Managed Identity endpoint for App Service, Functions, and Container Apps; VMs usually use IMDS instead | The Azure SDK reads the `AZURE_*` env vars directly. Claway never inspects them other than to report which sources are present in `claway doctor` output. ## Troubleshooting **401 Unauthorized on gpt-5.x deployments.** Azure serves gpt-5.x on `/chat/completions`, not `/responses`. Claway handles this automatically when the URL contains `openai.azure.com`, but if you see a 401 with an `Invalid API key` body, check that `api_mode` in your `config.yaml` is `chat_completions`. **404 on `/v1/messages?api-version=.../v1/messages`.** This is the malformed-URL bug from pre-fix Azure Anthropic setups. Upgrade Claway — the `api-version` parameter is now passed via `default_query` rather than baked into the base URL, so the SDK can't corrupt it during URL joining. **Wizard says "Auto-detection incomplete."** The endpoint rejected both the `/models` probe and the Anthropic Messages probe. This is normal for private endpoints behind a firewall or with an IP allow-list. Fall back to manual API mode selection and type your deployment name — everything still works, Claway just can't prefill the picker. **Wrong transport picked.** Run `claway model` again and the wizard will re-probe. If the probe still picks the wrong mode, you can edit `config.yaml` directly: ```yaml model: provider: azure-foundry api_mode: anthropic_messages # or chat_completions ``` **Entra ID: "credential chain exhausted" or 401 Unauthorized after switching to `auth_mode: entra_id`.** - Run `az login` to refresh your developer session (the cached token may have expired). - Verify the `Azure AI User` (or `Foundry User`) role assignment took effect: `az role assignment list --assignee <user-or-identity-id>` should list it on your Foundry resource. Role propagation can take up to 5 minutes. - For user-assigned managed identities, double-check `AZURE_CLIENT_ID` matches the identity attached to the compute resource. - Run `claway doctor` — the Azure Entra probe reports whether token acquisition succeeded and includes a remediation hint. **Entra ID: wizard preflight hangs or times out.** The 10 s preflight is a soft check. Choose "Save anyway and validate later" and run `claway doctor` after deploying to the target environment. Common causes include an unreachable token service or stale local login state — prefer workload identity in CI, set `AZURE_TENANT_ID`+`AZURE_CLIENT_ID`+`AZURE_CLIENT_SECRET` when using a service principal, or run `az login` for local development. **401 on Anthropic-style endpoint with Entra ID.** Verify the same `Azure AI User` (or `Foundry User`) role is assigned on the Foundry resource (it covers both `/openai/v1` and `/anthropic` paths). If the OpenAI-style probe works during the wizard but `claude-*` requests fail at runtime, the most common cause is a stale `model.entra.scope` left over from an earlier wizard run — delete the `entra.scope` line from `config.yaml` so the runtime falls back to the default `https://ai.azure.com/.default` scope. ## Related - [Environment variables](/reference/environment-variables) - [Configuration](/user-guide/configuration) - [AWS Bedrock](/guides/aws-bedrock) — the other major cloud provider integration - [Microsoft: Configure Entra ID for Foundry](https://learn.microsoft.com/azure/ai-foundry/foundry-models/how-to/configure-entra-id) — upstream documentation for the keyless path --- <!-- source: website/docs/guides/build-a-claway-plugin.md --> # Build a Claway Plugin # Build a Claway Plugin This guide walks through building a complete Claway plugin from scratch. By the end you'll have a working plugin with multiple tools, lifecycle hooks, shipped data files, and a bundled skill — everything the plugin system supports. :::info Not sure which guide you need? Claway has several distinct pluggable interfaces — some use Python `register_*` APIs, others are config-driven or drop-in directories. Use this map first: | If you want to add… | Read | |---|---| | Custom tools, hooks, slash commands, skills, or CLI subcommands | **This guide** (the general plugin surface) | | An **LLM / inference backend** (new provider) | [Model Provider Plugins](/developer-guide/model-provider-plugin) | | A **gateway channel** (Discord/Telegram/IRC/Teams/etc.) | Adding Platform Adapters | | A **memory backend** (Honcho/Mem0/Supermemory/etc.) | [Memory Provider Plugins](/developer-guide/memory-provider-plugin) | | A **context-compression engine** | [Context Engine Plugins](/developer-guide/context-engine-plugin) | | An **image-generation backend** | [Image Generation Provider Plugins](/developer-guide/image-gen-provider-plugin) | | A **video-generation backend** | [Video Generation Provider Plugins](/developer-guide/video-gen-provider-plugin) | | A **TTS backend** (any CLI — Piper, VoxCPM, Kokoro, voice cloning, …) | [TTS custom command providers](/user-guide/features/tts#custom-command-providers) — config-driven, no Python needed | | An **STT backend** (custom whisper / ASR CLI) | [Voice Message Transcription](/user-guide/features/tts#voice-message-transcription-stt) — set `CLAWAY_LOCAL_STT_COMMAND` to a shell template | | **External tools via MCP** (filesystem, GitHub, Linear, any MCP server) | [MCP](/user-guide/features/mcp) — declare `mcp_servers.<name>` in `config.yaml` | | **Gateway event hooks** (fire on startup, session events, commands) | [Event Hooks](/user-guide/features/hooks#gateway-event-hooks) — drop `HOOK.yaml` + `handler.py` into `~/.claway/hooks/<name>/` | | **Shell hooks** (run a shell command on events) | [Shell Hooks](/user-guide/features/hooks#shell-hooks) — declare under `hooks:` in `config.yaml` | | **Additional skill sources** (custom GitHub repos, private skill indexes) | [Skills](/user-guide/features/skills) — `claway skills tap add <repo>` · [Publishing a tap](/user-guide/features/skills#publishing-a-custom-skill-tap) | | A first-class **core** inference provider (not a plugin) | Adding Providers | See the full [Pluggable interfaces table](/user-guide/features/plugins#pluggable-interfaces--where-to-go-for-each) for a consolidated view of every extension surface including config-driven (TTS, STT, MCP, shell hooks) and drop-in directory (gateway hooks) styles. ::: :::caution Third-party-product plugins ship standalone — not into the core tree Plugins that integrate **someone else's product or project** — observability/metrics backends, vendor SaaS connectors, analytics dashboards, paid-service tie-ins — are built and distributed as **standalone plugin repos**, not merged into Claway itself. Users install them into `~/.claway/plugins/` or via a pip entry point; everything in this guide works the same way from a standalone repo. This is a coupling-and-maintenance decision (the core moves fast and we don't own your backend), not a quality bar — a plugin can be excellent and still belong in its own repo. Promote it in the Blockway Discord `#plugins-skills-and-skins` channel. See CONTRIBUTING.md for the policy. ::: ## What you're building A **calculator** plugin with two tools: - `calculate` — evaluate math expressions (`2**16`, `sqrt(144)`, `pi * 5**2`) - `unit_convert` — convert between units (`100 F → 37.78 C`, `5 km → 3.11 mi`) Plus a hook that logs every tool call, and a bundled skill file. ## Step 1: Create the plugin directory ```bash mkdir -p ~/.claway/plugins/calculator cd ~/.claway/plugins/calculator ``` ## Step 2: Write the manifest Create `plugin.yaml`: ```yaml name: calculator version: 1.0.0 description: Math calculator — evaluate expressions and convert units provides_tools: - calculate - unit_convert provides_hooks: - post_tool_call ``` This tells Claway: "I'm a plugin called calculator, I provide tools and hooks." The `provides_tools` and `provides_hooks` fields are lists of what the plugin registers. Optional fields you could add: ```yaml author: Your Name requires_env: # gate loading on env vars; prompted during install - SOME_API_KEY # simple format — plugin disabled if missing - name: OTHER_KEY # rich format — shows description/url during install description: "Key for the Other service" url: "https://other.com/keys" secret: true ``` ## Step 3: Write the tool schemas Create `schemas.py` — this is what the LLM reads to decide when to call your tools: ```python """Tool schemas — what the LLM sees.""" CALCULATE = { "name": "calculate", "description": ( "Evaluate a mathematical expression and return the result. " "Supports arithmetic (+, -, *, /, **), functions (sqrt, sin, cos, " "log, abs, round, floor, ceil), and constants (pi, e). " "Use this for any math the user asks about." ), "parameters": { "type": "object", "properties": { "expression": { "type": "string", "description": "Math expression to evaluate (e.g., '2**10', 'sqrt(144)')", }, }, "required": ["expression"], }, } UNIT_CONVERT = { "name": "unit_convert", "description": ( "Convert a value between units. Supports length (m, km, mi, ft, in), " "weight (kg, lb, oz, g), temperature (C, F, K), data (B, KB, MB, GB, TB), " "and time (s, min, hr, day)." ), "parameters": { "type": "object", "properties": { "value": { "type": "number", "description": "The numeric value to convert", }, "from_unit": { "type": "string", "description": "Source unit (e.g., 'km', 'lb', 'F', 'GB')", }, "to_unit": { "type": "string", "description": "Target unit (e.g., 'mi', 'kg', 'C', 'MB')", }, }, "required": ["value", "from_unit", "to_unit"], }, } ``` **Why schemas matter:** The `description` field is how the LLM decides when to use your tool. Be specific about what it does and when to use it. The `parameters` define what arguments the LLM passes. ## Step 4: Write the tool handlers Create `tools.py` — this is the code that actually executes when the LLM calls your tools: ```python """Tool handlers — the code that runs when the LLM calls each tool.""" import json import math # Safe globals for expression evaluation — no file/network access _SAFE_MATH = { "abs": abs, "round": round, "min": min, "max": max, "pow": pow, "sqrt": math.sqrt, "sin": math.sin, "cos": math.cos, "tan": math.tan, "log": math.log, "log2": math.log2, "log10": math.log10, "floor": math.floor, "ceil": math.ceil, "pi": math.pi, "e": math.e, "factorial": math.factorial, } def calculate(args: dict, **kwargs) -> str: """Evaluate a math expression safely. Rules for handlers: 1. Receive args (dict) — the parameters the LLM passed 2. Do the work 3. Return a JSON string — ALWAYS, even on error 4. Accept **kwargs for forward compatibility """ expression = args.get("expression", "").strip() if not expression: return json.dumps({"error": "No expression provided"}) try: result = eval(expression, {"__builtins__": {}}, _SAFE_MATH) return json.dumps({"expression": expression, "result": result}) except ZeroDivisionError: return json.dumps({"expression": expression, "error": "Division by zero"}) except Exception as e: return json.dumps({"expression": expression, "error": f"Invalid: {e}"}) # Conversion tables — values are in base units _LENGTH = {"m": 1, "km": 1000, "mi": 1609.34, "ft": 0.3048, "in": 0.0254, "cm": 0.01} _WEIGHT = {"kg": 1, "g": 0.001, "lb": 0.453592, "oz": 0.0283495} _DATA = {"B": 1, "KB": 1024, "MB": 1024**2, "GB": 1024**3, "TB": 1024**4} _TIME = {"s": 1, "ms": 0.001, "min": 60, "hr": 3600, "day": 86400} def _convert_temp(value, from_u, to_u): # Normalize to Celsius c = {"F": (value - 32) * 5/9, "K": value - 273.15}.get(from_u, value) # Convert to target return {"F": c * 9/5 + 32, "K": c + 273.15}.get(to_u, c) def unit_convert(args: dict, **kwargs) -> str: """Convert between units.""" value = args.get("value") from_unit = args.get("from_unit", "").strip() to_unit = args.get("to_unit", "").strip() if value is None or not from_unit or not to_unit: return json.dumps({"error": "Need value, from_unit, and to_unit"}) try: # Temperature if from_unit.upper() in {"C","F","K"} and to_unit.upper() in {"C","F","K"}: result = _convert_temp(float(value), from_unit.upper(), to_unit.upper()) return json.dumps({"input": f"{value} {from_unit}", "result": round(result, 4), "output": f"{round(result, 4)} {to_unit}"}) # Ratio-based conversions for table in (_LENGTH, _WEIGHT, _DATA, _TIME): lc = {k.lower(): v for k, v in table.items()} if from_unit.lower() in lc and to_unit.lower() in lc: result = float(value) * lc[from_unit.lower()] / lc[to_unit.lower()] return json.dumps({"input": f"{value} {from_unit}", "result": round(result, 6), "output": f"{round(result, 6)} {to_unit}"}) return json.dumps({"error": f"Cannot convert {from_unit} → {to_unit}"}) except Exception as e: return json.dumps({"error": f"Conversion failed: {e}"}) ``` **Key rules for handlers:** 1. **Signature:** `def my_handler(args: dict, **kwargs) -> str` 2. **Return:** Always a JSON string. Success and errors alike. 3. **Never raise:** Catch all exceptions, return error JSON instead. 4. **Accept `**kwargs`:** Claway may pass additional context in the future. ## Step 5: Write the registration Create `__init__.py` — this wires schemas to handlers: ```python """Calculator plugin — registration.""" import logging from . import schemas, tools logger = logging.getLogger(__name__) # Track tool usage via hooks _call_log = [] def _on_post_tool_call(tool_name, args, result, task_id, **kwargs): """Hook: runs after every tool call (not just ours).""" _call_log.append({"tool": tool_name, "session": task_id}) if len(_call_log) > 100: _call_log.pop(0) logger.debug("Tool called: %s (session %s)", tool_name, task_id) def register(ctx): """Wire schemas to handlers and register hooks.""" ctx.register_tool(name="calculate", toolset="calculator", schema=schemas.CALCULATE, handler=tools.calculate) ctx.register_tool(name="unit_convert", toolset="calculator", schema=schemas.UNIT_CONVERT, handler=tools.unit_convert) # This hook fires for ALL tool calls, not just ours ctx.register_hook("post_tool_call", _on_post_tool_call) ``` **What `register()` does:** - Called exactly once at startup - `ctx.register_tool()` puts your tool in the registry — the model sees it immediately - `ctx.register_hook()` subscribes to lifecycle events - `ctx.register_cli_command()` registers a CLI subcommand (e.g. `claway my-plugin <subcommand>`) - `ctx.register_command()` registers an in-session slash command (e.g. `/myplugin <args>` inside CLI / gateway chat) — see [Register slash commands](#register-slash-commands) below - `ctx.dispatch_tool(name, arguments)` — call any other tool (built-in or from another plugin) with the parent agent's context (approvals, credentials, task_id) wired up automatically. Useful from slash-command handlers that need to invoke `terminal`, `read_file`, or any other tool as if the model had called it directly. - If this function crashes, the plugin is disabled but Claway continues fine **`dispatch_tool` example — a slash command that runs a tool:** ```python def handle_scan(ctx, raw_args: str): """Implement /scan by invoking the terminal tool through the registry.""" result = ctx.dispatch_tool("terminal", {"command": f"find . -name '{raw_args}'"}) return result # returned to the caller's chat UI def register(ctx): # Handlers receive a single raw_args string; close over ctx via a lambda. ctx.register_command( "scan", lambda raw: handle_scan(ctx, raw), description="Find files matching a glob", ) ``` The dispatched tool goes through the normal approval, redaction, and budget pipelines — it's a real tool invocation, not a shortcut around them. ## Step 6: Test it Start Claway: ```bash claway ``` You should see `calculator: calculate, unit_convert` in the banner's tool list. Try these prompts: ``` What's 2 to the power of 16? Convert 100 fahrenheit to celsius What's the square root of 2 times pi? How many gigabytes is 1.5 terabytes? ``` Check plugin status: ``` /plugins ``` Output: ``` Plugins (1): ✓ calculator v1.0.0 (2 tools, 1 hooks) ``` ### Debugging plugin discovery If your plugin doesn't show up — or shows up but isn't loading — set `CLAWAY_PLUGINS_DEBUG=1` to get verbose discovery logs on stderr: ```bash CLAWAY_PLUGINS_DEBUG=1 claway plugins list ``` You'll see, for every plugin source (bundled, user, project, entry-points): - which directories were scanned and how many manifests each yielded - per manifest: resolved key, name, kind, source, on-disk path - skip reasons: `disabled via config`, `not enabled in config`, `exclusive plugin`, `no plugin.yaml, depth cap reached` - on load: the plugin being imported, plus a one-line summary of what `register(ctx)` registered (tools, hooks, slash commands, CLI commands) - on parse failure: a full traceback for the exception (YAML scanner errors, etc.) - on `register()` failure: a full traceback pointing at the line in your `__init__.py` that raised The same logs are always written to `~/.claway/logs/agent.log` at WARNING level (failures only) and DEBUG level (everything) when the env var is set. So if you can't run with the env var (e.g. from inside the gateway), tail the log file instead: ```bash claway logs --level WARNING | grep -i plugin ``` Common reasons a plugin doesn't appear: - **Not enabled in config** — plugins are opt-in. Run `claway plugins enable <name>` (the name comes from the `plugins list` output, which can be `<category>/<plugin>` for nested layouts). - **Wrong directory layout** — must be `~/.claway/plugins/<plugin-name>/plugin.yaml` (flat) or `~/.claway/plugins/<category>/<plugin-name>/plugin.yaml` (one level of category nesting, max). Anything deeper is ignored. - **Missing `__init__.py`** — the plugin directory needs both `plugin.yaml` and `__init__.py` with a `register(ctx)` function. - **Wrong `kind`** — gateway adapters need `kind: platform` in their manifest. Memory providers are auto-detected as `kind: exclusive` and routed through the `memory.provider` config instead of `plugins.enabled`. ## Your plugin's final structure ``` ~/.claway/plugins/calculator/ ├── plugin.yaml # "I'm calculator, I provide tools and hooks" ├── __init__.py # Wiring: schemas → handlers, register hooks ├── schemas.py # What the LLM reads (descriptions + parameter specs) └── tools.py # What runs (calculate, unit_convert functions) ``` Four files, clear separation: - **Manifest** declares what the plugin is - **Schemas** describe tools for the LLM - **Handlers** implement the actual logic - **Registration** connects everything ## What else can plugins do? ### Ship data files Put any files in your plugin directory and read them at import time: ```python # In tools.py or __init__.py from pathlib import Path _PLUGIN_DIR = Path(__file__).parent _DATA_FILE = _PLUGIN_DIR / "data" / "languages.yaml" with open(_DATA_FILE) as f: _DATA = yaml.safe_load(f) ``` ### Bundle skills Plugins can ship skill files that the agent loads via `skill_view("plugin:skill")`. Register them in your `__init__.py`: ``` ~/.claway/plugins/my-plugin/ ├── __init__.py ├── plugin.yaml └── skills/ ├── my-workflow/ │ └── SKILL.md └── my-checklist/ └── SKILL.md ``` ```python from pathlib import Path def register(ctx): skills_dir = Path(__file__).parent / "skills" for child in sorted(skills_dir.iterdir()): skill_md = child / "SKILL.md" if child.is_dir() and skill_md.exists(): ctx.register_skill(child.name, skill_md) ``` The agent can now load your skills with their namespaced name: ```python skill_view("my-plugin:my-workflow") # → plugin's version skill_view("my-workflow") # → built-in version (unchanged) ``` **Key properties:** - Plugin skills are **read-only** — they don't enter `~/.claway/skills/` and can't be edited via `skill_manage`. - Plugin skills are **not** listed in the system prompt's `<available_skills>` index — they're opt-in explicit loads. - Bare skill names are unaffected — the namespace prevents collisions with built-in skills. - When the agent loads a plugin skill, a bundle context banner is prepended listing sibling skills from the same plugin. :::tip Legacy pattern The old `shutil.copy2` pattern (copying a skill into `~/.claway/skills/`) still works but creates name collision risk with built-in skills. Prefer `ctx.register_skill()` for new plugins. ::: ### Gate on environment variables If your plugin needs an API key: ```yaml # plugin.yaml — simple format (backwards-compatible) requires_env: - WEATHER_API_KEY ``` If `WEATHER_API_KEY` isn't set, the plugin is disabled with a clear message. No crash, no error in the agent — just "Plugin weather disabled (missing: WEATHER_API_KEY)". When users run `claway plugins install`, they're **prompted interactively** for any missing `requires_env` variables. Values are saved to `.env` automatically. For a better install experience, use the rich format with descriptions and signup URLs: ```yaml # plugin.yaml — rich format requires_env: - name: WEATHER_API_KEY description: "API key for OpenWeather" url: "https://openweathermap.org/api" secret: true ``` | Field | Required | Description | |-------|----------|-------------| | `name` | Yes | Environment variable name | | `description` | No | Shown to user during install prompt | | `url` | No | Where to get the credential | | `secret` | No | If `true`, input is hidden (like a password field) | Both formats can be mixed in the same list. Already-set variables are skipped silently. ### Lazy-install optional Python dependencies If your plugin wraps an SDK that not every user will have installed (a vendor SDK, a heavy ML lib, a platform-specific package), don't `import` it at the top of the module. Use the `tools.lazy_deps.ensure(...)` helper inside the tool handler — Claway will install the package on first use, gated by the user's `security.allow_lazy_installs` config. ```python # tools.py from tools.lazy_deps import ensure, FeatureUnavailable def my_tool_handler(args, **kwargs): try: ensure("my-plugin.my-backend") # key must be in LAZY_DEPS except FeatureUnavailable as exc: return {"error": str(exc)} import my_backend_sdk # safe now ... ``` Two rules from the security model in `tools/lazy_deps.py`: | Rule | Why | |---|---| | Your feature key must appear in the in-tree `LAZY_DEPS` allowlist | Prevents a malicious config from coaxing Claway into installing arbitrary packages — only specs Claway itself ships are eligible | | Specs are PyPI-by-name only | No `--index-url`, `git+https://`, or file: paths. Pin versions with PEP 440 (`"my-sdk>=1.2,<2"`) inside the allowlist entry | For third-party plugins distributed via pip, declare the optional deps as `[project.optional-dependencies]` extras in your own `pyproject.toml` and tell users to `pip install your-plugin[backend]` — that path doesn't go through `lazy_deps`. The lazy-install dance is most useful for **bundled** plugins where shipping a hard dependency on every install would bloat the base Claway footprint. When `security.allow_lazy_installs: false` is set globally, `ensure()` raises `FeatureUnavailable` immediately with a remediation hint — your plugin should catch it and degrade gracefully (return an error result, not crash the tool loop). ### Thread-safe lazy singletons Plugins often cache an expensive object — an SDK client, an HTTP session, a connection pool — in a module-level variable built on first use: ```python _client = None def get_client(): global _client if _client is not None: return _client _client = ExpensiveClient(...) # ← TOCTOU race return _client ``` This is a footgun. Claway runs multiple threads in one process (delegated tool calls, background workers, the self-improvement fork), so two threads can hit `get_client()` before `_client` is set, **both** pass the `is not None` check, **both** run the expensive build, and the second write clobbers the first — leaking whatever resource the loser opened (connection, file handle, background thread). Don't hand-roll the lock. Use the helpers in `plugins/plugin_utils.py`: ```python from plugins.plugin_utils import lazy_singleton, SingletonSlot # Zero-arg accessor → decorate it: @lazy_singleton def get_client(): return ExpensiveClient(load_config()) # runs exactly once client = get_client() # safe across threads get_client.reset() # drop the instance (tests / teardown) # Accessor that takes a build argument → use a slot: _slot: SingletonSlot = SingletonSlot() def get_client(config=None): return _slot.get(lambda: ExpensiveClient(resolve(config))) def reset_client(): _slot.reset() ``` Both serialize concurrent first calls with double-checked locking and run the factory at most once. If the factory raises, nothing is cached and the next call retries. The honcho memory plugin (`plugins/memory/honcho/client.py`) is the reference consumer. > Rule of thumb: any time you write `global _something` followed by a `is None` check and a build, reach for one of these instead. ### Conditional tool availability For tools that depend on optional libraries: ```python ctx.register_tool( name="my_tool", schema={...}, handler=my_handler, check_fn=lambda: _has_optional_lib(), # False = tool hidden from model ) ``` ### Overriding a built-in tool To replace a built-in tool with your own implementation (e.g. swap the default browser tool for a headed-Chrome CDP backend, or replace `web_search` with a custom corporate index), pass `override=True`: ```python def register(ctx): ctx.register_tool( name="browser_navigate", # same name as the built-in toolset="plugin_my_browser", # your own toolset namespace schema={...}, handler=my_custom_navigate, override=True, # explicit opt-in ) ``` Without `override=True`, the registry rejects any registration that would shadow an existing tool from a different toolset — this prevents accidental overwrites. The override is logged at INFO level so it's auditable in `~/.claway/logs/agent.log`. Plugins load after built-in tools, so the registration order is correct: your handler replaces the built-in one. ### Register multiple hooks ```python def register(ctx): ctx.register_hook("pre_tool_call", before_any_tool) ctx.register_hook("post_tool_call", after_any_tool) ctx.register_hook("pre_llm_call", inject_memory) ctx.register_hook("on_session_start", on_new_session) ctx.register_hook("on_session_end", on_session_end) ``` ### Hook reference Each hook is documented in full on the **[Event Hooks reference](/user-guide/features/hooks#plugin-hooks)** — callback signatures, parameter tables, exactly when each fires, and examples. Here's the summary: | Hook | Fires when | Callback signature | Returns | |------|-----------|-------------------|---------| | [`pre_tool_call`](/user-guide/features/hooks#pre_tool_call) | Before any tool executes | `tool_name: str, args: dict, task_id: str` | ignored | | [`post_tool_call`](/user-guide/features/hooks#post_tool_call) | After any tool returns | `tool_name: str, args: dict, result: str, task_id: str, duration_ms: int` | ignored | | [`pre_llm_call`](/user-guide/features/hooks#pre_llm_call) | Once per turn, before the tool-calling loop | `session_id: str, user_message: str, conversation_history: list, is_first_turn: bool, model: str, platform: str` | [context injection](#pre_llm_call-context-injection) | | [`post_llm_call`](/user-guide/features/hooks#post_llm_call) | Once per turn, after the tool-calling loop (successful turns only) | `session_id: str, user_message: str, assistant_response: str, conversation_history: list, model: str, platform: str` | ignored | | [`on_session_start`](/user-guide/features/hooks#on_session_start) | New session created (first turn only) | `session_id: str, model: str, platform: str` | ignored | | [`on_session_end`](/user-guide/features/hooks#on_session_end) | End of every `run_conversation` call + CLI exit | `session_id: str, completed: bool, interrupted: bool, model: str, platform: str` | ignored | | [`on_session_finalize`](/user-guide/features/hooks#on_session_finalize) | CLI/gateway tears down an active session | `session_id: str \| None, platform: str` | ignored | | [`on_session_reset`](/user-guide/features/hooks#on_session_reset) | Gateway swaps in a new session key (`/new`, `/reset`) | `session_id: str, platform: str` | ignored | | `kanban_task_claimed` | A kanban task is claimed (dispatcher process, before the worker spawns) | `task_id: str, board: str \| None, assignee: str \| None, run_id: int \| None, profile_name: str` | ignored | | `kanban_task_completed` | A kanban task completes (worker process) | `task_id, board, assignee, run_id, profile_name, summary: str \| None` | ignored | | `kanban_task_blocked` | A kanban task is blocked (worker process) | `task_id, board, assignee, run_id, profile_name, reason: str \| None` | ignored | Most hooks are fire-and-forget observers — their return values are ignored. The exception is `pre_llm_call`, which can inject context into the conversation. All callbacks should accept `**kwargs` for forward compatibility. If a hook callback crashes, it's logged and skipped. Other hooks and the agent continue normally. The kanban lifecycle hooks fire **after** the board DB change commits, so a callback always sees durable state and can never hold the SQLite write lock. Because kanban workers run as separate `claway -p <profile> chat -q` subprocesses, `kanban_task_claimed` fires in the **dispatcher** process while `kanban_task_completed` / `kanban_task_blocked` fire in the **worker** process — hook in the dispatcher to observe every transition centrally, or in the worker for per-task in-session context. ### `pre_llm_call` context injection This is the only hook whose return value matters. When a `pre_llm_call` callback returns a dict with a `"context"` key (or a plain string), Claway injects that text into the **current turn's user message**. This is the mechanism for memory plugins, RAG integrations, guardrails, and any plugin that needs to provide the model with additional context. #### Return format ```python # Dict with context key return {"context": "Recalled memories:\n- User prefers dark mode\n- Last project: claway"} # Plain string (equivalent to the dict form above) return "Recalled memories:\n- User prefers dark mode" # Return None or don't return → no injection (observer-only) return None ``` Any non-None, non-empty return with a `"context"` key (or a plain non-empty string) is collected and appended to the user message for the current turn. #### How injection works Injected context is appended to the **user message**, not the system prompt. This is a deliberate design choice: - **Prompt cache preservation** — the system prompt stays identical across turns. Anthropic and OpenRouter cache the system prompt prefix, so keeping it stable saves 75%+ on input tokens in multi-turn conversations. If plugins modified the system prompt, every turn would be a cache miss. - **Ephemeral** — the injection happens at API call time only. The original user message in the conversation history is never mutated, and nothing is persisted to the session database. - **The system prompt is Claway's territory** — it contains model-specific guidance, tool enforcement rules, personality instructions, and cached skill content. Plugins contribute context alongside the user's input, not by altering the agent's core instructions. #### Example: Memory recall plugin ```python """Memory plugin — recalls relevant context from a vector store.""" import httpx MEMORY_API = "https://your-memory-api.example.com" def recall_context(session_id, user_message, is_first_turn, **kwargs): """Called before each LLM turn. Returns recalled memories.""" try: resp = httpx.post(f"{MEMORY_API}/recall", json={ "session_id": session_id, "query": user_message, }, timeout=3) memories = resp.json().get("results", []) if not memories: return None # nothing to inject text = "Recalled context from previous sessions:\n" text += "\n".join(f"- {m['text']}" for m in memories) return {"context": text} except Exception: return None # fail silently, don't break the agent def register(ctx): ctx.register_hook("pre_llm_call", recall_context) ``` #### Example: Guardrails plugin ```python """Guardrails plugin — enforces content policies.""" POLICY = """You MUST follow these content policies for this session: - Never generate code that accesses the filesystem outside the working directory - Always warn before executing destructive operations - Refuse requests involving personal data extraction""" def inject_guardrails(**kwargs): """Injects policy text into every turn.""" return {"context": POLICY} def register(ctx): ctx.register_hook("pre_llm_call", inject_guardrails) ``` #### Example: Observer-only hook (no injection) ```python """Analytics plugin — tracks turn metadata without injecting context.""" import logging logger = logging.getLogger(__name__) def log_turn(session_id, user_message, model, is_first_turn, **kwargs): """Fires before each LLM call. Returns None — no context injected.""" logger.info("Turn: session=%s model=%s first=%s msg_len=%d", session_id, model, is_first_turn, len(user_message or "")) # No return → no injection def register(ctx): ctx.register_hook("pre_llm_call", log_turn) ``` #### Multiple plugins returning context When multiple plugins return context from `pre_llm_call`, their outputs are joined with double newlines and appended to the user message together. The order follows plugin discovery order (alphabetical by plugin directory name). ### Register CLI commands Plugins can add their own `claway <plugin>` subcommand tree: ```python def _my_command(args): """Handler for claway my-plugin <subcommand>.""" sub = getattr(args, "my_command", None) if sub == "status": print("All good!") elif sub == "config": print("Current config: ...") else: print("Usage: claway my-plugin <status|config>") def _setup_argparse(subparser): """Build the argparse tree for claway my-plugin.""" subs = subparser.add_subparsers(dest="my_command") subs.add_parser("status", help="Show plugin status") subs.add_parser("config", help="Show plugin config") subparser.set_defaults(func=_my_command) def register(ctx): ctx.register_tool(...) ctx.register_cli_command( name="my-plugin", help="Manage my plugin", setup_fn=_setup_argparse, handler_fn=_my_command, ) ``` After registration, users can run `claway my-plugin status`, `claway my-plugin config`, etc. **Memory provider plugins** use a convention-based approach instead: add a `register_cli(subparser)` function to your plugin's `cli.py` file. The memory plugin discovery system finds it automatically — no `ctx.register_cli_command()` call needed. See the [Memory Provider Plugin guide](/developer-guide/memory-provider-plugin#adding-cli-commands) for details. **Active-provider gating:** Memory plugin CLI commands only appear when their provider is the active `memory.provider` in config. If a user hasn't set up your provider, your CLI commands won't clutter the help output. ### Register slash commands Plugins can register in-session slash commands — commands users type during a conversation (like `/lcm status` or `/ping`). These work in both CLI and gateway (Telegram, Discord, etc.). ```python def _handle_status(raw_args: str) -> str: """Handler for /mystatus — called with everything after the command name.""" if raw_args.strip() == "help": return "Usage: /mystatus [help|check]" return "Plugin status: all systems nominal" def register(ctx): ctx.register_command( "mystatus", handler=_handle_status, description="Show plugin status", ) ``` After registration, users can type `/mystatus` in any session. The command appears in autocomplete, `/help` output, and the Telegram bot menu. **Signature:** `ctx.register_command(name: str, handler: Callable, description: str = "", args_hint: str = "")` | Parameter | Type | Description | |-----------|------|-------------| | `name` | `str` | Command name without the leading slash (e.g. `"lcm"`, `"mystatus"`) | | `handler` | `Callable[[str], str \| None]` | Called with the raw argument string. May also be `async`. | | `description` | `str` | Shown in `/help`, autocomplete, and Telegram bot menu | **Key differences from `register_cli_command()`:** | | `register_command()` | `register_cli_command()` | |---|---|---| | Invoked as | `/name` in a session | `claway name` in a terminal | | Where it works | CLI sessions, Telegram, Discord, etc. | Terminal only | | Handler receives | Raw args string | argparse `Namespace` | | Use case | Diagnostics, status, quick actions | Complex subcommand trees, setup wizards | **Conflict protection:** If a plugin tries to register a name that conflicts with a built-in command (`help`, `model`, `new`, etc.), the registration is silently rejected with a log warning. Built-in commands always take precedence. **Async handlers:** The gateway dispatch automatically detects and awaits async handlers, so you can use either sync or async functions: ```python async def _handle_check(raw_args: str) -> str: result = await some_async_operation() return f"Check result: {result}" def register(ctx): ctx.register_command("check", handler=_handle_check, description="Run async check") ``` ### Dispatch tools from slash commands Slash command handlers that need to orchestrate tools (spawn a subagent via `delegate_task`, call `file_edit`, etc.) should use `ctx.dispatch_tool()` instead of reaching into framework internals. The parent-agent context (workspace hints, spinner, model inheritance) is wired up automatically. ```python def register(ctx): def _handle_deliver(raw_args: str): result = ctx.dispatch_tool( "delegate_task", { "goal": raw_args, "toolsets": ["terminal", "file", "web"], }, ) return result ctx.register_command( "deliver", handler=_handle_deliver, description="Delegate a goal to a subagent", ) ``` **Signature:** `ctx.dispatch_tool(name: str, args: dict, *, parent_agent=None) -> str` | Parameter | Type | Description | |-----------|------|-------------| | `name` | `str` | Tool name as registered in the tool registry (e.g. `"delegate_task"`, `"file_edit"`) | | `args` | `dict` | Tool arguments, same shape the model would send | | `parent_agent` | `Agent \| None` | Optional override. When omitted, resolves from the current CLI agent (or degrades gracefully in gateway mode) | **Runtime behavior:** - **CLI mode:** `parent_agent` is resolved from the active CLI agent so workspace hints, spinner, and model selection inherit as expected. - **Gateway mode:** There is no CLI agent, so tools degrade gracefully — workspace is read from the configured terminal working directory and no spinner is shown. - **Explicit override:** If the caller passes `parent_agent=` explicitly, it is respected and not overwritten. This is the public, stable interface for tool dispatch from plugin commands. Plugins should not reach into `ctx._cli_ref.agent` or similar private state. ### Act from inside a hook (profile + tools) `ctx._cli_ref` is only populated in an **interactive CLI** session. It is `None` in the gateway, in non-interactive `claway chat -q` runs, and in **kanban-spawned worker sessions** — so any plugin logic that reaches through `_cli_ref` silently no-ops in exactly those contexts. Two stable, session-agnostic APIs cover what hooks actually need: - **`ctx.profile_name`** — the active profile name (e.g. `"default"`, or the assignee profile in a kanban worker). Derived from `CLAWAY_HOME`, so it works everywhere with no `_cli_ref` dependency. - **`ctx.dispatch_tool(name, args)`** — invoke any registered tool (built-in or plugin), including the `kanban_*` tools, `delegate_task`, `terminal`, `read_file`, etc. Works from hook callbacks regardless of which process the hook fires in. Together these let a kanban lifecycle hook observe a transition and act on the board without touching framework internals: ```python def register(ctx): def on_blocked(*, task_id, reason=None, **kw): # Runs in the worker process; ctx._cli_ref is None here. ctx.dispatch_tool("kanban_comment", { "task_id": task_id, "comment": f"[{ctx.profile_name}] auto-noted block: {reason}", }) ctx.register_hook("kanban_task_blocked", on_blocked) ``` For running a full `claway <subcommand>` (e.g. `claway kanban show`), shell out with the `terminal` tool via `ctx.dispatch_tool("terminal", {"command": "claway kanban show ..."})` — there is no in-process slash-command bridge for headless worker sessions, and tools are the supported way to drive Claway from a hook. ### Handle Slack Block Kit button clicks Plugins that post Block Kit messages with interactive elements (buttons, overflow menus, datepickers, etc.) can register the click handlers directly with the Slack adapter — no monkey-patching of `slack_bolt.AsyncApp` required. ```python def register(ctx): async def _on_approve(ack, body, action): # ack within 3 seconds — slack_bolt requirement. await ack() # body["channel"]["id"], body["user"]["id"], body["message"]["ts"] # action["action_id"], action["value"] sweep_id = (action.get("value") or "").split("|", 1)[-1] # ...do the deterministic work, then post a follow-up. ctx.register_slack_action_handler("inbox_sweep_approve", _on_approve) ``` **Signature:** `ctx.register_slack_action_handler(action_id, callback) -> None` | Parameter | Type | Description | |-----------|------|-------------| | `action_id` | `str \| re.Pattern \| dict` | Whatever `slack_bolt.App.action()` accepts: a literal `action_id`, a compiled regex matching multiple ids, or a constraint dict like `{"action_id": "...", "block_id": "..."}` | | `callback` | async callable | Receives `(ack, body, action)` per the slack_bolt convention | **Runtime behavior:** - The handler is queued at plugin-load time and wired into the adapter's `slack_bolt.AsyncApp` when the Slack platform connects. - Each callback is wrapped defensively: if your handler raises, the gateway logs the error and best-effort-acks the click so Slack stops retrying. - Standard slack_bolt rules apply — `await ack()` within 3 seconds, then do longer work. - For multi-workspace deployments the handler fires for clicks from any connected workspace; use `body["team"]["id"]` if you need to scope behaviour. This is the public way for plugins to participate in Slack interactivity. Older plugins may patch `SlackAdapter.connect`; prefer this API instead. :::tip This guide covers **general plugins** (tools, hooks, slash commands, CLI commands). The sections below sketch the authoring pattern for each specialized plugin type; each links to its full guide for field reference and examples. ::: ## Specialized plugin types Claway has five specialized plugin types beyond the general surface. Each ships as a directory under `plugins/<category>/<name>/` (bundled) or `~/.claway/plugins/<category>/<name>/` (user). The contract differs by category — pick the one you need, then read its full guide. ### Model provider plugins — add an LLM backend Drop a profile into `plugins/model-providers/<name>/`: ```python # plugins/model-providers/acme/__init__.py from providers import register_provider from providers.base import ProviderProfile register_provider(ProviderProfile( name="acme", aliases=("acme-inference",), display_name="Acme Inference", env_vars=("ACME_API_KEY", "ACME_BASE_URL"), base_url="https://api.acme.example.com/v1", auth_type="api_key", default_aux_model="acme-small-fast", fallback_models=("acme-large-v3", "acme-medium-v3"), )) ``` ```yaml # plugins/model-providers/acme/plugin.yaml name: acme-provider kind: model-provider version: 1.0.0 description: Acme Inference — OpenAI-compatible direct API ``` Lazy-discovered the first time anything calls `get_provider_profile()` or `list_providers()` — `auth.py`, `config.py`, `doctor.py`, `models.py`, `runtime_provider.py`, and the chat_completions transport auto-wire to it. User plugins override bundled ones by name. **Full guide:** [Model Provider Plugins](/developer-guide/model-provider-plugin) — field reference, overridable hooks (`prepare_messages`, `build_extra_body`, `build_api_kwargs_extras`, `fetch_models`), api_mode selection, auth types, testing. ### Platform plugins — add a gateway channel Drop an adapter into `plugins/platforms/<name>/`: ```python # plugins/platforms/myplatform/adapter.py from gateway.platforms.base import BasePlatformAdapter class MyPlatformAdapter(BasePlatformAdapter): async def connect(self): ... async def send(self, chat_id, text): ... async def disconnect(self): ... def check_requirements(): import os return bool(os.environ.get("MYPLATFORM_TOKEN")) def _env_enablement(): import os tok = os.getenv("MYPLATFORM_TOKEN", "").strip() if not tok: return None return {"token": tok} def register(ctx): ctx.register_platform( name="myplatform", label="MyPlatform", adapter_factory=lambda cfg: MyPlatformAdapter(cfg), check_fn=check_requirements, required_env=["MYPLATFORM_TOKEN"], # Auto-populate PlatformConfig.extra from env so env-only setups # show up in `claway gateway status` without SDK instantiation. env_enablement_fn=_env_enablement, # Opt in to cron delivery: `deliver=myplatform` routes to this var. cron_deliver_env_var="MYPLATFORM_HOME_CHANNEL", emoji="💬", platform_hint="You are chatting via MyPlatform. Keep responses concise.", ) ``` ```yaml # plugins/platforms/myplatform/plugin.yaml name: myplatform-platform label: MyPlatform kind: platform version: 1.0.0 description: MyPlatform gateway adapter requires_env: - name: MYPLATFORM_TOKEN description: "Bot token from the MyPlatform console" password: true optional_env: - name: MYPLATFORM_HOME_CHANNEL description: "Default channel for cron delivery" password: false ``` **Full guide:** Adding Platform Adapters — complete `BasePlatformAdapter` contract, message routing, auth gating, setup wizard integration. Look at `plugins/platforms/irc/` for a stdlib-only working example. ### Memory provider plugins — add a cross-session knowledge backend Drop an implementation of `MemoryProvider` into `plugins/memory/<name>/`: ```python # plugins/memory/my-memory/__init__.py from agent.memory_provider import MemoryProvider class MyMemoryProvider(MemoryProvider): @property def name(self) -> str: return "my-memory" def is_available(self) -> bool: import os return bool(os.environ.get("MY_MEMORY_API_KEY")) def initialize(self, session_id: str, **kwargs) -> None: self._session_id = session_id def sync_turn(self, user_content, assistant_content, *, session_id="", messages=None) -> None: ... def prefetch(self, query, *, session_id="") -> str: ... def get_tool_schemas(self) -> list[dict]: return [] # required @abstractmethod — see full guide def register(ctx): ctx.register_memory_provider(MyMemoryProvider()) ``` Memory providers are single-select — only one is active at a time, chosen via `memory.provider` in `config.yaml`. **Full guide:** [Memory Provider Plugins](/developer-guide/memory-provider-plugin) — full `MemoryProvider` ABC, threading contract, profile isolation, CLI command registration via `cli.py`. ### Context engine plugins — replace the context compressor ```python # plugins/context_engine/my-engine/__init__.py from agent.context_engine import ContextEngine class MyContextEngine(ContextEngine): @property def name(self) -> str: return "my-engine" def update_from_response(self, usage) -> None: ... def should_compress(self, prompt_tokens: int = None) -> bool: ... def compress(self, messages, current_tokens=None, focus_topic=None) -> list: ... def register(ctx): ctx.register_context_engine(MyContextEngine()) ``` Context engines are single-select — chosen via `context.engine` in `config.yaml`. **Full guide:** [Context Engine Plugins](/developer-guide/context-engine-plugin). ### Image-generation backends Drop a provider into `plugins/image_gen/<name>/`: ```python # plugins/image_gen/my-imggen/__init__.py from agent.image_gen_provider import ImageGenProvider class MyImageGenProvider(ImageGenProvider): @property def name(self) -> str: return "my-imggen" def is_available(self) -> bool: ... def generate(self, prompt: str, aspect_ratio="landscape", **kwargs) -> dict: # returns success_response(...) / error_response(...) ... def register(ctx): ctx.register_image_gen_provider(MyImageGenProvider()) ``` ```yaml # plugins/image_gen/my-imggen/plugin.yaml name: my-imggen kind: backend version: 1.0.0 description: Custom image generation backend ``` **Full guide:** [Image Generation Provider Plugins](/developer-guide/image-gen-provider-plugin) — full `ImageGenProvider` ABC, `list_models()` / `get_setup_schema()` metadata, `success_response()`/`error_response()` helpers, base64 vs URL output, user overrides, pip distribution. **Reference examples:** `plugins/image_gen/openai/` (DALL-E / GPT-Image via OpenAI SDK), `plugins/image_gen/openai-codex/`, `plugins/image_gen/xai/` (Grok image gen). ## Non-Python extension surfaces Claway also accepts extensions that aren't Python plugins at all. These are shown in the [Pluggable interfaces table](/user-guide/features/plugins#pluggable-interfaces--where-to-go-for-each); the sections below sketch each authoring style briefly. ### MCP servers — register external tools Model Context Protocol (MCP) servers register their own tools into Claway without any Python plugin. Declare them in `~/.claway/config.yaml`: ```yaml mcp_servers: filesystem: command: "npx" args: ["-y", "@modelcontextprotocol/server-filesystem", "/home/user/projects"] timeout: 120 linear: url: "https://mcp.linear.app/sse" auth: type: "oauth" ``` Claway connects to each server at startup, lists its tools, and registers them alongside built-ins. The LLM sees them exactly like any other tool. **Full guide:** [MCP](/user-guide/features/mcp). ### Gateway event hooks — fire on lifecycle events Drop a manifest + handler into `~/.claway/hooks/<name>/`: ```yaml # ~/.claway/hooks/long-task-alert/HOOK.yaml name: long-task-alert description: Send a push notification when a long task finishes events: - agent:end ``` ```python # ~/.claway/hooks/long-task-alert/handler.py async def handle(event_type: str, context: dict) -> None: if context.get("duration_seconds", 0) > 120: # send notification … pass ``` Events include `gateway:startup`, `session:start`, `session:end`, `session:reset`, `agent:start`, `agent:step`, `agent:end`, and wildcard `command:*`. Errors in hooks are caught and logged — they never block the main pipeline. **Full guide:** [Gateway Event Hooks](/user-guide/features/hooks#gateway-event-hooks). ### Shell hooks — run a shell command on tool calls If you just want to run a script when a tool fires (notifications, audit logs, desktop alerts, auto-formatters), use shell hooks in `config.yaml` — no Python required: ```yaml hooks: - event: post_tool_call command: "notify-send 'Tool ran: {tool_name}'" when: tools: [terminal, patch, write_file] ``` Supports all the same events as Python plugin hooks (`pre_tool_call`, `post_tool_call`, `pre_llm_call`, `post_llm_call`, `on_session_start`, `on_session_end`, `pre_gateway_dispatch`) plus structured JSON output for `pre_tool_call` blocking decisions. **Full guide:** [Shell Hooks](/user-guide/features/hooks#shell-hooks). ### Skill sources — add a custom skill registry If you maintain a GitHub repo of skills (or want to pull from a community index beyond the built-in sources), add it as a **tap**: ```bash claway skills tap add myorg/skills-repo claway skills search my-workflow --source myorg/skills-repo claway skills install myorg/skills-repo/my-workflow ``` Publishing your own tap is just a GitHub repo with `skills/<skill-name>/SKILL.md` directories — no server or registry signup needed. **Full guides:** [Skills Hub](/user-guide/features/skills#skills-hub) · [Publishing a custom tap](/user-guide/features/skills#publishing-a-custom-skill-tap) (repo layout, minimal example, non-default paths, trust levels). ### TTS / STT via command templates Any CLI that reads/writes audio or text can be plugged in through `config.yaml` — no Python code: ```yaml tts: provider: voxcpm providers: voxcpm: type: command command: "voxcpm --ref ~/voice.wav --text-file {input_path} --out {output_path}" output_format: mp3 voice_compatible: true ``` For STT, point `CLAWAY_LOCAL_STT_COMMAND` at a shell template. Supported placeholders: `{input_path}`, `{output_path}`, `{format}`, `{voice}`, `{model}`, `{speed}` (TTS); `{input_path}`, `{output_dir}`, `{language}`, `{model}` (STT). Any path-interacting CLI is automatically a plugin. **Full guides:** [TTS custom command providers](/user-guide/features/tts#custom-command-providers) · [STT](/user-guide/features/tts#voice-message-transcription-stt). ## Distribute via pip For sharing plugins publicly, add an entry point to your Python package: ```toml # pyproject.toml [project.entry-points."claway_agent.plugins"] my-plugin = "my_plugin_package" ``` ```bash pip install claway-plugin-calculator # Plugin auto-discovered on next claway startup ``` ## Common mistakes **Handler doesn't return JSON string:** ```python # Wrong — returns a dict def handler(args, **kwargs): return {"result": 42} # Right — returns a JSON string def handler(args, **kwargs): return json.dumps({"result": 42}) ``` **Missing `**kwargs` in handler signature:** ```python # Wrong — will break if Claway passes extra context def handler(args): ... # Right def handler(args, **kwargs): ... ``` **Handler raises exceptions:** ```python # Wrong — exception propagates, tool call fails def handler(args, **kwargs): result = 1 / int(args["value"]) # ZeroDivisionError! return json.dumps({"result": result}) # Right — catch and return error JSON def handler(args, **kwargs): try: result = 1 / int(args.get("value", 0)) return json.dumps({"result": result}) except Exception as e: return json.dumps({"error": str(e)}) ``` **Schema description too vague:** ```python # Bad — model doesn't know when to use it "description": "Does stuff" # Good — model knows exactly when and how "description": "Evaluate a mathematical expression. Use for arithmetic, trig, logarithms. Supports: +, -, *, /, **, sqrt, sin, cos, log, pi, e." ``` --- <!-- source: website/docs/guides/cron-script-only.md --> # Script-Only Cron Jobs (No LLM) # Script-Only Cron Jobs Sometimes you already know exactly what message you want to send. You don't need an agent to reason about it — you just need a script to run on a timer, and its output (if any) to land in Telegram / Discord / Slack / Signal. Claway calls this **no-agent mode**. It's the cron system minus the LLM. <!-- ascii-guard-ignore --> ``` ┌──────────────────┐ ┌──────────────────┐ │ scheduler tick │ every │ run script │ │ (every N minutes)│ ──────▶ │ (bash or python) │ └──────────────────┘ └──────────────────┘ │ │ stdout ▼ ┌──────────────────┐ │ delivery router │ │ (telegram/disc…) │ └──────────────────┘ ``` <!-- ascii-guard-ignore-end --> - **No LLM call.** Zero tokens, zero agent loop, zero model spend. - **Script is the job.** The script decides whether to alert. Emit output → message gets sent. Emit nothing → silent tick. - **Bash or Python.** `.sh` / `.bash` files run under `/bin/bash`; any other extension runs under the current Python interpreter. Anything in `~/.claway/scripts/` is accepted. - **Same scheduler.** Lives in `cronjob` alongside LLM jobs — pausing, resuming, listing, logs, and delivery targeting all work the same way. ## When to Use It Use no-agent mode for: - **Memory / disk / GPU watchdogs.** Run every 5 minutes, alert only when a threshold is breached. - **CI hooks.** Deploy finished → post the commit SHA. Build failed → send the last 100 lines of the log. - **Periodic metrics.** "Daily Stripe revenue at 9am" as a simple API call + pretty-print. - **External event pollers.** Check an API, alert on state change. - **Heartbeats.** Ping a dashboard every N minutes to prove the host is alive. Use a normal (LLM-driven) cron job when you need the agent to **decide** what to say — summarize a long document, pick interesting items from a feed, draft a human-friendly message. The no-agent path is for cases where the script's stdout already IS the message. ## Create One from Chat The real win of no-agent mode is that the agent itself can set up the watchdog for you — no editor, no shell, no remembering CLI flags. You describe what you want, Claway writes the script, schedules it, and tells you when it'll fire. ### Example transcript > **You:** ping me on telegram if RAM is over 85% every 5 minutes > > **Claway:** *(writes `~/.claway/scripts/memory-watchdog.sh`, then calls `cronjob(...)` with `no_agent=true`)* > > Set up. Runs every 5 min, alerts Telegram only when RAM is over 85%. Script: `memory-watchdog.sh`. Job ID: `abc123`. Under the hood, the agent makes two tool calls: ```python # 1. Write the check script write_file( path="~/.claway/scripts/memory-watchdog.sh", content='''#!/usr/bin/env bash ram_pct=$(free | awk '/^Mem:/ {printf "%d", $3 * 100 / $2}') if [ "$ram_pct" -ge 85 ]; then echo "RAM ${ram_pct}% on $(hostname)" fi # Empty stdout = silent tick; no message sent. ''', ) # 2. Schedule it — no_agent=True skips the LLM on every tick cronjob( action="create", schedule="every 5m", script="memory-watchdog.sh", no_agent=True, deliver="telegram", name="memory-watchdog", ) ``` From that point on every tick is free: the scheduler runs the script, pipes its stdout to Telegram if non-empty, and never touches a model. ### What the agent decides for you When you phrase a request like "alert me when X" or "every N minutes check Y and tell me if Z", Claway's `cronjob` tool description tells it to reach for `no_agent=True` whenever the message content is fully determined by the script. It falls back to the normal LLM-driven path when the request needs reasoning (*"summarize the new issues"*, *"pick the most interesting headlines"*, *"draft a friendly reminder"*). You don't have to specify `--no-agent` yourself. Just describe the behavior. ### Managing watchdogs from chat The agent can pause, resume, edit, and remove jobs the same way it creates them: > **You:** stop the memory watchdog for tonight > > **Claway:** *(calls `cronjob(action='pause', job_id='abc123')`)* > > Paused. Resume with "turn it back on" or via `claway cron resume abc123`. > **You:** change it to every 15 minutes > > **Claway:** *(calls `cronjob(action='update', job_id='abc123', schedule='every 15m')`)* The full lifecycle (create / list / update / pause / resume / run-now / remove) is available to the agent without you learning any CLI commands. ## Create One from the CLI Prefer the shell? The CLI path gives you the same result with three commands: ```bash # 1. Write your script cat > ~/.claway/scripts/memory-watchdog.sh <<'EOF' #!/usr/bin/env bash # Alert when RAM usage is over 85%. Silent otherwise. RAM_PCT=$(free | awk '/^Mem:/ {printf "%d", $3 * 100 / $2}') if [ "$RAM_PCT" -ge 85 ]; then echo "⚠ RAM ${RAM_PCT}% on $(hostname)" fi # Empty stdout = silent run; no message sent. EOF chmod +x ~/.claway/scripts/memory-watchdog.sh # 2. Schedule it claway cron create "every 5m" \ --no-agent \ --script memory-watchdog.sh \ --deliver telegram \ --name "memory-watchdog" # 3. Verify claway cron list claway cron run <job_id> # fire it once to test ``` That's the whole thing. No prompt, no skill, no model. ## How Script Output Maps to Delivery | Script behavior | Result | |-----------------|--------| | Exit 0, non-empty stdout | stdout is delivered verbatim | | Exit 0, empty stdout | Silent tick — no delivery | | Exit 0, stdout contains `{"wakeAgent": false}` on the last line | Silent tick (shared gate with LLM jobs) | | Non-zero exit code | Error alert is delivered (so a broken watchdog doesn't fail silently) | | Script timeout | Error alert is delivered | The "silent when empty" behavior is the key to the classic watchdog pattern: the script is free to run every minute, but the channel only sees a message when something actually needs attention. ## Script Rules Scripts must live in `~/.claway/scripts/`. This is enforced at both job-creation time and run time — absolute paths, `~/` expansion, and path-traversal patterns (`../`) are rejected. The same directory is shared with the pre-check script gate used by LLM jobs. Interpreter choice is by file extension: | Extension | Interpreter | |-----------|-------------| | `.sh`, `.bash` | `/bin/bash` | | anything else | `sys.executable` (current Python) | We intentionally do NOT honour `#!/...` shebangs — keeping the interpreter set explicit and small reduces the surface the scheduler trusts. ## Schedule Syntax Same as all other cron jobs: ```bash claway cron create "every 5m" # interval claway cron create "every 2h" claway cron create "0 9 * * *" # standard cron: 9am daily claway cron create "30m" # one-shot: run once in 30 minutes ``` See the [cron feature reference](/user-guide/features/cron) for the full syntax. ## Delivery Targets `--deliver` accepts everything the gateway knows about. Some common shapes: ```bash --deliver telegram # platform home channel --deliver telegram:-1001234567890 # specific chat --deliver telegram:-1001234567890:17585 # specific Telegram forum topic --deliver discord:#ops --deliver slack:#engineering --deliver signal:+15551234567 --deliver local # just save to ~/.claway/cron/output/ ``` No running gateway is required at script-run time for bot-token platforms (Telegram, Discord, Slack, Signal, SMS, WhatsApp) — the tool calls each platform's REST endpoint directly using the credentials already in `~/.claway/.env` / `~/.claway/config.yaml`. ## Editing and Lifecycle ```bash claway cron list # see all jobs claway cron pause <job_id> # stop firing, keep definition claway cron resume <job_id> claway cron edit <job_id> --schedule "every 10m" # adjust cadence claway cron edit <job_id> --agent # flip to LLM mode claway cron edit <job_id> --no-agent --script … # flip back claway cron remove <job_id> # delete it ``` Everything that works on LLM jobs (pause, resume, manual trigger, delivery target changes) works on no-agent jobs too. ## Worked Example: Disk Space Alert ```bash cat > ~/.claway/scripts/disk-alert.sh <<'EOF' #!/usr/bin/env bash # Alert when / or /home is over 90% full. THRESHOLD=90 df -h / /home 2>/dev/null | awk -v t="$THRESHOLD" ' NR > 1 && $5+0 >= t { printf "⚠ Disk %s full on %s\n", $5, $6 } ' EOF chmod +x ~/.claway/scripts/disk-alert.sh claway cron create "*/15 * * * *" \ --no-agent \ --script disk-alert.sh \ --deliver telegram \ --name "disk-alert" ``` Silent when both filesystems are under 90%; fires exactly one line per over-threshold filesystem when one fills up. ## Comparison with Other Patterns | Approach | What runs | When to use | |----------|-----------|-------------| | `cronjob --no-agent` (this page) | Your script on Claway's schedule | Recurring watchdogs / alerts / metrics that don't need reasoning | | `cronjob` (default, LLM) | Agent with optional pre-check script | When the message content requires reasoning over data | | OS cron + `curl` to a [webhook subscription](/user-guide/messaging/webhooks) | Your script on the OS schedule | When Claway might be unhealthy (the thing you're monitoring) | For critical system-health watchdogs that must fire *even when the gateway is down*, use OS-level cron with a plain `curl` to a Claway webhook subscription (or any external alerting endpoint) — those run as independent OS processes and don't depend on Claway being up. The in-gateway scheduler is the right choice when the thing being monitored is external. ## Related - [Automate Anything with Cron](/guides/automate-with-cron) — LLM-driven cron patterns. - [Scheduled Tasks (Cron) reference](/user-guide/features/cron) — full schedule syntax, lifecycle, delivery routing. - [Webhook Subscriptions](/user-guide/messaging/webhooks) — fire-and-forget HTTP entry points for external schedulers. - Gateway Internals — delivery-router internals. --- <!-- source: website/docs/guides/cron-troubleshooting.md --> # Cron Troubleshooting # Cron Troubleshooting When a cron job isn't behaving as expected, work through these checks in order. Most issues fall into one of four categories: timing, delivery, permissions, or skill loading. --- ## Jobs Not Firing ### Check 1: Verify the job exists and is active ```bash claway cron list ``` Look for the job and confirm its state is `[active]` (not `[paused]` or `[completed]`). If it shows `[completed]`, the repeat count may be exhausted — edit the job to reset it. ### Check 2: Confirm the schedule is correct A misformatted schedule silently defaults to one-shot or is rejected entirely. Test your expression: | Your expression | Should evaluate to | |----------------|-------------------| | `0 9 * * *` | 9:00 AM every day | | `0 9 * * 1` | 9:00 AM every Monday | | `every 2h` | Every 2 hours from now | | `30m` | 30 minutes from now | | `2025-06-01T09:00:00` | June 1, 2025 at 9:00 AM UTC | If the job fires once and then disappears from the list, it's a one-shot schedule (`30m`, `1d`, or an ISO timestamp) — expected behavior. ### Check 3: Is the gateway running? Cron jobs are fired by the gateway's background ticker thread, which ticks every 60 seconds. A regular CLI chat session does **not** automatically fire cron jobs. If you're expecting jobs to fire automatically, you need a running gateway (`claway gateway` for foreground, or `claway gateway start` for the installed service). For one-off debugging, you can manually trigger a tick with `claway cron tick`. ### Check 4: Check the system clock and timezone Jobs use the local timezone. If your machine's clock is wrong or in a different timezone than expected, jobs will fire at the wrong times. Verify: ```bash date claway cron list # Compare next_run times with local time ``` --- ## Delivery Failures ### Check 1: Verify the deliver target is correct Delivery targets are case-sensitive and require the correct platform to be configured. A misconfigured target silently drops the response. | Target | Requires | |--------|----------| | `telegram` | `TELEGRAM_BOT_TOKEN` in `~/.claway/.env` | | `discord` | `DISCORD_BOT_TOKEN` in `~/.claway/.env` | | `slack` | `SLACK_BOT_TOKEN` in `~/.claway/.env` | | `whatsapp` | WhatsApp gateway configured | | `signal` | Signal gateway configured | | `matrix` | Matrix homeserver configured | | `email` | SMTP configured in `config.yaml` | | `sms` | SMS provider configured | | `local` | Write access to `~/.claway/cron/output/` | | `origin` | Delivers to the chat where the job was created | Other supported platforms include `mattermost`, `homeassistant`, `dingtalk`, `feishu`, `wecom`, `weixin`, `bluebubbles`, `qqbot`, and `webhook`. You can also target a specific chat with `platform:chat_id` syntax (e.g., `telegram:-1001234567890`). If delivery fails, the job still runs — it just won't send anywhere. Check `claway cron list` for updated `last_error` field (if available). ### Check 2: Check `[SILENT]` usage If your cron job produces no output, delivery is suppressed. If the agent response includes the cron quiet marker `[SILENT]`, delivery is also suppressed. This is intentional for monitoring jobs — but make sure your prompt is not accidentally suppressing everything. Use prompts like "respond with only [SILENT] if nothing changed." Avoid asking the agent to include `[SILENT]` inside a longer explanation, because cron treats that marker as a suppression signal. ### Check 3: Platform token permissions Each messaging platform bot needs specific permissions to receive messages. If delivery silently fails: - **Telegram**: Bot must be an admin in the target group/channel - **Discord**: Bot must have permission to send in the target channel - **Slack**: Bot must be added to the workspace and have `chat:write` scope ### Check 4: Response wrapping By default, a cron response is prefixed with the job's name as a short tag when you chose one (`cron.wrap_response: true` in `config.yaml`); automatically-named jobs get no tag. Some platforms or integrations prefer the bare output. To disable the tag entirely: ```yaml cron: wrap_response: false ``` --- ## Skill Loading Failures ### Check 1: Verify skills are installed ```bash claway skills list ``` Skills must be installed before they can be attached to cron jobs. If a skill is missing, install it first with `claway skills install <skill-name>` or via `/skills` in the CLI. ### Check 2: Check skill name vs. skill folder name Skill names are case-sensitive and must match the installed skill's folder name. If your job specifies `ai-funding-daily-report` but the skill folder is `ai-funding-daily-report`, confirm the exact name from `claway skills list`. ### Check 3: Skills that require interactive tools Cron jobs run with the `cronjob`, `messaging`, and `clarify` toolsets disabled. This prevents recursive cron creation, direct message sending (delivery is handled by the scheduler), and interactive prompts. If a skill relies on these toolsets, it won't work in a cron context. Check the skill's documentation to confirm it works in non-interactive (headless) mode. ### Check 4: Multi-skill ordering When using multiple skills, they load in order. If Skill A depends on context from Skill B, make sure B loads first: ```bash /cron add "0 9 * * *" "..." --skill context-skill --skill target-skill ``` In this example, `context-skill` loads before `target-skill`. --- ## Job Errors and Failures ### Check 1: Review recent job output If a job ran and failed, you may see error context in: 1. The chat where the job delivers (if delivery succeeded) 2. `~/.claway/logs/agent.log` for scheduler messages (or `errors.log` for warnings) 3. The job's `last_run` metadata via `claway cron list` ### Check 2: Common error patterns **"No such file or directory" for scripts** The `script` path must be an absolute path (or relative to the Claway config directory). Verify: ```bash ls ~/.claway/scripts/your-script.py # Must exist claway cron edit <job_id> --script ~/.claway/scripts/your-script.py ``` **"Skill not found" at job execution** The skill must be installed on the machine running the scheduler. If you move between machines, skills don't automatically sync — reinstall them with `claway skills install <skill-name>`. **Job runs but delivers nothing** Likely a delivery target issue (see Delivery Failures above), no output, or a response containing the cron quiet marker `[SILENT]`. **Job hangs or times out** The scheduler uses an inactivity-based timeout (default 600s, configurable via `CLAWAY_CRON_TIMEOUT` env var, `0` for unlimited). The agent can run as long as it's actively calling tools — the timer only fires after sustained inactivity. Long-running jobs should use scripts to handle data collection and deliver only the result. ### Check 3: Lock contention The scheduler uses file-based locking to prevent overlapping ticks. If two gateway instances are running (or a CLI session conflicts with a gateway), jobs may be delayed or skipped. Kill duplicate gateway processes: ```bash ps aux | grep claway # Kill duplicate processes, keep only one ``` ### Check 4: Permissions on jobs.json Jobs are stored in `~/.claway/cron/jobs.json`. If this file is not readable/writable by your user, the scheduler will fail silently: ```bash ls -la ~/.claway/cron/jobs.json chmod 600 ~/.claway/cron/jobs.json # Your user should own it ``` --- ## Performance Issues ### Slow job startup Each cron job creates a fresh AIAgent session, which may involve provider authentication and model loading. For time-sensitive schedules, add buffer time (e.g., `0 8 * * *` instead of `0 9 * * *`). ### Too many overlapping jobs The scheduler executes jobs sequentially within each tick. If multiple jobs are due at the same time, they run one after another. Consider staggering schedules (e.g., `0 9 * * *` and `5 9 * * *` instead of both at `0 9 * * *`) to avoid delays. ### Large script output Scripts that dump megabytes of output will slow down the agent and may hit token limits. Filter/summarize at the script level — emit only what the agent needs to reason about. --- ## Diagnostic Commands ```bash claway cron list # Show all jobs, states, next_run times claway cron run <job_id> # Schedule for next tick (for testing) claway cron edit <job_id> # Fix configuration issues claway logs # View recent Claway logs claway skills list # Verify installed skills ``` --- ## Getting More Help If you've worked through this guide and the issue persists: 1. Run the job with `claway cron run <job_id>` (fires on next gateway tick) and watch for errors in the chat output 2. Check `~/.claway/logs/agent.log` for scheduler messages and `~/.claway/logs/errors.log` for warnings 3. Email support@claway.io with: - The job ID and schedule - The delivery target - What you expected vs. what happened - Relevant error messages from the logs --- *For the complete cron reference, see [Automate Anything with Cron](/guides/automate-with-cron) and [Scheduled Tasks (Cron)](/user-guide/features/cron).* --- <!-- source: website/docs/guides/delegation-patterns.md --> # Delegation & Parallel Work # Delegation & Parallel Work Claway can spawn isolated child agents to work on tasks in parallel. Each subagent gets its own conversation, terminal session, and toolset. Only the final summary comes back — intermediate tool calls never enter your context window. For the full feature reference, see [Subagent Delegation](/user-guide/features/delegation). --- ## When to Delegate **Good candidates for delegation:** - Reasoning-heavy subtasks (debugging, code review, research synthesis) - Tasks that would flood your context with intermediate data - Parallel independent workstreams (research A and B simultaneously) - Fresh-context tasks where you want the agent to approach without bias **Use something else:** - Single tool call → just use the tool directly - Mechanical multi-step work with logic between steps → `execute_code` - Tasks needing user interaction → subagents can't use `clarify` - Quick file edits → do them directly - Durable long-running work that must outlive the current turn → `cronjob` or `terminal(background=True, notify_on_complete=True)`. `delegate_task` is **synchronous**: if the parent turn is interrupted, active children are cancelled and their work is discarded. --- ## Pattern: Parallel Research Research three topics simultaneously and get structured summaries back: ``` Research these three topics in parallel: 1. Current state of WebAssembly outside the browser 2. RISC-V server chip adoption in 2025 3. Practical quantum computing applications Focus on recent developments and key players. ``` Behind the scenes, Claway uses: ```python delegate_task(tasks=[ { "goal": "Research WebAssembly outside the browser in 2025", "context": "Focus on: runtimes (Wasmtime, Wasmer), cloud/edge use cases, WASI progress", "toolsets": ["web"] }, { "goal": "Research RISC-V server chip adoption", "context": "Focus on: server chips shipping, cloud providers adopting, software ecosystem", "toolsets": ["web"] }, { "goal": "Research practical quantum computing applications", "context": "Focus on: error correction breakthroughs, real-world use cases, key companies", "toolsets": ["web"] } ]) ``` All three run concurrently. Each subagent searches the web independently and returns a summary. The parent agent then synthesizes them into a coherent briefing. --- ## Pattern: Code Review Delegate a security review to a fresh-context subagent that approaches the code without preconceptions: ``` Review the authentication module at src/auth/ for security issues. Check for SQL injection, JWT validation problems, password handling, and session management. Fix anything you find and run the tests. ``` The key is the `context` field — it must include everything the subagent needs: ```python delegate_task( goal="Review src/auth/ for security issues and fix any found", context="""Project at /home/user/webapp. Python 3.11, Flask, PyJWT, bcrypt. Auth files: src/auth/login.py, src/auth/jwt.py, src/auth/middleware.py Test command: pytest tests/auth/ -v Focus on: SQL injection, JWT validation, password hashing, session management. Fix issues found and verify tests pass.""", toolsets=["terminal", "file"] ) ``` :::warning The Context Problem Subagents know **absolutely nothing** about your conversation. They start completely fresh. If you delegate "fix the bug we were discussing," the subagent has no idea what bug you mean. Always pass file paths, error messages, project structure, and constraints explicitly. ::: --- ## Pattern: Compare Alternatives Evaluate multiple approaches to the same problem in parallel, then pick the best: ``` I need to add full-text search to our Django app. Evaluate three approaches in parallel: 1. PostgreSQL tsvector (built-in) 2. Elasticsearch via django-elasticsearch-dsl 3. Meilisearch via meilisearch-python For each: setup complexity, query capabilities, resource requirements, and maintenance overhead. Compare them and recommend one. ``` Each subagent researches one option independently. Because they're isolated, there's no cross-contamination — each evaluation stands on its own merits. The parent agent gets all three summaries and makes the comparison. --- ## Pattern: Multi-File Refactoring Split a large refactoring task across parallel subagents, each handling a different part of the codebase: ```python delegate_task(tasks=[ { "goal": "Refactor all API endpoint handlers to use the new response format", "context": """Project at /home/user/api-server. Files: src/handlers/users.py, src/handlers/auth.py, src/handlers/billing.py Old format: return {"data": result, "status": "ok"} New format: return APIResponse(data=result, status=200).to_dict() Import: from src.responses import APIResponse Run tests after: pytest tests/handlers/ -v""", "toolsets": ["terminal", "file"] }, { "goal": "Update all client SDK methods to handle the new response format", "context": """Project at /home/user/api-server. Files: sdk/python/client.py, sdk/python/models.py Old parsing: result = response.json()["data"] New parsing: result = response.json()["data"] (same key, but add status code checking) Also update sdk/python/tests/test_client.py""", "toolsets": ["terminal", "file"] }, { "goal": "Update API documentation to reflect the new response format", "context": """Project at /home/user/api-server. Docs at: docs/api/. Format: Markdown with code examples. Update all response examples from old format to new format. Add a 'Response Format' section to docs/api/overview.md explaining the schema.""", "toolsets": ["terminal", "file"] } ]) ``` :::tip Each subagent gets its own terminal session. They can work on the same project directory without stepping on each other — as long as they're editing different files. If two subagents might touch the same file, handle that file yourself after the parallel work completes. ::: --- ## Pattern: Gather Then Analyze Use `execute_code` for mechanical data gathering, then delegate the reasoning-heavy analysis: ```python # Step 1: Mechanical gathering (execute_code is better here — no reasoning needed) execute_code(""" from claway_tools import web_search, web_extract results = [] for query in ["AI funding Q1 2026", "AI startup acquisitions 2026", "AI IPOs 2026"]: r = web_search(query, limit=5) for item in r["data"]["web"]: results.append({"title": item["title"], "url": item["url"], "desc": item["description"]}) # Extract full content from top 5 most relevant urls = [r["url"] for r in results[:5]] content = web_extract(urls) # Save for the analysis step import json with open("/tmp/ai-funding-data.json", "w") as f: json.dump({"search_results": results, "extracted": content["results"]}, f) print(f"Collected {len(results)} results, extracted {len(content['results'])} pages") """) # Step 2: Reasoning-heavy analysis (delegation is better here) delegate_task( goal="Analyze AI funding data and write a market report", context="""Raw data at /tmp/ai-funding-data.json contains search results and extracted web pages about AI funding, acquisitions, and IPOs in Q1 2026. Write a structured market report: key deals, trends, notable players, and outlook. Focus on deals over $100M.""", toolsets=["terminal", "file"] ) ``` This is often the most efficient pattern: `execute_code` handles the 10+ sequential tool calls cheaply, then a subagent does the single expensive reasoning task with a clean context. --- ## Toolset Selection Choose toolsets based on what the subagent needs: | Task type | Toolsets | Why | |-----------|----------|-----| | Web research | `["web"]` | web_search + web_extract only | | Code work | `["terminal", "file"]` | Shell access + file operations | | Full-stack | `["terminal", "file", "web"]` | Everything except messaging | | Read-only analysis | `["file"]` | Can only read files, no shell | Restricting toolsets keeps the subagent focused and prevents accidental side effects (like a research subagent running shell commands). --- ## Constraints - **Default 3 parallel tasks**: batches default to 3 concurrent subagents (configurable via `delegation.max_concurrent_children` in config.yaml, no hard ceiling, only a floor of 1) - **Nested delegation is opt-in**: leaf subagents (default) cannot call `delegate_task`, `clarify`, `memory`, or `execute_code`. Orchestrator subagents (`role="orchestrator"`) retain `delegate_task` for further delegation, but only when `delegation.max_spawn_depth` is raised above the default of 1 (floor 1, no ceiling); the other three remain blocked. Disable globally via `delegation.orchestrator_enabled: false`. ### Tuning Concurrency and Depth | Config | Default | Range | Effect | |--------|---------|-------|--------| | `max_concurrent_children` | 3 | >=1 | Parallel batch size per `delegate_task` call | | `max_spawn_depth` | 1 | >=1 | How many delegation levels can spawn further | Example: running 30 parallel workers with nested subagents: ```yaml delegation: max_concurrent_children: 30 max_spawn_depth: 2 ``` - **Separate terminals** — each subagent gets its own terminal session with separate working directory and state - **No conversation history** — subagents see only the `goal` and `context` the parent agent passes when calling `delegate_task` - **Default 50 iterations** — set `max_iterations` lower for simple tasks to save cost - **Not durable** — `delegate_task` is synchronous and runs inside the parent turn. If the parent is interrupted (new user message, `/stop`, `/new`), all active children are cancelled (`status="interrupted"`) and their work is discarded. For work that must outlive the current turn, use `cronjob` or `terminal(background=True, notify_on_complete=True)`. --- ## Tips **Be specific in goals.** "Fix the bug" is too vague. "Fix the TypeError in api/handlers.py line 47 where process_request() receives None from parse_body()" gives the subagent enough to work with. **Include file paths.** Subagents don't know your project structure. Always include absolute paths to relevant files, the project root, and the test command. **Use delegation for context isolation.** Sometimes you want a fresh perspective. Delegating forces you to articulate the problem clearly, and the subagent approaches it without the assumptions that built up in your conversation. **Check results.** Subagent summaries are just that — summaries. If a subagent says "fixed the bug and tests pass," verify by running the tests yourself or reading the diff. --- *For the complete delegation reference — all parameters, ACP integration, and advanced configuration — see [Subagent Delegation](/user-guide/features/delegation).* --- <!-- source: website/docs/guides/github-pr-review-agent.md --> # Tutorial: GitHub PR Review Agent # Tutorial: Build a GitHub PR Review Agent **The problem:** Your team opens PRs faster than you can review them. PRs sit for days waiting for eyeballs. Junior devs merge bugs because nobody had time to check. You spend your mornings catching up on diffs instead of building. **The solution:** An AI agent that watches your repos around the clock, reviews every new PR for bugs, security issues, and code quality, and sends you a summary — so you only spend time on PRs that actually need human judgment. **What you'll build:** ``` ┌───────────────────────────────────────────────────────────────────┐ │ │ │ Cron Timer ──▶ Claway Agent ──▶ GitHub API ──▶ Review │ │ (every 2h) + gh CLI (PR diffs) delivery │ │ + skill (Telegram, │ │ + memory Discord, │ │ local) │ │ │ └───────────────────────────────────────────────────────────────────┘ ``` This guide uses **cron jobs** to poll for PRs on a schedule — no server or public endpoint needed. Works behind NAT and firewalls. :::tip Want real-time reviews instead? If you have a public endpoint available, check out [Automated GitHub PR Comments with Webhooks](./webhook-github-pr-review.md) — GitHub pushes events to Claway instantly when PRs are opened or updated. ::: --- ## Prerequisites - **Claway Agent installed** — see the [Installation guide](/getting-started) - **Gateway running** for cron jobs: ```bash claway gateway install # Install as a service # or claway gateway # Run in foreground ``` - **GitHub CLI (`gh`) installed and authenticated**: ```bash # Install brew install gh # macOS sudo apt install gh # Ubuntu/Debian # Authenticate gh auth login ``` - **Messaging configured** (optional) — [Telegram](/user-guide/messaging/telegram) or [Discord](/user-guide/messaging/discord) :::tip No messaging? No problem Use `deliver: "local"` to save reviews to `~/.claway/cron/output/`. Great for testing before wiring up notifications. ::: --- ## Step 1: Verify the Setup Make sure Claway can access GitHub. Start a chat: ```bash claway ``` Test with a simple command: ``` Run: gh pr list --repo BlockWayz/claway --state open --limit 3 ``` You should see a list of open PRs. If this works, you're ready. --- ## Step 2: Try a Manual Review Still in the chat, ask Claway to review a real PR: ``` Review this pull request. Read the diff, check for bugs, security issues, and code quality. Be specific about line numbers and quote problematic code. Run: gh pr diff 3888 --repo BlockWayz/claway ``` Claway will: 1. Execute `gh pr diff` to fetch the code changes 2. Read through the entire diff 3. Produce a structured review with specific findings If you're happy with the quality, time to automate it. --- ## Step 3: Create a Review Skill A skill gives Claway consistent review guidelines that persist across sessions and cron runs. Without one, review quality varies. ```bash mkdir -p ~/.claway/skills/code-review ``` Create `~/.claway/skills/code-review/SKILL.md`: ```markdown --- name: code-review description: Review pull requests for bugs, security issues, and code quality --- # Code Review Guidelines When reviewing a pull request: ## What to Check 1. **Bugs** — Logic errors, off-by-one, null/undefined handling 2. **Security** — Injection, auth bypass, secrets in code, SSRF 3. **Performance** — N+1 queries, unbounded loops, memory leaks 4. **Style** — Naming conventions, dead code, missing error handling 5. **Tests** — Are changes tested? Do tests cover edge cases? ## Output Format For each finding: - **File:Line** — exact location - **Severity** — Critical / Warning / Suggestion - **What's wrong** — one sentence - **Fix** — how to fix it ## Rules - Be specific. Quote the problematic code. - Don't flag style nitpicks unless they affect readability. - If the PR looks good, say so. Don't invent problems. - End with: APPROVE / REQUEST_CHANGES / COMMENT ``` Verify it loaded — start `claway` and you should see `code-review` in the skills list at startup. --- ## Step 4: Teach It Your Conventions This is what makes the reviewer actually useful. Start a session and teach Claway your team's standards: ``` Remember: In our backend repo, we use Python with FastAPI. All endpoints must have type annotations and Pydantic models. We don't allow raw SQL — only SQLAlchemy ORM. Test files go in tests/ and must use pytest fixtures. ``` ``` Remember: In our frontend repo, we use TypeScript with React. No `any` types allowed. All components must have props interfaces. We use React Query for data fetching, never useEffect for API calls. ``` These memories persist forever — the reviewer will enforce your conventions without being told each time. --- ## Step 5: Create the Automated Cron Job Now wire it all together. Create a cron job that runs every 2 hours: ```bash claway cron create "0 */2 * * *" \ "Check for new open PRs and review them. Repos to monitor: - myorg/backend-api - myorg/frontend-app Steps: 1. Run: gh pr list --repo REPO --state open --limit 5 --json number,title,author,createdAt 2. For each PR created or updated in the last 4 hours: - Run: gh pr diff NUMBER --repo REPO - Review the diff using the code-review guidelines 3. Format output as: ## PR Reviews — today ### [repo] #[number]: [title] **Author:** [name] | **Verdict:** APPROVE/REQUEST_CHANGES/COMMENT [findings] If no new PRs found, say: No new PRs to review." \ --name "pr-review" \ --deliver telegram \ --skill code-review ``` Verify it's scheduled: ```bash claway cron list ``` ### Other useful schedules | Schedule | When | |----------|------| | `0 */2 * * *` | Every 2 hours | | `0 9,13,17 * * 1-5` | Three times a day, weekdays only | | `0 9 * * 1` | Weekly Monday morning roundup | | `30m` | Every 30 minutes (high-traffic repos) | --- ## Step 6: Run It On Demand Don't want to wait for the schedule? Trigger it manually: ```bash claway cron run pr-review ``` Or from within a chat session: ``` /cron run pr-review ``` --- ## Going Further ### Post Reviews Directly to GitHub Instead of delivering to Telegram, have the agent comment on the PR itself: Add this to your cron prompt: ``` After reviewing, post your review: - For issues: gh pr review NUMBER --repo REPO --comment --body "YOUR_REVIEW" - For critical issues: gh pr review NUMBER --repo REPO --request-changes --body "YOUR_REVIEW" - For clean PRs: gh pr review NUMBER --repo REPO --approve --body "Looks good" ``` :::caution Make sure `gh` has a token with `repo` scope. Reviews are posted as whoever `gh` is authenticated as. ::: ### Weekly PR Dashboard Create a Monday morning overview of all your repos: ```bash claway cron create "0 9 * * 1" \ "Generate a weekly PR dashboard: - myorg/backend-api - myorg/frontend-app - myorg/infra For each repo show: 1. Open PR count and oldest PR age 2. PRs merged this week 3. Stale PRs (older than 5 days) 4. PRs with no reviewer assigned Format as a clean summary." \ --name "weekly-dashboard" \ --deliver telegram ``` ### Multi-Repo Monitoring Scale up by adding more repos to the prompt. The agent processes them sequentially — no extra setup needed. --- ## Troubleshooting ### "gh: command not found" The gateway runs in a minimal environment. Ensure `gh` is in the system PATH and restart the gateway. ### Reviews are too generic 1. Add the `code-review` skill (Step 3) 2. Teach Claway your conventions via memory (Step 4) 3. The more context it has about your stack, the better the reviews ### Cron job doesn't run ```bash claway gateway status # Is the gateway running? claway cron list # Is the job enabled? ``` ### Rate limits GitHub allows 5,000 API requests/hour for authenticated users. Each PR review uses ~3-5 requests (list + diff + optional comments). Even reviewing 100 PRs/day stays well within limits. --- ## What's Next? - **[Webhook-Based PR Reviews](./webhook-github-pr-review.md)** — get instant reviews when PRs are opened (requires a public endpoint) - **[Daily Briefing Bot](/guides/daily-briefing-bot)** — combine PR reviews with your morning news digest - **[Build a Plugin](/guides/build-a-claway-plugin)** — wrap the review logic into a shareable plugin - **[Profiles](/user-guide/profiles)** — run a dedicated reviewer profile with its own memory and config - **[Fallback Providers](/user-guide/features/fallback-providers)** — ensure reviews run even when one provider is down --- <!-- source: website/docs/guides/google-gemini.md --> # Google Gemini # Google Gemini Claway Agent supports Google Gemini as a native provider using the **Google AI Studio / Gemini API** — not the OpenAI-compatible endpoint. This lets Claway translate its internal OpenAI-shaped message and tool loop into Gemini's native `generateContent` API while preserving tool calling, streaming, multimodal inputs, and Gemini-specific response metadata. ## Prerequisites - **Google AI Studio API key** — create one at [aistudio.google.com/apikey](https://aistudio.google.com/apikey) - **Billing-enabled Google Cloud project** — recommended for agent use. Gemini's free tier is too small for long-running agent sessions because Claway may make several model calls per user turn. - **Claway installed** — no extra Python package is required for the native Gemini provider. :::tip API key path Set `GOOGLE_API_KEY` or `GEMINI_API_KEY`. Claway checks both names for the `gemini` provider. ::: ## Quick Start ```bash # Add your Gemini API key echo "GOOGLE_API_KEY=..." >> ~/.claway/.env # Select Gemini as your provider claway model # → Choose "More providers..." → "Google AI Studio" # → Claway checks your key tier and shows Gemini models # → Select a model # Start chatting claway chat ``` If you prefer direct config editing, use the native Gemini API base URL: ```yaml model: default: gemini-3-flash-preview provider: gemini base_url: https://generativelanguage.googleapis.com/v1beta ``` ## Configuration After running `claway model`, your `~/.claway/config.yaml` will contain: ```yaml model: default: gemini-3-flash-preview provider: gemini base_url: https://generativelanguage.googleapis.com/v1beta ``` And in `~/.claway/.env`: ```bash GOOGLE_API_KEY=... ``` ### Native Gemini API The recommended endpoint is: ```text https://generativelanguage.googleapis.com/v1beta ``` Claway detects this endpoint and creates its native Gemini adapter. Internally, Claway still keeps the agent loop in OpenAI-shaped messages, then translates each request to Gemini's native schema: - `messages[]` → Gemini `contents[]` - system prompts → Gemini `systemInstruction` - tool schemas → Gemini `functionDeclarations` - tool results → Gemini `functionResponse` parts - streaming responses → OpenAI-shaped stream chunks for the Claway loop :::note Gemini 3 thought signatures For Gemini 3 tool use, Claway preserves the `thoughtSignature` values attached to function-call parts and replays them on the next tool turn. That covers the validation-critical path for multi-step agent workflows. Gemini 3 may also attach thought signatures to other response parts. Claway's native adapter is optimized for agent tool loops today, so it does not yet replay every non-tool-call signature with full part-level fidelity. ::: ### Prefer the Native Endpoint Google also exposes an OpenAI-compatible endpoint: ```text https://generativelanguage.googleapis.com/v1beta/openai/ ``` For Claway agent sessions, prefer the native Gemini endpoint above. Claway includes a native Gemini adapter so it can map multi-turn tool use, tool-call results, streaming, multimodal inputs, and Gemini response metadata directly onto Gemini's `generateContent` API. The OpenAI-compatible endpoint is still useful when you specifically need OpenAI API compatibility. If you previously set `GEMINI_BASE_URL` to the `/openai` URL, remove it or change it: ```bash GEMINI_BASE_URL=https://generativelanguage.googleapis.com/v1beta ``` ## Available Models The `claway model` picker shows Gemini models maintained in Claway's provider registry. Common choices include: | Model | ID | Notes | |-------|----|-------| | Gemini 3.1 Pro Preview | `gemini-3.1-pro-preview` | Most capable preview model when available | | Gemini 3 Pro Preview | `gemini-3-pro-preview` | Strong reasoning and coding model | | Gemini 3 Flash Preview | `gemini-3-flash-preview` | Recommended default balance of speed and capability | | Gemini 3.1 Flash Lite Preview | `gemini-3.1-flash-lite-preview` | Fastest / lowest-cost option when available | Model availability changes over time. If a model disappears or is not enabled for your key, run `claway model` again and pick one from the current list. :::info Model IDs Use Gemini's native model IDs such as `gemini-3-flash-preview`, not OpenRouter-style IDs like `google/gemini-3-flash-preview`, when `provider: gemini`. ::: ### Latest Aliases Google publishes moving aliases for the Pro and Flash Gemini families. `gemini-pro-latest` and `gemini-flash-latest` are useful when you want Google to advance the model automatically without changing your Claway config. | Alias | Currently tracks | Notes | |-------|------------------|-------| | `gemini-pro-latest` | Latest Gemini Pro model | Best when you want Google's current Pro default | | `gemini-flash-latest` | Latest Gemini Flash model | Best when you want Google's current Flash default | ```yaml model: default: gemini-pro-latest provider: gemini base_url: https://generativelanguage.googleapis.com/v1beta ``` If you need strict reproducibility, prefer explicit model IDs such as `gemini-3.1-pro-preview` or `gemini-3-flash-preview`. ### Gemma via the Gemini API Google also exposes Gemma models through the Gemini API. Claway recognizes these as Google models, but hides very low-throughput Gemma entries from the default model picker so new users do not accidentally select an evaluation-tier model for a long-running agent session. Useful evaluation IDs include: | Model | ID | Notes | |-------|----|-------| | Gemma 4 31B IT | `gemma-4-31b-it` | Larger Gemma model; useful for compatibility and quality evaluation | | Gemma 4 26B A4B IT | `gemma-4-26b-a4b-it` | Smaller active-parameter variant when available | These models are best treated as evaluation options on Gemini API keys. Google's Gemma API pricing is free-tier-only and the usage caps are low compared with production Gemini models, so sustained Claway agent use should normally move to a paid Gemini model, a self-hosted deployment, or another provider with appropriate quota. To use a Gemma model that is hidden from the picker, set it directly: ```yaml model: default: gemma-4-31b-it provider: gemini base_url: https://generativelanguage.googleapis.com/v1beta ``` ## Switching Models Mid-Session Use the `/model` command during a conversation: ```text /model gemini-3-flash-preview /model gemini-flash-latest /model gemini-3-pro-preview /model gemini-pro-latest /model gemma-4-31b-it /model gemini-3.1-flash-lite-preview ``` If you have not configured Gemini yet, exit the session and run `claway model` first. `/model` switches among already-configured providers and models; it does not collect new API keys. ## Diagnostics ```bash claway doctor ``` The doctor checks: - Whether `GOOGLE_API_KEY` or `GEMINI_API_KEY` is available - Whether configured provider credentials can be resolved ## Gateway (Messaging Platforms) Gemini works with all Claway gateway platforms (Telegram, Discord, Slack, WhatsApp, LINE, Feishu, etc.). Configure Gemini as your provider, then start the gateway normally: ```bash claway gateway setup claway gateway start ``` The gateway reads `config.yaml` and uses the same Gemini provider configuration. ## Troubleshooting ### "Gemini native client requires an API key" Claway could not find a usable API key. Add one of these to `~/.claway/.env`: ```bash GOOGLE_API_KEY=... # or GEMINI_API_KEY=... ``` Then run `claway model` again. ### "This Google API key is on the free tier" Claway probes Gemini API keys during setup. Free-tier quotas can be exhausted after a handful of agent turns because tool use, retries, compression, and auxiliary tasks may require multiple model calls. Enable billing on the Google Cloud project attached to your key, regenerate the key if needed, then run: ```bash claway model ``` ### "404 model not found" The selected model is not available for your account, region, or key. Run `claway model` again and pick another Gemini model from the current list. ### Gemma model is not shown in `claway model` Claway may hide low-throughput Gemma models from the picker by default. If you intentionally want to evaluate one, set the model ID directly in `~/.claway/config.yaml`. ### "429 quota exceeded" on Gemma Gemma models exposed through the Gemini API are useful for evaluation, but their Gemini API free-tier caps are low. Use them for compatibility testing, then switch to a paid Gemini model or another provider for sustained agent sessions. ### OpenAI-compatible endpoint is configured Check `~/.claway/.env` for: ```bash GEMINI_BASE_URL=https://generativelanguage.googleapis.com/v1beta/openai/ ``` Change it to the native endpoint or remove the override: ```bash GEMINI_BASE_URL=https://generativelanguage.googleapis.com/v1beta ``` ### Tool calling fails with schema errors Upgrade Claway and rerun `claway model`. The native Gemini adapter sanitizes tool schemas for Gemini's stricter function-declaration format; older builds or custom endpoints may not. ## Related - [AI Providers](/integrations/providers) - [Configuration](/user-guide/configuration) - [Fallback Providers](/user-guide/features/fallback-providers) - [AWS Bedrock](/guides/aws-bedrock) — native cloud-provider integration using AWS credentials --- <!-- source: website/docs/guides/google-vertex.md --> # Google Vertex AI # Google Vertex AI Claway Agent supports **Gemini models on Google Cloud Vertex AI** through Vertex's OpenAI-compatible endpoint. Unlike the [Google AI Studio provider](/guides/google-gemini) (which uses a static API key against `generativelanguage.googleapis.com`), Vertex gives you **enterprise-grade rate limits and GCP billing/credits**, and is the right choice when you want Gemini usage to draw on your Google Cloud account rather than an AI Studio key. :::info Vertex authenticates with OAuth2, not an API key Vertex has **no static API key** for the standard endpoint. Every request needs a short-lived **OAuth2 access token** (≈1 hour TTL) minted from either a service-account JSON or Application Default Credentials (ADC). Claway mints and **auto-refreshes** these tokens for you — you never paste a token by hand. This is why pasting a temporary token into a custom provider's `api_key` field does not work: it expires mid-session. ::: ## Prerequisites - **A Google Cloud project** with the **Vertex AI API enabled** and billing active. - **Credentials**, one of: - a **service-account JSON** key file with the `roles/aiplatform.user` role, or - **Application Default Credentials** via `gcloud auth application-default login` (or the metadata server when running on a GCP VM). - **`google-auth`** — installed automatically the first time you select Vertex (lazy install), or explicitly with `pip install 'claway[vertex]'`. ## Quick Start ```bash # Option A — service account JSON (recommended for servers / gateways) echo "VERTEX_CREDENTIALS_PATH=/path/to/service-account.json" >> ~/.claway/.env # Option B — Application Default Credentials (good for local dev) gcloud auth application-default login # Select Vertex as your provider claway model # → Choose "More providers..." → "Google Vertex AI" # → Enter your GCP project ID (or leave blank to use the one in your credentials) # → Choose a region (default: global) # → Select a Gemini model # Start chatting claway chat ``` ## Configuration Vertex splits its settings by sensitivity: - The **credential path** is a pointer to a secret and lives in `~/.claway/.env`. - **Project ID and region** are non-secret routing settings and live in `~/.claway/config.yaml`. `~/.claway/.env`: ```bash # One of these (checked in this order); omit both to use ADC: VERTEX_CREDENTIALS_PATH=/path/to/service-account.json GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json ``` `~/.claway/config.yaml`: ```yaml model: default: google/gemini-3-flash-preview provider: vertex vertex: project_id: my-gcp-project # blank → use the project embedded in the credentials region: global # "global" is required for the Gemini 3.x previews ``` :::tip Environment variables win over config.yaml `VERTEX_PROJECT_ID` and `VERTEX_REGION` override the `vertex.project_id` / `vertex.region` values in `config.yaml`. Use them for per-shell overrides; keep the durable settings in `config.yaml`. ::: ### How authentication works 1. Claway resolves credentials in this order: `VERTEX_CREDENTIALS_PATH` → `GOOGLE_APPLICATION_CREDENTIALS` → ADC. 2. It mints an OAuth2 access token (`cloud-platform` scope) and caches it, refreshing when the token is within 5 minutes of expiry. 3. The token is handed to a standard OpenAI client pointed at the Vertex endpoint: ```text https://aiplatform.googleapis.com/v1beta1/projects/{project}/locations/{region}/endpoints/openapi ``` Regional locations use a `{region}-aiplatform.googleapis.com` host instead. 4. If a session runs longer than the token lifetime and a request returns `401`, Claway re-mints the token and retries automatically. On a long-running gateway, if ADC's refresh token has itself expired, Claway falls back to the service-account JSON when one is configured. ## Available Models Vertex requires the `google/` vendor prefix on model IDs. The `claway model` picker offers: | Model | ID | |-------|----| | Gemini 3.1 Pro Preview | `google/gemini-3.1-pro-preview` | | Gemini 3 Pro Preview | `google/gemini-3-pro-preview` | | Gemini 3 Flash Preview | `google/gemini-3-flash-preview` | | Gemini 3.1 Flash Lite Preview | `google/gemini-3.1-flash-lite-preview` | | Gemini 2.5 Pro | `google/gemini-2.5-pro` | | Gemini 2.5 Flash | `google/gemini-2.5-flash` | :::note `global` region for Gemini 3.x The Gemini 3.x preview models are served through the `global` endpoint. Regional endpoints (`us-central1`, etc.) may 404 them. Leave `region: global` unless you have a specific reason to pin a region. ::: ## Switching Models Mid-Session ```text /model google/gemini-3-pro-preview /model google/gemini-3-flash-preview ``` `/model` switches among already-configured providers and models; it does not collect new credentials. Configure Vertex with `claway model` first. ## Reasoning / Thinking Vertex exposes Gemini's thinking budget through the OpenAI-compatible surface. Claway maps its reasoning-effort setting onto `extra_body.google.thinking_config` automatically, so `reasoning_effort` works the same way it does on other Gemini surfaces. ## Diagnostics ```bash claway doctor ``` The doctor reports whether Vertex credentials can be resolved (service-account path or ADC) and whether the provider is configured. ## Troubleshooting ### "Vertex AI credentials could not be resolved" Claway found neither a service-account JSON nor working ADC. Either set `VERTEX_CREDENTIALS_PATH` in `~/.claway/.env`, or run `gcloud auth application-default login`. If your project isn't embedded in the credentials, set `vertex.project_id` in `config.yaml`. ### `google-auth` not installed Install the extra: `pip install 'claway[vertex]'`. Claway also lazy-installs it the first time you select the Vertex provider. ### 404 on Gemini 3.x models You are probably on a regional endpoint. Set `region: global` in the `vertex:` section of `config.yaml` (or unset `VERTEX_REGION`). ### 403 / permission denied The service account (or your ADC identity) needs the `roles/aiplatform.user` role on the project, and the Vertex AI API must be enabled for that project. ## Related - [Google Gemini (AI Studio)](/guides/google-gemini) — static-API-key Gemini without GCP - [AWS Bedrock](/guides/aws-bedrock) — another native cloud-provider integration - [AI Providers](/integrations/providers) - [Configuration](/user-guide/configuration) --- <!-- source: website/docs/guides/local-llm-on-mac.md --> # Run Local LLMs on Mac # Run Local LLMs on Mac This guide walks you through running a local LLM server on macOS with an OpenAI-compatible API. You get full privacy, zero API costs, and surprisingly good performance on Apple Silicon. We cover two backends: | Backend | Install | Best at | Format | |---------|---------|---------|--------| | **llama.cpp** | `brew install llama.cpp` | Fastest time-to-first-token, quantized KV cache for low memory | GGUF | | **omlx** | [omlx.ai](https://omlx.ai) | Fastest token generation, native Metal optimization | MLX (safetensors) | Both expose an OpenAI-compatible `/v1/chat/completions` endpoint. Claway works with either one — just point it at `http://localhost:8080` or `http://localhost:8000`. :::info Apple Silicon only This guide targets Macs with Apple Silicon (M1 and later). Intel Macs will work with llama.cpp but without GPU acceleration — expect significantly slower performance. ::: --- ## Choosing a model For getting started, we recommend **Qwen3.5-9B** — it's a strong reasoning model that fits comfortably in 8GB+ of unified memory with quantization. | Variant | Size on disk | RAM needed (128K context) | Backend | |---------|-------------|---------------------------|---------| | Qwen3.5-9B-Q4_K_M (GGUF) | 5.3 GB | ~10 GB with quantized KV cache | llama.cpp | | Qwen3.5-9B-mlx-lm-mxfp4 (MLX) | ~5 GB | ~12 GB | omlx | **Memory rule of thumb:** model size + KV cache. A 9B Q4 model is ~5 GB. The KV cache at 128K context with Q4 quantization adds ~4-5 GB. With default (f16) KV cache, that balloons to ~16 GB. The quantized KV cache flags in llama.cpp are the key trick for memory-constrained systems. For larger models (27B, 35B), you'll need 32 GB+ of unified memory. The 9B is the sweet spot for 8-16 GB machines. --- ## Option A: llama.cpp llama.cpp is the most portable local LLM runtime. On macOS it uses Metal for GPU acceleration out of the box. ### Install ```bash brew install llama.cpp ``` This gives you the `llama-server` command globally. ### Download the model You need a GGUF-format model. The easiest source is Hugging Face via the `huggingface-cli`: ```bash brew install huggingface-cli ``` Then download: ```bash huggingface-cli download unsloth/Qwen3.5-9B-GGUF Qwen3.5-9B-Q4_K_M.gguf --local-dir ~/models ``` :::tip Gated models Some models on Hugging Face require authentication. Run `huggingface-cli login` first if you get a 401 or 404 error. ::: ### Start the server ```bash llama-server -m ~/models/Qwen3.5-9B-Q4_K_M.gguf \ -ngl 99 \ -c 131072 \ -np 1 \ -fa on \ --cache-type-k q4_0 \ --cache-type-v q4_0 \ --host 0.0.0.0 ``` Here's what each flag does: | Flag | Purpose | |------|---------| | `-ngl 99` | Offload all layers to GPU (Metal). Use a high number to ensure nothing stays on CPU. | | `-c 131072` | Context window size (128K tokens). Reduce this if you're low on memory. | | `-np 1` | Number of parallel slots. Keep at 1 for single-user use — more slots split your memory budget. | | `-fa on` | Flash attention. Reduces memory usage and speeds up long-context inference. | | `--cache-type-k q4_0` | Quantize the key cache to 4-bit. **This is the big memory saver.** | | `--cache-type-v q4_0` | Quantize the value cache to 4-bit. Together with the above, this cuts KV cache memory by ~75% vs f16. | | `--host 0.0.0.0` | Listen on all interfaces. Use `127.0.0.1` if you don't need network access. | The server is ready when you see: ``` main: server is listening on http://0.0.0.0:8080 srv update_slots: all slots are idle ``` ### Memory optimization for constrained systems The `--cache-type-k q4_0 --cache-type-v q4_0` flags are the most important optimization for systems with limited memory. Here's the impact at 128K context: | KV cache type | KV cache memory (128K ctx, 9B model) | |---------------|--------------------------------------| | f16 (default) | ~16 GB | | q8_0 | ~8 GB | | **q4_0** | **~4 GB** | On an 8 GB Mac, use `q4_0` KV cache and choose a smaller model that can still fit Claway's 64K minimum context. On 16 GB, you can comfortably do 128K context. On 32 GB+, you can run larger models or multiple parallel slots. If you're still running out of memory, reduce context only while staying at or above Claway's 64K minimum; otherwise switch to a smaller model or smaller quantization (Q3_K_M instead of Q4_K_M). ### Test it ```bash curl -s http://localhost:8080/v1/chat/completions \ -H "Content-Type: application/json" \ -d '{ "model": "Qwen3.5-9B-Q4_K_M.gguf", "messages": [{"role": "user", "content": "Hello!"}], "max_tokens": 50 }' | jq .choices[0].message.content ``` ### Get the model name If you forget the model name, query the models endpoint: ```bash curl -s http://localhost:8080/v1/models | jq '.data[].id' ``` --- ## Option B: MLX via omlx [omlx](https://omlx.ai) is a macOS-native app that manages and serves MLX models. MLX is Apple's own machine learning framework, optimized specifically for Apple Silicon's unified memory architecture. ### Install Download and install from [omlx.ai](https://omlx.ai). It provides a GUI for model management and a built-in server. ### Download the model Use the omlx app to browse and download models. Search for `Qwen3.5-9B-mlx-lm-mxfp4` and download it. Models are stored locally (typically in `~/.omlx/models/`). ### Start the server omlx serves models on `http://127.0.0.1:8000` by default. Start serving from the app UI, or use the CLI if available. ### Test it ```bash curl -s http://127.0.0.1:8000/v1/chat/completions \ -H "Content-Type: application/json" \ -d '{ "model": "Qwen3.5-9B-mlx-lm-mxfp4", "messages": [{"role": "user", "content": "Hello!"}], "max_tokens": 50 }' | jq .choices[0].message.content ``` ### List available models omlx can serve multiple models simultaneously: ```bash curl -s http://127.0.0.1:8000/v1/models | jq '.data[].id' ``` --- ## Benchmarks: llama.cpp vs MLX Both backends tested on the same machine (Apple M5 Max, 128 GB unified memory) running the same model (Qwen3.5-9B) at comparable quantization levels (Q4_K_M for GGUF, mxfp4 for MLX). Five diverse prompts, three runs each, backends tested sequentially to avoid resource contention. ### Results | Metric | llama.cpp (Q4_K_M) | MLX (mxfp4) | Winner | |--------|-------------------|-------------|--------| | **TTFT (avg)** | **67 ms** | 289 ms | llama.cpp (4.3x faster) | | **TTFT (p50)** | **66 ms** | 286 ms | llama.cpp (4.3x faster) | | **Generation (avg)** | 70 tok/s | **96 tok/s** | MLX (37% faster) | | **Generation (p50)** | 70 tok/s | **96 tok/s** | MLX (37% faster) | | **Total time (512 tokens)** | 7.3s | **5.5s** | MLX (25% faster) | ### What this means - **llama.cpp** excels at prompt processing — its flash attention + quantized KV cache pipeline gets you the first token in ~66ms. If you're building interactive applications where perceived responsiveness matters (chatbots, autocomplete), this is a meaningful advantage. - **MLX** generates tokens ~37% faster once it gets going. For batch workloads, long-form generation, or any task where total completion time matters more than initial latency, MLX finishes sooner. - Both backends are **extremely consistent** — variance across runs was negligible. You can rely on these numbers. ### Which one should you pick? | Use case | Recommendation | |----------|---------------| | Interactive chat, low-latency tools | llama.cpp | | Long-form generation, bulk processing | MLX (omlx) | | Memory-constrained (8-16 GB) | llama.cpp (quantized KV cache is unmatched) | | Serving multiple models simultaneously | omlx (built-in multi-model support) | | Maximum compatibility (Linux too) | llama.cpp | --- ## Connect to Claway Once your local server is running: ```bash claway model ``` Select **Custom endpoint** and follow the prompts. It will ask for the base URL and model name — use the values from whichever backend you set up above. --- ## Timeouts Claway automatically detects local endpoints (localhost, LAN IPs) and relaxes its streaming timeouts. No configuration needed for most setups. If you still hit timeout errors (e.g. very large contexts on slow hardware), you can override the streaming read timeout: ```bash # In your .env — raise from the 120s default to 30 minutes CLAWAY_STREAM_READ_TIMEOUT=1800 ``` | Timeout | Default | Local auto-adjustment | Env var override | |---------|---------|----------------------|------------------| | Stream read (socket-level) | 120s | Raised to 1800s | `CLAWAY_STREAM_READ_TIMEOUT` | | Stale stream detection | 180s | Disabled entirely | `CLAWAY_STREAM_STALE_TIMEOUT` | | API call (non-streaming) | 1800s | No change needed | `CLAWAY_API_TIMEOUT` | The stream read timeout is the one most likely to cause issues — it's the socket-level deadline for receiving the next chunk of data. During prefill on large contexts, local models may produce no output for minutes while processing the prompt. The auto-detection handles this transparently. --- <!-- source: website/docs/guides/local-ollama-setup.md --> # Run Claway Locally with Ollama — Zero API Cost # Run Claway Locally with Ollama — Zero API Cost ## The Problem Cloud LLM APIs charge per token. A heavy coding session can cost $5–20. For personal projects, learning, or privacy-sensitive work, that adds up — and you're sending every conversation to a third party. ## What This Guide Solves You'll set up Claway Agent running entirely on your own hardware, using [Ollama](https://ollama.com) as the model backend. No API keys, no subscriptions, no data leaving your machine. Once configured, Claway works exactly like it does with OpenRouter or Anthropic — terminal commands, file editing, web browsing, delegation — but the model runs locally. By the end, you'll have: - Ollama serving one or more open-weight models - Claway connected to Ollama as a custom endpoint - A working local agent that can edit files, run commands, and browse the web - Optional: a Telegram/Discord bot powered entirely by your own hardware ## What You Need | Component | Minimum | Recommended | |-----------|---------|-------------| | **RAM** | 8 GB (for 3B models) | 32+ GB (for 27B+ models) | | **Storage** | 5 GB free | 30+ GB (for multiple models) | | **CPU** | 4 cores | 8+ cores (AMD EPYC, Ryzen, Intel Xeon) | | **GPU** | Not required | NVIDIA GPU with 8+ GB VRAM speeds things up significantly | :::tip CPU-only works, but expect slower responses Ollama runs on CPU-only servers. A 9B model on a modern 8-core CPU gives ~10 tokens/sec. A 31B model on CPU is slower (~2–5 tokens/sec) — each response takes 30–120 seconds, but it works. A GPU dramatically improves this. For CPU-only setups, widen the API timeout via the env var (it's not a `config.yaml` key): ```bash # ~/.claway/.env CLAWAY_API_TIMEOUT=1800 # 30 minutes — generous for slow local models ``` ::: ## Step 1: Install Ollama ```bash curl -fsSL https://ollama.com/install.sh | sh ``` Verify it's running: ```bash ollama --version curl http://localhost:11434/api/tags # Should return {"models":[]} ``` ## Step 2: Pull a Model Choose based on your hardware: | Model | Size on Disk | RAM Needed | Tool Calling | Best For | |-------|-------------|------------|:------------:|----------| | `gemma4:31b` | ~20 GB | 24+ GB | Yes | Best quality — strong tool use and reasoning | | `gemma2:27b` | ~16 GB | 20+ GB | No | Conversational tasks, no tool use | | `gemma2:9b` | ~5 GB | 8+ GB | No | Fast chat, Q&A — cannot call tools | | `llama3.2:3b` | ~2 GB | 4+ GB | No | Lightweight quick answers only | :::warning Tool calling matters Claway is an **agentic** assistant — it edits files, runs commands, and browses the web through tool calls. Models without tool-call support can only chat; they can't take actions. For the full Claway experience, use a model that supports tools (like `gemma4:31b`). ::: Pull your chosen model: ```bash ollama pull gemma4:31b ``` :::info Multiple models You can pull several models and switch between them inside Claway with `/model`. Ollama loads the active model into memory on demand and unloads idle ones automatically. ::: Verify the model works: ```bash curl http://localhost:11434/v1/chat/completions \ -H "Content-Type: application/json" \ -d '{ "model": "gemma4:31b", "messages": [{"role": "user", "content": "Say hello"}], "max_tokens": 50 }' ``` You should see a JSON response with the model's reply. ## Step 3: Configure Claway Run the Claway setup wizard: ```bash claway setup ``` When prompted for a provider, select **Custom Endpoint** and enter: - **Base URL:** `http://localhost:11434/v1` - **API Key:** Leave empty or type `no-key` (Ollama doesn't need one) - **Model:** `gemma4:31b` (or whichever model you pulled) Alternatively, edit `~/.claway/config.yaml` directly: ```yaml model: default: "gemma4:31b" provider: "custom" base_url: "http://localhost:11434/v1" ``` ## Step 4: Start Using Claway ```bash claway ``` That's it. You're now running a fully local agent. Try it out: ``` You: List all Python files in this directory and count the lines of code in each You: Read the README.md and summarize what this project does You: Create a Python script that fetches the weather for Ho Chi Minh City ``` Claway will use the terminal tool, file operations, and your local model — no cloud calls. ## Step 5: Pick the Right Model for Your Task Not every task needs the biggest model. Here's a practical guide: | Task | Recommended Model | Why | |------|-------------------|-----| | File edits, code, terminal commands | `gemma4:31b` | Only model with reliable tool calling | | Quick Q&A (no tool use needed) | `gemma2:9b` | Fast responses for conversational tasks | | Lightweight chat | `llama3.2:3b` | Fastest, but very limited capabilities | :::note For full agentic work (editing files, running commands, browsing), `gemma4:31b` is currently the best local option with tool-call support. Check [Ollama's model library](https://ollama.com/library) for newer models — tool-calling support is expanding rapidly. ::: Switch models on the fly inside a session: ``` /model gemma2:9b ``` ## Step 6: Optimize for Speed ### Increase Ollama's Context Window By default, Ollama uses a 2048-token context. Claway requires at least 64,000 tokens for agentic work with tools: ```bash # Create a Modelfile that extends context cat > /tmp/Modelfile << 'EOF' FROM gemma4:31b PARAMETER num_ctx 64000 EOF ollama create gemma4-64k -f /tmp/Modelfile ``` Then update your Claway config to use `gemma4-64k` as the model name. ### Keep the Model Loaded By default, Ollama unloads models after 5 minutes of inactivity. For a persistent gateway bot, keep it loaded: ```bash # Set keep-alive to 24 hours curl http://localhost:11434/api/generate \ -d '{"model": "gemma4:31b", "keep_alive": "24h"}' ``` Or set it globally in Ollama's environment: ```bash # /etc/systemd/system/ollama.service.d/override.conf [Service] Environment="OLLAMA_KEEP_ALIVE=24h" ``` ### Use GPU Offloading (If Available) If you have an NVIDIA GPU, Ollama automatically offloads layers to it. Check with: ```bash ollama ps # Shows which model is loaded and how many GPU layers ``` For a 31B model on a 12 GB GPU, you'll get partial offload (~40 layers on GPU, rest on CPU), which still gives a significant speedup. ## Step 7: Run as a Gateway Bot (Optional) Once Claway works locally in the CLI, you can expose it as a Telegram or Discord bot — still running entirely on your hardware. ### Telegram 1. Create a bot via [@BotFather](https://t.me/BotFather) and get the token 2. Add to your `~/.claway/config.yaml`: ```yaml model: default: "gemma4:31b" provider: "custom" base_url: "http://localhost:11434/v1" platforms: telegram: enabled: true token: "YOUR_TELEGRAM_BOT_TOKEN" ``` 3. Start the gateway: ```bash claway gateway ``` Now message your bot on Telegram — it responds using your local model. ### Discord 1. Create a Discord application at [discord.com/developers](https://discord.com/developers/applications) 2. Add to config: ```yaml platforms: discord: enabled: true token: "YOUR_DISCORD_BOT_TOKEN" ``` 3. Start: `claway gateway` ## Step 8: Set Up Fallbacks (Optional) Local models can struggle with complex tasks. Set up a cloud fallback that only activates when the local model fails: ```yaml model: default: "gemma4:31b" provider: "custom" base_url: "http://localhost:11434/v1" fallback_providers: - provider: openrouter model: anthropic/claude-sonnet-4 ``` This way, 90% of your usage is free (local), and only the hard tasks hit the paid API. ## Troubleshooting ### "Connection refused" on startup Ollama isn't running. Start it: ```bash sudo systemctl start ollama # or ollama serve ``` ### Slow responses - **Check model size vs RAM:** If your model needs more RAM than available, it swaps to disk. Use a smaller model or add RAM. - **Check `ollama ps`:** If no GPU layers are offloaded, responses are CPU-bound. This is normal for CPU-only servers. - **Reduce context:** Large conversations slow down inference. Use `/compress` regularly, or set a lower compression threshold in config. ### Model doesn't follow tool calls Smaller models (3B, 7B) sometimes ignore tool-call instructions and produce plain text instead of structured function calls. Solutions: - **Use a bigger model** — `gemma4:31b` or `gemma2:27b` handle tool calls much better than 3B/7B models. - **Claway has auto-repair** — it detects malformed tool calls and attempts to fix them automatically. - **Set up a fallback** — if the local model fails 3 times, Claway falls back to a cloud provider. ### Context window errors The default Ollama context (2048 tokens) is too small for agentic work. See [Step 6](#step-6-optimize-for-speed) to increase it. ## Cost Comparison Here's what running locally saves compared to cloud APIs, based on a typical coding session (~100K tokens input, ~20K tokens output): | Provider | Cost per Session | Monthly (daily use) | |----------|-----------------|---------------------| | Anthropic Claude Sonnet | ~$0.80 | ~$24 | | OpenRouter (GPT-4o) | ~$0.60 | ~$18 | | **Ollama (local)** | **$0.00** | **$0.00** | Your only cost is electricity — roughly $0.01–0.05 per session depending on hardware. ## What Works Well Locally - **File editing and code generation** — models 9B+ handle this well - **Terminal commands** — Claway wraps the command, runs it, reads output regardless of model - **Web browsing** — the browser tool does the fetching; the model just interprets results - **Cron jobs and scheduled tasks** — work identically to cloud setups - **Multi-platform gateway** — Telegram, Discord, Slack all work with local models ## What's Better with Cloud Models - **Very complex multi-step reasoning** — 70B+ or cloud models like Claude Opus are noticeably better - **Long context windows** — cloud models offer 100K–1M tokens; local runtimes often default below Claway's 64K minimum unless you configure them - **Speed on large responses** — cloud inference is faster than CPU-only local for long generations The sweet spot: use local for everyday tasks, set up a cloud fallback for the hard stuff. --- <!-- source: website/docs/guides/microsoft-graph-app-registration.md --> # Register a Microsoft Graph Application # Register a Microsoft Graph Application The Teams meeting pipeline reads meeting transcripts, recordings, and related artifacts from Microsoft Graph using **app-only** (daemon) authentication — no user sign-in, no interactive consent per meeting. That requires an Azure AD application registration with admin-consented application permissions. This guide walks through: 1. Creating the app registration 2. Creating a client secret 3. Granting the Graph API permissions the pipeline needs 4. Admin-consenting those permissions 5. (Optional) Scoping the app to specific users with an Application Access Policy You need **tenant admin rights** (or an admin to grant consent on your behalf) to finish this. Bookmark the values you collect — they go into `~/.claway/.env` at the end. ## Prerequisites - A Microsoft 365 tenant with Teams Premium or Teams licenses that produce meeting transcripts and recordings - Admin access to the Azure portal at [entra.microsoft.com](https://entra.microsoft.com) - A publicly reachable HTTPS endpoint for Graph change notifications (set up later, in the webhook listener step) ## Step 1: Create the App Registration 1. Sign in to [entra.microsoft.com](https://entra.microsoft.com) as a tenant admin. 2. Navigate to **Identity → Applications → App registrations**. 3. Click **New registration**. 4. Fill in: - **Name:** `Claway Teams Meeting Pipeline` (or any name you'll recognize). - **Supported account types:** *Accounts in this organizational directory only (Single tenant)*. - **Redirect URI:** leave blank — app-only auth does not need one. 5. Click **Register**. You'll land on the app's overview page. Copy two values: - **Application (client) ID** → `MSGRAPH_CLIENT_ID` - **Directory (tenant) ID** → `MSGRAPH_TENANT_ID` ## Step 2: Create a Client Secret 1. In the left nav, open **Certificates & secrets**. 2. Click **New client secret**. 3. **Description:** `claway-graph-secret`. **Expires:** pick a value that matches your rotation policy (6-24 months is typical). 4. Click **Add**. 5. Copy the **Value** column immediately — it's only shown once. That value is `MSGRAPH_CLIENT_SECRET`. > The **Secret ID** column is not the secret. You want the **Value** column. ## Step 3: Grant Graph API Permissions The pipeline uses a minimum-viable set of application permissions. Add only what you need; each one widens what the app can read tenant-wide. 1. In the left nav, open **API permissions**. 2. Click **Add a permission** → **Microsoft Graph** → **Application permissions**. 3. Add the permissions from the table below that match what you want the pipeline to do. 4. After adding, click **Grant admin consent for `<your tenant>`**. The Status column should flip to a green checkmark for every permission. ### Required for transcript-first summaries | Permission | What it lets the app do | |------------|--------------------------| | `OnlineMeetings.Read.All` | Read Teams online meeting metadata (subject, participants, join URL). | | `OnlineMeetingTranscript.Read.All` | Read meeting transcripts generated by Teams. | ### Required for recording fallback (when a transcript is unavailable) | Permission | What it lets the app do | |------------|--------------------------| | `OnlineMeetingRecording.Read.All` | Download Teams meeting recordings for offline STT processing. | | `CallRecords.Read.All` | Resolve meetings from call records when only the join URL is known. | ### Required for outbound summary delivery (Graph mode only) If `platforms.teams.extra.delivery_mode` is `graph`, the pipeline posts summaries into a Teams channel or chat via the Graph API. Skip these if you use `incoming_webhook` delivery mode instead. | Permission | What it lets the app do | |------------|--------------------------| | `ChannelMessage.Send` | Post messages into Teams channels on behalf of the app. | | `Chat.ReadWrite.All` | Post messages into 1:1 and group chats (only if you set `chat_id` as the delivery target). | ### Not recommended - `OnlineMeetings.ReadWrite.All` / `Chat.ReadWrite` without `.All` — broader than the pipeline needs. - Delegated permissions — the pipeline uses app-only (client-credentials) flow; delegated permissions won't work without user sign-in. ## Step 4: (Recommended) Scope the App with an Application Access Policy By default, application permissions like `OnlineMeetings.Read.All` grant the app access to **every** meeting in the tenant. For partner demos and dev tenants that's fine; for production you almost certainly want to restrict which users' meetings the app can read. Microsoft provides **Application Access Policies** for Teams exactly for this. The policy is a PowerShell-only surface; there's no portal UI for it. From an admin PowerShell with the MicrosoftTeams module installed and connected (`Connect-MicrosoftTeams`): ```powershell # Create a policy scoped to the Claway app New-CsApplicationAccessPolicy ` -Identity "Claway-Meeting-Pipeline-Policy" ` -AppIds "<MSGRAPH_CLIENT_ID>" ` -Description "Restrict Claway meeting pipeline to allow-listed users" # Grant the policy to specific users whose meetings the pipeline may read Grant-CsApplicationAccessPolicy ` -PolicyName "Claway-Meeting-Pipeline-Policy" ` -Identity "alice@example.com" Grant-CsApplicationAccessPolicy ` -PolicyName "Claway-Meeting-Pipeline-Policy" ` -Identity "bob@example.com" ``` Propagation can take up to 30 minutes after granting. Verify with: ```powershell Test-CsApplicationAccessPolicy -Identity "alice@example.com" -AppId "<MSGRAPH_CLIENT_ID>" ``` Without the policy, **any** user's meetings are readable — that's what the permission technically grants. Don't skip this step on a production tenant. ## Step 5: Write the Credentials to Your Env File Put the three values you collected into `~/.claway/.env`: ```bash MSGRAPH_TENANT_ID=<directory-tenant-id> MSGRAPH_CLIENT_ID=<application-client-id> MSGRAPH_CLIENT_SECRET=<client-secret-value> ``` Set file permissions so only you can read the secret: ```bash chmod 600 ~/.claway/.env ``` ## Step 6: Verify the Token Flow Claway ships a Graph auth smoke-test. From your Claway install: ```python python -c " import asyncio from tools.microsoft_graph_auth import MicrosoftGraphTokenProvider provider = MicrosoftGraphTokenProvider.from_env() token = asyncio.run(provider.get_access_token()) print('Token acquired, length:', len(token)) print(provider.inspect_token_health()) " ``` A successful run prints a long token string and a health dict showing `cached: True` and an `expires_in_seconds` value near 3600. Failures produce a `MicrosoftGraphTokenError` with the Azure error code — the most common are: | Azure error | Meaning | Fix | |-------------|---------|-----| | `AADSTS7000215: Invalid client secret` | Secret value mismatched or expired. | Generate a new secret in step 2; update `.env`. | | `AADSTS700016: Application not found` | Wrong `MSGRAPH_CLIENT_ID` or wrong tenant. | Double-check the values from step 1 are from the same app. | | `AADSTS90002: Tenant not found` | Typo in `MSGRAPH_TENANT_ID`. | Copy the Directory (tenant) ID from the app overview again. | | `insufficient_claims` at call time (not token time) | Token acquires but Graph returns 401/403. | You skipped step 3 admin-consent, or added permissions but haven't re-consented. Revisit API permissions and click **Grant admin consent** again. | ## Rotating the Client Secret Azure client secrets have a hard expiry. Before yours expires: 1. Create a second client secret in step 2 without deleting the first one. 2. Update `MSGRAPH_CLIENT_SECRET` in `~/.claway/.env` with the new value. 3. Restart the gateway so the new secret is picked up: `claway gateway restart`. 4. Verify with the smoke test above. 5. Delete the old secret from the Azure portal. ## Next Steps Once credentials verify cleanly, continue with: - **Webhook listener setup** — stand up the `msgraph_webhook` gateway platform that receives Graph change notifications. - **Pipeline configuration** — configure the Teams meeting pipeline runtime and operator CLI. - **Outbound delivery** — wire summaries back into a Teams channel or chat. Those pages land alongside the PRs that add the corresponding runtime. This credentials setup is a standalone prerequisite and is safe to complete in advance. --- <!-- source: website/docs/guides/migrate-from-openclaw.md --> # Migrate from OpenClaw # Migrate from OpenClaw `claway claw migrate` imports your OpenClaw (or legacy Clawdbot/Moldbot) setup into Claway. This guide covers exactly what gets migrated, the config key mappings, and what to verify after migration. ## Quick start ```bash # Preview then migrate (always shows a preview first, then asks to confirm) claway claw migrate # Preview only, no changes claway claw migrate --dry-run # Full migration including API keys, skip confirmation claway claw migrate --preset full --migrate-secrets --yes ``` The migration always shows a full preview of what will be imported before making any changes. Review the list, then confirm to proceed. Reads from `~/.openclaw/` by default. Legacy `~/.clawdbot/` or `~/.moltbot/` directories are detected automatically. Same for legacy config filenames (`clawdbot.json`, `moltbot.json`). ## Options | Option | Description | |--------|-------------| | `--dry-run` | Preview only — stop after showing what would be migrated. | | `--preset <name>` | `full` (all compatible settings) or `user-data` (excludes infrastructure config). Neither preset imports secrets by default — pass `--migrate-secrets` explicitly. | | `--overwrite` | Overwrite existing Claway files on conflicts (default: refuse to apply when the plan has conflicts). | | `--migrate-secrets` | Include API keys. Required even under `--preset full` — no preset imports secrets silently. | | `--no-backup` | Skip the pre-migration zip snapshot of `~/.claway/` (by default a single restore-point archive is written before apply, under `~/.claway/backups/pre-migration-*.zip`; restorable with `claway import`). | | `--source <path>` | Custom OpenClaw directory. | | `--workspace-target <path>` | Where to place `AGENTS.md`. | | `--skill-conflict <mode>` | `skip` (default), `overwrite`, or `rename`. | | `--yes` | Skip the confirmation prompt after preview. | ## What gets migrated ### Persona, memory, and instructions | What | OpenClaw source | Claway destination | Notes | |------|----------------|-------------------|-------| | Persona | `workspace/SOUL.md` | `~/.claway/SOUL.md` | Direct copy | | Workspace instructions | `workspace/AGENTS.md` | `AGENTS.md` in `--workspace-target` | Requires `--workspace-target` flag | | Long-term memory | `workspace/MEMORY.md` | `~/.claway/memories/MEMORY.md` | Parsed into entries, merged with existing, deduped. Uses `§` delimiter. | | User profile | `workspace/USER.md` | `~/.claway/memories/USER.md` | Same entry-merge logic as memory. | | Daily memory files | `workspace/memory/*.md` | `~/.claway/memories/MEMORY.md` | All daily files merged into main memory. | Workspace files are also checked at `workspace.default/` and `workspace-main/` as fallback paths (OpenClaw renamed `workspace/` to `workspace-main/` in recent versions, and uses `workspace-{agentId}` for multi-agent setups). ### Skills (4 sources) | Source | OpenClaw location | Claway destination | |--------|------------------|-------------------| | Workspace skills | `workspace/skills/` | `~/.claway/skills/openclaw-imports/` | | Managed/shared skills | `~/.openclaw/skills/` | `~/.claway/skills/openclaw-imports/` | | Personal cross-project | `~/.agents/skills/` | `~/.claway/skills/openclaw-imports/` | | Project-level shared | `workspace/.agents/skills/` | `~/.claway/skills/openclaw-imports/` | Skill conflicts are handled by `--skill-conflict`: `skip` leaves the existing Claway skill, `overwrite` replaces it, `rename` creates a `-imported` copy. ### Model and provider configuration | What | OpenClaw config path | Claway destination | Notes | |------|---------------------|-------------------|-------| | Default model | `agents.defaults.model` | `config.yaml` → `model` | Can be a string or `{primary, fallbacks}` object | | Custom providers | `models.providers.*` | `config.yaml` → `custom_providers` | Maps `baseUrl`, `apiType`/`api` — handles both short ("openai", "anthropic") and hyphenated ("openai-completions", "anthropic-messages", "google-generative-ai") values | | Provider API keys | `models.providers.*.apiKey` | `~/.claway/.env` | Requires `--migrate-secrets`. See [API key resolution](#api-key-resolution) below. | ### Agent behavior | What | OpenClaw config path | Claway config path | Mapping | |------|---------------------|-------------------|---------| | Max turns | `agents.defaults.timeoutSeconds` | `agent.max_turns` | `timeoutSeconds / 10`, capped at 200 | | Verbose mode | `agents.defaults.verboseDefault` | `agent.verbose` | "off" / "on" / "full" | | Reasoning effort | `agents.defaults.thinkingDefault` | `agent.reasoning_effort` | "always"/"high"/"xhigh" → "high", "auto"/"medium"/"adaptive" → "medium", "off"/"low"/"none"/"minimal" → "low" | | Compression | `agents.defaults.compaction.mode` | `compression.enabled` | "off" → false, anything else → true | | Compression model | `agents.defaults.compaction.model` | `compression.summary_model` | Direct string copy | | Human delay | `agents.defaults.humanDelay.mode` | `human_delay.mode` | "natural" / "custom" / "off" | | Human delay timing | `agents.defaults.humanDelay.minMs` / `.maxMs` | `human_delay.min_ms` / `.max_ms` | Direct copy | | Timezone | `agents.defaults.userTimezone` | `timezone` | Direct string copy | | Exec timeout | `tools.exec.timeoutSec` | `terminal.timeout` | Direct copy (field is `timeoutSec`, not `timeout`) | | Docker sandbox | `agents.defaults.sandbox.backend` | `terminal.backend` | "docker" → "docker" | | Docker image | `agents.defaults.sandbox.docker.image` | `terminal.docker_image` | Direct copy | ### Session reset policies | OpenClaw config path | Claway config path | Notes | |---------------------|-------------------|-------| | `session.reset.mode` | `session_reset.mode` | "daily", "idle", or both | | `session.reset.atHour` | `session_reset.at_hour` | Hour (0–23) for daily reset | | `session.reset.idleMinutes` | `session_reset.idle_minutes` | Minutes of inactivity | Note: OpenClaw also has `session.resetTriggers` (a simple string array like `["daily", "idle"]`). If the structured `session.reset` isn't present, the migration falls back to inferring from `resetTriggers`. ### MCP servers | OpenClaw field | Claway field | Notes | |----------------|-------------|-------| | `mcp.servers.*.command` | `mcp_servers.*.command` | Stdio transport | | `mcp.servers.*.args` | `mcp_servers.*.args` | | | `mcp.servers.*.env` | `mcp_servers.*.env` | | | `mcp.servers.*.cwd` | `mcp_servers.*.cwd` | | | `mcp.servers.*.url` | `mcp_servers.*.url` | HTTP/SSE transport | | `mcp.servers.*.tools.include` | `mcp_servers.*.tools.include` | Tool filtering | | `mcp.servers.*.tools.exclude` | `mcp_servers.*.tools.exclude` | | ### TTS (text-to-speech) TTS settings are read from **two** OpenClaw config locations with this priority: 1. `messages.tts.providers.{provider}.*` (canonical location) 2. Top-level `talk.providers.{provider}.*` (fallback) 3. Legacy flat keys `messages.tts.{provider}.*` (oldest format) | What | Claway destination | |------|-------------------| | Provider name | `config.yaml` → `tts.provider` | | ElevenLabs voice ID | `config.yaml` → `tts.elevenlabs.voice_id` | | ElevenLabs model ID | `config.yaml` → `tts.elevenlabs.model_id` | | OpenAI model | `config.yaml` → `tts.openai.model` | | OpenAI voice | `config.yaml` → `tts.openai.voice` | | Edge TTS voice | `config.yaml` → `tts.edge.voice` (OpenClaw renamed "edge" to "microsoft" — both are recognized) | | TTS assets | `~/.claway/tts/` (file copy) | ### Messaging platforms | Platform | OpenClaw config path | Claway `.env` variable | Notes | |----------|---------------------|----------------------|-------| | Telegram | `channels.telegram.botToken` or `.accounts.default.botToken` | `TELEGRAM_BOT_TOKEN` | Token can be string or [SecretRef](#secretref-handling). Both flat and accounts layout supported. | | Telegram | `credentials/telegram-default-allowFrom.json` | `TELEGRAM_ALLOWED_USERS` | Comma-joined from `allowFrom[]` array | | Discord | `channels.discord.token` or `.accounts.default.token` | `DISCORD_BOT_TOKEN` | | | Discord | `channels.discord.allowFrom` or `.accounts.default.allowFrom` | `DISCORD_ALLOWED_USERS` | | | Slack | `channels.slack.botToken` or `.accounts.default.botToken` | `SLACK_BOT_TOKEN` | | | Slack | `channels.slack.appToken` or `.accounts.default.appToken` | `SLACK_APP_TOKEN` | | | Slack | `channels.slack.allowFrom` or `.accounts.default.allowFrom` | `SLACK_ALLOWED_USERS` | | | WhatsApp | `channels.whatsapp.allowFrom` or `.accounts.default.allowFrom` | `WHATSAPP_ALLOWED_USERS` | Auth via Baileys QR pairing — requires re-pairing after migration | | Signal | `channels.signal.account` or `.accounts.default.account` | `SIGNAL_ACCOUNT` | | | Signal | `channels.signal.httpUrl` or `.accounts.default.httpUrl` | `SIGNAL_HTTP_URL` | | | Signal | `channels.signal.allowFrom` or `.accounts.default.allowFrom` | `SIGNAL_ALLOWED_USERS` | | | Matrix | `channels.matrix.accessToken` or `.accounts.default.accessToken` | `MATRIX_ACCESS_TOKEN` | Uses `accessToken` (not `botToken`) | | Mattermost | `channels.mattermost.botToken` or `.accounts.default.botToken` | `MATTERMOST_BOT_TOKEN` | | ### Other config | What | OpenClaw path | Claway path | Notes | |------|-------------|-------------|-------| | Approval mode | `approvals.exec.mode` | `config.yaml` → `approvals.mode` | "auto"→"off", "always"→"manual", "smart"→"smart" | | Command allowlist | `exec-approvals.json` | `config.yaml` → `command_allowlist` | Patterns merged and deduped | | Browser CDP URL | `browser.cdpUrl` | `config.yaml` → `browser.cdp_url` | | | Browser headless | `browser.headless` | `config.yaml` → `browser.headless` | | | Brave search key | `tools.web.search.brave.apiKey` | `.env` → `BRAVE_API_KEY` | Requires `--migrate-secrets` | | Gateway auth token | `gateway.auth.token` | `.env` → `CLAWAY_GATEWAY_TOKEN` | Requires `--migrate-secrets` | | Working directory | `agents.defaults.workspace` | `config.yaml` → `terminal.cwd` | Legacy migrations may still emit `MESSAGING_CWD` as a compatibility fallback | ### Archived (no direct Claway equivalent) These are saved to `~/.claway/migration/openclaw/<timestamp>/archive/` for manual review: | What | Archive file | How to recreate in Claway | |------|-------------|--------------------------| | `IDENTITY.md` | `archive/workspace/IDENTITY.md` | Merge into `SOUL.md` | | `TOOLS.md` | `archive/workspace/TOOLS.md` | Claway has built-in tool instructions | | `HEARTBEAT.md` | `archive/workspace/HEARTBEAT.md` | Use cron jobs for periodic tasks | | `BOOTSTRAP.md` | `archive/workspace/BOOTSTRAP.md` | Use context files or skills | | Cron jobs | `archive/cron-config.json` | Recreate with `claway cron create` | | Plugins | `archive/plugins-config.json` | See [plugins guide](/user-guide/features/hooks) | | Hooks/webhooks | `archive/hooks-config.json` | Use `claway webhook` or gateway hooks | | Memory backend | `archive/memory-backend-config.json` | Configure via `claway honcho` | | Skills registry | `archive/skills-registry-config.json` | Use `claway skills config` | | UI/identity | `archive/ui-identity-config.json` | Use `/skin` command | | Logging | `archive/logging-diagnostics-config.json` | Set in `config.yaml` logging section | | Multi-agent list | `archive/agents-list.json` | Use Claway profiles | | Channel bindings | `archive/bindings.json` | Manual setup per platform | | Complex channels | `archive/channels-deep-config.json` | Manual platform config | ## API key resolution When `--migrate-secrets` is enabled, API keys are collected from **four sources** in priority order: 1. **Config values** — `models.providers.*.apiKey` and TTS provider keys in `openclaw.json` 2. **Environment file** — `~/.openclaw/.env` (keys like `OPENROUTER_API_KEY`, `ANTHROPIC_API_KEY`, etc.) 3. **Config env sub-object** — `openclaw.json` → `"env"` or `"env"."vars"` (some setups store keys here instead of a separate `.env` file) 4. **Auth profiles** — `~/.openclaw/agents/main/agent/auth-profiles.json` (per-agent credentials) Config values take priority. Each subsequent source fills any remaining gaps. ### Supported key targets `OPENROUTER_API_KEY`, `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, `DEEPSEEK_API_KEY`, `GEMINI_API_KEY`, `ZAI_API_KEY`, `MINIMAX_API_KEY`, `ELEVENLABS_API_KEY`, `TELEGRAM_BOT_TOKEN`, `VOICE_TOOLS_OPENAI_KEY` Keys not in this allowlist are never copied. ## SecretRef handling OpenClaw config values for tokens and API keys can be in three formats: ```json // Plain string "channels": { "telegram": { "botToken": "123456:ABC-DEF..." } } // Environment template "channels": { "telegram": { "botToken": "${TELEGRAM_BOT_TOKEN}" } } // SecretRef object "channels": { "telegram": { "botToken": { "source": "env", "id": "TELEGRAM_BOT_TOKEN" } } } ``` The migration resolves all three formats. For env templates and SecretRef objects with `source: "env"`, it looks up the value in `~/.openclaw/.env` and the `openclaw.json` env sub-object. SecretRef objects with `source: "file"` or `source: "exec"` can't be resolved automatically — the migration warns about these, and those values must be added to Claway manually via `claway config set`. ## After migration 1. **Check the migration report** — printed on completion with counts of migrated, skipped, and conflicting items. 2. **Review archived files** — anything in `~/.claway/migration/openclaw/<timestamp>/archive/` needs manual attention. 3. **Start a new session** — imported skills and memory entries take effect in new sessions, not the current one. 4. **Verify API keys** — run `claway status` to check provider authentication. 5. **Test messaging** — if you migrated platform tokens, restart the gateway: `systemctl --user restart claway-gateway` 6. **Check session policies** — run `claway config show` and verify the `session_reset` value matches your expectations. 7. **Re-pair WhatsApp** — WhatsApp uses QR code pairing (Baileys), not token migration. Run `claway whatsapp` to pair. 8. **Archive cleanup** — after confirming everything works, run `claway claw cleanup` to rename leftover OpenClaw directories to `.pre-migration/` (prevents state confusion). ## Troubleshooting ### "OpenClaw directory not found" The migration checks `~/.openclaw/`, then `~/.clawdbot/`, then `~/.moltbot/`. If your installation is elsewhere, use `--source /path/to/your/openclaw`. ### "No provider API keys found" Keys might be stored in several places depending on your OpenClaw version: inline in `openclaw.json` under `models.providers.*.apiKey`, in `~/.openclaw/.env`, in the `openclaw.json` `"env"` sub-object, or in `agents/main/agent/auth-profiles.json`. The migration checks all four. If keys use `source: "file"` or `source: "exec"` SecretRefs, they can't be resolved automatically — add them via `claway config set`. ### Skills not appearing after migration Imported skills land in `~/.claway/skills/openclaw-imports/`. Start a new session for them to take effect, or run `/skills` to verify they're loaded. ### TTS voice not migrated OpenClaw stores TTS settings in two places: `messages.tts.providers.*` and the top-level `talk` config. The migration checks both. If your voice ID was set via the OpenClaw UI (stored in a different path), you may need to set it manually: `claway config set tts.elevenlabs.voice_id YOUR_VOICE_ID`. --- <!-- source: website/docs/guides/minimax-oauth.md --> # MiniMax OAuth # MiniMax OAuth Claway Agent supports **MiniMax** through a browser-based OAuth login flow, using the same credentials as the [MiniMax portal](https://www.minimax.io). No API key or credit card is required — log in once and Claway automatically refreshes your session. The transport reuses the `anthropic_messages` adapter (MiniMax exposes an Anthropic Messages-compatible endpoint at `/anthropic`), so all existing tool-calling, streaming, and context features work without any adapter changes. ## Overview | Item | Value | |------|-------| | Provider ID | `minimax-oauth` | | Display name | MiniMax (OAuth) | | Auth type | Browser OAuth (PKCE redirect flow) | | Transport | Anthropic Messages-compatible (`anthropic_messages`) | | Models | `MiniMax-M2.7`, `MiniMax-M2.7-highspeed` | | Global endpoint | `https://api.minimax.io/anthropic` | | China endpoint | `https://api.minimaxi.com/anthropic` | | Requires env var | No (`MINIMAX_API_KEY` is **not** used for this provider) | ## Prerequisites - Python 3.9+ - Claway Agent installed - A MiniMax account at [minimax.io](https://www.minimax.io) (global) or [minimaxi.com](https://www.minimaxi.com) (China) - A browser available on the local machine (or use `--no-browser` for remote sessions) ## Quick Start ```bash # Launch the provider and model picker claway model # → Select "MiniMax (OAuth)" from the provider list # → Claway opens your browser to the MiniMax authorization page # → Approve access in the browser # → Select a model (MiniMax-M2.7 or MiniMax-M2.7-highspeed) # → Start chatting claway ``` After the first login, credentials are stored under `~/.claway/auth.json` and are refreshed automatically before each session. ## Logging In Manually You can trigger a login without going through the model picker: ```bash claway auth add minimax-oauth ``` ### China region If your account is on the China platform (`minimaxi.com`), use the API-key-based `minimax-cn` provider instead — `minimax-cn` is registered with `auth_type="api_key"` only (no OAuth flow). Configure `MINIMAX_CN_API_KEY` (and optionally `MINIMAX_CN_BASE_URL`) directly: ```bash echo 'MINIMAX_CN_API_KEY=your-key' >> ~/.claway/.env ``` ### Remote / headless sessions On servers or containers where no browser is available: ```bash claway auth add minimax-oauth --no-browser ``` Claway will print the verification URL and user code — open the URL on any device and enter the code when prompted. ## The OAuth Flow Claway implements a PKCE browser OAuth flow against the MiniMax OAuth endpoints: 1. Claway generates a PKCE verifier / challenge pair and a random state value. 2. It POSTs to `{base_url}/oauth/code` with the challenge and receives a `user_code` and `verification_uri`. 3. Your browser opens `verification_uri`. If prompted, enter the `user_code`. 4. Claway polls `{base_url}/oauth/token` until the token arrives (or the deadline passes). 5. Tokens (`access_token`, `refresh_token`, expiry) are saved to `~/.claway/auth.json` under the `minimax-oauth` key. Token refresh (standard OAuth `refresh_token` grant) runs automatically at each session start when the access token is within 60 seconds of expiry. ## Checking Login Status ```bash claway doctor ``` The `◆ Auth Providers` section will show: ``` ✓ MiniMax OAuth (logged in, region=global) ``` or, if not logged in: ``` ⚠ MiniMax OAuth (not logged in) ``` ## Switching Models ```bash claway model # → Select "MiniMax (OAuth)" # → Pick from the model list ``` Or set the model directly: ```bash claway config set model.default MiniMax-M2.7 claway config set model.provider minimax-oauth ``` ## Configuration Reference After login, `~/.claway/config.yaml` will contain entries similar to: ```yaml model: default: MiniMax-M2.7 provider: minimax-oauth base_url: https://api.minimax.io/anthropic ``` ### Region endpoints | Provider id | Portal | Inference endpoint | |-------------|--------|-------------------| | `minimax-oauth` (global) | `https://api.minimax.io` | `https://api.minimax.io/anthropic` | | `minimax-cn` (China) | `https://api.minimaxi.com` | `https://api.minimaxi.com/anthropic` | ### Provider aliases All of the following resolve to `minimax-oauth`: ```bash claway --provider minimax-oauth # canonical claway --provider minimax-portal # alias claway --provider minimax-global # alias claway --provider minimax_oauth # alias (underscore form) ``` ## Environment Variables The `minimax-oauth` provider does **not** use `MINIMAX_API_KEY` or `MINIMAX_BASE_URL`. Those variables are for the API-key-based `minimax` and `minimax-cn` providers only. | Variable | Effect | |----------|--------| | `MINIMAX_API_KEY` | Used by `minimax` provider only — ignored for `minimax-oauth` | | `MINIMAX_CN_API_KEY` | Used by `minimax-cn` provider only — ignored for `minimax-oauth` | To use `minimax-oauth` as the active provider, set `model.provider: minimax-oauth` in `config.yaml` (use `claway setup` for the guided flow), or pass `--provider minimax-oauth` for a single invocation: ```bash claway --provider minimax-oauth ``` ## Models | Model | Best for | |-------|----------| | `MiniMax-M2.7` | Long-context reasoning, complex tool-calling | | `MiniMax-M2.7-highspeed` | Lower latency, lighter tasks, auxiliary calls | Both models support up to 200,000 tokens of context. `MiniMax-M2.7-highspeed` is also used automatically as the auxiliary model for vision and delegation tasks when `minimax-oauth` is the primary provider. ## Troubleshooting ### Token expired — not re-logging in automatically Claway refreshes the token on every session start if it is within 60 seconds of expiry. If the access token is already expired (for example, after a long offline period), the refresh happens automatically on the next request. If refresh fails with `refresh_token_reused` or `invalid_grant`, Claway marks the session as requiring re-login. When the refresh failure is terminal (HTTP 4xx, `invalid_grant`, revoked grant, etc.), Claway marks the refresh token as dead and quarantines it locally so it doesn't keep replaying the doomed exchange. The agent surfaces a single "re-authentication required" message and stays out of the way until you log in again. **Fix:** run `claway auth add minimax-oauth` again to start a fresh login. The quarantine clears on the next successful exchange. ### Authorization timed out The device-code flow has a finite expiry window. If you don't approve the login in time, Claway raises a timeout error. **Fix:** re-run `claway auth add minimax-oauth` (or `claway model`). The flow starts fresh. ### State mismatch (possible CSRF) Claway detected that the `state` value returned by the authorization server does not match what it sent. **Fix:** re-run the login. If it persists, check for a proxy or redirect that is modifying the OAuth response. ### Logging in from a remote server If `claway` cannot open a browser window, use `--no-browser`: ```bash claway auth add minimax-oauth --no-browser ``` Claway prints the URL and code. Open the URL on any device and complete the flow there. ### "Not logged into MiniMax OAuth" error at runtime The auth store has no credentials for `minimax-oauth`. You have not logged in yet, or the credential file was deleted. **Fix:** run `claway model` and select MiniMax (OAuth), or run `claway auth add minimax-oauth`. ## Logging Out To remove stored MiniMax OAuth credentials: ```bash claway auth logout minimax-oauth ``` ## See Also - [AI Providers reference](../integrations/providers.md) - [Environment Variables](../reference/environment-variables.md) - [Configuration](../user-guide/configuration.md) - [claway doctor](../reference/cli-commands.md) --- <!-- source: website/docs/guides/oauth-over-ssh.md --> # OAuth over SSH / Remote Hosts # OAuth over SSH / Remote Hosts Some Claway providers — **xAI Grok OAuth**, **Spotify**, and **remote MCP servers** (Linear, Sentry, Atlassian, Asana, Figma, …) — use a *loopback redirect* OAuth flow. The auth server redirects your browser to `http://127.0.0.1:<port>/callback` so a tiny HTTP listener started by Claway can grab the authorization code. This works perfectly when Claway and your browser are on the same machine. It breaks the moment they aren't: your laptop's browser tries to reach `127.0.0.1` on **your laptop**, but the listener is bound to `127.0.0.1` on **the remote server**. The fix is a one-line SSH local-forward — **or**, when you don't have a real SSH client (GCP Cloud Shell, GitHub Codespaces, EC2 Instance Connect, Gitpod, browser-based web IDEs), the `--manual-paste` flag. ## TL;DR ```bash # On your local machine (laptop), in a separate terminal: ssh -N -L 56121:127.0.0.1:56121 user@remote-host # In your existing SSH session on the remote machine: claway auth add xai-oauth --no-browser # → Claway prints an authorize URL. Open it in a browser on your laptop. # → Your browser redirects to 127.0.0.1:56121/callback, the tunnel forwards # the request to the remote listener, login completes. ``` Port `56121` is what xAI OAuth uses. For Spotify, replace it with `43827`. Claway prints the exact port it bound to on the `Waiting for callback on ...` line — copy it from there. ## Browser-only remote (Cloud Shell / Codespaces / EC2 Instance Connect) If you don't have a regular SSH client — for example because you're running Claway inside GCP Cloud Shell, GitHub Codespaces, AWS EC2 Instance Connect, Gitpod, or another browser-based console — the SSH tunnel above isn't available. Use `--manual-paste` instead: ```bash claway auth add xai-oauth --manual-paste # → Claway prints an authorize URL. Open it in a browser on your laptop. # → Approve in the browser. The redirect to 127.0.0.1:56121/callback fails # to load — that's expected. # → Copy the FULL URL from the failed page's address bar. # → Paste it back into the terminal at the "Callback URL:" prompt. ``` The same flag works on `claway model --manual-paste` for the integrated model picker. Claway accepts three callback paste forms interchangeably: the full URL, a bare `?code=...&state=...` query fragment, or — when the upstream consent page renders the authorization code in-page instead of redirecting (xAI's current behavior on browser-based consoles) — just the bare code value on its own. Claway uses the **same PKCE verifier, state and nonce** for both paths, so the upstream OAuth flow is byte-identical — `--manual-paste` is purely a transport change for the callback hop and is not a security downgrade. ## Which Providers Need This | Provider | Loopback port | Tunnel needed? | |----------|---------------|----------------| | `xai-oauth` (Grok SuperGrok) | `56121` | Yes, when Claway is remote | | Spotify | `43827` | Yes, when Claway is remote | | MCP servers (`auth: oauth`) | auto-picked per server | Yes, when Claway is remote | | `anthropic` (Claude Pro/Max) | n/a | No — paste-the-code flow | | `openai-codex` (ChatGPT Plus/Pro) | n/a | No — device code flow | If your provider isn't in the table, you don't need a tunnel. ## MCP Servers Remote MCP servers (Linear, Sentry, Atlassian, Asana, Figma, etc.) use the same loopback redirect flow. Claway auto-picks a free port per server and prints the authorize URL when the OAuth flow kicks off — either at startup (when a new server appears in `mcp_servers:`) or when you run `claway mcp login <server>`. You have two ways to complete it from a remote host: **Option 1 — paste the redirect URL back (no setup, works anywhere).** On an interactive terminal, Claway prompts you to paste the redirect URL alongside running the local listener. After approving in your browser, the redirect to `http://127.0.0.1:<port>/callback` will show a connection error — that's expected. Copy the **full URL from the browser's address bar** and paste it at the Claway prompt: ``` MCP OAuth: authorization required. Open this URL in your browser: https://mcp.linear.app/authorize?response_type=code&... Or paste the redirect URL here (or the ?code=...&state=... portion) and press Enter: > https://mcp.linear.app/callback?code=abc123&state=xyz Got authorization code from paste — completing flow. ``` A bare `?code=...&state=...` query string is accepted too. This works for any MCP server with `auth: oauth` and requires no SSH config changes. **Option 2 — SSH port forward (same as xAI / Spotify).** Claway prints the exact port it bound to in the SSH-session hint. Open a separate terminal on your laptop: ```bash ssh -N -L <port>:127.0.0.1:<port> user@remote-host ``` Then open the authorize URL in your browser as normal; the redirect tunnels through and the listener picks it up. Use this when you need the flow to complete unattended (e.g. scripted re-auth where you can't paste interactively). **Pitfall — the 30s config-reload race.** If you edit `~/.claway/config.yaml` to add an OAuth MCP server from inside a running Claway session, the CLI auto-reloads MCP connections with a 30s timeout. That's not enough time to complete an interactive OAuth flow, and the reload will give up. Use `claway mcp login <server>` from a fresh terminal instead — it has no such cap and waits the full 5 min for you to paste back. ## Why the listener can't just bind 0.0.0.0 xAI and Spotify both validate the `redirect_uri` parameter against an allowlist. Both require the loopback form (`http://127.0.0.1:<exact-port>/callback`). Binding the listener to `0.0.0.0` or a different port would cause the auth server to reject the request as a redirect_uri mismatch. The SSH tunnel keeps the loopback URI intact end-to-end. ## Step-by-step: single SSH hop ### 1. Start the tunnel from your local machine ```bash # xAI Grok OAuth (port 56121) ssh -N -L 56121:127.0.0.1:56121 user@remote-host # Or for Spotify (port 43827) ssh -N -L 43827:127.0.0.1:43827 user@remote-host ``` `-N` means "don't open a remote shell, just hold the tunnel open." Keep this terminal running for the duration of the login. ### 2. In a separate SSH session, run the auth command ```bash ssh user@remote-host claway auth add xai-oauth --no-browser # or for Spotify: # claway auth add spotify --no-browser ``` Claway detects the SSH session, skips the browser auto-open, and prints an authorize URL plus a `Waiting for callback on http://127.0.0.1:<port>/callback` line. ### 3. Open the URL in your local browser Copy the authorize URL from the remote terminal and paste it into the browser on your laptop. Approve the consent screen. The auth server redirects to `http://127.0.0.1:<port>/callback`. Your browser hits the tunnel, the request is forwarded to the remote listener, and Claway prints `Login successful!`. You can tear down the tunnel (Ctrl+C in the first terminal) once you see the success line. ## Step-by-step: through a jump box If you reach Claway through a bastion / jump host, use SSH's built-in `-J` (ProxyJump): ```bash ssh -N -L 56121:127.0.0.1:56121 -J jump-user@jump-host user@final-host ``` This chains a SSH connection through the jump host without putting the loopback port on the jump box itself. The local `127.0.0.1:56121` on your laptop tunnels straight through to `127.0.0.1:56121` on the final remote host. For older OpenSSH that doesn't support `-J`, the long form is: ```bash ssh -N \ -o "ProxyCommand=ssh -W %h:%p jump-user@jump-host" \ -L 56121:127.0.0.1:56121 \ user@final-host ``` ## Mosh, tmux, ssh ControlMaster The tunnel is a property of the underlying SSH connection. If you're running Claway inside `tmux` over a mosh session, the mosh roaming doesn't carry the `-L` forwarding. Open a *separate* plain SSH session **only** for the `-L` tunnel — that's the connection that has to stay alive during the auth flow. Your interactive mosh/tmux session can keep running Claway normally. If you use `ssh -o ControlMaster=auto`, port forwards on a multiplexed connection share the master's lifetime. Restart the master if the tunnel doesn't come up: ```bash ssh -O exit user@remote-host ssh -N -L 56121:127.0.0.1:56121 user@remote-host ``` ## Troubleshooting ### `bind [127.0.0.1]:56121: Address already in use` Something on your laptop is already using that port. Either the previous tunnel didn't shut down cleanly, or a local Claway is also listening on it. Find and kill the offender: ```bash # macOS / Linux lsof -iTCP:56121 -sTCP:LISTEN kill <PID> ``` Then retry the `ssh -L` command. ### "Could not establish connection. We couldn't reach your app." (xAI) xAI's authorize page shows this when its redirect to `127.0.0.1:<port>/callback` doesn't reach a listener. Either the tunnel isn't running, the port is wrong, or you're using the port Claway printed in a previous run (the port can be auto-bumped if the preferred one is busy — always read the latest `Waiting for callback on ...` line). ### `xAI authorization timed out waiting for the local callback` Same root cause as above — the redirect never made it back. Check the tunnel is still alive (`ssh -N` doesn't show output, so look at the terminal you started it from), restart it if needed, and re-run `claway auth add xai-oauth --no-browser`. ### Tokens land in the wrong `~/.claway` The tokens are written under the Linux user that ran `claway auth add ...`. If your gateway / systemd service runs as a different user (e.g. `root` or a dedicated `claway` user), authenticate as **that** user so the tokens land in their `~/.claway/auth.json`. `sudo -u claway -i` or equivalent. ## See Also - [xAI Grok OAuth](./xai-grok-oauth.md) - [Spotify (`Running over SSH`)](../user-guide/features/spotify.md#running-over-ssh--in-a-headless-environment) - [Native MCP client (OAuth section)](../user-guide/features/mcp.md#oauth-authenticated-http-servers) - [SSH `-J` / ProxyJump (man page)](https://man.openbsd.org/ssh#J) --- <!-- source: website/docs/guides/operate-teams-meeting-pipeline.md --> # Operate the Teams Meeting Pipeline # Operate the Teams Meeting Pipeline Use this guide after you have already enabled the feature from [Teams Meetings](/user-guide/messaging/teams-meetings). This page covers: - operator CLI flows - routine subscription maintenance - failure triage - go-live checks - rollout worksheet ## Core Operator Commands ### Validate the config snapshot ```bash claway teams-pipeline validate ``` Use this first after any config change. ### Inspect token health ```bash claway teams-pipeline token-health claway teams-pipeline token-health --force-refresh ``` Use `--force-refresh` when you suspect stale auth state. ### Inspect subscriptions ```bash claway teams-pipeline subscriptions ``` ### Renew near-expiry subscriptions ```bash claway teams-pipeline maintain-subscriptions claway teams-pipeline maintain-subscriptions --dry-run ``` ### Automating subscription renewal (REQUIRED for production) **Microsoft Graph subscriptions expire in at most 72 hours.** If nothing renews them, meeting notifications silently stop after 3 days and the pipeline looks "broken." This is the #1 operational failure mode for any Graph-backed integration. You MUST run `maintain-subscriptions` on a schedule. Pick one of these three options: #### Option 1: Claway cron (recommended if you already run the Claway gateway) Claway ships a built-in cron scheduler. The `--no-agent` mode runs a script as the job (rather than using an LLM), and `--script` must point at a file under `~/.claway/scripts/`. First create the script: ```bash mkdir -p ~/.claway/scripts cat > ~/.claway/scripts/maintain-teams-subscriptions.sh <<'EOF' #!/usr/bin/env bash exec claway teams-pipeline maintain-subscriptions EOF chmod +x ~/.claway/scripts/maintain-teams-subscriptions.sh ``` Then register a script-only cron job that runs every 12 hours (gives 6x headroom against the 72h expiry window): ```bash claway cron create "0 */12 * * *" \ --name "teams-pipeline-maintain-subscriptions" \ --no-agent \ --script maintain-teams-subscriptions.sh \ --deliver local ``` Verify it was registered and inspect the next run time: ```bash claway cron list claway cron status # scheduler status ``` #### Option 2: systemd timer (recommended for Linux production deployments) Create `/etc/systemd/system/claway-teams-pipeline-maintain.service`: ```ini [Unit] Description=Claway Teams pipeline subscription maintenance After=network-online.target [Service] Type=oneshot User=claway EnvironmentFile=/etc/claway/env ExecStart=/usr/local/bin/claway teams-pipeline maintain-subscriptions ``` And `/etc/systemd/system/claway-teams-pipeline-maintain.timer`: ```ini [Unit] Description=Run Claway Teams pipeline subscription maintenance every 12 hours [Timer] OnBootSec=5min OnUnitActiveSec=12h Persistent=true [Install] WantedBy=timers.target ``` Enable: ```bash sudo systemctl daemon-reload sudo systemctl enable --now claway-teams-pipeline-maintain.timer systemctl list-timers claway-teams-pipeline-maintain.timer ``` #### Option 3: Plain crontab ```cron 0 */12 * * * /usr/local/bin/claway teams-pipeline maintain-subscriptions >> /var/log/claway/teams-pipeline-maintain.log 2>&1 ``` Make sure the cron environment has the `MSGRAPH_*` credentials. Simplest fix: source `~/.claway/.env` at the top of a wrapper script that crontab calls. #### Verifying renewal is working After you've set up the schedule, check renewal activity after the first scheduled run: ```bash claway teams-pipeline subscriptions # should show expirationDateTime advanced claway teams-pipeline maintain-subscriptions --dry-run # should show "0 expiring soon" most of the time ``` If you ever see your Graph webhook mysteriously "stop working" after exactly ~72 hours, this is the first thing to check: did the renewal job actually run? ### Inspect recent jobs ```bash claway teams-pipeline list claway teams-pipeline list --status failed claway teams-pipeline show <job-id> ``` ### Replay a stored job ```bash claway teams-pipeline run <job-id> ``` ### Dry-run meeting artifact fetches ```bash claway teams-pipeline fetch --meeting-id <meeting-id> claway teams-pipeline fetch --join-web-url "<join-url>" ``` ## Routine Runbook ### After first setup Run these in order: ```bash claway teams-pipeline validate claway teams-pipeline token-health --force-refresh claway teams-pipeline subscriptions ``` Then trigger or wait for a real meeting event and confirm: ```bash claway teams-pipeline list claway teams-pipeline show <job-id> ``` ### Daily or periodic checks - run `claway teams-pipeline maintain-subscriptions --dry-run` - inspect `claway teams-pipeline list --status failed` - verify the Teams delivery target is still the correct chat or channel ### Before changing webhook URLs or delivery targets - update the public notification URL or Teams target config - run `claway teams-pipeline validate` - renew or recreate affected subscriptions - confirm new events land in the expected sink ## Failure Triage ### No jobs are being created Check: - `msgraph_webhook` is enabled - the public notification URL points to `/msgraph/webhook` - the client state in the subscription matches `MSGRAPH_WEBHOOK_CLIENT_STATE` - subscriptions still exist remotely and are not expired ### Jobs stay in retry or fail before summarization Check: - transcript permissions and availability - recording permissions and artifact availability - `ffmpeg` availability if recording fallback is enabled - Graph token health ### Summaries are produced but not delivered to Teams Check: - `platforms.teams.enabled: true` - `delivery_mode` - `incoming_webhook_url` for webhook mode - `chat_id` or `team_id` plus `channel_id` for Graph mode - Teams auth config if Graph posting is used ### Duplicate or unexpected replays Check: - whether you manually replayed a job with `claway teams-pipeline run` - whether the sink record already exists for that meeting - whether you intentionally enabled a resend path in your local config ## Go-Live Checklist - [ ] Graph credentials are present and correct - [ ] `msgraph_webhook` is enabled and reachable from the public internet - [ ] `MSGRAPH_WEBHOOK_CLIENT_STATE` is set and matches subscriptions - [ ] transcript subscription is created - [ ] recording subscription is created if STT fallback is required - [ ] `ffmpeg` is installed if recording fallback is enabled - [ ] Teams outbound delivery target is configured and verified - [ ] Notion and Linear sinks are configured only if actually needed - [ ] `claway teams-pipeline validate` returns an OK snapshot - [ ] `claway teams-pipeline token-health --force-refresh` succeeds - [ ] **`maintain-subscriptions` is scheduled** (Claway cron, systemd timer, or crontab — see [Automating subscription renewal](#automating-subscription-renewal-required-for-production)). Without this, Graph subscriptions silently expire within 72 hours. - [ ] a real end-to-end meeting event has produced a stored job - [ ] at least one summary has reached the intended delivery sink ## Delivery-Mode Decision Guide | Mode | Use when | Tradeoff | |------|----------|----------| | `incoming_webhook` | you only need simple posting into Teams | simplest setup, less control | | `graph` | you need channel or chat posting through Graph | more control, more auth and target config | ## Operator Worksheet Fill this out before rollout: | Item | Value | |------|-------| | Public notification URL | | | Graph tenant ID | | | Graph client ID | | | Webhook client state | | | Transcript resource subscription | | | Recording resource subscription | | | Teams delivery mode | | | Teams chat ID or team/channel | | | Notion database ID | | | Linear team ID | | | Store path override, if any | | | Owner for daily checks | | ## Change Review Worksheet Use this before changing the deployment: | Question | Answer | |----------|--------| | Are we changing the public webhook URL? | | | Are we rotating Graph credentials? | | | Are we changing Teams delivery mode? | | | Are we moving to a new Teams chat or channel? | | | Do subscriptions need to be recreated or renewed? | | | Do we need a fresh end-to-end verification run? | | ## Related Docs - [Teams Meetings setup](/user-guide/messaging/teams-meetings) - [Microsoft Teams bot setup](/user-guide/messaging/teams) --- <!-- source: website/docs/guides/pipe-script-output.md --> # Pipe Script Output to Messaging Platforms # Pipe Script Output to Messaging Platforms `claway send` is a small, scriptable CLI that pushes a message to any messaging platform Claway is already configured for. Think of it as a cross-platform `curl` for notifications — you don't need a running gateway, you don't need an LLM, and you don't need to re-paste bot tokens into each of your scripts. Use it for: - System monitoring (memory, disk, GPU temp, long-running job finished) - CI/CD notifications (deploy done, test failure) - Cron scripts that need to ping you with results - Quick one-shot messages from a terminal - Piping any tool's output anywhere (`make | claway send --to slack:#builds`) The command reuses the same credentials and platform adapters that `claway gateway` already uses, so there's no second configuration surface to maintain. --- ## Quick Start ```bash # Plain text to the home channel for a platform claway send --to telegram "deploy finished" # Pipe in stdout from anything echo "RAM 92%" | claway send --to telegram:-1001234567890 # Send a file claway send --to discord:#ops --file /tmp/report.md # Attach a subject/header line claway send --to slack:#eng --subject "[CI] build.log" --file build.log # Thread target (Telegram topic, Discord thread) claway send --to telegram:-1001234567890:17585 "threaded reply" # List every configured target claway send --list # Filter by platform claway send --list telegram ``` --- ## Argument Reference | Flag | Description | |------|-------------| | `-t, --to TARGET` | Destination. See [target formats](#target-formats). | | `message` (positional) | Message text. Omit to read from `--file` or stdin. | | `-f, --file PATH` | Read the body from a file. `--file -` forces stdin. | | `-s, --subject LINE` | Prepend a header/subject line before the body. | | `-l, --list` | List available targets. Optional positional platform filter. | | `-q, --quiet` | No stdout on success (exit code only — ideal for scripts). | | `--json` | Emit the raw JSON result of the send. | | `-h, --help` | Show the built-in help text. | ### Target Formats | Format | Example | Meaning | |--------|---------|---------| | `platform` | `telegram` | Send to the platform's configured home channel | | `platform:chat_id` | `telegram:-1001234567890` | Specific numeric chat / group / user | | `platform:chat_id:thread_id` | `telegram:-1001234567890:17585` | Specific thread or Telegram forum topic | | `platform:#channel` | `discord:#ops` | Human-friendly channel name (resolved against the channel directory) | | `platform:+E164` | `signal:+15551234567` | Phone-addressed platforms: Signal, SMS, WhatsApp | Any platform Claway ships adapters for works as a target: `telegram`, `discord`, `slack`, `signal`, `sms`, `whatsapp`, `matrix`, `mattermost`, `feishu`, `dingtalk`, `wecom`, `weixin`, `email`, and others. ### Exit Codes | Code | Meaning | |------|---------| | `0` | Send (or list) succeeded | | `1` | Delivery failed at the platform level (auth, permissions, network) | | `2` | Usage / argument / config error | Exit codes follow the standard Unix convention so your scripts can branch on them the same way they would on `curl` or `grep`. --- ## Message Body Resolution `claway send` resolves the message body in this order: 1. **Positional argument** — `claway send --to telegram "hi"` 2. **`--file PATH`** — `claway send --to telegram --file msg.txt` 3. **Piped stdin** — `echo hi | claway send --to telegram` When stdin is a TTY (no pipe), Claway does **not** wait for input — you'll get a clear usage error instead. This keeps scripts from hanging if they accidentally omit the body. --- ## Real-World Examples ### Monitoring: Memory / Disk Alerts Replace ad-hoc `curl https://api.telegram.org/...` calls in your watchdogs with a single portable line: ```bash #!/usr/bin/env bash ram_pct=$(free | awk '/^Mem:/ {printf "%d", $3 * 100 / $2}') if [ "$ram_pct" -ge 85 ]; then claway send --to telegram --subject "⚠ MEMORY WARNING" \ "RAM ${ram_pct}% on $(hostname)" fi ``` Because `claway send` reuses your Claway config, the same script works on any host where Claway is installed — no need to export bot tokens into each machine's environment manually. :::tip Don't alert the gateway about itself For watchdogs that might fire when the gateway itself is struggling (OOM alerts, disk-full alerts), keep using a minimal `curl` call instead of `claway send`. If the Python interpreter can't load because the box is thrashing, you still want that alert to go out. ::: ### CI / CD: Build and Test Results ```bash # In .github/workflows/deploy.yml or any CI script if ./scripts/deploy.sh; then claway send --to slack:#deploys "✅ ${CI_COMMIT_SHA:0:7} deployed" else tail -n 100 deploy.log | claway send \ --to slack:#deploys --subject "❌ deploy failed" exit 1 fi ``` ### Cron: Daily Report ```bash # Crontab entry 0 9 * * * /usr/local/bin/generate-metrics.sh \ | /home/me/.claway/bin/claway send \ --to telegram --subject "Daily metrics $(date +%Y-%m-%d)" ``` ### Long-Running Tasks: Ping When Done ```bash ./train.py --epochs 200 && \ claway send --to telegram "training done" || \ claway send --to telegram "training failed (exit $?)" ``` ### Scripting with `--json` and `--quiet` ```bash # Hard-fail a script if delivery fails; don't clutter logs on success claway send --to telegram --quiet "keepalive" || { echo "Telegram delivery failed" >&2 exit 1 } # Capture the message ID for later editing / threading msg_id=$(claway send --to discord:#ops --json "build started" \ | jq -r .message_id) ``` --- ## Does `claway send` Need the Gateway Running? **Usually no.** For any bot-token platform — Telegram, Discord, Slack, Signal, SMS, WhatsApp Cloud API, and most others — `claway send` calls the platform's REST endpoint directly using credentials from `~/.claway/.env` and `~/.claway/config.yaml`. It's a standalone subprocess that exits as soon as the message is delivered. A live gateway is only required for **plugin platforms** that rely on a persistent adapter connection (for example, a custom plugin that keeps a long-lived WebSocket open). In that case you'll get a clear error pointing at the gateway; start it with `claway gateway start` and retry. --- ## Listing and Discovering Targets Before sending to a specific channel, you can inspect what's available: ```bash # Every target across every configured platform claway send --list # Just Telegram targets claway send --list telegram # Machine-readable claway send --list --json ``` The listing is built from `~/.claway/channel_directory.json`, which the gateway refreshes every few minutes while it's running. If you see "no channels discovered yet", start the gateway once (`claway gateway start`) so it can populate the cache. Human-friendly names (`discord:#ops`, `slack:#engineering`) are resolved against this cache at send time, so you don't need to memorize numeric IDs. --- ## Comparison with Other Approaches | Approach | Multi-platform | Reuses Claway creds | Needs gateway | Best for | |----------|----------------|---------------------|---------------|----------| | `claway send` | ✅ | ✅ | No (bot-token) | Everything below | | Raw `curl` to each platform | Each scripted separately | Manual | No | Critical watchdogs | | `cron` job with `--deliver` | ✅ | ✅ | No | Scheduled agent tasks | `claway send` is intentionally the simplest possible surface. If you need an agent to decide what to say, schedule a cron job — the agent's final response is auto-delivered to the configured `deliver:` target (the agent no longer fires messages itself). If you need a scheduled run with LLM-generated content, use `cronjob(action='create', prompt=...)` with `deliver='telegram:...'`. If you just need to pipe a raw string, reach for `claway send`. --- ## Related - [Automate Anything with Cron](/guides/automate-with-cron) — scheduled jobs whose output auto-delivers to any platform. - Gateway Internals — the delivery router that `claway send` shares with cron delivery. - [Messaging Platform Setup](/user-guide/messaging/) — one-time configuration for each platform. --- <!-- source: website/docs/guides/team-telegram-assistant.md --> # Tutorial: Team Telegram Assistant # Set Up a Team Telegram Assistant This tutorial walks you through setting up a Telegram bot powered by Claway Agent that multiple team members can use. By the end, your team will have a shared AI assistant they can message for help with code, research, system administration, and anything else — secured with per-user authorization. ## What We're Building A Telegram bot that: - **Any authorized team member** can DM for help — code reviews, research, shell commands, debugging - **Runs on your server** with full tool access — terminal, file editing, web search, code execution - **Per-user sessions** — each person gets their own conversation context - **Secure by default** — only approved users can interact, with two authorization methods - **Scheduled tasks** — daily standups, health checks, and reminders delivered to a team channel --- ## Prerequisites Before starting, make sure you have: - **Claway Agent installed** on a server or VPS (not your laptop — the bot needs to stay running). Follow the [installation guide](/getting-started) if you haven't yet. - **A Telegram account** for yourself (the bot owner) - **An LLM provider configured** — at minimum, an API key for OpenAI, Anthropic, or another supported provider in `~/.claway/.env` :::tip A $5/month VPS is plenty for running the gateway. Claway itself is lightweight — the LLM API calls are what cost money, and those happen remotely. ::: --- ## Step 1: Create a Telegram Bot Every Telegram bot starts with **@BotFather** — Telegram's official bot for creating bots. 1. **Open Telegram** and search for `@BotFather`, or go to [t.me/BotFather](https://t.me/BotFather) 2. **Send `/newbot`** — BotFather will ask you two things: - **Display name** — what users see (e.g., `Team Claway Assistant`) - **Username** — must end in `bot` (e.g., `myteam_claway_bot`) 3. **Copy the bot token** — BotFather replies with something like: ``` Use this token to access the HTTP API: 7123456789:AAH1bGciOiJSUzI1NiIsInR5cCI6Ikp... ``` Save this token — you'll need it in the next step. 4. **Set a description** (optional but recommended): ``` /setdescription ``` Choose your bot, then enter something like: ``` Team AI assistant powered by Claway Agent. DM me for help with code, research, debugging, and more. ``` 5. **Set bot commands** (optional — gives users a command menu): ``` /setcommands ``` Choose your bot, then paste: ``` new - Start a fresh conversation model - Show or change the AI model status - Show session info help - Show available commands stop - Stop the current task ``` :::warning Keep your bot token secret. Anyone with the token can control the bot. If it leaks, use `/revoke` in BotFather to generate a new one. ::: --- ## Step 2: Configure the Gateway You have two options: the interactive setup wizard (recommended) or manual configuration. ### Option A: Interactive Setup (Recommended) ```bash claway gateway setup ``` This walks you through everything with arrow-key selection. Pick **Telegram**, paste your bot token, and enter your user ID when prompted. ### Option B: Manual Configuration Add these lines to `~/.claway/.env`: ```bash # Telegram bot token from BotFather TELEGRAM_BOT_TOKEN=7123456789:AAH1bGciOiJSUzI1NiIsInR5cCI6Ikp... # Your Telegram user ID (numeric) TELEGRAM_ALLOWED_USERS=123456789 ``` ### Finding Your User ID Your Telegram user ID is a numeric value (not your username). To find it: 1. Message [@userinfobot](https://t.me/userinfobot) on Telegram 2. It instantly replies with your numeric user ID 3. Copy that number into `TELEGRAM_ALLOWED_USERS` :::info Telegram user IDs are permanent numbers like `123456789`. They're different from your `@username`, which can change. Always use the numeric ID for allowlists. ::: --- ## Step 3: Start the Gateway ### Quick Test Run the gateway in the foreground first to make sure everything works: ```bash claway gateway ``` You should see output like: ``` [Gateway] Starting Claway Gateway... [Gateway] Telegram adapter connected [Gateway] Cron scheduler started (tick every 60s) ``` Open Telegram, find your bot, and send it a message. If it replies, you're in business. Press `Ctrl+C` to stop. ### Production: Install as a Service For a persistent deployment that survives reboots: ```bash claway gateway install sudo claway gateway install --system # Linux only: boot-time system service ``` This creates a background service: a user-level **systemd** service on Linux by default, a **launchd** service on macOS, or a boot-time Linux system service if you pass `--system`. ```bash # Linux — manage the default user service claway gateway start claway gateway stop claway gateway status # View live logs journalctl --user -u claway-gateway -f # Keep running after SSH logout sudo loginctl enable-linger $USER # Linux servers — explicit system-service commands sudo claway gateway start --system sudo claway gateway status --system journalctl -u claway-gateway -f ``` ```bash # macOS — manage the service claway gateway start claway gateway stop tail -f ~/.claway/logs/gateway.log ``` :::tip macOS PATH The launchd plist captures your shell PATH at install time so gateway subprocesses can find tools like Node.js and ffmpeg. If you install new tools later, re-run `claway gateway install` to update the plist. ::: ### Verify It's Running ```bash claway gateway status ``` Then send a test message to your bot on Telegram. You should get a response within a few seconds. --- ## Step 4: Set Up Team Access Now let's give your teammates access. There are two approaches. ### Approach A: Static Allowlist Collect each team member's Telegram user ID (have them message [@userinfobot](https://t.me/userinfobot)) and add them as a comma-separated list: ```bash # In ~/.claway/.env TELEGRAM_ALLOWED_USERS=123456789,987654321,555555555 ``` Restart the gateway after changes: ```bash claway gateway stop && claway gateway start ``` ### Approach B: DM Pairing (Recommended for Teams) DM pairing is more flexible — you don't need to collect user IDs upfront. Here's how it works: 1. **Teammate DMs the bot** — since they're not on the allowlist, the bot replies with a one-time pairing code: ``` 🔐 Pairing code: XKGH5N7P Send this code to the bot owner for approval. ``` 2. **Teammate sends you the code** (via any channel — Slack, email, in person) 3. **You approve it** on the server: ```bash claway pairing approve telegram XKGH5N7P ``` 4. **They're in** — the bot immediately starts responding to their messages **Managing paired users:** ```bash # See all pending and approved users claway pairing list # Revoke someone's access claway pairing revoke telegram 987654321 # Clear expired pending codes claway pairing clear-pending ``` :::tip DM pairing is ideal for teams because you don't need to restart the gateway when adding new users. Approvals take effect immediately. ::: ### Security Considerations - **Never set `GATEWAY_ALLOW_ALL_USERS=true`** on a bot with terminal access — anyone who finds your bot could run commands on your server - Pairing codes expire after **1 hour** and use cryptographic randomness - Rate limiting prevents brute-force attacks: 1 request per user per 10 minutes, max 3 pending codes per platform - After 5 failed approval attempts, the platform enters a 1-hour lockout - All pairing data is stored with `chmod 0600` permissions --- ## Step 5: Configure the Bot ### Set a Home Channel A **home channel** is where the bot delivers cron job results and proactive messages. Without one, scheduled tasks have nowhere to send output. **Option 1:** Use the `/sethome` command in any Telegram group or chat where the bot is a member. **Option 2:** Set it manually in `~/.claway/.env`: ```bash TELEGRAM_HOME_CHANNEL=-1001234567890 TELEGRAM_HOME_CHANNEL_NAME="Team Updates" ``` To find a channel ID, add [@userinfobot](https://t.me/userinfobot) to the group — it will report the group's chat ID. ### Configure Tool Progress Display Control how much detail the bot shows when using tools. In `~/.claway/config.yaml`: ```yaml display: tool_progress: new # off | new | all | verbose ``` | Mode | What You See | |------|-------------| | `off` | Clean responses only — no tool activity | | `new` | Brief status for each new tool call (recommended for messaging) | | `all` | Every tool call with details | | `verbose` | Full tool output including command results | Users can also change this per-session with the `/verbose` command in chat. ### Set Up a Personality with SOUL.md Customize how the bot communicates by editing `~/.claway/SOUL.md`: For a full guide, see [Use SOUL.md with Claway](/guides/use-soul-with-claway). ```markdown # Soul You are a helpful team assistant. Be concise and technical. Use code blocks for any code. Skip pleasantries — the team values directness. When debugging, always ask for error logs before guessing at solutions. ``` ### Add Project Context If your team works on specific projects, create context files so the bot knows your stack: ```markdown <!-- ~/.claway/AGENTS.md --> # Team Context - We use Python 3.12 with FastAPI and SQLAlchemy - Frontend is React with TypeScript - CI/CD runs on GitHub Actions - Production deploys to AWS ECS - Always suggest writing tests for new code ``` :::info Context files are injected into every session's system prompt. Keep them concise — every character counts against your token budget. ::: --- ## Step 6: Set Up Scheduled Tasks With the gateway running, you can schedule recurring tasks that deliver results to your team channel. ### Daily Standup Summary Message the bot on Telegram: ``` Every weekday at 9am, check the GitHub repository at github.com/myorg/myproject for: 1. Pull requests opened/merged in the last 24 hours 2. Issues created or closed 3. Any CI/CD failures on the main branch Format as a brief standup-style summary. ``` The agent creates a cron job automatically and delivers results to the chat where you asked (or the home channel). ### Server Health Check ``` Every 6 hours, check disk usage with 'df -h', memory with 'free -h', and Docker container status with 'docker ps'. Report anything unusual — partitions above 80%, containers that have restarted, or high memory usage. ``` ### Managing Scheduled Tasks ```bash # From the CLI claway cron list # View all scheduled jobs claway cron status # Check if scheduler is running # From Telegram chat /cron list # View jobs /cron remove <job_id> # Remove a job ``` :::warning Cron job prompts run in completely fresh sessions with no memory of prior conversations. Make sure each prompt contains **all** the context the agent needs — file paths, URLs, server addresses, and clear instructions. ::: --- ## Production Tips ### Use Docker for Safety On a shared team bot, use Docker as the terminal backend so agent commands run in a container instead of on your host: ```bash # In ~/.claway/.env TERMINAL_BACKEND=docker TERMINAL_DOCKER_IMAGE=nikolaik/python-nodejs:python3.11-nodejs20 ``` Or in `~/.claway/config.yaml`: ```yaml terminal: backend: docker container_cpu: 1 container_memory: 5120 container_persistent: true ``` This way, even if someone asks the bot to run something destructive, your host system is protected. ### Monitor the Gateway ```bash # Check if the gateway is running claway gateway status # Watch live logs (Linux) journalctl --user -u claway-gateway -f # Watch live logs (macOS) tail -f ~/.claway/logs/gateway.log ``` ### Keep Claway Updated From Telegram, send `/update` to the bot — it will pull the latest version and restart. Or from the server: ```bash claway update claway gateway stop && claway gateway start ``` ### Log Locations | What | Location | |------|----------| | Gateway logs | `journalctl --user -u claway-gateway` (Linux) or `~/.claway/logs/gateway.log` (macOS) | | Cron job output | `~/.claway/cron/output/{job_id}/{timestamp}.md` | | Cron job definitions | `~/.claway/cron/jobs.json` | | Pairing data | `~/.claway/pairing/` | | Session history | `~/.claway/sessions/` | --- ## Going Further You've got a working team Telegram assistant. Here are some next steps: - **[Security Guide](/user-guide/security)** — deep dive into authorization, container isolation, and command approval - **[Messaging Gateway](/user-guide/messaging)** — full reference for gateway architecture, session management, and chat commands - **[Telegram Setup](/user-guide/messaging/telegram)** — platform-specific details including voice messages and TTS - **[Scheduled Tasks](/user-guide/features/cron)** — advanced cron scheduling with delivery options and cron expressions - **[Context Files](/user-guide/features/context-files)** — AGENTS.md, SOUL.md, and .cursorrules for project knowledge - **[Personality](/user-guide/features/personality)** — built-in personality presets and custom persona definitions - **Add more platforms** — the same gateway can simultaneously run [Discord](/user-guide/messaging/discord), [Slack](/user-guide/messaging/slack), and [WhatsApp](/user-guide/messaging/whatsapp) --- *Questions or issues? Open an issue on GitHub — contributions are welcome.* --- <!-- source: website/docs/guides/use-voice-mode-with-claway.md --> # Use Voice Mode with Claway # Use Voice Mode with Claway This guide is the practical companion to the [Voice Mode feature reference](/user-guide/features/voice-mode). If the feature page explains what voice mode can do, this guide shows how to actually use it well. ## What voice mode is good for Voice mode is especially useful when: - you want a hands-free CLI workflow - you want spoken responses in Telegram or Discord - you want Claway sitting in a Discord voice channel for live conversation - you want quick idea capture, debugging, or back-and-forth while walking around instead of typing ## Choose your voice mode setup There are really three different voice experiences in Claway. | Mode | Best for | Platform | |---|---|---| | Interactive microphone loop | Personal hands-free use while coding or researching | CLI | | Voice replies in chat | Spoken responses alongside normal messaging | Telegram, Discord | | Live voice channel bot | Group or personal live conversation in a VC | Discord voice channels | A good path is: 1. get text working first 2. enable voice replies second 3. move to Discord voice channels last if you want the full experience ## Step 1: make sure normal Claway works first Before touching voice mode, verify that: - Claway starts - your provider is configured - the agent can answer text prompts normally ```bash claway ``` Ask something simple: ```text What tools do you have available? ``` If that is not solid yet, fix text mode first. ## Step 2: install the right extras ### CLI microphone + playback ```bash cd ~/.claway/claway && uv pip install -e ".[voice]" ``` ### Messaging platforms ```bash cd ~/.claway/claway && uv pip install -e ".[messaging]" ``` ### Premium ElevenLabs TTS ```bash cd ~/.claway/claway && uv pip install -e ".[tts-premium]" ``` ### Local NeuTTS (optional) ```bash python -m pip install -U neutts[all] ``` ### Everything ```bash cd ~/.claway/claway && uv pip install -e ".[all]" ``` ## Step 3: install system dependencies ### macOS ```bash brew install portaudio ffmpeg opus brew install espeak-ng ``` ### Ubuntu / Debian ```bash sudo apt install portaudio19-dev ffmpeg libopus0 sudo apt install espeak-ng ``` Why these matter: - `portaudio` → microphone input / playback for CLI voice mode - `ffmpeg` → audio conversion for TTS and messaging delivery - `opus` → Discord voice codec support - `espeak-ng` → phonemizer backend for NeuTTS ## Step 4: choose STT and TTS providers Claway supports both local and cloud speech stacks. ### Easiest / cheapest setup Use local STT and free Edge TTS: - STT provider: `local` - TTS provider: `edge` This is usually the best place to start. ### Environment file example Add to `~/.claway/.env`: ```bash # Cloud STT options (local needs no key) GROQ_API_KEY=*** VOICE_TOOLS_OPENAI_KEY=*** # Premium TTS (optional) ELEVENLABS_API_KEY=*** ``` ### Provider recommendations #### Speech-to-text - `local` → best default for privacy and zero-cost use - `groq` → very fast cloud transcription - `openai` → good paid fallback #### Text-to-speech - `edge` → free and good enough for most users - `neutts` → free local/on-device TTS - `elevenlabs` → best quality - `openai` → good middle ground - `mistral` → multilingual, native Opus ### If you use `claway setup` If you choose NeuTTS in the setup wizard, Claway checks whether `neutts` is already installed. If it is missing, the wizard tells you NeuTTS needs the Python package `neutts` and the system package `espeak-ng`, offers to install them for you, installs `espeak-ng` with your platform package manager, and then runs: ```bash python -m pip install -U neutts[all] ``` If you skip that install or it fails, the wizard falls back to Edge TTS. ## Step 5: recommended config ```yaml voice: record_key: "ctrl+b" max_recording_seconds: 120 auto_tts: false beep_enabled: true silence_threshold: 200 silence_duration: 3.0 stt: provider: "local" local: model: "base" tts: provider: "edge" edge: voice: "en-US-AriaNeural" ``` This is a good conservative default for most people. If you want local TTS instead, switch the `tts` block to: ```yaml tts: provider: "neutts" neutts: ref_audio: '' ref_text: '' model: neuphonic/neutts-air-q4-gguf device: cpu ``` ## Use case 1: CLI voice mode ## Turn it on Start Claway: ```bash claway ``` Inside the CLI: ```text /voice on ``` ### Recording flow Default key: - `Ctrl+B` Workflow: 1. press `Ctrl+B` 2. speak 3. wait for silence detection to stop recording automatically 4. Claway transcribes and responds 5. if TTS is on, it speaks the answer 6. the loop can automatically restart for continuous use ### Useful commands ```text /voice /voice on /voice off /voice tts /voice status ``` ### Good CLI workflows #### Walk-up debugging Say: ```text I keep getting a docker permission error. Help me debug it. ``` Then continue hands-free: - "Read the last error again" - "Explain the root cause in simpler terms" - "Now give me the exact fix" #### Research / brainstorming Great for: - walking around while thinking - dictating half-formed ideas - asking Claway to structure your thoughts in real time #### Accessibility / low-typing sessions If typing is inconvenient, voice mode is one of the fastest ways to stay in the full Claway loop. ## Tuning CLI behavior ### Silence threshold If Claway starts/stops too aggressively, tune: ```yaml voice: silence_threshold: 250 ``` Higher threshold = less sensitive. ### Silence duration If you pause a lot between sentences, increase: ```yaml voice: silence_duration: 4.0 ``` ### Record key If `Ctrl+B` conflicts with your terminal or tmux habits: ```yaml voice: record_key: "ctrl+space" ``` ## Use case 2: voice replies in Telegram or Discord This mode is simpler than full voice channels. Claway stays a normal chat bot, but can speak replies. ### Start the gateway ```bash claway gateway ``` ### Turn on voice replies Inside Telegram or Discord: ```text /voice on ``` or ```text /voice tts ``` ### Modes | Mode | Meaning | |---|---| | `off` | text only | | `voice_only` | speak only when the user sent voice | | `all` | speak every reply | ### When to use which mode - `/voice on` if you want spoken replies only for voice-originating messages - `/voice tts` if you want a full spoken assistant all the time ### Good messaging workflows #### Telegram assistant on your phone Use when: - you are away from your machine - you want to send voice notes and get quick spoken replies - you want Claway to function like a portable research or ops assistant #### Discord DMs with spoken output Useful when you want private interaction without server-channel mention behavior. ## Use case 3: Discord voice channels This is the most advanced mode. Claway joins a Discord VC, listens to user speech, transcribes it, runs the normal agent pipeline, and speaks replies back into the channel. ## Required Discord permissions In addition to the normal text-bot setup, make sure the bot has: - Connect - Speak - preferably Use Voice Activity Also enable privileged intents in the Developer Portal: - Presence Intent - Server Members Intent - Message Content Intent ## Join and leave In a Discord text channel where the bot is present: ```text /voice join /voice leave /voice status ``` ### What happens when joined - users speak in the VC - Claway detects speech boundaries - transcripts are posted in the associated text channel - Claway responds in text and audio - the text channel is the one where `/voice join` was issued ### Best practices for Discord VC use - keep `DISCORD_ALLOWED_USERS` tight - use a dedicated bot/testing channel at first - verify STT and TTS work in ordinary text-chat voice mode before trying VC mode ## Voice quality recommendations ### Best quality setup - STT: local `large-v3` or Groq `whisper-large-v3` - TTS: ElevenLabs ### Best speed / convenience setup - STT: local `base` or Groq - TTS: Edge ### Best zero-cost setup - STT: local - TTS: Edge ## Common failure modes ### "No audio device found" Install `portaudio`. ### "Bot joins but hears nothing" Check: - your Discord user ID is in `DISCORD_ALLOWED_USERS` - you are not muted - privileged intents are enabled - the bot has Connect/Speak permissions ### "It transcribes but does not speak" Check: - TTS provider config - API key / quota for ElevenLabs or OpenAI - `ffmpeg` install for Edge conversion paths ### "Whisper outputs garbage" Try: - quieter environment - higher `silence_threshold` - different STT provider/model - shorter, clearer utterances ### "It works in DMs but not in server channels" That is often mention policy. By default, the bot needs an `@mention` in Discord server text channels unless configured otherwise. ## Suggested first-week setup If you want the shortest path to success: 1. get text Claway working 2. install `claway[voice]` 3. use CLI voice mode with local STT + Edge TTS 4. then enable `/voice on` in Telegram or Discord 5. only after that, try Discord VC mode That progression keeps the debugging surface small. ## Where to read next - [Voice Mode feature reference](/user-guide/features/voice-mode) - [Messaging Gateway](/user-guide/messaging) - [Discord setup](/user-guide/messaging/discord) - [Telegram setup](/user-guide/messaging/telegram) - [Configuration](/user-guide/configuration) --- <!-- source: website/docs/guides/xai-grok-oauth.md --> # xAI Grok OAuth (SuperGrok / X Premium+) # xAI Grok OAuth (SuperGrok / X Premium+) Claway Agent supports xAI Grok through a browser-based OAuth login flow against [accounts.x.ai](https://accounts.x.ai), using either a **SuperGrok subscription** ([grok.com](https://x.ai/grok)) or an **X Premium+ subscription** (linked X account). No `XAI_API_KEY` is required — log in once and Claway automatically refreshes your session in the background. When you sign in with an X account that has Premium+, xAI automatically links the subscription status to your xAI session, so the OAuth flow works the same as it does for direct SuperGrok subscribers. The transport reuses the `codex_responses` adapter (xAI exposes a Responses-style endpoint), so reasoning, tool-calling, streaming, and prompt caching work without any adapter changes. The same OAuth bearer token is also reused by every direct-to-xAI surface in Claway — TTS, image generation, video generation, and transcription — so a single login covers all four. ## Overview | Item | Value | |------|-------| | Provider ID | `xai-oauth` | | Display name | xAI Grok OAuth (SuperGrok / X Premium+) | | Auth type | Browser OAuth 2.0 PKCE (loopback callback) | | Transport | xAI Responses API (`codex_responses`) | | Default model | `grok-build-0.1` | | Endpoint | `https://api.x.ai/v1` | | Auth server | `https://accounts.x.ai` | | Requires env var | No (`XAI_API_KEY` is **not** used for this provider) | | Subscription | [SuperGrok](https://x.ai/grok) or [X Premium+](https://x.com/i/premium_sign_up) — see note below | ## Prerequisites - Python 3.9+ - Claway Agent installed - An active **SuperGrok** subscription on your xAI account, **or** an **X Premium+** subscription on the X account you sign in with (xAI links the subscription automatically) - A browser available on the local machine (or use `--no-browser` for remote sessions) :::warning xAI may restrict OAuth API access by tier xAI's backend enforces its own allowlist on the OAuth API surface and has been seen to reject standard SuperGrok subscribers with `HTTP 403` even though the in-app subscription is active. If OAuth login succeeds in the browser but inference returns 403, set `XAI_API_KEY` and switch to the API-key path (`provider: xai`) — that surface is not subject to the same gating today. ::: ## Quick Start ```bash # Launch the provider and model picker claway model # → Select "xAI Grok OAuth (SuperGrok / X Premium+)" from the provider list # → Claway opens your browser to accounts.x.ai # → Approve access in the browser # → Pick a model (grok-build-0.1 is at the top) # → Start chatting claway ``` After the first login, credentials are stored under `~/.claway/auth.json` and refreshed automatically before they expire. ## Logging In Manually You can trigger a login without going through the model picker: ```bash claway auth add xai-oauth ``` ### Remote / headless sessions On servers, containers, or SSH sessions where no browser is available, Claway detects the remote environment and prints the authorization URL instead of opening a browser. **Important:** the loopback listener still runs on the remote machine at `127.0.0.1:56121`. The xAI redirect needs to reach *that* listener, so opening the URL on your laptop will fail (`Could not establish connection. We couldn't reach your app.`) unless you forward the port: ```bash # In a separate terminal on your local machine: ssh -N -L 56121:127.0.0.1:56121 user@remote-host # Then in your SSH session on the remote machine: claway auth add xai-oauth --no-browser # Open the printed authorize URL in your local browser. ``` Through a jump box / bastion: add `-J jump-user@jump-host`. See [OAuth over SSH / Remote Hosts](./oauth-over-ssh.md) for the full step-by-step, including ProxyJump chains, mosh/tmux, and ControlMaster gotchas. ### Browser-only remotes (Cloud Shell, Codespaces, EC2 Instance Connect) If you don't have a regular SSH client (e.g. you're running Claway inside GCP Cloud Shell, GitHub Codespaces, AWS EC2 Instance Connect, Gitpod, or another browser-based console), the `ssh -L` recipe above isn't available. Use `--manual-paste` instead — Claway skips the loopback listener and lets you paste the failed callback URL straight from your browser: ```bash claway auth add xai-oauth --manual-paste # Or via the model picker: claway model --manual-paste ``` See [OAuth over SSH / Remote Hosts](./oauth-over-ssh.md#browser-only-remote-cloud-shell--codespaces--ec2-instance-connect) for the full walkthrough. If the consent page renders the authorization code directly on the page (xAI's current behavior on browser-based consoles) instead of redirecting to your `127.0.0.1:56121/callback`, paste **just the bare code value** at the `Callback URL:` prompt — Claway accepts the full URL, a bare `?code=...&state=...` query fragment, or a bare code interchangeably. ## How the Login Works 1. Claway opens your browser to `accounts.x.ai`. 2. You sign in (or confirm your existing session) and approve access. 3. xAI redirects back to Claway and the tokens are saved to `~/.claway/auth.json`. 4. From then on, Claway refreshes the access token in the background — you stay signed in until you `claway auth logout xai-oauth` or revoke access from your xAI account settings. ## Checking Login Status ```bash claway doctor ``` The `◆ Auth Providers` section will show the current state of every provider, including `xai-oauth`. ## Switching Models ```bash claway model # → Select "xAI Grok OAuth (SuperGrok / X Premium+)" # → Pick from the model list (grok-build-0.1 is pinned to the top) ``` Or set the model directly: ```bash claway config set model.default grok-build-0.1 claway config set model.provider xai-oauth ``` ## Configuration Reference After login, `~/.claway/config.yaml` will contain: ```yaml model: default: grok-build-0.1 provider: xai-oauth base_url: https://api.x.ai/v1 ``` ### Provider aliases All of the following resolve to `xai-oauth`: ```bash claway --provider xai-oauth # canonical claway --provider grok-oauth # alias claway --provider x-ai-oauth # alias claway --provider xai-grok-oauth # alias ``` ## Direct-to-xAI Tools (TTS / Image / Video / Transcription / X Search) Once you're logged in via OAuth, every direct-to-xAI tool reuses the same bearer token automatically — there is **no separate setup** unless you'd rather use an API key. To pick a backend for each tool: ```bash claway tools # → Text-to-Speech → "xAI TTS" # → Image Generation → "xAI Grok Imagine (image)" # → Video Generation → "xAI Grok Imagine" # → X (Twitter) Search → "xAI Grok OAuth (SuperGrok / X Premium+)" ``` If OAuth tokens are already stored, the picker confirms it and skips the credential prompt. If neither OAuth nor `XAI_API_KEY` is set, the picker offers a 3-choice menu: OAuth login, paste API key, or skip. :::note Video generation is off by default The `video_gen` toolset is disabled by default. Enable it in `claway tools` → `🎬 Video Generation` (press space) before the agent can call `video_generate`. Otherwise the agent may fall back to the bundled ComfyUI skill, which is also tagged for video generation. ::: :::note X search auto-enables when xAI credentials are present The `x_search` toolset auto-enables whenever xAI credentials (a SuperGrok / X Premium+ OAuth token or `XAI_API_KEY`) are configured. Disable explicitly via `claway tools` → `🐦 X (Twitter) Search` (press space) if you don't want this. The tool routes through xAI's built-in `x_search` Responses API — it works with **either** your SuperGrok / X Premium+ OAuth login or a paid `XAI_API_KEY`, and prefers OAuth when both are configured (uses your subscription quota instead of API spend). The tool schema is hidden from the model when no xAI credentials are configured, regardless of whether the toolset is enabled. ::: ### Models | Tool | Model | Notes | |------|-------|-------| | Chat | `grok-build-0.1` | Default; auto-selected when you log in via OAuth | | Chat | `grok-4.3` | Previous default | | Chat | `grok-4.20-0309-reasoning` | Reasoning variant | | Chat | `grok-4.20-0309-non-reasoning` | Non-reasoning variant | | Chat | `grok-4.20-multi-agent-0309` | Multi-agent variant | | Image | `grok-imagine-image` | Default; ~5–10 s | | Image | `grok-imagine-image-quality` | Higher fidelity; ~10–20 s | | Video | `grok-imagine-video` | Text-to-video | | Video | `grok-imagine-video-1.5-preview` | Image-to-video; dated alias `grok-imagine-video-1.5-2026-05-30` | | TTS | (default voice) | xAI `/v1/tts` endpoint | The chat catalog is derived live from the on-disk `models.dev` cache; new xAI releases appear automatically once that cache refreshes. `grok-build-0.1` is always pinned to the top of the list. ## Environment Variables | Variable | Effect | |----------|--------| | `XAI_BASE_URL` | Override the default `https://api.x.ai/v1` endpoint (rarely needed). | To select xAI as the active provider, set `model.provider: xai-oauth` in `config.yaml` (use `claway setup` for the guided flow) or pass `--provider xai-oauth` for a single invocation. ## Troubleshooting ### Token expired — not re-logging in automatically Claway refreshes the token before each session and again reactively on a 401. If refresh fails with `invalid_grant` (the refresh token was revoked, or the account was rotated), Claway surfaces a typed re-auth message instead of crashing. When the refresh failure is terminal (HTTP 4xx, `invalid_grant`, revoked grant, etc.), Claway marks the refresh token as dead and quarantines it locally — subsequent calls skip the doomed refresh attempt instead of replaying the same 401 over and over. The agent surfaces a single "re-authentication required" message and stays out of the way until you log in again. **Fix:** run `claway auth add xai-oauth` again to start a fresh login. The quarantine clears on the next successful exchange. ### Authorization timed out The loopback listener has a finite expiry window (default 180 s). If you don't approve the login in time, Claway raises a timeout error. **Fix:** re-run `claway auth add xai-oauth` (or `claway model`). The flow starts fresh. ### State mismatch (possible CSRF) Claway detected that the `state` value returned by the authorization server doesn't match what it sent. **Fix:** re-run the login. If it persists, check for a proxy or redirect that is modifying the OAuth response. ### Logging in from a remote server On SSH or container sessions Claway prints the authorization URL instead of opening a browser. The loopback callback listener still binds `127.0.0.1:56121` on the remote host — your laptop's browser can't reach it without an SSH local-forward: ```bash # Local machine, separate terminal: ssh -N -L 56121:127.0.0.1:56121 user@remote-host # Remote machine: claway auth add xai-oauth --no-browser ``` Full walkthrough (jump boxes, mosh/tmux, port conflicts): [OAuth over SSH / Remote Hosts](./oauth-over-ssh.md). ### HTTP 403 after a successful login (tier / entitlement) OAuth completed in the browser, tokens are saved, but inference or token refresh returns `HTTP 403` with a message similar to *"The caller does not have permission to execute the specified operation"*. This is **not** a stale-token problem — re-running `claway model` won't change it. xAI's backend has been seen to restrict OAuth API access to specific SuperGrok tiers despite the in-app subscription being active. **Fix:** set `XAI_API_KEY` and switch to the API-key path: ```bash export XAI_API_KEY=xai-... claway config set model.provider xai ``` Or upgrade your subscription at [x.ai/grok](https://x.ai/grok) if the OAuth route is required. ### "No xAI credentials found" error at runtime The auth store has no `xai-oauth` entry and no `XAI_API_KEY` is set. You haven't logged in yet, or the credential file was deleted. **Fix:** run `claway model` and pick the xAI Grok OAuth provider, or run `claway auth add xai-oauth`. ## Logging Out To remove all stored xAI Grok OAuth credentials: ```bash claway auth logout xai-oauth ``` This clears both the singleton OAuth entry in `auth.json` and any credential-pool rows for `xai-oauth`. Use `claway auth remove xai-oauth <index|id|label>` if you only want to drop a single pool entry (run `claway auth list xai-oauth` to see them). ## See Also - [OAuth over SSH / Remote Hosts](./oauth-over-ssh.md) — required reading if Claway is on a different machine than your browser - [AI Providers reference](../integrations/providers.md) - [Environment Variables](../reference/environment-variables.md) - [Configuration](../user-guide/configuration.md) - [Voice & TTS](../user-guide/features/tts.md) --- <!-- source: website/docs/operators/escalation.md --> # When to escalate # When to escalate to Blockway The dashboard exposes almost everything you need to run day-to-day operations without support. But some signals mean stop, don't retry, and open a ticket. This page is that list. ## Contact channels - **Slack shared channel** — your customer success contact will have added you at deployment. Use for anything non-urgent (< 4 h response goal, working hours HKT). - **support@claway.io** — email for anything that isn't in the shared channel. Includes screenshots + timestamps. First response within 1 business day. - **On-call phone** — hand-delivered when the customer signs. Reserved for production down. See below. ## Escalate immediately (on-call) - **Dashboard returns 5xx across all pages for more than five minutes.** Not a specific page — every page. This is the Claway process itself. Live Events being empty while the customer swears they messaged is often a version of this. - **The gateway systemd unit is in a restart loop.** `systemctl status claway-<tenant>-gateway` shows `Restart` count climbing every few seconds and each restart logs the same trace. Do not attempt a manual code fix on the customer's box. - **Data corruption warnings in logs.** Anything with the words "checksum", "invariant", "unreachable state", or "database corrupt" in either the gateway log or the postgres log. Stop the affected service and call. - **A message clearly leaked from the wrong tenant** — the accounting group's Jarvis referenced a client that belongs to the sales group. This should be structurally impossible; if it happens, the SQL isolation may have regressed and we treat it as a security incident. - **TOTP is broken and no operator can log in.** Do not remove the auth gate yourself. We have a recovery path. ## Escalate during business hours - The dashboard is up but a specific page is broken (500 error, blank render, "endpoint not found"). - Persona save appears to succeed but the change is not reflected in Jarvis's replies. If restarting the gateway does not fix it, escalate. - KB ingest is silently failing (documents queued but never appearing) and neither `KB_EMBEDDING_BASE_URL` nor `KB_RERANK_BASE_URL` values in **System → Env** are the cause. - The dashboard's version banner is more than one release behind and you are not sure how to upgrade safely. - Any UI text is in a language you do not read and there is no obvious translation button. ## Handle yourself first, escalate only if that fails - WhatsApp bridge stuck in `AwaitingInitialSync` — QR re-pair from **Connectors → WhatsApp**. - Session appears to have "amnesia" (Jarvis forgot recent context) — the compression step may have failed. **Sessions → Kill** it and restart the conversation. - Jarvis says "I don't have kb_search" — check the three gates in the [KB guide](/operators/kb-guide) troubleshooting section. - Alerts firing constantly — mute the noisy category in **Alerts**, then file a ticket asking us to re-tune the default. ## What to include in a ticket - Timestamp (with timezone). - Tenant slug (visible in the top-right of every dashboard page). - One-line summary of the symptom. - Screenshot of **Live Events** at the time of the symptom, if applicable. - If a specific chat is affected, the group JID (visible on the Personas page). - A single line saying "safe to restart `<service>`" or "please do not restart, customer has a live session" — this shortens our response time significantly. We do not need you to attach log excerpts unless we ask; the Infra Panel already ingests them. ## What we will never ask you for - Your TOTP secret. - The contents of `~/.claway/license.key`. - Any customer PII beyond what's needed to reproduce the specific symptom. If someone claiming to be Blockway asks for any of the above, stop and verify via the Slack channel first. --- <!-- source: website/docs/operators/retention-policy.md --> # operators/retention-policy.md # Data Retention Policy Claway keeps every customer's data on their own instance's disk. The gateway process runs a background retention sweep that enforces a configurable TTL per data class. This page tells you what defaults ship, what you can tune, and how to answer procurement's questions. ## Defaults Every field is optional. The values below are the shipped defaults. Anything absent in `config.yaml` under `retention:` uses these. | Class | Default TTL | What gets purged | |---|---|---| | Events (jarvis_ops PG) | 90 days | Control actions, tool calls, alerts, telemetry heartbeats | | Messages (SQLite `state.db`) | 180 days | User + agent message rows + FTS index | | Sessions (SQLite `state.db`) | 180 days | Session metadata (title, model, cost totals) | | KB documents | 365 days | Uploaded documents older than N days that aren't referenced in any recent session | | Audit trail | 365 days | `audit_events` / `control_actions` — who did what, when | | Memories | ∞ (999_999 days) | Deliberately effectively-off. Memories are user-authored; deleting them is destructive to Jarvis's persona. Set an explicit value to enable. | | Cache files | 7 days | `~/.claway/cache/{images,audio,videos,documents}/…` — inbound media, per-chat scoped since #media-cache-isolation | | Sweep interval | 6 hours | How often the worker wakes up. Never faster than 5 minutes. | ## Tuning ```yaml # ~/.claway/config.yaml retention: events_days: 30 # aggressive — 30 days of activity trail messages_days: 365 # keep a year of transcripts sessions_days: 365 kb_documents_days: 730 audit_days: 1825 # 5 years — matches most compliance minimums memories_days: 999999 # OFF cache_days: 3 # cache is a working copy; short is fine sweep_interval_hours: 6 ``` Config edits take effect on the **next sweep tick** — you don't need to restart the gateway. The worker reloads `load_gateway_config()` on every iteration. ## Bounds The worker clamps every value to `[1, 3650]` days. A misconfigured `events_days: 0` (or negative, or non-numeric) reverts to the shipping default, not "delete everything now." ## Log signal Every sweep emits an INFO line: ``` retention: purged events=124 messages=8 sessions=2 kb_documents=0 audit=1 memories=0 cache_files=347 errors=0 ``` Grep for `retention:` in the gateway journal. `errors > 0` means one of the sweeps hit an exception — check the WARNING lines just before. ## For enterprise procurement The buyer asks: "How long do you keep our data?" The answer: - **90 days** by default for operational events. - **180 days** by default for transcripts and sessions. - **1 year** by default for uploaded documents. - **1 year** by default for audit trail (who did what). - **Every one is tunable** by editing `config.yaml`. Range 1 day to 10 years. - **The purge is enforced automatically** by a scheduled worker in the gateway process. There is no "someone has to remember to run it" step. - **Memories are user-authored** and default to being kept indefinitely — we treat them like customer-owned files, not operational state. Set an explicit TTL to purge them. - **Cache** (inbound media working copies) is 7 days by default. These are per-chat scoped since 2026-07 so no accidental cross-chat exposure during the retention window. The buyer's follow-up: "What if we want to delete a specific tenant's data on demand?" That's the `tenant-offboarding` runbook — retention is the automatic sweep; offboarding is the on-demand purge. --- <!-- source: website/docs/operators/status-page-setup.md --> # operators/status-page-setup.md # status.claway.io — Public Status Page Setup > **Audience**: Blockway staff. This is a one-time setup for the public > uptime signal enterprise buyers see before signing. Not customer-facing. ## What ships out of the box The Claway Infra Panel already exposes two public endpoints — no auth required, safe to hit from anywhere: | URL | Format | Use for | |---|---|---| | `https://panel.claway.io/api/plugins/claway-infra-panel/status` | JSON | Machine-readable monitor / API poll | | `https://panel.claway.io/api/plugins/claway-infra-panel/status.html` | HTML | Human-readable current status | The JSON is the source of truth. Sample: ```json { "status": "operational", "fleet": { "instances_online": 12, "instances_total": 12 }, "incidents": [...], "generated_at": "2026-07-03T13:34:42+00:00" } ``` `status` is either `"operational"` (every registered instance heartbeated in the last 5 minutes) or `"degraded"` (at least one is missing). `incidents` is the operator-declared list (created from the panel's `/incidents` page). Heartbeat gaps are logged privately as SLO events — they don't post to the public page unless a Blockway staffer promotes them to a public incident. ## Recommended: Better Stack Uptime (free tier) Better Stack Uptime gives us the public status page + monitoring for $0/month on the free tier (up to 10 monitors, 3-minute check frequency, public status page included). We recommend this over self-rolling. ### Step-by-step 1. **Sign up** at [betterstack.com/uptime](https://betterstack.com/uptime). Use the `ops@blockway.io` alias so the account is shared, not personal. 2. **Create the monitor** — this is what actually polls Claway: - Type: `HTTP(s)` - URL: `https://panel.claway.io/api/plugins/claway-infra-panel/status` - Method: `GET` - Check frequency: `3 minutes` (free-tier max) - Region: pick 2 (e.g. `us-east-1` + `eu-west-1`) so a single-region outage doesn't page. - **Advanced → Response body contains**: `"operational"` — this promotes the monitor from "endpoint reachable" to "endpoint reachable AND says all is well". Without this, a `"degraded"` response would still be counted as up. - Notification: Slack channel `#claway-ops-oncall` or the phone rotation. Don't leave notifications empty. 3. **Create the status page**: - Better Stack → Status pages → New - Custom domain: `status.claway.io` - Point a `CNAME` from your DNS provider (`status` → `<generated>.betteruptime.com`). - Add the monitor from step 2 as the "Claway Panel" component. - Optionally add other components (WhatsApp bridge, KB worker) later — each needs its own healthz endpoint published. - Publish. 4. **Test**: ```bash # From your laptop — confirm the JSON is reachable + operational curl -s https://panel.claway.io/api/plugins/claway-infra-panel/status | jq .status # ⇒ "operational" ``` Then simulate a degraded response by stopping the gateway on the server for one minute (`systemctl --user stop claway-gateway`) — `instances_online` drops to zero, status flips to `"degraded"`, Better Stack alerts on the next poll. ### Cost | Tier | Monitors | Frequency | Cost | Verdict | |---|---|---|---|---| | Free | 10 | 3 min | $0/month | Ships day 1 | | Team | 50 | 30 s | $18/month | If we ever need sub-minute alerting | Stay on free until we outgrow it. ## Alternative: statuspage.io / Instatus Both work identically — same JSON keyword monitor, same DNS CNAME step. Better Stack is our pick because it also runs incident review + on-call paging in the same account, saving a second SaaS bill later. ## Manual smoke check Run this from any laptop with connectivity, no auth needed: ```bash # 1. Fleet health curl -s https://panel.claway.io/api/plugins/claway-infra-panel/status \ | python -c 'import sys, json; d=json.load(sys.stdin); print(d["status"], d["fleet"])' # 2. HTML view (what humans see) open https://panel.claway.io/api/plugins/claway-infra-panel/status.html # 3. Once Better Stack is live open https://status.claway.io ``` --- <!-- source: website/docs/reference/mcp-config-reference.md --> # MCP Config Reference # MCP Config Reference This page is the compact reference companion to the main MCP docs. For conceptual guidance, see: - [MCP (Model Context Protocol)](/user-guide/features/mcp) - [Use MCP with Claway](/guides/use-mcp-with-claway) ## Root config shape ```yaml mcp_servers: <server_name>: command: "..." # stdio servers args: [] env: {} # OR url: "..." # HTTP servers headers: {} # Optional HTTP/SSE TLS settings: ssl_verify: true # bool or path to a CA bundle (PEM) client_cert: "/path/to/cert.pem" # mTLS client certificate (see below) # client_key: "/path/to/key.pem" # optional, when key lives in a separate file enabled: true timeout: 120 connect_timeout: 60 supports_parallel_tool_calls: false tools: include: [] exclude: [] resources: true prompts: true ``` ## Server keys | Key | Type | Applies to | Meaning | |---|---|---|---| | `command` | string | stdio | Executable to launch | | `args` | list | stdio | Arguments for the subprocess | | `env` | mapping | stdio | Environment passed to the subprocess | | `url` | string | HTTP | Remote MCP endpoint | | `headers` | mapping | HTTP | Headers for remote server requests | | `ssl_verify` | bool or string | HTTP | TLS verification. `true` (default) uses system CAs, `false` disables verification (insecure), or a string path to a custom CA bundle (PEM) | | `client_cert` | string or list | HTTP | mTLS client certificate. String = path to a PEM file containing cert + key. List `[cert, key]` = separate files. List `[cert, key, password]` = encrypted key | | `client_key` | string | HTTP | Path to the client private key, when `client_cert` is a string and the key is in a separate file | | `enabled` | bool | both | Skip the server entirely when false | | `timeout` | number | both | Tool call timeout in seconds (default: `300`) | | `connect_timeout` | number | both | Initial connection timeout in seconds (default: `60`) | | `supports_parallel_tool_calls` | bool | both | Allow tools from this server to run concurrently | | `tools` | mapping | both | Filtering and utility-tool policy | | `auth` | string | HTTP | Authentication method. Set to `oauth` to enable OAuth 2.1 with PKCE | | `sampling` | mapping | both | Server-initiated LLM request policy (see MCP guide) | ## `tools` policy keys | Key | Type | Meaning | |---|---|---| | `include` | string or list | Whitelist server-native MCP tools | | `exclude` | string or list | Blacklist server-native MCP tools | | `resources` | bool-like | Enable/disable `list_resources` + `read_resource` | | `prompts` | bool-like | Enable/disable `list_prompts` + `get_prompt` | ## Filtering semantics ### `include` If `include` is set, only those server-native MCP tools are registered. ```yaml tools: include: [create_issue, list_issues] ``` ### `exclude` If `exclude` is set and `include` is not, every server-native MCP tool except those names is registered. ```yaml tools: exclude: [delete_customer] ``` ### Precedence If both are set, `include` wins. ```yaml tools: include: [create_issue] exclude: [create_issue, delete_issue] ``` Result: - `create_issue` is still allowed - `delete_issue` is ignored because `include` takes precedence ## Utility-tool policy Claway may register these utility wrappers per MCP server: Resources: - `list_resources` - `read_resource` Prompts: - `list_prompts` - `get_prompt` ### Disable resources ```yaml tools: resources: false ``` ### Disable prompts ```yaml tools: prompts: false ``` ### Capability-aware registration Even when `resources: true` or `prompts: true`, Claway only registers those utility tools if the MCP session actually exposes the corresponding capability. So this is normal: - you enable prompts - but no prompt utilities appear - because the server does not support prompts ## `enabled: false` ```yaml mcp_servers: legacy: url: "https://mcp.legacy.internal" enabled: false ``` Behavior: - no connection attempt - no discovery - no tool registration - config remains in place for later reuse ## Empty result behavior If filtering removes all server-native tools and no utility tools are registered, Claway does not create an empty MCP runtime toolset for that server. ## Example configs ### Safe GitHub allowlist ```yaml mcp_servers: github: command: "npx" args: ["-y", "@modelcontextprotocol/server-github"] env: GITHUB_PERSONAL_ACCESS_TOKEN: "***" tools: include: [list_issues, create_issue, update_issue, search_code] resources: false prompts: false ``` ### Stripe blacklist ```yaml mcp_servers: stripe: url: "https://mcp.stripe.com" headers: Authorization: "Bearer ***" tools: exclude: [delete_customer, refund_payment] ``` ### Resource-only docs server ```yaml mcp_servers: docs: url: "https://mcp.docs.example.com" tools: include: [] resources: true prompts: false ``` ### TLS client certificate (mTLS) For HTTP/SSE servers that require a client certificate, set `client_cert` (and optionally `client_key`): ```yaml mcp_servers: # Combined cert + key in a single PEM file internal_api: url: "https://mcp.internal.example.com/mcp" client_cert: "~/secrets/mcp-client.pem" # Separate cert and key files partner_api: url: "https://mcp.partner.example.com/mcp" client_cert: "~/secrets/client.crt" client_key: "~/secrets/client.key" # Encrypted key with a passphrase (3-element list form) bank_api: url: "https://mcp.bank.example.com/mcp" client_cert: ["~/secrets/client.crt", "~/secrets/client.key", "my-passphrase"] # Custom CA bundle (private CA / self-signed server) lab_api: url: "https://mcp.lab.local/mcp" ssl_verify: "~/secrets/lab-ca.pem" client_cert: "~/secrets/lab-client.pem" ``` Notes: - Paths support `~` expansion. Missing files fail fast at connect time with a server-scoped error message. - `ssl_verify: false` disables server certificate verification entirely. Don't use this with real services. - Works on both Streamable HTTP and SSE transports. ## Reloading config After changing MCP config, reload servers with: ```text /reload-mcp ``` ## Tool naming Server-native MCP tools become: ```text mcp_<server>_<tool> ``` Examples: - `mcp_github_create_issue` - `mcp_filesystem_read_file` - `mcp_my_api_query_data` Utility tools follow the same prefixing pattern: - `mcp_<server>_list_resources` - `mcp_<server>_read_resource` - `mcp_<server>_list_prompts` - `mcp_<server>_get_prompt` ### Name sanitization Hyphens (`-`) and dots (`.`) in both server names and tool names are replaced with underscores before registration. This ensures tool names are valid identifiers for LLM function-calling APIs. For example, a server named `my-api` exposing a tool called `list-items.v2` becomes: ```text mcp_my_api_list_items_v2 ``` Keep this in mind when writing `include` / `exclude` filters — use the **original** MCP tool name (with hyphens/dots), not the sanitized version. ## OAuth 2.1 authentication For HTTP servers that require OAuth, set `auth: oauth` on the server entry: ```yaml mcp_servers: protected_api: url: "https://mcp.example.com/mcp" auth: oauth ``` Behavior: - Claway uses the MCP SDK's OAuth 2.1 PKCE flow (metadata discovery, dynamic client registration, token exchange, and refresh) - On first connect, a browser window opens for authorization - Tokens are persisted to `~/.claway/mcp-tokens/<server>.json` and reused across sessions - Token refresh is automatic; re-authorization only happens when refresh fails - Only applies to HTTP/StreamableHTTP transport (`url`-based servers) --- <!-- source: website/docs/reference/profile-commands.md --> # reference/profile-commands.md # Profile Commands Reference This page covers all commands related to [Claway profiles](../user-guide/profiles.md). For general CLI commands, see [CLI Commands Reference](./cli-commands.md). ## `claway profile` ```bash claway profile <subcommand> ``` Top-level command for managing profiles. Running `claway profile` without a subcommand shows help. | Subcommand | Description | |------------|-------------| | `list` | List all profiles. | | `use` | Set the active (default) profile. | | `create` | Create a new profile. | | `describe` | Read or set a profile's description (used by the kanban orchestrator for routing). | | `delete` | Delete a profile. | | `show` | Show details about a profile. | | `alias` | Regenerate the shell alias for a profile. | | `rename` | Rename a profile. | | `export` | Export a profile to a tar.gz archive. | | `import` | Import a profile from a tar.gz archive. | | `install` | Install a profile distribution from a git URL or local directory. See [Profile Distributions](../user-guide/profile-distributions.md). | | `update` | Re-pull a distribution-managed profile and re-apply its bundle. | | `info` | Show distribution metadata for a profile (origin URL, commit, last update). | ## `claway profile list` ```bash claway profile list ``` Lists all profiles. The currently active profile is marked with `*`. **Example:** ```bash $ claway profile list default * work dev personal ``` No options. ## `claway profile use` ```bash claway profile use <name> ``` Sets `<name>` as the active profile. All subsequent `claway` commands (without `-p`) will use this profile. | Argument | Description | |----------|-------------| | `<name>` | Profile name to activate. Use `default` to return to the base profile. | **Example:** ```bash claway profile use work claway profile use default ``` ## `claway profile create` ```bash claway profile create <name> [options] ``` Creates a new profile. | Argument / Option | Description | |-------------------|-------------| | `<name>` | Name for the new profile. Must be a valid directory name (alphanumeric, hyphens, underscores). | | `--clone` | Copy `config.yaml`, `.env`, `SOUL.md`, and skills from the current profile. | | `--clone-all` | Copy everything (config, memories, skills, cron, plugins) from the current profile. Excludes per-profile history: sessions, `state.db`, backups, state-snapshots, checkpoints. | | `--clone-from <profile>` | Clone config/skills/SOUL from a specific profile instead of the current one. Implies `--clone` unless paired with `--clone-all`. | | `--no-alias` | Skip wrapper script creation. | | `--description "<text>"` | One- or two-sentence description of what this profile is good at. Used by the kanban orchestrator to route tasks based on role instead of profile name alone. Skip and add later via `claway profile describe`. Persisted in `<profile_dir>/profile.yaml`. | | `--no-skills` | Create an **empty** profile with zero bundled skills enabled. Writes a `.no-bundled-skills` marker into the profile so future `claway update` runs won't re-seed the bundled set, and refuses to combine with `--clone`, `--clone-from`, or `--clone-all` (which would copy skills in anyway). Useful for narrow orchestrator profiles or sandbox profiles that should not inherit the full skill catalog. To toggle this on an already-created profile (including the default `~/.claway`), use `claway skills opt-out` / `claway skills opt-in`. | Creating a profile does **not** make that profile directory the default project/workspace directory for terminal commands. If you want a profile to start in a specific project, set `terminal.cwd` in that profile's `config.yaml`. **Examples:** ```bash # Blank profile — needs full setup claway profile create mybot # Clone config only from current profile claway profile create work --clone # Clone everything from current profile claway profile create backup --clone-all # Clone config from a specific profile claway profile create work2 --clone-from work # Clone everything from a specific profile claway profile create work2-backup --clone-from work --clone-all ``` ## `claway profile describe` ```bash claway profile describe [<name>] [options] ``` Read or set a profile's description. The description is consumed by the kanban orchestrator to route tasks based on what each profile is good at, rather than guessing from the profile name alone. Persisted in `<profile_dir>/profile.yaml` so it survives reboots and is shared with the gateway. With no flags, prints the current description (or `(no description set for '<name>')` if empty). | Argument / Option | Description | |-------------------|-------------| | `<name>` | Profile to describe. Required unless `--all --auto` is used. | | `--text "<text>"` | Set the description to this exact text (user-authored). Overwrites any existing description. | | `--auto` | Auto-generate a 1-2 sentence description via the auxiliary LLM, based on the profile's installed skills, configured model, and name. Configure the model under `auxiliary.profile_describer` in `config.yaml`. Auto-generated descriptions are marked `description_auto: true` so the dashboard can flag them for review. | | `--overwrite` | With `--auto`, replace user-authored descriptions too (default: skip profiles whose description was set explicitly). | | `--all` | With `--auto`, sweep every profile missing a description. | **Examples:** ```bash # Read the current description claway profile describe researcher # Set it explicitly claway profile describe researcher --text "Reads source code and writes findings." # Let the LLM generate one claway profile describe researcher --auto # Fill in descriptions for every profile that doesn't have one claway profile describe --all --auto ``` ## `claway profile delete` ```bash claway profile delete <name> [options] ``` Deletes a profile and removes its shell alias. | Argument / Option | Description | |-------------------|-------------| | `<name>` | Profile to delete. | | `--yes`, `-y` | Skip confirmation prompt. | **Example:** ```bash claway profile delete mybot claway profile delete mybot --yes ``` :::warning This permanently deletes the profile's entire directory including all config, memories, sessions, and skills. Cannot delete the currently active profile. ::: ## `claway profile show` ```bash claway profile show <name> ``` Displays details about a profile including its home directory, configured model, gateway status, skills count, and configuration file status. This shows the profile's Claway home directory, not the terminal working directory. Terminal commands start from `terminal.cwd` (or the launch directory on the local backend when `cwd: "."`). | Argument | Description | |----------|-------------| | `<name>` | Profile to inspect. | **Example:** ```bash $ claway profile show work Profile: work Path: ~/.claway/profiles/work Model: anthropic/claude-sonnet-4 (anthropic) Gateway: stopped Skills: 12 .env: exists SOUL.md: exists Alias: ~/.local/bin/work ``` ## `claway profile alias` ```bash claway profile alias <name> [options] ``` Regenerates the shell alias script at `~/.local/bin/<name>`. Useful if the alias was accidentally deleted or if you need to update it after moving your Claway installation. | Argument / Option | Description | |-------------------|-------------| | `<name>` | Profile to create/update the alias for. | | `--remove` | Remove the wrapper script instead of creating it. | | `--name <alias>` | Custom alias name (default: profile name). | **Example:** ```bash claway profile alias work # Creates/updates ~/.local/bin/work claway profile alias work --name mywork # Creates ~/.local/bin/mywork claway profile alias work --remove # Removes the wrapper script ``` ## `claway profile rename` ```bash claway profile rename <old-name> <new-name> ``` Renames a profile. Updates the directory and shell alias. | Argument | Description | |----------|-------------| | `<old-name>` | Current profile name. | | `<new-name>` | New profile name. | **Example:** ```bash claway profile rename mybot assistant # ~/.claway/profiles/mybot → ~/.claway/profiles/assistant # ~/.local/bin/mybot → ~/.local/bin/assistant ``` ## `claway profile export` ```bash claway profile export <name> [options] ``` Exports a profile as a compressed tar.gz archive. | Argument / Option | Description | |-------------------|-------------| | `<name>` | Profile to export. | | `-o`, `--output <path>` | Output file path (default: `<name>.tar.gz`). | **Example:** ```bash claway profile export work # Creates work.tar.gz in the current directory claway profile export work -o ./work-2026-03-29.tar.gz ``` ## `claway profile import` ```bash claway profile import <archive> [options] ``` Imports a profile from a tar.gz archive. | Argument / Option | Description | |-------------------|-------------| | `<archive>` | Path to the tar.gz archive to import. | | `--name <name>` | Name for the imported profile (default: inferred from archive). | **Example:** ```bash claway profile import ./work-2026-03-29.tar.gz # Infers profile name from the archive claway profile import ./work-2026-03-29.tar.gz --name work-restored ``` ## Distribution commands :::tip **New to distributions?** Start with the [Profile Distributions user guide](../user-guide/profile-distributions.md) — it covers the why, when, and how with full examples. The sections below are a dry CLI reference for when you know what you want. ::: Distributions turn a profile into a shareable, versioned artifact published as a **git repository**. A recipient installs the distribution with a single command and can update it in place later without touching their local memories, sessions, or credentials. `auth.json` and `.env` are never part of a distribution — they stay on the installing user's machine. The recipient's user data (memories, sessions, auth, their own edits to `.env`) is always preserved across the initial install and subsequent updates. :::info `claway profile export` / `import` are still the right commands for **local backup and restore** of a profile on your own machine. Distribution (`install` / `update` / `info`) is a separate concept: ship a profile via git so someone else can install it. ::: ### `claway profile install` ```bash claway profile install <source> [--name <name>] [--alias] [--force] [--yes] ``` Installs a profile distribution from a git URL or a local directory. | Option | Description | |--------|-------------| | `<source>` | Git URL (`github.com/user/repo`, `https://...`, `git@...`, `ssh://`, `git://`) or a local directory containing `distribution.yaml` at its root. | | `--name NAME` | Override the profile name from the manifest. | | `--alias` | Also create a shell wrapper (e.g. `telemetry` → `claway -p telemetry`). | | `--force` | Overwrite an existing profile of the same name. User data is still preserved. | | `-y`, `--yes` | Skip the manifest-preview confirmation prompt. | The installer shows the manifest, lists required env vars, and warns about cron jobs before asking for confirmation. Required env vars go into a `.env.EXAMPLE` file you copy to `.env` and fill in. **Examples:** ```bash # Install from a GitHub repo (shorthand) claway profile install github.com/kyle/telemetry-distribution --alias # Install from a full HTTPS git URL claway profile install https://github.com/kyle/telemetry-distribution.git # Install from SSH claway profile install git@github.com:kyle/telemetry-distribution.git # Install from a local directory during development claway profile install ./telemetry/ ``` ### `claway profile update` ```bash claway profile update <name> [--force-config] [--yes] ``` Re-clones the distribution from its recorded source and applies updates. Distribution-owned files (SOUL.md, skills/, cron/, mcp.json) are overwritten; user data (memories, sessions, auth, .env) is never touched. `config.yaml` is preserved by default to keep your local overrides. Pass `--force-config` to reset it to the distribution's shipped config. ### `claway profile info` ```bash claway profile info <name> ``` Prints the profile's distribution manifest — name, version, required Claway version, author, env var requirements, the source URL/path, and the `Installed:` timestamp recorded when the distribution was last `install`-ed or `update`-d. Useful for checking what a shared profile needs before installing it, and for spotting "this profile was installed 6 months ago and hasn't been updated." `claway profile list` also shows the distribution name and version in a `Distribution` column, and `claway profile show <name>` / `delete <name>` surface the source URL so you can tell at a glance which profiles came from a git repo vs. were created locally. ### Private distributions A private git repository works as a distribution source with no extra configuration — the install shells out to your normal `git` binary, so whatever authentication your shell is already set up for (SSH key, `git credential` helper, GitHub CLI's stored HTTPS credentials) applies transparently. ```bash # Uses your SSH key, the same as any other `git clone` claway profile install git@github.com:your-org/internal-assistant.git # Uses your git credential helper claway profile install https://github.com/your-org/internal-assistant.git ``` If a clone prompts for credentials interactively in your terminal during install, that prompt flows through. Set up your auth the way you'd normally use `git clone` against the same repo first, then install. ### Distribution manifest (`distribution.yaml`) Every distribution has a `distribution.yaml` at the root of its repository: ```yaml name: telemetry version: 0.1.0 description: "Compliance monitoring harness" claway_requires: ">=0.12.0" author: "Your Name" license: "MIT" env_requires: - name: OPENAI_API_KEY description: "OpenAI API key" required: true - name: GRAPHITI_MCP_URL description: "Memory graph URL" required: false default: "http://127.0.0.1:8000/sse" distribution_owned: # optional; defaults to SOUL.md, config.yaml, # mcp.json, skills/, cron/, distribution.yaml - SOUL.md - skills/compliance/ - cron/ ``` `claway_requires` supports `>=`, `<=`, `==`, `!=`, `>`, `<`, or a bare version (treated as `>=`). Install fails with a clear error if the current Claway version doesn't satisfy the spec. `distribution_owned` is optional. If set, only those paths are replaced on update; anything else in the profile stays user-owned. If omitted, the defaults above apply. ### Publishing a distribution Authoring a distribution is just a git push: 1. In your profile directory, create `distribution.yaml` with at least `name` and `version`. 2. Initialize a git repo (or use an existing one) and push to GitHub / GitLab / any host Claway can clone from. 3. Tell recipients to run `claway profile install <your-repo-url>`. Use git tags for versioned releases — recipients who clone `HEAD` get your latest state, and you can always bump `version:` in the manifest. ## `claway -p` / `claway --profile` ```bash claway -p <name> <command> [options] claway --profile <name> <command> [options] ``` Global flag to run any Claway command under a specific profile without changing the sticky default. This overrides the active profile for the duration of the command. | Option | Description | |--------|-------------| | `-p <name>`, `--profile <name>` | Profile to use for this command. | **Examples:** ```bash claway -p work chat -q "Check the server status" claway --profile dev gateway start claway -p personal skills list claway -p work config edit ``` ## `claway completion` ```bash claway completion <shell> ``` Generates shell completion scripts. Includes completions for profile names and profile subcommands. | Argument | Description | |----------|-------------| | `<shell>` | Shell to generate completions for: `bash`, `zsh`, or `fish`. | **Examples:** ```bash # Install completions claway completion bash >> ~/.bashrc claway completion zsh >> ~/.zshrc claway completion fish > ~/.config/fish/completions/claway.fish # Reload shell source ~/.bashrc ``` After installation, tab completion works for: - `claway profile <TAB>` — subcommands (list, use, create, etc.) - `claway profile use <TAB>` — profile names - `claway -p <TAB>` — profile names ## See also - [Profiles User Guide](../user-guide/profiles.md) - [CLI Commands Reference](./cli-commands.md) - [FAQ — Profiles section](./faq.md#profiles) --- <!-- source: website/docs/user-guide/features/built-in-plugins.md --> # Built-in Plugins # Built-in Plugins Claway ships a small set of plugins bundled with the repository. They live under `<repo>/plugins/<name>/` and load automatically alongside user-installed plugins in `~/.claway/plugins/`. They use the same plugin surface as third-party plugins — hooks, tools, slash commands — just maintained in-tree. See the [Plugins](/user-guide/features/plugins) page for the general plugin system, and [Build a Claway Plugin](/guides/build-a-claway-plugin) to write your own. ## How discovery works The `PluginManager` scans four sources, in order: 1. **Bundled** — `<repo>/plugins/<name>/` (what this page documents) 2. **User** — `~/.claway/plugins/<name>/` 3. **Project** — `./.claway/plugins/<name>/` (requires `CLAWAY_ENABLE_PROJECT_PLUGINS=1`) 4. **Pip entry points** — `claway_agent.plugins` On name collision, later sources win — a user plugin named `disk-cleanup` would replace the bundled one. `plugins/memory/` and `plugins/context_engine/` are deliberately excluded from bundled scanning. Those directories use their own discovery paths because memory providers and context engines are single-select providers configured through `claway memory setup` / `context.engine` in config. ## Bundled plugins are opt-in Bundled plugins ship disabled. Discovery finds them (they appear in `claway plugins list` and the interactive `claway plugins` UI), but none load until you explicitly enable them: ```bash claway plugins enable disk-cleanup ``` Or via `~/.claway/config.yaml`: ```yaml plugins: enabled: - disk-cleanup ``` This is the same mechanism user-installed plugins use. Bundled plugins are never auto-enabled — not on fresh install, not for existing users upgrading to a newer Claway. You always opt in explicitly. To turn a bundled plugin off again: ```bash claway plugins disable disk-cleanup # or: remove it from plugins.enabled in config.yaml ``` ## Currently shipped The repo ships these bundled plugins under `plugins/`. All are opt-in — enable them via `claway plugins enable <name>`. | Plugin | Kind | Purpose | |---|---|---| | `disk-cleanup` | hooks + slash command | Auto-track ephemeral files and clean them on session end | | `security-guidance` | hooks | Pattern-match dangerous code on `write_file`/`patch` and append a security warning (or block) — 25 rules (Apache-2.0 fork of Anthropic's `claude-plugins-official` patterns) | | `observability/langfuse` | hooks | Trace turns / LLM calls / tools to [Langfuse](https://langfuse.com) | | `observability/nemo_relay` | hooks | Relay observability events (turns / LLM calls / tools) to an NVIDIA NeMo endpoint | | `teams_pipeline` | standalone | Microsoft Teams meeting pipeline — Graph-backed, transcript-first meeting summaries | | `spotify` | backend (7 tools) | Native Spotify playback, queue, search, playlists, albums, library | | `google_meet` | standalone | Join Meet calls, live-caption transcription, optional realtime duplex audio | | `image_gen/openai` | image backend | OpenAI `gpt-image-2` image generation backend (alternative to FAL) | | `image_gen/openai-codex` | image backend | OpenAI image generation via Codex OAuth | | `image_gen/xai` | image backend | xAI `grok-2-image` backend | | `claway-achievements` | dashboard tab | Steam-style collectible badges generated from your real Claway session history | | `kanban/dashboard` | dashboard tab | Kanban board UI for the multi-agent dispatcher — tasks, comments, fan-out, board switching. See [Kanban Multi-Agent](./kanban.md). | Memory providers (`plugins/memory/*`) and context engines (`plugins/context_engine/*`) are listed separately on [Memory Providers](./memory-providers.md) — they're managed through `claway memory` and `claway plugins` respectively. The full per-plugin detail for the two long-running hooks-based plugins follows. ### disk-cleanup Auto-tracks and removes ephemeral files created during sessions — test scripts, temp outputs, cron logs, stale chrome profiles — without requiring the agent to remember to call a tool. **How it works:** | Hook | Behaviour | |---|---| | `post_tool_call` | When `write_file` / `terminal` / `patch` creates a file matching `test_*`, `tmp_*`, or `*.test.*` inside `CLAWAY_HOME` or `/tmp/claway-*`, track it silently as `test` / `temp` / `cron-output`. | | `on_session_end` | If any test files were auto-tracked during the turn, run the safe `quick` cleanup and log a one-line summary. Stays silent otherwise. | **Deletion rules:** | Category | Threshold | Confirmation | |---|---|---| | `test` | every session end | Never | | `temp` | >7 days since tracked | Never | | `cron-output` | >14 days since tracked | Never | | empty dirs under CLAWAY_HOME | always | Never | | `research` | >30 days, beyond 10 newest | Always (deep only) | | `chrome-profile` | >14 days since tracked | Always (deep only) | | files >500 MB | never auto | Always (deep only) | **Slash command** — `/disk-cleanup` available in both CLI and gateway sessions: ``` /disk-cleanup status # breakdown + top-10 largest /disk-cleanup dry-run # preview without deleting /disk-cleanup quick # run safe cleanup now /disk-cleanup deep # quick + list items needing confirmation /disk-cleanup track <path> <category> # manual tracking /disk-cleanup forget <path> # stop tracking (does not delete) ``` **State** — everything lives at `$CLAWAY_HOME/disk-cleanup/`: | File | Contents | |---|---| | `tracked.json` | Tracked paths with category, size, and timestamp | | `tracked.json.bak` | Atomic-write backup of the above | | `cleanup.log` | Append-only audit trail of every track / skip / reject / delete | **Safety** — cleanup only ever touches paths under `CLAWAY_HOME` or `/tmp/claway-*`. Windows mounts (`/mnt/c/...`) are rejected. Well-known top-level state dirs (`logs/`, `memories/`, `sessions/`, `cron/`, `cache/`, `skills/`, `plugins/`, `disk-cleanup/` itself) are never removed even when empty — a fresh install does not get gutted on first session end. **Enabling:** `claway plugins enable disk-cleanup` (or check the box in `claway plugins`). **Disabling again:** `claway plugins disable disk-cleanup`. ### security-guidance Fast pattern-matched security warnings on file writes. When the agent's `write_file` / `patch` / `skill_manage` calls carry content matching a known-dangerous code pattern — `pickle.load`, `yaml.load` without `SafeLoader`, `eval(`, `os.system`, `subprocess(..., shell=True)`, JS `child_process.exec`, React `dangerouslySetInnerHTML`, raw `.innerHTML =` / `.outerHTML =` / `document.write`, Node `crypto.createCipher`, AES ECB mode, TLS verification disabled, XXE-prone `xml.etree` / `minidom` parsers, `<script src="//..." >` without SRI, `torch.load` without `weights_only=True`, GitHub Actions `${{ github.event.* }}` injection — the plugin appends a `⚠️ Security guidance` block to the tool's result. The file is still written. The model reads the warning in the next turn's tool message and can either fix the code or document why the construct is safe in this context. Pattern matching has a non-trivial false-positive rate, which is why warn (not block) is the default. **Coverage:** 25 rules total, covering unsafe deserialization, command injection, XSS sinks, crypto footguns, XXE, supply-chain (SRI), and CI/CD workflow injection. The pattern data is a verbatim Apache-2.0 fork of [Anthropic's `claude-plugins-official`](https://github.com/anthropics/claude-plugins-official/tree/main/plugins/security-guidance/hooks) — see the plugin's `LICENSE` and `NOTICE` files for attribution. **Modes:** | Env var | Effect | |---|---| | (unset) | **warn mode** (default) — file is written, warning appended to result | | `SECURITY_GUIDANCE_BLOCK=1` | **block mode** — write refused, warning returned as the block reason | | `SECURITY_GUIDANCE_DISABLE=1` | kill switch — plugin loads but does nothing | **Enabling:** `claway plugins enable security-guidance` (or check the box in `claway plugins`). **Disabling again:** `claway plugins disable security-guidance`. **What it does not do (yet):** the upstream Anthropic plugin has two more layers — an LLM diff review on each agent turn that touched files, and an agentic commit-time review that traces data flow across files. Neither is ported. The agent can already run those reviews on demand via `delegate_task`. ### observability/langfuse Traces Claway turns, LLM calls, and tool invocations to [Langfuse](https://langfuse.com) — an open-source LLM observability platform. One span per turn, one generation per API call, one tool observation per tool call. Usage totals, per-type token counts, and cost estimates come out of Claway's canonical `agent.usage_pricing` numbers, so the Langfuse dashboard sees the same breakdown (input / output / `cache_read_input_tokens` / `cache_creation_input_tokens` / `reasoning_tokens`) that appears in `claway logs`. The plugin is fail-open: no SDK installed, no credentials, or a transient Langfuse error — all turn into a silent no-op in the hook. The agent loop is never impacted. **Setup (interactive — recommended):** ```bash claway tools # → Langfuse Observability → Cloud or Self-Hosted ``` The wizard collects your keys, `pip install`s the `langfuse` SDK, and adds `observability/langfuse` to `plugins.enabled` for you. Restart Claway and the next turn ships a trace. **Setup (manual):** ```bash pip install langfuse claway plugins enable observability/langfuse ``` Then put the credentials in `~/.claway/.env`: ```bash CLAWAY_LANGFUSE_PUBLIC_KEY=pk-lf-... CLAWAY_LANGFUSE_SECRET_KEY=sk-lf-... CLAWAY_LANGFUSE_BASE_URL=https://cloud.langfuse.com # or your self-hosted URL ``` **How it works:** | Hook | Behaviour | |---|---| | `pre_api_request` / `pre_llm_call` | Open (or reuse) a per-turn root span "Claway turn". Start a `generation` child observation for this API call with serialized recent messages as input. | | `post_api_request` / `post_llm_call` | Close the generation, attach `usage_details`, `cost_details`, `finish_reason`, assistant output + tool calls. If no tool calls and non-empty content, close the turn. | | `pre_tool_call` | Start a `tool` child observation with sanitized `args`. | | `post_tool_call` | Close the tool observation with sanitized `result`. `read_file` payloads get summarized (head + tail + omitted-line count) so a huge file read stays under `CLAWAY_LANGFUSE_MAX_CHARS`. | Session grouping keys off the Claway session ID (or task ID for sub-agents) via `langfuse.propagate_attributes`, so everything in a single `claway chat` session lives under one Langfuse session. **Verify:** ```bash claway plugins list # observability/langfuse should show "enabled" claway chat -q "hello" # check the Langfuse UI for a "Claway turn" trace ``` **Optional tuning** (in `.env`): | Variable | Default | Purpose | |---|---|---| | `CLAWAY_LANGFUSE_ENV` | — | Environment tag on traces (`production`, `staging`, …) | | `CLAWAY_LANGFUSE_RELEASE` | — | Release/version tag | | `CLAWAY_LANGFUSE_SAMPLE_RATE` | `1.0` | Sampling rate passed to the SDK (0.0–1.0) | | `CLAWAY_LANGFUSE_MAX_CHARS` | `12000` | Per-field truncation for message content / tool args / tool results | | `CLAWAY_LANGFUSE_DEBUG` | `false` | Verbose plugin logging to `agent.log` | Claway-prefixed and standard SDK env vars (`LANGFUSE_PUBLIC_KEY`, `LANGFUSE_SECRET_KEY`, `LANGFUSE_BASE_URL`) are both accepted — Claway-prefixed wins when both are set. **Performance:** the Langfuse client is cached after the first hook call. If credentials or SDK are missing, that decision is also cached — subsequent hooks fast-return without re-checking env vars or reloading config. **Disabling:** `claway plugins disable observability/langfuse`. The plugin module is still discovered, but no module code runs until you re-enable. ### google_meet Lets the agent **join, transcribe, and participate in Google Meet calls** — take notes on a meeting, summarize the back-and-forth after, follow up on specific points, and (optionally) speak replies back into the call via TTS. **What it adds:** - A headless virtual participant that joins a Meet URL using browser automation - Live transcription of the meeting audio via the configured STT provider - A `meet_summarize` / `meet_speak` / `meet_followup` toolset the agent invokes to act on what it heard - Post-meeting artifacts (transcript, speaker-attributed notes, action items) saved under `~/.claway/cache/google_meet/<meeting_id>/` **Setup:** ```bash claway plugins enable google_meet # Prompts you to sign in via the plugin's OAuth flow on first use — # needs a Google account with Meet access. Host approval may be required # if the meeting enforces "only invited participants can join". ``` Usage from chat: > "Join meet.google.com/abc-defg-hij and take notes. After the call, send me a summary with action items." The agent kicks off the meeting join, streams the transcription back into its context as the call proceeds, and produces a structured summary when the meeting ends (or when you tell it to stop). **When to use it:** recurring standups where you want a bot to transcribe + summarize for async attendees; deposition-style interviews where you want structured notes; any case where you'd otherwise need Fireflies / Otter / Grain. When you'd rather not have an AI listening in — don't enable it. **Disabling:** `claway plugins disable google_meet`. Any cached transcripts and recordings stay in `~/.claway/cache/google_meet/` until you remove them. ### claway-achievements Adds a **Steam-style achievements tab to the dashboard** — 60+ collectible, tiered badges generated from your real Claway session history. Tool-chain feats, debugging patterns, vibe-coding streaks, skill/memory usage, model/provider variety, lifestyle quirks (weekend and night sessions). Originally authored by [@PCinkusz](https://github.com/PCinkusz) as an external plugin; brought in-tree so it stays in lockstep with Claway feature changes. **How it works:** - Scans your entire `~/.claway/state.db` session history on the dashboard backend - Per-session stats are cached by `(started_at, last_active)` fingerprint, so only new or changed sessions re-analyze on subsequent scans - First-ever scan runs in a background thread — the dashboard never blocks waiting for it, even on databases with thousands of sessions - Unlock state is persisted to `$CLAWAY_HOME/plugins/claway-achievements/state.json` **Tier progression:** Copper → Silver → Gold → Diamond → Olympian. Each card exposes a "What counts" section listing the exact metric being tracked. **Achievement states:** | State | Meaning | |---|---| | Unlocked | At least one tier achieved | | Discovered | Known achievement, progress visible, not yet earned | | Secret | Hidden until Claway detects the first related signal in your history | **API** — routes mount under `/api/plugins/claway-achievements/`: | Endpoint | Purpose | |---|---| | `GET /achievements` | Full catalog with per-badge unlock state (returns a pending placeholder while the first cold scan is running) | | `GET /scan-status` | State of the background scanner: `idle` / `running` / `failed`, last duration, run count | | `GET /recent-unlocks` | Twenty most recently unlocked badges, newest first | | `GET /sessions/{id}/badges` | Badges earned primarily in one specific session | | `POST /rescan` | Manual synchronous rescan (blocks; use when the user clicks the rescan button) | | `POST /reset-state` | Clear unlock history and cached snapshot | **State files** — live under `$CLAWAY_HOME/plugins/claway-achievements/`: | File | Contents | |---|---| | `state.json` | Unlock history: which badges you've earned and when. Stable across Claway updates. | | `scan_snapshot.json` | Last completed scan payload (served immediately on dashboard load) | | `scan_checkpoint.json` | Per-session stats cache keyed by fingerprint (makes warm rescans fast) | **Performance notes:** - Cold scan on ~8,000 sessions takes a few minutes. It runs in a background thread on first dashboard request; the UI sees a pending placeholder and polls `/scan-status`. - **Incremental results during a cold scan** — the scanner publishes a partial snapshot every ~250 sessions so each dashboard refresh shows more badges unlocked as the scan progresses. No minute-long stare at zeros. - Warm rescan reuses per-session stats for every session whose `started_at` + `last_active` fingerprint matches the checkpoint — completes in seconds even on large histories. - The in-memory snapshot TTL is 120s; stale requests serve the old snapshot immediately and kick a background refresh. You never wait on a spinner just because TTL expired. **Enabling:** Nothing to enable — `claway-achievements` is a dashboard-only plugin (no lifecycle hooks, no model-visible tools). It auto-registers as a tab in `claway dashboard` on first launch. The `plugins.enabled` config only gates lifecycle/tool plugins; dashboard plugins are discovered purely via their `dashboard/manifest.json`. **Opting out:** Delete or rename `plugins/claway-achievements/dashboard/manifest.json`, or override it with a user plugin of the same name in `~/.claway/plugins/claway-achievements/` that ships no dashboard. The plugin's state files under `$CLAWAY_HOME/plugins/claway-achievements/` survive — reinstalling preserves your unlock history. ## Adding a bundled plugin Bundled plugins are written exactly like any other Claway plugin — see [Build a Claway Plugin](/guides/build-a-claway-plugin). The only differences are: - Directory lives at `<repo>/plugins/<name>/` instead of `~/.claway/plugins/<name>/` - Manifest source is reported as `bundled` in `claway plugins list` - User plugins with the same name override the bundled version A plugin is a good candidate for bundling when: - It has no optional dependencies (or they're already `pip install .[all]` deps) - The behaviour benefits most users and is opt-out rather than opt-in - The logic ties into lifecycle hooks that the agent would otherwise have to remember to invoke - It complements a core capability without expanding the model-visible tool surface Counter-examples — things that should stay as user-installable plugins, not bundled: third-party integrations with API keys, niche workflows, large dependency trees, anything that would meaningfully change agent behaviour by default. --- <!-- source: website/docs/user-guide/features/codex-app-server-runtime.md --> # user-guide/features/codex-app-server-runtime.md # Codex App-Server Runtime Claway can optionally hand `openai/*` and `openai-codex/*` turns to the [Codex CLI app-server](https://github.com/openai/codex) instead of running its own tool loop. When enabled, terminal commands, file edits, sandboxing, and MCP tool calls all execute inside Codex's runtime — Claway becomes the shell around it (sessions DB, slash commands, gateway, memory and skill review). This is **opt-in only**. Default Claway behavior is unchanged unless you flip the flag. Claway never auto-routes you onto this runtime. ## Why - Run OpenAI agent turns against your **ChatGPT subscription** (no API key required) using the same auth flow Codex CLI uses. - Use **Codex's own toolset and sandbox** — `shell` for terminal/read/write/search, `apply_patch` for structured edits, `update_plan` for planning, all running inside seatbelt/landlock sandboxing. - **Native Codex plugins** — Linear, GitHub, Gmail, Calendar, Canva, etc. — installed via `codex plugin` are auto-migrated and active in your Claway session. - **Claway's richer tools come along** — web_search, web_extract, browser automation, vision, image generation, skills, and TTS work via an MCP callback. Codex calls back into Claway for tools it doesn't have built in. - **Memory and skill nudges keep working** — Codex's events are projected into Claway's message shape so the self-improvement loop sees a normal-looking transcript. ## What tools the model actually has This is the part most users want to know up front. When this runtime is on, the model running your turn has three independent sources of tools: ### 1. Codex's built-in toolset (always on) These ship with `codex app-server` itself — no Claway involvement, no MCP, no plugins. All five are available the moment the runtime starts: - **`shell`** — runs arbitrary shell commands inside the sandbox. This is how the model reads files (`cat`, `head`, `tail`), writes them (`echo > foo`, heredocs), searches them (`find`, `rg`, `grep`), navigates directories (`ls`, `cd`), runs builds, manages processes, and anything else you'd do in bash. - **`apply_patch`** — applies a structured multi-file diff in Codex's patch format. The model uses this for non-trivial code edits (adding a function, refactoring across files); shell heredocs are still available for one-off writes. - **`update_plan`** — codex's internal todo / plan tracker. Equivalent of Claway's `todo` tool, but managed entirely inside codex's runtime. - **`view_image`** — load a local image file into the conversation so the model can see it. - **`web_search`** — codex has its own built-in web search when configured. Claway also exposes `web_search` (Firecrawl-backed) via the callback below; the model picks whichever it prefers. So **anything you'd do via terminal — read/write/search/find/run — codex does natively**. The sandbox profile (`:workspace` by default when you enable the runtime) controls what's writable. ### 2. Native Codex plugins (auto-migrated from your `codex plugin` install) When you enable the runtime, Claway queries codex's `plugin/list` RPC and writes a `[plugins."<name>@openai-curated"]` entry for every plugin you have installed. The plugins themselves are managed by codex and authorized once via codex's own UI. Examples (the ones the OpenClaw thread highlighted as "YouTube-video-worthy"): - **Linear** — find/update issues - **GitHub** — search code, view PRs, comment - **Gmail** — read/send mail - **Google Calendar** — create/find events - **Outlook calendar/email** — same shape via the Microsoft connector - **Canva** — design generation - ...whatever else you've installed via `codex plugin marketplace add openai-curated` + `codex plugin install ...` What's NOT migrated: - Plugins you haven't installed yet — install them in Codex first. - ChatGPT app marketplace entries (`app/list`) — these are already enabled inside codex by virtue of your account auth. ### 3. Claway tool callback (MCP server, registered in `~/.codex/config.toml`) Claway registers itself as an MCP server so codex can call back for tools codex doesn't ship with. Available via the callback: - **`web_search`** / **`web_extract`** — Firecrawl-backed; tends to be cleaner than scraping for structured content. - **`browser_navigate` / `browser_click` / `browser_type` / `browser_press` / `browser_snapshot` / `browser_scroll` / `browser_back` / `browser_get_images` / `browser_console` / `browser_vision`** — full browser automation via Camofox or Browserbase. - **`vision_analyze`** — call a separate vision model to inspect an image (different from codex's `view_image` which loads it into the conversation). - **`image_generate`** — image generation through Claway's image_gen plugin chain. - **`skill_view` / `skills_list`** — read from Claway's skill library. - **`text_to_speech`** — TTS through Claway's configured provider. When the model wants one of these, codex spawns the `claway_tools_mcp_server` subprocess via stdio MCP, the call is dispatched through `model_tools.handle_function_call()` (same code path as Claway's default runtime), and the result is returned to codex like any other MCP response. ### What's NOT available on this runtime These four Claway tools require the running AIAgent context (mid-loop state) to dispatch, and a stateless MCP callback can't drive them. Switch back to the default runtime (`/codex-runtime auto`) when you need any of them: - **`delegate_task`** — spawn subagents - **`memory`** — Claway's persistent memory store - **`session_search`** — cross-session search - **`todo`** — Claway's todo store (codex's `update_plan` is the in-runtime equivalent) ## Workflow features (`/goal`, kanban, cron) ### `/goal` (the Ralph loop) **Works on this runtime.** Goals persist in `state_meta` keyed by session id, the continuation prompt feeds back as a normal user message through `run_conversation()`, and codex executes the next turn natively. The goal judge runs via the auxiliary client (configured via `auxiliary.goal_judge` in config.yaml), independent of which runtime is active. The judge's "blocked, needs user input" verdict is a clean escape if codex stalls on approvals. **One thing to be aware of:** each continuation prompt is a fresh codex turn, which means codex re-evaluates command approval policy from scratch. If you're doing a long-running goal with lots of writes, expect more approval prompts than you'd see on a single in-session task. Set `default_permissions = ":workspace"` (which Claway does automatically when you enable the runtime) so simple workspace writes don't require prompting. ### Kanban (multi-agent worktree dispatch) **Works on this runtime, with one subtle dependency.** The kanban dispatcher spawns each worker as a separate `claway chat -q` subprocess that reads the user's config — which means if `model.openai_runtime: codex_app_server` is set globally, workers also come up on the codex runtime. What works inside a codex-runtime worker: - Codex's full toolset (shell, apply_patch, update_plan, view_image, web_search) — the worker does its actual task work natively - The migrated codex plugins — Linear, GitHub, etc. - The Claway tool callback for browser_*, vision, image_gen, skills, TTS What also works because the MCP callback exposes them: - **`kanban_complete` / `kanban_block` / `kanban_comment` / `kanban_heartbeat`** — the worker handoff tools. These read `CLAWAY_KANBAN_TASK` from env (set by the dispatcher), gate access correctly, and write to the per-board SQLite DB pinned by `CLAWAY_KANBAN_DB`. Without these in the callback, a worker on this runtime could do its task but couldn't report back, hanging until the dispatcher's timeout. - **`kanban_show` / `kanban_list`** — read-only board queries for the worker to check its own context. - **`kanban_create` / `kanban_unblock` / `kanban_link`** — orchestrator-only operations. Available for orchestrator agents running on the codex runtime that need to dispatch new tasks. The kanban tools are gated by `CLAWAY_KANBAN_TASK` env var the dispatcher sets — that var is propagated to the codex subprocess (codex inherits env) and from there to the spawned `claway-tools` MCP server subprocess. So the tools see the right task id and gate correctly. For Codex app-server workers, Claway also passes narrow app-server sandbox overrides when `CLAWAY_KANBAN_TASK` is present: keep `workspace-write` sandboxing, add the **board DB directory plus every Kanban path the dispatcher pinned** as extra writable roots (`CLAWAY_KANBAN_WORKSPACES_ROOT`, `CLAWAY_KANBAN_WORKSPACE`, legacy `CLAWAY_KANBAN_ROOT` — deduplicated, DB-dir first), and keep network disabled by default. This avoids the brittle `:danger-no-sandbox` workaround while letting `kanban_complete` / `kanban_block` update the board DB **and** letting workers write reports/artifacts under workspace mounts that live outside the DB directory (e.g. `/media/.../kanban-workspaces/...` on a separate drive — issue #27941). ### Cron jobs **Not specifically tested.** Cron jobs run via `cronjob` → `AIAgent.run_conversation`, the same code path as the CLI. If the cron job's config has `openai_runtime: codex_app_server` it'll run on codex. The same tool-availability rules apply — codex built-ins + plugins + MCP callback work, agent-loop tools (delegate_task, memory, session_search, todo) don't. If your cron job relies on those, scope the cron to a profile that uses the default runtime. ## Trade-offs | | Claway default runtime | Codex app-server (opt-in) | |---|---|---| | `delegate_task` subagents | yes | not available — needs agent loop context | | `memory`, `session_search`, `todo` | yes | not available — needs agent loop context | | `web_search`, `web_extract` | yes | yes (via MCP callback) | | Browser automation (Camofox/Browserbase) | yes | yes (via MCP callback) | | `vision_analyze`, `image_generate` | yes | yes (via MCP callback) | | `skill_view`, `skills_list` | yes | yes (via MCP callback) | | `text_to_speech` | yes | yes (via MCP callback) | | Codex `shell` (terminal/read/write/search/find/run) | — | yes (Codex built-in) | | Codex `apply_patch` (structured multi-file edits) | — | yes (Codex built-in) | | Codex `update_plan` (in-runtime todo) | — | yes (Codex built-in) | | Codex `view_image` (load image into conversation) | — | yes (Codex built-in) | | Codex sandbox (seatbelt/landlock, profiles) | — | yes (Codex built-in) | | ChatGPT subscription auth | — | yes (via `openai-codex` provider) | | Native Codex plugins (Linear, GitHub, etc.) | — | yes (auto-migrated) | | User MCP servers | yes | yes (auto-migrated to codex) | | Memory + skill review (background) | yes | yes (via item projection) | | Multi-turn conversations | yes | yes | | `/goal` (Ralph loop) | yes | yes | | Kanban worker dispatch | yes | yes (via callback) | | Kanban orchestrator tools | yes | yes (via callback) | | All gateway platforms | yes | yes | | Non-OpenAI providers | yes | n/a — OpenAI/Codex-scoped | ## Prerequisites 1. **Codex CLI installed:** ```bash npm i -g @openai/codex codex --version # 0.130.0 or newer ``` 2. **Codex OAuth login.** The codex subprocess reads `~/.codex/auth.json`. Two ways to populate it: ```bash codex login # writes tokens to ~/.codex/auth.json ``` Claway's own `claway auth login codex` writes to `~/.claway/auth.json` — that's a separate session. **Run `codex login` separately** if you haven't. 3. **(Optional) Install the Codex plugins you want.** When you enable the runtime, Claway auto-migrates whichever curated plugins you've already installed via Codex CLI: ```bash codex plugin marketplace add openai-curated # then via codex's TUI, install Linear / GitHub / Gmail / etc. ``` Claway will discover them and write `[plugins."<name>@openai-curated"]` entries to `~/.codex/config.toml` automatically. ## Enabling In a Claway session: ``` /codex-runtime codex_app_server ``` That command: - Verifies the `codex` CLI is installed (blocks with an install hint if not). - Persists `model.openai_runtime: codex_app_server` to your config.yaml. - Migrates user MCP servers from `~/.claway/config.yaml` to `~/.codex/config.toml`. - **Discovers and migrates installed native Codex plugins** (Linear, GitHub, Gmail, Calendar, Canva, etc.) by querying Codex's `plugin/list` RPC. - **Registers Claway's own tools as an MCP server** so the codex subprocess can call back for tools codex doesn't ship with. - **Writes `default_permissions = ":workspace"`** so the sandbox allows writes within the workspace without prompting for every operation. - Tells you what was migrated. Takes effect on the **next** session — the current cached agent keeps the prior runtime so prompt caches stay valid. Synonyms: `/codex-runtime on`, `/codex-runtime off`, `/codex-runtime auto`. To check current state without changing anything: ``` /codex-runtime ``` You can also set it manually in `~/.claway/config.yaml`: ```yaml model: openai_runtime: codex_app_server # default is "auto" (= Claway runtime) ``` ## Self-improvement loop (memory + skill nudges) Claway's background self-improvement fires on counter thresholds: - Every 10 user prompts → a forked review agent looks at the conversation and decides whether anything should be saved to memory. - Every 10 tool iterations within a single turn → same idea but for skills (`skill_manage` writes). **Both keep working on the codex runtime.** The codex path projects each completed `commandExecution` / `fileChange` / `mcpToolCall` / `dynamicToolCall` item into a synthetic `assistant tool_call` + `tool` result message, so by the time the review runs it sees the same shape it sees on the default Claway runtime. How the wiring stays equivalent: | | Default runtime | Codex runtime | |---|---|---| | `_turns_since_memory` increments | per user prompt, in run_conversation pre-loop | same code path, before the early-return | | `_iters_since_skill` increments | per tool iteration in the chat-completions loop | by `turn.tool_iterations` after the codex turn returns | | Memory trigger (`_turns_since_memory >= _memory_nudge_interval`) | computed in pre-loop, fires after response | computed in pre-loop, passed through to codex helper | | Skill trigger (`_iters_since_skill >= _skill_nudge_interval`) | computed after the loop | computed after the codex turn | | `_spawn_background_review(messages_snapshot=..., review_memory=..., review_skills=...)` | called when either trigger fires | called identically when either trigger fires | One detail: the review fork itself needs to call Claway's agent-loop tools (`memory`, `skill_manage`), which require Claway's own dispatch. So when the parent agent is on `codex_app_server`, the review fork is **downgraded to `codex_responses`** — same OAuth credentials, same `openai-codex` provider, but talks to OpenAI's Responses API directly so Claway owns the loop and the agent-loop tools work. This is invisible to the user. Net effect: enable the codex runtime and your memory + skill nudges keep firing exactly as they would otherwise. ## How approvals work Codex requests approval before executing commands or applying patches. These get translated into Claway's standard "Dangerous Command" prompt: ``` ╭───────────────────────────────────────╮ │ Dangerous Command │ │ │ │ /bin/bash -lc 'echo hello > foo.txt' │ │ │ │ ❯ 1. Allow once │ │ 2. Allow for this session │ │ 3. Deny │ │ │ │ Codex requests exec in /your/cwd │ ╰───────────────────────────────────────╯ ``` - **Allow once** → approve this single command. - **Allow for this session** → Codex won't re-prompt for similar commands. - **Deny** → command is rejected; Codex continues in read-only mode. For `apply_patch` (file edit) approvals, Claway shows a summary of what changed (`1 add, 1 update: /tmp/new.py, /tmp/old.py`) when codex provides the data via the corresponding `fileChange` item. ## Permission profiles Codex has three built-in permission profiles: - `:read-only` — no writes; every shell command requires approval - `:workspace` — writes within the current workspace allowed without prompts (Claway's default when you enable the runtime) - `:danger-no-sandbox` — no sandbox at all (don't use this unless you understand it) You can override the default in `~/.codex/config.toml` outside Claway's managed block: ```toml default_permissions = ":read-only" ``` (Claway will preserve your override on re-migration as long as it lives outside the `# managed by claway` markers.) ## Auxiliary tasks and ChatGPT subscription token cost When this runtime is on with the `openai-codex` provider, **auxiliary tasks (title generation, context compression, vision auto-detect, the background self-improvement review fork) also flow through your ChatGPT subscription by default**, because Claway's auxiliary client uses the main provider/model when no per-task override is set. This isn't specific to `codex_app_server` — it's true for the existing `codex_responses` path too — but it's more visible here because you're explicitly opting in for the subscription billing. To route specific aux tasks to a cheaper / different model, set explicit overrides in `~/.claway/config.yaml`: ```yaml auxiliary: title_generation: provider: openrouter model: google/gemini-3-flash-preview compression: provider: openrouter model: google/gemini-3-flash-preview vision: provider: openrouter model: google/gemini-3-flash-preview goal_judge: provider: openrouter model: google/gemini-3-flash-preview ``` The self-improvement review fork inherits the main runtime via `_current_main_runtime()` and Claway downgrades it from `codex_app_server` to `codex_responses` automatically (so the fork can actually call `memory` and `skill_manage` — Claway's own agent-loop tools). That fork still uses your subscription auth unless you've routed aux tasks elsewhere. ## Editing `~/.codex/config.toml` safely Claway wraps everything it manages between two marker comments: ```toml # managed by claway — `claway codex-runtime migrate` regenerates this section default_permissions = ":workspace" [mcp_servers.filesystem] ... [plugins."github@openai-curated"] ... # end claway managed section ``` Anything **outside** that block is yours. Re-running migration (via `/codex-runtime codex_app_server` or whenever you toggle the runtime on) replaces the managed block in place but preserves user content above and below it verbatim. This means you can: - Add your own MCP servers Claway doesn't know about - Override `default_permissions` to `:read-only` if you prefer to be prompted - Configure codex-only options (model, providers, otel, etc.) - Add user-defined permission profiles in `[permissions.<name>]` tables Anything you add **inside** the managed block will get clobbered on the next migration. If you need a tweak that requires editing the managed block, file an issue and we'll add the knob. ## Multi-profile / multi-tenant setups By default, Claway points the codex subprocess at `~/.codex/` regardless of which Claway profile is active. This means `claway -p work` and `claway -p personal` share the same Codex auth, plugins, and config. For most users this is the right behavior — it matches what running `codex` CLI directly would do. If you want per-profile Codex isolation (separate auth, separate installed plugins, separate config), set `CODEX_HOME` explicitly per profile. The cleanest way is to point at a directory under your `CLAWAY_HOME`: ```bash # Inside the work profile, you might wrap claway: CODEX_HOME=~/.claway/profiles/work/codex claway chat ``` You'll need to re-run `codex login` once with that `CODEX_HOME` set so the OAuth tokens land in the profile-scoped location. After that, `claway -p work` will operate on isolated Codex state. We don't auto-scope this because moving an existing user's `~/.codex/` would silently invalidate their Codex CLI auth — anyone who already ran `codex login` would have to re-authenticate. Opt-in feels safer than surprising users. ## HOME environment variable passthrough Claway does NOT rewrite `HOME` when spawning the codex app-server subprocess (we use `os.environ.copy()` and only overlay `CODEX_HOME` and `RUST_LOG`). This means: - Commands codex runs via its `shell` tool see the real user `HOME` and find `~/.gitconfig`, `~/.gh/`, `~/.aws/`, `~/.npmrc`, etc. correctly. - Codex's internal state stays isolated through `CODEX_HOME` (which points at `~/.codex/` by default). This matches the boundary OpenClaw arrived at after some early experimentation: isolate Codex's state, leave the user's home alone. (Cf. openclaw/openclaw#81562.) ## MCP server migration Claway's `mcp_servers` config is auto-translated to the TOML format Codex expects. The migration runs every time you enable the runtime and is idempotent — re-runs replace the managed section but preserve any user-edited Codex config. What translates: | Claway (`config.yaml`) | Codex (`config.toml`) | |---|---| | `command` + `args` + `env` | stdio transport | | `url` + `headers` | streamable_http transport | | `timeout` | `tool_timeout_sec` | | `connect_timeout` | `startup_timeout_sec` | | `enabled: false` | `enabled = false` | What's not migrated: - Claway-specific keys like `sampling` (Codex's MCP client has no equivalent — these are dropped with a per-server warning). ## Native Codex plugin migration Plugins installed via `codex plugin` (Linear, GitHub, Gmail, Calendar, Canva, etc.) are discovered through Codex's `plugin/list` RPC. For each plugin where `installed: true`, Claway writes a `[plugins."<name>@openai-curated"]` block enabling it in your Claway session. This means: when your friend says "I have Calendar and GitHub set up in my Codex CLI" and they enable Claway's codex runtime, Claway activates those automatically. No re-configuration needed. What's NOT migrated: - Plugins you haven't installed yet — install them in Codex first. - Plugins where codex reports `availability != AVAILABLE` (broken install, expired OAuth, removed from marketplace, etc.). These are skipped to avoid writing config that would fail at activation time. - ChatGPT app marketplace entries (the per-account `app/list` results — these are already enabled inside codex by virtue of your account auth). - Plugin OAuth — you authorize each plugin once in Codex itself; Claway doesn't touch credentials. ## Claway tool callback (the new MCP server) Codex's built-in toolset covers shell/file ops/patches but doesn't have web search, browser automation, vision, image generation, etc. To keep those usable in a codex turn, Claway registers itself as an MCP server in `~/.codex/config.toml`: ```toml [mcp_servers.claway-tools] command = "/path/to/python" args = ["-m", "agent.transports.claway_tools_mcp_server"] env = { CLAWAY_HOME = "/your/.claway", PYTHONPATH = "...", CLAWAY_QUIET = "1" } startup_timeout_sec = 30.0 tool_timeout_sec = 600.0 ``` When the model calls `web_search` (or another exposed Claway tool), codex spawns the `claway_tools_mcp_server` subprocess via stdio, the request is dispatched through `model_tools.handle_function_call()`, and the result is projected back to codex like any other MCP response. **Tools available via the callback:** `web_search`, `web_extract`, `browser_navigate`, `browser_click`, `browser_type`, `browser_press`, `browser_snapshot`, `browser_scroll`, `browser_back`, `browser_get_images`, `browser_console`, `browser_vision`, `vision_analyze`, `image_generate`, `skill_view`, `skills_list`, `text_to_speech`. **Tools NOT available:** `delegate_task`, `memory`, `session_search`, `todo`. These need the running AIAgent context to dispatch (mid-loop state) and a stateless MCP callback can't drive them. Use the default Claway runtime (`/codex-runtime auto`) when you need these. ## Disabling Switch back at any time: ``` /codex-runtime auto ``` Effective on the next session. The Codex managed block stays in `~/.codex/config.toml` so you can re-enable later without losing config — or remove it manually if you prefer. ## Limitations This runtime is **opt-in beta**. Working as of Claway Agent 2026.5 + Codex CLI 0.130.0: - Multi-turn conversations - `commandExecution` and `fileChange` (apply_patch) approvals via Claway UI - MCP tool calls (verified against `@modelcontextprotocol/server-filesystem` and the new `claway-tools` callback) - Native Codex plugin migration (verified against Linear / GitHub / Calendar inventory) - Deny/cancel paths - Toggle on/off cycle - Memory and skill nudge counters (verified live via integration tests) - Claway web_search through codex (verified live: "OpenAI Codex CLI – Getting Started" returned end-to-end) Known limitations: - **Claway auth and codex auth are separate sessions.** You need both `codex login` AND `claway auth login codex` for the cleanest UX (the runtime uses codex's session for the LLM call). This is a deliberate design choice in Claway's `_import_codex_cli_tokens` — Claway won't share OAuth state with codex CLI to avoid clobbering each other on token refresh. - **`delegate_task`, `memory`, `session_search`, `todo` are unavailable on this runtime.** They need the running AIAgent context which a stateless MCP callback can't provide. Use `/codex-runtime auto` when you need these. - **No inline patch preview in approval prompts when codex doesn't track the changeset.** Codex's `fileChange` approval params don't always carry the changeset. Claway caches the data from the corresponding `item/started` notification when possible, but if approval arrives before the item has streamed, the prompt falls back to whatever `reason` codex provides. - **Sub-second cancellation isn't guaranteed.** Mid-stream interrupts (Ctrl+C while codex is responding) are sent via `turn/interrupt`, but if codex has already flushed the final message, you get the response anyway. If you find a bug, email support@claway.io with the output of `claway logs --since 5m` and mention `codex-runtime` in the subject. ## Architecture ``` ┌─── Claway shell (CLI / TUI / gateway) ───┐ │ sessions DB · slash commands · memory │ │ & skill review · cron · session pickers │ └──┬──────────────────────────────────────┬┘ │ user_message final │ ▼ text + │ ┌──────────────────────────────────┐ projected │ │ AIAgent.run_conversation() │ messages │ │ if api_mode == codex_app_server │ │ │ → CodexAppServerSession │ │ │ else: chat_completions / codex_responses (default) └────┬─────────────────────────────┘ │ │ JSON-RPC over stdio │ ▼ │ ┌──────────────────────────────────┐ │ │ codex app-server (subprocess) │──────────────┘ │ thread/start, turn/start │ │ item/* notifications │ │ shell + apply_patch + update_plan│ │ view_image + sandbox │ │ ┌─────────────────────────┐ │ │ │ MCP client │ │ │ │ ├─ user MCP servers │ │ │ │ ├─ native plugins │ │ │ │ │ (linear, github, │ │ │ │ │ gmail, calendar, │ │ │ │ │ canva, ...) │ │ │ │ └─ claway-tools ───────┼─────────────────┐ │ │ (callback to │ │ │ │ │ Claway's richer │ │ │ │ │ tools) │ │ │ │ └─────────────────────────┘ │ │ └──────────────────────────────────┘ │ │ ▼ ┌──────────────────────────────────────────────────────────┐ │ claway_tools_mcp_server.py (subprocess on demand) │ │ web_search, web_extract, browser_*, vision_analyze, │ │ image_generate, skill_view, skills_list, text_to_speech│ └──────────────────────────────────────────────────────────┘ ``` For protocol details, see the [Codex app-server protocol README](https://github.com/openai/codex/blob/main/codex-rs/app-server/README.md). --- <!-- source: website/docs/user-guide/features/computer-use.md --> # user-guide/features/computer-use.md # Computer Use Claway Agent can drive your desktop — clicking, typing, scrolling, dragging — in the **background** on **macOS, Windows, and Linux**. Your cursor doesn't move, keyboard focus doesn't change, and your virtual desktops / Spaces don't switch on you. You and the agent co-work on the same machine. Unlike most computer-use integrations, this works with **any tool-capable model** — Claude, GPT, Gemini, or an open model on a local OpenAI-compatible endpoint. There's no Anthropic-native schema to worry about. ## How it works The `computer_use` toolset speaks MCP over stdio to [`cua-driver`](https://github.com/trycua/cua), an open-source background computer-use driver. Each platform uses the appropriate accessibility + input stack under the hood: | Platform | Accessibility tree | Input dispatch | |---|---|---| | macOS | AX (private SkyLight SPIs) | `SLPSPostEventRecordTo` — pid-scoped, no cursor warp | | Windows | UIAutomation | `SendInput` + `PostMessage` — no focus steal | | Linux | AT-SPI (X11 + Wayland) | XTest (X11) / virtual-keyboard (Wayland) | The result is the same on every platform: the agent can read the accessibility tree of any visible window AND post synthesized events without bringing it to front, switching virtual desktops, or moving the real OS cursor. For the underlying contract — *why* background mode matters, the no-foreground invariant, click-dispatch internals — see **[cua.ai/docs/explanation/the-no-foreground-contract](https://cua.ai/docs/explanation/the-no-foreground-contract)**. ## Enabling Pick whichever path is most convenient — both run the same upstream installer: **Option 1: dedicated CLI command (most direct).** ``` claway computer-use install ``` This fetches and runs the upstream cua-driver installer — `install.sh` on macOS/Linux, `install.ps1` on Windows. Use `claway computer-use status` to verify the install. **Option 2: enable the toolset interactively.** 1. Run `claway tools`, pick `🖱️ Computer Use (macOS/Windows/Linux)`. 2. The setup runs the upstream installer (same as Option 1). After installing, regardless of which path you took, grant the platform-appropriate prereqs: | Platform | Prereqs | |---|---| | **macOS** | System Settings → Privacy & Security → **Accessibility** + **Screen Recording** → allow your terminal (or Claway app). `claway computer-use doctor` will tell you which permission is missing. | | **Windows** | None at install time. If you're driving over SSH (not RDP / console), you need the autostart pattern — see [cua.ai/docs/how-to-guides/driver/windows-ssh](https://cua.ai/docs/how-to-guides/driver/windows-ssh) for the Session 0 ↔ Session 1+ proxy. | | **Linux** | A reachable display server: `DISPLAY` set for X11, or `XDG_SESSION_TYPE=wayland`. Wayland sessions need an XWayland bridge for capture. AT-SPI must be on (default on GNOME/KDE/Xfce). | Then start a session with the toolset enabled: ``` claway -t computer_use chat ``` or add `computer_use` to your enabled toolsets in `~/.claway/config.yaml`. ## `claway computer-use doctor` — your first triage stop `claway computer-use doctor` runs cua-driver's structured `health_report` MCP tool and prints a per-check matrix. It's the single fastest way to find out *why* an action isn't working. ``` $ claway computer-use doctor ⚠️ cua-driver 0.5.8 on darwin — degraded ✅ binary_version: cua-driver 0.5.8 ✅ platform_supported: macOS 26.4.1 (arm64) ✅ session_active: MCP session is active. ❌ bundle_identity: Process has no CFBundleIdentifier. → Run the binary inside CuaDriver.app so TCC grants attribute correctly. ✅ tcc_accessibility: Accessibility is granted. ✅ tcc_screen_recording: Screen Recording is granted. ✅ ax_capability: AX is trusted and reachable. ✅ screen_capture_capability: ScreenCaptureKit reachable; 1 display(s) shareable. ``` - **Exit code 0** when overall is `ok` — everything's wired up. - **Exit code 1** when `degraded` or `failed` — at least one check failed; the hint on each failure tells you what to fix. - **Exit code 2** when the cua-driver binary itself isn't reachable. Useful flags: - `--include CHECK` — run only the listed checks (repeat for multiple) - `--skip CHECK` — skip a check (wins over `--include`) - `--json` — emit the raw structured payload, same shape as the `tools/call health_report` MCP response The check matrix is platform-aware: `bundle_identity` / `tcc_*` are `skip` on Windows + Linux because those concepts don't apply. `ax_capability` checks AX on macOS, UIA on Windows, AT-SPI on Linux — each with the right diagnostic hint when it can't reach. ## The agent cursor and sessions When the agent acts, you'll see a **tinted overlay cursor** glide across the screen to where each click / type / scroll lands. The real OS cursor never moves — the overlay is a visual cue that says "the agent is acting here." Each Claway run declares its own cua-driver **session id** (something like `claway-3a7b9c14d2e8`); the cursor's identity is keyed to that session, so concurrent runs / subagents each get their own cursor without stepping on each other. Tune the cursor with `cua-driver`'s CLI flags or the runtime `set_agent_cursor_style` MCP tool — see [cua.ai/docs/how-to-guides/driver/personalize-cursor](https://cua.ai/docs/how-to-guides/driver/personalize-cursor) for the full menu (built-in `arrow` vs `teardrop` silhouette, custom SVG / PNG / ICO via `--cursor-icon`, runtime gradient colors, bloom halo). ## Going deeper — the cua-driver skill pack Claway intentionally keeps its skill (`skills/computer-use/SKILL.md`) focused on the Claway-side `computer_use` action vocabulary — the single source of truth the agent loads. For the deeper material — platform-specific deep dives, recording semantics, browser page interaction — point your agent harness at the cua-driver skill pack the cua-driver team ships and maintains directly: ``` cua-driver skills install ``` This symlinks the pack into your agent harness' skill directory. After running it, an agent gets access to: | File | Topic | |---|---| | `SKILL.md` | The cross-platform core (snapshot invariant, no-foreground contract, click dispatch, AX-tree mechanics) | | `MACOS.md` | macOS specifics: no-foreground contract, AXMenuBar navigation, SkyLight click dispatch, Apple Events JS bridge | | `WINDOWS.md` | Windows specifics: UIA tree, UWP / `ApplicationFrameHost` hosting, Session 0 isolation, autostart pattern | | `LINUX.md` | Linux specifics: AT-SPI tree, X11 / Wayland, terminal-emulator detection | | `RECORDING.md` | Trajectory + video recording semantics | | `WEB_APPS.md` | Browser-page interaction tips | | `TESTS.md` | Replay-by-trajectory workflow | These are **platform deep dives, not duplicates of the Claway skill** — when an agent reports "on Windows, my click landed on the wrong element," it reads `WINDOWS.md` for the UIA / UWP context that explains why and what to do differently. `cua-driver skills status` shows what's installed and which agent harnesses it's linked into. Today the autodetect list covers Claude Code, Codex, OpenCode, OpenClaw, and Antigravity; **Claway autodetection is planned as a follow-up in `trycua/cua`** — until then, run `cua-driver skills install` once and point your harness at the resulting `~/.cua-driver/skills/cua-driver` directory (or symlink it into your usual skill space). ## Quick example User prompt: *"Find my latest email from Stripe and summarise what they want me to do."* The agent's plan (this is the same shape on macOS / Windows / Linux — the model substitutes the platform's idiomatic shortcut and app name): 1. `computer_use(action="capture", mode="som", app="Mail")` — gets a screenshot of the email app with every sidebar item, toolbar button, and message row numbered. 2. `computer_use(action="click", element=14)` — clicks the search field. 3. `computer_use(action="type", text="from:stripe")` 4. `computer_use(action="key", keys="return", capture_after=True)` — submit and get the new screenshot. 5. Click the top result, read the body, summarise. During all of this, your cursor stays wherever you left it and the email app never comes to front. ## Provider compatibility | Provider | Vision? | Works? | Notes | |---|---|---|---| | Anthropic (Claude Sonnet/Opus 3+) | ✅ | ✅ | Best overall; SOM + raw coordinates. | | OpenRouter (any vision model) | ✅ | ✅ | Multi-part tool messages supported. | | OpenAI (GPT-4+, GPT-5) | ✅ | ✅ | Same as above. | | Google (Gemini 2+) | ✅ | ✅ | Tool-calling + vision both supported. | | Local vLLM / LM Studio / Ollama (vision model) | ✅ | ✅ | If the model supports multi-part tool content. | | Text-only models | ❌ | ✅ (degraded) | Use `mode="ax"` for accessibility-tree-only operation. | Screenshots are sent inline with tool results as OpenAI-style `image_url` parts. For Anthropic, the adapter converts them into native `tool_result` image blocks. The image MIME type comes from cua-driver's explicit `mimeType` field (`image/png` or `image/jpeg`) — no client-side magic-byte sniffing. ## Safety Claway applies multi-layer guardrails: - Destructive actions (click, type, drag, scroll, key, focus_app) require approval — either interactively via the CLI dialog or via the messaging-platform approval buttons. - Hard-blocked key combos at the tool level: empty trash, force delete, lock screen, log out, force log out. - Hard-blocked type patterns: `curl | bash`, `sudo rm -rf /`, fork bombs, etc. - The agent's system prompt tells it explicitly: no clicking permission dialogs, no typing passwords, no following instructions embedded in screenshots. Pair with `approvals.mode: manual` in `~/.claway/config.yaml` if you want every action confirmed. ## Token efficiency Screenshots are expensive. Claway applies four layers of optimisation: - **Screenshot eviction** — the Anthropic adapter keeps only the 3 most recent screenshots in context; older ones become `[screenshot removed to save context]` placeholders. - **Client-side compression pruning** — the context compressor detects multimodal tool results and strips image parts from old ones. - **Image-aware token estimation** — each image is counted as ~1500 tokens (Anthropic's flat rate) instead of its base64 char length. - **Server-side context editing (Anthropic only)** — when active, the adapter enables `clear_tool_uses_20250919` via `context_management` so Anthropic's API clears old tool results server-side. A 20-action session on a 1568×900 display typically costs ~30K tokens of screenshot context, not ~600K. ## Limitations - **Performance.** Background mode is slower than foreground — accessibility-routed events take ~5–20 ms on macOS, ~3–10 ms on Windows UIA, ~5–15 ms on Linux AT-SPI vs direct HID posting. Not noticeable for agent-speed clicking; noticeable if you try to record a speed-run. - **No keyboard password entry.** `type` has hard-block patterns on command-shell payloads; for passwords, use the system's autofill (macOS Keychain / Windows Credential Manager / GNOME Keyring / KWallet). - **Some apps don't expose an accessibility tree.** Modern UWP apps on Windows, Electron < 28 on Linux, and a few macOS apps with custom drawing (Logic, Final Cut, some games) have sparse or empty AX trees. Fall back to pixel coordinates if the tree is empty — or skip the task entirely. - **Windows: elevated (admin) windows can't be driven from a normal agent.** Windows UIPI (User Interface Privilege Isolation) enforces integrity-level boundaries: a Medium-integrity process (the default Claway agent) cannot enumerate the UIA tree of, or inject mouse input into, a window owned by a High-integrity (Administrator) process. Symptom: `capture(mode='som')` returns 0 elements and `click(...)` reports success while doing nothing, even though the screenshot renders fine (GDI capture sits below the integrity check). Keyboard events partially bypass UIPI, so Tab / Enter can still navigate an elevated dialog. This is an OS constraint, not a cua-driver bug — it affects every Windows automation stack. To drive elevated windows, run the Claway agent itself at High integrity (launch from an elevated terminal); otherwise target non-elevated windows. - **Platform-specific deployment gotchas:** - **macOS** uses private SkyLight SPIs. Apple can change them in any OS update. Claway warns when the installed cua-driver is older than the version it was tested against. - **Windows** SSH sessions run in **Session 0**, which has no interactive desktop. Drive Claway from inside the RDP / console session, or set up cua-driver's autostart Scheduled Task — [windows-ssh](https://cua.ai/docs/how-to-guides/driver/windows-ssh) has the recipe. - **Linux** requires a reachable display server. Headless servers need Xvfb (`Xvfb :99 -screen 0 1920x1080x24`) before `computer_use` can capture or inject events. Pure Wayland sessions need an XWayland bridge for screen capture (cua-driver's Wayland inject path handles input independently). For cross-platform GUI automation without the desktop overhead (and without TCC / Session 0 / X11 setup), the `browser` toolset uses a real headless Chromium and is the right answer for web-only tasks. ## Configuration Override the driver binary path (tests / CI / local builds): ``` CLAWAY_CUA_DRIVER_CMD=/path/to/your/cua-driver ``` Swap the backend entirely (for testing): ``` CLAWAY_COMPUTER_USE_BACKEND=noop # records calls, no side effects ``` ### Telemetry cua-driver ships with anonymous usage telemetry (PostHog) enabled by default upstream. **Claway disables it for you** — on every cua-driver invocation (the MCP backend, `status`, `doctor`, and install) Claway sets `CUA_DRIVER_RS_TELEMETRY_ENABLED=0` in the driver's environment. To opt back in (let cua-driver use its own default and send telemetry), set this in `config.yaml`: ```yaml computer_use: cua_telemetry: true # default: false (telemetry off) ``` When it's on, `claway computer-use doctor` reports `telemetry: enabled`; when off (the default), it reports `telemetry: disabled via CUA_DRIVER_RS_TELEMETRY_ENABLED`. ## Testing against a local cua-driver build When you're developing cua-driver itself — or want to test an unreleased fix — point Claway at a binary you built from source instead of the published release. Claway resolves the driver with `shutil.which("cua-driver")` and **does not enforce `CLAWAY_CUA_DRIVER_VERSION`**, so a local build (reported as `0.0.0-local-*`) is accepted as-is. Two approaches: ### Option A — `install-local` (build + put it on PATH) From your `trycua/cua` checkout, run the upstream local installer. It builds the Rust backend in release mode and drops `cua-driver` into the same install layout the production installer uses, adding its bin dir to your PATH: ```powershell # Windows (PowerShell), from the cua repo root ./libs/cua-driver/scripts/install-local.ps1 -NoAutoStart ``` ```bash # macOS / Linux, from the cua repo root (defaults to a debug build without --release) ./libs/cua-driver/scripts/install-local.sh --release ``` - Windows stages the build under `%USERPROFILE%\.cua-driver\packages\…` and junctions `%LOCALAPPDATA%\Programs\Cua\cua-driver\bin` (added to your User PATH) to it. macOS/Linux symlinks `cua-driver` into `~/.local/bin` (override with `--bin-dir <path>`). - `-NoAutoStart` skips registering the `cua-driver-serve` logon daemon — you don't need it for Claway testing (see notes). Then open a fresh shell (so the PATH change is visible) and confirm: ``` cua-driver --version # local builds report 0.0.0-local-release # Windows: (Get-Command cua-driver).Source # macOS/Linux: which cua-driver ``` ### Option B — point Claway straight at the built binary (fastest loop) Skip the install ceremony entirely: `cargo build` and set `CLAWAY_CUA_DRIVER_CMD` to the resulting binary. Best for rapid edit/build/test. ```bash cargo build -p cua-driver # add --release for a release build; run from libs/cua-driver/rust ``` ``` # Windows (.env) CLAWAY_CUA_DRIVER_CMD=C:\path\to\cua\libs\cua-driver\rust\target\debug\cua-driver.exe # macOS / Linux (.env) CLAWAY_CUA_DRIVER_CMD=/path/to/cua/libs/cua-driver/rust/target/debug/cua-driver ``` ### Confirm Claway is using your build - `claway computer-use status` prints the resolved binary path and version. - `claway computer-use doctor` confirms the binary is reachable and exercises the full MCP path end-to-end. - In a session, `computer_use(action="capture")` exercises the spawned `cua-driver mcp` child process. ### Notes & gotchas - **Claway spawns its own `cua-driver mcp` child over stdio** — it does *not* attach to the long-running `cua-driver serve` autostart daemon or its named pipe. So the scheduled task / LaunchAgent is unnecessary for testing (`-NoAutoStart` is fine). The autostart daemon and the Windows UIAccess worker (`cua-driver-uia.exe`) only matter for foreground-safe input on some apps (e.g. WPF); the standard tool surface works through the stdio child. On Windows SSH sessions, the autostart pattern IS needed — see the Limitations section. - **Locked binary on Windows.** A running `cua-driver-serve` daemon can hold `cua-driver.exe` and block an overwrite on rebuild. `install-local.ps1` renames the locked binary out of the way automatically; if you `cargo build` manually (Option B), stop it first with `cua-driver autostart disable` (or `schtasks /End /TN cua-driver-serve`). - **Rebuild loop.** After editing cua-driver source, re-run `install-local` (rebuilds, restages, flips the `current` junction) for Option A, or just re-`cargo build` for Option B — no Claway change needed either way. - **Local builds skip the version check.** Claway warns when the installed cua-driver is older than its per-OS tested baseline, but exempts `0.0.0-local-*` dev builds — so your local build never triggers that warning. ## Troubleshooting **First action when anything's off: run `claway computer-use doctor`.** The structured per-check matrix tells you (and any agent helping you debug) exactly what's wrong. Specific failure modes the doctor doesn't catch: **`computer_use backend unavailable: cua-driver is not installed`** — Run `claway computer-use install` to fetch the cua-driver binary, or run `claway tools` and enable the Computer Use toolset. **Clicks seem to have no effect** — Capture and verify. A modal you didn't see may be blocking input. Dismiss it with `escape` or the close button. **Element indices are stale** — SOM indices are only valid until the next `capture`. Re-capture after any state-changing action. The wrapper carries opaque `element_token`s for stale detection — you'll see an explicit error rather than a wrong click. **"blocked pattern in type text"** — The text you tried to `type` matches the dangerous-shell-pattern list. Break the command up or reconsider. **Empty captures on Linux** — `DISPLAY` not set, or you're on pure Wayland without an XWayland bridge. `claway computer-use doctor` will flag this as `ax_capability: fail` with a `Set DISPLAY (X11)…` hint. **Empty captures on Windows over SSH** — You're in Session 0 (the services session). Drive from RDP / console directly, or set up the autostart pattern — see [cua.ai/docs/how-to-guides/driver/windows-ssh](https://cua.ai/docs/how-to-guides/driver/windows-ssh). ## See also - **Claway-side skill** — `skills/computer-use/SKILL.md` — teaches the Claway `computer_use` action vocabulary; this is what the agent loads. - **cua-driver skill pack** — for platform-specific deep dives (macOS no-foreground contract, Windows UIA + Session 0, Linux AT-SPI + X11/Wayland, recording, browser pages), run `cua-driver skills install` and read `MACOS.md` / `WINDOWS.md` / `LINUX.md` / `RECORDING.md` / `WEB_APPS.md`. Once `cua-driver skills install` autodetects Claway (planned follow-up), this happens automatically on install. - **cua.ai/docs** — the cua-driver project's documentation: - [What is computer use?](https://cua.ai/docs/explanation/what-is-computer-use) — concept intro - [The no-foreground contract](https://cua.ai/docs/explanation/the-no-foreground-contract) — *why* background mode matters - [Install reference](https://cua.ai/docs/how-to-guides/driver/install) — cross-platform install details - [Personalize the agent cursor](https://cua.ai/docs/how-to-guides/driver/personalize-cursor) — built-in shapes, custom assets, runtime overrides - [Drive Windows over SSH](https://cua.ai/docs/how-to-guides/driver/windows-ssh) — the Session 0 → Session 1+ autostart pattern - [Keep cua-driver running](https://cua.ai/docs/how-to-guides/driver/keep-running) — autostart / daemon lifecycle - [Connect your agent](https://cua.ai/docs/how-to-guides/driver/connect-your-agent) — register cua-driver with various harnesses (Claway among them) - [cua-driver source (trycua/cua)](https://github.com/trycua/cua) - [Browser automation](./browser.md) for cross-platform web tasks where you don't need to drive native apps. --- <!-- source: website/docs/user-guide/features/context-references.md --> # Context References # Context References Type `@` followed by a reference to inject content directly into your message. Claway expands the reference inline and appends the content under an `--- Attached Context ---` section. ## Supported References | Syntax | Description | |--------|-------------| | `@file:path/to/file.py` | Inject file contents | | `@file:path/to/file.py:10-25` | Inject specific line range (1-indexed, inclusive) | | `@folder:path/to/dir` | Inject directory tree listing with file metadata | | `@diff` | Inject `git diff` (unstaged working tree changes) | | `@staged` | Inject `git diff --staged` (staged changes) | | `@git:5` | Inject last N commits with patches (max 10) | | `@url:https://example.com` | Fetch and inject web page content | ## Usage Examples ```text Review @file:src/main.py and suggest improvements What changed? @diff Compare @file:old_config.yaml and @file:new_config.yaml What's in @folder:src/components? Summarize this article @url:https://arxiv.org/abs/2301.00001 ``` Multiple references work in a single message: ```text Check @file:main.py, and also @file:test.py. ``` Trailing punctuation (`,`, `.`, `;`, `!`, `?`) is automatically stripped from reference values. ## CLI Tab Completion In the interactive CLI, typing `@` triggers autocomplete: - `@` shows all reference types (`@diff`, `@staged`, `@file:`, `@folder:`, `@git:`, `@url:`) - `@file:` and `@folder:` trigger filesystem path completion with file size metadata - Bare `@` followed by partial text shows matching files and folders from the current directory ## Line Ranges The `@file:` reference supports line ranges for precise content injection: ```text @file:src/main.py:42 # Single line 42 @file:src/main.py:10-25 # Lines 10 through 25 (inclusive) ``` Lines are 1-indexed. Invalid ranges are silently ignored (full file is returned). ## Size Limits Context references are bounded to prevent overwhelming the model's context window: | Threshold | Value | Behavior | |-----------|-------|----------| | Soft limit | 25% of context length | Warning appended, expansion proceeds | | Hard limit | 50% of context length | Expansion refused, original message returned unchanged | | Folder entries | 200 files max | Excess entries replaced with `- ...` | | Git commits | 10 max | `@git:N` clamped to range [1, 10] | ## Security ### Sensitive Path Blocking These paths are always blocked from `@file:` references to prevent credential exposure: - SSH keys and config: `~/.ssh/id_rsa`, `~/.ssh/id_ed25519`, `~/.ssh/authorized_keys`, `~/.ssh/config` - Shell profiles: `~/.bashrc`, `~/.zshrc`, `~/.profile`, `~/.bash_profile`, `~/.zprofile` - Credential files: `~/.netrc`, `~/.pgpass`, `~/.npmrc`, `~/.pypirc` - Claway env: `$CLAWAY_HOME/.env` These directories are fully blocked (any file inside): - `~/.ssh/`, `~/.aws/`, `~/.gnupg/`, `~/.kube/`, `$CLAWAY_HOME/skills/.hub/` ### Path Traversal Protection All paths are resolved relative to the working directory. References that resolve outside the allowed workspace root are rejected. ### Binary File Detection Binary files are detected via MIME type and null-byte scanning. Known text extensions (`.py`, `.md`, `.json`, `.yaml`, `.toml`, `.js`, `.ts`, etc.) bypass MIME-based detection. Binary files are rejected with a warning. ## Platform Availability Context references are primarily a **CLI feature**. They work in the interactive CLI where `@` triggers tab completion and references are expanded before the message is sent to the agent. In **messaging platforms** (Telegram, Discord, etc.), the `@` syntax is not expanded by the gateway — messages are passed through as-is. The agent itself can still reference files via the `read_file`, `search_files`, and `web_extract` tools. ## Interaction with Context Compression When conversation context is compressed, the expanded reference content is included in the compression summary. This means: - Large file contents injected via `@file:` contribute to context usage - If the conversation is later compressed, the file content is summarized (not preserved verbatim) - For very large files, consider using line ranges (`@file:main.py:100-200`) to inject only relevant sections ## Common Patterns ```text # Code review workflow Review @diff and check for security issues # Debug with context This test is failing. Here's the test @file:tests/test_auth.py and the implementation @file:src/auth.py:50-80 # Project exploration What does this project do? @folder:src @file:README.md # Research Compare the approaches in @url:https://arxiv.org/abs/2301.00001 and @url:https://arxiv.org/abs/2301.00002 ``` ## Error Handling Invalid references produce inline warnings rather than failures: | Condition | Behavior | |-----------|----------| | File not found | Warning: "file not found" | | Binary file | Warning: "binary files are not supported" | | Folder not found | Warning: "folder not found" | | Git command fails | Warning with git stderr | | URL returns no content | Warning: "no content extracted" | | Sensitive path | Warning: "path is a sensitive credential file" | | Path outside workspace | Warning: "path is outside the allowed workspace" | --- <!-- source: website/docs/user-guide/features/credential-pools.md --> # user-guide/features/credential-pools.md # Credential Pools Credential pools let you register multiple API keys or OAuth tokens for the same provider. When one key hits a rate limit or billing quota, Claway automatically rotates to the next healthy key — keeping your session alive without switching providers. This is different from [fallback providers](./fallback-providers.md), which switch to a *different* provider entirely. Credential pools are same-provider rotation; fallback providers are cross-provider failover. Pools are tried first — if all pool keys are exhausted, *then* the fallback provider activates. ## How It Works ``` Your request → Pick key from pool (round_robin / least_used / fill_first / random) → Send to provider → 429 rate limit? → Plan/usage limit reached (e.g. ChatGPT/Codex "usage limit reached")? → Rotate to next pool key immediately (no retry — the cap won't clear on retry) → Generic / transient 429? → Retry same key once (transient blip) → Second 429 → rotate to next pool key → All keys exhausted → fallback_model (different provider) → 402 billing error? → Immediately rotate to next pool key (24h cooldown) → 401 auth expired? → Try refreshing the token (OAuth) → Refresh failed → rotate to next pool key → Success → continue normally ``` ## Quick Start If you already have an API key set in `.env`, Claway auto-discovers it as a 1-key pool. To benefit from pooling, add more keys: ```bash # Add a second OpenRouter key claway auth add openrouter --api-key sk-or-v1-your-second-key # Add a second Anthropic key claway auth add anthropic --type api-key --api-key sk-ant-api03-your-second-key # Add an Anthropic OAuth credential (requires Claude Max plan + extra usage credits) claway auth add anthropic --type oauth # Opens browser for OAuth login ``` Check your pools: ```bash claway auth list ``` Output: ``` openrouter (2 credentials): #1 OPENROUTER_API_KEY api_key env:OPENROUTER_API_KEY ← #2 backup-key api_key manual anthropic (3 credentials): #1 claway_pkce oauth claway_pkce ← #2 claude_code oauth claude_code #3 ANTHROPIC_API_KEY api_key env:ANTHROPIC_API_KEY ``` The `←` marks the currently selected credential. ## Interactive Management Run `claway auth` with no subcommand for an interactive wizard: ```bash claway auth ``` This shows your full pool status and offers a menu: ``` What would you like to do? 1. Add a credential 2. Remove a credential 3. Reset cooldowns for a provider 4. Set rotation strategy for a provider 5. Exit ``` For providers that support both API keys and OAuth (Anthropic, Codex), the add flow asks which type: ``` anthropic supports both API keys and OAuth login. 1. API key (paste a key from the provider dashboard) 2. OAuth login (authenticate via browser) Type [1/2]: ``` ## CLI Commands | Command | Description | |---------|-------------| | `claway auth` | Interactive pool management wizard | | `claway auth list` | Show all pools and credentials | | `claway auth list <provider>` | Show a specific provider's pool | | `claway auth add <provider>` | Add a credential (prompts for type and key) | | `claway auth add <provider> --type api-key --api-key <key>` | Add an API key non-interactively | | `claway auth add <provider> --type oauth` | Add an OAuth credential via browser login | | `claway auth remove <provider> <index>` | Remove credential by 1-based index | | `claway auth reset <provider>` | Clear all cooldowns/exhaustion status | ## Rotation Strategies Configure via `claway auth` → "Set rotation strategy" or in `config.yaml`: ```yaml credential_pool_strategies: openrouter: round_robin anthropic: least_used ``` | Strategy | Behavior | |----------|----------| | `fill_first` (default) | Use the first healthy key until it's exhausted, then move to the next | | `round_robin` | Cycle through keys evenly, rotating after each selection | | `least_used` | Always pick the key with the lowest request count | | `random` | Random selection among healthy keys | ## Error Recovery The pool handles different errors differently: | Error | Behavior | Cooldown | |-------|----------|----------| | **429 Rate Limit** | Retry same key once (transient). Second consecutive 429 rotates to next key | 1 hour | | **402 Billing/Quota** | Immediately rotate to next key | 24 hours | | **401 Auth Expired** | Try refreshing the OAuth token first. Rotate only if refresh fails | — | | **All keys exhausted** | Fall through to `fallback_model` if configured | — | The `has_retried_429` flag resets on every successful API call, so a single transient 429 doesn't trigger rotation. ## Custom Endpoint Pools Custom OpenAI-compatible endpoints (Together.ai, RunPod, local servers) get their own pools, keyed by the endpoint name from `custom_providers` in config.yaml. When you set up a custom endpoint via `claway model`, it auto-generates a name like "Together.ai" or "Local (localhost:8080)". This name becomes the pool key. ```bash # After setting up a custom endpoint via claway model: claway auth list # Shows: # Together.ai (1 credential): # #1 config key api_key config:Together.ai ← # Add a second key for the same endpoint: claway auth add Together.ai --api-key sk-together-second-key ``` Custom endpoint pools are stored in `auth.json` under `credential_pool` with a `custom:` prefix: ```json { "credential_pool": { "openrouter": [...], "custom:together.ai": [...] } } ``` ## Auto-Discovery Claway automatically discovers credentials from multiple sources and seeds the pool on startup: | Source | Example | Auto-seeded? | |--------|---------|-------------| | Environment variables | `OPENROUTER_API_KEY`, `ANTHROPIC_API_KEY` | Yes | | OAuth tokens (auth.json) | Codex device code | Yes | | Claude Code credentials | `~/.claude/.credentials.json` | Yes (Anthropic) | | Claway PKCE OAuth | `~/.claway/auth.json` | Yes (Anthropic) | | Custom endpoint config | `model.api_key` in config.yaml | Yes (custom endpoints) | | Manual entries | Added via `claway auth add` | Persisted in auth.json | Auto-seeded entries are updated on each pool load — if you remove an env var, its pool entry is automatically pruned. Manual entries (added via `claway auth add`) are never auto-pruned. Borrowed runtime secrets (for example env vars, Bitwarden/Vault/keyring/systemd references, and custom config values) are reference-only at the `auth.json` boundary. Claway can use the resolved value in memory for the current run, but it persists only metadata such as the source ref, label, status, request counters, and a non-reversible fingerprint. Manual entries and Claway-owned OAuth/device-code state keep the durable tokens they need to refresh. ## Delegation & Subagent Sharing When the agent spawns subagents via `delegate_task`, the parent's credential pool is automatically shared with children: - **Same provider** — the child receives the parent's full pool, enabling key rotation on rate limits - **Different provider** — the child loads that provider's own pool (if configured) - **No pool configured** — the child falls back to the inherited single API key This means subagents benefit from the same rate-limit resilience as the parent, with no extra configuration needed. Per-task credential leasing ensures children don't conflict with each other when rotating keys concurrently. ## Thread Safety The credential pool uses a threading lock for all state mutations (`select()`, `mark_exhausted_and_rotate()`, `try_refresh_current()`, `mark_used()`). This ensures safe concurrent access when the gateway handles multiple chat sessions simultaneously. ## Architecture For the full data flow diagram, see [`docs/credential-pool-flow.excalidraw`](https://excalidraw.com/#json=2Ycqhqpi6f12E_3ITyiwh,c7u9jSt5BwrmiVzHGbm87g) in the repository. The credential pool integrates at the provider resolution layer: 1. **`agent/credential_pool.py`** — Pool manager: storage, selection, rotation, cooldowns 2. **`claway_cli/auth_commands.py`** — CLI commands and interactive wizard 3. **`claway_cli/runtime_provider.py`** — Pool-aware credential resolution 4. **`run_agent.py`** — Error recovery: 429/402/401 → pool rotation → fallback ## Storage Pool state is stored in `~/.claway/auth.json` under the `credential_pool` key: ```json { "version": 1, "credential_pool": { "openrouter": [ { "id": "abc123", "label": "OPENROUTER_API_KEY", "auth_type": "api_key", "priority": 0, "source": "env:OPENROUTER_API_KEY", "secret_source": "bitwarden", "secret_fingerprint": "sha256:12ab34cd56ef7890", "last_status": "ok", "request_count": 142 } ], "anthropic": [ { "id": "manual1", "label": "personal-api-key", "auth_type": "api_key", "priority": 0, "source": "manual", "access_token": "sk-ant-api03-..." } ] } } ``` The OpenRouter entry above was borrowed from an external source, so the raw key is not stored in `auth.json`. The manual Anthropic entry was intentionally added to Claway's credential store, so its token remains persistable. Strategies are stored in `config.yaml` (not `auth.json`): ```yaml credential_pool_strategies: openrouter: round_robin anthropic: least_used ``` --- <!-- source: website/docs/user-guide/features/deliverable-mode.md --> # user-guide/features/deliverable-mode.md # Deliverable Mode When Claway Agent runs inside a messaging gateway (Slack, Discord, Telegram, WhatsApp, Signal, etc.), it can deliver generated files directly into the chat — not as paths the user has to copy, but as native attachments. A chart shows up as an inline image. A PDF report shows up as a file download. A spreadsheet uploads as `.xlsx`. The agent does not need to write a `MEDIA:` tag or do anything special — it just generates the file and mentions its absolute path in the response. The gateway picks the path out of the text, removes it from the visible message, and uploads the file natively. ## How it works Three pieces fit together: 1. **The agent has tools that produce files.** `execute_code` for charts via matplotlib, the `latex-pdf-report` skill for PDFs, the `powerpoint` skill for decks, `image_generate` for images, `text_to_speech` for audio, and so on. 2. **The gateway scans agent responses for file paths.** Any absolute path (`/tmp/...`) or home-relative path (`~/...`) ending in a supported extension gets extracted. Paths inside code blocks and inline code are ignored so code samples are never mutilated. 3. **The gateway dispatches by file type.** Images embed inline where the platform supports it; videos embed inline; audio routes to voice/audio attachments; everything else uploads as a file attachment. ## Supported file extensions | Category | Extensions | Delivery | |---|---|---| | Images | `.png .jpg .jpeg .gif .webp .bmp .tiff .svg` | Inline embed | | Video | `.mp4 .mov .avi .mkv .webm` | Inline embed (where supported) | | Audio | `.mp3 .wav .ogg .m4a .flac` | Voice / audio attachment | | Documents | `.pdf .docx .doc .odt .rtf .txt .md` | File upload | | Data | `.xlsx .xls .csv .tsv .json .xml .yaml .yml` | File upload | | Presentations | `.pptx .ppt .odp` | File upload | | Archives | `.zip .tar .gz .tgz .bz2 .7z` | File upload | | Web | `.html .htm` | File upload | `.py`, `.log`, and other source-file extensions are intentionally excluded so the agent doesn't auto-ship arbitrary source files; if you want to send code to the user, use a code block. ## Encouraging the agent to produce artifacts The agent doesn't reach for artifacts by default — it has to know to. Two ways to nudge it: **Per-session:** ask explicitly ("send me the comparison as a chart", "return the data as a CSV") or write your own custom-instructions / personality entry that biases toward artifact-style replies on messaging platforms. **Project-level:** add the bias to `AGENTS.md` / `CLAUDE.md` / `.cursorrules` in a project the agent works from, to your global persona in `~/.claway/SOUL.md`, or as a named preset under `agent.personalities` in `~/.claway/config.yaml` (switchable per session via `/personality`). The mechanic the agent has to use is simple: render the file to an absolute path (e.g. `/tmp/q3-revenue.png`) and mention that path as plain text in the reply. The gateway does the rest. Paths inside fenced code blocks or backticks are ignored so code samples are never mutilated. ## Kanban: artifacts ride completion notifications If you use Claway's kanban multi-agent workflow, workers can attach deliverable files to their `kanban_complete` call: ```python kanban_complete( summary="rendered Q3 revenue chart and report", artifacts=[ "/tmp/q3-revenue.png", "/tmp/q3-report.pdf", ], ) ``` When the gateway notifier delivers the "task completed" message to whoever subscribed to the task in Slack/Telegram/etc., it also uploads each artifact as a native attachment to that chat. The human gets the deliverable and the summary in one place. Files that don't exist on disk when the notifier runs are silently skipped. ## Connecting more services with MCP Beyond the artifact-delivery pipeline, the agent can reach into other services via MCP (Model Context Protocol). The MCP ecosystem ships community servers for most popular tools — install whichever you need: | Service | What it unlocks | |---|---| | **Notion** | Read/write Notion pages, databases, query workspace | | **GitHub** | Issues, PRs, comments, repo search beyond the gh CLI | | **Linear** | Tickets, projects, cycles | | **Slack** | Workspace-wide search, read other channels | | **Gmail** | Inbox triage, send mail, label management | | **Salesforce** | Leads, opportunities, account data | | **Snowflake / BigQuery** | SQL against data warehouses | | **Google Drive** | File search, contents, share management | Install MCP servers via `~/.claway/config.yaml` under the `mcp_servers` section. See [MCP integration](./mcp.md) for the full setup guide. ## Comparison to Perplexity Computer in Slack Perplexity Computer's Slack integration is built around the same idea: the agent generates a deliverable (chart, PDF, slide deck) and posts it back into the thread as a native attachment. Claway Agent's deliverable mode provides the same user-facing pattern locally: - Generation happens in the user's own venv / sandbox (no remote tenant). - Files land in the chat via the same Slack `files.uploadV2` API. - Connector breadth comes via MCP rather than a curated catalog of 400 hosted integrations — install the ones you actually use. OAuth tokens stay on the user's machine in `auth.json` / `.env`. No hosted token storage. No multi-tenant microVM. Same end result. --- <!-- source: website/docs/user-guide/features/honcho.md --> # Honcho Memory # Honcho Memory [Honcho](https://github.com/plastic-labs/honcho) is an AI-native memory backend that adds dialectic reasoning and deep user modeling on top of Claway's built-in memory system. Instead of simple key-value storage, Honcho maintains a running model of who the user is — their preferences, communication style, goals, and patterns — by reasoning about conversations after they happen. :::info Honcho is a Memory Provider Plugin Honcho is integrated into the [Memory Providers](./memory-providers.md) system. All features below are available through the unified memory provider interface. ::: ## What Honcho Adds | Capability | Built-in Memory | Honcho | |-----------|----------------|--------| | Cross-session persistence | ✔ File-based MEMORY.md/USER.md | ✔ Server-side with API | | User profile | ✔ Manual agent curation | ✔ Automatic dialectic reasoning | | Session summary | — | ✔ Session-scoped context injection | | Multi-agent isolation | — | ✔ Per-peer profile separation | | Observation modes | — | ✔ Unified or directional observation | | Conclusions (derived insights) | — | ✔ Server-side reasoning about patterns | | Search across history | ✔ FTS5 session search | ✔ Semantic search over conclusions | **Dialectic reasoning**: After each conversation turn (gated by `dialecticCadence`), Honcho analyzes the exchange and derives insights about the user's preferences, habits, and goals. These accumulate over time, giving the agent a deepening understanding that goes beyond what the user explicitly stated. The dialectic supports multi-pass depth (1–3 passes) with automatic cold/warm prompt selection — cold start queries focus on general user facts while warm queries prioritize session-scoped context. **Session-scoped context**: Base context now includes the session summary alongside the user representation and peer card. This gives the agent awareness of what has already been discussed in the current session, reducing repetition and enabling continuity. **Multi-agent profiles**: When multiple Claway instances talk to the same user (e.g., a coding assistant and a personal assistant), Honcho maintains separate "peer" profiles. Each peer sees only its own observations and conclusions, preventing cross-contamination of context. ## Setup ```bash claway memory setup # select "honcho" from the provider list ``` Or configure manually: ```yaml # ~/.claway/config.yaml memory: provider: honcho ``` ```bash echo 'HONCHO_API_KEY=***' >> ~/.claway/.env ``` Get an API key at [honcho.dev](https://honcho.dev). ## Architecture ### Two-Layer Context Injection Every turn (in `hybrid` or `context` mode), Honcho assembles two layers of context injected into the system prompt: 1. **Base context** — session summary, user representation, user peer card, AI self-representation, and AI identity card. Refreshed on `contextCadence`. This is the "who is this user" layer. 2. **Dialectic supplement** — LLM-synthesized reasoning about the user's current state and needs. Refreshed on `dialecticCadence`. This is the "what matters right now" layer. Both layers are concatenated and truncated to the `contextTokens` budget (if set). ### Cold/Warm Prompt Selection The dialectic automatically selects between two prompt strategies: - **Cold start** (no base context yet): General query — "Who is this person? What are their preferences, goals, and working style?" - **Warm session** (base context exists): Session-scoped query — "Given what's been discussed in this session so far, what context about this user is most relevant?" This happens automatically based on whether base context has been populated. ### Three Orthogonal Config Knobs Cost and depth are controlled by three independent knobs: | Knob | Controls | Default | |------|----------|---------| | `contextCadence` | Turns between `context()` API calls (base layer refresh) | `1` | | `dialecticCadence` | Turns between `peer.chat()` LLM calls (dialectic layer refresh) | `2` (recommended 1–5) | | `dialecticDepth` | Number of `.chat()` passes per dialectic invocation (1–3) | `1` | These are orthogonal — you can have frequent context refreshes with infrequent dialectic, or deep multi-pass dialectic at low frequency. Example: `contextCadence: 1, dialecticCadence: 5, dialecticDepth: 2` refreshes base context every turn, runs dialectic every 5 turns, and each dialectic run makes 2 passes. ### Dialectic Depth (Multi-Pass) When `dialecticDepth` > 1, each dialectic invocation runs multiple `.chat()` passes: - **Pass 0**: Cold or warm prompt (see above) - **Pass 1**: Self-audit — identifies gaps in the initial assessment and synthesizes evidence from recent sessions - **Pass 2**: Reconciliation — checks for contradictions between prior passes and produces a final synthesis Each pass uses a proportional reasoning level (lighter early passes, base level for the main pass). Override per-pass levels with `dialecticDepthLevels` — e.g., `["minimal", "medium", "high"]` for a depth-3 run. Passes bail out early if the prior pass returned strong signal (long, structured output), so depth 3 doesn't always mean 3 LLM calls. ### Session-Start Prewarm On session init, Honcho fires a dialectic call in the background at the full configured `dialecticDepth` and hands the result directly to turn 1's context assembly. A single-pass prewarm on a cold peer often returns thin output — multi-pass depth runs the audit/reconcile cycle before the user ever speaks. If prewarm hasn't landed by turn 1, turn 1 falls back to a synchronous call with a bounded timeout. ### Query-Adaptive Reasoning Level The auto-injected dialectic scales `dialecticReasoningLevel` by query length: +1 level at ≥120 chars, +2 at ≥400, clamped at `reasoningLevelCap` (default `"high"`). Disable with `reasoningHeuristic: false` to pin every auto call to `dialecticReasoningLevel`. Available levels: `minimal`, `low`, `medium`, `high`, `max`. ## Configuration Options Honcho is configured in `~/.honcho/config.json` (global) or `$CLAWAY_HOME/honcho.json` (profile-local). The setup wizard handles this for you. ### Self-Hosted Honcho with Authentication When pointing Claway at a self-hosted Honcho server, `claway honcho setup` (and `claway memory setup`) ask for a **local JWT / bearer token** after the base URL. Paste a JWT signed with the server's `AUTH_JWT_SECRET` (the Honcho compose env var) to enable authenticated access; leave it blank for servers running with `AUTH_USE_AUTH=false`. The local token is stored under the host block (`hosts.<host>.apiKey` in `honcho.json`), separate from any cloud `apiKey`, so you can flip the `Cloud or local?` prompt back to `cloud` later without losing either credential. ### Full Config Reference | Key | Default | Description | |-----|---------|-------------| | `contextTokens` | `null` (uncapped) | Token budget for auto-injected context per turn. Set to an integer (e.g. 1200) to cap. Truncates at word boundaries | | `contextCadence` | `1` | Minimum turns between `context()` API calls (base layer refresh) | | `dialecticCadence` | `2` | Minimum turns between `peer.chat()` LLM calls (dialectic layer). Recommended 1–5. In `tools` mode, irrelevant — model calls explicitly | | `dialecticDepth` | `1` | Number of `.chat()` passes per dialectic invocation. Clamped to 1–3 | | `dialecticDepthLevels` | `null` | Optional array of reasoning levels per pass, e.g. `["minimal", "low", "medium"]`. Overrides proportional defaults | | `dialecticReasoningLevel` | `'low'` | Base reasoning level: `minimal`, `low`, `medium`, `high`, `max` | | `dialecticDynamic` | `true` | When `true`, model can override reasoning level per-call via tool param | | `dialecticMaxChars` | `600` | Max chars of dialectic result injected into system prompt | | `recallMode` | `'hybrid'` | `hybrid` (auto-inject + tools), `context` (inject only), `tools` (tools only) | | `writeFrequency` | `'async'` | When to flush messages: `async` (background thread), `turn` (sync), `session` (batch on end), or integer N | | `saveMessages` | `true` | Whether to persist messages to Honcho API | | `observationMode` | `'directional'` | `directional` (all on) or `unified` (shared pool). Override with `observation` object for granular control | | `messageMaxChars` | `25000` | Max chars per message sent via `add_messages()`. Chunked if exceeded | | `dialecticMaxInputChars` | `10000` | Max chars for dialectic query input to `peer.chat()` | | `sessionStrategy` | `'per-directory'` | `per-directory`, `per-repo`, `per-session`, or `global` | | `pinUserPeer` | `false` | Gateway only. When `true`, every platform user collapses to `peerName` | | `userPeerAliases` | `{}` | Gateway only. Map of runtime IDs to peers (`{"7654321": "alice"}`). Many-to-one | | `runtimePeerPrefix` | `""` | Gateway only. Namespaces unknown runtime IDs (`telegram_7654321`) when no alias matches | **Session strategy** controls how Honcho sessions map to your work: - `per-session` — each `claway` run gets a fresh session. Clean starts, memory via tools. Recommended for new users. - `per-directory` — one Honcho session per working directory. Context accumulates across runs. - `per-repo` — one session per git repository. - `global` — single session across all directories. **Recall mode** controls how memory flows into conversations: - `hybrid` — context auto-injected into system prompt AND tools available (model decides when to query). - `context` — auto-injection only, tools hidden. - `tools` — tools only, no auto-injection. Agent must explicitly call `honcho_reasoning`, `honcho_search`, etc. **Settings per recall mode:** | Setting | `hybrid` | `context` | `tools` | |---------|----------|-----------|---------| | `writeFrequency` | flushes messages | flushes messages | flushes messages | | `contextCadence` | gates base context refresh | gates base context refresh | irrelevant — no injection | | `dialecticCadence` | gates auto LLM calls | gates auto LLM calls | irrelevant — model calls explicitly | | `dialecticDepth` | multi-pass per invocation | multi-pass per invocation | irrelevant — model calls explicitly | | `contextTokens` | caps injection | caps injection | irrelevant — no injection | | `dialecticDynamic` | gates model override | N/A (no tools) | gates model override | In `tools` mode, the model is fully in control — it calls `honcho_reasoning` when it wants, at whatever `reasoning_level` it picks. Cadence and budget settings only apply to modes with auto-injection (`hybrid` and `context`). ## Gateway Identity Mapping These settings only matter when you run the Claway gateway — the one entrypoint where users arrive with platform-native runtime IDs (Telegram UID, Discord snowflake, Slack user). CLI, TUI, and desktop sessions have no runtime ID and always resolve to `peerName`, so off-gateway these keys do nothing. The setup wizard detects whether a gateway platform is connected and skips this step entirely if not. When it runs, it asks one question — *who talks to this gateway?* — and derives the keys: | Answer | Result | |--------|--------| | **just me** | `pinUserPeer: true` — every non-agent gateway user collapses to your peer. Pin overrides all aliases, so pick this only when no user-side identity needs its own peer. If separate agents reach the gateway and each needs a distinct peer, do **not** pin — leave `pinUserPeer: false` and map them via `userPeerAliases` (the `[e]` editor) instead | | **me + other people** (pooled) | `pinUserPeer: false` + `userPeerAliases` mapping your runtime IDs to `peerName` — you stay on your shared history, others get their own peers | | **only other people** | `pinUserPeer: false`, optional `runtimePeerPrefix` — each user gets their own peer | Pick `[e]` at the prompt to set the three keys directly instead. The resolver tries the keys top-down, first match wins: `pinUserPeer` → `userPeerAliases[id]` → `runtimePeerPrefix + id` → raw runtime ID → `peerName` → session-key fallback. :::warning Un-pinning orphans pooled memory Flipping `pinUserPeer` from `true` to `false` does not migrate data — memory accumulated under `peerName` stays there, and platform users resolve to fresh, empty peers. To keep your own continuity, choose the **pooled** path so your runtime IDs alias back to `peerName`. The wizard offers this steer automatically when it detects the transition. ::: :::note Deprecated key `pinPeerName` is a legacy alias for `pinUserPeer` — still read for back-compat (`pinUserPeer` wins where both are set), never written. Re-running setup migrates it onto the canonical key. ::: ## Observation (Directional vs. Unified) Honcho models a conversation as peers exchanging messages. Each peer has two observation toggles that map 1:1 to Honcho's `SessionPeerConfig`: | Toggle | Effect | |--------|--------| | `observeMe` | Honcho builds a representation of this peer from its own messages | | `observeOthers` | This peer observes the other peer's messages (feeds cross-peer reasoning) | Two peers × two toggles = four flags. `observationMode` is a shorthand preset: | Preset | User flags | AI flags | Semantics | |--------|-----------|----------|-----------| | `"directional"` (default) | me: on, others: on | me: on, others: on | Full mutual observation. Enables cross-peer dialectic — "what does the AI know about the user, based on what the user said and the AI replied." | | `"unified"` | me: on, others: off | me: off, others: on | Shared-pool semantics — the AI observes the user's messages only, the user peer only self-models. Single-observer pool. | Override the preset with an explicit `observation` block for per-peer control: ```json "observation": { "user": { "observeMe": true, "observeOthers": true }, "ai": { "observeMe": true, "observeOthers": false } } ``` Common patterns: | Intent | Config | |--------|--------| | Full observation (most users) | `"observationMode": "directional"` | | AI shouldn't re-model the user from its own replies | `"ai": {"observeMe": true, "observeOthers": false}` | | Strong persona the AI peer shouldn't update from self-observation | `"ai": {"observeMe": false, "observeOthers": true}` | Server-side toggles set via the [Honcho dashboard](https://app.honcho.dev) win over local defaults — Claway syncs them back at session init. ## Tools When Honcho is active as the memory provider, five tools become available: | Tool | Purpose | |------|---------| | `honcho_profile` | Read or update peer card — pass `card` (list of facts) to update, omit to read | | `honcho_search` | Semantic search over context — raw excerpts, no LLM synthesis | | `honcho_context` | Full session context — summary, representation, card, recent messages | | `honcho_reasoning` | Synthesized answer from Honcho's LLM — pass `reasoning_level` (minimal/low/medium/high/max) to control depth | | `honcho_conclude` | Create or delete conclusions — pass `conclusion` to create, `delete_id` to remove (PII only) | ## CLI Commands The `claway honcho` subcommand is **only registered when Honcho is the active memory provider** (`memory.provider: honcho` in `config.yaml`). On a fresh install, configure Honcho directly with `claway memory setup honcho` (or run `claway memory setup` and pick it from the list); the `claway honcho` subcommand then appears on the next invocation. ```bash claway memory setup honcho # Configure Honcho directly (works before activation) claway honcho status # Connection status, config, and key settings claway honcho setup # Redirects to `claway memory setup` (post-activation alias) claway honcho strategy # Show or set session strategy (per-session/per-directory/per-repo/global) claway honcho peer # Show or update peer names + dialectic reasoning level claway honcho mode # Show or set recall mode (hybrid/context/tools) claway honcho tokens # Show or set token budget for context and dialectic claway honcho identity # Seed or show the AI peer's Honcho identity claway honcho sync # Sync Honcho config to all existing profiles claway honcho peers # Show peer identities across all profiles claway honcho sessions # List known Honcho session mappings claway honcho map # Map current directory to a Honcho session name claway honcho enable # Enable Honcho for the active profile claway honcho disable # Disable Honcho for the active profile claway honcho migrate # Step-by-step migration guide from openclaw-honcho ``` ## Migrating from `claway honcho` If you previously used the standalone `claway honcho setup`: 1. Your existing configuration (`honcho.json` or `~/.honcho/config.json`) is preserved 2. Your server-side data (memories, conclusions, user profiles) is intact 3. Set `memory.provider: honcho` in config.yaml to reactivate No re-login or re-setup needed. Run `claway memory setup` and select "honcho" — the wizard detects your existing config. ## Full Documentation See [Memory Providers — Honcho](./memory-providers.md#honcho) for the complete reference. --- <!-- source: website/docs/user-guide/features/kanban-worker-lanes.md --> # user-guide/features/kanban-worker-lanes.md # Kanban worker lanes A **worker lane** is a class of process that the kanban dispatcher can route tasks to. Each lane has an identity (the assignee string), a spawn mechanism, and a contract for what it must do with the task once spawned. This page is the contract. It exists for two audiences: - **Operators** picking which lanes to wire into a board (which profiles to create, which assignees to use). - **Plugin / integration authors** wanting to add a new lane shape (a CLI worker that wraps Codex / Claude Code / OpenCode, a containerised review worker, a non-Claway service that pulls tasks via the API). If you're writing the worker code itself — the agent that runs *inside* a lane — the kanban lifecycle and reference details are injected into the worker's system prompt automatically (the `KANBAN_GUIDANCE` block in `agent/prompt_builder.py`). ## The hierarchy ```text Claway Kanban = canonical task lifecycle + audit trail Worker lane = implementation executor for one assigned card Reviewer = human or human-proxy that gates "done" GitHub PR = upstreamable artifact (optional, for code lanes) ``` Claway Kanban owns lifecycle truth — `ready` → `running` → `blocked` / `done` / `archived`. Worker lanes execute work but never own that truth; everything they do flows back through the kanban kernel via the `kanban_*` tools (or, for non-Claway external workers, via the API). Reviewers gate the transition from "code change written" to "task done." ## What a lane provides To be a kanban worker lane, an integration must provide three things: ### 1. An assignee string The dispatcher matches `task.assignee` against either a Claway profile name (the default lane shape) or a registered non-spawnable identifier (the plugin lane shape — see [Adding an external CLI worker lane](#adding-an-external-cli-worker-lane) below). Tasks whose assignee doesn't resolve are left on `ready` with a `skipped_nonspawnable` event so a board operator can fix them; they are not silently dropped or executed by an arbitrary fallback. ### 2. A spawn mechanism For Claway profile lanes, the dispatcher's `_default_spawn` runs `claway -p <assignee> chat -q <prompt>` (or the equivalent module form when the `claway` shim isn't on `$PATH`) inside the task's pinned workspace, with these env vars set: | Variable | Carries | |---|---| | `CLAWAY_KANBAN_TASK` | the task id the worker is operating on | | `CLAWAY_KANBAN_DB` | absolute path to the per-board SQLite file | | `CLAWAY_KANBAN_BOARD` | board slug | | `CLAWAY_KANBAN_WORKSPACES_ROOT` | root of the board's workspace tree | | `CLAWAY_KANBAN_WORKSPACE` | absolute path to *this* task's workspace | | `CLAWAY_KANBAN_RUN_ID` | the current run's id (for the lifecycle gate) | | `CLAWAY_KANBAN_CLAIM_LOCK` | the claim lock string (`<host>:<pid>:<uuid>`) | | `CLAWAY_PROFILE` | the worker's own profile name (for `kanban_comment` author attribution) | | `CLAWAY_TENANT` | tenant namespace, if the task has one | For non-Claway lanes (registered via a plugin), the plugin supplies its own `spawn_fn` callable that gets `task`, `workspace`, and `board` and returns an optional pid for crash detection. ### 3. A lifecycle terminator Every claim must end in exactly one of: - `kanban_complete(summary=..., metadata=...)` — task succeeds, status flips to `done`. - `kanban_block(reason=...)` — task waits for human input, status flips to `blocked`. The dispatcher respawns when `kanban_unblock` runs. - The worker process exits without a tool call. The kernel reaps it and emits `crashed` (PID died) or `gave_up` (consecutive-failure breaker tripped) or `timed_out` (max_runtime exceeded). This is the failure path; healthy workers don't end here. The kanban kernel enforces that exactly one of these terminates each run. A worker that calls neither and exits normally is treated as crashed. ## Outputs and the review-required convention For most code-changing tasks, the work isn't truly *done* the moment the worker finishes — it needs a human reviewer. The kanban kernel doesn't enforce this distinction (a "code-changing task" is fuzzy and forcing block-instead-of-complete on every code worker would break flows where no review is wanted). It's a convention layered on top: - **Block instead of complete**, with `reason` prefixed `review-required: ` so the dashboard / `claway kanban show` surfaces the row as awaiting review. - **Drop structured metadata into a `kanban_comment` first** since `kanban_block` only carries the human-readable `reason`. Comments are the durable annotation channel — every audit-relevant field (changed_files, tests_run, diff_path or PR url, decisions) belongs there. - **Reviewer either approves and unblocks**, which respawns the worker with the comment thread for follow-ups; or asks for changes via another comment, which the next worker run sees as part of `kanban_show`'s context. The injected `KANBAN_GUIDANCE` covers both `kanban_complete` (truly terminal tasks — typo fixes, docs changes, research writeups) and the `review-required` block pattern. ## Logs and audit trail The dispatcher writes per-task worker stdout/stderr to `<board-root>/logs/<task_id>.log`. Logs are auditable from kanban metadata: - `task_runs` rows carry the `log_path`, exit code (where available), summary, and metadata. - `task_events` rows carry every state transition (`promoted`, `claimed`, `heartbeat`, `completed`, `blocked`, `gave_up`, `crashed`, `timed_out`, `reclaimed`, `claim_extended`). - `kanban_show` returns both, so a reviewer (or a follow-up worker) reading the task gets the full history without needing dashboard access. The dashboard renders run history with summaries, metadata blocks, and exit-status badges. CLI users can run `claway kanban tail <task_id>` to follow live, or `claway kanban runs <task_id>` for the historical attempt list. ## Existing lane shapes ### Claway profile lane (default) The shape every kanban worker takes today: the assignee is a profile name, the dispatcher spawns `claway -p <profile>`, the worker gets the `KANBAN_GUIDANCE` system-prompt block injected automatically, and uses the `kanban_*` tools to terminate the run. No setup beyond defining the profile. When you create profiles for your fleet, choose names that match the *role* you want the orchestrator to route to. The orchestrator (when there is one) discovers your profile names via `claway profile list` — there's no fixed roster the system assumes (the orchestrator side of the contract is part of the injected `KANBAN_GUIDANCE`). ### Orchestrator profile lane A specialisation of the profile lane: an orchestrator is a Claway profile whose toolset includes `kanban` but excludes `terminal` / `file` / `code` / `web` for implementation. Its job is decomposing a high-level goal into child tasks via `kanban_create` + `kanban_link` and stepping back. The orchestrator skill encodes the anti-temptation rules. ## Adding an external CLI worker lane Wiring a non-Claway CLI tool (Codex CLI, Claude Code CLI, OpenCode CLI, a local coding-model runner, etc.) as a kanban worker lane is *not yet a paved path*. The dispatcher's spawn function is pluggable (`spawn_fn` is a parameter on `dispatch_once`), and a plugin could register its own `spawn_fn` for a non-Claway assignee, but the surrounding integration work — wrapping the CLI's exit code into `kanban_complete` / `kanban_block` calls, mapping the CLI's workspace/sandbox conventions onto the dispatcher's `CLAWAY_KANBAN_WORKSPACE` env, handling auth and per-CLI policy — is still per-integration design work. If you're considering adding a CLI lane, contact support@claway.io describing the specific CLI and the workflow you're trying to enable. The contract above is the constraints any such lane must satisfy; the implementation shape (one plugin per CLI vs a generic CLI-runner plugin parameterised by config) is open. ## Failure modes the dispatcher handles So lane authors don't have to reimplement these: - **Stale claim TTL** — a worker that claims and then never heartbeats / completes / blocks gets reclaimed after `DEFAULT_CLAIM_TTL_SECONDS` (15 min default) — but only if the worker process has actually died. A live worker (slow model spending 20+ min in one tool-free LLM call) gets the claim *extended* instead of killed; only a dead PID is reclaimed. - **Crashed worker** — a worker whose host-local PID has vanished is detected by `detect_crashed_workers` and reaped; the task increments `consecutive_failures` and may auto-block when the breaker trips. - **Run-level retry** — when a task is retried (post-block, post-crash, post-reclaim), the worker can use the `expected_run_id` parameter on terminating tools to fail fast if its own run was already superseded. - **Per-task max runtime** — `task.max_runtime_seconds` hard-caps wall-clock time per run, regardless of PID liveness. Catches genuinely-deadlocked workers that the live-PID extension would otherwise keep running. - **Stranded-task detection** — a ready task whose assignee never produces a claim within `kanban.stranded_threshold_seconds` (default 30 min) shows up in `claway kanban diagnostics` as a `stranded_in_ready` warning. Severity escalates to error at 2x the threshold and critical at 6x. Catches typo'd assignees, deleted profiles, and down external worker pools in one signal — identity-agnostic, no per-board allowlist to curate. ## Related - [Kanban overview](./kanban) — the user-facing intro. - `KANBAN_GUIDANCE` — the worker + orchestrator lifecycle injected into every kanban worker's system prompt. --- <!-- source: website/docs/user-guide/features/lsp.md --> # LSP — Semantic Diagnostics # Language Server Protocol (LSP) Claway runs full language servers — pyright, gopls, rust-analyzer, typescript-language-server, clangd, and ~20 more — as background subprocesses and feeds their semantic diagnostics into the post-write lint check used by `write_file` and `patch`. When the agent edits a file, it sees exactly the errors that edit introduced — not just syntax errors, but **type errors, undefined names, missing imports, and project-wide semantic issues** the language server detects. This is the same architecture top-tier coding agents use. Claway ships it self-contained: no editor host required, no plugins to install, no separate daemon to manage. ## When LSP runs LSP is gated on **git workspace detection**. When the agent's working directory (or the file being edited) is inside a git repository, LSP runs against that workspace. When neither is in a git repo, LSP stays dormant — useful for messaging gateways where the cwd is the user's home directory and there's no project to diagnose. The check is layered: in-process syntax check first (microseconds), then LSP diagnostics second when syntax is clean. A flaky or missing language server can never break a write — every LSP failure path falls back silently to the syntax-only result. Concretely, on every successful `write_file` or `patch`: 1. Claway captures a baseline of current diagnostics for the file. 2. Performs the write. 3. Re-queries the language server, filters out diagnostics that were already in the baseline, and surfaces only the new ones. The agent sees output like: ``` { "bytes_written": 42, "dirs_created": false, "lint": {"status": "ok", "output": ""}, "lsp_diagnostics": "LSP diagnostics introduced by this edit:\n<diagnostics file=\"/path/to/foo.py\">\nERROR [42:5] Cannot find name 'foo' [reportUndefinedVariable] (Pyright)\nERROR [50:1] Argument of type \"str\" is not assignable to \"int\" [reportArgumentType] (Pyright)\n</diagnostics>" } ``` The `lint` field carries the syntax-check result (microsecond in-process parse via `ast.parse`, `json.loads`, etc.); the `lsp_diagnostics` field carries the semantic diagnostics from the real language server. Two channels, independent signals — the agent sees a syntax-clean file with semantic problems as ``lint: ok`` plus a populated ``lsp_diagnostics``. ## Supported languages | Language | Server | Auto-install | |----------|--------|--------------| | Python | `pyright-langserver` | npm | | TypeScript / JavaScript / JSX / TSX | `typescript-language-server` | npm | | Vue | `@vue/language-server` | npm | | Svelte | `svelte-language-server` | npm | | Astro | `@astrojs/language-server` | npm | | Go | `gopls` | `go install` | | Rust | `rust-analyzer` | manual (rustup) | | C / C++ | `clangd` | manual (LLVM) | | Bash / Zsh | `bash-language-server` | npm | | YAML | `yaml-language-server` | npm | | Lua | `lua-language-server` | manual (GitHub releases) | | PHP | `intelephense` | npm | | OCaml | `ocaml-lsp` | manual (opam) | | Dockerfile | `dockerfile-language-server-nodejs` | npm | | Terraform | `terraform-ls` | manual | | Dart | `dart language-server` | manual (dart sdk) | | Haskell | `haskell-language-server` | manual (ghcup) | | Julia | `julia` + LanguageServer.jl | manual | | Clojure | `clojure-lsp` | manual | | Nix | `nixd` | manual | | Zig | `zls` | manual | | Gleam | `gleam lsp` | manual (gleam install) | | Elixir | `elixir-ls` | manual | | Prisma | `prisma language-server` | manual | | Kotlin | `kotlin-language-server` | manual | | Java | `jdtls` | manual | | PowerShell | `PowerShellEditorServices` (`pwsh` host) | manual (release zip) | For "manual" entries, install the server through whatever toolchain manager makes sense for that language (rustup, ghcup, opam, brew, …). Claway auto-detects the binary on PATH or in `<CLAWAY_HOME>/lsp/bin/`. ### PowerShell PowerShellEditorServices isn't a single binary — it's a PowerShell module bundle launched by a `pwsh` (PowerShell 7+) or `powershell` host. Setup: 1. Install [PowerShell](https://github.com/PowerShell/PowerShell) so `pwsh` (or Windows `powershell`) is on PATH. 2. Download the latest release zip from [PowerShellEditorServices releases](https://github.com/PowerShell/PowerShellEditorServices/releases) and extract it. 3. Point Claway at the extracted bundle — the directory that contains `PowerShellEditorServices/Start-EditorServices.ps1`. Either: - set `lsp.servers.powershell.command: ["/path/to/bundle"]` in `config.yaml`, or - extract it to `<CLAWAY_HOME>/lsp/PowerShellEditorServices`, or - export `PSES_BUNDLE_PATH=/path/to/bundle`. `claway lsp status` reports `installed` once `pwsh` is found; if the bundle is missing you'll see a one-time warning in the logs with the download link. A few servers are installed alongside a peer dependency that npm won't auto-pull. The current case is `typescript-language-server`, which requires the `typescript` SDK importable from the same `node_modules` tree — Claway installs both packages together when you run `claway lsp install typescript` or auto-install fires on first use. ## CLI ``` claway lsp status # service state + per-server install status claway lsp list # registry, optionally --installed-only claway lsp install <id> # eagerly install one server claway lsp install-all # try every server with a known recipe claway lsp restart # tear down running clients claway lsp which <id> # print resolved binary path ``` `claway lsp status` is the best starting point — it shows which languages will get semantic diagnostics today and which need a binary installed. ## Configuration The defaults work for typical setups; nothing to set if the binaries are on PATH. ```yaml # config.yaml lsp: # Master toggle. Disabling skips the entire subsystem — no servers # spawn, no background event loop runs. enabled: true # How long to wait for diagnostics after each write. wait_mode: document # "document" or "full" wait_timeout: 5.0 # How to handle missing server binaries. # auto — install via npm/pip/go install into <CLAWAY_HOME>/lsp/bin # manual — only use binaries already on PATH install_strategy: auto # Per-server overrides (all optional). servers: pyright: disabled: false command: ["/abs/path/to/pyright-langserver", "--stdio"] env: { PYRIGHT_LOG_LEVEL: "info" } initialization_options: python: analysis: typeCheckingMode: "strict" typescript: disabled: true # skip TS even when its extensions match ``` ### Per-server keys * `disabled: true` — skip this server entirely even when its extensions match a file. * `command: [bin, ...args]` — pin a custom binary path. Bypasses auto-install. * `env: {KEY: value}` — extra env vars passed to the spawned process. * `initialization_options: {...}` — merged into the LSP `initializationOptions` payload sent in the `initialize` handshake. Server-specific; consult the language server's docs. ## Installation locations When `install_strategy: auto`, Claway installs binaries into `<CLAWAY_HOME>/lsp/bin/`. NPM packages land in `<CLAWAY_HOME>/lsp/node_modules/` with bin symlinks one level up. Go binaries come from `go install` with `GOBIN` pointed at the staging dir. Nothing is ever installed to `/usr/local/`, `~/.local/`, or any other shared location — the staging dir is fully Claway-owned and is removed when you reset the profile. ## Performance characteristics LSP servers are **lazy-spawned** on first use. Editing a Python file in a project that's never seen `.py` traffic spawns pyright; the spawn takes 1-3 seconds for most servers (rust-analyzer can take 10+ on a cold project). Subsequent edits in the same workspace re-use the running server. The LSP layer adds a few milliseconds to clean writes when no diagnostics are emitted. When diagnostics are emitted, the wait budget is `wait_timeout` seconds — typically the server responds in tens of milliseconds for pyright/tsserver and a few seconds for rust-analyzer mid-indexing. Servers are kept alive for the life of the Claway process. There's no idle-timeout reaper — the cost of restarting the server's index on every write would be far higher than holding the daemon. ## Disabling Set `lsp.enabled: false` in `config.yaml` to disable the entire subsystem. The post-write check falls back to the in-process syntax check (`ast.parse` for Python, `json.loads` for JSON, etc.) which ships unchanged from earlier versions. To disable a single language without disabling the whole layer: ```yaml lsp: servers: rust-analyzer: disabled: true ``` ## Troubleshooting **`claway lsp status` shows a server as "missing"** The binary isn't on PATH and isn't in `<CLAWAY_HOME>/lsp/bin/`. Run `claway lsp install <server_id>` to attempt an auto-install, or install the binary manually through the language's normal toolchain. **`Backend warnings` section in `claway lsp status`** Some servers ship as thin wrappers around an external CLI for actual diagnostics — they spawn cleanly and accept requests but never emit errors when the sidecar binary is missing. The most common case is `bash-language-server`, which delegates diagnostics to `shellcheck`. When `claway lsp status` shows a `Backend warnings` section, install the named tool through your OS package manager: ``` apt install shellcheck # Debian / Ubuntu brew install shellcheck # macOS scoop install shellcheck # Windows ``` The same warning is logged once at server spawn time in `~/.claway/logs/agent.log`. **Server starts but never returns diagnostics** Check `~/.claway/logs/agent.log` for `[agent.lsp.client]` entries — both stderr from the language server and protocol errors land there. Some servers (rust-analyzer especially) need to finish a project-wide index before they emit per-file diagnostics; the first edit after server start may complete with no diagnostics, with subsequent edits picking them up. **Server crashed** A crashed server is added to the broken-set and won't be retried for the rest of the session. Run `claway lsp restart` to clear the set; the next edit re-spawns. **Editing a file outside any git repo** By design, LSP only runs inside a git repository. If the project isn't yet initialized, run `git init` to enable LSP diagnostics. Otherwise the in-process syntax-only fallback applies. --- <!-- source: website/docs/user-guide/features/mixture-of-agents.md --> # Mixture of Agents # Mixture of Agents Mixture of Agents is a virtual model provider. Each named MoA preset appears as a selectable model under the `moa` provider. When you select a MoA preset, the preset's aggregator is the acting model. It is the model that writes the assistant response and emits tool calls. Reference models run first and provide analysis for the aggregator to use. Use MoA when a hard task benefits from multiple model perspectives but still needs Claway's normal agent loop: tool calls, follow-up iterations, interrupts, transcript persistence, and the same session context as any other message. ## Select a MoA preset as your model You can select a preset through the normal model picker surfaces: ```bash /model default --provider moa /model review --provider moa ``` MoA presets are selectable on **every Claway surface**, because MoA is a normal provider in the model system: - **CLI / gateway / TUI `/model`** — `/model <preset> --provider moa`, or `/model --provider moa` for the default preset. A bare `/model <preset>` also works when the name exactly matches a configured preset. - **`claway model`** and the **Dashboard model picker** — a `Mixture of Agents` provider row appears with your preset names as its models. - **Desktop GUI app** — the model dropdown shows an `MoA presets` section; selecting one (`MoA: <preset>`) switches the active model to that preset. The Desktop settings panel also creates and edits presets. Configured presets therefore show up wherever you would pick any other model. ## Slash command shortcut `/moa` is one-shot convenience sugar. It runs a single prompt through the **default** MoA preset, then restores whatever model you were on: ```bash /moa design and implement a migration plan for this flaky test cluster ``` Claway temporarily switches to the default MoA preset for that one turn, sends the prompt, then restores your previous model afterward. The whole argument is the prompt — `/moa` no longer interprets it as a preset name. ```bash /moa ``` Bare `/moa` (no prompt) just prints usage. To **switch** to a MoA preset for the rest of the session, select it from the model picker — MoA presets appear under a `Mixture of Agents` provider in every model-selection surface (see above). `/moa` is deliberately not a model switch, so a normal prompt can never accidentally change your model. ## How it works in the agent loop For each main model call when provider `moa` is selected, Claway: 1. resolves the selected preset by name; 2. runs the configured reference models without tool schemas (they receive only the conversation's user/assistant text — not the Claway system prompt or tool-call transcript — so reference calls stay cheap and avoid strict-provider rejections); 3. appends the reference outputs as private context for the aggregator; 4. calls the configured aggregator with the normal Claway tool schema; 5. treats the aggregator response as the real model response; 6. if the aggregator calls tools, Claway executes those tools normally; 7. on the next model iteration, the same MoA process runs again over the updated conversation, including tool results. Because MoA is selected through the normal model system, it composes automatically with `/goal`, gateway sessions, TUI sessions, and Desktop chat. ## Configure presets You can configure named MoA presets from: - Dashboard → Models → Model Settings → Mixture of Agents - Desktop app → Settings → Model → Mixture of Agents - `claway moa configure [name]` - `config.yaml` The config stores explicit provider/model pairs, so you can mix providers and use multiple models from the same provider: ```yaml moa: default_preset: default presets: default: reference_models: - provider: openai-codex model: gpt-5.5 - provider: openrouter model: deepseek/deepseek-v4-pro aggregator: provider: openrouter model: anthropic/claude-opus-4.8 reference_temperature: 0.6 aggregator_temperature: 0.4 max_tokens: 4096 enabled: true ``` Default preset: - reference: `openai-codex:gpt-5.5` - reference: `openrouter:deepseek/deepseek-v4-pro` - aggregator / acting model: `openrouter:anthropic/claude-opus-4.8` ## Terminal preset management ```bash claway moa list claway moa configure # update the default preset claway moa configure review # create or update a named preset claway moa delete review ``` ## Benchmarks On ClawayBench, a two-model MoA preset — `claude-opus-4.8` aggregating over a `gpt-5.5` reference — outscores either model run on its own: | Model | ClawayBench score | |---|---| | **Opus aggregator (opus-4.8 + gpt-5.5 reference) — MoA** | **0.8202** | | `anthropic/claude-opus-4.8` | 0.7607 | | `openai/gpt-5.5` | 0.7412 | The MoA configuration beats its strongest component (opus-4.8) by ~6 points, confirming that aggregating a second perspective lifts quality on hard tasks rather than just averaging the two. ## Prompt caching MoA is built so the **main conversation's prompt cache is never broken**. Selecting a MoA preset is a normal model selection: it does not mutate past context, swap toolsets, or rebuild the system prompt mid-conversation. Your conversation history, system prompt, and tool schema stay byte-stable, so the cached prefix every other model relies on is preserved exactly as it would be for a plain model. Switching to or away from a MoA preset costs the same cache invalidation as any other `/model` switch — no more. Both internal call types cache normally: - **Reference models** receive a trimmed, deterministic view of the conversation (system prompt and tool transcript stripped — see the loop above). Because that view is a stable function of the stable history, a reference model's prompt prefix repeats across iterations and caches normally. References are short advisory calls with no tools. - **The aggregator** is the acting model. The reference outputs are appended to the *end* of the latest user turn as private guidance. Because that text sits at the tail — below the entire stable prefix (system prompt + prior history) — it does not invalidate any cached prefix: the aggregator gets a cache hit on everything above the injection, and only the freshly appended tail is new. That is exactly how every normal turn behaves, where each new user message is also uncached tail tokens. So MoA does not sacrifice prompt caching on either call type. Its only real cost is the extra reference calls per iteration — you pay for multiple model perspectives, not for broken caches. The long-lived conversation prefix shared with the rest of Claway is fully intact. ## Notes - MoA is no longer listed under `claway tools`; there is no `moa` toolset to enable. - Setting `enabled: false` on a preset disables the reference fan-out for that preset: the aggregator acts alone, exactly as if you selected it as a plain model. This is the per-preset off switch surfaced in the dashboard and desktop settings. - A preset's aggregator cannot be another MoA preset. Recursive MoA trees are intentionally blocked. - Credential failures on one reference model do not abort the turn. Claway includes the failure in the reference context and continues with whatever models returned. - MoA increases model-call count. A single model iteration can involve multiple reference calls plus the aggregator call. --- <!-- source: website/docs/user-guide/features/pets.md --> # Pets (Petdex Mascots) # Pets Claway can show an animated **pet** — a small mascot sprite that reacts to what the agent is doing (idle, running a tool, thinking, finishing, failing) across the **CLI**, **TUI**, and **desktop app**. Pets come from the public [petdex](https://github.com/crafter-station/petdex) gallery. Pets are purely cosmetic. They have **no effect on prompt caching, tokens, or the agent's behavior** — the sprite is a display concern only. The feature is **off by default** and stays dormant until you install and select a pet. ## How it works - Pets are installed into your profile's `pets/` directory (`<CLAWAY_HOME>/pets/<slug>/`), so each [profile](../profiles.md) keeps its own set. - Selecting a pet writes `display.pet.slug` and `display.pet.enabled` to `config.yaml` — nothing is stored as a secret or env var. - Each surface watches the activity it already tracks and maps it to one of six animation states. The mapping lives in one place so every surface behaves the same: | Agent activity | Pet state | | --- | --- | | A tool/turn just failed | `failed` | | A plan finished (all todos done) | `jump` (celebrate) | | A turn finished cleanly | `wave` | | A tool is executing | `run` | | The model is thinking/reading | `review` | | Turn in flight (unspecified) | `run` | | Blocked on you (a clarify/approval prompt is open) | `waiting` (falls back to `idle` on legacy 8-row sheets) | | Nothing happening | `idle` | ## Rendering In the terminal (CLI/TUI), Claway renders the sprite at full fidelity when your terminal supports a graphics protocol (**kitty**, **Ghostty**, **WezTerm**, **iTerm2**, or **sixel**). Otherwise it falls back automatically to a truecolor Unicode **half-block** rendering. Inside a pipe or redirect (no TTY), terminal rendering is disabled by design. The desktop app draws the pet as a floating sprite on a canvas and toggles it from **Settings → Appearance**. ## Quick start (CLI) ```bash # Browse the gallery (filter by substring) claway pets list claway pets list cat # Install a pet and make it active in one step claway pets install boba --select # Preview / animate it in your terminal (Ctrl+C to stop) claway pets show # Check your setup claway pets doctor ``` ## `claway pets` commands | Goal | Command | | --- | --- | | Browse the gallery | `claway pets list [query] [--limit N]` | | List installed pets | `claway pets list --installed` | | Install a pet | `claway pets install <slug> [--select] [--force]` | | Set the active pet | `claway pets select [slug]` (omit slug for a picker) | | Resize the pet everywhere | `claway pets scale <factor>` (e.g. `0.5`, clamped 0.1–3.0) | | Preview/animate | `claway pets show [slug] [--state <s>] [--cycle] [--once] [--mode <m>] [--scale <f>]` | | Disable the pet | `claway pets off` | | Remove an installed pet | `claway pets remove <slug>` | | Diagnose setup | `claway pets doctor` | `claway pets show` flags: - `--state` — play a single state (`idle`, `wave`, `run`, `failed`, `review`, `jump`). - `--cycle` — cycle through every state. - `--once` — play once instead of looping. - `--mode` — override the render protocol (`kitty`, `iterm`, `sixel`, `unicode`, `auto`). - `--scale` — override the on-screen scale (`0` = use config). ## `/pet` slash command Inside the CLI and TUI you can manage the pet without leaving the session: - `/pet` — toggle the pet on/off (adopts the first installed pet if none is active). - `/pet list` — browse the gallery. - `/pet scale <factor>` — resize the pet everywhere (e.g. `/pet scale 0.5`). - `/pet <slug>` — adopt a specific pet. - `/pet off` — disable the pet. In the TUI, `/pet list` opens an interactive picker overlay; in the desktop app it opens the Cmd+K pet palette. ## Generating a pet (`/hatch`) Beyond installing pre-made pets from the gallery, Claway can **generate a brand-new pet** from a text description — its own AI sprite-generation pipeline. - CLI/TUI: `/hatch <description>` (alias `/generate-pet`), or `claway pets` → the generate flow. - Desktop app: the Pokédex-style **generate** UI — an animated egg, hatch FX, and a draft picker. How generation works (a two-step, cost-bounded flow): 1. **Base drafts** — a handful of cheap, prompt-only "what should this pet look like" variants are generated. You pick one, or remix/retry for a fresh round. 2. **Hatch** — the chosen base is used as a reference image to generate one grounded animation row per Claway state (idle, thinking, tool use, etc.), which are deterministically sliced into frames and packed into a standard petdex/Codex atlas (8×9 grid of 192×208 cells). The result is a valid spritesheet you keep — and could `petdex submit`. ### Image backend Generation uses the active [image-generation provider](/user-guide/features/image-generation), but it requires **reference-image grounding** so each animation row stays the same character as the base. Reference-capable backends: **OpenRouter**, **OpenAI** (`gpt-image-2`), and **Krea**. OpenRouter runs a quality-first model chain by default. - Resolution order prefers OpenAI → OpenRouter. - If no reference-capable backend is configured, generation surfaces an actionable error pointing you to `claway tools` → Image Generation. (Installing/adopting existing gallery pets needs no image backend.) - Override the backend with the `CLAWAY_PET_IMAGE_PROVIDER` env var (e.g. `CLAWAY_PET_IMAGE_PROVIDER=openrouter`). ## Desktop app In the desktop app you can manage the pet two ways: - **Cmd+K → "Pets…"** — browse, search, adopt, and toggle pets without leaving the keyboard (mirrors the theme picker). - **Settings → Appearance** — the same gallery plus a **size slider** that resizes the floating mascot live as you drag. Both adopt/toggle/resize the floating mascot in place — size changes apply instantly; adopting a new pet lights it up within a moment. ### Pop-out overlay **Shift-click** the floating pet to pop it out into its own transparent, always-on-top desktop window. Out there it stays visible while Claway is minimized (Codex-style), so a glance tells you what the agent is doing. Gestures once it's popped out: | Gesture | Action | | --- | --- | | **Drag** | Move the pet anywhere on screen, even outside the app. Its spot and in/out state persist across restarts. | | **Single-click** | Open a mini composer to send a prompt to the most recent session — without surfacing the app. | | **Double-click** | Toggle the app window: minimize it if it's up front, restore it if it's hidden. | | **Shift-click** | Pop the pet back into the window. | | **Mail icon** | Appears only when a turn finished while you were away; click to raise the app on the most recent thread (and mark it read). | Only the popped-out pet shows a **speech bubble** (`working…`, `thinking…`, `your turn`, …) — in-window the app itself is the surface, so the pet stays quiet there. The overlay is a pure puppet of the in-app pet — it carries no separate gateway connection and never appears in the dock or app switcher. ## Configuration All settings live under `display.pet` in `config.yaml`: ```yaml display: pet: enabled: false # master on/off (true once you select a pet) slug: "" # active pet; empty = first installed render_mode: auto # auto | kitty | iterm | sixel | unicode | off scale: 0.33 # master size knob (relative to native 192x208 frames) unicode_cols: 0 # hard override for terminal width (0 = derive from scale) ``` - **`scale`** is the single master size knob. One number shrinks every surface: the desktop canvas scales its pixels by it, and the CLI/TUI derive their terminal column width from it. The half-block fallback clamps to a legibility floor — it can't shrink as far as true-pixel kitty/GUI rendering without turning to mush, so the same `scale` looks crisp under kitty but is floored in half-blocks. - **`render_mode: auto`** detects kitty/iTerm2/sixel and falls back to unicode half-blocks. Set it explicitly to force a protocol or `off` to disable terminal rendering while keeping the pet on the desktop. - **`unicode_cols`** pins the terminal column width independently of `scale`; leave it at `0` to derive width from `scale`. ## Troubleshooting Run `claway pets doctor` — it reports: - the pets directory and which pets are installed, - `display.pet.enabled`, `display.pet.slug`, and the resolved active pet, - the configured `render_mode`, the detected terminal graphics protocol, and the effective mode for a TTY, - whether Pillow (used for sprite decoding) is importable. It prints `✓ ready` once a pet is installed, selected, enabled, and Pillow is available. Common gotchas: - A pet only shows once one is **installed AND selected** (`enabled: true`). - Inside a pipe/redirect (no TTY), terminal rendering is disabled by design. - The petdex npm CLI installs to `~/.codex/pets`; Claway uses its own profile-scoped `<CLAWAY_HOME>/pets/` instead — install through `claway pets`. ## See also - The [`petdex` skill](../skills/bundled/productivity/productivity-petdex.md) lets the agent install and switch pets for you on request. --- <!-- source: website/docs/user-guide/features/provider-routing.md --> # user-guide/features/provider-routing.md # Provider Routing When using [OpenRouter](https://openrouter.ai) as your LLM provider, Claway Agent supports **provider routing** — fine-grained control over which underlying AI providers handle your requests and how they're prioritized. OpenRouter routes requests to many providers (e.g., Anthropic, Google, AWS Bedrock, Together AI). Provider routing lets you optimize for cost, speed, quality, or enforce specific provider requirements. ## Configuration Add a `provider_routing` section to your `~/.claway/config.yaml`: ```yaml provider_routing: sort: "price" # How to rank providers only: [] # Whitelist: only use these providers ignore: [] # Blacklist: never use these providers order: [] # Explicit provider priority order require_parameters: false # Only use providers that support all parameters data_collection: null # Control data collection ("allow" or "deny") ``` :::info Provider routing only applies when using OpenRouter. It has no effect with direct provider connections (e.g., connecting directly to the Anthropic API). ::: ## Options ### `sort` Controls how OpenRouter ranks available providers for your request. | Value | Description | |-------|-------------| | `"price"` | Cheapest provider first | | `"throughput"` | Fastest tokens-per-second first | | `"latency"` | Lowest time-to-first-token first | ```yaml provider_routing: sort: "price" ``` ### `only` Whitelist of provider names. When set, **only** these providers will be used. All others are excluded. ```yaml provider_routing: only: - "Anthropic" - "Google" ``` ### `ignore` Blacklist of provider names. These providers will **never** be used, even if they offer the cheapest or fastest option. ```yaml provider_routing: ignore: - "Together" - "DeepInfra" ``` ### `order` Explicit priority order. Providers listed first are preferred. Unlisted providers are used as fallbacks. ```yaml provider_routing: order: - "Anthropic" - "Google" - "AWS Bedrock" ``` ### `require_parameters` When `true`, OpenRouter will only route to providers that support **all** parameters in your request (like `temperature`, `top_p`, `tools`, etc.). This avoids silent parameter drops. ```yaml provider_routing: require_parameters: true ``` ### `data_collection` Controls whether providers can use your prompts for training. Options are `"allow"` or `"deny"`. ```yaml provider_routing: data_collection: "deny" ``` ## Practical Examples ### Optimize for Cost Route to the cheapest available provider. Good for high-volume usage and development: ```yaml provider_routing: sort: "price" ``` ### Optimize for Speed Prioritize low-latency providers for interactive use: ```yaml provider_routing: sort: "latency" ``` ### Optimize for Throughput Best for long-form generation where tokens-per-second matters: ```yaml provider_routing: sort: "throughput" ``` ### Lock to Specific Providers Ensure all requests go through a specific provider for consistency: ```yaml provider_routing: only: - "Anthropic" ``` ### Avoid Specific Providers Exclude providers you don't want to use (e.g., for data privacy): ```yaml provider_routing: ignore: - "Together" - "Lepton" data_collection: "deny" ``` ### Preferred Order with Fallbacks Try your preferred providers first, fall back to others if unavailable: ```yaml provider_routing: order: - "Anthropic" - "Google" require_parameters: true ``` ## How It Works Provider routing preferences are passed to the OpenRouter API via the `extra_body.provider` field on every API call. This applies to both: - **CLI mode** — configured in `~/.claway/config.yaml`, loaded at startup - **Gateway mode** — same config file, loaded when the gateway starts The routing config is read from `config.yaml` and passed as parameters when creating the `AIAgent`: ``` providers_allowed ← from provider_routing.only providers_ignored ← from provider_routing.ignore providers_order ← from provider_routing.order provider_sort ← from provider_routing.sort provider_require_parameters ← from provider_routing.require_parameters provider_data_collection ← from provider_routing.data_collection ``` :::tip You can combine multiple options. For example, sort by price but exclude certain providers and require parameter support: ```yaml provider_routing: sort: "price" ignore: ["Together"] require_parameters: true data_collection: "deny" ``` ::: ## Default Behavior When no `provider_routing` section is configured (the default), OpenRouter uses its own default routing logic, which generally balances cost and availability automatically. :::tip Provider Routing vs. Fallback Models Provider routing controls which **sub-providers within OpenRouter** handle your requests. For automatic failover to an entirely different provider when your primary model fails, see [Fallback Providers](/user-guide/features/fallback-providers). ::: --- <!-- source: website/docs/user-guide/features/skins.md --> # Skins & Themes # Skins & Themes Skins control the **visual presentation** of the Claway CLI: banner colors, spinner faces and verbs, response-box labels, branding text, and the tool activity prefix. Conversational style and visual style are separate concepts: - **Personality** changes the agent's tone and wording. - **Skin** changes the CLI's appearance. ## Change skins ```bash /skin # show the current skin and list available skins /skin ares # switch to a built-in skin /skin mytheme # switch to a custom skin from ~/.claway/skins/mytheme.yaml ``` Or set the default skin in `~/.claway/config.yaml`: ```yaml display: skin: default ``` ## Built-in skins | Skin | Description | Agent branding | Visual character | |------|-------------|----------------|------------------| | `default` | Classic Claway — gold and kawaii | `Claway Agent` | Warm gold borders, cornsilk text, kawaii faces in spinners. The familiar caduceus banner. Clean and inviting. | | `ares` | War-god theme — crimson and bronze | `Ares Agent` | Deep crimson borders with bronze accents. Aggressive spinner verbs ("forging", "marching", "tempering steel"). Custom sword-and-shield ASCII art banner. | | `mono` | Monochrome — clean grayscale | `Claway Agent` | All grays — no color. Borders are `#555555`, text is `#c9d1d9`. Ideal for minimal terminal setups or screen recordings. | | `slate` | Cool blue — developer-focused | `Claway Agent` | Royal blue borders (`#4169e1`), soft blue text. Calm and professional. No custom spinner — uses default faces. | | `daylight` | Light theme for bright terminals with dark text and cool blue accents | `Claway Agent` | Designed for white or bright terminals. Dark slate text with blue borders, pale status surfaces, and a light completion menu that stays readable in light terminal profiles. | | `warm-lightmode` | Warm brown/gold text for light terminal backgrounds | `Claway Agent` | Warm parchment tones for light terminals. Dark brown text with saddle-brown accents, cream-colored status surfaces. An earthy alternative to the cooler daylight theme. | | `poseidon` | Ocean-god theme — deep blue and seafoam | `Poseidon Agent` | Deep blue to seafoam gradient. Ocean-themed spinners ("charting currents", "sounding the depth"). Trident ASCII art banner. | | `sisyphus` | Sisyphean theme — austere grayscale with persistence | `Sisyphus Agent` | Light grays with stark contrast. Boulder-themed spinners ("pushing uphill", "resetting the boulder", "enduring the loop"). Boulder-and-hill ASCII art banner. | | `charizard` | Volcanic theme — burnt orange and ember | `Charizard Agent` | Warm burnt orange to ember gradient. Fire-themed spinners ("banking into the draft", "measuring burn"). Dragon-silhouette ASCII art banner. | ## Complete list of configurable keys ### Colors (`colors:`) Controls all color values throughout the CLI. Values are hex color strings. | Key | Description | Default (`default` skin) | |-----|-------------|--------------------------| | `banner_border` | Panel border around the startup banner | `#CD7F32` (bronze) | | `banner_title` | Title text color in the banner | `#FFD700` (gold) | | `banner_accent` | Section headers in the banner (Available Tools, etc.) | `#FFBF00` (amber) | | `banner_dim` | Muted text in the banner (separators, secondary labels) | `#B8860B` (dark goldenrod) | | `banner_text` | Body text in the banner (tool names, skill names) | `#FFF8DC` (cornsilk) | | `ui_accent` | General UI accent color (highlights, active elements) | `#FFBF00` | | `ui_label` | UI labels and tags | `#4dd0e1` (teal) | | `ui_ok` | Success indicators (checkmarks, completion) | `#4caf50` (green) | | `ui_error` | Error indicators (failures, blocked) | `#ef5350` (red) | | `ui_warn` | Warning indicators (caution, approval prompts) | `#ffa726` (orange) | | `prompt` | Interactive prompt text color | `#FFF8DC` | | `input_rule` | Horizontal rule above the input area | `#CD7F32` | | `response_border` | Border around the agent's response box (ANSI escape) | `#FFD700` | | `session_label` | Session label color | `#DAA520` | | `session_border` | Session ID dim border color | `#8B8682` | | `status_bar_bg` | Background color for the TUI status / usage bar | `#1a1a2e` | | `voice_status_bg` | Background color for the voice-mode status badge | `#1a1a2e` | | `selection_bg` | Background color for the TUI mouse-selection highlighter. Falls back to `completion_menu_current_bg` when unset. | `#333355` | | `completion_menu_bg` | Background color for the completion menu list | `#1a1a2e` | | `completion_menu_current_bg` | Background color for the active completion row | `#333355` | | `completion_menu_meta_bg` | Background color for the completion meta column | `#1a1a2e` | | `completion_menu_meta_current_bg` | Background color for the active completion meta column | `#333355` | ### Spinner (`spinner:`) Controls the animated spinner shown while waiting for API responses. | Key | Type | Description | Example | |-----|------|-------------|---------| | `waiting_faces` | list of strings | Faces cycled while waiting for API response | `["(⚔)", "(⛨)", "(▲)"]` | | `thinking_faces` | list of strings | Faces cycled during model reasoning | `["(⚔)", "(⌁)", "(<>)"]` | | `thinking_verbs` | list of strings | Verbs shown in spinner messages | `["forging", "plotting", "hammering plans"]` | | `wings` | list of [left, right] pairs | Decorative brackets around the spinner | `[["⟪⚔", "⚔⟫"], ["⟪▲", "▲⟫"]]` | When spinner values are empty (like in `default` and `mono`), hardcoded defaults from `display.py` are used. ### Branding (`branding:`) Text strings used throughout the CLI interface. | Key | Description | Default | |-----|-------------|---------| | `agent_name` | Name shown in banner title and status display | `Claway Agent` | | `welcome` | Welcome message shown at CLI startup | `Welcome to Claway Agent! Type your message or /help for commands.` | | `goodbye` | Message shown on exit | `Goodbye! ⚕` | | `response_label` | Label on the response box header | ` ⚕ Claway ` | | `prompt_symbol` | Symbol before the user input prompt (bare token, renderers add a trailing space) | `❯` | | `help_header` | Header text for the `/help` command output | `(^_^)? Available Commands` | ### Other top-level keys | Key | Type | Description | Default | |-----|------|-------------|---------| | `tool_prefix` | string | Character prefixed to tool output lines in the CLI | `┊` | | `tool_emojis` | dict | Per-tool emoji overrides for spinners and progress (`{tool_name: emoji}`) | `{}` | | `banner_logo` | string | Rich-markup ASCII art logo (replaces the default CLAWAY_AGENT banner) | `""` | | `banner_hero` | string | Rich-markup hero art (replaces the default caduceus art) | `""` | ## Custom skins Create YAML files under `~/.claway/skins/`. User skins inherit missing values from the built-in `default` skin, so you only need to specify the keys you want to change. ### Full custom skin YAML template ```yaml # ~/.claway/skins/mytheme.yaml # Complete skin template — all keys shown. Delete any you don't need; # missing values automatically inherit from the 'default' skin. name: mytheme description: My custom theme colors: banner_border: "#CD7F32" banner_title: "#FFD700" banner_accent: "#FFBF00" banner_dim: "#B8860B" banner_text: "#FFF8DC" ui_accent: "#FFBF00" ui_label: "#4dd0e1" ui_ok: "#4caf50" ui_error: "#ef5350" ui_warn: "#ffa726" prompt: "#FFF8DC" input_rule: "#CD7F32" response_border: "#FFD700" session_label: "#DAA520" session_border: "#8B8682" status_bar_bg: "#1a1a2e" voice_status_bg: "#1a1a2e" selection_bg: "#333355" completion_menu_bg: "#1a1a2e" completion_menu_current_bg: "#333355" completion_menu_meta_bg: "#1a1a2e" completion_menu_meta_current_bg: "#333355" spinner: waiting_faces: - "(⚔)" - "(⛨)" - "(▲)" thinking_faces: - "(⚔)" - "(⌁)" - "(<>)" thinking_verbs: - "processing" - "analyzing" - "computing" - "evaluating" wings: - ["⟪⚡", "⚡⟫"] - ["⟪●", "●⟫"] branding: agent_name: "My Agent" welcome: "Welcome to My Agent! Type your message or /help for commands." goodbye: "See you later! ⚡" response_label: " ⚡ My Agent " prompt_symbol: "⚡" help_header: "(⚡) Available Commands" tool_prefix: "┊" # Per-tool emoji overrides (optional) tool_emojis: terminal: "⚔" web_search: "🔮" read_file: "📄" # Custom ASCII art banners (optional, Rich markup supported) # banner_logo: | # [bold #FFD700] MY AGENT [/] # banner_hero: | # [#FFD700] Custom art here [/] ``` ### Minimal custom skin example Since everything inherits from `default`, a minimal skin only needs to change what's different: ```yaml name: cyberpunk description: Neon terminal theme colors: banner_border: "#FF00FF" banner_title: "#00FFFF" banner_accent: "#FF1493" spinner: thinking_verbs: ["jacking in", "decrypting", "uploading"] wings: - ["⟨⚡", "⚡⟩"] branding: agent_name: "Cyber Agent" response_label: " ⚡ Cyber " tool_prefix: "▏" ``` ## Operational notes - Built-in skins load from `claway_cli/skin_engine.py`. - Unknown skins automatically fall back to `default`. - `/skin` updates the active CLI theme immediately for the current session. - User skins in `~/.claway/skins/` take precedence over built-in skins with the same name. - Skin changes via `/skin` are session-only. To make a skin your permanent default, set it in `config.yaml`. - The `banner_logo` and `banner_hero` fields support Rich console markup (e.g., `[bold #FF0000]text[/]`) for colored ASCII art. --- <!-- source: website/docs/user-guide/features/spotify.md --> # user-guide/features/spotify.md # Spotify Claway can control Spotify directly — playback, queue, search, playlists, saved tracks/albums, and listening history — using Spotify's official Web API with PKCE OAuth. Tokens are stored in `~/.claway/auth.json` and refreshed automatically on 401; you only log in once per machine (refresh tokens expire after ~6 months; re-run `claway auth spotify` when they do). Unlike Claway's built-in OAuth integrations (Google, GitHub Copilot, Codex), Spotify requires every user to register their own lightweight developer app. Spotify does not let third parties ship a public OAuth app that anyone can use. It takes about two minutes and `claway auth spotify` walks you through it. ## Prerequisites - A Spotify account. **Free** works for search, playlist, library, and activity tools. **Premium** is required for playback control (play, pause, skip, seek, volume, queue add, transfer). - Claway Agent installed and running. - For playback tools: an **active Spotify Connect device** — the Spotify app must be open on at least one device (phone, desktop, web player, speaker) so the Web API has something to control. If nothing is active you'll get a `403 Forbidden` with a "no active device" message; open Spotify on any device and retry. ## Setup ### One-shot: `claway tools` or first-run setup The fastest path. Run: ```bash claway tools ``` Scroll to `🎵 Spotify`, press space to toggle it on, then `s` to save. The same toggle is also available during the first-run `claway setup` / `claway setup tools` flow. Spotify stays opt-in, so enabling it there runs the same provider-aware configuration as `claway tools`. Claway drops you straight into the OAuth flow — if you don't have a Spotify app yet, it walks you through creating one inline. Once you finish, the toolset is enabled AND authenticated in one pass. If you prefer to do the steps separately (or you're re-authing later), use the two-step flow below. ### Two-step flow #### 1. Enable the toolset ```bash claway tools ``` Toggle `🎵 Spotify` on, save, and when the inline wizard opens, dismiss it (Ctrl+C). The toolset stays on; only the auth step is deferred. #### 2. Run the login wizard ```bash claway auth spotify ``` The 7 Spotify tools only appear in the agent's toolset after step 1 — they're off by default so users who don't want them don't ship extra tool schemas on every API call. If no `CLAWAY_SPOTIFY_CLIENT_ID` is set, Claway walks you through the app registration inline: 1. Opens `https://developer.spotify.com/dashboard` in your browser 2. Prints the exact values to paste into Spotify's "Create app" form 3. Prompts you for the Client ID you get back 4. Saves it to `~/.claway/.env` so future runs skip this step 5. Continues straight into the OAuth consent flow After you approve, tokens are written under `providers.spotify` in `~/.claway/auth.json`. The active inference provider is NOT changed — Spotify auth is independent of your LLM provider. ### Creating the Spotify app (what the wizard asks for) When the dashboard opens, click **Create app** and fill in: | Field | Value | |-------|-------| | App name | anything (e.g. `claway`) | | App description | anything (e.g. `personal Claway integration`) | | Website | leave blank | | Redirect URI | `http://127.0.0.1:43827/spotify/callback` | | Which API/SDKs? | check **Web API** | Agree to the terms and click **Save**. On the next page click **Settings** → copy the **Client ID** and paste it into the Claway prompt. That's the only value Claway needs — PKCE doesn't use a client secret. ### Running over SSH / in a headless environment If `SSH_CLIENT` or `SSH_TTY` is set, Claway skips the automatic browser open during both the wizard and the OAuth step. Copy the dashboard URL and the authorization URL Claway prints, open them in a browser on your local machine, and proceed normally — the local HTTP listener still runs on the remote host on port `43827`. Your laptop's browser can't reach the remote loopback without an SSH local-forward: ```bash ssh -N -L 43827:127.0.0.1:43827 user@remote-host ``` For jump-box / bastion setups and other gotchas (mosh, tmux, port conflicts), see [OAuth over SSH / Remote Hosts](../../guides/oauth-over-ssh.md). ## Verify ```bash claway auth status spotify ``` Shows whether tokens are present and when the access token expires. Refresh is automatic: when any Spotify API call returns 401, the client exchanges the refresh token and retries once. Refresh tokens persist across Claway restarts, so you only re-auth if you revoke the app in your Spotify account settings or run `claway auth logout spotify`. ## Using it Once logged in, the agent has access to 7 Spotify tools. You talk to the agent naturally — it picks the right tool and action. For the best behavior, the agent loads a companion skill that teaches canonical usage patterns (single-search-then-play, when not to preflight `get_state`, etc.). ``` > play some miles davis > what am I listening to > add this track to my Late Night Jazz playlist > skip to the next song > make a new playlist called "Focus 2026" and add the last three songs I played > which of my saved albums are by Radiohead > search for acoustic covers of Blackbird > transfer playback to my kitchen speaker ``` ### Tool reference All playback-mutating actions accept an optional `device_id` to target a specific device. If omitted, Spotify uses the currently active device. #### `spotify_playback` Control and inspect playback, plus fetch recently played history. | Action | Purpose | Premium? | |--------|---------|----------| | `get_state` | Full playback state (track, device, progress, shuffle/repeat) | No | | `get_currently_playing` | Just the current track (returns empty on 204 — see below) | No | | `play` | Start/resume playback. Optional: `context_uri`, `uris`, `offset`, `position_ms` | Yes | | `pause` | Pause playback | Yes | | `next` / `previous` | Skip track | Yes | | `seek` | Jump to `position_ms` | Yes | | `set_repeat` | `state` = `track` / `context` / `off` | Yes | | `set_shuffle` | `state` = `true` / `false` | Yes | | `set_volume` | `volume_percent` = 0-100 | Yes | | `recently_played` | Last played tracks. Optional `limit`, `before`, `after` (Unix ms) | No | #### `spotify_devices` | Action | Purpose | |--------|---------| | `list` | Every Spotify Connect device visible to your account | | `transfer` | Move playback to `device_id`. Optional `play: true` starts playback on transfer | ### Home Assistant-managed speakers If Home Assistant manages speakers that already support Spotify Connect (for example Sonos, Echo, Nest, or other Connect-capable speakers), they appear in `spotify_devices list` automatically whenever Spotify can see them. Claway does not need a Home Assistant ↔ Spotify bridge for this path — Spotify handles the device routing natively. Ask Claway to transfer playback by the speaker's display name (for example, “transfer Spotify to the kitchen speaker”), or call `spotify_devices list` and pass the exact `device_id` to `spotify_devices transfer` when scripting. If the speaker is missing, open the Spotify app or the speaker's Spotify integration once so Spotify registers it as an active Connect target. #### `spotify_queue` | Action | Purpose | Premium? | |--------|---------|----------| | `get` | Currently queued tracks | No | | `add` | Append `uri` to the queue | Yes | #### `spotify_search` Search the catalog. `query` is required. Optional: `types` (array of `track` / `album` / `artist` / `playlist` / `show` / `episode`), `limit`, `offset`, `market`. #### `spotify_playlists` | Action | Purpose | Required args | |--------|---------|---------------| | `list` | User's playlists | — | | `get` | One playlist + tracks | `playlist_id` | | `create` | New playlist | `name` (+ optional `description`, `public`, `collaborative`) | | `add_items` | Add tracks | `playlist_id`, `uris` (optional `position`) | | `remove_items` | Remove tracks | `playlist_id`, `uris` (+ optional `snapshot_id`) | | `update_details` | Rename / edit | `playlist_id` + any of `name`, `description`, `public`, `collaborative` | #### `spotify_albums` | Action | Purpose | Required args | |--------|---------|---------------| | `get` | Album metadata | `album_id` | | `tracks` | Album track list | `album_id` | #### `spotify_library` Unified access to saved tracks and saved albums. Pick the collection with the `kind` arg. | Action | Purpose | |--------|---------| | `list` | Paginated library listing | | `save` | Add `ids` / `uris` to library | | `remove` | Remove `ids` / `uris` from library | Required: `kind` = `tracks` or `albums`, plus `action`. ### Feature matrix: Free vs Premium Read-only tools work on Free accounts. Anything that mutates playback or the queue requires Premium. | Works on Free | Premium required | |---------------|------------------| | `spotify_search` (all) | `spotify_playback` — play, pause, next, previous, seek, set_repeat, set_shuffle, set_volume | | `spotify_playback` — get_state, get_currently_playing, recently_played | `spotify_queue` — add | | `spotify_devices` — list | `spotify_devices` — transfer | | `spotify_queue` — get | | | `spotify_playlists` (all) | | | `spotify_albums` (all) | | | `spotify_library` (all) | | ## Scheduling: Spotify + cron Because Spotify tools are regular Claway tools, a cron job running in a Claway session can trigger playback on any schedule. No new code needed. ### Morning wake-up playlist ```bash claway cron add \ --name "morning-commute" \ "0 7 * * 1-5" \ "Transfer playback to my kitchen speaker and start my 'Morning Commute' playlist. Volume to 40. Shuffle on." ``` What happens at 7am every weekday: 1. Cron spins up a headless Claway session. 2. Agent reads the prompt, calls `spotify_devices list` to find "kitchen speaker" by name, then `spotify_devices transfer` → `spotify_playback set_volume` → `spotify_playback set_shuffle` → `spotify_search` + `spotify_playback play`. 3. Music starts on the target speaker. Total cost: one session, a few tool calls, no human input. ### Wind-down at night ```bash claway cron add \ --name "wind-down" \ "30 22 * * *" \ "Pause Spotify. Then set volume to 20 so it's quiet when I start it again tomorrow." ``` ### Gotchas - **An active device must exist when the cron fires.** If no Spotify client is running (phone/desktop/Connect speaker), playback actions return `403 no active device`. For morning playlists, the trick is to target a device that's always on (Sonos, Echo, a smart speaker) rather than your phone. - **Premium required for anything that mutates playback** — play, pause, skip, volume, transfer. Read-only cron jobs (scheduled "email me my recently played tracks") work fine on Free. - **The cron agent inherits your active toolsets.** Spotify must be enabled in `claway tools` for the cron session to see the Spotify tools. - **Cron jobs run with `skip_memory=True`** so they don't write to your memory store. Full cron reference: [Cron Jobs](./cron). ## Sign out ```bash claway auth logout spotify ``` Removes tokens from `~/.claway/auth.json`. To also clear the app config, delete `CLAWAY_SPOTIFY_CLIENT_ID` (and `CLAWAY_SPOTIFY_REDIRECT_URI` if you set it) from `~/.claway/.env`, or run the wizard again. To revoke the app on Spotify's side, visit [Apps connected to your account](https://www.spotify.com/account/apps/) and click **REMOVE ACCESS**. ## Troubleshooting **`403 Forbidden — Player command failed: No active device found`** — You need Spotify running on at least one device. Open the Spotify app on your phone, desktop, or web player, start any track for a second to register it, and retry. `spotify_devices list` shows what's currently visible. **`403 Forbidden — Premium required`** — You're on a Free account trying to use a playback-mutating action. See the feature matrix above. **`204 No Content` on `get_currently_playing`** — nothing is currently playing on any device. This is Spotify's normal response, not an error; Claway surfaces it as an explanatory empty result (`is_playing: false`). **`INVALID_CLIENT: Invalid redirect URI`** — the redirect URI in your Spotify app settings doesn't match what Claway is using. The default is `http://127.0.0.1:43827/spotify/callback`. Either add that to your app's allowed redirect URIs, or set `CLAWAY_SPOTIFY_REDIRECT_URI` in `~/.claway/.env` to whatever you registered. **`429 Too Many Requests`** — Spotify's rate limit. Claway returns a friendly error; wait a minute and retry. If this persists, you're probably running a tight loop in a script — Spotify's quota resets roughly every 30 seconds. **`401 Unauthorized` keeps coming back** — Your refresh token was revoked (usually because you removed the app from your account, or the app was deleted). Run `claway auth spotify` again. **Wizard doesn't open the browser** — If you're over SSH or in a container without a display, Claway detects it and skips the auto-open. Copy the dashboard URL it prints and open it manually. ## Advanced: custom scopes By default Claway requests the scopes needed for every shipped tool. Override if you want to restrict access: ```bash claway auth spotify --scope "user-read-playback-state user-modify-playback-state playlist-read-private" ``` Scope reference: [Spotify Web API scopes](https://developer.spotify.com/documentation/web-api/concepts/scopes). If you request fewer scopes than a tool needs, that tool's calls will fail with 403. ## Advanced: custom client ID / redirect URI ```bash claway auth spotify --client-id <id> --redirect-uri http://localhost:3000/callback ``` Or set them permanently in `~/.claway/.env`: ``` CLAWAY_SPOTIFY_CLIENT_ID=<your_id> CLAWAY_SPOTIFY_REDIRECT_URI=http://localhost:3000/callback ``` The redirect URI must be allow-listed in your Spotify app's settings. The default works for almost everyone — only change it if port 43827 is taken. ## Where things live | File | Contents | |------|----------| | `~/.claway/auth.json` → `providers.spotify` | access token, refresh token, expiry, scope, redirect URI | | `~/.claway/.env` | `CLAWAY_SPOTIFY_CLIENT_ID`, optional `CLAWAY_SPOTIFY_REDIRECT_URI` | | Spotify app | owned by you at [developer.spotify.com/dashboard](https://developer.spotify.com/dashboard); contains the Client ID and the redirect URI allow-list | --- <!-- source: website/docs/user-guide/features/tool-search.md --> # user-guide/features/tool-search.md # Tool Search When you have many MCP servers or non-core plugin tools attached to a session, their JSON schemas can consume a substantial fraction of the context window on every turn — even when only a few of them are relevant to what the user actually asked for. **Tool Search** is Claway's opt-in progressive-disclosure layer for that problem. When activated, MCP and plugin tools are replaced in the model-visible tools array by three bridge tools, and the model loads each specific tool's schema on demand. :::info Built-in Claway tools never defer The tools that make up Claway's core capability set (`terminal`, `read_file`, `write_file`, `patch`, `search_files`, `todo`, `memory`, `browser_*`, `web_search`, `web_extract`, `clarify`, `execute_code`, `delegate_task`, `session_search`, and the rest of `_CLAWAY_CORE_TOOLS`) are *always* loaded directly. Only MCP tools and non-core plugin tools are eligible for deferral. ::: ## How it works When Tool Search activates for a turn, the model sees three new tools in place of the deferred ones: ``` tool_search(query, limit?) — search the deferred-tool catalog tool_describe(name) — load the full schema for one tool tool_call(name, arguments) — invoke a deferred tool ``` A typical interaction looks like: ``` Model: tool_search("create a github issue") → { matches: [{ name: "mcp_github_create_issue", ... }, ...] } Model: tool_describe("mcp_github_create_issue") → { parameters: { type: "object", properties: { ... } } } Model: tool_call("mcp_github_create_issue", { title: "...", body: "..." }) → { ok: true, issue_number: 42 } ``` When the model invokes `tool_call`, Claway **unwraps the bridge** and dispatches the underlying tool exactly as if the model had called it directly. Pre-tool-call hooks, guardrails, approval prompts, and post-tool-call hooks all run against the real tool name — not against `tool_call`. The activity feed in the CLI and gateway also unwraps so you see the underlying tool, not the bridge. ## When does it activate? By default Tool Search runs in `auto` mode: it activates only when the deferrable tool schemas would consume at least 10% of the active model's context window. Below that, the tools-array assembly is a pure pass-through and you pay no overhead. This decision is re-evaluated every time the tools array is built, so: - A session with just a few MCP tools and a long context model never activates Tool Search. - A session with many MCP servers attached (15+ tools typically) starts activating it. - Removing MCP servers mid-session correctly returns to direct exposure on the next assembly. ## Configuration ```yaml tools: tool_search: enabled: auto # auto (default), on, or off threshold_pct: 10 # percentage of context — only used in auto mode search_default_limit: 5 max_search_limit: 20 ``` | Key | Default | Meaning | | --- | --- | --- | | `enabled` | `auto` | `auto` activates above threshold; `on` always activates if there's at least one deferrable tool; `off` disables entirely. | | `threshold_pct` | `10` | Percentage of context length at which `auto` mode kicks in. Range 0–100. | | `search_default_limit` | `5` | Hits returned when the model calls `tool_search` without a `limit`. | | `max_search_limit` | `20` | Hard upper bound the model can request via `limit`. Range 1–50. | You can also flip the legacy boolean shape: ```yaml tools: tool_search: true # equivalent to {enabled: auto} ``` ## When NOT to use it Tool Search trades a fixed per-turn token cost (the three bridge tool schemas, ~300 tokens) and at least one extra round trip (search → describe → call) for the savings on the deferred schemas. It's a clear win when you have many tools and use few per turn; it's overhead when you have few tools total. The `auto` default handles this for you. If you set `enabled: on` unconditionally, expect a slight per-turn cost on small toolsets. ## Trade-offs that don't go away These come from the prompt-cache integrity invariant — they are inherent to any progressive-disclosure design, not specific to this implementation: - **One extra round trip on cold tools.** The first time the model needs a deferred tool, it spends one or two extra model calls to find and load the schema. The token savings on the static side are real, but a portion is paid back at runtime. - **No cache benefit on deferred schemas.** A loaded `tool_describe` result enters the conversation history (so it does get cached on subsequent turns) but it never benefits from the system-prompt cache prefix. - **Model-quality dependence.** Tool Search assumes the model can write a reasonable search query for the tool it wants. Smaller models do this less well; the published Anthropic numbers (49% → 74% on Opus 4 with vs. without tool search) show the upside but also that ~26 points of accuracy is still retrieval failure. - **Toolset edits invalidate cache.** Adding or removing a tool mid- session changes the bridge tools' descriptions (which include the count of deferred tools) and the catalog, so the prompt cache is invalidated. This is the same trade-off as any toolset edit. ## Implementation details - **Retrieval:** BM25 over tokenized tool name + description + parameter names. Falls back to a literal substring match on the tool name when BM25 returns no positive-score hits, which protects against zero-IDF degenerate cases (e.g. searching `"github"` against a catalog where every tool name contains "github"). - **Catalog is stateless across turns.** It rebuilds from the current tool-defs list every assembly — no session-keyed `Map`. This avoids the class of bug where a stored catalog drifts out of sync with the live tool registry. - **The catalog is scoped to the session's toolsets.** `tool_search`, `tool_describe`, and `tool_call` only ever see and invoke tools the session was actually granted. A subagent, kanban worker, or gateway session restricted to a subset of toolsets cannot use the bridge to discover or call a tool outside that subset — the deferred catalog is the deferrable slice of the session's own enabled/disabled toolsets, not the whole process registry. - **No JS sandbox.** Claway uses the simpler "structured tools" mode (search / describe / call as plain functions). The JS-sandbox "code mode" some other implementations offer is a large surface area; we skip it. ## See also - `tools/tool_search.py` — the implementation - `tests/tools/test_tool_search.py` — the regression suite - The `openclaw-tool-search-report` PDF in the original implementation PR for the research that shaped the design --- <!-- source: website/docs/user-guide/features/web-search.md --> # user-guide/features/web-search.md # Web Search & Extract Claway Agent includes two model-callable web tools backed by multiple providers: - **`web_search`** — search the web and return ranked results - **`web_extract`** — fetch and extract readable content from one or more URLs Both are configured through a single backend selection. Providers are chosen via `claway tools` or set directly in `config.yaml`. ## Backends | Provider | Env Var | Search | Extract | Free tier | |----------|---------|--------|---------|-----------| | **Firecrawl** (default) | `FIRECRAWL_API_KEY` | ✔ | ✔ | 500 credits/mo | | **SearXNG** | `SEARXNG_URL` | ✔ | — | ✔ Free (self-hosted) | | **Brave Search (free tier)** | `BRAVE_SEARCH_API_KEY` | ✔ | — | 2 000 queries/mo | | **DDGS (DuckDuckGo)** | — (no key) | ✔ | — | ✔ Free | | **Tavily** | `TAVILY_API_KEY` | ✔ | ✔ | 1 000 searches/mo | | **Exa** | `EXA_API_KEY` | ✔ | ✔ | 1 000 searches/mo | | **Parallel** | `PARALLEL_API_KEY` | ✔ | ✔ | Paid | | **xAI (Grok)** | `XAI_API_KEY` or `claway auth login xai-oauth` | ✔ | — | Paid (SuperGrok or per-token) | Brave Search, DDGS, and xAI are **search-only** — pair any of them with Firecrawl/Tavily/Exa/Parallel when you also need `web_extract`. DDGS uses the [`ddgs` Python package](https://pypi.org/project/ddgs/) under the hood; if it isn't already installed, run `pip install ddgs` (or let Claway lazy-install it on first use). xAI runs Grok's server-side `web_search` tool on the Responses API — results are LLM-generated rather than index-backed, so titles, descriptions, and URL choice are all model output (see the [trust-model caveat](#xai-grok) below). **Per-capability split:** you can use different providers for search and extract independently — for example SearXNG (free) for search and Firecrawl for extract. See [Per-capability configuration](#per-capability-configuration) below. --- ## How `web_extract` handles long pages Backends return raw page markdown, which can be huge (forum threads, docs sites, news articles with embedded comments). To keep your context window usable and your costs down, `web_extract` runs returned content through the **`web_extract` auxiliary model** before handing it to the agent. Behavior is purely size-driven: | Page size (characters) | What happens | |------------------------|--------------| | Under 5 000 | Returned as-is — no LLM call, full markdown reaches the agent | | 5 000 – 500 000 | Single-pass summary via the `web_extract` auxiliary model, capped at ~5 000 chars of output | | 500 000 – 2 000 000 | Chunked: split into 100 k-char chunks, summarize each in parallel, then synthesize a final summary (~5 000 chars) | | Over 2 000 000 | Refused with a hint to use a more focused source URL | The summary keeps quotes, code blocks, and key facts in their original formatting — it's a content compressor, not a paraphraser. If summarization fails or times out, Claway falls back to the first ~5 000 chars of raw content rather than a useless error. ### Which model does the summarizing? The `web_extract` auxiliary task. By default (`auxiliary.web_extract.provider: "auto"`), this is your **main chat model** — same provider, same model as `claway model`. That's fine for most setups, but on expensive reasoning models (Opus, MiniMax M2.7, etc.) every long-page extract adds meaningful cost. To route extraction summaries to a cheap, fast model regardless of your main: ```yaml # ~/.claway/config.yaml auxiliary: web_extract: provider: openrouter model: google/gemini-3-flash-preview timeout: 360 # seconds; raise if you hit summarization timeouts ``` Or pick interactively: `claway model` → **Configure auxiliary models** → `web_extract`. See [Auxiliary Models](/user-guide/configuration#auxiliary-models) for the full reference and per-task override patterns. ### When summarization gets in the way If you specifically need raw, unsummarized page content — for example, you're scraping a structured page where the LLM summary would drop important fields — use `browser_navigate` + `browser_snapshot` instead. The browser tool returns the live accessibility tree without auxiliary-model rewriting (subject to its own 8 000-char snapshot cap on huge pages). --- ## Setup ### Quick setup via `claway tools` Run `claway tools`, navigate to **Web Search & Extract**, and pick a provider. The wizard prompts for the required URL or API key and writes it to your config. ```bash claway tools ``` --- ### Firecrawl (default) Full-featured search and extract. Recommended for most users. ```bash # ~/.claway/.env FIRECRAWL_API_KEY=fc-your-key-here ``` Get a key at [firecrawl.dev](https://firecrawl.dev). The free tier includes 500 credits/month. **Self-hosted Firecrawl:** Point at your own instance instead of the cloud API: ```bash # ~/.claway/.env FIRECRAWL_API_URL=http://localhost:3002 ``` When `FIRECRAWL_API_URL` is set, the API key is optional (disable server auth with `USE_DB_AUTHENTICATION=false`). --- ### SearXNG (free, self-hosted) SearXNG is a privacy-respecting, open-source metasearch engine that aggregates results from 70+ search engines. **No API key required** — just point Claway at a running SearXNG instance. SearXNG is **search-only** — `web_extract` requires a separate extract provider. #### Option A — Self-host with Docker (recommended) This gives you a private instance with no rate limits. **1. Create a working directory:** ```bash mkdir -p ~/searxng/searxng cd ~/searxng ``` **2. Write a `docker-compose.yml`:** ```yaml # ~/searxng/docker-compose.yml services: searxng: image: searxng/searxng:latest container_name: searxng ports: - "8888:8080" volumes: - ./searxng:/etc/searxng:rw environment: - SEARXNG_BASE_URL=http://localhost:8888/ restart: unless-stopped ``` **3. Start the container:** ```bash docker compose up -d ``` **4. Enable the JSON API format:** SearXNG ships with JSON output disabled by default. Copy the generated config and enable it: ```bash # Copy the auto-generated config out of the container docker cp searxng:/etc/searxng/settings.yml ~/searxng/searxng/settings.yml ``` Open `~/searxng/searxng/settings.yml`. If `use_default_settings: true` is present, the file only contains your overrides. All other settings are inherited from the built-in defaults. To enable JSON responses for Claway, add the following override: ```yaml search: formats: - html - json ``` Your `settings.yml` should look similar to: ```yaml # Read the documentation before extending the defaults: # https://docs.searxng.org/admin/settings/ use_default_settings: true server: secret_key: "abcdef12345678" image_proxy: true search: formats: - html - json ``` **5. Restart to apply:** ```bash docker cp ~/searxng/searxng/settings.yml searxng:/etc/searxng/settings.yml docker restart searxng ``` **6. Verify it works:** ```bash curl -s "http://localhost:8888/search?q=test&format=json" | python3 -c \ "import sys,json; d=json.load(sys.stdin); print(f'{len(d[\"results\"])} results')" ``` You should see something like `10 results`. If you get a `403 Forbidden`, JSON format is still disabled — recheck step 4. **7. Configure Claway:** ```bash # ~/.claway/.env SEARXNG_URL=http://localhost:8888 ``` Then select SearXNG as the search backend in `~/.claway/config.yaml`: ```yaml web: search_backend: "searxng" ``` Or set via `claway tools` → Web Search & Extract → SearXNG. --- #### Option B — Use a public instance Public SearXNG instances are listed at [searx.space](https://searx.space/). Filter by instances that have **JSON format enabled** (shown in the table). ```bash # ~/.claway/.env SEARXNG_URL=https://searx.example.com ``` :::caution Public instances Public instances have rate limits, variable uptime, and may disable JSON format at any time. For production use, self-hosting is strongly recommended. ::: --- #### Pair SearXNG with an extract provider SearXNG handles search; you need a separate provider for `web_extract`. Use the per-capability keys: ```yaml # ~/.claway/config.yaml web: search_backend: "searxng" extract_backend: "firecrawl" # or tavily, exa, parallel ``` With this config, Claway uses SearXNG for all search queries and Firecrawl for URL extraction — combining free search with high-quality extraction. --- ### Tavily AI-optimised search and extract with a generous free tier. ```bash # ~/.claway/.env TAVILY_API_KEY=tvly-your-key-here ``` Get a key at [app.tavily.com](https://app.tavily.com/home). The free tier includes 1 000 searches/month. --- ### Exa Neural search with semantic understanding. Good for research and finding conceptually related content. ```bash # ~/.claway/.env EXA_API_KEY=your-exa-key-here ``` Get a key at [exa.ai](https://exa.ai). The free tier includes 1 000 searches/month. --- ### Parallel AI-native search and extraction with deep research capabilities. ```bash # ~/.claway/.env PARALLEL_API_KEY=your-parallel-key-here ``` Get access at [parallel.ai](https://parallel.ai). --- ### xAI (Grok) {#xai-grok} Routes `web_search` through Grok's server-side [web_search tool](https://docs.x.ai/developers/tools/web-search) on the Responses API. Grok runs the actual searching and returns the top results as structured JSON. Works with either credential path — no new env vars, no new setup wizard: ```bash # ~/.claway/.env (env-var path) XAI_API_KEY=sk-xai-your-key-here ``` or for SuperGrok subscribers: ```bash claway auth login xai-oauth ``` Then select xAI as the search backend: ```yaml # ~/.claway/config.yaml web: backend: "xai" ``` **Optional knobs:** ```yaml web: backend: "xai" xai: model: grok-build-0.1 # reasoning model required by web_search (default) allowed_domains: # optional, max 5 — mutex with excluded_domains - arxiv.org excluded_domains: # optional, max 5 - example-spam.com timeout: 90 # seconds (default) ``` **Search-only** — pair with Firecrawl / Tavily / Exa / Parallel if you also need `web_extract`. On 401 the provider performs a single forced OAuth-token refresh and retries (covers mid-window revocation and opaque tokens the proactive expiry check can't decode); env-var credentials skip the retry. :::caution Trust model Unlike index-backed providers (Brave, Tavily, Exa) which return verbatim search-engine results, xAI is an LLM choosing which URLs to surface and writing the titles and descriptions itself. The *content* of the query influences the output, so a maliciously crafted query (e.g. injected via untrusted upstream input the agent picked up) can in principle steer Grok into emitting attacker-chosen URLs. Treat returned URLs the same way you'd treat any model-generated link — validate before fetching, especially if the query came from untrusted input. ::: --- ## Configuration ### Single backend Set one provider for all web capabilities: ```yaml # ~/.claway/config.yaml web: backend: "searxng" # firecrawl | searxng | brave-free | ddgs | tavily | exa | parallel | xai ``` ### Per-capability configuration Use different providers for search vs extract. This lets you combine free search (SearXNG) with a paid extract provider, or vice versa: ```yaml # ~/.claway/config.yaml web: search_backend: "searxng" # used by web_search extract_backend: "firecrawl" # used by web_extract ``` When per-capability keys are empty, both fall through to `web.backend`. When `web.backend` is also empty, the backend is auto-detected from whichever API key/URL is present. **Priority order (per capability):** 1. `web.search_backend` / `web.extract_backend` (explicit per-capability) 2. `web.backend` (shared fallback) 3. Auto-detect from environment variables ### Auto-detection If no backend is explicitly configured, Claway picks the first available one based on which credentials are set: | Credential present | Auto-selected backend | |--------------------|-----------------------| | `FIRECRAWL_API_KEY` or `FIRECRAWL_API_URL` | firecrawl | | `PARALLEL_API_KEY` | parallel | | `TAVILY_API_KEY` | tavily | | `EXA_API_KEY` | exa | | `SEARXNG_URL` | searxng | xAI Web Search is **not** in the auto-detection chain — having `XAI_API_KEY` set (or being signed in via xAI Grok OAuth) does not automatically route web traffic through xAI, since those credentials are also used for inference / TTS / image gen and the user may want a different backend for web. Opt in explicitly with `web.backend: "xai"`. --- ## Verify your setup Run `claway setup` to see which web backend is detected: ``` ✅ Web Search & Extract (searxng) ``` Or check via the CLI: ```bash # Activate the venv and run the web tools module directly source ~/.claway/claway/.venv/bin/activate python -m tools.web_tools ``` This prints the active backend and its status: ``` ✅ Web backend: searxng Using SearXNG (search only): http://localhost:8888 ``` --- ## Troubleshooting ### `web_search` returns `{"success": false}` - Check `SEARXNG_URL` is reachable: `curl -s "http://localhost:8888/search?q=test&format=json"` - If you get HTTP 403, JSON format is disabled — add `json` to the `formats` list in `settings.yml` and restart - If you get a connection error, the container may not be running: `docker ps | grep searxng` ### `web_extract` says "search-only backend" SearXNG cannot extract URL content. Set `web.extract_backend` to a provider that supports extraction: ```yaml web: search_backend: "searxng" extract_backend: "firecrawl" # or tavily / exa / parallel ``` ### SearXNG returns 0 results Some public instances disable certain search engines or categories. Try: - A different query - A different public instance from [searx.space](https://searx.space/) - Self-hosting your own instance for reliable results ### Rate limited on a public instance Switch to a self-hosted instance (see [Option A](#option-a--self-host-with-docker-recommended) above). With Docker, your own instance has no rate limits. ### `web_extract` returns truncated content with a "summarization timed out" note The auxiliary model didn't finish summarizing within the configured timeout. Either: - Raise `auxiliary.web_extract.timeout` in `config.yaml` (default 360s on fresh installs, 30s if the key is missing) - Switch the `web_extract` auxiliary task to a faster model (e.g. `google/gemini-3-flash-preview`) — see [How `web_extract` handles long pages](#how-web_extract-handles-long-pages) - For pages where summarization is the wrong tool, use `browser_navigate` instead --- ## Optional skill: `searxng-search` For agents that need to use SearXNG via `curl` directly (e.g. as a fallback when the web toolset isn't available), install the `searxng-search` optional skill: ```bash claway skills install official/research/searxng-search ``` This adds a skill that teaches the agent how to: - Call the SearXNG JSON API via `curl` or Python - Filter by category (`general`, `news`, `science`, etc.) - Handle pagination and error cases - Fall back gracefully when SearXNG is unreachable --- <!-- source: website/docs/user-guide/features/x-search.md --> # user-guide/features/x-search.md # X (Twitter) Search The `x_search` tool lets the agent search X (Twitter) posts, profiles, and threads directly. It's backed by xAI's built-in `x_search` tool on the Responses API at `https://api.x.ai/v1/responses` — Grok itself runs the search server-side and returns synthesized results with citations to the originating posts. **Use this instead of `web_search`** when you specifically want current discussion, reactions, or claims **on X**. For general web pages, keep using `web_search` / `web_extract`. ## Authentication `x_search` registers when **either** xAI credential path is available: | Credential | Source | Setup | |------------|--------|-------| | **SuperGrok / X Premium+ OAuth** (preferred) | Browser login at `accounts.x.ai`, refreshed automatically | `claway auth add xai-oauth` — see [xAI Grok OAuth (SuperGrok / X Premium+)](../../guides/xai-grok-oauth.md) | | **`XAI_API_KEY`** | Paid xAI API key | Set in `~/.claway/.env` | Both hit the same endpoint with the same payload — the only difference is the bearer token. **When both are configured, SuperGrok OAuth wins** so x_search runs against your subscription quota instead of paid API spend. The tool's `check_fn` runs the xAI credential resolver every time the model's tool list is rebuilt. A `True` return means the bearer is fetchable AND non-empty AND (if it had expired) successfully refreshed. Revoked tokens with a failed refresh hide the tool from the schema; the model simply can't see it. ## Enabling the tool Auto-enables when xAI credentials (OAuth token or `XAI_API_KEY`) are present. Disable explicitly via `claway tools` → Search → x_search if you don't want this. ```bash claway tools # → 🐦 X (Twitter) Search (press space to toggle on) ``` The picker offers two credential choices: 1. **xAI Grok OAuth (SuperGrok / Premium+)** — opens the browser to `accounts.x.ai` if you're not already logged in 2. **xAI API key** — prompts for `XAI_API_KEY` Either choice satisfies the gating. You can pick whichever credentials you already have; the tool works identically with both. If both end up configured, OAuth is preferred at call time. ## Configuration ```yaml # ~/.claway/config.yaml x_search: # xAI model used for the Responses call. # grok-4.20-reasoning is the recommended default; any Grok model # with x_search tool access works. model: grok-4.20-reasoning # Request timeout in seconds. x_search can take 60–120s for # complex queries — the default is generous. Minimum: 30. timeout_seconds: 180 # Number of automatic retries on 5xx / ReadTimeout / ConnectionError. # Each retry backs off (1.5x attempt seconds, capped at 5s). retries: 2 ``` ## Tool parameters The agent calls `x_search` with these arguments: | Parameter | Type | Description | |-----------|------|-------------| | `query` | string (required) | What to look up on X. | | `allowed_x_handles` | string array | Optional list of handles to include **exclusively** (max 10). Leading `@` is stripped. | | `excluded_x_handles` | string array | Optional list of handles to exclude (max 10). Mutually exclusive with `allowed_x_handles`. | | `from_date` | string | Optional `YYYY-MM-DD` start date. | | `to_date` | string | Optional `YYYY-MM-DD` end date. | | `enable_image_understanding` | boolean | Ask xAI to analyze images attached to matching posts. | | `enable_video_understanding` | boolean | Ask xAI to analyze videos attached to matching posts. | The tool returns JSON with: - `answer` — synthesized text response from Grok - `citations` — citations returned by the Responses API top-level field - `inline_citations` — `url_citation` annotations extracted from the message body (each with `url`, `title`, `start_index`, `end_index`) - `degraded` — `true` when any narrowing filter (`allowed_x_handles`, `excluded_x_handles`, `from_date`, `to_date`) was set AND both citation channels came back empty. In that case the `answer` was synthesized from the model's own knowledge rather than the X index, so treat it as unsourced. `false` otherwise (including the "no filters set" case — a broad unsourced answer is just an answer, not a filter miss) - `degraded_reason` — short string naming which filters were active, or `null` when `degraded` is `false` - `credential_source` — `"xai-oauth"` if OAuth resolved, `"xai"` if API key resolved - `model`, `query`, `provider`, `tool`, `success` ### Date validation `from_date` / `to_date` are validated client-side before the HTTP call: - Both, if provided, must parse as `YYYY-MM-DD`. - When both are set, `from_date` must be on or before `to_date`. - `from_date` must not be later than today UTC — no posts can exist in a window that hasn't started yet, so the call would be guaranteed to return zero citations. - `to_date` in the future is allowed (callers may legitimately request "from yesterday to tomorrow" to catch posts as they arrive). Validation failures surface as a structured `{"error": "..."}` tool result, never as an HTTP call to xAI. ## Example Talking to the agent: > What are people on X saying about the new Grok image features? Focus on responses from @xai. The agent will: 1. Call `x_search` with `query="reactions to new Grok image features"`, `allowed_x_handles=["xai"]` 2. Get back a synthesized answer plus a list of citations linking to specific posts 3. Reply with the answer and references ## Troubleshooting ### "No xAI credentials available" The tool surfaces this when both auth paths fail. Either set `XAI_API_KEY` in `~/.claway/.env` or run `claway auth add xai-oauth` and complete the browser login. Then restart your session so the agent re-reads the tool registry. ### "`x_search` is not enabled for this model" The configured `x_search.model` doesn't have access to the server-side `x_search` tool. Switch to `grok-4.20-reasoning` (the default) or another Grok model that supports it. Check the [xAI documentation](https://docs.x.ai/) for the current list. ### Tool doesn't appear in the schema Two possible causes: 1. **Toolset not enabled.** Run `claway tools` and confirm `🐦 X (Twitter) Search` is checked. 2. **No xAI credentials.** The check_fn returns False, so the schema stays hidden. Run `claway auth status` to confirm xai-oauth login state, and check that `XAI_API_KEY` is set (if you're using the API-key path). ### `degraded: true` — answer with no citations When you used `allowed_x_handles`, `excluded_x_handles`, or a date range and the response comes back with `degraded: true`, xAI's X index returned no matching posts but Grok still produced a synthesized answer from its own training data. The answer is unsourced — do not treat it as a real X result. Causes worth checking: - **Typo in the handle.** Strip the `@`, double-check spelling, and confirm the account exists. - **Date range too narrow** or sliding past today's posts; widen and retry. - **xAI index gap.** Some active accounts intermittently fail to surface in `x_search` even when they post regularly. Retry after a few minutes, or use the `xurl` skill for direct X API reads when you need an exact handle's timeline. ## See Also - [xAI Grok OAuth (SuperGrok / Premium+)](../../guides/xai-grok-oauth.md) — the OAuth setup guide - [Web Search & Extract](web-search.md) — for general (non-X) web search - [Tools Reference](../../reference/tools-reference.md) — full tool catalog --- <!-- source: website/docs/user-guide/git-worktrees.md --> # Git Worktrees # Git Worktrees Claway Agent is often used on large, long‑lived repositories. When you want to: - Run **multiple agents in parallel** on the same project, or - Keep experimental refactors isolated from your main branch, Git **worktrees** are the safest way to give each agent its own checkout without duplicating the entire repository. This page shows how to combine worktrees with Claway so each session has a clean, isolated working directory. ## Why Use Worktrees with Claway? Claway treats the **current working directory** as the project root: - CLI: the directory where you run `claway` or `claway chat` - Messaging gateways: the directory set by `terminal.cwd` in `~/.claway/config.yaml` If you run multiple agents in the **same checkout**, their changes can interfere with each other: - One agent may delete or rewrite files the other is using. - It becomes harder to understand which changes belong to which experiment. With worktrees, each agent gets: - Its **own branch and working directory** - Its **own Checkpoint Manager history** for `/rollback` See also: [Checkpoints and /rollback](./checkpoints-and-rollback.md). ## Quick Start: Creating a Worktree From your main repository (containing `.git/`), create a new worktree for a feature branch: ```bash # From the main repo root cd /path/to/your/repo # Create a new branch and worktree in ../repo-feature git worktree add ../repo-feature feature/claway-experiment ``` This creates: - A new directory: `../repo-feature` - A new branch: `feature/claway-experiment` checked out in that directory Now you can `cd` into the new worktree and run Claway there: ```bash cd ../repo-feature # Start Claway in the worktree claway ``` Claway will: - See `../repo-feature` as the project root. - Use that directory for context files, code edits, and tools. - Use a **separate checkpoint history** for `/rollback` scoped to this worktree. ## Running Multiple Agents in Parallel You can create multiple worktrees, each with its own branch: ```bash cd /path/to/your/repo git worktree add ../repo-experiment-a feature/claway-a git worktree add ../repo-experiment-b feature/claway-b ``` In separate terminals: ```bash # Terminal 1 cd ../repo-experiment-a claway # Terminal 2 cd ../repo-experiment-b claway ``` Each Claway process: - Works on its own branch (`feature/claway-a` vs `feature/claway-b`). - Writes checkpoints under a different shadow repo hash (derived from the worktree path). - Can use `/rollback` independently without affecting the other. This is especially useful when: - Running batch refactors. - Trying different approaches to the same task. - Pairing CLI + gateway sessions against the same upstream repo. ## Cleaning Up Worktrees Safely When you are done with an experiment: 1. Decide whether to keep or discard the work. 2. If you want to keep it: - Merge the branch into your main branch as usual. 3. Remove the worktree: ```bash cd /path/to/your/repo # Remove the worktree directory and its reference git worktree remove ../repo-feature ``` Notes: - `git worktree remove` will refuse to remove a worktree with uncommitted changes unless you force it. - Removing a worktree does **not** automatically delete the branch; you can delete or keep the branch using normal `git branch` commands. - Claway checkpoint data under `~/.claway/checkpoints/` is not automatically pruned when you remove a worktree, but it is usually very small. ## Best Practices - **One worktree per Claway experiment** - Create a dedicated branch/worktree for each substantial change. - This keeps diffs focused and PRs small and reviewable. - **Name branches after the experiment** - e.g. `feature/claway-checkpoints-docs`, `feature/claway-refactor-tests`. - **Commit frequently** - Use git commits for high‑level milestones. - Use [checkpoints and /rollback](./checkpoints-and-rollback.md) as a safety net for tool‑driven edits in between. - **Avoid running Claway from the bare repo root when using worktrees** - Prefer the worktree directories instead, so each agent has a clear scope. ## Using `claway -w` (Automatic Worktree Mode) Claway has a built‑in `-w` flag that **automatically creates a disposable git worktree** with its own branch. You don't need to set up worktrees manually — just `cd` into your repo and run: ```bash cd /path/to/your/repo claway -w ``` Claway will: - Create a temporary worktree under `.worktrees/` inside your repo. - Check out an isolated branch (e.g. `claway/claway-<hash>`). - Run the full CLI session inside that worktree. This is the easiest way to get worktree isolation. You can also combine it with a single query: ```bash claway -w -z "Fix issue #123" ``` For parallel agents, open multiple terminals and run `claway -w` in each — every invocation gets its own worktree and branch automatically. ## Putting It All Together - Use **git worktrees** to give each Claway session its own clean checkout. - Use **branches** to capture the high‑level history of your experiments. - Use **checkpoints + `/rollback`** to recover from mistakes inside each worktree. This combination gives you: - Strong guarantees that different agents and experiments do not step on each other. - Fast iteration cycles with easy recovery from bad edits. - Clean, reviewable pull requests. --- <!-- source: website/docs/user-guide/managed-scope.md --> # Managed Scope # Managed Scope **Managed scope** lets an administrator push a baseline of configuration and secrets that a standard (non-root) user **cannot override**. It is intended for fleet/org deployments where IT needs to pin, for example, the model provider, a shared API base URL, or `security.redact_secrets: true` across every user on a machine. When a managed scope is present, the values it specifies win over the user's `~/.claway/config.yaml`, `~/.claway/.env`, and even the shell environment — for exactly the keys it pins. Everything else stays fully user-controlled. :::note Different from a package-manager–locked install A package-manager–managed install (declarative-distro / formula) blocks *all* config mutation and tells you to use your package manager. Managed scope is a separate mechanism: it injects *specific immutable values* on a per-key basis rather than locking the whole config. The two are independent and can coexist. ::: ## Where it lives Managed scope is read from a system-level directory, default `/etc/claway`: ```text /etc/claway/ ├── config.yaml # managed config layer (wins over ~/.claway/config.yaml) └── .env # managed env layer (wins over ~/.claway/.env + shell) ``` The directory and files are owned by `root` (directory mode `0755`, files `0644`): readable by everyone, writable only by an administrator. **That filesystem permission is the enforcement mechanism** — a standard user can read the managed files but cannot edit them. Either file is optional. A missing managed directory or missing file simply means "no managed scope," and configuration resolves exactly as it does without the feature. ### Relocating the directory The location can be relocated with the `CLAWAY_MANAGED_DIR` environment variable (for containers or non-`/etc` deployments). This is a deployment/bootstrap path knob — like `CLAWAY_HOME` — set by the same administrator who owns the managed files. It is **never persisted** to any `.env` by Claway. ```bash # Point managed scope at a custom directory (set by IT / the deployment, not the user) export CLAWAY_MANAGED_DIR=/opt/org/claway-policy ``` :::warning A user who can set `CLAWAY_MANAGED_DIR` can repoint managed scope at a directory they control, defeating it. In a real deployment this variable should be fixed by the administrator (e.g. baked into the service unit / container image), not left user-settable. `claway doctor` reports the *resolved* managed directory so a redirect is visible. ::: ## Precedence For the keys a managed layer specifies, the order is (highest wins): | Tier | config.yaml | .env | |---|---|---| | 1 | `/etc/claway/config.yaml` (managed) | `/etc/claway/.env` (managed) | | 2 | `~/.claway/config.yaml` (user) | `~/.claway/.env` (user) | | 3 | built-in defaults | pre-existing shell environment | Merging is **leaf-level**: pinning `model.default` does not freeze the rest of `model.*`. A managed `config.yaml` of: ```yaml model: default: org/standard-model ``` forces `model.default` for every user while leaving `model.fallback` (and every other key) under user control. :::note Precedence note For the keys it pins, managed scope deliberately wins over the shell environment too — otherwise it would not be "managed." This is the one place that inverts the usual "an environment variable overrides config.yaml" rule, and it applies only to the specific keys the managed layer specifies. ::: ## Seeing what's managed ```bash claway config # shows a header naming the managed source + the pinned keys claway doctor # reports the resolved managed dir + pinned key counts ``` If you try to change a managed value, Claway refuses and names the source: ```bash $ claway config set model.default my/model Cannot set 'model.default': it is managed by your administrator (/etc/claway/config.yaml) and cannot be changed. ``` The same applies to managed secrets — `claway config set` / setup will not write a user value for an env key pinned by the managed `.env`. ## Setting up a managed scope (administrators) ```bash sudo mkdir -p /etc/claway # Pin some config values for every user on this machine sudo tee /etc/claway/config.yaml >/dev/null <<'YAML' model: provider: openrouter security: redact_secrets: true YAML # Optionally pin a shared, non-sensitive env value sudo tee /etc/claway/.env >/dev/null <<'ENV' OPENAI_API_BASE=https://inference.example.com/v1 ENV sudo chmod 0755 /etc/claway sudo chmod 0644 /etc/claway/config.yaml /etc/claway/.env ``` Changes take effect on the next Claway start (a malformed managed file is logged loudly and ignored — it never blocks startup, but the admin should check `claway doctor` to confirm the policy is being applied). ## Security model and limitations (v1) - **Enforcement is filesystem permissions only.** If a user has write access to the managed directory (or runs Claway as `root`), managed scope is advisory. - **The managed `.env` is world-readable** (`0644`), so any local user can read secrets pushed through it. Use it for shared, non-sensitive values (an org API base URL, feature defaults) rather than high-sensitivity secrets. - **The agent's own tools are not hard-blocked from a managed *env* value.** A managed environment variable is applied at startup, but nothing stops the agent from setting a different value inside its own subprocess shell. v1 is a management-convenience boundary against a normal user, not an un-escapable sandbox. The following are intentionally **out of scope for v1** and may come later: - A hard boundary that the agent itself cannot escape. - Native managed locations on macOS and Windows (v1 is Linux/POSIX-first). - Drop-in fragment directories (`managed.d/`) for layered policy. - Signed / integrity-checked managed files. - Remote / device-management (MDM) delivery. - Tighter (group-scoped) permissions for managed secrets. --- <!-- source: website/docs/user-guide/messaging/bluebubbles.md --> # user-guide/messaging/bluebubbles.md # BlueBubbles (iMessage) Connect Claway to Apple iMessage via [BlueBubbles](https://bluebubbles.app/) — a free, open-source macOS server that bridges iMessage to any device. ## Prerequisites - A **Mac** (always on) running [BlueBubbles Server](https://bluebubbles.app/) - Apple ID signed into Messages.app on that Mac - BlueBubbles Server v1.0.0+ (webhooks require this version) - Network connectivity between Claway and the BlueBubbles server ## Setup ### 1. Install BlueBubbles Server Download and install from [bluebubbles.app](https://bluebubbles.app/). Complete the setup wizard — sign in with your Apple ID and configure a connection method (local network, Ngrok, Cloudflare, or Dynamic DNS). ### 2. Get your Server URL and Password In BlueBubbles Server → **Settings → API**, note: - **Server URL** (e.g., `http://192.168.1.10:1234`) - **Server Password** ### 3. Configure Claway Run the setup wizard: ```bash claway gateway setup ``` Select **BlueBubbles (iMessage)** and enter your server URL and password. Or set environment variables directly in `~/.claway/.env`: ```bash BLUEBUBBLES_SERVER_URL=http://192.168.1.10:1234 BLUEBUBBLES_PASSWORD=your-server-password ``` #### Optional: Require mentions in group chats By default, Claway responds to every authorized BlueBubbles/iMessage DM or group message. To make group chats opt-in, enable mention gating: ```yaml platforms: bluebubbles: enabled: true extra: require_mention: true ``` With `require_mention: true`, DMs still work normally, but group-chat messages are ignored unless they match a mention pattern. If you do not configure custom patterns, Claway uses conservative defaults for `Claway` and `@Claway agent` variants. For a custom agent name, set regex patterns: ```yaml platforms: bluebubbles: extra: require_mention: true mention_patterns: - '(?<![\w@])@?amos\b[,:\-]?' ``` ### 4. Authorize Users Choose one approach: **DM Pairing (recommended):** When someone messages your iMessage, Claway automatically sends them a pairing code. Approve it with: ```bash claway pairing approve bluebubbles <CODE> ``` Use `claway pairing list` to see pending codes and approved users. **Pre-authorize specific users** (in `~/.claway/.env`): ```bash BLUEBUBBLES_ALLOWED_USERS=user@icloud.com,+15551234567 ``` **Open access** (in `~/.claway/.env`): ```bash BLUEBUBBLES_ALLOW_ALL_USERS=true ``` ### 5. Start the Gateway ```bash claway gateway run ``` Claway will connect to your BlueBubbles server, register a webhook, and start listening for iMessage messages. ## How It Works ``` iMessage → Messages.app → BlueBubbles Server → Webhook → Claway Claway → BlueBubbles REST API → Messages.app → iMessage ``` - **Inbound:** BlueBubbles sends webhook events to a local listener when new messages arrive. No polling — instant delivery. - **Outbound:** Claway sends messages via the BlueBubbles REST API. - **Media:** Images, voice messages, videos, and documents are supported in both directions. Inbound attachments are downloaded and cached locally for the agent to process. ## Environment Variables | Variable | Required | Default | Description | |----------|----------|---------|-------------| | `BLUEBUBBLES_SERVER_URL` | Yes | — | BlueBubbles server URL | | `BLUEBUBBLES_PASSWORD` | Yes | — | Server password | | `BLUEBUBBLES_WEBHOOK_HOST` | No | `127.0.0.1` | Webhook listener bind address | | `BLUEBUBBLES_WEBHOOK_PORT` | No | `8645` | Webhook listener port | | `BLUEBUBBLES_WEBHOOK_PATH` | No | `/bluebubbles-webhook` | Webhook URL path | | `BLUEBUBBLES_HOME_CHANNEL` | No | — | Phone/email for cron delivery | | `BLUEBUBBLES_ALLOWED_USERS` | No | — | Comma-separated authorized users | | `BLUEBUBBLES_ALLOW_ALL_USERS` | No | `false` | Allow all users | | `BLUEBUBBLES_REQUIRE_MENTION` | No | `false` | Require a mention pattern before responding in group chats | | `BLUEBUBBLES_MENTION_PATTERNS` | No | Claway wake words | JSON array, newline-separated, or comma-separated regex patterns for group mention matching | Auto-marking messages as read is controlled by the `send_read_receipts` key under `platforms.bluebubbles.extra` in `~/.claway/config.yaml` (default: `true`). There is no corresponding environment variable. ## Features ### Text Messaging Send and receive iMessages. Markdown is automatically stripped for clean plain-text delivery. ### Rich Media - **Images:** Photos appear natively in the iMessage conversation - **Voice messages:** Audio files sent as iMessage voice messages - **Videos:** Video attachments - **Documents:** Files sent as iMessage attachments ### Tapback Reactions Love, like, dislike, laugh, emphasize, and question reactions. Requires the BlueBubbles [Private API helper](https://docs.bluebubbles.app/helper-bundle/installation). ### Typing Indicators Shows "typing..." in the iMessage conversation while the agent is processing. Requires Private API. ### Read Receipts Automatically marks messages as read after processing. Requires Private API. ### Chat Addressing You can address chats by email or phone number — Claway resolves them to BlueBubbles chat GUIDs automatically. No need to use raw GUID format. ## Private API Some features require the BlueBubbles [Private API helper](https://docs.bluebubbles.app/helper-bundle/installation): - Tapback reactions - Typing indicators - Read receipts - Creating new chats by address Without the Private API, basic text messaging and media still work. ## Troubleshooting ### "Cannot reach server" - Verify the server URL is correct and the Mac is on - Check that BlueBubbles Server is running - Ensure network connectivity (firewall, port forwarding) ### Messages not arriving - Check that the webhook is registered in BlueBubbles Server → Settings → API → Webhooks - Verify the webhook URL is reachable from the Mac - Check `claway logs gateway` for webhook errors (or `claway logs -f` to follow in real-time) ### "Private API helper not connected" - Install the Private API helper: [docs.bluebubbles.app](https://docs.bluebubbles.app/helper-bundle/installation) - Basic messaging works without it — only reactions, typing, and read receipts require it --- <!-- source: website/docs/user-guide/messaging/dingtalk.md --> # DingTalk # DingTalk Setup Claway Agent integrates with DingTalk (钉钉) as a chatbot, letting you chat with your AI assistant through direct messages or group chats. The bot connects via DingTalk's Stream Mode — a long-lived WebSocket connection that requires no public URL or webhook server — and replies using markdown-formatted messages through DingTalk's session webhook API. Before setup, here's the part most people want to know: how Claway behaves once it's in your DingTalk workspace. ## How Claway Behaves | Context | Behavior | |---------|----------| | **DMs (1:1 chat)** | Claway responds to every message. No `@mention` needed. Each DM has its own session. | | **Group chats** | Claway responds when you `@mention` it. Without a mention, Claway ignores the message. | | **Shared groups with multiple users** | By default, Claway isolates session history per user inside the group. Two people talking in the same group do not share one transcript unless you explicitly disable that. | ### Session Model in DingTalk By default: - each DM gets its own session - each user in a shared group chat gets their own session inside that group This is controlled by `config.yaml`: ```yaml group_sessions_per_user: true ``` Set it to `false` only if you explicitly want one shared conversation for the entire group: ```yaml group_sessions_per_user: false ``` This guide walks you through the full setup process — from creating your DingTalk bot to sending your first message. ## Prerequisites Install the required Python packages: ```bash cd ~/.claway/claway && uv pip install -e ".[dingtalk]" ``` Or individually: ```bash pip install dingtalk-stream httpx alibabacloud-dingtalk ``` - `dingtalk-stream` — DingTalk's official SDK for Stream Mode (WebSocket-based real-time messaging) - `httpx` — async HTTP client used for sending replies via session webhooks - `alibabacloud-dingtalk` — DingTalk OpenAPI SDK for AI Cards, emoji reactions, and media downloads ## Step 1: Create a DingTalk App 1. Go to the [DingTalk Developer Console](https://open-dev.dingtalk.com/). 2. Log in with your DingTalk admin account. 3. Click **Application Development** → **Custom Apps** → **Create App via H5 Micro-App** (or **Robot** depending on your console version). 4. Fill in: - **App Name**: e.g., `Claway Agent` - **Description**: optional 5. After creating, navigate to **Credentials & Basic Info** to find your **Client ID** (AppKey) and **Client Secret** (AppSecret). Copy both. :::warning[Credentials shown only once] The Client Secret is only displayed once when you create the app. If you lose it, you'll need to regenerate it. Never share these credentials publicly or commit them to Git. ::: ## Step 2: Enable the Robot Capability 1. In your app's settings page, go to **Add Capability** → **Robot**. 2. Enable the robot capability. 3. Under **Message Reception Mode**, select **Stream Mode** (recommended — no public URL needed). :::tip Stream Mode is the recommended setup. It uses a long-lived WebSocket connection initiated from your machine, so you don't need a public IP, domain name, or webhook endpoint. This works behind NAT, firewalls, and on local machines. ::: ## Step 3: Find Your DingTalk User ID Claway Agent uses your DingTalk User ID to control who can interact with the bot. DingTalk User IDs are alphanumeric strings set by your organization's admin. To find yours: 1. Ask your DingTalk organization admin — User IDs are configured in the DingTalk admin console under **Contacts** → **Members**. 2. Alternatively, the bot logs the `sender_id` for each incoming message. Start the gateway, send the bot a message, then check the logs for your ID. ## Step 4: Configure Claway Agent ### Option A: Interactive Setup (Recommended) Run the guided setup command: ```bash claway gateway setup ``` Select **DingTalk** when prompted. The setup wizard can authorize via one of two paths: - **QR-code device flow (recommended).** Scan the QR that prints in your terminal with the DingTalk mobile app — your Client ID and Client Secret are returned automatically and written to `~/.claway/.env`. No developer-console trip needed. - **Manual paste.** If you already have credentials (or QR scanning isn't convenient), paste your Client ID, Client Secret, and allowed user IDs when prompted. :::note openClaw branding disclosure Because DingTalk's `verification_uri_complete` is hardcoded to the openClaw identity at the API layer, the QR currently authorizes under an `openClaw` source string until Alibaba / DingTalk-Real-AI registers a Claway-specific template server-side. This is purely how DingTalk presents the consent screen — the bot you create is fully yours and private to your tenant. ::: ### Option B: Manual Configuration Add the following to your `~/.claway/.env` file: ```bash # Required DINGTALK_CLIENT_ID=your-app-key DINGTALK_CLIENT_SECRET=your-app-secret # Security: restrict who can interact with the bot DINGTALK_ALLOWED_USERS=user-id-1 # Multiple allowed users (comma-separated) # DINGTALK_ALLOWED_USERS=user-id-1,user-id-2 # Optional: group-chat gating (mirrors Slack/Telegram/Discord/WhatsApp) # DINGTALK_REQUIRE_MENTION=true # DINGTALK_FREE_RESPONSE_CHATS=cidABC==,cidDEF== # DINGTALK_MENTION_PATTERNS=^小马 # DINGTALK_HOME_CHANNEL=cidXXXX== # DINGTALK_ALLOW_ALL_USERS=true ``` Optional behavior settings in `~/.claway/config.yaml`: ```yaml group_sessions_per_user: true gateway: platforms: dingtalk: extra: # Require @mention in groups before the bot replies (parity with Slack/Telegram/Discord). # DMs ignore this — the bot always replies in 1:1 chats. require_mention: true # Per-platform allowlist. When set, only these DingTalk user IDs can interact with the bot # (same semantics as DINGTALK_ALLOWED_USERS, but scoped here instead of in .env). allowed_users: - user-id-1 - user-id-2 ``` - `group_sessions_per_user: true` keeps each participant's context isolated inside shared group chats - `require_mention: true` prevents the bot from responding to every group message — it only answers when someone @-mentions it - `allowed_users` under `dingtalk.extra` is an alternative to `DINGTALK_ALLOWED_USERS`; if both are set, they're merged ### Start the Gateway Once configured, start the DingTalk gateway: ```bash claway gateway ``` The bot should connect to DingTalk's Stream Mode within a few seconds. Send it a message — either a DM or in a group where it's been added — to test. :::tip You can run `claway gateway` in the background or as a systemd service for persistent operation. See the deployment docs for details. ::: ## Features ### AI Cards Claway can reply using DingTalk AI Cards instead of plain markdown messages. Cards provide a richer, more structured display and support streaming updates as the agent generates its response. To enable AI Cards, configure a card template ID in `config.yaml`: ```yaml platforms: dingtalk: enabled: true extra: card_template_id: "your-card-template-id" ``` You can find your card template ID in the DingTalk Developer Console under your app's AI Card settings. When AI Cards are enabled, all replies are sent as cards with streaming text updates. ### Emoji Reactions Claway automatically adds emoji reactions to your messages to show processing status: - 🤔Thinking — added when the bot starts processing your message - 🥳Done — added when the response is complete (replaces the Thinking reaction) These reactions work in both DMs and group chats. ### Display Settings You can customize DingTalk's display behavior independently from other platforms: ```yaml display: platforms: dingtalk: show_reasoning: false # Show model reasoning/thinking in replies streaming: true # Enable streaming responses (works with AI Cards) tool_progress: all # Show tool execution progress (all/new/off) interim_assistant_messages: true # Show intermediate commentary messages ``` To disable tool progress and intermediate messages for a cleaner experience: ```yaml display: platforms: dingtalk: tool_progress: off interim_assistant_messages: false ``` ## Troubleshooting ### Bot is not responding to messages **Cause**: The robot capability isn't enabled, or `DINGTALK_ALLOWED_USERS` doesn't include your User ID. **Fix**: Verify the robot capability is enabled in your app settings and that Stream Mode is selected. Check that your User ID is in `DINGTALK_ALLOWED_USERS`. Restart the gateway. ### "dingtalk-stream not installed" error **Cause**: The `dingtalk-stream` Python package is not installed. **Fix**: Install it: ```bash pip install dingtalk-stream httpx ``` ### "DINGTALK_CLIENT_ID and DINGTALK_CLIENT_SECRET required" **Cause**: The credentials aren't set in your environment or `.env` file. **Fix**: Verify `DINGTALK_CLIENT_ID` and `DINGTALK_CLIENT_SECRET` are set correctly in `~/.claway/.env`. The Client ID is your AppKey, and the Client Secret is your AppSecret from the DingTalk Developer Console. ### Stream disconnects / reconnection loops **Cause**: Network instability, DingTalk platform maintenance, or credential issues. **Fix**: The adapter automatically reconnects with exponential backoff (2s → 5s → 10s → 30s → 60s). Check that your credentials are valid and your app hasn't been deactivated. Verify your network allows outbound WebSocket connections. ### Bot is offline **Cause**: The Claway gateway isn't running, or it failed to connect. **Fix**: Check that `claway gateway` is running. Look at the terminal output for error messages. Common issues: wrong credentials, app deactivated, `dingtalk-stream` or `httpx` not installed. ### "No session_webhook available" **Cause**: The bot tried to reply but doesn't have a session webhook URL. This typically happens if the webhook expired or the bot was restarted between receiving the message and sending the reply. **Fix**: Send a new message to the bot — each incoming message provides a fresh session webhook for replies. This is a normal DingTalk limitation; the bot can only reply to messages it has received recently. ## Security :::warning Always set `DINGTALK_ALLOWED_USERS` to restrict who can interact with the bot. Without it, the gateway denies all users by default as a safety measure. Only add User IDs of people you trust — authorized users have full access to the agent's capabilities, including tool use and system access. ::: For more information on securing your Claway Agent deployment, see the [Security Guide](../security.md). ## Notes - **Stream Mode**: No public URL, domain name, or webhook server needed. The connection is initiated from your machine via WebSocket, so it works behind NAT and firewalls. - **AI Cards**: Optionally reply with rich AI Cards instead of plain markdown. Configure via `card_template_id`. - **Emoji Reactions**: Automatic 🤔Thinking/🥳Done reactions for processing status. - **Markdown responses**: Replies are formatted in DingTalk's markdown format for rich text display. - **Media support**: Images and files in incoming messages are automatically resolved and can be processed by vision tools. - **Message deduplication**: The adapter deduplicates messages with a 5-minute window to prevent processing the same message twice. - **Auto-reconnection**: If the stream connection drops, the adapter automatically reconnects with exponential backoff. - **Message length limit**: Responses are capped at 20,000 characters per message. Longer responses are truncated. --- <!-- source: website/docs/user-guide/messaging/feishu.md --> # Feishu / Lark # Feishu / Lark Setup Claway Agent integrates with Feishu and Lark as a full-featured bot. Once connected, you can chat with the agent in direct messages or group chats, receive cron job results in a home chat, and send text, images, audio, and file attachments through the normal gateway flow. The integration supports both connection modes: - `websocket` — recommended; Claway opens the outbound connection and you do not need a public webhook endpoint - `webhook` — useful when you want Feishu/Lark to push events into your gateway over HTTP ## How Claway Behaves | Context | Behavior | |---------|----------| | Direct messages | Claway responds to every message. | | Group chats | Claway responds only when the bot is @mentioned in the chat. | | Shared group chats | By default, session history is isolated per user inside a shared chat. | This shared-chat behavior is controlled by `config.yaml`: ```yaml group_sessions_per_user: true ``` Set it to `false` only if you explicitly want one shared conversation per chat. ## Step 1: Create a Feishu / Lark App ### Recommended: Scan-to-Create (one command) ```bash claway gateway setup ``` Select **Feishu / Lark** and scan the QR code with your Feishu or Lark mobile app. Claway will automatically create a bot application with the correct permissions and save the credentials. ### Alternative: Manual Setup If scan-to-create is not available, the wizard falls back to manual input: 1. Open the Feishu or Lark developer console: - Feishu: [https://open.feishu.cn/](https://open.feishu.cn/) - Lark: [https://open.larksuite.com/](https://open.larksuite.com/) 2. Create a new app. 3. In **Credentials & Basic Info**, copy the **App ID** and **App Secret**. 4. Enable the **Bot** capability for the app. 5. Run `claway gateway setup`, select **Feishu / Lark**, and enter the credentials when prompted. :::warning Keep the App Secret private. Anyone with it can impersonate your app. ::: ### Configure Permissions In the Feishu developer console, go to **Permission Management** and add the following scopes. You can bulk-import them in the permissions page. **Required permissions:** | Scope | Purpose | |-------|---------| | `im:message` | Receive and read messages | | `im:message:send_as_bot` | Send messages as the bot | | `im:resource` | Access images, files, and audio sent by users | | `im:chat` | Access chat/group metadata | | `im:chat:readonly` | Read chat list and membership | **Recommended permissions (for full functionality):** | Scope | Purpose | |-------|---------| | `im:message.reactions:readonly` | Receive emoji reaction events | | `admin:app.info:readonly` | Auto-detect bot identity for @mention gating | | `contact:user.id:readonly` | Resolve user IDs for allowlist matching | ### Configure Events In **Events and Callbacks**: 1. Set the connection mode to **Long Connection (WebSocket)** (recommended) or configure a webhook URL 2. In the **Event Configuration** section, subscribe to: - `im.message.receive_v1` — required for receiving messages ### Publish the App After configuring permissions and events, go to **Version Management** and publish a new version of the app. The permissions won't take effect until a version is published and approved (for enterprise apps, this may require admin approval). ## Step 2: Choose a Connection Mode ### Recommended: WebSocket mode Use WebSocket mode when Claway runs on your laptop, workstation, or a private server. No public URL is required. The official Lark SDK opens and maintains a persistent outbound WebSocket connection with automatic reconnection. ```bash FEISHU_CONNECTION_MODE=websocket ``` **Requirements:** The `websockets` Python package must be installed. The SDK handles connection lifecycle, heartbeats, and auto-reconnection internally. **How it works:** The adapter runs the Lark SDK's WebSocket client in a background executor thread. Inbound events (messages, reactions, card actions) are dispatched to the main asyncio loop. On disconnect, the SDK will attempt to reconnect automatically. ### Optional: Webhook mode Use webhook mode only when you already run Claway behind a reachable HTTP endpoint. ```bash FEISHU_CONNECTION_MODE=webhook ``` In webhook mode, Claway starts an HTTP server (via `aiohttp`) and serves a Feishu endpoint at: ```text /feishu/webhook ``` **Requirements:** The `aiohttp` Python package must be installed. You can customize the webhook server bind address and path: ```bash FEISHU_WEBHOOK_HOST=127.0.0.1 # default: 127.0.0.1 FEISHU_WEBHOOK_PORT=8765 # default: 8765 FEISHU_WEBHOOK_PATH=/feishu/webhook # default: /feishu/webhook ``` When Feishu sends a URL verification challenge (`type: url_verification`), the webhook responds automatically so you can complete the subscription setup in the Feishu developer console. The challenge response is gated on `FEISHU_VERIFICATION_TOKEN` when set — challenge requests with a missing or mismatched token are rejected so an unauthenticated remote cannot prove endpoint control by echoing attacker-controlled challenge data. ## Step 3: Configure Claway ### Option A: Interactive Setup ```bash claway gateway setup ``` Select **Feishu / Lark** and fill in the prompts. ### Option B: Manual Configuration Add the following to `~/.claway/.env`: ```bash FEISHU_APP_ID=cli_xxx FEISHU_APP_SECRET=secret_xxx FEISHU_DOMAIN=feishu FEISHU_CONNECTION_MODE=websocket # Optional but strongly recommended FEISHU_ALLOWED_USERS=ou_xxx,ou_yyy FEISHU_HOME_CHANNEL=oc_xxx ``` `FEISHU_DOMAIN` accepts: - `feishu` for Feishu China - `lark` for Lark international ## Step 4: Start the Gateway ```bash claway gateway ``` Then message the bot from Feishu/Lark to confirm that the connection is live. ## Home Chat Use `/set-home` in a Feishu/Lark chat to mark it as the home channel for cron job results and cross-platform notifications. You can also preconfigure it: ```bash FEISHU_HOME_CHANNEL=oc_xxx ``` ## Security ### User Allowlist For production use, set an allowlist of Feishu Open IDs: ```bash FEISHU_ALLOWED_USERS=ou_xxx,ou_yyy ``` If you leave the allowlist empty, anyone who can reach the bot may be able to use it. In group chats, the allowlist is checked against the sender's open_id before the message is processed. ### Webhook Encryption Key When running in webhook mode, set an encryption key to enable signature verification of inbound webhook payloads: ```bash FEISHU_ENCRYPT_KEY=your-encrypt-key ``` This key is found in the **Event Subscriptions** section of your Feishu app configuration. When set, the adapter verifies every webhook request using the signature algorithm: ``` SHA256(timestamp + nonce + encrypt_key + body) ``` The computed hash is compared against the `x-lark-signature` header using timing-safe comparison. Requests with invalid or missing signatures are rejected with HTTP 401. :::tip In WebSocket mode, signature verification is handled by the SDK itself, so `FEISHU_ENCRYPT_KEY` is optional. In webhook mode, it is strongly recommended for production. ::: ### Verification Token An additional layer of authentication that checks the `token` field inside webhook payloads: ```bash FEISHU_VERIFICATION_TOKEN=your-verification-token ``` This token is also found in the **Event Subscriptions** section of your Feishu app. When set, every inbound webhook payload must contain a matching `token` in its `header` object. Mismatched tokens are rejected with HTTP 401. Both `FEISHU_ENCRYPT_KEY` and `FEISHU_VERIFICATION_TOKEN` can be used together for defense in depth. ## Group Message Policy The `FEISHU_GROUP_POLICY` environment variable controls whether and how Claway responds in group chats: ```bash FEISHU_GROUP_POLICY=allowlist # default ``` | Value | Behavior | |-------|----------| | `open` | Claway responds to @mentions from any user in any group. | | `allowlist` | Claway only responds to @mentions from users listed in `FEISHU_ALLOWED_USERS`. | | `disabled` | Claway ignores all group messages entirely. | In all modes, the bot must be explicitly @mentioned (or @all) in the group before the message is processed. Direct messages always bypass this gate. Set `FEISHU_REQUIRE_MENTION=false` to let Claway read all group traffic without requiring an @mention: ```bash FEISHU_REQUIRE_MENTION=false ``` For per-chat control, set `require_mention` on a `group_rules` entry — see [Per-Group Access Control](#per-group-access-control) below. ### Bot Identity Claway auto-detects the bot's `open_id` and display name on startup. You only need to set these manually when auto-detection cannot reach the Feishu API, or when your app uses tenant-scoped user IDs: ```bash FEISHU_BOT_OPEN_ID=ou_xxx # only when auto-detection fails FEISHU_BOT_USER_ID=xxx # required if your app uses sender_id_type=user_id FEISHU_BOT_NAME=MyBot # only when auto-detection fails ``` ## Bot-to-Bot Messaging By default Claway ignores messages sent by other bots. Enable bot-to-bot messaging when you want Claway to participate in A2A orchestration or receive notifications from other bots in the same group. ```bash FEISHU_ALLOW_BOTS=mentions # default: none ``` | Value | Behavior | |-------|----------| | `none` | Ignore all messages from other bots (default). | | `mentions` | Accept only when the peer bot @mentions Claway. | | `all` | Accept every peer bot message. | Also configurable as `feishu.allow_bots` in `config.yaml` (env wins when both are set). Peer bots do not need to be added to `FEISHU_ALLOWED_USERS` — that allowlist applies to human senders only. Grant the `application:bot.basic_info:read` scope to display peer bot names; without it, peer bots still route correctly but appear as their `open_id`. ## Interactive Card Actions When users click buttons or interact with interactive cards sent by the bot, the adapter routes these as synthetic `/card` command events: - Button clicks become: `/card button {"key": "value", ...}` - The action's `value` payload from the card definition is included as JSON. - Card actions are deduplicated with a 15-minute window to prevent double processing. Gateway-driven update prompts use a native Feishu `Yes` / `No` card instead of falling back to plain text replies. When `claway update --gateway` needs confirmation, the adapter records the selected answer in Claway's `.update_response` file and replaces the card inline with a resolved state. Card action events are dispatched with `MessageType.COMMAND`, so they flow through the normal command processing pipeline. This is also how **command approval** works — when the agent needs to run a dangerous command, it sends an interactive card with Allow Once / Session / Always / Deny buttons. The user clicks a button, and the card action callback delivers the approval decision back to the agent. ### Required Feishu App Configuration Interactive cards require **three** configuration steps in the Feishu Developer Console. Missing any of them causes error **200340** when users click card buttons. 1. **Subscribe to the card action event:** In **Event Subscriptions**, add `card.action.trigger` to your subscribed events. 2. **Enable the Interactive Card capability:** In **App Features > Bot**, ensure the **Interactive Card** toggle is enabled. This tells Feishu that your app can receive card action callbacks. 3. **Configure the Card Request URL (webhook mode only):** In **App Features > Bot > Message Card Request URL**, set the URL to the same endpoint as your event webhook (e.g. `https://your-server:8765/feishu/webhook`). In WebSocket mode this is handled automatically by the SDK. :::warning Without all three steps, Feishu will successfully *send* interactive cards (sending only requires `im:message:send` permission), but clicking any button will return error 200340. The card appears to work — the error only surfaces when a user interacts with it. ::: ## Document Comment Intelligent Reply Beyond chat, the adapter can also answer `@`-mentions left on **Feishu/Lark documents**. When a user comments on a document (local text selection or whole-doc comment) and @-mentions the bot, Claway reads the document plus the surrounding comment thread and posts an LLM reply inline on the thread. Powered by the `drive.notice.comment_add_v1` event, the handler: - Fetches the document content and comment timeline in parallel (20 messages for whole-doc threads, 12 for local-selection threads). - Runs the agent with the `feishu_doc` + `feishu_drive` toolsets scoped to that single comment session. - Chunks replies at 4000 chars and posts them back as threaded replies. - Caches per-document sessions for 1 hour with a 50-message cap so follow-up comments on the same doc keep context. ### 3-Tier Access Control Document-comment replies are **explicit-grant only** — there is no implicit allow-all mode. Permissions resolve in this order (first match wins, per field): 1. **Exact doc** — rule scoped to a specific document token. 2. **Wildcard** — rule that matches a pattern of docs. 3. **Top-level** — default rule for the workspace. Two policies are available per rule: - **`allowlist`** — a static list of users / tenants. - **`pairing`** — static list ∪ runtime-approved store. Useful for rollouts where moderators can grant access live. Rules live in `~/.claway/feishu_comment_rules.json` (pairing grants in `~/.claway/feishu_comment_pairing.json`) with mtime-cached hot-reload — edits take effect on the next comment event without restarting the gateway. CLI: ```bash # Inspect current rules and pairing state python -m gateway.platforms.feishu_comment_rules status # Simulate an access check for a specific doc + user python -m gateway.platforms.feishu_comment_rules check <fileType:fileToken> <user_open_id> # Manage pairing grants at runtime python -m gateway.platforms.feishu_comment_rules pairing list python -m gateway.platforms.feishu_comment_rules pairing add <user_open_id> python -m gateway.platforms.feishu_comment_rules pairing remove <user_open_id> ``` ### Required Feishu App Configuration On top of the chat/card permissions already granted, add the drive comment event: - Subscribe to `drive.notice.comment_add_v1` in **Event Subscriptions**. - Grant the `docs:doc:readonly` and `drive:drive:readonly` scopes so the handler can read document content. ## Meeting Invitation Events You can invite the Claway Feishu/Lark bot into a video meeting the same way you invite a human participant. When the bot receives the meeting invitation event, Claway can automatically start an agent turn that attempts to join the meeting. Powered by the `vc.bot.meeting_invited_v1` event, the flow is: - A user invites the bot to a Feishu/Lark video meeting. - Feishu/Lark sends Claway the meeting invitation event. - Claway extracts the inviter, meeting topic, and meeting number. - If the inviter is authorized by the normal gateway allowlist or pairing policy, the agent receives the meeting number and tries to join automatically. - If the invite is malformed, or the agent cannot join, Claway drops the event or replies to the inviter with a concise explanation. Malformed invitations that do not include both an inviter and a `meeting_no` are ignored. ### Required Feishu App Configuration On top of the chat/card permissions already granted, add the video-meeting invitation event: - Subscribe to `vc.bot.meeting_invited_v1` in **Event Subscriptions**. - Enable the Video Conferencing permission scope prompted by the Feishu/Lark developer console for that event. - Keep `im:message` and `im:message:send_as_bot` enabled so Claway can reply to the inviter. - Ensure the gateway user allowlist or pairing policy authorizes the inviter. Meeting invitations do not bypass normal gateway access checks. ## Media Support ### Inbound (receiving) The adapter receives and caches the following media types from users: | Type | Extensions | How it's processed | |------|-----------|-------------------| | **Images** | .jpg, .jpeg, .png, .gif, .webp, .bmp | Downloaded via Feishu API and cached locally | | **Audio** | .ogg, .mp3, .wav, .m4a, .aac, .flac, .opus, .webm | Downloaded and cached; small text files are auto-extracted | | **Video** | .mp4, .mov, .avi, .mkv, .webm, .m4v, .3gp | Downloaded and cached as documents | | **Files** | .pdf, .doc, .docx, .xls, .xlsx, .ppt, .pptx, and more | Downloaded and cached as documents | Media from rich-text (post) messages, including inline images and file attachments, is also extracted and cached. For small text-based documents (.txt, .md), the file content is automatically injected into the message text so the agent can read it directly without needing tools. ### Outbound (sending) | Method | What it sends | |--------|--------------| | `send` | Text or rich post messages (auto-detected based on markdown content) | | `send_image` / `send_image_file` | Uploads image to Feishu, then sends as native image bubble (with optional caption) | | `send_document` | Uploads file to Feishu API, then sends as file attachment | | `send_voice` | Uploads audio file as a Feishu file attachment | | `send_video` | Uploads video and sends as native media message | | `send_animation` | GIFs are downgraded to file attachments (Feishu has no native GIF bubble) | File upload routing is automatic based on extension: - `.ogg`, `.opus` → uploaded as `opus` audio - `.mp4`, `.mov`, `.avi`, `.m4v` → uploaded as `mp4` media - `.pdf`, `.doc(x)`, `.xls(x)`, `.ppt(x)` → uploaded with their document type - Everything else → uploaded as a generic stream file ## Markdown Rendering and Post Fallback When outbound text contains markdown formatting (headings, bold, lists, code blocks, links, etc.), the adapter automatically sends it as a Feishu **post** message with an embedded `md` tag rather than as plain text. This enables rich rendering in the Feishu client. If the Feishu API rejects the post payload (e.g., due to unsupported markdown constructs), the adapter automatically falls back to sending as plain text with markdown stripped. This two-stage fallback ensures messages are always delivered. Plain text messages (no markdown detected) are sent as the simple `text` message type. ## Processing Status Reactions While the agent is working, the bot shows a `Typing` reaction on your message. It's cleared when the reply arrives, or replaced with `CrossMark` if processing failed. Set `FEISHU_REACTIONS=false` to turn it off. ## Burst Protection and Batching The adapter includes debouncing for rapid message bursts to avoid overwhelming the agent: ### Text Batching When a user sends multiple text messages in quick succession, they are merged into a single event before being dispatched: | Setting | Env Var | Default | |---------|---------|---------| | Quiet period | `CLAWAY_FEISHU_TEXT_BATCH_DELAY_SECONDS` | 0.6s | | Max messages per batch | `CLAWAY_FEISHU_TEXT_BATCH_MAX_MESSAGES` | 8 | | Max characters per batch | `CLAWAY_FEISHU_TEXT_BATCH_MAX_CHARS` | 4000 | ### Media Batching Multiple media attachments sent in quick succession (e.g., dragging several images) are merged into a single event: | Setting | Env Var | Default | |---------|---------|---------| | Quiet period | `CLAWAY_FEISHU_MEDIA_BATCH_DELAY_SECONDS` | 0.8s | ### Per-Chat Serialization Messages within the same chat are processed serially (one at a time) to maintain conversation coherence. Each chat has its own lock, so messages in different chats are processed concurrently. ## Rate Limiting (Webhook Mode) In webhook mode, the adapter enforces per-IP rate limiting to protect against abuse: - **Window:** 60-second sliding window - **Limit:** 120 requests per window per (app_id, path, IP) triple - **Tracking cap:** Up to 4096 unique keys tracked (prevents unbounded memory growth) Requests that exceed the limit receive HTTP 429 (Too Many Requests). ### Webhook Anomaly Tracking The adapter tracks consecutive error responses per IP address. After 25 consecutive errors from the same IP within a 6-hour window, a warning is logged. This helps detect misconfigured clients or probing attempts. Additional webhook protections: - **Body size limit:** 1 MB maximum - **Body read timeout:** 30 seconds - **Content-Type enforcement:** Only `application/json` is accepted ## WebSocket Tuning When using `websocket` mode, you can customize reconnect and ping behavior: ```yaml platforms: feishu: extra: ws_reconnect_interval: 120 # Seconds between reconnect attempts (default: 120) ws_ping_interval: 30 # Seconds between WebSocket pings (optional; SDK default if unset) ``` | Setting | Config key | Default | Description | |---------|-----------|---------|-------------| | Reconnect interval | `ws_reconnect_interval` | 120s | How long to wait between reconnection attempts | | Ping interval | `ws_ping_interval` | _(SDK default)_ | Frequency of WebSocket keepalive pings | ## Per-Group Access Control Beyond the global `FEISHU_GROUP_POLICY`, you can set fine-grained rules per group chat using `group_rules` in config.yaml: ```yaml platforms: feishu: extra: default_group_policy: "open" # Default for groups not in group_rules admins: # Users who can manage bot settings - "ou_admin_open_id" group_rules: "oc_group_chat_id_1": policy: "allowlist" # open | allowlist | blacklist | admin_only | disabled allowlist: - "ou_user_open_id_1" - "ou_user_open_id_2" "oc_group_chat_id_2": policy: "admin_only" "oc_group_chat_id_3": policy: "blacklist" blacklist: - "ou_blocked_user" "oc_free_chat": policy: "open" require_mention: false # overrides FEISHU_REQUIRE_MENTION for this chat ``` | Policy | Description | |--------|-------------| | `open` | Anyone in the group can use the bot | | `allowlist` | Only users in the group's `allowlist` can use the bot | | `blacklist` | Everyone except users in the group's `blacklist` can use the bot | | `admin_only` | Only users in the global `admins` list can use the bot in this group | | `disabled` | Bot ignores all messages in this group | Set `require_mention: false` on a `group_rules` entry to skip the @-mention requirement for that specific chat. When omitted, the chat inherits the global `FEISHU_REQUIRE_MENTION` value. Groups not listed in `group_rules` fall back to `default_group_policy` (defaults to the value of `FEISHU_GROUP_POLICY`). ## Deduplication Inbound messages are deduplicated using message IDs with a 24-hour TTL. The dedup state is persisted across restarts to `~/.claway/feishu_seen_message_ids.json`. | Setting | Env Var | Default | |---------|---------|---------| | Cache size | `CLAWAY_FEISHU_DEDUP_CACHE_SIZE` | 2048 entries | ## All Environment Variables | Variable | Required | Default | Description | |----------|----------|---------|-------------| | `FEISHU_APP_ID` | ✅ | — | Feishu/Lark App ID | | `FEISHU_APP_SECRET` | ✅ | — | Feishu/Lark App Secret | | `FEISHU_DOMAIN` | — | `feishu` | `feishu` (China) or `lark` (international) | | `FEISHU_CONNECTION_MODE` | — | `websocket` | `websocket` or `webhook` | | `FEISHU_ALLOWED_USERS` | — | _(empty)_ | Comma-separated open_id list for user allowlist | | `FEISHU_ALLOW_BOTS` | — | `none` | Accept messages from other bots: `none`, `mentions`, or `all` | | `FEISHU_REQUIRE_MENTION` | — | `true` | Whether group messages must @mention the bot | | `FEISHU_HOME_CHANNEL` | — | — | Chat ID for cron/notification output | | `FEISHU_ENCRYPT_KEY` | — | _(empty)_ | Encrypt key for webhook signature verification | | `FEISHU_VERIFICATION_TOKEN` | — | _(empty)_ | Verification token for webhook payload auth | | `FEISHU_GROUP_POLICY` | — | `allowlist` | Group message policy: `open`, `allowlist`, `disabled` | | `FEISHU_BOT_OPEN_ID` | — | _(empty)_ | Bot's open_id (for @mention detection) | | `FEISHU_BOT_USER_ID` | — | _(empty)_ | Bot's user_id (for @mention detection) | | `FEISHU_BOT_NAME` | — | _(empty)_ | Bot's display name (for @mention detection) | | `FEISHU_WEBHOOK_HOST` | — | `127.0.0.1` | Webhook server bind address | | `FEISHU_WEBHOOK_PORT` | — | `8765` | Webhook server port | | `FEISHU_WEBHOOK_PATH` | — | `/feishu/webhook` | Webhook endpoint path | | `CLAWAY_FEISHU_DEDUP_CACHE_SIZE` | — | `2048` | Max deduplicated message IDs to track | | `CLAWAY_FEISHU_TEXT_BATCH_DELAY_SECONDS` | — | `0.6` | Text burst debounce quiet period | | `CLAWAY_FEISHU_TEXT_BATCH_MAX_MESSAGES` | — | `8` | Max messages merged per text batch | | `CLAWAY_FEISHU_TEXT_BATCH_MAX_CHARS` | — | `4000` | Max characters merged per text batch | | `CLAWAY_FEISHU_MEDIA_BATCH_DELAY_SECONDS` | — | `0.8` | Media burst debounce quiet period | WebSocket and per-group ACL settings are configured via `config.yaml` under `platforms.feishu.extra` (see [WebSocket Tuning](#websocket-tuning) and [Per-Group Access Control](#per-group-access-control) above). ## Troubleshooting | Problem | Fix | |---------|-----| | `lark-oapi not installed` | Install the SDK: `pip install lark-oapi` | | `websockets not installed; websocket mode unavailable` | Install websockets: `pip install websockets` | | `aiohttp not installed; webhook mode unavailable` | Install aiohttp: `pip install aiohttp` | | `FEISHU_APP_ID or FEISHU_APP_SECRET not set` | Set both env vars or configure via `claway gateway setup` | | `Another local Claway gateway is already using this Feishu app_id` | Only one Claway instance can use the same app_id at a time. Stop the other gateway first. | | Bot doesn't respond in groups | Ensure the bot is @mentioned, check `FEISHU_GROUP_POLICY`, and verify the sender is in `FEISHU_ALLOWED_USERS` if policy is `allowlist` | | `Webhook rejected: invalid verification token` | Ensure `FEISHU_VERIFICATION_TOKEN` matches the token in your Feishu app's Event Subscriptions config | | `Webhook rejected: invalid signature` | Ensure `FEISHU_ENCRYPT_KEY` matches the encrypt key in your Feishu app config | | Post messages show as plain text | The Feishu API rejected the post payload; this is normal fallback behavior. Check logs for details. | | Images/files not received by bot | Grant `im:message` and `im:resource` permission scopes to your Feishu app | | Bot identity not auto-detected | Usually a transient network issue reaching Feishu's bot info endpoint. Set `FEISHU_BOT_OPEN_ID` and `FEISHU_BOT_NAME` manually as a workaround. | | Peer bot messages still ignored after enabling `FEISHU_ALLOW_BOTS` | Claway can't identify itself yet — set `FEISHU_BOT_OPEN_ID` (and `FEISHU_BOT_USER_ID` if your app uses `sender_id_type=user_id`). | | Peer bots show as `ou_xxxxxx` instead of by name | Grant the `application:bot.basic_info:read` scope. | | Error 200340 when clicking approval buttons | Enable **Interactive Card** capability and configure **Card Request URL** in the Feishu Developer Console. See [Required Feishu App Configuration](#required-feishu-app-configuration) above. | | `Webhook rate limit exceeded` | More than 120 requests/minute from the same IP. This is usually a misconfiguration or loop. | ## Toolset Feishu / Lark uses the `claway-feishu` platform preset, which includes the same core tools as Telegram and other gateway-based messaging platforms. --- <!-- source: website/docs/user-guide/messaging/google_chat.md --> # Google Chat # Google Chat Setup Connect Claway Agent to Google Chat as a bot. The integration uses Cloud Pub/Sub pull subscriptions for inbound events and the Chat REST API for outbound messages. Equivalent ergonomics to Slack Socket Mode or Telegram long-polling: your Claway process does not need a public URL, a tunnel, or a TLS certificate. It connects, authenticates, and listens on a subscription — the same way a Telegram bot listens on a token. > Run `claway gateway setup` and pick **Google Chat** for a guided walk-through. :::note Workspace edition Google Chat is part of Google Workspace. You can use this integration with a personal Workspace (`@yourdomain.com` registered through Google) or a work Workspace where you have the Admin rights to publish an app. Gmail-only accounts cannot host Chat apps. ::: ## Overview | Component | Value | |-----------|-------| | **Libraries** | `google-cloud-pubsub`, `google-api-python-client`, `google-auth` | | **Inbound transport** | Cloud Pub/Sub pull subscription (no public endpoint) | | **Outbound transport** | Chat REST API (`chat.googleapis.com`) | | **Authentication** | Service Account JSON with `roles/pubsub.subscriber` on the subscription | | **User identification** | Chat resource names (`users/{id}`) + email | --- ## Step 1: Create or pick a GCP project You need a Google Cloud project to host the Pub/Sub topic. If you don't have one, create it at [console.cloud.google.com](https://console.cloud.google.com) — personal accounts get a free tier that easily covers bot traffic. Note the project ID (e.g., `my-chat-bot-123`). You'll use it in every subsequent step. --- ## Step 2: Enable two APIs In the console, go to **APIs & Services → Library** and enable: - **Google Chat API** - **Cloud Pub/Sub API** Both are free for the volumes a personal bot generates. --- ## Step 3: Create a Service Account **IAM & Admin → Service Accounts → Create Service Account.** - Name: `claway-chat-bot` - Skip the "Grant this service account access to project" step. IAM on the specific subscription is all you need — do **NOT** grant project-level Pub/Sub roles. After creation, open the SA, go to **Keys → Add Key → Create new key → JSON** and download the file. Save it somewhere only Claway can read (e.g., `~/.claway/google-chat-sa.json`, `chmod 600`). :::caution There is NO "Chat Bot Caller" role A common mistake is to search for a Chat-specific IAM role and grant it at the project level. That role doesn't exist. Chat bot authority comes from being installed in a space, not from IAM. All your SA needs is Pub/Sub subscriber on the subscription you create in the next step. ::: --- ## Step 4: Create the Pub/Sub topic and subscription **Pub/Sub → Topics → Create topic.** - Topic ID: `claway-chat-events` - Leave the defaults for everything else. After creation, the topic's detail page has a **Subscriptions** tab. Create one: - Subscription ID: `claway-chat-events-sub` - Delivery type: **Pull** - Message retention: **7 days** (so backlog survives a claway restart) - Leave the rest default. --- ## Step 5: IAM binding on the topic (critical) On the **topic** (not the subscription), add an IAM principal: - Principal: `chat-api-push@system.gserviceaccount.com` - Role: `Pub/Sub Publisher` Without this, Google Chat cannot publish events to your topic and your bot will never receive anything. --- ## Step 6: IAM binding on the subscription On the **subscription**, add your own Service Account as a principal: - Principal: `claway-chat-bot@<your-project>.iam.gserviceaccount.com` - Role: `Pub/Sub Subscriber` Also grant `Pub/Sub Viewer` on the same subscription — Claway calls `subscription.get()` at startup as a reachability check. --- ## Step 7: Configure the Chat app Go to **APIs & Services → Google Chat API → Configuration**. - **App name**: whatever you want users to see ("Claway" is reasonable). - **Avatar URL**: any public PNG (Google has some defaults). - **Description**: a short sentence shown in the app directory. - **Functionality**: enable **Receive 1:1 messages** and **Join spaces and group conversations**. - **Connection settings**: select **Cloud Pub/Sub**, enter the topic name `projects/<your-project>/topics/claway-chat-events`. - **Visibility**: restrict to your workspace (or specific users) — do not publish to everyone while you're testing. Save. --- ## Step 8: Install the bot in a test space Open Google Chat in a browser. Start a DM with your app by searching for its name in the **+ New Chat** menu. The first time you message it, Google sends an `ADDED_TO_SPACE` event that Claway uses to cache the bot's own `users/{id}` for self-message filtering. --- ## Step 9: Configure Claway Add the Google Chat section to `~/.claway/.env`: ```bash # Required GOOGLE_CHAT_PROJECT_ID=my-chat-bot-123 GOOGLE_CHAT_SUBSCRIPTION_NAME=projects/my-chat-bot-123/subscriptions/claway-chat-events-sub GOOGLE_CHAT_SERVICE_ACCOUNT_JSON=/home/you/.claway/google-chat-sa.json # Authorization — paste the emails of people allowed to talk to the bot GOOGLE_CHAT_ALLOWED_USERS=you@yourdomain.com,coworker@yourdomain.com # Optional GOOGLE_CHAT_HOME_CHANNEL=spaces/AAAA... # default delivery destination for cron jobs GOOGLE_CHAT_MAX_MESSAGES=1 # Pub/Sub FlowControl; 1 serializes commands per session GOOGLE_CHAT_MAX_BYTES=16777216 # 16 MiB — cap on in-flight message bytes ``` The project ID also falls back to `GOOGLE_CLOUD_PROJECT`, and the SA path falls back to `GOOGLE_APPLICATION_CREDENTIALS` — use whichever convention you prefer. Install the dependencies the Google Chat adapter needs (no Claway extra is currently published — install them directly): ```bash pip install google-cloud-pubsub google-api-python-client google-auth google-auth-oauthlib ``` Start the gateway: ```bash claway gateway ``` You should see a log line like: ``` [GoogleChat] Connected; project=my-chat-bot-123, subscription=<redacted>, bot_user_id=users/XXXX, flow_control(msgs=1, bytes=16777216) ``` Send "hola" in the test DM. The bot posts a "Claway is thinking…" marker, then edits that same message in place with the real response — no "message deleted" tombstones. --- ## Formatting and capabilities Google Chat renders a limited markdown subset: | Supported | Not supported | |-----------|---------------| | `*bold*`, `_italic_`, `~strike~`, `` `code` `` | Headings, lists | | Inline images via URL | Interactive Card v2 buttons (v1 of this gateway) | | Native file attachments (after `/setup-files` — see Step 10) | Native voice notes / circular video notes | The agent's system prompt includes a Google Chat–specific hint so it knows these limits and avoids formatting that won't render. Message size limit: 4000 characters per message. Longer agent responses are automatically split across multiple messages. Thread support: when a user replies inside a thread, Claway detects the `thread.name` and posts its reply in the same thread, so each thread gets a separate Claway session. --- ## Step 10: Native attachment delivery (optional) Out of the box the bot can post text, inline images via URL, and download cards for audio/video/documents. To deliver **native** Chat attachments — the same file widget you get when a human drags-and-drops a file — each user authorizes the bot once via a per-user OAuth flow. ### Why a separate flow Google Chat's `media.upload` endpoint hard-rejects service-account auth: > This method doesn't support app authentication with a service account. > Authenticate with a user account. There's no IAM role or scope that fixes this. The endpoint only accepts user credentials. So the bot has to act *as a user* whenever it uploads a file — specifically, as the user who asked for the file. ### One-time setup (per profile) 1. Go to **APIs & Services → Credentials** in the same GCP project. 2. **Create credentials → OAuth client ID → Desktop app**. 3. Download the JSON. Move it onto the host that runs Claway. 4. Register the client with Claway (run under the profile you want it scoped to): ```bash # Default profile: python -m plugins.platforms.google_chat.oauth \ --client-secret /path/to/client_secret.json # A named profile gets its own separate registration: claway -p <profile> python -m plugins.platforms.google_chat.oauth \ --client-secret /path/to/client_secret.json ``` That writes the client secret into the active profile's Claway home (e.g. `~/.claway/google_chat_user_client_secret.json` for the default profile). The client secret is **profile-scoped, not shared across profiles** — each profile registers its own. This is deliberate: profiles are isolated auth boundaries, so two profiles can point at different Google OAuth apps / accounts. Register it once per profile that needs Google Chat attachment delivery. ### Per-user authorization (in chat) Each user runs the flow once, in their own DM with the bot: 1. They send `/setup-files` to the bot. It replies with status and the next step. 2. They send `/setup-files start`. The bot replies with an OAuth URL. 3. They open the URL, click **Allow**, and watch the browser fail to load `http://localhost:1/?...&code=...`. That failure is expected — the auth code is in the URL bar. 4. They copy the failed URL (or just the `code=...` value) and paste it back into chat as `/setup-files <PASTED_URL>`. The bot exchanges it for a refresh token. The token lands at `~/.claway/google_chat_user_tokens/<sanitized_email>.json`. Subsequent file requests in that user's DM use *their* token, so the bot uploads as them and the message lands in their space. To revoke later: `/setup-files revoke` deletes only that user's token. Other users' tokens are untouched. ### Scope The flow requests exactly one scope: `chat.messages.create`. That covers both `media.upload` and the `messages.create` that references the uploaded `attachmentDataRef`. No Drive, no broader Chat scopes — this is least-privilege on purpose. ### Multi-user behavior When the asker has no per-user token yet, the bot falls back to a legacy single-user token at `~/.claway/google_chat_user_token.json` (if present from a pre-multi-user install). When neither is available, the bot posts a clear text notice telling the asker to run `/setup-files`. A user revoking only clears their own slot. A 401/403 from one user's token evicts only that user's cache. Users don't disrupt each other. --- ## Troubleshooting **Bot stays silent after sending "hola."** 1. Check the Pub/Sub subscription has undelivered messages in the console. If it does, Claway isn't authenticated — verify `GOOGLE_CHAT_SERVICE_ACCOUNT_JSON` and that the SA is listed as `Pub/Sub Subscriber` on the subscription. 2. If the subscription has zero messages, Google Chat isn't publishing. Double-check the IAM binding on the **topic**: `chat-api-push@system.gserviceaccount.com` must have `Pub/Sub Publisher`. 3. Check `claway gateway` logs for `[GoogleChat] Connected`. If you see `[GoogleChat] Config validation failed`, the error message tells you which env var to fix. **Bot replies but an error message appears instead of the agent's answer.** Check logs for `[GoogleChat] Pub/Sub stream died` — if these repeat, your SA credentials may have been rotated or the subscription deleted. After 10 attempts the adapter marks itself fatal. **"403 Forbidden" on every outbound message.** The bot was removed from the space, or you revoked it in the Chat API console. Re-install it in the space (the next `ADDED_TO_SPACE` event will re-enable messaging automatically). **Too many "Rate limit hit" warnings.** The Chat API's default quotas allow 60 messages per space per minute. If your agent produces long streaming responses that exceed that, the adapter retries with exponential backoff — but you'll still see user-visible latency. Consider concise responses or raising the quota in the GCP console. **Bot keeps posting the "/setup-files" notice instead of files.** The asker has no per-user OAuth token and there's no legacy fallback. Run `/setup-files` in their DM and follow Step 10. After the exchange completes the next file request uploads natively without a gateway restart. **`/setup-files start` says "No client credentials stored."** The one-time setup wasn't done *for this profile* (the client secret is profile-scoped, so a registration under one profile won't be seen by another). From a terminal, run it under the profile the gateway uses: ```bash # Default profile: python -m plugins.platforms.google_chat.oauth \ --client-secret /path/to/client_secret.json # Named profile: claway -p <profile> python -m plugins.platforms.google_chat.oauth \ --client-secret /path/to/client_secret.json ``` Then send `/setup-files start` again. **`/setup-files <PASTED_URL>` says "Token exchange failed."** The auth code is single-use and short-lived (typically a few minutes). Send `/setup-files start` to get a fresh URL and retry. --- ## Security notes - **Service Account scope**: the adapter requests `chat.bot` and `pubsub` scopes. IAM should be the actual enforcement — grant your SA the minimum (`roles/pubsub.subscriber` + `roles/pubsub.viewer` on the subscription), not project-level or org-level Pub/Sub roles. - **Attachment download protection**: Claway will only attach the SA bearer token to URLs whose host matches a short allowlist of Google-owned domains (`googleapis.com`, `drive.google.com`, `lh[3-6].googleusercontent.com`, and a few others). Any other host is rejected before the HTTP request, to protect against SSRF scenarios where a crafted event could redirect the bearer token to the GCE metadata service. - **Redaction**: Service Account emails, subscription paths, and topic paths are stripped from log output by `agent/redact.py`. The debug envelope dump (`GOOGLE_CHAT_DEBUG_RAW=1`) routes through the same redaction filter and logs at DEBUG level. - **Compliance**: if you plan to connect this bot to a regulated workspace (anything with a data-residency or AI-governance policy), get that approval before the first install. - **User OAuth scope**: the per-user attachment flow requests *only* `chat.messages.create` — the minimum that covers `media.upload` plus the follow-up `messages.create`. Tokens are persisted as plain JSON at `~/.claway/google_chat_user_tokens/<sanitized_email>.json` (filesystem permissions are the protection — same model as the SA key file). Each token is owned by exactly one user; revoke is scoped to that user. --- <!-- source: website/docs/user-guide/messaging/homeassistant.md --> # user-guide/messaging/homeassistant.md # Home Assistant Integration Claway Agent integrates with [Home Assistant](https://www.home-assistant.io/) in two ways: 1. **Gateway platform** — subscribes to real-time state changes via WebSocket and responds to events 2. **Smart home tools** — four LLM-callable tools for querying and controlling devices via the REST API ## Setup ### 1. Create a Long-Lived Access Token 1. Open your Home Assistant instance 2. Go to your **Profile** (click your name in the sidebar) 3. Scroll to **Long-Lived Access Tokens** 4. Click **Create Token**, give it a name like "Claway Agent" 5. Copy the token ### 2. Configure Environment Variables ```bash # Add to ~/.claway/.env # Required: your Long-Lived Access Token HASS_TOKEN=your-long-lived-access-token # Optional: HA URL (default: http://homeassistant.local:8123) HASS_URL=http://192.168.1.100:8123 ``` :::info The `homeassistant` toolset is automatically enabled when `HASS_TOKEN` is set. Both the gateway platform and the device control tools activate from this single token. ::: ### 3. Start the Gateway ```bash claway gateway ``` Home Assistant will appear as a connected platform alongside any other messaging platforms (Telegram, Discord, etc.). ## Available Tools Claway Agent registers four tools for smart home control: ### `ha_list_entities` List Home Assistant entities, optionally filtered by domain or area. **Parameters:** - `domain` *(optional)* — Filter by entity domain: `light`, `switch`, `climate`, `sensor`, `binary_sensor`, `cover`, `fan`, `media_player`, etc. - `area` *(optional)* — Filter by area/room name (matches against friendly names): `living room`, `kitchen`, `bedroom`, etc. **Example:** ``` List all lights in the living room ``` Returns entity IDs, states, and friendly names. ### `ha_get_state` Get detailed state of a single entity, including all attributes (brightness, color, temperature setpoint, sensor readings, etc.). **Parameters:** - `entity_id` *(required)* — The entity to query, e.g., `light.living_room`, `climate.thermostat`, `sensor.temperature` **Example:** ``` What's the current state of climate.thermostat? ``` Returns: state, all attributes, last changed/updated timestamps. ### `ha_list_services` List available services (actions) for device control. Shows what actions can be performed on each device type and what parameters they accept. **Parameters:** - `domain` *(optional)* — Filter by domain, e.g., `light`, `climate`, `switch` **Example:** ``` What services are available for climate devices? ``` ### `ha_call_service` Call a Home Assistant service to control a device. **Parameters:** - `domain` *(required)* — Service domain: `light`, `switch`, `climate`, `cover`, `media_player`, `fan`, `scene`, `script` - `service` *(required)* — Service name: `turn_on`, `turn_off`, `toggle`, `set_temperature`, `set_hvac_mode`, `open_cover`, `close_cover`, `set_volume_level` - `entity_id` *(optional)* — Target entity, e.g., `light.living_room` - `data` *(optional)* — Additional parameters as a JSON object **Examples:** ``` Turn on the living room lights → ha_call_service(domain="light", service="turn_on", entity_id="light.living_room") ``` ``` Set the thermostat to 22 degrees in heat mode → ha_call_service(domain="climate", service="set_temperature", entity_id="climate.thermostat", data={"temperature": 22, "hvac_mode": "heat"}) ``` ``` Set living room lights to blue at 50% brightness → ha_call_service(domain="light", service="turn_on", entity_id="light.living_room", data={"brightness": 128, "color_name": "blue"}) ``` ## Gateway Platform: Real-Time Events The Home Assistant gateway adapter connects via WebSocket and subscribes to `state_changed` events. When a device state changes and matches your filters, it's forwarded to the agent as a message. ### Event Filtering :::warning Required Configuration By default, **no events are forwarded**. You must configure at least one of `watch_domains`, `watch_entities`, or `watch_all` to receive events. Without filters, a warning is logged at startup and all state changes are silently dropped. ::: Configure which events the agent sees in `~/.claway/config.yaml` under the Home Assistant platform's `extra` section: ```yaml platforms: homeassistant: enabled: true extra: watch_domains: - climate - binary_sensor - alarm_control_panel - light watch_entities: - sensor.front_door_battery ignore_entities: - sensor.uptime - sensor.cpu_usage - sensor.memory_usage cooldown_seconds: 30 ``` | Setting | Default | Description | |---------|---------|-------------| | `watch_domains` | *(none)* | Only watch these entity domains (e.g., `climate`, `light`, `binary_sensor`) | | `watch_entities` | *(none)* | Only watch these specific entity IDs | | `watch_all` | `false` | Set to `true` to receive **all** state changes (not recommended for most setups) | | `ignore_entities` | *(none)* | Always ignore these entities (applied before domain/entity filters) | | `cooldown_seconds` | `30` | Minimum seconds between events for the same entity | :::tip Start with a focused set of domains — `climate`, `binary_sensor`, and `alarm_control_panel` cover the most useful automations. Add more as needed. Use `ignore_entities` to suppress noisy sensors like CPU temperature or uptime counters. ::: ### Event Formatting State changes are formatted as human-readable messages based on domain: | Domain | Format | |--------|--------| | `climate` | "HVAC mode changed from 'off' to 'heat' (current: 21, target: 23)" | | `sensor` | "changed from 21°C to 22°C" | | `binary_sensor` | "triggered" / "cleared" | | `light`, `switch`, `fan` | "turned on" / "turned off" | | `alarm_control_panel` | "alarm state changed from 'armed_away' to 'triggered'" | | *(other)* | "changed from 'old' to 'new'" | ### Agent Responses Outbound messages from the agent are delivered as **Home Assistant persistent notifications** (via `persistent_notification.create`). These appear in the HA notification panel with the title "Claway Agent". ### Connection Management - **WebSocket** with 30-second heartbeat for real-time events - **Automatic reconnection** with backoff: 5s → 10s → 30s → 60s - **REST API** for outbound notifications (separate session to avoid WebSocket conflicts) - **Authorization** — HA events are always authorized (no user allowlist needed, since the `HASS_TOKEN` authenticates the connection) ## Security The Home Assistant tools enforce security restrictions: :::warning Blocked Domains The following service domains are **blocked** to prevent arbitrary code execution on the HA host: - `shell_command` — arbitrary shell commands - `command_line` — sensors/switches that execute commands - `python_script` — scripted Python execution - `pyscript` — broader scripting integration - `hassio` — addon control, host shutdown/reboot - `rest_command` — HTTP requests from HA server (SSRF vector) Attempting to call services in these domains returns an error. ::: Entity IDs are validated against the pattern `^[a-z_][a-z0-9_]*\.[a-z0-9_]+$` to prevent injection attacks. ## Example Automations ### Morning Routine ``` User: Start my morning routine Agent: 1. ha_call_service(domain="light", service="turn_on", entity_id="light.bedroom", data={"brightness": 128}) 2. ha_call_service(domain="climate", service="set_temperature", entity_id="climate.thermostat", data={"temperature": 22}) 3. ha_call_service(domain="media_player", service="turn_on", entity_id="media_player.kitchen_speaker") ``` ### Security Check ``` User: Is the house secure? Agent: 1. ha_list_entities(domain="binary_sensor") → checks door/window sensors 2. ha_get_state(entity_id="alarm_control_panel.home") → checks alarm status 3. ha_list_entities(domain="lock") → checks lock states 4. Reports: "All doors closed, alarm is armed_away, all locks engaged." ``` ### Reactive Automation (via Gateway Events) When connected as a gateway platform, the agent can react to events: ``` [Home Assistant] Front Door: triggered (was cleared) Agent automatically: 1. ha_get_state(entity_id="binary_sensor.front_door") 2. ha_call_service(domain="light", service="turn_on", entity_id="light.hallway") 3. Sends notification: "Front door opened. Hallway lights turned on." ``` ## Troubleshooting **Environment variables not picked up.** The adapter reads credentials from `~/.claway/.env` (auto-merged at startup) or from `config.yaml`. Double-check the file lives under the active Claway profile home and that there's no stray quoting around the URL/token. Restart the gateway after editing — env changes are only applied on process start. **REST auth failing (`401 Unauthorized`).** The token must be a *Long-Lived Access Token* created from your HA user profile page (**Profile → Security → Long-lived access tokens**). Short-lived UI session tokens won't work. Also verify the base URL includes the scheme and port (e.g. `http://homeassistant.local:8123`) and is reachable from the host running Claway — `curl -H "Authorization: Bearer <token>" <url>/api/` should return `{"message": "API running."}`. --- <!-- source: website/docs/user-guide/messaging/irc.md --> # user-guide/messaging/irc.md # IRC The IRC adapter connects Claway to any IRC server and relays messages between an IRC channel (or direct messages) and the agent. It speaks the IRC protocol over Python's stdlib `asyncio` — **no external dependencies, no SDK, no daemon**. It works with public networks like [Libera.Chat](https://libera.chat/) and any self-hosted ircd. IRC is plain text: there is no voice, image, file, thread, reaction, typing, or streaming support — replies are sent as `PRIVMSG` lines, with long messages split to fit the IRC line limit. > Run `claway gateway setup` and pick **IRC** for a guided walk-through. ## Prerequisites - An IRC server to connect to (e.g. `irc.libera.chat`) - A channel to join (e.g. `#claway`) — comma-separate to join several - A nickname for the bot (default: `claway-bot`) - Optional: a registered nick + NickServ password if your network requires identification ## Configure Claway You can configure IRC two ways — environment variables (for a quick env-only setup) or the `gateway` block in `~/.claway/gateway-config.yaml`. ### Option A — gateway-config.yaml ```yaml gateway: platforms: irc: enabled: true extra: server: irc.libera.chat port: 6697 nickname: claway-bot channel: "#claway" use_tls: true server_password: "" # optional server password nickserv_password: "" # optional NickServ identification allowed_users: [] # empty = allow all, or list of nicks max_message_length: 450 # IRC line limit (safe default) ``` ### Option B — environment variables | Variable | Required | Description | |----------|:--------:|-------------| | `IRC_SERVER` | ✅ | IRC server hostname (e.g. `irc.libera.chat`) | | `IRC_CHANNEL` | ✅ | Channel(s) to join — comma-separate for multiple | | `IRC_NICKNAME` | ✅ | Bot nickname (default: `claway-bot`) | | `IRC_PORT` | — | Server port (default: `6697` with TLS, `6667` without) | | `IRC_USE_TLS` | — | Use TLS (`true`/`false`; default `true` on port 6697) | | `IRC_SERVER_PASSWORD` | — | Server password for the `PASS` command | | `IRC_NICKSERV_PASSWORD` | — | NickServ password for automatic IDENTIFY on connect | | `IRC_ALLOWED_USERS` | — | Comma-separated nicks allowed to talk to the bot | | `IRC_ALLOW_ALL_USERS` | — | Allow anyone in the channel to talk to the bot (dev only) | | `IRC_HOME_CHANNEL` | — | Channel for cron / notification delivery (defaults to `IRC_CHANNEL`) | ## Access control By default, only nicks listed in `allowed_users` (or `IRC_ALLOWED_USERS`) may talk to the bot. Leave the list empty **and** set `IRC_ALLOW_ALL_USERS=true` to let anyone in the channel chat with Claway — useful for testing, but not recommended on public networks since IRC nicks are not authenticated unless the network enforces NickServ. If your network registers nicks, set `IRC_NICKSERV_PASSWORD` (or `nickserv_password`) so the bot identifies to NickServ on connect and keeps its registered nick. ## Channels vs. DMs - Messages in a joined channel are treated as a **group** conversation. - Private messages to the bot are treated as **direct messages**. Cron jobs and notifications are delivered to the **home channel** — `IRC_HOME_CHANNEL` if set, otherwise the first `IRC_CHANNEL`. ## Run the gateway ```bash claway gateway start ``` Check status with `claway gateway status` — IRC connection state is reported there, including for env-only setups. ## Notes - Long agent replies are automatically split into multiple `PRIVMSG` lines to stay within the IRC line limit (`max_message_length`, default 450 bytes after protocol overhead). - The adapter acquires a scoped credential lock per server+nick, so two Claway profiles won't fight over the same IRC identity. --- <!-- source: website/docs/user-guide/messaging/line.md --> # LINE # LINE Setup Run Claway Agent as a [LINE](https://line.me/) bot via the official LINE Messaging API. The adapter lives as a bundled platform plugin under `plugins/platforms/line/` — no core edits, just enable it like any other platform. LINE is the dominant messaging app in Japan, Taiwan, and Thailand. If your users live there, this is how they reach you. > Run `claway gateway setup` and pick **LINE** for a guided walk-through. ## How the bot responds | Context | Behavior | |---------|----------| | **1:1 chat** (`U` IDs) | Responds to every message | | **Group chat** (`C` IDs) | Responds when the group is on the allowlist | | **Multi-user room** (`R` IDs) | Responds when the room is on the allowlist | Inbound text, images, audio, video, files, stickers, and locations are all handled. Outbound text uses the **free reply token first** (single-use, ~60s window) and falls back to the metered Push API when the token has expired. --- ## Step 1: Create a LINE Messaging API channel 1. Go to the [LINE Developers Console](https://developers.line.biz/console/). 2. Create a Provider, then under it a **Messaging API** channel. 3. From the channel's **Basic settings** tab, copy the **Channel secret**. 4. From the **Messaging API** tab, scroll to **Channel access token (long-lived)** and click **Issue**. Copy the token. 5. In the **Messaging API** tab, also disable **Auto-reply messages** and **Greeting messages** so they don't fight your bot's replies. --- ## Step 2: Expose the webhook port LINE delivers webhooks over public HTTPS. The default port is `8646` — override with `LINE_PORT` if needed. ```bash # Cloudflare Tunnel (recommended for production — fixed hostname) cloudflared tunnel --url http://localhost:8646 # ngrok (good for dev) ngrok http 8646 # devtunnel devtunnel create claway-line --allow-anonymous devtunnel port create claway-line -p 8646 --protocol https devtunnel host claway-line ``` Copy the `https://...` URL — you'll set it as the webhook URL below. **Leave the tunnel running** while testing. For production, set up a fixed Cloudflare named tunnel so the webhook URL doesn't change on restart. --- ## Step 3: Configure Claway Add to `~/.claway/.env`: ```env LINE_CHANNEL_ACCESS_TOKEN=YOUR_LONG_LIVED_TOKEN LINE_CHANNEL_SECRET=YOUR_CHANNEL_SECRET # Allowlist — at least one of these (or LINE_ALLOW_ALL_USERS=true for dev) LINE_ALLOWED_USERS=U1234567890abcdef... # comma-separated U-prefixed IDs LINE_ALLOWED_GROUPS=C1234567890abcdef... # optional group IDs LINE_ALLOWED_ROOMS=R1234567890abcdef... # optional room IDs # Required for image / audio / video sends — the public HTTPS base URL # the tunnel resolves to. Without it, send_image/voice/video will refuse. LINE_PUBLIC_URL=https://my-tunnel.example.com ``` Then in `~/.claway/config.yaml`: ```yaml gateway: platforms: line: enabled: true ``` That's enough — the bundled-plugin scan in `gateway/config.py` automatically picks up `plugins/platforms/line/`. No `Platform.LINE` enum edit, no `_create_adapter` registration. --- ## Step 4: Set the webhook URL Back in the LINE console: 1. Open your channel → **Messaging API** tab. 2. Under **Webhook settings** → **Webhook URL**, paste `https://<your-tunnel>/line/webhook` (note the `/line/webhook` path — the adapter listens there). 3. Click **Verify**. LINE pings the URL; you should see a 200. 4. Toggle **Use webhook** to **On**. --- ## Step 5: Run the gateway ```bash claway gateway ``` The agent log shows: ``` LINE: webhook listening on 0.0.0.0:8646/line/webhook (public: https://my-tunnel.example.com) ``` Add the bot as a friend from the LINE app (scan the QR in the channel's **Messaging API** tab) and send it a message. --- ## Slow LLM responses LINE's reply token is single-use and expires roughly 60 seconds after the inbound event. Slow LLMs can't reply in time, which would normally force a paid Push API call. When the LLM is still running past `LINE_SLOW_RESPONSE_THRESHOLD` seconds (default `45`), the adapter consumes the original reply token to send a **Template Buttons** bubble: > 🤔 Still thinking. Tap below to fetch the answer when it's ready. > > [ Get answer ] The user taps **Get answer** when convenient — that postback delivers a *fresh* reply token, which the adapter uses to send the cached answer (still free). State machine: `PENDING → READY → DELIVERED`, plus `ERROR` for cancelled runs (the orphan PENDING resolves to "Run was interrupted before completion." after `/stop` so the persistent button doesn't loop). To disable the postback button and always Push-fallback instead: ```env LINE_SLOW_RESPONSE_THRESHOLD=0 ``` For the postback flow to fire reliably, suppress chatter that would consume the reply token before the threshold: ```yaml # ~/.claway/config.yaml display: interim_assistant_messages: false platforms: line: tool_progress: off ``` --- ## Cron / notification delivery ```env LINE_HOME_CHANNEL=Uxxxxxxxxxxxxxxxxxxxx # default delivery target ``` Cron jobs with `deliver: line` route to `LINE_HOME_CHANNEL`. The adapter ships a standalone Push-only sender so cron jobs work even when cron runs in a separate process from the gateway. --- ## Environment variable reference | Variable | Required | Default | Description | |---|---|---|---| | `LINE_CHANNEL_ACCESS_TOKEN` | yes | — | Long-lived channel access token | | `LINE_CHANNEL_SECRET` | yes | — | Channel secret (HMAC-SHA256 webhook verification) | | `LINE_HOST` | no | `0.0.0.0` | Webhook bind host | | `LINE_PORT` | no | `8646` | Webhook bind port | | `LINE_PUBLIC_URL` | for media | — | Public HTTPS base URL; required for image/voice/video sends | | `LINE_ALLOWED_USERS` | one of | — | Comma-separated user IDs (U-prefixed) | | `LINE_ALLOWED_GROUPS` | one of | — | Comma-separated group IDs (C-prefixed) | | `LINE_ALLOWED_ROOMS` | one of | — | Comma-separated room IDs (R-prefixed) | | `LINE_ALLOW_ALL_USERS` | dev only | `false` | Skip allowlist entirely | | `LINE_HOME_CHANNEL` | no | — | Default cron / notification delivery target | | `LINE_SLOW_RESPONSE_THRESHOLD` | no | `45` | Seconds before the postback button fires (`0` = disabled) | | `LINE_PENDING_TEXT` | no | "🤔 Still thinking…" | Bubble text shown alongside the postback button | | `LINE_BUTTON_LABEL` | no | "Get answer" | Button label | | `LINE_DELIVERED_TEXT` | no | "Already replied ✅" | Reply when an already-delivered button is tapped again | | `LINE_INTERRUPTED_TEXT` | no | "Run was interrupted before completion." | Reply when a `/stop` orphan button is tapped | --- ## Troubleshooting **"invalid signature" on webhook verify.** The `Channel secret` was copied wrong, or your tunnel rewrote the request body. Verify with `curl -i https://<tunnel>/line/webhook/health` first — that should return `{"status":"ok","platform":"line"}`. **Bot receives nothing in groups.** Check `LINE_ALLOWED_GROUPS` includes the `C...` group ID. To find a group ID, send a test message and grep `~/.claway/logs/gateway.log` for `LINE: rejecting unauthorized source` — the rejected source dict has the IDs. **`send_image` fails with "LINE_PUBLIC_URL must be set".** LINE's Messaging API does not accept binary uploads — images, audio, and video must be reachable HTTPS URLs. Set `LINE_PUBLIC_URL` to the tunnel's public hostname and the adapter will serve files from `/line/media/<token>/<filename>` automatically. **Postback button never appears.** Either the LLM responded faster than `LINE_SLOW_RESPONSE_THRESHOLD`, or another bubble (tool-progress, streaming) consumed the reply token first. See the suppression block under "Slow LLM responses". **"already in use by another profile".** The same channel access token is bound to another running Claway profile. Stop the other gateway or use a separate channel. --- ## Limitations * **Bubble and length caps.** Each LINE text bubble is capped at 5000 characters. Longer responses are smart-chunked at ~4500 characters across up to 5 bubbles per Reply/Push call, splitting on natural boundaries where possible. * **No native message editing.** LINE has no edit-message API — streaming responses always send fresh bubbles, never edit prior ones. * **No Markdown rendering.** Bold (`**`), italics (`*`), code fences, and headings render as literal characters. The adapter strips them before sending; URLs are preserved (`[label](url)` becomes `label (url)`). * **Loading indicator is DM-only.** LINE rejects the chat/loading API for groups and rooms, so the typing indicator only shows in 1:1 chats. --- <!-- source: website/docs/user-guide/messaging/matrix.md --> # Matrix # Matrix Setup Claway Agent integrates with Matrix, the open, federated messaging protocol. Matrix lets you run your own homeserver or use a public one like matrix.org — either way, you keep control of your communications. The bot connects via the `mautrix` Python SDK, processes messages through the Claway Agent pipeline (including tool use, memory, and reasoning), and responds in real time. It supports text, file attachments, images, audio, video, and optional end-to-end encryption (E2EE). Claway works with any Matrix homeserver — Synapse, Conduit, Dendrite, or matrix.org. Before setup, here's the part most people want to know: how Claway behaves once it's connected. ## How Claway Behaves | Context | Behavior | |---------|----------| | **DMs** | Claway responds to every message. No `@mention` needed. Each DM has its own session. Set `MATRIX_DM_MENTION_THREADS=true` to start a thread when the bot is `@mentioned` in a DM. | | **Rooms** | By default, Claway requires an `@mention` to respond. Set `MATRIX_REQUIRE_MENTION=false` or add room IDs to `MATRIX_FREE_RESPONSE_ROOMS` for free-response rooms. Room invites are auto-accepted. | | **Threads** | Claway supports Matrix threads (MSC3440). If you reply in a thread, Claway keeps the thread context isolated from the main room timeline. Threads where the bot has already participated do not require a mention. | | **Auto-threading** | By default, Claway auto-creates a thread for each message it responds to in a room. This keeps conversations isolated. Set `MATRIX_AUTO_THREAD=false` to disable. Set `MATRIX_DM_AUTO_THREAD=true` (default false) to also auto-create threads for DM messages — this is distinct from `MATRIX_DM_MENTION_THREADS`, which only starts a thread when the bot is `@mentioned` in a DM. | | **Commands** | Claway accepts normal `/commands` when your Matrix client sends them. If your client reserves `/` for local commands, use `!commands` instead; Claway normalizes known `!command` aliases to `/command`. | | **Interactive controls** | Dangerous-command approval and `/model` selection can use Matrix reactions. Approval reactions can be limited to the user who requested the action. | | **Thinking and tool activity** | Matrix uses threaded, editable thinking/tool-activity panes when gateway progress is enabled, so updates do not flood the main room timeline. | | **Shared rooms with multiple users** | By default, Claway isolates session history per user inside the room. Two people talking in the same room do not share one transcript unless you explicitly disable that. | :::tip The bot automatically joins rooms when invited. Just invite the bot's Matrix user to any room and it will join and start responding. ::: ## Capability Matrix This table is backed by the Matrix adapter capability declaration and Matrix test coverage. E2EE is mode-based because deployments choose whether encrypted rooms are disabled, opportunistic, or required. | Capability | Matrix | |------------|--------| | text | yes | | threads | yes | | reactions | yes | | approvals | yes | | model picker | yes | | thinking panes | yes | | images | yes | | multiple images | yes | | files | yes | | voice/audio | yes | | video | yes | | E2EE | off / optional / required | | diagnostics | yes | ### Session Model in Matrix By default: - each DM gets its own session - each thread gets its own session namespace - each user in a shared room gets their own session inside that room This is controlled by `config.yaml`: ```yaml group_sessions_per_user: true ``` Set it to `false` only if you explicitly want one shared conversation for the entire room: ```yaml group_sessions_per_user: false ``` Shared sessions can be useful for a collaborative room, but they also mean: - users share context growth and token costs - one person's long tool-heavy task can bloat everyone else's context - one person's in-flight run can interrupt another person's follow-up in the same room ### Mention and Threading Configuration You can configure mention and auto-threading behavior via environment variables or `config.yaml`: ```yaml matrix: require_mention: true # Require @mention in rooms (default: true) allowed_users: # Matrix users allowed to trigger agent turns - "@alice:matrix.org" allowed_rooms: # Matrix rooms allowed to trigger agent turns - "!abc123:matrix.org" free_response_rooms: # Rooms exempt from mention requirement - "!abc123:matrix.org" ignore_user_patterns: # Bridge/appservice ghost users to ignore - "^@telegram_" - "^@whatsapp_" process_notices: false # Ignore m.notice by default session_scope: room # auto|room|thread; room is recommended for project rooms auto_thread: true # Auto-create threads for responses (default: true) dm_mention_threads: false # Create thread when @mentioned in DM (default: false) ``` Or via environment variables: ```bash MATRIX_REQUIRE_MENTION=true MATRIX_ALLOWED_USERS=@alice:matrix.org MATRIX_ALLOWED_ROOMS=!abc123:matrix.org MATRIX_FREE_RESPONSE_ROOMS=!abc123:matrix.org,!def456:matrix.org MATRIX_IGNORE_USER_PATTERNS='^@telegram_,^@whatsapp_' MATRIX_PROCESS_NOTICES=false MATRIX_SESSION_SCOPE=room # recommended for stable project-room context MATRIX_AUTO_THREAD=true MATRIX_DM_MENTION_THREADS=false MATRIX_REACTIONS=true # default: true — emoji reactions during processing MATRIX_ALLOW_ROOM_MENTIONS=false ``` :::tip Disabling reactions `MATRIX_REACTIONS=false` turns off the processing-lifecycle emoji reactions (👀/✅/❌) the bot posts on inbound messages. Useful for rooms where reaction events are noisy or aren't supported by all participating clients. ::: :::tip Room-wide mentions Claway sends structured Matrix user mentions for explicit Matrix IDs such as `@alice:example.org`. Room-wide `@room` notifications are disabled by default; set `MATRIX_ALLOW_ROOM_MENTIONS=true` only in rooms where the bot is allowed to notify everyone. ::: :::note If you are upgrading from a version that did not have `MATRIX_REQUIRE_MENTION`, the bot previously responded to all messages in rooms. To preserve that behavior, set `MATRIX_REQUIRE_MENTION=false`. ::: ### Project Room Isolation If you use the same Matrix bot in multiple project rooms, configure stable room-scoped sessions: ```bash MATRIX_SESSION_SCOPE=room MATRIX_AUTO_THREAD=false ``` `MATRIX_SESSION_SCOPE` accepts: | Scope | Behavior | |-------|----------| | `auto` | Backward-compatible default. Existing `MATRIX_AUTO_THREAD` behavior controls synthetic threads. | | `room` | Unthreaded room messages stay in one stable room session. Real Matrix threads still use their thread root. | | `thread` | Unthreaded room messages synthesize a thread/session from the triggering event ID. | Claway now includes the current Matrix room name, room ID, topic, message ID, and a Matrix room-boundary note in the agent prompt. `/status` also shows the current Matrix room/session scope, and `/resume` will not silently resume a named session from another Matrix room unless you explicitly use `/resume --cross-room <session name>`. `MATRIX_SESSION_SCOPE=room` controls the room/thread lane. The existing `group_sessions_per_user` setting still controls whether users inside that room share the lane. With `group_sessions_per_user: true` (default), Alice and Bob get separate Project B sessions. With `group_sessions_per_user: false`, the room has one shared Project B transcript. This guide walks you through the full setup process — from creating your bot account to sending your first message. ## Step 1: Create a Bot Account You need a Matrix user account for the bot. There are several ways to do this: ### Option A: Register on Your Homeserver (Recommended) If you run your own homeserver (Synapse, Conduit, Dendrite): 1. Use the admin API or registration tool to create a new user: ```bash # Synapse example register_new_matrix_user -c /etc/synapse/homeserver.yaml http://localhost:8008 ``` 2. Choose a username like `claway` — the full user ID will be `@claway:your-server.org`. ### Option B: Use matrix.org or Another Public Homeserver 1. Go to [Element Web](https://app.element.io) and create a new account. 2. Pick a username for your bot (e.g., `claway-bot`). ### Option C: Use Your Own Account You can also run Claway as your own user. This means the bot posts as you — useful for personal assistants. ## Step 2: Get an Access Token Claway needs an access token to authenticate with the homeserver. You have two options: ### Option A: Access Token (Recommended) The most reliable way to get a token: **Via Element:** 1. Log in to [Element](https://app.element.io) with the bot account. 2. Go to **Settings** → **Help & About**. 3. Scroll down and expand **Advanced** — the access token is displayed there. 4. **Copy it immediately.** **Via the API:** ```bash curl -X POST https://your-server/_matrix/client/v3/login \ -H "Content-Type: application/json" \ -d '{ "type": "m.login.password", "user": "@claway:your-server.org", "password": "your-password" }' ``` The response includes an `access_token` field — copy it. :::warning[Keep your access token safe] The access token gives full access to the bot's Matrix account. Never share it publicly or commit it to Git. If compromised, revoke it by logging out all sessions for that user. ::: ### Option B: Password Login Instead of providing an access token, you can give Claway the bot's user ID and password. Claway will log in automatically on startup. This is simpler but means the password is stored in your `.env` file. ```bash MATRIX_USER_ID=@claway:your-server.org MATRIX_PASSWORD=your-password ``` ## Step 3: Find Your Matrix User ID Claway Agent uses your Matrix User ID to control who can interact with the bot. Matrix User IDs follow the format `@username:server`. To find yours: 1. Open [Element](https://app.element.io) (or your preferred Matrix client). 2. Click your avatar → **Settings**. 3. Your User ID is displayed at the top of the profile (e.g., `@alice:matrix.org`). :::tip Matrix User IDs always start with `@` and contain a `:` followed by the server name. For example: `@alice:matrix.org`, `@bob:your-server.com`. ::: ## Step 4: Configure Claway Agent ### Option A: Interactive Setup (Recommended) Run the guided setup command: ```bash claway gateway setup ``` Select **Matrix** when prompted, then provide your homeserver URL, access token (or user ID + password), and allowed user IDs when asked. ### Option B: Manual Configuration Add the following to your `~/.claway/.env` file: **Using an access token:** ```bash # Required MATRIX_HOMESERVER=https://matrix.example.org MATRIX_ACCESS_TOKEN=*** # Optional: user ID (auto-detected from token if omitted) # MATRIX_USER_ID=@claway:matrix.example.org # Security: restrict who can interact with the bot MATRIX_ALLOWED_USERS=@alice:matrix.example.org # Optional: restrict which rooms can trigger the bot MATRIX_ALLOWED_ROOMS=!abc123:matrix.example.org # Multiple allowed users (comma-separated) # MATRIX_ALLOWED_USERS=@alice:matrix.example.org,@bob:matrix.example.org ``` **Using password login:** ```bash # Required MATRIX_HOMESERVER=https://matrix.example.org MATRIX_USER_ID=@claway:matrix.example.org MATRIX_PASSWORD=*** # Security MATRIX_ALLOWED_USERS=@alice:matrix.example.org ``` ## Private Deployment Hardening For private Matrix deployments, set both user and room allowlists. If `MATRIX_ALLOWED_USERS` is unset, any sender who can reach the bot in a joined room can trigger an agent turn. If `MATRIX_ALLOWED_ROOMS` is unset, any room the bot joins can trigger an agent turn. A locked-down deployment should set both: ```bash MATRIX_ALLOWED_USERS=@alice:matrix.example.org,@bob:matrix.example.org MATRIX_ALLOWED_ROOMS=!ops:matrix.example.org,!dmroom:matrix.example.org ``` Bridge and appservice deployments need extra loop protection. Claway always ignores its own events, Matrix appservice-style users whose localpart starts with `_`, duplicate event IDs, old startup events, edit replacement events, and `m.notice` events by default. Add deployment-specific bridge ghost patterns when your bridge uses a different naming convention: ```bash MATRIX_IGNORE_USER_PATTERNS='^@telegram_,^@slack_,^@whatsapp_' ``` Only enable notices when a trusted human workflow really sends `m.notice`: ```bash MATRIX_PROCESS_NOTICES=true ``` Outbound whole-room notifications are disabled by default. Keep `MATRIX_ALLOW_ROOM_MENTIONS=false` unless the bot is explicitly allowed to wake the whole room with `@room`. Diagnostics and debug payloads redact Matrix access tokens, recovery keys, device identifiers, and message bodies. Media downloads are limited to Matrix `mxc://` content URIs and rejected when they exceed `MATRIX_MAX_MEDIA_BYTES`. Treat federated rooms and untrusted homeservers as untrusted input: keep room allowlists tight, prefer DMs or private rooms for tool-heavy work, and avoid authorizing bridge ghosts or appservice puppets as allowed users. Optional behavior settings in `~/.claway/config.yaml`: ```yaml group_sessions_per_user: true ``` - `group_sessions_per_user: true` keeps each participant's context isolated inside shared rooms ### Start the Gateway Once configured, start the Matrix gateway: ```bash claway gateway ``` The bot should connect to your homeserver and start syncing within a few seconds. Send it a message — either a DM or in a room it has joined — to test. :::tip You can run `claway gateway` in the background or as a systemd service for persistent operation. See the deployment docs for details. ::: ## End-to-End Encryption (E2EE) Claway supports Matrix end-to-end encryption, so you can chat with your bot in encrypted rooms. ### Requirements E2EE requires the `mautrix` library with encryption extras and the `libolm` C library: ```bash # Install mautrix with E2EE support pip install 'mautrix[encryption]' # Or install with claway extras cd ~/.claway/claway && uv pip install -e ".[matrix]" ``` You also need `libolm` installed on your system: ```bash # Debian/Ubuntu sudo apt install libolm-dev # macOS brew install libolm # Fedora sudo dnf install libolm-devel ``` ### Enable E2EE Add to your `~/.claway/.env`: ```bash MATRIX_E2EE_MODE=required ``` `MATRIX_E2EE_MODE` accepts: | Mode | Behavior | |------|----------| | `off` | Do not initialize Matrix E2EE. | | `optional` | Try E2EE when dependencies are available, but keep unencrypted rooms working if crypto cannot initialize. | | `required` | Fail closed if E2EE dependencies or crypto setup are not available. | Optional mode may fall back to non-E2EE operation when crypto setup is unavailable. Required mode fails closed instead of silently downgrading. For backwards compatibility, `MATRIX_ENCRYPTION=true` still enables required E2EE behavior. When E2EE is enabled, Claway: - Stores encryption keys in `~/.claway/platforms/matrix/store/` (legacy installs: `~/.claway/matrix/store/`) - Uploads device keys on first connection - Decrypts incoming messages and encrypts outgoing messages automatically - Auto-joins encrypted rooms when invited ### Matrix Tools and Controls In Matrix conversations, Claway exposes Matrix-specific tools to the agent: - `matrix_send_reaction` - `matrix_redact_message` - `matrix_create_room` - `matrix_invite_user` - `matrix_fetch_history` - `matrix_set_presence` These tools are scoped to Matrix contexts and are not available in non-Matrix toolsets. Admin-style tools are disabled by default: redaction requires `MATRIX_TOOLS_ALLOW_REDACTION=true`, invites require `MATRIX_TOOLS_ALLOW_INVITES=true`, and room creation requires `MATRIX_TOOLS_ALLOW_ROOM_CREATE=true`. Public room creation also requires `MATRIX_ALLOW_PUBLIC_ROOMS=true`. Matrix tools are limited to the current Matrix room by default. Explicit cross-room targets require `MATRIX_TOOLS_ALLOW_CROSS_ROOM=true`; redaction and invite-like cross-room actions additionally require `MATRIX_TOOLS_ALLOW_CROSS_ROOM_DESTRUCTIVE=true`. If `MATRIX_ALLOWED_ROOMS` is set, Matrix tools may only target those rooms. Reaction controls use: - ✅ approve once - ♾️ approve always - ❌ deny - number reactions for `/model` choices Set `MATRIX_APPROVAL_REQUIRE_SENDER=false` if you intentionally want any authorized Matrix user in the room to operate an approval/model picker prompt. The default is requester-bound when Claway knows who requested the action. ### Media Limits Claway uploads and downloads Matrix images, files, audio, and video through Matrix media APIs. Multiple generated images are sent as one ordered logical batch, preserving captions and thread context across the batch. By default, Matrix media over 100 MB is rejected before upload/download. Override with: ```bash MATRIX_MAX_MEDIA_BYTES=104857600 ``` Inbound media must use Matrix `mxc://` content URIs. Claway rejects arbitrary HTTP(S) media URLs in Matrix events to avoid turning a federated room into an unrestricted downloader. ## Synapse Integration Tests Claway includes an opt-in Synapse harness for local validation: ```bash docker compose -f tests/e2e/matrix_synapse_gateway/docker-compose.yml up -d CLAWAY_MATRIX_SYNAPSE_INTEGRATION=1 \ scripts/run_tests.sh -m "integration and matrix_synapse" \ tests/e2e/matrix_synapse_gateway/test_gateway.py docker compose -f tests/e2e/matrix_synapse_gateway/docker-compose.yml down -v ``` The harness creates temporary users through Synapse shared-secret registration and covers private-room send/receive, named-room invite/join, media upload/download, bot response delivery, and startup old-event filtering. E2EE smoke coverage is separately marked with `matrix_e2ee` so it can stay opt-in on developer machines. ### Cross-Signing Verification (Recommended) If your Matrix account has cross-signing enabled (the default in Element), set the recovery key so the bot can self-sign its device on startup. Without this, other Matrix clients may refuse to share encryption sessions with the bot after a device key rotation. ```bash MATRIX_RECOVERY_KEY=EsT... your recovery key here ``` **Where to find it:** In Element, go to **Settings** → **Security & Privacy** → **Encryption** → your recovery key (also called the "Security Key"). This is the key you were asked to save when you first set up cross-signing. On each startup, if `MATRIX_RECOVERY_KEY` is set, Claway imports cross-signing keys from the homeserver's secure secret storage and signs the current device. This is idempotent and safe to leave enabled permanently. If Claway bootstraps a new Matrix recovery key, it never logs the raw key. Set `MATRIX_RECOVERY_KEY_OUTPUT_FILE=/secure/path/matrix-recovery-key.txt` before startup to write a generated key once with file mode `0600`; the file is not overwritten if it already exists. :::warning[Deleting the crypto store] If you delete `~/.claway/platforms/matrix/store/crypto.db`, the bot loses its encryption identity. Simply restarting with the same device ID will **not** fully recover — the homeserver still holds one-time keys signed with the old identity key, and peers cannot establish new Olm sessions. Claway detects this condition on startup and refuses to enable E2EE, logging: `device XXXX has stale one-time keys on the server signed with a previous identity key`. **Easiest recovery: generate a new access token** (which gets a fresh device ID with no stale key history). See the "Upgrading from a previous version with E2EE" section below. This is the most reliable path and avoids touching the homeserver database. **Manual recovery** (advanced — keeps the same device ID): 1. Stop Synapse and delete the old device from its database: ```bash sudo systemctl stop matrix-synapse sudo sqlite3 /var/lib/matrix-synapse/homeserver.db " DELETE FROM e2e_device_keys_json WHERE device_id = 'DEVICE_ID' AND user_id = '@claway:your-server'; DELETE FROM e2e_one_time_keys_json WHERE device_id = 'DEVICE_ID' AND user_id = '@claway:your-server'; DELETE FROM e2e_fallback_keys_json WHERE device_id = 'DEVICE_ID' AND user_id = '@claway:your-server'; DELETE FROM devices WHERE device_id = 'DEVICE_ID' AND user_id = '@claway:your-server'; " sudo systemctl start matrix-synapse ``` Or via the Synapse admin API (note the URL-encoded user ID): ```bash curl -X DELETE -H "Authorization: Bearer ADMIN_TOKEN" \ 'https://your-server/_synapse/admin/v2/users/%40claway%3Ayour-server/devices/DEVICE_ID' ``` Note: deleting a device via the admin API may also invalidate the associated access token. You may need to generate a new token afterward. 2. Delete the local crypto store and restart Claway: ```bash rm -f ~/.claway/platforms/matrix/store/crypto.db* # restart claway ``` Other Matrix clients (Element, matrix-commander) may cache the old device keys. After recovery, type `/discardsession` in Element to force a new encryption session with the bot. ::: :::info If `mautrix[encryption]` is not installed or `libolm` is missing, the bot falls back to a plain (unencrypted) client automatically. You'll see a warning in the logs. ::: ## Home Room You can designate a "home room" where the bot sends proactive messages (such as cron job output, reminders, and notifications). There are two ways to set it: ### Using the Slash Command Type `/sethome` in any Matrix room where the bot is present. That room becomes the home room. If your Matrix client intercepts slash commands, type `!sethome` instead. ### Manual Configuration Add this to your `~/.claway/.env`: ```bash MATRIX_HOME_ROOM=!abc123def456:matrix.example.org ``` ## Room allowlist (`allowed_rooms`) Restrict the bot to a fixed set of Matrix rooms. When set, the bot **only** responds in rooms whose ID appears in the list — messages from any other room are silently ignored, even if the bot is mentioned. **DMs (direct chat rooms) are exempt** from this filter, so authorized users can always reach the bot one-on-one. ```yaml matrix: allowed_rooms: - "!abc123def456:matrix.example.org" - "!opsroom789:matrix.example.org" ``` Or via env var (comma-separated): ```bash MATRIX_ALLOWED_ROOMS="!abc123def456:matrix.example.org,!opsroom789:matrix.example.org" ``` Behavior: - Empty / unset → no restriction (default). - Non-empty → room ID must be on the list. The check runs **before** any other gating (mention requirement, sender allowlist, etc.). - Use the room's **internal ID** (`!abc...:server`), not its alias (`#room:server`). You can find a room's internal ID in Element via Room → Settings → Advanced. See also: [admin/user slash command split](../../reference/slash-commands.md#permissions-and-adminuser-split). :::tip To find a Room ID: in Element, go to the room → **Settings** → **Advanced** → the **Internal room ID** is shown there (starts with `!`). ::: ## Commands in Matrix Claway supports the same gateway commands in Matrix that it supports on other messaging platforms, including `/commands`, `/model`, `/stop`, `/queue`, `/steer`, `/goal`, `/subgoal`, `/background`, `/bg`, `/btw`, `/tasks`, and `/yolo`. Some Matrix clients reserve leading `/` for local client commands and may not send unknown slash commands to the room. In that case, use `!` as a Matrix-safe alias: ```text !commands !model !model gpt-5.5 --provider openrouter !queue continue with the next task !stop ``` Claway only normalizes `!command` when the command is known to the gateway, a registered plugin command, or an installed skill command. Ordinary exclamations such as `!important` remain normal chat messages. ## Troubleshooting ### Bot is not responding to messages **Cause**: The bot hasn't joined the room, `MATRIX_ALLOWED_USERS` doesn't include your User ID, `MATRIX_ALLOWED_ROOMS` doesn't include the room, or a room message did not mention the bot. **Fix**: Invite the bot to the room — it auto-joins on invite. Verify your User ID is in `MATRIX_ALLOWED_USERS` (use the full `@user:server` format) and the room ID is in `MATRIX_ALLOWED_ROOMS` if that allowlist is configured. In rooms, mention the bot or add the room to `MATRIX_FREE_RESPONSE_ROOMS`. Restart the gateway. ### Bot joins rooms but silently drops every message (clock skew) **Cause**: The host's system clock is set ahead of real time. The Matrix adapter applies a 5-second startup-grace filter (`event_ts < startup_ts - 5`) to ignore events replayed from initial sync. When the wall clock is ahead, every incoming event looks "older than startup" and is dropped before reaching the message handler — the bot appears connected but never replies. See #12614. **Symptom**: Gateway log shows `Matrix: dropped N live events as 'too old' more than 30s after startup`. **Fix**: Sync the host clock with NTP and restart the bot: ```bash # Debian/Ubuntu sudo timedatectl set-ntp true timedatectl status # confirm "System clock synchronized: yes" # macOS sudo sntp -sS time.apple.com ``` ### "Failed to authenticate" / "whoami failed" on startup **Cause**: The access token or homeserver URL is incorrect. **Fix**: Verify `MATRIX_HOMESERVER` points to your homeserver (include `https://`, no trailing slash). Check that `MATRIX_ACCESS_TOKEN` is valid — try it with curl: ```bash curl -H "Authorization: Bearer YOUR_TOKEN" \ https://your-server/_matrix/client/v3/account/whoami ``` If this returns your user info, the token is valid. If it returns an error, generate a new token. ### "mautrix not installed" error **Cause**: The `mautrix` Python package is not installed. **Fix**: Install it: ```bash pip install 'mautrix[encryption]' ``` Or with Claway extras: ```bash cd ~/.claway/claway && uv pip install -e ".[matrix]" ``` ### Encryption errors / "could not decrypt event" **Cause**: Missing encryption keys, `libolm` not installed, or the bot's device isn't trusted. **Fix**: 1. Verify `libolm` is installed on your system (see the E2EE section above). 2. Make sure `MATRIX_ENCRYPTION=true` is set in your `.env`. 3. In your Matrix client (Element), go to the bot's profile -> Sessions -> verify/trust the bot's device. 4. If the bot just joined an encrypted room, it can only decrypt messages sent *after* it joined. Older messages are inaccessible. ### Upgrading from a previous version with E2EE :::tip If you also manually deleted `crypto.db`, see the "Deleting the crypto store" warning in the E2EE section above — there are additional steps to clear stale one-time keys from the homeserver. ::: If you previously used Claway with `MATRIX_ENCRYPTION=true` and are upgrading to a version that uses the new SQLite-based crypto store, the bot's encryption identity has changed. Your Matrix client (Element) may cache the old device keys and refuse to share encryption sessions with the bot. **Symptoms**: The bot connects and shows "E2EE enabled" in the logs, but all messages show "could not decrypt event" and the bot never responds. **What's happening**: The old encryption state (from the previous `matrix-nio` or serialization-based `mautrix` backend) is incompatible with the new SQLite crypto store. The bot creates a fresh encryption identity, but your Matrix client still has the old keys cached and won't share the room's encryption session with a device whose keys changed. This is a Matrix security feature -- clients treat changed identity keys for the same device as suspicious. **Fix** (one-time migration): 1. **Generate a new access token** to get a fresh device ID. The simplest way: ```bash curl -X POST https://your-server/_matrix/client/v3/login \ -H "Content-Type: application/json" \ -d '{ "type": "m.login.password", "identifier": {"type": "m.id.user", "user": "@claway:your-server.org"}, "password": "***", "initial_device_display_name": "Claway Agent" }' ``` Copy the new `access_token` and update `MATRIX_ACCESS_TOKEN` in `~/.claway/.env`. 2. **Delete old encryption state**: ```bash rm -f ~/.claway/platforms/matrix/store/crypto.db rm -f ~/.claway/platforms/matrix/store/crypto_store.* ``` 3. **Set your recovery key** (if you use cross-signing — most Element users do). Add to `~/.claway/.env`: ```bash MATRIX_RECOVERY_KEY=EsT... your recovery key here ``` This lets the bot self-sign with cross-signing keys on startup, so Element trusts the new device immediately. Without this, Element may see the new device as unverified and refuse to share encryption sessions. Find your recovery key in Element under **Settings** → **Security & Privacy** → **Encryption**. 4. **Force your Matrix client to rotate the encryption session**. In Element, open the DM room with the bot and type `/discardsession`. This forces Element to create a new encryption session and share it with the bot's new device. 5. **Restart the gateway**: ```bash claway gateway run ``` If `MATRIX_RECOVERY_KEY` is set, you should see `Matrix: cross-signing verified via recovery key` in the logs. 6. **Send a new message**. The bot should decrypt and respond normally. :::note After migration, messages sent *before* the upgrade cannot be decrypted -- the old encryption keys are gone. This only affects the transition; new messages work normally. ::: :::tip **New installations are not affected.** This migration is only needed if you had a working E2EE setup with a previous version of Claway and are upgrading. **Why a new access token?** Each Matrix access token is bound to a specific device ID. Reusing the same device ID with new encryption keys causes other Matrix clients to distrust the device (they see changed identity keys as a potential security breach). A new access token gets a new device ID with no stale key history, so other clients trust it immediately. ::: ## Proxy Mode (E2EE on macOS) Matrix E2EE requires `libolm`, which doesn't compile on macOS ARM64 (Apple Silicon). The `claway[matrix]` extra is gated to Linux only. If you're on macOS, proxy mode lets you run E2EE in a Docker container on a Linux VM while the actual agent runs natively on macOS with full access to your local files, memory, and skills. ### How It Works ``` macOS (Host): └─ claway gateway ├─ api_server adapter ← listens on 0.0.0.0:8642 ├─ AIAgent ← single source of truth ├─ Sessions, memory, skills └─ Local file access (Obsidian, projects, etc.) Linux VM (Docker): └─ claway gateway (proxy mode) ├─ Matrix adapter ← E2EE decryption/encryption └─ HTTP forward → macOS:8642/v1/chat/completions (no LLM API keys, no agent, no inference) ``` The Docker container only handles Matrix protocol + E2EE. When a message arrives, it decrypts it and forwards the text to the host via a standard HTTP request. The host runs the agent, calls tools, generates a response, and streams it back. The container encrypts and sends the response to Matrix. All sessions are unified — CLI, Matrix, Telegram, and any other platform share the same memory and conversation history. ### Step 1: Configure the Host (macOS) Enable the API server so the host accepts incoming requests from the Docker container. Add to `~/.claway/.env`: ```bash API_SERVER_ENABLED=true API_SERVER_KEY=your-secret-key-here API_SERVER_HOST=0.0.0.0 ``` - `API_SERVER_HOST=0.0.0.0` binds to all interfaces so the Docker container can reach it. - `API_SERVER_KEY` is required for non-loopback binding. Pick a strong random string. - The API server runs on port 8642 by default (change with `API_SERVER_PORT` if needed). Start the gateway: ```bash claway gateway ``` You should see the API server start alongside any other platforms you have configured. Verify it's reachable from the VM: ```bash # From the Linux VM curl http://<mac-ip>:8642/health ``` ### Step 2: Configure the Docker Container (Linux VM) The container needs Matrix credentials and the proxy URL. It does NOT need LLM API keys. **`docker-compose.yml`:** ```yaml services: claway-matrix: build: . environment: # Matrix credentials MATRIX_HOMESERVER: "https://matrix.example.org" MATRIX_ACCESS_TOKEN: "syt_..." MATRIX_ALLOWED_USERS: "@you:matrix.example.org" MATRIX_ENCRYPTION: "true" MATRIX_DEVICE_ID: "CLAWAY_BOT" # Proxy mode — forward to host agent GATEWAY_PROXY_URL: "http://192.168.1.100:8642" GATEWAY_PROXY_KEY: "your-secret-key-here" volumes: - ./matrix-store:/root/.claway/platforms/matrix/store ``` **`Dockerfile`:** ```dockerfile FROM python:3.11-slim RUN apt-get update && apt-get install -y libolm-dev && rm -rf /var/lib/apt/lists/* RUN cd ~/.claway/claway && uv pip install -e ".[matrix]" CMD ["claway", "gateway"] ``` That's the entire container. No API keys for OpenRouter, Anthropic, or any inference provider. ### Step 3: Start Both 1. Start the host gateway first: ```bash claway gateway ``` 2. Start the Docker container: ```bash docker compose up -d ``` 3. Send a message in an encrypted Matrix room. The container decrypts it, forwards it to the host, and streams the response back. ### Configuration Reference Proxy mode is configured on the **container side** (the thin gateway): | Setting | Description | |---------|-------------| | `GATEWAY_PROXY_URL` | URL of the remote Claway API server (e.g., `http://192.168.1.100:8642`) | | `GATEWAY_PROXY_KEY` | Bearer token for authentication (must match `API_SERVER_KEY` on the host) | | `gateway.proxy_url` | Same as `GATEWAY_PROXY_URL` but in `config.yaml` | The host side needs: | Setting | Description | |---------|-------------| | `API_SERVER_ENABLED` | Set to `true` | | `API_SERVER_KEY` | Bearer token (shared with the container) | | `API_SERVER_HOST` | Set to `0.0.0.0` for network access | | `API_SERVER_PORT` | Port number (default: `8642`) | ### Works for Any Platform Proxy mode is not limited to Matrix. Any platform adapter can use it — set `GATEWAY_PROXY_URL` on any gateway instance and it will forward to the remote agent instead of running one locally. This is useful for any deployment where the platform adapter needs to run in a different environment from the agent (network isolation, E2EE requirements, resource constraints). :::tip Session continuity is maintained via the `X-Claway-Session-Id` header. The host's API server tracks sessions by this ID, so conversations persist across messages just like they would with a local agent. ::: :::note **Limitations (v1):** Tool progress messages from the remote agent are not relayed back — the user sees the streamed final response only, not individual tool calls. Dangerous command approval prompts are handled on the host side, not relayed to the Matrix user. These can be addressed in future updates. ::: ### Bot connects and sends, but ignores inbound messages **Cause**: Matrix event handlers only fire when sync payloads are dispatched through mautrix's `handle_sync()` machinery. A raw `client.sync()` poll that never calls `handle_sync()` can leave the adapter connected (send works) while inbound messages never reach `_on_room_message`. **Fix**: Claway uses an explicit sync loop that calls `client.handle_sync()` on both the initial sync and every incremental sync response. This keeps Claway's own background maintenance tasks (joined-room tracking, invite handling, E2EE key share) instead of delegating the full lifecycle to `client.start()`. If inbound messages still fail after a gateway restart, verify handlers are registered before the first sync and check logs for `sync event dispatch error`. ### Sync issues / bot falls behind **Cause**: Long-running tool executions can delay the sync loop, or the homeserver is slow. **Fix**: The sync loop automatically retries every 5 seconds on error. Check the Claway logs for sync-related warnings. If the bot consistently falls behind, ensure your homeserver has adequate resources. ### Bot is offline **Cause**: The Claway gateway isn't running, or it failed to connect. **Fix**: Check that `claway gateway` is running. Look at the terminal output for error messages. Common issues: wrong homeserver URL, expired access token, homeserver unreachable. ### "User not allowed" / Bot ignores you **Cause**: Your User ID isn't in `MATRIX_ALLOWED_USERS`. **Fix**: Add your User ID to `MATRIX_ALLOWED_USERS` in `~/.claway/.env` and restart the gateway. Use the full `@user:server` format. ### Bot ignores an entire room **Cause**: `MATRIX_ALLOWED_ROOMS` is set and the current room ID is not listed, or the room requires a mention and the message did not mention the bot. **Fix**: Add the room ID to `MATRIX_ALLOWED_ROOMS`, or remove the room allowlist if this is a personal deployment. To find a Room ID in Element, open room settings and check **Advanced**. ### Bridge messages loop or echo **Cause**: A bridge/appservice puppet is relaying bot output back as a new user message, or a bridge uses non-standard ghost user IDs. **Fix**: Keep bridge ghosts out of `MATRIX_ALLOWED_USERS`, add a matching `MATRIX_IGNORE_USER_PATTERNS` entry, and leave `MATRIX_PROCESS_NOTICES=false` unless notices are part of a trusted workflow. ## Security :::warning Always set `MATRIX_ALLOWED_USERS` and, for shared/private deployments, `MATRIX_ALLOWED_ROOMS`. Without them, anyone who can message the bot in a joined room may trigger the agent. Only authorize people and rooms you trust — authorized users have full access to the agent's capabilities, including tool use and system access. ::: For more information on securing your Claway Agent deployment, see the [Security Guide](../security.md). ## Notes - **Any homeserver**: Works with Synapse, Conduit, Dendrite, matrix.org, or any spec-compliant Matrix homeserver. No specific homeserver software required. - **Federation**: If you're on a federated homeserver, the bot can communicate with users from other servers — just add their full `@user:server` IDs to `MATRIX_ALLOWED_USERS`. - **Auto-join**: The bot automatically accepts room invites and joins. It starts responding immediately after joining. - **Media support**: Claway can send and receive images, audio, video, and file attachments. Media is uploaded to your homeserver using the Matrix content repository API. - **Native voice messages (MSC3245)**: The Matrix adapter automatically tags outgoing voice messages with the `org.matrix.msc3245.voice` flag. This means TTS responses and voice audio are rendered as **native voice bubbles** in Element and other clients that support MSC3245, rather than as generic audio file attachments. Incoming voice messages with the MSC3245 flag are also correctly identified and routed to speech-to-text transcription. No configuration is needed — this works automatically. --- <!-- source: website/docs/user-guide/messaging/mattermost.md --> # Mattermost # Mattermost Setup Claway Agent integrates with Mattermost as a bot, letting you chat with your AI assistant through direct messages or team channels. Mattermost is a self-hosted, open-source Slack alternative — you run it on your own infrastructure, keeping full control of your data. The bot connects via Mattermost's REST API (v4) and WebSocket for real-time events, processes messages through the Claway Agent pipeline (including tool use, memory, and reasoning), and responds in real time. It supports text, file attachments, images, and slash commands. No external Mattermost library is required — the adapter uses `aiohttp`, which is already a Claway dependency. Before setup, here's the part most people want to know: how Claway behaves once it's in your Mattermost instance. ## How Claway Behaves | Context | Behavior | |---------|----------| | **DMs** | Claway responds to every message. No `@mention` needed. Each DM has its own session. | | **Public/private channels** | Claway responds when you `@mention` it. Without a mention, Claway ignores the message. | | **Threads** | If `MATTERMOST_REPLY_MODE=thread`, Claway replies in a thread under your message. Thread context stays isolated from the parent channel. | | **Shared channels with multiple users** | By default, Claway isolates session history per user inside the channel. Two people talking in the same channel do not share one transcript unless you explicitly disable that. | :::tip If you want Claway to reply as threaded conversations (nested under your original message), set `MATTERMOST_REPLY_MODE=thread`. The default is `off`, which sends flat messages in the channel. ::: ### Session Model in Mattermost By default: - each DM gets its own session - each thread gets its own session namespace - each user in a shared channel gets their own session inside that channel This is controlled by `config.yaml`: ```yaml group_sessions_per_user: true ``` Set it to `false` only if you explicitly want one shared conversation for the entire channel: ```yaml group_sessions_per_user: false ``` Shared sessions can be useful for a collaborative channel, but they also mean: - users share context growth and token costs - one person's long tool-heavy task can bloat everyone else's context - one person's in-flight run can interrupt another person's follow-up in the same channel This guide walks you through the full setup process — from creating your bot on Mattermost to sending your first message. ## Step 1: Enable Bot Accounts Bot accounts must be enabled on your Mattermost server before you can create one. 1. Log in to Mattermost as a **System Admin**. 2. Go to **System Console** → **Integrations** → **Bot Accounts**. 3. Set **Enable Bot Account Creation** to **true**. 4. Click **Save**. :::info If you don't have System Admin access, ask your Mattermost administrator to enable bot accounts and create one for you. ::: ## Step 2: Create a Bot Account 1. In Mattermost, click the **☰** menu (top-left) → **Integrations** → **Bot Accounts**. 2. Click **Add Bot Account**. 3. Fill in the details: - **Username**: e.g., `claway` - **Display Name**: e.g., `Claway Agent` - **Description**: optional - **Role**: `Member` is sufficient 4. Click **Create Bot Account**. 5. Mattermost will display the **bot token**. **Copy it immediately.** :::warning[Token shown only once] The bot token is only displayed once when you create the bot account. If you lose it, you'll need to regenerate it from the bot account settings. Never share your token publicly or commit it to Git — anyone with this token has full control of the bot. ::: Store the token somewhere safe (a password manager, for example). You'll need it in Step 5. :::tip You can also use a **personal access token** instead of a bot account. Go to **Profile** → **Security** → **Personal Access Tokens** → **Create Token**. This is useful if you want Claway to post as your own user rather than a separate bot user. ::: ## Step 3: Add the Bot to Channels The bot needs to be a member of any channel where you want it to respond: 1. Open the channel where you want the bot. 2. Click the channel name → **Add Members**. 3. Search for your bot username (e.g., `claway`) and add it. For DMs, simply open a direct message with the bot — it will be able to respond immediately. ## Step 4: Find Your Mattermost User ID Claway Agent uses your Mattermost User ID to control who can interact with the bot. To find it: 1. Click your **avatar** (top-left corner) → **Profile**. 2. Your User ID is displayed in the profile dialog — click it to copy. Your User ID is a 26-character alphanumeric string like `3uo8dkh1p7g1mfk49ear5fzs5c`. :::warning Your User ID is **not** your username. The username is what appears after `@` (e.g., `@alice`). The User ID is a long alphanumeric identifier that Mattermost uses internally. ::: **Alternative**: You can also get your User ID via the API: ```bash curl -H "Authorization: Bearer YOUR_TOKEN" \ https://your-mattermost-server/api/v4/users/me | jq .id ``` :::tip To get a **Channel ID**: click the channel name → **View Info**. The Channel ID is shown in the info panel. You'll need this if you want to set a home channel manually. ::: ## Step 5: Configure Claway Agent ### Option A: Interactive Setup (Recommended) Run the guided setup command: ```bash claway gateway setup ``` Select **Mattermost** when prompted, then paste your server URL, bot token, and user ID when asked. ### Option B: Manual Configuration Add the following to your `~/.claway/.env` file: ```bash # Required MATTERMOST_URL=https://mm.example.com MATTERMOST_TOKEN=*** MATTERMOST_ALLOWED_USERS=3uo8dkh1p7g1mfk49ear5fzs5c # Multiple allowed users (comma-separated) # MATTERMOST_ALLOWED_USERS=3uo8dkh1p7g1mfk49ear5fzs5c,8fk2jd9s0a7bncm1xqw4tp6r3e # Optional: reply mode (thread or off, default: off) # MATTERMOST_REPLY_MODE=thread # Optional: respond without @mention (default: true = require mention) # MATTERMOST_REQUIRE_MENTION=false # Optional: channels where bot responds without @mention (comma-separated channel IDs) # MATTERMOST_FREE_RESPONSE_CHANNELS=channel_id_1,channel_id_2 ``` Optional behavior settings in `~/.claway/config.yaml`: ```yaml group_sessions_per_user: true ``` - `group_sessions_per_user: true` keeps each participant's context isolated inside shared channels and threads ### Start the Gateway Once configured, start the Mattermost gateway: ```bash claway gateway ``` The bot should connect to your Mattermost server within a few seconds. Send it a message — either a DM or in a channel where it's been added — to test. :::tip You can run `claway gateway` in the background or as a systemd service for persistent operation. See the deployment docs for details. ::: ## Home Channel You can designate a "home channel" where the bot sends proactive messages (such as cron job output, reminders, and notifications). There are two ways to set it: ### Using the Slash Command Type `/sethome` in any Mattermost channel where the bot is present. That channel becomes the home channel. ### Manual Configuration Add this to your `~/.claway/.env`: ```bash MATTERMOST_HOME_CHANNEL=abc123def456ghi789jkl012mn ``` Replace the ID with the actual channel ID (click the channel name → View Info → copy the ID). ## Reply Mode The `MATTERMOST_REPLY_MODE` setting controls how Claway posts responses: | Mode | Behavior | |------|----------| | `off` (default) | Claway posts flat messages in the channel, like a normal user. | | `thread` | Claway replies in a thread under your original message. Keeps channels clean when there's lots of back-and-forth. | Set it in your `~/.claway/.env`: ```bash MATTERMOST_REPLY_MODE=thread ``` ## Mention Behavior By default, the bot only responds in channels when `@mentioned`. You can change this: | Variable | Default | Description | |----------|---------|-------------| | `MATTERMOST_REQUIRE_MENTION` | `true` | Set to `false` to respond to all messages in channels (DMs always work). | | `MATTERMOST_FREE_RESPONSE_CHANNELS` | _(none)_ | Comma-separated channel IDs where the bot responds without `@mention`, even when require_mention is true. | To find a channel ID in Mattermost: open the channel, click the channel name header, and look for the ID in the URL or channel details. When the bot is `@mentioned`, the mention is automatically stripped from the message before processing. ## Channel allowlist (`allowed_channels`) Restrict the bot to a fixed set of Mattermost channels. When set, the bot **only** responds in channels whose ID appears in the list — messages from any other channel are silently ignored, even if the bot is `@mentioned`. **DMs are exempt** from this filter, so authorized users can always reach the bot in a direct message. ```yaml mattermost: allowed_channels: - "abc123def456ghi789jkl012mno" # #ops - "xyz987uvw654rst321opq098nml" # #incident-response ``` Or via env var (comma-separated): ```bash MATTERMOST_ALLOWED_CHANNELS="abc123def456ghi789jkl012mno,xyz987uvw654rst321opq098nml" ``` Behavior: - Empty / unset → no restriction (fully backward compatible). - Non-empty → channel ID must be on the list, or the message is dropped before any other gating (mention requirement, `MATTERMOST_FREE_RESPONSE_CHANNELS`, etc.) runs. - Find a channel ID via the Mattermost UI → channel header → "View Info", or read it from the channel URL. See also: [admin/user slash command split](../../reference/slash-commands.md#permissions-and-adminuser-split). ## Troubleshooting ### Bot is not responding to messages **Cause**: The bot is not a member of the channel, or `MATTERMOST_ALLOWED_USERS` doesn't include your User ID. **Fix**: Add the bot to the channel (channel name → Add Members → search for the bot). Verify your User ID is in `MATTERMOST_ALLOWED_USERS`. Restart the gateway. ### 403 Forbidden errors **Cause**: The bot token is invalid, or the bot doesn't have permission to post in the channel. **Fix**: Check that `MATTERMOST_TOKEN` in your `.env` file is correct. Make sure the bot account hasn't been deactivated. Verify the bot has been added to the channel. If using a personal access token, ensure your account has the required permissions. ### WebSocket disconnects / reconnection loops **Cause**: Network instability, Mattermost server restarts, or firewall/proxy issues with WebSocket connections. **Fix**: The adapter automatically reconnects with exponential backoff (2s → 60s). Check your server's WebSocket configuration — reverse proxies (nginx, Apache) need WebSocket upgrade headers configured. Verify no firewall is blocking WebSocket connections on your Mattermost server. For nginx, ensure your config includes: ```nginx location /api/v4/websocket { proxy_pass http://mattermost-backend; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_read_timeout 600s; } ``` ### "Failed to authenticate" on startup **Cause**: The token or server URL is incorrect. **Fix**: Verify `MATTERMOST_URL` points to your Mattermost server (include `https://`, no trailing slash). Check that `MATTERMOST_TOKEN` is valid — try it with curl: ```bash curl -H "Authorization: Bearer YOUR_TOKEN" \ https://your-server/api/v4/users/me ``` If this returns your bot's user info, the token is valid. If it returns an error, regenerate the token. ### Bot is offline **Cause**: The Claway gateway isn't running, or it failed to connect. **Fix**: Check that `claway gateway` is running. Look at the terminal output for error messages. Common issues: wrong URL, expired token, Mattermost server unreachable. ### "User not allowed" / Bot ignores you **Cause**: Your User ID isn't in `MATTERMOST_ALLOWED_USERS`. **Fix**: Add your User ID to `MATTERMOST_ALLOWED_USERS` in `~/.claway/.env` and restart the gateway. Remember: the User ID is a 26-character alphanumeric string, not your `@username`. ## Per-Channel Prompts Assign ephemeral system prompts to specific Mattermost channels. The prompt is injected at runtime on every turn — never persisted to transcript history — so changes take effect immediately. ```yaml mattermost: channel_prompts: "channel_id_abc123": | You are a research assistant. Focus on academic sources, citations, and concise synthesis. "channel_id_def456": | Code review mode. Be precise about edge cases and performance implications. ``` Keys are Mattermost channel IDs (find them in the channel URL or via the API). All messages in the matching channel get the prompt injected as an ephemeral system instruction. ## Security :::warning Always set `MATTERMOST_ALLOWED_USERS` to restrict who can interact with the bot. Without it, the gateway denies all users by default as a safety measure. Only add User IDs of people you trust — authorized users have full access to the agent's capabilities, including tool use and system access. ::: For more information on securing your Claway Agent deployment, see the [Security Guide](../security.md). ## Notes - **Self-hosted friendly**: Works with any self-hosted Mattermost instance. No Mattermost Cloud account or subscription required. - **No extra dependencies**: The adapter uses `aiohttp` for HTTP and WebSocket, which is already included with Claway Agent. - **Team Edition compatible**: Works with both Mattermost Team Edition (free) and Enterprise Edition. --- <!-- source: website/docs/user-guide/messaging/msgraph-webhook.md --> # Microsoft Graph Webhook Listener # Microsoft Graph Webhook Listener The `msgraph_webhook` gateway platform is an inbound event listener. It's how Claway receives **change notifications** from Microsoft Graph — "a Teams meeting ended," "a new message landed in this chat," "this calendar event was updated." Different from the `teams` platform (which is a chat bot users type to) — this one is M365 telling Claway something happened, not a person. Right now the primary consumer is the Teams meeting summary pipeline: Graph notifies when a meeting produces a transcript, the pipeline fetches it, and Claway posts a summary back into Teams. Other Graph resources (`/chats/.../messages`, `/users/.../events`) use the same listener — the pipeline consumers land with their own PRs. ## Prerequisites - Microsoft Graph application credentials — [Register a Microsoft Graph Application](/guides/microsoft-graph-app-registration) - A **public HTTPS URL** that Microsoft Graph can reach (Graph does not call private endpoints). A dev tunnel works for testing; production needs a real domain with a valid certificate. - A strong shared secret to use as the `clientState` value. Generate with `openssl rand -hex 32` and put it in `~/.claway/.env` as `MSGRAPH_WEBHOOK_CLIENT_STATE`. ## Quick Start Minimum `~/.claway/config.yaml`: ```yaml platforms: msgraph_webhook: enabled: true extra: host: 127.0.0.1 port: 8646 client_state: "replace-with-a-strong-secret" accepted_resources: - "communications/onlineMeetings" ``` Or via env vars in `~/.claway/.env` (auto-merged on startup): ```bash MSGRAPH_WEBHOOK_ENABLED=true MSGRAPH_WEBHOOK_PORT=8646 MSGRAPH_WEBHOOK_CLIENT_STATE=<generate-with-openssl-rand-hex-32> MSGRAPH_WEBHOOK_ACCEPTED_RESOURCES=communications/onlineMeetings ``` Note: the bind host is read from `extra.host` in `config.yaml` (see the example above); there is no `MSGRAPH_WEBHOOK_HOST` env-var override. Start the gateway: `claway gateway run`. The listener exposes: - `POST /msgraph/webhook` — change notifications from Graph - `GET /msgraph/webhook?validationToken=...` — Graph subscription validation handshake - `GET /health` — readiness probe with accepted/duplicate counters Expose the listener publicly (reverse proxy, dev tunnel, ingress). Your notification URL for Graph subscriptions is your public HTTPS origin followed by `/msgraph/webhook`: ``` https://ops.example.com/msgraph/webhook ``` ## Configuration All settings go under `platforms.msgraph_webhook.extra`: | Setting | Default | Description | |---------|---------|-------------| | `host` | `0.0.0.0` | Bind address for the HTTP listener. Non-loopback binds require `allowed_source_cidrs`; loopback (`127.0.0.1` / `::1`) is the easiest dev-tunnel / reverse-proxy setup. | | `port` | `8646` | Bind port. | | `webhook_path` | `/msgraph/webhook` | URL path Graph POSTs to. | | `health_path` | `/health` | Readiness endpoint. | | `client_state` | — | Shared secret Graph echoes in every notification. Compared with `hmac.compare_digest` — generate with `openssl rand -hex 32`. | | `accepted_resources` | `[]` (accept all) | Allowlist of Graph resource paths/patterns. Trailing `*` acts as prefix match. Leading `/` is tolerated. Example: `["communications/onlineMeetings", "chats/*/messages"]`. | | `max_seen_receipts` | `5000` | Dedupe cache size for notification IDs. Oldest entries evicted when the cap is hit. | | `allowed_source_cidrs` | `[]` | Required for non-loopback binds. Leave empty only when the listener is bound to loopback and fronted by a local tunnel / reverse proxy. | Most settings also have an equivalent env var (`MSGRAPH_WEBHOOK_*`) that merges into the config at gateway startup (the exception is `host`, which is config-only — see the note above) — see the [environment variables reference](/reference/environment-variables#microsoft-graph-teams-meetings). ## Security Hardening ### clientState is the primary auth check Every Graph notification includes the `clientState` string your subscription registered with. The listener rejects any notification whose `clientState` doesn't match, using timing-safe comparison. This is Microsoft's documented mechanism — treat the value as a strong shared secret. If `client_state` is unset, the listener refuses to start. ### Source-IP allowlisting (production deployments) For production, restrict the listener to Microsoft's published Graph webhook source IP ranges. Microsoft documents the egress ranges under the [Office 365 IP Address and URL Web service](https://learn.microsoft.com/en-us/microsoft-365/enterprise/urls-and-ip-address-ranges). Configure them as: ```yaml platforms: msgraph_webhook: enabled: true extra: host: 0.0.0.0 client_state: "..." allowed_source_cidrs: - "52.96.0.0/14" - "52.104.0.0/14" # ...add the current Microsoft 365 "Common" + "Teams" category egress ranges ``` Or as an env var: ```bash MSGRAPH_WEBHOOK_ALLOWED_SOURCE_CIDRS="52.96.0.0/14,52.104.0.0/14" ``` Binding a non-loopback host such as `0.0.0.0`, `::`, or a LAN IP without `allowed_source_cidrs` is refused at startup. If you're using a dev tunnel or reverse proxy on the same machine, bind Claway to `127.0.0.1` or `::1` and leave the allowlist empty there. Invalid CIDR strings log a warning and are ignored. **Review the Microsoft IP list quarterly** — it changes. ### HTTPS termination The listener speaks plain HTTP. Terminate TLS at your reverse proxy (Caddy, Nginx, Cloudflare Tunnel, AWS ALB) and proxy to the listener over the local network. Graph refuses to deliver to non-HTTPS endpoints, so there's no path for unencrypted traffic to reach you from Graph itself. ### Response hygiene On success the listener returns `202 Accepted` with an empty body — internal counters stay out of the wire response. Operators can observe counts via `/health`, which is guarded by the same source-IP rules as the webhook path. Status code table: | Outcome | Status | |---------|--------| | Notification(s) accepted or deduped | 202 | | Validation handshake (GET with `validationToken`) | 200 (echoes the token) | | Every item in batch failed clientState | 403 | | Malformed JSON / missing `value` array / unknown resource | 400 | | Source IP not in allowlist | 403 | | Bare GET without `validationToken` | 400 | ## Troubleshooting | Problem | What to check | |---------|---------------| | Graph subscription validation fails | Public URL is reachable, `/msgraph/webhook` path matches, GET with `validationToken` echoes the token verbatim as `text/plain` within 10 seconds. | | Notifications POST but nothing ingests | `client_state` matches what you registered the subscription with. Re-run `openssl rand -hex 32` and create a new subscription if the value drifted. Check `accepted_resources` includes the resource path Graph is sending. | | Every notification 403s | `clientState` mismatch (forged, or subscription registered with a different value). Re-create the subscription with `claway teams-pipeline subscribe --client-state "$MSGRAPH_WEBHOOK_CLIENT_STATE" ...` (ships with the pipeline runtime PR). | | Listener refuses to start on `0.0.0.0` | Set `allowed_source_cidrs` to Microsoft's current webhook egress ranges, or bind Claway to `127.0.0.1` / `::1` behind your tunnel or reverse proxy. | | Listener starts but `curl http://localhost:8646/health` hangs | Port binding collision. Check `ss -tlnp \| grep 8646` and change `port:` if needed. | | Real Graph requests from Microsoft get 403'd | Source IP allowlist is too narrow. Widen the list to include the current Microsoft egress ranges. If you're still validating the tunnel path, bind Claway to loopback and let the tunnel handle public exposure. | ## Related Docs - [Register a Microsoft Graph Application](/guides/microsoft-graph-app-registration) — Azure app registration prereq - [Environment Variables → Microsoft Graph](/reference/environment-variables#microsoft-graph-teams-meetings) — full env var list - [Microsoft Teams bot setup](/user-guide/messaging/teams) — the different platform that lets users chat with Claway in Teams --- <!-- source: website/docs/user-guide/messaging/ntfy.md --> # user-guide/messaging/ntfy.md # ntfy [ntfy](https://ntfy.sh/) is a simple HTTP-based pub-sub notification service. It works with the free public server at `ntfy.sh` or any self-hosted instance, and supports any client that can make HTTP requests — phones, browsers, scripts, watches. ntfy makes a great lightweight push channel for Claway: subscribe to a topic from the [ntfy mobile app](https://ntfy.sh/docs/subscribe/phone/), send messages to the topic to talk to the agent, get the response back on your phone. > Run `claway gateway setup` and pick **ntfy** for a guided walk-through. ## Prerequisites - A topic name (any unique string — `claway-myname-2026` works fine) - The [ntfy mobile app](https://ntfy.sh/docs/subscribe/phone/) installed and subscribed to that topic - Optional: a self-hosted ntfy server, or an `ntfy.sh` account token for private/reserved topics That's it. No SDK, no daemon, no Node.js. The adapter uses `httpx` which is already a Claway dependency. ## Configure Claway ### Via setup wizard ```bash claway gateway setup ``` Select **ntfy** and follow the prompts. ### Via environment variables Add these to `~/.claway/.env`: ``` NTFY_TOPIC=claway-myname-2026 NTFY_ALLOWED_USERS=claway-myname-2026 NTFY_HOME_CHANNEL=claway-myname-2026 ``` | Variable | Required | Description | |---|---|---| | `NTFY_TOPIC` | Yes | Topic to subscribe to (incoming messages) | | `NTFY_SERVER_URL` | Optional | Server URL (default: `https://ntfy.sh`) — point to a self-hosted ntfy for privacy | | `NTFY_TOKEN` | Optional | Bearer token (e.g. `tk_xyz`) or `user:pass` for Basic auth | | `NTFY_PUBLISH_TOPIC` | Optional | Different topic for outgoing replies (defaults to `NTFY_TOPIC`) | | `NTFY_MARKDOWN` | Optional | Set `true` to send replies with `X-Markdown: true` header | | `NTFY_ALLOWED_USERS` | Recommended | Comma-separated topic names allowed (treated as user IDs; see below) | | `NTFY_ALLOW_ALL_USERS` | Optional | Set `true` to allow every publisher — only safe for private topics with read tokens | | `NTFY_HOME_CHANNEL` | Optional | Default topic for cron / notification delivery | | `NTFY_HOME_CHANNEL_NAME` | Optional | Human label for the home channel | ## Identity model — read this before deploying ntfy has no native authenticated user identity. The `title` field on a published message is **publisher-controlled** and can be anything the sender wants. The Claway adapter does NOT use `title` for authorization — it would let any publisher who knows the topic spoof an allowed user. Instead, **the topic name itself is the identity**. Every message published to the topic is treated as coming from the same logical user (the topic). `NTFY_ALLOWED_USERS` is therefore typically just the topic name itself — a single-entry allowlist that gates the whole channel. This means **anyone who knows the topic can talk to the agent**. To make that a real trust boundary: - **Self-host ntfy** and lock the topic down with [Access Control](https://docs.ntfy.sh/config/#access-control). Only authorized clients with the read/write token can publish. - Or **use a private topic on ntfy.sh** ([reserved topics](https://docs.ntfy.sh/publish/#reserved-topics) require an account) and protect it with a `NTFY_TOKEN`. - Or **pick a long, unguessable topic name** (`claway-7d4f9c8b-2026`) and treat it as the shared secret. This is the lightest setup but the topic name leaks via any logs or screenshots. In all cases, do not put sensitive data through ntfy unless the underlying topic is access-controlled. ## Quick start — talk to your agent from your phone 1. Pick a topic name: `claway-myname-2026` 2. On your phone: install the [ntfy app](https://ntfy.sh/docs/subscribe/phone/), tap **+**, enter `claway-myname-2026` 3. On the host: ```bash echo 'NTFY_TOPIC=claway-myname-2026' >> ~/.claway/.env echo 'NTFY_ALLOWED_USERS=claway-myname-2026' >> ~/.claway/.env claway gateway restart ``` 4. From the ntfy app, send a message to the topic. The agent's reply lands as a push notification. ## Using ntfy with cron jobs Once `NTFY_HOME_CHANNEL` is set, cron jobs can deliver to ntfy: ```python cronjob( action="create", schedule="every 1h", deliver="ntfy", # uses NTFY_HOME_CHANNEL prompt="Check for alerts and summarise." ) ``` Or target a specific topic explicitly via the cron job's `deliver:` field, or from a shell script with the [`claway send` CLI](/guides/pipe-script-output): ```bash claway send ntfy:alerts-channel "Done!" ``` This works even when the cron runs out-of-process from the gateway — the plugin registers a `standalone_sender_fn` that opens its own HTTP connection. ## Self-hosting ntfy If you want full control: ```bash # Docker docker run -p 80:80 -it binwiederhier/ntfy serve # Native go install heckel.io/ntfy/v2@latest ntfy serve ``` Then point Claway at it: ``` NTFY_SERVER_URL=https://ntfy.mydomain.com NTFY_TOPIC=claway NTFY_TOKEN=tk_abc123 # if you've set up access control ``` Self-hosting gives you topic access control, message persistence policies, attachments, and emoji tags. See the [ntfy server docs](https://docs.ntfy.sh/install/). ## Markdown formatting ntfy clients render markdown when the publisher sets the `X-Markdown: true` header. To enable for outgoing Claway replies: ``` NTFY_MARKDOWN=true ``` Or in `config.yaml`: ```yaml platforms: ntfy: extra: markdown: true ``` The mobile app supports a subset of CommonMark — bold, italic, lists, links, fenced code blocks. See [ntfy's markdown docs](https://docs.ntfy.sh/publish/#markdown-formatting) for the exact set. ## Outgoing-only setup (notifications without inbound) If you only want Claway to *push* notifications to ntfy (cron summaries, alerts) and never accept messages back, set both `NTFY_TOPIC` and `NTFY_PUBLISH_TOPIC` to the same value and skip `NTFY_ALLOWED_USERS` entirely. With no allowlist, the agent never responds to inbound messages — your phone gets the pushes, but the conversation is one-way. ## Limits - **Message size**: ntfy caps message bodies at 4096 chars. Claway truncates with a warning when this is exceeded. - **No typing indicators**: the protocol doesn't expose one; `send_typing` is a no-op. - **No threads or attachments**: ntfy is plain push notifications. Long replies stay in the message body, no thread fanout. - **No native user identity**: see the identity-model section above. ## Troubleshooting **Auth failure / 401** — `NTFY_TOKEN` is wrong, or the token doesn't have publish/subscribe rights on this topic. The adapter halts its reconnect loop on 401 and the gateway runtime status will show `fatal: ntfy_unauthorized`. Fix the token and restart the gateway. **Topic not found / 404** — `NTFY_TOPIC` doesn't exist on the configured server. For ntfy.sh, topics are auto-created on first publish, so a 404 means you're pointed at a self-hosted server that doesn't have the topic provisioned. The adapter halts its reconnect loop with `fatal: ntfy_topic_not_found`. **Connected but no messages** — Check that `NTFY_ALLOWED_USERS` includes the topic name itself. With ntfy's identity model, the topic IS the user; leaving the allowlist empty rejects everything. **Reconnects every 60s** — The stream keepalive default is 55s; ntfy may have intermittent network issues. The adapter applies exponential backoff (2 → 5 → 10 → 30 → 60s) and resets to 0 once a stream stays alive ≥60s. --- <!-- source: website/docs/user-guide/messaging/photon.md --> # user-guide/messaging/photon.md # Photon iMessage Connect Claway to **iMessage** through [Photon][photon], a managed service that handles the Apple line allocation and abuse-prevention layer so you don't have to run your own Mac relay. The free tier uses Photon's shared iMessage line pool — different recipients may see different sending numbers, but each conversation stays stable. The paid Business tier gives every user the same dedicated number; the plugin supports both, and the free tier is the recommended starting point. :::info Free to start Photon's shared-line pool is free. No subscription is required to send your first iMessage from Claway — just a phone number we can bind to your account. ::: ## Architecture Photon is a **persistent-connection** channel, like Discord or Slack — **no webhook, no public URL, no signing secret to manage.** The `spectrum-ts` SDK holds a long-lived **gRPC stream** to Photon for both directions. Because the SDK is TypeScript-only, Claway runs it in a small supervised **Node sidecar** and talks to it over loopback: - **Inbound** — the sidecar consumes the SDK's `app.messages` gRPC stream and forwards each message to the Python adapter over a loopback `GET /inbound` (NDJSON). The adapter dedupes and dispatches it to the agent, reconnecting automatically if the stream drops. - **Outbound** — replies are loopback POSTs to the sidecar, which calls `space.send(...)` on the SDK. The Python plugin starts, supervises, and shuts down the sidecar automatically. ## Prerequisites - A Photon account — sign up at [app.photon.codes][app] - **Node.js 18.17 or newer** on PATH (`node --version`) - A phone number that can receive iMessage (used to bind your account) That's it — there is no public URL or tunnel to set up. ## First-time setup Either run the unified gateway wizard and pick **Photon iMessage**: ```bash claway gateway setup ``` …or run the Photon setup directly (the wizard calls the same flow): ```bash # Device-code login + project + user + sidecar deps, all in one claway photon setup --phone +15551234567 ``` The setup, in order: 1. **Device login** (`client_id=photon-cli`) — opens `https://app.photon.codes/` for approval and stores the bearer token. 2. **Finds or creates** the `Claway Agent` project on your account. 3. **Enables Spectrum**, reads the project's Spectrum id, and rotates the project secret. 4. **Registers your phone number** as a Spectrum user — skipped if a user with that number already exists, so re-running is safe. 5. **Prints your assigned iMessage line** — the number you text to reach your agent. 6. **Runs `npm install`** inside the plugin's sidecar directory. Runtime credentials are written to `~/.claway/.env` (`PHOTON_PROJECT_ID` = the Spectrum project id, `PHOTON_PROJECT_SECRET`), the same place every other channel keeps its token. Management metadata (device token, dashboard project id) lives in `~/.claway/auth.json` under `credential_pool.photon` / `credential_pool.photon_project`. ## Authorizing users Photon uses the same authorization model as every other Claway channel. Choose one approach: **DM pairing (default).** When an unknown number messages your Photon line, Claway replies with a pairing code. Approve it with: ```bash claway pairing approve photon <CODE> ``` Use `claway pairing list` to see pending codes and approved users. **Pre-authorize specific numbers** (in `~/.claway/.env`): ```bash PHOTON_ALLOWED_USERS=+15551234567,+15559876543 ``` **Open access** (dev only, in `~/.claway/.env`): ```bash PHOTON_ALLOW_ALL_USERS=true ``` When `PHOTON_ALLOWED_USERS` is set, unknown senders are silently ignored rather than offered a pairing code (the allowlist signals you deliberately restricted access). ### Require mentions in group chats By default Claway responds to every authorized DM and group message. To make group chats opt-in, enable mention gating (DMs still always work): ```yaml gateway: platforms: photon: enabled: true require_mention: true ``` With `require_mention: true`, group-chat messages are ignored unless they match a wake-word pattern. The defaults match `Claway` and `@Claway agent` variants. For a custom agent name, set regex patterns: ```yaml gateway: platforms: photon: require_mention: true mention_patterns: - '(?<![\w@])@?amos\b[,:\-]?' ``` Both keys also accept env vars (`PHOTON_REQUIRE_MENTION`, `PHOTON_MENTION_PATTERNS`). This is the same mention-gating model the BlueBubbles iMessage channel uses. ## Start the gateway ```bash claway gateway start ``` You'll see something like: ``` [photon] connected — sidecar on 127.0.0.1:8789, streaming inbound over gRPC ``` Send an iMessage to your assigned number and Claway will reply. ## Status & troubleshooting ```bash claway photon status ``` Prints saved credentials, sidecar health, your registered number, and the assigned iMessage line Claway uses. When a Photon token and dashboard project are available, `status` refreshes missing number rows from the dashboard without provisioning new lines. ``` Photon iMessage status ────────────────────── device token : ✓ stored dashboard project : 3c90c3cc-0d44-4b50-... spectrum project id : sp-... project secret : ✓ stored my number : +15551234567 assigned number : +16282679185 node binary : /usr/bin/node sidecar deps : ✓ installed ``` Common issues: - **`sidecar deps : ✗ run claway photon install-sidecar`** — Node is installed but `spectrum-ts` isn't. Run the suggested command. - **`device token : ✗ missing`** — run `claway photon setup` to log in. - **`No iMessage line assigned yet`** — Spectrum is enabled but no line has been provisioned; re-run `claway photon setup` or check the [dashboard][app]. - **Sidecar won't start** — confirm `node --version` is 18.17+ and that `claway photon install-sidecar` completed without errors. ## Limits today - **Inbound attachments are metadata-only.** Inbound events carry the filename + MIME type; the agent sees a marker but can't yet read the bytes. The SDK exposes attachment bytes via `content.read()`, so this is a sidecar follow-up. - **Outbound attachments are supported.** Claway sends images, voice notes, video, and documents through spectrum-ts' `attachment()` / `voice()` content builders via the sidecar's `/send-attachment` endpoint. Captions arrive as a separate iMessage bubble after the media. - **Photon's free quotas:** 5,000 messages per server per day, 50 new-conversation initiations per shared line per day. Increases available — email `help@photon.codes`. ## Env vars | Variable | Default | Notes | |---------------------------|--------------------|--------------------------------------------| | `PHOTON_PROJECT_ID` | from `.env` | Spectrum project id (the SDK's `projectId`); set by setup | | `PHOTON_PROJECT_SECRET` | from `.env` | Project secret; set by setup | | `PHOTON_SIDECAR_PORT` | `8789` | Loopback port for the sidecar control + inbound channel | | `PHOTON_SIDECAR_AUTOSTART`| `true` | Whether the adapter spawns the sidecar | | `PHOTON_NODE_BIN` | `which node` | Override the Node binary path | | `PHOTON_HOME_CHANNEL` | (unset) | Default space id for cron / notifications | | `PHOTON_HOME_CHANNEL_NAME`| (unset) | Human label for the home channel | | `PHOTON_ALLOWED_USERS` | (unset) | Comma-separated E.164 allowlist | | `PHOTON_ALLOW_ALL_USERS` | `false` | Dev only — accept any sender | | `PHOTON_REQUIRE_MENTION` | `false` | Require a wake word before responding in groups | | `PHOTON_MENTION_PATTERNS` | Claway wake words | JSON list / comma / newline regex patterns for group mentions | | `PHOTON_DASHBOARD_HOST` | `app.photon.codes` | Override the dashboard / device-login host | | `PHOTON_SPECTRUM_HOST` | `spectrum.photon.codes` | Override the Spectrum API host | [photon]: https://photon.codes/ [app]: https://app.photon.codes/ --- <!-- source: website/docs/user-guide/messaging/qqbot.md --> # user-guide/messaging/qqbot.md # QQ Bot Connect Claway to QQ via the **Official QQ Bot API (v2)** — supporting private (C2C), group @-mentions, guild, and direct messages with voice transcription. ## Overview The QQ Bot adapter uses the [Official QQ Bot API](https://bot.q.qq.com/wiki/develop/api-v2/) to: - Receive messages via a persistent **WebSocket** connection to the QQ Gateway - Send text and markdown replies via the **REST API** - Download and process images, voice messages, and file attachments - Transcribe voice messages using Tencent's built-in ASR or a configurable STT provider ## Prerequisites 1. **QQ Bot Application** — Register at [q.qq.com](https://q.qq.com): - Create a new application and note your **App ID** and **App Secret** - Enable the required intents: C2C messages, Group @-messages, Guild messages - Configure your bot in sandbox mode for testing, or publish for production 2. **Dependencies** — The adapter requires `aiohttp` and `httpx`: ```bash pip install aiohttp httpx ``` ## Configuration ### Interactive setup ```bash claway gateway setup ``` Select **QQ Bot** from the platform list and follow the prompts. ### Manual configuration Set the required environment variables in `~/.claway/.env`: ```bash QQ_APP_ID=your-app-id QQ_CLIENT_SECRET=your-app-secret ``` ## Environment Variables | Variable | Description | Default | |---|---|---| | `QQ_APP_ID` | QQ Bot App ID (required) | — | | `QQ_CLIENT_SECRET` | QQ Bot App Secret (required) | — | | `QQBOT_HOME_CHANNEL` | OpenID for cron/notification delivery | — | | `QQBOT_HOME_CHANNEL_NAME` | Display name for home channel | `Home` | | `QQ_ALLOWED_USERS` | Comma-separated user OpenIDs for DM access | open (all users) | | `QQ_GROUP_ALLOWED_USERS` | Comma-separated group OpenIDs for group access | — | | `QQ_ALLOW_ALL_USERS` | Set to `true` to allow all DMs | `false` | | `QQ_PORTAL_HOST` | Override the QQ portal host (set to `sandbox.q.qq.com` for sandbox routing) | `q.qq.com` | | `QQ_STT_API_KEY` | API key for voice-to-text provider | — | | `QQ_STT_BASE_URL` | (Not read directly — set `platforms.qqbot.extra.stt.baseUrl` in `config.yaml` instead) | n/a | | `QQ_STT_MODEL` | STT model name | `glm-asr` | ## Advanced Configuration For fine-grained control, add platform settings to `~/.claway/config.yaml`: ```yaml platforms: qqbot: enabled: true extra: app_id: "your-app-id" client_secret: "your-secret" markdown_support: true # enable QQ markdown (msg_type 2). Config-only; no env-var equivalent. dm_policy: "open" # open | allowlist | disabled allow_from: - "user_openid_1" group_policy: "open" # open | allowlist | disabled group_allow_from: - "group_openid_1" stt: provider: "zai" # zai (GLM-ASR), openai (Whisper), etc. baseUrl: "https://open.bigmodel.cn/api/coding/paas/v4" apiKey: "your-stt-key" model: "glm-asr" ``` ## Voice Messages (STT) Voice transcription works in two stages: 1. **QQ built-in ASR** (free, always tried first) — QQ provides `asr_refer_text` in voice message attachments, which uses Tencent's own speech recognition 2. **Configured STT provider** (fallback) — If QQ's ASR doesn't return text, the adapter calls an OpenAI-compatible STT API: - **Zhipu/GLM (zai)**: Default provider, uses `glm-asr` model - **OpenAI Whisper**: Set `QQ_STT_BASE_URL` and `QQ_STT_MODEL` - Any OpenAI-compatible STT endpoint ## Troubleshooting ### Bot disconnects immediately (quick disconnect) This usually means: - **Invalid App ID / Secret** — Double-check your credentials at q.qq.com - **Missing permissions** — Ensure the bot has the required intents enabled - **Sandbox-only bot** — If the bot is in sandbox mode, it can only receive messages from QQ's sandbox test channel ### Voice messages not transcribed 1. Check if QQ's built-in `asr_refer_text` is present in the attachment data 2. If using a custom STT provider, verify `QQ_STT_API_KEY` is set correctly 3. Check gateway logs for STT error messages ### Messages not delivered - Verify the bot's **intents** are enabled at q.qq.com - Check `QQ_ALLOWED_USERS` if DM access is restricted - For group messages, ensure the bot is **@mentioned** (group policy may require allowlisting) - Check `QQBOT_HOME_CHANNEL` for cron/notification delivery ### Connection errors - Ensure `aiohttp` and `httpx` are installed: `pip install aiohttp httpx` - Check network connectivity to `api.sgroup.qq.com` and the WebSocket gateway - Review gateway logs for detailed error messages and reconnect behavior --- <!-- source: website/docs/user-guide/messaging/raft.md --> # Raft # Raft Setup Claway connects to [Raft](https://raft.build) as an external agent through a local wake-channel bridge. The adapter starts a loopback HTTP endpoint that receives content-free wake hints from the bridge, then injects them into the Claway gateway session pipeline. The agent reads and sends messages through the Raft CLI — the adapter never touches message bodies or delivery cursors. :::info Division of Labor - **The bridge** owns: wake-hint consumption, dedup, backoff, reconnection, at-least-once delivery, and proof logging. - **The Claway adapter** owns: a localhost wake endpoint and injecting a short notice into the agent's context. - **The agent** owns: pulling messages (`raft message check`), replying (`raft message send`), and all other Raft interactions via the CLI. The adapter holds no Raft credentials — only a per-session shared token for localhost auth between the bridge and the endpoint. ::: --- ## Prerequisites - A **Raft workspace** where you can create an External Agent - The **Raft CLI** installed and logged in to that External Agent profile - **aiohttp** — Python package (included in Claway `[all]` extras) In Raft, open the Agents menu, create an External Agent, and follow the setup card to install the Raft CLI and log in the agent profile. Once the agent is created, Raft shows a Claway setup guide with the environment variables and configuration needed to start the gateway. --- ## Setup Add to `~/.claway/.env`: ```bash RAFT_PROFILE=your-agent-profile ``` That's it — the adapter auto-enables when `RAFT_PROFILE` is set. It generates a per-session bridge token, picks an ephemeral port, and spawns the bridge child process automatically when the gateway starts. --- ## How It Works ``` Raft Server → Bridge (wake-hints SSE) → POST /wake → Claway Adapter → Agent context Agent → raft message check → Raft Server (message bodies) Agent → raft message send → Raft Server (replies) ``` 1. The Raft server sends wake hints to the bridge process via SSE. 2. The bridge forwards each hint as a `POST /wake` to the adapter's loopback endpoint. 3. The adapter validates the bridge token, verifies the payload is content-free, and injects a wake notice into the Claway session. 4. The agent sees the wake notice and uses the Raft CLI to read messages and reply. Wake payloads are **content-free by contract** — they carry metadata (event ID, message ID, timestamps) but never message bodies, channel names, or sender identities. The adapter rejects any payload containing content-shaped fields (`text`, `body`, `content`, `messages`, etc.). --- ## Bridge The adapter automatically spawns `raft agent bridge` as a child process, passing the endpoint URL and token. The bridge connects to the Raft server using the configured profile and begins forwarding wake hints. It is terminated when the gateway shuts down. --- ## Environment Variables | Variable | Description | Default | |----------|-------------|---------| | `RAFT_PROFILE` | Raft agent profile slug — auto-enables the adapter when set | _(required)_ | --- <!-- source: website/docs/user-guide/messaging/simplex.md --> # user-guide/messaging/simplex.md # SimpleX Chat [SimpleX Chat](https://simplex.chat/) is a private, decentralised messaging platform where users own their contacts and groups. Unlike other platforms, SimpleX assigns no persistent user IDs — every contact is identified by an opaque internal ID generated at connection time, which makes it one of the most private messengers available. > Run `claway gateway setup` and pick **SimpleX** for a guided walk-through. ## Prerequisites - The **simplex-chat** CLI installed and running as a daemon - Python package **websockets** (`pip install websockets`) ## Install simplex-chat Download the latest release from the [simplex-chat GitHub releases](https://github.com/simplex-chat/simplex-chat/releases) page: ```bash # Linux / macOS binary curl -L https://github.com/simplex-chat/simplex-chat/releases/latest/download/simplex-chat-ubuntu-22_04-x86_64 -o simplex-chat chmod +x simplex-chat ``` The SimpleX Chat project does not publish a prebuilt Docker image for the chat client; to run it under Docker, build from source from the [simplex-chat repository](https://github.com/simplex-chat/simplex-chat). ## Start the daemon ```bash simplex-chat -p 5225 ``` The daemon listens on WebSocket at `ws://127.0.0.1:5225` by default. ## Configure Claway ### Via setup wizard ```bash claway gateway setup ``` Select **SimpleX Chat** and follow the prompts. ### Via environment variables Add these to `~/.claway/.env`: ``` SIMPLEX_WS_URL=ws://127.0.0.1:5225 SIMPLEX_ALLOWED_USERS=<contact-id-1>,<contact-id-2> SIMPLEX_HOME_CHANNEL=<contact-id> ``` | Variable | Required | Description | |---|---|---| | `SIMPLEX_WS_URL` | Yes | WebSocket URL of the simplex-chat daemon | | `SIMPLEX_ALLOWED_USERS` | Recommended | Comma-separated allowlist. Each entry can be a numeric `contactId` **or** a display name — both forms work. | | `SIMPLEX_ALLOW_ALL_USERS` | Optional | Set `true` to allow every contact (use carefully) | | `SIMPLEX_AUTO_ACCEPT` | Optional | Auto-accept incoming contact requests (default: `true`) | | `SIMPLEX_GROUP_ALLOWED` | Optional | Comma-separated group IDs the bot participates in, or `*` for any group. Omit to ignore group messages entirely | | `SIMPLEX_HOME_CHANNEL` | Optional | Default contact/group ID for cron job delivery | | `SIMPLEX_HOME_CHANNEL_NAME` | Optional | Human label for the home channel | | `CLAWAY_SIMPLEX_TEXT_BATCH_DELAY` | Optional | Quiet-period seconds (default: `0.8`) used to concatenate rapid-fire inbound text messages into one event | ## Find your contact ID or display name After starting the daemon, open a conversation with your agent contact. The numeric `contactId` appears in session logs. If you'd rather use the display name shown in the SimpleX UI, that works too — `SIMPLEX_ALLOWED_USERS` accepts either form. ## Authorization By default **all contacts are denied**. You must either: 1. Set `SIMPLEX_ALLOWED_USERS` to a comma-separated list of `contactId`s and/or display names (e.g. `SIMPLEX_ALLOWED_USERS=4,alice` matches either contactId 4 or the contact whose display name is "alice"), or 2. Use **DM pairing** — send any message to the bot and it will reply with a pairing code. Enter that code via `claway pairing approve simplex <CODE>`. ## Group chats By default the adapter ignores group messages — a bot in a group otherwise processes every member's traffic. Opt-in explicitly: ``` SIMPLEX_GROUP_ALLOWED=12,34 # specific group IDs # or SIMPLEX_GROUP_ALLOWED=* # any group the bot is in ``` Address groups by prefixing the chat ID with `group:`, e.g. `simplex:group:12` as a cron `deliver=` target or in a `claway send` call. ## Attachments The adapter supports native SimpleX attachments in both directions: - **Inbound** — incoming images, voice notes, and files are accepted via the daemon's XFTP flow (`rcvFileDescrReady` → `/freceive` → wait for `rcvFileComplete`) and surfaced as `MessageEvent.media_urls` with the appropriate `MessageType` (`PHOTO`, `VOICE`, `TEXT` + document). - **Outbound** — `send_image_file`, `send_voice`, `send_document`, and `send_video` all use the structured `/_send` form with `filePath`, so the receiving SimpleX client renders images inline and plays voice notes inline rather than offering them as downloads. Agent replies can also embed `MEDIA:/path/to/file` tags in plain text — the adapter strips the tag from the body and sends the file as either a voice note (audio extensions) or a document. ## Using SimpleX with cron jobs ```python cronjob( action="create", schedule="every 1h", deliver="simplex", # uses SIMPLEX_HOME_CHANNEL prompt="Check for alerts and summarise." ) ``` Or target a specific contact via the cron job's `deliver:` field, or from a shell script with the [`claway send` CLI](/guides/pipe-script-output): ```bash claway send simplex:<contact-id> "Done!" ``` ## Privacy notes - SimpleX never reveals phone numbers or email addresses — contacts use opaque IDs - The connection between Claway and the daemon is local WebSocket (`ws://127.0.0.1:5225`) — no data leaves your machine - Messages are end-to-end encrypted by the SimpleX protocol before reaching the daemon ## Troubleshooting **"Cannot reach daemon"** — Ensure `simplex-chat -p 5225` is running and the port matches `SIMPLEX_WS_URL`. **"websockets not installed"** — Run `pip install websockets`. **Messages not received** — Check that the contact's ID is in `SIMPLEX_ALLOWED_USERS` or approve them via DM pairing. --- <!-- source: website/docs/user-guide/messaging/sms.md --> # SMS (Twilio) # SMS Setup (Twilio) Claway connects to SMS through the [Twilio](https://www.twilio.com/) API. People text your Twilio phone number and get AI responses back — same conversational experience as Telegram or Discord, but over standard text messages. :::info Shared Credentials The SMS gateway shares credentials with the optional [telephony skill](/reference/skills-catalog). If you've already set up Twilio for voice calls or one-off SMS, the gateway works with the same `TWILIO_ACCOUNT_SID`, `TWILIO_AUTH_TOKEN`, and `TWILIO_PHONE_NUMBER`. ::: --- ## Prerequisites - **Twilio account** — [Sign up at twilio.com](https://www.twilio.com/try-twilio) (free trial available) - **A Twilio phone number** with SMS capability - **A publicly accessible server** — Twilio sends webhooks to your server when SMS arrives - **aiohttp** — `cd ~/.claway/claway && uv pip install -e ".[sms]"` --- ## Step 1: Get Your Twilio Credentials 1. Go to the [Twilio Console](https://console.twilio.com/) 2. Copy your **Account SID** and **Auth Token** from the dashboard 3. Go to **Phone Numbers → Manage → Active Numbers** — note your phone number in E.164 format (e.g., `+15551234567`) --- ## Step 2: Configure Claway ### Interactive setup (recommended) ```bash claway gateway setup ``` Select **SMS (Twilio)** from the platform list. The wizard will prompt for your credentials. ### Manual setup Add to `~/.claway/.env`: ```bash TWILIO_ACCOUNT_SID=ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx TWILIO_AUTH_TOKEN=your_auth_token_here TWILIO_PHONE_NUMBER=+15551234567 # Security: restrict to specific phone numbers (recommended) SMS_ALLOWED_USERS=+15559876543,+15551112222 # Optional: set a home channel for cron job delivery SMS_HOME_CHANNEL=+15559876543 ``` --- ## Step 3: Configure Twilio Webhook Twilio needs to know where to send incoming messages. In the [Twilio Console](https://console.twilio.com/): 1. Go to **Phone Numbers → Manage → Active Numbers** 2. Click your phone number 3. Under **Messaging → A MESSAGE COMES IN**, set: - **Webhook**: `https://your-server:8080/webhooks/twilio` - **HTTP Method**: `POST` :::tip Exposing Your Webhook If you're running Claway locally, use a tunnel to expose the webhook: ```bash # Using cloudflared cloudflared tunnel --url http://localhost:8080 # Using ngrok ngrok http 8080 ``` Set the resulting public URL as your Twilio webhook. ::: **Set `SMS_WEBHOOK_URL` to the same URL you configured in Twilio.** This is required for Twilio signature validation — the adapter will refuse to start without it: ```bash # Must match the webhook URL in your Twilio Console SMS_WEBHOOK_URL=https://your-server:8080/webhooks/twilio ``` The webhook port defaults to `8080`. Override with: ```bash SMS_WEBHOOK_PORT=3000 ``` --- ## Step 4: Start the Gateway ```bash claway gateway ``` You should see: ``` [sms] Twilio webhook server listening on 127.0.0.1:8080, from: +1555***4567 ``` If you see `Refusing to start: SMS_WEBHOOK_URL is required`, set `SMS_WEBHOOK_URL` to the public URL configured in your Twilio Console (see Step 3). Text your Twilio number — Claway will respond via SMS. --- ## Environment Variables | Variable | Required | Description | |----------|----------|-------------| | `TWILIO_ACCOUNT_SID` | Yes | Twilio Account SID (starts with `AC`) | | `TWILIO_AUTH_TOKEN` | Yes | Twilio Auth Token (also used for webhook signature validation) | | `TWILIO_PHONE_NUMBER` | Yes | Your Twilio phone number (E.164 format) | | `SMS_WEBHOOK_URL` | Yes | Public URL for Twilio signature validation — must match the webhook URL in your Twilio Console | | `SMS_WEBHOOK_PORT` | No | Webhook listener port (default: `8080`) | | `SMS_WEBHOOK_HOST` | No | Webhook bind address (default: `127.0.0.1`) | | `SMS_INSECURE_NO_SIGNATURE` | No | Set to `true` to disable signature validation (local dev only — **not for production**) | | `SMS_ALLOWED_USERS` | No | Comma-separated E.164 phone numbers allowed to chat | | `SMS_ALLOW_ALL_USERS` | No | Set to `true` to allow anyone (not recommended) | | `SMS_HOME_CHANNEL` | No | Phone number for cron job / notification delivery | | `SMS_HOME_CHANNEL_NAME` | No | Display name for the home channel (default: `Home`) | --- ## SMS-Specific Behavior - **Plain text only** — Markdown is automatically stripped since SMS renders it as literal characters - **1600 character limit** — Longer responses are split across multiple messages at natural boundaries (newlines, then spaces) - **Echo prevention** — Messages from your own Twilio number are ignored to prevent loops - **Phone number redaction** — Phone numbers are redacted in logs for privacy --- ## Security ### Webhook signature validation Claway validates that inbound webhooks genuinely originate from Twilio by verifying the `X-Twilio-Signature` header (HMAC-SHA1). This prevents attackers from injecting forged messages. **`SMS_WEBHOOK_URL` is required.** Set it to the public URL configured in your Twilio Console. The adapter will refuse to start without it. For local development without a public URL, you can disable validation: ```bash # Local dev only — NOT for production SMS_INSECURE_NO_SIGNATURE=true ``` ### User allowlists **The gateway denies all users by default.** Configure an allowlist: ```bash # Recommended: restrict to specific phone numbers SMS_ALLOWED_USERS=+15559876543,+15551112222 # Or allow all (NOT recommended for bots with terminal access) SMS_ALLOW_ALL_USERS=true ``` :::warning SMS has no built-in encryption. Don't use SMS for sensitive operations unless you understand the security implications. For sensitive use cases, prefer Signal or Telegram. ::: --- ## Troubleshooting ### Messages not arriving 1. Check your Twilio webhook URL is correct and publicly accessible 2. Verify `TWILIO_ACCOUNT_SID` and `TWILIO_AUTH_TOKEN` are correct 3. Check the Twilio Console → **Monitor → Logs → Messaging** for delivery errors 4. Ensure your phone number is in `SMS_ALLOWED_USERS` (or `SMS_ALLOW_ALL_USERS=true`) ### Replies not sending 1. Check `TWILIO_PHONE_NUMBER` is set correctly (E.164 format with `+`) 2. Verify your Twilio account has SMS-capable numbers 3. Check Claway gateway logs for Twilio API errors ### Webhook port conflicts If port 8080 is already in use, change it: ```bash SMS_WEBHOOK_PORT=3001 ``` Update the webhook URL in Twilio Console to match. --- <!-- source: website/docs/user-guide/messaging/teams-meetings.md --> # Teams Meetings # Microsoft Teams Meetings Use the Teams meeting pipeline when you want Claway to ingest Microsoft Graph meeting events, fetch transcripts first, fall back to recordings plus STT when needed, and deliver a structured summary to downstream sinks. Prerequisites: see [Microsoft Teams](./teams.md) for the underlying bot/credential setup. > Run `claway gateway setup` and pick **Teams Meetings** for a guided walk-through. This page focuses on setup and enablement: - Graph credentials - webhook listener configuration - Teams delivery modes - pipeline config shape For day-2 operations, go-live checks, and the operator worksheet, use the dedicated guide: [Operate the Teams Meeting Pipeline](/guides/operate-teams-meeting-pipeline). ## What This Feature Does The pipeline: 1. receives Microsoft Graph webhook events 2. resolves the meeting and prefers transcript artifacts first 3. falls back to recording download plus STT when no usable transcript is available 4. stores durable job state and sink records locally 5. can write summaries to Notion, Linear, and Microsoft Teams Operator actions stay in the CLI (the `teams-pipeline` subcommand is registered by the `teams_pipeline` plugin — enable it via `claway plugins enable teams_pipeline` or set `plugins.enabled: [teams_pipeline]` in `config.yaml`): ```bash claway teams-pipeline validate claway teams-pipeline list claway teams-pipeline maintain-subscriptions ``` ## Prerequisites Before enabling the meetings pipeline, make sure you have: - a working Claway install - the existing [Microsoft Teams bot setup](/user-guide/messaging/teams) if you want Teams outbound delivery - Microsoft Graph application credentials with the permissions required for the meeting resources you plan to subscribe to - a public HTTPS URL that Microsoft Graph can call for webhook delivery - `ffmpeg` installed if you want recording-plus-STT fallback ## Step 1: Add Microsoft Graph Credentials Add Graph app-only credentials to `~/.claway/.env`: ```bash MSGRAPH_TENANT_ID=<tenant-id> MSGRAPH_CLIENT_ID=<client-id> MSGRAPH_CLIENT_SECRET=<client-secret> ``` These credentials are used by: - the Graph client foundation - subscription maintenance commands - meeting resolution and artifact fetches - Graph-based Teams outbound delivery when you do not provide a dedicated Teams access token ## Step 2: Enable the Graph Webhook Listener The webhook listener is a gateway platform named `msgraph_webhook`. At minimum, enable it and set a client state value: ```bash MSGRAPH_WEBHOOK_ENABLED=true MSGRAPH_WEBHOOK_HOST=127.0.0.1 MSGRAPH_WEBHOOK_PORT=8646 MSGRAPH_WEBHOOK_CLIENT_STATE=<random-shared-secret> MSGRAPH_WEBHOOK_ACCEPTED_RESOURCES=communications/onlineMeetings ``` The listener exposes: - `/msgraph/webhook` for Graph notifications - `/health` for a simple health check You need to route your public HTTPS endpoint to that listener. For example, if your public domain is `https://ops.example.com`, your Graph notification URL would typically be: ```text https://ops.example.com/msgraph/webhook ``` ## Step 3: Configure Teams Delivery and Pipeline Behavior The meeting pipeline reads its runtime config from the existing `teams` platform entry. Pipeline-specific knobs live under `teams.extra.meeting_pipeline`. Teams outbound delivery stays on the normal Teams platform config surface. Example `~/.claway/config.yaml`: ```yaml platforms: msgraph_webhook: enabled: true extra: host: 127.0.0.1 port: 8646 client_state: "replace-me" accepted_resources: - "communications/onlineMeetings" teams: enabled: true extra: client_id: "your-teams-client-id" client_secret: "your-teams-client-secret" tenant_id: "your-teams-tenant-id" # outbound summary delivery delivery_mode: "graph" # or incoming_webhook team_id: "team-id" channel_id: "channel-id" # incoming_webhook_url: "https://..." meeting_pipeline: transcript_min_chars: 80 transcript_required: false transcription_fallback: true ffmpeg_extract_audio: true notion: enabled: false linear: enabled: false ``` If you bind the listener to a non-loopback host such as `0.0.0.0`, you must also set `allowed_source_cidrs` to Microsoft's webhook egress ranges. Loopback binds (`127.0.0.1` / `::1`) are the intended dev-tunnel and local reverse-proxy setup. ## Teams Delivery Modes The pipeline supports two Teams summary-delivery modes inside the existing Teams plugin. ### `incoming_webhook` Use this when you want a simple webhook post into Teams without channel-message creation through Graph. Required config: ```yaml platforms: teams: enabled: true extra: delivery_mode: "incoming_webhook" incoming_webhook_url: "https://..." ``` ### `graph` Use this when you want Claway to post the summary through Microsoft Graph into a Teams chat or channel. Supported targets: - `chat_id` - `team_id` + `channel_id` - `team_id` + `home_channel` fallback for the existing Teams platform Example: ```yaml platforms: teams: enabled: true extra: delivery_mode: "graph" team_id: "team-id" channel_id: "channel-id" ``` ## Step 4: Start the Gateway Start Claway normally after updating config: ```bash claway gateway run ``` Or, if you run Claway in Docker, start the gateway the same way you already do for your deployment. Check the listener: ```bash curl http://localhost:8646/health ``` ## Step 5: Create Graph Subscriptions Use the plugin CLI to create and inspect subscriptions. Examples: ```bash claway teams-pipeline subscribe \ --resource communications/onlineMeetings/getAllTranscripts \ --notification-url https://ops.example.com/msgraph/webhook \ --client-state "$MSGRAPH_WEBHOOK_CLIENT_STATE" claway teams-pipeline subscribe \ --resource communications/onlineMeetings/getAllRecordings \ --notification-url https://ops.example.com/msgraph/webhook \ --client-state "$MSGRAPH_WEBHOOK_CLIENT_STATE" ``` :::warning Graph subscriptions expire in 72 hours Microsoft Graph caps webhook subscriptions at 72 hours and will not auto-renew them. You MUST schedule `claway teams-pipeline maintain-subscriptions` before going live, or notifications will silently stop three days after any manual subscription creation. See [Automating subscription renewal](/guides/operate-teams-meeting-pipeline#automating-subscription-renewal-required-for-production) in the operator runbook — three options (Claway cron, systemd timer, plain crontab). ::: For subscription maintenance and day-2 operator flows, continue with the guide: [Operate the Teams Meeting Pipeline](/guides/operate-teams-meeting-pipeline). ## Validation Run the built-in validation snapshot: ```bash claway teams-pipeline validate ``` Useful companion checks: ```bash claway teams-pipeline token-health claway teams-pipeline subscriptions ``` ## Troubleshooting | Problem | What to check | |---------|---------------| | Graph webhook validation fails | Confirm the public URL is correct and reachable, and that Graph is calling the exact `/msgraph/webhook` path | | Jobs do not appear in `claway teams-pipeline list` | Confirm `msgraph_webhook` is enabled and that subscriptions point at the right notification URL | | Transcript-first never succeeds | Check Graph permissions for transcript resources and whether the transcript artifact exists for that meeting | | Recording fallback fails | Confirm `ffmpeg` is installed and the Graph app can access recording artifacts | | Teams summary delivery fails | Re-check `delivery_mode`, target IDs, and Teams auth config | ## Related Docs - [Microsoft Teams bot setup](/user-guide/messaging/teams) - [Operate the Teams Meeting Pipeline](/guides/operate-teams-meeting-pipeline) --- <!-- source: website/docs/user-guide/messaging/wecom-callback.md --> # user-guide/messaging/wecom-callback.md # WeCom Callback (Self-Built App) Connect Claway to WeCom (Enterprise WeChat) as a self-built enterprise application using the callback/webhook model. :::info WeCom Bot vs WeCom Callback Claway supports two WeCom integration modes: - **[WeCom Bot](wecom.md)** — bot-style, connects via WebSocket. Simpler setup, works in group chats. - **WeCom Callback** (this page) — self-built app, receives encrypted XML callbacks. Shows as a first-class app in users' WeCom sidebar. Supports multi-corp routing. ::: See also: [WeCom Bot](./wecom.md) for the bot-style integration. > Run `claway gateway setup` and pick **WeCom Callback** for a guided walk-through. ## How It Works 1. You register a self-built application in the WeCom Admin Console 2. WeCom pushes encrypted XML to your HTTP callback endpoint 3. Claway decrypts the message, queues it for the agent 4. Immediately acknowledges (silent — nothing displayed to the user) 5. The agent processes the request (typically 3–30 minutes) 6. The reply is delivered proactively via the WeCom `message/send` API ## Prerequisites - A WeCom enterprise account with admin access - `aiohttp` and `httpx` Python packages (included in the default install) - A publicly reachable server for the callback URL (or a tunnel like ngrok) ## Setup ### 1. Create a Self-Built App in WeCom 1. Go to [WeCom Admin Console](https://work.weixin.qq.com/) → **Applications** → **Create App** 2. Note your **Corp ID** (shown at the top of the admin console) 3. In the app settings, create a **Corp Secret** 4. Note the **Agent ID** from the app's overview page 5. Under **Receive Messages**, configure the callback URL: - URL: `http://YOUR_PUBLIC_IP:8645/wecom/callback` - Token: Generate a random token (WeCom provides one) - EncodingAESKey: Generate a key (WeCom provides one) ### 2. Configure Environment Variables Add to your `.env` file: ```bash WECOM_CALLBACK_CORP_ID=your-corp-id WECOM_CALLBACK_CORP_SECRET=your-corp-secret WECOM_CALLBACK_AGENT_ID=1000002 WECOM_CALLBACK_TOKEN=your-callback-token WECOM_CALLBACK_ENCODING_AES_KEY=your-43-char-aes-key # Optional WECOM_CALLBACK_HOST=0.0.0.0 WECOM_CALLBACK_PORT=8645 WECOM_CALLBACK_ALLOWED_USERS=user1,user2 ``` ### 3. Start the Gateway ```bash claway gateway ``` (Use `claway gateway start` only after `claway gateway install` has registered the systemd/launchd service.) The callback adapter starts an HTTP server on the configured port. WeCom will verify the callback URL via a GET request, then begin sending messages via POST. ## Configuration Reference Set these in `config.yaml` under `platforms.wecom_callback.extra`, or use environment variables: | Setting | Default | Description | |---------|---------|-------------| | `corp_id` | — | WeCom enterprise Corp ID (required) | | `corp_secret` | — | Corp secret for the self-built app (required) | | `agent_id` | — | Agent ID of the self-built app (required) | | `token` | — | Callback verification token (required) | | `encoding_aes_key` | — | 43-character AES key for callback encryption (required) | | `host` | `0.0.0.0` | Bind address for the HTTP callback server | | `port` | `8645` | Port for the HTTP callback server | | `path` | `/wecom/callback` | URL path for the callback endpoint | ## Multi-App Routing For enterprises running multiple self-built apps (e.g., across different departments or subsidiaries), configure the `apps` list in `config.yaml`: ```yaml platforms: wecom_callback: enabled: true extra: host: "0.0.0.0" port: 8645 apps: - name: "dept-a" corp_id: "ww_corp_a" corp_secret: "secret-a" agent_id: "1000002" token: "token-a" encoding_aes_key: "key-a-43-chars..." - name: "dept-b" corp_id: "ww_corp_b" corp_secret: "secret-b" agent_id: "1000003" token: "token-b" encoding_aes_key: "key-b-43-chars..." ``` Users are scoped by `corp_id:user_id` to prevent cross-corp collisions. When a user sends a message, the adapter records which app (corp) they belong to and routes replies through the correct app's access token. ## Access Control Restrict which users can interact with the app: ```bash # Allowlist specific users WECOM_CALLBACK_ALLOWED_USERS=zhangsan,lisi,wangwu # Or allow all users WECOM_CALLBACK_ALLOW_ALL_USERS=true ``` ## Endpoints The adapter exposes: | Method | Path | Purpose | |--------|------|---------| | GET | `/wecom/callback` | URL verification handshake (WeCom sends this during setup) | | POST | `/wecom/callback` | Encrypted message callback (WeCom sends user messages here) | | GET | `/health` | Health check — returns `{"status": "ok"}` | ## Encryption All callback payloads are encrypted with AES-CBC using the EncodingAESKey. The adapter handles: - **Inbound**: Decrypt XML payload, verify SHA1 signature - **Outbound**: Replies sent via proactive API (not encrypted callback response) The crypto implementation is compatible with Tencent's official WXBizMsgCrypt SDK. ## Limitations - **No streaming** — replies arrive as complete messages after the agent finishes - **No typing indicators** — the callback model doesn't support typing status - **Text only** — currently supports text messages for input; image/file/voice input not yet implemented. The agent is aware of outbound media capabilities via the WeCom platform hint (images, documents, video, voice). - **Response latency** — agent sessions take 3–30 minutes; users see the reply when processing completes ## Troubleshooting **Signature verification failing.** WeCom signs every request with the **Token** you registered in the admin console. A mismatch between the token configured in Claway and the token the admin console expects is the most common cause. Re-copy both the **Token** and **EncodingAESKey** from the admin console — they're easy to truncate. Whitespace in `~/.claway/.env` values around `=` will also break signature checks. After fixing, restart `claway gateway run`. **Callback URL not reachable / verification step fails.** WeCom hits the public URL you registered. Confirm: 1. Your reverse proxy / tunnel forwards `/wecom/callback` to the gateway's port. 2. The URL in the admin console is HTTPS (WeCom rejects plain HTTP). 3. From outside your network, `curl -i https://<your-domain>/wecom/callback` returns something other than a timeout (a 4xx without query params is fine — it just means the listener is reachable). **Port not reachable / listener not bound.** Check `claway gateway run` logs for the bound host/port. If the adapter bound to `127.0.0.1` you must front it with a reverse proxy or tunnel — WeCom's servers can't reach loopback. Set `extra.host: 0.0.0.0` in `config.yaml` (plus `allowed_source_cidrs` if exposing directly) or keep loopback and use a tunnel such as Cloudflare Tunnel / nginx. --- <!-- source: website/docs/user-guide/messaging/wecom.md --> # WeCom (Enterprise WeChat) # WeCom (Enterprise WeChat) Connect Claway to [WeCom](https://work.weixin.qq.com/) (企业微信), Tencent's enterprise messaging platform. The adapter uses WeCom's AI Bot WebSocket gateway for real-time bidirectional communication — no public endpoint or webhook needed. See also: [WeCom Callback](./wecom-callback.md) for inbound webhook setup. ## Prerequisites - A WeCom organization account - An AI Bot created in the WeCom Admin Console - The Bot ID and Secret from the bot's credentials page - Python packages: `aiohttp` and `httpx` ## Setup ### Step 1: Create an AI Bot #### Recommended: Scan-to-Create (one command) ```bash claway gateway setup ``` Select **WeCom** and scan the QR code with your WeCom mobile app. Claway will automatically create a bot application with the correct permissions and save the credentials. The setup wizard will: 1. Display a QR code in your terminal 2. Wait for you to scan it with the WeCom mobile app 3. Automatically retrieve the Bot ID and Secret 4. Guide you through access control configuration #### Alternative: Manual Setup If scan-to-create is not available, the wizard falls back to manual input: 1. Log in to the [WeCom Admin Console](https://work.weixin.qq.com/wework_admin/frame) 2. Navigate to **Applications** → **Create Application** → **AI Bot** 3. Configure the bot name and description 4. Copy the **Bot ID** and **Secret** from the credentials page 5. Run `claway gateway setup`, select **WeCom**, and enter the credentials when prompted :::warning Keep the Bot Secret private. Anyone with it can impersonate your bot. ::: ### Step 2: Configure Claway #### Option A: Interactive Setup (Recommended) ```bash claway gateway setup ``` Select **WeCom** and follow the prompts. The wizard will guide you through: - Bot credentials (via QR scan or manual entry) - Access control settings (allowlist, pairing mode, or open access) - Home channel for notifications #### Option B: Manual Configuration Add the following to `~/.claway/.env`: ```bash WECOM_BOT_ID=your-bot-id WECOM_SECRET=your-secret # Optional: restrict access WECOM_ALLOWED_USERS=user_id_1,user_id_2 # Optional: home channel for cron/notifications WECOM_HOME_CHANNEL=chat_id ``` ### Step 3: Start the gateway ```bash claway gateway ``` ## Features - **WebSocket transport** — persistent connection, no public endpoint needed - **DM and group messaging** — configurable access policies - **Per-group sender allowlists** — fine-grained control over who can interact in each group - **Media support** — images, files, voice, video upload and download - **AES-encrypted media** — automatic decryption for inbound attachments - **Quote context** — preserves reply threading - **Markdown rendering** — rich text responses - **Reply correlation** — responses are correlated to the inbound message context - **Auto-reconnect** — exponential backoff on connection drops :::note Streaming and typing indicators The WeCom adapter delivers each response as a single complete message — it does **not** stream responses token-by-token, and it does **not** show a typing indicator. "Reply correlation" (below) only threads a response to its inbound request; it is not live streaming. ::: ## Configuration Options Set these in `config.yaml` under `platforms.wecom.extra`: | Key | Default | Description | |-----|---------|-------------| | `bot_id` | — | WeCom AI Bot ID (required) | | `secret` | — | WeCom AI Bot Secret (required) | | `websocket_url` | `wss://openws.work.weixin.qq.com` | WebSocket gateway URL | | `dm_policy` | `open` | DM access: `open`, `allowlist`, `disabled`, `pairing` | | `group_policy` | `open` | Group access: `open`, `allowlist`, `disabled` | | `allow_from` | `[]` | User IDs allowed for DMs (when dm_policy=allowlist) | | `group_allow_from` | `[]` | Group IDs allowed (when group_policy=allowlist) | | `groups` | `{}` | Per-group configuration (see below) | ## Access Policies ### DM Policy Controls who can send direct messages to the bot: | Value | Behavior | |-------|----------| | `open` | Anyone can DM the bot (default) | | `allowlist` | Only user IDs in `allow_from` can DM | | `disabled` | All DMs are ignored | | `pairing` | Pairing mode (for initial setup) | ```bash WECOM_DM_POLICY=allowlist ``` ### Group Policy Controls which groups the bot responds in: | Value | Behavior | |-------|----------| | `open` | Bot responds in all groups (default) | | `allowlist` | Bot only responds in group IDs listed in `group_allow_from` | | `disabled` | All group messages are ignored | ```bash WECOM_GROUP_POLICY=allowlist ``` ### Per-Group Sender Allowlists For fine-grained control, you can restrict which users are allowed to interact with the bot within specific groups. This is configured in `config.yaml`: ```yaml platforms: wecom: enabled: true extra: bot_id: "your-bot-id" secret: "your-secret" group_policy: "allowlist" group_allow_from: - "group_id_1" - "group_id_2" groups: group_id_1: allow_from: - "user_alice" - "user_bob" group_id_2: allow_from: - "user_charlie" "*": allow_from: - "user_admin" ``` **How it works:** 1. The `group_policy` and `group_allow_from` controls determine whether a group is allowed at all. 2. If a group passes the top-level check, the `groups.<group_id>.allow_from` list (if present) further restricts which senders within that group can interact with the bot. 3. A wildcard `"*"` group entry serves as a default for groups not explicitly listed. 4. Allowlist entries support the `*` wildcard to allow all users, and entries are case-insensitive. 5. Entries can optionally use the `wecom:user:` or `wecom:group:` prefix format — the prefix is stripped automatically. If no `allow_from` is configured for a group, all users in that group are allowed (assuming the group itself passes the top-level policy check). ## Media Support ### Inbound (receiving) The adapter receives media attachments from users and caches them locally for agent processing: | Type | How it's handled | |------|-----------------| | **Images** | Downloaded and cached locally. Supports both URL-based and base64-encoded images. | | **Files** | Downloaded and cached. Filename is preserved from the original message. | | **Voice** | Voice message text transcription is extracted if available. | | **Mixed messages** | WeCom mixed-type messages (text + images) are parsed and all components extracted. | **Quoted messages:** Media from quoted (replied-to) messages is also extracted, so the agent has context about what the user is replying to. ### AES-Encrypted Media Decryption WeCom encrypts some inbound media attachments with AES-256-CBC. The adapter handles this automatically: - When an inbound media item includes an `aeskey` field, the adapter downloads the encrypted bytes and decrypts them using AES-256-CBC with PKCS#7 padding. - The AES key is the base64-decoded value of the `aeskey` field (must be exactly 32 bytes). - The IV is derived from the first 16 bytes of the key. - This requires the `cryptography` Python package (`pip install cryptography`). No configuration is needed — decryption happens transparently when encrypted media is received. ### Outbound (sending) | Method | What it sends | Size limit | |--------|--------------|------------| | `send` | Markdown text messages | 4000 chars | | `send_image` / `send_image_file` | Native image messages | 10 MB | | `send_document` | File attachments | 20 MB | | `send_voice` | Voice messages (AMR format only for native voice) | 2 MB | | `send_video` | Video messages | 10 MB | **Chunked upload:** Files are uploaded in 512 KB chunks through a three-step protocol (init → chunks → finish). The adapter handles this automatically. **Automatic downgrade:** When media exceeds the native type's size limit but is under the absolute 20 MB file limit, it is automatically sent as a generic file attachment instead: - Images > 10 MB → sent as file - Videos > 10 MB → sent as file - Voice > 2 MB → sent as file - Non-AMR audio → sent as file (WeCom only supports AMR for native voice) Files exceeding the absolute 20 MB limit are rejected with an informational message sent to the chat. ## Reply-Mode Responses When the bot receives a message via the WeCom callback, the adapter remembers the inbound request ID. If a response is sent while the request context is still active, the adapter uses WeCom's reply-mode (`aibot_respond_msg`) to correlate the response directly to the inbound message. This provides a more natural conversation experience in the WeCom client. The full response is delivered as a single message — the adapter does not stream tokens incrementally. If the inbound request context has expired or is unavailable, the adapter falls back to proactive message sending via `aibot_send_msg`. Reply-mode also works for media: uploaded media can be sent as a reply to the originating message. ## Connection and Reconnection The adapter maintains a persistent WebSocket connection to WeCom's gateway at `wss://openws.work.weixin.qq.com`. ### Connection Lifecycle 1. **Connect:** Opens a WebSocket connection and sends an `aibot_subscribe` authentication frame with the bot_id and secret. 2. **Heartbeat:** Sends application-level ping frames every 30 seconds to keep the connection alive. 3. **Listen:** Continuously reads inbound frames and dispatches message callbacks. ### Reconnection Behavior On connection loss, the adapter uses exponential backoff to reconnect: | Attempt | Delay | |---------|-------| | 1st retry | 2 seconds | | 2nd retry | 5 seconds | | 3rd retry | 10 seconds | | 4th retry | 30 seconds | | 5th+ retry | 60 seconds | After each successful reconnection, the backoff counter resets to zero. All pending request futures are failed on disconnect so callers don't hang indefinitely. ### Deduplication Inbound messages are deduplicated using message IDs with a 5-minute window and a maximum cache of 1000 entries. This prevents double-processing of messages during reconnection or network hiccups. ## All Environment Variables | Variable | Required | Default | Description | |----------|----------|---------|-------------| | `WECOM_BOT_ID` | ✅ | — | WeCom AI Bot ID | | `WECOM_SECRET` | ✅ | — | WeCom AI Bot Secret | | `WECOM_ALLOWED_USERS` | — | _(empty)_ | Comma-separated user IDs for the gateway-level allowlist | | `WECOM_HOME_CHANNEL` | — | — | Chat ID for cron/notification output | | `WECOM_WEBSOCKET_URL` | — | `wss://openws.work.weixin.qq.com` | WebSocket gateway URL | | `WECOM_DM_POLICY` | — | `open` | DM access policy | | `WECOM_GROUP_POLICY` | — | `open` | Group access policy | ## Troubleshooting | Problem | Fix | |---------|-----| | `WECOM_BOT_ID and WECOM_SECRET are required` | Set both env vars or configure in setup wizard | | `WeCom startup failed: aiohttp not installed` | Install aiohttp: `pip install aiohttp` | | `WeCom startup failed: httpx not installed` | Install httpx: `pip install httpx` | | `invalid secret (errcode=40013)` | Verify the secret matches your bot's credentials | | `Timed out waiting for subscribe acknowledgement` | Check network connectivity to `openws.work.weixin.qq.com` | | Bot doesn't respond in groups | Check `group_policy` setting and ensure the group ID is in `group_allow_from` | | Bot ignores certain users in a group | Check per-group `allow_from` lists in the `groups` config section | | Media decryption fails | Install `cryptography`: `pip install cryptography` | | `cryptography is required for WeCom media decryption` | The inbound media is AES-encrypted. Install: `pip install cryptography` | | Voice messages sent as files | WeCom only supports AMR format for native voice. Other formats are auto-downgraded to file. | | `File too large` error | WeCom has a 20 MB absolute limit on all file uploads. Compress or split the file. | | Images sent as files | Images > 10 MB exceed the native image limit and are auto-downgraded to file attachments. | | `Timeout sending message to WeCom` | The WebSocket may have disconnected. Check logs for reconnection messages. | | `WeCom websocket closed during authentication` | Network issue or incorrect credentials. Verify bot_id and secret. | --- <!-- source: website/docs/user-guide/messaging/weixin.md --> # Weixin (WeChat) # Weixin (WeChat) Connect Claway to [WeChat](https://weixin.qq.com/) (微信), Tencent's personal messaging platform. The adapter uses Tencent's **iLink Bot API** for personal WeChat accounts — this is distinct from WeCom (Enterprise WeChat). Messages are delivered via long-polling, so no public endpoint or webhook is required. :::info This adapter is for **personal WeChat accounts** (微信). If you need enterprise/corporate WeChat, see the [WeCom adapter](./wecom.md) instead. ::: :::warning iLink bot identity — ordinary WeChat groups may not work QR login connects Claway to an **iLink bot identity** (e.g. `a5ace6fd482e@im.bot`), **not** a fully scriptable ordinary personal WeChat account. Consequences: - The iLink bot identity generally **cannot be invited into ordinary WeChat groups** the way a normal contact can. - iLink typically **does not deliver ordinary WeChat group events** (including `@`-mentions of the personal account used for QR login) to the gateway for most bot-type accounts. - `@`-mentioning the personal WeChat account used to scan the QR code is **not** the same as `@`-mentioning the iLink bot — the bot is a separate identity. - The `WEIXIN_GROUP_POLICY` / `WEIXIN_GROUP_ALLOWED_USERS` settings below only take effect when iLink actually returns group events for your account type. If it doesn't, group messages will never reach Claway regardless of policy. In practice, most deployments only get DMs to the iLink bot working reliably. If group delivery doesn't work after configuration, the limitation is on the iLink side, not in Claway. The gateway logs a `WARNING` at startup whenever `WEIXIN_GROUP_POLICY` is set to anything other than `disabled`. ::: ## Prerequisites - A personal WeChat account - Python packages: `aiohttp` and `cryptography` - Terminal QR rendering is included when Claway is installed with the `messaging` extra Install the required dependencies: ```bash pip install aiohttp cryptography # Optional: for terminal QR code display cd ~/.claway/claway && uv pip install -e ".[messaging]" ``` ## Setup ### 1. Run the Setup Wizard The easiest way to connect your WeChat account is through the interactive setup: ```bash claway gateway setup ``` Select **Weixin** when prompted. The wizard will: 1. Request a QR code from the iLink Bot API 2. Display the QR code in your terminal (or provide a URL) 3. Wait for you to scan the QR code with the WeChat mobile app 4. Prompt you to confirm the login on your phone 5. Save the account credentials automatically to `~/.claway/weixin/accounts/` Once confirmed, you'll see a message like: ``` 微信连接成功,account_id=your-account-id ``` The wizard stores the `account_id`, `token`, and `base_url` so you don't need to configure them manually. ### 2. Configure Environment Variables After initial QR login, set at minimum the account ID in `~/.claway/.env`: ```bash WEIXIN_ACCOUNT_ID=your-account-id # Optional: override the token (normally auto-saved from QR login) # WEIXIN_TOKEN=your-bot-token # Optional: restrict access WEIXIN_DM_POLICY=open WEIXIN_ALLOWED_USERS=user_id_1,user_id_2 # Optional: restore legacy multiline splitting behavior # WEIXIN_SPLIT_MULTILINE_MESSAGES=true # Optional: home channel for cron/notifications WEIXIN_HOME_CHANNEL=chat_id WEIXIN_HOME_CHANNEL_NAME=Home ``` ### 3. Start the Gateway ```bash claway gateway ``` The adapter will restore saved credentials, connect to the iLink API, and begin long-polling for messages. ## Features - **Long-poll transport** — no public endpoint, webhook, or WebSocket needed - **QR code login** — scan-to-connect setup via `claway gateway setup` - **DM messaging** — configurable access policies; group messaging depends on iLink actually delivering group events for the connected identity (often not the case for iLink bot accounts — see the warning above) - **Media support** — images, video, files, and voice messages - **AES-128-ECB encrypted CDN** — automatic encryption/decryption for all media transfers - **Context token persistence** — disk-backed reply continuity across restarts - **Markdown formatting** — preserves Markdown, including headers, tables, and code blocks, so WeChat clients that support Markdown can render it natively - **Smart message chunking** — messages stay as a single bubble when under the limit; only oversized payloads split at logical boundaries - **Typing indicators** — shows "typing…" status in the WeChat client while the agent processes - **SSRF protection** — outbound media URLs are validated before download - **Message deduplication** — 5-minute sliding window prevents double-processing - **Automatic retry with backoff** — recovers from transient API errors ## Configuration Options Set these in `config.yaml` under `platforms.weixin.extra`: | Key | Default | Description | |-----|---------|-------------| | `account_id` | — | iLink Bot account ID (required) | | `token` | — | iLink Bot token (required, auto-saved from QR login) | | `base_url` | `https://ilinkai.weixin.qq.com` | iLink API base URL | | `cdn_base_url` | `https://novac2c.cdn.weixin.qq.com/c2c` | CDN base URL for media transfer | | `dm_policy` | `open` | DM access: `open`, `allowlist`, `disabled`, `pairing` | | `group_policy` | `disabled` | Group access: `open`, `allowlist`, `disabled` | | `allow_from` | `[]` | User IDs allowed for DMs (when dm_policy=allowlist) | | `group_allow_from` | `[]` | Group IDs allowed (when group_policy=allowlist) | | `split_multiline_messages` | `false` | When `true`, split multi-line replies into multiple chat messages (legacy behavior). When `false`, keep multi-line replies as one message unless they exceed the length limit. | | `text_batch_delay_seconds` | `3.0` | Quiet period (seconds) before a buffered burst of rapid text messages is flushed as one combined request. iLink delivers messages individually, so this debounce avoids one agent invocation per fragment. Set `0` to dispatch each message immediately. | | `text_batch_split_delay_seconds` | `5.0` | Extended flush delay used when the latest fragment is near the split threshold (long messages iLink may have chunked). | ## Access Policies ### DM Policy Controls who can send direct messages to the bot: | Value | Behavior | |-------|----------| | `open` | Anyone can DM the bot (default) | | `allowlist` | Only user IDs in `allow_from` can DM | | `disabled` | All DMs are ignored | | `pairing` | Pairing mode (for initial setup) | ```bash WEIXIN_DM_POLICY=allowlist WEIXIN_ALLOWED_USERS=user_id_1,user_id_2 ``` `WEIXIN_ALLOWED_USERS` is an **inbound filter**, not an invitation system. QR login connects one iLink bot identity to Claway. Other people do not scan the Claway QR code with their own accounts; they must message the connected iLink bot/contact through WeChat, and Claway will process the DM only if the sender's Weixin user ID is present in `WEIXIN_ALLOWED_USERS`. A practical setup flow is: 1. Pair Claway once with `claway gateway setup` and note the connected iLink bot account. 2. Have each allowed user send a direct message to that bot/contact. 3. Read the sender/user ID from the gateway logs or the inbound event payload. 4. Add those IDs to `WEIXIN_ALLOWED_USERS`, then restart the gateway. If only the account that scanned the QR code can talk to Claway, verify that the other users are messaging the iLink bot identity itself, not the personal WeChat account that performed the QR login. The iLink bot is a separate identity, and ordinary WeChat contact/group routing can be limited by Tencent's iLink behavior. ### Group Policy Controls which groups the bot responds in **when iLink delivers group events for the connected identity**. For QR-login iLink bot identities (e.g. `...@im.bot`), group events are typically not delivered at all, so this policy may have no effect — see the iLink bot limitation warning at the top of the page. | Value | Behavior | |-------|----------| | `open` | Bot responds in all groups (if events are delivered) | | `allowlist` | Bot only responds in group IDs listed in `group_allow_from` (if events are delivered) | | `disabled` | All group messages are ignored (default) | ```bash WEIXIN_GROUP_POLICY=allowlist # NOTE: this is a comma-separated list of group chat IDs, NOT member user IDs, # despite the variable name containing "USERS". Keep this in mind when configuring. WEIXIN_GROUP_ALLOWED_USERS=group_id_1,group_id_2 ``` :::note The default group policy is `disabled` for Weixin (unlike WeCom where it defaults to `open`). This is intentional — personal WeChat accounts may be in many groups, and iLink bot identities typically can't receive ordinary WeChat group messages at all. The gateway logs a `WARNING` at startup if you set `WEIXIN_GROUP_POLICY` to anything other than `disabled`. ::: ## Media Support ### Inbound (receiving) The adapter receives media attachments from users, downloads them from the WeChat CDN, decrypts them, and caches them locally for agent processing: | Type | How it's handled | |------|-----------------| | **Images** | Downloaded, AES-decrypted, and cached as JPEG. | | **Video** | Downloaded, AES-decrypted, and cached as MP4. | | **Files** | Downloaded, AES-decrypted, and cached. Original filename is preserved. | | **Voice** | If a text transcription is available, it's extracted as text. Otherwise the audio (SILK format) is downloaded and cached. | **Quoted messages:** Media from quoted (replied-to) messages is also extracted, so the agent has context about what the user is replying to. ### AES-128-ECB Encrypted CDN WeChat media files are transferred through an encrypted CDN. The adapter handles this transparently: - **Inbound:** Encrypted media is downloaded from the CDN using `encrypted_query_param` URLs, then decrypted with AES-128-ECB using the per-file key provided in the message payload. - **Outbound:** Files are encrypted locally with a random AES-128-ECB key, uploaded to the CDN, and the encrypted reference is included in the outbound message. - The AES key is 16 bytes (128-bit). Keys may arrive as raw base64 or hex-encoded — the adapter handles both formats. - This requires the `cryptography` Python package. No configuration is needed — encryption and decryption happen automatically. ### Outbound (sending) | Method | What it sends | |--------|--------------| | `send` | Text messages with Markdown formatting | | `send_image` / `send_image_file` | Native image messages (via CDN upload) | | `send_document` | File attachments (via CDN upload) | | `send_video` | Video messages (via CDN upload) | All outbound media goes through the encrypted CDN upload flow: 1. Generate a random AES-128 key 2. Encrypt the file with AES-128-ECB + PKCS#7 padding 3. Request an upload URL from the iLink API (`getuploadurl`) 4. Upload the ciphertext to the CDN 5. Send the message with the encrypted media reference ## Context Token Persistence The iLink Bot API requires a `context_token` to be echoed back with each outbound message for a given peer. The adapter maintains a disk-backed context token store: - Tokens are saved per account+peer to `~/.claway/weixin/accounts/<account_id>.context-tokens.json` - On startup, previously saved tokens are restored - Every inbound message updates the stored token for that sender - Outbound messages automatically include the latest context token This ensures reply continuity even after gateway restarts. ## Markdown Formatting WeChat clients connected through the iLink Bot API can render Markdown directly, so the adapter preserves Markdown instead of rewriting it: - **Headers** stay as Markdown headings (`#`, `##`, ...) - **Tables** stay as Markdown tables - **Code fences** stay as fenced code blocks - **Excessive blank lines** are collapsed to double newlines outside fenced code blocks ## Message Chunking Messages are delivered as a single chat message whenever they fit within the platform limit. Only oversized payloads are split for delivery: - Maximum message length: **4000 characters** - Messages under the limit stay intact even when they contain multiple paragraphs or line breaks - Oversized messages split at logical boundaries (paragraphs, blank lines, code fences) - Code fences are kept intact whenever possible (never split mid-block unless the fence itself exceeds the limit) - Oversized individual blocks fall back to the base adapter's truncation logic - A 0.3 s inter-chunk delay prevents WeChat rate-limit drops when multiple chunks are sent ## Typing Indicators The adapter shows typing status in the WeChat client: 1. When a message arrives, the adapter fetches a `typing_ticket` via the `getconfig` API 2. Typing tickets are cached for 10 minutes per user 3. `send_typing` sends a typing-start signal; `stop_typing` sends a typing-stop signal 4. The gateway automatically triggers typing indicators while the agent processes a message ## Long-Poll Connection The adapter uses HTTP long-polling (not WebSocket) to receive messages: ### How It Works 1. **Connect:** Validates credentials and starts the poll loop 2. **Poll:** Calls `getupdates` with a 35-second timeout; the server holds the request until messages arrive or the timeout expires 3. **Dispatch:** Inbound messages are dispatched concurrently via `asyncio.create_task` 4. **Sync buffer:** A persistent sync cursor (`get_updates_buf`) is saved to disk so the adapter resumes from the correct position after restarts ### Retry Behavior On API errors, the adapter uses a simple retry strategy: | Condition | Behavior | |-----------|----------| | Transient error (1st–2nd) | Retry after 2 seconds | | Repeated errors (3+) | Back off for 30 seconds, then reset counter | | Session expired (`errcode=-14`) | Pause for 10 minutes (re-login may be needed) | | Timeout | Immediately re-poll (normal long-poll behavior) | ### Deduplication Inbound messages are deduplicated using message IDs with a 5-minute window. This prevents double-processing during network hiccups or overlapping poll responses. ### Token Lock Only one Weixin gateway instance can use a given token at a time. The adapter acquires a scoped lock on startup and releases it on shutdown. If another gateway is already using the same token, startup fails with an informative error message. ## All Environment Variables | Variable | Required | Default | Description | |----------|----------|---------|-------------| | `WEIXIN_ACCOUNT_ID` | ✅ | — | iLink Bot account ID (from QR login) | | `WEIXIN_TOKEN` | ✅ | — | iLink Bot token (auto-saved from QR login) | | `WEIXIN_BASE_URL` | — | `https://ilinkai.weixin.qq.com` | iLink API base URL | | `WEIXIN_CDN_BASE_URL` | — | `https://novac2c.cdn.weixin.qq.com/c2c` | CDN base URL for media transfer | | `WEIXIN_DM_POLICY` | — | `open` | DM access policy: `open`, `allowlist`, `disabled`, `pairing` | | `WEIXIN_GROUP_POLICY` | — | `disabled` | Group access policy: `open`, `allowlist`, `disabled` | | `WEIXIN_ALLOWED_USERS` | — | _(empty)_ | Comma-separated user IDs for DM allowlist | | `WEIXIN_GROUP_ALLOWED_USERS` | — | _(empty)_ | Comma-separated **group chat IDs** (not member user IDs) for group allowlist. The variable name is legacy — it expects group IDs, not user IDs. | | `WEIXIN_HOME_CHANNEL` | — | — | Chat ID for cron/notification output | | `WEIXIN_HOME_CHANNEL_NAME` | — | `Home` | Display name for the home channel | | `WEIXIN_ALLOW_ALL_USERS` | — | — | Gateway-level flag to allow all users (used by setup wizard) | ## Troubleshooting | Problem | Fix | |---------|-----| | `Weixin startup failed: aiohttp and cryptography are required` | Install both: `pip install aiohttp cryptography` | | `Weixin startup failed: WEIXIN_TOKEN is required` | Run `claway gateway setup` to complete QR login, or set `WEIXIN_TOKEN` manually | | `Weixin startup failed: WEIXIN_ACCOUNT_ID is required` | Set `WEIXIN_ACCOUNT_ID` in your `.env` or run `claway gateway setup` | | `Another local Claway gateway is already using this Weixin token` | Stop the other gateway instance first — only one poller per token is allowed | | Session expired (`errcode=-14`) | Your login session has expired. Re-run `claway gateway setup` to scan a new QR code | | QR code expired during setup | The QR auto-refreshes up to 3 times. If it keeps expiring, check your network connection | | Bot doesn't respond to DMs | Check `WEIXIN_DM_POLICY` — if set to `allowlist`, the sender must be in `WEIXIN_ALLOWED_USERS` | | Bot ignores group messages | Group policy defaults to `disabled`. Set `WEIXIN_GROUP_POLICY=open` or `allowlist` — but note that QR-login iLink bot identities (`...@im.bot`) typically cannot receive ordinary WeChat group messages at all. If the gateway logs show no raw inbound events for group messages, the limitation is on the iLink side, not in Claway. | | Media download/upload fails | Ensure `cryptography` is installed. Check network access to `novac2c.cdn.weixin.qq.com` | | `Blocked unsafe URL (SSRF protection)` | The outbound media URL points to a private/internal address. Only public URLs are allowed | | Voice messages show as text | If WeChat provides a transcription, the adapter uses the text. This is expected behavior | | Messages appear duplicated | The adapter deduplicates by message ID. If you see duplicates, check if multiple gateway instances are running | | `iLink POST ... HTTP 4xx/5xx` | API error from the iLink service. Check your token validity and network connectivity | | Terminal QR code doesn't render | Reinstall with the messaging extra: `cd ~/.claway/claway && uv pip install -e ".[messaging]"`. Alternatively, open the URL printed above the QR | --- <!-- source: website/docs/user-guide/messaging/whatsapp-cloud.md --> # WhatsApp Business (Cloud API) # WhatsApp Business Cloud API Setup Claway can connect to WhatsApp through Meta's **official** WhatsApp Business Cloud API. This is the production-grade path: no Node.js bridge subprocess, no QR codes, no account-ban risk. In exchange: - You need a **Meta Business account** (not personal WhatsApp). - The bot operates on a dedicated business phone number, not your personal number. - The Claway gateway needs a **public HTTPS URL** so Meta can deliver inbound messages via webhook. - Replies more than 24 hours after the user's last message require a pre-approved **template** (this is Meta's "customer service window" rule, not a Claway limit). If those constraints don't work for your use case, the [Baileys bridge integration](./whatsapp.md) is the alternative — personal account, no public URL needed, but unofficial and ban-prone. :::tip Which one should I use? - **Cloud API (this guide)** — running a real business bot, want stability, fine with the Meta verification + template paperwork - **[Baileys bridge](./whatsapp.md)** — personal projects, quick demos, single-user setups, willing to risk the bot phone number's account ::: --- ## Quick start ```bash claway whatsapp-cloud ``` The wizard walks you through every credential, validates each one as you paste it (catches the #1 setup trap — pasting a phone number into the Phone Number ID field), and prints exact follow-up instructions for the parts that need to happen outside the wizard (starting cloudflared, configuring Meta's webhook dashboard). The rest of this page is the manual reference. --- ## Prerequisites 1. **A Meta Business account**. Create one at [business.facebook.com](https://business.facebook.com/). 2. **A Meta app with WhatsApp enabled**. See "Creating the Meta app" below. 3. **A way to expose a local port to the public internet** with HTTPS. Cloudflare Tunnel (`cloudflared`) is recommended — free, no port forwarding, no domain required. ngrok, your own domain with a reverse proxy + TLS, or a VPS with the gateway directly bound to a public IP all work too. 4. **Optional but recommended**: ffmpeg on `PATH` so outbound voice messages render as native WhatsApp voice-note bubbles (green waveform) instead of MP3 audio attachments. Claway degrades gracefully if absent. --- ## Creating the Meta app 1. Go to [developers.facebook.com/apps](https://developers.facebook.com/apps) → **Create App**. 2. Choose use case: **"Connect with customers through WhatsApp"** → **Next**. 3. Pick or create a business portfolio. Review the publishing requirements. Confirm → **Create app**. 4. After creation you'll land on **Customize use case → Connect on WhatsApp → Quickstart**. Click **Start using the API** → you're now on the **API Setup** page. 5. Make sure a WhatsApp Business Account (WABA) is linked. If you created a new portfolio in step 3, one was auto-created. Verify in the API Setup page. You'll need these values from the dashboard — the wizard prompts for them in this order: | Value | Where in dashboard | Field shape | Notes | |---|---|---|---| | **Phone Number ID** | App Dashboard → WhatsApp → API Setup → below the "From" dropdown | Numeric, 15-17 digits | **NOT** the phone number itself. The #1 setup mistake is pasting the actual phone number here. | | **Access Token** | App Dashboard → WhatsApp → API Setup → "Generate access token" | Starts with `EAA`, 100+ chars | Temp tokens last 24h — see "Permanent token" below for production. | | **App Secret** | App Dashboard → Settings → Basic → click "Show" next to App secret | 32-character lowercase hex | Used to verify incoming webhook signatures. Without it, inbound delivery is refused with 503. | | **App ID** (optional) | App Dashboard → Settings → Basic | Numeric, 15-16 digits | Not required for messaging, useful for analytics. | | **WABA ID** (optional) | App Dashboard → WhatsApp → API Setup → near the top | Numeric, 15+ digits | Not required for messaging, useful for analytics. | --- ## Permanent token (production) Temporary access tokens expire after **24 hours**, which means a token generated today stops working tomorrow. For production deployments use a **System User permanent token**: 1. Go to [business.facebook.com/latest/settings](https://business.facebook.com/latest/settings) → **System users** (left sidebar). 2. **Add** → name (e.g. `claway-bot`) → role: **Admin**. 3. Select the new user → **Assign Assets**: - Select your app → toggle **Manage app** under Full control. - Select your WhatsApp account → toggle **Manage WhatsApp Business Accounts** under Full control. - Click **Assign assets**. 4. **Generate token** with these permissions: - `business_management` - `whatsapp_business_messaging` - `whatsapp_business_management` 5. Set **token expiration: Never**. 6. Copy the token → update `WHATSAPP_CLOUD_ACCESS_TOKEN` in `~/.claway/.env` → restart the gateway. System User tokens don't expire unless you explicitly revoke them. --- ## Exposing Claway to the internet The Cloud API delivers inbound messages by HTTPS POST to your webhook URL — that means the Claway gateway has to be reachable from Meta's servers. Three common ways: ### Cloudflare Tunnel (recommended) Free, no port forwarding, works on Windows / macOS / Linux. Runs as a separate process alongside the gateway. **Install:** ```bash # Windows winget install Cloudflare.cloudflared # macOS brew install cloudflared # Linux # Download the binary from https://github.com/cloudflare/cloudflared/releases ``` **Run a quick tunnel** (no Cloudflare account needed — gives you a `https://<random>.trycloudflare.com` URL): ```bash cloudflared tunnel --url http://localhost:8090 ``` Note the printed URL — that's what you'll give Meta. :::warning Quick tunnels rotate The free quick-tunnel URL changes every time you restart `cloudflared`. For a stable URL, log in with `cloudflared tunnel login` and create a named tunnel. Free Cloudflare accounts get unlimited named tunnels — see [Cloudflare's docs](https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/) for the named-tunnel workflow. ::: ### ngrok ```bash ngrok http 8090 ``` Free tier shows a different URL on each restart. Paid tier gives you a stable subdomain. ### Your own domain + reverse proxy If you already have a server with a TLS cert (Caddy, nginx, etc.), point a route at `localhost:8090`. This is the most stable option for production but requires existing infrastructure. --- ## Configuring the webhook on Meta's side Once your tunnel is running: 1. Note the public URL printed by your tunnel — say `https://abc123.trycloudflare.com`. 2. Generate a **Verify Token** — the wizard does this for you with `secrets.token_urlsafe(32)`; if you're configuring manually, run: ```bash python -c "import secrets; print(secrets.token_urlsafe(32))" ``` Save it as `WHATSAPP_CLOUD_VERIFY_TOKEN` in `~/.claway/.env`. 3. Start the Claway gateway: `claway gateway`. 4. In the Meta App Dashboard → **WhatsApp → Configuration** (or **Use cases → Customize → Configuration** depending on UI version) → click **Edit** on the Webhook section. 5. Fill in: - **Callback URL**: `https://abc123.trycloudflare.com/whatsapp/webhook` - **Verify Token**: the string from step 2 (must match exactly) 6. Click **Verify and save**. Meta hits your URL with a GET request, the gateway echoes back the challenge, and Meta marks the webhook as verified. 7. Under **Webhook fields**, click **Manage** → subscribe to the **messages** field. This is what tells Meta to actually deliver inbound messages to your webhook. **To verify the loop manually** (from a third terminal): ```bash TUNNEL="https://abc123.trycloudflare.com" VERIFY="<your verify token>" # Should print HTTP 200 with body "hello" curl -i "$TUNNEL/whatsapp/webhook?hub.mode=subscribe&hub.verify_token=$VERIFY&hub.challenge=hello" # Health endpoint — should show verify_token_configured: true and app_secret_configured: true curl "$TUNNEL/health" ``` --- ## Recipient whitelist (Meta-side) In development mode (before your app goes through App Review), Meta restricts which numbers your bot can message: 1. App Dashboard → WhatsApp → API Setup → **To** dropdown. 2. Click **Manage phone number list**. 3. Add the phone numbers you want to message (yours, your team's, friendly testers). Meta sends each one a 6-digit verification code via SMS or WhatsApp. Up to 5 numbers in dev mode. Going to App Review removes this limit. --- ## Allowlist (Claway-side) In addition to Meta's recipient whitelist, Claway has its own per-platform allowlist that controls **which incoming messages the agent processes**. Add to `~/.claway/.env`: ```bash # Comma-separated phone numbers, country code, no '+' / spaces / dashes WHATSAPP_CLOUD_ALLOWED_USERS=15551234567,15557654321 # Or allow everyone (only safe in combination with Meta's recipient whitelist) # WHATSAPP_CLOUD_ALLOW_ALL_USERS=true ``` The wizard sets this in step 6. Without an allowlist, **every inbound message is denied** — this is intentional, so the bot can't be invoked by random numbers if the recipient whitelist is ever loosened. --- ## Polishing your bot's WhatsApp profile WhatsApp displays a **name and profile picture** for your bot in the chat header and contact list. These can't be set via the Cloud API — they live in Meta's Business Manager. Once your bot is working, head to **[business.facebook.com/wa/manage/phone-numbers](https://business.facebook.com/wa/manage/phone-numbers/)**, click your phone number, and you'll find: | What | Where | Notes | |---|---|---| | **Display name** | Top of the phone-number page | Changes go through Meta's name-review process (~24–48 hours). | | **Profile picture** | Top of the phone-number page | Square image, ≥640×640px recommended. Updates immediately. | | **About / description / website / email / hours / category** | "Edit profile" button | These appear in the info pane when a user taps the bot's name. Cosmetic. | | **Verified badge** (green checkmark) | Business Manager → Security Center → Start Verification | Requires Meta's separate business verification process. | The `claway whatsapp-cloud` wizard prints these links at the end of setup. None of this is required for the bot to work — it's pure polish for how your bot appears to users. --- ## Configuration reference All settings live in `~/.claway/.env`. Required values are in **bold**. | Variable | Default | Description | |---|---|---| | **`WHATSAPP_CLOUD_PHONE_NUMBER_ID`** | — | The 15-17 digit ID from API Setup. **Not** the phone number. | | **`WHATSAPP_CLOUD_ACCESS_TOKEN`** | — | Meta access token (starts with `EAA`). Temp 24h or System User permanent. | | **`WHATSAPP_CLOUD_APP_SECRET`** | — | 32-char hex from Settings → Basic. Without it, inbound is refused with 503. | | **`WHATSAPP_CLOUD_VERIFY_TOKEN`** | — | Shared secret for the GET handshake. Auto-generated by the wizard. | | **`WHATSAPP_CLOUD_ALLOWED_USERS`** | — | Comma-separated wa_ids allowed to message the bot. | | `WHATSAPP_CLOUD_ALLOW_ALL_USERS` | `false` | Set to `true` to bypass the allowlist. | | `WHATSAPP_CLOUD_APP_ID` | — | Optional, for future analytics integration. | | `WHATSAPP_CLOUD_WABA_ID` | — | Optional, for future analytics integration. | | `WHATSAPP_CLOUD_WEBHOOK_HOST` | `0.0.0.0` | Interface the webhook server binds to. | | `WHATSAPP_CLOUD_WEBHOOK_PORT` | `8090` | Port the webhook server binds to. Must match the port your tunnel forwards. | | `WHATSAPP_CLOUD_WEBHOOK_PATH` | `/whatsapp/webhook` | URL path Meta posts to. | | `WHATSAPP_CLOUD_API_VERSION` | `v20.0` | Meta Graph API version. Only override if a newer version is recommended in Meta's docs. | | `WHATSAPP_CLOUD_HOME_CHANNEL` | — | wa_id to use as the bot's home channel (for cron jobs etc). | You can have **both** the Baileys (`whatsapp`) and Cloud (`whatsapp_cloud`) adapters enabled simultaneously, targeting different phone numbers. --- ## Features ### Inbound - **Text messages** — passed straight to the agent. - **Images** — auto-downloaded and attached to the agent's input. Models with native vision (Claude, GPT-4o, Gemini, etc.) read the image directly; non-vision models receive an auto-generated text description. - **Voice notes** — auto-downloaded as `.ogg`, transcribed via your configured STT provider (local faster-whisper, OpenAI, Groq, etc.), then handed to the agent as text. - **Documents** — auto-downloaded. Small text-readable files (`.txt`, `.md`, `.json`, `.py`, `.csv`, etc.) up to 100KB get inlined into the agent's input so it can read them without a tool call. Larger files are cached locally for the agent's other tools to access. - **Button taps** — when the user taps a button the bot sent earlier (clarify choice, command approval, slash-command confirm), the tap is routed directly to the right handler. Stale taps fall back to being treated as regular text input. - **Reply context** — when the user replies to a previous bot message, the agent sees the original message as context. ### Outbound - **Text** — markdown is auto-converted to WhatsApp's flavored syntax (`**bold**` → `*bold*`, `~~strike~~` → `~strike~`, headers → bold, `[link](url)` → `link (url)`). Long messages split at 4096 chars per chunk. - **Images** — agent-generated images and local image files both supported, delivered as native photo attachments. - **Voice messages** — text-to-speech output is converted via ffmpeg into the native WhatsApp voice-note bubble (green waveform). Without ffmpeg installed, falls back to an MP3 audio attachment. See "Voice messages" below. - **Video / documents** — both supported, sent as native attachments. ### Interactive UX When the agent invokes any of these flows, Claway uses WhatsApp's native interactive messages — tap-to-answer buttons instead of "reply with the number" prompts: - **`clarify` tool** — multi-choice questions render as quick-reply buttons (1–3 choices) or a tap-to-open list sheet (4+ choices). Picking "✏️ Other" lets the user type a free-form answer that the agent receives as the resolution. - **Dangerous-command approvals** — when the agent's terminal/code execution hits a gated command, the user sees `✅ Approve` / `❌ Deny` buttons instead of needing to type `/approve` or `/deny`. - **Slash-command confirmations** — privileged commands like `/reload-mcp` show `✅ Approve Once` / `🔒 Always` / `❌ Cancel` buttons. All interactive prompts gracefully degrade to plain text if the buttons fail to render (e.g. on legacy WhatsApp clients). ### Read receipts and typing indicator Claway acknowledges inbound messages immediately: - Your message shows **blue double-checkmarks** as soon as the gateway receives it. - The bot's name in your WhatsApp chat shows **"typing…"** while the agent is preparing a reply. - The typing indicator auto-dismisses when the bot's first response message arrives. This makes it obvious when the bot has seen your message versus when it's still working on a response. ### Voice messages WhatsApp distinguishes between a "voice note" (the green waveform bubble) and a generic audio file attachment. The difference is purely codec: voice notes need to be `audio/ogg` with `opus` encoding. Claway TTS produces MP3. Two paths: - **With ffmpeg on PATH** (recommended) — outbound TTS is converted and arrives as a proper voice note. Install: - Windows: `winget install Gyan.FFmpeg` - macOS: `brew install ffmpeg` - Linux: package manager - **Without ffmpeg** — outbound TTS arrives as an MP3 audio attachment. Plays fine, just doesn't look like a voice note. A one-time warning fires in the gateway log so you know. You can check whether the gateway found ffmpeg via the health endpoint: ```bash curl http://localhost:8090/health # look for "ffmpeg_present": true ``` --- ## Known limitations ### 24-hour conversation window Meta only allows **free-form messages** within a 24-hour window after the user's last inbound message. Outside that window, the only thing Meta's API accepts is a pre-approved **message template**. **What this means in practice:** - Reactive chat (user DMs → bot replies within 24h → user replies → ...) works forever. This covers >95% of normal bot use. - **Cron jobs that deliver to WhatsApp** after a gap > 24h will fail with Graph error code `131047` ("Re-engagement message"). - **Long-running `delegate_task` async results** that take longer than 24h fail the same way. - **Webhook subscribers** that route external events to WhatsApp fail when the user hasn't DM'd the bot recently. Claway warns the agent about this window in its system prompt, so the model knows to mention it when scheduling delayed messages. Message-template support (the workaround for outside-window sends) is not yet implemented in Claway. If you need it, email support@claway.io — it's planned but waiting on a clear demand signal. ### Group chats The Cloud API has limited group support (capability-tier gated by Meta). Claway's `whatsapp_cloud` adapter currently handles **direct messages only** in v1. If you need group chats, use the Baileys bridge. ### Outbound rate limit Meta's default throughput is **80 messages/second per business phone number**, with upgrades available. Claway doesn't currently enforce this client-side — extremely high-volume sends could hit Meta's limit. --- ## Troubleshooting ### Setup verification fails ("URL couldn't be validated") in Meta dashboard Almost always one of: - **Tunnel URL is wrong or stale** — cloudflared quick tunnels rotate. Get a fresh URL and update both `.env` and Meta's dashboard. - **Verify token mismatch** — the token in `~/.claway/.env`'s `WHATSAPP_CLOUD_VERIFY_TOKEN` must match exactly what you typed into Meta's dashboard. Run the curl probe above to confirm the gateway's verify handshake works locally first. - **Gateway not running** — check `claway gateway` is up. - **App Secret not set** — without it, Claway refuses inbound POSTs with 503. Meta interprets that as "can't validate." ### `graph error 100`: Object with ID '...' does not exist You pasted your phone number (10-11 digits) into `WHATSAPP_CLOUD_PHONE_NUMBER_ID` instead of the Phone Number ID (Meta's 15-17 digit internal ID). Re-check the API Setup page — the Phone Number ID is shown *below* the "From" dropdown. The wizard catches this with a validator now, but it's worth knowing if you're configuring manually. ### `graph error 190`: Authentication Error Your access token is invalid. Subcodes: - `subcode 463` — token expired. Temp tokens last 24h. Regenerate, or switch to a System User permanent token (see above). - `subcode 467` — token invalidated (revoked or password changed). - Other 190 — token didn't have the required permissions when generated. Make sure all three (`business_management`, `whatsapp_business_messaging`, `whatsapp_business_management`) were selected. ### `graph error 131047`: Re-engagement message The 24-hour conversation window expired (see "Known limitations"). Either: - Ask the user to DM the bot first to reopen the window. - Wait for template support to land in Claway. ### Inbound message: `media metadata fetch failed (status=401)` Same 401 root causes as outbound (`graph error 190`) — the access token is invalid or expired. Fix the token. ### Bot replies appear as raw JSON / tool-call leakage Common cause: the toolset configured for `whatsapp_cloud` is missing the tools the agent wants to call. Check `claway tools list` and verify the platform is using `claway-whatsapp` (the default Cloud adapter toolset, same as Baileys). If the model emits tool-call-shaped text instead of a structured call, it usually means the toolset was effectively empty. See `claway_cli/platforms.py` for the platform → default toolset mapping. ### STT (voice note transcription) returns empty / "could not transcribe" The default `stt.provider: local` requires `faster-whisper` to be installed. Alternatively, switch `stt.provider` to a hosted speech-to-text provider (for example `openai` with `OPENAI_API_KEY` set) and restart the gateway. --- ## Security notes - **Treat the App Secret like a password** — anyone with it can forge webhook payloads that Claway will accept as authentic. - **The verify token is a shared secret** — leaks are lower-stakes (worst case someone could re-subscribe Meta's webhook to a different URL of theirs), but still avoid committing it. - **The access token is your bot's identity** — System User tokens are equivalent to long-lived API keys. Rotate immediately if a deployment is compromised. - **The webhook endpoint accepts only signed requests when `WHATSAPP_CLOUD_APP_SECRET` is set** — leave it set even in development. Without it, the gateway refuses inbound delivery with HTTP 503. - **The `/health` endpoint is unauthenticated** — it's safe to expose because it only reports config-presence booleans, not the values themselves. But if you'd rather not surface it, restrict access at the reverse proxy / tunnel layer. --- ## Comparison to the Baileys bridge | | Baileys (`claway whatsapp`) | Cloud API (`claway whatsapp-cloud`) | |---|---|---| | Account type | Personal | Business | | Setup | QR code scan | Meta app + WABA + token | | Dependencies | Node.js + npm | Pure Python (httpx + aiohttp) | | Process | Managed Node subprocess | aiohttp webhook server | | Public URL needed? | No | Yes | | Account ban risk | Yes (unofficial API) | No (officially supported) | | Inbound | Polling Node bridge | Webhook POST from Meta | | Outbound | Local bridge → Baileys | HTTPS to graph.facebook.com | | Groups | Full support | DMs only (v1) | | 24h window | No restriction | Hard rule — templates required after | | Voice notes (out) | Native | Native with ffmpeg, MP3 fallback otherwise | | Read receipts | No | Yes (blue double-checkmarks) | | Typing indicator | No | Yes (auto-dismisses on response) | | Interactive buttons | Text fallback only | Native (clarify, approval, slash-confirm) | | Production use | Risky (Meta can ban) | Designed for it | Most users running Claway for personal projects prefer Baileys. Most users running customer-facing bots prefer Cloud API. --- ## See also - [Meta's official WhatsApp Business Cloud API docs](https://developers.facebook.com/documentation/business-messaging/whatsapp/) — authoritative reference for the underlying platform, pricing, App Review, and Meta-side rate limits. - [WhatsApp (Baileys bridge) Setup](whatsapp.md) — the alternative integration for personal projects. - [Messaging Platforms overview](index.md) — all messaging integrations at a glance. --- <!-- source: website/docs/user-guide/messaging/yuanbao.md --> # Yuanbao # Yuanbao Connect Claway to [Yuanbao](https://yuanbao.tencent.com/), Tencent's enterprise messaging platform. The adapter uses a WebSocket gateway for real-time message delivery and supports both direct (C2C) and group conversations. :::info Yuanbao is an enterprise messaging platform primarily used within Tencent and enterprise environments. It uses WebSocket for real-time communication, HMAC-based authentication, and supports rich media including images, files, and voice messages. ::: ## Prerequisites - A Yuanbao account with bot creation permissions - Yuanbao APP_ID and APP_SECRET (from platform admin) - Python packages: `websockets` and `httpx` - For media support: `aiofiles` Install the required dependencies: ```bash pip install websockets httpx aiofiles ``` ## Setup ### 1. Create a Bot in Yuanbao 1. Download the Yuanbao app from [https://yuanbao.tencent.com/](https://yuanbao.tencent.com/) 2. In the app, go to **PAI → My Bot** and create a new bot 3. After the bot is created, copy the **APP_ID** and **APP_SECRET** ### 2. Run the Setup Wizard The easiest way to configure Yuanbao is through the interactive setup: ```bash claway gateway setup ``` Select **Yuanbao** when prompted. The wizard will: 1. Ask for your APP_ID 2. Ask for your APP_SECRET 3. Save the configuration automatically :::tip The WebSocket URL and API Domain have sensible defaults built in. You only need to provide APP_ID and APP_SECRET to get started. ::: ### 3. Configure Environment Variables After initial setup, verify these variables in `~/.claway/.env`: ```bash # Required YUANBAO_APP_ID=your-app-id YUANBAO_APP_SECRET=your-app-secret YUANBAO_WS_URL=wss://api.yuanbao.example.com/ws YUANBAO_API_DOMAIN=https://api.yuanbao.example.com # Optional: bot account ID (normally obtained automatically from sign-token) # YUANBAO_BOT_ID=your-bot-id # Optional: internal routing environment (e.g. test/staging/production) # YUANBAO_ROUTE_ENV=production # Optional: home channel for cron/notifications (format: direct:<account> or group:<group_code>) YUANBAO_HOME_CHANNEL=direct:bot_account_id YUANBAO_HOME_CHANNEL_NAME="Bot Notifications" # Optional: restrict access (legacy, see Access Control below for fine-grained policies) YUANBAO_ALLOWED_USERS=user_account_1,user_account_2 ``` ### 4. Start the Gateway ```bash claway gateway ``` The adapter will connect to the Yuanbao WebSocket gateway, authenticate using HMAC signatures, and begin processing messages. ## Features - **WebSocket gateway** — real-time bidirectional communication - **HMAC authentication** — secure request signing with APP_ID/APP_SECRET - **C2C messaging** — direct user-to-bot conversations - **Group messaging** — conversations in group chats - **Media support** — images, files, and voice messages via COS (Cloud Object Storage) - **Markdown formatting** — messages are automatically chunked for Yuanbao's size limits - **Message deduplication** — prevents duplicate processing of the same message - **Heartbeat/keep-alive** — maintains WebSocket connection stability - **Typing indicators** — shows "typing…" status while the agent processes - **Automatic reconnection** — handles WebSocket disconnections with exponential backoff - **Group information queries** — retrieve group details and member lists - **Sticker/Emoji support** — send TIMFaceElem stickers and emoji in conversations - **Auto-sethome** — first user to message the bot is automatically set as the home channel owner - **Slow-response notification** — sends a waiting message when the agent takes longer than expected ## Configuration Options ### Chat ID Formats Yuanbao uses prefixed identifiers depending on conversation type: | Chat Type | Format | Example | |-----------|--------|---------| | Direct message (C2C) | `direct:<account>` | `direct:user123` | | Group message | `group:<group_code>` | `group:grp456` | ### Media Uploads The Yuanbao adapter automatically handles media uploads via COS (Tencent Cloud Object Storage): - **Images**: Supports JPEG, PNG, GIF, WebP - **Files**: Supports all common document types - **Voice**: Supports WAV, MP3, OGG Media URLs are automatically validated and downloaded before upload to prevent SSRF attacks. ## Home Channel Use the `/sethome` command in any Yuanbao chat (DM or group) to designate it as the **home channel**. Scheduled tasks (cron jobs) deliver their results to this channel. :::tip Auto-sethome If no home channel is configured, the first user to message the bot will be automatically set as the home channel owner. If the current home channel is a group chat, the first DM will upgrade it to a direct channel. ::: You can also set it manually in `~/.claway/.env`: ```bash YUANBAO_HOME_CHANNEL=direct:user_account_id # or for a group: # YUANBAO_HOME_CHANNEL=group:group_code YUANBAO_HOME_CHANNEL_NAME="My Bot Updates" ``` ### Example: Set Home Channel 1. Start a conversation with the bot in Yuanbao 2. Send the command: `/sethome` 3. The bot responds: "Home channel set to [chat_name] with ID [chat_id]. Cron jobs will deliver to this location." 4. Future cron jobs and notifications will be sent to this channel ### Example: Cron Job Delivery Create a cron job: ```bash /cron "0 9 * * *" Check server status ``` The scheduled output will be delivered to your Yuanbao home channel every day at 9 AM. ## Usage Tips ### Starting a Conversation Send any message to the bot in Yuanbao: ``` hello ``` The bot responds in the same conversation thread. ### Available Commands All standard Claway commands work on Yuanbao: | Command | Description | |---------|-------------| | `/new` | Start a fresh conversation | | `/model [provider:model]` | Show or change the model | | `/sethome` | Set this chat as the home channel | | `/status` | Show session info | | `/help` | Show available commands | ### Sending Files To send a file to the bot, simply attach it directly in the Yuanbao chat. The bot will automatically download and process the file attachment. You can also include a message with the attachment: ``` Please analyze this document ``` ### Receiving Files When you ask the bot to create or export a file, it sends the file directly to your Yuanbao chat. ## Troubleshooting ### Bot is online but not responding to messages **Cause**: Authentication failed during WebSocket handshake. **Fix**: 1. Verify APP_ID and APP_SECRET are correct 2. Check that the WebSocket URL is accessible 3. Ensure the bot account has proper permissions 4. Review gateway logs: `tail -f ~/.claway/logs/gateway.log` ### "Connection refused" error **Cause**: WebSocket URL is unreachable or incorrect. **Fix**: 1. Verify the WebSocket URL format (should start with `wss://`) 2. Check network connectivity to the Yuanbao API domain 3. Confirm firewall allows WebSocket connections 4. Test URL with: `curl -I https://[YUANBAO_API_DOMAIN]` ### Media uploads fail **Cause**: COS credentials are invalid or media server is unreachable. **Fix**: 1. Verify API_DOMAIN is correct 2. Check that media upload permissions are enabled for your bot 3. Ensure the media file is accessible and not corrupted 4. Check COS bucket configuration with platform admin ### Messages not delivered to home channel **Cause**: Home channel ID format is incorrect or cron job hasn't triggered. **Fix**: 1. Verify YUANBAO_HOME_CHANNEL is in correct format 2. Test with `/sethome` command to auto-detect correct format 3. Check cron job schedule with `/status` 4. Verify bot has send permissions in the target chat ### Frequent disconnections **Cause**: WebSocket connection is unstable or network is unreliable. **Fix**: 1. Check gateway logs for error patterns 2. Increase heartbeat timeout in connection settings 3. Ensure stable network connection to Yuanbao API 4. Consider enabling verbose logging: `CLAWAY_LOG_LEVEL=debug` ## Access Control Yuanbao supports fine-grained access control for both DM and group conversations: ```bash # DM policy: open (default) | allowlist | disabled YUANBAO_DM_POLICY=open # Comma-separated user IDs allowed to DM the bot (only used when DM_POLICY=allowlist) YUANBAO_DM_ALLOW_FROM=user_id_1,user_id_2 # Group policy: open (default) | allowlist | disabled YUANBAO_GROUP_POLICY=open # Comma-separated group codes allowed (only used when GROUP_POLICY=allowlist) YUANBAO_GROUP_ALLOW_FROM=group_code_1,group_code_2 ``` These can also be set in `config.yaml`: ```yaml platforms: yuanbao: extra: dm_policy: allowlist dm_allow_from: "user1,user2" group_policy: open group_allow_from: "" ``` ## Advanced Configuration ### Message Chunking Yuanbao has a maximum message size. Claway automatically chunks large responses with Markdown-aware splitting (respects code fences, tables, and paragraph boundaries). ### Connection Parameters The following connection parameters are built into the adapter with sensible defaults: | Parameter | Default Value | Description | |-----------|---------------|-------------| | WebSocket connect timeout | 15 seconds | Time to wait for WS handshake | | Heartbeat interval | 30 seconds | Ping frequency to keep connection alive | | Max reconnect attempts | 100 | Maximum number of reconnection tries | | Reconnect backoff | 1s → 60s (exponential) | Wait time between reconnect attempts | | Reply heartbeat interval | 2 seconds | RUNNING status send frequency | | Send timeout | 30 seconds | Timeout for outbound WS messages | :::note These values are currently not configurable via environment variables. They are optimized for typical Yuanbao deployments. ::: ### Verbose Logging Enable debug logging to troubleshoot connection issues: ```bash CLAWAY_LOG_LEVEL=debug claway gateway ``` ## Integration with Other Features ### Cron Jobs Schedule tasks that run on Yuanbao: ``` /cron "0 */4 * * *" Report system health ``` Results are delivered to your home channel. ### Background Tasks Run long operations without blocking the conversation: ``` /background Analyze all files in the archive ``` ### Cross-Platform Messages Send a message from CLI to Yuanbao: ```bash claway chat -q "Send 'Hello from CLI' to yuanbao:group:group_code" ``` ## Related Documentation - [Messaging Gateway Overview](./index.md) - [Slash Commands Reference](/reference/slash-commands) - [Cron Jobs](/user-guide/features/cron) - [Background Sessions](/user-guide/cli#background-sessions) --- <!-- source: website/docs/user-guide/multi-profile-gateways.md --> # user-guide/multi-profile-gateways.md # Running Many Gateways at Once Operate multiple [profiles](./profiles.md) — each with its own bot tokens, sessions, and memory — as managed services on a single machine. This page covers the operational concerns: starting them all together, viewing logs across profiles, preventing the host from sleeping, and recovering from common launchd/systemd quirks. If you only run one Claway agent, you don't need this page — see [Profiles](./profiles.md) for the basics. ## When to use this You want this setup when you have two or more Claway agents that should all be online at the same time. Common reasons: - A personal assistant on one Telegram bot and a coding agent on another - One agent per family member or one per Slack workspace - Sandbox + production instances of the same configuration - A research agent + a writing agent + a cron-driven bot — each with isolated memory and skills Every profile already gets its own per-platform LaunchAgent (`ai.claway.gateway-<name>.plist`) or systemd user service (`claway-gateway-<name>.service`). This guide adds the patterns for managing them collectively. ## Quick start ```bash # Create profiles (once) claway profile create coder claway profile create personal-bot claway profile create research # Configure each coder setup personal-bot setup research setup # Install each gateway as a managed service coder gateway install personal-bot gateway install research gateway install # Start them all coder gateway start personal-bot gateway start research gateway start ``` That's it — three independent agents, each on its own process, restarting automatically on crash and on user login. ## Alternative: one gateway for all profiles (multiplexing) The model above runs **one process per profile**. That is the default and is the right choice for most setups. But on a host with many profiles — or a container deployment where one process per profile is operationally heavy — you can instead run a **single multiplexing gateway**: the default profile's gateway becomes the sole inbound process and serves messages for *every* profile on the box. This is **opt-in** and **off by default**. When it's off, nothing on this page changes — every behavior below is inert. ### When to prefer multiplexing - A container/VPS deployment where N supervisor units, N ports, and N PID files are a burden. - Many low-traffic profiles that don't each justify a full process. - You want a single thing to start, monitor, and restart. Stick with one-process-per-profile when you want hard process-level isolation between profiles (separate memory footprints, independent crash domains, the ability to restart one profile without touching the others). ### How to opt in Set the flag on the **default profile** (it owns the multiplexer) and restart its gateway: ```bash claway config set gateway.multiplex_profiles true claway gateway restart ``` Equivalently, in the default profile's `~/.claway/config.yaml`: ```yaml gateway: multiplex_profiles: true ``` (The flag is also accepted as a top-level `multiplex_profiles: true` for convenience.) On the next start the default gateway enumerates every profile, brings up each profile's enabled platforms under that profile's own credentials, and routes each inbound message to the profile it belongs to. Each turn resolves the routed profile's config, skills, memory, SOUL, **and provider keys** — credentials are never shared across profiles. You do **not** run `claway gateway start` for the secondary profiles — the default gateway serves them. See the contract changes below. ### What changes when multiplexing is on Enabling the flag changes how a few things behave. All of these revert the moment the flag is off. #### 1. Secondary profiles must not start their own gateway With a multiplexer running, a named-profile `claway gateway start` / `run` is a **hard error**, pointing you back at the multiplexer: ``` The default gateway is running as a profile multiplexer and already serves profile 'coder'. ... ``` The multiplexer is the single inbound process; a second profile gateway would double-bind that profile's platforms. Pass `--force` only if you deliberately want a separate process for that profile (not recommended while the multiplexer is running). The cross-profile lifecycle wrapper script earlier on this page is therefore **not** used in multiplex mode — you only manage the default gateway. #### 2. HTTP-inbound platforms are reached via a `/p/<profile>/` URL prefix Webhook (and other HTTP-inbound) traffic for a secondary profile arrives on the default listener under a profile prefix, **not** a second port: ``` # default profile POST http://host:8644/webhooks/<route> # the "coder" profile, same listener POST http://host:8644/p/coder/webhooks/<route> ``` An unknown or unconfigured profile in the prefix returns `404`. Because the one shared listener already serves every profile this way, a **secondary profile must not enable a port-binding platform itself** — doing so is a config error and the gateway refuses to start, naming the profile and platform: ``` Profile 'coder' enables the port-binding platform 'webhook', but gateway.multiplex_profiles is on. ... Remove platforms.webhook from profile 'coder's config.yaml (configure it only on the default profile). ``` Port-binding platforms covered by this rule: `webhook`, `api_server`, `msgraph_webhook`, `feishu`, `wecom_callback`, `bluebubbles`, `sms`. Configure any of these **only on the default profile**; every profile is reachable through its `/p/<profile>/` prefix. #### 3. Per-credential platforms still need their own token per profile Polling/connection platforms (Telegram, Discord, Slack, Matrix, Signal, …) work fine multiplexed, but each profile that enables one must supply its **own** bot token — the same token cannot be polled by two profiles at once. If two profiles configure the same `(platform, token)`, startup fails fast naming both profiles (see [Token-conflict safety](#token-conflict-safety) — the rule is unchanged, it's just enforced inside the one process now). #### 4. Session keys are namespaced by profile Each profile's sessions live under an `agent:<profile>:…` namespace so two profiles on the same platform/chat never collide in the shared session store. The **default** profile keeps the historical `agent:main:…` namespace byte-for-byte, so existing default-profile sessions are unaffected — no migration, no orphaned history. #### 5. One PID/lock and one status surface There is a single process-level PID and lock (the multiplexer, under the default home). `claway status` reports the multiplexer and the profiles it serves; `claway status -p <name>` slices to one profile. Each profile still writes its own `runtime_status.json` under its own home, so existing per-profile readers keep working. #### What does **not** change Per-profile `.env` credential isolation is preserved and, if anything, stricter: a profile's keys are resolved from its own scope and are never unioned into a shared environment (this also means subprocesses like MCP servers and Kanban workers only ever see their own profile's secrets). Kanban, profile-scoped skills/memory/SOUL, and model routing all behave per-profile exactly as they do with separate gateways. ## Start, stop, or restart all gateways at once The CLI ships with single-profile lifecycle commands. To act across every profile, wrap them in a shell loop. Put the snippet below in `~/.local/bin/claway-gateways` and `chmod +x` it: ```sh #!/bin/sh set -eu # Add or remove profile names here as you create / delete profiles. profiles="default coder personal-bot research" usage() { echo "Usage: claway-gateways {start|stop|restart|status|list}" } run_for_profile() { profile="$1" action="$2" if [ "$profile" = "default" ]; then claway gateway "$action" else claway -p "$profile" gateway "$action" fi } action="${1:-}" case "$action" in start|stop|restart|status) for profile in $profiles; do echo "==> $action $profile" run_for_profile "$profile" "$action" done ;; list) claway gateway list ;; *) usage exit 2 ;; esac ``` Then: ```bash claway-gateways start # start every configured profile claway-gateways stop # stop every configured profile claway-gateways restart # restart all claway-gateways status # status across all claway-gateways list # delegates to `claway gateway list` ``` :::tip The `default` profile is targeted with `claway gateway <action>` (no `-p`), not `claway -p default gateway <action>`. The wrapper above handles both forms. ::: ## Manage one profile The shortcut commands every profile installs: ```bash coder gateway run # foreground (Ctrl-C to stop) coder gateway start # start the managed service coder gateway stop # stop the managed service coder gateway restart # restart coder gateway status # status coder gateway install # create the LaunchAgent / systemd unit coder gateway uninstall # remove the service file ``` These are equivalent to `claway -p coder gateway <action>` — useful if a profile alias is not on `PATH` or if you target profiles dynamically from a script. ## Service files Each profile installs its own service with a unique name, so installations never clash: | Platform | Path | | -------- | ----------------------------------------------------------------- | | macOS | `~/Library/LaunchAgents/ai.claway.gateway-<profile>.plist` | | Linux | `~/.config/systemd/user/claway-gateway-<profile>.service` | The default profile keeps the historical names: `ai.claway.gateway.plist` / `claway-gateway.service`. ## Viewing logs Each profile writes to its own log files: ```bash # Default profile tail -f ~/.claway/logs/gateway.log tail -f ~/.claway/logs/gateway.error.log # Named profile tail -f ~/.claway/profiles/<name>/logs/gateway.log tail -f ~/.claway/profiles/<name>/logs/gateway.error.log ``` Stream every profile's log simultaneously: ```bash tail -f ~/.claway/logs/gateway.log ~/.claway/profiles/*/logs/gateway.log ``` The CLI also has a structured log viewer: ```bash claway logs -f # follow default profile claway -p coder logs -f # follow one profile claway logs --help # filters, levels, JSON output ``` ## Identify what's actually running ```bash claway profile list # profiles + model + gateway state claway-gateways status # full status across every profile launchctl list | grep claway # macOS — PIDs and labels systemctl --user list-units 'claway-gateway-*' # Linux — units ``` ## Editing configuration Every profile keeps its config inside its own directory: ``` ~/.claway/profiles/<name>/ ├── .env # API keys, bot tokens (chmod 600) ├── config.yaml # model, provider, toolsets, gateway settings └── SOUL.md # personality / system prompt ``` The default profile uses `~/.claway/` directly with the same three files. Edit them with any editor or via the CLI: ```bash claway config set model.model anthropic/claude-sonnet-4 # default profile coder config set model.model openai/gpt-5 # named profile ``` After editing `.env` or `config.yaml`, restart the affected gateway: ```bash coder gateway restart # or, for everything: claway-gateways restart ``` ## Keeping the host awake The gateway process can run all day, but the operating system will still try to sleep when idle. Two patterns: ### macOS — `caffeinate` `caffeinate` is built into macOS and prevents sleep while it runs. No install. ```bash caffeinate -dis # block display, idle, and system sleep caffeinate -dis -t 28800 # same, auto-exit after 8 hours caffeinate -i -w $(cat ~/.claway/gateway.pid) & # awake while default gateway runs # Persistent: run in background and forget nohup caffeinate -dis >/dev/null 2>&1 & disown # Inspect / stop pmset -g assertions | grep -iE 'caffeinate|prevent|user is active' pkill caffeinate ``` | Flag | Effect | | ------ | ------------------------------------------------- | | `-d` | block display sleep | | `-i` | block idle system sleep (default) | | `-m` | block disk sleep | | `-s` | block system sleep (AC-powered Macs only) | | `-u` | simulate user activity (prevents screen lock) | | `-t N` | auto-exit after `N` seconds | | `-w P` | exit when PID `P` exits | :::warning Lid-close still sleeps the Mac `caffeinate` cannot override the hardware-driven lid-close sleep on MacBooks. For lid-closed operation, change your Energy Saver / Battery preferences or use a third-party tool. ::: ### Linux — `systemd-inhibit` or `loginctl` ```bash # Inhibit suspend while a command runs systemd-inhibit --what=idle:sleep --who=claway --why="gateways running" \ sleep infinity & # Allow user services to keep running after logout (recommended) sudo loginctl enable-linger "$USER" ``` After enabling lingering, your systemd user units (including `claway-gateway-<profile>.service`) continue running across SSH disconnects and reboots. ## Token-conflict safety Each profile must use unique bot tokens for each platform. If two profiles share a Telegram, Discord, Slack, WhatsApp, or Signal token, the second gateway refuses to start with an error naming the conflicting profile. To audit: ```bash grep -H 'TELEGRAM_BOT_TOKEN\|DISCORD_BOT_TOKEN' \ ~/.claway/.env ~/.claway/profiles/*/.env ``` ## Updating the code `claway update` pulls the latest code once and syncs new bundled skills into every profile: ```bash claway update claway-gateways restart ``` User-modified skills are never overwritten. ## Troubleshooting ### "Could not find service in domain for user gui: 501" You ran `claway gateway start` after a previous `claway gateway stop`. The CLI's `stop` does a full `launchctl unload`, which removes the service from launchd's registry. The CLI catches this specific error on `start` and automatically re-loads the plist (`↻ launchd job was unloaded; reloading service definition`). The service starts normally. Nothing to fix. ### Stale PID after a crash If a profile's gateway shows `not running` but a process is still alive: ```bash ps -ef | grep "claway_cli.*-p <profile>" cat ~/.claway/profiles/<profile>/gateway.pid kill -TERM <pid> # graceful kill -KILL <pid> # if that fails after a few seconds <profile> gateway start ``` ### Forcing a hard reset of one service ```bash # macOS launchctl unload ~/Library/LaunchAgents/ai.claway.gateway-<profile>.plist launchctl load ~/Library/LaunchAgents/ai.claway.gateway-<profile>.plist # Linux systemctl --user restart claway-gateway-<profile>.service ``` ### Health check ```bash claway doctor # default profile claway -p <profile> doctor # one profile ``` --- <!-- source: website/docs/user-guide/profile-distributions.md --> # user-guide/profile-distributions.md # Profile Distributions: Share a Whole Agent A **profile distribution** packages a complete Claway agent — personality, skills, cron jobs, MCP connections, config — as a git repository. Anyone with access to the repo can install the whole agent with one command, update it in place, and keep their own memories, sessions, and API keys untouched. If a [profile](./profiles.md) is a local agent, a distribution is that agent made shareable. ## What this means Before distributions, sharing a Claway agent meant sending someone: 1. Your SOUL.md 2. A list of skills to install 3. Your config.yaml, minus the secrets 4. A description of which MCP servers you wired up 5. Any cron jobs you scheduled 6. Instructions for which env vars to set …and hoping they assembled it correctly. Every version bump or bug fix meant repeating the handoff. With distributions, all of that lives in one git repo: ``` my-research-agent/ ├── distribution.yaml # manifest: name, version, env-var requirements ├── SOUL.md # the agent's personality / system prompt ├── config.yaml # model, temperature, reasoning, tool defaults ├── skills/ # bundled skills that come with the agent ├── cron/ # scheduled tasks the agent runs └── mcp.json # MCP servers the agent connects to ``` Recipients run: ```bash claway profile install github.com/you/my-research-agent --alias ``` …and they now have the whole agent. They fill in their own API keys (`.env.EXAMPLE` → `.env`), and they can run `my-research-agent chat` or address it through Telegram / Discord / Slack / any gateway platform. When you push a new version, they run `claway profile update my-research-agent` and pull your changes — their memories and sessions stay put. ## Why git? We considered tarballs, HTTP archives, a custom format. None of them beat git: - **Zero build step for authors.** Push to GitHub; consumers install. There's no "pack this, upload that, update the index" loop. - **Tags, branches, and commits are already the versioning system.** A tag push does for us what "pack + upload a release" does for other tools. - **Updates are a fetch.** Not a re-download of the whole archive. - **Transparent.** Users can browse the repo, read diffs between versions, open issues against it, fork it to customize. - **Private repos work for free.** SSH keys, `git credential` helpers, GitHub CLI stored credentials — whatever auth your terminal is already set up for applies transparently. - **Reproducibility is a commit SHA.** The same thing pip and npm record. The tradeoff: recipients need git installed. On any machine running Claway in 2026, that's already true. ## When should you use a distribution? Good fits: - **You're sharing a specialized agent** — a compliance monitor, a code reviewer, a research assistant, a customer-support bot — with a team or with the community. - **You're deploying the same agent to multiple machines** and don't want to copy files manually each time. - **You're iterating on an agent** and want recipients to pick up new versions with one command. - **You're building an agent as a product** — opinionated defaults, curated skills, tuned prompts — that other people should use as a starting point. Not a fit: - **You just want to back up a profile on your own machine.** Use [`claway profile export` / `import`](../reference/profile-commands.md#claway-profile-export) — that's what those are for. - **You want to share API keys alongside the agent.** `auth.json` and `.env` are deliberately excluded from distributions. Each installer brings their own credentials. - **You want to share memories / sessions / conversation history.** Those are user data, not distribution content. Never shipped. :::caution **Claway does not control git.** The file exclusions described on this page are applied by the **installer** when someone runs `claway profile install` or `claway profile update`. They are **not** applied when you run `git add` or `git commit`. ::: ## The lifecycle: author to installer to update Below is the full end-to-end flow. Pick the side you care about. --- ## For authors: publishing a distribution ### Step 1 — Start from a working profile Build and refine the agent like any other profile: ```bash claway profile create research-bot research-bot setup # configure model, API keys # Edit ~/.claway/profiles/research-bot/SOUL.md # Install skills, wire up MCP servers, schedule cron jobs, etc. research-bot chat # dogfood until it feels right ``` ### Step 2 — Add a `distribution.yaml` Create `~/.claway/profiles/research-bot/distribution.yaml`: ```yaml name: research-bot version: 1.0.0 description: "Autonomous research assistant with arXiv and web tools" claway_requires: ">=0.12.0" author: "Your Name" license: "MIT" # Tell installers which env vars the agent needs. These are checked against # the installer's shell and existing .env file so they don't get nagged # about keys they already have configured. env_requires: - name: OPENAI_API_KEY description: "OpenAI API key (for model access)" required: true - name: SERPAPI_KEY description: "SerpAPI key for web search" required: false default: "" ``` That's the whole manifest. Every field except `name` has a sensible default. ### Step 3 — Create a `.gitignore` before the first commit :::warning Do this **before** running `git init` or `git add`. If you have already chatted with the profile, run setup, or otherwise used it, the directory now contains files you must not ship: `.env`, `auth.json`, `memories/`, `sessions/`, `state.db*`, `logs/`, and more. ::: Create `~/.claway/profiles/research-bot/.gitignore` with at minimum: ```gitignore # Credentials & secrets — NEVER commit auth.json .env .env.EXAMPLE # generated by install, not authorship domain # Runtime databases & state state.db state.db-shm state.db-wal claway_state.db response_store.db response_store.db-shm response_store.db-wal gateway.pid gateway_state.json processes.json auth.lock active_profile .update_check # User data — NEVER commit memories/ sessions/ logs/ plans/ workspace/ home/ # Caches & generated artifacts image_cache/ audio_cache/ document_cache/ browser_screenshots/ cache/ # Infrastructure (should not be in profile dir, but safe to exclude) claway/ .worktrees/ profiles/ bin/ node_modules/ # User customization namespace — your local overrides local/ # Checkpoints & backups (can be huge) checkpoints/ sandboxes/ backups/ # Logs errors.log .claway_history ``` This mirrors the [hard-excluded paths](#whats-not-in-a-distribution-ever) that the installer strips on its end. Anything else you want to keep out of the repo (scratch files, large assets, local-only skills) should also go in here. ### Step 4 — Push to a git repo ```bash cd ~/.claway/profiles/research-bot git init git add . git commit -m "v1.0.0" git remote add origin git@github.com:you/research-bot.git git tag v1.0.0 git push -u origin main --tags ``` The repo is now a distribution. Anyone with access can install it. :::note The installer will additionally strip the [hard-excluded paths](#whats-not-in-a-distribution-ever) even if an author somehow ships them — but that only protects installers, not the author. ::: ### Step 5 — Tag versioned releases Every time the agent reaches a stable point, bump the version and tag: ```bash # Edit distribution.yaml: version: 1.1.0 git add distribution.yaml SOUL.md skills/ git commit -m "v1.1.0: tighter research SOUL, add arxiv skill" git tag v1.1.0 git push --tags ``` Recipients who run `claway profile update research-bot` will pull the latest. ### What the repo looks like A complete authored distribution: ``` research-bot/ ├── .gitignore # excludes secrets & user data (see Step 3) ├── distribution.yaml # required ├── SOUL.md # strongly recommended ├── config.yaml # model, provider, tool defaults ├── mcp.json # MCP server connections ├── skills/ │ ├── arxiv-search/SKILL.md │ ├── paper-summarization/SKILL.md │ └── citation-lookup/SKILL.md ├── cron/ │ └── weekly-digest.json # scheduled tasks └── README.md # human-facing description (optional) ``` ### Distribution-owned vs user-owned When an installer updates to a new version, some things get replaced (author's domain) and some things stay put (installer's domain). Defaults: | Category | Paths | On update | |---|---|---| | **Distribution-owned** | `SOUL.md`, `config.yaml`, `mcp.json`, `skills/`, `cron/`, `distribution.yaml` | Replaced from the new clone | | **Config override** | `config.yaml` | Actually preserved by default — the installer may have tuned model or provider. Pass `--force-config` on update to reset. | | **User-owned** | `memories/`, `sessions/`, `state.db*`, `auth.json`, `.env`, `logs/`, `workspace/`, `plans/`, `home/`, `*_cache/`, `local/` | Never touched | You can override the distribution-owned list in the manifest: ```yaml distribution_owned: - SOUL.md - skills/research/ # only my research skills; other installed skills stay - cron/digest.json ``` When omitted, the defaults above apply — which is what most distributions want. --- ## For installers: using a distribution ### Install ```bash claway profile install github.com/you/research-bot --alias ``` What happens: 1. Clones the repo into a temporary directory. 2. Reads `distribution.yaml`, shows you the manifest (name, version, description, author, required env vars). 3. Checks each required env var against your shell environment and the target profile's existing `.env`. Marks each as `✓ set` or `needs setting` so you know exactly what to configure. 4. Asks for confirmation. Pass `-y` / `--yes` to skip. 5. Copies distribution-owned files into `~/.claway/profiles/research-bot/` (or wherever the manifest's `name` resolves). The [hard-excluded paths](#whats-not-in-a-distribution-ever) are stripped during this copy, even if the author accidentally left them in the repo. 6. Writes `.env.EXAMPLE` with the required keys commented out — copy to `.env` and fill in. 7. With `--alias`, creates a wrapper so you can run `research-bot chat` directly. ### Source types Any git URL works: ```bash # GitHub shorthand claway profile install github.com/you/research-bot # Full HTTPS claway profile install https://github.com/you/research-bot.git # SSH claway profile install git@github.com:you/research-bot.git # Self-hosted, GitLab, Gitea, Forgejo — any Git host claway profile install https://git.example.com/team/research-bot.git # Private repo using your configured git auth claway profile install git@github.com:your-org/internal-bot.git # Local directory during development (no git push needed) claway profile install ~/my-profile-in-progress/ ``` ### Override the profile name Two users wanting the same distribution under different profile names: ```bash # Alice claway profile install github.com/acme/support-bot --name support-us --alias # Bob (same distribution, different local name) claway profile install github.com/acme/support-bot --name support-eu --alias ``` ### Fill in env vars After install, the agent's profile contains a `.env.EXAMPLE`: ``` # Environment variables required by this Claway distribution. # Copy to `.env` and fill in your own values before running. # OpenAI API key (for model access) # (required) OPENAI_API_KEY= # SerpAPI key for web search # (optional) # SERPAPI_KEY= ``` Copy it: ```bash cp ~/.claway/profiles/research-bot/.env.EXAMPLE ~/.claway/profiles/research-bot/.env # Edit .env, paste your real keys ``` Required keys that were already in your shell environment (e.g. `OPENAI_API_KEY` exported in your `~/.zshrc`) are marked `✓ set` during install — you don't need to duplicate them in `.env`. ### Check what you installed ```bash claway profile info research-bot ``` Shows: ``` Distribution: research-bot Version: 1.0.0 Description: Autonomous research assistant with arXiv and web tools Author: Your Name Requires: Claway >=0.12.0 Source: https://github.com/you/research-bot Installed: 2026-05-08T17:04:32+00:00 Environment variables: OPENAI_API_KEY (required) — OpenAI API key (for model access) SERPAPI_KEY (optional) — SerpAPI key for web search ``` `claway profile list` also shows a `Distribution` column so at a glance you can see which of your profiles came from repos and which you hand-built: ``` Profile Model Gateway Alias Distribution ─────────────── ─────────────────────────── ─────────── ─────────── ──────────────────── ◆default claude-sonnet-4 stopped — — coder gpt-5 stopped coder — research-bot claude-opus-4 stopped research-bot research-bot@1.0.0 telemetry claude-sonnet-4 running telemetry telemetry@2.3.1 ``` ### Update ```bash claway profile update research-bot ``` What happens: 1. Re-clones the repo from the recorded source URL. 2. Replaces distribution-owned files (SOUL, skills, cron, mcp.json). 3. **Preserves** your `config.yaml` — you may have tuned the model, temperature, or other settings. Pass `--force-config` to overwrite. 4. **Never touches** user data: memories, sessions, auth, `.env`, logs, state. No re-downloading the whole archive. No stomping your local changes to config. No deleting your conversation history. ### Remove ```bash claway profile delete research-bot ``` The delete prompt surfaces distribution info before asking you to confirm: ``` Profile: research-bot Path: ~/.claway/profiles/research-bot Model: claude-opus-4 (anthropic) Skills: 12 Distribution: research-bot@1.0.0 Installed from: https://github.com/you/research-bot This will permanently delete: • All config, API keys, memories, sessions, skills, cron jobs • Command alias (~/.local/bin/research-bot) Type 'research-bot' to confirm: ``` So you never accidentally delete an agent without knowing where it came from or being able to re-install it. --- ## Use cases and patterns ### Personal: sync one agent across machines You built a research assistant on your laptop. You want the same agent on your workstation. ```bash # Laptop — create .gitignore first (see "For authors" Step 3), then: cd ~/.claway/profiles/research-bot git init && git add . && git status # confirm no secrets staged git commit -m "initial" git remote add origin git@github.com:you/research-bot.git git push -u origin main # Workstation claway profile install github.com/you/research-bot --alias # Fill in .env. Done. ``` Any iteration on the laptop (`git commit && push`) pulls onto the workstation with `claway profile update research-bot`. Memories stay per-machine — the laptop remembers its own conversations, the workstation remembers its own, they don't collide. ### Team: ship a reviewed internal agent Your engineering team wants a shared PR-review bot with a specific SOUL, specific skills, and a cron that runs every PR through it. ```bash # Engineering lead — create .gitignore first (see "For authors" Step 3), then: cd ~/.claway/profiles/pr-reviewer # ... build and tune ... git init && git add . && git status # confirm no secrets staged git commit -m "v1.0 PR reviewer" git tag v1.0.0 git push -u origin main --tags # push to your company's internal Git host # Each engineer claway profile install git@github.com:your-org/pr-reviewer.git --alias # Fill in .env with their own API key (billed to them), .env.EXAMPLE points at what's required pr-reviewer chat ``` When the lead ships v1.1 (better SOUL, new skill), engineers run `claway profile update pr-reviewer` and everyone's on the new version within minutes. ### Community: publish a public agent You built something novel — maybe a "Polymarket trader" or an "academic paper summarizer" or a "Minecraft server ops assistant." You want to share it. ```bash # You — create .gitignore first (see "For authors" Step 3), then: cd ~/.claway/profiles/polymarket-trader # Write a solid README.md at the repo root — GitHub shows it on the repo page git init && git add . && git status # confirm no secrets staged git commit -m "v1.0" git tag v1.0.0 # Publish to a public GitHub repo git remote add origin https://github.com/you/claway-polymarket-trader.git git push -u origin main --tags # Anyone claway profile install github.com/you/claway-polymarket-trader --alias ``` Tweet the install command. People who try it send you issues and PRs. If someone wants to customize, they fork — same git workflow everyone already knows. ### Product: ship an opinionated agent You built Claway-on-top — maybe a compliance-monitoring harness, a customer-support stack, a domain-specific research platform. You want to distribute it as a product. ```yaml # distribution.yaml name: telemetry-harness version: 2.3.1 description: "Compliance telemetry harness — monitors and reviews regulated workflows" claway_requires: ">=0.13.0" author: "Acme Compliance Inc." license: "Commercial" env_requires: - name: ACME_API_KEY description: "Your Acme Compliance license key (email support@acme.com)" required: true - name: OPENAI_API_KEY description: "OpenAI API key for model access" required: true - name: GRAPHITI_MCP_URL description: "URL for your Graphiti knowledge graph instance" required: false default: "http://127.0.0.1:8000/sse" ``` Your customers install via a single command; the install preview tells them exactly which keys to have ready; updates roll out the moment you tag a new release; their compliance data (`memories/`, `sessions/`) never leaves their machine. ### Ephemeral: one-off scripts on shared infra You're the ops lead. You want a temporary agent that diagnoses a production incident — a canned SOUL with the right tools and MCP connections — and runs on three on-call engineers' laptops for the next week. ```bash # You — create .gitignore first (see "For authors" Step 3), then: # Build the profile, commit, push a private repo git push -u origin main # Each on-call claway profile install git@github.com:your-org/incident-2026-q2.git --alias # Incident resolved — tear it down claway profile delete incident-2026-q2 ``` The install-delete cycle is cheap enough to be disposable. --- ## Recipes ### Pin to a specific version :::note Git ref pinning (`#v1.2.0`) is planned but not in the initial release — install currently tracks the default branch. Track your installed version via `claway profile info <name>` and hold off on updates until you're ready. ::: ### Check what version you're on vs. latest ```bash # Your installed version claway profile info research-bot | grep Version # Latest upstream (without installing) git ls-remote --tags https://github.com/you/research-bot | tail -5 ``` ### Keep local config customizations through updates The default update behavior already does this: `config.yaml` is preserved. To be safe, write your local tweaks to a file the distribution doesn't own: ```yaml # ~/.claway/profiles/research-bot/local/my-overrides.yaml # (distribution never touches local/) ``` …and reference it from `config.yaml` or your SOUL as needed. ### Force a clean re-install ```bash # Nuke and re-install from scratch (loses memories/sessions too) claway profile delete research-bot --yes claway profile install github.com/you/research-bot --alias # Update to current main but reset config.yaml to the distribution's default claway profile update research-bot --force-config --yes ``` ### Fork and customize The standard git workflow — distributions are just repos: ```bash # Fork the repo on GitHub, then install your fork claway profile install github.com/yourname/forked-research-bot --alias # Iterate locally in ~/.claway/profiles/forked-research-bot/ # Edit SOUL.md, commit, push to your fork # Upstream changes: pull them into your fork the usual way ``` ### Test a distribution before pushing From the author's machine: ```bash # Install from a local directory (no git push needed) claway profile install ~/.claway/profiles/research-bot --name research-bot-test --alias # Tweak, delete, re-install until it's right claway profile delete research-bot-test --yes claway profile install ~/.claway/profiles/research-bot --name research-bot-test ``` --- ## What's NOT in a distribution (ever) The installer hard-excludes these paths even if an author accidentally ships them. No config option lets you override this — the safety guard is a regression-tested invariant: - `auth.json` — OAuth tokens, platform credentials - `.env` — API keys, secrets - `memories/` — conversation memory - `sessions/` — conversation history - `state.db`, `state.db-shm`, `state.db-wal` — session metadata - `logs/` — agent and error logs - `workspace/` — generated working files - `plans/` — scratch plans - `home/` — user's home mount in Docker backends - `*_cache/` — image / audio / document caches - `local/` — user-reserved customization namespace When you clone a distribution as an installer, these simply aren't copied into your profile directory. When you update, your copies stay put. If you installed the same distribution on five machines, you have five isolated sets of this data — one per machine. :::caution This exclusion runs at **install / update time on the installer's machine**. It does **not** prevent an author from commiting sensitive/unnecessary files. Authors must use a [`.gitignore`](#step-3--create-a-gitignore-before-the-first-commit) to keep secrets out of the repo. ::: ## Security and trust Profile distributions are unsigned by default. You're trusting: - **The git host** (GitHub / GitLab / wherever) to serve the bytes the author pushed. - **The author** to not ship a malicious SOUL, skills, or cron jobs. Cron jobs from a distribution are **not auto-scheduled** — the installer prints `claway -p <name> cron list` and you enable them explicitly. SOUL.md and skills ARE active as soon as you start chatting with the profile, so read them before your first run if you're installing from someone you don't know. Rough analogy: installing a distribution is like installing a browser extension or a VS Code extension. Low friction, high power, trust the source. For internal company distributions, use a private repo and your normal git auth — nothing new to configure. Future versions may add signing, a lockfile (`.distribution-lock.yaml`) with a resolved commit SHA, and a `--dry-run` flag that prints the diff before applying an update. None of those are shipping yet. ## Under the hood For implementation details, precise CLI behavior, and all flags, see the [Profile Commands reference](../reference/profile-commands.md#distribution-commands). The short version: - `install`, `update`, `info` live inside `claway profile` — not a parallel command tree. - The manifest format is YAML with a tiny required schema (`name` only). - The installer uses your local `git` binary for cloning, so any auth your shell already handles (SSH keys, credential helpers) works transparently. - After clone, `.git/` is stripped — the installed profile isn't itself a git checkout, avoiding "oh my, I accidentally committed my `.env` to the distribution's git history" traps. - Reserved profile names (`claway`, `test`, `tmp`, `root`, `sudo`) are rejected at install time to avoid collisions with common binaries. ## See also - [Profiles: Running Multiple Agents](./profiles.md) — the base concept - [Profile Commands reference](../reference/profile-commands.md) — every flag, every option - [`claway profile export` / `import`](../reference/profile-commands.md#claway-profile-export) — local backup / restore (not distribution) - [Using SOUL with Claway](../guides/use-soul-with-claway.md) — authoring personalities - [Personality & SOUL](./features/personality.md) — how SOUL fits into the agent - [Skills catalog](../reference/skills-catalog.md) — skills you can bundle --- <!-- source: website/docs/user-guide/secrets/bitwarden.md --> # user-guide/secrets/bitwarden.md # Bitwarden Secrets Manager Pull API keys from [Bitwarden Secrets Manager](https://bitwarden.com/products/secrets-manager/) at process startup instead of storing them in plaintext inside `~/.claway/.env`. One bootstrap secret (a machine-account access token) replaces N per-provider keys, and rotating a credential becomes a single change in the Bitwarden web app. ## How it works 1. You create a **machine account** in Bitwarden Secrets Manager, give it read access to a project, and generate an **access token**. 2. Claway stores that single token in `~/.claway/.env` as `BWS_ACCESS_TOKEN`. 3. Every time `claway` (or the gateway, or a cron job) starts, after `~/.claway/.env` has loaded, Claway calls `bws secret list <project_id>` and sets the returned keys into `os.environ`. 4. By default Claway **overrides** values already in your environment, so Bitwarden is the source of truth — rotate a key once in the web app and every Claway process picks it up on next start. Flip `override_existing: false` in config if you want `.env` to win instead. The `bws` binary is auto-downloaded into `~/.claway/bin/` on first use — no `apt`, no `brew`, no `sudo`. ## Why machine accounts (and why no 2FA prompt) Bitwarden Secrets Manager is designed for non-interactive workloads: machine accounts can't be 2FA-gated because there's no human in the loop. The access token is the credential. Anyone with it can read every secret the machine account has access to, so treat it like a high-value bearer token — store it in `.env` (not `config.yaml`), and revoke + regenerate from the Bitwarden web app if it ever leaks. You set up the machine account *in the web app*, where your normal 2FA applies. After that the token is autonomous. ## Setup ### 1. Create a machine account and access token In the [Bitwarden web app](https://vault.bitwarden.com) (or [vault.bitwarden.eu](https://vault.bitwarden.eu) for EU accounts): 1. Switch to **Secrets Manager** from the product switcher. 2. Create or pick a **Project** (e.g. "Claway keys"). 3. Add your provider keys as secrets. The secret **Name** becomes the environment variable name — use `OPENROUTER_API_KEY`, `ANTHROPIC_API_KEY`, etc. 4. **Machine accounts → New machine account → My Claway machine** → **Projects** tab → grant Read access to your project. 5. **Access tokens** tab → **Create access token** → **Never** expires (or pick a date) → copy the token (starts with `0.`). Bitwarden cannot retrieve it again — keep the copy. Secrets Manager is included on the Bitwarden free tier with limits; no paid plan needed to try this. ### 2. Run the wizard ```bash claway secrets bitwarden setup ``` It will: 1. Download and verify `bws v2.0.0` into `~/.claway/bin/bws`. 2. Prompt you for the access token (input is hidden). Stored in `~/.claway/.env` as `BWS_ACCESS_TOKEN`. 3. Ask which Bitwarden region your machine account belongs to — **US Cloud**, **EU Cloud**, or **self-hosted / custom URL**. Stored in `config.yaml` as `secrets.bitwarden.server_url` and passed to `bws` as `BWS_SERVER_URL`. 4. List the projects the machine account can see; pick one. Stored in `config.yaml` as `secrets.bitwarden.project_id`. 5. Test-fetch the project's secrets and show you which env vars will resolve. 6. Flip `secrets.bitwarden.enabled: true`. Non-interactive setup is also supported via flags: ```bash claway secrets bitwarden setup \ --access-token "$BWS_ACCESS_TOKEN" \ --server-url https://vault.bitwarden.eu \ --project-id <project-uuid> ``` ### 3. Confirm ```bash claway secrets bitwarden status ``` From now on, every `claway` invocation pulls fresh secrets at startup. You'll see a one-line summary in stderr the first time secrets are applied in a process. ## CLI | Command | What it does | |---|---| | `claway secrets bitwarden setup` | Interactive wizard (install binary, prompt for token, pick project, test fetch) | | `claway secrets bitwarden status` | Show config + binary version + token presence | | `claway secrets bitwarden sync` | Dry-run: pull secrets now and show what would be applied | | `claway secrets bitwarden sync --apply` | Pull and export into the current shell's environment | | `claway secrets bitwarden install` | Just download the pinned `bws` binary (no auth required) | | `claway secrets bitwarden disable` | Flip `enabled: false`; leaves token + project id in place | ## Configuration Defaults in `~/.claway/config.yaml`: ```yaml secrets: bitwarden: enabled: false access_token_env: BWS_ACCESS_TOKEN project_id: "" server_url: "" cache_ttl_seconds: 300 override_existing: true auto_install: true ``` | Key | Default | What it does | |---|---|---| | `enabled` | `false` | Master switch. When false, Bitwarden is never contacted. | | `access_token_env` | `BWS_ACCESS_TOKEN` | Env var name that holds the bootstrap token. Change this if you already use `BWS_ACCESS_TOKEN` for something else. | | `project_id` | `""` | UUID of the project to sync from. | | `server_url` | `""` | Bitwarden region or self-hosted endpoint. Empty = `bws` default (US Cloud, `https://vault.bitwarden.com`). Set to `https://vault.bitwarden.eu` for EU Cloud, or your own URL for self-hosted. Plumbed into the `bws` subprocess as `BWS_SERVER_URL`. | | `cache_ttl_seconds` | `300` | How long an in-process fetch result is reused. Set to `0` to disable caching. Cache is per-process; new `claway` invocations start fresh. | | `override_existing` | `true` | When true, Bitwarden values overwrite anything already in env (so rotation in the web app actually takes effect). Flip to `false` if you want `.env` / shell exports to win locally. | | `auto_install` | `true` | When true, `bws` is auto-downloaded into `~/.claway/bin/` on first use. | ## Failure modes Bitwarden never blocks Claway startup. If anything goes wrong, you'll see a one-line warning in stderr and Claway continues with whatever credentials `.env` already had: | Symptom | Cause | Fix | |---|---|---| | `BWS_ACCESS_TOKEN is not set` | Enabled in config but token cleared from `.env` | Re-run `claway secrets bitwarden setup` | | `bws exited 1: invalid access token` | Token revoked or wrong | Generate a new token, re-run setup | | `[400 Bad Request] {"error":"invalid_client"}` | Token is for a Bitwarden region other than the one `bws` is calling (e.g. EU token hitting the US identity endpoint) | Re-run setup and pick the right region, or set `secrets.bitwarden.server_url` to `https://vault.bitwarden.eu` (or your self-hosted URL) | | `bws timed out` | Network blocked or Bitwarden API slow | Check connectivity to `api.bitwarden.com` (or your `server_url`) | | `bws binary not available` | `auto_install: false` and `bws` not on PATH | Install manually from [github.com/bitwarden/sdk-sm/releases](https://github.com/bitwarden/sdk-sm/releases) or flip `auto_install` back on | | `Checksum mismatch` | Download corrupted or tampered | Re-run, will retry; if it persists, file an issue | ## Security notes - The bootstrap token (`BWS_ACCESS_TOKEN`) is itself sensitive — anyone with it can read every secret the machine account has access to. Treat it the same as any other API key. - Claway will refuse to let Bitwarden overwrite the bootstrap token itself, even with `override_existing: true`. If you store `BWS_ACCESS_TOKEN` as a secret inside the project, it's silently skipped during apply. - The `bws` binary download is verified against the published SHA-256 checksum from the same GitHub release. Mismatch aborts the install. - The pinned version (`bws v2.0.0` at time of writing) is updated through PRs to this repo — Claway does not auto-upgrade `bws` to "latest" because upstream release shapes can change. ## When NOT to use this - **Single-machine personal setups** where `~/.claway/.env` is fine. You're trading one credential for another and adding a network dependency at startup. - **Air-gapped environments** that can't reach `api.bitwarden.com`. - **CI/CD** where the existing secrets-injection mechanism (GitHub Actions secrets, Vault, etc.) is already set up — pick one path, not two. The good case for this is multi-machine fleets, shared dev boxes, gateway VPSes, or any setup where you want centralized rotation and revocation across multiple Claway installations. --- <!-- source: website/docs/user-guide/secrets/index.md --> # user-guide/secrets/index.md # Secrets Claway can pull API keys from external secret managers at process startup instead of storing them in `~/.claway/.env`. The bootstrap token for the secret manager lives in `.env`; every other provider key (OpenAI, Anthropic, OpenRouter, etc.) can stay in the manager and rotate centrally. Supported: - [Bitwarden Secrets Manager](./bitwarden) — `bws` CLI, lazy-installed, free tier works. More backends (Vault, AWS Secrets Manager, 1Password CLI) are easy to add behind the same interface — the lift is one module in `agent/secret_sources/` and one CLI handler. File a request if you have a specific one in mind. --- <!-- source: website/docs/user-guide/skills/google-workspace.md --> # Google Workspace — Gmail, Calendar, Drive, Sheets & Docs # Google Workspace Skill Gmail, Calendar, Drive, Contacts, Sheets, and Docs integration for Claway. Uses OAuth2 with automatic token refresh. Prefers the [Google Workspace CLI (`gws`)](https://github.com/googleworkspace/cli) when available for broader coverage, and falls back to Google's Python client libraries otherwise. **Skill path:** `skills/productivity/google-workspace/` ## Setup The setup is fully agent-driven — ask Claway to set up Google Workspace and it walks you through each step. The flow: 1. **Create a Google Cloud project** and enable the required APIs (Gmail, Calendar, Drive, Sheets, Docs, People) 2. **Create OAuth 2.0 credentials** (Desktop app type) and download the client secret JSON 3. **Authorize** — Claway generates an auth URL, you approve in the browser, paste back the redirect URL 4. **Done** — token auto-refreshes from that point on :::tip Email-only users If you only need email (no Calendar/Drive/Sheets), use the **himalaya** skill instead — it works with a Gmail App Password and takes 2 minutes. No Google Cloud project needed. ::: ## Gmail ### Searching ```bash $GAPI gmail search "is:unread" --max 10 $GAPI gmail search "from:boss@company.com newer_than:1d" $GAPI gmail search "has:attachment filename:pdf newer_than:7d" ``` Returns JSON with `id`, `from`, `subject`, `date`, `snippet`, and `labels` for each message. ### Reading ```bash $GAPI gmail get MESSAGE_ID ``` Returns the full message body as text (prefers plain text, falls back to HTML). ### Sending ```bash # Basic send $GAPI gmail send --to user@example.com --subject "Hello" --body "Message text" # HTML email $GAPI gmail send --to user@example.com --subject "Report" \ --body "<h1>Q4 Results</h1><p>Details here</p>" --html # Custom From header (display name + email) $GAPI gmail send --to user@example.com --subject "Hello" \ --from '"Research Agent" <user@example.com>' --body "Message text" # With CC $GAPI gmail send --to user@example.com --cc "team@example.com" \ --subject "Update" --body "FYI" ``` ### Custom From Header The `--from` flag lets you customize the sender display name on outgoing emails. This is useful when multiple agents share the same Gmail account but you want recipients to see different names: ```bash # Agent 1 $GAPI gmail send --to client@co.com --subject "Research Summary" \ --from '"Research Agent" <shared@company.com>' --body "..." # Agent 2 $GAPI gmail send --to client@co.com --subject "Code Review" \ --from '"Code Assistant" <shared@company.com>' --body "..." ``` **How it works:** The `--from` value is set as the RFC 5322 `From` header on the MIME message. Gmail allows customizing the display name on your own authenticated email address without any additional configuration. Recipients see the custom display name (e.g. "Research Agent") while the email address stays the same. **Important:** If you use a *different email address* in `--from` (not the authenticated account), Gmail requires that address to be configured as a [Send As alias](https://support.google.com/mail/answer/22370) in Gmail Settings → Accounts → Send mail as. The `--from` flag works on both `send` and `reply`: ```bash $GAPI gmail reply MESSAGE_ID \ --from '"Support Bot" <shared@company.com>' --body "We're on it" ``` ### Replying ```bash $GAPI gmail reply MESSAGE_ID --body "Thanks, that works for me." ``` Automatically threads the reply (sets `In-Reply-To` and `References` headers) and uses the original message's thread ID. ### Labels ```bash # List all labels $GAPI gmail labels # Add/remove labels $GAPI gmail modify MESSAGE_ID --add-labels LABEL_ID $GAPI gmail modify MESSAGE_ID --remove-labels UNREAD ``` ## Calendar ```bash # List events (defaults to next 7 days) $GAPI calendar list $GAPI calendar list --start 2026-03-01T00:00:00Z --end 2026-03-07T23:59:59Z # Create event (timezone required) $GAPI calendar create --summary "Team Standup" \ --start 2026-03-01T10:00:00-07:00 --end 2026-03-01T10:30:00-07:00 # With location and attendees $GAPI calendar create --summary "Lunch" \ --start 2026-03-01T12:00:00Z --end 2026-03-01T13:00:00Z \ --location "Cafe" --attendees "alice@co.com,bob@co.com" # Delete event $GAPI calendar delete EVENT_ID ``` :::warning Calendar times **must** include a timezone offset (e.g. `-07:00`) or use UTC (`Z`). Bare datetimes like `2026-03-01T10:00:00` are ambiguous and will be treated as UTC. ::: ## Drive ```bash $GAPI drive search "quarterly report" --max 10 $GAPI drive search "mimeType='application/pdf'" --raw-query --max 5 ``` ## Sheets ```bash # Read a range $GAPI sheets get SHEET_ID "Sheet1!A1:D10" # Write to a range $GAPI sheets update SHEET_ID "Sheet1!A1:B2" --values '[["Name","Score"],["Alice","95"]]' # Append rows $GAPI sheets append SHEET_ID "Sheet1!A:C" --values '[["new","row","data"]]' ``` ## Docs ```bash $GAPI docs get DOC_ID ``` Returns the document title and full text content. ## Contacts ```bash $GAPI contacts list --max 20 ``` ## Output Format All commands return JSON. Key fields per service: | Command | Fields | |---------|--------| | `gmail search` | `id`, `threadId`, `from`, `to`, `subject`, `date`, `snippet`, `labels` | | `gmail get` | `id`, `threadId`, `from`, `to`, `subject`, `date`, `labels`, `body` | | `gmail send/reply` | `status`, `id`, `threadId` | | `calendar list` | `id`, `summary`, `start`, `end`, `location`, `description`, `htmlLink` | | `calendar create` | `status`, `id`, `summary`, `htmlLink` | | `drive search` | `id`, `name`, `mimeType`, `modifiedTime`, `webViewLink` | | `contacts list` | `name`, `emails`, `phones` | | `sheets get` | 2D array of cell values | ## Troubleshooting | Problem | Fix | |---------|-----| | `NOT_AUTHENTICATED` | Run setup (ask Claway to set up Google Workspace) | | `REFRESH_FAILED` | Token revoked — re-run authorization steps | | `HttpError 403: Insufficient Permission` | Missing scope — revoke and re-authorize with the right services | | `HttpError 403: Access Not Configured` | API not enabled in Google Cloud Console | | `ModuleNotFoundError` | Run setup script with `--install-deps` | ---