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.
- package/README.md +3 -1
- package/package.json +3 -1
- package/plugins/huaweicloud-core/.claude-plugin/plugin.json +16 -3
- package/plugins/huaweicloud-core/.codex-plugin/plugin.json +16 -3
- package/plugins/huaweicloud-core/.cursor-plugin/plugin.json +16 -3
- package/plugins/huaweicloud-core/.hermes-plugin/plugin.json +16 -3
- package/plugins/huaweicloud-core/.mcp.json +55 -1
- package/plugins/huaweicloud-core/.workbuddy-plugin/plugin.json +16 -3
- package/plugins/huaweicloud-core/dist/agents/codex-config.js +374 -0
- package/plugins/huaweicloud-core/dist/agents/codex-desktop.js +8 -1
- package/plugins/huaweicloud-core/dist/agents/codex.js +9 -0
- package/plugins/huaweicloud-core/dist/agents/opencode-config.js +157 -31
- package/plugins/huaweicloud-core/dist/agents/opencode.js +129 -1
- package/plugins/huaweicloud-core/dist/approval-gate.js +1185 -0
- package/plugins/huaweicloud-core/dist/approval-ledger.js +2331 -0
- package/plugins/huaweicloud-core/dist/approval-roster.js +89 -0
- package/plugins/huaweicloud-core/dist/approval-types.js +1 -0
- package/plugins/huaweicloud-core/dist/approvals-cli.js +4 -4
- package/plugins/huaweicloud-core/dist/data/icons-manifest.v1.json +23 -5
- package/plugins/huaweicloud-core/dist/dep/receipts.js +65 -5
- package/plugins/huaweicloud-core/dist/hcloud-cli.js +1 -1
- package/plugins/huaweicloud-core/dist/hcloud-plan.js +77 -56
- package/plugins/huaweicloud-core/dist/lib/approval-mode.js +32 -0
- package/plugins/huaweicloud-core/dist/lib/approval-tokens.js +18 -4
- package/plugins/huaweicloud-core/dist/lib/call-trace.js +7 -14
- package/plugins/huaweicloud-core/dist/lib/confirm-language.js +50 -0
- package/plugins/huaweicloud-core/dist/lib/credentials.js +9 -9
- package/plugins/huaweicloud-core/dist/lib/hdkit/hdkit-gate.js +1398 -0
- package/plugins/huaweicloud-core/dist/lib/hdkit/hdkitservice-api.js +362 -32
- package/plugins/huaweicloud-core/dist/lib/hdkit/sandbox-pool.js +6 -16
- package/plugins/huaweicloud-core/dist/lib/opencode-ask-rule.js +262 -0
- package/plugins/huaweicloud-core/dist/lib/opencode-saved-perms.js +282 -0
- package/plugins/huaweicloud-core/dist/lib/supplemental-redaction.js +116 -0
- package/plugins/huaweicloud-core/dist/lib/tool-schema-parts.js +31 -0
- package/plugins/huaweicloud-core/dist/lib/workspace-glob.js +442 -0
- package/plugins/huaweicloud-core/dist/mcp-config-io.js +28 -1
- package/plugins/huaweicloud-core/dist/mcp-protocol.js +75 -4
- package/plugins/huaweicloud-core/dist/mcp-server.js +6560 -898
- package/plugins/huaweicloud-core/dist/mcp-server.js.map +4 -4
- package/plugins/huaweicloud-core/dist/mcp-stdio-transport.js +14 -4
- package/plugins/huaweicloud-core/dist/packs/auth/approval.js +249 -0
- package/plugins/huaweicloud-core/dist/packs/auth/tools.js +44 -44
- package/plugins/huaweicloud-core/dist/packs/huaweicloud-cli/tools.js +119 -112
- package/plugins/huaweicloud-core/dist/packs/obs/approval.js +110 -0
- package/plugins/huaweicloud-core/dist/packs/obs/tools.js +7 -2
- package/plugins/huaweicloud-core/dist/packs/registry.js +19 -1
- package/plugins/huaweicloud-core/dist/packs/sandbox/approval.js +245 -0
- package/plugins/huaweicloud-core/dist/packs/sandbox/handlers-account.js +156 -23
- package/plugins/huaweicloud-core/dist/packs/sandbox/handlers-credentials.js +13 -1
- package/plugins/huaweicloud-core/dist/packs/sandbox/handlers-hwexec.js +136 -0
- package/plugins/huaweicloud-core/dist/packs/sandbox/handlers-session.js +11 -1
- package/plugins/huaweicloud-core/dist/packs/sandbox/handlers-tunnel.js +1 -0
- package/plugins/huaweicloud-core/dist/packs/sandbox/schemas.js +79 -9
- package/plugins/huaweicloud-core/dist/packs/sandbox/tools.js +28 -9
- package/plugins/huaweicloud-core/dist/packs/secrets/approval.js +46 -0
- package/plugins/huaweicloud-core/dist/packs/secrets/tools.js +4 -1
- package/plugins/huaweicloud-core/dist/packs/update/approval.js +79 -0
- package/plugins/huaweicloud-core/dist/packs/update/tools.js +8 -1
- package/plugins/huaweicloud-core/dist/packs/voucher/tools.js +1 -1
- package/plugins/huaweicloud-core/dist/packs-configure.js +74 -0
- package/plugins/huaweicloud-core/dist/safety/classify-text.js +36 -0
- package/plugins/huaweicloud-core/dist/safety/policy.js +2 -0
- package/plugins/huaweicloud-core/dist/sandbox/deploy-check.js +1 -1
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-auth.js +65 -14
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-cleanup.js +422 -0
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-expose-flow.js +66 -16
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-expose.js +13 -10
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-keepalive.js +42 -2
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-key.js +11 -3
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-tunnel.js +6 -0
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-validation.js +10 -1
- package/plugins/huaweicloud-core/dist/sandbox/hwexec-task.js +244 -0
- package/plugins/huaweicloud-core/dist/setup-cli.js +42 -4
- package/plugins/huaweicloud-core/dist/tool-definitions.js +9 -1
- package/plugins/huaweicloud-core/dist/tool-schemas.js +32 -6
- package/plugins/huaweicloud-core/dist/tools.js +76 -9
- package/plugins/huaweicloud-core/dist/update-registry.js +358 -5
- package/plugins/huaweicloud-core/dist/update-upgrade.js +1083 -14
- package/plugins/huaweicloud-core/dist/vendor-gate.js +2 -2
- package/plugins/huaweicloud-core/hooks/huaweicloud-safety.mjs +150 -1
- package/plugins/huaweicloud-core/hooks/huaweicloud-safety.py +53 -3
- package/plugins/huaweicloud-core/openclaw.plugin.json +1 -1
- package/plugins/huaweicloud-core/safety/policy.json +18 -11
- package/plugins/huaweicloud-core/safety/rules/cloud-risk-rules.json +114 -10
- package/plugins/huaweicloud-core/skills/huawei-sandbox/SKILL.md +190 -138
- package/plugins/huaweicloud-core/skills/huawei-sandbox/references/resource-pool.md +36 -12
- package/plugins/huaweicloud-core/skills/huawei-voucher/SKILL.md +2 -0
- package/plugins/huaweicloud-core/skills/huaweicloud-cli-and-auth/SKILL.md +5 -5
- package/plugins/huaweicloud-core/skills/huaweicloud-safety/SKILL.md +13 -8
- package/plugins/huaweicloud-core/skills/huaweicloud-safety/references/approvals.md +78 -23
- package/plugins/huaweicloud-core/skills/huaweicloud-troubleshooting/SKILL.md +21 -19
- package/plugins/huaweicloud-core/src/agents/codex-config.ts +432 -0
- package/plugins/huaweicloud-core/src/agents/codex-desktop.ts +8 -1
- package/plugins/huaweicloud-core/src/agents/codex.ts +10 -0
- package/plugins/huaweicloud-core/src/agents/opencode-config.ts +198 -30
- package/plugins/huaweicloud-core/src/agents/opencode.ts +157 -1
- package/plugins/huaweicloud-core/src/approval-gate.ts +1306 -0
- package/plugins/huaweicloud-core/src/approval-ledger.ts +2446 -0
- package/plugins/huaweicloud-core/src/approval-roster.ts +127 -0
- package/plugins/huaweicloud-core/src/approval-types.ts +237 -0
- package/plugins/huaweicloud-core/src/approvals-cli.ts +4 -4
- package/plugins/huaweicloud-core/src/data/icons-manifest.v1.json +23 -5
- package/plugins/huaweicloud-core/src/dep/receipts.ts +84 -5
- package/plugins/huaweicloud-core/src/hcloud-cli.ts +3 -0
- package/plugins/huaweicloud-core/src/hcloud-plan.ts +93 -63
- package/plugins/huaweicloud-core/src/lib/approval-mode.ts +34 -0
- package/plugins/huaweicloud-core/src/lib/approval-tokens.ts +19 -4
- package/plugins/huaweicloud-core/src/lib/call-trace.ts +7 -17
- package/plugins/huaweicloud-core/src/lib/confirm-language.ts +51 -0
- package/plugins/huaweicloud-core/src/lib/credentials.ts +9 -8
- package/plugins/huaweicloud-core/src/lib/hdkit/hdkit-gate.ts +1428 -0
- package/plugins/huaweicloud-core/src/lib/hdkit/hdkitservice-api.ts +377 -30
- package/plugins/huaweicloud-core/src/lib/hdkit/sandbox-pool.ts +8 -15
- package/plugins/huaweicloud-core/src/lib/opencode-ask-rule.ts +350 -0
- package/plugins/huaweicloud-core/src/lib/opencode-saved-perms.ts +354 -0
- package/plugins/huaweicloud-core/src/lib/supplemental-redaction.ts +129 -0
- package/plugins/huaweicloud-core/src/lib/tool-schema-parts.ts +40 -0
- package/plugins/huaweicloud-core/src/lib/workspace-glob.ts +414 -0
- package/plugins/huaweicloud-core/src/mcp-config-io.ts +27 -1
- package/plugins/huaweicloud-core/src/mcp-protocol.ts +88 -5
- package/plugins/huaweicloud-core/src/mcp-server.ts +13 -0
- package/plugins/huaweicloud-core/src/mcp-stdio-transport.ts +14 -4
- package/plugins/huaweicloud-core/src/packs/auth/approval.ts +302 -0
- package/plugins/huaweicloud-core/src/packs/auth/tools.ts +54 -45
- package/plugins/huaweicloud-core/src/packs/huaweicloud-cli/tools.ts +139 -120
- package/plugins/huaweicloud-core/src/packs/obs/approval.ts +122 -0
- package/plugins/huaweicloud-core/src/packs/obs/tools.ts +7 -2
- package/plugins/huaweicloud-core/src/packs/registry.ts +42 -1
- package/plugins/huaweicloud-core/src/packs/sandbox/approval.ts +296 -0
- package/plugins/huaweicloud-core/src/packs/sandbox/handlers-account.ts +168 -23
- package/plugins/huaweicloud-core/src/packs/sandbox/handlers-credentials.ts +11 -1
- package/plugins/huaweicloud-core/src/packs/sandbox/handlers-hwexec.ts +228 -0
- package/plugins/huaweicloud-core/src/packs/sandbox/handlers-session.ts +11 -1
- package/plugins/huaweicloud-core/src/packs/sandbox/handlers-tunnel.ts +1 -0
- package/plugins/huaweicloud-core/src/packs/sandbox/schemas.ts +100 -8
- package/plugins/huaweicloud-core/src/packs/sandbox/tools.ts +31 -8
- package/plugins/huaweicloud-core/src/packs/secrets/approval.ts +50 -0
- package/plugins/huaweicloud-core/src/packs/secrets/tools.ts +4 -1
- package/plugins/huaweicloud-core/src/packs/update/approval.ts +87 -0
- package/plugins/huaweicloud-core/src/packs/update/tools.ts +8 -1
- package/plugins/huaweicloud-core/src/packs/voucher/tools.ts +1 -1
- package/plugins/huaweicloud-core/src/packs-configure.ts +75 -0
- package/plugins/huaweicloud-core/src/safety/classify-text.ts +40 -0
- package/plugins/huaweicloud-core/src/safety/policy.ts +7 -0
- package/plugins/huaweicloud-core/src/sandbox/deploy-check.ts +1 -1
- package/plugins/huaweicloud-core/src/sandbox/devbridge-auth.ts +74 -14
- package/plugins/huaweicloud-core/src/sandbox/devbridge-cleanup.ts +509 -0
- package/plugins/huaweicloud-core/src/sandbox/devbridge-expose-flow.ts +70 -18
- package/plugins/huaweicloud-core/src/sandbox/devbridge-expose.ts +26 -10
- package/plugins/huaweicloud-core/src/sandbox/devbridge-keepalive.ts +41 -2
- package/plugins/huaweicloud-core/src/sandbox/devbridge-key.ts +9 -3
- package/plugins/huaweicloud-core/src/sandbox/devbridge-tunnel.ts +24 -0
- package/plugins/huaweicloud-core/src/sandbox/devbridge-validation.ts +11 -1
- package/plugins/huaweicloud-core/src/sandbox/hwexec-task.ts +304 -0
- package/plugins/huaweicloud-core/src/setup-cli.ts +45 -3
- package/plugins/huaweicloud-core/src/tool-definitions.ts +9 -1
- package/plugins/huaweicloud-core/src/tool-schemas.ts +39 -6
- package/plugins/huaweicloud-core/src/tools.ts +124 -10
- package/plugins/huaweicloud-core/src/update-registry.ts +340 -5
- package/plugins/huaweicloud-core/src/update-upgrade.ts +1130 -14
- package/plugins/huaweicloud-core/src/vendor-gate.ts +2 -2
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { runHcloud, planHcloudCommand, stripLeadingHcloudBinArgs, firstPlaceholderSecretArg, pinViewArgs, } from "../../hcloud-cli.js";
|
|
2
|
+
import { runHcloud, planHcloudCommand, stripLeadingHcloudBinArgs, firstPlaceholderSecretArg, pinViewArgs, needsUserConfirmation, quoteShellArg, hcloudExecutableLines, } from "../../hcloud-cli.js";
|
|
3
3
|
import { hcloudProbeNextStep, hcloudProbeRaw, probeHcloud } from "../../hcloud-probe.js";
|
|
4
4
|
import { redactSecrets } from "../../safety-policy.js";
|
|
5
5
|
import { asText } from "../../lib/as-text.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { approvalModeFromEnv } from "../../lib/approval-mode.js";
|
|
7
|
+
import { hashArgs } from "../../lib/approval-tokens.js";
|
|
8
|
+
import { approvalTokenArg, approvedByUserArg, booleanArg, numericArg, stringArrayArg, vendorConfirmed, } from "../../lib/tool-schema-parts.js";
|
|
8
9
|
import { asRecord } from "../../lib/as-record.js";
|
|
9
10
|
// The seven KooCLI-coupled execution tools sunk from core (src/tools.ts):
|
|
10
|
-
// version/profile inspection, plan/
|
|
11
|
-
// operation discovery, and region listing. The consent layer
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
11
|
+
// version/profile inspection, plan/readonly/approved command execution,
|
|
12
|
+
// operation discovery, and region listing. The consent layer lives in the
|
|
13
|
+
// dispatch-layer approval gate (src/approval-gate.ts) plus the token store
|
|
14
|
+
// (src/lib/approval-tokens.ts): the gate, driven by this pack's
|
|
15
|
+
// HUAWEICLOUD_CLI_APPROVAL_SPECS entry, owns the attestation check, the
|
|
16
|
+
// token lifecycle envelopes, the placeholder floor, and the args binding;
|
|
17
|
+
// the handler keeps the pure runHcloud execution. The approval posture
|
|
18
|
+
// resolves from DEVKIT_APPROVAL_MODE (src/lib/approval-mode.ts): 'token'
|
|
19
|
+
// (default) keeps the out-of-band terminal gate; 'ask' moves the
|
|
20
|
+
// confirmation onto the server-run gate (an elicitation form, or the T3
|
|
21
|
+
// chat round-trip), so the plan mints nothing and the run needs no token. The only allowWrites:true call
|
|
22
|
+
// sites in the codebase (the approved-run execution) live here, so trimming this pack
|
|
15
23
|
// removes the CLI execution face and its approval tools together: a
|
|
16
24
|
// configuration trimmed of this pack has no devkit-side hcloud CLI write
|
|
17
25
|
// path, and the gateway face, when enabled, is a separate delegated write
|
|
@@ -173,112 +181,67 @@ async function listOperations(service, options = {}) {
|
|
|
173
181
|
result,
|
|
174
182
|
};
|
|
175
183
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
}
|
|
197
|
-
const providedArgs = Array.isArray(args.args) ? args.args.map(String) : [];
|
|
198
|
-
// The token binds the plan's EFFECTIVE args (the plan strips a leading bin
|
|
199
|
-
// token before minting), so the verify side normalizes the same way: a run
|
|
200
|
-
// call that echoes the plan verbatim and one that sends the cleaned args
|
|
201
|
-
// both hash to the stored value, while any real argument change still
|
|
202
|
-
// rejects. Without this, a prefixed plan followed by a self-corrected run
|
|
203
|
-
// burned the single-use token on a mismatch (2026-11-05 UX report #6, the
|
|
204
|
-
// approval-trap probe).
|
|
205
|
-
const { args: effectiveArgs } = stripLeadingHcloudBinArgs(providedArgs);
|
|
206
|
-
// A placeholder-shaped secret VALUE at run time is never a real secret:
|
|
207
|
-
// executing a literal `<redacted>`/`<password>` as the password is always
|
|
208
|
-
// wrong. This guard runs BEFORE the token is consumed, so its own guidance
|
|
209
|
-
// (replace the value, then re-run) stays followable on the same approval
|
|
210
|
-
// (loop round 3, seat-1 B3: the guidance used to be a dead end — the
|
|
211
|
-
// rejection burned the only token).
|
|
212
|
-
const placeholderArg = firstPlaceholderSecretArg(effectiveArgs);
|
|
213
|
-
if (placeholderArg) {
|
|
214
|
-
throw new Error(`The argument "${placeholderArg}" still carries a placeholder secret value: replace <redacted> with the actual value the user approved, then re-run with the same approval token.`);
|
|
215
|
-
}
|
|
216
|
-
// The strict plan is pure, so it is computed before the token is consumed:
|
|
217
|
-
// its userConfirmation.needed decides whether the consume requires a grant,
|
|
218
|
-
// and the result still embeds it.
|
|
219
|
-
const strictPlan = planHcloudCommand(effectiveArgs, { allowWrites: false, mintApprovalToken: false });
|
|
220
|
-
// One snapshot: the confirmation gate, the args-hash binding, the pinView
|
|
221
|
-
// fallback, and the single-use claim all read the SAME entry — the one
|
|
222
|
-
// consumeApprovalToken returns. The pre-consume inspect-gate this replaces
|
|
223
|
-
// verified the grant on one read while execution consumed another, which
|
|
224
|
-
// a same-user store swap between the two reads laundered (the review's
|
|
225
|
-
// TOCTOU repro).
|
|
226
|
-
const consumed = consumeApprovalToken(token, { requireGrant: strictPlan.userConfirmation.needed });
|
|
227
|
-
if (consumed.status === 'grant_required') {
|
|
228
|
-
return {
|
|
229
|
-
status: 'rejected',
|
|
230
|
-
code: 'USER_CONFIRMATION_REQUIRED',
|
|
231
|
-
nextStep: 'Ask the user to run "npx huaweicloud-devkit approve <this approvalToken>" in their own terminal, then retry this exact call.',
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
if (consumed.status === 'gone') {
|
|
235
|
-
// Defensive: inspectApprovalToken said 'valid' but consume returned gone.
|
|
236
|
-
// The paths are the O_EXCL claim losing a race (another consumer is
|
|
237
|
-
// spending this exact token right now) or a store swap removing the
|
|
238
|
-
// entry between the two reads — classify via re-inspect, never a
|
|
239
|
-
// misleading success and never a false not_found.
|
|
240
|
-
const recheck = inspectApprovalToken(token);
|
|
241
|
-
if (recheck.state === 'expired')
|
|
242
|
-
return { status: 'rejected', code: 'CONFIRM_TOKEN_EXPIRED' };
|
|
243
|
-
return { status: 'ok', outcome: 'already_processed' };
|
|
244
|
-
}
|
|
245
|
-
const stored = consumed.entry;
|
|
246
|
-
if (hashArgs(effectiveArgs) !== stored.argsHash) {
|
|
247
|
-
// The pin view is the canonical fold for the substitution comparison
|
|
248
|
-
// (loop round 4, seat-1 B2): it folds the two-token/glued secret forms
|
|
249
|
-
// the redactor never did, so following the placeholder guidance on a
|
|
250
|
-
// two-token plan no longer dead-ends in a mismatch. Pre-schema entries
|
|
251
|
-
// (no argsPinView) fall back to the redactor comparison.
|
|
252
|
-
const storedView = JSON.stringify(stored.argsPinView ?? stored.argsRedacted);
|
|
253
|
-
const providedView = JSON.stringify(pinViewArgs(effectiveArgs));
|
|
254
|
-
if (storedView !== providedView) {
|
|
255
|
-
throw new Error('Provided args do not match the approved plan. Use the exact args from the plan. ' +
|
|
256
|
-
'If the plan shows <redacted> for passwords or secrets, replace <redacted> with the actual values.');
|
|
257
|
-
}
|
|
258
|
-
// Views equal means ONLY secret values differ. The plan carried real
|
|
259
|
-
// (non-placeholder) secrets → they are pinned: a different real secret
|
|
260
|
-
// rejects (loop round 2, the seat-2 A3 probe — a changed password used
|
|
261
|
-
// to execute). A placeholder-bearing plan (secretsSubstitutable) keeps
|
|
262
|
-
// the documented substitution flow.
|
|
263
|
-
if (stored.secretsSubstitutable !== true) {
|
|
264
|
-
// The message deliberately does not assert WHY the plan pinned: the
|
|
265
|
-
// detector is key-shape heuristic, so the plan may have carried real
|
|
266
|
-
// secrets, placeholder-adjacent values, or JSON-body forms where the
|
|
267
|
-
// substitution contract is not reliable (loop round 9, seat-1 B1/B2).
|
|
268
|
-
throw new Error('Secret values are pinned to the approved plan: re-run huaweicloud_plan_cli_command with the final values and re-approve.');
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
const result = await runHcloud(effectiveArgs, {
|
|
184
|
+
// A placeholder-shaped secret VALUE at run time is never a real secret in
|
|
185
|
+
// either approval mode: executing a literal `<redacted>`/`<password>` as
|
|
186
|
+
// the password is always wrong. The guard is shared so the two modes can
|
|
187
|
+
// never drift on detection; only the re-run wording is mode-aware — token
|
|
188
|
+
// mode keeps the guidance followable on the SAME approval (the guard runs
|
|
189
|
+
// before the token is consumed; loop round 3, seat-1 B3: the guidance used
|
|
190
|
+
// to be a dead end because the rejection burned the only token), while
|
|
191
|
+
// ask mode has no token to preserve and must not reference one.
|
|
192
|
+
function assertNoPlaceholderSecret(args, mode) {
|
|
193
|
+
const placeholderArg = firstPlaceholderSecretArg(args);
|
|
194
|
+
if (!placeholderArg)
|
|
195
|
+
return;
|
|
196
|
+
throw new Error(`The argument "${placeholderArg}" still carries a placeholder secret value: replace <redacted> with the actual value the user approved, ` +
|
|
197
|
+
(mode === 'ask' ? 'then re-run.' : 'then re-run with the same approval token.'));
|
|
198
|
+
}
|
|
199
|
+
// The run options both approval modes execute under: allowWrites stays
|
|
200
|
+
// scoped to this file's call sites (the only ones in the codebase), and
|
|
201
|
+
// the pass-through fields keep their names verbatim.
|
|
202
|
+
function approvedRunOptions(args) {
|
|
203
|
+
return {
|
|
272
204
|
allowWrites: true,
|
|
273
205
|
timeoutMs: args.timeoutMs,
|
|
274
206
|
maxRetries: args.maxRetries,
|
|
275
207
|
cwd: args.cwd,
|
|
276
208
|
stdin: args.stdin,
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
// The wire form of the args the approval binds and the engine executes:
|
|
212
|
+
// hcloud ARGUMENTS ("excluding the hcloud executable" per the schema),
|
|
213
|
+
// which agents routinely paste anyway — one derivation shared by the
|
|
214
|
+
// handler and the pack's approval spec.
|
|
215
|
+
function providedStringArgs(args) {
|
|
216
|
+
return Array.isArray(args.args) ? args.args.map(String) : [];
|
|
217
|
+
}
|
|
218
|
+
// Both approval modes end in the same execution: derive the effective
|
|
219
|
+
// args, plan strictly (never minting — ask mode has no token face, and in
|
|
220
|
+
// token mode the gate has already consumed it), execute, and embed the
|
|
221
|
+
// plan. The dispatch-layer approval gate (src/approval-gate.ts) owns
|
|
222
|
+
// everything consent-shaped ahead of this point; runHcloud's assertAllowed
|
|
223
|
+
// re-assertion of the strict classification stays the execution floor
|
|
224
|
+
// (secret/credential/invalid denies still throw; allowWrites:true stays
|
|
225
|
+
// scoped to the approved-run call sites, the only ones in the codebase).
|
|
226
|
+
async function executeApproved(args) {
|
|
227
|
+
const { args: effectiveArgs } = stripLeadingHcloudBinArgs(providedStringArgs(args));
|
|
228
|
+
const strictPlan = planHcloudCommand(effectiveArgs, {
|
|
229
|
+
allowWrites: false,
|
|
230
|
+
mintApprovalToken: false,
|
|
231
|
+
approvalMode: approvalModeFromEnv(process.env),
|
|
277
232
|
});
|
|
278
|
-
|
|
279
|
-
//
|
|
233
|
+
const result = await runHcloud(effectiveArgs, approvedRunOptions(args));
|
|
234
|
+
// Spread instead of in-place mutation: the HcloudRunResult shape stays
|
|
235
|
+
// owned by hcloud-cli.ts.
|
|
280
236
|
return { ...result, approved: true, plan: strictPlan };
|
|
281
237
|
}
|
|
238
|
+
async function runApprovedCommand(args = {}) {
|
|
239
|
+
// The gate has already verified the approvedByUser attestation,
|
|
240
|
+
// classified the token lifecycle (an ask-mode call routes here with no
|
|
241
|
+
// token), enforced the placeholder-secret floor before any consume, and
|
|
242
|
+
// bound the provided args to the consumed entry's hash and pin view.
|
|
243
|
+
return executeApproved(args);
|
|
244
|
+
}
|
|
282
245
|
async function listRegions() {
|
|
283
246
|
const result = await runHcloud(['IAM', 'KeystoneListRegions'], { timeoutMs: 30000, maxRetries: 0 }).catch((error) => ({
|
|
284
247
|
ok: false,
|
|
@@ -328,7 +291,10 @@ async function handleCheckCli(_args = {}, _opts = {}) {
|
|
|
328
291
|
return runVersionCheck();
|
|
329
292
|
}
|
|
330
293
|
async function handlePlanCliCommand(args = {}, _opts = {}) {
|
|
331
|
-
return planHcloudCommand(args.args || [], {
|
|
294
|
+
return planHcloudCommand(args.args || [], {
|
|
295
|
+
allowWrites: args.allowWrites === true,
|
|
296
|
+
approvalMode: approvalModeFromEnv(process.env),
|
|
297
|
+
});
|
|
332
298
|
}
|
|
333
299
|
async function handleRunReadonlyCommand(args = {}, _opts = {}) {
|
|
334
300
|
return runHcloud(args.args || [], {
|
|
@@ -358,7 +324,7 @@ const planCliCommandSchema = z.looseObject({
|
|
|
358
324
|
});
|
|
359
325
|
const runReadonlyCommandSchema = z.looseObject({
|
|
360
326
|
vendorConfirmed,
|
|
361
|
-
args: stringArrayArg,
|
|
327
|
+
args: stringArrayArg.describe('hcloud arguments, excluding the hcloud executable.'),
|
|
362
328
|
timeoutMs: numericArg.optional().describe('Optional timeout in milliseconds. Defaults to 60000.'),
|
|
363
329
|
maxRetries: numericArg.optional().describe('Optional retry count for transient network errors. Defaults to 1.'),
|
|
364
330
|
cwd: z.string().optional().describe('Optional working directory for the hcloud process.'),
|
|
@@ -370,9 +336,13 @@ const listOperationsSchema = z.looseObject({
|
|
|
370
336
|
});
|
|
371
337
|
const runApprovedCommandSchema = z.looseObject({
|
|
372
338
|
vendorConfirmed,
|
|
339
|
+
command: z
|
|
340
|
+
.string()
|
|
341
|
+
.optional()
|
|
342
|
+
.describe('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.'),
|
|
373
343
|
args: stringArrayArg.describe('hcloud arguments, excluding the hcloud executable.'),
|
|
374
|
-
approvalToken:
|
|
375
|
-
approvedByUser:
|
|
344
|
+
approvalToken: approvalTokenArg.describe('Required in token-approval mode (from huaweicloud_plan_cli_command); omit in ask mode, where the server-run gate confirms at run time.'),
|
|
345
|
+
approvedByUser: approvedByUserArg,
|
|
376
346
|
timeoutMs: numericArg.optional().describe('Optional timeout in milliseconds. Defaults to 60000.'),
|
|
377
347
|
maxRetries: numericArg.optional().describe('Optional retry count for transient network errors. Defaults to 1.'),
|
|
378
348
|
cwd: z.string().optional().describe('Optional working directory for the hcloud process.'),
|
|
@@ -382,6 +352,43 @@ const showProfileRedactedSchema = z.looseObject({
|
|
|
382
352
|
profile: z.string().optional().describe('Optional KooCLI profile name.'),
|
|
383
353
|
});
|
|
384
354
|
const listRegionsSchema = z.looseObject({ vendorConfirmed });
|
|
355
|
+
// The pack's approval registration: the run face is plan-face tokenSource
|
|
356
|
+
// (the plan tool mints, the gate never does). normalizeArgs returns the
|
|
357
|
+
// binding value — the effective args after the leading-bin strip — so the
|
|
358
|
+
// gate's hash, pin view, and ledger record equal what the plan minted
|
|
359
|
+
// over. classify answers the consume's grant requirement with the same
|
|
360
|
+
// pure strict view the trunk's embedded plan computed (a read-classified
|
|
361
|
+
// command still executes on an unconfirmed token). The summarize view
|
|
362
|
+
// never leaks raw args: the plan face redacts, and the summary names the
|
|
363
|
+
// tool plus the redacted command echo.
|
|
364
|
+
export const HUAWEICLOUD_CLI_APPROVAL_SPECS = {
|
|
365
|
+
huaweicloud_run_approved_command: {
|
|
366
|
+
domain: 'cli',
|
|
367
|
+
flavor: 'always',
|
|
368
|
+
tokenSource: 'plan-face',
|
|
369
|
+
normalizeArgs: (args) => stripLeadingHcloudBinArgs(providedStringArgs(args)).args,
|
|
370
|
+
commandAnchor: (bindingValue) => hcloudExecutableLines(bindingValue),
|
|
371
|
+
classify: (bindingValue) => (needsUserConfirmation(bindingValue) ? 'required' : 'none'),
|
|
372
|
+
assertArgsExecutable: (bindingValue, mode) => assertNoPlaceholderSecret(bindingValue, mode),
|
|
373
|
+
summarize: (bindingValue) => {
|
|
374
|
+
const effective = bindingValue;
|
|
375
|
+
// Round 10, G1: the summary is built from the REDACTED pin view, not
|
|
376
|
+
// the raw argument stream — the ApprovalSpec contract ("never the raw
|
|
377
|
+
// argument stream — a popup must not leak secrets") must hold for the
|
|
378
|
+
// one field PR-3's USER_CONFIRMATION_REQUIRED envelope and PR-4's
|
|
379
|
+
// elicitation form spread verbatim. pinViewArgs is the same redaction
|
|
380
|
+
// vocabulary the pin view uses; an unredactable summary would leak
|
|
381
|
+
// exactly what the pin view hides.
|
|
382
|
+
const redactedLine = ['hcloud', ...pinViewArgs(effective)].map((arg) => quoteShellArg(arg)).join(' ');
|
|
383
|
+
return {
|
|
384
|
+
summary: `huaweicloud_run_approved_command: ${redactedLine.slice(0, 200)}`,
|
|
385
|
+
argsHash: hashArgs(effective),
|
|
386
|
+
pinView: pinViewArgs(effective),
|
|
387
|
+
command: redactedLine,
|
|
388
|
+
};
|
|
389
|
+
},
|
|
390
|
+
},
|
|
391
|
+
};
|
|
385
392
|
export const HUAWEICLOUD_CLI_TOOLS = [
|
|
386
393
|
{
|
|
387
394
|
name: 'huaweicloud_check_cli',
|
|
@@ -391,7 +398,7 @@ export const HUAWEICLOUD_CLI_TOOLS = [
|
|
|
391
398
|
},
|
|
392
399
|
{
|
|
393
400
|
name: 'huaweicloud_plan_cli_command',
|
|
394
|
-
description: "Classify and plan a Huawei Cloud hcloud command without executing it. When the result's userConfirmation.needed is true, the
|
|
401
|
+
description: "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.",
|
|
395
402
|
schema: planCliCommandSchema,
|
|
396
403
|
handler: handlePlanCliCommand,
|
|
397
404
|
},
|
|
@@ -409,7 +416,7 @@ export const HUAWEICLOUD_CLI_TOOLS = [
|
|
|
409
416
|
},
|
|
410
417
|
{
|
|
411
418
|
name: 'huaweicloud_run_approved_command',
|
|
412
|
-
description: 'Run a write-capable hcloud command only after the exact command has been shown and explicitly approved by the user
|
|
419
|
+
description: '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.',
|
|
413
420
|
schema: runApprovedCommandSchema,
|
|
414
421
|
handler: handleRunApprovedCommand,
|
|
415
422
|
},
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { hashArgs } from "../../lib/approval-tokens.js";
|
|
2
|
+
import { redactSecrets } from "../../safety-policy.js";
|
|
3
|
+
// The obs pack's approval registrations (PR-3c): both bucket-config tools
|
|
4
|
+
// are CLASSIFIED on their `action` argument — `get` is a signed read that
|
|
5
|
+
// must never confirm, while `set` and `delete` are signed PUT/DELETE on
|
|
6
|
+
// live buckets (the most exposed cloud writes in the inventory) and elicit
|
|
7
|
+
// or prompt-ask every call. classify-before-mint holds at the gate face:
|
|
8
|
+
// a read never mints, and a write never executes without the human.
|
|
9
|
+
// The binding value is the CONTENT projection of the args — action,
|
|
10
|
+
// bucket, region, and the config payload — never the gate fields
|
|
11
|
+
// (approvalToken/approvedByUser), so the hash the token binds is stable
|
|
12
|
+
// across the mint → approve → retry cycle. No commandAnchor and no
|
|
13
|
+
// summarize command: these tools sign REST calls internally, so there is
|
|
14
|
+
// no executable line to pin or display — the summarize view is the
|
|
15
|
+
// confirmation content, per the ApprovalSpec contract for tools whose
|
|
16
|
+
// args carry no command.
|
|
17
|
+
//
|
|
18
|
+
// setup_obs_config stays unregistered (the flagged boundary item): it
|
|
19
|
+
// syncs credentials the user just configured through the auth face, so
|
|
20
|
+
// the human is present by construction.
|
|
21
|
+
// The content fields of the website-config call, in the shape the handler
|
|
22
|
+
// reads. Undefined optional fields ride as undefined (dropped by the
|
|
23
|
+
// hash/pin-view serializations both times, so the projection is stable).
|
|
24
|
+
function websiteBinding(args) {
|
|
25
|
+
return {
|
|
26
|
+
action: args.action,
|
|
27
|
+
bucket: args.bucket,
|
|
28
|
+
region: args.region,
|
|
29
|
+
indexDocument: args.indexDocument,
|
|
30
|
+
errorDocument: args.errorDocument,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function corsBinding(args) {
|
|
34
|
+
return {
|
|
35
|
+
action: args.action,
|
|
36
|
+
bucket: args.bucket,
|
|
37
|
+
region: args.region,
|
|
38
|
+
rules: args.rules,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
// Pure classification over the binding value: `get` is a signed read
|
|
42
|
+
// (none — no consent, no mint), everything else requires the human.
|
|
43
|
+
// An unknown action fails closed onto `required`; zod's enum rejects it
|
|
44
|
+
// before dispatch, so the branch is defensive only.
|
|
45
|
+
function classifyObsAction(value) {
|
|
46
|
+
return value.action === 'get' ? 'none' : 'required';
|
|
47
|
+
}
|
|
48
|
+
// The set-preconditions the handlers themselves enforce, moved before the
|
|
49
|
+
// mint (NoDoomedToken: a malformed set call must not mint an approval it
|
|
50
|
+
// could never spend — the retry would need new args, hence a new hash,
|
|
51
|
+
// hence a fresh approval). Mirrors the handlers' own throw text.
|
|
52
|
+
function assertWebsiteExecutable(value) {
|
|
53
|
+
const { action, indexDocument } = value;
|
|
54
|
+
if (action === 'set' && (typeof indexDocument !== 'string' || indexDocument === '')) {
|
|
55
|
+
throw new Error('indexDocument is required for action=set.');
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function assertCorsExecutable(value) {
|
|
59
|
+
const { action, rules } = value;
|
|
60
|
+
if (action === 'set' && (!Array.isArray(rules) || rules.length === 0)) {
|
|
61
|
+
throw new Error('rules array is required for action=set (allowedOrigin + allowedMethod, HEAD included).');
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// The summarize contract (approval-types.ts): the view is the REDACTED
|
|
65
|
+
// popup projection — never the raw argument stream. The whole binding
|
|
66
|
+
// folds through the shared redaction vocabulary (safety/redact.ts via the
|
|
67
|
+
// safety-policy face) before any field reaches the summary or the pin
|
|
68
|
+
// view, so a secret-shaped value riding any field is folded to
|
|
69
|
+
// <redacted>. The argsHash still binds the RAW content projection: the
|
|
70
|
+
// token pins what will actually execute, the view shows what the human
|
|
71
|
+
// may read.
|
|
72
|
+
function safeView(value) {
|
|
73
|
+
return redactSecrets(value);
|
|
74
|
+
}
|
|
75
|
+
export const OBS_APPROVAL_SPECS = {
|
|
76
|
+
huaweicloud_obs_set_website_config: {
|
|
77
|
+
domain: 'obs',
|
|
78
|
+
flavor: 'classified',
|
|
79
|
+
tokenSource: 'gate',
|
|
80
|
+
normalizeArgs: websiteBinding,
|
|
81
|
+
classify: classifyObsAction,
|
|
82
|
+
assertArgsExecutable: assertWebsiteExecutable,
|
|
83
|
+
summarize: (value) => {
|
|
84
|
+
const safe = safeView(value);
|
|
85
|
+
const index = safe.action === 'set' ? `, index ${String(safe.indexDocument)}` : '';
|
|
86
|
+
return {
|
|
87
|
+
summary: `huaweicloud_obs_set_website_config: ${String(safe.action)} website config on bucket ${String(safe.bucket)} (region ${String(safe.region)})${index}`,
|
|
88
|
+
argsHash: hashArgs(value),
|
|
89
|
+
pinView: safe,
|
|
90
|
+
};
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
huaweicloud_obs_set_cors: {
|
|
94
|
+
domain: 'obs',
|
|
95
|
+
flavor: 'classified',
|
|
96
|
+
tokenSource: 'gate',
|
|
97
|
+
normalizeArgs: corsBinding,
|
|
98
|
+
classify: classifyObsAction,
|
|
99
|
+
assertArgsExecutable: assertCorsExecutable,
|
|
100
|
+
summarize: (value) => {
|
|
101
|
+
const safe = safeView(value);
|
|
102
|
+
const count = safe.action === 'set' ? ` (${Array.isArray(safe.rules) ? safe.rules.length : 0} rule(s))` : '';
|
|
103
|
+
return {
|
|
104
|
+
summary: `huaweicloud_obs_set_cors: ${String(safe.action)} CORS rules${count} on bucket ${String(safe.bucket)} (region ${String(safe.region)})`,
|
|
105
|
+
argsHash: hashArgs(value),
|
|
106
|
+
pinView: safe,
|
|
107
|
+
};
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
};
|
|
@@ -7,6 +7,7 @@ import { readGlobalCredentialsStrict, writeObsConfig, resolveCredentialsWithRunt
|
|
|
7
7
|
import { runHcloud } from "../../hcloud-cli.js";
|
|
8
8
|
import { fetchWithProxy } from "../../proxy/proxy-agent.js";
|
|
9
9
|
import { asCredentialRecord } from "../../lib/credentials.js";
|
|
10
|
+
import { approvalTokenArg, approvedByUserArg } from "../../lib/tool-schema-parts.js";
|
|
10
11
|
import { asRecord } from "../../lib/as-record.js";
|
|
11
12
|
// Handlers migrated verbatim from src/tools.ts. setupObsConfig syncs the
|
|
12
13
|
// global credential vault (or the hcloud profile) into ~/.obsutilconfig;
|
|
@@ -361,11 +362,15 @@ const obsWebsiteConfigSchema = z.looseObject({
|
|
|
361
362
|
region: z.string().describe('OBS 桶所在区域,如 cn-north-4'),
|
|
362
363
|
indexDocument: z.string().optional().describe('首页文件名(action=set 时必填),如 index.html'),
|
|
363
364
|
errorDocument: z.string().optional().describe('错误页面文件名(action=set 时可选),如 404.html 或 error.html'),
|
|
365
|
+
approvalToken: approvalTokenArg,
|
|
366
|
+
approvedByUser: approvedByUserArg,
|
|
364
367
|
});
|
|
365
368
|
const obsCorsConfigSchema = z.looseObject({
|
|
366
369
|
action: z.enum(['set', 'get', 'delete']).describe('操作类型:set=配置 CORS 规则,get=查询当前规则,delete=删除规则'),
|
|
367
370
|
bucket: z.string().describe('OBS 桶名称'),
|
|
368
371
|
region: z.string().describe('OBS 桶所在区域,如 cn-north-4'),
|
|
372
|
+
approvalToken: approvalTokenArg,
|
|
373
|
+
approvedByUser: approvedByUserArg,
|
|
369
374
|
rules: z
|
|
370
375
|
.array(z.looseObject({
|
|
371
376
|
allowedOrigin: z.string().describe('允许的来源,如 https://your-app.example.com 或 *'),
|
|
@@ -390,7 +395,7 @@ export const OBS_TOOLS = [
|
|
|
390
395
|
},
|
|
391
396
|
{
|
|
392
397
|
name: 'huaweicloud_obs_set_website_config',
|
|
393
|
-
description: '配置 OBS 桶的静态网站托管(推荐路径:无需手写 XML,此工具内部实现 AWS4 签名调用 OBS REST API,屏蔽签名细节)。支持 set(配置)、get(查询)、delete
|
|
398
|
+
description: '配置 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。',
|
|
394
399
|
schema: obsWebsiteConfigSchema,
|
|
395
400
|
handler: handleObsWebsiteConfig,
|
|
396
401
|
},
|
|
@@ -402,7 +407,7 @@ export const OBS_TOOLS = [
|
|
|
402
407
|
// claimed the CLI lacks it, measured on its 7.2.x sandbox. The tool stays
|
|
403
408
|
// the recommended path (no XML file, no --noproxy traps); the CLI is the
|
|
404
409
|
// scripted alternative for 7.3.12+ environments.
|
|
405
|
-
description: '配置 OBS 桶的 CORS 规则(浏览器直传前置条件;推荐路径:此工具内部实现 AWS4 签名调用 OBS REST API(PUT/GET/DELETE /?cors),无需手写 XML,屏蔽签名细节)。支持 set(配置)、get(查询)、delete
|
|
410
|
+
description: '配置 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 才算成功)。',
|
|
406
411
|
schema: obsCorsConfigSchema,
|
|
407
412
|
handler: handleObsCorsConfig,
|
|
408
413
|
},
|
|
@@ -14,8 +14,15 @@ import { OBS_TOOL_HANDLERS } from "./obs/tools.js";
|
|
|
14
14
|
import { VOUCHER_TOOL_HANDLERS } from "./voucher/tools.js";
|
|
15
15
|
import { DISCOVERY_TOOL_HANDLERS } from "./discovery/tools.js";
|
|
16
16
|
import { HUAWEICLOUD_OPEN_MCP_TOOL_HANDLERS } from "./huaweicloud-open-mcp/tools.js";
|
|
17
|
-
import { HUAWEICLOUD_CLI_TOOL_HANDLERS } from "./huaweicloud-cli/tools.js";
|
|
17
|
+
import { HUAWEICLOUD_CLI_TOOL_HANDLERS, HUAWEICLOUD_CLI_APPROVAL_SPECS } from "./huaweicloud-cli/tools.js";
|
|
18
|
+
import { SANDBOX_APPROVAL_SPECS } from "./sandbox/approval.js";
|
|
18
19
|
import { SECRETS_TOOL_HANDLERS } from "./secrets/tools.js";
|
|
20
|
+
import { AUTH_APPROVAL_SPECS } from "./auth/approval.js";
|
|
21
|
+
import { OBS_APPROVAL_SPECS } from "./obs/approval.js";
|
|
22
|
+
import { UPDATE_APPROVAL_SPECS } from "./update/approval.js";
|
|
23
|
+
import { SECRETS_APPROVAL_SPECS } from "./secrets/approval.js";
|
|
24
|
+
import { PACKS_CONFIGURE_APPROVAL_SPEC } from "../packs-configure.js";
|
|
25
|
+
import { APPROVAL_TOOLS } from "../approval-roster.js";
|
|
19
26
|
// PackId and the Pack interface live in src/lib/pack-types.ts alongside
|
|
20
27
|
// PackToolDefinition, so packs and the registry share one vocabulary module.
|
|
21
28
|
// PACK_OF is the single source of truth for tool → pack ownership. The
|
|
@@ -55,6 +62,7 @@ export const PACK_OF = {
|
|
|
55
62
|
huaweicloud_check_account_type: 'auth',
|
|
56
63
|
huaweicloud_sandbox_exec_with_session: 'sandbox',
|
|
57
64
|
huaweicloud_sandbox_exec_one_shot: 'sandbox',
|
|
65
|
+
huaweicloud_sandbox_exec_poll: 'sandbox',
|
|
58
66
|
huaweicloud_sandbox_close_session: 'sandbox',
|
|
59
67
|
huaweicloud_sandbox_upload_file: 'sandbox',
|
|
60
68
|
huaweicloud_sandbox_upload_project: 'sandbox',
|
|
@@ -67,6 +75,7 @@ export const PACK_OF = {
|
|
|
67
75
|
huaweicloud_sandbox_sign_agreement: 'sandbox',
|
|
68
76
|
huaweicloud_sandbox_connect: 'sandbox',
|
|
69
77
|
huaweicloud_sandbox_credentials: 'sandbox',
|
|
78
|
+
huaweicloud_sandbox_shutdown: 'sandbox',
|
|
70
79
|
huaweicloud_voucher_status: 'voucher',
|
|
71
80
|
huaweicloud_voucher_claim: 'voucher',
|
|
72
81
|
huaweicloud_competition_voucher_claim: 'voucher',
|
|
@@ -105,6 +114,15 @@ export const PACK_TOOL_HANDLERS = {
|
|
|
105
114
|
export function isPackToolName(name) {
|
|
106
115
|
return Object.hasOwn(PACK_TOOL_HANDLERS, name);
|
|
107
116
|
}
|
|
117
|
+
export const APPROVAL_SPECS = {
|
|
118
|
+
...HUAWEICLOUD_CLI_APPROVAL_SPECS,
|
|
119
|
+
...SANDBOX_APPROVAL_SPECS,
|
|
120
|
+
...AUTH_APPROVAL_SPECS,
|
|
121
|
+
...OBS_APPROVAL_SPECS,
|
|
122
|
+
...UPDATE_APPROVAL_SPECS,
|
|
123
|
+
...SECRETS_APPROVAL_SPECS,
|
|
124
|
+
huaweicloud_packs_configure: PACKS_CONFIGURE_APPROVAL_SPEC,
|
|
125
|
+
};
|
|
108
126
|
// Per-pack tool lists invert PACK_OF instead of hand-writing name lists, so a
|
|
109
127
|
// pack can never claim an unassigned or non-existent tool.
|
|
110
128
|
function toolsFor(id) {
|