Skip to content

Commit a51d627

Browse files
feat(api): api update
1 parent 730f1be commit a51d627

43 files changed

Lines changed: 973 additions & 240 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 20
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-15eeb028f79b9a065b4e54a6ea6a58631e9bd5004f97820f0c79d18e3f8bac84.yml
3-
openapi_spec_hash: 38c8bacb6c8e4c46852a3e81e3fb9fda
4-
config_hash: 348a85e725de595ca05a61f4333794ac
1+
configured_endpoints: 22
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-05150c78e0e6e97b0ce97ed685ebcf1cb01dc839beccb99e9d3ead5b783cfd47.yml
3+
openapi_spec_hash: 833a5b6d53d98dc2beac2c4c394b20d5
4+
config_hash: 3695cfc829cfaae14490850b4a1ed282

api.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Shared Types
22

33
```python
4-
from opencode_ai.types import ProviderAuthError, UnknownError
4+
from opencode_ai.types import MessageAbortedError, ProviderAuthError, UnknownError
55
```
66

77
# Event
@@ -21,20 +21,28 @@ Methods:
2121
Types:
2222

2323
```python
24-
from opencode_ai.types import App, AppInitResponse
24+
from opencode_ai.types import App, LogLevel, Mode, AppInitResponse, AppLogResponse, AppModesResponse
2525
```
2626

2727
Methods:
2828

2929
- <code title="get /app">client.app.<a href="./src/opencode_ai/resources/app.py">get</a>() -> <a href="./src/opencode_ai/types/app.py">App</a></code>
3030
- <code title="post /app/init">client.app.<a href="./src/opencode_ai/resources/app.py">init</a>() -> <a href="./src/opencode_ai/types/app_init_response.py">AppInitResponse</a></code>
31+
- <code title="post /log">client.app.<a href="./src/opencode_ai/resources/app.py">log</a>(\*\*<a href="src/opencode_ai/types/app_log_params.py">params</a>) -> <a href="./src/opencode_ai/types/app_log_response.py">AppLogResponse</a></code>
32+
- <code title="get /mode">client.app.<a href="./src/opencode_ai/resources/app.py">modes</a>() -> <a href="./src/opencode_ai/types/app_modes_response.py">AppModesResponse</a></code>
3133

3234
# Find
3335

3436
Types:
3537

3638
```python
37-
from opencode_ai.types import FindFilesResponse, FindSymbolsResponse, FindTextResponse
39+
from opencode_ai.types import (
40+
Match,
41+
Symbol,
42+
FindFilesResponse,
43+
FindSymbolsResponse,
44+
FindTextResponse,
45+
)
3846
```
3947

4048
Methods:
@@ -48,7 +56,7 @@ Methods:
4856
Types:
4957

5058
```python
51-
from opencode_ai.types import FileReadResponse, FileStatusResponse
59+
from opencode_ai.types import File, FileReadResponse, FileStatusResponse
5260
```
5361

5462
Methods:
@@ -84,18 +92,19 @@ Types:
8492
```python
8593
from opencode_ai.types import (
8694
AssistantMessage,
87-
AssistantMessagePart,
8895
FilePart,
8996
Message,
97+
Part,
9098
Session,
99+
StepFinishPart,
91100
StepStartPart,
92101
TextPart,
93102
ToolPart,
94103
ToolStateCompleted,
95104
ToolStateError,
96105
ToolStatePending,
97106
ToolStateRunning,
98-
UserMessagePart,
107+
UserMessage,
99108
SessionListResponse,
100109
SessionDeleteResponse,
101110
SessionAbortResponse,

src/opencode_ai/resources/app.py

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22

33
from __future__ import annotations
44

5+
from typing import Dict
6+
from typing_extensions import Literal
7+
58
import httpx
69

10+
from ..types import app_log_params
711
from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
12+
from .._utils import maybe_transform, async_maybe_transform
813
from .._compat import cached_property
914
from .._resource import SyncAPIResource, AsyncAPIResource
1015
from .._response import (
@@ -15,7 +20,9 @@
1520
)
1621
from ..types.app import App
1722
from .._base_client import make_request_options
23+
from ..types.app_log_response import AppLogResponse
1824
from ..types.app_init_response import AppInitResponse
25+
from ..types.app_modes_response import AppModesResponse
1926

2027
__all__ = ["AppResource", "AsyncAppResource"]
2128

@@ -78,6 +85,76 @@ def init(
7885
cast_to=AppInitResponse,
7986
)
8087

88+
def log(
89+
self,
90+
*,
91+
level: Literal["debug", "info", "error", "warn"],
92+
message: str,
93+
service: str,
94+
extra: Dict[str, object] | NotGiven = NOT_GIVEN,
95+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
96+
# The extra values given here take precedence over values defined on the client or passed to this method.
97+
extra_headers: Headers | None = None,
98+
extra_query: Query | None = None,
99+
extra_body: Body | None = None,
100+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
101+
) -> AppLogResponse:
102+
"""
103+
Write a log entry to the server logs
104+
105+
Args:
106+
level: Log level
107+
108+
message: Log message
109+
110+
service: Service name for the log entry
111+
112+
extra: Additional metadata for the log entry
113+
114+
extra_headers: Send extra headers
115+
116+
extra_query: Add additional query parameters to the request
117+
118+
extra_body: Add additional JSON properties to the request
119+
120+
timeout: Override the client-level default timeout for this request, in seconds
121+
"""
122+
return self._post(
123+
"/log",
124+
body=maybe_transform(
125+
{
126+
"level": level,
127+
"message": message,
128+
"service": service,
129+
"extra": extra,
130+
},
131+
app_log_params.AppLogParams,
132+
),
133+
options=make_request_options(
134+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
135+
),
136+
cast_to=AppLogResponse,
137+
)
138+
139+
def modes(
140+
self,
141+
*,
142+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
143+
# The extra values given here take precedence over values defined on the client or passed to this method.
144+
extra_headers: Headers | None = None,
145+
extra_query: Query | None = None,
146+
extra_body: Body | None = None,
147+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
148+
) -> AppModesResponse:
149+
"""List all modes"""
150+
return self._get(
151+
"/mode",
152+
options=make_request_options(
153+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
154+
),
155+
cast_to=AppModesResponse,
156+
)
157+
81158

82159
class AsyncAppResource(AsyncAPIResource):
83160
@cached_property
@@ -137,6 +214,76 @@ async def init(
137214
cast_to=AppInitResponse,
138215
)
139216

217+
async def log(
218+
self,
219+
*,
220+
level: Literal["debug", "info", "error", "warn"],
221+
message: str,
222+
service: str,
223+
extra: Dict[str, object] | NotGiven = NOT_GIVEN,
224+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
225+
# The extra values given here take precedence over values defined on the client or passed to this method.
226+
extra_headers: Headers | None = None,
227+
extra_query: Query | None = None,
228+
extra_body: Body | None = None,
229+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
230+
) -> AppLogResponse:
231+
"""
232+
Write a log entry to the server logs
233+
234+
Args:
235+
level: Log level
236+
237+
message: Log message
238+
239+
service: Service name for the log entry
240+
241+
extra: Additional metadata for the log entry
242+
243+
extra_headers: Send extra headers
244+
245+
extra_query: Add additional query parameters to the request
246+
247+
extra_body: Add additional JSON properties to the request
248+
249+
timeout: Override the client-level default timeout for this request, in seconds
250+
"""
251+
return await self._post(
252+
"/log",
253+
body=await async_maybe_transform(
254+
{
255+
"level": level,
256+
"message": message,
257+
"service": service,
258+
"extra": extra,
259+
},
260+
app_log_params.AppLogParams,
261+
),
262+
options=make_request_options(
263+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
264+
),
265+
cast_to=AppLogResponse,
266+
)
267+
268+
async def modes(
269+
self,
270+
*,
271+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
272+
# The extra values given here take precedence over values defined on the client or passed to this method.
273+
extra_headers: Headers | None = None,
274+
extra_query: Query | None = None,
275+
extra_body: Body | None = None,
276+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
277+
) -> AppModesResponse:
278+
"""List all modes"""
279+
return await self._get(
280+
"/mode",
281+
options=make_request_options(
282+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
283+
),
284+
cast_to=AppModesResponse,
285+
)
286+
140287

141288
class AppResourceWithRawResponse:
142289
def __init__(self, app: AppResource) -> None:
@@ -148,6 +295,12 @@ def __init__(self, app: AppResource) -> None:
148295
self.init = to_raw_response_wrapper(
149296
app.init,
150297
)
298+
self.log = to_raw_response_wrapper(
299+
app.log,
300+
)
301+
self.modes = to_raw_response_wrapper(
302+
app.modes,
303+
)
151304

152305

153306
class AsyncAppResourceWithRawResponse:
@@ -160,6 +313,12 @@ def __init__(self, app: AsyncAppResource) -> None:
160313
self.init = async_to_raw_response_wrapper(
161314
app.init,
162315
)
316+
self.log = async_to_raw_response_wrapper(
317+
app.log,
318+
)
319+
self.modes = async_to_raw_response_wrapper(
320+
app.modes,
321+
)
163322

164323

165324
class AppResourceWithStreamingResponse:
@@ -172,6 +331,12 @@ def __init__(self, app: AppResource) -> None:
172331
self.init = to_streamed_response_wrapper(
173332
app.init,
174333
)
334+
self.log = to_streamed_response_wrapper(
335+
app.log,
336+
)
337+
self.modes = to_streamed_response_wrapper(
338+
app.modes,
339+
)
175340

176341

177342
class AsyncAppResourceWithStreamingResponse:
@@ -184,3 +349,9 @@ def __init__(self, app: AsyncAppResource) -> None:
184349
self.init = async_to_streamed_response_wrapper(
185350
app.init,
186351
)
352+
self.log = async_to_streamed_response_wrapper(
353+
app.log,
354+
)
355+
self.modes = async_to_streamed_response_wrapper(
356+
app.modes,
357+
)

src/opencode_ai/resources/session.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
from ..types.session_list_response import SessionListResponse
2525
from ..types.session_abort_response import SessionAbortResponse
2626
from ..types.session_delete_response import SessionDeleteResponse
27-
from ..types.user_message_part_param import UserMessagePartParam
2827
from ..types.session_messages_response import SessionMessagesResponse
2928
from ..types.session_summarize_response import SessionSummarizeResponse
3029

@@ -159,8 +158,10 @@ def chat(
159158
self,
160159
id: str,
161160
*,
161+
message_id: str,
162+
mode: str,
162163
model_id: str,
163-
parts: Iterable[UserMessagePartParam],
164+
parts: Iterable[session_chat_params.Part],
164165
provider_id: str,
165166
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
166167
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -189,6 +190,8 @@ def chat(
189190
f"/session/{id}/message",
190191
body=maybe_transform(
191192
{
193+
"message_id": message_id,
194+
"mode": mode,
192195
"model_id": model_id,
193196
"parts": parts,
194197
"provider_id": provider_id,
@@ -205,6 +208,7 @@ def init(
205208
self,
206209
id: str,
207210
*,
211+
message_id: str,
208212
model_id: str,
209213
provider_id: str,
210214
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -234,6 +238,7 @@ def init(
234238
f"/session/{id}/init",
235239
body=maybe_transform(
236240
{
241+
"message_id": message_id,
237242
"model_id": model_id,
238243
"provider_id": provider_id,
239244
},
@@ -519,8 +524,10 @@ async def chat(
519524
self,
520525
id: str,
521526
*,
527+
message_id: str,
528+
mode: str,
522529
model_id: str,
523-
parts: Iterable[UserMessagePartParam],
530+
parts: Iterable[session_chat_params.Part],
524531
provider_id: str,
525532
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
526533
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -549,6 +556,8 @@ async def chat(
549556
f"/session/{id}/message",
550557
body=await async_maybe_transform(
551558
{
559+
"message_id": message_id,
560+
"mode": mode,
552561
"model_id": model_id,
553562
"parts": parts,
554563
"provider_id": provider_id,
@@ -565,6 +574,7 @@ async def init(
565574
self,
566575
id: str,
567576
*,
577+
message_id: str,
568578
model_id: str,
569579
provider_id: str,
570580
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -594,6 +604,7 @@ async def init(
594604
f"/session/{id}/init",
595605
body=await async_maybe_transform(
596606
{
607+
"message_id": message_id,
597608
"model_id": model_id,
598609
"provider_id": provider_id,
599610
},

0 commit comments

Comments
 (0)