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,517 @@
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 ``pty`` resource."""
5
+
6
+ from __future__ import annotations
7
+
8
+ from collections.abc import Mapping, Sequence
9
+ from functools import cached_property
10
+ from typing import cast
11
+
12
+ from .._base_client import RequestOptions
13
+ from .._qs import encode_path_segment
14
+ from .._resource import AsyncAPIResource, SyncAPIResource
15
+ from .._types import NOT_GIVEN, Body, Headers, NotGiven, Query, Timeout
16
+ from ..types import (
17
+ Location,
18
+ PtyConnectTokenResponse,
19
+ PtyCreateResponse,
20
+ PtyGetResponse,
21
+ PtyID,
22
+ PtyListResponse,
23
+ PtyUpdateResponse,
24
+ PtyUpdateSize,
25
+ )
26
+
27
+ __all__ = ["PtyResource", "AsyncPtyResource"]
28
+
29
+
30
+ class PtyConnectResource(SyncAPIResource):
31
+ """Operations under ``client.pty.connect`` (OpenCode ``pty.connect``)."""
32
+
33
+ def token(
34
+ self,
35
+ pty_id: PtyID,
36
+ *,
37
+ location: Location | NotGiven | None = NOT_GIVEN,
38
+ x_opencode_ticket: str | NotGiven | None = NOT_GIVEN,
39
+ extra_headers: Headers | None = None,
40
+ extra_query: Query | None = None,
41
+ extra_body: Body | None = None,
42
+ timeout: Timeout | NotGiven = NOT_GIVEN,
43
+ ) -> PtyConnectTokenResponse:
44
+ """Create PTY WebSocket token.
45
+
46
+ Create a short-lived single-use ticket for opening a PTY WebSocket connection.
47
+
48
+ Raises:
49
+ InvalidRequestError
50
+ UnauthorizedError
51
+ ForbiddenError
52
+ PtyNotFoundError
53
+ LocationNotFoundError
54
+
55
+ ``POST /api/pty/:ptyID/connect-token``
56
+ """
57
+ return cast(
58
+ "PtyConnectTokenResponse",
59
+ self._client.request(
60
+ RequestOptions(
61
+ method="POST",
62
+ path=f"/api/pty/{encode_path_segment(pty_id)}/connect-token",
63
+ query={"location": self._location(location)},
64
+ headers={"x-opencode-ticket": x_opencode_ticket},
65
+ extra_headers=extra_headers,
66
+ extra_query=extra_query,
67
+ extra_body=extra_body,
68
+ timeout=timeout,
69
+ ),
70
+ response_type=PtyConnectTokenResponse,
71
+ ),
72
+ )
73
+
74
+
75
+ class PtyResource(SyncAPIResource):
76
+ """Operations under ``client.pty`` (OpenCode ``pty``)."""
77
+
78
+ @cached_property
79
+ def connect(self) -> PtyConnectResource:
80
+ return PtyConnectResource(self._client)
81
+
82
+ def list(
83
+ self,
84
+ *,
85
+ location: Location | NotGiven | None = NOT_GIVEN,
86
+ extra_headers: Headers | None = None,
87
+ extra_query: Query | None = None,
88
+ extra_body: Body | None = None,
89
+ timeout: Timeout | NotGiven = NOT_GIVEN,
90
+ ) -> PtyListResponse:
91
+ """List PTY sessions.
92
+
93
+ List PTY sessions for a location, including exited sessions retained until removal.
94
+
95
+ Raises:
96
+ InvalidRequestError
97
+ UnauthorizedError
98
+ LocationNotFoundError
99
+
100
+ ``GET /api/pty``
101
+ """
102
+ return cast(
103
+ "PtyListResponse",
104
+ self._client.request(
105
+ RequestOptions(
106
+ method="GET",
107
+ path="/api/pty",
108
+ query={"location": self._location(location)},
109
+ extra_headers=extra_headers,
110
+ extra_query=extra_query,
111
+ extra_body=extra_body,
112
+ timeout=timeout,
113
+ ),
114
+ response_type=PtyListResponse,
115
+ ),
116
+ )
117
+
118
+ def create(
119
+ self,
120
+ *,
121
+ location: Location | NotGiven | None = NOT_GIVEN,
122
+ command: str | NotGiven = NOT_GIVEN,
123
+ args: Sequence[str] | NotGiven = NOT_GIVEN,
124
+ cwd: str | NotGiven = NOT_GIVEN,
125
+ title: str | NotGiven = NOT_GIVEN,
126
+ env: Mapping[str, str] | NotGiven = NOT_GIVEN,
127
+ extra_headers: Headers | None = None,
128
+ extra_query: Query | None = None,
129
+ extra_body: Body | None = None,
130
+ timeout: Timeout | NotGiven = NOT_GIVEN,
131
+ ) -> PtyCreateResponse:
132
+ """Create PTY session.
133
+
134
+ Create a pseudo-terminal session for a location.
135
+
136
+ Raises:
137
+ InvalidRequestError
138
+ UnauthorizedError
139
+ LocationNotFoundError
140
+
141
+ ``POST /api/pty``
142
+ """
143
+ return cast(
144
+ "PtyCreateResponse",
145
+ self._client.request(
146
+ RequestOptions(
147
+ method="POST",
148
+ path="/api/pty",
149
+ query={"location": self._location(location)},
150
+ body={"command": command, "args": args, "cwd": cwd, "title": title, "env": env},
151
+ extra_headers=extra_headers,
152
+ extra_query=extra_query,
153
+ extra_body=extra_body,
154
+ timeout=timeout,
155
+ ),
156
+ response_type=PtyCreateResponse,
157
+ ),
158
+ )
159
+
160
+ def get(
161
+ self,
162
+ pty_id: PtyID,
163
+ *,
164
+ location: Location | NotGiven | None = NOT_GIVEN,
165
+ extra_headers: Headers | None = None,
166
+ extra_query: Query | None = None,
167
+ extra_body: Body | None = None,
168
+ timeout: Timeout | NotGiven = NOT_GIVEN,
169
+ ) -> PtyGetResponse:
170
+ """Get PTY session.
171
+
172
+ Get one PTY session, including its exit code once exited.
173
+
174
+ Raises:
175
+ InvalidRequestError
176
+ UnauthorizedError
177
+ PtyNotFoundError
178
+ LocationNotFoundError
179
+
180
+ ``GET /api/pty/:ptyID``
181
+ """
182
+ return cast(
183
+ "PtyGetResponse",
184
+ self._client.request(
185
+ RequestOptions(
186
+ method="GET",
187
+ path=f"/api/pty/{encode_path_segment(pty_id)}",
188
+ query={"location": self._location(location)},
189
+ extra_headers=extra_headers,
190
+ extra_query=extra_query,
191
+ extra_body=extra_body,
192
+ timeout=timeout,
193
+ ),
194
+ response_type=PtyGetResponse,
195
+ ),
196
+ )
197
+
198
+ def update(
199
+ self,
200
+ pty_id: PtyID,
201
+ *,
202
+ location: Location | NotGiven | None = NOT_GIVEN,
203
+ title: str | NotGiven = NOT_GIVEN,
204
+ size: PtyUpdateSize | NotGiven = NOT_GIVEN,
205
+ extra_headers: Headers | None = None,
206
+ extra_query: Query | None = None,
207
+ extra_body: Body | None = None,
208
+ timeout: Timeout | NotGiven = NOT_GIVEN,
209
+ ) -> PtyUpdateResponse:
210
+ """Update PTY session.
211
+
212
+ Update the title or viewport size of one PTY session.
213
+
214
+ Raises:
215
+ InvalidRequestError
216
+ UnauthorizedError
217
+ PtyNotFoundError
218
+ LocationNotFoundError
219
+
220
+ ``PUT /api/pty/:ptyID``
221
+ """
222
+ return cast(
223
+ "PtyUpdateResponse",
224
+ self._client.request(
225
+ RequestOptions(
226
+ method="PUT",
227
+ path=f"/api/pty/{encode_path_segment(pty_id)}",
228
+ query={"location": self._location(location)},
229
+ body={"title": title, "size": size},
230
+ extra_headers=extra_headers,
231
+ extra_query=extra_query,
232
+ extra_body=extra_body,
233
+ timeout=timeout,
234
+ ),
235
+ response_type=PtyUpdateResponse,
236
+ ),
237
+ )
238
+
239
+ def remove(
240
+ self,
241
+ pty_id: PtyID,
242
+ *,
243
+ location: Location | NotGiven | None = NOT_GIVEN,
244
+ extra_headers: Headers | None = None,
245
+ extra_query: Query | None = None,
246
+ extra_body: Body | None = None,
247
+ timeout: Timeout | NotGiven = NOT_GIVEN,
248
+ ) -> None:
249
+ """Remove PTY session.
250
+
251
+ Terminate and remove one PTY session.
252
+
253
+ Raises:
254
+ InvalidRequestError
255
+ UnauthorizedError
256
+ PtyNotFoundError
257
+ LocationNotFoundError
258
+
259
+ ``DELETE /api/pty/:ptyID``
260
+ """
261
+ self._client.request(
262
+ RequestOptions(
263
+ method="DELETE",
264
+ path=f"/api/pty/{encode_path_segment(pty_id)}",
265
+ query={"location": self._location(location)},
266
+ extra_headers=extra_headers,
267
+ extra_query=extra_query,
268
+ extra_body=extra_body,
269
+ timeout=timeout,
270
+ ),
271
+ kind="void",
272
+ )
273
+
274
+
275
+ class AsyncPtyConnectResource(AsyncAPIResource):
276
+ """Operations under ``client.pty.connect`` (OpenCode ``pty.connect``)."""
277
+
278
+ async def token(
279
+ self,
280
+ pty_id: PtyID,
281
+ *,
282
+ location: Location | NotGiven | None = NOT_GIVEN,
283
+ x_opencode_ticket: str | NotGiven | None = NOT_GIVEN,
284
+ extra_headers: Headers | None = None,
285
+ extra_query: Query | None = None,
286
+ extra_body: Body | None = None,
287
+ timeout: Timeout | NotGiven = NOT_GIVEN,
288
+ ) -> PtyConnectTokenResponse:
289
+ """Create PTY WebSocket token.
290
+
291
+ Create a short-lived single-use ticket for opening a PTY WebSocket connection.
292
+
293
+ Raises:
294
+ InvalidRequestError
295
+ UnauthorizedError
296
+ ForbiddenError
297
+ PtyNotFoundError
298
+ LocationNotFoundError
299
+
300
+ ``POST /api/pty/:ptyID/connect-token``
301
+ """
302
+ return cast(
303
+ "PtyConnectTokenResponse",
304
+ await self._client.request(
305
+ RequestOptions(
306
+ method="POST",
307
+ path=f"/api/pty/{encode_path_segment(pty_id)}/connect-token",
308
+ query={"location": self._location(location)},
309
+ headers={"x-opencode-ticket": x_opencode_ticket},
310
+ extra_headers=extra_headers,
311
+ extra_query=extra_query,
312
+ extra_body=extra_body,
313
+ timeout=timeout,
314
+ ),
315
+ response_type=PtyConnectTokenResponse,
316
+ ),
317
+ )
318
+
319
+
320
+ class AsyncPtyResource(AsyncAPIResource):
321
+ """Operations under ``client.pty`` (OpenCode ``pty``)."""
322
+
323
+ @cached_property
324
+ def connect(self) -> AsyncPtyConnectResource:
325
+ return AsyncPtyConnectResource(self._client)
326
+
327
+ async def list(
328
+ self,
329
+ *,
330
+ location: Location | NotGiven | None = NOT_GIVEN,
331
+ extra_headers: Headers | None = None,
332
+ extra_query: Query | None = None,
333
+ extra_body: Body | None = None,
334
+ timeout: Timeout | NotGiven = NOT_GIVEN,
335
+ ) -> PtyListResponse:
336
+ """List PTY sessions.
337
+
338
+ List PTY sessions for a location, including exited sessions retained until removal.
339
+
340
+ Raises:
341
+ InvalidRequestError
342
+ UnauthorizedError
343
+ LocationNotFoundError
344
+
345
+ ``GET /api/pty``
346
+ """
347
+ return cast(
348
+ "PtyListResponse",
349
+ await self._client.request(
350
+ RequestOptions(
351
+ method="GET",
352
+ path="/api/pty",
353
+ query={"location": self._location(location)},
354
+ extra_headers=extra_headers,
355
+ extra_query=extra_query,
356
+ extra_body=extra_body,
357
+ timeout=timeout,
358
+ ),
359
+ response_type=PtyListResponse,
360
+ ),
361
+ )
362
+
363
+ async def create(
364
+ self,
365
+ *,
366
+ location: Location | NotGiven | None = NOT_GIVEN,
367
+ command: str | NotGiven = NOT_GIVEN,
368
+ args: Sequence[str] | NotGiven = NOT_GIVEN,
369
+ cwd: str | NotGiven = NOT_GIVEN,
370
+ title: str | NotGiven = NOT_GIVEN,
371
+ env: Mapping[str, str] | NotGiven = NOT_GIVEN,
372
+ extra_headers: Headers | None = None,
373
+ extra_query: Query | None = None,
374
+ extra_body: Body | None = None,
375
+ timeout: Timeout | NotGiven = NOT_GIVEN,
376
+ ) -> PtyCreateResponse:
377
+ """Create PTY session.
378
+
379
+ Create a pseudo-terminal session for a location.
380
+
381
+ Raises:
382
+ InvalidRequestError
383
+ UnauthorizedError
384
+ LocationNotFoundError
385
+
386
+ ``POST /api/pty``
387
+ """
388
+ return cast(
389
+ "PtyCreateResponse",
390
+ await self._client.request(
391
+ RequestOptions(
392
+ method="POST",
393
+ path="/api/pty",
394
+ query={"location": self._location(location)},
395
+ body={"command": command, "args": args, "cwd": cwd, "title": title, "env": env},
396
+ extra_headers=extra_headers,
397
+ extra_query=extra_query,
398
+ extra_body=extra_body,
399
+ timeout=timeout,
400
+ ),
401
+ response_type=PtyCreateResponse,
402
+ ),
403
+ )
404
+
405
+ async def get(
406
+ self,
407
+ pty_id: PtyID,
408
+ *,
409
+ location: Location | NotGiven | None = NOT_GIVEN,
410
+ extra_headers: Headers | None = None,
411
+ extra_query: Query | None = None,
412
+ extra_body: Body | None = None,
413
+ timeout: Timeout | NotGiven = NOT_GIVEN,
414
+ ) -> PtyGetResponse:
415
+ """Get PTY session.
416
+
417
+ Get one PTY session, including its exit code once exited.
418
+
419
+ Raises:
420
+ InvalidRequestError
421
+ UnauthorizedError
422
+ PtyNotFoundError
423
+ LocationNotFoundError
424
+
425
+ ``GET /api/pty/:ptyID``
426
+ """
427
+ return cast(
428
+ "PtyGetResponse",
429
+ await self._client.request(
430
+ RequestOptions(
431
+ method="GET",
432
+ path=f"/api/pty/{encode_path_segment(pty_id)}",
433
+ query={"location": self._location(location)},
434
+ extra_headers=extra_headers,
435
+ extra_query=extra_query,
436
+ extra_body=extra_body,
437
+ timeout=timeout,
438
+ ),
439
+ response_type=PtyGetResponse,
440
+ ),
441
+ )
442
+
443
+ async def update(
444
+ self,
445
+ pty_id: PtyID,
446
+ *,
447
+ location: Location | NotGiven | None = NOT_GIVEN,
448
+ title: str | NotGiven = NOT_GIVEN,
449
+ size: PtyUpdateSize | NotGiven = NOT_GIVEN,
450
+ extra_headers: Headers | None = None,
451
+ extra_query: Query | None = None,
452
+ extra_body: Body | None = None,
453
+ timeout: Timeout | NotGiven = NOT_GIVEN,
454
+ ) -> PtyUpdateResponse:
455
+ """Update PTY session.
456
+
457
+ Update the title or viewport size of one PTY session.
458
+
459
+ Raises:
460
+ InvalidRequestError
461
+ UnauthorizedError
462
+ PtyNotFoundError
463
+ LocationNotFoundError
464
+
465
+ ``PUT /api/pty/:ptyID``
466
+ """
467
+ return cast(
468
+ "PtyUpdateResponse",
469
+ await self._client.request(
470
+ RequestOptions(
471
+ method="PUT",
472
+ path=f"/api/pty/{encode_path_segment(pty_id)}",
473
+ query={"location": self._location(location)},
474
+ body={"title": title, "size": size},
475
+ extra_headers=extra_headers,
476
+ extra_query=extra_query,
477
+ extra_body=extra_body,
478
+ timeout=timeout,
479
+ ),
480
+ response_type=PtyUpdateResponse,
481
+ ),
482
+ )
483
+
484
+ async def remove(
485
+ self,
486
+ pty_id: PtyID,
487
+ *,
488
+ location: Location | NotGiven | None = NOT_GIVEN,
489
+ extra_headers: Headers | None = None,
490
+ extra_query: Query | None = None,
491
+ extra_body: Body | None = None,
492
+ timeout: Timeout | NotGiven = NOT_GIVEN,
493
+ ) -> None:
494
+ """Remove PTY session.
495
+
496
+ Terminate and remove one PTY session.
497
+
498
+ Raises:
499
+ InvalidRequestError
500
+ UnauthorizedError
501
+ PtyNotFoundError
502
+ LocationNotFoundError
503
+
504
+ ``DELETE /api/pty/:ptyID``
505
+ """
506
+ await self._client.request(
507
+ RequestOptions(
508
+ method="DELETE",
509
+ path=f"/api/pty/{encode_path_segment(pty_id)}",
510
+ query={"location": self._location(location)},
511
+ extra_headers=extra_headers,
512
+ extra_query=extra_query,
513
+ extra_body=extra_body,
514
+ timeout=timeout,
515
+ ),
516
+ kind="void",
517
+ )
@@ -0,0 +1,98 @@
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 ``reference`` 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
+ ReferenceListResponse,
16
+ )
17
+
18
+ __all__ = ["ReferenceResource", "AsyncReferenceResource"]
19
+
20
+
21
+ class ReferenceResource(SyncAPIResource):
22
+ """Operations under ``client.reference`` (OpenCode ``reference``)."""
23
+
24
+ def list(
25
+ self,
26
+ *,
27
+ location: Location | NotGiven | None = NOT_GIVEN,
28
+ extra_headers: Headers | None = None,
29
+ extra_query: Query | None = None,
30
+ extra_body: Body | None = None,
31
+ timeout: Timeout | NotGiven = NOT_GIVEN,
32
+ ) -> ReferenceListResponse:
33
+ """List references.
34
+
35
+ List references available in the requested location.
36
+
37
+ Raises:
38
+ InvalidRequestError
39
+ UnauthorizedError
40
+ LocationNotFoundError
41
+
42
+ ``GET /api/reference``
43
+ """
44
+ return cast(
45
+ "ReferenceListResponse",
46
+ self._client.request(
47
+ RequestOptions(
48
+ method="GET",
49
+ path="/api/reference",
50
+ query={"location": self._location(location)},
51
+ extra_headers=extra_headers,
52
+ extra_query=extra_query,
53
+ extra_body=extra_body,
54
+ timeout=timeout,
55
+ ),
56
+ response_type=ReferenceListResponse,
57
+ ),
58
+ )
59
+
60
+
61
+ class AsyncReferenceResource(AsyncAPIResource):
62
+ """Operations under ``client.reference`` (OpenCode ``reference``)."""
63
+
64
+ async def list(
65
+ self,
66
+ *,
67
+ location: Location | NotGiven | None = NOT_GIVEN,
68
+ extra_headers: Headers | None = None,
69
+ extra_query: Query | None = None,
70
+ extra_body: Body | None = None,
71
+ timeout: Timeout | NotGiven = NOT_GIVEN,
72
+ ) -> ReferenceListResponse:
73
+ """List references.
74
+
75
+ List references available in the requested location.
76
+
77
+ Raises:
78
+ InvalidRequestError
79
+ UnauthorizedError
80
+ LocationNotFoundError
81
+
82
+ ``GET /api/reference``
83
+ """
84
+ return cast(
85
+ "ReferenceListResponse",
86
+ await self._client.request(
87
+ RequestOptions(
88
+ method="GET",
89
+ path="/api/reference",
90
+ query={"location": self._location(location)},
91
+ extra_headers=extra_headers,
92
+ extra_query=extra_query,
93
+ extra_body=extra_body,
94
+ timeout=timeout,
95
+ ),
96
+ response_type=ReferenceListResponse,
97
+ ),
98
+ )