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(agents): chain a receipt through every run step, summarize runs when they end, and drive runs and automations every minute

nirholas6df637ef2b80
diff --git a/api/cron/agent-automations.js b/api/cron/agent-automations.js
new file mode 100644
index 000000000..d55b9c4e5
--- /dev/null
+++ b/api/cron/agent-automations.js
@@ -0,0 +1,39 @@
+// GET /api/cron/agent-automations: the per-minute driver for v1 automations and runs.
+//
+// Two jobs, in order:
+// 1. runAutomationSweep evaluates every live automation with a polled trigger
+// (schedule, price_threshold, balance_below, launch_matching, graduation,
+// whale_buy) and fires the due ones. Tips fire inline from the tip path.
+// 2. driveDueRuns steps every queued, scheduled or running agent run a little,
+// including the runs step 1 just started. Each step takes a lease, so this
+// cron, a live SSE stream and the agent page replay can never step one run
+// twice at once, and a cancel requested between steps lands on the next one.
+//
+// Spend actions do not sign here: they execute through their backing wallet
+// intent, which carries the spend policy, per-intent caps and custody claim.
+
+import { json, method, wrapCron } from '../_lib/http.js';
+import { requireCron } from '../_lib/cron-auth.js';
+import { runAutomationSweep } from '../_lib/agents-v1/automations.js';
+import { driveDueRuns } from '../_lib/agents-v1/runs.js';
+
+// Leave headroom under the scheduler's request timeout for the sweep itself.
+const RUN_DEADLINE_MS = 40_000;
+
+export default wrapCron(async (req, res) => {
+ if (!method(req, res, ['GET', 'POST'])) return;
+ if (!requireCron(req, res)) return;
+
+ const startedAt = Date.now();
+ let automations;
+ try {
+ automations = await runAutomationSweep({ now: new Date() });
+ } catch (err) {
+ console.error('[agent-automations] sweep failed', err);
+ automations = { error: String(err?.message || err).slice(0, 200) };
+ }
+ const runs = await driveDueRuns({ limit: 10, deadlineMs: RUN_DEADLINE_MS });
+ const ms = Date.now() - startedAt;
+ console.info(`[agent-automations] done in ${ms}ms`, { automations, runs });
+ return json(res, 200, { data: { automations, runs, took_ms: ms } });
+});
diff --git a/vercel.json b/vercel.json
index 2870a442b..3cca4e047 100644
--- a/vercel.json
+++ b/vercel.json
@@ -6600,6 +6600,10 @@
"path": "/api/cron/wallet-intents",
"schedule": "*/10 * * * *"
},
+ {
+ "path": "/api/cron/agent-automations",
+ "schedule": "* * * * *"
+ },
{
"path": "/api/cron/reconcile-decisions",
"schedule": "*/10 * * * *"