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,111 @@
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 ``rpc`` resource."""
5
+
6
+ from __future__ import annotations
7
+
8
+ from typing import Any, 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
+ RpcOutput,
17
+ )
18
+
19
+ __all__ = ["RpcResource", "AsyncRpcResource"]
20
+
21
+
22
+ class RpcResource(SyncAPIResource):
23
+ """Operations under ``client.rpc`` (OpenCode ``rpc``)."""
24
+
25
+ def call(
26
+ self,
27
+ rpc_id: str,
28
+ method: str,
29
+ *,
30
+ location: Location | NotGiven | None = NOT_GIVEN,
31
+ input: Any | NotGiven = 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
+ ) -> RpcOutput:
37
+ """Call a plugin RPC.
38
+
39
+ Dispatch a method to the currently registered RPC at the requested location.
40
+
41
+ Raises:
42
+ RpcError
43
+ InvalidRequestError
44
+ UnauthorizedError
45
+ LocationNotFoundError
46
+ RpcInternalError
47
+
48
+ ``POST /api/rpc/:rpcID/:method``
49
+ """
50
+ return cast(
51
+ "RpcOutput",
52
+ self._client.request(
53
+ RequestOptions(
54
+ method="POST",
55
+ path=f"/api/rpc/{encode_path_segment(rpc_id)}/{encode_path_segment(method)}",
56
+ query={"location": self._location(location)},
57
+ body={"input": input},
58
+ extra_headers=extra_headers,
59
+ extra_query=extra_query,
60
+ extra_body=extra_body,
61
+ timeout=timeout,
62
+ ),
63
+ response_type=RpcOutput,
64
+ ),
65
+ )
66
+
67
+
68
+ class AsyncRpcResource(AsyncAPIResource):
69
+ """Operations under ``client.rpc`` (OpenCode ``rpc``)."""
70
+
71
+ async def call(
72
+ self,
73
+ rpc_id: str,
74
+ method: str,
75
+ *,
76
+ location: Location | NotGiven | None = NOT_GIVEN,
77
+ input: Any | NotGiven = NOT_GIVEN,
78
+ extra_headers: Headers | None = None,
79
+ extra_query: Query | None = None,
80
+ extra_body: Body | None = None,
81
+ timeout: Timeout | NotGiven = NOT_GIVEN,
82
+ ) -> RpcOutput:
83
+ """Call a plugin RPC.
84
+
85
+ Dispatch a method to the currently registered RPC at the requested location.
86
+
87
+ Raises:
88
+ RpcError
89
+ InvalidRequestError
90
+ UnauthorizedError
91
+ LocationNotFoundError
92
+ RpcInternalError
93
+
94
+ ``POST /api/rpc/:rpcID/:method``
95
+ """
96
+ return cast(
97
+ "RpcOutput",
98
+ await self._client.request(
99
+ RequestOptions(
100
+ method="POST",
101
+ path=f"/api/rpc/{encode_path_segment(rpc_id)}/{encode_path_segment(method)}",
102
+ query={"location": self._location(location)},
103
+ body={"input": input},
104
+ extra_headers=extra_headers,
105
+ extra_query=extra_query,
106
+ extra_body=extra_body,
107
+ timeout=timeout,
108
+ ),
109
+ response_type=RpcOutput,
110
+ ),
111
+ )
@@ -0,0 +1,228 @@
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 ``server`` 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
+ PairingCode,
16
+ PairingSession,
17
+ ServerInfo,
18
+ )
19
+
20
+ __all__ = ["ServerResource", "AsyncServerResource"]
21
+
22
+
23
+ class ServerResource(SyncAPIResource):
24
+ """Operations under ``client.server`` (OpenCode ``server``)."""
25
+
26
+ def info(
27
+ self,
28
+ *,
29
+ extra_headers: Headers | None = None,
30
+ extra_query: Query | None = None,
31
+ extra_body: Body | None = None,
32
+ timeout: Timeout | NotGiven = NOT_GIVEN,
33
+ ) -> ServerInfo:
34
+ """Get server info.
35
+
36
+ Return the server identity, connection URLs, paths, and readiness status.
37
+
38
+ Raises:
39
+ InvalidRequestError
40
+ UnauthorizedError
41
+
42
+ ``GET /api/info``
43
+ """
44
+ return cast(
45
+ "ServerInfo",
46
+ self._client.request(
47
+ RequestOptions(
48
+ method="GET",
49
+ path="/api/info",
50
+ extra_headers=extra_headers,
51
+ extra_query=extra_query,
52
+ extra_body=extra_body,
53
+ timeout=timeout,
54
+ ),
55
+ response_type=ServerInfo,
56
+ ),
57
+ )
58
+
59
+ def pair(
60
+ self,
61
+ *,
62
+ extra_headers: Headers | None = None,
63
+ extra_query: Query | None = None,
64
+ extra_body: Body | None = None,
65
+ timeout: Timeout | NotGiven = NOT_GIVEN,
66
+ ) -> PairingCode:
67
+ """Create pairing code.
68
+
69
+ Create a short-lived, single-use code for a /auth/connect/:code pairing link.
70
+
71
+ Raises:
72
+ InvalidRequestError
73
+ UnauthorizedError
74
+
75
+ ``POST /api/pair``
76
+ """
77
+ return cast(
78
+ "PairingCode",
79
+ self._client.request(
80
+ RequestOptions(
81
+ method="POST",
82
+ path="/api/pair",
83
+ extra_headers=extra_headers,
84
+ extra_query=extra_query,
85
+ extra_body=extra_body,
86
+ timeout=timeout,
87
+ ),
88
+ response_type=PairingCode,
89
+ ),
90
+ )
91
+
92
+ def connect(
93
+ self,
94
+ code: str,
95
+ *,
96
+ extra_headers: Headers | None = None,
97
+ extra_query: Query | None = None,
98
+ extra_body: Body | None = None,
99
+ timeout: Timeout | NotGiven = NOT_GIVEN,
100
+ ) -> PairingSession:
101
+ """Redeem pairing code.
102
+
103
+ Redeem a pairing code. Browsers receive a session cookie and a redirect to the web app; requests that accept JSON receive a session token to use as the password.
104
+
105
+ Raises:
106
+ InvalidRequestError
107
+ UnauthorizedError
108
+
109
+ ``GET /auth/connect/:code``
110
+ """
111
+ return cast(
112
+ "PairingSession",
113
+ self._client.request(
114
+ RequestOptions(
115
+ method="GET",
116
+ path=f"/auth/connect/{encode_path_segment(code)}",
117
+ extra_headers=extra_headers,
118
+ extra_query=extra_query,
119
+ extra_body=extra_body,
120
+ timeout=timeout,
121
+ ),
122
+ response_type=PairingSession,
123
+ ),
124
+ )
125
+
126
+
127
+ class AsyncServerResource(AsyncAPIResource):
128
+ """Operations under ``client.server`` (OpenCode ``server``)."""
129
+
130
+ async def info(
131
+ self,
132
+ *,
133
+ extra_headers: Headers | None = None,
134
+ extra_query: Query | None = None,
135
+ extra_body: Body | None = None,
136
+ timeout: Timeout | NotGiven = NOT_GIVEN,
137
+ ) -> ServerInfo:
138
+ """Get server info.
139
+
140
+ Return the server identity, connection URLs, paths, and readiness status.
141
+
142
+ Raises:
143
+ InvalidRequestError
144
+ UnauthorizedError
145
+
146
+ ``GET /api/info``
147
+ """
148
+ return cast(
149
+ "ServerInfo",
150
+ await self._client.request(
151
+ RequestOptions(
152
+ method="GET",
153
+ path="/api/info",
154
+ extra_headers=extra_headers,
155
+ extra_query=extra_query,
156
+ extra_body=extra_body,
157
+ timeout=timeout,
158
+ ),
159
+ response_type=ServerInfo,
160
+ ),
161
+ )
162
+
163
+ async def pair(
164
+ self,
165
+ *,
166
+ extra_headers: Headers | None = None,
167
+ extra_query: Query | None = None,
168
+ extra_body: Body | None = None,
169
+ timeout: Timeout | NotGiven = NOT_GIVEN,
170
+ ) -> PairingCode:
171
+ """Create pairing code.
172
+
173
+ Create a short-lived, single-use code for a /auth/connect/:code pairing link.
174
+
175
+ Raises:
176
+ InvalidRequestError
177
+ UnauthorizedError
178
+
179
+ ``POST /api/pair``
180
+ """
181
+ return cast(
182
+ "PairingCode",
183
+ await self._client.request(
184
+ RequestOptions(
185
+ method="POST",
186
+ path="/api/pair",
187
+ extra_headers=extra_headers,
188
+ extra_query=extra_query,
189
+ extra_body=extra_body,
190
+ timeout=timeout,
191
+ ),
192
+ response_type=PairingCode,
193
+ ),
194
+ )
195
+
196
+ async def connect(
197
+ self,
198
+ code: str,
199
+ *,
200
+ extra_headers: Headers | None = None,
201
+ extra_query: Query | None = None,
202
+ extra_body: Body | None = None,
203
+ timeout: Timeout | NotGiven = NOT_GIVEN,
204
+ ) -> PairingSession:
205
+ """Redeem pairing code.
206
+
207
+ Redeem a pairing code. Browsers receive a session cookie and a redirect to the web app; requests that accept JSON receive a session token to use as the password.
208
+
209
+ Raises:
210
+ InvalidRequestError
211
+ UnauthorizedError
212
+
213
+ ``GET /auth/connect/:code``
214
+ """
215
+ return cast(
216
+ "PairingSession",
217
+ await self._client.request(
218
+ RequestOptions(
219
+ method="GET",
220
+ path=f"/auth/connect/{encode_path_segment(code)}",
221
+ extra_headers=extra_headers,
222
+ extra_query=extra_query,
223
+ extra_body=extra_body,
224
+ timeout=timeout,
225
+ ),
226
+ response_type=PairingSession,
227
+ ),
228
+ )