Skip to main content

LifecycleHookEngine

Struct LifecycleHookEngine 

Source
pub struct LifecycleHookEngine { /* private fields */ }

Implementations§

Source§

impl LifecycleHookEngine

Source

pub fn new_with_session_gated( workspace: PathBuf, config: &HooksConfig, trigger: SessionStartTrigger, session_id: impl Into<String>, workspace_gated: bool, ) -> Result<Option<Self>>

Construct the engine with the workspace approval gate.

When workspace_gated is true, the workspace configuration (a workspace-root vtcode.toml, the workspace .vtcode/ fallback, a project profile, or a workspace-sourced agent spec with hooks) contains lifecycle hook commands. No lifecycle command then executes until the user explicitly approves the exact command set this engine will run, bound to its digest. Callers must pass true whenever VTCodeConfig.workspace_lifecycle_hooks is non-empty or the active primary agent contributes workspace-controlled hooks.

Source

pub async fn run_session_start(&self) -> Result<SessionStartHookOutcome>

Source

pub async fn run_session_end( &self, turn_id: &str, reason: SessionEndReason, ) -> Result<Vec<HookMessage>>

Source

pub async fn run_subagent_start( &self, parent_session_id: &str, child_thread_id: &str, agent_name: &str, display_label: &str, background: bool, status: &str, transcript_path: Option<&Path>, ) -> Result<Vec<HookMessage>>

Source

pub async fn run_subagent_stop( &self, parent_session_id: &str, child_thread_id: &str, agent_name: &str, display_label: &str, background: bool, status: &str, transcript_path: Option<&Path>, ) -> Result<Vec<HookMessage>>

Source

pub async fn run_user_prompt_submit( &self, turn_id: &str, prompt: &str, ) -> Result<UserPromptHookOutcome>

Execute all UserPromptSubmit hooks that match the prompt content.

Source

pub async fn run_permission_request( &self, tool_name: &str, tool_input: Option<&Value>, permission_request: &PermissionRequest, permission_suggestions: &[Value], ) -> Result<PermissionRequestHookOutcome>

Execute all PermissionRequest hooks that match the tool name.

Source

pub async fn run_pre_tool_use( &self, tool_name: &str, tool_input: Option<&Value>, tool_call_id: Option<&str>, ) -> Result<PreToolHookOutcome>

Execute all PreToolUse hooks that match the tool name.

Hooks run in configuration order. When a hook returns hookSpecificOutput.updatedInput, later hooks receive the rewritten tool input in their payload, so policy hooks placed after rewrite hooks observe the final command. The first Allow/Deny decision still short-circuits the remaining hooks.

Source

pub async fn run_post_tool_use( &self, tool_name: &str, tool_input: Option<&Value>, tool_output: &Value, tool_call_id: Option<&str>, ) -> Result<PostToolHookOutcome>

Execute all PostToolUse hooks that match the tool name.

Source

pub async fn run_pre_compact( &self, trigger: CompactionTrigger, mode: CompactionMode, original_message_count: usize, compacted_message_count: usize, history_artifact_path: Option<&str>, ) -> Result<PreCompactHookOutcome>

Execute all PreCompact hooks that match the compaction trigger.

Source

pub async fn run_notification( &self, notification_type: NotificationHookType, title: &str, message: &str, ) -> Result<Vec<HookMessage>>

Execute all Notification hooks that match the notification type.

Source

pub async fn run_stop( &self, last_assistant_message: &str, stop_hook_active: bool, ) -> Result<StopHookOutcome>

Execute all Stop hooks.

Source

pub async fn update_transcript_path(&self, path: Option<PathBuf>)

Update the transcript path that hooks can access via the VT_TRANSCRIPT_PATH env var.

Source

pub async fn transcript_path(&self) -> Option<PathBuf>

Return the current transcript path, if set.

Source

pub fn workspace_gated(&self) -> bool

Whether the workspace approval gate is active for this engine.

Source

pub fn command_digest(&self) -> &str

Digest of the exact lifecycle command set this engine will execute. Approvals are bound to this digest and revalidated before every spawn.

Source

pub fn command_previews(&self) -> Vec<LifecycleHookCommandPreview>

Every lifecycle command this engine will execute, with its canonical event key — the exact set an approval covers.

Source

pub async fn approve_workspace_hooks(&self)

Mark this engine’s exact command set as approved for the session. Only a digest equal to command_digest() satisfies the gate.

Source

pub async fn workspace_hooks_need_approval(&self) -> bool

Whether the gate is active and the current command set is not yet approved. The binary prompts the user before the first lifecycle run when this is true.

Trait Implementations§

Source§

impl Clone for LifecycleHookEngine

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

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> CacheValue for T
where T: Send + Sync + Clone + 'static,

Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> PtyHandle for T
where T: Send,

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WasmCompatSend for T
where T: Send,

Source§

impl<T> WasmCompatSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more