@b4run/cli

中文文档
0.15.8发布于 2026/10/31MITTypeScriptES Module构建来源已验证近 30 天下载 4221

Command-line development, testing, build, and runtime tools for B4.run applications.

原始使用文档
文档目录8 节
  1. Install
  2. Example
  3. Runtime and stability
  4. Usage reporting
  5. Related
  6. Maturity and support
  7. License
  8. Shared Postgres execution

B4.run

@b4run/cli

Command-line development tools and runtime embedding entry points for B4.run applications.

Use this when: You are developing, checking, testing, building, serving, or embedding a B4.run runtime.

The B4.run navlog demo: a VFR flight plan with its navlog sheet in the Workbench. Opens the demo video.
▶ Watch the 50-second navlog demo

Install

Requires Node.js 24 or later. create-b4-app adds the CLI to a new app for you. To add it to an existing app, install it as a regular dependency, not a dev dependency, because the server that b4 build emits imports @b4run/cli at runtime:

npm install @b4run/cli

Example

Run the local b4 binary through npx or a package.json script:

npx b4 dev
npx b4 check
npx b4 test
npx b4 build
CommandWhat it does
b4 devStarts the local development runtime with hot reload on 127.0.0.1.
b4 checkValidates the app's structure and configuration.
b4 verifyChecks the app, routes, generated types, dependencies, provider keys and Node version before you run or deploy.
b4 typegenRegenerates the route and tool types under .b4/.
b4 testRuns the app's colocated run.test.ts route scenarios. The starters' npm test runs vitest instead.
b4 buildGenerates deployment artifacts: a Node server, Dockerfile and LangSmith config by default.
b4 startServes the app in production, on 0.0.0.0:8000 by default.
b4 docsPrints the B4.run docs bundled with the installed CLI.

The CLI guide lists every command and flag.

b4 start serves the app without any code of your own. To let application code own the production Node listener instead, import serveRuntime from the package root:

import { serveRuntime } from "@b4run/cli"

const runtime = await serveRuntime({
  appRoot: process.cwd(),
  host: "0.0.0.0",
  port: 8000,
})

console.log(runtime.url)
// Call await runtime.close() during your host's ordered shutdown.

Runtime and stability

  • @b4run/cli and its b4 command are supported node-only application and tooling surfaces.
  • @b4run/cli/fetch is a supported edge-safe integration surface for generated fetch deployments.
  • @b4run/cli/runtime is Node-only and low-level.
  • @b4run/cli/workspace is Node-only and low-level: managed-workspace lifecycle for a host process, without the command program.
  • @b4run/cli/testing is a deprecated, back-compat-only node-only alias of @b4run/sdk/testing; it remains supported only for existing imports, and new scenario code should use the SDK subpath.

serveRuntime() starts once and does not watch files or run type generation at boot. Use b4 dev for the development watcher and generated types.

Usage reporting

The development-time commands (dev, build, add, check, typegen, verify, eval) report an anonymous usage signal when they finish: the command name, CLI version, Node major version, operating system, outcome, a coarse duration bucket, and an error class on failure. b4 dev also reports one activation signal the first time an AG-UI run finishes in a session, carrying only the CLI version and the route kind. b4 start, the runtime packages, and create-b4-app never report, and nothing about your routes, models, prompts, paths, or identity is sent. The first reporting command prints a one-time notice to stderr and creates a random id in ~/.b4/usage-id. CI and hosted build environments (GitHub Actions, Vercel, Render, Cloudflare Pages, and others) are silent automatically; see b4.run/privacy for details.

VariableEffect
B4_TELEMETRY_DISABLED=1Turns usage reporting off.
DO_NOT_TRACK=1Turns usage reporting off.
B4_SIGNALS_URLOverrides the URL signals are posted to.

B4_SIGNALS_URL is read from the shell environment once at startup, never from a project .env. The two opt-out variables are honoured from the shell before anything happens, and from a project .env for every send; a project .env loads after the command starts, so on the very first run the id file and the notice can still appear before it takes effect.

Maturity and support

B4.run is pre-1.0, and its public surface can change. All publishable B4.run packages release together as a fixed group; review the @b4run/cli changelog and upgrading guide before upgrading. For support, use GitHub Discussions; report defects in GitHub Issues.

License

MIT. See the repository license.

Shared Postgres execution

Generated Vercel and Hono Postgres deployments coordinate run ownership across instances. Another request executing the same thread receives HTTP 409 run_in_flight with Retry-After: 1; a browser-tool continuation holds the same ownership boundary while accepting results and resuming the graph. Successful terminal events are sent after final writes and ownership release, so a client can immediately submit the next turn.

For custom fetch embeddings, provide one RequestStores.runAdmission per request and construct its checkpoint, thread, permission and client-tool stores with the admission's fenced pool. See the Postgres storage package for the API and transaction limits. Sharing durable stores alone does not coordinate execution; the default in-memory registry is local to one handler. This does not add distributed AP cancellation or exactly-once external tool effects.

版本与发布记录

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

版本发布日期距今
0.15.8latest2026/10/317 天前
0.15.72026/10/2810 天前
0.15.52026/10/2712 天前
0.15.42026/10/2612 天前
0.15.22026/10/2514 天前
0.15.12026/10/2414 天前

关于 @b4run/cli 的常见问题

@b4run/cli 是什么?

Command-line development, testing, build, and runtime tools for B4.run applications.

如何安装 @b4run/cli?

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

@b4run/cli 支持 TypeScript 吗?

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

@b4run/cli 支持 ESM 还是 CommonJS?

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

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

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

@b4run/cli 可以商用吗?

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

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

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

@b4run/cli 还在维护吗?

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