omnikey-cli 1.6.1 → 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.
@@ -9,6 +9,7 @@ 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");
@@ -99,14 +100,31 @@ function readActiveProvider(cfg) {
99
100
  return config_1.config.aiProvider;
100
101
  }
101
102
  /**
102
- * Triggers a graceful daemon restart. The process is supervised by launchd
103
- * (macOS) / NSSM (Windows) with auto-restart enabled, so exiting will cause
104
- * the supervisor to relaunch the API with the freshly written config.json.
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.
108
+ *
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.
105
111
  */
106
112
  function scheduleDaemonRestart(reason) {
107
113
  setTimeout(() => {
108
- logger_1.logger.info(`Exiting process to trigger supervised restart: ${reason}`);
109
- process.exit(0);
114
+ const port = config_1.config.port;
115
+ const logFile = path_1.default.join(process.env.HOME || os_1.default.homedir(), '.omnikey', 'restart-daemon.log');
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
+ }
110
128
  }, 500);
111
129
  }
112
130
  function aiProviderRouter() {
@@ -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 = '37';
88
- const shortVersion = '1.0.36';
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.1",
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",