Skip to main content

Universal SDK for interacting with AI Agent CLIs (Gemini, Copilot, etc.)

Project description

Agent CLI SDK

CI License: MIT Python 3.8+

Note: This project is currently in Technical Preview.

The agent-cli-sdk provides a universal, programmable interface for interacting with AI Agent CLIs like GitHub Copilot and Google Gemini.

By leveraging your local CLI tools as the "runtime engine," this SDK allows you to build sophisticated agentic applications while reusing existing authentication, session persistence, and local context without managing complex API keys or HTTP clients manually.

🚀 Key Features

  • Universal Agent Interface: Write your business logic once using UniversalAgent and switch between drivers (CopilotDriver, GeminiDriver, MockDriver) seamlessly.
  • CLI as a Runtime: Reuses local binary capabilities (auth, tool execution, context awareness).
  • Full Protocol Support:
    • GitHub Copilot: Full JSON-RPC support (LSP-style framing) with bidirectional tool execution.
    • Google Gemini: Robust CLI wrapper with streaming JSON event parsing.
  • ReAct Loop & Custom Tools: Register any Python function as a tool; the SDK handles the thought-action-observation loop automatically.
  • Stateful Sessions: Built-in support for capturing and resuming CLI session IDs across application restarts.

📦 Installation

pip install agent-cli-sdk

Ensure you have the corresponding CLI installed:

  • Gemini: brew install gemini-cli shoud be login
  • Copilot: brew install copilot-cli shoud be login

🛠 Quick Start

One logic, any engine. Here is how you run a simple chat with Gemini:

import asyncio
from agent_sdk.core.agent import UniversalAgent
from agent_sdk.drivers.gemini_driver import GeminiDriver

async def main():
    # 1. Choose your engine
    driver = GeminiDriver() 
    
    # 2. Initialize the Universal Agent
    agent = UniversalAgent(driver)

    # 3. Stream responses
    print("User: Explain quantum computing.")
    async for event in agent.stream("Explain quantum computing."):
        if event.type.name == "CONTENT":
            print(event.payload, end="", flush=True)

if __name__ == "__main__":
    asyncio.run(main())

🎮 Explore Universal Demos

We provide a Guided Launcher to explore all SDK capabilities across different drivers.

python3 examples/demo_launcher.py

The launcher will:

  1. Auto-detect your environment (checking if gemini or copilot is installed).
  2. Allow you to select a Driver Engine.
  3. Let you select a Task (Chat, Custom Tools, Session Persistence, etc.) to run on that engine.

🏗 Architecture

The SDK follows a modular "Driver-Controller" pattern:

  • UniversalAgent: The high-level controller. Manages message history, tool registration, and the ReAct execution loop.
  • AgentDriver: The abstraction layer.
    • CopilotDriver: Implements JSON-RPC 2.0 over Stdio (LSP framing). Supports server-side requests (the CLI asking the SDK to run a tool).
    • GeminiDriver: Implements the CLI wrapper pattern with -o stream-json support.
  • JsonRpcClient: A robust, async-first JSON-RPC client designed for high-concurrency CLI communication.

🧪 Development & Testing

We maintain a high-quality codebase with extensive test coverage.

  • Unit & Integration Tests: 100% pass rate across 29 core test cases.
  • Code Coverage: 82% (targeting 90%+).
  • Stability: Built-in execution timeouts and automated cleanup for subprocesses.

Running Tests

# Run all tests with coverage report
pytest --cov=src/agent_sdk tests/ --ignore=tests/e2e --cov-report=term-missing --timeout=5

E2E Testing

E2E tests require authenticated local CLIs:

# Run Gemini E2E
pytest tests/e2e/test_gemini_e2e.py

📄 License

Distributed under the MIT License. See LICENSE for more information.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agent_cli_sdk-0.1.0.tar.gz (35.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agent_cli_sdk-0.1.0-py3-none-any.whl (17.8 kB view details)

Uploaded Python 3

File details

Details for the file agent_cli_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: agent_cli_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 35.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for agent_cli_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 517581609e83c0758513d836fa5cbb299288faf0c81a16aa4c7cdc137053a464
MD5 56bdb3903da4f8988e92d371ff6823de
BLAKE2b-256 d1df7e888025b5c83971030ba570545625f96d88dda12f84c3d4c43d0b9bc62e

See more details on using hashes here.

File details

Details for the file agent_cli_sdk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: agent_cli_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for agent_cli_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3398176466de6487031fe5d126ada5d486e7938491d1631c3c12a76be7c6e54b
MD5 e78bf164d05ffb3a3e2f921f94b8fd64
BLAKE2b-256 b346e6298d9ba2cb45e5026da9383174bb8cd995f315ca9e1f870a7223433c25

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page