(
id: string,
opts: SpawnOptions = {},
)
| 286 | } |
| 287 | |
| 288 | export async function spawnSession( |
| 289 | id: string, |
| 290 | opts: SpawnOptions = {}, |
| 291 | ): Promise<SpawnedSession> { |
| 292 | const body: Record<string, unknown> = {}; |
| 293 | if (opts.resume !== undefined) body['resume'] = opts.resume; |
| 294 | if (opts.agent !== undefined) body['agent'] = opts.agent; |
| 295 | if (opts.initialPrompt !== undefined) body['initialPrompt'] = opts.initialPrompt; |
| 296 | if (opts.terminalTheme !== undefined) body['terminalTheme'] = opts.terminalTheme; |
| 297 | const res = await fetch( |
| 298 | `/api/workspaces/${encodeURIComponent(id)}/sessions/spawn`, |
| 299 | { |
| 300 | method: 'POST', |
| 301 | headers: { 'content-type': 'application/json' }, |
| 302 | body: JSON.stringify(body), |
| 303 | }, |
| 304 | ); |
| 305 | if (!res.ok) { |
| 306 | const msg = await res.text().catch(() => ''); |
| 307 | throw new Error(`spawn session failed: ${res.status} ${msg}`); |
| 308 | } |
| 309 | return (await res.json()) as SpawnedSession; |
| 310 | } |
| 311 | |
| 312 | /** Response of the quick-chat launch: the (reused-or-created) chat workspace + the seeded session. */ |
| 313 | export interface QuickChatResult { |
no test coverage detected