Channels
Channels 是可选 adapters,用于 gateway、outbound 和 configuration 行为。
ts
import {
createChannelRegistry,
registerChannel,
type ChannelPlugin,
} from "duclaw-cli/sdk/core";注册 Channel
ts
const channels = createChannelRegistry();
registerChannel(channels, {
id: "custom-channel",
meta: {
id: "custom-channel",
label: "Custom Channel",
blurb: "Receives and sends messages through a custom transport.",
},
config: {
resolveAccount(cfg) {
return cfg;
},
},
outbound: {
async sendText(ctx) {
await sendMessageToTransport(ctx.to, ctx.text);
},
},
gateway: {
async startAccount(ctx) {
await startTransportListener(ctx.accountId, ctx.abortSignal);
},
async stopAccount(ctx) {
await stopTransportListener(ctx.accountId);
},
},
});当运行时需要 channel-aware 行为时,把 ChannelPlugin 传给 AgentConfig.channelPlugin。