opencode-python-sdk 0.2.0__py3-none-any.whl → 0.2.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. opencode/__init__.py +14 -0
  2. opencode/_aiohttp.py +44 -0
  3. opencode/_base_client.py +237 -11
  4. opencode/_client.py +115 -3
  5. opencode/_logs.py +29 -0
  6. opencode/_pagination.py +14 -0
  7. opencode/_response.py +316 -0
  8. opencode/_service.py +1018 -0
  9. opencode/resources/agent.py +63 -0
  10. opencode/resources/command.py +59 -0
  11. opencode/resources/config.py +93 -20
  12. opencode/resources/credential.py +149 -56
  13. opencode/resources/debug.py +156 -20
  14. opencode/resources/event.py +59 -0
  15. opencode/resources/experimental.py +210 -36
  16. opencode/resources/file.py +71 -0
  17. opencode/resources/form.py +59 -0
  18. opencode/resources/generate.py +59 -0
  19. opencode/resources/integration.py +538 -128
  20. opencode/resources/location.py +87 -18
  21. opencode/resources/mcp.py +252 -82
  22. opencode/resources/message.py +59 -0
  23. opencode/resources/migration.py +126 -0
  24. opencode/resources/model.py +63 -0
  25. opencode/resources/permission.py +272 -38
  26. opencode/resources/plugin.py +95 -22
  27. opencode/resources/project.py +63 -0
  28. opencode/resources/provider.py +63 -0
  29. opencode/resources/pty.py +172 -20
  30. opencode/resources/reference.py +59 -0
  31. opencode/resources/rpc.py +59 -0
  32. opencode/resources/server.py +67 -0
  33. opencode/resources/session.py +1159 -405
  34. opencode/resources/shell.py +101 -20
  35. opencode/resources/skill.py +59 -0
  36. opencode/resources/vcs.py +172 -20
  37. opencode/resources/voice.py +59 -0
  38. opencode/resources/websearch.py +63 -0
  39. opencode/resources/worktree.py +123 -40
  40. opencode/service.py +50 -0
  41. {opencode_python_sdk-0.2.0.dist-info → opencode_python_sdk-0.2.3.dist-info}/METADATA +111 -2
  42. opencode_python_sdk-0.2.3.dist-info/RECORD +67 -0
  43. opencode_python_sdk-0.2.0.dist-info/RECORD +0 -62
  44. {opencode_python_sdk-0.2.0.dist-info → opencode_python_sdk-0.2.3.dist-info}/WHEEL +0 -0
  45. {opencode_python_sdk-0.2.0.dist-info → opencode_python_sdk-0.2.3.dist-info}/licenses/LICENSE +0 -0
@@ -5,10 +5,17 @@
5
5
 
6
6
  from __future__ import annotations
7
7
 
8
+ from functools import cached_property
8
9
  from typing import TYPE_CHECKING, cast
9
10
 
10
11
  from .._base_client import RequestOptions
11
12
  from .._resource import AsyncAPIResource, SyncAPIResource
13
+ from .._response import (
14
+ async_to_raw_response_wrapper,
15
+ async_to_streamed_response_wrapper,
16
+ to_raw_response_wrapper,
17
+ to_streamed_response_wrapper,
18
+ )
12
19
  from .._types import NOT_GIVEN, Body, Headers, NotGiven, Query, Timeout
13
20
 
14
21
  if TYPE_CHECKING:
@@ -23,6 +30,16 @@ __all__ = ["LocationResource", "AsyncLocationResource"]
23
30
  class LocationResource(SyncAPIResource):
24
31
  """Operations under ``client.location`` (OpenCode ``location``)."""
25
32
 
33
+ @cached_property
34
+ def with_raw_response(self) -> LocationResourceWithRawResponse:
35
+ """Same methods, returning the raw HTTP response; call ``.parse()`` on it for the usual value."""
36
+ return LocationResourceWithRawResponse(self)
37
+
38
+ @cached_property
39
+ def with_streaming_response(self) -> LocationResourceWithStreamingResponse:
40
+ """Same methods, returning a context manager over the HTTP response without reading the body."""
41
+ return LocationResourceWithStreamingResponse(self)
42
+
26
43
  def get(
27
44
  self,
28
45
  *,
@@ -78,22 +95,53 @@ class LocationResource(SyncAPIResource):
78
95
 
79
96
  ``POST /api/location/reload``
80
97
  """
81
- self._client.request(
82
- RequestOptions(
83
- method="POST",
84
- path="/api/location/reload",
85
- extra_headers=extra_headers,
86
- extra_query=extra_query,
87
- extra_body=extra_body,
88
- timeout=timeout,
98
+ return cast(
99
+ "None",
100
+ self._client.request(
101
+ RequestOptions(
102
+ method="POST",
103
+ path="/api/location/reload",
104
+ extra_headers=extra_headers,
105
+ extra_query=extra_query,
106
+ extra_body=extra_body,
107
+ timeout=timeout,
108
+ ),
109
+ kind="void",
89
110
  ),
90
- kind="void",
91
111
  )
92
112
 
93
113
 
114
+ class LocationResourceWithRawResponse:
115
+ """``client.location.with_raw_response``."""
116
+
117
+ def __init__(self, resource: LocationResource) -> None:
118
+ self._resource = resource
119
+ self.get = to_raw_response_wrapper(resource.get)
120
+ self.reload = to_raw_response_wrapper(resource.reload)
121
+
122
+
123
+ class LocationResourceWithStreamingResponse:
124
+ """``client.location.with_streaming_response``."""
125
+
126
+ def __init__(self, resource: LocationResource) -> None:
127
+ self._resource = resource
128
+ self.get = to_streamed_response_wrapper(resource.get)
129
+ self.reload = to_streamed_response_wrapper(resource.reload)
130
+
131
+
94
132
  class AsyncLocationResource(AsyncAPIResource):
95
133
  """Operations under ``client.location`` (OpenCode ``location``)."""
96
134
 
135
+ @cached_property
136
+ def with_raw_response(self) -> AsyncLocationResourceWithRawResponse:
137
+ """Same methods, returning the raw HTTP response; call ``.parse()`` on it for the usual value."""
138
+ return AsyncLocationResourceWithRawResponse(self)
139
+
140
+ @cached_property
141
+ def with_streaming_response(self) -> AsyncLocationResourceWithStreamingResponse:
142
+ """Same methods, returning a context manager over the HTTP response without reading the body."""
143
+ return AsyncLocationResourceWithStreamingResponse(self)
144
+
97
145
  async def get(
98
146
  self,
99
147
  *,
@@ -149,14 +197,35 @@ class AsyncLocationResource(AsyncAPIResource):
149
197
 
150
198
  ``POST /api/location/reload``
151
199
  """
152
- await self._client.request(
153
- RequestOptions(
154
- method="POST",
155
- path="/api/location/reload",
156
- extra_headers=extra_headers,
157
- extra_query=extra_query,
158
- extra_body=extra_body,
159
- timeout=timeout,
200
+ return cast(
201
+ "None",
202
+ await self._client.request(
203
+ RequestOptions(
204
+ method="POST",
205
+ path="/api/location/reload",
206
+ extra_headers=extra_headers,
207
+ extra_query=extra_query,
208
+ extra_body=extra_body,
209
+ timeout=timeout,
210
+ ),
211
+ kind="void",
160
212
  ),
161
- kind="void",
162
213
  )
214
+
215
+
216
+ class AsyncLocationResourceWithRawResponse:
217
+ """``client.location.with_raw_response``."""
218
+
219
+ def __init__(self, resource: AsyncLocationResource) -> None:
220
+ self._resource = resource
221
+ self.get = async_to_raw_response_wrapper(resource.get)
222
+ self.reload = async_to_raw_response_wrapper(resource.reload)
223
+
224
+
225
+ class AsyncLocationResourceWithStreamingResponse:
226
+ """``client.location.with_streaming_response``."""
227
+
228
+ def __init__(self, resource: AsyncLocationResource) -> None:
229
+ self._resource = resource
230
+ self.get = async_to_streamed_response_wrapper(resource.get)
231
+ self.reload = async_to_streamed_response_wrapper(resource.reload)
opencode/resources/mcp.py CHANGED
@@ -11,6 +11,12 @@ from typing import TYPE_CHECKING, cast
11
11
  from .._base_client import RequestOptions
12
12
  from .._qs import encode_path_segment
13
13
  from .._resource import AsyncAPIResource, SyncAPIResource
14
+ from .._response import (
15
+ async_to_raw_response_wrapper,
16
+ async_to_streamed_response_wrapper,
17
+ to_raw_response_wrapper,
18
+ to_streamed_response_wrapper,
19
+ )
14
20
  from .._types import NOT_GIVEN, Body, Headers, NotGiven, Query, Timeout
15
21
 
16
22
  if TYPE_CHECKING:
@@ -27,6 +33,16 @@ __all__ = ["McpResource", "AsyncMcpResource"]
27
33
  class McpResourceResource(SyncAPIResource):
28
34
  """Operations under ``client.mcp.resource`` (OpenCode ``mcp.resource``)."""
29
35
 
36
+ @cached_property
37
+ def with_raw_response(self) -> McpResourceResourceWithRawResponse:
38
+ """Same methods, returning the raw HTTP response; call ``.parse()`` on it for the usual value."""
39
+ return McpResourceResourceWithRawResponse(self)
40
+
41
+ @cached_property
42
+ def with_streaming_response(self) -> McpResourceResourceWithStreamingResponse:
43
+ """Same methods, returning a context manager over the HTTP response without reading the body."""
44
+ return McpResourceResourceWithStreamingResponse(self)
45
+
30
46
  def catalog(
31
47
  self,
32
48
  *,
@@ -64,6 +80,22 @@ class McpResourceResource(SyncAPIResource):
64
80
  )
65
81
 
66
82
 
83
+ class McpResourceResourceWithRawResponse:
84
+ """``client.mcp.resource.with_raw_response``."""
85
+
86
+ def __init__(self, resource: McpResourceResource) -> None:
87
+ self._resource = resource
88
+ self.catalog = to_raw_response_wrapper(resource.catalog)
89
+
90
+
91
+ class McpResourceResourceWithStreamingResponse:
92
+ """``client.mcp.resource.with_streaming_response``."""
93
+
94
+ def __init__(self, resource: McpResourceResource) -> None:
95
+ self._resource = resource
96
+ self.catalog = to_streamed_response_wrapper(resource.catalog)
97
+
98
+
67
99
  class McpResource(SyncAPIResource):
68
100
  """Operations under ``client.mcp`` (OpenCode ``mcp``)."""
69
101
 
@@ -72,6 +104,16 @@ class McpResource(SyncAPIResource):
72
104
  """Operations under ``client.mcp.resource``."""
73
105
  return McpResourceResource(self._client)
74
106
 
107
+ @cached_property
108
+ def with_raw_response(self) -> McpResourceWithRawResponse:
109
+ """Same methods, returning the raw HTTP response; call ``.parse()`` on it for the usual value."""
110
+ return McpResourceWithRawResponse(self)
111
+
112
+ @cached_property
113
+ def with_streaming_response(self) -> McpResourceWithStreamingResponse:
114
+ """Same methods, returning a context manager over the HTTP response without reading the body."""
115
+ return McpResourceWithStreamingResponse(self)
116
+
75
117
  def list(
76
118
  self,
77
119
  *,
@@ -132,18 +174,21 @@ class McpResource(SyncAPIResource):
132
174
 
133
175
  ``PUT /api/experimental/mcp/:server``
134
176
  """
135
- self._client.request(
136
- RequestOptions(
137
- method="PUT",
138
- path=f"/api/experimental/mcp/{encode_path_segment(server)}",
139
- query={"location": self._location(location)},
140
- body={"config": config},
141
- extra_headers=extra_headers,
142
- extra_query=extra_query,
143
- extra_body=extra_body,
144
- timeout=timeout,
177
+ return cast(
178
+ "None",
179
+ self._client.request(
180
+ RequestOptions(
181
+ method="PUT",
182
+ path=f"/api/experimental/mcp/{encode_path_segment(server)}",
183
+ query={"location": self._location(location)},
184
+ body={"config": config},
185
+ extra_headers=extra_headers,
186
+ extra_query=extra_query,
187
+ extra_body=extra_body,
188
+ timeout=timeout,
189
+ ),
190
+ kind="void",
145
191
  ),
146
- kind="void",
147
192
  )
148
193
 
149
194
  def remove(
@@ -170,17 +215,20 @@ class McpResource(SyncAPIResource):
170
215
 
171
216
  ``DELETE /api/experimental/mcp/:server``
172
217
  """
173
- self._client.request(
174
- RequestOptions(
175
- method="DELETE",
176
- path=f"/api/experimental/mcp/{encode_path_segment(server)}",
177
- query={"location": self._location(location)},
178
- extra_headers=extra_headers,
179
- extra_query=extra_query,
180
- extra_body=extra_body,
181
- timeout=timeout,
218
+ return cast(
219
+ "None",
220
+ self._client.request(
221
+ RequestOptions(
222
+ method="DELETE",
223
+ path=f"/api/experimental/mcp/{encode_path_segment(server)}",
224
+ query={"location": self._location(location)},
225
+ extra_headers=extra_headers,
226
+ extra_query=extra_query,
227
+ extra_body=extra_body,
228
+ timeout=timeout,
229
+ ),
230
+ kind="void",
182
231
  ),
183
- kind="void",
184
232
  )
185
233
 
186
234
  def connect(
@@ -207,17 +255,20 @@ class McpResource(SyncAPIResource):
207
255
 
208
256
  ``POST /api/experimental/mcp/:server/connect``
209
257
  """
210
- self._client.request(
211
- RequestOptions(
212
- method="POST",
213
- path=f"/api/experimental/mcp/{encode_path_segment(server)}/connect",
214
- query={"location": self._location(location)},
215
- extra_headers=extra_headers,
216
- extra_query=extra_query,
217
- extra_body=extra_body,
218
- timeout=timeout,
258
+ return cast(
259
+ "None",
260
+ self._client.request(
261
+ RequestOptions(
262
+ method="POST",
263
+ path=f"/api/experimental/mcp/{encode_path_segment(server)}/connect",
264
+ query={"location": self._location(location)},
265
+ extra_headers=extra_headers,
266
+ extra_query=extra_query,
267
+ extra_body=extra_body,
268
+ timeout=timeout,
269
+ ),
270
+ kind="void",
219
271
  ),
220
- kind="void",
221
272
  )
222
273
 
223
274
  def disconnect(
@@ -244,23 +295,70 @@ class McpResource(SyncAPIResource):
244
295
 
245
296
  ``POST /api/experimental/mcp/:server/disconnect``
246
297
  """
247
- self._client.request(
248
- RequestOptions(
249
- method="POST",
250
- path=f"/api/experimental/mcp/{encode_path_segment(server)}/disconnect",
251
- query={"location": self._location(location)},
252
- extra_headers=extra_headers,
253
- extra_query=extra_query,
254
- extra_body=extra_body,
255
- timeout=timeout,
298
+ return cast(
299
+ "None",
300
+ self._client.request(
301
+ RequestOptions(
302
+ method="POST",
303
+ path=f"/api/experimental/mcp/{encode_path_segment(server)}/disconnect",
304
+ query={"location": self._location(location)},
305
+ extra_headers=extra_headers,
306
+ extra_query=extra_query,
307
+ extra_body=extra_body,
308
+ timeout=timeout,
309
+ ),
310
+ kind="void",
256
311
  ),
257
- kind="void",
258
312
  )
259
313
 
260
314
 
315
+ class McpResourceWithRawResponse:
316
+ """``client.mcp.with_raw_response``."""
317
+
318
+ def __init__(self, resource: McpResource) -> None:
319
+ self._resource = resource
320
+ self.list = to_raw_response_wrapper(resource.list)
321
+ self.add = to_raw_response_wrapper(resource.add)
322
+ self.remove = to_raw_response_wrapper(resource.remove)
323
+ self.connect = to_raw_response_wrapper(resource.connect)
324
+ self.disconnect = to_raw_response_wrapper(resource.disconnect)
325
+
326
+ @cached_property
327
+ def resource(self) -> McpResourceResourceWithRawResponse:
328
+ """``client.mcp.resource.with_raw_response``."""
329
+ return McpResourceResourceWithRawResponse(self._resource.resource)
330
+
331
+
332
+ class McpResourceWithStreamingResponse:
333
+ """``client.mcp.with_streaming_response``."""
334
+
335
+ def __init__(self, resource: McpResource) -> None:
336
+ self._resource = resource
337
+ self.list = to_streamed_response_wrapper(resource.list)
338
+ self.add = to_streamed_response_wrapper(resource.add)
339
+ self.remove = to_streamed_response_wrapper(resource.remove)
340
+ self.connect = to_streamed_response_wrapper(resource.connect)
341
+ self.disconnect = to_streamed_response_wrapper(resource.disconnect)
342
+
343
+ @cached_property
344
+ def resource(self) -> McpResourceResourceWithStreamingResponse:
345
+ """``client.mcp.resource.with_streaming_response``."""
346
+ return McpResourceResourceWithStreamingResponse(self._resource.resource)
347
+
348
+
261
349
  class AsyncMcpResourceResource(AsyncAPIResource):
262
350
  """Operations under ``client.mcp.resource`` (OpenCode ``mcp.resource``)."""
263
351
 
352
+ @cached_property
353
+ def with_raw_response(self) -> AsyncMcpResourceResourceWithRawResponse:
354
+ """Same methods, returning the raw HTTP response; call ``.parse()`` on it for the usual value."""
355
+ return AsyncMcpResourceResourceWithRawResponse(self)
356
+
357
+ @cached_property
358
+ def with_streaming_response(self) -> AsyncMcpResourceResourceWithStreamingResponse:
359
+ """Same methods, returning a context manager over the HTTP response without reading the body."""
360
+ return AsyncMcpResourceResourceWithStreamingResponse(self)
361
+
264
362
  async def catalog(
265
363
  self,
266
364
  *,
@@ -298,6 +396,22 @@ class AsyncMcpResourceResource(AsyncAPIResource):
298
396
  )
299
397
 
300
398
 
399
+ class AsyncMcpResourceResourceWithRawResponse:
400
+ """``client.mcp.resource.with_raw_response``."""
401
+
402
+ def __init__(self, resource: AsyncMcpResourceResource) -> None:
403
+ self._resource = resource
404
+ self.catalog = async_to_raw_response_wrapper(resource.catalog)
405
+
406
+
407
+ class AsyncMcpResourceResourceWithStreamingResponse:
408
+ """``client.mcp.resource.with_streaming_response``."""
409
+
410
+ def __init__(self, resource: AsyncMcpResourceResource) -> None:
411
+ self._resource = resource
412
+ self.catalog = async_to_streamed_response_wrapper(resource.catalog)
413
+
414
+
301
415
  class AsyncMcpResource(AsyncAPIResource):
302
416
  """Operations under ``client.mcp`` (OpenCode ``mcp``)."""
303
417
 
@@ -306,6 +420,16 @@ class AsyncMcpResource(AsyncAPIResource):
306
420
  """Operations under ``client.mcp.resource``."""
307
421
  return AsyncMcpResourceResource(self._client)
308
422
 
423
+ @cached_property
424
+ def with_raw_response(self) -> AsyncMcpResourceWithRawResponse:
425
+ """Same methods, returning the raw HTTP response; call ``.parse()`` on it for the usual value."""
426
+ return AsyncMcpResourceWithRawResponse(self)
427
+
428
+ @cached_property
429
+ def with_streaming_response(self) -> AsyncMcpResourceWithStreamingResponse:
430
+ """Same methods, returning a context manager over the HTTP response without reading the body."""
431
+ return AsyncMcpResourceWithStreamingResponse(self)
432
+
309
433
  async def list(
310
434
  self,
311
435
  *,
@@ -366,18 +490,21 @@ class AsyncMcpResource(AsyncAPIResource):
366
490
 
367
491
  ``PUT /api/experimental/mcp/:server``
368
492
  """
369
- await self._client.request(
370
- RequestOptions(
371
- method="PUT",
372
- path=f"/api/experimental/mcp/{encode_path_segment(server)}",
373
- query={"location": self._location(location)},
374
- body={"config": config},
375
- extra_headers=extra_headers,
376
- extra_query=extra_query,
377
- extra_body=extra_body,
378
- timeout=timeout,
493
+ return cast(
494
+ "None",
495
+ await self._client.request(
496
+ RequestOptions(
497
+ method="PUT",
498
+ path=f"/api/experimental/mcp/{encode_path_segment(server)}",
499
+ query={"location": self._location(location)},
500
+ body={"config": config},
501
+ extra_headers=extra_headers,
502
+ extra_query=extra_query,
503
+ extra_body=extra_body,
504
+ timeout=timeout,
505
+ ),
506
+ kind="void",
379
507
  ),
380
- kind="void",
381
508
  )
382
509
 
383
510
  async def remove(
@@ -404,17 +531,20 @@ class AsyncMcpResource(AsyncAPIResource):
404
531
 
405
532
  ``DELETE /api/experimental/mcp/:server``
406
533
  """
407
- await self._client.request(
408
- RequestOptions(
409
- method="DELETE",
410
- path=f"/api/experimental/mcp/{encode_path_segment(server)}",
411
- query={"location": self._location(location)},
412
- extra_headers=extra_headers,
413
- extra_query=extra_query,
414
- extra_body=extra_body,
415
- timeout=timeout,
534
+ return cast(
535
+ "None",
536
+ await self._client.request(
537
+ RequestOptions(
538
+ method="DELETE",
539
+ path=f"/api/experimental/mcp/{encode_path_segment(server)}",
540
+ query={"location": self._location(location)},
541
+ extra_headers=extra_headers,
542
+ extra_query=extra_query,
543
+ extra_body=extra_body,
544
+ timeout=timeout,
545
+ ),
546
+ kind="void",
416
547
  ),
417
- kind="void",
418
548
  )
419
549
 
420
550
  async def connect(
@@ -441,17 +571,20 @@ class AsyncMcpResource(AsyncAPIResource):
441
571
 
442
572
  ``POST /api/experimental/mcp/:server/connect``
443
573
  """
444
- await self._client.request(
445
- RequestOptions(
446
- method="POST",
447
- path=f"/api/experimental/mcp/{encode_path_segment(server)}/connect",
448
- query={"location": self._location(location)},
449
- extra_headers=extra_headers,
450
- extra_query=extra_query,
451
- extra_body=extra_body,
452
- timeout=timeout,
574
+ return cast(
575
+ "None",
576
+ await self._client.request(
577
+ RequestOptions(
578
+ method="POST",
579
+ path=f"/api/experimental/mcp/{encode_path_segment(server)}/connect",
580
+ query={"location": self._location(location)},
581
+ extra_headers=extra_headers,
582
+ extra_query=extra_query,
583
+ extra_body=extra_body,
584
+ timeout=timeout,
585
+ ),
586
+ kind="void",
453
587
  ),
454
- kind="void",
455
588
  )
456
589
 
457
590
  async def disconnect(
@@ -478,15 +611,52 @@ class AsyncMcpResource(AsyncAPIResource):
478
611
 
479
612
  ``POST /api/experimental/mcp/:server/disconnect``
480
613
  """
481
- await self._client.request(
482
- RequestOptions(
483
- method="POST",
484
- path=f"/api/experimental/mcp/{encode_path_segment(server)}/disconnect",
485
- query={"location": self._location(location)},
486
- extra_headers=extra_headers,
487
- extra_query=extra_query,
488
- extra_body=extra_body,
489
- timeout=timeout,
614
+ return cast(
615
+ "None",
616
+ await self._client.request(
617
+ RequestOptions(
618
+ method="POST",
619
+ path=f"/api/experimental/mcp/{encode_path_segment(server)}/disconnect",
620
+ query={"location": self._location(location)},
621
+ extra_headers=extra_headers,
622
+ extra_query=extra_query,
623
+ extra_body=extra_body,
624
+ timeout=timeout,
625
+ ),
626
+ kind="void",
490
627
  ),
491
- kind="void",
492
628
  )
629
+
630
+
631
+ class AsyncMcpResourceWithRawResponse:
632
+ """``client.mcp.with_raw_response``."""
633
+
634
+ def __init__(self, resource: AsyncMcpResource) -> None:
635
+ self._resource = resource
636
+ self.list = async_to_raw_response_wrapper(resource.list)
637
+ self.add = async_to_raw_response_wrapper(resource.add)
638
+ self.remove = async_to_raw_response_wrapper(resource.remove)
639
+ self.connect = async_to_raw_response_wrapper(resource.connect)
640
+ self.disconnect = async_to_raw_response_wrapper(resource.disconnect)
641
+
642
+ @cached_property
643
+ def resource(self) -> AsyncMcpResourceResourceWithRawResponse:
644
+ """``client.mcp.resource.with_raw_response``."""
645
+ return AsyncMcpResourceResourceWithRawResponse(self._resource.resource)
646
+
647
+
648
+ class AsyncMcpResourceWithStreamingResponse:
649
+ """``client.mcp.with_streaming_response``."""
650
+
651
+ def __init__(self, resource: AsyncMcpResource) -> None:
652
+ self._resource = resource
653
+ self.list = async_to_streamed_response_wrapper(resource.list)
654
+ self.add = async_to_streamed_response_wrapper(resource.add)
655
+ self.remove = async_to_streamed_response_wrapper(resource.remove)
656
+ self.connect = async_to_streamed_response_wrapper(resource.connect)
657
+ self.disconnect = async_to_streamed_response_wrapper(resource.disconnect)
658
+
659
+ @cached_property
660
+ def resource(self) -> AsyncMcpResourceResourceWithStreamingResponse:
661
+ """``client.mcp.resource.with_streaming_response``."""
662
+ return AsyncMcpResourceResourceWithStreamingResponse(self._resource.resource)
@@ -5,12 +5,19 @@
5
5
 
6
6
  from __future__ import annotations
7
7
 
8
+ from functools import cached_property
8
9
  from typing import TYPE_CHECKING, Literal
9
10
 
10
11
  from .._base_client import RequestOptions
11
12
  from .._pagination import AsyncPaginator, SyncCursorPage
12
13
  from .._qs import encode_path_segment
13
14
  from .._resource import AsyncAPIResource, SyncAPIResource
15
+ from .._response import (
16
+ async_to_raw_response_wrapper,
17
+ async_to_streamed_response_wrapper,
18
+ to_raw_response_wrapper,
19
+ to_streamed_response_wrapper,
20
+ )
14
21
  from .._types import NOT_GIVEN, Body, Headers, NotGiven, OpenEnum, Query, Timeout
15
22
 
16
23
  if TYPE_CHECKING:
@@ -25,6 +32,16 @@ __all__ = ["MessageResource", "AsyncMessageResource"]
25
32
  class MessageResource(SyncAPIResource):
26
33
  """Operations under ``client.message`` (OpenCode ``message``)."""
27
34
 
35
+ @cached_property
36
+ def with_raw_response(self) -> MessageResourceWithRawResponse:
37
+ """Same methods, returning the raw HTTP response; call ``.parse()`` on it for the usual value."""
38
+ return MessageResourceWithRawResponse(self)
39
+
40
+ @cached_property
41
+ def with_streaming_response(self) -> MessageResourceWithStreamingResponse:
42
+ """Same methods, returning a context manager over the HTTP response without reading the body."""
43
+ return MessageResourceWithStreamingResponse(self)
44
+
28
45
  def list(
29
46
  self,
30
47
  session_id: SessionID,
@@ -87,9 +104,35 @@ class MessageResource(SyncAPIResource):
87
104
  )
88
105
 
89
106
 
107
+ class MessageResourceWithRawResponse:
108
+ """``client.message.with_raw_response``."""
109
+
110
+ def __init__(self, resource: MessageResource) -> None:
111
+ self._resource = resource
112
+ self.list = to_raw_response_wrapper(resource.list)
113
+
114
+
115
+ class MessageResourceWithStreamingResponse:
116
+ """``client.message.with_streaming_response``."""
117
+
118
+ def __init__(self, resource: MessageResource) -> None:
119
+ self._resource = resource
120
+ self.list = to_streamed_response_wrapper(resource.list)
121
+
122
+
90
123
  class AsyncMessageResource(AsyncAPIResource):
91
124
  """Operations under ``client.message`` (OpenCode ``message``)."""
92
125
 
126
+ @cached_property
127
+ def with_raw_response(self) -> AsyncMessageResourceWithRawResponse:
128
+ """Same methods, returning the raw HTTP response; call ``.parse()`` on it for the usual value."""
129
+ return AsyncMessageResourceWithRawResponse(self)
130
+
131
+ @cached_property
132
+ def with_streaming_response(self) -> AsyncMessageResourceWithStreamingResponse:
133
+ """Same methods, returning a context manager over the HTTP response without reading the body."""
134
+ return AsyncMessageResourceWithStreamingResponse(self)
135
+
93
136
  def list(
94
137
  self,
95
138
  session_id: SessionID,
@@ -150,3 +193,19 @@ class AsyncMessageResource(AsyncAPIResource):
150
193
  ),
151
194
  response_type="SessionMessagesResponse",
152
195
  )
196
+
197
+
198
+ class AsyncMessageResourceWithRawResponse:
199
+ """``client.message.with_raw_response``."""
200
+
201
+ def __init__(self, resource: AsyncMessageResource) -> None:
202
+ self._resource = resource
203
+ self.list = async_to_raw_response_wrapper(resource.list)
204
+
205
+
206
+ class AsyncMessageResourceWithStreamingResponse:
207
+ """``client.message.with_streaming_response``."""
208
+
209
+ def __init__(self, resource: AsyncMessageResource) -> None:
210
+ self._resource = resource
211
+ self.list = async_to_streamed_response_wrapper(resource.list)