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.
- opencode/.generated.json +39 -0
- opencode/__init__.py +221 -0
- opencode/_base_client.py +539 -0
- opencode/_client.py +255 -0
- opencode/_constants.py +27 -0
- opencode/_errors.py +547 -0
- opencode/_events.py +732 -0
- opencode/_exceptions.py +271 -0
- opencode/_models.py +54 -0
- opencode/_pagination.py +192 -0
- opencode/_pty.py +586 -0
- opencode/_qs.py +95 -0
- opencode/_resource.py +42 -0
- opencode/_rpc.py +489 -0
- opencode/_server.py +335 -0
- opencode/_streaming.py +248 -0
- opencode/_types.py +77 -0
- opencode/_unions.py +46 -0
- opencode/_version.py +8 -0
- opencode/lib/__init__.py +5 -0
- opencode/lib/_ready.py +91 -0
- opencode/lib/_session.py +231 -0
- opencode/py.typed +0 -0
- opencode/resources/__init__.py +364 -0
- opencode/resources/agent.py +179 -0
- opencode/resources/command.py +100 -0
- opencode/resources/config.py +240 -0
- opencode/resources/credential.py +384 -0
- opencode/resources/debug.py +178 -0
- opencode/resources/event.py +88 -0
- opencode/resources/experimental.py +765 -0
- opencode/resources/file.py +355 -0
- opencode/resources/form.py +100 -0
- opencode/resources/generate.py +110 -0
- opencode/resources/integration.py +1033 -0
- opencode/resources/location.py +162 -0
- opencode/resources/mcp.py +492 -0
- opencode/resources/message.py +152 -0
- opencode/resources/migration.py +118 -0
- opencode/resources/model.py +177 -0
- opencode/resources/permission.py +704 -0
- opencode/resources/plugin.py +250 -0
- opencode/resources/project.py +187 -0
- opencode/resources/provider.py +183 -0
- opencode/resources/pty.py +522 -0
- opencode/resources/reference.py +100 -0
- opencode/resources/rpc.py +113 -0
- opencode/resources/server.py +230 -0
- opencode/resources/session.py +3567 -0
- opencode/resources/shell.py +412 -0
- opencode/resources/skill.py +100 -0
- opencode/resources/vcs.py +500 -0
- opencode/resources/voice.py +113 -0
- opencode/resources/websearch.py +184 -0
- opencode/resources/worktree.py +336 -0
- opencode/testing.py +508 -0
- opencode/types/__init__.py +1462 -0
- opencode/types/_generated.py +8540 -0
- opencode_python_sdk-0.0.1.dev1.dist-info/METADATA +468 -0
- opencode_python_sdk-0.0.1.dev1.dist-info/RECORD +62 -0
- opencode_python_sdk-0.0.1.dev1.dist-info/WHEEL +4 -0
- opencode_python_sdk-0.0.1.dev1.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,113 @@
|
|
|
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 TYPE_CHECKING, 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
|
+
|
|
15
|
+
if TYPE_CHECKING:
|
|
16
|
+
from ..types import (
|
|
17
|
+
Location,
|
|
18
|
+
RpcOutput,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
__all__ = ["RpcResource", "AsyncRpcResource"]
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class RpcResource(SyncAPIResource):
|
|
25
|
+
"""Operations under ``client.rpc`` (OpenCode ``rpc``)."""
|
|
26
|
+
|
|
27
|
+
def call(
|
|
28
|
+
self,
|
|
29
|
+
rpc_id: str,
|
|
30
|
+
method: str,
|
|
31
|
+
*,
|
|
32
|
+
location: Location | NotGiven | None = NOT_GIVEN,
|
|
33
|
+
input: Any | NotGiven = 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
|
+
) -> RpcOutput:
|
|
39
|
+
"""Call a plugin RPC.
|
|
40
|
+
|
|
41
|
+
Dispatch a method to the currently registered RPC at the requested location.
|
|
42
|
+
|
|
43
|
+
Raises:
|
|
44
|
+
RpcError: The server answered 400.
|
|
45
|
+
InvalidRequestError: The server answered 400.
|
|
46
|
+
UnauthorizedError: The server answered 401.
|
|
47
|
+
LocationNotFoundError: The server answered 404.
|
|
48
|
+
RpcInternalError: The server answered 500.
|
|
49
|
+
|
|
50
|
+
``POST /api/rpc/:rpcID/:method``
|
|
51
|
+
"""
|
|
52
|
+
return cast(
|
|
53
|
+
"RpcOutput",
|
|
54
|
+
self._client.request(
|
|
55
|
+
RequestOptions(
|
|
56
|
+
method="POST",
|
|
57
|
+
path=f"/api/rpc/{encode_path_segment(rpc_id)}/{encode_path_segment(method)}",
|
|
58
|
+
query={"location": self._location(location)},
|
|
59
|
+
body={"input": input},
|
|
60
|
+
extra_headers=extra_headers,
|
|
61
|
+
extra_query=extra_query,
|
|
62
|
+
extra_body=extra_body,
|
|
63
|
+
timeout=timeout,
|
|
64
|
+
),
|
|
65
|
+
response_type="RpcOutput",
|
|
66
|
+
),
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class AsyncRpcResource(AsyncAPIResource):
|
|
71
|
+
"""Operations under ``client.rpc`` (OpenCode ``rpc``)."""
|
|
72
|
+
|
|
73
|
+
async def call(
|
|
74
|
+
self,
|
|
75
|
+
rpc_id: str,
|
|
76
|
+
method: str,
|
|
77
|
+
*,
|
|
78
|
+
location: Location | NotGiven | None = NOT_GIVEN,
|
|
79
|
+
input: Any | NotGiven = NOT_GIVEN,
|
|
80
|
+
extra_headers: Headers | None = None,
|
|
81
|
+
extra_query: Query | None = None,
|
|
82
|
+
extra_body: Body | None = None,
|
|
83
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
84
|
+
) -> RpcOutput:
|
|
85
|
+
"""Call a plugin RPC.
|
|
86
|
+
|
|
87
|
+
Dispatch a method to the currently registered RPC at the requested location.
|
|
88
|
+
|
|
89
|
+
Raises:
|
|
90
|
+
RpcError: The server answered 400.
|
|
91
|
+
InvalidRequestError: The server answered 400.
|
|
92
|
+
UnauthorizedError: The server answered 401.
|
|
93
|
+
LocationNotFoundError: The server answered 404.
|
|
94
|
+
RpcInternalError: The server answered 500.
|
|
95
|
+
|
|
96
|
+
``POST /api/rpc/:rpcID/:method``
|
|
97
|
+
"""
|
|
98
|
+
return cast(
|
|
99
|
+
"RpcOutput",
|
|
100
|
+
await self._client.request(
|
|
101
|
+
RequestOptions(
|
|
102
|
+
method="POST",
|
|
103
|
+
path=f"/api/rpc/{encode_path_segment(rpc_id)}/{encode_path_segment(method)}",
|
|
104
|
+
query={"location": self._location(location)},
|
|
105
|
+
body={"input": input},
|
|
106
|
+
extra_headers=extra_headers,
|
|
107
|
+
extra_query=extra_query,
|
|
108
|
+
extra_body=extra_body,
|
|
109
|
+
timeout=timeout,
|
|
110
|
+
),
|
|
111
|
+
response_type="RpcOutput",
|
|
112
|
+
),
|
|
113
|
+
)
|
|
@@ -0,0 +1,230 @@
|
|
|
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 TYPE_CHECKING, 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
|
+
|
|
15
|
+
if TYPE_CHECKING:
|
|
16
|
+
from ..types import (
|
|
17
|
+
PairingCode,
|
|
18
|
+
PairingSession,
|
|
19
|
+
ServerInfo,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
__all__ = ["ServerResource", "AsyncServerResource"]
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class ServerResource(SyncAPIResource):
|
|
26
|
+
"""Operations under ``client.server`` (OpenCode ``server``)."""
|
|
27
|
+
|
|
28
|
+
def info(
|
|
29
|
+
self,
|
|
30
|
+
*,
|
|
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
|
+
) -> ServerInfo:
|
|
36
|
+
"""Get server info.
|
|
37
|
+
|
|
38
|
+
Return the server identity, connection URLs, paths, and readiness status.
|
|
39
|
+
|
|
40
|
+
Raises:
|
|
41
|
+
InvalidRequestError: The server answered 400.
|
|
42
|
+
UnauthorizedError: The server answered 401.
|
|
43
|
+
|
|
44
|
+
``GET /api/info``
|
|
45
|
+
"""
|
|
46
|
+
return cast(
|
|
47
|
+
"ServerInfo",
|
|
48
|
+
self._client.request(
|
|
49
|
+
RequestOptions(
|
|
50
|
+
method="GET",
|
|
51
|
+
path="/api/info",
|
|
52
|
+
extra_headers=extra_headers,
|
|
53
|
+
extra_query=extra_query,
|
|
54
|
+
extra_body=extra_body,
|
|
55
|
+
timeout=timeout,
|
|
56
|
+
),
|
|
57
|
+
response_type="ServerInfo",
|
|
58
|
+
),
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
def pair(
|
|
62
|
+
self,
|
|
63
|
+
*,
|
|
64
|
+
extra_headers: Headers | None = None,
|
|
65
|
+
extra_query: Query | None = None,
|
|
66
|
+
extra_body: Body | None = None,
|
|
67
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
68
|
+
) -> PairingCode:
|
|
69
|
+
"""Create pairing code.
|
|
70
|
+
|
|
71
|
+
Create a short-lived, single-use code for a /auth/connect/:code pairing link.
|
|
72
|
+
|
|
73
|
+
Raises:
|
|
74
|
+
InvalidRequestError: The server answered 400.
|
|
75
|
+
UnauthorizedError: The server answered 401.
|
|
76
|
+
|
|
77
|
+
``POST /api/pair``
|
|
78
|
+
"""
|
|
79
|
+
return cast(
|
|
80
|
+
"PairingCode",
|
|
81
|
+
self._client.request(
|
|
82
|
+
RequestOptions(
|
|
83
|
+
method="POST",
|
|
84
|
+
path="/api/pair",
|
|
85
|
+
extra_headers=extra_headers,
|
|
86
|
+
extra_query=extra_query,
|
|
87
|
+
extra_body=extra_body,
|
|
88
|
+
timeout=timeout,
|
|
89
|
+
),
|
|
90
|
+
response_type="PairingCode",
|
|
91
|
+
),
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
def connect(
|
|
95
|
+
self,
|
|
96
|
+
code: str,
|
|
97
|
+
*,
|
|
98
|
+
extra_headers: Headers | None = None,
|
|
99
|
+
extra_query: Query | None = None,
|
|
100
|
+
extra_body: Body | None = None,
|
|
101
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
102
|
+
) -> PairingSession:
|
|
103
|
+
"""Redeem pairing code.
|
|
104
|
+
|
|
105
|
+
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.
|
|
106
|
+
|
|
107
|
+
Raises:
|
|
108
|
+
InvalidRequestError: The server answered 400.
|
|
109
|
+
UnauthorizedError: The server answered 401.
|
|
110
|
+
|
|
111
|
+
``GET /auth/connect/:code``
|
|
112
|
+
"""
|
|
113
|
+
return cast(
|
|
114
|
+
"PairingSession",
|
|
115
|
+
self._client.request(
|
|
116
|
+
RequestOptions(
|
|
117
|
+
method="GET",
|
|
118
|
+
path=f"/auth/connect/{encode_path_segment(code)}",
|
|
119
|
+
extra_headers=extra_headers,
|
|
120
|
+
extra_query=extra_query,
|
|
121
|
+
extra_body=extra_body,
|
|
122
|
+
timeout=timeout,
|
|
123
|
+
),
|
|
124
|
+
response_type="PairingSession",
|
|
125
|
+
),
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
class AsyncServerResource(AsyncAPIResource):
|
|
130
|
+
"""Operations under ``client.server`` (OpenCode ``server``)."""
|
|
131
|
+
|
|
132
|
+
async def info(
|
|
133
|
+
self,
|
|
134
|
+
*,
|
|
135
|
+
extra_headers: Headers | None = None,
|
|
136
|
+
extra_query: Query | None = None,
|
|
137
|
+
extra_body: Body | None = None,
|
|
138
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
139
|
+
) -> ServerInfo:
|
|
140
|
+
"""Get server info.
|
|
141
|
+
|
|
142
|
+
Return the server identity, connection URLs, paths, and readiness status.
|
|
143
|
+
|
|
144
|
+
Raises:
|
|
145
|
+
InvalidRequestError: The server answered 400.
|
|
146
|
+
UnauthorizedError: The server answered 401.
|
|
147
|
+
|
|
148
|
+
``GET /api/info``
|
|
149
|
+
"""
|
|
150
|
+
return cast(
|
|
151
|
+
"ServerInfo",
|
|
152
|
+
await self._client.request(
|
|
153
|
+
RequestOptions(
|
|
154
|
+
method="GET",
|
|
155
|
+
path="/api/info",
|
|
156
|
+
extra_headers=extra_headers,
|
|
157
|
+
extra_query=extra_query,
|
|
158
|
+
extra_body=extra_body,
|
|
159
|
+
timeout=timeout,
|
|
160
|
+
),
|
|
161
|
+
response_type="ServerInfo",
|
|
162
|
+
),
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
async def pair(
|
|
166
|
+
self,
|
|
167
|
+
*,
|
|
168
|
+
extra_headers: Headers | None = None,
|
|
169
|
+
extra_query: Query | None = None,
|
|
170
|
+
extra_body: Body | None = None,
|
|
171
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
172
|
+
) -> PairingCode:
|
|
173
|
+
"""Create pairing code.
|
|
174
|
+
|
|
175
|
+
Create a short-lived, single-use code for a /auth/connect/:code pairing link.
|
|
176
|
+
|
|
177
|
+
Raises:
|
|
178
|
+
InvalidRequestError: The server answered 400.
|
|
179
|
+
UnauthorizedError: The server answered 401.
|
|
180
|
+
|
|
181
|
+
``POST /api/pair``
|
|
182
|
+
"""
|
|
183
|
+
return cast(
|
|
184
|
+
"PairingCode",
|
|
185
|
+
await self._client.request(
|
|
186
|
+
RequestOptions(
|
|
187
|
+
method="POST",
|
|
188
|
+
path="/api/pair",
|
|
189
|
+
extra_headers=extra_headers,
|
|
190
|
+
extra_query=extra_query,
|
|
191
|
+
extra_body=extra_body,
|
|
192
|
+
timeout=timeout,
|
|
193
|
+
),
|
|
194
|
+
response_type="PairingCode",
|
|
195
|
+
),
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
async def connect(
|
|
199
|
+
self,
|
|
200
|
+
code: str,
|
|
201
|
+
*,
|
|
202
|
+
extra_headers: Headers | None = None,
|
|
203
|
+
extra_query: Query | None = None,
|
|
204
|
+
extra_body: Body | None = None,
|
|
205
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
206
|
+
) -> PairingSession:
|
|
207
|
+
"""Redeem pairing code.
|
|
208
|
+
|
|
209
|
+
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.
|
|
210
|
+
|
|
211
|
+
Raises:
|
|
212
|
+
InvalidRequestError: The server answered 400.
|
|
213
|
+
UnauthorizedError: The server answered 401.
|
|
214
|
+
|
|
215
|
+
``GET /auth/connect/:code``
|
|
216
|
+
"""
|
|
217
|
+
return cast(
|
|
218
|
+
"PairingSession",
|
|
219
|
+
await self._client.request(
|
|
220
|
+
RequestOptions(
|
|
221
|
+
method="GET",
|
|
222
|
+
path=f"/auth/connect/{encode_path_segment(code)}",
|
|
223
|
+
extra_headers=extra_headers,
|
|
224
|
+
extra_query=extra_query,
|
|
225
|
+
extra_body=extra_body,
|
|
226
|
+
timeout=timeout,
|
|
227
|
+
),
|
|
228
|
+
response_type="PairingSession",
|
|
229
|
+
),
|
|
230
|
+
)
|