@frumu/tandem 0.3.4 → 0.3.6
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/bin/tandem-engine.js +17 -0
- package/package.json +30 -30
- package/scripts/install.js +178 -178
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const { spawnSync } = require("child_process");
|
|
5
|
+
|
|
6
|
+
const binaryName = process.platform === "win32" ? "tandem-engine.exe" : "tandem-engine";
|
|
7
|
+
const binaryPath = path.join(__dirname, "native", binaryName);
|
|
8
|
+
|
|
9
|
+
const child = spawnSync(binaryPath, process.argv.slice(2), { stdio: "inherit" });
|
|
10
|
+
|
|
11
|
+
if (child.error) {
|
|
12
|
+
console.error("tandem-engine binary is missing. Reinstall with: npm i -g @frumu/tandem");
|
|
13
|
+
console.error(child.error.message);
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
process.exit(child.status ?? 1);
|
package/package.json
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@frumu/tandem",
|
|
3
|
-
"version": "0.3.
|
|
4
|
-
"description": "Tandem Engine binary distribution",
|
|
5
|
-
"homepage": "https://tandem.frumu.ai",
|
|
1
|
+
{
|
|
2
|
+
"name": "@frumu/tandem",
|
|
3
|
+
"version": "0.3.6",
|
|
4
|
+
"description": "Tandem Engine binary distribution",
|
|
5
|
+
"homepage": "https://tandem.frumu.ai",
|
|
6
6
|
"bin": {
|
|
7
|
-
"tandem-engine": "bin/tandem-engine"
|
|
7
|
+
"tandem-engine": "bin/tandem-engine.js"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
|
-
"postinstall": "node
|
|
10
|
+
"postinstall": "node scripts/install.js"
|
|
11
11
|
},
|
|
12
|
-
"files": [
|
|
13
|
-
"bin",
|
|
14
|
-
"scripts"
|
|
15
|
-
],
|
|
16
|
-
"repository": {
|
|
17
|
-
"type": "git",
|
|
18
|
-
"url": "git+https://github.com/frumu-ai/tandem.git"
|
|
19
|
-
},
|
|
20
|
-
"author": "Frumu Ltd",
|
|
21
|
-
"license": "MIT OR Apache-2.0",
|
|
22
|
-
"publishConfig": {
|
|
23
|
-
"access": "public"
|
|
24
|
-
},
|
|
25
|
-
"os": [
|
|
26
|
-
"darwin",
|
|
27
|
-
"linux",
|
|
28
|
-
"win32"
|
|
29
|
-
],
|
|
30
|
-
"cpu": [
|
|
31
|
-
"x64",
|
|
32
|
-
"arm64"
|
|
33
|
-
]
|
|
34
|
-
}
|
|
12
|
+
"files": [
|
|
13
|
+
"bin",
|
|
14
|
+
"scripts"
|
|
15
|
+
],
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/frumu-ai/tandem.git"
|
|
19
|
+
},
|
|
20
|
+
"author": "Frumu Ltd",
|
|
21
|
+
"license": "MIT OR Apache-2.0",
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public"
|
|
24
|
+
},
|
|
25
|
+
"os": [
|
|
26
|
+
"darwin",
|
|
27
|
+
"linux",
|
|
28
|
+
"win32"
|
|
29
|
+
],
|
|
30
|
+
"cpu": [
|
|
31
|
+
"x64",
|
|
32
|
+
"arm64"
|
|
33
|
+
]
|
|
34
|
+
}
|
package/scripts/install.js
CHANGED
|
@@ -1,178 +1,178 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const https = require('https');
|
|
4
|
-
const { execSync } = require('child_process');
|
|
5
|
-
|
|
6
|
-
// Configuration
|
|
7
|
-
const REPO = "frumu-ai/tandem";
|
|
8
|
-
const MIN_SIZE = 1024 * 1024; // 1MB
|
|
9
|
-
|
|
10
|
-
// Platform mapping
|
|
11
|
-
const PLATFORM_MAP = {
|
|
12
|
-
'win32': { os: 'windows', ext: '.exe' },
|
|
13
|
-
'darwin': { os: 'darwin', ext: '' },
|
|
14
|
-
'linux': { os: 'linux', ext: '' }
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const ARCH_MAP = {
|
|
18
|
-
'x64': 'x64',
|
|
19
|
-
'arm64': 'arm64'
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
function getArtifactInfo() {
|
|
23
|
-
const platform = PLATFORM_MAP[process.platform];
|
|
24
|
-
const arch = ARCH_MAP[process.arch];
|
|
25
|
-
|
|
26
|
-
if (!platform || !arch) {
|
|
27
|
-
throw new Error(`Unsupported platform: ${process.platform}-${process.arch}`);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
let artifactName = `tandem-engine-${platform.os}-${arch}`;
|
|
31
|
-
// Handle specific artifact naming conventions (zip vs tar.gz)
|
|
32
|
-
if (platform.os === 'windows') {
|
|
33
|
-
artifactName += '.zip';
|
|
34
|
-
} else if (platform.os === 'darwin') {
|
|
35
|
-
artifactName += '.zip';
|
|
36
|
-
} else {
|
|
37
|
-
artifactName += '.tar.gz';
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return {
|
|
41
|
-
artifactName,
|
|
42
|
-
binaryName: `tandem-engine${platform.ext}`,
|
|
43
|
-
isWindows: platform.os === 'windows'
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const { artifactName, binaryName, isWindows } = getArtifactInfo();
|
|
48
|
-
const binDir = path.join(__dirname, '..', 'bin');
|
|
49
|
-
const destPath = path.join(binDir, binaryName);
|
|
50
|
-
|
|
51
|
-
if (!fs.existsSync(binDir)) {
|
|
52
|
-
fs.mkdirSync(binDir, { recursive: true });
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (fs.existsSync(destPath)) {
|
|
56
|
-
console.log("Binary already present.");
|
|
57
|
-
process.exit(0);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Helper to fetch JSON from GitHub API
|
|
61
|
-
function fetchJson(url) {
|
|
62
|
-
return new Promise((resolve, reject) => {
|
|
63
|
-
https.get(url, { headers: { 'User-Agent': 'tandem-engine-installer' } }, (res) => {
|
|
64
|
-
if (res.statusCode !== 200) {
|
|
65
|
-
if (res.statusCode === 302 || res.statusCode === 301) {
|
|
66
|
-
return fetchJson(res.headers.location).then(resolve).catch(reject);
|
|
67
|
-
}
|
|
68
|
-
return reject(new Error(`GitHub API HTTP ${res.statusCode}`));
|
|
69
|
-
}
|
|
70
|
-
let data = '';
|
|
71
|
-
res.on('data', chunk => data += chunk);
|
|
72
|
-
res.on('end', () => {
|
|
73
|
-
try { resolve(JSON.parse(data)); } catch (e) { reject(e); }
|
|
74
|
-
});
|
|
75
|
-
}).on('error', reject);
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// Simplified download
|
|
80
|
-
async function download() {
|
|
81
|
-
console.log(`Checking releases for ${REPO}...`);
|
|
82
|
-
const releases = await fetchJson(`https://api.github.com/repos/${REPO}/releases`);
|
|
83
|
-
|
|
84
|
-
// Get the version from package.json
|
|
85
|
-
const packageVersion = require('../package.json').version;
|
|
86
|
-
const targetTag = `v${packageVersion}`;
|
|
87
|
-
|
|
88
|
-
console.log(`Filtering releases for ${REPO} (Target: ${targetTag})...`);
|
|
89
|
-
// const releases = await fetchJson... <--- REMOVED DUPLICATE
|
|
90
|
-
|
|
91
|
-
// 1. Try to find the exact release for this package version
|
|
92
|
-
let release = releases.find(r => r.tag_name === targetTag);
|
|
93
|
-
|
|
94
|
-
if (!release) {
|
|
95
|
-
console.warn(`Warning: No release found for tag ${targetTag}. Checking for latest compatible assets...`);
|
|
96
|
-
// 2. Fallback: Find LATEST release that contains our asset (useful for nightly/beta where tags might differ)
|
|
97
|
-
release = releases.find(r => r.assets.some(a => a.name === artifactName));
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
if (!release) {
|
|
101
|
-
// Fallback: Check prereleases explicitly if strict filtering was on (it wasn't here)
|
|
102
|
-
// If not found, maybe name changed?
|
|
103
|
-
console.error(`Status: No release found with asset ${artifactName}`);
|
|
104
|
-
console.error("Available assets in latest:", releases[0]?.assets?.map(a => a.name));
|
|
105
|
-
process.exit(1);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const asset = release.assets.find(a => a.name === artifactName);
|
|
109
|
-
console.log(`Downloading ${asset.name} from ${release.tag_name}...`);
|
|
110
|
-
|
|
111
|
-
const file = fs.createWriteStream(path.join(binDir, artifactName));
|
|
112
|
-
|
|
113
|
-
return new Promise((resolve, reject) => {
|
|
114
|
-
const downloadUrl = asset.browser_download_url;
|
|
115
|
-
|
|
116
|
-
const request = (url) => {
|
|
117
|
-
https.get(url, { headers: { 'User-Agent': 'tandem-installer' } }, (res) => {
|
|
118
|
-
if (res.statusCode === 302 || res.statusCode === 301) {
|
|
119
|
-
return request(res.headers.location);
|
|
120
|
-
}
|
|
121
|
-
if (res.statusCode !== 200) return reject(new Error(`Download failed: HTTP ${res.statusCode}`));
|
|
122
|
-
res.pipe(file);
|
|
123
|
-
file.on('finish', () => {
|
|
124
|
-
file.close();
|
|
125
|
-
resolve(path.join(binDir, artifactName));
|
|
126
|
-
});
|
|
127
|
-
}).on('error', err => {
|
|
128
|
-
fs.unlink(path.join(binDir, artifactName), () => { }); // cleanup
|
|
129
|
-
reject(err);
|
|
130
|
-
});
|
|
131
|
-
};
|
|
132
|
-
request(downloadUrl);
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// Extract
|
|
137
|
-
async function extract(archivePath) {
|
|
138
|
-
console.log("Extracting...");
|
|
139
|
-
if (isWindows) {
|
|
140
|
-
execSync(`powershell -Command "Expand-Archive -Path '${archivePath}' -DestinationPath '${binDir}' -Force"`);
|
|
141
|
-
} else {
|
|
142
|
-
if (artifactName.endsWith('.zip')) {
|
|
143
|
-
execSync(`unzip -o "${archivePath}" -d "${binDir}"`);
|
|
144
|
-
} else {
|
|
145
|
-
execSync(`tar -xzf "${archivePath}" -C "${binDir}"`);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// Cleanup archive
|
|
150
|
-
fs.unlinkSync(archivePath);
|
|
151
|
-
|
|
152
|
-
// Locate binary (it might be inside a folder?)
|
|
153
|
-
// Our release workflow:
|
|
154
|
-
// Windows: dist/tandem-engine.exe -> zipped -> dist/tandem-engine.exe
|
|
155
|
-
// Linux: dist/tandem-engine -> tar -> dist/tandem-engine
|
|
156
|
-
// So on extraction, it might extract 'dist/tandem-engine' or just 'tandem-engine'.
|
|
157
|
-
// We should check.
|
|
158
|
-
|
|
159
|
-
// If extraction creates a folder (common behavior), we need to find it.
|
|
160
|
-
// Assuming root extraction for now based on GHA inspect.
|
|
161
|
-
// 'dist' folder? Yes. The GHA zips "dist/*". So it extracts "tandem-engine.exe" directly if zip didn't preserve root?
|
|
162
|
-
// "Compress-Archive -Path "dist/*" ... " -> This usually puts files at root of zip.
|
|
163
|
-
|
|
164
|
-
if (fs.existsSync(destPath)) {
|
|
165
|
-
console.log("Verified binary extracted.");
|
|
166
|
-
if (!isWindows) fs.chmodSync(destPath, 0o755);
|
|
167
|
-
} else {
|
|
168
|
-
console.error("Binary not found at expected path:", destPath);
|
|
169
|
-
// List files
|
|
170
|
-
console.log("Files in bin:", fs.readdirSync(binDir));
|
|
171
|
-
process.exit(1);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
download().then(extract).catch(err => {
|
|
176
|
-
console.error("Install failed:", err);
|
|
177
|
-
process.exit(1);
|
|
178
|
-
});
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const https = require('https');
|
|
4
|
+
const { execSync } = require('child_process');
|
|
5
|
+
|
|
6
|
+
// Configuration
|
|
7
|
+
const REPO = "frumu-ai/tandem";
|
|
8
|
+
const MIN_SIZE = 1024 * 1024; // 1MB
|
|
9
|
+
|
|
10
|
+
// Platform mapping
|
|
11
|
+
const PLATFORM_MAP = {
|
|
12
|
+
'win32': { os: 'windows', ext: '.exe' },
|
|
13
|
+
'darwin': { os: 'darwin', ext: '' },
|
|
14
|
+
'linux': { os: 'linux', ext: '' }
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const ARCH_MAP = {
|
|
18
|
+
'x64': 'x64',
|
|
19
|
+
'arm64': 'arm64'
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
function getArtifactInfo() {
|
|
23
|
+
const platform = PLATFORM_MAP[process.platform];
|
|
24
|
+
const arch = ARCH_MAP[process.arch];
|
|
25
|
+
|
|
26
|
+
if (!platform || !arch) {
|
|
27
|
+
throw new Error(`Unsupported platform: ${process.platform}-${process.arch}`);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
let artifactName = `tandem-engine-${platform.os}-${arch}`;
|
|
31
|
+
// Handle specific artifact naming conventions (zip vs tar.gz)
|
|
32
|
+
if (platform.os === 'windows') {
|
|
33
|
+
artifactName += '.zip';
|
|
34
|
+
} else if (platform.os === 'darwin') {
|
|
35
|
+
artifactName += '.zip';
|
|
36
|
+
} else {
|
|
37
|
+
artifactName += '.tar.gz';
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
artifactName,
|
|
42
|
+
binaryName: `tandem-engine${platform.ext}`,
|
|
43
|
+
isWindows: platform.os === 'windows'
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const { artifactName, binaryName, isWindows } = getArtifactInfo();
|
|
48
|
+
const binDir = path.join(__dirname, '..', 'bin', 'native');
|
|
49
|
+
const destPath = path.join(binDir, binaryName);
|
|
50
|
+
|
|
51
|
+
if (!fs.existsSync(binDir)) {
|
|
52
|
+
fs.mkdirSync(binDir, { recursive: true });
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (fs.existsSync(destPath)) {
|
|
56
|
+
console.log("Binary already present.");
|
|
57
|
+
process.exit(0);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Helper to fetch JSON from GitHub API
|
|
61
|
+
function fetchJson(url) {
|
|
62
|
+
return new Promise((resolve, reject) => {
|
|
63
|
+
https.get(url, { headers: { 'User-Agent': 'tandem-engine-installer' } }, (res) => {
|
|
64
|
+
if (res.statusCode !== 200) {
|
|
65
|
+
if (res.statusCode === 302 || res.statusCode === 301) {
|
|
66
|
+
return fetchJson(res.headers.location).then(resolve).catch(reject);
|
|
67
|
+
}
|
|
68
|
+
return reject(new Error(`GitHub API HTTP ${res.statusCode}`));
|
|
69
|
+
}
|
|
70
|
+
let data = '';
|
|
71
|
+
res.on('data', chunk => data += chunk);
|
|
72
|
+
res.on('end', () => {
|
|
73
|
+
try { resolve(JSON.parse(data)); } catch (e) { reject(e); }
|
|
74
|
+
});
|
|
75
|
+
}).on('error', reject);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Simplified download
|
|
80
|
+
async function download() {
|
|
81
|
+
console.log(`Checking releases for ${REPO}...`);
|
|
82
|
+
const releases = await fetchJson(`https://api.github.com/repos/${REPO}/releases`);
|
|
83
|
+
|
|
84
|
+
// Get the version from package.json
|
|
85
|
+
const packageVersion = require('../package.json').version;
|
|
86
|
+
const targetTag = `v${packageVersion}`;
|
|
87
|
+
|
|
88
|
+
console.log(`Filtering releases for ${REPO} (Target: ${targetTag})...`);
|
|
89
|
+
// const releases = await fetchJson... <--- REMOVED DUPLICATE
|
|
90
|
+
|
|
91
|
+
// 1. Try to find the exact release for this package version
|
|
92
|
+
let release = releases.find(r => r.tag_name === targetTag);
|
|
93
|
+
|
|
94
|
+
if (!release) {
|
|
95
|
+
console.warn(`Warning: No release found for tag ${targetTag}. Checking for latest compatible assets...`);
|
|
96
|
+
// 2. Fallback: Find LATEST release that contains our asset (useful for nightly/beta where tags might differ)
|
|
97
|
+
release = releases.find(r => r.assets.some(a => a.name === artifactName));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (!release) {
|
|
101
|
+
// Fallback: Check prereleases explicitly if strict filtering was on (it wasn't here)
|
|
102
|
+
// If not found, maybe name changed?
|
|
103
|
+
console.error(`Status: No release found with asset ${artifactName}`);
|
|
104
|
+
console.error("Available assets in latest:", releases[0]?.assets?.map(a => a.name));
|
|
105
|
+
process.exit(1);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const asset = release.assets.find(a => a.name === artifactName);
|
|
109
|
+
console.log(`Downloading ${asset.name} from ${release.tag_name}...`);
|
|
110
|
+
|
|
111
|
+
const file = fs.createWriteStream(path.join(binDir, artifactName));
|
|
112
|
+
|
|
113
|
+
return new Promise((resolve, reject) => {
|
|
114
|
+
const downloadUrl = asset.browser_download_url;
|
|
115
|
+
|
|
116
|
+
const request = (url) => {
|
|
117
|
+
https.get(url, { headers: { 'User-Agent': 'tandem-installer' } }, (res) => {
|
|
118
|
+
if (res.statusCode === 302 || res.statusCode === 301) {
|
|
119
|
+
return request(res.headers.location);
|
|
120
|
+
}
|
|
121
|
+
if (res.statusCode !== 200) return reject(new Error(`Download failed: HTTP ${res.statusCode}`));
|
|
122
|
+
res.pipe(file);
|
|
123
|
+
file.on('finish', () => {
|
|
124
|
+
file.close();
|
|
125
|
+
resolve(path.join(binDir, artifactName));
|
|
126
|
+
});
|
|
127
|
+
}).on('error', err => {
|
|
128
|
+
fs.unlink(path.join(binDir, artifactName), () => { }); // cleanup
|
|
129
|
+
reject(err);
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
request(downloadUrl);
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Extract
|
|
137
|
+
async function extract(archivePath) {
|
|
138
|
+
console.log("Extracting...");
|
|
139
|
+
if (isWindows) {
|
|
140
|
+
execSync(`powershell -Command "Expand-Archive -Path '${archivePath}' -DestinationPath '${binDir}' -Force"`);
|
|
141
|
+
} else {
|
|
142
|
+
if (artifactName.endsWith('.zip')) {
|
|
143
|
+
execSync(`unzip -o "${archivePath}" -d "${binDir}"`);
|
|
144
|
+
} else {
|
|
145
|
+
execSync(`tar -xzf "${archivePath}" -C "${binDir}"`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Cleanup archive
|
|
150
|
+
fs.unlinkSync(archivePath);
|
|
151
|
+
|
|
152
|
+
// Locate binary (it might be inside a folder?)
|
|
153
|
+
// Our release workflow:
|
|
154
|
+
// Windows: dist/tandem-engine.exe -> zipped -> dist/tandem-engine.exe
|
|
155
|
+
// Linux: dist/tandem-engine -> tar -> dist/tandem-engine
|
|
156
|
+
// So on extraction, it might extract 'dist/tandem-engine' or just 'tandem-engine'.
|
|
157
|
+
// We should check.
|
|
158
|
+
|
|
159
|
+
// If extraction creates a folder (common behavior), we need to find it.
|
|
160
|
+
// Assuming root extraction for now based on GHA inspect.
|
|
161
|
+
// 'dist' folder? Yes. The GHA zips "dist/*". So it extracts "tandem-engine.exe" directly if zip didn't preserve root?
|
|
162
|
+
// "Compress-Archive -Path "dist/*" ... " -> This usually puts files at root of zip.
|
|
163
|
+
|
|
164
|
+
if (fs.existsSync(destPath)) {
|
|
165
|
+
console.log("Verified binary extracted.");
|
|
166
|
+
if (!isWindows) fs.chmodSync(destPath, 0o755);
|
|
167
|
+
} else {
|
|
168
|
+
console.error("Binary not found at expected path:", destPath);
|
|
169
|
+
// List files
|
|
170
|
+
console.log("Files in bin:", fs.readdirSync(binDir));
|
|
171
|
+
process.exit(1);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
download().then(extract).catch(err => {
|
|
176
|
+
console.error("Install failed:", err);
|
|
177
|
+
process.exit(1);
|
|
178
|
+
});
|