@mentra/sdk 1.1.19

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 (101) hide show
  1. package/README.md +102 -0
  2. package/dist/constants/index.d.ts +14 -0
  3. package/dist/constants/index.d.ts.map +1 -0
  4. package/dist/constants/index.js +16 -0
  5. package/dist/examples/rtmp-streaming-example.d.ts +2 -0
  6. package/dist/examples/rtmp-streaming-example.d.ts.map +1 -0
  7. package/dist/examples/rtmp-streaming-example.js +102 -0
  8. package/dist/index.d.ts +4 -0
  9. package/dist/index.d.ts.map +1 -0
  10. package/dist/index.js +33 -0
  11. package/dist/logging/logger.d.ts +3 -0
  12. package/dist/logging/logger.d.ts.map +1 -0
  13. package/dist/logging/logger.js +79 -0
  14. package/dist/tpa/index.d.ts +6 -0
  15. package/dist/tpa/index.d.ts.map +1 -0
  16. package/dist/tpa/index.js +24 -0
  17. package/dist/tpa/server/index.d.ts +193 -0
  18. package/dist/tpa/server/index.d.ts.map +1 -0
  19. package/dist/tpa/server/index.js +436 -0
  20. package/dist/tpa/session/api-client.d.ts +49 -0
  21. package/dist/tpa/session/api-client.d.ts.map +1 -0
  22. package/dist/tpa/session/api-client.js +101 -0
  23. package/dist/tpa/session/dashboard.d.ts +52 -0
  24. package/dist/tpa/session/dashboard.d.ts.map +1 -0
  25. package/dist/tpa/session/dashboard.js +149 -0
  26. package/dist/tpa/session/events.d.ts +178 -0
  27. package/dist/tpa/session/events.d.ts.map +1 -0
  28. package/dist/tpa/session/events.js +294 -0
  29. package/dist/tpa/session/index.d.ts +391 -0
  30. package/dist/tpa/session/index.d.ts.map +1 -0
  31. package/dist/tpa/session/index.js +1452 -0
  32. package/dist/tpa/session/layouts.d.ts +150 -0
  33. package/dist/tpa/session/layouts.d.ts.map +1 -0
  34. package/dist/tpa/session/layouts.js +282 -0
  35. package/dist/tpa/session/modules/streaming.d.ts +100 -0
  36. package/dist/tpa/session/modules/streaming.d.ts.map +1 -0
  37. package/dist/tpa/session/modules/streaming.js +270 -0
  38. package/dist/tpa/session/settings.d.ts +202 -0
  39. package/dist/tpa/session/settings.d.ts.map +1 -0
  40. package/dist/tpa/session/settings.js +361 -0
  41. package/dist/tpa/token/index.d.ts +7 -0
  42. package/dist/tpa/token/index.d.ts.map +1 -0
  43. package/dist/tpa/token/index.js +22 -0
  44. package/dist/tpa/token/utils.d.ts +69 -0
  45. package/dist/tpa/token/utils.d.ts.map +1 -0
  46. package/dist/tpa/token/utils.js +144 -0
  47. package/dist/tpa/webview/index.d.ts +47 -0
  48. package/dist/tpa/webview/index.d.ts.map +1 -0
  49. package/dist/tpa/webview/index.js +344 -0
  50. package/dist/types/dashboard/index.d.ts +128 -0
  51. package/dist/types/dashboard/index.d.ts.map +1 -0
  52. package/dist/types/dashboard/index.js +12 -0
  53. package/dist/types/enums.d.ts +57 -0
  54. package/dist/types/enums.d.ts.map +1 -0
  55. package/dist/types/enums.js +72 -0
  56. package/dist/types/index.d.ts +38 -0
  57. package/dist/types/index.d.ts.map +1 -0
  58. package/dist/types/index.js +87 -0
  59. package/dist/types/layouts.d.ts +51 -0
  60. package/dist/types/layouts.d.ts.map +1 -0
  61. package/dist/types/layouts.js +3 -0
  62. package/dist/types/message-types.d.ts +109 -0
  63. package/dist/types/message-types.d.ts.map +1 -0
  64. package/dist/types/message-types.js +189 -0
  65. package/dist/types/messages/base.d.ts +12 -0
  66. package/dist/types/messages/base.d.ts.map +1 -0
  67. package/dist/types/messages/base.js +3 -0
  68. package/dist/types/messages/cloud-to-glasses.d.ts +126 -0
  69. package/dist/types/messages/cloud-to-glasses.d.ts.map +1 -0
  70. package/dist/types/messages/cloud-to-glasses.js +60 -0
  71. package/dist/types/messages/cloud-to-tpa.d.ts +228 -0
  72. package/dist/types/messages/cloud-to-tpa.d.ts.map +1 -0
  73. package/dist/types/messages/cloud-to-tpa.js +61 -0
  74. package/dist/types/messages/glasses-to-cloud.d.ts +219 -0
  75. package/dist/types/messages/glasses-to-cloud.d.ts.map +1 -0
  76. package/dist/types/messages/glasses-to-cloud.js +88 -0
  77. package/dist/types/messages/tpa-to-cloud.d.ts +146 -0
  78. package/dist/types/messages/tpa-to-cloud.d.ts.map +1 -0
  79. package/dist/types/messages/tpa-to-cloud.js +67 -0
  80. package/dist/types/models.d.ts +165 -0
  81. package/dist/types/models.d.ts.map +1 -0
  82. package/dist/types/models.js +84 -0
  83. package/dist/types/rtmp-stream.d.ts +68 -0
  84. package/dist/types/rtmp-stream.d.ts.map +1 -0
  85. package/dist/types/rtmp-stream.js +3 -0
  86. package/dist/types/streams.d.ts +138 -0
  87. package/dist/types/streams.d.ts.map +1 -0
  88. package/dist/types/streams.js +251 -0
  89. package/dist/types/token.d.ts +41 -0
  90. package/dist/types/token.d.ts.map +1 -0
  91. package/dist/types/token.js +7 -0
  92. package/dist/types/user-session.d.ts +73 -0
  93. package/dist/types/user-session.d.ts.map +1 -0
  94. package/dist/types/user-session.js +17 -0
  95. package/dist/types/webhooks.d.ts +107 -0
  96. package/dist/types/webhooks.d.ts.map +1 -0
  97. package/dist/types/webhooks.js +55 -0
  98. package/dist/utils/resource-tracker.d.ts +94 -0
  99. package/dist/utils/resource-tracker.d.ts.map +1 -0
  100. package/dist/utils/resource-tracker.js +153 -0
  101. package/package.json +50 -0
@@ -0,0 +1,138 @@
1
+ /**
2
+ * Types of streams that TPAs can subscribe to
3
+ *
4
+ * These are events and data that TPAs can receive from the cloud.
5
+ * Not all message types can be subscribed to as streams.
6
+ */
7
+ export declare enum StreamType {
8
+ BUTTON_PRESS = "button_press",
9
+ HEAD_POSITION = "head_position",
10
+ GLASSES_BATTERY_UPDATE = "glasses_battery_update",
11
+ PHONE_BATTERY_UPDATE = "phone_battery_update",
12
+ GLASSES_CONNECTION_STATE = "glasses_connection_state",
13
+ LOCATION_UPDATE = "location_update",
14
+ VPS_COORDINATES = "vps_coordinates",
15
+ TRANSCRIPTION = "transcription",
16
+ TRANSLATION = "translation",
17
+ VAD = "VAD",
18
+ AUDIO_CHUNK = "audio_chunk",
19
+ PHONE_NOTIFICATION = "phone_notification",
20
+ NOTIFICATION_DISMISSED = "notification_dismissed",
21
+ CALENDAR_EVENT = "calendar_event",
22
+ START_APP = "start_app",
23
+ STOP_APP = "stop_app",
24
+ OPEN_DASHBOARD = "open_dashboard",
25
+ CORE_STATUS_UPDATE = "core_status_update",
26
+ VIDEO = "video",
27
+ PHOTO_REQUEST = "photo_request",
28
+ PHOTO_RESPONSE = "photo_response",
29
+ RTMP_STREAM_STATUS = "rtmp_stream_status",
30
+ ALL = "all",
31
+ WILDCARD = "*",
32
+ AUGMENTOS_SETTINGS_UPDATE_REQUEST = "settings_update_request",
33
+ CUSTOM_MESSAGE = "custom_message",
34
+ PHOTO_TAKEN = "photo_taken"
35
+ }
36
+ /**
37
+ * Extended StreamType to support language-specific streams
38
+ * This allows us to treat language-specific strings as StreamType values
39
+ */
40
+ export type ExtendedStreamType = StreamType | string;
41
+ /**
42
+ * Categories of stream data
43
+ */
44
+ export declare enum StreamCategory {
45
+ /** Data from hardware sensors */
46
+ HARDWARE = "hardware",
47
+ /** Audio processing results */
48
+ AUDIO = "audio",
49
+ /** Phone-related events */
50
+ PHONE = "phone",
51
+ /** System-level events */
52
+ SYSTEM = "system"
53
+ }
54
+ /**
55
+ * Map of stream categories for each stream type
56
+ */
57
+ export declare const STREAM_CATEGORIES: Record<StreamType, StreamCategory>;
58
+ /**
59
+ * Branded type for TypeScript to recognize language-specific stream types
60
+ * This helps maintain type safety when using language-specific streams
61
+ */
62
+ export type LanguageStreamType<T extends string> = T & {
63
+ __languageStreamBrand: never;
64
+ };
65
+ /**
66
+ * Structure of a parsed language stream subscription
67
+ */
68
+ export interface LanguageStreamInfo {
69
+ type: StreamType;
70
+ baseType: string;
71
+ transcribeLanguage: string;
72
+ translateLanguage?: string;
73
+ original: ExtendedStreamType;
74
+ }
75
+ /**
76
+ * Check if a string is a valid language code
77
+ * Simple validation for language code format: xx-XX (e.g., en-US)
78
+ */
79
+ export declare function isValidLanguageCode(code: string): boolean;
80
+ /**
81
+ * Parse a subscription string to extract language information
82
+ *
83
+ * @param subscription Subscription string (e.g., "transcription:en-US" or "translation:es-ES-to-en-US")
84
+ * @returns Parsed language stream info or null if not a language-specific subscription
85
+ */
86
+ export declare function parseLanguageStream(subscription: ExtendedStreamType): LanguageStreamInfo | null;
87
+ /**
88
+ * Create a transcription stream identifier for a specific language
89
+ * Returns a type-safe stream type that can be used like a StreamType
90
+ *
91
+ * @param language Language code (e.g., "en-US")
92
+ * @returns Typed stream identifier
93
+ */
94
+ export declare function createTranscriptionStream(language: string): ExtendedStreamType;
95
+ /**
96
+ * Create a translation stream identifier for a language pair
97
+ * Returns a type-safe stream type that can be used like a StreamType
98
+ *
99
+ * @param sourceLanguage Source language code (e.g., "es-ES")
100
+ * @param targetLanguage Target language code (e.g., "en-US")
101
+ * @returns Typed stream identifier
102
+ */
103
+ export declare function createTranslationStream(sourceLanguage: string, targetLanguage: string): ExtendedStreamType;
104
+ /**
105
+ * Check if a subscription is a valid stream type
106
+ * This handles both enum-based StreamType values and language-specific stream formats
107
+ *
108
+ * @param subscription Subscription to validate
109
+ * @returns True if valid, false otherwise
110
+ */
111
+ export declare function isValidStreamType(subscription: ExtendedStreamType): boolean;
112
+ /**
113
+ * Helper function to check if a stream type is of a particular category
114
+ * Works with both standard and language-specific stream types
115
+ */
116
+ export declare function isStreamCategory(streamType: ExtendedStreamType, category: StreamCategory): boolean;
117
+ /**
118
+ * Helper function to get all stream types in a category
119
+ */
120
+ export declare function getStreamTypesByCategory(category: StreamCategory): StreamType[];
121
+ /**
122
+ * Get the base StreamType for a subscription
123
+ * Works with both standard StreamType values and language-specific formats
124
+ *
125
+ * @param subscription Subscription string or StreamType
126
+ * @returns The base StreamType enum value
127
+ */
128
+ export declare function getBaseStreamType(subscription: ExtendedStreamType): StreamType | null;
129
+ /**
130
+ * Check if a stream is a language-specific stream
131
+ */
132
+ export declare function isLanguageStream(subscription: ExtendedStreamType): boolean;
133
+ /**
134
+ * Get language information from a stream type
135
+ * Returns null for regular stream types
136
+ */
137
+ export declare function getLanguageInfo(subscription: ExtendedStreamType): LanguageStreamInfo | null;
138
+ //# sourceMappingURL=streams.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"streams.d.ts","sourceRoot":"","sources":["../../src/types/streams.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,oBAAY,UAAU;IAEpB,YAAY,iBAAiB;IAC7B,aAAa,kBAAkB;IAC/B,sBAAsB,2BAA2B;IACjD,oBAAoB,yBAAyB;IAC7C,wBAAwB,6BAA6B;IACrD,eAAe,oBAAoB;IACnC,eAAe,oBAAoB;IAGnC,aAAa,kBAAkB;IAC/B,WAAW,gBAAgB;IAC3B,GAAG,QAAQ;IACX,WAAW,gBAAgB;IAG3B,kBAAkB,uBAAuB;IACzC,sBAAsB,2BAA2B;IACjD,cAAc,mBAAmB;IAGjC,SAAS,cAAc;IACvB,QAAQ,aAAa;IACrB,cAAc,mBAAmB;IACjC,kBAAkB,uBAAuB;IAGzC,KAAK,UAAU;IACf,aAAa,kBAAkB;IAC/B,cAAc,mBAAmB;IACjC,kBAAkB,uBAAuB;IAGzC,GAAG,QAAQ;IACX,QAAQ,MAAM;IAGd,iCAAiC,4BAA4B;IAC7D,cAAc,mBAAmB;IACjC,WAAW,gBAAgB;CAC5B;AAED;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,UAAU,GAAG,MAAM,CAAC;AAErD;;GAEG;AACH,oBAAY,cAAc;IACxB,iCAAiC;IACjC,QAAQ,aAAa;IAErB,+BAA+B;IAC/B,KAAK,UAAU;IAEf,2BAA2B;IAC3B,KAAK,UAAU;IAEf,0BAA0B;IAC1B,MAAM,WAAW;CAClB;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,UAAU,EAAE,cAAc,CAiChE,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,MAAM,IA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ams.ts
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.STREAM_CATEGORIES = exports.StreamCategory = exports.StreamType = void 0;
5
+ exports.isValidLanguageCode = isValidLanguageCode;
6
+ exports.parseLanguageStream = parseLanguageStream;
7
+ exports.createTranscriptionStream = createTranscriptionStream;
8
+ exports.createTranslationStream = createTranslationStream;
9
+ exports.isValidStreamType = isValidStreamType;
10
+ exports.isStreamCategory = isStreamCategory;
11
+ exports.getStreamTypesByCategory = getStreamTypesByCategory;
12
+ exports.getBaseStreamType = getBaseStreamType;
13
+ exports.isLanguageStream = isLanguageStream;
14
+ exports.getLanguageInfo = getLanguageInfo;
15
+ /**
16
+ * Types of streams that TPAs can subscribe to
17
+ *
18
+ * These are events and data that TPAs can receive from the cloud.
19
+ * Not all message types can be subscribed to as streams.
20
+ */
21
+ var StreamType;
22
+ (function (StreamType) {
23
+ // Hardware streams
24
+ StreamType["BUTTON_PRESS"] = "button_press";
25
+ StreamType["HEAD_POSITION"] = "head_position";
26
+ StreamType["GLASSES_BATTERY_UPDATE"] = "glasses_battery_update";
27
+ StreamType["PHONE_BATTERY_UPDATE"] = "phone_battery_update";
28
+ StreamType["GLASSES_CONNECTION_STATE"] = "glasses_connection_state";
29
+ StreamType["LOCATION_UPDATE"] = "location_update";
30
+ StreamType["VPS_COORDINATES"] = "vps_coordinates";
31
+ // Audio streams
32
+ StreamType["TRANSCRIPTION"] = "transcription";
33
+ StreamType["TRANSLATION"] = "translation";
34
+ StreamType["VAD"] = "VAD";
35
+ StreamType["AUDIO_CHUNK"] = "audio_chunk";
36
+ // Phone streams
37
+ StreamType["PHONE_NOTIFICATION"] = "phone_notification";
38
+ StreamType["NOTIFICATION_DISMISSED"] = "notification_dismissed";
39
+ StreamType["CALENDAR_EVENT"] = "calendar_event";
40
+ // System streams
41
+ StreamType["START_APP"] = "start_app";
42
+ StreamType["STOP_APP"] = "stop_app";
43
+ StreamType["OPEN_DASHBOARD"] = "open_dashboard";
44
+ StreamType["CORE_STATUS_UPDATE"] = "core_status_update";
45
+ // Video streams
46
+ StreamType["VIDEO"] = "video";
47
+ StreamType["PHOTO_REQUEST"] = "photo_request";
48
+ StreamType["PHOTO_RESPONSE"] = "photo_response";
49
+ StreamType["RTMP_STREAM_STATUS"] = "rtmp_stream_status";
50
+ // Special subscription types
51
+ StreamType["ALL"] = "all";
52
+ StreamType["WILDCARD"] = "*";
53
+ // New stream type
54
+ StreamType["AUGMENTOS_SETTINGS_UPDATE_REQUEST"] = "settings_update_request";
55
+ StreamType["CUSTOM_MESSAGE"] = "custom_message";
56
+ StreamType["PHOTO_TAKEN"] = "photo_taken";
57
+ })(StreamType || (exports.StreamType = StreamType = {}));
58
+ /**
59
+ * Categories of stream data
60
+ */
61
+ var StreamCategory;
62
+ (function (StreamCategory) {
63
+ /** Data from hardware sensors */
64
+ StreamCategory["HARDWARE"] = "hardware";
65
+ /** Audio processing results */
66
+ StreamCategory["AUDIO"] = "audio";
67
+ /** Phone-related events */
68
+ StreamCategory["PHONE"] = "phone";
69
+ /** System-level events */
70
+ StreamCategory["SYSTEM"] = "system";
71
+ })(StreamCategory || (exports.StreamCategory = StreamCategory = {}));
72
+ /**
73
+ * Map of stream categories for each stream type
74
+ */
75
+ exports.STREAM_CATEGORIES = {
76
+ [StreamType.BUTTON_PRESS]: StreamCategory.HARDWARE,
77
+ [StreamType.HEAD_POSITION]: StreamCategory.HARDWARE,
78
+ [StreamType.GLASSES_BATTERY_UPDATE]: StreamCategory.HARDWARE,
79
+ [StreamType.PHONE_BATTERY_UPDATE]: StreamCategory.HARDWARE,
80
+ [StreamType.GLASSES_CONNECTION_STATE]: StreamCategory.HARDWARE,
81
+ [StreamType.LOCATION_UPDATE]: StreamCategory.HARDWARE,
82
+ [StreamType.VPS_COORDINATES]: StreamCategory.HARDWARE,
83
+ [StreamType.TRANSCRIPTION]: StreamCategory.AUDIO,
84
+ [StreamType.TRANSLATION]: StreamCategory.AUDIO,
85
+ [StreamType.VAD]: StreamCategory.AUDIO,
86
+ [StreamType.AUDIO_CHUNK]: StreamCategory.AUDIO,
87
+ [StreamType.PHONE_NOTIFICATION]: StreamCategory.PHONE,
88
+ [StreamType.NOTIFICATION_DISMISSED]: StreamCategory.PHONE,
89
+ [StreamType.CALENDAR_EVENT]: StreamCategory.PHONE,
90
+ [StreamType.START_APP]: StreamCategory.SYSTEM,
91
+ [StreamType.STOP_APP]: StreamCategory.SYSTEM,
92
+ [StreamType.OPEN_DASHBOARD]: StreamCategory.SYSTEM,
93
+ [StreamType.CORE_STATUS_UPDATE]: StreamCategory.SYSTEM,
94
+ [StreamType.VIDEO]: StreamCategory.HARDWARE,
95
+ [StreamType.PHOTO_REQUEST]: StreamCategory.HARDWARE,
96
+ [StreamType.PHOTO_RESPONSE]: StreamCategory.HARDWARE,
97
+ [StreamType.RTMP_STREAM_STATUS]: StreamCategory.HARDWARE,
98
+ [StreamType.ALL]: StreamCategory.SYSTEM,
99
+ [StreamType.WILDCARD]: StreamCategory.SYSTEM,
100
+ [StreamType.AUGMENTOS_SETTINGS_UPDATE_REQUEST]: StreamCategory.SYSTEM,
101
+ [StreamType.CUSTOM_MESSAGE]: StreamCategory.SYSTEM,
102
+ [StreamType.PHOTO_TAKEN]: StreamCategory.HARDWARE,
103
+ };
104
+ /**
105
+ * Create a language-branded stream type
106
+ * This is a type helper to ensure type safety for language-specific streams
107
+ */
108
+ function createLanguageStream(type) {
109
+ return type;
110
+ }
111
+ /**
112
+ * Check if a string is a valid language code
113
+ * Simple validation for language code format: xx-XX (e.g., en-US)
114
+ */
115
+ function isValidLanguageCode(code) {
116
+ return /^[a-z]{2,3}-[A-Z]{2}$/.test(code);
117
+ }
118
+ /**
119
+ * Parse a subscription string to extract language information
120
+ *
121
+ * @param subscription Subscription string (e.g., "transcription:en-US" or "translation:es-ES-to-en-US")
122
+ * @returns Parsed language stream info or null if not a language-specific subscription
123
+ */
124
+ function parseLanguageStream(subscription) {
125
+ if (typeof subscription !== 'string') {
126
+ return null;
127
+ }
128
+ // console.log(`🎤 Parsing language stream: ${subscription}`);
129
+ // Handle transcription format (transcription:en-US)
130
+ if (subscription.startsWith(`${StreamType.TRANSCRIPTION}:`)) {
131
+ const [baseType, languageCode] = subscription.split(':');
132
+ // console.log(`🎤 Parsing transcription stream: ${subscription}`);
133
+ // console.log(`🎤 Language code: ${languageCode}`);
134
+ if (languageCode && isValidLanguageCode(languageCode)) {
135
+ return {
136
+ type: StreamType.TRANSCRIPTION,
137
+ baseType,
138
+ transcribeLanguage: languageCode,
139
+ original: subscription
140
+ };
141
+ }
142
+ }
143
+ // Handle translation format (translation:es-ES-to-en-US)
144
+ if (subscription.startsWith(`${StreamType.TRANSLATION}:`)) {
145
+ const [baseType, languagePair] = subscription.split(':');
146
+ const [sourceLanguage, targetLanguage] = languagePair?.split('-to-') ?? [];
147
+ // console.log(`🎤 Parsing translation stream: ${subscription}`);
148
+ // console.log(`🎤 Source language: ${sourceLanguage}`);
149
+ // console.log(`🎤 Target language: ${targetLanguage}`);
150
+ if (sourceLanguage && targetLanguage &&
151
+ isValidLanguageCode(sourceLanguage) &&
152
+ isValidLanguageCode(targetLanguage)) {
153
+ return {
154
+ type: StreamType.TRANSLATION,
155
+ baseType,
156
+ transcribeLanguage: sourceLanguage,
157
+ translateLanguage: targetLanguage,
158
+ original: subscription
159
+ };
160
+ }
161
+ }
162
+ return null;
163
+ }
164
+ /**
165
+ * Create a transcription stream identifier for a specific language
166
+ * Returns a type-safe stream type that can be used like a StreamType
167
+ *
168
+ * @param language Language code (e.g., "en-US")
169
+ * @returns Typed stream identifier
170
+ */
171
+ function createTranscriptionStream(language) {
172
+ if (!isValidLanguageCode(language)) {
173
+ throw new Error(`Invalid language code: ${language}`);
174
+ }
175
+ return createLanguageStream(`${StreamType.TRANSCRIPTION}:${language}`);
176
+ }
177
+ /**
178
+ * Create a translation stream identifier for a language pair
179
+ * Returns a type-safe stream type that can be used like a StreamType
180
+ *
181
+ * @param sourceLanguage Source language code (e.g., "es-ES")
182
+ * @param targetLanguage Target language code (e.g., "en-US")
183
+ * @returns Typed stream identifier
184
+ */
185
+ function createTranslationStream(sourceLanguage, targetLanguage) {
186
+ if (!isValidLanguageCode(sourceLanguage) || !isValidLanguageCode(targetLanguage)) {
187
+ throw new Error(`Invalid language code(s): ${sourceLanguage}, ${targetLanguage}`);
188
+ }
189
+ return createLanguageStream(`${StreamType.TRANSLATION}:${sourceLanguage}-to-${targetLanguage}`);
190
+ }
191
+ /**
192
+ * Check if a subscription is a valid stream type
193
+ * This handles both enum-based StreamType values and language-specific stream formats
194
+ *
195
+ * @param subscription Subscription to validate
196
+ * @returns True if valid, false otherwise
197
+ */
198
+ function isValidStreamType(subscription) {
199
+ // Check if it's a standard StreamType
200
+ if (Object.values(StreamType).includes(subscription)) {
201
+ return true;
202
+ }
203
+ // Check if it's a valid language-specific stream
204
+ const languageStream = parseLanguageStream(subscription);
205
+ return languageStream !== null;
206
+ }
207
+ /**
208
+ * Helper function to check if a stream type is of a particular category
209
+ * Works with both standard and language-specific stream types
210
+ */
211
+ function isStreamCategory(streamType, category) {
212
+ const baseType = getBaseStreamType(streamType);
213
+ return baseType ? exports.STREAM_CATEGORIES[baseType] === category : false;
214
+ }
215
+ /**
216
+ * Helper function to get all stream types in a category
217
+ */
218
+ function getStreamTypesByCategory(category) {
219
+ return Object.entries(exports.STREAM_CATEGORIES)
220
+ .filter(([_, cat]) => cat === category)
221
+ .map(([type]) => type);
222
+ }
223
+ /**
224
+ * Get the base StreamType for a subscription
225
+ * Works with both standard StreamType values and language-specific formats
226
+ *
227
+ * @param subscription Subscription string or StreamType
228
+ * @returns The base StreamType enum value
229
+ */
230
+ function getBaseStreamType(subscription) {
231
+ // Check if it's already a standard StreamType
232
+ if (Object.values(StreamType).includes(subscription)) {
233
+ return subscription;
234
+ }
235
+ // Check if it's a language-specific stream
236
+ const languageStream = parseLanguageStream(subscription);
237
+ return languageStream?.type ?? null;
238
+ }
239
+ /**
240
+ * Check if a stream is a language-specific stream
241
+ */
242
+ function isLanguageStream(subscription) {
243
+ return parseLanguageStream(subscription) !== null;
244
+ }
245
+ /**
246
+ * Get language information from a stream type
247
+ * Returns null for regular stream types
248
+ */
249
+ function getLanguageInfo(subscription) {
250
+ return parseLanguageStream(subscription);
251
+ }
@@ -0,0 +1,41 @@
1
+ /**
2
+ * 🔐 TpaToken Types Module
3
+ *
4
+ * Defines types for the TPA token authentication mechanism.
5
+ */
6
+ /**
7
+ * The payload structure for TPA tokens
8
+ */
9
+ export interface TpaTokenPayload {
10
+ /** User identifier */
11
+ userId: string;
12
+ /** TPA package name */
13
+ packageName: string;
14
+ /** Session identifier */
15
+ sessionId: string;
16
+ /** UNIX timestamp when token was issued (in seconds) */
17
+ iat?: number;
18
+ /** UNIX timestamp when token expires (in seconds) */
19
+ exp?: number;
20
+ }
21
+ /**
22
+ * Response from validating a TPA token
23
+ */
24
+ export interface TokenValidationResult {
25
+ /** Whether the token is valid */
26
+ valid: boolean;
27
+ /** The decoded payload if valid */
28
+ payload?: TpaTokenPayload;
29
+ /** Error message if invalid */
30
+ error?: string;
31
+ }
32
+ /**
33
+ * Configuration for token creation
34
+ */
35
+ export interface TokenConfig {
36
+ /** Secret key used for signing (should match AugmentOS Cloud) */
37
+ secretKey: string;
38
+ /** Token expiration time in seconds (default: 300 - 5 minutes) */
39
+ expiresIn?: number;
40
+ }
41
+ //# sourceMappingURL=token.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../src/types/token.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,sBAAsB;IACtB,MAAM,EAAE,MAAM,CAAC;IAEf,uBAAuB;IACvB,WAAW,EAAE,MAAM,CAAC;IAEpB,yBAAyB;IACzB,SAAS,EAAE,MAAM,CAAC;IAElB,wDAAwD;IACxD,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,qDAAqD;IACrD,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,iCAAiC;IACjC,KAAK,EAAE,OAAO,CAAC;IAEf,mCAAmC;IACnC,OAAO,CAAC,EAAE,eAAe,CAAC;IAE1B,+BAA+B;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,iEAAiE;IACjE,SAAS,EAAE,MAAM,CAAC;IAElB,kEAAkE;IAClE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /**
3
+ * 🔐 TpaToken Types Module
4
+ *
5
+ * Defines types for the TPA token authentication mechanism.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,73 @@
1
+ import { WebSocket } from 'ws';
2
+ import { AppI, TranscriptI } from './models';
3
+ import { DisplayRequest } from './layouts';
4
+ import { Transform } from 'stream';
5
+ import { ConversationTranscriber, PushAudioInputStream } from 'microsoft-cognitiveservices-speech-sdk';
6
+ import { ExtendedStreamType } from './streams';
7
+ import pino from 'pino';
8
+ /**
9
+ * Session for an application
10
+ */
11
+ /**
12
+ * Audio processor configuration
13
+ */
14
+ export interface AudioProcessorConfig {
15
+ threshold: number;
16
+ ratio: number;
17
+ attack: number;
18
+ release: number;
19
+ gainDb: number;
20
+ sampleRate: number;
21
+ channels: number;
22
+ }
23
+ /**
24
+ * Audio processor interface
25
+ */
26
+ export interface AudioProcessorI extends Transform {
27
+ }
28
+ /**
29
+ * The display manager interface
30
+ */
31
+ export interface DisplayManagerI {
32
+ handleDisplayEvent(displayRequest: DisplayRequest, userSession: UserSession): boolean;
33
+ handleAppStart(packageName: string, userSession: UserSession): void;
34
+ handleAppStop(packageName: string, userSession: UserSession): void;
35
+ }
36
+ /**
37
+ * Currently active display
38
+ */
39
+ export interface ActiveDisplay {
40
+ displayRequest: DisplayRequest;
41
+ startedAt: Date;
42
+ expiresAt?: Date;
43
+ }
44
+ /**
45
+ * User session with glasses client
46
+ */
47
+ export interface UserSession {
48
+ sessionId: string;
49
+ userId: string;
50
+ startTime: Date;
51
+ disconnectedAt: Date | null;
52
+ logger: pino.Logger;
53
+ installedApps: AppI[];
54
+ activeAppSessions: string[];
55
+ loadingApps: Set<string>;
56
+ appSubscriptions: Map<string, ExtendedStreamType[]> | Object;
57
+ appConnections: Map<string, WebSocket>;
58
+ websocket: WebSocket;
59
+ transcript: TranscriptI;
60
+ pushStream?: PushAudioInputStream;
61
+ recognizer?: ConversationTranscriber;
62
+ isTranscribing: boolean;
63
+ lastAudioTimestamp?: number;
64
+ isGracefullyClosing?: boolean;
65
+ bufferedAudio: ArrayBufferLike[];
66
+ audioProcessor?: AudioProcessorI;
67
+ isAudioProcessing?: boolean;
68
+ whatToStream: ExtendedStreamType[];
69
+ }
70
+ /**
71
+ * App session within a user session
72
+ */
73
+ //# sourceMappingURL=user-session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-session.d.ts","sourceRoot":"","sources":["../../src/types/user-session.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAe,WAAW,EAAE,MAAM,UAAU,CAAC;AAE1D,OAAO,EAAE,cAAc,EAAU,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EACL,uBAAuB,EACvB,oBAAoB,EACrB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAc,MAAM,WAAW,CAAC;AAE3D,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;GAEG;AAkBH;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,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AAC;IAC5B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAG9B,aAAa,EAAE,eAAe,EAAE,CAAC;IAGjC,cAAc,CAAC,EAAE,eAAe,CAAC;IACjC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAG5B,YAAY,EAAE,kBAAkB,EAAE,CAAC;CACpC;AAED;;GAEG"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ // src/sessions.ts - Session-related interfaces
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ /**
5
+ * App session within a user session
6
+ */
7
+ // This is not actually used anywhere so i commented it out.
8
+ // export interface AppSession {
9
+ // packageName: string;
10
+ // userId: string;
11
+ // subscriptions: StreamType[];
12
+ // settings: AppSettings;
13
+ // websocket?: WebSocket;
14
+ // state: AppState;
15
+ // startTime: Date;
16
+ // lastActiveTime: Date;
17
+ // }
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Types of webhook requests that can be sent to TPAs
3
+ */
4
+ export declare enum WebhookRequestType {
5
+ /** Request to start a TPA session */
6
+ SESSION_REQUEST = "session_request",
7
+ /** Request to stop a TPA session */
8
+ STOP_REQUEST = "stop_request",
9
+ /** Server registration confirmation */
10
+ SERVER_REGISTRATION = "server_registration",
11
+ /** Server heartbeat response */
12
+ SERVER_HEARTBEAT = "server_heartbeat",
13
+ /** Session recovery request */
14
+ SESSION_RECOVERY = "session_recovery"
15
+ }
16
+ /**
17
+ * Base interface for all webhook requests
18
+ */
19
+ export interface BaseWebhookRequest {
20
+ /** Type of webhook request */
21
+ type: WebhookRequestType;
22
+ /** Session ID for the request */
23
+ sessionId: string;
24
+ /** User ID associated with the session */
25
+ userId: string;
26
+ /** Timestamp of the request */
27
+ timestamp: string;
28
+ }
29
+ /**
30
+ * Session request webhook
31
+ *
32
+ * Sent to a TPA when a user starts the TPA
33
+ */
34
+ export interface SessionWebhookRequest extends BaseWebhookRequest {
35
+ type: WebhookRequestType.SESSION_REQUEST;
36
+ augmentOSWebsocketUrl?: string;
37
+ }
38
+ /**
39
+ * Stop request webhook
40
+ *
41
+ * Sent to a TPA when a user or the system stops the TPA
42
+ */
43
+ export interface StopWebhookRequest extends BaseWebhookRequest {
44
+ type: WebhookRequestType.STOP_REQUEST;
45
+ reason: 'user_disabled' | 'system_stop' | 'error';
46
+ }
47
+ /**
48
+ * Server registration webhook
49
+ *
50
+ * Sent to a TPA when its server registration is confirmed
51
+ */
52
+ export interface ServerRegistrationWebhookRequest extends BaseWebhookRequest {
53
+ type: WebhookRequestType.SERVER_REGISTRATION;
54
+ registrationId: string;
55
+ packageName: string;
56
+ serverUrls: string[];
57
+ }
58
+ /**
59
+ * Session recovery webhook
60
+ *
61
+ * Sent to a TPA when the system is trying to recover a session after server restart
62
+ */
63
+ export interface SessionRecoveryWebhookRequest extends BaseWebhookRequest {
64
+ type: WebhookRequestType.SESSION_RECOVERY;
65
+ augmentOSWebsocketUrl: string;
66
+ }
67
+ /**
68
+ * Server heartbeat webhook
69
+ *
70
+ * Sent to a TPA to check its health status
71
+ */
72
+ export interface ServerHeartbeatWebhookRequest extends BaseWebhookRequest {
73
+ type: WebhookRequestType.SERVER_HEARTBEAT;
74
+ registrationId: string;
75
+ }
76
+ /**
77
+ * Union type for all webhook requests
78
+ */
79
+ export type WebhookRequest = SessionWebhookRequest | StopWebhookRequest | ServerRegistrationWebhookRequest | SessionRecoveryWebhookRequest | ServerHeartbeatWebhookRequest;
80
+ /**
81
+ * Response to a webhook request
82
+ */
83
+ export interface WebhookResponse {
84
+ status: 'success' | 'error';
85
+ message?: string;
86
+ }
87
+ /**
88
+ * Type guard to check if a webhook request is a session request
89
+ */
90
+ export declare function isSessionWebhookRequest(request: WebhookRequest): request is SessionWebhookRequest;
91
+ /**
92
+ * Type guard to check if a webhook request is a stop request
93
+ */
94
+ export declare function isStopWebhookRequest(request: WebhookRequest): request is StopWebhookRequest;
95
+ /**
96
+ * Type guard to check if a webhook request is a server registration request
97
+ */
98
+ export declare function isServerRegistrationWebhookRequest(request: WebhookRequest): request is ServerRegistrationWebhookRequest;
99
+ /**
100
+ * Type guard to check if a webhook request is a session recovery request
101
+ */
102
+ export declare function isSessionRecoveryWebhookRequest(request: WebhookRequest): request is SessionRecoveryWebhookRequest;
103
+ /**
104
+ * Type guard to check if a webhook request is a server heartbeat request
105
+ */
106
+ export declare function isServerHeartbeatWebhookRequest(request: WebhookRequest): request is ServerHeartbeatWebhookRequest;
107
+ //# sourceMappingURL=webhooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../../src/types/webhooks.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,oBAAY,kBAAkB;IAC5B,qCAAqC;IACrC,eAAe,oBAAoB;IAEnC,oCAAoC;IACpC,YAAY,iBAAiB;IAE7B,uCAAuC;IACvC,mBAAmB,wBAAwB;IAE3C,gCAAgC;IAChC,gBAAgB,qBAAqB;IAErC,+BAA+B;IAC/B,gBAAgB,qBAAqB;CACtC;AAEC;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,8BAA8B;IAC9B,IAAI,EAAE,kBAAkB,CAAC;IAEzB,iCAAiC;IACjC,SAAS,EAAE,MAAM,CAAC;IAElB,0CAA0C;IAC1C,MAAM,EAAE,MAAM,CAAC;IAEf,+BAA+B;IAC/B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,qBAAsB,SAAQ,kBAAkB;IAC/D,IAAI,EAAE,kBAAkB,CAAC,eAAe,CAAC;IACzC,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED;;;;GAIG;AACH,MAAM,WAAW,kBAAmB,SAAQ,kBAAkB;IAC5D,IAAI,EAAE,kBAAkB,CAAC,YAAY,CAAC;IACtC,MAAM,EAAE,eAAe,GAAG,aAAa,GAAG,OAAO,CAAC;CACnD;AAED;;;;GAIG;AACH,MAAM,WAAW,gCAAiC,SAAQ,kBAAkB;IAC1E,IAAI,EAAE,kBAAkB,CAAC,mBAAm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