huaweicloud-devkit 2.0.0-next.2 → 2.0.0-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 (161) hide show
  1. package/README.md +3 -1
  2. package/package.json +3 -1
  3. package/plugins/huaweicloud-core/.claude-plugin/plugin.json +16 -3
  4. package/plugins/huaweicloud-core/.codex-plugin/plugin.json +16 -3
  5. package/plugins/huaweicloud-core/.cursor-plugin/plugin.json +16 -3
  6. package/plugins/huaweicloud-core/.hermes-plugin/plugin.json +16 -3
  7. package/plugins/huaweicloud-core/.mcp.json +55 -1
  8. package/plugins/huaweicloud-core/.workbuddy-plugin/plugin.json +16 -3
  9. package/plugins/huaweicloud-core/dist/agents/codex-config.js +374 -0
  10. package/plugins/huaweicloud-core/dist/agents/codex-desktop.js +8 -1
  11. package/plugins/huaweicloud-core/dist/agents/codex.js +9 -0
  12. package/plugins/huaweicloud-core/dist/agents/opencode-config.js +157 -31
  13. package/plugins/huaweicloud-core/dist/agents/opencode.js +129 -1
  14. package/plugins/huaweicloud-core/dist/approval-gate.js +1185 -0
  15. package/plugins/huaweicloud-core/dist/approval-ledger.js +2331 -0
  16. package/plugins/huaweicloud-core/dist/approval-roster.js +89 -0
  17. package/plugins/huaweicloud-core/dist/approval-types.js +1 -0
  18. package/plugins/huaweicloud-core/dist/approvals-cli.js +4 -4
  19. package/plugins/huaweicloud-core/dist/data/icons-manifest.v1.json +23 -5
  20. package/plugins/huaweicloud-core/dist/dep/receipts.js +65 -5
  21. package/plugins/huaweicloud-core/dist/hcloud-cli.js +1 -1
  22. package/plugins/huaweicloud-core/dist/hcloud-plan.js +77 -56
  23. package/plugins/huaweicloud-core/dist/lib/approval-mode.js +32 -0
  24. package/plugins/huaweicloud-core/dist/lib/approval-tokens.js +18 -4
  25. package/plugins/huaweicloud-core/dist/lib/call-trace.js +7 -14
  26. package/plugins/huaweicloud-core/dist/lib/confirm-language.js +50 -0
  27. package/plugins/huaweicloud-core/dist/lib/credentials.js +9 -9
  28. package/plugins/huaweicloud-core/dist/lib/hdkit/hdkit-gate.js +1398 -0
  29. package/plugins/huaweicloud-core/dist/lib/hdkit/hdkitservice-api.js +362 -32
  30. package/plugins/huaweicloud-core/dist/lib/hdkit/sandbox-pool.js +6 -16
  31. package/plugins/huaweicloud-core/dist/lib/opencode-ask-rule.js +262 -0
  32. package/plugins/huaweicloud-core/dist/lib/opencode-saved-perms.js +282 -0
  33. package/plugins/huaweicloud-core/dist/lib/supplemental-redaction.js +116 -0
  34. package/plugins/huaweicloud-core/dist/lib/tool-schema-parts.js +31 -0
  35. package/plugins/huaweicloud-core/dist/lib/workspace-glob.js +442 -0
  36. package/plugins/huaweicloud-core/dist/mcp-config-io.js +28 -1
  37. package/plugins/huaweicloud-core/dist/mcp-protocol.js +75 -4
  38. package/plugins/huaweicloud-core/dist/mcp-server.js +6560 -898
  39. package/plugins/huaweicloud-core/dist/mcp-server.js.map +4 -4
  40. package/plugins/huaweicloud-core/dist/mcp-stdio-transport.js +14 -4
  41. package/plugins/huaweicloud-core/dist/packs/auth/approval.js +249 -0
  42. package/plugins/huaweicloud-core/dist/packs/auth/tools.js +44 -44
  43. package/plugins/huaweicloud-core/dist/packs/huaweicloud-cli/tools.js +119 -112
  44. package/plugins/huaweicloud-core/dist/packs/obs/approval.js +110 -0
  45. package/plugins/huaweicloud-core/dist/packs/obs/tools.js +7 -2
  46. package/plugins/huaweicloud-core/dist/packs/registry.js +19 -1
  47. package/plugins/huaweicloud-core/dist/packs/sandbox/approval.js +245 -0
  48. package/plugins/huaweicloud-core/dist/packs/sandbox/handlers-account.js +156 -23
  49. package/plugins/huaweicloud-core/dist/packs/sandbox/handlers-credentials.js +13 -1
  50. package/plugins/huaweicloud-core/dist/packs/sandbox/handlers-hwexec.js +136 -0
  51. package/plugins/huaweicloud-core/dist/packs/sandbox/handlers-session.js +11 -1
  52. package/plugins/huaweicloud-core/dist/packs/sandbox/handlers-tunnel.js +1 -0
  53. package/plugins/huaweicloud-core/dist/packs/sandbox/schemas.js +79 -9
  54. package/plugins/huaweicloud-core/dist/packs/sandbox/tools.js +28 -9
  55. package/plugins/huaweicloud-core/dist/packs/secrets/approval.js +46 -0
  56. package/plugins/huaweicloud-core/dist/packs/secrets/tools.js +4 -1
  57. package/plugins/huaweicloud-core/dist/packs/update/approval.js +79 -0
  58. package/plugins/huaweicloud-core/dist/packs/update/tools.js +8 -1
  59. package/plugins/huaweicloud-core/dist/packs/voucher/tools.js +1 -1
  60. package/plugins/huaweicloud-core/dist/packs-configure.js +74 -0
  61. package/plugins/huaweicloud-core/dist/safety/classify-text.js +36 -0
  62. package/plugins/huaweicloud-core/dist/safety/policy.js +2 -0
  63. package/plugins/huaweicloud-core/dist/sandbox/deploy-check.js +1 -1
  64. package/plugins/huaweicloud-core/dist/sandbox/devbridge-auth.js +65 -14
  65. package/plugins/huaweicloud-core/dist/sandbox/devbridge-cleanup.js +422 -0
  66. package/plugins/huaweicloud-core/dist/sandbox/devbridge-expose-flow.js +66 -16
  67. package/plugins/huaweicloud-core/dist/sandbox/devbridge-expose.js +13 -10
  68. package/plugins/huaweicloud-core/dist/sandbox/devbridge-keepalive.js +42 -2
  69. package/plugins/huaweicloud-core/dist/sandbox/devbridge-key.js +11 -3
  70. package/plugins/huaweicloud-core/dist/sandbox/devbridge-tunnel.js +6 -0
  71. package/plugins/huaweicloud-core/dist/sandbox/devbridge-validation.js +10 -1
  72. package/plugins/huaweicloud-core/dist/sandbox/hwexec-task.js +244 -0
  73. package/plugins/huaweicloud-core/dist/setup-cli.js +42 -4
  74. package/plugins/huaweicloud-core/dist/tool-definitions.js +9 -1
  75. package/plugins/huaweicloud-core/dist/tool-schemas.js +32 -6
  76. package/plugins/huaweicloud-core/dist/tools.js +76 -9
  77. package/plugins/huaweicloud-core/dist/update-registry.js +358 -5
  78. package/plugins/huaweicloud-core/dist/update-upgrade.js +1083 -14
  79. package/plugins/huaweicloud-core/dist/vendor-gate.js +2 -2
  80. package/plugins/huaweicloud-core/hooks/huaweicloud-safety.mjs +150 -1
  81. package/plugins/huaweicloud-core/hooks/huaweicloud-safety.py +53 -3
  82. package/plugins/huaweicloud-core/openclaw.plugin.json +1 -1
  83. package/plugins/huaweicloud-core/safety/policy.json +18 -11
  84. package/plugins/huaweicloud-core/safety/rules/cloud-risk-rules.json +114 -10
  85. package/plugins/huaweicloud-core/skills/huawei-sandbox/SKILL.md +190 -138
  86. package/plugins/huaweicloud-core/skills/huawei-sandbox/references/resource-pool.md +36 -12
  87. package/plugins/huaweicloud-core/skills/huawei-voucher/SKILL.md +2 -0
  88. package/plugins/huaweicloud-core/skills/huaweicloud-cli-and-auth/SKILL.md +5 -5
  89. package/plugins/huaweicloud-core/skills/huaweicloud-safety/SKILL.md +13 -8
  90. package/plugins/huaweicloud-core/skills/huaweicloud-safety/references/approvals.md +78 -23
  91. package/plugins/huaweicloud-core/skills/huaweicloud-troubleshooting/SKILL.md +21 -19
  92. package/plugins/huaweicloud-core/src/agents/codex-config.ts +432 -0
  93. package/plugins/huaweicloud-core/src/agents/codex-desktop.ts +8 -1
  94. package/plugins/huaweicloud-core/src/agents/codex.ts +10 -0
  95. package/plugins/huaweicloud-core/src/agents/opencode-config.ts +198 -30
  96. package/plugins/huaweicloud-core/src/agents/opencode.ts +157 -1
  97. package/plugins/huaweicloud-core/src/approval-gate.ts +1306 -0
  98. package/plugins/huaweicloud-core/src/approval-ledger.ts +2446 -0
  99. package/plugins/huaweicloud-core/src/approval-roster.ts +127 -0
  100. package/plugins/huaweicloud-core/src/approval-types.ts +237 -0
  101. package/plugins/huaweicloud-core/src/approvals-cli.ts +4 -4
  102. package/plugins/huaweicloud-core/src/data/icons-manifest.v1.json +23 -5
  103. package/plugins/huaweicloud-core/src/dep/receipts.ts +84 -5
  104. package/plugins/huaweicloud-core/src/hcloud-cli.ts +3 -0
  105. package/plugins/huaweicloud-core/src/hcloud-plan.ts +93 -63
  106. package/plugins/huaweicloud-core/src/lib/approval-mode.ts +34 -0
  107. package/plugins/huaweicloud-core/src/lib/approval-tokens.ts +19 -4
  108. package/plugins/huaweicloud-core/src/lib/call-trace.ts +7 -17
  109. package/plugins/huaweicloud-core/src/lib/confirm-language.ts +51 -0
  110. package/plugins/huaweicloud-core/src/lib/credentials.ts +9 -8
  111. package/plugins/huaweicloud-core/src/lib/hdkit/hdkit-gate.ts +1428 -0
  112. package/plugins/huaweicloud-core/src/lib/hdkit/hdkitservice-api.ts +377 -30
  113. package/plugins/huaweicloud-core/src/lib/hdkit/sandbox-pool.ts +8 -15
  114. package/plugins/huaweicloud-core/src/lib/opencode-ask-rule.ts +350 -0
  115. package/plugins/huaweicloud-core/src/lib/opencode-saved-perms.ts +354 -0
  116. package/plugins/huaweicloud-core/src/lib/supplemental-redaction.ts +129 -0
  117. package/plugins/huaweicloud-core/src/lib/tool-schema-parts.ts +40 -0
  118. package/plugins/huaweicloud-core/src/lib/workspace-glob.ts +414 -0
  119. package/plugins/huaweicloud-core/src/mcp-config-io.ts +27 -1
  120. package/plugins/huaweicloud-core/src/mcp-protocol.ts +88 -5
  121. package/plugins/huaweicloud-core/src/mcp-server.ts +13 -0
  122. package/plugins/huaweicloud-core/src/mcp-stdio-transport.ts +14 -4
  123. package/plugins/huaweicloud-core/src/packs/auth/approval.ts +302 -0
  124. package/plugins/huaweicloud-core/src/packs/auth/tools.ts +54 -45
  125. package/plugins/huaweicloud-core/src/packs/huaweicloud-cli/tools.ts +139 -120
  126. package/plugins/huaweicloud-core/src/packs/obs/approval.ts +122 -0
  127. package/plugins/huaweicloud-core/src/packs/obs/tools.ts +7 -2
  128. package/plugins/huaweicloud-core/src/packs/registry.ts +42 -1
  129. package/plugins/huaweicloud-core/src/packs/sandbox/approval.ts +296 -0
  130. package/plugins/huaweicloud-core/src/packs/sandbox/handlers-account.ts +168 -23
  131. package/plugins/huaweicloud-core/src/packs/sandbox/handlers-credentials.ts +11 -1
  132. package/plugins/huaweicloud-core/src/packs/sandbox/handlers-hwexec.ts +228 -0
  133. package/plugins/huaweicloud-core/src/packs/sandbox/handlers-session.ts +11 -1
  134. package/plugins/huaweicloud-core/src/packs/sandbox/handlers-tunnel.ts +1 -0
  135. package/plugins/huaweicloud-core/src/packs/sandbox/schemas.ts +100 -8
  136. package/plugins/huaweicloud-core/src/packs/sandbox/tools.ts +31 -8
  137. package/plugins/huaweicloud-core/src/packs/secrets/approval.ts +50 -0
  138. package/plugins/huaweicloud-core/src/packs/secrets/tools.ts +4 -1
  139. package/plugins/huaweicloud-core/src/packs/update/approval.ts +87 -0
  140. package/plugins/huaweicloud-core/src/packs/update/tools.ts +8 -1
  141. package/plugins/huaweicloud-core/src/packs/voucher/tools.ts +1 -1
  142. package/plugins/huaweicloud-core/src/packs-configure.ts +75 -0
  143. package/plugins/huaweicloud-core/src/safety/classify-text.ts +40 -0
  144. package/plugins/huaweicloud-core/src/safety/policy.ts +7 -0
  145. package/plugins/huaweicloud-core/src/sandbox/deploy-check.ts +1 -1
  146. package/plugins/huaweicloud-core/src/sandbox/devbridge-auth.ts +74 -14
  147. package/plugins/huaweicloud-core/src/sandbox/devbridge-cleanup.ts +509 -0
  148. package/plugins/huaweicloud-core/src/sandbox/devbridge-expose-flow.ts +70 -18
  149. package/plugins/huaweicloud-core/src/sandbox/devbridge-expose.ts +26 -10
  150. package/plugins/huaweicloud-core/src/sandbox/devbridge-keepalive.ts +41 -2
  151. package/plugins/huaweicloud-core/src/sandbox/devbridge-key.ts +9 -3
  152. package/plugins/huaweicloud-core/src/sandbox/devbridge-tunnel.ts +24 -0
  153. package/plugins/huaweicloud-core/src/sandbox/devbridge-validation.ts +11 -1
  154. package/plugins/huaweicloud-core/src/sandbox/hwexec-task.ts +304 -0
  155. package/plugins/huaweicloud-core/src/setup-cli.ts +45 -3
  156. package/plugins/huaweicloud-core/src/tool-definitions.ts +9 -1
  157. package/plugins/huaweicloud-core/src/tool-schemas.ts +39 -6
  158. package/plugins/huaweicloud-core/src/tools.ts +124 -10
  159. package/plugins/huaweicloud-core/src/update-registry.ts +340 -5
  160. package/plugins/huaweicloud-core/src/update-upgrade.ts +1130 -14
  161. package/plugins/huaweicloud-core/src/vendor-gate.ts +2 -2
@@ -2,25 +2,45 @@
2
2
 
3
3
  # 两池沙箱资源池口径(v3,2026-11 定稿)
4
4
 
5
- > 权威实现:hdkitservice(pool_type 服务端权威解析 + 池感知复用 + 429 双错误码)+ 本插件 `sandbox-pool.ts`。
5
+ > 权威实现:hdkitservice(pool_type 服务端权威解析 + 池感知复用 + 429 三错误码)+ 本插件 `sandbox-pool.ts`。
6
6
  > 本文件是口径快照,与实现冲突时以最新实测为准(基调:一切以实测为准,口头支持不作数)。
7
7
  > 本版合并并取代 #1071 旧口径(非持久 3h 固定 / 持久 14 天保留 / 三信号 / 关机前通知均已作废)。
8
8
 
9
9
  ## 机制
10
10
 
11
11
  - **池 = 平台预置模板**:非持久 `9a108ab1bc354bc4979b949b36e3c8c1` / 持久 `05860f507ee94930844907a3a136d1a7` / flavor 3U6G `23ebdfe3b2d34cc4b34a1aaf03d27c54`(服务端 `POOL_TEMPLATE_*` 环境变量维护)
12
- - 客户端传 `pool_type`(ephemeral/persistent),**服务端权威映射** template_id;显式 `template_id` 优先(自定义模板)
13
- - **无 persist_mode 请求参数**(需求方两次纠正);闲置语义由平台按模板配置,上游参数面仅 name/template_id/flavor_id/source/env/git
12
+ - 客户端只传 `pool_type`(ephemeral/persistent),**服务端权威映射** template_id;template_id/自定义模板已下线
13
+ - **无 persist_mode 请求参数**;闲置语义由平台按模板配置;上游参数面有 template_id,但客户端不再传入
14
14
  - 实例名前缀即池归属:`hcdke*`(非持久)/ `hcdkp*`(持久);同池才复用。遗留 `hcdk*` 老实例不参与池复用(老模板后续可能无对应资源池,处置待定)
15
15
 
16
16
  ## 两类沙箱
17
17
 
18
- | 维度 | 非持久化 (ephemeral) | 持久化 (persistent) |
19
- | -------- | --------------------------------------- | --------------------------------------------------------------------- |
20
- | 定位 | 预览/试用/一次性任务/敏感即焚 | 开发工作台/带数据库项目/跨日评审展示 |
21
- | 生命周期 | 闲置 30min 自动关机 + 1h 删除(已实测) | 闲置 1h 自动关机(实例与数据保留);回收上限 7 天(资源组 DB 硬约束) |
22
- | 存储 | 无持久盘 | 挂 EVS 32G |
23
- | 配额 | 每用户 1 台(同类复用) | 每用户 1 台(同类复用;可与 1 台非持久并存) |
18
+ | 维度 | 非持久化 (ephemeral) | 持久化 (persistent) |
19
+ | -------- | ----------------------------------------------- | --------------------------------------------------------------------- |
20
+ | 定位 | 预览/试用/一次性任务/敏感即焚(含全栈/DB 预览) | 开发工作台/需要跨会话保留数据的项目/跨日评审展示 |
21
+ | 生命周期 | 闲置 30min 自动关机 + 1h 删除(已实测) | 闲置 1h 自动关机(实例与数据保留);回收上限 7 天(资源组 DB 硬约束) |
22
+ | 存储 | 无持久盘 | 挂 EVS 32G |
23
+ | 配额 | 每用户 1 台(同类复用) | 每用户 1 台(同类复用;可与 1 台非持久并存) |
24
+
25
+ ## 选型决策树(V1 dev,2026-11-12 定稿)
26
+
27
+ 默认 `ephemeral`;技术栈不是持久化触发器。
28
+
29
+ | 信号 | pool_type | 动作 |
30
+ | --------------------------------------- | ------------ | ---------------------------- |
31
+ | 预览 / demo / 一次性 / 敏感即焚 | `ephemeral` | 不问 |
32
+ | 全栈/DB 但只是预览/演示 | `ephemeral` | 不问,不因技术栈升级 |
33
+ | 明确长期 / 跨天 / 保留数据 / 开发工作台 | `persistent` | 不问 |
34
+ | 模型推断工作台/长期,但用户未明说 | `persistent` | 确认一次 |
35
+ | 意图不明确 | 先问 | 默认推荐 `ephemeral` |
36
+ | 同一任务/同一轮部署的后续操作 | 沿用当前池 | 不中途切换 |
37
+ | 新预览任务 + 已有 persistent | `ephemeral` | 必要时问一次是否复用现有环境 |
38
+ | 用户明确 override | 按用户 | 提示数据不跨池迁移 |
39
+
40
+ - `persistent` 只能来自**明确长期意图**,或**推断后确认**;不得仅因 full-stack/DB 选 persistent。
41
+ - 同一任务沿用当前池;新任务重新选型。新预览默认 `ephemeral`,即使已有 persistent。
42
+ - 新预览可能复用现有环境/数据时问一次:“已有持久化沙箱,是否直接复用(保留现有环境/数据),还是新建临时预览环境?”
43
+ - 切换池数据不迁移。
24
44
 
25
45
  ## 生命周期(实测口径)
26
46
 
@@ -50,8 +70,9 @@
50
70
  ## 配额与错误码
51
71
 
52
72
  - 每用户每类型 1 台(同类复用,ephemeral + persistent 可并存 1+1);账号并发上限 5
53
- - 429 双错误码(均带 `Retry-After: 60`):
73
+ - 429 三错误码(`HDKIT_QUOTA_EXCEEDED` / `HDKIT_CAPACITY_INSUFFICIENT` 带 `Retry-After: 60`;`HDKIT_TEMPLATE_QUOTA_EXCEEDED` 不带):
54
74
  - `HDKIT_QUOTA_EXCEEDED`:用户配额满(上游 `HD.98320022`)→ 重试无效,引导释放/复用已有实例
75
+ - `HDKIT_TEMPLATE_QUOTA_EXCEEDED`:当前账号此类型沙箱运行中实例达上限(上游 `HD.98320082`)→ 需关机/释放同类型实例后重试
55
76
  - `HDKIT_CAPACITY_INSUFFICIENT`:池容量不足(上游 `HD.99003001`/`HD.99008001`/`HD.98330021`)→ 服务端直接返回最终文案“DevKit 免费资源当前使用人数较多,建议您错峰使用,感谢理解!”,客户端原样透传不再附加引导
56
77
  - 烧核:`HD.97520422` = 账号核心时长耗尽(沙箱运行消耗核时;客户端对含该码的错误输出友好播报)
57
78
 
@@ -62,10 +83,13 @@
62
83
  ## 客户端行为(本插件)
63
84
 
64
85
  - `sandbox_connect` 传 `pool_type`;非法值本地即报错(不发无效请求);未传由服务端默认 ephemeral
86
+ - 选型由 skill 的 Pool-Selection Gate 决定;客户端只校验/透传 `pool_type`,不自行推断
65
87
  - 生命周期提示只在两个时机播报:connect(会话首次连接,或复用实例被唤醒 `started=true`)与 `expose_tunnel`(交付地址时,返回 `urlLifetimeHint` + `warnings`);其余 exec/upload/deploy 工具不逐次播报
66
88
  - connect 返回值富化 `pool` 块(数值取服务端回显,缺失时用默认口径);生命周期口径按 workspace 缓存到 `~/.config/huaweicloud/sandbox-pools.json`(0600,7 天过期),进程重启后仍可播报
67
- - 429:配额满给 `remediation` 引导;容量不足只透传服务端最终文案 + `retryAfter`
68
- - 钉扎(可选,运维场景):`HW_POOL_TEMPLATE_EPHEMERAL`/`HW_POOL_TEMPLATE_PERSISTENT` 环境变量——设置后客户端附带映射 template_id 上送;日常部署无需配置(模板 ID 由服务端权威维护)
89
+ - 429:配额满与模板配额满给 `remediation` 引导;容量不足只透传服务端最终文案 + `retryAfter`;模板配额不带 `retryAfter`
90
+ - persistent 生命周期提示追加核时提醒:**如暂时不需要使用,建议尽快关机,避免持续消耗核时;可以告诉我帮你关机(实例与数据盘保留,下次连接会自动唤醒)。** ephemeral 不出现该提示
91
+ - `sandbox_shutdown` 调 hdkitservice `POST /shutdown`(DevStation `close`,不 delete);仅开发者明确要求时调用;返回 `stopped` / `shutting_down` / `already_stopped` / `close_requested`。非持久化沙箱也可关机,但不主动提示
92
+ - 模板 ID 仅由服务端 `POOL_TEMPLATE_*` 权威维护;客户端不再支持 `HW_POOL_TEMPLATE_*` 钉扎或显式 template_id
69
93
 
70
94
  ## 平台侧关键依赖(G 清单,非 devkit 交付)
71
95
 
@@ -20,6 +20,7 @@ version: 5
20
20
  2. 按返回严格判定:
21
21
  - `claimed=true` → 静默处理,不再提及代金券,不打扰用户
22
22
  - `claimed=false` 且 `message="未领取"` → **主动提示**,用下方话术并询问是否领取
23
+ - `claimed=false` 且 `code=HDKIT_VERSION_TOO_OLD` → **客户端版本过旧**(不是未领取):转述 remediation 升级引导(npx --yes huaweicloud-devkit@latest update --target <agent>、重启会话,或调用 huaweicloud_upgrade),**绝不提示领券**
23
24
  - 返回含凭证错误码(`code=HDKIT_CRED_MISSING` / `HDKIT_CRED_INVALID` / `HDKIT_CRED_RATE_LIMIT`),或 `message` 含「未配置 / not configured / AK/SK 无效 / 限额」**且 code 不属于服务端配置错误**(`HDKIT_VOUCHER_*` / `HDKIT_COMPETITION_*` —— 这些是服务端问题,见下方表格,不是用户凭证问题)→ **提示用户检查或配置华为云凭证**(不要误报为「服务不可用」)
24
25
  - 其余情况(如 `message="查询失败"`、状态不明确、调用异常)→ **严格不提示**
25
26
  3. 提示话术(可直接使用):
@@ -36,6 +37,7 @@ version: 5
36
37
 
37
38
  - `claimed=true` + message 以「已领取」开头 → 已领取,告知结果即可,不再引导
38
39
  - `claimed=false` + `message="未领取"` → 未领取,可引导领取
40
+ - `claimed=false` + `code=HDKIT_VERSION_TOO_OLD` → 客户端版本过旧:转述升级 remediation,**绝不提示领券**(与上表判定规则同款)
39
41
 
40
42
  ### 2. 领取代金券
41
43
 
@@ -99,10 +99,10 @@ curl -sSL https://cn-north-4-hdn-koocli.obs.cn-north-4.myhuaweicloud.com/cli/lat
99
99
  - Read-only: `List*`, `Show*`, `Get*`, `Describe*`.
100
100
  - Write: `Create*`, `Delete*`, `Update*`, `Resize*`, `Start*`, `Stop*`, `Authorize*`, and similar.
101
101
  - Secret: any operation returning secret string, binary secret, token, or password.
102
- 9. For write operations, follow the terminal confirmation contract:
103
- - Call `huaweicloud_plan_cli_command` and read `userConfirmation`. When `needed` is true, show the user the command echo and the `userConfirmation.command` line.
104
- - The user runs `npx huaweicloud-devkit approve <approvalToken>` in their own terminal. Never run it yourself. First use: the user runs `npx huaweicloud-devkit pin` once in their own terminal to enroll the approvals PIN.
105
- - Then call `huaweicloud_run_approved_command` with that token. An unconfirmed non-read command is rejected with `USER_CONFIRMATION_REQUIRED`; the token stays usable, so retry the same call after the user confirms.
102
+ 9. For write operations, follow the approval contract:
103
+ - Call `huaweicloud_plan_cli_command` and read `userConfirmation`. When `needed` is true, show the user the command echo.
104
+ - Token mode (the default): show the `userConfirmation.command` line; the user runs `npx huaweicloud-devkit approve <approvalToken>` in their own terminal. Never run it yourself. First use: the user runs `npx huaweicloud-devkit pin` once in their own terminal to enroll the approvals PIN. Then call `huaweicloud_run_approved_command` with that token; an unconfirmed non-read command is rejected with `USER_CONFIRMATION_REQUIRED`, and the token stays usable, so retry the same call after the user confirms.
105
+ - Ask mode (`userConfirmation.mode` is `ask`): no terminal line and no token — call `huaweicloud_run_approved_command` with the same args (the `command` display field is recommended but optional: without it the confirmation shows the derived redacted line). The server runs the confirmation for every call shape: an elicitation-capable client renders a form during the call, and any other client answers with `ASK_CONFIRMATION_REQUIRED` (show the command in chat, then retry with `approvedByUser: true`).
106
106
 
107
107
  ## KooCLI Syntax Notes
108
108
 
@@ -153,7 +153,7 @@ Credentials are resolved in this order (highest priority first):
153
153
  | 5 | S1 global file (no session flag) | `auth init` permanent credentials | Permanent (S1) |
154
154
  | 6 | KooCLI profile | `~/.hcloud/config.json` (KooCLI commands only) | Permanent |
155
155
 
156
- When switching accounts within the same Agent session, use `huaweicloud_auth_init` to set runtime credentials (overrides all sources for the current MCP process), or `huaweicloud_auth_switch action=persist`, which writes S1 with `configuredBySession: true` so the session-configured account outranks `HW_ACCESS_KEY` / `HW_SECRET_KEY`. Note: running `auth init` clears the configuredBySession flag.
156
+ When switching accounts within the same Agent session, use `huaweicloud_auth_init` to set runtime credentials (overrides all sources for the current MCP process), or `huaweicloud_auth_switch action=persist`, which writes S1 with `configuredBySession: true` so the session-configured account outranks `HW_ACCESS_KEY` / `HW_SECRET_KEY`. Note: running `auth init` clears the configuredBySession flag. Both calls are approval-gated: the user must confirm the switch, and the confirmation view names the target account fingerprint and the credential source — in the default token mode confirm the returned approvalToken in your own terminal (`npx huaweicloud-devkit approve <token>`), and under `DEVKIT_APPROVAL_MODE=ask` the server raises the confirmation itself (an elicitation form, or the `ASK_CONFIRMATION_REQUIRED` chat round-trip whose retry carries `approvedByUser: true`).
157
157
 
158
158
  ## Global Services & domain-id
159
159
 
@@ -23,28 +23,33 @@ Use this skill before any Huawei Cloud action that may expose secrets, change re
23
23
  - IAM/security
24
24
  - cost/payment
25
25
  - public exposure
26
- 5. For any non-read-only operation, follow the plan, confirm, run contract: plan with `huaweicloud_plan_cli_command`, show the user the command and the terminal confirmation line, wait for the user to confirm in their own terminal, then run with `huaweicloud_run_approved_command`. See `references/approvals.md`.
26
+ 5. For any non-read-only operation, follow the plan, confirm, run contract: plan with `huaweicloud_plan_cli_command`, show the user the command, then run with `huaweicloud_run_approved_command`. The confirm step follows the plan's `userConfirmation`: by default (token mode) show the terminal confirmation line and wait for the user to run it in their own terminal; when `userConfirmation.mode` is `ask`, call the run tool and let the SERVER ask the user — a capable client raises a form during the call, and any other client answers with `ASK_CONFIRMATION_REQUIRED` so you can show the command in chat and retry with `approvedByUser: true`. See `references/approvals.md`. The same gate covers the registered non-CLI mutators (`huaweicloud_obs_set_website_config`, `huaweicloud_obs_set_cors`, `huaweicloud_upgrade`, `huaweicloud_secret_delete`, `huaweicloud_packs_configure`): call the tool and let the gate confirm — obs `action=get` runs unconfirmed as a signed read; the shell CLI twins (`update`/`upgrade`, `secret rm`, `packs enable/disable`) are hook-denied on the Bash face.
27
27
  6. Redact secrets from command output, errors, JSON, logs, and generated reports.
28
28
  7. If a command contains `adminPass`, `password`, token, or any secret-like field, warn that plaintext can remain in shell history. Prefer local-only input, runtime injection, or user-side execution.
29
29
 
30
30
  ## Enforcement Layers
31
31
 
32
- - Hooks: `hooks/huaweicloud-safety.mjs` blocks risky Codex native hook calls without requiring Python; `hooks/huaweicloud-safety.py` remains for Hermes/Python hook compatibility. The hook also denies the `approve` and `pin` verbs on the agent Bash face.
32
+ - Hooks: `hooks/huaweicloud-safety.mjs` blocks risky Codex native hook calls without requiring Python; `hooks/huaweicloud-safety.py` remains for Hermes/Python hook compatibility. The hook also denies the `approve`, `pin`, and account-switch (`auth init` / `auth sync`) verbs on the agent Bash face — those CLIs are the operator's own terminal surface, and the account switch is approval-gated on the MCP tools.
33
33
  - MCP wrapper: the Node MCP server applies the same safety policy for Codex/OpenCode paths that do not enforce hooks, and the run tool refuses a non-read command without the user's terminal confirmation.
34
34
  - Skills: this document teaches agents the rule before they act.
35
35
 
36
36
  ## Write Execution Boundary
37
37
 
38
- 1. Plan: call `huaweicloud_plan_cli_command`. The result echoes the exact command and carries `userConfirmation: { needed, command }`.
39
- 2. Confirm: when `needed` is true, show the user the plan echo and the `userConfirmation.command` line (`npx huaweicloud-devkit approve <approvalToken>`), then wait. The USER runs that line in their own terminal, where a TTY check and a PIN gate the confirmation. First use: the user runs `npx huaweicloud-devkit pin` once in their own terminal to enroll the PIN.
40
- 3. Run: call `huaweicloud_run_approved_command` with the same `approvalToken` and `approvedByUser: true`.
38
+ 1. Plan: call `huaweicloud_plan_cli_command`. The result echoes the exact command and carries `userConfirmation: { needed, command }` in the default token mode, or `userConfirmation: { needed, mode: "ask", note }` when the plan ran under `DEVKIT_APPROVAL_MODE=ask`.
39
+ 2. Confirm (token mode, the default): when `needed` is true, show the user the plan echo and the `userConfirmation.command` line (`npx huaweicloud-devkit approve <approvalToken>`), then wait. The USER runs that line in their own terminal, where a TTY check and a PIN gate the confirmation. First use: the user runs `npx huaweicloud-devkit pin` once in their own terminal to enroll the PIN.
40
+ 3. Confirm (ask mode): when `userConfirmation.mode` is `ask`, there is no terminal line and no token. The FIRST unattested call to `huaweicloud_run_approved_command` (same args, no `approvedByUser`; the `command` display field is recommended but optional) makes the server ask: an elicitation-capable client renders a form, and any other client returns `ASK_CONFIRMATION_REQUIRED`, whose envelope carries the command — show it to the user in chat, then retry that same call with `approvedByUser: true`. That retry is model-relayed posture trust, labeled as such, and its envelope stays live for the session's TTL, so further identical retries of the SAME command execute without re-asking. Different args get their own envelope first.
41
+ 4. Run: in token mode call `huaweicloud_run_approved_command` with the same `args`, the `command` field, the plan's `approvalToken`, and `approvedByUser: true`. In ask mode the run call IS the confirmation (step 3): withhold `approvedByUser: true` on the FIRST call so the server asks, and send it only on the retry after the user answered in chat.
41
42
 
42
- A non-read command without that terminal confirmation is rejected with `USER_CONFIRMATION_REQUIRED`. The refusal does not consume the token, so retry the same call after the user confirms. Re-running a write needs a fresh plan and a fresh confirmation.
43
+ In token mode, a non-read command without that terminal confirmation is rejected with `USER_CONFIRMATION_REQUIRED`. The refusal does not consume the token, so retry the same call after the user confirms. Re-running a write needs a fresh plan and a fresh confirmation. In ask mode there is no token to refuse or consume: a new command line asks the user first, and a declined, dismissed, or timed-out form refuses fail-closed. Once the user has approved a line, its envelope stays live for the session's TTL, so retrying that same line does not ask again.
43
44
 
44
- Never run the approve or pin commands yourself; the hook denies both verbs on the agent's Bash face. The `approvedByUser: true` argument is not the terminal confirmation and never replaces it.
45
+ Never run the approve or pin commands yourself; the hook denies both verbs on the agent's Bash face. The `approvedByUser: true` argument is not the terminal confirmation: in token mode the run tool still requires the terminal-confirmed grant, and in ask mode it is only the chat round-trip's retry marker, sent after the user answered (posture trust, which the server cannot verify).
45
46
 
46
47
  Without the devkit tools, show the reviewed command and let the user execute it in their own terminal. After a write, verify with `huaweicloud_run_readonly_command` or another read-only check.
47
48
 
49
+ ## Gate-source roster tools (no plan face)
50
+
51
+ Beyond the hcloud plan/run pair, other registered tools carry the same gate with NO plan step — the gate itself mints the approval token. Today that is the account-switch pair, `huaweicloud_auth_init` and `huaweicloud_auth_switch`: every call confirms, and the confirmation view names the target account fingerprint and the credential source, because switching accounts is the step that can redirect every later approved write. In the default token mode the first call returns `USER_CONFIRMATION_REQUIRED` with a minted `approvalToken`; the user confirms it in their own terminal (`npx huaweicloud-devkit approve <token>`) and you retry the same call with the token. Under ask mode the ladder is the same as for hcloud writes: the form on a capable client, the `ASK_CONFIRMATION_REQUIRED` chat round-trip on the rest. Never switch accounts through the devkit CLI instead (`npx huaweicloud-devkit auth init` from Bash is hook-denied); the gate's confirmation is the only agent-side path, and the account the user confirmed is the account that switches.
52
+
48
53
  ## Proactive Hook Checks
49
54
 
50
55
  Before executing, deploying, or handing generated cloud artifacts to the user, run the matching check when available:
@@ -64,6 +69,6 @@ Hook checks inspect the command or plan text that is available before execution.
64
69
  - Use redacted profile inspection instead of raw `hcloud configure show`.
65
70
  - Use runtime secret injection instead of fetching secret values into chat.
66
71
  - Use the encrypted secret vault for durable secrets: store values as `secret://<scope>/<name>` refs and pass refs, never values. See `references/secrets.md`.
67
- - Use the terminal confirmation contract for writes: plan, user confirm, run. See `references/approvals.md`.
72
+ - Use the approval contract for writes: plan, user confirm, run — token mode by default; under `DEVKIT_APPROVAL_MODE=ask` the server raises the confirmation itself (a form, or the chat round-trip when the client cannot render one). See `references/approvals.md`.
68
73
  - Use read-only verification after a write.
69
74
  - Prefer reviewed IaC for durable infrastructure changes.
@@ -1,47 +1,102 @@
1
1
  <!-- generated from src/packs/core/skills/huaweicloud-safety - do not edit -->
2
2
 
3
- # Terminal Confirmation For Write Commands
3
+ # The Approval Gate For Registered Tools
4
4
 
5
- A write or execution command runs only after the user confirms the plan token in their own interactive terminal. The agent plans, the user confirms, the agent runs. One confirmation covers exactly one execution.
5
+ A registered tool's mutating call runs only after the user confirms it. The confirmation channel is the server-run ladder: an elicitation form on a capable client, a chat round-trip envelope on the rest, or the terminal token in token mode. The agent never confirms anything itself; `approvedByUser: true` is only ever a statement or a retry marker, never the confirmation.
6
6
 
7
- ## The three-step contract
7
+ ## The registered tools today
8
8
 
9
- 1. Plan: call `huaweicloud_plan_cli_command` with the final hcloud arguments. The result echoes the exact command and carries `userConfirmation`.
10
- - `needed: true` means the command is a write or has execution side effects, and `command` is the exact line the user must run: `npx huaweicloud-devkit approve <approvalToken>`.
11
- - `needed: false` means the command is read-only, so the terminal confirmation does not apply.
12
- 2. Confirm: show the user the plan echo and the `userConfirmation.command` line, then wait. The user runs that line in their own terminal. The terminal prints the redacted command and states that this authorizes one execution.
13
- 3. Run: call `huaweicloud_run_approved_command` with the same `approvalToken`, the same `args`, and `approvedByUser: true`.
9
+ One per line, append-shaped: a sibling registration adds its tools here without touching the rest.
14
10
 
15
- An unconfirmed non-read command is rejected with `status: "rejected"` and `code: "USER_CONFIRMATION_REQUIRED"`, plus a `nextStep` naming the approve line. The refusal does not consume the token, so retry the same call after the user confirms.
11
+ - `huaweicloud_run_approved_command` — the hcloud pair's run face (the PR-1 registration)
12
+ - `huaweicloud_sandbox_connect`
13
+ - `huaweicloud_sandbox_exec_with_session`
14
+ - `huaweicloud_sandbox_exec_one_shot`
15
+ - `huaweicloud_sandbox_expose_tunnel`
16
+ - `huaweicloud_sandbox_renew_tunnel`
17
+ - `huaweicloud_sandbox_keepalive_watchdog`
18
+ - `huaweicloud_sandbox_sign_agreement`
19
+ - `huaweicloud_sandbox_credentials`
20
+ - `huaweicloud_sandbox_shutdown`
21
+ - `huaweicloud_auth_init`
22
+ - `huaweicloud_auth_switch`
23
+
24
+ ## The two gate flavors
25
+
26
+ - **Always.** The call confirms on every invocation — connect, shutdown, the tunnel faces, sign_agreement, credentials, and the hcloud run face's write-classified commands. No content rule ever exempts them.
27
+ - **Classified.** The two sandbox exec faces classify the `command` string first (the same engines the Bash safety face uses). A benign command runs with NO confirmation surface at all — no form, no envelope, no token. A write-classified command confirms on every call. The strict engine refuses some content with the rule named and no confirmation unlocks it — the families its rows cover: credential-file reads, environment dumps, recursive forced rm in any combined-flag spelling (`rm -rf`/`-fr`, flags interposed or after the target, `--`, quoted, glob, `$VAR`, dot-prefixed names, `.`, `..`, `~`, `$HOME`, `*`, `--no-preserve-root`), `find` with `-delete`, pipelines sweeping files into rm, downloads piped into a shell, disk format, and shutdown commands. The refusal set is those rows and nothing more: a command outside them is not silently stopped, so prefer targeted deletions (rm with exact file names, no combined -rf flag), and treat any refusal as a boundary to rework.
28
+
29
+ The same destructive rows also deny on the agent's own Bash face through the safety hook (the operator-approved widening): unanchored recursive rm — any combined-flag spelling, including `rm -rf node_modules` and the quoted/glob/`$VAR` forms — and `find … -delete` now refuse there too. The operator chose the safe direction: a false deny on the agent face costs one rephrased command, a miss costs the workspace. A human's own terminal is unaffected — the hook gates the agent face only.
30
+
31
+ ## Token mode (the default)
32
+
33
+ 1. Call the tool. A first no-token call returns `status: "rejected"`, `code: "USER_CONFIRMATION_REQUIRED"`, a minted `approvalToken`, and `userConfirmation.command` — the exact line the user must run in their own terminal: `npx huaweicloud-devkit approve <approvalToken>`. Nothing executed.
34
+ 2. The user confirms in their own interactive terminal (PIN-checked; first use enrolls the PIN via `npx huaweicloud-devkit pin`). The terminal prints the redacted request and states that this authorizes one execution.
35
+ 3. Retry the same call with the same `approvalToken` and `approvedByUser: true`. The confirmation authorizes one execution of one command.
36
+
37
+ - The token expires five minutes after minting. An expired token is refused; the call needs a fresh terminal confirmation, never a blind retry.
38
+ - A retry consumes the token. A repeat of the same token reports `outcome: "already_processed"`, never a second execution.
39
+ - Changing the arguments rejects the call — the token pins the exact arguments and any real secret values in it.
40
+
41
+ For the hcloud run face, `command` is the display anchor: the full hcloud command line, checked against the args array (a mismatch rejects with `COMMAND_ARGS_MISMATCH`, nothing executes). The plan result carries it as the TOP-LEVEL `command` field (the redacted echo; substitute real values wherever it shows `<redacted>`). The sandbox tools carry no anchor — their `command` field IS the content.
42
+
43
+ ## Registered tools beyond the hcloud pair
44
+
45
+ The same gate covers every tool on the approval roster, not only the hcloud plan/run pair. A roster tool with no plan face mints its own token at the gate: the first call in the default token mode returns `USER_CONFIRMATION_REQUIRED` with a fresh `approvalToken` and a `userConfirmation` summary naming what the call does — the user confirms that token the same way (`npx huaweicloud-devkit approve <token>`), and the retry carries the token. In ask mode the same ladder as above applies: the form, or the `ASK_CONFIRMATION_REQUIRED` chat round-trip.
46
+
47
+ The account-switch pair is registered (PR-3b): `huaweicloud_auth_init` and `huaweicloud_auth_switch` confirm on every call, and their confirmation views name the target account fingerprint and the credential source, because the account switch is the step that can redirect every later approved write to a different account. The confirmation binds the resolved snapshot — the account, region, and session token of the switch — so the account the user confirmed is the account that switches; a changed file or a changed region re-asks instead of executing. The devkit CLI verbs (`npx huaweicloud-devkit auth init`, `auth sync`) are the operator's own terminal surface: the hook denies them on the agent Bash face, so an agent cannot use the CLI to bypass the gate the MCP tools carry. `auth_confirm` (the persist-conflict reconciliation) and the read faces (`auth_status`, `check_account_type`, `auth_sync` on the MCP surface) stay ungated by this chain.
48
+
49
+ ## Ask mode (DEVKIT_APPROVAL_MODE=ask): the server-run confirmation
50
+
51
+ The confirmation happens on the server, in one of two tiers.
52
+
53
+ 1. **The form.** A client that declares the MCP elicitation form capability gets a form raised by the devkit during the tool call. The form shows the command line when there is one (the exec faces), else the redacted summary (the lifecycle faces), and ONE three-choice decision: `approve-once` (run it exactly once), `approve-session` (also grant standing consent for the exact same call in this session — identical later calls run without asking again, and the grant dies when the devkit server restarts), or `decline`. A dismissed form and a five-minute timeout cancel the same way. You do nothing for this tier: make the call and let the human answer. The form's display strings resolve through a three-tier language ladder: the operator's `DEVKIT_CONFIRM_LANG` env pin first, then the `confirmLanguage` argument you may relay — send the user's conversation language (`zh` or `en`) so a Chinese conversation gets a Chinese form; the server never sees the chat, so this argument is the only channel that carries the conversation's language — and the machine locale last. A zh resolution renders the message, the field title, and the choice labels in Simplified Chinese; the decision VALUES stay the English wire vocabulary (`decline`, `approve-once`, `approve-session`) in every language.
54
+ 2. **The chat round-trip.** A client with no form capability answers the call with `status: "rejected"` and `code: "ASK_CONFIRMATION_REQUIRED"`. The envelope carries the command or summary and the instruction: show it to the user in chat, wait for their explicit answer, then retry the same call with `approvedByUser: true`. That retry is posture trust: it is the user's word as you report it, with no mechanical proof a human answered. Never send the retry before the user answers, and never answer for them.
55
+
56
+ Every non-approval answer refuses fail-closed: a decline, a dismiss, the timeout, a transport failure, and an accept whose submitted content carries no valid decision value (a client that answers accept without answering the form schema it was shown — that shape gets its own code, `ELICITATION_INVALID_CONTENT`, so it is diagnosable from the refusal) all return a clean rejection (`ELICITATION_DECLINED`, `ELICITATION_CANCELLED`, `ELICITATION_TIMEOUT`, `ELICITATION_FAILED`, `ELICITATION_INVALID_CONTENT`) with nothing executed and nothing recorded. Do not retry a refused command without a fresh approval.
57
+
58
+ ## The retry memo (uncertain delivery)
59
+
60
+ When an approved call's delivery was uncertain — the call threw and whether it completed is unknowable — a byte-identical retry reuses the prior consent: no second form, no fresh envelope, no new approval. The response carries `approvedVia: "retry-uncertain"` so you can tell the reuse from a fresh confirmation. The memo is scoped to the result: after a delivered outcome it is cleared, so a confirmed consequence is never silently repeated — an identical retry then confirms again like any first call. A retry with different arguments is a different key and always confirms. The memo lives in the devkit server process and dies with it: after a restart the same command confirms again. A session standing-consent grant answers the same way with `approvedVia: "standing-session"` and the same restart boundary.
61
+
62
+ The consent ledger records which tier answered: `evidence: "elicitation"` for a form answer, `evidence: "posture"` for a chat-round-trip retry. A ledger row that says posture means a model reported the user's approval, not that a human was mechanically verified. A memo reuse inherits the original event's tier and never upgrades it.
63
+
64
+ On OpenCode the installer writes one exact `allow` rule per roster tool ahead of the server's own confirmation. That rule is yield-only: it suppresses the redundant client popup and never confirms anything — the form does on a form-capable client (opencode 2.x), and on 1.19–1.x the chat round-trip does, recorded as posture trust. A saved "always allow" row from a pre-yield install is likewise inert, because the server's confirmation is raised inside the tool call and never routes through the client's permission evaluation, and the yield rules mean the popup no longer appears to recreate one. `npx huaweicloud-devkit doctor` lists such rows as a stale-grant WARNING, with the `opencode api GET /api/permission/saved` and `opencode api DELETE /api/permission/saved/<id>` commands that remove them. Doctor also lists recorded session standing consents. A `deny` rule on a roster tool still blocks the call in the client, and doctor fails it. The remote transport refuses ask mode outright and forces token mode. Token mode remains the default and the fallback for harnesses without a per-call confirmation surface.
16
65
 
17
66
  ## The PIN and the TTY check
18
67
 
19
68
  The approve command refuses to record a confirmation unless stdin and stdout are both terminals. A pipe cannot answer a prompt, so an agent that shells out to Bash cannot drive the confirmation. A human at an interactive terminal can.
20
69
 
21
- First use is two steps, both in the user's own terminal: run `npx huaweicloud-devkit pin` once to choose an approvals PIN (at least 6 characters, typed twice), then confirm plans with `npx huaweicloud-devkit approve <approvalToken>`. The approve command refuses outright on a machine with no enrolled PIN instead of enrolling one inline. Every confirmation verifies the PIN with three attempts per invocation.
70
+ First use is two steps, both in the user's own terminal: run `npx huaweicloud-devkit pin` once to choose an approvals PIN (at least 6 characters, typed twice), then confirm with `npx huaweicloud-devkit approve <approvalToken>`. The approve command refuses outright on a machine with no enrolled PIN instead of enrolling one inline. Every confirmation verifies the PIN with three attempts per invocation.
22
71
 
23
72
  A wrong PIN also counts toward a persistent failure lockout: every sixth cumulative failure locks verification for 5 minutes, doubling per lockout episode and capped at 24 hours, and a correct PIN clears the counter. The failure lockout is guidance, not a boundary — a same-user process can edit the PIN record the same way it can edit any file under `~/.config/huaweicloud/`.
24
73
 
25
74
  The PIN record stores only a mac over the vault custody master key, never the plaintext. The PIN proves presence at the terminal. It does not prove the user read the command.
26
75
 
27
- ## One confirmation per execution
28
-
29
- The confirmation authorizes one execution of one command.
30
-
31
- - The plan token expires 5 minutes after the plan. An expired token is refused, and the agent must plan the command again.
32
- - A run consumes the token. A repeat run of the same token reports `outcome: "already_processed"`, never a second execution.
33
- - A run result's plan is minted without a token, so it never carries a usable approval. Re-running the command needs a fresh `huaweicloud_plan_cli_command` call and a fresh terminal confirmation.
34
- - Changing the arguments rejects the run, because the token pins the exact command hash and any real secret values in it.
35
-
36
76
  ## What the agent must not do
37
77
 
38
78
  - Never run `npx huaweicloud-devkit approve` or `npx huaweicloud-devkit pin` yourself, in any spelling. The confirmation's value is that the user's own terminal records it, and the safety hook denies both verbs on the agent Bash face for exactly that reason.
39
- - Never treat `approvedByUser: true` as the confirmation. It is the agent's statement that the user approved the exact command, and the run tool still requires the terminal-confirmed grant.
79
+ - Never run `npx huaweicloud-devkit auth init`, `auth sync`, or `auth reconcile` yourself, in any spelling. The account switch is approval-gated on the MCP tools, the CLI is the operator's own terminal surface, and the safety hook denies those verbs on the agent Bash face — shelling out to them would switch every later approved write's account with no confirmation.
80
+ - Never treat `approvedByUser: true` as the confirmation. In token mode it is the agent's statement that the user approved the exact call and the tool still requires the terminal-confirmed grant; in ask mode it is the chat round-trip's retry marker, sent only after the user answered, and it never substitutes for the form or the round-trip.
40
81
  - Never ask the user for their PIN, and never enter a PIN on the user's behalf.
41
- - Never retry a run with different arguments under the same token. Plan again and get a fresh confirmation.
82
+ - Never retry a call with different arguments under the same memo or token. The reuse covers the byte-identical call only; anything else confirms again.
83
+ - Always send `command` on the hcloud run face: the full command line, never a prettified or shortened one. The gate rejects a mismatch with the `args` instead of running it; the sandbox exec faces' `command` is content, not a display anchor, and the seven lifecycle faces carry no field at all.
84
+ - Never invent the user's answer to the chat round-trip. Wait for it, then retry with `approvedByUser: true` only after they approve.
85
+ - Never treat a strict-engine refusal as approval-shaped: the engine denies credential-file reads, environment dumps, and the destructive families its rows name (recursive forced rm in any combined-flag spelling — quoted, glob, `$VAR`, dot-prefixed, `--`, interposed-flag targets — plus `find` with `-delete`, pipelines sweeping files into rm, pipe-to-shell downloads, disk format, shutdown) before any confirmation surface exists, and no channel unlocks them. The refusal set is those rows and nothing more — a command outside them is your responsibility to keep targeted. Rework any refused command instead of retrying it.
42
86
 
43
87
  ## Honest security boundary
44
88
 
45
- The terminal confirmation defends: execution needs a user-recorded, PIN-checked grant made at an interactive terminal; the grant is a custody-keyed mac bound to the token, the confirmation time, and every stored field the run gate trusts (command hash, pin view, redacted form, secret-pinning flag, mint time), so a same-user edit of the state string or any trusted field does not verify; and a non-read command without a valid grant never runs.
89
+ The gate defends: execution needs a user-recorded confirmation — a PIN-checked terminal grant bound to the token and every stored field the run gate trusts (command hash, pin view, redacted form, mint time), or a server-raised form answer the client relayed, or an explicitly-labelled posture attestation whose line was shown first. The terminal grant is a custody-keyed mac, so a same-user edit of the state string or any trusted field does not verify; and a gated call without a valid confirmation never runs.
90
+
91
+ It does NOT defend against: a socially engineered user who approves a command they did not read (the form and terminal print the request, but neither proves comprehension); a same-user process that holds BOTH the custody master key and write access to `~/.config/huaweicloud/`, which can forge a grant for any pending token on the keyfile tier; a harness without the safety hook, where the TTY check is the only barrier and an agent driving a pseudo-terminal looks like a terminal; the hook's text gate missing variable-indirect verbs (`V=approve; npx huaweicloud-devkit $V` — the same indirection residual the shell shadow documents for the secret gate), where the agent reaches the CLI spelling through a shell variable; or a posture-tier retry, which trusts the model's report of the user's answer by design and is labelled as such on every surface that shows it. This is a consent gate, not an isolation boundary.
92
+
93
+ ## The registered non-CLI tools
94
+
95
+ The gate also covers tools that have no plan face and no executable line. Call the tool and let the gate confirm: the no-token call mints the token itself and returns `USER_CONFIRMATION_REQUIRED` with the same approve line; ask mode raises the form or the chat round-trip on the call. These tools take NO `command` field — their confirmation view is the summarized request (the gate rejects a fabricated command line outright), and the obs pair's summarize names the bucket and region, upgrade's names the channel and target, secret_delete's names the ref, packs_configure's names the pack ids.
96
+
97
+ - `huaweicloud_obs_set_website_config` / `huaweicloud_obs_set_cors` gate per classification: `action=get` is a signed read — it runs unconfirmed; `set` and `delete` are signed writes on a live bucket and confirm every call.
98
+ - `huaweicloud_upgrade` confirms every call and displays the channel ("latest") plus the target: the handler elects the stable or prerelease dist tag from the installed version after consent, so the consent pins the channel, not the resolved artifact.
99
+ - `huaweicloud_secret_delete` confirms every call, names the ref, and warns that deleting a ref S1 credentials point at breaks those reads until re-stored. `huaweicloud_secret_set` stays ungated: the user is the plaintext source.
100
+ - `huaweicloud_packs_configure` confirms every call in a stdio session and names the enabled or disabled pack ids; sessionless surfaces are refused outright with no token minted.
46
101
 
47
- It does NOT defend against: a socially engineered user who approves a command they did not read (the terminal prints the command, but the PIN proves presence, not comprehension); a same-user process that holds BOTH the custody master key and write access to `~/.config/huaweicloud/`, which can forge a grant for any pending token on the keyfile tier; a harness without the safety hook, where the TTY check is the only barrier and an agent driving a pseudo-terminal looks like a terminal; or the hook's text gate missing variable-indirect verbs (`V=approve; npx huaweicloud-devkit $V` — the same indirection residual the shell shadow documents for the secret gate), where the agent reaches the CLI spelling through a shell variable. This is a consent gate, not an isolation boundary.
102
+ `huaweicloud_setup_obs_config` stays ungated (it syncs credentials the user just configured). The devkit CLI twins of the gated mutations (`npx huaweicloud-devkit update|upgrade`, `secret rm`, `packs enable|disable|all`) are hook-denied on the agent Bash face — run the MCP tool instead, or let the user type the CLI line in their own terminal.
@@ -13,12 +13,13 @@ Use evidence before fixes. Do not guess service behavior when request IDs, regio
13
13
 
14
14
  ## Critical Warnings
15
15
 
16
- | Trap | Why |
17
- | --------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
18
- | Error in response body, not HTTP status | Many APIs return HTTP 200 with error in JSON body. Always check `error_code` and `error_msg` |
19
- | Missing `project_id` is common | New users often omit project_id from API path or CLI. Get it from `IAM KeystoneListProjects` |
20
- | Sandbox may block hcloud | OpenCode/Codex sandbox can block hcloud metadata files in `~/.hcloud/`. Use `dangerouslyDisableSandbox` or Bash tool |
21
- | KooCLI param prefix varies | VPC params need `--vpc.x`, ECS params need `--server.x`, ALWAYS check `--help` first |
16
+ | Trap | Why |
17
+ | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
18
+ | Error in response body, not HTTP status | Many APIs return HTTP 200 with error in JSON body. Always check `error_code` and `error_msg` |
19
+ | Missing `project_id` is common | New users often omit project_id from API path or CLI. Get it from `IAM KeystoneListProjects` |
20
+ | Sandbox may block hcloud | OpenCode/Codex sandbox can block hcloud metadata files in `~/.hcloud/`. Use `dangerouslyDisableSandbox` or Bash tool |
21
+ | `unsupported call` is not a cloud error | In Codex it means the harness dropped the tool-routing `namespace` field (custom OpenAI-compatible provider) — the call never reached the devkit or Huawei Cloud. Do not retry the identical call |
22
+ | KooCLI param prefix varies | VPC params need `--vpc.x`, ECS params need `--server.x`, ALWAYS check `--help` first |
22
23
 
23
24
  ## Workflow
24
25
 
@@ -52,19 +53,20 @@ Use evidence before fixes. Do not guess service behavior when request IDs, regio
52
53
 
53
54
  ## Common Error Codes
54
55
 
55
- | Error | Likely Cause | Fix |
56
- | --------------------------------------- | ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
57
- | AuthFailure / 401 | AK/SK invalid or expired | Regenerate AK/SK, re-run `npx huaweicloud-devkit auth init` |
58
- | AccessDenied / 403 | IAM permission missing | Check `huawei-iam` skill, add required policy action |
59
- | NoSuchKey / 404 | Resource not found | Verify resource ID, region, and project_id |
60
- | QuotaExceeded | Account limit reached | Request quota increase in console |
61
- | [USE_ERROR] 不正确的参数 | Wrong param name | Run `--help`, check `--param=value` format and nested prefix |
62
- | `[USE_ERROR]缺少必填参数 cli-domain-id` | Invalid/expired credentials — KooCLI's account-id lookup failed (APIGW.0301) | Re-run `npx huaweicloud-devkit auth init`; KooCLI auto-resolves domain-id once creds are valid |
63
- | Ecs.0005 | Flavor-image mismatch | Check image `__support_*` against flavor virtualization type |
64
- | FSS.0400 | FunctionGraph latest version error | Strip `:latest` from function URN |
65
- | FSS.1417 | DEDICATEDGATEWAY missing params | Add instance_id, group_id, protocol, env_name, env_id |
66
- | APIC.7201 | Missing security_group_id | Add `--security_group_id` param for APIG CreateInstanceV2 |
67
- | [NETWORK_ERROR] | Transient network failure | Retry with `maxRetries` param or wait and retry |
56
+ | Error | Likely Cause | Fix |
57
+ | ---------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
58
+ | AuthFailure / 401 | AK/SK invalid or expired | Regenerate AK/SK, re-run `npx huaweicloud-devkit auth init` |
59
+ | AccessDenied / 403 | IAM permission missing | Check `huawei-iam` skill, add required policy action |
60
+ | NoSuchKey / 404 | Resource not found | Verify resource ID, region, and project_id |
61
+ | QuotaExceeded | Account limit reached | Request quota increase in console |
62
+ | [USE_ERROR] 不正确的参数 | Wrong param name | Run `--help`, check `--param=value` format and nested prefix |
63
+ | `[USE_ERROR]缺少必填参数 cli-domain-id` | Invalid/expired credentials — KooCLI's account-id lookup failed (APIGW.0301) | Re-run `npx huaweicloud-devkit auth init`; KooCLI auto-resolves domain-id once creds are valid |
64
+ | Ecs.0005 | Flavor-image mismatch | Check image `__support_*` against flavor virtualization type |
65
+ | FSS.0400 | FunctionGraph latest version error | Strip `:latest` from function URN |
66
+ | FSS.1417 | DEDICATEDGATEWAY missing params | Add instance_id, group_id, protocol, env_name, env_id |
67
+ | APIC.7201 | Missing security_group_id | Add `--security_group_id` param for APIG CreateInstanceV2 |
68
+ | [NETWORK_ERROR] | Transient network failure | Retry with `maxRetries` param or wait and retry |
69
+ | `unsupported call: <huaweicloud tool>` (Codex) | Codex resolves MCP tools by the `namespace` field with no flat-name fallback; a custom OpenAI-compatible provider that drops it makes every call after the first fail this way (measured 2026-11-13, 690/692 calls; only a fresh session's first call dispatches) | Stop retrying — the call never reaches the devkit. Fix the gateway to round-trip `namespace` on function_call items, or use a provider that preserves it |
68
70
 
69
71
  ## KooCLI Error Types
70
72