sdk-rust README

The project's README from github.com/astrid-runtime/sdk-rust. As one markdown file: README.md.

astrid-sdk

License: MIT OR Apache-2.0 MSRV: 1.94

The Rust SDK for building Astrid capsules.

In the OS model, this is the standard library for user-space processes. It gives capsule authors safe, typed access to every kernel service: filesystem, IPC, networking, storage, approval, scheduling, and more. Capsule authors depend on astrid-sdk and serde. Everything else is handled.

Crates

Crate Role
astrid-sdk Safe Rust SDK for capsule authors. Mirrors std module layout: fs, net, process, env, time, log, plus Astrid-specific modules: ipc, kv, http, hooks, cron, uplink, identity, approval, runtime.
astrid-sdk-macros #[capsule] proc macro. Generates WASM ABI exports from annotated impl blocks: tool dispatch, command routing, hook handlers, cron handlers, install/upgrade entry points.
astrid-sys Raw WASM-to-host FFI bindings. The syscall table. Every parameter crosses as Vec<u8>. You should not use this directly.

Quick start

[dependencies]
astrid-sdk = "0.2"
serde = { version = "1.0", features = ["derive"] }
use astrid_sdk::prelude::*;

#[derive(Default)]
pub struct MyTools;

#[capsule]
impl MyTools {
    #[astrid::tool]
    fn search_issues(&self, args: SearchArgs) -> Result<SearchResult, SysError> {
        let token = env::var("GITHUB_TOKEN")?;
        let resp = http::get(&format!(
            "https://api.github.com/search/issues?q={}", args.query
        ))?;
        // ...
    }
}

The #[capsule] macro generates all WASM ABI boilerplate: extern "C" exports, JSON serialization across the boundary, tool schema generation, and dispatch routing.

Building capsules

Capsules compile to wasm32-wasip2:

rustup target add wasm32-wasip2
cargo build --target wasm32-wasip2 --release

Development

cargo build --workspace
cargo test --workspace -- --quiet
cargo clippy --workspace --all-features -- -D warnings

License

Dual-licensed under MIT and Apache 2.0.

Copyright (c) 2025-2026 Joshua J. Bouw and Unicity Labs.

sdk-rust (astrid-runtime/sdk-rust)

Searching Database…

这是什么?这是用于构建 Astrid “capsule” 的 Rust SDK——capsule 是沙盒化的 WASM 模块,在 Astrid OS 模型中充当用户态进程,可以类型安全地访问文件系统、IPC、网络、存储、审批和调度等内核服务。
astrid-sdk 是库还是代码生成器?两者都是:astrid-sdk 是一个安全 Rust 库,镜像 std 的模块布局(fs、net、process、env、time、log)外加 Astrid 特有的模块;astrid-sdk-macros 则提供 #[capsule] 过程宏,为你生成所有 WASM ABI 样板代码。
如何用这个 SDK 构建一个 capsule?在你的 crate 中依赖 astrid-sdk(和 serde),用 #[capsule] 宏标注你的实现,然后把 crate 编译到 wasm32-wasip2 目标。
除了 astrid-sdk 本身我还需要别的吗?capsule 作者只需添加 astrid-sdk 和 serde 作为依赖——SDK 会替你处理跨 WASM 边界的 JSON 序列化、工具 schema 生成和分发路由。
我应该直接调用 astrid-sys 而不用 astrid-sdk 吗?不要——astrid-sys 只是原始的 WASM 到宿主机的 FFI 系统调用表,README 明确警告不要直接使用它;请坚持使用 astrid-sdk 中的安全封装。
capsule 到底是什么?capsule 是一个沙盒化的 WASM 模块,在 Astrid OS 模型中的行为类似用户态进程,它以类型化的方式访问内核服务,而不是直接使用原始系统调用。
capsule 可以访问哪些内核服务?通过专门的 SDK 模块,它可以访问 IPC、键值存储、HTTP、hooks、cron 调度、uplink、身份、审批和通用运行时服务,此外还有类似 std 的 fs、net、process、env、time 和 log 模块。
#[capsule] 宏能省去我手写哪些东西?它会自动生成 extern "C" 的 WASM ABI 导出、跨宿主边界的 JSON 序列化、工具 schema 生成和分发路由,让你完全不必直接接触 astrid-sys。
Size
0.4 MB
Stars
4.3K
Age
7mo
Commits · 90 Days