| 324 | }; |
| 325 | |
| 326 | /** |
| 327 | * Create a typed, fetch-based client for cloud-agent-next tRPC endpoints. |
| 328 | * |
| 329 | * The caller is responsible for assembling the correct headers (Bearer token, |
| 330 | * internal API key, skip-balance-check, etc.) because different procedures |
| 331 | * require different auth levels. |
| 332 | */ |
| 333 | export function createCloudAgentNextFetchClient(baseUrl: string): CloudAgentNextFetchClient { |
| 334 | const trpc = (procedure: string) => `${baseUrl}/trpc/${procedure}`; |
| 335 | |
| 336 | return { |
| 337 | async prepareSession(headers, input) { |
| 338 | const data = await trpcPost<Record<string, unknown>>( |
| 339 | trpc('prepareSession'), |
| 340 | headers, |
| 341 | input, |
| 342 | 'prepareSession' |