/** * GatewaySessionsApi — session CRUD, search, compaction, tag/pin/archive, * stats, and chat-id grouping for the gateway REST surface. * * Twenty-four methods, previously sitting on `GatewayService` as a mix of * one-line `sessionIndex.*` delegations and small composite operations (e.g. * `restoreCheckpoint` also evicts the in-memory agent, `runCompaction` also * appends a transcript context entry). Centralising them here lets routes * depend on the narrow `GatewaySessionsApi` surface instead of the full * `GatewayService`, and keeps the gateway composition root focused on * lifecycle + wiring. */ import type { AgentService } from '../../agent/service.js'; import type { CompactionResult } from '../../agent/memory/compaction.js'; import { SessionIndex } from '../../session/index.js'; import type { ExportFormat, SessionListQuery } from '../../session/types.js'; import type { SessionPatchBody } from '../../session/patch-metadata.js'; import { type SessionResetResult } from '../session-reset-service.js'; export interface GatewaySessionsApiOptions { sessionIndex: SessionIndex; /** Resolves the live agent service (created lazily; throws if gateway is starting). */ getAgentService: () => AgentService; /** Read-only view of in-flight webchat runs (per session key → run id). */ getActiveWebchatRunId: (sessionKey: string) => string | undefined; } export declare class GatewaySessionsApi { private readonly opts; constructor(opts: GatewaySessionsApiOptions); listSessions(query?: SessionListQuery): Promise>; /** Subagent sessions have keys starting with `subagent:`. */ listSubagents(query?: SessionListQuery): Promise>; getSession(key: string, options?: { includeTranscriptSummary?: boolean; includeTranscriptRows?: boolean; }): Promise; resolveSession(input: { key?: string; sessionKey?: string; sessionId?: string; }): Promise<{ sessionKey: string; sessionId: string; session: Awaited>; } | null>; /** Read-only: in-flight webchat agent run for this session key, if any. */ getActiveRun(sessionKey: string): { active: boolean; runId?: string; }; getMessagePage(key: string, options?: { offset?: number; limit?: number; before?: string; includeTranscriptSummary?: boolean; includeTranscriptRows?: boolean; includeContextRows?: boolean; }): Promise<{ session: import("../../session/types.js").SessionDetail; pagination: { total: number; limit: number; offset: number; hasMore: boolean; before?: string; nextBeforeCursor?: string; }; }>; getTimeline(key: string): Promise; getTranscriptWindow(key: string, options: { rowNumber: number; before?: number; after?: number; }): Promise<{ messages: import("../../session/client-history.js").ClientHistoryMessage[]; startRowNumber: number; endRowNumber: number; totalRows: number; }>; patch(key: string, body: SessionPatchBody): Promise<{ ok: true; } | { ok: false; error: string; }>; getAgentConfig(sessionKey: string): Promise; /** Resolved markdown workspace for a session (after hydration / mkdir). */ getEffectiveWorkspacePath(sessionKey: string): Promise; patchAgentConfig(sessionKey: string, body: { thinkingLevel?: string; model?: string | null; activityDetailLevel?: string | null; reasoningLevel?: string | null; verboseLevel?: string; workingDirectory?: string; responseLanguage?: string | null; }): Promise; listCompactionBoundaries(key: string): Promise; restoreBeforeCompactionBoundary(key: string, compactionId: string): Promise; runCompaction(key: string, options?: { instructions?: string; force?: boolean; }): Promise; delete(key: string): Promise<{ deleted: boolean; }>; /** Reset transcript in place (archive + new session id); preserves session key and overrides. */ reset(key: string): Promise; deleteMany(keys: string[]): Promise<{ success: string[]; failed: string[]; }>; rename(key: string, name: string): Promise<{ renamed: boolean; }>; tag(key: string, tags: string[]): Promise<{ tagged: boolean; }>; untag(key: string, tags: string[]): Promise<{ untagged: boolean; }>; archive(key: string): Promise<{ archived: boolean; }>; unarchive(key: string): Promise<{ unarchived: boolean; }>; pin(key: string): Promise<{ pinned: boolean; }>; unpin(key: string): Promise<{ unpinned: boolean; }>; search(query: string): Promise; searchIn(key: string, keyword: string): Promise; export(key: string, format: ExportFormat): Promise<{ content: string; }>; importExport(targetKey: string, jsonContent: string): Promise<{ sessionKey: string; rowCount: number; }>; fork(key: string, targetKey: string): Promise<{ sessionKey: string; rowCount: number; }>; forkRows(key: string, targetKey: string, options?: { throughRow?: number; }): Promise<{ sessionKey: string; rowCount: number; }>; btwQuery(sessionKey: string, question: string): Promise<{ text: string; error?: string; }>; stats(): Promise; /** * Distinct chat-id pairs from sessions, grouped by channel. Used by automation * configuration UI to seed the "send to existing chat" picker. */ chatIds(channel?: string): Promise>; }