@cef-ai/cli

中文文档
4.2.0发布于 2026/10/30TypeScriptES Module近 30 天下载 3918

cef — build, typegen, and inspect agents from the command line. Mirrors the Agent Runtime contract (ADR-001): bundles install a flat handler map at globalThis.__handlers, manifests carry the routing table the orchestrator reads.

原始使用文档
文档目录10 节
  1. Install
  2. Subcommands
  3. DDC credentials ( cef push , cef widget push , cef cubby pu…
  4. Cubbies a pushed agent declares
  5. Quickstart
  6. Publishing into an organization vault
  7. Programmatic API
  8. Build-time lints
  9. Companion packages
  10. References

@cef-ai/cli

cef — build, typegen, and inspect agents from the command line. Mirrors the Agent Runtime contract (ADR-001): bundles install a flat handler map at globalThis.__handlers, manifests carry the routing table the orchestrator reads.

Install

pnpm add -D @cef-ai/cli

This adds the cef binary to node_modules/.bin. In a workspace project, invoke it via pnpm exec cef <subcommand>.

Subcommands

SubcommandStatusDescription
cef init [dir]shippedScaffold a hello-world agent project (agent + cubby + widget + test), depending on the published @cef-ai/* packages. Interactive with --yes/flags; writes AI-friendly files that auto-wire the cef Claude Code plugin (--no-ai to skip).
cef deployshippedMake an agent live: apply the repo's deployments/ folder (or a single set file) to the platform. --endpoint <url> (or $CEF_ENDPOINT; defaults to dev), --deployments <file|dir>, --version, --as-pubkey, --dry-run. Requires deployment records + reachability to the endpoint.
cef buildshippedLint the agent entry, bundle with esbuild (the bundle imports the SDK runtime shims and installs globalThis.__handlers), emit dist/<agentId>/{bundle.js,manifest.json}.
cef typegenshippedGenerate .cef/generated.d.ts (declaration-merged KnownEventTypes) and refresh cef.lock.json.
cef inspect <agentDir>shippedRead a built manifest.json, run the bundle in node:vm, and report the handler names exposed on __handlers plus any routing targets the manifest references but the bundle doesn't expose.
cef publishshippedPOST a built agent's card to the marketplace API (--as-pubkey, --access-token/$CEF_ACCESS_TOKEN — the same CLI access token cef deploy uses).
cef pushshippedUpload an agent to DDC. --kind internal (the default) uploads a built agent's bundle.js (+ widget dirs) and stamps the manifest's bundle ref — directly into a bucket you control (--bucket), or through vault-api into an organization vault's scope (--vault <id> --vault-scope <scope>). --kind external registers an agent that runs outside the platform, from its A2A Agent Card: fetches the card, derives a manifest (kind: "external", a2aCard: <url>, no bundle) and writes it to the same bucket registry. External flags: --card <url>, --alias, --agent-version, --scope, --idle-timeout.
cef eval <sub>shippedWorkflow evaluations, one workflow at a time (--workflow, default: the one cef.config.ts or dist/ declares). datasets, create <dataset>, pull <dataset> / push <dataset> (repo datasets/<dataset>/ ↔ the vault; push --cut, --force, --prune, --restore; pull --force), run <dataset> (--workflow-version, --dataset-version, --repeats, --baseline, --resume), experiments [dataset], compare <a> <b>. Evaluations live in the vault the workflow runs in (--vault/$CEF_VAULT_ID, default the wallet's own), in its scope (--scope, default its requiredScopes); needs a wallet (--keystore/--password or --secret-phrase) or --access-token/$CEF_ACCESS_TOKEN, and the vault's grant on that scope. run also needs --as-pubkey/$CEF_AS_PUBKEY. See @cef-ai/eval.
cef teststubPlaceholder — use vitest directly with @cef-ai/testing until the integrated runner lands.
cef devstubPlaceholder — pending the packaged platform image.

cef build writes one directory per declared agent:

dist/
  <agentId>/
    bundle.js      # IIFE that installs globalThis.__handlers — a flat map
                   # of handler functions the runtime dispatches as
                   # __handlers[name](event, context). Event handlers are
                   # keyed "<engagementId>::<method>"; lifecycle hooks under
                   # the fixed keys onStart / onClose.
    manifest.json  # AgentManifest body — bundle embedded inline; each
                   # engagement carries handles{eventType -> handlerName}
                   # (namespaced) and hooks[] ("start"/"close"). Identity /
                   # signature fields are blank until `cef publish` signs.

The handler-name namespacing (<engagementId>::<method>) keeps the flat __handlers map collision-free when multiple engagements declare a method of the same name; the orchestrator returns these strings verbatim from HandlerFor, so AR looks them up directly. Lifecycle hooks are NOT namespaced — the orchestrator hardcodes onStart / onClose — so a method name may be reused as an event handler across engagements, but only one engagement per agent may own each lifecycle hook (cef build errors on a collision).

cef typegen reads cef.config.ts (and publishes declarations) and writes .cef/generated.d.ts, populating KnownEventTypes so authors get string-literal autocompletion on @OnEvent and ctx.publish. The cef.lock.json snapshot is rewritten on every run so VCS diffs surface typegen drift.

DDC credentials (cef push, cef widget push, cef cubby push)

Writes to the bucket are authorized by exactly one of:

  • --secret-phrase / $CEF_DDC_SECRET_PHRASE — the phrase of the key that owns the bucket.
  • --access-token / $CEF_DDC_ACCESS_TOKEN — a DDC access token granted by the bucket owner.

An access token either names no subject (a bearer token: sent as it is) or was issued to one key, its subject — the token in a ROC agent service invite is issued to the invited member. The storage node accepts a subject-bound token only on requests signed by that key, so the CLI needs its phrase too: --subject-phrase / $CEF_DDC_SUBJECT_PHRASE. The CLI checks that the phrase derives the subject (sr25519 or ed25519) before connecting, and refuses a subject-bound token without it rather than letting the node answer issuer doesn't match subject in parent token. Without that phrase, use "Copy DDC token for the CLI" on the agent service's Members panel in ROC — it signs, with your wallet, a token that names no subject beneath your invite — or ask the bucket owner for a token that names no subject.

Cubbies a pushed agent declares

A bucket push (cef push --bucket) also declares, in the bucket's cubby registry (cubbies/<alias>), every cubby the manifest carries that the registry does not name yet — at 0.1.0, the version cef cubby push uses, with the manifest's migrations. This is what ROC does on Deploy for the workflow runner's runs cubby; without it a workflow pushed only through the CLI fails at its first step with cubby: lookup schema: … Failed to get cns record. An alias the registry already names is never touched (change a declared schema with cef cubby push), and nothing is declared when the registry cannot be read. A declaration that fails to write fails the command after the agent was pushed; pushing again retries it. cef push --vault does not do this — vault-api does not declare cubbies either.

Quickstart

pnpm add -D @cef-ai/cli
pnpm exec cef build
pnpm exec cef inspect dist/<agentId>

Registering an agent that runs elsewhere is the same command with a different --kind, and needs no build step at all — there is no code of ours to compile:

pnpm exec cef push --kind external \
  --card https://ai.example/.well-known/agent-card.json \
  --bucket 1338 --as-pubkey 0x<agent-service-pubkey> --env dev

It appears in ROC's registry like any other agent, and can be connected to a vault and sent events from the sandbox.

Publishing into an organization vault

An organization vault's agents live in the vault's own registry bucket, and vault-api writes it — not the CLI. Name the vault and the scope to publish from instead of a bucket:

pnpm exec cef push --vault <vaultId> --vault-scope gtm \
  --secret-phrase "<your wallet phrase>" --as-pubkey 0x<agent-service-pubkey> --env dev

vault-api checks that you hold write on the scope (the vault owner, or a member with a member-level grant on it) and binds the agent's alias to the scope it is first published from, so another scope cannot replace it. The CLI uploads the version's files with the manifest unstamped; vault-api stamps the bundle and widget CIDs and returns the stored manifest, which cef push writes back to dist/<id>/manifest.json.

Credentials: --secret-phrase / $CEF_VAULT_SECRET_PHRASE signs with your own wallet key, derived as ed25519 (the only scheme vault-api accepts), or --vault-token / $CEF_VAULT_TOKEN sends a wallet-api token. $CEF_DDC_SECRET_PHRASE is not used here: it names a bucket owner, not you. --bucket, --access-token, --preset, --endpoint and --cdn do not apply and are refused.

A vault answers REGISTRY_NOT_CONFIGURED until its owner has recorded a registry bucket and sealed a registry delegation for it (PUT /api/v1/vaults/<vaultId>/delegations). The owner does that with "Enable agent publishing" on the organization page in ROC, or with sdk.vault.delegations.grant from @cef-ai/vault-sdk.

The kinds take disjoint flags — a bundle has no card, and a card has no dist/ — so passing one kind's flag with the other's --kind is refused by name rather than ignored. The failure it prevents is silent: --card without --kind external would otherwise push whatever was last built and report success.

Programmatic API

Every subcommand has a corresponding function exported from the package root, useful from tests and scripts:

import { cefBuild, cefTypegen, cefInspect } from "@cef-ai/cli";

const build = await cefBuild({ cwd: process.cwd(), outDir: "dist" });
for (const a of build.agents) {
  console.log(a.agentId, a.bundlePath, a.bundleBytes);
}

await cefTypegen({ configPath: "./cef.config.ts" });

const inspected = await cefInspect({
  agentDir: "dist/echo",
  print: false,
});
for (const e of inspected.engagements) {
  console.log(e.id, e.handles, e.hooks, e.exposedMethods, e.missingMethods);
}

Build-time lints

cef build runs a syntactic lint pass over the agent's entry file before bundling. Failures abort the build with a single, actionable message. The rules mirror those in @cef-ai/eslint-plugin so editor warnings agree with CI failures.

  • @OnEvent(...) argument must be a string literal.
  • ctx.publish(t, ...) first argument must be a string literal.
  • ctx.cubby("alias") argument must be a literal AND a declared alias in cef.config.ts cubbies[].alias.
  • ctx.models.X member must reference a declared model alias.
  • Imports must not target the banned module list (Node built-ins like fs, net, http, child_process, plus sync DB / network npm packages). Agents use the global fetch for HTTP and ctx.cubby for state; globalThis.crypto (WebCrypto) replaces node:crypto.

The full banned-module list and rationale live in agent-sdk.md §7.

Companion packages

References

  • Agent SDK spec: ../../../company-memory-bank/specs/platform/03-components/agent-sdk.md
  • Runtime integration contract: ../../../company-memory-bank/specs/platform/03-components/sdk-runtime-integration-contract.md

The ../company-memory-bank/... paths point at an internal sibling repo and are not browsable from a fresh clone.

版本与发布记录

@cef-ai/cli 共发布 60 个版本,首次发布于 2026/04/08;过去 12 个月发布了 60 个版本。

版本发布日期距今
4.2.0latest2026/10/3010 天前
4.1.12026/10/2911 天前
4.1.02026/10/2712 天前
4.0.02026/10/2218 天前
3.0.02026/10/2119 天前
2.9.12026/10/1723 天前

关于 @cef-ai/cli 的常见问题

@cef-ai/cli 是什么?

cef — build, typegen, and inspect agents from the command line. Mirrors the Agent Runtime contract (ADR-001): bundles install a flat handler map at globalThis.__handlers, manifests carry the routing table the orchestrator reads.

如何安装 @cef-ai/cli?

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

@cef-ai/cli 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@cef-ai/cli 支持 ESM 还是 CommonJS?

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

@cef-ai/cli 可以商用吗?

@cef-ai/cli 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@cef-ai/cli 的下载量有多少?

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

@cef-ai/cli 还在维护吗?

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