/**
 * Hub entry — Fastify server + Feishu WebSocket listener + org admin HTTP.
 *
 * Wires the full trigger path: lark ws receives `im.message.receive_v1` →
 * trigger handler resolves chat->project (ADR-0001), creates AgentRun + acquires
 * the project lock (ADR-0002), runs the AI SDK-backed agent runner
 * (ADR-0017), and releases the lock on finish. Feishu context reads inside the
 * loop are ADR-0003-authorized (chat must match binding).
 *
 * Org admin (ADR-0021): Feishu OAuth session + `/api/org/:orgSlug/*`.
 *
 * Env (see .env.example):
 *  DATABASE_URL, HUB_SILO_ORGANIZATION_ID, PORT,
 *  HUB_PROJECT_WORKSPACE_ROOT, HUB_SESSION_SECRET, HUB_PUBLIC_BASE_URL.
 * Provider credentials are org-scoped encrypted records; production receives
 * the local master-key keyring only through systemd CREDENTIALS_DIRECTORY.
 */
import "dotenv/config";
import { startHub } from "./hub.js";

startHub().catch((error: unknown) => {
  console.error("[hub] fatal:", error);
  process.exitCode = 1;
});
