omnikey-cli 1.6.2 → 1.6.3
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/backend-dist/aiProviderRoutes.js +20 -37
- package/package.json +1 -1
|
@@ -9,10 +9,10 @@ const zod_1 = __importDefault(require("zod"));
|
|
|
9
9
|
const fs_1 = __importDefault(require("fs"));
|
|
10
10
|
const path_1 = __importDefault(require("path"));
|
|
11
11
|
const os_1 = __importDefault(require("os"));
|
|
12
|
+
const child_process_1 = require("child_process");
|
|
12
13
|
const authMiddleware_1 = require("./authMiddleware");
|
|
13
14
|
const config_1 = require("./config");
|
|
14
15
|
const logger_1 = require("./logger");
|
|
15
|
-
const scheduledJobExecutor_1 = require("./scheduledJobExecutor");
|
|
16
16
|
const providerEnum = zod_1.default.enum(['openai', 'anthropic', 'gemini', 'nemotron']);
|
|
17
17
|
const putSchema = zod_1.default.object({
|
|
18
18
|
apiKey: zod_1.default.string().min(1).max(4096),
|
|
@@ -100,48 +100,31 @@ function readActiveProvider(cfg) {
|
|
|
100
100
|
return config_1.config.aiProvider;
|
|
101
101
|
}
|
|
102
102
|
/**
|
|
103
|
-
* Triggers a daemon restart by
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
* way up.
|
|
103
|
+
* Triggers a daemon restart by spawning a detached `omnikey restart-daemon`
|
|
104
|
+
* process. Using spawn with detached:true + unref() instead of a shell script
|
|
105
|
+
* avoids PATH lookup failures when the daemon runs under launchd/NSSM (which
|
|
106
|
+
* provide a minimal environment). We resolve the CLI path relative to
|
|
107
|
+
* __dirname so it works regardless of PATH.
|
|
109
108
|
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
* with stdio redirected to a log file and `disown` so the actual
|
|
113
|
-
* `omnikey restart-daemon` invocation escapes the shell's process tree
|
|
114
|
-
* before this process is terminated. `runScript` is fire-and-forget: we do
|
|
115
|
-
* not await it because we expect to be killed before it returns.
|
|
109
|
+
* The API server lives in cli/backend-dist/ and the omnikey CLI lives in
|
|
110
|
+
* cli/dist/, so path.resolve(__dirname, '../dist/index.js') is always valid.
|
|
116
111
|
*/
|
|
117
112
|
function scheduleDaemonRestart(reason) {
|
|
118
113
|
setTimeout(() => {
|
|
119
114
|
const port = config_1.config.port;
|
|
120
115
|
const logFile = path_1.default.join(process.env.HOME || os_1.default.homedir(), '.omnikey', 'restart-daemon.log');
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
// long before runScript's exec promise resolves.
|
|
134
|
-
void (0, scheduledJobExecutor_1.runScript)(script)
|
|
135
|
-
.then((result) => {
|
|
136
|
-
if (result.isError) {
|
|
137
|
-
logger_1.logger.error('runScript reported a non-zero exit for restart-daemon.', {
|
|
138
|
-
output: result.output,
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
})
|
|
142
|
-
.catch((err) => {
|
|
143
|
-
logger_1.logger.error('Unexpected runScript failure while restarting daemon.', { error: err });
|
|
144
|
-
});
|
|
116
|
+
const omnikeyCli = path_1.default.resolve(__dirname, '../dist/index.js');
|
|
117
|
+
logger_1.logger.info(`Spawning detached \`omnikey restart-daemon --port ${port}\` (${reason})`);
|
|
118
|
+
try {
|
|
119
|
+
fs_1.default.mkdirSync(path_1.default.dirname(logFile), { recursive: true });
|
|
120
|
+
const out = fs_1.default.openSync(logFile, 'a');
|
|
121
|
+
const child = (0, child_process_1.spawn)(process.execPath, [omnikeyCli, 'restart-daemon', '--port', String(port)], { detached: true, stdio: ['ignore', out, out] });
|
|
122
|
+
child.unref();
|
|
123
|
+
fs_1.default.closeSync(out);
|
|
124
|
+
}
|
|
125
|
+
catch (err) {
|
|
126
|
+
logger_1.logger.error('Failed to spawn restart-daemon process.', { error: err });
|
|
127
|
+
}
|
|
145
128
|
}, 500);
|
|
146
129
|
}
|
|
147
130
|
function aiProviderRouter() {
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public",
|
|
5
5
|
"registry": "https://registry.npmjs.org/"
|
|
6
6
|
},
|
|
7
|
-
"version": "1.6.
|
|
7
|
+
"version": "1.6.3",
|
|
8
8
|
"description": "CLI for onboarding users to Omnikey AI and configuring OPENAI_API_KEY. Use Yarn for install/build.",
|
|
9
9
|
"engines": {
|
|
10
10
|
"node": ">=14.0.0",
|