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,3567 @@
|
|
|
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 ``session`` 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 TYPE_CHECKING, Any, Literal, cast
|
|
12
|
+
|
|
13
|
+
from .._base_client import RequestOptions
|
|
14
|
+
from .._pagination import AsyncPaginator, SyncCursorPage
|
|
15
|
+
from .._qs import encode_path_segment
|
|
16
|
+
from .._resource import AsyncAPIResource, SyncAPIResource
|
|
17
|
+
from .._streaming import AsyncStream, Stream
|
|
18
|
+
from .._types import NOT_GIVEN, Body, Headers, NotGiven, OpenEnum, Query, Timeout
|
|
19
|
+
from ..lib._session import AsyncSessionHelpers, SessionHelpers
|
|
20
|
+
|
|
21
|
+
if TYPE_CHECKING:
|
|
22
|
+
from ..types import (
|
|
23
|
+
AbsolutePath,
|
|
24
|
+
AgentID,
|
|
25
|
+
EventSeq,
|
|
26
|
+
FileDiffInfo,
|
|
27
|
+
FormAnswer,
|
|
28
|
+
FormDetail,
|
|
29
|
+
FormFields,
|
|
30
|
+
FormID,
|
|
31
|
+
FormInfo,
|
|
32
|
+
FormMetadata,
|
|
33
|
+
InstructionEntryInfo,
|
|
34
|
+
InstructionEntryKey,
|
|
35
|
+
LocationPublicRef,
|
|
36
|
+
ModelRef,
|
|
37
|
+
PermissionRuleset,
|
|
38
|
+
ProjectID,
|
|
39
|
+
PromptAgentAttachment,
|
|
40
|
+
PromptInputFileAttachment,
|
|
41
|
+
PromptInputSkillAttachment,
|
|
42
|
+
RelativePath,
|
|
43
|
+
SessionGenerateResponseData,
|
|
44
|
+
SessionID,
|
|
45
|
+
SessionInboxCompaction,
|
|
46
|
+
SessionInboxDelivery,
|
|
47
|
+
SessionInboxInfo,
|
|
48
|
+
SessionInboxSynthetic,
|
|
49
|
+
SessionInboxUser,
|
|
50
|
+
SessionInfo,
|
|
51
|
+
SessionInterruptResponse,
|
|
52
|
+
SessionLogItem,
|
|
53
|
+
SessionMessageID,
|
|
54
|
+
SessionMessageInfo,
|
|
55
|
+
SessionMetadata,
|
|
56
|
+
SessionRevert,
|
|
57
|
+
SessionsCursor,
|
|
58
|
+
SessionStatsInfo,
|
|
59
|
+
SessionTransferData,
|
|
60
|
+
SkillID,
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
__all__ = ["SessionResource", "AsyncSessionResource"]
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class SessionRevertResource(SyncAPIResource):
|
|
67
|
+
"""Operations under ``client.session.revert`` (OpenCode ``session.revert``)."""
|
|
68
|
+
|
|
69
|
+
def stage(
|
|
70
|
+
self,
|
|
71
|
+
session_id: SessionID,
|
|
72
|
+
*,
|
|
73
|
+
message_id: SessionMessageID,
|
|
74
|
+
files: bool | NotGiven | None = NOT_GIVEN,
|
|
75
|
+
extra_headers: Headers | None = None,
|
|
76
|
+
extra_query: Query | None = None,
|
|
77
|
+
extra_body: Body | None = None,
|
|
78
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
79
|
+
) -> SessionRevert:
|
|
80
|
+
"""Stage session revert.
|
|
81
|
+
|
|
82
|
+
Stage or move a reversible session boundary and optionally apply its file changes.
|
|
83
|
+
|
|
84
|
+
Raises:
|
|
85
|
+
InvalidRequestError: The server answered 400.
|
|
86
|
+
UnauthorizedError: The server answered 401.
|
|
87
|
+
MessageNotFoundError: The server answered 404.
|
|
88
|
+
SessionNotFoundError: The server answered 404.
|
|
89
|
+
LocationNotFoundError: The server answered 404.
|
|
90
|
+
SessionBusyError: The server answered 409.
|
|
91
|
+
UnknownError: The server answered 500.
|
|
92
|
+
|
|
93
|
+
``POST /api/session/:sessionID/revert/stage``
|
|
94
|
+
"""
|
|
95
|
+
return cast(
|
|
96
|
+
"SessionRevert",
|
|
97
|
+
self._client.request(
|
|
98
|
+
RequestOptions(
|
|
99
|
+
method="POST",
|
|
100
|
+
path=f"/api/session/{encode_path_segment(session_id)}/revert/stage",
|
|
101
|
+
body={"messageID": message_id, "files": files},
|
|
102
|
+
extra_headers=extra_headers,
|
|
103
|
+
extra_query=extra_query,
|
|
104
|
+
extra_body=extra_body,
|
|
105
|
+
timeout=timeout,
|
|
106
|
+
),
|
|
107
|
+
response_type="SessionRevert",
|
|
108
|
+
unwrap=True,
|
|
109
|
+
),
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
def clear(
|
|
113
|
+
self,
|
|
114
|
+
session_id: SessionID,
|
|
115
|
+
*,
|
|
116
|
+
extra_headers: Headers | None = None,
|
|
117
|
+
extra_query: Query | None = None,
|
|
118
|
+
extra_body: Body | None = None,
|
|
119
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
120
|
+
) -> None:
|
|
121
|
+
"""Clear staged revert.
|
|
122
|
+
|
|
123
|
+
Raises:
|
|
124
|
+
InvalidRequestError: The server answered 400.
|
|
125
|
+
UnauthorizedError: The server answered 401.
|
|
126
|
+
SessionNotFoundError: The server answered 404.
|
|
127
|
+
LocationNotFoundError: The server answered 404.
|
|
128
|
+
SessionBusyError: The server answered 409.
|
|
129
|
+
UnknownError: The server answered 500.
|
|
130
|
+
|
|
131
|
+
``DELETE /api/session/:sessionID/revert``
|
|
132
|
+
"""
|
|
133
|
+
self._client.request(
|
|
134
|
+
RequestOptions(
|
|
135
|
+
method="DELETE",
|
|
136
|
+
path=f"/api/session/{encode_path_segment(session_id)}/revert",
|
|
137
|
+
extra_headers=extra_headers,
|
|
138
|
+
extra_query=extra_query,
|
|
139
|
+
extra_body=extra_body,
|
|
140
|
+
timeout=timeout,
|
|
141
|
+
),
|
|
142
|
+
kind="void",
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
def commit(
|
|
146
|
+
self,
|
|
147
|
+
session_id: SessionID,
|
|
148
|
+
*,
|
|
149
|
+
extra_headers: Headers | None = None,
|
|
150
|
+
extra_query: Query | None = None,
|
|
151
|
+
extra_body: Body | None = None,
|
|
152
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
153
|
+
) -> None:
|
|
154
|
+
"""Commit staged revert.
|
|
155
|
+
|
|
156
|
+
Raises:
|
|
157
|
+
InvalidRequestError: The server answered 400.
|
|
158
|
+
UnauthorizedError: The server answered 401.
|
|
159
|
+
SessionNotFoundError: The server answered 404.
|
|
160
|
+
LocationNotFoundError: The server answered 404.
|
|
161
|
+
SessionBusyError: The server answered 409.
|
|
162
|
+
|
|
163
|
+
``POST /api/session/:sessionID/revert/commit``
|
|
164
|
+
"""
|
|
165
|
+
self._client.request(
|
|
166
|
+
RequestOptions(
|
|
167
|
+
method="POST",
|
|
168
|
+
path=f"/api/session/{encode_path_segment(session_id)}/revert/commit",
|
|
169
|
+
extra_headers=extra_headers,
|
|
170
|
+
extra_query=extra_query,
|
|
171
|
+
extra_body=extra_body,
|
|
172
|
+
timeout=timeout,
|
|
173
|
+
),
|
|
174
|
+
kind="void",
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
class SessionInboxResource(SyncAPIResource):
|
|
179
|
+
"""Operations under ``client.session.inbox`` (OpenCode ``session.inbox``)."""
|
|
180
|
+
|
|
181
|
+
def list(
|
|
182
|
+
self,
|
|
183
|
+
session_id: SessionID,
|
|
184
|
+
*,
|
|
185
|
+
extra_headers: Headers | None = None,
|
|
186
|
+
extra_query: Query | None = None,
|
|
187
|
+
extra_body: Body | None = None,
|
|
188
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
189
|
+
) -> builtins.list[SessionInboxInfo]:
|
|
190
|
+
"""List session inbox.
|
|
191
|
+
|
|
192
|
+
List durable enqueued session work not yet delivered, ordered by enqueue sequence. Includes user, synthetic, compaction, and move items.
|
|
193
|
+
|
|
194
|
+
Raises:
|
|
195
|
+
InvalidRequestError: The server answered 400.
|
|
196
|
+
UnauthorizedError: The server answered 401.
|
|
197
|
+
SessionNotFoundError: The server answered 404.
|
|
198
|
+
|
|
199
|
+
``GET /api/session/:sessionID/inbox``
|
|
200
|
+
"""
|
|
201
|
+
return cast(
|
|
202
|
+
"builtins.list[SessionInboxInfo]",
|
|
203
|
+
self._client.request(
|
|
204
|
+
RequestOptions(
|
|
205
|
+
method="GET",
|
|
206
|
+
path=f"/api/session/{encode_path_segment(session_id)}/inbox",
|
|
207
|
+
extra_headers=extra_headers,
|
|
208
|
+
extra_query=extra_query,
|
|
209
|
+
extra_body=extra_body,
|
|
210
|
+
timeout=timeout,
|
|
211
|
+
),
|
|
212
|
+
response_type="builtins.list[SessionInboxInfo]",
|
|
213
|
+
unwrap=True,
|
|
214
|
+
),
|
|
215
|
+
)
|
|
216
|
+
|
|
217
|
+
def cancel(
|
|
218
|
+
self,
|
|
219
|
+
session_id: SessionID,
|
|
220
|
+
inbox_id: SessionMessageID,
|
|
221
|
+
*,
|
|
222
|
+
extra_headers: Headers | None = None,
|
|
223
|
+
extra_query: Query | None = None,
|
|
224
|
+
extra_body: Body | None = None,
|
|
225
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
226
|
+
) -> None:
|
|
227
|
+
"""Cancel inbox input.
|
|
228
|
+
|
|
229
|
+
Cancel an inbox item that has not yet been delivered. Unavailable items are a no-op.
|
|
230
|
+
|
|
231
|
+
Raises:
|
|
232
|
+
InvalidRequestError: The server answered 400.
|
|
233
|
+
UnauthorizedError: The server answered 401.
|
|
234
|
+
SessionNotFoundError: The server answered 404.
|
|
235
|
+
|
|
236
|
+
``DELETE /api/session/:sessionID/inbox/:inboxID``
|
|
237
|
+
"""
|
|
238
|
+
self._client.request(
|
|
239
|
+
RequestOptions(
|
|
240
|
+
method="DELETE",
|
|
241
|
+
path=f"/api/session/{encode_path_segment(session_id)}/inbox/{encode_path_segment(inbox_id)}",
|
|
242
|
+
extra_headers=extra_headers,
|
|
243
|
+
extra_query=extra_query,
|
|
244
|
+
extra_body=extra_body,
|
|
245
|
+
timeout=timeout,
|
|
246
|
+
),
|
|
247
|
+
kind="void",
|
|
248
|
+
)
|
|
249
|
+
|
|
250
|
+
def update(
|
|
251
|
+
self,
|
|
252
|
+
session_id: SessionID,
|
|
253
|
+
inbox_id: SessionMessageID,
|
|
254
|
+
*,
|
|
255
|
+
delivery: SessionInboxDelivery,
|
|
256
|
+
extra_headers: Headers | None = None,
|
|
257
|
+
extra_query: Query | None = None,
|
|
258
|
+
extra_body: Body | None = None,
|
|
259
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
260
|
+
) -> None:
|
|
261
|
+
"""Update inbox item.
|
|
262
|
+
|
|
263
|
+
Change a pending inbox item's delivery mode. Steering wakes session execution.
|
|
264
|
+
|
|
265
|
+
Raises:
|
|
266
|
+
InvalidRequestError: The server answered 400.
|
|
267
|
+
UnauthorizedError: The server answered 401.
|
|
268
|
+
SessionNotFoundError: The server answered 404.
|
|
269
|
+
ConflictError: The server answered 409.
|
|
270
|
+
|
|
271
|
+
``PATCH /api/session/:sessionID/inbox/:inboxID``
|
|
272
|
+
"""
|
|
273
|
+
self._client.request(
|
|
274
|
+
RequestOptions(
|
|
275
|
+
method="PATCH",
|
|
276
|
+
path=f"/api/session/{encode_path_segment(session_id)}/inbox/{encode_path_segment(inbox_id)}",
|
|
277
|
+
body={"delivery": delivery},
|
|
278
|
+
extra_headers=extra_headers,
|
|
279
|
+
extra_query=extra_query,
|
|
280
|
+
extra_body=extra_body,
|
|
281
|
+
timeout=timeout,
|
|
282
|
+
),
|
|
283
|
+
kind="void",
|
|
284
|
+
)
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
class SessionInstructionsEntryResource(SyncAPIResource):
|
|
288
|
+
"""Operations under ``client.session.instructions.entry`` (OpenCode ``session.instructions.entry``)."""
|
|
289
|
+
|
|
290
|
+
def list(
|
|
291
|
+
self,
|
|
292
|
+
session_id: SessionID,
|
|
293
|
+
*,
|
|
294
|
+
extra_headers: Headers | None = None,
|
|
295
|
+
extra_query: Query | None = None,
|
|
296
|
+
extra_body: Body | None = None,
|
|
297
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
298
|
+
) -> builtins.list[InstructionEntryInfo]:
|
|
299
|
+
"""List instruction entries.
|
|
300
|
+
|
|
301
|
+
List API-managed instruction entries attached to the session.
|
|
302
|
+
|
|
303
|
+
This endpoint is experimental in OpenCode and may change without notice.
|
|
304
|
+
|
|
305
|
+
Raises:
|
|
306
|
+
InvalidRequestError: The server answered 400.
|
|
307
|
+
UnauthorizedError: The server answered 401.
|
|
308
|
+
SessionNotFoundError: The server answered 404.
|
|
309
|
+
LocationNotFoundError: The server answered 404.
|
|
310
|
+
|
|
311
|
+
``GET /api/experimental/session/:sessionID/instructions/entries``
|
|
312
|
+
"""
|
|
313
|
+
return cast(
|
|
314
|
+
"builtins.list[InstructionEntryInfo]",
|
|
315
|
+
self._client.request(
|
|
316
|
+
RequestOptions(
|
|
317
|
+
method="GET",
|
|
318
|
+
path=f"/api/experimental/session/{encode_path_segment(session_id)}/instructions/entries",
|
|
319
|
+
extra_headers=extra_headers,
|
|
320
|
+
extra_query=extra_query,
|
|
321
|
+
extra_body=extra_body,
|
|
322
|
+
timeout=timeout,
|
|
323
|
+
),
|
|
324
|
+
response_type="builtins.list[InstructionEntryInfo]",
|
|
325
|
+
unwrap=True,
|
|
326
|
+
),
|
|
327
|
+
)
|
|
328
|
+
|
|
329
|
+
def put(
|
|
330
|
+
self,
|
|
331
|
+
session_id: SessionID,
|
|
332
|
+
key: InstructionEntryKey,
|
|
333
|
+
*,
|
|
334
|
+
value: Any,
|
|
335
|
+
extra_headers: Headers | None = None,
|
|
336
|
+
extra_query: Query | None = None,
|
|
337
|
+
extra_body: Body | None = None,
|
|
338
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
339
|
+
) -> None:
|
|
340
|
+
"""Put instruction entry.
|
|
341
|
+
|
|
342
|
+
Attach or replace one durable instruction entry. Changes announce as updates at the next step boundary.
|
|
343
|
+
|
|
344
|
+
This endpoint is experimental in OpenCode and may change without notice.
|
|
345
|
+
|
|
346
|
+
Raises:
|
|
347
|
+
InvalidRequestError: The server answered 400.
|
|
348
|
+
UnauthorizedError: The server answered 401.
|
|
349
|
+
SessionNotFoundError: The server answered 404.
|
|
350
|
+
LocationNotFoundError: The server answered 404.
|
|
351
|
+
InstructionEntryValueTooLargeError: The server answered 413.
|
|
352
|
+
|
|
353
|
+
``PUT /api/experimental/session/:sessionID/instructions/entries/:key``
|
|
354
|
+
"""
|
|
355
|
+
self._client.request(
|
|
356
|
+
RequestOptions(
|
|
357
|
+
method="PUT",
|
|
358
|
+
path=f"/api/experimental/session/{encode_path_segment(session_id)}/instructions/entries/{encode_path_segment(key)}",
|
|
359
|
+
body={"value": value},
|
|
360
|
+
extra_headers=extra_headers,
|
|
361
|
+
extra_query=extra_query,
|
|
362
|
+
extra_body=extra_body,
|
|
363
|
+
timeout=timeout,
|
|
364
|
+
),
|
|
365
|
+
kind="void",
|
|
366
|
+
)
|
|
367
|
+
|
|
368
|
+
def remove(
|
|
369
|
+
self,
|
|
370
|
+
session_id: SessionID,
|
|
371
|
+
key: InstructionEntryKey,
|
|
372
|
+
*,
|
|
373
|
+
extra_headers: Headers | None = None,
|
|
374
|
+
extra_query: Query | None = None,
|
|
375
|
+
extra_body: Body | None = None,
|
|
376
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
377
|
+
) -> None:
|
|
378
|
+
"""Remove instruction entry.
|
|
379
|
+
|
|
380
|
+
Remove one instruction entry; the removal is announced to the model at the next step boundary.
|
|
381
|
+
|
|
382
|
+
This endpoint is experimental in OpenCode and may change without notice.
|
|
383
|
+
|
|
384
|
+
Raises:
|
|
385
|
+
InvalidRequestError: The server answered 400.
|
|
386
|
+
UnauthorizedError: The server answered 401.
|
|
387
|
+
SessionNotFoundError: The server answered 404.
|
|
388
|
+
LocationNotFoundError: The server answered 404.
|
|
389
|
+
|
|
390
|
+
``DELETE /api/experimental/session/:sessionID/instructions/entries/:key``
|
|
391
|
+
"""
|
|
392
|
+
self._client.request(
|
|
393
|
+
RequestOptions(
|
|
394
|
+
method="DELETE",
|
|
395
|
+
path=f"/api/experimental/session/{encode_path_segment(session_id)}/instructions/entries/{encode_path_segment(key)}",
|
|
396
|
+
extra_headers=extra_headers,
|
|
397
|
+
extra_query=extra_query,
|
|
398
|
+
extra_body=extra_body,
|
|
399
|
+
timeout=timeout,
|
|
400
|
+
),
|
|
401
|
+
kind="void",
|
|
402
|
+
)
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
class SessionInstructionsResource(SyncAPIResource):
|
|
406
|
+
"""Operations under ``client.session.instructions`` (OpenCode ``session.instructions``)."""
|
|
407
|
+
|
|
408
|
+
@cached_property
|
|
409
|
+
def entry(self) -> SessionInstructionsEntryResource:
|
|
410
|
+
"""Operations under ``client.session.instructions.entry``."""
|
|
411
|
+
return SessionInstructionsEntryResource(self._client)
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
class SessionMessageResource(SyncAPIResource):
|
|
415
|
+
"""Operations under ``client.session.message`` (OpenCode ``session.message``)."""
|
|
416
|
+
|
|
417
|
+
def get(
|
|
418
|
+
self,
|
|
419
|
+
session_id: SessionID,
|
|
420
|
+
message_id: SessionMessageID,
|
|
421
|
+
*,
|
|
422
|
+
extra_headers: Headers | None = None,
|
|
423
|
+
extra_query: Query | None = None,
|
|
424
|
+
extra_body: Body | None = None,
|
|
425
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
426
|
+
) -> SessionMessageInfo:
|
|
427
|
+
"""Get session message.
|
|
428
|
+
|
|
429
|
+
Retrieve one projected message owned by the Session.
|
|
430
|
+
|
|
431
|
+
Raises:
|
|
432
|
+
InvalidRequestError: The server answered 400.
|
|
433
|
+
UnauthorizedError: The server answered 401.
|
|
434
|
+
SessionNotFoundError: The server answered 404.
|
|
435
|
+
MessageNotFoundError: The server answered 404.
|
|
436
|
+
|
|
437
|
+
``GET /api/session/:sessionID/message/:messageID``
|
|
438
|
+
"""
|
|
439
|
+
return cast(
|
|
440
|
+
"SessionMessageInfo",
|
|
441
|
+
self._client.request(
|
|
442
|
+
RequestOptions(
|
|
443
|
+
method="GET",
|
|
444
|
+
path=f"/api/session/{encode_path_segment(session_id)}/message/{encode_path_segment(message_id)}",
|
|
445
|
+
extra_headers=extra_headers,
|
|
446
|
+
extra_query=extra_query,
|
|
447
|
+
extra_body=extra_body,
|
|
448
|
+
timeout=timeout,
|
|
449
|
+
),
|
|
450
|
+
response_type="SessionMessageInfo",
|
|
451
|
+
unwrap=True,
|
|
452
|
+
),
|
|
453
|
+
)
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
class SessionFormResource(SyncAPIResource):
|
|
457
|
+
"""Operations under ``client.session.form`` (OpenCode ``session.form``)."""
|
|
458
|
+
|
|
459
|
+
def list(
|
|
460
|
+
self,
|
|
461
|
+
session_id: str,
|
|
462
|
+
*,
|
|
463
|
+
extra_headers: Headers | None = None,
|
|
464
|
+
extra_query: Query | None = None,
|
|
465
|
+
extra_body: Body | None = None,
|
|
466
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
467
|
+
) -> builtins.list[FormInfo]:
|
|
468
|
+
"""List session forms.
|
|
469
|
+
|
|
470
|
+
Retrieve pending forms for a session.
|
|
471
|
+
|
|
472
|
+
Raises:
|
|
473
|
+
InvalidRequestError: The server answered 400.
|
|
474
|
+
UnauthorizedError: The server answered 401.
|
|
475
|
+
SessionNotFoundError: The server answered 404.
|
|
476
|
+
LocationNotFoundError: The server answered 404.
|
|
477
|
+
|
|
478
|
+
``GET /api/session/:sessionID/form``
|
|
479
|
+
"""
|
|
480
|
+
return cast(
|
|
481
|
+
"builtins.list[FormInfo]",
|
|
482
|
+
self._client.request(
|
|
483
|
+
RequestOptions(
|
|
484
|
+
method="GET",
|
|
485
|
+
path=f"/api/session/{encode_path_segment(session_id)}/form",
|
|
486
|
+
extra_headers=extra_headers,
|
|
487
|
+
extra_query=extra_query,
|
|
488
|
+
extra_body=extra_body,
|
|
489
|
+
timeout=timeout,
|
|
490
|
+
),
|
|
491
|
+
response_type="builtins.list[FormInfo]",
|
|
492
|
+
unwrap=True,
|
|
493
|
+
),
|
|
494
|
+
)
|
|
495
|
+
|
|
496
|
+
def create(
|
|
497
|
+
self,
|
|
498
|
+
session_id: str,
|
|
499
|
+
*,
|
|
500
|
+
title: str,
|
|
501
|
+
fields: FormFields,
|
|
502
|
+
id: FormID | NotGiven | None = NOT_GIVEN,
|
|
503
|
+
metadata: FormMetadata | NotGiven = NOT_GIVEN,
|
|
504
|
+
extra_headers: Headers | None = None,
|
|
505
|
+
extra_query: Query | None = None,
|
|
506
|
+
extra_body: Body | None = None,
|
|
507
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
508
|
+
) -> FormInfo:
|
|
509
|
+
"""Create session form.
|
|
510
|
+
|
|
511
|
+
Create a form for a session.
|
|
512
|
+
|
|
513
|
+
Raises:
|
|
514
|
+
InvalidRequestError: The server answered 400.
|
|
515
|
+
UnauthorizedError: The server answered 401.
|
|
516
|
+
SessionNotFoundError: The server answered 404.
|
|
517
|
+
LocationNotFoundError: The server answered 404.
|
|
518
|
+
ConflictError: The server answered 409.
|
|
519
|
+
|
|
520
|
+
``POST /api/session/:sessionID/form``
|
|
521
|
+
"""
|
|
522
|
+
return cast(
|
|
523
|
+
"FormInfo",
|
|
524
|
+
self._client.request(
|
|
525
|
+
RequestOptions(
|
|
526
|
+
method="POST",
|
|
527
|
+
path=f"/api/session/{encode_path_segment(session_id)}/form",
|
|
528
|
+
body={"id": id, "title": title, "metadata": metadata, "fields": fields},
|
|
529
|
+
extra_headers=extra_headers,
|
|
530
|
+
extra_query=extra_query,
|
|
531
|
+
extra_body=extra_body,
|
|
532
|
+
timeout=timeout,
|
|
533
|
+
),
|
|
534
|
+
response_type="FormInfo",
|
|
535
|
+
unwrap=True,
|
|
536
|
+
),
|
|
537
|
+
)
|
|
538
|
+
|
|
539
|
+
def get(
|
|
540
|
+
self,
|
|
541
|
+
session_id: str,
|
|
542
|
+
form_id: FormID,
|
|
543
|
+
*,
|
|
544
|
+
extra_headers: Headers | None = None,
|
|
545
|
+
extra_query: Query | None = None,
|
|
546
|
+
extra_body: Body | None = None,
|
|
547
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
548
|
+
) -> FormDetail:
|
|
549
|
+
"""Get session form.
|
|
550
|
+
|
|
551
|
+
Retrieve a form and its current state for a session.
|
|
552
|
+
|
|
553
|
+
Raises:
|
|
554
|
+
InvalidRequestError: The server answered 400.
|
|
555
|
+
UnauthorizedError: The server answered 401.
|
|
556
|
+
SessionNotFoundError: The server answered 404.
|
|
557
|
+
FormNotFoundError: The server answered 404.
|
|
558
|
+
LocationNotFoundError: The server answered 404.
|
|
559
|
+
|
|
560
|
+
``GET /api/session/:sessionID/form/:formID``
|
|
561
|
+
"""
|
|
562
|
+
return cast(
|
|
563
|
+
"FormDetail",
|
|
564
|
+
self._client.request(
|
|
565
|
+
RequestOptions(
|
|
566
|
+
method="GET",
|
|
567
|
+
path=f"/api/session/{encode_path_segment(session_id)}/form/{encode_path_segment(form_id)}",
|
|
568
|
+
extra_headers=extra_headers,
|
|
569
|
+
extra_query=extra_query,
|
|
570
|
+
extra_body=extra_body,
|
|
571
|
+
timeout=timeout,
|
|
572
|
+
),
|
|
573
|
+
response_type="FormDetail",
|
|
574
|
+
unwrap=True,
|
|
575
|
+
),
|
|
576
|
+
)
|
|
577
|
+
|
|
578
|
+
def reply(
|
|
579
|
+
self,
|
|
580
|
+
session_id: str,
|
|
581
|
+
form_id: FormID,
|
|
582
|
+
*,
|
|
583
|
+
answer: FormAnswer,
|
|
584
|
+
extra_headers: Headers | None = None,
|
|
585
|
+
extra_query: Query | None = None,
|
|
586
|
+
extra_body: Body | None = None,
|
|
587
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
588
|
+
) -> None:
|
|
589
|
+
"""Reply to form.
|
|
590
|
+
|
|
591
|
+
Submit an answer to a pending form.
|
|
592
|
+
|
|
593
|
+
Raises:
|
|
594
|
+
FormInvalidAnswerError: The server answered 400.
|
|
595
|
+
InvalidRequestError: The server answered 400.
|
|
596
|
+
UnauthorizedError: The server answered 401.
|
|
597
|
+
SessionNotFoundError: The server answered 404.
|
|
598
|
+
FormNotFoundError: The server answered 404.
|
|
599
|
+
LocationNotFoundError: The server answered 404.
|
|
600
|
+
FormAlreadySettledError: The server answered 409.
|
|
601
|
+
|
|
602
|
+
``POST /api/session/:sessionID/form/:formID/reply``
|
|
603
|
+
"""
|
|
604
|
+
self._client.request(
|
|
605
|
+
RequestOptions(
|
|
606
|
+
method="POST",
|
|
607
|
+
path=f"/api/session/{encode_path_segment(session_id)}/form/{encode_path_segment(form_id)}/reply",
|
|
608
|
+
body={"answer": answer},
|
|
609
|
+
extra_headers=extra_headers,
|
|
610
|
+
extra_query=extra_query,
|
|
611
|
+
extra_body=extra_body,
|
|
612
|
+
timeout=timeout,
|
|
613
|
+
),
|
|
614
|
+
kind="void",
|
|
615
|
+
)
|
|
616
|
+
|
|
617
|
+
def cancel(
|
|
618
|
+
self,
|
|
619
|
+
session_id: str,
|
|
620
|
+
form_id: FormID,
|
|
621
|
+
*,
|
|
622
|
+
message: str | NotGiven | None = NOT_GIVEN,
|
|
623
|
+
extra_headers: Headers | None = None,
|
|
624
|
+
extra_query: Query | None = None,
|
|
625
|
+
extra_body: Body | None = None,
|
|
626
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
627
|
+
) -> None:
|
|
628
|
+
"""Cancel form.
|
|
629
|
+
|
|
630
|
+
Cancel a pending form, optionally telling the asker why it was not answered.
|
|
631
|
+
|
|
632
|
+
Raises:
|
|
633
|
+
InvalidRequestError: The server answered 400.
|
|
634
|
+
UnauthorizedError: The server answered 401.
|
|
635
|
+
SessionNotFoundError: The server answered 404.
|
|
636
|
+
FormNotFoundError: The server answered 404.
|
|
637
|
+
LocationNotFoundError: The server answered 404.
|
|
638
|
+
FormAlreadySettledError: The server answered 409.
|
|
639
|
+
|
|
640
|
+
``DELETE /api/session/:sessionID/form/:formID``
|
|
641
|
+
"""
|
|
642
|
+
self._client.request(
|
|
643
|
+
RequestOptions(
|
|
644
|
+
method="DELETE",
|
|
645
|
+
path=f"/api/session/{encode_path_segment(session_id)}/form/{encode_path_segment(form_id)}",
|
|
646
|
+
query={"message": message},
|
|
647
|
+
extra_headers=extra_headers,
|
|
648
|
+
extra_query=extra_query,
|
|
649
|
+
extra_body=extra_body,
|
|
650
|
+
timeout=timeout,
|
|
651
|
+
),
|
|
652
|
+
kind="void",
|
|
653
|
+
)
|
|
654
|
+
|
|
655
|
+
|
|
656
|
+
class SessionResource(SessionHelpers):
|
|
657
|
+
"""Operations under ``client.session`` (OpenCode ``session``)."""
|
|
658
|
+
|
|
659
|
+
@cached_property
|
|
660
|
+
def revert(self) -> SessionRevertResource:
|
|
661
|
+
"""Operations under ``client.session.revert``."""
|
|
662
|
+
return SessionRevertResource(self._client)
|
|
663
|
+
|
|
664
|
+
@cached_property
|
|
665
|
+
def inbox(self) -> SessionInboxResource:
|
|
666
|
+
"""Operations under ``client.session.inbox``."""
|
|
667
|
+
return SessionInboxResource(self._client)
|
|
668
|
+
|
|
669
|
+
@cached_property
|
|
670
|
+
def instructions(self) -> SessionInstructionsResource:
|
|
671
|
+
"""Operations under ``client.session.instructions``."""
|
|
672
|
+
return SessionInstructionsResource(self._client)
|
|
673
|
+
|
|
674
|
+
@cached_property
|
|
675
|
+
def message(self) -> SessionMessageResource:
|
|
676
|
+
"""Operations under ``client.session.message``."""
|
|
677
|
+
return SessionMessageResource(self._client)
|
|
678
|
+
|
|
679
|
+
@cached_property
|
|
680
|
+
def form(self) -> SessionFormResource:
|
|
681
|
+
"""Operations under ``client.session.form``."""
|
|
682
|
+
return SessionFormResource(self._client)
|
|
683
|
+
|
|
684
|
+
def list(
|
|
685
|
+
self,
|
|
686
|
+
*,
|
|
687
|
+
limit: int | NotGiven | None = NOT_GIVEN,
|
|
688
|
+
order: OpenEnum[Literal["asc", "desc"]] | NotGiven | None = NOT_GIVEN,
|
|
689
|
+
search: str | NotGiven | None = NOT_GIVEN,
|
|
690
|
+
parent_id: SessionID | NotGiven | None = NOT_GIVEN,
|
|
691
|
+
archived: bool | NotGiven | None = NOT_GIVEN,
|
|
692
|
+
directory: AbsolutePath | NotGiven | None = NOT_GIVEN,
|
|
693
|
+
project: ProjectID | NotGiven | None = NOT_GIVEN,
|
|
694
|
+
subpath: RelativePath | NotGiven | None = NOT_GIVEN,
|
|
695
|
+
cursor: SessionsCursor | NotGiven | None = NOT_GIVEN,
|
|
696
|
+
extra_headers: Headers | None = None,
|
|
697
|
+
extra_query: Query | None = None,
|
|
698
|
+
extra_body: Body | None = None,
|
|
699
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
700
|
+
) -> SyncCursorPage[SessionInfo]:
|
|
701
|
+
"""List sessions.
|
|
702
|
+
|
|
703
|
+
Retrieve sessions in the requested order. Items keep that order across pages; use cursor.next or cursor.previous to move through the ordered list.
|
|
704
|
+
|
|
705
|
+
Args:
|
|
706
|
+
limit: Maximum number of sessions to return. Defaults to the newest 50 sessions.
|
|
707
|
+
order: Session order for the first page. Use desc for newest first or asc for oldest first.
|
|
708
|
+
parent_id: Filter by parent session. Use null to return only root sessions.
|
|
709
|
+
archived: Filter by archive state. Use true to return only archived sessions or false to exclude them. Omit to include both.
|
|
710
|
+
|
|
711
|
+
Raises:
|
|
712
|
+
InvalidCursorError: The server answered 400.
|
|
713
|
+
InvalidRequestError: The server answered 400.
|
|
714
|
+
UnauthorizedError: The server answered 401.
|
|
715
|
+
|
|
716
|
+
``GET /api/session``
|
|
717
|
+
"""
|
|
718
|
+
return self._client.page(
|
|
719
|
+
RequestOptions(
|
|
720
|
+
method="GET",
|
|
721
|
+
path="/api/session",
|
|
722
|
+
query={
|
|
723
|
+
"limit": limit,
|
|
724
|
+
"order": order,
|
|
725
|
+
"search": search,
|
|
726
|
+
"parentID": parent_id,
|
|
727
|
+
"archived": archived,
|
|
728
|
+
"directory": directory,
|
|
729
|
+
"project": project,
|
|
730
|
+
"subpath": subpath,
|
|
731
|
+
"cursor": cursor,
|
|
732
|
+
},
|
|
733
|
+
extra_headers=extra_headers,
|
|
734
|
+
extra_query=extra_query,
|
|
735
|
+
extra_body=extra_body,
|
|
736
|
+
timeout=timeout,
|
|
737
|
+
),
|
|
738
|
+
response_type="SessionsResponse",
|
|
739
|
+
)
|
|
740
|
+
|
|
741
|
+
def stats(
|
|
742
|
+
self,
|
|
743
|
+
*,
|
|
744
|
+
from_: float | OpenEnum[Literal["Infinity", "-Infinity", "NaN"]] | NotGiven | None = NOT_GIVEN,
|
|
745
|
+
to: float | OpenEnum[Literal["Infinity", "-Infinity", "NaN"]] | NotGiven | None = NOT_GIVEN,
|
|
746
|
+
project: ProjectID | NotGiven | None = NOT_GIVEN,
|
|
747
|
+
timezone: str | NotGiven | None = NOT_GIVEN,
|
|
748
|
+
tools: OpenEnum[Literal["none", "summary", "detail"]] | NotGiven | None = NOT_GIVEN,
|
|
749
|
+
extra_headers: Headers | None = None,
|
|
750
|
+
extra_query: Query | None = None,
|
|
751
|
+
extra_body: Body | None = None,
|
|
752
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
753
|
+
) -> SessionStatsInfo:
|
|
754
|
+
"""Get session statistics.
|
|
755
|
+
|
|
756
|
+
Aggregate local session activity, usage, and tool reliability for a time range.
|
|
757
|
+
|
|
758
|
+
This endpoint is experimental in OpenCode and may change without notice.
|
|
759
|
+
|
|
760
|
+
Raises:
|
|
761
|
+
InvalidRequestError: The server answered 400.
|
|
762
|
+
UnauthorizedError: The server answered 401.
|
|
763
|
+
|
|
764
|
+
``GET /api/experimental/session/stats``
|
|
765
|
+
"""
|
|
766
|
+
return cast(
|
|
767
|
+
"SessionStatsInfo",
|
|
768
|
+
self._client.request(
|
|
769
|
+
RequestOptions(
|
|
770
|
+
method="GET",
|
|
771
|
+
path="/api/experimental/session/stats",
|
|
772
|
+
query={"from": from_, "to": to, "project": project, "timezone": timezone, "tools": tools},
|
|
773
|
+
extra_headers=extra_headers,
|
|
774
|
+
extra_query=extra_query,
|
|
775
|
+
extra_body=extra_body,
|
|
776
|
+
timeout=timeout,
|
|
777
|
+
),
|
|
778
|
+
response_type="SessionStatsInfo",
|
|
779
|
+
unwrap=True,
|
|
780
|
+
),
|
|
781
|
+
)
|
|
782
|
+
|
|
783
|
+
def create(
|
|
784
|
+
self,
|
|
785
|
+
*,
|
|
786
|
+
id: SessionID | NotGiven | None = NOT_GIVEN,
|
|
787
|
+
parent_id: SessionID | NotGiven | None = NOT_GIVEN,
|
|
788
|
+
title: str | NotGiven | None = NOT_GIVEN,
|
|
789
|
+
agent: AgentID | NotGiven | None = NOT_GIVEN,
|
|
790
|
+
model: ModelRef | NotGiven | None = NOT_GIVEN,
|
|
791
|
+
location: LocationPublicRef | NotGiven | None = NOT_GIVEN,
|
|
792
|
+
metadata: SessionMetadata | NotGiven | None = NOT_GIVEN,
|
|
793
|
+
permissions: PermissionRuleset | NotGiven | None = NOT_GIVEN,
|
|
794
|
+
extra_headers: Headers | None = None,
|
|
795
|
+
extra_query: Query | None = None,
|
|
796
|
+
extra_body: Body | None = None,
|
|
797
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
798
|
+
) -> SessionInfo:
|
|
799
|
+
"""Create session.
|
|
800
|
+
|
|
801
|
+
Create a session at the requested location. A parentID creates a linked child session at its parent's location.
|
|
802
|
+
|
|
803
|
+
Raises:
|
|
804
|
+
InvalidRequestError: The server answered 400.
|
|
805
|
+
UnauthorizedError: The server answered 401.
|
|
806
|
+
SessionNotFoundError: The server answered 404.
|
|
807
|
+
|
|
808
|
+
``POST /api/session``
|
|
809
|
+
"""
|
|
810
|
+
return cast(
|
|
811
|
+
"SessionInfo",
|
|
812
|
+
self._client.request(
|
|
813
|
+
RequestOptions(
|
|
814
|
+
method="POST",
|
|
815
|
+
path="/api/session",
|
|
816
|
+
body={
|
|
817
|
+
"id": id,
|
|
818
|
+
"parentID": parent_id,
|
|
819
|
+
"title": title,
|
|
820
|
+
"agent": agent,
|
|
821
|
+
"model": model,
|
|
822
|
+
"location": self._location(location),
|
|
823
|
+
"metadata": metadata,
|
|
824
|
+
"permissions": permissions,
|
|
825
|
+
},
|
|
826
|
+
extra_headers=extra_headers,
|
|
827
|
+
extra_query=extra_query,
|
|
828
|
+
extra_body=extra_body,
|
|
829
|
+
timeout=timeout,
|
|
830
|
+
),
|
|
831
|
+
response_type="SessionInfo",
|
|
832
|
+
unwrap=True,
|
|
833
|
+
),
|
|
834
|
+
)
|
|
835
|
+
|
|
836
|
+
def import_(
|
|
837
|
+
self,
|
|
838
|
+
*,
|
|
839
|
+
info: SessionInfo,
|
|
840
|
+
messages: Sequence[Any],
|
|
841
|
+
location: LocationPublicRef | NotGiven | None = NOT_GIVEN,
|
|
842
|
+
extra_headers: Headers | None = None,
|
|
843
|
+
extra_query: Query | None = None,
|
|
844
|
+
extra_body: Body | None = None,
|
|
845
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
846
|
+
) -> SessionInfo:
|
|
847
|
+
"""Import session.
|
|
848
|
+
|
|
849
|
+
Import a projected session transcript at the requested location. Accepts transcripts exported by earlier releases. If parentID is supplied, the parent session must already exist; import parents before children.
|
|
850
|
+
|
|
851
|
+
This endpoint is experimental in OpenCode and may change without notice.
|
|
852
|
+
|
|
853
|
+
Raises:
|
|
854
|
+
InvalidRequestError: The server answered 400.
|
|
855
|
+
UnauthorizedError: The server answered 401.
|
|
856
|
+
SessionNotFoundError: The server answered 404.
|
|
857
|
+
ConflictError: The server answered 409.
|
|
858
|
+
|
|
859
|
+
``POST /api/experimental/session/import``
|
|
860
|
+
"""
|
|
861
|
+
return cast(
|
|
862
|
+
"SessionInfo",
|
|
863
|
+
self._client.request(
|
|
864
|
+
RequestOptions(
|
|
865
|
+
method="POST",
|
|
866
|
+
path="/api/experimental/session/import",
|
|
867
|
+
body={"info": info, "messages": messages, "location": self._location(location)},
|
|
868
|
+
extra_headers=extra_headers,
|
|
869
|
+
extra_query=extra_query,
|
|
870
|
+
extra_body=extra_body,
|
|
871
|
+
timeout=timeout,
|
|
872
|
+
),
|
|
873
|
+
response_type="SessionInfo",
|
|
874
|
+
unwrap=True,
|
|
875
|
+
),
|
|
876
|
+
)
|
|
877
|
+
|
|
878
|
+
def export(
|
|
879
|
+
self,
|
|
880
|
+
session_id: SessionID,
|
|
881
|
+
*,
|
|
882
|
+
sanitize: bool | NotGiven | None = NOT_GIVEN,
|
|
883
|
+
extra_headers: Headers | None = None,
|
|
884
|
+
extra_query: Query | None = None,
|
|
885
|
+
extra_body: Body | None = None,
|
|
886
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
887
|
+
) -> SessionTransferData:
|
|
888
|
+
"""Export session.
|
|
889
|
+
|
|
890
|
+
Export a complete projected session transcript.
|
|
891
|
+
|
|
892
|
+
This endpoint is experimental in OpenCode and may change without notice.
|
|
893
|
+
|
|
894
|
+
Raises:
|
|
895
|
+
InvalidRequestError: The server answered 400.
|
|
896
|
+
UnauthorizedError: The server answered 401.
|
|
897
|
+
SessionNotFoundError: The server answered 404.
|
|
898
|
+
UnknownError: The server answered 500.
|
|
899
|
+
|
|
900
|
+
``GET /api/experimental/session/:sessionID/export``
|
|
901
|
+
"""
|
|
902
|
+
return cast(
|
|
903
|
+
"SessionTransferData",
|
|
904
|
+
self._client.request(
|
|
905
|
+
RequestOptions(
|
|
906
|
+
method="GET",
|
|
907
|
+
path=f"/api/experimental/session/{encode_path_segment(session_id)}/export",
|
|
908
|
+
query={"sanitize": sanitize},
|
|
909
|
+
extra_headers=extra_headers,
|
|
910
|
+
extra_query=extra_query,
|
|
911
|
+
extra_body=extra_body,
|
|
912
|
+
timeout=timeout,
|
|
913
|
+
),
|
|
914
|
+
response_type="SessionTransferData",
|
|
915
|
+
unwrap=True,
|
|
916
|
+
),
|
|
917
|
+
)
|
|
918
|
+
|
|
919
|
+
def active(
|
|
920
|
+
self,
|
|
921
|
+
*,
|
|
922
|
+
extra_headers: Headers | None = None,
|
|
923
|
+
extra_query: Query | None = None,
|
|
924
|
+
extra_body: Body | None = None,
|
|
925
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
926
|
+
) -> builtins.dict[str, Any]:
|
|
927
|
+
"""List active sessions.
|
|
928
|
+
|
|
929
|
+
Retrieve foreground Session drains currently owned by this OpenCode process. Sessions absent from the result are inactive.
|
|
930
|
+
|
|
931
|
+
Raises:
|
|
932
|
+
InvalidRequestError: The server answered 400.
|
|
933
|
+
UnauthorizedError: The server answered 401.
|
|
934
|
+
|
|
935
|
+
``GET /api/session/active``
|
|
936
|
+
"""
|
|
937
|
+
return cast(
|
|
938
|
+
"builtins.dict[str, Any]",
|
|
939
|
+
self._client.request(
|
|
940
|
+
RequestOptions(
|
|
941
|
+
method="GET",
|
|
942
|
+
path="/api/session/active",
|
|
943
|
+
extra_headers=extra_headers,
|
|
944
|
+
extra_query=extra_query,
|
|
945
|
+
extra_body=extra_body,
|
|
946
|
+
timeout=timeout,
|
|
947
|
+
),
|
|
948
|
+
response_type="builtins.dict[str, Any]",
|
|
949
|
+
unwrap=True,
|
|
950
|
+
),
|
|
951
|
+
)
|
|
952
|
+
|
|
953
|
+
def get(
|
|
954
|
+
self,
|
|
955
|
+
session_id: SessionID,
|
|
956
|
+
*,
|
|
957
|
+
extra_headers: Headers | None = None,
|
|
958
|
+
extra_query: Query | None = None,
|
|
959
|
+
extra_body: Body | None = None,
|
|
960
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
961
|
+
) -> SessionInfo:
|
|
962
|
+
"""Get session.
|
|
963
|
+
|
|
964
|
+
Retrieve a session by ID.
|
|
965
|
+
|
|
966
|
+
Raises:
|
|
967
|
+
InvalidRequestError: The server answered 400.
|
|
968
|
+
UnauthorizedError: The server answered 401.
|
|
969
|
+
SessionNotFoundError: The server answered 404.
|
|
970
|
+
|
|
971
|
+
``GET /api/session/:sessionID``
|
|
972
|
+
"""
|
|
973
|
+
return cast(
|
|
974
|
+
"SessionInfo",
|
|
975
|
+
self._client.request(
|
|
976
|
+
RequestOptions(
|
|
977
|
+
method="GET",
|
|
978
|
+
path=f"/api/session/{encode_path_segment(session_id)}",
|
|
979
|
+
extra_headers=extra_headers,
|
|
980
|
+
extra_query=extra_query,
|
|
981
|
+
extra_body=extra_body,
|
|
982
|
+
timeout=timeout,
|
|
983
|
+
),
|
|
984
|
+
response_type="SessionInfo",
|
|
985
|
+
unwrap=True,
|
|
986
|
+
),
|
|
987
|
+
)
|
|
988
|
+
|
|
989
|
+
def remove(
|
|
990
|
+
self,
|
|
991
|
+
session_id: SessionID,
|
|
992
|
+
*,
|
|
993
|
+
extra_headers: Headers | None = None,
|
|
994
|
+
extra_query: Query | None = None,
|
|
995
|
+
extra_body: Body | None = None,
|
|
996
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
997
|
+
) -> None:
|
|
998
|
+
"""Delete session.
|
|
999
|
+
|
|
1000
|
+
Delete a session and its child sessions.
|
|
1001
|
+
|
|
1002
|
+
Raises:
|
|
1003
|
+
InvalidRequestError: The server answered 400.
|
|
1004
|
+
UnauthorizedError: The server answered 401.
|
|
1005
|
+
SessionNotFoundError: The server answered 404.
|
|
1006
|
+
|
|
1007
|
+
``DELETE /api/session/:sessionID``
|
|
1008
|
+
"""
|
|
1009
|
+
self._client.request(
|
|
1010
|
+
RequestOptions(
|
|
1011
|
+
method="DELETE",
|
|
1012
|
+
path=f"/api/session/{encode_path_segment(session_id)}",
|
|
1013
|
+
extra_headers=extra_headers,
|
|
1014
|
+
extra_query=extra_query,
|
|
1015
|
+
extra_body=extra_body,
|
|
1016
|
+
timeout=timeout,
|
|
1017
|
+
),
|
|
1018
|
+
kind="void",
|
|
1019
|
+
)
|
|
1020
|
+
|
|
1021
|
+
def fork(
|
|
1022
|
+
self,
|
|
1023
|
+
session_id: SessionID,
|
|
1024
|
+
*,
|
|
1025
|
+
before: SessionMessageID | NotGiven | None = NOT_GIVEN,
|
|
1026
|
+
extra_headers: Headers | None = None,
|
|
1027
|
+
extra_query: Query | None = None,
|
|
1028
|
+
extra_body: Body | None = None,
|
|
1029
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
1030
|
+
) -> SessionInfo:
|
|
1031
|
+
"""Fork session.
|
|
1032
|
+
|
|
1033
|
+
Create a child session by copying projected history before a message. Omit before to copy the full history.
|
|
1034
|
+
|
|
1035
|
+
Raises:
|
|
1036
|
+
InvalidRequestError: The server answered 400.
|
|
1037
|
+
UnauthorizedError: The server answered 401.
|
|
1038
|
+
SessionNotFoundError: The server answered 404.
|
|
1039
|
+
MessageNotFoundError: The server answered 404.
|
|
1040
|
+
LocationNotFoundError: The server answered 404.
|
|
1041
|
+
|
|
1042
|
+
``POST /api/session/:sessionID/fork``
|
|
1043
|
+
"""
|
|
1044
|
+
return cast(
|
|
1045
|
+
"SessionInfo",
|
|
1046
|
+
self._client.request(
|
|
1047
|
+
RequestOptions(
|
|
1048
|
+
method="POST",
|
|
1049
|
+
path=f"/api/session/{encode_path_segment(session_id)}/fork",
|
|
1050
|
+
body={"before": before},
|
|
1051
|
+
extra_headers=extra_headers,
|
|
1052
|
+
extra_query=extra_query,
|
|
1053
|
+
extra_body=extra_body,
|
|
1054
|
+
timeout=timeout,
|
|
1055
|
+
),
|
|
1056
|
+
response_type="SessionInfo",
|
|
1057
|
+
unwrap=True,
|
|
1058
|
+
),
|
|
1059
|
+
)
|
|
1060
|
+
|
|
1061
|
+
def switch_agent(
|
|
1062
|
+
self,
|
|
1063
|
+
session_id: SessionID,
|
|
1064
|
+
*,
|
|
1065
|
+
agent: AgentID,
|
|
1066
|
+
extra_headers: Headers | None = None,
|
|
1067
|
+
extra_query: Query | None = None,
|
|
1068
|
+
extra_body: Body | None = None,
|
|
1069
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
1070
|
+
) -> None:
|
|
1071
|
+
"""Switch session agent.
|
|
1072
|
+
|
|
1073
|
+
Switch the agent used by subsequent provider turns.
|
|
1074
|
+
|
|
1075
|
+
Raises:
|
|
1076
|
+
InvalidRequestError: The server answered 400.
|
|
1077
|
+
UnauthorizedError: The server answered 401.
|
|
1078
|
+
SessionNotFoundError: The server answered 404.
|
|
1079
|
+
LocationNotFoundError: The server answered 404.
|
|
1080
|
+
|
|
1081
|
+
``POST /api/session/:sessionID/agent``
|
|
1082
|
+
"""
|
|
1083
|
+
self._client.request(
|
|
1084
|
+
RequestOptions(
|
|
1085
|
+
method="POST",
|
|
1086
|
+
path=f"/api/session/{encode_path_segment(session_id)}/agent",
|
|
1087
|
+
body={"agent": agent},
|
|
1088
|
+
extra_headers=extra_headers,
|
|
1089
|
+
extra_query=extra_query,
|
|
1090
|
+
extra_body=extra_body,
|
|
1091
|
+
timeout=timeout,
|
|
1092
|
+
),
|
|
1093
|
+
kind="void",
|
|
1094
|
+
)
|
|
1095
|
+
|
|
1096
|
+
def switch_model(
|
|
1097
|
+
self,
|
|
1098
|
+
session_id: SessionID,
|
|
1099
|
+
*,
|
|
1100
|
+
model: ModelRef,
|
|
1101
|
+
extra_headers: Headers | None = None,
|
|
1102
|
+
extra_query: Query | None = None,
|
|
1103
|
+
extra_body: Body | None = None,
|
|
1104
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
1105
|
+
) -> None:
|
|
1106
|
+
"""Switch session model.
|
|
1107
|
+
|
|
1108
|
+
Switch the model used by subsequent provider turns.
|
|
1109
|
+
|
|
1110
|
+
Raises:
|
|
1111
|
+
InvalidRequestError: The server answered 400.
|
|
1112
|
+
UnauthorizedError: The server answered 401.
|
|
1113
|
+
SessionNotFoundError: The server answered 404.
|
|
1114
|
+
LocationNotFoundError: The server answered 404.
|
|
1115
|
+
|
|
1116
|
+
``POST /api/session/:sessionID/model``
|
|
1117
|
+
"""
|
|
1118
|
+
self._client.request(
|
|
1119
|
+
RequestOptions(
|
|
1120
|
+
method="POST",
|
|
1121
|
+
path=f"/api/session/{encode_path_segment(session_id)}/model",
|
|
1122
|
+
body={"model": model},
|
|
1123
|
+
extra_headers=extra_headers,
|
|
1124
|
+
extra_query=extra_query,
|
|
1125
|
+
extra_body=extra_body,
|
|
1126
|
+
timeout=timeout,
|
|
1127
|
+
),
|
|
1128
|
+
kind="void",
|
|
1129
|
+
)
|
|
1130
|
+
|
|
1131
|
+
def update(
|
|
1132
|
+
self,
|
|
1133
|
+
session_id: SessionID,
|
|
1134
|
+
*,
|
|
1135
|
+
title: str | NotGiven | None = NOT_GIVEN,
|
|
1136
|
+
metadata: SessionMetadata | NotGiven | None = NOT_GIVEN,
|
|
1137
|
+
permissions: PermissionRuleset | NotGiven | None = NOT_GIVEN,
|
|
1138
|
+
archived: bool | NotGiven | None = NOT_GIVEN,
|
|
1139
|
+
extra_headers: Headers | None = None,
|
|
1140
|
+
extra_query: Query | None = None,
|
|
1141
|
+
extra_body: Body | None = None,
|
|
1142
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
1143
|
+
) -> None:
|
|
1144
|
+
"""Update session.
|
|
1145
|
+
|
|
1146
|
+
Update mutable session properties.
|
|
1147
|
+
|
|
1148
|
+
Args:
|
|
1149
|
+
archived: Archive the session with true or restore it with false. Repeating the current state is a no-op.
|
|
1150
|
+
|
|
1151
|
+
Raises:
|
|
1152
|
+
InvalidRequestError: The server answered 400.
|
|
1153
|
+
UnauthorizedError: The server answered 401.
|
|
1154
|
+
SessionNotFoundError: The server answered 404.
|
|
1155
|
+
LocationNotFoundError: The server answered 404.
|
|
1156
|
+
|
|
1157
|
+
``PATCH /api/session/:sessionID``
|
|
1158
|
+
"""
|
|
1159
|
+
self._client.request(
|
|
1160
|
+
RequestOptions(
|
|
1161
|
+
method="PATCH",
|
|
1162
|
+
path=f"/api/session/{encode_path_segment(session_id)}",
|
|
1163
|
+
body={"title": title, "metadata": metadata, "permissions": permissions, "archived": archived},
|
|
1164
|
+
extra_headers=extra_headers,
|
|
1165
|
+
extra_query=extra_query,
|
|
1166
|
+
extra_body=extra_body,
|
|
1167
|
+
timeout=timeout,
|
|
1168
|
+
),
|
|
1169
|
+
kind="void",
|
|
1170
|
+
)
|
|
1171
|
+
|
|
1172
|
+
def move(
|
|
1173
|
+
self,
|
|
1174
|
+
session_id: SessionID,
|
|
1175
|
+
*,
|
|
1176
|
+
directory: AbsolutePath,
|
|
1177
|
+
delivery: SessionInboxDelivery | NotGiven | None = NOT_GIVEN,
|
|
1178
|
+
extra_headers: Headers | None = None,
|
|
1179
|
+
extra_query: Query | None = None,
|
|
1180
|
+
extra_body: Body | None = None,
|
|
1181
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
1182
|
+
) -> None:
|
|
1183
|
+
"""Move session.
|
|
1184
|
+
|
|
1185
|
+
Move a session to another project directory at the requested delivery boundary.
|
|
1186
|
+
|
|
1187
|
+
Raises:
|
|
1188
|
+
InvalidRequestError: The server answered 400.
|
|
1189
|
+
UnauthorizedError: The server answered 401.
|
|
1190
|
+
SessionNotFoundError: The server answered 404.
|
|
1191
|
+
|
|
1192
|
+
``POST /api/session/:sessionID/move``
|
|
1193
|
+
"""
|
|
1194
|
+
self._client.request(
|
|
1195
|
+
RequestOptions(
|
|
1196
|
+
method="POST",
|
|
1197
|
+
path=f"/api/session/{encode_path_segment(session_id)}/move",
|
|
1198
|
+
body={"directory": directory, "delivery": delivery},
|
|
1199
|
+
extra_headers=extra_headers,
|
|
1200
|
+
extra_query=extra_query,
|
|
1201
|
+
extra_body=extra_body,
|
|
1202
|
+
timeout=timeout,
|
|
1203
|
+
),
|
|
1204
|
+
kind="void",
|
|
1205
|
+
)
|
|
1206
|
+
|
|
1207
|
+
def prompt(
|
|
1208
|
+
self,
|
|
1209
|
+
session_id: SessionID,
|
|
1210
|
+
*,
|
|
1211
|
+
text: str,
|
|
1212
|
+
id: SessionMessageID | NotGiven | None = NOT_GIVEN,
|
|
1213
|
+
files: Sequence[PromptInputFileAttachment] | NotGiven = NOT_GIVEN,
|
|
1214
|
+
agents: Sequence[PromptAgentAttachment] | NotGiven = NOT_GIVEN,
|
|
1215
|
+
skills: Sequence[PromptInputSkillAttachment] | NotGiven = NOT_GIVEN,
|
|
1216
|
+
metadata: Mapping[str, Any] | NotGiven = NOT_GIVEN,
|
|
1217
|
+
delivery: SessionInboxDelivery | NotGiven | None = NOT_GIVEN,
|
|
1218
|
+
resume: bool | NotGiven | None = NOT_GIVEN,
|
|
1219
|
+
extra_headers: Headers | None = None,
|
|
1220
|
+
extra_query: Query | None = None,
|
|
1221
|
+
extra_body: Body | None = None,
|
|
1222
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
1223
|
+
) -> SessionInboxUser:
|
|
1224
|
+
"""Send message.
|
|
1225
|
+
|
|
1226
|
+
Durably admit one session input and schedule agent-loop execution unless resume is false.
|
|
1227
|
+
|
|
1228
|
+
Raises:
|
|
1229
|
+
InvalidRequestError: The server answered 400.
|
|
1230
|
+
UnauthorizedError: The server answered 401.
|
|
1231
|
+
SessionNotFoundError: The server answered 404.
|
|
1232
|
+
LocationNotFoundError: The server answered 404.
|
|
1233
|
+
ConflictError: The server answered 409.
|
|
1234
|
+
|
|
1235
|
+
``POST /api/session/:sessionID/prompt``
|
|
1236
|
+
"""
|
|
1237
|
+
return cast(
|
|
1238
|
+
"SessionInboxUser",
|
|
1239
|
+
self._client.request(
|
|
1240
|
+
RequestOptions(
|
|
1241
|
+
method="POST",
|
|
1242
|
+
path=f"/api/session/{encode_path_segment(session_id)}/prompt",
|
|
1243
|
+
body={
|
|
1244
|
+
"id": id,
|
|
1245
|
+
"text": text,
|
|
1246
|
+
"files": files,
|
|
1247
|
+
"agents": agents,
|
|
1248
|
+
"skills": skills,
|
|
1249
|
+
"metadata": metadata,
|
|
1250
|
+
"delivery": delivery,
|
|
1251
|
+
"resume": resume,
|
|
1252
|
+
},
|
|
1253
|
+
extra_headers=extra_headers,
|
|
1254
|
+
extra_query=extra_query,
|
|
1255
|
+
extra_body=extra_body,
|
|
1256
|
+
timeout=timeout,
|
|
1257
|
+
),
|
|
1258
|
+
response_type="SessionInboxUser",
|
|
1259
|
+
unwrap=True,
|
|
1260
|
+
),
|
|
1261
|
+
)
|
|
1262
|
+
|
|
1263
|
+
def command(
|
|
1264
|
+
self,
|
|
1265
|
+
session_id: SessionID,
|
|
1266
|
+
*,
|
|
1267
|
+
name: str,
|
|
1268
|
+
text: str,
|
|
1269
|
+
files: Sequence[PromptInputFileAttachment] | NotGiven = NOT_GIVEN,
|
|
1270
|
+
agents: Sequence[PromptAgentAttachment] | NotGiven = NOT_GIVEN,
|
|
1271
|
+
skills: Sequence[PromptInputSkillAttachment] | NotGiven = NOT_GIVEN,
|
|
1272
|
+
delivery: SessionInboxDelivery | NotGiven | None = NOT_GIVEN,
|
|
1273
|
+
extra_headers: Headers | None = None,
|
|
1274
|
+
extra_query: Query | None = None,
|
|
1275
|
+
extra_body: Body | None = None,
|
|
1276
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
1277
|
+
) -> None:
|
|
1278
|
+
"""Run command.
|
|
1279
|
+
|
|
1280
|
+
Execute a slash command callback immediately.
|
|
1281
|
+
|
|
1282
|
+
Raises:
|
|
1283
|
+
InvalidRequestError: The server answered 400.
|
|
1284
|
+
UnauthorizedError: The server answered 401.
|
|
1285
|
+
SessionNotFoundError: The server answered 404.
|
|
1286
|
+
CommandNotFoundError: The server answered 404.
|
|
1287
|
+
LocationNotFoundError: The server answered 404.
|
|
1288
|
+
CommandExecutionError: The server answered 500.
|
|
1289
|
+
|
|
1290
|
+
``POST /api/session/:sessionID/command``
|
|
1291
|
+
"""
|
|
1292
|
+
self._client.request(
|
|
1293
|
+
RequestOptions(
|
|
1294
|
+
method="POST",
|
|
1295
|
+
path=f"/api/session/{encode_path_segment(session_id)}/command",
|
|
1296
|
+
body={
|
|
1297
|
+
"name": name,
|
|
1298
|
+
"text": text,
|
|
1299
|
+
"files": files,
|
|
1300
|
+
"agents": agents,
|
|
1301
|
+
"skills": skills,
|
|
1302
|
+
"delivery": delivery,
|
|
1303
|
+
},
|
|
1304
|
+
extra_headers=extra_headers,
|
|
1305
|
+
extra_query=extra_query,
|
|
1306
|
+
extra_body=extra_body,
|
|
1307
|
+
timeout=timeout,
|
|
1308
|
+
),
|
|
1309
|
+
kind="void",
|
|
1310
|
+
)
|
|
1311
|
+
|
|
1312
|
+
def skill(
|
|
1313
|
+
self,
|
|
1314
|
+
session_id: SessionID,
|
|
1315
|
+
*,
|
|
1316
|
+
id: SkillID,
|
|
1317
|
+
resume: bool | NotGiven | None = NOT_GIVEN,
|
|
1318
|
+
extra_headers: Headers | None = None,
|
|
1319
|
+
extra_query: Query | None = None,
|
|
1320
|
+
extra_body: Body | None = None,
|
|
1321
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
1322
|
+
) -> None:
|
|
1323
|
+
"""Activate skill.
|
|
1324
|
+
|
|
1325
|
+
Activate a skill for a session by appending a skill message and resuming execution.
|
|
1326
|
+
|
|
1327
|
+
This endpoint is experimental in OpenCode and may change without notice.
|
|
1328
|
+
|
|
1329
|
+
Raises:
|
|
1330
|
+
InvalidRequestError: The server answered 400.
|
|
1331
|
+
UnauthorizedError: The server answered 401.
|
|
1332
|
+
SessionNotFoundError: The server answered 404.
|
|
1333
|
+
SkillNotFoundError: The server answered 404.
|
|
1334
|
+
LocationNotFoundError: The server answered 404.
|
|
1335
|
+
|
|
1336
|
+
``POST /api/experimental/session/:sessionID/skill``
|
|
1337
|
+
"""
|
|
1338
|
+
self._client.request(
|
|
1339
|
+
RequestOptions(
|
|
1340
|
+
method="POST",
|
|
1341
|
+
path=f"/api/experimental/session/{encode_path_segment(session_id)}/skill",
|
|
1342
|
+
body={"id": id, "resume": resume},
|
|
1343
|
+
extra_headers=extra_headers,
|
|
1344
|
+
extra_query=extra_query,
|
|
1345
|
+
extra_body=extra_body,
|
|
1346
|
+
timeout=timeout,
|
|
1347
|
+
),
|
|
1348
|
+
kind="void",
|
|
1349
|
+
)
|
|
1350
|
+
|
|
1351
|
+
def synthetic(
|
|
1352
|
+
self,
|
|
1353
|
+
session_id: SessionID,
|
|
1354
|
+
*,
|
|
1355
|
+
text: str,
|
|
1356
|
+
id: SessionMessageID | NotGiven | None = NOT_GIVEN,
|
|
1357
|
+
description: str | NotGiven | None = NOT_GIVEN,
|
|
1358
|
+
metadata: Mapping[str, Any] | NotGiven = NOT_GIVEN,
|
|
1359
|
+
delivery: SessionInboxDelivery | NotGiven | None = NOT_GIVEN,
|
|
1360
|
+
resume: bool | NotGiven | None = NOT_GIVEN,
|
|
1361
|
+
extra_headers: Headers | None = None,
|
|
1362
|
+
extra_query: Query | None = None,
|
|
1363
|
+
extra_body: Body | None = None,
|
|
1364
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
1365
|
+
) -> SessionInboxSynthetic:
|
|
1366
|
+
"""Add synthetic message.
|
|
1367
|
+
|
|
1368
|
+
Durably admit synthetic session input and schedule execution unless resume is false.
|
|
1369
|
+
|
|
1370
|
+
Raises:
|
|
1371
|
+
InvalidRequestError: The server answered 400.
|
|
1372
|
+
UnauthorizedError: The server answered 401.
|
|
1373
|
+
SessionNotFoundError: The server answered 404.
|
|
1374
|
+
LocationNotFoundError: The server answered 404.
|
|
1375
|
+
ConflictError: The server answered 409.
|
|
1376
|
+
|
|
1377
|
+
``POST /api/session/:sessionID/synthetic``
|
|
1378
|
+
"""
|
|
1379
|
+
return cast(
|
|
1380
|
+
"SessionInboxSynthetic",
|
|
1381
|
+
self._client.request(
|
|
1382
|
+
RequestOptions(
|
|
1383
|
+
method="POST",
|
|
1384
|
+
path=f"/api/session/{encode_path_segment(session_id)}/synthetic",
|
|
1385
|
+
body={
|
|
1386
|
+
"id": id,
|
|
1387
|
+
"text": text,
|
|
1388
|
+
"description": description,
|
|
1389
|
+
"metadata": metadata,
|
|
1390
|
+
"delivery": delivery,
|
|
1391
|
+
"resume": resume,
|
|
1392
|
+
},
|
|
1393
|
+
extra_headers=extra_headers,
|
|
1394
|
+
extra_query=extra_query,
|
|
1395
|
+
extra_body=extra_body,
|
|
1396
|
+
timeout=timeout,
|
|
1397
|
+
),
|
|
1398
|
+
response_type="SessionInboxSynthetic",
|
|
1399
|
+
unwrap=True,
|
|
1400
|
+
),
|
|
1401
|
+
)
|
|
1402
|
+
|
|
1403
|
+
def shell(
|
|
1404
|
+
self,
|
|
1405
|
+
session_id: SessionID,
|
|
1406
|
+
*,
|
|
1407
|
+
command: str,
|
|
1408
|
+
id: SessionMessageID | NotGiven | None = NOT_GIVEN,
|
|
1409
|
+
extra_headers: Headers | None = None,
|
|
1410
|
+
extra_query: Query | None = None,
|
|
1411
|
+
extra_body: Body | None = None,
|
|
1412
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
1413
|
+
) -> None:
|
|
1414
|
+
"""Run shell command.
|
|
1415
|
+
|
|
1416
|
+
Execute one shell command in the session's working directory. Emits a shell.started event before execution and a shell.ended event with the merged output after.
|
|
1417
|
+
|
|
1418
|
+
Raises:
|
|
1419
|
+
InvalidRequestError: The server answered 400.
|
|
1420
|
+
UnauthorizedError: The server answered 401.
|
|
1421
|
+
SessionNotFoundError: The server answered 404.
|
|
1422
|
+
LocationNotFoundError: The server answered 404.
|
|
1423
|
+
|
|
1424
|
+
``POST /api/session/:sessionID/shell``
|
|
1425
|
+
"""
|
|
1426
|
+
self._client.request(
|
|
1427
|
+
RequestOptions(
|
|
1428
|
+
method="POST",
|
|
1429
|
+
path=f"/api/session/{encode_path_segment(session_id)}/shell",
|
|
1430
|
+
body={"id": id, "command": command},
|
|
1431
|
+
extra_headers=extra_headers,
|
|
1432
|
+
extra_query=extra_query,
|
|
1433
|
+
extra_body=extra_body,
|
|
1434
|
+
timeout=timeout,
|
|
1435
|
+
),
|
|
1436
|
+
kind="void",
|
|
1437
|
+
)
|
|
1438
|
+
|
|
1439
|
+
def compact(
|
|
1440
|
+
self,
|
|
1441
|
+
session_id: SessionID,
|
|
1442
|
+
*,
|
|
1443
|
+
id: SessionMessageID | NotGiven | None = NOT_GIVEN,
|
|
1444
|
+
delivery: SessionInboxDelivery | NotGiven | None = NOT_GIVEN,
|
|
1445
|
+
extra_headers: Headers | None = None,
|
|
1446
|
+
extra_query: Query | None = None,
|
|
1447
|
+
extra_body: Body | None = None,
|
|
1448
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
1449
|
+
) -> SessionInboxCompaction:
|
|
1450
|
+
"""Compact session.
|
|
1451
|
+
|
|
1452
|
+
Durably admit a session compaction request. Steers by default: it runs at the next step boundary instead of waiting behind queued prompts.
|
|
1453
|
+
|
|
1454
|
+
Raises:
|
|
1455
|
+
InvalidRequestError: The server answered 400.
|
|
1456
|
+
UnauthorizedError: The server answered 401.
|
|
1457
|
+
SessionNotFoundError: The server answered 404.
|
|
1458
|
+
LocationNotFoundError: The server answered 404.
|
|
1459
|
+
ConflictError: The server answered 409.
|
|
1460
|
+
|
|
1461
|
+
``POST /api/session/:sessionID/compact``
|
|
1462
|
+
"""
|
|
1463
|
+
return cast(
|
|
1464
|
+
"SessionInboxCompaction",
|
|
1465
|
+
self._client.request(
|
|
1466
|
+
RequestOptions(
|
|
1467
|
+
method="POST",
|
|
1468
|
+
path=f"/api/session/{encode_path_segment(session_id)}/compact",
|
|
1469
|
+
body={"id": id, "delivery": delivery},
|
|
1470
|
+
extra_headers=extra_headers,
|
|
1471
|
+
extra_query=extra_query,
|
|
1472
|
+
extra_body=extra_body,
|
|
1473
|
+
timeout=timeout,
|
|
1474
|
+
),
|
|
1475
|
+
response_type="SessionInboxCompaction",
|
|
1476
|
+
unwrap=True,
|
|
1477
|
+
),
|
|
1478
|
+
)
|
|
1479
|
+
|
|
1480
|
+
def wait(
|
|
1481
|
+
self,
|
|
1482
|
+
session_id: SessionID,
|
|
1483
|
+
*,
|
|
1484
|
+
extra_headers: Headers | None = None,
|
|
1485
|
+
extra_query: Query | None = None,
|
|
1486
|
+
extra_body: Body | None = None,
|
|
1487
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
1488
|
+
) -> None:
|
|
1489
|
+
"""Wait for session.
|
|
1490
|
+
|
|
1491
|
+
Wait for a session agent loop to become idle.
|
|
1492
|
+
|
|
1493
|
+
This endpoint is experimental in OpenCode and may change without notice.
|
|
1494
|
+
|
|
1495
|
+
Raises:
|
|
1496
|
+
InvalidRequestError: The server answered 400.
|
|
1497
|
+
UnauthorizedError: The server answered 401.
|
|
1498
|
+
SessionNotFoundError: The server answered 404.
|
|
1499
|
+
LocationNotFoundError: The server answered 404.
|
|
1500
|
+
ServiceUnavailableError: The server answered 503.
|
|
1501
|
+
|
|
1502
|
+
``POST /api/experimental/session/:sessionID/wait``
|
|
1503
|
+
"""
|
|
1504
|
+
self._client.request(
|
|
1505
|
+
RequestOptions(
|
|
1506
|
+
method="POST",
|
|
1507
|
+
path=f"/api/experimental/session/{encode_path_segment(session_id)}/wait",
|
|
1508
|
+
extra_headers=extra_headers,
|
|
1509
|
+
extra_query=extra_query,
|
|
1510
|
+
extra_body=extra_body,
|
|
1511
|
+
timeout=timeout,
|
|
1512
|
+
),
|
|
1513
|
+
kind="void",
|
|
1514
|
+
)
|
|
1515
|
+
|
|
1516
|
+
def context(
|
|
1517
|
+
self,
|
|
1518
|
+
session_id: SessionID,
|
|
1519
|
+
*,
|
|
1520
|
+
extra_headers: Headers | None = None,
|
|
1521
|
+
extra_query: Query | None = None,
|
|
1522
|
+
extra_body: Body | None = None,
|
|
1523
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
1524
|
+
) -> builtins.list[SessionMessageInfo]:
|
|
1525
|
+
"""Get session context.
|
|
1526
|
+
|
|
1527
|
+
Retrieve the active context messages for a session (all messages after the last compaction).
|
|
1528
|
+
|
|
1529
|
+
Raises:
|
|
1530
|
+
InvalidRequestError: The server answered 400.
|
|
1531
|
+
UnauthorizedError: The server answered 401.
|
|
1532
|
+
SessionNotFoundError: The server answered 404.
|
|
1533
|
+
UnknownError: The server answered 500.
|
|
1534
|
+
|
|
1535
|
+
``GET /api/session/:sessionID/context``
|
|
1536
|
+
"""
|
|
1537
|
+
return cast(
|
|
1538
|
+
"builtins.list[SessionMessageInfo]",
|
|
1539
|
+
self._client.request(
|
|
1540
|
+
RequestOptions(
|
|
1541
|
+
method="GET",
|
|
1542
|
+
path=f"/api/session/{encode_path_segment(session_id)}/context",
|
|
1543
|
+
extra_headers=extra_headers,
|
|
1544
|
+
extra_query=extra_query,
|
|
1545
|
+
extra_body=extra_body,
|
|
1546
|
+
timeout=timeout,
|
|
1547
|
+
),
|
|
1548
|
+
response_type="builtins.list[SessionMessageInfo]",
|
|
1549
|
+
unwrap=True,
|
|
1550
|
+
),
|
|
1551
|
+
)
|
|
1552
|
+
|
|
1553
|
+
def diff(
|
|
1554
|
+
self,
|
|
1555
|
+
session_id: SessionID,
|
|
1556
|
+
*,
|
|
1557
|
+
from_: SessionMessageID | NotGiven | None = NOT_GIVEN,
|
|
1558
|
+
to: SessionMessageID | NotGiven | None = NOT_GIVEN,
|
|
1559
|
+
context: int | NotGiven | None = NOT_GIVEN,
|
|
1560
|
+
extra_headers: Headers | None = None,
|
|
1561
|
+
extra_query: Query | None = None,
|
|
1562
|
+
extra_body: Body | None = None,
|
|
1563
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
1564
|
+
) -> builtins.list[FileDiffInfo]:
|
|
1565
|
+
"""Diff session turns.
|
|
1566
|
+
|
|
1567
|
+
Structured per-file diffs of the files a turn changed. A turn runs from the first prompt after the session was last idle until its next idle marker, so prompts steered in while it was busy belong to the same turn; `to` extends the range through a later turn. Compares the range's first recorded snapshot with its last; a step still running in the active session compares against the working copy. Ranges that span a location change are rejected. In sessions without any idle marker, a prompt's turn spans until the next user message.
|
|
1568
|
+
|
|
1569
|
+
Args:
|
|
1570
|
+
from_: User message whose turn to diff. Defaults to the turn of the newest user message.
|
|
1571
|
+
to: Later user message whose turn ends the range. Defaults to the turn of `from` alone.
|
|
1572
|
+
context: Unchanged lines around each hunk. Omit for full-file patches.
|
|
1573
|
+
|
|
1574
|
+
Raises:
|
|
1575
|
+
InvalidRequestError: The server answered 400.
|
|
1576
|
+
UnauthorizedError: The server answered 401.
|
|
1577
|
+
MessageNotFoundError: The server answered 404.
|
|
1578
|
+
SessionNotFoundError: The server answered 404.
|
|
1579
|
+
LocationNotFoundError: The server answered 404.
|
|
1580
|
+
UnknownError: The server answered 500.
|
|
1581
|
+
|
|
1582
|
+
``GET /api/session/:sessionID/diff``
|
|
1583
|
+
"""
|
|
1584
|
+
return cast(
|
|
1585
|
+
"builtins.list[FileDiffInfo]",
|
|
1586
|
+
self._client.request(
|
|
1587
|
+
RequestOptions(
|
|
1588
|
+
method="GET",
|
|
1589
|
+
path=f"/api/session/{encode_path_segment(session_id)}/diff",
|
|
1590
|
+
query={"from": from_, "to": to, "context": context},
|
|
1591
|
+
extra_headers=extra_headers,
|
|
1592
|
+
extra_query=extra_query,
|
|
1593
|
+
extra_body=extra_body,
|
|
1594
|
+
timeout=timeout,
|
|
1595
|
+
),
|
|
1596
|
+
response_type="builtins.list[FileDiffInfo]",
|
|
1597
|
+
unwrap=True,
|
|
1598
|
+
),
|
|
1599
|
+
)
|
|
1600
|
+
|
|
1601
|
+
def generate(
|
|
1602
|
+
self,
|
|
1603
|
+
session_id: SessionID,
|
|
1604
|
+
*,
|
|
1605
|
+
prompt: str,
|
|
1606
|
+
extra_headers: Headers | None = None,
|
|
1607
|
+
extra_query: Query | None = None,
|
|
1608
|
+
extra_body: Body | None = None,
|
|
1609
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
1610
|
+
) -> SessionGenerateResponseData:
|
|
1611
|
+
"""Generate text from session context.
|
|
1612
|
+
|
|
1613
|
+
Generate transient text from the current session context without mutating session history.
|
|
1614
|
+
|
|
1615
|
+
Raises:
|
|
1616
|
+
InvalidRequestError: The server answered 400.
|
|
1617
|
+
UnauthorizedError: The server answered 401.
|
|
1618
|
+
SessionNotFoundError: The server answered 404.
|
|
1619
|
+
LocationNotFoundError: The server answered 404.
|
|
1620
|
+
ServiceUnavailableError: The server answered 503.
|
|
1621
|
+
|
|
1622
|
+
``POST /api/session/:sessionID/generate``
|
|
1623
|
+
"""
|
|
1624
|
+
return cast(
|
|
1625
|
+
"SessionGenerateResponseData",
|
|
1626
|
+
self._client.request(
|
|
1627
|
+
RequestOptions(
|
|
1628
|
+
method="POST",
|
|
1629
|
+
path=f"/api/session/{encode_path_segment(session_id)}/generate",
|
|
1630
|
+
body={"prompt": prompt},
|
|
1631
|
+
extra_headers=extra_headers,
|
|
1632
|
+
extra_query=extra_query,
|
|
1633
|
+
extra_body=extra_body,
|
|
1634
|
+
timeout=timeout,
|
|
1635
|
+
),
|
|
1636
|
+
response_type="SessionGenerateResponseData",
|
|
1637
|
+
unwrap=True,
|
|
1638
|
+
),
|
|
1639
|
+
)
|
|
1640
|
+
|
|
1641
|
+
def log(
|
|
1642
|
+
self,
|
|
1643
|
+
session_id: SessionID,
|
|
1644
|
+
*,
|
|
1645
|
+
after: EventSeq | NotGiven | None = NOT_GIVEN,
|
|
1646
|
+
follow: bool | NotGiven | None = NOT_GIVEN,
|
|
1647
|
+
extra_headers: Headers | None = None,
|
|
1648
|
+
extra_query: Query | None = None,
|
|
1649
|
+
extra_body: Body | None = None,
|
|
1650
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
1651
|
+
) -> Stream[SessionLogItem]:
|
|
1652
|
+
"""Read the session log.
|
|
1653
|
+
|
|
1654
|
+
Experimental durable session event log. Reads events after an exclusive aggregate sequence and continues with live events when follow=true.
|
|
1655
|
+
|
|
1656
|
+
This endpoint is experimental in OpenCode and may change without notice.
|
|
1657
|
+
|
|
1658
|
+
Raises:
|
|
1659
|
+
InvalidRequestError: The server answered 400.
|
|
1660
|
+
UnauthorizedError: The server answered 401.
|
|
1661
|
+
SessionNotFoundError: The server answered 404.
|
|
1662
|
+
|
|
1663
|
+
``GET /api/experimental/session/:sessionID/log``
|
|
1664
|
+
"""
|
|
1665
|
+
return self._client.stream(
|
|
1666
|
+
RequestOptions(
|
|
1667
|
+
method="GET",
|
|
1668
|
+
path=f"/api/experimental/session/{encode_path_segment(session_id)}/log",
|
|
1669
|
+
query={"after": after, "follow": follow},
|
|
1670
|
+
extra_headers=extra_headers,
|
|
1671
|
+
extra_query=extra_query,
|
|
1672
|
+
extra_body=extra_body,
|
|
1673
|
+
timeout=timeout,
|
|
1674
|
+
),
|
|
1675
|
+
item_type="SessionLogItem",
|
|
1676
|
+
)
|
|
1677
|
+
|
|
1678
|
+
def interrupt(
|
|
1679
|
+
self,
|
|
1680
|
+
session_id: SessionID,
|
|
1681
|
+
*,
|
|
1682
|
+
resume: bool | NotGiven | None = NOT_GIVEN,
|
|
1683
|
+
extra_headers: Headers | None = None,
|
|
1684
|
+
extra_query: Query | None = None,
|
|
1685
|
+
extra_body: Body | None = None,
|
|
1686
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
1687
|
+
) -> SessionInterruptResponse:
|
|
1688
|
+
"""Interrupt session execution.
|
|
1689
|
+
|
|
1690
|
+
Interrupt active execution owned by this OpenCode process. Returns interrupted=true when an active execution was interrupted and false for the idle no-op. When resume=true, execution resumes pending steering input and next-in-line control items (manual compaction, moves) while queued prompts remain parked.
|
|
1691
|
+
|
|
1692
|
+
Raises:
|
|
1693
|
+
InvalidRequestError: The server answered 400.
|
|
1694
|
+
UnauthorizedError: The server answered 401.
|
|
1695
|
+
SessionNotFoundError: The server answered 404.
|
|
1696
|
+
LocationNotFoundError: The server answered 404.
|
|
1697
|
+
|
|
1698
|
+
``POST /api/session/:sessionID/interrupt``
|
|
1699
|
+
"""
|
|
1700
|
+
return cast(
|
|
1701
|
+
"SessionInterruptResponse",
|
|
1702
|
+
self._client.request(
|
|
1703
|
+
RequestOptions(
|
|
1704
|
+
method="POST",
|
|
1705
|
+
path=f"/api/session/{encode_path_segment(session_id)}/interrupt",
|
|
1706
|
+
query={"resume": resume},
|
|
1707
|
+
extra_headers=extra_headers,
|
|
1708
|
+
extra_query=extra_query,
|
|
1709
|
+
extra_body=extra_body,
|
|
1710
|
+
timeout=timeout,
|
|
1711
|
+
),
|
|
1712
|
+
response_type="SessionInterruptResponse",
|
|
1713
|
+
),
|
|
1714
|
+
)
|
|
1715
|
+
|
|
1716
|
+
def background(
|
|
1717
|
+
self,
|
|
1718
|
+
session_id: SessionID,
|
|
1719
|
+
*,
|
|
1720
|
+
extra_headers: Headers | None = None,
|
|
1721
|
+
extra_query: Query | None = None,
|
|
1722
|
+
extra_body: Body | None = None,
|
|
1723
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
1724
|
+
) -> None:
|
|
1725
|
+
"""Background blocking session tools.
|
|
1726
|
+
|
|
1727
|
+
Move active foreground backgroundable tools for this session into background observation. Idle requests are a no-op.
|
|
1728
|
+
|
|
1729
|
+
Raises:
|
|
1730
|
+
InvalidRequestError: The server answered 400.
|
|
1731
|
+
UnauthorizedError: The server answered 401.
|
|
1732
|
+
SessionNotFoundError: The server answered 404.
|
|
1733
|
+
LocationNotFoundError: The server answered 404.
|
|
1734
|
+
|
|
1735
|
+
``POST /api/session/:sessionID/background``
|
|
1736
|
+
"""
|
|
1737
|
+
self._client.request(
|
|
1738
|
+
RequestOptions(
|
|
1739
|
+
method="POST",
|
|
1740
|
+
path=f"/api/session/{encode_path_segment(session_id)}/background",
|
|
1741
|
+
extra_headers=extra_headers,
|
|
1742
|
+
extra_query=extra_query,
|
|
1743
|
+
extra_body=extra_body,
|
|
1744
|
+
timeout=timeout,
|
|
1745
|
+
),
|
|
1746
|
+
kind="void",
|
|
1747
|
+
)
|
|
1748
|
+
|
|
1749
|
+
def environment(
|
|
1750
|
+
self,
|
|
1751
|
+
session_id: SessionID,
|
|
1752
|
+
*,
|
|
1753
|
+
variables: Mapping[str, str],
|
|
1754
|
+
extra_headers: Headers | None = None,
|
|
1755
|
+
extra_query: Query | None = None,
|
|
1756
|
+
extra_body: Body | None = None,
|
|
1757
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
1758
|
+
) -> None:
|
|
1759
|
+
"""Set session environment.
|
|
1760
|
+
|
|
1761
|
+
Replace the process environment used by local shell commands for this session.
|
|
1762
|
+
|
|
1763
|
+
Raises:
|
|
1764
|
+
InvalidRequestError: The server answered 400.
|
|
1765
|
+
UnauthorizedError: The server answered 401.
|
|
1766
|
+
SessionNotFoundError: The server answered 404.
|
|
1767
|
+
|
|
1768
|
+
``PUT /api/session/:sessionID/environment``
|
|
1769
|
+
"""
|
|
1770
|
+
self._client.request(
|
|
1771
|
+
RequestOptions(
|
|
1772
|
+
method="PUT",
|
|
1773
|
+
path=f"/api/session/{encode_path_segment(session_id)}/environment",
|
|
1774
|
+
body={"variables": variables},
|
|
1775
|
+
extra_headers=extra_headers,
|
|
1776
|
+
extra_query=extra_query,
|
|
1777
|
+
extra_body=extra_body,
|
|
1778
|
+
timeout=timeout,
|
|
1779
|
+
),
|
|
1780
|
+
kind="void",
|
|
1781
|
+
)
|
|
1782
|
+
|
|
1783
|
+
def view(
|
|
1784
|
+
self,
|
|
1785
|
+
session_id: SessionID,
|
|
1786
|
+
*,
|
|
1787
|
+
idle: float,
|
|
1788
|
+
extra_headers: Headers | None = None,
|
|
1789
|
+
extra_query: Query | None = None,
|
|
1790
|
+
extra_body: Body | None = None,
|
|
1791
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
1792
|
+
) -> None:
|
|
1793
|
+
"""View session.
|
|
1794
|
+
|
|
1795
|
+
Mark the idle transition observed by the viewer as viewed.
|
|
1796
|
+
|
|
1797
|
+
Raises:
|
|
1798
|
+
InvalidRequestError: The server answered 400.
|
|
1799
|
+
UnauthorizedError: The server answered 401.
|
|
1800
|
+
SessionNotFoundError: The server answered 404.
|
|
1801
|
+
|
|
1802
|
+
``POST /api/session/:sessionID/view``
|
|
1803
|
+
"""
|
|
1804
|
+
self._client.request(
|
|
1805
|
+
RequestOptions(
|
|
1806
|
+
method="POST",
|
|
1807
|
+
path=f"/api/session/{encode_path_segment(session_id)}/view",
|
|
1808
|
+
body={"idle": idle},
|
|
1809
|
+
extra_headers=extra_headers,
|
|
1810
|
+
extra_query=extra_query,
|
|
1811
|
+
extra_body=extra_body,
|
|
1812
|
+
timeout=timeout,
|
|
1813
|
+
),
|
|
1814
|
+
kind="void",
|
|
1815
|
+
)
|
|
1816
|
+
|
|
1817
|
+
|
|
1818
|
+
class AsyncSessionRevertResource(AsyncAPIResource):
|
|
1819
|
+
"""Operations under ``client.session.revert`` (OpenCode ``session.revert``)."""
|
|
1820
|
+
|
|
1821
|
+
async def stage(
|
|
1822
|
+
self,
|
|
1823
|
+
session_id: SessionID,
|
|
1824
|
+
*,
|
|
1825
|
+
message_id: SessionMessageID,
|
|
1826
|
+
files: bool | NotGiven | None = NOT_GIVEN,
|
|
1827
|
+
extra_headers: Headers | None = None,
|
|
1828
|
+
extra_query: Query | None = None,
|
|
1829
|
+
extra_body: Body | None = None,
|
|
1830
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
1831
|
+
) -> SessionRevert:
|
|
1832
|
+
"""Stage session revert.
|
|
1833
|
+
|
|
1834
|
+
Stage or move a reversible session boundary and optionally apply its file changes.
|
|
1835
|
+
|
|
1836
|
+
Raises:
|
|
1837
|
+
InvalidRequestError: The server answered 400.
|
|
1838
|
+
UnauthorizedError: The server answered 401.
|
|
1839
|
+
MessageNotFoundError: The server answered 404.
|
|
1840
|
+
SessionNotFoundError: The server answered 404.
|
|
1841
|
+
LocationNotFoundError: The server answered 404.
|
|
1842
|
+
SessionBusyError: The server answered 409.
|
|
1843
|
+
UnknownError: The server answered 500.
|
|
1844
|
+
|
|
1845
|
+
``POST /api/session/:sessionID/revert/stage``
|
|
1846
|
+
"""
|
|
1847
|
+
return cast(
|
|
1848
|
+
"SessionRevert",
|
|
1849
|
+
await self._client.request(
|
|
1850
|
+
RequestOptions(
|
|
1851
|
+
method="POST",
|
|
1852
|
+
path=f"/api/session/{encode_path_segment(session_id)}/revert/stage",
|
|
1853
|
+
body={"messageID": message_id, "files": files},
|
|
1854
|
+
extra_headers=extra_headers,
|
|
1855
|
+
extra_query=extra_query,
|
|
1856
|
+
extra_body=extra_body,
|
|
1857
|
+
timeout=timeout,
|
|
1858
|
+
),
|
|
1859
|
+
response_type="SessionRevert",
|
|
1860
|
+
unwrap=True,
|
|
1861
|
+
),
|
|
1862
|
+
)
|
|
1863
|
+
|
|
1864
|
+
async def clear(
|
|
1865
|
+
self,
|
|
1866
|
+
session_id: SessionID,
|
|
1867
|
+
*,
|
|
1868
|
+
extra_headers: Headers | None = None,
|
|
1869
|
+
extra_query: Query | None = None,
|
|
1870
|
+
extra_body: Body | None = None,
|
|
1871
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
1872
|
+
) -> None:
|
|
1873
|
+
"""Clear staged revert.
|
|
1874
|
+
|
|
1875
|
+
Raises:
|
|
1876
|
+
InvalidRequestError: The server answered 400.
|
|
1877
|
+
UnauthorizedError: The server answered 401.
|
|
1878
|
+
SessionNotFoundError: The server answered 404.
|
|
1879
|
+
LocationNotFoundError: The server answered 404.
|
|
1880
|
+
SessionBusyError: The server answered 409.
|
|
1881
|
+
UnknownError: The server answered 500.
|
|
1882
|
+
|
|
1883
|
+
``DELETE /api/session/:sessionID/revert``
|
|
1884
|
+
"""
|
|
1885
|
+
await self._client.request(
|
|
1886
|
+
RequestOptions(
|
|
1887
|
+
method="DELETE",
|
|
1888
|
+
path=f"/api/session/{encode_path_segment(session_id)}/revert",
|
|
1889
|
+
extra_headers=extra_headers,
|
|
1890
|
+
extra_query=extra_query,
|
|
1891
|
+
extra_body=extra_body,
|
|
1892
|
+
timeout=timeout,
|
|
1893
|
+
),
|
|
1894
|
+
kind="void",
|
|
1895
|
+
)
|
|
1896
|
+
|
|
1897
|
+
async def commit(
|
|
1898
|
+
self,
|
|
1899
|
+
session_id: SessionID,
|
|
1900
|
+
*,
|
|
1901
|
+
extra_headers: Headers | None = None,
|
|
1902
|
+
extra_query: Query | None = None,
|
|
1903
|
+
extra_body: Body | None = None,
|
|
1904
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
1905
|
+
) -> None:
|
|
1906
|
+
"""Commit staged revert.
|
|
1907
|
+
|
|
1908
|
+
Raises:
|
|
1909
|
+
InvalidRequestError: The server answered 400.
|
|
1910
|
+
UnauthorizedError: The server answered 401.
|
|
1911
|
+
SessionNotFoundError: The server answered 404.
|
|
1912
|
+
LocationNotFoundError: The server answered 404.
|
|
1913
|
+
SessionBusyError: The server answered 409.
|
|
1914
|
+
|
|
1915
|
+
``POST /api/session/:sessionID/revert/commit``
|
|
1916
|
+
"""
|
|
1917
|
+
await self._client.request(
|
|
1918
|
+
RequestOptions(
|
|
1919
|
+
method="POST",
|
|
1920
|
+
path=f"/api/session/{encode_path_segment(session_id)}/revert/commit",
|
|
1921
|
+
extra_headers=extra_headers,
|
|
1922
|
+
extra_query=extra_query,
|
|
1923
|
+
extra_body=extra_body,
|
|
1924
|
+
timeout=timeout,
|
|
1925
|
+
),
|
|
1926
|
+
kind="void",
|
|
1927
|
+
)
|
|
1928
|
+
|
|
1929
|
+
|
|
1930
|
+
class AsyncSessionInboxResource(AsyncAPIResource):
|
|
1931
|
+
"""Operations under ``client.session.inbox`` (OpenCode ``session.inbox``)."""
|
|
1932
|
+
|
|
1933
|
+
async def list(
|
|
1934
|
+
self,
|
|
1935
|
+
session_id: SessionID,
|
|
1936
|
+
*,
|
|
1937
|
+
extra_headers: Headers | None = None,
|
|
1938
|
+
extra_query: Query | None = None,
|
|
1939
|
+
extra_body: Body | None = None,
|
|
1940
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
1941
|
+
) -> builtins.list[SessionInboxInfo]:
|
|
1942
|
+
"""List session inbox.
|
|
1943
|
+
|
|
1944
|
+
List durable enqueued session work not yet delivered, ordered by enqueue sequence. Includes user, synthetic, compaction, and move items.
|
|
1945
|
+
|
|
1946
|
+
Raises:
|
|
1947
|
+
InvalidRequestError: The server answered 400.
|
|
1948
|
+
UnauthorizedError: The server answered 401.
|
|
1949
|
+
SessionNotFoundError: The server answered 404.
|
|
1950
|
+
|
|
1951
|
+
``GET /api/session/:sessionID/inbox``
|
|
1952
|
+
"""
|
|
1953
|
+
return cast(
|
|
1954
|
+
"builtins.list[SessionInboxInfo]",
|
|
1955
|
+
await self._client.request(
|
|
1956
|
+
RequestOptions(
|
|
1957
|
+
method="GET",
|
|
1958
|
+
path=f"/api/session/{encode_path_segment(session_id)}/inbox",
|
|
1959
|
+
extra_headers=extra_headers,
|
|
1960
|
+
extra_query=extra_query,
|
|
1961
|
+
extra_body=extra_body,
|
|
1962
|
+
timeout=timeout,
|
|
1963
|
+
),
|
|
1964
|
+
response_type="builtins.list[SessionInboxInfo]",
|
|
1965
|
+
unwrap=True,
|
|
1966
|
+
),
|
|
1967
|
+
)
|
|
1968
|
+
|
|
1969
|
+
async def cancel(
|
|
1970
|
+
self,
|
|
1971
|
+
session_id: SessionID,
|
|
1972
|
+
inbox_id: SessionMessageID,
|
|
1973
|
+
*,
|
|
1974
|
+
extra_headers: Headers | None = None,
|
|
1975
|
+
extra_query: Query | None = None,
|
|
1976
|
+
extra_body: Body | None = None,
|
|
1977
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
1978
|
+
) -> None:
|
|
1979
|
+
"""Cancel inbox input.
|
|
1980
|
+
|
|
1981
|
+
Cancel an inbox item that has not yet been delivered. Unavailable items are a no-op.
|
|
1982
|
+
|
|
1983
|
+
Raises:
|
|
1984
|
+
InvalidRequestError: The server answered 400.
|
|
1985
|
+
UnauthorizedError: The server answered 401.
|
|
1986
|
+
SessionNotFoundError: The server answered 404.
|
|
1987
|
+
|
|
1988
|
+
``DELETE /api/session/:sessionID/inbox/:inboxID``
|
|
1989
|
+
"""
|
|
1990
|
+
await self._client.request(
|
|
1991
|
+
RequestOptions(
|
|
1992
|
+
method="DELETE",
|
|
1993
|
+
path=f"/api/session/{encode_path_segment(session_id)}/inbox/{encode_path_segment(inbox_id)}",
|
|
1994
|
+
extra_headers=extra_headers,
|
|
1995
|
+
extra_query=extra_query,
|
|
1996
|
+
extra_body=extra_body,
|
|
1997
|
+
timeout=timeout,
|
|
1998
|
+
),
|
|
1999
|
+
kind="void",
|
|
2000
|
+
)
|
|
2001
|
+
|
|
2002
|
+
async def update(
|
|
2003
|
+
self,
|
|
2004
|
+
session_id: SessionID,
|
|
2005
|
+
inbox_id: SessionMessageID,
|
|
2006
|
+
*,
|
|
2007
|
+
delivery: SessionInboxDelivery,
|
|
2008
|
+
extra_headers: Headers | None = None,
|
|
2009
|
+
extra_query: Query | None = None,
|
|
2010
|
+
extra_body: Body | None = None,
|
|
2011
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
2012
|
+
) -> None:
|
|
2013
|
+
"""Update inbox item.
|
|
2014
|
+
|
|
2015
|
+
Change a pending inbox item's delivery mode. Steering wakes session execution.
|
|
2016
|
+
|
|
2017
|
+
Raises:
|
|
2018
|
+
InvalidRequestError: The server answered 400.
|
|
2019
|
+
UnauthorizedError: The server answered 401.
|
|
2020
|
+
SessionNotFoundError: The server answered 404.
|
|
2021
|
+
ConflictError: The server answered 409.
|
|
2022
|
+
|
|
2023
|
+
``PATCH /api/session/:sessionID/inbox/:inboxID``
|
|
2024
|
+
"""
|
|
2025
|
+
await self._client.request(
|
|
2026
|
+
RequestOptions(
|
|
2027
|
+
method="PATCH",
|
|
2028
|
+
path=f"/api/session/{encode_path_segment(session_id)}/inbox/{encode_path_segment(inbox_id)}",
|
|
2029
|
+
body={"delivery": delivery},
|
|
2030
|
+
extra_headers=extra_headers,
|
|
2031
|
+
extra_query=extra_query,
|
|
2032
|
+
extra_body=extra_body,
|
|
2033
|
+
timeout=timeout,
|
|
2034
|
+
),
|
|
2035
|
+
kind="void",
|
|
2036
|
+
)
|
|
2037
|
+
|
|
2038
|
+
|
|
2039
|
+
class AsyncSessionInstructionsEntryResource(AsyncAPIResource):
|
|
2040
|
+
"""Operations under ``client.session.instructions.entry`` (OpenCode ``session.instructions.entry``)."""
|
|
2041
|
+
|
|
2042
|
+
async def list(
|
|
2043
|
+
self,
|
|
2044
|
+
session_id: SessionID,
|
|
2045
|
+
*,
|
|
2046
|
+
extra_headers: Headers | None = None,
|
|
2047
|
+
extra_query: Query | None = None,
|
|
2048
|
+
extra_body: Body | None = None,
|
|
2049
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
2050
|
+
) -> builtins.list[InstructionEntryInfo]:
|
|
2051
|
+
"""List instruction entries.
|
|
2052
|
+
|
|
2053
|
+
List API-managed instruction entries attached to the session.
|
|
2054
|
+
|
|
2055
|
+
This endpoint is experimental in OpenCode and may change without notice.
|
|
2056
|
+
|
|
2057
|
+
Raises:
|
|
2058
|
+
InvalidRequestError: The server answered 400.
|
|
2059
|
+
UnauthorizedError: The server answered 401.
|
|
2060
|
+
SessionNotFoundError: The server answered 404.
|
|
2061
|
+
LocationNotFoundError: The server answered 404.
|
|
2062
|
+
|
|
2063
|
+
``GET /api/experimental/session/:sessionID/instructions/entries``
|
|
2064
|
+
"""
|
|
2065
|
+
return cast(
|
|
2066
|
+
"builtins.list[InstructionEntryInfo]",
|
|
2067
|
+
await self._client.request(
|
|
2068
|
+
RequestOptions(
|
|
2069
|
+
method="GET",
|
|
2070
|
+
path=f"/api/experimental/session/{encode_path_segment(session_id)}/instructions/entries",
|
|
2071
|
+
extra_headers=extra_headers,
|
|
2072
|
+
extra_query=extra_query,
|
|
2073
|
+
extra_body=extra_body,
|
|
2074
|
+
timeout=timeout,
|
|
2075
|
+
),
|
|
2076
|
+
response_type="builtins.list[InstructionEntryInfo]",
|
|
2077
|
+
unwrap=True,
|
|
2078
|
+
),
|
|
2079
|
+
)
|
|
2080
|
+
|
|
2081
|
+
async def put(
|
|
2082
|
+
self,
|
|
2083
|
+
session_id: SessionID,
|
|
2084
|
+
key: InstructionEntryKey,
|
|
2085
|
+
*,
|
|
2086
|
+
value: Any,
|
|
2087
|
+
extra_headers: Headers | None = None,
|
|
2088
|
+
extra_query: Query | None = None,
|
|
2089
|
+
extra_body: Body | None = None,
|
|
2090
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
2091
|
+
) -> None:
|
|
2092
|
+
"""Put instruction entry.
|
|
2093
|
+
|
|
2094
|
+
Attach or replace one durable instruction entry. Changes announce as updates at the next step boundary.
|
|
2095
|
+
|
|
2096
|
+
This endpoint is experimental in OpenCode and may change without notice.
|
|
2097
|
+
|
|
2098
|
+
Raises:
|
|
2099
|
+
InvalidRequestError: The server answered 400.
|
|
2100
|
+
UnauthorizedError: The server answered 401.
|
|
2101
|
+
SessionNotFoundError: The server answered 404.
|
|
2102
|
+
LocationNotFoundError: The server answered 404.
|
|
2103
|
+
InstructionEntryValueTooLargeError: The server answered 413.
|
|
2104
|
+
|
|
2105
|
+
``PUT /api/experimental/session/:sessionID/instructions/entries/:key``
|
|
2106
|
+
"""
|
|
2107
|
+
await self._client.request(
|
|
2108
|
+
RequestOptions(
|
|
2109
|
+
method="PUT",
|
|
2110
|
+
path=f"/api/experimental/session/{encode_path_segment(session_id)}/instructions/entries/{encode_path_segment(key)}",
|
|
2111
|
+
body={"value": value},
|
|
2112
|
+
extra_headers=extra_headers,
|
|
2113
|
+
extra_query=extra_query,
|
|
2114
|
+
extra_body=extra_body,
|
|
2115
|
+
timeout=timeout,
|
|
2116
|
+
),
|
|
2117
|
+
kind="void",
|
|
2118
|
+
)
|
|
2119
|
+
|
|
2120
|
+
async def remove(
|
|
2121
|
+
self,
|
|
2122
|
+
session_id: SessionID,
|
|
2123
|
+
key: InstructionEntryKey,
|
|
2124
|
+
*,
|
|
2125
|
+
extra_headers: Headers | None = None,
|
|
2126
|
+
extra_query: Query | None = None,
|
|
2127
|
+
extra_body: Body | None = None,
|
|
2128
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
2129
|
+
) -> None:
|
|
2130
|
+
"""Remove instruction entry.
|
|
2131
|
+
|
|
2132
|
+
Remove one instruction entry; the removal is announced to the model at the next step boundary.
|
|
2133
|
+
|
|
2134
|
+
This endpoint is experimental in OpenCode and may change without notice.
|
|
2135
|
+
|
|
2136
|
+
Raises:
|
|
2137
|
+
InvalidRequestError: The server answered 400.
|
|
2138
|
+
UnauthorizedError: The server answered 401.
|
|
2139
|
+
SessionNotFoundError: The server answered 404.
|
|
2140
|
+
LocationNotFoundError: The server answered 404.
|
|
2141
|
+
|
|
2142
|
+
``DELETE /api/experimental/session/:sessionID/instructions/entries/:key``
|
|
2143
|
+
"""
|
|
2144
|
+
await self._client.request(
|
|
2145
|
+
RequestOptions(
|
|
2146
|
+
method="DELETE",
|
|
2147
|
+
path=f"/api/experimental/session/{encode_path_segment(session_id)}/instructions/entries/{encode_path_segment(key)}",
|
|
2148
|
+
extra_headers=extra_headers,
|
|
2149
|
+
extra_query=extra_query,
|
|
2150
|
+
extra_body=extra_body,
|
|
2151
|
+
timeout=timeout,
|
|
2152
|
+
),
|
|
2153
|
+
kind="void",
|
|
2154
|
+
)
|
|
2155
|
+
|
|
2156
|
+
|
|
2157
|
+
class AsyncSessionInstructionsResource(AsyncAPIResource):
|
|
2158
|
+
"""Operations under ``client.session.instructions`` (OpenCode ``session.instructions``)."""
|
|
2159
|
+
|
|
2160
|
+
@cached_property
|
|
2161
|
+
def entry(self) -> AsyncSessionInstructionsEntryResource:
|
|
2162
|
+
"""Operations under ``client.session.instructions.entry``."""
|
|
2163
|
+
return AsyncSessionInstructionsEntryResource(self._client)
|
|
2164
|
+
|
|
2165
|
+
|
|
2166
|
+
class AsyncSessionMessageResource(AsyncAPIResource):
|
|
2167
|
+
"""Operations under ``client.session.message`` (OpenCode ``session.message``)."""
|
|
2168
|
+
|
|
2169
|
+
async def get(
|
|
2170
|
+
self,
|
|
2171
|
+
session_id: SessionID,
|
|
2172
|
+
message_id: SessionMessageID,
|
|
2173
|
+
*,
|
|
2174
|
+
extra_headers: Headers | None = None,
|
|
2175
|
+
extra_query: Query | None = None,
|
|
2176
|
+
extra_body: Body | None = None,
|
|
2177
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
2178
|
+
) -> SessionMessageInfo:
|
|
2179
|
+
"""Get session message.
|
|
2180
|
+
|
|
2181
|
+
Retrieve one projected message owned by the Session.
|
|
2182
|
+
|
|
2183
|
+
Raises:
|
|
2184
|
+
InvalidRequestError: The server answered 400.
|
|
2185
|
+
UnauthorizedError: The server answered 401.
|
|
2186
|
+
SessionNotFoundError: The server answered 404.
|
|
2187
|
+
MessageNotFoundError: The server answered 404.
|
|
2188
|
+
|
|
2189
|
+
``GET /api/session/:sessionID/message/:messageID``
|
|
2190
|
+
"""
|
|
2191
|
+
return cast(
|
|
2192
|
+
"SessionMessageInfo",
|
|
2193
|
+
await self._client.request(
|
|
2194
|
+
RequestOptions(
|
|
2195
|
+
method="GET",
|
|
2196
|
+
path=f"/api/session/{encode_path_segment(session_id)}/message/{encode_path_segment(message_id)}",
|
|
2197
|
+
extra_headers=extra_headers,
|
|
2198
|
+
extra_query=extra_query,
|
|
2199
|
+
extra_body=extra_body,
|
|
2200
|
+
timeout=timeout,
|
|
2201
|
+
),
|
|
2202
|
+
response_type="SessionMessageInfo",
|
|
2203
|
+
unwrap=True,
|
|
2204
|
+
),
|
|
2205
|
+
)
|
|
2206
|
+
|
|
2207
|
+
|
|
2208
|
+
class AsyncSessionFormResource(AsyncAPIResource):
|
|
2209
|
+
"""Operations under ``client.session.form`` (OpenCode ``session.form``)."""
|
|
2210
|
+
|
|
2211
|
+
async def list(
|
|
2212
|
+
self,
|
|
2213
|
+
session_id: str,
|
|
2214
|
+
*,
|
|
2215
|
+
extra_headers: Headers | None = None,
|
|
2216
|
+
extra_query: Query | None = None,
|
|
2217
|
+
extra_body: Body | None = None,
|
|
2218
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
2219
|
+
) -> builtins.list[FormInfo]:
|
|
2220
|
+
"""List session forms.
|
|
2221
|
+
|
|
2222
|
+
Retrieve pending forms for a session.
|
|
2223
|
+
|
|
2224
|
+
Raises:
|
|
2225
|
+
InvalidRequestError: The server answered 400.
|
|
2226
|
+
UnauthorizedError: The server answered 401.
|
|
2227
|
+
SessionNotFoundError: The server answered 404.
|
|
2228
|
+
LocationNotFoundError: The server answered 404.
|
|
2229
|
+
|
|
2230
|
+
``GET /api/session/:sessionID/form``
|
|
2231
|
+
"""
|
|
2232
|
+
return cast(
|
|
2233
|
+
"builtins.list[FormInfo]",
|
|
2234
|
+
await self._client.request(
|
|
2235
|
+
RequestOptions(
|
|
2236
|
+
method="GET",
|
|
2237
|
+
path=f"/api/session/{encode_path_segment(session_id)}/form",
|
|
2238
|
+
extra_headers=extra_headers,
|
|
2239
|
+
extra_query=extra_query,
|
|
2240
|
+
extra_body=extra_body,
|
|
2241
|
+
timeout=timeout,
|
|
2242
|
+
),
|
|
2243
|
+
response_type="builtins.list[FormInfo]",
|
|
2244
|
+
unwrap=True,
|
|
2245
|
+
),
|
|
2246
|
+
)
|
|
2247
|
+
|
|
2248
|
+
async def create(
|
|
2249
|
+
self,
|
|
2250
|
+
session_id: str,
|
|
2251
|
+
*,
|
|
2252
|
+
title: str,
|
|
2253
|
+
fields: FormFields,
|
|
2254
|
+
id: FormID | NotGiven | None = NOT_GIVEN,
|
|
2255
|
+
metadata: FormMetadata | NotGiven = NOT_GIVEN,
|
|
2256
|
+
extra_headers: Headers | None = None,
|
|
2257
|
+
extra_query: Query | None = None,
|
|
2258
|
+
extra_body: Body | None = None,
|
|
2259
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
2260
|
+
) -> FormInfo:
|
|
2261
|
+
"""Create session form.
|
|
2262
|
+
|
|
2263
|
+
Create a form for a session.
|
|
2264
|
+
|
|
2265
|
+
Raises:
|
|
2266
|
+
InvalidRequestError: The server answered 400.
|
|
2267
|
+
UnauthorizedError: The server answered 401.
|
|
2268
|
+
SessionNotFoundError: The server answered 404.
|
|
2269
|
+
LocationNotFoundError: The server answered 404.
|
|
2270
|
+
ConflictError: The server answered 409.
|
|
2271
|
+
|
|
2272
|
+
``POST /api/session/:sessionID/form``
|
|
2273
|
+
"""
|
|
2274
|
+
return cast(
|
|
2275
|
+
"FormInfo",
|
|
2276
|
+
await self._client.request(
|
|
2277
|
+
RequestOptions(
|
|
2278
|
+
method="POST",
|
|
2279
|
+
path=f"/api/session/{encode_path_segment(session_id)}/form",
|
|
2280
|
+
body={"id": id, "title": title, "metadata": metadata, "fields": fields},
|
|
2281
|
+
extra_headers=extra_headers,
|
|
2282
|
+
extra_query=extra_query,
|
|
2283
|
+
extra_body=extra_body,
|
|
2284
|
+
timeout=timeout,
|
|
2285
|
+
),
|
|
2286
|
+
response_type="FormInfo",
|
|
2287
|
+
unwrap=True,
|
|
2288
|
+
),
|
|
2289
|
+
)
|
|
2290
|
+
|
|
2291
|
+
async def get(
|
|
2292
|
+
self,
|
|
2293
|
+
session_id: str,
|
|
2294
|
+
form_id: FormID,
|
|
2295
|
+
*,
|
|
2296
|
+
extra_headers: Headers | None = None,
|
|
2297
|
+
extra_query: Query | None = None,
|
|
2298
|
+
extra_body: Body | None = None,
|
|
2299
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
2300
|
+
) -> FormDetail:
|
|
2301
|
+
"""Get session form.
|
|
2302
|
+
|
|
2303
|
+
Retrieve a form and its current state for a session.
|
|
2304
|
+
|
|
2305
|
+
Raises:
|
|
2306
|
+
InvalidRequestError: The server answered 400.
|
|
2307
|
+
UnauthorizedError: The server answered 401.
|
|
2308
|
+
SessionNotFoundError: The server answered 404.
|
|
2309
|
+
FormNotFoundError: The server answered 404.
|
|
2310
|
+
LocationNotFoundError: The server answered 404.
|
|
2311
|
+
|
|
2312
|
+
``GET /api/session/:sessionID/form/:formID``
|
|
2313
|
+
"""
|
|
2314
|
+
return cast(
|
|
2315
|
+
"FormDetail",
|
|
2316
|
+
await self._client.request(
|
|
2317
|
+
RequestOptions(
|
|
2318
|
+
method="GET",
|
|
2319
|
+
path=f"/api/session/{encode_path_segment(session_id)}/form/{encode_path_segment(form_id)}",
|
|
2320
|
+
extra_headers=extra_headers,
|
|
2321
|
+
extra_query=extra_query,
|
|
2322
|
+
extra_body=extra_body,
|
|
2323
|
+
timeout=timeout,
|
|
2324
|
+
),
|
|
2325
|
+
response_type="FormDetail",
|
|
2326
|
+
unwrap=True,
|
|
2327
|
+
),
|
|
2328
|
+
)
|
|
2329
|
+
|
|
2330
|
+
async def reply(
|
|
2331
|
+
self,
|
|
2332
|
+
session_id: str,
|
|
2333
|
+
form_id: FormID,
|
|
2334
|
+
*,
|
|
2335
|
+
answer: FormAnswer,
|
|
2336
|
+
extra_headers: Headers | None = None,
|
|
2337
|
+
extra_query: Query | None = None,
|
|
2338
|
+
extra_body: Body | None = None,
|
|
2339
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
2340
|
+
) -> None:
|
|
2341
|
+
"""Reply to form.
|
|
2342
|
+
|
|
2343
|
+
Submit an answer to a pending form.
|
|
2344
|
+
|
|
2345
|
+
Raises:
|
|
2346
|
+
FormInvalidAnswerError: The server answered 400.
|
|
2347
|
+
InvalidRequestError: The server answered 400.
|
|
2348
|
+
UnauthorizedError: The server answered 401.
|
|
2349
|
+
SessionNotFoundError: The server answered 404.
|
|
2350
|
+
FormNotFoundError: The server answered 404.
|
|
2351
|
+
LocationNotFoundError: The server answered 404.
|
|
2352
|
+
FormAlreadySettledError: The server answered 409.
|
|
2353
|
+
|
|
2354
|
+
``POST /api/session/:sessionID/form/:formID/reply``
|
|
2355
|
+
"""
|
|
2356
|
+
await self._client.request(
|
|
2357
|
+
RequestOptions(
|
|
2358
|
+
method="POST",
|
|
2359
|
+
path=f"/api/session/{encode_path_segment(session_id)}/form/{encode_path_segment(form_id)}/reply",
|
|
2360
|
+
body={"answer": answer},
|
|
2361
|
+
extra_headers=extra_headers,
|
|
2362
|
+
extra_query=extra_query,
|
|
2363
|
+
extra_body=extra_body,
|
|
2364
|
+
timeout=timeout,
|
|
2365
|
+
),
|
|
2366
|
+
kind="void",
|
|
2367
|
+
)
|
|
2368
|
+
|
|
2369
|
+
async def cancel(
|
|
2370
|
+
self,
|
|
2371
|
+
session_id: str,
|
|
2372
|
+
form_id: FormID,
|
|
2373
|
+
*,
|
|
2374
|
+
message: str | NotGiven | None = NOT_GIVEN,
|
|
2375
|
+
extra_headers: Headers | None = None,
|
|
2376
|
+
extra_query: Query | None = None,
|
|
2377
|
+
extra_body: Body | None = None,
|
|
2378
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
2379
|
+
) -> None:
|
|
2380
|
+
"""Cancel form.
|
|
2381
|
+
|
|
2382
|
+
Cancel a pending form, optionally telling the asker why it was not answered.
|
|
2383
|
+
|
|
2384
|
+
Raises:
|
|
2385
|
+
InvalidRequestError: The server answered 400.
|
|
2386
|
+
UnauthorizedError: The server answered 401.
|
|
2387
|
+
SessionNotFoundError: The server answered 404.
|
|
2388
|
+
FormNotFoundError: The server answered 404.
|
|
2389
|
+
LocationNotFoundError: The server answered 404.
|
|
2390
|
+
FormAlreadySettledError: The server answered 409.
|
|
2391
|
+
|
|
2392
|
+
``DELETE /api/session/:sessionID/form/:formID``
|
|
2393
|
+
"""
|
|
2394
|
+
await self._client.request(
|
|
2395
|
+
RequestOptions(
|
|
2396
|
+
method="DELETE",
|
|
2397
|
+
path=f"/api/session/{encode_path_segment(session_id)}/form/{encode_path_segment(form_id)}",
|
|
2398
|
+
query={"message": message},
|
|
2399
|
+
extra_headers=extra_headers,
|
|
2400
|
+
extra_query=extra_query,
|
|
2401
|
+
extra_body=extra_body,
|
|
2402
|
+
timeout=timeout,
|
|
2403
|
+
),
|
|
2404
|
+
kind="void",
|
|
2405
|
+
)
|
|
2406
|
+
|
|
2407
|
+
|
|
2408
|
+
class AsyncSessionResource(AsyncSessionHelpers):
|
|
2409
|
+
"""Operations under ``client.session`` (OpenCode ``session``)."""
|
|
2410
|
+
|
|
2411
|
+
@cached_property
|
|
2412
|
+
def revert(self) -> AsyncSessionRevertResource:
|
|
2413
|
+
"""Operations under ``client.session.revert``."""
|
|
2414
|
+
return AsyncSessionRevertResource(self._client)
|
|
2415
|
+
|
|
2416
|
+
@cached_property
|
|
2417
|
+
def inbox(self) -> AsyncSessionInboxResource:
|
|
2418
|
+
"""Operations under ``client.session.inbox``."""
|
|
2419
|
+
return AsyncSessionInboxResource(self._client)
|
|
2420
|
+
|
|
2421
|
+
@cached_property
|
|
2422
|
+
def instructions(self) -> AsyncSessionInstructionsResource:
|
|
2423
|
+
"""Operations under ``client.session.instructions``."""
|
|
2424
|
+
return AsyncSessionInstructionsResource(self._client)
|
|
2425
|
+
|
|
2426
|
+
@cached_property
|
|
2427
|
+
def message(self) -> AsyncSessionMessageResource:
|
|
2428
|
+
"""Operations under ``client.session.message``."""
|
|
2429
|
+
return AsyncSessionMessageResource(self._client)
|
|
2430
|
+
|
|
2431
|
+
@cached_property
|
|
2432
|
+
def form(self) -> AsyncSessionFormResource:
|
|
2433
|
+
"""Operations under ``client.session.form``."""
|
|
2434
|
+
return AsyncSessionFormResource(self._client)
|
|
2435
|
+
|
|
2436
|
+
def list(
|
|
2437
|
+
self,
|
|
2438
|
+
*,
|
|
2439
|
+
limit: int | NotGiven | None = NOT_GIVEN,
|
|
2440
|
+
order: OpenEnum[Literal["asc", "desc"]] | NotGiven | None = NOT_GIVEN,
|
|
2441
|
+
search: str | NotGiven | None = NOT_GIVEN,
|
|
2442
|
+
parent_id: SessionID | NotGiven | None = NOT_GIVEN,
|
|
2443
|
+
archived: bool | NotGiven | None = NOT_GIVEN,
|
|
2444
|
+
directory: AbsolutePath | NotGiven | None = NOT_GIVEN,
|
|
2445
|
+
project: ProjectID | NotGiven | None = NOT_GIVEN,
|
|
2446
|
+
subpath: RelativePath | NotGiven | None = NOT_GIVEN,
|
|
2447
|
+
cursor: SessionsCursor | NotGiven | None = NOT_GIVEN,
|
|
2448
|
+
extra_headers: Headers | None = None,
|
|
2449
|
+
extra_query: Query | None = None,
|
|
2450
|
+
extra_body: Body | None = None,
|
|
2451
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
2452
|
+
) -> AsyncPaginator[SessionInfo]:
|
|
2453
|
+
"""List sessions.
|
|
2454
|
+
|
|
2455
|
+
Retrieve sessions in the requested order. Items keep that order across pages; use cursor.next or cursor.previous to move through the ordered list.
|
|
2456
|
+
|
|
2457
|
+
Args:
|
|
2458
|
+
limit: Maximum number of sessions to return. Defaults to the newest 50 sessions.
|
|
2459
|
+
order: Session order for the first page. Use desc for newest first or asc for oldest first.
|
|
2460
|
+
parent_id: Filter by parent session. Use null to return only root sessions.
|
|
2461
|
+
archived: Filter by archive state. Use true to return only archived sessions or false to exclude them. Omit to include both.
|
|
2462
|
+
|
|
2463
|
+
Raises:
|
|
2464
|
+
InvalidCursorError: The server answered 400.
|
|
2465
|
+
InvalidRequestError: The server answered 400.
|
|
2466
|
+
UnauthorizedError: The server answered 401.
|
|
2467
|
+
|
|
2468
|
+
``GET /api/session``
|
|
2469
|
+
"""
|
|
2470
|
+
return self._client.page(
|
|
2471
|
+
RequestOptions(
|
|
2472
|
+
method="GET",
|
|
2473
|
+
path="/api/session",
|
|
2474
|
+
query={
|
|
2475
|
+
"limit": limit,
|
|
2476
|
+
"order": order,
|
|
2477
|
+
"search": search,
|
|
2478
|
+
"parentID": parent_id,
|
|
2479
|
+
"archived": archived,
|
|
2480
|
+
"directory": directory,
|
|
2481
|
+
"project": project,
|
|
2482
|
+
"subpath": subpath,
|
|
2483
|
+
"cursor": cursor,
|
|
2484
|
+
},
|
|
2485
|
+
extra_headers=extra_headers,
|
|
2486
|
+
extra_query=extra_query,
|
|
2487
|
+
extra_body=extra_body,
|
|
2488
|
+
timeout=timeout,
|
|
2489
|
+
),
|
|
2490
|
+
response_type="SessionsResponse",
|
|
2491
|
+
)
|
|
2492
|
+
|
|
2493
|
+
async def stats(
|
|
2494
|
+
self,
|
|
2495
|
+
*,
|
|
2496
|
+
from_: float | OpenEnum[Literal["Infinity", "-Infinity", "NaN"]] | NotGiven | None = NOT_GIVEN,
|
|
2497
|
+
to: float | OpenEnum[Literal["Infinity", "-Infinity", "NaN"]] | NotGiven | None = NOT_GIVEN,
|
|
2498
|
+
project: ProjectID | NotGiven | None = NOT_GIVEN,
|
|
2499
|
+
timezone: str | NotGiven | None = NOT_GIVEN,
|
|
2500
|
+
tools: OpenEnum[Literal["none", "summary", "detail"]] | NotGiven | None = NOT_GIVEN,
|
|
2501
|
+
extra_headers: Headers | None = None,
|
|
2502
|
+
extra_query: Query | None = None,
|
|
2503
|
+
extra_body: Body | None = None,
|
|
2504
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
2505
|
+
) -> SessionStatsInfo:
|
|
2506
|
+
"""Get session statistics.
|
|
2507
|
+
|
|
2508
|
+
Aggregate local session activity, usage, and tool reliability for a time range.
|
|
2509
|
+
|
|
2510
|
+
This endpoint is experimental in OpenCode and may change without notice.
|
|
2511
|
+
|
|
2512
|
+
Raises:
|
|
2513
|
+
InvalidRequestError: The server answered 400.
|
|
2514
|
+
UnauthorizedError: The server answered 401.
|
|
2515
|
+
|
|
2516
|
+
``GET /api/experimental/session/stats``
|
|
2517
|
+
"""
|
|
2518
|
+
return cast(
|
|
2519
|
+
"SessionStatsInfo",
|
|
2520
|
+
await self._client.request(
|
|
2521
|
+
RequestOptions(
|
|
2522
|
+
method="GET",
|
|
2523
|
+
path="/api/experimental/session/stats",
|
|
2524
|
+
query={"from": from_, "to": to, "project": project, "timezone": timezone, "tools": tools},
|
|
2525
|
+
extra_headers=extra_headers,
|
|
2526
|
+
extra_query=extra_query,
|
|
2527
|
+
extra_body=extra_body,
|
|
2528
|
+
timeout=timeout,
|
|
2529
|
+
),
|
|
2530
|
+
response_type="SessionStatsInfo",
|
|
2531
|
+
unwrap=True,
|
|
2532
|
+
),
|
|
2533
|
+
)
|
|
2534
|
+
|
|
2535
|
+
async def create(
|
|
2536
|
+
self,
|
|
2537
|
+
*,
|
|
2538
|
+
id: SessionID | NotGiven | None = NOT_GIVEN,
|
|
2539
|
+
parent_id: SessionID | NotGiven | None = NOT_GIVEN,
|
|
2540
|
+
title: str | NotGiven | None = NOT_GIVEN,
|
|
2541
|
+
agent: AgentID | NotGiven | None = NOT_GIVEN,
|
|
2542
|
+
model: ModelRef | NotGiven | None = NOT_GIVEN,
|
|
2543
|
+
location: LocationPublicRef | NotGiven | None = NOT_GIVEN,
|
|
2544
|
+
metadata: SessionMetadata | NotGiven | None = NOT_GIVEN,
|
|
2545
|
+
permissions: PermissionRuleset | NotGiven | None = NOT_GIVEN,
|
|
2546
|
+
extra_headers: Headers | None = None,
|
|
2547
|
+
extra_query: Query | None = None,
|
|
2548
|
+
extra_body: Body | None = None,
|
|
2549
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
2550
|
+
) -> SessionInfo:
|
|
2551
|
+
"""Create session.
|
|
2552
|
+
|
|
2553
|
+
Create a session at the requested location. A parentID creates a linked child session at its parent's location.
|
|
2554
|
+
|
|
2555
|
+
Raises:
|
|
2556
|
+
InvalidRequestError: The server answered 400.
|
|
2557
|
+
UnauthorizedError: The server answered 401.
|
|
2558
|
+
SessionNotFoundError: The server answered 404.
|
|
2559
|
+
|
|
2560
|
+
``POST /api/session``
|
|
2561
|
+
"""
|
|
2562
|
+
return cast(
|
|
2563
|
+
"SessionInfo",
|
|
2564
|
+
await self._client.request(
|
|
2565
|
+
RequestOptions(
|
|
2566
|
+
method="POST",
|
|
2567
|
+
path="/api/session",
|
|
2568
|
+
body={
|
|
2569
|
+
"id": id,
|
|
2570
|
+
"parentID": parent_id,
|
|
2571
|
+
"title": title,
|
|
2572
|
+
"agent": agent,
|
|
2573
|
+
"model": model,
|
|
2574
|
+
"location": self._location(location),
|
|
2575
|
+
"metadata": metadata,
|
|
2576
|
+
"permissions": permissions,
|
|
2577
|
+
},
|
|
2578
|
+
extra_headers=extra_headers,
|
|
2579
|
+
extra_query=extra_query,
|
|
2580
|
+
extra_body=extra_body,
|
|
2581
|
+
timeout=timeout,
|
|
2582
|
+
),
|
|
2583
|
+
response_type="SessionInfo",
|
|
2584
|
+
unwrap=True,
|
|
2585
|
+
),
|
|
2586
|
+
)
|
|
2587
|
+
|
|
2588
|
+
async def import_(
|
|
2589
|
+
self,
|
|
2590
|
+
*,
|
|
2591
|
+
info: SessionInfo,
|
|
2592
|
+
messages: Sequence[Any],
|
|
2593
|
+
location: LocationPublicRef | NotGiven | None = NOT_GIVEN,
|
|
2594
|
+
extra_headers: Headers | None = None,
|
|
2595
|
+
extra_query: Query | None = None,
|
|
2596
|
+
extra_body: Body | None = None,
|
|
2597
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
2598
|
+
) -> SessionInfo:
|
|
2599
|
+
"""Import session.
|
|
2600
|
+
|
|
2601
|
+
Import a projected session transcript at the requested location. Accepts transcripts exported by earlier releases. If parentID is supplied, the parent session must already exist; import parents before children.
|
|
2602
|
+
|
|
2603
|
+
This endpoint is experimental in OpenCode and may change without notice.
|
|
2604
|
+
|
|
2605
|
+
Raises:
|
|
2606
|
+
InvalidRequestError: The server answered 400.
|
|
2607
|
+
UnauthorizedError: The server answered 401.
|
|
2608
|
+
SessionNotFoundError: The server answered 404.
|
|
2609
|
+
ConflictError: The server answered 409.
|
|
2610
|
+
|
|
2611
|
+
``POST /api/experimental/session/import``
|
|
2612
|
+
"""
|
|
2613
|
+
return cast(
|
|
2614
|
+
"SessionInfo",
|
|
2615
|
+
await self._client.request(
|
|
2616
|
+
RequestOptions(
|
|
2617
|
+
method="POST",
|
|
2618
|
+
path="/api/experimental/session/import",
|
|
2619
|
+
body={"info": info, "messages": messages, "location": self._location(location)},
|
|
2620
|
+
extra_headers=extra_headers,
|
|
2621
|
+
extra_query=extra_query,
|
|
2622
|
+
extra_body=extra_body,
|
|
2623
|
+
timeout=timeout,
|
|
2624
|
+
),
|
|
2625
|
+
response_type="SessionInfo",
|
|
2626
|
+
unwrap=True,
|
|
2627
|
+
),
|
|
2628
|
+
)
|
|
2629
|
+
|
|
2630
|
+
async def export(
|
|
2631
|
+
self,
|
|
2632
|
+
session_id: SessionID,
|
|
2633
|
+
*,
|
|
2634
|
+
sanitize: bool | NotGiven | None = NOT_GIVEN,
|
|
2635
|
+
extra_headers: Headers | None = None,
|
|
2636
|
+
extra_query: Query | None = None,
|
|
2637
|
+
extra_body: Body | None = None,
|
|
2638
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
2639
|
+
) -> SessionTransferData:
|
|
2640
|
+
"""Export session.
|
|
2641
|
+
|
|
2642
|
+
Export a complete projected session transcript.
|
|
2643
|
+
|
|
2644
|
+
This endpoint is experimental in OpenCode and may change without notice.
|
|
2645
|
+
|
|
2646
|
+
Raises:
|
|
2647
|
+
InvalidRequestError: The server answered 400.
|
|
2648
|
+
UnauthorizedError: The server answered 401.
|
|
2649
|
+
SessionNotFoundError: The server answered 404.
|
|
2650
|
+
UnknownError: The server answered 500.
|
|
2651
|
+
|
|
2652
|
+
``GET /api/experimental/session/:sessionID/export``
|
|
2653
|
+
"""
|
|
2654
|
+
return cast(
|
|
2655
|
+
"SessionTransferData",
|
|
2656
|
+
await self._client.request(
|
|
2657
|
+
RequestOptions(
|
|
2658
|
+
method="GET",
|
|
2659
|
+
path=f"/api/experimental/session/{encode_path_segment(session_id)}/export",
|
|
2660
|
+
query={"sanitize": sanitize},
|
|
2661
|
+
extra_headers=extra_headers,
|
|
2662
|
+
extra_query=extra_query,
|
|
2663
|
+
extra_body=extra_body,
|
|
2664
|
+
timeout=timeout,
|
|
2665
|
+
),
|
|
2666
|
+
response_type="SessionTransferData",
|
|
2667
|
+
unwrap=True,
|
|
2668
|
+
),
|
|
2669
|
+
)
|
|
2670
|
+
|
|
2671
|
+
async def active(
|
|
2672
|
+
self,
|
|
2673
|
+
*,
|
|
2674
|
+
extra_headers: Headers | None = None,
|
|
2675
|
+
extra_query: Query | None = None,
|
|
2676
|
+
extra_body: Body | None = None,
|
|
2677
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
2678
|
+
) -> builtins.dict[str, Any]:
|
|
2679
|
+
"""List active sessions.
|
|
2680
|
+
|
|
2681
|
+
Retrieve foreground Session drains currently owned by this OpenCode process. Sessions absent from the result are inactive.
|
|
2682
|
+
|
|
2683
|
+
Raises:
|
|
2684
|
+
InvalidRequestError: The server answered 400.
|
|
2685
|
+
UnauthorizedError: The server answered 401.
|
|
2686
|
+
|
|
2687
|
+
``GET /api/session/active``
|
|
2688
|
+
"""
|
|
2689
|
+
return cast(
|
|
2690
|
+
"builtins.dict[str, Any]",
|
|
2691
|
+
await self._client.request(
|
|
2692
|
+
RequestOptions(
|
|
2693
|
+
method="GET",
|
|
2694
|
+
path="/api/session/active",
|
|
2695
|
+
extra_headers=extra_headers,
|
|
2696
|
+
extra_query=extra_query,
|
|
2697
|
+
extra_body=extra_body,
|
|
2698
|
+
timeout=timeout,
|
|
2699
|
+
),
|
|
2700
|
+
response_type="builtins.dict[str, Any]",
|
|
2701
|
+
unwrap=True,
|
|
2702
|
+
),
|
|
2703
|
+
)
|
|
2704
|
+
|
|
2705
|
+
async def get(
|
|
2706
|
+
self,
|
|
2707
|
+
session_id: SessionID,
|
|
2708
|
+
*,
|
|
2709
|
+
extra_headers: Headers | None = None,
|
|
2710
|
+
extra_query: Query | None = None,
|
|
2711
|
+
extra_body: Body | None = None,
|
|
2712
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
2713
|
+
) -> SessionInfo:
|
|
2714
|
+
"""Get session.
|
|
2715
|
+
|
|
2716
|
+
Retrieve a session by ID.
|
|
2717
|
+
|
|
2718
|
+
Raises:
|
|
2719
|
+
InvalidRequestError: The server answered 400.
|
|
2720
|
+
UnauthorizedError: The server answered 401.
|
|
2721
|
+
SessionNotFoundError: The server answered 404.
|
|
2722
|
+
|
|
2723
|
+
``GET /api/session/:sessionID``
|
|
2724
|
+
"""
|
|
2725
|
+
return cast(
|
|
2726
|
+
"SessionInfo",
|
|
2727
|
+
await self._client.request(
|
|
2728
|
+
RequestOptions(
|
|
2729
|
+
method="GET",
|
|
2730
|
+
path=f"/api/session/{encode_path_segment(session_id)}",
|
|
2731
|
+
extra_headers=extra_headers,
|
|
2732
|
+
extra_query=extra_query,
|
|
2733
|
+
extra_body=extra_body,
|
|
2734
|
+
timeout=timeout,
|
|
2735
|
+
),
|
|
2736
|
+
response_type="SessionInfo",
|
|
2737
|
+
unwrap=True,
|
|
2738
|
+
),
|
|
2739
|
+
)
|
|
2740
|
+
|
|
2741
|
+
async def remove(
|
|
2742
|
+
self,
|
|
2743
|
+
session_id: SessionID,
|
|
2744
|
+
*,
|
|
2745
|
+
extra_headers: Headers | None = None,
|
|
2746
|
+
extra_query: Query | None = None,
|
|
2747
|
+
extra_body: Body | None = None,
|
|
2748
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
2749
|
+
) -> None:
|
|
2750
|
+
"""Delete session.
|
|
2751
|
+
|
|
2752
|
+
Delete a session and its child sessions.
|
|
2753
|
+
|
|
2754
|
+
Raises:
|
|
2755
|
+
InvalidRequestError: The server answered 400.
|
|
2756
|
+
UnauthorizedError: The server answered 401.
|
|
2757
|
+
SessionNotFoundError: The server answered 404.
|
|
2758
|
+
|
|
2759
|
+
``DELETE /api/session/:sessionID``
|
|
2760
|
+
"""
|
|
2761
|
+
await self._client.request(
|
|
2762
|
+
RequestOptions(
|
|
2763
|
+
method="DELETE",
|
|
2764
|
+
path=f"/api/session/{encode_path_segment(session_id)}",
|
|
2765
|
+
extra_headers=extra_headers,
|
|
2766
|
+
extra_query=extra_query,
|
|
2767
|
+
extra_body=extra_body,
|
|
2768
|
+
timeout=timeout,
|
|
2769
|
+
),
|
|
2770
|
+
kind="void",
|
|
2771
|
+
)
|
|
2772
|
+
|
|
2773
|
+
async def fork(
|
|
2774
|
+
self,
|
|
2775
|
+
session_id: SessionID,
|
|
2776
|
+
*,
|
|
2777
|
+
before: SessionMessageID | NotGiven | None = NOT_GIVEN,
|
|
2778
|
+
extra_headers: Headers | None = None,
|
|
2779
|
+
extra_query: Query | None = None,
|
|
2780
|
+
extra_body: Body | None = None,
|
|
2781
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
2782
|
+
) -> SessionInfo:
|
|
2783
|
+
"""Fork session.
|
|
2784
|
+
|
|
2785
|
+
Create a child session by copying projected history before a message. Omit before to copy the full history.
|
|
2786
|
+
|
|
2787
|
+
Raises:
|
|
2788
|
+
InvalidRequestError: The server answered 400.
|
|
2789
|
+
UnauthorizedError: The server answered 401.
|
|
2790
|
+
SessionNotFoundError: The server answered 404.
|
|
2791
|
+
MessageNotFoundError: The server answered 404.
|
|
2792
|
+
LocationNotFoundError: The server answered 404.
|
|
2793
|
+
|
|
2794
|
+
``POST /api/session/:sessionID/fork``
|
|
2795
|
+
"""
|
|
2796
|
+
return cast(
|
|
2797
|
+
"SessionInfo",
|
|
2798
|
+
await self._client.request(
|
|
2799
|
+
RequestOptions(
|
|
2800
|
+
method="POST",
|
|
2801
|
+
path=f"/api/session/{encode_path_segment(session_id)}/fork",
|
|
2802
|
+
body={"before": before},
|
|
2803
|
+
extra_headers=extra_headers,
|
|
2804
|
+
extra_query=extra_query,
|
|
2805
|
+
extra_body=extra_body,
|
|
2806
|
+
timeout=timeout,
|
|
2807
|
+
),
|
|
2808
|
+
response_type="SessionInfo",
|
|
2809
|
+
unwrap=True,
|
|
2810
|
+
),
|
|
2811
|
+
)
|
|
2812
|
+
|
|
2813
|
+
async def switch_agent(
|
|
2814
|
+
self,
|
|
2815
|
+
session_id: SessionID,
|
|
2816
|
+
*,
|
|
2817
|
+
agent: AgentID,
|
|
2818
|
+
extra_headers: Headers | None = None,
|
|
2819
|
+
extra_query: Query | None = None,
|
|
2820
|
+
extra_body: Body | None = None,
|
|
2821
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
2822
|
+
) -> None:
|
|
2823
|
+
"""Switch session agent.
|
|
2824
|
+
|
|
2825
|
+
Switch the agent used by subsequent provider turns.
|
|
2826
|
+
|
|
2827
|
+
Raises:
|
|
2828
|
+
InvalidRequestError: The server answered 400.
|
|
2829
|
+
UnauthorizedError: The server answered 401.
|
|
2830
|
+
SessionNotFoundError: The server answered 404.
|
|
2831
|
+
LocationNotFoundError: The server answered 404.
|
|
2832
|
+
|
|
2833
|
+
``POST /api/session/:sessionID/agent``
|
|
2834
|
+
"""
|
|
2835
|
+
await self._client.request(
|
|
2836
|
+
RequestOptions(
|
|
2837
|
+
method="POST",
|
|
2838
|
+
path=f"/api/session/{encode_path_segment(session_id)}/agent",
|
|
2839
|
+
body={"agent": agent},
|
|
2840
|
+
extra_headers=extra_headers,
|
|
2841
|
+
extra_query=extra_query,
|
|
2842
|
+
extra_body=extra_body,
|
|
2843
|
+
timeout=timeout,
|
|
2844
|
+
),
|
|
2845
|
+
kind="void",
|
|
2846
|
+
)
|
|
2847
|
+
|
|
2848
|
+
async def switch_model(
|
|
2849
|
+
self,
|
|
2850
|
+
session_id: SessionID,
|
|
2851
|
+
*,
|
|
2852
|
+
model: ModelRef,
|
|
2853
|
+
extra_headers: Headers | None = None,
|
|
2854
|
+
extra_query: Query | None = None,
|
|
2855
|
+
extra_body: Body | None = None,
|
|
2856
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
2857
|
+
) -> None:
|
|
2858
|
+
"""Switch session model.
|
|
2859
|
+
|
|
2860
|
+
Switch the model used by subsequent provider turns.
|
|
2861
|
+
|
|
2862
|
+
Raises:
|
|
2863
|
+
InvalidRequestError: The server answered 400.
|
|
2864
|
+
UnauthorizedError: The server answered 401.
|
|
2865
|
+
SessionNotFoundError: The server answered 404.
|
|
2866
|
+
LocationNotFoundError: The server answered 404.
|
|
2867
|
+
|
|
2868
|
+
``POST /api/session/:sessionID/model``
|
|
2869
|
+
"""
|
|
2870
|
+
await self._client.request(
|
|
2871
|
+
RequestOptions(
|
|
2872
|
+
method="POST",
|
|
2873
|
+
path=f"/api/session/{encode_path_segment(session_id)}/model",
|
|
2874
|
+
body={"model": model},
|
|
2875
|
+
extra_headers=extra_headers,
|
|
2876
|
+
extra_query=extra_query,
|
|
2877
|
+
extra_body=extra_body,
|
|
2878
|
+
timeout=timeout,
|
|
2879
|
+
),
|
|
2880
|
+
kind="void",
|
|
2881
|
+
)
|
|
2882
|
+
|
|
2883
|
+
async def update(
|
|
2884
|
+
self,
|
|
2885
|
+
session_id: SessionID,
|
|
2886
|
+
*,
|
|
2887
|
+
title: str | NotGiven | None = NOT_GIVEN,
|
|
2888
|
+
metadata: SessionMetadata | NotGiven | None = NOT_GIVEN,
|
|
2889
|
+
permissions: PermissionRuleset | NotGiven | None = NOT_GIVEN,
|
|
2890
|
+
archived: bool | NotGiven | None = NOT_GIVEN,
|
|
2891
|
+
extra_headers: Headers | None = None,
|
|
2892
|
+
extra_query: Query | None = None,
|
|
2893
|
+
extra_body: Body | None = None,
|
|
2894
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
2895
|
+
) -> None:
|
|
2896
|
+
"""Update session.
|
|
2897
|
+
|
|
2898
|
+
Update mutable session properties.
|
|
2899
|
+
|
|
2900
|
+
Args:
|
|
2901
|
+
archived: Archive the session with true or restore it with false. Repeating the current state is a no-op.
|
|
2902
|
+
|
|
2903
|
+
Raises:
|
|
2904
|
+
InvalidRequestError: The server answered 400.
|
|
2905
|
+
UnauthorizedError: The server answered 401.
|
|
2906
|
+
SessionNotFoundError: The server answered 404.
|
|
2907
|
+
LocationNotFoundError: The server answered 404.
|
|
2908
|
+
|
|
2909
|
+
``PATCH /api/session/:sessionID``
|
|
2910
|
+
"""
|
|
2911
|
+
await self._client.request(
|
|
2912
|
+
RequestOptions(
|
|
2913
|
+
method="PATCH",
|
|
2914
|
+
path=f"/api/session/{encode_path_segment(session_id)}",
|
|
2915
|
+
body={"title": title, "metadata": metadata, "permissions": permissions, "archived": archived},
|
|
2916
|
+
extra_headers=extra_headers,
|
|
2917
|
+
extra_query=extra_query,
|
|
2918
|
+
extra_body=extra_body,
|
|
2919
|
+
timeout=timeout,
|
|
2920
|
+
),
|
|
2921
|
+
kind="void",
|
|
2922
|
+
)
|
|
2923
|
+
|
|
2924
|
+
async def move(
|
|
2925
|
+
self,
|
|
2926
|
+
session_id: SessionID,
|
|
2927
|
+
*,
|
|
2928
|
+
directory: AbsolutePath,
|
|
2929
|
+
delivery: SessionInboxDelivery | NotGiven | None = NOT_GIVEN,
|
|
2930
|
+
extra_headers: Headers | None = None,
|
|
2931
|
+
extra_query: Query | None = None,
|
|
2932
|
+
extra_body: Body | None = None,
|
|
2933
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
2934
|
+
) -> None:
|
|
2935
|
+
"""Move session.
|
|
2936
|
+
|
|
2937
|
+
Move a session to another project directory at the requested delivery boundary.
|
|
2938
|
+
|
|
2939
|
+
Raises:
|
|
2940
|
+
InvalidRequestError: The server answered 400.
|
|
2941
|
+
UnauthorizedError: The server answered 401.
|
|
2942
|
+
SessionNotFoundError: The server answered 404.
|
|
2943
|
+
|
|
2944
|
+
``POST /api/session/:sessionID/move``
|
|
2945
|
+
"""
|
|
2946
|
+
await self._client.request(
|
|
2947
|
+
RequestOptions(
|
|
2948
|
+
method="POST",
|
|
2949
|
+
path=f"/api/session/{encode_path_segment(session_id)}/move",
|
|
2950
|
+
body={"directory": directory, "delivery": delivery},
|
|
2951
|
+
extra_headers=extra_headers,
|
|
2952
|
+
extra_query=extra_query,
|
|
2953
|
+
extra_body=extra_body,
|
|
2954
|
+
timeout=timeout,
|
|
2955
|
+
),
|
|
2956
|
+
kind="void",
|
|
2957
|
+
)
|
|
2958
|
+
|
|
2959
|
+
async def prompt(
|
|
2960
|
+
self,
|
|
2961
|
+
session_id: SessionID,
|
|
2962
|
+
*,
|
|
2963
|
+
text: str,
|
|
2964
|
+
id: SessionMessageID | NotGiven | None = NOT_GIVEN,
|
|
2965
|
+
files: Sequence[PromptInputFileAttachment] | NotGiven = NOT_GIVEN,
|
|
2966
|
+
agents: Sequence[PromptAgentAttachment] | NotGiven = NOT_GIVEN,
|
|
2967
|
+
skills: Sequence[PromptInputSkillAttachment] | NotGiven = NOT_GIVEN,
|
|
2968
|
+
metadata: Mapping[str, Any] | NotGiven = NOT_GIVEN,
|
|
2969
|
+
delivery: SessionInboxDelivery | NotGiven | None = NOT_GIVEN,
|
|
2970
|
+
resume: bool | NotGiven | None = NOT_GIVEN,
|
|
2971
|
+
extra_headers: Headers | None = None,
|
|
2972
|
+
extra_query: Query | None = None,
|
|
2973
|
+
extra_body: Body | None = None,
|
|
2974
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
2975
|
+
) -> SessionInboxUser:
|
|
2976
|
+
"""Send message.
|
|
2977
|
+
|
|
2978
|
+
Durably admit one session input and schedule agent-loop execution unless resume is false.
|
|
2979
|
+
|
|
2980
|
+
Raises:
|
|
2981
|
+
InvalidRequestError: The server answered 400.
|
|
2982
|
+
UnauthorizedError: The server answered 401.
|
|
2983
|
+
SessionNotFoundError: The server answered 404.
|
|
2984
|
+
LocationNotFoundError: The server answered 404.
|
|
2985
|
+
ConflictError: The server answered 409.
|
|
2986
|
+
|
|
2987
|
+
``POST /api/session/:sessionID/prompt``
|
|
2988
|
+
"""
|
|
2989
|
+
return cast(
|
|
2990
|
+
"SessionInboxUser",
|
|
2991
|
+
await self._client.request(
|
|
2992
|
+
RequestOptions(
|
|
2993
|
+
method="POST",
|
|
2994
|
+
path=f"/api/session/{encode_path_segment(session_id)}/prompt",
|
|
2995
|
+
body={
|
|
2996
|
+
"id": id,
|
|
2997
|
+
"text": text,
|
|
2998
|
+
"files": files,
|
|
2999
|
+
"agents": agents,
|
|
3000
|
+
"skills": skills,
|
|
3001
|
+
"metadata": metadata,
|
|
3002
|
+
"delivery": delivery,
|
|
3003
|
+
"resume": resume,
|
|
3004
|
+
},
|
|
3005
|
+
extra_headers=extra_headers,
|
|
3006
|
+
extra_query=extra_query,
|
|
3007
|
+
extra_body=extra_body,
|
|
3008
|
+
timeout=timeout,
|
|
3009
|
+
),
|
|
3010
|
+
response_type="SessionInboxUser",
|
|
3011
|
+
unwrap=True,
|
|
3012
|
+
),
|
|
3013
|
+
)
|
|
3014
|
+
|
|
3015
|
+
async def command(
|
|
3016
|
+
self,
|
|
3017
|
+
session_id: SessionID,
|
|
3018
|
+
*,
|
|
3019
|
+
name: str,
|
|
3020
|
+
text: str,
|
|
3021
|
+
files: Sequence[PromptInputFileAttachment] | NotGiven = NOT_GIVEN,
|
|
3022
|
+
agents: Sequence[PromptAgentAttachment] | NotGiven = NOT_GIVEN,
|
|
3023
|
+
skills: Sequence[PromptInputSkillAttachment] | NotGiven = NOT_GIVEN,
|
|
3024
|
+
delivery: SessionInboxDelivery | NotGiven | None = NOT_GIVEN,
|
|
3025
|
+
extra_headers: Headers | None = None,
|
|
3026
|
+
extra_query: Query | None = None,
|
|
3027
|
+
extra_body: Body | None = None,
|
|
3028
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
3029
|
+
) -> None:
|
|
3030
|
+
"""Run command.
|
|
3031
|
+
|
|
3032
|
+
Execute a slash command callback immediately.
|
|
3033
|
+
|
|
3034
|
+
Raises:
|
|
3035
|
+
InvalidRequestError: The server answered 400.
|
|
3036
|
+
UnauthorizedError: The server answered 401.
|
|
3037
|
+
SessionNotFoundError: The server answered 404.
|
|
3038
|
+
CommandNotFoundError: The server answered 404.
|
|
3039
|
+
LocationNotFoundError: The server answered 404.
|
|
3040
|
+
CommandExecutionError: The server answered 500.
|
|
3041
|
+
|
|
3042
|
+
``POST /api/session/:sessionID/command``
|
|
3043
|
+
"""
|
|
3044
|
+
await self._client.request(
|
|
3045
|
+
RequestOptions(
|
|
3046
|
+
method="POST",
|
|
3047
|
+
path=f"/api/session/{encode_path_segment(session_id)}/command",
|
|
3048
|
+
body={
|
|
3049
|
+
"name": name,
|
|
3050
|
+
"text": text,
|
|
3051
|
+
"files": files,
|
|
3052
|
+
"agents": agents,
|
|
3053
|
+
"skills": skills,
|
|
3054
|
+
"delivery": delivery,
|
|
3055
|
+
},
|
|
3056
|
+
extra_headers=extra_headers,
|
|
3057
|
+
extra_query=extra_query,
|
|
3058
|
+
extra_body=extra_body,
|
|
3059
|
+
timeout=timeout,
|
|
3060
|
+
),
|
|
3061
|
+
kind="void",
|
|
3062
|
+
)
|
|
3063
|
+
|
|
3064
|
+
async def skill(
|
|
3065
|
+
self,
|
|
3066
|
+
session_id: SessionID,
|
|
3067
|
+
*,
|
|
3068
|
+
id: SkillID,
|
|
3069
|
+
resume: bool | NotGiven | None = NOT_GIVEN,
|
|
3070
|
+
extra_headers: Headers | None = None,
|
|
3071
|
+
extra_query: Query | None = None,
|
|
3072
|
+
extra_body: Body | None = None,
|
|
3073
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
3074
|
+
) -> None:
|
|
3075
|
+
"""Activate skill.
|
|
3076
|
+
|
|
3077
|
+
Activate a skill for a session by appending a skill message and resuming execution.
|
|
3078
|
+
|
|
3079
|
+
This endpoint is experimental in OpenCode and may change without notice.
|
|
3080
|
+
|
|
3081
|
+
Raises:
|
|
3082
|
+
InvalidRequestError: The server answered 400.
|
|
3083
|
+
UnauthorizedError: The server answered 401.
|
|
3084
|
+
SessionNotFoundError: The server answered 404.
|
|
3085
|
+
SkillNotFoundError: The server answered 404.
|
|
3086
|
+
LocationNotFoundError: The server answered 404.
|
|
3087
|
+
|
|
3088
|
+
``POST /api/experimental/session/:sessionID/skill``
|
|
3089
|
+
"""
|
|
3090
|
+
await self._client.request(
|
|
3091
|
+
RequestOptions(
|
|
3092
|
+
method="POST",
|
|
3093
|
+
path=f"/api/experimental/session/{encode_path_segment(session_id)}/skill",
|
|
3094
|
+
body={"id": id, "resume": resume},
|
|
3095
|
+
extra_headers=extra_headers,
|
|
3096
|
+
extra_query=extra_query,
|
|
3097
|
+
extra_body=extra_body,
|
|
3098
|
+
timeout=timeout,
|
|
3099
|
+
),
|
|
3100
|
+
kind="void",
|
|
3101
|
+
)
|
|
3102
|
+
|
|
3103
|
+
async def synthetic(
|
|
3104
|
+
self,
|
|
3105
|
+
session_id: SessionID,
|
|
3106
|
+
*,
|
|
3107
|
+
text: str,
|
|
3108
|
+
id: SessionMessageID | NotGiven | None = NOT_GIVEN,
|
|
3109
|
+
description: str | NotGiven | None = NOT_GIVEN,
|
|
3110
|
+
metadata: Mapping[str, Any] | NotGiven = NOT_GIVEN,
|
|
3111
|
+
delivery: SessionInboxDelivery | NotGiven | None = NOT_GIVEN,
|
|
3112
|
+
resume: bool | NotGiven | None = NOT_GIVEN,
|
|
3113
|
+
extra_headers: Headers | None = None,
|
|
3114
|
+
extra_query: Query | None = None,
|
|
3115
|
+
extra_body: Body | None = None,
|
|
3116
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
3117
|
+
) -> SessionInboxSynthetic:
|
|
3118
|
+
"""Add synthetic message.
|
|
3119
|
+
|
|
3120
|
+
Durably admit synthetic session input and schedule execution unless resume is false.
|
|
3121
|
+
|
|
3122
|
+
Raises:
|
|
3123
|
+
InvalidRequestError: The server answered 400.
|
|
3124
|
+
UnauthorizedError: The server answered 401.
|
|
3125
|
+
SessionNotFoundError: The server answered 404.
|
|
3126
|
+
LocationNotFoundError: The server answered 404.
|
|
3127
|
+
ConflictError: The server answered 409.
|
|
3128
|
+
|
|
3129
|
+
``POST /api/session/:sessionID/synthetic``
|
|
3130
|
+
"""
|
|
3131
|
+
return cast(
|
|
3132
|
+
"SessionInboxSynthetic",
|
|
3133
|
+
await self._client.request(
|
|
3134
|
+
RequestOptions(
|
|
3135
|
+
method="POST",
|
|
3136
|
+
path=f"/api/session/{encode_path_segment(session_id)}/synthetic",
|
|
3137
|
+
body={
|
|
3138
|
+
"id": id,
|
|
3139
|
+
"text": text,
|
|
3140
|
+
"description": description,
|
|
3141
|
+
"metadata": metadata,
|
|
3142
|
+
"delivery": delivery,
|
|
3143
|
+
"resume": resume,
|
|
3144
|
+
},
|
|
3145
|
+
extra_headers=extra_headers,
|
|
3146
|
+
extra_query=extra_query,
|
|
3147
|
+
extra_body=extra_body,
|
|
3148
|
+
timeout=timeout,
|
|
3149
|
+
),
|
|
3150
|
+
response_type="SessionInboxSynthetic",
|
|
3151
|
+
unwrap=True,
|
|
3152
|
+
),
|
|
3153
|
+
)
|
|
3154
|
+
|
|
3155
|
+
async def shell(
|
|
3156
|
+
self,
|
|
3157
|
+
session_id: SessionID,
|
|
3158
|
+
*,
|
|
3159
|
+
command: str,
|
|
3160
|
+
id: SessionMessageID | NotGiven | None = NOT_GIVEN,
|
|
3161
|
+
extra_headers: Headers | None = None,
|
|
3162
|
+
extra_query: Query | None = None,
|
|
3163
|
+
extra_body: Body | None = None,
|
|
3164
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
3165
|
+
) -> None:
|
|
3166
|
+
"""Run shell command.
|
|
3167
|
+
|
|
3168
|
+
Execute one shell command in the session's working directory. Emits a shell.started event before execution and a shell.ended event with the merged output after.
|
|
3169
|
+
|
|
3170
|
+
Raises:
|
|
3171
|
+
InvalidRequestError: The server answered 400.
|
|
3172
|
+
UnauthorizedError: The server answered 401.
|
|
3173
|
+
SessionNotFoundError: The server answered 404.
|
|
3174
|
+
LocationNotFoundError: The server answered 404.
|
|
3175
|
+
|
|
3176
|
+
``POST /api/session/:sessionID/shell``
|
|
3177
|
+
"""
|
|
3178
|
+
await self._client.request(
|
|
3179
|
+
RequestOptions(
|
|
3180
|
+
method="POST",
|
|
3181
|
+
path=f"/api/session/{encode_path_segment(session_id)}/shell",
|
|
3182
|
+
body={"id": id, "command": command},
|
|
3183
|
+
extra_headers=extra_headers,
|
|
3184
|
+
extra_query=extra_query,
|
|
3185
|
+
extra_body=extra_body,
|
|
3186
|
+
timeout=timeout,
|
|
3187
|
+
),
|
|
3188
|
+
kind="void",
|
|
3189
|
+
)
|
|
3190
|
+
|
|
3191
|
+
async def compact(
|
|
3192
|
+
self,
|
|
3193
|
+
session_id: SessionID,
|
|
3194
|
+
*,
|
|
3195
|
+
id: SessionMessageID | NotGiven | None = NOT_GIVEN,
|
|
3196
|
+
delivery: SessionInboxDelivery | NotGiven | None = NOT_GIVEN,
|
|
3197
|
+
extra_headers: Headers | None = None,
|
|
3198
|
+
extra_query: Query | None = None,
|
|
3199
|
+
extra_body: Body | None = None,
|
|
3200
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
3201
|
+
) -> SessionInboxCompaction:
|
|
3202
|
+
"""Compact session.
|
|
3203
|
+
|
|
3204
|
+
Durably admit a session compaction request. Steers by default: it runs at the next step boundary instead of waiting behind queued prompts.
|
|
3205
|
+
|
|
3206
|
+
Raises:
|
|
3207
|
+
InvalidRequestError: The server answered 400.
|
|
3208
|
+
UnauthorizedError: The server answered 401.
|
|
3209
|
+
SessionNotFoundError: The server answered 404.
|
|
3210
|
+
LocationNotFoundError: The server answered 404.
|
|
3211
|
+
ConflictError: The server answered 409.
|
|
3212
|
+
|
|
3213
|
+
``POST /api/session/:sessionID/compact``
|
|
3214
|
+
"""
|
|
3215
|
+
return cast(
|
|
3216
|
+
"SessionInboxCompaction",
|
|
3217
|
+
await self._client.request(
|
|
3218
|
+
RequestOptions(
|
|
3219
|
+
method="POST",
|
|
3220
|
+
path=f"/api/session/{encode_path_segment(session_id)}/compact",
|
|
3221
|
+
body={"id": id, "delivery": delivery},
|
|
3222
|
+
extra_headers=extra_headers,
|
|
3223
|
+
extra_query=extra_query,
|
|
3224
|
+
extra_body=extra_body,
|
|
3225
|
+
timeout=timeout,
|
|
3226
|
+
),
|
|
3227
|
+
response_type="SessionInboxCompaction",
|
|
3228
|
+
unwrap=True,
|
|
3229
|
+
),
|
|
3230
|
+
)
|
|
3231
|
+
|
|
3232
|
+
async def wait(
|
|
3233
|
+
self,
|
|
3234
|
+
session_id: SessionID,
|
|
3235
|
+
*,
|
|
3236
|
+
extra_headers: Headers | None = None,
|
|
3237
|
+
extra_query: Query | None = None,
|
|
3238
|
+
extra_body: Body | None = None,
|
|
3239
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
3240
|
+
) -> None:
|
|
3241
|
+
"""Wait for session.
|
|
3242
|
+
|
|
3243
|
+
Wait for a session agent loop to become idle.
|
|
3244
|
+
|
|
3245
|
+
This endpoint is experimental in OpenCode and may change without notice.
|
|
3246
|
+
|
|
3247
|
+
Raises:
|
|
3248
|
+
InvalidRequestError: The server answered 400.
|
|
3249
|
+
UnauthorizedError: The server answered 401.
|
|
3250
|
+
SessionNotFoundError: The server answered 404.
|
|
3251
|
+
LocationNotFoundError: The server answered 404.
|
|
3252
|
+
ServiceUnavailableError: The server answered 503.
|
|
3253
|
+
|
|
3254
|
+
``POST /api/experimental/session/:sessionID/wait``
|
|
3255
|
+
"""
|
|
3256
|
+
await self._client.request(
|
|
3257
|
+
RequestOptions(
|
|
3258
|
+
method="POST",
|
|
3259
|
+
path=f"/api/experimental/session/{encode_path_segment(session_id)}/wait",
|
|
3260
|
+
extra_headers=extra_headers,
|
|
3261
|
+
extra_query=extra_query,
|
|
3262
|
+
extra_body=extra_body,
|
|
3263
|
+
timeout=timeout,
|
|
3264
|
+
),
|
|
3265
|
+
kind="void",
|
|
3266
|
+
)
|
|
3267
|
+
|
|
3268
|
+
async def context(
|
|
3269
|
+
self,
|
|
3270
|
+
session_id: SessionID,
|
|
3271
|
+
*,
|
|
3272
|
+
extra_headers: Headers | None = None,
|
|
3273
|
+
extra_query: Query | None = None,
|
|
3274
|
+
extra_body: Body | None = None,
|
|
3275
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
3276
|
+
) -> builtins.list[SessionMessageInfo]:
|
|
3277
|
+
"""Get session context.
|
|
3278
|
+
|
|
3279
|
+
Retrieve the active context messages for a session (all messages after the last compaction).
|
|
3280
|
+
|
|
3281
|
+
Raises:
|
|
3282
|
+
InvalidRequestError: The server answered 400.
|
|
3283
|
+
UnauthorizedError: The server answered 401.
|
|
3284
|
+
SessionNotFoundError: The server answered 404.
|
|
3285
|
+
UnknownError: The server answered 500.
|
|
3286
|
+
|
|
3287
|
+
``GET /api/session/:sessionID/context``
|
|
3288
|
+
"""
|
|
3289
|
+
return cast(
|
|
3290
|
+
"builtins.list[SessionMessageInfo]",
|
|
3291
|
+
await self._client.request(
|
|
3292
|
+
RequestOptions(
|
|
3293
|
+
method="GET",
|
|
3294
|
+
path=f"/api/session/{encode_path_segment(session_id)}/context",
|
|
3295
|
+
extra_headers=extra_headers,
|
|
3296
|
+
extra_query=extra_query,
|
|
3297
|
+
extra_body=extra_body,
|
|
3298
|
+
timeout=timeout,
|
|
3299
|
+
),
|
|
3300
|
+
response_type="builtins.list[SessionMessageInfo]",
|
|
3301
|
+
unwrap=True,
|
|
3302
|
+
),
|
|
3303
|
+
)
|
|
3304
|
+
|
|
3305
|
+
async def diff(
|
|
3306
|
+
self,
|
|
3307
|
+
session_id: SessionID,
|
|
3308
|
+
*,
|
|
3309
|
+
from_: SessionMessageID | NotGiven | None = NOT_GIVEN,
|
|
3310
|
+
to: SessionMessageID | NotGiven | None = NOT_GIVEN,
|
|
3311
|
+
context: int | NotGiven | None = NOT_GIVEN,
|
|
3312
|
+
extra_headers: Headers | None = None,
|
|
3313
|
+
extra_query: Query | None = None,
|
|
3314
|
+
extra_body: Body | None = None,
|
|
3315
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
3316
|
+
) -> builtins.list[FileDiffInfo]:
|
|
3317
|
+
"""Diff session turns.
|
|
3318
|
+
|
|
3319
|
+
Structured per-file diffs of the files a turn changed. A turn runs from the first prompt after the session was last idle until its next idle marker, so prompts steered in while it was busy belong to the same turn; `to` extends the range through a later turn. Compares the range's first recorded snapshot with its last; a step still running in the active session compares against the working copy. Ranges that span a location change are rejected. In sessions without any idle marker, a prompt's turn spans until the next user message.
|
|
3320
|
+
|
|
3321
|
+
Args:
|
|
3322
|
+
from_: User message whose turn to diff. Defaults to the turn of the newest user message.
|
|
3323
|
+
to: Later user message whose turn ends the range. Defaults to the turn of `from` alone.
|
|
3324
|
+
context: Unchanged lines around each hunk. Omit for full-file patches.
|
|
3325
|
+
|
|
3326
|
+
Raises:
|
|
3327
|
+
InvalidRequestError: The server answered 400.
|
|
3328
|
+
UnauthorizedError: The server answered 401.
|
|
3329
|
+
MessageNotFoundError: The server answered 404.
|
|
3330
|
+
SessionNotFoundError: The server answered 404.
|
|
3331
|
+
LocationNotFoundError: The server answered 404.
|
|
3332
|
+
UnknownError: The server answered 500.
|
|
3333
|
+
|
|
3334
|
+
``GET /api/session/:sessionID/diff``
|
|
3335
|
+
"""
|
|
3336
|
+
return cast(
|
|
3337
|
+
"builtins.list[FileDiffInfo]",
|
|
3338
|
+
await self._client.request(
|
|
3339
|
+
RequestOptions(
|
|
3340
|
+
method="GET",
|
|
3341
|
+
path=f"/api/session/{encode_path_segment(session_id)}/diff",
|
|
3342
|
+
query={"from": from_, "to": to, "context": context},
|
|
3343
|
+
extra_headers=extra_headers,
|
|
3344
|
+
extra_query=extra_query,
|
|
3345
|
+
extra_body=extra_body,
|
|
3346
|
+
timeout=timeout,
|
|
3347
|
+
),
|
|
3348
|
+
response_type="builtins.list[FileDiffInfo]",
|
|
3349
|
+
unwrap=True,
|
|
3350
|
+
),
|
|
3351
|
+
)
|
|
3352
|
+
|
|
3353
|
+
async def generate(
|
|
3354
|
+
self,
|
|
3355
|
+
session_id: SessionID,
|
|
3356
|
+
*,
|
|
3357
|
+
prompt: str,
|
|
3358
|
+
extra_headers: Headers | None = None,
|
|
3359
|
+
extra_query: Query | None = None,
|
|
3360
|
+
extra_body: Body | None = None,
|
|
3361
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
3362
|
+
) -> SessionGenerateResponseData:
|
|
3363
|
+
"""Generate text from session context.
|
|
3364
|
+
|
|
3365
|
+
Generate transient text from the current session context without mutating session history.
|
|
3366
|
+
|
|
3367
|
+
Raises:
|
|
3368
|
+
InvalidRequestError: The server answered 400.
|
|
3369
|
+
UnauthorizedError: The server answered 401.
|
|
3370
|
+
SessionNotFoundError: The server answered 404.
|
|
3371
|
+
LocationNotFoundError: The server answered 404.
|
|
3372
|
+
ServiceUnavailableError: The server answered 503.
|
|
3373
|
+
|
|
3374
|
+
``POST /api/session/:sessionID/generate``
|
|
3375
|
+
"""
|
|
3376
|
+
return cast(
|
|
3377
|
+
"SessionGenerateResponseData",
|
|
3378
|
+
await self._client.request(
|
|
3379
|
+
RequestOptions(
|
|
3380
|
+
method="POST",
|
|
3381
|
+
path=f"/api/session/{encode_path_segment(session_id)}/generate",
|
|
3382
|
+
body={"prompt": prompt},
|
|
3383
|
+
extra_headers=extra_headers,
|
|
3384
|
+
extra_query=extra_query,
|
|
3385
|
+
extra_body=extra_body,
|
|
3386
|
+
timeout=timeout,
|
|
3387
|
+
),
|
|
3388
|
+
response_type="SessionGenerateResponseData",
|
|
3389
|
+
unwrap=True,
|
|
3390
|
+
),
|
|
3391
|
+
)
|
|
3392
|
+
|
|
3393
|
+
async def log(
|
|
3394
|
+
self,
|
|
3395
|
+
session_id: SessionID,
|
|
3396
|
+
*,
|
|
3397
|
+
after: EventSeq | NotGiven | None = NOT_GIVEN,
|
|
3398
|
+
follow: bool | NotGiven | None = NOT_GIVEN,
|
|
3399
|
+
extra_headers: Headers | None = None,
|
|
3400
|
+
extra_query: Query | None = None,
|
|
3401
|
+
extra_body: Body | None = None,
|
|
3402
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
3403
|
+
) -> AsyncStream[SessionLogItem]:
|
|
3404
|
+
"""Read the session log.
|
|
3405
|
+
|
|
3406
|
+
Experimental durable session event log. Reads events after an exclusive aggregate sequence and continues with live events when follow=true.
|
|
3407
|
+
|
|
3408
|
+
This endpoint is experimental in OpenCode and may change without notice.
|
|
3409
|
+
|
|
3410
|
+
Raises:
|
|
3411
|
+
InvalidRequestError: The server answered 400.
|
|
3412
|
+
UnauthorizedError: The server answered 401.
|
|
3413
|
+
SessionNotFoundError: The server answered 404.
|
|
3414
|
+
|
|
3415
|
+
``GET /api/experimental/session/:sessionID/log``
|
|
3416
|
+
"""
|
|
3417
|
+
return await self._client.stream(
|
|
3418
|
+
RequestOptions(
|
|
3419
|
+
method="GET",
|
|
3420
|
+
path=f"/api/experimental/session/{encode_path_segment(session_id)}/log",
|
|
3421
|
+
query={"after": after, "follow": follow},
|
|
3422
|
+
extra_headers=extra_headers,
|
|
3423
|
+
extra_query=extra_query,
|
|
3424
|
+
extra_body=extra_body,
|
|
3425
|
+
timeout=timeout,
|
|
3426
|
+
),
|
|
3427
|
+
item_type="SessionLogItem",
|
|
3428
|
+
)
|
|
3429
|
+
|
|
3430
|
+
async def interrupt(
|
|
3431
|
+
self,
|
|
3432
|
+
session_id: SessionID,
|
|
3433
|
+
*,
|
|
3434
|
+
resume: bool | NotGiven | None = NOT_GIVEN,
|
|
3435
|
+
extra_headers: Headers | None = None,
|
|
3436
|
+
extra_query: Query | None = None,
|
|
3437
|
+
extra_body: Body | None = None,
|
|
3438
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
3439
|
+
) -> SessionInterruptResponse:
|
|
3440
|
+
"""Interrupt session execution.
|
|
3441
|
+
|
|
3442
|
+
Interrupt active execution owned by this OpenCode process. Returns interrupted=true when an active execution was interrupted and false for the idle no-op. When resume=true, execution resumes pending steering input and next-in-line control items (manual compaction, moves) while queued prompts remain parked.
|
|
3443
|
+
|
|
3444
|
+
Raises:
|
|
3445
|
+
InvalidRequestError: The server answered 400.
|
|
3446
|
+
UnauthorizedError: The server answered 401.
|
|
3447
|
+
SessionNotFoundError: The server answered 404.
|
|
3448
|
+
LocationNotFoundError: The server answered 404.
|
|
3449
|
+
|
|
3450
|
+
``POST /api/session/:sessionID/interrupt``
|
|
3451
|
+
"""
|
|
3452
|
+
return cast(
|
|
3453
|
+
"SessionInterruptResponse",
|
|
3454
|
+
await self._client.request(
|
|
3455
|
+
RequestOptions(
|
|
3456
|
+
method="POST",
|
|
3457
|
+
path=f"/api/session/{encode_path_segment(session_id)}/interrupt",
|
|
3458
|
+
query={"resume": resume},
|
|
3459
|
+
extra_headers=extra_headers,
|
|
3460
|
+
extra_query=extra_query,
|
|
3461
|
+
extra_body=extra_body,
|
|
3462
|
+
timeout=timeout,
|
|
3463
|
+
),
|
|
3464
|
+
response_type="SessionInterruptResponse",
|
|
3465
|
+
),
|
|
3466
|
+
)
|
|
3467
|
+
|
|
3468
|
+
async def background(
|
|
3469
|
+
self,
|
|
3470
|
+
session_id: SessionID,
|
|
3471
|
+
*,
|
|
3472
|
+
extra_headers: Headers | None = None,
|
|
3473
|
+
extra_query: Query | None = None,
|
|
3474
|
+
extra_body: Body | None = None,
|
|
3475
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
3476
|
+
) -> None:
|
|
3477
|
+
"""Background blocking session tools.
|
|
3478
|
+
|
|
3479
|
+
Move active foreground backgroundable tools for this session into background observation. Idle requests are a no-op.
|
|
3480
|
+
|
|
3481
|
+
Raises:
|
|
3482
|
+
InvalidRequestError: The server answered 400.
|
|
3483
|
+
UnauthorizedError: The server answered 401.
|
|
3484
|
+
SessionNotFoundError: The server answered 404.
|
|
3485
|
+
LocationNotFoundError: The server answered 404.
|
|
3486
|
+
|
|
3487
|
+
``POST /api/session/:sessionID/background``
|
|
3488
|
+
"""
|
|
3489
|
+
await self._client.request(
|
|
3490
|
+
RequestOptions(
|
|
3491
|
+
method="POST",
|
|
3492
|
+
path=f"/api/session/{encode_path_segment(session_id)}/background",
|
|
3493
|
+
extra_headers=extra_headers,
|
|
3494
|
+
extra_query=extra_query,
|
|
3495
|
+
extra_body=extra_body,
|
|
3496
|
+
timeout=timeout,
|
|
3497
|
+
),
|
|
3498
|
+
kind="void",
|
|
3499
|
+
)
|
|
3500
|
+
|
|
3501
|
+
async def environment(
|
|
3502
|
+
self,
|
|
3503
|
+
session_id: SessionID,
|
|
3504
|
+
*,
|
|
3505
|
+
variables: Mapping[str, str],
|
|
3506
|
+
extra_headers: Headers | None = None,
|
|
3507
|
+
extra_query: Query | None = None,
|
|
3508
|
+
extra_body: Body | None = None,
|
|
3509
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
3510
|
+
) -> None:
|
|
3511
|
+
"""Set session environment.
|
|
3512
|
+
|
|
3513
|
+
Replace the process environment used by local shell commands for this session.
|
|
3514
|
+
|
|
3515
|
+
Raises:
|
|
3516
|
+
InvalidRequestError: The server answered 400.
|
|
3517
|
+
UnauthorizedError: The server answered 401.
|
|
3518
|
+
SessionNotFoundError: The server answered 404.
|
|
3519
|
+
|
|
3520
|
+
``PUT /api/session/:sessionID/environment``
|
|
3521
|
+
"""
|
|
3522
|
+
await self._client.request(
|
|
3523
|
+
RequestOptions(
|
|
3524
|
+
method="PUT",
|
|
3525
|
+
path=f"/api/session/{encode_path_segment(session_id)}/environment",
|
|
3526
|
+
body={"variables": variables},
|
|
3527
|
+
extra_headers=extra_headers,
|
|
3528
|
+
extra_query=extra_query,
|
|
3529
|
+
extra_body=extra_body,
|
|
3530
|
+
timeout=timeout,
|
|
3531
|
+
),
|
|
3532
|
+
kind="void",
|
|
3533
|
+
)
|
|
3534
|
+
|
|
3535
|
+
async def view(
|
|
3536
|
+
self,
|
|
3537
|
+
session_id: SessionID,
|
|
3538
|
+
*,
|
|
3539
|
+
idle: float,
|
|
3540
|
+
extra_headers: Headers | None = None,
|
|
3541
|
+
extra_query: Query | None = None,
|
|
3542
|
+
extra_body: Body | None = None,
|
|
3543
|
+
timeout: Timeout | NotGiven = NOT_GIVEN,
|
|
3544
|
+
) -> None:
|
|
3545
|
+
"""View session.
|
|
3546
|
+
|
|
3547
|
+
Mark the idle transition observed by the viewer as viewed.
|
|
3548
|
+
|
|
3549
|
+
Raises:
|
|
3550
|
+
InvalidRequestError: The server answered 400.
|
|
3551
|
+
UnauthorizedError: The server answered 401.
|
|
3552
|
+
SessionNotFoundError: The server answered 404.
|
|
3553
|
+
|
|
3554
|
+
``POST /api/session/:sessionID/view``
|
|
3555
|
+
"""
|
|
3556
|
+
await self._client.request(
|
|
3557
|
+
RequestOptions(
|
|
3558
|
+
method="POST",
|
|
3559
|
+
path=f"/api/session/{encode_path_segment(session_id)}/view",
|
|
3560
|
+
body={"idle": idle},
|
|
3561
|
+
extra_headers=extra_headers,
|
|
3562
|
+
extra_query=extra_query,
|
|
3563
|
+
extra_body=extra_body,
|
|
3564
|
+
timeout=timeout,
|
|
3565
|
+
),
|
|
3566
|
+
kind="void",
|
|
3567
|
+
)
|