AI Engineering Workspace
PartialChat, 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-onlyapp/src/lib/marketplace-core.mjs
1// Zloud Marketplace catalog + parameter validation (pure). Shared by the control plane and the QA suite.2// "verified" is NEVER set here: it is derived at runtime from recorded successful deployments (see /api/cloud/apps GET).3// Deployable kinds are the ones the agent can run WITHOUT root: "static" (agent-served files), "node" (inline Node script), "git-node" (git clone + npm).4// Everything else is catalogued with its requirements but is not deployable yet (needs Docker/root) and says so.5export const PORT_RANGE = { min: 20000, max: 29999 };6const common = { rollback: "automatic: a release that fails its health check is stopped and the previous healthy release is restarted", storage: "per-app directory under the agent home (releases kept: 3)" };7export const TEMPLATES = [8 { id: "static-site", name: "Static Website", kind: "static", version: "1.0.0", deployable: true, summary: "Serve HTML/CSS/JS files from your own VPS.", requires: [], resources: { cpu: "0.05", memMb: 64, diskMb: 50 }, ports: ["http (auto-allocated 20000–29999)"], secrets: [], health: "GET / returns < 500 within 10 s", ...common,9 params: [{ key: "title", label: "Page title", type: "string", max: 80, default: "Hello from Zloud" }, { key: "html", label: "index.html body", type: "text", max: 20000, default: "<h1>Hello from Zloud</h1>" }] },10 { id: "node-app", name: "Node.js", kind: "node", version: "1.0.0", deployable: true, summary: "Run a Node.js HTTP server (server.js) with environment variables.", requires: ["node>=18"], resources: { cpu: "0.25", memMb: 256, diskMb: 200 }, ports: ["http (auto-allocated; passed as $PORT)"], secrets: ["optional env vars (stored encrypted-at-rest is NOT implemented: use only non-critical values)"], health: "GET / returns < 500 within 10 s", ...common,11 params: [{ key: "code", label: "server.js (must listen on process.env.PORT)", type: "text", max: 50000, required: true, default: "require('http').createServer((q,s)=>s.end('Hello from Zloud Node')).listen(process.env.PORT,'0.0.0.0')" }, { key: "env", label: "Environment (KEY=value per line)", type: "env", max: 20 }] },12 { id: "git-node", name: "Git repository (Node.js)", kind: "git-node", version: "1.0.0", deployable: true, summary: "Clone an https Git repository, run npm install, then npm start.", requires: ["node>=18", "git", "npm"], resources: { cpu: "0.5", memMb: 512, diskMb: 1000 }, ports: ["http (auto-allocated; passed as $PORT)"], secrets: ["optional env vars"], health: "GET / returns < 500 within 30 s", ...common,13 params: [{ key: "repo", label: "HTTPS Git URL", type: "https-url", max: 300, required: true }, { key: "ref", label: "Branch or tag", type: "ref", max: 100, default: "main" }, { key: "env", label: "Environment", type: "env", max: 20 }] },14 ...[["nginx", "Nginx", "Docker or root package install"], ["nextjs", "Next.js", "Node build step (use Git repository template for now)"], ["postgresql", "PostgreSQL", "Docker or root package install, persistent volume"], ["redis", "Redis", "Docker or root package install"], ["opencode", "OpenCode", "provider credentials + isolated runtime"], ["wordpress", "WordPress", "PHP + MySQL (Docker Compose)"], ["docker-compose", "Docker Compose", "Docker on the target VPS"]]15 .map(([id, name, why]) => ({ id, name, kind: "unsupported", version: "-", deployable: false, summary: `${name}: catalogued, not deployable yet.`, requires: [why], resources: {}, ports: [], secrets: [], health: "-", rollback: "-", storage: "-", params: [] })),16];17export const template = id => TEMPLATES.find(t => t.id === id);18const NAME = /^[a-z0-9][a-z0-9-]{1,38}[a-z0-9]$/;19export const validName = n => NAME.test(String(n ?? ""));20const ENVKEY = /^[A-Z_][A-Z0-9_]{0,40}$/; const RESERVED = new Set(["PORT", "PATH", "HOME", "LD_PRELOAD", "LD_LIBRARY_PATH", "NODE_OPTIONS", "SHELL", "USER"]);21/** Returns { ok, params } with normalised params or { ok:false, error }. */22export function validateParams(t, raw) {23 if (!t) return { ok: false, error: "unknown template" }; if (!t.deployable) return { ok: false, error: `${t.name} is not deployable yet (${t.requires.join("; ")})` };24 const src = raw && typeof raw === "object" ? raw : {}; const out = {};25 for (const p of t.params) {26 let v = src[p.key]; if (v == null || v === "") v = p.default; if (v == null || v === "") { if (p.required) return { ok: false, error: `${p.label} is required` }; continue; }27 if (p.type === "env") { const lines = String(v).split(/\r?\n/).map(s => s.trim()).filter(Boolean); if (lines.length > p.max) return { ok: false, error: `at most ${p.max} environment lines` }; const env = {}; for (const l of lines) { const i = l.indexOf("="); const k = l.slice(0, i); if (i < 1 || !ENVKEY.test(k) || RESERVED.has(k)) return { ok: false, error: `invalid or reserved environment name: ${k.slice(0, 30)}` }; env[k] = l.slice(i + 1).slice(0, 500); } out[p.key] = env; continue; }28 v = String(v); if (v.length > p.max) return { ok: false, error: `${p.label} is too long (max ${p.max})` };29 if (p.type === "https-url") { let u; try { u = new URL(v); } catch { return { ok: false, error: "repository must be a valid URL" }; } if (u.protocol !== "https:" || u.username || u.password) return { ok: false, error: "repository must be an https URL without credentials" }; }30 if (p.type === "ref" && !/^[A-Za-z0-9._\/-]{1,100}$/.test(v)) return { ok: false, error: "invalid branch or tag" };31 out[p.key] = v;32 }33 return { ok: true, params: out };34}35/** Dependency check against what the agent reported ({node:"v22.1.0", git:true, npm:true, docker:false}). */36export function missingDeps(t, caps) {37 const miss = []; for (const r of t.requires ?? []) { const m = /^node>=(\d+)$/.exec(r); if (m) { const v = parseInt(String(caps?.node ?? "").replace(/^v/, "")); if (!(v >= +m[1])) miss.push(r); } else if (r === "git" || r === "npm" || r === "docker") { if (!caps?.[r]) miss.push(r); } }38 return miss;39}40export const pickPort = used => { const u = new Set(used); for (let p = PORT_RANGE.min; p <= PORT_RANGE.max; p++) if (!u.has(p)) return p; return null; };41
Conversation
PartialSign 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.