Single-owner coordinator for client-side Hooks v2 state.
HooksManager is the only place in the client that builds or holds a
HooksRuntime. The Textual app, the Textual stream adapter, and the headless
runner each hold a manager and call intention-revealing lifecycle methods on
it; none of them inspect the runtime, the hook service, or their availability.
A manager whose configuration failed to load stays usable and answers every call with a neutral result, so consumers never need an availability check.
Reads current session identity at invocation time, never cached.
Client state required to create a domain hook invocation.
Execute client-owned events and apply their common side effects.
User-facing output goes through the runtime's presenter, which the owning
HooksManager also holds. The service never wraps or replaces it, so there
is exactly one presenter per session.
Raised when a client-owned hook stops lifecycle processing.
Supported hook lifecycle events.
Normalized result shared by TUI and headless permission handling.
How one batch of gated tool calls was resolved by hooks.
Indices refer to positions in the originating action_requests list, so a
caller can line outcomes back up with its own UI rows.
Present hook output consistently across interactive and headless clients.
Decides whether project-scoped hooks may run in a given directory.
Trust is a property of the workspace, not of the session, so it must be re-resolved every time the working directory moves. A session that starts in a trusted project and later moves into an untrusted one must not carry the original grant forward.
Callers hand this policy to HooksManager, which resolves it on load and on
every reload; nothing upstream needs to hold or reinterpret the decision.
Client-facing builder for the per-run graph context payload.
Callers populate this and pass it via context= to astream/ainvoke.
ConfigurableModelMiddleware and the interrupt_on when predicate read
it from request.runtime.context. In-process LangGraph coerces it into
CLIContextSchema (the registered context_schema); over the API it stays
a plain dict — which is why consumers handle both shapes.
Tool-approval policy selected for an interactive thread.
Reason context compaction was requested.
dcode lifecycle notifications with compatible wire mappings.
Reason a session-end event occurred.
Reason a session-start event occurred.
Native tool-call data used by hook lifecycle owners.
Callable that surfaces a user-visible hook notice.
Callable that updates hook-owned transient status text.
Client-owned session runtime around an immutable Hooks snapshot.
Owns configuration snapshot identity, transcript materialization, and the
HookEngine. Server-owned lifecycle events reach this runtime through the
interrupt fulfill path in hooks.client.
Collect completed stream messages into a Hooks transcript runtime.
A discovered plugin ready to feed dcode adapters.
Live client identity projected into every hook invocation.
Result of a lifecycle hook that may halt the caller.
Result of UserPromptSubmit, including its prompt rewrites.
Owns the Hooks v2 runtime, presenter, hook service, and transcripts.
The presenter is the manager's, not the runtime's: one instance is created once and handed to every runtime the manager loads, so a reload or a late UI attachment never leaves two presenters competing for the same output.