From 30aebdf5e004888218d466394e989edcac20ebe6 Mon Sep 17 00:00:00 2001 From: a2a-cloud Date: Sat, 18 Jul 2026 03:26:49 +0000 Subject: [PATCH] a2a-source-edit: remove frontend/src/a2a.js --- frontend/src/a2a.js | 66 --------------------------------------------- 1 file changed, 66 deletions(-) delete mode 100644 frontend/src/a2a.js diff --git a/frontend/src/a2a.js b/frontend/src/a2a.js deleted file mode 100644 index 0251692..0000000 --- a/frontend/src/a2a.js +++ /dev/null @@ -1,66 +0,0 @@ -export const CONFIG_URL = import.meta.env.DEV ? "/config.json" : "./config.json"; - -export async function requestJson(url, init = {}) { - const response = await fetch(url, { credentials: "same-origin", ...init }); - const text = await response.text(); - let data = null; - try { - data = text ? JSON.parse(text) : null; - } catch { - data = { message: text }; - } - if (!response.ok) { - const detail = data && (data.detail || data.message || data.error); - const err = new Error(detail || `request failed: ${response.status}`); - err.status = response.status; - throw err; - } - return data; -} - -export async function loadAgentConfig() { - return requestJson(CONFIG_URL); -} - -export async function loadSession(config) { - return requestJson(config.endpoints.session); -} - -export function signInUrl(config) { - const target = config.auth?.authorizeUrl || config.auth?.loginUrl; - if (!target) return null; - const next = encodeURIComponent( - window.location.pathname + window.location.search + window.location.hash, - ); - return `${target}${target.includes("?") ? "&" : "?"}next=${next}`; -} - -export async function callSkill(config, skillName, args) { - return requestJson(`${config.endpoints.invoke}/${encodeURIComponent(skillName)}`, { - method: "POST", - headers: { "content-type": "application/json" }, - body: JSON.stringify({ arguments: args }), - }); -} - -export async function fileToBrowserDocument(file, maxBytes = 128000) { - if (file.size > maxBytes) { - throw new Error(`${file.name} is too large. Upload files up to ${Math.round(maxBytes / 1000)} KB.`); - } - const mediaType = file.type || (file.name.endsWith(".json") ? "application/json" : file.name.endsWith(".csv") ? "text/csv" : "text/plain"); - if (!["text/csv", "text/plain", "application/json"].includes(mediaType)) { - throw new Error(`${file.name} must be CSV, JSON, or plain text.`); - } - const buffer = await file.arrayBuffer(); - let binary = ""; - const bytes = new Uint8Array(buffer); - const chunkSize = 0x8000; - for (let i = 0; i < bytes.length; i += chunkSize) { - binary += String.fromCharCode(...bytes.subarray(i, i + chunkSize)); - } - return { - filename: file.name, - media_type: mediaType, - data_base64: btoa(binary), - }; -}