omnikey-cli 1.6.1 → 1.6.2
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.
|
@@ -12,6 +12,7 @@ const os_1 = __importDefault(require("os"));
|
|
|
12
12
|
const authMiddleware_1 = require("./authMiddleware");
|
|
13
13
|
const config_1 = require("./config");
|
|
14
14
|
const logger_1 = require("./logger");
|
|
15
|
+
const scheduledJobExecutor_1 = require("./scheduledJobExecutor");
|
|
15
16
|
const providerEnum = zod_1.default.enum(['openai', 'anthropic', 'gemini', 'nemotron']);
|
|
16
17
|
const putSchema = zod_1.default.object({
|
|
17
18
|
apiKey: zod_1.default.string().min(1).max(4096),
|
|
@@ -99,14 +100,48 @@ function readActiveProvider(cfg) {
|
|
|
99
100
|
return config_1.config.aiProvider;
|
|
100
101
|
}
|
|
101
102
|
/**
|
|
102
|
-
* Triggers a
|
|
103
|
-
* (
|
|
104
|
-
*
|
|
103
|
+
* Triggers a daemon restart by handing off to the shared `runScript` helper
|
|
104
|
+
* (the same one used by the scheduled-job executor). The script invokes the
|
|
105
|
+
* `omnikey restart-daemon --port <port>` CLI, which tears down the
|
|
106
|
+
* launchd / NSSM persistence agent and brings a fresh daemon back up on the
|
|
107
|
+
* same port — picking up the rewritten config.json values from env on the
|
|
108
|
+
* way up.
|
|
109
|
+
*
|
|
110
|
+
* Important: `omnikey restart-daemon` calls `killDaemon()` first, which kills
|
|
111
|
+
* *this* Node process. To survive that, we wrap the call in `nohup ... &`
|
|
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.
|
|
105
116
|
*/
|
|
106
117
|
function scheduleDaemonRestart(reason) {
|
|
107
118
|
setTimeout(() => {
|
|
108
|
-
|
|
109
|
-
process.
|
|
119
|
+
const port = config_1.config.port;
|
|
120
|
+
const logFile = path_1.default.join(process.env.HOME || os_1.default.homedir(), '.omnikey', 'restart-daemon.log');
|
|
121
|
+
const script = [
|
|
122
|
+
'#!/usr/bin/env bash',
|
|
123
|
+
'set -u',
|
|
124
|
+
`mkdir -p "$(dirname "${logFile}")"`,
|
|
125
|
+
`echo "[$(date -Iseconds)] restart-daemon triggered: ${reason}" >> "${logFile}"`,
|
|
126
|
+
// Detach the actual restart so it survives this daemon's imminent death.
|
|
127
|
+
`nohup omnikey restart-daemon --port ${port} >> "${logFile}" 2>&1 &`,
|
|
128
|
+
'disown || true',
|
|
129
|
+
'exit 0',
|
|
130
|
+
].join('\n');
|
|
131
|
+
logger_1.logger.info(`Running \`omnikey restart-daemon --port ${port}\` via runScript (${reason})`);
|
|
132
|
+
// Fire-and-forget: we expect `omnikey restart-daemon` to kill this process
|
|
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
|
+
});
|
|
110
145
|
}, 500);
|
|
111
146
|
}
|
|
112
147
|
function aiProviderRouter() {
|
package/backend-dist/index.js
CHANGED
|
@@ -84,8 +84,8 @@ app.get('/macos/appcast', (req, res) => {
|
|
|
84
84
|
const appcastUrl = `${baseUrl}/macos/appcast`;
|
|
85
85
|
// These should match the values embedded into the macOS app
|
|
86
86
|
// Info.plist in macOS/build_release_dmg.sh.
|
|
87
|
-
const bundleVersion = '
|
|
88
|
-
const shortVersion = '1.0.
|
|
87
|
+
const bundleVersion = '39';
|
|
88
|
+
const shortVersion = '1.0.38';
|
|
89
89
|
const xml = `<?xml version="1.0" encoding="utf-8"?>
|
|
90
90
|
<rss version="2.0"
|
|
91
91
|
xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle"
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.computeNextRunAt = computeNextRunAt;
|
|
7
7
|
exports.startScheduledJobExecutor = startScheduledJobExecutor;
|
|
8
|
+
exports.runScript = runScript;
|
|
8
9
|
exports.executeJob = executeJob;
|
|
9
10
|
const child_process_1 = require("child_process");
|
|
10
11
|
const promises_1 = require("fs/promises");
|
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.2",
|
|
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",
|