@glassly/engine 0.3.3-dev.669 → 0.3.4-dev.674

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.
Files changed (115) hide show
  1. package/build/engine.d.ts +38 -14
  2. package/build/engine.d.ts.map +1 -1
  3. package/build/engine.js +3 -0
  4. package/build/engine.js.map +1 -1
  5. package/build/facades/ai.d.ts +32 -0
  6. package/build/facades/ai.d.ts.map +1 -0
  7. package/build/facades/ai.js +38 -0
  8. package/build/facades/ai.js.map +1 -0
  9. package/build/facades/glasses.d.ts +30 -24
  10. package/build/facades/glasses.d.ts.map +1 -1
  11. package/build/facades/glasses.js +49 -30
  12. package/build/facades/glasses.js.map +1 -1
  13. package/build/facades/glassesSettings.d.ts.map +1 -1
  14. package/build/facades/glassesSettings.js +1 -0
  15. package/build/facades/glassesSettings.js.map +1 -1
  16. package/build/facades/pairing.d.ts +6 -5
  17. package/build/facades/pairing.d.ts.map +1 -1
  18. package/build/facades/pairing.js +14 -14
  19. package/build/facades/pairing.js.map +1 -1
  20. package/build/generated/releaseMetadata.js +4 -4
  21. package/build/generated/releaseMetadata.js.map +1 -1
  22. package/build/index.d.ts +5 -2
  23. package/build/index.d.ts.map +1 -1
  24. package/build/index.js +2 -0
  25. package/build/index.js.map +1 -1
  26. package/build/services/DeviceEventRouter.d.ts.map +1 -1
  27. package/build/services/DeviceEventRouter.js +9 -1
  28. package/build/services/DeviceEventRouter.js.map +1 -1
  29. package/build/services/GestureDotsService.d.ts +4 -3
  30. package/build/services/GestureDotsService.d.ts.map +1 -1
  31. package/build/services/GestureDotsService.js +17 -12
  32. package/build/services/GestureDotsService.js.map +1 -1
  33. package/build/services/GlassesTouchInput.d.ts.map +1 -1
  34. package/build/services/GlassesTouchInput.js +11 -9
  35. package/build/services/GlassesTouchInput.js.map +1 -1
  36. package/build/services/LlmRouting.d.ts +35 -0
  37. package/build/services/LlmRouting.d.ts.map +1 -0
  38. package/build/services/LlmRouting.js +25 -0
  39. package/build/services/LlmRouting.js.map +1 -0
  40. package/build/services/LocalLlmModelManager.d.ts +79 -0
  41. package/build/services/LocalLlmModelManager.d.ts.map +1 -0
  42. package/build/services/LocalLlmModelManager.js +278 -0
  43. package/build/services/LocalLlmModelManager.js.map +1 -0
  44. package/build/services/LocalLlmPrompt.d.ts +90 -0
  45. package/build/services/LocalLlmPrompt.d.ts.map +1 -0
  46. package/build/services/LocalLlmPrompt.js +189 -0
  47. package/build/services/LocalLlmPrompt.js.map +1 -0
  48. package/build/services/LocalLlmProvider.d.ts +35 -0
  49. package/build/services/LocalLlmProvider.d.ts.map +1 -0
  50. package/build/services/LocalLlmProvider.js +217 -0
  51. package/build/services/LocalLlmProvider.js.map +1 -0
  52. package/build/services/LocalMiniappRuntime.d.ts +9 -1
  53. package/build/services/LocalMiniappRuntime.d.ts.map +1 -1
  54. package/build/services/LocalMiniappRuntime.js +91 -17
  55. package/build/services/LocalMiniappRuntime.js.map +1 -1
  56. package/build/services/STTModelManager.d.ts +25 -2
  57. package/build/services/STTModelManager.d.ts.map +1 -1
  58. package/build/services/STTModelManager.js +137 -6
  59. package/build/services/STTModelManager.js.map +1 -1
  60. package/build/services/controllers.d.ts +21 -0
  61. package/build/services/controllers.d.ts.map +1 -0
  62. package/build/services/controllers.js +62 -0
  63. package/build/services/controllers.js.map +1 -0
  64. package/build/services/effectiveCapabilities.d.ts.map +1 -1
  65. package/build/services/effectiveCapabilities.js +18 -24
  66. package/build/services/effectiveCapabilities.js.map +1 -1
  67. package/build/services/neuralBand/NeuralBandInput.d.ts +17 -6
  68. package/build/services/neuralBand/NeuralBandInput.d.ts.map +1 -1
  69. package/build/services/neuralBand/NeuralBandInput.js +40 -23
  70. package/build/services/neuralBand/NeuralBandInput.js.map +1 -1
  71. package/build/services/neuralBand/NeuralBandSettingsSync.d.ts.map +1 -1
  72. package/build/services/neuralBand/NeuralBandSettingsSync.js +23 -26
  73. package/build/services/neuralBand/NeuralBandSettingsSync.js.map +1 -1
  74. package/build/services/settingsBridge.d.ts +26 -18
  75. package/build/services/settingsBridge.d.ts.map +1 -1
  76. package/build/services/settingsBridge.js +36 -15
  77. package/build/services/settingsBridge.js.map +1 -1
  78. package/build/stores/bluetoothSettingKeys.d.ts.map +1 -1
  79. package/build/stores/bluetoothSettingKeys.js +3 -1
  80. package/build/stores/bluetoothSettingKeys.js.map +1 -1
  81. package/build/stores/core.d.ts.map +1 -1
  82. package/build/stores/core.js +0 -1
  83. package/build/stores/core.js.map +1 -1
  84. package/build/stores/glasses.d.ts.map +1 -1
  85. package/build/stores/glasses.js +2 -6
  86. package/build/stores/glasses.js.map +1 -1
  87. package/build/stores/settings.d.ts.map +1 -1
  88. package/build/stores/settings.js +28 -2
  89. package/build/stores/settings.js.map +1 -1
  90. package/package.json +12 -8
  91. package/src/engine.ts +3 -0
  92. package/src/facades/ai.ts +43 -0
  93. package/src/facades/glasses.ts +60 -31
  94. package/src/facades/glassesSettings.ts +1 -0
  95. package/src/facades/pairing.ts +18 -14
  96. package/src/generated/releaseMetadata.ts +4 -4
  97. package/src/index.ts +16 -2
  98. package/src/services/DeviceEventRouter.ts +8 -1
  99. package/src/services/GestureDotsService.ts +20 -14
  100. package/src/services/GlassesTouchInput.ts +11 -9
  101. package/src/services/LlmRouting.ts +49 -0
  102. package/src/services/LocalLlmModelManager.ts +327 -0
  103. package/src/services/LocalLlmPrompt.ts +246 -0
  104. package/src/services/LocalLlmProvider.ts +289 -0
  105. package/src/services/LocalMiniappRuntime.ts +137 -21
  106. package/src/services/STTModelManager.ts +140 -8
  107. package/src/services/controllers.ts +77 -0
  108. package/src/services/effectiveCapabilities.ts +16 -32
  109. package/src/services/neuralBand/NeuralBandInput.ts +50 -26
  110. package/src/services/neuralBand/NeuralBandSettingsSync.ts +28 -26
  111. package/src/services/settingsBridge.ts +60 -22
  112. package/src/stores/bluetoothSettingKeys.ts +3 -1
  113. package/src/stores/core.ts +0 -1
  114. package/src/stores/glasses.ts +2 -6
  115. package/src/stores/settings.ts +28 -2
package/build/engine.d.ts CHANGED
@@ -56,26 +56,33 @@ export declare const engine: {
56
56
  onAdvert: (cb: (advert: import("@glassly/bluetooth-sdk").KeyboardAdvertEvent) => void) => (() => void);
57
57
  onPairing: (cb: (prompt: import("@glassly/bluetooth-sdk").KeyboardPairingEvent) => void) => (() => void);
58
58
  };
59
- controller: {
60
- connectDefault: () => Promise<void>;
61
- disconnect: () => Promise<void>;
62
- forget: () => Promise<void>;
63
- status: () => import("./facades/glasses").ControllerStatusSnapshot;
64
- onStatus: (cb: (status: import("./facades/glasses").ControllerStatusSnapshot) => void) => (() => void);
59
+ controllers: {
60
+ list: () => import("@glassly/bluetooth-sdk").PairedController[];
61
+ onList: (cb: (controllers: import("@glassly/bluetooth-sdk").PairedController[]) => void) => (() => void);
62
+ statuses: () => Record<string, import("@glassly/bluetooth-sdk").ControllerStatus>;
63
+ status: (id: string) => import("@glassly/bluetooth-sdk").ControllerStatus | undefined;
64
+ onStatus: (cb: (statuses: Record<string, import("@glassly/bluetooth-sdk").ControllerStatus>) => void) => (() => void);
65
+ connected: () => import("@glassly/bluetooth-sdk").ControllerStatus[];
66
+ isConnected: (model?: string) => boolean;
67
+ connect: (id: string) => Promise<void>;
68
+ connectAll: () => Promise<void>;
69
+ cancelAttempt: () => Promise<void>;
70
+ disconnect: (id: string) => Promise<void>;
71
+ forget: (id: string) => Promise<void>;
65
72
  };
66
73
  neuralBand: {
67
74
  setMetaSession: (accessToken: string, userId: string) => Promise<void>;
68
75
  clearMetaSession: () => Promise<void>;
69
76
  hasMetaSession: () => Promise<boolean>;
70
- isClaimed: () => Promise<boolean>;
77
+ isClaimed: (id: string) => Promise<boolean>;
71
78
  claimStatus: () => import(".").NeuralBandClaimStatus;
72
79
  resetClaim: () => void;
73
80
  onClaimStatus: (cb: (status: import(".").NeuralBandClaimStatus) => void) => (() => void);
74
- setHandwriting: (enabled: boolean) => Promise<void>;
75
- handwritingStatus: () => import(".").NeuralBandHandwritingStatus;
76
- onHandwritingStatus: (cb: (status: import(".").NeuralBandHandwritingStatus) => void) => (() => void);
77
- setPointer: (enabled: boolean) => Promise<void>;
78
- setHand: (hand: "left" | "right") => Promise<void>;
81
+ setHandwriting: (id: string, enabled: boolean) => Promise<void>;
82
+ handwritingStatus: (id: string) => import(".").NeuralBandHandwritingStatus;
83
+ onHandwritingStatus: (cb: (update: import(".").NeuralBandHandwritingUpdate) => void) => (() => void);
84
+ setPointer: (id: string, enabled: boolean) => Promise<void>;
85
+ setHand: (id: string, hand: "left" | "right") => Promise<void>;
79
86
  };
80
87
  audio: {
81
88
  getMediaVolume: () => Promise<import("@glassly/bluetooth-sdk").GlassesMediaVolumeGetResult>;
@@ -139,6 +146,24 @@ export declare const engine: {
139
146
  deleteModel: (_code?: string | undefined) => Promise<void>;
140
147
  };
141
148
  };
149
+ /** On-device LLM model management (Settings > AI Models). */
150
+ ai: {
151
+ local: {
152
+ models: () => import(".").LocalLlmModelConfig[];
153
+ selectedModelId: () => import(".").LocalLlmModelId;
154
+ select: (id: import(".").LocalLlmModelId) => Promise<void>;
155
+ isDownloaded: (id?: import(".").LocalLlmModelId) => Promise<boolean>;
156
+ downloadedModelIds: () => Promise<import(".").LocalLlmModelId[]>;
157
+ download: (id?: import(".").LocalLlmModelId) => Promise<void>;
158
+ cancelDownload: () => Promise<void>;
159
+ deleteModel: (id?: import(".").LocalLlmModelId) => Promise<void>;
160
+ status: () => import(".").LocalLlmDownloadStatus | null;
161
+ onStatusChanged: (listener: (status: import(".").LocalLlmDownloadStatus | null) => void) => (() => void);
162
+ isLoaded: () => boolean;
163
+ unload: () => Promise<void>;
164
+ formatBytes: (bytes: number) => string;
165
+ };
166
+ };
142
167
  /** Cloud live-session status + account ops — engine owns the client. */
143
168
  session: {
144
169
  status: () => import(".").CloudClientStatusSnapshot;
@@ -265,8 +290,6 @@ export declare const engine: {
265
290
  scan: (model: import("@glassly/bluetooth-sdk").DeviceModel) => Promise<void>;
266
291
  scanning: () => boolean;
267
292
  onScanning: (cb: (scanning: boolean) => void) => (() => void);
268
- scanningController: () => boolean;
269
- onScanningController: (cb: (scanning: boolean) => void) => (() => void);
270
293
  otherBtConnected: () => boolean;
271
294
  onOtherBtConnected: (cb: (connected: boolean) => void) => (() => void);
272
295
  searchResults: () => {
@@ -285,6 +308,7 @@ export declare const engine: {
285
308
  setDefault: (device: import("@glassly/bluetooth-sdk").Device | null) => Promise<void>;
286
309
  setBluetoothClassicTarget: (device: import("@glassly/bluetooth-sdk").Device) => Promise<void>;
287
310
  abandonAttempt: () => Promise<void>;
311
+ abandonControllerAttempt: () => Promise<void>;
288
312
  onPairFailure: (cb: (event: import("@glassly/bluetooth-sdk").PairFailureEvent) => void) => (() => void);
289
313
  onGlassesNotReady: (cb: (event: import("@glassly/bluetooth-sdk").GlassesNotReadyEvent) => void) => (() => void);
290
314
  waitForReady: (options?: import("./facades/pairing").PairingReadyWaitOptions) => Promise<boolean>;
@@ -1 +1 @@
1
- {"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAC,SAAS,EAAkD,aAAa,EAAC,MAAM,qBAAqB,CAAA;AA4C5G,eAAO,MAAM,MAAM;IACjB,2EAA2E;;IAE3E,8EAA8E;;IAE9E;iDAC6C;;IAgG7C;;yCAEqC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAmCrC,wEAAwE;;;;;;;;IAExE,sEAAsE;;;;;;;;;;;;IAEtE,qFAAqF;;;;gBA5HV,CAAC;mBAAiB,CAAC;;;gBAM5F,CADA;mBAAiB,CAAC;;;;;;;;;;;;;;;;;IAyHpB,qEAAqE;;;;IAErE,sFAAsF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEtF,6EAA6E;;;;;;;;;;;;IAE7E,iFAAiF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;;IAE5E,+EAA+E;;;;;;;;;;;;IAE/E,kFAAkF;;;;;+BArJxD,CAAA;;;+BAUyC,CAAC;;;;;;;;;;;;IA6IpE,mFAAmF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGpF,CAAA"}
package/build/engine.js CHANGED
@@ -33,6 +33,7 @@ import { gallerySyncService } from "./services/asg/gallerySyncService";
33
33
  import { glasses } from "./facades/glasses";
34
34
  import { display } from "./facades/display";
35
35
  import { speech } from "./facades/speech";
36
+ import { ai } from "./facades/ai";
36
37
  import { session } from "./facades/session";
37
38
  import { settings } from "./facades/settings";
38
39
  import { dev } from "./facades/dev";
@@ -189,6 +190,8 @@ export const engine = {
189
190
  },
190
191
  glasses,
191
192
  speech,
193
+ /** On-device LLM model management (Settings > AI Models). */
194
+ ai,
192
195
  /** Cloud live-session status + account ops — engine owns the client. */
193
196
  session,
194
197
  /** Typed keyed user settings over the engine-owned settings store. */
@@ -1 +1 @@
1
- {"version":3,"file":"engine.js","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAC,SAAS,EAAE,KAAK,IAAI,cAAc,EAAE,IAAI,IAAI,aAAa,EAAE,aAAa,EAAC,MAAM,qBAAqB,CAAA;AAC5G,OAAO,EAAC,kBAAkB,EAAC,MAAM,+BAA+B,CAAA;AAChE,OAAO,EAAC,kBAAkB,EAAE,6BAA6B,EAAC,MAAM,iCAAiC,CAAA;AACjG,OAAO,EAAC,uBAAuB,EAAE,sBAAsB,EAAC,MAAM,+BAA+B,CAAA;AAC7F,OAAO,EAAC,4BAA4B,EAAE,2BAA2B,EAAC,MAAM,oCAAoC,CAAA;AAC5G,OAAO,EAAC,wBAAwB,EAAE,uBAAuB,EAAC,MAAM,gCAAgC,CAAA;AAChG,OAAO,EAAC,4BAA4B,EAAE,2BAA2B,EAAC,MAAM,oCAAoC,CAAA;AAC5G,OAAO,EAAC,eAAe,EAAE,cAAc,EAAC,MAAM,uBAAu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AAC;IACD,OAAO;IACP,MAAM;IACN,wEAAwE;IACxE,OAAO;IACP,sEAAsE;IACtE,QAAQ;IACR,qFAAqF;IACrF,GAAG;IACH,qEAAqE;IACrE,OAAO;IACP,sFAAsF;IACtF,GAAG;IACH,6EAA6E;IAC7E,OAAO;IACP,iFAAiF;IACjF,QAAQ;IACR,8CAA8C;IAC9C,OAAO;IACP,uDAAuD;IACvD,kBAAkB;IAClB,8EAA8E;IAC9E,WAAW;IACX,qFAAqF;IACrF,aAAa;IACb,4EAA4E;IAC5E,IAAI;IACJ,+EAA+E;IAC/E,MAAM;IACN,kFAAkF;IAClF,QAAQ;IACR,mFAAmF;IACnF,YAAY;IACZ,OAAO;CACR,CAAA","sourcesContent":["/**\n * `engine` — the namespaced OEM-facing engine API (the \"(A) host API\" from the\n * Phase-1 contract). Host UI calls `engine.<domain>.<method>()`; each domain is a\n * typed facade over the runtime. (Exported from the `@glassly/engine` module, whose\n * name stays `engine` in code; the public API surface is `engine`.)\n *\n * It grows one facade at a time. The migration-era flat store/service exports\n * remain in a private Glassly host package; they shrink as screens move onto\n * `engine.*`.\n */\nimport {configure, start as bootstrapStart, stop as bootstrapStop, updateUiSeams} from \"./runtime/bootstrap\"\nimport {cloudClientService} from \"./services/CloudClientService\"\nimport {hydrateDeviceStore, demoteOrphanedDefaultWearable} from \"./services/DeviceStoreHydration\"\nimport {startPairedGlassesLatch, stopPairedGlassesLatch} from \"./services/PairedGlassesLatch\"\nimport {startMiniappPauseCoordinator, stopMiniappPauseCoordinator} from \"./services/MiniappPauseCoordinator\"\nimport {startGlassesSettingsSync, stopGlassesSettingsSync} from \"./services/GlassesSettingsSync\"\nimport {startGlassesStatusProjection, stopGlassesStatusProjection} from \"./services/GlassesStatusProjection\"\nimport {startOtaService, stopOtaService} from \"./services/OtaService\"\nimport {startAudioCloudUplink, stopAudioCloudUplink} from \"./services/AudioCloudUplink\"\nimport sonioxDirectService from \"./services/soniox/SonioxDirectService\"\nimport {startSupportProfileSync, stopSupportProfileSync} from \"./services/SupportProfileSync\"\nimport {startDeviceEventRouter, stopDeviceEventRouter} from \"./services/DeviceEventRouter\"\nimport {startPhoneActivityTracking, stopPhoneActivityTracking} from \"./services/PhoneActivity\"\nimport {startPhoneNotificationsSync, stopPhoneNotificationsSync} from \"./services/PhoneNotificationsSync\"\nimport {startSpeakerIdSync, stopSpeakerIdSync} from \"./services/SpeakerIdSync\"\nimport {startNeuralBandSettingsSync, stopNeuralBandSettingsSync} from \"./services/neuralBand/NeuralBandSettingsSync\"\nimport {startCaptionsTesterReportService, stopCaptionsTesterReportService} from \"./services/CaptionsTesterReportService\"\nimport {startJSCrashloopReportService, stopJSCrashloopReportService} from \"./services/JSCrashloopReportService\"\nimport {ensureMiniappEngine, stopMiniappEngine} from \"./services/MiniappEngine\"\nimport localMiniappRuntime from \"./services/LocalMiniappRuntime\"\nimport displayProcessor from \"./services/DisplayProcessor\"\nimport {gallerySyncService} from \"./services/asg/gallerySyncService\"\nimport {glasses} from \"./facades/glasses\"\nimport {display} from \"./facades/display\"\nimport {speech} from \"./facades/speech\"\nimport {session} from \"./facades/session\"\nimport {settings} from \"./facades/settings\"\nimport {dev} from \"./facades/dev\"\nimport {reports} from \"./facades/reports\"\nimport {ota} from \"./facades/ota\"\nimport {gallery} from \"./facades/gallery\"\nimport {miniapps} from \"./facades/miniapps\"\nimport {pairing} from \"./facades/pairing\"\nimport {phoneNotifications} from \"./facades/phoneNotifications\"\nimport {permissions} from \"./facades/permissions\"\nimport {notifications} from \"./facades/notifications\"\nimport {maps} from \"./facades/maps\"\nimport {memory} from \"./facades/memory\"\nimport {speakers} from \"./facades/speakers\"\nimport {providerKeys} from \"./facades/providerKeys\"\nimport {logBuffer} from \"./utils/devLogging\"\nimport pageHost from \"./services/pages/PageHost\"\nimport gestureDotsService from \"./services/GestureDotsService\"\n\nexport const engine = {\n /** Front door — hand engine auth + config, then start/stop the runtime. */\n configure,\n /** Merge host-UI seams on a running runtime (scan overlay, wifi setup, …). */\n updateUiSeams,\n /** Start the runtime: mark started + construct/connect the cloud client + begin\n * syncing device settings to the glasses. */\n async start() {\n // Reports attach recent phone logs, so engine owns console interception for\n // OEM hosts too. Idempotent; the Glassly host may start it earlier.\n logBuffer.startConsoleInterception()\n await bootstrapStart()\n // Construct + connect the cloud client so the documented configure()+start()\n // lifecycle yields a live engine.session for OEMs. Idempotent for repeated\n // start() calls.\n cloudClientService.init()\n // Project native device status -> the engine stores (the inbound feed the rest\n // of the runtime reads). Established first so the stores are live before the\n // syncs below react to them.\n startGlassesStatusProjection((changed) => localMiniappRuntime.forwardEvent(\"glasses_connection_state\", changed))\n // Lock + foreground state, read by the dashboard's notification gate and\n // the G2 notification ctrl below; up before either consumer.\n startPhoneActivityTracking()\n // The overlay slot's owner: the designated dashboard miniapp's page shows\n // through it (ADR-0006), so it is up before the miniapp runtime.\n pageHost.start()\n gestureDotsService.start()\n // Route the rest of the inbound device events (wifi/hotspot/gallery -> stores+bus,\n // photo/stream -> coordinators, button/touch/accel/head -> miniapps, save_setting ->\n // store, miniapp_selected -> launcher) so a bare OEM gets device data, not just the\n // Glassly app's MantleManager.\n startDeviceEventRouter()\n // Hydration contract: the native DeviceStore is in-memory and starts empty\n // every launch; seed it from the persisted settings BEFORE start() resolves\n // so every post-start getDefaultDevice() read is a trustworthy two-state\n // answer (no false \"absent\" for genuinely-paired users at cold start).\n // Ordered before startGlassesSettingsSync so the settings load can't\n // double-push through the change subscription. A failed hydration must not\n // brick the runtime: start() continues, and the guards that consume\n // hasDefaultDevice() see the rejection and fail open.\n try {\n await hydrateDeviceStore()\n // Boot repair: a persisted default_wearable without a native default\n // device (identity abandoned mid-pairing, or resurrected from the server\n // before identity stopped syncing) demotes to pending_wearable so hosts\n // render finish-pairing instead of a connect that would throw.\n await demoteOrphanedDefaultWearable()\n } catch (error) {\n console.warn(\"engine.start: device-store hydration failed:\", error instanceof Error ? error.message : error)\n }\n // After the settings load so an already-paired phone latches on this start.\n startPairedGlassesLatch()\n // Pause local miniapps while the paired glasses stay disconnected. Reads\n // the pairing identity, so after the settings load like the latch.\n startMiniappPauseCoordinator()\n // Project the glasses' OTA events into the store for the engine.ota read surface.\n startOtaService()\n // Forward glasses mic_lc3 frames to the v2 cloud session so cloud transcription\n // works for any host (not just the Glassly app's host-side MantleManager fork).\n startAudioCloudUplink()\n // Phone -> Soniox direct transcription (user-supplied API key). Started\n // after device-store hydration so the persisted key is already loaded.\n sonioxDirectService.start()\n // Not awaited: the exchange behind it is a Core round trip with no client\n // deadline, and start() must resolve offline. The glasses get the token\n // when it lands; identity resolution joins the same single-flight exchange.\n void cloudClientService.syncCoreTokenToBluetooth().catch((error) => {\n console.warn(\n \"engine.start: initial Cloud core token sync failed:\",\n error instanceof Error ? error.message : error,\n )\n })\n startSupportProfileSync()\n // Push device-setting changes to the glasses for ANY host, so\n // engine.glasses.settings.set() reaches the device (not just the Glassly app).\n startGlassesSettingsSync()\n // Same for phone-notification config -> the native listener (Android).\n startPhoneNotificationsSync()\n // On-device speaker identification: sync the enabled setting + enrolled\n // profile centroids to the native SpeakerIdEngine, and start the resolver\n // that annotates cloud transcripts with resolved speaker identities.\n startSpeakerIdSync()\n // Meta Neural Band: push the air mouse and wearing-hand settings to the band on connect.\n startNeuralBandSettingsSync()\n // Android internal/e2e: laptop captions tester can broadcast a failure intent;\n // engine owns turning that into a Cloud report.\n startCaptionsTesterReportService()\n // JSRuntime crashloop-disabled is runtime state; engine owns filing the\n // automatic report while hosts only render alert/telemetry side effects.\n startJSCrashloopReportService()\n // Bring up the local-miniapp engine so a bare OEM can run JSRuntime miniapps:\n // the LocalMiniappRuntime (registry + WebView bridge), the JSRuntime router\n // (crust-bound spawn/dispatch pump + launcher wiring), the DisplayProcessor\n // (layout arbitration over the engine stores), and the gallery-sync service.\n // All idempotent — when the Glassly app's host bootstrap also calls these, the\n // second call is a no-op. Host-only crashloop telemetry is attached\n // separately by the Glassly app.\n localMiniappRuntime.initialize()\n ensureMiniappEngine()\n displayProcessor.attachToRuntime()\n gallerySyncService.initialize()\n },\n /** Stop the runtime: tear down the settings sync + cloud client + mark stopped.\n * Each step is guarded so one failing teardown can't skip the rest and leak\n * the remaining runtime services. */\n async stop() {\n const safely = async (label: string, step: () => unknown): Promise<void> => {\n try {\n await step()\n } catch (error) {\n console.warn(`engine.stop: ${label} failed:`, error)\n }\n }\n await safely(\"glasses settings sync\", stopGlassesSettingsSync)\n await safely(\"paired glasses latch\", stopPairedGlassesLatch)\n await safely(\"miniapp pause coordinator\", stopMiniappPauseCoordinator)\n await safely(\"glasses status projection\", stopGlassesStatusProjection)\n await safely(\"device event router\", stopDeviceEventRouter)\n await safely(\"page host\", () => pageHost.stop())\n await safely(\"gesture dots service\", () => gestureDotsService.stop())\n await safely(\"ota service\", stopOtaService)\n await safely(\"audio cloud uplink\", stopAudioCloudUplink)\n await safely(\"soniox direct service\", () => sonioxDirectService.stop())\n await safely(\"support profile sync\", stopSupportProfileSync)\n await safely(\"phone notifications sync\", stopPhoneNotificationsSync)\n await safely(\"phone activity tracking\", stopPhoneActivityTracking)\n await safely(\"speaker id sync\", stopSpeakerIdSync)\n await safely(\"neural band settings sync\", stopNeuralBandSettingsSync)\n await safely(\"captions tester report service\", stopCaptionsTesterReportService)\n await safely(\"js crashloop report service\", stopJSCrashloopReportService)\n await safely(\"miniapp engine\", stopMiniappEngine)\n await safely(\"local miniapp runtime\", () => localMiniappRuntime.cleanup())\n await safely(\"display processor\", () => displayProcessor.detachFromRuntime())\n await safely(\"gallery sync service\", () => gallerySyncService.cleanup())\n await safely(\"cloud client\", () => cloudClientService.shutdown())\n await safely(\"bootstrap\", bootstrapStop)\n },\n glasses,\n speech,\n /** Cloud live-session status + account ops — engine owns the client. */\n session,\n /** Typed keyed user settings over the engine-owned settings store. */\n settings,\n /** Developer/debug surface (backend+cloud URL overrides, reconnect, min version). */\n dev,\n /** Bug-report, automatic runtime report, and feedback submission. */\n reports,\n /** Firmware OTA read/observe surface (updateAvailable/status + on* subscriptions). */\n ota,\n /** Gallery sync: status/onStatus · onNotice (host renders) · sync/cancel. */\n gallery,\n /** Miniapp lifecycle (the WebView bridge primitives are exported separately). */\n miniapps,\n /** First-time glasses discovery + pairing. */\n pairing,\n /** Phone→glasses notification forwarding (Android). */\n phoneNotifications,\n /** OS permissions (check/request/openSettings + per-miniapp requirements). */\n permissions,\n /** Inbound alerts engine→host (crashloop, version-incompatible, connection loss). */\n notifications,\n /** Maps providers — user-supplied Mapbox access token (Settings > Keys). */\n maps,\n /** Shared user-scoped memory timeline (Settings > Memory + session.memory). */\n memory,\n /** Device-local voice profiles for on-device speaker ID (Settings > Speakers). */\n speakers,\n /** AI/voice provider key validation — user-supplied keys (Settings > API Keys). */\n providerKeys,\n display,\n}\n"]}
1
+ {"version":3,"file":"engine.js","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAC,SAAS,EAAE,KAAK,IAAI,cAAc,EAAE,IAAI,IAAI,aAAa,EAAE,aAAa,EAAC,MAAM,qBAAqB,CAAA;AAC5G,OAAO,EAAC,kBAAkB,EAAC,MAAM,+BAA+B,CAAA;AAChE,OAAO,EAAC,kBAAkB,EAAE,6BAA6B,EAAC,MAAM,iCAAiC,CAAA;AACjG,OAAO,EAAC,uBAAuB,EAAE,sBAAsB,EAAC,MAAM,+BAA+B,CAAA;AAC7F,OAAO,EAAC,4BAA4B,EAAE,2BAA2B,EAAC,MAAM,oCAAoC,CAAA;AAC5G,OAAO,EAAC,wBAAwB,EAAE,uBAAuB,EAAC,MAAM,gCAAgC,CAAA;AAChG,OAAO,EAAC,4BAA4B,EAAE,2BAA2B,EAAC,MAAM,oCAAoC,CAAA;AAC5G,OAAO,EAAC,eAAe,EAAE,cAAc,EAAC,MAAM,uBAAuB,CAAA;AACrE,OAAO,EAAC,qBAAqB,EAAE,oBAAoB,EAAC,MAAM,6BAA6B,CAAA;AACvF,OAAO,mBAAmB,MAAM,uCAAuC,CAAA;AACvE,OAAO,EAAC,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AAsE;IACtE,QAAQ;IACR,qFAAqF;IACrF,GAAG;IACH,qEAAqE;IACrE,OAAO;IACP,sFAAsF;IACtF,GAAG;IACH,6EAA6E;IAC7E,OAAO;IACP,iFAAiF;IACjF,QAAQ;IACR,8CAA8C;IAC9C,OAAO;IACP,uDAAuD;IACvD,kBAAkB;IAClB,8EAA8E;IAC9E,WAAW;IACX,qFAAqF;IACrF,aAAa;IACb,4EAA4E;IAC5E,IAAI;IACJ,+EAA+E;IAC/E,MAAM;IACN,kFAAkF;IAClF,QAAQ;IACR,mFAAmF;IACnF,YAAY;IACZ,OAAO;CACR,CAAA","sourcesContent":["/**\n * `engine` — the namespaced OEM-facing engine API (the \"(A) host API\" from the\n * Phase-1 contract). Host UI calls `engine.<domain>.<method>()`; each domain is a\n * typed facade over the runtime. (Exported from the `@glassly/engine` module, whose\n * name stays `engine` in code; the public API surface is `engine`.)\n *\n * It grows one facade at a time. The migration-era flat store/service exports\n * remain in a private Glassly host package; they shrink as screens move onto\n * `engine.*`.\n */\nimport {configure, start as bootstrapStart, stop as bootstrapStop, updateUiSeams} from \"./runtime/bootstrap\"\nimport {cloudClientService} from \"./services/CloudClientService\"\nimport {hydrateDeviceStore, demoteOrphanedDefaultWearable} from \"./services/DeviceStoreHydration\"\nimport {startPairedGlassesLatch, stopPairedGlassesLatch} from \"./services/PairedGlassesLatch\"\nimport {startMiniappPauseCoordinator, stopMiniappPauseCoordinator} from \"./services/MiniappPauseCoordinator\"\nimport {startGlassesSettingsSync, stopGlassesSettingsSync} from \"./services/GlassesSettingsSync\"\nimport {startGlassesStatusProjection, stopGlassesStatusProjection} from \"./services/GlassesStatusProjection\"\nimport {startOtaService, stopOtaService} from \"./services/OtaService\"\nimport {startAudioCloudUplink, stopAudioCloudUplink} from \"./services/AudioCloudUplink\"\nimport sonioxDirectService from \"./services/soniox/SonioxDirectService\"\nimport {startSupportProfileSync, stopSupportProfileSync} from \"./services/SupportProfileSync\"\nimport {startDeviceEventRouter, stopDeviceEventRouter} from \"./services/DeviceEventRouter\"\nimport {startPhoneActivityTracking, stopPhoneActivityTracking} from \"./services/PhoneActivity\"\nimport {startPhoneNotificationsSync, stopPhoneNotificationsSync} from \"./services/PhoneNotificationsSync\"\nimport {startSpeakerIdSync, stopSpeakerIdSync} from \"./services/SpeakerIdSync\"\nimport {startNeuralBandSettingsSync, stopNeuralBandSettingsSync} from \"./services/neuralBand/NeuralBandSettingsSync\"\nimport {startCaptionsTesterReportService, stopCaptionsTesterReportService} from \"./services/CaptionsTesterReportService\"\nimport {startJSCrashloopReportService, stopJSCrashloopReportService} from \"./services/JSCrashloopReportService\"\nimport {ensureMiniappEngine, stopMiniappEngine} from \"./services/MiniappEngine\"\nimport localMiniappRuntime from \"./services/LocalMiniappRuntime\"\nimport displayProcessor from \"./services/DisplayProcessor\"\nimport {gallerySyncService} from \"./services/asg/gallerySyncService\"\nimport {glasses} from \"./facades/glasses\"\nimport {display} from \"./facades/display\"\nimport {speech} from \"./facades/speech\"\nimport {ai} from \"./facades/ai\"\nimport {session} from \"./facades/session\"\nimport {settings} from \"./facades/settings\"\nimport {dev} from \"./facades/dev\"\nimport {reports} from \"./facades/reports\"\nimport {ota} from \"./facades/ota\"\nimport {gallery} from \"./facades/gallery\"\nimport {miniapps} from \"./facades/miniapps\"\nimport {pairing} from \"./facades/pairing\"\nimport {phoneNotifications} from \"./facades/phoneNotifications\"\nimport {permissions} from \"./facades/permissions\"\nimport {notifications} from \"./facades/notifications\"\nimport {maps} from \"./facades/maps\"\nimport {memory} from \"./facades/memory\"\nimport {speakers} from \"./facades/speakers\"\nimport {providerKeys} from \"./facades/providerKeys\"\nimport {logBuffer} from \"./utils/devLogging\"\nimport pageHost from \"./services/pages/PageHost\"\nimport gestureDotsService from \"./services/GestureDotsService\"\n\nexport const engine = {\n /** Front door — hand engine auth + config, then start/stop the runtime. */\n configure,\n /** Merge host-UI seams on a running runtime (scan overlay, wifi setup, …). */\n updateUiSeams,\n /** Start the runtime: mark started + construct/connect the cloud client + begin\n * syncing device settings to the glasses. */\n async start() {\n // Reports attach recent phone logs, so engine owns console interception for\n // OEM hosts too. Idempotent; the Glassly host may start it earlier.\n logBuffer.startConsoleInterception()\n await bootstrapStart()\n // Construct + connect the cloud client so the documented configure()+start()\n // lifecycle yields a live engine.session for OEMs. Idempotent for repeated\n // start() calls.\n cloudClientService.init()\n // Project native device status -> the engine stores (the inbound feed the rest\n // of the runtime reads). Established first so the stores are live before the\n // syncs below react to them.\n startGlassesStatusProjection((changed) => localMiniappRuntime.forwardEvent(\"glasses_connection_state\", changed))\n // Lock + foreground state, read by the dashboard's notification gate and\n // the G2 notification ctrl below; up before either consumer.\n startPhoneActivityTracking()\n // The overlay slot's owner: the designated dashboard miniapp's page shows\n // through it (ADR-0006), so it is up before the miniapp runtime.\n pageHost.start()\n gestureDotsService.start()\n // Route the rest of the inbound device events (wifi/hotspot/gallery -> stores+bus,\n // photo/stream -> coordinators, button/touch/accel/head -> miniapps, save_setting ->\n // store, miniapp_selected -> launcher) so a bare OEM gets device data, not just the\n // Glassly app's MantleManager.\n startDeviceEventRouter()\n // Hydration contract: the native DeviceStore is in-memory and starts empty\n // every launch; seed it from the persisted settings BEFORE start() resolves\n // so every post-start getDefaultDevice() read is a trustworthy two-state\n // answer (no false \"absent\" for genuinely-paired users at cold start).\n // Ordered before startGlassesSettingsSync so the settings load can't\n // double-push through the change subscription. A failed hydration must not\n // brick the runtime: start() continues, and the guards that consume\n // hasDefaultDevice() see the rejection and fail open.\n try {\n await hydrateDeviceStore()\n // Boot repair: a persisted default_wearable without a native default\n // device (identity abandoned mid-pairing, or resurrected from the server\n // before identity stopped syncing) demotes to pending_wearable so hosts\n // render finish-pairing instead of a connect that would throw.\n await demoteOrphanedDefaultWearable()\n } catch (error) {\n console.warn(\"engine.start: device-store hydration failed:\", error instanceof Error ? error.message : error)\n }\n // After the settings load so an already-paired phone latches on this start.\n startPairedGlassesLatch()\n // Pause local miniapps while the paired glasses stay disconnected. Reads\n // the pairing identity, so after the settings load like the latch.\n startMiniappPauseCoordinator()\n // Project the glasses' OTA events into the store for the engine.ota read surface.\n startOtaService()\n // Forward glasses mic_lc3 frames to the v2 cloud session so cloud transcription\n // works for any host (not just the Glassly app's host-side MantleManager fork).\n startAudioCloudUplink()\n // Phone -> Soniox direct transcription (user-supplied API key). Started\n // after device-store hydration so the persisted key is already loaded.\n sonioxDirectService.start()\n // Not awaited: the exchange behind it is a Core round trip with no client\n // deadline, and start() must resolve offline. The glasses get the token\n // when it lands; identity resolution joins the same single-flight exchange.\n void cloudClientService.syncCoreTokenToBluetooth().catch((error) => {\n console.warn(\n \"engine.start: initial Cloud core token sync failed:\",\n error instanceof Error ? error.message : error,\n )\n })\n startSupportProfileSync()\n // Push device-setting changes to the glasses for ANY host, so\n // engine.glasses.settings.set() reaches the device (not just the Glassly app).\n startGlassesSettingsSync()\n // Same for phone-notification config -> the native listener (Android).\n startPhoneNotificationsSync()\n // On-device speaker identification: sync the enabled setting + enrolled\n // profile centroids to the native SpeakerIdEngine, and start the resolver\n // that annotates cloud transcripts with resolved speaker identities.\n startSpeakerIdSync()\n // Meta Neural Band: push the air mouse and wearing-hand settings to the band on connect.\n startNeuralBandSettingsSync()\n // Android internal/e2e: laptop captions tester can broadcast a failure intent;\n // engine owns turning that into a Cloud report.\n startCaptionsTesterReportService()\n // JSRuntime crashloop-disabled is runtime state; engine owns filing the\n // automatic report while hosts only render alert/telemetry side effects.\n startJSCrashloopReportService()\n // Bring up the local-miniapp engine so a bare OEM can run JSRuntime miniapps:\n // the LocalMiniappRuntime (registry + WebView bridge), the JSRuntime router\n // (crust-bound spawn/dispatch pump + launcher wiring), the DisplayProcessor\n // (layout arbitration over the engine stores), and the gallery-sync service.\n // All idempotent — when the Glassly app's host bootstrap also calls these, the\n // second call is a no-op. Host-only crashloop telemetry is attached\n // separately by the Glassly app.\n localMiniappRuntime.initialize()\n ensureMiniappEngine()\n displayProcessor.attachToRuntime()\n gallerySyncService.initialize()\n },\n /** Stop the runtime: tear down the settings sync + cloud client + mark stopped.\n * Each step is guarded so one failing teardown can't skip the rest and leak\n * the remaining runtime services. */\n async stop() {\n const safely = async (label: string, step: () => unknown): Promise<void> => {\n try {\n await step()\n } catch (error) {\n console.warn(`engine.stop: ${label} failed:`, error)\n }\n }\n await safely(\"glasses settings sync\", stopGlassesSettingsSync)\n await safely(\"paired glasses latch\", stopPairedGlassesLatch)\n await safely(\"miniapp pause coordinator\", stopMiniappPauseCoordinator)\n await safely(\"glasses status projection\", stopGlassesStatusProjection)\n await safely(\"device event router\", stopDeviceEventRouter)\n await safely(\"page host\", () => pageHost.stop())\n await safely(\"gesture dots service\", () => gestureDotsService.stop())\n await safely(\"ota service\", stopOtaService)\n await safely(\"audio cloud uplink\", stopAudioCloudUplink)\n await safely(\"soniox direct service\", () => sonioxDirectService.stop())\n await safely(\"support profile sync\", stopSupportProfileSync)\n await safely(\"phone notifications sync\", stopPhoneNotificationsSync)\n await safely(\"phone activity tracking\", stopPhoneActivityTracking)\n await safely(\"speaker id sync\", stopSpeakerIdSync)\n await safely(\"neural band settings sync\", stopNeuralBandSettingsSync)\n await safely(\"captions tester report service\", stopCaptionsTesterReportService)\n await safely(\"js crashloop report service\", stopJSCrashloopReportService)\n await safely(\"miniapp engine\", stopMiniappEngine)\n await safely(\"local miniapp runtime\", () => localMiniappRuntime.cleanup())\n await safely(\"display processor\", () => displayProcessor.detachFromRuntime())\n await safely(\"gallery sync service\", () => gallerySyncService.cleanup())\n await safely(\"cloud client\", () => cloudClientService.shutdown())\n await safely(\"bootstrap\", bootstrapStop)\n },\n glasses,\n speech,\n /** On-device LLM model management (Settings > AI Models). */\n ai,\n /** Cloud live-session status + account ops — engine owns the client. */\n session,\n /** Typed keyed user settings over the engine-owned settings store. */\n settings,\n /** Developer/debug surface (backend+cloud URL overrides, reconnect, min version). */\n dev,\n /** Bug-report, automatic runtime report, and feedback submission. */\n reports,\n /** Firmware OTA read/observe surface (updateAvailable/status + on* subscriptions). */\n ota,\n /** Gallery sync: status/onStatus · onNotice (host renders) · sync/cancel. */\n gallery,\n /** Miniapp lifecycle (the WebView bridge primitives are exported separately). */\n miniapps,\n /** First-time glasses discovery + pairing. */\n pairing,\n /** Phone→glasses notification forwarding (Android). */\n phoneNotifications,\n /** OS permissions (check/request/openSettings + per-miniapp requirements). */\n permissions,\n /** Inbound alerts engine→host (crashloop, version-incompatible, connection loss). */\n notifications,\n /** Maps providers — user-supplied Mapbox access token (Settings > Keys). */\n maps,\n /** Shared user-scoped memory timeline (Settings > Memory + session.memory). */\n memory,\n /** Device-local voice profiles for on-device speaker ID (Settings > Speakers). */\n speakers,\n /** AI/voice provider key validation — user-supplied keys (Settings > API Keys). */\n providerKeys,\n display,\n}\n"]}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * ai facade — `engine.ai.local`: the on-device LLM model that serves
3
+ * session.ai calls routed to the phone (forceLocal / localFallback). Thin
4
+ * passthrough over LocalLlmModelManager and LocalLlmProvider so Settings >
5
+ * AI Models can list, pick, download, and delete models without reaching
6
+ * into engine internals.
7
+ */
8
+ import { type LocalLlmDownloadStatus, type LocalLlmModelConfig, type LocalLlmModelId } from "../services/LocalLlmModelManager";
9
+ export declare const ai: {
10
+ local: {
11
+ /** The catalog, in dropdown order. */
12
+ models: () => LocalLlmModelConfig[];
13
+ /** The Settings > AI Models pick. */
14
+ selectedModelId: () => LocalLlmModelId;
15
+ select: (id: LocalLlmModelId) => Promise<void>;
16
+ isDownloaded: (id?: LocalLlmModelId) => Promise<boolean>;
17
+ downloadedModelIds: () => Promise<LocalLlmModelId[]>;
18
+ download: (id?: LocalLlmModelId) => Promise<void>;
19
+ cancelDownload: () => Promise<void>;
20
+ /** Removes the files and drops the resident runner if it was this model. */
21
+ deleteModel: (id?: LocalLlmModelId) => Promise<void>;
22
+ status: () => LocalLlmDownloadStatus | null;
23
+ /** Subscribe to download status changes; fires immediately, returns an unsubscribe. */
24
+ onStatusChanged: (listener: (status: LocalLlmDownloadStatus | null) => void) => (() => void);
25
+ /** Whether a model is resident in memory right now. */
26
+ isLoaded: () => boolean;
27
+ /** Drop the resident model (memory pressure, debugging). */
28
+ unload: () => Promise<void>;
29
+ formatBytes: (bytes: number) => string;
30
+ };
31
+ };
32
+ //# sourceMappingURL=ai.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai.d.ts","sourceRoot":"","sources":["../../src/facades/ai.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAA6B,EAE3B,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACrB,MAAM,kCAAkC,CAAA;AAGzC,eAAO,MAAM,EAAE;;QAEX,sCAAsC;sBAC1B,mBAAmB,EAAE;QACjC,qCAAqC;+BAChB,eAAe;qBACvB,eAAe,KAAG,OAAO,CAAC,IAAI,CAAC;4BACxB,eAAe,KAAG,OAAO,CAAC,OAAO,CAAC;kCAC9B,OAAO,CAAC,eAAe,EAAE,CAAC;wBAClC,eAAe,KAAG,OAAO,CAAC,IAAI,CAAC;8BAC3B,OAAO,CAAC,IAAI,CAAC;QACjC,4EAA4E;2BACnD,eAAe,KAAG,OAAO,CAAC,IAAI,CAAC;sBAK5C,sBAAsB,GAAG,IAAI;QACzC,uFAAuF;oCAC3D,CAAC,MAAM,EAAE,sBAAsB,GAAG,IAAI,KAAK,IAAI,KAAG,CAAC,MAAM,IAAI,CAAC;QAE1F,uDAAuD;wBACzC,OAAO;QACrB,4DAA4D;sBAChD,OAAO,CAAC,IAAI,CAAC;6BACJ,MAAM,KAAG,MAAM;;CAEvC,CAAA"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * ai facade — `engine.ai.local`: the on-device LLM model that serves
3
+ * session.ai calls routed to the phone (forceLocal / localFallback). Thin
4
+ * passthrough over LocalLlmModelManager and LocalLlmProvider so Settings >
5
+ * AI Models can list, pick, download, and delete models without reaching
6
+ * into engine internals.
7
+ */
8
+ import localLlmModelManager, { LocalLlmModelManager, } from "../services/LocalLlmModelManager";
9
+ import localLlmProvider from "../services/LocalLlmProvider";
10
+ export const ai = {
11
+ local: {
12
+ /** The catalog, in dropdown order. */
13
+ models: () => localLlmModelManager.models(),
14
+ /** The Settings > AI Models pick. */
15
+ selectedModelId: () => localLlmModelManager.selectedModelId(),
16
+ select: (id) => localLlmModelManager.select(id),
17
+ isDownloaded: (id) => localLlmModelManager.isModelAvailable(id),
18
+ downloadedModelIds: () => localLlmModelManager.downloadedModelIds(),
19
+ download: (id) => localLlmModelManager.downloadModel(id),
20
+ cancelDownload: () => localLlmModelManager.cancelDownload(),
21
+ /** Removes the files and drops the resident runner if it was this model. */
22
+ deleteModel: async (id) => {
23
+ const target = id ?? localLlmModelManager.selectedModelId();
24
+ if (localLlmProvider.loadedModelId() === target)
25
+ await localLlmProvider.unload();
26
+ await localLlmModelManager.deleteModel(target);
27
+ },
28
+ status: () => localLlmModelManager.getStatus(),
29
+ /** Subscribe to download status changes; fires immediately, returns an unsubscribe. */
30
+ onStatusChanged: (listener) => localLlmModelManager.subscribe(listener),
31
+ /** Whether a model is resident in memory right now. */
32
+ isLoaded: () => localLlmProvider.isLoaded(),
33
+ /** Drop the resident model (memory pressure, debugging). */
34
+ unload: () => localLlmProvider.unload(),
35
+ formatBytes: (bytes) => LocalLlmModelManager.formatBytes(bytes),
36
+ },
37
+ };
38
+ //# sourceMappingURL=ai.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai.js","sourceRoot":"","sources":["../../src/facades/ai.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,oBAAoB,EAAE,EAC3B,oBAAoB,GAIrB,MAAM,kCAAkC,CAAA;AACzC,OAAO,gBAAgB,MAAM,8BAA8B,CAAA;AAE3D,MAAM,CAAC,MAAM,EAAE,GAAG;IAChB,KAAK,EAAE;QACL,sCAAsC;QACtC,MAAM,EAAE,GAA0B,EAAE,CAAC,oBAAoB,CAAC,MAAM,EAAE;QAClE,qCAAqC;QACrC,eAAe,EAAE,GAAoB,EAAE,C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ed to the phone (forceLocal / localFallback). Thin\n * passthrough over LocalLlmModelManager and LocalLlmProvider so Settings >\n * AI Models can list, pick, download, and delete models without reaching\n * into engine internals.\n */\nimport localLlmModelManager, {\n LocalLlmModelManager,\n type LocalLlmDownloadStatus,\n type LocalLlmModelConfig,\n type LocalLlmModelId,\n} from \"../services/LocalLlmModelManager\"\nimport localLlmProvider from \"../services/LocalLlmProvider\"\n\nexport const ai = {\n local: {\n /** The catalog, in dropdown order. */\n models: (): LocalLlmModelConfig[] => localLlmModelManager.models(),\n /** The Settings > AI Models pick. */\n selectedModelId: (): LocalLlmModelId => localLlmModelManager.selectedModelId(),\n select: (id: LocalLlmModelId): Promise<void> => localLlmModelManager.select(id),\n isDownloaded: (id?: LocalLlmModelId): Promise<boolean> => localLlmModelManager.isModelAvailable(id),\n downloadedModelIds: (): Promise<LocalLlmModelId[]> => localLlmModelManager.downloadedModelIds(),\n download: (id?: LocalLlmModelId): Promise<void> => localLlmModelManager.downloadModel(id),\n cancelDownload: (): Promise<void> => localLlmModelManager.cancelDownload(),\n /** Removes the files and drops the resident runner if it was this model. */\n deleteModel: async (id?: LocalLlmModelId): Promise<void> => {\n const target = id ?? localLlmModelManager.selectedModelId()\n if (localLlmProvider.loadedModelId() === target) await localLlmProvider.unload()\n await localLlmModelManager.deleteModel(target)\n },\n status: (): LocalLlmDownloadStatus | null => localLlmModelManager.getStatus(),\n /** Subscribe to download status changes; fires immediately, returns an unsubscribe. */\n onStatusChanged: (listener: (status: LocalLlmDownloadStatus | null) => void): (() => void) =>\n localLlmModelManager.subscribe(listener),\n /** Whether a model is resident in memory right now. */\n isLoaded: (): boolean => localLlmProvider.isLoaded(),\n /** Drop the resident model (memory pressure, debugging). */\n unload: (): Promise<void> => localLlmProvider.unload(),\n formatBytes: (bytes: number): string => LocalLlmModelManager.formatBytes(bytes),\n },\n}\n"]}
@@ -1,5 +1,5 @@
1
- import type { ButtonPressEvent, ConnectOptions, Device, KeyboardAdvertEvent, KeyboardPairingEvent, TouchEvent } from "@glassly/bluetooth-sdk";
2
- import { type NeuralBandClaimStatus, type NeuralBandHandwritingStatus } from "../services/neuralBand/NeuralBandInput";
1
+ import type { ButtonPressEvent, ConnectOptions, ControllerStatus, Device, KeyboardAdvertEvent, KeyboardPairingEvent, PairedController, TouchEvent } from "@glassly/bluetooth-sdk";
2
+ import { type NeuralBandClaimStatus, type NeuralBandHandwritingStatus, type NeuralBandHandwritingUpdate } from "../services/neuralBand/NeuralBandInput";
3
3
  declare function projectStatus(): {
4
4
  state: "connecting" | "connected" | "disconnected" | "scanning" | "bonding";
5
5
  fullyBooted: boolean;
@@ -17,12 +17,6 @@ declare function projectStatus(): {
17
17
  btClassic: boolean;
18
18
  ancsAuthorized: boolean;
19
19
  };
20
- declare function projectControllerStatus(): {
21
- connected: boolean;
22
- fullyBooted: boolean;
23
- battery: number;
24
- signal: number;
25
- };
26
20
  declare function projectKeyboardStatus(): {
27
21
  /** Connected glasses run a firmware that can host a keyboard (G2 Glassly CFW 39+). */
28
22
  available: boolean;
@@ -62,7 +56,6 @@ declare function projectInfo(): {
62
56
  };
63
57
  };
64
58
  export type GlassesStatusSnapshot = ReturnType<typeof projectStatus>;
65
- export type ControllerStatusSnapshot = ReturnType<typeof projectControllerStatus>;
66
59
  export type KeyboardStatusSnapshot = ReturnType<typeof projectKeyboardStatus>;
67
60
  export type GlassesInfoSnapshot = ReturnType<typeof projectInfo>;
68
61
  export declare const glasses: {
@@ -133,31 +126,44 @@ export declare const glasses: {
133
126
  onAdvert: (cb: (advert: KeyboardAdvertEvent) => void) => (() => void);
134
127
  onPairing: (cb: (prompt: KeyboardPairingEvent) => void) => (() => void);
135
128
  };
136
- controller: {
137
- connectDefault: () => Promise<void>;
138
- disconnect: () => Promise<void>;
139
- forget: () => Promise<void>;
140
- status: () => ControllerStatusSnapshot;
141
- onStatus: (cb: (status: ControllerStatusSnapshot) => void) => (() => void);
129
+ controllers: {
130
+ /** Paired controllers in pairing order. */
131
+ list: () => PairedController[];
132
+ onList: (cb: (controllers: PairedController[]) => void) => (() => void);
133
+ /** Live driver statuses by id; a paired controller without an entry is idle. */
134
+ statuses: () => Record<string, ControllerStatus>;
135
+ status: (id: string) => ControllerStatus | undefined;
136
+ onStatus: (cb: (statuses: Record<string, ControllerStatus>) => void) => (() => void);
137
+ /** Controllers delivering input (linked, route or claim done). */
138
+ connected: () => ControllerStatus[];
139
+ isConnected: (model?: string) => boolean;
140
+ connect: (id: string) => Promise<void>;
141
+ /** Reconnect every paired controller that is not connected. */
142
+ connectAll: () => Promise<void>;
143
+ /** Drop an in-flight controller scan or pairing; paired records are untouched. */
144
+ cancelAttempt: () => Promise<void>;
145
+ /** Disconnect; the controller stays paired. */
146
+ disconnect: (id: string) => Promise<void>;
147
+ forget: (id: string) => Promise<void>;
142
148
  };
143
149
  neuralBand: {
144
- /** Store the Meta account session the one-time band claim uses. */
150
+ /** Store the Meta account session the one-time band claim uses (account-wide). */
145
151
  setMetaSession: (accessToken: string, userId: string) => Promise<void>;
146
152
  clearMetaSession: () => Promise<void>;
147
153
  hasMetaSession: () => Promise<boolean>;
148
- /** A band identity is stored on this phone, so the remembered band connects without a claim. */
149
- isClaimed: () => Promise<boolean>;
150
- /** The latest claim progress, kept across screens. */
154
+ /** This band's identity is stored on this phone, so it reconnects without a claim. */
155
+ isClaimed: (id: string) => Promise<boolean>;
156
+ /** The latest claim progress of any band (with its `controllerId`), kept across screens. */
151
157
  claimStatus: () => NeuralBandClaimStatus;
152
158
  resetClaim: () => void;
153
159
  onClaimStatus: (cb: (status: NeuralBandClaimStatus) => void) => (() => void);
154
160
  /** The band's handwriting model; writing arrives on the miniapp keyboard stream. */
155
- setHandwriting: (enabled: boolean) => Promise<void>;
156
- handwritingStatus: () => NeuralBandHandwritingStatus;
157
- onHandwritingStatus: (cb: (status: NeuralBandHandwritingStatus) => void) => (() => void);
161
+ setHandwriting: (id: string, enabled: boolean) => Promise<void>;
162
+ handwritingStatus: (id: string) => NeuralBandHandwritingStatus;
163
+ onHandwritingStatus: (cb: (update: NeuralBandHandwritingUpdate) => void) => (() => void);
158
164
  /** The band's air mouse; movement reaches miniapps on the pointer stream. */
159
- setPointer: (enabled: boolean) => Promise<void>;
160
- setHand: (hand: "left" | "right") => Promise<void>;
165
+ setPointer: (id: string, enabled: boolean) => Promise<void>;
166
+ setHand: (id: string, hand: "left" | "right") => Promise<void>;
161
167
  };
162
168
  audio: {
163
169
  /** Read the glasses' current media volume. */
@@ -1 +1 @@
1
- {"version":3,"file":"glasses.d.ts","sourceRoot":"","sources":["../../src/facades/glasses.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,gBAAgB,EAChB,cAAc,EACd,MAAM,EACN,mBAAmB,EACnB,oBAAoB,EACpB,UAAU,EACX,MAAM,wBAAwB,CAAA;AAQ/B,OAAwB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,2BAA2B,EACjC,MAAM,wCAAwC,CAAA;AAS/C,iBAAS,aAAa;;;;;;;;;;;;;;;;EAerB;AAED,iBAAS,uBAAuB;;;;;EAQ/B;AAED,iBAAS,qBAAqB;IAG1B,sFAAsF;;;;IAItF,6DAA6D;;;;EAKhE;AAED,iBAAS,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyBnB;AAED,MAAM,MAAM,qBAAqB,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAA;AACpE,MAAM,MAAM,wBAAwB,GAAG,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAA;AACjF,MAAM,MAAM,sBAAsB,GAAG,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAA;AAC7E,MAAM,MAAM,mBAAmB,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAA;AAEhE,eAAO,MAAM,OAAO;IAElB;;;;OAIG;0BACuB,OAAO,CAAC,IAAI,CAAC;sBASvB,OAAO,CAAC,IAAI,CAAC;kBACjB,OAAO,CAAC,IAAI,CAAC;IACzB,iDAAiD;sBACzB,MAAM,YAAY,cAAc,KAAG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AChC,+CAA+C;yBAC9B,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC;qBACpB,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC;;;QAQzC,kFAAkF;sCACpD,MAAM,UAAU,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC;gCAE9C,OAAO,CAAC,IAAI,CAAC;8BACf,OAAO,CAAC,OAAO,CAAC;QACpC,sFAAsF;wBACtE,MAAM,KAAG,OAAO,CAAC,OAAO,CAAC;QACzC,4FAA4F;2BAC3E,qBAAqB;0BACtB,IAAI;4BACA,CAAC,MAAM,EAAE,qBAAqB,KAAK,IAAI,KAAG,CAAC,MAAM,IAAI,CAAC;QAC1E,oFAAoF;6BAC/D,MAAM,WAAW,OAAO,KAAG,OAAO,CAAC,IAAI,CAAC;gCACrC,MAAM,KAAG,2BAA2B;kCAClC,CAAC,MAAM,EAAE,2BAA2B,KAAK,IAAI,KAAG,CAAC,MAAM,IAAI,CAAC;QAEtF,6EAA6E;yBAC5D,MAAM,WAAW,OAAO,KAAG,OAAO,CAAC,IAAI,CAAC;sBAC3C,MAAM,QAAQ,MAAM,GAAG,OAAO,KAAG,OAAO,CAAC,IAAI,CAAC;;;QAK5D,8CAA8C;;QAE9C,qCAAqC;gCACb,MAAM;QAC9B,6EAA6E;oCACjD,OAAO,KAAG,OAAO,CAAC,IAAI,CAAC;QACnD;;;;WAIG;yBACc,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,KAAG,CAAC,MAAM,IAAI,CAAC;;;;;;;;;;;;;;;;;CAgBzD,CAAA"}
@@ -18,6 +18,7 @@ import micStateCoordinator from "../services/MicStateCoordinator";
18
18
  import { projectPairingIdentity } from "../services/PairingIdentity";
19
19
  import { isGlassesConnected, isGlassesReady } from "../services/GlassesReadiness";
20
20
  import { pushAllBluetoothSettings } from "../services/GlassesSettingsSync";
21
+ import { isControllerReady, pairedControllersFrom, readyControllers } from "../services/controllers";
21
22
  import neuralBandInput from "../services/neuralBand/NeuralBandInput";
22
23
  import { recordSupportProfileConnectionFailure } from "../services/SupportProfileSync";
23
24
  import { getModelCapabilities } from "../types";
@@ -41,14 +42,16 @@ function projectStatus() {
41
42
  ancsAuthorized: Boolean(s.ancsAuthorized),
42
43
  };
43
44
  }
44
- function projectControllerStatus() {
45
- const s = useGlassesStore.getState();
46
- return {
47
- connected: s.controllerConnected,
48
- fullyBooted: s.controllerFullyBooted,
49
- battery: s.controllerBatteryLevel,
50
- signal: s.controllerSignalStrength,
51
- };
45
+ function projectControllerList() {
46
+ return pairedControllersFrom(useSettingsStore.getState().getSetting(SETTINGS.controllers.key));
47
+ }
48
+ // Copies: snapshots must not hand callers mutable references into the store.
49
+ function projectControllerStatuses() {
50
+ const statuses = {};
51
+ for (const [id, status] of Object.entries(useGlassesStore.getState().controllers ?? {})) {
52
+ statuses[id] = { ...status };
53
+ }
54
+ return statuses;
52
55
  }
53
56
  function projectKeyboardStatus() {
54
57
  const s = useGlassesStore.getState();
@@ -241,43 +244,59 @@ export const glasses = {
241
244
  return () => sub.remove();
242
245
  },
243
246
  },
244
- // --- ring controller (optional input device) ---
245
- controller: {
246
- connectDefault: () => BluetoothSdk.connectDefaultController(),
247
- disconnect: () => BluetoothSdk.disconnectController(),
248
- forget: () => BluetoothSdk.forgetController(),
249
- status: () => projectControllerStatus(),
250
- onStatus: (cb) => {
251
- let last = JSON.stringify(projectControllerStatus());
252
- return useGlassesStore.subscribe(() => {
253
- const snap = projectControllerStatus();
254
- const key = JSON.stringify(snap);
247
+ // --- controllers (input accessories linked to the phone), by registry id ---
248
+ controllers: {
249
+ /** Paired controllers in pairing order. */
250
+ list: () => projectControllerList(),
251
+ onList: (cb) => {
252
+ let last = JSON.stringify(projectControllerList());
253
+ return useSettingsStore.subscribe(() => {
254
+ const list = projectControllerList();
255
+ const key = JSON.stringify(list);
255
256
  if (key === last)
256
257
  return;
257
258
  last = key;
258
- cb(snap);
259
+ cb(list);
259
260
  });
260
261
  },
262
+ /** Live driver statuses by id; a paired controller without an entry is idle. */
263
+ statuses: () => projectControllerStatuses(),
264
+ status: (id) => projectControllerStatuses()[id],
265
+ onStatus: (cb) => useGlassesStore.subscribe((s) => s.controllers, () => cb(projectControllerStatuses())),
266
+ /** Controllers delivering input (linked, route or claim done). */
267
+ connected: () => readyControllers(projectControllerStatuses()),
268
+ isConnected: (model) => Object.values(useGlassesStore.getState().controllers ?? {}).some((status) => isControllerReady(status) && (model === undefined || status.model === model)),
269
+ connect: (id) => BluetoothSdk.connectController(id),
270
+ /** Reconnect every paired controller that is not connected. */
271
+ connectAll: () => BluetoothSdk.connectControllers(),
272
+ /** Drop an in-flight controller scan or pairing; paired records are untouched. */
273
+ cancelAttempt: () => BluetoothSdk.cancelControllerAttempt(),
274
+ /** Disconnect; the controller stays paired. */
275
+ disconnect: (id) => BluetoothSdk.disconnectController(id),
276
+ forget: async (id) => {
277
+ await BluetoothSdk.forgetController(id);
278
+ neuralBandInput.forget(id);
279
+ },
261
280
  },
262
- // --- Meta Neural Band (a controller with a claim step and its own features) ---
281
+ // --- Meta Neural Band (a controller with a claim step and its own features), by controller id ---
263
282
  neuralBand: {
264
- /** Store the Meta account session the one-time band claim uses. */
283
+ /** Store the Meta account session the one-time band claim uses (account-wide). */
265
284
  setMetaSession: (accessToken, userId) => BluetoothSdk.neuralBandSetMetaSession(accessToken, userId),
266
285
  clearMetaSession: () => BluetoothSdk.neuralBandClearMetaSession(),
267
286
  hasMetaSession: () => BluetoothSdk.neuralBandHasMetaSession(),
268
- /** A band identity is stored on this phone, so the remembered band connects without a claim. */
269
- isClaimed: () => BluetoothSdk.neuralBandIsClaimed(),
270
- /** The latest claim progress, kept across screens. */
271
- claimStatus: () => neuralBandInput.claimStatus(),
287
+ /** This band's identity is stored on this phone, so it reconnects without a claim. */
288
+ isClaimed: (id) => BluetoothSdk.neuralBandIsClaimed(id),
289
+ /** The latest claim progress of any band (with its `controllerId`), kept across screens. */
290
+ claimStatus: () => ({ ...neuralBandInput.claimStatus() }),
272
291
  resetClaim: () => neuralBandInput.resetClaim(),
273
292
  onClaimStatus: (cb) => neuralBandInput.onClaimStatus(cb),
274
293
  /** The band's handwriting model; writing arrives on the miniapp keyboard stream. */
275
- setHandwriting: (enabled) => BluetoothSdk.neuralBandSetHandwriting(enabled),
276
- handwritingStatus: () => neuralBandInput.handwritingStatus(),
294
+ setHandwriting: (id, enabled) => BluetoothSdk.neuralBandSetHandwriting(id, enabled),
295
+ handwritingStatus: (id) => ({ ...neuralBandInput.handwritingStatus(id) }),
277
296
  onHandwritingStatus: (cb) => neuralBandInput.onHandwritingStatus(cb),
278
297
  /** The band's air mouse; movement reaches miniapps on the pointer stream. */
279
- setPointer: (enabled) => BluetoothSdk.neuralBandSetPointer(enabled),
280
- setHand: (hand) => BluetoothSdk.neuralBandSetHand(hand),
298
+ setPointer: (id, enabled) => BluetoothSdk.neuralBandSetPointer(id, enabled),
299
+ setHand: (id, hand) => BluetoothSdk.neuralBandSetHand(id, hand),
281
300
  },
282
301
  // --- audio (glasses media-volume, own-app playback hint, live mic level) ---
283
302
  audio: {