Cortex SDK
The official Rust SDK for Cortex trusted native plugins.
cortex-sdk is the public boundary between a plugin crate and the Cortex
runtime. It defines plugin metadata, tool traits, runtime invocation context,
structured results, media attachments, effect declarations, and the stable
C-compatible native ABI used by trusted in-process plugins.
Process-isolated JSON plugins do not need this crate. They are described by a
plugin manifest and a child-process command. Use cortex-sdk when you are
building a reviewed native plugin that exports cortex_plugin_init and is
loaded into the daemon process.
Install
[]
= "1.6.11"
= "1"
Native plugins are built as cdylib shared libraries:
[]
= ["cdylib", "rlib"]
Minimal Plugin
use *;
;
;
export_plugin!;
Runtime Context
Tools that need session metadata, actor identity, transport/source, execution
scope, progress updates, or observer text should override
Tool::execute_with_runtime:
Use runtime callbacks for operator-visible progress only. Tool return values remain the authoritative data passed back to the model.
Effects and Policy
Declare side effects so Cortex can apply policy and permission gates before a tool runs:
Good effect declarations should be specific enough for the operator to understand the blast radius: path, network host, process command, or stateful operation. Do not hide side effects in generic descriptions.
Media Results
Return files through structured attachments instead of calling transport APIs:
Ok
Cortex is responsible for delivering attachments through the active transport.
Native ABI
The runtime loads a native plugin with dlopen, calls
cortex_plugin_init, and receives a CortexPluginApi function table. Rust
trait objects never cross the dynamic-library boundary. Structured values move
through UTF-8 JSON buffers allocated by the plugin and released through the SDK
ABI helpers.
NATIVE_ABI_VERSION is the ABI compatibility marker. Plugin manifests must set
[native].abi_version to the ABI version they target.
Manifest
Native plugins also need a Cortex manifest:
= "example"
= "0.1.0"
= "Example Cortex native plugin"
= "1.6.11"
= "trusted_native"
[]
= ["tools"]
= []
= []
= []
= false
= false
= false
[]
= "trusted_in_process"
[]
= "lib/libexample.so"
= "trusted_in_process"
= 1
Release Checklist
- Build the shared library with
cargo build --release. - Copy the library into the manifest-declared
lib/path. - Run
cortex plugin review .. - Run
cortex plugin test .. - Sign with a private key stored outside the repository.
- Pack with
cortex plugin pack .. - Publish the
.cpxarchive and checksum as release assets.
Documentation
- Runtime and plugin guide: https://github.com/by-scott/cortex/blob/main/docs/plugin-development.md
- SDK API docs: https://docs.rs/cortex-sdk/latest/cortex_sdk/
- Cortex releases: https://github.com/by-scott/cortex/releases/latest
License
MIT.