Capsule Development
Skill này làm gì
Skill này hướng dẫn xây dựng một capsule, tức chương trình nhỏ an toàn chạy bên trong Unicity AOS. Skill dành cho lập trình viên muốn viết và cài các mảnh chương trình mới cho hệ thống agent.
Khi nào nên dùng
- ✓Khi bạn muốn bắt đầu một capsule mới cho thiết lập Unicity AOS.
- ✓Khi một capsule không build, liên kết hoặc cài đặt được và cần gỡ lỗi.
- ✓Khi bạn cần kiểm tra quy tắc truy cập của capsule đã được thiết lập đúng.
Liên kết skill
https://github.com/unicity-aos/aos-ce/blob/main/capsules/capsule-system/src/skills/capsule-development/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Tạo một capsule Unicity AOS mới từ template được hỗ trợ, build nó và cài đặt để kiểm thử.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent bắt đầu từ template dự án chính thức và thiết lập manifest, nơi kiểm soát những gì capsule được truy cập. Sau đó nó build cho mục tiêu cần thiết và kiểm tra danh sách truy cập trước khi cài.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
Capsule Development
A capsule is a Rust WebAssembly component that runs inside the Astrid Runtime sandbox shipped by Unicity AOS. The runtime routes IPC, enforces capabilities, mediates host access, and audits execution. Business logic belongs in capsules.
The manifest is part of the security boundary. Its [publish] and [subscribe]
tables are the IPC access-control list: a topic that is not declared is denied.
Capsules target wasm32-unknown-unknown, not WASI, and reach the host only through
the audited SDK/WIT imports granted by the manifest.
Start from the supported scaffold
aos capsule new my-capsule
cd my-capsule
The generated project contains:
my-capsule/
├── .cargo/config.toml
├── rust-toolchain.toml
├── Cargo.toml
├── Capsule.toml
└── src/lib.rs
Do not begin from an old [[interceptor]] manifest or an ipc_publish /
ipc_subscribe capability array. Those formats are obsolete.
Compiler target
.cargo/config.toml selects the capsule target and activates the SDK's custom
randomness backend:
[build]
target = "wasm32-unknown-unknown"
[target.wasm32-unknown-unknown]
rustflags = ["--cfg=getrandom_backend=\"custom\""]
The getrandom_backend setting must live in the final capsule crate. Without it,
dependencies such as UUID generators or randomized hash maps can fail to link.
Pin the toolchain and target in rust-toolchain.toml:
[toolchain]
channel = "1.94.0"
targets = ["wasm32-unknown-unknown"]
components = ["rustfmt", "clippy"]
Cargo package
Use a cdylib and the current 0.7 SDK surface:
[package]
name = "my-capsule"
version = "0.1.0"
edition = "2024"
publish = false
[lib]
crate-type = ["cdylib"]
[dependencies]
astrid-sdk = { version = "0.7", features = ["derive"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
[profile.release]
opt-level = "z"
lto = true
codegen-units = 1
strip = true
panic = "abort"
Capsule manifest
This minimal tool capsule exposes one hello tool:
[package]
name = "my-capsule"
version = "0.1.0"
description = "A small example capsule"
authors = ["Your Name <you@example.com>"]
astrid-version = ">=0.7.0"
[[component]]
id = "my-capsule"
file = "my_capsule.wasm"
type = "executable"
[capabilities]
fs_read = ["home://data/my-capsule/"]
fs_write = ["home://data/my-capsule/"]
[publish]
"tool.v1.execute.*.result" = { wit = "@unicity-astrid/wit/types/tool-call-result" }
"tool.v1.response.describe.*" = { wit = "@unicity-astrid/wit/tool/describe-response" }
[subscribe]
"tool.v1.execute.hello" = { wit = "@unicity-astrid/wit/types/tool-call", handler = "tool_execute_hello" }
"tool.v1.request.describe" = { wit = "@unicity-astrid/wit/tool/describe-request", handler = "tool_describe" }
Skills are agent user-space instructions, not a Capsule.toml protocol. Ship a trigger Skill through the host plugin or the agent-level Skills service, and expose capsule-owned reference material through typed IPC tools when useful. Do not add an agent Skill section to the manifest or request filesystem write authority merely to modify a host's instruction directory.
The published @unicity-astrid/wit/... strings and astrid:* WIT namespaces
are stable runtime identifiers. Keep them exact even though the product CLI is
aos.
For a tool capsule, both publish entries are required: one returns tool results,
and the other answers the describe fan-out that makes tools visible to agents.
Every tool needs its own concrete execute subscription. A subscribe wildcard may
have one trailing *; publish permissions should be as narrow as practical.
Manifest data is untrusted input. Do not put operator authority, principal identity, or a secret scope in a capsule-controlled field. The kernel stamps the caller identity and decides operator-only policy.
Implement a tool
#![deny(unsafe_code)]
#![deny(clippy::all)]
use astrid_sdk::prelude::*;
use astrid_sdk::schemars;
use serde::Deserialize;
#[derive(Default)]
pub struct MyCapsule;
#[derive(Debug, Default, Deserialize, schemars::JsonSchema)]
pub struct HelloArgs {
/// Person to greet.
pub name: String,
}
#[capsule]
impl MyCapsule {
/// Greet a person by name.
#[astrid::tool("hello")]
pub fn hello(&self, args: HelloArgs) -> Result<String, SysError> {
Ok(format!("Hello, {}!", args.name))
}
}
The tool macro derives the input schema from JsonSchema, uses the method's doc
comment as the tool desc
Câu hỏi thường gặp
Vì sao manifest quan trọng?
Danh sách truy cập của nó kiểm soát những thông điệp capsule được gửi và nhận, và mọi thứ không khai báo đều bị từ chối.
Tôi có thể bắt đầu từ ví dụ cũ không?
Không. Các định dạng manifest cũ đã lỗi thời, nên skill bắt đầu từ template hiện tại.
Tôi có cần biết Rust không?
Skill dùng Rust, nên lập trình viên biết Rust sẽ tận dụng được nhiều nhất.
Chi tiết
Mô tả gốc của tác giả
Build, test, package, install, and debug a current Unicity AOS capsule
repo: unicity-aos/aos-ce
Độ phổ biến
- Sao GitHub
- 8.5k
- Vị trí xếp hạng
- #12454
- Giấy phép
- Apache-2.0
- Cập nhật
- 22/10/2026
Bình luận
- …
Thêm skill từ kho mã này
capsule-forge
8.5kGiúp agent của bạn quyết định một khả năng mới nên là skill, capsule hay plugin, rồi xây dựng hoặc sửa nó trên hệ thống Unicity AOS.
meta-harness
8.5kGiúp agent của bạn nhận ra chỗ các công cụ, trí nhớ hoặc hướng dẫn của nó còn thiếu sót trong lúc làm việc thật, rồi cải thiện và giữ phiên bản tốt hơn.
Skill tương tự
api-connector-builder
280kGiúp agent của bạn xây dựng kết nối API mới theo đúng mẫu đã có, dùng khi bạn cần thêm một tích hợp mà không tạo cách làm mới.
api-design
280kGiúp agent của bạn thiết kế REST API theo các thực hành tốt nhất, hữu ích để định nghĩa cách API giao tiếp, hiển thị lỗi và tổ chức dữ liệu.
backend-patterns
280kGiúp agent của bạn với các mẫu kiến trúc phía máy chủ và tối ưu cơ sở dữ liệu, hữu ích khi xây dựng hoặc rà soát code chạy trên máy chủ.