import { createDecorator, type ServiceIdentifier } from '#/_base/di/instantiation'; import type { ISessionScopeHandle } from '#/_base/di/scope'; import type { Event, IWaitUntil } from '#/_base/event'; import type { SessionSummary } from '#/app/sessionIndex/sessionIndex'; import type { SessionMeta } from '#/session/sessionMetadata/sessionMetadata'; import type { CreateChildSessionOptions, CreateSessionOptions, ForkSessionOptions, ResumeSessionOptions, SessionArchivedEvent, SessionClosedEvent, SessionCreatedEvent, SessionForkedEvent, SessionWillCloseEvent, SessionWillCreateEvent, } from '#/workspace/sessionLifecycle/sessionLifecycle'; export interface CreateManagedSessionOptions extends CreateSessionOptions { readonly workspaceId?: string; } export interface UnguardedSessionLifecycle { archive(): Promise; restore(): Promise; } export interface ISessionManager { readonly _serviceBrand: undefined; readonly onWillCreateSession?: Event; readonly onDidCreateSession?: Event; readonly onWillCloseSession?: Event; readonly onDidCloseSession?: Event; readonly onWillDeleteSession?: Event<{ readonly sessionId: string } & IWaitUntil>; readonly onDidArchiveSession?: Event; readonly onDidForkSession?: Event; create(options: CreateManagedSessionOptions): Promise; resume(sessionId: string, options?: ResumeSessionOptions): Promise; get(sessionId: string): ISessionScopeHandle | undefined; status(sessionId: string): Promise; whenResumeSettled(sessionId: string): Promise; withLifecycleSerialization( sessionId: string, work: (unguarded: UnguardedSessionLifecycle) => Promise, ): Promise; list(): readonly ISessionScopeHandle[]; close(sessionId: string): Promise; archive(sessionId: string): Promise; restore(sessionId: string, options?: ResumeSessionOptions): Promise; delete(sessionId: string): Promise; fork(options: ForkSessionOptions): Promise; createChild(options: CreateChildSessionOptions): Promise; } export const ISessionManager: ServiceIdentifier = createDecorator('sessionManager');