opencode-python-sdk 0.0.1.dev1__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 (62) hide show
  1. opencode/.generated.json +39 -0
  2. opencode/__init__.py +221 -0
  3. opencode/_base_client.py +539 -0
  4. opencode/_client.py +255 -0
  5. opencode/_constants.py +27 -0
  6. opencode/_errors.py +547 -0
  7. opencode/_events.py +732 -0
  8. opencode/_exceptions.py +271 -0
  9. opencode/_models.py +54 -0
  10. opencode/_pagination.py +192 -0
  11. opencode/_pty.py +586 -0
  12. opencode/_qs.py +95 -0
  13. opencode/_resource.py +42 -0
  14. opencode/_rpc.py +489 -0
  15. opencode/_server.py +335 -0
  16. opencode/_streaming.py +248 -0
  17. opencode/_types.py +77 -0
  18. opencode/_unions.py +46 -0
  19. opencode/_version.py +8 -0
  20. opencode/lib/__init__.py +5 -0
  21. opencode/lib/_ready.py +91 -0
  22. opencode/lib/_session.py +231 -0
  23. opencode/py.typed +0 -0
  24. opencode/resources/__init__.py +364 -0
  25. opencode/resources/agent.py +179 -0
  26. opencode/resources/command.py +100 -0
  27. opencode/resources/config.py +240 -0
  28. opencode/resources/credential.py +384 -0
  29. opencode/resources/debug.py +178 -0
  30. opencode/resources/event.py +88 -0
  31. opencode/resources/experimental.py +765 -0
  32. opencode/resources/file.py +355 -0
  33. opencode/resources/form.py +100 -0
  34. opencode/resources/generate.py +110 -0
  35. opencode/resources/integration.py +1033 -0
  36. opencode/resources/location.py +162 -0
  37. opencode/resources/mcp.py +492 -0
  38. opencode/resources/message.py +152 -0
  39. opencode/resources/migration.py +118 -0
  40. opencode/resources/model.py +177 -0
  41. opencode/resources/permission.py +704 -0
  42. opencode/resources/plugin.py +250 -0
  43. opencode/resources/project.py +187 -0
  44. opencode/resources/provider.py +183 -0
  45. opencode/resources/pty.py +522 -0
  46. opencode/resources/reference.py +100 -0
  47. opencode/resources/rpc.py +113 -0
  48. opencode/resources/server.py +230 -0
  49. opencode/resources/session.py +3567 -0
  50. opencode/resources/shell.py +412 -0
  51. opencode/resources/skill.py +100 -0
  52. opencode/resources/vcs.py +500 -0
  53. opencode/resources/voice.py +113 -0
  54. opencode/resources/websearch.py +184 -0
  55. opencode/resources/worktree.py +336 -0
  56. opencode/testing.py +508 -0
  57. opencode/types/__init__.py +1462 -0
  58. opencode/types/_generated.py +8540 -0
  59. opencode_python_sdk-0.0.1.dev1.dist-info/METADATA +468 -0
  60. opencode_python_sdk-0.0.1.dev1.dist-info/RECORD +62 -0
  61. opencode_python_sdk-0.0.1.dev1.dist-info/WHEEL +4 -0
  62. opencode_python_sdk-0.0.1.dev1.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,412 @@
1
+ # This file is generated by `python -m codegen` from spec/contract.json. Do not edit it by hand.
2
+ # OpenCode 2.1.2
3
+
4
+ """The ``shell`` resource."""
5
+
6
+ from __future__ import annotations
7
+
8
+ from collections.abc import Mapping
9
+ from typing import TYPE_CHECKING, Any, cast
10
+
11
+ from .._base_client import RequestOptions
12
+ from .._qs import encode_path_segment
13
+ from .._resource import AsyncAPIResource, SyncAPIResource
14
+ from .._types import NOT_GIVEN, Body, Headers, NotGiven, Query, Timeout
15
+
16
+ if TYPE_CHECKING:
17
+ from ..types import (
18
+ Location,
19
+ ShellCreateResponse,
20
+ ShellGetResponse,
21
+ ShellID,
22
+ ShellListResponse,
23
+ ShellOutputResponse,
24
+ )
25
+
26
+ __all__ = ["ShellResource", "AsyncShellResource"]
27
+
28
+
29
+ class ShellResource(SyncAPIResource):
30
+ """Operations under ``client.shell`` (OpenCode ``shell``)."""
31
+
32
+ def list(
33
+ self,
34
+ *,
35
+ location: Location | NotGiven | None = NOT_GIVEN,
36
+ extra_headers: Headers | None = None,
37
+ extra_query: Query | None = None,
38
+ extra_body: Body | None = None,
39
+ timeout: Timeout | NotGiven = NOT_GIVEN,
40
+ ) -> ShellListResponse:
41
+ """List running shell commands.
42
+
43
+ List currently running shell commands for a location. Exited commands are not included.
44
+
45
+ Raises:
46
+ InvalidRequestError: The server answered 400.
47
+ UnauthorizedError: The server answered 401.
48
+ LocationNotFoundError: The server answered 404.
49
+
50
+ ``GET /api/shell``
51
+ """
52
+ return cast(
53
+ "ShellListResponse",
54
+ self._client.request(
55
+ RequestOptions(
56
+ method="GET",
57
+ path="/api/shell",
58
+ query={"location": self._location(location)},
59
+ extra_headers=extra_headers,
60
+ extra_query=extra_query,
61
+ extra_body=extra_body,
62
+ timeout=timeout,
63
+ ),
64
+ response_type="ShellListResponse",
65
+ ),
66
+ )
67
+
68
+ def create(
69
+ self,
70
+ *,
71
+ command: str,
72
+ location: Location | NotGiven | None = NOT_GIVEN,
73
+ cwd: str | NotGiven = NOT_GIVEN,
74
+ timeout_: int | NotGiven = NOT_GIVEN,
75
+ metadata: Mapping[str, Any] | NotGiven = NOT_GIVEN,
76
+ extra_headers: Headers | None = None,
77
+ extra_query: Query | None = None,
78
+ extra_body: Body | None = None,
79
+ timeout: Timeout | NotGiven = NOT_GIVEN,
80
+ ) -> ShellCreateResponse:
81
+ """Run shell command.
82
+
83
+ Spawn one non-interactive shell command for a location. Combined stdout/stderr is captured to a file pageable via output.
84
+
85
+ Raises:
86
+ InvalidRequestError: The server answered 400.
87
+ UnauthorizedError: The server answered 401.
88
+ LocationNotFoundError: The server answered 404.
89
+
90
+ ``POST /api/shell``
91
+ """
92
+ return cast(
93
+ "ShellCreateResponse",
94
+ self._client.request(
95
+ RequestOptions(
96
+ method="POST",
97
+ path="/api/shell",
98
+ query={"location": self._location(location)},
99
+ body={"command": command, "cwd": cwd, "timeout": timeout_, "metadata": metadata},
100
+ extra_headers=extra_headers,
101
+ extra_query=extra_query,
102
+ extra_body=extra_body,
103
+ timeout=timeout,
104
+ ),
105
+ response_type="ShellCreateResponse",
106
+ ),
107
+ )
108
+
109
+ def get(
110
+ self,
111
+ id: ShellID,
112
+ *,
113
+ location: Location | NotGiven | None = NOT_GIVEN,
114
+ extra_headers: Headers | None = None,
115
+ extra_query: Query | None = None,
116
+ extra_body: Body | None = None,
117
+ timeout: Timeout | NotGiven = NOT_GIVEN,
118
+ ) -> ShellGetResponse:
119
+ """Get shell command.
120
+
121
+ Get one shell command, including its status and exit code once exited.
122
+
123
+ Raises:
124
+ InvalidRequestError: The server answered 400.
125
+ UnauthorizedError: The server answered 401.
126
+ ShellNotFoundError: The server answered 404.
127
+ LocationNotFoundError: The server answered 404.
128
+
129
+ ``GET /api/shell/:id``
130
+ """
131
+ return cast(
132
+ "ShellGetResponse",
133
+ self._client.request(
134
+ RequestOptions(
135
+ method="GET",
136
+ path=f"/api/shell/{encode_path_segment(id)}",
137
+ query={"location": self._location(location)},
138
+ extra_headers=extra_headers,
139
+ extra_query=extra_query,
140
+ extra_body=extra_body,
141
+ timeout=timeout,
142
+ ),
143
+ response_type="ShellGetResponse",
144
+ ),
145
+ )
146
+
147
+ def output(
148
+ self,
149
+ id: ShellID,
150
+ *,
151
+ location: Location | NotGiven | None = NOT_GIVEN,
152
+ cursor: int | NotGiven | None = NOT_GIVEN,
153
+ limit: int | NotGiven | None = NOT_GIVEN,
154
+ extra_headers: Headers | None = None,
155
+ extra_query: Query | None = None,
156
+ extra_body: Body | None = None,
157
+ timeout: Timeout | NotGiven = NOT_GIVEN,
158
+ ) -> ShellOutputResponse:
159
+ """Read shell output.
160
+
161
+ Page through captured combined output by absolute byte cursor.
162
+
163
+ Raises:
164
+ InvalidRequestError: The server answered 400.
165
+ UnauthorizedError: The server answered 401.
166
+ ShellNotFoundError: The server answered 404.
167
+ LocationNotFoundError: The server answered 404.
168
+
169
+ ``GET /api/shell/:id/output``
170
+ """
171
+ return cast(
172
+ "ShellOutputResponse",
173
+ self._client.request(
174
+ RequestOptions(
175
+ method="GET",
176
+ path=f"/api/shell/{encode_path_segment(id)}/output",
177
+ query={"location": self._location(location), "cursor": cursor, "limit": limit},
178
+ extra_headers=extra_headers,
179
+ extra_query=extra_query,
180
+ extra_body=extra_body,
181
+ timeout=timeout,
182
+ ),
183
+ response_type="ShellOutputResponse",
184
+ ),
185
+ )
186
+
187
+ def remove(
188
+ self,
189
+ id: ShellID,
190
+ *,
191
+ location: Location | NotGiven | None = NOT_GIVEN,
192
+ extra_headers: Headers | None = None,
193
+ extra_query: Query | None = None,
194
+ extra_body: Body | None = None,
195
+ timeout: Timeout | NotGiven = NOT_GIVEN,
196
+ ) -> None:
197
+ """Remove shell command.
198
+
199
+ Terminate and remove one shell command and its retained output.
200
+
201
+ Raises:
202
+ InvalidRequestError: The server answered 400.
203
+ UnauthorizedError: The server answered 401.
204
+ LocationNotFoundError: The server answered 404.
205
+
206
+ ``DELETE /api/shell/:id``
207
+ """
208
+ self._client.request(
209
+ RequestOptions(
210
+ method="DELETE",
211
+ path=f"/api/shell/{encode_path_segment(id)}",
212
+ query={"location": self._location(location)},
213
+ extra_headers=extra_headers,
214
+ extra_query=extra_query,
215
+ extra_body=extra_body,
216
+ timeout=timeout,
217
+ ),
218
+ kind="void",
219
+ )
220
+
221
+
222
+ class AsyncShellResource(AsyncAPIResource):
223
+ """Operations under ``client.shell`` (OpenCode ``shell``)."""
224
+
225
+ async def list(
226
+ self,
227
+ *,
228
+ location: Location | NotGiven | None = NOT_GIVEN,
229
+ extra_headers: Headers | None = None,
230
+ extra_query: Query | None = None,
231
+ extra_body: Body | None = None,
232
+ timeout: Timeout | NotGiven = NOT_GIVEN,
233
+ ) -> ShellListResponse:
234
+ """List running shell commands.
235
+
236
+ List currently running shell commands for a location. Exited commands are not included.
237
+
238
+ Raises:
239
+ InvalidRequestError: The server answered 400.
240
+ UnauthorizedError: The server answered 401.
241
+ LocationNotFoundError: The server answered 404.
242
+
243
+ ``GET /api/shell``
244
+ """
245
+ return cast(
246
+ "ShellListResponse",
247
+ await self._client.request(
248
+ RequestOptions(
249
+ method="GET",
250
+ path="/api/shell",
251
+ query={"location": self._location(location)},
252
+ extra_headers=extra_headers,
253
+ extra_query=extra_query,
254
+ extra_body=extra_body,
255
+ timeout=timeout,
256
+ ),
257
+ response_type="ShellListResponse",
258
+ ),
259
+ )
260
+
261
+ async def create(
262
+ self,
263
+ *,
264
+ command: str,
265
+ location: Location | NotGiven | None = NOT_GIVEN,
266
+ cwd: str | NotGiven = NOT_GIVEN,
267
+ timeout_: int | NotGiven = NOT_GIVEN,
268
+ metadata: Mapping[str, Any] | NotGiven = NOT_GIVEN,
269
+ extra_headers: Headers | None = None,
270
+ extra_query: Query | None = None,
271
+ extra_body: Body | None = None,
272
+ timeout: Timeout | NotGiven = NOT_GIVEN,
273
+ ) -> ShellCreateResponse:
274
+ """Run shell command.
275
+
276
+ Spawn one non-interactive shell command for a location. Combined stdout/stderr is captured to a file pageable via output.
277
+
278
+ Raises:
279
+ InvalidRequestError: The server answered 400.
280
+ UnauthorizedError: The server answered 401.
281
+ LocationNotFoundError: The server answered 404.
282
+
283
+ ``POST /api/shell``
284
+ """
285
+ return cast(
286
+ "ShellCreateResponse",
287
+ await self._client.request(
288
+ RequestOptions(
289
+ method="POST",
290
+ path="/api/shell",
291
+ query={"location": self._location(location)},
292
+ body={"command": command, "cwd": cwd, "timeout": timeout_, "metadata": metadata},
293
+ extra_headers=extra_headers,
294
+ extra_query=extra_query,
295
+ extra_body=extra_body,
296
+ timeout=timeout,
297
+ ),
298
+ response_type="ShellCreateResponse",
299
+ ),
300
+ )
301
+
302
+ async def get(
303
+ self,
304
+ id: ShellID,
305
+ *,
306
+ location: Location | NotGiven | None = NOT_GIVEN,
307
+ extra_headers: Headers | None = None,
308
+ extra_query: Query | None = None,
309
+ extra_body: Body | None = None,
310
+ timeout: Timeout | NotGiven = NOT_GIVEN,
311
+ ) -> ShellGetResponse:
312
+ """Get shell command.
313
+
314
+ Get one shell command, including its status and exit code once exited.
315
+
316
+ Raises:
317
+ InvalidRequestError: The server answered 400.
318
+ UnauthorizedError: The server answered 401.
319
+ ShellNotFoundError: The server answered 404.
320
+ LocationNotFoundError: The server answered 404.
321
+
322
+ ``GET /api/shell/:id``
323
+ """
324
+ return cast(
325
+ "ShellGetResponse",
326
+ await self._client.request(
327
+ RequestOptions(
328
+ method="GET",
329
+ path=f"/api/shell/{encode_path_segment(id)}",
330
+ query={"location": self._location(location)},
331
+ extra_headers=extra_headers,
332
+ extra_query=extra_query,
333
+ extra_body=extra_body,
334
+ timeout=timeout,
335
+ ),
336
+ response_type="ShellGetResponse",
337
+ ),
338
+ )
339
+
340
+ async def output(
341
+ self,
342
+ id: ShellID,
343
+ *,
344
+ location: Location | NotGiven | None = NOT_GIVEN,
345
+ cursor: int | NotGiven | None = NOT_GIVEN,
346
+ limit: int | NotGiven | None = NOT_GIVEN,
347
+ extra_headers: Headers | None = None,
348
+ extra_query: Query | None = None,
349
+ extra_body: Body | None = None,
350
+ timeout: Timeout | NotGiven = NOT_GIVEN,
351
+ ) -> ShellOutputResponse:
352
+ """Read shell output.
353
+
354
+ Page through captured combined output by absolute byte cursor.
355
+
356
+ Raises:
357
+ InvalidRequestError: The server answered 400.
358
+ UnauthorizedError: The server answered 401.
359
+ ShellNotFoundError: The server answered 404.
360
+ LocationNotFoundError: The server answered 404.
361
+
362
+ ``GET /api/shell/:id/output``
363
+ """
364
+ return cast(
365
+ "ShellOutputResponse",
366
+ await self._client.request(
367
+ RequestOptions(
368
+ method="GET",
369
+ path=f"/api/shell/{encode_path_segment(id)}/output",
370
+ query={"location": self._location(location), "cursor": cursor, "limit": limit},
371
+ extra_headers=extra_headers,
372
+ extra_query=extra_query,
373
+ extra_body=extra_body,
374
+ timeout=timeout,
375
+ ),
376
+ response_type="ShellOutputResponse",
377
+ ),
378
+ )
379
+
380
+ async def remove(
381
+ self,
382
+ id: ShellID,
383
+ *,
384
+ location: Location | NotGiven | None = NOT_GIVEN,
385
+ extra_headers: Headers | None = None,
386
+ extra_query: Query | None = None,
387
+ extra_body: Body | None = None,
388
+ timeout: Timeout | NotGiven = NOT_GIVEN,
389
+ ) -> None:
390
+ """Remove shell command.
391
+
392
+ Terminate and remove one shell command and its retained output.
393
+
394
+ Raises:
395
+ InvalidRequestError: The server answered 400.
396
+ UnauthorizedError: The server answered 401.
397
+ LocationNotFoundError: The server answered 404.
398
+
399
+ ``DELETE /api/shell/:id``
400
+ """
401
+ await self._client.request(
402
+ RequestOptions(
403
+ method="DELETE",
404
+ path=f"/api/shell/{encode_path_segment(id)}",
405
+ query={"location": self._location(location)},
406
+ extra_headers=extra_headers,
407
+ extra_query=extra_query,
408
+ extra_body=extra_body,
409
+ timeout=timeout,
410
+ ),
411
+ kind="void",
412
+ )
@@ -0,0 +1,100 @@
1
+ # This file is generated by `python -m codegen` from spec/contract.json. Do not edit it by hand.
2
+ # OpenCode 2.1.2
3
+
4
+ """The ``skill`` resource."""
5
+
6
+ from __future__ import annotations
7
+
8
+ from typing import TYPE_CHECKING, cast
9
+
10
+ from .._base_client import RequestOptions
11
+ from .._resource import AsyncAPIResource, SyncAPIResource
12
+ from .._types import NOT_GIVEN, Body, Headers, NotGiven, Query, Timeout
13
+
14
+ if TYPE_CHECKING:
15
+ from ..types import (
16
+ Location,
17
+ SkillListResponse,
18
+ )
19
+
20
+ __all__ = ["SkillResource", "AsyncSkillResource"]
21
+
22
+
23
+ class SkillResource(SyncAPIResource):
24
+ """Operations under ``client.skill`` (OpenCode ``skill``)."""
25
+
26
+ def list(
27
+ self,
28
+ *,
29
+ location: Location | NotGiven | None = NOT_GIVEN,
30
+ extra_headers: Headers | None = None,
31
+ extra_query: Query | None = None,
32
+ extra_body: Body | None = None,
33
+ timeout: Timeout | NotGiven = NOT_GIVEN,
34
+ ) -> SkillListResponse:
35
+ """List skills.
36
+
37
+ Retrieve currently registered skills.
38
+
39
+ Raises:
40
+ InvalidRequestError: The server answered 400.
41
+ UnauthorizedError: The server answered 401.
42
+ LocationNotFoundError: The server answered 404.
43
+
44
+ ``GET /api/skill``
45
+ """
46
+ return cast(
47
+ "SkillListResponse",
48
+ self._client.request(
49
+ RequestOptions(
50
+ method="GET",
51
+ path="/api/skill",
52
+ query={"location": self._location(location)},
53
+ extra_headers=extra_headers,
54
+ extra_query=extra_query,
55
+ extra_body=extra_body,
56
+ timeout=timeout,
57
+ ),
58
+ response_type="SkillListResponse",
59
+ ),
60
+ )
61
+
62
+
63
+ class AsyncSkillResource(AsyncAPIResource):
64
+ """Operations under ``client.skill`` (OpenCode ``skill``)."""
65
+
66
+ async def list(
67
+ self,
68
+ *,
69
+ location: Location | NotGiven | None = NOT_GIVEN,
70
+ extra_headers: Headers | None = None,
71
+ extra_query: Query | None = None,
72
+ extra_body: Body | None = None,
73
+ timeout: Timeout | NotGiven = NOT_GIVEN,
74
+ ) -> SkillListResponse:
75
+ """List skills.
76
+
77
+ Retrieve currently registered skills.
78
+
79
+ Raises:
80
+ InvalidRequestError: The server answered 400.
81
+ UnauthorizedError: The server answered 401.
82
+ LocationNotFoundError: The server answered 404.
83
+
84
+ ``GET /api/skill``
85
+ """
86
+ return cast(
87
+ "SkillListResponse",
88
+ await self._client.request(
89
+ RequestOptions(
90
+ method="GET",
91
+ path="/api/skill",
92
+ query={"location": self._location(location)},
93
+ extra_headers=extra_headers,
94
+ extra_query=extra_query,
95
+ extra_body=extra_body,
96
+ timeout=timeout,
97
+ ),
98
+ response_type="SkillListResponse",
99
+ ),
100
+ )