一键导入
agent-gateway
Local-first personal AI agent gateway architecture for Windows with messaging integrations, tool execution, and real-time streaming.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Local-first personal AI agent gateway architecture for Windows with messaging integrations, tool execution, and real-time streaming.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
WCAG 2.2 accessibility audit and remediation guidance for frontend code, UI reviews, keyboard/focus testing, ARIA usage, contrast, forms, and regression checks.
Anthropic Claude API expert - master Messages API requests, responses, streaming, tool use, prompt caching, and current Claude 4-family model practices.
REST and HTTP API design with OpenAPI 3.1, resource modeling, versioning, pagination, idempotency, errors, validation, auth boundaries, and production compatibility.
Expert in converting between AI provider APIs - Anthropic, Gemini, OpenRouter, Groq, Mistral, DeepSeek, and NVIDIA NIM.
Comprehensive authentication system for AI agent gateway with JWT tokens, session management, and multi-factor authentication.
Role-based access control (RBAC) and permission system for AI agent gateway with fine-grained resource authorization and policy enforcement.
| name | agent-gateway |
| type | skill |
| description | Local-first personal AI agent gateway architecture for Windows with messaging integrations, tool execution, and real-time streaming. |
| version | 1.0.0 |
| author | skillregistry |
| license | MIT |
| agents | ["cursor","claude-code","copilot","gemini-cli"] |
| categories | ["backend","ai-ml","architecture","realtime"] |
| tags | ["agent","gateway","local-first","windows","realtime","websocket","messaging","ai"] |
Build a local-first personal AI agent gateway on Windows that connects messaging platforms with LLM providers via HTTP/WebSocket endpoints.
Messaging Platforms (Telegram) → Gateway → LLM Providers
↓ ↓ ↓
WebSocket HTTP Tools
(Mobile) (RPC) (Bash, Browser, Canvas)
↓ ↓ ↓
Streaming Config Approval Gates
| Component | Purpose | Tech |
|---|---|---|
| HTTP Server | REST/RPC endpoints | Express/Fastify |
| WebSocket | Real-time connections | ws/Socket.io |
| Message Router | Channel+sender lookup | Custom |
| Session Manager | Session lifecycle | Custom |
| Tool Gateway | Tool execution | node-pty, CDP |
| LLM Router | LLM provider selection | Custom |
| Storage | Persistence | LanceDB, SQLite |
GatewayConfig = {
gateway: { port: 3000, wsPort: 3001, maxConnections: 1000 }
security: { mode: 'always-require-approval' | 'owner-only' | 'yolo' }
storage: { lancedbPath: string, sqlitePath: string, retentionDays: 90 }
providers: Record<string, { type: 'openai'|'anthropic'|'local', apiKey: string, model: string }>
tools: { bash: { enabled: true, requireApproval: true }, ... }
bindings: { channelId: string, senderId: string, agent: string, mode: string }[]
allowlist: { users: string[], channels: string[], ips: string[] }
}
SHA256(channelId:senderId).jsonl append-only format// Session structure
interface Session {
id: string
channelId: string
senderId: string
createdAt: number
updatedAt: number
agent: string
mode: 'default' | 'strict' | 'sandbox'
state: {
conversation: Array<{ role: string, content: string, timestamp: number }>
pendingApproval?: { tool: string, arguments: any, requestedAt: number }
}
metadata: { tokenCount: number, lastCompaction: number, checkpoint?: string }
}
class MessageRouter {
async routeMessage(channelId: string, senderId: string, message: string): Promise<{ session: Session, agent: string, shouldRespond: boolean }> {
// 1. Check authorization (allowlist)
// 2. Check mention requirement for group chats
// 3. Find binding or use default agent
// 4. Derive session key
// 5. Load or create session
// 6. Check compaction needed
return { session, agent, shouldRespond: true }
}
}
GET /health - Health checkGET /api/config - Get configurationPOST /api/chat - Send messageGET /api/channels - List channelsPOST /api/channels/:id/webhook - Platform webhookClient → Server:
{type: "pair", token: "..."} - Pair device{type: "subscribe", channelId: "..."} - Subscribe{type: "message", channelId: "...", text: "..."} - Send message{type: "canvas", channelId: "...", commands: [...]} - Canvas updateServer → Client:
{type: "chunk", channelId: "...", delta: "..."} - Message chunk{type: "message", channelId: "...", text: "...", done: true} - Complete{type: "canvas", channelId: "...", commands: [...]} - Canvas update{type: "presence", userId: "...", status: "online"} - Presence// Config modes
'always-require-approval' // Always ask before dangerous tools
'owner-only' // Only owner can approve
'yolo' // No approval (sandbox recommended)
bash - Shell execution (node-pty)cron - Scheduled jobsbrowser - Chrome CDP controlcanvas - Drawing commandsimage - Image generation (Sharp)file - File read/write# Install
pnpm init
pnpm add express ws zod better-sqlite3 @lancedb/lancedb node-pty @napi-rs/canvas sharp
pnpm add -D typescript vitest tsx @types/node
# Basic gateway
import { AgentGateway } from './core/gateway';
const gateway = new AgentGateway(config);
await gateway.initialize();
agent-gateway/
├── src/
│ ├── config/ # Zod schemas, config loading
│ ├── core/ # Gateway, server, router
│ ├── services/ # Session, LLM, tools, storage
│ ├── platforms/ # Telegram, WebSocket
│ └── api/ # HTTP routes, middleware
├── tests/ # Unit & integration tests
└── data/ # LanceDB, SQLite, uploads
FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY dist ./dist
COPY data ./data
EXPOSE 3000 3001
HEALTHCHECK --interval=30s CMD wget -q -O- http://localhost:3000/health
CMD ["node", "dist/index.js"]