SphereFlow is a policy-constrained agent that buys a recurring service on Unicity Testnet2 without a person approving each payment. An operator sets a standing goal and limits once. The agent service then discovers supplier quotes through the Sphere intent market, chooses an eligible counterparty, and settles a UCT payment with its own persisted wallet.
| Field | Value |
|---|---|
| Track | Autonomous agents / Payments and markets |
| Network | Unicity Testnet2 (network ID 4) |
| Agentic | Yes, when agent:run is deployed on a schedule. The worker makes and settles a purchase without a per-payment click. |
| AstridOS | In progress — an Astrid capsule source is included, but do not claim the AstridOS XP boost until the capsule has been built and installed in an Astrid runtime. |
| Live dashboard | https://sphereflow-psi.vercel.app |
The dashboard is only the control plane. The economic action runs in agent/treasury-agent.mjs:
- Reads enabled procurement goals from Supabase.
- Searches Sphere's signed intent market for a matching service offer.
- Filters quotes by expiry, trusted-supplier setting, unit-price ceiling, rolling 24-hour budget, and interval budget.
- Claims one durable, idempotent job using a database lease.
- Sends UCT to the selected counterparty using the Testnet2 Node SDK wallet.
- Writes a hash-linked audit event and never re-sends an indeterminate settlement.
The agent wallet is separate from the browser wallet. Its key material lives only in SPHEREFLOW_AGENT_DATA_DIR, and the service-role database key never enters the dashboard bundle.
Operator goal + limits → Supabase durable queue → SphereFlow worker
├─ Sphere intent market search
├─ deterministic policy selection
├─ Testnet2 UCT settlement
└─ hash-linked audit trail
Prerequisites: Node 22+, a Supabase project, and a funded Testnet2 Sphere wallet for the worker. Testnet UCT is self-minted through the official SDK; it is not mainnet value.
- Install app dependencies and copy
.env.exampleto.env.local. - Run
supabase/migrations/20260727_autonomous_procurement.sqlin the Supabase SQL editor. - Set
SUPABASE_URL,SUPABASE_SERVICE_ROLE_KEY, and a non-sharedSPHEREFLOW_AGENT_DATA_DIR. Never use aNEXT_PUBLIC_name for the service key. - On first boot, set
SPHEREFLOW_AGENT_AUTOGENERATE=true, runnpm run agent:run, save the generated wallet recovery phrase offline, then set it back tofalse. - Fund the agent's Testnet2 wallet and register/publish its identity. Add at least one supplier
serviceintent in the Sphere market. Its description must containservice=<tag>;recipient=<@nametag-or-DIRECT-address>; set its market price in UCT and its expiry normally. - Insert an enabled
procurement_goalsrow. Setservice_tagto the offer tag andmax_unit_price_uctto its maximum price. Whenrequire_trusted_supplier=true, settrusted_suppliersto the supplier's marketagentPublicKeyor recipient address—the supplier cannot self-attest into this allow-list. - Run
npm run agent:runfrom a persistent process, container, or scheduled job at least as often as the goal interval. The service needs a persistent volume forSPHEREFLOW_AGENT_DATA_DIR. For Astrid-controlled invocation, runnode agent/treasury-agent.mjs --serve; it exposes an authenticated/tickendpoint only on loopback by default.
The app itself runs with npm run dev. Use npm run build before deployment (must pass for submission).
npm run agent:dry-run # queue only
npm run agent:run # one full autonomous tick
npm run agent:serve # POST /tick on loopback for Astrid/cronFollow-on operators: see docs/HANDOFF.md for remaining live-environment steps.
- Record the goal and the supplier's signed market offer.
- Run the worker with no dashboard interaction.
- Show the resulting
procurement_jobs.transfer_id, the matching Testnet2 wallet history entry, and theagent_audit_eventschain. - Re-run the worker in the same interval: the unique idempotency key must prevent a second payment.
- Change the quote above the cap or let it expire: the job must be skipped, never paid.
- A database lease prevents concurrent workers from paying the same job.
- A unique interval-derived idempotency key prevents duplicate scheduled work.
CERTIFICATION_UNCONFIRMEDbecomessent_pending_confirmation; it is deliberately never retried as a new send.- The database tables have RLS enabled and are accessed by the worker using the Supabase service role only.
- The worker’s intent-market parser intentionally rejects offers without the required machine-readable quote fields.
astrid/sphereflow-procurement/ contains the capsule manifest and source for an Astrid capability-gated tick tool. Install Astrid, install the official JavaScript capsule SDK, build the capsule, and wire its HTTP tool to a privately authenticated worker endpoint before claiming the Astrid boost. The current browser “Astrid-aligned” controls are product UX only and are not the Astrid runtime.