huaweicloud-devkit 2.0.0-next.1 → 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 +3 -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/codearts-work.js +4 -0
- package/plugins/huaweicloud-core/dist/agents/codearts.js +4 -0
- 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/auth/s1-store.js +43 -22
- 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/approval-tokens.js +3 -3
- package/plugins/huaweicloud-core/dist/lib/opencode-ask-rule.js +116 -0
- package/plugins/huaweicloud-core/dist/lib/pack-state.js +23 -19
- package/plugins/huaweicloud-core/dist/lib/param-warnings.js +70 -0
- package/plugins/huaweicloud-core/dist/lib/state-dir.js +125 -0
- package/plugins/huaweicloud-core/dist/mcp-protocol.js +20 -1
- package/plugins/huaweicloud-core/dist/mcp-server.js +849 -585
- package/plugins/huaweicloud-core/dist/mcp-server.js.map +4 -4
- package/plugins/huaweicloud-core/dist/packs/huaweicloud-cli/tools.js +74 -22
- package/plugins/huaweicloud-core/dist/setup-cli.js +22 -3
- package/plugins/huaweicloud-core/dist/tool-schemas.js +15 -0
- package/plugins/huaweicloud-core/dist/tools.js +36 -4
- package/plugins/huaweicloud-core/dist/update-skip.js +5 -6
- package/plugins/huaweicloud-core/openclaw.plugin.json +1 -1
- package/plugins/huaweicloud-core/safety/rules/cloud-risk-rules.json +78 -2
- 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/codearts-work.ts +3 -0
- package/plugins/huaweicloud-core/src/agents/codearts.ts +4 -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/auth/s1-store.ts +41 -20
- 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/approval-tokens.ts +3 -3
- package/plugins/huaweicloud-core/src/lib/opencode-ask-rule.ts +131 -0
- package/plugins/huaweicloud-core/src/lib/pack-state.ts +23 -20
- package/plugins/huaweicloud-core/src/lib/param-warnings.ts +69 -0
- package/plugins/huaweicloud-core/src/lib/state-dir.ts +128 -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 +27 -2
- package/plugins/huaweicloud-core/src/tool-schemas.ts +16 -0
- package/plugins/huaweicloud-core/src/tools.ts +39 -4
- package/plugins/huaweicloud-core/src/update-skip.ts +5 -6
|
@@ -3,6 +3,7 @@ import { runHcloud, planHcloudCommand, stripLeadingHcloudBinArgs, firstPlacehold
|
|
|
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 { approvalModeFromEnv } from "../../lib/approval-mode.js";
|
|
6
7
|
import { consumeApprovalToken, hashArgs, inspectApprovalToken } from "../../lib/approval-tokens.js";
|
|
7
8
|
import { booleanArg, numericArg, stringArrayArg, vendorConfirmed } from "../../lib/tool-schema-parts.js";
|
|
8
9
|
import { asRecord } from "../../lib/as-record.js";
|
|
@@ -10,7 +11,11 @@ import { asRecord } from "../../lib/as-record.js";
|
|
|
10
11
|
// version/profile inspection, plan/read-only/approved command execution,
|
|
11
12
|
// operation discovery, and region listing. The consent layer is imported
|
|
12
13
|
// directly from src/lib/approval-tokens.ts (the CLI face's consent module),
|
|
13
|
-
// not the hcloud-cli.ts re-export shim. The
|
|
14
|
+
// not the hcloud-cli.ts re-export shim. The approval posture resolves from
|
|
15
|
+
// DEVKIT_APPROVAL_MODE (src/lib/approval-mode.ts): 'token' (default) keeps
|
|
16
|
+
// the out-of-band terminal gate; 'ask' makes the harness client's own
|
|
17
|
+
// permission prompt the user's confirmation, so the plan mints nothing and
|
|
18
|
+
// the run needs no token. The only allowWrites:true call site
|
|
14
19
|
// in the codebase (runApprovedCommand) lives here, so trimming this pack
|
|
15
20
|
// removes the CLI execution face and its approval tools together: a
|
|
16
21
|
// configuration trimmed of this pack has no devkit-side hcloud CLI write
|
|
@@ -173,10 +178,64 @@ async function listOperations(service, options = {}) {
|
|
|
173
178
|
result,
|
|
174
179
|
};
|
|
175
180
|
}
|
|
181
|
+
// A placeholder-shaped secret VALUE at run time is never a real secret in
|
|
182
|
+
// either approval mode: executing a literal `<redacted>`/`<password>` as
|
|
183
|
+
// the password is always wrong. The guard is shared so the two modes can
|
|
184
|
+
// never drift on detection; only the re-run wording is mode-aware — token
|
|
185
|
+
// mode keeps the guidance followable on the SAME approval (the guard runs
|
|
186
|
+
// before the token is consumed; loop round 3, seat-1 B3: the guidance used
|
|
187
|
+
// to be a dead end because the rejection burned the only token), while
|
|
188
|
+
// ask mode has no token to preserve and must not reference one.
|
|
189
|
+
function assertNoPlaceholderSecret(args, mode) {
|
|
190
|
+
const placeholderArg = firstPlaceholderSecretArg(args);
|
|
191
|
+
if (!placeholderArg)
|
|
192
|
+
return;
|
|
193
|
+
throw new Error(`The argument "${placeholderArg}" still carries a placeholder secret value: replace <redacted> with the actual value the user approved, ` +
|
|
194
|
+
(mode === 'ask' ? 'then re-run.' : 'then re-run with the same approval token.'));
|
|
195
|
+
}
|
|
196
|
+
// The run options both approval modes execute under: allowWrites stays
|
|
197
|
+
// scoped to this file's call sites (the only ones in the codebase), and
|
|
198
|
+
// the pass-through fields keep their names verbatim.
|
|
199
|
+
function approvedRunOptions(args) {
|
|
200
|
+
return {
|
|
201
|
+
allowWrites: true,
|
|
202
|
+
timeoutMs: args.timeoutMs,
|
|
203
|
+
maxRetries: args.maxRetries,
|
|
204
|
+
cwd: args.cwd,
|
|
205
|
+
stdin: args.stdin,
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
// Ask mode (DEVKIT_APPROVAL_MODE=ask): the harness client's permission
|
|
209
|
+
// prompt on this very call is the user's confirmation, so there is no
|
|
210
|
+
// token to inspect or consume. The safety floors are unchanged — the
|
|
211
|
+
// placeholder-secret guard above, and runHcloud's assertAllowed
|
|
212
|
+
// re-assertion of the strict classification (secret/credential/invalid
|
|
213
|
+
// denies still throw; allowWrites:true stays scoped to this one call
|
|
214
|
+
// site, the only one in the codebase).
|
|
215
|
+
async function runApprovedCommandAskMode(args) {
|
|
216
|
+
const providedArgs = Array.isArray(args.args) ? args.args.map(String) : [];
|
|
217
|
+
// Same normalization as the token path: the strict plan and the executed
|
|
218
|
+
// argv must agree on the effective args.
|
|
219
|
+
const { args: effectiveArgs } = stripLeadingHcloudBinArgs(providedArgs);
|
|
220
|
+
assertNoPlaceholderSecret(effectiveArgs, 'ask');
|
|
221
|
+
const strictPlan = planHcloudCommand(effectiveArgs, {
|
|
222
|
+
allowWrites: false,
|
|
223
|
+
mintApprovalToken: false,
|
|
224
|
+
approvalMode: 'ask',
|
|
225
|
+
});
|
|
226
|
+
const result = await runHcloud(effectiveArgs, approvedRunOptions(args));
|
|
227
|
+
// Spread instead of in-place mutation, mirroring the token path: the
|
|
228
|
+
// HcloudRunResult shape stays owned by hcloud-cli.ts.
|
|
229
|
+
return { ...result, approved: true, plan: strictPlan };
|
|
230
|
+
}
|
|
176
231
|
async function runApprovedCommand(args = {}) {
|
|
177
232
|
if (args.approvedByUser !== true) {
|
|
178
233
|
throw new Error('approvedByUser must be true after explicit user approval for this exact command.');
|
|
179
234
|
}
|
|
235
|
+
const approvalMode = approvalModeFromEnv(process.env);
|
|
236
|
+
if (approvalMode === 'ask') {
|
|
237
|
+
return runApprovedCommandAskMode(args);
|
|
238
|
+
}
|
|
180
239
|
const token = String(args.approvalToken || '');
|
|
181
240
|
// D4-24 precise JSON contract (#745): expired and already-consumed tokens
|
|
182
241
|
// return a structured result instead of throwing a generic Error string, so
|
|
@@ -203,16 +262,9 @@ async function runApprovedCommand(args = {}) {
|
|
|
203
262
|
// burned the single-use token on a mismatch (2026-11-05 UX report #6, the
|
|
204
263
|
// approval-trap probe).
|
|
205
264
|
const { args: effectiveArgs } = stripLeadingHcloudBinArgs(providedArgs);
|
|
206
|
-
//
|
|
207
|
-
//
|
|
208
|
-
|
|
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
|
-
}
|
|
265
|
+
// Placeholder guard before the consume: the shared helper's token-mode
|
|
266
|
+
// wording keeps the guidance followable on the same approval.
|
|
267
|
+
assertNoPlaceholderSecret(effectiveArgs, 'token');
|
|
216
268
|
// The strict plan is pure, so it is computed before the token is consumed:
|
|
217
269
|
// its userConfirmation.needed decides whether the consume requires a grant,
|
|
218
270
|
// and the result still embeds it.
|
|
@@ -268,13 +320,7 @@ async function runApprovedCommand(args = {}) {
|
|
|
268
320
|
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
321
|
}
|
|
270
322
|
}
|
|
271
|
-
const result = await runHcloud(effectiveArgs,
|
|
272
|
-
allowWrites: true,
|
|
273
|
-
timeoutMs: args.timeoutMs,
|
|
274
|
-
maxRetries: args.maxRetries,
|
|
275
|
-
cwd: args.cwd,
|
|
276
|
-
stdin: args.stdin,
|
|
277
|
-
});
|
|
323
|
+
const result = await runHcloud(effectiveArgs, approvedRunOptions(args));
|
|
278
324
|
// Spread instead of in-place mutation: identical serialized content, minus a
|
|
279
325
|
// write to the HcloudRunResult shape owned by hcloud-cli.ts.
|
|
280
326
|
return { ...result, approved: true, plan: strictPlan };
|
|
@@ -328,7 +374,10 @@ async function handleCheckCli(_args = {}, _opts = {}) {
|
|
|
328
374
|
return runVersionCheck();
|
|
329
375
|
}
|
|
330
376
|
async function handlePlanCliCommand(args = {}, _opts = {}) {
|
|
331
|
-
return planHcloudCommand(args.args || [], {
|
|
377
|
+
return planHcloudCommand(args.args || [], {
|
|
378
|
+
allowWrites: args.allowWrites === true,
|
|
379
|
+
approvalMode: approvalModeFromEnv(process.env),
|
|
380
|
+
});
|
|
332
381
|
}
|
|
333
382
|
async function handleRunReadonlyCommand(args = {}, _opts = {}) {
|
|
334
383
|
return runHcloud(args.args || [], {
|
|
@@ -371,7 +420,10 @@ const listOperationsSchema = z.looseObject({
|
|
|
371
420
|
const runApprovedCommandSchema = z.looseObject({
|
|
372
421
|
vendorConfirmed,
|
|
373
422
|
args: stringArrayArg.describe('hcloud arguments, excluding the hcloud executable.'),
|
|
374
|
-
approvalToken: z
|
|
423
|
+
approvalToken: z
|
|
424
|
+
.string()
|
|
425
|
+
.optional()
|
|
426
|
+
.describe('Required in token-approval mode (from huaweicloud_plan_cli_command); omit in ask mode where the harness client confirms at run time.'),
|
|
375
427
|
approvedByUser: booleanArg.describe('Must be true only after the user explicitly approves this exact command.'),
|
|
376
428
|
timeoutMs: numericArg.optional().describe('Optional timeout in milliseconds. Defaults to 60000.'),
|
|
377
429
|
maxRetries: numericArg.optional().describe('Optional retry count for transient network errors. Defaults to 1.'),
|
|
@@ -391,7 +443,7 @@ export const HUAWEICLOUD_CLI_TOOLS = [
|
|
|
391
443
|
},
|
|
392
444
|
{
|
|
393
445
|
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
|
|
446
|
+
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 — 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
447
|
schema: planCliCommandSchema,
|
|
396
448
|
handler: handlePlanCliCommand,
|
|
397
449
|
},
|
|
@@ -409,7 +461,7 @@ export const HUAWEICLOUD_CLI_TOOLS = [
|
|
|
409
461
|
},
|
|
410
462
|
{
|
|
411
463
|
name: 'huaweicloud_run_approved_command',
|
|
412
|
-
description:
|
|
464
|
+
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 harness client's permission prompt on this call is the confirmation: pass the same args with approvedByUser: true and no approvalToken. Vendor-gated (vendorConfirmed): call only when the vendor is established — see the vendorConfirmed parameter description; when unknown, ask which cloud the user means first.",
|
|
413
465
|
schema: runApprovedCommandSchema,
|
|
414
466
|
handler: handleRunApprovedCommand,
|
|
415
467
|
},
|
|
@@ -25,6 +25,7 @@ import { queryDistTagsFetch, determineTarget, semverCompare } from "./update-che
|
|
|
25
25
|
import { getKooCliVersion, compareVersion, kooCliDownloadBase } from "./koocli-version.js";
|
|
26
26
|
import { hcloudProbeNextStep, hcloudProbeRaw, probeHcloud } from "./hcloud-probe.js";
|
|
27
27
|
import { asRecord } from "./lib/as-record.js";
|
|
28
|
+
import { devkitStateBase, displayStatePath, huaweiConfigBase, probeWritableDir } from "./lib/state-dir.js";
|
|
28
29
|
import { DEPENDENCIES, DEPENDENCY_IDS, requiredDependencies } from "./lib/dependency-model.js";
|
|
29
30
|
import { resolveDependencyCommand } from "./lib/dep-resolve.js";
|
|
30
31
|
// The installer's payload machinery: file ops, server payload placement,
|
|
@@ -64,7 +65,7 @@ import { codexDesktopStatus, codexSectionStatus, codexStatus, hasCodexCLI, insta
|
|
|
64
65
|
import { codexDesktopDoctorMcpConfigured, deployCodexDesktop, uninstallCodexDesktop } from "./agents/codex-desktop.js";
|
|
65
66
|
import { deployDsh, dshStatus, uninstallDsh } from "./agents/dsh.js";
|
|
66
67
|
import { dshDoctorMcpConfigured, dshPayloadDoctorSection } from "./agents/dsh-patch.js";
|
|
67
|
-
import { deployOpenCode, opencodeDoctorMcpConfigured, opencodeDoctorSeam, opencodeStatus, uninstallOpenCode, } from "./agents/opencode.js";
|
|
68
|
+
import { deployOpenCode, opencodeDoctorAskRule, opencodeDoctorMcpConfigured, opencodeDoctorSeam, opencodeStatus, uninstallOpenCode, } from "./agents/opencode.js";
|
|
68
69
|
import { deployOpenClaw, openclawDoctorMcpConfigured, openclawStatus, uninstallOpenClaw } from "./agents/openclaw.js";
|
|
69
70
|
import { codeartsDoctorMcpConfigured, codeartsStatus, deployCodeArts, uninstallCodeArts } from "./agents/codearts.js";
|
|
70
71
|
import { codeartsWorkDoctorMcpConfigured, codeartsWorkStatus, deployCodeArtsWork, uninstallCodeArtsWork, } from "./agents/codearts-work.js";
|
|
@@ -765,6 +766,21 @@ async function cmdDoctor() {
|
|
|
765
766
|
const nodeParts = process.versions.node.split('.').map(Number);
|
|
766
767
|
const nodeOk = nodeParts[0] > 22 || (nodeParts[0] === 22 && nodeParts[1] >= 19);
|
|
767
768
|
check('Node.js >= 22.19', nodeOk, 'Run: nvm install 22.19 && nvm use 22.19');
|
|
769
|
+
// State directory — gateway pack state, approval tokens, S1 writes and
|
|
770
|
+
// update state all write here. A read-only home falls back to an
|
|
771
|
+
// agent-owned dir (state-dir.ts); the fallback is a warning, not a failure.
|
|
772
|
+
const configBase = huaweiConfigBase();
|
|
773
|
+
const stateBase = devkitStateBase();
|
|
774
|
+
const stateDisplay = displayStatePath(stateBase);
|
|
775
|
+
if (stateBase === configBase) {
|
|
776
|
+
check(`State directory writable (${stateDisplay})`, probeWritableDir(stateBase), 'Fix permissions, or set HUAWEICLOUD_STATE_DIR to a writable path');
|
|
777
|
+
}
|
|
778
|
+
else if (probeWritableDir(stateBase)) {
|
|
779
|
+
ctx.warn(`State directory fallback: ${stateDisplay} (${displayStatePath(configBase)} is not writable; set HUAWEICLOUD_STATE_DIR to pin it)`);
|
|
780
|
+
}
|
|
781
|
+
else {
|
|
782
|
+
check(`State directory writable (${stateDisplay})`, false, 'Set HUAWEICLOUD_STATE_DIR to a writable path');
|
|
783
|
+
}
|
|
768
784
|
// MCP server — derived from the per-row doctor bindings (one membership
|
|
769
785
|
// table for every payload check in this doctor run). The bindings run the
|
|
770
786
|
// pure triple probes here; their native-freshness halves run late, after
|
|
@@ -854,10 +870,13 @@ async function cmdDoctor() {
|
|
|
854
870
|
}
|
|
855
871
|
const mcpConfigured = mcpCfgTarget !== null;
|
|
856
872
|
check('MCP configured', mcpConfigured, mcpCfgTarget ? `Found in ${mcpCfgTarget} config` : 'Run: npx huaweicloud-devkit install');
|
|
857
|
-
//
|
|
858
|
-
// agents/opencode.ts owns the per-glob kept/missing
|
|
873
|
+
// OpenCode-only installer seams — the skills-tree permission check (the
|
|
874
|
+
// section in agents/opencode.ts owns the per-glob kept/missing
|
|
875
|
+
// evaluation) and the ASK approval posture check (the same file owns the
|
|
876
|
+
// client-rule/server-env pair evaluation).
|
|
859
877
|
if (installedPayload?.id === 'opencode') {
|
|
860
878
|
opencodeDoctorSeam(ctx);
|
|
879
|
+
opencodeDoctorAskRule(ctx);
|
|
861
880
|
}
|
|
862
881
|
// Hermes MCP Python SDK (only checked when Hermes config is found).
|
|
863
882
|
hermesDoctorSdkCheck(ctx, mcpCfgTarget);
|
|
@@ -142,6 +142,21 @@ export function getToolSchema(name) {
|
|
|
142
142
|
export function toolSchemaEntries() {
|
|
143
143
|
return Object.entries(TOOL_SCHEMAS);
|
|
144
144
|
}
|
|
145
|
+
const argKeyCache = new Map();
|
|
146
|
+
// The keys a tool's input schema declares, plus the central vendorConfirmed
|
|
147
|
+
// part (rendered only on cloud-facing tools but accepted by the dispatch gate
|
|
148
|
+
// everywhere). callTool's unknown-parameter warning reads this; the #530
|
|
149
|
+
// pass-through leniency itself is unchanged.
|
|
150
|
+
export function toolArgKeys(name) {
|
|
151
|
+
const cached = argKeyCache.get(name);
|
|
152
|
+
if (cached)
|
|
153
|
+
return cached;
|
|
154
|
+
const def = TOOL_SCHEMAS[name]._zod?.def;
|
|
155
|
+
const keys = new Set(Object.keys(def?.shape ?? {}));
|
|
156
|
+
keys.add('vendorConfirmed');
|
|
157
|
+
argKeyCache.set(name, keys);
|
|
158
|
+
return keys;
|
|
159
|
+
}
|
|
145
160
|
// Runtime guard: every entry must be a constructed zod loose-object. A bare
|
|
146
161
|
// raw shape would be wrapped by the SDK into STRIP semantics, silently
|
|
147
162
|
// dropping client keys instead of passing them through.
|
|
@@ -25,12 +25,14 @@ import { PACK_TOOL_HANDLERS, isPackToolName } from "./packs/registry.js";
|
|
|
25
25
|
// the build-time --check stray scan, and validate-package's skill gate all
|
|
26
26
|
// hold one membership predicate (dir-or-symlink with a SKILL.md).
|
|
27
27
|
import { listSkillDirs } from "./lib/skill-tree.js";
|
|
28
|
+
import { attachParamWarnings, unknownParamWarnings } from "./lib/param-warnings.js";
|
|
28
29
|
import { recordToolCall, traceEnabled } from "./lib/call-trace.js";
|
|
29
30
|
// The tool name/description registry (TOOL_DEFINITIONS_LITERALS and its
|
|
30
31
|
// derived types) lives in tool-definitions.ts; this module keeps the
|
|
31
32
|
// re-export face every importer (mcp-protocol, tests, scripts) already
|
|
32
33
|
// targets — same exported names, same import path, same behavior.
|
|
33
34
|
import { TOOL_DEFINITIONS } from "./tool-definitions.js";
|
|
35
|
+
import { toolArgKeys } from "./tool-schemas.js";
|
|
34
36
|
// The vendorConfirmed gate (VENDOR_GATED_TOOLS, the gate/challenge
|
|
35
37
|
// messages, and the once-per-session challenge state) lives in
|
|
36
38
|
// vendor-gate.ts; this module re-exports the roster for its existing
|
|
@@ -101,15 +103,19 @@ export async function callTool(name, rawArgs = {}, opts = {}) {
|
|
|
101
103
|
const args = normalizeNumericArgs(rawArgs);
|
|
102
104
|
const toolValue = toolInvokeValue(name, args);
|
|
103
105
|
trackToolInvoke(name, toolValue);
|
|
106
|
+
// Unknown keys stay accepted (#530 leniency) but are no longer silent: a
|
|
107
|
+
// typo'd optional parameter would otherwise return a default-shaped result
|
|
108
|
+
// the model reads as a successful filter.
|
|
109
|
+
const paramWarnings = unknownParamWarnings(args, toolArgKeys(name));
|
|
104
110
|
// Trace sits between normalization and dispatch: it records the shape
|
|
105
111
|
// the handler will actually see, and only calls that reached dispatch —
|
|
106
112
|
// SDK-level zod rejects never get here (see lib/call-trace.ts contract).
|
|
107
113
|
if (!traceEnabled())
|
|
108
|
-
return dispatchTool(name, args, opts);
|
|
114
|
+
return attachParamWarnings(await dispatchTool(name, args, opts), paramWarnings);
|
|
109
115
|
try {
|
|
110
116
|
const result = await dispatchTool(name, args, opts);
|
|
111
117
|
recordToolCall(name, args, true);
|
|
112
|
-
return result;
|
|
118
|
+
return attachParamWarnings(result, paramWarnings);
|
|
113
119
|
}
|
|
114
120
|
catch (error) {
|
|
115
121
|
recordToolCall(name, args, false, error);
|
|
@@ -180,11 +186,14 @@ function hookResult(result) {
|
|
|
180
186
|
ok: result.decision !== 'deny',
|
|
181
187
|
decision: result.decision,
|
|
182
188
|
findings: result.findings,
|
|
189
|
+
// allow means "no rule matched", never "approved": make that explicit so
|
|
190
|
+
// an agent cannot read a green advisory check as a safety verdict.
|
|
191
|
+
...(result.decision === 'allow' ? { unmatched: true } : {}),
|
|
183
192
|
nextStep: result.decision === 'deny'
|
|
184
193
|
? 'Revise the command, artifact, or deployment plan before execution.'
|
|
185
194
|
: result.decision === 'warn'
|
|
186
195
|
? 'Review the warnings with the user before proceeding.'
|
|
187
|
-
: 'No Huawei Cloud hook risk rule matched.',
|
|
196
|
+
: 'No Huawei Cloud hook risk rule matched. This is not a safety verdict or an approval.',
|
|
188
197
|
};
|
|
189
198
|
}
|
|
190
199
|
// The advisory command face used to answer a bare allow for an hcloud command
|
|
@@ -199,7 +208,10 @@ function hookResult(result) {
|
|
|
199
208
|
// cn hint, and a real service or a missing catalog keeps the original wording.
|
|
200
209
|
// The run faces stay allow for everything but the triage's negative-evidence
|
|
201
210
|
// deny (refined at planHcloudCommand, which the run engine asserts), and the
|
|
202
|
-
// PreToolUse hook is untouched (it acts on deny alone).
|
|
211
|
+
// PreToolUse hook is untouched (it acts on deny alone). The same face upgrades
|
|
212
|
+
// classified write/execution operations to hwc-write-operation: the advisory
|
|
213
|
+
// signal that a write needs the plan + approval path, never an execution
|
|
214
|
+
// block (run_readonly_command and the approval chain own that decision).
|
|
203
215
|
// `classify` is injectable so the OBS-14-shape closure is honestly pinnable:
|
|
204
216
|
// a classifier crash used to fall through to the bare allow (silent fail-open,
|
|
205
217
|
// the #564 shape one layer up); it now degrades to an hwc-unverified-command
|
|
@@ -227,6 +239,18 @@ const unverifiedFinding = (command) => ({
|
|
|
227
239
|
source: 'command',
|
|
228
240
|
evidence: command.slice(0, 240),
|
|
229
241
|
});
|
|
242
|
+
const writeOperationFinding = (command) => ({
|
|
243
|
+
ruleId: 'hwc-write-operation',
|
|
244
|
+
title: 'Write or execution operation',
|
|
245
|
+
category: 'approval',
|
|
246
|
+
severity: 'warn',
|
|
247
|
+
message: 'This command is classified as a write or execution operation. Raw shell execution is blocked; ' +
|
|
248
|
+
'writes require a plan and explicit user approval.',
|
|
249
|
+
remediation: 'Plan the exact command with huaweicloud_plan_cli_command, show it to the user, obtain explicit approval, ' +
|
|
250
|
+
'then run it with huaweicloud_run_approved_command and the approval token.',
|
|
251
|
+
source: 'command',
|
|
252
|
+
evidence: command.slice(0, 240),
|
|
253
|
+
});
|
|
230
254
|
export function withUnknownOperationWarn(command, result, classify = classifyTextCommand) {
|
|
231
255
|
if (result.decision !== 'allow' || result.findings.length > 0 || !command.trim())
|
|
232
256
|
return result;
|
|
@@ -237,6 +261,14 @@ export function withUnknownOperationWarn(command, result, classify = classifyTex
|
|
|
237
261
|
catch {
|
|
238
262
|
return { ...result, decision: 'warn', findings: [unverifiedFinding(command)] };
|
|
239
263
|
}
|
|
264
|
+
// The advisory face never turns a write into "safe": classified writes and
|
|
265
|
+
// execution operations get a warn even when the pattern catalog has no
|
|
266
|
+
// specific finding. The enforcement faces (run_readonly_command, the
|
|
267
|
+
// PreToolUse hook, the plan/run approval chain) are unchanged — this is
|
|
268
|
+
// the pre-flight signal, not the gate.
|
|
269
|
+
if (classification?.risk === 'write' || classification?.risk === 'execution') {
|
|
270
|
+
return { ...result, decision: 'warn', findings: [writeOperationFinding(command)] };
|
|
271
|
+
}
|
|
240
272
|
if (classification?.risk !== 'unknown_read')
|
|
241
273
|
return result;
|
|
242
274
|
const triage = triageUnknownService(classification.service);
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
// Skip-state (dismiss) persistence for the update machinery: the plugin-local
|
|
2
|
-
// skip file with per-session suffixing (#607), the
|
|
3
|
-
// and the atomic read/write pair. Part of the src/update-* family
|
|
4
|
-
// src/update-check.ts re-export face.
|
|
2
|
+
// skip file with per-session suffixing (#607), the writable-state-tree
|
|
3
|
+
// fallback, and the atomic read/write pair. Part of the src/update-* family
|
|
4
|
+
// behind the src/update-check.ts re-export face.
|
|
5
5
|
import { existsSync, readFileSync, writeFileSync, renameSync, mkdirSync, rmSync } from 'node:fs';
|
|
6
6
|
import { join, dirname, resolve } from 'node:path';
|
|
7
|
-
import { homedir } from 'node:os';
|
|
8
7
|
import { asText } from "./lib/as-text.js";
|
|
8
|
+
import { devkitStateBase } from "./lib/pack-state.js";
|
|
9
9
|
import { selfDir } from "./update-installed.js";
|
|
10
10
|
const COOLDOWN_DAYS = 3;
|
|
11
11
|
export function skipFilePath() {
|
|
12
12
|
return join(resolve(selfDir(), '..'), '.update-skip.json');
|
|
13
13
|
}
|
|
14
14
|
export function fallbackSkipFilePath() {
|
|
15
|
-
|
|
16
|
-
return join(base, '.config', 'huaweicloud', 'devkit-skip.json');
|
|
15
|
+
return join(devkitStateBase(), 'devkit-skip.json');
|
|
17
16
|
}
|
|
18
17
|
// 会话化 skip 文件:remote 多会话按 sessionId 拆分,stdio/默认保持原文件(向后兼容)。
|
|
19
18
|
function sanitizeSessionId(sessionId) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "huaweicloud-devkit",
|
|
3
3
|
"id": "huaweicloud-devkit",
|
|
4
4
|
"displayName": "HuaweiCloud DevKit",
|
|
5
|
-
"version": "2.0.0-next.
|
|
5
|
+
"version": "2.0.0-next.3",
|
|
6
6
|
"family": "bundle-plugin",
|
|
7
7
|
"bundleFormat": "codex",
|
|
8
8
|
"description": "Guide coding agents to use Huawei Cloud safely — KooCLI, APIs, SDKs, 40 MCP tools, skills, and safety guardrails.",
|
|
@@ -182,6 +182,61 @@
|
|
|
182
182
|
"message": "The artifact contains a literal access key, secret key, or security token. Credentials committed to IaC, config, or code leak through git history, logs, and state files.",
|
|
183
183
|
"remediation": "Remove the literal credential: reference it from environment variables, a DEW CSMS secret reference, or the platform credential vault (huaweicloud_secret_set), and rotate the exposed key immediately."
|
|
184
184
|
},
|
|
185
|
+
{
|
|
186
|
+
"id": "hwc-artifact-plaintext-password",
|
|
187
|
+
"title": "Plaintext password in artifact",
|
|
188
|
+
"category": "secret",
|
|
189
|
+
"severity": "warn",
|
|
190
|
+
"stages": ["artifact", "deploy_plan"],
|
|
191
|
+
"match": {
|
|
192
|
+
"any": [
|
|
193
|
+
{
|
|
194
|
+
"field": "text",
|
|
195
|
+
"regex": "[A-Za-z0-9_.-]*(?:password|passwd|pwd|secret)(?!://)[\"']?\\s*[:=]\\s*[\"']?(?!(?:<|\\$|%|\\{\\{|#\\{|secret://|var\\.|local\\.|module\\.|data\\.|each\\.|path\\.|terraform\\.|env\\.|os\\.environ|process\\.env|\\*{3,}|changeme|change_me|placeholder|example|xxx|none|N/A))[^\\s\"'<>]{3,}"
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
"field": "text",
|
|
199
|
+
"regex": "<(?:password|passwd|pwd)[^>]*>\\s*(?!(?:<|\\$|%|\\{\\{|#\\{|secret://|\\*{3,}|changeme|change_me|placeholder|example|xxx|none|N/A))[^<\\s][^<]{2,}\\s*</(?:password|passwd|pwd)>"
|
|
200
|
+
}
|
|
201
|
+
]
|
|
202
|
+
},
|
|
203
|
+
"message": "The artifact or plan carries what looks like a plaintext password or secret value.",
|
|
204
|
+
"remediation": "Replace the literal with a secret reference (DEW CSMS, huaweicloud_secret_set, ${VAR}, or var.<name>) and rotate any value that was committed."
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
"id": "hwc-container-privileged",
|
|
208
|
+
"title": "Privileged container",
|
|
209
|
+
"category": "container",
|
|
210
|
+
"severity": "deny",
|
|
211
|
+
"stages": ["artifact", "deploy_plan"],
|
|
212
|
+
"match": {
|
|
213
|
+
"any": [
|
|
214
|
+
{
|
|
215
|
+
"field": "text",
|
|
216
|
+
"regex": "\\bprivileged[\"']?\\s*[:=]\\s*[\"']?true\\b"
|
|
217
|
+
}
|
|
218
|
+
]
|
|
219
|
+
},
|
|
220
|
+
"message": "The manifest or plan runs a container with privileged: true (host devices and capabilities).",
|
|
221
|
+
"remediation": "Drop privileged mode. Grant only the specific capabilities the workload needs (capabilities.add) and run as a non-root user."
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
"id": "hwc-container-privilege-escalation",
|
|
225
|
+
"title": "Container privilege escalation allowed",
|
|
226
|
+
"category": "container",
|
|
227
|
+
"severity": "warn",
|
|
228
|
+
"stages": ["artifact", "deploy_plan"],
|
|
229
|
+
"match": {
|
|
230
|
+
"any": [
|
|
231
|
+
{
|
|
232
|
+
"field": "text",
|
|
233
|
+
"regex": "\\ballowPrivilegeEscalation[\"']?\\s*[:=]\\s*[\"']?true\\b"
|
|
234
|
+
}
|
|
235
|
+
]
|
|
236
|
+
},
|
|
237
|
+
"message": "The manifest allows a process to gain more privileges than its parent (allowPrivilegeEscalation: true).",
|
|
238
|
+
"remediation": "Set allowPrivilegeEscalation: false and runAsNonRoot: true unless the workload provably requires escalation."
|
|
239
|
+
},
|
|
185
240
|
{
|
|
186
241
|
"id": "hwc-obs-anonymous-write",
|
|
187
242
|
"title": "OBS anonymous write",
|
|
@@ -244,17 +299,38 @@
|
|
|
244
299
|
},
|
|
245
300
|
{
|
|
246
301
|
"field": "text",
|
|
247
|
-
"regex": "(\\\"Action\\\"\\s*:\\s*(\\\"(\\*|\\*:\\*)\\\"|\\[\\s*\\\"(\\*|\\*:\\*)\\\")|Action\\s*[=:]\\s*(\\*|\\*:\\*)|AdministratorAccess|FullAccess)"
|
|
302
|
+
"regex": "(\\\"Action\\\"\\s*:\\s*(\\\"(\\*|\\*:\\*)\\\"|\\[\\s*\\\"(\\*|\\*:\\*)\\\")|Action\\s*[=:]\\s*(\\*|\\*:\\*)|[\"']?actions?[\"']?\\s*[=:]\\s*(?:\\[\\s*)?[\"']?(?:\\*|\\*:\\*)|AdministratorAccess|FullAccess)"
|
|
248
303
|
},
|
|
249
304
|
{
|
|
250
305
|
"field": "text",
|
|
251
|
-
"regex": "(\\\"Effect\\\"\\s*:\\s*\\\"Allow\\\"|Effect\\s*[=:]\\s*Allow)"
|
|
306
|
+
"regex": "(\\\"Effect\\\"\\s*:\\s*\\\"Allow\\\"|Effect\\s*[=:]\\s*[\"']?Allow[\"']?)"
|
|
252
307
|
}
|
|
253
308
|
]
|
|
254
309
|
},
|
|
255
310
|
"message": "The change appears to grant broad administrator permissions.",
|
|
256
311
|
"remediation": "Use least-privilege service actions, resource constraints, and short-lived credentials for generated application workflows."
|
|
257
312
|
},
|
|
313
|
+
{
|
|
314
|
+
"id": "hwc-iam-wildcard-action",
|
|
315
|
+
"title": "Wildcard IAM action",
|
|
316
|
+
"category": "iam",
|
|
317
|
+
"severity": "warn",
|
|
318
|
+
"stages": ["command", "artifact", "deploy_plan"],
|
|
319
|
+
"match": {
|
|
320
|
+
"all": [
|
|
321
|
+
{
|
|
322
|
+
"field": "text",
|
|
323
|
+
"regex": "(IAM|policy|role|agency|Statement|Action|actions)"
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
"field": "text",
|
|
327
|
+
"regex": "[\"']?(?:Action|actions?)[\"']?\\s*[:=]\\s*(?:\\[\\s*)?[\"']?(?:\\*|\\*:\\*)[\"']?"
|
|
328
|
+
}
|
|
329
|
+
]
|
|
330
|
+
},
|
|
331
|
+
"message": "The IAM grant uses a wildcard action (* or *:*), which grants every operation on the matched resources.",
|
|
332
|
+
"remediation": "Replace the wildcard with the least-privilege service actions the workflow actually calls, and constrain the resources."
|
|
333
|
+
},
|
|
258
334
|
{
|
|
259
335
|
"id": "hwc-iam-highrisk-write",
|
|
260
336
|
"title": "High-risk IAM write operation",
|
|
@@ -99,10 +99,10 @@ curl -sSL https://cn-north-4-hdn-koocli.obs.cn-north-4.myhuaweicloud.com/cli/lat
|
|
|
99
99
|
- Read-only: `List*`, `Show*`, `Get*`, `Describe*`.
|
|
100
100
|
- Write: `Create*`, `Delete*`, `Update*`, `Resize*`, `Start*`, `Stop*`, `Authorize*`, and similar.
|
|
101
101
|
- Secret: any operation returning secret string, binary secret, token, or password.
|
|
102
|
-
9. For write operations, follow the
|
|
103
|
-
- Call `huaweicloud_plan_cli_command` and read `userConfirmation`. When `needed` is true, show the user the command echo
|
|
104
|
-
-
|
|
105
|
-
-
|
|
102
|
+
9. For write operations, follow the approval contract:
|
|
103
|
+
- Call `huaweicloud_plan_cli_command` and read `userConfirmation`. When `needed` is true, show the user the command echo.
|
|
104
|
+
- Token mode (the default): show the `userConfirmation.command` line; the user runs `npx huaweicloud-devkit approve <approvalToken>` in their own terminal. Never run it yourself. First use: the user runs `npx huaweicloud-devkit pin` once in their own terminal to enroll the approvals PIN. Then call `huaweicloud_run_approved_command` with that token; an unconfirmed non-read command is rejected with `USER_CONFIRMATION_REQUIRED`, and the token stays usable, so retry the same call after the user confirms.
|
|
105
|
+
- Ask mode (`userConfirmation.mode` is `ask`): no terminal line and no token — call `huaweicloud_run_approved_command` with the same args and `approvedByUser: true`; the harness client prompts the user on that call, and that prompt is the confirmation.
|
|
106
106
|
|
|
107
107
|
## KooCLI Syntax Notes
|
|
108
108
|
|
|
@@ -23,7 +23,7 @@ Use this skill before any Huawei Cloud action that may expose secrets, change re
|
|
|
23
23
|
- IAM/security
|
|
24
24
|
- cost/payment
|
|
25
25
|
- public exposure
|
|
26
|
-
5. For any non-read-only operation, follow the plan, confirm, run contract: plan with `huaweicloud_plan_cli_command`, show the user the command
|
|
26
|
+
5. For any non-read-only operation, follow the plan, confirm, run contract: plan with `huaweicloud_plan_cli_command`, show the user the command, then run with `huaweicloud_run_approved_command`. The confirm step follows the plan's `userConfirmation`: by default (token mode) show the terminal confirmation line and wait for the user to run it in their own terminal; when `userConfirmation.mode` is `ask`, call the run tool directly — the harness client prompts the user on that call. See `references/approvals.md`.
|
|
27
27
|
6. Redact secrets from command output, errors, JSON, logs, and generated reports.
|
|
28
28
|
7. If a command contains `adminPass`, `password`, token, or any secret-like field, warn that plaintext can remain in shell history. Prefer local-only input, runtime injection, or user-side execution.
|
|
29
29
|
|
|
@@ -35,13 +35,14 @@ Use this skill before any Huawei Cloud action that may expose secrets, change re
|
|
|
35
35
|
|
|
36
36
|
## Write Execution Boundary
|
|
37
37
|
|
|
38
|
-
1. Plan: call `huaweicloud_plan_cli_command`. The result echoes the exact command and carries `userConfirmation: { needed, command }`.
|
|
39
|
-
2. Confirm: when `needed` is true, show the user the plan echo and the `userConfirmation.command` line (`npx huaweicloud-devkit approve <approvalToken>`), then wait. The USER runs that line in their own terminal, where a TTY check and a PIN gate the confirmation. First use: the user runs `npx huaweicloud-devkit pin` once in their own terminal to enroll the PIN.
|
|
40
|
-
3.
|
|
38
|
+
1. Plan: call `huaweicloud_plan_cli_command`. The result echoes the exact command and carries `userConfirmation: { needed, command }` in the default token mode, or `userConfirmation: { needed, mode: "ask", note }` when the plan ran under `DEVKIT_APPROVAL_MODE=ask`.
|
|
39
|
+
2. Confirm (token mode, the default): when `needed` is true, show the user the plan echo and the `userConfirmation.command` line (`npx huaweicloud-devkit approve <approvalToken>`), then wait. The USER runs that line in their own terminal, where a TTY check and a PIN gate the confirmation. First use: the user runs `npx huaweicloud-devkit pin` once in their own terminal to enroll the PIN.
|
|
40
|
+
3. Confirm (ask mode): when `userConfirmation.mode` is `ask`, there is no terminal line and no token. Call `huaweicloud_run_approved_command` with the same args and `approvedByUser: true`; the harness client prompts the user on that call, and that prompt IS the confirmation.
|
|
41
|
+
4. Run: call `huaweicloud_run_approved_command` with the same `args` and `approvedByUser: true`, plus the plan's `approvalToken` in token mode — no token in ask mode.
|
|
41
42
|
|
|
42
|
-
|
|
43
|
+
In token mode, a non-read command without that terminal confirmation is rejected with `USER_CONFIRMATION_REQUIRED`. The refusal does not consume the token, so retry the same call after the user confirms. Re-running a write needs a fresh plan and a fresh confirmation. In ask mode there is no token to refuse or consume; a retried call prompts the user again.
|
|
43
44
|
|
|
44
|
-
Never run the approve or pin commands yourself; the hook denies both verbs on the agent's Bash face. The `approvedByUser: true` argument is not the terminal confirmation and never replaces it.
|
|
45
|
+
Never run the approve or pin commands yourself; the hook denies both verbs on the agent's Bash face. The `approvedByUser: true` argument is not the terminal confirmation and never replaces it (in ask mode the harness client's own prompt is the confirmation the server trusts).
|
|
45
46
|
|
|
46
47
|
Without the devkit tools, show the reviewed command and let the user execute it in their own terminal. After a write, verify with `huaweicloud_run_readonly_command` or another read-only check.
|
|
47
48
|
|
|
@@ -64,6 +65,6 @@ Hook checks inspect the command or plan text that is available before execution.
|
|
|
64
65
|
- Use redacted profile inspection instead of raw `hcloud configure show`.
|
|
65
66
|
- Use runtime secret injection instead of fetching secret values into chat.
|
|
66
67
|
- Use the encrypted secret vault for durable secrets: store values as `secret://<scope>/<name>` refs and pass refs, never values. See `references/secrets.md`.
|
|
67
|
-
- Use the
|
|
68
|
+
- Use the approval contract for writes: plan, user confirm, run — token mode by default, the harness client's permission prompt when `DEVKIT_APPROVAL_MODE=ask`. See `references/approvals.md`.
|
|
68
69
|
- Use read-only verification after a write.
|
|
69
70
|
- Prefer reviewed IaC for durable infrastructure changes.
|
|
@@ -33,6 +33,16 @@ The confirmation authorizes one execution of one command.
|
|
|
33
33
|
- A run result's plan is minted without a token, so it never carries a usable approval. Re-running the command needs a fresh `huaweicloud_plan_cli_command` call and a fresh terminal confirmation.
|
|
34
34
|
- Changing the arguments rejects the run, because the token pins the exact command hash and any real secret values in it.
|
|
35
35
|
|
|
36
|
+
## Ask mode (DEVKIT_APPROVAL_MODE=ask)
|
|
37
|
+
|
|
38
|
+
An alternative posture where the confirmation happens in the harness client's own permission prompt instead of the terminal. The plan mints no token and its `userConfirmation` carries `{ needed: true, mode: "ask", note }` instead of a `command` line; `huaweicloud_run_approved_command` needs only the same `args` plus `approvedByUser: true` — the client's prompt on that call IS the user's confirmation.
|
|
39
|
+
|
|
40
|
+
The operator opts in; it is never the default. On OpenCode the installer (at or above 2.0) writes a top-level `permissions` array entry with effect `ask` for the `huaweicloud-devkit_huaweicloud_run_approved_command` action, plus `DEVKIT_APPROVAL_MODE=ask` in the mcp entry's environment, so the client half and the server half move together — the rule without the env double-gates (the client prompts AND the server still demands a token), the env without the rule fail-opens (the server trusts a prompt nobody shows). On other harnesses the operator sets `DEVKIT_APPROVAL_MODE=ask` in the server environment themselves; Claude Code needs no permission rule because the run tool declares `_meta` `anthropic/requiresUserInteraction` and the client prompts on every call.
|
|
41
|
+
|
|
42
|
+
What changes: no approval token, no UUID in the model's context, no 5-minute TTL, and no single-use replay guard — a retried or repeated call simply prompts the user again. The PIN and TTY checks do not apply; the client's own prompt UI is the gate. `approvedByUser: true` is still required and still means the user approved this exact command.
|
|
43
|
+
|
|
44
|
+
Honest trust boundary: the evidence is the client prompt itself — a harness without a per-tool prompt (or one whose permission system auto-approves) would execute without any user confirmation, which is why the mode is opt-in and the pair must stay whole. OpenCode's "Allow always" answer to the prompt saves an `allow` rule on the same action that removes the gate from then on — `npx huaweicloud-devkit doctor` fails that state; delete the rule or set its effect back to `ask`. The remote transport refuses ask mode outright and forces token mode. Token mode remains the default and the fallback for harnesses without a per-tool prompt.
|
|
45
|
+
|
|
36
46
|
## What the agent must not do
|
|
37
47
|
|
|
38
48
|
- Never run `npx huaweicloud-devkit approve` or `npx huaweicloud-devkit pin` yourself, in any spelling. The confirmation's value is that the user's own terminal records it, and the safety hook denies both verbs on the agent Bash face for exactly that reason.
|
|
@@ -12,6 +12,7 @@ import { mergeCommandStyle, applyUserDelta, inheritPeerUserEnv } from '../mcp-co
|
|
|
12
12
|
import { takeAgentDelta } from '../mcp-config-backup.ts';
|
|
13
13
|
import { printMcpConfigStatus, readJsonRecord, removeMcpServerEntry, writeMcpSettingsFile } from '../mcp-config-io.ts';
|
|
14
14
|
import { asRecord } from '../lib/as-record.ts';
|
|
15
|
+
import { stateDirNotice } from '../lib/state-dir.ts';
|
|
15
16
|
import {
|
|
16
17
|
copyServerPayload,
|
|
17
18
|
installRuntimeDeps,
|
|
@@ -112,6 +113,8 @@ export async function deployCodeArtsWork(_mode: DeployMode): Promise<void> {
|
|
|
112
113
|
const pluginDest = codeartsWorkPluginsDir();
|
|
113
114
|
|
|
114
115
|
copyServerPayload(pluginDest);
|
|
116
|
+
const stateNotice = stateDirNotice();
|
|
117
|
+
if (stateNotice) console.log(` [CodeArts Work] ${stateNotice}`);
|
|
115
118
|
registerCodeartsWorkMcp();
|
|
116
119
|
|
|
117
120
|
installRuntimeDeps(pluginDest);
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
} from '../targets.ts';
|
|
15
15
|
import { findHcloudBin } from '../hcloud-probe.ts';
|
|
16
16
|
import { asRecord } from '../lib/as-record.ts';
|
|
17
|
+
import { stateDirNotice } from '../lib/state-dir.ts';
|
|
17
18
|
import { ensureMcpServersConfig, printMcpConfigStatus, removeMcpServerEntry } from '../mcp-config-io.ts';
|
|
18
19
|
import {
|
|
19
20
|
PACKAGE_ROOT,
|
|
@@ -54,6 +55,9 @@ export async function deployCodeArts(mode: DeployMode): Promise<void> {
|
|
|
54
55
|
|
|
55
56
|
copyServerPayload(pluginDest);
|
|
56
57
|
|
|
58
|
+
const stateNotice = stateDirNotice();
|
|
59
|
+
if (stateNotice) console.log(` [CodeArts] ${stateNotice}`);
|
|
60
|
+
|
|
57
61
|
const codeartsHookDir = join(homedir(), '.codeartsdoer', 'plugins');
|
|
58
62
|
mkdirSync(codeartsHookDir, { recursive: true });
|
|
59
63
|
copyFileSync(pluginSrc, join(codeartsHookDir, 'skill-tracker.js'));
|