@antseed/ant-agent

中文文档
0.1.36发布于 2026/10/27TypeScriptES Module零依赖近 30 天下载 3503

Ant Seed的蚂蚁代理运行时间——将知识货币化为只读,知识强化的AI代理

中文使用文档
文档目录10 节
  1. 如何运作
  2. 代理目录结构
  3. 探员. json
  4. 使用量
  5. 程序化
  6. 国 际
  7. 知识加载
  8. 自定义工具
  9. 程序工具
  10. 注射什么药

@ antseed/ ant- agent (英语)

Ant Seed的蚂蚁代理运行时间. 让种子跑跑者将知识货币化,方法是将任何提供者包装成一个人物、护栏、点播知识模块和定制工具.

蚂蚁剂是 只读,知识强化的AI服务. 它不代表用户行事——它利用创作者包并维护的被整理出的专门知识来回答问题.

如何运作

  1. 创建者定义代理: persona + guardrails + 知识模块( markdown 文件)
  2. 根据买方的每一项请求,个人、护栏和 antseed_load_knowledge 输入工具
  3. LLM 决定何时加载知识——它使用模块名称调用工具并接收内容
  4. 代理环路执行内部工具调用并重新提示, 直到 LLM 生成最终文本响应
  5. 买方得到干净的流程反应——没有内部工具或循环文物

当没有定义知识模块时,没有注入工具,并且是单调的注射(只使用人称+护栏).

代理目录结构

my-agent/
  agent.json           # manifest
  persona.md           # who the agent is
  knowledge/           # knowledge modules
    linkedin-posting.md
    content-strategy.md
  tools/               # custom tool scripts (optional)
    fetch-trends.js

探员. json

{
  "name": "social-media-advisor",
  "persona": "./persona.md",
  "guardrails": [
    "Never write posts without explicit request",
    "Always disclose AI-generated content when asked"
  ],
  "knowledge": [
    {
      "name": "linkedin-posting",
      "description": "Creating and optimizing LinkedIn posts",
      "file": "./knowledge/linkedin-posting.md"
    },
    {
      "name": "content-strategy",
      "description": "Content calendars and strategy frameworks",
      "file": "./knowledge/content-strategy.md"
    }
  ],
  "tools": [
    {
      "name": "fetch_trends",
      "description": "Fetch trending topics for a platform",
      "parameters": {
        "type": "object",
        "properties": { "platform": { "type": "string" } },
        "required": ["platform"]
      },
      "execute": "./tools/fetch-trends.js"
    }
  ]
}
外地需求说明
name对代理名称
persona没有使用代理系统的标记下文件的路径 :
guardrails没有代理商必须遵守的硬规则
knowledge没有需求加载的知识模块阵列
knowledge[].name对模块的独特标识符
knowledge[].description对简短说明——向LLM显示以确定相关性
knowledge[].file对包含全部内容的标记下文件路径
tools没有LLM 可调用的自定义工具阵列
tools[].name对工具名( 自动前缀为 antseed_(中文(简体) )
tools[].description对向 LLM 显示描述
tools[].parameters没有JSON Schema 工具参数( 默认为空对象)
tools[].execute对导入默认函数的 JS 文件路径
confidentialityPrompt没有自定义保密指令( 有合理的默认)

使用量

程序化

import { loadAntAgent, AntAgentProvider } from '@antseed/ant-agent';

// Load agent (knowledge + tools from agent.json)
const agent = await loadAntAgent('./my-agent');
const boundProvider = new AntAgentProvider(innerProvider, agent);

// Per-service agents
const socialAgent = await loadAntAgent('./social-agent');
const codingAgent = await loadAntAgent('./coding-agent');
const boundProvider = new AntAgentProvider(innerProvider, {
  'social-model-v1': socialAgent,
  'coding-model-v1': codingAgent,
  '*': socialAgent,
});

node.registerProvider(boundProvider);

国 际

添加 agentDir 给你的蚂蚁配置。 单个代理(所有服务)使用字符串,或每个服务代理的地图:

{
  "seller": {
    "agentDir": "./my-agent"
  }
}

服务人员:

{
  "seller": {
    "agentDir": {
      "social-model-v1": "./agents/social",
      "coding-model-v1": "./agents/coding",
      "*": "./agents/default"
    }
  }
}

这个 "*" 键是对没有明确代理的服务的一种倒置。 没有匹配代理的服务没有变化.

然后运行 antseed seller start 和往常一样.

知识加载

在界定知识单元时 antseed_load_knowledge 工具与任何购买工具一起注入请求中。 工具描述包括一个可用模块名称和描述的目录.

LLM根据对话决定要加载哪些模块. 它可以:

  • 装入一个模块,获取内容,然后回复
  • 通过连续的工具调用加载多个模块
  • 如果问题不需要专业知识,直接回答而不装入任何模块

这使背景保持重点——只有LLM法官的相关知识才能被加载. 买家问起LinkedIn不会得到X/Twitter知识 膨胀上下文.

自定义工具

除了知识加载,创建者还可以添加LLM在代理循环期间可以调用的自定义工具. 定义工具 agent.json 带有 execute 字段指联署文件:

{
  "tools": [{
    "name": "fetch_trends",
    "description": "Fetch trending topics for a platform",
    "parameters": {
      "type": "object",
      "properties": { "platform": { "type": "string" } },
      "required": ["platform"]
    },
    "execute": "./tools/fetch-trends.js"
  }]
}

JS 文件导出一个接收工具参数并返回字符串的默认函数:

// tools/fetch-trends.js
export default async function(args) {
  const res = await fetch(`https://api.example.com/trends/${args.platform}`);
  return await res.text();
}

工具名自动前缀 antseed_ 注射时(例如, fetch_trends 变成 antseed_fetch_trends) (中文(简体) ). LLM 可以看到所有内部工具与买入工具, 并附有系统快速使用指令 antseed_* 仅按要求提供用于上下文收集和购买工具的工具.

如果一个工具的执行函数抛出,错误消息会作为出错结果返回到LLM,这样它就可以优雅地恢复.

程序工具

工具也可以通过选项参数在程序上添加(当工具需要访问运行时状态) :

import { AntAgentProvider, loadAntAgent, type AntAgentTool } from '@antseed/ant-agent';

const customTool: AntAgentTool = {
  name: 'lookup_user',
  description: 'Look up user details',
  parameters: { type: 'object', properties: { id: { type: 'string' } }, required: ['id'] },
  execute: async (args) => db.users.findById(args.id),
};

const agent = await loadAntAgent('./my-agent');
new AntAgentProvider(innerProvider, agent, { tools: [customTool] });

明确的工具和方案工具合并在一起.

注射什么药

系统提示器按此顺序组装:

  1. 个人a - 代理人的身份和专门知识
  2. 工具集指令 ——告诉LLM如何使用 antseed_ 工具对购买工具(仅在存在知识模块的情况下)
  3. 护栏 - 硬规则
  4. 及时保密 ——防止LLM披露注入内容

此外, antseed_* 将工具与买方提供的任何工具一起添加到请求的工具清单中。 包括内置 antseed_load_knowledge (在定义知识模块时)和任何通过选项传递的自定义工具.

买方自身的系统即时(如果有的话)在代理人内容后保留.

版本与发布记录

@antseed/ant-agent 共发布 23 个版本,首次发布于 2026/04/05;过去 12 个月发布了 23 个版本。

版本发布日期距今
0.1.36latest2026/10/2711 天前
0.1.352026/08/122 个月前
0.1.342026/04/266 个月前
0.1.332026/04/266 个月前
0.1.322026/04/266 个月前
0.1.312026/04/236 个月前

关于 @antseed/ant-agent 的常见问题

@antseed/ant-agent 是什么?

Ant Seed的蚂蚁代理运行时间——将知识货币化为只读,知识强化的AI代理

如何安装 @antseed/ant-agent?

在项目目录运行 npm install @antseed/ant-agent,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@antseed/node(>=0.1.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@antseed/ant-agent 支持 TypeScript 吗?

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

@antseed/ant-agent 支持 ESM 还是 CommonJS?

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

@antseed/ant-agent 可以商用吗?

@antseed/ant-agent 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@antseed/ant-agent 的下载量有多少?

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

@antseed/ant-agent 还在维护吗?

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