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
@@ -6,6 +6,9 @@ import {
6
6
  stripLeadingHcloudBinArgs,
7
7
  firstPlaceholderSecretArg,
8
8
  pinViewArgs,
9
+ needsUserConfirmation,
10
+ quoteShellArg,
11
+ hcloudExecutableLines,
9
12
  type HcloudRunResult,
10
13
  type HcloudRunOptions,
11
14
  } from '../../hcloud-cli.ts';
@@ -13,22 +16,33 @@ import { hcloudProbeNextStep, hcloudProbeRaw, probeHcloud, type ProbeHcloudOptio
13
16
  import { redactSecrets } from '../../safety-policy.ts';
14
17
  import { asText } from '../../lib/as-text.ts';
15
18
  import { approvalModeFromEnv, type ApprovalMode } from '../../lib/approval-mode.ts';
16
- import { consumeApprovalToken, hashArgs, inspectApprovalToken } from '../../lib/approval-tokens.ts';
17
- import { booleanArg, numericArg, stringArrayArg, vendorConfirmed } from '../../lib/tool-schema-parts.ts';
19
+ import { hashArgs } from '../../lib/approval-tokens.ts';
20
+ import {
21
+ approvalTokenArg,
22
+ approvedByUserArg,
23
+ booleanArg,
24
+ numericArg,
25
+ stringArrayArg,
26
+ vendorConfirmed,
27
+ } from '../../lib/tool-schema-parts.ts';
18
28
  import type { PackToolDefinition, LooseToolSchema } from '../../lib/pack-types.ts';
19
29
  import type { CallToolOptions, ToolArgs } from '../../tools.ts';
20
30
  import { asRecord } from '../../lib/as-record.ts';
31
+ import type { ApprovalSpec } from '../../approval-types.ts';
21
32
 
22
33
  // The seven KooCLI-coupled execution tools sunk from core (src/tools.ts):
23
- // version/profile inspection, plan/read-only/approved command execution,
24
- // operation discovery, and region listing. The consent layer is imported
25
- // directly from src/lib/approval-tokens.ts (the CLI face's consent module),
26
- // not the hcloud-cli.ts re-export shim. The approval posture resolves from
27
- // DEVKIT_APPROVAL_MODE (src/lib/approval-mode.ts): 'token' (default) keeps
28
- // the out-of-band terminal gate; 'ask' makes the harness client's own
29
- // permission prompt the user's confirmation, so the plan mints nothing and
30
- // the run needs no token. The only allowWrites:true call site
31
- // in the codebase (runApprovedCommand) lives here, so trimming this pack
34
+ // version/profile inspection, plan/readonly/approved command execution,
35
+ // operation discovery, and region listing. The consent layer lives in the
36
+ // dispatch-layer approval gate (src/approval-gate.ts) plus the token store
37
+ // (src/lib/approval-tokens.ts): the gate, driven by this pack's
38
+ // HUAWEICLOUD_CLI_APPROVAL_SPECS entry, owns the attestation check, the
39
+ // token lifecycle envelopes, the placeholder floor, and the args binding;
40
+ // the handler keeps the pure runHcloud execution. The approval posture
41
+ // resolves from DEVKIT_APPROVAL_MODE (src/lib/approval-mode.ts): 'token'
42
+ // (default) keeps the out-of-band terminal gate; 'ask' moves the
43
+ // confirmation onto the server-run gate (an elicitation form, or the T3
44
+ // chat round-trip), so the plan mints nothing and the run needs no token. The only allowWrites:true call
45
+ // sites in the codebase (the approved-run execution) live here, so trimming this pack
32
46
  // removes the CLI execution face and its approval tools together: a
33
47
  // configuration trimmed of this pack has no devkit-side hcloud CLI write
34
48
  // path, and the gateway face, when enabled, is a separate delegated write
@@ -237,134 +251,41 @@ function approvedRunOptions(args: ToolArgs): HcloudRunOptions {
237
251
  };
238
252
  }
239
253
 
240
- // Ask mode (DEVKIT_APPROVAL_MODE=ask): the harness client's permission
241
- // prompt on this very call is the user's confirmation, so there is no
242
- // token to inspect or consume. The safety floors are unchanged — the
243
- // placeholder-secret guard above, and runHcloud's assertAllowed
244
- // re-assertion of the strict classification (secret/credential/invalid
245
- // denies still throw; allowWrites:true stays scoped to this one call
246
- // site, the only one in the codebase).
247
- async function runApprovedCommandAskMode(args: ToolArgs): Promise<unknown> {
248
- const providedArgs = Array.isArray(args.args) ? args.args.map(String) : [];
249
- // Same normalization as the token path: the strict plan and the executed
250
- // argv must agree on the effective args.
251
- const { args: effectiveArgs } = stripLeadingHcloudBinArgs(providedArgs);
252
- assertNoPlaceholderSecret(effectiveArgs, 'ask');
254
+ // The wire form of the args the approval binds and the engine executes:
255
+ // hcloud ARGUMENTS ("excluding the hcloud executable" per the schema),
256
+ // which agents routinely paste anyway — one derivation shared by the
257
+ // handler and the pack's approval spec.
258
+ function providedStringArgs(args: ToolArgs): string[] {
259
+ return Array.isArray(args.args) ? args.args.map(String) : [];
260
+ }
261
+
262
+ // Both approval modes end in the same execution: derive the effective
263
+ // args, plan strictly (never minting — ask mode has no token face, and in
264
+ // token mode the gate has already consumed it), execute, and embed the
265
+ // plan. The dispatch-layer approval gate (src/approval-gate.ts) owns
266
+ // everything consent-shaped ahead of this point; runHcloud's assertAllowed
267
+ // re-assertion of the strict classification stays the execution floor
268
+ // (secret/credential/invalid denies still throw; allowWrites:true stays
269
+ // scoped to the approved-run call sites, the only ones in the codebase).
270
+ async function executeApproved(args: ToolArgs): Promise<unknown> {
271
+ const { args: effectiveArgs } = stripLeadingHcloudBinArgs(providedStringArgs(args));
253
272
  const strictPlan = planHcloudCommand(effectiveArgs, {
254
273
  allowWrites: false,
255
274
  mintApprovalToken: false,
256
- approvalMode: 'ask',
275
+ approvalMode: approvalModeFromEnv(process.env),
257
276
  });
258
277
  const result = await runHcloud(effectiveArgs, approvedRunOptions(args));
259
- // Spread instead of in-place mutation, mirroring the token path: the
260
- // HcloudRunResult shape stays owned by hcloud-cli.ts.
278
+ // Spread instead of in-place mutation: the HcloudRunResult shape stays
279
+ // owned by hcloud-cli.ts.
261
280
  return { ...result, approved: true, plan: strictPlan };
262
281
  }
263
282
 
264
283
  async function runApprovedCommand(args: ToolArgs = {}) {
265
- if (args.approvedByUser !== true) {
266
- throw new Error('approvedByUser must be true after explicit user approval for this exact command.');
267
- }
268
- const approvalMode = approvalModeFromEnv(process.env);
269
- if (approvalMode === 'ask') {
270
- return runApprovedCommandAskMode(args);
271
- }
272
- const token = String(args.approvalToken || '');
273
-
274
- // D4-24 precise JSON contract (#745): expired and already-consumed tokens
275
- // return a structured result instead of throwing a generic Error string, so
276
- // clients can machine-assert the two non-success states.
277
- const inspection = inspectApprovalToken(token);
278
- if (inspection.state === 'already_consumed') {
279
- return { status: 'ok', outcome: 'already_processed' };
280
- }
281
- if (inspection.state === 'expired') {
282
- return { status: 'rejected', code: 'CONFIRM_TOKEN_EXPIRED' };
283
- }
284
- if (inspection.state === 'not_found') {
285
- // A token that was never created (typo / unknown / pruned beyond the
286
- // tombstone window) is still a rejection, but carries no expired/already
287
- // semantics — surface a distinct code so clients can tell the cases apart.
288
- return { status: 'rejected', code: 'CONFIRM_TOKEN_NOT_FOUND' };
289
- }
290
-
291
- const providedArgs = Array.isArray(args.args) ? args.args.map(String) : [];
292
- // The token binds the plan's EFFECTIVE args (the plan strips a leading bin
293
- // token before minting), so the verify side normalizes the same way: a run
294
- // call that echoes the plan verbatim and one that sends the cleaned args
295
- // both hash to the stored value, while any real argument change still
296
- // rejects. Without this, a prefixed plan followed by a self-corrected run
297
- // burned the single-use token on a mismatch (2026-11-05 UX report #6, the
298
- // approval-trap probe).
299
- const { args: effectiveArgs } = stripLeadingHcloudBinArgs(providedArgs);
300
- // Placeholder guard before the consume: the shared helper's token-mode
301
- // wording keeps the guidance followable on the same approval.
302
- assertNoPlaceholderSecret(effectiveArgs, 'token');
303
-
304
- // The strict plan is pure, so it is computed before the token is consumed:
305
- // its userConfirmation.needed decides whether the consume requires a grant,
306
- // and the result still embeds it.
307
- const strictPlan = planHcloudCommand(effectiveArgs, { allowWrites: false, mintApprovalToken: false });
308
-
309
- // One snapshot: the confirmation gate, the args-hash binding, the pinView
310
- // fallback, and the single-use claim all read the SAME entry — the one
311
- // consumeApprovalToken returns. The pre-consume inspect-gate this replaces
312
- // verified the grant on one read while execution consumed another, which
313
- // a same-user store swap between the two reads laundered (the review's
314
- // TOCTOU repro).
315
- const consumed = consumeApprovalToken(token, { requireGrant: strictPlan.userConfirmation.needed });
316
- if (consumed.status === 'grant_required') {
317
- return {
318
- status: 'rejected',
319
- code: 'USER_CONFIRMATION_REQUIRED',
320
- nextStep:
321
- 'Ask the user to run "npx huaweicloud-devkit approve <this approvalToken>" in their own terminal, then retry this exact call.',
322
- };
323
- }
324
- if (consumed.status === 'gone') {
325
- // Defensive: inspectApprovalToken said 'valid' but consume returned gone.
326
- // The paths are the O_EXCL claim losing a race (another consumer is
327
- // spending this exact token right now) or a store swap removing the
328
- // entry between the two reads — classify via re-inspect, never a
329
- // misleading success and never a false not_found.
330
- const recheck = inspectApprovalToken(token);
331
- if (recheck.state === 'expired') return { status: 'rejected', code: 'CONFIRM_TOKEN_EXPIRED' };
332
- return { status: 'ok', outcome: 'already_processed' };
333
- }
334
- const stored = consumed.entry;
335
- if (hashArgs(effectiveArgs) !== stored.argsHash) {
336
- // The pin view is the canonical fold for the substitution comparison
337
- // (loop round 4, seat-1 B2): it folds the two-token/glued secret forms
338
- // the redactor never did, so following the placeholder guidance on a
339
- // two-token plan no longer dead-ends in a mismatch. Pre-schema entries
340
- // (no argsPinView) fall back to the redactor comparison.
341
- const storedView = JSON.stringify(stored.argsPinView ?? stored.argsRedacted);
342
- const providedView = JSON.stringify(pinViewArgs(effectiveArgs));
343
- if (storedView !== providedView) {
344
- throw new Error(
345
- 'Provided args do not match the approved plan. Use the exact args from the plan. ' +
346
- 'If the plan shows <redacted> for passwords or secrets, replace <redacted> with the actual values.',
347
- );
348
- }
349
- // Views equal means ONLY secret values differ. The plan carried real
350
- // (non-placeholder) secrets → they are pinned: a different real secret
351
- // rejects (loop round 2, the seat-2 A3 probe — a changed password used
352
- // to execute). A placeholder-bearing plan (secretsSubstitutable) keeps
353
- // the documented substitution flow.
354
- if (stored.secretsSubstitutable !== true) {
355
- // The message deliberately does not assert WHY the plan pinned: the
356
- // detector is key-shape heuristic, so the plan may have carried real
357
- // secrets, placeholder-adjacent values, or JSON-body forms where the
358
- // substitution contract is not reliable (loop round 9, seat-1 B1/B2).
359
- throw new Error(
360
- 'Secret values are pinned to the approved plan: re-run huaweicloud_plan_cli_command with the final values and re-approve.',
361
- );
362
- }
363
- }
364
- const result = await runHcloud(effectiveArgs, approvedRunOptions(args));
365
- // Spread instead of in-place mutation: identical serialized content, minus a
366
- // write to the HcloudRunResult shape owned by hcloud-cli.ts.
367
- return { ...result, approved: true, plan: strictPlan };
284
+ // The gate has already verified the approvedByUser attestation,
285
+ // classified the token lifecycle (an ask-mode call routes here with no
286
+ // token), enforced the placeholder-secret floor before any consume, and
287
+ // bound the provided args to the consumed entry's hash and pin view.
288
+ return executeApproved(args);
368
289
  }
369
290
 
370
291
  async function listRegions() {
@@ -458,7 +379,7 @@ const planCliCommandSchema = z.looseObject({
458
379
  });
459
380
  const runReadonlyCommandSchema = z.looseObject({
460
381
  vendorConfirmed,
461
- args: stringArrayArg,
382
+ args: stringArrayArg.describe('hcloud arguments, excluding the hcloud executable.'),
462
383
  timeoutMs: numericArg.optional().describe('Optional timeout in milliseconds. Defaults to 60000.'),
463
384
  maxRetries: numericArg.optional().describe('Optional retry count for transient network errors. Defaults to 1.'),
464
385
  cwd: z.string().optional().describe('Optional working directory for the hcloud process.'),
@@ -470,14 +391,17 @@ const listOperationsSchema = z.looseObject({
470
391
  });
471
392
  const runApprovedCommandSchema = z.looseObject({
472
393
  vendorConfirmed,
473
- args: stringArrayArg.describe('hcloud arguments, excluding the hcloud executable.'),
474
- approvalToken: z
394
+ command: z
475
395
  .string()
476
396
  .optional()
477
397
  .describe(
478
- 'Required in token-approval mode (from huaweicloud_plan_cli_command); omit in ask mode where the harness client confirms at run time.',
398
+ 'Always send this: the exact full hcloud command line this call executes, for example "hcloud ECS DeleteServer --server_id=i-123". The plan result\'s command field (huaweicloud_plan_cli_command) is the display line: copy it and substitute the real values wherever it shows <redacted>, or send the args array spelled out as one line. The confirmation body shows it as the first thing the user reads, and the server checks it equals the line the args array spells: a mismatch is rejected without executing anything. Only a legacy caller that predates this field omits it, and the field is optional in the schema so such a call still reaches the gate instead of dying in validation.',
479
399
  ),
480
- approvedByUser: booleanArg.describe('Must be true only after the user explicitly approves this exact command.'),
400
+ args: stringArrayArg.describe('hcloud arguments, excluding the hcloud executable.'),
401
+ approvalToken: approvalTokenArg.describe(
402
+ 'Required in token-approval mode (from huaweicloud_plan_cli_command); omit in ask mode, where the server-run gate confirms at run time.',
403
+ ),
404
+ approvedByUser: approvedByUserArg,
481
405
  timeoutMs: numericArg.optional().describe('Optional timeout in milliseconds. Defaults to 60000.'),
482
406
  maxRetries: numericArg.optional().describe('Optional retry count for transient network errors. Defaults to 1.'),
483
407
  cwd: z.string().optional().describe('Optional working directory for the hcloud process.'),
@@ -488,6 +412,44 @@ const showProfileRedactedSchema = z.looseObject({
488
412
  });
489
413
  const listRegionsSchema = z.looseObject({ vendorConfirmed });
490
414
 
415
+ // The pack's approval registration: the run face is plan-face tokenSource
416
+ // (the plan tool mints, the gate never does). normalizeArgs returns the
417
+ // binding value — the effective args after the leading-bin strip — so the
418
+ // gate's hash, pin view, and ledger record equal what the plan minted
419
+ // over. classify answers the consume's grant requirement with the same
420
+ // pure strict view the trunk's embedded plan computed (a read-classified
421
+ // command still executes on an unconfirmed token). The summarize view
422
+ // never leaks raw args: the plan face redacts, and the summary names the
423
+ // tool plus the redacted command echo.
424
+ export const HUAWEICLOUD_CLI_APPROVAL_SPECS: Readonly<Record<'huaweicloud_run_approved_command', ApprovalSpec>> = {
425
+ huaweicloud_run_approved_command: {
426
+ domain: 'cli',
427
+ flavor: 'always',
428
+ tokenSource: 'plan-face',
429
+ normalizeArgs: (args) => stripLeadingHcloudBinArgs(providedStringArgs(args)).args,
430
+ commandAnchor: (bindingValue) => hcloudExecutableLines(bindingValue as string[]),
431
+ classify: (bindingValue) => (needsUserConfirmation(bindingValue as string[]) ? 'required' : 'none'),
432
+ assertArgsExecutable: (bindingValue, mode) => assertNoPlaceholderSecret(bindingValue as string[], mode),
433
+ summarize: (bindingValue) => {
434
+ const effective = bindingValue as string[];
435
+ // Round 10, G1: the summary is built from the REDACTED pin view, not
436
+ // the raw argument stream — the ApprovalSpec contract ("never the raw
437
+ // argument stream — a popup must not leak secrets") must hold for the
438
+ // one field PR-3's USER_CONFIRMATION_REQUIRED envelope and PR-4's
439
+ // elicitation form spread verbatim. pinViewArgs is the same redaction
440
+ // vocabulary the pin view uses; an unredactable summary would leak
441
+ // exactly what the pin view hides.
442
+ const redactedLine = ['hcloud', ...pinViewArgs(effective)].map((arg) => quoteShellArg(arg)).join(' ');
443
+ return {
444
+ summary: `huaweicloud_run_approved_command: ${redactedLine.slice(0, 200)}`,
445
+ argsHash: hashArgs(effective),
446
+ pinView: pinViewArgs(effective),
447
+ command: redactedLine,
448
+ };
449
+ },
450
+ },
451
+ };
452
+
491
453
  export const HUAWEICLOUD_CLI_TOOLS = [
492
454
  {
493
455
  name: 'huaweicloud_check_cli',
@@ -499,7 +461,7 @@ export const HUAWEICLOUD_CLI_TOOLS = [
499
461
  {
500
462
  name: 'huaweicloud_plan_cli_command',
501
463
  description:
502
- "Classify and plan a Huawei Cloud hcloud command without executing it. When the result's userConfirmation.needed is true, the command waits on user confirmation before huaweicloud_run_approved_command will accept it: in the default token mode the USER runs the userConfirmation.command line (npx huaweicloud-devkit approve <approvalToken>) in their own terminal, and under DEVKIT_APPROVAL_MODE=ask the harness client itself prompts the user on the run call — no token is needed. Vendor-gated (vendorConfirmed): call only when the vendor is established — see the vendorConfirmed parameter description; when unknown, ask which cloud the user means first.",
464
+ "Classify and plan a Huawei Cloud hcloud command without executing it. When the result's userConfirmation.needed is true, the command waits on user confirmation before huaweicloud_run_approved_command will accept it: in the default token mode the USER runs the userConfirmation.command line (npx huaweicloud-devkit approve <approvalToken>) in their own terminal, and under DEVKIT_APPROVAL_MODE=ask the server raises the confirmation itself on the run call (an elicitation form, or an ASK_CONFIRMATION_REQUIRED chat round-trip) — no token is needed. Vendor-gated (vendorConfirmed): call only when the vendor is established — see the vendorConfirmed parameter description; when unknown, ask which cloud the user means first.",
503
465
  schema: planCliCommandSchema,
504
466
  handler: handlePlanCliCommand,
505
467
  },
@@ -520,7 +482,7 @@ export const HUAWEICLOUD_CLI_TOOLS = [
520
482
  {
521
483
  name: 'huaweicloud_run_approved_command',
522
484
  description:
523
- "Run a write-capable hcloud command only after the exact command has been shown and explicitly approved by the user. In the default token mode the user must also confirm the plan token in their own terminal (npx huaweicloud-devkit approve <token>) — a non-read command without that terminal confirmation is rejected with USER_CONFIRMATION_REQUIRED and the token stays usable. Under DEVKIT_APPROVAL_MODE=ask the harness client's permission prompt on this call is the confirmation: pass the same args with approvedByUser: true and no approvalToken. Vendor-gated (vendorConfirmed): call only when the vendor is established — see the vendorConfirmed parameter description; when unknown, ask which cloud the user means first.",
485
+ 'Run a write-capable hcloud command only after the exact command has been shown and explicitly approved by the user. In the default token mode the user must also confirm the plan token in their own terminal (npx huaweicloud-devkit approve <token>) — a non-read command without that terminal confirmation is rejected with USER_CONFIRMATION_REQUIRED and the token stays usable. Under DEVKIT_APPROVAL_MODE=ask the confirmation runs on the server: on a client that supports MCP elicitation the devkit raises a form during this call (approve runs it once; dismiss, decline, or the timeout cancels it), and on any other client the call returns ASK_CONFIRMATION_REQUIRED, whose envelope carries the command line — show it to the user in chat, then retry the same call with approvedByUser: true, which is model-relayed posture trust. In both modes always send command: it is the line the user reads, and the server rejects a line that does not match args (COMMAND_ARGS_MISMATCH). Vendor-gated (vendorConfirmed): call only when the vendor is established — see the vendorConfirmed parameter description; when unknown, ask which cloud the user means first.',
524
486
  schema: runApprovedCommandSchema,
525
487
  handler: handleRunApprovedCommand,
526
488
  },
@@ -0,0 +1,122 @@
1
+ import { hashArgs } from '../../lib/approval-tokens.ts';
2
+ import { redactSecrets } from '../../safety-policy.ts';
3
+ import type { ApprovalSpec, ClassifyVerdict } from '../../approval-types.ts';
4
+ import type { ToolArgs } from '../../tools.ts';
5
+
6
+ // The obs pack's approval registrations (PR-3c): both bucket-config tools
7
+ // are CLASSIFIED on their `action` argument — `get` is a signed read that
8
+ // must never confirm, while `set` and `delete` are signed PUT/DELETE on
9
+ // live buckets (the most exposed cloud writes in the inventory) and elicit
10
+ // or prompt-ask every call. classify-before-mint holds at the gate face:
11
+ // a read never mints, and a write never executes without the human.
12
+ // The binding value is the CONTENT projection of the args — action,
13
+ // bucket, region, and the config payload — never the gate fields
14
+ // (approvalToken/approvedByUser), so the hash the token binds is stable
15
+ // across the mint → approve → retry cycle. No commandAnchor and no
16
+ // summarize command: these tools sign REST calls internally, so there is
17
+ // no executable line to pin or display — the summarize view is the
18
+ // confirmation content, per the ApprovalSpec contract for tools whose
19
+ // args carry no command.
20
+ //
21
+ // setup_obs_config stays unregistered (the flagged boundary item): it
22
+ // syncs credentials the user just configured through the auth face, so
23
+ // the human is present by construction.
24
+
25
+ // The content fields of the website-config call, in the shape the handler
26
+ // reads. Undefined optional fields ride as undefined (dropped by the
27
+ // hash/pin-view serializations both times, so the projection is stable).
28
+ function websiteBinding(args: ToolArgs): Record<string, unknown> {
29
+ return {
30
+ action: args.action,
31
+ bucket: args.bucket,
32
+ region: args.region,
33
+ indexDocument: args.indexDocument,
34
+ errorDocument: args.errorDocument,
35
+ };
36
+ }
37
+
38
+ function corsBinding(args: ToolArgs): Record<string, unknown> {
39
+ return {
40
+ action: args.action,
41
+ bucket: args.bucket,
42
+ region: args.region,
43
+ rules: args.rules,
44
+ };
45
+ }
46
+
47
+ // Pure classification over the binding value: `get` is a signed read
48
+ // (none — no consent, no mint), everything else requires the human.
49
+ // An unknown action fails closed onto `required`; zod's enum rejects it
50
+ // before dispatch, so the branch is defensive only.
51
+ function classifyObsAction(value: unknown): ClassifyVerdict {
52
+ return (value as { action?: unknown }).action === 'get' ? 'none' : 'required';
53
+ }
54
+
55
+ // The set-preconditions the handlers themselves enforce, moved before the
56
+ // mint (NoDoomedToken: a malformed set call must not mint an approval it
57
+ // could never spend — the retry would need new args, hence a new hash,
58
+ // hence a fresh approval). Mirrors the handlers' own throw text.
59
+ function assertWebsiteExecutable(value: unknown): void {
60
+ const { action, indexDocument } = value as { action?: unknown; indexDocument?: unknown };
61
+ if (action === 'set' && (typeof indexDocument !== 'string' || indexDocument === '')) {
62
+ throw new Error('indexDocument is required for action=set.');
63
+ }
64
+ }
65
+
66
+ function assertCorsExecutable(value: unknown): void {
67
+ const { action, rules } = value as { action?: unknown; rules?: unknown };
68
+ if (action === 'set' && (!Array.isArray(rules) || rules.length === 0)) {
69
+ throw new Error('rules array is required for action=set (allowedOrigin + allowedMethod, HEAD included).');
70
+ }
71
+ }
72
+
73
+ // The summarize contract (approval-types.ts): the view is the REDACTED
74
+ // popup projection — never the raw argument stream. The whole binding
75
+ // folds through the shared redaction vocabulary (safety/redact.ts via the
76
+ // safety-policy face) before any field reaches the summary or the pin
77
+ // view, so a secret-shaped value riding any field is folded to
78
+ // <redacted>. The argsHash still binds the RAW content projection: the
79
+ // token pins what will actually execute, the view shows what the human
80
+ // may read.
81
+ function safeView(value: unknown): Record<string, unknown> {
82
+ return redactSecrets(value) as Record<string, unknown>;
83
+ }
84
+
85
+ export const OBS_APPROVAL_SPECS: Readonly<
86
+ Record<'huaweicloud_obs_set_website_config' | 'huaweicloud_obs_set_cors', ApprovalSpec>
87
+ > = {
88
+ huaweicloud_obs_set_website_config: {
89
+ domain: 'obs',
90
+ flavor: 'classified',
91
+ tokenSource: 'gate',
92
+ normalizeArgs: websiteBinding,
93
+ classify: classifyObsAction,
94
+ assertArgsExecutable: assertWebsiteExecutable,
95
+ summarize: (value) => {
96
+ const safe = safeView(value);
97
+ const index = safe.action === 'set' ? `, index ${String(safe.indexDocument)}` : '';
98
+ return {
99
+ summary: `huaweicloud_obs_set_website_config: ${String(safe.action)} website config on bucket ${String(safe.bucket)} (region ${String(safe.region)})${index}`,
100
+ argsHash: hashArgs(value),
101
+ pinView: safe,
102
+ };
103
+ },
104
+ },
105
+ huaweicloud_obs_set_cors: {
106
+ domain: 'obs',
107
+ flavor: 'classified',
108
+ tokenSource: 'gate',
109
+ normalizeArgs: corsBinding,
110
+ classify: classifyObsAction,
111
+ assertArgsExecutable: assertCorsExecutable,
112
+ summarize: (value) => {
113
+ const safe = safeView(value);
114
+ const count = safe.action === 'set' ? ` (${Array.isArray(safe.rules) ? safe.rules.length : 0} rule(s))` : '';
115
+ return {
116
+ summary: `huaweicloud_obs_set_cors: ${String(safe.action)} CORS rules${count} on bucket ${String(safe.bucket)} (region ${String(safe.region)})`,
117
+ argsHash: hashArgs(value),
118
+ pinView: safe,
119
+ };
120
+ },
121
+ },
122
+ };
@@ -10,6 +10,7 @@ import { fetchWithProxy } from '../../proxy/proxy-agent.ts';
10
10
  import { asCredentialRecord, type CredentialLike } from '../../lib/credentials.ts';
11
11
  import type { PackToolDefinition, LooseToolSchema } from '../../lib/pack-types.ts';
12
12
  import type { CallToolOptions, ToolArgs } from '../../tools.ts';
13
+ import { approvalTokenArg, approvedByUserArg } from '../../lib/tool-schema-parts.ts';
13
14
  import { asRecord } from '../../lib/as-record.ts';
14
15
 
15
16
  // Handlers migrated verbatim from src/tools.ts. setupObsConfig syncs the
@@ -411,12 +412,16 @@ const obsWebsiteConfigSchema = z.looseObject({
411
412
  region: z.string().describe('OBS 桶所在区域,如 cn-north-4'),
412
413
  indexDocument: z.string().optional().describe('首页文件名(action=set 时必填),如 index.html'),
413
414
  errorDocument: z.string().optional().describe('错误页面文件名(action=set 时可选),如 404.html 或 error.html'),
415
+ approvalToken: approvalTokenArg,
416
+ approvedByUser: approvedByUserArg,
414
417
  });
415
418
 
416
419
  const obsCorsConfigSchema = z.looseObject({
417
420
  action: z.enum(['set', 'get', 'delete']).describe('操作类型:set=配置 CORS 规则,get=查询当前规则,delete=删除规则'),
418
421
  bucket: z.string().describe('OBS 桶名称'),
419
422
  region: z.string().describe('OBS 桶所在区域,如 cn-north-4'),
423
+ approvalToken: approvalTokenArg,
424
+ approvedByUser: approvedByUserArg,
420
425
  rules: z
421
426
  .array(
422
427
  z.looseObject({
@@ -447,7 +452,7 @@ export const OBS_TOOLS = [
447
452
  {
448
453
  name: 'huaweicloud_obs_set_website_config',
449
454
  description:
450
- '配置 OBS 桶的静态网站托管(推荐路径:无需手写 XML,此工具内部实现 AWS4 签名调用 OBS REST API,屏蔽签名细节)。支持 set(配置)、get(查询)、delete(删除)三种操作。KooCLI 7.3.12+ 另有 `hcloud OBS website -method=put -localfile=<xml>`(XML 文件方式;7.2.x 无此 CLI 命令)。操作前需确保桶已创建且已设置 public-read ACL。',
455
+ '配置 OBS 桶的静态网站托管(推荐路径:无需手写 XML,此工具内部实现 AWS4 签名调用 OBS REST API,屏蔽签名细节)。支持 set(配置)、get(查询)、delete(删除)三种操作。审批门把关(PR-3c):set 与 delete 是对线上桶的签名 PUT/DELETE,无 token 调用返回 USER_CONFIRMATION_REQUIRED 供用户在终端确认,DEVKIT_APPROVAL_MODE=ask 时由服务器弹出确认;get 是签名只读,从不确认、直接执行。KooCLI 7.3.12+ 另有 `hcloud OBS website -method=put -localfile=<xml>`(XML 文件方式;7.2.x 无此 CLI 命令)。操作前需确保桶已创建且已设置 public-read ACL。',
451
456
  schema: obsWebsiteConfigSchema,
452
457
  handler: handleObsWebsiteConfig,
453
458
  },
@@ -460,7 +465,7 @@ export const OBS_TOOLS = [
460
465
  // the recommended path (no XML file, no --noproxy traps); the CLI is the
461
466
  // scripted alternative for 7.3.12+ environments.
462
467
  description:
463
- '配置 OBS 桶的 CORS 规则(浏览器直传前置条件;推荐路径:此工具内部实现 AWS4 签名调用 OBS REST API(PUT/GET/DELETE /?cors),无需手写 XML,屏蔽签名细节)。支持 set(配置)、get(查询)、delete(删除)三种操作。allowedMethod 必须含 HEAD(BrowserJS SDK 每次操作前发 HEAD ?apiversion 探测,缺 HEAD 时浏览器吞掉探测请求报 Network Error)。KooCLI 7.3.12+ 另有 `hcloud OBS cors obs://<bucket> -method=put -localfile=<xml>`(XML 文件方式;7.2.x 无此 CLI 命令)。配置成功后用返回体中的 verify 命令做 OPTIONS 预检验证(200 + Access-Control-Allow-Origin 才算成功)。',
468
+ '配置 OBS 桶的 CORS 规则(浏览器直传前置条件;推荐路径:此工具内部实现 AWS4 签名调用 OBS REST API(PUT/GET/DELETE /?cors),无需手写 XML,屏蔽签名细节)。支持 set(配置)、get(查询)、delete(删除)三种操作。审批门把关(PR-3c):set 与 delete 是对线上桶的签名 PUT/DELETE,无 token 调用返回 USER_CONFIRMATION_REQUIRED 供用户在终端确认,DEVKIT_APPROVAL_MODE=ask 时由服务器弹出确认;get 是签名只读,从不确认、直接执行。allowedMethod 必须含 HEAD(BrowserJS SDK 每次操作前发 HEAD ?apiversion 探测,缺 HEAD 时浏览器吞掉探测请求报 Network Error)。KooCLI 7.3.12+ 另有 `hcloud OBS cors obs://<bucket> -method=put -localfile=<xml>`(XML 文件方式;7.2.x 无此 CLI 命令)。配置成功后用返回体中的 verify 命令做 OPTIONS 预检验证(200 + Access-Control-Allow-Origin 才算成功)。',
464
469
  schema: obsCorsConfigSchema,
465
470
  handler: handleObsCorsConfig,
466
471
  },
@@ -16,8 +16,16 @@ import { OBS_TOOL_HANDLERS } from './obs/tools.ts';
16
16
  import { VOUCHER_TOOL_HANDLERS } from './voucher/tools.ts';
17
17
  import { DISCOVERY_TOOL_HANDLERS } from './discovery/tools.ts';
18
18
  import { HUAWEICLOUD_OPEN_MCP_TOOL_HANDLERS } from './huaweicloud-open-mcp/tools.ts';
19
- import { HUAWEICLOUD_CLI_TOOL_HANDLERS } from './huaweicloud-cli/tools.ts';
19
+ import { HUAWEICLOUD_CLI_TOOL_HANDLERS, HUAWEICLOUD_CLI_APPROVAL_SPECS } from './huaweicloud-cli/tools.ts';
20
+ import { SANDBOX_APPROVAL_SPECS } from './sandbox/approval.ts';
20
21
  import { SECRETS_TOOL_HANDLERS } from './secrets/tools.ts';
22
+ import { AUTH_APPROVAL_SPECS } from './auth/approval.ts';
23
+ import { OBS_APPROVAL_SPECS } from './obs/approval.ts';
24
+ import { UPDATE_APPROVAL_SPECS } from './update/approval.ts';
25
+ import { SECRETS_APPROVAL_SPECS } from './secrets/approval.ts';
26
+ import { PACKS_CONFIGURE_APPROVAL_SPEC } from '../packs-configure.ts';
27
+ import type { ApprovalSpec } from '../approval-types.ts';
28
+ import { APPROVAL_TOOLS } from '../approval-roster.ts';
21
29
 
22
30
  // PackId and the Pack interface live in src/lib/pack-types.ts alongside
23
31
  // PackToolDefinition, so packs and the registry share one vocabulary module.
@@ -59,6 +67,7 @@ export const PACK_OF = {
59
67
  huaweicloud_check_account_type: 'auth',
60
68
  huaweicloud_sandbox_exec_with_session: 'sandbox',
61
69
  huaweicloud_sandbox_exec_one_shot: 'sandbox',
70
+ huaweicloud_sandbox_exec_poll: 'sandbox',
62
71
  huaweicloud_sandbox_close_session: 'sandbox',
63
72
  huaweicloud_sandbox_upload_file: 'sandbox',
64
73
  huaweicloud_sandbox_upload_project: 'sandbox',
@@ -71,6 +80,7 @@ export const PACK_OF = {
71
80
  huaweicloud_sandbox_sign_agreement: 'sandbox',
72
81
  huaweicloud_sandbox_connect: 'sandbox',
73
82
  huaweicloud_sandbox_credentials: 'sandbox',
83
+ huaweicloud_sandbox_shutdown: 'sandbox',
74
84
  huaweicloud_voucher_status: 'voucher',
75
85
  huaweicloud_voucher_claim: 'voucher',
76
86
  huaweicloud_competition_voucher_claim: 'voucher',
@@ -122,6 +132,37 @@ export function isPackToolName(name: ToolName): name is PackToolName {
122
132
  return Object.hasOwn(PACK_TOOL_HANDLERS, name);
123
133
  }
124
134
 
135
+ // The per-pack approval specs merged once, keyed exactly by the roster
136
+ // (approval-roster.ts). The satisfies check closes the loop at compile
137
+ // time in ONE direction — for real, because the roster is a const tuple:
138
+ // a roster entry without a spec fails the Record's required keys, and a
139
+ // spec the roster does not carry fails the excess-property check — but
140
+ // ONLY for inline object literals. A spread merge (the shape PR-3 uses
141
+ // to add its per-pack spec tables, `{ ...A, ...B }`) introduces object
142
+ // types TypeScript does not excess-check (round 10, finding 2: a
143
+ // spread-in spec for an unrostered tool typechecked, silently gated, and
144
+ // recorded an ask-mode consent no popup ever showed — a spec-only
145
+ // registration is invisible to the hook exemption, _meta, and the
146
+ // ask-rule writers the roster drives). The runtime invariant in
147
+ // test/structure.test.ts (every APPROVAL_SPECS key must be a roster
148
+ // member) closes the spread direction: a pack spec whose tool the roster
149
+ // does not carry fails the battery loud. The dispatch-layer gate
150
+ // (src/approval-gate.ts, called from tools.ts after the vendor gate)
151
+ // resolves each call's spec from this table; the roster itself stays a
152
+ // plain string tuple so the .mjs hook and PR-2's opencode writer can
153
+ // import it without the registry graph.
154
+ export type ApprovalRosterName = (typeof APPROVAL_TOOLS)[number];
155
+
156
+ export const APPROVAL_SPECS = {
157
+ ...HUAWEICLOUD_CLI_APPROVAL_SPECS,
158
+ ...SANDBOX_APPROVAL_SPECS,
159
+ ...AUTH_APPROVAL_SPECS,
160
+ ...OBS_APPROVAL_SPECS,
161
+ ...UPDATE_APPROVAL_SPECS,
162
+ ...SECRETS_APPROVAL_SPECS,
163
+ huaweicloud_packs_configure: PACKS_CONFIGURE_APPROVAL_SPEC,
164
+ } satisfies Record<ApprovalRosterName, ApprovalSpec>;
165
+
125
166
  // Per-pack tool lists invert PACK_OF instead of hand-writing name lists, so a
126
167
  // pack can never claim an unassigned or non-existent tool.
127
168
  function toolsFor(id: PackId): ToolName[] {