Skip to content
  1. Home
  2. workspace
Checking…
Public view — sanitized data only. Sign in over HTTPS to create projects and manage the workspace.

AI Engineering Workspace

Partial

Chat, files, terminal and preview in one place. Chat sessions run on a durable Postgres-backed queue (chat only: no tools or shell). Live models need an API key; the terminal is unavailable.

Project files

read-only

app/src/components/domains-client.tsx

1"use client";
2import { useCallback, useEffect, useState } from "react";
3type Rec = { type: string; name: string; value: string; purpose: string };
4type Dm = { id: string; hostname: string; node_id: string; deployment_id: string | null; status: string; dns_status: string | null; is_primary: boolean; redirect_to: string | null; tls_status: string; tls_expires: string | null; proxy_status: string; instructions: { records: Rec[]; note: string } };
5const DNS: Record<string, string> = { ok: "DNS verified", "wrong-target": "Ownership proven, but the domain points somewhere else", "no-route-record": "Ownership proven, but no A/CNAME record found yet", "ownership-not-proven": "TXT record not found yet" };
6export function DomainsPanel({ canEdit, canAdmin }: { canEdit: boolean; canAdmin: boolean }) {
7 const [d, setD] = useState<any>(null); const [msg, setMsg] = useState(""); const [host, setHost] = useState(""); const [node, setNode] = useState(""); const [app, setApp] = useState(""); const [busy, setBusy] = useState(false);
8 const load = useCallback(async () => { const r = await fetch("/api/cloud/domains"); if (r.ok) setD(await r.json()); }, []); useEffect(() => { load(); const t = setInterval(load, 6000); return () => clearInterval(t); }, [load]);
9 const post = async (b: any) => { setBusy(true); setMsg(""); const r = await fetch("/api/cloud/domains", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(b) }); const j = await r.json().catch(() => ({})); setBusy(false); if (!r.ok) setMsg(j.error ?? `error ${r.status}`); else { if (j.dns) setMsg(DNS[j.dns] ?? j.dns); load(); } return j; };
10 if (!d) return <p className="text-sm text-muted">Loading…</p>; const sv = d.servers as any[];
11 return <div className="space-y-6">
12 <section className="rounded-xl border border-line p-4 text-sm" aria-label="Add a domain"><h2 className="font-medium">Connect a domain</h2><p className="mt-1 text-xs text-muted">Reverse proxy: Caddy on your server (automatic HTTPS and renewal). Visitors use plain https://your-domain — no port numbers. Databases and admin services are never routed.</p>
13 {!canEdit ? <p className="mt-2 text-muted">Developer role required.</p> : sv.length === 0 ? <p className="mt-2 text-amber-600">Enroll a server first (External VPS).</p> : <div className="mt-3 grid gap-2 sm:grid-cols-3">
14 <input aria-label="Domain" className="rounded border border-line bg-surface p-2" placeholder="app.example.com" value={host} onChange={e => setHost(e.target.value.toLowerCase())} />
15 <select aria-label="Server" className="rounded border border-line bg-surface p-2" value={node} onChange={e => { setNode(e.target.value); setApp(""); }}><option value="">Server…</option>{sv.map(s => <option key={s.id} value={s.id}>{s.label}{s.caddy ? "" : " (proxy not installed)"}</option>)}</select>
16 <select aria-label="Application" className="rounded border border-line bg-surface p-2" value={app} onChange={e => setApp(e.target.value)}><option value="">Application (optional)…</option>{d.apps.filter((a: any) => a.node_id === node).map((a: any) => <option key={a.id} value={a.id}>{a.name} (:{a.port})</option>)}</select>
17 <button disabled={busy || !host || !node} onClick={() => post({ action: "add", hostname: host, nodeId: node, deploymentId: app || undefined }).then(j => j.id && setHost(""))} className="w-fit rounded-lg bg-accent px-4 py-2 text-accentfg disabled:opacity-50">Add domain</button></div>}</section>
18 {msg && <p role="status" className="rounded border border-line bg-surface2 p-2 text-sm">{msg}</p>}
19 <section aria-label="Domains"><h2 className="mb-2 font-medium">Domains</h2>{d.domains.length === 0 ? <p className="text-sm text-muted">No domains yet.</p> : <ul className="space-y-3">{d.domains.map((m: Dm) => { const srv = sv.find(s => s.id === m.node_id); const apps = d.apps.filter((a: any) => a.node_id === m.node_id); return <li key={m.id} className="rounded-xl border border-line p-3 text-sm">
20 <div className="flex flex-wrap items-center justify-between gap-2"><span className="break-all font-medium">{m.hostname}{m.is_primary && <span className="ml-2 rounded bg-surface2 px-1.5 text-[11px]">primary</span>}{m.redirect_to && <span className="ml-2 text-[11px] text-muted">redirects to {m.redirect_to}</span>}</span>
21 <span className="text-xs text-muted">ownership: <b className={m.status === "verified" ? "text-emerald-600" : "text-amber-600"}>{m.status}</b> · DNS: {m.dns_status ?? "unchecked"} · proxy: {m.proxy_status} · SSL: <b className={m.tls_status === "valid" ? "text-emerald-600" : ""}>{m.tls_status}{m.tls_expires ? ` (to ${m.tls_expires.slice(0, 10)})` : ""}</b> · renewal: automatic (Caddy)</span></div>
22 <div className="mt-2 overflow-x-auto"><table className="w-full text-left text-xs"><thead className="text-muted"><tr><th className="pr-3">Type</th><th className="pr-3">Name</th><th>Value</th></tr></thead><tbody>{m.instructions.records.map((r, i) => <tr key={i}><td className="pr-3 font-medium">{r.type}</td><td className="mono pr-3 break-all">{r.name}</td><td className="mono break-all">{r.value}</td></tr>)}</tbody></table></div><p className="mt-1 text-[11px] text-muted">{m.instructions.note}</p>
23 {canEdit && <div className="mt-2 flex flex-wrap items-center gap-2 text-xs"><button disabled={busy} onClick={() => post({ action: "verify", id: m.id })} className="rounded border border-line px-2 py-1">Verify DNS</button>
24 <select aria-label="Mapped application" value={m.deployment_id ?? ""} onChange={e => post({ action: "map", id: m.id, deploymentId: e.target.value || null })} className="rounded border border-line bg-surface px-2 py-1"><option value="">No application</option>{apps.map((a: any) => <option key={a.id} value={a.id}>{a.name} (:{a.port}, {a.status})</option>)}</select>
25 <button disabled={busy || !m.deployment_id} onClick={() => post({ action: "primary", id: m.id })} className="rounded border border-line px-2 py-1">Make primary</button>
26 <button disabled={busy} onClick={() => post({ action: "redirect", id: m.id, enabled: !m.redirect_to })} className="rounded border border-line px-2 py-1">{m.redirect_to ? "Stop redirect" : "Redirect to primary"}</button>
27 <button disabled={busy || m.status !== "verified" || srv?.state !== "online"} onClick={() => post({ action: "apply", nodeId: m.node_id })} className="rounded bg-accent px-2 py-1 text-accentfg disabled:opacity-50">Apply to server</button>
28 {canAdmin && <button disabled={busy} onClick={() => post({ action: "remove", id: m.id })} className="rounded border border-red-300 px-2 py-1 text-red-700">Remove</button>}</div>}
29 {srv && !srv.caddy && <p className="mt-2 rounded bg-amber-50 p-2 text-[11px] text-amber-800 dark:bg-amber-950 dark:text-amber-200">Caddy is not detected on this server. Owner action (needs root once): install Caddy from your distribution's official repository and enable its service so it can bind ports 80/443; the agent then manages only its own config file.</p>}</li>; })}</ul>}</section>
30 <details className="rounded-xl border border-line p-3 text-xs"><summary className="cursor-pointer font-medium">Proxy configuration that will be applied (preview)</summary>{Object.entries(d.preview as Record<string, string>).map(([k, v]) => <pre key={k} className="mono mt-2 overflow-auto whitespace-pre rounded bg-surface2 p-2">{v}</pre>)}</details></div>;
31}
32

Conversation

Partial
Sign in to start AI sessions.

Task checklist

  • Application shell deployed
  • Persistent projects
  • Agent runtime
  • Sandboxed terminal

Execution activity

No agent sessions. Git HEAD 0eebc42 on master.

Approval requests

None pending.