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
|
@@ -6,23 +6,43 @@ import {
|
|
|
6
6
|
stripLeadingHcloudBinArgs,
|
|
7
7
|
firstPlaceholderSecretArg,
|
|
8
8
|
pinViewArgs,
|
|
9
|
+
needsUserConfirmation,
|
|
10
|
+
quoteShellArg,
|
|
11
|
+
hcloudExecutableLines,
|
|
9
12
|
type HcloudRunResult,
|
|
13
|
+
type HcloudRunOptions,
|
|
10
14
|
} from '../../hcloud-cli.ts';
|
|
11
15
|
import { hcloudProbeNextStep, hcloudProbeRaw, probeHcloud, type ProbeHcloudOptions } from '../../hcloud-probe.ts';
|
|
12
16
|
import { redactSecrets } from '../../safety-policy.ts';
|
|
13
17
|
import { asText } from '../../lib/as-text.ts';
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
18
|
+
import { approvalModeFromEnv, type ApprovalMode } from '../../lib/approval-mode.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';
|
|
16
28
|
import type { PackToolDefinition, LooseToolSchema } from '../../lib/pack-types.ts';
|
|
17
29
|
import type { CallToolOptions, ToolArgs } from '../../tools.ts';
|
|
18
30
|
import { asRecord } from '../../lib/as-record.ts';
|
|
31
|
+
import type { ApprovalSpec } from '../../approval-types.ts';
|
|
19
32
|
|
|
20
33
|
// The seven KooCLI-coupled execution tools sunk from core (src/tools.ts):
|
|
21
|
-
// version/profile inspection, plan/
|
|
22
|
-
// operation discovery, and region listing. The consent layer
|
|
23
|
-
//
|
|
24
|
-
//
|
|
25
|
-
//
|
|
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
|
|
26
46
|
// removes the CLI execution face and its approval tools together: a
|
|
27
47
|
// configuration trimmed of this pack has no devkit-side hcloud CLI write
|
|
28
48
|
// path, and the gateway face, when enabled, is a separate delegated write
|
|
@@ -201,123 +221,73 @@ async function listOperations(service: string | undefined, options: { timeoutMs?
|
|
|
201
221
|
};
|
|
202
222
|
}
|
|
203
223
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
const
|
|
214
|
-
if (
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
if (inspection.state === 'not_found') {
|
|
221
|
-
// A token that was never created (typo / unknown / pruned beyond the
|
|
222
|
-
// tombstone window) is still a rejection, but carries no expired/already
|
|
223
|
-
// semantics — surface a distinct code so clients can tell the cases apart.
|
|
224
|
-
return { status: 'rejected', code: 'CONFIRM_TOKEN_NOT_FOUND' };
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
const providedArgs = Array.isArray(args.args) ? args.args.map(String) : [];
|
|
228
|
-
// The token binds the plan's EFFECTIVE args (the plan strips a leading bin
|
|
229
|
-
// token before minting), so the verify side normalizes the same way: a run
|
|
230
|
-
// call that echoes the plan verbatim and one that sends the cleaned args
|
|
231
|
-
// both hash to the stored value, while any real argument change still
|
|
232
|
-
// rejects. Without this, a prefixed plan followed by a self-corrected run
|
|
233
|
-
// burned the single-use token on a mismatch (2026-11-05 UX report #6, the
|
|
234
|
-
// approval-trap probe).
|
|
235
|
-
const { args: effectiveArgs } = stripLeadingHcloudBinArgs(providedArgs);
|
|
236
|
-
// A placeholder-shaped secret VALUE at run time is never a real secret:
|
|
237
|
-
// executing a literal `<redacted>`/`<password>` as the password is always
|
|
238
|
-
// wrong. This guard runs BEFORE the token is consumed, so its own guidance
|
|
239
|
-
// (replace the value, then re-run) stays followable on the same approval
|
|
240
|
-
// (loop round 3, seat-1 B3: the guidance used to be a dead end — the
|
|
241
|
-
// rejection burned the only token).
|
|
242
|
-
const placeholderArg = firstPlaceholderSecretArg(effectiveArgs);
|
|
243
|
-
if (placeholderArg) {
|
|
244
|
-
throw new Error(
|
|
245
|
-
`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.`,
|
|
246
|
-
);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
// The strict plan is pure, so it is computed before the token is consumed:
|
|
250
|
-
// its userConfirmation.needed decides whether the consume requires a grant,
|
|
251
|
-
// and the result still embeds it.
|
|
252
|
-
const strictPlan = planHcloudCommand(effectiveArgs, { allowWrites: false, mintApprovalToken: false });
|
|
224
|
+
// A placeholder-shaped secret VALUE at run time is never a real secret in
|
|
225
|
+
// either approval mode: executing a literal `<redacted>`/`<password>` as
|
|
226
|
+
// the password is always wrong. The guard is shared so the two modes can
|
|
227
|
+
// never drift on detection; only the re-run wording is mode-aware — token
|
|
228
|
+
// mode keeps the guidance followable on the SAME approval (the guard runs
|
|
229
|
+
// before the token is consumed; loop round 3, seat-1 B3: the guidance used
|
|
230
|
+
// to be a dead end because the rejection burned the only token), while
|
|
231
|
+
// ask mode has no token to preserve and must not reference one.
|
|
232
|
+
function assertNoPlaceholderSecret(args: string[], mode: ApprovalMode): void {
|
|
233
|
+
const placeholderArg = firstPlaceholderSecretArg(args);
|
|
234
|
+
if (!placeholderArg) return;
|
|
235
|
+
throw new Error(
|
|
236
|
+
`The argument "${placeholderArg}" still carries a placeholder secret value: replace <redacted> with the actual value the user approved, ` +
|
|
237
|
+
(mode === 'ask' ? 'then re-run.' : 'then re-run with the same approval token.'),
|
|
238
|
+
);
|
|
239
|
+
}
|
|
253
240
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
// TOCTOU repro).
|
|
260
|
-
const consumed = consumeApprovalToken(token, { requireGrant: strictPlan.userConfirmation.needed });
|
|
261
|
-
if (consumed.status === 'grant_required') {
|
|
262
|
-
return {
|
|
263
|
-
status: 'rejected',
|
|
264
|
-
code: 'USER_CONFIRMATION_REQUIRED',
|
|
265
|
-
nextStep:
|
|
266
|
-
'Ask the user to run "npx huaweicloud-devkit approve <this approvalToken>" in their own terminal, then retry this exact call.',
|
|
267
|
-
};
|
|
268
|
-
}
|
|
269
|
-
if (consumed.status === 'gone') {
|
|
270
|
-
// Defensive: inspectApprovalToken said 'valid' but consume returned gone.
|
|
271
|
-
// The paths are the O_EXCL claim losing a race (another consumer is
|
|
272
|
-
// spending this exact token right now) or a store swap removing the
|
|
273
|
-
// entry between the two reads — classify via re-inspect, never a
|
|
274
|
-
// misleading success and never a false not_found.
|
|
275
|
-
const recheck = inspectApprovalToken(token);
|
|
276
|
-
if (recheck.state === 'expired') return { status: 'rejected', code: 'CONFIRM_TOKEN_EXPIRED' };
|
|
277
|
-
return { status: 'ok', outcome: 'already_processed' };
|
|
278
|
-
}
|
|
279
|
-
const stored = consumed.entry;
|
|
280
|
-
if (hashArgs(effectiveArgs) !== stored.argsHash) {
|
|
281
|
-
// The pin view is the canonical fold for the substitution comparison
|
|
282
|
-
// (loop round 4, seat-1 B2): it folds the two-token/glued secret forms
|
|
283
|
-
// the redactor never did, so following the placeholder guidance on a
|
|
284
|
-
// two-token plan no longer dead-ends in a mismatch. Pre-schema entries
|
|
285
|
-
// (no argsPinView) fall back to the redactor comparison.
|
|
286
|
-
const storedView = JSON.stringify(stored.argsPinView ?? stored.argsRedacted);
|
|
287
|
-
const providedView = JSON.stringify(pinViewArgs(effectiveArgs));
|
|
288
|
-
if (storedView !== providedView) {
|
|
289
|
-
throw new Error(
|
|
290
|
-
'Provided args do not match the approved plan. Use the exact args from the plan. ' +
|
|
291
|
-
'If the plan shows <redacted> for passwords or secrets, replace <redacted> with the actual values.',
|
|
292
|
-
);
|
|
293
|
-
}
|
|
294
|
-
// Views equal means ONLY secret values differ. The plan carried real
|
|
295
|
-
// (non-placeholder) secrets → they are pinned: a different real secret
|
|
296
|
-
// rejects (loop round 2, the seat-2 A3 probe — a changed password used
|
|
297
|
-
// to execute). A placeholder-bearing plan (secretsSubstitutable) keeps
|
|
298
|
-
// the documented substitution flow.
|
|
299
|
-
if (stored.secretsSubstitutable !== true) {
|
|
300
|
-
// The message deliberately does not assert WHY the plan pinned: the
|
|
301
|
-
// detector is key-shape heuristic, so the plan may have carried real
|
|
302
|
-
// secrets, placeholder-adjacent values, or JSON-body forms where the
|
|
303
|
-
// substitution contract is not reliable (loop round 9, seat-1 B1/B2).
|
|
304
|
-
throw new Error(
|
|
305
|
-
'Secret values are pinned to the approved plan: re-run huaweicloud_plan_cli_command with the final values and re-approve.',
|
|
306
|
-
);
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
const result = await runHcloud(effectiveArgs, {
|
|
241
|
+
// The run options both approval modes execute under: allowWrites stays
|
|
242
|
+
// scoped to this file's call sites (the only ones in the codebase), and
|
|
243
|
+
// the pass-through fields keep their names verbatim.
|
|
244
|
+
function approvedRunOptions(args: ToolArgs): HcloudRunOptions {
|
|
245
|
+
return {
|
|
310
246
|
allowWrites: true,
|
|
311
247
|
timeoutMs: args.timeoutMs,
|
|
312
248
|
maxRetries: args.maxRetries,
|
|
313
249
|
cwd: args.cwd,
|
|
314
250
|
stdin: args.stdin,
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
|
|
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));
|
|
272
|
+
const strictPlan = planHcloudCommand(effectiveArgs, {
|
|
273
|
+
allowWrites: false,
|
|
274
|
+
mintApprovalToken: false,
|
|
275
|
+
approvalMode: approvalModeFromEnv(process.env),
|
|
315
276
|
});
|
|
316
|
-
|
|
317
|
-
//
|
|
277
|
+
const result = await runHcloud(effectiveArgs, approvedRunOptions(args));
|
|
278
|
+
// Spread instead of in-place mutation: the HcloudRunResult shape stays
|
|
279
|
+
// owned by hcloud-cli.ts.
|
|
318
280
|
return { ...result, approved: true, plan: strictPlan };
|
|
319
281
|
}
|
|
320
282
|
|
|
283
|
+
async function runApprovedCommand(args: ToolArgs = {}) {
|
|
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);
|
|
289
|
+
}
|
|
290
|
+
|
|
321
291
|
async function listRegions() {
|
|
322
292
|
const result = await runHcloud(['IAM', 'KeystoneListRegions'], { timeoutMs: 30000, maxRetries: 0 }).catch(
|
|
323
293
|
(error): HcloudRunResult => ({
|
|
@@ -370,7 +340,10 @@ async function handleCheckCli(_args: ToolArgs = {}, _opts: CallToolOptions = {})
|
|
|
370
340
|
}
|
|
371
341
|
|
|
372
342
|
async function handlePlanCliCommand(args: ToolArgs = {}, _opts: CallToolOptions = {}) {
|
|
373
|
-
return planHcloudCommand(args.args || [], {
|
|
343
|
+
return planHcloudCommand(args.args || [], {
|
|
344
|
+
allowWrites: args.allowWrites === true,
|
|
345
|
+
approvalMode: approvalModeFromEnv(process.env),
|
|
346
|
+
});
|
|
374
347
|
}
|
|
375
348
|
|
|
376
349
|
async function handleRunReadonlyCommand(args: ToolArgs = {}, _opts: CallToolOptions = {}) {
|
|
@@ -406,7 +379,7 @@ const planCliCommandSchema = z.looseObject({
|
|
|
406
379
|
});
|
|
407
380
|
const runReadonlyCommandSchema = z.looseObject({
|
|
408
381
|
vendorConfirmed,
|
|
409
|
-
args: stringArrayArg,
|
|
382
|
+
args: stringArrayArg.describe('hcloud arguments, excluding the hcloud executable.'),
|
|
410
383
|
timeoutMs: numericArg.optional().describe('Optional timeout in milliseconds. Defaults to 60000.'),
|
|
411
384
|
maxRetries: numericArg.optional().describe('Optional retry count for transient network errors. Defaults to 1.'),
|
|
412
385
|
cwd: z.string().optional().describe('Optional working directory for the hcloud process.'),
|
|
@@ -418,9 +391,17 @@ const listOperationsSchema = z.looseObject({
|
|
|
418
391
|
});
|
|
419
392
|
const runApprovedCommandSchema = z.looseObject({
|
|
420
393
|
vendorConfirmed,
|
|
394
|
+
command: z
|
|
395
|
+
.string()
|
|
396
|
+
.optional()
|
|
397
|
+
.describe(
|
|
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.',
|
|
399
|
+
),
|
|
421
400
|
args: stringArrayArg.describe('hcloud arguments, excluding the hcloud executable.'),
|
|
422
|
-
approvalToken:
|
|
423
|
-
|
|
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,
|
|
424
405
|
timeoutMs: numericArg.optional().describe('Optional timeout in milliseconds. Defaults to 60000.'),
|
|
425
406
|
maxRetries: numericArg.optional().describe('Optional retry count for transient network errors. Defaults to 1.'),
|
|
426
407
|
cwd: z.string().optional().describe('Optional working directory for the hcloud process.'),
|
|
@@ -431,6 +412,44 @@ const showProfileRedactedSchema = z.looseObject({
|
|
|
431
412
|
});
|
|
432
413
|
const listRegionsSchema = z.looseObject({ vendorConfirmed });
|
|
433
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
|
+
|
|
434
453
|
export const HUAWEICLOUD_CLI_TOOLS = [
|
|
435
454
|
{
|
|
436
455
|
name: 'huaweicloud_check_cli',
|
|
@@ -442,7 +461,7 @@ export const HUAWEICLOUD_CLI_TOOLS = [
|
|
|
442
461
|
{
|
|
443
462
|
name: 'huaweicloud_plan_cli_command',
|
|
444
463
|
description:
|
|
445
|
-
"Classify and plan a Huawei Cloud hcloud command without executing it. When the result's userConfirmation.needed is true, the
|
|
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.",
|
|
446
465
|
schema: planCliCommandSchema,
|
|
447
466
|
handler: handlePlanCliCommand,
|
|
448
467
|
},
|
|
@@ -463,7 +482,7 @@ export const HUAWEICLOUD_CLI_TOOLS = [
|
|
|
463
482
|
{
|
|
464
483
|
name: 'huaweicloud_run_approved_command',
|
|
465
484
|
description:
|
|
466
|
-
'Run a write-capable hcloud command only after the exact command has been shown and explicitly approved by the user
|
|
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.',
|
|
467
486
|
schema: runApprovedCommandSchema,
|
|
468
487
|
handler: handleRunApprovedCommand,
|
|
469
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
|
|
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
|
|
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[] {
|