@finalai/agents

中文文档
0.6.2发布于 2026/11/01Apache-2.0TypeScriptES Module

Agent authoring, client APIs, and CLI.

原始使用文档

@finalai/agents

SDK for defining, publishing, and using agents. Authoring helpers are implemented in @finalai/agent-definition; Final-specific bindings come from @finalai/final-agent-provider.

import { defineAgent } from '@finalai/agents';
import { serverlessPi } from '@finalai/agents/harnesses';

export default defineAgent({
  name: 'Assistant',
  harness: serverlessPi({
    credentials: { payer: 'agent-owner', tryInOrder: [{ kind: 'platform' }] },
  }),
});

Use @finalai/agents/client for definitions, sessions, conversations, approvals, attachments, schedules, sandbox access, and realtime. Use final-agents --help for CLI commands. Compilation requires Node 26 and ships its assets through agent-definition.

Credential-chain declarations select which credentials an agent may use and in which order. Set the payer policy explicitly in the harness configuration.

For custom provider implementations, import contracts from @finalai/agent-provider, sandbox adapters from @finalai/agent-provider/sandbox, and conformance tools from @finalai/agent-provider/conformance. Run a harness check with final-agents conformance ./harness.ts.

Use FINAL_API_HOST with FINAL_API_KEY to select a deployment once for build and publish; an explicit --host overrides it. Use defineHostedConnection for a named connection resolved by hosting at session start. defineFinalConnection() uses the same path with the final binding. Explicit URL declarations remain static. See the repository's hosting guide for provider contexts, resource lookup, and the required hosting integration.

版本与发布记录

@finalai/agents 共发布 21 个版本,首次发布于 2026/10/15;过去 12 个月发布了 21 个版本。

版本发布日期距今
0.6.2latest2026/11/012 天前
0.6.12026/11/012 天前
0.6.02026/10/313 天前
0.5.02026/10/286 天前
0.4.42026/10/277 天前
0.4.32026/10/2311 天前

关于 @finalai/agents 的常见问题

@finalai/agents 是什么?

代理编写、客户端api和CLI。

如何安装 @finalai/agents?

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

@finalai/agents 支持 TypeScript 吗?

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

@finalai/agents 支持 ESM 还是 CommonJS?

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

@finalai/agents 需要什么版本的 Node.js?

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

@finalai/agents 可以商用吗?

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

@finalai/agents 还在维护吗?

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