Skip to content

Conversation

@basnijholt
Copy link
Owner

Summary

  • Add FastAPI server exposing Claude Code via REST + WebSocket for remote access
  • Use official Claude Agent SDK with existing Claude Code subscription authentication
  • New CLI command: agent-cli claude-serve --port 8765 --cwd /path/to/project

Features

  • REST endpoints: /session/new, /session/{id}/prompt, /session/{id}/cancel
  • WebSocket endpoint: /session/{id}/stream for real-time streaming
  • Session continuity: Multi-turn conversations via Claude SDK resume parameter
  • iOS Shortcut integration: Updated documentation with setup instructions

Installation

pip install agent-cli[claude]

Prerequisites

  • Run claude /login once to authenticate with your Claude.ai account

Test plan

  • Tested health endpoint
  • Tested session creation
  • Tested single prompt ("What is 2+2?")
  • Tested session continuity ("Now multiply that by 3" → 12)
  • Tested file access operations
  • Test WebSocket streaming

Add a FastAPI server that exposes Claude Code capabilities via REST and WebSocket,
enabling remote access from iOS Shortcuts, web interfaces, or any HTTP client.

Uses the official Claude Agent SDK which authenticates via existing Claude Code
subscription (after running `claude /login`).

Features:
- REST endpoints: /session/new, /session/{id}/prompt, /session/{id}/cancel
- WebSocket endpoint: /session/{id}/stream for real-time streaming
- Session management with conversation continuity (via resume parameter)
- Configurable allowed tools and permission modes
- New CLI command: `agent-cli claude-serve`

Install with: pip install agent-cli[claude]
- Extract _build_options helper to eliminate duplicated ClaudeAgentOptions construction
- Remove unused _get_sdk_types function
- Remove unused Session.messages field
- Define DEFAULT_ALLOWED_TOOLS as module constant
- Add 16 unit tests covering SessionManager, endpoints, and options builder
- Add ProjectManager with "In {project}," prefix parsing, sticky sessions,
  and explicit project parameter support
- Add LogStore for conversation history with log_id-based retrieval
- Add /prompt endpoint with automatic session/project management
- Add /log/{id} and /logs endpoints for web UI viewing
- Add /projects and /switch-project endpoints
- Track file changes from Edit/Write/MultiEdit tool calls
- Configure projects via config.toml [claude_server] section
- Add comprehensive tests (29 total, all passing)
- Replace custom CSS with DaisyUI via CDN
- Dark theme with cards, badges, tables
- Collapsible full response section
- Mobile-responsive layout
- Interactive chat interface with DaisyUI styling
- Hold-to-record mic button for voice input
- Configurable voice server URL for transcription
- Project selector dropdown
- Chat bubble UI with files_changed and log links
- Mobile-friendly responsive layout
- Auto-generate self-signed SSL certificate on first use
- Store certs in ~/.config/agent-cli/ssl/
- Required for voice recording on Safari/iOS (mediaDevices needs HTTPS)
- Add better error handling when mediaDevices unavailable
- Update endpoint display to show protocol
…missions

- Add /logs/json endpoint for JSON log retrieval
- Load conversation history on chat page load
- Add explicit mic permission button for Safari/iOS
- Add permission state tracking and improved UX feedback
- Add per-file ruff ignore for S608 (HTML templates, not SQL)
- Replace custom JS chat handling with HTMX attributes
- Add /chat/messages endpoint for loading history as HTML fragments
- Add /chat/send endpoint for form submission returning HTML
- Move all imports to top of file (no more inline imports)
- Remove _check_claude_sdk() - assume SDK is installed
- Add _render_message helper for consistent chat bubble HTML
- Reduce JS from ~150 lines to ~70 (voice recording only)
- Add /chat/stream endpoint that streams response via Server-Sent Events
- Update chat UI to show real-time streaming text as Claude responds
- Show tool usage indicators during streaming (🔧 tool names)
- Replace final streaming bubble with complete message including metadata
- Simplify header: just clock icon for history, no text
- Remove unused project selector code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants