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-only- ..
- apple-touch-icon.png
- brand-guidelines-v2.md
- brand-manifest-v2.json
- favicon-16.png
- favicon-32.png
- favicon-48.png
- favicon.ico
- icon-192.png
- icon-512.png
- maskable-192.png
- maskable-512.png
- source-brand-board.png
- source-crop-icon-fullcolor.png
- source-crop-lockup-dark.png
- source-crop-wordmark-light.png
- zloud-app-icon-1024.png
- zloud-app-icon.svg
- zloud-favicon.svg
- zloud-mark-1024.png
- zloud-mark-512.png
- zloud-mark-mono-512.png
- zloud-mark-mono.svg
- zloud-mark-reversed.svg
- zloud-mark-white-512.png
- zloud-mark-white.svg
- zloud-mark.svg
- zloud-maskable.svg
- zloud-wordmark-dark.svg
- zloud-wordmark-light.svg
- zloud-wordmark-mono.svg
app/src/lib/cloud.ts
1import crypto from "node:crypto";2import { db, now, uid } from "./db";34export const LIFECYCLE = ["created", "pending_provisioning", "active", "suspended", "terminated"] as const;5export type Lifecycle = (typeof LIFECYCLE)[number];6/** Allowed lifecycle transitions (terminated is final; nothing is purchased or charged by any transition). */7export const TRANSITIONS: Record<string, Lifecycle[]> = { created: ["active", "pending_provisioning", "terminated"], pending_provisioning: ["created", "active", "terminated"], active: ["suspended", "terminated"], suspended: ["active", "terminated"], terminated: [] };8export const ONLINE_MS = 45_000;9export const sha = (s: string) => crypto.createHash("sha256").update(s).digest("hex");10export const newToken = (prefix: string) => `${prefix}_${crypto.randomBytes(24).toString("hex")}`;11export async function orgLimits(orgId: string) { return await db().prepare("SELECT max_instances,max_nodes,max_projects,ai_monthly_cap_usd,protected,status FROM organizations WHERE id=?").get(orgId) as any; }12export async function usageSummary(orgId: string) {13 const ms = new Date(Date.UTC(new Date().getUTCFullYear(), new Date().getUTCMonth(), 1)).toISOString();14 const ai = await db().prepare("SELECT COALESCE(SUM(cost_usd),0) usd, COALESCE(SUM(tokens_in),0) ti, COALESCE(SUM(tokens_out),0) tout, COUNT(*) calls FROM usage_ledger WHERE org_id=? AND ts>=?").get(orgId, ms) as any;15 const c = async (q: string) => Number((await db().prepare(q).get(orgId) as any).n);16 const lim = await orgLimits(orgId);17 return { month: ms.slice(0, 7), ai: { usd: Number(ai.usd), tokens_in: Number(ai.ti), tokens_out: Number(ai.tout), calls: Number(ai.calls), cap_usd: Number(lim.ai_monthly_cap_usd) },18 counts: { instances: await c("SELECT COUNT(*) n FROM instances WHERE org_id=? AND status<>'terminated'"), nodes: await c("SELECT COUNT(*) n FROM nodes WHERE org_id=? AND revoked_at IS NULL"), projects: await c("SELECT COUNT(*) n FROM projects WHERE org_id=?") },19 quotas: { instances: lim.max_instances, nodes: lim.max_nodes, projects: lim.max_projects }, charges: "none — metering only; nothing is billed" };20}21export const nodeState = (n: { revoked_at?: string | null; enroll_used_at?: string | null; last_seen?: number | null }) => n.revoked_at ? "revoked" : !n.enroll_used_at ? "awaiting-agent" : n.last_seen && Date.now() - Number(n.last_seen) < ONLINE_MS ? "online" : "offline";22export async function record(orgId: string, kind: string, quantity: number, unit: string, instanceId?: string | null) { await db().prepare("INSERT INTO usage_records(org_id,instance_id,kind,quantity,unit,ts) VALUES(?,?,?,?,?,?)").run(orgId, instanceId ?? null, kind, quantity, unit, now()); }23export { uid, now };24
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 692573d on master.
Approval requests
None pending.