Bot
feat: implement Devin-style Agent Workstation Panel with files, logs, settings, and screenshot tabs
b973b15
Raw
History Blame Contribute Delete
1.41 kB
import { NextRequest, NextResponse } from "next/server";
import { getSession } from "auth/server";
const getBackendUrl = () => {
if (process.env.BACKEND_API_URL) return process.env.BACKEND_API_URL;
const spaceId = process.env.SPACE_ID || "";
if (spaceId.startsWith("shyota/")) {
return "https://shyota-claude-code-backend.hf.space";
}
return "https://augment17-claude-code-backend.hf.space";
};
export async function GET(req: NextRequest) {
const session = await getSession();
if (!session?.user) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}
const backendUrl = getBackendUrl();
const apiKey = process.env.BACKEND_API_KEY || "";
const searchParams = req.nextUrl.searchParams;
const path = searchParams.get("path");
try {
let targetUrl = `${backendUrl}/api/workspace/tree`;
if (path) {
targetUrl = `${backendUrl}/api/workspace/file?path=${encodeURIComponent(path)}`;
}
const res = await fetch(targetUrl, {
headers: {
"Authorization": `Bearer ${apiKey}`,
},
cache: "no-store",
});
if (!res.ok) {
const txt = await res.text();
return NextResponse.json({ error: txt }, { status: res.status });
}
const data = await res.json();
return NextResponse.json(data);
} catch (err: any) {
return NextResponse.json({ error: err.message }, { status: 500 });
}
}