You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-**Connection Trait**: Defines an abstraction for communication. This allows swapping the local subprocess harness with other backends (e.g., remote or mock harnesses) in the future.
30
-
-**LocalConnectionStrategy**: Acts as a builder/strategy to configure and initialize a `LocalConnection`.
-**Connection Trait**: Defines an abstraction for communication. This allows swapping the local subprocess harness with other backends (e.g., remote, mock, or WASM-based network harnesses) in the future.
33
+
-**LocalConnectionStrategy**: Configures and initializes a `LocalConnection` by spawning a local helper subprocess (for native / non-WASM environments).
34
+
-**WasmConnectionStrategy**: Configures and initializes a `WasmConnection` that connects to a remote or host-side `localharness` WebSocket server over TCP (enabled for `target_arch = "wasm32"` environments where subprocess spawning is not supported).
31
35
32
36
### 2. Observer Pattern (`hooks.rs`)
33
37
-**Hook Trait**: Defines lifecycle hooks that users can register to observe and modify agent actions:
@@ -49,13 +53,20 @@ The SDK leverages several object-oriented and functional design patterns:
49
53
-**Tool Trait**: Encapsulates specific capabilities (e.g., file edits, command execution, directory searching) into unified command units.
50
54
-**ToolRunner**: Coordinates registration and execution of these command objects, mapping harness tool calls to their respective handlers.
51
55
56
+
### 5. Background Trigger Pattern (`triggers.rs`)
57
+
-**Trigger Trait**: Defines asynchronous background tasks (such as status polling, listener intervals, etc.) that can interact with the connection session concurrently.
58
+
-**TriggerRunner**: Coordinates and spawns registered triggers in separate tasks when the agent session starts.
59
+
60
+
### 6. Direct Gemini Client (`direct.rs`)
61
+
-**GeminiDirectClient**: A transport-agnostic client that constructs REST request payloads and parses responses directly from the Gemini API. Bypasses the `localharness` and WebSocket loop entirely. It is helpful for environments where TCP/WebSocket or spawning subprocesses is not possible (e.g. lightweight WASI components).
62
+
52
63
---
53
64
54
65
## Component Details
55
66
56
-
### Connection Lifecycle
67
+
### Connection Lifecycle (Native Subprocess)
57
68
58
-
The connection to `localharness` follows a strict handshake and upgrade protocol:
69
+
The connection to `localharness`via subprocess follows a strict handshake and upgrade protocol:
59
70
60
71
```mermaid
61
72
sequenceDiagram
@@ -79,6 +90,21 @@ sequenceDiagram
79
90
3.**Upgrade**: The SDK initiates a WebSocket client connection to the harness server using the retrieved port and API key, upgrading communication to a structured bi-directional stream.
80
91
4.**Disconnection**: When dropped, the subprocess is killed cleanly.
0 commit comments