# subako-function-sdk
Write [Subako](https://subako.ai) function packages in Rust. Each `#[function]` becomes a tool an agent can call:
- the function's name is the tool's name;
- its doc comment is the description the model reads;
- its input and output types, which derive `JsonSchema`, become the tool's schemas.
```rust
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use subako_function_sdk::{ToolError, function, package};
#[derive(Deserialize, JsonSchema)]
struct GreetInput {
/// Who to greet.
name: String,
}
#[derive(Serialize, JsonSchema)]
struct Greeting {
message: String,
}
/// Greet someone by name.
#[function]
fn greet(input: GreetInput) -> Result<Greeting, ToolError> {
Ok(Greeting { message: format!("Hello, {}!", input.name) })
}
package! {
name: "hello",
description: "Says hello.",
functions: [greet],
}
```
Build the module for `wasm32-wasip1`. The same crate built for your machine prints the package's `subako-package.json` with `cargo run -- --subako-manifest`.
To start a new package, use the template, which also packages the bundle Subako takes:
```sh
cargo generate subako-ai/subako-function-template-rust
```
## License
Licensed under either of [Apache License, Version 2.0](LICENSE-APACHE) or [MIT license](LICENSE-MIT) at your option.