{"_id":"@agent-anvil-platform/plugin-runtime","name":"@agent-anvil-platform/plugin-runtime","dist-tags":{"latest":"0.7.0"},"versions":{"0.7.0":{"name":"@agent-anvil-platform/plugin-runtime","version":"0.7.0","description":"agent-anvil Platform 插件运行期适配器：ws 生命周期客户端（5 消息）+ MCP/A2A server 装配 + manifest 生成器（FR-5.6）","keywords":["agent-anvil-platform","plugin-runtime","ws","mcp","a2a","manifest"],"license":"Apache-2.0","author":{"name":"MapleBytes"},"homepage":"https://gitee.com/agent-anvil/agent-anvil-platform-sdk/tree/master/packages/plugin-runtime","repository":{"type":"git","url":"git+https://gitee.com/agent-anvil/agent-anvil-platform-sdk.git","directory":"packages/plugin-runtime"},"bugs":{"url":"https://gitee.com/agent-anvil/agent-anvil-platform-sdk/issues"},"type":"module","main":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","default":"./dist/index.js"},"./package.json":"./package.json"},"sideEffects":false,"engines":{"node":">=20"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"scripts":{"build":"tsc","typecheck":"tsc --noEmit","test":"cd ../.. && npx jest --config packages/plugin-runtime/jest.config.mjs","prepublishOnly":"npm run build"},"dependencies":{"@a2a-js/sdk":"^1.1.0","@modelcontextprotocol/sdk":"^1.30.0","ws":"^8.21.0"},"devDependencies":{"@types/jest":"^29.5.14","@types/node":"^26.2.0","@types/ws":"^8.18.0","jest":"^29.7.0","ts-jest":"^29.2.5","typescript":"^5.6.0"},"_id":"@agent-anvil-platform/plugin-runtime@0.7.0","_nodeVersion":"22.18.0","_npmVersion":"10.9.3","dist":{"integrity":"sha512-LMhPW4hV5+8pnnV0LOlyqPh4tcE3LJ4dXovokm0Gz5Wtjokwy9LRgOviayGT4pTWjCr7EjIfaDlK5CC4GvPDZQ==","shasum":"1ad58558a0dcc053100fee7454a0828aa7395dbb","tarball":"https://registry.npmjs.org/@agent-anvil-platform/plugin-runtime/-/plugin-runtime-0.7.0.tgz","fileCount":29,"unpackedSize":107429,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIElyo9pYf7C1BQY1N0iGjtxdRRU19U8+BTHtuH9CLQvEAiEA6uU3PbzkGcjB7kj/egaSnkJyauD5SsbRXiiKmQZ17JA="}]},"_npmUser":{"name":"ai-admin-platform","email":"987846224@qq.com"},"directories":{},"maintainers":[{"name":"ai-admin-platform","email":"987846224@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/plugin-runtime_0.7.0_1788918012228_0.1670452590563909"},"_hasShrinkwrap":false}},"time":{"created":"2026-09-09T01:40:12.011Z","0.7.0":"2026-09-09T01:40:12.377Z","modified":"2026-09-09T01:40:12.638Z"},"maintainers":[{"name":"ai-admin-platform","email":"987846224@qq.com"}],"description":"agent-anvil Platform 插件运行期适配器：ws 生命周期客户端（5 消息）+ MCP/A2A server 装配 + manifest 生成器（FR-5.6）","homepage":"https://gitee.com/agent-anvil/agent-anvil-platform-sdk/tree/master/packages/plugin-runtime","keywords":["agent-anvil-platform","plugin-runtime","ws","mcp","a2a","manifest"],"repository":{"type":"git","url":"git+https://gitee.com/agent-anvil/agent-anvil-platform-sdk.git","directory":"packages/plugin-runtime"},"author":{"name":"MapleBytes"},"bugs":{"url":"https://gitee.com/agent-anvil/agent-anvil-platform-sdk/issues"},"license":"Apache-2.0","readme":"# @agent-anvil/plugin-runtime\r\n\r\nagent-anvil Platform 插件运行期适配器（TypeScript ESM，FR-5.6 Node 适配器）。\r\n\r\n提供四类能力：\r\n\r\n- **WsLifecycleClient**：宿主与插件子进程之间的 ws 生命周期客户端。状态机\r\n  `DISCONNECTED → REGISTERING → INITIALIZED → READY → ERROR`，收发 5 消息\r\n  （`register` / `initialize` / `ready` / `heartbeat` / `policy.update`），\r\n  心跳默认 30s、断连宽限默认 5s 自动重连（`close()` 主动关闭不重连），\r\n  会话 token 替换 bootstrap、`policy.update.updates.sessionToken` 轮换。\r\n- **McpServerAssembler**：基于官方 `@modelcontextprotocol/sdk` 的 Streamable HTTP\r\n  装配，只注册 manifest `tools` 节声明的工具（全名 `plugin:{code}:{domain}:{action}`），\r\n  未声明注册抛 `ToolNotDeclaredError`。\r\n- **A2aServerAssembler**：基于官方 `@a2a-js/sdk` 装配 A2A Agent（Agent Card +\r\n  task 处理），并把 `POST|GET /a2a` 接入数据面。\r\n- **ManifestGenerator**：manifest.json 生成器（schemaVersion `1.0`），键序稳定、\r\n  仅输出非空节。\r\n- **DataPlaneServer**：最小数据面绑定（Node `http`），`POST /mcp` / `POST|GET /a2a`\r\n  分发，传输可注入（测试用 mock，不起真端口）。\r\n\r\n## 安装\r\n\r\n```bash\r\nnpm install @agent-anvil/plugin-runtime\r\n```\r\n\r\n运行期依赖：`ws`、`@modelcontextprotocol/sdk`、`@a2a-js/sdk`（Node >= 20）。\r\n\r\n## 快速使用\r\n\r\n```ts\r\nimport { WsLifecycleClient, generateManifest } from '@agent-anvil/plugin-runtime';\r\n\r\nconst client = new WsLifecycleClient();\r\nclient.onInitialize((msg) => {\r\n  console.log('initialized', msg.pluginId, msg.sessionToken);\r\n});\r\nclient.connect('wss://host/lifecycle', 'bootstrap-token');\r\nclient.register({\r\n  manifest: { code: 'demo', version: '1.0.0', schemaVersion: '1.0' },\r\n  authToken: 'bootstrap-token',\r\n});\r\n```\r\n\r\n## 开发\r\n\r\n```bash\r\nnpm run typecheck   # tsc --noEmit\r\nnpm run build       # tsc\r\nnpm test            # jest（约 30 例）\r\n```\r\n\r\n## License\r\n\r\nApache-2.0\r\n","readmeFilename":"README.md","_rev":"1-d21ce00a0109f8221a5cc2d421566bd3"}