anyclaw-sdk-channel 0.3.5

Channel SDK for anyclaw — build messaging channel integrations
Documentation

anyclaw-sdk-channel

Build messaging channel integrations for anyclaw — implement the Channel trait and the SDK handles all JSON-RPC framing, the initialize handshake, and bidirectional message routing.

crates.io docs.rs

⚠️ Unstable — APIs may change between releases.

Quick Example

use anyclaw_sdk_channel::{Channel, ChannelCapabilities, ChannelHarness, ChannelSdkError, ChannelSendMessage};
use anyclaw_sdk_types::{ChannelRequestPermission, DeliverMessage, PermissionResponse};
use tokio::sync::mpsc;

struct MyChannel {
    outbound: Option<mpsc::Sender<ChannelSendMessage>>,
}

impl Channel for MyChannel {
    fn capabilities(&self) -> ChannelCapabilities {
        ChannelCapabilities { streaming: true, rich_text: false }
    }

    async fn on_ready(
        &mut self,
        outbound: mpsc::Sender<ChannelSendMessage>,
        _permission_tx: mpsc::Sender<PermissionResponse>,
    ) -> Result<(), ChannelSdkError> {
        self.outbound = Some(outbound);
        // Start your platform listener (HTTP server, webhook, polling loop, etc.)
        Ok(())
    }

    async fn deliver_message(&mut self, msg: DeliverMessage) -> Result<(), ChannelSdkError> {
        // Render the agent's response to your platform
        Ok(())
    }

    async fn show_permission_prompt(&mut self, _req: ChannelRequestPermission) -> Result<(), ChannelSdkError> {
        // Show permission UI — return immediately, respond async via permission_tx
        Ok(())
    }
}

#[tokio::main]
async fn main() {
    ChannelHarness::new(MyChannel { outbound: None })
        .run_stdio()
        .await
        .unwrap();
}

on_initialize, handle_unknown, and on_session_created have default no-op implementations. Override them only if needed.

Going Further

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.