huaweicloud-devkit 2.0.0-next.3 → 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 +141 -86
  13. package/plugins/huaweicloud-core/dist/agents/opencode.js +106 -39
  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 +62 -61
  23. package/plugins/huaweicloud-core/dist/lib/approval-mode.js +7 -5
  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 +224 -78
  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 +68 -16
  38. package/plugins/huaweicloud-core/dist/mcp-server.js +6506 -912
  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 +85 -130
  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 +36 -1
  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 +2 -2
  89. package/plugins/huaweicloud-core/skills/huaweicloud-safety/SKILL.md +11 -7
  90. package/plugins/huaweicloud-core/skills/huaweicloud-safety/references/approvals.md +74 -29
  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 +176 -88
  96. package/plugins/huaweicloud-core/src/agents/opencode.ts +125 -54
  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 +68 -70
  106. package/plugins/huaweicloud-core/src/lib/approval-mode.ts +7 -5
  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 +302 -83
  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 +81 -17
  121. package/plugins/huaweicloud-core/src/mcp-server.ts +7 -7
  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 +99 -137
  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 +39 -1
  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
@@ -1,5 +1,6 @@
1
1
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
2
  import { InMemoryTransport } from '@modelcontextprotocol/sdk/inMemory.js';
3
+ import { ErrorCode, McpError, } from '@modelcontextprotocol/sdk/types.js';
3
4
  import { TOOL_DEFINITIONS, callTool, verifySkillTree, SKILLS_ROOT, } from "./tools.js";
4
5
  import { PACK_OF } from "./packs/registry.js";
5
6
  import { resolveEnabledPacks } from "./packs/enable.js";
@@ -98,6 +99,21 @@ const VENDOR_BOUNDARY_RULE = 'Vendor boundary: tools or skills being available i
98
99
  "For a request that involves cloud resources but names no vendor, infer the vendor only from an explicit mention, hcloud/KooCLI artifacts, myhuaweicloud endpoints, Huawei region IDs, or earlier turns of this conversation — generic service vocabulary (ECS, VPC, RDS, serverless) and the devkit's own presence do not infer it. " +
99
100
  "When the vendor is still unknown, ask the user which cloud they mean before operating on cloud resources through any tool or hcloud command, and before probing Huawei Cloud tooling, credential, or account state (CLI install checks, profile reads, auth status). Cloud-facing tools enforce this with a vendorConfirmed parameter — pass the user's establishing words as its value, never an invented quote. " +
100
101
  "Requests that are not cloud tasks are outside this rule; tasks for other clouds remain answerable from general knowledge — the devkit's tools themselves only operate on Huawei Cloud. ";
102
+ // Harness tool-routing failure, shared by the stdio instruction forms (the
103
+ // remote face rides no harness model wire — see the remote return).
104
+ // Measured failure (2026-11-13, live codex 0.167.2 session + reproduced
105
+ // against the same provider): codex presents MCP tools as namespace-type
106
+ // tools and dispatches ONLY through the `namespace` field on function_call
107
+ // items, with no flat-name fallback; a custom OpenAI-compatible model
108
+ // gateway that drops that field (request history and/or generated calls)
109
+ // turns every regenerated call namespace-less, codex's registry
110
+ // (namespace, name) exact-match misses, and the harness answers
111
+ // `unsupported call: <tool>` — 690 of 692 huaweicloud calls in the dump,
112
+ // none ever reaching the devkit server, while the model retried the
113
+ // identical call in a spin. The devkit cannot observe or fix these
114
+ // calls; the only devkit-side lever is teaching the agent what the
115
+ // signature means so the spin stops after one reply.
116
+ const UNSUPPORTED_CALL_RULE = 'Tool-routing note: a reply "unsupported call: <tool>" naming a huaweicloud tool comes from your harness client, not from the devkit or Huawei Cloud — the call never reached this server, so retrying the identical call cannot succeed; report it to the user once and stop. ';
101
117
  export function instructionsFor(remote, runtimePacks = false) {
102
118
  if (remote) {
103
119
  return ('Skill loading: call huaweicloud_list_skills once for the effective skill catalog ' +
@@ -136,6 +152,7 @@ export function instructionsFor(remote, runtimePacks = false) {
136
152
  // directory, and the stdio instructions render on both.
137
153
  "Root disambiguation: huawei-* pack-owned service skills live only in this tree — on directory-loading agents, the native skills directory carrying the six huaweicloud-* meta-skill copies in your context is a different root, so never guess a service skill's path by analogy to it; the tree location stated above (skillRoot, the field a huaweicloud_list_skills payload carries) must be in hand before the first service-skill read, never fetched in parallel with a guessed one. " +
138
154
  VENDOR_BOUNDARY_RULE +
155
+ UNSUPPORTED_CALL_RULE +
139
156
  'Route Huawei Cloud tasks through the huaweicloud-core skill; browse packs with huaweicloud_list_packs.');
140
157
  }
141
158
  // 会话内首个非 check/upgrade 工具调用附加 _updateInfo,只消费一次。
@@ -216,13 +233,45 @@ export function normalizeToolCallParams(message) {
216
233
  }
217
234
  return message;
218
235
  }
236
+ // The server-run confirmation seam (PR-1.5). The SDK captures the client's
237
+ // initialize params on the per-session Server instance (that IS the session
238
+ // record), so `capable` reads the declared `elicitation.form` capability and
239
+ // never re-probes. The prompt raises a form-mode elicitation with an
240
+ // explicit timeout and resolves every failure as a decision: the gate
241
+ // refuses fail-closed instead of surfacing a transport error as the tool
242
+ // result. Never wired on the remote face (it forces token mode and must not
243
+ // elicit).
244
+ // The SDK's request-timeout code (-32001) as a plain number: the enum type
245
+ // has no shared member with the wire error's numeric code, so compare numbers.
246
+ const REQUEST_TIMEOUT_CODE = ErrorCode.RequestTimeout;
247
+ function createElicitationSeam(server) {
248
+ return {
249
+ get capable() {
250
+ return server.server.getClientCapabilities()?.elicitation?.form !== undefined;
251
+ },
252
+ async prompt({ message, schema, timeoutMs }) {
253
+ try {
254
+ const result = await server.server.elicitInput({ mode: 'form', message, requestedSchema: schema }, { timeout: timeoutMs });
255
+ return { decision: result.action, content: result.content };
256
+ }
257
+ catch (error) {
258
+ if (error instanceof McpError && error.code === REQUEST_TIMEOUT_CODE) {
259
+ return { decision: 'timeout', detail: error.message };
260
+ }
261
+ return { decision: 'error', detail: error instanceof Error ? error.message : String(error) };
262
+ }
263
+ },
264
+ };
265
+ }
219
266
  export function createDevkitMcpServer({ sessionId, runtimePacks = false, remoteSurface = false, } = {}) {
220
267
  assertConstructedSchemas();
221
268
  // The approval posture resolves once at construction: a bogus
222
269
  // DEVKIT_APPROVAL_MODE throws here (boot fail-fast, the same doctrine
223
- // DEVKIT_PACKS applies through syncDisclosure), and registerOne below is
224
- // the one place the mode changes the wire surface.
225
- const askMode = approvalModeFromEnv(process.env) === 'ask';
270
+ // DEVKIT_PACKS applies through syncDisclosure). The value itself is read
271
+ // per call by the gate, and it no longer changes the wire surface: the
272
+ // PR-1.5 flip removed the client interaction flag, because the server
273
+ // raises the confirmation now.
274
+ approvalModeFromEnv(process.env);
226
275
  // The contradictory construction is refused, not cautioned: a remote that
227
276
  // also carried runtime pack toggling would attach the onPacksChanged seam
228
277
  // to every callOpts, publishing the server host's absolute install path
@@ -279,20 +328,23 @@ export function createDevkitMcpServer({ sessionId, runtimePacks = false, remoteS
279
328
  registered.set(tool.name, server.registerTool(tool.name, {
280
329
  description: tool.description,
281
330
  inputSchema: getToolSchema(tool.name),
282
- // Ask mode only: Claude Code honors this flag by prompting the
283
- // user on every call of this tool — even in acceptEdits/auto/
284
- // bypassPermissions modes, with no "don't ask again" — and that
285
- // client prompt IS the user's confirmation the mode trusts.
286
- // Other clients ignore the flag. Declared only in ask mode so
287
- // token-mode Claude Code users don't gain a second prompt on top
288
- // of the terminal approve they already run.
289
- ...(askMode && tool.name === 'huaweicloud_run_approved_command'
290
- ? { _meta: { 'anthropic/requiresUserInteraction': true } }
291
- : {}),
331
+ // No client interaction flag (PR-1.5 flip). The confirmation runs
332
+ // on the server now: on an elicitation-capable client the gate
333
+ // raises its own form, and on the rest the T3 chat round-trip is
334
+ // the confirmation. A client dialog ahead of either would
335
+ // double-confirm (codex measured the two-interaction sequence:
336
+ // its own approval prompt, then the server form), so roster tools
337
+ // carry no `anthropic/requiresUserInteraction`. The machinery
338
+ // stays roster-driven where it lives: nothing here keys on the
339
+ // roster because the policy emits nothing for any tool.
292
340
  }, async (args) => {
293
- const callOpts = runtimePacks
294
- ? { sessionId, onPacksChanged: () => syncDisclosure() }
295
- : { sessionId };
341
+ // The server-run confirmation seam rides every stdio call; the
342
+ // remote face never wires it (ask mode is force-downgraded there).
343
+ const elicitation = remoteSurface ? undefined : createElicitationSeam(server);
344
+ const callOpts = {
345
+ ...(runtimePacks ? { sessionId, onPacksChanged: () => syncDisclosure() } : { sessionId }),
346
+ ...(elicitation ? { elicitation } : {}),
347
+ };
296
348
  const result = await callTool(tool.name, args, callOpts);
297
349
  const decorated = _decorateResult(sessionId, tool.name, result);
298
350
  return {