import { request } from "../../app/api.js";

export const sendSessionMessage = (sessionId, payload) => request(`/sessions/${sessionId}/messages`, { method: "POST", body: typeof payload === "string" ? { text: payload } : payload });
export const decideSessionApproval = (sessionId, approvalId, decision) => request(`/sessions/${sessionId}/approvals/${approvalId}`, { method: "POST", body: { decision } });
export const attachThreadWorkspace = (accountId, threadId, workspaceId) => request(`/accounts/${encodeURIComponent(accountId)}/threads/${encodeURIComponent(threadId)}/open`, { method: "POST", body: { workspaceId } });
export const listConversationCapabilities = (accountId, workspaceId) => request(`/accounts/${encodeURIComponent(accountId)}/capabilities?workspaceId=${encodeURIComponent(workspaceId ?? "")}`);
export const uploadSessionAttachment = (sessionId, attachment) => request(`/sessions/${sessionId}/attachments`, { method: "POST", body: attachment });
export const deleteSessionAttachment = (sessionId, attachmentId) => request(`/sessions/${encodeURIComponent(sessionId)}/attachments/${encodeURIComponent(attachmentId)}`, { method: "DELETE" });
export const stopSessionTurn = (sessionId) => request(`/sessions/${sessionId}/stop`, { method: "POST" });

export const steerQueuedSessionMessage = (sessionId, queuedMessageId) => request(`/sessions/${sessionId}/queued-messages/${queuedMessageId}/steer`, { method: "POST" });
export const deleteQueuedSessionMessage = (sessionId, queuedMessageId) => request(`/sessions/${sessionId}/queued-messages/${queuedMessageId}`, { method: "DELETE" });
