MCPcopy Create free account
hub / github.com/TraderAlice/OpenAlice / spawnSession

Function spawnSession

ui/src/components/workspace/api.ts:288–310  ·  view source on GitHub ↗
(
  id: string,
  opts: SpawnOptions = {},
)

Source from the content-addressed store, hash-verified

286}
287
288export 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. */
313export interface QuickChatResult {

Callers 1

WorkspacesProviderFunction · 0.90

Calls 1

fetchFunction · 0.50

Tested by

no test coverage detected