openfox 2.0.6 → 2.0.8

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.
@@ -5818,23 +5818,28 @@ import { Router as Router6 } from "express";
5818
5818
  import { spawn as spawn5 } from "child_process";
5819
5819
 
5820
5820
  // src/constants.ts
5821
- var VERSION = "2.0.6";
5821
+ var VERSION = "2.0.8";
5822
5822
 
5823
5823
  // src/server/routes/auto-update.ts
5824
5824
  var updateInProgress = false;
5825
5825
  function isRunningAsService() {
5826
5826
  return process.env["OPENFOX_SERVICE"] === "true";
5827
5827
  }
5828
+ var UPDATE_TIMEOUT = 12e4;
5829
+ async function checkAuth(req, opts) {
5830
+ if (opts.requireAuth) {
5831
+ const authorized = await opts.requireAuth(req);
5832
+ if (!authorized) {
5833
+ return false;
5834
+ }
5835
+ }
5836
+ return true;
5837
+ }
5828
5838
  function createAutoUpdateRoutes(options = {}) {
5829
5839
  const router = Router6();
5830
- router.get("/check", async (req, res) => {
5831
- const isTest = req.query["test"] === "1";
5840
+ router.get("/check", async (_req, res) => {
5832
5841
  const isService = isRunningAsService();
5833
5842
  const current = VERSION;
5834
- if (isTest) {
5835
- res.json({ current: "1.0.0", latest: "1.1.0", isUpdateAvailable: true, isService });
5836
- return;
5837
- }
5838
5843
  try {
5839
5844
  const latest = await new Promise((resolve3, reject) => {
5840
5845
  const child = spawn5("npm", ["view", "openfox", "version"], {
@@ -5864,45 +5869,64 @@ function createAutoUpdateRoutes(options = {}) {
5864
5869
  }
5865
5870
  });
5866
5871
  router.post("/", async (req, res) => {
5867
- if (options.requireAuth) {
5868
- const authorized = await options.requireAuth(req);
5869
- if (!authorized) {
5870
- res.status(401).json({ error: "Unauthorized" });
5871
- return;
5872
- }
5872
+ if (!await checkAuth(req, options)) {
5873
+ res.status(401).json({ error: "Unauthorized" });
5874
+ return;
5873
5875
  }
5874
5876
  if (updateInProgress) {
5875
5877
  res.status(409).json({ error: "Update already in progress" });
5876
5878
  return;
5877
5879
  }
5880
+ updateInProgress = true;
5878
5881
  try {
5879
- let stderr = "";
5880
5882
  const isService = isRunningAsService();
5881
- const updateCmd = isService ? "openfox update --service" : "openfox update";
5882
- const child = spawn5("bash", ["-c", updateCmd], {
5883
- detached: true,
5884
- stdio: ["ignore", "ignore", "pipe"]
5883
+ const child = spawn5("bash", ["-c", "openfox update"], {
5884
+ stdio: ["ignore", "pipe", "pipe"]
5885
5885
  });
5886
- if (child.stderr) {
5887
- child.stderr.on("data", (data) => {
5888
- stderr += data.toString();
5889
- });
5890
- }
5891
- child.unref();
5892
- updateInProgress = true;
5893
- child.on("close", () => {
5894
- updateInProgress = false;
5886
+ let stdout = "";
5887
+ let stderr = "";
5888
+ child.stdout?.on("data", (data) => {
5889
+ stdout += data.toString();
5895
5890
  });
5896
- setTimeout(() => {
5897
- if (stderr) {
5898
- console.error("[auto-update] subprocess error:", stderr);
5899
- }
5900
- updateInProgress = false;
5901
- }, 3e4);
5902
- res.json({ success: true, isService });
5891
+ child.stderr?.on("data", (data) => {
5892
+ stderr += data.toString();
5893
+ });
5894
+ const timeout = setTimeout(() => {
5895
+ child.kill();
5896
+ }, UPDATE_TIMEOUT);
5897
+ const exitCode = await new Promise((resolve3) => {
5898
+ child.on("close", resolve3);
5899
+ child.on("error", () => resolve3(1));
5900
+ });
5901
+ clearTimeout(timeout);
5902
+ if (exitCode === 0) {
5903
+ const versionMatch = stdout.match(/Updated: ([\d.]+)/);
5904
+ const version = versionMatch?.[1] ?? VERSION;
5905
+ res.json({ success: true, version, isService });
5906
+ } else {
5907
+ const error = exitCode === null ? "Update timed out" : stderr || stdout || "Update failed";
5908
+ res.json({ success: false, error, isService });
5909
+ }
5903
5910
  } catch (err) {
5904
- updateInProgress = false;
5905
5911
  res.status(500).json({ error: err instanceof Error ? err.message : "Update failed to start" });
5912
+ } finally {
5913
+ updateInProgress = false;
5914
+ }
5915
+ });
5916
+ router.post("/restart", async (req, res) => {
5917
+ if (!await checkAuth(req, options)) {
5918
+ res.status(401).json({ error: "Unauthorized" });
5919
+ return;
5920
+ }
5921
+ try {
5922
+ const child = spawn5("bash", ["-c", "openfox service restart"], {
5923
+ detached: true,
5924
+ stdio: "ignore"
5925
+ });
5926
+ child.unref();
5927
+ res.json({ success: true });
5928
+ } catch (err) {
5929
+ res.status(500).json({ error: err instanceof Error ? err.message : "Failed to trigger restart" });
5906
5930
  }
5907
5931
  });
5908
5932
  return router;
@@ -6547,10 +6571,11 @@ async function createServerHandle(config4) {
6547
6571
  });
6548
6572
  app.get("/api/providers/models", async (req, res) => {
6549
6573
  const url = req.query["url"];
6574
+ const apiKey = req.query["apiKey"];
6550
6575
  if (!url) return res.status(400).json({ error: "url is required" });
6551
6576
  try {
6552
6577
  const { fetchModelsWithContext } = await import("./provider-manager-YA2WALTF.js");
6553
- const models = await fetchModelsWithContext(url);
6578
+ const models = await fetchModelsWithContext(url, apiKey);
6554
6579
  if (models.length === 0) {
6555
6580
  return res.status(404).json({ error: `No models found at ${buildModelsUrl(url)}`, url });
6556
6581
  }
@@ -7027,4 +7052,4 @@ export {
7027
7052
  createServerHandle,
7028
7053
  createServer
7029
7054
  };
7030
- //# sourceMappingURL=chunk-HMTROIVE.js.map
7055
+ //# sourceMappingURL=chunk-22ZTEMW6.js.map
@@ -124,7 +124,8 @@ async function runCli(options) {
124
124
  "no-browser": { type: "boolean" },
125
125
  help: { type: "boolean", short: "h" },
126
126
  version: { type: "boolean", short: "v" },
127
- service: { type: "boolean" }
127
+ service: { type: "boolean" },
128
+ follow: { type: "boolean", short: "f" }
128
129
  },
129
130
  allowPositionals: true,
130
131
  strict: true
@@ -159,6 +160,9 @@ async function runCli(options) {
159
160
  case "service": {
160
161
  const { runServiceCommand } = await import("./service-FJ4TW5L7.js");
161
162
  const [, subcommand, ...serviceArgs] = positionals;
163
+ if (values.follow) {
164
+ serviceArgs.push("-f");
165
+ }
162
166
  if (subcommand === "--help" || subcommand === "-h" || values.help) {
163
167
  runServiceCommand(mode, void 0);
164
168
  } else {
@@ -180,8 +184,7 @@ async function runCli(options) {
180
184
  const __filename = fileURLToPath(import.meta.url);
181
185
  const __dirname = dirname(__filename);
182
186
  const updateScriptPath = join(__dirname, "cli", "update.sh");
183
- const updateArgs = values["service"] ? ["--service"] : [];
184
- const result = spawnSync(updateScriptPath, updateArgs, { shell: true, stdio: "inherit" });
187
+ const result = spawnSync(updateScriptPath, [], { shell: true, stdio: "inherit" });
185
188
  if (result.status !== 0) {
186
189
  process.exit(result.status ?? 1);
187
190
  }
@@ -193,7 +196,7 @@ async function runCli(options) {
193
196
  if (!configExists) {
194
197
  await runNetworkSetup(mode);
195
198
  }
196
- const { runServe } = await import("./serve-L7ZELNVN.js");
199
+ const { runServe } = await import("./serve-KRO3CDHT.js");
197
200
  const serveOptions = { mode };
198
201
  if (values.port) serveOptions.port = parseInt(values.port);
199
202
  if (values["no-browser"] === true) serveOptions.openBrowser = false;
@@ -205,4 +208,4 @@ async function runCli(options) {
205
208
  export {
206
209
  runCli
207
210
  };
208
- //# sourceMappingURL=chunk-L5XRDDFW.js.map
211
+ //# sourceMappingURL=chunk-NVMGZPN2.js.map
package/dist/cli/dev.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  runCli
4
- } from "../chunk-L5XRDDFW.js";
4
+ } from "../chunk-NVMGZPN2.js";
5
5
  import {
6
6
  logger
7
7
  } from "../chunk-K44MW7JJ.js";
package/dist/cli/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  runCli
4
- } from "../chunk-L5XRDDFW.js";
4
+ } from "../chunk-NVMGZPN2.js";
5
5
  import {
6
6
  logger
7
7
  } from "../chunk-K44MW7JJ.js";
@@ -13,11 +13,5 @@ echo "Updating OpenFox: $CURRENT_VERSION -> $LATEST_VERSION"
13
13
  npm cache clean --force
14
14
  npm update -g openfox
15
15
  NEW_VERSION=$(openfox --version)
16
-
17
- if [ "$1" = "--service" ]; then
18
- echo "Restarting service..."
19
- systemd-run --user --scope systemctl --user restart openfox
20
- else
21
- echo "Updated: $NEW_VERSION"
22
- echo "Please restart OpenFox to use the new version."
23
- fi
16
+ echo "Updated: $NEW_VERSION"
17
+ echo "Please restart OpenFox to use the new version."
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openfox",
3
- "version": "2.0.6",
3
+ "version": "2.0.8",
4
4
  "description": "Local-LLM-first agentic coding assistant",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  VERSION,
3
3
  createServer
4
- } from "./chunk-HMTROIVE.js";
4
+ } from "./chunk-22ZTEMW6.js";
5
5
  import "./chunk-NZCKCJH5.js";
6
6
  import "./chunk-LIOHT26X.js";
7
7
  import "./chunk-KGZMKMEZ.js";
@@ -188,4 +188,4 @@ async function runServe(options) {
188
188
  export {
189
189
  runServe
190
190
  };
191
- //# sourceMappingURL=serve-L7ZELNVN.js.map
191
+ //# sourceMappingURL=serve-KRO3CDHT.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createServer,
3
3
  createServerHandle
4
- } from "../chunk-HMTROIVE.js";
4
+ } from "../chunk-22ZTEMW6.js";
5
5
  import "../chunk-NZCKCJH5.js";
6
6
  import "../chunk-LIOHT26X.js";
7
7
  import "../chunk-KGZMKMEZ.js";