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.

chore(scripts): add the EPA fuel-economy probe, the pcarmarket structure probe and the source-breadth runner

nirholas2849cafb6bcc
diff --git a/scripts/.epa.mts b/scripts/.epa.mts
new file mode 100644
index 000000000..f3507c431
--- /dev/null
+++ b/scripts/.epa.mts
@@ -0,0 +1,25 @@
+/**
+ * EPA fuel economy: a free, keyless, documented API.
+ *
+ * It fills mpgCity and mpgHighway for every car whose year, make and model we
+ * know, which is nearly all of them. That is a facet with almost no coverage
+ * today filled from a public dataset, with no crawling and no blocking risk.
+ */
+const base = 'https://www.fueleconomy.gov/ws/rest/vehicle/menu';
+for (const [label, url] of [
+ ['years', `${base}/year`],
+ ['makes 2017', `${base}/make?year=2017`],
+ ['models', `${base}/model?year=2017&make=Porsche`],
+ ['options', `${base}/options?year=2017&make=Porsche&model=Macan`],
+] as [string, string][]) {
+ try {
+ const r = await fetch(url, { headers: { Accept: 'application/json' }, signal: AbortSignal.timeout(20000) });
+ const t = await r.text();
+ console.log(`${label.padEnd(12)} ${r.status} ${t.slice(0, 200).replace(/\s+/g, ' ')}`);
+ } catch (e) { console.log(`${label.padEnd(12)} ERR ${(e as Error).message.slice(0, 60)}`); }
+}
+// And the record itself, which carries the mpg figures.
+const r = await fetch('https://www.fueleconomy.gov/ws/rest/vehicle/41007', { headers: { Accept: 'application/json' }, signal: AbortSignal.timeout(20000) });
+const j = await r.json() as Record<string, unknown>;
+console.log('\nvehicle record fields:', Object.keys(j).filter(k => /city|highway|comb|fuel|cyl|disp|trany|drive|year|make|model|range|batt/i.test(k)).join(' '));
+console.log('sample:', JSON.stringify({ year: j.year, make: j.make, model: j.model, city08: j.city08, highway08: j.highway08, cylinders: j.cylinders, displ: j.displ, trany: j.trany, drive: j.drive }));
diff --git a/scripts/.pcar.mts b/scripts/.pcar.mts
new file mode 100644
index 000000000..63fc4c40a
--- /dev/null
+++ b/scripts/.pcar.mts
@@ -0,0 +1,16 @@
+import { fetchWithTls } from '/workspaces/carsearch/src/transport/tls.js';
+const r = await fetchWithTls('https://www.pcarmarket.com/auction/');
+const b = r.body;
+console.log('bytes', b.length, 'status', r.status);
+// What repeating structures hold the auctions?
+for (const re of [/class="([a-z0-9_-]*(?:auction|lot|listing|card|item)[a-z0-9_-]*)"/gi]) {
+ const counts = new Map<string, number>();
+ for (const m of b.matchAll(re)) counts.set(m[1]!, (counts.get(m[1]!) ?? 0) + 1);
+ console.log('candidate classes:', [...counts].sort((a,b)=>b[1]-a[1]).slice(0,10).map(([c,n])=>`${c}x${n}`).join(' '));
+}
+const links = [...b.matchAll(/href="(\/auction\/[^"]+)"/g)].map(m=>m[1]!);
+console.log('auction links:', new Set(links).size, [...new Set(links)].slice(0,4));
+const prices = [...b.matchAll(/\$[\d,]{4,}/g)].map(m=>m[0]);
+console.log('price-shaped strings:', prices.length, prices.slice(0,8));
+const titles = [...b.matchAll(/<h\d[^>]*>([^<]{10,90})<\/h\d>/g)].map(m=>m[1]!.trim());
+console.log('headings:', titles.length); for (const t of titles.slice(0,6)) console.log(' ', t);
diff --git a/scripts/broaden-index.sh b/scripts/broaden-index.sh
new file mode 100755
index 000000000..9bf4d1652
--- /dev/null
+++ b/scripts/broaden-index.sh
@@ -0,0 +1,36 @@
+#!/usr/bin/env bash
+# Builds breadth across the newly wired sources.
+#
+# Each of these covers something the dealer sources do not: Copart states a
+# title brand on every lot, Craigslist is private-party supply and states owner
+# counts, Carvana and duPont carry VINs that dedupe against everything else,
+# and the auction sources produce the completed sales every market statistic
+# rests on.
+#
+# Sequential per source: the throttle is per host and these do not share one,
+# but running them together would put three browsers and a TLS client on the
+# same egress IP at once, which is how a working source becomes a challenged one.
+set -uo pipefail
+cd "$(dirname "$0")/.."
+
+run() {
+ local label="$1"; shift
+ echo "=== $label"
+ timeout 900 npx tsx src/cli.ts search "$@" --concurrency 1 --no-enrich 2>&1 \
+ | grep -E "kept |by source|integrity|FAILED" | head -6
+}
+
+# Salvage, for title-status coverage across the market rather than one marque.
+for mk in Porsche BMW Mercedes-Benz Toyota Ford Chevrolet Honda Audi Jeep Lexus; do
+ run "copart $mk" --make "$mk" --sources copart
+done
+
+# Retail inventory carrying VINs.
+for mk in Porsche BMW Mercedes-Benz Toyota Ford; do
+ run "carvana $mk" --make "$mk" --sources carvana
+done
+
+# Their URLs do not filter, so one broad pass is the whole catalogue.
+run "dupont (broad)" --sources dupontregistry
+run "pcarmarket (broad)" --sources pcarmarket
+run "hagerty (broad)" --sources hagertymarketplace