/** * Server-side agent-chat proxy for an app opened inside Dispatch. * * The Desktop app already solves this by pointing the rail's `apiUrl` at a * loopback relay onto the target app's `/_agent-native/agent-chat`, so parity * with the app's native chat holds structurally instead of by copying tools and * instructions into Dispatch's agent. This is the web equivalent: Dispatch * forwards the whole agent-chat subtree to the app's own server. * * Credential: the app's OWN embed session, minted through the existing paths in * `mcp-gateway.ts` — the same credential the app pane's iframe already runs on. * Dispatch consumes the one-time ticket server-side and reuses the resulting * short-lived embed token as a bearer, which is an authentication path the * framework already accepts (`resolveEmbedSessionFromRequest`). No new auth * scheme, and no token gains scope it did not already have. * * A dedicated Nitro route rather than an action: agent-chat streams (SSE for * `/runs/:id/events`, a token stream for the turn itself) and returns non-JSON * bodies, which is the documented exception in CLAUDE.md to the * actions-over-routes rule. */ export interface WorkspaceAppChatSession { /** Target app root, including any configured base path. */ appBaseUrl: string; token: string; embedTarget: string; expiresAt: number; } /** * Read the embed token's own `exp` claim. Guessing a TTL here would silently * produce a session that the target has already rejected, so a token we cannot * read an expiry from is an error rather than a default. */ export declare function embedSessionTokenExpiry(token: string): number; /** * Exchange the one-time embed ticket for the reusable short-lived token. The * target's embed-start route answers a redirect whose location carries both the * token and the path the token is bound to. */ export declare function exchangeEmbedStartUrl(startUrl: string, fetchImpl?: typeof fetch): Promise; /** Test seam: drop cached app sessions so a spec starts from a cold proxy. */ export declare function clearWorkspaceAppChatSessions(): void; /** h3 v2 request event: `url` is the parsed URL and `req` is the web Request. */ interface WorkspaceAppChatProxyEvent { url: URL; req: Request; } export declare function createWorkspaceAppChatProxyHandler(options?: { fetchImpl?: typeof fetch; }): (event: WorkspaceAppChatProxyEvent) => Promise; export {}; //# sourceMappingURL=workspace-app-chat-proxy.d.ts.map