diff --git a/frontend/src/a2a.js b/frontend/src/a2a.js index 219d3f4..9fd3342 100644 --- a/frontend/src/a2a.js +++ b/frontend/src/a2a.js @@ -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(); @@ -40,11 +46,12 @@ export async function callSkill(config, skillName, args) { if (config.auth?.invokeRequiresSession) { await requireSession(config); } - const result = 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 }), }); + const result = unwrapInvokeResponse(payload); if (result?.status === "setup_required") { throw new Error(result.message || "Setup required before running this skill."); }