import { Preferences } from '@capacitor/preferences'; const BACKEND_BASE_URL = window.BACKEND_BASE_URL || 'https://api.example.com'; export { Preferences }; export async function syncApp(appId) { if (!appId || appId.trim() === '') { throw new Error('appId is required'); } const { value } = await Preferences.get({ key: `app_${appId}` }); if (!value) { throw new Error(`App not found: ${appId}`); } const appData = JSON.parse(value); const response = await fetch(`${BACKEND_BASE_URL}/desktop/apps/sync`, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify(appData), }); if (!response.ok) { throw new Error(`Sync failed: ${response.status}`); } return response.json(); } export async function runOpencodeTask(appId, taskName, args = []) { if (!appId || appId.trim() === '') { throw new Error('appId is required'); } if (!taskName || taskName.trim() === '') { throw new Error('taskName is required'); } throw new Error('OpenCode execution is not supported on mobile devices. Please use the desktop app for this feature.'); }