huaweicloud-devkit 2.0.0-next.2 → 2.0.0-next.3
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 +1 -1
- package/package.json +1 -1
- package/plugins/huaweicloud-core/.claude-plugin/plugin.json +1 -1
- package/plugins/huaweicloud-core/.codex-plugin/plugin.json +1 -1
- package/plugins/huaweicloud-core/.cursor-plugin/plugin.json +1 -1
- package/plugins/huaweicloud-core/.hermes-plugin/plugin.json +1 -1
- package/plugins/huaweicloud-core/.workbuddy-plugin/plugin.json +1 -1
- package/plugins/huaweicloud-core/dist/agents/opencode-config.js +73 -2
- package/plugins/huaweicloud-core/dist/agents/opencode.js +62 -1
- package/plugins/huaweicloud-core/dist/hcloud-plan.js +25 -5
- package/plugins/huaweicloud-core/dist/lib/approval-mode.js +30 -0
- package/plugins/huaweicloud-core/dist/lib/opencode-ask-rule.js +116 -0
- package/plugins/huaweicloud-core/dist/mcp-protocol.js +20 -1
- package/plugins/huaweicloud-core/dist/mcp-server.js +86 -18
- package/plugins/huaweicloud-core/dist/mcp-server.js.map +3 -3
- package/plugins/huaweicloud-core/dist/packs/huaweicloud-cli/tools.js +74 -22
- package/plugins/huaweicloud-core/dist/setup-cli.js +6 -3
- package/plugins/huaweicloud-core/openclaw.plugin.json +1 -1
- package/plugins/huaweicloud-core/skills/huaweicloud-cli-and-auth/SKILL.md +4 -4
- package/plugins/huaweicloud-core/skills/huaweicloud-safety/SKILL.md +8 -7
- package/plugins/huaweicloud-core/skills/huaweicloud-safety/references/approvals.md +10 -0
- package/plugins/huaweicloud-core/src/agents/opencode-config.ts +82 -2
- package/plugins/huaweicloud-core/src/agents/opencode.ts +86 -1
- package/plugins/huaweicloud-core/src/hcloud-plan.ts +38 -6
- package/plugins/huaweicloud-core/src/lib/approval-mode.ts +32 -0
- package/plugins/huaweicloud-core/src/lib/opencode-ask-rule.ts +131 -0
- package/plugins/huaweicloud-core/src/mcp-protocol.ts +20 -1
- package/plugins/huaweicloud-core/src/mcp-server.ts +13 -0
- package/plugins/huaweicloud-core/src/packs/huaweicloud-cli/tools.ts +81 -24
- package/plugins/huaweicloud-core/src/setup-cli.ts +6 -2
|
@@ -55735,7 +55735,8 @@ function planHcloudCommand(args, options = {}) {
|
|
|
55735
55735
|
warnings.push(`${triage.message} ${triage.nextStep}`);
|
|
55736
55736
|
}
|
|
55737
55737
|
}
|
|
55738
|
-
const
|
|
55738
|
+
const approvalMode = options.approvalMode ?? "token";
|
|
55739
|
+
const approvalToken = approvalMode === "ask" || options.mintApprovalToken === false ? void 0 : createApprovalToken(normalizedArgs, {
|
|
55739
55740
|
secretsSubstitutable: secretsSubstitutable(normalizedArgs),
|
|
55740
55741
|
argsPinView: pinViewArgs(normalizedArgs)
|
|
55741
55742
|
});
|
|
@@ -55755,7 +55756,13 @@ function planHcloudCommand(args, options = {}) {
|
|
|
55755
55756
|
...approvalToken !== void 0 ? { approvalToken } : {},
|
|
55756
55757
|
// `command` exists only where a token was minted: a run-path plan stays
|
|
55757
55758
|
// silent rather than name a line for a token the run cannot offer.
|
|
55758
|
-
|
|
55759
|
+
// Ask mode names the posture instead — the confirmation happens at the
|
|
55760
|
+
// run call, and the note teaches exactly that.
|
|
55761
|
+
userConfirmation: needsConfirmation ? approvalMode === "ask" ? {
|
|
55762
|
+
needed: true,
|
|
55763
|
+
mode: "ask",
|
|
55764
|
+
note: "The harness client confirms this command with the user when huaweicloud_run_approved_command is called. Call it with the same args and approvedByUser: true. No terminal approval line or token is needed."
|
|
55765
|
+
} : {
|
|
55759
55766
|
needed: true,
|
|
55760
55767
|
...approvalToken !== void 0 ? { command: `npx huaweicloud-devkit approve ${approvalToken}` } : {}
|
|
55761
55768
|
} : { needed: false },
|
|
@@ -57896,6 +57903,23 @@ var init_pack6 = __esm({
|
|
|
57896
57903
|
}
|
|
57897
57904
|
});
|
|
57898
57905
|
|
|
57906
|
+
// plugins/huaweicloud-core/dist.new/lib/approval-mode.js
|
|
57907
|
+
function approvalModeFromEnv(env) {
|
|
57908
|
+
const raw = env[APPROVAL_MODE_ENV];
|
|
57909
|
+
if (raw === void 0 || raw === "")
|
|
57910
|
+
return "token";
|
|
57911
|
+
if (raw === "ask" || raw === "token")
|
|
57912
|
+
return raw;
|
|
57913
|
+
throw new Error(`DEVKIT_APPROVAL_MODE must be "ask" or "token" (got "${raw}")`);
|
|
57914
|
+
}
|
|
57915
|
+
var APPROVAL_MODE_ENV;
|
|
57916
|
+
var init_approval_mode = __esm({
|
|
57917
|
+
"plugins/huaweicloud-core/dist.new/lib/approval-mode.js"() {
|
|
57918
|
+
"use strict";
|
|
57919
|
+
APPROVAL_MODE_ENV = "DEVKIT_APPROVAL_MODE";
|
|
57920
|
+
}
|
|
57921
|
+
});
|
|
57922
|
+
|
|
57899
57923
|
// plugins/huaweicloud-core/dist.new/packs/huaweicloud-cli/tools.js
|
|
57900
57924
|
async function runVersionCheck(options = {}) {
|
|
57901
57925
|
const result = probeHcloud(options);
|
|
@@ -57999,10 +58023,41 @@ async function listOperations(service, options = {}) {
|
|
|
57999
58023
|
result
|
|
58000
58024
|
};
|
|
58001
58025
|
}
|
|
58026
|
+
function assertNoPlaceholderSecret(args, mode) {
|
|
58027
|
+
const placeholderArg = firstPlaceholderSecretArg(args);
|
|
58028
|
+
if (!placeholderArg)
|
|
58029
|
+
return;
|
|
58030
|
+
throw new Error(`The argument "${placeholderArg}" still carries a placeholder secret value: replace <redacted> with the actual value the user approved, ` + (mode === "ask" ? "then re-run." : "then re-run with the same approval token."));
|
|
58031
|
+
}
|
|
58032
|
+
function approvedRunOptions(args) {
|
|
58033
|
+
return {
|
|
58034
|
+
allowWrites: true,
|
|
58035
|
+
timeoutMs: args.timeoutMs,
|
|
58036
|
+
maxRetries: args.maxRetries,
|
|
58037
|
+
cwd: args.cwd,
|
|
58038
|
+
stdin: args.stdin
|
|
58039
|
+
};
|
|
58040
|
+
}
|
|
58041
|
+
async function runApprovedCommandAskMode(args) {
|
|
58042
|
+
const providedArgs = Array.isArray(args.args) ? args.args.map(String) : [];
|
|
58043
|
+
const { args: effectiveArgs } = stripLeadingHcloudBinArgs(providedArgs);
|
|
58044
|
+
assertNoPlaceholderSecret(effectiveArgs, "ask");
|
|
58045
|
+
const strictPlan = planHcloudCommand(effectiveArgs, {
|
|
58046
|
+
allowWrites: false,
|
|
58047
|
+
mintApprovalToken: false,
|
|
58048
|
+
approvalMode: "ask"
|
|
58049
|
+
});
|
|
58050
|
+
const result = await runHcloud2(effectiveArgs, approvedRunOptions(args));
|
|
58051
|
+
return { ...result, approved: true, plan: strictPlan };
|
|
58052
|
+
}
|
|
58002
58053
|
async function runApprovedCommand(args = {}) {
|
|
58003
58054
|
if (args.approvedByUser !== true) {
|
|
58004
58055
|
throw new Error("approvedByUser must be true after explicit user approval for this exact command.");
|
|
58005
58056
|
}
|
|
58057
|
+
const approvalMode = approvalModeFromEnv(process.env);
|
|
58058
|
+
if (approvalMode === "ask") {
|
|
58059
|
+
return runApprovedCommandAskMode(args);
|
|
58060
|
+
}
|
|
58006
58061
|
const token = String(args.approvalToken || "");
|
|
58007
58062
|
const inspection = inspectApprovalToken(token);
|
|
58008
58063
|
if (inspection.state === "already_consumed") {
|
|
@@ -58016,10 +58071,7 @@ async function runApprovedCommand(args = {}) {
|
|
|
58016
58071
|
}
|
|
58017
58072
|
const providedArgs = Array.isArray(args.args) ? args.args.map(String) : [];
|
|
58018
58073
|
const { args: effectiveArgs } = stripLeadingHcloudBinArgs(providedArgs);
|
|
58019
|
-
|
|
58020
|
-
if (placeholderArg) {
|
|
58021
|
-
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.`);
|
|
58022
|
-
}
|
|
58074
|
+
assertNoPlaceholderSecret(effectiveArgs, "token");
|
|
58023
58075
|
const strictPlan = planHcloudCommand(effectiveArgs, { allowWrites: false, mintApprovalToken: false });
|
|
58024
58076
|
const consumed = consumeApprovalToken(token, { requireGrant: strictPlan.userConfirmation.needed });
|
|
58025
58077
|
if (consumed.status === "grant_required") {
|
|
@@ -58046,13 +58098,7 @@ async function runApprovedCommand(args = {}) {
|
|
|
58046
58098
|
throw new Error("Secret values are pinned to the approved plan: re-run huaweicloud_plan_cli_command with the final values and re-approve.");
|
|
58047
58099
|
}
|
|
58048
58100
|
}
|
|
58049
|
-
const result = await runHcloud2(effectiveArgs,
|
|
58050
|
-
allowWrites: true,
|
|
58051
|
-
timeoutMs: args.timeoutMs,
|
|
58052
|
-
maxRetries: args.maxRetries,
|
|
58053
|
-
cwd: args.cwd,
|
|
58054
|
-
stdin: args.stdin
|
|
58055
|
-
});
|
|
58101
|
+
const result = await runHcloud2(effectiveArgs, approvedRunOptions(args));
|
|
58056
58102
|
return { ...result, approved: true, plan: strictPlan };
|
|
58057
58103
|
}
|
|
58058
58104
|
async function listRegions() {
|
|
@@ -58103,7 +58149,10 @@ async function handleCheckCli(_args = {}, _opts = {}) {
|
|
|
58103
58149
|
return runVersionCheck();
|
|
58104
58150
|
}
|
|
58105
58151
|
async function handlePlanCliCommand(args = {}, _opts = {}) {
|
|
58106
|
-
return planHcloudCommand(args.args || [], {
|
|
58152
|
+
return planHcloudCommand(args.args || [], {
|
|
58153
|
+
allowWrites: args.allowWrites === true,
|
|
58154
|
+
approvalMode: approvalModeFromEnv(process.env)
|
|
58155
|
+
});
|
|
58107
58156
|
}
|
|
58108
58157
|
async function handleRunReadonlyCommand(args = {}, _opts = {}) {
|
|
58109
58158
|
return runHcloud2(args.args || [], {
|
|
@@ -58134,6 +58183,7 @@ var init_tools7 = __esm({
|
|
|
58134
58183
|
init_hcloud_probe();
|
|
58135
58184
|
init_safety_policy();
|
|
58136
58185
|
init_as_text();
|
|
58186
|
+
init_approval_mode();
|
|
58137
58187
|
init_approval_tokens();
|
|
58138
58188
|
init_tool_schema_parts();
|
|
58139
58189
|
init_as_record();
|
|
@@ -58202,7 +58252,7 @@ var init_tools7 = __esm({
|
|
|
58202
58252
|
runApprovedCommandSchema = external_exports.looseObject({
|
|
58203
58253
|
vendorConfirmed,
|
|
58204
58254
|
args: stringArrayArg.describe("hcloud arguments, excluding the hcloud executable."),
|
|
58205
|
-
approvalToken: external_exports.string().describe("
|
|
58255
|
+
approvalToken: external_exports.string().optional().describe("Required in token-approval mode (from huaweicloud_plan_cli_command); omit in ask mode where the harness client confirms at run time."),
|
|
58206
58256
|
approvedByUser: booleanArg.describe("Must be true only after the user explicitly approves this exact command."),
|
|
58207
58257
|
timeoutMs: numericArg.optional().describe("Optional timeout in milliseconds. Defaults to 60000."),
|
|
58208
58258
|
maxRetries: numericArg.optional().describe("Optional retry count for transient network errors. Defaults to 1."),
|
|
@@ -58222,7 +58272,7 @@ var init_tools7 = __esm({
|
|
|
58222
58272
|
},
|
|
58223
58273
|
{
|
|
58224
58274
|
name: "huaweicloud_plan_cli_command",
|
|
58225
|
-
description: "Classify and plan a Huawei Cloud hcloud command without executing it. When the result's userConfirmation.needed is true, the
|
|
58275
|
+
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 harness client itself prompts the user on the run call \u2014 no token is needed. Vendor-gated (vendorConfirmed): call only when the vendor is established \u2014 see the vendorConfirmed parameter description; when unknown, ask which cloud the user means first.",
|
|
58226
58276
|
schema: planCliCommandSchema,
|
|
58227
58277
|
handler: handlePlanCliCommand
|
|
58228
58278
|
},
|
|
@@ -58240,7 +58290,7 @@ var init_tools7 = __esm({
|
|
|
58240
58290
|
},
|
|
58241
58291
|
{
|
|
58242
58292
|
name: "huaweicloud_run_approved_command",
|
|
58243
|
-
description: "Run a write-capable hcloud command only after the exact command has been shown and explicitly approved by the user
|
|
58293
|
+
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>) \u2014 a non-read command without that terminal confirmation is rejected with USER_CONFIRMATION_REQUIRED and the token stays usable. Under DEVKIT_APPROVAL_MODE=ask the harness client's permission prompt on this call is the confirmation: pass the same args with approvedByUser: true and no approvalToken. Vendor-gated (vendorConfirmed): call only when the vendor is established \u2014 see the vendorConfirmed parameter description; when unknown, ask which cloud the user means first.",
|
|
58244
58294
|
schema: runApprovedCommandSchema,
|
|
58245
58295
|
handler: handleRunApprovedCommand
|
|
58246
58296
|
},
|
|
@@ -60850,6 +60900,7 @@ function normalizeToolCallParams(message) {
|
|
|
60850
60900
|
}
|
|
60851
60901
|
function createDevkitMcpServer({ sessionId, runtimePacks = false, remoteSurface = false } = {}) {
|
|
60852
60902
|
assertConstructedSchemas();
|
|
60903
|
+
const askMode = approvalModeFromEnv(process.env) === "ask";
|
|
60853
60904
|
if (remoteSurface && runtimePacks) {
|
|
60854
60905
|
throw new Error("contradictory construction: remoteSurface and runtimePacks are mutually exclusive \u2014 the stateless remote must not carry runtime pack toggling (it would leak host paths through skill payloads)");
|
|
60855
60906
|
}
|
|
@@ -60867,7 +60918,18 @@ function createDevkitMcpServer({ sessionId, runtimePacks = false, remoteSurface
|
|
|
60867
60918
|
]);
|
|
60868
60919
|
const isWanted = (tool, enabled) => enabled.has(PACK_OF[tool.name]) && (runtimePacks || tool.name !== "huaweicloud_packs_configure") && (!remoteSurface || PACK_OF[tool.name] !== "secrets" && !REMOTE_WITHHELD_LOCAL_WRITERS.has(tool.name));
|
|
60869
60920
|
const registerOne = (tool) => {
|
|
60870
|
-
registered.set(tool.name, server.registerTool(tool.name, {
|
|
60921
|
+
registered.set(tool.name, server.registerTool(tool.name, {
|
|
60922
|
+
description: tool.description,
|
|
60923
|
+
inputSchema: getToolSchema(tool.name),
|
|
60924
|
+
// Ask mode only: Claude Code honors this flag by prompting the
|
|
60925
|
+
// user on every call of this tool — even in acceptEdits/auto/
|
|
60926
|
+
// bypassPermissions modes, with no "don't ask again" — and that
|
|
60927
|
+
// client prompt IS the user's confirmation the mode trusts.
|
|
60928
|
+
// Other clients ignore the flag. Declared only in ask mode so
|
|
60929
|
+
// token-mode Claude Code users don't gain a second prompt on top
|
|
60930
|
+
// of the terminal approve they already run.
|
|
60931
|
+
...askMode && tool.name === "huaweicloud_run_approved_command" ? { _meta: { "anthropic/requiresUserInteraction": true } } : {}
|
|
60932
|
+
}, async (args) => {
|
|
60871
60933
|
const callOpts = runtimePacks ? { sessionId, onPacksChanged: () => syncDisclosure() } : { sessionId };
|
|
60872
60934
|
const result = await callTool(tool.name, args, callOpts);
|
|
60873
60935
|
const decorated = _decorateResult(sessionId, tool.name, result);
|
|
@@ -60912,6 +60974,7 @@ var init_mcp_protocol = __esm({
|
|
|
60912
60974
|
init_telemetry();
|
|
60913
60975
|
init_agent_detect();
|
|
60914
60976
|
init_as_record();
|
|
60977
|
+
init_approval_mode();
|
|
60915
60978
|
pkgVersion = readInstalledVersion() || "0.0.0";
|
|
60916
60979
|
TRIMMED_CAPABILITY_RULE = "That unavailability is about the capability, not just the skill text or the MCP tools: a trimmed pack's services are unavailable through every execution path, including hcloud commands run directly from your shell \u2014 never silently proceed that way; confirm with the user instead. ";
|
|
60917
60980
|
VENDOR_BOUNDARY_RULE = "Vendor boundary: tools or skills being available in this session is not evidence of which cloud the user means. For a request that involves cloud resources but names no vendor, infer the vendor only from an explicit mention, hcloud/KooCLI artifacts, myhuaweicloud endpoints, Huawei region IDs, or earlier turns of this conversation \u2014 generic service vocabulary (ECS, VPC, RDS, serverless) and the devkit's own presence do not infer it. When the vendor is still unknown, ask the user which cloud they mean before operating on cloud resources through any tool or hcloud command, and before probing Huawei Cloud tooling, credential, or account state (CLI install checks, profile reads, auth status). Cloud-facing tools enforce this with a vendorConfirmed parameter \u2014 pass the user's establishing words as its value, never an invented quote. Requests that are not cloud tasks are outside this rule; tasks for other clouds remain answerable from general knowledge \u2014 the devkit's tools themselves only operate on Huawei Cloud. ";
|
|
@@ -62348,6 +62411,7 @@ function maybePreinstallKooCli({ force = false } = {}) {
|
|
|
62348
62411
|
}
|
|
62349
62412
|
|
|
62350
62413
|
// plugins/huaweicloud-core/dist.new/mcp-server.js
|
|
62414
|
+
init_approval_mode();
|
|
62351
62415
|
var transportIdx = process.argv.indexOf("--transport");
|
|
62352
62416
|
var transport = transportIdx > -1 && process.argv[transportIdx + 1] ? process.argv[transportIdx + 1] : "stdio";
|
|
62353
62417
|
var portIdx = process.argv.indexOf("--port");
|
|
@@ -62387,6 +62451,10 @@ try {
|
|
|
62387
62451
|
} catch {
|
|
62388
62452
|
}
|
|
62389
62453
|
if (transport === "remote") {
|
|
62454
|
+
if (approvalModeFromEnv(process.env) === "ask") {
|
|
62455
|
+
process.env.DEVKIT_APPROVAL_MODE = "token";
|
|
62456
|
+
process.stderr.write("DEVKIT_APPROVAL_MODE=ask is not supported on the remote transport (no per-call permission prompt to trust); falling back to token approval.\n");
|
|
62457
|
+
}
|
|
62390
62458
|
const { startRemoteServer: startRemoteServer2 } = await Promise.resolve().then(() => (init_mcp_server_remote(), mcp_server_remote_exports));
|
|
62391
62459
|
startRemoteServer2({ port: remotePort, host: remoteHost }).catch((error62) => {
|
|
62392
62460
|
process.stderr.write(`Failed to start MCP remote server: ${error62 instanceof Error ? error62.message : String(error62)}
|