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- ..
- _clean.mjs
- acceptance.mjs
- ai-adapters.mjs
- ai-enqueue.mjs
- central.mjs
- deploy-flow.mjs
- external-vps.mjs
- fake-opencode.mjs
- gates.mjs
- immersive.mjs
- lower.mjs
- nexus.mjs
- oidc-core.mjs
- oidc-flow.mjs
- opencode-engine.mjs
- owner-auth.mjs
- proxy.mjs
- retake-landing.mjs
- rls.mjs
- run.mjs
- services.mjs
- shot-central.mjs
- tenant-isolation.mjs
- trusted-https.mjs
- web-shots.mjs
- with-derived.mjs
app/src/app/api/ai/sessions/[id]/control/route.ts
1import { db, now } from "@/lib/db";2import { auditT, sessionOf, tenant, notFound } from "@/lib/tenant";3// pause/cancel on a queued run take effect at once; on a running run they are flags the worker honours at its next stream flush.4export async function POST(req: Request, { params }: { params: Promise<{ id: string }> }) {5 const g = await tenant("developer", { write: true }); if (g.res) return g.res; const ctx = g.ctx; const { id } = await params; if (!(await sessionOf(ctx, id))) return notFound();6 const b = await req.json().catch(() => ({})); const action = String(b.action);7 const r = await db().prepare("SELECT id,status FROM ai_runs WHERE session_id=? AND status IN ('queued','running','paused','failed') ORDER BY created_at DESC LIMIT 1").get(id) as any;8 if (!r) return Response.json({ error: "no active run" }, { status: 404 });9 const n = now(); let q = "";10 if (action === "pause") q = r.status === "queued" ? "UPDATE ai_runs SET status='paused', updated_at=? WHERE id=? AND status='queued'" : r.status === "running" ? "UPDATE ai_runs SET cancel_requested=2, updated_at=? WHERE id=? AND status='running'" : "";11 else if (action === "resume") q = r.status === "paused" ? "UPDATE ai_runs SET status='queued', cancel_requested=0, run_after=0, updated_at=? WHERE id=? AND status='paused'" : "";12 else if (action === "retry") q = r.status === "failed" ? "UPDATE ai_runs SET status='queued', cancel_requested=0, attempts=0, error=NULL, run_after=0, updated_at=? WHERE id=? AND status='failed'" : "";13 else if (action === "cancel") q = r.status === "running" ? "UPDATE ai_runs SET cancel_requested=1, updated_at=? WHERE id=? AND status='running'" : "UPDATE ai_runs SET status='cancelled', updated_at=? WHERE id=? AND status IN ('queued','paused','failed')";14 else return Response.json({ error: "action must be pause|resume|cancel|retry" }, { status: 400 });15 if (!q) return Response.json({ error: `cannot ${action} a ${r.status} run` }, { status: 409 });16 await db().prepare(q).run(n, r.id);17 await db().prepare("INSERT INTO ai_checkpoints(run_id,seq,kind,detail,created_at) VALUES(?,(SELECT COALESCE(MAX(seq),0)+1 FROM ai_checkpoints WHERE run_id=?),?,?,?)").run(r.id, r.id, `control:${action}`, "requested by admin", n);18 await auditT(ctx, `ai.run.${action}`, r.id, { session: id }); return Response.json({ ok: true, run: r.id });19}20
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 0eebc42 on master.
Approval requests
None pending.