@antseed/ant-agent

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

Ant agent runtime for AntSeed — monetize knowledge with read-only, knowledge-augmented AI agents

原始使用文档
文档目录10 节
  1. How it works
  2. Agent directory structure
  3. agent.json
  4. Usage
  5. Programmatic
  6. CLI
  7. Knowledge loading
  8. Custom tools
  9. Programmatic tools
  10. What gets injected

@antseed/ant-agent

Ant agent runtime for AntSeed. Lets seed runners monetize their knowledge by wrapping any provider with a persona, guardrails, on-demand knowledge modules, and custom tools.

An ant agent is a read-only, knowledge-augmented AI service. It doesn't act on the user's behalf — it answers questions using curated expertise that the creator packages and maintains.

How it works

  1. Creator defines an agent: persona + guardrails + knowledge modules (markdown files)
  2. On each buyer request, persona, guardrails, and an antseed_load_knowledge tool are injected
  3. The LLM decides when to load knowledge — it calls the tool with a module name and receives the content
  4. The agent loop executes internal tool calls and re-prompts until the LLM produces a final text response
  5. The buyer gets a clean streamed response — no internal tools or loop artifacts

When no knowledge modules are defined, no tools are injected and it's a single-call injection (persona + guardrails only).

Agent directory structure

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

agent.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"
    }
  ]
}
FieldRequiredDescription
nameYesAgent name
personaNoPath to markdown file with the agent's system prompt / personality
guardrailsNoArray of hard rules the agent must follow
knowledgeNoArray of knowledge modules for on-demand loading
knowledge[].nameYesUnique identifier for the module
knowledge[].descriptionYesShort description — shown to the LLM to decide relevance
knowledge[].fileYesPath to the markdown file with the full content
toolsNoArray of custom tools the LLM can call
tools[].nameYesTool name (auto-prefixed with antseed_)
tools[].descriptionYesDescription shown to the LLM
tools[].parametersNoJSON Schema for tool parameters (defaults to empty object)
tools[].executeYesPath to a JS file that exports a default function
confidentialityPromptNoCustom confidentiality instruction (has a sensible default)

Usage

Programmatic

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);

CLI

Add agentDir to your antseed config. Use a string for a single agent (all services), or a map for per-service agents:

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

Per-service:

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

The "*" key is a fallback for services with no explicit agent. Services with no matching agent pass through unchanged.

Then run antseed seller start as usual.

Knowledge loading

When knowledge modules are defined, the antseed_load_knowledge tool is injected into the request alongside any buyer tools. The tool description includes a catalog of available module names and descriptions.

The LLM decides which modules to load based on the conversation. It can:

  • Load one module, get the content, then respond
  • Load multiple modules across successive tool calls
  • Respond directly without loading any modules if the question doesn't require specialized knowledge

This keeps the context focused — only the knowledge the LLM judges relevant gets loaded. A buyer asking about LinkedIn won't get X/Twitter knowledge bloating the context.

Custom tools

Beyond knowledge loading, creators can add custom tools that the LLM can call during the agent loop. Define tools in agent.json with an execute field pointing to a JS file:

{
  "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"
  }]
}

The JS file exports a default function that receives the tool arguments and returns a string:

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

Tool names are automatically prefixed with antseed_ when injected (e.g., fetch_trends becomes antseed_fetch_trends). The LLM sees all internal tools alongside buyer tools, with system prompt instructions to use antseed_* tools for context gathering and buyer tools only as requested.

If a tool's execute function throws, the error message is returned to the LLM as an error result so it can recover gracefully.

Programmatic tools

Tools can also be added programmatically via the options parameter (useful when tools need access to runtime state):

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] });

Manifest tools and programmatic tools are merged together.

What gets injected

The system prompt is assembled in this order:

  1. Persona — the agent's identity and expertise
  2. Tool-set instructions — tells the LLM how to use antseed_ tools vs buyer tools (only when knowledge modules exist)
  3. Guardrails — hard rules
  4. Confidentiality prompt — prevents the LLM from revealing injected content

Additionally, antseed_* tools are added to the request's tool list alongside any buyer-provided tools. This includes the built-in antseed_load_knowledge (when knowledge modules are defined) and any custom tools passed via options.

The buyer's own system prompt (if any) is preserved after the agent's content.

版本与发布记录

@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 agent runtime for AntSeed — monetize knowledge with read-only, knowledge-augmented AI agents

如何安装 @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 和提交记录判断。