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.9"
".": "0.1.0-alpha.10"
}
6 changes: 3 additions & 3 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 20
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-945f9da9e9a4c4008834deef63e4346c0076e020eed3d3c98c249095033c1ac5.yml
openapi_spec_hash: 522a44f6cb0677435fe2ac7693848ad7
config_hash: 6c8822d278ba83456e5eed6d774ca230
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-15eeb028f79b9a065b4e54a6ea6a58631e9bd5004f97820f0c79d18e3f8bac84.yml
openapi_spec_hash: 38c8bacb6c8e4c46852a3e81e3fb9fda
config_hash: 348a85e725de595ca05a61f4333794ac
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 0.1.0-alpha.10 (2025-07-06)

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

### Features

* **api:** manual updates ([fdab2a9](https://github.com/sst/opencode-sdk-python/commit/fdab2a9ee5b71d90b1c18c00f67e40247efae0e4))

## 0.1.0-alpha.9 (2025-07-05)

Full Changelog: [v0.1.0-alpha.8...v0.1.0-alpha.9](https://github.com/sst/opencode-sdk-python/compare/v0.1.0-alpha.8...v0.1.0-alpha.9)
Expand Down
17 changes: 9 additions & 8 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,19 @@ Types:

```python
from opencode_ai.types import (
AssistantMessage,
AssistantMessagePart,
FilePart,
Message,
MessagePart,
ReasoningPart,
Session,
SourceURLPart,
StepStartPart,
TextPart,
ToolCall,
ToolInvocationPart,
ToolPartialCall,
ToolResult,
ToolPart,
ToolStateCompleted,
ToolStateError,
ToolStatePending,
ToolStateRunning,
UserMessagePart,
SessionListResponse,
SessionDeleteResponse,
SessionAbortResponse,
Expand All @@ -110,7 +111,7 @@ Methods:
- <code title="get /session">client.session.<a href="./src/opencode_ai/resources/session.py">list</a>() -> <a href="./src/opencode_ai/types/session_list_response.py">SessionListResponse</a></code>
- <code title="delete /session/{id}">client.session.<a href="./src/opencode_ai/resources/session.py">delete</a>(id) -> <a href="./src/opencode_ai/types/session_delete_response.py">SessionDeleteResponse</a></code>
- <code title="post /session/{id}/abort">client.session.<a href="./src/opencode_ai/resources/session.py">abort</a>(id) -> <a href="./src/opencode_ai/types/session_abort_response.py">SessionAbortResponse</a></code>
- <code title="post /session/{id}/message">client.session.<a href="./src/opencode_ai/resources/session.py">chat</a>(id, \*\*<a href="src/opencode_ai/types/session_chat_params.py">params</a>) -> <a href="./src/opencode_ai/types/message.py">Message</a></code>
- <code title="post /session/{id}/message">client.session.<a href="./src/opencode_ai/resources/session.py">chat</a>(id, \*\*<a href="src/opencode_ai/types/session_chat_params.py">params</a>) -> <a href="./src/opencode_ai/types/assistant_message.py">AssistantMessage</a></code>
- <code title="post /session/{id}/init">client.session.<a href="./src/opencode_ai/resources/session.py">init</a>(id, \*\*<a href="src/opencode_ai/types/session_init_params.py">params</a>) -> <a href="./src/opencode_ai/types/session_init_response.py">SessionInitResponse</a></code>
- <code title="get /session/{id}/message">client.session.<a href="./src/opencode_ai/resources/session.py">messages</a>(id) -> <a href="./src/opencode_ai/types/session_messages_response.py">SessionMessagesResponse</a></code>
- <code title="post /session/{id}/share">client.session.<a href="./src/opencode_ai/resources/session.py">share</a>(id) -> <a href="./src/opencode_ai/types/session.py">Session</a></code>
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.9"
version = "0.1.0-alpha.10"
description = "The official Python library for the opencode API"
dynamic = ["readme"]
license = "Apache-2.0"
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.9" # x-release-please-version
__version__ = "0.1.0-alpha.10" # x-release-please-version
16 changes: 8 additions & 8 deletions src/opencode_ai/resources/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
async_to_streamed_response_wrapper,
)
from .._base_client import make_request_options
from ..types.message import Message
from ..types.session import Session
from ..types.message_part_param import MessagePartParam
from ..types.assistant_message import AssistantMessage
from ..types.session_init_response import SessionInitResponse
from ..types.session_list_response import SessionListResponse
from ..types.session_abort_response import SessionAbortResponse
from ..types.session_delete_response import SessionDeleteResponse
from ..types.user_message_part_param import UserMessagePartParam
from ..types.session_messages_response import SessionMessagesResponse
from ..types.session_summarize_response import SessionSummarizeResponse

Expand Down Expand Up @@ -160,15 +160,15 @@ def chat(
id: str,
*,
model_id: str,
parts: Iterable[MessagePartParam],
parts: Iterable[UserMessagePartParam],
provider_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Message:
) -> AssistantMessage:
"""
Create and send a new message to a session

Expand Down Expand Up @@ -198,7 +198,7 @@ def chat(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=Message,
cast_to=AssistantMessage,
)

def init(
Expand Down Expand Up @@ -520,15 +520,15 @@ async def chat(
id: str,
*,
model_id: str,
parts: Iterable[MessagePartParam],
parts: Iterable[UserMessagePartParam],
provider_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Message:
) -> AssistantMessage:
"""
Create and send a new message to a session

Expand Down Expand Up @@ -558,7 +558,7 @@ async def chat(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=Message,
cast_to=AssistantMessage,
)

async def init(
Expand Down
24 changes: 9 additions & 15 deletions src/opencode_ai/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,43 +13,37 @@
from .file_part import FilePart as FilePart
from .mcp_local import McpLocal as McpLocal
from .text_part import TextPart as TextPart
from .tool_call import ToolCall as ToolCall
from .tool_part import ToolPart as ToolPart
from .mcp_remote import McpRemote as McpRemote
from .tool_result import ToolResult as ToolResult
from .message_part import MessagePart as MessagePart
from .reasoning_part import ReasoningPart as ReasoningPart
from .file_part_param import FilePartParam as FilePartParam
from .source_url_part import SourceURLPart as SourceURLPart
from .step_start_part import StepStartPart as StepStartPart
from .text_part_param import TextPartParam as TextPartParam
from .tool_call_param import ToolCallParam as ToolCallParam
from .file_read_params import FileReadParams as FileReadParams
from .find_text_params import FindTextParams as FindTextParams
from .tool_state_error import ToolStateError as ToolStateError
from .app_init_response import AppInitResponse as AppInitResponse
from .assistant_message import AssistantMessage as AssistantMessage
from .find_files_params import FindFilesParams as FindFilesParams
from .tool_partial_call import ToolPartialCall as ToolPartialCall
from .tool_result_param import ToolResultParam as ToolResultParam
from .user_message_part import UserMessagePart as UserMessagePart
from .file_read_response import FileReadResponse as FileReadResponse
from .find_text_response import FindTextResponse as FindTextResponse
from .message_part_param import MessagePartParam as MessagePartParam
from .tool_state_pending import ToolStatePending as ToolStatePending
from .tool_state_running import ToolStateRunning as ToolStateRunning
from .event_list_response import EventListResponse as EventListResponse
from .find_files_response import FindFilesResponse as FindFilesResponse
from .find_symbols_params import FindSymbolsParams as FindSymbolsParams
from .session_chat_params import SessionChatParams as SessionChatParams
from .session_init_params import SessionInitParams as SessionInitParams
from .file_status_response import FileStatusResponse as FileStatusResponse
from .reasoning_part_param import ReasoningPartParam as ReasoningPartParam
from .tool_invocation_part import ToolInvocationPart as ToolInvocationPart
from .tool_state_completed import ToolStateCompleted as ToolStateCompleted
from .find_symbols_response import FindSymbolsResponse as FindSymbolsResponse
from .session_init_response import SessionInitResponse as SessionInitResponse
from .session_list_response import SessionListResponse as SessionListResponse
from .source_url_part_param import SourceURLPartParam as SourceURLPartParam
from .step_start_part_param import StepStartPartParam as StepStartPartParam
from .assistant_message_part import AssistantMessagePart as AssistantMessagePart
from .session_abort_response import SessionAbortResponse as SessionAbortResponse
from .session_delete_response import SessionDeleteResponse as SessionDeleteResponse
from .tool_partial_call_param import ToolPartialCallParam as ToolPartialCallParam
from .user_message_part_param import UserMessagePartParam as UserMessagePartParam
from .session_summarize_params import SessionSummarizeParams as SessionSummarizeParams
from .config_providers_response import ConfigProvidersResponse as ConfigProvidersResponse
from .session_messages_response import SessionMessagesResponse as SessionMessagesResponse
from .session_summarize_response import SessionSummarizeResponse as SessionSummarizeResponse
from .tool_invocation_part_param import ToolInvocationPartParam as ToolInvocationPartParam
81 changes: 81 additions & 0 deletions src/opencode_ai/types/assistant_message.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing import List, Union, Optional
from typing_extensions import Literal, Annotated, TypeAlias

from pydantic import Field as FieldInfo

from .._utils import PropertyInfo
from .._models import BaseModel
from .shared.unknown_error import UnknownError
from .assistant_message_part import AssistantMessagePart
from .shared.provider_auth_error import ProviderAuthError

__all__ = ["AssistantMessage", "Path", "Time", "Tokens", "TokensCache", "Error", "ErrorMessageOutputLengthError"]


class Path(BaseModel):
cwd: str

root: str


class Time(BaseModel):
created: float

completed: Optional[float] = None


class TokensCache(BaseModel):
read: float

write: float


class Tokens(BaseModel):
cache: TokensCache

input: float

output: float

reasoning: float


class ErrorMessageOutputLengthError(BaseModel):
data: object

name: Literal["MessageOutputLengthError"]


Error: TypeAlias = Annotated[
Union[ProviderAuthError, UnknownError, ErrorMessageOutputLengthError], PropertyInfo(discriminator="name")
]


class AssistantMessage(BaseModel):
id: str

cost: float

api_model_id: str = FieldInfo(alias="modelID")

parts: List[AssistantMessagePart]

path: Path

provider_id: str = FieldInfo(alias="providerID")

role: Literal["assistant"]

session_id: str = FieldInfo(alias="sessionID")

system: List[str]

time: Time

tokens: Tokens

error: Optional[Error] = None

summary: Optional[bool] = None
15 changes: 15 additions & 0 deletions src/opencode_ai/types/assistant_message_part.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing import Union
from typing_extensions import Annotated, TypeAlias

from .._utils import PropertyInfo
from .text_part import TextPart
from .tool_part import ToolPart
from .step_start_part import StepStartPart

__all__ = ["AssistantMessagePart"]

AssistantMessagePart: TypeAlias = Annotated[
Union[TextPart, ToolPart, StepStartPart], PropertyInfo(discriminator="type")
]
30 changes: 15 additions & 15 deletions src/opencode_ai/types/event_list_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from .message import Message
from .session import Session
from .._models import BaseModel
from .message_part import MessagePart
from .shared.unknown_error import UnknownError
from .assistant_message_part import AssistantMessagePart
from .shared.provider_auth_error import ProviderAuthError

__all__ = [
Expand All @@ -22,10 +22,10 @@
"EventPermissionUpdatedPropertiesTime",
"EventFileEdited",
"EventFileEditedProperties",
"EventStorageWrite",
"EventStorageWriteProperties",
"EventInstallationUpdated",
"EventInstallationUpdatedProperties",
"EventStorageWrite",
"EventStorageWriteProperties",
"EventMessageUpdated",
"EventMessageUpdatedProperties",
"EventMessageRemoved",
Expand Down Expand Up @@ -91,6 +91,16 @@ class EventFileEdited(BaseModel):
type: Literal["file.edited"]


class EventInstallationUpdatedProperties(BaseModel):
version: str


class EventInstallationUpdated(BaseModel):
properties: EventInstallationUpdatedProperties

type: Literal["installation.updated"]


class EventStorageWriteProperties(BaseModel):
key: str

Expand All @@ -103,16 +113,6 @@ class EventStorageWrite(BaseModel):
type: Literal["storage.write"]


class EventInstallationUpdatedProperties(BaseModel):
version: str


class EventInstallationUpdated(BaseModel):
properties: EventInstallationUpdatedProperties

type: Literal["installation.updated"]


class EventMessageUpdatedProperties(BaseModel):
info: Message

Expand All @@ -138,7 +138,7 @@ class EventMessageRemoved(BaseModel):
class EventMessagePartUpdatedProperties(BaseModel):
message_id: str = FieldInfo(alias="messageID")

part: MessagePart
part: AssistantMessagePart

session_id: str = FieldInfo(alias="sessionID")

Expand Down Expand Up @@ -218,8 +218,8 @@ class EventFileWatcherUpdated(BaseModel):
EventLspClientDiagnostics,
EventPermissionUpdated,
EventFileEdited,
EventStorageWrite,
EventInstallationUpdated,
EventStorageWrite,
EventMessageUpdated,
EventMessageRemoved,
EventMessagePartUpdated,
Expand Down
4 changes: 1 addition & 3 deletions src/opencode_ai/types/file_part.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
from typing import Optional
from typing_extensions import Literal

from pydantic import Field as FieldInfo

from .._models import BaseModel

__all__ = ["FilePart"]


class FilePart(BaseModel):
media_type: str = FieldInfo(alias="mediaType")
mime: str

type: Literal["file"]

Expand Down
Loading