24}
25
26export function MessageItem({ message, usages, messageEndTimes, running }: MessageItemProps) {
27 return (
28 <div
2import { useLocalStorage } from "https://esm.sh/react-use?dev&deps=react@18.2.0&react-dom@18.2.0";
3
4export function Login() {
5 const [bearerToken, setBearerToken] = useLocalStorage("bearer", "");
6 const [anthropicApiKey, setAnthropicApiKey] = useLocalStorage("anthropic_api_key", "");
10}
11
12export function ImageUpload({ images, setImages }: ImageUploadProps) {
13 const fileInputRef = useRef<HTMLInputElement>(null);
14 const [isDragging, setIsDragging] = useState(false);
174
175// Component to display images in messages
176export function ImagePreview({ images }: { images: string[] }) {
177 const [expandedImage, setExpandedImage] = useState<string | null>(null);
178
2import { ValTown } from "npm:@valtown/sdk@0.37.0";
3
4async function view(
5 vt: ValTown,
6 project: any,
40}
41
42async function str_replace(
43 vt: ValTown,
44 project: any,
74}
75
76async function create(vt: ValTown, project: any, branch_id: string | undefined, path: string, file_text?: string) {
77 let type_: "file" | "http" | "script";
78 if (path.includes("backend/index.ts")) type_ = "http";
96}
97
98async function insert(
99 vt: ValTown,
100 project: any,
128 }
129}
130async function undo_edit(vt: ValTown, project: any, branch_id: string | undefined) {
131 return "Error: Command unimplemented";
132}
133
134export function getTextEditorTool(bearerToken: string, project: any, branch_id: string | undefined) {
135 const vt = new ValTown({ bearerToken });
136 return anthropic.tools.textEditor_20250124({
6}
7
8export function ErrorDisplay({ error }: ErrorDisplayProps) {
9 if (!error) return null;
10
16}
17
18// Helper function to build a tree structure from flat file list
19const buildFileTree = (files: Array<{ path: string; type: string }>): FileNode[] => {
20 const root: FileNode[] = [];
209};
210
211export function DirectoryTree({ files, onSelectionChange }: DirectoryTreeProps) {
212 const [treeData, setTreeData] = useState<FileNode[]>([]);
213 const [checkedState, setCheckedState] = useState<Record<string, boolean>>({});
220 }, [files]);
221
222 // Helper function to convert numbers to words (for small numbers)
223 const numberToWords = (num: number): string => {
224 const words = [
9}
10
11export function CreateBranch({
12 projectId,
13 bearerToken,
10import { ApiKeyWarning } from "./ApiKeyWarning.tsx";
11
12export function Chat({
13 project,
14 bearerToken,
12}
13
14export function ChatMessages({
15 messages,
16 usages,
12}
13
14export function ChatInput({
15 input,
16 handleInputChange,
115 onClick={() => {
116 const customStop = (window as any).customStopRef?.current;
117 if (typeof customStop === "function") {
118 customStop();
119 }