@glassly/miniapp 0.1.0-dev.26

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 (312) hide show
  1. package/README.md +275 -0
  2. package/dist/background/index.d.ts +64 -0
  3. package/dist/background/index.d.ts.map +1 -0
  4. package/dist/background/index.js +26 -0
  5. package/dist/background/index.js.map +1 -0
  6. package/dist/background/register.d.ts +39 -0
  7. package/dist/background/register.d.ts.map +1 -0
  8. package/dist/background/register.js +72 -0
  9. package/dist/background/register.js.map +1 -0
  10. package/dist/dev-reload.d.ts +21 -0
  11. package/dist/dev-reload.d.ts.map +1 -0
  12. package/dist/dev-reload.js +60 -0
  13. package/dist/dev-reload.js.map +1 -0
  14. package/dist/envelope.d.ts +23 -0
  15. package/dist/envelope.d.ts.map +1 -0
  16. package/dist/envelope.js +47 -0
  17. package/dist/envelope.js.map +1 -0
  18. package/dist/globals.d.ts +54 -0
  19. package/dist/globals.d.ts.map +1 -0
  20. package/dist/globals.js +12 -0
  21. package/dist/globals.js.map +1 -0
  22. package/dist/hardware.d.ts +24 -0
  23. package/dist/hardware.d.ts.map +1 -0
  24. package/dist/hardware.js +20 -0
  25. package/dist/hardware.js.map +1 -0
  26. package/dist/index.d.ts +65 -0
  27. package/dist/index.d.ts.map +1 -0
  28. package/dist/index.js +34 -0
  29. package/dist/index.js.map +1 -0
  30. package/dist/modules/actions.d.ts +81 -0
  31. package/dist/modules/actions.d.ts.map +1 -0
  32. package/dist/modules/actions.js +137 -0
  33. package/dist/modules/actions.js.map +1 -0
  34. package/dist/modules/ai.d.ts +211 -0
  35. package/dist/modules/ai.d.ts.map +1 -0
  36. package/dist/modules/ai.js +117 -0
  37. package/dist/modules/ai.js.map +1 -0
  38. package/dist/modules/auth.d.ts +25 -0
  39. package/dist/modules/auth.d.ts.map +1 -0
  40. package/dist/modules/auth.js +52 -0
  41. package/dist/modules/auth.js.map +1 -0
  42. package/dist/modules/base64.d.ts +16 -0
  43. package/dist/modules/base64.d.ts.map +1 -0
  44. package/dist/modules/base64.js +92 -0
  45. package/dist/modules/base64.js.map +1 -0
  46. package/dist/modules/blob.d.ts +161 -0
  47. package/dist/modules/blob.d.ts.map +1 -0
  48. package/dist/modules/blob.js +277 -0
  49. package/dist/modules/blob.js.map +1 -0
  50. package/dist/modules/camera.d.ts +183 -0
  51. package/dist/modules/camera.d.ts.map +1 -0
  52. package/dist/modules/camera.js +119 -0
  53. package/dist/modules/camera.js.map +1 -0
  54. package/dist/modules/cloud.d.ts +34 -0
  55. package/dist/modules/cloud.d.ts.map +1 -0
  56. package/dist/modules/cloud.js +70 -0
  57. package/dist/modules/cloud.js.map +1 -0
  58. package/dist/modules/dashboard.d.ts +24 -0
  59. package/dist/modules/dashboard.d.ts.map +1 -0
  60. package/dist/modules/dashboard.js +39 -0
  61. package/dist/modules/dashboard.js.map +1 -0
  62. package/dist/modules/display.d.ts +174 -0
  63. package/dist/modules/display.d.ts.map +1 -0
  64. package/dist/modules/display.js +83 -0
  65. package/dist/modules/display.js.map +1 -0
  66. package/dist/modules/events.d.ts +178 -0
  67. package/dist/modules/events.d.ts.map +1 -0
  68. package/dist/modules/events.js +168 -0
  69. package/dist/modules/events.js.map +1 -0
  70. package/dist/modules/glasses.d.ts +36 -0
  71. package/dist/modules/glasses.d.ts.map +1 -0
  72. package/dist/modules/glasses.js +52 -0
  73. package/dist/modules/glasses.js.map +1 -0
  74. package/dist/modules/heading.d.ts +16 -0
  75. package/dist/modules/heading.d.ts.map +1 -0
  76. package/dist/modules/heading.js +20 -0
  77. package/dist/modules/heading.js.map +1 -0
  78. package/dist/modules/imu.d.ts +31 -0
  79. package/dist/modules/imu.d.ts.map +1 -0
  80. package/dist/modules/imu.js +40 -0
  81. package/dist/modules/imu.js.map +1 -0
  82. package/dist/modules/input.d.ts +50 -0
  83. package/dist/modules/input.d.ts.map +1 -0
  84. package/dist/modules/input.js +70 -0
  85. package/dist/modules/input.js.map +1 -0
  86. package/dist/modules/keys.d.ts +30 -0
  87. package/dist/modules/keys.d.ts.map +1 -0
  88. package/dist/modules/keys.js +37 -0
  89. package/dist/modules/keys.js.map +1 -0
  90. package/dist/modules/languages.d.ts +42 -0
  91. package/dist/modules/languages.d.ts.map +1 -0
  92. package/dist/modules/languages.js +57 -0
  93. package/dist/modules/languages.js.map +1 -0
  94. package/dist/modules/led.d.ts +35 -0
  95. package/dist/modules/led.d.ts.map +1 -0
  96. package/dist/modules/led.js +39 -0
  97. package/dist/modules/led.js.map +1 -0
  98. package/dist/modules/location.d.ts +27 -0
  99. package/dist/modules/location.d.ts.map +1 -0
  100. package/dist/modules/location.js +35 -0
  101. package/dist/modules/location.js.map +1 -0
  102. package/dist/modules/memory.d.ts +126 -0
  103. package/dist/modules/memory.d.ts.map +1 -0
  104. package/dist/modules/memory.js +141 -0
  105. package/dist/modules/memory.js.map +1 -0
  106. package/dist/modules/mic.d.ts +61 -0
  107. package/dist/modules/mic.d.ts.map +1 -0
  108. package/dist/modules/mic.js +94 -0
  109. package/dist/modules/mic.js.map +1 -0
  110. package/dist/modules/miniapps.d.ts +82 -0
  111. package/dist/modules/miniapps.d.ts.map +1 -0
  112. package/dist/modules/miniapps.js +58 -0
  113. package/dist/modules/miniapps.js.map +1 -0
  114. package/dist/modules/navigation.d.ts +332 -0
  115. package/dist/modules/navigation.d.ts.map +1 -0
  116. package/dist/modules/navigation.js +387 -0
  117. package/dist/modules/navigation.js.map +1 -0
  118. package/dist/modules/permissions.d.ts +58 -0
  119. package/dist/modules/permissions.d.ts.map +1 -0
  120. package/dist/modules/permissions.js +66 -0
  121. package/dist/modules/permissions.js.map +1 -0
  122. package/dist/modules/phone.d.ts +95 -0
  123. package/dist/modules/phone.d.ts.map +1 -0
  124. package/dist/modules/phone.js +110 -0
  125. package/dist/modules/phone.js.map +1 -0
  126. package/dist/modules/pivots/engine.d.ts +169 -0
  127. package/dist/modules/pivots/engine.d.ts.map +1 -0
  128. package/dist/modules/pivots/engine.js +778 -0
  129. package/dist/modules/pivots/engine.js.map +1 -0
  130. package/dist/modules/pivots/geometry.d.ts +84 -0
  131. package/dist/modules/pivots/geometry.d.ts.map +1 -0
  132. package/dist/modules/pivots/geometry.js +371 -0
  133. package/dist/modules/pivots/geometry.js.map +1 -0
  134. package/dist/modules/pivots/instructions.d.ts +139 -0
  135. package/dist/modules/pivots/instructions.d.ts.map +1 -0
  136. package/dist/modules/pivots/instructions.js +281 -0
  137. package/dist/modules/pivots/instructions.js.map +1 -0
  138. package/dist/modules/speaker.d.ts +175 -0
  139. package/dist/modules/speaker.d.ts.map +1 -0
  140. package/dist/modules/speaker.js +249 -0
  141. package/dist/modules/speaker.js.map +1 -0
  142. package/dist/modules/speakers.d.ts +29 -0
  143. package/dist/modules/speakers.d.ts.map +1 -0
  144. package/dist/modules/speakers.js +38 -0
  145. package/dist/modules/speakers.js.map +1 -0
  146. package/dist/modules/storage.d.ts +50 -0
  147. package/dist/modules/storage.d.ts.map +1 -0
  148. package/dist/modules/storage.js +99 -0
  149. package/dist/modules/storage.js.map +1 -0
  150. package/dist/modules/stream.d.ts +133 -0
  151. package/dist/modules/stream.d.ts.map +1 -0
  152. package/dist/modules/stream.js +53 -0
  153. package/dist/modules/stream.js.map +1 -0
  154. package/dist/modules/system.d.ts +71 -0
  155. package/dist/modules/system.d.ts.map +1 -0
  156. package/dist/modules/system.js +65 -0
  157. package/dist/modules/system.js.map +1 -0
  158. package/dist/modules/transcription.d.ts +99 -0
  159. package/dist/modules/transcription.d.ts.map +1 -0
  160. package/dist/modules/transcription.js +126 -0
  161. package/dist/modules/transcription.js.map +1 -0
  162. package/dist/modules/translation.d.ts +65 -0
  163. package/dist/modules/translation.d.ts.map +1 -0
  164. package/dist/modules/translation.js +121 -0
  165. package/dist/modules/translation.js.map +1 -0
  166. package/dist/modules/ui.d.ts +186 -0
  167. package/dist/modules/ui.d.ts.map +1 -0
  168. package/dist/modules/ui.js +289 -0
  169. package/dist/modules/ui.js.map +1 -0
  170. package/dist/protocol.d.ts +390 -0
  171. package/dist/protocol.d.ts.map +1 -0
  172. package/dist/protocol.js +419 -0
  173. package/dist/protocol.js.map +1 -0
  174. package/dist/react/MiniappHeader.d.ts +44 -0
  175. package/dist/react/MiniappHeader.d.ts.map +1 -0
  176. package/dist/react/MiniappHeader.js +32 -0
  177. package/dist/react/MiniappHeader.js.map +1 -0
  178. package/dist/react/MiniappProvider.d.ts +33 -0
  179. package/dist/react/MiniappProvider.d.ts.map +1 -0
  180. package/dist/react/MiniappProvider.js +15 -0
  181. package/dist/react/MiniappProvider.js.map +1 -0
  182. package/dist/react/capsuleHeaderLayout.d.ts +3 -0
  183. package/dist/react/capsuleHeaderLayout.d.ts.map +1 -0
  184. package/dist/react/capsuleHeaderLayout.js +5 -0
  185. package/dist/react/capsuleHeaderLayout.js.map +1 -0
  186. package/dist/react/index.d.ts +13 -0
  187. package/dist/react/index.d.ts.map +1 -0
  188. package/dist/react/index.js +9 -0
  189. package/dist/react/index.js.map +1 -0
  190. package/dist/react/useCapabilities.d.ts +26 -0
  191. package/dist/react/useCapabilities.d.ts.map +1 -0
  192. package/dist/react/useCapabilities.js +27 -0
  193. package/dist/react/useCapabilities.js.map +1 -0
  194. package/dist/react/useCapsuleHeaderStyle.d.ts +27 -0
  195. package/dist/react/useCapsuleHeaderStyle.d.ts.map +1 -0
  196. package/dist/react/useCapsuleHeaderStyle.js +39 -0
  197. package/dist/react/useCapsuleHeaderStyle.js.map +1 -0
  198. package/dist/react/useColorScheme.d.ts +18 -0
  199. package/dist/react/useColorScheme.d.ts.map +1 -0
  200. package/dist/react/useColorScheme.js +24 -0
  201. package/dist/react/useColorScheme.js.map +1 -0
  202. package/dist/react/useConnected.d.ts +17 -0
  203. package/dist/react/useConnected.d.ts.map +1 -0
  204. package/dist/react/useConnected.js +39 -0
  205. package/dist/react/useConnected.js.map +1 -0
  206. package/dist/react/useRpc.d.ts +29 -0
  207. package/dist/react/useRpc.d.ts.map +1 -0
  208. package/dist/react/useRpc.js +82 -0
  209. package/dist/react/useRpc.js.map +1 -0
  210. package/dist/react/useSafeArea.d.ts +21 -0
  211. package/dist/react/useSafeArea.d.ts.map +1 -0
  212. package/dist/react/useSafeArea.js +22 -0
  213. package/dist/react/useSafeArea.js.map +1 -0
  214. package/dist/session.d.ts +355 -0
  215. package/dist/session.d.ts.map +1 -0
  216. package/dist/session.js +688 -0
  217. package/dist/session.js.map +1 -0
  218. package/dist/sub-path-types.test-d.d.ts +40 -0
  219. package/dist/sub-path-types.test-d.d.ts.map +1 -0
  220. package/dist/sub-path-types.test-d.js +37 -0
  221. package/dist/sub-path-types.test-d.js.map +1 -0
  222. package/dist/transport/auto.d.ts +35 -0
  223. package/dist/transport/auto.d.ts.map +1 -0
  224. package/dist/transport/auto.js +124 -0
  225. package/dist/transport/auto.js.map +1 -0
  226. package/dist/transport/dispatch.d.ts +43 -0
  227. package/dist/transport/dispatch.d.ts.map +1 -0
  228. package/dist/transport/dispatch.js +91 -0
  229. package/dist/transport/dispatch.js.map +1 -0
  230. package/dist/transport/local-socket.d.ts +28 -0
  231. package/dist/transport/local-socket.d.ts.map +1 -0
  232. package/dist/transport/local-socket.js +80 -0
  233. package/dist/transport/local-socket.js.map +1 -0
  234. package/dist/transport/mock.d.ts +54 -0
  235. package/dist/transport/mock.d.ts.map +1 -0
  236. package/dist/transport/mock.js +210 -0
  237. package/dist/transport/mock.js.map +1 -0
  238. package/dist/transport/postmessage.d.ts +36 -0
  239. package/dist/transport/postmessage.d.ts.map +1 -0
  240. package/dist/transport/postmessage.js +78 -0
  241. package/dist/transport/postmessage.js.map +1 -0
  242. package/dist/transport/types.d.ts +25 -0
  243. package/dist/transport/types.d.ts.map +1 -0
  244. package/dist/transport/types.js +11 -0
  245. package/dist/transport/types.js.map +1 -0
  246. package/dist/ui/index.d.ts +107 -0
  247. package/dist/ui/index.d.ts.map +1 -0
  248. package/dist/ui/index.js +32 -0
  249. package/dist/ui/index.js.map +1 -0
  250. package/package.json +88 -0
  251. package/src/background/index.ts +177 -0
  252. package/src/background/register.ts +89 -0
  253. package/src/dev-reload.ts +59 -0
  254. package/src/envelope.ts +54 -0
  255. package/src/globals.ts +62 -0
  256. package/src/hardware.ts +25 -0
  257. package/src/index.ts +216 -0
  258. package/src/modules/actions.ts +189 -0
  259. package/src/modules/ai.ts +281 -0
  260. package/src/modules/auth.ts +68 -0
  261. package/src/modules/base64.ts +87 -0
  262. package/src/modules/blob.ts +341 -0
  263. package/src/modules/camera.ts +258 -0
  264. package/src/modules/cloud.ts +94 -0
  265. package/src/modules/dashboard.ts +51 -0
  266. package/src/modules/display.ts +214 -0
  267. package/src/modules/events.ts +318 -0
  268. package/src/modules/glasses.ts +58 -0
  269. package/src/modules/heading.ts +23 -0
  270. package/src/modules/imu.ts +44 -0
  271. package/src/modules/input.ts +87 -0
  272. package/src/modules/keys.ts +46 -0
  273. package/src/modules/languages.ts +72 -0
  274. package/src/modules/led.ts +61 -0
  275. package/src/modules/location.ts +39 -0
  276. package/src/modules/memory.ts +224 -0
  277. package/src/modules/mic.ts +103 -0
  278. package/src/modules/miniapps.ts +103 -0
  279. package/src/modules/navigation.ts +674 -0
  280. package/src/modules/permissions.ts +83 -0
  281. package/src/modules/phone.ts +155 -0
  282. package/src/modules/pivots/engine.ts +863 -0
  283. package/src/modules/pivots/geometry.ts +409 -0
  284. package/src/modules/pivots/instructions.ts +341 -0
  285. package/src/modules/speaker.ts +347 -0
  286. package/src/modules/speakers.ts +40 -0
  287. package/src/modules/storage.ts +109 -0
  288. package/src/modules/stream.ts +168 -0
  289. package/src/modules/system.ts +113 -0
  290. package/src/modules/transcription.ts +180 -0
  291. package/src/modules/translation.ts +156 -0
  292. package/src/modules/ui.ts +481 -0
  293. package/src/protocol.ts +482 -0
  294. package/src/react/MiniappHeader.tsx +114 -0
  295. package/src/react/MiniappProvider.tsx +50 -0
  296. package/src/react/capsuleHeaderLayout.ts +11 -0
  297. package/src/react/index.ts +12 -0
  298. package/src/react/useCapabilities.ts +29 -0
  299. package/src/react/useCapsuleHeaderStyle.ts +55 -0
  300. package/src/react/useColorScheme.ts +26 -0
  301. package/src/react/useConnected.ts +47 -0
  302. package/src/react/useRpc.ts +103 -0
  303. package/src/react/useSafeArea.ts +36 -0
  304. package/src/session.ts +969 -0
  305. package/src/sub-path-types.test-d.ts +60 -0
  306. package/src/transport/auto.ts +143 -0
  307. package/src/transport/dispatch.ts +106 -0
  308. package/src/transport/local-socket.ts +91 -0
  309. package/src/transport/mock.ts +255 -0
  310. package/src/transport/postmessage.ts +95 -0
  311. package/src/transport/types.ts +26 -0
  312. package/src/ui/index.ts +129 -0
@@ -0,0 +1,70 @@
1
+ /**
2
+ * @fileoverview InputModule — physical control events on the glasses.
3
+ *
4
+ * Combines button + touch surfaces. Future input modes (gesture, voice
5
+ * command, eye tracking) will extend this module rather than spawning new
6
+ * top-level modules.
7
+ *
8
+ * Touch overloads:
9
+ *
10
+ * session.input.onTouch(handler)
11
+ * session.input.onTouch("single_tap", handler)
12
+ * session.input.onTouch(["swipe_up", "swipe_down"], handler)
13
+ *
14
+ * Per-gesture filtering rides on `touch_event:<gesture>` stream variants
15
+ * the phone runtime fans out alongside the bare `touch_event` stream.
16
+ */
17
+ import { MiniappRequestType, MiniappStreamType } from "../protocol";
18
+ export class InputModule {
19
+ constructor(session) {
20
+ this.session = session;
21
+ }
22
+ /**
23
+ * Declare the gestures this miniapp is handling itself, replacing any
24
+ * previous claim set. While a claimed gesture arrives and this app is
25
+ * FOREGROUND on the glasses, the host skips its default behavior for it —
26
+ * today that is `double_tap`, which otherwise opens the dashboard (or
27
+ * toggles head-up). The events themselves still arrive via `onTouch`
28
+ * either way; claiming only suppresses the system default.
29
+ *
30
+ * Pass `[]` to release every claim. Claims are cleared automatically when
31
+ * the miniapp stops, and are inert while the app is backgrounded — a
32
+ * background app never hijacks a system gesture.
33
+ *
34
+ * session.input.setClaimedGestures(["double_tap"]) // in-app back gesture
35
+ * session.input.setClaimedGestures([]) // back to system default
36
+ */
37
+ setClaimedGestures(gestures) {
38
+ return this.session
39
+ .sendRequest({ type: MiniappRequestType.CLAIM_GESTURES, gestures })
40
+ .then(() => undefined);
41
+ }
42
+ onButtonPress(handler) {
43
+ return this.session._subscribe(MiniappStreamType.BUTTON_PRESS, handler);
44
+ }
45
+ onTouch(gestureOrHandler, maybeHandler) {
46
+ // Plain handler — subscribe to all touches.
47
+ if (typeof gestureOrHandler === "function") {
48
+ return this.session._subscribe(MiniappStreamType.TOUCH_EVENT, gestureOrHandler);
49
+ }
50
+ const handler = maybeHandler;
51
+ const gestures = Array.isArray(gestureOrHandler) ? gestureOrHandler : [gestureOrHandler];
52
+ if (gestures.length === 0)
53
+ return () => { };
54
+ const unsubs = [];
55
+ for (const g of gestures) {
56
+ unsubs.push(this.session._subscribe(`${MiniappStreamType.TOUCH_EVENT}:${g}`, handler));
57
+ }
58
+ return () => {
59
+ for (const u of unsubs) {
60
+ try {
61
+ u();
62
+ }
63
+ catch {
64
+ /* ignore */
65
+ }
66
+ }
67
+ };
68
+ }
69
+ }
70
+ //# sourceMappingURL=input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input.js","sourceRoot":"","sources":["../../src/modules/input.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAC,kBAAkB,EAAE,iBAAiB,EAAC,MAAM,aAAa,CAAA;AAIjE,MAAM,OAAO,WAAW;IACtB,YAA6B,OAAuB;QAAvB,YAAO,GAAP,OAAO,CAAgB;IAAG,CAAC;IAExD;;;;;;;;;;;;;;OAcG;IACH,kBAAkB,CAAC,QAAkB;QACnC,OAAO,IAAI,CAAC,OAAO;aAChB,WAAW,CAAO,EAAC,IAAI,EAAE,kBAAkB,CAAC,cAAc,EAAE,QAAQ,EAAC,CAAC;aACtE,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAA;IAC1B,CAAC;IAED,aAAa,CAAC,OAAwC;QACpD,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,iBAAiB,CAAC,YAAY,EAAE,OAAkC,CAAC,CAAA;IACpG,CAAC;IAYD,OAAO,CACL,gBAAiE,EACjE,YAAwC;QAExC,4CAA4C;QAC5C,IAAI,OAAO,gBAAgB,KAAK,UAAU,EAAE,CAAC;YAC3C,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,iBAAiB,CAAC,WAAW,EAAE,gBAA2C,CAAC,CAAA;QAC5G,CAAC;QAED,MAAM,OAAO,GAAG,YAAa,CAAA;QAC7B,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAA;QACxF,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,GAAG,EAAE,GAAE,CAAC,CAAA;QAE1C,MAAM,MAAM,GAAoB,EAAE,CAAA;QAClC,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;YACzB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,iBAAiB,CAAC,WAAW,IAAI,CAAC,EAAE,EAAE,OAAkC,CAAC,CAAC,CAAA;QACnH,CAAC;QACD,OAAO,GAAG,EAAE;YACV,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;gBACvB,IAAI,CAAC;oBACH,CAAC,EAAE,CAAA;gBACL,CAAC;gBAAC,MAAM,CAAC;oBACP,YAAY;gBACd,CAAC;YACH,CAAC;QACH,CAAC,CAAA;IACH,CAAC;CACF"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @fileoverview KeysModule — read user-supplied provider API keys.
3
+ *
4
+ * Users can enter their own provider API keys in the Glassly App
5
+ * (Settings > API Keys). A miniapp that declares the API_KEYS permission in
6
+ * miniapp.json can read the providers in {@link ApiKeyProvider}; the phone
7
+ * runtime rejects with PERMISSION_NOT_DECLARED otherwise.
8
+ *
9
+ * The provider set is an explicit host-side allowlist — asking for anything
10
+ * else (e.g. the Soniox transcription key, which is deliberately not exposed
11
+ * to miniapps) rejects with INVALID_ARGUMENT. Keys are device-local settings:
12
+ * the value travels only across the local bridge, never through any server.
13
+ */
14
+ import { MiniappSession } from "../session";
15
+ /** Providers whose user-supplied keys miniapps may read. */
16
+ export type ApiKeyProvider = "anthropic" | "gemini" | "openai" | "elevenlabs" | "mapbox";
17
+ export declare class KeysModule {
18
+ private readonly session;
19
+ constructor(session: MiniappSession);
20
+ /** True iff `API_KEYS` is declared in the miniapp's manifest. */
21
+ get hasPermission(): boolean;
22
+ /**
23
+ * Fetch the user's API key for a provider. Resolves with the key, or null
24
+ * when the user hasn't saved one for that provider. Values are not cached —
25
+ * re-fetch (e.g. on retry after a 401 from the provider) to pick up a key
26
+ * the user edited in Settings while the miniapp was running.
27
+ */
28
+ get(provider: ApiKeyProvider): Promise<string | null>;
29
+ }
30
+ //# sourceMappingURL=keys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../src/modules/keys.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAA;AAEzC,4DAA4D;AAC5D,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,QAAQ,GAAG,QAAQ,GAAG,YAAY,GAAG,QAAQ,CAAA;AAMxF,qBAAa,UAAU;IACT,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,cAAc;IAEpD,iEAAiE;IACjE,IAAI,aAAa,IAAI,OAAO,CAE3B;IAED;;;;;OAKG;IACG,GAAG,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CAO5D"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @fileoverview KeysModule — read user-supplied provider API keys.
3
+ *
4
+ * Users can enter their own provider API keys in the Glassly App
5
+ * (Settings > API Keys). A miniapp that declares the API_KEYS permission in
6
+ * miniapp.json can read the providers in {@link ApiKeyProvider}; the phone
7
+ * runtime rejects with PERMISSION_NOT_DECLARED otherwise.
8
+ *
9
+ * The provider set is an explicit host-side allowlist — asking for anything
10
+ * else (e.g. the Soniox transcription key, which is deliberately not exposed
11
+ * to miniapps) rejects with INVALID_ARGUMENT. Keys are device-local settings:
12
+ * the value travels only across the local bridge, never through any server.
13
+ */
14
+ import { MiniappRequestType } from "../protocol";
15
+ export class KeysModule {
16
+ constructor(session) {
17
+ this.session = session;
18
+ }
19
+ /** True iff `API_KEYS` is declared in the miniapp's manifest. */
20
+ get hasPermission() {
21
+ return this.session._hasManifestPermission("API_KEYS");
22
+ }
23
+ /**
24
+ * Fetch the user's API key for a provider. Resolves with the key, or null
25
+ * when the user hasn't saved one for that provider. Values are not cached —
26
+ * re-fetch (e.g. on retry after a 401 from the provider) to pick up a key
27
+ * the user edited in Settings while the miniapp was running.
28
+ */
29
+ async get(provider) {
30
+ const result = await this.session.sendRequest({
31
+ type: MiniappRequestType.KEYS_GET,
32
+ provider,
33
+ });
34
+ return result?.key ?? null;
35
+ }
36
+ }
37
+ //# sourceMappingURL=keys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keys.js","sourceRoot":"","sources":["../../src/modules/keys.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAC,kBAAkB,EAAC,MAAM,aAAa,CAAA;AAU9C,MAAM,OAAO,UAAU;IACrB,YAA6B,OAAuB;QAAvB,YAAO,GAAP,OAAO,CAAgB;IAAG,CAAC;IAExD,iEAAiE;IACjE,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,UAAU,CAAC,CAAA;IACxD,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,GAAG,CAAC,QAAwB;QAChC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,CAAgB;YAC3D,IAAI,EAAE,kBAAkB,CAAC,QAAQ;YACjC,QAAQ;SACT,CAAC,CAAA;QACF,OAAO,MAAM,EAAE,GAAG,IAAI,IAAI,CAAA;IAC5B,CAAC;CACF"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @fileoverview Language validation at the SDK boundary (issue 021, WP2).
3
+ *
4
+ * The registry itself lives in `@glassly/cloud-protocol/languages` (single
5
+ * source of truth shared with the cloud). This module re-exports the types so
6
+ * miniapps import everything from `@glassly/miniapp`, and adds the throwing
7
+ * validators the typed module surfaces (`transcription.*`, `translation.*`)
8
+ * call on every language parameter.
9
+ *
10
+ * Contract (design doc docs/issues/021-typed-language-subscriptions):
11
+ * - Valid by construction: params are typed as literal unions, so TS users
12
+ * get autocomplete and compile errors.
13
+ * - Loud at runtime: JS users (or `any` casts) get a thrown
14
+ * `MiniappValidationError` with a suggestion, never silent fallback.
15
+ * - Canonical on the wire: bare codes ("fr") canonicalize to their default
16
+ * tag ("fr-FR") before becoming stream keys, so the phone/cloud only ever
17
+ * see registry tags.
18
+ */
19
+ import { isTranscriptionLanguage, SUPPORTED_LANGUAGE_HINTS, SUPPORTED_TRANSCRIPTION_LANGUAGES } from "@glassly/cloud-protocol/languages";
20
+ import type { LanguageHint, TranscriptionLanguage } from "@glassly/cloud-protocol/languages";
21
+ export { SUPPORTED_LANGUAGE_HINTS, SUPPORTED_TRANSCRIPTION_LANGUAGES, isTranscriptionLanguage };
22
+ export type { LanguageHint, TranscriptionLanguage };
23
+ /**
24
+ * Thrown synchronously by SDK methods when a parameter fails validation.
25
+ * Deliberately a hard throw (not a warning, not a silent default): an invalid
26
+ * language previously produced a subscription that silently transcribed the
27
+ * wrong language or silently never spoke (OS-1746).
28
+ */
29
+ export declare class MiniappValidationError extends Error {
30
+ constructor(message: string);
31
+ }
32
+ /**
33
+ * Canonicalize a subscription language or throw. Accepts registry tags
34
+ * ("fr-FR") and bare registry codes ("fr" -> "fr-FR").
35
+ */
36
+ export declare function requireTranscriptionLanguage(value: string, param: string): TranscriptionLanguage;
37
+ /**
38
+ * Normalize a language hint to the bare code the STT provider accepts, or
39
+ * throw. Accepts bare codes ("fr") and registry tags ("fr-FR" -> "fr").
40
+ */
41
+ export declare function requireLanguageHint(value: string, param: string): LanguageHint;
42
+ //# sourceMappingURL=languages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"languages.d.ts","sourceRoot":"","sources":["../../src/modules/languages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EACL,uBAAuB,EAIvB,wBAAwB,EACxB,iCAAiC,EAClC,MAAM,mCAAmC,CAAA;AAC1C,OAAO,KAAK,EAAC,YAAY,EAAE,qBAAqB,EAAC,MAAM,mCAAmC,CAAA;AAE1F,OAAO,EAAC,wBAAwB,EAAE,iCAAiC,EAAE,uBAAuB,EAAC,CAAA;AAC7F,YAAY,EAAC,YAAY,EAAE,qBAAqB,EAAC,CAAA;AAEjD;;;;;GAKG;AACH,qBAAa,sBAAuB,SAAQ,KAAK;gBACnC,OAAO,EAAE,MAAM;CAI5B;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,qBAAqB,CAShG;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,YAAY,CAO9E"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * @fileoverview Language validation at the SDK boundary (issue 021, WP2).
3
+ *
4
+ * The registry itself lives in `@glassly/cloud-protocol/languages` (single
5
+ * source of truth shared with the cloud). This module re-exports the types so
6
+ * miniapps import everything from `@glassly/miniapp`, and adds the throwing
7
+ * validators the typed module surfaces (`transcription.*`, `translation.*`)
8
+ * call on every language parameter.
9
+ *
10
+ * Contract (design doc docs/issues/021-typed-language-subscriptions):
11
+ * - Valid by construction: params are typed as literal unions, so TS users
12
+ * get autocomplete and compile errors.
13
+ * - Loud at runtime: JS users (or `any` casts) get a thrown
14
+ * `MiniappValidationError` with a suggestion, never silent fallback.
15
+ * - Canonical on the wire: bare codes ("fr") canonicalize to their default
16
+ * tag ("fr-FR") before becoming stream keys, so the phone/cloud only ever
17
+ * see registry tags.
18
+ */
19
+ import { isTranscriptionLanguage, suggestTranscriptionLanguage, toLanguageHint, toTranscriptionLanguage, SUPPORTED_LANGUAGE_HINTS, SUPPORTED_TRANSCRIPTION_LANGUAGES, } from "@glassly/cloud-protocol/languages";
20
+ export { SUPPORTED_LANGUAGE_HINTS, SUPPORTED_TRANSCRIPTION_LANGUAGES, isTranscriptionLanguage };
21
+ /**
22
+ * Thrown synchronously by SDK methods when a parameter fails validation.
23
+ * Deliberately a hard throw (not a warning, not a silent default): an invalid
24
+ * language previously produced a subscription that silently transcribed the
25
+ * wrong language or silently never spoke (OS-1746).
26
+ */
27
+ export class MiniappValidationError extends Error {
28
+ constructor(message) {
29
+ super(message);
30
+ this.name = "MiniappValidationError";
31
+ }
32
+ }
33
+ /**
34
+ * Canonicalize a subscription language or throw. Accepts registry tags
35
+ * ("fr-FR") and bare registry codes ("fr" -> "fr-FR").
36
+ */
37
+ export function requireTranscriptionLanguage(value, param) {
38
+ const canonical = toTranscriptionLanguage(value);
39
+ if (canonical)
40
+ return canonical;
41
+ const suggestion = suggestTranscriptionLanguage(value);
42
+ throw new MiniappValidationError(`${param}: unknown language ${JSON.stringify(value)}` +
43
+ (suggestion ? ` — did you mean ${JSON.stringify(suggestion)}?` : "") +
44
+ ` Supported values are BCP-47 tags from SUPPORTED_TRANSCRIPTION_LANGUAGES (e.g. "en-US", "fr-FR").`);
45
+ }
46
+ /**
47
+ * Normalize a language hint to the bare code the STT provider accepts, or
48
+ * throw. Accepts bare codes ("fr") and registry tags ("fr-FR" -> "fr").
49
+ */
50
+ export function requireLanguageHint(value, param) {
51
+ const hint = toLanguageHint(value);
52
+ if (hint)
53
+ return hint;
54
+ throw new MiniappValidationError(`${param}: unknown language hint ${JSON.stringify(value)}. ` +
55
+ `Hints are bare ISO 639-1 codes from SUPPORTED_LANGUAGE_HINTS (e.g. "en", "fr").`);
56
+ }
57
+ //# sourceMappingURL=languages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"languages.js","sourceRoot":"","sources":["../../src/modules/languages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EACL,uBAAuB,EACvB,4BAA4B,EAC5B,cAAc,EACd,uBAAuB,EACvB,wBAAwB,EACxB,iCAAiC,GAClC,MAAM,mCAAmC,CAAA;AAG1C,OAAO,EAAC,wBAAwB,EAAE,iCAAiC,EAAE,uBAAuB,EAAC,CAAA;AAG7F;;;;;GAKG;AACH,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAC/C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAA;IACtC,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,UAAU,4BAA4B,CAAC,KAAa,EAAE,KAAa;IACvE,MAAM,SAAS,GAAG,uBAAuB,CAAC,KAAK,CAAC,CAAA;IAChD,IAAI,SAAS;QAAE,OAAO,SAAS,CAAA;IAC/B,MAAM,UAAU,GAAG,4BAA4B,CAAC,KAAK,CAAC,CAAA;IACtD,MAAM,IAAI,sBAAsB,CAC9B,GAAG,KAAK,sBAAsB,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE;QACnD,CAAC,UAAU,CAAC,CAAC,CAAC,mBAAmB,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QACpE,mGAAmG,CACtG,CAAA;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAa,EAAE,KAAa;IAC9D,MAAM,IAAI,GAAG,cAAc,CAAC,KAAK,CAAC,CAAA;IAClC,IAAI,IAAI;QAAE,OAAO,IAAI,CAAA;IACrB,MAAM,IAAI,sBAAsB,CAC9B,GAAG,KAAK,2BAA2B,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI;QAC1D,iFAAiF,CACpF,CAAA;AACH,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @fileoverview LedModule — glasses RGB LED control.
3
+ *
4
+ * API mirrors the cloud SDK's LED module. Colors are named strings
5
+ * (the phone maps them to per-device LED indices). Actions are "on" / "off".
6
+ */
7
+ import { MiniappSession } from "../session";
8
+ export type LedColor = "red" | "green" | "blue" | "orange" | "white";
9
+ export type LedControlResult = {
10
+ type?: "rgb_led_control_response";
11
+ state: "success";
12
+ requestId: string;
13
+ };
14
+ export interface LedControlOptions {
15
+ color?: LedColor;
16
+ /** LED on duration in ms. */
17
+ ontime?: number;
18
+ /** LED off duration in ms. */
19
+ offtime?: number;
20
+ /** Number of on/off cycles. */
21
+ count?: number;
22
+ }
23
+ export declare class LedModule {
24
+ private readonly session;
25
+ constructor(session: MiniappSession);
26
+ /** Turn an LED on with the given pattern. Resolves after the glasses acknowledge the command. */
27
+ turnOn(options?: LedControlOptions): Promise<LedControlResult>;
28
+ /** Turn all LEDs off. Resolves after the glasses acknowledge the command. */
29
+ turnOff(): Promise<LedControlResult>;
30
+ /** Blink pattern — repeats `count` times with ontime/offtime. */
31
+ blink(color: LedColor, ontime: number, offtime: number, count: number): Promise<LedControlResult>;
32
+ /** Solid LED for a fixed duration. */
33
+ solid(color: LedColor, duration: number): Promise<LedControlResult>;
34
+ }
35
+ //# sourceMappingURL=led.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"led.d.ts","sourceRoot":"","sources":["../../src/modules/led.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAA;AAEzC,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAA;AAEpE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,CAAC,EAAE,0BAA0B,CAAA;IACjC,KAAK,EAAE,SAAS,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,EAAE,QAAQ,CAAA;IAChB,6BAA6B;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,8BAA8B;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,+BAA+B;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,qBAAa,SAAS;IACR,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,cAAc;IAEpD,iGAAiG;IAC3F,MAAM,CAAC,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAWxE,6EAA6E;IACvE,OAAO,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAO1C,iEAAiE;IAC3D,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAIvG,sCAAsC;IAChC,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAG1E"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * @fileoverview LedModule — glasses RGB LED control.
3
+ *
4
+ * API mirrors the cloud SDK's LED module. Colors are named strings
5
+ * (the phone maps them to per-device LED indices). Actions are "on" / "off".
6
+ */
7
+ import { MiniappRequestType } from "../protocol";
8
+ export class LedModule {
9
+ constructor(session) {
10
+ this.session = session;
11
+ }
12
+ /** Turn an LED on with the given pattern. Resolves after the glasses acknowledge the command. */
13
+ async turnOn(options = {}) {
14
+ return this.session.sendRequest({
15
+ type: MiniappRequestType.RGB_LED,
16
+ action: "on",
17
+ color: options.color ?? "red",
18
+ ontime: options.ontime ?? 1000,
19
+ offtime: options.offtime ?? 0,
20
+ count: options.count ?? 1,
21
+ });
22
+ }
23
+ /** Turn all LEDs off. Resolves after the glasses acknowledge the command. */
24
+ async turnOff() {
25
+ return this.session.sendRequest({
26
+ type: MiniappRequestType.RGB_LED,
27
+ action: "off",
28
+ });
29
+ }
30
+ /** Blink pattern — repeats `count` times with ontime/offtime. */
31
+ async blink(color, ontime, offtime, count) {
32
+ return this.turnOn({ color, ontime, offtime, count });
33
+ }
34
+ /** Solid LED for a fixed duration. */
35
+ async solid(color, duration) {
36
+ return this.turnOn({ color, ontime: duration, offtime: 0, count: 1 });
37
+ }
38
+ }
39
+ //# sourceMappingURL=led.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"led.js","sourceRoot":"","sources":["../../src/modules/led.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,kBAAkB,EAAC,MAAM,aAAa,CAAA;AAqB9C,MAAM,OAAO,SAAS;IACpB,YAA6B,OAAuB;QAAvB,YAAO,GAAP,OAAO,CAAgB;IAAG,CAAC;IAExD,iGAAiG;IACjG,KAAK,CAAC,MAAM,CAAC,UAA6B,EAAE;QAC1C,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAmB;YAChD,IAAI,EAAE,kBAAkB,CAAC,OAAO;YAChC,MAAM,EAAE,IAAI;YACZ,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,KAAK;YAC7B,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,IAAI;YAC9B,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,CAAC;YAC7B,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;SAC1B,CAAC,CAAA;IACJ,CAAC;IAED,6EAA6E;IAC7E,KAAK,CAAC,OAAO;QACX,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAmB;YAChD,IAAI,EAAE,kBAAkB,CAAC,OAAO;YAChC,MAAM,EAAE,KAAK;SACd,CAAC,CAAA;IACJ,CAAC;IAED,iEAAiE;IACjE,KAAK,CAAC,KAAK,CAAC,KAAe,EAAE,MAAc,EAAE,OAAe,EAAE,KAAa;QACzE,OAAO,IAAI,CAAC,MAAM,CAAC,EAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAC,CAAC,CAAA;IACrD,CAAC;IAED,sCAAsC;IACtC,KAAK,CAAC,KAAK,CAAC,KAAe,EAAE,QAAgB;QAC3C,OAAO,IAAI,CAAC,MAAM,CAAC,EAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAC,CAAC,CAAA;IACrE,CAAC;CACF"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @fileoverview LocationModule — phone location events.
3
+ *
4
+ * Exposes both a continuous `onUpdate` subscription and a one-shot
5
+ * `getOnce()` poll over `MiniappRequestType.LOCATION_POLL`.
6
+ *
7
+ * LOCATION permission must be declared in miniapp.json for either path to
8
+ * succeed; the phone runtime rejects with PERMISSION_NOT_DECLARED
9
+ * otherwise.
10
+ */
11
+ import { MiniappSession } from "../session";
12
+ import type { LocationData, UnsubscribeFn } from "./events";
13
+ export declare class LocationModule {
14
+ private readonly session;
15
+ constructor(session: MiniappSession);
16
+ /** True iff `LOCATION` is declared in the miniapp's manifest. */
17
+ get hasPermission(): boolean;
18
+ /** Subscribe to continuous location updates. */
19
+ onUpdate(handler: (data: LocationData) => void): UnsubscribeFn;
20
+ /**
21
+ * Request a single location fix. Resolves with the next available
22
+ * reading from the phone. Useful at app load to seed UI before a
23
+ * continuous stream of updates begins.
24
+ */
25
+ getOnce(): Promise<LocationData>;
26
+ }
27
+ //# sourceMappingURL=location.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"location.d.ts","sourceRoot":"","sources":["../../src/modules/location.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAA;AACzC,OAAO,KAAK,EAAC,YAAY,EAAE,aAAa,EAAC,MAAM,UAAU,CAAA;AAEzD,qBAAa,cAAc;IACb,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,cAAc;IAEpD,iEAAiE;IACjE,IAAI,aAAa,IAAI,OAAO,CAE3B;IAED,gDAAgD;IAChD,QAAQ,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,IAAI,GAAG,aAAa;IAI9D;;;;OAIG;IACH,OAAO,IAAI,OAAO,CAAC,YAAY,CAAC;CAKjC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @fileoverview LocationModule — phone location events.
3
+ *
4
+ * Exposes both a continuous `onUpdate` subscription and a one-shot
5
+ * `getOnce()` poll over `MiniappRequestType.LOCATION_POLL`.
6
+ *
7
+ * LOCATION permission must be declared in miniapp.json for either path to
8
+ * succeed; the phone runtime rejects with PERMISSION_NOT_DECLARED
9
+ * otherwise.
10
+ */
11
+ import { MiniappRequestType, MiniappStreamType } from "../protocol";
12
+ export class LocationModule {
13
+ constructor(session) {
14
+ this.session = session;
15
+ }
16
+ /** True iff `LOCATION` is declared in the miniapp's manifest. */
17
+ get hasPermission() {
18
+ return this.session._hasManifestPermission("LOCATION");
19
+ }
20
+ /** Subscribe to continuous location updates. */
21
+ onUpdate(handler) {
22
+ return this.session._subscribe(MiniappStreamType.LOCATION_UPDATE, handler);
23
+ }
24
+ /**
25
+ * Request a single location fix. Resolves with the next available
26
+ * reading from the phone. Useful at app load to seed UI before a
27
+ * continuous stream of updates begins.
28
+ */
29
+ getOnce() {
30
+ return this.session.sendRequest({
31
+ type: MiniappRequestType.LOCATION_POLL,
32
+ });
33
+ }
34
+ }
35
+ //# sourceMappingURL=location.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"location.js","sourceRoot":"","sources":["../../src/modules/location.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAC,kBAAkB,EAAE,iBAAiB,EAAC,MAAM,aAAa,CAAA;AAIjE,MAAM,OAAO,cAAc;IACzB,YAA6B,OAAuB;QAAvB,YAAO,GAAP,OAAO,CAAgB;IAAG,CAAC;IAExD,iEAAiE;IACjE,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,UAAU,CAAC,CAAA;IACxD,CAAC;IAED,gDAAgD;IAChD,QAAQ,CAAC,OAAqC;QAC5C,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,iBAAiB,CAAC,eAAe,EAAE,OAAkC,CAAC,CAAA;IACvG,CAAC;IAED;;;;OAIG;IACH,OAAO;QACL,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAe;YAC5C,IAAI,EAAE,kBAAkB,CAAC,aAAa;SACvC,CAAC,CAAA;IACJ,CAAC;CACF"}
@@ -0,0 +1,126 @@
1
+ /**
2
+ * @fileoverview MemoryModule — the user's shared, phone-local memory timeline.
3
+ *
4
+ * One unified per-hour stream of what happened around the user — spoken
5
+ * transcript lines AND notes (manual, voice, auto) — plus the hourly summary
6
+ * that heads each session. The store lives on the phone (host-level,
7
+ * user-scoped), NOT in the per-miniapp storage namespace: every miniapp that
8
+ * declares the MEMORY manifest permission reads and writes the same timeline,
9
+ * and the user manages it in Settings > Memory.
10
+ *
11
+ * A "session" is one clock hour that has entries, derived from entry
12
+ * timestamps at read time — there is no stored session id.
13
+ *
14
+ * All calls require the MEMORY manifest permission; without it the host
15
+ * rejects with PERMISSION_NOT_DECLARED. Nothing here leaves the phone.
16
+ */
17
+ import { MiniappSession } from "../session";
18
+ export type MemoryEntryKind = "line" | "note";
19
+ /** How a note entry originated (only meaningful when kind === "note"). */
20
+ export type MemoryNoteSource = "voice" | "ui" | "auto";
21
+ export interface MemoryEntry {
22
+ id: string;
23
+ kind: MemoryEntryKind;
24
+ text: string;
25
+ /** Epoch ms the entry happened. */
26
+ at: number;
27
+ speakerId: string | null;
28
+ /** Enrolled-speaker display name resolved by on-device speaker ID, when known. */
29
+ resolvedSpeakerName?: string | null;
30
+ language: string | null;
31
+ /** Present for note entries. */
32
+ source?: MemoryNoteSource;
33
+ }
34
+ export interface MemorySummary {
35
+ /** Epoch ms of the hour bucket start. */
36
+ hourStart: number;
37
+ text: string;
38
+ createdAt: number;
39
+ }
40
+ /** One derived session: a clock hour with its entries and summary. */
41
+ export interface MemorySession {
42
+ hourStart: number;
43
+ entries: MemoryEntry[];
44
+ summary: string | null;
45
+ lineCount: number;
46
+ noteCount: number;
47
+ }
48
+ export interface MemoryQuery {
49
+ /** Epoch ms lower bound (inclusive). Omit for "from the beginning". */
50
+ sinceMs?: number;
51
+ /** Epoch ms upper bound (inclusive). Omit for "until now". */
52
+ untilMs?: number;
53
+ /** Case-insensitive EXACT substring filter (codes, URLs, exact phrases). */
54
+ contains?: string;
55
+ /**
56
+ * Fuzzy any-of terms: an entry matches when ANY term matches, and a
57
+ * multi-word term requires all of its words. Matching tolerates the small
58
+ * misspellings speech-to-text produces for names ("Korwin" matches
59
+ * "Corwin"). Host caps at 8 terms. Combined with `contains` as AND.
60
+ * Ignored by hosts that predate fuzzy search.
61
+ */
62
+ terms?: string[];
63
+ /** Max entries returned (host caps at 200; default 60). Newest kept. */
64
+ limit?: number;
65
+ }
66
+ export interface MemorySearchResult {
67
+ /** Matches in chronological order (newest last). */
68
+ entries: MemoryEntry[];
69
+ /**
70
+ * Entries inside the TIME window before keyword filtering — distinguishes
71
+ * "keyword matched nothing" from "window empty". Undefined on hosts that
72
+ * predate fuzzy search.
73
+ */
74
+ windowCount?: number;
75
+ }
76
+ export declare class MemoryModule {
77
+ private readonly session;
78
+ constructor(session: MiniappSession);
79
+ /** True iff this miniapp's manifest declares the MEMORY permission. */
80
+ get hasPermission(): boolean;
81
+ /** Append a spoken transcript line to the timeline. */
82
+ appendLine(input: {
83
+ text: string;
84
+ speakerId: string | null;
85
+ language: string | null;
86
+ at: number;
87
+ }): Promise<void>;
88
+ /**
89
+ * Add a note. `at` targets the hour it belongs to — omit for "now" (the
90
+ * current session), or pass a timestamp inside a past hour to append to
91
+ * that session. Notes dedupe on normalized text within the same hour;
92
+ * resolves null when the note was a duplicate (or empty).
93
+ */
94
+ addNote(text: string, source?: MemoryNoteSource, at?: number): Promise<MemoryEntry | null>;
95
+ /** Delete one entry (line or note) by id. Resolves false when unknown. */
96
+ removeEntry(id: string): Promise<boolean>;
97
+ /** Delete every entry (and summary) in an hour, or a whole day of hours. */
98
+ removeScope(scope: "session" | "day", at: number): Promise<void>;
99
+ /** All sessions (hours with entries), newest hour first. */
100
+ sessions(): Promise<MemorySession[]>;
101
+ /**
102
+ * Query the full timeline by absolute-time window and keyword — the
103
+ * on-device executor shape for LLM history-search tools. Newest last, so
104
+ * slicing keeps the most recent matches when the limit bites.
105
+ */
106
+ query(q?: MemoryQuery): Promise<MemoryEntry[]>;
107
+ /**
108
+ * query() plus search diagnostics ({@link MemorySearchResult.windowCount}).
109
+ * Same wire request; prefer this from LLM history-search tools so an empty
110
+ * result can explain WHY it was empty instead of triggering a blind retry.
111
+ */
112
+ search(q?: MemoryQuery): Promise<MemorySearchResult>;
113
+ /** Entries in [sinceMs, untilMs), newest last. Uncapped (unlike query). */
114
+ window(sinceMs: number, untilMs?: number): Promise<MemoryEntry[]>;
115
+ /** Plain-text export of a scope, for the OS share sheet. */
116
+ exportText(scope: "session" | "day" | "all", at?: number): Promise<string>;
117
+ /** Upsert the summary heading an hour (keyed by hourStart). */
118
+ addSummary(summary: MemorySummary): Promise<void>;
119
+ /** All hourly summaries, newest hour first. */
120
+ summaries(): Promise<MemorySummary[]>;
121
+ /** Most recent COMPLETED hour with lines but no summary, or null. */
122
+ pendingSummaryHour(nowMs?: number): Promise<number | null>;
123
+ /** Drop the entire timeline: every entry and every summary. */
124
+ clear(): Promise<void>;
125
+ }
126
+ //# sourceMappingURL=memory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/modules/memory.ts"],"names":[],"mappings":"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"}