[PR #65] [MERGED] feat: Add Droid (Factory.ai) provider support #254

Closed
opened 2026-02-27 07:18:42 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/justlovemaki/AIClient-2-API/pull/65
Author: @bee4come
Created: 10/15/2025
Status: Merged
Merged: 10/15/2025
Merged by: @justlovemaki

Base: mainHead: feature/add-droid-provider


📝 Commits (3)

  • 903c417 Add Droid (Factory.ai) provider support
  • b28004b feat: improve Droid provider implementation and configuration
  • 17ec64b fix: improve droid provider with context isolation and message parsing

📊 Changes

11 files changed (+710 additions, -5 deletions)

View changed files

📝 README.md (+19 -2)
📝 config.json.example (+2 -0)
📝 package-lock.json (+1 -1)
📝 provider_pools.json.example (+13 -0)
📝 src/adapter.js (+44 -0)
📝 src/common.js (+11 -2)
src/droid/README.md (+227 -0)
src/droid/droid-core.js (+257 -0)
src/droid/droid-strategy.js (+74 -0)
📝 src/provider-strategies.js (+3 -0)
test-droid.js (+59 -0)

📄 Description

Summary

This PR adds support for Factory.ai's Droid CLI as a new provider in the AIClient-2-API project, enabling OpenAI-compatible API access to Droid.

Changes

Core Implementation

  • src/droid/droid-core.js: Core service that wraps the Droid CLI

    • Executes droid exec commands with proper flags
    • Handles both streaming and non-streaming responses
    • Includes context isolation to prevent directory context leakage
    • Supports message format conversion (OpenAI ↔ Claude)
  • src/droid/droid-strategy.js: Strategy pattern implementation for Droid protocol

    • Extends Claude protocol strategy (Droid uses Claude-compatible API)
    • Handles request/response transformations
  • src/droid/README.md: Comprehensive documentation

    • Usage examples
    • Configuration guide
    • Troubleshooting tips

Integration

  • src/adapter.js: Added DroidApiServiceAdapter to adapter factory
  • src/common.js: Added Droid constants and protocol mapping (droid → claude)
  • src/provider-strategies.js: Registered DroidStrategy in strategy factory
  • README.md: Updated main documentation with Droid provider section

Key Features

OpenAI-Compatible API

  • /v1/chat/completions endpoint
  • /v1/models endpoint
  • Streaming and non-streaming support

Context Isolation

  • Uses --cwd flag to run Droid in isolated temp directory
  • Prevents project context from leaking into responses

Message Format Support

  • Handles both string and array content formats
  • Proper conversion between OpenAI and Claude formats

Security

  • Uses --skip-permissions-unsafe flag for non-interactive execution
  • Tested against prompt injection attacks (all blocked successfully)

Testing

All functionality has been tested and verified:

# Start API server
node src/api-server.js --model-provider droid-factory-oauth --port 3001 --api-key test-key

# Test basic request
curl http://localhost:3001/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer test-key" \
  -d '{
    "model": "claude-sonnet-4-5-20250929",
    "messages": [
      {"role": "user", "content": "What is 2+2?"}
    ]
  }'

Test Results

API requests work correctly
Context isolation verified
Message parsing handles all formats
Security: Prompt injection attacks blocked
Response format matches OpenAI spec

Configuration

Add to your config:

{
  "providers": [
    {
      "provider": "droid-factory-oauth",
      "models": ["claude-sonnet-4-5-20250929"]
    }
  ]
}

Prerequisites

Breaking Changes

None. This is a new feature addition.

N/A - New feature implementation


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/justlovemaki/AIClient-2-API/pull/65 **Author:** [@bee4come](https://github.com/bee4come) **Created:** 10/15/2025 **Status:** ✅ Merged **Merged:** 10/15/2025 **Merged by:** [@justlovemaki](https://github.com/justlovemaki) **Base:** `main` ← **Head:** `feature/add-droid-provider` --- ### 📝 Commits (3) - [`903c417`](https://github.com/justlovemaki/AIClient-2-API/commit/903c417c4ac45e3531e5d9892ccb276b9876e6ea) Add Droid (Factory.ai) provider support - [`b28004b`](https://github.com/justlovemaki/AIClient-2-API/commit/b28004b4e26923d23a13cc5e72dbb14d6a9d0245) feat: improve Droid provider implementation and configuration - [`17ec64b`](https://github.com/justlovemaki/AIClient-2-API/commit/17ec64b8630b6f5792e970bac7f3725b254ff5d1) fix: improve droid provider with context isolation and message parsing ### 📊 Changes **11 files changed** (+710 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+19 -2) 📝 `config.json.example` (+2 -0) 📝 `package-lock.json` (+1 -1) 📝 `provider_pools.json.example` (+13 -0) 📝 `src/adapter.js` (+44 -0) 📝 `src/common.js` (+11 -2) ➕ `src/droid/README.md` (+227 -0) ➕ `src/droid/droid-core.js` (+257 -0) ➕ `src/droid/droid-strategy.js` (+74 -0) 📝 `src/provider-strategies.js` (+3 -0) ➕ `test-droid.js` (+59 -0) </details> ### 📄 Description ## Summary This PR adds support for Factory.ai's Droid CLI as a new provider in the AIClient-2-API project, enabling OpenAI-compatible API access to Droid. ## Changes ### Core Implementation - **`src/droid/droid-core.js`**: Core service that wraps the Droid CLI - Executes `droid exec` commands with proper flags - Handles both streaming and non-streaming responses - Includes context isolation to prevent directory context leakage - Supports message format conversion (OpenAI ↔ Claude) - **`src/droid/droid-strategy.js`**: Strategy pattern implementation for Droid protocol - Extends Claude protocol strategy (Droid uses Claude-compatible API) - Handles request/response transformations - **`src/droid/README.md`**: Comprehensive documentation - Usage examples - Configuration guide - Troubleshooting tips ### Integration - **`src/adapter.js`**: Added `DroidApiServiceAdapter` to adapter factory - **`src/common.js`**: Added Droid constants and protocol mapping (droid → claude) - **`src/provider-strategies.js`**: Registered `DroidStrategy` in strategy factory - **`README.md`**: Updated main documentation with Droid provider section ## Key Features ✅ **OpenAI-Compatible API** - `/v1/chat/completions` endpoint - `/v1/models` endpoint - Streaming and non-streaming support ✅ **Context Isolation** - Uses `--cwd` flag to run Droid in isolated temp directory - Prevents project context from leaking into responses ✅ **Message Format Support** - Handles both string and array content formats - Proper conversion between OpenAI and Claude formats ✅ **Security** - Uses `--skip-permissions-unsafe` flag for non-interactive execution - Tested against prompt injection attacks (all blocked successfully) ## Testing All functionality has been tested and verified: ```bash # Start API server node src/api-server.js --model-provider droid-factory-oauth --port 3001 --api-key test-key # Test basic request curl http://localhost:3001/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer test-key" \ -d '{ "model": "claude-sonnet-4-5-20250929", "messages": [ {"role": "user", "content": "What is 2+2?"} ] }' ``` ### Test Results ✅ API requests work correctly ✅ Context isolation verified ✅ Message parsing handles all formats ✅ Security: Prompt injection attacks blocked ✅ Response format matches OpenAI spec ## Configuration Add to your config: ```json { "providers": [ { "provider": "droid-factory-oauth", "models": ["claude-sonnet-4-5-20250929"] } ] } ``` ## Prerequisites - Droid CLI must be installed and authenticated - Install from: https://factory.ai/product/cli ## Breaking Changes None. This is a new feature addition. ## Related Issues N/A - New feature implementation --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 07:18:42 +03:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/AIClient-2-API-justlovemaki#254
No description provided.