opencode-python-sdk 0.1.1__py3-none-any.whl → 0.1.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
opencode/__init__.py CHANGED
@@ -75,11 +75,39 @@ from ._exceptions import (
75
75
  )
76
76
  from ._models import BaseModel
77
77
  from ._pagination import AsyncCursorPage, AsyncPaginator, SyncCursorPage
78
+ from ._pty import AsyncPtyConnection, PtyConnection, PtyConnectionError
78
79
  from ._server import AsyncOpencodeServer, OpencodeServer, ServerStartError
79
80
  from ._streaming import AsyncStream, Stream
80
81
  from ._types import NOT_GIVEN, NotGiven
81
82
  from ._version import __version__
82
83
 
84
+ # isort: split
85
+ # Hand-written helpers, kept apart from the generated error-import block above.
86
+ from ._events import (
87
+ SUBSCRIBER_CAPACITY,
88
+ AsyncEventHub,
89
+ AsyncSubscription,
90
+ EventHub,
91
+ EventOverflowError,
92
+ Reconnect,
93
+ Subscription,
94
+ session_id_of,
95
+ )
96
+ from ._rpc import (
97
+ AsyncRpcClient,
98
+ AsyncRpcEvents,
99
+ RpcCallError,
100
+ RpcCallInternalError,
101
+ RpcClient,
102
+ RpcDefinition,
103
+ RpcEventDefinition,
104
+ RpcEventPayload,
105
+ RpcEvents,
106
+ RpcMethod,
107
+ rpc_event,
108
+ rpc_method,
109
+ )
110
+
83
111
  # <generated:api-version>
84
112
  API_VERSION = "2.1.2"
85
113
  """The OpenCode server version this client was generated from."""
@@ -97,6 +125,7 @@ __all__ = [
97
125
  "AsyncOpencode",
98
126
  "AsyncOpencodeServer",
99
127
  "AsyncPaginator",
128
+ "AsyncPtyConnection",
100
129
  "AsyncStream",
101
130
  "AuthenticationError",
102
131
  "BadRequestError",
@@ -111,6 +140,8 @@ __all__ = [
111
140
  "OpencodeError",
112
141
  "OpencodeServer",
113
142
  "PermissionDeniedError",
143
+ "PtyConnection",
144
+ "PtyConnectionError",
114
145
  "RateLimitError",
115
146
  "ServerStartError",
116
147
  "ServiceUnavailableError",
@@ -119,6 +150,27 @@ __all__ = [
119
150
  "UnprocessableEntityError",
120
151
  "__version__",
121
152
  "types",
153
+ # Shared event stream and typed plugin RPC
154
+ "SUBSCRIBER_CAPACITY",
155
+ "AsyncEventHub",
156
+ "AsyncRpcClient",
157
+ "AsyncRpcEvents",
158
+ "AsyncSubscription",
159
+ "EventHub",
160
+ "EventOverflowError",
161
+ "Reconnect",
162
+ "RpcCallError",
163
+ "RpcCallInternalError",
164
+ "RpcClient",
165
+ "RpcDefinition",
166
+ "RpcEventDefinition",
167
+ "RpcEventPayload",
168
+ "RpcEvents",
169
+ "RpcMethod",
170
+ "Subscription",
171
+ "rpc_event",
172
+ "rpc_method",
173
+ "session_id_of",
122
174
  # <generated:error-exports>
123
175
  "AgentNotFoundError",
124
176
  "CommandExecutionError",
opencode/_client.py CHANGED
@@ -1,11 +1,14 @@
1
1
  from __future__ import annotations
2
2
 
3
+ from functools import cached_property
3
4
  from typing import TYPE_CHECKING
4
5
 
5
6
  from typing_extensions import Self
6
7
 
7
8
  from ._base_client import AsyncAPIClient, SyncAPIClient
8
9
  from ._constants import DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT, DEFAULT_USERNAME
10
+ from ._events import AsyncEventHub, EventHub
11
+ from ._rpc import AsyncTypedRpcResource, TypedRpcResource
9
12
  from ._types import NOT_GIVEN, NotGiven, Timeout
10
13
  from .resources import AsyncResources, SyncResources
11
14
 
@@ -70,6 +73,16 @@ class Opencode(SyncAPIClient, SyncResources):
70
73
  http_client=http_client,
71
74
  )
72
75
 
76
+ @cached_property
77
+ def events(self) -> EventHub:
78
+ """The shared event stream: one connection for every subscriber. See :class:`opencode.EventHub`."""
79
+ return EventHub(self)
80
+
81
+ @cached_property
82
+ def rpc(self) -> TypedRpcResource:
83
+ """Plugin RPC calls: ``client.rpc.call(...)``, or ``client.rpc(Definition)`` for typed access."""
84
+ return TypedRpcResource(self)
85
+
73
86
  def with_options(
74
87
  self,
75
88
  *,
@@ -138,6 +151,16 @@ class AsyncOpencode(AsyncAPIClient, AsyncResources):
138
151
  http_client=http_client,
139
152
  )
140
153
 
154
+ @cached_property
155
+ def events(self) -> AsyncEventHub:
156
+ """The shared event stream: one connection for every subscriber. See :class:`opencode.AsyncEventHub`."""
157
+ return AsyncEventHub(self)
158
+
159
+ @cached_property
160
+ def rpc(self) -> AsyncTypedRpcResource:
161
+ """Plugin RPC calls: ``client.rpc.call(...)``, or ``client.rpc(Definition)`` for typed access."""
162
+ return AsyncTypedRpcResource(self)
163
+
141
164
  def with_options(
142
165
  self,
143
166
  *,