@agent-anvil-platform/plugin-runtime
v0.7.0
Published
agent-anvil Platform 插件运行期适配器:ws 生命周期客户端(5 消息)+ MCP/A2A server 装配 + manifest 生成器(FR-5.6)
Maintainers
Readme
@agent-anvil/plugin-runtime
agent-anvil Platform 插件运行期适配器(TypeScript ESM,FR-5.6 Node 适配器)。
提供四类能力:
- WsLifecycleClient:宿主与插件子进程之间的 ws 生命周期客户端。状态机
DISCONNECTED → REGISTERING → INITIALIZED → READY → ERROR,收发 5 消息 (register/initialize/ready/heartbeat/policy.update), 心跳默认 30s、断连宽限默认 5s 自动重连(close()主动关闭不重连), 会话 token 替换 bootstrap、policy.update.updates.sessionToken轮换。 - McpServerAssembler:基于官方
@modelcontextprotocol/sdk的 Streamable HTTP 装配,只注册 manifesttools节声明的工具(全名plugin:{code}:{domain}:{action}), 未声明注册抛ToolNotDeclaredError。 - A2aServerAssembler:基于官方
@a2a-js/sdk装配 A2A Agent(Agent Card + task 处理),并把POST|GET /a2a接入数据面。 - ManifestGenerator:manifest.json 生成器(schemaVersion
1.0),键序稳定、 仅输出非空节。 - DataPlaneServer:最小数据面绑定(Node
http),POST /mcp/POST|GET /a2a分发,传输可注入(测试用 mock,不起真端口)。
安装
npm install @agent-anvil/plugin-runtime运行期依赖:ws、@modelcontextprotocol/sdk、@a2a-js/sdk(Node >= 20)。
快速使用
import { WsLifecycleClient, generateManifest } from '@agent-anvil/plugin-runtime';
const client = new WsLifecycleClient();
client.onInitialize((msg) => {
console.log('initialized', msg.pluginId, msg.sessionToken);
});
client.connect('wss://host/lifecycle', 'bootstrap-token');
client.register({
manifest: { code: 'demo', version: '1.0.0', schemaVersion: '1.0' },
authToken: 'bootstrap-token',
});开发
npm run typecheck # tsc --noEmit
npm run build # tsc
npm test # jest(约 30 例)License
Apache-2.0
