huaweicloud-devkit 2.0.1-next.2 → 2.0.1-next.4

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.
Files changed (75) hide show
  1. package/README.md +26 -3
  2. package/README.zh-CN.md +24 -1
  3. package/package.json +1 -1
  4. package/plugins/huaweicloud-core/.claude-plugin/plugin.json +1 -1
  5. package/plugins/huaweicloud-core/.codex-plugin/plugin.json +1 -1
  6. package/plugins/huaweicloud-core/.cursor-plugin/plugin.json +1 -1
  7. package/plugins/huaweicloud-core/.hermes-plugin/plugin.json +1 -1
  8. package/plugins/huaweicloud-core/.mcp.json +3 -0
  9. package/plugins/huaweicloud-core/.workbuddy-plugin/plugin.json +1 -1
  10. package/plugins/huaweicloud-core/dist/approval-roster.js +2 -0
  11. package/plugins/huaweicloud-core/dist/lib/hdkit/hdkit-gate.js +7 -0
  12. package/plugins/huaweicloud-core/dist/lib/hdkit/hdkitservice-api.js +30 -1
  13. package/plugins/huaweicloud-core/dist/lib/hdkit/sandbox-pool.js +21 -0
  14. package/plugins/huaweicloud-core/dist/mcp-server.js +4227 -3049
  15. package/plugins/huaweicloud-core/dist/mcp-server.js.map +4 -4
  16. package/plugins/huaweicloud-core/dist/packs/registry.js +1 -0
  17. package/plugins/huaweicloud-core/dist/packs/sandbox/approval.js +13 -2
  18. package/plugins/huaweicloud-core/dist/packs/sandbox/handlers-account.js +198 -10
  19. package/plugins/huaweicloud-core/dist/packs/sandbox/handlers-credentials.js +11 -0
  20. package/plugins/huaweicloud-core/dist/packs/sandbox/handlers-session.js +22 -0
  21. package/plugins/huaweicloud-core/dist/packs/sandbox/handlers-tunnel.js +46 -0
  22. package/plugins/huaweicloud-core/dist/packs/sandbox/handlers-upload.js +11 -0
  23. package/plugins/huaweicloud-core/dist/packs/sandbox/schemas.js +20 -0
  24. package/plugins/huaweicloud-core/dist/packs/sandbox/tools.js +26 -18
  25. package/plugins/huaweicloud-core/dist/sandbox/deploy-check.js +97 -0
  26. package/plugins/huaweicloud-core/dist/sandbox/deploy-nginx.js +30 -14
  27. package/plugins/huaweicloud-core/dist/sandbox/devbox/devbox-backend.js +37 -0
  28. package/plugins/huaweicloud-core/dist/sandbox/devbox/devbox-connections.js +84 -0
  29. package/plugins/huaweicloud-core/dist/sandbox/devbox/devbox-envd-client.js +229 -0
  30. package/plugins/huaweicloud-core/dist/sandbox/devbox/devbox-envd-protocol.js +151 -0
  31. package/plugins/huaweicloud-core/dist/sandbox/devbox/devbox-envd-transport.js +121 -0
  32. package/plugins/huaweicloud-core/dist/sandbox/devbox/devbox-service-api.js +80 -0
  33. package/plugins/huaweicloud-core/dist/sandbox/devbox/devbox-upload.js +106 -0
  34. package/plugins/huaweicloud-core/dist/sandbox/hwlink-connection.js +12 -0
  35. package/plugins/huaweicloud-core/dist/sandbox/upload-project.js +5 -2
  36. package/plugins/huaweicloud-core/dist/server-install.js +363 -0
  37. package/plugins/huaweicloud-core/dist/setup-cli.js +16 -0
  38. package/plugins/huaweicloud-core/dist/tool-definitions.js +4 -0
  39. package/plugins/huaweicloud-core/dist/tools.js +1 -0
  40. package/plugins/huaweicloud-core/openclaw.plugin.json +1 -1
  41. package/plugins/huaweicloud-core/safety/policy.json +2 -1
  42. package/plugins/huaweicloud-core/skills/huawei-sandbox/SKILL.md +67 -16
  43. package/plugins/huaweicloud-core/skills/huawei-sandbox/references/devbox-backend.md +78 -0
  44. package/plugins/huaweicloud-core/skills/huawei-sandbox/references/resource-pool.md +14 -0
  45. package/plugins/huaweicloud-core/skills/huaweicloud-safety/references/approvals.md +2 -1
  46. package/plugins/huaweicloud-core/src/approval-roster.ts +2 -0
  47. package/plugins/huaweicloud-core/src/lib/hdkit/hdkit-gate.ts +7 -0
  48. package/plugins/huaweicloud-core/src/lib/hdkit/hdkitservice-api.ts +30 -1
  49. package/plugins/huaweicloud-core/src/lib/hdkit/sandbox-pool.ts +22 -0
  50. package/plugins/huaweicloud-core/src/mcp-server-remote.ts +68 -5
  51. package/plugins/huaweicloud-core/src/mcp-server.ts +4 -1
  52. package/plugins/huaweicloud-core/src/packs/registry.ts +1 -0
  53. package/plugins/huaweicloud-core/src/packs/sandbox/approval.ts +15 -2
  54. package/plugins/huaweicloud-core/src/packs/sandbox/handlers-account.ts +206 -11
  55. package/plugins/huaweicloud-core/src/packs/sandbox/handlers-credentials.ts +12 -0
  56. package/plugins/huaweicloud-core/src/packs/sandbox/handlers-session.ts +23 -0
  57. package/plugins/huaweicloud-core/src/packs/sandbox/handlers-tunnel.ts +49 -0
  58. package/plugins/huaweicloud-core/src/packs/sandbox/handlers-upload.ts +11 -0
  59. package/plugins/huaweicloud-core/src/packs/sandbox/schemas.ts +23 -0
  60. package/plugins/huaweicloud-core/src/packs/sandbox/tools.ts +27 -17
  61. package/plugins/huaweicloud-core/src/sandbox/deploy-check.ts +105 -0
  62. package/plugins/huaweicloud-core/src/sandbox/deploy-nginx.ts +36 -18
  63. package/plugins/huaweicloud-core/src/sandbox/devbox/devbox-backend.ts +44 -0
  64. package/plugins/huaweicloud-core/src/sandbox/devbox/devbox-connections.ts +115 -0
  65. package/plugins/huaweicloud-core/src/sandbox/devbox/devbox-envd-client.ts +281 -0
  66. package/plugins/huaweicloud-core/src/sandbox/devbox/devbox-envd-protocol.ts +180 -0
  67. package/plugins/huaweicloud-core/src/sandbox/devbox/devbox-envd-transport.ts +142 -0
  68. package/plugins/huaweicloud-core/src/sandbox/devbox/devbox-service-api.ts +102 -0
  69. package/plugins/huaweicloud-core/src/sandbox/devbox/devbox-upload.ts +167 -0
  70. package/plugins/huaweicloud-core/src/sandbox/hwlink-connection.ts +12 -0
  71. package/plugins/huaweicloud-core/src/sandbox/upload-project.ts +5 -2
  72. package/plugins/huaweicloud-core/src/server-install.ts +442 -0
  73. package/plugins/huaweicloud-core/src/setup-cli.ts +16 -0
  74. package/plugins/huaweicloud-core/src/tool-definitions.ts +4 -0
  75. package/plugins/huaweicloud-core/src/tools.ts +3 -0
package/README.md CHANGED
@@ -285,7 +285,30 @@ It listens on `127.0.0.1:9528` by default. Then connect with a remote config (op
285
285
  }
286
286
  ```
287
287
 
288
- > Use `--port <port>` if 9528 is taken and update `url` accordingly; add `--host 0.0.0.0` for LAN access. The remote server has no built-in auth — do not expose it anonymously to the public internet.
288
+ > Use `--port <port>` if 9528 is taken and update `url` accordingly; add `--host 0.0.0.0` for LAN access. The remote server is unauthenticated unless you pass `--auth-password-file <file>` — do not expose it anonymously to the public internet.
289
+
290
+ ### Server Mode (systemd, Linux)
291
+
292
+ Runs the MCP server as a pair of hardened systemd services with a dedicated OS user and generated auth password — for unattended/ops environments.
293
+
294
+ ```bash
295
+ sudo npx --yes huaweicloud-devkit install-server # defaults: /opt/kunpeng, business 8088, tool 7088, user devkit
296
+ sudo npx --yes huaweicloud-devkit install-server --install-path /opt/kunpeng --port 8088 --tool-port 7088 --user devkit
297
+ sudo npx --yes huaweicloud-devkit uninstall-server # add --remove-user to delete the service user
298
+ ```
299
+
300
+ What it provisions:
301
+
302
+ - Dedicated system user (default `devkit`, nologin shell) that runs both services
303
+ - `huaweicloud-devkit.service` (business port, default 8088) and `huaweicloud-devkit-tool.service` (tool port, default 7088)
304
+ - Generated auth password at `<install-path>/devkit/server/.auth-password` (0600, owned by the service user); every RPC requires `Authorization: Bearer <password>` or `x-devkit-password: <password>` — `GET /health` stays open for probes
305
+ - Self-contained runtime under `<install-path>/devkit/app` (Node.js 22.19+ is auto-provisioned when missing)
306
+ - Idempotent: re-running refreshes services; add `--rotate-password` to regenerate the password
307
+ - Side effect: re-runs and password rotation restart both services (brief downtime window); the previous password stops working as soon as the restart completes
308
+
309
+ Firewall rules are never changed by the installer. When firewalld is detected the install output prints the exact `--add-port` commands to run yourself; other distros: open the two ports per your firewall tool.
310
+
311
+ Note: the remote transport has no session for interactive confirmations, so write operations fall back to token approval — on the server, confirm write commands with `npx huaweicloud-devkit approve <token>`.
289
312
 
290
313
  ### Install KooCLI
291
314
 
@@ -401,8 +424,8 @@ Debug logs are written to the plugin's `telemetry/telemetry-debug.log` file.
401
424
  - **Safety-first execution** — all write operations require explicit user approval; credentials and secrets are automatically redacted from output
402
425
  - **Pre-execution risk checks** — public exposure, credential leaks, and destructive operations are caught before they run
403
426
  - **Regional awareness** — auto-discovers available regions and checks service availability before creating resources
404
- - **Sandbox (DevStation)** — temporary cloud runtime for web app deployment with instant public URL preview
405
- - **Capability packs (56 MCP tools)** — the devkit ships ten packs (core 12 tools; huaweicloud-cli carries the 20 service skills plus the 7 KooCLI execution tools; sandbox, auth, obs, voucher, update, discovery, secrets, huaweicloud-open-mcp for the rest). The huaweicloud-open-mcp pack proxies Huawei Cloud's full OpenAPI catalog through the local huaweicloud-open-mcp gateway with one generic call tool (`huaweicloud_gateway_call`: search_apis → list_apis → get_api discovery, execute_api with gateway-engine-gated consent; install the gateway with pip or uv, or just have `uvx` on PATH — no persistent install needed). Discover packs with `huaweicloud_list_packs` → `huaweicloud_pack_info`, browse the effective skill catalog with `huaweicloud_list_skills` (every enabled pack's skills with name, description, version, and reference filenames in one call, plus `skillRoot` — the tree's absolute location; which skills are ENABLED is pack-gated and can change at runtime, so a `huawei-*` service skill absent from the catalog belongs to a trimmed pack — the six `huaweicloud-*` meta-skills never appear in it and are always available), read the skill files directly under `skillRoot` on a same-machine install (the stdio server instructions state the location at initialize, so no catalog call is needed just to start reading; the taught policy is action-first — attempt the direct read, the attempt itself is the reachability check), and fall back to `huaweicloud_retrieve_skill` only when the attempted read fails or is denied — the taught reaction is falling back (the loader needs no file access), never repeatedly requesting. (the gated, telemetry-bearing, portable fallback, whose stdio payload also carries `skillRoot`; the six core meta-skills are additionally installed as native skill copies on directory-loading agents for system-prompt visibility). Trim the surface with `DEVKIT_PACKS` (comma-separated pack ids, e.g. `DEVKIT_PACKS=core,sandbox`); unset means all packs, unknown ids fail fast at startup, and core (pack meta, safety and discovery surface) is always included — trimming huaweicloud-cli removes the CLI execution face and its approval tools together. In a live stdio agent session, `huaweicloud_packs_configure` enables or disables packs on the spot (session-scoped; the refreshed tool list is pushed to the agent, and restarting the session restores the operator posture; the stateless remote surface does not carry it). Manage the surface persistently after install with `npx huaweicloud-devkit packs status | enable <ids> | disable <ids> | all [--target <agent>]`: the command rewrites `DEVKIT_PACKS` inside every installed agent's MCP config (the install-time `--packs` flag never overwrites an existing value), and the change takes effect on the agent's next session restart.
427
+ - **Sandbox (DevStation legacy / DevBox platform pool)** — temporary cloud runtime for web app deployment with instant public URL preview; `HW_SANDBOX_BACKEND=devbox` selects the platform resource pool (per-IAM-user ephemeral sandbox, one-shot exec/files, app-port preview)
428
+ - **Capability packs (57 MCP tools)** — the devkit ships ten packs (core 12 tools; huaweicloud-cli carries the 20 service skills plus the 7 KooCLI execution tools; sandbox, auth, obs, voucher, update, discovery, secrets, huaweicloud-open-mcp for the rest). The huaweicloud-open-mcp pack proxies Huawei Cloud's full OpenAPI catalog through the local huaweicloud-open-mcp gateway with one generic call tool (`huaweicloud_gateway_call`: search_apis → list_apis → get_api discovery, execute_api with gateway-engine-gated consent; install the gateway with pip or uv, or just have `uvx` on PATH — no persistent install needed). Discover packs with `huaweicloud_list_packs` → `huaweicloud_pack_info`, browse the effective skill catalog with `huaweicloud_list_skills` (every enabled pack's skills with name, description, version, and reference filenames in one call, plus `skillRoot` — the tree's absolute location; which skills are ENABLED is pack-gated and can change at runtime, so a `huawei-*` service skill absent from the catalog belongs to a trimmed pack — the six `huaweicloud-*` meta-skills never appear in it and are always available), read the skill files directly under `skillRoot` on a same-machine install (the stdio server instructions state the location at initialize, so no catalog call is needed just to start reading; the taught policy is action-first — attempt the direct read, the attempt itself is the reachability check), and fall back to `huaweicloud_retrieve_skill` only when the attempted read fails or is denied — the taught reaction is falling back (the loader needs no file access), never repeatedly requesting. (the gated, telemetry-bearing, portable fallback, whose stdio payload also carries `skillRoot`; the six core meta-skills are additionally installed as native skill copies on directory-loading agents for system-prompt visibility). Trim the surface with `DEVKIT_PACKS` (comma-separated pack ids, e.g. `DEVKIT_PACKS=core,sandbox`); unset means all packs, unknown ids fail fast at startup, and core (pack meta, safety and discovery surface) is always included — trimming huaweicloud-cli removes the CLI execution face and its approval tools together. In a live stdio agent session, `huaweicloud_packs_configure` enables or disables packs on the spot (session-scoped; the refreshed tool list is pushed to the agent, and restarting the session restores the operator posture; the stateless remote surface does not carry it). Manage the surface persistently after install with `npx huaweicloud-devkit packs status | enable <ids> | disable <ids> | all [--target <agent>]`: the command rewrites `DEVKIT_PACKS` inside every installed agent's MCP config (the install-time `--packs` flag never overwrites an existing value), and the change takes effect on the agent's next session restart.
406
429
 
407
430
  Harness permission notes (skill-tree reads outside the workspace): the taught reaction above is universal — when a direct read fails or is denied, fall back to `huaweicloud_retrieve_skill`, never repeatedly request. The OpenCode installer writes a persistent permission seam (external_directory allow + edit deny over the tree globs, plus an edit-only deny over the plugin payload root so the edit tools cannot rewrite the deployed classifier the in-process gate imports); on other harnesses the operator can pre-allow the tree in the harness's own config if prompts bother them. Honest semantics for the seam: the allow covers every path-taking tool including bash (an allowed external directory inherits workspace defaults), so shell-mediated writes to the tree stop asking too — the edit deny governs only the edit tools; the tree is regenerated on every install/update, and the devkit's PreToolUse hook still denies hcloud writes. On opencode at or above 1.19.0 the installer additionally writes the ASK approval posture as a pair — one exact `allow` entry per roster tool on the `huaweicloud-devkit_<tool>` action (a top-level `permissions` array entry on 2.0+, a `permission`-object key on 1.19–1.x; the two generations name the rule identically) plus `DEVKIT_APPROVAL_MODE=ask` in the mcp entry's environment. Ask mode is the devkit-wide default (an env-less install runs it too); the explicit env half pins the posture and anchors doctor's drift check, and the client `allow` rule only yields the client's own redundant popup to the server-run gate. On opencode 2.x the gate raises an elicitation form, so the form is the single confirmation; on 1.19–1.x the client cannot render forms, so the yield hands the confirmation to the chat round-trip — the envelope answered in chat and retried with `approvedByUser: true`, which the consent ledger records as posture trust (the user's word as the agent reports it, no mechanical proof a human answered). No terminal approve trip, no token UUID (`DEVKIT_APPROVAL_MODE=token` opts back into the PIN-checked terminal gate); below the floor neither half is written — the server still runs its env-unset ask default, just without the client yield — and an install or update still removes the legacy ask rules. The allow rules are written only when the server half is present or established this run; a user-set `DEVKIT_APPROVAL_MODE` value wins, no client rules are kept, and rules a past install wrote are removed value-exact so the user's mechanical posture stays clean. A client `allow` rule can no longer fail anything open, while a `deny` rule still blocks the call in the client — which is why `npx huaweicloud-devkit doctor` fails one, fails a leftover devkit-written ask rule (the migration missed it), and warns when allow rules are present without the server env or the client half is unverifiable. Ownership follows the skills-tree seam's doctrine — add-only-if-absent per rule and value-exact removal — including its accepted edge: a user-authored rule of the identical shape that predates the install is removed together with the devkit's own. Residual from pre-yield installs: a saved "Always allow" row in OpenCode's permission store is a stale grant — the gate never consults it, and the yield rules mean the popup no longer appears to recreate it. `npx huaweicloud-devkit doctor` reports it as a `[WARN]` naming the row and the store; clean it up with `opencode api GET /api/permission/saved` (list) and `opencode api DELETE /api/permission/saved/<id>` (remove). See the huaweicloud-safety skill's approvals reference.
408
431
 
package/README.zh-CN.md CHANGED
@@ -279,7 +279,30 @@ npx --yes huaweicloud-devkit-mcp --transport remote
279
279
  }
280
280
  ```
281
281
 
282
- > 端口被占用时用 `--port <端口>` 换端口,`url` 同步修改;需要局域网访问时加 `--host 0.0.0.0`。remote 服务器不内置鉴权,请勿匿名暴露到公网。
282
+ > 端口被占用时用 `--port <端口>` 换端口,`url` 同步修改;需要局域网访问时加 `--host 0.0.0.0`。remote 服务器默认不内置鉴权,须加 `--auth-password-file <文件>` 才启用密码校验——请勿匿名暴露到公网。
283
+
284
+ ### 服务器模式(systemd,Linux)
285
+
286
+ 以一对加固的 systemd 服务运行 MCP server:专用 OS 用户 + 自动生成的鉴权密码,适合无人值守/运维环境。
287
+
288
+ ```bash
289
+ sudo npx --yes huaweicloud-devkit install-server # 默认:/opt/kunpeng,业务端口 8088,工具端口 7088,用户 devkit
290
+ sudo npx --yes huaweicloud-devkit install-server --install-path /opt/kunpeng --port 8088 --tool-port 7088 --user devkit
291
+ sudo npx --yes huaweicloud-devkit uninstall-server # 追加 --remove-user 可删除服务用户
292
+ ```
293
+
294
+ 它会创建:
295
+
296
+ - 专用系统用户(默认 `devkit`,nologin shell),两个服务均以该用户运行
297
+ - `huaweicloud-devkit.service`(业务端口,默认 8088)与 `huaweicloud-devkit-tool.service`(工具端口,默认 7088)
298
+ - 自动生成的鉴权密码 `<install-path>/devkit/server/.auth-password`(0600,属主为服务用户);所有 RPC 需携带 `Authorization: Bearer <密码>` 或 `x-devkit-password: <密码>` —— `GET /health` 保持开放供探活
299
+ - 自包含运行时 `<install-path>/devkit/app`(缺 Node.js 22.19+ 时自动下载)
300
+ - 幂等可重跑;追加 `--rotate-password` 可重新生成密码
301
+ - 重跑或轮换密码会使两个服务各重启一次(短暂停机窗口);重启完成后旧密码立即失效
302
+
303
+ 装机不会改动任何防火墙规则:检测到 firewalld 在运行时,安装输出会原样打印 `--add-port` 命令由你自己执行;其他发行版请按各自防火墙工具放行两个端口。
304
+
305
+ 注意:remote 传输没有会话可承载交互确认,写操作自动回退令牌审批——在服务器上用 `npx huaweicloud-devkit approve <token>` 确认写命令。
283
306
 
284
307
  ### 安装 KooCLI
285
308
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "huaweicloud-devkit",
3
3
  "mcpName": "io.github.huaweicloud/huaweicloud-devkit",
4
- "version": "2.0.1-next.2",
4
+ "version": "2.0.1-next.4",
5
5
  "kooCliVersion": "7.3.12",
6
6
  "description": "Agent toolkit that helps coding agents use Huawei Cloud Skills, KooCLI, APIs, SDKs, and future MCP capabilities safely and accurately.",
7
7
  "type": "module",
@@ -16,7 +16,7 @@
16
16
  },
17
17
  "mcpServers": "./.mcp.json",
18
18
  "description": "Guide coding agents to use Huawei Cloud Skills, KooCLI, APIs, SDKs, and future MCP capabilities with safer execution and less context.",
19
- "version": "2.0.1-next.2",
19
+ "version": "2.0.1-next.4",
20
20
  "author": {
21
21
  "name": "HuaweiCloud Mate",
22
22
  "url": "https://github.com/huaweicloud"
@@ -19,7 +19,7 @@
19
19
  },
20
20
  "mcpServers": "./.mcp.json",
21
21
  "description": "Agent toolkit that helps coding agents use Huawei Cloud Skills, KooCLI, APIs, SDKs, and future MCP capabilities safely and accurately.",
22
- "version": "2.0.1-next.2",
22
+ "version": "2.0.1-next.4",
23
23
  "author": {
24
24
  "name": "HuaweiCloud Mate",
25
25
  "url": "https://github.com/huaweicloud"
@@ -16,7 +16,7 @@
16
16
  },
17
17
  "mcpServers": "./.mcp.json",
18
18
  "description": "Guide coding agents to use Huawei Cloud Skills, KooCLI, APIs, SDKs, and future MCP capabilities with safer execution and less context.",
19
- "version": "2.0.1-next.2",
19
+ "version": "2.0.1-next.4",
20
20
  "author": {
21
21
  "name": "HuaweiCloud Mate",
22
22
  "url": "https://github.com/huaweicloud"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "huaweicloud-devkit",
3
- "version": "2.0.1-next.2",
3
+ "version": "2.0.1-next.4",
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",
@@ -39,6 +39,9 @@
39
39
  "huaweicloud_sandbox_shutdown": {
40
40
  "approval_mode": "approve"
41
41
  },
42
+ "huaweicloud_sandbox_kill": {
43
+ "approval_mode": "approve"
44
+ },
42
45
  "huaweicloud_auth_init": {
43
46
  "approval_mode": "approve"
44
47
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "huaweicloud-devkit",
3
- "version": "2.0.1-next.2",
3
+ "version": "2.0.1-next.4",
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",
@@ -39,6 +39,7 @@ export const APPROVAL_TOOLS = [
39
39
  'huaweicloud_sandbox_sign_agreement',
40
40
  'huaweicloud_sandbox_credentials',
41
41
  'huaweicloud_sandbox_shutdown',
42
+ 'huaweicloud_sandbox_kill',
42
43
  'huaweicloud_auth_init',
43
44
  'huaweicloud_auth_switch',
44
45
  'huaweicloud_obs_set_website_config',
@@ -69,6 +70,7 @@ export const APPROVAL_TOOL_INPUT_SHAPES = {
69
70
  huaweicloud_sandbox_sign_agreement: 'structured',
70
71
  huaweicloud_sandbox_credentials: 'structured',
71
72
  huaweicloud_sandbox_shutdown: 'structured',
73
+ huaweicloud_sandbox_kill: 'structured',
72
74
  huaweicloud_auth_init: 'structured',
73
75
  huaweicloud_auth_switch: 'structured',
74
76
  huaweicloud_obs_set_website_config: 'structured',
@@ -320,6 +320,13 @@ const NON_RETRYABLE_CLIENT_CODES = new Set([
320
320
  'HDKIT_NOT_REALNAME',
321
321
  'HDKIT_NOT_AGREEMENT',
322
322
  'HDKIT_NOT_REALNAME_AND_AGREEMENT',
323
+ // DevBox control-plane verdicts: re-authentication / IAM authorization /
324
+ // backend-scope rejections cannot be advanced by retrying the same call.
325
+ 'HDKIT_CREDENTIAL_INVALID',
326
+ 'HDKIT_CREDENTIAL_EXPIRED',
327
+ 'HDKIT_CREDENTIAL_FORBIDDEN',
328
+ 'HDKIT_IDENTITY_UNSUPPORTED',
329
+ 'HDKIT_BACKEND_UNSUPPORTED',
323
330
  ]);
324
331
  export function isNonRetryableBusinessError(error) {
325
332
  // 烧核裁决不重试(round 29/MUST 2):请求层在重试判定前落 coreHoursExhausted
@@ -100,7 +100,9 @@ function transportReason(error, fallback) {
100
100
  }
101
101
  return Object.assign(new Error(cleanMessage(reason) || fallback), { bodyUnreadable: true });
102
102
  }
103
- async function hdkitRequest(method, path, body, timeoutMs = 300000) {
103
+ // Devbox control plane reuses the exact same credential/token/retry envelope;
104
+ // exported for devbox-service-api.ts (the design keeps one request seam).
105
+ export async function hdkitRequest(method, path, body, timeoutMs = 300000) {
104
106
  const { ak, sk, securitytoken } = getCredentials();
105
107
  if (!ak || !sk) {
106
108
  throw new Error('Huawei Cloud credentials are not configured. ' +
@@ -256,6 +258,33 @@ async function hdkitRequest(method, path, body, timeoutMs = 300000) {
256
258
  ],
257
259
  };
258
260
  }
261
+ // Devbox 控制面凭证码(A:每次 AK/SK,无 sandbox key):401 重新认证、
262
+ // 403 修 IAM 授权、identity 不支持 agency/临时凭证——都不是重试能推进的。
263
+ if (canonCode(code) === 'HDKIT_CREDENTIAL_INVALID' || canonCode(code) === 'HDKIT_CREDENTIAL_EXPIRED') {
264
+ err.remediation = {
265
+ hint: 'DevBox 控制面凭证无效或已失效(devbox 没有 sandbox key,每次调用都用 AK/SK):',
266
+ steps: [
267
+ '运行 npx huaweicloud-devkit auth init 重新配置有效 AK/SK(或 huaweicloud_auth_switch)',
268
+ '临时凭证已过期时先刷新 STS 凭证再重试',
269
+ '重新认证后 connect 会复用原 sandbox(running/paused),不会新建',
270
+ ],
271
+ };
272
+ }
273
+ if (canonCode(code) === 'HDKIT_CREDENTIAL_FORBIDDEN') {
274
+ err.remediation = {
275
+ hint: '当前账号无权限执行 DevBox 控制面操作:',
276
+ steps: ['检查 IAM 授权是否包含所需沙箱/DevBox 权限', '不要当作凭证过期反复重登;授权修正后重试'],
277
+ };
278
+ }
279
+ if (canonCode(code) === 'HDKIT_IDENTITY_UNSUPPORTED') {
280
+ err.remediation = {
281
+ hint: 'devbox v1 只接受 IAM 用户(principal_urn 为 :user:)的凭证:',
282
+ steps: [
283
+ '改用 IAM 用户的永久 AK/SK(临时/agency 凭证不在 v1 范围)',
284
+ '不要降级成 account 级租户;每个 IAM 子账号独立 sandbox',
285
+ ],
286
+ };
287
+ }
259
288
  // 429 三错误码(两池配额契约 + 用户级模板 running 上限,dev dff5df91 + 45dd4f99):
260
289
  // 配额满与模板上限给出各自的引导;池容量不足只透传服务端最终文案
261
290
  // (“DevKit 免费资源当前使用人数较多,建议您错峰使用,感谢理解!”),不再附加
@@ -233,6 +233,27 @@ export function enrichConnectResult(result, options = {}) {
233
233
  const rec = result;
234
234
  const poolType = asString(rec.pool_type || rec.poolType);
235
235
  const announce = options.announce !== false;
236
+ // Devbox lifecycle is server-authoritative (end_at / token_expiration /
237
+ // pause_retention_hours), NOT the DevStation idle policy numbers. Never fall
238
+ // through to the legacy idle shutdown/delete broadcast on this backend.
239
+ if (asString(rec.backend) === 'devbox') {
240
+ if (!announce) {
241
+ delete rec.pool;
242
+ return result;
243
+ }
244
+ const endAt = asString(rec.end_at || rec.endAt);
245
+ const tokenExpiration = asString(rec.token_expiration || rec.tokenExpiration);
246
+ const retentionRaw = rec.pause_retention_hours ?? rec.pauseRetentionHours;
247
+ const retention = typeof retentionRaw === 'number' && retentionRaw > 0 ? retentionRaw : 168;
248
+ rec.pool = {
249
+ pool_type: 'ephemeral',
250
+ lifecycle: `devbox ephemeral sandbox${endAt ? `; TTL ends ${endAt}` : ''}; pause retention ${retention}h`,
251
+ ttl_hint: `DevBox 沙箱${endAt ? `到期时间 ${endAt}` : '按平台 TTL 到期'};` +
252
+ `shutdown 暂停后保留 ${retention} 小时,超期由平台回收。重要数据请及时保存或迁出。` +
253
+ (tokenExpiration ? ` EnvD 数据面 token 到期时间 ${tokenExpiration},devkit 会自动刷新一次。` : ''),
254
+ };
255
+ return result;
256
+ }
236
257
  if (!announce || !poolType || !isPoolType(poolType)) {
237
258
  delete rec.pool;
238
259
  return result;