Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.1.0-alpha.5"
".": "0.1.0-alpha.6"
}
6 changes: 3 additions & 3 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 16
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-b4a3f35e4a44e5a5034508ced15d7b44c1924000062e0f5293797413d26ee412.yml
openapi_spec_hash: f17b1091020f90126e6cefc2d38ff85f
config_hash: 1156f6f6fb7245e7b021daddf23153e3
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-384a94f70b48c84af9eddcac72bbe12952c3ae3bd7fededfa1c63b203d12d828.yml
openapi_spec_hash: e47ad28d646736d5d79d2dd1086d517d
config_hash: e2d21e779cfc4e26a99b9e4e75de3f50
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 0.1.0-alpha.6 (2025-06-30)

Full Changelog: [v0.1.0-alpha.5...v0.1.0-alpha.6](https://github.com/sst/opencode-sdk-python/compare/v0.1.0-alpha.5...v0.1.0-alpha.6)

### Features

* **api:** update via SDK Studio ([e1cb382](https://github.com/sst/opencode-sdk-python/commit/e1cb382c5391eb135a31ad98c7301c061191c563))
* **api:** update via SDK Studio ([0985851](https://github.com/sst/opencode-sdk-python/commit/09858518e9312ca72238efd596cc0313927c26e3))

## 0.1.0-alpha.5 (2025-06-30)

Full Changelog: [v0.1.0-alpha.4...v0.1.0-alpha.5](https://github.com/sst/opencode-sdk-python/compare/v0.1.0-alpha.4...v0.1.0-alpha.5)
Expand Down
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,32 @@ async def main() -> None:
asyncio.run(main())
```

## Streaming responses

We provide support for streaming responses using Server Side Events (SSE).

```python
from opencode_ai import Opencode

client = Opencode()

stream = client.event.list()
for events in stream:
print(events)
```

The async client uses the exact same interface.

```python
from opencode_ai import AsyncOpencode

client = AsyncOpencode()

stream = await client.event.list()
async for events in stream:
print(events)
```

## Using types

Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typing.html#typing.TypedDict). Responses are [Pydantic models](https://docs.pydantic.dev) which also provide helper methods for things like:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "opencode-ai"
version = "0.1.0-alpha.5"
version = "0.1.0-alpha.6"
description = "The official Python library for the opencode API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down
4 changes: 4 additions & 0 deletions src/opencode_ai/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ def __init__(
_strict_response_validation=_strict_response_validation,
)

self._default_stream_cls = Stream

self.event = event.EventResource(self)
self.app = app.AppResource(self)
self.file = file.FileResource(self)
Expand Down Expand Up @@ -247,6 +249,8 @@ def __init__(
_strict_response_validation=_strict_response_validation,
)

self._default_stream_cls = AsyncStream

self.event = event.AsyncEventResource(self)
self.app = app.AsyncAppResource(self)
self.file = file.AsyncFileResource(self)
Expand Down
2 changes: 1 addition & 1 deletion src/opencode_ai/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

__title__ = "opencode_ai"
__version__ = "0.1.0-alpha.5" # x-release-please-version
__version__ = "0.1.0-alpha.6" # x-release-please-version
35 changes: 17 additions & 18 deletions src/opencode_ai/resources/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
async_to_raw_response_wrapper,
async_to_streamed_response_wrapper,
)
from .._streaming import Stream, AsyncStream
from .._base_client import make_request_options
from ..types.event_list_response import EventListResponse

Expand Down Expand Up @@ -50,17 +51,16 @@ def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> EventListResponse:
) -> Stream[EventListResponse]:
"""Get events"""
return cast(
EventListResponse,
self._get(
"/event",
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=cast(Any, EventListResponse), # Union types cannot be passed in as arguments in the type system
return self._get(
"/event",
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=cast(Any, EventListResponse), # Union types cannot be passed in as arguments in the type system
stream=True,
stream_cls=Stream[EventListResponse],
)


Expand Down Expand Up @@ -93,17 +93,16 @@ async def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> EventListResponse:
) -> AsyncStream[EventListResponse]:
"""Get events"""
return cast(
EventListResponse,
await self._get(
"/event",
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=cast(Any, EventListResponse), # Union types cannot be passed in as arguments in the type system
return await self._get(
"/event",
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=cast(Any, EventListResponse), # Union types cannot be passed in as arguments in the type system
stream=True,
stream_cls=AsyncStream[EventListResponse],
)


Expand Down
2 changes: 0 additions & 2 deletions src/opencode_ai/types/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ class App(BaseModel):

path: Path

project: str

time: Time

user: str
2 changes: 2 additions & 0 deletions src/opencode_ai/types/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ class ProviderModels(BaseModel):

reasoning: Optional[bool] = None

release_date: Optional[str] = None

temperature: Optional[bool] = None

tool_call: Optional[bool] = None
Expand Down
82 changes: 54 additions & 28 deletions src/opencode_ai/types/event_list_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@

__all__ = [
"EventListResponse",
"EventStorageWrite",
"EventStorageWriteProperties",
"EventInstallationUpdated",
"EventInstallationUpdatedProperties",
"EventLspClientDiagnostics",
"EventLspClientDiagnosticsProperties",
"EventPermissionUpdated",
"EventPermissionUpdatedProperties",
"EventPermissionUpdatedPropertiesTime",
"EventFileEdited",
"EventFileEditedProperties",
"EventStorageWrite",
"EventStorageWriteProperties",
"EventInstallationUpdated",
"EventInstallationUpdatedProperties",
"EventMessageUpdated",
"EventMessageUpdatedProperties",
"EventMessagePartUpdated",
Expand All @@ -32,35 +34,15 @@
"EventSessionUpdatedProperties",
"EventSessionDeleted",
"EventSessionDeletedProperties",
"EventSessionIdle",
"EventSessionIdleProperties",
"EventSessionError",
"EventSessionErrorProperties",
"EventSessionErrorPropertiesError",
"EventSessionErrorPropertiesErrorMessageOutputLengthError",
]


class EventStorageWriteProperties(BaseModel):
key: str

content: Optional[object] = None


class EventStorageWrite(BaseModel):
properties: EventStorageWriteProperties

type: Literal["storage.write"]


class EventInstallationUpdatedProperties(BaseModel):
version: str


class EventInstallationUpdated(BaseModel):
properties: EventInstallationUpdatedProperties

type: Literal["installation.updated"]


class EventLspClientDiagnosticsProperties(BaseModel):
path: str

Expand Down Expand Up @@ -95,6 +77,38 @@ class EventPermissionUpdated(BaseModel):
type: Literal["permission.updated"]


class EventFileEditedProperties(BaseModel):
file: str


class EventFileEdited(BaseModel):
properties: EventFileEditedProperties

type: Literal["file.edited"]


class EventStorageWriteProperties(BaseModel):
key: str

content: Optional[object] = None


class EventStorageWrite(BaseModel):
properties: EventStorageWriteProperties

type: Literal["storage.write"]


class EventInstallationUpdatedProperties(BaseModel):
version: str


class EventInstallationUpdated(BaseModel):
properties: EventInstallationUpdatedProperties

type: Literal["installation.updated"]


class EventMessageUpdatedProperties(BaseModel):
info: Message

Expand Down Expand Up @@ -139,6 +153,16 @@ class EventSessionDeleted(BaseModel):
type: Literal["session.deleted"]


class EventSessionIdleProperties(BaseModel):
session_id: str = FieldInfo(alias="sessionID")


class EventSessionIdle(BaseModel):
properties: EventSessionIdleProperties

type: Literal["session.idle"]


class EventSessionErrorPropertiesErrorMessageOutputLengthError(BaseModel):
data: object

Expand All @@ -163,14 +187,16 @@ class EventSessionError(BaseModel):

EventListResponse: TypeAlias = Annotated[
Union[
EventStorageWrite,
EventInstallationUpdated,
EventLspClientDiagnostics,
EventPermissionUpdated,
EventFileEdited,
EventStorageWrite,
EventInstallationUpdated,
EventMessageUpdated,
EventMessagePartUpdated,
EventSessionUpdated,
EventSessionDeleted,
EventSessionIdle,
EventSessionError,
],
PropertyInfo(discriminator="type"),
Expand Down
3 changes: 3 additions & 0 deletions src/opencode_ai/types/mcp_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@ class McpLocal(BaseModel):
type: Literal["local"]
"""Type of MCP server connection"""

enabled: Optional[bool] = None
"""Enable or disable the MCP server on startup"""

environment: Optional[Dict[str, str]] = None
"""Environment variables to set when running the MCP server"""
4 changes: 4 additions & 0 deletions src/opencode_ai/types/mcp_remote.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing import Optional
from typing_extensions import Literal

from .._models import BaseModel
Expand All @@ -13,3 +14,6 @@ class McpRemote(BaseModel):

url: str
"""URL of the remote MCP server"""

enabled: Optional[bool] = None
"""Enable or disable the MCP server on startup"""
2 changes: 2 additions & 0 deletions src/opencode_ai/types/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class Model(BaseModel):

reasoning: bool

release_date: str

temperature: bool

tool_call: bool
Loading