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- ..
- ai.ts
- apps.ts
- audit.ts
- auth.ts
- central-core.d.mts
- central-core.mjs
- central.ts
- cloud.ts
- config.ts
- crypto.ts
- db.ts
- design.ts
- engines.ts
- files.ts
- gates.ts
- gateway.ts
- marketplace-core.d.mts
- marketplace-core.mjs
- metrics.ts
- modules.ts
- motion.ts
- nexus-core.d.mts
- nexus-core.mjs
- oidc-core.d.mts
- oidc-core.mjs
- oidc.ts
- providers.ts
- proxy-core.d.mts
- proxy-core.mjs
- pwauth-core.d.mts
- pwauth-core.mjs
- requirements.ts
- rls.sql.d.mts
- rls.sql.mjs
- services-content.ts
- ssrf.ts
- status.ts
- tenant.ts
- tlsgate.ts
- workspace.ts
app/src/app/api/ai/sessions/route.ts
1import { auditT, tenant } from "@/lib/tenant";2import { db, now, uid } from "@/lib/db";3import { MODELS } from "@/lib/providers";4import { providerOk } from "@/lib/ai";5import { isFreeOcModel } from "@/lib/engines";6export const dynamic = "force-dynamic";7export async function GET() {8 const g = await tenant("viewer"); if (g.res) return g.res;9 return Response.json(await db().prepare("SELECT * FROM ai_sessions WHERE org_id=? ORDER BY updated_at DESC LIMIT 50").all(g.ctx.orgId));10}11export async function POST(req: Request) {12 const g = await tenant("developer", { write: true }); if (g.res) return g.res; const ctx = g.ctx;13 const b = await req.json().catch(() => ({})); const provider = String(b.provider ?? ""), model = String(b.model ?? "");14 if (!providerOk(provider) || (provider === "opencode" ? !isFreeOcModel(model) : !(MODELS[provider] ?? []).includes(model))) return Response.json({ error: "unsupported provider/model" }, { status: 400 });15 const budget = Number(b.budget_usd ?? 1); if (!(budget > 0 && budget <= 100)) return Response.json({ error: "budget_usd must be in (0,100]" }, { status: 400 });16 const title = String(b.title ?? "New session").slice(0, 80) || "New session";17 let project: string | null = null;18 if (b.project_id) { const p = await db().prepare("SELECT id FROM projects WHERE id=? AND org_id=?").get(String(b.project_id), ctx.orgId); if (!p) return Response.json({ error: "unknown project" }, { status: 404 }); project = String(b.project_id); }19 const id = uid("ses_"); await db().prepare("INSERT INTO ai_sessions(id,project_id,title,provider,model,budget_usd,created_at,updated_at,org_id) VALUES(?,?,?,?,?,?,?,?,?)").run(id, project, title, provider, model, budget, now(), now(), ctx.orgId);20 await auditT(ctx, "ai.session.create", id, { provider, model, budget }); return Response.json({ id });21}22
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.