Node SDK 集成

在自己的 Node 应用中使用相同账号、Run 客户端与扩展请求构造器。

在项目中安装#

终端
npm install https://zioon.tech/downloads/zioon-cli-0.2.0.tgz
npx zioon auth login zioon-cloud

包的模块名为 @zioon/cli,可在 Node.js 22.5 或更新版本中使用。SDK 复用当前系统用户已经保存的账号登录,不返回令牌。

提交和读取任务#

run.mjs
import { createAccountRuntimeClient } from "@zioon/cli";

const { runtime } = await createAccountRuntimeClient();
const { runId } = await runtime.createRun({
  prompt: "整理这次发布需要准备的材料。"
});
const run = await runtime.followRun(runId, (event) => {
  console.log(event.type);
});
console.log(run.status, run.output);
if (run.status !== "completed") process.exitCode = 1;

runtimeProfile 可选择已有端点;baseUrl 可指定另一个已经单独登录的 Runtime。SDK 需要现有授权,不在程序启动时自动完成网页登录。

调用账户扩展#

extension.mjs
import { createAccountRuntimeClient, extensionRunRequest } from "@zioon/cli";

const { runtime, extensions } = await createAccountRuntimeClient();
const snapshot = await extensions.snapshot();
const entry = snapshot.entries.find((item) => item.id === "LISTING_ID");
if (!entry?.installation?.config) throw new Error("Install and configure the extension first");
const request = extensionRunRequest(entry, "call", {
  tool: "hello", arguments: { name: "Zioon" }
});
const { runId } = await runtime.createRun(request);
const run = await runtime.followRun(runId, () => {});
console.log(run.status, run.output);

完整 Runtime 插件使用 runtimePluginToolRequest(pluginId, discoveredTool, args, profileId)。discoveredTool 必须来自真实工具目录,并属于所选插件。

SDK 的范围#

当前提供 Node ESM 客户端、扩展请求构造器与 Run 流订阅函数。SDK 认证层用于 Node CLI 环境;浏览器应用使用现有网页登录与获准接口,不把本机凭据文件打包进页面。

更多端点与失败状态见 HTTP API。

最后核对:2026-10-28 · 能力以实际部署与账号权限为准

搜索文档

输入关键词,查找操作说明。

↑ ↓ 选择 · Enter 打开全部文档 →