@recallai/desktop-sdk 2025.3.24-281fab31aa87043b2fbe0ed81ae984c326e4d33e → 2025.3.24-8aba6fcafe81656498e80d8125b215a37fd1c982
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.
- package/desktop_sdk_macos_exe +0 -0
- package/desktop_sdk_macos_frameworks.tar +0 -0
- package/index.d.ts +3 -2
- package/index.js +66 -8
- package/package.json +6 -2
package/desktop_sdk_macos_exe
CHANGED
|
Binary file
|
|
Binary file
|
package/index.d.ts
CHANGED
|
@@ -60,7 +60,8 @@ declare module '@recallai/desktop-sdk' {
|
|
|
60
60
|
|
|
61
61
|
export interface RecallAiSdkConfig {
|
|
62
62
|
api_url: string;
|
|
63
|
-
acquirePermissionsOnStartup?: Permission[]
|
|
63
|
+
acquirePermissionsOnStartup?: Permission[];
|
|
64
|
+
restartOnError?: boolean;
|
|
64
65
|
}
|
|
65
66
|
|
|
66
67
|
export interface StartRecordingConfig {
|
|
@@ -129,7 +130,7 @@ declare module '@recallai/desktop-sdk' {
|
|
|
129
130
|
|
|
130
131
|
export interface PermissionStatusEvent {
|
|
131
132
|
permission: Permission;
|
|
132
|
-
granted:
|
|
133
|
+
granted: boolean;
|
|
133
134
|
}
|
|
134
135
|
|
|
135
136
|
export interface ErrorEvent {
|
package/index.js
CHANGED
|
@@ -45,6 +45,41 @@ let proc;
|
|
|
45
45
|
const listeners = [];
|
|
46
46
|
const pendingCommands = {};
|
|
47
47
|
|
|
48
|
+
let lastOptions;
|
|
49
|
+
let remainingAutomaticRestarts = 10;
|
|
50
|
+
let unexpectedShutdown = false;
|
|
51
|
+
|
|
52
|
+
async function doLog(level, log) {
|
|
53
|
+
try {
|
|
54
|
+
const levelMap = {
|
|
55
|
+
"info": "log",
|
|
56
|
+
"warning": "warn",
|
|
57
|
+
"error": "error"
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
console[levelMap[level]](...log);
|
|
61
|
+
|
|
62
|
+
await sendCommand("log", {
|
|
63
|
+
log: log.join(" "),
|
|
64
|
+
level: level
|
|
65
|
+
});
|
|
66
|
+
} catch (e) {
|
|
67
|
+
//console.error("Log failed:", e.message, e.stack);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function log(...log) {
|
|
72
|
+
doLog("info", log);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function logWarning(...log) {
|
|
76
|
+
doLog("warning", log);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function logError(...log) {
|
|
80
|
+
doLog("error", log);
|
|
81
|
+
}
|
|
82
|
+
|
|
48
83
|
function emitEvent(type, payload) {
|
|
49
84
|
for (const listener of listeners) {
|
|
50
85
|
if (listener.type === type)
|
|
@@ -65,12 +100,12 @@ function startProcess() {
|
|
|
65
100
|
const exe_path = exe_paths.find(fs.existsSync);
|
|
66
101
|
|
|
67
102
|
if (!exe_path) {
|
|
68
|
-
|
|
103
|
+
logError(`Desktop SDK: Couldn't launch! This is likely an issue with the build tool you're using.`);
|
|
69
104
|
|
|
70
105
|
for (const exe_path of exe_paths)
|
|
71
|
-
|
|
106
|
+
logError("Tried:", exe_path);
|
|
72
107
|
|
|
73
|
-
|
|
108
|
+
log();
|
|
74
109
|
|
|
75
110
|
return;
|
|
76
111
|
}
|
|
@@ -117,7 +152,7 @@ function startProcess() {
|
|
|
117
152
|
break;
|
|
118
153
|
}
|
|
119
154
|
} catch (err) {
|
|
120
|
-
|
|
155
|
+
logError("Desktop SDK: Failed to parse incoming data:", err);
|
|
121
156
|
}
|
|
122
157
|
});
|
|
123
158
|
|
|
@@ -127,7 +162,7 @@ function startProcess() {
|
|
|
127
162
|
type: 'process',
|
|
128
163
|
message: `The Desktop SDK server process has failed to start or exited improperly.`
|
|
129
164
|
});
|
|
130
|
-
|
|
165
|
+
logError(`Desktop SDK: Process error: ${error.message}`);
|
|
131
166
|
});
|
|
132
167
|
|
|
133
168
|
proc.on('close', (code, signal) => {
|
|
@@ -137,12 +172,20 @@ function startProcess() {
|
|
|
137
172
|
if (code === 0 || signal == 'SIGINT')
|
|
138
173
|
return;
|
|
139
174
|
|
|
140
|
-
|
|
175
|
+
logError(`Desktop SDK: Process exited with code ${code}, signal ${signal}`);
|
|
141
176
|
|
|
142
177
|
emitEvent('error', {
|
|
143
178
|
type: 'process',
|
|
144
179
|
message: "The Desktop SDK server process exited unexpectedly."
|
|
145
180
|
});
|
|
181
|
+
|
|
182
|
+
unexpectedShutdown = true;
|
|
183
|
+
|
|
184
|
+
if (lastOptions.restartOnError && remainingAutomaticRestarts > 0) {
|
|
185
|
+
remainingAutomaticRestarts--;
|
|
186
|
+
console.error("Automatically restarting Desktop SDK due to unexpected exit!");
|
|
187
|
+
doInit(lastOptions);
|
|
188
|
+
}
|
|
146
189
|
});
|
|
147
190
|
}
|
|
148
191
|
|
|
@@ -166,14 +209,29 @@ function sendCommand(command, params = {}) {
|
|
|
166
209
|
});
|
|
167
210
|
}
|
|
168
211
|
|
|
212
|
+
function doInit(options) {
|
|
213
|
+
startProcess();
|
|
214
|
+
|
|
215
|
+
if (unexpectedShutdown) {
|
|
216
|
+
logError("Desktop SDK: Recovered from unexpected shutdown");
|
|
217
|
+
unexpectedShutdown = false;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return sendCommand("init", { config: JSON.stringify(options) });
|
|
221
|
+
}
|
|
222
|
+
|
|
169
223
|
function init(options) {
|
|
170
224
|
let { api_url, dev } = options;
|
|
225
|
+
|
|
171
226
|
if (!dev && (!api_url || !api_url.startsWith("https"))) {
|
|
172
227
|
throw new Error(`api_url must be an https url, got: ${api_url}`);
|
|
173
228
|
}
|
|
174
229
|
|
|
175
|
-
|
|
176
|
-
|
|
230
|
+
if (options.restartOnError === undefined)
|
|
231
|
+
options.restartOnError = true;
|
|
232
|
+
|
|
233
|
+
lastOptions = options;
|
|
234
|
+
doInit(options);
|
|
177
235
|
}
|
|
178
236
|
|
|
179
237
|
async function shutdown() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@recallai/desktop-sdk",
|
|
3
|
-
"version": "2025.03.24-
|
|
3
|
+
"version": "2025.03.24-8aba6fcafe81656498e80d8125b215a37fd1c982",
|
|
4
4
|
"description": "Recall Desktop SDK (Alpha)",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"types": "./index.d.ts",
|
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
"uuid": "^11.1.0"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
|
-
"install": "./unpack-frameworks.sh"
|
|
11
|
+
"install": "./unpack-frameworks.sh",
|
|
12
|
+
"validate-types": "tsc --noEmit index.d.ts"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"typescript": "^5.3.3"
|
|
12
16
|
}
|
|
13
17
|
}
|