fix frontend invoke result handling

This commit is contained in:
2026-07-19 13:08:00 -03:00
parent c10f522a55
commit 83c1166075

View File

@@ -1,5 +1,11 @@
export const CONFIG_URL = import.meta.env.DEV ? "/config.json" : "./config.json";
export function unwrapInvokeResponse(payload) {
return payload && typeof payload === "object" && "result" in payload
? payload.result
: payload;
}
export async function requestJson(url, init = {}) {
const response = await fetch(url, { credentials: "same-origin", ...init });
const text = await response.text();
@@ -51,11 +57,12 @@ export async function callSkill(config, skillName, args) {
await requireSession(config);
}
try {
return await requestJson(`${config.endpoints.invoke}/${encodeURIComponent(skillName)}`, {
const payload = await requestJson(`${config.endpoints.invoke}/${encodeURIComponent(skillName)}`, {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ arguments: args }),
});
return unwrapInvokeResponse(payload);
} catch (err) {
if (err.status === 401) {
const target = signInUrl(config);