duclaw-cli 1.9.7 → 1.9.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/bundle.js CHANGED
@@ -30242,7 +30242,7 @@ function printHelp() {
30242
30242
  `);
30243
30243
  }
30244
30244
  function printVersion() {
30245
- console.log(`duclaw-cli v${true ? "1.9.7" : "unknown"}`);
30245
+ console.log(`duclaw-cli v${true ? "1.9.8" : "unknown"}`);
30246
30246
  }
30247
30247
  function getDuclawTemplate() {
30248
30248
  return {
@@ -44508,6 +44508,7 @@ var MAX_SESSION_OUTPUT_LENGTH = 5e4;
44508
44508
  var DEFAULT_TIMEOUT_MS = 3e4;
44509
44509
  var DEFAULT_SESSION_TTL_MS = 30 * 60 * 1e3;
44510
44510
  var SHELL_CANDIDATES2 = ["/bin/sh", "/usr/bin/sh", "/bin/bash"];
44511
+ var DEFAULT_PROTECTED_PORTS = ["3100"];
44511
44512
  var sessions = /* @__PURE__ */ new Map();
44512
44513
  function findExecutableShell2() {
44513
44514
  for (const shell of SHELL_CANDIDATES2) {
@@ -44538,6 +44539,36 @@ function validateCwd(cwd) {
44538
44539
  return `[bash] \u9519\u8BEF: cwd \u4E0D\u53EF\u7528: ${cwd} (${err.message})`;
44539
44540
  }
44540
44541
  }
44542
+ function getProtectedPorts() {
44543
+ const configured = process.env.DUCLAW_BASH_PROTECTED_PORTS ?? [process.env.KANBAN_PORT, process.env.PORT, ...DEFAULT_PROTECTED_PORTS].filter(Boolean).join(",");
44544
+ return [...new Set(
44545
+ configured.split(",").map((port) => port.trim()).filter((port) => /^\d{1,5}$/.test(port))
44546
+ )];
44547
+ }
44548
+ function validateProtectedRuntimeCommand(command) {
44549
+ const ports = getProtectedPorts();
44550
+ if (ports.length === 0) return null;
44551
+ for (const port of ports) {
44552
+ const portRef = new RegExp(`(^|[^\\d])(:${port}|-${port}\\b|${port}/tcp\\b)`);
44553
+ const targetsProtectedPort = portRef.test(command);
44554
+ if (!targetsProtectedPort) continue;
44555
+ const killsProcess = /\b(kill|pkill|killall|fuser)\b/.test(command) || /\blsof\b[\s\S]*\bxargs\b[\s\S]*\bkill\b/.test(command) || /\bss\b[\s\S]*\bxargs\b[\s\S]*\bkill\b/.test(command);
44556
+ if (killsProcess) {
44557
+ return [
44558
+ `[bash] \u62D2\u7EDD\u6267\u884C: \u547D\u4EE4\u8BD5\u56FE\u6E05\u7406 Duclaw runtime \u4FDD\u7559\u7AEF\u53E3 ${port}\u3002`,
44559
+ `\u8BE5\u7AEF\u53E3\u627F\u8F7D\u5F53\u524D\u667A\u80FD\u4F53\u7684 HTTP/gateway\uFF0C\u6740\u6389\u5B83\u4F1A\u5BFC\u81F4 iOS \u663E\u793A\u5DF2\u5173\u673A\u6216 502\u3002`,
44560
+ `\u8BF7\u6362\u7528\u9879\u76EE\u81EA\u5DF1\u7684\u5F00\u53D1\u7AEF\u53E3\uFF08\u4F8B\u5982 3001/5173\uFF09\uFF0C\u4E0D\u8981\u5BF9 ${port} \u6267\u884C kill/lsof/fuser/pkill\u3002`
44561
+ ].join("\n");
44562
+ }
44563
+ }
44564
+ if (/\b(pkill|killall)\b[\s\S]*\b(node|tsx|pnpm|npm)\b/.test(command)) {
44565
+ return [
44566
+ `[bash] \u62D2\u7EDD\u6267\u884C: \u547D\u4EE4\u4F1A\u6309\u8FDB\u7A0B\u540D\u6279\u91CF\u7EC8\u6B62 Node/JS \u8FDB\u7A0B\u3002`,
44567
+ `\u8FD9\u53EF\u80FD\u8BEF\u6740 Duclaw runtime\u3002\u8BF7\u53EA\u7EC8\u6B62\u660E\u786E\u5C5E\u4E8E\u5F53\u524D\u9879\u76EE\u7684 PID \u6216 session_id\u3002`
44568
+ ].join("\n");
44569
+ }
44570
+ return null;
44571
+ }
44541
44572
  function truncateOutput(output, limit = MAX_OUTPUT_LENGTH) {
44542
44573
  if (output.length <= limit) return output;
44543
44574
  return output.slice(0, limit) + `
@@ -44659,6 +44690,8 @@ var bashTool = {
44659
44690
  if (!command || command.trim() === "") {
44660
44691
  return `[bash] \u9519\u8BEF: command \u4E0D\u80FD\u4E3A\u7A7A`;
44661
44692
  }
44693
+ const protectedCommandError = validateProtectedRuntimeCommand(command);
44694
+ if (protectedCommandError) return protectedCommandError;
44662
44695
  if (userRequest?.workspacePath && explicitCwd) {
44663
44696
  const rejection = validateWorkspacePath(explicitCwd, userRequest.workspacePath);
44664
44697
  if (rejection) return `[bash] ${rejection}`;
@@ -53504,7 +53537,7 @@ var systemRoutes = new Hono2();
53504
53537
  var startTime = Date.now();
53505
53538
  systemRoutes.get("/system/info", (c) => {
53506
53539
  return c.json({
53507
- version: true ? "1.9.7" : "unknown",
53540
+ version: true ? "1.9.8" : "unknown",
53508
53541
  uptime: Math.floor((Date.now() - startTime) / 1e3),
53509
53542
  env: process.env.NODE_ENV || "development",
53510
53543
  nodeVersion: process.version