"use client";
import { useState } from "react";
import { AlertTriangle, Bot, Loader2 } from "lucide-react";
import { agentBuilderStub, type AgentBuilderAdapter } from "./agent-builder";
import { WorkspaceComposer } from "./workspace-composer";
export type AgentLibraryStatus =
| { status: "loading" }
| { status: "empty" }
| { status: "error"; message: string };
export function AgentLibraryState({ state }: { state: AgentLibraryStatus }) {
if (state.status === "loading") {
return (
Loading agents…
);
}
if (state.status === "error") {
return (
{state.message}
);
}
return (
No reusable agents yet
Agent creation and the workspace library are coming soon. You can draft
instructions below; nothing will be created or sent to Chat.
);
}
export function AgentsMode({
workspaceSlug,
active,
builder = agentBuilderStub,
libraryState = { status: "empty" },
}: {
workspaceSlug: string;
active: boolean;
builder?: AgentBuilderAdapter;
libraryState?: AgentLibraryStatus;
}) {
const [input, setInput] = useState("");
const [notice, setNotice] = useState(null);
const [busy, setBusy] = useState(false);
async function submitBuilderRequest() {
setBusy(true);
try {
const result = await builder({ workspaceSlug, prompt: input.trim() });
setNotice(result.message);
} catch {
setNotice(
"Builder unavailable. Your draft has been kept; please try again later.",
);
} finally {
setBusy(false);
}
}
return (
Agent library
{notice && (
{notice}
)}
{
void submitBuilderRequest();
}}
/>
);
}