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
3214ae78d3
commit
731f553f04
14 changed files with 167 additions and 143 deletions
|
|
@ -23,6 +23,7 @@ from .._base_client import make_request_options
|
|||
from ..types.app_log_response import AppLogResponse
|
||||
from ..types.app_init_response import AppInitResponse
|
||||
from ..types.app_modes_response import AppModesResponse
|
||||
from ..types.app_providers_response import AppProvidersResponse
|
||||
|
||||
__all__ = ["AppResource", "AsyncAppResource"]
|
||||
|
||||
|
|
@ -155,6 +156,25 @@ class AppResource(SyncAPIResource):
|
|||
cast_to=AppModesResponse,
|
||||
)
|
||||
|
||||
def providers(
|
||||
self,
|
||||
*,
|
||||
# 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,
|
||||
) -> AppProvidersResponse:
|
||||
"""List all providers"""
|
||||
return self._get(
|
||||
"/config/providers",
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
||||
),
|
||||
cast_to=AppProvidersResponse,
|
||||
)
|
||||
|
||||
|
||||
class AsyncAppResource(AsyncAPIResource):
|
||||
@cached_property
|
||||
|
|
@ -284,6 +304,25 @@ class AsyncAppResource(AsyncAPIResource):
|
|||
cast_to=AppModesResponse,
|
||||
)
|
||||
|
||||
async def providers(
|
||||
self,
|
||||
*,
|
||||
# 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,
|
||||
) -> AppProvidersResponse:
|
||||
"""List all providers"""
|
||||
return await self._get(
|
||||
"/config/providers",
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
||||
),
|
||||
cast_to=AppProvidersResponse,
|
||||
)
|
||||
|
||||
|
||||
class AppResourceWithRawResponse:
|
||||
def __init__(self, app: AppResource) -> None:
|
||||
|
|
@ -301,6 +340,9 @@ class AppResourceWithRawResponse:
|
|||
self.modes = to_raw_response_wrapper(
|
||||
app.modes,
|
||||
)
|
||||
self.providers = to_raw_response_wrapper(
|
||||
app.providers,
|
||||
)
|
||||
|
||||
|
||||
class AsyncAppResourceWithRawResponse:
|
||||
|
|
@ -319,6 +361,9 @@ class AsyncAppResourceWithRawResponse:
|
|||
self.modes = async_to_raw_response_wrapper(
|
||||
app.modes,
|
||||
)
|
||||
self.providers = async_to_raw_response_wrapper(
|
||||
app.providers,
|
||||
)
|
||||
|
||||
|
||||
class AppResourceWithStreamingResponse:
|
||||
|
|
@ -337,6 +382,9 @@ class AppResourceWithStreamingResponse:
|
|||
self.modes = to_streamed_response_wrapper(
|
||||
app.modes,
|
||||
)
|
||||
self.providers = to_streamed_response_wrapper(
|
||||
app.providers,
|
||||
)
|
||||
|
||||
|
||||
class AsyncAppResourceWithStreamingResponse:
|
||||
|
|
@ -355,3 +403,6 @@ class AsyncAppResourceWithStreamingResponse:
|
|||
self.modes = async_to_streamed_response_wrapper(
|
||||
app.modes,
|
||||
)
|
||||
self.providers = async_to_streamed_response_wrapper(
|
||||
app.providers,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ from .._response import (
|
|||
)
|
||||
from .._base_client import make_request_options
|
||||
from ..types.config import Config
|
||||
from ..types.config_providers_response import ConfigProvidersResponse
|
||||
|
||||
__all__ = ["ConfigResource", "AsyncConfigResource"]
|
||||
|
||||
|
|
@ -59,25 +58,6 @@ class ConfigResource(SyncAPIResource):
|
|||
cast_to=Config,
|
||||
)
|
||||
|
||||
def providers(
|
||||
self,
|
||||
*,
|
||||
# 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,
|
||||
) -> ConfigProvidersResponse:
|
||||
"""List all providers"""
|
||||
return self._get(
|
||||
"/config/providers",
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
||||
),
|
||||
cast_to=ConfigProvidersResponse,
|
||||
)
|
||||
|
||||
|
||||
class AsyncConfigResource(AsyncAPIResource):
|
||||
@cached_property
|
||||
|
|
@ -118,25 +98,6 @@ class AsyncConfigResource(AsyncAPIResource):
|
|||
cast_to=Config,
|
||||
)
|
||||
|
||||
async def providers(
|
||||
self,
|
||||
*,
|
||||
# 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,
|
||||
) -> ConfigProvidersResponse:
|
||||
"""List all providers"""
|
||||
return await self._get(
|
||||
"/config/providers",
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
||||
),
|
||||
cast_to=ConfigProvidersResponse,
|
||||
)
|
||||
|
||||
|
||||
class ConfigResourceWithRawResponse:
|
||||
def __init__(self, config: ConfigResource) -> None:
|
||||
|
|
@ -145,9 +106,6 @@ class ConfigResourceWithRawResponse:
|
|||
self.get = to_raw_response_wrapper(
|
||||
config.get,
|
||||
)
|
||||
self.providers = to_raw_response_wrapper(
|
||||
config.providers,
|
||||
)
|
||||
|
||||
|
||||
class AsyncConfigResourceWithRawResponse:
|
||||
|
|
@ -157,9 +115,6 @@ class AsyncConfigResourceWithRawResponse:
|
|||
self.get = async_to_raw_response_wrapper(
|
||||
config.get,
|
||||
)
|
||||
self.providers = async_to_raw_response_wrapper(
|
||||
config.providers,
|
||||
)
|
||||
|
||||
|
||||
class ConfigResourceWithStreamingResponse:
|
||||
|
|
@ -169,9 +124,6 @@ class ConfigResourceWithStreamingResponse:
|
|||
self.get = to_streamed_response_wrapper(
|
||||
config.get,
|
||||
)
|
||||
self.providers = to_streamed_response_wrapper(
|
||||
config.providers,
|
||||
)
|
||||
|
||||
|
||||
class AsyncConfigResourceWithStreamingResponse:
|
||||
|
|
@ -181,6 +133,3 @@ class AsyncConfigResourceWithStreamingResponse:
|
|||
self.get = async_to_streamed_response_wrapper(
|
||||
config.get,
|
||||
)
|
||||
self.providers = async_to_streamed_response_wrapper(
|
||||
config.providers,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -17,28 +17,30 @@ from .shared import (
|
|||
from .symbol import Symbol as Symbol
|
||||
from .message import Message as Message
|
||||
from .session import Session as Session
|
||||
from .keybinds import Keybinds as Keybinds
|
||||
from .provider import Provider as Provider
|
||||
from .file_part import FilePart as FilePart
|
||||
from .log_level import LogLevel as LogLevel
|
||||
from .mcp_local import McpLocal as McpLocal
|
||||
from .text_part import TextPart as TextPart
|
||||
from .tool_part import ToolPart as ToolPart
|
||||
from .mcp_remote import McpRemote as McpRemote
|
||||
from .mode_config import ModeConfig as ModeConfig
|
||||
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
|
||||
from .mcp_local_config import McpLocalConfig as McpLocalConfig
|
||||
from .step_finish_part import StepFinishPart as StepFinishPart
|
||||
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 .mcp_remote_config import McpRemoteConfig as McpRemoteConfig
|
||||
from .app_modes_response import AppModesResponse as AppModesResponse
|
||||
from .file_read_response import FileReadResponse as FileReadResponse
|
||||
from .find_text_response import FindTextResponse as FindTextResponse
|
||||
|
|
@ -54,9 +56,9 @@ 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 .app_providers_response import AppProvidersResponse as AppProvidersResponse
|
||||
from .session_abort_response import SessionAbortResponse as SessionAbortResponse
|
||||
from .session_delete_response import SessionDeleteResponse as SessionDeleteResponse
|
||||
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
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@ from typing import Dict, List
|
|||
from .._models import BaseModel
|
||||
from .provider import Provider
|
||||
|
||||
__all__ = ["ConfigProvidersResponse"]
|
||||
__all__ = ["AppProvidersResponse"]
|
||||
|
||||
|
||||
class ConfigProvidersResponse(BaseModel):
|
||||
class AppProvidersResponse(BaseModel):
|
||||
default: Dict[str, str]
|
||||
|
||||
providers: List[Provider]
|
||||
|
|
@ -5,13 +5,14 @@ from typing_extensions import Literal, Annotated, TypeAlias
|
|||
|
||||
from pydantic import Field as FieldInfo
|
||||
|
||||
from . import mode
|
||||
from .._utils import PropertyInfo
|
||||
from .._models import BaseModel
|
||||
from .keybinds import Keybinds
|
||||
from .log_level import LogLevel
|
||||
from .mcp_local import McpLocal
|
||||
from .mcp_remote import McpRemote
|
||||
from .mode_config import ModeConfig
|
||||
from .layout_config import LayoutConfig
|
||||
from .keybinds_config import KeybindsConfig
|
||||
from .mcp_local_config import McpLocalConfig
|
||||
from .mcp_remote_config import McpRemoteConfig
|
||||
|
||||
__all__ = [
|
||||
"Config",
|
||||
|
|
@ -50,19 +51,19 @@ class Experimental(BaseModel):
|
|||
hook: Optional[ExperimentalHook] = None
|
||||
|
||||
|
||||
Mcp: TypeAlias = Annotated[Union[McpLocal, McpRemote], PropertyInfo(discriminator="type")]
|
||||
Mcp: TypeAlias = Annotated[Union[McpLocalConfig, McpRemoteConfig], PropertyInfo(discriminator="type")]
|
||||
|
||||
|
||||
class Mode(BaseModel):
|
||||
build: Optional[mode.Mode] = None
|
||||
build: Optional[ModeConfig] = None
|
||||
|
||||
plan: Optional[mode.Mode] = None
|
||||
plan: Optional[ModeConfig] = None
|
||||
|
||||
if TYPE_CHECKING:
|
||||
# Stub to indicate that arbitrary properties are accepted.
|
||||
# To access properties that are not valid identifiers you can use `getattr`, e.g.
|
||||
# `getattr(obj, '$type')`
|
||||
def __getattr__(self, attr: str) -> mode.Mode: ...
|
||||
def __getattr__(self, attr: str) -> ModeConfig: ...
|
||||
|
||||
|
||||
class ProviderModelsCost(BaseModel):
|
||||
|
|
@ -140,10 +141,10 @@ class Config(BaseModel):
|
|||
instructions: Optional[List[str]] = None
|
||||
"""Additional instruction files or patterns to include"""
|
||||
|
||||
keybinds: Optional[Keybinds] = None
|
||||
keybinds: Optional[KeybindsConfig] = None
|
||||
"""Custom keybind configurations"""
|
||||
|
||||
layout: Optional[Literal["auto", "stretch"]] = None
|
||||
layout: Optional[LayoutConfig] = None
|
||||
"""Layout to use for the TUI"""
|
||||
|
||||
log_level: Optional[LogLevel] = None
|
||||
|
|
|
|||
|
|
@ -4,10 +4,10 @@ from pydantic import Field as FieldInfo
|
|||
|
||||
from .._models import BaseModel
|
||||
|
||||
__all__ = ["Keybinds"]
|
||||
__all__ = ["KeybindsConfig"]
|
||||
|
||||
|
||||
class Keybinds(BaseModel):
|
||||
class KeybindsConfig(BaseModel):
|
||||
app_exit: str
|
||||
"""Exit the application"""
|
||||
|
||||
7
src/opencode_ai/types/layout_config.py
Normal file
7
src/opencode_ai/types/layout_config.py
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
__all__ = ["LayoutConfig"]
|
||||
|
||||
LayoutConfig: TypeAlias = Literal["auto", "stretch"]
|
||||
|
|
@ -5,10 +5,10 @@ from typing_extensions import Literal
|
|||
|
||||
from .._models import BaseModel
|
||||
|
||||
__all__ = ["McpLocal"]
|
||||
__all__ = ["McpLocalConfig"]
|
||||
|
||||
|
||||
class McpLocal(BaseModel):
|
||||
class McpLocalConfig(BaseModel):
|
||||
command: List[str]
|
||||
"""Command and arguments to run the MCP server"""
|
||||
|
||||
|
|
@ -5,10 +5,10 @@ from typing_extensions import Literal
|
|||
|
||||
from .._models import BaseModel
|
||||
|
||||
__all__ = ["McpRemote"]
|
||||
__all__ = ["McpRemoteConfig"]
|
||||
|
||||
|
||||
class McpRemote(BaseModel):
|
||||
class McpRemoteConfig(BaseModel):
|
||||
type: Literal["remote"]
|
||||
"""Type of MCP server connection"""
|
||||
|
||||
|
|
@ -4,10 +4,10 @@ from typing import Dict, Optional
|
|||
|
||||
from .._models import BaseModel
|
||||
|
||||
__all__ = ["Mode"]
|
||||
__all__ = ["ModeConfig"]
|
||||
|
||||
|
||||
class Mode(BaseModel):
|
||||
class ModeConfig(BaseModel):
|
||||
model: Optional[str] = None
|
||||
|
||||
prompt: Optional[str] = None
|
||||
Loading…
Add table
Add a link
Reference in a new issue