Skip to main content

Crate workforce_skill_sdk

Crate workforce_skill_sdk 

Source
Expand description

§workforce-skill-sdk

Write custom workforce skill tools in Rust that compile to WASM.

This crate wraps the raw WASM host ABI so you write normal Rust code instead of pointer manipulation. Compile with --target wasm32-unknown-unknown and distribute via a GitHub repo.

§Quick Start

use workforce_skill_sdk::prelude::*;

workforce_skill_sdk::init!();

tool!(get_weather, "Get current weather", {
    "type": "object",
    "properties": {
        "city": { "type": "string", "description": "City name" }
    },
    "required": ["city"]
}, |input: ToolInput| {
    let city = input.get_str("city").unwrap_or("unknown");
    let resp = http::get(
        &format!("https://wttr.in/{}?format=j1", city),
        &[],
    );
    match resp {
        Some(r) if r.is_success() => ToolOutput::success(json!({"weather": r.body})),
        _ => ToolOutput::error("Failed to fetch weather"),
    }
});

§Architecture

Skill authors write tool handlers that receive a ToolInput (the agent’s input parameters) and return a ToolOutput (success/failure with data). The SDK handles serialisation, memory management, and host function calls.

Modules§

artifact
Read and stage workforce artifacts (uploaded files, produced outputs).
config
Read skill-scoped configuration values.
http
log
Structured logging from inside your WASM skill.
prelude
Import everything you need to write skill tools.
tools
Invoke platform tools declared in this skill’s [[permissions]].
util
Utility functions for common operations in WASM skill handlers.
vault
Read and write secrets in the workforce vault.

Macros§

init
Initialize the workforce skill SDK runtime.
tool
Define a tool handler function.

Structs§

ToolInput
Input parameters received by a tool handler.
ToolOutput
Output from a tool handler.