neoagent 2.3.1-beta.0 → 2.3.1-beta.100
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 +63 -5
- package/README.md +16 -5
- package/com.neoagent.plist +1 -1
- package/docs/automation.md +82 -41
- package/docs/capabilities.md +85 -89
- package/docs/configuration.md +89 -87
- package/docs/getting-started.md +46 -27
- package/docs/hardware.md +1 -1
- package/docs/index.md +24 -30
- package/docs/integrations.md +46 -60
- package/docs/migration.md +41 -146
- package/docs/operations.md +23 -20
- package/docs/skills.md +20 -20
- package/docs/why-neoagent.md +15 -13
- package/extensions/chrome-browser/background.mjs +10 -2
- package/flutter_app/.metadata +42 -0
- package/flutter_app/DESIGN_SYSTEM.md +166 -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 +185 -0
- package/flutter_app/android/app/src/main/kotlin/com/neoagent/flutter_app/MainActivity.kt +888 -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 +117 -0
- package/flutter_app/lib/features/notifications/notification_interceptor.dart +73 -0
- package/flutter_app/lib/features/onboarding/onboarding_chrome.dart +571 -0
- package/flutter_app/lib/features/onboarding/onboarding_messaging_step.dart +275 -0
- package/flutter_app/lib/features/onboarding/onboarding_model_step.dart +366 -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 +107 -0
- package/flutter_app/lib/main_account_settings.dart +1340 -0
- package/flutter_app/lib/main_admin.dart +900 -0
- package/flutter_app/lib/main_app_shell.dart +2162 -0
- package/flutter_app/lib/main_chat.dart +3902 -0
- package/flutter_app/lib/main_controller.dart +7229 -0
- package/flutter_app/lib/main_devices.dart +1738 -0
- package/flutter_app/lib/main_integrations.dart +917 -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 +3807 -0
- package/flutter_app/lib/main_navigation.dart +206 -0
- package/flutter_app/lib/main_operations.dart +5249 -0
- package/flutter_app/lib/main_recordings.dart +920 -0
- package/flutter_app/lib/main_runtime.dart +869 -0
- package/flutter_app/lib/main_settings.dart +2288 -0
- package/flutter_app/lib/main_shared.dart +3393 -0
- package/flutter_app/lib/main_spacing.dart +33 -0
- package/flutter_app/lib/main_theme.dart +276 -0
- package/flutter_app/lib/main_unified.dart +388 -0
- package/flutter_app/lib/main_voice_assistant.dart +957 -0
- package/flutter_app/lib/src/analytics_service.dart +294 -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 +58 -0
- package/flutter_app/lib/src/app_release_updater.dart +511 -0
- package/flutter_app/lib/src/backend_client.dart +1870 -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 +48 -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 +1256 -0
- package/flutter_app/pubspec.yaml +59 -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 +465 -43
- package/package.json +11 -3
- package/runtime/paths.js +137 -0
- package/server/config/analytics.js +30 -0
- package/server/db/database.js +363 -21
- package/server/guest-agent.android.package.json +13 -0
- package/server/guest-agent.browser.package.json +14 -0
- package/server/guest_agent.js +98 -52
- package/server/http/middleware.js +55 -2
- package/server/http/routes.js +6 -1
- package/server/http/static.js +41 -1
- package/server/index.js +16 -16
- 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/AssetManifest.json +1 -1
- package/server/public/assets/NOTICES +679 -129
- package/server/public/assets/assets/branding/onboarding_intro.mp4 +0 -0
- package/server/public/assets/fonts/MaterialIcons-Regular.otf +0 -0
- package/server/public/assets/packages/mixpanel_flutter/assets/mixpanel.js +3 -0
- package/server/public/canvaskit/wimp.wasm +0 -0
- package/server/public/flutter_bootstrap.js +2 -2
- package/server/public/main.dart.js +95866 -87333
- package/server/routes/account.js +26 -1
- package/server/routes/agents.js +6 -2
- package/server/routes/android.js +22 -6
- package/server/routes/auth.js +25 -5
- package/server/routes/browser.js +47 -13
- package/server/routes/integrations.js +119 -9
- package/server/routes/memory.js +179 -8
- package/server/routes/runtime.js +14 -0
- package/server/routes/screenHistory.js +46 -0
- package/server/routes/settings.js +102 -24
- package/server/routes/skills.js +12 -0
- package/server/routes/social_video.js +66 -0
- package/server/routes/tasks.js +22 -2
- package/server/routes/triggers.js +90 -0
- package/server/routes/wearable.js +67 -0
- package/server/routes/widgets.js +4 -4
- package/server/services/ai/capabilityHealth.js +23 -51
- package/server/services/ai/compaction.js +1 -1
- package/server/services/ai/deliverables/artifact_helpers.js +190 -0
- package/server/services/ai/deliverables/contracts.js +113 -0
- package/server/services/ai/deliverables/index.js +20 -0
- package/server/services/ai/deliverables/selector.js +94 -0
- package/server/services/ai/deliverables/validator.js +63 -0
- package/server/services/ai/deliverables/workflows.js +207 -0
- package/server/services/ai/engine.js +372 -27
- package/server/services/ai/hooks.js +127 -0
- package/server/services/ai/integrated_tools/index.js +98 -0
- package/server/services/ai/integrated_tools/remotion.js +373 -0
- package/server/services/ai/integrated_tools/shared.js +204 -0
- package/server/services/ai/integrated_tools/slidev.js +207 -0
- package/server/services/ai/loopPolicy.js +146 -0
- package/server/services/ai/models.js +36 -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 +384 -0
- package/server/services/ai/recordingInsights.js +11 -13
- package/server/services/ai/runEvents.js +100 -0
- package/server/services/ai/settings.js +20 -0
- package/server/services/ai/systemPrompt.js +16 -2
- package/server/services/ai/taskAnalysis.js +2 -0
- package/server/services/ai/toolResult.js +20 -0
- package/server/services/ai/toolRunner.js +46 -6
- package/server/services/ai/toolSelector.js +54 -1
- package/server/services/ai/tools.js +360 -127
- package/server/services/android/android_bootstrap_worker.js +63 -0
- package/server/services/android/controller.js +442 -1760
- package/server/services/bootstrap_helpers.js +0 -34
- package/server/services/browser/controller.js +326 -52
- package/server/services/cli/executor.js +40 -1
- package/server/services/desktop/screenRecorder.js +182 -0
- package/server/services/integrations/env.js +10 -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 +8 -2
- package/server/services/integrations/spotify/provider.js +488 -0
- package/server/services/integrations/trello/provider.js +842 -0
- package/server/services/integrations/weather/provider.js +559 -0
- package/server/services/integrations/whatsapp/provider.js +6 -2
- package/server/services/manager.js +109 -154
- package/server/services/mcp/client.js +120 -23
- package/server/services/memory/llm_transfer.js +218 -0
- package/server/services/memory/manager.js +299 -35
- package/server/services/messaging/access_policy.js +10 -0
- package/server/services/messaging/automation.js +1 -1
- package/server/services/messaging/manager.js +93 -8
- 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_tcp_transport.js +25 -0
- package/server/services/runtime/backends/local-vm.js +221 -158
- package/server/services/runtime/docker-vm-manager.js +392 -0
- package/server/services/runtime/guest_bootstrap.js +654 -0
- package/server/services/runtime/manager.js +85 -29
- package/server/services/runtime/settings.js +22 -31
- package/server/services/runtime/validation.js +16 -31
- package/server/services/skills/base_catalog.js +33 -0
- package/server/services/social_video/adapters/base.js +26 -0
- package/server/services/social_video/adapters/index.js +27 -0
- package/server/services/social_video/adapters/instagram.js +17 -0
- package/server/services/social_video/adapters/tiktok.js +17 -0
- package/server/services/social_video/adapters/x.js +17 -0
- package/server/services/social_video/adapters/youtube.js +17 -0
- package/server/services/social_video/captions.js +187 -0
- package/server/services/social_video/frame.js +42 -0
- package/server/services/social_video/index.js +7 -0
- package/server/services/social_video/metadata.js +63 -0
- package/server/services/social_video/result.js +63 -0
- package/server/services/social_video/service.js +720 -0
- package/server/services/social_video/url.js +83 -0
- package/server/services/tasks/adapters/index.js +2 -0
- package/server/services/tasks/adapters/manual.js +12 -0
- package/server/services/tasks/adapters/schedule.js +33 -5
- package/server/services/tasks/adapters/weather_event.js +84 -0
- package/server/services/tasks/integration_runtime.js +86 -1
- package/server/services/tasks/runtime.js +3 -3
- package/server/services/tasks/task_repository.js +3 -6
- package/server/services/voice/agentBridge.js +20 -4
- package/server/services/voice/message.js +3 -0
- 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/runtime.js +8 -8
- package/server/services/voice/runtimeManager.js +292 -20
- 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/websocket.js +3 -1
- package/server/services/widgets/focus_widget.js +137 -0
- package/server/services/widgets/service.js +182 -6
- package/server/services/workspace/manager.js +301 -0
- package/server/utils/deployment.js +16 -9
- 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
- package/server/services/messaging/access_policy.test.js +0 -228
- package/server/services/runtime/backends/host.js +0 -37
- package/server/services/runtime/qemu.js +0 -391
|
@@ -0,0 +1,488 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { describeEnvStatus, resolveSpotifyOAuthConfig } = require('../env');
|
|
4
|
+
const { appendQuery, createOAuthProvider } = require('../oauth_provider');
|
|
5
|
+
|
|
6
|
+
const SPOTIFY_APPS = [
|
|
7
|
+
{
|
|
8
|
+
id: 'spotify',
|
|
9
|
+
label: 'Spotify',
|
|
10
|
+
description: 'Connect Spotify for playback status, search, and playback controls.',
|
|
11
|
+
scopes: [
|
|
12
|
+
'user-read-email',
|
|
13
|
+
'user-read-private',
|
|
14
|
+
'user-read-playback-state',
|
|
15
|
+
'user-modify-playback-state',
|
|
16
|
+
'user-read-currently-playing',
|
|
17
|
+
'user-read-recently-played',
|
|
18
|
+
],
|
|
19
|
+
},
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
const spotifyToolDefinitions = [
|
|
23
|
+
{
|
|
24
|
+
appId: 'spotify',
|
|
25
|
+
name: 'spotify_get_current_playback',
|
|
26
|
+
access: 'read',
|
|
27
|
+
description: 'Get current playback state for the connected Spotify account.',
|
|
28
|
+
parameters: { type: 'object', properties: {} },
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
appId: 'spotify',
|
|
32
|
+
name: 'spotify_get_recently_played',
|
|
33
|
+
access: 'read',
|
|
34
|
+
description: 'Get recently played tracks for the connected Spotify account.',
|
|
35
|
+
parameters: {
|
|
36
|
+
type: 'object',
|
|
37
|
+
properties: {
|
|
38
|
+
limit: { type: 'number', description: 'Maximum number of tracks (1-50), default 20.' },
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
appId: 'spotify',
|
|
44
|
+
name: 'spotify_search',
|
|
45
|
+
access: 'read',
|
|
46
|
+
description: 'Search Spotify catalog for tracks, albums, artists, or playlists.',
|
|
47
|
+
parameters: {
|
|
48
|
+
type: 'object',
|
|
49
|
+
properties: {
|
|
50
|
+
query: { type: 'string', description: 'Search query text.' },
|
|
51
|
+
type: { type: 'string', description: 'Comma-separated types: track,artist,album,playlist. Default track.' },
|
|
52
|
+
limit: { type: 'number', description: 'Maximum items per type (1-50), default 10.' },
|
|
53
|
+
market: { type: 'string', description: 'Optional market code like US.' },
|
|
54
|
+
},
|
|
55
|
+
required: ['query'],
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
appId: 'spotify',
|
|
60
|
+
name: 'spotify_control_playback',
|
|
61
|
+
access: 'write',
|
|
62
|
+
description: 'Control Spotify playback: play, pause, next, previous, seek, set_volume, shuffle, or repeat.',
|
|
63
|
+
parameters: {
|
|
64
|
+
type: 'object',
|
|
65
|
+
properties: {
|
|
66
|
+
action: {
|
|
67
|
+
type: 'string',
|
|
68
|
+
description: 'Playback action: play, pause, next, previous, seek, set_volume, shuffle, repeat.',
|
|
69
|
+
},
|
|
70
|
+
device_id: { type: 'string', description: 'Optional target device ID.' },
|
|
71
|
+
context_uri: { type: 'string', description: 'Optional context URI for play action.' },
|
|
72
|
+
uris: { type: 'array', items: { type: 'string' }, description: 'Optional track URIs for play action.' },
|
|
73
|
+
position_ms: { type: 'number', description: 'Optional playback offset in ms for play/seek.' },
|
|
74
|
+
volume_percent: { type: 'number', description: 'Volume 0-100 for set_volume action.' },
|
|
75
|
+
state: { type: 'boolean', description: 'Shuffle state for shuffle action.' },
|
|
76
|
+
mode: { type: 'string', description: 'Repeat mode for repeat action: track, context, off.' },
|
|
77
|
+
},
|
|
78
|
+
required: ['action'],
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
appId: 'spotify',
|
|
83
|
+
name: 'spotify_api_request',
|
|
84
|
+
access: 'dynamic_http_method',
|
|
85
|
+
description: 'Make an authenticated Spotify Web API request for advanced operations.',
|
|
86
|
+
parameters: {
|
|
87
|
+
type: 'object',
|
|
88
|
+
properties: {
|
|
89
|
+
method: { type: 'string', description: 'HTTP method.' },
|
|
90
|
+
path: { type: 'string', description: 'Spotify API path such as /v1/me/player/devices.' },
|
|
91
|
+
query: { type: 'object', description: 'Optional query parameters.' },
|
|
92
|
+
body: { type: 'object', description: 'Optional JSON request body.' },
|
|
93
|
+
},
|
|
94
|
+
required: ['method', 'path'],
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
];
|
|
98
|
+
|
|
99
|
+
function requireText(value, label) {
|
|
100
|
+
const text = String(value || '').trim();
|
|
101
|
+
if (!text) {
|
|
102
|
+
throw new Error(`${label} is required.`);
|
|
103
|
+
}
|
|
104
|
+
return text;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function spotifyUrl(path, query) {
|
|
108
|
+
const rawPath = String(path || '').trim();
|
|
109
|
+
const url = new URL(
|
|
110
|
+
rawPath.startsWith('http')
|
|
111
|
+
? rawPath
|
|
112
|
+
: `https://api.spotify.com${rawPath.startsWith('/') ? '' : '/'}${rawPath}`,
|
|
113
|
+
);
|
|
114
|
+
if (url.hostname !== 'api.spotify.com') {
|
|
115
|
+
throw new Error('Spotify API request URL must target api.spotify.com.');
|
|
116
|
+
}
|
|
117
|
+
for (const [key, value] of Object.entries(query || {})) {
|
|
118
|
+
if (value === undefined || value === null) continue;
|
|
119
|
+
url.searchParams.set(key, String(value));
|
|
120
|
+
}
|
|
121
|
+
return url.toString();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
async function refreshSpotifyAccessToken(config, credentials) {
|
|
125
|
+
const refreshToken = String(credentials?.refresh_token || '').trim();
|
|
126
|
+
if (!refreshToken) {
|
|
127
|
+
return credentials;
|
|
128
|
+
}
|
|
129
|
+
const basic = Buffer.from(`${config.clientId}:${config.clientSecret}`).toString('base64');
|
|
130
|
+
const response = await fetch('https://accounts.spotify.com/api/token', {
|
|
131
|
+
method: 'POST',
|
|
132
|
+
headers: {
|
|
133
|
+
Authorization: `Basic ${basic}`,
|
|
134
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
135
|
+
Accept: 'application/json',
|
|
136
|
+
},
|
|
137
|
+
body: new URLSearchParams({
|
|
138
|
+
grant_type: 'refresh_token',
|
|
139
|
+
refresh_token: refreshToken,
|
|
140
|
+
}).toString(),
|
|
141
|
+
});
|
|
142
|
+
const data = await response.json().catch(() => ({}));
|
|
143
|
+
if (!response.ok) {
|
|
144
|
+
const message = data?.error_description || data?.error || `${response.status} ${response.statusText}`;
|
|
145
|
+
throw new Error(`Spotify token refresh failed: ${message}`);
|
|
146
|
+
}
|
|
147
|
+
const expiresIn = Number(data?.expires_in) || 3600;
|
|
148
|
+
return {
|
|
149
|
+
...credentials,
|
|
150
|
+
access_token: data?.access_token || credentials.access_token,
|
|
151
|
+
refresh_token: data?.refresh_token || refreshToken,
|
|
152
|
+
token_type: data?.token_type || credentials.token_type || 'Bearer',
|
|
153
|
+
scope: data?.scope || credentials.scope || '',
|
|
154
|
+
expires_in: expiresIn,
|
|
155
|
+
expires_at: new Date(Date.now() + expiresIn * 1000).toISOString(),
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
async function ensureSpotifyAccessToken(config, credentials) {
|
|
160
|
+
const accessToken = String(credentials?.access_token || '').trim();
|
|
161
|
+
if (!accessToken) {
|
|
162
|
+
throw new Error('Spotify access token is missing. Reconnect this integration account.');
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const expiresAt = Date.parse(String(credentials?.expires_at || ''));
|
|
166
|
+
const isNearExpiry = Number.isFinite(expiresAt) && expiresAt <= Date.now() + 60 * 1000;
|
|
167
|
+
if (isNearExpiry && credentials?.refresh_token) {
|
|
168
|
+
return refreshSpotifyAccessToken(config, credentials);
|
|
169
|
+
}
|
|
170
|
+
return credentials;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
async function spotifyRequest(config, credentials, { method = 'GET', path, query, body }) {
|
|
174
|
+
let nextCredentials = await ensureSpotifyAccessToken(config, credentials);
|
|
175
|
+
const tokenType = String(nextCredentials?.token_type || 'Bearer').trim() || 'Bearer';
|
|
176
|
+
|
|
177
|
+
const performRequest = async (tokenCreds) => {
|
|
178
|
+
const tokenType = String(tokenCreds?.token_type || 'Bearer').trim() || 'Bearer';
|
|
179
|
+
const response = await fetch(spotifyUrl(path, query), {
|
|
180
|
+
method: String(method || 'GET').toUpperCase(),
|
|
181
|
+
headers: {
|
|
182
|
+
Authorization: `${tokenType} ${tokenCreds.access_token}`,
|
|
183
|
+
Accept: 'application/json',
|
|
184
|
+
...(body === undefined ? {} : { 'Content-Type': 'application/json' }),
|
|
185
|
+
},
|
|
186
|
+
...(body === undefined ? {} : { body: JSON.stringify(body) }),
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
if (response.status === 204) {
|
|
190
|
+
return { ok: true, data: null, response };
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const text = await response.text();
|
|
194
|
+
let parsed = null;
|
|
195
|
+
try {
|
|
196
|
+
parsed = text ? JSON.parse(text) : null;
|
|
197
|
+
} catch {
|
|
198
|
+
parsed = null;
|
|
199
|
+
}
|
|
200
|
+
return { ok: response.ok, data: parsed ?? text, response };
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
let result = await performRequest(nextCredentials);
|
|
204
|
+
if (!result.ok && result.response.status === 401 && nextCredentials.refresh_token) {
|
|
205
|
+
nextCredentials = await refreshSpotifyAccessToken(config, nextCredentials);
|
|
206
|
+
result = await performRequest(nextCredentials);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (!result.ok) {
|
|
210
|
+
const message =
|
|
211
|
+
(result.data && typeof result.data === 'object' && (result.data.error?.message || result.data.error_description || result.data.error)) ||
|
|
212
|
+
`${result.response.status} ${result.response.statusText}`;
|
|
213
|
+
throw new Error(`Spotify request failed: ${String(message).trim()}`);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
return {
|
|
217
|
+
data: result.data,
|
|
218
|
+
credentials: nextCredentials,
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
async function executeSpotifyTool(toolName, args, { credentials }) {
|
|
223
|
+
const config = resolveSpotifyOAuthConfig();
|
|
224
|
+
switch (toolName) {
|
|
225
|
+
case 'spotify_get_current_playback': {
|
|
226
|
+
const { data, credentials: updated } = await spotifyRequest(config, credentials, {
|
|
227
|
+
path: '/v1/me/player',
|
|
228
|
+
});
|
|
229
|
+
return { result: data || { is_playing: false }, credentials: updated };
|
|
230
|
+
}
|
|
231
|
+
case 'spotify_get_recently_played': {
|
|
232
|
+
const limit = Math.max(1, Math.min(Number(args.limit) || 20, 50));
|
|
233
|
+
const { data, credentials: updated } = await spotifyRequest(config, credentials, {
|
|
234
|
+
path: '/v1/me/player/recently-played',
|
|
235
|
+
query: { limit },
|
|
236
|
+
});
|
|
237
|
+
return { result: data, credentials: updated };
|
|
238
|
+
}
|
|
239
|
+
case 'spotify_search': {
|
|
240
|
+
const queryText = requireText(args.query, 'query');
|
|
241
|
+
const types = String(args.type || 'track')
|
|
242
|
+
.split(',')
|
|
243
|
+
.map((entry) => entry.trim().toLowerCase())
|
|
244
|
+
.filter(Boolean)
|
|
245
|
+
.filter((entry) => ['track', 'artist', 'album', 'playlist'].includes(entry));
|
|
246
|
+
const type = types.length > 0 ? types.join(',') : 'track';
|
|
247
|
+
const limit = Math.max(1, Math.min(Number(args.limit) || 10, 50));
|
|
248
|
+
const market = String(args.market || '').trim().toUpperCase();
|
|
249
|
+
const { data, credentials: updated } = await spotifyRequest(config, credentials, {
|
|
250
|
+
path: '/v1/search',
|
|
251
|
+
query: {
|
|
252
|
+
q: queryText,
|
|
253
|
+
type,
|
|
254
|
+
limit,
|
|
255
|
+
...(market ? { market } : {}),
|
|
256
|
+
},
|
|
257
|
+
});
|
|
258
|
+
return { result: data, credentials: updated };
|
|
259
|
+
}
|
|
260
|
+
case 'spotify_control_playback': {
|
|
261
|
+
const action = String(args.action || '').trim().toLowerCase();
|
|
262
|
+
const deviceId = String(args.device_id || '').trim();
|
|
263
|
+
const query = deviceId ? { device_id: deviceId } : undefined;
|
|
264
|
+
|
|
265
|
+
let request;
|
|
266
|
+
switch (action) {
|
|
267
|
+
case 'play':
|
|
268
|
+
request = {
|
|
269
|
+
method: 'PUT',
|
|
270
|
+
path: '/v1/me/player/play',
|
|
271
|
+
query,
|
|
272
|
+
body: {
|
|
273
|
+
...(String(args.context_uri || '').trim() ? { context_uri: String(args.context_uri).trim() } : {}),
|
|
274
|
+
...(Array.isArray(args.uris) ? { uris: args.uris } : {}),
|
|
275
|
+
...(Number.isFinite(Number(args.position_ms)) ? { position_ms: Number(args.position_ms) } : {}),
|
|
276
|
+
},
|
|
277
|
+
};
|
|
278
|
+
break;
|
|
279
|
+
case 'pause':
|
|
280
|
+
request = { method: 'PUT', path: '/v1/me/player/pause', query };
|
|
281
|
+
break;
|
|
282
|
+
case 'next':
|
|
283
|
+
request = { method: 'POST', path: '/v1/me/player/next', query };
|
|
284
|
+
break;
|
|
285
|
+
case 'previous':
|
|
286
|
+
request = { method: 'POST', path: '/v1/me/player/previous', query };
|
|
287
|
+
break;
|
|
288
|
+
case 'seek': {
|
|
289
|
+
const positionMs = Number(args.position_ms);
|
|
290
|
+
if (!Number.isFinite(positionMs) || positionMs < 0) {
|
|
291
|
+
throw new Error('position_ms must be a non-negative number for seek action.');
|
|
292
|
+
}
|
|
293
|
+
request = {
|
|
294
|
+
method: 'PUT',
|
|
295
|
+
path: '/v1/me/player/seek',
|
|
296
|
+
query: {
|
|
297
|
+
...(query || {}),
|
|
298
|
+
position_ms: Math.floor(positionMs),
|
|
299
|
+
},
|
|
300
|
+
};
|
|
301
|
+
break;
|
|
302
|
+
}
|
|
303
|
+
case 'set_volume': {
|
|
304
|
+
const volume = Number(args.volume_percent);
|
|
305
|
+
if (!Number.isFinite(volume) || volume < 0 || volume > 100) {
|
|
306
|
+
throw new Error('volume_percent must be between 0 and 100 for set_volume action.');
|
|
307
|
+
}
|
|
308
|
+
request = {
|
|
309
|
+
method: 'PUT',
|
|
310
|
+
path: '/v1/me/player/volume',
|
|
311
|
+
query: {
|
|
312
|
+
...(query || {}),
|
|
313
|
+
volume_percent: Math.round(volume),
|
|
314
|
+
},
|
|
315
|
+
};
|
|
316
|
+
break;
|
|
317
|
+
}
|
|
318
|
+
case 'shuffle': {
|
|
319
|
+
if (typeof args.state !== 'boolean') {
|
|
320
|
+
throw new Error('state must be true or false for shuffle action.');
|
|
321
|
+
}
|
|
322
|
+
request = {
|
|
323
|
+
method: 'PUT',
|
|
324
|
+
path: '/v1/me/player/shuffle',
|
|
325
|
+
query: {
|
|
326
|
+
...(query || {}),
|
|
327
|
+
state: args.state,
|
|
328
|
+
},
|
|
329
|
+
};
|
|
330
|
+
break;
|
|
331
|
+
}
|
|
332
|
+
case 'repeat': {
|
|
333
|
+
const mode = String(args.mode || '').trim().toLowerCase();
|
|
334
|
+
if (!['track', 'context', 'off'].includes(mode)) {
|
|
335
|
+
throw new Error('mode must be one of track, context, or off for repeat action.');
|
|
336
|
+
}
|
|
337
|
+
request = {
|
|
338
|
+
method: 'PUT',
|
|
339
|
+
path: '/v1/me/player/repeat',
|
|
340
|
+
query: {
|
|
341
|
+
...(query || {}),
|
|
342
|
+
state: mode,
|
|
343
|
+
},
|
|
344
|
+
};
|
|
345
|
+
break;
|
|
346
|
+
}
|
|
347
|
+
default:
|
|
348
|
+
throw new Error('Unsupported action. Use play, pause, next, previous, seek, set_volume, shuffle, or repeat.');
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
const { data, credentials: updated } = await spotifyRequest(config, credentials, request);
|
|
352
|
+
return {
|
|
353
|
+
result: {
|
|
354
|
+
action,
|
|
355
|
+
ok: true,
|
|
356
|
+
response: data,
|
|
357
|
+
},
|
|
358
|
+
credentials: updated,
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
case 'spotify_api_request': {
|
|
362
|
+
const { data, credentials: updated } = await spotifyRequest(config, credentials, {
|
|
363
|
+
method: args.method,
|
|
364
|
+
path: requireText(args.path, 'path'),
|
|
365
|
+
query: args.query,
|
|
366
|
+
body: args.body,
|
|
367
|
+
});
|
|
368
|
+
return { result: data, credentials: updated };
|
|
369
|
+
}
|
|
370
|
+
default:
|
|
371
|
+
return null;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
async function fetchSpotifyProfile(accessToken) {
|
|
376
|
+
const response = await fetch('https://api.spotify.com/v1/me', {
|
|
377
|
+
method: 'GET',
|
|
378
|
+
headers: {
|
|
379
|
+
Authorization: `Bearer ${accessToken}`,
|
|
380
|
+
Accept: 'application/json',
|
|
381
|
+
},
|
|
382
|
+
});
|
|
383
|
+
const payload = await response.json().catch(() => ({}));
|
|
384
|
+
if (!response.ok) {
|
|
385
|
+
const message = payload?.error?.message || payload?.error || `${response.status} ${response.statusText}`;
|
|
386
|
+
throw new Error(`Spotify profile request failed: ${message}`);
|
|
387
|
+
}
|
|
388
|
+
return payload;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
function createSpotifyProvider() {
|
|
392
|
+
return createOAuthProvider({
|
|
393
|
+
key: 'spotify',
|
|
394
|
+
label: 'Spotify',
|
|
395
|
+
description: 'Official Spotify account integration for music search and playback control.',
|
|
396
|
+
icon: 'spotify',
|
|
397
|
+
requiresRefreshToken: true,
|
|
398
|
+
apps: SPOTIFY_APPS,
|
|
399
|
+
toolDefinitions: spotifyToolDefinitions,
|
|
400
|
+
connectPrompt:
|
|
401
|
+
'Connect Spotify to allow playback-aware automations, track search, and playback controls from the agent.',
|
|
402
|
+
getEnvStatus() {
|
|
403
|
+
return describeEnvStatus(resolveSpotifyOAuthConfig(), {
|
|
404
|
+
label: 'Spotify',
|
|
405
|
+
});
|
|
406
|
+
},
|
|
407
|
+
async beginOAuth({ state, app }) {
|
|
408
|
+
const config = resolveSpotifyOAuthConfig();
|
|
409
|
+
return {
|
|
410
|
+
url: appendQuery('https://accounts.spotify.com/authorize', {
|
|
411
|
+
response_type: 'code',
|
|
412
|
+
client_id: config.clientId,
|
|
413
|
+
redirect_uri: config.redirectUri,
|
|
414
|
+
scope: app.scopes.join(' '),
|
|
415
|
+
state,
|
|
416
|
+
show_dialog: 'true',
|
|
417
|
+
}),
|
|
418
|
+
appId: app.id,
|
|
419
|
+
};
|
|
420
|
+
},
|
|
421
|
+
async finishOAuth({ code, app }) {
|
|
422
|
+
const config = resolveSpotifyOAuthConfig();
|
|
423
|
+
const basic = Buffer.from(`${config.clientId}:${config.clientSecret}`).toString('base64');
|
|
424
|
+
const tokenResponse = await fetch('https://accounts.spotify.com/api/token', {
|
|
425
|
+
method: 'POST',
|
|
426
|
+
headers: {
|
|
427
|
+
Authorization: `Basic ${basic}`,
|
|
428
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
429
|
+
Accept: 'application/json',
|
|
430
|
+
},
|
|
431
|
+
body: new URLSearchParams({
|
|
432
|
+
grant_type: 'authorization_code',
|
|
433
|
+
code,
|
|
434
|
+
redirect_uri: config.redirectUri,
|
|
435
|
+
}).toString(),
|
|
436
|
+
});
|
|
437
|
+
const token = await tokenResponse.json().catch(() => ({}));
|
|
438
|
+
if (!tokenResponse.ok) {
|
|
439
|
+
const message = token?.error_description || token?.error || `${tokenResponse.status} ${tokenResponse.statusText}`;
|
|
440
|
+
throw new Error(`Spotify OAuth token exchange failed: ${message}`);
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
const accessToken = String(token?.access_token || '').trim();
|
|
444
|
+
if (!accessToken) {
|
|
445
|
+
throw new Error('Spotify OAuth did not return an access token.');
|
|
446
|
+
}
|
|
447
|
+
const refreshToken = String(token?.refresh_token || '').trim();
|
|
448
|
+
if (!refreshToken) {
|
|
449
|
+
throw new Error('Spotify OAuth did not return a refresh token.');
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
const profile = await fetchSpotifyProfile(accessToken);
|
|
453
|
+
const accountEmail =
|
|
454
|
+
String(profile?.email || '').trim() ||
|
|
455
|
+
(String(profile?.id || '').trim() ? `spotify:${String(profile.id).trim()}` : 'spotify_user');
|
|
456
|
+
|
|
457
|
+
const expiresIn = Number(token?.expires_in) || 3600;
|
|
458
|
+
return {
|
|
459
|
+
appId: app.id,
|
|
460
|
+
accountEmail,
|
|
461
|
+
credentials: {
|
|
462
|
+
access_token: accessToken,
|
|
463
|
+
refresh_token: refreshToken,
|
|
464
|
+
token_type: token?.token_type || 'Bearer',
|
|
465
|
+
scope: token?.scope || app.scopes.join(' '),
|
|
466
|
+
expires_in: expiresIn,
|
|
467
|
+
expires_at: new Date(Date.now() + expiresIn * 1000).toISOString(),
|
|
468
|
+
},
|
|
469
|
+
scopes: String(token?.scope || app.scopes.join(' '))
|
|
470
|
+
.split(/\s+/)
|
|
471
|
+
.map((scope) => scope.trim())
|
|
472
|
+
.filter(Boolean),
|
|
473
|
+
metadata: {
|
|
474
|
+
spotifyUserId: profile?.id || null,
|
|
475
|
+
displayName: profile?.display_name || null,
|
|
476
|
+
email: profile?.email || null,
|
|
477
|
+
country: profile?.country || null,
|
|
478
|
+
product: profile?.product || null,
|
|
479
|
+
},
|
|
480
|
+
};
|
|
481
|
+
},
|
|
482
|
+
executeTool: executeSpotifyTool,
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
module.exports = {
|
|
487
|
+
createSpotifyProvider,
|
|
488
|
+
};
|