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- ..
- assets
- basic-languages
- editor
- language
- nls
- abap-D-t0cyap.js
- apex-CcIm7xu6.js
- azcli-BA0tQDCg.js
- bat-C397hTD6.js
- bicep-DF5aW17k.js
- cameligo-plsz8qhj.js
- clojure-Y2auQMzK.js
- coffee-Bu45yuWE.js
- cpp-CkKPQIni.js
- csharp-CX28MZyh.js
- csp-D8uWnyxW.js
- css-CaeNmE3S.js
- css.worker-C7XcYe5x.js
- cssMode-DpEkhVlW.js
- cypher-DVThT8BS.js
- dart-CmGfCvrO.js
- dockerfile-CZqqYdch.js
- ecl-30fUercY.js
- editor-CG9c2pE-.js
- editor.js
- elixir-O3PRlgxO.js
- flow9-DqtmStfK.js
- freemarker2-DTUDMAl2.js
- fsharp-BOMdg4U1.js
- go-D_hbi-Jt.js
- graphql-CKUU4kLG.js
- handlebars-qLqoXa-4.js
- hcl-DTaboeZW.js
- html-DTxBj26n.js
- html.worker-VIR_LTyv.js
- htmlMode-DFBg6CMj.js
- index-BVflv2uG.js
- index.js
- ini--YXggpAu.js
- java-CI4ZMsH9.js
- javascript-BiL3JN6i.js
- json.worker-DzWXGkG8.js
- jsonMode-Dz4r0pwo.js
- julia-BwzEvaQw.js
- kotlin-IUYPiTV8.js
- less-C0eDYdqa.js
- lexon-iON-Kj97.js
- liquid-lXEUQRVn.js
- loader.js
- lspLanguageFeatures-IeRAvoKK.js
- lua-DtygF91M.js
- m3-CsR4AuFi.js
- markdown-C_rD0bIw.js
- mdx-Dtr248s4.js
- mips-CiYP61RB.js
- monaco.contribution-BRs4bdz5.js
- monaco.contribution-ChoOM5Gg.js
- monaco.contribution-DbKqsbmO.js
- monaco.contribution-DKFaWvum.js
- msdax-C38-sJlp.js
- mysql-CdtbpvbG.js
- nls.messages-loader.js
- objective-c-CntZFaHX.js
- pascal-r6kuqfl_.js
- pascaligo-BiXoTmXh.js
- perl-DABw_TcH.js
- pgsql-me_jFXeX.js
- php-D_kh-9LK.js
- pla-VfZjczW0.js
- postiats-BBSzz8Pk.js
- powerquery-Dt-g_2cc.js
- powershell-B-7ap1zc.js
- protobuf-BmtuEB1A.js
- pug-BRpRNeEb.js
- python-Cma5OvNe.js
- qsharp-BzsFaUU9.js
- r-f8dDdrp4.js
- razor-C8pOqqry.js
- redis-fvZQY4PI.js
- redshift-45Et0LQi.js
- restructuredtext-C7UUFKFD.js
- ruby-CZO8zYTz.js
- rust-Bfetafyc.js
- sb-3GYllVck.js
- scala-foMgrKo1.js
- scheme-CHdMtr7p.js
- scss-C1cmLt9V.js
- shell-ClXCKCEW.js
- solidity-MZ6ExpPy.js
- sophia-DWkuSsPQ.js
- sparql-AUGFYSyk.js
- sql-32GpJSV2.js
- st-CuDFIVZ_.js
- swift-t-PfMj7W.js
- systemverilog-Ch4vA8Yt.js
- tcl-D74tq1nH.js
- toggleHighContrast-CmI6H2gJ.js
- ts.worker-Dp2_QI6H.js
- tsMode-DgC3tGu_.js
- twig-C6taOxMV.js
- typescript-PjDChiYw.js
- typespec-D-PIh9Xw.js
- vb-Dyb2648j.js
- wgsl-BhLXMOR0.js
- workers-B_Zs9c54.js
- xml-BgCkTIhY.js
- yaml-D0tu26m-.js
app/src/lib/engines.ts
1// Engine registry + discovery. An "engine" is whatever executes an AI run: direct provider APIs or an agent CLI.2import { execFile } from "node:child_process";3import fs from "node:fs";4import os from "node:os";5import path from "node:path";6import { db, getSetting, setSetting } from "./db";7import { credentialStatus } from "./providers";89const OC_HOME = process.env.ZCS_OPENCODE_HOME || path.join(os.homedir(), ".local/opencode/home");10const OC_BIN = process.env.ZCS_OPENCODE_BIN || path.join(os.homedir(), ".local/opencode/node_modules/.bin/opencode");11export const isFreeOcModel = (m: string) => /^opencode\/[\w.-]+$/.test(m) && (/-free$/.test(m) || m === "opencode/big-pickle");12const env = () => ({ PATH: process.env.PATH, HOME: OC_HOME, XDG_CONFIG_HOME: `${OC_HOME}/c`, XDG_DATA_HOME: `${OC_HOME}/d`, XDG_STATE_HOME: `${OC_HOME}/s`, XDG_CACHE_HOME: `${OC_HOME}/k`, NO_COLOR: "1" } as unknown as NodeJS.ProcessEnv);13const run = (args: string[], ms: number) => new Promise<string | null>(res => execFile(OC_BIN, args, { env: env(), timeout: ms, maxBuffer: 1_000_000 }, (e, out) => res(e ? null : String(out))));1415export type OcInfo = { installed: boolean; version: string | null; models: string[]; freeModels: string[]; checkedAt: string };16let cache: { at: number; v: OcInfo } | null = null;17export async function opencodeInfo(force = false): Promise<OcInfo> {18 if (!force && cache && Date.now() - cache.at < 300_000) return cache.v;19 let installed = false; try { fs.accessSync(OC_BIN, fs.constants.X_OK); installed = true; } catch {}20 const version = installed ? (await run(["--version"], 15_000))?.trim().replace(/^opencode\s+v?/i, "") ?? null : null;21 const models = installed && version ? (await run(["models"], 30_000))?.split("\n").map(s => s.trim()).filter(l => /^[\w.-]+\/[\w.:-]+$/.test(l)) ?? [] : [];22 const v = { installed, version, models, freeModels: models.filter(isFreeOcModel), checkedAt: new Date().toISOString() }; cache = { at: Date.now(), v }; return v;23}2425export type EngineId = "claude-code" | "opencode" | "anthropic" | "openai" | "codex";26export const DEFAULT_MODEL: Record<string, string> = { opencode: "opencode/big-pickle", anthropic: "claude-haiku-5-5", openai: "gpt-4o-mini", mock: "mock-1" };27export async function loadEngineSettings() {28 let order: string[] = ["opencode", "anthropic", "openai"]; try { order = JSON.parse(await getSetting("ai.fallback_order", JSON.stringify(order))); } catch {}29 return { default: await getSetting("engine.default", ""), consent: (await getSetting("engine.opencode.consent", "0")) === "1", fallbackEnabled: (await getSetting("ai.fallback_enabled", "0")) === "1", fallbackOrder: order };30}31export async function engineStatus(orgId: string) {32 const oc = await opencodeInfo(); const cs = await credentialStatus(orgId); const st = await loadEngineSettings();33 const direct = (id: "anthropic" | "openai", name: string, models: string[]) => ({ id, name, kind: "direct API", installed: true, ready: !!cs[id], state: cs[id] ? (cs[id].status === "verified" ? "ready" : "key stored (" + cs[id].status + ")") : "awaiting credentials", models, note: "Streaming adapter verified against protocol stubs. Never run against the real API: no key supplied." });34 return [35 { id: "opencode", name: "OpenCode", kind: "agent engine (CLI)", installed: oc.installed, version: oc.version, ready: oc.installed && st.consent && oc.freeModels.length > 0, state: !oc.installed ? "not installed" : !st.consent ? "installed — owner consent required" : "ready (free models)", models: oc.freeModels, note: "Runs `opencode run --standalone` as a child process: no listening port. Execution engine, not a sandbox. Only documented free models are enabled; paid providers need credentials that are not configured." },36 direct("anthropic", "Direct Anthropic API", ["claude-sonnet-5-5", "claude-opus-5-5", "claude-haiku-5-5"]),37 direct("openai", "Direct OpenAI API", ["gpt-4o", "gpt-4o-mini"]),38 { id: "claude-code", name: "Claude Code", kind: "agent engine (CLI)", installed: false, ready: false, state: "blocked", models: [], note: "Not used as an application engine: a Claude Code subscription login is not an application credential and is never read. Needs an API-key-based integration and an isolation runtime." },39 { id: "codex", name: "Codex", kind: "agent engine (CLI)", installed: false, ready: false, state: "planned", models: [], note: "Future integration; nothing installed." },40 ];41}42export async function activeSessions(orgId?: string) {43 return await db().prepare("SELECT s.id,s.title,s.provider,s.model,s.status,s.project_id,s.spent_usd,r.status run_status FROM ai_sessions s LEFT JOIN LATERAL (SELECT status FROM ai_runs WHERE session_id=s.id ORDER BY created_at DESC LIMIT 1) r ON true WHERE (s.status<>'idle' OR r.status IN ('queued','running','paused')) AND (?::text IS NULL OR s.org_id=?) ORDER BY s.updated_at DESC LIMIT 20").all(orgId ?? null, orgId ?? null);44}45export { setSetting };46
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.