@mentra/miniapp 3.4.0-dev.998 → 3.4.0

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 (109) hide show
  1. package/README.md +7 -7
  2. package/dist/background/index.d.ts +5 -2
  3. package/dist/background/index.d.ts.map +1 -1
  4. package/dist/background/index.js.map +1 -1
  5. package/dist/background/register.d.ts +3 -1
  6. package/dist/background/register.d.ts.map +1 -1
  7. package/dist/background/register.js +19 -2
  8. package/dist/background/register.js.map +1 -1
  9. package/dist/index.d.ts +6 -3
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js.map +1 -1
  12. package/dist/modules/blob.d.ts +2 -1
  13. package/dist/modules/blob.d.ts.map +1 -1
  14. package/dist/modules/blob.js +2 -1
  15. package/dist/modules/blob.js.map +1 -1
  16. package/dist/modules/events.d.ts +16 -6
  17. package/dist/modules/events.d.ts.map +1 -1
  18. package/dist/modules/events.js +53 -47
  19. package/dist/modules/events.js.map +1 -1
  20. package/dist/modules/mic.d.ts +26 -4
  21. package/dist/modules/mic.d.ts.map +1 -1
  22. package/dist/modules/mic.js +13 -4
  23. package/dist/modules/mic.js.map +1 -1
  24. package/dist/modules/miniapps.d.ts +44 -57
  25. package/dist/modules/miniapps.d.ts.map +1 -1
  26. package/dist/modules/miniapps.js +21 -24
  27. package/dist/modules/miniapps.js.map +1 -1
  28. package/dist/modules/speaker.d.ts +41 -10
  29. package/dist/modules/speaker.d.ts.map +1 -1
  30. package/dist/modules/speaker.js +17 -6
  31. package/dist/modules/speaker.js.map +1 -1
  32. package/dist/modules/speechProcessing.d.ts +29 -0
  33. package/dist/modules/speechProcessing.d.ts.map +1 -0
  34. package/dist/modules/speechProcessing.js +22 -0
  35. package/dist/modules/speechProcessing.js.map +1 -0
  36. package/dist/modules/stream.d.ts +39 -0
  37. package/dist/modules/stream.d.ts.map +1 -1
  38. package/dist/modules/stream.js +13 -1
  39. package/dist/modules/stream.js.map +1 -1
  40. package/dist/modules/system.d.ts +8 -3
  41. package/dist/modules/system.d.ts.map +1 -1
  42. package/dist/modules/system.js +1 -1
  43. package/dist/modules/system.js.map +1 -1
  44. package/dist/modules/telemetry.d.ts +25 -0
  45. package/dist/modules/telemetry.d.ts.map +1 -0
  46. package/dist/modules/telemetry.js +61 -0
  47. package/dist/modules/telemetry.js.map +1 -0
  48. package/dist/modules/transcription.d.ts +70 -3
  49. package/dist/modules/transcription.d.ts.map +1 -1
  50. package/dist/modules/transcription.js +68 -2
  51. package/dist/modules/transcription.js.map +1 -1
  52. package/dist/protocol.d.ts +29 -15
  53. package/dist/protocol.d.ts.map +1 -1
  54. package/dist/protocol.js +30 -15
  55. package/dist/protocol.js.map +1 -1
  56. package/dist/react/MentraProvider.d.ts +13 -1
  57. package/dist/react/MentraProvider.d.ts.map +1 -1
  58. package/dist/react/MentraProvider.js +31 -1
  59. package/dist/react/MentraProvider.js.map +1 -1
  60. package/dist/react/stream-preview/PreviewConnection.d.ts +13 -0
  61. package/dist/react/stream-preview/PreviewConnection.d.ts.map +1 -1
  62. package/dist/react/stream-preview/PreviewConnection.js +40 -1
  63. package/dist/react/stream-preview/PreviewConnection.js.map +1 -1
  64. package/dist/react/stream-preview/transport.d.ts.map +1 -1
  65. package/dist/react/stream-preview/transport.js +2 -0
  66. package/dist/react/stream-preview/transport.js.map +1 -1
  67. package/dist/session.d.ts +59 -6
  68. package/dist/session.d.ts.map +1 -1
  69. package/dist/session.js +203 -43
  70. package/dist/session.js.map +1 -1
  71. package/dist/transport/auto.js +6 -0
  72. package/dist/transport/auto.js.map +1 -1
  73. package/dist/transport/dispatch.d.ts +2 -0
  74. package/dist/transport/dispatch.d.ts.map +1 -1
  75. package/dist/transport/dispatch.js +7 -2
  76. package/dist/transport/dispatch.js.map +1 -1
  77. package/dist/transport/local-socket.d.ts +6 -0
  78. package/dist/transport/local-socket.d.ts.map +1 -1
  79. package/dist/transport/local-socket.js +34 -2
  80. package/dist/transport/local-socket.js.map +1 -1
  81. package/dist/transport/types.d.ts +4 -1
  82. package/dist/transport/types.d.ts.map +1 -1
  83. package/dist/ui/index.d.ts +7 -4
  84. package/dist/ui/index.d.ts.map +1 -1
  85. package/dist/ui/index.js.map +1 -1
  86. package/package.json +2 -2
  87. package/src/background/index.ts +6 -3
  88. package/src/background/register.ts +24 -2
  89. package/src/index.ts +13 -3
  90. package/src/modules/blob.ts +2 -1
  91. package/src/modules/events.ts +65 -51
  92. package/src/modules/mic.ts +30 -4
  93. package/src/modules/miniapps.ts +59 -71
  94. package/src/modules/speaker.ts +56 -12
  95. package/src/modules/speechProcessing.ts +42 -0
  96. package/src/modules/stream.ts +44 -1
  97. package/src/modules/system.ts +8 -3
  98. package/src/modules/telemetry.ts +62 -0
  99. package/src/modules/transcription.ts +106 -9
  100. package/src/protocol.ts +32 -16
  101. package/src/react/MentraProvider.tsx +23 -2
  102. package/src/react/stream-preview/PreviewConnection.ts +54 -3
  103. package/src/react/stream-preview/transport.ts +4 -8
  104. package/src/session.ts +206 -52
  105. package/src/transport/auto.ts +5 -0
  106. package/src/transport/dispatch.ts +7 -2
  107. package/src/transport/local-socket.ts +30 -1
  108. package/src/transport/types.ts +4 -1
  109. package/src/ui/index.ts +7 -4
@@ -30,6 +30,7 @@
30
30
  import { EventEmitter } from "eventemitter3";
31
31
  import { makeRequestId } from "../envelope";
32
32
  import { MiniappRequestType, MiniappStreamType } from "../protocol";
33
+ import { resolveSpeechProcessing } from "./speechProcessing";
33
34
  // ---------------------------------------------------------------------------
34
35
  // Registry
35
36
  // ---------------------------------------------------------------------------
@@ -43,8 +44,6 @@ export class EventManager {
43
44
  this.emitter = new EventEmitter();
44
45
  /** Stream -> ref count. Outbound SUBSCRIBE tracks active streams and routing changes. */
45
46
  this.refCounts = new Map();
46
- /** Transcription stream -> refs that require on-device-only processing. */
47
- this.forceLocalRefCounts = new Map();
48
47
  }
49
48
  /**
50
49
  * Generic subscribe. `stream` is the raw wire value, including any language
@@ -57,21 +56,25 @@ export class EventManager {
57
56
  * the outbound SUBSCRIBE list. Native already knows to deliver UI envelopes
58
57
  * via a separate envelope `type`; the EventManager only routes them
59
58
  * locally.
59
+ *
60
+ * `processing` applies to transcription streams only.
60
61
  */
61
62
  subscribe(stream, handler, options = {}) {
62
63
  const isInternal = stream.startsWith("_");
63
- const forceLocal = options.forceLocal === true && stream.startsWith(`${MiniappStreamType.TRANSCRIPTION}:`);
64
64
  const isTranscription = stream.startsWith(`${MiniappStreamType.TRANSCRIPTION}:`);
65
+ const processing = isTranscription ? resolveSpeechProcessing(options, "events.subscribe(options)") : "preferCloud";
66
+ const localOnly = processing === "localOnly";
65
67
  const listenerId = isTranscription ? `${this.listenerScope}:${++this.listenerSeq}` : undefined;
66
68
  let active = true;
67
69
  const listener = (data, route) => {
68
70
  if (!active)
69
71
  return;
70
- if (stream.startsWith(`${MiniappStreamType.TRANSCRIPTION}:`)) {
72
+ if (isTranscription) {
73
+ // The host tags every transcription event with the class it is for.
71
74
  // Hosts that predate routed transcription events omit `route`. Treat
72
- // those events as the default/cloud path so a forceLocal listener can
73
- // never accidentally receive cloud text.
74
- if (forceLocal ? route !== "forceLocal" && route !== "all" : route === "forceLocal")
75
+ // those events as the cloud path so a localOnly listener can never
76
+ // accidentally receive cloud text.
77
+ if (localOnly ? route !== "forceLocal" && route !== "all" : route === "forceLocal")
75
78
  return;
76
79
  }
77
80
  handler(data);
@@ -82,20 +85,13 @@ export class EventManager {
82
85
  };
83
86
  this.retireListeners.add(retire);
84
87
  if (listenerId)
85
- this.transcriptionListeners.set(listenerId, { stream, forceLocal, invoke: listener });
88
+ this.transcriptionListeners.set(listenerId, { stream, processing, invoke: listener });
86
89
  if (!isInternal) {
87
90
  const before = this.refCounts.get(stream) ?? 0;
88
91
  this.refCounts.set(stream, before + 1);
89
- const forceLocalBefore = this.forceLocalRefCounts.get(stream) ?? 0;
90
- const defaultBefore = before - forceLocalBefore;
91
- if (forceLocal)
92
- this.forceLocalRefCounts.set(stream, forceLocalBefore + 1);
93
- if (isTranscription ||
94
- before === 0 ||
95
- (forceLocal && forceLocalBefore === 0) ||
96
- (!forceLocal && defaultBefore === 0)) {
92
+ // Every transcription listener is registered with the host by id.
93
+ if (isTranscription || before === 0)
97
94
  this.sendSubscriptionUpdate();
98
- }
99
95
  }
100
96
  return () => {
101
97
  if (!active)
@@ -108,27 +104,13 @@ export class EventManager {
108
104
  if (isInternal)
109
105
  return;
110
106
  const current = this.refCounts.get(stream) ?? 0;
111
- const forceLocalCurrent = this.forceLocalRefCounts.get(stream) ?? 0;
112
- let subscriptionChanged = current <= 1;
113
107
  if (current <= 1) {
114
108
  this.refCounts.delete(stream);
115
109
  }
116
110
  else {
117
111
  this.refCounts.set(stream, current - 1);
118
112
  }
119
- if (forceLocal) {
120
- if (forceLocalCurrent <= 1) {
121
- this.forceLocalRefCounts.delete(stream);
122
- subscriptionChanged = true;
123
- }
124
- else {
125
- this.forceLocalRefCounts.set(stream, forceLocalCurrent - 1);
126
- }
127
- }
128
- else if (current - forceLocalCurrent <= 1) {
129
- subscriptionChanged = true;
130
- }
131
- if (isTranscription || subscriptionChanged)
113
+ if (isTranscription || current <= 1)
132
114
  this.sendSubscriptionUpdate();
133
115
  };
134
116
  }
@@ -140,7 +122,6 @@ export class EventManager {
140
122
  this.transcriptionListeners.clear();
141
123
  this.emitter.removeAllListeners();
142
124
  this.refCounts.clear();
143
- this.forceLocalRefCounts.clear();
144
125
  this.sendSubscriptionUpdate();
145
126
  }
146
127
  // -------------------------------------------------------------------------
@@ -148,6 +129,8 @@ export class EventManager {
148
129
  // -------------------------------------------------------------------------
149
130
  /** @internal */
150
131
  _forwardEvent(stream, data, transcriptionRoute, listenerId) {
132
+ if (stream.startsWith(`${MiniappStreamType.TRANSCRIPTION}:`))
133
+ data = withTranscriptionSource(data);
151
134
  if (listenerId !== undefined) {
152
135
  const listener = this.transcriptionListeners.get(listenerId);
153
136
  if (listener && (listener.stream === stream || listener.stream === "transcription:auto"))
@@ -181,28 +164,51 @@ export class EventManager {
181
164
  }
182
165
  }
183
166
  sendSubscriptionUpdate() {
184
- const subscriptions = Array.from(this.refCounts.keys()).map((stream) => {
167
+ const subscriptions = [];
168
+ for (const stream of this.refCounts.keys()) {
185
169
  if (stream === MiniappStreamType.LOCATION_UPDATE)
186
- return { stream: "location_stream", rate: "realtime" };
187
- const forceLocalRefs = this.forceLocalRefCounts.get(stream) ?? 0;
188
- if (forceLocalRefs === 0)
189
- return stream;
190
- const totalRefs = this.refCounts.get(stream) ?? 0;
191
- return {
192
- stream,
193
- forceLocal: true,
194
- ...(totalRefs > forceLocalRefs ? { includeCloud: true } : {}),
195
- };
196
- });
170
+ subscriptions.push({ stream: "location_stream", rate: "realtime" });
171
+ else if (!stream.startsWith(`${MiniappStreamType.TRANSCRIPTION}:`))
172
+ subscriptions.push(stream);
173
+ }
174
+ // One entry per transcription stream and processing its listeners ask for.
175
+ const transcription = new Set();
176
+ for (const { stream, processing } of this.transcriptionListeners.values()) {
177
+ const key = `${processing} ${stream}`;
178
+ if (transcription.has(key))
179
+ continue;
180
+ transcription.add(key);
181
+ subscriptions.push({ stream, ...processingOnWire(processing) });
182
+ }
197
183
  this.session.sendOneShot({
198
184
  type: MiniappRequestType.SUBSCRIBE,
199
185
  subscriptions,
200
- transcriptionListeners: [...this.transcriptionListeners].map(([id, { stream, forceLocal }]) => ({
186
+ transcriptionListeners: [...this.transcriptionListeners].map(([id, { stream, processing }]) => ({
201
187
  id,
202
188
  stream,
203
- forceLocal,
189
+ ...processingOnWire(processing),
204
190
  })),
205
191
  });
206
192
  }
207
193
  }
194
+ /**
195
+ * The wire form of a transcription listener's processing. Hosts before
196
+ * `processing` (Mentra App 3.4.0) read only `forceLocal`, so `localOnly` keeps
197
+ * sending it: there a localOnly listener still never gets cloud text.
198
+ */
199
+ function processingOnWire(processing) {
200
+ return processing === "localOnly" ? { processing, forceLocal: true } : { processing };
201
+ }
202
+ /**
203
+ * Hosts before `source` (Mentra App 3.4.0) leave it out. Their on-device
204
+ * transcripts carry `type: "local_transcription"`, their cloud ones do not.
205
+ */
206
+ function withTranscriptionSource(data) {
207
+ if (typeof data !== "object" || data === null)
208
+ return data;
209
+ const event = data;
210
+ if (event.source === "cloud" || event.source === "local")
211
+ return data;
212
+ return { ...event, source: event.type === "local_transcription" ? "local" : "cloud" };
213
+ }
208
214
  //# sourceMappingURL=events.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/modules/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAC,YAAY,EAAC,MAAM,eAAe,CAAA;AAE1C,OAAO,EAAC,aAAa,EAAC,MAAM,aAAa,CAAA;AACzC,OAAO,EAAC,kBAAkB,EAAE,iBAAiB,EAAC,MAAM,aAAa,CAAA;AAqIjE,8EAA8E;AAC9E,WAAW;AACX,8EAA8E;AAE9E,MAAM,OAAO,YAAY;IAcvB,YAA6B,OAAuB;QAAvB,YAAO,GAAP,OAAO,CAAgB;QAbnC,kBAAa,GAAG,aAAa,EAAE,CAAA;QACxC,gBAAW,GAAG,CAAC,CAAA;QACf,2BAAsB,GAAG,IAAI,GAAG,EAGrC,CAAA;QACK,oBAAe,GAAG,IAAI,GAAG,EAAc,CAAA;QAC9B,YAAO,GAAG,IAAI,YAAY,EAAE,CAAA;QAC7C,yFAAyF;QACxE,cAAS,GAAG,IAAI,GAAG,EAAkB,CAAA;QACtD,2EAA2E;QAC1D,wBAAmB,GAAG,IAAI,GAAG,EAAkB,CAAA;IAET,CAAC;IAExD;;;;;;;;;;;OAWG;IACH,SAAS,CAAC,MAAc,EAAE,OAAgC,EAAE,UAAkC,EAAE;QAC9F,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;QACzC,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,KAAK,IAAI,IAAI,MAAM,CAAC,UAAU,CAAC,GAAG,iBAAiB,CAAC,aAAa,GAAG,CAAC,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E,EAAC,MAAM,EAAE,UAAU,EAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBAC5F,EAAE;gBACF,MAAM;gBACN,GAAG,gBAAgB,CAAC,UAAU,CAAC;aAChC,CAAC,CAAC;SACJ,CAAC,CAAA;IACJ,CAAC;CACF;AAED;;;;GAIG;AACH,SAAS,gBAAgB,CAAC,UAA4B;IACpD,OAAO,UAAU,KAAK,WAAW,CAAC,CAAC,CAAC,EAAC,UAAU,EAAE,UAAU,EAAE,IAAI,EAAC,CAAC,CAAC,CAAC,EAAC,UAAU,EAAC,CAAA;AACnF,CAAC;AAED;;;GAGG;AACH,SAAS,uBAAuB,CAAC,IAAa;IAC5C,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,IAAI,CAAA;IAC1D,MAAM,KAAK,GAAG,IAA0C,CAAA;IACxD,IAAI,KAAK,CAAC,MAAM,KAAK,OAAO,IAAI,KAAK,CAAC,MAAM,KAAK,OAAO;QAAE,OAAO,IAAI,CAAA;IACrE,OAAO,EAAC,GAAG,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,IAAI,KAAK,qBAAqB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,EAAC,CAAA;AACrF,CAAC"}
@@ -25,20 +25,42 @@ export interface MicLease {
25
25
  readonly sessionId: number;
26
26
  release(): Promise<void>;
27
27
  }
28
+ /**
29
+ * On-device wake-word ("Hey Mentra") event. It describes only the wake-word
30
+ * model: `loading` while the phone loads it, `ready` once it is listening,
31
+ * `detected` for each detection, and `error` when it cannot run (`message`
32
+ * says why). The state of the on-device speech-to-text model is reported
33
+ * separately by `session.transcription.onModelStatus`.
34
+ */
35
+ export interface WakeWordEvent {
36
+ kind: "loading" | "ready" | "detected" | "error";
37
+ /** The phrase this event is about. Currently always "Hey Mentra". */
38
+ phrase: string;
39
+ /** Unix epoch milliseconds. */
40
+ timestamp: number;
41
+ message?: string;
42
+ }
28
43
  export declare class MicModule {
29
44
  private readonly session;
30
45
  /** All active unsubscribe functions for stop() to tear down at once. */
31
46
  private readonly unsubs;
32
47
  constructor(session: MiniappSession);
33
48
  /**
34
- * Subscribe to voice activity detection (VAD) events. `data.status` is
35
- * `true` while the user is speaking, `false` when silent.
49
+ * Subscribe to on-device voice activity detection. One event when the user
50
+ * starts speaking (`status: true`) and one when they stop (`status: false`,
51
+ * with `silentForMs` saying how long the audio has already been quiet). A
52
+ * gap in microphone audio counts as silence. Requires MICROPHONE permission.
36
53
  */
37
54
  onVoiceActivity(handler: (data: VadData) => void): UnsubscribeFn;
38
55
  /**
39
- * Subscribe to raw audio chunks. Format depends on the phone's mic mode
40
- * (PCM or LC3, base64-encoded).
56
+ * Subscribe to the on-device "Hey Mentra" wake word. Every subscribed
57
+ * miniapp receives every detection. You get the detector's current state
58
+ * right away, then every change. The phone loads the wake-word model while
59
+ * any miniapp subscribes and downloads it on first use. Requires MICROPHONE
60
+ * permission.
41
61
  */
62
+ onWakeWord(handler: (event: WakeWordEvent) => void): UnsubscribeFn;
63
+ /** Subscribe to raw audio chunks in the phone's PCM/LC3 microphone format. */
42
64
  onAudioChunk(handler: (data: AudioChunkData) => void): UnsubscribeFn;
43
65
  /**
44
66
  * Request glasses-side voice activity detection (GX8002) for this miniapp's
@@ -1 +1 @@
1
- {"version":3,"file":"mic.d.ts","sourceRoot":"","sources":["../../src/modules/mic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAA;AACzC,OAAO,KAAK,EAAC,cAAc,EAAE,aAAa,EAAE,OAAO,EAAC,MAAM,UAAU,CAAA;AAEpE,kDAAkD;AAClD,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,OAAO,CAAA;AAElD,kFAAkF;AAClF,MAAM,MAAM,iBAAiB,GAAG,YAAY,GAAG,eAAe,GAAG,iBAAiB,GAAG,YAAY,CAAA;AAEjG,kEAAkE;AAClE,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;;;;OAIG;IACH,IAAI,IAAI,IAAI;IAWZ,mEAAmE;IACnE,IAAI,aAAa,IAAI,OAAO,CAE3B;IAID,OAAO,CAAC,KAAK;CAOd"}
@@ -22,16 +22,25 @@ export class MicModule {
22
22
  this.unsubs = new Set();
23
23
  }
24
24
  /**
25
- * Subscribe to voice activity detection (VAD) events. `data.status` is
26
- * `true` while the user is speaking, `false` when silent.
25
+ * Subscribe to on-device voice activity detection. One event when the user
26
+ * starts speaking (`status: true`) and one when they stop (`status: false`,
27
+ * with `silentForMs` saying how long the audio has already been quiet). A
28
+ * gap in microphone audio counts as silence. Requires MICROPHONE permission.
27
29
  */
28
30
  onVoiceActivity(handler) {
29
31
  return this.track(this.session._subscribe(MiniappStreamType.VAD, handler));
30
32
  }
31
33
  /**
32
- * Subscribe to raw audio chunks. Format depends on the phone's mic mode
33
- * (PCM or LC3, base64-encoded).
34
+ * Subscribe to the on-device "Hey Mentra" wake word. Every subscribed
35
+ * miniapp receives every detection. You get the detector's current state
36
+ * right away, then every change. The phone loads the wake-word model while
37
+ * any miniapp subscribes and downloads it on first use. Requires MICROPHONE
38
+ * permission.
34
39
  */
40
+ onWakeWord(handler) {
41
+ return this.track(this.session._subscribe(MiniappStreamType.WAKE_WORD, handler));
42
+ }
43
+ /** Subscribe to raw audio chunks in the phone's PCM/LC3 microphone format. */
35
44
  onAudioChunk(handler) {
36
45
  return this.track(this.session._subscribe(MiniappStreamType.AUDIO_CHUNK, handler));
37
46
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mic.js","sourceRoot":"","sources":["../../src/modules/mic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAC,kBAAkB,EAAE,iBAAiB,EAAC,MAAM,aAAa,CAAA;AAgBjE,MAAM,OAAO,SAAS;IAIpB,YAA6B,OAAuB;QAAvB,YAAO,GAAP,OAAO,CAAgB;QAHpD,wEAAwE;QACvD,WAAM,GAAG,IAAI,GAAG,EAAiB,CAAA;I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CAAC,CAAA;QACxF,CAAC;QACD,MAAM,EAAC,SAAS,EAAC,GAAG,MAAM,CAAA;QAC1B,IAAI,QAAQ,GAAG,KAAK,CAAA;QACpB,OAAO;YACL,SAAS;YACT,OAAO,EAAE,KAAK,IAAI,EAAE;gBAClB,IAAI,QAAQ;oBAAE,OAAM;gBACpB,QAAQ,GAAG,IAAI,CAAA;gBACf,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,CAAO;oBACnC,IAAI,EAAE,kBAAkB,CAAC,WAAW;oBACpC,SAAS;iBACV,CAAC,CAAA;YACJ,CAAC;SACF,CAAA;IACH,CAAC;IAED;;;;OAIG;IACH,IAAI;QACF,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAC5B,IAAI,CAAC;gBACH,CAAC,EAAE,CAAA;YACL,CAAC;YAAC,MAAM,CAAC;gBACP,YAAY;YACd,CAAC;QACH,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAA;IACrB,CAAC;IAED,mEAAmE;IACnE,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,YAAY,CAAC,CAAA;IAC1D,CAAC;IAED,2EAA2E;IAEnE,KAAK,CAAC,KAAoB;QAChC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QACtB,OAAO,GAAG,EAAE;YACV,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;YACzB,KAAK,EAAE,CAAA;QACT,CAAC,CAAA;IACH,CAAC;CACF"}
@@ -7,10 +7,12 @@
7
7
  * layer (invoke / handle) lives on `session.actions`, not here — these are
8
8
  * operations on the app as a whole, not on a declared action.
9
9
  *
10
- * Installation (`install`, `checkInstallCompatibility`, `uninstall`) is
11
- * narrower still: the host accepts it only from a Store miniapp bundled with
12
- * the Mentra App build. The host downloads, verifies, and activates the
13
- * release through its own installer; the Store only selects the release.
10
+ * Installing (`install`, `checkInstallCompatibility`, `uninstall`) is
11
+ * narrower still: only a miniapp on the Mentra App's system list, running the
12
+ * release the Mentra App installed for it, may install miniapps. Development
13
+ * builds, which may use the calls above, may not. The host installs from a
14
+ * miniapp URL through the same installer as every other way in, with no install
15
+ * sheet: the caller asks the person first.
14
16
  */
15
17
  import { MiniappSession } from "../session";
16
18
  /** A declared action surfaced by {@link MiniappsModule.list}. */
@@ -56,10 +58,6 @@ export interface MiniappInfo {
56
58
  compatibility: MiniappCompatibility;
57
59
  /** True when this package identity is backed by a ZIP in the Mentra App build. */
58
60
  system: boolean;
59
- /** Store package that owns updates of this active release, when it is Store-managed. */
60
- storeOwnerPackageName?: string;
61
- /** Store the host build assigns to update this bundled package's active release, if any. */
62
- systemStoreOwnerPackageName?: string;
63
61
  /** Declared actions (empty if the miniapp declares none). */
64
62
  actions: MiniappActionInfo[];
65
63
  }
@@ -72,47 +70,41 @@ export interface MiniappHardwareRequirement {
72
70
  level: string;
73
71
  description?: string;
74
72
  }
75
- /** Backend-neutral release request, accepted only from a bundled, host-trusted Store. */
73
+ /** A miniapp to install. */
76
74
  export interface InstallMiniappRequest {
77
- packageName: string;
78
- version: string;
79
- bundleUrl: string;
80
- /** SHA-256 of the release ZIP; the host refuses any other bytes. */
81
- bundleSha256: string;
82
- /**
83
- * Bearer for `bundleUrl`, when the Store's backend requires one. The host
84
- * forwards it untouched and keeps no Store address of its own: entitlement is
85
- * settled between this miniapp and its backend, integrity by the SHA-256 and
86
- * the bundle's publisher signature.
87
- */
88
- bundleAuthorization?: string;
75
+ /** The miniapp's URL: the HTTPS address that serves its `miniapp.json`. */
76
+ url: string;
89
77
  /**
90
- * Automatic update: never stop a running miniapp. A running or starting
91
- * target defers the request with `APP_RUNNING`.
78
+ * The package the person agreed to install. When given, a URL that serves another package installs nothing and
79
+ * fails with `not_a_miniapp`.
92
80
  */
93
- onlyIfStopped?: boolean;
94
- /**
95
- * With `onlyIfStopped`: when the target is running, the host stages the
96
- * release and asks the user whether to update now. Declining, or a prompt the
97
- * host does not show (the Mentra App is in the background, another prompt is
98
- * open, or this miniapp was asked within the last day), still answers
99
- * `APP_RUNNING`.
100
- */
101
- askIfRunning?: boolean;
102
- /** Minimum Mentra App version declared by the release manifest. */
103
- minHostVersion?: string;
104
- /** Mentra Miniapp SDK version declared by the release manifest. */
105
- sdkVersion?: string;
106
- /** Glasses hardware requirements declared by the release manifest. */
107
- hardwareRequirements?: MiniappHardwareRequirement[];
108
- releaseId?: string;
109
- channel?: string;
81
+ packageName?: string;
110
82
  }
111
83
  export interface InstallMiniappResult {
84
+ /**
85
+ * `installed`: this release installed. `opened`: nothing installed, because the miniapp is installed from this URL
86
+ * already, or a newer release of it is; {@link MiniappsModule.open} it to show it. `deferred`: the miniapp is
87
+ * running, so its update waits until it stops, or until the person answers the Mentra App's update prompt.
88
+ */
89
+ status: "installed" | "opened" | "deferred";
112
90
  packageName: string;
91
+ /** The installed version: the new release, or the one that stays. */
113
92
  version: string;
114
- installedByStore: string;
115
93
  }
94
+ /**
95
+ * Why an install failed: the `reason` of an `INSTALL_FAILED` rejection from {@link MiniappsModule.install}.
96
+ * - `not_a_miniapp`: the URL serves no valid `miniapp.json` or bundle.
97
+ * - `domain_mismatch`: the package name doesn't belong to the URL's domain.
98
+ * - `archived`: Mentra archived this URL; it doesn't install.
99
+ * - `needs_newer_app`: the miniapp needs a newer Mentra App, or hardware the glasses lack.
100
+ * - `access_denied`: its server refused this account, or this deployment doesn't allow installing from a URL.
101
+ * - `age_restricted`: the person's declared age is below the miniapp's age rating.
102
+ * - `network`: the URL couldn't be reached.
103
+ * - `cancelled`: the Mentra App signed out or switched deployments meanwhile.
104
+ * - `integrity`: the bundle doesn't match what `miniapp.json` names.
105
+ * - `signature_invalid`: the bundle's signature doesn't match the installed miniapp's publisher.
106
+ */
107
+ export type InstallMiniappFailureReason = "not_a_miniapp" | "domain_mismatch" | "archived" | "needs_newer_app" | "access_denied" | "age_restricted" | "network" | "cancelled" | "integrity" | "signature_invalid";
116
108
  export interface InstallMiniappCompatibilityRequest {
117
109
  minHostVersion?: string | null;
118
110
  sdkVersion?: string | null;
@@ -125,15 +117,8 @@ export type InstallMiniappCompatibility = {
125
117
  blocker: "host" | "sdk" | "hardware";
126
118
  reason: string;
127
119
  };
128
- export type InstallMiniappPhase = "downloading" | "verifying" | "extracting" | "activating" | "complete";
129
- export interface InstallMiniappProgress {
130
- packageName: string;
131
- version: string;
132
- phase: InstallMiniappPhase;
133
- }
134
120
  export declare class MiniappsModule {
135
121
  private readonly session;
136
- private readonly progressHandlers;
137
122
  constructor(session: MiniappSession);
138
123
  /**
139
124
  * List installed miniapps. Compatible-only by default; pass
@@ -154,18 +139,20 @@ export declare class MiniappsModule {
154
139
  /** Stop another miniapp. SYSTEM-only. */
155
140
  stop(packageName: string): Promise<void>;
156
141
  /**
157
- * Download, verify, and install a release through the phone host. Accepted
158
- * only from a Store bundled with the Mentra App build; other callers receive
159
- * NOT_PERMITTED.
142
+ * Install the miniapp at a miniapp URL, with no install sheet: ask the person first. The host fetches its
143
+ * `miniapp.json`, checks the package name against the URL's domain, registers the URL with Mentra, checks the
144
+ * phone can run it, and downloads, verifies and installs its bundle.
145
+ *
146
+ * Only a miniapp on the Mentra App's system list may install; any other caller gets NOT_PERMITTED. A failed
147
+ * install rejects with INSTALL_FAILED, whose `reason` is an {@link InstallMiniappFailureReason}.
160
148
  */
161
149
  install(request: InstallMiniappRequest): Promise<InstallMiniappResult>;
162
- /** Check host, Mentra Miniapp SDK, and glasses compatibility before offering or applying an update. */
150
+ /** Check a release's Mentra App, SDK and glasses requirements against this phone. System-list miniapps only. */
163
151
  checkInstallCompatibility(request: InstallMiniappCompatibilityRequest): Promise<InstallMiniappCompatibility>;
164
- /** Subscribe to host-owned install progress. Returns an unsubscribe function. */
165
- onInstallProgress(handler: (progress: InstallMiniappProgress) => void): () => void;
166
- /** @internal */
167
- _deliverInstallProgress(progress: InstallMiniappProgress): void;
168
- /** Uninstall a package this Store installed. Bundled Stores only. */
152
+ /**
153
+ * Uninstall a miniapp installed from a miniapp URL. A miniapp the Mentra App bundles, one a workspace manages and a
154
+ * development build stay, with NOT_PERMITTED. System-list miniapps only.
155
+ */
169
156
  uninstall(packageName: string): Promise<void>;
170
157
  }
171
158
  //# sourceMappingURL=miniapps.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"miniapps.d.ts","sourceRoot":"","sources":["../../src/modules/miniapps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAA;AAEzC,iEAAiE;AACjE,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAA;IACV,WAAW,EAAE,MAAM,CAAA;IACnB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACpC,8EAA8E;IAC9E,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACtC;;;OAGG;IACH,SAAS,EAAE,YAAY,GAAG,WAAW,CAAA;CACtC;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,YAAY,EAAE,OAAO,CAAA;IACrB,eAAe,EAAE,KAAK,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAC,CAAC,CAAA;IACtD,eAAe,EAAE,KAAK,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAC,CAAC,CAAA;IACtD,QAAQ,EAAE,MAAM,EAAE,CAAA;CACnB;AAED,6DAA6D;AAC7D,MAAM,WAAW,WAAW;IAC1B,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,OAAO,CAAA;IAChB,aAAa,EAAE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AQ,CAAC,OAAO;gBAAP,OAAO,EAAE,cAAc;IAEpD;;;;OAIG;IACG,IAAI,CAAC,IAAI,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAQ9D;;;;;;OAMG;IACG,KAAK,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAO/C,sEAAsE;IAChE,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ9C,yCAAyC;IACnC,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAO9C;;;;;;;OAOG;IACG,OAAO,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAa5E,gHAAgH;IAC1G,yBAAyB,CAAC,OAAO,EAAE,kCAAkC,GAAG,OAAO,CAAC,2BAA2B,CAAC;IASlH;;;OAGG;IACG,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAMpD"}
@@ -7,16 +7,17 @@
7
7
  * layer (invoke / handle) lives on `session.actions`, not here — these are
8
8
  * operations on the app as a whole, not on a declared action.
9
9
  *
10
- * Installation (`install`, `checkInstallCompatibility`, `uninstall`) is
11
- * narrower still: the host accepts it only from a Store miniapp bundled with
12
- * the Mentra App build. The host downloads, verifies, and activates the
13
- * release through its own installer; the Store only selects the release.
10
+ * Installing (`install`, `checkInstallCompatibility`, `uninstall`) is
11
+ * narrower still: only a miniapp on the Mentra App's system list, running the
12
+ * release the Mentra App installed for it, may install miniapps. Development
13
+ * builds, which may use the calls above, may not. The host installs from a
14
+ * miniapp URL through the same installer as every other way in, with no install
15
+ * sheet: the caller asks the person first.
14
16
  */
15
17
  import { MiniappRequestType } from "../protocol";
16
18
  export class MiniappsModule {
17
19
  constructor(session) {
18
20
  this.session = session;
19
- this.progressHandlers = new Set();
20
21
  }
21
22
  /**
22
23
  * List installed miniapps. Compatible-only by default; pass
@@ -59,21 +60,24 @@ export class MiniappsModule {
59
60
  });
60
61
  }
61
62
  /**
62
- * Download, verify, and install a release through the phone host. Accepted
63
- * only from a Store bundled with the Mentra App build; other callers receive
64
- * NOT_PERMITTED.
63
+ * Install the miniapp at a miniapp URL, with no install sheet: ask the person first. The host fetches its
64
+ * `miniapp.json`, checks the package name against the URL's domain, registers the URL with Mentra, checks the
65
+ * phone can run it, and downloads, verifies and installs its bundle.
66
+ *
67
+ * Only a miniapp on the Mentra App's system list may install; any other caller gets NOT_PERMITTED. A failed
68
+ * install rejects with INSTALL_FAILED, whose `reason` is an {@link InstallMiniappFailureReason}.
65
69
  */
66
70
  async install(request) {
67
71
  return this.session.sendRequest({
68
- ...request,
69
72
  type: MiniappRequestType.MINIAPPS_INSTALL,
73
+ url: request.url,
74
+ ...(request.packageName !== undefined ? { packageName: request.packageName } : {}),
70
75
  },
71
- // Downloading, validating, extracting, asking the user and relaunching
72
- // can legitimately outlast the SDK's default request timeout. The request
73
- // still settles on the host response or session disconnect.
76
+ // Fetching, registering, downloading and installing can legitimately outlast the SDK's default request
77
+ // timeout. The request still settles on the host response or session disconnect.
74
78
  { timeoutMs: 0 });
75
79
  }
76
- /** Check host, Mentra Miniapp SDK, and glasses compatibility before offering or applying an update. */
80
+ /** Check a release's Mentra App, SDK and glasses requirements against this phone. System-list miniapps only. */
77
81
  async checkInstallCompatibility(request) {
78
82
  return this.session.sendRequest({
79
83
  type: MiniappRequestType.MINIAPPS_INSTALL_CHECK,
@@ -82,17 +86,10 @@ export class MiniappsModule {
82
86
  hardwareRequirements: request.hardwareRequirements ?? [],
83
87
  });
84
88
  }
85
- /** Subscribe to host-owned install progress. Returns an unsubscribe function. */
86
- onInstallProgress(handler) {
87
- this.progressHandlers.add(handler);
88
- return () => this.progressHandlers.delete(handler);
89
- }
90
- /** @internal */
91
- _deliverInstallProgress(progress) {
92
- for (const handler of this.progressHandlers)
93
- handler(progress);
94
- }
95
- /** Uninstall a package this Store installed. Bundled Stores only. */
89
+ /**
90
+ * Uninstall a miniapp installed from a miniapp URL. A miniapp the Mentra App bundles, one a workspace manages and a
91
+ * development build stay, with NOT_PERMITTED. System-list miniapps only.
92
+ */
96
93
  async uninstall(packageName) {
97
94
  await this.session.sendRequest({
98
95
  type: MiniappRequestType.MINIAPPS_UNINSTALL,
@@ -1 +1 @@
1
- {"version":3,"file":"miniapps.js","sourceRoot":"","sources":["../../src/modules/miniapps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAC,kBAAkB,EAAC,MAAM,aAAa,CAAA;AA0H9C,MAAM,OAAO,cAAc;IAGzB,YAA6B,OAAuB;QAAvB,YAAO,GAAP,OAAO,CAAgB;QAFnC,qBAAgB,GAAG,IAAI,GAAG,EAA8C,CAAA;IAElC,CAAC;IAExD;;;;OAIG;IACH,KAAK,CAAC,IAAI,CAAC,IAA0B;QACnC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,CAAgB;YAC3D,IAAI,EAAE,kBAAkB,CAAC,aAAa;YACtC,mBAAmB,EAAE,IAAI,EAAE,mBAAmB,IAAI,KAAK;SACxD,CAAC,CAAA;QACF,OAAO,MAAM,IAAI,EAAE,CAAA;IACrB,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,KAAK,CAAC,WAAmB;QAC7B,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,CAAO;YACnC,IAAI,EAAE,kBAAkB,CAAC,cAAc;YACvC,WAAW;SACZ,CAAC,CAAA;IACJ,CAAC;IAED,sEAAsE;IACtE,KAAK,CAAC,IAAI,CAAC,WAAmB;QAC5B,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,CAAO;YACnC,IAAI,EAAE,kBAAkB,CAAC,cAAc;YACvC,WAAW;YACX,UAAU,EAAE,IAAI;SACjB,CAAC,CAAA;IACJ,CAAC;IAED,yCAAyC;IACzC,KAAK,CAAC,IAAI,CAAC,WAAmB;QAC5B,M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