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