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.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
test(fleet-console): smoke the real HTTP core path and index the service in services/README
nirholascb57d791d944
diff --git a/prompts/swarm-100/service-fleet-console.md b/prompts/swarm-100/service-fleet-console.mddeleted file mode 100644index 4059505b7..000000000--- a/prompts/swarm-100/service-fleet-console.md+++ /dev/null@@ -1,82 +0,0 @@-# Service audit: services/fleet-console--How to run: paste this file's repo path into a fresh Claude Code chat in this-repository and say "run this work order". This file is fully self-contained:-it depends on no other prompt file anywhere. If neighboring files in-prompts/swarm-100/ are gone, that work is done; if present, ignore them.-Every claim below rots; step 0 re-measures, and what you measure wins.--## Operating clause (binding)--- Read CLAUDE.md first. Its rules override everything, including this file.-- Finish 100% in this session. Never end the turn with a question, an option- list, or an unexecuted plan. A judgment call goes in one line of the final- report; it never becomes a question that halts work.-- The only permitted stops are the CLAUDE.md stop-and-ask gates: spending real- funds or any irreversible on-chain write, git push or a production deploy,- committing content that references a crypto project other than $THREE, and- destroying unrecoverable data.-- No mocks, no fake data, no placeholder stubs, no unfinished-work markers, no- commented-out code. Real APIs and real integrations only.-- The em-dash and en-dash characters are banned in everything you write.-- Concurrent agents share this worktree: stage explicit paths only (never a- bare add-everything), and commit finished work promptly.-- Before committing, run: npm run check:rules -- --paths <files you touched>.- It must exit 0.--## Step 0: re-derive the current state--1. Read services/fleet-console/README.md and its run configuration.-2. Determine where it runs (Cloud Run service, sidecar, local daemon) and- whether that instance is alive right now; the CLAUDE.md playbook has the- gcloud commands (remember: export PATH="$HOME/google-cloud-sdk/bin:$PATH").--## Task: bring this service to verified-healthy--1. README accuracy against the code; fix stale claims.-2. Build and start it locally per its own instructions; exercise its core- path for real.-3. Tests: run what exists, add a core-path smoke test if none exists.-4. If it has a live instance: recent logs free of unhandled errors, or root- causes fixed and committed (deploys stay owner-gated).--## Definition of done--- [ ] Local build and a real core-path exercise both succeed.-- [ ] Tests pass, including a core-path smoke test.-- [ ] README verified accurate.-- [ ] Live-instance health verified or fixes committed and flagged.-- [ ] npm run check:rules -- --paths <touched files> exits 0.--## Never blocked--| Blocker | Resolution (act, do not ask) |-|---|---|-| Missing env var or credential | Check .env and .env.local, then the Cloud Run service env, then Secret Manager (the CLAUDE.md self-unblock playbook has the exact commands). If it truly exists nowhere, wire the code fully behind the env var, prove the wiring with a dry run, and name the single missing var in the report. |-| gcloud not on PATH | Run: export PATH="$HOME/google-cloud-sdk/bin:$PATH" |-| Dev server port 3000 busy | Another agent may be serving this repo; probe it and reuse if so. Otherwise start your own on a free port: npx vite --port 3101 |-| Playwright browser missing | npx playwright install chromium |-| A surface needs a signed-in user | Register a fresh account through the real /register flow against the real API and use it. Never mock the session. |-| A defect sits in code you did not touch | Fix it if it blocks a Definition of done line (root cause it, never mask it). Otherwise note it in the report and continue. |-| An unrelated test is red | Same rule. Never pipe npm test through tail; it masks exit codes. |--## Close out (required)--1. Verify every Definition of done line with the actual command output in- front of you. Never claim a line you did not verify.-2. Commit with explicit paths and a subject that describes the diff (house- style: type(scope): what changed and why a reader cares).-3. Delete this prompt file in that same commit:-- git rm prompts/swarm-100/service-fleet-console.md-- The shrinking directory is this campaign's only progress ledger; there is- no progress log to update.-4. Final report: what step 0 measured, what changed (file list), evidence per- Definition of done line, and any one-line judgment calls. No trailing- questions, no unexecuted plans.--If a line genuinely cannot pass inside this session (an external party must-respond, or an owner-gated action is the final step), finish everything else,-leave this file in place, and state exactly which line remains and who owns-it. Never delete this file on a partial.diff --git a/services/README.md b/services/README.mdindex e41b0f62d..c2fb3a25b 100644--- a/services/README.md+++ b/services/README.md@@ -1,9 +1,16 @@# Services-Long-running, standalone three.ws services — processes that hold persistent connections or run continuously, so they do not fit the request/response shape of a Vercel function (`api/`) or a stateless Cloud Run / Cloudflare worker (`workers/`). Each service is its own subdirectory with a `package.json`, an entrypoint, and a `Dockerfile`.+Long-running, standalone three.ws services: processes that hold persistent connections or run continuously, so they do not fit the request/response shape of a Vercel function (`api/`) or a stateless Cloud Run / Cloudflare worker (`workers/`). Each service is its own subdirectory with a `package.json` and an entrypoint, plus a `Dockerfile` when it is meant to be deployed as a container.## Services+| Service | What it is | Deployed as |+| --- | --- | --- |+| [`pump-graduations/`](pump-graduations) | pump.fun graduations indexer, detailed below | Container (`Dockerfile`) |+| [`agent-screen-caster/`](agent-screen-caster) | Gives an agent a live, watchable screen from a real Playwright session. See its [README](agent-screen-caster/README.md) | Container (`Dockerfile`) |+| [`liquidation-collector/`](liquidation-collector) | Aggregates public futures liquidation feeds into a rolling REST snapshot. See its [README](liquidation-collector/README.md) | Cloud Run (`liquidation-collector`) |+| [`fleet-console/`](fleet-console) | Health console for an open-source fleet: probes what every repository of a GitHub owner claims and scores what it finds. HTTP dashboard, CLI, and MCP server. See its [README](fleet-console/README.md) | Not deployed, by design: run it from a terminal, a cron job, or next to an agent |+### `pump-graduations/` — pump.fun graduations indexerA Node.js service that holds a long-lived Solana WebSocket subscription to the Pump program and detects token "graduations" (bonding-curve -> PumpAMM migration), pushing each event into Upstash Redis. The Vercel side reads the events back from Redis; this service is the only piece that keeps the live WS open.diff --git a/tests/fleet-console-server.test.js b/tests/fleet-console-server.test.jsnew file mode 100644index 000000000..df8c3d8d0--- /dev/null+++ b/tests/fleet-console-server.test.js@@ -0,0 +1,323 @@+/**+ * Core-path smoke test for the fleet console service (services/fleet-console).+ *+ * The sibling suite (tests/fleet-console.test.js) covers the pure pieces in+ * isolation. This one exercises the path a user actually takes: a snapshot on+ * disk, the store loading it, the real HTTP handler on a real socket, and every+ * route answering with the right status, content type and content. Nothing is+ * mocked. The only synthetic input is the probe results inside the snapshot,+ * because a unit suite cannot reach the live internet, and everything derived+ * from them (scores, summary, attention ranking, badges, HTML) is produced by+ * the service's own code.+ */++import { describe, it, expect, beforeAll, afterAll } from 'vitest';+import { mkdtemp, rm } from 'node:fs/promises';+import { tmpdir } from 'node:os';+import { join } from 'node:path';+import { createServer } from 'node:http';++// config.js snapshots the environment at import time, so the data directory has+// to be pointed at a scratch path before anything in the service is loaded.+const dataDir = await mkdtemp(join(tmpdir(), 'fleet-console-test-'));+process.env.FLEET_DATA_DIR = dataDir;+process.env.FLEET_SCAN_ON_BOOT = 'false';+process.env.FLEET_SCAN_INTERVAL_MS = '0';+process.env.FLEET_OWNER = 'test-owner';+delete process.env.FLEET_SCAN_TOKEN;++const store = await import('../services/fleet-console/src/store.js');+const { handler } = await import('../services/fleet-console/src/server.js');+const { scoreRepo, summarise } = await import('../services/fleet-console/src/score.js');+const { partialReasons } = await import('../services/fleet-console/src/scan.js');++const probe = (url, state) => ({+ url,+ state,+ status: state === 'live' ? 200 : state === 'not_found' ? 404 : null,+ ms: 21,+ finalUrl: url,+ redirected: false,+ detail: ''+});++/** Two repositories built by the service's own scorer, one healthy and one not. */+function buildSnapshot() {+ const gathered = [+ {+ name: 'healthy-widget',+ fullName: 'test-owner/healthy-widget',+ description: 'A widget that keeps its promises',+ htmlUrl: 'https://github.com/test-owner/healthy-widget',+ stars: 42,+ language: 'JavaScript',+ topics: ['widget', 'cli', 'node'],+ license: 'MIT',+ pushedAt: new Date(Date.now() - 3 * 86400000).toISOString(),+ readmeBytes: 5200,+ hasDocsDir: true,+ packageVersion: '1.4.0',+ deployments: [probe('https://healthy-widget.example.dev/', 'live')],+ links: [probe('https://spec.example.org/v1', 'live')],+ packages: {+ checked: [{ name: 'healthy-widget', published: true, latest: '1.4.0', deprecated: false, role: 'manifest' }],+ missing: [],+ ownPackage: { name: 'healthy-widget', published: true, latest: '1.4.0' }+ }+ },+ {+ name: 'broken-widget',+ fullName: 'test-owner/broken-widget',+ description: '',+ htmlUrl: 'https://github.com/test-owner/broken-widget',+ stars: 7,+ language: 'TypeScript',+ topics: [],+ license: '',+ pushedAt: new Date(Date.now() - 800 * 86400000).toISOString(),+ readmeBytes: 220,+ hasDocsDir: false,+ packageVersion: '0.1.0',+ deployments: [probe('https://broken-widget.example.dev/', 'not_found')],+ links: [probe('https://gone.example.dev/', 'dns_failure')],+ packages: {+ checked: [{ name: 'broken-widget', published: false, latest: '', deprecated: false, role: 'manifest' }],+ missing: ['broken-widget'],+ ownPackage: { name: 'broken-widget', published: false, latest: '' }+ }+ }+ ];++ const repos = gathered.map((repo) => ({ ...repo, ...scoreRepo(repo) }));+ return {+ owner: 'test-owner',+ generatedAt: new Date().toISOString(),+ durationMs: 4200,+ partial: true,+ partialReason: 'repo_cap',+ totalOwned: 9,+ authenticated: true,+ rateLimit: { limit: 5000, remaining: 4900, resetAt: new Date(Date.now() + 600000).toISOString() },+ summary: summarise(repos),+ repos+ };+}++let base = '';+let server = null;++const get = (path, init) => fetch(`${base}${path}`, init);++beforeAll(async () => {+ await store.load();+ server = createServer((req, res) => {+ handler(req, res).catch(() => {+ if (!res.headersSent) res.writeHead(500);+ res.end();+ });+ });+ await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve));+ base = `http://127.0.0.1:${server.address().port}`;+});++afterAll(async () => {+ if (server) await new Promise((resolve) => server.close(resolve));+ await rm(dataDir, { recursive: true, force: true });+});++describe('before the first scan', () => {+ it('is alive and says so, without claiming to have data', async () => {+ const res = await get('/healthz');+ expect(res.status).toBe(200);+ expect(await res.json()).toMatchObject({ ok: true, hasSnapshot: false, owner: 'test-owner' });+ });++ it('serves the scanning state rather than an empty dashboard', async () => {+ const res = await get('/');+ expect(res.status).toBe(200);+ expect(res.headers.get('content-type')).toContain('text/html');+ const body = await res.text();+ expect(body).toContain('<!doctype html>');+ expect(body.toLowerCase()).toContain('scan');+ });++ it('tells an API client there is nothing to read yet instead of returning an empty fleet', async () => {+ for (const path of ['/api/fleet', '/api/attention']) {+ const res = await get(path);+ expect(res.status, path).toBe(503);+ expect((await res.json()).error).toBeTruthy();+ }+ });++ it('renders a badge that admits it has no measurement', async () => {+ const res = await get('/badge/fleet.svg');+ expect(res.status).toBe(200);+ expect(res.headers.get('content-type')).toContain('image/svg+xml');+ expect(await res.text()).toContain('not scanned');+ });+});++describe('a stored snapshot, served', () => {+ beforeAll(async () => {+ await store.save(buildSnapshot());+ });++ it('persists the snapshot to disk and reloads it, so a restart is not an outage', async () => {+ const reloaded = await store.load();+ expect(reloaded.owner).toBe('test-owner');+ expect(reloaded.repos).toHaveLength(2);+ expect(store.findRepo('HEALTHY-WIDGET').name).toBe('healthy-widget');+ });++ it('reports the whole fleet in slim form, and the full measurements on request', async () => {+ const slimRes = await get('/api/fleet');+ expect(slimRes.status).toBe(200);+ const slimBody = await slimRes.json();+ expect(slimBody.summary.repos).toBe(2);+ expect(slimBody.repos.map((repo) => repo.name).sort()).toEqual(['broken-widget', 'healthy-widget']);+ expect(slimBody.repos[0].checks).toBeUndefined();++ const fullBody = await (await get('/api/fleet?full=1')).json();+ expect(fullBody.repos.every((repo) => Array.isArray(repo.checks) && repo.checks.length > 0)).toBe(true);+ });++ it('ranks what is broken worst first, with a fix on every item', async () => {+ const res = await get('/api/attention');+ expect(res.status).toBe(200);+ const report = await res.json();+ expect(report.count).toBeGreaterThan(0);+ expect(report.items[0].severity).toBe('high');+ expect(report.items.map((item) => item.kind)).toContain('deployment_down');+ expect(report.items.map((item) => item.kind)).toContain('package_unpublished');+ expect(report.items.every((item) => item.repo && item.target)).toBe(true);+ });++ it('serves one repository with its history, and 404s a name it never scanned', async () => {+ const res = await get('/api/repo/broken-widget');+ expect(res.status).toBe(200);+ const repo = await res.json();+ expect(repo.score).toBeLessThan(60);+ expect(repo.checks.find((check) => check.id === 'packages').status).toBe('fail');+ expect(repo.history.at(-1)).toMatchObject({ score: repo.score });++ expect((await get('/api/repo/never-existed')).status).toBe(404);+ });++ it('renders the dashboard with every repository on it', async () => {+ const res = await get('/');+ expect(res.status).toBe(200);+ const body = await res.text();+ expect(body).toContain('healthy-widget');+ expect(body).toContain('broken-widget');+ expect(body).toContain('test-owner');+ });++ it('names the real reason a scan was partial instead of blaming the rate limit', async () => {+ const body = await (await get('/')).text();+ expect(body).toContain('Partial scan.');+ expect(body).toContain('FLEET_MAX_REPOS');+ expect(body).not.toContain('rate-limit budget');+ });++ it('renders a repository page, and a 404 page for one that was never scanned', async () => {+ const res = await get('/r/healthy-widget');+ expect(res.status).toBe(200);+ const body = await res.text();+ expect(body).toContain('healthy-widget.example.dev');+ expect(res.headers.get('content-type')).toContain('text/html');++ const missing = await get('/r/never-existed');+ expect(missing.status).toBe(404);+ expect(await missing.text()).toContain('never-existed');+ });++ it('explains the scoring model on its own docs page', async () => {+ const res = await get('/docs');+ expect(res.status).toBe(200);+ expect(await res.text()).toContain('<!doctype html>');+ });++ it('serves fleet, repository and deployment badges as cacheable SVG', async () => {+ for (const path of ['/badge/fleet.svg', '/badge/healthy-widget.svg', '/badge/broken-widget/deployment.svg']) {+ const res = await get(path);+ expect(res.status, path).toBe(200);+ expect(res.headers.get('content-type'), path).toContain('image/svg+xml');+ expect(res.headers.get('cache-control'), path).toContain('max-age');+ const body = await res.text();+ expect(body.startsWith('<svg'), path).toBe(true);+ expect(body.trim().endsWith('</svg>'), path).toBe(true);+ }+ expect(await (await get('/badge/broken-widget/deployment.svg')).text()).toContain('0/1 live');+ });++ it('reports scan progress on a pollable endpoint that is never cached', async () => {+ const res = await get('/api/status');+ expect(res.headers.get('cache-control')).toContain('max-age=0');+ const body = await res.json();+ expect(body).toMatchObject({ hasSnapshot: true, owner: 'test-owner' });+ expect(body.progress.running).toBe(false);+ });++ it('refuses on-demand scans while no scan token is configured, and rejects the wrong method', async () => {+ expect((await get('/api/scan', { method: 'POST' })).status).toBe(403);+ expect((await get('/api/scan')).status).toBe(405);+ });++ it('answers an unknown path with a 404 page rather than a stack trace', async () => {+ const res = await get('/not/a/route');+ expect(res.status).toBe(404);+ expect(await res.text()).toContain('<!doctype html>');+ });++ it('allows a browser on another origin to read the JSON surfaces', async () => {+ expect((await get('/api/fleet')).headers.get('access-control-allow-origin')).toBe('*');+ });+});++describe('why a scan covered less than the fleet', () => {+ const snapshot = (overrides) => ({+ partial: true,+ authenticated: true,+ summary: { repos: 6 },+ totalOwned: 189,+ rateLimit: { resetAt: '2026-08-11T06:00:00.000Z' },+ ...overrides+ });++ it('says nothing at all about a complete scan', () => {+ expect(partialReasons({ partial: false, summary: { repos: 9 }, totalOwned: 9 })).toEqual([]);+ expect(partialReasons(null)).toEqual([]);+ });++ it('blames the repository cap, not GitHub, when the cap is what stopped the scan', () => {+ const [reason, ...rest] = partialReasons(snapshot({ partialReason: 'repo_cap' }));+ expect(rest).toEqual([]);+ expect(reason).toContain('FLEET_MAX_REPOS');+ expect(reason).toContain('6 most-starred of 189');+ expect(reason).not.toMatch(/rate|budget/i);+ });++ it('blames the request budget when that is what ran out', () => {+ const reasons = partialReasons(snapshot({ partialReason: 'rate_limit', totalOwned: 6 }));+ expect(reasons).toHaveLength(1);+ expect(reasons[0]).toContain('request budget ran out');+ expect(reasons[0]).toContain('2026-08-11T06:00:00.000Z');+ });++ it('points an unauthenticated operator at the token that would fix it', () => {+ const [reason] = partialReasons(snapshot({ partialReason: 'rate_limit', authenticated: false, totalOwned: 6 }));+ expect(reason).toContain('GITHUB_TOKEN');+ });++ it('still says something honest about a snapshot written before the reason was recorded', () => {+ const reasons = partialReasons(snapshot({ totalOwned: 6 }));+ expect(reasons).toEqual(['6 of 6 repositories were scanned.']);+ });++ it('reports both causes when both applied, so half a fix is not mistaken for a whole one', () => {+ const reasons = partialReasons(snapshot({ partialReason: 'rate_limit' }));+ expect(reasons).toHaveLength(2);+ expect(reasons[0]).toContain('request budget');+ expect(reasons[1]).toContain('FLEET_MAX_REPOS');+ });+});