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/tlsgate.ts
1import tls from "node:tls";2import { headers } from "next/headers";3import { resolveConfig } from "./config";45// Credentials are accepted only on a connection that is PROVABLY trusted. Three independent facts must hold:6// 1. the edge (which overwrites every x-zcs-* header, so clients cannot forge them) says this TLS session was served with the publicly trusted,7// unexpired certificate selected by SNI, and the Host header names that same SNI host;8// 2. the host is the explicitly configured canonical host (never merely derived from the request);9// 3. a real handshake against the edge for that host validates against the system CA store with hostname verification (cached briefly).10// This is objective evidence, not a typed attestation, and it never depends on the self-signed preview certificate.11type Verified = { ok: boolean; reason?: string; validTo?: string; issuer?: string };12const cache = new Map<string, { at: number; v: Verified }>();13const TTL = 5 * 60 * 1000;1415export function verifyChain(host: string, port = Number(process.env.STUDIO_HTTPS_PORT || 8443)): Promise<Verified> {16 const hit = cache.get(host + ":" + port); if (hit && Date.now() - hit.at < TTL) return Promise.resolve(hit.v);17 return new Promise(resolve => {18 let done = false; const fin = (v: Verified) => { if (done) return; done = true; if (v.ok) cache.set(host + ":" + port, { at: Date.now(), v }); resolve(v); };19 const s = tls.connect({ host: "127.0.0.1", port, servername: host, rejectUnauthorized: true, minVersion: "TLSv1.2" }, () => {20 const c = s.getPeerCertificate(); const left = Date.parse(c.valid_to) - Date.now();21 s.end(); fin(left > 24 * 3600 * 1000 ? { ok: true, validTo: c.valid_to, issuer: String((c.issuer as any)?.O ?? "") } : { ok: false, reason: "certificate expires within 24 hours" });22 });23 s.setTimeout(5000, () => { s.destroy(); fin({ ok: false, reason: "handshake timeout" }); }); s.on("error", e => fin({ ok: false, reason: "chain/hostname verification failed: " + e.message.slice(0, 80) }));24 });25}2627export async function trustedConnection(): Promise<{ ok: boolean; reason?: string; host?: string; validTo?: string }> {28 const h = await headers(); const no = (reason: string) => ({ ok: false, reason });29 if (h.get("x-zcs-proto") !== "https") return no("not HTTPS");30 if (h.get("x-zcs-cert") !== "trusted") return no("served with the self-signed preview certificate");31 const host = (h.get("host") || "").replace(/:\d+$/, "").toLowerCase(); const sni = h.get("x-zcs-sni") || "";32 if (!host || host !== sni) return no("Host does not match the TLS server name");33 const pub = (await resolveConfig()).PUBLIC_BASE_URL;34 if (pub.source === "derived" || !pub.value) return no("canonical public URL is not configured");35 let canon = ""; try { canon = new URL(pub.value).hostname.toLowerCase(); } catch { return no("invalid canonical URL"); }36 if (canon !== host) return no("not the canonical host");37 const v = await verifyChain(host); return v.ok ? { ok: true, host, validTo: v.validTo } : no(v.reason ?? "verification failed");38}39
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.