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.
- package/dist/{chunk-HMTROIVE.js → chunk-22ZTEMW6.js} +62 -37
- package/dist/{chunk-L5XRDDFW.js → chunk-NVMGZPN2.js} +8 -5
- package/dist/cli/dev.js +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli/update.sh +2 -8
- package/dist/package.json +1 -1
- package/dist/{serve-L7ZELNVN.js → serve-KRO3CDHT.js} +2 -2
- package/dist/server/index.js +1 -1
- package/dist/web/assets/{index-Cwshb4LW.js → index-BBA0xZ_3.js} +46 -46
- package/dist/web/index.html +1 -1
- package/dist/web/sw.js +1 -1
- package/package.json +1 -1
|
@@ -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.
|
|
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 (
|
|
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
|
|
5868
|
-
|
|
5869
|
-
|
|
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
|
|
5882
|
-
|
|
5883
|
-
detached: true,
|
|
5884
|
-
stdio: ["ignore", "ignore", "pipe"]
|
|
5883
|
+
const child = spawn5("bash", ["-c", "openfox update"], {
|
|
5884
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
5885
5885
|
});
|
|
5886
|
-
|
|
5887
|
-
|
|
5888
|
-
|
|
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
|
-
|
|
5897
|
-
|
|
5898
|
-
|
|
5899
|
-
|
|
5900
|
-
|
|
5901
|
-
},
|
|
5902
|
-
|
|
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-
|
|
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
|
|
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-
|
|
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-
|
|
211
|
+
//# sourceMappingURL=chunk-NVMGZPN2.js.map
|
package/dist/cli/dev.js
CHANGED
package/dist/cli/index.js
CHANGED
package/dist/cli/update.sh
CHANGED
|
@@ -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
|
-
|
|
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,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
VERSION,
|
|
3
3
|
createServer
|
|
4
|
-
} from "./chunk-
|
|
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-
|
|
191
|
+
//# sourceMappingURL=serve-KRO3CDHT.js.map
|