import type { VerbatimCompactionDetails, VerbatimCompactionPreparation, VerbatimCompactionResult } from "../compaction/index.ts"; import type { BranchSummaryEntry, CompactionEntry, CustomMessageEntry, SessionEntry } from "../session-manager.ts"; /** Fired after session_start to allow extensions to provide additional resource paths. */ export interface ResourcesDiscoverEvent { type: "resources_discover"; cwd: string; reason: "startup" | "reload"; } /** Result from resources_discover event handler */ export interface ResourcesDiscoverResult { skillPaths?: string[]; promptPaths?: string[]; themePaths?: string[]; } /** Fired when a session is started, loaded, or reloaded */ export interface SessionStartEvent { type: "session_start"; /** Why this session start happened. */ reason: "startup" | "reload" | "new" | "resume" | "fork"; /** Previously active session ID. Present for "new", "resume", and "fork". */ previousSessionId?: string; } /** Why a session's interrupted-work recovery is running. */ export type SessionRecoveryReason = "startup" | "resume" | "workflow_stage_resume"; /** * Fired once per session, after the host has shown the transcript and before interrupted * deliveries are replayed. Restore background work, such as child agents, here. */ export interface SessionRecoveryRestoreEvent { type: "session_recovery_restore"; reason: SessionRecoveryReason; } /** A durable delivery card that was shown before the process exited but never reached the model. */ export interface PendingRecoveryDelivery { /** Entry id of the original visible card. */ entryId: string; customType: string; content: CustomMessageEntry["content"]; details: CustomMessageEntry["details"]; /** ISO timestamp of the original card. */ timestamp: string; stageAdmissionKey?: string; delivery: "steer" | "followUp"; } /** Fired after `session_recovery_restore` when interrupted deliveries are waiting to be replayed. */ export interface SessionRecoveryReplayEvent { type: "session_recovery_replay"; reason: SessionRecoveryReason; pending: readonly PendingRecoveryDelivery[]; } /** Fired when the current session metadata changes. */ export interface SessionInfoChangedEvent { type: "session_info_changed"; /** Current normalized session name. Undefined when the name is cleared. */ name: string | undefined; } /** Fired before switching to another session (can be cancelled) */ export interface SessionBeforeSwitchEvent { type: "session_before_switch"; reason: "new" | "resume"; targetSessionId?: string; } /** Fired before forking a session (can be cancelled) */ export interface SessionBeforeForkEvent { type: "session_before_fork"; entryId: string; position: "before" | "at"; } /** Fired before context compaction (can be cancelled or customized) */ export interface SessionBeforeCompactEvent { type: "session_before_compact"; reason: "manual" | "threshold" | "overflow"; parameters: VerbatimCompactionPreparation["parameters"]; preparation: VerbatimCompactionPreparation; branchEntries: SessionEntry[]; signal: AbortSignal; } /** Fired after context compaction succeeds */ export interface SessionCompactEvent { type: "session_compact"; reason: "manual" | "threshold" | "overflow"; parameters: VerbatimCompactionPreparation["parameters"]; result: VerbatimCompactionResult; compactionEntry: CompactionEntry; fromExtension: boolean; } /** Fired after context compaction fails or is aborted. */ export interface SessionCompactFailedEvent { type: "session_compact_failed"; reason: "manual" | "threshold" | "overflow"; errorMessage?: string; aborted: boolean; willRetry: boolean; fromExtension: boolean; } /** Fired before an extension runtime is torn down due to quit, reload, or session replacement. */ export interface SessionShutdownEvent { type: "session_shutdown"; reason: "quit" | "reload" | "new" | "resume" | "fork"; /** Destination session ID when shutting down due to session replacement. */ targetSessionId?: string; /** True when a `quit` was caused by a host termination signal (SIGTERM/SIGHUP) rather than an explicit user quit. */ fromSignal?: boolean; } /** Preparation data for tree navigation */ export interface TreePreparation { targetId: string; oldLeafId: string | null; commonAncestorId: string | null; entriesToSummarize: SessionEntry[]; userWantsSummary: boolean; /** Custom instructions for summarization */ customInstructions?: string; /** If true, customInstructions replaces the default prompt instead of being appended */ replaceInstructions?: boolean; /** Label to attach to the branch summary entry */ label?: string; } /** Fired before navigating in the session tree (can be cancelled) */ export interface SessionBeforeTreeEvent { type: "session_before_tree"; preparation: TreePreparation; signal: AbortSignal; } /** Fired after navigating in the session tree */ export interface SessionTreeEvent { type: "session_tree"; newLeafId: string | null; oldLeafId: string | null; summaryEntry?: BranchSummaryEntry; fromExtension?: boolean; } export type SessionEvent = SessionStartEvent | SessionRecoveryRestoreEvent | SessionRecoveryReplayEvent | SessionInfoChangedEvent | SessionBeforeSwitchEvent | SessionBeforeForkEvent | SessionBeforeCompactEvent | SessionCompactEvent | SessionCompactFailedEvent | SessionShutdownEvent | SessionBeforeTreeEvent | SessionTreeEvent; //# sourceMappingURL=session-events.d.ts.map