> ## Documentation Index
> Fetch the complete documentation index at: https://docs.anyway.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Anyway CLI

> 从终端使用当前支持的 Business 与 Agents 工作流。

## 安装与更新

```bash theme={null}
npm install -g @anyway-sh/cli
anyway update --check
anyway update
```

请使用 `anyway --help` 查看当前已安装版本的权威命令清单。

## 鉴权方式

| 模式                        | 用途                              |
| ------------------------- | ------------------------------- |
| `anyway login`            | 产品、订单、钱包所有权、额度、仪表盘、追踪和开发者设置     |
| `ANYWAY_AGENT_WALLET_KEY` | 智能体身份、策略、历史、签名、直接付款授权和超级 API 调用 |
| 本地智能体记录                   | 无需导出环境变量即可选择已保存的智能体钱包密钥         |

```bash theme={null}
anyway login
anyway whoami
anyway whoami --refresh
anyway logout
```

### 登录时创建智能体钱包

启动智能体钱包组合流程：

```bash theme={null}
anyway login --agent-wallet
```

对于 SSH、CI 或智能体运行环境，请先启动流程，再完成两个阶段：

```bash theme={null}
anyway login --agent-wallet --non-interactive
anyway login --continue
anyway wallets agents create --continue
```

状态为 `pending` 时，请重复对应的继续命令。

## 产品与付款链接

```bash theme={null}
anyway products list
anyway products get PRD_EXAMPLE
anyway products create --name "My Product" --price 29.99
anyway products create --name "Crypto Tip" --provider crypto
anyway products update PRD_EXAMPLE --name "New name"
anyway products publish PRD_EXAMPLE
anyway products archive PRD_EXAMPLE
anyway products payment-links PRD_EXAMPLE
anyway products payment-links PRD_EXAMPLE create --provider crypto --price 9.99
```

创建产品或链接时会返回 `paymentLinkUrl`。请原样分享这个完整的 Anyway URL，不要解析、拼接或修改。

## 订单与仪表盘

```bash theme={null}
anyway orders list --status paid --page 1 --size 20
anyway orders list --product PRD_EXAMPLE --page 1 --size 20
anyway orders list --format csv
anyway dashboard templates
anyway dashboard query TEMPLATE_ID --days 30
```

CSV 和 JSON 输出使用与表格输出相同的结果页和筛选条件。

## 组织钱包与额度

```bash theme={null}
anyway wallets balance
anyway wallets transactions
anyway wallets credit balance
anyway wallets credit ledger
anyway wallets credit topup
```

组织额度与钱包 USDC 是不同资产。额度余额不是可提现的钱包 USDC。

## 智能体钱包管理

以下商户登录命令用于管理组织钱包：

```bash theme={null}
anyway wallets agents create --name "Research Agent"
anyway wallets agents create --non-interactive
anyway wallets agents create --continue
anyway wallets agents list
anyway wallets agents reset AGENT_ID
anyway wallets agents reset AGENT_ID --non-interactive
anyway wallets agents reset AGENT_ID --continue
```

运行环境和本地密钥命令使用智能体钱包密钥：

```bash theme={null}
export ANYWAY_AGENT_WALLET_KEY="<base64url key bundle>"
anyway wallets agents import --token "<bundle>"
anyway wallets agents import --token-file ./agent-wallet-key.txt
anyway wallets agents list --local
anyway wallets agents list --local --offline
anyway wallets agents default AGENT_ID
anyway wallets agents whoami [AGENT_ID]
anyway wallets agents policies [AGENT_ID]
anyway wallets agents history [AGENT_ID] --limit 50
anyway wallets agents credit-balance [AGENT_ID]
anyway wallets agents forget AGENT_ID --yes
```

`default` 和 `forget` 只修改本地 CLI 记录，不会轮换或删除服务端钱包。

### 签名或授权付款

```bash theme={null}
anyway wallets agents pay --to 0xRECIPIENT --amount 1.5
anyway wallets agents sign --typed-data-file ./typed-data.json
```

服务端会在签名前执行所选钱包的支出策略。

## 超级 API

```bash theme={null}
anyway superapi call "<x402 endpoint URL>"
anyway superapi call "<x402 endpoint URL>" \
  --method POST --body '{"query":"payment APIs"}'
```

常用参数包括 `--body-file`、`--header`、`--headers-json`、`--agent`、`--validity-seconds` 和 `--yes`。`--yes` 会跳过报价确认；只有明确允许自动批准时才使用。

## 设置与钱包初始化

```bash theme={null}
anyway setup --check
anyway setup
anyway setup -y
anyway init wallets --type crypto
anyway init wallets --type agent
```

`setup` 会为检测到的兼容智能体安装 Anyway Agent Skill。

## 追踪、开发者设置、CLI 遥测与反馈

```bash theme={null}
anyway traces status
anyway traces list --limit 20
anyway developer keys list
anyway developer keys list --type payment_key
anyway developer keys create --name "Production SDK"
anyway developer keys delete KEY_ID
anyway telemetry
anyway telemetry off
anyway telemetry on
anyway telemetry reset
anyway telemetry inspect superapi call
anyway feedback "Describe the issue"
anyway feedback "Describe the issue" --category bug --attach-last
anyway feedback "Describe the issue" --dry-run
```

CLI 使用情况遥测与智能体追踪 SDK 指南中的应用追踪相互独立。`telemetry inspect` 只预览脱敏后的命令事件，不会发送数据。对精确参数有要求的自动化脚本，应先运行对应命令的 `--help`。

## 自动化

全局自动化参数：

| 参数               | 行为                        |
| ---------------- | ------------------------- |
| `--format table` | 默认的人类可读输出                 |
| `--format json`  | 在标准输出中输出结构化结果             |
| `--format csv`   | 对返回多行数据的命令输出 CSV          |
| `--timeout 10s`  | 到达期限后停止；支持 `ms`、`s` 或 `m` |
| `--yes`、`-y`     | 跳过支持的确认步骤                 |

稳定的进程退出分类为：`0` 成功、`1` 未知、`2` 参数验证、`3` 鉴权、`4` 超时、`5` 网络、`6` 服务端错误、`7` 限流、`8` 其他客户端错误。

<Warning>
  不要把登录令牌或智能体钱包密钥写入终端历史记录、CI 日志、遥测、截图或模型提示词。优先使用密钥注入，并在导入后删除临时密钥文件。
</Warning>
