Conversation
Add Rust language support to the Copilot SDK repository with: - CopilotClient for process spawning and connection management (stdio/TCP) - CopilotSession for event subscriptions and message handling - JSON-RPC 2.0 client with Content-Length framing - Tool definition system using schemars for JSON Schema generation - Session event types matching other SDK implementations - E2E test harness and basic example - README with usage documentation Update justfile with format-rust, lint-rust, test-rust targets. Update repository README and CONTRIBUTING docs.
BREAKING CHANGES: - CopilotClient::new() now returns Result<Self, CopilotError> - SessionEventHandler now takes Arc<SessionEvent> instead of SessionEvent Fixes: - Add MAX_MESSAGE_SIZE (100MB) limit to prevent DoS via Content-Length - Remove panics on invalid user input, return errors instead - Replace block_on() calls with proper async handling - Add bounded task spawning with semaphore (limit 100) - Fix destroy()/dispatch_event() race condition with AtomicBool - Remove dead code (response_write_tx field) Also adds comprehensive documentation to all public types.
Add automatic reconnection when the CLI process exits or the connection is lost. This matches the behavior of the NodeJS SDK. Changes: - Add disconnect callback to JsonRpcClient that fires when read loop exits - Add start_arc() method for Arc-wrapped clients with auto-reconnect - Add reconnect logic that stops and restarts the connection - Add session invalidation to notify handlers of connection loss - Sessions receive SessionError events when connection is lost The implementation uses a channel-based approach to decouple the sync disconnect callback from async reconnection handling, ensuring all futures remain Send-safe for tokio::spawn.
|
Thanks for offering to contribute this, @solatticus! Sorry we didn't previously clarify this, but currently we are not accepting additional language SDKs in this repo. We're evolving both Copilot CLI and its SDK extremely quickly right now, and don't have capacity to let the number of languages we maintain grow beyond the existing four. This might change in the future but we've decided to lock it to the four languages we see most demand for in the short term (JS/TS on Node, Python, Go, and C#). Instead, would you be interested in maintaining a Rust Copilot SDK as an external project? If so, we'd love to link to it from our docs. (Sidenote: to clarify this in the future, I've filed #68) |
|
Fair enough! Thanks for the clarification. I'll leave it up, but can't make any maintenance promises! cheers |
Rust SDK for the Copilot CLI
I'm sure there's plenty to improve or replace, but just to get the ball rolling ->
schemarsFiles Added
Usage
Testing
cargo build- compiles successfullycargo test- all unit tests passcargo clippy -- -D warnings- no warnings