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,248 @@
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 ``plugin`` resource."""
5
+
6
+ from __future__ import annotations
7
+
8
+ from collections.abc import Sequence
9
+ from typing import 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
+ from ..types import (
15
+ Location,
16
+ PluginCheckResponse,
17
+ PluginListResponse,
18
+ )
19
+
20
+ __all__ = ["PluginResource", "AsyncPluginResource"]
21
+
22
+
23
+ class PluginResource(SyncAPIResource):
24
+ """Operations under ``client.plugin`` (OpenCode ``plugin``)."""
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
+ ) -> PluginListResponse:
35
+ """List plugins.
36
+
37
+ Retrieve enabled server plugins and their current status.
38
+
39
+ Raises:
40
+ InvalidRequestError
41
+ UnauthorizedError
42
+ LocationNotFoundError
43
+
44
+ ``GET /api/plugin``
45
+ """
46
+ return cast(
47
+ "PluginListResponse",
48
+ self._client.request(
49
+ RequestOptions(
50
+ method="GET",
51
+ path="/api/plugin",
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=PluginListResponse,
59
+ ),
60
+ )
61
+
62
+ def check(
63
+ self,
64
+ *,
65
+ location: Location | NotGiven | None = NOT_GIVEN,
66
+ target: str | NotGiven | None = NOT_GIVEN,
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
+ ) -> PluginCheckResponse:
72
+ """Check plugin updates.
73
+
74
+ Check one or all package plugins for available updates.
75
+
76
+ Raises:
77
+ InvalidRequestError
78
+ UnauthorizedError
79
+ LocationNotFoundError
80
+
81
+ ``POST /api/plugin/check``
82
+ """
83
+ return cast(
84
+ "PluginCheckResponse",
85
+ self._client.request(
86
+ RequestOptions(
87
+ method="POST",
88
+ path="/api/plugin/check",
89
+ query={"location": self._location(location)},
90
+ body={"target": target},
91
+ extra_headers=extra_headers,
92
+ extra_query=extra_query,
93
+ extra_body=extra_body,
94
+ timeout=timeout,
95
+ ),
96
+ response_type=PluginCheckResponse,
97
+ ),
98
+ )
99
+
100
+ def update(
101
+ self,
102
+ *,
103
+ targets: Sequence[str],
104
+ location: Location | NotGiven | None = NOT_GIVEN,
105
+ extra_headers: Headers | None = None,
106
+ extra_query: Query | None = None,
107
+ extra_body: Body | None = None,
108
+ timeout: Timeout | NotGiven = NOT_GIVEN,
109
+ ) -> None:
110
+ """Update plugins.
111
+
112
+ Update package plugins concurrently and notify active locations to reload them. Responds once every update has finished; fails when any update fails.
113
+
114
+ Raises:
115
+ InvalidRequestError
116
+ UnauthorizedError
117
+ LocationNotFoundError
118
+ ServiceUnavailableError
119
+
120
+ ``POST /api/plugin/update``
121
+ """
122
+ self._client.request(
123
+ RequestOptions(
124
+ method="POST",
125
+ path="/api/plugin/update",
126
+ query={"location": self._location(location)},
127
+ body={"targets": targets},
128
+ extra_headers=extra_headers,
129
+ extra_query=extra_query,
130
+ extra_body=extra_body,
131
+ timeout=timeout,
132
+ ),
133
+ kind="void",
134
+ )
135
+
136
+
137
+ class AsyncPluginResource(AsyncAPIResource):
138
+ """Operations under ``client.plugin`` (OpenCode ``plugin``)."""
139
+
140
+ async def list(
141
+ self,
142
+ *,
143
+ location: Location | NotGiven | None = NOT_GIVEN,
144
+ extra_headers: Headers | None = None,
145
+ extra_query: Query | None = None,
146
+ extra_body: Body | None = None,
147
+ timeout: Timeout | NotGiven = NOT_GIVEN,
148
+ ) -> PluginListResponse:
149
+ """List plugins.
150
+
151
+ Retrieve enabled server plugins and their current status.
152
+
153
+ Raises:
154
+ InvalidRequestError
155
+ UnauthorizedError
156
+ LocationNotFoundError
157
+
158
+ ``GET /api/plugin``
159
+ """
160
+ return cast(
161
+ "PluginListResponse",
162
+ await self._client.request(
163
+ RequestOptions(
164
+ method="GET",
165
+ path="/api/plugin",
166
+ query={"location": self._location(location)},
167
+ extra_headers=extra_headers,
168
+ extra_query=extra_query,
169
+ extra_body=extra_body,
170
+ timeout=timeout,
171
+ ),
172
+ response_type=PluginListResponse,
173
+ ),
174
+ )
175
+
176
+ async def check(
177
+ self,
178
+ *,
179
+ location: Location | NotGiven | None = NOT_GIVEN,
180
+ target: str | NotGiven | None = NOT_GIVEN,
181
+ extra_headers: Headers | None = None,
182
+ extra_query: Query | None = None,
183
+ extra_body: Body | None = None,
184
+ timeout: Timeout | NotGiven = NOT_GIVEN,
185
+ ) -> PluginCheckResponse:
186
+ """Check plugin updates.
187
+
188
+ Check one or all package plugins for available updates.
189
+
190
+ Raises:
191
+ InvalidRequestError
192
+ UnauthorizedError
193
+ LocationNotFoundError
194
+
195
+ ``POST /api/plugin/check``
196
+ """
197
+ return cast(
198
+ "PluginCheckResponse",
199
+ await self._client.request(
200
+ RequestOptions(
201
+ method="POST",
202
+ path="/api/plugin/check",
203
+ query={"location": self._location(location)},
204
+ body={"target": target},
205
+ extra_headers=extra_headers,
206
+ extra_query=extra_query,
207
+ extra_body=extra_body,
208
+ timeout=timeout,
209
+ ),
210
+ response_type=PluginCheckResponse,
211
+ ),
212
+ )
213
+
214
+ async def update(
215
+ self,
216
+ *,
217
+ targets: Sequence[str],
218
+ location: Location | NotGiven | None = NOT_GIVEN,
219
+ extra_headers: Headers | None = None,
220
+ extra_query: Query | None = None,
221
+ extra_body: Body | None = None,
222
+ timeout: Timeout | NotGiven = NOT_GIVEN,
223
+ ) -> None:
224
+ """Update plugins.
225
+
226
+ Update package plugins concurrently and notify active locations to reload them. Responds once every update has finished; fails when any update fails.
227
+
228
+ Raises:
229
+ InvalidRequestError
230
+ UnauthorizedError
231
+ LocationNotFoundError
232
+ ServiceUnavailableError
233
+
234
+ ``POST /api/plugin/update``
235
+ """
236
+ await self._client.request(
237
+ RequestOptions(
238
+ method="POST",
239
+ path="/api/plugin/update",
240
+ query={"location": self._location(location)},
241
+ body={"targets": targets},
242
+ extra_headers=extra_headers,
243
+ extra_query=extra_query,
244
+ extra_body=extra_body,
245
+ timeout=timeout,
246
+ ),
247
+ kind="void",
248
+ )
@@ -0,0 +1,185 @@
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 ``project`` resource."""
5
+
6
+ from __future__ import annotations
7
+
8
+ import builtins
9
+ from typing import 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
+ AbsolutePath,
17
+ Project,
18
+ ProjectCommands,
19
+ ProjectIcon,
20
+ ProjectID,
21
+ )
22
+
23
+ __all__ = ["ProjectResource", "AsyncProjectResource"]
24
+
25
+
26
+ class ProjectResource(SyncAPIResource):
27
+ """Operations under ``client.project`` (OpenCode ``project``)."""
28
+
29
+ def list(
30
+ self,
31
+ *,
32
+ archived: bool | NotGiven | None = NOT_GIVEN,
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[Project]:
38
+ """List projects.
39
+
40
+ List known projects. Archived projects are excluded unless archived=true.
41
+
42
+ Raises:
43
+ InvalidRequestError
44
+ UnauthorizedError
45
+ LocationNotFoundError
46
+
47
+ ``GET /api/project``
48
+ """
49
+ return cast(
50
+ "builtins.list[Project]",
51
+ self._client.request(
52
+ RequestOptions(
53
+ method="GET",
54
+ path="/api/project",
55
+ query={"archived": archived},
56
+ extra_headers=extra_headers,
57
+ extra_query=extra_query,
58
+ extra_body=extra_body,
59
+ timeout=timeout,
60
+ ),
61
+ response_type=builtins.list[Project],
62
+ ),
63
+ )
64
+
65
+ def update(
66
+ self,
67
+ project_id: ProjectID,
68
+ *,
69
+ canonical: AbsolutePath | NotGiven = NOT_GIVEN,
70
+ name: str | NotGiven = NOT_GIVEN,
71
+ icon: ProjectIcon | NotGiven = NOT_GIVEN,
72
+ commands: ProjectCommands | NotGiven = NOT_GIVEN,
73
+ extra_headers: Headers | None = None,
74
+ extra_query: Query | None = None,
75
+ extra_body: Body | None = None,
76
+ timeout: Timeout | NotGiven = NOT_GIVEN,
77
+ ) -> Project:
78
+ """Update project.
79
+
80
+ Update the project canonical directory, display metadata, and workspace commands.
81
+
82
+ Raises:
83
+ InvalidRequestError
84
+ UnauthorizedError
85
+ ProjectNotFoundError
86
+ LocationNotFoundError
87
+
88
+ ``PATCH /api/project/:projectID``
89
+ """
90
+ return cast(
91
+ "Project",
92
+ self._client.request(
93
+ RequestOptions(
94
+ method="PATCH",
95
+ path=f"/api/project/{encode_path_segment(project_id)}",
96
+ body={"canonical": canonical, "name": name, "icon": icon, "commands": commands},
97
+ extra_headers=extra_headers,
98
+ extra_query=extra_query,
99
+ extra_body=extra_body,
100
+ timeout=timeout,
101
+ ),
102
+ response_type=Project,
103
+ ),
104
+ )
105
+
106
+
107
+ class AsyncProjectResource(AsyncAPIResource):
108
+ """Operations under ``client.project`` (OpenCode ``project``)."""
109
+
110
+ async def list(
111
+ self,
112
+ *,
113
+ archived: bool | 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
+ ) -> builtins.list[Project]:
119
+ """List projects.
120
+
121
+ List known projects. Archived projects are excluded unless archived=true.
122
+
123
+ Raises:
124
+ InvalidRequestError
125
+ UnauthorizedError
126
+ LocationNotFoundError
127
+
128
+ ``GET /api/project``
129
+ """
130
+ return cast(
131
+ "builtins.list[Project]",
132
+ await self._client.request(
133
+ RequestOptions(
134
+ method="GET",
135
+ path="/api/project",
136
+ query={"archived": archived},
137
+ extra_headers=extra_headers,
138
+ extra_query=extra_query,
139
+ extra_body=extra_body,
140
+ timeout=timeout,
141
+ ),
142
+ response_type=builtins.list[Project],
143
+ ),
144
+ )
145
+
146
+ async def update(
147
+ self,
148
+ project_id: ProjectID,
149
+ *,
150
+ canonical: AbsolutePath | NotGiven = NOT_GIVEN,
151
+ name: str | NotGiven = NOT_GIVEN,
152
+ icon: ProjectIcon | NotGiven = NOT_GIVEN,
153
+ commands: ProjectCommands | NotGiven = 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
+ ) -> Project:
159
+ """Update project.
160
+
161
+ Update the project canonical directory, display metadata, and workspace commands.
162
+
163
+ Raises:
164
+ InvalidRequestError
165
+ UnauthorizedError
166
+ ProjectNotFoundError
167
+ LocationNotFoundError
168
+
169
+ ``PATCH /api/project/:projectID``
170
+ """
171
+ return cast(
172
+ "Project",
173
+ await self._client.request(
174
+ RequestOptions(
175
+ method="PATCH",
176
+ path=f"/api/project/{encode_path_segment(project_id)}",
177
+ body={"canonical": canonical, "name": name, "icon": icon, "commands": commands},
178
+ extra_headers=extra_headers,
179
+ extra_query=extra_query,
180
+ extra_body=extra_body,
181
+ timeout=timeout,
182
+ ),
183
+ response_type=Project,
184
+ ),
185
+ )
@@ -0,0 +1,181 @@
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 ``provider`` resource."""
5
+
6
+ from __future__ import annotations
7
+
8
+ from typing import cast
9
+
10
+ from .._base_client import RequestOptions
11
+ from .._qs import encode_path_segment
12
+ from .._resource import AsyncAPIResource, SyncAPIResource
13
+ from .._types import NOT_GIVEN, Body, Headers, NotGiven, Query, Timeout
14
+ from ..types import (
15
+ Location,
16
+ ProviderGetResponse,
17
+ ProviderID,
18
+ ProviderListResponse,
19
+ )
20
+
21
+ __all__ = ["ProviderResource", "AsyncProviderResource"]
22
+
23
+
24
+ class ProviderResource(SyncAPIResource):
25
+ """Operations under ``client.provider`` (OpenCode ``provider``)."""
26
+
27
+ def list(
28
+ self,
29
+ *,
30
+ location: Location | NotGiven | None = NOT_GIVEN,
31
+ extra_headers: Headers | None = None,
32
+ extra_query: Query | None = None,
33
+ extra_body: Body | None = None,
34
+ timeout: Timeout | NotGiven = NOT_GIVEN,
35
+ ) -> ProviderListResponse:
36
+ """List providers.
37
+
38
+ Retrieve active AI providers so clients can show provider availability and configuration.
39
+
40
+ Raises:
41
+ InvalidRequestError
42
+ UnauthorizedError
43
+ LocationNotFoundError
44
+ ServiceUnavailableError
45
+
46
+ ``GET /api/provider``
47
+ """
48
+ return cast(
49
+ "ProviderListResponse",
50
+ self._client.request(
51
+ RequestOptions(
52
+ method="GET",
53
+ path="/api/provider",
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=ProviderListResponse,
61
+ ),
62
+ )
63
+
64
+ def get(
65
+ self,
66
+ provider_id: ProviderID,
67
+ *,
68
+ location: Location | NotGiven | None = 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
+ ) -> ProviderGetResponse:
74
+ """Get provider.
75
+
76
+ Retrieve a single AI provider so clients can inspect its availability and endpoint settings.
77
+
78
+ Raises:
79
+ InvalidRequestError
80
+ UnauthorizedError
81
+ ProviderNotFoundError
82
+ LocationNotFoundError
83
+ ServiceUnavailableError
84
+
85
+ ``GET /api/provider/:providerID``
86
+ """
87
+ return cast(
88
+ "ProviderGetResponse",
89
+ self._client.request(
90
+ RequestOptions(
91
+ method="GET",
92
+ path=f"/api/provider/{encode_path_segment(provider_id)}",
93
+ query={"location": self._location(location)},
94
+ extra_headers=extra_headers,
95
+ extra_query=extra_query,
96
+ extra_body=extra_body,
97
+ timeout=timeout,
98
+ ),
99
+ response_type=ProviderGetResponse,
100
+ ),
101
+ )
102
+
103
+
104
+ class AsyncProviderResource(AsyncAPIResource):
105
+ """Operations under ``client.provider`` (OpenCode ``provider``)."""
106
+
107
+ async def list(
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
+ ) -> ProviderListResponse:
116
+ """List providers.
117
+
118
+ Retrieve active AI providers so clients can show provider availability and configuration.
119
+
120
+ Raises:
121
+ InvalidRequestError
122
+ UnauthorizedError
123
+ LocationNotFoundError
124
+ ServiceUnavailableError
125
+
126
+ ``GET /api/provider``
127
+ """
128
+ return cast(
129
+ "ProviderListResponse",
130
+ await self._client.request(
131
+ RequestOptions(
132
+ method="GET",
133
+ path="/api/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=ProviderListResponse,
141
+ ),
142
+ )
143
+
144
+ async def get(
145
+ self,
146
+ provider_id: ProviderID,
147
+ *,
148
+ location: Location | NotGiven | None = NOT_GIVEN,
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
+ ) -> ProviderGetResponse:
154
+ """Get provider.
155
+
156
+ Retrieve a single AI provider so clients can inspect its availability and endpoint settings.
157
+
158
+ Raises:
159
+ InvalidRequestError
160
+ UnauthorizedError
161
+ ProviderNotFoundError
162
+ LocationNotFoundError
163
+ ServiceUnavailableError
164
+
165
+ ``GET /api/provider/:providerID``
166
+ """
167
+ return cast(
168
+ "ProviderGetResponse",
169
+ await self._client.request(
170
+ RequestOptions(
171
+ method="GET",
172
+ path=f"/api/provider/{encode_path_segment(provider_id)}",
173
+ query={"location": self._location(location)},
174
+ extra_headers=extra_headers,
175
+ extra_query=extra_query,
176
+ extra_body=extra_body,
177
+ timeout=timeout,
178
+ ),
179
+ response_type=ProviderGetResponse,
180
+ ),
181
+ )