diff --git a/frontend/src/a2a.js b/frontend/src/a2a.js index 6c17a5d..52bd3be 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(); @@ -34,7 +40,7 @@ export function signInUrl(config) { } export async function callSkill(config, skillName, args) { - return requestJson( + const payload = await requestJson( `${config.endpoints.invoke}/${encodeURIComponent(skillName)}`, { method: "POST", @@ -42,6 +48,7 @@ export async function callSkill(config, skillName, args) { body: JSON.stringify({ arguments: args }), }, ); + return unwrapInvokeResponse(payload); } export function fixtureInvoices() {