Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 8, 2025

This PR implements a REST API server that allows AI agents and external tools to interact with Zephyr IDE functionality programmatically. The API provides endpoints for project management, build operations, flashing, and workspace configuration access.

Features

API Server

  • HTTP server using Node.js built-in modules (no additional dependencies)
  • Configurable port and optional API key authentication
  • CORS support for web-based clients
  • Automatic start/stop with extension lifecycle

Configuration Options

New VS Code settings added:

  • zephyr-ide.api_server_enabled - Enable/disable the API server
  • zephyr-ide.api_server_port - Configure server port (default: 8080)
  • zephyr-ide.api_server_key - Optional API key for authentication

API Endpoints

  • GET /api/status - Extension and workspace status
  • GET /api/projects - List all projects and their build configurations
  • POST /api/projects - Create new projects (initiates interactive process)
  • GET /api/projects/{name}/builds - Get build configurations for a project
  • POST /api/projects/{name}/builds - Add build configurations
  • POST /api/build - Trigger builds with optional project/build selection
  • POST /api/flash - Flash firmware to target devices
  • GET /api/workspace/config - Get sanitized workspace configuration

Security

  • Optional API key authentication via X-API-Key or Authorization headers
  • Server binds to localhost only by default
  • Sanitized responses to prevent sensitive data exposure

Documentation and Examples

  • Complete API documentation in docs/API.md
  • Python client example (examples/api-client.py) for AI agent integration
  • Bash testing script (examples/test-api.sh) for endpoint validation
  • Unit tests for API server functionality

Usage Example

import requests

# Configure API client
headers = {"X-API-Key": "your-api-key"}
api_base = "http://localhost:8080/api"

# Get extension status
status = requests.get(f"{api_base}/status", headers=headers).json()
print(f"Zephyr IDE version: {status['data']['version']}")

# Build active project
build_result = requests.post(f"{api_base}/build", 
                           json={"pristine": False}, 
                           headers=headers).json()

Integration

The API server integrates seamlessly with existing Zephyr IDE functionality:

  • Wraps existing command implementations
  • Updates automatically when workspace configuration changes
  • Maintains consistency with VS Code UI operations
  • Provides same functionality as interactive commands

This enables AI agents to automate Zephyr development workflows, perform automated builds, manage projects, and integrate with CI/CD pipelines while maintaining the same reliability and feature set as the interactive extension.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • update.code.visualstudio.com
    • Triggering command: node /home/REDACTED/work/zephyr-ide/zephyr-ide/node_modules/.bin/vscode-test (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits August 8, 2025 16:07
Co-authored-by: rijesha <7819200+rijesha@users.noreply.github.com>
Co-authored-by: rijesha <7819200+rijesha@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] I would like to add an IPC agent or rest api to expose the zephyr-ide functions to AI agents. Add REST API server for AI agent integration Aug 8, 2025
@Copilot Copilot AI requested a review from rijesha August 8, 2025 16:10
Copilot finished work on behalf of rijesha August 8, 2025 16:10
@rijesha rijesha deleted the branch main August 14, 2025 00:08
@rijesha rijesha closed this Aug 14, 2025
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