remote voice receiving and talking

This commit is contained in:
KingKDot
2026-03-07 23:27:57 -06:00
parent fb9f10bb45
commit 51a653a6aa
21 changed files with 1559 additions and 3 deletions
+45
View File
@@ -122,6 +122,51 @@ export async function sendCommand(clientId, action) {
}
}
export async function sendSupportChat(clientId, message, requireReply = true) {
try {
const res = await fetch(`/api/clients/${clientId}/command`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ action: "support_chat", message, requireReply }),
});
const data = await res.json().catch(() => ({}));
if (!res.ok) {
return {
ok: false,
error: data?.error || `support chat failed ${res.status}`,
response: "",
};
}
return {
ok: Boolean(data?.ok),
error: data?.error || "",
response: typeof data?.response === "string" ? data.response : "",
};
} catch (err) {
console.error(err);
return { ok: false, error: "Support chat request failed", response: "" };
}
}
export async function fetchVoiceCapabilities(clientId) {
try {
const res = await fetch(`/api/clients/${clientId}/command`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ action: "voice_capabilities" }),
});
const data = await res.json().catch(() => ({}));
return {
ok: Boolean(data?.ok),
capabilities: data?.capabilities || null,
error: data?.error || (res.ok ? "" : `voice capabilities failed ${res.status}`),
};
} catch (err) {
console.error(err);
return { ok: false, capabilities: null, error: "Voice capability probe failed" };
}
}
export async function requestPreview(clientId) {
const ok = await sendCommand(clientId, "screenshot");
if (ok) {