@ia-ccun/code-agent-claw 0.0.4 → 0.0.5

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/bin/cli.js CHANGED
@@ -18,17 +18,32 @@ if (args.includes('--help') || args.includes('-h')) {
18
18
  console.log('Usage: code-agent-claw [options]');
19
19
  console.log('');
20
20
  console.log('Options:');
21
- console.log(' --version, -v Show version number');
22
- console.log(' --help, -h Show this help message');
21
+ console.log(' --version, -v Show version number');
22
+ console.log(' --port, -p <port> Specify server port (default: 8081)');
23
+ console.log(' --help, -h Show this help message');
23
24
  process.exit(0);
24
25
  }
25
26
 
27
+ // 解析端口参数
28
+ let port = null;
29
+ for (let i = 0; i < args.length; i++) {
30
+ if ((args[i] === '--port' || args[i] === '-p') && args[i + 1]) {
31
+ port = args[i + 1];
32
+ break;
33
+ }
34
+ }
35
+
26
36
  const distPath = path.join(__dirname, '..', 'dist', 'index.js');
27
37
 
38
+ const env = { ...process.env };
39
+ if (port) {
40
+ env.AICODE_UI_PORT = port;
41
+ }
42
+
28
43
  const child = spawn('node', [distPath], {
29
44
  stdio: 'inherit',
30
45
  cwd: process.cwd(),
31
- env: process.env
46
+ env
32
47
  });
33
48
 
34
49
  child.on('exit', (code) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ia-ccun/code-agent-claw",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "Code Agent Claw WebUI - Node.js implementation with frontend configuration",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
package/public/index.html CHANGED
@@ -1771,7 +1771,19 @@
1771
1771
 
1772
1772
  // WebSocket
1773
1773
  let ws;
1774
+ let reconnectTimer;
1774
1775
  function connectWebSocket() {
1776
+ // 清除之前的重连定时器
1777
+ if (reconnectTimer) {
1778
+ clearTimeout(reconnectTimer);
1779
+ reconnectTimer = null;
1780
+ }
1781
+
1782
+ // 关闭旧的连接
1783
+ if (ws && ws.readyState === WebSocket.OPEN) {
1784
+ ws.close();
1785
+ }
1786
+
1775
1787
  const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
1776
1788
  const wsUrl = `${protocol}//${window.location.host}/ws/agent`;
1777
1789
 
@@ -1792,7 +1804,7 @@
1792
1804
  };
1793
1805
 
1794
1806
  ws.onclose = () => {
1795
- setTimeout(connectWebSocket, 3000);
1807
+ reconnectTimer = setTimeout(connectWebSocket, 3000);
1796
1808
  };
1797
1809
  }
1798
1810