@glassly/engine 0.3.2-beta.572 → 0.3.2-beta.597
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 +1 -1
- package/build/engine.d.ts +15 -1
- package/build/engine.d.ts.map +1 -1
- package/build/engine.js +7 -3
- package/build/engine.js.map +1 -1
- package/build/facades/dev.d.ts +2 -2
- package/build/facades/dev.d.ts.map +1 -1
- package/build/facades/dev.js +2 -2
- package/build/facades/dev.js.map +1 -1
- package/build/facades/glasses.d.ts +20 -0
- package/build/facades/glasses.d.ts.map +1 -1
- package/build/facades/glasses.js +21 -0
- package/build/facades/glasses.js.map +1 -1
- package/build/facades/pairing.js +1 -1
- package/build/facades/pairing.js.map +1 -1
- package/build/facades/reports.js +2 -2
- package/build/facades/reports.js.map +1 -1
- package/build/facades/session.d.ts +1 -1
- package/build/facades/session.js +2 -2
- package/build/facades/session.js.map +1 -1
- package/build/generated/releaseMetadata.js +3 -3
- package/build/generated/releaseMetadata.js.map +1 -1
- package/build/index.d.ts +3 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +3 -1
- package/build/index.js.map +1 -1
- package/build/runtime/bootstrap.d.ts +2 -2
- package/build/runtime/bootstrap.d.ts.map +1 -1
- package/build/runtime/bootstrap.js.map +1 -1
- package/build/services/CloudAudioSubscriptionSync.d.ts +2 -2
- package/build/services/CloudAudioSubscriptionSync.js +2 -2
- package/build/services/CloudAudioSubscriptionSync.js.map +1 -1
- package/build/services/CloudClientService.d.ts +2 -2
- package/build/services/CloudClientService.d.ts.map +1 -1
- package/build/services/CloudClientService.js +4 -4
- package/build/services/CloudClientService.js.map +1 -1
- package/build/services/CloudTranscriptE2EMetrics.d.ts +2 -2
- package/build/services/CloudTranscriptE2EMetrics.d.ts.map +1 -1
- package/build/services/CloudTranscriptE2EMetrics.js +3 -3
- package/build/services/CloudTranscriptE2EMetrics.js.map +1 -1
- package/build/services/DeviceEventRouter.d.ts.map +1 -1
- package/build/services/DeviceEventRouter.js +5 -0
- package/build/services/DeviceEventRouter.js.map +1 -1
- package/build/services/GestureDotsService.d.ts +9 -9
- package/build/services/GestureDotsService.d.ts.map +1 -1
- package/build/services/GestureDotsService.js +75 -50
- package/build/services/GestureDotsService.js.map +1 -1
- package/build/services/GlassesTouchInput.d.ts +1 -1
- package/build/services/GlassesTouchInput.d.ts.map +1 -1
- package/build/services/GlassesTouchInput.js +7 -4
- package/build/services/GlassesTouchInput.js.map +1 -1
- package/build/services/LocalMiniappRuntime.d.ts +1 -1
- package/build/services/LocalMiniappRuntime.d.ts.map +1 -1
- package/build/services/LocalMiniappRuntime.js +26 -7
- package/build/services/LocalMiniappRuntime.js.map +1 -1
- package/build/services/LocalSttFallbackCoordinator.d.ts +5 -2
- package/build/services/LocalSttFallbackCoordinator.d.ts.map +1 -1
- package/build/services/LocalSttFallbackCoordinator.js +7 -3
- package/build/services/LocalSttFallbackCoordinator.js.map +1 -1
- package/build/services/PhonePhotoCoordinator.d.ts +1 -1
- package/build/services/PhonePhotoCoordinator.js +4 -4
- package/build/services/PhonePhotoCoordinator.js.map +1 -1
- package/build/services/PhoneStreamCoordinator.d.ts +1 -1
- package/build/services/PhoneStreamCoordinator.js +1 -1
- package/build/services/PhoneStreamCoordinator.js.map +1 -1
- package/build/services/SupportProfileSync.d.ts +1 -1
- package/build/services/SupportProfileSync.js +2 -2
- package/build/services/SupportProfileSync.js.map +1 -1
- package/build/services/TranscriptionRouting.d.ts +6 -1
- package/build/services/TranscriptionRouting.d.ts.map +1 -1
- package/build/services/TranscriptionRouting.js +7 -3
- package/build/services/TranscriptionRouting.js.map +1 -1
- package/build/services/cloudStreamApi.d.ts +2 -2
- package/build/services/cloudStreamApi.js +2 -2
- package/build/services/cloudStreamApi.js.map +1 -1
- package/build/services/gestureDotGlyphs.d.ts +1 -1
- package/build/services/gestureDotGlyphs.d.ts.map +1 -1
- package/build/services/gestureDotGlyphs.js +5 -0
- package/build/services/gestureDotGlyphs.js.map +1 -1
- package/build/services/neuralBand/MetaAuth.d.ts +31 -0
- package/build/services/neuralBand/MetaAuth.d.ts.map +1 -0
- package/build/services/neuralBand/MetaAuth.js +161 -0
- package/build/services/neuralBand/MetaAuth.js.map +1 -0
- package/build/services/neuralBand/NeuralBandInput.d.ts +50 -0
- package/build/services/neuralBand/NeuralBandInput.d.ts.map +1 -0
- package/build/services/neuralBand/NeuralBandInput.js +114 -0
- package/build/services/neuralBand/NeuralBandInput.js.map +1 -0
- package/build/services/neuralBand/NeuralBandSettingsSync.d.ts +3 -0
- package/build/services/neuralBand/NeuralBandSettingsSync.d.ts.map +1 -0
- package/build/services/neuralBand/NeuralBandSettingsSync.js +52 -0
- package/build/services/neuralBand/NeuralBandSettingsSync.js.map +1 -0
- package/build/services/neuralBand/sha256.d.ts +7 -0
- package/build/services/neuralBand/sha256.d.ts.map +1 -0
- package/build/services/neuralBand/sha256.js +68 -0
- package/build/services/neuralBand/sha256.js.map +1 -0
- package/build/services/soniox/SonioxRealtimeClient.d.ts +2 -2
- package/build/services/soniox/SonioxRealtimeClient.js +2 -2
- package/build/services/soniox/SonioxRealtimeClient.js.map +1 -1
- package/build/services/soniox/SonioxTokenAssembler.d.ts +1 -1
- package/build/services/soniox/SonioxTokenAssembler.js +1 -1
- package/build/services/soniox/SonioxTokenAssembler.js.map +1 -1
- package/build/stores/cloudClientStatus.js +1 -1
- package/build/stores/cloudClientStatus.js.map +1 -1
- package/build/stores/settings.d.ts.map +1 -1
- package/build/stores/settings.js +25 -7
- package/build/stores/settings.js.map +1 -1
- package/build/types/enums.d.ts +2 -1
- package/build/types/enums.d.ts.map +1 -1
- package/build/types/enums.js +1 -0
- package/build/types/enums.js.map +1 -1
- package/build/utils/cloudClient/cloudSecureStore.js +2 -2
- package/build/utils/cloudClient/cloudSecureStore.js.map +1 -1
- package/package.json +7 -7
- package/src/engine.ts +7 -3
- package/src/facades/dev.ts +2 -2
- package/src/facades/glasses.ts +27 -0
- package/src/facades/pairing.ts +1 -1
- package/src/facades/reports.ts +2 -2
- package/src/facades/session.ts +2 -2
- package/src/generated/releaseMetadata.ts +3 -3
- package/src/index.ts +15 -1
- package/src/runtime/bootstrap.ts +2 -2
- package/src/services/CloudAudioSubscriptionSync.ts +2 -2
- package/src/services/CloudClientService.ts +4 -4
- package/src/services/CloudTranscriptE2EMetrics.ts +3 -3
- package/src/services/DeviceEventRouter.ts +5 -0
- package/src/services/GestureDotsService.ts +72 -49
- package/src/services/GlassesTouchInput.ts +13 -5
- package/src/services/LocalMiniappRuntime.ts +46 -24
- package/src/services/LocalSttFallbackCoordinator.ts +18 -4
- package/src/services/PhonePhotoCoordinator.ts +4 -4
- package/src/services/PhoneStreamCoordinator.ts +1 -1
- package/src/services/SupportProfileSync.ts +2 -2
- package/src/services/TranscriptionRouting.ts +12 -4
- package/src/services/cloudStreamApi.ts +3 -3
- package/src/services/gestureDotGlyphs.ts +6 -1
- package/src/services/neuralBand/MetaAuth.ts +192 -0
- package/src/services/neuralBand/NeuralBandInput.ts +148 -0
- package/src/services/neuralBand/NeuralBandSettingsSync.ts +63 -0
- package/src/services/neuralBand/sha256.ts +70 -0
- package/src/services/soniox/SonioxRealtimeClient.ts +2 -2
- package/src/services/soniox/SonioxTokenAssembler.ts +1 -1
- package/src/stores/cloudClientStatus.ts +1 -1
- package/src/stores/settings.ts +25 -7
- package/src/types/enums.ts +1 -0
- package/src/utils/cloudClient/cloudSecureStore.ts +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CloudClientService.js","sourceRoot":"","sources":["../../src/services/CloudClientService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAC,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,gBAAgB,EAAC,MAAM,oCAAoC,CAAA;AAQ7G,OAAO,EAAC,QAAQ,EAAC,MAAM,cAAc,CAAA;AAGrC,OAAO,YAAY,MAAM,iCAAiC,CAAA;AAC1D,OAAO,WAAW,MAAM,gBAAgB,C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a,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAA;YACjD,CAAC;YACD,cAAc,CAAC,GAAG,IAAwD;gBACxE,OAAO,aAAa,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,CAAA;YACxD,CAAC;YACD,QAAQ,CAAC,GAAG,IAAkD;gBAC5D,OAAO,aAAa,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAA;YAClD,CAAC;SACF;QACD,cAAc,EAAE;YACd,MAAM,CAAC,GAAG,IAAuD;gBAC/D,OAAO,aAAa,EAAE,CAAC,cAAc,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAA;YACvD,CAAC;SACF;KACF;IAED,qBAAqB;QACnB,OAAO,kBAAkB,CAAC,MAAM,GAAG,CAAC,CAAA;IACtC,CAAC;CACF,CAAA","sourcesContent":["/**\n * Owns the singleton `@glassly/cloud-client` (CloudClient) for the engine runtime\n * — the keystone move that pulls backend comms INTO engine.\n *\n * engine constructs the client from engine-owned pieces (the native UDP socket,\n * the MMKV secure store, the cloud-status store) plus the two things the host\n * provides through the engine front door: `auth.getSubjectToken` (the one\n * permanent seam — the OEM owns login) and the resolved cloud endpoints\n * (`config.coreUrl/runtimeUrl`, computed host-side from dev/settings). On init it\n * exposes cloud runtime methods directly from this service, so the host no longer\n * injects a cloud adapter — engine owns construction and wiring.\n *\n * The local-miniapp path drives the cloud's transcription/translation through\n * this service.\n */\nimport {CloudClient, setNativeHttp, setNativeUdp, setSecureStorage} from \"@glassly/cloud-client/react-native\"\nimport type {\n PreinstalledMiniappRegistry,\n RuntimeSnapshot,\n StoreCatalogResponse,\n StoreListing,\n} from \"@glassly/cloud-client/react-native\"\nimport type {SubjectTokenType} from \"@glassly/cloud-client\"\nimport {Platform} from \"react-native\"\nimport type {AudioSubscription, QuotaStatusPayload, TranscriptionData, TranslationData} from \"@glassly/cloud-protocol\"\n\nimport BluetoothSdk from \"@glassly/bluetooth-sdk/internal\"\nimport CrustModule from \"@glassly/crust\"\nimport {getAuth, getConfigValues} from \"../runtime/bootstrap\"\nimport {useSettingsStore, SETTINGS} from \"../stores/settings\"\nimport {type CloudClientStatusSnapshot, type MiniappAuthToken} from \"../runtime/config\"\nimport {createCloudUdpSocket} from \"../utils/cloudClient/RnUdpAdapter\"\nimport {cloudSecureStore} from \"../utils/cloudClient/cloudSecureStore\"\nimport {storage as mmkvStorage} from \"../utils/storage\"\nimport {useCloudClientStatusStore} from \"../stores/cloudClientStatus\"\nimport {islandNotifications} from \"./NotificationsEmitter\"\nimport {BgTimer} from \"../utils/timers\"\nimport {logCloudV2TranscriptMetric} from \"./CloudTranscriptE2EMetrics\"\nimport {isLocalUserId, LocalMiniappUserIdentity} from \"./LocalMiniappUserIdentity\"\nimport {migrateLocalMiniappData, type LocalMiniappDataMigrationBackend} from \"./LocalMiniappDataMigration\"\nimport {nativeHttpResponseBody} from \"./NativeHttpResponse\"\n\nconst LOG_TAG = \"cloudClient\"\ntype CloudCore = NonNullable<CloudClient[\"core\"]>\n\n// Persistent cloud-disconnect detector: the cloud-client reconnect loop is infinite\n// and never surfaces a \"giving up\" signal, so \"persistent failure\" = the session has\n// been continuously NOT connected for this long. A quick reconnect cancels it; brief\n// flaps that recover don't fire. Raised as engine.notifications(connection_failed_persistent).\nconst CLOUD_PERSISTENT_FAILURE_MS = 60_000\nconst LOCAL_MINIAPP_USER_ID_KEY = \"glassly.localMiniapp.userId\"\n\n/** Cancel the pending persistent-failure alarm + re-arm for the next outage. */\nfunction clearPersistentFailureAlarm(): void {\n if (persistentFailureTimer) {\n BgTimer.clearTimeout(persistentFailureTimer)\n persistentFailureTimer = null\n }\n persistentFailureNotified = false\n}\n\ntype Lc3FrameSizeBytes = 20 | 40 | 60\n\n// Neutral last-ditch fallbacks (reachable under `adb reverse`) for when the host\n// passes no endpoints. The host normally resolves the real URLs (dev override /\n// Metro host / env) and hands them in via `engine.configure({config})`.\nconst FALLBACK_CORE_URL = \"http://localhost:3000\"\nconst FALLBACK_RUNTIME_URL = \"http://localhost:3001\"\nconst LOCAL_AUTH_PORT = 3002\n\nlet client: CloudClient | null = null\nlet connected = false\nlet persistentFailureTimer: ReturnType<typeof BgTimer.setTimeout> | null = null\nlet persistentFailureNotified = false\nlet audioSubscriptions: AudioSubscription[] = []\nlet transportsReady = false\n/** Endpoints to build with — seeded from config, overridable via reconnect(). */\nlet endpointsOverride: {core: string; runtime: string} | null = null\nlet runtimeStatusUnsubscribe: (() => void) | null = null\nlet transcriptUnsubscribe: (() => void) | null = null\nlet translationUnsubscribe: (() => void) | null = null\nlet quotaUnsubscribe: (() => void) | null = null\nlet authStateUnsubscribe: (() => void) | null = null\nlet localDevRuntimeToken: {runtimeUrl: string; token: string; expiresAtMs: number} | null = null\nlet lc3FrameSizeUnsubscribe: (() => void) | null = null\nlet disableCloudUnsubscribe: (() => void) | null = null\nlet coreTokenSyncPromise: Promise<string> | null = null\n/**\n * A device-local namespace (`local_…`) whose data still needs to be adopted\n * into the account namespace. Set when a sign-in displaces a local id; cleared\n * once {@link adoptLocalNamespace} has moved the data.\n */\nlet pendingLocalNamespace: string | null = null\n\n/**\n * Moves blob bytes between user directories during namespace adoption.\n * Registered by LocalMiniappRuntime (which owns the BlobStore instance) so this\n * service doesn't import it and create a cycle. Absent in tests / before the\n * runtime boots, in which case only the key-value stores migrate.\n */\ntype BlobNamespaceMigrator = (fromUserId: string, toUserId: string) => {moved: number; skipped: number}\nlet blobNamespaceMigrator: BlobNamespaceMigrator | null = null\n\n/**\n * Register the blob-bytes half of namespace adoption. Called by\n * LocalMiniappRuntime at construction — it owns the BlobStore instance, and\n * having it push the hook here keeps this service from importing the runtime.\n */\nexport function setBlobNamespaceMigrator(migrator: BlobNamespaceMigrator | null): void {\n blobNamespaceMigrator = migrator\n}\n\n/** Result-free view of MMKV, as the migration's plain get/set/remove/keys. */\nconst migrationBackend: LocalMiniappDataMigrationBackend = {\n get(key: string): unknown | null {\n const result = mmkvStorage.load<unknown>(key)\n return result.is_ok() ? result.value : null\n },\n set(key: string, value: unknown): void {\n const result = mmkvStorage.save(key, value)\n if (result.is_error()) throw result.error\n },\n remove(key: string): void {\n const result = mmkvStorage.remove(key)\n if (result.is_error()) throw result.error\n },\n keys(): string[] {\n return mmkvStorage.getAllKeys()\n },\n}\n\n/**\n * Adopt data written under a device-local namespace into the signed-in\n * account's, so miniapp state created while cloud was disabled survives\n * sign-in. No-op unless a sign-in actually displaced a local id.\n */\nfunction adoptLocalNamespace(coreUserId: string): void {\n const from = pendingLocalNamespace\n if (!from) return\n // Clear first: a failure must not re-run on every subsequent resolve, and the\n // migration is idempotent anyway.\n pendingLocalNamespace = null\n if (!coreUserId || from === coreUserId) return\n\n try {\n const keys = migrateLocalMiniappData(migrationBackend, from, coreUserId)\n const blobs = blobNamespaceMigrator?.(from, coreUserId) ?? {moved: 0, skipped: 0}\n if (keys.moved || keys.skipped || blobs.moved || blobs.skipped) {\n console.log(\n `${LOG_TAG}: adopted local miniapp data into account namespace ` +\n `(keys ${keys.moved} moved/${keys.skipped} skipped, blobs ${blobs.moved} moved/${blobs.skipped} skipped)`,\n )\n }\n } catch (err) {\n console.warn(`${LOG_TAG}: local namespace adoption failed: ${(err as Error)?.message ?? err}`)\n }\n}\n\nconst localMiniappUserIdentity = new LocalMiniappUserIdentity({\n get(): string | null {\n const result = mmkvStorage.load<string>(LOCAL_MINIAPP_USER_ID_KEY)\n return result.is_ok() ? result.value : null\n },\n set(userId: string): void {\n const result = mmkvStorage.save(LOCAL_MINIAPP_USER_ID_KEY, userId)\n if (result.is_error()) throw result.error\n },\n remove(): void {\n const result = mmkvStorage.remove(LOCAL_MINIAPP_USER_ID_KEY)\n if (result.is_error()) throw result.error\n },\n})\n\nconst transcriptListeners = new Set<(d: TranscriptionData) => void>()\nconst translationListeners = new Set<(d: TranslationData) => void>()\nconst quotaListeners = new Set<(d: QuotaStatusPayload) => void>()\nconst statusListeners = new Set<(snapshot: CloudClientStatusSnapshot) => void>()\nconst connectionListeners = new Set<(connected: boolean) => void>()\n\nfunction resolveEndpoints(): {core: string; runtime: string} {\n if (endpointsOverride) return endpointsOverride\n const cfg = getConfigValues()\n return {\n core: cfg.coreUrl?.trim() || FALLBACK_CORE_URL,\n runtime: cfg.runtimeUrl?.trim() || FALLBACK_RUNTIME_URL,\n }\n}\n\nfunction getCoreClient(): CloudCore {\n if (!client) construct()\n const core = client?.core\n if (!core) throw new Error(\"cloud client core not configured\")\n return core\n}\n\nfunction syncCoreAccessTokenToBluetooth(): Promise<string> {\n if (coreTokenSyncPromise) return coreTokenSyncPromise\n\n coreTokenSyncPromise = syncCoreAccessTokenToBluetoothInternal().finally(() => {\n coreTokenSyncPromise = null\n })\n return coreTokenSyncPromise\n}\n\nasync function syncCoreAccessTokenToBluetoothInternal(): Promise<string> {\n if (!client) construct()\n const c = client\n if (!c) throw new Error(\"cloud client not initialized\")\n\n const token = await c.auth.getCoreToken()\n if (c !== client) {\n throw new Error(\"cloud client changed while syncing core token\")\n }\n adoptLocalNamespace(c.auth.identity.userId)\n localMiniappUserIdentity.remember(c.auth.identity.userId)\n const result = await useSettingsStore.getState().setSetting(SETTINGS.core_token.key, token, false)\n if (result.is_error()) {\n throw result.error\n }\n\n try {\n await BluetoothSdk.updateBluetoothSettings({[SETTINGS.core_token.key]: token})\n } catch (err) {\n console.warn(`${LOG_TAG}: direct Bluetooth core_token sync failed: ${(err as Error)?.message ?? err}`)\n }\n\n return token\n}\n\nfunction frameSizeBytes(): Lc3FrameSizeBytes {\n // Read LIVE from the engine settings store (the source of truth) so a\n // reconnect after a glasses swap (G1=20 ↔ G2=40) picks up the new frame size,\n // not the one-time engine.configure({config}) snapshot. Falls back to the\n // config value (set at boot) then 20 when the setting is unset.\n const fromSettings = useSettingsStore.getState().getSetting(SETTINGS.lc3_frame_size.key)\n const size = fromSettings ?? getConfigValues().audioFrameSizeBytes\n return size === 20 || size === 40 || size === 60 ? size : 20\n}\n\nasync function getSubjectToken(): Promise<{token: string; type: SubjectTokenType}> {\n const a = getAuth()\n if (!a) throw new Error(\"cloudClient: engine.configure({auth}) not called\")\n const r = await a.getSubjectToken()\n // IslandAuth's SubjectTokenType is intentionally open (`string & {}`) so OEMs\n // can use other token kinds; cloud-client's is a closed union. The host's\n // actual value (\"supabase\") is valid — narrow at this boundary.\n return {token: r.token, type: r.type as SubjectTokenType}\n}\n\nfunction normalizeExpiresAt(expiresAt: number): number {\n return expiresAt < 10_000_000_000 ? expiresAt * 1000 : expiresAt\n}\n\nfunction shouldUseLocalDevRuntimeToken(endpoints: {runtime: string}): boolean {\n if (!__DEV__) return false\n try {\n const host = new URL(endpoints.runtime).hostname\n return host === \"localhost\" || host === \"127.0.0.1\" || host === \"10.0.2.2\"\n } catch {\n return false\n }\n}\n\nasync function getLocalDevRuntimeToken(runtimeEndpoint: string, opts?: {forceRefresh?: boolean}): Promise<string> {\n const now = Date.now()\n if (\n !opts?.forceRefresh &&\n localDevRuntimeToken?.runtimeUrl === runtimeEndpoint &&\n localDevRuntimeToken.expiresAtMs - now > 60_000\n ) {\n return localDevRuntimeToken.token\n }\n\n const base = new URL(runtimeEndpoint)\n base.port = String(LOCAL_AUTH_PORT)\n base.pathname = \"/api/dev/runtime-token\"\n base.search = new URLSearchParams({userId: \"local-phone-user\", tenantId: \"glassly\"}).toString()\n\n const res = await fetch(base.toString())\n if (!res.ok) {\n throw new Error(`cloudClient: local dev runtime token failed (${res.status})`)\n }\n const body = (await res.json()) as {access_token?: string; expires_in?: number}\n if (!body.access_token) {\n throw new Error(\"cloudClient: local dev runtime token response missing access_token\")\n }\n localDevRuntimeToken = {\n runtimeUrl: runtimeEndpoint,\n token: body.access_token,\n expiresAtMs: now + (body.expires_in ?? 300) * 1000,\n }\n return body.access_token\n}\n\nfunction toCloudClientStatusSnapshot(snapshot: RuntimeSnapshot): CloudClientStatusSnapshot {\n return {status: snapshot.status, audioTransport: snapshot.audioTransport}\n}\n\nfunction currentRuntimeStatus(): CloudClientStatusSnapshot {\n const state = useCloudClientStatusStore.getState()\n return {status: state.status, audioTransport: state.audioTransport}\n}\n\nfunction setRuntimeStatus(snapshot: RuntimeSnapshot): void {\n useCloudClientStatusStore.getState().setSnapshot(snapshot)\n emitStatus(toCloudClientStatusSnapshot(snapshot))\n}\n\nfunction resetRuntimeStatus(): void {\n useCloudClientStatusStore.getState().reset()\n emitStatus(currentRuntimeStatus())\n}\n\nfunction stringifyMeta(meta: unknown): string {\n if (!meta || typeof meta !== \"object\") return \"\"\n try {\n return ` ${JSON.stringify(meta)}`\n } catch {\n return \"\"\n }\n}\n\nconst cloudLogger = {\n debug: (msg: string, meta?: unknown) => console.log(`${LOG_TAG}: debug: ${msg}${stringifyMeta(meta)}`),\n info: (msg: string, meta?: unknown) => console.log(`${LOG_TAG}: info: ${msg}${stringifyMeta(meta)}`),\n warn: (msg: string, meta?: unknown) => console.warn(`${LOG_TAG}: warn: ${msg}${stringifyMeta(meta)}`),\n error: (msg: string, meta?: unknown) => console.warn(`${LOG_TAG}: error: ${msg}${stringifyMeta(meta)}`),\n}\n\nfunction notifyConnectionListeners(next: boolean): void {\n for (const l of connectionListeners) {\n try {\n l(next)\n } catch (err) {\n console.warn(`${LOG_TAG}: connection listener threw: ${(err as Error)?.message ?? err}`)\n }\n }\n}\n\nfunction extractUnsubscribe(sub: unknown): (() => void) | null {\n const candidates: unknown[] = []\n const s = sub as Record<string, unknown> | null | undefined\n if (s && typeof s === \"object\") {\n candidates.push(s)\n candidates.push((s.value as Record<string, unknown>)?.subscription)\n candidates.push((s.data as Record<string, unknown>)?.subscription)\n candidates.push(s.subscription)\n }\n for (const c of candidates) {\n const unsub = (c as {unsubscribe?: unknown})?.unsubscribe\n if (typeof unsub === \"function\") return unsub as () => void\n }\n return null\n}\n\nfunction ensureAuthWatch(): void {\n if (authStateUnsubscribe) return\n authStateUnsubscribe = () => {}\n\n const auth = getAuth()\n if (!auth?.onStateChange) return\n\n let reconnectPending = false\n try {\n const sub = auth.onStateChange((event, session) => {\n if (event === \"SIGNED_OUT\") {\n localMiniappUserIdentity.forget()\n return\n }\n // A new sign-in may belong to a different account. Force the next\n // storage request to resolve and persist that account's Core identity.\n // A device-local namespace is remembered first so the data written while\n // cloud was off can follow the user into the account (see\n // adoptLocalNamespace).\n if (event === \"SIGNED_IN\") {\n const local = localMiniappUserIdentity.get()\n if (local && isLocalUserId(local)) pendingLocalNamespace = local\n localMiniappUserIdentity.forget()\n }\n if (!session?.token) return\n if (connected || reconnectPending) return\n\n reconnectPending = true\n console.log(`${LOG_TAG}: auth session available (${event}) while disconnected — reconnecting`)\n try {\n cloudClientService.reconnect()\n } finally {\n BgTimer.setTimeout(() => {\n reconnectPending = false\n }, 0)\n }\n })\n\n const unsub = extractUnsubscribe(sub)\n if (unsub) authStateUnsubscribe = unsub\n } catch (err) {\n console.warn(`${LOG_TAG}: auth watch subscribe failed: ${(err as Error)?.message ?? err}`)\n }\n}\n\nfunction stopAuthWatch(): void {\n authStateUnsubscribe?.()\n authStateUnsubscribe = null\n}\n\nfunction emitTranscript(data: TranscriptionData): void {\n for (const l of transcriptListeners) {\n try {\n l(data)\n } catch (err) {\n console.warn(`${LOG_TAG}: transcript listener threw: ${(err as Error)?.message ?? err}`)\n }\n }\n}\n\nfunction emitTranslation(data: TranslationData): void {\n for (const l of translationListeners) {\n try {\n l(data)\n } catch (err) {\n console.warn(`${LOG_TAG}: translation listener threw: ${(err as Error)?.message ?? err}`)\n }\n }\n}\n\nfunction emitQuota(data: QuotaStatusPayload): void {\n for (const l of quotaListeners) {\n try {\n l(data)\n } catch (err) {\n console.warn(`${LOG_TAG}: quota listener threw: ${(err as Error)?.message ?? err}`)\n }\n }\n}\n\nfunction emitStatus(snapshot: CloudClientStatusSnapshot): void {\n for (const l of statusListeners) {\n try {\n l(snapshot)\n } catch (err) {\n console.warn(`${LOG_TAG}: status listener threw: ${(err as Error)?.message ?? err}`)\n }\n }\n}\n\nfunction ensureTransports(): void {\n if (transportsReady) return\n transportsReady = true\n setNativeUdp(() => createCloudUdpSocket())\n setSecureStorage(cloudSecureStore)\n if (Platform.OS !== \"android\") return\n setNativeHttp(async (input, init) => {\n if (typeof input !== \"string\" || (init?.body != null && typeof init.body !== \"string\")) {\n return globalThis.fetch(input, init)\n }\n const headers = Object.fromEntries(new Headers(init?.headers).entries())\n const result = await CrustModule.nativeHttpRequest(\n init?.method ?? \"GET\",\n input,\n headers,\n (init?.body as string | undefined) ?? null,\n )\n return new Response(nativeHttpResponseBody(result.status, result.body), {\n status: result.status,\n statusText: result.statusText,\n headers: result.headers,\n })\n })\n}\n\nfunction clearRuntimeEventSubscriptions(): void {\n runtimeStatusUnsubscribe?.()\n runtimeStatusUnsubscribe = null\n transcriptUnsubscribe?.()\n transcriptUnsubscribe = null\n translationUnsubscribe?.()\n translationUnsubscribe = null\n quotaUnsubscribe?.()\n quotaUnsubscribe = null\n}\n\n/**\n * The user's hard \"never talk to Glassly cloud\" stance (Settings > Privacy).\n * Read imperatively at every would-be-connect point rather than cached, so\n * flipping the toggle takes effect without a restart. `=== true` because\n * getSetting is `any` and an unhydrated store must not read as \"disabled\".\n */\nfunction cloudDisabled(): boolean {\n return useSettingsStore.getState().getSetting(SETTINGS.disable_cloud.key) === true\n}\n\nfunction startLc3FrameSizeWatcher(): void {\n if (lc3FrameSizeUnsubscribe) return\n\n let last = frameSizeBytes()\n lc3FrameSizeUnsubscribe = useSettingsStore.subscribe(\n (state) => state.getSetting(SETTINGS.lc3_frame_size.key),\n () => {\n const next = frameSizeBytes()\n if (next === last) return\n last = next\n if (!client) return\n console.log(`${LOG_TAG}: LC3 frame size changed to ${next}; reconnecting runtime`)\n cloudClientService.reconnect()\n },\n )\n}\n\nfunction stopLc3FrameSizeWatcher(): void {\n lc3FrameSizeUnsubscribe?.()\n lc3FrameSizeUnsubscribe = null\n}\n\n/**\n * Apply a mid-session flip of the Privacy toggle without a restart: turning it\n * on tears the live client down, turning it back off reconnects. Installed by\n * init() on BOTH branches — when cloud starts disabled there is no client to\n * hang the watcher off, but we still need to notice the user re-enabling it.\n */\nfunction startDisableCloudWatcher(): void {\n if (disableCloudUnsubscribe) return\n\n let last = cloudDisabled()\n disableCloudUnsubscribe = useSettingsStore.subscribe(\n (state) => state.getSetting(SETTINGS.disable_cloud.key),\n () => {\n const next = cloudDisabled()\n if (next === last) return\n last = next\n if (next) {\n console.log(`${LOG_TAG}: cloud disabled — tearing down client`)\n cloudClientService.stop()\n } else {\n console.log(`${LOG_TAG}: cloud re-enabled — reconnecting`)\n cloudClientService.init()\n }\n },\n )\n}\n\nfunction stopDisableCloudWatcher(): void {\n disableCloudUnsubscribe?.()\n disableCloudUnsubscribe = null\n}\n\nfunction construct(): void {\n ensureTransports()\n\n const endpoints = resolveEndpoints()\n console.log(`${LOG_TAG}: endpoints ${JSON.stringify(endpoints)}`)\n\n const coreAuth = {getSubjectToken}\n const auth = shouldUseLocalDevRuntimeToken(endpoints)\n ? {\n core: coreAuth,\n runtime: {getToken: (opts?: {forceRefresh?: boolean}) => getLocalDevRuntimeToken(endpoints.runtime, opts)},\n }\n : {core: coreAuth, runtime: {source: \"core\" as const}}\n\n client = new CloudClient({\n endpoints,\n // The phone LC3-encodes mic audio (even in phone/simulated mode); announce\n // LC3 at 16 kHz with the frame size the encoder emits.\n audio: {codec: \"lc3\", sampleRate: 16000, frameSizeBytes: frameSizeBytes()},\n auth,\n timers: {\n setTimeout: (callback, delayMs) => BgTimer.setTimeout(callback, delayMs),\n clearTimeout: (handle) => BgTimer.clearTimeout(handle as number),\n setInterval: (callback, intervalMs) => BgTimer.setInterval(callback, intervalMs),\n clearInterval: (handle) => BgTimer.clearInterval(handle as number),\n },\n logger: cloudLogger,\n })\n\n const c = client\n clearRuntimeEventSubscriptions()\n runtimeStatusUnsubscribe = c.runtime.onStatusChanged((status) => {\n if (c !== client) return\n setRuntimeStatus(status)\n })\n transcriptUnsubscribe = c.runtime.onTranscript((data) => {\n if (c !== client) return\n logCloudV2TranscriptMetric(data)\n emitTranscript(data)\n })\n translationUnsubscribe = c.runtime.onTranslation((data) => {\n if (c !== client) return\n emitTranslation(data)\n })\n quotaUnsubscribe = c.runtime.onQuota((data) => {\n if (c !== client) return\n emitQuota(data)\n })\n setRuntimeStatus(c.runtime.getStatus())\n\n c.runtime.onConnected(() => {\n if (c !== client) return\n connected = true\n console.log(`${LOG_TAG}: runtime connected`)\n console.log(`${LOG_TAG}: debug: ws-session-debug connected`)\n // Cloud is up — cancel any pending persistent-failure alarm and re-arm for the\n // next outage.\n clearPersistentFailureAlarm()\n // Re-apply the authoritative subscription set, including the empty set, so\n // a fresh phone launch clears any stale server-side audio subscriptions.\n c.runtime\n .setSubscriptions(audioSubscriptions)\n .catch((err) =>\n console.warn(`${LOG_TAG}: re-applying queued subscriptions failed: ${(err as Error)?.message ?? err}`),\n )\n notifyConnectionListeners(true)\n })\n c.runtime.onDisconnected((info) => {\n if (c !== client) return\n connected = false\n console.log(`${LOG_TAG}: runtime disconnected (${info.reason})`)\n console.log(\n `${LOG_TAG}: debug: ws-session-debug disconnected reason=${info.reason} willStayDown=${/superseded by newer session/i.test(info.reason)}`,\n )\n // Arm the persistent-failure alarm once; if we're still down when it fires, raise\n // the notification. A reconnect within the window cancels it (onConnected above).\n if (!persistentFailureTimer && !persistentFailureNotified) {\n persistentFailureTimer = BgTimer.setTimeout(() => {\n persistentFailureTimer = null\n if (connected) return\n persistentFailureNotified = true\n islandNotifications.emit({\n kind: \"connection_failed_persistent\",\n reason: `Cloud session has been disconnected for over ${Math.round(CLOUD_PERSISTENT_FAILURE_MS / 1000)}s`,\n metadata: {downForMs: CLOUD_PERSISTENT_FAILURE_MS, lastReason: info.reason},\n timestamp: Date.now(),\n })\n }, CLOUD_PERSISTENT_FAILURE_MS)\n }\n notifyConnectionListeners(false)\n })\n c.runtime.onError((err) => {\n console.warn(`${LOG_TAG}: runtime error: ${err.code}`)\n })\n\n // Dead credentials (refresh AND subject exchange both failed). Surface to\n // the host so it can force a re-login — otherwise the app looks signed-in\n // while every cloud feature silently fails. Fires at most once per client\n // instance (the auth module latches until a successful exchange).\n c.auth.onExpired(() => {\n if (c !== client) return\n console.warn(`${LOG_TAG}: cloud session expired beyond recovery — notifying host`)\n getAuth()?.onSessionExpired?.()\n })\n\n // Best-effort connect. Do not crash the app if the dev cloud is unreachable.\n c.runtime\n .connect()\n .then(() => console.log(`${LOG_TAG}: connect() resolved`))\n .catch((err) => console.warn(`${LOG_TAG}: connect() failed: ${err?.message ?? err}`))\n\n syncCoreAccessTokenToBluetooth().catch((err) =>\n console.warn(`${LOG_TAG}: initial Bluetooth core_token sync failed: ${(err as Error)?.message ?? err}`),\n )\n\n startLc3FrameSizeWatcher()\n}\n\n/**\n * engine's cloud client. Owns the singleton CloudClient, its connection state,\n * and the runtime-hook wiring.\n */\nexport const cloudClientService = {\n /**\n * Construct (once) + connect the client. Idempotent. Best-effort connect — a\n * failure is logged and the app keeps running. Requires\n * `engine.configure({auth, config})` first.\n */\n init(): void {\n if (client) return\n // Privacy stance wins over every caller, including the lazy `if (!client)\n // this.init()` paths below — this is the one chokepoint where the client\n // gets built, so refusing here keeps the socket from ever opening.\n if (cloudDisabled()) {\n console.log(`${LOG_TAG}: init skipped — cloud disabled in Privacy settings`)\n startDisableCloudWatcher()\n return\n }\n ensureAuthWatch()\n startDisableCloudWatcher()\n construct()\n },\n\n /** True when the user has turned Glassly cloud off entirely. */\n isCloudDisabled(): boolean {\n return cloudDisabled()\n },\n\n /**\n * Tear down + rebuild. Pass new endpoints to switch URLs; pass `null` to CLEAR\n * a prior override and fall back to the boot config (so cleared/default cloud\n * URLs don't keep reconnecting to a stale override); omit to keep the current.\n */\n reconnect(endpoints?: {core: string; runtime: string} | null): void {\n const prevCore = resolveEndpoints().core\n if (endpoints !== undefined) endpointsOverride = endpoints\n // Tokens are minted per backend (per-env signing keys + user DB), so a\n // core switch makes the persisted refresh token dead weight the new\n // backend will reject. Drop it so the client goes straight to a subject\n // exchange instead of burning a round trip on a guaranteed invalid_grant.\n // Key literal matches cloud-client's token-store.ts REFRESH_TOKEN_KEY.\n if (resolveEndpoints().core !== prevCore) {\n console.log(`${LOG_TAG}: core endpoint changed — dropping persisted cloud refresh token`)\n void cloudSecureStore.delete(\"glassly.cloud-client.refreshToken\")\n }\n try {\n client?.runtime.close()\n } catch (err) {\n console.warn(`${LOG_TAG}: reconnect close() failed: ${(err as Error)?.message ?? err}`)\n }\n clearRuntimeEventSubscriptions()\n clearPersistentFailureAlarm()\n\n const wasConnected = connected\n client = null\n localDevRuntimeToken = null\n connected = false\n resetRuntimeStatus()\n if (wasConnected) notifyConnectionListeners(false)\n\n // Same gate as init(): endpoint changes / LC3 reconnects must not resurrect\n // a connection the user has switched off.\n if (cloudDisabled()) {\n console.log(`${LOG_TAG}: reconnect skipped — cloud disabled in Privacy settings`)\n return\n }\n construct()\n },\n\n async getPreinstalledMiniappRegistry(): Promise<PreinstalledMiniappRegistry> {\n if (!client) this.init()\n const c = client\n if (!c?.core) throw new Error(\"cloud client core is unavailable\")\n return c.core.miniapps.getRegistry()\n },\n\n async getStoreCatalog(): Promise<StoreCatalogResponse> {\n if (!client) this.init()\n const c = client\n if (!c?.core) throw new Error(\"cloud client core is unavailable\")\n return c.core.store.list()\n },\n\n async getStoreListing(packageName: string): Promise<StoreListing> {\n if (!client) this.init()\n const c = client\n if (!c?.core) throw new Error(\"cloud client core is unavailable\")\n return c.core.store.get(packageName)\n },\n\n /** Bytes of a store icon or screenshot; these routes need the user Bearer. */\n async fetchStoreAsset(url: string): Promise<Uint8Array> {\n if (!client) this.init()\n const c = client\n if (!c?.core) throw new Error(\"cloud client core is unavailable\")\n return c.core.store.fetchAsset(url)\n },\n\n /**\n * Resolve the stable Core-owned Glassly user id.\n *\n * Storage must use this identity rather than the short-lived Core access\n * token. A previously verified id is restored from MMKV so local miniapps\n * remain available after an offline process restart. On first sign-in,\n * callers join the auth module's single-flight exchange/refresh instead of\n * falling back to an anonymous namespace.\n */\n async resolveUserId(): Promise<string> {\n // With cloud off there is no client to exchange a token with and never will\n // be, so the online path below would throw on every storage call and take\n // offline-capable local miniapps down with it. Fall back to a device-local\n // namespace instead — a cached Core id still wins inside resolveLocal().\n if (cloudDisabled()) return localMiniappUserIdentity.resolveLocal()\n\n return localMiniappUserIdentity.resolve(async () => {\n if (!client) this.init()\n const c = client\n if (!c) throw new Error(\"cloud client not initialized\")\n\n await c.auth.getCoreToken()\n if (c !== client) throw new Error(\"cloud client changed while resolving user identity\")\n // Runs before resolve() persists the id, so the local namespace is adopted\n // whichever path reaches Core identity first (this or the token sync).\n adoptLocalNamespace(c.auth.identity.userId)\n return c.auth.identity.userId\n })\n },\n\n /** Read the stable Glassly user id after async identity resolution. */\n getUserId(): string {\n // Mirrors resolveUserId(): with cloud off, minting is synchronous and\n // cannot fail, so sync callers (BlobStore) don't depend on an async resolve\n // having run first.\n if (cloudDisabled()) return localMiniappUserIdentity.resolveLocal()\n const userId = localMiniappUserIdentity.get()\n if (!userId) throw new Error(\"Glassly user identity is unavailable\")\n return userId\n },\n\n async getMiniappAuthToken(\n packageName: string,\n opts?: {minTtlMs?: number; devAttestation?: string},\n ): Promise<MiniappAuthToken> {\n if (!client) this.init()\n const c = client\n if (!c) throw new Error(\"cloud client not initialized\")\n\n const {token, expiresAt} = await c.auth.getMiniappToken(packageName, opts)\n const identity = c.auth.identity\n return {\n userId: identity.userId,\n tenantId: identity.tenantId,\n token,\n expiresAt: normalizeExpiresAt(expiresAt),\n }\n },\n\n /**\n * Tear down the client + connection (the engine.stop() lifecycle).\n *\n * Deliberately leaves the disable-cloud watcher installed: this is also the\n * teardown the Privacy toggle triggers, and dropping the subscription here\n * would strand the app disconnected until restart when the user flips the\n * toggle back off. `shutdown()` is the full-stop variant that removes it.\n */\n stop(): void {\n try {\n client?.runtime.close()\n } catch (err) {\n console.warn(`${LOG_TAG}: stop close() failed: ${(err as Error)?.message ?? err}`)\n }\n stopLc3FrameSizeWatcher()\n stopAuthWatch()\n clearRuntimeEventSubscriptions()\n clearPersistentFailureAlarm()\n const wasConnected = connected\n client = null\n // stop() is part of the logout lifecycle and runs before the host emits\n // SIGNED_OUT. Remove the persisted namespace owner here so a later account\n // can never inherit it. A force-stop/process kill does not call stop(), so\n // the cached id still survives the offline cold-start case.\n localMiniappUserIdentity.forget()\n localDevRuntimeToken = null\n connected = false\n resetRuntimeStatus()\n if (wasConnected) notifyConnectionListeners(false)\n },\n\n /** `stop()` plus the disable-cloud watcher — for a genuine engine teardown. */\n shutdown(): void {\n this.stop()\n stopDisableCloudWatcher()\n },\n\n /** Device-side managed photo (cloud-v2): presign now, deliver bytes, await ready. */\n startManagedPhoto(opts: Record<string, unknown> = {}) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.startManagedPhoto(opts)\n },\n awaitManagedPhotoReady(requestId: string) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.awaitManagedPhotoReady(requestId)\n },\n\n /** Managed stream (cloud-v2): provision ingest+playback on the runtime. */\n startManagedStream(opts: Record<string, unknown> = {}) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.startManagedStream(opts)\n },\n getManagedStreamStatus(streamId: string) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.getManagedStreamStatus(streamId)\n },\n stopManagedStream(streamId: string) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.stopManagedStream(streamId)\n },\n\n /** Current live-session connection state (handshake completed). */\n isConnected(): boolean {\n return connected\n },\n\n /** Subscribe to connection-state transitions. Returns an unsubscribe fn. */\n onConnectionChange(listener: (connected: boolean) => void): () => void {\n connectionListeners.add(listener)\n return () => {\n connectionListeners.delete(listener)\n }\n },\n\n /** Replace the v2 cloud's audio subscription set for the live session. */\n async setSubscriptions(subs: AudioSubscription[]): Promise<void> {\n // Cache unconditionally so the desired set survives a not-yet-connected\n // session and reconnects; the onConnected handler re-applies the cached set.\n audioSubscriptions = subs\n const c = client\n if (connected && c) {\n await c.runtime.setSubscriptions(subs)\n }\n },\n\n sendAudioFrame(frame: Uint8Array): void {\n client?.runtime.sendAudioFrame(frame)\n },\n\n onTranscript(cb: (d: TranscriptionData) => void): () => void {\n transcriptListeners.add(cb)\n return () => {\n transcriptListeners.delete(cb)\n }\n },\n\n onTranslation(cb: (d: TranslationData) => void): () => void {\n translationListeners.add(cb)\n return () => {\n translationListeners.delete(cb)\n }\n },\n\n /** Plan-quota block/unblock pushes for metered cloud streams. */\n onQuota(cb: (d: QuotaStatusPayload) => void): () => void {\n quotaListeners.add(cb)\n return () => {\n quotaListeners.delete(cb)\n }\n },\n\n getStatus(): CloudClientStatusSnapshot {\n return currentRuntimeStatus()\n },\n\n getCoreUrl(): string {\n return resolveEndpoints().core\n },\n\n syncCoreTokenToBluetooth(): Promise<string> {\n return syncCoreAccessTokenToBluetooth()\n },\n\n onStatusChanged(cb: (snapshot: CloudClientStatusSnapshot) => void): () => void {\n statusListeners.add(cb)\n return () => {\n statusListeners.delete(cb)\n }\n },\n\n tts: {\n speak(text: string, options?: Parameters<CloudClient[\"runtime\"][\"tts\"][\"speak\"]>[1]) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.tts.speak(text, options)\n },\n },\n\n llm: {\n /**\n * One completion turn through the cloud LLM service. `userApiKey` is the\n * user's own provider key when they've saved one; the cloud bills that key\n * instead of the platform's and skips metering. It rides as a header, never\n * in the request body.\n */\n complete(\n req: Parameters<CloudClient[\"runtime\"][\"llm\"][\"complete\"]>[0],\n opts?: Parameters<CloudClient[\"runtime\"][\"llm\"][\"complete\"]>[1],\n ) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.llm.complete(req, opts)\n },\n\n /** One agentic visual-generation run. Long-running; see cloud-client docs. */\n generate(\n req: Parameters<CloudClient[\"runtime\"][\"llm\"][\"generate\"]>[0],\n opts?: Parameters<CloudClient[\"runtime\"][\"llm\"][\"generate\"]>[1],\n ) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.llm.generate(req, opts)\n },\n\n /** Start a pollable generate job (async flavor; 404 on old clouds). */\n startGenerateJob(\n req: Parameters<CloudClient[\"runtime\"][\"llm\"][\"startGenerateJob\"]>[0],\n opts?: Parameters<CloudClient[\"runtime\"][\"llm\"][\"startGenerateJob\"]>[1],\n ) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.llm.startGenerateJob(req, opts)\n },\n\n generateJobStatus(jobId: string) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.llm.generateJobStatus(jobId)\n },\n\n cancelGenerateJob(jobId: string) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.llm.cancelGenerateJob(jobId)\n },\n },\n\n maps: {\n directions(req: Parameters<CloudClient[\"runtime\"][\"maps\"][\"directions\"]>[0]) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.maps.directions(req)\n },\n reverseGeocode(coord: Parameters<CloudClient[\"runtime\"][\"maps\"][\"reverseGeocode\"]>[0]) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.maps.reverseGeocode(coord)\n },\n placeAutocomplete(req: Parameters<CloudClient[\"runtime\"][\"maps\"][\"placeAutocomplete\"]>[0]) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.maps.placeAutocomplete(req)\n },\n placeDetails(req: Parameters<CloudClient[\"runtime\"][\"maps\"][\"placeDetails\"]>[0]) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.maps.placeDetails(req)\n },\n /**\n * The deployment's public map render token ({provider, token}) for the\n * consumers that can't be proxied (tiles, native nav SDK). `token` null =\n * this deployment serves none. See MapboxTokenService for the caching\n * consumer.\n */\n renderToken() {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.maps.renderToken()\n },\n },\n\n core: {\n reports: {\n submit(...args: Parameters<CloudCore[\"reports\"][\"submit\"]>) {\n return getCoreClient().reports.submit(...args)\n },\n addLogs(...args: Parameters<CloudCore[\"reports\"][\"addLogs\"]>) {\n return getCoreClient().reports.addLogs(...args)\n },\n addScreenshots(...args: Parameters<CloudCore[\"reports\"][\"addScreenshots\"]>) {\n return getCoreClient().reports.addScreenshots(...args)\n },\n complete(...args: Parameters<CloudCore[\"reports\"][\"complete\"]>) {\n return getCoreClient().reports.complete(...args)\n },\n },\n supportProfile: {\n update(...args: Parameters<CloudCore[\"supportProfile\"][\"update\"]>) {\n return getCoreClient().supportProfile.update(...args)\n },\n },\n },\n\n hasAudioSubscriptions(): boolean {\n return audioSubscriptions.length > 0\n },\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CloudClientService.js","sourceRoot":"","sources":["../../src/services/CloudClientService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAC,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,gBAAgB,EAAC,MAAM,oCAAoC,CAAA;AAQ7G,OAAO,EAAC,QAAQ,EAAC,MAAM,cAAc,CAAA;AAGrC,OAAO,YAAY,MAAM,iCAAiC,CAAA;AAC1D,OAAO,WAAW,MAAM,gBAAgB,CAAA;AACxC,OAAO,EAAC,OAAO,EAAE,eAAe,EAAC,MAAM,sBAAsB,CAAA;AAC7D,OAAO,EAAC,gBAAgB,EAAE,QAAQ,EAAC,MAAM,oBAAoB,CAAA;AAE7D,OAAO,EAAC,oBAAoB,EAAC,MAAM,mCAAmC,CAAA;AACtE,OAAO,EAAC,gBAAgB,EAAC,MAAM,uCAAuC,CAAA;AACtE,OAAO,EAAC,OAAO,IAAI,WAAW,EAAC,MAAM,kBAAkB,CAAA;AACvD,OAAO,EAAC,yBAAyB,EAAC,MAAM,6BAA6B,CAAA;AACrE,OAAO,EAAC,mBAAmB,EAAC,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAAC,OAAO,EAAC,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAC,wBAAwB,EAAC,MAAM,6BAA6B,CAAA;AACpE,OAAO,EAAC,aAAa,EAAE,wBAAwB,EAAC,MAAM,4BAA4B,CAAA;AAClF,OAAO,EAAC,uBAAuB,EAAwC,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ine runtime\n * — the keystone move that pulls backend comms INTO engine.\n *\n * engine constructs the client from engine-owned pieces (the native UDP socket,\n * the MMKV secure store, the cloud-status store) plus the two things the host\n * provides through the engine front door: `auth.getSubjectToken` (the one\n * permanent seam — the OEM owns login) and the resolved cloud endpoints\n * (`config.coreUrl/runtimeUrl`, computed host-side from dev/settings). On init it\n * exposes cloud runtime methods directly from this service, so the host no longer\n * injects a cloud adapter — engine owns construction and wiring.\n *\n * The local-miniapp path drives the cloud's transcription/translation through\n * this service.\n */\nimport {CloudClient, setNativeHttp, setNativeUdp, setSecureStorage} from \"@glassly/cloud-client/react-native\"\nimport type {\n PreinstalledMiniappRegistry,\n RuntimeSnapshot,\n StoreCatalogResponse,\n StoreListing,\n} from \"@glassly/cloud-client/react-native\"\nimport type {SubjectTokenType} from \"@glassly/cloud-client\"\nimport {Platform} from \"react-native\"\nimport type {AudioSubscription, QuotaStatusPayload, TranscriptionData, TranslationData} from \"@glassly/cloud-protocol\"\n\nimport BluetoothSdk from \"@glassly/bluetooth-sdk/internal\"\nimport CrustModule from \"@glassly/crust\"\nimport {getAuth, getConfigValues} from \"../runtime/bootstrap\"\nimport {useSettingsStore, SETTINGS} from \"../stores/settings\"\nimport {type CloudClientStatusSnapshot, type MiniappAuthToken} from \"../runtime/config\"\nimport {createCloudUdpSocket} from \"../utils/cloudClient/RnUdpAdapter\"\nimport {cloudSecureStore} from \"../utils/cloudClient/cloudSecureStore\"\nimport {storage as mmkvStorage} from \"../utils/storage\"\nimport {useCloudClientStatusStore} from \"../stores/cloudClientStatus\"\nimport {islandNotifications} from \"./NotificationsEmitter\"\nimport {BgTimer} from \"../utils/timers\"\nimport {logCloudTranscriptMetric} from \"./CloudTranscriptE2EMetrics\"\nimport {isLocalUserId, LocalMiniappUserIdentity} from \"./LocalMiniappUserIdentity\"\nimport {migrateLocalMiniappData, type LocalMiniappDataMigrationBackend} from \"./LocalMiniappDataMigration\"\nimport {nativeHttpResponseBody} from \"./NativeHttpResponse\"\n\nconst LOG_TAG = \"cloudClient\"\ntype CloudCore = NonNullable<CloudClient[\"core\"]>\n\n// Persistent cloud-disconnect detector: the cloud-client reconnect loop is infinite\n// and never surfaces a \"giving up\" signal, so \"persistent failure\" = the session has\n// been continuously NOT connected for this long. A quick reconnect cancels it; brief\n// flaps that recover don't fire. Raised as engine.notifications(connection_failed_persistent).\nconst CLOUD_PERSISTENT_FAILURE_MS = 60_000\nconst LOCAL_MINIAPP_USER_ID_KEY = \"glassly.localMiniapp.userId\"\n\n/** Cancel the pending persistent-failure alarm + re-arm for the next outage. */\nfunction clearPersistentFailureAlarm(): void {\n if (persistentFailureTimer) {\n BgTimer.clearTimeout(persistentFailureTimer)\n persistentFailureTimer = null\n }\n persistentFailureNotified = false\n}\n\ntype Lc3FrameSizeBytes = 20 | 40 | 60\n\n// Neutral last-ditch fallbacks (reachable under `adb reverse`) for when the host\n// passes no endpoints. The host normally resolves the real URLs (dev override /\n// Metro host / env) and hands them in via `engine.configure({config})`.\nconst FALLBACK_CORE_URL = \"http://localhost:3000\"\nconst FALLBACK_RUNTIME_URL = \"http://localhost:3001\"\nconst LOCAL_AUTH_PORT = 3002\n\nlet client: CloudClient | null = null\nlet connected = false\nlet persistentFailureTimer: ReturnType<typeof BgTimer.setTimeout> | null = null\nlet persistentFailureNotified = false\nlet audioSubscriptions: AudioSubscription[] = []\nlet transportsReady = false\n/** Endpoints to build with — seeded from config, overridable via reconnect(). */\nlet endpointsOverride: {core: string; runtime: string} | null = null\nlet runtimeStatusUnsubscribe: (() => void) | null = null\nlet transcriptUnsubscribe: (() => void) | null = null\nlet translationUnsubscribe: (() => void) | null = null\nlet quotaUnsubscribe: (() => void) | null = null\nlet authStateUnsubscribe: (() => void) | null = null\nlet localDevRuntimeToken: {runtimeUrl: string; token: string; expiresAtMs: number} | null = null\nlet lc3FrameSizeUnsubscribe: (() => void) | null = null\nlet disableCloudUnsubscribe: (() => void) | null = null\nlet coreTokenSyncPromise: Promise<string> | null = null\n/**\n * A device-local namespace (`local_…`) whose data still needs to be adopted\n * into the account namespace. Set when a sign-in displaces a local id; cleared\n * once {@link adoptLocalNamespace} has moved the data.\n */\nlet pendingLocalNamespace: string | null = null\n\n/**\n * Moves blob bytes between user directories during namespace adoption.\n * Registered by LocalMiniappRuntime (which owns the BlobStore instance) so this\n * service doesn't import it and create a cycle. Absent in tests / before the\n * runtime boots, in which case only the key-value stores migrate.\n */\ntype BlobNamespaceMigrator = (fromUserId: string, toUserId: string) => {moved: number; skipped: number}\nlet blobNamespaceMigrator: BlobNamespaceMigrator | null = null\n\n/**\n * Register the blob-bytes half of namespace adoption. Called by\n * LocalMiniappRuntime at construction — it owns the BlobStore instance, and\n * having it push the hook here keeps this service from importing the runtime.\n */\nexport function setBlobNamespaceMigrator(migrator: BlobNamespaceMigrator | null): void {\n blobNamespaceMigrator = migrator\n}\n\n/** Result-free view of MMKV, as the migration's plain get/set/remove/keys. */\nconst migrationBackend: LocalMiniappDataMigrationBackend = {\n get(key: string): unknown | null {\n const result = mmkvStorage.load<unknown>(key)\n return result.is_ok() ? result.value : null\n },\n set(key: string, value: unknown): void {\n const result = mmkvStorage.save(key, value)\n if (result.is_error()) throw result.error\n },\n remove(key: string): void {\n const result = mmkvStorage.remove(key)\n if (result.is_error()) throw result.error\n },\n keys(): string[] {\n return mmkvStorage.getAllKeys()\n },\n}\n\n/**\n * Adopt data written under a device-local namespace into the signed-in\n * account's, so miniapp state created while cloud was disabled survives\n * sign-in. No-op unless a sign-in actually displaced a local id.\n */\nfunction adoptLocalNamespace(coreUserId: string): void {\n const from = pendingLocalNamespace\n if (!from) return\n // Clear first: a failure must not re-run on every subsequent resolve, and the\n // migration is idempotent anyway.\n pendingLocalNamespace = null\n if (!coreUserId || from === coreUserId) return\n\n try {\n const keys = migrateLocalMiniappData(migrationBackend, from, coreUserId)\n const blobs = blobNamespaceMigrator?.(from, coreUserId) ?? {moved: 0, skipped: 0}\n if (keys.moved || keys.skipped || blobs.moved || blobs.skipped) {\n console.log(\n `${LOG_TAG}: adopted local miniapp data into account namespace ` +\n `(keys ${keys.moved} moved/${keys.skipped} skipped, blobs ${blobs.moved} moved/${blobs.skipped} skipped)`,\n )\n }\n } catch (err) {\n console.warn(`${LOG_TAG}: local namespace adoption failed: ${(err as Error)?.message ?? err}`)\n }\n}\n\nconst localMiniappUserIdentity = new LocalMiniappUserIdentity({\n get(): string | null {\n const result = mmkvStorage.load<string>(LOCAL_MINIAPP_USER_ID_KEY)\n return result.is_ok() ? result.value : null\n },\n set(userId: string): void {\n const result = mmkvStorage.save(LOCAL_MINIAPP_USER_ID_KEY, userId)\n if (result.is_error()) throw result.error\n },\n remove(): void {\n const result = mmkvStorage.remove(LOCAL_MINIAPP_USER_ID_KEY)\n if (result.is_error()) throw result.error\n },\n})\n\nconst transcriptListeners = new Set<(d: TranscriptionData) => void>()\nconst translationListeners = new Set<(d: TranslationData) => void>()\nconst quotaListeners = new Set<(d: QuotaStatusPayload) => void>()\nconst statusListeners = new Set<(snapshot: CloudClientStatusSnapshot) => void>()\nconst connectionListeners = new Set<(connected: boolean) => void>()\n\nfunction resolveEndpoints(): {core: string; runtime: string} {\n if (endpointsOverride) return endpointsOverride\n const cfg = getConfigValues()\n return {\n core: cfg.coreUrl?.trim() || FALLBACK_CORE_URL,\n runtime: cfg.runtimeUrl?.trim() || FALLBACK_RUNTIME_URL,\n }\n}\n\nfunction getCoreClient(): CloudCore {\n if (!client) construct()\n const core = client?.core\n if (!core) throw new Error(\"cloud client core not configured\")\n return core\n}\n\nfunction syncCoreAccessTokenToBluetooth(): Promise<string> {\n if (coreTokenSyncPromise) return coreTokenSyncPromise\n\n coreTokenSyncPromise = syncCoreAccessTokenToBluetoothInternal().finally(() => {\n coreTokenSyncPromise = null\n })\n return coreTokenSyncPromise\n}\n\nasync function syncCoreAccessTokenToBluetoothInternal(): Promise<string> {\n if (!client) construct()\n const c = client\n if (!c) throw new Error(\"cloud client not initialized\")\n\n const token = await c.auth.getCoreToken()\n if (c !== client) {\n throw new Error(\"cloud client changed while syncing core token\")\n }\n adoptLocalNamespace(c.auth.identity.userId)\n localMiniappUserIdentity.remember(c.auth.identity.userId)\n const result = await useSettingsStore.getState().setSetting(SETTINGS.core_token.key, token, false)\n if (result.is_error()) {\n throw result.error\n }\n\n try {\n await BluetoothSdk.updateBluetoothSettings({[SETTINGS.core_token.key]: token})\n } catch (err) {\n console.warn(`${LOG_TAG}: direct Bluetooth core_token sync failed: ${(err as Error)?.message ?? err}`)\n }\n\n return token\n}\n\nfunction frameSizeBytes(): Lc3FrameSizeBytes {\n // Read LIVE from the engine settings store (the source of truth) so a\n // reconnect after a glasses swap (G1=20 ↔ G2=40) picks up the new frame size,\n // not the one-time engine.configure({config}) snapshot. Falls back to the\n // config value (set at boot) then 20 when the setting is unset.\n const fromSettings = useSettingsStore.getState().getSetting(SETTINGS.lc3_frame_size.key)\n const size = fromSettings ?? getConfigValues().audioFrameSizeBytes\n return size === 20 || size === 40 || size === 60 ? size : 20\n}\n\nasync function getSubjectToken(): Promise<{token: string; type: SubjectTokenType}> {\n const a = getAuth()\n if (!a) throw new Error(\"cloudClient: engine.configure({auth}) not called\")\n const r = await a.getSubjectToken()\n // IslandAuth's SubjectTokenType is intentionally open (`string & {}`) so OEMs\n // can use other token kinds; cloud-client's is a closed union. The host's\n // actual value (\"supabase\") is valid — narrow at this boundary.\n return {token: r.token, type: r.type as SubjectTokenType}\n}\n\nfunction normalizeExpiresAt(expiresAt: number): number {\n return expiresAt < 10_000_000_000 ? expiresAt * 1000 : expiresAt\n}\n\nfunction shouldUseLocalDevRuntimeToken(endpoints: {runtime: string}): boolean {\n if (!__DEV__) return false\n try {\n const host = new URL(endpoints.runtime).hostname\n return host === \"localhost\" || host === \"127.0.0.1\" || host === \"10.0.2.2\"\n } catch {\n return false\n }\n}\n\nasync function getLocalDevRuntimeToken(runtimeEndpoint: string, opts?: {forceRefresh?: boolean}): Promise<string> {\n const now = Date.now()\n if (\n !opts?.forceRefresh &&\n localDevRuntimeToken?.runtimeUrl === runtimeEndpoint &&\n localDevRuntimeToken.expiresAtMs - now > 60_000\n ) {\n return localDevRuntimeToken.token\n }\n\n const base = new URL(runtimeEndpoint)\n base.port = String(LOCAL_AUTH_PORT)\n base.pathname = \"/api/dev/runtime-token\"\n base.search = new URLSearchParams({userId: \"local-phone-user\", tenantId: \"glassly\"}).toString()\n\n const res = await fetch(base.toString())\n if (!res.ok) {\n throw new Error(`cloudClient: local dev runtime token failed (${res.status})`)\n }\n const body = (await res.json()) as {access_token?: string; expires_in?: number}\n if (!body.access_token) {\n throw new Error(\"cloudClient: local dev runtime token response missing access_token\")\n }\n localDevRuntimeToken = {\n runtimeUrl: runtimeEndpoint,\n token: body.access_token,\n expiresAtMs: now + (body.expires_in ?? 300) * 1000,\n }\n return body.access_token\n}\n\nfunction toCloudClientStatusSnapshot(snapshot: RuntimeSnapshot): CloudClientStatusSnapshot {\n return {status: snapshot.status, audioTransport: snapshot.audioTransport}\n}\n\nfunction currentRuntimeStatus(): CloudClientStatusSnapshot {\n const state = useCloudClientStatusStore.getState()\n return {status: state.status, audioTransport: state.audioTransport}\n}\n\nfunction setRuntimeStatus(snapshot: RuntimeSnapshot): void {\n useCloudClientStatusStore.getState().setSnapshot(snapshot)\n emitStatus(toCloudClientStatusSnapshot(snapshot))\n}\n\nfunction resetRuntimeStatus(): void {\n useCloudClientStatusStore.getState().reset()\n emitStatus(currentRuntimeStatus())\n}\n\nfunction stringifyMeta(meta: unknown): string {\n if (!meta || typeof meta !== \"object\") return \"\"\n try {\n return ` ${JSON.stringify(meta)}`\n } catch {\n return \"\"\n }\n}\n\nconst cloudLogger = {\n debug: (msg: string, meta?: unknown) => console.log(`${LOG_TAG}: debug: ${msg}${stringifyMeta(meta)}`),\n info: (msg: string, meta?: unknown) => console.log(`${LOG_TAG}: info: ${msg}${stringifyMeta(meta)}`),\n warn: (msg: string, meta?: unknown) => console.warn(`${LOG_TAG}: warn: ${msg}${stringifyMeta(meta)}`),\n error: (msg: string, meta?: unknown) => console.warn(`${LOG_TAG}: error: ${msg}${stringifyMeta(meta)}`),\n}\n\nfunction notifyConnectionListeners(next: boolean): void {\n for (const l of connectionListeners) {\n try {\n l(next)\n } catch (err) {\n console.warn(`${LOG_TAG}: connection listener threw: ${(err as Error)?.message ?? err}`)\n }\n }\n}\n\nfunction extractUnsubscribe(sub: unknown): (() => void) | null {\n const candidates: unknown[] = []\n const s = sub as Record<string, unknown> | null | undefined\n if (s && typeof s === \"object\") {\n candidates.push(s)\n candidates.push((s.value as Record<string, unknown>)?.subscription)\n candidates.push((s.data as Record<string, unknown>)?.subscription)\n candidates.push(s.subscription)\n }\n for (const c of candidates) {\n const unsub = (c as {unsubscribe?: unknown})?.unsubscribe\n if (typeof unsub === \"function\") return unsub as () => void\n }\n return null\n}\n\nfunction ensureAuthWatch(): void {\n if (authStateUnsubscribe) return\n authStateUnsubscribe = () => {}\n\n const auth = getAuth()\n if (!auth?.onStateChange) return\n\n let reconnectPending = false\n try {\n const sub = auth.onStateChange((event, session) => {\n if (event === \"SIGNED_OUT\") {\n localMiniappUserIdentity.forget()\n return\n }\n // A new sign-in may belong to a different account. Force the next\n // storage request to resolve and persist that account's Core identity.\n // A device-local namespace is remembered first so the data written while\n // cloud was off can follow the user into the account (see\n // adoptLocalNamespace).\n if (event === \"SIGNED_IN\") {\n const local = localMiniappUserIdentity.get()\n if (local && isLocalUserId(local)) pendingLocalNamespace = local\n localMiniappUserIdentity.forget()\n }\n if (!session?.token) return\n if (connected || reconnectPending) return\n\n reconnectPending = true\n console.log(`${LOG_TAG}: auth session available (${event}) while disconnected — reconnecting`)\n try {\n cloudClientService.reconnect()\n } finally {\n BgTimer.setTimeout(() => {\n reconnectPending = false\n }, 0)\n }\n })\n\n const unsub = extractUnsubscribe(sub)\n if (unsub) authStateUnsubscribe = unsub\n } catch (err) {\n console.warn(`${LOG_TAG}: auth watch subscribe failed: ${(err as Error)?.message ?? err}`)\n }\n}\n\nfunction stopAuthWatch(): void {\n authStateUnsubscribe?.()\n authStateUnsubscribe = null\n}\n\nfunction emitTranscript(data: TranscriptionData): void {\n for (const l of transcriptListeners) {\n try {\n l(data)\n } catch (err) {\n console.warn(`${LOG_TAG}: transcript listener threw: ${(err as Error)?.message ?? err}`)\n }\n }\n}\n\nfunction emitTranslation(data: TranslationData): void {\n for (const l of translationListeners) {\n try {\n l(data)\n } catch (err) {\n console.warn(`${LOG_TAG}: translation listener threw: ${(err as Error)?.message ?? err}`)\n }\n }\n}\n\nfunction emitQuota(data: QuotaStatusPayload): void {\n for (const l of quotaListeners) {\n try {\n l(data)\n } catch (err) {\n console.warn(`${LOG_TAG}: quota listener threw: ${(err as Error)?.message ?? err}`)\n }\n }\n}\n\nfunction emitStatus(snapshot: CloudClientStatusSnapshot): void {\n for (const l of statusListeners) {\n try {\n l(snapshot)\n } catch (err) {\n console.warn(`${LOG_TAG}: status listener threw: ${(err as Error)?.message ?? err}`)\n }\n }\n}\n\nfunction ensureTransports(): void {\n if (transportsReady) return\n transportsReady = true\n setNativeUdp(() => createCloudUdpSocket())\n setSecureStorage(cloudSecureStore)\n if (Platform.OS !== \"android\") return\n setNativeHttp(async (input, init) => {\n if (typeof input !== \"string\" || (init?.body != null && typeof init.body !== \"string\")) {\n return globalThis.fetch(input, init)\n }\n const headers = Object.fromEntries(new Headers(init?.headers).entries())\n const result = await CrustModule.nativeHttpRequest(\n init?.method ?? \"GET\",\n input,\n headers,\n (init?.body as string | undefined) ?? null,\n )\n return new Response(nativeHttpResponseBody(result.status, result.body), {\n status: result.status,\n statusText: result.statusText,\n headers: result.headers,\n })\n })\n}\n\nfunction clearRuntimeEventSubscriptions(): void {\n runtimeStatusUnsubscribe?.()\n runtimeStatusUnsubscribe = null\n transcriptUnsubscribe?.()\n transcriptUnsubscribe = null\n translationUnsubscribe?.()\n translationUnsubscribe = null\n quotaUnsubscribe?.()\n quotaUnsubscribe = null\n}\n\n/**\n * The user's hard \"never talk to Glassly cloud\" stance (Settings > Privacy).\n * Read imperatively at every would-be-connect point rather than cached, so\n * flipping the toggle takes effect without a restart. `=== true` because\n * getSetting is `any` and an unhydrated store must not read as \"disabled\".\n */\nfunction cloudDisabled(): boolean {\n return useSettingsStore.getState().getSetting(SETTINGS.disable_cloud.key) === true\n}\n\nfunction startLc3FrameSizeWatcher(): void {\n if (lc3FrameSizeUnsubscribe) return\n\n let last = frameSizeBytes()\n lc3FrameSizeUnsubscribe = useSettingsStore.subscribe(\n (state) => state.getSetting(SETTINGS.lc3_frame_size.key),\n () => {\n const next = frameSizeBytes()\n if (next === last) return\n last = next\n if (!client) return\n console.log(`${LOG_TAG}: LC3 frame size changed to ${next}; reconnecting runtime`)\n cloudClientService.reconnect()\n },\n )\n}\n\nfunction stopLc3FrameSizeWatcher(): void {\n lc3FrameSizeUnsubscribe?.()\n lc3FrameSizeUnsubscribe = null\n}\n\n/**\n * Apply a mid-session flip of the Privacy toggle without a restart: turning it\n * on tears the live client down, turning it back off reconnects. Installed by\n * init() on BOTH branches — when cloud starts disabled there is no client to\n * hang the watcher off, but we still need to notice the user re-enabling it.\n */\nfunction startDisableCloudWatcher(): void {\n if (disableCloudUnsubscribe) return\n\n let last = cloudDisabled()\n disableCloudUnsubscribe = useSettingsStore.subscribe(\n (state) => state.getSetting(SETTINGS.disable_cloud.key),\n () => {\n const next = cloudDisabled()\n if (next === last) return\n last = next\n if (next) {\n console.log(`${LOG_TAG}: cloud disabled — tearing down client`)\n cloudClientService.stop()\n } else {\n console.log(`${LOG_TAG}: cloud re-enabled — reconnecting`)\n cloudClientService.init()\n }\n },\n )\n}\n\nfunction stopDisableCloudWatcher(): void {\n disableCloudUnsubscribe?.()\n disableCloudUnsubscribe = null\n}\n\nfunction construct(): void {\n ensureTransports()\n\n const endpoints = resolveEndpoints()\n console.log(`${LOG_TAG}: endpoints ${JSON.stringify(endpoints)}`)\n\n const coreAuth = {getSubjectToken}\n const auth = shouldUseLocalDevRuntimeToken(endpoints)\n ? {\n core: coreAuth,\n runtime: {getToken: (opts?: {forceRefresh?: boolean}) => getLocalDevRuntimeToken(endpoints.runtime, opts)},\n }\n : {core: coreAuth, runtime: {source: \"core\" as const}}\n\n client = new CloudClient({\n endpoints,\n // The phone LC3-encodes mic audio (even in phone/simulated mode); announce\n // LC3 at 16 kHz with the frame size the encoder emits.\n audio: {codec: \"lc3\", sampleRate: 16000, frameSizeBytes: frameSizeBytes()},\n auth,\n timers: {\n setTimeout: (callback, delayMs) => BgTimer.setTimeout(callback, delayMs),\n clearTimeout: (handle) => BgTimer.clearTimeout(handle as number),\n setInterval: (callback, intervalMs) => BgTimer.setInterval(callback, intervalMs),\n clearInterval: (handle) => BgTimer.clearInterval(handle as number),\n },\n logger: cloudLogger,\n })\n\n const c = client\n clearRuntimeEventSubscriptions()\n runtimeStatusUnsubscribe = c.runtime.onStatusChanged((status) => {\n if (c !== client) return\n setRuntimeStatus(status)\n })\n transcriptUnsubscribe = c.runtime.onTranscript((data) => {\n if (c !== client) return\n logCloudTranscriptMetric(data)\n emitTranscript(data)\n })\n translationUnsubscribe = c.runtime.onTranslation((data) => {\n if (c !== client) return\n emitTranslation(data)\n })\n quotaUnsubscribe = c.runtime.onQuota((data) => {\n if (c !== client) return\n emitQuota(data)\n })\n setRuntimeStatus(c.runtime.getStatus())\n\n c.runtime.onConnected(() => {\n if (c !== client) return\n connected = true\n console.log(`${LOG_TAG}: runtime connected`)\n console.log(`${LOG_TAG}: debug: ws-session-debug connected`)\n // Cloud is up — cancel any pending persistent-failure alarm and re-arm for the\n // next outage.\n clearPersistentFailureAlarm()\n // Re-apply the authoritative subscription set, including the empty set, so\n // a fresh phone launch clears any stale server-side audio subscriptions.\n c.runtime\n .setSubscriptions(audioSubscriptions)\n .catch((err) =>\n console.warn(`${LOG_TAG}: re-applying queued subscriptions failed: ${(err as Error)?.message ?? err}`),\n )\n notifyConnectionListeners(true)\n })\n c.runtime.onDisconnected((info) => {\n if (c !== client) return\n connected = false\n console.log(`${LOG_TAG}: runtime disconnected (${info.reason})`)\n console.log(\n `${LOG_TAG}: debug: ws-session-debug disconnected reason=${info.reason} willStayDown=${/superseded by newer session/i.test(info.reason)}`,\n )\n // Arm the persistent-failure alarm once; if we're still down when it fires, raise\n // the notification. A reconnect within the window cancels it (onConnected above).\n if (!persistentFailureTimer && !persistentFailureNotified) {\n persistentFailureTimer = BgTimer.setTimeout(() => {\n persistentFailureTimer = null\n if (connected) return\n persistentFailureNotified = true\n islandNotifications.emit({\n kind: \"connection_failed_persistent\",\n reason: `Cloud session has been disconnected for over ${Math.round(CLOUD_PERSISTENT_FAILURE_MS / 1000)}s`,\n metadata: {downForMs: CLOUD_PERSISTENT_FAILURE_MS, lastReason: info.reason},\n timestamp: Date.now(),\n })\n }, CLOUD_PERSISTENT_FAILURE_MS)\n }\n notifyConnectionListeners(false)\n })\n c.runtime.onError((err) => {\n console.warn(`${LOG_TAG}: runtime error: ${err.code}`)\n })\n\n // Dead credentials (refresh AND subject exchange both failed). Surface to\n // the host so it can force a re-login — otherwise the app looks signed-in\n // while every cloud feature silently fails. Fires at most once per client\n // instance (the auth module latches until a successful exchange).\n c.auth.onExpired(() => {\n if (c !== client) return\n console.warn(`${LOG_TAG}: cloud session expired beyond recovery — notifying host`)\n getAuth()?.onSessionExpired?.()\n })\n\n // Best-effort connect. Do not crash the app if the dev cloud is unreachable.\n c.runtime\n .connect()\n .then(() => console.log(`${LOG_TAG}: connect() resolved`))\n .catch((err) => console.warn(`${LOG_TAG}: connect() failed: ${err?.message ?? err}`))\n\n syncCoreAccessTokenToBluetooth().catch((err) =>\n console.warn(`${LOG_TAG}: initial Bluetooth core_token sync failed: ${(err as Error)?.message ?? err}`),\n )\n\n startLc3FrameSizeWatcher()\n}\n\n/**\n * engine's cloud client. Owns the singleton CloudClient, its connection state,\n * and the runtime-hook wiring.\n */\nexport const cloudClientService = {\n /**\n * Construct (once) + connect the client. Idempotent. Best-effort connect — a\n * failure is logged and the app keeps running. Requires\n * `engine.configure({auth, config})` first.\n */\n init(): void {\n if (client) return\n // Privacy stance wins over every caller, including the lazy `if (!client)\n // this.init()` paths below — this is the one chokepoint where the client\n // gets built, so refusing here keeps the socket from ever opening.\n if (cloudDisabled()) {\n console.log(`${LOG_TAG}: init skipped — cloud disabled in Privacy settings`)\n startDisableCloudWatcher()\n return\n }\n ensureAuthWatch()\n startDisableCloudWatcher()\n construct()\n },\n\n /** True when the user has turned Glassly cloud off entirely. */\n isCloudDisabled(): boolean {\n return cloudDisabled()\n },\n\n /**\n * Tear down + rebuild. Pass new endpoints to switch URLs; pass `null` to CLEAR\n * a prior override and fall back to the boot config (so cleared/default cloud\n * URLs don't keep reconnecting to a stale override); omit to keep the current.\n */\n reconnect(endpoints?: {core: string; runtime: string} | null): void {\n const prevCore = resolveEndpoints().core\n if (endpoints !== undefined) endpointsOverride = endpoints\n // Tokens are minted per backend (per-env signing keys + user DB), so a\n // core switch makes the persisted refresh token dead weight the new\n // backend will reject. Drop it so the client goes straight to a subject\n // exchange instead of burning a round trip on a guaranteed invalid_grant.\n // Key literal matches cloud-client's token-store.ts REFRESH_TOKEN_KEY.\n if (resolveEndpoints().core !== prevCore) {\n console.log(`${LOG_TAG}: core endpoint changed — dropping persisted cloud refresh token`)\n void cloudSecureStore.delete(\"glassly.cloud-client.refreshToken\")\n }\n try {\n client?.runtime.close()\n } catch (err) {\n console.warn(`${LOG_TAG}: reconnect close() failed: ${(err as Error)?.message ?? err}`)\n }\n clearRuntimeEventSubscriptions()\n clearPersistentFailureAlarm()\n\n const wasConnected = connected\n client = null\n localDevRuntimeToken = null\n connected = false\n resetRuntimeStatus()\n if (wasConnected) notifyConnectionListeners(false)\n\n // Same gate as init(): endpoint changes / LC3 reconnects must not resurrect\n // a connection the user has switched off.\n if (cloudDisabled()) {\n console.log(`${LOG_TAG}: reconnect skipped — cloud disabled in Privacy settings`)\n return\n }\n construct()\n },\n\n async getPreinstalledMiniappRegistry(): Promise<PreinstalledMiniappRegistry> {\n if (!client) this.init()\n const c = client\n if (!c?.core) throw new Error(\"cloud client core is unavailable\")\n return c.core.miniapps.getRegistry()\n },\n\n async getStoreCatalog(): Promise<StoreCatalogResponse> {\n if (!client) this.init()\n const c = client\n if (!c?.core) throw new Error(\"cloud client core is unavailable\")\n return c.core.store.list()\n },\n\n async getStoreListing(packageName: string): Promise<StoreListing> {\n if (!client) this.init()\n const c = client\n if (!c?.core) throw new Error(\"cloud client core is unavailable\")\n return c.core.store.get(packageName)\n },\n\n /** Bytes of a store icon or screenshot; these routes need the user Bearer. */\n async fetchStoreAsset(url: string): Promise<Uint8Array> {\n if (!client) this.init()\n const c = client\n if (!c?.core) throw new Error(\"cloud client core is unavailable\")\n return c.core.store.fetchAsset(url)\n },\n\n /**\n * Resolve the stable Core-owned Glassly user id.\n *\n * Storage must use this identity rather than the short-lived Core access\n * token. A previously verified id is restored from MMKV so local miniapps\n * remain available after an offline process restart. On first sign-in,\n * callers join the auth module's single-flight exchange/refresh instead of\n * falling back to an anonymous namespace.\n */\n async resolveUserId(): Promise<string> {\n // With cloud off there is no client to exchange a token with and never will\n // be, so the online path below would throw on every storage call and take\n // offline-capable local miniapps down with it. Fall back to a device-local\n // namespace instead — a cached Core id still wins inside resolveLocal().\n if (cloudDisabled()) return localMiniappUserIdentity.resolveLocal()\n\n return localMiniappUserIdentity.resolve(async () => {\n if (!client) this.init()\n const c = client\n if (!c) throw new Error(\"cloud client not initialized\")\n\n await c.auth.getCoreToken()\n if (c !== client) throw new Error(\"cloud client changed while resolving user identity\")\n // Runs before resolve() persists the id, so the local namespace is adopted\n // whichever path reaches Core identity first (this or the token sync).\n adoptLocalNamespace(c.auth.identity.userId)\n return c.auth.identity.userId\n })\n },\n\n /** Read the stable Glassly user id after async identity resolution. */\n getUserId(): string {\n // Mirrors resolveUserId(): with cloud off, minting is synchronous and\n // cannot fail, so sync callers (BlobStore) don't depend on an async resolve\n // having run first.\n if (cloudDisabled()) return localMiniappUserIdentity.resolveLocal()\n const userId = localMiniappUserIdentity.get()\n if (!userId) throw new Error(\"Glassly user identity is unavailable\")\n return userId\n },\n\n async getMiniappAuthToken(\n packageName: string,\n opts?: {minTtlMs?: number; devAttestation?: string},\n ): Promise<MiniappAuthToken> {\n if (!client) this.init()\n const c = client\n if (!c) throw new Error(\"cloud client not initialized\")\n\n const {token, expiresAt} = await c.auth.getMiniappToken(packageName, opts)\n const identity = c.auth.identity\n return {\n userId: identity.userId,\n tenantId: identity.tenantId,\n token,\n expiresAt: normalizeExpiresAt(expiresAt),\n }\n },\n\n /**\n * Tear down the client + connection (the engine.stop() lifecycle).\n *\n * Deliberately leaves the disable-cloud watcher installed: this is also the\n * teardown the Privacy toggle triggers, and dropping the subscription here\n * would strand the app disconnected until restart when the user flips the\n * toggle back off. `shutdown()` is the full-stop variant that removes it.\n */\n stop(): void {\n try {\n client?.runtime.close()\n } catch (err) {\n console.warn(`${LOG_TAG}: stop close() failed: ${(err as Error)?.message ?? err}`)\n }\n stopLc3FrameSizeWatcher()\n stopAuthWatch()\n clearRuntimeEventSubscriptions()\n clearPersistentFailureAlarm()\n const wasConnected = connected\n client = null\n // stop() is part of the logout lifecycle and runs before the host emits\n // SIGNED_OUT. Remove the persisted namespace owner here so a later account\n // can never inherit it. A force-stop/process kill does not call stop(), so\n // the cached id still survives the offline cold-start case.\n localMiniappUserIdentity.forget()\n localDevRuntimeToken = null\n connected = false\n resetRuntimeStatus()\n if (wasConnected) notifyConnectionListeners(false)\n },\n\n /** `stop()` plus the disable-cloud watcher — for a genuine engine teardown. */\n shutdown(): void {\n this.stop()\n stopDisableCloudWatcher()\n },\n\n /** Device-side managed photo: presign now, deliver bytes, await ready. */\n startManagedPhoto(opts: Record<string, unknown> = {}) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.startManagedPhoto(opts)\n },\n awaitManagedPhotoReady(requestId: string) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.awaitManagedPhotoReady(requestId)\n },\n\n /** Managed stream: provision ingest+playback on the runtime. */\n startManagedStream(opts: Record<string, unknown> = {}) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.startManagedStream(opts)\n },\n getManagedStreamStatus(streamId: string) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.getManagedStreamStatus(streamId)\n },\n stopManagedStream(streamId: string) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.stopManagedStream(streamId)\n },\n\n /** Current live-session connection state (handshake completed). */\n isConnected(): boolean {\n return connected\n },\n\n /** Subscribe to connection-state transitions. Returns an unsubscribe fn. */\n onConnectionChange(listener: (connected: boolean) => void): () => void {\n connectionListeners.add(listener)\n return () => {\n connectionListeners.delete(listener)\n }\n },\n\n /** Replace the v2 cloud's audio subscription set for the live session. */\n async setSubscriptions(subs: AudioSubscription[]): Promise<void> {\n // Cache unconditionally so the desired set survives a not-yet-connected\n // session and reconnects; the onConnected handler re-applies the cached set.\n audioSubscriptions = subs\n const c = client\n if (connected && c) {\n await c.runtime.setSubscriptions(subs)\n }\n },\n\n sendAudioFrame(frame: Uint8Array): void {\n client?.runtime.sendAudioFrame(frame)\n },\n\n onTranscript(cb: (d: TranscriptionData) => void): () => void {\n transcriptListeners.add(cb)\n return () => {\n transcriptListeners.delete(cb)\n }\n },\n\n onTranslation(cb: (d: TranslationData) => void): () => void {\n translationListeners.add(cb)\n return () => {\n translationListeners.delete(cb)\n }\n },\n\n /** Plan-quota block/unblock pushes for metered cloud streams. */\n onQuota(cb: (d: QuotaStatusPayload) => void): () => void {\n quotaListeners.add(cb)\n return () => {\n quotaListeners.delete(cb)\n }\n },\n\n getStatus(): CloudClientStatusSnapshot {\n return currentRuntimeStatus()\n },\n\n getCoreUrl(): string {\n return resolveEndpoints().core\n },\n\n syncCoreTokenToBluetooth(): Promise<string> {\n return syncCoreAccessTokenToBluetooth()\n },\n\n onStatusChanged(cb: (snapshot: CloudClientStatusSnapshot) => void): () => void {\n statusListeners.add(cb)\n return () => {\n statusListeners.delete(cb)\n }\n },\n\n tts: {\n speak(text: string, options?: Parameters<CloudClient[\"runtime\"][\"tts\"][\"speak\"]>[1]) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.tts.speak(text, options)\n },\n },\n\n llm: {\n /**\n * One completion turn through the cloud LLM service. `userApiKey` is the\n * user's own provider key when they've saved one; the cloud bills that key\n * instead of the platform's and skips metering. It rides as a header, never\n * in the request body.\n */\n complete(\n req: Parameters<CloudClient[\"runtime\"][\"llm\"][\"complete\"]>[0],\n opts?: Parameters<CloudClient[\"runtime\"][\"llm\"][\"complete\"]>[1],\n ) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.llm.complete(req, opts)\n },\n\n /** One agentic visual-generation run. Long-running; see cloud-client docs. */\n generate(\n req: Parameters<CloudClient[\"runtime\"][\"llm\"][\"generate\"]>[0],\n opts?: Parameters<CloudClient[\"runtime\"][\"llm\"][\"generate\"]>[1],\n ) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.llm.generate(req, opts)\n },\n\n /** Start a pollable generate job (async flavor; 404 on old clouds). */\n startGenerateJob(\n req: Parameters<CloudClient[\"runtime\"][\"llm\"][\"startGenerateJob\"]>[0],\n opts?: Parameters<CloudClient[\"runtime\"][\"llm\"][\"startGenerateJob\"]>[1],\n ) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.llm.startGenerateJob(req, opts)\n },\n\n generateJobStatus(jobId: string) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.llm.generateJobStatus(jobId)\n },\n\n cancelGenerateJob(jobId: string) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.llm.cancelGenerateJob(jobId)\n },\n },\n\n maps: {\n directions(req: Parameters<CloudClient[\"runtime\"][\"maps\"][\"directions\"]>[0]) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.maps.directions(req)\n },\n reverseGeocode(coord: Parameters<CloudClient[\"runtime\"][\"maps\"][\"reverseGeocode\"]>[0]) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.maps.reverseGeocode(coord)\n },\n placeAutocomplete(req: Parameters<CloudClient[\"runtime\"][\"maps\"][\"placeAutocomplete\"]>[0]) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.maps.placeAutocomplete(req)\n },\n placeDetails(req: Parameters<CloudClient[\"runtime\"][\"maps\"][\"placeDetails\"]>[0]) {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.maps.placeDetails(req)\n },\n /**\n * The deployment's public map render token ({provider, token}) for the\n * consumers that can't be proxied (tiles, native nav SDK). `token` null =\n * this deployment serves none. See MapboxTokenService for the caching\n * consumer.\n */\n renderToken() {\n if (!client) throw new Error(\"cloud client not connected\")\n return client.runtime.maps.renderToken()\n },\n },\n\n core: {\n reports: {\n submit(...args: Parameters<CloudCore[\"reports\"][\"submit\"]>) {\n return getCoreClient().reports.submit(...args)\n },\n addLogs(...args: Parameters<CloudCore[\"reports\"][\"addLogs\"]>) {\n return getCoreClient().reports.addLogs(...args)\n },\n addScreenshots(...args: Parameters<CloudCore[\"reports\"][\"addScreenshots\"]>) {\n return getCoreClient().reports.addScreenshots(...args)\n },\n complete(...args: Parameters<CloudCore[\"reports\"][\"complete\"]>) {\n return getCoreClient().reports.complete(...args)\n },\n },\n supportProfile: {\n update(...args: Parameters<CloudCore[\"supportProfile\"][\"update\"]>) {\n return getCoreClient().supportProfile.update(...args)\n },\n },\n },\n\n hasAudioSubscriptions(): boolean {\n return audioSubscriptions.length > 0\n },\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { TranscriptionData } from "@glassly/cloud-protocol";
|
|
2
|
-
export declare function
|
|
3
|
-
export declare function
|
|
2
|
+
export declare function buildCloudTranscriptMetric(data: TranscriptionData): Record<string, unknown>;
|
|
3
|
+
export declare function logCloudTranscriptMetric(data: TranscriptionData): void;
|
|
4
4
|
//# sourceMappingURL=CloudTranscriptE2EMetrics.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CloudTranscriptE2EMetrics.d.ts","sourceRoot":"","sources":["../../src/services/CloudTranscriptE2EMetrics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,yBAAyB,CAAA;AAI9D,wBAAgB,
|
|
1
|
+
{"version":3,"file":"CloudTranscriptE2EMetrics.d.ts","sourceRoot":"","sources":["../../src/services/CloudTranscriptE2EMetrics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,yBAAyB,CAAA;AAI9D,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAkB3F;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,iBAAiB,GAAG,IAAI,CAEtE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { buildE2EMetric, logE2EMetricPayload } from "../utils/e2eMetrics";
|
|
2
|
-
export function
|
|
2
|
+
export function buildCloudTranscriptMetric(data) {
|
|
3
3
|
return buildE2EMetric("cloud_v2_transcript", {
|
|
4
4
|
text: data.text,
|
|
5
5
|
state: data.isFinal ? "final" : "interim",
|
|
@@ -18,7 +18,7 @@ export function buildCloudV2TranscriptMetric(data) {
|
|
|
18
18
|
subscription: data.subscription,
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
|
-
export function
|
|
22
|
-
logE2EMetricPayload(
|
|
21
|
+
export function logCloudTranscriptMetric(data) {
|
|
22
|
+
logE2EMetricPayload(buildCloudTranscriptMetric(data), "cloud_v2_transcript");
|
|
23
23
|
}
|
|
24
24
|
//# sourceMappingURL=CloudTranscriptE2EMetrics.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CloudTranscriptE2EMetrics.js","sourceRoot":"","sources":["../../src/services/CloudTranscriptE2EMetrics.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,cAAc,EAAE,mBAAmB,EAAC,MAAM,qBAAqB,CAAA;AAEvE,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"CloudTranscriptE2EMetrics.js","sourceRoot":"","sources":["../../src/services/CloudTranscriptE2EMetrics.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,cAAc,EAAE,mBAAmB,EAAC,MAAM,qBAAqB,CAAA;AAEvE,MAAM,UAAU,0BAA0B,CAAC,IAAuB;IAChE,OAAO,cAAc,CAAC,qBAAqB,EAAE;QAC3C,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;QACzC,QAAQ,EAAE,IAAI,CAAC,OAAO;QACtB,iBAAiB,EAAE,IAAI,CAAC,gBAAgB;QACxC,iBAAiB,EAAE,IAAI,CAAC,gBAAgB;QACxC,YAAY,EAAE,IAAI,CAAC,WAAW;QAC9B,UAAU,EAAE,IAAI,CAAC,SAAS;QAC1B,QAAQ,EAAE,IAAI,CAAC,OAAO;QACtB,MAAM,EAAE,IAAI,CAAC,KAAK;QAClB,WAAW,EAAE,IAAI,CAAC,UAAU;QAC5B,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,YAAY,EAAE,IAAI,CAAC,SAAS;QAC5B,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM;QAC/B,YAAY,EAAE,IAAI,CAAC,YAAY;KAChC,CAAC,CAAA;AACJ,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,IAAuB;IAC9D,mBAAmB,CAAC,0BAA0B,CAAC,IAAI,CAAC,EAAE,qBAAqB,CAAC,CAAA;AAC9E,CAAC","sourcesContent":["import type {TranscriptionData} from \"@glassly/cloud-protocol\"\n\nimport {buildE2EMetric, logE2EMetricPayload} from \"../utils/e2eMetrics\"\n\nexport function buildCloudTranscriptMetric(data: TranscriptionData): Record<string, unknown> {\n return buildE2EMetric(\"cloud_v2_transcript\", {\n text: data.text,\n state: data.isFinal ? \"final\" : \"interim\",\n is_final: data.isFinal,\n resolved_language: data.resolvedLanguage,\n language_detected: data.languageDetected,\n utterance_id: data.utteranceId,\n speaker_id: data.speakerId,\n start_ms: data.startMs,\n end_ms: data.endMs,\n duration_ms: data.durationMs,\n provider: data.provider,\n confidence: data.confidence,\n timestamp_ms: data.timestamp,\n token_count: data.tokens.length,\n subscription: data.subscription,\n })\n}\n\nexport function logCloudTranscriptMetric(data: TranscriptionData): void {\n logE2EMetricPayload(buildCloudTranscriptMetric(data), \"cloud_v2_transcript\")\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeviceEventRouter.d.ts","sourceRoot":"","sources":["../../src/services/DeviceEventRouter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DeviceEventRouter.d.ts","sourceRoot":"","sources":["../../src/services/DeviceEventRouter.ts"],"names":[],"mappings":"AA0CA,wBAAgB,sBAAsB,IAAI,IAAI,CAuQ7C;AAED,wBAAgB,qBAAqB,IAAI,IAAI,CAI5C"}
|
|
@@ -34,6 +34,7 @@ import { retirePendingSelectionOnPromotion } from "./PairingIdentity";
|
|
|
34
34
|
import GlobalEventEmitter from "../utils/GlobalEventEmitter";
|
|
35
35
|
import { asgCameraApi } from "./asg/asgCameraApi";
|
|
36
36
|
import { dispatchTouchEvent, resetTouchInput } from "./GlassesTouchInput";
|
|
37
|
+
import neuralBandInput from "./neuralBand/NeuralBandInput";
|
|
37
38
|
import dashboardOpenTrace from "./debug/DashboardOpenTrace";
|
|
38
39
|
let subs = [];
|
|
39
40
|
export function startDeviceEventRouter() {
|
|
@@ -177,6 +178,10 @@ export function startDeviceEventRouter() {
|
|
|
177
178
|
// Physical keyboard bridged through G2 Glassly CFW: raw HID transitions →
|
|
178
179
|
// layout-translated keyboard_event stream (with synthesized auto-repeat).
|
|
179
180
|
subs.push(BluetoothSdk.addListener("keyboard_key", (event) => glassesKeyboardInput.handle(event)));
|
|
181
|
+
// Meta Neural Band: its gestures ride touch_event above; these are its own streams.
|
|
182
|
+
subs.push(BluetoothSdk.addListener("neural_band_claim", (event) => neuralBandInput.handleClaim(event)));
|
|
183
|
+
subs.push(BluetoothSdk.addListener("neural_band_handwriting", (event) => neuralBandInput.handleHandwriting(event)));
|
|
184
|
+
subs.push(BluetoothSdk.addListener("neural_band_pointer", (event) => neuralBandInput.handlePointer(event)));
|
|
180
185
|
subs.push({
|
|
181
186
|
remove: useGlassesStore.subscribe((s) => s.keyboardConnected === true, (connected) => {
|
|
182
187
|
if (!connected)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeviceEventRouter.js","sourceRoot":"","sources":["../../src/services/DeviceEventRouter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,YAAY,MAAM,iCAAiC,CAAA;AAC1D,OAAO,EAAC,OAAO,EAAC,MAAM,iBAAiB,CAAA;AAEvC,OAAO,mBAAmB,MAAM,uBAAuB,CAAA;AACvD,OAAO,oBAAoB,MAAM,wBAAwB,CAAA;AACzD,OAAO,oBAAoB,MAAM,wBAAwB,CAAA;AACzD,OAAO,2BAA2B,MAAM,+BAA+B,CAAA;AACvE,OAAO,uBAAuB,MAAM,2BAA2B,CAAA;AAC/D,OAAO,oBAAoB,MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAA;AAC7D,OAAO,EAAC,sBAAsB,EAAC,MAAM,0BAA0B,CAAA;AAC/D,OAAO,EAAC,kBAAkB,EAAC,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAC,iBAAiB,EAAC,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAC,iCAAiC,EAAC,MAAM,mBAAmB,CAAA;AACnE,OAAO,kBAAkB,MAAM,6BAA6B,CAAA;AAC5D,OAAO,EAA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":["/**\n * Device-event router — engine-owned. Subscribes to the inbound native BLE/device\n * events and routes them into the engine runtime: device stores, the process event\n * bus, the photo/stream coordinators, and local miniapps (via forwardEvent).\n *\n * Why this exists: engine owns the stores, coordinators, miniapp runtime, and facades,\n * but it never *subscribed to the device* for most events — the host MantleManager was\n * still the event router the whole runtime secretly depended on. So a bare OEM that\n * imported engine + called engine.start() got a connected runtime with almost no device\n * data flowing in (no miniapp input, dead gallery sync, starved coordinators). This\n * service moves those inbound bridges into engine so ANY host gets them.\n *\n * Scope: the engine legs only. The Cloud V1 relays that used to live beside them in\n * MantleManager (touch→cloud, the cloud-SDK stream/photo legs, etc.) were deleted with\n * Cloud V1 app end-of-life.\n *\n * Started by `engine.start()`. Idempotent.\n */\nimport BluetoothSdk from \"@glassly/bluetooth-sdk/internal\"\nimport {shallow} from \"zustand/shallow\"\n\nimport localMiniappRuntime from \"./LocalMiniappRuntime\"\nimport glassesKeyboardInput from \"./GlassesKeyboardInput\"\nimport glassesSensorService from \"./GlassesSensorService\"\nimport localSttFallbackCoordinator from \"./LocalSttFallbackCoordinator\"\nimport localTranslationService from \"./LocalTranslationService\"\nimport speakerLabelResolver from \"./SpeakerLabelResolver\"\nimport {phonePhotoCoordinator} from \"./PhonePhotoCoordinator\"\nimport {phoneStreamCoordinator} from \"./PhoneStreamCoordinator\"\nimport {isGlassesConnected} from \"./GlassesReadiness\"\nimport {useGlassesStore} from \"../stores/glasses\"\nimport {useSettingsStore} from \"../stores/settings\"\nimport {useAppStatusStore} from \"../stores/apps\"\nimport {retirePendingSelectionOnPromotion} from \"./PairingIdentity\"\nimport GlobalEventEmitter from \"../utils/GlobalEventEmitter\"\nimport {asgCameraApi} from \"./asg/asgCameraApi\"\nimport {dispatchTouchEvent, resetTouchInput} from \"./GlassesTouchInput\"\nimport dashboardOpenTrace from \"./debug/DashboardOpenTrace\"\n\nlet subs: Array<{remove: () => void}> = []\n\nexport function startDeviceEventRouter(): void {\n if (subs.length) return\n\n subs.push(\n BluetoothSdk.addListener(\"light_sensor\", ({type: _type, ...reading}) => {\n localMiniappRuntime.forwardEvent(\"light_sensor\", reading)\n }),\n // Stock firmware emits these only inside its nav UI; custom firmware whenever the\n // raw compass runs. Either way they feed the one session.compass stream.\n BluetoothSdk.addListener(\"compass_heading\", ({type: _type, heading, ...reading}) => {\n localMiniappRuntime.forwardEvent(\"glasses_compass\", {degrees: heading, ...reading})\n }),\n BluetoothSdk.addListener(\"compass_calibration\", ({type: _type, ...reading}) => {\n localMiniappRuntime.forwardEvent(\"compass_calibration\", reading)\n }),\n {\n remove: useGlassesStore.subscribe(\n (s) => s.connection,\n (connection) => {\n if (isGlassesConnected(connection)) void glassesSensorService.resync()\n else glassesSensorService.disconnected()\n },\n ),\n },\n {\n // CFW classification lands after device-ready; compass demand recorded before\n // that only reaches the firmware once the scene canvas is published.\n remove: useGlassesStore.subscribe(\n (s) => s.sceneCanvasWidth,\n (width) => {\n if ((width ?? 0) > 0) void glassesSensorService.resync()\n },\n ),\n },\n )\n\n // --- device state → engine stores ---\n\n // Standalone WiFi status → glasses store.\n subs.push(\n BluetoothSdk.addListener(\"wifi_status_change\", (event) => {\n const {type: _type, ...wifi} = event\n useGlassesStore.getState().setGlassesInfo({wifi})\n }),\n )\n\n // Forward glasses Wi-Fi to miniapps (session.glasses.onWifi) from the STORE — the\n // single source of truth — so every path converges here: wifi_status_change,\n // onGlassesStatus, and BLE disconnect. Effective connectivity requires the glasses\n // to be connected AND on Wi-Fi, so a disconnect correctly flips `connected` false.\n subs.push({\n remove: useGlassesStore.subscribe(\n (s) => {\n const connected = isGlassesConnected(s.connection) && s.wifi.state === \"connected\"\n return {\n connected,\n ssid: s.wifi.state === \"connected\" ? s.wifi.ssid : undefined,\n localIp: s.wifi.state === \"connected\" ? s.wifi.localIp : undefined,\n }\n },\n (wifi) => localMiniappRuntime.forwardEvent(\"glasses_wifi\", wifi),\n {equalityFn: shallow},\n ),\n })\n\n // Battery streams follow the store, including initial native hydration and\n // onGlassesStatus patches. G2 can report its level without battery_status;\n // forwarding only that legacy event leaves a running dashboard ring-only.\n subs.push({\n remove: useGlassesStore.subscribe(\n (s) => ({level: s.batteryLevel, charging: s.charging}),\n (battery) => {\n localMiniappRuntime.forwardEvent(\"glasses_battery_update\", {\n type: \"glasses_battery_update\",\n ...battery,\n timestamp: Date.now(),\n })\n },\n {equalityFn: shallow},\n ),\n })\n\n // Legacy standalone events feed the same store subscription.\n subs.push(\n BluetoothSdk.addListener(\"battery_status\", (event) => {\n const state = useGlassesStore.getState()\n state.setBatteryInfo(event.level, event.charging, state.caseBatteryLevel, state.caseCharging)\n }),\n )\n\n // Hotspot status → glasses store + event bus. engine's own gallerySyncService listens\n // on the bus for these, so without this bridge engine's gallery sync is dead.\n subs.push(\n BluetoothSdk.addListener(\"hotspot_status_change\", (event) => {\n const enabled = event.state === \"enabled\"\n const ssid = enabled ? event.ssid : \"\"\n const password = enabled ? event.password : \"\"\n const localIp = enabled ? event.localIp : \"\"\n useGlassesStore.getState().setHotspotInfo(enabled, ssid, password, localIp)\n // Always retarget the ASG camera client: on disable (or an event with no\n // IP) fall back to the localhost default so later calls fail fast instead\n // of hitting the previous network's stale glasses IP.\n asgCameraApi.setServer(localIp || \"localhost\", 8089)\n GlobalEventEmitter.emit(\"hotspot_status_change\", {enabled, ssid, password, local_ip: localIp})\n }),\n )\n subs.push(\n BluetoothSdk.addListener(\"hotspot_error\", (event) => {\n GlobalEventEmitter.emit(\"hotspot_error\", {error_message: event.errorMessage, timestamp: event.timestamp})\n }),\n )\n\n // Glasses gallery content counts → event bus (consumed by gallerySyncService).\n subs.push(\n BluetoothSdk.addListener(\"gallery_status\", (event) => {\n GlobalEventEmitter.emit(\"gallery_status\", {\n photos: event.photos,\n videos: event.videos,\n total: event.total,\n has_content: event.hasContent,\n camera_busy: event.cameraBusy,\n })\n }),\n )\n\n // Hardware-originated setting changes (user changes a setting ON the glasses) → store.\n // The inbound complement to GlassesSettingsSync (which only pushes store→device).\n subs.push(\n BluetoothSdk.addListener(\"save_setting\", async (event) => {\n const settings = useSettingsStore.getState()\n // Damp the relay: native re-echoes some settings unconditionally (e.g.\n // the identity block at every handleDeviceReady) — a same-value echo\n // must not become a store write (persistence churn + change-push noise).\n if (settings.getSetting(event.key) !== event.value) {\n await settings.setSetting(event.key, event.value)\n }\n // Two-phase identity: a promoted default retires the pending selection\n // marker. The rule lives with PairingIdentity (a no-op for other keys).\n await retirePendingSelectionOnPromotion(event.key, event.value)\n }),\n )\n\n // --- coordinators (owns()-gated) ---\n\n // Phone-owned photo errors settle the in-flight long-poll fast (vs. timeout).\n // Non-owned photo responses used to forward to the Cloud V1 photo pipeline via\n // restComms; that relay was removed with Cloud V1 app end-of-life, so they drop.\n // Wire v2 sends a short 4-hex BLE requestId; the coordinator maps it back to\n // the cloud requestId (resolveCloudRequestId) before ownership checks.\n subs.push(\n BluetoothSdk.addListener(\"photo_response\", (event) => {\n const cloudRequestId = event.requestId ? phonePhotoCoordinator.resolveCloudRequestId(event.requestId) : \"\"\n if (cloudRequestId && phonePhotoCoordinator.owns(cloudRequestId)) {\n if (event.state === \"error\") {\n phonePhotoCoordinator.handlePhotoError(\n event.requestId ?? cloudRequestId,\n event.errorCode ?? \"GLASSES_ERROR\",\n event.errorMessage ?? \"Glasses reported an error\",\n )\n }\n }\n }),\n )\n\n // Phone-owned stream status / keep-alive → the stream coordinator. The Cloud V1 relay\n // for non-owned streams was removed with Cloud V1 app end-of-life.\n subs.push(\n BluetoothSdk.addListener(\"stream_status\", (event) => {\n if (event.streamId && phoneStreamCoordinator.owns(event.streamId)) {\n phoneStreamCoordinator.handleGlassesStatus(event)\n }\n }),\n )\n subs.push(\n BluetoothSdk.addListener(\"keep_alive_ack\", (event) => {\n if (event.streamId && phoneStreamCoordinator.owns(event.streamId)) {\n phoneStreamCoordinator.handleKeepAliveAck(event)\n }\n }),\n )\n\n // --- device input → local miniapps (forwardEvent is subscriber-gated; a no-op when\n // no miniapp listens). The v1 SocketComms cloud legs for these were removed with\n // the Cloud V1 ripout. ---\n\n subs.push(\n BluetoothSdk.addListener(\"button_press\", (event) => {\n localMiniappRuntime.forwardEvent(\"button_press\", event)\n }),\n )\n subs.push(BluetoothSdk.addListener(\"touch_event\", dispatchTouchEvent))\n // Physical keyboard bridged through G2 Glassly CFW: raw HID transitions →\n // layout-translated keyboard_event stream (with synthesized auto-repeat).\n subs.push(BluetoothSdk.addListener(\"keyboard_key\", (event) => glassesKeyboardInput.handle(event)))\n subs.push({\n remove: useGlassesStore.subscribe(\n (s) => s.keyboardConnected === true,\n (connected) => {\n if (!connected) glassesKeyboardInput.reset()\n },\n ),\n })\n // G2 IMU accelerometer — payload already matches the miniapp AccelData shape.\n subs.push(\n BluetoothSdk.addListener(\"accel_event\", (event) => {\n localMiniappRuntime.forwardEvent(\"accel_event\", {\n x: event.x,\n y: event.y,\n z: event.z,\n timestamp: typeof event.timestamp === \"number\" ? event.timestamp : Date.now(),\n })\n }),\n )\n // Head position — translate native {up:boolean} → SDK {position:\"up\"|\"down\"}.\n // The dashboard miniapp opens on head-up from this stream (ADR-0006).\n subs.push(\n BluetoothSdk.addListener(\"head_up\", (event) => {\n if (event.up) dashboardOpenTrace.trigger(\"head-up\")\n localMiniappRuntime.forwardEvent(\"head_up\", {position: event.up ? \"up\" : \"down\", timestamp: Date.now()})\n }),\n )\n subs.push({remove: dashboardOpenTrace.start()})\n // On-device STT transcripts → local miniapps only while the local engine is\n // active (cloud fallback or an explicit forceLocal subscription). The runtime\n // filters mixed local/cloud delivery per miniapp to avoid double-delivery.\n // forwardEvent is subscriber-gated — a no-op when no miniapp listens.\n // (Was MantleManager.handle_local_transcription; its offline-captions display branch\n // went away with the pseudo captions renderer.)\n subs.push(\n BluetoothSdk.addListener(\"local_transcription\", (event) => {\n if (!localSttFallbackCoordinator.isActive()) return\n const lang = event.transcribeLanguage ?? localSttFallbackCoordinator.getActiveLanguage() ?? \"en-US\"\n // Native stamps resolvedSpeakerId when the voice matched the enrolled\n // profile; surface that as `isUser` (the native join has no\n // confident-other signal, so unmatched stays unannotated).\n localMiniappRuntime.forwardEvent(\n `transcription:${lang}`,\n speakerLabelResolver.annotateLocalTranscript(event),\n \"local\",\n )\n localTranslationService.onLocalTranscript(event, lang)\n }),\n )\n\n // --- glasses swipe-menu app launcher (G2) ---\n subs.push(\n BluetoothSdk.addListener(\"miniapp_selected\", (event) => {\n const packageName = event.packageName as string\n if (!packageName) return\n const app = useAppStatusStore.getState().apps.find((a) => a.packageName === packageName)\n if (!app) return\n // Toggle: stop if running, else start.\n if (app.running) {\n useAppStatusStore.getState().stop(packageName)\n } else {\n useAppStatusStore.getState().start(app, {skipNavigation: true, launchSource: \"glasses\"})\n }\n }),\n )\n}\n\nexport function stopDeviceEventRouter(): void {\n for (const sub of subs) sub.remove()\n subs = []\n resetTouchInput()\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DeviceEventRouter.js","sourceRoot":"","sources":["../../src/services/DeviceEventRouter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,YAAY,MAAM,iCAAiC,CAAA;AAC1D,OAAO,EAAC,OAAO,EAAC,MAAM,iBAAiB,CAAA;AAEvC,OAAO,mBAAmB,MAAM,uBAAuB,CAAA;AACvD,OAAO,oBAAoB,MAAM,wBAAwB,CAAA;AACzD,OAAO,oBAAoB,MAAM,wBAAwB,CAAA;AACzD,OAAO,2BAA2B,MAAM,+BAA+B,CAAA;AACvE,OAAO,uBAAuB,MAAM,2BAA2B,CAAA;AAC/D,OAAO,oBAAoB,MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAA;AAC7D,OAAO,EAAC,sBAAsB,EAAC,MAAM,0BAA0B,CAAA;AAC/D,OAAO,EAAC,kBAAkB,EAAC,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB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B,MAAM,GAAG,GAAG,iBAAiB,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,KAAK,WAAW,CAAC,CAAA;QACxF,IAAI,CAAC,GAAG;YAAE,OAAM;QAChB,uCAAuC;QACvC,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;YAChB,iBAAiB,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;QAChD,CAAC;aAAM,CAAC;YACN,iBAAiB,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,EAAC,cAAc,EAAE,IAAI,EAAE,YAAY,EAAE,SAAS,EAAC,CAAC,CAAA;QAC1F,CAAC;IACH,CAAC,CAAC,CACH,CAAA;AACH,CAAC;AAED,MAAM,UAAU,qBAAqB;IACnC,KAAK,MAAM,GAAG,IAAI,IAAI;QAAE,GAAG,CAAC,MAAM,EAAE,CAAA;IACpC,IAAI,GAAG,EAAE,CAAA;IACT,eAAe,EAAE,CAAA;AACnB,CAAC","sourcesContent":["/**\n * Device-event router — engine-owned. Subscribes to the inbound native BLE/device\n * events and routes them into the engine runtime: device stores, the process event\n * bus, the photo/stream coordinators, and local miniapps (via forwardEvent).\n *\n * Why this exists: engine owns the stores, coordinators, miniapp runtime, and facades,\n * but it never *subscribed to the device* for most events — the host MantleManager was\n * still the event router the whole runtime secretly depended on. So a bare OEM that\n * imported engine + called engine.start() got a connected runtime with almost no device\n * data flowing in (no miniapp input, dead gallery sync, starved coordinators). This\n * service moves those inbound bridges into engine so ANY host gets them.\n *\n * Scope: the engine legs only. The Cloud V1 relays that used to live beside them in\n * MantleManager (touch→cloud, the cloud-SDK stream/photo legs, etc.) were deleted with\n * Cloud V1 app end-of-life.\n *\n * Started by `engine.start()`. Idempotent.\n */\nimport BluetoothSdk from \"@glassly/bluetooth-sdk/internal\"\nimport {shallow} from \"zustand/shallow\"\n\nimport localMiniappRuntime from \"./LocalMiniappRuntime\"\nimport glassesKeyboardInput from \"./GlassesKeyboardInput\"\nimport glassesSensorService from \"./GlassesSensorService\"\nimport localSttFallbackCoordinator from \"./LocalSttFallbackCoordinator\"\nimport localTranslationService from \"./LocalTranslationService\"\nimport speakerLabelResolver from \"./SpeakerLabelResolver\"\nimport {phonePhotoCoordinator} from \"./PhonePhotoCoordinator\"\nimport {phoneStreamCoordinator} from \"./PhoneStreamCoordinator\"\nimport {isGlassesConnected} from \"./GlassesReadiness\"\nimport {useGlassesStore} from \"../stores/glasses\"\nimport {useSettingsStore} from \"../stores/settings\"\nimport {useAppStatusStore} from \"../stores/apps\"\nimport {retirePendingSelectionOnPromotion} from \"./PairingIdentity\"\nimport GlobalEventEmitter from \"../utils/GlobalEventEmitter\"\nimport {asgCameraApi} from \"./asg/asgCameraApi\"\nimport {dispatchTouchEvent, resetTouchInput} from \"./GlassesTouchInput\"\nimport neuralBandInput from \"./neuralBand/NeuralBandInput\"\nimport dashboardOpenTrace from \"./debug/DashboardOpenTrace\"\n\nlet subs: Array<{remove: () => void}> = []\n\nexport function startDeviceEventRouter(): void {\n if (subs.length) return\n\n subs.push(\n BluetoothSdk.addListener(\"light_sensor\", ({type: _type, ...reading}) => {\n localMiniappRuntime.forwardEvent(\"light_sensor\", reading)\n }),\n // Stock firmware emits these only inside its nav UI; custom firmware whenever the\n // raw compass runs. Either way they feed the one session.compass stream.\n BluetoothSdk.addListener(\"compass_heading\", ({type: _type, heading, ...reading}) => {\n localMiniappRuntime.forwardEvent(\"glasses_compass\", {degrees: heading, ...reading})\n }),\n BluetoothSdk.addListener(\"compass_calibration\", ({type: _type, ...reading}) => {\n localMiniappRuntime.forwardEvent(\"compass_calibration\", reading)\n }),\n {\n remove: useGlassesStore.subscribe(\n (s) => s.connection,\n (connection) => {\n if (isGlassesConnected(connection)) void glassesSensorService.resync()\n else glassesSensorService.disconnected()\n },\n ),\n },\n {\n // CFW classification lands after device-ready; compass demand recorded before\n // that only reaches the firmware once the scene canvas is published.\n remove: useGlassesStore.subscribe(\n (s) => s.sceneCanvasWidth,\n (width) => {\n if ((width ?? 0) > 0) void glassesSensorService.resync()\n },\n ),\n },\n )\n\n // --- device state → engine stores ---\n\n // Standalone WiFi status → glasses store.\n subs.push(\n BluetoothSdk.addListener(\"wifi_status_change\", (event) => {\n const {type: _type, ...wifi} = event\n useGlassesStore.getState().setGlassesInfo({wifi})\n }),\n )\n\n // Forward glasses Wi-Fi to miniapps (session.glasses.onWifi) from the STORE — the\n // single source of truth — so every path converges here: wifi_status_change,\n // onGlassesStatus, and BLE disconnect. Effective connectivity requires the glasses\n // to be connected AND on Wi-Fi, so a disconnect correctly flips `connected` false.\n subs.push({\n remove: useGlassesStore.subscribe(\n (s) => {\n const connected = isGlassesConnected(s.connection) && s.wifi.state === \"connected\"\n return {\n connected,\n ssid: s.wifi.state === \"connected\" ? s.wifi.ssid : undefined,\n localIp: s.wifi.state === \"connected\" ? s.wifi.localIp : undefined,\n }\n },\n (wifi) => localMiniappRuntime.forwardEvent(\"glasses_wifi\", wifi),\n {equalityFn: shallow},\n ),\n })\n\n // Battery streams follow the store, including initial native hydration and\n // onGlassesStatus patches. G2 can report its level without battery_status;\n // forwarding only that legacy event leaves a running dashboard ring-only.\n subs.push({\n remove: useGlassesStore.subscribe(\n (s) => ({level: s.batteryLevel, charging: s.charging}),\n (battery) => {\n localMiniappRuntime.forwardEvent(\"glasses_battery_update\", {\n type: \"glasses_battery_update\",\n ...battery,\n timestamp: Date.now(),\n })\n },\n {equalityFn: shallow},\n ),\n })\n\n // Legacy standalone events feed the same store subscription.\n subs.push(\n BluetoothSdk.addListener(\"battery_status\", (event) => {\n const state = useGlassesStore.getState()\n state.setBatteryInfo(event.level, event.charging, state.caseBatteryLevel, state.caseCharging)\n }),\n )\n\n // Hotspot status → glasses store + event bus. engine's own gallerySyncService listens\n // on the bus for these, so without this bridge engine's gallery sync is dead.\n subs.push(\n BluetoothSdk.addListener(\"hotspot_status_change\", (event) => {\n const enabled = event.state === \"enabled\"\n const ssid = enabled ? event.ssid : \"\"\n const password = enabled ? event.password : \"\"\n const localIp = enabled ? event.localIp : \"\"\n useGlassesStore.getState().setHotspotInfo(enabled, ssid, password, localIp)\n // Always retarget the ASG camera client: on disable (or an event with no\n // IP) fall back to the localhost default so later calls fail fast instead\n // of hitting the previous network's stale glasses IP.\n asgCameraApi.setServer(localIp || \"localhost\", 8089)\n GlobalEventEmitter.emit(\"hotspot_status_change\", {enabled, ssid, password, local_ip: localIp})\n }),\n )\n subs.push(\n BluetoothSdk.addListener(\"hotspot_error\", (event) => {\n GlobalEventEmitter.emit(\"hotspot_error\", {error_message: event.errorMessage, timestamp: event.timestamp})\n }),\n )\n\n // Glasses gallery content counts → event bus (consumed by gallerySyncService).\n subs.push(\n BluetoothSdk.addListener(\"gallery_status\", (event) => {\n GlobalEventEmitter.emit(\"gallery_status\", {\n photos: event.photos,\n videos: event.videos,\n total: event.total,\n has_content: event.hasContent,\n camera_busy: event.cameraBusy,\n })\n }),\n )\n\n // Hardware-originated setting changes (user changes a setting ON the glasses) → store.\n // The inbound complement to GlassesSettingsSync (which only pushes store→device).\n subs.push(\n BluetoothSdk.addListener(\"save_setting\", async (event) => {\n const settings = useSettingsStore.getState()\n // Damp the relay: native re-echoes some settings unconditionally (e.g.\n // the identity block at every handleDeviceReady) — a same-value echo\n // must not become a store write (persistence churn + change-push noise).\n if (settings.getSetting(event.key) !== event.value) {\n await settings.setSetting(event.key, event.value)\n }\n // Two-phase identity: a promoted default retires the pending selection\n // marker. The rule lives with PairingIdentity (a no-op for other keys).\n await retirePendingSelectionOnPromotion(event.key, event.value)\n }),\n )\n\n // --- coordinators (owns()-gated) ---\n\n // Phone-owned photo errors settle the in-flight long-poll fast (vs. timeout).\n // Non-owned photo responses used to forward to the Cloud V1 photo pipeline via\n // restComms; that relay was removed with Cloud V1 app end-of-life, so they drop.\n // Wire v2 sends a short 4-hex BLE requestId; the coordinator maps it back to\n // the cloud requestId (resolveCloudRequestId) before ownership checks.\n subs.push(\n BluetoothSdk.addListener(\"photo_response\", (event) => {\n const cloudRequestId = event.requestId ? phonePhotoCoordinator.resolveCloudRequestId(event.requestId) : \"\"\n if (cloudRequestId && phonePhotoCoordinator.owns(cloudRequestId)) {\n if (event.state === \"error\") {\n phonePhotoCoordinator.handlePhotoError(\n event.requestId ?? cloudRequestId,\n event.errorCode ?? \"GLASSES_ERROR\",\n event.errorMessage ?? \"Glasses reported an error\",\n )\n }\n }\n }),\n )\n\n // Phone-owned stream status / keep-alive → the stream coordinator. The Cloud V1 relay\n // for non-owned streams was removed with Cloud V1 app end-of-life.\n subs.push(\n BluetoothSdk.addListener(\"stream_status\", (event) => {\n if (event.streamId && phoneStreamCoordinator.owns(event.streamId)) {\n phoneStreamCoordinator.handleGlassesStatus(event)\n }\n }),\n )\n subs.push(\n BluetoothSdk.addListener(\"keep_alive_ack\", (event) => {\n if (event.streamId && phoneStreamCoordinator.owns(event.streamId)) {\n phoneStreamCoordinator.handleKeepAliveAck(event)\n }\n }),\n )\n\n // --- device input → local miniapps (forwardEvent is subscriber-gated; a no-op when\n // no miniapp listens). The v1 SocketComms cloud legs for these were removed with\n // the Cloud V1 ripout. ---\n\n subs.push(\n BluetoothSdk.addListener(\"button_press\", (event) => {\n localMiniappRuntime.forwardEvent(\"button_press\", event)\n }),\n )\n subs.push(BluetoothSdk.addListener(\"touch_event\", dispatchTouchEvent))\n // Physical keyboard bridged through G2 Glassly CFW: raw HID transitions →\n // layout-translated keyboard_event stream (with synthesized auto-repeat).\n subs.push(BluetoothSdk.addListener(\"keyboard_key\", (event) => glassesKeyboardInput.handle(event)))\n // Meta Neural Band: its gestures ride touch_event above; these are its own streams.\n subs.push(BluetoothSdk.addListener(\"neural_band_claim\", (event) => neuralBandInput.handleClaim(event)))\n subs.push(BluetoothSdk.addListener(\"neural_band_handwriting\", (event) => neuralBandInput.handleHandwriting(event)))\n subs.push(BluetoothSdk.addListener(\"neural_band_pointer\", (event) => neuralBandInput.handlePointer(event)))\n subs.push({\n remove: useGlassesStore.subscribe(\n (s) => s.keyboardConnected === true,\n (connected) => {\n if (!connected) glassesKeyboardInput.reset()\n },\n ),\n })\n // G2 IMU accelerometer — payload already matches the miniapp AccelData shape.\n subs.push(\n BluetoothSdk.addListener(\"accel_event\", (event) => {\n localMiniappRuntime.forwardEvent(\"accel_event\", {\n x: event.x,\n y: event.y,\n z: event.z,\n timestamp: typeof event.timestamp === \"number\" ? event.timestamp : Date.now(),\n })\n }),\n )\n // Head position — translate native {up:boolean} → SDK {position:\"up\"|\"down\"}.\n // The dashboard miniapp opens on head-up from this stream (ADR-0006).\n subs.push(\n BluetoothSdk.addListener(\"head_up\", (event) => {\n if (event.up) dashboardOpenTrace.trigger(\"head-up\")\n localMiniappRuntime.forwardEvent(\"head_up\", {position: event.up ? \"up\" : \"down\", timestamp: Date.now()})\n }),\n )\n subs.push({remove: dashboardOpenTrace.start()})\n // On-device STT transcripts → local miniapps only while the local engine is\n // active (cloud fallback or an explicit forceLocal subscription). The runtime\n // filters mixed local/cloud delivery per miniapp to avoid double-delivery.\n // forwardEvent is subscriber-gated — a no-op when no miniapp listens.\n // (Was MantleManager.handle_local_transcription; its offline-captions display branch\n // went away with the pseudo captions renderer.)\n subs.push(\n BluetoothSdk.addListener(\"local_transcription\", (event) => {\n if (!localSttFallbackCoordinator.isActive()) return\n const lang = event.transcribeLanguage ?? localSttFallbackCoordinator.getActiveLanguage() ?? \"en-US\"\n // Native stamps resolvedSpeakerId when the voice matched the enrolled\n // profile; surface that as `isUser` (the native join has no\n // confident-other signal, so unmatched stays unannotated).\n localMiniappRuntime.forwardEvent(\n `transcription:${lang}`,\n speakerLabelResolver.annotateLocalTranscript(event),\n \"local\",\n )\n localTranslationService.onLocalTranscript(event, lang)\n }),\n )\n\n // --- glasses swipe-menu app launcher (G2) ---\n subs.push(\n BluetoothSdk.addListener(\"miniapp_selected\", (event) => {\n const packageName = event.packageName as string\n if (!packageName) return\n const app = useAppStatusStore.getState().apps.find((a) => a.packageName === packageName)\n if (!app) return\n // Toggle: stop if running, else start.\n if (app.running) {\n useAppStatusStore.getState().stop(packageName)\n } else {\n useAppStatusStore.getState().start(app, {skipNavigation: true, launchSource: \"glasses\"})\n }\n }),\n )\n}\n\nexport function stopDeviceEventRouter(): void {\n for (const sub of subs) sub.remove()\n subs = []\n resetTouchInput()\n}\n"]}
|
|
@@ -2,13 +2,10 @@ declare class GestureDotsService {
|
|
|
2
2
|
private started;
|
|
3
3
|
private flash;
|
|
4
4
|
private flashTimer;
|
|
5
|
-
/**
|
|
6
|
-
private
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
* event; the tap_end that follows on release is what clears it).
|
|
10
|
-
*/
|
|
11
|
-
private holdRecognized;
|
|
5
|
+
/** Raw controller holds survive hold recognition/dial events until their own release. */
|
|
6
|
+
private presses;
|
|
7
|
+
/** Avoid sending identical images for successive phases of the same press. */
|
|
8
|
+
private renderedGlyph;
|
|
12
9
|
/** Whether the indicator scene currently has anything on it (needs a clear when the flash ends). */
|
|
13
10
|
private visible;
|
|
14
11
|
private unsubs;
|
|
@@ -21,10 +18,13 @@ declare class GestureDotsService {
|
|
|
21
18
|
/**
|
|
22
19
|
* Flash a gesture on the indicator. Other gesture names are ignored.
|
|
23
20
|
* Claimed gestures cancel any earlier press/flash without starting a new
|
|
24
|
-
* one: the claimant may also consume the release edge.
|
|
21
|
+
* one: the claimant may also consume the release edge. `fingerIndex` is the
|
|
22
|
+
* Neural Band's finger on its pinches and press edges (1 = middle).
|
|
25
23
|
*/
|
|
26
|
-
noteGesture(gestureName: string, claimed?: boolean): void;
|
|
24
|
+
noteGesture(gestureName: string, claimed?: boolean, fingerIndex?: number): void;
|
|
27
25
|
private applyGesture;
|
|
26
|
+
private clearFlash;
|
|
27
|
+
private startFlash;
|
|
28
28
|
/** Debug setting only; no payloads or retained history. Correlate seq with G2PERF. */
|
|
29
29
|
private trace;
|
|
30
30
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GestureDotsService.d.ts","sourceRoot":"","sources":["../../src/services/GestureDotsService.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GestureDotsService.d.ts","sourceRoot":"","sources":["../../src/services/GestureDotsService.ts"],"names":[],"mappings":"AAyCA,cAAM,kBAAkB;IACtB,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,KAAK,CAA+B;IAC5C,OAAO,CAAC,UAAU,CAAsB;IACxC,yFAAyF;IACzF,OAAO,CAAC,OAAO,CAA4D;IAC3E,8EAA8E;IAC9E,OAAO,CAAC,aAAa,CAA+B;IACpD,oGAAoG;IACpG,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,MAAM,CAAwB;IAEtC,KAAK,IAAI,IAAI;IAqBb,IAAI,IAAI,IAAI;IAOZ,OAAO,CAAC,YAAY;IAOpB,uFAAuF;IACvF,OAAO,CAAC,UAAU;IAQlB,OAAO,CAAC,OAAO;IAIf;;;;;OAKG;IACH,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,UAAQ,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI;IAM7E,OAAO,CAAC,YAAY;IAgDpB,OAAO,CAAC,UAAU;IAMlB,OAAO,CAAC,UAAU;IAWlB,sFAAsF;IACtF,OAAO,CAAC,KAAK;IAgBb;;;;;;;;;;OAUG;IACH,OAAO,CAAC,MAAM;CAqCf;AAED,QAAA,MAAM,kBAAkB,oBAA2B,CAAA;AACnD,eAAe,kBAAkB,CAAA;AACjC,OAAO,EAAC,kBAAkB,EAAC,CAAA"}
|