/** Safe PHION reference flow: DISCOVER -> INTENT -> PREFLIGHT. Never pays or executes. */ const base = "https://phion.systems"; const headers = { "content-type": "application/json", "user-agent": "phion-reference-client-typescript/1.46.4", "x-phion-discovery-source": "reference_client", }; const get = async (path: string) => (await fetch(base + path, { headers })).json(); const post = async (path: string, body: unknown) => (await fetch(base + path, { method: "POST", headers, body: JSON.stringify(body) })).json(); const discovery: any = await get("/v1/discovery"); const intent: any = await post("/v1/intent", { intent: "verify public web evidence with signed sources", budgetUsdc: 0.005, }); const service = intent.recommendedService ?? intent.eligibleServices?.[0]; if (!service) throw new Error("PHION abstained: no eligible service"); const preflight = await post("/v1/preflight/service", { serviceId: service.serviceId, input: { url: "https://example.com" }, network: "eip155:8453", intentId: intent.intentId, correlationId: intent.correlationId, }); console.log(JSON.stringify({ serviceCount: discovery.serviceCount, intent, preflight }, null, 2)); // Stop here. Inspect the immutable offer and payment requirements before authorization.