onlyonecli 0.0.0-stage → 0.1.1
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/LICENSE +21 -0
- package/README.md +4 -2
- package/bin/onlyone.cjs +5 -0
- package/launcher.cjs +96 -0
- package/package.json +21 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jason Lee
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
#
|
|
1
|
+
# OnlyOne
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Install: `npm install -g onlyonecli` (Node.js 22+). Run `onlyone` and enter your deployed Worker URL, owner email and email code. The CLI registers this computer and starts its background executor. Claude Code / Codex must be installed and signed in separately.
|
|
4
|
+
|
|
5
|
+
Linux requires glibc and user systemd; macOS uses launchd. Windows x64 support is pending npm approval of the platform package; it cannot run on Windows until that package is available. Windows service support uses a current-user logon task. `onlyone update` or the app’s Update all machines action stages and validates a new npm release before draining and restarting.
|
package/bin/onlyone.cjs
ADDED
package/launcher.cjs
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// Shared by the npm command and the private, stable service entry point.
|
|
2
|
+
const fs = require('node:fs');
|
|
3
|
+
const path = require('node:path');
|
|
4
|
+
const os = require('node:os');
|
|
5
|
+
const { spawn } = require('node:child_process');
|
|
6
|
+
const read = file => JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
7
|
+
function write(file, value) {
|
|
8
|
+
fs.writeFileSync(file + '.next', JSON.stringify(value), { mode: 0o600 });
|
|
9
|
+
fs.renameSync(file + '.next', file);
|
|
10
|
+
}
|
|
11
|
+
function platformBinary(root) {
|
|
12
|
+
const name = `onlyone-${process.platform}-${process.arch}`;
|
|
13
|
+
if (!['linux-x64', 'linux-arm64', 'darwin-x64', 'darwin-arm64', 'win32-x64'].includes(`${process.platform}-${process.arch}`))
|
|
14
|
+
throw new Error(`OnlyOne does not support ${process.platform}/${process.arch}`);
|
|
15
|
+
if (process.platform === 'linux' && !process.report.getReport().header.glibcVersionRuntime)
|
|
16
|
+
throw new Error('OnlyOne requires glibc Linux; Alpine/musl is not supported yet');
|
|
17
|
+
try {
|
|
18
|
+
return path.join(path.dirname(require.resolve(name + '/package.json', { paths: [root] })), 'bin', process.platform === 'win32' ? 'onlyone.exe' : 'onlyone');
|
|
19
|
+
} catch { throw new Error(`Missing ${name}. Reinstall onlyonecli with npm optional dependencies enabled.`); }
|
|
20
|
+
}
|
|
21
|
+
function npmCli() {
|
|
22
|
+
const candidates = [process.env.npm_execpath, path.join(path.dirname(process.execPath), 'node_modules/npm/bin/npm-cli.js'),
|
|
23
|
+
path.resolve(path.dirname(process.execPath), '../lib/node_modules/npm/bin/npm-cli.js')];
|
|
24
|
+
for (const directory of (process.env.PATH || '').split(path.delimiter)) {
|
|
25
|
+
const shim = path.join(directory, process.platform === 'win32' ? 'npm.cmd' : 'npm');
|
|
26
|
+
if (fs.existsSync(shim)) {
|
|
27
|
+
const real = fs.realpathSync(shim);
|
|
28
|
+
candidates.push(real.endsWith('.js') ? real : path.join(path.dirname(real), 'node_modules/npm/bin/npm-cli.js'));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return candidates.find(file => file && fs.existsSync(file) && file.endsWith('.js'));
|
|
32
|
+
}
|
|
33
|
+
async function run(args, root) {
|
|
34
|
+
const home = path.resolve((process.env.ONLYONE_HOME || path.join(os.homedir(), '.onlyone')).replace(/^~/, os.homedir()));
|
|
35
|
+
const currentFile = path.join(home, 'cli/current.json');
|
|
36
|
+
const service = args[0] === '--service';
|
|
37
|
+
let env = { ...process.env };
|
|
38
|
+
if (service) env = { ...env, ...read(path.join(home, 'cli/service.json')) };
|
|
39
|
+
else {
|
|
40
|
+
env.ONLYONE_NPM_ROOT = root;
|
|
41
|
+
env.ONLYONE_NODE = process.execPath;
|
|
42
|
+
const npm = npmCli();
|
|
43
|
+
if (npm) env.ONLYONE_NPM_CLI = npm;
|
|
44
|
+
}
|
|
45
|
+
let stopping = false, child;
|
|
46
|
+
for (const signal of ['SIGINT', 'SIGTERM']) process.on(signal, () => {
|
|
47
|
+
stopping = true;
|
|
48
|
+
if (child) child.kill(signal);
|
|
49
|
+
});
|
|
50
|
+
do {
|
|
51
|
+
const state = fs.existsSync(currentFile) ? read(currentFile) : null;
|
|
52
|
+
const binary = state ? state.binary : platformBinary(root);
|
|
53
|
+
const started = Date.now();
|
|
54
|
+
const log = service && process.platform === 'win32' ? fs.openSync(path.join(home, 'cli/daemon.log'), 'a', 0o600) : null;
|
|
55
|
+
child = spawn(binary, service ? ['daemon'] : args, { env, stdio: log === null ? 'inherit' : ['ignore', log, log], windowsHide: service });
|
|
56
|
+
if (log !== null) fs.closeSync(log);
|
|
57
|
+
let ready = false, timer;
|
|
58
|
+
const stopUnready = () => {
|
|
59
|
+
const elapsed = Date.now() - started;
|
|
60
|
+
if (elapsed > 135_000) child.kill('SIGKILL');
|
|
61
|
+
else if (elapsed > 120_000) child.kill('SIGTERM');
|
|
62
|
+
};
|
|
63
|
+
if (service && state.pending) timer = setInterval(() => {
|
|
64
|
+
try {
|
|
65
|
+
const readyFile = path.join(path.dirname(env.ONLYONE_DATA_DIR), 'service-ready');
|
|
66
|
+
ready = fs.readFileSync(readyFile, 'utf8').trim() === String(child.pid);
|
|
67
|
+
if (ready && Date.now() - started > 10_000) {
|
|
68
|
+
const latest = read(currentFile);
|
|
69
|
+
if (latest.version === state.version) write(currentFile, { ...latest, pending: false });
|
|
70
|
+
clearInterval(timer);
|
|
71
|
+
} else stopUnready();
|
|
72
|
+
} catch { stopUnready(); }
|
|
73
|
+
}, 250);
|
|
74
|
+
const code = await new Promise(resolve => {
|
|
75
|
+
child.once('error', error => { console.error(`Could not start OnlyOne: ${error.message}`); resolve(1); });
|
|
76
|
+
child.once('exit', (code, signal) => resolve(code ?? (signal ? 1 : 0)));
|
|
77
|
+
});
|
|
78
|
+
clearInterval(timer);
|
|
79
|
+
if (!service) { process.exitCode = code; return; }
|
|
80
|
+
// Only an unconfirmed candidate rolls back. Ordinary daemon failures use the service retry delay.
|
|
81
|
+
const latest = read(currentFile);
|
|
82
|
+
let rolledBack = false;
|
|
83
|
+
if (!stopping && latest.version === state.version && latest.pending && latest.previous) {
|
|
84
|
+
console.error(`OnlyOne ${state.version} failed startup; restoring ${latest.previous.version}`);
|
|
85
|
+
write(currentFile, latest.previous);
|
|
86
|
+
rolledBack = true;
|
|
87
|
+
fs.writeFileSync(path.join(home, 'update-rejected'), state.version, { mode: 0o600 });
|
|
88
|
+
let update = {};
|
|
89
|
+
try { update = read(path.join(home, 'update-state.json')); } catch {}
|
|
90
|
+
write(path.join(home, 'update-state.json'), { ...update, state: 'failed', detail: `Startup failed; restored ${latest.previous.version}`, ts: new Date().toISOString() });
|
|
91
|
+
}
|
|
92
|
+
if (!stopping) await new Promise(resolve => setTimeout(resolve, rolledBack ? 0 : 10_000));
|
|
93
|
+
} while (!stopping);
|
|
94
|
+
}
|
|
95
|
+
module.exports = { run, platformBinary, npmCli };
|
|
96
|
+
if (require.main === module) run(process.argv.slice(2)).catch(error => { console.error(error.message); process.exitCode = 1; });
|
package/package.json
CHANGED
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "onlyonecli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Your own AI team on your computers",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": ">=22"
|
|
8
|
+
},
|
|
9
|
+
"bin": {
|
|
10
|
+
"onlyone": "bin/onlyone.cjs"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"bin/onlyone.cjs",
|
|
14
|
+
"launcher.cjs"
|
|
15
|
+
],
|
|
16
|
+
"optionalDependencies": {
|
|
17
|
+
"onlyone-linux-x64": "0.1.1",
|
|
18
|
+
"onlyone-linux-arm64": "0.1.1",
|
|
19
|
+
"onlyone-darwin-x64": "0.1.1",
|
|
20
|
+
"onlyone-darwin-arm64": "0.1.1",
|
|
21
|
+
"onlyone-win32-x64": "0.1.1"
|
|
22
|
+
}
|
|
23
|
+
}
|