feat: WS request proxy — Gateway proxies HTTP via WebSocket (#210 Phase 2)

- Add ws-protocol.ts with WsRequest/WsResponse types + parsers
- AgentSocket DO: proxy POST handler, pending request map, 30s timeout
- /api/agents/:agent/* routes through DO WS when connected, falls back to HTTP
- ws-client handles incoming WsRequest, fetches local serve, returns WsResponse
- startGatewayWsClient accepts localPort for request handling

Testing: #213
This commit is contained in:
2026-05-12 14:42:19 +08:00
parent 18e3dc7603
commit ec3c97b200
7 changed files with 413 additions and 38 deletions
+4
View File
@@ -3,6 +3,10 @@
"version": "0.1.0",
"private": true,
"type": "module",
"exports": {
".": "./src/index.ts",
"./ws-protocol": "./src/ws-protocol.ts"
},
"scripts": {
"dev": "wrangler dev",
"deploy": "wrangler deploy"