/** * Pure REST handlers for `/api/sessions/*`. * * Same shape as projects handlers — see that file's header for the contract. * * Note: session deletion does not tear down the in-flight spectral stream itself. * The Batch 3 dispatcher must call `manager.disposeSessionStream(id)` BEFORE * invoking `handleDeleteSession` so the FK cascade doesn't leave a zombie * bridge driving events at a row that no longer exists. This matches the * ordering the old Hono route used. */ import type { SessionStreamManager } from "../session-stream.js"; import type { SessionStore } from "../storage.js"; import type { WireSessionDetail, WireSessionMemoryDetails, WireSessionMemoryStatus, WireSessionSummary } from "../wire.js"; export type CompactSessionMode = "dcp-lite"; export interface CreateSessionInputRaw { projectId?: unknown; title?: unknown; } export interface UpdateSessionInputRaw { title?: unknown; manual?: unknown; } export interface UpdateSessionAgentInputRaw { activeAgent?: unknown; } export interface GetSessionMessagesInputRaw { beforeSeq?: unknown; beforeCreatedAt?: unknown; beforeId?: unknown; limit?: unknown; } export interface GetSessionMessagesInputRaw { beforeSeq?: unknown; beforeCreatedAt?: unknown; beforeId?: unknown; limit?: unknown; } export interface CompactSessionInputRaw { mode?: unknown; } export declare function parseCompactSessionMode(body: unknown): CompactSessionMode; export declare function handleCreateSession(store: SessionStore, body: CreateSessionInputRaw): WireSessionSummary; export declare function handleGetSessionDetail(store: SessionStore, id: string): WireSessionDetail; /** Async relay-path twin of {@link handleGetSessionDetail}. */ export declare function handleGetSessionDetailAsync(store: SessionStore, id: string): Promise; export declare function handleGetSessionMessages(store: SessionStore, id: string, query: GetSessionMessagesInputRaw): WireSessionDetail; /** Async relay-path twin of {@link handleGetSessionMessages}. */ export declare function handleGetSessionMessagesAsync(store: SessionStore, id: string, query: GetSessionMessagesInputRaw): Promise; export declare function handleUpdateSession(store: SessionStore, id: string, body: UpdateSessionInputRaw): WireSessionSummary; export declare function handleGetSessionActiveAgent(store: SessionStore, id: string, cwd?: string, agentDir?: string): { activeAgent: string | null; }; /** Async relay-path twin of {@link handleGetSessionActiveAgent}. */ export declare function handleGetSessionActiveAgentAsync(store: SessionStore, id: string, cwd?: string, agentDir?: string): Promise<{ activeAgent: string | null; }>; export declare function handleUpdateSessionActiveAgent(store: SessionStore, id: string, body: UpdateSessionAgentInputRaw, manager?: SessionStreamManager, cwd?: string, agentDir?: string): { activeAgent: string | null; }; /** Async relay-path twin of {@link handleUpdateSessionActiveAgent}. */ export declare function handleUpdateSessionActiveAgentAsync(store: SessionStore, id: string, body: UpdateSessionAgentInputRaw, manager?: SessionStreamManager, cwd?: string, agentDir?: string): Promise<{ activeAgent: string | null; }>; export declare function handleDeleteSession(store: SessionStore, id: string): void; export interface CleanupAllSessionsInputRaw { olderThanDays?: unknown; } export interface CleanupAllSessionsResult { deleted: number; ids: string[]; /** sessionId → owning projectId, captured before deletion for event attribution. */ projectIds: Record; } /** * Cross-project twin of `handleCleanupProjectSessions` (projects.ts): no * project filter, so validation is the only gate. Stream teardown and * `session_deleted` meta-event publication remain the dispatcher's job — * see `cleanup_all_sessions` there. */ export declare function handleCleanupAllSessions(store: SessionStore, body: CleanupAllSessionsInputRaw): CleanupAllSessionsResult; export declare function handleGetSessionMemoryStatus(store: SessionStore, manager: SessionStreamManager, id: string): WireSessionMemoryStatus; export declare function handleGetSessionMemoryDetails(store: SessionStore, manager: SessionStreamManager, id: string): WireSessionMemoryDetails; export declare function handleCompactSession(store: SessionStore, manager: SessionStreamManager, id: string, body?: unknown): Promise<{ ok: true; }>; /** * Remember & delete: compact the session (which persists observations as * project memory via the compaction hook), then delete the session. * * This gives the user a way to keep a session's reflections as durable * cross-session memory even for short sessions that never hit the compaction * threshold naturally. */ export declare function handleRememberAndDeleteSession(store: SessionStore, manager: SessionStreamManager, id: string): Promise<{ ok: true; }>; /** * Fork a session: create a new session copying all messages from the * source, with the `fork_compact_source_id` flag set so the * SessionStreamManager compacts after the first assistant turn. */ export declare function handleForkSession(store: SessionStore, id: string, body: { title?: unknown; }): WireSessionSummary; //# sourceMappingURL=sessions.d.ts.map