@codespar/cli

中文文档
0.22.6发布于 2026/11/02MITES Module构建来源已验证近 30 天下载 2675

CodeSpar CLI. The agentic OS for money movement in Latin America, from your terminal: authenticate, browse servers, mint mandates, execute tools, manage sessions, stream logs.

原始使用文档
文档目录10 节
  1. Install
  2. Usage
  3. Commands
  4. Global flags
  5. Where the commands come from
  6. Configuration
  7. Templates
  8. Starter-kit templates
  9. Need more?
  10. License

@codespar/cli

Command-line interface for CodeSpar — authenticate, browse servers, execute tools, manage sessions, stream logs, and scaffold projects from your terminal.

Install

npm install -g @codespar/cli

Usage

# Authenticate (stores API key in ~/.codespar/config.json)
codespar login

# Browse the catalog
codespar servers list
codespar tools list --server asaas

# Run a single tool call
codespar execute codespar_pay \
  --server asaas \
  --input '{"method":"pix","amount":15000,"currency":"BRL"}'

# Give an agent a unified multi-currency wallet under ONE signed mandate:
# a Pix (BRL) slot and a USDC slot, each with its own per-currency cap. No FX.
codespar mandate create --consumer shopper --agent buyer \
  --payee https://x402.codespar.dev/api/market-data,11144477735 \
  --slot BRL:pix:50000:1500 \
  --slot USDC:usdc:100:100

# See the wallet, rolled up per currency
codespar wallet shopper

# The same mandate pays a 402-protected API in USDC (gated by the USDC per-tx cap)
codespar spend --mandate <id> --amount 1 --agent buyer \
  --payee https://x402.codespar.dev/api/market-data

# Move value between slots (per-currency, no FX — a cross-currency move is a real
# ramp trade at the real rate). Omit --execute to just plan it.
codespar transfer shopper --from BRL --to USDC --amount 15000

# Every published meta-tool is invocable by name; the actions come from the
# published definition, so an unknown one is refused before anything is sent
codespar tools meta
codespar tool codespar_wallet --action balance --arg consumer_id=con_0000
codespar pay --action status --arg reference=pay_0000

# Resource groups are derived from the served OpenAPI document: each
# subcommand is one operation, its path parameters are the positionals
codespar sellers status slr_0000
codespar wallets list --query status=active
codespar triggers create --input '{"url":"https://example.test/hook","events":["payment.settled"]}'
codespar boletos list con_0000

# Manage sessions and logs
codespar sessions list
codespar logs tail --server stripe

# Scaffold a new agent
codespar init my-agent

Commands

CommandDescription
loginSave API key to ~/.codespar/config.json
logoutClear the stored API key
whoamiShow the organization, project and key the credential resolves to
servers listList servers (filter by --category, --region)
servers show <id>Show a server's details and tools
tools listList tools (filter by --server)
tools show <name>Show a tool's full input/output schema
tools meta [name]The 15 published meta-tool definitions — actions, required input, vocabularies
tool <name>Invoke any published meta-tool: --action, --arg key=value, --input
pay / kycShorthand for tool codespar_pay / tool codespar_kyc
consumers <sub>Consumers: profile, Pix keys, Pix lookups, receipts, contact verification
boletos <sub>DDA: subscribe a document, list the boletos it receives
sellers <sub>Sellers: onboarding status, custody, pending settlement, ledger
mcp-servers <sub>Tenant MCP servers: register, validate, patch a tool, sweep platform fees
wallets <sub>Wallets: balances, ledger, funding sources, execute, transfer, custody
triggers <sub>Triggers (webhooks): endpoints, deliveries, DLQ, secret rotation, redelivery
execute <tool>Run a single tool call in a throwaway session
discover <query>Search the catalog for tools matching a use case
agent run <dir>Run one turn of an agent directory built on @codespar/agent-core (--input, --approve/--deny) through its own npm start; same output, same exit code
eval <dir>Run the agent's npm run check + npm run eval (adversarial suite and scenarios), one line per case; exit 1 on any failure
mandate createCreate a consumer mandate — the agent's allowance. --slot CURRENCY:METHOD:CAP:PER_TX (repeatable, e.g. BRL:pix:50000:1500) for a unified multi-currency wallet; per-currency caps, no FX
mandate revoke <id>Revoke a consumer mandate (POST /v1/mandates/{id}/revoke); active or paused → revoked, terminal. --reason goes to the evidence row
wallet <consumer>Show the consumer's unified wallet, rolled up per currency
transfer <consumer>Move value between wallet slots (--from --to --amount [--execute]); a cross-currency move is a real ramp trade at the real rate, no FX
spendExecute an agentic spend against a mandate (x402 / USDC / Pix, routed by payee)
chargeIssue an inbound charge via codespar_charge
shipGenerate label / quote rates / track via codespar_ship
ledgerPost entries / read balances / create accounts via codespar_ledger
issueIssue / freeze / read agent spend cards via codespar_issue
payment-status <id>Poll async settlement status (add --stream)
verification-status <id>Poll async KYC status (add --stream)
wizard [server]Connection wizard — required secrets, connect URL, next steps
sessions listList recent sessions (filter by --status, --limit)
sessions show <id>Show session details (add --logs for tool calls)
sessions close <id>Close an active session
connect listList active Connect Links per user
connect start <server>Start an OAuth Connect Link flow (add --open)
connect revoke <server>Revoke a connection
logs tailStream tool-call logs in real time (SSE)
audit replayAsk the API whether the audit chain is verified over an interval (--from/--to, ISO 8601) and render the verdict; the chain check runs server-side, exit 1 when the verdict is not verified
init <name> [--template <slug>]Scaffold a new commerce agent from a template; init --list shows them

Global flags

FlagDescription
--jsonMachine-readable JSON output (pipe into jq)
--api-key <key>Override the stored key
--base-url <url>Point at a custom API (staging, self-hosted)
--project <id>Scope requests to a project (multi-project orgs)

Resource-group subcommands also take -q, --query key=value (repeatable), --timeout <ms>, and — when the operation declares a request body — -i, --input '<json>' or -f, --input-file <path>. Each subcommand's --help lists the query parameters the document marks required (for example owner on codespar shop instruments) and ends with one example that names every positional, every required -q key and the body flag.

Where the commands come from

The resource groups and the meta-tool commands are not written one by one. codespar sellers, consumers, boletos, mcp-servers, wallets and triggers are derived from API_OPERATIONS — the operation table @codespar/sdk generates from the served OpenAPI document — so a subcommand is one operation, and the request behind it is the one the document declares. codespar tool <name> reads the 15 shared meta-tool definitions from @codespar/types: the names, the actions and the required input are the published ones, checked before anything is sent.

A resource family with no command needs a written exception with a date (src/surface.ts), and the coverage test refuses to let that list grow.

Configuration

Resolution order (first match wins):

  1. Command-line flags (--api-key, --base-url, --project)
  2. Environment variables (CODESPAR_API_KEY, CODESPAR_BASE_URL, CODESPAR_PROJECT)
  3. Config file at ~/.codespar/config.json (chmod 600)

Templates

codespar init --list prints this table from the package itself, with a one-line description per template.

SlugStack
pix-agentNode + OpenAI — minimal Pix charge + WhatsApp notify
ecommerce-checkoutNode + Claude — full Complete Loop
streaming-chatNext.js + Vercel AI — token-by-token streaming
multi-tenantNext.js + OpenAI — one API key, N tenants
bills-agentStarter kit — The consumer delegates the month's bills to an agent that pays under a signed mandate: per-payment cap, monthly cap, named payees, expiry. Every payment returns a receipt.
checkout-agentStarter kit — The merchant's agent that sells in the conversation: the customer builds a cart the code prices, the attendant (or the sales policy) confirms the order, one bolepix is issued with an idempotency key, the QR and the copy-and-paste go to the customer, and the order closes on commerce.charge.paid.
collections-agentStarter kit — The merchant's agent that collects: agrees terms with the payer inside a negotiation envelope, issues one bolepix per instalment with an idempotency key, presents the QR and the copy-and-paste in the conversation, and closes the cycle on commerce.charge.paid or commerce.charge.expired.
hello-agentStarter kit — The worked example of the codespar-agent-builder skill: a read-only agent that reads the month's bills and cannot pay. Built from the five files, the packs and one kit module.
supplier-payments-agentStarter kit — A company delegates its suppliers, commissions and payroll to an agent that pays them in batches under one signed mandate. A batch is a loop of executions: one refusal does not stop the others, and re-running it pays nobody twice.

The kit rows between those markers are written by npm run sync:kit-templates from each agent's own description. Do not edit them by hand: the next sync overwrites them, which is the point — a hand-kept list goes stale on the next agent that lands.

Starter-kit templates

The kit templates are the agents of codespar/agent-starter-kits, copied into this package at release time — every agent the synced ref carries, discovered rather than listed, which is why the table above is generated. init never fetches them: what it scaffolds is what the published tarball carries, so it works offline and two installs of the same CLI version scaffold the same bytes.

codespar init my-bills --template bills-agent
cd my-bills
cp agents/bills-agent/.env.example agents/bills-agent/.env   # then fill in your keys
npm install
npm run consent -- --yes
npm start

The scaffold mirrors the kits repository: agents/<name>/ and the kits-local packages that agent needs are the kits' own files, byte for byte, under a generated root package.json that links them as npm workspaces. None of those packages is published on npm — @codespar/agent-core and, since the runner was split out of it, @codespar/agent-runtime, which owns the codespar-agent bin every agent script calls — so they travel vendored and the agent's own pins resolve to those copies exactly as they do in the kits repository. Which ones to vendor is walked from the agent's dependencies, transitively, and a build that would leave one behind is refused rather than shipped: a pin with no directory behind it sends npm install to the registry for a package that was never published there. Nothing inside the kit is rewritten: agent.yaml keeps the kits' cli: and mcp: pins, and every relative path (../../tsconfig.base.json, the .env the agent reads from its own directory, the paths its README names) keeps resolving.

The template's own root scripts are narrowed to the one agent, and its check is deliberately NOT the kits root's: the kits root runs repo-level gates over files a single-agent template does not carry.

templates/kits.lock.json records which kits ref was synced (tag or commit), the commit it resolved to, and a content hash per template. The release gate (npm run check:kit-templates, run in CI and in the publish workflow) fetches that ref again, rebuilds the templates and fails if the packaged trees differ from the lock by a byte — a hand-edited template or a lock bumped without a sync does not ship.

To bump the kits to a new tag or commit, from packages/cli:

npm run sync:kit-templates -- --ref <tag-or-sha>   # rewrites templates/<kit>/, the lock and the README rows
git add templates README.md && git commit

A bump can bring agents that did not exist before, so it can add templates; the sync writes the table above and the lock, and codespar init --list reads the lock. Run the e2e job (CODESPAR_CLI_KIT_E2E=1) on a bump: it is the only gate that proves a freshly generated template still installs and passes its own npm run check, for every template the lock names.

then bump this package's version (new template content is at least a minor). Without --ref the sync re-runs at the locked ref, which is the way to regenerate the trees after a change to the sync script itself.

Need more?

Need governance, budget limits, and audit trails for agent payments? CodeSpar Enterprise adds policy engine, payment routing, and compliance templates on top of these MCP servers.

License

MIT — codespar.dev

版本与发布记录

@codespar/cli 共发布 41 个版本,首次发布于 2026/04/20;过去 12 个月发布了 41 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.22.6latest2026/11/027 天前
0.22.52026/11/019 天前
0.22.42026/10/3010 天前
0.22.22026/10/2813 天前
0.22.12026/10/2713 天前
0.22.02026/10/2714 天前

关于 @codespar/cli 的常见问题

@codespar/cli 是什么?

CodeSpar CLI. The agentic OS for money movement in Latin America, from your terminal: authenticate, browse servers, mint mandates, execute tools, manage sessions, stream logs.

如何安装 @codespar/cli?

在项目目录运行 npm install @codespar/cli,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 codespar,可以用 npx codespar 直接运行。

@codespar/cli 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/codespar__cli 是否存在。

@codespar/cli 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@codespar/cli 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@codespar/cli 可以商用吗?

@codespar/cli 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@codespar/cli 的下载量有多少?

根据 npm 官方下载统计,@codespar/cli 在 2026/10/10 – 2026/11/08 这 30 天内被下载 2,675 次,日均约 89 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@codespar/cli 还在维护吗?

最新版本 0.22.6 发布于 2026/11/02(7 天前);至今共发布 41 个版本,其中过去 12 个月发布了 41 个;首次发布于 2026/04/20。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。