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

Function createWorkspace

ui/src/components/workspace/api.ts:93–114  ·  view source on GitHub ↗
(
  tag: string,
  template: string,
  agents?: readonly string[],
)

Source from the content-addressed store, hash-verified

91 * `WorkspaceCreator.create`). Pass an explicit set only to pin a subset.
92 */
93export async function createWorkspace(
94 tag: string,
95 template: string,
96 agents?: readonly string[],
97): Promise<CreateResult> {
98 const res = await fetch('/api/workspaces', {
99 method: 'POST',
100 headers: { 'content-type': 'application/json' },
101 body: JSON.stringify(agents && agents.length > 0 ? { tag, template, agents } : { tag, template }),
102 });
103 if (res.ok) {
104 const body = (await res.json()) as { workspace: Workspace };
105 return { ok: true, workspace: body.workspace };
106 }
107 let err: CreateError;
108 try {
109 err = (await res.json()) as CreateError;
110 } catch {
111 err = { error: 'bootstrap_failed', message: `HTTP ${res.status}` };
112 }
113 return { ok: false, status: res.status, error: err };
114}
115
116export interface TemplateInfo {
117 readonly name: string;

Callers 1

useCreateWorkspaceFunction · 0.90

Calls 1

fetchFunction · 0.50

Tested by

no test coverage detected