← back to Ventura Claw
Add POST /api/admin/cache/prime endpoint
320d50b79552fca8dc2e2257ce2522a00094320d · 2026-05-06 05:09:13 -0700 · Steve Abrams
Re-fires the 5 preset cache primes on demand — useful when Mac1 evicts qwen3:14b
(concurrent codex 8-way runs etc.) and visitors are eating cold-loads. Admin-gated.
Audit-logged as admin_cache_prime. Returns {ok, primed, total, cache_size}.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Files touched
Diff
commit 320d50b79552fca8dc2e2257ce2522a00094320d
Author: Steve Abrams <info@agentabrams.com>
Date: Wed May 6 05:09:13 2026 -0700
Add POST /api/admin/cache/prime endpoint
Re-fires the 5 preset cache primes on demand — useful when Mac1 evicts qwen3:14b
(concurrent codex 8-way runs etc.) and visitors are eating cold-loads. Admin-gated.
Audit-logged as admin_cache_prime. Returns {ok, primed, total, cache_size}.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---
server/server.js | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/server/server.js b/server/server.js
index 6cd2b8b..1640586 100644
--- a/server/server.js
+++ b/server/server.js
@@ -510,6 +510,36 @@ app.get("/admin/approvals", requireAdminPage, (req, res) => res.sendFile(p
app.get("/admin/audit", requireAdminPage, (req, res) => res.sendFile(path.join(PUB, "admin-audit.html")));
// public endpoints
+// Admin: force a re-fire of the preset cache prime. Useful when Mac1 evicts qwen3:14b
+// (concurrent codex run, etc.) and visitors are eating cold-loads. Authenticated admins
+// can hit this and the next 5 preset queries become instant cache hits.
+app.post("/api/admin/cache/prime", requireAdmin, async (req, res) => {
+ const presets = [
+ "post in #launch on slack saying we shipped",
+ "refund order 1234 on shopify",
+ "purge cloudflare cache for businessclaw.agentabrams.com",
+ "add a row to my hubspot deals pipeline",
+ "send a message to the team",
+ ];
+ const userConnected = new Set(CONNECTORS.map(c => c.id));
+ let primed = 0;
+ for (const m of presets) {
+ try {
+ const intent = await LLM.classifyIntent(m, { connectors: CONNECTORS, userConnected });
+ if (intent) {
+ _demoCacheSet(m.trim().toLowerCase(), {
+ connector: intent.connector, action: intent.action || null,
+ reason: intent.reason || null, question: intent.question || null,
+ options: intent.options || null, suggested: intent.suggested || null,
+ });
+ primed++;
+ }
+ } catch { /* continue */ }
+ }
+ logEvent({ kind: "admin_cache_prime", by: req.session.email, primed, total: presets.length });
+ res.json({ ok: true, primed, total: presets.length, cache_size: _demoCache.size });
+});
+
// /healthz — text "ok" for load-balancer probes; JSON variant for admin observability.
app.get("/healthz", (req, res) => {
if (req.query.format === "json" || req.headers.accept?.includes("application/json")) {
← 21481b0 Overnight ticks — public surface polish (post-61cfcb1)
·
back to Ventura Claw
·
/changelog updated + ● Prime cache UI button on admin d6f1881 →