x402-trust-layer 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (293) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/DEPLOY.md +53 -0
  3. package/Dockerfile +30 -0
  4. package/LICENSE +21 -0
  5. package/README.md +294 -0
  6. package/dist/agents/a2a-payment.d.ts +37 -0
  7. package/dist/agents/a2a-payment.js +105 -0
  8. package/dist/agents/agent-escrow.d.ts +30 -0
  9. package/dist/agents/agent-escrow.js +23 -0
  10. package/dist/agents/agent-verify.d.ts +15 -0
  11. package/dist/agents/agent-verify.js +112 -0
  12. package/dist/agents/api-router.d.ts +32 -0
  13. package/dist/agents/api-router.js +228 -0
  14. package/dist/agents/attestation-registry.d.ts +35 -0
  15. package/dist/agents/attestation-registry.js +76 -0
  16. package/dist/agents/audition-coach.d.ts +45 -0
  17. package/dist/agents/audition-coach.js +257 -0
  18. package/dist/agents/bedrock-bridge.d.ts +3 -0
  19. package/dist/agents/bedrock-bridge.js +60 -0
  20. package/dist/agents/budget-allocator.d.ts +24 -0
  21. package/dist/agents/budget-allocator.js +31 -0
  22. package/dist/agents/compliance-ledger.d.ts +66 -0
  23. package/dist/agents/compliance-ledger.js +80 -0
  24. package/dist/agents/dispute-resolver.d.ts +62 -0
  25. package/dist/agents/dispute-resolver.js +124 -0
  26. package/dist/agents/evidence-locker.d.ts +30 -0
  27. package/dist/agents/evidence-locker.js +47 -0
  28. package/dist/agents/facilitator-failover.d.ts +15 -0
  29. package/dist/agents/facilitator-failover.js +18 -0
  30. package/dist/agents/identity-gate.d.ts +20 -0
  31. package/dist/agents/identity-gate.js +79 -0
  32. package/dist/agents/mandate-compiler.d.ts +51 -0
  33. package/dist/agents/mandate-compiler.js +73 -0
  34. package/dist/agents/mandate-diff.d.ts +41 -0
  35. package/dist/agents/mandate-diff.js +170 -0
  36. package/dist/agents/market-buy-advisor.d.ts +65 -0
  37. package/dist/agents/market-buy-advisor.js +234 -0
  38. package/dist/agents/merchant-trust.d.ts +38 -0
  39. package/dist/agents/merchant-trust.js +171 -0
  40. package/dist/agents/mpp-session-broker.d.ts +27 -0
  41. package/dist/agents/mpp-session-broker.js +29 -0
  42. package/dist/agents/mpp-session-v2.d.ts +76 -0
  43. package/dist/agents/mpp-session-v2.js +269 -0
  44. package/dist/agents/payment-intent-compiler.d.ts +21 -0
  45. package/dist/agents/payment-intent-compiler.js +45 -0
  46. package/dist/agents/pipeline-execute.d.ts +40 -0
  47. package/dist/agents/pipeline-execute.js +100 -0
  48. package/dist/agents/pipeline-trust-v2.d.ts +31 -0
  49. package/dist/agents/pipeline-trust-v2.js +111 -0
  50. package/dist/agents/pre-x402-guard.d.ts +35 -0
  51. package/dist/agents/pre-x402-guard.js +84 -0
  52. package/dist/agents/quality-escrow-semantic.d.ts +88 -0
  53. package/dist/agents/quality-escrow-semantic.js +137 -0
  54. package/dist/agents/quality-escrow.d.ts +65 -0
  55. package/dist/agents/quality-escrow.js +104 -0
  56. package/dist/agents/quality-monitor.d.ts +32 -0
  57. package/dist/agents/quality-monitor.js +77 -0
  58. package/dist/agents/rail-optimizer.d.ts +33 -0
  59. package/dist/agents/rail-optimizer.js +133 -0
  60. package/dist/agents/receipt-auditor.d.ts +14 -0
  61. package/dist/agents/receipt-auditor.js +145 -0
  62. package/dist/agents/refund-arbiter.d.ts +24 -0
  63. package/dist/agents/refund-arbiter.js +70 -0
  64. package/dist/agents/research-brief.d.ts +14 -0
  65. package/dist/agents/research-brief.js +66 -0
  66. package/dist/agents/risk-gate.d.ts +11 -0
  67. package/dist/agents/risk-gate.js +78 -0
  68. package/dist/agents/settlement-graph.d.ts +16 -0
  69. package/dist/agents/settlement-graph.js +38 -0
  70. package/dist/agents/spend-governor.d.ts +2 -0
  71. package/dist/agents/spend-governor.js +70 -0
  72. package/dist/agents/trust-network.d.ts +138 -0
  73. package/dist/agents/trust-network.js +244 -0
  74. package/dist/agents/x402-proxy.d.ts +32 -0
  75. package/dist/agents/x402-proxy.js +90 -0
  76. package/dist/client/demo-alchemy-live.d.ts +1 -0
  77. package/dist/client/demo-alchemy-live.js +226 -0
  78. package/dist/client/demo-tail.d.ts +1 -0
  79. package/dist/client/demo-tail.js +100 -0
  80. package/dist/client/demo.d.ts +1 -0
  81. package/dist/client/demo.js +293 -0
  82. package/dist/config.d.ts +94 -0
  83. package/dist/config.js +223 -0
  84. package/dist/index.d.ts +1 -0
  85. package/dist/index.js +389 -0
  86. package/dist/lib/agent-response.d.ts +14 -0
  87. package/dist/lib/agent-response.js +13 -0
  88. package/dist/lib/agentic-gateways.d.ts +5 -0
  89. package/dist/lib/agentic-gateways.js +15 -0
  90. package/dist/lib/agentic-probes.d.ts +10 -0
  91. package/dist/lib/agentic-probes.js +49 -0
  92. package/dist/lib/alchemy-x402-fetch.d.ts +16 -0
  93. package/dist/lib/alchemy-x402-fetch.js +95 -0
  94. package/dist/lib/apply-verifier-body.d.ts +7 -0
  95. package/dist/lib/apply-verifier-body.js +179 -0
  96. package/dist/lib/attestation.d.ts +30 -0
  97. package/dist/lib/attestation.js +107 -0
  98. package/dist/lib/bazaar-extension.d.ts +15 -0
  99. package/dist/lib/bazaar-extension.js +265 -0
  100. package/dist/lib/bazaar.d.ts +100 -0
  101. package/dist/lib/bazaar.js +341 -0
  102. package/dist/lib/certified-sellers.d.ts +41 -0
  103. package/dist/lib/certified-sellers.js +129 -0
  104. package/dist/lib/chains.d.ts +20 -0
  105. package/dist/lib/chains.js +78 -0
  106. package/dist/lib/db-persistence.d.ts +7 -0
  107. package/dist/lib/db-persistence.js +65 -0
  108. package/dist/lib/db.d.ts +5 -0
  109. package/dist/lib/db.js +113 -0
  110. package/dist/lib/discovery-page.d.ts +2 -0
  111. package/dist/lib/discovery-page.js +71 -0
  112. package/dist/lib/ecosystem-telemetry.d.ts +20 -0
  113. package/dist/lib/ecosystem-telemetry.js +80 -0
  114. package/dist/lib/erc8004/agent-card.d.ts +34 -0
  115. package/dist/lib/erc8004/agent-card.js +151 -0
  116. package/dist/lib/erc8004/cache.d.ts +3 -0
  117. package/dist/lib/erc8004/cache.js +17 -0
  118. package/dist/lib/erc8004/constants.d.ts +22 -0
  119. package/dist/lib/erc8004/constants.js +35 -0
  120. package/dist/lib/erc8004/registry.d.ts +19 -0
  121. package/dist/lib/erc8004/registry.js +171 -0
  122. package/dist/lib/erc8004/resolve-agent.d.ts +7 -0
  123. package/dist/lib/erc8004/resolve-agent.js +70 -0
  124. package/dist/lib/erc8004/trust-score.d.ts +33 -0
  125. package/dist/lib/erc8004/trust-score.js +136 -0
  126. package/dist/lib/escrow-ledger.d.ts +14 -0
  127. package/dist/lib/escrow-ledger.js +54 -0
  128. package/dist/lib/escrow-unified.d.ts +15 -0
  129. package/dist/lib/escrow-unified.js +28 -0
  130. package/dist/lib/facilitator-extra.d.ts +13 -0
  131. package/dist/lib/facilitator-extra.js +52 -0
  132. package/dist/lib/facilitators.d.ts +20 -0
  133. package/dist/lib/facilitators.js +89 -0
  134. package/dist/lib/host-policy.d.ts +4 -0
  135. package/dist/lib/host-policy.js +20 -0
  136. package/dist/lib/idempotency.d.ts +4 -0
  137. package/dist/lib/idempotency.js +120 -0
  138. package/dist/lib/ledger.d.ts +2 -0
  139. package/dist/lib/ledger.js +17 -0
  140. package/dist/lib/logger.d.ts +6 -0
  141. package/dist/lib/logger.js +24 -0
  142. package/dist/lib/mandate-vc.d.ts +20 -0
  143. package/dist/lib/mandate-vc.js +25 -0
  144. package/dist/lib/mandate.d.ts +44 -0
  145. package/dist/lib/mandate.js +190 -0
  146. package/dist/lib/marketplace.d.ts +7 -0
  147. package/dist/lib/marketplace.js +127 -0
  148. package/dist/lib/migrations.d.ts +2 -0
  149. package/dist/lib/migrations.js +130 -0
  150. package/dist/lib/nonce-store.d.ts +6 -0
  151. package/dist/lib/nonce-store.js +109 -0
  152. package/dist/lib/openapi-agentcash.d.ts +5 -0
  153. package/dist/lib/openapi-agentcash.js +288 -0
  154. package/dist/lib/openapi-meta.d.ts +5 -0
  155. package/dist/lib/openapi-meta.js +235 -0
  156. package/dist/lib/otel.d.ts +2 -0
  157. package/dist/lib/otel.js +25 -0
  158. package/dist/lib/paid-resource-url.d.ts +6 -0
  159. package/dist/lib/paid-resource-url.js +47 -0
  160. package/dist/lib/parse-with-verifier-fallback.d.ts +3 -0
  161. package/dist/lib/parse-with-verifier-fallback.js +13 -0
  162. package/dist/lib/payment-request-context.d.ts +10 -0
  163. package/dist/lib/payment-request-context.js +5 -0
  164. package/dist/lib/payment-response.d.ts +13 -0
  165. package/dist/lib/payment-response.js +39 -0
  166. package/dist/lib/payto-guard.d.ts +10 -0
  167. package/dist/lib/payto-guard.js +20 -0
  168. package/dist/lib/probe.d.ts +29 -0
  169. package/dist/lib/probe.js +157 -0
  170. package/dist/lib/problem-detail.d.ts +10 -0
  171. package/dist/lib/problem-detail.js +14 -0
  172. package/dist/lib/rate-limit.d.ts +12 -0
  173. package/dist/lib/rate-limit.js +126 -0
  174. package/dist/lib/replay-middleware.d.ts +3 -0
  175. package/dist/lib/replay-middleware.js +27 -0
  176. package/dist/lib/response-guard.d.ts +5 -0
  177. package/dist/lib/response-guard.js +40 -0
  178. package/dist/lib/safe-fetch.d.ts +5 -0
  179. package/dist/lib/safe-fetch.js +19 -0
  180. package/dist/lib/security.d.ts +13 -0
  181. package/dist/lib/security.js +61 -0
  182. package/dist/lib/semantic-judge.d.ts +14 -0
  183. package/dist/lib/semantic-judge.js +107 -0
  184. package/dist/lib/semantic-judge.test.d.ts +1 -0
  185. package/dist/lib/semantic-judge.test.js +11 -0
  186. package/dist/lib/ssrf.d.ts +10 -0
  187. package/dist/lib/ssrf.js +130 -0
  188. package/dist/lib/ssrf.test.d.ts +1 -0
  189. package/dist/lib/ssrf.test.js +16 -0
  190. package/dist/lib/suite-catalog.d.ts +83 -0
  191. package/dist/lib/suite-catalog.js +131 -0
  192. package/dist/lib/telemetry.d.ts +5 -0
  193. package/dist/lib/telemetry.js +37 -0
  194. package/dist/lib/verifier-fast-path.d.ts +10 -0
  195. package/dist/lib/verifier-fast-path.js +44 -0
  196. package/dist/lib/verifier-probe-protocol.d.ts +7 -0
  197. package/dist/lib/verifier-probe-protocol.js +115 -0
  198. package/dist/lib/verify-examples.d.ts +2 -0
  199. package/dist/lib/verify-examples.js +438 -0
  200. package/dist/lib/version.d.ts +2 -0
  201. package/dist/lib/version.js +2 -0
  202. package/dist/lib/webhook-auth.d.ts +3 -0
  203. package/dist/lib/webhook-auth.js +34 -0
  204. package/dist/lib/webhook-routes.d.ts +2 -0
  205. package/dist/lib/webhook-routes.js +112 -0
  206. package/dist/lib/webhooks.d.ts +23 -0
  207. package/dist/lib/webhooks.js +123 -0
  208. package/dist/lib/webhooks.test.d.ts +1 -0
  209. package/dist/lib/webhooks.test.js +16 -0
  210. package/dist/lib/x402-client-options.d.ts +28 -0
  211. package/dist/lib/x402-client-options.js +138 -0
  212. package/dist/lib/x402-headers.d.ts +10 -0
  213. package/dist/lib/x402-headers.js +27 -0
  214. package/dist/lib/x402-paid.d.ts +5 -0
  215. package/dist/lib/x402-paid.js +252 -0
  216. package/dist/lib/x402-payment-replay.d.ts +22 -0
  217. package/dist/lib/x402-payment-replay.js +57 -0
  218. package/dist/lib/x402gle-host-verify.d.ts +3 -0
  219. package/dist/lib/x402gle-host-verify.js +27 -0
  220. package/dist/protocol/agent-passport.d.ts +34 -0
  221. package/dist/protocol/agent-passport.js +44 -0
  222. package/dist/protocol/compliance-v2.d.ts +21 -0
  223. package/dist/protocol/compliance-v2.js +19 -0
  224. package/dist/protocol/credit-bureau.d.ts +18 -0
  225. package/dist/protocol/credit-bureau.js +44 -0
  226. package/dist/protocol/crypto.d.ts +6 -0
  227. package/dist/protocol/crypto.js +41 -0
  228. package/dist/protocol/escrow-fsm.d.ts +33 -0
  229. package/dist/protocol/escrow-fsm.js +99 -0
  230. package/dist/protocol/fraud-engine.d.ts +28 -0
  231. package/dist/protocol/fraud-engine.js +77 -0
  232. package/dist/protocol/observability.d.ts +14 -0
  233. package/dist/protocol/observability.js +21 -0
  234. package/dist/protocol/pipeline-full-trust.d.ts +40 -0
  235. package/dist/protocol/pipeline-full-trust.js +96 -0
  236. package/dist/protocol/proof-of-execution.d.ts +36 -0
  237. package/dist/protocol/proof-of-execution.js +48 -0
  238. package/dist/protocol/reasoning-audit.d.ts +27 -0
  239. package/dist/protocol/reasoning-audit.js +51 -0
  240. package/dist/protocol/replay-guard.d.ts +28 -0
  241. package/dist/protocol/replay-guard.js +76 -0
  242. package/dist/protocol/replay-guard.test.d.ts +1 -0
  243. package/dist/protocol/replay-guard.test.js +10 -0
  244. package/dist/protocol/security-audit.d.ts +18 -0
  245. package/dist/protocol/security-audit.js +45 -0
  246. package/dist/protocol/store.d.ts +5 -0
  247. package/dist/protocol/store.js +59 -0
  248. package/dist/protocol/threat-catalog.d.ts +13 -0
  249. package/dist/protocol/threat-catalog.js +75 -0
  250. package/dist/protocol/trust-oracle.d.ts +23 -0
  251. package/dist/protocol/trust-oracle.js +30 -0
  252. package/dist/protocol/trust-score-v2.d.ts +33 -0
  253. package/dist/protocol/trust-score-v2.js +78 -0
  254. package/dist/protocol/zk-proofs.d.ts +24 -0
  255. package/dist/protocol/zk-proofs.js +32 -0
  256. package/dist/routes/a2a-agent-card.d.ts +3 -0
  257. package/dist/routes/a2a-agent-card.js +28 -0
  258. package/dist/routes/catalog.d.ts +5 -0
  259. package/dist/routes/catalog.js +47 -0
  260. package/dist/routes/register-all.d.ts +3 -0
  261. package/dist/routes/register-all.js +1240 -0
  262. package/dist/routes/schemas.d.ts +83 -0
  263. package/dist/routes/schemas.js +38 -0
  264. package/dist/routes/shared.d.ts +16 -0
  265. package/dist/routes/shared.js +27 -0
  266. package/dist/routes-protocol.d.ts +10 -0
  267. package/dist/routes-protocol.js +322 -0
  268. package/dist/routes.d.ts +2 -0
  269. package/dist/routes.js +2 -0
  270. package/dist/types.d.ts +66 -0
  271. package/dist/types.js +1 -0
  272. package/openapi.json +7940 -0
  273. package/package.json +124 -0
  274. package/public/.well-known/ai-plugin.json +12 -0
  275. package/public/assets/aegis-logo-blue.png +0 -0
  276. package/public/assets/aegis-logo-gold.png +0 -0
  277. package/public/assets/aegis-logo-green.png +0 -0
  278. package/public/assets/aegis-logo-purple.png +0 -0
  279. package/public/assets/aegis-logo-red.png +0 -0
  280. package/public/assets/aegis-logo-white.png +0 -0
  281. package/public/assets/aegis-logo.png +0 -0
  282. package/public/assets/x402-trustlayer-logo.png +0 -0
  283. package/public/assets/x402-trustlayer-logo.svg +5 -0
  284. package/public/data/agents.json +1528 -0
  285. package/public/index.html +198 -0
  286. package/public/landing.css +342 -0
  287. package/public/landing.js +405 -0
  288. package/public/llms-full.txt +582 -0
  289. package/public/llms.txt +132 -0
  290. package/public/skill.md +135 -0
  291. package/railway.toml +9 -0
  292. package/scripts/docker-entrypoint.sh +7 -0
  293. package/scripts/patch-facilitator-timeout.mjs +61 -0
@@ -0,0 +1,405 @@
1
+ (function () {
2
+ const BASE = window.location.origin;
3
+ const $ = (s, r = document) => r.querySelector(s);
4
+ const $$ = (s, r = document) => [...r.querySelectorAll(s)];
5
+
6
+ let catalog = null;
7
+ let activeTier = "all";
8
+ let searchQuery = "";
9
+ let activeView = "terminal";
10
+ let heroIdx = 0;
11
+ let heroTimer = null;
12
+
13
+ const TIER_COLORS = {
14
+ entry: "#16C7C0",
15
+ marketplace: "#3B82F6",
16
+ orchestration: "#8B5CF6",
17
+ core: "#34D399",
18
+ attestation: "#F5A623",
19
+ trust: "#F97316",
20
+ intelligence: "#A78BFA",
21
+ enterprise: "#E879F9",
22
+ tier1: "#FBBF24",
23
+ };
24
+
25
+ function esc(s) {
26
+ return String(s)
27
+ .replace(/&/g, "&")
28
+ .replace(/</g, "&lt;")
29
+ .replace(/>/g, "&gt;")
30
+ .replace(/"/g, "&quot;");
31
+ }
32
+
33
+ function chips(arr) {
34
+ return (arr || []).map((t) => `<span class="chip">${esc(t)}</span>`).join("");
35
+ }
36
+
37
+ function filteredAgents() {
38
+ if (!catalog) return [];
39
+ const q = searchQuery.toLowerCase();
40
+ return catalog.agents.filter((a) => {
41
+ if (activeTier !== "all" && a.tier !== activeTier) return false;
42
+ if (!q) return true;
43
+ const hay = (a.name + a.path + a.summary + a.tags.join(" ") + a.tierLabel).toLowerCase();
44
+ return hay.includes(q);
45
+ });
46
+ }
47
+
48
+ function priceFmt(n) {
49
+ return "$" + Number(n).toFixed(2);
50
+ }
51
+
52
+ function renderTerminalRow(a) {
53
+ return `
54
+ <div class="term-row" data-id="${esc(a.id)}" role="button" tabindex="0">
55
+ <div class="method">${esc(a.method)}</div>
56
+ <div>
57
+ <div class="path-main">${esc(a.path)}</div>
58
+ <div class="path-name">${esc(a.name)}</div>
59
+ <div class="tier-tag">${esc(a.tierLabel)} · ${esc(a.layer)}</div>
60
+ </div>
61
+ <div class="price-tag">${priceFmt(a.price)}</div>
62
+ </div>`;
63
+ }
64
+
65
+ function renderCard(a) {
66
+ const color = TIER_COLORS[a.tier] || "#16C7C0";
67
+ return `
68
+ <article class="api-card" data-id="${esc(a.id)}" role="button" tabindex="0">
69
+ <div class="api-card-head">
70
+ <div class="api-tier" style="border-color:${color};color:${color}">${esc(a.tierLabel)}</div>
71
+ <div class="api-price">${priceFmt(a.price)}</div>
72
+ </div>
73
+ <h3 class="api-name">${esc(a.name)}</h3>
74
+ <div class="api-route mono">${esc(a.method)} ${esc(a.path)}</div>
75
+ <p class="api-summary">${esc(a.summary)}</p>
76
+ </article>`;
77
+ }
78
+
79
+ function renderDetail(a) {
80
+ const url = `${BASE}${a.path}`;
81
+ const color = TIER_COLORS[a.tier] || "#16C7C0";
82
+ const body =
83
+ a.method === "GET"
84
+ ? `curl ${esc(url)}`
85
+ : `curl -X ${esc(a.method)} ${esc(url)} \\\n -H "content-type: application/json" \\\n -d '{}'`;
86
+
87
+ return `
88
+ <div class="detail-head">
89
+ <div>
90
+ <div class="api-tier" style="border-color:${color};color:${color};display:inline-block;margin-bottom:8px">${esc(a.tierLabel)}</div>
91
+ <h3>${esc(a.name)}</h3>
92
+ <div class="detail-route mono">${esc(a.method)} ${esc(a.path)} · layer: ${esc(a.layer)}</div>
93
+ </div>
94
+ <div class="detail-price">${priceFmt(a.price)}</div>
95
+ </div>
96
+ <div class="detail-block">
97
+ <h4>Summary</h4>
98
+ <p>${esc(a.summary)}</p>
99
+ </div>
100
+ <div class="detail-block">
101
+ <h4>Why it matters</h4>
102
+ <p>${esc(a.why)}</p>
103
+ </div>
104
+ <div class="detail-block">
105
+ <h4>Key inputs</h4>
106
+ <div class="chips">${chips(a.inputs)}</div>
107
+ </div>
108
+ <div class="detail-block">
109
+ <h4>Response highlights</h4>
110
+ <div class="chips">${chips(a.outputs)}</div>
111
+ </div>
112
+ <div class="detail-block">
113
+ <h4>Tags</h4>
114
+ <div class="chips">${chips(a.tags)}</div>
115
+ </div>
116
+ <div class="detail-block">
117
+ <h4>Docs</h4>
118
+ <p style="font-size:13px;color:var(--muted)"><a href="/skill.md">skill.md</a> · <a href="/openapi.json">OpenAPI</a> · <a href="?agent=${esc(a.id)}">Permalink</a></p>
119
+ </div>
120
+ <div class="detail-block">
121
+ <h4>Example call</h4>
122
+ <pre class="code-block">${body}</pre>
123
+ <p style="font-size:12px;color:var(--dim);margin-top:8px">Returns HTTP 402 first — pay with x402 USDC, then retry with X-Payment header.</p>
124
+ </div>`;
125
+ }
126
+
127
+ function openDetail(id) {
128
+ const a = catalog.agents.find((x) => x.id === id);
129
+ if (!a) return;
130
+ const panel = $("#agent-detail");
131
+ const content = $("#detail-content");
132
+ if (!panel || !content) return;
133
+ content.innerHTML = renderDetail(a);
134
+ panel.classList.remove("hidden");
135
+ document.body.style.overflow = "hidden";
136
+ }
137
+
138
+ function closeDetail() {
139
+ const panel = $("#agent-detail");
140
+ if (!panel) return;
141
+ panel.classList.add("hidden");
142
+ document.body.style.overflow = "";
143
+ }
144
+
145
+ function bindAgentClicks(root) {
146
+ if (!root) return;
147
+ root.addEventListener("click", (e) => {
148
+ const row = e.target.closest("[data-id]");
149
+ if (!row) return;
150
+ openDetail(row.dataset.id);
151
+ });
152
+ root.addEventListener("keydown", (e) => {
153
+ if (e.key !== "Enter" && e.key !== " ") return;
154
+ const row = e.target.closest("[data-id]");
155
+ if (!row) return;
156
+ e.preventDefault();
157
+ openDetail(row.dataset.id);
158
+ });
159
+ }
160
+
161
+ function renderViews() {
162
+ const agents = filteredAgents();
163
+ const termList = $("#terminal-list");
164
+ const cards = $("#view-cards");
165
+ const count = $("#api-count");
166
+
167
+ if (count) count.textContent = String(agents.length);
168
+
169
+ if (termList) {
170
+ termList.innerHTML =
171
+ agents.length === 0
172
+ ? `<div class="term-row"><div></div><div>No agents match your filter.</div><div></div></div>`
173
+ : agents.map(renderTerminalRow).join("");
174
+ }
175
+
176
+ if (cards) {
177
+ cards.innerHTML =
178
+ agents.length === 0
179
+ ? `<p style="color:var(--muted);padding:24px">No agents match your filter.</p>`
180
+ : agents.map(renderCard).join("");
181
+ }
182
+ }
183
+
184
+ function setView(view) {
185
+ activeView = view;
186
+ const term = $("#view-terminal");
187
+ const cards = $("#view-cards");
188
+ $$(".vt").forEach((b) => b.classList.toggle("active", b.dataset.view === view));
189
+ if (term) term.classList.toggle("hidden", view !== "terminal");
190
+ if (cards) cards.classList.toggle("hidden", view !== "cards");
191
+ }
192
+
193
+ function renderTiers(agents) {
194
+ const nav = $("#tier-nav");
195
+ if (!nav) return;
196
+ const tiers = [...new Set(agents.map((a) => a.tier))];
197
+ const labels = {};
198
+ agents.forEach((a) => {
199
+ labels[a.tier] = a.tierLabel;
200
+ });
201
+ const order = [
202
+ "all",
203
+ "killer",
204
+ "entry",
205
+ "tier1",
206
+ "protocol",
207
+ "orchestration",
208
+ "bundle",
209
+ "core",
210
+ "identity",
211
+ "attestation",
212
+ "trust",
213
+ "intelligence",
214
+ "enterprise",
215
+ ];
216
+ nav.innerHTML = order
217
+ .filter((t) => t === "all" || tiers.includes(t))
218
+ .map((t) => {
219
+ const label = t === "all" ? `All ${agents.length}` : labels[t] || t;
220
+ const active = t === activeTier ? " active" : "";
221
+ return `<button type="button" class="tier-pill${active}" data-tier="${t}">${esc(label)}</button>`;
222
+ })
223
+ .join("");
224
+ nav.onclick = (e) => {
225
+ const btn = e.target.closest("[data-tier]");
226
+ if (!btn) return;
227
+ activeTier = btn.dataset.tier;
228
+ $$(".tier-pill", nav).forEach((b) => b.classList.toggle("active", b === btn));
229
+ renderViews();
230
+ };
231
+ }
232
+
233
+ function renderLayers(layers) {
234
+ const el = $("#layers-grid");
235
+ if (!el || !layers) return;
236
+ el.innerHTML = layers
237
+ .map(
238
+ (l) => `
239
+ <div class="layer-card">
240
+ <div class="layer-num">${esc(l.num)} · ${esc(l.title)}</div>
241
+ <h3>${esc(l.title)}</h3>
242
+ <p>${esc(l.desc)}</p>
243
+ </div>`,
244
+ )
245
+ .join("");
246
+ }
247
+
248
+ function setStatsImmediate(agents) {
249
+ const endpoints = agents?.length ?? 58;
250
+ const elEndpoints = $("#s-endpoints");
251
+ const elVerified = $("#s-verified");
252
+ const elChains = $("#s-chains");
253
+ if (elEndpoints) {
254
+ elEndpoints.textContent = String(endpoints);
255
+ elEndpoints.dataset.count = String(endpoints);
256
+ }
257
+ if (elVerified) {
258
+ elVerified.textContent = "100%";
259
+ elVerified.dataset.count = "100";
260
+ }
261
+ if (elChains) {
262
+ elChains.textContent = "3";
263
+ elChains.dataset.count = "3";
264
+ }
265
+ updateCheapest(agents ?? []);
266
+ }
267
+
268
+ function animateCounters() {
269
+ $$("[data-count]").forEach((el) => {
270
+ const target = parseInt(el.dataset.count, 10);
271
+ if (Number.isNaN(target)) return;
272
+ const isPct = el.id === "s-verified";
273
+ const duration = 1200;
274
+ const start = performance.now();
275
+ function tick(now) {
276
+ const p = Math.min(1, (now - start) / duration);
277
+ const eased = 1 - Math.pow(1 - p, 3);
278
+ const val = Math.round(target * eased);
279
+ el.textContent = isPct ? val + "%" : String(val);
280
+ if (p < 1) requestAnimationFrame(tick);
281
+ }
282
+ requestAnimationFrame(tick);
283
+ });
284
+ }
285
+
286
+ function observeStats() {
287
+ const stats = $("#stats");
288
+ if (!stats) {
289
+ animateCounters();
290
+ return;
291
+ }
292
+ const obs = new IntersectionObserver(
293
+ (entries) => {
294
+ entries.forEach((e) => {
295
+ if (e.isIntersecting) {
296
+ animateCounters();
297
+ obs.disconnect();
298
+ }
299
+ });
300
+ },
301
+ { threshold: 0.3 },
302
+ );
303
+ obs.observe(stats);
304
+ }
305
+
306
+ function startHeroTerminal(agents) {
307
+ const el = $("#hero-terminal");
308
+ if (!el || !agents.length) return;
309
+ const sample = agents.slice().sort((a, b) => a.path.localeCompare(b.path));
310
+
311
+ function paint() {
312
+ const lines = [];
313
+ for (let i = 0; i < 5; i++) {
314
+ const a = sample[(heroIdx + i) % sample.length];
315
+ lines.push(
316
+ `<div class="term-line"><span class="path">${esc(a.method)} ${esc(a.path)}</span><span class="price">${priceFmt(a.price)}</span></div>`,
317
+ );
318
+ }
319
+ lines.push(`<div><span class="cursor-blink">▊</span></div>`);
320
+ el.innerHTML = lines.join("");
321
+ heroIdx = (heroIdx + 1) % sample.length;
322
+ }
323
+
324
+ paint();
325
+ if (heroTimer) clearInterval(heroTimer);
326
+ heroTimer = setInterval(paint, 2800);
327
+ }
328
+
329
+ function updateCheapest(agents) {
330
+ const el = $("#s-cheapest");
331
+ if (!el || !agents.length) return;
332
+ const min = Math.min(...agents.map((a) => a.price));
333
+ el.textContent = priceFmt(min);
334
+ }
335
+
336
+ async function loadHealth() {
337
+ try {
338
+ const h = await fetch("/health").then((r) => r.json());
339
+ const badge = $("#hero-badge-text");
340
+ if (badge && h.endpointCount) {
341
+ const chainLabel = Array.isArray(h.chains) ? h.chains.join(" · ") : "Base · Solana · Polygon";
342
+ badge.textContent = `${h.endpointCount} Live Endpoints · ${chainLabel}`;
343
+ }
344
+ } catch (_) {}
345
+ }
346
+
347
+ async function init() {
348
+ try {
349
+ catalog = await fetch("/data/agents.json").then((r) => r.json());
350
+ } catch {
351
+ const termList = $("#terminal-list");
352
+ if (termList) termList.innerHTML = `<div class="term-row"><div></div><div>Could not load agent catalog.</div><div></div></div>`;
353
+ return;
354
+ }
355
+
356
+ renderLayers(catalog.layers);
357
+ renderTiers(catalog.agents);
358
+ setStatsImmediate(catalog.agents);
359
+ renderViews();
360
+ updateCheapest(catalog.agents);
361
+ startHeroTerminal(catalog.agents);
362
+ observeStats();
363
+ loadHealth();
364
+
365
+ bindAgentClicks($("#terminal-list"));
366
+ bindAgentClicks($("#view-cards"));
367
+
368
+ const search = $("#api-search");
369
+ if (search) {
370
+ search.addEventListener("input", () => {
371
+ searchQuery = search.value.trim();
372
+ renderViews();
373
+ });
374
+ }
375
+
376
+ $$(".view-toggle .vt").forEach((btn) => {
377
+ btn.addEventListener("click", () => setView(btn.dataset.view));
378
+ });
379
+
380
+ const closeBtn = $("#detail-close");
381
+ const panel = $("#agent-detail");
382
+ if (closeBtn) closeBtn.addEventListener("click", closeDetail);
383
+ if (panel) {
384
+ panel.addEventListener("click", (e) => {
385
+ if (e.target === panel) closeDetail();
386
+ });
387
+ }
388
+ document.addEventListener("keydown", (e) => {
389
+ if (e.key === "Escape") closeDetail();
390
+ });
391
+
392
+ const params = new URLSearchParams(window.location.search);
393
+ const hashAgent = window.location.hash.replace(/^#/, "").replace(/^agent[=\/]?/, "");
394
+ const deepId = params.get("agent") || (hashAgent && !hashAgent.startsWith("agents") ? hashAgent : null);
395
+ if (deepId) {
396
+ openDetail(deepId);
397
+ if (params.get("agent")) {
398
+ history.replaceState(null, "", window.location.pathname + "#agents");
399
+ }
400
+ }
401
+ }
402
+
403
+ if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", init);
404
+ else init();
405
+ })();