Skip to content
  1. Home
  2. workspace
Checking…
Demo 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/lib/providers.ts

1// Provider registry, pricing estimates and real credential verification (read-only API calls).
2import { db, now } from "./db";
3import { decrypt, encrypt, hintOf } from "./crypto";
4
5export type ProviderId = "anthropic" | "openai" | "github" | "cloudflare" | "godaddy" | "hostinger" | "digitalocean";
6export const INTEGRATIONS: { id: ProviderId; name: string; desc: string; ai?: boolean }[] = [
7 { id: "anthropic", name: "Anthropic", desc: "Claude models via the Messages API (API key)", ai: true },
8 { id: "openai", name: "OpenAI", desc: "GPT models via Chat Completions (API key)", ai: true },
9 { id: "github", name: "GitHub", desc: "Source hosting (personal access token)" },
10 { id: "cloudflare", name: "Cloudflare", desc: "DNS & CDN (API token)" },
11 { id: "godaddy", name: "GoDaddy", desc: "Registrar & DNS (key:secret)" },
12 { id: "hostinger", name: "Hostinger", desc: "VPS provider (API token)" },
13 { id: "digitalocean", name: "DigitalOcean", desc: "Cloud nodes (API token)" },
14];
15
16// ESTIMATES in USD per 1M tokens. Operator-editable via setting `ai.pricing`; provider invoices are authoritative.
17export const DEFAULT_PRICING: Record<string, { in: number; out: number }> = {
18 "claude-sonnet-5-5": { in: 3, out: 15 }, "claude-opus-5-5": { in: 15, out: 75 }, "claude-haiku-5-5": { in: 1, out: 5 },
19 "gpt-4o": { in: 2.5, out: 10 }, "gpt-4o-mini": { in: 0.15, out: 0.6 }, "mock-1": { in: 0, out: 0 },
20};
21export const MODELS: Record<string, string[]> = { anthropic: ["claude-sonnet-5-5", "claude-opus-5-5", "claude-haiku-5-5"], openai: ["gpt-4o", "gpt-4o-mini"], mock: ["mock-1"] };
22export const mockAllowed = () => process.env.ZCS_ALLOW_MOCK === "1";
23
24const probe: Record<ProviderId, (k: string) => { url: string; headers: Record<string, string> }> = {
25 anthropic: k => ({ url: "https://api.anthropic.com/v1/models?limit=1", headers: { "x-api-key": k, "anthropic-version": "2023-06-01" } }),
26 openai: k => ({ url: "https://api.openai.com/v1/models", headers: { authorization: `Bearer ${k}` } }),
27 github: k => ({ url: "https://api.github.com/user", headers: { authorization: `Bearer ${k}`, "user-agent": "zoo-cloud-studio", accept: "application/vnd.github+json" } }),
28 cloudflare: k => ({ url: "https://api.cloudflare.com/client/v4/user/tokens/verify", headers: { authorization: `Bearer ${k}` } }),
29 godaddy: k => ({ url: "https://api.godaddy.com/v1/domains?limit=1", headers: { authorization: `sso-key ${k}` } }),
30 hostinger: k => ({ url: "https://developers.hostinger.com/api/vps/v1/virtual-machines", headers: { authorization: `Bearer ${k}` } }),
31 digitalocean: k => ({ url: "https://api.digitalocean.com/v2/account", headers: { authorization: `Bearer ${k}` } }),
32};
33
34/** "verified" only on a real 2xx from the provider. Network failure => "error", never faked. */
35export async function verifyKey(id: ProviderId, key: string): Promise<{ status: "verified" | "invalid" | "error"; detail: string }> {
36 const p = probe[id](key);
37 try {
38 const r = await fetch(p.url, { headers: p.headers, signal: AbortSignal.timeout(10_000), redirect: "error" });
39 if (r.ok) return { status: "verified", detail: `HTTP ${r.status}` };
40 if (r.status === 401 || r.status === 403) return { status: "invalid", detail: `HTTP ${r.status} (rejected)` };
41 return { status: "error", detail: `HTTP ${r.status}` };
42 } catch (e) { return { status: "error", detail: `network: ${(e as Error).name}` }; }
43}
44
45export async function saveCredential(orgId: string, id: ProviderId, key: string) {
46 const e = encrypt(key); const v = await verifyKey(id, key);
47 await db().prepare(`INSERT INTO credentials(id,provider,ciphertext,iv,tag,hint,verified_at,status,updated_at,org_id) VALUES(?,?,?,?,?,?,?,?,?,?)
48 ON CONFLICT(org_id,provider) DO UPDATE SET ciphertext=excluded.ciphertext, iv=excluded.iv, tag=excluded.tag, hint=excluded.hint, verified_at=excluded.verified_at, status=excluded.status, updated_at=excluded.updated_at`)
49 .run(`cred_${orgId}_${id}`, id, e.ciphertext, e.iv, e.tag, hintOf(key), v.status === "verified" ? now() : null, v.status, now(), orgId);
50 return v;
51}
52export async function credentialStatus(orgId: string) {
53 const rows = await db().prepare("SELECT provider,hint,status,verified_at,updated_at FROM credentials WHERE org_id=?").all(orgId) as any[];
54 return Object.fromEntries(rows.map(r => [r.provider, { hint: r.hint, status: r.status, verified_at: r.verified_at, updated_at: r.updated_at }]));
55}
56export async function revealKey(orgId: string, id: ProviderId): Promise<string | null> {
57 const r = await db().prepare("SELECT ciphertext,iv,tag FROM credentials WHERE provider=? AND org_id=?").get(id, orgId) as any; return r ? decrypt(r) : null;
58}
59

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 692573d on master.

Approval requests

None pending.