ompgui 0.4.0 → 0.4.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.
- package/.next/BUILD_ID +1 -1
- package/.next/app-path-routes-manifest.json +2 -2
- package/.next/build-manifest.json +3 -3
- package/.next/prerender-manifest.json +3 -3
- package/.next/react-loadable-manifest.json +1 -1
- package/.next/required-server-files.js +3 -2
- package/.next/required-server-files.json +3 -2
- package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.rsc +2 -2
- package/.next/server/app/_global-error.segments/_full.segment.rsc +2 -2
- package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found/page.js +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +3 -3
- package/.next/server/app/_not-found.segments/_full.segment.rsc +3 -3
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/api/app-update/route.js +1 -1
- package/.next/server/app/api/auth/all-providers/route.js +1 -1
- package/.next/server/app/api/auth/api-key/[provider]/route.js +1 -1
- package/.next/server/app/api/auth/logout/[provider]/route.js +1 -1
- package/.next/server/app/api/mcp/route.js +1 -1
- package/.next/server/app/api/models-config/catalog/route.js +1 -1
- package/.next/server/app/api/models-config/route.js +1 -1
- package/.next/server/app/api/models-config/test/route.js +1 -1
- package/.next/server/app/api/omp-version/route.js +1 -1
- package/.next/server/app/api/plugins/route.js +1 -1
- package/.next/server/app/api/sessions/[id]/context/route.js +1 -1
- package/.next/server/app/api/sessions/[id]/export/route.js +1 -1
- package/.next/server/app/api/sessions/[id]/route.js +1 -1
- package/.next/server/app/api/web-auth/session/route.js +1 -1
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +4 -4
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +3 -3
- package/.next/server/app/index.segments/_full.segment.rsc +4 -4
- package/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/login/page.js +1 -1
- package/.next/server/app/login/page_client-reference-manifest.js +1 -1
- package/.next/server/app/login.html +1 -1
- package/.next/server/app/login.rsc +4 -4
- package/.next/server/app/login.segments/_full.segment.rsc +4 -4
- package/.next/server/app/login.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/login.segments/login/__PAGE__.segment.rsc +3 -3
- package/.next/server/app/page.js +3 -3
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app-paths-manifest.json +2 -2
- package/.next/server/chunks/1671.js +1 -1
- package/.next/server/chunks/3798.js +1 -1
- package/.next/server/chunks/4445.js +1 -1
- package/.next/server/chunks/6209.js +1 -1
- package/.next/server/chunks/6465.js +1 -1
- package/.next/server/chunks/7834.js +1 -1
- package/.next/server/instrumentation.js +1 -1
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/.next/server/middleware.js +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/static/chunks/4315-9e1f7675d0f49d8b.js +1 -0
- package/.next/static/chunks/6522.07d01cfb1ad3768e.js +1 -0
- package/.next/static/chunks/app/login/page-529e71a823982db0.js +1 -0
- package/.next/static/chunks/app/{page-60629bbe3fe259ef.js → page-0d51c0ee4910e024.js} +6 -6
- package/.next/static/chunks/{webpack-11f7dad1df4f814f.js → webpack-d5d95f150515a23a.js} +1 -1
- package/README.ja.md +28 -28
- package/README.ko.md +28 -28
- package/README.md +28 -28
- package/README.zh-CN.md +28 -28
- package/bin/node-version.js +1 -1
- package/bin/omp-web-options.js +1 -85
- package/bin/omp-web.js +1 -153
- package/bin/ompgui-options.js +24 -0
- package/bin/ompgui-security.test.mjs +8 -0
- package/bin/ompgui.js +31 -0
- package/next.config.ts +1 -0
- package/package.json +6 -6
- package/.next/static/chunks/4315-50f4eb7d435d214a.js +0 -1
- package/.next/static/chunks/6522.a49bd5d1f0532830.js +0 -1
- package/.next/static/chunks/app/login/page-e9ec076f136fb627.js +0 -1
- /package/.next/static/{YAZYeEe1KDqN7al9eJ-PR → VBxoKAa50kI5B1rMOpGl3}/_buildManifest.js +0 -0
- /package/.next/static/{YAZYeEe1KDqN7al9eJ-PR → VBxoKAa50kI5B1rMOpGl3}/_ssgManifest.js +0 -0
package/bin/omp-web-options.js
CHANGED
|
@@ -1,86 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
4
|
-
const { parseArgs } = require("util");
|
|
5
|
-
|
|
6
|
-
const TRUE_VALUES = new Set(["1", "true", "yes", "on"]);
|
|
7
|
-
|
|
8
|
-
function isEnabled(value) {
|
|
9
|
-
return typeof value === "string" && TRUE_VALUES.has(value.trim().toLowerCase());
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
function printHelp() {
|
|
14
|
-
console.log(`Usage: ompweb [options]
|
|
15
|
-
|
|
16
|
-
Options:
|
|
17
|
-
-p, --port <port> Server port (default 30177, env PORT)
|
|
18
|
-
-H, --hostname <host> Bind hostname (default 127.0.0.1, env OMP_WEB_HOSTNAME)
|
|
19
|
-
--password <pass> Password for the web sign-in screen (env OMP_WEB_PASSWORD)
|
|
20
|
-
--no-open Do not open the browser automatically
|
|
21
|
-
-h, --help Show this help
|
|
22
|
-
--version Show version
|
|
23
|
-
|
|
24
|
-
Password:
|
|
25
|
-
ompweb --password "a-long-random-password"
|
|
26
|
-
# env-variable forms (POSIX, PowerShell, CMD handled uniformly)
|
|
27
|
-
OMP_WEB_PASSWORD="secret" ompweb
|
|
28
|
-
$env:OMP_WEB_PASSWORD="secret"; ompweb # PowerShell
|
|
29
|
-
set OMP_WEB_PASSWORD=secret&& ompweb # CMD
|
|
30
|
-
|
|
31
|
-
Security: use HTTPS via a trusted reverse proxy or VPN when binding to a
|
|
32
|
-
non-loopback hostname, so the password and session cookie stay private.`);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function parseLaunchOptions(args = process.argv.slice(2), env = process.env) {
|
|
36
|
-
const { values: cliArgs } = parseArgs({
|
|
37
|
-
args,
|
|
38
|
-
options: {
|
|
39
|
-
port: { type: "string", short: "p" },
|
|
40
|
-
hostname: { type: "string", short: "H" },
|
|
41
|
-
password: { type: "string" },
|
|
42
|
-
help: { type: "boolean", short: "h" },
|
|
43
|
-
version: { type: "boolean" },
|
|
44
|
-
"no-open": { type: "boolean" },
|
|
45
|
-
},
|
|
46
|
-
strict: false,
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
// --password wins over env so Windows users without POSIX inline-env syntax have a first-class option.
|
|
50
|
-
const password = cliArgs.password ?? env.OMP_WEB_PASSWORD;
|
|
51
|
-
if (cliArgs.version) {
|
|
52
|
-
try {
|
|
53
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
54
|
-
const pkg = require("../package.json");
|
|
55
|
-
console.log(pkg.version ?? "0.0.0");
|
|
56
|
-
} catch { console.log("0.0.0"); }
|
|
57
|
-
return {
|
|
58
|
-
port: cliArgs.port ?? env.PORT ?? "30177",
|
|
59
|
-
hostname: cliArgs.hostname ?? env.OMP_WEB_HOSTNAME ?? "127.0.0.1",
|
|
60
|
-
password,
|
|
61
|
-
openBrowser: !cliArgs["no-open"] && !isEnabled(env.OMP_WEB_NO_OPEN),
|
|
62
|
-
version: true,
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
// Expose help flag without exiting here — caller (bin/omp-web.js) decides
|
|
66
|
-
// whether to exit, keeping parseLaunchOptions testable. Print here so
|
|
67
|
-
// --help works even when the caller is a test.
|
|
68
|
-
if (cliArgs.help) {
|
|
69
|
-
printHelp();
|
|
70
|
-
return {
|
|
71
|
-
port: cliArgs.port ?? env.PORT ?? "30177",
|
|
72
|
-
hostname: cliArgs.hostname ?? env.OMP_WEB_HOSTNAME ?? "127.0.0.1",
|
|
73
|
-
password,
|
|
74
|
-
openBrowser: !cliArgs["no-open"] && !isEnabled(env.OMP_WEB_NO_OPEN),
|
|
75
|
-
help: true,
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
return {
|
|
79
|
-
port: cliArgs.port ?? env.PORT ?? "30177",
|
|
80
|
-
hostname: cliArgs.hostname ?? env.OMP_WEB_HOSTNAME ?? "127.0.0.1",
|
|
81
|
-
password,
|
|
82
|
-
openBrowser: !cliArgs["no-open"] && !isEnabled(env.OMP_WEB_NO_OPEN),
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
module.exports = { parseLaunchOptions };
|
|
2
|
+
module.exports = require("./ompgui-options");
|
package/bin/omp-web.js
CHANGED
|
@@ -1,155 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
-
|
|
4
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
5
|
-
const { getUnsupportedNodeVersionMessage, isNodeVersionSupported } = require("./node-version");
|
|
6
|
-
|
|
7
|
-
if (!isNodeVersionSupported(process.versions.node)) {
|
|
8
|
-
console.error(getUnsupportedNodeVersionMessage(process.versions.node));
|
|
9
|
-
process.exit(1);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
13
|
-
const { spawn } = require("child_process");
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
15
|
-
const path = require("path");
|
|
16
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
17
|
-
const fs = require("fs");
|
|
18
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
19
|
-
const { parseLaunchOptions } = require("./omp-web-options");
|
|
20
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
21
|
-
const { isPortAvailable } = require("./port-availability");
|
|
22
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
23
|
-
const { wireChildProcessLifecycle } = require("./process-lifecycle");
|
|
24
|
-
|
|
25
|
-
const pkgDir = path.join(__dirname, "..");
|
|
26
|
-
const nextDir = path.join(pkgDir, ".next");
|
|
27
|
-
|
|
28
|
-
// Resolve next's CLI entry directly to avoid relying on .bin symlinks (which
|
|
29
|
-
// may not exist when installed via npx).
|
|
30
|
-
let nextBin;
|
|
31
|
-
try {
|
|
32
|
-
nextBin = require.resolve("next/dist/bin/next", { paths: [pkgDir] });
|
|
33
|
-
} catch {
|
|
34
|
-
// Fallback: locate next package root and derive the bin path manually.
|
|
35
|
-
try {
|
|
36
|
-
const nextPkg = require.resolve("next/package.json", { paths: [pkgDir] });
|
|
37
|
-
nextBin = path.join(path.dirname(nextPkg), "dist", "bin", "next");
|
|
38
|
-
} catch {
|
|
39
|
-
nextBin = path.join(pkgDir, "node_modules", "next", "dist", "bin", "next");
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const launchOptions = parseLaunchOptions();
|
|
44
|
-
if (launchOptions.help || launchOptions.version) {
|
|
45
|
-
process.exit(0);
|
|
46
|
-
}
|
|
47
|
-
const port = launchOptions.port;
|
|
48
|
-
const hostname = launchOptions.hostname;
|
|
49
|
-
const password = launchOptions.password;
|
|
50
|
-
const openBrowser = launchOptions.openBrowser;
|
|
51
|
-
// Propagate --password into the env for proxy.ts / lib/web-auth.ts and the spawned Next process.
|
|
52
|
-
if (password) process.env.OMP_WEB_PASSWORD = password;
|
|
53
|
-
const loopbackHostnames = new Set(["127.0.0.1", "localhost", "::1", "[::1]"]);
|
|
54
|
-
const passwordEnabled = typeof password === "string" && password.length > 0;
|
|
55
|
-
|
|
56
|
-
if (!fs.existsSync(nextDir)) {
|
|
57
|
-
console.error("Build artifacts not found. Please report this issue.");
|
|
58
|
-
process.exit(1);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (!loopbackHostnames.has(hostname)) {
|
|
62
|
-
if (!passwordEnabled) {
|
|
63
|
-
console.error(`Refusing to listen on ${hostname} without OMP_WEB_PASSWORD (or --password). Set a strong password or bind to 127.0.0.1.`);
|
|
64
|
-
process.exit(1);
|
|
65
|
-
}
|
|
66
|
-
console.warn(`Warning: ompweb is listening on ${hostname} over HTTP. Use HTTPS or a trusted VPN to protect the password and session cookie in transit.`);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const nextArgs = ["start", "-p", port];
|
|
70
|
-
nextArgs.push("-H", hostname);
|
|
71
|
-
|
|
72
|
-
// Always run next's JS entry with node directly — avoids .bin symlink issues
|
|
73
|
-
// and path-with-spaces problems on Windows when shell: true is used.
|
|
74
|
-
const url = `http://${hostname}:${port}`;
|
|
75
|
-
|
|
76
|
-
function openBrowserWindow(targetUrl) {
|
|
77
|
-
const isWindows = process.platform === "win32";
|
|
78
|
-
const isMac = process.platform === "darwin";
|
|
79
|
-
const isWsl = process.platform === "linux" && Boolean(process.env.WSL_DISTRO_NAME || process.env.WSL_INTEROP);
|
|
80
|
-
const openCmd = isWindows ? "cmd.exe" : isMac ? "open" : isWsl ? "wslview" : "xdg-open";
|
|
81
|
-
const openArgs = isWindows ? ["/c", "start", "", targetUrl] : [targetUrl];
|
|
82
|
-
|
|
83
|
-
try {
|
|
84
|
-
const opener = spawn(openCmd, openArgs, {
|
|
85
|
-
stdio: "ignore",
|
|
86
|
-
detached: true,
|
|
87
|
-
});
|
|
88
|
-
opener.on("error", (error) => {
|
|
89
|
-
console.warn(`Could not open browser automatically: ${error.message}`);
|
|
90
|
-
});
|
|
91
|
-
opener.unref();
|
|
92
|
-
} catch (error) {
|
|
93
|
-
console.warn(`Could not open browser automatically: ${error.message}`);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
async function main() {
|
|
98
|
-
if (!await isPortAvailable(port, hostname)) {
|
|
99
|
-
console.log(`ompweb is already running on ${hostname}:${port}.`);
|
|
100
|
-
if (openBrowser) {
|
|
101
|
-
console.log(`Opening ${url} in your browser...`);
|
|
102
|
-
openBrowserWindow(url);
|
|
103
|
-
}
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const child = spawn(process.execPath, [nextBin, ...nextArgs], {
|
|
108
|
-
cwd: pkgDir,
|
|
109
|
-
stdio: ["inherit", "pipe", "inherit"],
|
|
110
|
-
env: {
|
|
111
|
-
...process.env,
|
|
112
|
-
OMP_WEB_PACKAGE_DIR: pkgDir,
|
|
113
|
-
OMP_WEB_LAUNCHER_PID: String(process.pid),
|
|
114
|
-
OMP_WEB_PORT: port,
|
|
115
|
-
OMP_WEB_HOSTNAME: hostname,
|
|
116
|
-
},
|
|
117
|
-
});
|
|
118
|
-
wireChildProcessLifecycle(child);
|
|
119
|
-
|
|
120
|
-
let browserOpened = false;
|
|
121
|
-
const tryOpenBrowser = () => {
|
|
122
|
-
if (!openBrowser || browserOpened) return;
|
|
123
|
-
browserOpened = true;
|
|
124
|
-
openBrowserWindow(url);
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
child.stdout.on("data", (chunk) => {
|
|
128
|
-
const text = chunk.toString();
|
|
129
|
-
process.stdout.write(text);
|
|
130
|
-
if (/ready|started|local:\s*http|listening/i.test(text)) {
|
|
131
|
-
tryOpenBrowser();
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
if (openBrowser) {
|
|
136
|
-
const checkInterval = setInterval(async () => {
|
|
137
|
-
if (browserOpened) {
|
|
138
|
-
clearInterval(checkInterval);
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
const available = await isPortAvailable(port, hostname);
|
|
142
|
-
if (!available) {
|
|
143
|
-
clearInterval(checkInterval);
|
|
144
|
-
tryOpenBrowser();
|
|
145
|
-
}
|
|
146
|
-
}, 250);
|
|
147
|
-
|
|
148
|
-
setTimeout(() => clearInterval(checkInterval), 15000);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
main().catch((error) => {
|
|
153
|
-
console.error(`Could not check whether ${url} is available: ${error.message}`);
|
|
154
|
-
process.exit(1);
|
|
155
|
-
});
|
|
3
|
+
require("./ompgui.js");
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { parseArgs } = require("util");
|
|
4
|
+
const TRUE_VALUES = new Set(["1", "true", "yes", "on"]);
|
|
5
|
+
function isEnabled(value) { return typeof value === "string" && TRUE_VALUES.has(value.trim().toLowerCase()); }
|
|
6
|
+
function printHelp() {
|
|
7
|
+
console.log(`Usage: ompgui [options]
|
|
8
|
+
|
|
9
|
+
Options:
|
|
10
|
+
-p, --port <port> Server port (default 30177, env OMPGUI_PORT)
|
|
11
|
+
-H, --hostname <host> Bind hostname (default 127.0.0.1, env OMPGUI_HOSTNAME)
|
|
12
|
+
--password <pass> Password for the web sign-in screen (env OMPGUI_PASSWORD)
|
|
13
|
+
--no-open Do not open the browser automatically
|
|
14
|
+
-h, --help Show this help
|
|
15
|
+
--version Show version`);
|
|
16
|
+
}
|
|
17
|
+
function parseLaunchOptions(args = process.argv.slice(2), env = process.env) {
|
|
18
|
+
const { values: cliArgs } = parseArgs({ args, options: { port:{type:"string",short:"p"}, hostname:{type:"string",short:"H"}, password:{type:"string"}, help:{type:"boolean",short:"h"}, version:{type:"boolean"}, "no-open":{type:"boolean"} }, strict:false });
|
|
19
|
+
const result = { port: cliArgs.port ?? env.OMPGUI_PORT ?? env.PORT ?? env.OMP_WEB_PORT ?? "30177", hostname: cliArgs.hostname ?? env.OMPGUI_HOSTNAME ?? env.OMP_WEB_HOSTNAME ?? "127.0.0.1", password: cliArgs.password ?? env.OMPGUI_PASSWORD ?? env.OMP_WEB_PASSWORD, openBrowser: !cliArgs["no-open"] && !isEnabled(env.OMPGUI_NO_OPEN) && !isEnabled(env.OMP_WEB_NO_OPEN) };
|
|
20
|
+
if (cliArgs.help) { printHelp(); result.help = true; }
|
|
21
|
+
if (cliArgs.version) { try { result.version = true; console.log(require("../package.json").version ?? "0.0.0"); } catch { result.version = true; } }
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
module.exports = { parseLaunchOptions, isEnabled };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import test from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { spawnSync } from "node:child_process";
|
|
4
|
+
test("ompgui refuses unauthenticated non-loopback binds", () => {
|
|
5
|
+
const result = spawnSync(process.execPath, ["bin/ompgui.js", "--hostname", "0.0.0.0", "--no-open"], { encoding:"utf8", env:{ ...process.env, OMPGUI_PASSWORD:"", OMP_WEB_PASSWORD:"", OMPGUI_HOSTNAME:undefined, OMP_WEB_HOSTNAME:undefined } });
|
|
6
|
+
assert.equal(result.status, 1);
|
|
7
|
+
assert.match(result.stderr, /Refusing to listen/);
|
|
8
|
+
});
|
package/bin/ompgui.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
const { getUnsupportedNodeVersionMessage, isNodeVersionSupported } = require("./node-version");
|
|
4
|
+
if (!isNodeVersionSupported(process.versions.node)) { console.error(getUnsupportedNodeVersionMessage(process.versions.node)); process.exit(1); }
|
|
5
|
+
const { spawn } = require("child_process");
|
|
6
|
+
const path = require("path");
|
|
7
|
+
const fs = require("fs");
|
|
8
|
+
const { parseLaunchOptions } = require("./ompgui-options");
|
|
9
|
+
const { isPortAvailable } = require("./port-availability");
|
|
10
|
+
const { wireChildProcessLifecycle } = require("./process-lifecycle");
|
|
11
|
+
const pkgDir = path.join(__dirname, "..");
|
|
12
|
+
const nextDir = path.join(pkgDir, ".next");
|
|
13
|
+
let nextBin;
|
|
14
|
+
try { nextBin = require.resolve("next/dist/bin/next", { paths:[pkgDir] }); } catch { try { nextBin = path.join(path.dirname(require.resolve("next/package.json", {paths:[pkgDir]})), "dist", "bin", "next"); } catch { nextBin = path.join(pkgDir,"node_modules/next/dist/bin/next"); } }
|
|
15
|
+
const options = parseLaunchOptions();
|
|
16
|
+
if (options.help || options.version) process.exit(0);
|
|
17
|
+
const { port, hostname, password, openBrowser } = options;
|
|
18
|
+
if (password) { process.env.OMPGUI_PASSWORD = password; process.env.OMP_WEB_PASSWORD = password; }
|
|
19
|
+
const loopback = new Set(["127.0.0.1","localhost","::1","[::1]"]);
|
|
20
|
+
if (!fs.existsSync(nextDir)) { console.error("Build artifacts not found. Please report this issue."); process.exit(1); }
|
|
21
|
+
if (!loopback.has(hostname) && !(typeof password === "string" && password.length)) { console.error(`Refusing to listen on ${hostname} without OMPGUI_PASSWORD (or --password). Set a strong password or bind to 127.0.0.1.`); process.exit(1); }
|
|
22
|
+
const url = `http://${hostname}:${port}`;
|
|
23
|
+
function openBrowserWindow(target) { const cmd = process.platform === "win32" ? "cmd.exe" : process.platform === "darwin" ? "open" : process.platform === "linux" && (process.env.WSL_DISTRO_NAME || process.env.WSL_INTEROP) ? "wslview" : "xdg-open"; const args = process.platform === "win32" ? ["/c","start","",target] : [target]; try { const p=spawn(cmd,args,{stdio:"ignore",detached:true}); p.on("error",e=>console.warn(`Could not open browser automatically: ${e.message}`)); p.unref(); } catch(e) { console.warn(`Could not open browser automatically: ${e.message}`); } }
|
|
24
|
+
async function main() {
|
|
25
|
+
if (!await isPortAvailable(port, hostname)) { console.log(`ompgui is already running on ${hostname}:${port}.`); if (openBrowser) openBrowserWindow(url); return; }
|
|
26
|
+
const env={...process.env, OMPGUI_PACKAGE_DIR:pkgDir, OMPGUI_LAUNCHER_PID:String(process.pid), OMPGUI_PORT:port, OMPGUI_HOSTNAME:hostname, OMP_WEB_PACKAGE_DIR:pkgDir, OMP_WEB_LAUNCHER_PID:String(process.pid), OMP_WEB_PORT:port, OMP_WEB_HOSTNAME:hostname};
|
|
27
|
+
const child=spawn(process.execPath,[nextBin,"start","-p",port,"-H",hostname],{cwd:pkgDir,stdio:["inherit","pipe","inherit"],env}); wireChildProcessLifecycle(child);
|
|
28
|
+
let opened=false; const ready=()=>{if(!openBrowser||opened)return; opened=true; openBrowserWindow(url);}; child.stdout.on("data",c=>{process.stdout.write(c);if(/ready|started|local:\s*http|listening/i.test(c.toString()))ready();});
|
|
29
|
+
if(openBrowser){const timer=setInterval(async()=>{if(opened)return clearInterval(timer);if(!await isPortAvailable(port,hostname)){clearInterval(timer);ready();}},250);setTimeout(()=>clearInterval(timer),15000);}
|
|
30
|
+
}
|
|
31
|
+
main().catch(e=>{console.error(`Could not check whether ${url} is available: ${e.message}`);process.exit(1);});
|
package/next.config.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ompgui",
|
|
3
|
-
"version": "0.4.
|
|
4
|
-
"description": "Web UI for the oh-my-pi (omp) coding agent",
|
|
5
|
-
"homepage": "https://github.com/dbc-hbin/
|
|
3
|
+
"version": "0.4.2",
|
|
4
|
+
"description": "Web UI & Browser GUI for the oh-my-pi (omp) coding agent",
|
|
5
|
+
"homepage": "https://github.com/dbc-hbin/ompgui#readme",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/dbc-hbin/
|
|
8
|
+
"url": "git+https://github.com/dbc-hbin/ompgui.git"
|
|
9
9
|
},
|
|
10
10
|
"bugs": {
|
|
11
|
-
"url": "https://github.com/dbc-hbin/
|
|
11
|
+
"url": "https://github.com/dbc-hbin/ompgui/issues"
|
|
12
12
|
},
|
|
13
13
|
"author": "dbc-hbin",
|
|
14
14
|
"license": "MIT",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"node": ">=22.19.0"
|
|
17
17
|
},
|
|
18
18
|
"bin": {
|
|
19
|
-
"ompgui": "bin/
|
|
19
|
+
"ompgui": "bin/ompgui.js",
|
|
20
20
|
"ompweb": "bin/omp-web.js"
|
|
21
21
|
},
|
|
22
22
|
"files": [
|