/** Shared types between client and server for claw-web * EXACT parity with original claw-code repository. */ export type MessageRole = "user" | "assistant" | "system" | "tool"; export interface ToolCallData { id: string; name: string; arguments: string; } export interface ToolResultData { toolCallId: string; toolName: string; output: string; isError?: boolean; durationMs?: number; } export interface ChatMessageData { id?: number; sessionId: number; role: MessageRole; content: string | null; toolCalls?: ToolCallData[] | null; toolCallId?: string | null; toolName?: string | null; promptTokens?: number; completionTokens?: number; cost?: number; model?: string | null; durationMs?: number; createdAt?: Date; } export interface SessionData { id: number; userId: number; title: string; model: string; provider: string; systemPrompt: string | null; isArchived: number; createdAt: Date; updatedAt: Date; } export interface SettingsData { apiProvider: string; apiKey?: string | null; apiBaseUrl?: string | null; model: string; maxTokens: number; temperature: number; topP: number; systemPrompt?: string | null; memoryContent?: string | null; theme: string; expandToolCalls: number; autoApproveSafeTools: number; } export interface CostSummary { totalCost: number; totalPromptTokens: number; totalCompletionTokens: number; } /** SSE event types for streaming */ export type StreamEventType = | "text_delta" | "tool_call_start" | "tool_call_delta" | "tool_call_end" | "tool_result" | "message_start" | "message_end" | "error" | "usage" | "status" | "ask_user" | "title_update" | "plan_update"; export interface StreamEvent { type: StreamEventType; data: unknown; } /** * Tool names — EXACT parity with original claw-code mvp_tool_specs (19 tools). * Names are PascalCase/snake_case exactly as in the Rust source. */ export const TOOL_NAMES = [ // Core 19 tools (from Rust mvp_tool_specs) "bash", "PowerShell", "read_file", "write_file", "edit_file", "glob_search", "grep_search", "NotebookEdit", "WebSearch", "WebFetch", "TodoWrite", "Agent", "SendUserMessage", "Brief", "TestingPermission", "ToolSearch", "Config", "Skill", "Sleep", "REPL", "StructuredOutput", // Extended (full parity with original claw-code) "TaskCreate", "TaskGet", "TaskList", "TaskOutput", "TaskStop", "TaskUpdate", "CronCreate", "CronDelete", "CronList", "LSP", "EnterPlanMode", "ExitPlanMode", "EnterWorktree", "ExitWorktree", "TeamCreate", "TeamDelete", "RemoteTrigger", "SyntheticOutput", // MCP "mcp_tool", "list_mcp_resources", "read_mcp_resource", "mcp_auth", ] as const; export type ToolName = (typeof TOOL_NAMES)[number]; /** * Slash commands — EXACT parity with original claw-code SLASH_COMMAND_SPECS (28 commands). * Names, descriptions, and categories match the Rust commands crate. */ export const SLASH_COMMANDS = [ { name: "/help", description: "Show available slash commands", category: "General" }, { name: "/status", description: "Show current session status", category: "General" }, { name: "/compact", description: "Compact local session history", category: "Context" }, { name: "/model", description: "Show or switch the active model", category: "Config" }, { name: "/permissions", description: "Show or switch the active permission mode", category: "Config" }, { name: "/clear", description: "Start a fresh local session", category: "Session" }, { name: "/cost", description: "Show cumulative token usage for this session", category: "Info" }, { name: "/resume", description: "Load a saved session into the REPL", category: "Session" }, { name: "/config", description: "Inspect Claw config files or merged sections", category: "Config" }, { name: "/memory", description: "Inspect loaded Claw instruction memory files", category: "Memory" }, { name: "/init", description: "Create a starter CLAW.md for this repo", category: "System" }, { name: "/diff", description: "Show git diff for current workspace changes", category: "Git" }, { name: "/version", description: "Show CLI version and build information", category: "Info" }, { name: "/bughunter", description: "Inspect the codebase for likely bugs", category: "Tools" }, { name: "/branch", description: "List, create, or switch git branches", category: "Git" }, { name: "/worktree", description: "List, add, remove, or prune git worktrees", category: "Git" }, { name: "/commit", description: "Generate a commit message and create a git commit", category: "Git" }, { name: "/commit-push-pr", description: "Commit workspace changes, push the branch, and open a PR", category: "Git" }, { name: "/pr", description: "Draft or create a pull request from the conversation", category: "Git" }, { name: "/issue", description: "Draft or create a GitHub issue from the conversation", category: "Git" }, { name: "/ultraplan", description: "Run a deep planning prompt with multi-step reasoning", category: "Planning" }, { name: "/teleport", description: "Jump to a file or symbol by searching the workspace", category: "Navigation" }, { name: "/debug-tool-call", description: "Replay the last tool call with debug details", category: "Debug" }, { name: "/export", description: "Export the current conversation to a file", category: "Session" }, { name: "/session", description: "List or switch managed local sessions", category: "Session" }, { name: "/plugin", description: "Manage Claw Code plugins", category: "Integration", aliases: ["/plugins", "/marketplace"] }, { name: "/agents", description: "List configured agents", category: "Agent" }, { name: "/skills", description: "List available skills", category: "Tools" }, // ── Extended commands (full parity) ── { name: "/advisor", description: "Toggle advisor mode (suggest without executing)", category: "Config" }, { name: "/ant-trace", description: "Trace tool execution history", category: "Debug" }, { name: "/api", description: "Show API key configuration", category: "Config" }, { name: "/autofix-pr", description: "Auto-fix PR review comments", category: "Git" }, { name: "/backfill-sessions", description: "Migrate sessions from older formats", category: "Session" }, { name: "/break-cache", description: "Clear all in-memory caches", category: "System" }, { name: "/bridge", description: "IDE bridge connection management", category: "Integration" }, { name: "/bridge-kick", description: "Restart IDE bridge connection", category: "Integration" }, { name: "/btw", description: "Add a quick aside to the conversation", category: "General" }, { name: "/caches", description: "Show cache status and sizes", category: "System" }, { name: "/chrome", description: "Chrome integration status", category: "Integration" }, { name: "/color", description: "Switch color scheme", category: "Config" }, { name: "/context", description: "Show context window usage", category: "Context" }, { name: "/context-noninteractive", description: "Non-interactive context dump", category: "Context" }, { name: "/conversation", description: "Export or view conversation stats", category: "Session" }, { name: "/ctx_viz", description: "Visualize context window contents", category: "Context" }, { name: "/desktop", description: "Desktop mode information", category: "Integration" }, { name: "/exit", description: "Exit the application", category: "General" }, { name: "/extra-usage", description: "Extended token usage statistics", category: "Info" }, { name: "/extra-usage-core", description: "Core usage breakdown", category: "Info" }, { name: "/extra-usage-noninteractive", description: "Non-interactive usage stats", category: "Info" }, { name: "/fast", description: "Enable fast mode (low effort)", category: "Config" }, { name: "/good-claw", description: "Send positive feedback", category: "General" }, { name: "/heapdump", description: "Show memory heap dump", category: "Debug" }, { name: "/ide", description: "IDE integration information", category: "Integration" }, { name: "/init-verifiers", description: "Initialize code verification hooks", category: "Tools" }, { name: "/insights", description: "Show session insights and patterns", category: "Info" }, { name: "/install", description: "Install npm/pip/apt packages", category: "Tools" }, { name: "/install-github-app", description: "Install the Claw GitHub App", category: "Integration" }, { name: "/install-slack-app", description: "Install the Claw Slack App", category: "Integration" }, { name: "/mobile", description: "Mobile mode information", category: "Integration" }, { name: "/mock-limits", description: "Toggle mock rate limits for testing", category: "Debug" }, { name: "/oauth-refresh", description: "Refresh OAuth tokens", category: "System" }, { name: "/passes", description: "Show agentic pass count", category: "Info" }, { name: "/perf-issue", description: "Report a performance issue", category: "Debug" }, { name: "/privacy-settings", description: "View privacy settings", category: "Config" }, { name: "/rate-limit-options", description: "View rate limit configuration", category: "Config" }, { name: "/remote-env", description: "Remote environment configuration", category: "Integration" }, { name: "/rename", description: "Rename the current session", category: "Session" }, { name: "/reset-limits", description: "Reset rate limits to defaults", category: "System" }, { name: "/reviewRemote", description: "Review a remote pull request", category: "Git" }, { name: "/security-review", description: "Run a security review scan", category: "Tools" }, { name: "/statusline", description: "Show status line configuration", category: "Config" }, { name: "/upgrade", description: "Check for and install updates", category: "System" }, ] as const; /** API Provider presets — matching original claw-code providers */ export const API_PROVIDERS = [ { id: "claw", name: "Claw API (Built-in)", baseUrl: "" }, { id: "huggingface", name: "HuggingFace", baseUrl: "https://router.huggingface.co/v1" }, { id: "xai", name: "xAI (Grok)", baseUrl: "https://api.x.ai/v1" }, { id: "openrouter", name: "OpenRouter", baseUrl: "https://openrouter.ai/api/v1" }, { id: "openai", name: "OpenAI", baseUrl: "https://api.openai.com/v1" }, { id: "anthropic", name: "Anthropic", baseUrl: "https://api.anthropic.com/v1" }, { id: "ollama", name: "Ollama (Local)", baseUrl: "http://localhost:11434/v1" }, { id: "custom", name: "Custom API", baseUrl: "" }, ] as const; /** * Model presets — EXACT parity with original claw-code providers/mod.rs. * Aliases and model IDs match the Rust model registry. */ export const MODEL_PRESETS = [ // Xiaomi MiMo (default) { id: "XiaomiMiMo/MiMo-V2-Flash", name: "MiMo-V2-Flash", provider: "huggingface", alias: "mimo", tier: "standard" }, // Qwen models { id: "Qwen/Qwen3-8B", name: "Qwen3 8B", provider: "huggingface", alias: "qwen3-8b", tier: "fast" }, { id: "Qwen/Qwen3-Coder-30B-A3B-Instruct", name: "Qwen3 Coder 30B", provider: "huggingface", alias: "qwen-coder", tier: "standard" }, // Meta Llama { id: "meta-llama/Llama-3.3-70B-Instruct", name: "Llama 3.3 70B", provider: "huggingface", alias: "llama", tier: "frontier" }, // DeepSeek { id: "deepseek-ai/DeepSeek-V3.2", name: "DeepSeek V3.2", provider: "huggingface", alias: "deepseek", tier: "frontier" }, { id: "deepseek-ai/DeepSeek-R1", name: "DeepSeek R1", provider: "huggingface", alias: "deepseek-r1", tier: "frontier" }, ] as const; /** The frontier model name as defined in original claw-code */ export const FRONTIER_MODEL_NAME = "Qwen3-Coder-480B-Turbo"; export const DEFAULT_MODEL_ALIAS = "qwen-coder"; export const DEFAULT_MODEL_ID = "Qwen/Qwen3-Coder-480B-A35B-Instruct-Turbo"; /** Effort levels */ export const EFFORT_LEVELS = ["low", "medium", "high"] as const; export type EffortLevel = (typeof EFFORT_LEVELS)[number]; /** Plan step status */ export type PlanStepStatus = "pending" | "in_progress" | "done" | "skipped"; export interface PlanStep { id: number; text: string; status: PlanStepStatus; }