跳到正文
Skillpedia
API 与服务器(后端)7.6k · #13182

server-plugins

它能做什么

这项技能说明服务器插件在 Agent-Native 应用中如何运作,以及框架路由应放在哪里。适合添加服务器功能,或排查自动出现的路由问题的开发者。

适用场景

  • ✓当你需要为应用添加自定义服务器插件的时候。
  • ✓当你需要在普通 API 路由和操作之间做决定的时候。
  • ✓当内置框架路由的行为出乎意料的时候。

技能链接

https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/server-plugins/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/server-plugins/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请为这个应用添加一项自定义服务器功能,并告诉我它应该是 API 路由还是操作。”

每周 5 个新技能,1 分钟读完。

工作原理

默认插件会自动加载。只有需要定制的插件才会拥有自己的文件,所有框架路由都放在共享的路径前缀下。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Server Plugins & Framework Routes

Default Plugins (auto-mount)

Five default plugins auto-mount when your app doesn't have a custom version in server/plugins/:

Plugin Default behavior Customize when
agent-chat Agent chat endpoints Custom mentionProviders or systemPrompt
auth Auth middleware Custom publicPaths or Google OAuth config
core-routes /_agent-native/poll, /_agent-native/ping, etc Custom envKeys or sseRoute
resources Resource CRUD Rarely
terminal Terminal emulator Rarely

Only create plugin files for plugins you need to customize. Let defaults auto-mount.

Framework Route Namespace: /_agent-native/

All framework-level routes live under /_agent-native/ to avoid collisions with template-specific /api/* routes.

Hard rule

  • ALL framework routes go under /_agent-native/.
  • Templates own /api/* only for route-only domain concerns such as uploads, streaming, webhooks, OAuth callbacks, or non-JSON protocols.
  • Never put framework routes under /api/.
  • Never put template routes under /_agent-native/ — that namespace is reserved.
  • Never create /api/* routes that only wrap, proxy, or re-export actions. Use the existing /_agent-native/actions/:name endpoint or the React action hooks.

Auto-mounted framework routes

Route Purpose
GET /_agent-native/poll Polling endpoint for DB change detection
GET /_agent-native/events SSE endpoint for real-time sync
GET /_agent-native/ping Health check
GET/PUT/DELETE /_agent-native/application-state/:key Application state CRUD
GET/PUT/DELETE /_agent-native/application-state/compose/:id Compose draft CRUD
POST /_agent-native/agent-chat Agent chat SSE endpoint
GET /_agent-native/agent-chat/mentions Mention search for @-tagging
GET /_agent-native/env-status Env key configuration status
POST /_agent-native/env-vars Save env vars
/_agent-native/auth/* Authentication (login, session, logout)
/_agent-native/google/* Google OAuth (callback, auth-url, etc.)
/_agent-native/resources/* Resource CRUD
/_agent-native/actions/:name Auto-mounted action endpoints
/_agent-native/available-clis Available CLI tools
/_agent-native/agent-terminal-info Terminal connection info
/_agent-native/collab/* Real-time collaboration (see real-time-collab)
/_agent-native/a2a A2A JSON-RPC endpoint (see a2a-protocol)

Actions-First Approach

For standard CRUD and data operations, use defineAction in actions/ — the framework auto-mounts them as HTTP endpoints at /_agent-native/actions/:name. Only create custom /api/* routes for things actions can't do:

  • File uploads with multipart form data
  • Streaming responses
  • Webhooks from external services
  • OAuth callbacks

Before adding a route, inspect the existing action files. Reuse the action if it already encodes the business rule, or add a new action if the operation should be available to both the agent and the UI. A route whose implementation mostly calls an action is usually the wrong abst

常见问题

每个插件都需要一个文件吗?

不需要。技能说明应让默认值自动加载,只定制你需要的部分。

框架路由使用什么路径?

它们使用前缀 /_agent-native/,以避免与应用路由冲突。

什么时候应使用 /api/ 路由?

用于仅与路由相关的事务,例如上传或流式传输。

详情

作者的原始描述

Framework server plugins and the `/_agent-native/` route namespace. Use when adding a custom server plugin, deciding whether to create an `/api/` route vs an action, or debugging auto-mounted framework routes.

repo: BuilderIO/agent-native

热度

GitHub 星标
7.6k
排名
#13182
许可证
MIT
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能