pharia-kernel-sdk-rs
Rust SDK for Pharia Kernel Skills
Getting Started
Create a new crate
Update Cargo.toml
Then update your Cargo.toml with some WASM and Kernel specific configuration.
[]
= "hello-world"
= "2021"
= "0.1.0"
[]
# This specifies how it should be compiled, necessary for WASM components.
= ["cdylib"]
[]
# For capturing errors in your skill code.
= "1"
# The Skill SDK for building Kernel Skills
= { = "0.6.0" }
# Used for autogenerating an OpenAPI spec for your skill.
= "0.8"
# For deriving custom input and output structs
= { = "1", = ["derive"] }
[]
# Helpers for testing.
= { = "0.6.0" }
[]
= 1
= "s"
= false
= true
= true
Start writing your skill
With this setup, you should be able to start writing a basic Skill component. Your input and output can be anything that implements serde's Deserialize for your input and Serialize for your output.
use ;
// This can also return an `anyhow::Result<String>` if you need handle errors.
Testing
With the pharia-skill-test crate, you can run your skill code locally and test that it is working as expected.
A basic test for the above example would be:
Which you can then run like a normal Rust test:
Build
To deploy your skill, you will need to compile for WASM, specifically a WASM WASI target.
First you will need to make sure you have the wasm32-wasip2 target installed, which is available as of Rust v1.82.0:
Now you should be able to compile your skill:
You can now find your compiled component in your target directory, like target/wasm32-wasip2/release/hello_world.wasm