276 lines
7.6 KiB
TypeScript
276 lines
7.6 KiB
TypeScript
import { invoke } from "@tauri-apps/api/core";
|
|
import type {
|
|
Project,
|
|
TuleapCredentialsSafe,
|
|
Agent,
|
|
AgentRole,
|
|
AgentTool,
|
|
FilterGroup,
|
|
WatchedTracker,
|
|
TrackerField,
|
|
ProcessedTicket,
|
|
Worktree,
|
|
TicketResult,
|
|
OrchaiNotification,
|
|
ProjectModule,
|
|
LiveSession,
|
|
LiveMessage,
|
|
LiveAgentExchange,
|
|
AgentTask,
|
|
} from "./types";
|
|
|
|
export async function createProject(
|
|
name: string,
|
|
pathOrUrl: string,
|
|
baseBranch: string
|
|
): Promise<Project> {
|
|
return invoke("create_project", {
|
|
name,
|
|
pathOrUrl,
|
|
baseBranch,
|
|
});
|
|
}
|
|
|
|
export async function listProjects(): Promise<Project[]> {
|
|
return invoke("list_projects");
|
|
}
|
|
|
|
export async function getProject(id: string): Promise<Project> {
|
|
return invoke("get_project", { id });
|
|
}
|
|
|
|
export async function updateProject(
|
|
id: string,
|
|
name: string,
|
|
baseBranch: string
|
|
): Promise<void> {
|
|
return invoke("update_project", { id, name, baseBranch });
|
|
}
|
|
|
|
export async function deleteProject(id: string): Promise<void> {
|
|
return invoke("delete_project", { id });
|
|
}
|
|
|
|
// Agents
|
|
export async function createAgent(
|
|
name: string,
|
|
role: AgentRole,
|
|
tool: AgentTool,
|
|
customPrompt: string
|
|
): Promise<Agent> {
|
|
return invoke("create_agent", { name, role, tool, customPrompt });
|
|
}
|
|
export async function listAgents(): Promise<Agent[]> {
|
|
return invoke("list_agents");
|
|
}
|
|
export async function getAgent(id: string): Promise<Agent> {
|
|
return invoke("get_agent", { id });
|
|
}
|
|
export async function updateAgent(
|
|
id: string,
|
|
name: string,
|
|
role: AgentRole,
|
|
tool: AgentTool,
|
|
customPrompt: string
|
|
): Promise<void> {
|
|
return invoke("update_agent", { id, name, role, tool, customPrompt });
|
|
}
|
|
export async function improveAgentPrompt(
|
|
name: string,
|
|
role: AgentRole,
|
|
tool: AgentTool,
|
|
customPrompt: string
|
|
): Promise<string> {
|
|
return invoke("improve_agent_prompt", { name, role, tool, customPrompt });
|
|
}
|
|
export async function deleteAgent(id: string): Promise<void> {
|
|
return invoke("delete_agent", { id });
|
|
}
|
|
|
|
// Credentials
|
|
export async function setTuleapCredentials(tuleapUrl: string, username: string, password: string): Promise<TuleapCredentialsSafe> {
|
|
return invoke("set_tuleap_credentials", { tuleapUrl, username, password });
|
|
}
|
|
export async function getTuleapCredentials(): Promise<TuleapCredentialsSafe | null> {
|
|
return invoke("get_tuleap_credentials");
|
|
}
|
|
export async function deleteTuleapCredentials(): Promise<void> {
|
|
return invoke("delete_tuleap_credentials");
|
|
}
|
|
export async function testTuleapConnection(): Promise<string> {
|
|
return invoke("test_tuleap_connection");
|
|
}
|
|
|
|
// Trackers
|
|
export async function addTracker(
|
|
projectId: string,
|
|
trackerId: number,
|
|
trackerLabel: string,
|
|
pollingInterval: number,
|
|
analystAgentId: string,
|
|
developerAgentId: string,
|
|
filters: FilterGroup[]
|
|
): Promise<WatchedTracker> {
|
|
return invoke("add_tracker", {
|
|
payload: {
|
|
projectId,
|
|
trackerId,
|
|
trackerLabel,
|
|
pollingInterval,
|
|
analystAgentId,
|
|
developerAgentId,
|
|
filters,
|
|
},
|
|
});
|
|
}
|
|
export async function listTrackers(projectId: string): Promise<WatchedTracker[]> {
|
|
return invoke("list_trackers", { projectId });
|
|
}
|
|
export async function updateTracker(
|
|
id: string,
|
|
trackerId: number,
|
|
trackerLabel: string,
|
|
pollingInterval: number,
|
|
analystAgentId: string,
|
|
developerAgentId: string,
|
|
filters: FilterGroup[],
|
|
enabled: boolean
|
|
): Promise<void> {
|
|
return invoke("update_tracker", {
|
|
id,
|
|
update: {
|
|
tracker_id: trackerId,
|
|
tracker_label: trackerLabel,
|
|
polling_interval: pollingInterval,
|
|
analyst_agent_id: analystAgentId,
|
|
developer_agent_id: developerAgentId,
|
|
filters,
|
|
enabled,
|
|
},
|
|
});
|
|
}
|
|
export async function removeTracker(id: string): Promise<void> {
|
|
return invoke("remove_tracker", { id });
|
|
}
|
|
export async function getTrackerFields(trackerId: number): Promise<TrackerField[]> {
|
|
return invoke("get_tracker_fields", { trackerId });
|
|
}
|
|
|
|
// Tickets & Polling
|
|
export async function listProcessedTickets(projectId: string): Promise<ProcessedTicket[]> {
|
|
return invoke("list_processed_tickets", { projectId });
|
|
}
|
|
export async function manualPoll(trackerId: string): Promise<ProcessedTicket[]> {
|
|
return invoke("manual_poll", { trackerId });
|
|
}
|
|
export async function getQueueStatus(projectId: string): Promise<ProcessedTicket[]> {
|
|
return invoke("get_queue_status", { projectId });
|
|
}
|
|
|
|
// Orchestrator
|
|
export async function getTicketResult(ticketId: string): Promise<TicketResult> {
|
|
return invoke("get_ticket_result", { ticketId });
|
|
}
|
|
export async function retryTicket(ticketId: string): Promise<void> {
|
|
return invoke("retry_ticket", { ticketId });
|
|
}
|
|
export async function cancelTicket(ticketId: string): Promise<void> {
|
|
return invoke("cancel_ticket", { ticketId });
|
|
}
|
|
|
|
// Worktrees
|
|
export async function listWorktrees(projectId: string): Promise<Worktree[]> {
|
|
return invoke("list_worktrees", { projectId });
|
|
}
|
|
export async function getWorktreeDiff(worktreeId: string): Promise<string> {
|
|
return invoke("get_worktree_diff", { worktreeId });
|
|
}
|
|
export async function applyFixToBranch(worktreeId: string, targetBranch: string): Promise<void> {
|
|
return invoke("apply_fix_to_branch", { worktreeId, targetBranch });
|
|
}
|
|
export async function deleteWorktreeCmd(worktreeId: string): Promise<void> {
|
|
return invoke("delete_worktree_cmd", { worktreeId });
|
|
}
|
|
export async function listLocalBranches(projectId: string): Promise<string[]> {
|
|
return invoke("list_local_branches", { projectId });
|
|
}
|
|
|
|
// Notifications
|
|
export async function listNotifications(
|
|
projectId: string,
|
|
unreadOnly: boolean
|
|
): Promise<OrchaiNotification[]> {
|
|
return invoke("list_notifications", { projectId, unreadOnly });
|
|
}
|
|
export async function markNotificationRead(id: string): Promise<void> {
|
|
return invoke("mark_notification_read", { id });
|
|
}
|
|
export async function markAllNotificationsRead(projectId: string): Promise<number> {
|
|
return invoke("mark_all_notifications_read", { projectId });
|
|
}
|
|
|
|
// Project modules
|
|
export async function listProjectModules(projectId: string): Promise<ProjectModule[]> {
|
|
return invoke("list_project_modules", { projectId });
|
|
}
|
|
|
|
export async function setProjectModuleEnabled(
|
|
projectId: string,
|
|
moduleKey: string,
|
|
enabled: boolean
|
|
): Promise<void> {
|
|
return invoke("set_project_module_enabled", { projectId, moduleKey, enabled });
|
|
}
|
|
|
|
// Live agent
|
|
export async function createLiveSession(
|
|
projectId: string,
|
|
agentId: string,
|
|
title: string
|
|
): Promise<LiveSession> {
|
|
return invoke("create_live_session", { projectId, agentId, title });
|
|
}
|
|
|
|
export async function listLiveSessions(projectId: string): Promise<LiveSession[]> {
|
|
return invoke("list_live_sessions", { projectId });
|
|
}
|
|
|
|
export async function listLiveMessages(sessionId: string): Promise<LiveMessage[]> {
|
|
return invoke("list_live_messages", { sessionId });
|
|
}
|
|
|
|
export async function setLiveSessionArchived(
|
|
sessionId: string,
|
|
archived: boolean
|
|
): Promise<LiveSession> {
|
|
return invoke("set_live_session_archived", { sessionId, archived });
|
|
}
|
|
|
|
export async function sendLiveMessage(
|
|
sessionId: string,
|
|
message: string
|
|
): Promise<LiveAgentExchange> {
|
|
return invoke("send_live_message", { sessionId, message });
|
|
}
|
|
|
|
// Agent tasks
|
|
export async function createAgentTask(
|
|
projectId: string,
|
|
agentId: string,
|
|
title: string,
|
|
description: string
|
|
): Promise<AgentTask> {
|
|
return invoke("create_agent_task", { projectId, agentId, title, description });
|
|
}
|
|
|
|
export async function listAgentTasks(projectId: string): Promise<AgentTask[]> {
|
|
return invoke("list_agent_tasks", { projectId });
|
|
}
|
|
|
|
export async function retryAgentTask(taskId: string): Promise<void> {
|
|
return invoke("retry_agent_task", { taskId });
|
|
}
|
|
|
|
export async function cancelAgentTask(taskId: string): Promise<void> {
|
|
return invoke("cancel_agent_task", { taskId });
|
|
}
|