3.2 KiB
3.2 KiB
AI API & Agentic Workflow Enhancement - Phase 2 Handoff
Date: 2025-11-20
Status: Phase 2 Implementation Complete
Previous Plan: docs/internal/AI_API_ENHANCEMENT_HANDOFF.md
Overview
This handoff covers the completion of Phase 2, which focused on unifying the UI for model selection and implementing the initial HTTP API server foundation. The codebase is now ready for building and verifying the API endpoints.
Completed Work
1. UI Unification (src/app/editor/agent/agent_chat_widget.cc)
- Unified Model List: Replaced the separate Ollama/Gemini list logic with a single, unified list derived from
ModelRegistry. - Provider Badges: Models in the list now display their provider (e.g.,
[ollama],[gemini]). - Contextual Configuration:
- If an Ollama model is selected, the "Ollama Host" input is displayed.
- If a Gemini model is selected, the "API Key" input is displayed.
- Favorites & Presets: Updated to work with the unified
ModelInfostructure.
2. HTTP Server Implementation (src/cli/service/api/)
HttpServerClass:- Wraps
httplib::Serverrunning in a backgroundstd::thread. - Exposed via
Start(port)andStop()methods. - Graceful shutdown handling.
- Wraps
- API Handlers:
GET /api/v1/health: Returns server status (JSON).GET /api/v1/models: Returns list of available models fromModelRegistry.
- Integration:
- Updated
src/cli/agent.cmaketo includehttp_server.cc,api_handlers.cc, andmodel_registry.cc. - Updated
src/app/main.ccto accept--enable_apiand--api_portflags.
- Updated
Build & Test Instructions
1. Building
The project uses CMake. The new files are automatically included in the yaze_agent library via src/cli/agent.cmake.
# Generate build files (if not already done)
cmake -B build -G Ninja
# Build the main application
cmake --build build --target yaze_app
2. Testing the UI
- Launch the editor:
./build/yaze_app --editor=Agent - Verify the Model Configuration panel:
- You should see a single list of models.
- Try searching for a model.
- Select an Ollama model -> Verify "Host" input appears.
- Select a Gemini model -> Verify "API Key" input appears.
3. Testing the API
-
Launch the editor with API enabled:
./build/yaze_app --enable_api --api_port=8080(Check logs for "Starting API server on port 8080")
-
Test Health Endpoint:
curl -v http://localhost:8080/api/v1/health # Expected: {"status":"ok", "version":"1.0", ...} -
Test Models Endpoint:
curl -v http://localhost:8080/api/v1/models # Expected: {"models": [{"name": "...", "provider": "..."}], "count": ...}
Next Steps (Phase 3 & 4)
Phase 3: Tool Expansion
- FileSystemTool: Implement safe file read/write operations (
src/cli/handlers/tools/filesystem_commands.h). - BuildTool: Implement cmake/ninja triggers.
- Editor Integration: Inject editor state (open files, errors) into the agent context.
Phase 4: Structured Output
- Refactor
ToolDispatcherto return JSON objects instead of capturing stdout strings. - Update API to expose a
/api/v1/chatendpoint that returns these structured responses.