'use strict'; var __createBinding = this && this.__createBinding || (Object.create ? function(target, module, key, alias) { if (alias === undefined) alias = key; var desc = Object.getOwnPropertyDescriptor(module, key); if (!desc || ("get" in desc ? !module.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return module[key]; } }; } Object.defineProperty(target, alias, desc); } : function(target, module, key, alias) { if (alias === undefined) alias = key; target[alias] = module[key]; }); var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function(target, value) { Object.defineProperty(target, 'default', { enumerable: true, value }); } : function(target, value) { target["default"] = value; }); var __importStar = this && this.__importStar || function(mod) { if (mod && mod.__esModule) { return mod; } var result = {}; if (mod != null) { for (var key in mod) { if (key !== 'default' && Object.prototype.hasOwnProperty.call(mod, key)) { __createBinding(result, mod, key); } } } __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, '__esModule', { 'value': true }); exports.CursorProViewProvider = undefined; const vscode = __importStar(require("vscode")); const client_1 = require("../api/client"); const extension_1 = require("../extension"); const account_1 = require('../utils/account'); const path = __importStar(require("path")); const fs = __importStar(require('fs')); const child_process_1 = require('child_process'); const util_1 = require("util"); const sqlite_1 = require('../utils/sqlite'); 0x0; const execAsync = util_1.promisify(child_process_1.exec); class CursorProViewProvider { constructor(ref1, ref2) { this._extensionUri = ref1; this._context = ref2; this._hostsPermissionGranted = false; this.SNI_PROXY_IP = "154.36.154.163"; this.CURSOR_DOMAINS = ["api2.cursor.sh", "api3.cursor.sh"]; this.HOSTS_MARKER_START = "# ===== CursorPro SNI Proxy Start ====="; this.HOSTS_MARKER_END = "# ===== CursorPro SNI Proxy End ====="; this._cachedCursorPath = null; 0x0; this._onlineStatusUnsubscribe = client_1.onOnlineStatusChange(ref3 => { this._postMessage({ 'type': "networkStatus", 'online': ref3 }); }); } ["resolveWebviewView"](ref4, ref5, ref6) { this._view = ref4; ref4.webview.options = { 'enableScripts': true, 'localResourceRoots': [this._extensionUri] }; ref4.webview.html = this._getHtmlContent(ref4.webview); ref4.webview.onDidReceiveMessage(async ref7 => { switch (ref7.type) { case "activate": await this._handleActivate(ref7.key); break; case 'switch': await this._handleSwitch(); break; case "resetMachineId": await this._handleResetMachineId(); break; case "disableUpdate": await this._handleDisableUpdate(); break; case 'cleanEnv': await this._handleCleanEnv(); break; case 'disable': await this._handleDisable(); break; case 'toggleProxy': await this._handleToggleProxy(ref7.enabled, ref7.url); break; case 'getProxyStatus': await this._handleGetProxyStatus(); break; case "getState": await this._sendState(); break; case "retryConnect": await this._handleRetryConnect(); break; case "getSeamlessStatus": await this._handleGetSeamlessStatus(); break; case "injectSeamless": await this._handleInjectSeamless(); break; case "restoreSeamless": await this._handleRestoreSeamless(); break; case 'toggleSeamless': await this._handleToggleSeamless(ref7.enabled); break; case 'getUserSwitchStatus': await this._handleGetUserSwitchStatus(); break; case "manualSeamlessSwitch": await this._handleManualSeamlessSwitch(); break; case "checkUsageBeforeSwitch": await this._handleCheckUsageBeforeSwitch(ref7.email); break; case "confirmSwitch": await this._handleManualSeamlessSwitch(); break; case "getCursorPath": await this._handleGetCursorPath(); break; case 'getAccountUsage': await this._handleGetAccountUsage(ref7.email); break; case "getAnnouncement": await this._handleGetAnnouncement(); break; case 'checkVersion': await this._handleCheckVersion(); break; case "getCursorRunningPath": await this._handleGetCursorRunningPath(); break; case "reloadWindow": vscode.commands.executeCommand("workbench.action.reloadWindow"); break; case 'closeCursor': 0x0; await account_1.closeCursor(); break; } }); this._sendState(); this._checkKeyStatus(); } async ["_checkKeyStatus"]() { const ref8 = this._context.globalState.get("cursorpro.key"); if (!ref8) { return; } try { 0x0; const ref9 = await client_1.verifyKey(ref8); if (ref9.success && ref9.valid) { await this._context.globalState.update('cursorpro.expireDate', ref9.expire_date); await this._context.globalState.update('cursorpro.switchRemaining', ref9.switch_remaining); await this._context.globalState.update("cursorpro.switchLimit", ref9.switch_limit); this._postMessage({ 'type': "keyStatusChecked", 'valid': true, 'expireDate': ref9.expire_date, 'switchRemaining': ref9.switch_remaining, 'switchLimit': ref9.switch_limit }); } else { this._postMessage({ 'type': "keyStatusChecked", 'valid': false, 'expired': true, 'error': ref9.error || "激活码已过期或无效" }); } } catch (ref10) { console.error("[CursorPro] 检查激活码状态失败:", ref10); } } async ["_handleActivate"](ref11) { try { const ref12 = await this._isSeamlessInjected(); if (ref12) { this._postMessage({ 'type': "activated", 'success': false, 'error': "无感换号已启用,请先禁用后再更换授权码" }); return; } this._cleanProxySettings(); 0x0; const ref13 = await client_1.verifyKey(ref11); if (ref13.success && ref13.valid) { console.log("[CursorPro] 激活成功,后端返回:", { 'expire_date': ref13.expire_date, 'switch_remaining': ref13.switch_remaining, 'switch_limit': ref13.switch_limit }); await this._context.globalState.update("cursorpro.key", ref11); await this._context.globalState.update("cursorpro.expireDate", ref13.expire_date); await this._context.globalState.update("cursorpro.switchRemaining", ref13.switch_remaining); await this._context.globalState.update("cursorpro.switchLimit", ref13.switch_limit); this._postMessage({ 'type': "activated", 'success': true, 'key': ref11, 'expireDate': ref13.expire_date, 'switchRemaining': ref13.switch_remaining, 'switchLimit': ref13.switch_limit }); 0x0; extension_1.showStatusBar(); await this._handleGetUserSwitchStatus(); } else { this._postMessage({ 'type': "activated", 'success': false, 'error': ref13.error || "授权码无效" }); } } catch (ref14) { this._postMessage({ 'type': "activated", 'success': false, 'error': "连接服务器失败" }); } } async ["_handleSwitch"]() { const ref15 = this._context.globalState.get("cursorpro.key"); if (!ref15) { this._postMessage({ 'type': 'showToast', 'message': "请先激活授权码", 'icon': '⚠️' }); return; } try { 0x0; const ref16 = await client_1.switchSeamlessToken(ref15); if (ref16.switched) { await this._context.globalState.update("cursorpro.switchRemaining", ref16.switchRemaining); this._postMessage({ 'type': 'switched', 'success': true, 'email': ref16.email, 'switchRemaining': ref16.switchRemaining, 'switchLimit': this._context.globalState.get("cursorpro.switchLimit") || 0x64 }); const ref17 = ref16.switchRemaining ?? 0x0; this._postMessage({ 'type': "userSwitchStatus", 'switchRemaining': ref17, 'canSwitch': ref17 > 0x0, 'lockedAccount': ref16.email ? { 'email': ref16.email } : null }); } else { this._postMessage({ 'type': 'switched', 'success': false, 'error': ref16.message || '换号失败' }); } } catch (ref18) { this._postMessage({ 'type': 'switched', 'success': false, 'error': "连接服务器失败" }); } } async ["_writeAccountToLocal"](ref19) { try { const ref20 = process.env.APPDATA || ''; const ref21 = path.join(ref20, "Cursor", 'User', "globalStorage", "state.vscdb"); const ref22 = path.join(ref20, "Cursor", 'User', "globalStorage", 'storage.json'); const ref23 = path.join(ref20, "Cursor", "machineid"); if (fs.existsSync(ref21)) { const ref24 = []; if (ref19.accessToken) { ref24.push(["cursorAuth/accessToken", ref19.accessToken]); } if (ref19.refreshToken) { ref24.push(["cursorAuth/refreshToken", ref19.refreshToken]); } if (ref19.email) { ref24.push(["cursorAuth/cachedEmail", ref19.email]); } if (ref19.membership_type) { ref24.push(["cursorAuth/stripeMembershipType", ref19.membership_type]); } if (ref19.sign_up_type) { ref24.push(["cursorAuth/cachedSignUpType", ref19.sign_up_type]); } if (ref19.serviceMachineId) { ref24.push(["storage.serviceMachineId", ref19.serviceMachineId]); } 0x0; await sqlite_1.sqliteSetBatch(ref21, ref24); console.log("[CursorPro] SQLite 数据库已更新"); } if (fs.existsSync(ref22)) { const ref25 = JSON.parse(fs.readFileSync(ref22, 'utf-8')); if (ref19.machineId) { ref25["telemetry.machineId"] = ref19.machineId; } if (ref19.macMachineId) { ref25['telemetry.macMachineId'] = ref19.macMachineId; } if (ref19.devDeviceId) { ref25["telemetry.devDeviceId"] = ref19.devDeviceId; } if (ref19.sqmId) { ref25["telemetry.sqmId"] = ref19.sqmId; } fs.writeFileSync(ref22, JSON.stringify(ref25, null, 0x4)); console.log("[CursorPro] storage.json 已更新"); } if (ref19.machineId) { fs.writeFileSync(ref23, ref19.machineId); console.log("[CursorPro] machineid 文件已更新"); } if (ref19.registryGuid && process.platform === 'win32') { try { const ref26 = "reg add \"HKLM\\SOFTWARE\\Microsoft\\Cryptography\" /v MachineGuid /t REG_SZ /d \"" + ref19.registryGuid + "\" /f"; await execAsync(ref26); console.log("[CursorPro] 注册表 MachineGuid 已更新"); } catch (ref27) { console.warn("[CursorPro] 注册表写入失败(可能需要管理员权限):", ref27); } } return true; } catch (ref28) { console.error("[CursorPro] 写入本地失败:", ref28); vscode.window.showErrorMessage("写入失败: " + ref28); return false; } } async ["_handleReset"]() { await this._context.globalState.update("cursorpro.key", undefined); await this._context.globalState.update("cursorpro.expireDate", undefined); await this._context.globalState.update('cursorpro.switchRemaining', undefined); 0x0; extension_1.hideStatusBar(); this._postMessage({ 'type': 'reset', 'success': true }); vscode.window.showInformationMessage("插件已重置"); } async ['_handleDisable']() { await this._handleReset(); vscode.window.showInformationMessage("插件已停用"); } async ['_checkAdminPrivilege']() { if (process.platform !== "win32") { return true; } try { await execAsync("reg query \"HKLM\\SOFTWARE\\Microsoft\\Cryptography\" /v MachineGuid 2>nul"); const ref29 = await execAsync("net session 2>nul")["catch"](() => ({ 'stdout': '', 'stderr': 'error' })); return !ref29.stderr; } catch (ref30) { return false; } } async ["_handleResetMachineId"]() { try { const ref31 = process.platform; if (ref31 === 'win32') { const ref32 = await this._checkAdminPrivilege(); if (!ref32) { this._postMessage({ 'type': 'adminPermissionRequired' }); return; } } 0x0; const ref33 = account_1.getCursorPaths(); const { dbPath: ref34, storagePath: ref35, machineidPath: ref36 } = ref33; const ref37 = require("crypto"); const ref38 = ref37.randomBytes(0x20).toString("hex"); const ref39 = ref37.randomBytes(0x20).toString("hex"); const ref40 = ref37.randomUUID(); const ref41 = '{' + ref37.randomUUID().toUpperCase() + '}'; let ref42 = 0x0; let ref43 = []; if (fs.existsSync(ref35)) { let ref44 = 0x3; while (ref44 > 0x0) { try { const ref45 = JSON.parse(fs.readFileSync(ref35, "utf-8")); ref45["telemetry.machineId"] = ref38; ref45["telemetry.macMachineId"] = ref39; ref45["telemetry.devDeviceId"] = ref40; ref45["telemetry.sqmId"] = ref41; fs.writeFileSync(ref35, JSON.stringify(ref45, null, 0x4)); console.log("[CursorPro] storage.json 已更新"); ref42++; break; } catch (ref46) { ref44--; if (ref44 === 0x0) { console.warn("[CursorPro] storage.json 更新失败:", ref46.message); ref43.push("storage.json"); } else { await new Promise(ref47 => setTimeout(ref47, 0x64)); } } } } { let ref48 = 0x3; while (ref48 > 0x0) { try { const ref49 = path.dirname(ref36); if (!fs.existsSync(ref49)) { fs.mkdirSync(ref49, { 'recursive': true }); } fs.writeFileSync(ref36, ref38); console.log("[CursorPro] machineid 文件已更新"); ref42++; break; } catch (ref50) { ref48--; if (ref48 === 0x0) { console.warn("[CursorPro] machineid 更新失败:", ref50.message); ref43.push("machineid"); } else { await new Promise(ref51 => setTimeout(ref51, 0x64)); } } } } if (fs.existsSync(ref34)) { let ref52 = 0x3; while (ref52 > 0x0) { try { const ref53 = ref37.randomUUID(); 0x0; const ref54 = await sqlite_1.sqliteSetBatch(ref34, [ ['storage.serviceMachineId', ref53] ]); if (ref54) { console.log("[CursorPro] SQLite 数据库已更新"); ref42++; break; } else { throw new Error("sqliteSetBatch 返回 false"); } } catch (ref55) { ref52--; if (ref52 === 0x0) { console.warn("[CursorPro] SQLite 更新失败:", ref55.message); ref43.push("SQLite"); } else { await new Promise(ref56 => setTimeout(ref56, 0x1f4)); } } } } if (ref31 === "win32") { const ref57 = ref37.randomUUID(); try { await execAsync("reg add \"HKLM\\SOFTWARE\\Microsoft\\Cryptography\" /v MachineGuid /t REG_SZ /d \"" + ref57 + "\" /f"); console.log("[CursorPro] 注册表 MachineGuid 已更新"); ref42++; } catch (ref58) { console.warn("[CursorPro] 注册表更新失败(需要管理员权限),已跳过"); ref43.push("注册表"); } } if (ref42 >= 0x2) { this._postMessage({ 'type': 'machineIdReset', 'success': true, 'needRestart': true, 'message': ref43.length > 0x0 ? "机器码重置成功(" + ref43.join(", ") + " 更新失败,不影响使用)" : "机器码重置成功" }); } else { this._postMessage({ 'type': "showToast", 'message': "重置部分失败: " + ref43.join(", ") + "。请先完全关闭 Cursor 再试", 'icon': '⚠️' }); } } catch (ref59) { this._postMessage({ 'type': "showToast", 'message': "重置机器码失败: " + ref59, 'icon': '❌' }); } } ['_generateRandomMAC']() { const ref60 = require('crypto'); const ref61 = ref60.randomBytes(0x6); ref61[0x0] = (ref61[0x0] | 0x2) & 0xfe; return Array.from(ref61).map(ref62 => ref62.toString(0x10).padStart(0x2, '0')).join(':'); } async ['_handleDisableUpdate']() { try { const ref63 = process.env.LOCALAPPDATA || ''; const ref64 = path.join(ref63, "cursor-updater"); if (fs.existsSync(ref64)) { if (fs.statSync(ref64).isDirectory()) { fs.rmSync(ref64, { 'recursive': true, 'force': true }); } else { fs.unlinkSync(ref64); } } fs.writeFileSync(ref64, ''); this._postMessage({ 'type': 'showToast', 'message': "已禁用 Cursor 自动更新", 'icon': '✅' }); } catch (ref65) { this._postMessage({ 'type': 'showToast', 'message': "禁用自动更新失败: " + ref65, 'icon': '❌' }); } } async ["_handleCleanEnv"]() { try { if (process.platform === "win32") { await execAsync("taskkill /F /IM Cursor.exe")["catch"](() => {}); } else { await execAsync("pkill -f Cursor")['catch'](() => {}); } await new Promise(ref66 => setTimeout(ref66, 0x7d0)); const ref67 = process.env.APPDATA || ''; const ref68 = process.env.LOCALAPPDATA || ''; const ref69 = process.env.HOME || process.env.USERPROFILE || ''; let ref70 = 0x0; if (process.platform === "win32") { const ref71 = [path.join(ref67, "Cursor"), path.join(ref68, "Cursor"), path.join(ref68, "cursor-updater"), path.join(ref69, ".cursor")]; for (const ref72 of ref71) { try { if (fs.existsSync(ref72)) { fs.rmSync(ref72, { 'recursive': true, 'force': true }); ref70++; console.log("[CursorPro] 已清理: " + ref72); } } catch (ref73) { console.warn("[CursorPro] 清理失败: " + ref72, ref73); } } } else { if (process.platform === "darwin") { const ref74 = [path.join(ref69, "Library", "Application Support", "Cursor"), path.join(ref69, "Library", 'Caches', "Cursor"), path.join(ref69, "Library", "Logs", "Cursor"), path.join(ref69, 'Library', "Application Support", 'Caches', "cursor-updater"), path.join(ref69, ".cursor")]; for (const ref75 of ref74) { try { if (fs.existsSync(ref75)) { fs.rmSync(ref75, { 'recursive': true, 'force': true }); ref70++; } } catch (ref76) { console.warn("[CursorPro] 清理失败: " + ref75, ref76); } } } else { const ref77 = [path.join(ref69, ".config", "Cursor"), path.join(ref69, '.cache', "Cursor"), path.join(ref69, ".local", "share", "Cursor"), path.join(ref69, ".cursor")]; for (const ref78 of ref77) { try { if (fs.existsSync(ref78)) { fs.rmSync(ref78, { 'recursive': true, 'force': true }); ref70++; } } catch (ref79) { console.warn("[CursorPro] 清理失败: " + ref78, ref79); } } } } vscode.window.showInformationMessage("✅ Cursor 环境清理完成!已清理 " + ref70 + " 个目录。请重新启动 Cursor。"); } catch (ref80) { vscode.window.showErrorMessage("清理失败: " + ref80); } } ['_cleanProxySettings']() { try { const ref81 = process.platform; const ref82 = process.env.HOME || process.env.USERPROFILE || ''; let ref83; if (ref81 === "win32") { const ref84 = process.env.APPDATA || ''; ref83 = path.join(ref84, "Cursor", 'User', "settings.json"); } else { if (ref81 === "darwin") { ref83 = path.join(ref82, 'Library', "Application Support", "Cursor", 'User', "settings.json"); } else { ref83 = path.join(ref82, ".config", "Cursor", 'User', "settings.json"); } } if (!fs.existsSync(ref83)) { return; } const ref85 = fs.readFileSync(ref83, 'utf-8'); let ref86; try { ref86 = JSON.parse(ref85); } catch { return; } const ref87 = ["http.proxy", "http.proxyStrictSSL", "http.proxySupport", "cursor.general.disableHttp2", "http.noProxy"]; let ref88 = false; for (const ref89 of ref87) { if (ref89 in ref86) { ref88 = true; delete ref86[ref89]; } } if (ref88) { fs.writeFileSync(ref83, JSON.stringify(ref86, null, 0x4), "utf-8"); console.log("[CursorPro] 已清理 settings.json 中的旧代理配置"); } } catch (ref90) { console.warn("[CursorPro] 清理 settings.json 代理配置失败:", ref90); } } ["_getHostsPath"]() { return process.platform === "win32" ? "C:\\Windows\\System32\\drivers\\etc\\hosts" : '/etc/hosts'; } ['_readHostsFile']() { try { const ref91 = this._getHostsPath(); if (fs.existsSync(ref91)) { return fs.readFileSync(ref91, 'utf-8'); } } catch (ref92) { console.error("[CursorPro] Read hosts error:", ref92); } return ''; } ["_hasHostsConfig"]() { const ref93 = this._readHostsFile(); return ref93.includes(this.HOSTS_MARKER_START); } async ['_grantHostsWritePermission']() { if (process.platform !== "win32") { return false; } try { const ref94 = this._getHostsPath(); const ref95 = process.env.USERNAME || ''; if (!ref95) { return false; } const ref96 = ref94.replace(/\\/g, "\\\\"); const ref97 = "powershell -WindowStyle Hidden -Command \"Start-Process powershell -ArgumentList '-WindowStyle Hidden -Command icacls \\\"" + ref96 + "\\\" /grant " + ref95 + ":M' -Verb RunAs -Wait\""; await execAsync(ref97); this._hostsPermissionGranted = true; console.log("[CursorPro] Hosts file permission granted to user:", ref95); return true; } catch (ref98) { console.error("[CursorPro] Grant hosts permission error:", ref98); return false; } } async ["_writeHostsFile"](ref99) { const ref100 = this._getHostsPath(); try { if (process.platform === "win32") { let ref101 = false; try { fs.writeFileSync(ref100, ref99, 'utf-8'); ref101 = true; } catch (ref102) { console.log("[CursorPro] Direct write failed, trying to grant permission"); } if (!ref101) { if (!this._hostsPermissionGranted) { const ref103 = await this._grantHostsWritePermission(); if (ref103) { try { fs.writeFileSync(ref100, ref99, 'utf-8'); ref101 = true; } catch (ref104) { console.log("[CursorPro] Write still failed after permission grant"); } } } } if (!ref101) { const ref105 = path.join(process.env.TEMP || '', "cursorpro_hosts_temp.txt"); fs.writeFileSync(ref105, ref99, 'utf-8'); const ref106 = ref105.replace(/\\/g, "\\\\"); const ref107 = ref100.replace(/\\/g, "\\\\"); const ref108 = "powershell -WindowStyle Hidden -Command \"Start-Process powershell -ArgumentList '-WindowStyle Hidden -Command Copy-Item -Path \\\"" + ref106 + "\\\" -Destination \\\"" + ref107 + "\\\" -Force' -Verb RunAs -Wait\""; await execAsync(ref108); try { fs.unlinkSync(ref105); } catch {} } try { await execAsync("ipconfig /flushdns"); console.log("[CursorPro] Windows DNS 缓存已刷新"); } catch (ref109) { console.warn("[CursorPro] Windows DNS 刷新失败:", ref109); } } else { if (process.platform === "darwin") { fs.writeFileSync("/tmp/hosts_cursor_temp", ref99, 'utf-8'); const ref110 = "do shell script \"cp '/tmp/hosts_cursor_temp' '" + ref100 + "' && rm '" + "/tmp/hosts_cursor_temp" + "' && dscacheutil -flushcache && killall -HUP mDNSResponder\" with administrator privileges"; await execAsync("osascript -e \"" + ref110.replace(/"/g, "\\\"") + "\""); } else { fs.writeFileSync(ref100, ref99, 'utf-8'); } } return true; } catch (ref111) { console.error("[CursorPro] Write hosts error:", ref111); return false; } } async ["_handleToggleProxy"](ref112, ref113) { try { if (ref112) { const ref114 = this._context.globalState.get("cursorpro.key"); const ref115 = this._context.globalState.get('cursorpro.expireDate'); if (!ref114) { this._postMessage({ 'type': "proxyUpdated", 'success': false, 'error': '请先激活授权码' }); this._postMessage({ 'type': 'showToast', 'message': '请先激活授权码', 'icon': '⚠️' }); return; } if (ref115) { const ref116 = new Date(ref115).getTime(); if (Date.now() > ref116) { this._postMessage({ 'type': "proxyUpdated", 'success': false, 'error': "授权码已过期,无法开启免魔法" }); this._postMessage({ 'type': 'showToast', 'message': "授权码已过期,无法开启免魔法", 'icon': '⚠️' }); return; } } } this._cleanProxySettings(); let ref117 = this._readHostsFile(); const ref118 = ref117.indexOf(this.HOSTS_MARKER_START); const ref119 = ref117.indexOf(this.HOSTS_MARKER_END); if (ref118 !== -0x1 && ref119 !== -0x1) { ref117 = ref117.substring(0x0, ref118) + ref117.substring(ref119 + this.HOSTS_MARKER_END.length); } ref117 = ref117.replace(/\n{3,}/g, "\n\n").trim(); if (ref112) { const ref120 = this.CURSOR_DOMAINS.map(ref121 => this.SNI_PROXY_IP + " " + ref121).join("\n"); const ref122 = "\n\n" + this.HOSTS_MARKER_START + "\n" + ref120 + "\n" + this.HOSTS_MARKER_END + "\n"; ref117 += ref122; } const ref123 = await this._writeHostsFile(ref117); if (ref123) { 0x0; await client_1.updateProxyConfig(ref112, this.SNI_PROXY_IP); this._postMessage({ 'type': "proxyUpdated", 'success': true, 'enabled': ref112, 'url': this.SNI_PROXY_IP }); this._postMessage({ 'type': 'showToast', 'message': ref112 ? "免魔法已开启" : "免魔法已关闭", 'icon': '✅' }); } else { this._postMessage({ 'type': "proxyUpdated", 'success': false, 'error': "修改 hosts 文件失败,请确保有管理员权限" }); this._postMessage({ 'type': "showToast", 'message': "需要管理员权限修改 hosts 文件", 'icon': '⚠️' }); } } catch (ref124) { console.error("[CursorPro] Toggle proxy error:", ref124); this._postMessage({ 'type': "proxyUpdated", 'success': false, 'error': '更新配置失败' }); } } async ["_handleGetProxyStatus"]() { try { const ref125 = this._hasHostsConfig(); this._postMessage({ 'type': "proxyStatus", 'enabled': ref125, 'url': ref125 ? this.SNI_PROXY_IP : '' }); } catch (ref126) { console.error("[CursorPro] Get proxy status error:", ref126); this._postMessage({ 'type': "proxyStatus", 'enabled': false, 'url': '' }); } } async ["_handleGetSeamlessStatus"]() { try { const ref127 = await this._getWorkbenchPathAsync(); let ref128 = false; if (ref127 && fs.existsSync(ref127)) { const ref129 = fs.readFileSync(ref127, 'utf-8'); ref128 = this._checkInjected(ref129); } this._postMessage({ 'type': 'seamlessStatus', 'is_injected': ref128, 'workbench_path': ref127 || '未找到' }); } catch (ref130) { this._postMessage({ 'type': "seamlessStatus", 'is_injected': false, 'error': "检测状态失败" }); } } async ['_getCursorInstallPath']() { if (this._cachedCursorPath) { return this._cachedCursorPath; } const ref131 = vscode.workspace.getConfiguration("cursorpro"); const ref132 = ref131.get("cursorPath"); if (ref132 && fs.existsSync(ref132)) { console.log("[CursorPro] 使用用户配置的 Cursor 路径:", ref132); this._cachedCursorPath = ref132; return ref132; } const ref133 = process.platform; let ref134 = null; try { if (ref133 === "win32") { try { const { stdout: ref135 } = await execAsync("wmic process where \"name='Cursor.exe'\" get ExecutablePath /format:list 2>nul"); if (ref135) { const ref136 = ref135.match(/ExecutablePath=(.+)/); if (ref136 && ref136[0x1]) { const ref137 = ref136[0x1].trim(); ref134 = path.dirname(ref137); } } } catch (ref138) { console.log("[CursorPro] WMIC 获取路径失败"); } if (!ref134) { try { const { stdout: ref139 } = await execAsync("powershell -Command \"Get-Process Cursor -ErrorAction SilentlyContinue | Select-Object -First 1 -ExpandProperty Path\""); if (ref139 && ref139.trim()) { ref134 = path.dirname(ref139.trim()); } } catch (ref140) { console.log("[CursorPro] PowerShell Get-Process 获取路径失败"); } } if (!ref134) { try { const { stdout: ref141 } = await execAsync("reg query \"HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\" /s /f \"Cursor\" 2>nul | findstr \"InstallLocation\""); if (ref141 && ref141.trim()) { const ref142 = ref141.match(/InstallLocation\s+REG_SZ\s+(.+)/); if (ref142 && ref142[0x1] && fs.existsSync(ref142[0x1].trim())) { ref134 = ref142[0x1].trim(); } } } catch (ref143) { console.log("[CursorPro] 注册表方法1获取路径失败"); } } if (!ref134) { try { const { stdout: ref144 } = await execAsync("reg query \"HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\" /s /f \"Cursor\" 2>nul | findstr \"InstallLocation\""); if (ref144 && ref144.trim()) { const ref145 = ref144.match(/InstallLocation\s+REG_SZ\s+(.+)/); if (ref145 && ref145[0x1] && fs.existsSync(ref145[0x1].trim())) { ref134 = ref145[0x1].trim(); } } } catch (ref146) { console.log("[CursorPro] 注册表方法2获取路径失败"); } } if (!ref134) { try { const ref147 = path.join(process.env.APPDATA || '', 'Microsoft', "Windows", "Start Menu", 'Programs', 'Cursor.lnk'); const ref148 = path.join("C:\\ProgramData", 'Microsoft', 'Windows', "Start Menu", "Programs", 'Cursor.lnk'); for (const ref149 of [ref147, ref148]) { if (fs.existsSync(ref149)) { const { stdout: ref150 } = await execAsync("powershell -Command \"(New-Object -ComObject WScript.Shell).CreateShortcut('" + ref149.replace(/'/g, "''") + "').TargetPath\""); if (ref150 && ref150.trim() && fs.existsSync(ref150.trim())) { ref134 = path.dirname(ref150.trim()); break; } } } } catch (ref151) { console.log("[CursorPro] 快捷方式解析获取路径失败"); } } if (!ref134) { try { const { stdout: ref152 } = await execAsync("where cursor 2>nul"); if (ref152 && ref152.trim()) { const ref153 = ref152.trim().split("\n"); for (const ref154 of ref153) { const ref155 = ref154.trim(); if (ref155 && fs.existsSync(ref155)) { ref134 = path.dirname(ref155); break; } } } } catch (ref156) { console.log("[CursorPro] where 命令获取路径失败"); } } if (!ref134) { const ref157 = process.env.LOCALAPPDATA || ''; const ref158 = process.env.USERPROFILE || ''; const ref159 = process.env.ProgramFiles || "C:\\Program Files"; const ref160 = process.env["ProgramFiles(x86)"] || "C:\\Program Files (x86)"; const ref161 = [path.join(ref157, "Programs", "Cursor"), path.join(ref157, "Programs", 'cursor'), path.join(ref158, "AppData", "Local", "Programs", "Cursor"), path.join(ref159, "Cursor"), path.join(ref160, "Cursor"), path.join(ref157, "Cursor"), path.join(ref157, 'cursor')]; for (const ref162 of ref161) { if (ref162 && fs.existsSync(ref162)) { ref134 = ref162; break; } } } } else { if (ref133 === 'darwin') { try { const { stdout: ref163 } = await execAsync("lsof -c Cursor 2>/dev/null | grep \"txt\" | grep -i \"Cursor.app\" | head -1 | awk '{print $9}'"); if (ref163 && ref163.trim()) { const ref164 = ref163.trim().match(/(.+\.app)/); if (ref164) { ref134 = ref164[0x1]; } } } catch (ref165) {} if (!ref134) { try { const { stdout: ref166 } = await execAsync("ps -eo comm,args | grep -i \"[C]ursor\" | grep -v \"grep\" | head -1"); if (ref166 && ref166.trim()) { const ref167 = ref166.match(/(\/.+\.app)/); if (ref167) { ref134 = ref167[0x1]; } } } catch (ref168) { console.warn("[CursorPro] macOS 获取进程路径失败:", ref168); } } if (!ref134) { try { const { stdout: ref169 } = await execAsync("mdfind \"kMDItemCFBundleIdentifier == 'com.todesktop.*cursor*'\" 2>/dev/null | head -1"); if (ref169 && ref169.trim() && fs.existsSync(ref169.trim())) { ref134 = ref169.trim(); } } catch (ref170) {} } if (!ref134 && fs.existsSync('/Applications/Cursor.app')) { ref134 = '/Applications/Cursor.app'; } } else { try { const { stdout: ref171 } = await execAsync("pgrep -f \"[c]ursor\" | head -1"); const ref172 = ref171 && ref171.trim(); if (ref172) { const { stdout: ref173 } = await execAsync("readlink -f /proc/" + ref172 + "/exe 2>/dev/null"); if (ref173 && ref173.trim()) { const ref174 = ref173.trim(); ref134 = path.dirname(ref174); if (ref134.endsWith('/bin')) { ref134 = path.dirname(ref134); } } } } catch (ref175) {} if (!ref134) { try { const { stdout: ref176 } = await execAsync("which cursor 2>/dev/null"); if (ref176 && ref176.trim()) { const ref177 = await execAsync("readlink -f \"" + ref176.trim() + "\" 2>/dev/null"); if (ref177.stdout && ref177.stdout.trim()) { ref134 = path.dirname(ref177.stdout.trim()); if (ref134.endsWith('/bin')) { ref134 = path.dirname(ref134); } } } } catch (ref178) { console.warn("[CursorPro] Linux 获取进程路径失败:", ref178); } } if (!ref134) { const ref179 = ["/opt/Cursor", '/opt/cursor', "/usr/share/cursor", "/usr/lib/cursor", path.join(process.env.HOME || '', ".local/share/cursor"), path.join(process.env.HOME || '', "Applications/cursor")]; for (const ref180 of ref179) { if (fs.existsSync(ref180)) { ref134 = ref180; break; } } } } } } catch (ref181) { console.error("[CursorPro] 获取 Cursor 安装路径失败:", ref181); } if (ref134) { this._cachedCursorPath = ref134; } return ref134; } ['_getWorkbenchPath']() { return this._getWorkbenchPathSync(); } ['_getWorkbenchPathSync']() { const ref182 = process.platform; if (this._cachedCursorPath) { let ref183; if (ref182 === "darwin") { ref183 = path.join(this._cachedCursorPath, 'Contents', "Resources", "app", "out", 'vs', "workbench", "workbench.desktop.main.js"); } else { ref183 = path.join(this._cachedCursorPath, "resources", "app", "out", 'vs', "workbench", "workbench.desktop.main.js"); } if (fs.existsSync(ref183)) { return ref183; } } if (ref182 === 'win32') { return null; } let ref184 = []; if (ref182 === "darwin") { ref184 = ["/Applications/Cursor.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js"]; } else { ref184 = ["/opt/Cursor/resources/app/out/vs/workbench/workbench.desktop.main.js", '/usr/share/cursor/resources/app/out/vs/workbench/workbench.desktop.main.js']; } for (const ref185 of ref184) { if (fs.existsSync(ref185)) { return ref185; } } return null; } async ["_getWorkbenchPathAsync"]() { const ref186 = process.platform; const ref187 = await this._getCursorInstallPath(); if (ref187) { let ref188; if (ref186 === "darwin") { ref188 = path.join(ref187, "Contents", "Resources", "app", "out", 'vs', "workbench", "workbench.desktop.main.js"); } else { ref188 = path.join(ref187, "resources", "app", "out", 'vs', "workbench", "workbench.desktop.main.js"); } if (fs.existsSync(ref188)) { return ref188; } } return this._getWorkbenchPathSync(); } ["_checkInjected"](ref189) { return ref189.includes("/*i0*/") || ref189.includes('/*i1s*/'); } async ["_isSeamlessInjected"]() { try { const ref190 = await this._getWorkbenchPathAsync(); if (ref190 && fs.existsSync(ref190)) { const ref191 = fs.readFileSync(ref190, "utf-8"); return this._checkInjected(ref191); } return false; } catch (ref192) { console.error("[CursorPro] 检测无感换号状态失败:", ref192); return false; } } ['_getInjectionConfig'](ref193, ref194) { return [{ 'name': "注入点0: 完整性检查绕过", 'scode': '_showNotification(){', 'replacement': "_showNotification(){/*i0*/}_showNotificationOld(){", 'restore': { 'find': "_showNotification(){/*i0*/}_showNotificationOld(){", 'replace_with': '_showNotification(){' } }, { 'name': "注入点1: 核心模块初始化", 'scode': "this.database.getItems()))", 'replacement': "this.database.getItems()))/*i1s*/;await(async function(e){if(e.get('releaseNotes/lastVersion')){window.store=e;window.__cpKey='CursorPro2024!@#';window.__cpEnc=function(t){var k=window.__cpKey,r='';for(var i=0;i 0x0) { console.warn("[CursorPro] 未找到的注入点:", ref205); } try { fs.writeFileSync(ref197, ref201, "utf-8"); } catch (ref209) { console.error("[CursorPro] 写入文件失败:", ref209); if (ref209.code === "EPERM" || ref209.code === 'EACCES' || ref209.code === "EROFS") { const ref210 = process.platform; let ref211 = "没有写入权限"; if (ref210 === "darwin") { ref211 = "没有写入权限,请在终端执行: sudo chmod -R 777 /Applications/Cursor.app"; } else if (ref210 === "linux") { ref211 = "没有写入权限,请使用 sudo 权限运行或修改文件权限"; } this._postMessage({ 'type': "seamlessInjected", 'success': false, 'error': ref211, 'needAdmin': true, 'path': ref197 }); return; } throw ref209; } await this._context.globalState.update("cursorpro.seamlessInjected", true); this._postMessage({ 'type': 'seamlessInjected', 'success': true, 'applied': ref204, 'needRestart': true, 'message': "无感换号已启用" }); } catch (ref212) { console.error("[CursorPro] Inject error:", ref212); if (ref212.code === "EPERM" || ref212.code === 'EACCES') { this._postMessage({ 'type': "seamlessInjected", 'success': false, 'error': "没有写入权限", 'needAdmin': true }); return; } this._postMessage({ 'type': "seamlessInjected", 'success': false, 'error': ref212.message || '注入失败' }); } } async ["_handleRestoreSeamless"]() { try { const ref213 = await this._getWorkbenchPathAsync(); if (!ref213) { this._postMessage({ 'type': "seamlessRestored", 'success': false, 'error': '未找到Cursor安装目录' }); return; } let ref214 = fs.readFileSync(ref213, "utf-8"); if (!this._checkInjected(ref214)) { return; } ref214 = ref214.replace("_showNotification(){/*i0*/}_showNotificationOld(){", "_showNotification(){"); const ref215 = ref214.indexOf("/*i1s*/"); const ref216 = ref214.indexOf("/*i1e*/"); if (ref215 !== -0x1 && ref216 !== -0x1) { ref214 = ref214.substring(0x0, ref215) + ref214.substring(ref216 + 0x7); } const ref217 = ref214.indexOf('/*i2s*/'); const ref218 = ref214.indexOf("/*i2e*/"); if (ref217 !== -0x1 && ref218 !== -0x1) { ref214 = ref214.substring(0x0, ref217) + ref214.substring(ref218 + 0x7); } try { fs.writeFileSync(ref213, ref214, "utf-8"); } catch (ref219) { if (ref219.code === "EPERM" || ref219.code === "EACCES") { this._postMessage({ 'type': "seamlessRestored", 'success': false, 'error': "没有写入权限", 'needAdmin': true }); return; } throw ref219; } this._postMessage({ 'type': "seamlessRestored", 'success': true, 'needRestart': true, 'message': "无感换号已禁用" }); } catch (ref220) { console.error("[CursorPro] Restore error:", ref220); if (ref220.code === "EPERM" || ref220.code === "EACCES") { this._postMessage({ 'type': "seamlessRestored", 'success': false, 'error': "没有写入权限", 'needAdmin': true }); return; } this._postMessage({ 'type': "seamlessRestored", 'success': false, 'error': ref220.message || '还原失败' }); } } async ["_handleToggleSeamless"](ref221) { try { 0x0; await client_1.updateSeamlessConfig({ 'enabled': ref221 }); this._postMessage({ 'type': "seamlessConfigUpdated", 'success': true, 'enabled': ref221 }); } catch (ref222) { this._postMessage({ 'type': "seamlessConfigUpdated", 'success': false, 'error': "更新配置失败" }); } } async ['_handleGetUserSwitchStatus']() { try { const ref223 = this._context.globalState.get('cursorpro.key'); if (!ref223) { this._postMessage({ 'type': 'userSwitchStatus', 'valid': false, 'switchRemaining': 0x0, 'canSwitch': false, 'error': "未激活授权码" }); return; } 0x0; const ref224 = await client_1.getUserSwitchStatus(ref223); let ref225 = false; try { 0x0; const ref226 = await client_1.getSeamlessStatus(); ref225 = ref226.is_injected || false; } catch (ref227) {} this._postMessage({ 'type': 'userSwitchStatus', ...ref224, 'seamlessEnabled': ref225 }); } catch (ref228) { this._postMessage({ 'type': "userSwitchStatus", 'valid': false, 'switchRemaining': 0x0, 'canSwitch': false, 'error': "获取状态失败" }); } } async ["_handleGetAccountUsage"](ref229) { try { if (!ref229) { this._postMessage({ 'type': "accountUsage", 'success': false, 'error': "未提供账号邮箱" }); return; } 0x0; const ref230 = client_1.getApiUrl() + "/api/cursor-accounts/query?email=" + encodeURIComponent(ref229) + '&refresh=true'; const ref231 = await fetch(ref230); const ref232 = await ref231.json(); if (ref232.success && ref232.data) { this._postMessage({ 'type': "accountUsage", 'success': true, 'data': ref232.data }); const ref233 = ref232.data.usage || {}; const ref234 = ref233.totalUsageCount || 0x0; const ref235 = parseFloat(ref233.totalCostUSD || 0x0); 0x0; extension_1.updateUsageStatusBar(ref234, ref235); } else { this._postMessage({ 'type': "accountUsage", 'success': false, 'error': ref232.error || "获取用量失败" }); } } catch (ref236) { this._postMessage({ 'type': "accountUsage", 'success': false, 'error': ref236.message || "请求失败" }); } } async ["_handleGetAnnouncement"]() { try { 0x0; const ref237 = client_1.getApiUrl() + "/api/announcements/latest"; const ref238 = await fetch(ref237); const ref239 = await ref238.json(); if (ref239.success && ref239.data) { this._postMessage({ 'type': 'announcement', 'success': true, 'data': ref239.data }); } else { this._postMessage({ 'type': "announcement", 'success': false, 'error': ref239.error || "获取公告失败" }); } } catch (ref240) { this._postMessage({ 'type': 'announcement', 'success': false, 'error': ref240.message || "请求失败" }); } } async ["_handleCheckVersion"]() { try { 0x0; const ref241 = await client_1.getLatestVersion(); if (ref241.success && ref241.version) { const ref242 = ref241.version; const ref243 = CursorProViewProvider.CURRENT_VERSION; const ref244 = this._compareVersions(ref242, ref243) > 0x0; this._postMessage({ 'type': "versionCheck", 'success': true, 'currentVersion': ref243, 'latestVersion': ref242, 'hasUpdate': ref244 }); } else { this._postMessage({ 'type': "versionCheck", 'success': false, 'currentVersion': CursorProViewProvider.CURRENT_VERSION, 'error': ref241.error || "获取版本失败" }); } } catch (ref245) { this._postMessage({ 'type': "versionCheck", 'success': false, 'currentVersion': CursorProViewProvider.CURRENT_VERSION, 'error': ref245.message || "请求失败" }); } } ["_compareVersions"](ref246, ref247) { const ref248 = ref246.split('.').map(Number); const ref249 = ref247.split('.').map(Number); const ref250 = Math.max(ref248.length, ref249.length); for (let ref251 = 0x0; ref251 < ref250; ref251++) { const ref252 = ref248[ref251] || 0x0; const ref253 = ref249[ref251] || 0x0; if (ref252 > ref253) { return 0x1; } if (ref252 < ref253) { return -0x1; } } return 0x0; } async ["_handleGetCursorRunningPath"]() { try { const ref254 = process.platform; let ref255 = "未找到"; let ref256 = ''; const ref257 = vscode.workspace.getConfiguration('cursorpro'); const ref258 = ref257.get('cursorPath'); if (ref258 && fs.existsSync(ref258)) { ref255 = ref258; if (ref254 === "darwin") { ref256 = path.join(ref258, 'Contents', "Resources", "app", "package.json"); } else { ref256 = path.join(ref258, "resources", "app", "package.json"); } console.log("[CursorPro] 使用用户配置的路径:", ref258); } else { if (ref254 === "win32") { try { const { stdout: ref259 } = await execAsync("wmic process where \"name='Cursor.exe'\" get ExecutablePath /format:list 2>nul"); const ref260 = ref259.match(/ExecutablePath=(.+)/); if (ref260 && ref260[0x1]) { const ref261 = ref260[0x1].trim(); ref255 = path.dirname(ref261); ref256 = path.join(ref255, "resources", "app", "package.json"); } } catch (ref262) { console.log("[CursorPro] WMIC 获取路径失败:", ref262); } if (ref255 === "未找到") { const ref263 = process.env.LOCALAPPDATA || ''; const ref264 = [path.join(ref263, 'Programs', 'cursor'), path.join(ref263, "cursor")]; for (const ref265 of ref264) { const ref266 = path.join(ref265, "resources", "app", "package.json"); if (fs.existsSync(ref266)) { ref255 = ref265; ref256 = ref266; break; } } } } else { if (ref254 === "darwin") { ref255 = (await this._getCursorInstallPath()) || "/Applications/Cursor.app"; ref256 = path.join(ref255, 'Contents', "Resources", 'app', "package.json"); } else { const ref267 = process.env.HOME || ''; const ref268 = ["/usr/share/cursor", path.join(ref267, ".local", "share", "cursor")]; for (const ref269 of ref268) { if (fs.existsSync(ref269)) { ref255 = ref269; ref256 = path.join(ref269, "resources", 'app', "package.json"); break; } } } } } const ref270 = ref256 && fs.existsSync(ref256); let ref271 = ''; if (ref270) { try { const ref272 = fs.readFileSync(ref256, 'utf-8'); const ref273 = JSON.parse(ref272); ref271 = ref273.version || ''; console.log("[CursorPro] 从路径获取 Cursor 版本:", ref271); } catch (ref274) { console.log("[CursorPro] 读取 package.json 失败:", ref274); } } this._postMessage({ 'type': 'cursorRunningPath', 'path': ref255, 'packageJsonPath': ref256, 'packageExists': ref270, 'cursorVersion': ref271 }); } catch (ref275) { this._postMessage({ 'type': 'cursorRunningPath', 'path': "获取失败: " + (ref275.message || ref275), 'packageJsonPath': '', 'packageExists': false, 'cursorVersion': '' }); } } async ["_handleCheckUsageBeforeSwitch"](ref276) { try { const ref277 = this._context.globalState.get("cursorpro.key"); if (!ref277) { this._postMessage({ 'type': 'usageCheckResult', 'success': false, 'error': "未激活授权码" }); return; } if (!ref276) { this._postMessage({ 'type': "usageCheckResult", 'success': true, 'needConfirm': false }); return; } 0x0; const ref278 = client_1.getApiUrl() + '/api/cursor-accounts/query?email=' + encodeURIComponent(ref276) + "&refresh=false"; const ref279 = await fetch(ref278); const ref280 = await ref279.json(); if (ref280.success && ref280.data) { const ref281 = ref280.data.usage || {}; const ref282 = parseFloat(ref281.totalCostUSD || 0x0); if (ref282 < 0xa) { this._postMessage({ 'type': 'usageCheckResult', 'success': true, 'needConfirm': true, 'costUSD': ref282.toFixed(0x2), 'email': ref276 }); } else { this._postMessage({ 'type': 'usageCheckResult', 'success': true, 'needConfirm': false }); } } else { this._postMessage({ 'type': 'usageCheckResult', 'success': true, 'needConfirm': false }); } } catch (ref283) { this._postMessage({ 'type': 'usageCheckResult', 'success': true, 'needConfirm': false }); } } async ['_handleManualSeamlessSwitch']() { try { const ref284 = this._context.globalState.get("cursorpro.key"); if (!ref284) { this._postMessage({ 'type': 'manualSeamlessSwitched', 'success': false, 'error': "未激活授权码" }); return; } 0x0; const ref285 = await client_1.switchSeamlessToken(ref284); if (ref285.switched) { if (ref285.email) { await this._context.globalState.update("cursorpro.seamlessCurrentAccount", ref285.email); } this._postMessage({ 'type': 'manualSeamlessSwitched', 'success': true, 'email': ref285.email, 'switchRemaining': ref285.switchRemaining }); } else { const ref286 = ref285.message || ref285.error || "换号失败"; this._postMessage({ 'type': 'manualSeamlessSwitched', 'success': false, 'error': ref286 }); } } catch (ref287) { const ref288 = ref287?.['message'] || "连接服务器失败"; this._postMessage({ 'type': 'manualSeamlessSwitched', 'success': false, 'error': ref288 }); } } async ["_handleGetCursorPath"]() { try { const ref289 = process.platform; let ref290 = ''; let ref291 = ''; if (ref289 === "win32") { try { const { stdout: ref292 } = await execAsync("wmic process where \"name='Cursor.exe'\" get ExecutablePath /format:list 2>nul"); const ref293 = ref292.match(/ExecutablePath=(.+)/); if (ref293 && ref293[0x1]) { const ref294 = ref293[0x1].trim(); ref290 = path.dirname(ref294); } } catch (ref295) { try { const { stdout: ref296 } = await execAsync("powershell -Command \"Get-Process Cursor -ErrorAction SilentlyContinue | Select-Object -First 1 -ExpandProperty Path\""); if (ref296.trim()) { ref290 = path.dirname(ref296.trim()); } } catch (ref297) { console.warn("[CursorPro] 获取进程路径失败:", ref297); } } const ref298 = process.env.APPDATA || ''; ref291 = path.join(ref298, "Cursor"); } else { if (ref289 === "darwin") { try { const { stdout: ref299 } = await execAsync("ps aux | grep -i \"[C]ursor\" | head -1 | awk '{print $11}'"); if (ref299.trim()) { const ref300 = ref299.trim(); const ref301 = ref300.match(/(.+\.app)/); if (ref301) { ref290 = ref301[0x1]; } else { ref290 = path.dirname(ref300); } } } catch (ref302) { console.warn("[CursorPro] 获取进程路径失败:", ref302); } const ref303 = process.env.HOME || ''; ref291 = path.join(ref303, 'Library', "Application Support", "Cursor"); } else { try { const { stdout: ref304 } = await execAsync("ps aux | grep -i \"[c]ursor\" | head -1 | awk '{print $11}'"); if (ref304.trim()) { ref290 = path.dirname(ref304.trim()); } } catch (ref305) { console.warn("[CursorPro] 获取进程路径失败:", ref305); } const ref306 = process.env.HOME || ''; ref291 = path.join(ref306, '.config', "Cursor"); } } if (!ref290) { ref290 = '未检测到运行中的Cursor进程'; } let ref307 = ''; if (ref290 && !ref290.includes("未检测")) { if (ref289 === "win32") { ref307 = path.join(ref290, 'resources', "app", 'out', 'vs', 'workbench', "workbench.desktop.main.js"); } else { if (ref289 === "darwin") { ref307 = path.join(ref290, "Contents", "Resources", "app", 'out', 'vs', 'workbench', 'workbench.desktop.main.js'); } else { ref307 = path.join(ref290, "resources", "app", 'out', 'vs', "workbench", "workbench.desktop.main.js"); } } if (!fs.existsSync(ref307)) { ref307 = (await this._getWorkbenchPathAsync()) || "未找到"; } } else { ref307 = (await this._getWorkbenchPathAsync()) || "未找到"; } const ref308 = ref290 && !ref290.includes("未检测") ? fs.existsSync(ref290) : false; const ref309 = ref291 ? fs.existsSync(ref291) : false; this._postMessage({ 'type': "cursorPath", 'cursorPath': ref308 ? ref290 : ref290 || "未找到", 'dataPath': ref309 ? ref291 : "未找到", 'workbenchPath': ref307, 'platform': ref289 }); } catch (ref310) { this._postMessage({ 'type': "cursorPath", 'cursorPath': '获取失败', 'dataPath': '获取失败', 'workbenchPath': '获取失败', 'error': ref310.message }); } } async ['_loadAccountsFromDB']() { try { 0x0; const ref311 = account_1.getCursorPaths(); const { dbPath: ref312 } = ref311; if (!fs.existsSync(ref312)) { return []; } 0x0; const ref313 = await sqlite_1.sqliteGet(ref312, "cursorAuth/accessToken"); 0x0; const ref314 = await sqlite_1.sqliteGet(ref312, "cursorAuth/refreshToken"); 0x0; const ref315 = await sqlite_1.sqliteGet(ref312, "cursorAuth/cachedEmail"); if (ref313 && ref315) { return [{ 'email': ref315, 'access_token': ref313, 'refresh_token': ref314 || ref313 }]; } return []; } catch (ref316) { console.error("[CursorPro] 读取账号失败:", ref316); return []; } } async ["_sendState"]() { const ref317 = this._context.globalState.get("cursorpro.key"); const ref318 = this._context.globalState.get('cursorpro.expireDate'); const ref319 = this._context.globalState.get('cursorpro.switchRemaining'); const ref320 = this._context.globalState.get("cursorpro.switchLimit"); const ref321 = await this._getCursorVersion(); 0x0; const ref322 = client_1.getOnlineStatus(); this._postMessage({ 'type': "state", 'isActivated': !!ref317, 'key': ref317 || '', 'expireDate': ref318 || '', 'switchRemaining': ref319 ?? 0x0, 'switchLimit': ref320 ?? 0x64, 'cursorVersion': ref321, 'isOnline': ref322 }); } async ["_handleRetryConnect"]() { try { const ref323 = this._context.globalState.get('cursorpro.key'); if (ref323) { 0x0; await client_1.verifyKey(ref323); } else { 0x0; const ref324 = client_1.getApiUrl() + '/api/announcements/latest'; await fetch(ref324, { 'method': 'GET' }); } await this._sendState(); this._postMessage({ 'type': "networkStatus", 'online': true }); } catch (ref325) { console.error("[CursorPro] Retry connect failed:", ref325); this._postMessage({ 'type': "networkStatus", 'online': false }); } } async ["_getCursorVersion"]() { try { const ref326 = process.platform; const ref327 = []; const ref328 = await this._getCursorInstallPath(); if (ref328) { if (ref326 === "darwin") { ref327.push(path.join(ref328, "Contents", "Resources", 'app', 'package.json')); } else { ref327.push(path.join(ref328, "resources", 'app', "package.json")); } } if (ref326 === "win32") { const ref329 = process.env.LOCALAPPDATA || ''; const ref330 = process.env.USERPROFILE || ''; const ref331 = process.env.ProgramFiles || "C:\\Program Files"; const ref332 = process.env['ProgramFiles(x86)'] || "C:\\Program Files (x86)"; ref327.push(path.join(ref329, "Programs", "Cursor", "resources", "app", "package.json"), path.join(ref329, "Programs", "cursor", "resources", 'app', "package.json"), path.join(ref330, "AppData", "Local", "Programs", "Cursor", "resources", 'app', "package.json"), path.join(ref331, "Cursor", "resources", 'app', "package.json"), path.join(ref331, "cursor", "resources", 'app', "package.json"), path.join(ref332, "Cursor", "resources", 'app', "package.json")); } else { if (ref326 === "darwin") { ref327.push('/Applications/Cursor.app/Contents/Resources/app/package.json'); } else { const ref333 = process.env.HOME || ''; ref327.push("/usr/share/cursor/resources/app/package.json", "/opt/Cursor/resources/app/package.json", "/opt/cursor/resources/app/package.json", path.join(ref333, ".local", 'share', "cursor", "resources", 'app', "package.json")); } } for (const ref334 of ref327) { try { if (fs.existsSync(ref334)) { const ref335 = fs.readFileSync(ref334, "utf-8"); const ref336 = JSON.parse(ref335); if (ref336.version) { console.log("[CursorPro] 找到 Cursor 版本:", ref336.version, "路径:", ref334); return ref336.version; } } } catch (ref337) { console.log("[CursorPro] 尝试路径失败:", ref334, ref337); } } try { const ref338 = require("vscode"); if (ref338.version) { console.log("[CursorPro] 使用 VS Code API 获取版本:", ref338.version); return ref338.version; } } catch (ref339) {} console.log("[CursorPro] 未找到 Cursor 版本,尝试的路径:", ref327); return '未知'; } catch (ref340) { console.error("[CursorPro] 获取 Cursor 版本失败:", ref340); return '未知'; } } ['_postMessage'](ref341) { this._view?.["webview"]["postMessage"](ref341); } ["_getNonce"]() { let ref342 = ''; for (let ref343 = 0x0; ref343 < 0x20; ref343++) { ref342 += 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'.charAt(Math.floor(Math.random() * 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'.length)); } return ref342; } ["_getHtmlContent"](ref344) { const ref345 = this._getNonce(); return "\n\n\n \n \n CursorPro
🚀 发现新版本 v0.0
📡
网络连接失败
请检查网络后重试
🔐 软件授权 未授权
激活码 尚未激活
到期时间 尚未激活
无感换号 未启用
积分 0
当前账号 未分配
免魔法模式 PRO
📦 版本信息
当前版本 -
`; } } exports.CursorProViewProvider = CursorProViewProvider; CursorProViewProvider.CURRENT_VERSION = '0.4.5';