HooksManager(
self,
identity: SessionIdentityProvider,
presenter: HookPresenter = HookPresenter(),
_runtime:| Name | Type |
|---|---|
| identity | SessionIdentityProvider |
| presenter | HookPresenter |
| _runtime | HooksRuntime | None |
| trust | WorkspaceTrust |
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.
Policy re-resolved on every reload; the manager is its only interpreter.
Whether hook configuration loaded successfully for this session.
Load hook configuration and return a ready manager.
Never raises: a failed load yields an inert manager whose lifecycle methods are all no-ops.
Wrap an already-loaded runtime.
A supplied runtime brought its own presenter, so that one is adopted rather than displaced; the given sinks are bound onto it so the runtime and the manager keep sharing a single instance.
Return a manager that runs nothing, for state built before setup.
Route hook notices, diagnostics, and progress to a client's UI.
For callers handed a manager that was loaded before their UI existed. Load diagnostics are re-presented so anything the earlier load could only log now reaches the user.
Return whether any handler is configured for event.
Rebuild the runtime after configuration or working-directory changes.
Workspace trust is re-resolved for cwd, so moving from a trusted
project into an untrusted one drops project hooks instead of carrying
the previous grant forward. The presenter survives the reload, so the
client's output sinks stay bound.
Pending SessionStart context is dropped with the old runtime, matching
the lifecycle boundary that triggers a reload.
Run SessionStart and accumulate any context it returns.
Context is retained rather than returned; take_pending_context
consumes it when the next model turn is assembled.
Run SessionEnd for the outgoing thread.
Run UserPromptSubmit before a user turn reaches the model.
Run PreCompact before conversation compaction.
Run PermissionRequest for each pending tool call.
Run Notification for one supported dcode notification.
Consume SessionStart context accumulated for the next model turn.
Return a transcript recorder for one stream.
Project checkpoint messages into the client transcript.
Stamp snapshot identity and server event gates onto graph context.
Execute one server-owned hook interrupt on the client runtime.
Execute a batch of server-owned hook interrupts.