{"_id":"@agent-trust/gateway","_rev":"4-7352fc5876effc2c0028aa4030714c22","name":"@agent-trust/gateway","dist-tags":{"latest":"1.3.0"},"versions":{"1.0.0":{"name":"@agent-trust/gateway","version":"1.0.0","keywords":["ai","agent","gateway","trust","middleware","express","jwt","certificate","reputation","ai-agents","agenttrust"],"author":{"name":"AgentTrust"},"license":"MIT","_id":"@agent-trust/gateway@1.0.0","maintainers":[{"name":"mmsadek96","email":"mmsadek96@gmail.com"}],"homepage":"https://github.com/mmsadek96/agentgateway/tree/main/packages/gateway#readme","bugs":{"url":"https://github.com/mmsadek96/agentgateway/issues"},"dist":{"shasum":"fecfc0191d93ce65cfcc1476c4f645d6f077ef86","tarball":"https://registry.npmjs.org/@agent-trust/gateway/-/gateway-1.0.0.tgz","fileCount":30,"integrity":"sha512-V1lBe/2q1L3KsKJhCgEyqjKETmvR+QKoL/x7OpsVSTr8cmwMtrb/eI9sbv2ES0ApyXIqzo6arLDSAk6rojy6Xg==","signatures":[{"sig":"MEUCIBIiK1F8tBsmtIRmSDbyFvTm/Yz8yYK/75JBf9qBqGGmAiEA+UKEC7tWRx2qHBwbWSljYTOdbiXXVz0fuSmscq8M740=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":83038},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=18.0.0"},"gitHead":"86ecf7e0d9d2ebafbccbabb2281f5c1e01652efd","scripts":{"dev":"tsc --watch","build":"tsc"},"_npmUser":{"name":"mmsadek96","email":"mmsadek96@gmail.com"},"repository":{"url":"git+https://github.com/mmsadek96/agentgateway.git","type":"git","directory":"packages/gateway"},"_npmVersion":"10.9.3","description":"Express middleware that lets trusted AI agents interact with your website. Verifies cryptographic certificates, checks reputation scores, and reports behavior.","directories":{},"_nodeVersion":"22.20.0","dependencies":{"jsonwebtoken":"^9.0.2"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.3.3","@types/express":"^4.17.21","@types/jsonwebtoken":"^9.0.6"},"peerDependencies":{"express":"^4.18.0"},"_npmOperationalInternal":{"tmp":"tmp/gateway_1.0.0_1771718387200_0.6686669623031425","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@agent-trust/gateway","version":"1.1.0","keywords":["ai","agent","gateway","trust","middleware","express","jwt","certificate","reputation","ai-agents","agenttrust","prompt-injection","ml","security","behavioral-analysis","huggingface","onnx"],"author":{"name":"AgentTrust"},"license":"MIT","_id":"@agent-trust/gateway@1.1.0","maintainers":[{"name":"mmsadek96","email":"mmsadek96@gmail.com"}],"homepage":"https://github.com/mmsadek96/agentgateway/tree/main/packages/gateway#readme","bugs":{"url":"https://github.com/mmsadek96/agentgateway/issues"},"dist":{"shasum":"2d1ea705d30bac79f7dfdf8764aa5f3196f907aa","tarball":"https://registry.npmjs.org/@agent-trust/gateway/-/gateway-1.1.0.tgz","fileCount":34,"integrity":"sha512-k8ZlVWYOPqlPrffgazdjiiG3seTuY8R07hESRuJlNd55oUPwuTlgiU05Sg7H8mFBD2FLwaNv9OIcHPey7ZpTiw==","signatures":[{"sig":"MEYCIQD9gVnwG34suYL601k2N5zAa5C1HU5MSdreNVVoL2bTTwIhAMxxHbPoR4dVlcS/NAQggW0CWQMrLUAI1VGcnZPi10Yq","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":114603},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=18.0.0"},"gitHead":"89ee78af4222f7fcd572f292218d8d5e4e53322a","scripts":{"dev":"tsc --watch","build":"tsc"},"_npmUser":{"name":"mmsadek96","email":"mmsadek96@gmail.com"},"repository":{"url":"git+https://github.com/mmsadek96/agentgateway.git","type":"git","directory":"packages/gateway"},"_npmVersion":"10.9.3","description":"Express middleware that lets trusted AI agents interact with your website. Verifies cryptographic certificates, checks reputation scores, reports behavior, and detects prompt injection attacks with ML.","directories":{},"_nodeVersion":"22.20.0","dependencies":{"jsonwebtoken":"^9.0.2"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.3.3","@types/express":"^4.17.21","@types/jsonwebtoken":"^9.0.6"},"peerDependencies":{"express":"^4.18.0"},"optionalDependencies":{"@huggingface/transformers":"^3.8.1"},"_npmOperationalInternal":{"tmp":"tmp/gateway_1.1.0_1771722238560_0.069635152474808","host":"s3://npm-registry-packages-npm-production"}},"1.2.0":{"name":"@agent-trust/gateway","version":"1.2.0","keywords":["ai","agent","gateway","trust","middleware","express","jwt","certificate","reputation","ai-agents","agenttrust","prompt-injection","ml","security","behavioral-analysis","huggingface","onnx","scope","scope-manifest","authorization"],"author":{"name":"AgentTrust"},"license":"MIT","_id":"@agent-trust/gateway@1.2.0","maintainers":[{"name":"mmsadek96","email":"mmsadek96@gmail.com"}],"homepage":"https://github.com/mmsadek96/agentgateway/tree/main/packages/gateway#readme","bugs":{"url":"https://github.com/mmsadek96/agentgateway/issues"},"dist":{"shasum":"21ac46a88326b70b2de85d958a753c5f2016898b","tarball":"https://registry.npmjs.org/@agent-trust/gateway/-/gateway-1.2.0.tgz","fileCount":34,"integrity":"sha512-XKdEhoAulVoYIJaJ4wVOyKCT/T2maB9k24KCWne7RZqZCfVyhaAbRdPf7Q27YdVYlStAw1bp7VdxQE/eFZ5Aeg==","signatures":[{"sig":"MEUCIFKcyBmj8sLy7ZXcARWu22nGfnZtZLWe7+3ADKhA/xKiAiEAt8244nxaHMF8z14s1sHwMqkMm2Gx6kP3o+3nj+t+vZI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":118362},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=18.0.0"},"gitHead":"ef3e81df8dfad43657bc0252f1e0e646aaf8abfa","scripts":{"dev":"tsc --watch","build":"tsc"},"_npmUser":{"name":"mmsadek96","email":"mmsadek96@gmail.com"},"repository":{"url":"git+https://github.com/mmsadek96/agentgateway.git","type":"git","directory":"packages/gateway"},"_npmVersion":"10.9.3","description":"Express middleware that lets trusted AI agents interact with your website. Verifies cryptographic certificates, enforces scope manifests, checks reputation scores, reports behavior, and detects prompt injection attacks with ML.","directories":{},"_nodeVersion":"22.20.0","dependencies":{"jsonwebtoken":"^9.0.2"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.3.3","@types/express":"^4.17.21","@types/jsonwebtoken":"^9.0.6"},"peerDependencies":{"express":"^4.18.0"},"optionalDependencies":{"@huggingface/transformers":"^3.8.1"},"_npmOperationalInternal":{"tmp":"tmp/gateway_1.2.0_1771725537568_0.4927648115227121","host":"s3://npm-registry-packages-npm-production"}},"1.3.0":{"name":"@agent-trust/gateway","version":"1.3.0","description":"Express middleware that lets trusted AI agents interact with your website. Verifies cryptographic certificates, enforces scope manifests, checks reputation scores, reports behavior, and detects prompt injection attacks with ML.","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc","dev":"tsc --watch"},"keywords":["ai","agent","gateway","trust","middleware","express","jwt","certificate","reputation","ai-agents","agenttrust","prompt-injection","ml","security","behavioral-analysis","huggingface","onnx","scope","scope-manifest","authorization"],"author":{"name":"AgentTrust"},"license":"MIT","homepage":"https://github.com/mmsadek96/agentgateway/tree/main/packages/gateway#readme","repository":{"type":"git","url":"git+https://github.com/mmsadek96/agentgateway.git","directory":"packages/gateway"},"bugs":{"url":"https://github.com/mmsadek96/agentgateway/issues"},"peerDependencies":{"express":"^4.18.0"},"dependencies":{"jsonwebtoken":"^9.0.2"},"optionalDependencies":{"@huggingface/transformers":"^3.8.1"},"devDependencies":{"@types/express":"^4.17.21","@types/jsonwebtoken":"^9.0.6","typescript":"^5.3.3"},"engines":{"node":">=18.0.0"},"_id":"@agent-trust/gateway@1.3.0","gitHead":"c49ce282b8f88fa534e2414e17a2edec7f555a42","_nodeVersion":"22.20.0","_npmVersion":"10.9.3","dist":{"integrity":"sha512-WJSQqySJZYKjlmQTbUCr6Orf5w4KOOEsvAKGpyC95XLJU1jFI43WTCvW1xIbsWJQnEpXUXR2otRnEUp9VET4Gw==","shasum":"1e6f695e40193c96f6bd35e59e13db975173dbf7","tarball":"https://registry.npmjs.org/@agent-trust/gateway/-/gateway-1.3.0.tgz","fileCount":38,"unpackedSize":147996,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCYwePLv1Yo8cQx5W4DO2aLhWOurnxwQljAbysRLjO5SAIgFcB8QTvJ1qbrGVbOtngWDvEZhRdMVdU75INq1Ko5KZY="}]},"_npmUser":{"name":"mmsadek96","email":"mmsadek96@gmail.com"},"directories":{},"maintainers":[{"name":"mmsadek96","email":"mmsadek96@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/gateway_1.3.0_1771781766013_0.5827737653897647"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-21T23:59:47.137Z","modified":"2026-02-22T17:36:06.637Z","1.0.0":"2026-02-21T23:59:47.319Z","1.1.0":"2026-02-22T01:03:58.716Z","1.2.0":"2026-02-22T01:58:57.708Z","1.3.0":"2026-02-22T17:36:06.169Z"},"bugs":{"url":"https://github.com/mmsadek96/agentgateway/issues"},"author":{"name":"AgentTrust"},"license":"MIT","homepage":"https://github.com/mmsadek96/agentgateway/tree/main/packages/gateway#readme","keywords":["ai","agent","gateway","trust","middleware","express","jwt","certificate","reputation","ai-agents","agenttrust","prompt-injection","ml","security","behavioral-analysis","huggingface","onnx","scope","scope-manifest","authorization"],"repository":{"type":"git","url":"git+https://github.com/mmsadek96/agentgateway.git","directory":"packages/gateway"},"description":"Express middleware that lets trusted AI agents interact with your website. Verifies cryptographic certificates, enforces scope manifests, checks reputation scores, reports behavior, and detects prompt injection attacks with ML.","maintainers":[{"name":"mmsadek96","email":"mmsadek96@gmail.com"}],"readme":"# @agent-trust/gateway\n\nExpress middleware that lets trusted AI agents interact with your website. Part of the [AgentTrust](https://github.com/mmsadek96/agentgateway) ecosystem.\n\n## Install\n\n```bash\nnpm install @agent-trust/gateway\n```\n\n> **TypeScript users:** Types are included. You'll also need `@types/express` if you don't already have it:\n> ```bash\n> npm install -D @types/express\n> ```\n\n## Quick Start\n\n```typescript\nimport express from 'express';\nimport { createGateway } from '@agent-trust/gateway';\n\nconst app = express();\napp.use(express.json());\n\nconst gateway = createGateway({\n  stationUrl: 'https://agentgateway-6f041c655eb3.herokuapp.com',\n  gatewayId: 'my-store',\n  stationApiKey: 'YOUR_API_KEY',\n  actions: {\n    'search_products': {\n      description: 'Search the product catalog',\n      minScore: 30,\n      parameters: {\n        query: { type: 'string', required: true, description: 'Search query' }\n      },\n      handler: async (params) => {\n        return await db.products.search(params.query);\n      }\n    },\n    'place_order': {\n      description: 'Place an order',\n      minScore: 70,  // Higher trust required\n      parameters: {\n        productId: { type: 'string', required: true },\n        quantity: { type: 'number', required: true }\n      },\n      handler: async (params, agent) => {\n        return await db.orders.create({ ...params, agentId: agent.agentId });\n      }\n    }\n  },\n  behavior: {\n    maxActionsPerMinute: 30,\n    derivatives: {\n      enabled: true,\n      velocityThresholds: { actions_per_minute: 8, failures_per_minute: 3 },\n      useAccelerationBlocking: true,\n      predictiveBlockingSeconds: 30,\n    },\n    onSuspiciousActivity: (event) => {\n      console.warn('Suspicious agent:', event.flag, event.description);\n    }\n  }\n});\n\napp.use('/agent-gateway', gateway.router());\napp.listen(3000);\n```\n\n## Features\n\n- **Certificate verification** — validates RS256 JWT certificates from the AgentTrust Station\n- **Score-based access** — different actions require different reputation levels\n- **Real-time behavioral tracking** — detects and blocks suspicious agents mid-session\n- **Auto-reporting** — reports agent behavior back to Station automatically (synced to Base L2 on-chain)\n- **Discovery endpoints** — agents can discover available actions programmatically\n- **On-chain trust** — every certificate and reputation score is recorded on Base L2, independently verifiable on [BaseScan](https://basescan.org/address/0xb880bC6b0634812E85EC635B899cA197429069e8)\n\n## Behavioral Tracking\n\nThe gateway monitors agent behavior in real-time and detects:\n\n| Detection | What it catches |\n|-----------|----------------|\n| `rapid_fire` | Too many requests per minute |\n| `high_failure_rate` | Probing / brute force |\n| `action_enumeration` | Scanning endpoints |\n| `repeated_action` | Automation (same action on loop) |\n| `scope_violation` | Accessing above trust level |\n| `burst_detected` | Sudden activity after idle |\n| `velocity_spike` | Metric rate-of-change exceeds threshold (ramping attack) |\n| `accelerating_attack` | Metric acceleration indicates escalating threat |\n| `predictive_breach` | Forecasted score will breach block threshold in 30s |\n\nAgents get a behavioral score (0-100) that degrades with violations. Drop below threshold = blocked mid-session.\n\n### Derivative-Based Detection (NEW)\n\nThe gateway now computes mathematical derivatives (velocity and acceleration) on behavioral metrics in real-time. This catches attacks that static thresholds miss:\n\n- **Velocity spike** — detects slow ramp-up attacks before they hit static limits\n- **Accelerating attack** — catches explosive probing and escalation patterns\n- **Predictive blocking** — forecasts behavioral score 30 seconds ahead and blocks before breach\n\nConfigure via the `derivatives` option in `behavior` config.\n\n## API\n\n### Routes (mounted on your chosen path)\n\n| Method | Path | Description |\n|--------|------|-------------|\n| `GET` | `/.well-known/agent-gateway` | Discovery manifest |\n| `GET` | `/actions` | List available actions |\n| `POST` | `/actions/:name` | Execute an action (cert required) |\n| `GET` | `/behavior/sessions` | Monitor active sessions |\n\n## Links\n\n- [Full documentation](https://github.com/mmsadek96/agentgateway)\n- [Live Station](https://agentgateway-6f041c655eb3.herokuapp.com/)\n- [API docs](https://agentgateway-6f041c655eb3.herokuapp.com/docs)\n\n## License\n\nMIT\n","readmeFilename":"README.md"}