feat(webui): chat from the dashboard
Brings the chat surface to the Web UI: /api/chat with its own handlers and tests, a self-contained ui/src/chat feature folder, and the shared plumbing to reach the same router Telegram uses. Includes a dangerous-command approval path (internal/gateway/dangerous.go, internal/webui/dangerous.go, and the Telegram counterpart) so /rollback and /stop are gated the same way on both surfaces, persona handling for web sessions, and release-update formatting split out of the Telegram service so both can render it. web_parity_test.go pins that the two surfaces expose the same commands. Authored in a parallel session; committed here so it lands with the rest rather than sitting uncommitted while other work builds on top of it. task check passes with it in place. Screenshots used while building are gitignored (*.png) rather than committed, matching the call made on the earlier design reference.
This commit is contained in:
1 parent
8ae21f25db
commit
68ba3456ee
29 files changed
+2616
-112
No files matched your search
@@ -71,6 +71,67 @@ export const api = {
|
||||
config: () => req("/api/config"),
|
||||
logs: (params) => req("/api/logs" + qs(params)),
|
||||
memory: () => req("/api/memory"),
|
||||
chatSessions: () => req("/api/chat/sessions"),
|
||||
chatMessages: (id) => req(`/api/chat/sessions/${encodeURIComponent(id)}/messages`),
|
||||
chatCancel: async (sessionID) => {
|
||||
const res = await fetch("/api/chat/cancel", {
|
||||
method: "POST", headers: { Accept: "application/json", "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ session_id: sessionID }), signal: AbortSignal.timeout(15000),
|
||||
});
|
||||
if (!res.ok) throw new ApiError(await errorMessage(res), res.status);
|
||||
return res.json();
|
||||
},
|
||||
chatMessage: async (channelID, text) => {
|
||||
const res = await fetch("/api/chat/message", {
|
||||
method: "POST", headers: { Accept: "application/json", "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ channel_id: channelID, source_id: crypto.randomUUID(), text }),
|
||||
signal: AbortSignal.timeout(15000),
|
||||
});
|
||||
if (!res.ok) throw new ApiError(await errorMessage(res), res.status);
|
||||
return res.json();
|
||||
},
|
||||
chatPersona: async (sessionID, name) => {
|
||||
const res = await fetch("/api/chat/persona", {
|
||||
method: "POST", headers: { Accept: "application/json", "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ session_id: sessionID, name }), signal: AbortSignal.timeout(15000),
|
||||
});
|
||||
if (!res.ok) throw new ApiError(await errorMessage(res), res.status);
|
||||
return res.json();
|
||||
},
|
||||
chatUpdate: () => req("/api/chat/update"),
|
||||
chatUpdateDefer: async (snapshot) => {
|
||||
const res = await fetch("/api/chat/update/defer", {
|
||||
method: "POST", headers: { Accept: "application/json", "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ snapshot }), signal: AbortSignal.timeout(15000),
|
||||
});
|
||||
if (!res.ok) throw new ApiError(await errorMessage(res), res.status);
|
||||
return res.json();
|
||||
},
|
||||
chatUpdateInstall: async (snapshot) => {
|
||||
const res = await fetch("/api/chat/update/install", {
|
||||
method: "POST", headers: { Accept: "application/json", "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ snapshot }), signal: AbortSignal.timeout(120000),
|
||||
});
|
||||
if (!res.ok) throw new ApiError(await errorMessage(res), res.status);
|
||||
return res.json();
|
||||
},
|
||||
chatDangerous: () => req("/api/chat/dangerous"),
|
||||
chatDangerousRequest: async (kind, spec) => {
|
||||
const res = await fetch(`/api/chat/dangerous/${encodeURIComponent(kind)}`, {
|
||||
method: "POST", headers: { Accept: "application/json", "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ spec }), signal: AbortSignal.timeout(15000),
|
||||
});
|
||||
if (!res.ok) throw new ApiError(await errorMessage(res), res.status);
|
||||
return res.json();
|
||||
},
|
||||
chatDangerousDecision: async (id, decision) => {
|
||||
const res = await fetch(`/api/chat/dangerous/${encodeURIComponent(id)}/decision`, {
|
||||
method: "POST", headers: { Accept: "application/json", "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ decision }), signal: AbortSignal.timeout(15000),
|
||||
});
|
||||
if (!res.ok) throw new ApiError(await errorMessage(res), res.status);
|
||||
return res.json();
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user