diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index fcf87d6..6de9587 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -1,16 +1,22 @@ import { useEffect, useMemo, useState } from "react"; -import { - callSkill, - loadAgentConfig, - loadSession, - sampleArgs, -} from "./a2a.js"; +import { callSkill, loadAgentConfig, loadSession } from "./a2a.js"; + +const SAMPLE_EMAIL = { + sender_email: "Customer Example ", + subject: "Refund request for pi_test123", + body: "Please refund 25.00 USD for payment pi_test123.", + message_id: "", + stripe_payment_intent_id: "pi_test123", + requested_refund_amount_cents: 2500, + currency: "usd", + customer_name: "Customer", +}; export function App() { const [config, setConfig] = useState(null); const [session, setSession] = useState(null); - const [selectedSkillName, setSelectedSkillName] = useState(""); - const [argsText, setArgsText] = useState("{}"); + const [selectedSkillName, setSelectedSkillName] = useState("process_support_email"); + const [argsText, setArgsText] = useState(JSON.stringify(SAMPLE_EMAIL, null, 2)); const [result, setResult] = useState(null); const [error, setError] = useState(null); const [running, setRunning] = useState(false); @@ -19,11 +25,6 @@ export function App() { loadAgentConfig() .then((data) => { setConfig(data); - const firstSkill = data.skills?.[0]; - if (firstSkill) { - setSelectedSkillName(firstSkill.name); - setArgsText(JSON.stringify(sampleArgs(firstSkill), null, 2)); - } return loadSession(data).catch(() => null); }) .then((sessionData) => setSession(sessionData)) @@ -35,11 +36,22 @@ export function App() { [config, selectedSkillName], ); - function selectSkill(skill) { - setSelectedSkillName(skill.name); - setArgsText(JSON.stringify(sampleArgs(skill), null, 2)); + function selectSkill(name) { + setSelectedSkillName(name); setResult(null); setError(null); + if (name === "process_support_email") setArgsText(JSON.stringify(SAMPLE_EMAIL, null, 2)); + if (name === "execute_approved_refund") { + setArgsText(JSON.stringify({ + action_digest: "paste_action_digest_from_preview", + approval_token: "APPROVE-REFUND-first16digest", + stripe_payment_intent_id: "pi_test123", + amount_cents: 2500, + currency: "usd", + customer_email: "customer@example.com", + reason: "requested_by_customer", + }, null, 2)); + } } async function runSkill(event) { @@ -60,34 +72,30 @@ export function App() { } if (!config) { - return ( -
-

{error || "Loading A2A agent contract..."}

-
- ); + return

{error || "Loading support refund agent..."}

; } + const skills = config.skills || []; + return (