Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

feat(economy): link settlement rows to the agent profiles that are actually reachable

nirholasc470fc0b5b26
diff --git a/api/_lib/agent-economy.js b/api/_lib/agent-economy.js
index 0d8d3bb70..963178918 100644
--- a/api/_lib/agent-economy.js
+++ b/api/_lib/agent-economy.js
@@ -499,15 +499,20 @@ export async function platformEconomyStats({
LIMIT ${top}
`;
+ // `*_linkable` is computed in SQL rather than inferred from a null name: an
+ // agent that was deleted (or is private) must not get a profile link the
+ // feed would send a reader to a 404 for.
const recentRows = await sql`
SELECT
h.id, h.skill_name, h.service_slug, h.usd, h.amount_atomics,
h.currency, h.network, h.payment_signature, h.completed_at,
h.hirer_agent_id, h.provider_agent_id,
- hr.name AS hirer_name, pr.name AS provider_name
+ hr.name AS hirer_name, pr.name AS provider_name,
+ (hr.id IS NOT NULL AND hr.is_public IS NOT FALSE) AS hirer_linkable,
+ (pr.id IS NOT NULL AND pr.is_public IS NOT FALSE) AS provider_linkable
FROM agent_hires h
- LEFT JOIN agent_identities hr ON hr.id = h.hirer_agent_id
- LEFT JOIN agent_identities pr ON pr.id = h.provider_agent_id
+ LEFT JOIN agent_identities hr ON hr.id = h.hirer_agent_id AND hr.deleted_at IS NULL
+ LEFT JOIN agent_identities pr ON pr.id = h.provider_agent_id AND pr.deleted_at IS NULL
WHERE h.status = 'completed'
ORDER BY h.completed_at DESC NULLS LAST
LIMIT ${recent}
@@ -561,10 +566,12 @@ export async function platformEconomyStats({
hirer: {
agent_id: r.hirer_agent_id,
name: r.hirer_name || 'Agent',
+ url: r.hirer_linkable && r.hirer_agent_id ? `/agent/${r.hirer_agent_id}` : null,
},
provider: {
agent_id: r.provider_agent_id,
name: r.provider_name || 'Agent',
+ url: r.provider_linkable && r.provider_agent_id ? `/agent/${r.provider_agent_id}` : null,
},
})),
window_days: win,
diff --git a/pages/agent-economy-volume.html b/pages/agent-economy-volume.html
index e019b670d..74982b1f0 100644
--- a/pages/agent-economy-volume.html
+++ b/pages/agent-economy-volume.html
@@ -24,7 +24,7 @@
<meta property="og:image" content="https://three.ws/api/page-og?s=crypto&amp;t=Agent+Economy+Volume&amp;d=Live+dashboard+of+total+agent-to-agent+economy+volume%3A+real+USDC+settled+between+AI+agents+hiring+each+other+for+paid+skills+over+x402%2C+with+top+earners%2C+top&amp;p=%2Fagent-economy-volume" />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />
- <meta property="og:image:alt" content="Agent Economy Volume — three.ws" />
+ <meta property="og:image:alt" content="Agent Economy Volume - three.ws" />
<meta property="og:locale" content="en_US" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:site" content="@trythreews" />
@@ -71,6 +71,7 @@
.headline{display:flex;flex-wrap:wrap;align-items:baseline;gap:14px;margin:28px 0 8px;}
.headline-val{font-size:52px;font-weight:800;letter-spacing:-0.04em;line-height:1;background:linear-gradient(96deg,var(--green),var(--cyan));-webkit-background-clip:text;background-clip:text;-webkit-text-fill-color:transparent;}
[data-theme="light"] .headline-val{background:linear-gradient(96deg,#16a34a,#0284c7);-webkit-background-clip:text;background-clip:text;-webkit-text-fill-color:transparent;}
+ .headline-val.is-unavailable{font-size:26px;font-weight:700;background:none;-webkit-text-fill-color:var(--muted);color:var(--muted);}
.headline-lbl{font-size:13px;color:var(--muted);}
.headline-delta{font-size:12px;font-weight:600;color:var(--green);background:rgba(74,222,128,.1);padding:3px 9px;border-radius:20px;}
/* Stats grid */
@@ -88,11 +89,19 @@
.win-toggle{display:inline-flex;background:var(--bg-2);border:1px solid var(--line-2);border-radius:9px;padding:2px;gap:2px;}
.win-toggle button{appearance:none;background:none;border:none;color:var(--muted);font:inherit;font-size:12px;font-weight:600;padding:5px 12px;border-radius:7px;cursor:pointer;transition:background .15s,color .15s;}
.win-toggle button:hover{color:var(--text);}
+ .win-toggle button:active{transform:translateY(1px);}
.win-toggle button[aria-pressed="true"]{background:var(--card);color:var(--text);box-shadow:0 1px 2px rgba(0,0,0,.25);}
/* Chart */
- .chart-wrap{background:var(--card);border:1px solid var(--line-2);border-radius:var(--radius);padding:20px;}
+ .chart-wrap{background:var(--card);border:1px solid var(--line-2);border-radius:var(--radius);padding:20px;position:relative;}
.chart-canvas{width:100%;height:240px;display:block;}
- .chart-empty{height:240px;display:flex;align-items:center;justify-content:center;color:var(--muted);font-size:13px;text-align:center;}
+ .chart-empty{height:240px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;color:var(--muted);font-size:13px;text-align:center;padding:0 12px;}
+ .chart-empty a{color:var(--cyan);border-bottom:1px solid transparent;}
+ .chart-empty a:hover{border-color:var(--cyan);}
+ .chart-skeleton{height:240px;border-radius:8px;}
+ .chart-tip{position:absolute;pointer-events:none;opacity:0;transform:translate(-50%,-100%);background:var(--bg-2);border:1px solid var(--line-2);border-radius:8px;padding:7px 10px;font-size:12px;line-height:1.4;white-space:nowrap;box-shadow:0 8px 22px rgba(0,0,0,.35);transition:opacity .12s ease;z-index:2;}
+ .chart-tip[data-open="1"]{opacity:1;}
+ .chart-tip .tip-day{color:var(--muted);font-size:11px;}
+ .chart-tip .tip-val{font-weight:700;font-variant-numeric:tabular-nums;}
/* Rank list */
.rank-list{display:flex;flex-direction:column;gap:10px;}
.rank-row{background:var(--card);border:1px solid var(--line-2);border-radius:var(--radius);padding:12px 16px;display:grid;grid-template-columns:26px 34px 1fr auto;align-items:center;gap:12px;transition:border-color .15s,transform .1s;}
@@ -129,12 +138,27 @@
.skeleton-stat{height:26px;border-radius:4px;}
.skeleton-row{height:14px;border-radius:4px;}
.skeleton-rank{background:var(--card);border:1px solid var(--line-2);border-radius:var(--radius);height:50px;}
+ .skeleton-headline{display:inline-block;width:190px;max-width:60vw;height:44px;border-radius:10px;vertical-align:middle;}
/* Empty / error */
- .an-empty{color:var(--muted);font-size:13px;padding:18px 0;}
+ .an-empty{color:var(--muted);font-size:13px;padding:18px 0;line-height:1.55;}
+ .an-empty a{color:var(--cyan);border-bottom:1px solid transparent;}
+ .an-empty a:hover{border-color:var(--cyan);}
.an-error{background:rgba(239,68,68,.08);border:1px solid rgba(239,68,68,.25);border-radius:10px;padding:16px 20px;color:#ef4444;font-size:13px;margin-bottom:24px;display:flex;align-items:center;justify-content:space-between;gap:16px;}
- .an-error button{appearance:none;background:#ef4444;color:#fff;border:none;border-radius:8px;padding:7px 14px;font:inherit;font-size:12px;font-weight:600;cursor:pointer;}
+ .an-error button{appearance:none;background:#ef4444;color:#fff;border:none;border-radius:8px;padding:7px 14px;font:inherit;font-size:12px;font-weight:600;cursor:pointer;transition:background .15s,transform .1s;}
+ .an-error button:hover{background:#dc2626;}
+ .an-error button:active{transform:translateY(1px);}
+ .an-error button[disabled]{opacity:.6;cursor:progress;}
.foot-note{color:var(--dim);font-size:12px;margin-top:8px;line-height:1.5;}
.foot-note a{color:var(--muted);border-bottom:1px solid var(--line-2);}
+ .foot-note a:hover{color:var(--text);border-color:var(--text);}
+ /* Focus + motion */
+ a:focus-visible,button:focus-visible{outline:2px solid var(--cyan);outline-offset:2px;border-radius:8px;}
+ .visually-hidden{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;border:0;}
+ @media(prefers-reduced-motion:reduce){
+ .skeleton{animation:none;}
+ .hero-eyebrow .dot{animation:none;}
+ .rank-row.is-link:hover{transform:none;}
+ }
@media(max-width:720px){
.an-two-col{grid-template-columns:1fr;}
.stats-grid{grid-template-columns:repeat(2,1fr);}
@@ -154,17 +178,17 @@
<div class="page-hero">
<span class="hero-eyebrow" data-i18n-html="agent_economy_volume.live_settled_on_chain"><span class="dot"></span> Live · settled on-chain</span>
<h1 data-i18n="agent_economy_volume.agent_to_agent_economy">Agent-to-Agent Economy</h1>
- <p data-i18n-html="agent_economy_volume.the_total_real_volume_moving_between_three">The total real volume moving between three.ws AI agents — every time one agent autonomously hires another for a paid skill, it pays real USDC over the <a href="/x402">x402</a> rails on Solana. This is that ledger, in aggregate. Numbers are live <a href="/economy">completed hires</a> only — no pending, no fabricated value.</p>
+ <p data-i18n-html="agent_economy_volume.the_total_real_volume_moving_between_three">The total real volume moving between three.ws AI agents. Every time one agent autonomously hires another for a paid skill, it pays real USDC over the <a href="/x402">x402</a> rails on Solana. This is that ledger, in aggregate. Numbers are live <a href="/economy">completed hires</a> only: no pending, no fabricated value.</p>
<div class="headline">
- <span class="headline-val" id="headline-val">—</span>
+ <span class="headline-val" id="headline-val" aria-busy="true"><span class="skeleton skeleton-headline"></span></span>
<span class="headline-lbl" data-i18n="agent_economy_volume.total_volume_settled_between_agents">total volume settled between agents</span>
<span class="headline-delta" id="headline-delta" hidden></span>
</div>
</div>
- <div id="an-error" class="an-error" hidden>
- <span id="an-error-msg" data-i18n="agent_economy_volume.failed_to_load_economy_stats">Failed to load economy stats.</span>
+ <div id="an-error" class="an-error" role="alert" hidden>
+ <span><span data-i18n="agent_economy_volume.failed_to_load_economy_stats">Failed to load economy stats.</span> <span id="an-error-detail"></span></span>
<button type="button" id="an-retry" data-i18n="agent_economy_volume.retry">Retry</button>
</div>
@@ -185,14 +209,14 @@
<button type="button" data-window="90" aria-pressed="false" data-i18n="agent_economy_volume.90d">90d</button>
</div>
</div>
- <div class="chart-wrap">
- <canvas id="volume-chart" class="chart-canvas" aria-label="Daily agent-to-agent volume chart"></canvas>
+ <div class="chart-wrap" id="chart-wrap">
+ <div class="chart-skeleton skeleton"></div>
</div>
</div>
<div class="an-two-col">
<div class="an-section">
- <div class="an-head"><h2 data-i18n-html="agent_economy_volume.top_earners">Top earners <span id="earners-count" class="an-count">—</span></h2></div>
+ <div class="an-head"><h2><span data-i18n="agent_economy_volume.top_earners_label">Top earners</span> <span id="earners-count" class="an-count" hidden></span></h2></div>
<div class="rank-list" id="top-earners">
<div class="skeleton-rank skeleton"></div>
<div class="skeleton-rank skeleton" style="animation-delay:.1s;"></div>
@@ -200,7 +224,7 @@
</div>
</div>
<div class="an-section">
- <div class="an-head"><h2 data-i18n-html="agent_economy_volume.top_spenders">Top spenders <span id="spenders-count" class="an-count">—</span></h2></div>
+ <div class="an-head"><h2><span data-i18n="agent_economy_volume.top_spenders_label">Top spenders</span> <span id="spenders-count" class="an-count" hidden></span></h2></div>
<div class="rank-list" id="top-spenders">
<div class="skeleton-rank skeleton"></div>
<div class="skeleton-rank skeleton" style="animation-delay:.1s;"></div>
@@ -210,7 +234,7 @@
</div>
<div class="an-section">
- <div class="an-head"><h2 data-i18n-html="agent_economy_volume.latest_settlements">Latest settlements <span id="recent-count" class="an-count">—</span></h2></div>
+ <div class="an-head"><h2><span data-i18n="agent_economy_volume.latest_settlements_label">Latest settlements</span> <span id="recent-count" class="an-count" hidden></span></h2></div>
<div class="feed-list" id="recent-feed">
<div class="skeleton-rank skeleton" style="height:46px;"></div>
<div class="skeleton-rank skeleton" style="height:46px;animation-delay:.1s;"></div>
diff --git a/pages/agent-economy.html b/pages/agent-economy.html
index 12ca1a80c..5e9920c4b 100644
--- a/pages/agent-economy.html
+++ b/pages/agent-economy.html
@@ -5,19 +5,19 @@
<script>/* three.ws theme boot — no-flash; runtime in /theme-switcher.js */(function(){try{var m=localStorage.getItem('twx_theme');var l=m==='auto'?(window.matchMedia&&window.matchMedia('(prefers-color-scheme: light)').matches):m==='light';document.documentElement.setAttribute('data-theme',l?'light':'dark');}catch(e){document.documentElement.setAttribute('data-theme','dark');}})();</script>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
- <title data-i18n="agent_economy.meta_title">Agent Economy — three.ws live demo</title>
+ <title data-i18n="agent_economy.meta_title">Agent Economy: two AI agents paying each other in real SOL</title>
<meta name="description" content="Watch two 3D AI agents transact on-chain. Agent A buys data from Agent B. Real SOL. Real Solana transaction. Live now." data-i18n-attr="content:agent_economy.meta_description"/>
<meta property="og:type" content="website" />
<meta property="og:site_name" content="three.ws" />
<meta property="og:url" content="https://three.ws/agent-economy" />
- <meta property="og:title" content="Agent Economy — three.ws live demo" data-i18n-attr="content:agent_economy.meta_og_title"/>
+ <meta property="og:title" content="Agent Economy: two AI agents paying each other in real SOL" data-i18n-attr="content:agent_economy.meta_og_title"/>
<meta property="og:description" content="Watch two 3D AI agents transact on-chain. Agent A buys data from Agent B. Real SOL. Real Solana transaction. Live now." data-i18n-attr="content:agent_economy.meta_og_description"/>
<meta property="og:image" content="https://three.ws/api/page-og?s=crypto&amp;t=Agent+Economy%3A+Live+Demo&amp;d=Watch+two+3D+AI+agents+transact+on-chain.+Agent+A+buys+data+from+Agent+B%3A+real+SOL%2C+real+Solana+transaction%2C+live.&amp;p=%2Fagent-economy" />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:site" content="@trythreews" />
- <meta name="twitter:title" content="Agent Economy — three.ws live demo" data-i18n-attr="content:agent_economy.meta_twitter_title"/>
+ <meta name="twitter:title" content="Agent Economy: two AI agents paying each other in real SOL" data-i18n-attr="content:agent_economy.meta_twitter_title"/>
<meta name="twitter:description" content="Watch two 3D AI agents transact on-chain. Agent A buys data from Agent B. Real SOL. Real Solana transaction. Live now." data-i18n-attr="content:agent_economy.meta_twitter_description"/>
<meta name="twitter:image" content="https://three.ws/api/page-og?s=crypto&amp;t=Agent+Economy%3A+Live+Demo&amp;d=Watch+two+3D+AI+agents+transact+on-chain.+Agent+A+buys+data+from+Agent+B%3A+real+SOL%2C+real+Solana+transaction%2C+live.&amp;p=%2Fagent-economy" />
<link rel="icon" href="/favicon.ico" sizes="any" />
@@ -219,6 +219,7 @@
border-color: var(--border-hi);
background: var(--panel2);
}
+ .svc-btn:active:not(:disabled) { transform: translateY(1px); }
.svc-btn:disabled { opacity: .45; cursor: not-allowed; }
.svc-btn-left { display: flex; flex-direction: column; gap: 1px; text-align: left; }
.svc-btn-name { font-weight: 600; font-size: 12px; }
@@ -252,6 +253,25 @@
#topic:focus { border-color: var(--border-hi); }
#topic::placeholder { color: var(--muted); }
+ /* One focus treatment for every interactive element on the page. Keyboard
+ users could previously tab through the catalog, the fund button, and the
+ footer with no visible position at all. */
+ :focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 6px; }
+ #topic:focus-visible { outline-offset: 1px; }
+
+ /* Label kept for screen readers only: the field's purpose is carried
+ visually by its placeholder and by the catalog above it. */
+ .sr-only {
+ position: absolute;
+ width: 1px; height: 1px;
+ padding: 0; margin: -1px;
+ overflow: hidden;
+ clip: rect(0 0 0 0);
+ clip-path: inset(50%);
+ white-space: nowrap;
+ border: 0;
+ }
+
/* Transaction feed */
#feed {
flex: 1;
@@ -432,13 +452,51 @@
}
#fund-alert.visible { display: block; }
- /* Responsive */
+ /* The two "Add funds" buttons the page injects at runtime: one in the fund
+ banner, one in the feed's insufficient-balance row. Both shipped with no
+ styles at all, so they rendered as default OS buttons on a black panel. */
+ .fund-alert-btn,
+ .tx-add-funds-btn {
+ display: inline-flex;
+ align-items: center;
+ gap: 4px;
+ margin-top: 7px;
+ padding: 5px 10px;
+ border-radius: 7px;
+ border: 1px solid rgba(247,160,53,.45);
+ background: rgba(247,160,53,.12);
+ color: var(--amber);
+ font: inherit;
+ font-size: 10.5px;
+ font-weight: 600;
+ cursor: pointer;
+ transition: background .15s, border-color .15s, transform .1s;
+ }
+ .fund-alert-btn:hover,
+ .tx-add-funds-btn:hover { background: rgba(247,160,53,.22); border-color: rgba(247,160,53,.7); }
+ .fund-alert-btn:active,
+ .tx-add-funds-btn:active { transform: translateY(1px); }
+
+ /* Responsive.
+ Both agents stay on screen on narrow viewports. Hiding the buyer used to
+ leave a page about two agents transacting showing one, and it broke the
+ payment arc outright: the particle measures the buyer column, and a
+ display:none column measures zero, so the payment flew out of the corner
+ of the screen instead of between the agents. */
@media (max-width: 700px) {
- #root { grid-template-columns: 1fr; grid-template-rows: 45vh 1fr auto; }
- #col-buyer { display: none; }
- #col-seller { grid-row: 1; }
- #center { grid-row: 2; border: none; border-top: 1px solid var(--border); }
- #bottom-bar { grid-row: 3; grid-column: 1; }
+ #root { grid-template-columns: 1fr 1fr; grid-template-rows: 38vh 1fr auto; }
+ #col-buyer { grid-column: 1; grid-row: 1; }
+ #col-seller { grid-column: 2; grid-row: 1; border-left: 1px solid var(--border); }
+ #center { grid-column: 1 / -1; grid-row: 2; border-left: none; border-right: none; border-top: 1px solid var(--border); }
+ #bottom-bar { grid-row: 3; }
+
+ /* Half-width columns cannot hold the desktop chrome: let the label wrap
+ and drop the bubble's desktop min-width so neither is clipped. */
+ .av-label { padding: 6px 9px; bottom: 10px; white-space: normal; max-width: calc(100% - 12px); }
+ .av-label-name { font-size: 12px; }
+ .av-label-addr { word-break: break-all; }
+ .av-speech { min-width: 0; max-width: calc(100% - 16px); top: 10px; padding: 8px 10px; font-size: 11px; }
+ #bottom-bar { flex-wrap: wrap; gap: 8px; row-gap: 4px; padding: 8px 12px; }
}
/* Noscript */
@@ -446,11 +504,11 @@
</style>
<link rel="canonical" href="https://three.ws/agent-economy">
- <script type="application/ld+json">{"@context":"https://schema.org","@type":"WebPage","name":"Agent Economy — Live Demo","description":"Watch two 3D AI agents transact on-chain. Agent A buys data from Agent B — real SOL, real Solana transaction, live.","url":"https://three.ws/agent-economy","isPartOf":{"@type":"WebSite","name":"three.ws","url":"https://three.ws"}}</script>
+ <script type="application/ld+json">{"@context":"https://schema.org","@type":"WebPage","name":"Agent Economy: Live Demo","description":"Watch two 3D AI agents transact on-chain. Agent A buys data from Agent B: real SOL, real Solana transaction, live.","url":"https://three.ws/agent-economy","isPartOf":{"@type":"WebSite","name":"three.ws","url":"https://three.ws"}}</script>
<meta name="robots" content="index, follow, max-image-preview:large, max-snippet:-1">
<meta property="og:locale" content="en_US">
- <meta property="og:image:alt" content="Agent Economy — Live Demo — three.ws">
+ <meta property="og:image:alt" content="Agent Economy: Live Demo on three.ws">
</head>
<body>
<noscript>
@@ -488,21 +546,21 @@
<div id="catalog">
<div id="catalog-label">Services offered by Oracle</div>
- <button class="svc-btn" type="button" data-service="market-analysis" aria-label="Buy Market Analysis from Oracle for $0.001 — live sentiment and trend read" data-i18n-attr="aria-label:agent_economy.buy_market_analysis_from_ora_arialabel">
+ <button class="svc-btn" type="button" data-service="market-analysis" aria-label="Buy Market Analysis from Oracle for $0.001, live sentiment and trend read" data-i18n-attr="aria-label:agent_economy.buy_market_analysis_from_ora_arialabel">
<div class="svc-btn-left">
<span class="svc-btn-name">Market Analysis</span>
<span class="svc-btn-tag">Live sentiment + trend read</span>
</div>
<span class="svc-btn-price">$0.001</span>
</button>
- <button class="svc-btn" type="button" data-service="onchain-insight" aria-label="Buy On-Chain Insight from Oracle for $0.002 — wallet activity and holder data" data-i18n-attr="aria-label:agent_economy.buy_on_chain_insight_from_or_arialabel">
+ <button class="svc-btn" type="button" data-service="onchain-insight" aria-label="Buy On-Chain Insight from Oracle for $0.002, wallet activity and holder data" data-i18n-attr="aria-label:agent_economy.buy_on_chain_insight_from_or_arialabel">
<div class="svc-btn-left">
<span class="svc-btn-name">On-Chain Insight</span>
<span class="svc-btn-tag">Wallet activity + holder data</span>
</div>
<span class="svc-btn-price">$0.002</span>
</button>
- <button class="svc-btn" type="button" data-service="risk-score" aria-label="Buy Risk Score from Oracle for $0.003 — AI-generated protocol rating" data-i18n-attr="aria-label:agent_economy.buy_risk_score_from_oracle_f_arialabel">
+ <button class="svc-btn" type="button" data-service="risk-score" aria-label="Buy Risk Score from Oracle for $0.003, AI-generated protocol rating" data-i18n-attr="aria-label:agent_economy.buy_risk_score_from_oracle_f_arialabel">
<div class="svc-btn-left">
<span class="svc-btn-name">Risk Score</span>
<span class="svc-btn-tag">AI-generated protocol rating</span>
@@ -512,12 +570,13 @@
</div>
<div id="topic-wrap">
- <input id="topic" type="text" placeholder="Topic (optional) — e.g. Solana, JUP, pump.fun" maxlength="120" autocomplete="off" spellcheck="false" />
+ <label class="sr-only" for="topic">Topic for the requested service (optional)</label>
+ <input id="topic" type="text" placeholder="Topic (optional), e.g. Solana or $THREE" maxlength="120" autocomplete="off" spellcheck="false" />
</div>
<div id="feed">
<div id="feed-empty">
- <svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round">
+ <svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" aria-hidden="true" focusable="false">
<polyline points="22 12 18 12 15 21 9 3 6 12 2 12"/>
</svg>
<span data-i18n="agent_economy.pick_a_service_above_to_watch_the">Pick a service above to watch the agents transact</span>
@@ -525,7 +584,7 @@
</div>
<div id="status-bar">
- <span id="status-text" data-i18n="agent_economy.ready_select_a_service_to_start">Ready — select a service to start</span>
+ <span id="status-text" data-i18n="agent_economy.ready_select_a_service_to_start">Ready. Select a service to start.</span>
<span id="tx-count"></span>
</div>
</div>
diff --git a/src/agent-economy-volume.js b/src/agent-economy-volume.js
index 632126040..d86bca7b8 100644
--- a/src/agent-economy-volume.js
+++ b/src/agent-economy-volume.js
@@ -1,16 +1,22 @@
/**
- * Agent Economy Volume dashboard — fetches and renders the platform-wide
+ * Agent Economy Volume dashboard: fetches and renders the platform-wide
* agent-to-agent economy roll-up from /api/agent-economy/volume.
*
* Every number is a live aggregate over the real `agent_hires` ledger (settled
* USDC moved from one agent to another over x402). The volume bar chart is drawn
- * with the native Canvas API — no external charting dependency.
+ * with the native Canvas API, with no external charting dependency, and carries
+ * a screen-reader table of the same series so the data is never canvas-only.
*/
const ENDPOINT = '/api/agent-economy/volume';
+const REFRESH_MS = 60_000;
+const DAY_MS = 86_400_000;
let currentWindow = 30;
-let lastDaily = []; // cached so the window toggle can redraw without refetching the whole window-30 payload
+let lastDaily = []; // cached so the window toggle can redraw without refetching
+let hasData = false; // a successful load has painted real numbers at least once
+let inFlight = false;
+let chartHit = null; // bar geometry from the last paint, for tooltip hit testing
// ── Formatting ──────────────────────────────────────────────────────────────
@@ -55,6 +61,19 @@ function initials(name) {
return parts.map((p) => p[0]?.toUpperCase() || '').join('') || 'A';
}
+// The API buckets each day with Postgres date_trunc, which runs in UTC, so the
+// client series has to be built and labelled in UTC too. Deriving day keys from
+// the visitor's local calendar puts every bar one day off east of UTC.
+function utcDayKey(ms) {
+ return new Date(ms).toISOString().slice(0, 10);
+}
+
+function dayLabel(key, opts = { month: 'short', day: 'numeric' }) {
+ const [y, m, d] = String(key).split('-').map(Number);
+ if (!Number.isFinite(y)) return String(key);
+ return new Date(Date.UTC(y, m - 1, d)).toLocaleDateString(undefined, { ...opts, timeZone: 'UTC' });
+}
+
// ── Components ───────────────────────────────────────────────────────────────
function statCard(val, lbl, sub) {
@@ -90,6 +109,15 @@ function rankRow(num, agent, sub, primary, secondary) {
</${tag}>`;
}
+// An agent in the feed is a link exactly when the API says its profile is
+// public, which mirrors the leaderboard rows above it.
+function feedAgent(a) {
+ const name = escapeHtml(a?.name || 'Agent');
+ return a?.url
+ ? `<a class="feed-agent" href="${escapeHtml(a.url)}">${name}</a>`
+ : `<span class="feed-agent">${name}</span>`;
+}
+
function feedRow(h) {
const skill = h.skill_name || h.service_slug || 'a skill';
const link = h.explorer_url
@@ -97,9 +125,9 @@ function feedRow(h) {
: '';
return `<div class="feed-row">
<div class="feed-flow">
- <span class="feed-agent">${escapeHtml(h.hirer?.name || 'Agent')}</span>
- <span class="feed-arrow">→</span>
- <span class="feed-agent">${escapeHtml(h.provider?.name || 'Agent')}</span>
+ ${feedAgent(h.hirer)}
+ <span class="feed-arrow" aria-hidden="true">→</span>
+ ${feedAgent(h.provider)}
<span class="feed-skill">· ${escapeHtml(skill)}</span>
</div>
<span class="feed-amt">${fmtUsd(h.usd)}</span>
@@ -156,9 +184,8 @@ function drawVolumeChart(canvas, days) {
days.forEach((d, i) => {
if (i % step !== 0 && i !== days.length - 1) return;
const x = pad.left + (days.length <= 1 ? chartW / 2 : (i / (days.length - 1)) * chartW);
- const label = new Date(d.day).toLocaleDateString(undefined, { month: 'short', day: 'numeric' });
ctx.fillStyle = textColor;
- ctx.fillText(label, x, H - pad.bottom + 16);
+ ctx.fillText(dayLabel(d.day), x, H - pad.bottom + 16);
});
// Bars with gradient
@@ -167,6 +194,7 @@ function drawVolumeChart(canvas, days) {
grad.addColorStop(1, isDark ? 'rgba(87,199,255,0.55)' : 'rgba(2,132,199,0.5)');
const slot = chartW / days.length;
const barW = Math.max(2, Math.min(22, slot - 3));
+ const bars = [];
days.forEach((d, i) => {
const v = Number(d.volume_usd) || 0;
const x = pad.left + i * slot + (slot - barW) / 2;
@@ -176,7 +204,9 @@ function drawVolumeChart(canvas, days) {
ctx.beginPath();
ctx.roundRect(x, y, barW, barH, 2);
ctx.fill();
+ bars.push({ cx: x + barW / 2, top: y, day: d });
});
+ chartHit = { bars, left: pad.left, slot, width: chartW };
}
function yLabel(v) {
@@ -190,41 +220,133 @@ function yLabel(v) {
// Build a zero-filled day series for the requested window from the daily rows so
// the chart always shows a continuous timeline, not just days that had volume.
function buildSeries(daily, windowDays) {
- const byDay = new Map(daily.map((d) => [d.day, Number(d.volume_usd) || 0]));
+ const byDay = new Map(daily.map((d) => [String(d.day).slice(0, 10), d]));
const out = [];
- const today = new Date();
+ const todayUtc = Date.parse(`${utcDayKey(Date.now())}T00:00:00Z`);
for (let i = windowDays - 1; i >= 0; i--) {
- const dt = new Date(today);
- dt.setDate(today.getDate() - i);
- const key = dt.toISOString().slice(0, 10);
- out.push({ day: key, volume_usd: byDay.get(key) || 0 });
+ const key = utcDayKey(todayUtc - i * DAY_MS);
+ const hit = byDay.get(key);
+ out.push({
+ day: key,
+ volume_usd: Number(hit?.volume_usd) || 0,
+ hires: Number(hit?.hires) || 0,
+ });
}
return out;
}
+function seriesSummary(series) {
+ const total = series.reduce((sum, d) => sum + d.volume_usd, 0);
+ const active = series.filter((d) => d.volume_usd > 0).length;
+ return `Daily agent-to-agent volume, last ${series.length} days: ${fmtUsd(total)} across ${active} ${active === 1 ? 'day' : 'days'} with settlements.`;
+}
+
+// The canvas alone is invisible to assistive tech, so the same series is also
+// rendered as an offscreen table. Only days with volume are listed: a 90-row
+// table of zeros is noise, not data.
+function seriesTable(series) {
+ const rows = series.filter((d) => d.volume_usd > 0);
+ if (!rows.length) return '';
+ // The offscreen wrapper is a div, not the table itself: a clipped <table>
+ // still lays out at its min-content width and pushes the page into a
+ // horizontal scroll on a narrow viewport.
+ return `<div class="visually-hidden"><table>
+ <caption>Daily agent-to-agent settled volume</caption>
+ <thead><tr><th scope="col">Day</th><th scope="col">Volume</th><th scope="col">Hires</th></tr></thead>
+ <tbody>${rows.map((d) => `<tr><th scope="row">${escapeHtml(dayLabel(d.day, { year: 'numeric', month: 'short', day: 'numeric' }))}</th><td>${escapeHtml(fmtUsd(d.volume_usd))}</td><td>${fmtCount(d.hires)}</td></tr>`).join('')}</tbody>
+ </table></div>`;
+}
+
+function chartWrap() {
+ return document.getElementById('chart-wrap');
+}
+
+function renderChartMessage(html) {
+ const wrap = chartWrap();
+ if (wrap) wrap.innerHTML = `<div class="chart-empty">${html}</div>`;
+ chartHit = null;
+}
+
function renderChart() {
- const canvas = document.getElementById('volume-chart');
- const wrap = canvas?.parentElement;
- if (!canvas || !wrap) return;
- const hasVolume = lastDaily.some((d) => (Number(d.volume_usd) || 0) > 0);
- if (!hasVolume) {
- wrap.innerHTML = '<div class="chart-empty">No settled agent-to-agent volume in this window yet.</div>';
+ const wrap = chartWrap();
+ if (!wrap) return;
+ if (!hasData) return; // still loading: the skeleton stays up
+ const series = buildSeries(lastDaily, currentWindow);
+ if (!series.some((d) => d.volume_usd > 0)) {
+ renderChartMessage(`<span>No settled agent-to-agent volume in the last ${currentWindow} days.</span><a href="/economy">Watch the live economy</a>`);
return;
}
if (!wrap.querySelector('canvas')) {
- wrap.innerHTML = '<canvas id="volume-chart" class="chart-canvas" aria-label="Daily agent-to-agent volume chart"></canvas>';
+ wrap.innerHTML = `<canvas id="volume-chart" class="chart-canvas" role="img"></canvas>
+ <div class="chart-tip" id="chart-tip" aria-hidden="true"></div>`;
+ wireChartTooltip();
}
- const series = buildSeries(lastDaily, currentWindow);
- requestAnimationFrame(() => drawVolumeChart(document.getElementById('volume-chart'), series));
+ const canvas = wrap.querySelector('canvas');
+ closeTip();
+ canvas.setAttribute('aria-label', seriesSummary(series));
+ wrap.querySelector('.visually-hidden')?.remove();
+ wrap.insertAdjacentHTML('beforeend', seriesTable(series));
+ requestAnimationFrame(() => drawVolumeChart(canvas, series));
}
-// ── Data ─────────────────────────────────────────────────────────────────────
+// A tooltip left open across a resize keeps the coordinates of the old layout,
+// which parks it past the right edge and widens the whole page. Closing it also
+// resets the position so a hidden tip can never extend the document.
+function closeTip() {
+ const tip = document.getElementById('chart-tip');
+ if (!tip) return;
+ tip.dataset.open = '0';
+ tip.style.left = '0px';
+ tip.style.top = '0px';
+}
+
+function wireChartTooltip() {
+ const wrap = chartWrap();
+ const canvas = wrap?.querySelector('canvas');
+ const tip = document.getElementById('chart-tip');
+ if (!canvas || !tip) return;
+ canvas.addEventListener('pointermove', (e) => {
+ if (!chartHit?.bars.length) return;
+ const rect = canvas.getBoundingClientRect();
+ const x = e.clientX - rect.left;
+ const idx = Math.min(
+ chartHit.bars.length - 1,
+ Math.max(0, Math.floor((x - chartHit.left) / chartHit.slot)),
+ );
+ const bar = chartHit.bars[idx];
+ const d = bar.day;
+ tip.innerHTML = `<div class="tip-day">${escapeHtml(dayLabel(d.day, { year: 'numeric', month: 'short', day: 'numeric' }))}</div>
+ <div class="tip-val">${escapeHtml(fmtUsd(d.volume_usd))}</div>
+ <div class="tip-day">${fmtCount(d.hires)} ${d.hires === 1 ? 'hire' : 'hires'}</div>`;
+ const maxLeft = (wrap?.clientWidth || canvas.offsetWidth) - 8;
+ tip.style.left = `${Math.min(maxLeft, Math.max(8, canvas.offsetLeft + bar.cx))}px`;
+ tip.style.top = `${canvas.offsetTop + Math.max(bar.top, 12) - 8}px`;
+ tip.dataset.open = '1';
+ });
+ canvas.addEventListener('pointerleave', closeTip);
+}
+
+// ── Rendering ────────────────────────────────────────────────────────────────
+
+function setCount(id, value) {
+ const el = document.getElementById(id);
+ if (!el) return;
+ el.textContent = String(value);
+ el.hidden = false;
+}
-function showError(msg) {
+// The banner's headline sentence is static translated copy; only this detail
+// clause is dynamic. Keeping them in separate elements is deliberate: the i18n
+// runtime rewrites annotated elements after first paint, so anything JS writes
+// has to live outside an annotated node or it gets overwritten.
+function showError(detail) {
const el = document.getElementById('an-error');
- const m = document.getElementById('an-error-msg');
- if (m) m.textContent = msg || 'Failed to load economy stats.';
+ const m = document.getElementById('an-error-detail');
+ if (m) m.textContent = detail || '';
if (el) el.hidden = false;
+ // Nothing has ever painted: swap the skeletons for a real, explained state
+ // instead of leaving a shimmer that never resolves.
+ if (!hasData) renderUnavailable();
}
function clearError() {
@@ -232,8 +354,53 @@ function clearError() {
if (el) el.hidden = true;
}
+const UNAVAILABLE_COPY = 'Could not load. Use Retry above.';
+
+function renderUnavailable() {
+ const headline = document.getElementById('headline-val');
+ if (headline) {
+ headline.textContent = 'Unavailable';
+ headline.classList.add('is-unavailable');
+ headline.removeAttribute('aria-busy');
+ }
+ document.getElementById('headline-delta').hidden = true;
+ document.getElementById('stats-grid').innerHTML = '';
+ for (const id of ['top-earners', 'top-spenders', 'recent-feed']) {
+ const el = document.getElementById(id);
+ if (el) el.innerHTML = `<div class="an-empty">${UNAVAILABLE_COPY}</div>`;
+ }
+ renderChartMessage('<span>Volume chart unavailable.</span>');
+ for (const id of ['earners-count', 'spenders-count', 'recent-count']) {
+ const el = document.getElementById(id);
+ if (el) el.hidden = true;
+ }
+}
+
+function renderSkeletons() {
+ const headline = document.getElementById('headline-val');
+ if (headline) {
+ headline.classList.remove('is-unavailable');
+ headline.setAttribute('aria-busy', 'true');
+ headline.innerHTML = '<span class="skeleton skeleton-headline"></span>';
+ }
+ document.getElementById('stats-grid').innerHTML = Array.from({ length: 5 }, () =>
+ '<div class="stat-card"><div class="skeleton skeleton-stat" style="width:62%;"></div><div class="skeleton skeleton-row" style="width:48%;margin-top:10px;"></div></div>').join('');
+ const ranks = Array.from({ length: 3 }, (_, i) =>
+ `<div class="skeleton-rank skeleton" style="animation-delay:.${i}s;"></div>`).join('');
+ document.getElementById('top-earners').innerHTML = ranks;
+ document.getElementById('top-spenders').innerHTML = ranks;
+ document.getElementById('recent-feed').innerHTML = Array.from({ length: 3 }, (_, i) =>
+ `<div class="skeleton-rank skeleton" style="height:46px;animation-delay:.${i}s;"></div>`).join('');
+ const wrap = chartWrap();
+ if (wrap) wrap.innerHTML = '<div class="chart-skeleton skeleton"></div>';
+ chartHit = null;
+}
+
function renderTotals(t) {
- document.getElementById('headline-val').textContent = fmtUsd(t.volume_usd, { compact: t.volume_usd >= 10_000 });
+ const headline = document.getElementById('headline-val');
+ headline.classList.remove('is-unavailable');
+ headline.removeAttribute('aria-busy');
+ headline.textContent = fmtUsd(t.volume_usd, { compact: t.volume_usd >= 10_000 });
const delta = document.getElementById('headline-delta');
if (t.volume_24h_usd > 0) {
@@ -245,7 +412,7 @@ function renderTotals(t) {
const avg = t.hires > 0 ? t.avg_hire_usd : 0;
document.getElementById('stats-grid').innerHTML = [
- statCard(fmtCount(t.hires), 'Settled hires', t.pending_hires ? `${fmtCount(t.pending_hires)} pending` : 'agent → agent payments'),
+ statCard(fmtCount(t.hires), 'Settled hires', t.pending_hires ? `${fmtCount(t.pending_hires)} pending` : 'agent to agent payments'),
statCard(fmtUsd(t.volume_7d_usd, { compact: t.volume_7d_usd >= 10_000 }), 'Volume · 7 days', `${fmtCount(t.hires_7d)} hires`),
statCard(fmtUsd(avg), 'Avg hire value', 'per settled call'),
statCard(fmtCount(t.unique_providers), 'Earning agents', 'sold a skill'),
@@ -253,59 +420,73 @@ function renderTotals(t) {
].join('');
}
-function renderLeaderboards(data) {
- const earners = document.getElementById('top-earners');
- const spenders = document.getElementById('top-spenders');
-
- document.getElementById('earners-count').textContent = data.top_providers.length;
- earners.innerHTML = data.top_providers.length
- ? data.top_providers.map((a, i) => rankRow(
+function renderLeaderboards(providers, hirers) {
+ setCount('earners-count', providers.length);
+ document.getElementById('top-earners').innerHTML = providers.length
+ ? providers.map((a, i) => rankRow(
i + 1, a,
`${fmtCount(a.hires)} ${a.hires === 1 ? 'hire' : 'hires'}${a.avg_rating ? ` · ${a.avg_rating.toFixed(1)}★` : ''}`,
fmtUsd(a.earned_usd), 'earned',
)).join('')
- : '<div class="an-empty">No agent has earned from a hire yet.</div>';
+ : '<div class="an-empty">No agent has earned from a hire yet. <a href="/agent-wallet">List a paid skill</a> and yours can be first.</div>';
- document.getElementById('spenders-count').textContent = data.top_hirers.length;
- spenders.innerHTML = data.top_hirers.length
- ? data.top_hirers.map((a, i) => rankRow(
+ setCount('spenders-count', hirers.length);
+ document.getElementById('top-spenders').innerHTML = hirers.length
+ ? hirers.map((a, i) => rankRow(
i + 1, a,
`${fmtCount(a.hires)} ${a.hires === 1 ? 'hire' : 'hires'}`,
fmtUsd(a.spent_usd), 'spent',
)).join('')
- : '<div class="an-empty">No agent has hired another yet.</div>';
+ : '<div class="an-empty">No agent has hired another yet. <a href="/x402">Browse the x402 catalog</a> to see what is hireable.</div>';
}
function renderFeed(recent) {
- const feed = document.getElementById('recent-feed');
- document.getElementById('recent-count').textContent = recent.length;
- feed.innerHTML = recent.length
+ setCount('recent-count', recent.length);
+ document.getElementById('recent-feed').innerHTML = recent.length
? recent.map(feedRow).join('')
- : '<div class="an-empty">No settlements yet — be the first to put your agent to work.</div>';
+ : '<div class="an-empty">No settlements yet. <a href="/agent-wallet">Put your agent to work</a> and its first hire lands here.</div>';
}
-async function load() {
+// ── Data ─────────────────────────────────────────────────────────────────────
+
+async function load({ showLoading = false } = {}) {
+ if (inFlight) return;
+ inFlight = true;
+ const retry = document.getElementById('an-retry');
+ if (retry) retry.disabled = true;
+ if (showLoading && !hasData) renderSkeletons();
clearError();
- let res;
+
+ // The network boundary is the only place that may throw here: a render
+ // failure is a bug, not a network error, and must not be reported as one.
+ let data;
try {
- res = await fetch(`${ENDPOINT}?window=90&top=10&recent=14`, { headers: { accept: 'application/json' } });
- } catch {
- res = null;
- }
- if (!res || !res.ok) {
- showError(res ? `Failed to load (${res.status}). Please retry.` : 'Network error. Please retry.');
+ const res = await fetch(`${ENDPOINT}?window=90&top=10&recent=14`, { headers: { accept: 'application/json' } });
+ if (!res.ok) throw new Error(`http_${res.status}`);
+ data = await res.json();
+ } catch (err) {
+ // Offline, DNS failure, a 5xx, or a body that is not the JSON we asked for.
+ const status = /^http_(\d+)$/.exec(err?.message || '')?.[1];
+ showError(status ? `The server returned HTTP ${status}.` : 'Network error: check your connection and retry.');
+ inFlight = false;
+ if (retry) retry.disabled = false;
return;
}
+ inFlight = false;
+ if (retry) retry.disabled = false;
- const data = await res.json();
if (!data?.ok) {
- showError('Stats are temporarily unavailable. Please retry.');
+ showError('The stats service reported a problem. Please retry.');
return;
}
lastDaily = Array.isArray(data.daily) ? data.daily : [];
+ hasData = true;
renderTotals(data.totals || {});
- renderLeaderboards(data);
+ renderLeaderboards(
+ Array.isArray(data.top_providers) ? data.top_providers : [],
+ Array.isArray(data.top_hirers) ? data.top_hirers : [],
+ );
renderFeed(Array.isArray(data.recent) ? data.recent : []);
renderChart();
}
@@ -326,21 +507,21 @@ function wireWindowToggle() {
function init() {
wireWindowToggle();
- document.getElementById('an-retry')?.addEventListener('click', load);
+ document.getElementById('an-retry')?.addEventListener('click', () => load({ showLoading: true }));
// Redraw the canvas on resize + theme change so it stays crisp.
let raf;
window.addEventListener('resize', () => {
cancelAnimationFrame(raf);
raf = requestAnimationFrame(renderChart);
});
- const themeObserver = new MutationObserver(renderChart);
- themeObserver.observe(document.documentElement, { attributes: true, attributeFilter: ['data-theme'] });
+ new MutationObserver(renderChart)
+ .observe(document.documentElement, { attributes: true, attributeFilter: ['data-theme'] });
- load();
+ load({ showLoading: true });
// Light auto-refresh so the dashboard stays live without hammering the DB.
setInterval(() => {
if (document.visibilityState === 'visible') load();
- }, 60_000);
+ }, REFRESH_MS);
}
if (document.readyState === 'loading') {
diff --git a/src/agent-economy.js b/src/agent-economy.js
index bde48b295..7c75c36fa 100644
--- a/src/agent-economy.js
+++ b/src/agent-economy.js
@@ -1,8 +1,8 @@
-// Agent Economy — two 3D AI agents transacting on-chain.
+// Agent Economy: two 3D AI agents transacting on-chain.
//
// Nova (buyer, left) picks a service from Oracle's catalog, pays real SOL,
// and Oracle delivers the analysis. Every transaction is real: a live Solana
-// wallet sends lamports, the tx signature links to Solana FM.
+// wallet sends lamports, the tx signature links to a Solana explorer.
//
// Architecture:
// - Two <agent-3d> avatars loaded into iframes (the existing embed pattern).
@@ -10,9 +10,9 @@
// delivery on the server. No x402 client lib needed in the browser: the
// server signs with AVATAR_WALLET_SECRET.
// - Speech bubbles + avatar animations driven by postMessage to each iframe.
-// - A payment particle arc animates from buyer → seller on real tx confirmation.
+// - A payment particle arc animates from buyer to seller on real tx confirmation.
// - /api/agent-economy/status polled on load to show live wallet balances.
-// - The tx feed in the center column is pure DOM — no framework.
+// - The tx feed in the center column is pure DOM, no framework.
import { buildReceiptHTML, buildReceiptText } from './shared/payment-receipt.js';
import { showAddFunds } from './shared/add-funds.js';
@@ -45,8 +45,10 @@ function renderBal(elId, info) {
}
const sol = typeof info.sol === 'number' ? info.sol : null;
if (sol === null) {
+ // Configured wallet, unreadable balance: say so rather than showing a
+ // dash the reader has to guess at.
el.className = 'av-label-bal bal-unknown';
- el.textContent = '—';
+ el.textContent = 'balance unavailable';
return;
}
const usdStr = info.usd != null ? ` · $${info.usd.toFixed(2)}` : '';
@@ -64,20 +66,22 @@ function renderFundAlert(status) {
if (!aCfg) {
// Technical detail (env var name) goes to console only
log.info('[three.ws] agent-economy: AVATAR_WALLET_SECRET not configured');
- html = '<strong>Live transactions are paused.</strong> This feature is temporarily unavailable — check back shortly.';
+ html = '<strong>Live transactions are paused.</strong> This feature is temporarily unavailable. Check back shortly.';
} else {
const addr = status.agentA.address;
const exp = status.agentA.explorer || `https://solscan.io/account/${addr}`;
html = `<strong>Nova needs a small amount of SOL to transact.</strong> Fund her wallet to get started:
- <span class="fund-addr">${addr} <a href="${exp}" target="_blank" rel="noopener">↗ Solscan</a></span>
- <button class="fund-alert-btn" data-addr="${escHtml(addr)}">Add funds →</button>`;
+ <span class="fund-addr">${escHtml(addr)} <a href="${escHtml(exp)}" target="_blank" rel="noopener">↗ Solscan</a></span>
+ <button class="fund-alert-btn" type="button" data-addr="${escHtml(addr)}">Add funds →</button>`;
}
el.innerHTML = html;
el.classList.add('visible');
el.querySelector('.fund-alert-btn')?.addEventListener('click', (e) => {
const addr = e.currentTarget.dataset.addr;
- if (addr) showAddFunds({ walletAddress: addr }).then(() => refreshWalletStatus());
+ // Nova pays in native lamports, so the onramp has to deliver SOL. Funding
+ // her with USDC would leave her exactly as unable to transact as before.
+ if (addr) showAddFunds({ walletAddress: addr, asset: 'SOL' }).then(() => refreshWalletStatus());
});
}
@@ -345,7 +349,7 @@ async function purchase(service) {
}));
} else if (tx?.error === 'wallet_unconfigured') {
// Log technical detail privately; never surface env-var names to users
- log.info('[three.ws] agent-economy: wallet_unconfigured —', tx.message);
+ log.info('[three.ws] agent-economy: wallet_unconfigured:', tx.message);
addFeedItem({
icon: '⏸️',
type: 'pay',
@@ -356,7 +360,7 @@ async function purchase(service) {
} else if (tx?.error === 'insufficient_balance') {
const agentAddr = currentWalletStatus?.agentA?.address;
const fundBtn = agentAddr
- ? `<button class="tx-add-funds-btn" data-addr="${escHtml(agentAddr)}">Add funds →</button>`
+ ? `<button class="tx-add-funds-btn" type="button" data-addr="${escHtml(agentAddr)}">Add funds →</button>`
: '';
const feedEl = addFeedItem({
icon: '💰',
@@ -366,12 +370,12 @@ async function purchase(service) {
});
feedEl?.querySelector('.tx-add-funds-btn')?.addEventListener('click', (e) => {
const addr = e.currentTarget.dataset.addr;
- if (addr) showAddFunds({ walletAddress: addr }).then(() => refreshWalletStatus());
+ if (addr) showAddFunds({ walletAddress: addr, asset: 'SOL' }).then(() => refreshWalletStatus());
});
- setStatus('Nova\'s wallet needs funds — use "Add funds" above');
+ setStatus('Nova\'s wallet needs funds. Use "Add funds" to top her up.');
} else if (tx?.error === 'no_recipient') {
// Log technical detail privately; never surface env-var names to users
- log.info('[three.ws] agent-economy: no_recipient —', tx.message);
+ log.info('[three.ws] agent-economy: no_recipient:', tx.message);
addFeedItem({
icon: '⏸️',
type: 'pay',
@@ -379,9 +383,21 @@ async function purchase(service) {
sub: 'This feature is temporarily unavailable. Check back shortly.',
});
setStatus('Live transactions are temporarily unavailable');
+ } else if (tx?.error === 'rate_limited') {
+ // A spent budget is not a failure, and telling the reader "the network
+ // rejected it" would send them retrying against a ceiling that only
+ // clears tomorrow.
+ addFeedItem({
+ icon: '🧾',
+ type: 'pay',
+ title: 'Daily demo budget reached',
+ sub: 'Oracle still delivered the service. Live payments resume tomorrow.',
+ });
+ setStatus('Daily demo transaction budget reached. Payments resume tomorrow.');
} else if (tx?.error) {
log.warn('[three.ws] agent-economy tx error:', tx.error, tx.message);
- addFeedItem({ icon: '⚠️', type: 'pay', title: 'Transaction didn\'t go through', sub: 'The network rejected this transaction — try again in a moment.' });
+ addFeedItem({ icon: '⚠️', type: 'pay', title: 'Transaction didn\'t go through', sub: 'The network rejected this transaction. Try again in a moment.' });
+ setStatus('Payment failed. Try another service or retry in a moment.');
}
// Oracle delivers the service
diff --git a/tests/agent-economy-platform.test.js b/tests/agent-economy-platform.test.js
index ed8aa5dd2..2d23b40a6 100644
--- a/tests/agent-economy-platform.test.js
+++ b/tests/agent-economy-platform.test.js
@@ -54,7 +54,7 @@ describe('platformEconomyStats', () => {
],
// recent
[
- { id: 'r1', skill_name: 'market-analysis', service_slug: 'mkt', usd: 0.005, amount_atomics: '5000', currency: 'USDC', network: 'solana', payment_signature: 'SIG1', completed_at: '2026-06-29T00:00:00.000Z', hirer_agent_id: 'h1', provider_agent_id: 'p1', hirer_name: 'Trader', provider_name: 'Oracle' },
+ { id: 'r1', skill_name: 'market-analysis', service_slug: 'mkt', usd: 0.005, amount_atomics: '5000', currency: 'USDC', network: 'solana', payment_signature: 'SIG1', completed_at: '2026-06-29T00:00:00.000Z', hirer_agent_id: 'h1', provider_agent_id: 'p1', hirer_name: 'Trader', provider_name: 'Oracle', hirer_linkable: true, provider_linkable: false },
],
);
@@ -87,8 +87,10 @@ describe('platformEconomyStats', () => {
id: 'r1', skill_name: 'market-analysis', usd: 0.005, network: 'solana',
payment_signature: 'SIG1',
});
- expect(r.recent[0].hirer).toEqual({ agent_id: 'h1', name: 'Trader' });
- expect(r.recent[0].provider).toEqual({ agent_id: 'p1', name: 'Oracle' });
+ // The feed links an agent exactly when the row says it is linkable (alive
+ // and public), so a private or deleted agent is named but not linked.
+ expect(r.recent[0].hirer).toEqual({ agent_id: 'h1', name: 'Trader', url: '/agent/h1' });
+ expect(r.recent[0].provider).toEqual({ agent_id: 'p1', name: 'Oracle', url: null });
});
it('derives recent USD from atomics when the usd column is null', async () => {
@@ -102,6 +104,7 @@ describe('platformEconomyStats', () => {
const r = await platformEconomyStats();
expect(r.recent[0].usd).toBe(2.5); // 2_500_000 atomics / 1e6
expect(r.recent[0].hirer.name).toBe('Agent'); // null name falls back
+ expect(r.recent[0].hirer.url).toBe(null); // an unjoinable agent is never linked
});
it('clamps out-of-range params into safe bounds', async () => {