@glassly/engine 0.1.0-dev.98 → 0.2.8-dev.445
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/README.md +28 -0
- package/build/engine.d.ts +32 -10
- package/build/engine.d.ts.map +1 -1
- package/build/engine.js +24 -16
- package/build/engine.js.map +1 -1
- package/build/facades/dev.d.ts +9 -0
- package/build/facades/dev.d.ts.map +1 -1
- package/build/facades/dev.js +9 -0
- package/build/facades/dev.js.map +1 -1
- package/build/facades/display.d.ts +10 -3
- package/build/facades/display.d.ts.map +1 -1
- package/build/facades/display.js +22 -8
- package/build/facades/display.js.map +1 -1
- package/build/facades/displayMirror.d.ts +11 -0
- package/build/facades/displayMirror.d.ts.map +1 -1
- package/build/facades/displayMirror.js +22 -0
- package/build/facades/displayMirror.js.map +1 -1
- package/build/facades/glasses.d.ts +31 -1
- package/build/facades/glasses.d.ts.map +1 -1
- package/build/facades/glasses.js +51 -0
- package/build/facades/glasses.js.map +1 -1
- package/build/facades/memory.d.ts +0 -6
- package/build/facades/memory.d.ts.map +1 -1
- package/build/facades/memory.js +1 -9
- package/build/facades/memory.js.map +1 -1
- package/build/facades/miniapps.d.ts +3 -1
- package/build/facades/miniapps.d.ts.map +1 -1
- package/build/facades/miniapps.js +3 -1
- package/build/facades/miniapps.js.map +1 -1
- package/build/facades/pairing.d.ts.map +1 -1
- package/build/facades/pairing.js +5 -4
- package/build/facades/pairing.js.map +1 -1
- package/build/facades/permissions.d.ts +2 -0
- package/build/facades/permissions.d.ts.map +1 -1
- package/build/facades/permissions.js +48 -0
- package/build/facades/permissions.js.map +1 -1
- package/build/facades/phoneNotifications.d.ts +20 -9
- package/build/facades/phoneNotifications.d.ts.map +1 -1
- package/build/facades/phoneNotifications.js +33 -26
- package/build/facades/phoneNotifications.js.map +1 -1
- package/build/facades/settings.d.ts.map +1 -1
- package/build/facades/settings.js +1 -2
- package/build/facades/settings.js.map +1 -1
- package/build/generated/releaseMetadata.js +4 -4
- package/build/generated/releaseMetadata.js.map +1 -1
- package/build/index.d.ts +6 -4
- package/build/index.d.ts.map +1 -1
- package/build/index.js +5 -4
- package/build/index.js.map +1 -1
- package/build/react/MentraLiveOtaFlow.js +2 -2
- package/build/react/MentraLiveOtaFlow.js.map +1 -1
- package/build/react/useMentraLiveOta.d.ts.map +1 -1
- package/build/react/useMentraLiveOta.js +8 -7
- package/build/react/useMentraLiveOta.js.map +1 -1
- package/build/runtime/config.d.ts +1 -1
- package/build/runtime/config.d.ts.map +1 -1
- package/build/runtime/config.js.map +1 -1
- package/build/services/AppRegistry.d.ts +4 -1
- package/build/services/AppRegistry.d.ts.map +1 -1
- package/build/services/AppRegistry.js +21 -1
- package/build/services/AppRegistry.js.map +1 -1
- package/build/services/BlobStore.d.ts +2 -2
- package/build/services/BlobStore.js +3 -3
- package/build/services/BlobStore.js.map +1 -1
- package/build/services/CloudClientService.d.ts +7 -3
- package/build/services/CloudClientService.d.ts.map +1 -1
- package/build/services/CloudClientService.js +34 -9
- package/build/services/CloudClientService.js.map +1 -1
- package/build/services/DevServerBridge.d.ts +1 -18
- package/build/services/DevServerBridge.d.ts.map +1 -1
- package/build/services/DevServerBridge.js +9 -8
- package/build/services/DevServerBridge.js.map +1 -1
- package/build/services/DeviceEventRouter.d.ts.map +1 -1
- package/build/services/DeviceEventRouter.js +58 -71
- package/build/services/DeviceEventRouter.js.map +1 -1
- package/build/services/DisplayDiagnostics.d.ts +5 -0
- package/build/services/DisplayDiagnostics.d.ts.map +1 -0
- package/build/services/DisplayDiagnostics.js +105 -0
- package/build/services/DisplayDiagnostics.js.map +1 -0
- package/build/services/DisplayProcessor.d.ts +6 -7
- package/build/services/DisplayProcessor.d.ts.map +1 -1
- package/build/services/DisplayProcessor.js +17 -45
- package/build/services/DisplayProcessor.js.map +1 -1
- package/build/services/GestureDotsService.d.ts +10 -4
- package/build/services/GestureDotsService.d.ts.map +1 -1
- package/build/services/GestureDotsService.js +70 -16
- package/build/services/GestureDotsService.js.map +1 -1
- package/build/services/GlassesKeyboardInput.d.ts +77 -0
- package/build/services/GlassesKeyboardInput.d.ts.map +1 -0
- package/build/services/GlassesKeyboardInput.js +261 -0
- package/build/services/GlassesKeyboardInput.js.map +1 -0
- package/build/services/GlassesSensorService.d.ts +47 -0
- package/build/services/GlassesSensorService.d.ts.map +1 -0
- package/build/services/GlassesSensorService.js +242 -0
- package/build/services/GlassesSensorService.js.map +1 -0
- package/build/services/GlassesTouchInput.d.ts +14 -0
- package/build/services/GlassesTouchInput.d.ts.map +1 -0
- package/build/services/GlassesTouchInput.js +107 -0
- package/build/services/GlassesTouchInput.js.map +1 -0
- package/build/services/HeadingService.d.ts +0 -6
- package/build/services/HeadingService.d.ts.map +1 -1
- package/build/services/HeadingService.js +0 -27
- package/build/services/HeadingService.js.map +1 -1
- package/build/services/HotspotShutdown.d.ts.map +1 -1
- package/build/services/HotspotShutdown.js +2 -1
- package/build/services/HotspotShutdown.js.map +1 -1
- package/build/services/JSCrashloopReportService.js +2 -2
- package/build/services/JSCrashloopReportService.js.map +1 -1
- package/build/services/JSRouter.d.ts +6 -4
- package/build/services/JSRouter.d.ts.map +1 -1
- package/build/services/JSRouter.js +15 -13
- package/build/services/JSRouter.js.map +1 -1
- package/build/services/LocalDisplayManager.d.ts +35 -7
- package/build/services/LocalDisplayManager.d.ts.map +1 -1
- package/build/services/LocalDisplayManager.js +105 -27
- package/build/services/LocalDisplayManager.js.map +1 -1
- package/build/services/LocalMiniappDataMigration.d.ts +1 -1
- package/build/services/LocalMiniappDataMigration.js +1 -1
- package/build/services/LocalMiniappDataMigration.js.map +1 -1
- package/build/services/LocalMiniappRuntime.d.ts +64 -11
- package/build/services/LocalMiniappRuntime.d.ts.map +1 -1
- package/build/services/LocalMiniappRuntime.js +441 -35
- package/build/services/LocalMiniappRuntime.js.map +1 -1
- package/build/services/LocalSttFallbackCoordinator.d.ts +3 -0
- package/build/services/LocalSttFallbackCoordinator.d.ts.map +1 -1
- package/build/services/LocalSttFallbackCoordinator.js +27 -8
- package/build/services/LocalSttFallbackCoordinator.js.map +1 -1
- package/build/services/MemoryStore.d.ts +8 -33
- package/build/services/MemoryStore.d.ts.map +1 -1
- package/build/services/MemoryStore.js +30 -56
- package/build/services/MemoryStore.js.map +1 -1
- package/build/services/MiniappEngine.d.ts +3 -3
- package/build/services/MiniappEngine.js +7 -7
- package/build/services/MiniappEngine.js.map +1 -1
- package/build/services/MiniappLauncher.d.ts +8 -0
- package/build/services/MiniappLauncher.d.ts.map +1 -1
- package/build/services/MiniappLauncher.js +19 -1
- package/build/services/MiniappLauncher.js.map +1 -1
- package/build/services/MirrorService.d.ts +24 -0
- package/build/services/MirrorService.d.ts.map +1 -0
- package/build/services/MirrorService.js +132 -0
- package/build/services/MirrorService.js.map +1 -0
- package/build/services/NativeNavigationService.d.ts +2 -3
- package/build/services/NativeNavigationService.d.ts.map +1 -1
- package/build/services/NativeNavigationService.js +24 -21
- package/build/services/NativeNavigationService.js.map +1 -1
- package/build/services/NavigationHandlers.d.ts.map +1 -1
- package/build/services/NavigationHandlers.js +10 -5
- package/build/services/NavigationHandlers.js.map +1 -1
- package/build/services/OtaInstallCoordinator.d.ts.map +1 -1
- package/build/services/OtaInstallCoordinator.js +24 -23
- package/build/services/OtaInstallCoordinator.js.map +1 -1
- package/build/services/PairedGlassesLatch.d.ts +7 -0
- package/build/services/PairedGlassesLatch.d.ts.map +1 -0
- package/build/services/PairedGlassesLatch.js +38 -0
- package/build/services/PairedGlassesLatch.js.map +1 -0
- package/build/services/PhoneActivity.d.ts +23 -0
- package/build/services/PhoneActivity.d.ts.map +1 -0
- package/build/services/PhoneActivity.js +111 -0
- package/build/services/PhoneActivity.js.map +1 -0
- package/build/services/PhoneCameraFovCoordinator.d.ts.map +1 -1
- package/build/services/PhoneCameraFovCoordinator.js +4 -3
- package/build/services/PhoneCameraFovCoordinator.js.map +1 -1
- package/build/services/PhoneNotificationsSync.d.ts +40 -6
- package/build/services/PhoneNotificationsSync.d.ts.map +1 -1
- package/build/services/PhoneNotificationsSync.js +160 -84
- package/build/services/PhoneNotificationsSync.js.map +1 -1
- package/build/services/PhonePhotoCoordinator.d.ts.map +1 -1
- package/build/services/PhonePhotoCoordinator.js +6 -5
- package/build/services/PhonePhotoCoordinator.js.map +1 -1
- package/build/services/PhoneStreamCoordinator.d.ts.map +1 -1
- package/build/services/PhoneStreamCoordinator.js +8 -7
- package/build/services/PhoneStreamCoordinator.js.map +1 -1
- package/build/services/STTModelManager.d.ts +3 -0
- package/build/services/STTModelManager.d.ts.map +1 -1
- package/build/services/STTModelManager.js +15 -1
- package/build/services/STTModelManager.js.map +1 -1
- package/build/services/SceneRenderer.d.ts +43 -2
- package/build/services/SceneRenderer.d.ts.map +1 -1
- package/build/services/SceneRenderer.js +123 -8
- package/build/services/SceneRenderer.js.map +1 -1
- package/build/services/StreamLifecycleController.d.ts.map +1 -1
- package/build/services/StreamLifecycleController.js +6 -14
- package/build/services/StreamLifecycleController.js.map +1 -1
- package/build/services/TTSModelManager.js +1 -1
- package/build/services/TTSModelManager.js.map +1 -1
- package/build/services/UIRouter.d.ts +2 -2
- package/build/services/UIRouter.js +5 -5
- package/build/services/UIRouter.js.map +1 -1
- package/build/services/asg/galleryPathMigration.js +1 -1
- package/build/services/asg/galleryPathMigration.js.map +1 -1
- package/build/services/asg/gallerySyncService.js +2 -2
- package/build/services/asg/gallerySyncService.js.map +1 -1
- package/build/services/asg/localStorageService.d.ts.map +1 -1
- package/build/services/asg/localStorageService.js +3 -3
- package/build/services/asg/localStorageService.js.map +1 -1
- package/build/services/debug/DashboardOpenTrace.d.ts +32 -0
- package/build/services/debug/DashboardOpenTrace.d.ts.map +1 -0
- package/build/services/debug/DashboardOpenTrace.js +128 -0
- package/build/services/debug/DashboardOpenTrace.js.map +1 -0
- package/build/services/debug/dashboardOpenTimeline.d.ts +77 -0
- package/build/services/debug/dashboardOpenTimeline.d.ts.map +1 -0
- package/build/services/debug/dashboardOpenTimeline.js +195 -0
- package/build/services/debug/dashboardOpenTimeline.js.map +1 -0
- package/build/services/effectiveCapabilities.d.ts.map +1 -1
- package/build/services/effectiveCapabilities.js +25 -13
- package/build/services/effectiveCapabilities.js.map +1 -1
- package/build/services/gestureClaims.d.ts +34 -15
- package/build/services/gestureClaims.d.ts.map +1 -1
- package/build/services/gestureClaims.js +42 -21
- package/build/services/gestureClaims.js.map +1 -1
- package/build/services/manifestFields.d.ts +9 -0
- package/build/services/manifestFields.d.ts.map +1 -0
- package/build/services/manifestFields.js +26 -0
- package/build/services/manifestFields.js.map +1 -0
- package/build/services/memoryStoreInstance.d.ts +0 -10
- package/build/services/memoryStoreInstance.d.ts.map +1 -1
- package/build/services/memoryStoreInstance.js +2 -31
- package/build/services/memoryStoreInstance.js.map +1 -1
- package/build/services/mirrorSnapshot.d.ts +16 -0
- package/build/services/mirrorSnapshot.d.ts.map +1 -0
- package/build/services/mirrorSnapshot.js +102 -0
- package/build/services/mirrorSnapshot.js.map +1 -0
- package/build/services/nativeNavigationGate.d.ts +8 -0
- package/build/services/nativeNavigationGate.d.ts.map +1 -0
- package/build/services/nativeNavigationGate.js +12 -0
- package/build/services/nativeNavigationGate.js.map +1 -0
- package/build/services/notificationAppCatalog.d.ts +7 -0
- package/build/services/notificationAppCatalog.d.ts.map +1 -0
- package/build/services/notificationAppCatalog.js +16 -0
- package/build/services/notificationAppCatalog.js.map +1 -0
- package/build/services/notifications/notificationPolicy.d.ts +55 -0
- package/build/services/notifications/notificationPolicy.d.ts.map +1 -0
- package/build/services/notifications/notificationPolicy.js +41 -0
- package/build/services/notifications/notificationPolicy.js.map +1 -0
- package/build/services/pages/OverlayPages.d.ts +26 -0
- package/build/services/pages/OverlayPages.d.ts.map +1 -0
- package/build/services/pages/OverlayPages.js +80 -0
- package/build/services/pages/OverlayPages.js.map +1 -0
- package/build/services/pages/PageHost.d.ts +32 -0
- package/build/services/pages/PageHost.d.ts.map +1 -0
- package/build/services/pages/PageHost.js +99 -0
- package/build/services/pages/PageHost.js.map +1 -0
- package/build/services/pages/overlayApps.d.ts +25 -0
- package/build/services/pages/overlayApps.d.ts.map +1 -0
- package/build/services/pages/overlayApps.js +66 -0
- package/build/services/pages/overlayApps.js.map +1 -0
- package/build/services/pages/pageEligibility.d.ts +9 -0
- package/build/services/pages/pageEligibility.d.ts.map +1 -0
- package/build/services/pages/pageEligibility.js +27 -0
- package/build/services/pages/pageEligibility.js.map +1 -0
- package/build/services/settingsBridge.d.ts +58 -0
- package/build/services/settingsBridge.d.ts.map +1 -0
- package/build/services/settingsBridge.js +90 -0
- package/build/services/settingsBridge.js.map +1 -0
- package/build/services/speakerProfileStoreInstance.js +1 -1
- package/build/services/speakerProfileStoreInstance.js.map +1 -1
- package/build/services/uiShim.d.ts +1 -1
- package/build/services/uiShim.js +4 -4
- package/build/services/uiShim.js.map +1 -1
- package/build/stores/appVisibility.d.ts +28 -0
- package/build/stores/appVisibility.d.ts.map +1 -1
- package/build/stores/appVisibility.js +34 -0
- package/build/stores/appVisibility.js.map +1 -1
- package/build/stores/apps.d.ts +13 -0
- package/build/stores/apps.d.ts.map +1 -1
- package/build/stores/apps.js +66 -12
- package/build/stores/apps.js.map +1 -1
- package/build/stores/bluetoothSettingKeys.js +1 -1
- package/build/stores/bluetoothSettingKeys.js.map +1 -1
- package/build/stores/display.d.ts +3 -3
- package/build/stores/display.d.ts.map +1 -1
- package/build/stores/display.js +16 -4
- package/build/stores/display.js.map +1 -1
- package/build/stores/glasses.d.ts.map +1 -1
- package/build/stores/glasses.js +14 -1
- package/build/stores/glasses.js.map +1 -1
- package/build/stores/settings.d.ts +1 -0
- package/build/stores/settings.d.ts.map +1 -1
- package/build/stores/settings.js +170 -44
- package/build/stores/settings.js.map +1 -1
- package/build/types/applet.d.ts +14 -1
- package/build/types/applet.d.ts.map +1 -1
- package/build/types/applet.js.map +1 -1
- package/build/types/capabilities/even-realities-g2.d.ts.map +1 -1
- package/build/types/capabilities/even-realities-g2.js +5 -0
- package/build/types/capabilities/even-realities-g2.js.map +1 -1
- package/build/types/capabilities/simulated-glasses.d.ts +1 -1
- package/build/types/capabilities/simulated-glasses.d.ts.map +1 -1
- package/build/types/capabilities/simulated-glasses.js +7 -4
- package/build/types/capabilities/simulated-glasses.js.map +1 -1
- package/build/types/hardware.d.ts +20 -1
- package/build/types/hardware.d.ts.map +1 -1
- package/build/types/hardware.js +2 -0
- package/build/types/hardware.js.map +1 -1
- package/build/types/index.d.ts +1 -0
- package/build/types/index.d.ts.map +1 -1
- package/build/types/index.js +1 -0
- package/build/types/index.js.map +1 -1
- package/build/utils/debouncedPatch.d.ts +3 -1
- package/build/utils/debouncedPatch.d.ts.map +1 -1
- package/build/utils/debouncedPatch.js +6 -3
- package/build/utils/debouncedPatch.js.map +1 -1
- package/build/utils/devMiniappLaunch.d.ts.map +1 -1
- package/build/utils/devMiniappLaunch.js +4 -3
- package/build/utils/devMiniappLaunch.js.map +1 -1
- package/build/utils/display/measurer/TextMeasurer.d.ts +2 -159
- package/build/utils/display/measurer/TextMeasurer.d.ts.map +1 -1
- package/build/utils/display/measurer/TextMeasurer.js +2 -272
- package/build/utils/display/measurer/TextMeasurer.js.map +1 -1
- package/build/utils/display/measurer/script-detection.d.ts +1 -52
- package/build/utils/display/measurer/script-detection.d.ts.map +1 -1
- package/build/utils/display/measurer/script-detection.js +2 -183
- package/build/utils/display/measurer/script-detection.js.map +1 -1
- package/build/utils/display/pixelArt.d.ts +3 -0
- package/build/utils/display/pixelArt.d.ts.map +1 -0
- package/build/utils/display/pixelArt.js +3 -0
- package/build/utils/display/pixelArt.js.map +1 -0
- package/build/utils/display/profiles/g1.d.ts +1 -32
- package/build/utils/display/profiles/g1.d.ts.map +1 -1
- package/build/utils/display/profiles/g1.js +2 -212
- package/build/utils/display/profiles/g1.js.map +1 -1
- package/build/utils/display/profiles/g2.d.ts +1 -12
- package/build/utils/display/profiles/g2.d.ts.map +1 -1
- package/build/utils/display/profiles/g2.js +2 -33
- package/build/utils/display/profiles/g2.js.map +1 -1
- package/build/utils/display/profiles/nex.d.ts +1 -9
- package/build/utils/display/profiles/nex.d.ts.map +1 -1
- package/build/utils/display/profiles/nex.js +2 -149
- package/build/utils/display/profiles/nex.js.map +1 -1
- package/build/utils/display/profiles/types.d.ts +1 -102
- package/build/utils/display/profiles/types.d.ts.map +1 -1
- package/build/utils/display/profiles/types.js.map +1 -1
- package/build/utils/display/profiles/z100.d.ts +1 -32
- package/build/utils/display/profiles/z100.d.ts.map +1 -1
- package/build/utils/display/profiles/z100.js +2 -181
- package/build/utils/display/profiles/z100.js.map +1 -1
- package/build/utils/display/scene/degrade.d.ts.map +1 -1
- package/build/utils/display/scene/degrade.js +4 -1
- package/build/utils/display/scene/degrade.js.map +1 -1
- package/build/utils/display/scene/differ.d.ts +13 -1
- package/build/utils/display/scene/differ.d.ts.map +1 -1
- package/build/utils/display/scene/differ.js +22 -0
- package/build/utils/display/scene/differ.js.map +1 -1
- package/build/utils/display/scene/index.d.ts +1 -1
- package/build/utils/display/scene/index.d.ts.map +1 -1
- package/build/utils/display/scene/index.js.map +1 -1
- package/build/utils/display/scene/process.d.ts.map +1 -1
- package/build/utils/display/scene/process.js +183 -11
- package/build/utils/display/scene/process.js.map +1 -1
- package/build/utils/display/scene/store.d.ts +1 -1
- package/build/utils/display/scene/store.d.ts.map +1 -1
- package/build/utils/display/scene/store.js +0 -0
- package/build/utils/display/scene/store.js.map +1 -1
- package/build/utils/display/scene/svgPath.d.ts +9 -0
- package/build/utils/display/scene/svgPath.d.ts.map +1 -0
- package/build/utils/display/scene/svgPath.js +167 -0
- package/build/utils/display/scene/svgPath.js.map +1 -0
- package/build/utils/display/scene/types.d.ts +2 -142
- package/build/utils/display/scene/types.d.ts.map +1 -1
- package/build/utils/display/scene/types.js +0 -0
- package/build/utils/display/scene/types.js.map +1 -1
- package/build/utils/display/wrapper/TextWrapper.d.ts +1 -101
- package/build/utils/display/wrapper/TextWrapper.d.ts.map +1 -1
- package/build/utils/display/wrapper/TextWrapper.js +2 -470
- package/build/utils/display/wrapper/TextWrapper.js.map +1 -1
- package/build/utils/display/wrapper/types.d.ts +2 -74
- package/build/utils/display/wrapper/types.d.ts.map +1 -1
- package/build/utils/display/wrapper/types.js +2 -10
- package/build/utils/display/wrapper/types.js.map +1 -1
- package/build/utils/hardware/hardware.js +1 -1
- package/build/utils/hardware/hardware.js.map +1 -1
- package/build/utils/timers/timers.d.ts.map +1 -1
- package/build/utils/timers/timers.js +26 -4
- package/build/utils/timers/timers.js.map +1 -1
- package/package.json +8 -8
- package/src/engine.ts +24 -15
- package/src/facades/dev.ts +10 -0
- package/src/facades/display.ts +21 -8
- package/src/facades/displayMirror.ts +29 -0
- package/src/facades/glasses.ts +61 -1
- package/src/facades/memory.ts +1 -12
- package/src/facades/miniapps.ts +4 -1
- package/src/facades/pairing.ts +8 -6
- package/src/facades/permissions.ts +46 -0
- package/src/facades/phoneNotifications.ts +45 -26
- package/src/facades/settings.ts +1 -2
- package/src/generated/releaseMetadata.ts +4 -4
- package/src/index.ts +6 -9
- package/src/react/MentraLiveOtaFlow.tsx +2 -2
- package/src/react/useMentraLiveOta.ts +14 -8
- package/src/runtime/config.ts +1 -1
- package/src/services/AppRegistry.ts +43 -7
- package/src/services/BlobStore.ts +3 -3
- package/src/services/CloudClientService.ts +37 -10
- package/src/services/DevServerBridge.ts +12 -10
- package/src/services/DeviceEventRouter.ts +73 -74
- package/src/services/DisplayDiagnostics.ts +107 -0
- package/src/services/DisplayProcessor.ts +20 -55
- package/src/services/GestureDotsService.ts +77 -16
- package/src/services/GlassesKeyboardInput.ts +306 -0
- package/src/services/GlassesSensorService.ts +233 -0
- package/src/services/GlassesTouchInput.ts +128 -0
- package/src/services/HeadingService.ts +0 -24
- package/src/services/HotspotShutdown.ts +3 -1
- package/src/services/JSCrashloopReportService.ts +2 -2
- package/src/services/JSRouter.ts +29 -14
- package/src/services/LocalDisplayManager.ts +112 -26
- package/src/services/LocalMiniappDataMigration.ts +1 -1
- package/src/services/LocalMiniappRuntime.ts +500 -43
- package/src/services/LocalSttFallbackCoordinator.ts +28 -7
- package/src/services/MemoryStore.ts +32 -80
- package/src/services/MiniappEngine.ts +7 -7
- package/src/services/MiniappLauncher.ts +25 -1
- package/src/services/MirrorService.ts +139 -0
- package/src/services/NativeNavigationService.ts +29 -25
- package/src/services/NavigationHandlers.ts +10 -5
- package/src/services/OtaInstallCoordinator.ts +36 -34
- package/src/services/PairedGlassesLatch.ts +39 -0
- package/src/services/PhoneActivity.ts +116 -0
- package/src/services/PhoneCameraFovCoordinator.ts +6 -4
- package/src/services/PhoneNotificationsSync.ts +185 -103
- package/src/services/PhonePhotoCoordinator.ts +9 -10
- package/src/services/PhoneStreamCoordinator.ts +13 -11
- package/src/services/STTModelManager.ts +15 -1
- package/src/services/SceneRenderer.ts +148 -10
- package/src/services/StreamLifecycleController.ts +9 -7
- package/src/services/TTSModelManager.ts +1 -1
- package/src/services/UIRouter.ts +5 -5
- package/src/services/asg/galleryPathMigration.ts +1 -1
- package/src/services/asg/gallerySyncService.ts +2 -2
- package/src/services/asg/localStorageService.ts +3 -3
- package/src/services/debug/DashboardOpenTrace.ts +153 -0
- package/src/services/debug/dashboardOpenTimeline.ts +237 -0
- package/src/services/effectiveCapabilities.ts +32 -13
- package/src/services/gestureClaims.ts +72 -23
- package/src/services/manifestFields.ts +23 -0
- package/src/services/memoryStoreInstance.ts +2 -34
- package/src/services/mirrorSnapshot.ts +116 -0
- package/src/services/nativeNavigationGate.ts +14 -0
- package/src/services/notificationAppCatalog.ts +21 -0
- package/src/services/notifications/notificationPolicy.ts +87 -0
- package/src/services/pages/OverlayPages.ts +86 -0
- package/src/services/pages/PageHost.ts +116 -0
- package/src/services/pages/overlayApps.ts +72 -0
- package/src/services/pages/pageEligibility.ts +30 -0
- package/src/services/settingsBridge.ts +111 -0
- package/src/services/speakerProfileStoreInstance.ts +1 -1
- package/src/services/uiShim.ts +4 -4
- package/src/stores/appVisibility.ts +45 -0
- package/src/stores/apps.ts +110 -32
- package/src/stores/bluetoothSettingKeys.ts +1 -1
- package/src/stores/display.ts +18 -7
- package/src/stores/glasses.ts +15 -1
- package/src/stores/settings.ts +175 -51
- package/src/types/applet.ts +14 -1
- package/src/types/capabilities/even-realities-g2.ts +6 -0
- package/src/types/capabilities/simulated-glasses.ts +8 -4
- package/src/types/hardware.ts +34 -1
- package/src/types/index.ts +1 -0
- package/src/utils/debouncedPatch.ts +8 -4
- package/src/utils/devMiniappLaunch.ts +5 -3
- package/src/utils/display/measurer/TextMeasurer.ts +3 -346
- package/src/utils/display/measurer/script-detection.ts +10 -218
- package/src/utils/display/pixelArt.ts +3 -0
- package/src/utils/display/profiles/g1.ts +2 -236
- package/src/utils/display/profiles/g2.ts +2 -39
- package/src/utils/display/profiles/nex.ts +2 -166
- package/src/utils/display/profiles/types.ts +9 -132
- package/src/utils/display/profiles/z100.ts +2 -198
- package/src/utils/display/scene/degrade.ts +4 -1
- package/src/utils/display/scene/differ.ts +25 -1
- package/src/utils/display/scene/index.ts +5 -0
- package/src/utils/display/scene/process.ts +196 -13
- package/src/utils/display/scene/store.ts +0 -0
- package/src/utils/display/scene/svgPath.ts +163 -0
- package/src/utils/display/scene/types.ts +0 -0
- package/src/utils/display/wrapper/TextWrapper.ts +2 -546
- package/src/utils/display/wrapper/types.ts +3 -102
- package/src/utils/hardware/hardware.ts +1 -1
- package/src/utils/timers/timers.ts +32 -4
- package/build/services/CustomDashboardModel.d.ts +0 -48
- package/build/services/CustomDashboardModel.d.ts.map +0 -1
- package/build/services/CustomDashboardModel.js +0 -73
- package/build/services/CustomDashboardModel.js.map +0 -1
- package/build/services/CustomDashboardService.d.ts +0 -63
- package/build/services/CustomDashboardService.d.ts.map +0 -1
- package/build/services/CustomDashboardService.js +0 -576
- package/build/services/CustomDashboardService.js.map +0 -1
- package/build/services/DashboardCoordinator.d.ts +0 -26
- package/build/services/DashboardCoordinator.d.ts.map +0 -1
- package/build/services/DashboardCoordinator.js +0 -125
- package/build/services/DashboardCoordinator.js.map +0 -1
- package/build/services/iosNotificationAppCatalog.d.ts +0 -13
- package/build/services/iosNotificationAppCatalog.d.ts.map +0 -1
- package/build/services/iosNotificationAppCatalog.js +0 -28
- package/build/services/iosNotificationAppCatalog.js.map +0 -1
- package/src/services/CustomDashboardModel.ts +0 -83
- package/src/services/CustomDashboardService.ts +0 -598
- package/src/services/DashboardCoordinator.ts +0 -121
- package/src/services/iosNotificationAppCatalog.ts +0 -39
|
@@ -33,6 +33,7 @@ declare class LocalSttFallbackCoordinator {
|
|
|
33
33
|
*/
|
|
34
34
|
private cloudConnected;
|
|
35
35
|
private localActive;
|
|
36
|
+
private starting;
|
|
36
37
|
private cloudAdapterAttached;
|
|
37
38
|
/**
|
|
38
39
|
* Soniox-direct (user API key) state, pushed by SonioxDirectService. While
|
|
@@ -51,6 +52,7 @@ declare class LocalSttFallbackCoordinator {
|
|
|
51
52
|
*/
|
|
52
53
|
private sttQuotaBlocked;
|
|
53
54
|
private constructor();
|
|
55
|
+
private retryAfterModelReady;
|
|
54
56
|
/**
|
|
55
57
|
* Lazy-attach the engine cloud connection listener. The coordinator is
|
|
56
58
|
* constructed at module load, before engine.start() brings up the cloud
|
|
@@ -92,6 +94,7 @@ declare class LocalSttFallbackCoordinator {
|
|
|
92
94
|
private currentReason;
|
|
93
95
|
private publishReason;
|
|
94
96
|
private startLocalStt;
|
|
97
|
+
private activateLocalStt;
|
|
95
98
|
private stopLocalStt;
|
|
96
99
|
private shouldUseLocalStt;
|
|
97
100
|
private log;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LocalSttFallbackCoordinator.d.ts","sourceRoot":"","sources":["../../src/services/LocalSttFallbackCoordinator.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;GAcG;AACH;;;;;GAKG;AACH,MAAM,MAAM,sBAAsB,GAC9B,aAAa,GACb,oBAAoB,GACpB,gBAAgB,GAChB,WAAW,GACX,sBAAsB,CAAA;AAE1B,cAAM,2BAA2B;IAC/B,OAAO,CAAC,MAAM,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AM,GAAG,IAAI;IAIlC,mEAAmE;IACnE,SAAS,IAAI,sBAAsB,GAAG,IAAI;IAI1C,oBAAoB,CAAC,gBAAgB,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,aAAa,UAAQ,GAAG,IAAI;IAQrG;;;;;;OAMG;IACH,iBAAiB,IAAI,IAAI;IAEzB;;;;OAIG;IACG,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAO9D,iBAAiB,IAAI,OAAO;IAI5B,uEAAuE;IACvE,yBAAyB,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI;IAQnE;2CACuC;IACvC,OAAO,CAAC,SAAS;YAWH,SAAS;IAmBvB;;;;OAIG;IACH,OAAO,CAAC,aAAa;IAQrB,OAAO,CAAC,aAAa;YAQP,aAAa;YASb,gBAAgB;IAqB9B,OAAO,CAAC,YAAY;IAOpB,OAAO,CAAC,iBAAiB;IAIzB,OAAO,CAAC,GAAG;CAGZ;AAED,QAAA,MAAM,2BAA2B,6BAA4C,CAAA;AAC7E,eAAe,2BAA2B,CAAA"}
|
|
@@ -16,6 +16,7 @@ class LocalSttFallbackCoordinator {
|
|
|
16
16
|
*/
|
|
17
17
|
cloudConnected = true;
|
|
18
18
|
localActive = false;
|
|
19
|
+
starting = null;
|
|
19
20
|
cloudAdapterAttached = false;
|
|
20
21
|
/**
|
|
21
22
|
* Soniox-direct (user API key) state, pushed by SonioxDirectService. While
|
|
@@ -40,6 +41,16 @@ class LocalSttFallbackCoordinator {
|
|
|
40
41
|
// registered a subscription.
|
|
41
42
|
useSettingsStore.getState().setSetting(ISLAND_SETTINGS_KEYS.localSttFallbackActive, false);
|
|
42
43
|
useSettingsStore.getState().setSetting(ISLAND_SETTINGS_KEYS.localSttFallbackReason, "");
|
|
44
|
+
sttModelManager.onModelReady(() => {
|
|
45
|
+
void this.retryAfterModelReady();
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
async retryAfterModelReady() {
|
|
49
|
+
// A model can finish downloading while the initial availability check is
|
|
50
|
+
// still pending. Wait for that attempt before retrying so readiness is
|
|
51
|
+
// never lost and native restarts cannot overlap.
|
|
52
|
+
await this.starting;
|
|
53
|
+
await this.reconcile();
|
|
43
54
|
}
|
|
44
55
|
/**
|
|
45
56
|
* Lazy-attach the engine cloud connection listener. The coordinator is
|
|
@@ -132,7 +143,12 @@ class LocalSttFallbackCoordinator {
|
|
|
132
143
|
this.attachCloudAdapterIfReady();
|
|
133
144
|
const shouldBeActive = this.shouldUseLocalStt();
|
|
134
145
|
if (shouldBeActive && !this.localActive) {
|
|
135
|
-
|
|
146
|
+
if (!this.starting) {
|
|
147
|
+
this.starting = this.startLocalStt().finally(() => {
|
|
148
|
+
this.starting = null;
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
await this.starting;
|
|
136
152
|
}
|
|
137
153
|
else if (!shouldBeActive && this.localActive) {
|
|
138
154
|
this.stopLocalStt(this.hasTranscriptionSubscription ? "primary transcription recovered" : "subscription gone");
|
|
@@ -168,6 +184,14 @@ class LocalSttFallbackCoordinator {
|
|
|
168
184
|
}
|
|
169
185
|
async startLocalStt() {
|
|
170
186
|
this.log("starting local stt");
|
|
187
|
+
try {
|
|
188
|
+
await this.activateLocalStt();
|
|
189
|
+
}
|
|
190
|
+
catch (err) {
|
|
191
|
+
this.log(`local stt startup failed: ${err}`);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
async activateLocalStt() {
|
|
171
195
|
const modelAvailable = await sttModelManager.isModelAvailable();
|
|
172
196
|
if (!modelAvailable) {
|
|
173
197
|
this.log("local stt model is not available yet — skipping activation");
|
|
@@ -177,13 +201,8 @@ class LocalSttFallbackCoordinator {
|
|
|
177
201
|
this.log("local stt activation skipped: routing changed before start completed");
|
|
178
202
|
return;
|
|
179
203
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
await BluetoothSdk.restartTranscriber();
|
|
183
|
-
}
|
|
184
|
-
catch (err) {
|
|
185
|
-
this.log(`restartTranscriber failed: ${err}`);
|
|
186
|
-
}
|
|
204
|
+
// Native rejects unless the recognizer and its processing loop are ready.
|
|
205
|
+
await BluetoothSdk.restartTranscriber();
|
|
187
206
|
if (!this.shouldUseLocalStt()) {
|
|
188
207
|
this.log("local stt activation skipped: routing changed during transcriber restart");
|
|
189
208
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LocalSttFallbackCoordinator.js","sourceRoot":"","sources":["../../src/services/LocalSttFallbackCoordinator.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,iCAAiC,CAAA;AAC1D,OAAO,EAAC,oBAAoB,EAAC,MAAM,mBAAmB,CAAA;AACtD,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAA;AACvD,OAAO,eAAe,MAAM,mBAAmB,CAAA;AA8B/C,MAAM,2BAA2B;IACvB,MAAM,CAAC,QAAQ,CAA6B;IAE5C,4BAA4B,GAAG,KAAK,CAAA;IACpC,yBAAyB,GAAG,KAAK,CAAA;IACjC,cAAc,GAAkB,IAAI,CAAA;IAC5C;;;;;OAKG;IACK,cAAc,GAAG,IAAI,CAAA;IACrB,WAAW,GAAG,KAAK,CAAA;IACnB,oBAAoB,GAAG,KAAK,CAAA;IACpC;;;;;;OAMG;IACK,mBAAmB,GAAG,KAAK,CAAA;IAC3B,mBAAmB,GAAG,IAAI,CAAA;IAClC;;;;;OAKG;IACK,eAAe,GAAG,KAAK,CAAA;IAE/B;QACE,wEAAwE;QACxE,uEAAuE;QACvE,wEAAwE;QACxE,6BAA6B;QAC7B,gBAAgB,CAAC,QAAQ,EAAE,CAAC,UAAU,CAAC,oBAAoB,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAA;QAC1F,gBAAgB,CAAC,QAAQ,EAAE,CAAC,UAAU,CAAC,oB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;IACtB,CAAC;IAEO,YAAY,CAAC,MAAc;QACjC,IAAI,CAAC,GAAG,CAAC,uBAAuB,MAAM,EAAE,CAAC,CAAA;QACzC,gBAAgB,CAAC,QAAQ,EAAE,CAAC,UAAU,CAAC,oBAAoB,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAA;QAC1F,IAAI,CAAC,WAAW,GAAG,KAAK,CAAA;QACxB,IAAI,CAAC,aAAa,EAAE,CAAA;IACtB,CAAC;IAEO,iBAAiB;QACvB,OAAO,IAAI,CAAC,4BAA4B,IAAI,CAAC,IAAI,CAAC,yBAAyB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAA;IACnG,CAAC;IAEO,GAAG,CAAC,GAAW;QACrB,OAAO,CAAC,GAAG,CAAC,sBAAsB,GAAG,EAAE,CAAC,CAAA;IAC1C,CAAC;CACF;AAED,MAAM,2BAA2B,GAAG,2BAA2B,CAAC,WAAW,EAAE,CAAA;AAC7E,eAAe,2BAA2B,CAAA","sourcesContent":["import BluetoothSdk from \"@glassly/bluetooth-sdk/internal\"\nimport {ISLAND_SETTINGS_KEYS} from \"../runtime/config\"\nimport {useSettingsStore} from \"../stores/settings\"\nimport {cloudClientService} from \"./CloudClientService\"\nimport sttModelManager from \"./STTModelManager\"\n\n/**\n * Decides whether on-device Sherpa STT should produce transcripts for local\n * miniapps, instead of (or in addition to) cloud transcription. Local STT is\n * active when the cloud is unavailable (disconnected or refusing STT for plan\n * quota) or any subscription requires `forceLocal`.\n *\n * Activation flips `localSttFallbackActive` in the settings store, which\n * the bluetooth-sdk native side reads to decide whether to feed PCM into\n * the SherpaOnnxTranscriber. Local transcripts then flow back through the\n * `local_transcription` Bridge event; the host wires that event to\n * `localMiniappRuntime.forwardEvent`, with this coordinator providing the\n * subscription-active gate so we never publish transcripts to miniapps that\n * aren't asking for them. LocalMiniappRuntime filters mixed local/cloud\n * delivery per miniapp.\n */\n/**\n * Why local STT is currently active, mirrored into the\n * `local_stt_fallback_reason` setting (\"\" while inactive) so UI can show it.\n * When several causes hold at once, the primary-path outage wins over\n * `force_local` (a forced subscription would keep local STT on either way).\n */\nexport type LocalSttFallbackReason =\n | \"force_local\"\n | \"cloud_disconnected\"\n | \"cloud_disabled\"\n | \"stt_quota\"\n | \"provider_unreachable\"\n\nclass LocalSttFallbackCoordinator {\n private static instance: LocalSttFallbackCoordinator\n\n private hasTranscriptionSubscription = false\n private hasForceLocalSubscription = false\n private activeLanguage: string | null = null\n /**\n * Default to \"cloud is up\" so we never accidentally activate local STT before\n * the cloud client has had a chance to start. We attach lazily on the first\n * subscription/reconcile pass; once attached, this field reflects the real\n * cloud-client runtime status.\n */\n private cloudConnected = true\n private localActive = false\n private cloudAdapterAttached = false\n /**\n * Soniox-direct (user API key) state, pushed by SonioxDirectService. While\n * enabled, IT is the primary transcription path — cloud connectivity is\n * irrelevant and sherpa engages on Soniox health instead. Defaults healthy\n * for the same reason cloudConnected defaults true: never activate local STT\n * before the primary has had a chance to come up.\n */\n private sonioxDirectEnabled = false\n private sonioxDirectHealthy = true\n /**\n * Cloud STT refused for plan quota (`stream.quota` blocked=true). The cloud\n * connection stays up, so this is tracked separately from `cloudConnected`:\n * for transcription purposes the cloud path is down, and sherpa takes over\n * if its model is on-device. Soniox-direct is unmetered and unaffected.\n */\n private sttQuotaBlocked = false\n\n private constructor() {\n // Reset the persisted mirror flag on boot — the in-memory state in this\n // coordinator is the source of truth, and a stale \"true\" left from the\n // previous session would cause native to feed Sherpa before any miniapp\n // registered a subscription.\n useSettingsStore.getState().setSetting(ISLAND_SETTINGS_KEYS.localSttFallbackActive, false)\n useSettingsStore.getState().setSetting(ISLAND_SETTINGS_KEYS.localSttFallbackReason, \"\")\n }\n\n /**\n * Lazy-attach the engine cloud connection listener. The coordinator is\n * constructed at module load, before engine.start() brings up the cloud\n * client, so we defer until the first reconcile.\n */\n private attachCloudAdapterIfReady(): void {\n if (this.cloudAdapterAttached) return\n this.cloudConnected = cloudClientService.isConnected()\n cloudClientService.onStatusChanged((status) => {\n const connected = status.status === \"connected\"\n if (this.cloudConnected === connected) return\n this.log(`cloud connection -> ${connected ? \"up\" : \"down\"}`)\n this.cloudConnected = connected\n void this.reconcile()\n })\n this.cloudAdapterAttached = true\n }\n\n static getInstance(): LocalSttFallbackCoordinator {\n if (!LocalSttFallbackCoordinator.instance) {\n LocalSttFallbackCoordinator.instance = new LocalSttFallbackCoordinator()\n }\n return LocalSttFallbackCoordinator.instance\n }\n\n isActive(): boolean {\n return this.localActive\n }\n\n getActiveLanguage(): string | null {\n return this.activeLanguage\n }\n\n /** The cause of the current activation, or null while inactive. */\n getReason(): LocalSttFallbackReason | null {\n return this.localActive ? this.currentReason() : null\n }\n\n onSubscriptionChange(hasTranscription: boolean, language: string | null, hasForceLocal = false): void {\n this.log(`onSubscriptionChange(hasTx=${hasTranscription}, lang=${language}, forceLocal=${hasForceLocal})`)\n this.hasTranscriptionSubscription = hasTranscription\n this.hasForceLocalSubscription = hasTranscription && hasForceLocal\n this.activeLanguage = hasTranscription ? language : null\n void this.reconcile()\n }\n\n /**\n * Informational hook, retained for API stability. No longer called: the\n * authoritative switching signal is the cloud-client adapter (local miniapps\n * are powered only by V2). v1 cloud transcripts deliberately do NOT drive this\n * coordinator anymore. Kept for future hysteresis if connection-state alone\n * proves too coarse.\n */\n onCloudTranscript(): void {}\n\n /**\n * Pushed when the cloud announces/clears an STT quota block. Awaitable so\n * the caller can inspect `isActive()` afterwards to phrase its user notice\n * (\"continuing on-device\" vs \"transcription paused\").\n */\n async onSttQuotaBlockedChange(blocked: boolean): Promise<void> {\n if (this.sttQuotaBlocked === blocked) return\n this.log(`stt quota -> ${blocked ? \"blocked\" : \"restored\"}`)\n this.sttQuotaBlocked = blocked\n await this.reconcile()\n }\n\n isSttQuotaBlocked(): boolean {\n return this.sttQuotaBlocked\n }\n\n /** Pushed by SonioxDirectService on every enable/health transition. */\n onSonioxDirectStateChange(enabled: boolean, healthy: boolean): void {\n if (this.sonioxDirectEnabled === enabled && this.sonioxDirectHealthy === healthy) return\n this.log(`soniox-direct -> enabled=${enabled} healthy=${healthy}`)\n this.sonioxDirectEnabled = enabled\n this.sonioxDirectHealthy = healthy\n void this.reconcile()\n }\n\n /** Whether the primary transcription path (Soniox-direct when a user key is\n * set, the cloud otherwise) is up. */\n private primaryUp(): boolean {\n // Cloud turned off in Privacy settings: the cloud path is not merely down,\n // it is never coming back, so on-device STT is the primary. Checked ahead\n // of `cloudConnected` because that field defaults to true (so local STT\n // doesn't pre-empt cloud at boot) and would otherwise report a path that\n // will never connect as up. Soniox-direct is a user-supplied third-party\n // key, not Glassly cloud, so it stays available.\n if (!this.sonioxDirectEnabled && cloudClientService.isCloudDisabled()) return false\n return this.sonioxDirectEnabled ? this.sonioxDirectHealthy : this.cloudConnected && !this.sttQuotaBlocked\n }\n\n private async reconcile(): Promise<void> {\n this.attachCloudAdapterIfReady()\n const shouldBeActive = this.shouldUseLocalStt()\n if (shouldBeActive && !this.localActive) {\n await this.startLocalStt()\n } else if (!shouldBeActive && this.localActive) {\n this.stopLocalStt(this.hasTranscriptionSubscription ? \"primary transcription recovered\" : \"subscription gone\")\n } else if (shouldBeActive && this.localActive) {\n // Still active, but the cause may have shifted (e.g. quota block landing\n // while already offline for a disconnect) — keep the mirror current.\n this.publishReason()\n }\n }\n\n /**\n * Ranks the concurrent causes: a dead-forever cloud path first, then the\n * primary provider's own failure, then transient outages, with `force_local`\n * only when the primary is actually up. Mirrors `primaryUp()`.\n */\n private currentReason(): LocalSttFallbackReason {\n if (!this.sonioxDirectEnabled && cloudClientService.isCloudDisabled()) return \"cloud_disabled\"\n if (this.sonioxDirectEnabled && !this.sonioxDirectHealthy) return \"provider_unreachable\"\n if (!this.sonioxDirectEnabled && !this.cloudConnected) return \"cloud_disconnected\"\n if (!this.sonioxDirectEnabled && this.sttQuotaBlocked) return \"stt_quota\"\n return \"force_local\"\n }\n\n private publishReason(): void {\n const reason = this.localActive ? this.currentReason() : \"\"\n const store = useSettingsStore.getState()\n if (store.getSetting(ISLAND_SETTINGS_KEYS.localSttFallbackReason) !== reason) {\n store.setSetting(ISLAND_SETTINGS_KEYS.localSttFallbackReason, reason)\n }\n }\n\n private async startLocalStt(): Promise<void> {\n this.log(\"starting local stt\")\n const modelAvailable = await sttModelManager.isModelAvailable()\n if (!modelAvailable) {\n this.log(\"local stt model is not available yet — skipping activation\")\n return\n }\n if (!this.shouldUseLocalStt()) {\n this.log(\"local stt activation skipped: routing changed before start completed\")\n return\n }\n try {\n // Direct btsdk call now (was a host restartTranscriber hook).\n await BluetoothSdk.restartTranscriber()\n } catch (err) {\n this.log(`restartTranscriber failed: ${err}`)\n }\n if (!this.shouldUseLocalStt()) {\n this.log(\"local stt activation skipped: routing changed during transcriber restart\")\n return\n }\n useSettingsStore.getState().setSetting(ISLAND_SETTINGS_KEYS.localSttFallbackActive, true)\n this.localActive = true\n this.publishReason()\n }\n\n private stopLocalStt(reason: string): void {\n this.log(`stopping local stt: ${reason}`)\n useSettingsStore.getState().setSetting(ISLAND_SETTINGS_KEYS.localSttFallbackActive, false)\n this.localActive = false\n this.publishReason()\n }\n\n private shouldUseLocalStt(): boolean {\n return this.hasTranscriptionSubscription && (this.hasForceLocalSubscription || !this.primaryUp())\n }\n\n private log(msg: string): void {\n console.log(`[LocalSttFallback] ${msg}`)\n }\n}\n\nconst localSttFallbackCoordinator = LocalSttFallbackCoordinator.getInstance()\nexport default localSttFallbackCoordinator\n"]}
|
|
1
|
+
{"version":3,"file":"LocalSttFallbackCoordinator.js","sourceRoot":"","sources":["../../src/services/LocalSttFallbackCoordinator.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,iCAAiC,CAAA;AAC1D,OAAO,EAAC,oBAAoB,EAAC,MAAM,mBAAmB,CAAA;AACtD,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAA;AACvD,OAAO,eAAe,MAAM,mBAAmB,CAAA;A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Y,CAAC,MAAc;QACjC,IAAI,CAAC,GAAG,CAAC,uBAAuB,MAAM,EAAE,CAAC,CAAA;QACzC,gBAAgB,CAAC,QAAQ,EAAE,CAAC,UAAU,CAAC,oBAAoB,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAA;QAC1F,IAAI,CAAC,WAAW,GAAG,KAAK,CAAA;QACxB,IAAI,CAAC,aAAa,EAAE,CAAA;IACtB,CAAC;IAEO,iBAAiB;QACvB,OAAO,IAAI,CAAC,4BAA4B,IAAI,CAAC,IAAI,CAAC,yBAAyB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAA;IACnG,CAAC;IAEO,GAAG,CAAC,GAAW;QACrB,OAAO,CAAC,GAAG,CAAC,sBAAsB,GAAG,EAAE,CAAC,CAAA;IAC1C,CAAC;CACF;AAED,MAAM,2BAA2B,GAAG,2BAA2B,CAAC,WAAW,EAAE,CAAA;AAC7E,eAAe,2BAA2B,CAAA","sourcesContent":["import BluetoothSdk from \"@glassly/bluetooth-sdk/internal\"\nimport {ISLAND_SETTINGS_KEYS} from \"../runtime/config\"\nimport {useSettingsStore} from \"../stores/settings\"\nimport {cloudClientService} from \"./CloudClientService\"\nimport sttModelManager from \"./STTModelManager\"\n\n/**\n * Decides whether on-device Sherpa STT should produce transcripts for local\n * miniapps, instead of (or in addition to) cloud transcription. Local STT is\n * active when the cloud is unavailable (disconnected or refusing STT for plan\n * quota) or any subscription requires `forceLocal`.\n *\n * Activation flips `localSttFallbackActive` in the settings store, which\n * the bluetooth-sdk native side reads to decide whether to feed PCM into\n * the SherpaOnnxTranscriber. Local transcripts then flow back through the\n * `local_transcription` Bridge event; the host wires that event to\n * `localMiniappRuntime.forwardEvent`, with this coordinator providing the\n * subscription-active gate so we never publish transcripts to miniapps that\n * aren't asking for them. LocalMiniappRuntime filters mixed local/cloud\n * delivery per miniapp.\n */\n/**\n * Why local STT is currently active, mirrored into the\n * `local_stt_fallback_reason` setting (\"\" while inactive) so UI can show it.\n * When several causes hold at once, the primary-path outage wins over\n * `force_local` (a forced subscription would keep local STT on either way).\n */\nexport type LocalSttFallbackReason =\n | \"force_local\"\n | \"cloud_disconnected\"\n | \"cloud_disabled\"\n | \"stt_quota\"\n | \"provider_unreachable\"\n\nclass LocalSttFallbackCoordinator {\n private static instance: LocalSttFallbackCoordinator\n\n private hasTranscriptionSubscription = false\n private hasForceLocalSubscription = false\n private activeLanguage: string | null = null\n /**\n * Default to \"cloud is up\" so we never accidentally activate local STT before\n * the cloud client has had a chance to start. We attach lazily on the first\n * subscription/reconcile pass; once attached, this field reflects the real\n * cloud-client runtime status.\n */\n private cloudConnected = true\n private localActive = false\n private starting: Promise<void> | null = null\n private cloudAdapterAttached = false\n /**\n * Soniox-direct (user API key) state, pushed by SonioxDirectService. While\n * enabled, IT is the primary transcription path — cloud connectivity is\n * irrelevant and sherpa engages on Soniox health instead. Defaults healthy\n * for the same reason cloudConnected defaults true: never activate local STT\n * before the primary has had a chance to come up.\n */\n private sonioxDirectEnabled = false\n private sonioxDirectHealthy = true\n /**\n * Cloud STT refused for plan quota (`stream.quota` blocked=true). The cloud\n * connection stays up, so this is tracked separately from `cloudConnected`:\n * for transcription purposes the cloud path is down, and sherpa takes over\n * if its model is on-device. Soniox-direct is unmetered and unaffected.\n */\n private sttQuotaBlocked = false\n\n private constructor() {\n // Reset the persisted mirror flag on boot — the in-memory state in this\n // coordinator is the source of truth, and a stale \"true\" left from the\n // previous session would cause native to feed Sherpa before any miniapp\n // registered a subscription.\n useSettingsStore.getState().setSetting(ISLAND_SETTINGS_KEYS.localSttFallbackActive, false)\n useSettingsStore.getState().setSetting(ISLAND_SETTINGS_KEYS.localSttFallbackReason, \"\")\n sttModelManager.onModelReady(() => {\n void this.retryAfterModelReady()\n })\n }\n\n private async retryAfterModelReady(): Promise<void> {\n // A model can finish downloading while the initial availability check is\n // still pending. Wait for that attempt before retrying so readiness is\n // never lost and native restarts cannot overlap.\n await this.starting\n await this.reconcile()\n }\n\n /**\n * Lazy-attach the engine cloud connection listener. The coordinator is\n * constructed at module load, before engine.start() brings up the cloud\n * client, so we defer until the first reconcile.\n */\n private attachCloudAdapterIfReady(): void {\n if (this.cloudAdapterAttached) return\n this.cloudConnected = cloudClientService.isConnected()\n cloudClientService.onStatusChanged((status) => {\n const connected = status.status === \"connected\"\n if (this.cloudConnected === connected) return\n this.log(`cloud connection -> ${connected ? \"up\" : \"down\"}`)\n this.cloudConnected = connected\n void this.reconcile()\n })\n this.cloudAdapterAttached = true\n }\n\n static getInstance(): LocalSttFallbackCoordinator {\n if (!LocalSttFallbackCoordinator.instance) {\n LocalSttFallbackCoordinator.instance = new LocalSttFallbackCoordinator()\n }\n return LocalSttFallbackCoordinator.instance\n }\n\n isActive(): boolean {\n return this.localActive\n }\n\n getActiveLanguage(): string | null {\n return this.activeLanguage\n }\n\n /** The cause of the current activation, or null while inactive. */\n getReason(): LocalSttFallbackReason | null {\n return this.localActive ? this.currentReason() : null\n }\n\n onSubscriptionChange(hasTranscription: boolean, language: string | null, hasForceLocal = false): void {\n this.log(`onSubscriptionChange(hasTx=${hasTranscription}, lang=${language}, forceLocal=${hasForceLocal})`)\n this.hasTranscriptionSubscription = hasTranscription\n this.hasForceLocalSubscription = hasTranscription && hasForceLocal\n this.activeLanguage = hasTranscription ? language : null\n void this.reconcile()\n }\n\n /**\n * Informational hook, retained for API stability. No longer called: the\n * authoritative switching signal is the cloud-client adapter (local miniapps\n * are powered only by V2). v1 cloud transcripts deliberately do NOT drive this\n * coordinator anymore. Kept for future hysteresis if connection-state alone\n * proves too coarse.\n */\n onCloudTranscript(): void {}\n\n /**\n * Pushed when the cloud announces/clears an STT quota block. Awaitable so\n * the caller can inspect `isActive()` afterwards to phrase its user notice\n * (\"continuing on-device\" vs \"transcription paused\").\n */\n async onSttQuotaBlockedChange(blocked: boolean): Promise<void> {\n if (this.sttQuotaBlocked === blocked) return\n this.log(`stt quota -> ${blocked ? \"blocked\" : \"restored\"}`)\n this.sttQuotaBlocked = blocked\n await this.reconcile()\n }\n\n isSttQuotaBlocked(): boolean {\n return this.sttQuotaBlocked\n }\n\n /** Pushed by SonioxDirectService on every enable/health transition. */\n onSonioxDirectStateChange(enabled: boolean, healthy: boolean): void {\n if (this.sonioxDirectEnabled === enabled && this.sonioxDirectHealthy === healthy) return\n this.log(`soniox-direct -> enabled=${enabled} healthy=${healthy}`)\n this.sonioxDirectEnabled = enabled\n this.sonioxDirectHealthy = healthy\n void this.reconcile()\n }\n\n /** Whether the primary transcription path (Soniox-direct when a user key is\n * set, the cloud otherwise) is up. */\n private primaryUp(): boolean {\n // Cloud turned off in Privacy settings: the cloud path is not merely down,\n // it is never coming back, so on-device STT is the primary. Checked ahead\n // of `cloudConnected` because that field defaults to true (so local STT\n // doesn't pre-empt cloud at boot) and would otherwise report a path that\n // will never connect as up. Soniox-direct is a user-supplied third-party\n // key, not Glassly cloud, so it stays available.\n if (!this.sonioxDirectEnabled && cloudClientService.isCloudDisabled()) return false\n return this.sonioxDirectEnabled ? this.sonioxDirectHealthy : this.cloudConnected && !this.sttQuotaBlocked\n }\n\n private async reconcile(): Promise<void> {\n this.attachCloudAdapterIfReady()\n const shouldBeActive = this.shouldUseLocalStt()\n if (shouldBeActive && !this.localActive) {\n if (!this.starting) {\n this.starting = this.startLocalStt().finally(() => {\n this.starting = null\n })\n }\n await this.starting\n } else if (!shouldBeActive && this.localActive) {\n this.stopLocalStt(this.hasTranscriptionSubscription ? \"primary transcription recovered\" : \"subscription gone\")\n } else if (shouldBeActive && this.localActive) {\n // Still active, but the cause may have shifted (e.g. quota block landing\n // while already offline for a disconnect) — keep the mirror current.\n this.publishReason()\n }\n }\n\n /**\n * Ranks the concurrent causes: a dead-forever cloud path first, then the\n * primary provider's own failure, then transient outages, with `force_local`\n * only when the primary is actually up. Mirrors `primaryUp()`.\n */\n private currentReason(): LocalSttFallbackReason {\n if (!this.sonioxDirectEnabled && cloudClientService.isCloudDisabled()) return \"cloud_disabled\"\n if (this.sonioxDirectEnabled && !this.sonioxDirectHealthy) return \"provider_unreachable\"\n if (!this.sonioxDirectEnabled && !this.cloudConnected) return \"cloud_disconnected\"\n if (!this.sonioxDirectEnabled && this.sttQuotaBlocked) return \"stt_quota\"\n return \"force_local\"\n }\n\n private publishReason(): void {\n const reason = this.localActive ? this.currentReason() : \"\"\n const store = useSettingsStore.getState()\n if (store.getSetting(ISLAND_SETTINGS_KEYS.localSttFallbackReason) !== reason) {\n store.setSetting(ISLAND_SETTINGS_KEYS.localSttFallbackReason, reason)\n }\n }\n\n private async startLocalStt(): Promise<void> {\n this.log(\"starting local stt\")\n try {\n await this.activateLocalStt()\n } catch (err) {\n this.log(`local stt startup failed: ${err}`)\n }\n }\n\n private async activateLocalStt(): Promise<void> {\n const modelAvailable = await sttModelManager.isModelAvailable()\n if (!modelAvailable) {\n this.log(\"local stt model is not available yet — skipping activation\")\n return\n }\n if (!this.shouldUseLocalStt()) {\n this.log(\"local stt activation skipped: routing changed before start completed\")\n return\n }\n // Native rejects unless the recognizer and its processing loop are ready.\n await BluetoothSdk.restartTranscriber()\n if (!this.shouldUseLocalStt()) {\n this.log(\"local stt activation skipped: routing changed during transcriber restart\")\n return\n }\n useSettingsStore.getState().setSetting(ISLAND_SETTINGS_KEYS.localSttFallbackActive, true)\n this.localActive = true\n this.publishReason()\n }\n\n private stopLocalStt(reason: string): void {\n this.log(`stopping local stt: ${reason}`)\n useSettingsStore.getState().setSetting(ISLAND_SETTINGS_KEYS.localSttFallbackActive, false)\n this.localActive = false\n this.publishReason()\n }\n\n private shouldUseLocalStt(): boolean {\n return this.hasTranscriptionSubscription && (this.hasForceLocalSubscription || !this.primaryUp())\n }\n\n private log(msg: string): void {\n console.log(`[LocalSttFallback] ${msg}`)\n }\n}\n\nconst localSttFallbackCoordinator = LocalSttFallbackCoordinator.getInstance()\nexport default localSttFallbackCoordinator\n"]}
|
|
@@ -18,24 +18,16 @@
|
|
|
18
18
|
*/
|
|
19
19
|
import type { MemoryEntry, MemoryNoteSource, MemorySession, MemorySummary } from "@glassly/miniapp";
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
21
|
+
* Physical bounds. There is no age cap: the timeline stays until the user
|
|
22
|
+
* deletes it (clear()/removeScope). The entry cap bounds the write cost —
|
|
23
|
+
* every persist re-serializes the whole timeline, so it is a perf ceiling as
|
|
24
|
+
* much as a product number — and the summary cap keeps one row per hour for
|
|
25
|
+
* about half a year of round-the-clock use, far longer at a normal pace.
|
|
25
26
|
*/
|
|
26
|
-
export
|
|
27
|
-
maxAgeMs: number;
|
|
27
|
+
export declare const MEMORY_BOUNDS: {
|
|
28
28
|
maxEntries: number;
|
|
29
29
|
maxSummaries: number;
|
|
30
|
-
}
|
|
31
|
-
/** Free-tier visibility: a 14-day rolling window. */
|
|
32
|
-
export declare const STANDARD_RETENTION: MemoryRetentionPolicy;
|
|
33
|
-
/**
|
|
34
|
-
* Plus/Pro visibility — and the store's PHYSICAL bounds for every tier. The
|
|
35
|
-
* entry cap also bounds the write cost — every persist re-serializes the
|
|
36
|
-
* whole timeline, so this cap is a perf ceiling as much as a product number.
|
|
37
|
-
*/
|
|
38
|
-
export declare const EXTENDED_RETENTION: MemoryRetentionPolicy;
|
|
30
|
+
};
|
|
39
31
|
export interface MemoryStoreBackend {
|
|
40
32
|
get(key: string): unknown | null;
|
|
41
33
|
set(key: string, value: unknown): void;
|
|
@@ -50,13 +42,6 @@ export interface MemoryStoreHooks {
|
|
|
50
42
|
* utterance. Set to 0 to persist synchronously (tests).
|
|
51
43
|
*/
|
|
52
44
|
writeDebounceMs?: number;
|
|
53
|
-
/**
|
|
54
|
-
* Visibility policy resolver, consulted at every read. A function (not a
|
|
55
|
-
* value) so the host can flip between STANDARD and EXTENDED as the user's
|
|
56
|
-
* subscription changes without rebuilding the store. Absent = standard.
|
|
57
|
-
* Never affects what is STORED — pruning is fixed at EXTENDED bounds.
|
|
58
|
-
*/
|
|
59
|
-
getRetention?: () => MemoryRetentionPolicy;
|
|
60
45
|
}
|
|
61
46
|
export interface MemoryStats {
|
|
62
47
|
entryCount: number;
|
|
@@ -157,17 +142,7 @@ export declare class MemoryStore {
|
|
|
157
142
|
* are left in place; its new build reads through the memory bridge instead.
|
|
158
143
|
*/
|
|
159
144
|
private migrateFromAssist;
|
|
160
|
-
|
|
161
|
-
/** Entries inside the active tier's visibility window, oldest first. */
|
|
162
|
-
private visibleEntries;
|
|
163
|
-
private visibleSummaries;
|
|
164
|
-
/**
|
|
165
|
-
* Physical bounds, ALWAYS the extended policy regardless of tier. A free or
|
|
166
|
-
* lapsed user's older timeline stays on disk (reads just can't see past
|
|
167
|
-
* their window) so upgrading — or re-upgrading — restores it rather than
|
|
168
|
-
* finding it deleted. Deleting remains the user's call: clear()/removeScope
|
|
169
|
-
* operate on the physical store.
|
|
170
|
-
*/
|
|
145
|
+
/** Keep the newest MEMORY_BOUNDS.maxEntries; nothing goes for age — deleting is the user's call. */
|
|
171
146
|
private prune;
|
|
172
147
|
private key;
|
|
173
148
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MemoryStore.d.ts","sourceRoot":"","sources":["../../src/services/MemoryStore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAC,WAAW,EAAE,gBAAgB,EAAE,aAAa,EAAE,aAAa,EAAC,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"MemoryStore.d.ts","sourceRoot":"","sources":["../../src/services/MemoryStore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAC,WAAW,EAAE,gBAAgB,EAAE,aAAa,EAAE,aAAa,EAAC,MAAM,kBAAkB,CAAA;AA2BjG;;;;;;GAMG;AACH,eAAO,MAAM,aAAa;;;CAGzB,CAAA;AAWD,MAAM,WAAW,kBAAkB;IACjC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OA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AE,CAAA;QAChB,KAAK,CAAC,EAAE,MAAM,CAAA;KACf,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAI1B;;;;OAIG;IACG,MAAM,CAAC,CAAC,EAAE;QACd,OAAO,CAAC,EAAE,MAAM,CAAA;QAChB,OAAO,CAAC,EAAE,MAAM,CAAA;QAChB,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;QAChB,KAAK,CAAC,EAAE,MAAM,CAAA;KACf,GAAG,OAAO,CAAC;QAAC,OAAO,EAAE,WAAW,EAAE,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAC,CAAC;IAYpD,WAAW,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;IAK7C,qEAAqE;IAC/D,kBAAkB,CAAC,KAAK,GAAE,MAAmB,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAc5E,4DAA4D;IACtD,UAAU,CAAC,KAAK,EAAE,SAAS,GAAG,KAAK,GAAG,KAAK,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;YAkClE,YAAY;YAYZ,OAAO;IAoBrB;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;IAyDzB,oGAAoG;IACpG,OAAO,CAAC,KAAK;IAKb,OAAO,CAAC,GAAG;IAIX;;;;;OAKG;IACH,OAAO,CAAC,kBAAkB;YAgBZ,UAAU;YAWV,gBAAgB;IAK9B,OAAO,CAAC,WAAW;CASpB"}
|
|
@@ -17,10 +17,16 @@
|
|
|
17
17
|
* user-scoped keys so existing history survives the move.
|
|
18
18
|
*/
|
|
19
19
|
import { searchMemoryEntries } from "../utils/memory/search";
|
|
20
|
+
import { BgTimer } from "../utils/timers";
|
|
20
21
|
const KEY_ROOT = "memory_";
|
|
21
22
|
const LOG_SUFFIX = "log";
|
|
22
23
|
const SUMMARY_SUFFIX = "summaries";
|
|
23
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* The pre-memory-layer Assist miniapp whose storage namespace we migrate.
|
|
26
|
+
* Assist now ships as com.glassly.assistant; the timeline it reads is
|
|
27
|
+
* user-scoped (KEY_ROOT below), so the rename needs no second migration and
|
|
28
|
+
* this constant stays pinned to the old namespace.
|
|
29
|
+
*/
|
|
24
30
|
const LEGACY_ASSIST_PACKAGE = "com.tetramo.assistant";
|
|
25
31
|
const LEGACY_STORAGE_ROOT = "localstorage_";
|
|
26
32
|
const LEGACY_LOG_KEY = "assistant:session-log";
|
|
@@ -30,22 +36,16 @@ const LEGACY_SUMMARY_KEY = "assistant:hourly-summaries";
|
|
|
30
36
|
const LEGACY_TRANSCRIPT_KEY = "assistant:transcript-log";
|
|
31
37
|
const LEGACY_NOTES_KEY = "assistant:notes";
|
|
32
38
|
const HOUR_MS = 60 * 60 * 1000;
|
|
33
|
-
const DAY_MS = 24 * HOUR_MS;
|
|
34
|
-
/** Free-tier visibility: a 14-day rolling window. */
|
|
35
|
-
export const STANDARD_RETENTION = {
|
|
36
|
-
maxAgeMs: 14 * DAY_MS,
|
|
37
|
-
maxEntries: 4000,
|
|
38
|
-
maxSummaries: 24 * 14,
|
|
39
|
-
};
|
|
40
39
|
/**
|
|
41
|
-
*
|
|
42
|
-
* entry cap
|
|
43
|
-
* whole timeline, so
|
|
40
|
+
* Physical bounds. There is no age cap: the timeline stays until the user
|
|
41
|
+
* deletes it (clear()/removeScope). The entry cap bounds the write cost —
|
|
42
|
+
* every persist re-serializes the whole timeline, so it is a perf ceiling as
|
|
43
|
+
* much as a product number — and the summary cap keeps one row per hour for
|
|
44
|
+
* about half a year of round-the-clock use, far longer at a normal pace.
|
|
44
45
|
*/
|
|
45
|
-
export const
|
|
46
|
-
maxAgeMs: 180 * DAY_MS,
|
|
46
|
+
export const MEMORY_BOUNDS = {
|
|
47
47
|
maxEntries: 24_000,
|
|
48
|
-
maxSummaries:
|
|
48
|
+
maxSummaries: 4320,
|
|
49
49
|
};
|
|
50
50
|
const QUERY_LIMIT_CAP = 200;
|
|
51
51
|
const QUERY_LIMIT_DEFAULT = 60;
|
|
@@ -87,7 +87,7 @@ export class MemoryStore {
|
|
|
87
87
|
*/
|
|
88
88
|
async flush() {
|
|
89
89
|
if (this.logFlushTimer) {
|
|
90
|
-
clearTimeout(this.logFlushTimer);
|
|
90
|
+
BgTimer.clearTimeout(this.logFlushTimer);
|
|
91
91
|
this.logFlushTimer = null;
|
|
92
92
|
}
|
|
93
93
|
if (this.logDirty)
|
|
@@ -190,7 +190,7 @@ export class MemoryStore {
|
|
|
190
190
|
}
|
|
191
191
|
async addSummary(summary) {
|
|
192
192
|
await this.ensureLoaded();
|
|
193
|
-
const { maxSummaries } =
|
|
193
|
+
const { maxSummaries } = MEMORY_BOUNDS;
|
|
194
194
|
this.summaries = this.summaries.filter((s) => s.hourStart !== summary.hourStart);
|
|
195
195
|
this.summaries.push(summary);
|
|
196
196
|
if (this.summaries.length > maxSummaries) {
|
|
@@ -199,32 +199,26 @@ export class MemoryStore {
|
|
|
199
199
|
await this.persistSummaries();
|
|
200
200
|
this.emitChanged();
|
|
201
201
|
}
|
|
202
|
-
// === Reads ===
|
|
203
|
-
//
|
|
204
|
-
// Every read goes through the VISIBLE view: entries inside the active
|
|
205
|
-
// tier's window. Older data may still be stored (see prune) — it is frozen,
|
|
206
|
-
// not deleted, so an upgrade widens these views instantly.
|
|
202
|
+
// === Reads === (the whole stored timeline; nothing is hidden by age)
|
|
207
203
|
/** Entries in [sinceMs, untilMs), newest last. */
|
|
208
204
|
async window(sinceMs, untilMs = Date.now()) {
|
|
209
205
|
await this.ensureLoaded();
|
|
210
|
-
return this.
|
|
206
|
+
return this.entries.filter((e) => e.at >= sinceMs && e.at < untilMs);
|
|
211
207
|
}
|
|
212
208
|
/** All note entries, newest first (Settings > Memory list). */
|
|
213
209
|
async notes() {
|
|
214
210
|
await this.ensureLoaded();
|
|
215
|
-
return this.
|
|
216
|
-
.filter((e) => e.kind === "note")
|
|
217
|
-
.sort((a, b) => b.at - a.at);
|
|
211
|
+
return this.entries.filter((e) => e.kind === "note").sort((a, b) => b.at - a.at);
|
|
218
212
|
}
|
|
219
213
|
async stats() {
|
|
220
214
|
await this.ensureLoaded();
|
|
221
|
-
const visible = this.
|
|
215
|
+
const visible = this.entries;
|
|
222
216
|
const noteCount = visible.filter((e) => e.kind === "note").length;
|
|
223
217
|
return {
|
|
224
218
|
entryCount: visible.length,
|
|
225
219
|
lineCount: visible.length - noteCount,
|
|
226
220
|
noteCount,
|
|
227
|
-
summaryCount: this.
|
|
221
|
+
summaryCount: this.summaries.filter((s) => s.text.trim()).length,
|
|
228
222
|
oldestAt: visible.length > 0 ? visible[0].at : null,
|
|
229
223
|
};
|
|
230
224
|
}
|
|
@@ -232,13 +226,13 @@ export class MemoryStore {
|
|
|
232
226
|
async sessionList() {
|
|
233
227
|
await this.ensureLoaded();
|
|
234
228
|
const byHour = new Map();
|
|
235
|
-
for (const e of this.
|
|
229
|
+
for (const e of this.entries) {
|
|
236
230
|
const h = hourStartOf(e.at);
|
|
237
231
|
const list = byHour.get(h) ?? [];
|
|
238
232
|
list.push(e);
|
|
239
233
|
byHour.set(h, list);
|
|
240
234
|
}
|
|
241
|
-
const summaryByHour = new Map(this.
|
|
235
|
+
const summaryByHour = new Map(this.summaries.map((s) => [s.hourStart, s.text]));
|
|
242
236
|
return [...byHour.entries()]
|
|
243
237
|
.map(([hourStart, entries]) => {
|
|
244
238
|
entries.sort((a, b) => a.at - b.at);
|
|
@@ -269,7 +263,7 @@ export class MemoryStore {
|
|
|
269
263
|
async search(q) {
|
|
270
264
|
await this.ensureLoaded();
|
|
271
265
|
const limit = q.limit && q.limit > 0 ? Math.min(q.limit, QUERY_LIMIT_CAP) : QUERY_LIMIT_DEFAULT;
|
|
272
|
-
return searchMemoryEntries(this.
|
|
266
|
+
return searchMemoryEntries(this.entries, {
|
|
273
267
|
sinceMs: q.sinceMs,
|
|
274
268
|
untilMs: q.untilMs,
|
|
275
269
|
contains: q.contains,
|
|
@@ -279,7 +273,7 @@ export class MemoryStore {
|
|
|
279
273
|
}
|
|
280
274
|
async summaryList() {
|
|
281
275
|
await this.ensureLoaded();
|
|
282
|
-
return this.
|
|
276
|
+
return [...this.summaries].sort((a, b) => b.hourStart - a.hourStart);
|
|
283
277
|
}
|
|
284
278
|
/** Most recent COMPLETED hour with lines but no summary, or null. */
|
|
285
279
|
async pendingSummaryHour(nowMs = Date.now()) {
|
|
@@ -287,7 +281,7 @@ export class MemoryStore {
|
|
|
287
281
|
const currentHour = hourStartOf(nowMs);
|
|
288
282
|
const summarized = new Set(this.summaries.map((s) => s.hourStart));
|
|
289
283
|
const hours = new Set();
|
|
290
|
-
for (const e of this.
|
|
284
|
+
for (const e of this.entries) {
|
|
291
285
|
if (e.kind !== "line")
|
|
292
286
|
continue;
|
|
293
287
|
const h = hourStartOf(e.at);
|
|
@@ -428,29 +422,9 @@ export class MemoryStore {
|
|
|
428
422
|
console.warn("MemoryStore: Assist migration failed:", err instanceof Error ? err.message : err);
|
|
429
423
|
}
|
|
430
424
|
}
|
|
431
|
-
|
|
432
|
-
return this.hooks.getRetention?.() ?? STANDARD_RETENTION;
|
|
433
|
-
}
|
|
434
|
-
/** Entries inside the active tier's visibility window, oldest first. */
|
|
435
|
-
visibleEntries() {
|
|
436
|
-
const cutoff = Date.now() - this.retention().maxAgeMs;
|
|
437
|
-
return this.entries.filter((e) => e.at >= cutoff);
|
|
438
|
-
}
|
|
439
|
-
visibleSummaries() {
|
|
440
|
-
const cutoff = Date.now() - this.retention().maxAgeMs;
|
|
441
|
-
return this.summaries.filter((s) => s.hourStart >= cutoff);
|
|
442
|
-
}
|
|
443
|
-
/**
|
|
444
|
-
* Physical bounds, ALWAYS the extended policy regardless of tier. A free or
|
|
445
|
-
* lapsed user's older timeline stays on disk (reads just can't see past
|
|
446
|
-
* their window) so upgrading — or re-upgrading — restores it rather than
|
|
447
|
-
* finding it deleted. Deleting remains the user's call: clear()/removeScope
|
|
448
|
-
* operate on the physical store.
|
|
449
|
-
*/
|
|
425
|
+
/** Keep the newest MEMORY_BOUNDS.maxEntries; nothing goes for age — deleting is the user's call. */
|
|
450
426
|
prune() {
|
|
451
|
-
const {
|
|
452
|
-
const cutoff = Date.now() - maxAgeMs;
|
|
453
|
-
this.entries = this.entries.filter((e) => e.at >= cutoff);
|
|
427
|
+
const { maxEntries } = MEMORY_BOUNDS;
|
|
454
428
|
if (this.entries.length > maxEntries)
|
|
455
429
|
this.entries = this.entries.slice(-maxEntries);
|
|
456
430
|
}
|
|
@@ -472,7 +446,7 @@ export class MemoryStore {
|
|
|
472
446
|
this.logDirty = true;
|
|
473
447
|
if (this.logFlushTimer)
|
|
474
448
|
return;
|
|
475
|
-
this.logFlushTimer = setTimeout(() => {
|
|
449
|
+
this.logFlushTimer = BgTimer.setTimeout(() => {
|
|
476
450
|
this.logFlushTimer = null;
|
|
477
451
|
void this.persistLog().catch((err) => console.warn("MemoryStore: debounced log write failed:", err instanceof Error ? err.message : err));
|
|
478
452
|
}, delay);
|
|
@@ -481,7 +455,7 @@ export class MemoryStore {
|
|
|
481
455
|
// Any write of the full array satisfies whatever the debounce was holding.
|
|
482
456
|
this.logDirty = false;
|
|
483
457
|
if (this.logFlushTimer) {
|
|
484
|
-
clearTimeout(this.logFlushTimer);
|
|
458
|
+
BgTimer.clearTimeout(this.logFlushTimer);
|
|
485
459
|
this.logFlushTimer = null;
|
|
486
460
|
}
|
|
487
461
|
if (this.loadedUserId == null)
|