Table of Contents

Class OpenClawBridgeChannel

Namespace
JD.AI.Channels.OpenClaw
Assembly
JD.AI.Channels.OpenClaw.dll

Bridges JD.AI gateway to an OpenClaw instance via WebSocket JSON-RPC. Implements IChannel to appear as a regular channel in the JD.AI gateway. Messages sent to this channel are forwarded to OpenClaw via chat.send; messages from OpenClaw are surfaced as inbound channel messages via chat events.

public sealed class OpenClawBridgeChannel : IChannel, IAsyncDisposable
Inheritance
OpenClawBridgeChannel
Implements
Inherited Members

Constructors

OpenClawBridgeChannel(OpenClawRpcClient, ILogger<OpenClawBridgeChannel>, OpenClawConfig)

public OpenClawBridgeChannel(OpenClawRpcClient rpc, ILogger<OpenClawBridgeChannel> logger, OpenClawConfig config)

Parameters

rpc OpenClawRpcClient
logger ILogger<OpenClawBridgeChannel>
config OpenClawConfig

Properties

ChannelType

Unique channel type identifier (e.g., "discord", "signal", "web").

public string ChannelType { get; }

Property Value

string

DisplayName

Display name for this channel instance.

public string DisplayName { get; }

Property Value

string

IsConnected

Whether the channel is currently connected and healthy.

public bool IsConnected { get; }

Property Value

bool

RpcClient

The underlying RPC client for direct event subscription.

public OpenClawRpcClient RpcClient { get; }

Property Value

OpenClawRpcClient

Methods

AbortSessionAsync(string, CancellationToken)

Aborts the currently running agent for an OpenClaw session. Used by the intercept handler to stop OpenClaw's own processing.

public Task AbortSessionAsync(string sessionKey, CancellationToken ct = default)

Parameters

sessionKey string
ct CancellationToken

Returns

Task

ConnectAsync(CancellationToken)

Connects to the messaging platform.

public Task ConnectAsync(CancellationToken ct = default)

Parameters

ct CancellationToken

Returns

Task

DeleteSessionsByPrefixAsync(IEnumerable<string>, IEnumerable<string>?, bool, CancellationToken)

Deletes OpenClaw sessions whose keys begin with one of the provided prefixes. Intended for bridge-disable cleanup of JD.AI-managed session namespaces.

public Task<int> DeleteSessionsByPrefixAsync(IEnumerable<string> sessionKeyPrefixes, IEnumerable<string>? sessionKeyContains = null, bool deleteTranscript = true, CancellationToken ct = default)

Parameters

sessionKeyPrefixes IEnumerable<string>
sessionKeyContains IEnumerable<string>
deleteTranscript bool
ct CancellationToken

Returns

Task<int>

DisconnectAsync(CancellationToken)

Gracefully disconnects.

public Task DisconnectAsync(CancellationToken ct = default)

Parameters

ct CancellationToken

Returns

Task

DisposeAsync()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.

public ValueTask DisposeAsync()

Returns

ValueTask

A task that represents the asynchronous dispose operation.

GetChannelStatusAsync(CancellationToken)

Gets channel status from the OpenClaw gateway.

public Task<RpcResponse> GetChannelStatusAsync(CancellationToken ct = default)

Parameters

ct CancellationToken

Returns

Task<RpcResponse>

GetSkillStatusAsync(CancellationToken)

Gets skill status from the OpenClaw gateway.

public Task<RpcResponse> GetSkillStatusAsync(CancellationToken ct = default)

Parameters

ct CancellationToken

Returns

Task<RpcResponse>

InjectMessageAsync(string, string, CancellationToken)

Injects a message into an OpenClaw session without triggering agent processing. Use this for injecting JD.AI-generated responses back into the conversation.

public Task InjectMessageAsync(string sessionKey, string content, CancellationToken ct = default)

Parameters

sessionKey string
content string
ct CancellationToken

Returns

Task

ListSessionsAsync(CancellationToken)

Lists all active sessions on the OpenClaw gateway.

public Task<RpcResponse> ListSessionsAsync(CancellationToken ct = default)

Parameters

ct CancellationToken

Returns

Task<RpcResponse>

RpcAsync(string, object?, CancellationToken)

Sends an arbitrary RPC request to the OpenClaw gateway.

public Task<RpcResponse> RpcAsync(string method, object? parameters = null, CancellationToken ct = default)

Parameters

method string
parameters object
ct CancellationToken

Returns

Task<RpcResponse>

SendMessageAsync(string, string, CancellationToken)

Sends a message to the specified conversation/thread.

public Task SendMessageAsync(string conversationId, string content, CancellationToken ct = default)

Parameters

conversationId string
content string
ct CancellationToken

Returns

Task

Events

MessageReceived

Raised when a new inbound message arrives.

public event Func<ChannelMessage, Task>? MessageReceived

Event Type

Func<ChannelMessage, Task>

Remarks

Uses Func<ChannelMessage, Task> instead of EventHandler to support async handlers.