{"_id":"@a2am/gateway","_rev":"3-a4d6bfc4e738e1901face4963bc6695c","name":"@a2am/gateway","dist-tags":{"latest":"0.1.2"},"versions":{"0.1.0":{"name":"@a2am/gateway","version":"0.1.0","keywords":["a2am","gateway","http","websocket","agent-discovery","p2p","decentralized"],"author":{"name":"A2AM Team"},"license":"MIT","_id":"@a2am/gateway@0.1.0","maintainers":[{"name":"maurim2","email":"mvelez@chrom.ar"}],"homepage":"https://github.com/base60s/A2AM#readme","bugs":{"url":"https://github.com/base60s/A2AM/issues"},"bin":{"a2am-gateway":"bin/gateway.js"},"dist":{"shasum":"e77bf21369ec7455895772da79cb238fabded2b1","tarball":"https://registry.npmjs.org/@a2am/gateway/-/gateway-0.1.0.tgz","fileCount":22,"integrity":"sha512-Ev9ZeZYeR5VGdQrMoU8GBZ1NbVOfnDgUtxE159AqaluThRXqjXiF6isu3b4kYpGzO+Cy2ZEbHS9eQUS5XJ8kGQ==","signatures":[{"sig":"MEUCIAkmKZ0/h6I4JIHec4MJ2fJUXLvApqBVhsqO/vx5D3ltAiEA6LPQNmMw3tor6QwSKewhMIaH/hXVa2WYSSp4tzVhjDQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":54440},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"a62b0da176e3e8e3218fca59b1f2d69ebb7ebf91","scripts":{"dev":"node ../../node_modules/typescript/bin/tsc --watch","test":"node ../../node_modules/vitest/vitest.mjs run","build":"node ../../node_modules/typescript/bin/tsc","clean":"rm -rf dist","start":"node ./dist/index.js","prepublishOnly":"npm run build"},"_npmUser":{"name":"maurim2","email":"mvelez@chrom.ar"},"repository":{"url":"git+https://github.com/base60s/A2AM.git","type":"git","directory":"packages/gateway"},"_npmVersion":"11.6.2","description":"HTTP/WebSocket gateway for A2AM network - run with npx @a2am/gateway","directories":{},"_nodeVersion":"25.2.1","dependencies":{"ws":"^8.16.0","@a2am/core":"^0.1.0","@a2am/node":"^0.1.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^1.2.0","@types/ws":"^8.5.10","typescript":"^5.3.3"},"_npmOperationalInternal":{"tmp":"tmp/gateway_0.1.0_1769187014908_0.5950540093675631","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@a2am/gateway","version":"0.1.1","keywords":["a2am","gateway","http","websocket","agent-discovery","p2p","decentralized"],"author":{"name":"A2AM Team"},"license":"MIT","_id":"@a2am/gateway@0.1.1","maintainers":[{"name":"maurim2","email":"mvelez@chrom.ar"}],"homepage":"https://github.com/base60s/A2AM#readme","bugs":{"url":"https://github.com/base60s/A2AM/issues"},"bin":{"a2am-gateway":"bin/gateway.js"},"dist":{"shasum":"bbadc16fb139c0c0ecb4330e670560c63fe3781f","tarball":"https://registry.npmjs.org/@a2am/gateway/-/gateway-0.1.1.tgz","fileCount":23,"integrity":"sha512-XGcY0fh+jfh70z65hSTbfsMhESIO5X8POgf2SlzF31nZ165TLQpkuOMZKvx9xws97lkdqVW4XviW4ms7i0NXSA==","signatures":[{"sig":"MEYCIQDkCVffgex0iFh6Eh7cRU4mvFlmzbmJzo0CnfBIcawO3wIhAKHaWiaIuldCX9qm6jT0BVwdypoz/jqGYNbPZXj4gjfL","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":75022},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"4360a83b41f505c7e375577c2eed2a9a6b2ad7bd","scripts":{"dev":"tsc --watch","test":"vitest run","build":"tsc","clean":"rm -rf dist","start":"node ./dist/index.js","prepublishOnly":"npm run build"},"_npmUser":{"name":"maurim2","email":"mvelez@chrom.ar"},"repository":{"url":"git+https://github.com/base60s/A2AM.git","type":"git","directory":"packages/gateway"},"_npmVersion":"11.6.2","description":"HTTP/WebSocket gateway for A2AM network - run with npx @a2am/gateway","directories":{},"_nodeVersion":"25.2.1","dependencies":{"ws":"^8.16.0","@a2am/core":"^0.1.0","@a2am/node":"^0.1.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^1.2.0","@types/ws":"^8.5.10","typescript":"^5.3.3"},"_npmOperationalInternal":{"tmp":"tmp/gateway_0.1.1_1769194623640_0.8655508661692346","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@a2am/gateway","version":"0.1.2","description":"HTTP/WebSocket gateway for A2AM network - run with npx @a2am/gateway","type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","bin":{"a2am-gateway":"bin/gateway.js"},"exports":{".":{"import":"./dist/index.js","types":"./dist/index.d.ts"}},"scripts":{"build":"tsc","start":"node ./dist/index.js","dev":"tsc --watch","test":"vitest run","clean":"rm -rf dist","prepublishOnly":"npm run build"},"keywords":["a2am","gateway","http","websocket","agent-discovery","p2p","decentralized"],"author":{"name":"A2AM Team"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/base60s/A2AM.git","directory":"packages/gateway"},"bugs":{"url":"https://github.com/base60s/A2AM/issues"},"homepage":"https://github.com/base60s/A2AM#readme","publishConfig":{"access":"public"},"dependencies":{"@a2am/core":"^0.1.1","@a2am/node":"^0.1.2","ws":"^8.16.0"},"devDependencies":{"@types/ws":"^8.5.10","typescript":"^5.3.3","vitest":"^1.2.0"},"gitHead":"0c67074fe194aaf96714c0d397a773f05159b158","_id":"@a2am/gateway@0.1.2","_nodeVersion":"25.2.1","_npmVersion":"11.6.2","dist":{"integrity":"sha512-9xRwSyVQQIu4krwC3qxB2zOIrwBsrq4Eavt8YfZGm+cNI7E+5/GM9aywDs9C8x6iqlo1mB/kz5TdNdAhdEcz2Q==","shasum":"3afa34d5a770520134cd79cdae1f48ca03e809f5","tarball":"https://registry.npmjs.org/@a2am/gateway/-/gateway-0.1.2.tgz","fileCount":23,"unpackedSize":75022,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCoWqbNvXKgF6yjqJeHESL09aPHfNsn4PRIAWr/PwyckQIhAOQ5SdSmS3l2Eq32KnwgJj2uZQGrpRl+z3kXyap/L2Vj"}]},"_npmUser":{"name":"maurim2","email":"mvelez@chrom.ar"},"directories":{},"maintainers":[{"name":"maurim2","email":"mvelez@chrom.ar"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/gateway_0.1.2_1769196795488_0.91803152420742"},"_hasShrinkwrap":false}},"time":{"created":"2026-01-23T16:50:14.781Z","modified":"2026-01-23T19:33:15.770Z","0.1.0":"2026-01-23T16:50:15.047Z","0.1.1":"2026-01-23T18:57:03.777Z","0.1.2":"2026-01-23T19:33:15.643Z"},"bugs":{"url":"https://github.com/base60s/A2AM/issues"},"author":{"name":"A2AM Team"},"license":"MIT","homepage":"https://github.com/base60s/A2AM#readme","keywords":["a2am","gateway","http","websocket","agent-discovery","p2p","decentralized"],"repository":{"type":"git","url":"git+https://github.com/base60s/A2AM.git","directory":"packages/gateway"},"description":"HTTP/WebSocket gateway for A2AM network - run with npx @a2am/gateway","maintainers":[{"name":"maurim2","email":"mvelez@chrom.ar"}],"readme":"# @a2am/gateway\n\nHTTP/WebSocket gateway that bridges the A2AM P2P network. Anyone can run a gateway to help decentralize the network.\n\n## Why Run a Gateway?\n\n```\n                    ┌─────────────┐\n                    │  Gateway A  │\n                    │  (Railway)  │\n                    └──────┬──────┘\n                           │\n        ┌──────────────────┼──────────────────┐\n        │                  │                  │\n        ▼                  ▼                  ▼\n┌─────────────┐    ┌─────────────┐    ┌─────────────┐\n│  Gateway B  │◄──►│  Gateway C  │◄──►│  Gateway D  │\n│  (Vercel)   │    │  (Fly.io)   │    │   (Self)    │\n└─────────────┘    └─────────────┘    └─────────────┘\n        │                  │                  │\n        └──────────────────┴──────────────────┘\n                           │\n                    ┌──────┴──────┐\n                    │ Hyperswarm  │\n                    │     DHT     │\n                    └─────────────┘\n```\n\n- **Resilience**: Can't shut down what's everywhere\n- **Performance**: Geographically distributed, low latency\n- **Decentralization**: No central authority controls discovery\n- **Community-owned**: Users run infrastructure\n\n## Quick Start\n\n### Run Locally\n\n```bash\n# With npx (no install required)\nnpx @a2am/gateway\n\n# Or with custom port\nnpx @a2am/gateway --port 8080\n```\n\n### Install Globally\n\n```bash\nnpm install -g @a2am/gateway\n\n# Run\na2am-gateway --port 9000\n```\n\n## Deployment Options\n\n### Option A: Railway (Recommended)\n\nOne-click deploy to Railway:\n\n```bash\n# Clone and deploy\ngit clone https://github.com/base60s/A2AM.git\ncd A2AM/packages/gateway\nrailway init\nrailway up\n```\n\nRailway auto-configures `PORT` and provides a public URL.\n\n### Option B: Docker\n\n```dockerfile\nFROM node:20-alpine\nWORKDIR /app\nRUN npm install -g @a2am/gateway\nEXPOSE 9000\nENV PORT=9000\nCMD [\"a2am-gateway\"]\n```\n\nBuild and run:\n\n```bash\ndocker build -t a2am-gateway .\ndocker run -p 9000:9000 a2am-gateway\n```\n\n### Option C: Fly.io\n\n```bash\n# Create fly.toml\ncat > fly.toml << 'EOF'\napp = \"my-a2am-gateway\"\n\n[build]\n  image = \"node:20-alpine\"\n\n[env]\n  PORT = \"8080\"\n\n[processes]\n  app = \"npx @a2am/gateway\"\n\n[[services]]\n  internal_port = 8080\n  protocol = \"tcp\"\n\n  [[services.ports]]\n    handlers = [\"http\"]\n    port = 80\n\n  [[services.ports]]\n    handlers = [\"tls\", \"http\"]\n    port = 443\nEOF\n\n# Deploy\nfly launch\nfly deploy\n```\n\n### Option D: Heroku\n\n```bash\n# Create Procfile\necho \"web: npx @a2am/gateway\" > Procfile\n\n# Deploy\nheroku create my-a2am-gateway\ngit push heroku main\n```\n\n### Option E: Vercel (Serverless)\n\nNote: Vercel's serverless model has limitations for WebSocket connections. Consider Railway or Fly.io for full functionality.\n\n### Option F: Self-Hosted (VPS)\n\n```bash\n# Install on any Linux server\nnpm install -g @a2am/gateway\n\n# Run with systemd\ncat > /etc/systemd/system/a2am-gateway.service << 'EOF'\n[Unit]\nDescription=A2AM Gateway\nAfter=network.target\n\n[Service]\nType=simple\nExecStart=/usr/bin/a2am-gateway --port 9000\nRestart=always\nEnvironment=NODE_ENV=production\n\n[Install]\nWantedBy=multi-user.target\nEOF\n\nsystemctl enable a2am-gateway\nsystemctl start a2am-gateway\n```\n\n## Federation Setup\n\nOnce your gateway is running, connect it to the A2AM network:\n\n```bash\n# Add existing gateways to your federation\ncurl -X POST https://your-gateway.example.com/federation/add \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"url\":\"https://airy-radiance-production-ea90.up.railway.app\"}'\n\ncurl -X POST https://your-gateway.example.com/federation/add \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"url\":\"https://resplendent-nourishment-production.up.railway.app\"}'\n```\n\nOr set federation peers via environment variable:\n\n```bash\nA2AM_FEDERATION_PEERS=https://airy-radiance-production-ea90.up.railway.app,https://resplendent-nourishment-production.up.railway.app npx @a2am/gateway\n```\n\n## API Reference\n\n### REST API\n\n```bash\n# Health check\nGET /health\n\n# Publish an agent\nPOST /publish\nContent-Type: application/json\n{ \"id\": \"...\", \"name\": \"...\", \"capabilities\": [...], \"endpoint\": \"...\", \"protocols\": [...], \"sig\": \"...\" }\n\n# Discover agents\nGET /discover?capability=travel/flights&limit=10\n\n# Get specific agent\nGET /agent/:id\n\n# Gateway stats\nGET /stats\n\n# Federation status\nGET /federation\n\n# Add federation peer\nPOST /federation/add\nContent-Type: application/json\n{ \"url\": \"https://other-gateway.example.com\" }\n```\n\n### WebSocket API\n\n```javascript\nconst ws = new WebSocket('wss://your-gateway.example.com');\n\n// Subscribe to capability updates\nws.send(JSON.stringify({ type: 'subscribe', capability: 'travel' }));\n\n// Receive agent updates\nws.onmessage = (event) => {\n  const msg = JSON.parse(event.data);\n  if (msg.type === 'agent') {\n    console.log('New agent:', msg.agent);\n  }\n};\n\n// Publish agent\nws.send(JSON.stringify({ type: 'publish', agent: { ... } }));\n\n// Discover agents\nws.send(JSON.stringify({ type: 'discover', capability: 'travel', requestId: '123' }));\n```\n\n## Configuration\n\n### Environment Variables\n\n| Variable | Description | Default |\n|----------|-------------|---------|\n| `PORT` | HTTP/WebSocket port | `9000` |\n| `A2AM_FEDERATION_PEERS` | Comma-separated gateway URLs | (none) |\n| `A2AM_FEDERATION_ENABLED` | Enable federation | `true` |\n| `A2AM_FEDERATION_SYNC_INTERVAL` | Sync interval (ms) | `60000` |\n| `A2AM_P2P_ENABLED` | Enable Hyperswarm P2P | `true` |\n\n### Command Line Options\n\n```bash\na2am-gateway [options]\n\nOptions:\n  --port, -p      Port to listen on (default: 9000)\n  --host, -h      Host to bind to (default: 0.0.0.0)\n  --no-p2p        Disable Hyperswarm P2P backbone\n  --no-federation Disable gateway federation\n  --peers         Comma-separated federation peer URLs\n```\n\n## Architecture\n\n```\n┌──────────────────────────────────────────────────────────────┐\n│                        Gateway Server                         │\n├──────────────────────────────────────────────────────────────┤\n│                                                               │\n│  ┌─────────────┐    ┌─────────────┐    ┌─────────────┐       │\n│  │  HTTP API   │    │  WebSocket  │    │  Federation │       │\n│  │  /publish   │    │  subscribe  │    │    Sync     │       │\n│  │  /discover  │    │  publish    │    │             │       │\n│  └──────┬──────┘    └──────┬──────┘    └──────┬──────┘       │\n│         │                  │                  │               │\n│         └─────────┬────────┴─────────┬────────┘               │\n│                   │                  │                        │\n│         ┌─────────▼──────────────────▼─────────┐              │\n│         │           Agent Store                │              │\n│         │     (in-memory + persistence)        │              │\n│         └─────────┬────────────────────────────┘              │\n│                   │                                           │\n│         ┌─────────▼────────────────────────────┐              │\n│         │        Hyperswarm P2P Node           │              │\n│         │     (DHT, Topic Sharding, Bloom)     │              │\n│         └──────────────────────────────────────┘              │\n│                                                               │\n└──────────────────────────────────────────────────────────────┘\n```\n\n## Live Gateways\n\nCurrent public gateways (federated):\n\n| Gateway | URL | Region |\n|---------|-----|--------|\n| A2AM Gateway 1 | https://airy-radiance-production-ea90.up.railway.app | US |\n| A2AM Gateway 2 | https://resplendent-nourishment-production.up.railway.app | US |\n\nWant to add your gateway to this list? Open a PR!\n\n## Development\n\n```bash\n# Clone the repo\ngit clone https://github.com/base60s/A2AM.git\ncd A2AM\n\n# Install dependencies\npnpm install\n\n# Build\npnpm build\n\n# Run gateway in dev mode\ncd packages/gateway\npnpm dev\n\n# Run tests\npnpm test\n```\n\n## Monitoring\n\n### Health Check\n\n```bash\ncurl https://your-gateway.example.com/health\n```\n\nResponse:\n```json\n{\n  \"status\": \"healthy\",\n  \"uptime\": 3600,\n  \"agentCount\": 42,\n  \"p2p\": { \"connected\": true, \"peers\": 5 },\n  \"federation\": { \"enabled\": true, \"peers\": 2, \"healthy\": 2 }\n}\n```\n\n### Stats\n\n```bash\ncurl https://your-gateway.example.com/stats\n```\n\nResponse:\n```json\n{\n  \"agents\": 42,\n  \"capabilities\": [\"travel/flights\", \"ai/chat\", \"data/search\"],\n  \"queries\": { \"total\": 1000, \"last24h\": 100 },\n  \"publishes\": { \"total\": 50, \"last24h\": 5 }\n}\n```\n\n## Security\n\n- All agents are cryptographically signed with Ed25519\n- Gateway verifies signatures before storing agents\n- Federation uses signature verification for sync\n- No sensitive data is stored on gateways\n\n## License\n\nMIT\n","readmeFilename":"README.md"}