apolemia 1.0.0

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.
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawn } = require('child_process');
4
+ const path = require('path');
5
+ const fs = require('fs');
6
+
7
+ const OS_MAP = { win32: 'windows', darwin: 'darwin', linux: 'linux' };
8
+ const ARCH_MAP = { x64: 'amd64', arm64: 'arm64' };
9
+
10
+ const platform = OS_MAP[process.platform];
11
+ const arch = ARCH_MAP[process.arch];
12
+
13
+ const binaryName = platform === 'windows'
14
+ ? `apolemia-worker-${platform}-${arch}.exe`
15
+ : `apolemia-worker-${platform}-${arch}`;
16
+ const binaryPath = path.join(__dirname, binaryName);
17
+
18
+ if (!fs.existsSync(binaryPath)) {
19
+ console.error(`Error: Apolemia Worker binary not found at ${binaryPath}`);
20
+ console.error('Try running "npm install" again to download the binary.');
21
+ process.exit(1);
22
+ }
23
+
24
+ const args = process.argv.slice(2);
25
+ const child = spawn(binaryPath, args, { stdio: 'inherit' });
26
+
27
+ child.on('exit', (code) => {
28
+ process.exit(code);
29
+ });
30
+
31
+ child.on('error', (err) => {
32
+ console.error('Failed to start Apolemia Worker:', err);
33
+ process.exit(1);
34
+ });
package/package.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "apolemia",
3
+ "version": "1.0.0",
4
+ "description": "Apolemia AI Platform Worker CLI",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/Openheartprojects/apolemia-worker.git"
8
+ },
9
+ "bin": {
10
+ "apolemia": "bin/apolemia.js"
11
+ },
12
+ "scripts": {
13
+ "postinstall": "node scripts/install.js"
14
+ },
15
+ "engines": {
16
+ "node": ">=14"
17
+ }
18
+ }
@@ -0,0 +1,82 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const https = require('https');
4
+ const { execSync } = require('child_process');
5
+
6
+ const REPO = 'Openheartprojects/apolemia-worker';
7
+ // In a real production scenario, we would fetch the latest tag from GitHub API
8
+ // For now, we use a fallback or specific version logic
9
+ const VERSION = 'v1.0.0';
10
+
11
+ const OS_MAP = {
12
+ win32: 'windows',
13
+ darwin: 'darwin',
14
+ linux: 'linux'
15
+ };
16
+
17
+ const ARCH_MAP = {
18
+ x64: 'amd64',
19
+ arm64: 'arm64'
20
+ };
21
+
22
+ const platform = OS_MAP[process.platform];
23
+ const arch = ARCH_MAP[process.arch];
24
+
25
+ if (!platform || !arch) {
26
+ console.error(`Unsupported platform/architecture: ${process.platform}/${process.arch}`);
27
+ process.exit(1);
28
+ }
29
+
30
+ const binaryName = platform === 'windows'
31
+ ? `apolemia-worker-${platform}-${arch}.exe`
32
+ : `apolemia-worker-${platform}-${arch}`;
33
+ const url = `https://github.com/${REPO}/releases/download/${VERSION}/${binaryName}`;
34
+
35
+ const binDir = path.join(__dirname, '..', 'bin');
36
+ const destPath = path.join(binDir, binaryName);
37
+
38
+ if (!fs.existsSync(binDir)) {
39
+ fs.mkdirSync(binDir, { recursive: true });
40
+ }
41
+
42
+ console.log(`Downloading Atlaps Worker ${VERSION} for ${platform}/${arch}...`);
43
+ console.log(`Source: ${url}`);
44
+
45
+ function download(url, dest) {
46
+ return new Promise((resolve, reject) => {
47
+ const file = fs.createWriteStream(dest);
48
+ https.get(url, (response) => {
49
+ if (response.statusCode === 302 || response.statusCode === 301) {
50
+ // Handle GitHub redirect
51
+ download(response.headers.location, dest).then(resolve).catch(reject);
52
+ return;
53
+ }
54
+ if (response.statusCode !== 200) {
55
+ reject(new Error(`Failed to download: ${response.statusCode}`));
56
+ return;
57
+ }
58
+ response.pipe(file);
59
+ file.on('finish', () => {
60
+ file.close(resolve);
61
+ });
62
+ }).on('error', (err) => {
63
+ fs.unlink(dest, () => reject(err));
64
+ });
65
+ });
66
+ }
67
+
68
+ download(url, destPath)
69
+ .then(() => {
70
+ console.log('Download complete!');
71
+ if (platform !== 'windows') {
72
+ fs.chmodSync(destPath, 0o755);
73
+ }
74
+ })
75
+ .catch((err) => {
76
+ console.error('Error downloading binary:', err.message);
77
+ console.log('\n--- Troubleshooting ---');
78
+ console.log('The binary might not be available for this specific tag yet.');
79
+ console.log('Please ensure the GitHub Release has the expected assets.');
80
+ // Don't fail the whole npm install if the binary is missing (for dev environments)
81
+ process.exit(0);
82
+ });