From a6cf7c5b2a411503294088428ca7918226eca161 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 27 Jun 2025 14:47:07 +0000 Subject: [PATCH 1/2] feat(api): update via SDK Studio --- .stats.yml | 2 +- CONTRIBUTING.md | 2 +- README.md | 48 +++++++++---------- SECURITY.md | 2 +- api.md | 44 ++++++++--------- mypy.ini | 2 +- pyproject.toml | 12 ++--- release-please-config.json | 2 +- requirements-dev.lock | 16 +++---- requirements.lock | 16 +++---- scripts/lint | 2 +- src/{opencode => opencode_ai}/__init__.py | 4 +- src/{opencode => opencode_ai}/_base_client.py | 2 +- src/{opencode => opencode_ai}/_client.py | 0 src/{opencode => opencode_ai}/_compat.py | 0 src/{opencode => opencode_ai}/_constants.py | 0 src/{opencode => opencode_ai}/_exceptions.py | 0 src/{opencode => opencode_ai}/_files.py | 0 src/{opencode => opencode_ai}/_models.py | 0 src/{opencode => opencode_ai}/_qs.py | 0 src/{opencode => opencode_ai}/_resource.py | 0 src/{opencode => opencode_ai}/_response.py | 10 ++-- src/{opencode => opencode_ai}/_streaming.py | 0 src/{opencode => opencode_ai}/_types.py | 2 +- .../_utils/__init__.py | 0 src/{opencode => opencode_ai}/_utils/_logs.py | 4 +- .../_utils/_proxy.py | 0 .../_utils/_reflection.py | 0 .../_utils/_resources_proxy.py | 8 ++-- .../_utils/_streams.py | 0 src/{opencode => opencode_ai}/_utils/_sync.py | 0 .../_utils/_transform.py | 0 .../_utils/_typing.py | 0 .../_utils/_utils.py | 0 src/{opencode => opencode_ai}/_version.py | 2 +- src/opencode_ai/lib/.keep | 4 ++ src/{opencode => opencode_ai}/py.typed | 0 .../resources/__init__.py | 0 .../resources/app.py | 0 .../resources/config.py | 0 .../resources/event.py | 0 .../resources/file.py | 0 .../resources/session.py | 0 .../types/__init__.py | 0 src/{opencode => opencode_ai}/types/app.py | 0 .../types/app_init_response.py | 0 src/{opencode => opencode_ai}/types/config.py | 0 .../types/config_providers_response.py | 0 .../types/event_list_response.py | 0 .../types/file_part.py | 0 .../types/file_part_param.py | 0 .../types/file_search_params.py | 0 .../types/file_search_response.py | 0 .../types/keybinds.py | 0 .../types/mcp_local.py | 0 .../types/mcp_remote.py | 0 .../types/message.py | 0 .../types/message_part.py | 0 .../types/message_part_param.py | 0 src/{opencode => opencode_ai}/types/model.py | 0 .../types/provider.py | 0 .../types/reasoning_part.py | 0 .../types/reasoning_part_param.py | 0 .../types/session.py | 0 .../types/session_abort_response.py | 0 .../types/session_chat_params.py | 0 .../types/session_delete_response.py | 0 .../types/session_init_params.py | 0 .../types/session_init_response.py | 0 .../types/session_list_response.py | 0 .../types/session_messages_response.py | 0 .../types/session_summarize_params.py | 0 .../types/session_summarize_response.py | 0 .../types/shared/__init__.py | 0 .../types/shared/provider_auth_error.py | 0 .../types/shared/unknown_error.py | 0 .../types/source_url_part.py | 0 .../types/source_url_part_param.py | 0 .../types/step_start_part.py | 0 .../types/step_start_part_param.py | 0 .../types/text_part.py | 0 .../types/text_part_param.py | 0 .../types/tool_call.py | 0 .../types/tool_call_param.py | 0 .../types/tool_invocation_part.py | 0 .../types/tool_invocation_part_param.py | 0 .../types/tool_partial_call.py | 0 .../types/tool_partial_call_param.py | 0 .../types/tool_result.py | 0 .../types/tool_result_param.py | 0 tests/api_resources/test_app.py | 4 +- tests/api_resources/test_config.py | 4 +- tests/api_resources/test_event.py | 4 +- tests/api_resources/test_file.py | 4 +- tests/api_resources/test_session.py | 4 +- tests/conftest.py | 6 +-- tests/test_client.py | 46 +++++++++--------- tests/test_deepcopy.py | 2 +- tests/test_extract_files.py | 4 +- tests/test_files.py | 2 +- tests/test_models.py | 6 +-- tests/test_qs.py | 2 +- tests/test_required_args.py | 2 +- tests/test_response.py | 14 +++--- tests/test_streaming.py | 4 +- tests/test_transform.py | 8 ++-- tests/test_utils/test_proxy.py | 2 +- tests/test_utils/test_typing.py | 2 +- tests/utils.py | 8 ++-- 109 files changed, 159 insertions(+), 153 deletions(-) rename src/{opencode => opencode_ai}/__init__.py (95%) rename src/{opencode => opencode_ai}/_base_client.py (99%) rename src/{opencode => opencode_ai}/_client.py (100%) rename src/{opencode => opencode_ai}/_compat.py (100%) rename src/{opencode => opencode_ai}/_constants.py (100%) rename src/{opencode => opencode_ai}/_exceptions.py (100%) rename src/{opencode => opencode_ai}/_files.py (100%) rename src/{opencode => opencode_ai}/_models.py (100%) rename src/{opencode => opencode_ai}/_qs.py (100%) rename src/{opencode => opencode_ai}/_resource.py (100%) rename src/{opencode => opencode_ai}/_response.py (98%) rename src/{opencode => opencode_ai}/_streaming.py (100%) rename src/{opencode => opencode_ai}/_types.py (99%) rename src/{opencode => opencode_ai}/_utils/__init__.py (100%) rename src/{opencode => opencode_ai}/_utils/_logs.py (76%) rename src/{opencode => opencode_ai}/_utils/_proxy.py (100%) rename src/{opencode => opencode_ai}/_utils/_reflection.py (100%) rename src/{opencode => opencode_ai}/_utils/_resources_proxy.py (51%) rename src/{opencode => opencode_ai}/_utils/_streams.py (100%) rename src/{opencode => opencode_ai}/_utils/_sync.py (100%) rename src/{opencode => opencode_ai}/_utils/_transform.py (100%) rename src/{opencode => opencode_ai}/_utils/_typing.py (100%) rename src/{opencode => opencode_ai}/_utils/_utils.py (100%) rename src/{opencode => opencode_ai}/_version.py (84%) create mode 100644 src/opencode_ai/lib/.keep rename src/{opencode => opencode_ai}/py.typed (100%) rename src/{opencode => opencode_ai}/resources/__init__.py (100%) rename src/{opencode => opencode_ai}/resources/app.py (100%) rename src/{opencode => opencode_ai}/resources/config.py (100%) rename src/{opencode => opencode_ai}/resources/event.py (100%) rename src/{opencode => opencode_ai}/resources/file.py (100%) rename src/{opencode => opencode_ai}/resources/session.py (100%) rename src/{opencode => opencode_ai}/types/__init__.py (100%) rename src/{opencode => opencode_ai}/types/app.py (100%) rename src/{opencode => opencode_ai}/types/app_init_response.py (100%) rename src/{opencode => opencode_ai}/types/config.py (100%) rename src/{opencode => opencode_ai}/types/config_providers_response.py (100%) rename src/{opencode => opencode_ai}/types/event_list_response.py (100%) rename src/{opencode => opencode_ai}/types/file_part.py (100%) rename src/{opencode => opencode_ai}/types/file_part_param.py (100%) rename src/{opencode => opencode_ai}/types/file_search_params.py (100%) rename src/{opencode => opencode_ai}/types/file_search_response.py (100%) rename src/{opencode => opencode_ai}/types/keybinds.py (100%) rename src/{opencode => opencode_ai}/types/mcp_local.py (100%) rename src/{opencode => opencode_ai}/types/mcp_remote.py (100%) rename src/{opencode => opencode_ai}/types/message.py (100%) rename src/{opencode => opencode_ai}/types/message_part.py (100%) rename src/{opencode => opencode_ai}/types/message_part_param.py (100%) rename src/{opencode => opencode_ai}/types/model.py (100%) rename src/{opencode => opencode_ai}/types/provider.py (100%) rename src/{opencode => opencode_ai}/types/reasoning_part.py (100%) rename src/{opencode => opencode_ai}/types/reasoning_part_param.py (100%) rename src/{opencode => opencode_ai}/types/session.py (100%) rename src/{opencode => opencode_ai}/types/session_abort_response.py (100%) rename src/{opencode => opencode_ai}/types/session_chat_params.py (100%) rename src/{opencode => opencode_ai}/types/session_delete_response.py (100%) rename src/{opencode => opencode_ai}/types/session_init_params.py (100%) rename src/{opencode => opencode_ai}/types/session_init_response.py (100%) rename src/{opencode => opencode_ai}/types/session_list_response.py (100%) rename src/{opencode => opencode_ai}/types/session_messages_response.py (100%) rename src/{opencode => opencode_ai}/types/session_summarize_params.py (100%) rename src/{opencode => opencode_ai}/types/session_summarize_response.py (100%) rename src/{opencode => opencode_ai}/types/shared/__init__.py (100%) rename src/{opencode => opencode_ai}/types/shared/provider_auth_error.py (100%) rename src/{opencode => opencode_ai}/types/shared/unknown_error.py (100%) rename src/{opencode => opencode_ai}/types/source_url_part.py (100%) rename src/{opencode => opencode_ai}/types/source_url_part_param.py (100%) rename src/{opencode => opencode_ai}/types/step_start_part.py (100%) rename src/{opencode => opencode_ai}/types/step_start_part_param.py (100%) rename src/{opencode => opencode_ai}/types/text_part.py (100%) rename src/{opencode => opencode_ai}/types/text_part_param.py (100%) rename src/{opencode => opencode_ai}/types/tool_call.py (100%) rename src/{opencode => opencode_ai}/types/tool_call_param.py (100%) rename src/{opencode => opencode_ai}/types/tool_invocation_part.py (100%) rename src/{opencode => opencode_ai}/types/tool_invocation_part_param.py (100%) rename src/{opencode => opencode_ai}/types/tool_partial_call.py (100%) rename src/{opencode => opencode_ai}/types/tool_partial_call_param.py (100%) rename src/{opencode => opencode_ai}/types/tool_result.py (100%) rename src/{opencode => opencode_ai}/types/tool_result_param.py (100%) diff --git a/.stats.yml b/.stats.yml index d463b78..11e3f99 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 16 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-3c79948402e96d2aae6e46095db2cf80759750d1b042d6f91281a72c415b14de.yml openapi_spec_hash: f9c2fc5988f0a30397929995c2be2c85 -config_hash: fddca9bc092956a3e82f3f3bdba448d1 +config_hash: d4c4c71d9a092267df2d4ab61fd89e63 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4ee6770..dcef083 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -36,7 +36,7 @@ $ pip install -r requirements-dev.lock Most of the SDK is generated code. Modifications to code will be persisted between generations, but may result in merge conflicts between manual patches and changes from the generator. The generator will never -modify the contents of the `src/opencode/lib/` and `examples/` directories. +modify the contents of the `src/opencode_ai/lib/` and `examples/` directories. ## Adding and running examples diff --git a/README.md b/README.md index 8500eb5..5066f50 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Opencode Python API library -[![PyPI version]()](https://pypi.org/project/opencode/) +[![PyPI version]()](https://pypi.org/project/opencode-ai/) The Opencode Python library provides convenient access to the Opencode REST API from any Python 3.8+ application. The library includes type definitions for all request params and response fields, @@ -16,7 +16,7 @@ The REST API documentation can be found on [opencode.ai](https://opencode.ai/doc ```sh # install from PyPI -pip install --pre opencode +pip install --pre opencode-ai ``` ## Usage @@ -24,7 +24,7 @@ pip install --pre opencode The full API of this library can be found in [api.md](api.md). ```python -from opencode import Opencode +from opencode_ai import Opencode client = Opencode() @@ -37,7 +37,7 @@ Simply import `AsyncOpencode` instead of `Opencode` and use `await` with each AP ```python import asyncio -from opencode import AsyncOpencode +from opencode_ai import AsyncOpencode client = AsyncOpencode() @@ -59,15 +59,15 @@ You can enable this by installing `aiohttp`: ```sh # install from PyPI -pip install --pre opencode[aiohttp] +pip install --pre opencode-ai[aiohttp] ``` Then you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`: ```python import asyncio -from opencode import DefaultAioHttpClient -from opencode import AsyncOpencode +from opencode_ai import DefaultAioHttpClient +from opencode_ai import AsyncOpencode async def main() -> None: @@ -91,27 +91,27 @@ Typed requests and responses provide autocomplete and documentation within your ## Handling errors -When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `opencode.APIConnectionError` is raised. +When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `opencode_ai.APIConnectionError` is raised. When the API returns a non-success status code (that is, 4xx or 5xx -response), a subclass of `opencode.APIStatusError` is raised, containing `status_code` and `response` properties. +response), a subclass of `opencode_ai.APIStatusError` is raised, containing `status_code` and `response` properties. -All errors inherit from `opencode.APIError`. +All errors inherit from `opencode_ai.APIError`. ```python -import opencode -from opencode import Opencode +import opencode_ai +from opencode_ai import Opencode client = Opencode() try: client.event.list() -except opencode.APIConnectionError as e: +except opencode_ai.APIConnectionError as e: print("The server could not be reached") print(e.__cause__) # an underlying Exception, likely raised within httpx. -except opencode.RateLimitError as e: +except opencode_ai.RateLimitError as e: print("A 429 status code was received; we should back off a bit.") -except opencode.APIStatusError as e: +except opencode_ai.APIStatusError as e: print("Another non-200-range status code was received") print(e.status_code) print(e.response) @@ -139,7 +139,7 @@ Connection errors (for example, due to a network connectivity problem), 408 Requ You can use the `max_retries` option to configure or disable retry settings: ```python -from opencode import Opencode +from opencode_ai import Opencode # Configure the default for all requests: client = Opencode( @@ -157,7 +157,7 @@ By default requests time out after 1 minute. You can configure this with a `time which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/timeouts/#fine-tuning-the-configuration) object: ```python -from opencode import Opencode +from opencode_ai import Opencode # Configure the default for all requests: client = Opencode( @@ -209,7 +209,7 @@ if response.my_field is None: The "raw" Response object can be accessed by prefixing `.with_raw_response.` to any HTTP method call, e.g., ```py -from opencode import Opencode +from opencode_ai import Opencode client = Opencode() response = client.event.with_raw_response.list() @@ -219,9 +219,9 @@ event = response.parse() # get the object that `event.list()` would have return print(event) ``` -These methods return an [`APIResponse`](https://github.com/sst/opencode-sdk-python/tree/main/src/opencode/_response.py) object. +These methods return an [`APIResponse`](https://github.com/sst/opencode-sdk-python/tree/main/src/opencode_ai/_response.py) object. -The async client returns an [`AsyncAPIResponse`](https://github.com/sst/opencode-sdk-python/tree/main/src/opencode/_response.py) with the same structure, the only difference being `await`able methods for reading the response content. +The async client returns an [`AsyncAPIResponse`](https://github.com/sst/opencode-sdk-python/tree/main/src/opencode_ai/_response.py) with the same structure, the only difference being `await`able methods for reading the response content. #### `.with_streaming_response` @@ -283,7 +283,7 @@ You can directly override the [httpx client](https://www.python-httpx.org/api/#c ```python import httpx -from opencode import Opencode, DefaultHttpxClient +from opencode_ai import Opencode, DefaultHttpxClient client = Opencode( # Or use the `OPENCODE_BASE_URL` env var @@ -306,7 +306,7 @@ client.with_options(http_client=DefaultHttpxClient(...)) By default the library closes underlying HTTP connections whenever the client is [garbage collected](https://docs.python.org/3/reference/datamodel.html#object.__del__). You can manually close the client using the `.close()` method if desired, or with a context manager that closes when exiting. ```py -from opencode import Opencode +from opencode_ai import Opencode with Opencode() as client: # make requests here @@ -334,8 +334,8 @@ If you've upgraded to the latest version but aren't seeing any new features you You can determine the version that is being used at runtime with: ```py -import opencode -print(opencode.__version__) +import opencode_ai +print(opencode_ai.__version__) ``` ## Requirements diff --git a/SECURITY.md b/SECURITY.md index 6912e12..a8a2837 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -20,7 +20,7 @@ or products provided by Opencode, please follow the respective company's securit ### Opencode Terms and Policies -Please contact support@sst.dev for any questions or concerns regarding the security of our services. +Please contact hello@sst.dev for any questions or concerns regarding the security of our services. --- diff --git a/api.md b/api.md index aa0dce5..9a9f536 100644 --- a/api.md +++ b/api.md @@ -1,7 +1,7 @@ # Shared Types ```python -from opencode.types import ProviderAuthError, UnknownError +from opencode_ai.types import ProviderAuthError, UnknownError ``` # Event @@ -9,44 +9,44 @@ from opencode.types import ProviderAuthError, UnknownError Types: ```python -from opencode.types import EventListResponse +from opencode_ai.types import EventListResponse ``` Methods: -- client.event.list() -> EventListResponse +- client.event.list() -> EventListResponse # App Types: ```python -from opencode.types import App, AppInitResponse +from opencode_ai.types import App, AppInitResponse ``` Methods: -- client.app.get() -> App -- client.app.init() -> AppInitResponse +- client.app.get() -> App +- client.app.init() -> AppInitResponse # File Types: ```python -from opencode.types import FileSearchResponse +from opencode_ai.types import FileSearchResponse ``` Methods: -- client.file.search(\*\*params) -> FileSearchResponse +- client.file.search(\*\*params) -> FileSearchResponse # Config Types: ```python -from opencode.types import ( +from opencode_ai.types import ( Config, Keybinds, McpLocal, @@ -59,15 +59,15 @@ from opencode.types import ( Methods: -- client.config.get() -> Config -- client.config.providers() -> ConfigProvidersResponse +- client.config.get() -> Config +- client.config.providers() -> ConfigProvidersResponse # Session Types: ```python -from opencode.types import ( +from opencode_ai.types import ( FilePart, Message, MessagePart, @@ -91,13 +91,13 @@ from opencode.types import ( Methods: -- client.session.create() -> Session -- client.session.list() -> SessionListResponse -- client.session.delete(id) -> SessionDeleteResponse -- client.session.abort(id) -> SessionAbortResponse -- client.session.chat(id, \*\*params) -> Message -- client.session.init(id, \*\*params) -> SessionInitResponse -- client.session.messages(id) -> SessionMessagesResponse -- client.session.share(id) -> Session -- client.session.summarize(id, \*\*params) -> SessionSummarizeResponse -- client.session.unshare(id) -> Session +- client.session.create() -> Session +- client.session.list() -> SessionListResponse +- client.session.delete(id) -> SessionDeleteResponse +- client.session.abort(id) -> SessionAbortResponse +- client.session.chat(id, \*\*params) -> Message +- client.session.init(id, \*\*params) -> SessionInitResponse +- client.session.messages(id) -> SessionMessagesResponse +- client.session.share(id) -> Session +- client.session.summarize(id, \*\*params) -> SessionSummarizeResponse +- client.session.unshare(id) -> Session diff --git a/mypy.ini b/mypy.ini index 2614cf4..34af79f 100644 --- a/mypy.ini +++ b/mypy.ini @@ -8,7 +8,7 @@ show_error_codes = True # # We also exclude our `tests` as mypy doesn't always infer # types correctly and Pyright will still catch any type errors. -exclude = ^(src/opencode/_files\.py|_dev/.*\.py|tests/.*)$ +exclude = ^(src/opencode_ai/_files\.py|_dev/.*\.py|tests/.*)$ strict_equality = True implicit_reexport = True diff --git a/pyproject.toml b/pyproject.toml index faa2b74..fd3c571 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,11 +1,11 @@ [project] -name = "opencode" +name = "opencode-ai" version = "0.1.0-alpha.1" description = "The official Python library for the opencode API" dynamic = ["readme"] license = "Apache-2.0" authors = [ -{ name = "Opencode", email = "support@sst.dev" }, +{ name = "Opencode", email = "hello@sst.dev" }, ] dependencies = [ "httpx>=0.23.0, <1", @@ -78,14 +78,14 @@ format = { chain = [ "check:ruff" = "ruff check ." "fix:ruff" = "ruff check --fix ." -"check:importable" = "python -c 'import opencode'" +"check:importable" = "python -c 'import opencode_ai'" typecheck = { chain = [ "typecheck:pyright", "typecheck:mypy" ]} "typecheck:pyright" = "pyright" -"typecheck:verify-types" = "pyright --verifytypes opencode --ignoreexternal" +"typecheck:verify-types" = "pyright --verifytypes opencode_ai --ignoreexternal" "typecheck:mypy" = "mypy ." [build-system] @@ -98,7 +98,7 @@ include = [ ] [tool.hatch.build.targets.wheel] -packages = ["src/opencode"] +packages = ["src/opencode_ai"] [tool.hatch.build.targets.sdist] # Basically everything except hidden files/directories (such as .github, .devcontainers, .python-version, etc) @@ -201,7 +201,7 @@ length-sort = true length-sort-straight = true combine-as-imports = true extra-standard-library = ["typing_extensions"] -known-first-party = ["opencode", "tests"] +known-first-party = ["opencode_ai", "tests"] [tool.ruff.lint.per-file-ignores] "bin/**.py" = ["T201", "T203"] diff --git a/release-please-config.json b/release-please-config.json index 0a23c92..c08c065 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -61,6 +61,6 @@ ], "release-type": "python", "extra-files": [ - "src/opencode/_version.py" + "src/opencode_ai/_version.py" ] } \ No newline at end of file diff --git a/requirements-dev.lock b/requirements-dev.lock index 0c97d32..8e408a1 100644 --- a/requirements-dev.lock +++ b/requirements-dev.lock @@ -14,14 +14,14 @@ aiohappyeyeballs==2.6.1 # via aiohttp aiohttp==3.12.8 # via httpx-aiohttp - # via opencode + # via opencode-ai aiosignal==1.3.2 # via aiohttp annotated-types==0.6.0 # via pydantic anyio==4.4.0 # via httpx - # via opencode + # via opencode-ai argcomplete==3.1.2 # via nox async-timeout==5.0.1 @@ -37,7 +37,7 @@ dirty-equals==0.6.0 distlib==0.3.7 # via virtualenv distro==1.8.0 - # via opencode + # via opencode-ai exceptiongroup==1.2.2 # via anyio # via pytest @@ -54,10 +54,10 @@ httpcore==1.0.2 # via httpx httpx==0.28.1 # via httpx-aiohttp - # via opencode + # via opencode-ai # via respx httpx-aiohttp==0.1.6 - # via opencode + # via opencode-ai idna==3.4 # via anyio # via httpx @@ -90,7 +90,7 @@ propcache==0.3.1 # via aiohttp # via yarl pydantic==2.10.3 - # via opencode + # via opencode-ai pydantic-core==2.27.1 # via pydantic pygments==2.18.0 @@ -114,7 +114,7 @@ six==1.16.0 # via python-dateutil sniffio==1.3.0 # via anyio - # via opencode + # via opencode-ai time-machine==2.9.0 tomli==2.0.2 # via mypy @@ -123,7 +123,7 @@ typing-extensions==4.12.2 # via anyio # via multidict # via mypy - # via opencode + # via opencode-ai # via pydantic # via pydantic-core # via pyright diff --git a/requirements.lock b/requirements.lock index 79114f2..4a4f03f 100644 --- a/requirements.lock +++ b/requirements.lock @@ -14,14 +14,14 @@ aiohappyeyeballs==2.6.1 # via aiohttp aiohttp==3.12.8 # via httpx-aiohttp - # via opencode + # via opencode-ai aiosignal==1.3.2 # via aiohttp annotated-types==0.6.0 # via pydantic anyio==4.4.0 # via httpx - # via opencode + # via opencode-ai async-timeout==5.0.1 # via aiohttp attrs==25.3.0 @@ -30,7 +30,7 @@ certifi==2023.7.22 # via httpcore # via httpx distro==1.8.0 - # via opencode + # via opencode-ai exceptiongroup==1.2.2 # via anyio frozenlist==1.6.2 @@ -42,9 +42,9 @@ httpcore==1.0.2 # via httpx httpx==0.28.1 # via httpx-aiohttp - # via opencode + # via opencode-ai httpx-aiohttp==0.1.6 - # via opencode + # via opencode-ai idna==3.4 # via anyio # via httpx @@ -56,16 +56,16 @@ propcache==0.3.1 # via aiohttp # via yarl pydantic==2.10.3 - # via opencode + # via opencode-ai pydantic-core==2.27.1 # via pydantic sniffio==1.3.0 # via anyio - # via opencode + # via opencode-ai typing-extensions==4.12.2 # via anyio # via multidict - # via opencode + # via opencode-ai # via pydantic # via pydantic-core yarl==1.20.0 diff --git a/scripts/lint b/scripts/lint index 3d712ce..bac00da 100755 --- a/scripts/lint +++ b/scripts/lint @@ -8,4 +8,4 @@ echo "==> Running lints" rye run lint echo "==> Making sure it imports" -rye run python -c 'import opencode' +rye run python -c 'import opencode_ai' diff --git a/src/opencode/__init__.py b/src/opencode_ai/__init__.py similarity index 95% rename from src/opencode/__init__.py rename to src/opencode_ai/__init__.py index 40cc502..7d8c13c 100644 --- a/src/opencode/__init__.py +++ b/src/opencode_ai/__init__.py @@ -89,12 +89,12 @@ # Update the __module__ attribute for exported symbols so that # error messages point to this module instead of the module # it was originally defined in, e.g. -# opencode._exceptions.NotFoundError -> opencode.NotFoundError +# opencode_ai._exceptions.NotFoundError -> opencode_ai.NotFoundError __locals = locals() for __name in __all__: if not __name.startswith("__"): try: - __locals[__name].__module__ = "opencode" + __locals[__name].__module__ = "opencode_ai" except (TypeError, AttributeError): # Some of our exported symbols are builtins which we can't set attributes for. pass diff --git a/src/opencode/_base_client.py b/src/opencode_ai/_base_client.py similarity index 99% rename from src/opencode/_base_client.py rename to src/opencode_ai/_base_client.py index e6d9600..f7025f4 100644 --- a/src/opencode/_base_client.py +++ b/src/opencode_ai/_base_client.py @@ -389,7 +389,7 @@ def __init__( if max_retries is None: # pyright: ignore[reportUnnecessaryComparison] raise TypeError( - "max_retries cannot be None. If you want to disable retries, pass `0`; if you want unlimited retries, pass `math.inf` or a very high number; if you want the default behavior, pass `opencode.DEFAULT_MAX_RETRIES`" + "max_retries cannot be None. If you want to disable retries, pass `0`; if you want unlimited retries, pass `math.inf` or a very high number; if you want the default behavior, pass `opencode_ai.DEFAULT_MAX_RETRIES`" ) def _enforce_trailing_slash(self, url: URL) -> URL: diff --git a/src/opencode/_client.py b/src/opencode_ai/_client.py similarity index 100% rename from src/opencode/_client.py rename to src/opencode_ai/_client.py diff --git a/src/opencode/_compat.py b/src/opencode_ai/_compat.py similarity index 100% rename from src/opencode/_compat.py rename to src/opencode_ai/_compat.py diff --git a/src/opencode/_constants.py b/src/opencode_ai/_constants.py similarity index 100% rename from src/opencode/_constants.py rename to src/opencode_ai/_constants.py diff --git a/src/opencode/_exceptions.py b/src/opencode_ai/_exceptions.py similarity index 100% rename from src/opencode/_exceptions.py rename to src/opencode_ai/_exceptions.py diff --git a/src/opencode/_files.py b/src/opencode_ai/_files.py similarity index 100% rename from src/opencode/_files.py rename to src/opencode_ai/_files.py diff --git a/src/opencode/_models.py b/src/opencode_ai/_models.py similarity index 100% rename from src/opencode/_models.py rename to src/opencode_ai/_models.py diff --git a/src/opencode/_qs.py b/src/opencode_ai/_qs.py similarity index 100% rename from src/opencode/_qs.py rename to src/opencode_ai/_qs.py diff --git a/src/opencode/_resource.py b/src/opencode_ai/_resource.py similarity index 100% rename from src/opencode/_resource.py rename to src/opencode_ai/_resource.py diff --git a/src/opencode/_response.py b/src/opencode_ai/_response.py similarity index 98% rename from src/opencode/_response.py rename to src/opencode_ai/_response.py index fb4ffa5..203be5d 100644 --- a/src/opencode/_response.py +++ b/src/opencode_ai/_response.py @@ -217,7 +217,9 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T: and not issubclass(origin, BaseModel) and issubclass(origin, pydantic.BaseModel) ): - raise TypeError("Pydantic models must subclass our base model type, e.g. `from opencode import BaseModel`") + raise TypeError( + "Pydantic models must subclass our base model type, e.g. `from opencode_ai import BaseModel`" + ) if ( cast_to is not object @@ -283,7 +285,7 @@ def parse(self, *, to: type[_T] | None = None) -> R | _T: the `to` argument, e.g. ```py - from opencode import BaseModel + from opencode_ai import BaseModel class MyModel(BaseModel): @@ -385,7 +387,7 @@ async def parse(self, *, to: type[_T] | None = None) -> R | _T: the `to` argument, e.g. ```py - from opencode import BaseModel + from opencode_ai import BaseModel class MyModel(BaseModel): @@ -556,7 +558,7 @@ async def stream_to_file( class MissingStreamClassError(TypeError): def __init__(self) -> None: super().__init__( - "The `stream` argument was set to `True` but the `stream_cls` argument was not given. See `opencode._streaming` for reference", + "The `stream` argument was set to `True` but the `stream_cls` argument was not given. See `opencode_ai._streaming` for reference", ) diff --git a/src/opencode/_streaming.py b/src/opencode_ai/_streaming.py similarity index 100% rename from src/opencode/_streaming.py rename to src/opencode_ai/_streaming.py diff --git a/src/opencode/_types.py b/src/opencode_ai/_types.py similarity index 99% rename from src/opencode/_types.py rename to src/opencode_ai/_types.py index e52791c..e9ba7eb 100644 --- a/src/opencode/_types.py +++ b/src/opencode_ai/_types.py @@ -81,7 +81,7 @@ # This unfortunately means that you will either have # to import this type and pass it explicitly: # -# from opencode import NoneType +# from opencode_ai import NoneType # client.get('/foo', cast_to=NoneType) # # or build it yourself: diff --git a/src/opencode/_utils/__init__.py b/src/opencode_ai/_utils/__init__.py similarity index 100% rename from src/opencode/_utils/__init__.py rename to src/opencode_ai/_utils/__init__.py diff --git a/src/opencode/_utils/_logs.py b/src/opencode_ai/_utils/_logs.py similarity index 76% rename from src/opencode/_utils/_logs.py rename to src/opencode_ai/_utils/_logs.py index e1b3dca..4cbc451 100644 --- a/src/opencode/_utils/_logs.py +++ b/src/opencode_ai/_utils/_logs.py @@ -1,12 +1,12 @@ import os import logging -logger: logging.Logger = logging.getLogger("opencode") +logger: logging.Logger = logging.getLogger("opencode_ai") httpx_logger: logging.Logger = logging.getLogger("httpx") def _basic_config() -> None: - # e.g. [2023-10-05 14:12:26 - opencode._base_client:818 - DEBUG] HTTP Request: POST http://127.0.0.1:4010/foo/bar "200 OK" + # e.g. [2023-10-05 14:12:26 - opencode_ai._base_client:818 - DEBUG] HTTP Request: POST http://127.0.0.1:4010/foo/bar "200 OK" logging.basicConfig( format="[%(asctime)s - %(name)s:%(lineno)d - %(levelname)s] %(message)s", datefmt="%Y-%m-%d %H:%M:%S", diff --git a/src/opencode/_utils/_proxy.py b/src/opencode_ai/_utils/_proxy.py similarity index 100% rename from src/opencode/_utils/_proxy.py rename to src/opencode_ai/_utils/_proxy.py diff --git a/src/opencode/_utils/_reflection.py b/src/opencode_ai/_utils/_reflection.py similarity index 100% rename from src/opencode/_utils/_reflection.py rename to src/opencode_ai/_utils/_reflection.py diff --git a/src/opencode/_utils/_resources_proxy.py b/src/opencode_ai/_utils/_resources_proxy.py similarity index 51% rename from src/opencode/_utils/_resources_proxy.py rename to src/opencode_ai/_utils/_resources_proxy.py index 44dc13c..0e17312 100644 --- a/src/opencode/_utils/_resources_proxy.py +++ b/src/opencode_ai/_utils/_resources_proxy.py @@ -7,17 +7,17 @@ class ResourcesProxy(LazyProxy[Any]): - """A proxy for the `opencode.resources` module. + """A proxy for the `opencode_ai.resources` module. - This is used so that we can lazily import `opencode.resources` only when - needed *and* so that users can just import `opencode` and reference `opencode.resources` + This is used so that we can lazily import `opencode_ai.resources` only when + needed *and* so that users can just import `opencode_ai` and reference `opencode_ai.resources` """ @override def __load__(self) -> Any: import importlib - mod = importlib.import_module("opencode.resources") + mod = importlib.import_module("opencode_ai.resources") return mod diff --git a/src/opencode/_utils/_streams.py b/src/opencode_ai/_utils/_streams.py similarity index 100% rename from src/opencode/_utils/_streams.py rename to src/opencode_ai/_utils/_streams.py diff --git a/src/opencode/_utils/_sync.py b/src/opencode_ai/_utils/_sync.py similarity index 100% rename from src/opencode/_utils/_sync.py rename to src/opencode_ai/_utils/_sync.py diff --git a/src/opencode/_utils/_transform.py b/src/opencode_ai/_utils/_transform.py similarity index 100% rename from src/opencode/_utils/_transform.py rename to src/opencode_ai/_utils/_transform.py diff --git a/src/opencode/_utils/_typing.py b/src/opencode_ai/_utils/_typing.py similarity index 100% rename from src/opencode/_utils/_typing.py rename to src/opencode_ai/_utils/_typing.py diff --git a/src/opencode/_utils/_utils.py b/src/opencode_ai/_utils/_utils.py similarity index 100% rename from src/opencode/_utils/_utils.py rename to src/opencode_ai/_utils/_utils.py diff --git a/src/opencode/_version.py b/src/opencode_ai/_version.py similarity index 84% rename from src/opencode/_version.py rename to src/opencode_ai/_version.py index 70cdf17..4d98701 100644 --- a/src/opencode/_version.py +++ b/src/opencode_ai/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -__title__ = "opencode" +__title__ = "opencode_ai" __version__ = "0.1.0-alpha.1" # x-release-please-version diff --git a/src/opencode_ai/lib/.keep b/src/opencode_ai/lib/.keep new file mode 100644 index 0000000..5e2c99f --- /dev/null +++ b/src/opencode_ai/lib/.keep @@ -0,0 +1,4 @@ +File generated from our OpenAPI spec by Stainless. + +This directory can be used to store custom files to expand the SDK. +It is ignored by Stainless code generation and its content (other than this keep file) won't be touched. \ No newline at end of file diff --git a/src/opencode/py.typed b/src/opencode_ai/py.typed similarity index 100% rename from src/opencode/py.typed rename to src/opencode_ai/py.typed diff --git a/src/opencode/resources/__init__.py b/src/opencode_ai/resources/__init__.py similarity index 100% rename from src/opencode/resources/__init__.py rename to src/opencode_ai/resources/__init__.py diff --git a/src/opencode/resources/app.py b/src/opencode_ai/resources/app.py similarity index 100% rename from src/opencode/resources/app.py rename to src/opencode_ai/resources/app.py diff --git a/src/opencode/resources/config.py b/src/opencode_ai/resources/config.py similarity index 100% rename from src/opencode/resources/config.py rename to src/opencode_ai/resources/config.py diff --git a/src/opencode/resources/event.py b/src/opencode_ai/resources/event.py similarity index 100% rename from src/opencode/resources/event.py rename to src/opencode_ai/resources/event.py diff --git a/src/opencode/resources/file.py b/src/opencode_ai/resources/file.py similarity index 100% rename from src/opencode/resources/file.py rename to src/opencode_ai/resources/file.py diff --git a/src/opencode/resources/session.py b/src/opencode_ai/resources/session.py similarity index 100% rename from src/opencode/resources/session.py rename to src/opencode_ai/resources/session.py diff --git a/src/opencode/types/__init__.py b/src/opencode_ai/types/__init__.py similarity index 100% rename from src/opencode/types/__init__.py rename to src/opencode_ai/types/__init__.py diff --git a/src/opencode/types/app.py b/src/opencode_ai/types/app.py similarity index 100% rename from src/opencode/types/app.py rename to src/opencode_ai/types/app.py diff --git a/src/opencode/types/app_init_response.py b/src/opencode_ai/types/app_init_response.py similarity index 100% rename from src/opencode/types/app_init_response.py rename to src/opencode_ai/types/app_init_response.py diff --git a/src/opencode/types/config.py b/src/opencode_ai/types/config.py similarity index 100% rename from src/opencode/types/config.py rename to src/opencode_ai/types/config.py diff --git a/src/opencode/types/config_providers_response.py b/src/opencode_ai/types/config_providers_response.py similarity index 100% rename from src/opencode/types/config_providers_response.py rename to src/opencode_ai/types/config_providers_response.py diff --git a/src/opencode/types/event_list_response.py b/src/opencode_ai/types/event_list_response.py similarity index 100% rename from src/opencode/types/event_list_response.py rename to src/opencode_ai/types/event_list_response.py diff --git a/src/opencode/types/file_part.py b/src/opencode_ai/types/file_part.py similarity index 100% rename from src/opencode/types/file_part.py rename to src/opencode_ai/types/file_part.py diff --git a/src/opencode/types/file_part_param.py b/src/opencode_ai/types/file_part_param.py similarity index 100% rename from src/opencode/types/file_part_param.py rename to src/opencode_ai/types/file_part_param.py diff --git a/src/opencode/types/file_search_params.py b/src/opencode_ai/types/file_search_params.py similarity index 100% rename from src/opencode/types/file_search_params.py rename to src/opencode_ai/types/file_search_params.py diff --git a/src/opencode/types/file_search_response.py b/src/opencode_ai/types/file_search_response.py similarity index 100% rename from src/opencode/types/file_search_response.py rename to src/opencode_ai/types/file_search_response.py diff --git a/src/opencode/types/keybinds.py b/src/opencode_ai/types/keybinds.py similarity index 100% rename from src/opencode/types/keybinds.py rename to src/opencode_ai/types/keybinds.py diff --git a/src/opencode/types/mcp_local.py b/src/opencode_ai/types/mcp_local.py similarity index 100% rename from src/opencode/types/mcp_local.py rename to src/opencode_ai/types/mcp_local.py diff --git a/src/opencode/types/mcp_remote.py b/src/opencode_ai/types/mcp_remote.py similarity index 100% rename from src/opencode/types/mcp_remote.py rename to src/opencode_ai/types/mcp_remote.py diff --git a/src/opencode/types/message.py b/src/opencode_ai/types/message.py similarity index 100% rename from src/opencode/types/message.py rename to src/opencode_ai/types/message.py diff --git a/src/opencode/types/message_part.py b/src/opencode_ai/types/message_part.py similarity index 100% rename from src/opencode/types/message_part.py rename to src/opencode_ai/types/message_part.py diff --git a/src/opencode/types/message_part_param.py b/src/opencode_ai/types/message_part_param.py similarity index 100% rename from src/opencode/types/message_part_param.py rename to src/opencode_ai/types/message_part_param.py diff --git a/src/opencode/types/model.py b/src/opencode_ai/types/model.py similarity index 100% rename from src/opencode/types/model.py rename to src/opencode_ai/types/model.py diff --git a/src/opencode/types/provider.py b/src/opencode_ai/types/provider.py similarity index 100% rename from src/opencode/types/provider.py rename to src/opencode_ai/types/provider.py diff --git a/src/opencode/types/reasoning_part.py b/src/opencode_ai/types/reasoning_part.py similarity index 100% rename from src/opencode/types/reasoning_part.py rename to src/opencode_ai/types/reasoning_part.py diff --git a/src/opencode/types/reasoning_part_param.py b/src/opencode_ai/types/reasoning_part_param.py similarity index 100% rename from src/opencode/types/reasoning_part_param.py rename to src/opencode_ai/types/reasoning_part_param.py diff --git a/src/opencode/types/session.py b/src/opencode_ai/types/session.py similarity index 100% rename from src/opencode/types/session.py rename to src/opencode_ai/types/session.py diff --git a/src/opencode/types/session_abort_response.py b/src/opencode_ai/types/session_abort_response.py similarity index 100% rename from src/opencode/types/session_abort_response.py rename to src/opencode_ai/types/session_abort_response.py diff --git a/src/opencode/types/session_chat_params.py b/src/opencode_ai/types/session_chat_params.py similarity index 100% rename from src/opencode/types/session_chat_params.py rename to src/opencode_ai/types/session_chat_params.py diff --git a/src/opencode/types/session_delete_response.py b/src/opencode_ai/types/session_delete_response.py similarity index 100% rename from src/opencode/types/session_delete_response.py rename to src/opencode_ai/types/session_delete_response.py diff --git a/src/opencode/types/session_init_params.py b/src/opencode_ai/types/session_init_params.py similarity index 100% rename from src/opencode/types/session_init_params.py rename to src/opencode_ai/types/session_init_params.py diff --git a/src/opencode/types/session_init_response.py b/src/opencode_ai/types/session_init_response.py similarity index 100% rename from src/opencode/types/session_init_response.py rename to src/opencode_ai/types/session_init_response.py diff --git a/src/opencode/types/session_list_response.py b/src/opencode_ai/types/session_list_response.py similarity index 100% rename from src/opencode/types/session_list_response.py rename to src/opencode_ai/types/session_list_response.py diff --git a/src/opencode/types/session_messages_response.py b/src/opencode_ai/types/session_messages_response.py similarity index 100% rename from src/opencode/types/session_messages_response.py rename to src/opencode_ai/types/session_messages_response.py diff --git a/src/opencode/types/session_summarize_params.py b/src/opencode_ai/types/session_summarize_params.py similarity index 100% rename from src/opencode/types/session_summarize_params.py rename to src/opencode_ai/types/session_summarize_params.py diff --git a/src/opencode/types/session_summarize_response.py b/src/opencode_ai/types/session_summarize_response.py similarity index 100% rename from src/opencode/types/session_summarize_response.py rename to src/opencode_ai/types/session_summarize_response.py diff --git a/src/opencode/types/shared/__init__.py b/src/opencode_ai/types/shared/__init__.py similarity index 100% rename from src/opencode/types/shared/__init__.py rename to src/opencode_ai/types/shared/__init__.py diff --git a/src/opencode/types/shared/provider_auth_error.py b/src/opencode_ai/types/shared/provider_auth_error.py similarity index 100% rename from src/opencode/types/shared/provider_auth_error.py rename to src/opencode_ai/types/shared/provider_auth_error.py diff --git a/src/opencode/types/shared/unknown_error.py b/src/opencode_ai/types/shared/unknown_error.py similarity index 100% rename from src/opencode/types/shared/unknown_error.py rename to src/opencode_ai/types/shared/unknown_error.py diff --git a/src/opencode/types/source_url_part.py b/src/opencode_ai/types/source_url_part.py similarity index 100% rename from src/opencode/types/source_url_part.py rename to src/opencode_ai/types/source_url_part.py diff --git a/src/opencode/types/source_url_part_param.py b/src/opencode_ai/types/source_url_part_param.py similarity index 100% rename from src/opencode/types/source_url_part_param.py rename to src/opencode_ai/types/source_url_part_param.py diff --git a/src/opencode/types/step_start_part.py b/src/opencode_ai/types/step_start_part.py similarity index 100% rename from src/opencode/types/step_start_part.py rename to src/opencode_ai/types/step_start_part.py diff --git a/src/opencode/types/step_start_part_param.py b/src/opencode_ai/types/step_start_part_param.py similarity index 100% rename from src/opencode/types/step_start_part_param.py rename to src/opencode_ai/types/step_start_part_param.py diff --git a/src/opencode/types/text_part.py b/src/opencode_ai/types/text_part.py similarity index 100% rename from src/opencode/types/text_part.py rename to src/opencode_ai/types/text_part.py diff --git a/src/opencode/types/text_part_param.py b/src/opencode_ai/types/text_part_param.py similarity index 100% rename from src/opencode/types/text_part_param.py rename to src/opencode_ai/types/text_part_param.py diff --git a/src/opencode/types/tool_call.py b/src/opencode_ai/types/tool_call.py similarity index 100% rename from src/opencode/types/tool_call.py rename to src/opencode_ai/types/tool_call.py diff --git a/src/opencode/types/tool_call_param.py b/src/opencode_ai/types/tool_call_param.py similarity index 100% rename from src/opencode/types/tool_call_param.py rename to src/opencode_ai/types/tool_call_param.py diff --git a/src/opencode/types/tool_invocation_part.py b/src/opencode_ai/types/tool_invocation_part.py similarity index 100% rename from src/opencode/types/tool_invocation_part.py rename to src/opencode_ai/types/tool_invocation_part.py diff --git a/src/opencode/types/tool_invocation_part_param.py b/src/opencode_ai/types/tool_invocation_part_param.py similarity index 100% rename from src/opencode/types/tool_invocation_part_param.py rename to src/opencode_ai/types/tool_invocation_part_param.py diff --git a/src/opencode/types/tool_partial_call.py b/src/opencode_ai/types/tool_partial_call.py similarity index 100% rename from src/opencode/types/tool_partial_call.py rename to src/opencode_ai/types/tool_partial_call.py diff --git a/src/opencode/types/tool_partial_call_param.py b/src/opencode_ai/types/tool_partial_call_param.py similarity index 100% rename from src/opencode/types/tool_partial_call_param.py rename to src/opencode_ai/types/tool_partial_call_param.py diff --git a/src/opencode/types/tool_result.py b/src/opencode_ai/types/tool_result.py similarity index 100% rename from src/opencode/types/tool_result.py rename to src/opencode_ai/types/tool_result.py diff --git a/src/opencode/types/tool_result_param.py b/src/opencode_ai/types/tool_result_param.py similarity index 100% rename from src/opencode/types/tool_result_param.py rename to src/opencode_ai/types/tool_result_param.py diff --git a/tests/api_resources/test_app.py b/tests/api_resources/test_app.py index cdadc62..ab04f6a 100644 --- a/tests/api_resources/test_app.py +++ b/tests/api_resources/test_app.py @@ -7,9 +7,9 @@ import pytest -from opencode import Opencode, AsyncOpencode +from opencode_ai import Opencode, AsyncOpencode from tests.utils import assert_matches_type -from opencode.types import App, AppInitResponse +from opencode_ai.types import App, AppInitResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") diff --git a/tests/api_resources/test_config.py b/tests/api_resources/test_config.py index 600a5ec..5131373 100644 --- a/tests/api_resources/test_config.py +++ b/tests/api_resources/test_config.py @@ -7,9 +7,9 @@ import pytest -from opencode import Opencode, AsyncOpencode +from opencode_ai import Opencode, AsyncOpencode from tests.utils import assert_matches_type -from opencode.types import Config, ConfigProvidersResponse +from opencode_ai.types import Config, ConfigProvidersResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") diff --git a/tests/api_resources/test_event.py b/tests/api_resources/test_event.py index 4e0a06d..21c167c 100644 --- a/tests/api_resources/test_event.py +++ b/tests/api_resources/test_event.py @@ -7,9 +7,9 @@ import pytest -from opencode import Opencode, AsyncOpencode +from opencode_ai import Opencode, AsyncOpencode from tests.utils import assert_matches_type -from opencode.types import EventListResponse +from opencode_ai.types import EventListResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") diff --git a/tests/api_resources/test_file.py b/tests/api_resources/test_file.py index e897cc5..2e8d52b 100644 --- a/tests/api_resources/test_file.py +++ b/tests/api_resources/test_file.py @@ -7,9 +7,9 @@ import pytest -from opencode import Opencode, AsyncOpencode +from opencode_ai import Opencode, AsyncOpencode from tests.utils import assert_matches_type -from opencode.types import FileSearchResponse +from opencode_ai.types import FileSearchResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") diff --git a/tests/api_resources/test_session.py b/tests/api_resources/test_session.py index 7baa55e..9b2e0b5 100644 --- a/tests/api_resources/test_session.py +++ b/tests/api_resources/test_session.py @@ -7,9 +7,9 @@ import pytest -from opencode import Opencode, AsyncOpencode +from opencode_ai import Opencode, AsyncOpencode from tests.utils import assert_matches_type -from opencode.types import ( +from opencode_ai.types import ( Message, Session, SessionInitResponse, diff --git a/tests/conftest.py b/tests/conftest.py index e44793b..aa47bd6 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -10,15 +10,15 @@ import pytest from pytest_asyncio import is_async_test -from opencode import Opencode, AsyncOpencode, DefaultAioHttpClient -from opencode._utils import is_dict +from opencode_ai import Opencode, AsyncOpencode, DefaultAioHttpClient +from opencode_ai._utils import is_dict if TYPE_CHECKING: from _pytest.fixtures import FixtureRequest # pyright: ignore[reportPrivateImportUsage] pytest.register_assert_rewrite("tests.utils") -logging.getLogger("opencode").setLevel(logging.DEBUG) +logging.getLogger("opencode_ai").setLevel(logging.DEBUG) # automatically add `pytest.mark.asyncio()` to all of our async tests diff --git a/tests/test_client.py b/tests/test_client.py index cd53b2c..0e900dd 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -21,11 +21,11 @@ from respx import MockRouter from pydantic import ValidationError -from opencode import Opencode, AsyncOpencode, APIResponseValidationError -from opencode._types import Omit -from opencode._models import BaseModel, FinalRequestOptions -from opencode._exceptions import APIStatusError, APITimeoutError, APIResponseValidationError -from opencode._base_client import ( +from opencode_ai import Opencode, AsyncOpencode, APIResponseValidationError +from opencode_ai._types import Omit +from opencode_ai._models import BaseModel, FinalRequestOptions +from opencode_ai._exceptions import APIStatusError, APITimeoutError, APIResponseValidationError +from opencode_ai._base_client import ( DEFAULT_TIMEOUT, HTTPX_DEFAULT_TIMEOUT, BaseClient, @@ -223,10 +223,10 @@ def add_leak(leaks: list[tracemalloc.StatisticDiff], diff: tracemalloc.Statistic # to_raw_response_wrapper leaks through the @functools.wraps() decorator. # # removing the decorator fixes the leak for reasons we don't understand. - "opencode/_legacy_response.py", - "opencode/_response.py", + "opencode_ai/_legacy_response.py", + "opencode_ai/_response.py", # pydantic.BaseModel.model_dump || pydantic.BaseModel.dict leak memory for some reason. - "opencode/_compat.py", + "opencode_ai/_compat.py", # Standard library leaks we don't care about. "/logging/__init__.py", ] @@ -671,7 +671,7 @@ def test_parse_retry_after_header(self, remaining_retries: int, retry_after: str calculated = client._calculate_retry_timeout(remaining_retries, options, headers) assert calculated == pytest.approx(timeout, 0.5 * 0.875) # pyright: ignore[reportUnknownMemberType] - @mock.patch("opencode._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) + @mock.patch("opencode_ai._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) @pytest.mark.respx(base_url=base_url) def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter, client: Opencode) -> None: respx_mock.get("/event").mock(side_effect=httpx.TimeoutException("Test timeout error")) @@ -681,7 +681,7 @@ def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter, clien assert _get_open_connections(self.client) == 0 - @mock.patch("opencode._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) + @mock.patch("opencode_ai._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) @pytest.mark.respx(base_url=base_url) def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter, client: Opencode) -> None: respx_mock.get("/event").mock(return_value=httpx.Response(500)) @@ -691,7 +691,7 @@ def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter, client assert _get_open_connections(self.client) == 0 @pytest.mark.parametrize("failures_before_success", [0, 2, 4]) - @mock.patch("opencode._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) + @mock.patch("opencode_ai._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) @pytest.mark.respx(base_url=base_url) @pytest.mark.parametrize("failure_mode", ["status", "exception"]) def test_retries_taken( @@ -722,7 +722,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: assert int(response.http_request.headers.get("x-stainless-retry-count")) == failures_before_success @pytest.mark.parametrize("failures_before_success", [0, 2, 4]) - @mock.patch("opencode._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) + @mock.patch("opencode_ai._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) @pytest.mark.respx(base_url=base_url) def test_omit_retry_count_header( self, client: Opencode, failures_before_success: int, respx_mock: MockRouter @@ -745,7 +745,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: assert len(response.http_request.headers.get_list("x-stainless-retry-count")) == 0 @pytest.mark.parametrize("failures_before_success", [0, 2, 4]) - @mock.patch("opencode._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) + @mock.patch("opencode_ai._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) @pytest.mark.respx(base_url=base_url) def test_overwrite_retry_count_header( self, client: Opencode, failures_before_success: int, respx_mock: MockRouter @@ -985,10 +985,10 @@ def add_leak(leaks: list[tracemalloc.StatisticDiff], diff: tracemalloc.Statistic # to_raw_response_wrapper leaks through the @functools.wraps() decorator. # # removing the decorator fixes the leak for reasons we don't understand. - "opencode/_legacy_response.py", - "opencode/_response.py", + "opencode_ai/_legacy_response.py", + "opencode_ai/_response.py", # pydantic.BaseModel.model_dump || pydantic.BaseModel.dict leak memory for some reason. - "opencode/_compat.py", + "opencode_ai/_compat.py", # Standard library leaks we don't care about. "/logging/__init__.py", ] @@ -1439,7 +1439,7 @@ async def test_parse_retry_after_header(self, remaining_retries: int, retry_afte calculated = client._calculate_retry_timeout(remaining_retries, options, headers) assert calculated == pytest.approx(timeout, 0.5 * 0.875) # pyright: ignore[reportUnknownMemberType] - @mock.patch("opencode._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) + @mock.patch("opencode_ai._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) @pytest.mark.respx(base_url=base_url) async def test_retrying_timeout_errors_doesnt_leak( self, respx_mock: MockRouter, async_client: AsyncOpencode @@ -1451,7 +1451,7 @@ async def test_retrying_timeout_errors_doesnt_leak( assert _get_open_connections(self.client) == 0 - @mock.patch("opencode._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) + @mock.patch("opencode_ai._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) @pytest.mark.respx(base_url=base_url) async def test_retrying_status_errors_doesnt_leak( self, respx_mock: MockRouter, async_client: AsyncOpencode @@ -1463,7 +1463,7 @@ async def test_retrying_status_errors_doesnt_leak( assert _get_open_connections(self.client) == 0 @pytest.mark.parametrize("failures_before_success", [0, 2, 4]) - @mock.patch("opencode._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) + @mock.patch("opencode_ai._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) @pytest.mark.respx(base_url=base_url) @pytest.mark.asyncio @pytest.mark.parametrize("failure_mode", ["status", "exception"]) @@ -1495,7 +1495,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: assert int(response.http_request.headers.get("x-stainless-retry-count")) == failures_before_success @pytest.mark.parametrize("failures_before_success", [0, 2, 4]) - @mock.patch("opencode._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) + @mock.patch("opencode_ai._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) @pytest.mark.respx(base_url=base_url) @pytest.mark.asyncio async def test_omit_retry_count_header( @@ -1519,7 +1519,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: assert len(response.http_request.headers.get_list("x-stainless-retry-count")) == 0 @pytest.mark.parametrize("failures_before_success", [0, 2, 4]) - @mock.patch("opencode._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) + @mock.patch("opencode_ai._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) @pytest.mark.respx(base_url=base_url) @pytest.mark.asyncio async def test_overwrite_retry_count_header( @@ -1553,8 +1553,8 @@ def test_get_platform(self) -> None: import nest_asyncio import threading - from opencode._utils import asyncify - from opencode._base_client import get_platform + from opencode_ai._utils import asyncify + from opencode_ai._base_client import get_platform async def test_main() -> None: result = await asyncify(get_platform)() diff --git a/tests/test_deepcopy.py b/tests/test_deepcopy.py index 9441edd..f43fa4f 100644 --- a/tests/test_deepcopy.py +++ b/tests/test_deepcopy.py @@ -1,4 +1,4 @@ -from opencode._utils import deepcopy_minimal +from opencode_ai._utils import deepcopy_minimal def assert_different_identities(obj1: object, obj2: object) -> None: diff --git a/tests/test_extract_files.py b/tests/test_extract_files.py index aafd30a..1fc490b 100644 --- a/tests/test_extract_files.py +++ b/tests/test_extract_files.py @@ -4,8 +4,8 @@ import pytest -from opencode._types import FileTypes -from opencode._utils import extract_files +from opencode_ai._types import FileTypes +from opencode_ai._utils import extract_files def test_removes_files_from_input() -> None: diff --git a/tests/test_files.py b/tests/test_files.py index 37b608d..6aec2c3 100644 --- a/tests/test_files.py +++ b/tests/test_files.py @@ -4,7 +4,7 @@ import pytest from dirty_equals import IsDict, IsList, IsBytes, IsTuple -from opencode._files import to_httpx_files, async_to_httpx_files +from opencode_ai._files import to_httpx_files, async_to_httpx_files readme_path = Path(__file__).parent.parent.joinpath("README.md") diff --git a/tests/test_models.py b/tests/test_models.py index aa90966..6776dbd 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -7,9 +7,9 @@ import pydantic from pydantic import Field -from opencode._utils import PropertyInfo -from opencode._compat import PYDANTIC_V2, parse_obj, model_dump, model_json -from opencode._models import BaseModel, construct_type +from opencode_ai._utils import PropertyInfo +from opencode_ai._compat import PYDANTIC_V2, parse_obj, model_dump, model_json +from opencode_ai._models import BaseModel, construct_type class BasicModel(BaseModel): diff --git a/tests/test_qs.py b/tests/test_qs.py index ce566b0..876a71f 100644 --- a/tests/test_qs.py +++ b/tests/test_qs.py @@ -4,7 +4,7 @@ import pytest -from opencode._qs import Querystring, stringify +from opencode_ai._qs import Querystring, stringify def test_empty() -> None: diff --git a/tests/test_required_args.py b/tests/test_required_args.py index c6a4010..d4b6a7e 100644 --- a/tests/test_required_args.py +++ b/tests/test_required_args.py @@ -2,7 +2,7 @@ import pytest -from opencode._utils import required_args +from opencode_ai._utils import required_args def test_too_many_positional_params() -> None: diff --git a/tests/test_response.py b/tests/test_response.py index 130c423..24cd168 100644 --- a/tests/test_response.py +++ b/tests/test_response.py @@ -6,8 +6,8 @@ import pytest import pydantic -from opencode import Opencode, BaseModel, AsyncOpencode -from opencode._response import ( +from opencode_ai import Opencode, BaseModel, AsyncOpencode +from opencode_ai._response import ( APIResponse, BaseAPIResponse, AsyncAPIResponse, @@ -15,8 +15,8 @@ AsyncBinaryAPIResponse, extract_response_type, ) -from opencode._streaming import Stream -from opencode._base_client import FinalRequestOptions +from opencode_ai._streaming import Stream +from opencode_ai._base_client import FinalRequestOptions class ConcreteBaseAPIResponse(APIResponse[bytes]): ... @@ -37,7 +37,7 @@ def test_extract_response_type_direct_classes() -> None: def test_extract_response_type_direct_class_missing_type_arg() -> None: with pytest.raises( RuntimeError, - match="Expected type to have a type argument at index 0 but it did not", + match="Expected type to have a type argument at index 0 but it did not", ): extract_response_type(AsyncAPIResponse) @@ -68,7 +68,7 @@ def test_response_parse_mismatched_basemodel(client: Opencode) -> None: with pytest.raises( TypeError, - match="Pydantic models must subclass our base model type, e.g. `from opencode import BaseModel`", + match="Pydantic models must subclass our base model type, e.g. `from opencode_ai import BaseModel`", ): response.parse(to=PydanticModel) @@ -86,7 +86,7 @@ async def test_async_response_parse_mismatched_basemodel(async_client: AsyncOpen with pytest.raises( TypeError, - match="Pydantic models must subclass our base model type, e.g. `from opencode import BaseModel`", + match="Pydantic models must subclass our base model type, e.g. `from opencode_ai import BaseModel`", ): await response.parse(to=PydanticModel) diff --git a/tests/test_streaming.py b/tests/test_streaming.py index ad34b32..a3e8d4f 100644 --- a/tests/test_streaming.py +++ b/tests/test_streaming.py @@ -5,8 +5,8 @@ import httpx import pytest -from opencode import Opencode, AsyncOpencode -from opencode._streaming import Stream, AsyncStream, ServerSentEvent +from opencode_ai import Opencode, AsyncOpencode +from opencode_ai._streaming import Stream, AsyncStream, ServerSentEvent @pytest.mark.asyncio diff --git a/tests/test_transform.py b/tests/test_transform.py index 7718e97..14a6ae1 100644 --- a/tests/test_transform.py +++ b/tests/test_transform.py @@ -8,15 +8,15 @@ import pytest -from opencode._types import NOT_GIVEN, Base64FileInput -from opencode._utils import ( +from opencode_ai._types import NOT_GIVEN, Base64FileInput +from opencode_ai._utils import ( PropertyInfo, transform as _transform, parse_datetime, async_transform as _async_transform, ) -from opencode._compat import PYDANTIC_V2 -from opencode._models import BaseModel +from opencode_ai._compat import PYDANTIC_V2 +from opencode_ai._models import BaseModel _T = TypeVar("_T") diff --git a/tests/test_utils/test_proxy.py b/tests/test_utils/test_proxy.py index f4e2025..303ab41 100644 --- a/tests/test_utils/test_proxy.py +++ b/tests/test_utils/test_proxy.py @@ -2,7 +2,7 @@ from typing import Any from typing_extensions import override -from opencode._utils import LazyProxy +from opencode_ai._utils import LazyProxy class RecursiveLazyProxy(LazyProxy[Any]): diff --git a/tests/test_utils/test_typing.py b/tests/test_utils/test_typing.py index adffcc2..47ff1f5 100644 --- a/tests/test_utils/test_typing.py +++ b/tests/test_utils/test_typing.py @@ -2,7 +2,7 @@ from typing import Generic, TypeVar, cast -from opencode._utils import extract_type_var_from_base +from opencode_ai._utils import extract_type_var_from_base _T = TypeVar("_T") _T2 = TypeVar("_T2") diff --git a/tests/utils.py b/tests/utils.py index 7075829..5842949 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -8,8 +8,8 @@ from datetime import date, datetime from typing_extensions import Literal, get_args, get_origin, assert_type -from opencode._types import Omit, NoneType -from opencode._utils import ( +from opencode_ai._types import Omit, NoneType +from opencode_ai._utils import ( is_dict, is_list, is_list_type, @@ -18,8 +18,8 @@ is_annotated_type, is_type_alias_type, ) -from opencode._compat import PYDANTIC_V2, field_outer_type, get_model_fields -from opencode._models import BaseModel +from opencode_ai._compat import PYDANTIC_V2, field_outer_type, get_model_fields +from opencode_ai._models import BaseModel BaseModelT = TypeVar("BaseModelT", bound=BaseModel) From 51ba45e024cc6f51c0339dc15542f6da72edfb30 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 27 Jun 2025 14:47:39 +0000 Subject: [PATCH 2/2] release: 0.1.0-alpha.2 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 8 ++++++++ pyproject.toml | 2 +- src/opencode_ai/_version.py | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index ba6c348..f14b480 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.1" + ".": "0.1.0-alpha.2" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 64f1337..7e43daf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.1.0-alpha.2 (2025-06-27) + +Full Changelog: [v0.1.0-alpha.1...v0.1.0-alpha.2](https://github.com/sst/opencode-sdk-python/compare/v0.1.0-alpha.1...v0.1.0-alpha.2) + +### Features + +* **api:** update via SDK Studio ([a6cf7c5](https://github.com/sst/opencode-sdk-python/commit/a6cf7c5b2a411503294088428ca7918226eca161)) + ## 0.1.0-alpha.1 (2025-06-27) Full Changelog: [v0.0.1-alpha.0...v0.1.0-alpha.1](https://github.com/sst/opencode-sdk-python/compare/v0.0.1-alpha.0...v0.1.0-alpha.1) diff --git a/pyproject.toml b/pyproject.toml index fd3c571..221adc3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "opencode-ai" -version = "0.1.0-alpha.1" +version = "0.1.0-alpha.2" description = "The official Python library for the opencode API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/opencode_ai/_version.py b/src/opencode_ai/_version.py index 4d98701..24df6a8 100644 --- a/src/opencode_ai/_version.py +++ b/src/opencode_ai/_version.py @@ -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.1" # x-release-please-version +__version__ = "0.1.0-alpha.2" # x-release-please-version