@recallai/desktop-sdk 2025.6.23-425eeb0809b1dcbef42a7fecef4c80180352f8c2 → 2025.6.27-0d4239d0dac9f065eb2fad92dbb784286c1358e8
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/index.js +53 -43
- package/package.json +4 -1
- package/setup.js +68 -20
- package/desktop_sdk_macos_exe +0 -0
- package/desktop_sdk_macos_frameworks.tar +0 -0
package/index.js
CHANGED
|
@@ -2,6 +2,7 @@ const path = require('path');
|
|
|
2
2
|
const { spawn } = require('child_process');
|
|
3
3
|
const readline = require('node:readline');
|
|
4
4
|
const fs = require('node:fs');
|
|
5
|
+
const os = require("node:os");
|
|
5
6
|
const { v4: uuidv4 } = require('uuid');
|
|
6
7
|
|
|
7
8
|
// HACK: This is needed because of https://github.com/electron/electron/issues/6262
|
|
@@ -11,7 +12,9 @@ const { v4: uuidv4 } = require('uuid');
|
|
|
11
12
|
|
|
12
13
|
const exe_paths = [
|
|
13
14
|
path.join(__dirname, "desktop_sdk_macos_exe").replace('app.asar', 'app.asar.unpacked'),
|
|
14
|
-
path.join(__dirname, "desktop_sdk_macos_exe")
|
|
15
|
+
path.join(__dirname, "desktop_sdk_macos_exe"),
|
|
16
|
+
path.join(__dirname, "agent-windows.exe").replace('app.asar', 'app.asar.unpacked'),
|
|
17
|
+
path.join(__dirname, "agent-windows.exe")
|
|
15
18
|
];
|
|
16
19
|
|
|
17
20
|
let proc;
|
|
@@ -83,59 +86,64 @@ function startProcess() {
|
|
|
83
86
|
return;
|
|
84
87
|
}
|
|
85
88
|
|
|
89
|
+
let envExtra = {};
|
|
90
|
+
|
|
91
|
+
if (process.platform === "win32") {
|
|
92
|
+
envExtra["GST_PLUGIN_PATH"] = path.join(path.dirname(exe_path), "gstreamer-1.0");
|
|
93
|
+
}
|
|
94
|
+
|
|
86
95
|
proc = spawn(exe_path, {
|
|
87
|
-
stdio:
|
|
96
|
+
stdio: "pipe",
|
|
88
97
|
env: {
|
|
89
98
|
"GST_DEBUG": "2",
|
|
90
|
-
"GST_DEBUG_DUMP_DOT_DIR":
|
|
91
|
-
|
|
99
|
+
"GST_DEBUG_DUMP_DOT_DIR": os.tmpdir(),
|
|
100
|
+
...envExtra,
|
|
92
101
|
}
|
|
93
102
|
});
|
|
94
103
|
|
|
95
|
-
const extraStream = proc.stdio[3];
|
|
96
|
-
|
|
97
|
-
const rl = readline.createInterface({ input: extraStream, crlfDelay: Infinity });
|
|
98
104
|
const rlStdout = readline.createInterface({ input: proc.stdout, crlfDelay: Infinity });
|
|
99
105
|
const rlStderr = readline.createInterface({ input: proc.stderr, crlfDelay: Infinity });
|
|
100
106
|
|
|
101
|
-
rlStdout.on('line', (
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
if (data.status === "success") {
|
|
125
|
-
pendingCommand.resolve(data.result);
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
pendingCommand.reject(new Error(data.result));
|
|
107
|
+
rlStdout.on('line', (line) => {
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
if (line.startsWith("recall_ai_command|")) {
|
|
111
|
+
try {
|
|
112
|
+
const data = JSON.parse(line.substring(18));
|
|
113
|
+
|
|
114
|
+
switch (data.type) {
|
|
115
|
+
case "event":
|
|
116
|
+
const event = JSON.parse(data.event);
|
|
117
|
+
emitEvent(event.type, event.payload);
|
|
118
|
+
break;
|
|
119
|
+
|
|
120
|
+
case "response":
|
|
121
|
+
const pendingCommand = pendingCommands[data.commandId];
|
|
122
|
+
if (pendingCommand) {
|
|
123
|
+
if (data.status === "success") {
|
|
124
|
+
pendingCommand.resolve(data.result);
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
pendingCommand.reject(new Error(data.result));
|
|
128
|
+
}
|
|
129
|
+
delete pendingCommands[data.commandId];
|
|
129
130
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
} catch (err) {
|
|
134
|
+
logError("Desktop SDK: Failed to parse incoming data:", err);
|
|
133
135
|
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
+
} else {
|
|
137
|
+
if (process.env.RECALLAI_DESKTOP_SDK_DEV)
|
|
138
|
+
console.log(line);
|
|
136
139
|
}
|
|
137
140
|
});
|
|
138
141
|
|
|
142
|
+
rlStderr.on('line', (line) => {
|
|
143
|
+
if (process.env.RECALLAI_DESKTOP_SDK_DEV)
|
|
144
|
+
console.error(line);
|
|
145
|
+
});
|
|
146
|
+
|
|
139
147
|
proc.on('error', (error) => {
|
|
140
148
|
flushPendingCommands(new Error(`Process error: ${error.message}`));
|
|
141
149
|
emitEvent('error', {
|
|
@@ -200,8 +208,10 @@ function doInit(options) {
|
|
|
200
208
|
return sendCommand("init", { config: JSON.stringify(options) });
|
|
201
209
|
}
|
|
202
210
|
|
|
203
|
-
function init(options) {
|
|
204
|
-
if (process.platform !== "darwin"
|
|
211
|
+
async function init(options) {
|
|
212
|
+
if (process.platform !== "darwin"
|
|
213
|
+
&& process.platform !== "win32"
|
|
214
|
+
) {
|
|
205
215
|
throw new Error(`Platform ${process.platform} is not supported by Desktop SDK`);
|
|
206
216
|
}
|
|
207
217
|
|
|
@@ -217,7 +227,7 @@ function init(options) {
|
|
|
217
227
|
options.restartOnError = true;
|
|
218
228
|
|
|
219
229
|
lastOptions = options;
|
|
220
|
-
doInit(options);
|
|
230
|
+
return doInit(options);
|
|
221
231
|
}
|
|
222
232
|
|
|
223
233
|
async function shutdown() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@recallai/desktop-sdk",
|
|
3
|
-
"version": "2025.06.
|
|
3
|
+
"version": "2025.06.27-0d4239d0dac9f065eb2fad92dbb784286c1358e8",
|
|
4
4
|
"description": "Recall Desktop SDK (Alpha)",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"types": "./index.d.ts",
|
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
"tar": "^7.4.3",
|
|
9
9
|
"uuid": "^11.1.0"
|
|
10
10
|
},
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": ">=18.0.0"
|
|
13
|
+
},
|
|
11
14
|
"scripts": {
|
|
12
15
|
"install": "node ./setup.js",
|
|
13
16
|
"validate-types": "tsc --noEmit index.d.ts"
|
package/setup.js
CHANGED
|
@@ -1,48 +1,96 @@
|
|
|
1
1
|
const fs = require("fs");
|
|
2
2
|
const path = require("path");
|
|
3
3
|
const tar = require("tar");
|
|
4
|
+
const { Readable } = require("stream");
|
|
5
|
+
const { finished } = require("stream/promises");
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
7
|
+
const nativeTarPathMacOS = path.join(__dirname, "desktop_sdk_macos.tar");
|
|
8
|
+
const nativeTarPathWin32 = path.join(__dirname, "desktop_sdk_win32.tar");
|
|
9
|
+
const nativeUrlBase = "https://recallai-desktop-sdk-releases.s3.us-east-1.amazonaws.com";
|
|
10
|
+
|
|
11
|
+
async function downloadFile(url, path) {
|
|
12
|
+
const stream = fs.createWriteStream(path);
|
|
13
|
+
const { body } = await fetch(url);
|
|
14
|
+
await finished(Readable.fromWeb(body).pipe(stream));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async function cleanup() {
|
|
18
|
+
for (const platform of [nativeTarPathMacOS, nativeTarPathWin32]) {
|
|
19
|
+
try {
|
|
20
|
+
fs.unlinkSync(platform);
|
|
21
|
+
} catch (e) {
|
|
22
|
+
// Nothing.
|
|
19
23
|
}
|
|
20
24
|
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async function setupMacOS(version) {
|
|
28
|
+
await downloadFile(`${nativeUrlBase}/${version}/desktop_sdk_macos.tar`, nativeTarPathMacOS);
|
|
29
|
+
|
|
30
|
+
if (!fs.existsSync(nativeTarPathMacOS)) {
|
|
31
|
+
console.error("Missing native platform tar file");
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const frameworksDir = path.join(__dirname, "Frameworks");
|
|
36
|
+
|
|
37
|
+
if (fs.existsSync(frameworksDir)) {
|
|
38
|
+
fs.rmSync(frameworksDir, { recursive: true, force: true });
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
try {
|
|
42
|
+
await tar.extract({ file: nativeTarPathMacOS, cwd: __dirname });
|
|
43
|
+
} catch (e) {
|
|
44
|
+
console.error("Error extracting tar file:", e);
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
await cleanup();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async function setupWin32(version) {
|
|
52
|
+
await downloadFile(`${nativeUrlBase}/${version}/desktop_sdk_win32.tar`, nativeTarPathWin32);
|
|
53
|
+
|
|
54
|
+
if (!fs.existsSync(nativeTarPathWin32)) {
|
|
55
|
+
console.error("Missing native platform tar file");
|
|
56
|
+
process.exit(1);
|
|
57
|
+
}
|
|
21
58
|
|
|
22
|
-
|
|
23
|
-
|
|
59
|
+
const gstreamerDir = path.join(__dirname, "gstreamer-1.0");
|
|
60
|
+
|
|
61
|
+
if (fs.existsSync(gstreamerDir)) {
|
|
62
|
+
fs.rmSync(gstreamerDir, { recursive: true, force: true });
|
|
24
63
|
}
|
|
25
64
|
|
|
26
65
|
try {
|
|
27
|
-
await tar.extract({ file:
|
|
66
|
+
await tar.extract({ file: nativeTarPathWin32, cwd: __dirname });
|
|
28
67
|
} catch (e) {
|
|
29
68
|
console.error("Error extracting tar file:", e);
|
|
30
69
|
process.exit(1);
|
|
31
70
|
}
|
|
32
71
|
|
|
33
|
-
|
|
72
|
+
await cleanup();
|
|
34
73
|
}
|
|
35
74
|
|
|
36
75
|
async function setup() {
|
|
76
|
+
const package = fs.readFileSync("./package.json");
|
|
77
|
+
const packageJson = JSON.parse(package);
|
|
78
|
+
const version = packageJson["version"].split("-")[1];
|
|
79
|
+
|
|
80
|
+
console.log(`Downloading native sdk for version: ${version}, platform: ${process.platform}`);
|
|
81
|
+
|
|
37
82
|
if (process.platform === "darwin") {
|
|
38
|
-
await setupMacOS();
|
|
83
|
+
await setupMacOS(version);
|
|
84
|
+
} else if (process.platform === "win32") {
|
|
85
|
+
await setupWin32(version);
|
|
39
86
|
} else {
|
|
40
87
|
console.warn("Unsupported platform, Desktop SDK will not be available.");
|
|
88
|
+
await cleanup();
|
|
41
89
|
}
|
|
42
90
|
}
|
|
43
91
|
|
|
44
92
|
if (process.env.RECALL_LOCAL_BUILD) {
|
|
45
|
-
console.log("Doing local build, skipping
|
|
93
|
+
console.log("Doing local build, skipping platform native install");
|
|
46
94
|
} else {
|
|
47
95
|
setup();
|
|
48
96
|
}
|
package/desktop_sdk_macos_exe
DELETED
|
Binary file
|
|
Binary file
|