npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@faapi/agent

v3.1.0

Published

Agent runtime for faapi — LLM-driven ReAct loop over scanned agent / tool registries

Readme

@faapi/agent

faapi 的 agent 运行时——在已扫描的 agent / tool 注册表之上提供 LLM 驱动的 ReAct 循环

@faapi/agent 组合 faapi 核心包已生成的 faapi-agents.js + faapi-tools.js 清单,提供:

  • LLM Provider 抽象(Phase 3.2)—— 统一接口对接 OpenAI / Anthropic 等 provider
  • ReAct 循环引擎(Phase 3.3)—— LLM 输出 → 调用 tool / 递归 sub-agent → 把结果回灌给 LLM,循环直到最终回答
  • Agent 类(Phase 3.4)—— 按 agent.name 查找元数据、加载 handler、组装 agent.tools + sub-agent,提供 run / stream / asTool
  • 递归防护 —— maxTurns + maxAgentDepth(来自 config.agent 或 agent 自身 config 块)

与 faapi 核心的关系

faapi 核心(@faapi/faapi)           @faapi/agent(本包)
────────────────────────────         ────────────────────────────
scanAgents  →  faapi-agents.js   ──→  Agent.run / stream
scanTools   →  faapi-tools.js    ──→  reactLoop 组装 tool 列表
agentRegistry / toolRegistry     ──→  resolveAgentTools / resolveSubAgents / asTool
loadAgentModule / loadToolModule ──→  reactLoop 执行 tool / sub-agent
config.agent(llm / maxTurns …)  ──→  Agent 类构造参数

核心包负责扫描与产物生成(dev/prod 一致),本包负责运行时编排——LLM 调用、tool 分发、递归控制、流式输出。

安装

pnpm add @faapi/agent
# 或
npm install @faapi/agent

要求 Node.js >= 24。

当前为 canary 阶段(Phase 3.x 持续开发中),API 可能在稳定前调整。

启用方式

faapi.config.tsplugins 中声明即启用 agent 运行时(Phase 3.5 集成):

import type { FaapiConfig } from '@faapi/faapi';

export default {
  agent: {
    llm: {
      provider: 'openai',
      apiKey: process.env.OPENAI_API_KEY,
      model: 'gpt-4o',
    },
    defaultAgent: 'researcher',
    maxTurns: 10,
    maxAgentDepth: 3,
  },
  plugins: ['@faapi/agent'],
} satisfies FaapiConfig;

CLI 启动时动态加载——未安装时自动跳过,不影响核心功能。需单独安装:pnpm add @faapi/agent

多 agent 组织

agent 与 tool 的目录约定(由 faapi 核心包扫描,详见 AGENTS.md 5.4):

src/
├── tools/                          ← 所有 tool(agent 通过 config.tools 显式引用)
│   └── weather/handler.ts
├── agents/
│   ├── researcher/                 ← agent "researcher"
│   │   └── handler.ts             ← export const config / export function run
│   └── writer/
│       └── handler.ts             ← config.agents: ['researcher'] → 可调用 researcher
  • tool 位置:src/tools/**(所有 tool 统一放此目录,无 agent 专属 tool 概念)
  • agent 可用 tool:在 agent 的 config.tools 字段显式声明引用 tool 名
  • sub-agent:在 agent 的 config.agents 字段声明可调用的其他 agent 名

状态

Phase 3.1:包骨架初始化(按 AGENTS.md 6.5 清单配置)。

许可证

MIT