@ace3-memory/ace 3.0.6 → 3.0.7
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/download-binary.js +105 -103
- package/package.json +1 -1
package/download-binary.js
CHANGED
|
@@ -2,14 +2,13 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* ACE Binary Downloader (npm postinstall script)
|
|
4
4
|
* Downloads platform-specific ACE binary from GitHub releases
|
|
5
|
-
*
|
|
5
|
+
* Dynamically fetches latest release - no hardcoded versions
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
const https = require('https');
|
|
9
9
|
const fs = require('fs');
|
|
10
10
|
const path = require('path');
|
|
11
11
|
|
|
12
|
-
const VERSION = process.env.ACE_VERSION || 'v3.0.4';
|
|
13
12
|
const GITHUB_REPO = 'AdyBrooks46/AutonomousContextEngine';
|
|
14
13
|
const BINARY_DIR = path.join(__dirname, 'bin');
|
|
15
14
|
|
|
@@ -18,131 +17,134 @@ const platform = process.platform;
|
|
|
18
17
|
const arch = process.arch;
|
|
19
18
|
|
|
20
19
|
// Map to binary names
|
|
21
|
-
// Note: macOS Intel (x64) uses ARM64 binary via Rosetta 2
|
|
22
20
|
const BINARY_MAP = {
|
|
23
21
|
'darwin-arm64': 'ace-macos-arm64',
|
|
24
|
-
'darwin-x64': 'ace-macos-
|
|
22
|
+
'darwin-x64': 'ace-macos-x64',
|
|
25
23
|
'linux-x64': 'ace-linux-x64',
|
|
26
24
|
'win32-x64': 'ace-windows-x64.exe'
|
|
27
25
|
};
|
|
28
26
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
27
|
+
// Fetch latest release version from GitHub API
|
|
28
|
+
function getLatestVersion() {
|
|
29
|
+
return new Promise((resolve) => {
|
|
30
|
+
const options = {
|
|
31
|
+
hostname: 'api.github.com',
|
|
32
|
+
path: `/repos/${GITHUB_REPO}/releases/latest`,
|
|
33
|
+
headers: { 'User-Agent': 'ace-installer' }
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
https.get(options, (res) => {
|
|
37
|
+
let data = '';
|
|
38
|
+
res.on('data', chunk => data += chunk);
|
|
39
|
+
res.on('end', () => {
|
|
40
|
+
try {
|
|
41
|
+
const release = JSON.parse(data);
|
|
42
|
+
resolve(release.tag_name);
|
|
43
|
+
} catch {
|
|
44
|
+
resolve(null);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}).on('error', () => resolve(null));
|
|
48
|
+
});
|
|
36
49
|
}
|
|
37
50
|
|
|
38
|
-
//
|
|
39
|
-
|
|
40
|
-
|
|
51
|
+
// Download file with redirect support
|
|
52
|
+
function downloadFile(url, destPath) {
|
|
53
|
+
return new Promise((resolve, reject) => {
|
|
54
|
+
const file = fs.createWriteStream(destPath);
|
|
55
|
+
let downloadedBytes = 0;
|
|
56
|
+
let totalBytes = 0;
|
|
41
57
|
|
|
42
|
-
|
|
43
|
-
|
|
58
|
+
const handleResponse = (response) => {
|
|
59
|
+
if (response.statusCode === 302 || response.statusCode === 301) {
|
|
60
|
+
https.get(response.headers.location, handleResponse).on('error', reject);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
44
63
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
64
|
+
if (response.statusCode !== 200) {
|
|
65
|
+
reject(new Error(`HTTP ${response.statusCode}`));
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
49
68
|
|
|
50
|
-
|
|
51
|
-
const file = fs.createWriteStream(binaryPath);
|
|
52
|
-
let downloadedBytes = 0;
|
|
53
|
-
let totalBytes = 0;
|
|
69
|
+
totalBytes = parseInt(response.headers['content-length'], 10);
|
|
54
70
|
|
|
55
|
-
|
|
56
|
-
if (response.statusCode === 302 || response.statusCode === 301) {
|
|
57
|
-
// Follow redirect
|
|
58
|
-
https.get(response.headers.location, (redirectResponse) => {
|
|
59
|
-
totalBytes = parseInt(redirectResponse.headers['content-length'], 10);
|
|
60
|
-
|
|
61
|
-
redirectResponse.on('data', (chunk) => {
|
|
71
|
+
response.on('data', (chunk) => {
|
|
62
72
|
downloadedBytes += chunk.length;
|
|
63
|
-
|
|
64
|
-
|
|
73
|
+
if (totalBytes > 0) {
|
|
74
|
+
const percent = ((downloadedBytes / totalBytes) * 100).toFixed(1);
|
|
75
|
+
process.stdout.write(`\r⏳ Progress: ${percent}% (${(downloadedBytes / 1024 / 1024).toFixed(1)}MB)`);
|
|
76
|
+
}
|
|
65
77
|
});
|
|
66
78
|
|
|
67
|
-
|
|
79
|
+
response.pipe(file);
|
|
68
80
|
|
|
69
81
|
file.on('finish', () => {
|
|
70
82
|
file.close(() => {
|
|
71
83
|
process.stdout.write('\n');
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
// Make executable (Unix-like systems)
|
|
75
|
-
if (platform !== 'win32') {
|
|
76
|
-
try {
|
|
77
|
-
fs.chmodSync(binaryPath, 0o755);
|
|
78
|
-
console.log('✅ Binary made executable');
|
|
79
|
-
} catch (err) {
|
|
80
|
-
console.error('⚠️ Could not make binary executable:', err.message);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
console.log(`✅ ACE installed successfully!`);
|
|
85
|
-
console.log(`\n🚀 Quick start:`);
|
|
86
|
-
console.log(` 1. ace login # Authenticate`);
|
|
87
|
-
console.log(` 2. ace start # Start server`);
|
|
88
|
-
console.log(` 3. ace status # Check status\n`);
|
|
84
|
+
resolve();
|
|
89
85
|
});
|
|
90
86
|
});
|
|
91
|
-
}
|
|
92
|
-
fs.unlinkSync(binaryPath);
|
|
93
|
-
console.error(`\n❌ Download failed:`, err.message);
|
|
94
|
-
process.exit(1);
|
|
95
|
-
});
|
|
96
|
-
} else if (response.statusCode === 200) {
|
|
97
|
-
totalBytes = parseInt(response.headers['content-length'], 10);
|
|
98
|
-
|
|
99
|
-
response.on('data', (chunk) => {
|
|
100
|
-
downloadedBytes += chunk.length;
|
|
101
|
-
const percent = ((downloadedBytes / totalBytes) * 100).toFixed(1);
|
|
102
|
-
process.stdout.write(`\r⏳ Progress: ${percent}% (${(downloadedBytes / 1024 / 1024).toFixed(1)}MB / ${(totalBytes / 1024 / 1024).toFixed(1)}MB)`);
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
response.pipe(file);
|
|
106
|
-
|
|
107
|
-
file.on('finish', () => {
|
|
108
|
-
file.close(() => {
|
|
109
|
-
process.stdout.write('\n');
|
|
110
|
-
console.log('✅ Download complete');
|
|
111
|
-
|
|
112
|
-
// Make executable (Unix-like systems)
|
|
113
|
-
if (platform !== 'win32') {
|
|
114
|
-
try {
|
|
115
|
-
fs.chmodSync(binaryPath, 0o755);
|
|
116
|
-
console.log('✅ Binary made executable');
|
|
117
|
-
} catch (err) {
|
|
118
|
-
console.error('⚠️ Could not make binary executable:', err.message);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
87
|
+
};
|
|
121
88
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
89
|
+
https.get(url, handleResponse).on('error', reject);
|
|
90
|
+
file.on('error', reject);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Main installation
|
|
95
|
+
async function install() {
|
|
96
|
+
const platformKey = `${platform}-${arch}`;
|
|
97
|
+
const binaryName = BINARY_MAP[platformKey];
|
|
98
|
+
|
|
99
|
+
if (!binaryName) {
|
|
100
|
+
console.error(`❌ Unsupported platform: ${platform} ${arch}`);
|
|
101
|
+
console.error(`Supported: macOS (Intel/Apple Silicon), Linux x64, Windows x64`);
|
|
132
102
|
process.exit(1);
|
|
133
103
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
104
|
+
|
|
105
|
+
// Get latest version from GitHub
|
|
106
|
+
console.log('\n📦 Checking for latest ACE release...');
|
|
107
|
+
const version = process.env.ACE_VERSION || await getLatestVersion();
|
|
108
|
+
|
|
109
|
+
if (!version) {
|
|
110
|
+
console.error('❌ Could not determine latest version from GitHub');
|
|
111
|
+
process.exit(1);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const downloadUrl = `https://github.com/${GITHUB_REPO}/releases/download/${version}/${binaryName}`;
|
|
115
|
+
const binaryPath = path.join(BINARY_DIR, 'ace' + (platform === 'win32' ? '.exe' : ''));
|
|
116
|
+
|
|
117
|
+
console.log(`📦 Installing ACE ${version} for ${platform} ${arch}...`);
|
|
118
|
+
console.log(`📥 Downloading: ${binaryName}`);
|
|
119
|
+
|
|
120
|
+
// Create bin directory
|
|
121
|
+
if (!fs.existsSync(BINARY_DIR)) {
|
|
122
|
+
fs.mkdirSync(BINARY_DIR, { recursive: true });
|
|
137
123
|
}
|
|
138
|
-
console.error(`\n❌ Download failed:`, err.message);
|
|
139
|
-
process.exit(1);
|
|
140
|
-
});
|
|
141
124
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
125
|
+
try {
|
|
126
|
+
await downloadFile(downloadUrl, binaryPath);
|
|
127
|
+
console.log('✅ Download complete');
|
|
128
|
+
|
|
129
|
+
// Make executable (Unix-like systems)
|
|
130
|
+
if (platform !== 'win32') {
|
|
131
|
+
fs.chmodSync(binaryPath, 0o755);
|
|
132
|
+
console.log('✅ Binary made executable');
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
console.log(`✅ ACE ${version} installed successfully!`);
|
|
136
|
+
console.log(`\n🚀 Quick start:`);
|
|
137
|
+
console.log(` 1. ace login # Authenticate`);
|
|
138
|
+
console.log(` 2. ace start # Start server`);
|
|
139
|
+
console.log(` 3. ace status # Check status\n`);
|
|
140
|
+
} catch (err) {
|
|
141
|
+
if (fs.existsSync(binaryPath)) {
|
|
142
|
+
fs.unlinkSync(binaryPath);
|
|
143
|
+
}
|
|
144
|
+
console.error(`\n❌ Failed to download: ${err.message}`);
|
|
145
|
+
console.error(`URL: ${downloadUrl}`);
|
|
146
|
+
process.exit(1);
|
|
145
147
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
install();
|