huaweicloud-devkit 1.0.2-dev.0 → 1.0.2-dev.11
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/README.md +27 -3
- package/README.zh-CN.md +27 -3
- package/package.json +1 -1
- package/plugins/huaweicloud-core/.claude-plugin/plugin.json +1 -1
- package/plugins/huaweicloud-core/.codex-plugin/plugin.json +1 -1
- package/plugins/huaweicloud-core/.cursor-plugin/plugin.json +1 -1
- package/plugins/huaweicloud-core/.mcp.json +3 -1
- package/plugins/huaweicloud-core/safety/policy.json +15 -1
- package/plugins/huaweicloud-core/safety/rules/cloud-risk-rules.json +21 -0
- package/plugins/huaweicloud-core/skills/huawei-ecs/SKILL.md +1 -1
- package/plugins/huaweicloud-core/skills/huawei-ecs/references/troubleshooting.md +1 -1
- package/plugins/huaweicloud-core/skills/huawei-functiongraph/SKILL.md +1 -1
- package/plugins/huaweicloud-core/skills/huawei-getting-started/SKILL.md +2 -2
- package/plugins/huaweicloud-core/skills/huawei-obs/SKILL.md +8 -0
- package/plugins/huaweicloud-core/skills/huawei-obs/references/single-file-share.md +40 -0
- package/plugins/huaweicloud-core/skills/huawei-sandbox/SKILL.md +134 -0
- package/plugins/huaweicloud-core/skills/huaweicloud-cli-and-auth/SKILL.md +2 -1
- package/plugins/huaweicloud-core/skills/huaweicloud-core/SKILL.md +3 -1
- package/plugins/huaweicloud-core/skills/huaweicloud-troubleshooting/SKILL.md +1 -1
- package/plugins/huaweicloud-core/src/auth/agent-registration.mjs +87 -0
- package/plugins/huaweicloud-core/src/auth/credentials.mjs +95 -0
- package/plugins/huaweicloud-core/src/auth/service.mjs +63 -0
- package/plugins/huaweicloud-core/src/mcp-server.mjs +11 -0
- package/plugins/huaweicloud-core/src/sandbox/hdkitservice-api.mjs +87 -0
- package/plugins/huaweicloud-core/src/sandbox/hwlink-api.mjs +153 -0
- package/plugins/huaweicloud-core/src/sandbox/session-manager.mjs +105 -0
- package/plugins/huaweicloud-core/src/setup-cli.mjs +582 -68
- package/plugins/huaweicloud-core/src/tools.mjs +159 -3
- package/plugins/huaweicloud-core/src/ws-exec/hwlink-exec-client.js +427 -0
- package/plugins/huaweicloud-core/src/ws-exec/hwlink-fair-queue.js +132 -0
- package/plugins/huaweicloud-core/src/ws-exec/hwlink-multiplexer.js +227 -0
- package/plugins/huaweicloud-core/src/ws-exec/hwlink-packet.js +202 -0
- package/plugins/huaweicloud-core/src/ws-exec/hwlink-terminal-channel.js +158 -0
- package/plugins/huaweicloud-core/src/ws-exec/index.js +19 -0
- package/plugins/huaweicloud-core/src/ws-exec/ws-exec-client.js +338 -0
package/README.md
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# HuaweiCloud DevKit
|
|
2
2
|
|
|
3
|
+
[](https://github.com/huaweicloud/huaweicloud-devkit/discussions)
|
|
3
4
|
[](LICENSE)
|
|
4
|
-
[](https://github.com/huaweicloud/huaweicloud-devkit/actions/workflows/ci.yml)
|
|
5
6
|
|
|
6
7
|
**[中文](README.zh-CN.md) | English**
|
|
7
8
|
|
|
@@ -9,6 +10,10 @@ Help AI coding agents use Huawei Cloud safely and accurately — a single integr
|
|
|
9
10
|
|
|
10
11
|
Supports OpenCode, Codex, CodeArts Agent, and WorkBuddy.
|
|
11
12
|
|
|
13
|
+
## Prerequisites
|
|
14
|
+
|
|
15
|
+
- Node.js >= 20
|
|
16
|
+
|
|
12
17
|
## Quick Start
|
|
13
18
|
|
|
14
19
|
### OpenCode
|
|
@@ -34,6 +39,15 @@ npx --yes huaweicloud-devkit install --target codex
|
|
|
34
39
|
|
|
35
40
|
> The Codex CLI must be installed first.
|
|
36
41
|
|
|
42
|
+
```bash
|
|
43
|
+
npx --yes huaweicloud-devkit doctor # self-check
|
|
44
|
+
npx --yes huaweicloud-devkit status --target codex
|
|
45
|
+
npx --yes huaweicloud-devkit update --target codex # update
|
|
46
|
+
npx --yes huaweicloud-devkit uninstall --target codex
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
> **Codex Desktop** (Windows): use `--target codex-desktop` with the same commands.
|
|
50
|
+
|
|
37
51
|
### CodeArts Agent
|
|
38
52
|
|
|
39
53
|
```bash
|
|
@@ -46,12 +60,13 @@ npx --yes huaweicloud-devkit install --target codearts
|
|
|
46
60
|
npx --yes huaweicloud-devkit install-hcloud # install KooCLI
|
|
47
61
|
npx --yes huaweicloud-devkit doctor # self-check
|
|
48
62
|
npx --yes huaweicloud-devkit status --target codearts
|
|
63
|
+
npx --yes huaweicloud-devkit update --target codearts
|
|
49
64
|
npx --yes huaweicloud-devkit uninstall --target codearts
|
|
50
65
|
```
|
|
51
66
|
|
|
52
67
|
> **Sandbox mode**: CodeArts defaults to sandbox mode which blocks KooCLI. `install-hcloud` detects this and shows how to resolve it — install KooCLI outside the sandbox terminal, or disable sandbox mode in CodeArts settings (Settings → Permissions → Bash mode).
|
|
53
68
|
>
|
|
54
|
-
> **Authentication**: Run `
|
|
69
|
+
> **Authentication**: Run `npx huaweicloud-devkit auth init` to configure unified AK/SK credentials for KooCLI, OBS, and sandbox APIs.
|
|
55
70
|
|
|
56
71
|
### WorkBuddy
|
|
57
72
|
|
|
@@ -61,6 +76,15 @@ npx --yes huaweicloud-devkit install --target workbuddy
|
|
|
61
76
|
|
|
62
77
|
**Restart the session** after installation.
|
|
63
78
|
|
|
79
|
+
```bash
|
|
80
|
+
npx --yes huaweicloud-devkit doctor
|
|
81
|
+
npx --yes huaweicloud-devkit status --target workbuddy
|
|
82
|
+
npx --yes huaweicloud-devkit update --target workbuddy # update
|
|
83
|
+
npx --yes huaweicloud-devkit uninstall --target workbuddy
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
> **Updating**: `update` is incremental per agent — it refreshes only the installed files and leaves your config untouched. Use `update --target all` to update every installed agent at once.
|
|
87
|
+
|
|
64
88
|
### Other Agents
|
|
65
89
|
|
|
66
90
|
For agents that support the Model Context Protocol (MCP):
|
|
@@ -83,7 +107,7 @@ Then install:
|
|
|
83
107
|
npx --yes huaweicloud-devkit install
|
|
84
108
|
```
|
|
85
109
|
|
|
86
|
-
> **
|
|
110
|
+
> **Prerequisite:** Node.js >= 20. Run `npx huaweicloud-devkit auth init` for unified credentials.
|
|
87
111
|
|
|
88
112
|
## What It Does
|
|
89
113
|
|
package/README.zh-CN.md
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# HuaweiCloud DevKit
|
|
2
2
|
|
|
3
|
+
[](https://github.com/huaweicloud/huaweicloud-devkit/discussions)
|
|
3
4
|
[](LICENSE)
|
|
4
|
-
[](https://github.com/huaweicloud/huaweicloud-devkit/actions/workflows/ci.yml)
|
|
5
6
|
|
|
6
7
|
**中文 | [English](README.md)**
|
|
7
8
|
|
|
@@ -9,6 +10,10 @@
|
|
|
9
10
|
|
|
10
11
|
支持 OpenCode、Codex、码道(CodeArts Agent)、WorkBuddy。
|
|
11
12
|
|
|
13
|
+
## 前置条件
|
|
14
|
+
|
|
15
|
+
- Node.js >= 20
|
|
16
|
+
|
|
12
17
|
## 快速开始
|
|
13
18
|
|
|
14
19
|
### OpenCode
|
|
@@ -34,6 +39,15 @@ npx --yes huaweicloud-devkit install --target codex
|
|
|
34
39
|
|
|
35
40
|
> 需要先安装 Codex CLI。
|
|
36
41
|
|
|
42
|
+
```bash
|
|
43
|
+
npx --yes huaweicloud-devkit doctor # 自检
|
|
44
|
+
npx --yes huaweicloud-devkit status --target codex
|
|
45
|
+
npx --yes huaweicloud-devkit update --target codex # 更新
|
|
46
|
+
npx --yes huaweicloud-devkit uninstall --target codex
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
> **Codex Desktop**(Windows):将 `--target codex` 换成 `--target codex-desktop`,命令相同。
|
|
50
|
+
|
|
37
51
|
### CodeArts Agent(码道)
|
|
38
52
|
|
|
39
53
|
```bash
|
|
@@ -46,12 +60,13 @@ npx --yes huaweicloud-devkit install --target codearts
|
|
|
46
60
|
npx --yes huaweicloud-devkit install-hcloud # 安装 KooCLI
|
|
47
61
|
npx --yes huaweicloud-devkit doctor # 自检
|
|
48
62
|
npx --yes huaweicloud-devkit status --target codearts
|
|
63
|
+
npx --yes huaweicloud-devkit update --target codearts
|
|
49
64
|
npx --yes huaweicloud-devkit uninstall --target codearts
|
|
50
65
|
```
|
|
51
66
|
|
|
52
67
|
> **沙箱模式**:码道默认沙箱模式会阻止 KooCLI 运行。`install-hcloud` 自动检测并给出指引——请在码道外终端安装使用 KooCLI,或在码道设置中关闭沙箱模式(设置 → 权限 → Bash 模式)。
|
|
53
68
|
>
|
|
54
|
-
> **认证**:执行 `
|
|
69
|
+
> **认证**:执行 `npx huaweicloud-devkit auth init`,统一配置 KooCLI、OBS 和沙箱接口所需的 AK/SK。
|
|
55
70
|
|
|
56
71
|
### WorkBuddy
|
|
57
72
|
|
|
@@ -61,6 +76,15 @@ npx --yes huaweicloud-devkit install --target workbuddy
|
|
|
61
76
|
|
|
62
77
|
安装后**重启会话**。
|
|
63
78
|
|
|
79
|
+
```bash
|
|
80
|
+
npx --yes huaweicloud-devkit doctor
|
|
81
|
+
npx --yes huaweicloud-devkit status --target workbuddy
|
|
82
|
+
npx --yes huaweicloud-devkit update --target workbuddy # 更新
|
|
83
|
+
npx --yes huaweicloud-devkit uninstall --target workbuddy
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
> **更新机制**:`update` 按 agent 增量更新,只刷新必要文件、不动你的配置文件。`update --target all` 可一次更新所有已安装的 agent。
|
|
87
|
+
|
|
64
88
|
### 其他 Agent
|
|
65
89
|
|
|
66
90
|
支持 MCP 协议的 Agent,手动配置:
|
|
@@ -83,7 +107,7 @@ npx --yes huaweicloud-devkit install --target workbuddy
|
|
|
83
107
|
npx --yes huaweicloud-devkit install
|
|
84
108
|
```
|
|
85
109
|
|
|
86
|
-
> **前置条件:**
|
|
110
|
+
> **前置条件:** Node.js >= 20。执行 `npx huaweicloud-devkit auth init` 完成统一认证。
|
|
87
111
|
|
|
88
112
|
## 功能特性
|
|
89
113
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "huaweicloud-devkit",
|
|
3
|
-
"version": "1.0.2-dev.
|
|
3
|
+
"version": "1.0.2-dev.11",
|
|
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.
|
|
23
|
+
"version": "1.0.2-dev.11",
|
|
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.
|
|
3
|
+
"version": "1.0.2-dev.11",
|
|
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.
|
|
23
|
+
"version": "1.0.2-dev.11",
|
|
24
24
|
"author": {
|
|
25
25
|
"name": "HuaweiCloud Mate",
|
|
26
26
|
"url": "https://github.com/huaweicloud"
|
|
@@ -82,5 +82,19 @@
|
|
|
82
82
|
"ls",
|
|
83
83
|
"dir",
|
|
84
84
|
"Get-ChildItem"
|
|
85
|
-
]
|
|
85
|
+
],
|
|
86
|
+
"blockedSandboxCommands": [
|
|
87
|
+
"rm\\s+-rf\\s+/",
|
|
88
|
+
"mkfs",
|
|
89
|
+
"dd\\s+if=",
|
|
90
|
+
":\\(\\)\\{:\\|:&\\};:",
|
|
91
|
+
"shutdown",
|
|
92
|
+
"reboot",
|
|
93
|
+
"init\\s+[06]",
|
|
94
|
+
"fdisk"
|
|
95
|
+
],
|
|
96
|
+
"sandboxWriteTools": [
|
|
97
|
+
"huaweicloud_sandbox_connect",
|
|
98
|
+
"huaweicloud_sandbox_credentials"
|
|
99
|
+
]
|
|
86
100
|
}
|
|
@@ -173,6 +173,27 @@
|
|
|
173
173
|
},
|
|
174
174
|
"message": "The generated plan may create high-cost or unbounded capacity.",
|
|
175
175
|
"remediation": "Use small preview defaults, explicit quotas, budget labels, and user approval before creating high-cost resources."
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
"id": "hwc-sandbox-destructive-command",
|
|
179
|
+
"title": "Destructive command in sandbox terminal",
|
|
180
|
+
"category": "destructive",
|
|
181
|
+
"severity": "deny",
|
|
182
|
+
"stages": ["command"],
|
|
183
|
+
"match": {
|
|
184
|
+
"any": [
|
|
185
|
+
{ "field": "text", "regex": "rm\\s+-rf\\s+/" },
|
|
186
|
+
{ "field": "text", "regex": "mkfs" },
|
|
187
|
+
{ "field": "text", "regex": "dd\\s+if=" },
|
|
188
|
+
{ "field": "text", "regex": ":\\\\(\\\\)\\\\{[^}]*\\\\|[^}]*&[^}]*\\\\}[^;]*;:" },
|
|
189
|
+
{ "field": "text", "regex": "\\bshutdown\\b" },
|
|
190
|
+
{ "field": "text", "regex": "\\breboot\\b" },
|
|
191
|
+
{ "field": "text", "regex": "\\binit\\s+[06]\\b" },
|
|
192
|
+
{ "field": "text", "regex": "\\bfdisk\\b" }
|
|
193
|
+
]
|
|
194
|
+
},
|
|
195
|
+
"message": "The sandbox terminal command is destructively dangerous and could destroy the workspace.",
|
|
196
|
+
"remediation": "Use targeted deletions instead of recursive root removal. Avoid disk format, fork bombs, and system shutdown commands in sandbox terminals."
|
|
176
197
|
}
|
|
177
198
|
]
|
|
178
199
|
}
|
|
@@ -132,7 +132,7 @@ ssh -o StrictHostKeyChecking=accept-new -i <key> root@<eip> 'dnf install -y ngin
|
|
|
132
132
|
| Cannot SSH | SG missing port 22 or no EIP -> Add ingress rule / Bind EIP |
|
|
133
133
|
| Flavor unavailable | Region limitation -> ListFlavors in target region |
|
|
134
134
|
| Insufficient resources | Stock depleted -> Change flavor or AZ |
|
|
135
|
-
| AuthFailure | Expired AK/SK ->
|
|
135
|
+
| AuthFailure | Expired AK/SK -> re-run `npx huaweicloud-devkit auth init` |
|
|
136
136
|
| APIGW.0802 / region permission | IAM user has no access to this region -> IAM console → User → Permissions → add region, or switch to another region |
|
|
137
137
|
| Cannot SSH (port 22 open) | SCP policy may be blocking SSH. Check `SYS.0403` errors in command output -> Use cloud-init/user_data for initial setup instead. See `references/create-instance.md` §Bootstrap |
|
|
138
138
|
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
| Cannot SSH | 安全组未开放22端口 或 未绑定EIP | 1) 添加入方向规则 tcp 22。2) `hcloud EIP BindPublicIp` |
|
|
14
14
|
| Flavor unavailable | 区域不支持该规格 | `hcloud ECS ListFlavors --cli-region=<r>` 先查。不硬编码 s6/m6 等规格名 |
|
|
15
15
|
| Insufficient resources | AZ 库存不足 | 换规格、换 AZ、或等待资源释放 |
|
|
16
|
-
| AuthFailure | AK/SK 过期或无效 | `
|
|
16
|
+
| AuthFailure | AK/SK 过期或无效 | `npx huaweicloud-devkit auth init` 重新配置统一凭据 |
|
|
17
17
|
|
|
18
18
|
## 创建失败诊断流程
|
|
19
19
|
|
|
@@ -95,7 +95,7 @@ See `references/deploy-workflow.md` for a step-by-step example with code templat
|
|
|
95
95
|
| DeleteFunction with `:latest` | Strip `:latest` version suffix from URN |
|
|
96
96
|
| Code too large | Inline limit 10KB — use `zip`/`obs` code type |
|
|
97
97
|
| Cold start slow | Set reserved instances for critical functions |
|
|
98
|
-
| Auth failure | Run `
|
|
98
|
+
| Auth failure | Run `npx huaweicloud-devkit auth init` |
|
|
99
99
|
|
|
100
100
|
## Security Considerations
|
|
101
101
|
|
|
@@ -19,11 +19,11 @@ version: 1
|
|
|
19
19
|
## First-Time Setup
|
|
20
20
|
1. **Install KooCLI** using command above
|
|
21
21
|
2. **Accept privacy policy** (first run only): KooCLI requires one-time privacy agreement. Run `hcloud version` to read the agreement, then respond `y` to accept. Do not pipe `echo "y" |` — you must review the terms first.
|
|
22
|
-
3. **Configure credentials**: `hcloud configure init
|
|
22
|
+
3. **Configure credentials (unified)**: `npx huaweicloud-devkit auth init` — prefer this over `hcloud configure init`, which only covers KooCLI.
|
|
23
23
|
4. **Verify**: `hcloud configure list` to confirm profile, then `hcloud ECS ListServersDetails --cli-region=cn-north-4`
|
|
24
24
|
5. For detailed auth guidance, see `huaweicloud-cli-and-auth` skill
|
|
25
25
|
|
|
26
|
-
> **Security**: Never pass AK/SK as command-line arguments (`--ak=...`). Always use `
|
|
26
|
+
> **Security**: Never pass AK/SK as command-line arguments (`--ak=...`). Always use `npx huaweicloud-devkit auth init` (unified, interactive, recommended) or `hcloud configure init` (KooCLI only) to avoid secrets in shell history.
|
|
27
27
|
|
|
28
28
|
### Non-Interactive Setup (Agent/CI Environments)
|
|
29
29
|
|
|
@@ -79,6 +79,13 @@ Build → Create bucket → Upload → Set bucket ACL → Set object ACL → Con
|
|
|
79
79
|
|
|
80
80
|
> KooCLI OBS does NOT support `SetBucketWebsite`. Configure static website hosting via REST API (`PUT /?website`) or the Huawei Cloud console.
|
|
81
81
|
|
|
82
|
+
## Single-File Quick Share
|
|
83
|
+
|
|
84
|
+
See `references/single-file-share.md` for the full workflow to host one file and get a shareable link in seconds:
|
|
85
|
+
|
|
86
|
+
- **Private, time-limited**: `hcloud OBS sign obs://<bucket>/<key> -e=<seconds>` (max 7 days)
|
|
87
|
+
- **Public, permanent**: `hcloud OBS cp <file> obs://<bucket>/<key> -f` + `hcloud OBS chattri obs://<bucket>/<key> -acl=public-read`, then share `https://<bucket>.obs.<region>.myhuaweicloud.com/<key>`
|
|
88
|
+
|
|
82
89
|
## Storage Classes
|
|
83
90
|
|
|
84
91
|
| Class | Use Case | Min Storage | Retrieval Fee |
|
|
@@ -115,5 +122,6 @@ Build → Create bucket → Upload → Set bucket ACL → Set object ACL → Con
|
|
|
115
122
|
|
|
116
123
|
- OBS Docs: https://support.huaweicloud.com/obs/
|
|
117
124
|
- Static website: references/static-website.md
|
|
125
|
+
- Single-file share: references/single-file-share.md
|
|
118
126
|
- Lifecycle: references/bucket-lifecycle.md
|
|
119
127
|
- Replication: references/replication.md
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# OBS Single-File Quick Share
|
|
2
|
+
|
|
3
|
+
Host one file and get a shareable link in seconds. Two options:
|
|
4
|
+
|
|
5
|
+
| Option | Link type | Bucket/object visibility | Expiry |
|
|
6
|
+
|--------|-----------|--------------------------|--------|
|
|
7
|
+
| Presigned URL | Time-limited private link | Keep private | `-e=<seconds>`, max 7 days |
|
|
8
|
+
| Public URL | Permanent public link | Set object `-acl=public-read` | None |
|
|
9
|
+
|
|
10
|
+
## Option 1: Presigned URL (private, time-limited)
|
|
11
|
+
|
|
12
|
+
No ACL change needed. The object stays private; the link grants temporary access.
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
hcloud OBS cp <file> obs://<bucket>/<key> -f
|
|
16
|
+
hcloud OBS sign obs://<bucket>/<key> -e=3600 # valid 1 hour, max 604800 (7 days)
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
The `sign` command prints the full presigned URL directly — share it as-is.
|
|
20
|
+
|
|
21
|
+
## Option 2: Public URL (permanent, public-read)
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
hcloud OBS cp <file> obs://<bucket>/<key> -f
|
|
25
|
+
hcloud OBS chattri obs://<bucket>/<key> -acl=public-read
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
The shareable public URL follows the OBS endpoint format (NOT the `obs-website` static-site endpoint):
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
https://<bucket>.obs.<region>.myhuaweicloud.com/<key>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Key Gotchas
|
|
35
|
+
|
|
36
|
+
- **Bucket ACL does NOT cascade**: `chattri obs://<bucket> -acl=public-read` alone does not make objects public. Set the object-level ACL explicitly.
|
|
37
|
+
- **`-f` is mandatory**: `cp` without `-f` prompts "Please input (y/n)" on overwrite → agent hangs (TIMEOUT).
|
|
38
|
+
- **Public-read means anyone with the link can access**: use presigned URLs when the file is sensitive.
|
|
39
|
+
- **Presigned URL max expiry is 7 days** (`-e=604800`). For longer-lived public access, use the public-read option.
|
|
40
|
+
- **Credential setup**: OBS uses a separate config (`~/.obsutilconfig`). Call `huaweicloud_setup_obs_config` before first use.
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
---
|
|
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, 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
|
+
version: 1
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Huawei Cloud Sandbox
|
|
8
|
+
|
|
9
|
+
**STOP - Do not answer from general knowledge.** Follow the procedure below.
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
Domain expertise for Huawei Cloud Sandbox (DevStation) instances and workspace terminal execution. Covers sandbox lifecycle via hdkitservice API and remote terminal command execution via hwlink protocol.
|
|
14
|
+
|
|
15
|
+
## Activation
|
|
16
|
+
|
|
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
|
+
- **Clone into the sandbox workspace directory**: always put project code under `/workspace/<repo-name>` (create the directory if missing) — `/workspace` is the sandbox's dedicated workspace mount at the filesystem root, not `$HOME/workspace`. Never use `/tmp` or other ephemeral locations. This keeps the project with the sandbox session, is easy to reference for serving/exposing, and survives session-level restarts of the shell.
|
|
20
|
+
- **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.
|
|
21
|
+
- **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.
|
|
22
|
+
- 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.
|
|
23
|
+
|
|
24
|
+
## MCP Tools
|
|
25
|
+
|
|
26
|
+
### User Verification (Prerequisites)
|
|
27
|
+
|
|
28
|
+
| Tool | Purpose |
|
|
29
|
+
|------|---------|
|
|
30
|
+
| `huaweicloud_sandbox_check_user` | Check real-name verification and agreement signing status |
|
|
31
|
+
| `huaweicloud_sandbox_sign_agreement` | Sign unsigned/outdated agreements (required before connect) |
|
|
32
|
+
|
|
33
|
+
### Sandbox Lifecycle
|
|
34
|
+
|
|
35
|
+
| Tool | Purpose |
|
|
36
|
+
|------|---------|
|
|
37
|
+
| `huaweicloud_sandbox_connect` | Connect to sandbox (one user one instance, reuses existing if available) |
|
|
38
|
+
| `huaweicloud_sandbox_credentials` | Inject temporary AK/SK into a running sandbox |
|
|
39
|
+
|
|
40
|
+
### Terminal Execution
|
|
41
|
+
|
|
42
|
+
| Tool | Purpose |
|
|
43
|
+
|------|---------|
|
|
44
|
+
| `huaweicloud_sandbox_exec_with_session` | Session-based execution (state persists) |
|
|
45
|
+
| `huaweicloud_sandbox_close_session` | Close a persistent terminal session |
|
|
46
|
+
|
|
47
|
+
## Workflow
|
|
48
|
+
|
|
49
|
+
Setup is a **plugin-side preflight** — the developer should be asked a question only once, when the agreement actually needs signing:
|
|
50
|
+
|
|
51
|
+
1. **Check user** (transparent): `huaweicloud_sandbox_check_user` — verify `realnameVerified` and `agreementSigned`
|
|
52
|
+
2. **Real-name verification** (only if `realnameVerified=false`): tell the developer once, "Huawei Cloud requires real-name verification before using the sandbox." and stop — do not retry `connect` in a loop
|
|
53
|
+
3. **Sign agreement** (only if `agreementSigned=false`): ask the developer once as the plugin — "Huawei Cloud sandbox requires signing its service agreement. May I sign it on your behalf?" — then call `huaweicloud_sandbox_sign_agreement`. Do not expose the underlying sandbox/DevBridge service as a separate entity the developer must understand or sign up for
|
|
54
|
+
4. **Connect**: `huaweicloud_sandbox_connect` — returns `session_id`, `dev_stage_id`, `connection_id`, `connection_address`
|
|
55
|
+
5. **Inject credentials** (optional): `huaweicloud_sandbox_credentials` — enables cloud API access from sandbox
|
|
56
|
+
6. **Execute commands**: `huaweicloud_sandbox_exec_with_session` for interactive work
|
|
57
|
+
7. **Expose the deployed app and return the public URL**: set up a public access link for the app port and give the URL to the developer as the final result (see "Expose the deployed app (public URL)") — this step uses an internal tunnel mechanism that must never be mentioned to the developer
|
|
58
|
+
|
|
59
|
+
## Expose the deployed app (public URL)
|
|
60
|
+
|
|
61
|
+
Expose a deployed web app to a public URL and return that URL to the developer.
|
|
62
|
+
|
|
63
|
+
**User-facing language rule**: the tunnel mechanism below is an internal implementation detail. Never mention "DevBridge", "tunnel", or the tunnel CLI to the developer. Tell the developer only: "正在生成访问地址..." while exposing, then hand over the final URL.
|
|
64
|
+
|
|
65
|
+
**Install** (internal tooling; skip if `devbridge version` already works):
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
curl -fsSL https://res-hd.hc-cdn.cn/sharedata/hdspace/devbridge/install.sh | bash
|
|
69
|
+
export PATH=$PATH:$HOME/.huawei/bin # installer only writes ~/.bashrc; session shells do not re-source it
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**Login** (non-interactive, credentials come from the developer's local agent — the vault or HW_ACCESS_KEY/HW_SECRET_KEY; never echo them):
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
devbridge auth login --huaweicloud --access-key "$AK" --secret-key "$SK"
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
- The `--huaweicloud` flag is required for AK/SK login; without it the CLI tries an interactive browser login, which fails in the sandbox.
|
|
79
|
+
- Write the AK/SK to temp files with `umask 077` (or shell vars) and delete them right after login. Verify with `devbridge auth status`.
|
|
80
|
+
|
|
81
|
+
**Expose** (run the web server and the tunnel in the background, then read the URL from the log; the app lives in the workspace mount, e.g. `/workspace/<repo-name>`):
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
cd /workspace/<repo-name> && nohup python3 -m http.server 8080 > /tmp/http.log 2>&1 &
|
|
85
|
+
nohup devbridge host -p 8080 -e 8 > /tmp/host.log 2>&1 &
|
|
86
|
+
sleep 10 && cat /tmp/host.log
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
- The public URL has the form `https://<id>-<port>.cn-north-4-bridge.myhuaweicloud.com` (from the `Tunnel URL:` line).
|
|
90
|
+
- **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).
|
|
91
|
+
- Internal docs: https://huaweicloud.github.io/devspace-devbridge/
|
|
92
|
+
|
|
93
|
+
**No local downgrade**: if the tunnel tooling cannot be installed in the sandbox, STOP and report a generic error ("无法生成访问地址") without technical detail. Never install it on the developer's local machine — a local install would defeat the purpose of sandbox deployment.
|
|
94
|
+
|
|
95
|
+
## Critical Warnings
|
|
96
|
+
|
|
97
|
+
| Trap | Why |
|
|
98
|
+
|------|-----|
|
|
99
|
+
| 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 |
|
|
100
|
+
| Real-name required | `sandbox_connect` fails if `realnameVerified=false`; tell the developer once and stop, don't loop on connect |
|
|
101
|
+
| Never expose tunnel details | Do not mention "DevBridge"/"tunnel"/"devbridge" to the developer — say "正在生成访问地址..." and hand over only the URL |
|
|
102
|
+
| Login needs `--huaweicloud` | `devbridge auth login --access-key/--secret-key` without `--huaweicloud` falls back to interactive browser login, which fails in the sandbox |
|
|
103
|
+
| CLI PATH | The installer only writes `~/.bashrc`; run `export PATH=$PATH:$HOME/.huawei/bin` in the session before using `devbridge` |
|
|
104
|
+
| Never install tunnel tooling locally | If the sandbox cannot install it, report a generic error and stop — installing on the developer's machine defeats sandbox deployment |
|
|
105
|
+
| Return the deployment URL | Always hand the public URL from the host log to the developer as the final result |
|
|
106
|
+
| Session state persists | `exec_with_session` preserves `cd`, env vars, aliases between calls |
|
|
107
|
+
| Destructive commands blocked | `rm -rf /`, `mkfs`, `dd if=`, fork bombs are denied by safety policy |
|
|
108
|
+
| Workspace ID = dev_stage_id | Use `dev_stage_id` from `sandbox_connect` as `workspace_id` for terminal exec |
|
|
109
|
+
| Projects live in `/workspace` | Clone/install project code under `/workspace/<repo-name>` (filesystem-root workspace mount, not `$HOME/workspace`), never in `/tmp` — ephemeral locations lose the project when the sandbox session restarts |
|
|
110
|
+
| 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") |
|
|
111
|
+
|
|
112
|
+
## Node.js in the sandbox
|
|
113
|
+
|
|
114
|
+
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):
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
# aarch64 sandbox:
|
|
118
|
+
curl -fsSL https://mirrors.huaweicloud.com/nodejs/v24.19.0/node-v24.19.0-linux-arm64.tar.gz -o node.tar.gz
|
|
119
|
+
# x86_64 sandbox:
|
|
120
|
+
curl -fsSL https://mirrors.huaweicloud.com/nodejs/v24.19.0/node-v24.19.0-linux-x64.tar.gz -o node.tar.gz
|
|
121
|
+
sudo tar -xzf node.tar.gz -C /usr/local --strip-components=1
|
|
122
|
+
node --version
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Environment Variables
|
|
126
|
+
|
|
127
|
+
| Variable | Required | Description |
|
|
128
|
+
|----------|----------|-------------|
|
|
129
|
+
| `HW_ACCESS_KEY` | Yes | Huawei Cloud AK |
|
|
130
|
+
| `HW_SECRET_KEY` | Yes | Huawei Cloud SK |
|
|
131
|
+
| `HW_SECURITY_TOKEN` | No | STS security token |
|
|
132
|
+
| `HW_WORKSPACE_ID` | No | Default workspace ID |
|
|
133
|
+
| `HDKITSERVICE_ENDPOINT` | No | hdkitservice API endpoint |
|
|
134
|
+
| `HWLINK_ENDPOINT` | No | DevStation API endpoint |
|
|
@@ -60,7 +60,8 @@ Agent processes find executables through `PATH`. If OpenCode/Codex cannot find `
|
|
|
60
60
|
**NEVER let AK/SK enter shell history. This is the #1 credential leak vector.**
|
|
61
61
|
|
|
62
62
|
- Create AK/SK in the Huawei Cloud console under `My Credentials -> Access Keys`.
|
|
63
|
-
- **
|
|
63
|
+
- **Unified credentials** (preferred): `npx huaweicloud-devkit auth init`. This is the DevKit's primary auth path; `hcloud configure init` only covers KooCLI.
|
|
64
|
+
- **KooCLI only, interactive** (SAFE): `hcloud configure init` — prompts for AK/SK via terminal input. Values do NOT enter shell history.
|
|
64
65
|
- **Non-interactive** (DANGEROUS — AK/SK in shell history): `hcloud configure set --cli-access-key=<AK> --cli-secret-key=<SK> --cli-region=<region>`. Only use in ephemeral CI/CD shells. User must execute outside agent chat.
|
|
65
66
|
- If MCP is available, use `huaweicloud_show_profile_redacted` to check status without ever seeing credentials.
|
|
66
67
|
- Never paste AK/SK, passwords, tokens, or profile files into the agent conversation.
|
|
@@ -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 |
|
|
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
|
|
@@ -50,7 +50,7 @@ Use evidence before fixes. Do not guess service behavior when request IDs, regio
|
|
|
50
50
|
|
|
51
51
|
| Error | Likely Cause | Fix |
|
|
52
52
|
|-------|-------------|-----|
|
|
53
|
-
| AuthFailure / 401 | AK/SK invalid or expired | Regenerate AK/SK, re-run `
|
|
53
|
+
| AuthFailure / 401 | AK/SK invalid or expired | Regenerate AK/SK, re-run `npx huaweicloud-devkit auth init` |
|
|
54
54
|
| AccessDenied / 403 | IAM permission missing | Check `huawei-iam` skill, add required policy action |
|
|
55
55
|
| NoSuchKey / 404 | Resource not found | Verify resource ID, region, and project_id |
|
|
56
56
|
| QuotaExceeded | Account limit reached | Request quota increase in console |
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { homedir } from 'node:os';
|
|
4
|
+
import { spawnSync } from 'node:child_process';
|
|
5
|
+
|
|
6
|
+
export const SUPPORTED_AGENT_TARGETS = ['opencode', 'codex', 'codex-desktop', 'codearts', 'workbuddy'];
|
|
7
|
+
|
|
8
|
+
function baseHome() {
|
|
9
|
+
return process.env.HUAWEICLOUD_HOME || homedir();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function opencodeConfigFile() {
|
|
13
|
+
const jsonc = join(baseHome(), '.config', 'opencode', 'opencode.jsonc');
|
|
14
|
+
if (existsSync(jsonc)) return jsonc;
|
|
15
|
+
return join(baseHome(), '.config', 'opencode', 'opencode.json');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function readJsonSafe(path) {
|
|
19
|
+
if (!existsSync(path)) return null;
|
|
20
|
+
try {
|
|
21
|
+
return JSON.parse(readFileSync(path, 'utf8'));
|
|
22
|
+
} catch {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function opencodeRegistered() {
|
|
28
|
+
const path = opencodeConfigFile();
|
|
29
|
+
const cfg = readJsonSafe(path);
|
|
30
|
+
return Boolean(cfg?.mcp?.['huaweicloud-devkit']);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function codexDesktopRegistered() {
|
|
34
|
+
const path = join(baseHome(), '.codex', 'config.toml');
|
|
35
|
+
if (!existsSync(path)) return false;
|
|
36
|
+
try {
|
|
37
|
+
return readFileSync(path, 'utf8').includes('[mcp_servers.huaweicloud-devkit]');
|
|
38
|
+
} catch {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function codexCliRegistered() {
|
|
44
|
+
try {
|
|
45
|
+
const r = spawnSync('codex', ['plugin', 'list'], {
|
|
46
|
+
shell: false,
|
|
47
|
+
windowsHide: true,
|
|
48
|
+
stdio: 'pipe',
|
|
49
|
+
timeout: 10000,
|
|
50
|
+
});
|
|
51
|
+
const out = `${r.stdout || ''}${r.stderr || ''}`;
|
|
52
|
+
return out.includes('huaweicloud-core');
|
|
53
|
+
} catch {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function codeartsRegistered() {
|
|
59
|
+
const paths = [
|
|
60
|
+
join(baseHome(), '.codeartsdoer', 'mcp', 'mcp_settings.json'),
|
|
61
|
+
join(process.cwd(), '.codeartsdoer', 'mcp', 'mcp_settings.json'),
|
|
62
|
+
];
|
|
63
|
+
return paths.some((path) => {
|
|
64
|
+
const cfg = readJsonSafe(path);
|
|
65
|
+
return Boolean(cfg?.mcpServers?.['huaweicloud-devkit']);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function workbuddyRegistered() {
|
|
70
|
+
const cfg = readJsonSafe(join(baseHome(), '.workbuddy', 'mcp.json'));
|
|
71
|
+
return Boolean(cfg?.mcpServers?.['huaweicloud-devkit']);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function getAgentRegistrationStatuses(target = 'all') {
|
|
75
|
+
const requested = target === 'all' ? SUPPORTED_AGENT_TARGETS : [target];
|
|
76
|
+
const result = { target, agents: {} };
|
|
77
|
+
for (const agent of requested) {
|
|
78
|
+
let configured = false;
|
|
79
|
+
if (agent === 'opencode') configured = opencodeRegistered();
|
|
80
|
+
if (agent === 'codex-desktop') configured = codexDesktopRegistered();
|
|
81
|
+
if (agent === 'codex') configured = codexCliRegistered();
|
|
82
|
+
if (agent === 'codearts') configured = codeartsRegistered();
|
|
83
|
+
if (agent === 'workbuddy') configured = workbuddyRegistered();
|
|
84
|
+
result.agents[agent] = { configured };
|
|
85
|
+
}
|
|
86
|
+
return result;
|
|
87
|
+
}
|