mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-04-26 00:46:23 +02:00
Add agent selection and artifact management to RowboatX UI
- Implemented agent selection dropdown in the input area. - Enhanced artifact management with loading, saving, and error handling. - Added new API routes for fetching agent summaries and run details. - Updated sidebar to display agents, configurations, and runs dynamically. - Introduced theme selection options in the user navigation menu.
This commit is contained in:
parent
b1f6e64244
commit
023a65de45
8 changed files with 965 additions and 251 deletions
|
|
@ -11,7 +11,7 @@ export const dynamic = 'force-dynamic';
|
|||
export async function POST(request: NextRequest) {
|
||||
try {
|
||||
const body = await request.json();
|
||||
const { message, runId } = body;
|
||||
const { message, runId, agentId } = body;
|
||||
|
||||
if (!message || typeof message !== 'string') {
|
||||
return Response.json(
|
||||
|
|
@ -25,7 +25,7 @@ export async function POST(request: NextRequest) {
|
|||
// Create new run if no runId provided
|
||||
if (!currentRunId) {
|
||||
const run = await cliClient.createRun({
|
||||
agentId: 'copilot',
|
||||
agentId: agentId || 'copilot',
|
||||
});
|
||||
currentRunId = run.id;
|
||||
}
|
||||
|
|
|
|||
71
apps/rowboatx/app/api/cli/[...path]/route.ts
Normal file
71
apps/rowboatx/app/api/cli/[...path]/route.ts
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
import { NextRequest } from "next/server";
|
||||
|
||||
const BACKEND = process.env.CLI_BACKEND_URL || "http://localhost:3000";
|
||||
const CORS_HEADERS = {
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
"Access-Control-Allow-Methods": "GET,POST,PUT,DELETE,OPTIONS",
|
||||
"Access-Control-Allow-Headers": "Content-Type, Authorization",
|
||||
};
|
||||
|
||||
async function forward(req: NextRequest, method: string, segments?: string[]) {
|
||||
const search = req.nextUrl.search || "";
|
||||
const targetPath = (segments || []).join("/");
|
||||
const target = `${BACKEND}/${targetPath}${search}`;
|
||||
|
||||
const init: RequestInit = {
|
||||
method,
|
||||
headers: {
|
||||
"Content-Type": req.headers.get("content-type") || "application/json",
|
||||
},
|
||||
};
|
||||
|
||||
if (method !== "GET" && method !== "HEAD") {
|
||||
init.body = await req.text();
|
||||
}
|
||||
|
||||
const res = await fetch(target, init);
|
||||
const body = await res.text();
|
||||
return new Response(body, {
|
||||
status: res.status,
|
||||
headers: {
|
||||
"content-type": res.headers.get("content-type") || "application/json",
|
||||
...CORS_HEADERS,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function GET(
|
||||
req: NextRequest,
|
||||
context: { params: Promise<{ path?: string[] }> }
|
||||
) {
|
||||
const { path } = await context.params;
|
||||
return forward(req, "GET", path);
|
||||
}
|
||||
|
||||
export async function POST(
|
||||
req: NextRequest,
|
||||
context: { params: Promise<{ path?: string[] }> }
|
||||
) {
|
||||
const { path } = await context.params;
|
||||
return forward(req, "POST", path);
|
||||
}
|
||||
|
||||
export async function PUT(
|
||||
req: NextRequest,
|
||||
context: { params: Promise<{ path?: string[] }> }
|
||||
) {
|
||||
const { path } = await context.params;
|
||||
return forward(req, "PUT", path);
|
||||
}
|
||||
|
||||
export async function DELETE(
|
||||
req: NextRequest,
|
||||
context: { params: Promise<{ path?: string[] }> }
|
||||
) {
|
||||
const { path } = await context.params;
|
||||
return forward(req, "DELETE", path);
|
||||
}
|
||||
|
||||
export async function OPTIONS() {
|
||||
return new Response(null, { status: 204, headers: CORS_HEADERS });
|
||||
}
|
||||
34
apps/rowboatx/app/api/rowboat/run/route.ts
Normal file
34
apps/rowboatx/app/api/rowboat/run/route.ts
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import { NextRequest } from "next/server";
|
||||
import os from "os";
|
||||
import path from "path";
|
||||
import { promises as fs } from "fs";
|
||||
|
||||
const ROWBOAT_ROOT = path.join(os.homedir(), ".rowboat", "runs");
|
||||
|
||||
export async function GET(req: NextRequest) {
|
||||
const fileParam = req.nextUrl.searchParams.get("file");
|
||||
if (!fileParam) {
|
||||
return Response.json({ error: "file param required" }, { status: 400 });
|
||||
}
|
||||
|
||||
// Prevent path traversal: only allow basenames.
|
||||
const safeName = path.basename(fileParam);
|
||||
const target = path.join(ROWBOAT_ROOT, safeName);
|
||||
|
||||
try {
|
||||
const content = await fs.readFile(target, "utf8");
|
||||
let parsed: any = null;
|
||||
try {
|
||||
parsed = JSON.parse(content);
|
||||
} catch {
|
||||
parsed = null;
|
||||
}
|
||||
return Response.json({ file: safeName, parsed, raw: content });
|
||||
} catch (error: any) {
|
||||
console.error("Failed to read run file", error);
|
||||
return Response.json(
|
||||
{ error: "Failed to read run file" },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
28
apps/rowboatx/app/api/rowboat/summary/route.ts
Normal file
28
apps/rowboatx/app/api/rowboat/summary/route.ts
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import { NextRequest } from "next/server";
|
||||
import path from "path";
|
||||
import os from "os";
|
||||
import { promises as fs } from "fs";
|
||||
|
||||
const ROWBOAT_ROOT = path.join(os.homedir(), ".rowboat");
|
||||
|
||||
async function safeList(dir: string): Promise<string[]> {
|
||||
const full = path.join(ROWBOAT_ROOT, dir);
|
||||
try {
|
||||
const entries = await fs.readdir(full, { withFileTypes: true });
|
||||
return entries.filter((e) => e.isFile()).map((e) => e.name);
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
export async function GET(_req: NextRequest) {
|
||||
const agents = await safeList("agents");
|
||||
const config = await safeList("config");
|
||||
const runs = await safeList("runs");
|
||||
|
||||
return Response.json({
|
||||
agents,
|
||||
config,
|
||||
runs,
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue