This repository has been archived on 2026-03-24. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
token-gated-economy/artifacts/api-server/src/index.ts
Replit Agent 7f34b0e192
Some checks failed
CI / Typecheck & Lint (pull_request) Failing after 0s
feat(integration): WS bridge, Tower at /tower, agent state visuals, payment panel, E2E test
- artifacts/api-server/src/routes/events.ts: WebSocket bridge at /api/ws
  EventBus → Matrix protocol (agent_state, job_created, job_complete, agent_count, ping)
- artifacts/api-server/src/index.ts: HTTP server wraps WS attachment on /api/ws
- artifacts/api-server/src/app.ts: Serve Matrix dist at /tower with __dirname-based
  path (fix process.cwd() resolution when CWD is api-server dir)
- the-matrix/js/agents.js: Extended update() with 4 visual states:
  idle/active/thinking/working (glow, ring speed, emissive intensity, scale all vary)
- the-matrix/index.html: Rewritten with sliding payment panel (step machine:
  input → eval-invoice → work-invoice → result),  SUBMIT JOB button
- the-matrix/js/payment.js: Full job submission flow; create→eval→work→result
  with stub payment support and polling
- the-matrix/js/main.js: Import initPaymentPanel, call on firstInit; fix SW path
  to use BASE_URL
- the-matrix/js/websocket.js: Auto-derive WS URL from window.location
- scripts/e2e-test.sh: Full E2E integration test — 10/10 PASS verified

Closes integration sprint T001-T005. E2E verified: Mode1 + Mode2 full flows pass.
2026-03-19 01:19:04 +00:00

30 lines
863 B
TypeScript

import { createServer } from "http";
import app from "./app.js";
import { attachWebSocketServer } from "./routes/events.js";
import { rootLogger } from "./lib/logger.js";
const rawPort = process.env["PORT"];
if (!rawPort) {
throw new Error("PORT environment variable is required but was not provided.");
}
const port = Number(rawPort);
if (Number.isNaN(port) || port <= 0) {
throw new Error(`Invalid PORT value: "${rawPort}"`);
}
const server = createServer(app);
attachWebSocketServer(server);
server.listen(port, () => {
rootLogger.info("server started", { port });
const domain = process.env["REPLIT_DEV_DOMAIN"];
if (domain) {
rootLogger.info("public url", { url: `https://${domain}/api/ui` });
rootLogger.info("tower url", { url: `https://${domain}/tower` });
rootLogger.info("ws url", { url: `wss://${domain}/api/ws` });
}
});