import { SessionSnapshot, ConversationTurn, StructuredSessionState, Workspace, LayoutNode, TaskWindowLayout, WorkspaceDefaultProvider, WorkspaceTask, WorkspaceTaskWorktree, WorkspaceTaskStatus } from "./types.js"; import type { AgentActivityItem, Mission, MissionAttempt, MissionReviewComment, MissionReviewStatus, MissionStatus } from "./mission-types.js"; import { type PasswordVault, type PasswordVaultItem, type PasswordVaultItemFilter, type PasswordVaultItemInput } from "./password-manager.js"; type AuthPrincipalKind = "browser-admin" | "connected-app"; export type AuthScope = "admin" | "sessions" | "files" | "password-vault" | "session-preferences"; export interface AuthPrincipal { kind: AuthPrincipalKind; scopes: AuthScope[]; } export interface PersistedAuthSession { token: string; expiresAt: number; principal: AuthPrincipal; } export declare function resolveDatabasePath(configPath: string): string; export declare function ensureDatabaseFile(dbPath: string): boolean; export declare class WandStorage { private readonly db; constructor(dbPath: string); close(): void; /** * Run a synchronous group of storage operations atomically. Calls must not * be nested because SQLite does not support a second BEGIN on this connection. */ transaction(action: () => T): T; /** Get a config value from database */ getConfigValue(key: string): string | null; /** Set a config value in database */ setConfigValue(key: string, value: string): void; /** Delete a config value */ deleteConfigValue(key: string): void; /** 读取偏好。未设置或 JSON 解析失败时返回 fallback。 */ getPreference(key: string, fallback: T): T; /** 写入偏好。undefined / null 视为删除。 */ setPreference(key: string, value: T | null | undefined): void; /** 判断偏好是否在 DB 中存在(区别于值为 null/false/"")。 */ hasPreference(key: string): boolean; /** Return user-defined workspace labels keyed by normalized session cwd. */ listSessionDirectoryNames(): Map; /** Set a workspace label, or remove it when name is null/blank. */ setSessionDirectoryName(directoryPath: string, name: string | null): void; listWorkspaces(): Workspace[]; getWorkspace(id: string): Workspace | null; createWorkspace(input: { name: string; cwd: string; defaultProvider?: WorkspaceDefaultProvider; }): Workspace; updateWorkspace(id: string, patch: { name?: string; cwd?: string; defaultProvider?: WorkspaceDefaultProvider | null; }): void; saveWorkspaceLayout(id: string, layout: LayoutNode | null): void; touchWorkspace(id: string): void; deleteWorkspace(id: string, options?: { cascade?: boolean; }): void; listSessionsByWorkspace(workspaceId: string): SessionSnapshot[]; /** 显式更新某会话的工作空间归属(用于创建时绑定)。 */ setSessionWorkspaceId(sessionId: string, workspaceId: string | null): void; /** Lightweight count of persisted sessions grouped by workspace. */ countSessionsByWorkspace(): Map; /** Sessions not yet attached to a project. Omits messages/output. */ listUnboundSessionBindings(): Array<{ id: string; cwd: string; worktree: SessionSnapshot["worktree"]; }>; listWorkspaceTasks(workspaceId: string): WorkspaceTask[]; getWorkspaceTask(id: string): WorkspaceTask | null; createWorkspaceTask(input: { workspaceId: string; name: string; worktree?: WorkspaceTaskWorktree | null; status?: WorkspaceTaskStatus; }): WorkspaceTask; updateWorkspaceTask(id: string, patch: { name?: string; status?: WorkspaceTaskStatus; worktree?: WorkspaceTaskWorktree | null; }): void; saveWorkspaceTaskLayout(id: string, layout: TaskWindowLayout | null): void; touchWorkspaceTask(id: string): void; deleteWorkspaceTask(id: string, options?: { cascade?: boolean; }): void; listSessionsByWorkspaceTask(taskId: string): SessionSnapshot[]; setSessionWorkspaceTaskId(sessionId: string, taskId: string | null): void; /** Get password from database */ getPassword(): string | null; /** Set password in database */ setPassword(password: string): void; /** Check if password has been set (not default) */ hasCustomPassword(): boolean; /** Get appSecret from database (used to mint Android appTokens) */ getAppSecret(): string | null; /** Persist appSecret in database (DB is the authoritative source after first migration) */ setAppSecret(value: string): void; private encryptStoredPassword; private decryptPasswordItem; ensureDefaultPasswordVault(): void; listPasswordVaults(): PasswordVault[]; createPasswordVault(nameInput: unknown): PasswordVault; getPasswordVault(id: string): PasswordVault | null; listPasswordItems(filter?: PasswordVaultItemFilter): PasswordVaultItem[]; getPasswordItem(id: string): PasswordVaultItem | null; createPasswordItem(input: PasswordVaultItemInput): PasswordVaultItem; updatePasswordItem(id: string, input: PasswordVaultItemInput): PasswordVaultItem | null; touchPasswordItem(id: string): PasswordVaultItem | null; deletePasswordItem(id: string): boolean; saveAuthSession(token: string, expiresAt: number, principal?: AuthPrincipal): void; getAuthSession(token: string): PersistedAuthSession | null; deleteAuthSession(token: string): void; deleteAllAuthSessions(): void; deleteExpiredAuthSessions(now: number): void; saveMission(mission: Mission): void; getMission(id: string): Mission | null; listMissions(includeArchived?: boolean): Mission[]; updateMissionStatus(id: string, status: MissionStatus, updatedAt?: string): void; saveMissionAttempt(attempt: MissionAttempt): void; getMissionAttempt(id: string): MissionAttempt | null; getMissionAttemptBySession(sessionId: string): MissionAttempt | null; listMissionAttempts(missionId: string): MissionAttempt[]; saveMissionReviewComment(comment: MissionReviewComment): void; listMissionReviewComments(missionId: string, attemptId?: string): MissionReviewComment[]; updateMissionReviewStatus(ids: string[], status: MissionReviewStatus, at?: string): void; upsertAgentActivity(item: AgentActivityItem): void; listAgentActivity(): AgentActivityItem[]; markAgentActivityRead(sessionId?: string): void; saveSession(snapshot: SessionSnapshot): void; /** Update runtime/scalar fields without serializing or rewriting messages/output. */ updateSessionRuntimeMetadata(snapshot: SessionSnapshot): void; /** Compatibility alias for older callers; intentionally excludes output/messages. */ saveSessionMetadata(snapshot: SessionSnapshot): void; /** Checkpoint only the PTY/structured text output window. */ checkpointSessionOutput(id: string, output: string, ptyOutputSeq?: number): void; /** * Checkpoint the conversation payload once, optionally folding the matching * structured state/output into the same statement. */ checkpointSessionMessages(id: string, messages: ConversationTurn[], structuredState?: StructuredSessionState | null, output?: string, ptyOutputSeq?: number): void; getSession(id: string): SessionSnapshot | null; getLatestSessionByClaudeSessionId(claudeSessionId: string): SessionSnapshot | null; loadSessions(): SessionSnapshot[]; private mapSessionRow; deleteSession(id: string): void; } export {};