huaweicloud-devkit 1.0.2-dev.6 → 1.0.2-dev.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "huaweicloud-devkit",
3
- "version": "1.0.2-dev.6",
3
+ "version": "1.0.2-dev.8",
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-dev.6",
23
+ "version": "1.0.2-dev.8",
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-dev.6",
3
+ "version": "1.0.2-dev.8",
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-dev.6",
23
+ "version": "1.0.2-dev.8",
24
24
  "author": {
25
25
  "name": "HuaweiCloud Mate",
26
26
  "url": "https://github.com/huaweicloud"
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: huawei-sandbox
3
- description: "Use when creating, connecting, or managing Huawei Cloud Sandbox instances and workspace terminals, or when a task needs a temporary runtime to deploy, run, or preview a web application. Covers sandbox lifecycle (check-user, sign-agreement, connect, release), session-based terminal execution, and credential injection. Triggers on: sandbox, workspace, terminal, web app deployment, deploy web app, preview app, hwlink, devstation, hdkitservice, remote exec. NOT for: ECS instances (use huawei-ecs), CCE clusters (use huawei-cce)."
3
+ description: "Use when creating, connecting, or managing Huawei Cloud Sandbox instances and workspace terminals, or when a task needs a temporary runtime to deploy, run, or preview a web application. Covers sandbox lifecycle (check-user, sign-agreement, connect, release), session-based terminal execution, and credential injection. Triggers on: sandbox, workspace, terminal, web app deployment, deploy web app, preview app, deploy github, github repo, deploy repo, website, static site, web application, hwlink, devstation, hdkitservice, remote exec. NOT for: ECS instances (use huawei-ecs), CCE clusters (use huawei-cce)."
4
4
  version: 1
5
5
  ---
6
6
 
@@ -15,6 +15,8 @@ Domain expertise for Huawei Cloud Sandbox (DevStation) instances and workspace t
15
15
  ## Activation
16
16
 
17
17
  - **Proactive offering**: when the developer's task needs a temporary runtime (e.g. "deploy this web app", "run this app and preview it"), offer the sandbox proactively — the developer never has to say "use sandbox". Prompt: "This task can be satisfied by a sandbox — use it?"
18
+ - **Detect web apps in deploy-a-repo prompts**: prompts like "部署 GitHub - <owner>/<repo>" or "deploy <github repo>" do not say "web app". Clone or inspect the repository first (package.json with dev/serve/build scripts, index.html, frontend framework dependencies such as vue/react/angular/vite, static sites, Dockerfile running a web server). If it is a web application, offer the sandbox first: "检测到该项目是 Web 应用,建议优先使用沙箱部署(临时运行环境,可预览访问),是否使用?"
19
+ - **Deployment must end with a public URL**: after deploying and exposing the app with DevBridge, always return the tunnel URL to the developer as the final result — a deployment without an accessible link is incomplete.
18
20
  - **Do not intercept a specified target**: if the task already names a deployment target (ECS, CCE, an existing server), follow that target instead of offering the sandbox. Offer the sandbox only when the task needs a temporary runtime or no target is specified.
19
21
  - The developer never needs to name or understand the sandbox as a separate service. Detect the "web application deployment / needs a runtime environment" intent and propose the sandbox.
20
22
 
@@ -52,7 +54,42 @@ Setup is a **plugin-side preflight** — the developer should be asked a questio
52
54
  4. **Connect**: `huaweicloud_sandbox_connect` — returns `session_id`, `dev_stage_id`, `connection_id`, `connection_address`
53
55
  5. **Inject credentials** (optional): `huaweicloud_sandbox_credentials` — enables cloud API access from sandbox
54
56
  6. **Execute commands**: `huaweicloud_sandbox_exec_with_session` for interactive work
55
- 7. **Release**: `huaweicloud_sandbox_release` cleans up sandbox and session
57
+ 7. **Expose the deployed app with DevBridge**: install DevBridge in the sandbox, log in with the developer's AK/SK, create a tunnel for the app port, and return the public URL to the developer (see "DevBridge reverse proxy")
58
+ 8. **Release**: `huaweicloud_sandbox_release` — cleans up sandbox and session
59
+
60
+ ## DevBridge reverse proxy
61
+
62
+ Expose a deployed web app to a public URL and return that URL to the developer.
63
+
64
+ **Install** (skip if `devbridge version` already works):
65
+
66
+ ```bash
67
+ curl -fsSL https://res-hd.hc-cdn.cn/sharedata/hdspace/devbridge/install.sh | bash
68
+ export PATH=$PATH:$HOME/.huawei/bin # installer only writes ~/.bashrc; session shells do not re-source it
69
+ ```
70
+
71
+ **Login** (non-interactive, credentials come from the developer's local agent — the vault or HW_ACCESS_KEY/HW_SECRET_KEY; never echo them):
72
+
73
+ ```bash
74
+ devbridge auth login --huaweicloud --access-key "$AK" --secret-key "$SK"
75
+ ```
76
+
77
+ - The `--huaweicloud` flag is required for AK/SK login; without it the CLI tries an interactive browser login, which fails in the sandbox.
78
+ - Write the AK/SK to temp files with `umask 077` (or shell vars) and delete them right after login. Verify with `devbridge auth status`.
79
+
80
+ **Expose** (run the web server and the tunnel in the background, then read the URL from the log):
81
+
82
+ ```bash
83
+ cd <app-dir> && nohup python3 -m http.server 8080 > /tmp/http.log 2>&1 &
84
+ nohup devbridge host -p 8080 -e 8 > /tmp/host.log 2>&1 &
85
+ sleep 10 && cat /tmp/host.log
86
+ ```
87
+
88
+ - The tunnel URL has the form `https://<tunnelId>-<port>.cn-north-4-bridge.myhuaweicloud.com` (from the `Tunnel URL:` line).
89
+ - **Return this URL to the developer as the deployment result link.** Keep the host process running (do not close the session before handing over the URL).
90
+ - Docs: https://huaweicloud.github.io/devspace-devbridge/
91
+
92
+ **No local downgrade**: if DevBridge cannot be installed in the sandbox, STOP and report the error. Never install DevBridge on the developer's local machine — a local install would defeat the purpose of sandbox deployment.
56
93
 
57
94
  ## Critical Warnings
58
95
 
@@ -60,10 +97,27 @@ Setup is a **plugin-side preflight** — the developer should be asked a questio
60
97
  |------|-----|
61
98
  | Agreement required first | `sandbox_connect` fails if the agreement isn't signed; the `sandbox_check_user` preflight detects this, so surface it to the developer only when signing is needed |
62
99
  | Real-name required | `sandbox_connect` fails if `realname_verified=false`; tell the developer once and stop, don't loop on connect |
100
+ | DevBridge login needs `--huaweicloud` | `devbridge auth login --access-key/--secret-key` without `--huaweicloud` falls back to interactive browser login, which fails in the sandbox |
101
+ | DevBridge PATH | The installer only writes `~/.bashrc`; run `export PATH=$PATH:$HOME/.huawei/bin` in the session before using `devbridge` |
102
+ | Never install DevBridge locally | If the sandbox cannot install DevBridge, report the error and stop — installing on the developer's machine defeats sandbox deployment |
103
+ | Return the deployment URL | Always hand the `Tunnel URL` from `devbridge host` to the developer as the final result |
63
104
  | Session state persists | `exec_with_session` preserves `cd`, env vars, aliases between calls |
64
105
  | Destructive commands blocked | `rm -rf /`, `mkfs`, `dd if=`, fork bombs are denied by safety policy |
65
106
  | Workspace ID = dev_stage_id | Use `dev_stage_id` from `sandbox_connect` as `workspace_id` for terminal exec |
66
- | Node.js >= 22 required | Sandbox terminal uses built-in WebSocket (globalThis.WebSocket) |
107
+ | Node.js >= 22 required | Sandbox terminal uses built-in WebSocket (globalThis.WebSocket); if Node.js is missing, install it from the Huawei Cloud mirror (see "Node.js in the sandbox") |
108
+
109
+ ## Node.js in the sandbox
110
+
111
+ If the sandbox has no Node.js, download it from the Huawei Cloud mirror. Pick the tarball matching the sandbox arch (`uname -m`: `aarch64` -> arm64, `x86_64` -> x64):
112
+
113
+ ```bash
114
+ # aarch64 sandbox:
115
+ curl -fsSL https://mirrors.huaweicloud.com/nodejs/v24.19.0/node-v24.19.0-linux-arm64.tar.gz -o node.tar.gz
116
+ # x86_64 sandbox:
117
+ curl -fsSL https://mirrors.huaweicloud.com/nodejs/v24.19.0/node-v24.19.0-linux-x64.tar.gz -o node.tar.gz
118
+ sudo tar -xzf node.tar.gz -C /usr/local --strip-components=1
119
+ node --version
120
+ ```
67
121
 
68
122
  ## Environment Variables
69
123
 
@@ -36,7 +36,8 @@ Do not rely on training data for facts. Huawei Cloud services, pricing, quotas,
36
36
  | observability | Observability Routing | monitor, alarm, log, audit, trace, Cloud Eye | Handoff to huawei-cloud-eye or huawei-cts |
37
37
  | billing | Billing Routing | cost, bill, budget, spending, invoice | Handoff to huawei-billing |
38
38
  | iam | IAM Routing | permission, policy, role, user, group, AK/SK | Handoff to huawei-iam |
39
- | deployment | Deployment Routing | deploy, CI/CD, pipeline, release | Handoff to huawei-deployment |
39
+ | deployment | Deployment Routing | deploy, CI/CD, pipeline, release | CI/CD pipeline -> huawei-deployment; deploy a web app or a GitHub repo (no CI/CD target) -> huawei-sandbox |
40
+ | sandbox | Sandbox Routing | sandbox, DevStation, workspace, terminal, preview, temporary runtime | Handoff to huawei-sandbox |
40
41
  | cli | CLI and Auth Routing | install hcloud, configure KooCLI, AK/SK setup | Handoff to huaweicloud-cli-and-auth |
41
42
  | safety | Safety Routing | is this safe, approve command, risk review | Handoff to huaweicloud-safety |
42
43
  | troubleshoot | Troubleshooting Routing | error, bug, failed, AccessDenied, quota | Handoff to huaweicloud-troubleshooting |
@@ -67,6 +68,7 @@ Do not rely on training data for facts. Huawei Cloud services, pricing, quotas,
67
68
  | Audit trails | CTS | huawei-cts |
68
69
  | Backup / disaster recovery | CBR | huawei-cbr |
69
70
  | CI/CD pipeline | CloudDeploy | huawei-deployment |
71
+ | Temporary runtime / web app preview | Sandbox (DevStation) | huawei-sandbox |
70
72
  | Getting started | Account setup | huaweicloud-cli-and-auth |
71
73
 
72
74
  ## Capability Sources
@@ -1417,6 +1417,13 @@ function printAuthStatus(status) {
1417
1417
  async function cmdAuthInit() {
1418
1418
  console.log(BANNER);
1419
1419
  console.log('HuaweiCloud DevKit Unified Authentication Setup\n');
1420
+ console.log('\x1b[1m获取 AK/SK(如果还没有):\x1b[0m');
1421
+ console.log(' 1. 打开华为云控制台:');
1422
+ console.log(' https://console.huaweicloud.com/console/?region=cn-north-4#/home');
1423
+ console.log(' 2. 点击右上角账号名 -> 我的凭证');
1424
+ console.log(' 3. 进入"访问密钥"页签 -> 点击"新增访问密钥",完成身份验证');
1425
+ console.log(' 4. 下载凭证文件(内含 AK 和 SK)。');
1426
+ console.log(' 注意:SK 只在创建密钥时显示一次,请妥善保存该文件。\n');
1420
1427
 
1421
1428
  let ak = process.env.HW_ACCESS_KEY || '';
1422
1429
  let sk = process.env.HW_SECRET_KEY || '';
@@ -1445,22 +1452,21 @@ async function cmdAuthInit() {
1445
1452
 
1446
1453
 
1447
1454
  const vaultPath = writeGlobalCredentials({ ak, sk, securityToken, region });
1448
- console.log(`\nCredentials stored: ${vaultPath}`);
1449
1455
 
1450
1456
  try {
1451
- const obs = writeObsConfig({ ak, sk, securityToken, region });
1452
- console.log(`OBS config synced: ${obs.path} (${obs.endpoint})`);
1457
+ writeObsConfig({ ak, sk, securityToken, region });
1453
1458
  } catch (error) {
1454
1459
  console.log(`OBS config sync failed: ${error.message}`);
1455
1460
  }
1456
1461
 
1457
1462
  if (findHcloudBin()) {
1458
1463
  const result = configureHcloud({ ak, sk, region });
1459
- console.log(result.ok ? 'KooCLI profile updated.' : `KooCLI update failed: ${result.error || result.code}`);
1464
+ if (!result.ok) console.log(`KooCLI update failed: ${result.error || result.code}`);
1460
1465
  } else {
1461
1466
  console.log('KooCLI not found. Run "npx huaweicloud-devkit install-hcloud" and then "auth sync".');
1462
1467
  }
1463
1468
 
1469
+ console.log('\nCredentials synchronized.');
1464
1470
  console.log('\nNext steps:');
1465
1471
  console.log(' npx huaweicloud-devkit install --target all');
1466
1472
  console.log(' Restart your agent sessions.');
@@ -1480,12 +1486,10 @@ async function cmdAuthSync() {
1480
1486
 
1481
1487
  const result = syncAuth(target);
1482
1488
  if (result.ok) {
1483
- console.log(`OBS config synced: ${result.obs.path} (${result.obs.endpoint})`);
1489
+ console.log('Credentials synchronized.');
1484
1490
  } else {
1485
1491
  console.error(result.error);
1486
1492
  }
1487
- console.log('Agent MCP registration:');
1488
- printAuthAgents(result.agents);
1489
1493
  }
1490
1494
 
1491
1495
  async function cmdAuthStatus() {
@@ -721,6 +721,7 @@ function serviceCatalog(intent = '') {
721
721
  { keywords: ['cts', 'audit', 'trace', 'tracker'], skills: ['huawei-cts'], services: ['CTS'] },
722
722
  { keywords: ['cbr', 'backup', 'restore', 'vault', 'snapshot'], skills: ['huawei-cbr'], services: ['CBR'] },
723
723
  { keywords: ['deployment', 'deploy', 'ci/cd', 'pipeline', 'release'], skills: ['huawei-deployment'], services: ['CloudDeploy'] },
724
+ { keywords: ['sandbox', 'devstation', 'workspace', 'terminal', 'preview', 'hwlink'], skills: ['huawei-sandbox'], services: ['Sandbox', 'DevStation'] },
724
725
  { keywords: ['dds', 'dcs', 'mongodb', 'redis', 'memcached', 'cache', 'document db'], skills: ['huawei-dds-dcs'], services: ['DDS', 'DCS'] },
725
726
  ];
726
727
  const matched = [];