coding-tool-x 3.6.11 → 3.6.12
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/README.md +6 -8
- package/package.json +1 -1
- package/src/commands/daemon.js +3 -1
- package/src/commands/ui.js +4 -3
- package/src/index.js +11 -0
- package/src/server/index.js +0 -15
- package/src/utils/cli-flags.js +7 -0
package/README.md
CHANGED
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
- 支持配置模板,将提示词、技能、命令、代理、MCP、插件组合成一套模板
|
|
59
59
|
- 支持 Dashboard、Analytics、日志、统计导出、环境诊断
|
|
60
60
|
- 支持面板访问密码
|
|
61
|
-
- LAN
|
|
61
|
+
- LAN 模式默认允许面板的远程写操作
|
|
62
62
|
|
|
63
63
|
### 通知
|
|
64
64
|
|
|
@@ -148,17 +148,15 @@ ctx ui --https
|
|
|
148
148
|
|
|
149
149
|
```bash
|
|
150
150
|
ctx ui --host
|
|
151
|
+
# 或
|
|
152
|
+
ctx --hosts
|
|
151
153
|
```
|
|
152
154
|
|
|
153
155
|
LAN 模式说明:
|
|
154
156
|
|
|
155
157
|
- 服务会监听 `0.0.0.0`
|
|
156
|
-
-
|
|
157
|
-
-
|
|
158
|
-
|
|
159
|
-
```bash
|
|
160
|
-
CC_TOOL_ALLOW_REMOTE_WRITE=true ctx ui --host
|
|
161
|
-
```
|
|
158
|
+
- 局域网内可访问 Web UI,并默认允许面板写入配置
|
|
159
|
+
- `ctx ui --hosts` 是同等别名
|
|
162
160
|
|
|
163
161
|
### 单独控制平台代理
|
|
164
162
|
|
|
@@ -342,7 +340,7 @@ npm test
|
|
|
342
340
|
|
|
343
341
|
## 已知说明
|
|
344
342
|
|
|
345
|
-
- `ctx ui --host` 开启 LAN
|
|
343
|
+
- `ctx ui --host` / `ctx ui --hosts` 开启 LAN 访问后,局域网内默认可执行面板写操作,请只在可信网络中使用
|
|
346
344
|
- OpenCode 部分能力依赖本机可访问的 OpenCode 配置目录和 `sqlite3`
|
|
347
345
|
- 配置导出包可能包含 API Key、Webhook、OAuth 等敏感信息,请妥善保管
|
|
348
346
|
|
package/package.json
CHANGED
package/src/commands/daemon.js
CHANGED
|
@@ -11,6 +11,7 @@ const {
|
|
|
11
11
|
getPortToolIssue,
|
|
12
12
|
formatPortToolIssue
|
|
13
13
|
} = require('../utils/port-helper');
|
|
14
|
+
const { hasHostFlag } = require('../utils/cli-flags');
|
|
14
15
|
|
|
15
16
|
const PM2_APP_NAME = 'cc-tool';
|
|
16
17
|
const STARTUP_LOG_FILE = 'cc-tool-out.log';
|
|
@@ -499,7 +500,7 @@ async function handleStart() {
|
|
|
499
500
|
try {
|
|
500
501
|
const config = loadConfig();
|
|
501
502
|
const port = config.ports?.webUI || 19999;
|
|
502
|
-
const enableHost =
|
|
503
|
+
const enableHost = hasHostFlag();
|
|
503
504
|
const enableHttps = process.argv.includes('--https');
|
|
504
505
|
fs.mkdirSync(PATHS.logs, { recursive: true });
|
|
505
506
|
|
|
@@ -733,6 +734,7 @@ module.exports = {
|
|
|
733
734
|
_test: {
|
|
734
735
|
detectStalePm2RuntimeIssue,
|
|
735
736
|
extractMissingPm2ForkScriptPath,
|
|
737
|
+
buildStartOptions,
|
|
736
738
|
shouldTreatPortOwnershipAsReady,
|
|
737
739
|
getManagedPorts,
|
|
738
740
|
shouldStopPM2Process
|
package/src/commands/ui.js
CHANGED
|
@@ -3,13 +3,14 @@ const { startServer } = require('../server');
|
|
|
3
3
|
const open = require('open');
|
|
4
4
|
const { getProxyStatus } = require('../server/proxy-server');
|
|
5
5
|
const { loadConfig } = require('../config/loader');
|
|
6
|
+
const { hasHostFlag } = require('../utils/cli-flags');
|
|
6
7
|
|
|
7
8
|
async function handleUI() {
|
|
8
9
|
// 检查是否为 daemon 模式(PM2 启动)
|
|
9
10
|
const isDaemon = process.argv.includes('--daemon');
|
|
10
11
|
|
|
11
|
-
// 检查是否启用 LAN 访问 (--host 标志)
|
|
12
|
-
const enableHost =
|
|
12
|
+
// 检查是否启用 LAN 访问 (--host/--hosts 标志)
|
|
13
|
+
const enableHost = hasHostFlag();
|
|
13
14
|
const enableHttps = process.argv.includes('--https');
|
|
14
15
|
const host = enableHost ? '0.0.0.0' : '127.0.0.1';
|
|
15
16
|
const protocol = enableHttps ? 'https' : 'http';
|
|
@@ -18,7 +19,7 @@ async function handleUI() {
|
|
|
18
19
|
console.clear();
|
|
19
20
|
console.log(chalk.cyan.bold('\n[NET] 启动 Coding-Tool Web UI...\n'));
|
|
20
21
|
if (enableHost) {
|
|
21
|
-
console.log(chalk.yellow('[WARN] LAN 访问已启用 (--host)\n'));
|
|
22
|
+
console.log(chalk.yellow('[WARN] LAN 访问已启用 (--host/--hosts)\n'));
|
|
22
23
|
}
|
|
23
24
|
if (enableHttps) {
|
|
24
25
|
console.log(chalk.yellow('[LOCK] 已启用本地 HTTPS 模式 (--https)\n'));
|
package/src/index.js
CHANGED
|
@@ -16,6 +16,7 @@ const { handleUpdate } = require('./commands/update');
|
|
|
16
16
|
const { ensureStorageDirMigrated } = require('./config/paths');
|
|
17
17
|
const PluginManager = require('./plugins/plugin-manager');
|
|
18
18
|
const eventBus = require('./plugins/event-bus');
|
|
19
|
+
const { hasHostFlag } = require('./utils/cli-flags');
|
|
19
20
|
const chalk = require('chalk');
|
|
20
21
|
const path = require('path');
|
|
21
22
|
const fs = require('fs');
|
|
@@ -53,9 +54,12 @@ function showHelp() {
|
|
|
53
54
|
console.log(' ctx ui 前台启动 Web UI(仅本地访问)');
|
|
54
55
|
console.log(' ctx ui --https 前台启动 Web UI(本地 HTTPS)');
|
|
55
56
|
console.log(' ctx ui --host 前台启动 Web UI(允许 LAN 访问)');
|
|
57
|
+
console.log(' ctx ui --hosts 前台启动 Web UI(同 --host)');
|
|
58
|
+
console.log(' ctx --hosts 前台启动 Web UI(同 ctx ui --host)');
|
|
56
59
|
console.log(' ctx ui start 后台启动 Web UI');
|
|
57
60
|
console.log(' ctx ui start --https 后台启动 Web UI(本地 HTTPS)');
|
|
58
61
|
console.log(' ctx ui start --host 后台启动 Web UI(允许 LAN 访问)');
|
|
62
|
+
console.log(' ctx ui start --hosts 后台启动 Web UI(同 --host)');
|
|
59
63
|
console.log(' ctx ui stop 停止 Web UI');
|
|
60
64
|
console.log(' ctx ui restart 重启 Web UI\n');
|
|
61
65
|
|
|
@@ -156,6 +160,13 @@ async function main() {
|
|
|
156
160
|
return;
|
|
157
161
|
}
|
|
158
162
|
|
|
163
|
+
// LAN 快捷入口,等同于 ctx ui --host/--hosts
|
|
164
|
+
if (hasHostFlag(process.argv) && !args.some((arg) => arg && !arg.startsWith('-'))) {
|
|
165
|
+
const { handleUI } = require('./commands/ui');
|
|
166
|
+
await handleUI();
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
|
|
159
170
|
// daemon 命令兼容(保持与 README 中旧命令一致)
|
|
160
171
|
if (args[0] === 'daemon') {
|
|
161
172
|
const subCommand = args[1] || 'status';
|
package/src/server/index.js
CHANGED
|
@@ -23,7 +23,6 @@ const { startProxyServer } = require('./proxy-server');
|
|
|
23
23
|
const { startCodexProxyServer } = require('./codex-proxy-server');
|
|
24
24
|
const { startGeminiProxyServer } = require('./gemini-proxy-server');
|
|
25
25
|
const { startOpenCodeProxyServer, collectProxyModelList } = require('./opencode-proxy-server');
|
|
26
|
-
const { createRemoteMutationGuard } = require('./services/network-access');
|
|
27
26
|
const { createApiRequestLogger } = require('./services/request-logger');
|
|
28
27
|
const { inspectWebBuildState, ensureWebDistReady } = require('./services/web-build');
|
|
29
28
|
const { ensureHttpsCredentials } = require('./services/https-cert');
|
|
@@ -149,8 +148,6 @@ async function startServer(port, host = '127.0.0.1', options = {}) {
|
|
|
149
148
|
|
|
150
149
|
const app = express();
|
|
151
150
|
const useHttps = options.useHttps === true || process.argv.includes('--https');
|
|
152
|
-
const lanMode = host === '0.0.0.0';
|
|
153
|
-
const allowRemoteMutation = process.env.CC_TOOL_ALLOW_REMOTE_WRITE === 'true';
|
|
154
151
|
|
|
155
152
|
// Middleware
|
|
156
153
|
app.use(express.json({ limit: '100mb' }));
|
|
@@ -170,15 +167,6 @@ async function startServer(port, host = '127.0.0.1', options = {}) {
|
|
|
170
167
|
// API 请求日志(由 CC_TOOL_LOG_API_REQUESTS=true 环境变量控制,默认关闭)
|
|
171
168
|
app.use('/api', createApiRequestLogger());
|
|
172
169
|
|
|
173
|
-
if (lanMode) {
|
|
174
|
-
app.use('/api', createRemoteMutationGuard({
|
|
175
|
-
enabled: true,
|
|
176
|
-
allowRemoteMutation,
|
|
177
|
-
message: '出于安全考虑,LAN 模式默认仅允许本机执行写操作。可设置 CC_TOOL_ALLOW_REMOTE_WRITE=true 覆盖。'
|
|
178
|
-
}));
|
|
179
|
-
|
|
180
|
-
}
|
|
181
|
-
|
|
182
170
|
// API Routes
|
|
183
171
|
app.use('/api/projects', require('./api/projects')(config));
|
|
184
172
|
app.use('/api/sessions', require('./api/sessions')(config));
|
|
@@ -316,9 +304,6 @@ async function startServer(port, host = '127.0.0.1', options = {}) {
|
|
|
316
304
|
console.log(chalk.gray(' [TIP] 首次访问自签名证书时,浏览器可能会提示手动信任本地证书'));
|
|
317
305
|
}
|
|
318
306
|
|
|
319
|
-
if (host === '0.0.0.0' && !allowRemoteMutation) {
|
|
320
|
-
console.log(chalk.yellow(' [LOCK] 已启用 LAN 安全保护:远程写操作默认禁用'));
|
|
321
|
-
}
|
|
322
307
|
// 自动恢复代理状态
|
|
323
308
|
autoRestoreProxies();
|
|
324
309
|
|