|
2 | 2 |
|
3 | 3 | How a domain's Services become the wire surface (`/api/v2`) and WebSocket events. This is a **design-time** decision: which Services are exposed, under what public `resource:action` name, and which events stream. |
4 | 4 |
|
| 5 | +> **Implementation note (2026-08):** the current `/api/v2` surface is hand-written route files |
| 6 | +> under `packages/agent-gateway/src/routes/v2/`, mounted by `src/routes/registerApiV2Routes.ts` |
| 7 | +> (see `packages/agent-gateway/AGENTS.md`). There is no generic `actionMap` dispatcher in |
| 8 | +> agent-gateway today; the `resource:action` model and tables below are the original v2 edge |
| 9 | +> design. The facade rules (§2, §4), the scope-resolution rule, and the WS-event rules (§5) |
| 10 | +> still apply to route-file exposure. |
| 11 | +
|
5 | 12 | The transport (`/api/v2` over HTTP + WS) lives in the **edge** layer (`gateway`/`rpc`/`transport`). It borrows business Services by interface; business code never imports it. |
6 | 13 |
|
7 | 14 | ## 1. The edge model |
@@ -45,7 +52,7 @@ A Service method is directly exposable iff **all** hold: |
45 | 52 | 3. Errors are `PythinkerError` (coded). |
46 | 53 | 4. It is a command/query, not a factory, stream, byte-store, or sink. |
47 | 54 |
|
48 | | -If any fail → add a wire-safe orchestration method to the owning domain Service (e.g. `IAgentPromptService.submit` settles `{turn_id}` instead of returning the live `PromptHandle`) or compose several domain Services at the edge — kap-server's `routes/prompts.ts` is the reference for edge-side composition. |
| 55 | +If any fail → add a wire-safe orchestration method to the owning domain Service (e.g. `IAgentPromptService.submit` settles `{turn_id}` instead of returning the live `PromptHandle`) or compose several domain Services at the edge — agent-gateway's `routes/prompts.ts` is the reference for edge-side composition. |
49 | 56 |
|
50 | 57 | ## 3. Per-scope `resource:action` map |
51 | 58 |
|
@@ -160,7 +167,7 @@ The `eventMap` binds a public event name to the scope's `Event` source (analogou |
160 | 167 |
|
161 | 168 | Session-level `onDidChange` sources (metadata / interactions) carry no payload today, so they are not exposed until there is a concrete consumer. |
162 | 169 |
|
163 | | -Safety / reliability (carried over from `packages/server/src/ws/connection.ts` and VSCode's `ChannelServer`): |
| 170 | +Safety / reliability (carried over from VSCode's `ChannelServer`, and the legacy v1 server those ideas were ported from): |
164 | 171 |
|
165 | 172 | - request ids + active-request table — `cancel` / `unlisten` disposes them; |
166 | 173 | - heartbeat — `ping` every 30s, `pong` timeout 10s → `terminate`; |
|
0 commit comments