import type { Request, Response, NextFunction } from 'express'; export interface CreateMcpServerInput { name: string; server: McpServerConfig; description?: string; apps?: Partial; } export interface UpdateMcpServerInput { name?: string; server?: McpServerConfig; description?: string; apps?: Partial; } export interface Session { agentId: string; workspacePath: string; outputBuffer: string; flushTimer: NodeJS.Timeout | null; flushInFlight: Promise | null; seq: number; } export interface SkillPackage { downloadUrl?: string; fileName?: string; sha256?: string; skillName?: string; } export interface PluginPackage { downloadUrl?: string; fileName?: string; sha256?: string; pluginName?: string; } export interface McpPayload { id?: string; name: string; transport?: string; command?: string; url?: string; args?: string[]; env?: Record; enabled?: boolean; installedAt?: string; } export interface McpServerConfig { type?: string; command?: string; url?: string; args?: string[]; env?: Record; headers?: Record; } export interface McpServerInput { name: string; server: unknown; description?: string; apps?: SdkApps; } export interface LegacyMcpStateItem { id: string; name: string; transport: string; command: string; url: string; args: string[]; env: Record; enabled: boolean; apps?: SdkApps; installedAt: string; } export interface Skill { sourceDir?: string; directory?: string; filePath?: string; name?: string; description?: string; apps?: SdkApps; id?: string; installedAt?: string | number; } export interface LegacySkillStateItem { id: string; name: string; fileName: string; filePath: string; bytes: number; apps?: SdkApps; installedAt: string; } export interface SdkApps { acode?: boolean; claude?: boolean; claudecode?: boolean; codex?: boolean; gemini?: boolean; opencode?: boolean; openclaw?: boolean; } export interface InstanceState { initialized: boolean; skills: LegacySkillStateItem[]; mcpServers: LegacyMcpStateItem[]; enabledTools: string[]; toolStatus: Record; skillEnabled: boolean; mcpEnabled: boolean; updatedAt: string | null; } export interface ToolInstallStatus { tool: string; installed: boolean; executable: string | null; version: string | null; installing: boolean; error: string | null; currentStep?: string | null; attempts?: ToolInstallAttempt[]; failure?: ToolInstallFailure | null; } export interface ToolInstallAttempt { step: string; label: string; command: string | null; status: 'running' | 'success' | 'error' | 'skipped'; startedAt: string; finishedAt?: string; durationMs?: number; stdout?: string; stderr?: string; error?: string | null; code?: string | number | null; signal?: string | null; } export interface ToolInstallFailure { step: string; command: string | null; message: string; stdout?: string; stderr?: string; code?: string | number | null; signal?: string | null; } export interface InitLogEntry { step: string; status: 'pending' | 'running' | 'success' | 'error' | 'skipped'; message: string; timestamp: string; details?: Record; } export interface AiSourceApplyPayload { agentId?: string; template?: Record | null; acodeTemplateId?: string | null; claudecodeTemplateId?: string | null; codexTemplateId?: string | null; opencodeTemplateId?: string | null; acode?: Record | null; claudecode?: Record | null; codex?: Record | null; opencode?: Record | null; } export interface DownloadResult { fileName: string; outputPath: string; bytes: number; } export type RequestHandler = (req: Request, res: Response, next: NextFunction) => void | Promise; export interface CallbackResponse { ok: boolean; [key: string]: unknown; } export interface PersistedSession { sessionId: string; agentId: string; workspacePath: string; command: string; startedAt: string; status: 'running' | 'stopped'; runtimeStatus?: string; runtimeActionType?: string; runtimeActionLabel?: string; runtimeActionDetail?: string; pid?: number; providerSessionId?: string; mode?: 'sdk'; idleInputAutoCommand?: string; nonInputAutoCommand?: string; } export interface SessionsListResponse { ok: boolean; active: Array<{ sessionId: string; agentId: string; workspacePath: string; status: string; runtimeStatus?: string; runtimeActionType?: string; runtimeActionLabel?: string; runtimeActionDetail?: string; startedAt: string | null; }>; persisted: PersistedSession[]; } export interface RecoverSessionRequest { agentId: string; workspacePath?: string; command?: string; idleInputAutoCommand?: string; nonInputAutoCommand?: string; } export interface RecoverSessionResult { ok: boolean; sessionId: string; agentId: string; workspacePath: string; command: string; status: string; recovered: boolean; mode?: 'sdk'; message?: string; }