opencode-python-sdk 0.1.2__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
@@ -81,6 +81,33 @@ from ._streaming import AsyncStream, Stream
81
81
  from ._types import NOT_GIVEN, NotGiven
82
82
  from ._version import __version__
83
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
+
84
111
  # <generated:api-version>
85
112
  API_VERSION = "2.1.2"
86
113
  """The OpenCode server version this client was generated from."""
@@ -123,6 +150,27 @@ __all__ = [
123
150
  "UnprocessableEntityError",
124
151
  "__version__",
125
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",
126
174
  # <generated:error-exports>
127
175
  "AgentNotFoundError",
128
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
  *,