Skip to content

Add Rust SDK variant following Go SDK pattern - #1

Open
erezak with Copilot wants to merge 2 commits into
mainfrom
copilot/add-rust-sdk-variant
Open

Add Rust SDK variant following Go SDK pattern#1
erezak with Copilot wants to merge 2 commits into
mainfrom
copilot/add-rust-sdk-variant

Conversation

Copilot AI commented Jan 24, 2026

Copy link
Copy Markdown

Adds a complete Rust SDK for programmatic access to the GitHub Copilot CLI.

Core Implementation

  • rust/src/client.rs - Client struct managing CLI process lifecycle, session creation, tool call handling
  • rust/src/session.rs - Session struct with event subscription, message sending, tool registration
  • rust/src/jsonrpc.rs - JSON-RPC 2.0 client for stdio transport
  • rust/src/types.rs - All data types (ClientOptions, SessionConfig, Tool, SessionEvent, etc.)

Build & Docs

  • Cargo.toml with tokio, serde, uuid dependencies
  • README with API reference and usage examples
  • Cookbook scaffold at cookbook/rust/
  • Updated root README and justfile with Rust targets

Usage

use copilot_sdk::{Client, SessionConfig, MessageOptions, SessionEventType};
use std::sync::Arc;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new(None);
    client.start().await?;

    let session = client.create_session(Some(SessionConfig {
        model: Some("gpt-5".to_string()),
        ..Default::default()
    })).await?;

    session.on(Arc::new(|event| {
        if event.event_type == SessionEventType::AssistantMessage {
            println!("{}", event.data.content.unwrap_or_default());
        }
    })).await;

    session.send(MessageOptions {
        prompt: "Hello!".to_string(),
        ..Default::default()
    }).await?;

    Ok(())
}
Original prompt

Add a Rust SDK variant, following the example of the Go SDK


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: erezak <406695+erezak@users.noreply.github.com>
Copilot AI changed the title [WIP] Add Rust SDK variant following Go SDK example Add Rust SDK variant following Go SDK pattern Jan 24, 2026
Copilot AI requested a review from erezak January 24, 2026 22:26
@erezak
erezak marked this pull request as ready for review January 24, 2026 22:32
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