Skip to main content

sim_lib_skill/
lib.rs

1//! Agent skills for the SIM runtime.
2//!
3//! A *skill* is a callable capability that an agent can invoke -- a tool, a
4//! model, a resource, a prompt, a memory, a retriever, a judge, or a router.
5//! Each skill is described by a [`SkillCard`] that pairs a stable identity and
6//! symbol with input and output [`sim_shape`] contracts, a [`SkillPolicy`]
7//! governing caching/recording/privacy, and the transport that actually runs
8//! the call. Cards are bound into a [`SkillRegistry`] and exposed as ordinary
9//! callable runtime objects through [`SkillCallable`].
10//!
11//! Behavior is provided by a [`SkillTransport`]: a backend (fixture, HTTP, MCP,
12//! process, OpenAI-compatible server, ...) that knows how to discover and call
13//! skills. [`SkillLib`] registers the `skill/*` operations (install, bind,
14//! list, card, call, and the feature-gated audit/tool/runner/serve surfaces)
15//! when the library is loaded into a [`sim_kernel::Cx`].
16//!
17//! Optional Cargo features select transports and integrations: `mcp`, `http`,
18//! `openai`, `process`, `agent`, `runner`, `serve`, and the `cache`/`cassette`
19//! recording surfaces.
20
21#![forbid(unsafe_code)]
22#![deny(missing_docs)]
23
24#[cfg(feature = "agent")]
25mod agent;
26mod browse;
27mod callable;
28mod card;
29mod citizen;
30mod expr;
31mod fixture;
32#[cfg(feature = "http")]
33pub mod http;
34mod install;
35mod manifest;
36#[cfg(feature = "mcp")]
37pub mod mcp;
38#[cfg(feature = "openai")]
39mod openai;
40mod ops;
41#[cfg(feature = "process")]
42pub mod process;
43#[cfg(any(feature = "cache", feature = "cassette"))]
44mod record;
45mod registry;
46#[cfg(feature = "runner")]
47mod runner;
48#[cfg(feature = "serve")]
49mod serve;
50mod transport;
51
52/// Cookbook recipes for this lib, embedded at build time.
53pub static RECIPES: sim_cookbook::EmbeddedDir =
54    include!(concat!(env!("OUT_DIR"), "/cookbook_recipes.rs"));
55
56#[cfg(test)]
57mod tests;
58
59#[cfg(feature = "agent")]
60pub use agent::skill_as_tool_symbol;
61pub use callable::SkillCallable;
62pub use card::{
63    FixtureSkillSpec, SkillCacheMode, SkillCard, SkillCassetteMode, SkillPolicy,
64    SkillPrivacyPolicy, SkillRole,
65};
66pub use citizen::{SkillCardDescriptor, skill_card_descriptor_class_symbol};
67pub use fixture::{FixtureBehavior, FixtureTransport};
68pub use install::{install_fixture_skill, install_skill_lib};
69pub use manifest::{SkillLib, manifest_name, skill_exports};
70#[cfg(feature = "mcp")]
71pub use mcp::{
72    FixtureMcpTransport, McpCallParams, McpPromptArgument, McpPromptDescriptor, McpPromptGetParams,
73    McpResourceDescriptor, McpResourceReadParams, McpToolDescriptor, McpToolResult,
74    mcp_call_params_class_symbol, mcp_prompt_argument_class_symbol,
75    mcp_prompt_descriptor_class_symbol, mcp_prompt_get_params_class_symbol,
76    mcp_resource_descriptor_class_symbol, mcp_resource_read_params_class_symbol,
77    mcp_tool_descriptor_class_symbol, mcp_tool_result_class_symbol, skill_mcp_call_symbol,
78    skill_mcp_tools_symbol,
79};
80#[cfg(feature = "openai")]
81pub use openai::{
82    insert_skill_openai_tools, skill_openai_tool_descriptor, skill_openai_tool_symbol,
83    skill_openai_tools_symbol,
84};
85pub use ops::{
86    SkillFunction, skill_bind_symbol, skill_call_capability, skill_call_symbol, skill_card_symbol,
87    skill_install_capability, skill_install_symbol, skill_list_symbol, skill_serve_capability,
88    skill_specific_call_capability,
89};
90#[cfg(any(feature = "cache", feature = "cassette"))]
91pub use ops::{skill_audit_capability, skill_audit_symbol};
92#[cfg(feature = "process")]
93pub use process::{
94    ProcessSkillProtocol, ProcessSkillSpec, ProcessSkillTransport, skill_process_capability,
95};
96pub use registry::{SkillRegistry, skill_registry, skill_registry_symbol};
97#[cfg(feature = "runner")]
98pub use runner::{SkillModelRunner, skill_as_runner_symbol, skill_model_runner};
99#[cfg(feature = "serve")]
100pub use serve::skill_serve_mcp_symbol;
101pub use transport::{SkillEventSink, SkillTransport, SkillTransportValue, skill_transport_value};
102
103/// Stable identifier for the skill library and its symbol namespace.
104pub const SKILL_LIB_ID: &str = "skill";