Skip to main content

PluginApi

Struct PluginApi 

Source
#[repr(C)]
pub struct PluginApi {
Show 18 fields pub abi_version: u32, pub struct_size: u32, pub free_string: FreeStringFn, pub register_tool: Option<extern "C" fn(schema: *const StableToolSchema, execute_fn: ToolExecuteFn, poll_fn: ToolPollFn, cancel_fn: ToolCancelFn, destroy_fn: ToolDestroyFn, plugin_free_string: FreeStringFn) -> i32>, pub register_command: Option<extern "C" fn(name: StbStringRef, description: StbStringRef, handler: CommandHandlerFn) -> i32>, pub register_shortcut: Option<extern "C" fn(key: StbStringRef, description: StbStringRef) -> i32>, pub register_flag: Option<extern "C" fn(name: StbStringRef, description: StbStringRef) -> i32>, pub register_provider: Option<extern "C" fn(provider_id: StbStringRef, base_url: StbStringRef, api_style: StbStringRef, request_fn: ProviderRequestFn, plugin_free_string: FreeStringFn, user_data: *mut c_void) -> i32>, pub register_message_renderer: Option<extern "C" fn(name: StbStringRef, render_fn: RenderFn, plugin_free_string: FreeStringFn, user_data: *mut c_void) -> i32>, pub register_markdown_transformer: Option<extern "C" fn(name: StbStringRef, render_fn: RenderFn, plugin_free_string: FreeStringFn, user_data: *mut c_void) -> i32>, pub register_entry_renderer: Option<extern "C" fn(name: StbStringRef, render_fn: RenderFn, plugin_free_string: FreeStringFn, user_data: *mut c_void) -> i32>, pub register_event_handler: Option<extern "C" fn(tag: EventTag, handler: EventHandlerFn, user_data: *mut c_void) -> i32>, pub register_resources_discover: Option<extern "C" fn(handler: ResourcesDiscoverFn, plugin_free_string: FreeStringFn, user_data: *mut c_void) -> i32>, pub runtime_action: RuntimeActionFn, pub dispatch_event: Option<extern "C" fn(event: StablePluginEvent, user_data: *mut c_void) -> i32>, pub user_data: *mut c_void, pub declare: Option<extern "C" fn(json: StbStringRef) -> i32>, pub register_before_agent_start: Option<extern "C" fn(handler: BeforeAgentStartFn, plugin_free_string: FreeStringFn, user_data: *mut c_void) -> i32>,
}
Expand description

The host-provided API struct. The first two fields (abi_version and struct_size) are contract-identity markers that survive future signature changes: a plugin reads them from the pointer before anything else, so even if the entrypoint arity changes, the version check remains robust.

Fields§

§abi_version: u32

Contract identity. First field so a plugin can validate before reading anything else, independent of the entrypoint arity.

§struct_size: u32

sizeof(PluginApi) as the host built it. Lets a plugin detect a host that predates slots it wants (host_struct_size < plugin’s expected offset). Future hosts may grow this struct; old plugins check struct_size before accessing new fields.

§free_string: FreeStringFn

Host’s free_string — the plugin calls this for every StbString it receives from the host (outputs of actions, event payloads, inputs to execute). Never null.

§register_tool: Option<extern "C" fn(schema: *const StableToolSchema, execute_fn: ToolExecuteFn, poll_fn: ToolPollFn, cancel_fn: ToolCancelFn, destroy_fn: ToolDestroyFn, plugin_free_string: FreeStringFn) -> i32>§register_command: Option<extern "C" fn(name: StbStringRef, description: StbStringRef, handler: CommandHandlerFn) -> i32>§register_shortcut: Option<extern "C" fn(key: StbStringRef, description: StbStringRef) -> i32>§register_flag: Option<extern "C" fn(name: StbStringRef, description: StbStringRef) -> i32>§register_provider: Option<extern "C" fn(provider_id: StbStringRef, base_url: StbStringRef, api_style: StbStringRef, request_fn: ProviderRequestFn, plugin_free_string: FreeStringFn, user_data: *mut c_void) -> i32>§register_message_renderer: Option<extern "C" fn(name: StbStringRef, render_fn: RenderFn, plugin_free_string: FreeStringFn, user_data: *mut c_void) -> i32>§register_markdown_transformer: Option<extern "C" fn(name: StbStringRef, render_fn: RenderFn, plugin_free_string: FreeStringFn, user_data: *mut c_void) -> i32>§register_entry_renderer: Option<extern "C" fn(name: StbStringRef, render_fn: RenderFn, plugin_free_string: FreeStringFn, user_data: *mut c_void) -> i32>§register_event_handler: Option<extern "C" fn(tag: EventTag, handler: EventHandlerFn, user_data: *mut c_void) -> i32>§register_resources_discover: Option<extern "C" fn(handler: ResourcesDiscoverFn, plugin_free_string: FreeStringFn, user_data: *mut c_void) -> i32>§runtime_action: RuntimeActionFn§dispatch_event: Option<extern "C" fn(event: StablePluginEvent, user_data: *mut c_void) -> i32>§user_data: *mut c_void§declare: Option<extern "C" fn(json: StbStringRef) -> i32>

Declare this plugin’s host-side preferences as a JSON object, e.g. {"priority":60,"platforms":["linux","macos"]}. Nullable: host does not support declarations yet (plugin skips the call; host applies defaults: priority 100, all platforms).

§register_before_agent_start: Option<extern "C" fn(handler: BeforeAgentStartFn, plugin_free_string: FreeStringFn, user_data: *mut c_void) -> i32>

Register a system-prompt transformer for the run (pi’s before_agent_start returning systemPrompt).

Appended last on purpose. A plugin compiled against a shorter PluginApi indexes every earlier field by offset, so a slot inserted in the middle would make an old plugin read the new host’s fields at the wrong offsets. Appending keeps every existing offset valid, which is what lets this ship without an ABI version bump; a plugin checks struct_size (or the slot for None) before using it.

Nullable: a host that predates this slot leaves it None, the plugin skips the call, and the prompt is left alone — exactly that host’s behavior before this slot existed.

Trait Implementations§

Source§

impl Clone for PluginApi

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for PluginApi

Source§

impl Send for PluginApi

Source§

impl Sync for PluginApi

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.