JuanCS-Dev's picture
Deploy: streamer Stream Deck dashboard at /studio
7e736bc verified
Raw History Blame Contribute Delete
2.97 kB
// dashboard/features/studio/api.js
// Thin wrappers over the real bot endpoints, reusing the shared fetch helper
// (which injects the admin token and rewrites /api paths for HF Spaces).
import { fetchWithTimeout } from "../shared/api.js";
const TIMEOUT = 12000;
export function getControlPlane() {
return fetchWithTimeout("/api/control-plane", { method: "GET" }, TIMEOUT);
}
export function getSentiment(channel = "default") {
return fetchWithTimeout(
`/api/sentiment/scores?channel=${encodeURIComponent(channel)}`,
{ method: "GET" },
TIMEOUT,
);
}
export function getHudMessages(since = 0) {
return fetchWithTimeout(
`/api/hud/messages?since=${encodeURIComponent(since)}`,
{ method: "GET" },
TIMEOUT,
);
}
export function getClipJobs() {
return fetchWithTimeout("/api/clip-jobs", { method: "GET" }, TIMEOUT);
}
export function getVisionStatus() {
return fetchWithTimeout("/api/vision/status", { method: "GET" }, TIMEOUT);
}
export function getChurnRisk(channel = "default") {
return fetchWithTimeout(
`/api/coaching/churn-risk?channel=${encodeURIComponent(channel)}`,
{ method: "GET" },
TIMEOUT,
);
}
export function getObservability(channel = "default") {
return fetchWithTimeout(
`/api/observability?channel=${encodeURIComponent(channel)}`,
{ method: "GET" },
TIMEOUT,
);
}
export function getActionQueue(limit = 20) {
return fetchWithTimeout(
`/api/action-queue?limit=${encodeURIComponent(limit)}`,
{ method: "GET" },
TIMEOUT,
);
}
// ---- Actions (POST) ----
export function suspendAgent() {
return fetchWithTimeout(
"/api/agent/suspend",
{ method: "POST", body: JSON.stringify({}) },
TIMEOUT,
);
}
export function resumeAgent() {
return fetchWithTimeout(
"/api/agent/resume",
{ method: "POST", body: JSON.stringify({}) },
TIMEOUT,
);
}
export function sendChat(text, channelId = null) {
return fetchWithTimeout(
"/api/chat/send",
{ method: "POST", body: JSON.stringify({ text, channel_id: channelId }) },
20000,
);
}
export function autonomyTick() {
return fetchWithTimeout(
"/api/autonomy/tick",
{ method: "POST", body: JSON.stringify({}) },
TIMEOUT,
);
}
export function decideAction(actionId, decision) {
return fetchWithTimeout(
`/api/action-queue/${encodeURIComponent(actionId)}/decision`,
{ method: "POST", body: JSON.stringify({ decision }) },
TIMEOUT,
);
}
// action: "join" | "part" | "list"
export function channelAction(action, channel = "") {
return fetchWithTimeout(
"/api/channel-control",
{ method: "POST", body: JSON.stringify({ action, channel }) },
TIMEOUT,
);
}
export function getPostStreamReport(channel = "default", generate = false) {
return fetchWithTimeout(
`/api/observability/post-stream-report?channel=${encodeURIComponent(
channel,
)}&generate=${generate ? "true" : "false"}`,
{ method: "GET" },
30000,
);
}