opencode-python-sdk 0.1.3__py3-none-any.whl → 0.2.2__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/__init__.py +19 -1
- opencode/_base_client.py +24 -3
- opencode/_client.py +173 -2
- opencode/_events.py +5 -2
- opencode/_rpc.py +9 -2
- opencode/_service.py +1018 -0
- opencode/lib/__init__.py +5 -0
- opencode/lib/_ready.py +91 -0
- opencode/lib/_session.py +231 -0
- opencode/resources/agent.py +13 -11
- opencode/resources/command.py +9 -7
- opencode/resources/config.py +12 -10
- opencode/resources/credential.py +13 -11
- opencode/resources/debug.py +9 -7
- opencode/resources/event.py +9 -5
- opencode/resources/experimental.py +31 -29
- opencode/resources/file.py +15 -13
- opencode/resources/form.py +9 -7
- opencode/resources/generate.py +9 -7
- opencode/resources/integration.py +28 -26
- opencode/resources/location.py +9 -7
- opencode/resources/mcp.py +13 -11
- opencode/resources/message.py +9 -8
- opencode/resources/migration.py +10 -12
- opencode/resources/model.py +12 -10
- opencode/resources/permission.py +29 -27
- opencode/resources/plugin.py +12 -10
- opencode/resources/project.py +14 -12
- opencode/resources/provider.py +13 -11
- opencode/resources/pty.py +23 -21
- opencode/resources/reference.py +9 -7
- opencode/resources/rpc.py +9 -7
- opencode/resources/server.py +14 -12
- opencode/resources/session.py +92 -90
- opencode/resources/shell.py +19 -17
- opencode/resources/skill.py +9 -7
- opencode/resources/vcs.py +22 -20
- opencode/resources/voice.py +9 -7
- opencode/resources/websearch.py +13 -11
- opencode/resources/worktree.py +13 -11
- opencode/service.py +50 -0
- opencode/testing.py +508 -0
- {opencode_python_sdk-0.1.3.dist-info → opencode_python_sdk-0.2.2.dist-info}/METADATA +71 -1
- opencode_python_sdk-0.2.2.dist-info/RECORD +64 -0
- opencode_python_sdk-0.1.3.dist-info/RECORD +0 -58
- {opencode_python_sdk-0.1.3.dist-info → opencode_python_sdk-0.2.2.dist-info}/WHEEL +0 -0
- {opencode_python_sdk-0.1.3.dist-info → opencode_python_sdk-0.2.2.dist-info}/licenses/LICENSE +0 -0
opencode/resources/vcs.py
CHANGED
|
@@ -6,20 +6,22 @@
|
|
|
6
6
|
from __future__ import annotations
|
|
7
7
|
|
|
8
8
|
from functools import cached_property
|
|
9
|
-
from typing import cast
|
|
9
|
+
from typing import TYPE_CHECKING, cast
|
|
10
10
|
|
|
11
11
|
from .._base_client import RequestOptions
|
|
12
12
|
from .._resource import AsyncAPIResource, SyncAPIResource
|
|
13
13
|
from .._types import NOT_GIVEN, Body, Headers, NotGiven, Query, Timeout
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
|
|
15
|
+
if TYPE_CHECKING:
|
|
16
|
+
from ..types import (
|
|
17
|
+
Location,
|
|
18
|
+
VcsBaseResponse,
|
|
19
|
+
VcsBranchListResponse,
|
|
20
|
+
VcsDiffResponse,
|
|
21
|
+
VcsGetResponse,
|
|
22
|
+
VcsMode,
|
|
23
|
+
VcsStatusResponse,
|
|
24
|
+
)
|
|
23
25
|
|
|
24
26
|
__all__ = ["VcsResource", "AsyncVcsResource"]
|
|
25
27
|
|
|
@@ -61,7 +63,7 @@ class VcsBranchResource(SyncAPIResource):
|
|
|
61
63
|
extra_body=extra_body,
|
|
62
64
|
timeout=timeout,
|
|
63
65
|
),
|
|
64
|
-
response_type=VcsBranchListResponse,
|
|
66
|
+
response_type="VcsBranchListResponse",
|
|
65
67
|
),
|
|
66
68
|
)
|
|
67
69
|
|
|
@@ -143,7 +145,7 @@ class VcsResource(SyncAPIResource):
|
|
|
143
145
|
extra_body=extra_body,
|
|
144
146
|
timeout=timeout,
|
|
145
147
|
),
|
|
146
|
-
response_type=VcsGetResponse,
|
|
148
|
+
response_type="VcsGetResponse",
|
|
147
149
|
),
|
|
148
150
|
)
|
|
149
151
|
|
|
@@ -180,7 +182,7 @@ class VcsResource(SyncAPIResource):
|
|
|
180
182
|
extra_body=extra_body,
|
|
181
183
|
timeout=timeout,
|
|
182
184
|
),
|
|
183
|
-
response_type=VcsBaseResponse,
|
|
185
|
+
response_type="VcsBaseResponse",
|
|
184
186
|
),
|
|
185
187
|
)
|
|
186
188
|
|
|
@@ -216,7 +218,7 @@ class VcsResource(SyncAPIResource):
|
|
|
216
218
|
extra_body=extra_body,
|
|
217
219
|
timeout=timeout,
|
|
218
220
|
),
|
|
219
|
-
response_type=VcsStatusResponse,
|
|
221
|
+
response_type="VcsStatusResponse",
|
|
220
222
|
),
|
|
221
223
|
)
|
|
222
224
|
|
|
@@ -256,7 +258,7 @@ class VcsResource(SyncAPIResource):
|
|
|
256
258
|
extra_body=extra_body,
|
|
257
259
|
timeout=timeout,
|
|
258
260
|
),
|
|
259
|
-
response_type=VcsDiffResponse,
|
|
261
|
+
response_type="VcsDiffResponse",
|
|
260
262
|
),
|
|
261
263
|
)
|
|
262
264
|
|
|
@@ -298,7 +300,7 @@ class AsyncVcsBranchResource(AsyncAPIResource):
|
|
|
298
300
|
extra_body=extra_body,
|
|
299
301
|
timeout=timeout,
|
|
300
302
|
),
|
|
301
|
-
response_type=VcsBranchListResponse,
|
|
303
|
+
response_type="VcsBranchListResponse",
|
|
302
304
|
),
|
|
303
305
|
)
|
|
304
306
|
|
|
@@ -380,7 +382,7 @@ class AsyncVcsResource(AsyncAPIResource):
|
|
|
380
382
|
extra_body=extra_body,
|
|
381
383
|
timeout=timeout,
|
|
382
384
|
),
|
|
383
|
-
response_type=VcsGetResponse,
|
|
385
|
+
response_type="VcsGetResponse",
|
|
384
386
|
),
|
|
385
387
|
)
|
|
386
388
|
|
|
@@ -417,7 +419,7 @@ class AsyncVcsResource(AsyncAPIResource):
|
|
|
417
419
|
extra_body=extra_body,
|
|
418
420
|
timeout=timeout,
|
|
419
421
|
),
|
|
420
|
-
response_type=VcsBaseResponse,
|
|
422
|
+
response_type="VcsBaseResponse",
|
|
421
423
|
),
|
|
422
424
|
)
|
|
423
425
|
|
|
@@ -453,7 +455,7 @@ class AsyncVcsResource(AsyncAPIResource):
|
|
|
453
455
|
extra_body=extra_body,
|
|
454
456
|
timeout=timeout,
|
|
455
457
|
),
|
|
456
|
-
response_type=VcsStatusResponse,
|
|
458
|
+
response_type="VcsStatusResponse",
|
|
457
459
|
),
|
|
458
460
|
)
|
|
459
461
|
|
|
@@ -493,6 +495,6 @@ class AsyncVcsResource(AsyncAPIResource):
|
|
|
493
495
|
extra_body=extra_body,
|
|
494
496
|
timeout=timeout,
|
|
495
497
|
),
|
|
496
|
-
response_type=VcsDiffResponse,
|
|
498
|
+
response_type="VcsDiffResponse",
|
|
497
499
|
),
|
|
498
500
|
)
|
opencode/resources/voice.py
CHANGED
|
@@ -6,15 +6,17 @@
|
|
|
6
6
|
from __future__ import annotations
|
|
7
7
|
|
|
8
8
|
from collections.abc import Mapping
|
|
9
|
-
from typing import Any, cast
|
|
9
|
+
from typing import TYPE_CHECKING, Any, cast
|
|
10
10
|
|
|
11
11
|
from .._base_client import RequestOptions
|
|
12
12
|
from .._resource import AsyncAPIResource, SyncAPIResource
|
|
13
13
|
from .._types import NOT_GIVEN, Body, Headers, NotGiven, Query, Timeout
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
|
|
15
|
+
if TYPE_CHECKING:
|
|
16
|
+
from ..types import (
|
|
17
|
+
VoiceSessionResponseData,
|
|
18
|
+
VoiceTransportInput,
|
|
19
|
+
)
|
|
18
20
|
|
|
19
21
|
__all__ = ["VoiceResource", "AsyncVoiceResource"]
|
|
20
22
|
|
|
@@ -59,7 +61,7 @@ class VoiceResource(SyncAPIResource):
|
|
|
59
61
|
extra_body=extra_body,
|
|
60
62
|
timeout=timeout,
|
|
61
63
|
),
|
|
62
|
-
response_type=VoiceSessionResponseData,
|
|
64
|
+
response_type="VoiceSessionResponseData",
|
|
63
65
|
unwrap=True,
|
|
64
66
|
),
|
|
65
67
|
)
|
|
@@ -105,7 +107,7 @@ class AsyncVoiceResource(AsyncAPIResource):
|
|
|
105
107
|
extra_body=extra_body,
|
|
106
108
|
timeout=timeout,
|
|
107
109
|
),
|
|
108
|
-
response_type=VoiceSessionResponseData,
|
|
110
|
+
response_type="VoiceSessionResponseData",
|
|
109
111
|
unwrap=True,
|
|
110
112
|
),
|
|
111
113
|
)
|
opencode/resources/websearch.py
CHANGED
|
@@ -5,17 +5,19 @@
|
|
|
5
5
|
|
|
6
6
|
from __future__ import annotations
|
|
7
7
|
|
|
8
|
-
from typing import cast
|
|
8
|
+
from typing import TYPE_CHECKING, cast
|
|
9
9
|
|
|
10
10
|
from .._base_client import RequestOptions
|
|
11
11
|
from .._resource import AsyncAPIResource, SyncAPIResource
|
|
12
12
|
from .._types import NOT_GIVEN, Body, Headers, NotGiven, Query, Timeout
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
|
|
14
|
+
if TYPE_CHECKING:
|
|
15
|
+
from ..types import (
|
|
16
|
+
Location,
|
|
17
|
+
WebSearchID,
|
|
18
|
+
WebsearchProvidersResponse,
|
|
19
|
+
WebsearchQueryResponse,
|
|
20
|
+
)
|
|
19
21
|
|
|
20
22
|
__all__ = ["WebsearchResource", "AsyncWebsearchResource"]
|
|
21
23
|
|
|
@@ -56,7 +58,7 @@ class WebsearchResource(SyncAPIResource):
|
|
|
56
58
|
extra_body=extra_body,
|
|
57
59
|
timeout=timeout,
|
|
58
60
|
),
|
|
59
|
-
response_type=WebsearchProvidersResponse,
|
|
61
|
+
response_type="WebsearchProvidersResponse",
|
|
60
62
|
),
|
|
61
63
|
)
|
|
62
64
|
|
|
@@ -96,7 +98,7 @@ class WebsearchResource(SyncAPIResource):
|
|
|
96
98
|
extra_body=extra_body,
|
|
97
99
|
timeout=timeout,
|
|
98
100
|
),
|
|
99
|
-
response_type=WebsearchQueryResponse,
|
|
101
|
+
response_type="WebsearchQueryResponse",
|
|
100
102
|
),
|
|
101
103
|
)
|
|
102
104
|
|
|
@@ -137,7 +139,7 @@ class AsyncWebsearchResource(AsyncAPIResource):
|
|
|
137
139
|
extra_body=extra_body,
|
|
138
140
|
timeout=timeout,
|
|
139
141
|
),
|
|
140
|
-
response_type=WebsearchProvidersResponse,
|
|
142
|
+
response_type="WebsearchProvidersResponse",
|
|
141
143
|
),
|
|
142
144
|
)
|
|
143
145
|
|
|
@@ -177,6 +179,6 @@ class AsyncWebsearchResource(AsyncAPIResource):
|
|
|
177
179
|
extra_body=extra_body,
|
|
178
180
|
timeout=timeout,
|
|
179
181
|
),
|
|
180
|
-
response_type=WebsearchQueryResponse,
|
|
182
|
+
response_type="WebsearchQueryResponse",
|
|
181
183
|
),
|
|
182
184
|
)
|
opencode/resources/worktree.py
CHANGED
|
@@ -5,17 +5,19 @@
|
|
|
5
5
|
|
|
6
6
|
from __future__ import annotations
|
|
7
7
|
|
|
8
|
-
from typing import cast
|
|
8
|
+
from typing import TYPE_CHECKING, cast
|
|
9
9
|
|
|
10
10
|
from .._base_client import RequestOptions
|
|
11
11
|
from .._resource import AsyncAPIResource, SyncAPIResource
|
|
12
12
|
from .._types import NOT_GIVEN, Body, Headers, NotGiven, Query, Timeout
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
|
|
14
|
+
if TYPE_CHECKING:
|
|
15
|
+
from ..types import (
|
|
16
|
+
AbsolutePath,
|
|
17
|
+
ProjectID,
|
|
18
|
+
WorktreeInfo,
|
|
19
|
+
WorktreeList,
|
|
20
|
+
)
|
|
19
21
|
|
|
20
22
|
__all__ = ["WorktreeResource", "AsyncWorktreeResource"]
|
|
21
23
|
|
|
@@ -55,7 +57,7 @@ class WorktreeResource(SyncAPIResource):
|
|
|
55
57
|
extra_body=extra_body,
|
|
56
58
|
timeout=timeout,
|
|
57
59
|
),
|
|
58
|
-
response_type=WorktreeList,
|
|
60
|
+
response_type="WorktreeList",
|
|
59
61
|
),
|
|
60
62
|
)
|
|
61
63
|
|
|
@@ -102,7 +104,7 @@ class WorktreeResource(SyncAPIResource):
|
|
|
102
104
|
extra_body=extra_body,
|
|
103
105
|
timeout=timeout,
|
|
104
106
|
),
|
|
105
|
-
response_type=WorktreeInfo,
|
|
107
|
+
response_type="WorktreeInfo",
|
|
106
108
|
),
|
|
107
109
|
)
|
|
108
110
|
|
|
@@ -212,7 +214,7 @@ class AsyncWorktreeResource(AsyncAPIResource):
|
|
|
212
214
|
extra_body=extra_body,
|
|
213
215
|
timeout=timeout,
|
|
214
216
|
),
|
|
215
|
-
response_type=WorktreeList,
|
|
217
|
+
response_type="WorktreeList",
|
|
216
218
|
),
|
|
217
219
|
)
|
|
218
220
|
|
|
@@ -259,7 +261,7 @@ class AsyncWorktreeResource(AsyncAPIResource):
|
|
|
259
261
|
extra_body=extra_body,
|
|
260
262
|
timeout=timeout,
|
|
261
263
|
),
|
|
262
|
-
response_type=WorktreeInfo,
|
|
264
|
+
response_type="WorktreeInfo",
|
|
263
265
|
),
|
|
264
266
|
)
|
|
265
267
|
|
opencode/service.py
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"""Find, start and stop the local OpenCode background service.
|
|
2
|
+
|
|
3
|
+
Example::
|
|
4
|
+
|
|
5
|
+
from opencode import Opencode, service
|
|
6
|
+
|
|
7
|
+
endpoint = service.ensure() # or service.discover(), which never starts one
|
|
8
|
+
print(endpoint.url)
|
|
9
|
+
|
|
10
|
+
with Opencode.from_service() as client:
|
|
11
|
+
print(client.server.info().version)
|
|
12
|
+
|
|
13
|
+
See :mod:`opencode._service` for how this follows the TypeScript client.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
from ._service import (
|
|
19
|
+
BasicAuth,
|
|
20
|
+
Endpoint,
|
|
21
|
+
EnsureReason,
|
|
22
|
+
PtyMode,
|
|
23
|
+
ServiceError,
|
|
24
|
+
Version,
|
|
25
|
+
async_discover,
|
|
26
|
+
async_ensure,
|
|
27
|
+
async_stop,
|
|
28
|
+
default_file,
|
|
29
|
+
discover,
|
|
30
|
+
ensure,
|
|
31
|
+
headers,
|
|
32
|
+
stop,
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
__all__ = [
|
|
36
|
+
"BasicAuth",
|
|
37
|
+
"Endpoint",
|
|
38
|
+
"EnsureReason",
|
|
39
|
+
"PtyMode",
|
|
40
|
+
"ServiceError",
|
|
41
|
+
"Version",
|
|
42
|
+
"async_discover",
|
|
43
|
+
"async_ensure",
|
|
44
|
+
"async_stop",
|
|
45
|
+
"default_file",
|
|
46
|
+
"discover",
|
|
47
|
+
"ensure",
|
|
48
|
+
"headers",
|
|
49
|
+
"stop",
|
|
50
|
+
]
|