{"_id":"@donwei123/agent-can-bus","name":"@donwei123/agent-can-bus","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@donwei123/agent-can-bus","version":"0.1.0","private":false,"type":"module","description":"LAN Agent-CAN bus service for multi-agent messaging, arbitration, ACK, task status, and audit.","bin":{"agent-can-server":"dist/src/server.js","agent-can-mcp":"dist/src/mcp-server.js","agent-can-runtime":"dist/scripts/runtime-agent.js","agent-can-setup-codex":"dist/scripts/setup-codex.js"},"scripts":{"dev":"tsx watch src/server.ts","start":"node dist/src/server.js","build":"tsc -p tsconfig.json","typecheck":"tsc --noEmit -p tsconfig.json","mcp":"node dist/src/mcp-server.js","mcp:dev":"tsx src/mcp-server.ts","agent:runtime":"tsx scripts/runtime-agent.ts","setup:codex":"tsx scripts/setup-codex.ts","prepack":"pnpm build"},"dependencies":{"@fastify/websocket":"^11.2.0","@modelcontextprotocol/sdk":"^1.29.0","@sinclair/typebox":"^0.34.41","better-sqlite3":"^12.5.0","fastify":"^5.6.2","nanoid":"^5.1.6","ws":"^8.18.3","zod":"^4.1.13"},"devDependencies":{"@types/better-sqlite3":"^7.6.13","@types/node":"^24.10.2","@types/ws":"^8.18.1","tsx":"^4.20.6","typescript":"^5.9.3"},"_id":"@donwei123/agent-can-bus@0.1.0","_nodeVersion":"24.14.0","_npmVersion":"11.9.0","dist":{"integrity":"sha512-/7OFUGE9Aj8gvw4Za2Nl22+cNc/aRfBP4Rip9GicZRB96VivYql14r0Be5T4E3YfbpJeGk8rYdNpeqRz6Qovww==","shasum":"6781b3670ec37060d82b1198a0eab5657fba0b5d","tarball":"https://registry.npmjs.org/@donwei123/agent-can-bus/-/agent-can-bus-0.1.0.tgz","fileCount":19,"unpackedSize":78691,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQC+TB4iuC+Kh4SNSgtvBjM6hnI2m5VISi9d0rwTwW50TAIgQ5+uwuDC6vBSad/VCBs4lHKSc41bKV4PcYBTG2bXhw8="}]},"_npmUser":{"name":"donwei123","email":"12132301@mail.sustech.edu.cn"},"directories":{},"maintainers":[{"name":"donwei123","email":"12132301@mail.sustech.edu.cn"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/agent-can-bus_0.1.0_1781253725645_0.011204487610505076"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-12T08:42:05.480Z","0.1.0":"2026-06-12T08:42:05.768Z","modified":"2026-06-12T08:42:05.982Z"},"maintainers":[{"name":"donwei123","email":"12132301@mail.sustech.edu.cn"}],"description":"LAN Agent-CAN bus service for multi-agent messaging, arbitration, ACK, task status, and audit.","readme":"# Agent-CAN Bus\n\nTypeScript LAN service for Agent-to-Agent communication architecture.\n\nThis project is only the communication layer:\n\n- agent registration and discovery\n- CAN-style numeric node addressing\n- frame routing\n- ACK / STAT / RES / ERR flow\n- request-response waiting by correlation id\n- queue, audit, approvals\n- MCP bridge for controlling the bus from Codex\n- A2A-inspired field model: AgentCard/Skill, Task, Message, Part, Artifact, Status\n\nIt does not implement business tools. Weather, filesystem, browser, ERP, MES, CRM, or shell execution must live inside an external agent runtime.\n\n## Run\n\n```bash\npnpm install\npnpm build\npnpm start\n```\n\n## Install For Other Machines\n\nAfter publishing or sharing the package tarball, other machines can install it as a normal npm package.\n\nGlobal install from npm:\n\n```bash\nnpm install -g @donwei123/agent-can-bus\n```\n\nLocal install from a packed tarball:\n\n```bash\nnpm install -g ./donwei123-agent-can-bus-0.1.0.tgz\n```\n\nThen register Codex MCP and Agent-CAN skills:\n\n```bash\nagent-can-setup-codex \\\n  --bus-url http://192.168.1.168:8787 \\\n  --token dev-agent-can-token\n```\n\nThis writes:\n\n- MCP server id: `agent-can-bus`\n- MCP tools: `agent_can_health`, `agent_can_list_agents`, `agent_can_request_task`, and related bus tools\n- Skills: `agent-can-bus`, `agent-can-protocol`, `agent-can-ops`, `agent-can-runtime`\n\nRestart Codex CLI after setup. Then a user can ask:\n\n```text\n用 Agent-CAN 问 can:2：你好\n```\n\nThe setup command intentionally runs explicitly instead of as `postinstall`; installing an npm package should not silently rewrite Codex config.\n\nPackage commands:\n\n```bash\nagent-can-server\nagent-can-runtime\nagent-can-mcp\nagent-can-setup-codex\n```\n\nDefault endpoints:\n\n- Management UI: `http://127.0.0.1:8787/`\n- HTTP: `http://127.0.0.1:8787`\n- WebSocket: `ws://127.0.0.1:8787/ws`\n- Health: `GET /health`\n- Agents: `GET /agents`\n- Frames: `GET /frames`\n- Request/response: `POST /tasks/request`\n- Queue: `GET /queue`\n- Approvals: `GET /approvals`\n- Audit: `GET /audit`\n- A2A card draft: `GET /a2a/agent-card`\n\nDefault development token:\n\n```text\ndev-agent-can-token\n```\n\nUse it as `Authorization: Bearer dev-agent-can-token`, `x-agent-can-token`, or WebSocket query `?token=dev-agent-can-token`.\n\n## Runtime Agent\n\nThe included runtime agent is a protocol entrypoint. It registers on the bus, accepts `TASK` frames, immediately returns `STAT ack.accepted`, then either:\n\n- calls a configured external executor and returns `RES`\n- returns `ERR runtime.not_configured` when no executor is configured\n\nThe bus stays communication-only. Cursor, Codex, Python agents, shell tools, RAG, ERP, MES, CRM, or file access must be connected behind the runtime as external executors.\n\n```bash\nAGENT_CAN_WS=ws://127.0.0.1:8787/ws \\\nAGENT_CAN_TOKEN=dev-agent-can-token \\\nAGENT_ID=runtime_agent \\\nAGENT_CAN_ID=2 \\\npnpm agent:runtime\n```\n\nEcho executor for transport testing:\n\n```bash\nAGENT_CAN_WS=ws://127.0.0.1:8787/ws \\\nAGENT_CAN_TOKEN=dev-agent-can-token \\\nAGENT_ID=runtime_agent \\\nAGENT_CAN_ID=2 \\\nAGENT_CAN_EXECUTOR_COMMAND=/bin/echo \\\npnpm agent:runtime\n```\n\nCursor Agent CLI executor:\n\n```bash\nAGENT_CAN_WS=ws://127.0.0.1:8787/ws \\\nAGENT_CAN_TOKEN=dev-agent-can-token \\\nAGENT_ID=remote_runtime_agent \\\nAGENT_CAN_ID=2 \\\nAGENT_CAN_EXECUTOR_COMMAND=/home/zeroerr-ai72/.local/bin/cursor-agent \\\nAGENT_CAN_EXECUTOR_ARGS_JSON='[\"--print\",\"--mode\",\"ask\",\"--output-format\",\"text\",\"--trust\"]' \\\nAGENT_CAN_EXECUTOR_TIMEOUT_MS=120000 \\\npnpm agent:runtime\n```\n\n## Request/Response\n\nSubmit a task without hand-building a full frame:\n\n```bash\ncurl -X POST \\\n  -H 'content-type: application/json' \\\n  -H 'x-agent-can-token: dev-agent-can-token' \\\n  -d '{\"target\":\"can:2\",\"intent\":\"agent.message\",\"input\":{\"message\":{\"role\":\"user\",\"parts\":[{\"kind\":\"text\",\"text\":\"hello\"}]}},\"timeout_ms\":10000}' \\\n  http://127.0.0.1:8787/tasks/request\n```\n\nThe bus returns delivery metadata, status frames, and the first matching `RES` or `ERR`.\n\nFor Codex CLI, use natural language:\n\n```text\n用 Agent-CAN 问 can:2：机器人关节有哪些结构和组件？\n```\n\nIf the CLI needs an explicit tool instruction:\n\n```text\n使用 agent-can-bus 的 agent_can_request_task，target=can:2，intent=agent.message，input.message.role=user，input.message.parts=[{\"kind\":\"text\",\"text\":\"机器人关节有哪些结构和组件？\"}]，timeout_ms=120000\n```\n\n## MCP Server\n\nBuild first:\n\n```bash\npnpm build\n```\n\nRun as stdio MCP server:\n\n```bash\nAGENT_CAN_HTTP=http://127.0.0.1:8787 \\\nAGENT_CAN_TOKEN=dev-agent-can-token \\\npnpm mcp\n```\n\nMCP tools exposed:\n\n- `agent_can_health`\n- `agent_can_list_agents`\n- `agent_can_list_frames`\n- `agent_can_list_queue`\n- `agent_can_list_approvals`\n- `agent_can_decide_approval`\n- `agent_can_send_frame`\n- `agent_can_request`\n- `agent_can_request_task`\n- `agent_can_a2a_card`\n\n## LAN Test\n\nStart the bus for LAN access:\n\n```bash\nAGENT_CAN_HOST=0.0.0.0 AGENT_CAN_PORT=8787 pnpm start\n```\n\nOn another machine, start an agent runtime:\n\n```bash\nAGENT_CAN_WS=ws://<bus-ip>:8787/ws \\\nAGENT_CAN_TOKEN=dev-agent-can-token \\\nAGENT_ID=remote_runtime_agent \\\nAGENT_CAN_ID=2 \\\nAGENT_CAN_EXECUTOR_COMMAND=/bin/echo \\\npnpm agent:runtime\n```\n\n## Boundary\n\nThe bus must not contain hardcoded business branches or tool calls.\n\nThose belong to real agent runtimes. Agent-CAN only transports frames and records their lifecycle.\n","readmeFilename":"README.md","_rev":"1-0d4626eaac6290d844b99d3a445ffd83"}