AgentStack
Browse Sign in
Browse Why AgentStack Sell Docs
Sign in
SKILL verified MIT Self-run

Molykit

skill-sagev1-makepad-skills-molykit · by SageV1

|

No reviews yet
0 installs
24 views
0.0% view→install

Install

$ agentstack add skill-sagev1-makepad-skills-molykit

✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.

Security review

✓ Passed

No issues found. Passed automated security review. · v0.1.0 How review works →

  • Prompt-injection patterns
  • Secret / credential exfiltration
  • Dangerous shell & filesystem operations
  • Untrusted network calls
  • Known-malicious package signatures

What it can access

  • Network access No
  • Filesystem access No
  • Shell / process execution Used
  • Environment & secrets No
  • Dynamic code execution No

From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.

View the full security report →

Verified badge

Passed review? Show it. Paste this badge into your README, it links to the public security report.

AgentStack Verified badge Links to your public security report.
[![AgentStack Verified](https://agentstack.voostack.com/badges/verified.svg)](https://agentstack.voostack.com/security/report/skill-sagev1-makepad-skills-molykit)

Reliability & compatibility

Security review passed
0 installs to date
no reviews yet
24d ago

Declared compatibility

Claude CodeClaude Desktop

Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.

Preview Execution monitoring

We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.

How agent discovery & health will work →
Are you the author of Molykit? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

MolyKit Skill

Best practices for building AI chat interfaces with Makepad using MolyKit - a toolkit for cross-platform AI chat applications.

Source codebase: /Users/zhangalex/Work/Projects/FW/robius/moly/moly-kit

Triggers

Use this skill when:

  • Building AI chat interfaces with Makepad
  • Integrating OpenAI or other LLM APIs
  • Implementing cross-platform async for native and WASM
  • Creating chat widgets (messages, prompts, avatars)
  • Handling SSE streaming responses
  • Keywords: molykit, moly-kit, ai chat, bot client, openai makepad, chat widget, sse streaming

Overview

MolyKit provides:

  • Cross-platform async utilities (PlatformSend, spawn(), ThreadToken)
  • Ready-to-use chat widgets (Chat, Messages, PromptInput, Avatar)
  • BotClient trait for AI provider integration
  • OpenAI-compatible client with SSE streaming
  • Protocol types for messages, bots, and tool calls
  • MCP (Model Context Protocol) support

Cross-Platform Async Patterns

PlatformSend - Send Only on Native

/// Implies Send only on native platforms, not on WASM
/// - On native: implemented by types that implement Send
/// - On WASM: implemented by ALL types
pub trait PlatformSend: PlatformSendInner {}

/// Boxed future type for cross-platform use
pub type BoxPlatformSendFuture = Pin + 'a>>;

/// Boxed stream type for cross-platform use
pub type BoxPlatformSendStream = Pin + 'a>>;

Platform-Agnostic Spawning

/// Runs a future independently
/// - Uses tokio on native (requires Send)
/// - Uses wasm-bindgen-futures on WASM (no Send required)
pub fn spawn(fut: impl PlatformSendFuture + 'static);

// Usage
spawn(async move {
    let result = fetch_data().await;
    Cx::post_action(DataReady(result));
    SignalToUI::set_ui_signal();
});

Task Cancellation with AbortOnDropHandle

/// Handle that aborts its future when dropped
pub struct AbortOnDropHandle(AbortHandle);

// Usage - task cancelled when widget dropped
#[rust]
task_handle: Option,

fn start_task(&mut self) {
    let (future, handle) = abort_on_drop(async move {
        // async work...
    });
    self.task_handle = Some(handle);
    spawn(async move { let _ = future.await; });
}

ThreadToken for Non-Send Types on WASM

/// Store non-Send value in thread-local, access via token
pub struct ThreadToken;

impl ThreadToken {
    pub fn new(value: T) -> Self;
    pub fn peek(&self, f: impl FnOnce(&T) -> R) -> R;
    pub fn peek_mut(&self, f: impl FnOnce(&mut T) -> R) -> R;
}

// Usage - wrap non-Send type for use across Send boundaries
let token = ThreadToken::new(non_send_value);
spawn(async move {
    token.peek(|value| {
        // use value...
    });
});

BotClient Trait

Implementing AI Provider Integration

pub trait BotClient: Send {
    /// Send message with streamed response
    fn send(
        &mut self,
        bot_id: &BotId,
        messages: &[Message],
        tools: &[Tool],
    ) -> BoxPlatformSendStream>;

    /// Get available bots/models
    fn bots(&self) -> BoxPlatformSendFuture>>;

    /// Clone for passing around
    fn clone_box(&self) -> Box;
}

// Usage
let client = OpenAIClient::new("https://api.openai.com/v1".into());
client.set_key("sk-...")?;
let context = BotContext::from(client);

BotContext - Sharable Wrapper

/// Sharable wrapper with loaded bots for sync UI access
pub struct BotContext(Arc>);

impl BotContext {
    pub fn load(&mut self) -> BoxPlatformSendFuture>;
    pub fn bots(&self) -> Vec;
    pub fn get_bot(&self, id: &BotId) -> Option;
    pub fn client(&self) -> Box;
}

// Usage
let mut context = BotContext::from(client);
spawn(async move {
    if let Err(errors) = context.load().await.into_result() {
        // handle errors
    }
    Cx::post_action(BotsLoaded);
});

Protocol Types

Message Structure

pub struct Message {
    pub from: EntityId,         // User, System, Bot(BotId), App
    pub metadata: MessageMetadata,
    pub content: MessageContent,
}

pub struct MessageContent {
    pub text: String,           // Main content (markdown)
    pub reasoning: String,      // AI reasoning/thinking
    pub citations: Vec, // Source URLs
    pub attachments: Vec,
    pub tool_calls: Vec,
    pub tool_results: Vec,
}

pub struct MessageMetadata {
    pub is_writing: bool,       // Still being streamed
    pub created_at: DateTime,
}

Bot Identification

/// Globally unique bot ID: ;@
pub struct BotId(Arc);

impl BotId {
    pub fn new(id: &str, provider: &str) -> Self;
    pub fn id(&self) -> &str;       // provider-local id
    pub fn provider(&self) -> &str; // provider domain
}

// Example: BotId::new("gpt-4", "api.openai.com")
// -> "5;gpt-4@api.openai.com"

Widget Patterns

Slot Widget - Runtime Content Replacement

live_design! {
    pub Slot = {{Slot}} {
        width: Fill, height: Fit,
        slot =  {}  // default content
    }
}

// Usage - replace content at runtime
let mut slot = widget.slot(id!(content));
if let Some(custom) = client.content_widget(cx, ...) {
    slot.replace(custom);
} else {
    slot.restore();  // back to default
    slot.default().as_standard_message_content().set_content(cx, &content);
}

Avatar Widget - Text/Image Toggle

live_design! {
    pub Avatar = {{Avatar}}  {
        grapheme =  {
            visible: false,
            label =  { text: "P" }
        }
        dependency =  {
            visible: false,
            image =  {}
        }
    }
}

impl Widget for Avatar {
    fn draw_walk(&mut self, cx: &mut Cx2d, ...) -> DrawStep {
        if let Some(avatar) = &self.avatar {
            match avatar {
                Picture::Grapheme(g) => {
                    self.view(id!(grapheme)).set_visible(cx, true);
                    self.view(id!(dependency)).set_visible(cx, false);
                    self.label(id!(label)).set_text(cx, &g);
                }
                Picture::Dependency(d) => {
                    self.view(id!(dependency)).set_visible(cx, true);
                    self.view(id!(grapheme)).set_visible(cx, false);
                    self.image(id!(image)).load_image_dep_by_path(cx, d.as_str());
                }
            }
        }
        self.deref.draw_walk(cx, scope, walk)
    }
}

PromptInput Widget

#[derive(Live, Widget)]
pub struct PromptInput {
    #[deref] deref: CommandTextInput,
    #[live] pub send_icon: LiveValue,
    #[live] pub stop_icon: LiveValue,
    #[rust] pub task: Task,           // Send or Stop
    #[rust] pub interactivity: Interactivity,
}

impl PromptInput {
    pub fn submitted(&self, actions: &Actions) -> bool;
    pub fn reset(&mut self, cx: &mut Cx);
    pub fn set_send(&mut self);
    pub fn set_stop(&mut self);
    pub fn enable(&mut self);
    pub fn disable(&mut self);
}

Messages Widget - Conversation View

#[derive(Live, Widget)]
pub struct Messages {
    #[deref] deref: View,
    #[rust] pub messages: Vec,
    #[rust] pub bot_context: Option,
}

impl Messages {
    pub fn set_messages(&mut self, messages: Vec, scroll_to_bottom: bool);
    pub fn scroll_to_bottom(&mut self, cx: &mut Cx, triggered_by_stream: bool);
    pub fn is_at_bottom(&self) -> bool;
}

UiRunner Pattern for Async-to-UI

impl Widget for PromptInput {
    fn handle_event(&mut self, cx: &mut Cx, event: &Event, scope: &mut Scope) {
        self.deref.handle_event(cx, event, scope);
        self.ui_runner().handle(cx, event, scope, self);

        if self.button(id!(attach)).clicked(event.actions()) {
            let ui = self.ui_runner();
            Attachment::pick_multiple(move |result| match result {
                Ok(attachments) => {
                    ui.defer_with_redraw(move |me, cx, _| {
                        me.attachment_list_ref().write().attachments.extend(attachments);
                    });
                }
                Err(_) => {}
            });
        }
    }
}

SSE Streaming

/// Parse SSE byte stream into message stream
pub fn parse_sse(s: S) -> impl Stream>
where
    S: Stream>,
    B: AsRef,
{
    // Split on "\n\n", extract "data:" content
    // Filter comments and [DONE] messages
}

// Usage in BotClient::send
fn send(&mut self, ...) -> BoxPlatformSendStream {
    let stream = stream! {
        let response = client.post(url).send().await?;
        let events = parse_sse(response.bytes_stream());

        for await event in events {
            let completion: Completion = serde_json::from_str(&event)?;
            content.text.push_str(&completion.delta.content);
            yield ClientResult::new_ok(content.clone());
        }
    };
    Box::pin(stream)
}

Best Practices

  1. Use PlatformSend for cross-platform: Same code works on native and WASM
  2. Use spawn() not tokio::spawn: Platform-agnostic task spawning
  3. Use AbortOnDropHandle: Cancel tasks when widget drops
  4. Use ThreadToken for non-Send on WASM: Thread-local storage with token access
  5. Use Slot for custom content: Allow BotClient to provide custom widgets
  6. Use read()/write() pattern: Safe borrow access via WidgetRef
  7. Use UiRunner::deferwithredraw: Update widget from async context
  8. Handle ClientResult partial success: May have value AND errors

Reference Files

  • llms.txt - Complete MolyKit API reference

Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet, be the first.

Versions

  • v0.1.0 Imported from the upstream source.