huaweicloud-devkit 1.0.2-next.5 → 1.0.2-next.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "huaweicloud-devkit",
3
- "version": "1.0.2-next.5",
3
+ "version": "1.0.2-next.6",
4
4
  "description": "Agent toolkit that helps coding agents use Huawei Cloud Skills, KooCLI, APIs, SDKs, and future MCP capabilities safely and accurately.",
5
5
  "type": "module",
6
6
  "files": [
@@ -20,7 +20,7 @@
20
20
  "mcpServers": "./.mcp.json",
21
21
  "description": "Guide coding agents to use Huawei Cloud Skills, KooCLI, APIs, SDKs, and future MCP capabilities with safer execution and less context.",
22
22
  "skills": "./skills/",
23
- "version": "1.0.2-next.5",
23
+ "version": "1.0.2-next.6",
24
24
  "author": {
25
25
  "name": "HuaweiCloud Mate",
26
26
  "url": "https://github.com/huaweicloud"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "huaweicloud-core",
3
- "version": "1.0.2-next.5",
3
+ "version": "1.0.2-next.6",
4
4
  "description": "Guide coding agents to use Huawei Cloud Skills, KooCLI, APIs, SDKs, and future MCP capabilities with safer execution and less context.",
5
5
  "author": {
6
6
  "name": "HuaweiCloud Mate",
@@ -20,7 +20,7 @@
20
20
  "mcpServers": "./.mcp.json",
21
21
  "description": "Guide coding agents to use Huawei Cloud Skills, KooCLI, APIs, SDKs, and future MCP capabilities with safer execution and less context.",
22
22
  "skills": "./skills/",
23
- "version": "1.0.2-next.5",
23
+ "version": "1.0.2-next.6",
24
24
  "author": {
25
25
  "name": "HuaweiCloud Mate",
26
26
  "url": "https://github.com/huaweicloud"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "huaweicloud-core",
3
- "version": "1.0.2-next.5",
3
+ "version": "1.0.2-next.6",
4
4
  "description": "Guide coding agents to use Huawei Cloud Skills, KooCLI, APIs, SDKs, and future MCP capabilities with safer execution and less context.",
5
5
  "author": {
6
6
  "name": "HuaweiCloud Mate",
@@ -1,5 +1,6 @@
1
1
  import { spawn } from 'node:child_process';
2
2
  import { classifyHcloudArgs, redactSecrets, assertAllowed } from './safety-policy.mjs';
3
+ import { getProxySettings } from './proxy/proxy-config.mjs';
3
4
 
4
5
  const DEFAULT_TIMEOUT_MS = 60_000;
5
6
  const DEFAULT_FORCE_KILL_AFTER_MS = 2_000;
@@ -59,12 +60,20 @@ function runHcloudOnce(plan, options) {
59
60
  const cwd = options.cwd || undefined;
60
61
 
61
62
  return new Promise((resolve) => {
63
+ const proxySettings = getProxySettings();
64
+ const proxyEnv = {};
65
+ if (proxySettings) {
66
+ if (proxySettings.https_proxy) proxyEnv.HTTPS_PROXY = proxySettings.https_proxy;
67
+ if (proxySettings.http_proxy) proxyEnv.HTTP_PROXY = proxySettings.http_proxy;
68
+ if (proxySettings.no_proxy) proxyEnv.NO_PROXY = proxySettings.no_proxy;
69
+ }
62
70
  const child = spawn(executable, [...executableArgs, ...plan.rawArgs], {
63
71
  shell: false,
64
72
  windowsHide: true,
65
73
  cwd,
66
74
  env: {
67
75
  ...process.env,
76
+ ...proxyEnv,
68
77
  ...options.env,
69
78
  },
70
79
  });
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
2
3
  import { stdin, stdout } from 'node:process';
3
4
  import { rmSync, existsSync } from 'node:fs';
4
5
  import { resolve, dirname } from 'node:path';
@@ -3,6 +3,11 @@ import { getProxyUrlForTarget } from './proxy-config.mjs';
3
3
  let cachedDispatcher = undefined;
4
4
  let cachedDispatcherProxyUrl = null;
5
5
 
6
+ async function importUndici() {
7
+ try { return await import('node:undici'); }
8
+ catch { return await import('undici'); }
9
+ }
10
+
6
11
  export async function getProxyDispatcher(targetUrl) {
7
12
  const proxyUrl = getProxyUrlForTarget(targetUrl);
8
13
  if (!proxyUrl) return undefined;
@@ -11,7 +16,7 @@ export async function getProxyDispatcher(targetUrl) {
11
16
  return cachedDispatcher;
12
17
  }
13
18
 
14
- const { ProxyAgent } = await import('undici');
19
+ const { ProxyAgent } = await importUndici();
15
20
  cachedDispatcher = new ProxyAgent(proxyUrl);
16
21
  cachedDispatcherProxyUrl = proxyUrl;
17
22
  return cachedDispatcher;
@@ -29,7 +34,7 @@ export async function createProxyWebSocket(url, protocols) {
29
34
  }
30
35
 
31
36
  const dispatcher = await getProxyDispatcher(url);
32
- const { WebSocket: UndiciWebSocket } = await import('undici');
37
+ const { WebSocket: UndiciWebSocket } = await importUndici();
33
38
 
34
39
  const wsOptions = { dispatcher };
35
40
  if (protocols) {
@@ -55,7 +60,7 @@ export function getWebSocketImpl(targetUrl) {
55
60
 
56
61
  const wsPromise = (async () => {
57
62
  const dispatcher = await getProxyDispatcher(url);
58
- const { WebSocket: UndiciWebSocket } = await import('undici');
63
+ const { WebSocket: UndiciWebSocket } = await importUndici();
59
64
 
60
65
  const wsOptions = { dispatcher };
61
66
  if (protocols) {
@@ -47,6 +47,10 @@ function shouldBypassProxy(hostname, noProxyList) {
47
47
  if (!p) continue;
48
48
  if (p === lower) return true;
49
49
  if (p === '*') return true;
50
+ if (p.startsWith('*.')) {
51
+ const domain = p.slice(1);
52
+ if (lower.endsWith(domain) || lower === p.slice(2)) return true;
53
+ }
50
54
  if (p.startsWith('.') && lower.endsWith(p)) return true;
51
55
  if (lower.endsWith('.' + p)) return true;
52
56
  }
@@ -60,9 +64,9 @@ export function getProxySettings(targetUrl) {
60
64
 
61
65
  const fileConfig = readProxyConfig();
62
66
 
63
- const https_proxy = envHttps || (fileConfig?.https_proxy || '');
64
- const http_proxy = envHttp || (fileConfig?.http_proxy || '');
65
- const no_proxy = envNoProxy || (fileConfig?.no_proxy || '');
67
+ const https_proxy = envHttps || fileConfig?.https_proxy || fileConfig?.HTTPS_PROXY || '';
68
+ const http_proxy = envHttp || fileConfig?.http_proxy || fileConfig?.HTTP_PROXY || '';
69
+ const no_proxy = envNoProxy || fileConfig?.no_proxy || fileConfig?.NO_PROXY || '';
66
70
 
67
71
  if (!https_proxy && !http_proxy) return null;
68
72
 
@@ -1131,8 +1131,9 @@ async function cmdInstall() {
1131
1131
 
1132
1132
  console.log(`\n\x1b[1m下一步:\x1b[0m`);
1133
1133
  console.log(` 1. 配置统一凭据:npx huaweicloud-devkit auth init`);
1134
- console.log(` 2. 重启 ${appName} 会话(MCP 工具重启后生效)`);
1135
- console.log(` 3. 运行自检:npx huaweicloud-devkit doctor`);
1134
+ console.log(` 2. 配置代理(企业内网):npx huaweicloud-devkit proxy init`);
1135
+ console.log(` 3. 重启 ${appName} 会话(MCP 工具重启后生效)`);
1136
+ console.log(` 4. 运行自检:npx huaweicloud-devkit doctor`);
1136
1137
 
1137
1138
  // Write install marker for doctor to detect
1138
1139
  const markerDir = target === 'dsh' ? dshPluginsDir()
@@ -1874,12 +1875,12 @@ async function cmdProxyInit() {
1874
1875
 
1875
1876
  const httpsProxy = await readLineQuestion(`HTTPS proxy [${existing.https_proxy || 'none'}]: `);
1876
1877
  const httpProxy = await readLineQuestion(`HTTP proxy [${existing.http_proxy || 'none'}]: `);
1877
- const noProxy = await readLineQuestion(`NO_PROXY hosts [${existing.no_proxy || 'localhost,127.0.0.1'}]: `);
1878
+ const noProxy = await readLineQuestion(`NO_PROXY hosts [${existing.no_proxy || '127.0.0.1,localhost,.huawei.com'}]: `);
1878
1879
 
1879
1880
  const config = {
1880
1881
  https_proxy: httpsProxy || existing.https_proxy || '',
1881
1882
  http_proxy: httpProxy || existing.http_proxy || '',
1882
- no_proxy: noProxy || existing.no_proxy || 'localhost,127.0.0.1',
1883
+ no_proxy: noProxy || existing.no_proxy || '127.0.0.1,localhost,.huawei.com',
1883
1884
  };
1884
1885
 
1885
1886
  const path = writeProxyConfig(config);