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/app/api/projects/[id]/tasks/route.ts
1import { db, now, uid } from "@/lib/db";2import { auditT, projectOf, tenant, notFound } from "@/lib/tenant";3export const dynamic = "force-dynamic";4type T = { id: string; title: string; done: number; depends_on: string; milestone_id: string | null };5const parse = (s: string): string[] => { try { const a = JSON.parse(s); return Array.isArray(a) ? a.map(String) : []; } catch { return []; } };6/** true if making `id` depend on `deps` would create a cycle */7function cycle(all: T[], id: string, deps: string[]): boolean {8 const g = new Map(all.map(t => [t.id, t.id === id ? deps : parse(t.depends_on)])); const seen = new Set<string>(); const stack = [...deps];9 while (stack.length) { const n = stack.pop()!; if (n === id) return true; if (seen.has(n)) continue; seen.add(n); stack.push(...(g.get(n) ?? [])); } return false;10}11export async function POST(req: Request, { params }: { params: Promise<{ id: string }> }) {12 const g = await tenant("developer", { write: true }); if (g.res) return g.res; const ctx = g.ctx; const { id } = await params;13 const b = await req.json().catch(() => ({})); const d = db();14 if (!(await projectOf(ctx, id))) return notFound();15 const all = await d.prepare("SELECT id,title,done,depends_on,milestone_id FROM tasks WHERE project_id=?").all(id) as T[]; const byId = new Map(all.map(t => [t.id, t]));16 if (b.toggle) {17 const t = byId.get(String(b.toggle)); if (!t) return Response.json({ error: "task not found" }, { status: 404 });18 if (!t.done) { const open = parse(t.depends_on).map(x => byId.get(x)).filter(x => x && !x.done); if (open.length) return Response.json({ error: `Blocked by unfinished dependencies: ${open.map(x => x!.title).join(", ")}` }, { status: 409 }); }19 await d.prepare("UPDATE tasks SET done=1-done WHERE id=? AND project_id=?").run(t.id, id); return Response.json({ ok: true });20 }21 if (b.update) { // {update: taskId, depends_on?: string[], milestone_id?: string|null, blocked_reason?: string|null}22 const t = byId.get(String(b.update)); if (!t) return Response.json({ error: "task not found" }, { status: 404 });23 if (b.depends_on !== undefined) {24 const deps: string[] = Array.isArray(b.depends_on) ? [...new Set<string>(b.depends_on.map(String))] : []; if (deps.length > 20 || deps.some(x => !byId.has(x) || x === t.id)) return Response.json({ error: "invalid dependency" }, { status: 422 });25 if (cycle(all, t.id, deps)) return Response.json({ error: "dependency cycle rejected" }, { status: 422 });26 await d.prepare("UPDATE tasks SET depends_on=? WHERE id=?").run(JSON.stringify(deps), t.id);27 }28 if (b.milestone_id !== undefined) { if (b.milestone_id && !await d.prepare("SELECT 1 FROM milestones WHERE id=? AND project_id=?").get(String(b.milestone_id), id)) return Response.json({ error: "milestone not found" }, { status: 404 }); await d.prepare("UPDATE tasks SET milestone_id=? WHERE id=?").run(b.milestone_id ? String(b.milestone_id) : null, t.id); }29 if (b.blocked_reason !== undefined) await d.prepare("UPDATE tasks SET blocked_reason=? WHERE id=?").run(b.blocked_reason ? String(b.blocked_reason).slice(0, 200) : null, t.id);30 await auditT(ctx, "task.update", id, { task: t.id }); return Response.json({ ok: true });31 }32 const title = String(b.title ?? "").trim(); if (title.length < 1 || title.length > 200) return Response.json({ error: "title required (≤200 chars)" }, { status: 422 });33 const tid = uid("t_"); await d.prepare("INSERT INTO tasks(id,project_id,title,created_at) VALUES(?,?,?,?)").run(tid, id, title, now());34 await auditT(ctx, "task.create", id, { title }); return Response.json({ id: tid }, { status: 201 });35}36
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.