const endpoint = process.env.VISIONX_AGENT_ENDPOINT; // This app's /api/public/agents/discovery
const key = process.env.VISIONX_AGENT_KEY; // Server-side service credential only
const agent = { external_id: "claims-worker-v1", name: "Claims worker", type: "workflow", framework: "LangGraph" };
async function report(op, payload) {
  const response = await fetch(endpoint, { method: "POST", headers: { "Authorization": "Bearer " + key, "Content-Type": "application/json" }, body: JSON.stringify({ op, payload }) });
  if (!response.ok) throw new Error("Registration refused: " + response.status);
  return response.json();
}
const registration = await report("register", agent);
const correlation_id = crypto.randomUUID();
await report("tool_start", { agent_id: registration.agents[0].id, correlation_id, tool_name: "documents.read" });
// Execute your own separately authorized tool. Never send arguments, prompts or results.
await report("tool_finish", { agent_id: registration.agents[0].id, correlation_id, tool_name: "documents.read", outcome: "success" });
await report("heartbeat", { agent_id: registration.agents[0].id });
