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(vanity): expose the in-stock target patterns so the grinder can resume

nirholas974cdb8e08dc
diff --git a/api/_lib/vanity-inventory-store.js b/api/_lib/vanity-inventory-store.js
index 1c431e267..3eded32cc 100644
--- a/api/_lib/vanity-inventory-store.js
+++ b/api/_lib/vanity-inventory-store.js
@@ -164,6 +164,34 @@ export async function inventoryStats() {
};
}
+/**
+ * Every distinct target pattern that still has stock ON THE SHELF.
+ *
+ * The batch grinder (workers/vanity-grinder) runs on ephemeral spot tasks whose
+ * local checkpoint file dies with the container, so a restart used to re-grind
+ * patterns that were already sitting in this table. This is the durable resume
+ * signal: the grinder seeds its completed-set from here and skips those targets.
+ *
+ * Deliberately filtered to `available` rather than "ever ground": a pattern that
+ * sold out is exactly what the replenish cron wants ground again.
+ *
+ * @returns {Promise<Array<{prefix:string|null, suffix:string|null, ignoreCase:boolean, count:number}>>}
+ */
+export async function availableTargetPatterns() {
+ const rows = await sql`
+ SELECT prefix, suffix, ignore_case, count(*) AS n
+ FROM vanity_inventory
+ WHERE status = 'available'
+ GROUP BY prefix, suffix, ignore_case
+ `;
+ return rows.map((row) => ({
+ prefix: row.prefix,
+ suffix: row.suffix,
+ ignoreCase: Boolean(row.ignore_case),
+ count: Number(row.n || 0),
+ }));
+}
+
/**
* Atomically reserve an available item for a paying buyer. This is the FIRST half
* of purchase: it flips available→reserved only if the row is still available, so