Skip to main content

ExtensionEvent

Enum ExtensionEvent 

Source
pub enum ExtensionEvent<'a> {
Show 28 variants ResourcesDiscover { cwd: &'a Path, reason: &'a str, }, McpServersChange { servers: &'a [RegisteredMcpServer], }, SessionStart { reason: &'a str, previous_session_file: Option<&'a str>, }, SessionInfoChanged { name: Option<&'a str>, }, SessionBeforeSwitch { reason: &'a str, target_session_file: Option<&'a str>, }, SessionBeforeFork { entry_id: &'a str, position: &'a str, }, SessionBeforeCompact { preparation: Value, branch_entries: &'a [&'a FileEntry], custom_instructions: Option<&'a str>, reason: CompactionReason, will_retry: bool, }, SessionCompact { compaction_entry: &'a FileEntry, from_extension: bool, reason: CompactionReason, will_retry: bool, }, SessionCompactFailed { reason: CompactionReason, error_message: Option<&'a str>, aborted: bool, will_retry: bool, from_extension: bool, }, SessionShutdown { reason: &'a str, target_session_file: Option<&'a str>, }, SessionBeforeTree { preparation: TreePreparation<'a>, }, SessionTree { new_leaf_id: Option<&'a str>, old_leaf_id: Option<&'a str>, summary_entry: Option<&'a FileEntry>, from_extension: Option<bool>, }, Context { messages: &'a [Message], }, ContextWithSystem { messages: &'a [Message], }, AfterProviderResponse { status: u16, headers: &'a IndexMap<String, String>, }, BeforeAgentStart { prompt: &'a str, images: &'a [ImageContent], system_prompt: &'a str, system_prompt_options: &'a SystemPromptOptions, }, AgentBeforeSettle { outcome: &'a str, }, AgentSettled, UiPromptStart(UiPrompt<'a>), UiPromptEnd(UiPrompt<'a>), TurnEnd { turn_index: u64, message: &'a Message, tool_results: &'a [Message], message_entry_id: &'a str, tool_result_entry_ids: &'a [String], outcome: &'a str, }, MessageEnd { message: &'a Value, }, ModelSelect { model: &'a Model, previous_model: Option<&'a Model>, source: &'a str, }, ThinkingLevelSelect { level: ThinkingLevel, previous_level: ThinkingLevel, }, UserBash { command: &'a str, exclude_from_context: bool, cwd: &'a Path, }, Input { text: &'a str, images: &'a [ImageContent], source: &'a str, streaming_behavior: Option<StreamingBehavior>, }, ToolCall { tool_name: &'a str, tool_call_id: &'a str, parent_tool_call_id: Option<&'a str>, input: &'a Value, }, ToolResult { tool_name: &'a str, tool_call_id: &'a str, parent_tool_call_id: Option<&'a str>, input: &'a Value, content: &'a [ContentBlock], details: Option<&'a Value>, structured_content: Option<&'a Value>, is_error: bool, usage: Option<&'a Usage>, },
}
Expand description

A pi event for extension handlers. Absent optional fields are left out, as pi leaves them undefined.

Variants§

§

ResourcesDiscover

Fields

§cwd: &'a Path
§reason: &'a str
§

McpServersChange

Fields

§servers: &'a [RegisteredMcpServer]
§

SessionStart

Fields

§reason: &'a str
§previous_session_file: Option<&'a str>
§

SessionInfoChanged

Fields

§name: Option<&'a str>
§

SessionBeforeSwitch

Fields

§reason: &'a str
§target_session_file: Option<&'a str>
§

SessionBeforeFork

Fields

§entry_id: &'a str
§position: &'a str

at or before.

§

SessionBeforeCompact

Fields

§preparation: Value

pi’s CompactionPreparation, which yapi-core defines.

§branch_entries: &'a [&'a FileEntry]
§custom_instructions: Option<&'a str>
§will_retry: bool
§

SessionCompact

Fields

§compaction_entry: &'a FileEntry
§from_extension: bool
§will_retry: bool
§

SessionCompactFailed

Fields

§error_message: Option<&'a str>
§aborted: bool
§will_retry: bool
§from_extension: bool
§

SessionShutdown

Fields

§reason: &'a str
§target_session_file: Option<&'a str>
§

SessionBeforeTree

Fields

§preparation: TreePreparation<'a>
§

SessionTree

Fields

§new_leaf_id: Option<&'a str>
§old_leaf_id: Option<&'a str>
§summary_entry: Option<&'a FileEntry>
§from_extension: Option<bool>
§

Context

Fields

§messages: &'a [Message]
§

ContextWithSystem

Fields

§messages: &'a [Message]
§

AfterProviderResponse

Fields

§status: u16
§headers: &'a IndexMap<String, String>
§

BeforeAgentStart

Fields

§prompt: &'a str
§images: &'a [ImageContent]
§system_prompt: &'a str
§system_prompt_options: &'a SystemPromptOptions
§

AgentBeforeSettle

Fields

§outcome: &'a str
§

AgentSettled

§

UiPromptStart(UiPrompt<'a>)

§

UiPromptEnd(UiPrompt<'a>)

§

TurnEnd

Fields

§turn_index: u64
§message: &'a Message
§tool_results: &'a [Message]
§message_entry_id: &'a str
§tool_result_entry_ids: &'a [String]
§outcome: &'a str
§

MessageEnd

Fields

§message: &'a Value

The message as the previous handler left it.

§

ModelSelect

Fields

§model: &'a Model
§previous_model: Option<&'a Model>
§source: &'a str
§

ThinkingLevelSelect

Fields

§previous_level: ThinkingLevel
§

UserBash

Fields

§command: &'a str
§exclude_from_context: bool
§cwd: &'a Path
§

Input

Fields

§text: &'a str
§images: &'a [ImageContent]
§source: &'a str
§streaming_behavior: Option<StreamingBehavior>
§

ToolCall

Fields

§tool_name: &'a str
§tool_call_id: &'a str
§parent_tool_call_id: Option<&'a str>
§input: &'a Value
§

ToolResult

Fields

§tool_name: &'a str
§tool_call_id: &'a str
§parent_tool_call_id: Option<&'a str>
§input: &'a Value
§content: &'a [ContentBlock]
§details: Option<&'a Value>
§structured_content: Option<&'a Value>
§is_error: bool
§usage: Option<&'a Usage>

Implementations§

Source§

impl ExtensionEvent<'_>

Source

pub fn to_value(&self) -> Value

The event as the JSON document handlers receive.

Trait Implementations§

Source§

impl<'a> Debug for ExtensionEvent<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Serialize for ExtensionEvent<'a>

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for ExtensionEvent<'a>

§

impl<'a> RefUnwindSafe for ExtensionEvent<'a>

§

impl<'a> Send for ExtensionEvent<'a>

§

impl<'a> Sync for ExtensionEvent<'a>

§

impl<'a> Unpin for ExtensionEvent<'a>

§

impl<'a> UnsafeUnpin for ExtensionEvent<'a>

§

impl<'a> UnwindSafe for ExtensionEvent<'a>

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> 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, 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.