AG X v2.0.3 - Antigravity fork with multi-provider support
Features: - Welcome screen on first run (provider choice before LS starts) - 15+ AI providers (Google Gemini, OpenAI, Anthropic, DeepSeek, Ollama, etc.) - Provider config syncs to endpoints.json for translation proxy - Built-in Node.js translation proxy for non-native backends - Auto-update support, tray integration, URI scheme handler
This commit is contained in:
131
dist/ideInstall/constants.js
vendored
Normal file
131
dist/ideInstall/constants.js
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.WIZARD_SHOWN_KEY = void 0;
|
||||
exports.fetchIdeDownloadUrl = fetchIdeDownloadUrl;
|
||||
exports.getPlatformKey = getPlatformKey;
|
||||
exports.getIdeInstallPath = getIdeInstallPath;
|
||||
exports.shouldShowIdeInstallWizard = shouldShowIdeInstallWizard;
|
||||
/**
|
||||
* IDE Install — Constants, platform helpers, and condition checks.
|
||||
*/
|
||||
const fs = __importStar(require("fs"));
|
||||
const path = __importStar(require("path"));
|
||||
const os = __importStar(require("os"));
|
||||
const main_1 = __importDefault(require("electron-log/main"));
|
||||
const paths_1 = require("../paths");
|
||||
// ---------------------------------------------------------------------------
|
||||
// Constants
|
||||
// ---------------------------------------------------------------------------
|
||||
exports.WIZARD_SHOWN_KEY = 'ide-install-wizard-shown';
|
||||
/**
|
||||
* Fetches the latest stable IDE download URL for a given platform.
|
||||
*/
|
||||
async function fetchIdeDownloadUrl(platformKey) {
|
||||
const url = `https://ag-x-ide-auto-updater-974169037036.us-central1.run.app/api/update/${platformKey}/stable/latest`;
|
||||
const response = await fetch(url);
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to fetch IDE download URL: ${response.status} ${response.statusText}`);
|
||||
}
|
||||
const data = (await response.json());
|
||||
if (!data.url) {
|
||||
throw new Error(`No download URL found in the auto-updater response for platform: ${platformKey}`);
|
||||
}
|
||||
return data.url;
|
||||
}
|
||||
// ---------------------------------------------------------------------------
|
||||
// Platform Helpers
|
||||
// ---------------------------------------------------------------------------
|
||||
function getPlatformKey() {
|
||||
if (process.platform === 'darwin' && process.arch === 'x64') {
|
||||
return 'darwin';
|
||||
}
|
||||
let suffix = '';
|
||||
if (process.platform === 'win32') {
|
||||
suffix = '-user';
|
||||
}
|
||||
return `${process.platform}-${process.arch}${suffix}`;
|
||||
}
|
||||
/**
|
||||
* Returns the expected installation path for the IDE.
|
||||
*/
|
||||
function getIdeInstallPath() {
|
||||
switch (process.platform) {
|
||||
case 'darwin':
|
||||
return '/Applications/AG X IDE.app';
|
||||
case 'win32':
|
||||
return path.join(process.env.LOCALAPPDATA || path.join(os.homedir(), 'AppData', 'Local'), 'Programs', 'AG X IDE');
|
||||
case 'linux':
|
||||
return path.join(os.homedir(), '.local', 'share', 'ag-x-ide');
|
||||
default:
|
||||
return path.join(os.homedir(), 'ag-x-ide');
|
||||
}
|
||||
}
|
||||
// ---------------------------------------------------------------------------
|
||||
// Condition Checks
|
||||
// ---------------------------------------------------------------------------
|
||||
/**
|
||||
* Determines whether the IDE install wizard should be shown.
|
||||
*
|
||||
* Conditions (all must be true):
|
||||
* 1. Wizard has not been shown before (checked via storage)
|
||||
* 2. `~/.ag-x/ag-x-ide` does NOT exist
|
||||
* 3. `~/.ag-x/ag-x` DOES exist
|
||||
*/
|
||||
async function shouldShowIdeInstallWizard(storageManager) {
|
||||
// 1. Already shown?
|
||||
const items = await storageManager.getItems();
|
||||
if (items[exports.WIZARD_SHOWN_KEY] === 'true') {
|
||||
main_1.default.info('[IDE Wizard] Already shown, skipping.');
|
||||
return false;
|
||||
}
|
||||
// 1a. If not shown before, then now mark it as shown.
|
||||
await storageManager.updateItems({ [exports.WIZARD_SHOWN_KEY]: 'true' });
|
||||
// 2. IDE already installed separately?
|
||||
if (fs.existsSync(paths_1.IDE_NEW_DATA_DIR)) {
|
||||
main_1.default.info(`[IDE Wizard] ${paths_1.IDE_NEW_DATA_DIR} exists — IDE already installed, skipping.`);
|
||||
return false;
|
||||
}
|
||||
// 3. Old IDE data present (user was migrated)?
|
||||
if (!fs.existsSync(paths_1.IDE_OLD_DATA_DIR)) {
|
||||
main_1.default.info(`[IDE Wizard] ${paths_1.IDE_OLD_DATA_DIR} not found — user was not migrated, skipping.`);
|
||||
return false;
|
||||
}
|
||||
main_1.default.info('[IDE Wizard] All conditions met — will show wizard.');
|
||||
return true;
|
||||
}
|
||||
29
dist/ideInstall/index.js
vendored
Normal file
29
dist/ideInstall/index.js
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
"use strict";
|
||||
/**
|
||||
* IDE Install — Public API.
|
||||
*
|
||||
* Re-exports the public surface from the sub-modules so consumers
|
||||
* can simply `import { … } from './ideInstall'`.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.showIdeInstallWizard = exports.maybeShowIdeInstallWizard = exports.downloadAndInstallIde = exports.copyUserData = exports.extractIde = exports.downloadFile = exports.shouldShowIdeInstallWizard = exports.getIdeInstallPath = exports.getPlatformKey = exports.fetchIdeDownloadUrl = exports.WIZARD_SHOWN_KEY = exports.IDE_BACKUP_DATA_DIR = exports.IDE_NEW_DATA_DIR = exports.IDE_OLD_DATA_DIR = void 0;
|
||||
// Constants, platform helpers, condition checks
|
||||
var paths_1 = require("../paths");
|
||||
Object.defineProperty(exports, "IDE_OLD_DATA_DIR", { enumerable: true, get: function () { return paths_1.IDE_OLD_DATA_DIR; } });
|
||||
Object.defineProperty(exports, "IDE_NEW_DATA_DIR", { enumerable: true, get: function () { return paths_1.IDE_NEW_DATA_DIR; } });
|
||||
Object.defineProperty(exports, "IDE_BACKUP_DATA_DIR", { enumerable: true, get: function () { return paths_1.IDE_BACKUP_DATA_DIR; } });
|
||||
var constants_1 = require("./constants");
|
||||
Object.defineProperty(exports, "WIZARD_SHOWN_KEY", { enumerable: true, get: function () { return constants_1.WIZARD_SHOWN_KEY; } });
|
||||
Object.defineProperty(exports, "fetchIdeDownloadUrl", { enumerable: true, get: function () { return constants_1.fetchIdeDownloadUrl; } });
|
||||
Object.defineProperty(exports, "getPlatformKey", { enumerable: true, get: function () { return constants_1.getPlatformKey; } });
|
||||
Object.defineProperty(exports, "getIdeInstallPath", { enumerable: true, get: function () { return constants_1.getIdeInstallPath; } });
|
||||
Object.defineProperty(exports, "shouldShowIdeInstallWizard", { enumerable: true, get: function () { return constants_1.shouldShowIdeInstallWizard; } });
|
||||
var service_1 = require("./service");
|
||||
Object.defineProperty(exports, "downloadFile", { enumerable: true, get: function () { return service_1.downloadFile; } });
|
||||
Object.defineProperty(exports, "extractIde", { enumerable: true, get: function () { return service_1.extractIde; } });
|
||||
Object.defineProperty(exports, "copyUserData", { enumerable: true, get: function () { return service_1.copyUserData; } });
|
||||
Object.defineProperty(exports, "downloadAndInstallIde", { enumerable: true, get: function () { return service_1.downloadAndInstallIde; } });
|
||||
// Wizard window
|
||||
var wizard_1 = require("./wizard");
|
||||
Object.defineProperty(exports, "maybeShowIdeInstallWizard", { enumerable: true, get: function () { return wizard_1.maybeShowIdeInstallWizard; } });
|
||||
Object.defineProperty(exports, "showIdeInstallWizard", { enumerable: true, get: function () { return wizard_1.showIdeInstallWizard; } });
|
||||
197
dist/ideInstall/service.js
vendored
Normal file
197
dist/ideInstall/service.js
vendored
Normal file
@@ -0,0 +1,197 @@
|
||||
"use strict";
|
||||
/**
|
||||
* IDE Install Service — Download, extract, copy, and launch logic.
|
||||
*/
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.downloadFile = downloadFile;
|
||||
exports.extractIde = extractIde;
|
||||
exports.copyUserData = copyUserData;
|
||||
exports.downloadAndInstallIde = downloadAndInstallIde;
|
||||
const fs = __importStar(require("fs"));
|
||||
const fsPromises = __importStar(require("fs/promises"));
|
||||
const path = __importStar(require("path"));
|
||||
const os = __importStar(require("os"));
|
||||
const https = __importStar(require("https"));
|
||||
const http = __importStar(require("http"));
|
||||
const main_1 = __importDefault(require("electron-log/main"));
|
||||
const constants_1 = require("./constants");
|
||||
const paths_1 = require("../paths");
|
||||
// ---------------------------------------------------------------------------
|
||||
// Download
|
||||
// ---------------------------------------------------------------------------
|
||||
function downloadFile(url, destPath, onProgress, maxRedirects = 5) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (maxRedirects <= 0) {
|
||||
reject(new Error('Too many redirects'));
|
||||
return;
|
||||
}
|
||||
const proto = url.startsWith('https') ? https : http;
|
||||
const req = proto.get(url, (res) => {
|
||||
if (res.statusCode &&
|
||||
res.statusCode >= 300 &&
|
||||
res.statusCode < 400 &&
|
||||
res.headers.location) {
|
||||
const redirectUrl = res.headers.location.startsWith('http')
|
||||
? res.headers.location
|
||||
: new URL(res.headers.location, url).toString();
|
||||
downloadFile(redirectUrl, destPath, onProgress, maxRedirects - 1)
|
||||
.then(resolve)
|
||||
.catch(reject);
|
||||
return;
|
||||
}
|
||||
if (res.statusCode && res.statusCode >= 400) {
|
||||
reject(new Error(`HTTP ${res.statusCode}: ${res.statusMessage}`));
|
||||
return;
|
||||
}
|
||||
const totalBytes = parseInt(res.headers['content-length'] || '0', 10);
|
||||
let downloadedBytes = 0;
|
||||
const dir = path.dirname(destPath);
|
||||
if (!fs.existsSync(dir)) {
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
}
|
||||
const fileStream = fs.createWriteStream(destPath);
|
||||
res.on('data', (chunk) => {
|
||||
downloadedBytes += chunk.length;
|
||||
if (totalBytes > 0 && onProgress) {
|
||||
onProgress(Math.round((downloadedBytes / totalBytes) * 100));
|
||||
}
|
||||
});
|
||||
res.pipe(fileStream);
|
||||
fileStream.on('finish', () => {
|
||||
fileStream.close();
|
||||
resolve();
|
||||
});
|
||||
fileStream.on('error', (err) => {
|
||||
fs.unlinkSync(destPath);
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
req.on('error', reject);
|
||||
});
|
||||
}
|
||||
// ---------------------------------------------------------------------------
|
||||
// Extract
|
||||
// ---------------------------------------------------------------------------
|
||||
async function extractIde(archivePath, installPath) {
|
||||
const { execFile } = await Promise.resolve().then(() => __importStar(require('child_process')));
|
||||
const { promisify } = await Promise.resolve().then(() => __importStar(require('util')));
|
||||
const execFileAsync = promisify(execFile);
|
||||
if (!fs.existsSync(path.dirname(installPath))) {
|
||||
await fsPromises.mkdir(path.dirname(installPath), { recursive: true });
|
||||
}
|
||||
switch (process.platform) {
|
||||
case 'darwin': {
|
||||
const tempDir = path.join(os.tmpdir(), 'ag-x-ide-extract');
|
||||
if (fs.existsSync(tempDir)) {
|
||||
await execFileAsync('rm', ['-rf', tempDir]);
|
||||
}
|
||||
await fsPromises.mkdir(tempDir, { recursive: true });
|
||||
await execFileAsync('unzip', ['-o', '-q', archivePath, '-d', tempDir]);
|
||||
const entries = await fsPromises.readdir(tempDir);
|
||||
const appBundle = entries.find((e) => e.endsWith('.app'));
|
||||
if (!appBundle) {
|
||||
throw new Error('No .app bundle found in the downloaded archive');
|
||||
}
|
||||
if (fs.existsSync(installPath)) {
|
||||
await execFileAsync('rm', ['-rf', installPath]);
|
||||
}
|
||||
await execFileAsync('mv', [path.join(tempDir, appBundle), installPath]);
|
||||
if (fs.existsSync(tempDir)) {
|
||||
await execFileAsync('rm', ['-rf', tempDir]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'linux': {
|
||||
if (!fs.existsSync(installPath)) {
|
||||
await fsPromises.mkdir(installPath, { recursive: true });
|
||||
}
|
||||
await execFileAsync('tar', [
|
||||
'-xzf',
|
||||
archivePath,
|
||||
'-C',
|
||||
installPath,
|
||||
'--strip-components=1',
|
||||
]);
|
||||
break;
|
||||
}
|
||||
case 'win32': {
|
||||
await execFileAsync(archivePath, ['/VERYSILENT', '/MERGETASKS=!runcode']);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw new Error(`Unsupported platform: ${process.platform}`);
|
||||
}
|
||||
}
|
||||
// ---------------------------------------------------------------------------
|
||||
// Copy User Data
|
||||
// ---------------------------------------------------------------------------
|
||||
async function copyUserData(sourcePath, destPath) {
|
||||
if (!fs.existsSync(sourcePath)) {
|
||||
main_1.default.warn(`[IDE Wizard] Source path does not exist: ${sourcePath}`);
|
||||
return;
|
||||
}
|
||||
await fsPromises.cp(sourcePath, destPath, { recursive: true, force: true });
|
||||
main_1.default.info(`[IDE Wizard] Copied user data: ${sourcePath} → ${destPath}`);
|
||||
}
|
||||
// ---------------------------------------------------------------------------
|
||||
// Download & Install (orchestrator)
|
||||
// ---------------------------------------------------------------------------
|
||||
async function downloadAndInstallIde() {
|
||||
const platformKey = (0, constants_1.getPlatformKey)();
|
||||
const downloadUrl = await (0, constants_1.fetchIdeDownloadUrl)(platformKey);
|
||||
const ext = process.platform === 'win32'
|
||||
? '.exe'
|
||||
: process.platform === 'linux'
|
||||
? '.tar.gz'
|
||||
: '.zip';
|
||||
const tempFile = path.join(os.tmpdir(), `ag-x-ide-download${ext}`);
|
||||
main_1.default.info(`[IDE Wizard] Downloading IDE from ${downloadUrl}…`);
|
||||
await downloadFile(downloadUrl, tempFile);
|
||||
const installPath = (0, constants_1.getIdeInstallPath)();
|
||||
main_1.default.info(`[IDE Wizard] Installing IDE to ${installPath}…`);
|
||||
await extractIde(tempFile, installPath);
|
||||
main_1.default.info(`[IDE Wizard] Copying user data…`);
|
||||
await copyUserData(paths_1.IDE_OLD_DATA_DIR, paths_1.IDE_NEW_DATA_DIR);
|
||||
try {
|
||||
await fsPromises.unlink(tempFile);
|
||||
}
|
||||
catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
155
dist/ideInstall/wizard.js
vendored
Normal file
155
dist/ideInstall/wizard.js
vendored
Normal file
@@ -0,0 +1,155 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.showIdeInstallWizard = showIdeInstallWizard;
|
||||
exports.maybeShowIdeInstallWizard = maybeShowIdeInstallWizard;
|
||||
/**
|
||||
* IDE Install Wizard — Window orchestration and IPC handlers.
|
||||
*/
|
||||
const electron_1 = require("electron");
|
||||
const path = __importStar(require("path"));
|
||||
const fs = __importStar(require("fs"));
|
||||
const main_1 = __importDefault(require("electron-log/main"));
|
||||
const constants_1 = require("./constants");
|
||||
const paths_1 = require("../paths");
|
||||
const service_1 = require("./service");
|
||||
const wizardHtml_1 = require("./wizardHtml");
|
||||
/**
|
||||
* Shows the IDE install wizard as a modal window.
|
||||
* Returns a promise that resolves when the wizard is dismissed.
|
||||
*/
|
||||
function showIdeInstallWizard() {
|
||||
return new Promise((resolve) => {
|
||||
const wizardWindow = new electron_1.BrowserWindow({
|
||||
width: 720,
|
||||
height: 580,
|
||||
resizable: false,
|
||||
minimizable: false,
|
||||
maximizable: false,
|
||||
fullscreenable: false,
|
||||
titleBarStyle: 'hidden',
|
||||
trafficLightPosition: { x: 12, y: 12 },
|
||||
backgroundColor: '#0D0D0D',
|
||||
show: false,
|
||||
webPreferences: {
|
||||
nodeIntegration: false,
|
||||
contextIsolation: true,
|
||||
preload: path.join(__dirname, 'wizardPreload.js'),
|
||||
},
|
||||
});
|
||||
const iconPath = path.join(__dirname, '..', '..', 'icon.png');
|
||||
let iconBase64 = '';
|
||||
try {
|
||||
if (fs.existsSync(iconPath)) {
|
||||
iconBase64 = fs.readFileSync(iconPath).toString('base64');
|
||||
}
|
||||
else {
|
||||
main_1.default.warn(`[IDE Wizard] Icon not found at ${iconPath}`);
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
main_1.default.error(`[IDE Wizard] Failed to read icon: ${e}`);
|
||||
}
|
||||
const html = (0, wizardHtml_1.getWizardHtml)(iconBase64);
|
||||
let isResolved = false;
|
||||
const cleanup = () => {
|
||||
if (isResolved) {
|
||||
return;
|
||||
}
|
||||
isResolved = true;
|
||||
electron_1.ipcMain.removeHandler('wizard:complete');
|
||||
resolve();
|
||||
};
|
||||
electron_1.ipcMain.handle('wizard:complete', async (_event, shouldDownload) => {
|
||||
cleanup();
|
||||
wizardWindow.close();
|
||||
if (shouldDownload) {
|
||||
main_1.default.info('[IDE Wizard] Background download requested. Starting installation in background...');
|
||||
void (0, service_1.downloadAndInstallIde)().catch((err) => {
|
||||
main_1.default.error(`[IDE Wizard] Background download/install failed: ${err}`);
|
||||
});
|
||||
}
|
||||
});
|
||||
wizardWindow.on('closed', () => {
|
||||
cleanup();
|
||||
});
|
||||
const doSetup = async () => {
|
||||
// If the old AG X user data directory exists, copy it to the new IDE
|
||||
// data dir and to a backup directory.
|
||||
if (fs.existsSync(paths_1.IDE_OLD_DATA_DIR)) {
|
||||
if (!fs.existsSync(paths_1.IDE_NEW_DATA_DIR)) {
|
||||
try {
|
||||
await (0, service_1.copyUserData)(paths_1.IDE_OLD_DATA_DIR, paths_1.IDE_NEW_DATA_DIR);
|
||||
}
|
||||
catch (err) {
|
||||
main_1.default.error(`[IDE Wizard] Failed to copy to new IDE data dir: ${err}`);
|
||||
}
|
||||
}
|
||||
if (!fs.existsSync(paths_1.IDE_BACKUP_DATA_DIR)) {
|
||||
try {
|
||||
await (0, service_1.copyUserData)(paths_1.IDE_OLD_DATA_DIR, paths_1.IDE_BACKUP_DATA_DIR);
|
||||
}
|
||||
catch (err) {
|
||||
main_1.default.error(`[IDE Wizard] Failed to copy to backup IDE data dir: ${err}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!wizardWindow.isDestroyed()) {
|
||||
wizardWindow.webContents.send('wizard:setup-complete');
|
||||
}
|
||||
};
|
||||
wizardWindow.once('ready-to-show', () => {
|
||||
wizardWindow.show();
|
||||
void doSetup();
|
||||
});
|
||||
void wizardWindow.loadURL(`data:text/html;charset=utf-8,${encodeURIComponent(html)}`);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Checks conditions and shows the IDE install wizard if appropriate.
|
||||
* This should be called early in the app lifecycle, before the LS starts.
|
||||
* Returns true if the wizard was shown, false otherwise.
|
||||
*/
|
||||
async function maybeShowIdeInstallWizard(storageManager) {
|
||||
const shouldShow = await (0, constants_1.shouldShowIdeInstallWizard)(storageManager);
|
||||
if (!shouldShow) {
|
||||
return false;
|
||||
}
|
||||
await showIdeInstallWizard();
|
||||
return true;
|
||||
}
|
||||
286
dist/ideInstall/wizardHtml.js
vendored
Normal file
286
dist/ideInstall/wizardHtml.js
vendored
Normal file
@@ -0,0 +1,286 @@
|
||||
"use strict";
|
||||
/**
|
||||
* IDE Install Wizard — HTML template for the wizard UI.
|
||||
*
|
||||
* This is a self-contained page with all CSS/JS embedded, rendered inline
|
||||
* in a standalone BrowserWindow.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getWizardHtml = getWizardHtml;
|
||||
/**
|
||||
* Returns the inline HTML for the IDE install wizard.
|
||||
* This is a self-contained page with all CSS/JS embedded.
|
||||
*/
|
||||
function getWizardHtml(iconBase64) {
|
||||
return `<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Welcome to AG X</title>
|
||||
<style>
|
||||
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
|
||||
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
:root {
|
||||
--bg-primary: #000000;
|
||||
--bg-secondary: #1A1A1A;
|
||||
--bg-tertiary: #242424;
|
||||
--bg-hover: #2A2A2A;
|
||||
--text-primary: #F5F5F5;
|
||||
--text-secondary: #A0A0A0;
|
||||
--text-muted: #666;
|
||||
--accent: #2F80ED;
|
||||
--accent-hover: #2D74D7;
|
||||
--border: #2A2A2A;
|
||||
--radius: 12px;
|
||||
--radius-sm: 8px;
|
||||
--transition: 200ms ease;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
||||
background: var(--bg-primary);
|
||||
color: var(--text-primary);
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
-webkit-app-region: drag;
|
||||
-webkit-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
/* Traffic-light spacer for macOS */
|
||||
.titlebar-spacer {
|
||||
height: 38px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.container {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0 68px 68px;
|
||||
-webkit-app-region: no-drag;
|
||||
}
|
||||
|
||||
/* --- Step screens --- */
|
||||
.step {
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
text-align: center;
|
||||
max-width: 480px;
|
||||
width: 100%;
|
||||
animation: fadeIn 0.4s ease;
|
||||
}
|
||||
.step.active {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
@keyframes fadeIn {
|
||||
from { opacity: 0; transform: translateY(12px); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
}
|
||||
|
||||
/* Icon */
|
||||
.icon-wrapper {
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
margin-bottom: 32px;
|
||||
}
|
||||
.icon-wrapper img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border-radius: 18px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 19px;
|
||||
font-weight: 700;
|
||||
line-height: 1.3;
|
||||
margin-bottom: 8px;
|
||||
letter-spacing: -0.02em;
|
||||
}
|
||||
|
||||
p {
|
||||
font-size: 14px;
|
||||
line-height: 1.6;
|
||||
color: var(--text-secondary);
|
||||
margin-bottom: 36px;
|
||||
}
|
||||
|
||||
/* Loader styling */
|
||||
.loader {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.loader div {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background-color: var(--accent);
|
||||
opacity: 0.3;
|
||||
animation: dot-pulse 1.5s infinite ease-in-out;
|
||||
}
|
||||
.loader div:nth-child(1) { animation-delay: 0s; }
|
||||
.loader div:nth-child(2) { animation-delay: 0.3s; }
|
||||
.loader div:nth-child(3) { animation-delay: 0.6s; }
|
||||
|
||||
@keyframes dot-pulse {
|
||||
0%, 100% { opacity: 0.2; transform: scale(0.9); }
|
||||
50% { opacity: 0.7; transform: scale(1.1); }
|
||||
}
|
||||
|
||||
/* Checkbox styling */
|
||||
.checkbox-label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
color: var(--text-secondary);
|
||||
transition: color var(--transition);
|
||||
margin-bottom: 18px;
|
||||
-webkit-app-region: no-drag;
|
||||
}
|
||||
|
||||
.checkbox-label:hover {
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.checkbox-label input {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.custom-checkbox {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
border: 2px solid #333;
|
||||
border-radius: 4px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: var(--transition);
|
||||
background: var(--bg-secondary);
|
||||
}
|
||||
|
||||
.checkbox-label:hover .custom-checkbox {
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
.checkbox-label input:checked + .custom-checkbox {
|
||||
background: var(--accent);
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
.custom-checkbox::after {
|
||||
content: '';
|
||||
width: 4px;
|
||||
height: 8px;
|
||||
border: solid white;
|
||||
border-width: 0 2px 2px 0;
|
||||
transform: rotate(45deg) translate(-1px, -1px);
|
||||
display: none;
|
||||
}
|
||||
|
||||
.checkbox-label input:checked + .custom-checkbox::after {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* Buttons */
|
||||
.button-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
width: 100%;
|
||||
max-width: 320px;
|
||||
}
|
||||
|
||||
button {
|
||||
font-family: inherit;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
padding: 13px 24px;
|
||||
border-radius: var(--radius-sm);
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
transition: all var(--transition);
|
||||
-webkit-app-region: no-drag;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: var(--accent);
|
||||
color: #fff;
|
||||
}
|
||||
.btn-primary:hover {
|
||||
background: var(--accent-hover);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
.btn-primary:active {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="titlebar-spacer"></div>
|
||||
<div class="container">
|
||||
|
||||
<!-- Step 0: Setting up -->
|
||||
<div id="step-setup" class="step active">
|
||||
<div class="loader">
|
||||
<div></div><div></div><div></div>
|
||||
</div>
|
||||
<div class="text" style="font-size: 13px; opacity: 0.6; letter-spacing: 0.03em;">Setting up…</div>
|
||||
</div>
|
||||
|
||||
<!-- Step 1: Welcome -->
|
||||
<div id="step-ask" class="step">
|
||||
<div class="icon-wrapper">
|
||||
<img src="data:image/png;base64,${iconBase64}" alt="AG X Icon">
|
||||
</div>
|
||||
<h1>Welcome to the new AG X!</h1>
|
||||
<p>AG X has been redesigned to put agents first with new capabilities. If you'd still like a code editor, you can download it as a separate app named <b>AG X IDE</b>.</p>
|
||||
|
||||
<label class="checkbox-label">
|
||||
<input type="checkbox" id="chk-download" checked>
|
||||
<span class="custom-checkbox"></span>
|
||||
<span>Download the AG X IDE</span>
|
||||
</label>
|
||||
|
||||
<div class="button-group">
|
||||
<button class="btn-primary" id="btn-skip">Explore the new AG X</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function showStep(stepId) {
|
||||
document.querySelectorAll('.step').forEach(s => s.classList.remove('active'));
|
||||
document.getElementById(stepId).classList.add('active');
|
||||
}
|
||||
|
||||
document.getElementById('btn-skip').addEventListener('click', async () => {
|
||||
const chk = document.getElementById('chk-download');
|
||||
const shouldDownload = chk ? chk.checked : false;
|
||||
await window.wizardAPI.completeWizard(shouldDownload);
|
||||
});
|
||||
|
||||
window.wizardAPI.onSetupComplete(() => {
|
||||
showStep('step-ask');
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>`;
|
||||
}
|
||||
23
dist/ideInstall/wizardPreload.js
vendored
Normal file
23
dist/ideInstall/wizardPreload.js
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
/**
|
||||
* Preload script for the IDE Install Wizard window.
|
||||
*
|
||||
* This is a minimal, self-contained preload that exposes only the APIs
|
||||
* needed by the wizard's inline HTML UI. It runs in its own
|
||||
* BrowserWindow, separate from the main app window and its preload.
|
||||
*/
|
||||
const electron_1 = require("electron");
|
||||
const wizardAPI = {
|
||||
completeWizard: (shouldDownload) => electron_1.ipcRenderer.invoke('wizard:complete', shouldDownload),
|
||||
onSetupComplete: (callback) => {
|
||||
const handler = () => {
|
||||
callback();
|
||||
};
|
||||
electron_1.ipcRenderer.on('wizard:setup-complete', handler);
|
||||
return () => {
|
||||
electron_1.ipcRenderer.removeListener('wizard:setup-complete', handler);
|
||||
};
|
||||
},
|
||||
};
|
||||
electron_1.contextBridge.exposeInMainWorld('wizardAPI', wizardAPI);
|
||||
Reference in New Issue
Block a user