Users, file manager, image generation, budgets and agent workflow

- User management: local accounts (Argon2) and OpenID Connect, admin/user
  roles, per-user folders plus admin-shared folders, read-only session
  sharing, event filtering per user
- File manager with CodeMirror editor and git client (status, diff,
  stage, commit, branches, fetch/pull/push, log, clone/init)
- Image generation via fal.ai: generate_image tool and image page
- Budgets: monthly limits per provider, provider balances/costs
  (OpenRouter, Anthropic admin cost report, fal.ai), price discovery
- Subagents on other models, background tasks, concurrency limits per
  host/model/subagent
- MCP tools loaded on demand (mcp_search/mcp_call), read-only hints
- Permission mode "auto", safe read-only commands always allowed
- Persistent message queue with attachments, deletable
- Live reasoning incl. <think> tags, activity animations, CSS themes,
  mobile layout, statistics per user, upload size handling
- Docker: named volume for state, localhost-bound port

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Richard ZinkandClaude Opus 5.5 committed 2026-11-08 16:54:08 +01:00
1 parent f3a2fe3816
commit 49262c612c
70 files changed
+8495 -714

No files matched your search

+18 -15
View File
@@ -1,14 +1,6 @@
import type { ServerEvent } from "./types";
const TOKEN_KEY = "codecraft.token";
export function getToken(): string {
return localStorage.getItem(TOKEN_KEY) ?? "";
}
export function setToken(token: string) {
localStorage.setItem(TOKEN_KEY, token);
}
// Authentication uses an HttpOnly session cookie set by /api/auth/login.
export class ApiError extends Error {
constructor(
@@ -21,20 +13,32 @@ export class ApiError extends Error {
export async function api<T = any>(path: string, init: RequestInit & { json?: unknown } = {}): Promise<T> {
const headers: Record<string, string> = { ...(init.headers as Record<string, string>) };
const token = getToken();
if (token) headers.Authorization = `Bearer ${token}`;
let body = init.body;
if (init.json !== undefined) {
headers["Content-Type"] = "application/json";
body = JSON.stringify(init.json);
}
const res = await fetch(`/api${path}`, { ...init, headers, body });
const res = await fetch(`/api${path}`, { ...init, headers, body, credentials: "same-origin" });
if (res.status === 401 && !path.startsWith("/auth/") && path !== "/info") onUnauthorized?.();
const text = await res.text();
const data = text ? JSON.parse(text) : null;
let data: any = null;
try {
data = text ? JSON.parse(text) : null;
} catch {
// Proxies answer with HTML error pages (e.g. 413 from nginx).
const hint = res.status === 413 ? "request too large – the reverse proxy rejected the upload (client_max_body_size)" : res.statusText || "unexpected response";
throw new ApiError(res.status, `HTTP ${res.status}: ${hint}`);
}
if (!res.ok) throw new ApiError(res.status, data?.error ?? res.statusText);
return data as T;
}
/** Called when the session expired (set by the app to show the login). */
let onUnauthorized: (() => void) | undefined;
export function setUnauthorizedHandler(fn: () => void) {
onUnauthorized = fn;
}
export const get = <T = any>(path: string) => api<T>(path);
export const post = <T = any>(path: string, json?: unknown) => api<T>(path, { method: "POST", json: json ?? {} });
export const patch = <T = any>(path: string, json: unknown) => api<T>(path, { method: "PATCH", json });
@@ -55,8 +59,7 @@ export function connectEvents(handlers: {
const open = () => {
const proto = location.protocol === "https:" ? "wss" : "ws";
const token = encodeURIComponent(getToken());
ws = new WebSocket(`${proto}://${location.host}/api/ws?token=${token}`);
ws = new WebSocket(`${proto}://${location.host}/api/ws`);
ws.onopen = () => {
retry = 0;
handlers.onOpen();