Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
49c7f9d
✨ feat(openclaw): add OpenClaw bot integration with WebSocket gateway
Feb 10, 2026
1895563
♻️ refactor(openclaw): extract bot chat state to BotChatProvider
Feb 11, 2026
38a5191
♻️ refactor(components): extract shared BotMessageList and MarkdownCo…
Feb 11, 2026
9626630
✨ feat(botchat): add auto-scroll and polling for real-time updates
Feb 11, 2026
f6e2be2
🐛 fix(botchat): filter system context markers from history messages
Feb 11, 2026
065ae18
🐛 fix(botchat): properly extract user content from system-polluted me…
Feb 11, 2026
e2e3b3b
🐛 fix(library): show bot chats in sidebar on library page
Feb 11, 2026
2049912
🐛 fix(botchat): remove duplicate loadChatHistory call in useEffect
Feb 11, 2026
1061059
✨ feat(home): add task mode toggle buttons at bottom of chat input
Feb 11, 2026
5fe2d2b
✨ feat(botchat): implement WebSocket real-time streaming with moltbot…
Feb 12, 2026
acd6f1f
✨ feat(home): add polling support for async Bot chat responses
Feb 12, 2026
26cd11f
🐛 fix(botchat): resolve WebSocket issues with React StrictMode
Feb 12, 2026
3892a3c
✨ feat(botchat): add "More..." button to show all bot chats
Feb 12, 2026
36fe37b
✨ feat(settings): improve OpenClaw Bot settings page
Feb 12, 2026
a38748e
📝 docs(locale): update navigation labels for clarity
Feb 12, 2026
32b8e65
🐛 fix(botchat): resolve duplicate message display in Bot chat
Feb 12, 2026
d709e9b
🐛 fix(botchat): preserve thinking and toolCalls in real-time messages
Feb 12, 2026
8edd019
🙈 chore: add .claude to .gitignore
Feb 12, 2026
5f9f4a7
✨ feat(sidebar): add tab navigation for Local/Bot tasks
Feb 15, 2026
0be704c
♻️ refactor(sidebar): improve pagination for history lists
Feb 15, 2026
b7a79b8
✨ feat(sidebar): improve bot chat titles and pagination
Feb 16, 2026
6bf4e3c
✨ feat(db): add unified storage for local tasks and bot chats
Feb 16, 2026
bfef7d1
📝 docs: add moltbot architecture analysis document
Feb 16, 2026
47a282c
✨ feat(sidebar): merge local tasks and bot chats into unified list
Feb 16, 2026
7ea4bdd
♻️ refactor(sidebar): fix task display and simplify bot session handling
Feb 16, 2026
41420ec
🐛 fix(sidebar): persist pagination state across navigation
Feb 16, 2026
69e8543
✨ feat(input): add provider selector dropdown for task execution
Feb 16, 2026
0d6f7b0
🔥 chore(settings): remove agent runtime selector from workplace
Feb 16, 2026
7ce0a75
✨ feat(input): show OpenClaw settings when not configured
Feb 16, 2026
50b78e1
docs: add bot session SQLite sync design document
Feb 19, 2026
0c0f4a8
docs: add bot session SQLite sync implementation plan
Feb 19, 2026
63e658d
feat(db): add bot_sessions and bot_messages tables
Feb 20, 2026
de2a64d
feat(types): add BotSessionRow and BotMessageRow types
Feb 20, 2026
714b7de
feat(db): add bot session CRUD functions
Feb 20, 2026
fb7362c
feat(db): add bot message CRUD functions
Feb 20, 2026
6c97d0c
feat(sync): add bot session sync utilities
Feb 20, 2026
d46ae6b
fix(sync): improve error handling and type safety
Feb 20, 2026
926afcc
feat(provider): integrate SQLite sync in BotChatProvider
Feb 20, 2026
37499b4
fix(provider): add cleanup and error logging
Feb 20, 2026
ab51ba4
feat(botchat): load local messages first with background sync
Feb 20, 2026
172c3ca
fix: resolve TypeScript error in bot-chat-provider
Feb 20, 2026
2cde026
feat(agent): implement two-step SSE pattern to fix WKWebView timeout
Feb 24, 2026
7df4f9f
feat(settings): add API format selector for Anthropic/OpenAI compatib…
Feb 25, 2026
3aacfc8
✨ feat(agent): add language-aware responses and fix UI issues
Feb 26, 2026
792af3b
✨ feat(ui): add sample prompts to home page
Feb 26, 2026
26cade1
✨ feat(agent): complete two-step SSE pattern and improve prompts UI
Feb 26, 2026
d762613
Merge branch 'dev' of workany-ai/workany into feat/sidebar-bot-integr…
Feb 28, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,7 @@ coverage/

# TypeScript cache
*.tsbuildinfo

.claude

features/
252 changes: 252 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,252 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Development Commands

```bash
# Install dependencies
pnpm install

# Development (recommended - runs API + desktop app)
pnpm dev:app

# Start API server only (port 2026 dev, 2620 production)
pnpm dev:api

# Start web UI only (port 1420)
pnpm dev:web

# Start all (API + web)
pnpm dev:all

# Build
pnpm build # Frontend
pnpm build:api # API to dist/
pnpm build:api:binary # API to standalone binary

# Desktop app builds (platform-specific)
pnpm build:app:mac-arm
pnpm build:app:mac-intel
pnpm build:app:linux
pnpm build:app:windows

# Linting and formatting
pnpm lint # ESLint
pnpm lint:fix # ESLint with auto-fix
pnpm format # Prettier
```

## Architecture Overview

WorkAny is a **three-tier desktop AI agent application**:

```
┌─────────────────────────────────────────────────────────────────────┐
│ Tauri Desktop Shell │
│ (src-tauri/ - Rust) │
│ - Window management, file system access, SQLite database │
│ - Embeds API binary as sidecar (src-api/dist/workany-api) │
└───────────────────────────┬─────────────────────────────────────────┘
┌───────────────────┴───────────────────┐
│ │
┌───────▼────────────┐ ┌───────────▼──────────┐
│ React Frontend │ │ Hono API Server │
│ (src/ - TSX) │◄────────────►│ (src-api/ - TS) │
│ Port: 1420 │ HTTP/JSON │ Port: 2026/2620 │
└────────────────────┘ └───────────┬──────────┘
┌──────────────────────┴───────────────────┐
│ Provider System │
├──────────────────────────────────────────┤
│ Agent Providers: │
│ - claude (Claude Agent SDK) │
│ - codex (OpenAI Codex) │
│ - deepagents (DeepAgents.js) │
│ │
│ Sandbox Providers: │
│ - codex (Codex CLI - VM isolation) │
│ - claude (Anthropic sandbox-runtime) │
│ - native (process execution) │
└──────────────────────────────────────────┘
```

## Core Subsystems

### 1. Provider System (`src-api/src/shared/provider/`)

Extensible registry pattern for both Agent and Sandbox providers. Key interfaces:

- `IProviderRegistry`: Register, get, and manage provider instances
- `ProviderPlugin`: Define providers with metadata, factory, lifecycle hooks
- `defineProviderPlugin()`: Helper to create typed provider plugins

**Provider loading flow:**
1. `initProviderManager()` reads `~/.workany/config.json`
2. Registers built-in providers (codex, claude, native)
3. Initializes configured providers from config

### 2. Agent System (`src-api/src/core/agent/`)

Agent implementations wrap different AI runtimes:

| Provider | Implementation | Usage |
|----------|---------------|-------|
| `claude` | Claude Agent SDK via anthropic.ai/claude-code | Production |
| `codex` | OpenAI Codex CLI | Optional |
| `deepagents` | DeepAgents.js library | Optional |

**Key interfaces:**
- `IAgent`: `run()`, `plan()`, `execute()`, `stop()`
- `AgentMessage`: Streaming message types (`text`, `tool_use`, `tool_result`, `plan`, etc.)
- `ConversationMessage`: Role-based chat history with image attachments

**Two-phase execution:**
1. **Plan phase**: `agent.plan()` → returns `TaskPlan` with steps
2. **Execute phase**: `agent.execute(planId)` → executes approved plan

### 3. Sandbox System (`src-api/src/core/sandbox/`)

Isolated code execution providers:

| Provider | Isolation | Network | Use Case |
|----------|-----------|---------|----------|
| `codex` | VM | Blocked | Untrusted code, security-sensitive |
| `claude` | Container | Varies | Claude Code integration |
| `native` | Process | Allowed | Trusted code, local operations |

**Key interfaces:**
- `ISandboxProvider`: `exec()`, `runScript()`, `isAvailable()`
- `SandboxExecOptions`: command, args, cwd, env, timeout, image
- `VolumeMount`: hostPath ↔ guestPath mapping

**Provider selection:** Codex preferred with fallback to native (see `src-api/src/app/api/sandbox.ts:37-81`)

### 4. MCP Integration (`src-api/src/app/api/mcp.ts`)

Model Context Protocol server support:

**Config paths searched:**
- `~/.workany/mcp.json` (WorkAny-specific)
- `~/.claude/settings.json` (Claude Code shared)

**Server types:**
- `stdio`: Command with args (local process)
- `http`: URL with headers (remote service)

### 5. Skills System

Agent skills are loaded from:
- `~/.workany/skills/` (app-specific)
- `~/.claude/skills/` (shared with Claude Code)

Skills extend agent capabilities with specialized workflows.

## API Routes Structure

```
/health - Dependency checking, setup
/agent - Agent execution (plan/execute modes)
POST /agent/run - Direct execution
POST /agent/plan - Planning phase
POST /agent/execute - Execute approved plan
/sandbox - Code execution
POST /sandbox/exec - Run command
POST /sandbox/run/file - Run script file
GET /sandbox/available - Provider info
/mcp - MCP server configuration
/files - File operations
/providers - Provider management
/preview - Artifact preview server
```

## Configuration Files

| Path | Purpose |
|------|---------|
| `~/.workany/config.json` | Provider selection, API keys, model config |
| `~/.workany/mcp.json` | MCP server configurations |
| `~/.claude/settings.json` | Claude Code settings (shared MCP config) |
| `~/.claude/skills/` | Shared agent skills directory |

**Config structure (`~/.workany/config.json`):**
```json
{
"providers": {
"sandbox": { "type": "codex", "config": {...} },
"agent": { "type": "claude", "config": {...} }
},
"apiKey": "...",
"model": "claude-sonnet-4-20250514"
}
```

## Important Constants

All centralized in `src-api/src/config/constants.ts`:

- `DEFAULT_API_PORT`: 2620 (production), 2026 (development)
- `DEFAULT_SANDBOX_PROVIDER`: "codex"
- `DEFAULT_AGENT_PROVIDER`: "claude"
- `SANDBOX_IMAGES`: node (node:18-alpine), python (python:3.11-slim), bun (oven/bun:latest)

## Frontend Architecture

**Main entry:** `src/main.tsx` → `src/app/App.tsx`

**Key pages:**
- `src/app/pages/Home.tsx`: Task input and agent messages
- `src/app/pages/Setup.tsx`: First-time dependency installation
- `src/app/pages/Library.tsx`: File/task library
- `src/app/pages/TaskDetail.tsx`: Task execution view

**Shared hooks:**
- `src/shared/hooks/useAgent.ts`: Agent communication
- `src/shared/hooks/useProviders.ts`: Provider management
- `src/shared/hooks/useVitePreview.ts`: Artifact preview

**Artifact previews:** `src/components/artifacts/` - Supports HTML, React, PDF, Excel, PPTX, images, video, audio, code

## Tauri Integration

**Binary embedding:** The compiled API binary (`src-api/dist/workany-api`) is bundled as a Tauri sidecar. See `src-tauri/tauri.conf.json:34-36`.

**Rust backend:** Minimal - primarily handles window lifecycle, file system dialogs via Tauri plugins. All business logic in Node.js API server.

**Database:** SQLite via `tauri-plugin-sql` for task/file storage.

## Dependency Checking Flow

When the app starts (`src/app/pages/Setup.tsx`):

1. Frontend polls `GET /health/dependencies` (5 retries, 1s delay)
2. Backend runs `which claude` and `which codex` with extended PATH
3. If unavailable, shows setup screen with install commands
4. "Codex" is optional, "Claude Code" is required

**Failure mode:** "无法检查依赖" (Unable to check dependencies) indicates API server unreachable or health check failed.

## Testing

No test suite currently exists. When adding tests:
- Unit tests for provider registry, agent base classes
- Integration tests for API endpoints
- E2E tests with Playwright for critical user flows

## Common Issues

**API server not reachable:**
- Check `pnpm dev:api` is running
- Verify `API_BASE_URL` in frontend config
- Check port conflicts (2026/2620)

**Codex sandbox unavailable:**
- Codex CLI must be installed and in PATH
- Extended PATH in `health.ts:87-113` includes common npm/global paths
- Falls back to `native` provider automatically

**MCP servers not loading:**
- Verify config file format: `{"mcpServers": {...}}`
- Check stdio command paths are absolute or in PATH
- Claude Code shares MCP config via `~/.claude/settings.json`
Loading