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
|
@@ -36,12 +36,14 @@ import { PACK_TOOL_HANDLERS, isPackToolName, type PackToolName } from './packs/r
|
|
|
36
36
|
// the build-time --check stray scan, and validate-package's skill gate all
|
|
37
37
|
// hold one membership predicate (dir-or-symlink with a SKILL.md).
|
|
38
38
|
import { listSkillDirs } from './lib/skill-tree.ts';
|
|
39
|
+
import { attachParamWarnings, unknownParamWarnings } from './lib/param-warnings.ts';
|
|
39
40
|
import { recordToolCall, traceEnabled } from './lib/call-trace.ts';
|
|
40
41
|
// The tool name/description registry (TOOL_DEFINITIONS_LITERALS and its
|
|
41
42
|
// derived types) lives in tool-definitions.ts; this module keeps the
|
|
42
43
|
// re-export face every importer (mcp-protocol, tests, scripts) already
|
|
43
44
|
// targets — same exported names, same import path, same behavior.
|
|
44
45
|
import { TOOL_DEFINITIONS, type ToolName } from './tool-definitions.ts';
|
|
46
|
+
import { toolArgKeys } from './tool-schemas.ts';
|
|
45
47
|
// The vendorConfirmed gate (VENDOR_GATED_TOOLS, the gate/challenge
|
|
46
48
|
// messages, and the once-per-session challenge state) lives in
|
|
47
49
|
// vendor-gate.ts; this module re-exports the roster for its existing
|
|
@@ -237,15 +239,19 @@ export async function callTool(name: ToolName, rawArgs: ToolArgs = {}, opts: Cal
|
|
|
237
239
|
const args = normalizeNumericArgs(rawArgs);
|
|
238
240
|
const toolValue = toolInvokeValue(name, args);
|
|
239
241
|
trackToolInvoke(name, toolValue);
|
|
242
|
+
// Unknown keys stay accepted (#530 leniency) but are no longer silent: a
|
|
243
|
+
// typo'd optional parameter would otherwise return a default-shaped result
|
|
244
|
+
// the model reads as a successful filter.
|
|
245
|
+
const paramWarnings = unknownParamWarnings(args, toolArgKeys(name));
|
|
240
246
|
|
|
241
247
|
// Trace sits between normalization and dispatch: it records the shape
|
|
242
248
|
// the handler will actually see, and only calls that reached dispatch —
|
|
243
249
|
// SDK-level zod rejects never get here (see lib/call-trace.ts contract).
|
|
244
|
-
if (!traceEnabled()) return dispatchTool(name, args, opts);
|
|
250
|
+
if (!traceEnabled()) return attachParamWarnings(await dispatchTool(name, args, opts), paramWarnings);
|
|
245
251
|
try {
|
|
246
252
|
const result = await dispatchTool(name, args, opts);
|
|
247
253
|
recordToolCall(name, args, true);
|
|
248
|
-
return result;
|
|
254
|
+
return attachParamWarnings(result, paramWarnings);
|
|
249
255
|
} catch (error) {
|
|
250
256
|
recordToolCall(name, args, false, error);
|
|
251
257
|
throw error;
|
|
@@ -318,12 +324,15 @@ function hookResult(result: RiskEvaluation) {
|
|
|
318
324
|
ok: result.decision !== 'deny',
|
|
319
325
|
decision: result.decision,
|
|
320
326
|
findings: result.findings,
|
|
327
|
+
// allow means "no rule matched", never "approved": make that explicit so
|
|
328
|
+
// an agent cannot read a green advisory check as a safety verdict.
|
|
329
|
+
...(result.decision === 'allow' ? { unmatched: true } : {}),
|
|
321
330
|
nextStep:
|
|
322
331
|
result.decision === 'deny'
|
|
323
332
|
? 'Revise the command, artifact, or deployment plan before execution.'
|
|
324
333
|
: result.decision === 'warn'
|
|
325
334
|
? 'Review the warnings with the user before proceeding.'
|
|
326
|
-
: 'No Huawei Cloud hook risk rule matched.',
|
|
335
|
+
: 'No Huawei Cloud hook risk rule matched. This is not a safety verdict or an approval.',
|
|
327
336
|
};
|
|
328
337
|
}
|
|
329
338
|
|
|
@@ -339,7 +348,10 @@ function hookResult(result: RiskEvaluation) {
|
|
|
339
348
|
// cn hint, and a real service or a missing catalog keeps the original wording.
|
|
340
349
|
// The run faces stay allow for everything but the triage's negative-evidence
|
|
341
350
|
// deny (refined at planHcloudCommand, which the run engine asserts), and the
|
|
342
|
-
// PreToolUse hook is untouched (it acts on deny alone).
|
|
351
|
+
// PreToolUse hook is untouched (it acts on deny alone). The same face upgrades
|
|
352
|
+
// classified write/execution operations to hwc-write-operation: the advisory
|
|
353
|
+
// signal that a write needs the plan + approval path, never an execution
|
|
354
|
+
// block (run_readonly_command and the approval chain own that decision).
|
|
343
355
|
// `classify` is injectable so the OBS-14-shape closure is honestly pinnable:
|
|
344
356
|
// a classifier crash used to fall through to the bare allow (silent fail-open,
|
|
345
357
|
// the #564 shape one layer up); it now degrades to an hwc-unverified-command
|
|
@@ -372,6 +384,21 @@ const unverifiedFinding = (command: string): RiskFinding => ({
|
|
|
372
384
|
evidence: command.slice(0, 240),
|
|
373
385
|
});
|
|
374
386
|
|
|
387
|
+
const writeOperationFinding = (command: string): RiskFinding => ({
|
|
388
|
+
ruleId: 'hwc-write-operation',
|
|
389
|
+
title: 'Write or execution operation',
|
|
390
|
+
category: 'approval',
|
|
391
|
+
severity: 'warn',
|
|
392
|
+
message:
|
|
393
|
+
'This command is classified as a write or execution operation. Raw shell execution is blocked; ' +
|
|
394
|
+
'writes require a plan and explicit user approval.',
|
|
395
|
+
remediation:
|
|
396
|
+
'Plan the exact command with huaweicloud_plan_cli_command, show it to the user, obtain explicit approval, ' +
|
|
397
|
+
'then run it with huaweicloud_run_approved_command and the approval token.',
|
|
398
|
+
source: 'command',
|
|
399
|
+
evidence: command.slice(0, 240),
|
|
400
|
+
});
|
|
401
|
+
|
|
375
402
|
export function withUnknownOperationWarn(
|
|
376
403
|
command: string,
|
|
377
404
|
result: RiskEvaluation,
|
|
@@ -384,6 +411,14 @@ export function withUnknownOperationWarn(
|
|
|
384
411
|
} catch {
|
|
385
412
|
return { ...result, decision: 'warn', findings: [unverifiedFinding(command)] };
|
|
386
413
|
}
|
|
414
|
+
// The advisory face never turns a write into "safe": classified writes and
|
|
415
|
+
// execution operations get a warn even when the pattern catalog has no
|
|
416
|
+
// specific finding. The enforcement faces (run_readonly_command, the
|
|
417
|
+
// PreToolUse hook, the plan/run approval chain) are unchanged — this is
|
|
418
|
+
// the pre-flight signal, not the gate.
|
|
419
|
+
if (classification?.risk === 'write' || classification?.risk === 'execution') {
|
|
420
|
+
return { ...result, decision: 'warn', findings: [writeOperationFinding(command)] };
|
|
421
|
+
}
|
|
387
422
|
if (classification?.risk !== 'unknown_read') return result;
|
|
388
423
|
const triage = triageUnknownService(classification.service);
|
|
389
424
|
if (triage.cause === 'service-not-found' || triage.cause === 'lang-missing') {
|
|
@@ -1,12 +1,12 @@
|
|
|
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
|
|
|
9
8
|
import { asText } from './lib/as-text.ts';
|
|
9
|
+
import { devkitStateBase } from './lib/pack-state.ts';
|
|
10
10
|
import { selfDir } from './update-installed.ts';
|
|
11
11
|
|
|
12
12
|
const COOLDOWN_DAYS = 3;
|
|
@@ -22,8 +22,7 @@ export function skipFilePath(): string {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export function fallbackSkipFilePath(): string {
|
|
25
|
-
|
|
26
|
-
return join(base, '.config', 'huaweicloud', 'devkit-skip.json');
|
|
25
|
+
return join(devkitStateBase(), 'devkit-skip.json');
|
|
27
26
|
}
|
|
28
27
|
|
|
29
28
|
// 会话化 skip 文件:remote 多会话按 sessionId 拆分,stdio/默认保持原文件(向后兼容)。
|