Skip to content

Commit 72946d6

Browse files
committed
feat: Implement Rust Copilot SDK with JSON-RPC support
- Add error handling module for SDK operations. - Create generated module for session events. - Define session event types for communication. - Implement JSON-RPC client for bidirectional communication. - Add session management for interactive conversations. - Introduce tool system for defining and handling custom tools. - Define core types for the Copilot SDK, including client options and system messages. - Add tests for JSON-RPC functionality, tool system, and core types.
1 parent 1f06cf5 commit 72946d6

22 files changed

Lines changed: 2460 additions & 3 deletions

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ The GitHub Copilot SDK exposes the same engine behind Copilot CLI: a production-
1616
| **Python** | [`cookbook/python/`](./cookbook/python/README.md) | `pip install github-copilot-sdk` |
1717
| **Go** | [`cookbook/go/`](./cookbook/go/README.md) | `go get github.com/github/copilot-sdk/go` |
1818
| **.NET** | [`cookbook/dotnet/`](./cookbook/dotnet/README.md) | `dotnet add package GitHub.Copilot.SDK` |
19+
| **Rust** | [`rust/`](./rust/README.md) | `cargo add github-copilot-sdk` |
1920

2021
See the individual SDK READMEs for installation, usage examples, and API reference.
2122

justfile

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ default:
33
@just --list
44

55
# Format all code across all languages
6-
format: format-go format-python format-nodejs format-dotnet
6+
format: format-go format-python format-nodejs format-dotnet format-rust
77

88
# Lint all code across all languages
9-
lint: lint-go lint-python lint-nodejs lint-dotnet
9+
lint: lint-go lint-python lint-nodejs lint-dotnet lint-rust
1010

1111
# Run tests for all languages
12-
test: test-go test-python test-nodejs test-dotnet
12+
test: test-go test-python test-nodejs test-dotnet test-rust
1313

1414
# Format Go code
1515
format-go:
@@ -71,13 +71,29 @@ test-dotnet:
7171
@echo "=== Testing .NET code ==="
7272
@cd dotnet && dotnet test test/GitHub.Copilot.SDK.Test.csproj
7373

74+
# Format Rust code
75+
format-rust:
76+
@echo "=== Formatting Rust code ==="
77+
@cd rust && cargo fmt
78+
79+
# Lint Rust code
80+
lint-rust:
81+
@echo "=== Linting Rust code ==="
82+
@cd rust && cargo clippy --all-targets -- -D warnings
83+
84+
# Test Rust code
85+
test-rust:
86+
@echo "=== Testing Rust code ==="
87+
@cd rust && cargo test
88+
7489
# Install all dependencies
7590
install:
7691
@echo "=== Installing dependencies ==="
7792
@cd nodejs && npm ci
7893
@cd python && uv pip install -e ".[dev]"
7994
@cd go && go mod download
8095
@cd dotnet && dotnet restore
96+
@cd rust && cargo fetch
8197
@echo "✅ All dependencies installed"
8298

8399
# Run interactive SDK playground

rust/.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Rust
2+
/target
3+
Cargo.lock
4+
**/*.rs.bk
5+
*.pdb
6+
7+
# IDE
8+
.vscode/
9+
.idea/
10+
*.swp
11+
*.swo
12+
*~
13+
14+
# OS
15+
.DS_Store
16+
Thumbs.db

rust/Cargo.toml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
[package]
2+
name = "github-copilot-sdk"
3+
version = "0.1.0"
4+
edition = "2021"
5+
authors = ["GitHub <opensource+copilot-sdk@github.com>"]
6+
description = "GitHub Copilot SDK for Rust - Embed Copilot's agentic workflows in your application"
7+
license = "MIT"
8+
repository = "https://github.com/github/copilot-sdk"
9+
homepage = "https://github.com/github/copilot-sdk"
10+
documentation = "https://docs.rs/github-copilot-sdk"
11+
readme = "README.md"
12+
keywords = ["github", "copilot", "ai", "agent", "sdk"]
13+
categories = ["api-bindings", "development-tools"]
14+
15+
[dependencies]
16+
tokio = { version = "1.41", features = ["full"] }
17+
serde = { version = "1.0", features = ["derive"] }
18+
serde_json = "1.0"
19+
uuid = { version = "1.11", features = ["v4", "serde"] }
20+
thiserror = "2.0"
21+
async-trait = "0.1"
22+
23+
[dev-dependencies]
24+
tokio-test = "0.4"
25+
chrono = "0.4"
26+
27+
[lib]
28+
name = "github_copilot_sdk"
29+
path = "src/lib.rs"
30+
31+
[[example]]
32+
name = "hello"
33+
path = "examples/hello.rs"
34+
35+
[[example]]
36+
name = "tools"
37+
path = "examples/tools.rs"
38+
39+
[[example]]
40+
name = "permissions"
41+
path = "examples/permissions.rs"
42+
43+
[[example]]
44+
name = "mcp"
45+
path = "examples/mcp.rs"

0 commit comments

Comments
 (0)