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,760 @@
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 ``experimental`` resource."""
5
+
6
+ from __future__ import annotations
7
+
8
+ import builtins
9
+ from collections.abc import Mapping, Sequence
10
+ from functools import cached_property
11
+ from typing import cast
12
+
13
+ from .._base_client import RequestOptions
14
+ from .._qs import encode_path_segment
15
+ from .._resource import AsyncAPIResource, SyncAPIResource
16
+ from .._types import NOT_GIVEN, Body, Headers, NotGiven, Query, Timeout
17
+ from ..types import (
18
+ ExperimentalPersistentPtyCreateSize,
19
+ ExperimentalPersistentPtyHandoffResponse,
20
+ ExperimentalPersistentPtyUpdateSize,
21
+ PersistentPtyInfo,
22
+ PersistentPtyReadLines,
23
+ PersistentPtyReadResult,
24
+ PersistentPtySnapshot,
25
+ PtyID,
26
+ PtyTicketConnectToken,
27
+ SessionID,
28
+ )
29
+
30
+ __all__ = ["ExperimentalResource", "AsyncExperimentalResource"]
31
+
32
+
33
+ class ExperimentalPersistentPtyResource(SyncAPIResource):
34
+ """Operations under ``client.experimental.persistent_pty`` (OpenCode ``experimental.persistentPty``)."""
35
+
36
+ def read(
37
+ self,
38
+ session_id: SessionID,
39
+ *,
40
+ lines: PersistentPtyReadLines | NotGiven | None = NOT_GIVEN,
41
+ extra_headers: Headers | None = None,
42
+ extra_query: Query | None = None,
43
+ extra_body: Body | None = None,
44
+ timeout: Timeout | NotGiven = NOT_GIVEN,
45
+ ) -> PersistentPtyReadResult | None:
46
+ """Read the session's most recently controlled terminal.
47
+
48
+ Read the last physical rows without changing selection or taking control. Omitted lines uses the live terminal height; larger counts include retained history. Blank rows are preserved. Screen dimensions and cursor remain relative to the live screen. Returns null when no current terminal exists. Selection is server-local and resets on restart. Experimental: may change without compatibility guarantees.
49
+
50
+ This endpoint is experimental in OpenCode and may change without notice.
51
+
52
+ Raises:
53
+ InvalidRequestError
54
+ UnauthorizedError
55
+ ServiceUnavailableError
56
+
57
+ ``GET /api/experimental/session/:sessionID/terminal/read``
58
+ """
59
+ return cast(
60
+ "PersistentPtyReadResult | None",
61
+ self._client.request(
62
+ RequestOptions(
63
+ method="GET",
64
+ path=f"/api/experimental/session/{encode_path_segment(session_id)}/terminal/read",
65
+ query={"lines": lines},
66
+ extra_headers=extra_headers,
67
+ extra_query=extra_query,
68
+ extra_body=extra_body,
69
+ timeout=timeout,
70
+ ),
71
+ response_type=PersistentPtyReadResult | None,
72
+ unwrap=True,
73
+ ),
74
+ )
75
+
76
+ def list(
77
+ self,
78
+ session_id: SessionID,
79
+ *,
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
+ ) -> builtins.list[PersistentPtyInfo]:
85
+ """This endpoint is experimental in OpenCode and may change without notice.
86
+
87
+ Raises:
88
+ InvalidRequestError
89
+ UnauthorizedError
90
+ ServiceUnavailableError
91
+
92
+ ``GET /api/experimental/session/:sessionID/terminal``
93
+ """
94
+ return cast(
95
+ "builtins.list[PersistentPtyInfo]",
96
+ self._client.request(
97
+ RequestOptions(
98
+ method="GET",
99
+ path=f"/api/experimental/session/{encode_path_segment(session_id)}/terminal",
100
+ extra_headers=extra_headers,
101
+ extra_query=extra_query,
102
+ extra_body=extra_body,
103
+ timeout=timeout,
104
+ ),
105
+ response_type=builtins.list[PersistentPtyInfo],
106
+ unwrap=True,
107
+ ),
108
+ )
109
+
110
+ def create(
111
+ self,
112
+ session_id: SessionID,
113
+ *,
114
+ args: Sequence[str],
115
+ title: str,
116
+ env: Mapping[str, str],
117
+ command: str | NotGiven = NOT_GIVEN,
118
+ cwd: str | NotGiven = NOT_GIVEN,
119
+ size: ExperimentalPersistentPtyCreateSize | NotGiven = NOT_GIVEN,
120
+ extra_headers: Headers | None = None,
121
+ extra_query: Query | None = None,
122
+ extra_body: Body | None = None,
123
+ timeout: Timeout | NotGiven = NOT_GIVEN,
124
+ ) -> PersistentPtyInfo:
125
+ """This endpoint is experimental in OpenCode and may change without notice.
126
+
127
+ Raises:
128
+ InvalidRequestError
129
+ UnauthorizedError
130
+ ServiceUnavailableError
131
+
132
+ ``POST /api/experimental/session/:sessionID/terminal``
133
+ """
134
+ return cast(
135
+ "PersistentPtyInfo",
136
+ self._client.request(
137
+ RequestOptions(
138
+ method="POST",
139
+ path=f"/api/experimental/session/{encode_path_segment(session_id)}/terminal",
140
+ body={"command": command, "args": args, "cwd": cwd, "title": title, "env": env, "size": size},
141
+ extra_headers=extra_headers,
142
+ extra_query=extra_query,
143
+ extra_body=extra_body,
144
+ timeout=timeout,
145
+ ),
146
+ response_type=PersistentPtyInfo,
147
+ unwrap=True,
148
+ ),
149
+ )
150
+
151
+ def shutdown(
152
+ self,
153
+ *,
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
+ ) -> None:
159
+ """This endpoint is experimental in OpenCode and may change without notice.
160
+
161
+ Raises:
162
+ InvalidRequestError
163
+ UnauthorizedError
164
+ ServiceUnavailableError
165
+
166
+ ``POST /api/experimental/persistent-pty/shutdown``
167
+ """
168
+ self._client.request(
169
+ RequestOptions(
170
+ method="POST",
171
+ path="/api/experimental/persistent-pty/shutdown",
172
+ extra_headers=extra_headers,
173
+ extra_query=extra_query,
174
+ extra_body=extra_body,
175
+ timeout=timeout,
176
+ ),
177
+ kind="void",
178
+ )
179
+
180
+ def handoff(
181
+ self,
182
+ *,
183
+ extra_headers: Headers | None = None,
184
+ extra_query: Query | None = None,
185
+ extra_body: Body | None = None,
186
+ timeout: Timeout | NotGiven = NOT_GIVEN,
187
+ ) -> ExperimentalPersistentPtyHandoffResponse:
188
+ """This endpoint is experimental in OpenCode and may change without notice.
189
+
190
+ Raises:
191
+ InvalidRequestError
192
+ UnauthorizedError
193
+ ServiceUnavailableError
194
+
195
+ ``POST /api/experimental/persistent-pty/handoff``
196
+ """
197
+ return cast(
198
+ "ExperimentalPersistentPtyHandoffResponse",
199
+ self._client.request(
200
+ RequestOptions(
201
+ method="POST",
202
+ path="/api/experimental/persistent-pty/handoff",
203
+ extra_headers=extra_headers,
204
+ extra_query=extra_query,
205
+ extra_body=extra_body,
206
+ timeout=timeout,
207
+ ),
208
+ response_type=ExperimentalPersistentPtyHandoffResponse,
209
+ ),
210
+ )
211
+
212
+ def get(
213
+ self,
214
+ pty_id: PtyID,
215
+ *,
216
+ extra_headers: Headers | None = None,
217
+ extra_query: Query | None = None,
218
+ extra_body: Body | None = None,
219
+ timeout: Timeout | NotGiven = NOT_GIVEN,
220
+ ) -> PersistentPtyInfo:
221
+ """This endpoint is experimental in OpenCode and may change without notice.
222
+
223
+ Raises:
224
+ InvalidRequestError
225
+ UnauthorizedError
226
+ PtyNotFoundError
227
+ ServiceUnavailableError
228
+
229
+ ``GET /api/experimental/persistent-pty/:ptyID``
230
+ """
231
+ return cast(
232
+ "PersistentPtyInfo",
233
+ self._client.request(
234
+ RequestOptions(
235
+ method="GET",
236
+ path=f"/api/experimental/persistent-pty/{encode_path_segment(pty_id)}",
237
+ extra_headers=extra_headers,
238
+ extra_query=extra_query,
239
+ extra_body=extra_body,
240
+ timeout=timeout,
241
+ ),
242
+ response_type=PersistentPtyInfo,
243
+ unwrap=True,
244
+ ),
245
+ )
246
+
247
+ def update(
248
+ self,
249
+ pty_id: PtyID,
250
+ *,
251
+ size: ExperimentalPersistentPtyUpdateSize,
252
+ attachment_id: str | NotGiven = NOT_GIVEN,
253
+ extra_headers: Headers | None = None,
254
+ extra_query: Query | None = None,
255
+ extra_body: Body | None = None,
256
+ timeout: Timeout | NotGiven = NOT_GIVEN,
257
+ ) -> PersistentPtyInfo:
258
+ """This endpoint is experimental in OpenCode and may change without notice.
259
+
260
+ Raises:
261
+ InvalidRequestError
262
+ UnauthorizedError
263
+ PtyNotFoundError
264
+ ServiceUnavailableError
265
+
266
+ ``PUT /api/experimental/persistent-pty/:ptyID``
267
+ """
268
+ return cast(
269
+ "PersistentPtyInfo",
270
+ self._client.request(
271
+ RequestOptions(
272
+ method="PUT",
273
+ path=f"/api/experimental/persistent-pty/{encode_path_segment(pty_id)}",
274
+ body={"attachmentID": attachment_id, "size": size},
275
+ extra_headers=extra_headers,
276
+ extra_query=extra_query,
277
+ extra_body=extra_body,
278
+ timeout=timeout,
279
+ ),
280
+ response_type=PersistentPtyInfo,
281
+ unwrap=True,
282
+ ),
283
+ )
284
+
285
+ def snapshot(
286
+ self,
287
+ pty_id: PtyID,
288
+ *,
289
+ extra_headers: Headers | None = None,
290
+ extra_query: Query | None = None,
291
+ extra_body: Body | None = None,
292
+ timeout: Timeout | NotGiven = NOT_GIVEN,
293
+ ) -> PersistentPtySnapshot:
294
+ """This endpoint is experimental in OpenCode and may change without notice.
295
+
296
+ Raises:
297
+ InvalidRequestError
298
+ UnauthorizedError
299
+ PtyNotFoundError
300
+ ServiceUnavailableError
301
+
302
+ ``GET /api/experimental/persistent-pty/:ptyID/snapshot``
303
+ """
304
+ return cast(
305
+ "PersistentPtySnapshot",
306
+ self._client.request(
307
+ RequestOptions(
308
+ method="GET",
309
+ path=f"/api/experimental/persistent-pty/{encode_path_segment(pty_id)}/snapshot",
310
+ extra_headers=extra_headers,
311
+ extra_query=extra_query,
312
+ extra_body=extra_body,
313
+ timeout=timeout,
314
+ ),
315
+ response_type=PersistentPtySnapshot,
316
+ unwrap=True,
317
+ ),
318
+ )
319
+
320
+ def remove(
321
+ self,
322
+ pty_id: PtyID,
323
+ *,
324
+ extra_headers: Headers | None = None,
325
+ extra_query: Query | None = None,
326
+ extra_body: Body | None = None,
327
+ timeout: Timeout | NotGiven = NOT_GIVEN,
328
+ ) -> None:
329
+ """This endpoint is experimental in OpenCode and may change without notice.
330
+
331
+ Raises:
332
+ InvalidRequestError
333
+ UnauthorizedError
334
+ PtyNotFoundError
335
+ ServiceUnavailableError
336
+
337
+ ``DELETE /api/experimental/persistent-pty/:ptyID``
338
+ """
339
+ self._client.request(
340
+ RequestOptions(
341
+ method="DELETE",
342
+ path=f"/api/experimental/persistent-pty/{encode_path_segment(pty_id)}",
343
+ extra_headers=extra_headers,
344
+ extra_query=extra_query,
345
+ extra_body=extra_body,
346
+ timeout=timeout,
347
+ ),
348
+ kind="void",
349
+ )
350
+
351
+ def connect_token(
352
+ self,
353
+ pty_id: PtyID,
354
+ *,
355
+ x_opencode_ticket: str | NotGiven | None = NOT_GIVEN,
356
+ extra_headers: Headers | None = None,
357
+ extra_query: Query | None = None,
358
+ extra_body: Body | None = None,
359
+ timeout: Timeout | NotGiven = NOT_GIVEN,
360
+ ) -> PtyTicketConnectToken:
361
+ """This endpoint is experimental in OpenCode and may change without notice.
362
+
363
+ Raises:
364
+ InvalidRequestError
365
+ UnauthorizedError
366
+ ForbiddenError
367
+ PtyNotFoundError
368
+ ServiceUnavailableError
369
+
370
+ ``POST /api/experimental/persistent-pty/:ptyID/connect-token``
371
+ """
372
+ return cast(
373
+ "PtyTicketConnectToken",
374
+ self._client.request(
375
+ RequestOptions(
376
+ method="POST",
377
+ path=f"/api/experimental/persistent-pty/{encode_path_segment(pty_id)}/connect-token",
378
+ headers={"x-opencode-ticket": x_opencode_ticket},
379
+ extra_headers=extra_headers,
380
+ extra_query=extra_query,
381
+ extra_body=extra_body,
382
+ timeout=timeout,
383
+ ),
384
+ response_type=PtyTicketConnectToken,
385
+ unwrap=True,
386
+ ),
387
+ )
388
+
389
+
390
+ class ExperimentalResource(SyncAPIResource):
391
+ """Operations under ``client.experimental`` (OpenCode ``experimental``)."""
392
+
393
+ @cached_property
394
+ def persistent_pty(self) -> ExperimentalPersistentPtyResource:
395
+ return ExperimentalPersistentPtyResource(self._client)
396
+
397
+
398
+ class AsyncExperimentalPersistentPtyResource(AsyncAPIResource):
399
+ """Operations under ``client.experimental.persistent_pty`` (OpenCode ``experimental.persistentPty``)."""
400
+
401
+ async def read(
402
+ self,
403
+ session_id: SessionID,
404
+ *,
405
+ lines: PersistentPtyReadLines | NotGiven | None = NOT_GIVEN,
406
+ extra_headers: Headers | None = None,
407
+ extra_query: Query | None = None,
408
+ extra_body: Body | None = None,
409
+ timeout: Timeout | NotGiven = NOT_GIVEN,
410
+ ) -> PersistentPtyReadResult | None:
411
+ """Read the session's most recently controlled terminal.
412
+
413
+ Read the last physical rows without changing selection or taking control. Omitted lines uses the live terminal height; larger counts include retained history. Blank rows are preserved. Screen dimensions and cursor remain relative to the live screen. Returns null when no current terminal exists. Selection is server-local and resets on restart. Experimental: may change without compatibility guarantees.
414
+
415
+ This endpoint is experimental in OpenCode and may change without notice.
416
+
417
+ Raises:
418
+ InvalidRequestError
419
+ UnauthorizedError
420
+ ServiceUnavailableError
421
+
422
+ ``GET /api/experimental/session/:sessionID/terminal/read``
423
+ """
424
+ return cast(
425
+ "PersistentPtyReadResult | None",
426
+ await self._client.request(
427
+ RequestOptions(
428
+ method="GET",
429
+ path=f"/api/experimental/session/{encode_path_segment(session_id)}/terminal/read",
430
+ query={"lines": lines},
431
+ extra_headers=extra_headers,
432
+ extra_query=extra_query,
433
+ extra_body=extra_body,
434
+ timeout=timeout,
435
+ ),
436
+ response_type=PersistentPtyReadResult | None,
437
+ unwrap=True,
438
+ ),
439
+ )
440
+
441
+ async def list(
442
+ self,
443
+ session_id: SessionID,
444
+ *,
445
+ extra_headers: Headers | None = None,
446
+ extra_query: Query | None = None,
447
+ extra_body: Body | None = None,
448
+ timeout: Timeout | NotGiven = NOT_GIVEN,
449
+ ) -> builtins.list[PersistentPtyInfo]:
450
+ """This endpoint is experimental in OpenCode and may change without notice.
451
+
452
+ Raises:
453
+ InvalidRequestError
454
+ UnauthorizedError
455
+ ServiceUnavailableError
456
+
457
+ ``GET /api/experimental/session/:sessionID/terminal``
458
+ """
459
+ return cast(
460
+ "builtins.list[PersistentPtyInfo]",
461
+ await self._client.request(
462
+ RequestOptions(
463
+ method="GET",
464
+ path=f"/api/experimental/session/{encode_path_segment(session_id)}/terminal",
465
+ extra_headers=extra_headers,
466
+ extra_query=extra_query,
467
+ extra_body=extra_body,
468
+ timeout=timeout,
469
+ ),
470
+ response_type=builtins.list[PersistentPtyInfo],
471
+ unwrap=True,
472
+ ),
473
+ )
474
+
475
+ async def create(
476
+ self,
477
+ session_id: SessionID,
478
+ *,
479
+ args: Sequence[str],
480
+ title: str,
481
+ env: Mapping[str, str],
482
+ command: str | NotGiven = NOT_GIVEN,
483
+ cwd: str | NotGiven = NOT_GIVEN,
484
+ size: ExperimentalPersistentPtyCreateSize | NotGiven = NOT_GIVEN,
485
+ extra_headers: Headers | None = None,
486
+ extra_query: Query | None = None,
487
+ extra_body: Body | None = None,
488
+ timeout: Timeout | NotGiven = NOT_GIVEN,
489
+ ) -> PersistentPtyInfo:
490
+ """This endpoint is experimental in OpenCode and may change without notice.
491
+
492
+ Raises:
493
+ InvalidRequestError
494
+ UnauthorizedError
495
+ ServiceUnavailableError
496
+
497
+ ``POST /api/experimental/session/:sessionID/terminal``
498
+ """
499
+ return cast(
500
+ "PersistentPtyInfo",
501
+ await self._client.request(
502
+ RequestOptions(
503
+ method="POST",
504
+ path=f"/api/experimental/session/{encode_path_segment(session_id)}/terminal",
505
+ body={"command": command, "args": args, "cwd": cwd, "title": title, "env": env, "size": size},
506
+ extra_headers=extra_headers,
507
+ extra_query=extra_query,
508
+ extra_body=extra_body,
509
+ timeout=timeout,
510
+ ),
511
+ response_type=PersistentPtyInfo,
512
+ unwrap=True,
513
+ ),
514
+ )
515
+
516
+ async def shutdown(
517
+ self,
518
+ *,
519
+ extra_headers: Headers | None = None,
520
+ extra_query: Query | None = None,
521
+ extra_body: Body | None = None,
522
+ timeout: Timeout | NotGiven = NOT_GIVEN,
523
+ ) -> None:
524
+ """This endpoint is experimental in OpenCode and may change without notice.
525
+
526
+ Raises:
527
+ InvalidRequestError
528
+ UnauthorizedError
529
+ ServiceUnavailableError
530
+
531
+ ``POST /api/experimental/persistent-pty/shutdown``
532
+ """
533
+ await self._client.request(
534
+ RequestOptions(
535
+ method="POST",
536
+ path="/api/experimental/persistent-pty/shutdown",
537
+ extra_headers=extra_headers,
538
+ extra_query=extra_query,
539
+ extra_body=extra_body,
540
+ timeout=timeout,
541
+ ),
542
+ kind="void",
543
+ )
544
+
545
+ async def handoff(
546
+ self,
547
+ *,
548
+ extra_headers: Headers | None = None,
549
+ extra_query: Query | None = None,
550
+ extra_body: Body | None = None,
551
+ timeout: Timeout | NotGiven = NOT_GIVEN,
552
+ ) -> ExperimentalPersistentPtyHandoffResponse:
553
+ """This endpoint is experimental in OpenCode and may change without notice.
554
+
555
+ Raises:
556
+ InvalidRequestError
557
+ UnauthorizedError
558
+ ServiceUnavailableError
559
+
560
+ ``POST /api/experimental/persistent-pty/handoff``
561
+ """
562
+ return cast(
563
+ "ExperimentalPersistentPtyHandoffResponse",
564
+ await self._client.request(
565
+ RequestOptions(
566
+ method="POST",
567
+ path="/api/experimental/persistent-pty/handoff",
568
+ extra_headers=extra_headers,
569
+ extra_query=extra_query,
570
+ extra_body=extra_body,
571
+ timeout=timeout,
572
+ ),
573
+ response_type=ExperimentalPersistentPtyHandoffResponse,
574
+ ),
575
+ )
576
+
577
+ async def get(
578
+ self,
579
+ pty_id: PtyID,
580
+ *,
581
+ extra_headers: Headers | None = None,
582
+ extra_query: Query | None = None,
583
+ extra_body: Body | None = None,
584
+ timeout: Timeout | NotGiven = NOT_GIVEN,
585
+ ) -> PersistentPtyInfo:
586
+ """This endpoint is experimental in OpenCode and may change without notice.
587
+
588
+ Raises:
589
+ InvalidRequestError
590
+ UnauthorizedError
591
+ PtyNotFoundError
592
+ ServiceUnavailableError
593
+
594
+ ``GET /api/experimental/persistent-pty/:ptyID``
595
+ """
596
+ return cast(
597
+ "PersistentPtyInfo",
598
+ await self._client.request(
599
+ RequestOptions(
600
+ method="GET",
601
+ path=f"/api/experimental/persistent-pty/{encode_path_segment(pty_id)}",
602
+ extra_headers=extra_headers,
603
+ extra_query=extra_query,
604
+ extra_body=extra_body,
605
+ timeout=timeout,
606
+ ),
607
+ response_type=PersistentPtyInfo,
608
+ unwrap=True,
609
+ ),
610
+ )
611
+
612
+ async def update(
613
+ self,
614
+ pty_id: PtyID,
615
+ *,
616
+ size: ExperimentalPersistentPtyUpdateSize,
617
+ attachment_id: str | NotGiven = NOT_GIVEN,
618
+ extra_headers: Headers | None = None,
619
+ extra_query: Query | None = None,
620
+ extra_body: Body | None = None,
621
+ timeout: Timeout | NotGiven = NOT_GIVEN,
622
+ ) -> PersistentPtyInfo:
623
+ """This endpoint is experimental in OpenCode and may change without notice.
624
+
625
+ Raises:
626
+ InvalidRequestError
627
+ UnauthorizedError
628
+ PtyNotFoundError
629
+ ServiceUnavailableError
630
+
631
+ ``PUT /api/experimental/persistent-pty/:ptyID``
632
+ """
633
+ return cast(
634
+ "PersistentPtyInfo",
635
+ await self._client.request(
636
+ RequestOptions(
637
+ method="PUT",
638
+ path=f"/api/experimental/persistent-pty/{encode_path_segment(pty_id)}",
639
+ body={"attachmentID": attachment_id, "size": size},
640
+ extra_headers=extra_headers,
641
+ extra_query=extra_query,
642
+ extra_body=extra_body,
643
+ timeout=timeout,
644
+ ),
645
+ response_type=PersistentPtyInfo,
646
+ unwrap=True,
647
+ ),
648
+ )
649
+
650
+ async def snapshot(
651
+ self,
652
+ pty_id: PtyID,
653
+ *,
654
+ extra_headers: Headers | None = None,
655
+ extra_query: Query | None = None,
656
+ extra_body: Body | None = None,
657
+ timeout: Timeout | NotGiven = NOT_GIVEN,
658
+ ) -> PersistentPtySnapshot:
659
+ """This endpoint is experimental in OpenCode and may change without notice.
660
+
661
+ Raises:
662
+ InvalidRequestError
663
+ UnauthorizedError
664
+ PtyNotFoundError
665
+ ServiceUnavailableError
666
+
667
+ ``GET /api/experimental/persistent-pty/:ptyID/snapshot``
668
+ """
669
+ return cast(
670
+ "PersistentPtySnapshot",
671
+ await self._client.request(
672
+ RequestOptions(
673
+ method="GET",
674
+ path=f"/api/experimental/persistent-pty/{encode_path_segment(pty_id)}/snapshot",
675
+ extra_headers=extra_headers,
676
+ extra_query=extra_query,
677
+ extra_body=extra_body,
678
+ timeout=timeout,
679
+ ),
680
+ response_type=PersistentPtySnapshot,
681
+ unwrap=True,
682
+ ),
683
+ )
684
+
685
+ async def remove(
686
+ self,
687
+ pty_id: PtyID,
688
+ *,
689
+ extra_headers: Headers | None = None,
690
+ extra_query: Query | None = None,
691
+ extra_body: Body | None = None,
692
+ timeout: Timeout | NotGiven = NOT_GIVEN,
693
+ ) -> None:
694
+ """This endpoint is experimental in OpenCode and may change without notice.
695
+
696
+ Raises:
697
+ InvalidRequestError
698
+ UnauthorizedError
699
+ PtyNotFoundError
700
+ ServiceUnavailableError
701
+
702
+ ``DELETE /api/experimental/persistent-pty/:ptyID``
703
+ """
704
+ await self._client.request(
705
+ RequestOptions(
706
+ method="DELETE",
707
+ path=f"/api/experimental/persistent-pty/{encode_path_segment(pty_id)}",
708
+ extra_headers=extra_headers,
709
+ extra_query=extra_query,
710
+ extra_body=extra_body,
711
+ timeout=timeout,
712
+ ),
713
+ kind="void",
714
+ )
715
+
716
+ async def connect_token(
717
+ self,
718
+ pty_id: PtyID,
719
+ *,
720
+ x_opencode_ticket: str | NotGiven | None = NOT_GIVEN,
721
+ extra_headers: Headers | None = None,
722
+ extra_query: Query | None = None,
723
+ extra_body: Body | None = None,
724
+ timeout: Timeout | NotGiven = NOT_GIVEN,
725
+ ) -> PtyTicketConnectToken:
726
+ """This endpoint is experimental in OpenCode and may change without notice.
727
+
728
+ Raises:
729
+ InvalidRequestError
730
+ UnauthorizedError
731
+ ForbiddenError
732
+ PtyNotFoundError
733
+ ServiceUnavailableError
734
+
735
+ ``POST /api/experimental/persistent-pty/:ptyID/connect-token``
736
+ """
737
+ return cast(
738
+ "PtyTicketConnectToken",
739
+ await self._client.request(
740
+ RequestOptions(
741
+ method="POST",
742
+ path=f"/api/experimental/persistent-pty/{encode_path_segment(pty_id)}/connect-token",
743
+ headers={"x-opencode-ticket": x_opencode_ticket},
744
+ extra_headers=extra_headers,
745
+ extra_query=extra_query,
746
+ extra_body=extra_body,
747
+ timeout=timeout,
748
+ ),
749
+ response_type=PtyTicketConnectToken,
750
+ unwrap=True,
751
+ ),
752
+ )
753
+
754
+
755
+ class AsyncExperimentalResource(AsyncAPIResource):
756
+ """Operations under ``client.experimental`` (OpenCode ``experimental``)."""
757
+
758
+ @cached_property
759
+ def persistent_pty(self) -> AsyncExperimentalPersistentPtyResource:
760
+ return AsyncExperimentalPersistentPtyResource(self._client)