@glassly/engine 0.4.0-dev.1039 → 0.4.0-dev.1042

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.
@@ -1,9 +1,9 @@
1
1
  export const ENGINE_RELEASE_METADATA = Object.freeze({
2
2
  "schemaVersion": 1,
3
3
  "familyBaseVersion": "0.4.0",
4
- "releaseIdentity": "0.4.0-dev.1039",
5
- "releaseSetId": "glassly-0.4.0-dev.1039",
6
- "sourceCommit": "daea71d3a5f3ab0c53c092cb2484c28b2b8d8493",
4
+ "releaseIdentity": "0.4.0-dev.1042",
5
+ "releaseSetId": "glassly-0.4.0-dev.1042",
6
+ "sourceCommit": "efd69f62018117af77c4270370674256802dc597",
7
7
  "otaManifestUrl": null,
8
8
  "otaManifestSha256": null
9
9
  });
@@ -1 +1 @@
1
- {"version":3,"file":"releaseMetadata.js","sourceRoot":"","sources":["../../src/generated/releaseMetadata.ts"],"names":[],"mappings":"AAWA,MAAM,CAAC,MAAM,uBAAuB,GAAoC,MAAM,CAAC,MAAM,CAAC;IACpF,eAAe,EAAE,CAAC;IAClB,mBAAmB,EAAE,OAAO;IAC5B,iBAAiB,EAAE,gBAAgB;IACnC,cAAc,EAAE,wBAAwB;IACxC,cAAc,EAAE,0CAA0C;IAC1D,gBAAgB,EAAE,IAAI;IACtB,mBAAmB,EAAE,IAAI;CAC1B,CAAC,CAAA","sourcesContent":["/** Generated by release CI. Do not edit in a release checkout. */\nexport interface EngineReleaseMetadata {\n schemaVersion: 1\n familyBaseVersion: string | null\n releaseIdentity: string | null\n releaseSetId: string | null\n sourceCommit: string | null\n otaManifestUrl: string | null\n otaManifestSha256: string | null\n}\n\nexport const ENGINE_RELEASE_METADATA: Readonly<EngineReleaseMetadata> = Object.freeze({\n \"schemaVersion\": 1,\n \"familyBaseVersion\": \"0.4.0\",\n \"releaseIdentity\": \"0.4.0-dev.1039\",\n \"releaseSetId\": \"glassly-0.4.0-dev.1039\",\n \"sourceCommit\": \"daea71d3a5f3ab0c53c092cb2484c28b2b8d8493\",\n \"otaManifestUrl\": null,\n \"otaManifestSha256\": null\n})\n"]}
1
+ {"version":3,"file":"releaseMetadata.js","sourceRoot":"","sources":["../../src/generated/releaseMetadata.ts"],"names":[],"mappings":"AAWA,MAAM,CAAC,MAAM,uBAAuB,GAAoC,MAAM,CAAC,MAAM,CAAC;IACpF,eAAe,EAAE,CAAC;IAClB,mBAAmB,EAAE,OAAO;IAC5B,iBAAiB,EAAE,gBAAgB;IACnC,cAAc,EAAE,wBAAwB;IACxC,cAAc,EAAE,0CAA0C;IAC1D,gBAAgB,EAAE,IAAI;IACtB,mBAAmB,EAAE,IAAI;CAC1B,CAAC,CAAA","sourcesContent":["/** Generated by release CI. Do not edit in a release checkout. */\nexport interface EngineReleaseMetadata {\n schemaVersion: 1\n familyBaseVersion: string | null\n releaseIdentity: string | null\n releaseSetId: string | null\n sourceCommit: string | null\n otaManifestUrl: string | null\n otaManifestSha256: string | null\n}\n\nexport const ENGINE_RELEASE_METADATA: Readonly<EngineReleaseMetadata> = Object.freeze({\n \"schemaVersion\": 1,\n \"familyBaseVersion\": \"0.4.0\",\n \"releaseIdentity\": \"0.4.0-dev.1042\",\n \"releaseSetId\": \"glassly-0.4.0-dev.1042\",\n \"sourceCommit\": \"efd69f62018117af77c4270370674256802dc597\",\n \"otaManifestUrl\": null,\n \"otaManifestSha256\": null\n})\n"]}
@@ -14,7 +14,7 @@
14
14
  * this service.
15
15
  */
16
16
  import { CloudClient } from "@glassly/cloud-client/react-native";
17
- import type { PreinstalledMiniappRegistry, StoreCatalogResponse, StoreListing, StoreReleasesResponse } from "@glassly/cloud-client/react-native";
17
+ import type { PreinstalledMiniappRegistry, StoreCatalogResponse, StoreListing, StoreReleasesResponse, StoreHostOptions } from "@glassly/cloud-client/react-native";
18
18
  import type { AudioSubscription, QuotaStatusPayload, TranscriptionData, TranslationData } from "@glassly/cloud-protocol";
19
19
  import { type CloudClientStatusSnapshot, type MiniappAuthToken } from "../runtime/config";
20
20
  type CloudCore = NonNullable<CloudClient["core"]>;
@@ -57,9 +57,9 @@ export declare const cloudClientService: {
57
57
  runtime: string;
58
58
  } | null): void;
59
59
  getPreinstalledMiniappRegistry(): Promise<PreinstalledMiniappRegistry>;
60
- getStoreCatalog(): Promise<StoreCatalogResponse>;
61
- getStoreListing(packageName: string): Promise<StoreListing>;
62
- getStoreReleases(packageName: string): Promise<StoreReleasesResponse>;
60
+ getStoreCatalog(opts?: StoreHostOptions): Promise<StoreCatalogResponse>;
61
+ getStoreListing(packageName: string, opts?: StoreHostOptions): Promise<StoreListing>;
62
+ getStoreReleases(packageName: string, opts?: StoreHostOptions): Promise<StoreReleasesResponse>;
63
63
  /** Bytes of a store icon or screenshot; these routes need the user Bearer. */
64
64
  fetchStoreAsset(url: string): Promise<Uint8Array>;
65
65
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"CloudClientService.d.ts","sourceRoot":"","sources":["../../src/services/CloudClientService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAC,WAAW,EAAgD,MAAM,oCAAoC,CAAA;AAC7G,OAAO,KAAK,EACV,2BAA2B,EAE3B,oBAAoB,EACpB,YAAY,EACZ,qBAAqB,EACtB,MAAM,oCAAoC,CAAA;AAG3C,OAAO,KAAK,EAAC,iBAAiB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,eAAe,EAAC,MAAM,yBAAyB,CAAA;AAMtH,OAAO,EAAC,KAAK,yBAAyB,EAAE,KAAK,gBAAgB,EAAC,MAAM,mBAAmB,CAAA;AAavF,KAAK,SAAS,GAAG,WAAW,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAA;AAsDjD;;;;;GAKG;AACH,KAAK,qBAAqB,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC,CAAA;AAGv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;;;;;;;;wBAOf,UAAU,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;8BAIrD,UAAU,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;;;;+BAI9D,UAAU,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC;;;;;;;;0BAIvE,UAAU,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;;;;;;;QAI/E;;;;;WAKG;;;;;;;;;;;;;;;;;;;6BA6BoB,OAAO;CAGjC,CAAA"}
@@ -711,29 +711,29 @@ export const cloudClientService = {
711
711
  throw new Error("cloud client core is unavailable");
712
712
  return c.core.miniapps.getRegistry();
713
713
  },
714
- async getStoreCatalog() {
714
+ async getStoreCatalog(opts) {
715
715
  if (!client)
716
716
  this.init();
717
717
  const c = client;
718
718
  if (!c?.core)
719
719
  throw new Error("cloud client core is unavailable");
720
- return c.core.store.list();
720
+ return c.core.store.list(opts);
721
721
  },
722
- async getStoreListing(packageName) {
722
+ async getStoreListing(packageName, opts) {
723
723
  if (!client)
724
724
  this.init();
725
725
  const c = client;
726
726
  if (!c?.core)
727
727
  throw new Error("cloud client core is unavailable");
728
- return c.core.store.get(packageName);
728
+ return c.core.store.get(packageName, opts);
729
729
  },
730
- async getStoreReleases(packageName) {
730
+ async getStoreReleases(packageName, opts) {
731
731
  if (!client)
732
732
  this.init();
733
733
  const c = client;
734
734
  if (!c?.core)
735
735
  throw new Error("cloud client core is unavailable");
736
- return c.core.store.releases(packageName);
736
+ return c.core.store.releases(packageName, opts);
737
737
  },
738
738
  /** Bytes of a store icon or screenshot; these routes need the user Bearer. */
739
739
  async fet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;;;;WAKG;QACH,WAAW;YACT,IAAI,CAAC,MAAM;gBAAE,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAA;YAC1D,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,CAAA;QAC1C,CAAC;KACF;IAED,IAAI,EAAE;QACJ,OAAO,EAAE;YACP,MAAM,CAAC,GAAG,IAAgD;gBACxD,OAAO,aAAa,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAA;YAChD,CAAC;YACD,OAAO,CAAC,GAAG,IAAiD;gBAC1D,OAAO,aAAa,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 StoreReleasesResponse,\n} from \"@glassly/cloud-client/react-native\"\nimport type {SubjectTokenType} from \"@glassly/cloud-client\"\nimport {AppState, 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\n/** The cloud closed us for a newer socket; the client stays down until reconnect(). */\nlet superseded = 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 foregroundUnsubscribe: (() => 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\n// Via init(), never construct(): init() holds the disable-cloud gate, and a\n// client built past it opens the runtime socket and retries it forever.\nfunction requireClient(): CloudClient {\n if (!client) cloudClientService.init()\n if (!client) throw new Error(\"Glassly cloud is disabled\")\n return client\n}\n\nfunction getCoreClient(): CloudCore {\n const core = requireClient().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 const c = requireClient()\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 * Reclaim a superseded session only on foreground: the user picked this phone\n * up, and a reclaim on any other signal would fight the newer socket.\n */\nfunction startForegroundWatcher(): void {\n if (foregroundUnsubscribe) return\n\n const subscription = AppState.addEventListener(\"change\", (state) => {\n if (state !== \"active\" || !superseded || !client) return\n console.log(`${LOG_TAG}: foregrounded after supersede; reconnecting runtime`)\n cloudClientService.reconnect()\n })\n foregroundUnsubscribe = () => subscription.remove()\n}\n\nfunction stopForegroundWatcher(): void {\n foregroundUnsubscribe?.()\n foregroundUnsubscribe = 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 superseded = false\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 superseded = /superseded by newer session/i.test(info.reason)\n console.log(`${LOG_TAG}: runtime disconnected (${info.reason})`)\n console.log(`${LOG_TAG}: debug: ws-session-debug disconnected reason=${info.reason} willStayDown=${superseded}`)\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 startForegroundWatcher()\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 superseded = 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 async getStoreReleases(packageName: string): Promise<StoreReleasesResponse> {\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.releases(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 stopForegroundWatcher()\n stopAuthWatch()\n clearRuntimeEventSubscriptions()\n clearPersistentFailureAlarm()\n const wasConnected = connected\n client = null\n superseded = false\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 // The next engine.start() is configured afresh; an override left by a\n // reconnect() in this process would otherwise outrank the new config\n // and keep the client on the previous backend.\n endpointsOverride = null\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
+ {"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;AAU7G,OAAO,EAAC,QAAQ,EAAE,QAAQ,EAAC,MAAM,cAAc,CAAA;AAG/C,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,MAAM,6BAA6B,CAAA;AAC1G,OAAO,EAAC,sBAAsB,EAAC,MAAM,s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/**\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 StoreReleasesResponse,\n StoreHostOptions,\n} from \"@glassly/cloud-client/react-native\"\nimport type {SubjectTokenType} from \"@glassly/cloud-client\"\nimport {AppState, 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\n/** The cloud closed us for a newer socket; the client stays down until reconnect(). */\nlet superseded = 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 foregroundUnsubscribe: (() => 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\n// Via init(), never construct(): init() holds the disable-cloud gate, and a\n// client built past it opens the runtime socket and retries it forever.\nfunction requireClient(): CloudClient {\n if (!client) cloudClientService.init()\n if (!client) throw new Error(\"Glassly cloud is disabled\")\n return client\n}\n\nfunction getCoreClient(): CloudCore {\n const core = requireClient().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 const c = requireClient()\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 * Reclaim a superseded session only on foreground: the user picked this phone\n * up, and a reclaim on any other signal would fight the newer socket.\n */\nfunction startForegroundWatcher(): void {\n if (foregroundUnsubscribe) return\n\n const subscription = AppState.addEventListener(\"change\", (state) => {\n if (state !== \"active\" || !superseded || !client) return\n console.log(`${LOG_TAG}: foregrounded after supersede; reconnecting runtime`)\n cloudClientService.reconnect()\n })\n foregroundUnsubscribe = () => subscription.remove()\n}\n\nfunction stopForegroundWatcher(): void {\n foregroundUnsubscribe?.()\n foregroundUnsubscribe = 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 superseded = false\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 superseded = /superseded by newer session/i.test(info.reason)\n console.log(`${LOG_TAG}: runtime disconnected (${info.reason})`)\n console.log(`${LOG_TAG}: debug: ws-session-debug disconnected reason=${info.reason} willStayDown=${superseded}`)\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 startForegroundWatcher()\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 superseded = 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(opts?: StoreHostOptions): 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(opts)\n },\n\n async getStoreListing(packageName: string, opts?: StoreHostOptions): 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, opts)\n },\n\n async getStoreReleases(packageName: string, opts?: StoreHostOptions): Promise<StoreReleasesResponse> {\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.releases(packageName, opts)\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 stopForegroundWatcher()\n stopAuthWatch()\n clearRuntimeEventSubscriptions()\n clearPersistentFailureAlarm()\n const wasConnected = connected\n client = null\n superseded = false\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 // The next engine.start() is configured afresh; an override left by a\n // reconnect() in this process would otherwise outrank the new config\n // and keep the client on the previous backend.\n endpointsOverride = null\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 +1 @@
1
- {"version":3,"file":"HotspotOtaTransport.d.ts","sourceRoot":"","sources":["../../src/services/HotspotOtaTransport.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,4BAA4B,EAAC,MAAM,yBAAyB,CAAA;AACzE,OAAO,EAML,KAAK,2BAA2B,EAEjC,MAAM,yBAAyB,CAAA;AAIhC,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,aAAa,GAAG,kBAAkB,GAAG,iBAAiB,GAAG,SAAS,CAAA;AAEzG,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,eAAe,CAAA;IACtB,QAAQ,CAAC,EAAE,2BAA2B,CAAA;CACvC,CAAA;AAED,MAAM,MAAM,mBAAmB,GAC7B,gCAAgC,GAAG,sBAAsB,GAAG,qBAAqB,GAAG,uBAAuB,CAAA;AAE7G,qBAAa,wBAAyB,SAAQ,KAAK;aAE/B,IAAI,EAAE,mBAAmB;gBAAzB,IAAI,EAAE,mBAAmB,EACzC,OAAO,EAAE,MAAM;CAKlB;AAED,yFAAyF;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CAA4B;IAC5C,OAAO,CAAC,gBAAgB,CAAQ;IAChC,OAAO,CAAC,qBAAqB,CAAQ;IACrC,OAAO,CAAC,aAAa,CAAQ;IAC7B,OAAO,CAAC,eAAe,CAA6B;IAE9C,OAAO,CACX,WAAW,EAAE,4BAA4B,EACzC,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,kBAAkB,KAAK,IAAI,GAClD,OAAO,CAAC,MAAM,CAAC;IAuElB,gGAAgG;YAClF,2BAA2B;IAczC,OAAO,CAAC,mBAAmB,CAa1B;IAEK,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CA4BhC;AAED,eAAO,MAAM,mBAAmB,qBAA4B,CAAA"}
@@ -1,7 +1,6 @@
1
1
  import BluetoothSdk, { isEnabledHotspotStatus } from "@glassly/bluetooth-sdk";
2
2
  import { otaServer } from "@glassly/bluetooth-sdk/ota-transport";
3
3
  // One coordinator selects the native Android or iOS staging implementation at runtime.
4
- // eslint-disable-next-line react-native/split-platform-components
5
4
  import { PermissionsAndroid, Platform } from "react-native";
6
5
  import { cleanupArtifacts, OtaArtifactError, planArtifacts, prepareArtifacts, rewriteManifestForLocalServer, } from "./OtaArtifactDownloader";
7
6
  import { disableHotspotWithRetry } from "./HotspotShutdown";
@@ -1 +1 @@
1
- {"version":3,"file":"HotspotOtaTransport.js","sourceRoot":"","sources":["../../src/services/HotspotOtaTransport.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,EAAE,EAAC,sBAAsB,EAAC,MAAM,wBAAwB,CAAA;AAC3E,OAAO,EAAC,SAAS,EAAC,MAAM,sCAAsC,CAAA;AAC9D,uFAAuF;AACvF,kEAAkE;AAClE,OAAO,EAAC,kBAAkB,EAAE,QAAQ,EAAC,MAAM,cAAc,CAAA;AAEzD,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EAChB,6BAA6B,GAG9B,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAC,uBAAuB,EAAC,MAA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AC,MAAM,mBAAmB,GAAG,IAAI,mBAAmB,EAAE,CAAA","sourcesContent":["import BluetoothSdk, {isEnabledHotspotStatus} from \"@glassly/bluetooth-sdk\"\nimport {otaServer} from \"@glassly/bluetooth-sdk/ota-transport\"\n// One coordinator selects the native Android or iOS staging implementation at runtime.\n// eslint-disable-next-line react-native/split-platform-components\nimport {PermissionsAndroid, Platform} from \"react-native\"\nimport type {OtaCheckCurrentGlassesResult} from \"./OtaUpdateCheckService\"\nimport {\n cleanupArtifacts,\n OtaArtifactError,\n planArtifacts,\n prepareArtifacts,\n rewriteManifestForLocalServer,\n type OtaArtifactDownloadProgress,\n type PreparedOtaArtifact,\n} from \"./OtaArtifactDownloader\"\nimport {disableHotspotWithRetry} from \"./HotspotShutdown\"\nimport {localNetworkTransport} from \"./asg/localNetworkTransport\"\n\nexport type HotspotOtaPhase = \"idle\" | \"downloading\" | \"starting_hotspot\" | \"joining_hotspot\" | \"serving\"\n\nexport type HotspotOtaProgress = {\n phase: HotspotOtaPhase\n artifact?: OtaArtifactDownloadProgress\n}\n\nexport type HotspotOtaErrorCode =\n \"hotspot_wifi_permission_denied\" | \"hotspot_start_failed\" | \"hotspot_join_failed\" | \"hotspot_server_failed\"\n\nexport class HotspotOtaTransportError extends Error {\n constructor(\n public readonly code: HotspotOtaErrorCode,\n message: string,\n ) {\n super(message)\n this.name = \"HotspotOtaTransportError\"\n }\n}\n\n/** Owns the single phone-side endpoint and network lease for one hotspot OTA attempt. */\nclass HotspotOtaTransport {\n private active = false\n private prepared: PreparedOtaArtifact[] = []\n private hotspotRequested = false\n private localNetworkConnected = false\n private serverStarted = false\n private teardownPromise: Promise<void> | null = null\n\n async prepare(\n checkResult: OtaCheckCurrentGlassesResult,\n onProgress?: (progress: HotspotOtaProgress) => void,\n ): Promise<string> {\n if (this.teardownPromise) await this.teardownPromise\n if (this.active) {\n throw new Error(\"A hotspot OTA transport is already active\")\n }\n if (!checkResult.manifestBody) {\n throw new Error(\"The selected OTA check has no manifest body\")\n }\n\n let phase: HotspotOtaPhase = \"downloading\"\n try {\n await this.ensureAndroidWifiPermission()\n onProgress?.({phase: \"downloading\"})\n this.prepared = await prepareArtifacts(\n planArtifacts(checkResult),\n (artifact) => onProgress?.({phase: \"downloading\", artifact}),\n Platform.OS === \"ios\" ? this.downloadIosArtifact : undefined,\n )\n\n phase = \"starting_hotspot\"\n onProgress?.({phase: \"starting_hotspot\"})\n this.hotspotRequested = true\n const hotspot = await BluetoothSdk.setHotspotState(true)\n if (!isEnabledHotspotStatus(hotspot)) {\n throw new HotspotOtaTransportError(\"hotspot_start_failed\", \"Mentra Live did not return hotspot credentials\")\n }\n phase = \"joining_hotspot\"\n onProgress?.({phase: \"joining_hotspot\"})\n const scopedAddress = await localNetworkTransport.connect(hotspot.ssid, hotspot.password)\n this.localNetworkConnected = true\n let localAddress = scopedAddress\n if (Platform.OS === \"ios\") {\n try {\n localAddress = await otaServer.waitForWifiAddress(hotspot.localIp, 15_000)\n } catch (error) {\n throw new HotspotOtaTransportError(\n \"hotspot_join_failed\",\n error instanceof Error ? error.message : String(error),\n )\n }\n }\n const artifactPaths = Object.fromEntries(this.prepared.map((artifact) => [artifact.sha256, artifact.filePath]))\n // Start exactly one native listener to learn its selected port, then atomically replace\n // the placeholder with the immutable rewritten manifest before ota_start is sent.\n const server = await otaServer.start(\"{}\", artifactPaths, localAddress)\n this.serverStarted = true\n const manifest = rewriteManifestForLocalServer(checkResult.manifestBody, this.prepared, server.baseUrl)\n const published = await otaServer.start(manifest, artifactPaths, server.host)\n if (published.manifestUrl !== server.manifestUrl) {\n throw new Error(\"Local OTA server endpoint changed while publishing the manifest\")\n }\n this.active = true\n onProgress?.({phase: \"serving\"})\n return published.manifestUrl\n } catch (error) {\n const joined = this.localNetworkConnected\n await this.teardown()\n if (error instanceof OtaArtifactError || error instanceof HotspotOtaTransportError) {\n throw error\n }\n const message = error instanceof Error ? error.message : String(error)\n if (phase === \"starting_hotspot\") {\n throw new HotspotOtaTransportError(\"hotspot_start_failed\", message)\n }\n if (phase === \"joining_hotspot\" && !joined) {\n throw new HotspotOtaTransportError(\"hotspot_join_failed\", message)\n }\n throw new HotspotOtaTransportError(\"hotspot_server_failed\", message)\n }\n }\n\n /** Android 13+ requires the nearby-WiFi runtime grant before WifiNetworkSpecifier is usable. */\n private async ensureAndroidWifiPermission(): Promise<void> {\n if (Platform.OS !== \"android\") return\n\n const permission = PermissionsAndroid.PERMISSIONS.NEARBY_WIFI_DEVICES\n if (await PermissionsAndroid.check(permission)) return\n const result = await PermissionsAndroid.request(permission)\n if (result !== PermissionsAndroid.RESULTS.GRANTED) {\n throw new HotspotOtaTransportError(\n \"hotspot_wifi_permission_denied\",\n \"Nearby devices permission is required to connect to the glasses hotspot\",\n )\n }\n }\n\n private downloadIosArtifact = async (\n entry: {url: string},\n destination: string,\n onProgress?: (bytesWritten: number, contentLength: number) => void,\n ): Promise<{statusCode: number}> => {\n const subscription = otaServer.onArtifactDownloadProgress((event) => {\n if (event.destination === destination) onProgress?.(event.bytesWritten, event.contentLength)\n })\n try {\n return await otaServer.downloadArtifact(entry.url, destination)\n } finally {\n subscription.remove()\n }\n }\n\n async teardown(): Promise<void> {\n if (this.teardownPromise) return this.teardownPromise\n this.teardownPromise = (async () => {\n if (this.hotspotRequested) {\n const hotspotStopped = await disableHotspotWithRetry(() => BluetoothSdk.setHotspotState(false), {\n // A completed APK step has just replaced ASG. Let the new command path\n // settle before asking it to tear down the SystemUI-owned access point.\n initialDelayMs: this.serverStarted ? 750 : 0,\n })\n if (!hotspotStopped) {\n console.warn(\"[OTA_PROGRESS] glasses hotspot shutdown was not confirmed after bounded retries\")\n }\n }\n if (this.serverStarted) await otaServer.stop().catch(() => {})\n if (this.localNetworkConnected) await localNetworkTransport.disconnect().catch(() => {})\n await cleanupArtifacts().catch(() => {})\n this.prepared = []\n this.active = false\n this.serverStarted = false\n this.localNetworkConnected = false\n this.hotspotRequested = false\n })()\n try {\n await this.teardownPromise\n } finally {\n this.teardownPromise = null\n }\n }\n}\n\nexport const hotspotOtaTransport = new HotspotOtaTransport()\n"]}
1
+ {"version":3,"file":"HotspotOtaTransport.js","sourceRoot":"","sources":["../../src/services/HotspotOtaTransport.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,EAAE,EAAC,sBAAsB,EAAC,MAAM,wBAAwB,CAAA;AAC3E,OAAO,EAAC,SAAS,EAAC,MAAM,sCAAsC,CAAA;AAC9D,uFAAuF;AACvF,OAAO,EAAC,kBAAkB,EAAE,QAAQ,EAAC,MAAM,cAAc,CAAA;AAEzD,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EAChB,6BAA6B,GAG9B,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAC,uBAAuB,EAAC,MAAM,mBAAmB,CAAA;AACzD,OAAO,EAAC,qBAAqB,EAAC,MAAM,6BAA6B,CAAA;AAYjE,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IAE/B;IADlB,YACkB,IAAyB,EACzC,OAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAA;QAHE,SAAI,GAAJ,IAAI,CAAqB;QAIzC,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAA;IACxC,CAAC;CACF;AAED,yFAAyF;AACzF,MAAM,mBAAmB;IACf,MAAM,GAAG,KAAK,CAAA;IACd,QAAQ,GAA0B,EAAE,CAAA;IACpC,gBAAgB,GAAG,KAAK,CAAA;IACxB,qBAAqB,GAAG,KAAK,CAAA;IAC7B,aAAa,GAAG,KAAK,CAAA;IACrB,eAAe,GAAyB,IAAI,CAAA;IAEpD,KAAK,CAAC,OAAO,CACX,WAAyC,EACzC,UAAmD;QAEnD,IAAI,IAAI,CAAC,eAAe;YAAE,MAAM,IAAI,CAAC,eAAe,CAAA;QACpD,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAA;QAC9D,CAAC;QACD,IAAI,CAAC,WAAW,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AM,gBAAgB,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;YACxC,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAA;YAClB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;YACnB,IAAI,CAAC,aAAa,GAAG,KAAK,CAAA;YAC1B,IAAI,CAAC,qBAAqB,GAAG,KAAK,CAAA;YAClC,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAA;QAC/B,CAAC,CAAC,EAAE,CAAA;QACJ,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,eAAe,CAAA;QAC5B,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,eAAe,GAAG,IAAI,CAAA;QAC7B,CAAC;IACH,CAAC;CACF;AAED,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,mBAAmB,EAAE,CAAA","sourcesContent":["import BluetoothSdk, {isEnabledHotspotStatus} from \"@glassly/bluetooth-sdk\"\nimport {otaServer} from \"@glassly/bluetooth-sdk/ota-transport\"\n// One coordinator selects the native Android or iOS staging implementation at runtime.\nimport {PermissionsAndroid, Platform} from \"react-native\"\nimport type {OtaCheckCurrentGlassesResult} from \"./OtaUpdateCheckService\"\nimport {\n cleanupArtifacts,\n OtaArtifactError,\n planArtifacts,\n prepareArtifacts,\n rewriteManifestForLocalServer,\n type OtaArtifactDownloadProgress,\n type PreparedOtaArtifact,\n} from \"./OtaArtifactDownloader\"\nimport {disableHotspotWithRetry} from \"./HotspotShutdown\"\nimport {localNetworkTransport} from \"./asg/localNetworkTransport\"\n\nexport type HotspotOtaPhase = \"idle\" | \"downloading\" | \"starting_hotspot\" | \"joining_hotspot\" | \"serving\"\n\nexport type HotspotOtaProgress = {\n phase: HotspotOtaPhase\n artifact?: OtaArtifactDownloadProgress\n}\n\nexport type HotspotOtaErrorCode =\n \"hotspot_wifi_permission_denied\" | \"hotspot_start_failed\" | \"hotspot_join_failed\" | \"hotspot_server_failed\"\n\nexport class HotspotOtaTransportError extends Error {\n constructor(\n public readonly code: HotspotOtaErrorCode,\n message: string,\n ) {\n super(message)\n this.name = \"HotspotOtaTransportError\"\n }\n}\n\n/** Owns the single phone-side endpoint and network lease for one hotspot OTA attempt. */\nclass HotspotOtaTransport {\n private active = false\n private prepared: PreparedOtaArtifact[] = []\n private hotspotRequested = false\n private localNetworkConnected = false\n private serverStarted = false\n private teardownPromise: Promise<void> | null = null\n\n async prepare(\n checkResult: OtaCheckCurrentGlassesResult,\n onProgress?: (progress: HotspotOtaProgress) => void,\n ): Promise<string> {\n if (this.teardownPromise) await this.teardownPromise\n if (this.active) {\n throw new Error(\"A hotspot OTA transport is already active\")\n }\n if (!checkResult.manifestBody) {\n throw new Error(\"The selected OTA check has no manifest body\")\n }\n\n let phase: HotspotOtaPhase = \"downloading\"\n try {\n await this.ensureAndroidWifiPermission()\n onProgress?.({phase: \"downloading\"})\n this.prepared = await prepareArtifacts(\n planArtifacts(checkResult),\n (artifact) => onProgress?.({phase: \"downloading\", artifact}),\n Platform.OS === \"ios\" ? this.downloadIosArtifact : undefined,\n )\n\n phase = \"starting_hotspot\"\n onProgress?.({phase: \"starting_hotspot\"})\n this.hotspotRequested = true\n const hotspot = await BluetoothSdk.setHotspotState(true)\n if (!isEnabledHotspotStatus(hotspot)) {\n throw new HotspotOtaTransportError(\"hotspot_start_failed\", \"Mentra Live did not return hotspot credentials\")\n }\n phase = \"joining_hotspot\"\n onProgress?.({phase: \"joining_hotspot\"})\n const scopedAddress = await localNetworkTransport.connect(hotspot.ssid, hotspot.password)\n this.localNetworkConnected = true\n let localAddress = scopedAddress\n if (Platform.OS === \"ios\") {\n try {\n localAddress = await otaServer.waitForWifiAddress(hotspot.localIp, 15_000)\n } catch (error) {\n throw new HotspotOtaTransportError(\n \"hotspot_join_failed\",\n error instanceof Error ? error.message : String(error),\n )\n }\n }\n const artifactPaths = Object.fromEntries(this.prepared.map((artifact) => [artifact.sha256, artifact.filePath]))\n // Start exactly one native listener to learn its selected port, then atomically replace\n // the placeholder with the immutable rewritten manifest before ota_start is sent.\n const server = await otaServer.start(\"{}\", artifactPaths, localAddress)\n this.serverStarted = true\n const manifest = rewriteManifestForLocalServer(checkResult.manifestBody, this.prepared, server.baseUrl)\n const published = await otaServer.start(manifest, artifactPaths, server.host)\n if (published.manifestUrl !== server.manifestUrl) {\n throw new Error(\"Local OTA server endpoint changed while publishing the manifest\")\n }\n this.active = true\n onProgress?.({phase: \"serving\"})\n return published.manifestUrl\n } catch (error) {\n const joined = this.localNetworkConnected\n await this.teardown()\n if (error instanceof OtaArtifactError || error instanceof HotspotOtaTransportError) {\n throw error\n }\n const message = error instanceof Error ? error.message : String(error)\n if (phase === \"starting_hotspot\") {\n throw new HotspotOtaTransportError(\"hotspot_start_failed\", message)\n }\n if (phase === \"joining_hotspot\" && !joined) {\n throw new HotspotOtaTransportError(\"hotspot_join_failed\", message)\n }\n throw new HotspotOtaTransportError(\"hotspot_server_failed\", message)\n }\n }\n\n /** Android 13+ requires the nearby-WiFi runtime grant before WifiNetworkSpecifier is usable. */\n private async ensureAndroidWifiPermission(): Promise<void> {\n if (Platform.OS !== \"android\") return\n\n const permission = PermissionsAndroid.PERMISSIONS.NEARBY_WIFI_DEVICES\n if (await PermissionsAndroid.check(permission)) return\n const result = await PermissionsAndroid.request(permission)\n if (result !== PermissionsAndroid.RESULTS.GRANTED) {\n throw new HotspotOtaTransportError(\n \"hotspot_wifi_permission_denied\",\n \"Nearby devices permission is required to connect to the glasses hotspot\",\n )\n }\n }\n\n private downloadIosArtifact = async (\n entry: {url: string},\n destination: string,\n onProgress?: (bytesWritten: number, contentLength: number) => void,\n ): Promise<{statusCode: number}> => {\n const subscription = otaServer.onArtifactDownloadProgress((event) => {\n if (event.destination === destination) onProgress?.(event.bytesWritten, event.contentLength)\n })\n try {\n return await otaServer.downloadArtifact(entry.url, destination)\n } finally {\n subscription.remove()\n }\n }\n\n async teardown(): Promise<void> {\n if (this.teardownPromise) return this.teardownPromise\n this.teardownPromise = (async () => {\n if (this.hotspotRequested) {\n const hotspotStopped = await disableHotspotWithRetry(() => BluetoothSdk.setHotspotState(false), {\n // A completed APK step has just replaced ASG. Let the new command path\n // settle before asking it to tear down the SystemUI-owned access point.\n initialDelayMs: this.serverStarted ? 750 : 0,\n })\n if (!hotspotStopped) {\n console.warn(\"[OTA_PROGRESS] glasses hotspot shutdown was not confirmed after bounded retries\")\n }\n }\n if (this.serverStarted) await otaServer.stop().catch(() => {})\n if (this.localNetworkConnected) await localNetworkTransport.disconnect().catch(() => {})\n await cleanupArtifacts().catch(() => {})\n this.prepared = []\n this.active = false\n this.serverStarted = false\n this.localNetworkConnected = false\n this.hotspotRequested = false\n })()\n try {\n await this.teardownPromise\n } finally {\n this.teardownPromise = null\n }\n }\n}\n\nexport const hotspotOtaTransport = new HotspotOtaTransport()\n"]}
@@ -91,7 +91,7 @@ export const SETTINGS = {
91
91
  },
92
92
  memomind_accessory_picker: {
93
93
  key: "memomind_accessory_picker",
94
- defaultValue: () => false,
94
+ defaultValue: () => true,
95
95
  writable: true,
96
96
  saveOnServer: false,
97
97
  persist: true,