neoagent 2.3.1-beta.6 → 2.3.1-beta.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +45 -0
- package/docs/capabilities.md +2 -2
- package/docs/configuration.md +6 -5
- package/docs/hardware.md +1 -1
- package/docs/integrations.md +2 -3
- package/flutter_app/.metadata +42 -0
- package/flutter_app/README.md +21 -0
- package/flutter_app/analysis_options.yaml +32 -0
- package/flutter_app/android/app/build.gradle.kts +111 -0
- package/flutter_app/android/app/src/debug/AndroidManifest.xml +7 -0
- package/flutter_app/android/app/src/main/AndroidManifest.xml +171 -0
- package/flutter_app/android/app/src/main/kotlin/com/neoagent/flutter_app/MainActivity.kt +804 -0
- package/flutter_app/android/app/src/main/kotlin/com/neoagent/flutter_app/auto/NeoAgentCarAppService.kt +114 -0
- package/flutter_app/android/app/src/main/kotlin/com/neoagent/flutter_app/health/HealthConnectGateway.kt +280 -0
- package/flutter_app/android/app/src/main/kotlin/com/neoagent/flutter_app/health/HealthSyncNotifications.kt +113 -0
- package/flutter_app/android/app/src/main/kotlin/com/neoagent/flutter_app/health/HealthSyncPayload.kt +57 -0
- package/flutter_app/android/app/src/main/kotlin/com/neoagent/flutter_app/health/HealthSyncScheduler.kt +78 -0
- package/flutter_app/android/app/src/main/kotlin/com/neoagent/flutter_app/health/HealthSyncWorker.kt +253 -0
- package/flutter_app/android/app/src/main/kotlin/com/neoagent/flutter_app/health/PermissionsRationaleActivity.kt +46 -0
- package/flutter_app/android/app/src/main/kotlin/com/neoagent/flutter_app/recording/RecordingBootReceiver.kt +21 -0
- package/flutter_app/android/app/src/main/kotlin/com/neoagent/flutter_app/recording/RecordingForegroundService.kt +586 -0
- package/flutter_app/android/app/src/main/kotlin/com/neoagent/flutter_app/recording/RecordingStateStore.kt +78 -0
- package/flutter_app/android/app/src/main/kotlin/com/neoagent/flutter_app/recording/RecordingUploadClient.kt +104 -0
- package/flutter_app/android/app/src/main/kotlin/com/neoagent/flutter_app/telecom/NeoAgentConnection.kt +118 -0
- package/flutter_app/android/app/src/main/kotlin/com/neoagent/flutter_app/telecom/NeoAgentConnectionService.kt +86 -0
- package/flutter_app/android/app/src/main/kotlin/com/neoagent/flutter_app/widgets/AiHomeWidgetProvider.kt +457 -0
- package/flutter_app/android/app/src/main/kotlin/com/neoagent/flutter_app/widgets/AiWidgetStore.kt +194 -0
- package/flutter_app/android/app/src/main/kotlin/com/neoagent/flutter_app/widgets/VoiceLaunchWidgetProvider.kt +67 -0
- package/flutter_app/android/app/src/main/kotlin/com/neoagent/flutter_app/widgets/WidgetConfigActivity.kt +228 -0
- package/flutter_app/android/app/src/main/kotlin/com/neoagent/flutter_app/widgets/WidgetSyncScheduler.kt +72 -0
- package/flutter_app/android/app/src/main/kotlin/com/neoagent/flutter_app/widgets/WidgetSyncWorker.kt +186 -0
- package/flutter_app/android/app/src/main/kotlin/com/neoagent/flutter_app/widgets/WidgetTaskRunWorker.kt +210 -0
- package/flutter_app/android/app/src/main/res/drawable/launch_background.xml +12 -0
- package/flutter_app/android/app/src/main/res/drawable/neoagent_ai_widget_bg.xml +11 -0
- package/flutter_app/android/app/src/main/res/drawable/neoagent_ai_widget_task_bg.xml +8 -0
- package/flutter_app/android/app/src/main/res/drawable-v21/launch_background.xml +12 -0
- package/flutter_app/android/app/src/main/res/layout/neoagent_ai_widget.xml +138 -0
- package/flutter_app/android/app/src/main/res/layout/neoagent_ai_widget_task_row.xml +52 -0
- package/flutter_app/android/app/src/main/res/layout/neoagent_voice_widget.xml +49 -0
- package/flutter_app/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/flutter_app/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/flutter_app/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/flutter_app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/flutter_app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/flutter_app/android/app/src/main/res/values/arrays.xml +8 -0
- package/flutter_app/android/app/src/main/res/values/strings.xml +12 -0
- package/flutter_app/android/app/src/main/res/values/styles.xml +18 -0
- package/flutter_app/android/app/src/main/res/values-night/styles.xml +18 -0
- package/flutter_app/android/app/src/main/res/xml/automotive_app_desc.xml +4 -0
- package/flutter_app/android/app/src/main/res/xml/file_paths.xml +6 -0
- package/flutter_app/android/app/src/main/res/xml/neoagent_ai_widget_info.xml +12 -0
- package/flutter_app/android/app/src/main/res/xml/neoagent_voice_widget_info.xml +12 -0
- package/flutter_app/android/app/src/profile/AndroidManifest.xml +7 -0
- package/flutter_app/android/build.gradle.kts +24 -0
- package/flutter_app/android/ci-release.keystore +0 -0
- package/flutter_app/android/gradle/wrapper/gradle-wrapper.properties +5 -0
- package/flutter_app/android/gradle.properties +3 -0
- package/flutter_app/android/key.properties +4 -0
- package/flutter_app/android/settings.gradle.kts +26 -0
- package/flutter_app/assets/branding/app_icon_1024.png +0 -0
- package/flutter_app/assets/branding/app_icon_128.png +0 -0
- package/flutter_app/assets/branding/app_icon_192.png +0 -0
- package/flutter_app/assets/branding/app_icon_256.png +0 -0
- package/flutter_app/assets/branding/app_icon_32.png +0 -0
- package/flutter_app/assets/branding/app_icon_512.png +0 -0
- package/flutter_app/assets/branding/app_icon_64.png +0 -0
- package/flutter_app/assets/branding/onboarding_intro.mp4 +0 -0
- package/flutter_app/assets/branding/tray_icon_template.png +0 -0
- package/flutter_app/lib/features/location/location_service.dart +119 -0
- package/flutter_app/lib/features/notifications/notification_interceptor.dart +97 -0
- package/flutter_app/lib/features/onboarding/onboarding_chrome.dart +569 -0
- package/flutter_app/lib/features/onboarding/onboarding_messaging_step.dart +157 -0
- package/flutter_app/lib/features/onboarding/onboarding_model_step.dart +233 -0
- package/flutter_app/lib/features/onboarding/onboarding_shell.dart +57 -0
- package/flutter_app/lib/features/onboarding/onboarding_video_step.dart +218 -0
- package/flutter_app/lib/features/onboarding/onboarding_welcome_step.dart +46 -0
- package/flutter_app/lib/main.dart +103 -0
- package/flutter_app/lib/main_account_settings.dart +1250 -0
- package/flutter_app/lib/main_admin.dart +886 -0
- package/flutter_app/lib/main_app_shell.dart +2134 -0
- package/flutter_app/lib/main_chat.dart +3316 -0
- package/flutter_app/lib/main_controller.dart +6836 -0
- package/flutter_app/lib/main_devices.dart +2396 -0
- package/flutter_app/lib/main_integrations.dart +909 -0
- package/flutter_app/lib/main_launcher.dart +959 -0
- package/flutter_app/lib/main_launcher_entry.dart +5 -0
- package/flutter_app/lib/main_models.dart +3539 -0
- package/flutter_app/lib/main_navigation.dart +188 -0
- package/flutter_app/lib/main_operations.dart +4851 -0
- package/flutter_app/lib/main_recordings.dart +920 -0
- package/flutter_app/lib/main_runtime.dart +838 -0
- package/flutter_app/lib/main_settings.dart +2040 -0
- package/flutter_app/lib/main_shared.dart +3147 -0
- package/flutter_app/lib/main_theme.dart +257 -0
- package/flutter_app/lib/main_voice_assistant.dart +957 -0
- package/flutter_app/lib/src/android_apk_drop_zone.dart +32 -0
- package/flutter_app/lib/src/android_apk_drop_zone_stub.dart +16 -0
- package/flutter_app/lib/src/android_apk_drop_zone_web.dart +348 -0
- package/flutter_app/lib/src/android_app_installer.dart +22 -0
- package/flutter_app/lib/src/android_app_installer_io.dart +122 -0
- package/flutter_app/lib/src/android_app_installer_stub.dart +21 -0
- package/flutter_app/lib/src/android_auto_bridge.dart +59 -0
- package/flutter_app/lib/src/android_launcher_bridge.dart +239 -0
- package/flutter_app/lib/src/app_launch_bridge.dart +29 -0
- package/flutter_app/lib/src/app_release_updater.dart +511 -0
- package/flutter_app/lib/src/backend_client.dart +1837 -0
- package/flutter_app/lib/src/desktop_companion.dart +2 -0
- package/flutter_app/lib/src/desktop_companion_actions.dart +586 -0
- package/flutter_app/lib/src/desktop_companion_io.dart +538 -0
- package/flutter_app/lib/src/desktop_companion_stub.dart +59 -0
- package/flutter_app/lib/src/desktop_native_bridge.dart +91 -0
- package/flutter_app/lib/src/desktop_screen_capture.dart +21 -0
- package/flutter_app/lib/src/desktop_screen_capture_io.dart +142 -0
- package/flutter_app/lib/src/desktop_screen_capture_stub.dart +12 -0
- package/flutter_app/lib/src/diagnostics_logger.dart +119 -0
- package/flutter_app/lib/src/health_bridge.dart +136 -0
- package/flutter_app/lib/src/live_voice_capture.dart +85 -0
- package/flutter_app/lib/src/messaging_access_summary.dart +46 -0
- package/flutter_app/lib/src/network/app_http_client.dart +53 -0
- package/flutter_app/lib/src/network/app_http_client_factory.dart +6 -0
- package/flutter_app/lib/src/network/app_http_client_io.dart +138 -0
- package/flutter_app/lib/src/network/app_http_client_stub.dart +3 -0
- package/flutter_app/lib/src/network/app_http_client_web.dart +94 -0
- package/flutter_app/lib/src/oauth_launcher.dart +33 -0
- package/flutter_app/lib/src/oauth_launcher_io.dart +95 -0
- package/flutter_app/lib/src/oauth_launcher_stub.dart +33 -0
- package/flutter_app/lib/src/oauth_launcher_web.dart +107 -0
- package/flutter_app/lib/src/recording_bridge.dart +232 -0
- package/flutter_app/lib/src/recording_bridge_io.dart +1019 -0
- package/flutter_app/lib/src/recording_bridge_stub.dart +120 -0
- package/flutter_app/lib/src/recording_bridge_web.dart +689 -0
- package/flutter_app/lib/src/recording_payloads.dart +86 -0
- package/flutter_app/lib/src/theme/palette.dart +81 -0
- package/flutter_app/lib/src/web_app_update_monitor.dart +17 -0
- package/flutter_app/lib/src/web_app_update_monitor_stub.dart +24 -0
- package/flutter_app/lib/src/web_app_update_monitor_web.dart +123 -0
- package/flutter_app/lib/src/widget_bridge.dart +49 -0
- package/flutter_app/linux/CMakeLists.txt +128 -0
- package/flutter_app/linux/flutter/CMakeLists.txt +88 -0
- package/flutter_app/linux/flutter/generated_plugin_registrant.cc +47 -0
- package/flutter_app/linux/flutter/generated_plugin_registrant.h +15 -0
- package/flutter_app/linux/flutter/generated_plugins.cmake +32 -0
- package/flutter_app/linux/runner/CMakeLists.txt +26 -0
- package/flutter_app/linux/runner/main.cc +6 -0
- package/flutter_app/linux/runner/my_application.cc +144 -0
- package/flutter_app/linux/runner/my_application.h +18 -0
- package/flutter_app/linux/runner/resources/app_icon.png +0 -0
- package/flutter_app/macos/Flutter/Flutter-Debug.xcconfig +2 -0
- package/flutter_app/macos/Flutter/Flutter-Release.xcconfig +2 -0
- package/flutter_app/macos/Flutter/GeneratedPluginRegistrant.swift +44 -0
- package/flutter_app/macos/Podfile +42 -0
- package/flutter_app/macos/Podfile.lock +87 -0
- package/flutter_app/macos/Runner/AppDelegate.swift +576 -0
- package/flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json +68 -0
- package/flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png +0 -0
- package/flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png +0 -0
- package/flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png +0 -0
- package/flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png +0 -0
- package/flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png +0 -0
- package/flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png +0 -0
- package/flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png +0 -0
- package/flutter_app/macos/Runner/Base.lproj/MainMenu.xib +342 -0
- package/flutter_app/macos/Runner/Configs/AppInfo.xcconfig +14 -0
- package/flutter_app/macos/Runner/Configs/Debug.xcconfig +2 -0
- package/flutter_app/macos/Runner/Configs/Release.xcconfig +2 -0
- package/flutter_app/macos/Runner/Configs/Warnings.xcconfig +13 -0
- package/flutter_app/macos/Runner/DebugProfile.entitlements +16 -0
- package/flutter_app/macos/Runner/Info.plist +36 -0
- package/flutter_app/macos/Runner/MainFlutterWindow.swift +19 -0
- package/flutter_app/macos/Runner/Release.entitlements +12 -0
- package/flutter_app/macos/Runner.xcodeproj/project.pbxproj +801 -0
- package/flutter_app/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/flutter_app/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +99 -0
- package/flutter_app/macos/Runner.xcworkspace/contents.xcworkspacedata +10 -0
- package/flutter_app/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/flutter_app/macos/RunnerTests/RunnerTests.swift +12 -0
- package/flutter_app/patch_strings.py +12 -0
- package/flutter_app/pubspec.lock +1224 -0
- package/flutter_app/pubspec.yaml +57 -0
- package/flutter_app/test/messaging_access_summary_test.dart +22 -0
- package/flutter_app/test/recording_payloads_test.dart +53 -0
- package/flutter_app/third_party/desktop_audio_capture/LICENSE +21 -0
- package/flutter_app/third_party/desktop_audio_capture/README.md +262 -0
- package/flutter_app/third_party/desktop_audio_capture/lib/audio_capture.dart +65 -0
- package/flutter_app/third_party/desktop_audio_capture/lib/config/mic_audio_config.dart +153 -0
- package/flutter_app/third_party/desktop_audio_capture/lib/config/system_adudio_config.dart +110 -0
- package/flutter_app/third_party/desktop_audio_capture/lib/mic/mic_audio_capture.dart +461 -0
- package/flutter_app/third_party/desktop_audio_capture/lib/model/audio_status.dart +91 -0
- package/flutter_app/third_party/desktop_audio_capture/lib/model/decibel_data.dart +106 -0
- package/flutter_app/third_party/desktop_audio_capture/lib/model/input_device_type.dart +219 -0
- package/flutter_app/third_party/desktop_audio_capture/lib/system/system_audio_capture.dart +336 -0
- package/flutter_app/third_party/desktop_audio_capture/linux/CMakeLists.txt +101 -0
- package/flutter_app/third_party/desktop_audio_capture/linux/audio_capture_plugin.cc +692 -0
- package/flutter_app/third_party/desktop_audio_capture/linux/include/audio_capture/audio_capture_plugin.h +35 -0
- package/flutter_app/third_party/desktop_audio_capture/linux/include/audio_capture/mic_capture_plugin.h +36 -0
- package/flutter_app/third_party/desktop_audio_capture/linux/include/desktop_audio_capture/audio_capture_plugin.h +32 -0
- package/flutter_app/third_party/desktop_audio_capture/linux/include/desktop_audio_capture/mic_capture_plugin.h +32 -0
- package/flutter_app/third_party/desktop_audio_capture/linux/mic_capture_plugin.cc +878 -0
- package/flutter_app/third_party/desktop_audio_capture/macos/Classes/AudioCapturePlugin.swift +27 -0
- package/flutter_app/third_party/desktop_audio_capture/macos/Classes/MicCapturePlugin.swift +1172 -0
- package/flutter_app/third_party/desktop_audio_capture/macos/Classes/SystemCapturePlugin.swift +655 -0
- package/flutter_app/third_party/desktop_audio_capture/macos/Resources/PrivacyInfo.xcprivacy +12 -0
- package/flutter_app/third_party/desktop_audio_capture/macos/desktop_audio_capture.podspec +30 -0
- package/flutter_app/third_party/desktop_audio_capture/pubspec.yaml +87 -0
- package/flutter_app/third_party/desktop_audio_capture/windows/CMakeLists.txt +105 -0
- package/flutter_app/third_party/desktop_audio_capture/windows/audio_capture_plugin.cpp +80 -0
- package/flutter_app/third_party/desktop_audio_capture/windows/audio_capture_plugin.h +31 -0
- package/flutter_app/third_party/desktop_audio_capture/windows/audio_capture_plugin_c_api.cpp +12 -0
- package/flutter_app/third_party/desktop_audio_capture/windows/include/audio_capture/audio_capture_plugin_c_api.h +23 -0
- package/flutter_app/third_party/desktop_audio_capture/windows/include/desktop_audio_capture/audio_capture_plugin.h +25 -0
- package/flutter_app/third_party/desktop_audio_capture/windows/mic_capture_plugin.cpp +1117 -0
- package/flutter_app/third_party/desktop_audio_capture/windows/mic_capture_plugin.h +115 -0
- package/flutter_app/third_party/desktop_audio_capture/windows/system_audio_capture_plugin.cpp +777 -0
- package/flutter_app/third_party/desktop_audio_capture/windows/system_audio_capture_plugin.h +87 -0
- package/flutter_app/third_party/flutter_secure_storage_linux/linux/CMakeLists.txt +30 -0
- package/flutter_app/third_party/flutter_secure_storage_linux/linux/flutter_secure_storage_linux_plugin.cc +215 -0
- package/flutter_app/third_party/flutter_secure_storage_linux/linux/include/flutter_secure_storage_linux/flutter_secure_storage_linux_plugin.h +27 -0
- package/flutter_app/third_party/flutter_secure_storage_linux/pubspec.yaml +20 -0
- package/flutter_app/tool/generate_desktop_branding.py +219 -0
- package/flutter_app/web/favicon.png +0 -0
- package/flutter_app/web/favicon.svg +12 -0
- package/flutter_app/web/icons/Icon-192.png +0 -0
- package/flutter_app/web/icons/Icon-512.png +0 -0
- package/flutter_app/web/icons/Icon-maskable-192.png +0 -0
- package/flutter_app/web/icons/Icon-maskable-512.png +0 -0
- package/flutter_app/web/index.html +39 -0
- package/flutter_app/web/manifest.json +35 -0
- package/flutter_app/windows/CMakeLists.txt +108 -0
- package/flutter_app/windows/flutter/CMakeLists.txt +109 -0
- package/flutter_app/windows/flutter/generated_plugin_registrant.cc +50 -0
- package/flutter_app/windows/flutter/generated_plugin_registrant.h +15 -0
- package/flutter_app/windows/flutter/generated_plugins.cmake +36 -0
- package/flutter_app/windows/runner/CMakeLists.txt +41 -0
- package/flutter_app/windows/runner/Runner.rc +121 -0
- package/flutter_app/windows/runner/flutter_window.cpp +533 -0
- package/flutter_app/windows/runner/flutter_window.h +37 -0
- package/flutter_app/windows/runner/main.cpp +53 -0
- package/flutter_app/windows/runner/resource.h +16 -0
- package/flutter_app/windows/runner/resources/app_icon.ico +0 -0
- package/flutter_app/windows/runner/runner.exe.manifest +14 -0
- package/flutter_app/windows/runner/utils.cpp +65 -0
- package/flutter_app/windows/runner/utils.h +19 -0
- package/flutter_app/windows/runner/win32_window.cpp +299 -0
- package/flutter_app/windows/runner/win32_window.h +102 -0
- package/lib/install_helpers.js +31 -0
- package/lib/manager.js +201 -6
- package/package.json +5 -3
- package/server/db/database.js +125 -1
- package/server/http/middleware.js +55 -2
- package/server/http/routes.js +1 -0
- package/server/http/static.js +41 -1
- package/server/index.js +3 -0
- package/server/public/.last_build_id +1 -1
- package/server/public/assets/AssetManifest.bin +1 -1
- package/server/public/assets/AssetManifest.bin.json +1 -1
- package/server/public/assets/NOTICES +281 -1
- package/server/public/assets/assets/branding/onboarding_intro.mp4 +0 -0
- package/server/public/assets/fonts/MaterialIcons-Regular.otf +0 -0
- package/server/public/canvaskit/wimp.wasm +0 -0
- package/server/public/flutter_bootstrap.js +2 -2
- package/server/public/main.dart.js +86314 -82363
- package/server/routes/auth.js +26 -5
- package/server/routes/integrations.js +108 -1
- package/server/routes/memory.js +11 -2
- package/server/routes/settings.js +84 -2
- package/server/routes/wearable.js +67 -0
- package/server/services/ai/engine.js +3 -2
- package/server/services/ai/models.js +30 -0
- package/server/services/ai/providers/githubCopilot.js +97 -0
- package/server/services/ai/providers/openai.js +2 -1
- package/server/services/ai/providers/openaiCodex.js +31 -0
- package/server/services/ai/settings.js +20 -0
- package/server/services/ai/toolSelector.js +54 -1
- package/server/services/ai/tools.js +88 -5
- package/server/services/desktop/screenRecorder.js +65 -9
- package/server/services/integrations/env.js +5 -0
- package/server/services/integrations/figma/provider.js +1 -0
- package/server/services/integrations/github/common.js +106 -0
- package/server/services/integrations/github/provider.js +499 -0
- package/server/services/integrations/github/repos.js +1124 -0
- package/server/services/integrations/google/provider.js +1 -0
- package/server/services/integrations/manager.js +88 -12
- package/server/services/integrations/microsoft/provider.js +1 -0
- package/server/services/integrations/oauth_provider.js +25 -8
- package/server/services/integrations/provider_config_store.js +85 -0
- package/server/services/integrations/registry.js +4 -2
- package/server/services/integrations/spotify/provider.js +1 -0
- package/server/services/integrations/trello/provider.js +842 -0
- package/server/services/manager.js +46 -1
- package/server/services/mcp/client.js +120 -23
- package/server/services/memory/manager.js +39 -2
- package/server/services/messaging/access_policy.js +10 -0
- package/server/services/messaging/manager.js +49 -0
- package/server/services/messaging/meshtastic.js +277 -0
- package/server/services/messaging/meshtastic_env.js +40 -0
- package/server/services/messaging/meshtastic_protocol.js +530 -0
- package/server/services/messaging/meshtastic_protocol.test.js +33 -0
- package/server/services/messaging/meshtastic_tcp_transport.js +25 -0
- package/server/services/tasks/runtime.js +1 -1
- package/server/services/voice/openaiClient.js +4 -1
- package/server/services/voice/openaiSpeech.js +6 -1
- package/server/services/voice/providers.js +144 -15
- package/server/services/voice/runtimeManager.js +156 -19
- package/server/services/voice/turnRunner.js +29 -9
- package/server/services/wearable/firmware_manifest.js +353 -0
- package/server/services/wearable/gateway.js +350 -0
- package/server/services/wearable/protocol.js +45 -0
- package/server/services/wearable/service.js +240 -0
- package/server/services/widgets/service.js +3 -0
- package/server/utils/local_secrets.js +56 -0
- package/server/utils/logger.js +37 -9
- package/server/services/integrations/home_assistant/provider.js +0 -350
|
@@ -0,0 +1,586 @@
|
|
|
1
|
+
import 'dart:convert';
|
|
2
|
+
import 'dart:io';
|
|
3
|
+
|
|
4
|
+
import 'package:flutter/foundation.dart';
|
|
5
|
+
import 'package:image/image.dart' as img;
|
|
6
|
+
import 'package:package_info_plus/package_info_plus.dart';
|
|
7
|
+
|
|
8
|
+
import 'desktop_native_bridge.dart';
|
|
9
|
+
import 'desktop_screen_capture.dart';
|
|
10
|
+
|
|
11
|
+
class DesktopCompanionSnapshot {
|
|
12
|
+
const DesktopCompanionSnapshot({
|
|
13
|
+
required this.screenshotBase64,
|
|
14
|
+
required this.contentType,
|
|
15
|
+
required this.width,
|
|
16
|
+
required this.height,
|
|
17
|
+
required this.displays,
|
|
18
|
+
required this.activeDisplayId,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
final String screenshotBase64;
|
|
22
|
+
final String contentType;
|
|
23
|
+
final int width;
|
|
24
|
+
final int height;
|
|
25
|
+
final List<Map<String, Object?>> displays;
|
|
26
|
+
final String activeDisplayId;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
class DesktopCompanionActions {
|
|
30
|
+
DesktopCompanionActions({required DesktopScreenCapture screenCapture})
|
|
31
|
+
: _screenCapture = screenCapture;
|
|
32
|
+
|
|
33
|
+
final DesktopScreenCapture _screenCapture;
|
|
34
|
+
final DesktopNativeBridge _nativeBridge = DesktopNativeBridge();
|
|
35
|
+
|
|
36
|
+
bool get isCaptureSupported => _screenCapture.isSupported;
|
|
37
|
+
|
|
38
|
+
Future<Map<String, Object?>> buildHello({
|
|
39
|
+
required String deviceId,
|
|
40
|
+
required String activationId,
|
|
41
|
+
required String label,
|
|
42
|
+
required bool companionEnabled,
|
|
43
|
+
required bool paused,
|
|
44
|
+
String? activeDisplayId,
|
|
45
|
+
}) async {
|
|
46
|
+
final platformStatus = await _platformStatus();
|
|
47
|
+
final capabilities = await _capabilities(platformStatus: platformStatus);
|
|
48
|
+
final snapshot = await _safeSnapshotForStatus(
|
|
49
|
+
activeDisplayId: activeDisplayId,
|
|
50
|
+
platformStatus: platformStatus,
|
|
51
|
+
);
|
|
52
|
+
final packageInfo = await PackageInfo.fromPlatform();
|
|
53
|
+
return <String, Object?>{
|
|
54
|
+
'deviceId': deviceId,
|
|
55
|
+
'activationId': activationId,
|
|
56
|
+
'label': label,
|
|
57
|
+
'hostname': _localHostname(),
|
|
58
|
+
'platform': defaultTargetPlatform.name,
|
|
59
|
+
'platformVersion': Platform.operatingSystemVersion,
|
|
60
|
+
'appVersion': packageInfo.version,
|
|
61
|
+
'companionEnabled': companionEnabled,
|
|
62
|
+
'paused': paused,
|
|
63
|
+
'permissions': _permissions(capabilities, platformStatus: platformStatus),
|
|
64
|
+
'capabilities': capabilities,
|
|
65
|
+
'displays': snapshot?.displays ?? const <Map<String, Object?>>[],
|
|
66
|
+
'activeDisplayId':
|
|
67
|
+
snapshot?.activeDisplayId ??
|
|
68
|
+
platformStatus['activeDisplayId']?.toString() ??
|
|
69
|
+
activeDisplayId ??
|
|
70
|
+
'primary',
|
|
71
|
+
'metadata': <String, Object?>{
|
|
72
|
+
'captureSupported': _screenCapture.isSupported,
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
Future<DesktopCompanionSnapshot?> captureSnapshot({
|
|
78
|
+
String? activeDisplayId,
|
|
79
|
+
}) async {
|
|
80
|
+
if (_usesNativeDesktopBridge) {
|
|
81
|
+
final frame = await _nativeBridge.captureFrame(
|
|
82
|
+
displayId: activeDisplayId,
|
|
83
|
+
);
|
|
84
|
+
final bytes = frame['bytes'];
|
|
85
|
+
if (bytes is! Uint8List || bytes.isEmpty) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
final decoded = img.decodeImage(bytes);
|
|
89
|
+
final width = (frame['width'] as num?)?.round() ?? decoded?.width ?? 0;
|
|
90
|
+
final height = (frame['height'] as num?)?.round() ?? decoded?.height ?? 0;
|
|
91
|
+
final displays = _normalizeDisplays(
|
|
92
|
+
frame['displays'],
|
|
93
|
+
fallbackDisplayId:
|
|
94
|
+
frame['displayId']?.toString() ?? activeDisplayId ?? 'primary',
|
|
95
|
+
width: width,
|
|
96
|
+
height: height,
|
|
97
|
+
);
|
|
98
|
+
return DesktopCompanionSnapshot(
|
|
99
|
+
screenshotBase64: base64Encode(bytes),
|
|
100
|
+
contentType: frame['mimeType']?.toString() ?? 'image/png',
|
|
101
|
+
width: width,
|
|
102
|
+
height: height,
|
|
103
|
+
displays: displays,
|
|
104
|
+
activeDisplayId:
|
|
105
|
+
frame['displayId']?.toString() ?? activeDisplayId ?? 'primary',
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
final capture = await _screenCapture.captureCurrentScreen();
|
|
110
|
+
if (capture == null || capture.bytes.isEmpty) return null;
|
|
111
|
+
final bytes = Uint8List.fromList(capture.bytes);
|
|
112
|
+
final decoded = img.decodeImage(bytes);
|
|
113
|
+
final width = decoded?.width ?? 0;
|
|
114
|
+
final height = decoded?.height ?? 0;
|
|
115
|
+
return DesktopCompanionSnapshot(
|
|
116
|
+
screenshotBase64: base64Encode(bytes),
|
|
117
|
+
contentType: capture.mimeType,
|
|
118
|
+
width: width,
|
|
119
|
+
height: height,
|
|
120
|
+
activeDisplayId: activeDisplayId ?? 'primary',
|
|
121
|
+
displays: <Map<String, Object?>>[
|
|
122
|
+
<String, Object?>{
|
|
123
|
+
'id': activeDisplayId ?? 'primary',
|
|
124
|
+
'label': 'Primary Display',
|
|
125
|
+
'width': width,
|
|
126
|
+
'height': height,
|
|
127
|
+
'scaleFactor': 1,
|
|
128
|
+
'primary': true,
|
|
129
|
+
},
|
|
130
|
+
],
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
Future<Map<String, Object?>> getStatus({
|
|
135
|
+
required String label,
|
|
136
|
+
required bool paused,
|
|
137
|
+
String? activeDisplayId,
|
|
138
|
+
}) async {
|
|
139
|
+
final platformStatus = await _platformStatus();
|
|
140
|
+
final capabilities = await _capabilities(platformStatus: platformStatus);
|
|
141
|
+
final snapshot = await _safeSnapshotForStatus(
|
|
142
|
+
activeDisplayId: activeDisplayId,
|
|
143
|
+
platformStatus: platformStatus,
|
|
144
|
+
);
|
|
145
|
+
return <String, Object?>{
|
|
146
|
+
'paused': paused,
|
|
147
|
+
'label': label,
|
|
148
|
+
'activeDisplayId':
|
|
149
|
+
snapshot?.activeDisplayId ??
|
|
150
|
+
platformStatus['activeDisplayId']?.toString() ??
|
|
151
|
+
activeDisplayId ??
|
|
152
|
+
'primary',
|
|
153
|
+
'displays': snapshot?.displays ?? const <Map<String, Object?>>[],
|
|
154
|
+
'permissions': _permissions(capabilities, platformStatus: platformStatus),
|
|
155
|
+
'capabilities': capabilities,
|
|
156
|
+
if (platformStatus['frontmostApp'] != null)
|
|
157
|
+
'frontmostApp': platformStatus['frontmostApp'],
|
|
158
|
+
if (platformStatus['frontmostWindowTitle'] != null)
|
|
159
|
+
'frontmostWindowTitle': platformStatus['frontmostWindowTitle'],
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
Future<Map<String, Object?>> captureFrame({String? activeDisplayId}) async {
|
|
164
|
+
final snapshot = await captureSnapshot(activeDisplayId: activeDisplayId);
|
|
165
|
+
if (snapshot == null) {
|
|
166
|
+
throw Exception('Desktop capture is not available on this platform.');
|
|
167
|
+
}
|
|
168
|
+
return <String, Object?>{
|
|
169
|
+
'screenshotBase64': snapshot.screenshotBase64,
|
|
170
|
+
'contentType': snapshot.contentType,
|
|
171
|
+
'width': snapshot.width,
|
|
172
|
+
'height': snapshot.height,
|
|
173
|
+
'displayId': snapshot.activeDisplayId,
|
|
174
|
+
'displays': snapshot.displays,
|
|
175
|
+
'capturedAt': DateTime.now().toUtc().toIso8601String(),
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
Future<Map<String, Object?>> observe({
|
|
180
|
+
bool includeTree = false,
|
|
181
|
+
String? activeDisplayId,
|
|
182
|
+
}) async {
|
|
183
|
+
final result = await captureFrame(activeDisplayId: activeDisplayId);
|
|
184
|
+
return <String, Object?>{
|
|
185
|
+
...result,
|
|
186
|
+
'tree': includeTree ? const <Map<String, Object?>>[] : null,
|
|
187
|
+
'treeSupported': false,
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
Future<Map<String, Object?>> click({
|
|
192
|
+
required int x,
|
|
193
|
+
required int y,
|
|
194
|
+
String button = 'left',
|
|
195
|
+
String? displayId,
|
|
196
|
+
}) async {
|
|
197
|
+
await _assertInputSupported('click');
|
|
198
|
+
final normalizedButton = _normalizeMouseButton(button);
|
|
199
|
+
if (_usesNativeDesktopBridge) {
|
|
200
|
+
await _nativeBridge.click(
|
|
201
|
+
x: x,
|
|
202
|
+
y: y,
|
|
203
|
+
button: normalizedButton,
|
|
204
|
+
displayId: displayId,
|
|
205
|
+
);
|
|
206
|
+
} else if (defaultTargetPlatform == TargetPlatform.linux) {
|
|
207
|
+
final buttonCode = normalizedButton == 'right'
|
|
208
|
+
? '3'
|
|
209
|
+
: (normalizedButton == 'middle' ? '2' : '1');
|
|
210
|
+
await _run(
|
|
211
|
+
_ShellCommand('xdotool', <String>[
|
|
212
|
+
'mousemove',
|
|
213
|
+
'$x',
|
|
214
|
+
'$y',
|
|
215
|
+
'click',
|
|
216
|
+
buttonCode,
|
|
217
|
+
]),
|
|
218
|
+
);
|
|
219
|
+
} else {
|
|
220
|
+
throw Exception('click is not supported on this platform.');
|
|
221
|
+
}
|
|
222
|
+
return <String, Object?>{'success': true, 'x': x, 'y': y, 'button': button};
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
Future<Map<String, Object?>> drag({
|
|
226
|
+
required int x1,
|
|
227
|
+
required int y1,
|
|
228
|
+
required int x2,
|
|
229
|
+
required int y2,
|
|
230
|
+
int durationMs = 280,
|
|
231
|
+
String? displayId,
|
|
232
|
+
}) async {
|
|
233
|
+
await _assertInputSupported('drag');
|
|
234
|
+
if (_usesNativeDesktopBridge) {
|
|
235
|
+
await _nativeBridge.drag(
|
|
236
|
+
x1: x1,
|
|
237
|
+
y1: y1,
|
|
238
|
+
x2: x2,
|
|
239
|
+
y2: y2,
|
|
240
|
+
durationMs: durationMs,
|
|
241
|
+
displayId: displayId,
|
|
242
|
+
);
|
|
243
|
+
} else if (defaultTargetPlatform == TargetPlatform.linux) {
|
|
244
|
+
await _run(_ShellCommand('xdotool', <String>['mousemove', '$x1', '$y1']));
|
|
245
|
+
await _run(_ShellCommand('xdotool', const <String>['mousedown', '1']));
|
|
246
|
+
await Future<void>.delayed(
|
|
247
|
+
Duration(milliseconds: durationMs.clamp(40, 2000)),
|
|
248
|
+
);
|
|
249
|
+
await _run(_ShellCommand('xdotool', <String>['mousemove', '$x2', '$y2']));
|
|
250
|
+
await _run(_ShellCommand('xdotool', const <String>['mouseup', '1']));
|
|
251
|
+
} else {
|
|
252
|
+
throw Exception('drag is not supported on this platform.');
|
|
253
|
+
}
|
|
254
|
+
return <String, Object?>{
|
|
255
|
+
'success': true,
|
|
256
|
+
'x1': x1,
|
|
257
|
+
'y1': y1,
|
|
258
|
+
'x2': x2,
|
|
259
|
+
'y2': y2,
|
|
260
|
+
'durationMs': durationMs,
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
Future<Map<String, Object?>> scroll({
|
|
265
|
+
int deltaX = 0,
|
|
266
|
+
int deltaY = 0,
|
|
267
|
+
String? displayId,
|
|
268
|
+
}) async {
|
|
269
|
+
await _assertInputSupported('scroll');
|
|
270
|
+
if (deltaY == 0 && deltaX == 0) {
|
|
271
|
+
return <String, Object?>{
|
|
272
|
+
'success': true,
|
|
273
|
+
'deltaX': deltaX,
|
|
274
|
+
'deltaY': deltaY,
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
if (_usesNativeDesktopBridge) {
|
|
278
|
+
await _nativeBridge.scroll(
|
|
279
|
+
deltaX: deltaX,
|
|
280
|
+
deltaY: deltaY,
|
|
281
|
+
displayId: displayId,
|
|
282
|
+
);
|
|
283
|
+
} else if (defaultTargetPlatform == TargetPlatform.linux) {
|
|
284
|
+
if (deltaY != 0) {
|
|
285
|
+
final clicks = (deltaY.abs() / 120).ceil().clamp(1, 12);
|
|
286
|
+
final button = deltaY < 0 ? '5' : '4';
|
|
287
|
+
await _run(
|
|
288
|
+
_ShellCommand('xdotool', <String>[
|
|
289
|
+
'click',
|
|
290
|
+
'--repeat',
|
|
291
|
+
'$clicks',
|
|
292
|
+
button,
|
|
293
|
+
]),
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
if (deltaX != 0) {
|
|
297
|
+
final clicks = (deltaX.abs() / 120).ceil().clamp(1, 12);
|
|
298
|
+
final button = deltaX < 0 ? '6' : '7';
|
|
299
|
+
await _run(
|
|
300
|
+
_ShellCommand('xdotool', <String>[
|
|
301
|
+
'click',
|
|
302
|
+
'--repeat',
|
|
303
|
+
'$clicks',
|
|
304
|
+
button,
|
|
305
|
+
]),
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
} else {
|
|
309
|
+
throw Exception('scroll is not supported on this platform.');
|
|
310
|
+
}
|
|
311
|
+
return <String, Object?>{
|
|
312
|
+
'success': true,
|
|
313
|
+
'deltaX': deltaX,
|
|
314
|
+
'deltaY': deltaY,
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
Future<Map<String, Object?>> typeText({
|
|
319
|
+
required String text,
|
|
320
|
+
bool pressEnter = false,
|
|
321
|
+
}) async {
|
|
322
|
+
await _assertInputSupported('type text');
|
|
323
|
+
if (_usesNativeDesktopBridge) {
|
|
324
|
+
await _nativeBridge.typeText(text: text, pressEnter: pressEnter);
|
|
325
|
+
} else if (defaultTargetPlatform == TargetPlatform.linux) {
|
|
326
|
+
if (text.isNotEmpty) {
|
|
327
|
+
await _run(
|
|
328
|
+
_ShellCommand('xdotool', <String>[
|
|
329
|
+
'type',
|
|
330
|
+
'--delay',
|
|
331
|
+
'1',
|
|
332
|
+
'--',
|
|
333
|
+
text,
|
|
334
|
+
]),
|
|
335
|
+
);
|
|
336
|
+
}
|
|
337
|
+
if (pressEnter) {
|
|
338
|
+
await _run(_ShellCommand('xdotool', const <String>['key', 'Return']));
|
|
339
|
+
}
|
|
340
|
+
} else {
|
|
341
|
+
throw Exception('type text is not supported on this platform.');
|
|
342
|
+
}
|
|
343
|
+
return <String, Object?>{
|
|
344
|
+
'success': true,
|
|
345
|
+
'textLength': text.length,
|
|
346
|
+
'pressEnter': pressEnter,
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
Future<Map<String, Object?>> pressKey({required String key}) async {
|
|
351
|
+
await _assertInputSupported('press keys');
|
|
352
|
+
if (_usesNativeDesktopBridge) {
|
|
353
|
+
await _nativeBridge.pressKey(key);
|
|
354
|
+
} else if (defaultTargetPlatform == TargetPlatform.linux) {
|
|
355
|
+
final normalized = key.trim();
|
|
356
|
+
if (normalized.isEmpty) {
|
|
357
|
+
throw Exception('Key is required.');
|
|
358
|
+
}
|
|
359
|
+
await _run(_ShellCommand('xdotool', <String>['key', normalized]));
|
|
360
|
+
} else {
|
|
361
|
+
throw Exception('press keys is not supported on this platform.');
|
|
362
|
+
}
|
|
363
|
+
return <String, Object?>{'success': true, 'key': key};
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
Future<Map<String, Object?>> launchApp({required String app}) async {
|
|
367
|
+
if (app.trim().isEmpty) {
|
|
368
|
+
throw Exception('App name is required.');
|
|
369
|
+
}
|
|
370
|
+
final command = switch (defaultTargetPlatform) {
|
|
371
|
+
TargetPlatform.macOS => _ShellCommand('open', <String>['-a', app]),
|
|
372
|
+
TargetPlatform.windows => _ShellCommand('powershell', <String>[
|
|
373
|
+
'-NoProfile',
|
|
374
|
+
'-NonInteractive',
|
|
375
|
+
'-Command',
|
|
376
|
+
'Start-Process -FilePath ${_psQuote(app)}',
|
|
377
|
+
]),
|
|
378
|
+
TargetPlatform.linux => _ShellCommand('sh', <String>[
|
|
379
|
+
'-lc',
|
|
380
|
+
'if command -v ${_shQuote(app)} >/dev/null 2>&1; then ${_shQuote(app)} >/dev/null 2>&1 & disown; else gtk-launch ${_shQuote(app)} >/dev/null 2>&1 & disown; fi',
|
|
381
|
+
]),
|
|
382
|
+
TargetPlatform.android ||
|
|
383
|
+
TargetPlatform.iOS ||
|
|
384
|
+
TargetPlatform.fuchsia => throw Exception(
|
|
385
|
+
'Launching desktop apps is not supported on this platform.',
|
|
386
|
+
),
|
|
387
|
+
};
|
|
388
|
+
await _run(command);
|
|
389
|
+
return <String, Object?>{'success': true, 'app': app};
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
Future<Map<String, Object?>> getTree() async {
|
|
393
|
+
return <String, Object?>{
|
|
394
|
+
'supported': false,
|
|
395
|
+
'nodes': const <Map<String, Object?>>[],
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
Future<Map<String, Object?>> _capabilities({
|
|
400
|
+
Map<String, Object?>? platformStatus,
|
|
401
|
+
}) async {
|
|
402
|
+
final status = platformStatus ?? await _platformStatus();
|
|
403
|
+
final inputSupported = await _inputSupported(platformStatus: status);
|
|
404
|
+
final permissions = status['permissions'];
|
|
405
|
+
final screenCapturePermission = permissions is Map
|
|
406
|
+
? permissions['screenCapture']?.toString()
|
|
407
|
+
: null;
|
|
408
|
+
return <String, Object?>{
|
|
409
|
+
'screenshot':
|
|
410
|
+
_screenCapture.isSupported &&
|
|
411
|
+
screenCapturePermission != 'required' &&
|
|
412
|
+
screenCapturePermission != 'unsupported',
|
|
413
|
+
'click': inputSupported,
|
|
414
|
+
'drag': inputSupported,
|
|
415
|
+
'scroll': inputSupported,
|
|
416
|
+
'typeText': inputSupported,
|
|
417
|
+
'pressKey': inputSupported,
|
|
418
|
+
'launchApp': _isDesktopPlatform,
|
|
419
|
+
'accessibilityTree': false,
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
Map<String, Object?> _permissions(
|
|
424
|
+
Map<String, Object?> capabilities, {
|
|
425
|
+
Map<String, Object?>? platformStatus,
|
|
426
|
+
}) {
|
|
427
|
+
final status = platformStatus ?? const <String, Object?>{};
|
|
428
|
+
final reportedPermissions = status['permissions'];
|
|
429
|
+
if (reportedPermissions is Map) {
|
|
430
|
+
return reportedPermissions.map(
|
|
431
|
+
(key, value) => MapEntry(key.toString(), value),
|
|
432
|
+
);
|
|
433
|
+
}
|
|
434
|
+
final inputAvailable = capabilities['click'] == true;
|
|
435
|
+
return <String, Object?>{
|
|
436
|
+
'screenCapture': _screenCapture.isSupported ? 'available' : 'unsupported',
|
|
437
|
+
'inputControl': inputAvailable ? 'available' : 'unsupported',
|
|
438
|
+
'accessibility': defaultTargetPlatform == TargetPlatform.windows
|
|
439
|
+
? 'available'
|
|
440
|
+
: 'unsupported',
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
Future<bool> _inputSupported({Map<String, Object?>? platformStatus}) async {
|
|
445
|
+
switch (defaultTargetPlatform) {
|
|
446
|
+
case TargetPlatform.macOS:
|
|
447
|
+
final status = platformStatus ?? await _platformStatus();
|
|
448
|
+
final permissions = status['permissions'];
|
|
449
|
+
if (permissions is Map) {
|
|
450
|
+
return permissions['inputControl'] == 'available' &&
|
|
451
|
+
permissions['accessibility'] == 'available';
|
|
452
|
+
}
|
|
453
|
+
return false;
|
|
454
|
+
case TargetPlatform.windows:
|
|
455
|
+
return true;
|
|
456
|
+
case TargetPlatform.linux:
|
|
457
|
+
try {
|
|
458
|
+
final result = await Process.run('sh', <String>[
|
|
459
|
+
'-lc',
|
|
460
|
+
'command -v xdotool >/dev/null 2>&1',
|
|
461
|
+
]);
|
|
462
|
+
return result.exitCode == 0;
|
|
463
|
+
} catch (_) {
|
|
464
|
+
return false;
|
|
465
|
+
}
|
|
466
|
+
case TargetPlatform.android:
|
|
467
|
+
case TargetPlatform.iOS:
|
|
468
|
+
case TargetPlatform.fuchsia:
|
|
469
|
+
return false;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
Future<Map<String, Object?>> _platformStatus() async {
|
|
474
|
+
if (_usesNativeDesktopBridge) {
|
|
475
|
+
return await _nativeBridge.getStatus();
|
|
476
|
+
}
|
|
477
|
+
return const <String, Object?>{};
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
bool get _usesNativeDesktopBridge =>
|
|
481
|
+
defaultTargetPlatform == TargetPlatform.macOS ||
|
|
482
|
+
defaultTargetPlatform == TargetPlatform.windows;
|
|
483
|
+
|
|
484
|
+
bool get _isDesktopPlatform =>
|
|
485
|
+
defaultTargetPlatform == TargetPlatform.macOS ||
|
|
486
|
+
defaultTargetPlatform == TargetPlatform.windows ||
|
|
487
|
+
defaultTargetPlatform == TargetPlatform.linux;
|
|
488
|
+
|
|
489
|
+
Future<void> _assertInputSupported(String action) async {
|
|
490
|
+
final supported = await _inputSupported();
|
|
491
|
+
if (!supported) {
|
|
492
|
+
throw Exception(
|
|
493
|
+
'$action is not available on ${defaultTargetPlatform.name} (missing runtime permission or dependency).',
|
|
494
|
+
);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
Future<DesktopCompanionSnapshot?> _safeSnapshotForStatus({
|
|
499
|
+
required String? activeDisplayId,
|
|
500
|
+
required Map<String, Object?> platformStatus,
|
|
501
|
+
}) async {
|
|
502
|
+
final permissions = _permissions(
|
|
503
|
+
const <String, Object?>{},
|
|
504
|
+
platformStatus: platformStatus,
|
|
505
|
+
);
|
|
506
|
+
final screenCaptureState =
|
|
507
|
+
permissions['screenCapture']?.toString().toLowerCase() ?? 'unknown';
|
|
508
|
+
if (screenCaptureState == 'required' ||
|
|
509
|
+
screenCaptureState == 'unsupported') {
|
|
510
|
+
return null;
|
|
511
|
+
}
|
|
512
|
+
try {
|
|
513
|
+
return await captureSnapshot(activeDisplayId: activeDisplayId);
|
|
514
|
+
} catch (_) {
|
|
515
|
+
return null;
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
String _normalizeMouseButton(String button) {
|
|
520
|
+
final value = button.trim().toLowerCase();
|
|
521
|
+
if (value == 'left' || value == 'right' || value == 'middle') {
|
|
522
|
+
return value;
|
|
523
|
+
}
|
|
524
|
+
return 'left';
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
List<Map<String, Object?>> _normalizeDisplays(
|
|
528
|
+
Object? raw, {
|
|
529
|
+
required String fallbackDisplayId,
|
|
530
|
+
required int width,
|
|
531
|
+
required int height,
|
|
532
|
+
}) {
|
|
533
|
+
if (raw is List) {
|
|
534
|
+
final displays = raw
|
|
535
|
+
.whereType<Map>()
|
|
536
|
+
.map(
|
|
537
|
+
(item) => item.map((key, value) => MapEntry(key.toString(), value)),
|
|
538
|
+
)
|
|
539
|
+
.toList(growable: false);
|
|
540
|
+
if (displays.isNotEmpty) {
|
|
541
|
+
return displays;
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
return <Map<String, Object?>>[
|
|
545
|
+
<String, Object?>{
|
|
546
|
+
'id': fallbackDisplayId,
|
|
547
|
+
'label': 'Primary Display',
|
|
548
|
+
'width': width,
|
|
549
|
+
'height': height,
|
|
550
|
+
'scaleFactor': 1,
|
|
551
|
+
'primary': true,
|
|
552
|
+
},
|
|
553
|
+
];
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
Future<void> _run(_ShellCommand command) async {
|
|
557
|
+
final result = await Process.run(command.command, command.args);
|
|
558
|
+
if (result.exitCode != 0) {
|
|
559
|
+
final stderr = result.stderr?.toString().trim();
|
|
560
|
+
final stdout = result.stdout?.toString().trim();
|
|
561
|
+
final details = stderr?.isNotEmpty == true
|
|
562
|
+
? stderr
|
|
563
|
+
: (stdout?.isNotEmpty == true ? stdout : 'unknown error');
|
|
564
|
+
throw Exception('Command failed (${command.command}): $details');
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
class _ShellCommand {
|
|
570
|
+
const _ShellCommand(this.command, this.args);
|
|
571
|
+
|
|
572
|
+
final String command;
|
|
573
|
+
final List<String> args;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
String _shQuote(String value) => "'${value.replaceAll("'", "'\"'\"'")}'";
|
|
577
|
+
|
|
578
|
+
String _psQuote(String value) => "'${value.replaceAll("'", "''")}'";
|
|
579
|
+
|
|
580
|
+
String _localHostname() {
|
|
581
|
+
final host = Platform.localHostname.trim();
|
|
582
|
+
if (host.isNotEmpty) {
|
|
583
|
+
return host;
|
|
584
|
+
}
|
|
585
|
+
return defaultTargetPlatform.name;
|
|
586
|
+
}
|