Cosin CLI
Use cosin to call the COS API and COS-backed skills from the terminal.
What the CLI does
INLINECODE1 now accepts only relative paths.
There are three request styles:
- 1. INLINECODE2
Calls
https://skills.bankofuniverse.org/skills directly and prints the upstream body directly.
- 2. Normal COS API paths such as INLINECODE4
These are sent directly to the COS API host.
- 3. Skill paths under INLINECODE5
These are converted internally into x402 pay-and-call requests:
- - keeps the same request path
- builds the target URL from INLINECODE6
- sends that target URL to
POST /agent/pay-and-call on the COS API host
Users should not pass absolute URLs to the CLI anymore.
Gather inputs
Collect these inputs before running the CLI:
- - A COS bearer token for INLINECODE8
- An HTTP method
- A relative path starting with INLINECODE9
- Optional JSON for INLINECODE10
- Optional repeatable headers for
--header or INLINECODE12 - Optional
--base-url override for normal COS API calls
Ask for the token if the user has not provided one. Treat it as sensitive.
Protect credentials
- - Treat the
--key value as sensitive - Do not print, commit, or hardcode the token
- Keep the token in the command line argument, not in repo files
Run the CLI
Use one of these command shapes:
CODEBLOCK0
Important flags:
- -
--key <token> for the required bearer token - INLINECODE16 for an optional JSON request body
- INLINECODE17 or
-H 'Name: value' for repeatable custom headers - INLINECODE19 to override the default COS API base URL for direct API calls
- INLINECODE20 or
-v to print the installed CLI version - INLINECODE22 or
-h to print usage
Subcommand notes:
- -
skills does not accept INLINECODE25 - INLINECODE26 does not accept custom headers
- INLINECODE27 does not accept INLINECODE28
- INLINECODE29 does not accept custom headers
Supported paths
Built-in catalog
Use this to discover available skills:
CODEBLOCK1
Expected upstream skills include:
Returns a random value from the Chainlink-based skill endpoint.
Returns the latest price for a supported token symbol.
Supported symbols for /cos/crypto/price/:symbol:
- - INLINECODE33
- INLINECODE34
- INLINECODE35
- INLINECODE36
- INLINECODE37
- INLINECODE38
- INLINECODE39
Direct COS API calls
Use normal API paths to call COS directly:
CODEBLOCK2
Skill calls through /cos/...
Use /cos/... when you want to call a skill through COS:
CODEBLOCK3
Internally, the CLI turns those into x402 pay-and-call requests to the COS backend.
Use the agent shortcut
Use agent, agent status, or agent me as a convenience alias for GET /agent/me.
CODEBLOCK4
Do not combine agent with --json or custom headers.
Validate inputs before running
- - Ensure the path starts with INLINECODE48
- Do not pass absolute URLs
- Use
skills, not INLINECODE50 - Ensure
--json is valid JSON - Ensure headers use INLINECODE52
- For
/cos/crypto/chainlink/random, only use INLINECODE54 - For
/cos/crypto/price/:symbol, only use GET and only the supported symbols
Read the output
Expect the CLI to:
- - Print an HTTP status line for normal API requests,
/cos/... skill calls, and INLINECODE58 - Print only the upstream body for the
skills subcommand - Pretty-print JSON response bodies
- Print
<empty response body> for empty responses - Return a non-zero exit code for unsuccessful HTTP responses or CLI argument errors
Work locally in this repo
Use the local build when working inside this repository:
CODEBLOCK5
Use the published command shape locally when that is more convenient:
CODEBLOCK6
Cosin CLI
使用 cosin 从终端调用 COS API 和基于 COS 的技能。
CLI 功能
cosin 现在只接受相对路径。
有三种请求风格:
- 1. skills
直接调用 https://skills.bankofuniverse.org/skills 并直接打印上游响应体。
- 2. 普通 COS API 路径,如 /v1/me
这些路径直接发送到 COS API 主机。
- 3. /cos/... 下的技能路径
这些路径在内部转换为 x402 支付并调用请求:
- 保持相同的请求路径
- 从 SKILLS
BASEURL 构建目标 URL
- 将该目标 URL 发送到 COS API 主机的 POST /agent/pay-and-call
用户不应再向 CLI 传递绝对 URL。
收集输入
运行 CLI 前收集以下输入:
- - 用于 --key 的 COS 持有者令牌
- HTTP 方法
- 以 / 开头的相对路径
- 可选的 --json JSON 数据
- 可重复的 --header 或 -H 标头
- 可选的 --base-url 覆盖普通 COS API 调用的基础 URL
如果用户未提供令牌,则询问令牌。将其视为敏感信息。
保护凭证
- - 将 --key 值视为敏感信息
- 不要打印、提交或硬编码令牌
- 将令牌保留在命令行参数中,而不是仓库文件中
运行 CLI
使用以下命令格式之一:
sh
cosin --key [--json ] [--header Name: value] [--base-url ]
cosin --key agent [status|me] [--base-url ]
cosin --key skills
重要标志:
- - --key 用于必需的持有者令牌
- --json 用于可选的 JSON 请求体
- --header Name: value 或 -H Name: value 用于可重复的自定义标头
- --base-url 覆盖直接 API 调用的默认 COS API 基础 URL
- --version 或 -v 打印已安装的 CLI 版本
- --help 或 -h 打印使用说明
子命令说明:
- - skills 不接受 --json
- skills 不接受自定义标头
- agent 不接受 --json
- agent 不接受自定义标头
支持的路径
内置目录
使用此命令发现可用技能:
sh
cosin --key skills
预期的上游技能包括:
- - /cos/crypto/chainlink/random
从基于 Chainlink 的技能端点返回随机值。
- - /cos/crypto/price/:symbol
返回支持的代币符号的最新价格。
/cos/crypto/price/:symbol 支持的符号:
- - BTC
- ETH
- HYPE
- SOL
- TRX
- USDT
- USDC
直接 COS API 调用
使用普通 API 路径直接调用 COS:
sh
cosin --key GET /v1/me
cosin --key POST /v1/orders --json {symbol:BTCUSDT}
通过 /cos/... 调用技能
当需要通过 COS 调用技能时使用 /cos/...:
sh
cosin --key GET /cos/crypto/chainlink/random
cosin --key GET /cos/crypto/price/BTC
在内部,CLI 将这些转换为发送到 COS 后端的 x402 支付并调用请求。
使用 agent 快捷方式
使用 agent、agent status 或 agent me 作为 GET /agent/me 的便捷别名。
sh
cosin --key agent
cosin --key agent status
cosin --key agent me
不要将 agent 与 --json 或自定义标头结合使用。
运行前验证输入
- - 确保路径以 / 开头
- 不要传递绝对 URL
- 使用 skills,而不是 GET /skills
- 确保 --json 是有效的 JSON
- 确保标头使用 Name: value 格式
- 对于 /cos/crypto/chainlink/random,仅使用 GET
- 对于 /cos/crypto/price/:symbol,仅使用 GET 且仅使用支持的符号
读取输出
预期 CLI 会:
- - 为普通 API 请求、/cos/... 技能调用和 agent 打印 HTTP 状态行
- 为 skills 子命令仅打印上游响应体
- 美化打印 JSON 响应体
- 为空响应打印
- 对于不成功的 HTTP 响应或 CLI 参数错误,返回非零退出码
在此仓库中本地工作
在此仓库内工作时使用本地构建:
sh
bun run build
./dist/index.js --key agent
./dist/index.js --key skills
./dist/index.js --key GET /v1/me
./dist/index.js --key GET /cos/crypto/chainlink/random
当更方便时,在本地使用已发布的命令格式:
sh
bun x cosin --key agent
bun x cosin --key skills
bun x cosin --key GET /v1/me
bun x cosin --key GET /cos/crypto/price/BTC