| 203 | } |
| 204 | |
| 205 | export async function setWorkspaceDefaultAgent(agent: string | null): Promise<string | null> { |
| 206 | const res = await fetch('/api/config/workspace-default-agent', { |
| 207 | method: 'PUT', |
| 208 | headers: { 'content-type': 'application/json' }, |
| 209 | body: JSON.stringify({ agent }), |
| 210 | }); |
| 211 | if (!res.ok) { |
| 212 | const msg = await res.text().catch(() => ''); |
| 213 | throw new Error(`set workspace default agent failed: ${res.status} ${msg}`); |
| 214 | } |
| 215 | const body = (await res.json()) as { agent?: string | null }; |
| 216 | return body.agent ?? null; |
| 217 | } |
| 218 | |
| 219 | export async function getIssueDefaultAgent(): Promise<string | null> { |
| 220 | const res = await fetch('/api/config/issue-default-agent'); |