| 156 | } |
| 157 | |
| 158 | export class ClineProvider |
| 159 | extends EventEmitter<TaskProviderEvents> |
| 160 | implements vscode.WebviewViewProvider, TelemetryPropertiesProvider, TaskProviderLike |
| 161 | { |
| 162 | // Used in package.json as the view's id. This value cannot be changed due |
| 163 | // to how VSCode caches views based on their id, and updating the id would |
| 164 | // break existing instances of the extension. |
| 165 | public static readonly sideBarId = `${Package?.commandIDPrefix || "costrict"}.SidebarProvider` |
| 166 | public static readonly tabPanelId = `${Package?.commandIDPrefix || "costrict"}.TabPanelProvider` |
| 167 | private static activeInstances: Set<ClineProvider> = new Set() |
| 168 | private disposables: vscode.Disposable[] = [] |
| 169 | private webviewDisposables: vscode.Disposable[] = [] |
| 170 | private view?: vscode.WebviewView | vscode.WebviewPanel |
| 171 | private clineStack: Task[] = [] |
| 172 | private codeIndexStatusSubscription?: vscode.Disposable |
| 173 | private codeIndexManager?: CodeIndexManager |
| 174 | private _workspaceTracker?: WorkspaceTracker // workSpaceTracker read-only for access outside this class |
| 175 | protected mcpHub?: McpHub // Change from private to protected |
| 176 | protected skillsManager?: SkillsManager |
| 177 | private marketplaceManager: MarketplaceManager |
| 178 | private mdmService?: MdmService |
| 179 | private costrictAuthCommands?: CostrictAuthCommands |
| 180 | private autoCleanupService?: AutoCleanupService |
| 181 | private taskCreationCallback: (task: Task) => void |
| 182 | private taskEventListeners: WeakMap<Task, Array<() => void>> = new WeakMap() |
| 183 | private currentWorkspacePath: string | undefined |
| 184 | private _disposed = false |
| 185 | // Tracks which tab is currently active in the Webview. |
| 186 | private _activeTab: string = "chat" |
| 187 | |
| 188 | private recentTasksCache?: string[] |
| 189 | private cachedCustomModes?: Awaited<ReturnType<CustomModesManager["getCustomModes"]>> |
| 190 | private cachedWorkspaceCommandLists?: Partial<Record<"allowedCommands" | "deniedCommands", string[]>> |
| 191 | private cachedMergedCommands?: Partial< |
| 192 | Record< |
| 193 | "allowedCommands" | "deniedCommands", |
| 194 | { globalStateCommands: string[]; workspaceCommands: string[]; mergedCommands: string[] } |
| 195 | > |
| 196 | > |
| 197 | private cachedCustomStoragePath?: string |
| 198 | public readonly taskHistoryStore: TaskHistoryStore |
| 199 | private taskHistoryStoreInitialized = false |
| 200 | private globalStateWriteThroughTimer: ReturnType<typeof setTimeout> | null = null |
| 201 | private static readonly GLOBAL_STATE_WRITE_THROUGH_DEBOUNCE_MS = 5000 // 5 seconds |
| 202 | private pendingOperations: Map<string, PendingEditOperation> = new Map() |
| 203 | private static readonly PENDING_OPERATION_TIMEOUT_MS = 30000 // 30 seconds |
| 204 | |
| 205 | // private cloudOrganizationsCache: CloudOrganizationMembership[] | null = null |
| 206 | // private cloudOrganizationsCacheTimestamp: number | null = null |
| 207 | // private static readonly CLOUD_ORGANIZATIONS_CACHE_DURATION_MS = 5 * 1000 // 5 seconds |
| 208 | |
| 209 | /** |
| 210 | * Monotonically increasing sequence number for clineMessages state pushes. |
| 211 | * Used by the frontend to reject stale state that arrives out-of-order. |
| 212 | */ |
| 213 | private clineMessagesSeq = 0 |
| 214 | |
| 215 | /** |
nothing calls this directly
no test coverage detected