82e8c8905b
* feat: replace agent_type with agent_profile_id - Replace agent_type field with agent_profile_id across backend and frontend - Add ProfileResolver interface and StoreProfileResolver implementation - Update task creation/update to use agent_profile_id - Change default agent runtime from docker to standalone - Fix workspace state types to include all required fields - Fix websocket handlers type mismatches for environments, executors, workspaces - Update integration tests to use agent_profile_id * feat: pass model as CLI argument to agents - Add ModelFlag field to AgentTypeConfig for specifying the CLI flag - Set ModelFlag to '--model' for all agents (auggie, claude, codex, gemini, opencode, copilot) - Update launchStandalone to append model flag to agent command - Update launchDocker/buildContainerConfig to append model flag to container command - Model is passed when both agent supports ModelFlag and profile has Model configured * fix: make WebSocket message handling async to prevent blocking When a long-running handler like orchestrator.prompt was executing, it blocked the ReadPump loop, preventing other requests (like workspace.tree.get) from being processed until the handler completed. Now each message is handled in its own goroutine, allowing concurrent message handling so file tree requests work while the agent is working. * feat: show task description as first message in chat - Add 'Task' label with distinct styling (lighter background, border) - Pass taskDescription from page to TaskChatPanel component - Differentiate from regular user messages visually
180 lines
5.4 KiB
TypeScript
180 lines
5.4 KiB
TypeScript
import { getBackendConfig } from '@/lib/config';
|
|
import type {
|
|
BoardSnapshot,
|
|
ListAgentsResponse,
|
|
ListAgentDiscoveryResponse,
|
|
ListBoardsResponse,
|
|
ListEnvironmentsResponse,
|
|
ListExecutorsResponse,
|
|
ListRepositoriesResponse,
|
|
ListWorkspacesResponse,
|
|
RepositoryBranchesResponse,
|
|
Task,
|
|
UserSettingsResponse,
|
|
Workspace,
|
|
} from '@/lib/types/http';
|
|
|
|
export type ApiRequestOptions = {
|
|
baseUrl?: string;
|
|
cache?: RequestCache;
|
|
init?: RequestInit;
|
|
};
|
|
|
|
function resolveUrl(pathOrUrl: string, baseUrl: string) {
|
|
if (pathOrUrl.startsWith('http://') || pathOrUrl.startsWith('https://')) {
|
|
return pathOrUrl;
|
|
}
|
|
return `${baseUrl}${pathOrUrl}`;
|
|
}
|
|
|
|
async function fetchJson<T>(pathOrUrl: string, options?: ApiRequestOptions): Promise<T> {
|
|
const baseUrl = options?.baseUrl ?? getBackendConfig().apiBaseUrl;
|
|
const response = await fetch(resolveUrl(pathOrUrl, baseUrl), {
|
|
...options?.init,
|
|
cache: options?.cache,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
...(options?.init?.headers ?? {}),
|
|
},
|
|
});
|
|
if (!response.ok) {
|
|
throw new Error(`Request failed: ${response.status} ${response.statusText}`);
|
|
}
|
|
if (response.status === 204) {
|
|
return undefined as T;
|
|
}
|
|
const text = await response.text();
|
|
if (!text) {
|
|
return undefined as T;
|
|
}
|
|
return JSON.parse(text) as T;
|
|
}
|
|
|
|
export async function createWorkspace(
|
|
payload: { name: string; description?: string },
|
|
options?: ApiRequestOptions
|
|
) {
|
|
return fetchJson<Workspace>('/api/v1/workspaces', {
|
|
...options,
|
|
init: { method: 'POST', body: JSON.stringify(payload), ...(options?.init ?? {}) },
|
|
});
|
|
}
|
|
|
|
export async function listWorkspaces(options?: ApiRequestOptions) {
|
|
return fetchJson<ListWorkspacesResponse>('/api/v1/workspaces', options);
|
|
}
|
|
|
|
export async function listBoards(workspaceId: string, options?: ApiRequestOptions) {
|
|
const baseUrl = options?.baseUrl ?? getBackendConfig().apiBaseUrl;
|
|
const url = new URL(`${baseUrl}/api/v1/boards`);
|
|
url.searchParams.set('workspace_id', workspaceId);
|
|
return fetchJson<ListBoardsResponse>(url.toString(), options);
|
|
}
|
|
|
|
export async function fetchBoardSnapshot(boardId: string, options?: ApiRequestOptions) {
|
|
return fetchJson<BoardSnapshot>(`/api/v1/boards/${boardId}/snapshot`, options);
|
|
}
|
|
|
|
export async function listRepositories(workspaceId: string, options?: ApiRequestOptions) {
|
|
return fetchJson<ListRepositoriesResponse>(`/api/v1/workspaces/${workspaceId}/repositories`, options);
|
|
}
|
|
|
|
export async function listRepositoryBranches(repositoryId: string, options?: ApiRequestOptions) {
|
|
return fetchJson<RepositoryBranchesResponse>(`/api/v1/repositories/${repositoryId}/branches`, options);
|
|
}
|
|
|
|
export async function createTask(
|
|
payload: {
|
|
workspace_id: string;
|
|
board_id: string;
|
|
column_id: string;
|
|
title: string;
|
|
description?: string;
|
|
position?: number;
|
|
repository_url?: string;
|
|
branch?: string;
|
|
agent_profile_id?: string;
|
|
environment_id?: string;
|
|
executor_id?: string;
|
|
state?: Task['state'];
|
|
},
|
|
options?: ApiRequestOptions
|
|
) {
|
|
return fetchJson<Task>('/api/v1/tasks', {
|
|
...options,
|
|
init: { method: 'POST', body: JSON.stringify(payload), ...(options?.init ?? {}) },
|
|
});
|
|
}
|
|
|
|
export async function updateTask(
|
|
taskId: string,
|
|
payload: {
|
|
title?: string;
|
|
description?: string;
|
|
position?: number;
|
|
agent_profile_id?: string;
|
|
assigned_to?: string;
|
|
state?: Task['state'];
|
|
},
|
|
options?: ApiRequestOptions
|
|
) {
|
|
return fetchJson<Task>(`/api/v1/tasks/${taskId}`, {
|
|
...options,
|
|
init: { method: 'PATCH', body: JSON.stringify(payload), ...(options?.init ?? {}) },
|
|
});
|
|
}
|
|
|
|
export async function deleteTask(taskId: string, options?: ApiRequestOptions) {
|
|
return fetchJson<void>(`/api/v1/tasks/${taskId}`, {
|
|
...options,
|
|
init: { method: 'DELETE', ...(options?.init ?? {}) },
|
|
});
|
|
}
|
|
|
|
export async function moveTask(
|
|
taskId: string,
|
|
payload: { board_id: string; column_id: string; position: number },
|
|
options?: ApiRequestOptions
|
|
) {
|
|
return fetchJson<Task>(`/api/v1/tasks/${taskId}/move`, {
|
|
...options,
|
|
init: { method: 'POST', body: JSON.stringify(payload), ...(options?.init ?? {}) },
|
|
});
|
|
}
|
|
|
|
export async function fetchUserSettings(options?: ApiRequestOptions) {
|
|
return fetchJson<UserSettingsResponse>('/api/v1/user/settings', options);
|
|
}
|
|
|
|
export async function updateUserSettings(
|
|
payload: { workspace_id: string; board_id: string; repository_ids: string[] },
|
|
options?: ApiRequestOptions
|
|
) {
|
|
return fetchJson<UserSettingsResponse>('/api/v1/user/settings', {
|
|
...options,
|
|
init: { method: 'PATCH', body: JSON.stringify(payload), ...(options?.init ?? {}) },
|
|
});
|
|
}
|
|
|
|
export async function fetchTask(taskId: string, options?: ApiRequestOptions) {
|
|
return fetchJson<Task>(`/api/v1/tasks/${taskId}`, options);
|
|
}
|
|
|
|
export async function listExecutors(options?: ApiRequestOptions): Promise<ListExecutorsResponse> {
|
|
return fetchJson<ListExecutorsResponse>('/api/v1/executors', options);
|
|
}
|
|
|
|
export async function listEnvironments(options?: ApiRequestOptions): Promise<ListEnvironmentsResponse> {
|
|
return fetchJson<ListEnvironmentsResponse>('/api/v1/environments', options);
|
|
}
|
|
|
|
export async function listAgents(options?: ApiRequestOptions): Promise<ListAgentsResponse> {
|
|
return fetchJson<ListAgentsResponse>('/api/v1/agents', options);
|
|
}
|
|
|
|
export async function listAgentDiscovery(
|
|
options?: ApiRequestOptions
|
|
): Promise<ListAgentDiscoveryResponse> {
|
|
return fetchJson<ListAgentDiscoveryResponse>('/api/v1/agents/discovery', options);
|
|
}
|