Introduction¶
The design philosophy of DSH is “everything is a plugin”. During development, bidirectional communication between the host and client often requires handling complex networking layers and protocol adaptation. The following section introduces memorax-ai/the-binding-of-dsh, which integrates native DSH Connection and Typert Gateway to solve the problem of bidirectional service calls between the Host and Client.
Plugin Positioning¶
This is a DSH plugin for establishing bidirectional RPC between the Host and Client. It is maintained by memorax-ai and primarily addresses the following issues:
* Host-to-Client calls: Supports targeted calls to connected browser or Node objects.
* Bidirectional communication: Supports symmetric bidirectional calls via Typert Gateway.
* Lifecycle management: Handles request association, cancellation, and connection lifecycle.
Core Features¶
- Targeted Host-to-Client calls: Supports calling connected browser or Node peers.
- Symmetric Typert Gateway calls: Supports bidirectional calls via Typert Gateway.
- Connection and request handling: Provides mechanisms for request association, cancellation, and connection lifecycle handling.
- Multi-version compatibility strategy:
- Legacy hosts: Share native
events.hostWebSocket for RPC and events. - Modern hosts: Use Binding sockets for bidirectional RPC and native Gateway streams for events.
- Legacy hosts: Share native
- Separation of concerns: The Connection object is responsible for peer addressing and lifecycle; the Typert Gateway object is responsible for service descriptors, encoders/decoders, calls, and errors.
Installation and Activation¶
Installing this plugin requires the following environment:
* Node.js 22.22.3 or later.
* Harmony 0.8.6 or later (Harmony automatically resolves browser module dependencies and automatically orders Binding modules).
The installation command is as follows:
npm install the-binding-of-dsh
Typical Usage¶
The plugin provides a set of APIs for Host and Client usage:
- Subscribe to events:
peer.subscribe('api-session/status', (...args) => refreshSessionStatus(args))
- Handle events:
peer.handleEvent('approval/request', async ({ agentId, request, signal }) => {
// 处理逻辑
})
- Establish connection:
await peer.connect()
- Streaming:
stream(endpoint, payload, signal)
Notes¶
- Connection status:
connect()only resolves after the Gateway is ready for the handshake. After disconnection, callconnect()again or enablereconnectDelayMsfor automatic retries. - Event replay: Binding does not replay events. After the connection is restored, manually refresh the application state and reopen business streams.
- Agent context: Handlers do not rebuild Agent context.
- Version compatibility: If a legacy client only requests Legacy events, Modern hosts return HTTP 409.
- Code verification: This plugin follows the MIT license. Inspect the source code and license before installation.
Summary¶
This plugin provides a structured bidirectional communication layer for DSH development, simplifying the interaction logic between the Host and Client. The complete source code and documentation are available on GitHub.
References¶
- GitHub: https://github.com/memorax-ai/the-binding-of-dsh
- Catalog page: https://www.skillhub.cn/plugins/memorax-ai/the-binding-of-dsh