mirror of
https://github.com/lWolvesl/antigravity-usage-monitor.git
synced 2026-11-27 01:19:25 +08:00
fix(panel): auto-provision Desktop shortcuts and add out-of-job 1-click host relaunch for 2.33.0+
- Add cross-platform desktop launcher manager (backend/desktop-launcher-config.mjs): automatically appends --remote-debugging-port=0 to user Desktop (including OneDrive), Start Menu, Taskbar pinned, and Startup Antigravity.lnk shortcuts plus existing HKCU Run entries on Windows and XDG .desktop launchers on Linux, with clean rollback when switching back to Sidebar Only mode - Remove ineffective Desktop argv.json provisioning (Electron Desktop 2.33.0 does not read argv.json) while retaining ~/.antigravity-ide/argv.json for Antigravity IDE - Add POST /api/bridge/relaunch (with hot-reload POST /api/settings fallback) using Shell.Application (-Sta + UTF-8 BOM .ps1) on Windows to break out of the host Job Object, exit tray instances, clean up stale DevToolsActivePort files, sanitize host environment variables, and relaunch with --remote-debugging-port=0 (plus open -a / nohup support on macOS and Linux, and live running-process path discovery across drives) - Surface dismissible BridgeStatusNotice banner directly at the top of App.js alongside Settings tabs so users can activate topbar/composer mounting in one click Closes #26
This commit is contained in:
@@ -45,8 +45,14 @@ import {
|
||||
import { getCloudStatus } from './pricing-catalog.mjs';
|
||||
import { buildTelemetryPayload } from './telemetry-builder.mjs';
|
||||
import {
|
||||
ensureDesktopLaunchEntriesConfigured,
|
||||
triggerDesktopHostRelaunch,
|
||||
} from './desktop-launcher-config.mjs';
|
||||
import {
|
||||
ensureIdeRemoteDebuggingArgv,
|
||||
notifyModelContextWindowsChanged,
|
||||
notifyWindowOverlaySetting,
|
||||
resolveDevToolsPortCandidates,
|
||||
startDefaultWindowBridge,
|
||||
} from './window-bridge.mjs';
|
||||
import { ensureCliStatusLineConfigured } from './cli-statusline-config.mjs';
|
||||
@@ -452,6 +458,20 @@ export async function executeAccountCredentialAction(data) {
|
||||
};
|
||||
}
|
||||
|
||||
export async function executeBridgeRelaunchAction() {
|
||||
ensureIdeRemoteDebuggingArgv({ enabled: true });
|
||||
await ensureDesktopLaunchEntriesConfigured({ enabled: true }).catch(() => {});
|
||||
const result = await triggerDesktopHostRelaunch({
|
||||
stalePortFiles: resolveDevToolsPortCandidates(),
|
||||
});
|
||||
return {
|
||||
status: result.ok ? 200 : Number(result.status || 500),
|
||||
contentType: 'application/json',
|
||||
headers: { 'Cache-Control': 'no-store' },
|
||||
body: JSON.stringify(result),
|
||||
};
|
||||
}
|
||||
|
||||
const BRIDGE_ROUTE_LOOKUP = new Map(
|
||||
BRIDGE_API_ROUTE_DEFS.map((r) => [`${r.method}:${r.path}`, r.action])
|
||||
);
|
||||
@@ -462,6 +482,9 @@ export async function dispatchBridgeApiRequest(pathname, method, data, opts = un
|
||||
case 'telemetry':
|
||||
return executeTelemetryAction(data, opts);
|
||||
case 'settings':
|
||||
if (isPlainObject(data) && data.__bridgeAction === 'relaunch') {
|
||||
return executeBridgeRelaunchAction();
|
||||
}
|
||||
return executeSettingsAction(data);
|
||||
case 'accounts_get':
|
||||
return executeAccountCredentialAction();
|
||||
@@ -477,6 +500,8 @@ export async function dispatchBridgeApiRequest(pathname, method, data, opts = un
|
||||
return executeCloudSyncAction();
|
||||
case 'plugin_update':
|
||||
return executePluginUpdateAction();
|
||||
case 'bridge_relaunch':
|
||||
return executeBridgeRelaunchAction();
|
||||
default:
|
||||
return {
|
||||
status: 404,
|
||||
|
||||
@@ -0,0 +1,995 @@
|
||||
/**
|
||||
* @fileoverview Antigravity Desktop 2.33.0+ 跨平台启动入口自动补齐与一键带参重拉控制器。
|
||||
*
|
||||
* 背景:
|
||||
* Antigravity Desktop (`Antigravity.exe` / `Antigravity.app` / `antigravity`) 自 `2.33.0` 起
|
||||
* 默认不再于启动时开启 `--remote-debugging-port=0`,且独立 Electron 桌面端不读取 VS Code 系的 `argv.json`。
|
||||
*
|
||||
* 本模块在不触碰任何宿主二进制与 `app.asar` 的前提下,提供两层无感恢复能力:
|
||||
* 1. 日常全自动层 (`ensureDesktopLaunchEntriesConfigured`):
|
||||
* - Windows:自动为当前用户的桌面(含 OneDrive 重定向桌面)、开始菜单、任务栏固定图标、启动文件夹中的
|
||||
* `Antigravity.lnk` 快捷方式及已存在的 `HKCU\...\Run` 自启项补齐 `--remote-debugging-port=0`;
|
||||
* - Linux:自动在 `~/.local/share/applications/antigravity.desktop`(必要时自系统目录复制)与
|
||||
* `~/.config/autostart/antigravity.desktop` 的 `Exec=` 中补齐 `--remote-debugging-port=0`;
|
||||
* - 当用户切回「仅侧边栏」且无上下文窗口覆写时,可干净移除本插件托管的 `--remote-debugging-port=0`,绝不触碰用户自定义端口;
|
||||
* 2. 当下裸启动会话一键重拉层 (`triggerDesktopHostRelaunch`):
|
||||
* - Windows 通过 `Shell.Application` (`explorer.exe` 进程外 COM) 脱离宿主 Job Object 托管生命周期,
|
||||
* macOS / Linux 通过独立会话 `nohup` 脱离进程组,自动退出系统托盘常驻实例、清理陈旧 `DevToolsActivePort`
|
||||
* 并以纯净桌面环境变量追加 `--remote-debugging-port=0` 重新拉起宿主客户端。
|
||||
*/
|
||||
|
||||
import { existsSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from 'node:fs';
|
||||
import { homedir } from 'node:os';
|
||||
import { basename, dirname, join } from 'node:path';
|
||||
import { DATA_DIR, lsRuntimeEndpoint } from './config.mjs';
|
||||
|
||||
export const REMOTE_DEBUG_LAUNCH_FLAG = '--remote-debugging-port=0';
|
||||
|
||||
const REMOTE_DEBUG_ANY_RE = /(?:^|\s)--remote-debugging-port(?:=|\s|$)/i;
|
||||
const REMOTE_DEBUG_MANAGED_ZERO_RE = /(?:^|\s+)--remote-debugging-port=(?:"0"|'0'|0)(?=\s|$)/gi;
|
||||
|
||||
/**
|
||||
* 在命令行参数字符串中幂等补齐或移除托管的 `--remote-debugging-port=0`,保留用户自定义的其它参数或自定义端口。
|
||||
*
|
||||
* @param {unknown} rawArgs
|
||||
* @param {{ enabled?: boolean }} [options]
|
||||
* @returns {{ changed: boolean, configured: boolean, alreadyConfigured?: boolean, removed?: boolean, args: string }}
|
||||
*/
|
||||
export function ensureRemoteDebugFlagInArgs(rawArgs, { enabled = true } = {}) {
|
||||
const current = String(rawArgs ?? '').trim();
|
||||
if (enabled) {
|
||||
if (REMOTE_DEBUG_ANY_RE.test(current)) {
|
||||
return {
|
||||
changed: false,
|
||||
configured: true,
|
||||
alreadyConfigured: true,
|
||||
args: current,
|
||||
};
|
||||
}
|
||||
const nextArgs = current
|
||||
? `${current} ${REMOTE_DEBUG_LAUNCH_FLAG}`
|
||||
: REMOTE_DEBUG_LAUNCH_FLAG;
|
||||
return {
|
||||
changed: true,
|
||||
configured: true,
|
||||
args: nextArgs,
|
||||
};
|
||||
}
|
||||
|
||||
if (!REMOTE_DEBUG_MANAGED_ZERO_RE.test(current)) {
|
||||
REMOTE_DEBUG_MANAGED_ZERO_RE.lastIndex = 0;
|
||||
return {
|
||||
changed: false,
|
||||
configured: REMOTE_DEBUG_ANY_RE.test(current),
|
||||
args: current,
|
||||
};
|
||||
}
|
||||
REMOTE_DEBUG_MANAGED_ZERO_RE.lastIndex = 0;
|
||||
const stripped = current.replace(REMOTE_DEBUG_MANAGED_ZERO_RE, ' ').replace(/\s{2,}/g, ' ').trim();
|
||||
return {
|
||||
changed: stripped !== current,
|
||||
configured: REMOTE_DEBUG_ANY_RE.test(stripped),
|
||||
removed: stripped !== current,
|
||||
args: stripped,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析并无损修补 Windows `HKCU\Software\Microsoft\Windows\CurrentVersion\Run` 自启命令行字符串。
|
||||
* 严格仅匹配目标可执行文件名为 `Antigravity.exe` 的项(排除 `Antigravity IDE.exe` 及无关程序)。
|
||||
*
|
||||
* @param {unknown} rawValue
|
||||
* @param {{ enabled?: boolean }} [options]
|
||||
* @returns {{ matched: boolean, changed: boolean, configured: boolean, value: string }}
|
||||
*/
|
||||
export function patchWindowsRunRegistryCommand(rawValue, { enabled = true } = {}) {
|
||||
const raw = String(rawValue ?? '').trim();
|
||||
if (!raw) {
|
||||
return { matched: false, changed: false, configured: false, value: raw };
|
||||
}
|
||||
const m = raw.match(/^\s*(?:"([^"]+)"|([^\s"]+))([\s\S]*)$/);
|
||||
if (!m) {
|
||||
return { matched: false, changed: false, configured: false, value: raw };
|
||||
}
|
||||
const exePath = String(m[1] || m[2] || '').trim();
|
||||
const exeLeaf = exePath.split(/[\\/]/).pop() || '';
|
||||
if (exeLeaf.toLowerCase() !== 'antigravity.exe') {
|
||||
return { matched: false, changed: false, configured: false, value: raw };
|
||||
}
|
||||
const quotedExe = m[1] ? `"${exePath}"` : /\s/.test(exePath) ? `"${exePath}"` : exePath;
|
||||
const patchedArgs = ensureRemoteDebugFlagInArgs(m[3] || '', { enabled });
|
||||
const nextValue = patchedArgs.args ? `${quotedExe} ${patchedArgs.args}` : quotedExe;
|
||||
return {
|
||||
matched: true,
|
||||
changed: nextValue !== raw,
|
||||
configured: patchedArgs.configured,
|
||||
value: nextValue,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 修补 Linux XDG `.desktop` 文件文本中的 `Exec=` 启动行(仅作用于 `antigravity` 桌面端,不修改 `antigravity-ide`)。
|
||||
*
|
||||
* @param {string} rawText
|
||||
* @param {{ enabled?: boolean }} [options]
|
||||
* @returns {{ matched: boolean, changed: boolean, configured: boolean, text: string }}
|
||||
*/
|
||||
export function patchLinuxDesktopEntryText(rawText, { enabled = true } = {}) {
|
||||
if (typeof rawText !== 'string' || !rawText.trim()) {
|
||||
return { matched: false, changed: false, configured: false, text: String(rawText || '') };
|
||||
}
|
||||
const eol = rawText.includes('\r\n') ? '\r\n' : '\n';
|
||||
const lines = rawText.split(/\r?\n/);
|
||||
let matched = false;
|
||||
let changed = false;
|
||||
let configured = false;
|
||||
|
||||
const nextLines = lines.map((line) => {
|
||||
const execMatch = line.match(/^(\s*Exec\s*=\s*)(.+)$/);
|
||||
if (!execMatch) return line;
|
||||
const prefix = execMatch[1];
|
||||
const cmdBody = execMatch[2].trim();
|
||||
const binMatch = cmdBody.match(/^(?:"([^"]+)"|'([^']+)'|([^\s"']+))([\s\S]*)$/);
|
||||
if (!binMatch) return line;
|
||||
const rawBin = String(binMatch[1] || binMatch[2] || binMatch[3] || '');
|
||||
const leaf = (rawBin.split('/').pop() || '').toLowerCase();
|
||||
if (leaf !== 'antigravity') {
|
||||
return line;
|
||||
}
|
||||
matched = true;
|
||||
const binToken = binMatch[1]
|
||||
? `"${binMatch[1]}"`
|
||||
: binMatch[2]
|
||||
? `'${binMatch[2]}'`
|
||||
: binMatch[3];
|
||||
const rest = String(binMatch[4] || '').trim();
|
||||
|
||||
if (enabled) {
|
||||
if (REMOTE_DEBUG_ANY_RE.test(rest)) {
|
||||
configured = true;
|
||||
return line;
|
||||
}
|
||||
configured = true;
|
||||
changed = true;
|
||||
const fieldCodeMatch = rest.match(/^(.*?)\s*(%[fFuUdDnNickvm](?:\s+%[fFuUdDnNickvm])*)\s*$/);
|
||||
if (fieldCodeMatch) {
|
||||
const beforeCodes = fieldCodeMatch[1].trim();
|
||||
const codes = fieldCodeMatch[2].trim();
|
||||
const mid = beforeCodes
|
||||
? `${beforeCodes} ${REMOTE_DEBUG_LAUNCH_FLAG}`
|
||||
: REMOTE_DEBUG_LAUNCH_FLAG;
|
||||
return `${prefix}${binToken} ${mid} ${codes}`;
|
||||
}
|
||||
return rest
|
||||
? `${prefix}${binToken} ${rest} ${REMOTE_DEBUG_LAUNCH_FLAG}`
|
||||
: `${prefix}${binToken} ${REMOTE_DEBUG_LAUNCH_FLAG}`;
|
||||
}
|
||||
|
||||
const stripped = ensureRemoteDebugFlagInArgs(rest, { enabled: false });
|
||||
configured = configured || stripped.configured;
|
||||
if (!stripped.changed) return line;
|
||||
changed = true;
|
||||
return stripped.args ? `${prefix}${binToken} ${stripped.args}` : `${prefix}${binToken}`;
|
||||
});
|
||||
|
||||
return {
|
||||
matched,
|
||||
changed,
|
||||
configured,
|
||||
text: changed ? nextLines.join(eol) : rawText,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理 Sidecar / MCP 子进程继承的宿主会话私有环境变量,确保重拉后的客户端运行于纯净桌面上下文。
|
||||
*
|
||||
* @param {Record<string, string|undefined>} [baseEnv=process.env]
|
||||
* @returns {Record<string, string>}
|
||||
*/
|
||||
export function buildSanitizedDesktopRelaunchEnv(baseEnv = process.env) {
|
||||
const clean = {};
|
||||
for (const [key, val] of Object.entries(baseEnv || {})) {
|
||||
if (val === undefined || val === null) continue;
|
||||
if (
|
||||
/^(?:ANTIGRAVITY_|CHROME_DEVTOOLS_MCP_|USAGE_MONITOR_|ELECTRON_RUN_AS_NODE$|NODE_OPTIONS$)/i.test(
|
||||
key
|
||||
)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
clean[key] = String(val);
|
||||
}
|
||||
return clean;
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动定位本机 Antigravity Desktop(或 IDE)主程序路径(优先从 `ANTIGRAVITY_AGENTAPI_EXE` 向上反推,回退标准安装目录)。
|
||||
*
|
||||
* @param {{
|
||||
* env?: Record<string, string|undefined>,
|
||||
* platform?: string,
|
||||
* homeDir?: string,
|
||||
* existsFn?: (p: string) => boolean,
|
||||
* }} [options]
|
||||
* @returns {{ found: boolean, kind: 'desktop'|'ide'|'', executablePath: string, appBundlePath: string }}
|
||||
*/
|
||||
export function resolveDesktopHostExecutable({
|
||||
env = process.env,
|
||||
platform = process.platform,
|
||||
homeDir = homedir(),
|
||||
existsFn = existsSync,
|
||||
} = {}) {
|
||||
const safeExists = (p) => {
|
||||
try {
|
||||
return Boolean(p && existsFn(p));
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
const hintPaths = [
|
||||
String(env?.USAGE_MONITOR_HOST_EXE || '').trim(),
|
||||
String(env?.ANTIGRAVITY_AGENTAPI_EXE || '').trim(),
|
||||
String(env?.CHROME_DEVTOOLS_MCP_JS || '').trim(),
|
||||
].filter(Boolean);
|
||||
|
||||
for (const rawHint of hintPaths) {
|
||||
if (platform === 'darwin') {
|
||||
const appIdx = rawHint.toLowerCase().indexOf('.app/');
|
||||
const bundleCand =
|
||||
appIdx >= 0
|
||||
? rawHint.slice(0, appIdx + 4)
|
||||
: rawHint.toLowerCase().endsWith('.app')
|
||||
? rawHint
|
||||
: '';
|
||||
if (bundleCand && safeExists(bundleCand)) {
|
||||
const isIde = /antigravity\s*ide\.app$/i.test(bundleCand);
|
||||
const macBin = join(
|
||||
bundleCand,
|
||||
'Contents',
|
||||
'MacOS',
|
||||
isIde ? 'Antigravity IDE' : 'Antigravity'
|
||||
);
|
||||
return {
|
||||
found: true,
|
||||
kind: isIde ? 'ide' : 'desktop',
|
||||
executablePath: safeExists(macBin) ? macBin : bundleCand,
|
||||
appBundlePath: bundleCand,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (platform === 'win32' && /\.exe$/i.test(rawHint) && !/language_server/i.test(rawHint)) {
|
||||
if (safeExists(rawHint)) {
|
||||
const isIde = /antigravity\s*ide\.exe$/i.test(rawHint);
|
||||
return {
|
||||
found: true,
|
||||
kind: isIde ? 'ide' : 'desktop',
|
||||
executablePath: rawHint,
|
||||
appBundlePath: '',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
let cur = rawHint;
|
||||
for (let depth = 0; depth < 8 && cur && dirname(cur) !== cur; depth += 1) {
|
||||
const base = basename(cur).toLowerCase();
|
||||
if (base === 'resources') {
|
||||
const installRoot = dirname(cur);
|
||||
if (platform === 'win32') {
|
||||
const desktopExe = join(installRoot, 'Antigravity.exe');
|
||||
if (safeExists(desktopExe)) {
|
||||
return { found: true, kind: 'desktop', executablePath: desktopExe, appBundlePath: '' };
|
||||
}
|
||||
const ideExe = join(installRoot, 'Antigravity IDE.exe');
|
||||
if (safeExists(ideExe)) {
|
||||
return { found: true, kind: 'ide', executablePath: ideExe, appBundlePath: '' };
|
||||
}
|
||||
} else if (platform === 'linux') {
|
||||
for (const binName of ['antigravity', 'Antigravity']) {
|
||||
const linuxExe = join(installRoot, binName);
|
||||
if (safeExists(linuxExe)) {
|
||||
return { found: true, kind: 'desktop', executablePath: linuxExe, appBundlePath: '' };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
cur = dirname(cur);
|
||||
}
|
||||
}
|
||||
|
||||
if (platform === 'win32') {
|
||||
const localAppData = env?.LOCALAPPDATA || join(homeDir, 'AppData', 'Local');
|
||||
const programFiles = env?.ProgramFiles || 'C:\\Program Files';
|
||||
const winCandidates = [
|
||||
join(localAppData, 'Programs', 'Antigravity', 'Antigravity.exe'),
|
||||
join(programFiles, 'Antigravity', 'Antigravity.exe'),
|
||||
join(localAppData, 'Antigravity', 'Antigravity.exe'),
|
||||
];
|
||||
for (const cand of winCandidates) {
|
||||
if (safeExists(cand)) {
|
||||
return { found: true, kind: 'desktop', executablePath: cand, appBundlePath: '' };
|
||||
}
|
||||
}
|
||||
} else if (platform === 'darwin') {
|
||||
const macBundles = [
|
||||
join(homeDir, 'Applications', 'Antigravity.app'),
|
||||
'/Applications/Antigravity.app',
|
||||
];
|
||||
for (const bundlePath of macBundles) {
|
||||
if (safeExists(bundlePath)) {
|
||||
const macBin = join(bundlePath, 'Contents', 'MacOS', 'Antigravity');
|
||||
return {
|
||||
found: true,
|
||||
kind: 'desktop',
|
||||
executablePath: safeExists(macBin) ? macBin : bundlePath,
|
||||
appBundlePath: bundlePath,
|
||||
};
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const linuxCandidates = [
|
||||
'/opt/Antigravity/antigravity',
|
||||
'/opt/antigravity/antigravity',
|
||||
'/usr/share/antigravity/antigravity',
|
||||
'/usr/bin/antigravity',
|
||||
join(homeDir, '.local', 'bin', 'antigravity'),
|
||||
];
|
||||
for (const cand of linuxCandidates) {
|
||||
if (safeExists(cand)) {
|
||||
return { found: true, kind: 'desktop', executablePath: cand, appBundlePath: '' };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return { found: false, kind: '', executablePath: '', appBundlePath: '' };
|
||||
}
|
||||
|
||||
async function runLauncherExecFile(file, args, options = {}) {
|
||||
const cpMod = await import('node:child_process');
|
||||
const execFileFn = cpMod.execFile || cpMod.default?.execFile;
|
||||
if (typeof execFileFn !== 'function') {
|
||||
throw new Error('child_process.execFile unavailable');
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
execFileFn(
|
||||
file,
|
||||
args,
|
||||
{
|
||||
windowsHide: true,
|
||||
timeout: options.timeoutMs || 8000,
|
||||
maxBuffer: 1024 * 1024,
|
||||
env: options.env || process.env,
|
||||
},
|
||||
(err, stdout) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
return;
|
||||
}
|
||||
resolve(String(stdout || ''));
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
async function spawnDetachedProcess(file, args, options = {}) {
|
||||
const cpMod = await import('node:child_process');
|
||||
const spawnFn = cpMod.spawn || cpMod.default?.spawn;
|
||||
if (typeof spawnFn !== 'function') {
|
||||
throw new Error('child_process.spawn unavailable');
|
||||
}
|
||||
const child = spawnFn(file, args, {
|
||||
detached: true,
|
||||
stdio: 'ignore',
|
||||
windowsHide: true,
|
||||
cwd: options.cwd || undefined,
|
||||
env: options.env || process.env,
|
||||
});
|
||||
child.unref?.();
|
||||
return { pid: Number(child?.pid || 0) };
|
||||
}
|
||||
|
||||
function writeTextFileAtomically(filePath, content, fsOps) {
|
||||
const { mkdirFn, writeFn, renameFn, unlinkFn } = fsOps;
|
||||
mkdirFn(dirname(filePath), { recursive: true });
|
||||
const tmpPath = `${filePath}.tmp-${process.pid}`;
|
||||
try {
|
||||
writeFn(tmpPath, content, 'utf8');
|
||||
renameFn(tmpPath, filePath);
|
||||
} catch {
|
||||
try {
|
||||
unlinkFn(tmpPath);
|
||||
} catch {
|
||||
// 忽略临时文件清理异常
|
||||
}
|
||||
writeFn(filePath, content, 'utf8');
|
||||
}
|
||||
}
|
||||
|
||||
const WIN_SHORTCUT_PROVISION_PS = `
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$enableFlag = $env:AGY_LAUNCH_ENABLED -eq '1'
|
||||
$updated = New-Object System.Collections.Generic.List[string]
|
||||
$configured = New-Object System.Collections.Generic.List[string]
|
||||
$ws = New-Object -ComObject WScript.Shell
|
||||
$userProgramsDir = [Environment]::GetFolderPath('Programs')
|
||||
|
||||
$scanSpecs = @(
|
||||
@{ Dir = [Environment]::GetFolderPath('Desktop'); Recurse = $false; IsCommon = $false },
|
||||
@{ Dir = $userProgramsDir; Recurse = $true; IsCommon = $false },
|
||||
@{ Dir = [Environment]::GetFolderPath('StartMenu'); Recurse = $false; IsCommon = $false },
|
||||
@{ Dir = [Environment]::GetFolderPath('Startup'); Recurse = $false; IsCommon = $false },
|
||||
@{ Dir = (Join-Path $env:APPDATA 'Microsoft\\Internet Explorer\\Quick Launch\\User Pinned\\TaskBar'); Recurse = $false; IsCommon = $false },
|
||||
@{ Dir = [Environment]::GetFolderPath('CommonDesktopDirectory'); Recurse = $false; IsCommon = $true },
|
||||
@{ Dir = [Environment]::GetFolderPath('CommonPrograms'); Recurse = $true; IsCommon = $true }
|
||||
)
|
||||
|
||||
$seen = New-Object 'System.Collections.Generic.HashSet[string]' ([System.StringComparer]::OrdinalIgnoreCase)
|
||||
foreach ($spec in $scanSpecs) {
|
||||
$dir = [string]$spec.Dir
|
||||
if (-not $dir -or -not (Test-Path -LiteralPath $dir)) { continue }
|
||||
$items = @()
|
||||
try {
|
||||
if ($spec.Recurse) {
|
||||
$items = @(Get-ChildItem -LiteralPath $dir -Filter '*.lnk' -File -Recurse -Depth 2 -ErrorAction SilentlyContinue)
|
||||
} else {
|
||||
$items = @(Get-ChildItem -LiteralPath $dir -Filter '*.lnk' -File -ErrorAction SilentlyContinue)
|
||||
}
|
||||
} catch { continue }
|
||||
|
||||
foreach ($item in $items) {
|
||||
$lnkPath = [string]$item.FullName
|
||||
if (-not $seen.Add($lnkPath)) { continue }
|
||||
try {
|
||||
$sc = $ws.CreateShortcut($lnkPath)
|
||||
$target = [string]$sc.TargetPath
|
||||
if ([System.IO.Path]::GetFileName($target) -ine 'Antigravity.exe') { continue }
|
||||
$curArgs = [string]$sc.Arguments
|
||||
if ($enableFlag) {
|
||||
if ($curArgs -match '(?:^|\\s)--remote-debugging-port(?:=|\\s|$)') {
|
||||
$configured.Add($lnkPath)
|
||||
continue
|
||||
}
|
||||
$nextArgs = ($curArgs.Trim() + ' --remote-debugging-port=0').Trim()
|
||||
try {
|
||||
$sc.Arguments = $nextArgs
|
||||
$sc.Save()
|
||||
$updated.Add($lnkPath)
|
||||
$configured.Add($lnkPath)
|
||||
} catch {
|
||||
if ($spec.IsCommon -and $userProgramsDir -and (Test-Path -LiteralPath $userProgramsDir)) {
|
||||
$fallbackLnk = Join-Path $userProgramsDir ([System.IO.Path]::GetFileName($lnkPath))
|
||||
if (-not (Test-Path -LiteralPath $fallbackLnk)) {
|
||||
try {
|
||||
$uSc = $ws.CreateShortcut($fallbackLnk)
|
||||
$uSc.TargetPath = $target
|
||||
$uSc.Arguments = $nextArgs
|
||||
if ($sc.WorkingDirectory) { $uSc.WorkingDirectory = $sc.WorkingDirectory }
|
||||
if ($sc.IconLocation) { $uSc.IconLocation = $sc.IconLocation }
|
||||
if ($sc.Description) { $uSc.Description = $sc.Description }
|
||||
$uSc.Save()
|
||||
$updated.Add($fallbackLnk)
|
||||
$configured.Add($fallbackLnk)
|
||||
} catch {}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$stripped = ([regex]::Replace($curArgs, '(?:^|\\s+)--remote-debugging-port=(?:"0"|''0''|0)(?=\\s|$)', ' ')).Trim()
|
||||
if ($stripped -ne $curArgs.Trim()) {
|
||||
try {
|
||||
$sc.Arguments = $stripped
|
||||
$sc.Save()
|
||||
$updated.Add($lnkPath)
|
||||
} catch {}
|
||||
}
|
||||
if ($stripped -match '(?:^|\\s)--remote-debugging-port(?:=|\\s|$)') {
|
||||
$configured.Add($lnkPath)
|
||||
}
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
}
|
||||
|
||||
$runKey = 'HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Run'
|
||||
if (Test-Path -LiteralPath $runKey) {
|
||||
try {
|
||||
$regItem = Get-Item -LiteralPath $runKey -ErrorAction SilentlyContinue
|
||||
if ($regItem) {
|
||||
foreach ($valName in $regItem.GetValueNames()) {
|
||||
$rawCmd = [string]$regItem.GetValue($valName, '', [Microsoft.Win32.RegistryValueOptions]::DoNotExpandEnvironmentNames)
|
||||
if (-not $rawCmd) { continue }
|
||||
if ($rawCmd -notmatch '^\\s*(?:"([^"]+)"|([^\\s"]+))(.*)$') { continue }
|
||||
$exeCandidate = if ($Matches[1]) { $Matches[1] } else { $Matches[2] }
|
||||
$restPart = [string]$Matches[3]
|
||||
if ([System.IO.Path]::GetFileName($exeCandidate) -ine 'Antigravity.exe') { continue }
|
||||
$quotedExe = if ($Matches[1] -or $exeCandidate -match '\\s') { '"' + $exeCandidate + '"' } else { $exeCandidate }
|
||||
if ($enableFlag) {
|
||||
if ($restPart -match '(?:^|\\s)--remote-debugging-port(?:=|\\s|$)') {
|
||||
$configured.Add("HKCU:Run:$valName")
|
||||
continue
|
||||
}
|
||||
$nextRest = ($restPart.Trim() + ' --remote-debugging-port=0').Trim()
|
||||
$nextVal = "$quotedExe $nextRest"
|
||||
Set-ItemProperty -LiteralPath $runKey -Name $valName -Value $nextVal -ErrorAction SilentlyContinue
|
||||
$updated.Add("HKCU:Run:$valName")
|
||||
$configured.Add("HKCU:Run:$valName")
|
||||
} else {
|
||||
$strippedRest = ([regex]::Replace($restPart, '(?:^|\\s+)--remote-debugging-port=(?:"0"|''0''|0)(?=\\s|$)', ' ')).Trim()
|
||||
$nextVal = if ($strippedRest) { "$quotedExe $strippedRest" } else { $quotedExe }
|
||||
if ($nextVal -ne $rawCmd.Trim()) {
|
||||
Set-ItemProperty -LiteralPath $runKey -Name $valName -Value $nextVal -ErrorAction SilentlyContinue
|
||||
$updated.Add("HKCU:Run:$valName")
|
||||
}
|
||||
if ($strippedRest -match '(?:^|\\s)--remote-debugging-port(?:=|\\s|$)') {
|
||||
$configured.Add("HKCU:Run:$valName")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
|
||||
[pscustomobject]@{
|
||||
ok = $true
|
||||
updatedPaths = @($updated)
|
||||
configuredPaths = @($configured)
|
||||
} | ConvertTo-Json -Compress
|
||||
`.trim();
|
||||
|
||||
/**
|
||||
* 自动同步当前系统下用户空间启动入口(Windows `.lnk` / `HKCU:Run`、Linux `.desktop`)中的 `--remote-debugging-port=0`。
|
||||
*
|
||||
* @param {{
|
||||
* enabled?: boolean,
|
||||
* env?: Record<string, string|undefined>,
|
||||
* platform?: string,
|
||||
* homeDir?: string,
|
||||
* execFileFn?: ((file: string, args: string[], opts?: object) => Promise<string>)|null,
|
||||
* fsOps?: {
|
||||
* existsFn?: typeof existsSync,
|
||||
* readFn?: typeof readFileSync,
|
||||
* writeFn?: typeof writeFileSync,
|
||||
* mkdirFn?: typeof mkdirSync,
|
||||
* renameFn?: typeof renameSync,
|
||||
* unlinkFn?: typeof unlinkSync,
|
||||
* }|null,
|
||||
* allowInTest?: boolean,
|
||||
* }} [options]
|
||||
*/
|
||||
export async function ensureDesktopLaunchEntriesConfigured({
|
||||
enabled = true,
|
||||
env = process.env,
|
||||
platform = process.platform,
|
||||
homeDir = homedir(),
|
||||
execFileFn = null,
|
||||
fsOps = null,
|
||||
allowInTest = false,
|
||||
} = {}) {
|
||||
if (lsRuntimeEndpoint.addr === 'test.invalid' && !allowInTest) {
|
||||
return {
|
||||
checked: false,
|
||||
updated: false,
|
||||
alreadyConfigured: false,
|
||||
updatedPaths: [],
|
||||
configuredPaths: [],
|
||||
reason: 'test_sandbox_skipped',
|
||||
};
|
||||
}
|
||||
|
||||
const ops = {
|
||||
existsFn: fsOps?.existsFn || existsSync,
|
||||
readFn: fsOps?.readFn || readFileSync,
|
||||
writeFn: fsOps?.writeFn || writeFileSync,
|
||||
mkdirFn: fsOps?.mkdirFn || mkdirSync,
|
||||
renameFn: fsOps?.renameFn || renameSync,
|
||||
unlinkFn: fsOps?.unlinkFn || unlinkSync,
|
||||
};
|
||||
|
||||
if (platform === 'win32') {
|
||||
try {
|
||||
const runner = execFileFn || runLauncherExecFile;
|
||||
const out = await runner(
|
||||
'powershell.exe',
|
||||
['-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass', '-Command', WIN_SHORTCUT_PROVISION_PS],
|
||||
{
|
||||
timeoutMs: 9000,
|
||||
env: {
|
||||
...env,
|
||||
AGY_LAUNCH_ENABLED: enabled ? '1' : '0',
|
||||
},
|
||||
}
|
||||
);
|
||||
const trimmed = String(out || '').trim();
|
||||
const jsonLine = trimmed.split(/\r?\n/).reverse().find((l) => l.trim().startsWith('{')) || '';
|
||||
const parsed = jsonLine ? JSON.parse(jsonLine) : null;
|
||||
const updatedPaths = Array.isArray(parsed?.updatedPaths)
|
||||
? parsed.updatedPaths.map(String).filter(Boolean)
|
||||
: [];
|
||||
const configuredPaths = Array.isArray(parsed?.configuredPaths)
|
||||
? parsed.configuredPaths.map(String).filter(Boolean)
|
||||
: [];
|
||||
return {
|
||||
checked: true,
|
||||
updated: updatedPaths.length > 0,
|
||||
alreadyConfigured: updatedPaths.length === 0 && configuredPaths.length > 0,
|
||||
configured: configuredPaths.length > 0,
|
||||
updatedPaths,
|
||||
configuredPaths,
|
||||
};
|
||||
} catch (err) {
|
||||
return {
|
||||
checked: true,
|
||||
updated: false,
|
||||
alreadyConfigured: false,
|
||||
configured: false,
|
||||
updatedPaths: [],
|
||||
configuredPaths: [],
|
||||
reason: 'win_shortcut_error',
|
||||
error: err?.message || String(err),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (platform === 'linux') {
|
||||
const dataHome = env?.XDG_DATA_HOME || join(homeDir, '.local', 'share');
|
||||
const configHome = env?.XDG_CONFIG_HOME || join(homeDir, '.config');
|
||||
const userDesktopFile = join(dataHome, 'applications', 'antigravity.desktop');
|
||||
const systemDesktopFiles = [
|
||||
'/usr/share/applications/antigravity.desktop',
|
||||
'/usr/local/share/applications/antigravity.desktop',
|
||||
];
|
||||
const autostartDesktopFile = join(configHome, 'autostart', 'antigravity.desktop');
|
||||
|
||||
const updatedPaths = [];
|
||||
const configuredPaths = [];
|
||||
|
||||
try {
|
||||
let baseUserText = '';
|
||||
if (ops.existsFn(userDesktopFile)) {
|
||||
baseUserText = String(ops.readFn(userDesktopFile, 'utf8') || '');
|
||||
} else if (enabled) {
|
||||
const sysSource = systemDesktopFiles.find((p) => ops.existsFn(p));
|
||||
if (sysSource) {
|
||||
baseUserText = String(ops.readFn(sysSource, 'utf8') || '');
|
||||
}
|
||||
}
|
||||
if (baseUserText) {
|
||||
const patched = patchLinuxDesktopEntryText(baseUserText, { enabled });
|
||||
if (patched.changed) {
|
||||
writeTextFileAtomically(userDesktopFile, patched.text, ops);
|
||||
updatedPaths.push(userDesktopFile);
|
||||
}
|
||||
if (patched.configured) {
|
||||
configuredPaths.push(userDesktopFile);
|
||||
}
|
||||
}
|
||||
|
||||
if (ops.existsFn(autostartDesktopFile)) {
|
||||
const autoRaw = String(ops.readFn(autostartDesktopFile, 'utf8') || '');
|
||||
const patchedAuto = patchLinuxDesktopEntryText(autoRaw, { enabled });
|
||||
if (patchedAuto.changed) {
|
||||
writeTextFileAtomically(autostartDesktopFile, patchedAuto.text, ops);
|
||||
updatedPaths.push(autostartDesktopFile);
|
||||
}
|
||||
if (patchedAuto.configured) {
|
||||
configuredPaths.push(autostartDesktopFile);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
checked: true,
|
||||
updated: updatedPaths.length > 0,
|
||||
alreadyConfigured: updatedPaths.length === 0 && configuredPaths.length > 0,
|
||||
configured: configuredPaths.length > 0,
|
||||
updatedPaths,
|
||||
configuredPaths,
|
||||
};
|
||||
} catch (err) {
|
||||
return {
|
||||
checked: true,
|
||||
updated: false,
|
||||
alreadyConfigured: false,
|
||||
configured: false,
|
||||
updatedPaths,
|
||||
configuredPaths,
|
||||
reason: 'linux_desktop_error',
|
||||
error: err?.message || String(err),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// macOS `.app` 包具有 Apple 代码签名,不修改签名目录,交由一键重拉 (`open -a ... --args`) 处理
|
||||
return {
|
||||
checked: true,
|
||||
updated: false,
|
||||
alreadyConfigured: false,
|
||||
configured: false,
|
||||
updatedPaths: [],
|
||||
configuredPaths: [],
|
||||
reason: 'macos_app_bundle_signed',
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 当静态环境变量与默认安装目录均未命中(如用户自定义安装至 D:/E: 盘且 Sidecar 未继承 `ANTIGRAVITY_AGENTAPI_EXE`)时,
|
||||
* 直接从当前正在运行的宿主进程动态反查主程序绝对路径。
|
||||
*/
|
||||
async function discoverRunningHostExecutable({ platform = process.platform, execFileFn = null } = {}) {
|
||||
const runner = execFileFn || runLauncherExecFile;
|
||||
if (platform === 'win32') {
|
||||
try {
|
||||
const ps =
|
||||
"@(Get-Process -Name 'Antigravity','Antigravity IDE' -ErrorAction SilentlyContinue | Where-Object { $_.Path } | Select-Object -First 1) | ForEach-Object { [pscustomobject]@{ path = [string]$_.Path; name = [string]$_.ProcessName } } | ConvertTo-Json -Compress";
|
||||
const out = await runner(
|
||||
'powershell.exe',
|
||||
['-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass', '-Command', ps],
|
||||
{ timeoutMs: 4000 }
|
||||
);
|
||||
const trimmed = String(out || '').trim();
|
||||
if (trimmed && trimmed.startsWith('{')) {
|
||||
const parsed = JSON.parse(trimmed);
|
||||
const exePath = String(parsed?.path || '').trim();
|
||||
if (exePath) {
|
||||
const isIde = /ide/i.test(String(parsed?.name || '')) || /antigravity\s*ide\.exe$/i.test(exePath);
|
||||
return {
|
||||
found: true,
|
||||
kind: isIde ? 'ide' : 'desktop',
|
||||
executablePath: exePath,
|
||||
appBundlePath: '',
|
||||
};
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// 忽略动态进程探测异常
|
||||
}
|
||||
} else if (platform === 'darwin') {
|
||||
try {
|
||||
const out = await runner(
|
||||
'osascript',
|
||||
['-e', 'POSIX path of (path to application "Antigravity")'],
|
||||
{ timeoutMs: 3000 }
|
||||
);
|
||||
const bundlePath = String(out || '').trim().replace(/\/+$/, '');
|
||||
if (bundlePath && /\.app$/i.test(bundlePath)) {
|
||||
return {
|
||||
found: true,
|
||||
kind: 'desktop',
|
||||
executablePath: bundlePath,
|
||||
appBundlePath: bundlePath,
|
||||
};
|
||||
}
|
||||
} catch {
|
||||
// 忽略 AppleScript 探测异常
|
||||
}
|
||||
}
|
||||
return { found: false, kind: '', executablePath: '', appBundlePath: '' };
|
||||
}
|
||||
|
||||
function psSingleQuote(val) {
|
||||
return `'${String(val ?? '').replace(/'/g, "''")}'`;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建 Windows 脱离宿主 Job Object 的隐藏重拉内层脚本(写入临时 UTF-8 BOM `.ps1` 文件后交由 `explorer.exe` 拉起,规避 `ShellExecute` 参数长度上限)。
|
||||
*
|
||||
* @param {string} executablePath
|
||||
* @param {string[]} stalePortFiles
|
||||
* @param {'desktop'|'ide'|''} kind
|
||||
* @returns {string}
|
||||
*/
|
||||
export function buildWindowsRelaunchInnerScript(executablePath, stalePortFiles = [], kind = 'desktop') {
|
||||
const procName = kind === 'ide' ? 'Antigravity IDE' : 'Antigravity';
|
||||
const portLiterals = (Array.isArray(stalePortFiles) ? stalePortFiles : [])
|
||||
.map((p) => String(p || '').trim())
|
||||
.filter(Boolean)
|
||||
.map(psSingleQuote)
|
||||
.join(', ');
|
||||
|
||||
return `
|
||||
Start-Sleep -Milliseconds 480
|
||||
$exe = ${psSingleQuote(executablePath)}
|
||||
$procName = ${psSingleQuote(procName)}
|
||||
$staleList = @(${portLiterals})
|
||||
$mySid = (Get-Process -Id $PID).SessionId
|
||||
|
||||
if (-not $exe -or -not (Test-Path -LiteralPath $exe)) {
|
||||
$livePath = Get-Process -Name $procName -ErrorAction SilentlyContinue | Where-Object { $_.SessionId -eq $mySid -and $_.Path } | Select-Object -First 1 -ExpandProperty Path
|
||||
if ($livePath) { $exe = [string]$livePath }
|
||||
}
|
||||
|
||||
$findTargets = {
|
||||
@(Get-Process -Name $procName -ErrorAction SilentlyContinue | Where-Object {
|
||||
$_.SessionId -eq $mySid -and (-not $_.Path -or -not $exe -or [string]::Equals($_.Path, $exe, [System.StringComparison]::OrdinalIgnoreCase))
|
||||
})
|
||||
}
|
||||
|
||||
$initial = & $findTargets
|
||||
foreach ($p in $initial) {
|
||||
try {
|
||||
if ($p.MainWindowHandle -ne 0) { [void]$p.CloseMainWindow() }
|
||||
} catch {}
|
||||
}
|
||||
Start-Sleep -Milliseconds 850
|
||||
|
||||
$remaining = & $findTargets
|
||||
foreach ($p in $remaining) {
|
||||
try { Stop-Process -Id $p.Id -Force -ErrorAction SilentlyContinue } catch {}
|
||||
}
|
||||
|
||||
for ($i = 0; $i -lt 30; $i++) {
|
||||
if ((& $findTargets).Count -eq 0) { break }
|
||||
Start-Sleep -Milliseconds 200
|
||||
}
|
||||
|
||||
foreach ($fp in $staleList) {
|
||||
if ($fp -and (Test-Path -LiteralPath $fp)) {
|
||||
try { Remove-Item -LiteralPath $fp -Force -ErrorAction SilentlyContinue } catch {}
|
||||
}
|
||||
}
|
||||
|
||||
if ($exe -and (Test-Path -LiteralPath $exe)) {
|
||||
$workDir = Split-Path -Parent $exe
|
||||
Start-Process -FilePath $exe -ArgumentList '--remote-debugging-port=0' -WorkingDirectory $workDir
|
||||
}
|
||||
|
||||
if ($PSCommandPath -and (Test-Path -LiteralPath $PSCommandPath)) {
|
||||
Remove-Item -LiteralPath $PSCommandPath -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
`.trim();
|
||||
}
|
||||
|
||||
const WIN_OUT_OF_JOB_DISPATCH_PS = `
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$innerArgs = '-NoProfile -NonInteractive -ExecutionPolicy Bypass -WindowStyle Hidden -File "' + $env:AGY_RELAUNCH_PS1 + '"'
|
||||
try {
|
||||
$shellApp = New-Object -ComObject Shell.Application
|
||||
$shellApp.ShellExecute('powershell.exe', $innerArgs, '', 'open', 0)
|
||||
Write-Output '{"ok":true,"method":"shell_application"}'
|
||||
} catch {
|
||||
Start-Process -FilePath 'powershell.exe' -ArgumentList $innerArgs -WindowStyle Hidden
|
||||
Write-Output '{"ok":true,"method":"start_process"}'
|
||||
}
|
||||
`.trim();
|
||||
|
||||
/**
|
||||
* 触发跨平台一键退出系统托盘后台并追加 `--remote-debugging-port=0` 重新拉起宿主客户端。
|
||||
*
|
||||
* @param {{
|
||||
* env?: Record<string, string|undefined>,
|
||||
* platform?: string,
|
||||
* homeDir?: string,
|
||||
* stalePortFiles?: string[],
|
||||
* execFileFn?: ((file: string, args: string[], opts?: object) => Promise<string>)|null,
|
||||
* spawnFn?: ((file: string, args: string[], opts?: object) => Promise<{ pid: number }>)|null,
|
||||
* existsFn?: typeof existsSync,
|
||||
* writeFileFn?: typeof writeFileSync,
|
||||
* mkdirFn?: typeof mkdirSync,
|
||||
* allowInTest?: boolean,
|
||||
* }} [options]
|
||||
*/
|
||||
export async function triggerDesktopHostRelaunch({
|
||||
env = process.env,
|
||||
platform = process.platform,
|
||||
homeDir = homedir(),
|
||||
stalePortFiles = [],
|
||||
execFileFn = null,
|
||||
spawnFn = null,
|
||||
existsFn = existsSync,
|
||||
writeFileFn = writeFileSync,
|
||||
mkdirFn = mkdirSync,
|
||||
allowInTest = false,
|
||||
} = {}) {
|
||||
if (lsRuntimeEndpoint.addr === 'test.invalid' && !allowInTest) {
|
||||
return { ok: false, status: 403, error: 'Disabled in test sandbox' };
|
||||
}
|
||||
|
||||
let hostInfo = resolveDesktopHostExecutable({ env, platform, homeDir, existsFn });
|
||||
if (!hostInfo.found) {
|
||||
hostInfo = await discoverRunningHostExecutable({ platform, execFileFn });
|
||||
}
|
||||
if (!hostInfo.found) {
|
||||
return {
|
||||
ok: false,
|
||||
status: 404,
|
||||
error: 'Unable to locate Antigravity executable on this machine',
|
||||
};
|
||||
}
|
||||
|
||||
const cleanEnv = buildSanitizedDesktopRelaunchEnv(env);
|
||||
const cleanStaleFiles = (Array.isArray(stalePortFiles) ? stalePortFiles : [])
|
||||
.map((p) => String(p || '').trim())
|
||||
.filter(Boolean);
|
||||
|
||||
if (platform === 'win32') {
|
||||
const innerScript = buildWindowsRelaunchInnerScript(
|
||||
hostInfo.executablePath,
|
||||
cleanStaleFiles,
|
||||
hostInfo.kind
|
||||
);
|
||||
const tempDir = String(env?.TEMP || env?.TMP || DATA_DIR || homeDir).trim();
|
||||
mkdirFn(tempDir, { recursive: true });
|
||||
const relaunchPs1Path = join(tempDir, `agy-monitor-relaunch-${process.pid}.ps1`);
|
||||
// UTF-8 with BOM ensures Windows PowerShell 5.1 parses non-ASCII paths accurately across all system locales
|
||||
writeFileFn(relaunchPs1Path, `\uFEFF${innerScript}\r\n`, 'utf8');
|
||||
|
||||
const runner = execFileFn || runLauncherExecFile;
|
||||
await runner(
|
||||
'powershell.exe',
|
||||
[
|
||||
'-Sta',
|
||||
'-NoProfile',
|
||||
'-NonInteractive',
|
||||
'-ExecutionPolicy',
|
||||
'Bypass',
|
||||
'-Command',
|
||||
WIN_OUT_OF_JOB_DISPATCH_PS,
|
||||
],
|
||||
{
|
||||
timeoutMs: 6000,
|
||||
env: {
|
||||
...cleanEnv,
|
||||
AGY_RELAUNCH_PS1: relaunchPs1Path,
|
||||
},
|
||||
}
|
||||
);
|
||||
return {
|
||||
ok: true,
|
||||
relaunching: true,
|
||||
platform,
|
||||
executablePath: hostInfo.executablePath,
|
||||
};
|
||||
}
|
||||
|
||||
const spawner = spawnFn || spawnDetachedProcess;
|
||||
|
||||
if (platform === 'darwin') {
|
||||
const appTarget = hostInfo.appBundlePath || hostInfo.executablePath;
|
||||
const appName = hostInfo.kind === 'ide' ? 'Antigravity IDE' : 'Antigravity';
|
||||
const shScript = [
|
||||
'sleep 0.45',
|
||||
`osascript -e 'tell application "${appName}" to quit' >/dev/null 2>&1 || true`,
|
||||
`i=0; while [ $i -lt 25 ] && pgrep -x "${appName}" >/dev/null 2>&1; do sleep 0.2; i=$((i+1)); done`,
|
||||
`if pgrep -x "${appName}" >/dev/null 2>&1; then killall "${appName}" >/dev/null 2>&1 || true; sleep 0.4; fi`,
|
||||
'IFS=":"; for f in $AGY_STALE_PORT_FILES; do [ -n "$f" ] && rm -f "$f"; done',
|
||||
'open -a "$AGY_RELAUNCH_APP" --args --remote-debugging-port=0 >/dev/null 2>&1',
|
||||
].join('; ');
|
||||
await spawner('/bin/sh', ['-c', shScript], {
|
||||
env: {
|
||||
...cleanEnv,
|
||||
AGY_RELAUNCH_APP: appTarget,
|
||||
AGY_STALE_PORT_FILES: cleanStaleFiles.join(':'),
|
||||
},
|
||||
});
|
||||
return {
|
||||
ok: true,
|
||||
relaunching: true,
|
||||
platform,
|
||||
executablePath: appTarget,
|
||||
};
|
||||
}
|
||||
|
||||
const procLeaf = basename(hostInfo.executablePath) || 'antigravity';
|
||||
const linuxScript = [
|
||||
'sleep 0.45',
|
||||
'uid="$(id -u)"',
|
||||
'pkill -u "$uid" -x "$AGY_PROC_NAME" >/dev/null 2>&1 || true',
|
||||
'i=0; while [ $i -lt 25 ] && pgrep -u "$uid" -x "$AGY_PROC_NAME" >/dev/null 2>&1; do sleep 0.2; i=$((i+1)); done',
|
||||
'IFS=":"; for f in $AGY_STALE_PORT_FILES; do [ -n "$f" ] && rm -f "$f"; done',
|
||||
'nohup "$AGY_RELAUNCH_EXE" --remote-debugging-port=0 >/dev/null 2>&1 &',
|
||||
].join('; ');
|
||||
await spawner('/bin/sh', ['-c', linuxScript], {
|
||||
env: {
|
||||
...cleanEnv,
|
||||
AGY_RELAUNCH_EXE: hostInfo.executablePath,
|
||||
AGY_PROC_NAME: procLeaf,
|
||||
AGY_STALE_PORT_FILES: cleanStaleFiles.join(':'),
|
||||
},
|
||||
});
|
||||
return {
|
||||
ok: true,
|
||||
relaunching: true,
|
||||
platform,
|
||||
executablePath: hostInfo.executablePath,
|
||||
};
|
||||
}
|
||||
@@ -31,6 +31,10 @@ import {
|
||||
saveJson,
|
||||
} from './config.mjs';
|
||||
import { createContextWindowSyncExpression } from './context-windows.mjs';
|
||||
import {
|
||||
ensureDesktopLaunchEntriesConfigured,
|
||||
resolveDesktopHostExecutable,
|
||||
} from './desktop-launcher-config.mjs';
|
||||
|
||||
const windowBridgeRef = `window[${JSON.stringify(WINDOW_BRIDGE_KEY)}]`;
|
||||
const windowOverlayRef = `window[${JSON.stringify(WINDOW_OVERLAY_KEY)}]`;
|
||||
@@ -102,56 +106,6 @@ export function resolveIdeArgvPath(env = process.env, homeDir = homedir()) {
|
||||
return join(homeDir, '.antigravity-ide', 'argv.json');
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析 Antigravity Desktop 2.0 各平台可能的启动参数文件 `argv.json` 候选路径。
|
||||
*
|
||||
* @param {Record<string, string|undefined>} [env=process.env]
|
||||
* @param {string} [platform=process.platform]
|
||||
* @param {string} [homeDir=homedir()]
|
||||
* @returns {{ dotAntigravityArgv: string, userDataArgvPaths: string[], geminiArgvPath: string }}
|
||||
*/
|
||||
export function resolveDesktopArgvCandidates(
|
||||
env = process.env,
|
||||
platform = process.platform,
|
||||
homeDir = homedir()
|
||||
) {
|
||||
const dotAntigravityArgv = join(homeDir, '.antigravity', 'argv.json');
|
||||
const geminiBase = String(env?.ANTIGRAVITY_GEMINI_DIR || '').trim() || join(homeDir, '.gemini');
|
||||
const geminiArgvPath = join(geminiBase, 'antigravity', 'argv.json');
|
||||
|
||||
let userDataDirs = [];
|
||||
if (platform === 'win32') {
|
||||
const appData = env?.APPDATA || join(homeDir, 'AppData', 'Roaming');
|
||||
const localAppData = env?.LOCALAPPDATA || join(homeDir, 'AppData', 'Local');
|
||||
userDataDirs = [join(appData, 'Antigravity'), join(localAppData, 'Antigravity')];
|
||||
} else if (platform === 'darwin') {
|
||||
userDataDirs = [
|
||||
join(homeDir, 'Library', 'Application Support', 'Antigravity'),
|
||||
join(homeDir, '.config', 'Antigravity'),
|
||||
];
|
||||
} else {
|
||||
const configHome = env?.XDG_CONFIG_HOME || join(homeDir, '.config');
|
||||
userDataDirs = [join(configHome, 'Antigravity')];
|
||||
}
|
||||
|
||||
const seen = new Set();
|
||||
const userDataArgvPaths = [];
|
||||
for (const dir of userDataDirs) {
|
||||
const argvPath = join(dir, 'argv.json');
|
||||
const key = platform === 'win32' ? argvPath.toLowerCase() : argvPath;
|
||||
if (!seen.has(key)) {
|
||||
seen.add(key);
|
||||
userDataArgvPaths.push(argvPath);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
dotAntigravityArgv,
|
||||
userDataArgvPaths,
|
||||
geminiArgvPath,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 词法扫描 JSONC 文本(支持 `//`、`/* ... * /` 注释与尾随逗号),提取纯 JSON 字符串及顶层键值坐标。
|
||||
*
|
||||
@@ -461,111 +415,6 @@ export function ensureIdeRemoteDebuggingArgv({
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 当检测到本机已安装 Antigravity Desktop 2.0(存在 `~/.antigravity`、`~/.gemini/antigravity` 或系统 `Antigravity` 数据目录)时,
|
||||
* 同步参照 IDE 方案自动补齐 `~/.antigravity/argv.json` 与已有桌面端数据目录下的 `argv.json` (`"remote-debugging-port": "0"`)。
|
||||
*
|
||||
* @param {{ env?: Record<string, string|undefined>, platform?: string, homeDir?: string, enabled?: boolean }} [options]
|
||||
*/
|
||||
export function ensureDesktopRemoteDebuggingArgv({
|
||||
env = process.env,
|
||||
platform = process.platform,
|
||||
homeDir = homedir(),
|
||||
enabled = true,
|
||||
} = {}) {
|
||||
if (!enabled) {
|
||||
return { checked: false, updated: false, alreadyConfigured: false, reason: 'disabled', results: [] };
|
||||
}
|
||||
const candidates = resolveDesktopArgvCandidates(env, platform, homeDir);
|
||||
const dotDir = dirname(candidates.dotAntigravityArgv);
|
||||
const probeDirs = [
|
||||
dotDir,
|
||||
...candidates.userDataArgvPaths.map((p) => dirname(p)),
|
||||
dirname(candidates.geminiArgvPath),
|
||||
];
|
||||
const hasDesktopInstall = probeDirs.some((dir) => {
|
||||
try {
|
||||
return existsSync(dir);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (!hasDesktopInstall) {
|
||||
return {
|
||||
checked: true,
|
||||
updated: false,
|
||||
alreadyConfigured: false,
|
||||
reason: 'desktop_dir_missing',
|
||||
results: [],
|
||||
};
|
||||
}
|
||||
|
||||
const results = [
|
||||
patchSingleHostArgvFile(candidates.dotAntigravityArgv, {
|
||||
createDir: true,
|
||||
missingReason: 'desktop_dir_missing',
|
||||
}),
|
||||
...candidates.userDataArgvPaths.map((argvPath) =>
|
||||
patchSingleHostArgvFile(argvPath, {
|
||||
createDir: false,
|
||||
missingReason: 'desktop_dir_missing',
|
||||
})
|
||||
),
|
||||
patchSingleHostArgvFile(candidates.geminiArgvPath, {
|
||||
createDir: false,
|
||||
missingReason: 'desktop_dir_missing',
|
||||
}),
|
||||
];
|
||||
|
||||
const updatedPaths = results.filter((r) => r.updated).map((r) => r.argvPath);
|
||||
const configuredPaths = results
|
||||
.filter((r) => r.updated || r.alreadyConfigured)
|
||||
.map((r) => r.argvPath);
|
||||
return {
|
||||
checked: true,
|
||||
updated: updatedPaths.length > 0,
|
||||
alreadyConfigured: updatedPaths.length === 0 && configuredPaths.length > 0,
|
||||
updatedPaths,
|
||||
configuredPaths,
|
||||
results,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 统一补齐本机 Antigravity IDE 与 Antigravity Desktop 的 `argv.json` 调试端口参数。
|
||||
*
|
||||
* @param {{ env?: Record<string, string|undefined>, platform?: string, homeDir?: string, enabled?: boolean }} [options]
|
||||
*/
|
||||
export function ensureHostRemoteDebuggingArgv({
|
||||
env = process.env,
|
||||
platform = process.platform,
|
||||
homeDir = homedir(),
|
||||
enabled = true,
|
||||
} = {}) {
|
||||
if (!enabled) {
|
||||
return { checked: false, updated: false, alreadyConfigured: false, reason: 'disabled' };
|
||||
}
|
||||
const ide = ensureIdeRemoteDebuggingArgv({ env, homeDir, enabled: true });
|
||||
const desktop = ensureDesktopRemoteDebuggingArgv({ env, platform, homeDir, enabled: true });
|
||||
const updatedPaths = [
|
||||
...(ide.updated && ide.argvPath ? [ide.argvPath] : []),
|
||||
...(desktop.updatedPaths || []),
|
||||
];
|
||||
const configuredPaths = [
|
||||
...((ide.updated || ide.alreadyConfigured) && ide.argvPath ? [ide.argvPath] : []),
|
||||
...(desktop.configuredPaths || []),
|
||||
];
|
||||
return {
|
||||
checked: true,
|
||||
updated: updatedPaths.length > 0,
|
||||
alreadyConfigured: updatedPaths.length === 0 && configuredPaths.length > 0,
|
||||
updatedPaths,
|
||||
configuredPaths,
|
||||
ide,
|
||||
desktop,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 从 `DevToolsActivePort` 文件文本首行提取合法的本地调试端口号。
|
||||
*
|
||||
@@ -860,6 +709,10 @@ export function createWindowBridgeController(options) {
|
||||
onVersionDrift = null,
|
||||
leaseFilePath = '',
|
||||
autoConfigureIdeArgv = options?.env === undefined && options?.homeDir === undefined,
|
||||
launcherExecFileFn = null,
|
||||
launcherFsOps = null,
|
||||
allowDesktopLauncherInTest = false,
|
||||
existsHostFn = existsSync,
|
||||
WebSocketImpl = globalThis.WebSocket,
|
||||
} = options || {};
|
||||
|
||||
@@ -886,8 +739,21 @@ export function createWindowBridgeController(options) {
|
||||
let hadInjectedChatFrames = false;
|
||||
let cdpFallbackActive = false;
|
||||
let ideArgvProvisioned = false;
|
||||
let hostLauncherPromise = null;
|
||||
let argvUpdatedThisBoot = false;
|
||||
let argvConfigured = false;
|
||||
let launcherConfigured = false;
|
||||
const hostExecInfo = resolveDesktopHostExecutable({
|
||||
env,
|
||||
platform,
|
||||
homeDir,
|
||||
existsFn: existsHostFn,
|
||||
});
|
||||
// Windows / macOS 支持从运行中宿主进程动态反查任意盘符路径,因此桌面端环境下即使自定义安装路径不在默认盘符也可一键重拉
|
||||
const canRelaunch = Boolean(
|
||||
hostExecInfo.found ||
|
||||
((platform === 'win32' || platform === 'darwin') && options?.existsHostFn === undefined)
|
||||
);
|
||||
let lastPersistedLeaseSig = '';
|
||||
let lastBridgeStatus = {
|
||||
state: 'pending',
|
||||
@@ -896,6 +762,8 @@ export function createWindowBridgeController(options) {
|
||||
targets: 0,
|
||||
argvUpdatedThisBoot: false,
|
||||
argvConfigured: false,
|
||||
launcherConfigured: false,
|
||||
canRelaunch,
|
||||
updatedAtMs: 0,
|
||||
};
|
||||
let hadContextWindows = false;
|
||||
@@ -1333,11 +1201,13 @@ export function createWindowBridgeController(options) {
|
||||
aliveCount: Number(aliveCount || 0),
|
||||
targets: Number(targets || 0),
|
||||
argvUpdatedThisBoot: Boolean(argvUpdatedThisBoot),
|
||||
argvConfigured: Boolean(argvConfigured),
|
||||
argvConfigured: Boolean(argvConfigured || launcherConfigured),
|
||||
launcherConfigured: Boolean(launcherConfigured || argvConfigured),
|
||||
canRelaunch: Boolean(canRelaunch),
|
||||
updatedAtMs: Date.now(),
|
||||
};
|
||||
if (leasedBySelf && leaseFilePath) {
|
||||
const sig = `${nextState}:${lastBridgeStatus.aliveCount}:${lastBridgeStatus.targets}:${argvUpdatedThisBoot ? 1 : 0}:${argvConfigured ? 1 : 0}`;
|
||||
const sig = `${nextState}:${lastBridgeStatus.aliveCount}:${lastBridgeStatus.targets}:${lastBridgeStatus.argvUpdatedThisBoot ? 1 : 0}:${lastBridgeStatus.launcherConfigured ? 1 : 0}:${lastBridgeStatus.canRelaunch ? 1 : 0}`;
|
||||
if (sig !== lastPersistedLeaseSig) {
|
||||
lastPersistedLeaseSig = sig;
|
||||
saveJson(leaseFilePath, {
|
||||
@@ -1350,12 +1220,44 @@ export function createWindowBridgeController(options) {
|
||||
targets: lastBridgeStatus.targets,
|
||||
argvUpdatedThisBoot: lastBridgeStatus.argvUpdatedThisBoot,
|
||||
argvConfigured: lastBridgeStatus.argvConfigured,
|
||||
launcherConfigured: lastBridgeStatus.launcherConfigured,
|
||||
canRelaunch: lastBridgeStatus.canRelaunch,
|
||||
updatedAtMs: Date.now(),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function provisionHostLaunchersOnce() {
|
||||
if (ideArgvProvisioned) return Promise.resolve();
|
||||
if (hostLauncherPromise) return hostLauncherPromise;
|
||||
hostLauncherPromise = (async () => {
|
||||
const ideRes = ensureIdeRemoteDebuggingArgv({ env, homeDir, enabled: true });
|
||||
const desktopRes = await ensureDesktopLaunchEntriesConfigured({
|
||||
enabled: true,
|
||||
env,
|
||||
platform,
|
||||
homeDir,
|
||||
execFileFn: launcherExecFileFn,
|
||||
fsOps: launcherFsOps,
|
||||
allowInTest: allowDesktopLauncherInTest,
|
||||
});
|
||||
if (ideRes.updated || desktopRes.updated) {
|
||||
argvUpdatedThisBoot = true;
|
||||
}
|
||||
if (ideRes.updated || ideRes.alreadyConfigured) {
|
||||
argvConfigured = true;
|
||||
}
|
||||
if (desktopRes.updated || desktopRes.alreadyConfigured || desktopRes.configured) {
|
||||
launcherConfigured = true;
|
||||
}
|
||||
ideArgvProvisioned = true;
|
||||
})().finally(() => {
|
||||
hostLauncherPromise = null;
|
||||
});
|
||||
return hostLauncherPromise;
|
||||
}
|
||||
|
||||
async function runSyncInternal({ forceReinject = false } = {}) {
|
||||
if (stopped) return { ok: false, reason: 'stopped' };
|
||||
const bundleVersion = String(getBundleVersionFn() || '');
|
||||
@@ -1372,20 +1274,10 @@ export function createWindowBridgeController(options) {
|
||||
const enabled = Boolean(curSettings.enableWindowOverlay !== false && mountMode !== 'sidebar');
|
||||
const contextWindows = curSettings.modelContextWindows || {};
|
||||
const hasContextWindows = Object.keys(contextWindows).length > 0;
|
||||
if ((enabled || hasContextWindows) && autoConfigureIdeArgv && !ideArgvProvisioned) {
|
||||
const prov = ensureHostRemoteDebuggingArgv({ env, platform, homeDir, enabled: true });
|
||||
if (prov.updated) {
|
||||
argvUpdatedThisBoot = true;
|
||||
argvConfigured = true;
|
||||
} else if (prov.alreadyConfigured) {
|
||||
argvConfigured = true;
|
||||
}
|
||||
const noInstallDirs =
|
||||
prov.ide?.reason === 'ide_dir_missing' && prov.desktop?.reason === 'desktop_dir_missing';
|
||||
if (prov.updated || prov.alreadyConfigured || noInstallDirs) {
|
||||
ideArgvProvisioned = true;
|
||||
}
|
||||
}
|
||||
const provPending =
|
||||
(enabled || hasContextWindows) && autoConfigureIdeArgv && !ideArgvProvisioned
|
||||
? provisionHostLaunchersOnce()
|
||||
: hostLauncherPromise;
|
||||
|
||||
let leasedBySelf = false;
|
||||
let currentLease = null;
|
||||
@@ -1402,13 +1294,18 @@ export function createWindowBridgeController(options) {
|
||||
return { ok: false, enabled: true, reason: 'older_than_leader', injected: 0 };
|
||||
}
|
||||
if (leaseVerNum === myVerNum || String(lease?.bundleVersion || '') === bundleVersion) {
|
||||
const mergedConfigured = Boolean(
|
||||
lease?.launcherConfigured || lease?.argvConfigured || launcherConfigured || argvConfigured
|
||||
);
|
||||
lastBridgeStatus = {
|
||||
state: String(lease?.syncState || 'active'),
|
||||
enabled: Boolean(enabled),
|
||||
aliveCount: Number(lease?.aliveCount || 0),
|
||||
targets: Number(lease?.targets || 0),
|
||||
argvUpdatedThisBoot: Boolean(lease?.argvUpdatedThisBoot || argvUpdatedThisBoot),
|
||||
argvConfigured: Boolean(lease?.argvConfigured || argvConfigured),
|
||||
argvConfigured: mergedConfigured,
|
||||
launcherConfigured: mergedConfigured,
|
||||
canRelaunch: Boolean(lease?.canRelaunch ?? canRelaunch),
|
||||
updatedAtMs: Date.now(),
|
||||
};
|
||||
return { ok: true, enabled: true, reason: 'follower_yield', leaderPid: leasePid, injected: 0 };
|
||||
@@ -1425,13 +1322,18 @@ export function createWindowBridgeController(options) {
|
||||
aliveCount: lastBridgeStatus.aliveCount,
|
||||
targets: lastBridgeStatus.targets,
|
||||
argvUpdatedThisBoot: Boolean(argvUpdatedThisBoot),
|
||||
argvConfigured: Boolean(argvConfigured),
|
||||
argvConfigured: Boolean(argvConfigured || launcherConfigured),
|
||||
launcherConfigured: Boolean(launcherConfigured || argvConfigured),
|
||||
canRelaunch: Boolean(canRelaunch),
|
||||
updatedAtMs: Date.now(),
|
||||
});
|
||||
}
|
||||
|
||||
const cdpPorts = findActiveDevToolsPorts();
|
||||
if (!cdpPorts.length) {
|
||||
if (provPending) {
|
||||
await provPending.catch(() => {});
|
||||
}
|
||||
updateBridgeStatus(enabled || hasContextWindows ? 'no_devtools_port' : 'disabled', {
|
||||
enabled,
|
||||
leasedBySelf,
|
||||
@@ -1443,6 +1345,9 @@ export function createWindowBridgeController(options) {
|
||||
|
||||
const { reachableCount, targets } = await collectAllMainWindowTargets(cdpPorts);
|
||||
if (reachableCount === 0) {
|
||||
if (provPending) {
|
||||
await provPending.catch(() => {});
|
||||
}
|
||||
updateBridgeStatus(enabled || hasContextWindows ? 'cdp_unreachable' : 'disabled', {
|
||||
enabled,
|
||||
leasedBySelf,
|
||||
@@ -1896,6 +1801,20 @@ export function createWindowBridgeController(options) {
|
||||
if (!enabled) {
|
||||
hadInjectedTargets = true;
|
||||
hadInjectedChatFrames = true;
|
||||
const cur = getSettingsFn() || {};
|
||||
const hasCtx = Object.keys(cur.modelContextWindows || {}).length > 0;
|
||||
if (!hasCtx && autoConfigureIdeArgv) {
|
||||
launcherConfigured = false;
|
||||
void ensureDesktopLaunchEntriesConfigured({
|
||||
enabled: false,
|
||||
env,
|
||||
platform,
|
||||
homeDir,
|
||||
execFileFn: launcherExecFileFn,
|
||||
fsOps: launcherFsOps,
|
||||
allowInTest: allowDesktopLauncherInTest,
|
||||
}).catch(() => {});
|
||||
}
|
||||
} else {
|
||||
ideArgvProvisioned = false;
|
||||
hadInjectedChatFrames = true;
|
||||
@@ -1928,6 +1847,8 @@ export function getDefaultWindowBridgeStatus() {
|
||||
targets: 0,
|
||||
argvUpdatedThisBoot: false,
|
||||
argvConfigured: false,
|
||||
launcherConfigured: false,
|
||||
canRelaunch: false,
|
||||
updatedAtMs: 0,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user