huaweicloud-devkit 1.1.14-next.4 → 1.1.14-next.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "huaweicloud-devkit",
3
3
  "mcpName": "io.github.huaweicloud/huaweicloud-devkit",
4
- "version": "1.1.14-next.4",
4
+ "version": "1.1.14-next.5",
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",
@@ -17,7 +17,7 @@
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
19
  "skills": "./skills/",
20
- "version": "1.1.14-next.4",
20
+ "version": "1.1.14-next.5",
21
21
  "author": {
22
22
  "name": "HuaweiCloud Mate",
23
23
  "url": "https://github.com/huaweicloud"
@@ -20,7 +20,7 @@
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
22
  "skills": "./skills/",
23
- "version": "1.1.14-next.4",
23
+ "version": "1.1.14-next.5",
24
24
  "author": {
25
25
  "name": "HuaweiCloud Mate",
26
26
  "url": "https://github.com/huaweicloud"
@@ -17,7 +17,7 @@
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
19
  "skills": "./skills/",
20
- "version": "1.1.14-next.4",
20
+ "version": "1.1.14-next.5",
21
21
  "author": {
22
22
  "name": "HuaweiCloud Mate",
23
23
  "url": "https://github.com/huaweicloud"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "huaweicloud-devkit",
3
- "version": "1.1.14-next.4",
3
+ "version": "1.1.14-next.5",
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,6 +1,6 @@
1
1
  {
2
2
  "name": "huaweicloud-devkit",
3
- "version": "1.1.14-next.4",
3
+ "version": "1.1.14-next.5",
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",
@@ -2,7 +2,7 @@
2
2
  "name": "huaweicloud-devkit",
3
3
  "id": "huaweicloud-devkit",
4
4
  "displayName": "HuaweiCloud DevKit",
5
- "version": "1.1.14-next.4",
5
+ "version": "1.1.14-next.5",
6
6
  "family": "bundle-plugin",
7
7
  "bundleFormat": "codex",
8
8
  "description": "Guide coding agents to use Huawei Cloud safely — KooCLI, APIs, SDKs, 28 MCP tools, skills, and safety guardrails.",
@@ -74,6 +74,7 @@
74
74
  "sandboxWriteTools": [
75
75
  "huaweicloud_sandbox_connect",
76
76
  "huaweicloud_sandbox_credentials",
77
- "huaweicloud_sandbox_upload_file"
77
+ "huaweicloud_sandbox_upload_file",
78
+ "huaweicloud_sandbox_shutdown"
78
79
  ]
79
80
  }
@@ -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, backend service, or full-stack workbench. 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, backend service, 工作台, workbench, full-stack, 全栈, CRUD 应用, database-backed REST API, PostgREST, postgres, 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, backend service, or full-stack workbench. Covers sandbox lifecycle (check-user, sign-agreement, connect, shutdown, credentials), 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, backend service, 工作台, workbench, full-stack, 全栈, CRUD 应用, database-backed REST API, PostgREST, postgres, 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
 
@@ -43,6 +43,40 @@ Hard rules:
43
43
  - **Pre-code checkpoint (MANDATORY)**: before uploading or writing ANY application code, verify the backend choice matches this gate. If an SPA-only deployment already started and persistence turns out to be implied, STOP, tell the developer, and redirect to the full-stack path — do not paper over it with a bolted-on static backend.
44
44
  - After the choice: PostgREST → follow [Full-Stack: REST API over PostgreSQL](#full-stack-rest-api-over-postgresql-postgrest) **FIRST** (backend before any frontend code), then continue with the web deployment steps; 自带后端 / 纯静态 → continue with [Web Application Deployment](#web-application-deployment).
45
45
 
46
+ ## Pool-Selection Gate (MANDATORY — do not skip)
47
+
48
+ Before `huaweicloud_sandbox_connect`, select the pool by **task intent**, not by tech stack. Default is `ephemeral`.
49
+
50
+ ### 1. Default ephemeral
51
+
52
+ - Preview / demo / trial / one-off / sensitive burn-after-use → `ephemeral`, even for full-stack or DB-backed projects.
53
+ - A DB/full-stack stack is only a capability hint; it does not by itself require persistence.
54
+
55
+ ### 2. Persistent only with explicit or confirmed long-term intent
56
+
57
+ Use `persistent` only when:
58
+
59
+ - the developer explicitly says long-term / cross-day / resume later / keep data / development workbench; or
60
+ - you infer a workbench/long-term task from the conversation, but the developer did not say it explicitly → ask once before connecting.
61
+
62
+ If the intent is ambiguous, ask exactly one question:
63
+
64
+ > 这个任务需要跨会话保留数据吗?① 临时预览/一次性(默认,非持久化) ② 长期/跨天继续(持久化)
65
+
66
+ ### 3. Task continuity
67
+
68
+ - Same task / same deployment follow-up: keep the current pool; do not re-evaluate mid-task.
69
+ - New task: re-evaluate. A new preview stays `ephemeral` even if a persistent sandbox already exists.
70
+ - If the new preview might reuse the existing environment/data, ask once:
71
+ > 已有持久化沙箱,是否直接复用(保留现有环境/数据),还是新建临时预览环境?
72
+ - Switching pools does not migrate data; tell the developer.
73
+
74
+ ### 4. Never
75
+
76
+ - Never select `persistent` merely because the project is full-stack or DB-backed.
77
+ - Never switch pool silently mid-task.
78
+ - Never ask the pool question when the intent is already explicit.
79
+
46
80
  ## Overview
47
81
 
48
82
  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.
@@ -53,30 +87,36 @@ Domain expertise for Huawei Cloud Sandbox (DevStation) instances and workspace t
53
87
 
54
88
  `huaweicloud_sandbox_connect` 用 `pool_type` 选择资源池(服务端权威映射模板;**没有 persist_mode 参数**;客户端不再支持传 template_id/自定义模板):
55
89
 
56
- > 下表生命周期数值仅用于内部选池与诊断:ephemeral 不向开发者播报;persistent 只播报沙箱生命周期,不播报隧道有效期/自动续期。
90
+ > 下表生命周期数值仅用于内部选池与诊断:ephemeral 不向开发者播报;persistent 只播报沙箱生命周期与核时提醒,不播报隧道有效期/自动续期。
57
91
 
58
92
  | pool_type | 语义 | 生命周期(平台策略) | 适用 |
59
93
  | ------------------- | ------------------ | ------------------------------------------------------------ | --------------------------- |
60
94
  | `ephemeral`(默认) | 非持久沙箱 | 闲置 30 分钟自动关机 + 闲置 1 小时自动删除(平台定时任务) | 临时运行/预览,勿存重要数据 |
61
95
  | `persistent` | 持久沙箱(EVS 盘) | 数据跨关机保留;闲置 1 小时自动关机;闲置回收保留期上限 7 天 | 需要跨会话保留数据 |
62
96
 
63
- Selection rules(agent 按意图自动选池,开发者可覆盖;意图不明确时呈现两类供选择):
64
-
65
- | 意图 / 场景 | pool_type | 理由 |
66
- | ------------------------- | ---------- | ----------------------------------- |
67
- | 预览 / 试用 / demo | ephemeral | 用完即弃,无需保留状态 |
68
- | 一次性任务(跑完即弃) | ephemeral | 结果带出沙箱;实例随闲置回收 |
69
- | 敏感内容(即焚) | ephemeral | 闲置 1 小时自动删除,数据随实例消亡 |
70
- | 开发工作台 / workbench | persistent | 会话跨天;状态需跨关机保留 |
71
- | 带数据库项目(DB-backed) | persistent | 数据落在挂载的 EVS 盘(32G) |
72
- | 跨日评审 / 展示 | persistent | 评审者后续日期回访;实例保留 |
73
-
97
+ Selection rules(按意图自动选池;具体按 [Pool-Selection Gate](#pool-selection-gate-mandatory--do-not-skip) 执行;默认 `ephemeral`,`persistent` 需明确长期意图或确认;开发者可覆盖):
98
+
99
+ | 意图 / 场景 | pool_type | 理由 |
100
+ | ---------------------------- | ---------- | -------------------------------------- |
101
+ | 预览 / 试用 / demo | ephemeral | 用完即弃,无需保留状态 |
102
+ | 一次性任务(跑完即弃) | ephemeral | 结果带出沙箱;实例随闲置回收 |
103
+ | 敏感内容(即焚) | ephemeral | 闲置 1 小时自动删除,数据随实例消亡 |
104
+ | 带数据库但只是预览/演示 | ephemeral | 预览可重建数据;技术栈不是持久化触发器 |
105
+ | 开发工作台 / workbench | persistent | 会话跨天;状态需跨关机保留 |
106
+ | 带数据库且需要跨会话保留数据 | persistent | 数据落在挂载的 EVS 盘(32G) |
107
+ | 跨日评审 / 展示 | persistent | 评审者后续日期回访;实例保留 |
108
+
109
+ - **预览/一次性即使全栈/DB 也用 `ephemeral`**;技术栈不是持久化触发器
110
+ - **`persistent` 只能来自明确长期意图,或推断后确认**;不得仅因 full-stack/DB 选 persistent
111
+ - **同一任务沿用当前池**;新任务重新选型;新预览默认 `ephemeral`,必要时问一次是否复用已有 persistent
112
+ - **切换池数据不迁移**
74
113
  - **配额**:每用户每类型 1 台(1+1 可并存);同池 connect 自动复用已有实例
75
- - **429 双错误码**:`HDKIT_QUOTA_EXCEEDED`(账号配额满,重试无效→引导释放/复用);`HDKIT_CAPACITY_INSUFFICIENT`(池容量不足,服务端直接返回最终文案“DevKit 免费资源当前使用人数较多,建议您错峰使用,感谢理解!”,客户端不再附加引导)。响应带 `Retry-After`
114
+ - **429 三错误码**:`HDKIT_QUOTA_EXCEEDED`(账号配额满,重试无效→引导释放/复用);`HDKIT_TEMPLATE_QUOTA_EXCEEDED`(当前账号此类型沙箱运行中实例达上限,需关机/释放同类型实例后重试,无 `Retry-After`);`HDKIT_CAPACITY_INSUFFICIENT`(池容量不足,服务端直接返回最终文案“DevKit 免费资源当前使用人数较多,建议您错峰使用,感谢理解!”,客户端不再附加引导)。`HDKIT_QUOTA_EXCEEDED` / `HDKIT_CAPACITY_INSUFFICIENT` 响应带 `Retry-After: 60`
76
115
  - **生命周期播报**:生命周期数值仅用于内部选池与诊断,不逐次播报。
77
116
  - **ephemeral**:交付 URL 时只给 URL。不要提隧道/沙箱有效期、自动续期、闲置关机或删除,也不要建议迁移到持久沙箱或 OBS。例外:隧道无法持久时按 tunnel-persistence 小节的失败路径提示开发者“隧道将在会话结束后失效,请勿分享”;这不属于常规有效期播报。
78
- - **persistent**:只播报沙箱生命周期(闲置关机、数据盘保留、闲置回收上限),使用 `sandboxLifetime` / connect 的 `pool.ttl_hint` 口径;不要播报 devbridge 隧道有效期或自动续期。
117
+ - **persistent**:播报沙箱生命周期(闲置关机、数据盘保留、闲置回收上限),使用 `sandboxLifetime` / connect 的 `pool.ttl_hint` 口径;并提示“如暂时不需要使用,建议尽快关机,避免持续消耗核时;可以告诉我帮你关机(实例与数据盘保留,下次连接会自动唤醒)”。不要播报 devbridge 隧道有效期或自动续期。
79
118
  - **烧核播报口径**:沙箱运行消耗核时,播报用「平台赠送 + 活动赚取」口径(非直接计费);账号核时耗尽(`HD.97520422`)时工具返回值给出友好引导
119
+ - **关机纪律**:仅当开发者明确要求关机时调用 `huaweicloud_sandbox_shutdown`;调用前确认一次,绝不自动关机。关机 ≠ 删除:只 close,不 delete,实例与 EVS 数据盘保留,下次 connect 自动唤醒。非持久化沙箱也可关机,但不主动提示;不要向开发者提“控制台关机”。
80
120
  - **删除纪律**:不向开发者暴露生命周期删除 API(回收走平台闲置策略 G1);开发者主动删除时必须二次确认(确认要删除?数据不可恢复);绝不做延后代删
81
121
  - 不支持传 `template_id`;自定义模板已下线,客户端只传 `pool_type`
82
122
  - 完整口径、容量规划与 G 清单:[references/resource-pool.md](references/resource-pool.md)
@@ -112,6 +152,7 @@ Selection rules(agent 按意图自动选池,开发者可覆盖;意图不
112
152
  | --------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
113
153
  | `huaweicloud_sandbox_connect` | Connect to sandbox (one instance per user per pool; `pool_type` selects ephemeral/persistent, default ephemeral) |
114
154
  | `huaweicloud_sandbox_credentials` | Inject temporary AK/SK into a running sandbox |
155
+ | `huaweicloud_sandbox_shutdown` | Shut down a running sandbox (close only; instance/data disk retained; reconnect wakes it) |
115
156
 
116
157
  ### Tunnel Persistence (public URL lifetime)
117
158
 
@@ -146,6 +187,7 @@ Selection rules(agent 按意图自动选池,开发者可覆盖;意图不
146
187
  | Deployment completeness check | `deploy_check` | Verifies nginx, DevBridge, URL, QR before reporting success |
147
188
  | Tunnel lifetime renewal | `renew_tunnel` | Rolling-window renewal, same URL stays alive |
148
189
  | URL must outlive the session | `keepalive_watchdog` | Unattended host re-attach + daily renewal + health check |
190
+ | 暂不使用 / 节省核时 | `sandbox_shutdown` | 只关机不删除;数据盘保留,下次 connect 自动唤醒 |
149
191
  | Single file upload (<1MB) | `upload_file` | Base64 chunked, reliable for small files |
150
192
  | Project directory upload (>1MB) | `upload_project` | HTTP tunnel, much faster than base64 for multi-file projects |
151
193
 
@@ -167,9 +209,9 @@ Selection rules(agent 按意图自动选池,开发者可覆盖;意图不
167
209
 
168
210
  **Step 0 — Target-Selection Gate (MANDATORY)**: before any sandbox lifecycle tool, confirm the target. If the developer asked to deploy/host/publish a site without naming a target, STOP and run the [Target-Selection Gate](#target-selection-gate-mandatory--do-not-skip) first; do NOT call `huaweicloud_sandbox_connect` until it is resolved. Proceed with this workflow only if the target is already confirmed as sandbox (or a temporary runtime).
169
211
 
170
- **Step 0.3 — Resource pool selection**: once the target is sandbox, pick the pool type per the [两池沙箱(pool_type)](#两池沙箱pool_type) selection rules (auto by intent, developer may override; 1 instance per type, same type reuses). Check the task survives the chosen type's lifecycle window (ephemeral: idle 30min shutdown + 1h delete; persistent: 7-day idle reclaim cap) before connecting.
212
+ **Step 0.5 — Stack-Selection Gate (MANDATORY)**: before selecting a pool or uploading application code, confirm the backend stack via the [Stack-Selection Gate](#stack-selection-gate-mandatory--do-not-skip). 工作台/workbench/全栈/full-stack/CRUD/持久化 ⇒ full-stack (PostgreSQL + PostgREST default) — do NOT start an SPA-only deployment for a workbench request.
171
213
 
172
- **Step 0.5 — Stack-Selection Gate (MANDATORY)**: before uploading or writing any application code, confirm the backend stack via the [Stack-Selection Gate](#stack-selection-gate-mandatory--do-not-skip). 工作台/workbench/全栈/full-stack/CRUD/持久化 ⇒ full-stack (PostgreSQL + PostgREST default) — do NOT start an SPA-only deployment for a workbench request.
214
+ **Step 0.6 — Pool-Selection Gate (MANDATORY)**: once the target is sandbox and the stack is known, select the pool per the [Pool-Selection Gate](#pool-selection-gate-mandatory--do-not-skip). Default `ephemeral`; use `persistent` only with explicit long-term intent or after confirmation. Same task reuses the current pool; a new task is re-evaluated. Check the task survives the chosen type's lifecycle window (ephemeral: idle 30min shutdown + 1h delete; persistent: 7-day idle reclaim cap) before connecting.
173
215
 
174
216
  Setup is a **plugin-side preflight** — the developer should be asked a question only once, when the agreement actually needs signing:
175
217
 
@@ -13,12 +13,32 @@
13
13
 
14
14
  ## 两类沙箱
15
15
 
16
- | 维度 | 非持久化 (ephemeral) | 持久化 (persistent) |
17
- | -------- | --------------------------------------- | --------------------------------------------------------------------- |
18
- | 定位 | 预览/试用/一次性任务/敏感即焚 | 开发工作台/带数据库项目/跨日评审展示 |
19
- | 生命周期 | 闲置 30min 自动关机 + 1h 删除(已实测) | 闲置 1h 自动关机(实例与数据保留);回收上限 7 天(资源组 DB 硬约束) |
20
- | 存储 | 无持久盘 | 挂 EVS 32G |
21
- | 配额 | 每用户 1 台(同类复用) | 每用户 1 台(同类复用;可与 1 台非持久并存) |
16
+ | 维度 | 非持久化 (ephemeral) | 持久化 (persistent) |
17
+ | -------- | ----------------------------------------------- | --------------------------------------------------------------------- |
18
+ | 定位 | 预览/试用/一次性任务/敏感即焚(含全栈/DB 预览) | 开发工作台/需要跨会话保留数据的项目/跨日评审展示 |
19
+ | 生命周期 | 闲置 30min 自动关机 + 1h 删除(已实测) | 闲置 1h 自动关机(实例与数据保留);回收上限 7 天(资源组 DB 硬约束) |
20
+ | 存储 | 无持久盘 | 挂 EVS 32G |
21
+ | 配额 | 每用户 1 台(同类复用) | 每用户 1 台(同类复用;可与 1 台非持久并存) |
22
+
23
+ ## 选型决策树(V1 dev,2026-11-12 定稿)
24
+
25
+ 默认 `ephemeral`;技术栈不是持久化触发器。
26
+
27
+ | 信号 | pool_type | 动作 |
28
+ | --------------------------------------- | ------------ | ---------------------------- |
29
+ | 预览 / demo / 一次性 / 敏感即焚 | `ephemeral` | 不问 |
30
+ | 全栈/DB 但只是预览/演示 | `ephemeral` | 不问,不因技术栈升级 |
31
+ | 明确长期 / 跨天 / 保留数据 / 开发工作台 | `persistent` | 不问 |
32
+ | 模型推断工作台/长期,但用户未明说 | `persistent` | 确认一次 |
33
+ | 意图不明确 | 先问 | 默认推荐 `ephemeral` |
34
+ | 同一任务/同一轮部署的后续操作 | 沿用当前池 | 不中途切换 |
35
+ | 新预览任务 + 已有 persistent | `ephemeral` | 必要时问一次是否复用现有环境 |
36
+ | 用户明确 override | 按用户 | 提示数据不跨池迁移 |
37
+
38
+ - `persistent` 只能来自**明确长期意图**,或**推断后确认**;不得仅因 full-stack/DB 选 persistent。
39
+ - 同一任务沿用当前池;新任务重新选型。新预览默认 `ephemeral`,即使已有 persistent。
40
+ - 新预览可能复用现有环境/数据时问一次:“已有持久化沙箱,是否直接复用(保留现有环境/数据),还是新建临时预览环境?”
41
+ - 切换池数据不迁移。
22
42
 
23
43
  ## 生命周期(实测口径)
24
44
 
@@ -31,7 +51,7 @@
31
51
  | 删除/关机前通知 | 不支持(G6 诉求中)→ 不播报 TTL;仅内部可见 | 现状 |
32
52
  | 两池实际差异 | 仅 EVS 32GiB 数据盘(非持久池无 disks 字段) | ✅ 已实证 |
33
53
 
34
- > 生命周期数值是**内部选池/诊断口径**,不向开发者播报:ephemeral 不播报;persistent 只播报沙箱生命周期,不播报隧道有效期/自动续期。由 hdkitservice 配置(`POOL_EPHEMERAL_IDLE_SHUTDOWN_MINUTES` / `POOL_EPHEMERAL_IDLE_DELETE_MINUTES` / `POOL_PERSISTENT_IDLE_SHUTDOWN_MINUTES` / `POOL_PERSISTENT_RECLAIM_MINUTES`,统一以**分钟**为单位;7 天 = 10080)随 connect 响应回显;客户端以回显为准,缺失时按上表默认值兜底。实际关机/删除策略由平台资源池执行,hdkitservice 不控制。
54
+ > 生命周期数值是**内部选池/诊断口径**,不向开发者播报:ephemeral 不播报;persistent 只播报沙箱生命周期与核时提醒,不播报隧道有效期/自动续期。由 hdkitservice 配置(`POOL_EPHEMERAL_IDLE_SHUTDOWN_MINUTES` / `POOL_EPHEMERAL_IDLE_DELETE_MINUTES` / `POOL_PERSISTENT_IDLE_SHUTDOWN_MINUTES` / `POOL_PERSISTENT_RECLAIM_MINUTES`,统一以**分钟**为单位;7 天 = 10080)随 connect 响应回显;客户端以回显为准,缺失时按上表默认值兜底。实际关机/删除策略由平台资源池执行,hdkitservice 不控制。
35
55
 
36
56
  ## 容量规划(原始申请口径)
37
57
 
@@ -48,8 +68,9 @@
48
68
  ## 配额与错误码
49
69
 
50
70
  - 每用户每类型 1 台(同类复用,ephemeral + persistent 可并存 1+1);账号并发上限 5
51
- - 429 双错误码(均带 `Retry-After: 60`):
71
+ - 429 三错误码(`HDKIT_QUOTA_EXCEEDED` / `HDKIT_CAPACITY_INSUFFICIENT` 带 `Retry-After: 60`;`HDKIT_TEMPLATE_QUOTA_EXCEEDED` 不带):
52
72
  - `HDKIT_QUOTA_EXCEEDED`:用户配额满(上游 `HD.98320022`)→ 重试无效,引导释放/复用已有实例
73
+ - `HDKIT_TEMPLATE_QUOTA_EXCEEDED`:当前账号此类型沙箱运行中实例达上限(上游 `HD.98320082`)→ 需关机/释放同类型实例后重试
53
74
  - `HDKIT_CAPACITY_INSUFFICIENT`:池容量不足(上游 `HD.99003001`/`HD.99008001`/`HD.98330021`)→ 服务端直接返回最终文案“DevKit 免费资源当前使用人数较多,建议您错峰使用,感谢理解!”,客户端原样透传不再附加引导
54
75
  - 烧核:`HD.97520422` = 账号核心时长耗尽(沙箱运行消耗核时;客户端对含该码的错误输出友好播报)
55
76
 
@@ -60,9 +81,12 @@
60
81
  ## 客户端行为(本插件)
61
82
 
62
83
  - `sandbox_connect` 传 `pool_type`;非法值本地即报错(不发无效请求);未传由服务端默认 ephemeral
63
- - 生命周期数据只在内部使用:connect(会话首次连接,或复用实例被唤醒 `started=true`)与 `expose_tunnel`(交付地址时)会返回 `sandboxLifetime` / `urlLifetimeHint` / `warnings` 供内部诊断;ephemeral 不向开发者播报,persistent 只播报沙箱生命周期(不含隧道有效期/自动续期);其余 exec/upload/deploy 工具不逐次播报
84
+ - 选型由 skill 的 Pool-Selection Gate 决定;客户端只校验/透传 `pool_type`,不自行推断
85
+ - 生命周期数据只在内部使用:connect(会话首次连接,或复用实例被唤醒 `started=true`)与 `expose_tunnel`(交付地址时)会返回 `sandboxLifetime` / `urlLifetimeHint` / `warnings` 供内部诊断;ephemeral 不向开发者播报,persistent 只播报沙箱生命周期与核时提醒(不含隧道有效期/自动续期);其余 exec/upload/deploy 工具不逐次播报
64
86
  - connect 返回值富化 `pool` 块(数值取服务端回显,缺失时用默认口径);生命周期口径按 workspace 缓存到 `~/.config/huaweicloud/sandbox-pools.json`(0600,7 天过期),仅内部使用(进程重启后仍可用于选池/诊断,不向开发者播报)
65
87
  - 429:配额满给 `remediation` 引导;容量不足只透传服务端最终文案 + `retryAfter`
88
+ - persistent 生命周期提示追加核时提醒:**如暂时不需要使用,建议尽快关机,避免持续消耗核时;可以告诉我帮你关机(实例与数据盘保留,下次连接会自动唤醒)。** ephemeral 不出现该提示
89
+ - `sandbox_shutdown` 调 hdkitservice `POST /shutdown`(DevStation `close`,不 delete);仅开发者明确要求时调用;返回 `stopped` / `shutting_down` / `already_stopped` / `close_requested`。非持久化沙箱也可关机,但不主动提示
66
90
  - 模板 ID 仅由服务端 `POOL_TEMPLATE_*` 权威维护;客户端不再支持 `HW_POOL_TEMPLATE_*` 钉扎或显式 template_id
67
91
 
68
92
  ## 平台侧关键依赖(G 清单,非 devkit 交付)
@@ -79,9 +79,10 @@ async function hdkitRequest(method, path, body, timeoutMs = 300000) {
79
79
  ],
80
80
  };
81
81
  }
82
- // 429 双错误码(两池配额契约):配额满给出释放/复用引导;池容量不足只透传服务端
83
- // 最终文案(“DevKit 免费资源当前使用人数较多,建议您错峰使用,感谢理解!”),
84
- // 不再附加额外引导——该文案即最终展示内容。两者均携带服务端 Retry-After。
82
+ // 429 三错误码:配额满给出释放/复用引导;模板 running 上限与池容量不足只透传
83
+ // 服务端最终文案(不带 CODE 前缀、不附加额外引导)。
84
+ // HDKIT_QUOTA_EXCEEDED / HDKIT_CAPACITY_INSUFFICIENT 带 Retry-After;
85
+ // HDKIT_TEMPLATE_QUOTA_EXCEEDED 不带(需关机/释放同类型实例后重试)。
85
86
  if (code === 'HDKIT_QUOTA_EXCEEDED') {
86
87
  err.retryAfter = resp.headers.get('Retry-After') || undefined;
87
88
  err.remediation = {
@@ -93,6 +94,14 @@ async function hdkitRequest(method, path, body, timeoutMs = 300000) {
93
94
  ],
94
95
  };
95
96
  }
97
+ // 用户级模板 running 上限(HD.98320082):服务端文案即最终展示内容
98
+ // (不带 "CODE: " 前缀、不附加旧的“每账号最多 5 台”引导)
99
+ if (code === 'HDKIT_TEMPLATE_QUOTA_EXCEEDED') {
100
+ err.message =
101
+ typeof data.message === 'string' && data.message.trim()
102
+ ? data.message
103
+ : '当前账号在此类型沙箱的运行中实例已达上限,无法创建新的沙箱';
104
+ }
96
105
  if (code === 'HDKIT_CAPACITY_INSUFFICIENT') {
97
106
  err.retryAfter = resp.headers.get('Retry-After') || undefined;
98
107
  // 该文案即最终展示内容(不带 "CODE: " 前缀、不附加引导)
@@ -231,6 +240,18 @@ export async function hdkitCredentials(sessionId, devStageId, enableSts = true)
231
240
  return await hdkitRequest('POST', 'credentials', body);
232
241
  }
233
242
 
243
+ export async function hdkitShutdown(sessionId, devStageId) {
244
+ const body = {};
245
+ if (sessionId) body.session_id = sessionId;
246
+ if (devStageId) body.dev_stage_id = devStageId;
247
+
248
+ if (!sessionId && !devStageId) {
249
+ throw new Error('session_id or dev_stage_id is required');
250
+ }
251
+
252
+ return await hdkitRequest('POST', 'shutdown', body, 120000);
253
+ }
254
+
234
255
  // ── DevBridge API Key relay 代理(经 hdkitservice 透传 DevStation relay 接口)──
235
256
  // 凭证由 hdkitRequest 内部 getCredentials() 统一解析,调用方无需传
236
257
 
@@ -19,6 +19,10 @@ export const DEFAULT_POOL_LIFECYCLE = {
19
19
  persistent: { idleShutdownMinutes: 60, idleDeleteMinutes: null, reclaimMinutes: 7 * 24 * 60 },
20
20
  };
21
21
 
22
+ /** 持久化沙箱的核时节省提示:与生命周期提示同一时机播报;ephemeral 不播报 */
23
+ export const PERSISTENT_CORE_HOURS_HINT =
24
+ '如暂时不需要使用,建议尽快关机,避免持续消耗核时;可以告诉我帮你关机(实例与数据盘保留,下次连接会自动唤醒)。';
25
+
22
26
  const CACHE_TTL_MS = 7 * 24 * 60 * 60 * 1000;
23
27
 
24
28
  /** workspaceId → { poolType, lifecycle, updatedAt }:connect 回显后缓存 */
@@ -196,7 +200,7 @@ export function poolContextFor(workspaceId) {
196
200
  return {
197
201
  poolMode: 'persistent',
198
202
  poolLifecycle: { poolType, ...lifecycle },
199
- persistenceHint: `持久沙箱:闲置 ${shutdown}自动关机(数据盘保留);闲置回收保留期最长 ${reclaim}`,
203
+ persistenceHint: `持久沙箱:闲置 ${shutdown}自动关机(数据盘保留);闲置回收保留期最长 ${reclaim}。${PERSISTENT_CORE_HOURS_HINT}`,
200
204
  };
201
205
  }
202
206
 
@@ -213,7 +217,7 @@ function buildConnectTtlHint(poolType, lifecycle) {
213
217
  const reclaim = formatReclaim(lifecycle.reclaimMinutes, DEFAULT_POOL_LIFECYCLE.persistent.reclaimMinutes);
214
218
  return {
215
219
  lifecycle: `idle shutdown ${lifecycle.idleShutdownMinutes}min; EVS data disk retained; idle reclaim within ${lifecycle.reclaimMinutes}min max`,
216
- ttl_hint: `持久沙箱:闲置 ${shutdown}自动关机(实例与数据盘保留,重新连接可继续使用);闲置回收保留期最长 ${reclaim},到期实例与数据将被删除,长期不用请自行导出。`,
220
+ ttl_hint: `持久沙箱:闲置 ${shutdown}自动关机(实例与数据盘保留,重新连接可继续使用);闲置回收保留期最长 ${reclaim},到期实例与数据将被删除,长期不用请自行导出。${PERSISTENT_CORE_HOURS_HINT}`,
217
221
  };
218
222
  }
219
223
 
@@ -277,7 +281,7 @@ export function buildExposeLifetimeNotice(poolContext, expiryHours) {
277
281
  urlLifetimeHint:
278
282
  `该公网地址随沙箱存亡:持久沙箱闲置 ${shutdown}自动关机(地址失效,但实例与数据盘保留,` +
279
283
  `重新连接沙箱后可重新暴露端口恢复访问);闲置回收保留期最长 ${reclaim},到期实例与数据将被删除。` +
280
- `隧道有效期 ${tunnelHours} 小时不等于沙箱存活期;自动续期只保隧道,不能阻止沙箱关机。`,
284
+ `隧道有效期 ${tunnelHours} 小时不等于沙箱存活期;自动续期只保隧道,不能阻止沙箱关机。${PERSISTENT_CORE_HOURS_HINT}`,
281
285
  warning:
282
286
  `URL 存活期提示:持久沙箱闲置 ${shutdown}自动关机,此地址届时失效(实例与数据保留,` +
283
287
  `重新连接后可恢复);闲置回收上限 ${reclaim}`,
@@ -42,6 +42,7 @@ import {
42
42
  hdkitSignAgreement,
43
43
  hdkitConnectWithRetry,
44
44
  hdkitCredentials,
45
+ hdkitShutdown,
45
46
  hdkitVoucherStatus,
46
47
  hdkitVoucherClaim,
47
48
  hdkitCompetitionVoucherClaim,
@@ -893,7 +894,7 @@ export const TOOL_DEFINITIONS = [
893
894
  {
894
895
  name: 'huaweicloud_sandbox_connect',
895
896
  description:
896
- 'Connect to a sandbox via hdkitservice. One instance per user per pool — reuses the same-pool sandbox if available, otherwise creates a new one. Quota: 1 instance per pool type (a user may hold 1 ephemeral AND 1 persistent simultaneously; same-type requests reuse the existing instance). On quota exhaustion the API returns HTTP 429 with a Retry-After header and a dual error code: HDKIT_QUOTA_EXCEEDED (retry useless — release or reuse the existing instance) vs HDKIT_CAPACITY_INSUFFICIENT (pool capacity; retry later / off-peak). Gateway 502/504 timeouts during orchestration are retried automatically (30s/45s backoff) — the server may already have created the instance, so a retry reuses it. Returns session_id, dev_stage_id, connection_id, connection_address, expiresAt (STS credential expiry), pool_type echo, server-configured lifecycle numbers (pool_idle_shutdown_minutes / pool_idle_delete_minutes / pool_reclaim_minutes) and started (true when a reused instance was woken from shutdown). Lifecycle numbers are internal: never surface ephemeral tunnel/sandbox lifetime, auto-renewal, idle shutdown/delete, or migration suggestions; for persistent pools relay only the sandbox lifecycle notice (see huawei-sandbox skill).',
897
+ "Connect to a sandbox via hdkitservice. One instance per user per pool — reuses the same-pool sandbox if available, otherwise creates a new one. Quota: 1 instance per pool type (a user may hold 1 ephemeral AND 1 persistent simultaneously; same-type requests reuse the existing instance). On quota exhaustion the API returns HTTP 429 with one of three codes: HDKIT_QUOTA_EXCEEDED (retry useless — release or reuse the existing instance; Retry-After 60), HDKIT_TEMPLATE_QUOTA_EXCEEDED (the account's running instances for this sandbox type are at the limit — shut down or release an instance of the same type and retry; no Retry-After), or HDKIT_CAPACITY_INSUFFICIENT (pool capacity; retry later / off-peak; Retry-After 60). Gateway 502/504 timeouts during orchestration are retried automatically (30s/45s backoff) — the server may already have created the instance, so a retry reuses it. Returns session_id, dev_stage_id, connection_id, connection_address, expiresAt (STS credential expiry), pool_type echo, server-configured lifecycle numbers (pool_idle_shutdown_minutes / pool_idle_delete_minutes / pool_reclaim_minutes) and started (true when a reused instance was woken from shutdown). Lifecycle numbers are internal: never surface ephemeral tunnel/sandbox lifetime, auto-renewal, idle shutdown/delete, or migration suggestions; for persistent pools relay only the sandbox lifecycle notice (see huawei-sandbox skill).",
897
898
  inputSchema: {
898
899
  type: 'object',
899
900
  properties: {
@@ -947,6 +948,20 @@ export const TOOL_DEFINITIONS = [
947
948
  },
948
949
  },
949
950
  },
951
+ {
952
+ name: 'huaweicloud_sandbox_shutdown',
953
+ description:
954
+ 'Shut down a running sandbox via hdkitservice to stop core-hour consumption. This calls DevStation close, NOT delete: the instance is retained; for persistent sandboxes the EVS data disk is also retained. A later huaweicloud_sandbox_connect wakes it. Works for both ephemeral and persistent sandboxes. Only call when the developer explicitly asks to shut down; never auto-shutdown. Returns devStageId, status (stopped/shutting_down/already_stopped/close_requested) and message.',
955
+ inputSchema: {
956
+ type: 'object',
957
+ properties: {
958
+ session_id: { type: 'string', description: 'Session ID from huaweicloud_sandbox_connect (optional)' },
959
+ dev_stage_id: { type: 'string', description: 'DevStation environment ID (alternative to session_id)' },
960
+ workspace_id: { type: 'string', description: 'Workspace ID; defaults to the current workspace' },
961
+ username: { type: 'string', description: 'Login username for the terminal session (default: root)' },
962
+ },
963
+ },
964
+ },
950
965
  {
951
966
  name: 'huaweicloud_voucher_status',
952
967
  description:
@@ -1774,10 +1789,11 @@ export async function callTool(name, rawArgs = {}, opts = {}) {
1774
1789
  try {
1775
1790
  connectResult = await hdkitConnectWithRetry(connectArgs);
1776
1791
  } catch (error) {
1777
- // 业务预期失败(429 双码 / 烧核 / 凭证失效)转结构化返回,remediation 才能穿透 MCP 边界;
1792
+ // 业务预期失败(429 三码 / 烧核 / 凭证失效)转结构化返回,remediation 才能穿透 MCP 边界;
1778
1793
  // 其余错误维持抛出(MCP 层透传 code+message)
1779
1794
  if (
1780
1795
  error?.code === 'HDKIT_QUOTA_EXCEEDED' ||
1796
+ error?.code === 'HDKIT_TEMPLATE_QUOTA_EXCEEDED' ||
1781
1797
  error?.code === 'HDKIT_CAPACITY_INSUFFICIENT' ||
1782
1798
  error?.code === 'HDKIT_CRED_INVALID' ||
1783
1799
  error?.code === 'HDKIT_VERSION_TOO_OLD' ||
@@ -1907,6 +1923,29 @@ export async function callTool(name, rawArgs = {}, opts = {}) {
1907
1923
  if (validation.skipped) result.warning = validation.error;
1908
1924
  return result;
1909
1925
  }
1926
+ case 'huaweicloud_sandbox_shutdown': {
1927
+ const sessionId = args.session_id;
1928
+ const workspaceId = args.dev_stage_id || args.workspace_id || getCurrentWorkspaceId();
1929
+ const devStageId = args.dev_stage_id || args.workspace_id || (sessionId ? undefined : workspaceId);
1930
+ const id = sessionId || devStageId;
1931
+ if (!id) {
1932
+ return {
1933
+ ok: false,
1934
+ code: 'HDKIT_INVALID_REQUEST',
1935
+ message:
1936
+ 'session_id or dev_stage_id is required. No sandbox connected — call huaweicloud_sandbox_connect first, or pass workspace_id.',
1937
+ };
1938
+ }
1939
+ try {
1940
+ const shutdown = await hdkitShutdown(sessionId, devStageId);
1941
+ try {
1942
+ await closeSession(shutdown.devStageId || workspaceId || sessionId, args.username || 'root');
1943
+ } catch {}
1944
+ return { ok: true, ...shutdown };
1945
+ } catch (error) {
1946
+ return toVersionGateResult(error);
1947
+ }
1948
+ }
1910
1949
  case 'huaweicloud_voucher_status':
1911
1950
  return await hdkitVoucherStatus(args.domain_id);
1912
1951
  case 'huaweicloud_voucher_claim': {