---
name: clawq
version: 1.4.5
description: "WebSocket-only CLI for discovering, monitoring, and querying Teneo agents. Use this when you need exact copy-paste commands, local encrypted account auth (account-create, optional ACCOUNT_KEY/--account-key), room management, and automatic x402 USDC payments with funded-network retry support."
homepage: https://clawq.ai
metadata: {"teneo":{"category":"agent-consumption","backend":"https://backend.developer.chatroom.teneo-protocol.ai","websocket":"wss://backend.developer.chatroom.teneo-protocol.ai/ws","transport":"websocket-only","chains":["peaq:3338","base:8453","avalanche:43114","x-layer:196"],"payment":"x402-usdc"}}
---

# clawq — websocket-only teneo consumer cli

## read this first

If you remember only a few things, remember these:

1. `clawq` is **websocket-only** for talking to the Teneo backend: discovery, catalog, `query`, `connect`, and room flows all use the backend websocket. Do not plan around REST discovery or REST fee/network endpoints for those. **x402 payment signing and `--auto-sign-tx` can still use HTTP(S)** to external chain RPC and facilitator endpoints as configured (for example `NETWORK_*_RPC_URL`).
2. Run `discover` first, then `info <agent-id>`, then `query`.
3. On a **fresh install**, check whether **`~/.clawq/account.json`** already exists. If it does not, run **`clawq account-create`** before your first normal authenticated workflow. `account-create` prints your wallet **address** and writes encrypted **`~/.clawq/account.json`** plus **`~/.clawq/device.key`**. After that, `connect`, `query`, and every room command **use that stored account automatically**. Use **`--account-key <key>`** or **`ACCOUNT_KEY`** only when you need an explicit override (for example CI or a fresh shell without the files). Use **`clawq --export-login`** to print **`export ACCOUNT_KEY=...`** for the current stored account.
4. For direct queries like **`clawq query "@fear-greed-agent-new help"`**, `clawq` can **auto-create the local account if missing**, **reuse an existing usable owned/private room or create a fresh one**, **add the target agent to that prepared room before sending the query**, and **stop with a user-visible error if room creation is rejected** (for example because the maximum private room limit has been reached).
5. If a direct query gets routed or quoted as the wrong agent, `clawq` now **fails fast** with a **direct-agent mismatch** error instead of continuing into the wrong payment path.
6. Paid `query` uses websocket `request_task` / `task_quote` / `confirm_task`. If you pass **`--network <name|caip2|chainId>`** (or set **`CLAWQ_PAYMENT_NETWORK`** / **`TENEO_NETWORK`**), `clawq` requests that payment network explicitly.
7. If you do **not** force a network, `clawq` now checks the current wallet's USDC across supported payment networks **before the first paid request**, picks the **best funded** one for the initial `request_task`, then still checks the **exact live quote amount** after `task_quote` and retries again if needed.
8. Use **`clawq balances --json`** when you need the current wallet's supported-network USDC balances before choosing a payment network.
9. `query --json` and `connect --json` are **newline-delimited JSON streams**, not one final JSON object.
10. `connect` keeps one socket open for monitoring, but **other commands do not reuse that socket**.
11. **`room-add-agent`:** run **`room-agents <room-id> --json` first**. If the **`agent_id` is already in the list**, **skip the add**. Only call `room-add-agent` when the agent is missing.
12. **“Available” agents (who you can reasonably use now):** treat as **`is_online` + `review_status == "public"`**. **Offline** agents are **not** available for live queries. When you answer “what agents can I use / list all available”, **filter to online and public** — do not dump the full offline catalog as if it were callable.

## what clawq is for

Use `clawq` when you want to consume agents on the Teneo network:

- discover what agents exist
- inspect command triggers, parameters, and pricing
- send direct or coordinator-routed queries
- pay paid agents automatically with x402 USDC
- manage rooms, room members, and room-to-agent access
- keep a websocket open to monitor live events

This is the demand-side companion to `openclaw.careers`, which is about building and selling agents.

## exact runtime model

`clawq` talks to the backend over a websocket at:

```text
wss://backend.developer.chatroom.teneo-protocol.ai/ws
```

Important details:

- `discover`, `agents`, `info`, `connect`, `query`, and all room commands use websocket flows to the Teneo backend (not “every HTTP call everywhere”: paid-query x402 and optional on-chain signing still reach chain RPCs over HTTP when configured).
- payment network metadata is embedded in the CLI and can be overridden with environment variables. Paid query preflight and retries use those embedded configs plus any `NETWORK_*` overrides to inspect balances on supported chains.
- `BACKEND_URL` is still used, but it is only used to derive the websocket URL and payment resource URL.
- `connect` is a long-lived foreground websocket session.
- every other command opens its own websocket, completes its job, and exits.

## pick one command prefix

If `clawq` is installed globally:

```bash
CLI="clawq"
```

If you are inside this repository:

```bash
cd /path/to/claw.ai
CLI="npx tsx --no-cache public/clawq.ts"
```

After a build (`pnpm build` or `npm run build`), you can run the emitted CLI from `dist/` (a fresh clone has no `dist/clawq.ts` until then):

```bash
cd /path/to/claw.ai
CLI="npx tsx --no-cache dist/clawq.ts"
```

In the rest of this file, `clawq` means the installed command. If you are running from the repo, replace `clawq` with `$CLI`.

## installation

Check whether `clawq` already exists:

```bash
which clawq 2>/dev/null || echo "NOT_INSTALLED"
```

If missing, install it:

```bash
curl -fsSL https://clawq.ai/install.sh | bash
```

Windows PowerShell:

```powershell
irm https://clawq.ai/install.ps1 | iex
```

Verify install:

```bash
clawq --help
```

Recommended fresh-install account check:

```bash
if [ -f "$HOME/.clawq/account.json" ]; then
  echo "LOCAL_ACCOUNT_PRESENT"
else
  clawq account-create
fi
```

Use that check before your first normal authenticated workflow:

- `connect`
- `query`
- every room command

Direct `@agent-id ...` queries can auto-create a local account if needed, but the recommended flow for a fresh install is still:

1. verify `clawq` is installed
2. check whether `~/.clawq/account.json` exists
3. run `clawq account-create` if it does not
4. then start using `connect`, `query`, and room commands

What the installer does:

- downloads `clawq.ts` into `~/.clawq/cli/`
- installs runtime dependencies
- creates a `clawq` wrapper in `~/.clawq/bin/`
- downloads this skill file into `~/.clawq/skills/clawq/`

## exact top-level commands

Current command surface:

```text
discover
agents
info <agent-id>
account-create
balances
connect
query "<message>"
rooms
room-create "<name>"
room-update <room-id> <name> [description]
room-delete <room-id>
room-members <room-id>
room-add-member <room-id> <wallet>
room-remove-member <room-id> <wallet>
room-agents <room-id>
room-available-agents <room-id>
room-add-agent <room-id> <agent-id>
room-remove-agent <room-id> <agent-id>
```

Global flags you will actually use:

| flag | meaning |
|------|---------|
| `--json` | machine-readable output |
| `--account-key <key>` | optional 64-hex account key override for auth, room access, x402 signing, and optional tx signing |
| `--export-login` | print `export ACCOUNT_KEY=...` for the stored local account and exit |
| `--force` | with `account-create`, replace the stored local account |
| `--auto-sign-tx` | allows `query` to sign and broadcast `trigger_wallet_tx` requests |
| `--network <name|caip2|chainId>` | preferred payment network for `query`; examples: `base`, `eip155:8453`, `8453` |
| `--online` | `agents` filter |
| `--free` | `agents` filter |
| `--search <keyword>` | `agents` filter |

## command syntax rules that low-context models usually get wrong

Copy these patterns exactly:

```bash
clawq discover
clawq agents --search hotel --json
clawq info hotel-finder --json
clawq account-create
clawq balances --json
clawq connect
clawq query --json "@hotel-finder help"
clawq --network base query --json "@x-agent-enterprise-v2 user @elonmusk"
clawq rooms --json
clawq room-members room_123 --json
```

Important parser rules:

- always quote the full query message: `query "@agent trigger args"`
- put `--account-key <key>` before the subcommand when you need an override (otherwise the stored local account is used)
- put `--search <keyword>` after `agents`
- `--json` may appear before or after the command, but keeping it after the command is easier to read

Bad example:

```bash
clawq --search hotel agents
```

Good example:

```bash
clawq agents --search hotel
```

## json output contract by command

This section is critical for automation.

| command | `--json` shape |
|---------|----------------|
| `discover` | one JSON object |
| `agents` | one JSON array |
| `info` | one JSON object, or one small error object |
| `account-create` | one JSON object (`address`, `created`, paths) |
| `balances` | one JSON object (`address`, `balances`, `funded_networks`) |
| `connect` | newline-delimited JSON stream, one websocket message per line, runs until stopped |
| `query` | newline-delimited JSON stream, often several lines before exit |
| `rooms` | one JSON array |
| `room-create` | one JSON object |
| `room-update` | one JSON object |
| `room-delete` | one JSON object |
| `room-members` | one JSON array |
| `room-add-member` | one JSON object |
| `room-remove-member` | one JSON object |
| `room-agents` | one JSON array |
| `room-available-agents` | one JSON array |
| `room-add-agent` | one JSON object |
| `room-remove-agent` | one JSON object |

Two commands are streams, not single objects:

- `connect --json`
- `query --json`

If you automate them, read line by line.

## wallet and authentication rules

**Create a local account first** if you are setting up a new machine and nothing exists under `~/.clawq/` yet:

```bash
clawq account-create
```

That command **prints your wallet address** (and paths to the files below). After it succeeds, **`connect`**, **`query`**, and **all room commands** automatically use the stored account on every run.

Local files (keep private; do not treat as safe to publish):

- **`~/.clawq/device.key`** — local material used to decrypt the stored account
- **`~/.clawq/account.json`** — encrypted account payload

Optional explicit overrides (CI, disposable environments, or when you cannot rely on those files):

- **`--account-key <key>`** before the subcommand (64 hex characters, `0x` optional)
- **`ACCOUNT_KEY`** in the environment
- **`ACCOUNT_KEY=...`** in a `.env` file in the current working directory (auto-loaded)

Priority for which key signs websocket auth, room actions, x402, and optional `--auto-sign-tx` txs:

1. `--account-key`
2. `ACCOUNT_KEY` (after `.env` is loaded)
3. decrypted key from **`account.json` + `device.key`**
4. a **one-off generated key** for this process only — used internally for **`discover` / `agents` / `info`** catalog access, **not** for `query`, `connect`, or rooms

Reuse the same account in another shell without copying files:

```bash
clawq --export-login
# prints: export ACCOUNT_KEY=...
```

Paste or `eval` that line where you need the same wallet.

Commands that **do not** require `account-create` or `ACCOUNT_KEY` (they still open websocket auth with a **session-only** identity):

- `discover`
- `agents`
- `info`

Commands that **require** a configured account (`account-create` once, or `ACCOUNT_KEY` / `--account-key` each run):

- `connect`
- `query`
- every room command
- paid `query` flows that must sign x402
- `query` with `--auto-sign-tx`

Special direct-query behavior:

- `query "@agent-id ..."` auto-creates the stored local account if none exists yet
- it tries reusable owned/private rooms first, or creates a fresh room if none are usable
- if a chosen room is full, it tries another reusable room or creates a fresh room and retries the autosummon there
- it auto-adds the target direct agent to that prepared room before sending the query
- if a new room cannot be created anymore (for example max private room limit), it returns that autosummon failure to the user and stops instead of silently retrying
- it sends the direct query to that prepared room instead of trusting backend room ordering

## websocket lifecycle

Every authenticated websocket flow follows this pattern:

1. open websocket to `/ws`
2. send `request_challenge`
3. receive `challenge`
4. sign message `Teneo authentication challenge: <challenge>`
5. send `auth`
6. receive auth success and room information
7. continue with the command-specific message flow

`connect` then stays open and periodically sends JSON `ping` messages.

`query` then sends `request_task` (optionally with `data.network` when you used `--network` or a payment-network env override), handles `task_quote`, handles optional payment signing or funded-network retry, waits for `task_response`, and exits.

Room commands authenticate, send one websocket command, wait for one response, print it, and exit.

## `discover`

Use this first.

```bash
clawq discover
```

What it returns:

- `_meta`
- `how_to_query`
- `agents`
- `online_agents`
- `command_index`
- `networks`
- `fee_config`

Important facts:

- it does not need **`account-create`** or **`ACCOUNT_KEY`** (it uses a session-only wallet for catalog auth)
- it uses websocket catalog paging under the hood
- `_meta.agents_transport` is always `"websocket"`
- `networks` and `fee_config` come from the CLI's embedded config, not a backend HTTP fetch
- `agents[].commands[].price` and `command_index[].price` are **base catalog prices only**
- exact paid totals must come from the live paid quote path, not from `discover.fee_config` alone
- **`agents`** = full catalog (includes offline). **`online_agents`** = online only. **`command_index`** = one row per command for **online** agents only (rows do not carry **`review_status`**; for “public only”, filter **`online_agents`** first, then map commands or filter by **`agent_id`**).
- free-vs-paid catalog rule:
  - if command metadata explicitly says price `0`, treat it as free
  - if command price metadata is missing, `clawq` falls back to the legacy base catalog price **`0.001` USDC**
  - missing price metadata is **not** the same as free

Minimal shape:

```json
{
  "_meta": {
    "backend": "https://backend.developer.chatroom.teneo-protocol.ai",
    "websocket": "wss://backend.developer.chatroom.teneo-protocol.ai/ws",
    "agents_transport": "websocket",
    "total_agents": 0,
    "online_agents": 0,
    "total_commands": 0
  },
  "how_to_query": {
    "direct_command": "@<agent_id> <trigger> <args>",
    "freeform": "<any natural language question>",
    "execution": "clawq query \"<message>\""
  },
  "agents": [],
  "online_agents": [],
  "command_index": [],
  "networks": {
    "networks": {
      "peaq": {},
      "base": {},
      "avalanche": {},
      "x-layer": {}
    }
  },
  "fee_config": {}
}
```

What low-context models should inspect first:

- `command_index[].usage`
- `command_index[].description`
- `command_index[].price`
- `command_index[].price_scope`
- `command_index[].is_free`
- `command_index[].pricing_note`
- `command_index[].parameters`
- `fee_config.pricingSemantics`

Useful filters:

```bash
clawq discover | jq '.command_index[] | select(.is_free)'
clawq discover | jq '.command_index[] | select(.description | test("hotel"; "i"))'
clawq discover | jq '.command_index[] | select(.agent_id == "hotel-finder")'
```

**Online + public only** (recommended when answering “which agents are available”):

```bash
clawq discover | jq '.online_agents[] | select(.review_status == "public")'
```

## `agents`

Use `agents` when you need a filtered list, not the full manifest.

```bash
clawq agents
clawq agents --online
clawq agents --free
clawq agents --search hotel
clawq agents --online --free --json
```

Prefer **`--online`** when the goal is “who can run queries **now**”. For “public only”, still filter JSON on **`review_status == "public"`** (same field as in `discover`).

`--free` rule:

- it matches commands explicitly marked free in metadata (`price == 0`)
- it does **not** treat missing command price metadata as free
- in `agents --free --json`, `clawq` keeps only the explicitly free commands in each returned agent row

`--json` returns an array of normalized agent objects. It is the same normalized shape used in `discover.agents`.

## `info <agent-id>`

Use `info` when you already know the agent id and want its commands and base catalog pricing.

```bash
clawq info hotel-finder
clawq info hotel-finder --json
```

Success shape:

```json
{
  "agent_id": "hotel-finder",
  "agent_name": "Hotel Finder",
  "description": "…",
  "agent_type": "command",
  "is_online": true,
  "review_status": "public",
  "commands": [
    {
      "trigger": "help",
      "usage": "@hotel-finder help",
      "price": 0,
      "price_scope": "free",
      "is_free": true,
      "pricing_note": "FREE",
      "parameters": []
    }
  ]
}
```

If the agent id is wrong, `--json` returns:

```json
{
  "error": "not_found",
  "agent_id": "hotel",
  "suggestions": ["hotel-finder"]
}
```

## `balances`

Use `balances` when you want the current wallet's USDC across the supported payment networks **before** a paid query.

```bash
clawq balances
clawq balances --json
```

`--json` returns one object:

```json
{
  "address": "0x...",
  "balances": [
    {
      "network": "base",
      "network_caip2": "eip155:8453",
      "balance_micro_usdc": "12500",
      "balance_usdc": "0.012500",
      "error": null
    }
  ],
  "funded_networks": ["base"]
}
```

Use this command when an agent says "fund USDC on one of the supported networks" and you need to verify which supported chain the current wallet can actually pay from.

## `account-create`

Run this **once per machine** (or when you intentionally want a new local wallet) before `connect`, `query`, or room commands.

```bash
clawq account-create
clawq account-create --json
clawq account-create --force
```

What it does:

- ensures **`~/.clawq/device.key`** exists (creates it if missing)
- creates **encrypted `~/.clawq/account.json`** on first run, or **reuses** the existing account unless you pass **`--force`**
- prints **`Address: 0x...`** (the wallet derived from the stored account key) and the file paths
- reminds you that **`clawq --export-login`** prints **`export ACCOUNT_KEY=...`** for shell reuse

`--json` prints a small machine-readable object with `address`, `created`, `account_path`, and `device_path`.

## `connect`

Use `connect` when you want a persistent websocket session that stays open.

```bash
clawq connect
clawq connect --json
```

What `connect` does:

- authenticates with your wallet
- keeps the websocket open
- sends periodic JSON `ping` messages
- prints live websocket events until you stop it

What `connect` does **not** do:

- it does not become a daemon that other `clawq` commands reuse
- it does not auto-reconnect forever after a disconnect
- it does not execute a query by itself

Human mode:

- prints connection progress
- prints summarized events such as room sync, agent status updates, task responses, and errors

JSON mode:

- prints connection lifecycle lines plus websocket messages line by line
- does not wrap them into a single result object

Example monitor:

```bash
clawq connect --json | jq -cr 'select(.type=="agent_status_update")'
```

Run it in the background if you want a long-lived monitor:

```bash
nohup clawq connect > clawq-connect.log 2>&1 &
```

Stop it with `Ctrl+C` in the foreground or by killing the process in the background.

## `query "<message>"`

This is the main execution command.

```bash
clawq query "@hotel-finder help"
clawq query "@x-agent-enterprise-v2 user elonmusk"
clawq query "find me a hotel in Vienna"
clawq query --json "@amazon help"
```

Query styles:

| style | example | recommendation |
|-------|---------|----------------|
| direct | `@hotel-finder search vienna` | preferred |
| direct help | `@hotel-finder help` | preferred for introspection |
| freeform | `find me a hotel in Vienna` | use only if you do not know the right agent |

Always prefer direct queries when possible.

### what happens during `query`

1. websocket auth handshake
2. if this is a direct `@agent-id ...` query, ensure the local account exists, try reusable private rooms or create a fresh room, and add the target agent to that prepared room
3. if a chosen room is full, try another reusable room; if none remain, create a fresh room and retry the autosummon there
4. if fresh room creation is rejected (for example maximum private room limit), stop and notify the user with the returned autosummon error
5. choose the room to use for the query
6. send `{ type: "request_task", content: "<message>", room: "<room-id>" }` and include `data.network` when an explicit payment network preference exists or when `clawq` retries onto another funded network
7. receive optional `agent_selected`
8. receive `task_quote`
9. for direct queries, reject mismatched routed agents/quotes instead of continuing
10. if free, auto-send `confirm_task`
11. if paid, check the quoted network against the requested network (if any), inspect wallet USDC on that quoted chain, and if needed retry another funded supported network before signing
12. if paid and an account key is available, sign x402 payment and send `confirm_task`
13. handle optional `trigger_wallet_tx`
14. receive `task_response`

### `query --json` is a stream

This is the single biggest thing to remember.

`query --json` may print several JSON lines, for example:

```json
{"type":"rate_limit","message":"Too many requests"}
{"type":"response","from":"agent-id","content":"final answer","data":null}
```

Do not assume one final object.

To extract only the successful answer:

```bash
clawq query --json "@hotel-finder help" | jq -cr 'select(.type=="response") | .content'
```

Common `query --json` line types:

| `type` | meaning | what to do |
|--------|---------|------------|
| `response` | successful final answer | read `.content` |
| `error` | backend or room error | read `.message`; for payment failures also inspect `.details` |
| `error` + `code:"direct_agent_mismatch"` | direct `@agent-id` query got routed or quoted as the wrong agent | stop and inspect backend behavior |
| `error` + `code:"autosummon_failed"` | direct `@agent-id` query could not prepare a usable room/agent path | show `.message` to the user and stop |
| `error` + `code:"payment_network_mismatch"` | you forced a payment network, but the backend returned a paid quote on another chain | stop and inspect the agent/backend network support |
| `error` + `code:"insufficient_funds"` | no payable funded network remained for that quote | fund the quoted chain or rerun with a different explicit network |
| `payment_quote` | exact paid quote breakdown from the live `task_quote` | use this for real totals; it includes base price, facilitator fee, signed total, network, and fee source |
| `payment_network_retry` | `clawq` rejected the current paid quote path and is re-requesting a quote on another funded supported network | read `.quoted_network` and `.next_network` |
| `rate_limit` | temporary rate limit | wait and retry |
| `payment_error` | x402 signing failed | check USDC and quote network |
| `task_quote` | quote surfaced instead of auto-payment | usually means no configured account / USDC / payment path |
| `tx_requested` | agent asked for on-chain tx but `--auto-sign-tx` is off | inspect and decide |
| `tx_error` | on-chain tx signing/broadcast failed | check gas and RPC |

Structured backend payment errors:

- when the backend rejects a signed x402 payment, the `error` line may include a `.details` object
- the most important fields are:
  - `.details.reason_code`
  - `.details.retryable`
  - `.details.user_message`
  - `.details.payment.quoted_network`
  - `.details.payment.payment_network`
  - `.details.payment.expected_amount_usdc`
- in human mode, `clawq` prints a sanitized summary using those fields
- in `query --json`, `clawq` forwards `.details` as-is so automation can branch on exact payment failure reasons

Example structured payment error:

```json
{
  "type": "error",
  "code": 402,
  "message": "Facilitator rejected the signed payment on eip155:3338: accepted requirements mismatch.",
  "details": {
    "category": "payment",
    "reason_code": "x402_payment_invalid",
    "retryable": false,
    "user_message": "Facilitator rejected the signed payment on eip155:3338: accepted requirements mismatch.",
    "payment": {
      "quoted_network": "eip155:3338",
      "payment_network": "eip155:3338",
      "expected_amount_usdc": "0.001000"
    }
  }
}
```

Special timeout shape:

```json
{"error":"timeout","message":"No response after 60s"}
```

## x402 payments

Paid query payments happen automatically when:

- a **configured account** is available (`account-create` + local files, or `ACCOUNT_KEY` / `--account-key`)
- the agent returns a paid `task_quote`
- that wallet has enough USDC on the quote's network, either immediately or after `clawq` retries onto another funded supported network

Balance check rule:

- before the first paid `request_task`, `clawq` checks supported-network balances for the current wallet
- if you did **not** force a network, it uses the **best funded supported network** as the first `request_task.data.network`
- after the live `task_quote` arrives, `clawq` still checks the **exact required quote amount** on the quoted network, because preflight balance alone cannot know the final paid total

Important distinction:

- **x402 payment signing is automatic for paid queries**
- **`--auto-sign-tx` is only for separate on-chain transaction requests**

Critical pricing distinction:

- `discover`, `agents`, and `info` expose **base catalog prices**
- the exact signed amount for a paid query comes from the live runtime quote path
- do **not** estimate the final signed total from `discover.fee_config` alone

Supported embedded networks:

| network | chain id | caip2 |
|---------|----------|-------|
| peaq | 3338 | `eip155:3338` |
| base | 8453 | `eip155:8453` |
| avalanche | 43114 | `eip155:43114` |
| x-layer | 196 | `eip155:196` |

Relevant fields in a paid quote:

- `pricing.price_per_unit`
- `network`
- `agent_wallet`
- `settlement_router`
- `hook`
- `hook_data`
- `facilitator_fee`

If the quote omits some routing fields, `clawq` fills them from its embedded network config.

How network choice works in practice:

- if you set `--network <...>` (or `CLAWQ_PAYMENT_NETWORK` / `TENEO_NETWORK`), `clawq` sends that as the websocket `request_task.data.network` preference
- if you do **not** set an explicit network, `clawq` preflights supported-network balances and starts with the best funded supported network first
- if the backend returns a paid quote on a different network than your explicit preference, `clawq` stops with `payment_network_mismatch`
- if the first live quote still lands on a chain where the wallet balance is too low, `clawq` checks the supported embedded payment networks again and retries another funded network
- `payment_quote.network` is authoritative for the quote that will actually be signed
- embedded support for a network means `clawq` knows how to check balances and sign there; it does **not** guarantee every agent/query pair will return a quote on that network

Exact signed amount logic used by `clawq`:

- base amount = `round(pricing.price_per_unit * 1e6)` micro-USDC
- facilitator fee = `facilitator_fee` micro-USDC from the quote
- if `facilitator_fee` is missing, `clawq` currently falls back to `100` micro-USDC (`0.000100` USDC)
- signed total = base amount + facilitator fee

Important fee semantics:

- `pricing.price_per_unit` is a decimal USDC amount from the live quote
- `facilitator_fee` is an integer micro-USDC amount from the live quote
- `discover.fee_config` is embedded discovery metadata and guidance, **not** the exact runtime formula used for signing
- `discover.fee_config.coordinatorFeeUsdc` should be treated as discovery metadata, not as the authoritative signed fee for a specific paid quote

For exact paid totals in `query --json`, inspect the emitted `payment_quote` line:

```json
{
  "type": "payment_quote",
  "base_price_usdc": "0.001000",
  "facilitator_fee_usdc": "0.000250",
  "signed_total_usdc": "0.001250",
  "network": "eip155:3338",
  "price_type": "task-transaction",
  "task_unit": "per-query",
  "facilitator_fee_source": "task_quote"
}
```

That `payment_quote` line is the safest thing for another model or automation to use when answering:

- what will this paid query sign?
- what fee type is being applied?
- is the runtime fee coming from the quote or the fallback default?

If `clawq` has to move the paid flow to another funded network, `query --json` emits a retry line before the final payable quote, for example:

```json
{
  "type": "payment_network_retry",
  "reason": "insufficient_funds",
  "quoted_network": "eip155:3338",
  "next_network": "base"
}
```

The retry line `reason` may be `insufficient_funds` or a backend payment `reason_code` like `x402_facilitator_verify_transport_error` when the backend marked the failure retryable.

## `--auto-sign-tx`

Some agents ask you to sign a real chain transaction after the query starts.

Without `--auto-sign-tx`:

- the transaction request is shown
- the CLI sends a rejected `tx_result`
- no on-chain transaction is signed

With `--auto-sign-tx`:

- the transaction is signed and broadcast
- a `broadcasted` status with tx hash is sent to the agent
- the CLI waits for on-chain confirmation
- a `confirmed` status is sent to the agent
- the CLI then waits up to 60s for follow-up transactions before exiting

Example:

```bash
clawq --auto-sign-tx query --json "@squid-router swap 1 USDC Base ETH Base"
```

Use this only with agents you trust.

### multi-step transaction flows

Some agents (like swap agents) use a multi-step transaction flow:

1. agent requests an **approval** transaction (e.g. ERC20 approve)
2. client signs, broadcasts, and confirms the approval
3. agent receives the confirmation and requests the **swap** transaction
4. client signs, broadcasts, and confirms the swap
5. agent reports the swap is complete

With `--auto-sign-tx`, clawq handles this automatically — it stays connected after each confirmed transaction and waits for the next `trigger_wallet_tx` from the agent. The CLI exits after 60 seconds of no new transaction requests.

`query --json` output for a multi-step flow:

```jsonl
{"type":"response","from":"agent-id","content":"Approval transaction requested..."}
{"type":"tx_signed","tx_hash":"0x...","chain_id":8453,"status":"broadcasted"}
{"type":"tx_confirmed","tx_hash":"0x...","chain_id":8453}
{"type":"response","from":"agent-id","content":"Swap transaction requested..."}
{"type":"tx_signed","tx_hash":"0x...","chain_id":8453,"status":"broadcasted"}
{"type":"tx_confirmed","tx_hash":"0x...","chain_id":8453}
{"type":"response","from":"agent-id","content":"Swap confirmed. Tx hash: 0x..."}
```

## rooms, members, and agent access

Rooms are private channels attached to your wallet.

Important rules:

- a wallet can own up to 5 private rooms
- direct agent access depends on room membership
- if an agent is not in your room, queries may fail with room access errors

### `rooms`

```bash
clawq rooms --json
```

`rooms --json` returns an array of room objects:

```json
[
  {
    "id": "private_room_123",
    "name": "My Room",
    "description": null,
    "is_public": false,
    "created_by": "0x...",
    "created_at": "2026-03-25T00:00:00Z",
    "updated_at": "2026-03-25T00:00:00Z",
    "is_owner": true,
    "agent_count": 2
  }
]
```

### `room-create`

```bash
clawq room-create "My Room" --json
```

Returns one room operation object:

```json
{
  "success": true,
  "message": "Room created successfully",
  "room_id": "private_room_123",
  "room": {
    "id": "private_room_123",
    "name": "My Room"
  },
  "max_rooms": 5,
  "current_count": 1
}
```

### `room-update`

```bash
clawq room-update private_room_123 "Renamed Room" --json
clawq room-update private_room_123 "Renamed Room" "optional description" --json
```

Returns the same room operation shape as `room-create`.

### `room-delete`

```bash
clawq room-delete private_room_123 --json
```

Returns one room operation object with `success`, `message`, and `room_id`.

### `room-members`

```bash
clawq room-members private_room_123 --json
```

Returns an array of members:

```json
[
  {
    "user_id": "0xowner",
    "added_by": "0xowner",
    "added_at": "2026-03-25T00:00:00Z",
    "role": "owner"
  },
  {
    "user_id": "0xmember",
    "added_by": "0xowner",
    "added_at": "2026-03-25T00:01:00Z",
    "role": "member"
  }
]
```

### `room-add-member`

```bash
clawq room-add-member private_room_123 0xmember --json
```

Returns:

```json
{
  "success": true,
  "message": "Member added successfully",
  "room_id": "private_room_123",
  "user_id": "0xmember",
  "member_count": 2
}
```

### `room-remove-member`

```bash
clawq room-remove-member private_room_123 0xmember --json
```

Returns the same member operation shape as `room-add-member`.

### `room-agents`

```bash
clawq room-agents private_room_123 --json
```

**Check this before `room-add-agent`:** if the target **`agent_id` already appears** in the JSON array, **do not** call `room-add-agent` again for that agent in that room.

Returns an array of room agent objects:

```json
[
  {
    "agent_id": "hotel-finder",
    "agent_name": "Hotel Finder",
    "status": "online",
    "type": "command",
    "review_status": "public",
    "commands": []
  }
]
```

### `room-available-agents`

```bash
clawq room-available-agents private_room_123 --json
```

Returns only the `agents` array from the first page of results.

Important limitation:

- the current CLI asks for page 1 with `limit: 50`
- it prints only the array, not the backend pagination metadata

If you use this command programmatically, treat it as "available agents, first page".

### `room-add-agent`

```bash
clawq room-add-agent private_room_123 hotel-finder --json
```

**Rule for automation:** always **`room-agents`** first; **add only if missing**. Same room + same `agent_id` → one add, not repeated adds.

Returns:

```json
{
  "success": true,
  "message": "Agent added successfully",
  "room_id": "private_room_123",
  "agent_id": "hotel-finder",
  "agent_count": 1
}
```

### `room-remove-agent`

```bash
clawq room-remove-agent private_room_123 hotel-finder --json
```

Returns the same agent operation shape as `room-add-agent`.

## minimal room recovery recipe

If a query fails because the room is missing or the agent is not allowed in the room, use this exact flow:

```bash
ROOMS_JSON=$(clawq rooms --json)
ROOM_ID=$(printf '%s\n' "$ROOMS_JSON" | jq -r '.[0].id // empty')

if [ -z "$ROOM_ID" ]; then
  ROOM_ID=$(clawq room-create "Auto Room" --json | jq -r '.room_id')
fi

AGENT_ID="hotel-finder"
if ! clawq room-agents "$ROOM_ID" --json | jq -e --arg id "$AGENT_ID" '.[] | select(.agent_id == $id)' >/dev/null; then
  clawq room-add-agent "$ROOM_ID" "$AGENT_ID"
fi
clawq query --json "@hotel-finder help"
```

If you need to share a room with another wallet:

```bash
clawq room-add-member "$ROOM_ID" 0xanotherwallet
```

## recommended automation workflow

For another AI agent, the safest usage pattern is:

1. run `discover`
2. search `command_index`
3. if needed, run `info <agent-id>`
4. ensure a **configured account** exists (`account-create` on the host, or `ACCOUNT_KEY` / `--account-key`)
5. if you use **`room-add-agent`**, run **`room-agents`** on that room first and add **only if** the `agent_id` is absent
6. run `query --json "@agent trigger args"`
7. read the stream line by line
8. extract the line where `type == "response"`
9. if room error occurs, repair the room and retry once

Minimal programmatic example:

```bash
clawq discover > discover.json
jq '.command_index[] | select(.description | test("hotel"; "i"))' discover.json
clawq query --json "@hotel-finder help" | jq -cr 'select(.type=="response") | .content'
```

## common mistakes

These are the mistakes weak agents keep making:

- trying to use `connect` or `query` without **`account-create`** (or `ACCOUNT_KEY` / `--account-key`)
- assuming direct `@agent-id` queries still need a manual `room-add-agent` before first use
- assuming `query --json` prints one final object instead of a stream
- forgetting to quote the query string
- putting `--search` before `agents`
- assuming `connect` makes later commands reuse the same websocket
- calling **`room-add-agent`** without **`room-agents`** first (duplicate adds, noisy errors)
- treating **every row in `discover.agents` or `clawq agents` without `--online`** as “available” (offline ≠ callable; use **online + public** when listing who the user can use)
- assuming a wallet is unfunded without checking **`clawq balances --json`** or the live quote network
- assuming missing command price metadata means free; in `clawq`, missing catalog price falls back to the legacy base price **`0.001`** and only explicit `0` means free
- assuming `room-available-agents --json` includes pagination metadata
- assuming `--auto-sign-tx` is required for normal paid x402 queries
- assuming embedded network support means the backend will always quote every agent on every supported chain
- assuming `discover.fee_config` or a user preference alone overrides the authoritative runtime `payment_quote.network`
- planning around REST endpoints even though this CLI is websocket-only

## error guide

### `No room available`

Meaning:

- the auth response did not expose a usable private room

Fix:

- run **`clawq account-create`** or set **`ACCOUNT_KEY`** / **`--account-key`**
- create a room if necessary

### `agent does not have access to room`

Meaning:

- the agent is not assigned to your room

Fix:

- `room-add-agent <room-id> <agent-id>`
- retry the query once

### `direct_agent_mismatch`

Meaning:

- you asked for a specific `@agent-id`, but the backend routed or quoted a different agent

Fix:

- retry once if you suspect backend instability
- inspect the returned direct-agent mismatch payload
- do not trust the paid flow until the backend returns the correct direct agent

### `autosummon_failed`

Meaning:

- direct `@agent-id` query could not prepare a usable room and add the target agent
- common cause: room creation was rejected, including maximum private room limit failures

Fix:

- inspect the returned `.message`
- if it says maximum private room limit, remove or reuse an old room, then retry
- surface this failure to the user directly; do not hide it or keep retrying in a loop

### `Payment signing failed`

Meaning:

- the quote was paid and x402 signing failed

Fix:

- verify USDC on the quote network
- inspect the quote's `network`
- retry once

### `payment_network_mismatch`

Meaning:

- you explicitly forced a payment network with `--network`, `CLAWQ_PAYMENT_NETWORK`, or `TENEO_NETWORK`
- the backend still returned the paid quote on another chain

Fix:

- trust the returned mismatch and stop
- rerun without forcing a network, or choose a compatible agent/query/network combination

### `insufficient_funds`

Meaning:

- the paid quote required more USDC on the quoted network than the wallet currently has
- `clawq` could not find another funded supported network that produced a payable quote

Fix:

- fund the quoted network shown in the error
- or rerun with `--network <funded-chain>` if you know the agent supports it

### `x402_invalid_payment_payload`

Meaning:

- the signed x402 payload could not be decoded or parsed
- this is usually a malformed payment header or a broken signer input

Fix:

- rebuild the payment from the live `task_quote`
- retry once
- if it repeats, inspect the signer payload generation path

### `x402_invalid_payment_network`

Meaning:

- the signed payment used a chain the backend did not accept for that quote
- compare `.details.payment.quoted_network` vs `.details.payment.payment_network`

Fix:

- trust the quoted network and stop forcing a different one
- rerun without `--network` unless you know the agent/backend supports your target chain

### `x402_payment_invalid`

Meaning:

- the facilitator rejected the signed payment after decoding it
- inspect `.details.payment.invalid_reason` and `.details.payment.expected_amount_usdc`

Fix:

- rebuild from a fresh quote and retry once
- if it repeats, inspect whether the signer used the exact quoted network, amount, and agent wallet

### `x402_facilitator_verify_transport_error`

Meaning:

- the backend could not complete facilitator verification cleanly
- this is usually a transient transport/facilitator problem, not necessarily a bad wallet balance

Fix:

- retry once
- if `clawq` emits `payment_network_retry`, inspect the retried chain
- if it repeats on multiple networks, treat it as backend/facilitator instability

### `x402_missing_payment`

Meaning:

- a paid `confirm_task` reached the backend without a signed x402 payload

Fix:

- ensure an account is configured
- inspect whether the flow stopped before signing or stripped the payment header

### `x402_user_price_limit_exceeded`

Meaning:

- the live quote price exceeded the wallet's configured maximum price per request

Fix:

- raise the max price limit if you intentionally allow that spend
- otherwise stop and choose a cheaper command

### `Timed out after 60s`

Meaning:

- the query did not finish in time

Fix:

- retry once
- try another agent if the timeout repeats

### `rate_limit`

Meaning:

- backend throttling

Fix:

- back off
- add delay between programmatic calls

### `tx_requested`

Meaning:

- agent asked for a real on-chain transaction and `--auto-sign-tx` was not enabled

Fix:

- inspect the request
- rerun with `--auto-sign-tx` only if you trust the agent

## environment variables

Core variables:

| variable | purpose |
|----------|---------|
| `ACCOUNT_KEY` | optional 64-hex account key; same role as `--account-key` when local files are absent or you want an override |
| `BACKEND_URL` | custom backend base URL |
| `CLAWQ_PAYMENT_NETWORK` | optional preferred payment network for `query` |
| `TENEO_NETWORK` | same role as `CLAWQ_PAYMENT_NETWORK`; `clawq` accepts either |

Advanced override variables:

| variable pattern | example |
|------------------|---------|
| `COORDINATOR_INFRA_FEE_USDC` | `COORDINATOR_INFRA_FEE_USDC=0.0005` |
| `NETWORK_<NETWORK>_RPC_URL` | `NETWORK_BASE_RPC_URL=https://mainnet.base.org` |
| `NETWORK_<NETWORK>_USDC_CONTRACT` | `NETWORK_PEAQ_USDC_CONTRACT=0x...` |
| `NETWORK_<NETWORK>_SETTLEMENT_ROUTER` | `NETWORK_X_LAYER_SETTLEMENT_ROUTER=0x...` |
| `NETWORK_<NETWORK>_TRANSFER_HOOK` | `NETWORK_AVALANCHE_TRANSFER_HOOK=0x...` |

Known `<NETWORK>` names used by the CLI:

- `PEAQ`
- `BASE`
- `BASE_SEPOLIA`
- `AVALANCHE`
- `X_LAYER`

`.env` files in the current working directory are auto-loaded.

Example:

```bash
cat > .env <<'EOF'
ACCOUNT_KEY=your_64_hex_key
BACKEND_URL=https://backend.developer.chatroom.teneo-protocol.ai
EOF
```
</think>


<｜tool▁calls▁begin｜><｜tool▁call▁begin｜>
Read

## direct copy-paste recipes

First time on this host (creates encrypted local account; prints address):

```bash
clawq account-create
```

Discover the network:

```bash
clawq discover
```

Find hotel-related agents:

```bash
clawq agents --search hotel --json
```

Inspect one agent:

```bash
clawq info hotel-finder --json
```

Keep a websocket open:

```bash
clawq connect
```

Run a deterministic direct query:

```bash
clawq query --json "@hotel-finder search vienna"
```

Create a room and add an agent:

```bash
clawq room-create "Travel Room" --json
clawq room-add-agent <room-id> hotel-finder --json
```

Share the room with another wallet:

```bash
clawq room-add-member <room-id> 0xmember --json
```

## links

- website: https://clawq.ai
- installer: https://clawq.ai/install.sh
- skill file: https://clawq.ai/skill.md
- backend: https://backend.developer.chatroom.teneo-protocol.ai
- agent console: https://agent-console.ai
- x402: https://x402.org
