@compozy/client

中文文档
0.5.5发布于 2026/11/09MITTypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 3243

Experimental zero-dependency TypeScript client for CompozyOS applications

原始使用文档

@compozy/client

A zero-dependency TypeScript client for applications built on CompozyOS. Supports Node 18+, Bun, Deno, browsers, and edge runtimes. The daemon remains a separate service.

Experimental in this release: names and shapes may change in the next release without a deprecation window. Pin the exact version.

import { Compozy } from "@compozy/client";

const compozy = await Compozy.connect();
const { workspace } = await compozy.workspaces.resolveWorkspace({ body: { path: process.cwd() } });
const { session } = await compozy.sessions.createSession({
  body: { workspace: workspace.id, agent_name: "claude" },
});
const reply = await compozy.prompt({
  workspaceId: workspace.id,
  sessionId: session.id,
  message: "Summarize this repository.",
});
if (reply.kind === "stream") {
  for await (const chunk of reply.chunks) {
    if (chunk.type === "text-delta") process.stdout.write(chunk.delta);
  }
}

Node discovery checks baseUrl, COMPOZY_URL, the daemon.json in home/COMPOZY_HOME/~/.compozy, then http://127.0.0.1:2123. Browsers default to http://localhost:2123. Pass token for an app token; Node also reads COMPOZY_APP_TOKEN. All operations accept an abort signal.

Use promptResponse() in a server route to forward the AI SDK UI message stream unchanged. Read other SSE operations through events(operationId, options), which reconnects with Last-Event-ID after network or server failures. Client errors stop immediately; 20 consecutive failures stop the stream. Aborting a prompt stops reading without canceling the daemon's turn.

Prompt helpers generate a command identity when idempotencyKey is omitted. Supply the same key when retrying the same input to preserve its message identity and replay the daemon's receipt.

The Node-only @compozy/client/node entry adds Compozy.start({ home }) and close({ stopDaemon: true }). It only stops the daemon this instance started while the same home still names the owned process. Shutdown signals the retained child handle and waits for its exit, so a daemon that replaces it cannot become the stop target. The main browser entry contains no Node modules.

Generated resource methods cover JSON operations. Exported paths, operations, components, and Operation* helpers also work with other HTTP clients. There is no dependency on React or ai.

See Build an app, chat UI, and browser access for tutorials and API reference samples.

版本与发布记录

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

版本发布日期距今
0.5.5latest2026/11/091 天前
0.5.42026/11/082 天前
0.5.32026/11/064 天前
0.5.22026/11/055 天前
0.5.12026/11/046 天前
0.5.02026/11/037 天前

其他发布通道:bootstrap → 0.3.0-beta.35,beta → 0.4.0。

关于 @compozy/client 的常见问题

@compozy/client 是什么?

Experimental zero-dependency TypeScript client for CompozyOS applications

如何安装 @compozy/client?

在项目目录运行 npm install @compozy/client,或使用 pnpm add / yarn add / bun add。

@compozy/client 支持 TypeScript 吗?

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

@compozy/client 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@compozy/client 需要什么版本的 Node.js?

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

@compozy/client 可以商用吗?

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

@compozy/client 的下载量有多少?

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

@compozy/client 还在维护吗?

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