@agentproto/driver-cli

中文文档
0.3.1发布于 2026/11/01Apache-2.0TypeScriptES Module构建来源已验证近 30 天下载 4930

agentproto/cli-runtime — AIP-29 CLI provider specialisation. Sugar over @agentproto/driver for command-line binaries: argv templating, subprocess invocation, exit-code mapping, output parsing. v0.1 ships subprocess invocation; OS-level sandbox enforcement

原始使用文档
文档目录3 节
  1. Working directory
  2. Completion, timeouts, and orphaned children
  3. Spec

@agentproto/driver-cli

Reference implementation of the CLI provider specialisation over AIP-30 DRIVER.md defineDriver — defineCliDriver wraps a binary as a conformant provider: argv templating against ${input.X} / ${secrets.X}, subprocess spawn, exit-code → semantic error mapping, and text/JSON output parsing.

import { defineCliDriver } from "@agentproto/driver-cli"

const ghCli = defineCliDriver({
  id: "gh-cli",
  name: "GitHub CLI",
  description: "Wraps gh for PR operations.",
  kind: "cli",
  bin: "gh",
  implements: [
    {
      tool: "./tools/create-pr/TOOL.md",
      version: "^1",
      metadata: { cli: { argv: ["pr", "create", "--title", "${input.title}"] } },
    },
  ],
})

Working directory

CliDriverDefinition.cwd (optional, absolute) sets the spawned subprocess's working directory. Left unset, the subprocess inherits whatever directory the host process happens to be running in — correct for a standalone TS-authored driver invoked directly, but not what an app-bundled DRIVER.md usually means.

Relative paths in an app-bundled cli driver resolve against the app root, not the daemon's own cwd. When this driver is loaded from an app bundle via @agentproto/app's loadAppBundledTools, cwd is set to the app root (the directory containing .agentproto/) automatically, unless the DRIVER.md's metadata.cli.cwd overrides it — itself resolved relative to the app root, and rejected at load time if it would resolve outside the app root.

Completion, timeouts, and orphaned children

A call completes on the spawned subprocess's own exit, never on its stdio close — the direct child's exit only depends on its own lifetime, while close also waits for its stdout/stderr pipes to close. A binary that spawns its own child with inherited or piped stdio (e.g. headless Chrome) can leave an orphan holding that pipe open long after the binary's real work is done (the orphan may even be reparented to pid 1), which would hang close forever even though the tool call itself succeeded. A short drain window after exit still gives any already-in-flight stdio a chance to land before the streams are torn down.

The subprocess is spawned detached (its own process group). On the run's cancel signal aborting, or on a caller-side timeout (see @agentproto/workflow-runtime's per-step timeout_ms, which wraps every tool step dispatch — this package has no timeout of its own), the WHOLE process group is killed via process.kill(-pid) (SIGTERM, escalating to SIGKILL if a survivor remains after a short grace period) — not just the direct child — so an orphan sharing that group doesn't outlive the call.

Spec

See AIP-29 for the CLI provider specialisation and AIP-30 for the base defineDriver contract. This package is the TypeScript reference implementation.

版本与发布记录

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

版本发布日期距今
0.3.1latest2026/11/016 天前
0.3.02026/10/2711 天前
0.2.52026/10/1919 天前
0.2.42026/10/1029 天前
0.2.32026/10/0929 天前
0.2.22026/09/301 个月前

关于 @agentproto/driver-cli 的常见问题

@agentproto/driver-cli 是什么?

agentproto/cli-runtime — AIP-29 CLI provider specialisation. Sugar over @agentproto/driver for command-line binaries: argv templating, subprocess invocation, exit-code mapping, output parsing. v0.1 ships subprocess invocation; OS-level sandbox enforcement

如何安装 @agentproto/driver-cli?

在项目目录运行 npm install @agentproto/driver-cli,或使用 pnpm add / yarn add / bun add。

@agentproto/driver-cli 支持 TypeScript 吗?

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

@agentproto/driver-cli 支持 ESM 还是 CommonJS?

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

@agentproto/driver-cli 可以商用吗?

@agentproto/driver-cli 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@agentproto/driver-cli 的下载量有多少?

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

@agentproto/driver-cli 还在维护吗?

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