wormclaude 1.0.237 → 1.0.238
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/theme.js +1 -1
- package/dist/tools.js +30 -0
- package/package.json +1 -1
package/dist/theme.js
CHANGED
package/dist/tools.js
CHANGED
|
@@ -7,6 +7,7 @@ import { createRequire } from 'node:module';
|
|
|
7
7
|
import * as fs from 'node:fs';
|
|
8
8
|
import * as os from 'node:os';
|
|
9
9
|
import * as path from 'node:path';
|
|
10
|
+
import * as net from 'node:net';
|
|
10
11
|
import { loadConfig } from './api.js';
|
|
11
12
|
import { runAgentLoop } from './agent.js';
|
|
12
13
|
import { resolveSubagent, subagentTypesHint, platformNote } from './subagents.js';
|
|
@@ -33,6 +34,28 @@ const DEFAULT_BASH_TIMEOUT_MS = 120000;
|
|
|
33
34
|
// Sunucu/never-exits komutları: ön planda çalışırsa CLI'ı bloklar (timeout'a kadar "donma").
|
|
34
35
|
// Bunları run_in_background istenmese bile OTOMATİK arka plana alıyoruz → CLI asla donmaz.
|
|
35
36
|
const _DEV_SERVER_RE = /\b(?:npm|pnpm|yarn)\s+(?:run\s+)?(?:dev|start|serve|preview)\b|\b(?:next|nuxt|vite|gatsby)\s+(?:dev|develop|start)\b|\bng\s+serve\b|\breact-scripts\s+start\b|\bnodemon\b|\bhttp-server\b|(?:^|\s)serve(?:\s|$)|\bpython3?\s+-m\s+http\.server\b|\bflask\s+run\b|\buvicorn\b|\bgunicorn\b|\bphp\s+-S\b|\brails\s+s(?:erver)?\b|\bwebpack(?:-dev-server)?\s+serve\b/i;
|
|
37
|
+
// Dev-server komutundan portu çıkar (http.server 9090 / -S host:8000 / --port 3000 / -p 8080 / :9090).
|
|
38
|
+
function _extractServerPort(cmd) {
|
|
39
|
+
const m = cmd.match(/\bhttp\.server\s+(\d{2,5})\b/i)
|
|
40
|
+
|| cmd.match(/-S\s+[^\s:]*:(\d{2,5})/i)
|
|
41
|
+
|| cmd.match(/(?:--port[=\s]+|(?:^|\s)-p\s+|:)(\d{2,5})\b/i);
|
|
42
|
+
const p = m ? Number(m[1]) : NaN;
|
|
43
|
+
return p >= 1 && p <= 65535 ? p : null;
|
|
44
|
+
}
|
|
45
|
+
// Port 127.0.0.1'de zaten dinleniyor mu? Kısa TCP bağlantı denemesi (bağlanabiliyorsa DOLU).
|
|
46
|
+
function _portInUse(port) {
|
|
47
|
+
return new Promise((resolve) => {
|
|
48
|
+
const sock = net.connect({ port, host: '127.0.0.1' });
|
|
49
|
+
const done = (v) => { try {
|
|
50
|
+
sock.destroy();
|
|
51
|
+
}
|
|
52
|
+
catch { } resolve(v); };
|
|
53
|
+
sock.setTimeout(700);
|
|
54
|
+
sock.once('connect', () => done(true));
|
|
55
|
+
sock.once('timeout', () => done(false));
|
|
56
|
+
sock.once('error', () => done(false));
|
|
57
|
+
});
|
|
58
|
+
}
|
|
36
59
|
const MAX_BASH_TIMEOUT_MS = 600000;
|
|
37
60
|
// Paket KURULUM komutları (winget/choco/pip/apt/brew/npm -g …) yavaştır (indirme+derleme):
|
|
38
61
|
// 2 dk default timeout'u aşıp ÖLDÜRÜLÜYORLARDI → "install yarım kaldı" + devre-kesici tetikleniyordu.
|
|
@@ -1665,6 +1688,13 @@ export async function executeTool(name, args) {
|
|
|
1665
1688
|
// Sunucu/never-exits komutu → run_in_background istenmese bile otomatik arka plana al (donma yok).
|
|
1666
1689
|
const _autoBg = !args.run_in_background && _DEV_SERVER_RE.test(_cmd);
|
|
1667
1690
|
if (args.run_in_background || _autoBg) {
|
|
1691
|
+
// PORT ÇAKIŞMASI: dev-server sabit bir portta başlatılacaksa ve o port ZATEN doluysa,
|
|
1692
|
+
// yeni sunucu bind edemez → istekler ESKİ sunucuya gider (curl 200 yanıltıcı, yanlış site).
|
|
1693
|
+
// Başlatmadan önce yakala, modele başka port söylet.
|
|
1694
|
+
const _sp = _extractServerPort(_cmd);
|
|
1695
|
+
if (_sp != null && await _portInUse(_sp)) {
|
|
1696
|
+
return { ok: false, output: `[PORT-IN-USE] Port ${_sp} is already occupied by another server on this machine — starting here would NOT serve your files (requests would hit that OTHER server, so a 200 check is misleading and the user sees the wrong site). Pick a DIFFERENT free port (e.g. ${_sp === 8000 ? 8181 : 8000}, 8090, or 5500) and run the command again with that port, then tell the user the new URL.` };
|
|
1697
|
+
}
|
|
1668
1698
|
const task = tasks.create('shell', _cmd.slice(0, 60));
|
|
1669
1699
|
const child = spawn(_cmd, { shell: true, windowsHide: true, cwd: getBashCwd() });
|
|
1670
1700
|
task.child = child;
|