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,182 @@
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 ``websearch`` 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
+ WebSearchID,
16
+ WebsearchProvidersResponse,
17
+ WebsearchQueryResponse,
18
+ )
19
+
20
+ __all__ = ["WebsearchResource", "AsyncWebsearchResource"]
21
+
22
+
23
+ class WebsearchResource(SyncAPIResource):
24
+ """Operations under ``client.websearch`` (OpenCode ``websearch``)."""
25
+
26
+ def providers(
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
+ ) -> WebsearchProvidersResponse:
35
+ """List web search providers.
36
+
37
+ Return the registered web search providers.
38
+
39
+ Raises:
40
+ InvalidRequestError
41
+ UnauthorizedError
42
+ LocationNotFoundError
43
+ ServiceUnavailableError
44
+
45
+ ``GET /api/websearch/provider``
46
+ """
47
+ return cast(
48
+ "WebsearchProvidersResponse",
49
+ self._client.request(
50
+ RequestOptions(
51
+ method="GET",
52
+ path="/api/websearch/provider",
53
+ query={"location": self._location(location)},
54
+ extra_headers=extra_headers,
55
+ extra_query=extra_query,
56
+ extra_body=extra_body,
57
+ timeout=timeout,
58
+ ),
59
+ response_type=WebsearchProvidersResponse,
60
+ ),
61
+ )
62
+
63
+ def query(
64
+ self,
65
+ *,
66
+ query: str,
67
+ location: Location | NotGiven | None = NOT_GIVEN,
68
+ provider_id: WebSearchID | NotGiven = NOT_GIVEN,
69
+ extra_headers: Headers | None = None,
70
+ extra_query: Query | None = None,
71
+ extra_body: Body | None = None,
72
+ timeout: Timeout | NotGiven = NOT_GIVEN,
73
+ ) -> WebsearchQueryResponse:
74
+ """Search the web.
75
+
76
+ Run one web search through the selected provider. Specify a provider to override the configured default.
77
+
78
+ Raises:
79
+ InvalidRequestError
80
+ UnauthorizedError
81
+ LocationNotFoundError
82
+ ServiceUnavailableError
83
+
84
+ ``POST /api/websearch``
85
+ """
86
+ return cast(
87
+ "WebsearchQueryResponse",
88
+ self._client.request(
89
+ RequestOptions(
90
+ method="POST",
91
+ path="/api/websearch",
92
+ query={"location": self._location(location)},
93
+ body={"query": query, "providerID": provider_id},
94
+ extra_headers=extra_headers,
95
+ extra_query=extra_query,
96
+ extra_body=extra_body,
97
+ timeout=timeout,
98
+ ),
99
+ response_type=WebsearchQueryResponse,
100
+ ),
101
+ )
102
+
103
+
104
+ class AsyncWebsearchResource(AsyncAPIResource):
105
+ """Operations under ``client.websearch`` (OpenCode ``websearch``)."""
106
+
107
+ async def providers(
108
+ self,
109
+ *,
110
+ location: Location | NotGiven | None = NOT_GIVEN,
111
+ extra_headers: Headers | None = None,
112
+ extra_query: Query | None = None,
113
+ extra_body: Body | None = None,
114
+ timeout: Timeout | NotGiven = NOT_GIVEN,
115
+ ) -> WebsearchProvidersResponse:
116
+ """List web search providers.
117
+
118
+ Return the registered web search providers.
119
+
120
+ Raises:
121
+ InvalidRequestError
122
+ UnauthorizedError
123
+ LocationNotFoundError
124
+ ServiceUnavailableError
125
+
126
+ ``GET /api/websearch/provider``
127
+ """
128
+ return cast(
129
+ "WebsearchProvidersResponse",
130
+ await self._client.request(
131
+ RequestOptions(
132
+ method="GET",
133
+ path="/api/websearch/provider",
134
+ query={"location": self._location(location)},
135
+ extra_headers=extra_headers,
136
+ extra_query=extra_query,
137
+ extra_body=extra_body,
138
+ timeout=timeout,
139
+ ),
140
+ response_type=WebsearchProvidersResponse,
141
+ ),
142
+ )
143
+
144
+ async def query(
145
+ self,
146
+ *,
147
+ query: str,
148
+ location: Location | NotGiven | None = NOT_GIVEN,
149
+ provider_id: WebSearchID | NotGiven = NOT_GIVEN,
150
+ extra_headers: Headers | None = None,
151
+ extra_query: Query | None = None,
152
+ extra_body: Body | None = None,
153
+ timeout: Timeout | NotGiven = NOT_GIVEN,
154
+ ) -> WebsearchQueryResponse:
155
+ """Search the web.
156
+
157
+ Run one web search through the selected provider. Specify a provider to override the configured default.
158
+
159
+ Raises:
160
+ InvalidRequestError
161
+ UnauthorizedError
162
+ LocationNotFoundError
163
+ ServiceUnavailableError
164
+
165
+ ``POST /api/websearch``
166
+ """
167
+ return cast(
168
+ "WebsearchQueryResponse",
169
+ await self._client.request(
170
+ RequestOptions(
171
+ method="POST",
172
+ path="/api/websearch",
173
+ query={"location": self._location(location)},
174
+ body={"query": query, "providerID": provider_id},
175
+ extra_headers=extra_headers,
176
+ extra_query=extra_query,
177
+ extra_body=extra_body,
178
+ timeout=timeout,
179
+ ),
180
+ response_type=WebsearchQueryResponse,
181
+ ),
182
+ )
@@ -0,0 +1,334 @@
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 ``worktree`` 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
+ AbsolutePath,
15
+ ProjectID,
16
+ WorktreeInfo,
17
+ WorktreeList,
18
+ )
19
+
20
+ __all__ = ["WorktreeResource", "AsyncWorktreeResource"]
21
+
22
+
23
+ class WorktreeResource(SyncAPIResource):
24
+ """Operations under ``client.worktree`` (OpenCode ``worktree``)."""
25
+
26
+ def list(
27
+ self,
28
+ *,
29
+ project_id: ProjectID,
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
+ ) -> WorktreeList:
35
+ """List worktrees.
36
+
37
+ Return the project's saved worktree inventory without loading configuration or running discovery.
38
+
39
+ Raises:
40
+ InvalidRequestError
41
+ UnauthorizedError
42
+ ProjectNotFoundError
43
+
44
+ ``GET /api/worktree``
45
+ """
46
+ return cast(
47
+ "WorktreeList",
48
+ self._client.request(
49
+ RequestOptions(
50
+ method="GET",
51
+ path="/api/worktree",
52
+ query={"projectID": project_id},
53
+ extra_headers=extra_headers,
54
+ extra_query=extra_query,
55
+ extra_body=extra_body,
56
+ timeout=timeout,
57
+ ),
58
+ response_type=WorktreeList,
59
+ ),
60
+ )
61
+
62
+ def create(
63
+ self,
64
+ *,
65
+ project_id: ProjectID,
66
+ from_: AbsolutePath | NotGiven = NOT_GIVEN,
67
+ branch: str | NotGiven = NOT_GIVEN,
68
+ directory: AbsolutePath | NotGiven = NOT_GIVEN,
69
+ name: str | NotGiven = 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
+ ) -> WorktreeInfo:
75
+ """Create worktree.
76
+
77
+ Load the project's canonical configuration, create a local worktree using its selected strategy, then run the project's setup script.
78
+
79
+ Raises:
80
+ WorktreeError
81
+ InvalidRequestError
82
+ UnauthorizedError
83
+ ProjectNotFoundError
84
+
85
+ ``POST /api/worktree``
86
+ """
87
+ return cast(
88
+ "WorktreeInfo",
89
+ self._client.request(
90
+ RequestOptions(
91
+ method="POST",
92
+ path="/api/worktree",
93
+ body={
94
+ "projectID": project_id,
95
+ "from": from_,
96
+ "branch": branch,
97
+ "directory": directory,
98
+ "name": name,
99
+ },
100
+ extra_headers=extra_headers,
101
+ extra_query=extra_query,
102
+ extra_body=extra_body,
103
+ timeout=timeout,
104
+ ),
105
+ response_type=WorktreeInfo,
106
+ ),
107
+ )
108
+
109
+ def remove(
110
+ self,
111
+ *,
112
+ project_id: ProjectID,
113
+ directory: AbsolutePath,
114
+ force: bool,
115
+ extra_headers: Headers | None = None,
116
+ extra_query: Query | None = None,
117
+ extra_body: Body | None = None,
118
+ timeout: Timeout | NotGiven = NOT_GIVEN,
119
+ ) -> None:
120
+ """Remove worktree.
121
+
122
+ Load the project's canonical configuration and remove a saved worktree using its recorded strategy.
123
+
124
+ Raises:
125
+ WorktreeError
126
+ InvalidRequestError
127
+ UnauthorizedError
128
+ ProjectNotFoundError
129
+
130
+ ``DELETE /api/worktree``
131
+ """
132
+ self._client.request(
133
+ RequestOptions(
134
+ method="DELETE",
135
+ path="/api/worktree",
136
+ body={"projectID": project_id, "directory": directory, "force": force},
137
+ extra_headers=extra_headers,
138
+ extra_query=extra_query,
139
+ extra_body=extra_body,
140
+ timeout=timeout,
141
+ ),
142
+ kind="void",
143
+ )
144
+
145
+ def refresh(
146
+ self,
147
+ *,
148
+ project_id: ProjectID,
149
+ extra_headers: Headers | None = None,
150
+ extra_query: Query | None = None,
151
+ extra_body: Body | None = None,
152
+ timeout: Timeout | NotGiven = NOT_GIVEN,
153
+ ) -> None:
154
+ """Refresh worktrees.
155
+
156
+ Load the project's canonical configuration, discover worktrees across known checkout roots using all available strategies, and reconcile saved state.
157
+
158
+ Raises:
159
+ WorktreeError
160
+ InvalidRequestError
161
+ UnauthorizedError
162
+ ProjectNotFoundError
163
+
164
+ ``POST /api/worktree/refresh``
165
+ """
166
+ self._client.request(
167
+ RequestOptions(
168
+ method="POST",
169
+ path="/api/worktree/refresh",
170
+ body={"projectID": project_id},
171
+ extra_headers=extra_headers,
172
+ extra_query=extra_query,
173
+ extra_body=extra_body,
174
+ timeout=timeout,
175
+ ),
176
+ kind="void",
177
+ )
178
+
179
+
180
+ class AsyncWorktreeResource(AsyncAPIResource):
181
+ """Operations under ``client.worktree`` (OpenCode ``worktree``)."""
182
+
183
+ async def list(
184
+ self,
185
+ *,
186
+ project_id: ProjectID,
187
+ extra_headers: Headers | None = None,
188
+ extra_query: Query | None = None,
189
+ extra_body: Body | None = None,
190
+ timeout: Timeout | NotGiven = NOT_GIVEN,
191
+ ) -> WorktreeList:
192
+ """List worktrees.
193
+
194
+ Return the project's saved worktree inventory without loading configuration or running discovery.
195
+
196
+ Raises:
197
+ InvalidRequestError
198
+ UnauthorizedError
199
+ ProjectNotFoundError
200
+
201
+ ``GET /api/worktree``
202
+ """
203
+ return cast(
204
+ "WorktreeList",
205
+ await self._client.request(
206
+ RequestOptions(
207
+ method="GET",
208
+ path="/api/worktree",
209
+ query={"projectID": project_id},
210
+ extra_headers=extra_headers,
211
+ extra_query=extra_query,
212
+ extra_body=extra_body,
213
+ timeout=timeout,
214
+ ),
215
+ response_type=WorktreeList,
216
+ ),
217
+ )
218
+
219
+ async def create(
220
+ self,
221
+ *,
222
+ project_id: ProjectID,
223
+ from_: AbsolutePath | NotGiven = NOT_GIVEN,
224
+ branch: str | NotGiven = NOT_GIVEN,
225
+ directory: AbsolutePath | NotGiven = NOT_GIVEN,
226
+ name: str | NotGiven = 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
+ ) -> WorktreeInfo:
232
+ """Create worktree.
233
+
234
+ Load the project's canonical configuration, create a local worktree using its selected strategy, then run the project's setup script.
235
+
236
+ Raises:
237
+ WorktreeError
238
+ InvalidRequestError
239
+ UnauthorizedError
240
+ ProjectNotFoundError
241
+
242
+ ``POST /api/worktree``
243
+ """
244
+ return cast(
245
+ "WorktreeInfo",
246
+ await self._client.request(
247
+ RequestOptions(
248
+ method="POST",
249
+ path="/api/worktree",
250
+ body={
251
+ "projectID": project_id,
252
+ "from": from_,
253
+ "branch": branch,
254
+ "directory": directory,
255
+ "name": name,
256
+ },
257
+ extra_headers=extra_headers,
258
+ extra_query=extra_query,
259
+ extra_body=extra_body,
260
+ timeout=timeout,
261
+ ),
262
+ response_type=WorktreeInfo,
263
+ ),
264
+ )
265
+
266
+ async def remove(
267
+ self,
268
+ *,
269
+ project_id: ProjectID,
270
+ directory: AbsolutePath,
271
+ force: bool,
272
+ extra_headers: Headers | None = None,
273
+ extra_query: Query | None = None,
274
+ extra_body: Body | None = None,
275
+ timeout: Timeout | NotGiven = NOT_GIVEN,
276
+ ) -> None:
277
+ """Remove worktree.
278
+
279
+ Load the project's canonical configuration and remove a saved worktree using its recorded strategy.
280
+
281
+ Raises:
282
+ WorktreeError
283
+ InvalidRequestError
284
+ UnauthorizedError
285
+ ProjectNotFoundError
286
+
287
+ ``DELETE /api/worktree``
288
+ """
289
+ await self._client.request(
290
+ RequestOptions(
291
+ method="DELETE",
292
+ path="/api/worktree",
293
+ body={"projectID": project_id, "directory": directory, "force": force},
294
+ extra_headers=extra_headers,
295
+ extra_query=extra_query,
296
+ extra_body=extra_body,
297
+ timeout=timeout,
298
+ ),
299
+ kind="void",
300
+ )
301
+
302
+ async def refresh(
303
+ self,
304
+ *,
305
+ project_id: ProjectID,
306
+ extra_headers: Headers | None = None,
307
+ extra_query: Query | None = None,
308
+ extra_body: Body | None = None,
309
+ timeout: Timeout | NotGiven = NOT_GIVEN,
310
+ ) -> None:
311
+ """Refresh worktrees.
312
+
313
+ Load the project's canonical configuration, discover worktrees across known checkout roots using all available strategies, and reconcile saved state.
314
+
315
+ Raises:
316
+ WorktreeError
317
+ InvalidRequestError
318
+ UnauthorizedError
319
+ ProjectNotFoundError
320
+
321
+ ``POST /api/worktree/refresh``
322
+ """
323
+ await self._client.request(
324
+ RequestOptions(
325
+ method="POST",
326
+ path="/api/worktree/refresh",
327
+ body={"projectID": project_id},
328
+ extra_headers=extra_headers,
329
+ extra_query=extra_query,
330
+ extra_body=extra_body,
331
+ timeout=timeout,
332
+ ),
333
+ kind="void",
334
+ )