Skip to main content
The Palyra WASM Plugin System provides a high-performance, sandboxed runtime for executing untrusted code via the palyra-plugins-runtime crate. This system is the foundation for Skills, which are signed, versioned artifacts containing WASM modules, manifests, and metadata.

Plugin Runtime Architecture

The runtime is built on Wasmtime and implements a strict capability-based security model. Plugins cannot access the host system directly; they must interact through a set of “Host Capability” imports defined in the WIT-like interface.

WasmRuntime Implementation

The WasmRuntime class in crates/palyra-plugins/runtime/src/lib.rs manages the lifecycle of WASM execution. It enforces hard limits on resource consumption to prevent Denial of Service (DoS) attacks.
LimitDescriptionDefault Value
fuel_budgetInstruction count limit (deterministic)10,000,000 crates/palyra-plugins/runtime/src/lib.rs#34-34
max_memory_bytesMaximum linear memory allocation64 MB crates/palyra-plugins/runtime/src/lib.rs#35-35
max_table_elementsMaximum WASM table entries100,000 crates/palyra-plugins/runtime/src/lib.rs#36-36
max_instancesConcurrent instance limit per store256 crates/palyra-plugins/runtime/src/lib.rs#37-37

Capability Grant System

Plugins operate under a CapabilityGrantSet, which allowlists specific external resources. These grants are translated into integer handles passed to the WASM guest at runtime. Code Entity Mapping: Runtime Execution Sources: [crates/palyra-plugins/runtime/src/lib.rs#105-186](http://crates/palyra-plugins/runtime/src/lib.rs#105-186), [crates/palyra-plugins/runtime/src/lib.rs#42-81](http://crates/palyra-plugins/runtime/src/lib.rs#42-81)

Skill Artifacts & Manifests

A Skill is a packaged .palyra-skill archive (ZIP format) containing a mandatory skill.toml manifest, WASM modules, and optional assets.

skill.toml Structure

The manifest defines the skill’s identity, required capabilities, and tool entrypoints.

Security & Trust Store

Palyra employs a Trust-on-First-Use (TOFU) pinning mechanism for skill publishers.
  1. Verification: The verify_skill_artifact function checks Ed25519 signatures against the SkillTrustStore crates/palyra-skills/src/verify.rs.
  2. Quarantine: Newly discovered skills or those with signature mismatches are placed in quarantine until promoted by an operator.
  3. Audit: The audit_skill_artifact_security function performs static analysis on the WASM module (e.g., checking exported function counts) crates/palyra-skills/src/audit.rs.
Code Entity Mapping: Skill Verification Flow Sources: [crates/palyra-skills/src/lib.rs#11-24](http://crates/palyra-skills/src/lib.rs#11-24), [crates/palyra-skills/src/manifest.rs#12-49](http://crates/palyra-skills/src/manifest.rs#12-49)

Plugin Execution Flow

When a tool call is dispatched to a WASM plugin, the wasm_plugin_runner.rs in the daemon handles the resolution and execution.
  1. Resolution: resolve_module_source determines if the module is inline or part of an installed skill crates/palyra-daemon/src/wasm_plugin_runner.rs#179-213.
  2. Capability Mapping: capability_grants_from_manifest extracts the required permissions from the skill.toml crates/palyra-skills/src/runtime.rs.
  3. Execution: execute_module initializes the WasmRuntime, sets the fuel budget, and invokes the entrypoint crates/palyra-daemon/src/wasm_plugin_runner.rs#271-310.

Error Handling

The runner maps WASM traps and resource exhaustion to WasmPluginRunErrorKind:
  • QuotaExceeded: Hit fuel or memory limits.
  • CapabilityDenied: Attempted to access a resource not in the manifest.
  • TimedOut: Exceeded wall_clock_timeout_ms.
Sources: [crates/palyra-daemon/src/wasm_plugin_runner.rs#43-51](http://crates/palyra-daemon/src/wasm_plugin_runner.rs#43-51), [crates/palyra-daemon/src/wasm_plugin_runner.rs#96-126](http://crates/palyra-daemon/src/wasm_plugin_runner.rs#96-126)

CLI Skill Commands

The palyra skills command group provides the primary interface for managing the skill lifecycle.
CommandFunctionKey Implementation
package buildCompiles manifest and WASM into a signed artifactbuild_signed_skill_artifact crates/palyra-cli/src/commands/skills.rs#59-67
package verifyValidates signatures and trust statusverify_skill_artifact crates/palyra-cli/src/commands/skills.rs#124-126
installAdds a skill to the managed skills directoryinstall_skill_artifact crates/palyra-cli/tests/skills_lifecycle.rs#186-197
listDisplays installed skills and their runtime statusemit_inventory_list crates/palyra-cli/src/output/skills.rs#25-57
Sources: [crates/palyra-cli/src/commands/skills.rs#5-105](http://crates/palyra-cli/src/commands/skills.rs#5-105), [crates/palyra-cli/src/output/skills.rs#4-119](http://crates/palyra-cli/src/output/skills.rs#4-119)