// capitolare.js — minimal JS SDK const CAP = "https://hivemorph.onrender.com/v1/capitolare"; export class Capitolare { constructor({ framework = "custom", agent_did = "" } = {}) { this.framework = framework; this.agent_did = agent_did; this.p = null; } async enter() { const r = await fetch(`${CAP}/enter`, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ framework: this.framework, agent_did: this.agent_did }), }); this.p = await r.json(); return this.p; } async propose(counterparty_passport_id, job_kind, amount_micro_usdc = 500_000) { const r = await fetch(`${CAP}/propose`, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ proposer_passport_id: this.p.passport_id, counterparty_passport_id, job_kind, amount_micro_usdc, }), }); return await r.json(); } async accept(session_id) { const r = await fetch(`${CAP}/accept`, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ session_id, accepter_passport_id: this.p.passport_id }), }); return await r.json(); } async settle(session_id, { sealed = false, tx_hash = "" } = {}) { const r = await fetch(`${CAP}/settle`, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ session_id, sealed, tx_hash }), }); return await r.json(); } }