Expand description
AgentSessionRuntime — owns the current AgentSession and drives the
new / switch / fork / import replacement pipeline.
Ports coding-agent/src/core/agent-session-runtime.ts. The runtime is
single-owner: each replacement operation (under a serializing async mutex)
creates the replacement session, tears down the current one, atomically
swaps, and rebinds listeners on the new session.
Replacement order (matches TS regression 2860: withSession runs AFTER
rebind on the NEW session):
emit_before_switch/emit_before_fork(cancellable).- Build the new session manager.
- Call the factory → new session + services + diagnostics.
teardown_current: typedsession_shutdown{reason, targetSessionFile}emit, thenbefore_session_invalidate, thensession.dispose().apply(result): swap session + services + diagnostics.finish_session_replacement:rebind_session(new_session)then optionalwith_session(ctx). The mode’s rebind callsbind_extensionson the new session, which emits the storedsession_start{new|resume|fork}after the old host received itssession_shutdownin step 4.
Re-exports§
pub use crate::core::session_transfer::SessionImportFileNotFoundError as SessionImportFileNotFound;
Structs§
- Agent
Session Runtime - Owns the current
AgentSessionplus cwd-bound services, and drives the replacement pipeline for new / switch / fork / import. - Agent
Session Runtime Services - Cwd-bound service handles the runtime needs to drive replacements.
- Create
Agent Session Runtime Options - Inputs to
CreateAgentSessionRuntimeFactory::create. - Create
Agent Session Runtime Result - Result returned by
CreateAgentSessionRuntimeFactory::create. - Fork
Outcome - Outcome of
fork. - NewSession
Options - Options for
AgentSessionRuntime::new_session. - Switch
Outcome - Outcome of
new_session/switch_session/import_from_jsonl. - Switch
Session Options - Options for
AgentSessionRuntime::switch_session.
Enums§
- Agent
Session Runtime Error - Errors from runtime operations.
- Fork
Position - Options for
AgentSessionRuntime::fork.
Traits§
- Create
Agent Session Runtime Factory - Factory that builds a fresh session + services from a session manager.
Functions§
- create_
agent_ session_ runtime - Create the initial runtime from a factory and initial session manager.
Type Aliases§
- Before
Session Invalidate Callback - Synchronous callback invoked after
session_shutdownhandlers finish but before the old session is invalidated (host UI teardown that must not yield to the event loop). - Rebind
Session Callback - Async callback invoked on the new session after teardown + apply, before
with_session. Re-binds listeners / event subscriptions.