Skip to content
Back to skills

x-herald-cli

CSecurity

用 x-herald CLI 运维/诊断 x-herald LLM 网关:供应商与模型实例、模型组与路由规则、虚拟密钥、请求日志与指标、路由追踪与熔断、成本核算、配置导入导出,以及 thinking 模式 400(roleMapping / patchMissingReasoningContent)等实例配置修复。当需要在不访问数据库的前提下查询或改动网关配置、排查请求失败/路由异常/成本异常时使用。认证三级回退、默认 JSON 输出与 --dry-run 契约也在此。

  • 4 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 4, 2026
ai-agentsgobashgitapi

Works with

  • claude code
  • cursor
  • cli
  • api

Security analysis

C71/100
  • criticalPipes output to a shell interpreter
  • mediumUses curl or wget to download content
  • criticalDownloads and executes remote scripts — classic supply chain attack

Pro scans all 6 files and shows the line behind each finding

Scanned December 4, 2026

npx -y skills add xartifact/x-herald --skill skills --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of x-herald-cli?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for x-herald-cli
[![Security: C — Skills Directory](https://www.skillsdirectory.com/api/skills/xartifact-x-herald-cli/badge)](https://www.skillsdirectory.com/skills/xartifact-x-herald-cli)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: x-herald-cli
description: "用 x-herald CLI 运维/诊断 x-herald LLM 网关:供应商与模型实例、模型组与路由规则、虚拟密钥、请求日志与指标、路由追踪与熔断、成本核算、配置导入导出,以及 thinking 模式 400(roleMapping / patchMissingReasoningContent)等实例配置修复。当需要在不访问数据库的前提下查询或改动网关配置、排查请求失败/路由异常/成本异常时使用。认证三级回退、默认 JSON 输出与 --dry-run 契约也在此。"
---

# x-herald CLI 运维

用 `x-herald` CLI 运维 x-herald LLM 网关。本目录面向**通用编码/运维 Agent**(Claude Code、Codex、OpenCode、Pi 等),
不依赖任何特定客户端约定:所有结论都能用列出的命令复现。

## 安装(无需 clone 仓库)

发布物是单文件二进制,内嵌本技能的全部文件。目标机只需要一条命令:

```bash
# 从 GitHub Release 安装(自动选平台、校验 SHA256、装到 ~/.local/bin)
curl -fsSL https://raw.githubusercontent.com/xartifact/x-herald/main/scripts/install-cli.sh | sh

# 或者已有二进制时:把技能写进已存在的 agent 目录(claude/codex/agents/pi/omp/opencode)
x-herald skill install
```

`skill install` 默认只写已存在的 runtime 目录;`--all` 全部创建,`--runtime <id>` 指定单个,`--dir <path>` 落到自定义目录,
`--dry-run` 只打印目标。`x-herald skill show [file]` 打印内嵌原文(默认 `SKILL.md`,也可 `commands.json`)。

镜像/离线:`X_HERALD_CLI_BASE_URL=<前缀> sh install-cli.sh` 从内网镜像取同名文件,`X_HERALD_CLI_BIN_DIR` 改安装目录。

## 先决条件

- 网关可达:`X_HERALD_URL`(默认 `http://localhost:3000`)
- 管理员凭据:`x-herald auth login` 换取 JWT 并落盘(`~/.config/x-herald/config.json`,权限 0600)

认证三级回退,优先级从高到低:

1. `--token <jwt>`(或 `X_HERALD_TOKEN`)
2. `X_HERALD_TOKEN` 环境变量
3. `x-herald auth login` 落盘的 token

`--api-key` / `X_HERALD_API_KEY` 是**虚拟密钥**,只对 `/api/v1` 生效,不能用于管理 API。
`x-herald auth whoami` 会显示当前 `tokenSource`(`flag` / `env` / `config` / `none`),排查 401 先看它。

## 输出契约(给 Agent 的硬约定)

- 默认 `--format json`:stdout **只有** payload(`{success,data}` 已解包),可直接 `| jq`。
- 列表类端点(带游标/分页)保留信封:用 `--format json` 时会看到 `data`、`nextCursor`、`hasMore`。
- `--format table` **仅供人看**,列宽与列名不保证稳定,Agent 不要解析。
- 进度、警告、错误一律走 stderr,不污染 stdout。
- 退出码:`0` 成功;`1` 失败(HTTP 错误、参数缺失、未认证)。错误信息形如
  `HTTP 401: Missing or invalid authorization header (run ...)`。
- 版本更新提示只写 stderr,且**只在命令成功之后**出现:stdout 仍是纯 payload。
  查询结果缓存 24 小时,无网络时静默跳过,因此不会拖慢命令。
  自动化场景用 `--no-update-check` 或 `X_HERALD_NO_UPDATE_CHECK=1` 关闭。

## 命令地图

| 领域 | 命令组 | 典型用途 |
|---|---|---|
| 上游 | `providers` | 增删改供应商、拉取上游模型、同步为实例、thinking 映射 |
| 路由配置 | `groups` / `instances` | 模型组与实例、组内排序、能力覆盖、连通性测试 |
| 客户端 | `access` / `rules` / `overview` | 接入模型、路由版本(图)、全局路由总览 |
| 鉴权 | `keys` | 虚拟密钥、限流、用量、轮换 |
| 观测 | `logs` / `metrics` / `traces` / `cb` | 请求日志、指标、路由追踪、熔断器 |
| 成本 | `costs` | 汇总、按密钥/供应商/模型、定价 |
| 系统 | `settings` / `workspaces` / `config` | 系统参数、工作区、配置导入导出 |
| AI | `ai` | 日志诊断、按自然语言生成实例配置 |
| 兜底 | `api` | 任意端点:`x-herald api <METHOD> <PATH>` |

发现新端点或本文未覆盖的端点,用 `api` 兜底;`--dry-run` 可先看将发出的请求。

## 高频操作

```bash
# 健康与身份
x-herald ping
x-herald auth login
x-herald auth whoami

# 供应商 → 实例
x-herald providers list
x-herald providers create --name openai \
  --protocols '{"openai":{"baseUrl":"https://api.openai.com/v1","enabled":true}}' \
  --api-key sk-...
x-herald providers models <providerId>
x-herald providers sync-models <providerId> --models '[{"id":"gpt-4o","name":"gpt-4o"}]'

# 模型组与实例(capabilities 稀疏:缺省=继承上层)
x-herald groups create --name gpt-4o --category chat --capabilities '{"streaming":true}'
x-herald instances create --provider-id <pid> --name gpt-4o-openai \
  --actual-model-name gpt-4o --model-type text_generation --protocol openai \
  --group-ids '["<gid>"]'
x-herald instances test <instanceId>

# 观测
x-herald logs list --page-size 20 --status failure
x-herald logs get <logId>
x-herald logs stats-overview --start-date 2026-11-01
x-herald cb states
x-herald traces list --outcome all_failed

# 成本
x-herald costs summary --start-date 2026-11-01
x-herald costs by-provider --start-date 2026-11-01

# 配置备份 / 恢复
x-herald config export > backup.json
x-herald config import --file-body "$(cat backup.json)"
```

## 场景手册

- 排障(5xx / 超时 / 全部候选失败):[`troubleshooting.md`](./troubleshooting.md)
- 变更与回滚(配置改动、发布前后检查):[`change-and-rollback.md`](./change-and-rollback.md)
- 成本巡检(异常花费、定价、用量核对):[`cost-audit.md`](./cost-audit.md)
- 接入新 Provider(协议判定、探测、连通性验证、回滚):[`provider-onboarding.md`](./provider-onboarding.md)

## 安全边界

- 只读排查优先;`delete`、`toggle`、`cleanup`、`import`、`cb trip` 会改变线上行为,先确认再执行。
- 配置变更前先 `x-herald config export > before.json`,回滚用同一份导入。
- 不要把 JWT 或虚拟密钥写进仓库、日志或对话;`auth whoami` 刻意不打印 token。

## 机器可读索引

`commands.json` 由 `src/spec-commands.ts` 生成,列出每个命令的 `command`、`method`、`path`、`description`、
`args` 与 `options`(含 `in: query|body`)。Agent 应优先查它而不是解析 `--help`:

```bash
jq '.commands[] | select(.command | contains("instances create"))' skills/commands.json
```

改完 spec 表后执行 `bun run gen:commands`;`src/command-index.test.ts` 会在两者不一致时失败。

Files in this skill

  • SKILL.md6.4 KB
  • change-and-rollback.md3.7 KB
  • commands.json50.6 KB
  • cost-audit.md2.5 KB
  • provider-onboarding.md7.5 KB
  • troubleshooting.md4 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.