[PR #8688] feat(sdk): add Python SDK with full JS SDK v2 feature parity #12830

Closed
opened 2026-02-16 18:17:43 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/8688

State: closed
Merged: No


Fixes #4031
Closes #2266

Summary

  • Add Python SDK for OpenCode API with full feature parity to JS SDK v2
  • Implement all 28 API classes matching JS SDK structure
  • Add comprehensive type hints using TypedDict
  • Support both sync and async APIs
  • Include SSE support for real-time event streaming

Key Features

  • Full API Coverage: All endpoints from JS SDK v2 implemented
  • Type Safety: Complete type hints for all methods and responses
  • Dual API: Both synchronous and asynchronous methods (method() / method_async())
  • Server Management: create_opencode_server() and create_opencode_tui() helpers
  • Config Support: Full Config TypedDict with tools, agents, commands, MCP servers

Files Added

  • opencode_sdk/ - Main SDK package
  • tests/ - Comprehensive test suite (204 tests)
  • example/example.py - Usage examples
  • scripts/publish.py - PyPI publish script
  • README.md - Documentation with examples

Optional Parameters Added (matching JS SDK v2)

  • session.summarize: auto parameter
  • session.prompt: variant parameter
  • session.prompt_async_fire: variant parameter
  • session.command: variant and parts parameters
  • find.files: type and limit parameters

Test plan

  • All 204 unit tests passing
  • Type checking with mypy
  • Linting with ruff

🤖 Generated with Claude Code

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/8688 **State:** closed **Merged:** No --- Fixes #4031 Closes #2266 ## Summary - Add Python SDK for OpenCode API with full feature parity to JS SDK v2 - Implement all 28 API classes matching JS SDK structure - Add comprehensive type hints using TypedDict - Support both sync and async APIs - Include SSE support for real-time event streaming ### Key Features - **Full API Coverage**: All endpoints from JS SDK v2 implemented - **Type Safety**: Complete type hints for all methods and responses - **Dual API**: Both synchronous and asynchronous methods (`method()` / `method_async()`) - **Server Management**: `create_opencode_server()` and `create_opencode_tui()` helpers - **Config Support**: Full Config TypedDict with tools, agents, commands, MCP servers ### Files Added - `opencode_sdk/` - Main SDK package - `tests/` - Comprehensive test suite (204 tests) - `example/example.py` - Usage examples - `scripts/publish.py` - PyPI publish script - `README.md` - Documentation with examples ### Optional Parameters Added (matching JS SDK v2) - `session.summarize`: `auto` parameter - `session.prompt`: `variant` parameter - `session.prompt_async_fire`: `variant` parameter - `session.command`: `variant` and `parts` parameters - `find.files`: `type` and `limit` parameters ## Test plan - [x] All 204 unit tests passing - [x] Type checking with mypy - [x] Linting with ruff 🤖 Generated with [Claude Code](https://claude.com/claude-code)
yindo added the pull-request label 2026-02-16 18:17:43 -05:00
yindo closed this issue 2026-02-16 18:17:43 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12830