mirror of
https://github.com/anomalyco/opencode-sdk-python.git
synced 2026-04-28 12:39:54 +00:00
feat(api): api update
This commit is contained in:
parent
6fc2509c19
commit
e9bdc09f73
10 changed files with 138 additions and 146 deletions
|
|
@ -1,4 +1,4 @@
|
|||
configured_endpoints: 22
|
||||
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-8792f91dd070f7b4ee671fc86e8a03976dc7fb6ee49f8c99ad989e1597003774.yml
|
||||
openapi_spec_hash: fe9dc3a074be560de0b97df9b5af2c1b
|
||||
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-f9a2ce0fd0addc365614ef8c4bb1746f5ba14bc92f3d01f4cd85fb3b33a8d975.yml
|
||||
openapi_spec_hash: c58dec8e5250d41f216cded6afb763af
|
||||
config_hash: b7f3d9742335715c458494988498b183
|
||||
|
|
|
|||
|
|
@ -158,11 +158,12 @@ class SessionResource(SyncAPIResource):
|
|||
self,
|
||||
id: str,
|
||||
*,
|
||||
message_id: str,
|
||||
mode: str,
|
||||
model_id: str,
|
||||
parts: Iterable[session_chat_params.Part],
|
||||
provider_id: str,
|
||||
session_id: str,
|
||||
message_id: str | NotGiven = NOT_GIVEN,
|
||||
mode: str | NotGiven = NOT_GIVEN,
|
||||
# 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,
|
||||
|
|
@ -190,11 +191,12 @@ class SessionResource(SyncAPIResource):
|
|||
f"/session/{id}/message",
|
||||
body=maybe_transform(
|
||||
{
|
||||
"message_id": message_id,
|
||||
"mode": mode,
|
||||
"model_id": model_id,
|
||||
"parts": parts,
|
||||
"provider_id": provider_id,
|
||||
"session_id": session_id,
|
||||
"message_id": message_id,
|
||||
"mode": mode,
|
||||
},
|
||||
session_chat_params.SessionChatParams,
|
||||
),
|
||||
|
|
@ -524,11 +526,12 @@ class AsyncSessionResource(AsyncAPIResource):
|
|||
self,
|
||||
id: str,
|
||||
*,
|
||||
message_id: str,
|
||||
mode: str,
|
||||
model_id: str,
|
||||
parts: Iterable[session_chat_params.Part],
|
||||
provider_id: str,
|
||||
session_id: str,
|
||||
message_id: str | NotGiven = NOT_GIVEN,
|
||||
mode: str | NotGiven = NOT_GIVEN,
|
||||
# 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,
|
||||
|
|
@ -556,11 +559,12 @@ class AsyncSessionResource(AsyncAPIResource):
|
|||
f"/session/{id}/message",
|
||||
body=await async_maybe_transform(
|
||||
{
|
||||
"message_id": message_id,
|
||||
"mode": mode,
|
||||
"model_id": model_id,
|
||||
"parts": parts,
|
||||
"provider_id": provider_id,
|
||||
"session_id": session_id,
|
||||
"message_id": message_id,
|
||||
"mode": mode,
|
||||
},
|
||||
session_chat_params.SessionChatParams,
|
||||
),
|
||||
|
|
|
|||
|
|
@ -27,10 +27,8 @@ from .user_message import UserMessage as UserMessage
|
|||
from .layout_config import LayoutConfig as LayoutConfig
|
||||
from .snapshot_part import SnapshotPart as SnapshotPart
|
||||
from .app_log_params import AppLogParams as AppLogParams
|
||||
from .file_part_param import FilePartParam as FilePartParam
|
||||
from .keybinds_config import KeybindsConfig as KeybindsConfig
|
||||
from .step_start_part import StepStartPart as StepStartPart
|
||||
from .text_part_param import TextPartParam as TextPartParam
|
||||
from .app_log_response import AppLogResponse as AppLogResponse
|
||||
from .file_read_params import FileReadParams as FileReadParams
|
||||
from .find_text_params import FindTextParams as FindTextParams
|
||||
|
|
|
|||
|
|
@ -162,10 +162,10 @@ class Config(BaseModel):
|
|||
provider: Optional[Dict[str, Provider]] = None
|
||||
"""Custom provider configurations and model overrides"""
|
||||
|
||||
share: Optional[Literal["auto", "disabled"]] = None
|
||||
share: Optional[Literal["manual", "auto", "disabled"]] = None
|
||||
"""
|
||||
Control sharing behavior: 'auto' enables automatic sharing, 'disabled' disables
|
||||
all sharing
|
||||
Control sharing behavior:'manual' allows manual sharing via commands, 'auto'
|
||||
enables automatic sharing, 'disabled' disables all sharing
|
||||
"""
|
||||
|
||||
theme: Optional[str] = None
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing_extensions import Literal, Required, Annotated, TypedDict
|
||||
|
||||
from .._utils import PropertyInfo
|
||||
|
||||
__all__ = ["FilePartParam"]
|
||||
|
||||
|
||||
class FilePartParam(TypedDict, total=False):
|
||||
id: Required[str]
|
||||
|
||||
message_id: Required[Annotated[str, PropertyInfo(alias="messageID")]]
|
||||
|
||||
mime: Required[str]
|
||||
|
||||
session_id: Required[Annotated[str, PropertyInfo(alias="sessionID")]]
|
||||
|
||||
type: Required[Literal["file"]]
|
||||
|
||||
url: Required[str]
|
||||
|
||||
filename: str
|
||||
|
|
@ -105,7 +105,10 @@ class KeybindsConfig(BaseModel):
|
|||
"""Unshare current session"""
|
||||
|
||||
switch_mode: str
|
||||
"""Switch mode"""
|
||||
"""Next mode"""
|
||||
|
||||
switch_mode_reverse: str
|
||||
"""Previous Mode"""
|
||||
|
||||
theme_list: str
|
||||
"""List available themes"""
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
from typing import Optional
|
||||
from typing import Dict, Optional
|
||||
from typing_extensions import Literal
|
||||
|
||||
from .._models import BaseModel
|
||||
|
|
@ -17,3 +17,6 @@ class McpRemoteConfig(BaseModel):
|
|||
|
||||
enabled: Optional[bool] = None
|
||||
"""Enable or disable the MCP server on startup"""
|
||||
|
||||
headers: Optional[Dict[str, str]] = None
|
||||
"""Headers to send with the request"""
|
||||
|
|
|
|||
|
|
@ -3,25 +3,55 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import Union, Iterable
|
||||
from typing_extensions import Required, Annotated, TypeAlias, TypedDict
|
||||
from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict
|
||||
|
||||
from .._utils import PropertyInfo
|
||||
from .file_part_param import FilePartParam
|
||||
from .text_part_param import TextPartParam
|
||||
|
||||
__all__ = ["SessionChatParams", "Part"]
|
||||
__all__ = ["SessionChatParams", "Part", "PartUnionMember0", "PartUnionMember0Time", "PartUnionMember1"]
|
||||
|
||||
|
||||
class SessionChatParams(TypedDict, total=False):
|
||||
message_id: Required[Annotated[str, PropertyInfo(alias="messageID")]]
|
||||
|
||||
mode: Required[str]
|
||||
|
||||
model_id: Required[Annotated[str, PropertyInfo(alias="modelID")]]
|
||||
|
||||
parts: Required[Iterable[Part]]
|
||||
|
||||
provider_id: Required[Annotated[str, PropertyInfo(alias="providerID")]]
|
||||
|
||||
session_id: Required[Annotated[str, PropertyInfo(alias="sessionID")]]
|
||||
|
||||
Part: TypeAlias = Union[FilePartParam, TextPartParam]
|
||||
message_id: Annotated[str, PropertyInfo(alias="messageID")]
|
||||
|
||||
mode: str
|
||||
|
||||
|
||||
class PartUnionMember0Time(TypedDict, total=False):
|
||||
start: Required[float]
|
||||
|
||||
end: float
|
||||
|
||||
|
||||
class PartUnionMember0(TypedDict, total=False):
|
||||
text: Required[str]
|
||||
|
||||
type: Required[Literal["text"]]
|
||||
|
||||
id: str
|
||||
|
||||
synthetic: bool
|
||||
|
||||
time: PartUnionMember0Time
|
||||
|
||||
|
||||
class PartUnionMember1(TypedDict, total=False):
|
||||
mime: Required[str]
|
||||
|
||||
type: Required[Literal["file"]]
|
||||
|
||||
url: Required[str]
|
||||
|
||||
id: str
|
||||
|
||||
filename: str
|
||||
|
||||
|
||||
Part: TypeAlias = Union[PartUnionMember0, PartUnionMember1]
|
||||
|
|
|
|||
|
|
@ -1,31 +0,0 @@
|
|||
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing_extensions import Literal, Required, Annotated, TypedDict
|
||||
|
||||
from .._utils import PropertyInfo
|
||||
|
||||
__all__ = ["TextPartParam", "Time"]
|
||||
|
||||
|
||||
class Time(TypedDict, total=False):
|
||||
start: Required[float]
|
||||
|
||||
end: float
|
||||
|
||||
|
||||
class TextPartParam(TypedDict, total=False):
|
||||
id: Required[str]
|
||||
|
||||
message_id: Required[Annotated[str, PropertyInfo(alias="messageID")]]
|
||||
|
||||
session_id: Required[Annotated[str, PropertyInfo(alias="sessionID")]]
|
||||
|
||||
text: Required[str]
|
||||
|
||||
type: Required[Literal["text"]]
|
||||
|
||||
synthetic: bool
|
||||
|
||||
time: Time
|
||||
|
|
@ -171,20 +171,40 @@ class TestSession:
|
|||
def test_method_chat(self, client: Opencode) -> None:
|
||||
session = client.session.chat(
|
||||
id="id",
|
||||
message_id="messageID",
|
||||
mode="mode",
|
||||
model_id="modelID",
|
||||
parts=[
|
||||
{
|
||||
"id": "id",
|
||||
"message_id": "messageID",
|
||||
"mime": "mime",
|
||||
"session_id": "sessionID",
|
||||
"type": "file",
|
||||
"url": "url",
|
||||
"text": "text",
|
||||
"type": "text",
|
||||
}
|
||||
],
|
||||
provider_id="providerID",
|
||||
session_id="ses",
|
||||
)
|
||||
assert_matches_type(AssistantMessage, session, path=["response"])
|
||||
|
||||
@pytest.mark.skip()
|
||||
@parametrize
|
||||
def test_method_chat_with_all_params(self, client: Opencode) -> None:
|
||||
session = client.session.chat(
|
||||
id="id",
|
||||
model_id="modelID",
|
||||
parts=[
|
||||
{
|
||||
"text": "text",
|
||||
"type": "text",
|
||||
"id": "id",
|
||||
"synthetic": True,
|
||||
"time": {
|
||||
"start": 0,
|
||||
"end": 0,
|
||||
},
|
||||
}
|
||||
],
|
||||
provider_id="providerID",
|
||||
session_id="ses",
|
||||
message_id="msg",
|
||||
mode="mode",
|
||||
)
|
||||
assert_matches_type(AssistantMessage, session, path=["response"])
|
||||
|
||||
|
|
@ -193,20 +213,15 @@ class TestSession:
|
|||
def test_raw_response_chat(self, client: Opencode) -> None:
|
||||
response = client.session.with_raw_response.chat(
|
||||
id="id",
|
||||
message_id="messageID",
|
||||
mode="mode",
|
||||
model_id="modelID",
|
||||
parts=[
|
||||
{
|
||||
"id": "id",
|
||||
"message_id": "messageID",
|
||||
"mime": "mime",
|
||||
"session_id": "sessionID",
|
||||
"type": "file",
|
||||
"url": "url",
|
||||
"text": "text",
|
||||
"type": "text",
|
||||
}
|
||||
],
|
||||
provider_id="providerID",
|
||||
session_id="ses",
|
||||
)
|
||||
|
||||
assert response.is_closed is True
|
||||
|
|
@ -219,20 +234,15 @@ class TestSession:
|
|||
def test_streaming_response_chat(self, client: Opencode) -> None:
|
||||
with client.session.with_streaming_response.chat(
|
||||
id="id",
|
||||
message_id="messageID",
|
||||
mode="mode",
|
||||
model_id="modelID",
|
||||
parts=[
|
||||
{
|
||||
"id": "id",
|
||||
"message_id": "messageID",
|
||||
"mime": "mime",
|
||||
"session_id": "sessionID",
|
||||
"type": "file",
|
||||
"url": "url",
|
||||
"text": "text",
|
||||
"type": "text",
|
||||
}
|
||||
],
|
||||
provider_id="providerID",
|
||||
session_id="ses",
|
||||
) as response:
|
||||
assert not response.is_closed
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
|
|
@ -248,20 +258,15 @@ class TestSession:
|
|||
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
|
||||
client.session.with_raw_response.chat(
|
||||
id="",
|
||||
message_id="messageID",
|
||||
mode="mode",
|
||||
model_id="modelID",
|
||||
parts=[
|
||||
{
|
||||
"id": "id",
|
||||
"message_id": "messageID",
|
||||
"mime": "mime",
|
||||
"session_id": "sessionID",
|
||||
"type": "file",
|
||||
"url": "url",
|
||||
"text": "text",
|
||||
"type": "text",
|
||||
}
|
||||
],
|
||||
provider_id="providerID",
|
||||
session_id="ses",
|
||||
)
|
||||
|
||||
@pytest.mark.skip()
|
||||
|
|
@ -645,20 +650,40 @@ class TestAsyncSession:
|
|||
async def test_method_chat(self, async_client: AsyncOpencode) -> None:
|
||||
session = await async_client.session.chat(
|
||||
id="id",
|
||||
message_id="messageID",
|
||||
mode="mode",
|
||||
model_id="modelID",
|
||||
parts=[
|
||||
{
|
||||
"id": "id",
|
||||
"message_id": "messageID",
|
||||
"mime": "mime",
|
||||
"session_id": "sessionID",
|
||||
"type": "file",
|
||||
"url": "url",
|
||||
"text": "text",
|
||||
"type": "text",
|
||||
}
|
||||
],
|
||||
provider_id="providerID",
|
||||
session_id="ses",
|
||||
)
|
||||
assert_matches_type(AssistantMessage, session, path=["response"])
|
||||
|
||||
@pytest.mark.skip()
|
||||
@parametrize
|
||||
async def test_method_chat_with_all_params(self, async_client: AsyncOpencode) -> None:
|
||||
session = await async_client.session.chat(
|
||||
id="id",
|
||||
model_id="modelID",
|
||||
parts=[
|
||||
{
|
||||
"text": "text",
|
||||
"type": "text",
|
||||
"id": "id",
|
||||
"synthetic": True,
|
||||
"time": {
|
||||
"start": 0,
|
||||
"end": 0,
|
||||
},
|
||||
}
|
||||
],
|
||||
provider_id="providerID",
|
||||
session_id="ses",
|
||||
message_id="msg",
|
||||
mode="mode",
|
||||
)
|
||||
assert_matches_type(AssistantMessage, session, path=["response"])
|
||||
|
||||
|
|
@ -667,20 +692,15 @@ class TestAsyncSession:
|
|||
async def test_raw_response_chat(self, async_client: AsyncOpencode) -> None:
|
||||
response = await async_client.session.with_raw_response.chat(
|
||||
id="id",
|
||||
message_id="messageID",
|
||||
mode="mode",
|
||||
model_id="modelID",
|
||||
parts=[
|
||||
{
|
||||
"id": "id",
|
||||
"message_id": "messageID",
|
||||
"mime": "mime",
|
||||
"session_id": "sessionID",
|
||||
"type": "file",
|
||||
"url": "url",
|
||||
"text": "text",
|
||||
"type": "text",
|
||||
}
|
||||
],
|
||||
provider_id="providerID",
|
||||
session_id="ses",
|
||||
)
|
||||
|
||||
assert response.is_closed is True
|
||||
|
|
@ -693,20 +713,15 @@ class TestAsyncSession:
|
|||
async def test_streaming_response_chat(self, async_client: AsyncOpencode) -> None:
|
||||
async with async_client.session.with_streaming_response.chat(
|
||||
id="id",
|
||||
message_id="messageID",
|
||||
mode="mode",
|
||||
model_id="modelID",
|
||||
parts=[
|
||||
{
|
||||
"id": "id",
|
||||
"message_id": "messageID",
|
||||
"mime": "mime",
|
||||
"session_id": "sessionID",
|
||||
"type": "file",
|
||||
"url": "url",
|
||||
"text": "text",
|
||||
"type": "text",
|
||||
}
|
||||
],
|
||||
provider_id="providerID",
|
||||
session_id="ses",
|
||||
) as response:
|
||||
assert not response.is_closed
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
|
|
@ -722,20 +737,15 @@ class TestAsyncSession:
|
|||
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
|
||||
await async_client.session.with_raw_response.chat(
|
||||
id="",
|
||||
message_id="messageID",
|
||||
mode="mode",
|
||||
model_id="modelID",
|
||||
parts=[
|
||||
{
|
||||
"id": "id",
|
||||
"message_id": "messageID",
|
||||
"mime": "mime",
|
||||
"session_id": "sessionID",
|
||||
"type": "file",
|
||||
"url": "url",
|
||||
"text": "text",
|
||||
"type": "text",
|
||||
}
|
||||
],
|
||||
provider_id="providerID",
|
||||
session_id="ses",
|
||||
)
|
||||
|
||||
@pytest.mark.skip()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue