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,240 @@
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 ``config`` resource."""
5
+
6
+ from __future__ import annotations
7
+
8
+ import builtins
9
+ from typing import TYPE_CHECKING, cast
10
+
11
+ from .._base_client import RequestOptions
12
+ from .._resource import AsyncAPIResource, SyncAPIResource
13
+ from .._types import NOT_GIVEN, Body, Headers, NotGiven, Query, Timeout
14
+
15
+ if TYPE_CHECKING:
16
+ from ..types import (
17
+ ConfigEntry,
18
+ ConfigShellOption,
19
+ Location,
20
+ )
21
+
22
+ __all__ = ["ConfigResource", "AsyncConfigResource"]
23
+
24
+
25
+ class ConfigResource(SyncAPIResource):
26
+ """Operations under ``client.config`` (OpenCode ``config``)."""
27
+
28
+ def get(
29
+ self,
30
+ *,
31
+ location: Location | NotGiven | None = NOT_GIVEN,
32
+ extra_headers: Headers | None = None,
33
+ extra_query: Query | None = None,
34
+ extra_body: Body | None = None,
35
+ timeout: Timeout | NotGiven = NOT_GIVEN,
36
+ ) -> builtins.list[ConfigEntry]:
37
+ """Get configuration.
38
+
39
+ Return configuration documents and discovery sources for the requested location, from lowest to highest priority.
40
+
41
+ Raises:
42
+ InvalidRequestError: The server answered 400.
43
+ UnauthorizedError: The server answered 401.
44
+ LocationNotFoundError: The server answered 404.
45
+
46
+ ``GET /api/config``
47
+ """
48
+ return cast(
49
+ "builtins.list[ConfigEntry]",
50
+ self._client.request(
51
+ RequestOptions(
52
+ method="GET",
53
+ path="/api/config",
54
+ query={"location": self._location(location)},
55
+ extra_headers=extra_headers,
56
+ extra_query=extra_query,
57
+ extra_body=extra_body,
58
+ timeout=timeout,
59
+ ),
60
+ response_type="builtins.list[ConfigEntry]",
61
+ ),
62
+ )
63
+
64
+ def shells(
65
+ self,
66
+ *,
67
+ extra_headers: Headers | None = None,
68
+ extra_query: Query | None = None,
69
+ extra_body: Body | None = None,
70
+ timeout: Timeout | NotGiven = NOT_GIVEN,
71
+ ) -> builtins.list[ConfigShellOption]:
72
+ """List available shells.
73
+
74
+ Return shells available to terminal and agent execution.
75
+
76
+ Raises:
77
+ InvalidRequestError: The server answered 400.
78
+ UnauthorizedError: The server answered 401.
79
+ LocationNotFoundError: The server answered 404.
80
+
81
+ ``GET /api/config/shell``
82
+ """
83
+ return cast(
84
+ "builtins.list[ConfigShellOption]",
85
+ self._client.request(
86
+ RequestOptions(
87
+ method="GET",
88
+ path="/api/config/shell",
89
+ extra_headers=extra_headers,
90
+ extra_query=extra_query,
91
+ extra_body=extra_body,
92
+ timeout=timeout,
93
+ ),
94
+ response_type="builtins.list[ConfigShellOption]",
95
+ ),
96
+ )
97
+
98
+ def update(
99
+ self,
100
+ *,
101
+ shell: str | None,
102
+ extra_headers: Headers | None = None,
103
+ extra_query: Query | None = None,
104
+ extra_body: Body | None = None,
105
+ timeout: Timeout | NotGiven = NOT_GIVEN,
106
+ ) -> None:
107
+ """Update global configuration.
108
+
109
+ Patch supported fields in the highest-precedence global configuration document.
110
+
111
+ This endpoint is experimental in OpenCode and may change without notice.
112
+
113
+ Raises:
114
+ InvalidRequestError: The server answered 400.
115
+ UnauthorizedError: The server answered 401.
116
+ LocationNotFoundError: The server answered 404.
117
+
118
+ ``PATCH /api/experimental/config``
119
+ """
120
+ self._client.request(
121
+ RequestOptions(
122
+ method="PATCH",
123
+ path="/api/experimental/config",
124
+ body={"shell": shell},
125
+ extra_headers=extra_headers,
126
+ extra_query=extra_query,
127
+ extra_body=extra_body,
128
+ timeout=timeout,
129
+ ),
130
+ kind="void",
131
+ )
132
+
133
+
134
+ class AsyncConfigResource(AsyncAPIResource):
135
+ """Operations under ``client.config`` (OpenCode ``config``)."""
136
+
137
+ async def get(
138
+ self,
139
+ *,
140
+ location: Location | NotGiven | None = NOT_GIVEN,
141
+ extra_headers: Headers | None = None,
142
+ extra_query: Query | None = None,
143
+ extra_body: Body | None = None,
144
+ timeout: Timeout | NotGiven = NOT_GIVEN,
145
+ ) -> builtins.list[ConfigEntry]:
146
+ """Get configuration.
147
+
148
+ Return configuration documents and discovery sources for the requested location, from lowest to highest priority.
149
+
150
+ Raises:
151
+ InvalidRequestError: The server answered 400.
152
+ UnauthorizedError: The server answered 401.
153
+ LocationNotFoundError: The server answered 404.
154
+
155
+ ``GET /api/config``
156
+ """
157
+ return cast(
158
+ "builtins.list[ConfigEntry]",
159
+ await self._client.request(
160
+ RequestOptions(
161
+ method="GET",
162
+ path="/api/config",
163
+ query={"location": self._location(location)},
164
+ extra_headers=extra_headers,
165
+ extra_query=extra_query,
166
+ extra_body=extra_body,
167
+ timeout=timeout,
168
+ ),
169
+ response_type="builtins.list[ConfigEntry]",
170
+ ),
171
+ )
172
+
173
+ async def shells(
174
+ self,
175
+ *,
176
+ extra_headers: Headers | None = None,
177
+ extra_query: Query | None = None,
178
+ extra_body: Body | None = None,
179
+ timeout: Timeout | NotGiven = NOT_GIVEN,
180
+ ) -> builtins.list[ConfigShellOption]:
181
+ """List available shells.
182
+
183
+ Return shells available to terminal and agent execution.
184
+
185
+ Raises:
186
+ InvalidRequestError: The server answered 400.
187
+ UnauthorizedError: The server answered 401.
188
+ LocationNotFoundError: The server answered 404.
189
+
190
+ ``GET /api/config/shell``
191
+ """
192
+ return cast(
193
+ "builtins.list[ConfigShellOption]",
194
+ await self._client.request(
195
+ RequestOptions(
196
+ method="GET",
197
+ path="/api/config/shell",
198
+ extra_headers=extra_headers,
199
+ extra_query=extra_query,
200
+ extra_body=extra_body,
201
+ timeout=timeout,
202
+ ),
203
+ response_type="builtins.list[ConfigShellOption]",
204
+ ),
205
+ )
206
+
207
+ async def update(
208
+ self,
209
+ *,
210
+ shell: str | None,
211
+ extra_headers: Headers | None = None,
212
+ extra_query: Query | None = None,
213
+ extra_body: Body | None = None,
214
+ timeout: Timeout | NotGiven = NOT_GIVEN,
215
+ ) -> None:
216
+ """Update global configuration.
217
+
218
+ Patch supported fields in the highest-precedence global configuration document.
219
+
220
+ This endpoint is experimental in OpenCode and may change without notice.
221
+
222
+ Raises:
223
+ InvalidRequestError: The server answered 400.
224
+ UnauthorizedError: The server answered 401.
225
+ LocationNotFoundError: The server answered 404.
226
+
227
+ ``PATCH /api/experimental/config``
228
+ """
229
+ await self._client.request(
230
+ RequestOptions(
231
+ method="PATCH",
232
+ path="/api/experimental/config",
233
+ body={"shell": shell},
234
+ extra_headers=extra_headers,
235
+ extra_query=extra_query,
236
+ extra_body=extra_body,
237
+ timeout=timeout,
238
+ ),
239
+ kind="void",
240
+ )
@@ -0,0 +1,384 @@
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 ``credential`` resource."""
5
+
6
+ from __future__ import annotations
7
+
8
+ import builtins
9
+ from typing import TYPE_CHECKING, 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
+ CredentialEntry,
19
+ CredentialID,
20
+ CredentialValue,
21
+ IntegrationID,
22
+ )
23
+
24
+ __all__ = ["CredentialResource", "AsyncCredentialResource"]
25
+
26
+
27
+ class CredentialResource(SyncAPIResource):
28
+ """Operations under ``client.credential`` (OpenCode ``credential``)."""
29
+
30
+ def list(
31
+ self,
32
+ *,
33
+ extra_headers: Headers | None = None,
34
+ extra_query: Query | None = None,
35
+ extra_body: Body | None = None,
36
+ timeout: Timeout | NotGiven = NOT_GIVEN,
37
+ ) -> builtins.list[CredentialEntry]:
38
+ """List credentials.
39
+
40
+ List every stored integration credential, including its secret value.
41
+
42
+ Raises:
43
+ InvalidRequestError: The server answered 400.
44
+ UnauthorizedError: The server answered 401.
45
+
46
+ ``GET /api/credential``
47
+ """
48
+ return cast(
49
+ "builtins.list[CredentialEntry]",
50
+ self._client.request(
51
+ RequestOptions(
52
+ method="GET",
53
+ path="/api/credential",
54
+ extra_headers=extra_headers,
55
+ extra_query=extra_query,
56
+ extra_body=extra_body,
57
+ timeout=timeout,
58
+ ),
59
+ response_type="builtins.list[CredentialEntry]",
60
+ unwrap=True,
61
+ ),
62
+ )
63
+
64
+ def create(
65
+ self,
66
+ *,
67
+ integration_id: IntegrationID,
68
+ value: CredentialValue,
69
+ id: CredentialID | NotGiven = NOT_GIVEN,
70
+ label: str | NotGiven = NOT_GIVEN,
71
+ activate: bool | NotGiven = NOT_GIVEN,
72
+ extra_headers: Headers | None = None,
73
+ extra_query: Query | None = None,
74
+ extra_body: Body | None = None,
75
+ timeout: Timeout | NotGiven = NOT_GIVEN,
76
+ ) -> CredentialEntry:
77
+ """Create credential.
78
+
79
+ Store an integration credential. It becomes the integration's active credential unless activate is false and the integration already has one. Fails with a conflict when the requested ID already exists.
80
+
81
+ Raises:
82
+ InvalidRequestError: The server answered 400.
83
+ UnauthorizedError: The server answered 401.
84
+ ConflictError: The server answered 409.
85
+
86
+ ``POST /api/credential``
87
+ """
88
+ return cast(
89
+ "CredentialEntry",
90
+ self._client.request(
91
+ RequestOptions(
92
+ method="POST",
93
+ path="/api/credential",
94
+ body={
95
+ "id": id,
96
+ "integrationID": integration_id,
97
+ "label": label,
98
+ "value": value,
99
+ "activate": activate,
100
+ },
101
+ extra_headers=extra_headers,
102
+ extra_query=extra_query,
103
+ extra_body=extra_body,
104
+ timeout=timeout,
105
+ ),
106
+ response_type="CredentialEntry",
107
+ unwrap=True,
108
+ ),
109
+ )
110
+
111
+ def update(
112
+ self,
113
+ credential_id: CredentialID,
114
+ *,
115
+ label: str,
116
+ extra_headers: Headers | None = None,
117
+ extra_query: Query | None = None,
118
+ extra_body: Body | None = None,
119
+ timeout: Timeout | NotGiven = NOT_GIVEN,
120
+ ) -> None:
121
+ """Update credential.
122
+
123
+ Update a stored credential label.
124
+
125
+ Raises:
126
+ InvalidRequestError: The server answered 400.
127
+ UnauthorizedError: The server answered 401.
128
+
129
+ ``PATCH /api/credential/:credentialID``
130
+ """
131
+ self._client.request(
132
+ RequestOptions(
133
+ method="PATCH",
134
+ path=f"/api/credential/{encode_path_segment(credential_id)}",
135
+ body={"label": label},
136
+ extra_headers=extra_headers,
137
+ extra_query=extra_query,
138
+ extra_body=extra_body,
139
+ timeout=timeout,
140
+ ),
141
+ kind="void",
142
+ )
143
+
144
+ def activate(
145
+ self,
146
+ credential_id: CredentialID,
147
+ *,
148
+ extra_headers: Headers | None = None,
149
+ extra_query: Query | None = None,
150
+ extra_body: Body | None = None,
151
+ timeout: Timeout | NotGiven = NOT_GIVEN,
152
+ ) -> None:
153
+ """Activate credential.
154
+
155
+ Activate a stored integration credential.
156
+
157
+ Raises:
158
+ InvalidRequestError: The server answered 400.
159
+ UnauthorizedError: The server answered 401.
160
+
161
+ ``POST /api/credential/:credentialID/activate``
162
+ """
163
+ self._client.request(
164
+ RequestOptions(
165
+ method="POST",
166
+ path=f"/api/credential/{encode_path_segment(credential_id)}/activate",
167
+ extra_headers=extra_headers,
168
+ extra_query=extra_query,
169
+ extra_body=extra_body,
170
+ timeout=timeout,
171
+ ),
172
+ kind="void",
173
+ )
174
+
175
+ def remove(
176
+ self,
177
+ credential_id: CredentialID,
178
+ *,
179
+ extra_headers: Headers | None = None,
180
+ extra_query: Query | None = None,
181
+ extra_body: Body | None = None,
182
+ timeout: Timeout | NotGiven = NOT_GIVEN,
183
+ ) -> None:
184
+ """Remove credential.
185
+
186
+ Remove a stored integration credential.
187
+
188
+ Raises:
189
+ InvalidRequestError: The server answered 400.
190
+ UnauthorizedError: The server answered 401.
191
+
192
+ ``DELETE /api/credential/:credentialID``
193
+ """
194
+ self._client.request(
195
+ RequestOptions(
196
+ method="DELETE",
197
+ path=f"/api/credential/{encode_path_segment(credential_id)}",
198
+ extra_headers=extra_headers,
199
+ extra_query=extra_query,
200
+ extra_body=extra_body,
201
+ timeout=timeout,
202
+ ),
203
+ kind="void",
204
+ )
205
+
206
+
207
+ class AsyncCredentialResource(AsyncAPIResource):
208
+ """Operations under ``client.credential`` (OpenCode ``credential``)."""
209
+
210
+ async def list(
211
+ self,
212
+ *,
213
+ extra_headers: Headers | None = None,
214
+ extra_query: Query | None = None,
215
+ extra_body: Body | None = None,
216
+ timeout: Timeout | NotGiven = NOT_GIVEN,
217
+ ) -> builtins.list[CredentialEntry]:
218
+ """List credentials.
219
+
220
+ List every stored integration credential, including its secret value.
221
+
222
+ Raises:
223
+ InvalidRequestError: The server answered 400.
224
+ UnauthorizedError: The server answered 401.
225
+
226
+ ``GET /api/credential``
227
+ """
228
+ return cast(
229
+ "builtins.list[CredentialEntry]",
230
+ await self._client.request(
231
+ RequestOptions(
232
+ method="GET",
233
+ path="/api/credential",
234
+ extra_headers=extra_headers,
235
+ extra_query=extra_query,
236
+ extra_body=extra_body,
237
+ timeout=timeout,
238
+ ),
239
+ response_type="builtins.list[CredentialEntry]",
240
+ unwrap=True,
241
+ ),
242
+ )
243
+
244
+ async def create(
245
+ self,
246
+ *,
247
+ integration_id: IntegrationID,
248
+ value: CredentialValue,
249
+ id: CredentialID | NotGiven = NOT_GIVEN,
250
+ label: str | NotGiven = NOT_GIVEN,
251
+ activate: bool | NotGiven = NOT_GIVEN,
252
+ extra_headers: Headers | None = None,
253
+ extra_query: Query | None = None,
254
+ extra_body: Body | None = None,
255
+ timeout: Timeout | NotGiven = NOT_GIVEN,
256
+ ) -> CredentialEntry:
257
+ """Create credential.
258
+
259
+ Store an integration credential. It becomes the integration's active credential unless activate is false and the integration already has one. Fails with a conflict when the requested ID already exists.
260
+
261
+ Raises:
262
+ InvalidRequestError: The server answered 400.
263
+ UnauthorizedError: The server answered 401.
264
+ ConflictError: The server answered 409.
265
+
266
+ ``POST /api/credential``
267
+ """
268
+ return cast(
269
+ "CredentialEntry",
270
+ await self._client.request(
271
+ RequestOptions(
272
+ method="POST",
273
+ path="/api/credential",
274
+ body={
275
+ "id": id,
276
+ "integrationID": integration_id,
277
+ "label": label,
278
+ "value": value,
279
+ "activate": activate,
280
+ },
281
+ extra_headers=extra_headers,
282
+ extra_query=extra_query,
283
+ extra_body=extra_body,
284
+ timeout=timeout,
285
+ ),
286
+ response_type="CredentialEntry",
287
+ unwrap=True,
288
+ ),
289
+ )
290
+
291
+ async def update(
292
+ self,
293
+ credential_id: CredentialID,
294
+ *,
295
+ label: str,
296
+ extra_headers: Headers | None = None,
297
+ extra_query: Query | None = None,
298
+ extra_body: Body | None = None,
299
+ timeout: Timeout | NotGiven = NOT_GIVEN,
300
+ ) -> None:
301
+ """Update credential.
302
+
303
+ Update a stored credential label.
304
+
305
+ Raises:
306
+ InvalidRequestError: The server answered 400.
307
+ UnauthorizedError: The server answered 401.
308
+
309
+ ``PATCH /api/credential/:credentialID``
310
+ """
311
+ await self._client.request(
312
+ RequestOptions(
313
+ method="PATCH",
314
+ path=f"/api/credential/{encode_path_segment(credential_id)}",
315
+ body={"label": label},
316
+ extra_headers=extra_headers,
317
+ extra_query=extra_query,
318
+ extra_body=extra_body,
319
+ timeout=timeout,
320
+ ),
321
+ kind="void",
322
+ )
323
+
324
+ async def activate(
325
+ self,
326
+ credential_id: CredentialID,
327
+ *,
328
+ extra_headers: Headers | None = None,
329
+ extra_query: Query | None = None,
330
+ extra_body: Body | None = None,
331
+ timeout: Timeout | NotGiven = NOT_GIVEN,
332
+ ) -> None:
333
+ """Activate credential.
334
+
335
+ Activate a stored integration credential.
336
+
337
+ Raises:
338
+ InvalidRequestError: The server answered 400.
339
+ UnauthorizedError: The server answered 401.
340
+
341
+ ``POST /api/credential/:credentialID/activate``
342
+ """
343
+ await self._client.request(
344
+ RequestOptions(
345
+ method="POST",
346
+ path=f"/api/credential/{encode_path_segment(credential_id)}/activate",
347
+ extra_headers=extra_headers,
348
+ extra_query=extra_query,
349
+ extra_body=extra_body,
350
+ timeout=timeout,
351
+ ),
352
+ kind="void",
353
+ )
354
+
355
+ async def remove(
356
+ self,
357
+ credential_id: CredentialID,
358
+ *,
359
+ extra_headers: Headers | None = None,
360
+ extra_query: Query | None = None,
361
+ extra_body: Body | None = None,
362
+ timeout: Timeout | NotGiven = NOT_GIVEN,
363
+ ) -> None:
364
+ """Remove credential.
365
+
366
+ Remove a stored integration credential.
367
+
368
+ Raises:
369
+ InvalidRequestError: The server answered 400.
370
+ UnauthorizedError: The server answered 401.
371
+
372
+ ``DELETE /api/credential/:credentialID``
373
+ """
374
+ await self._client.request(
375
+ RequestOptions(
376
+ method="DELETE",
377
+ path=f"/api/credential/{encode_path_segment(credential_id)}",
378
+ extra_headers=extra_headers,
379
+ extra_query=extra_query,
380
+ extra_body=extra_body,
381
+ timeout=timeout,
382
+ ),
383
+ kind="void",
384
+ )