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,6 +6,7 @@ import { isCredentialEnvVarName, SECRET_REF_PATTERN } from '../../lib/secret-vau
|
|
|
6
6
|
import { isCredentialFilePath } from '../../safety-policy.ts';
|
|
7
7
|
import type { PackToolDefinition, LooseToolSchema } from '../../lib/pack-types.ts';
|
|
8
8
|
import type { CallToolOptions, ToolArgs } from '../../tools.ts';
|
|
9
|
+
import { approvalTokenArg, approvedByUserArg } from '../../lib/tool-schema-parts.ts';
|
|
9
10
|
|
|
10
11
|
// The secrets pack: vault writes and inventory through MCP. There is
|
|
11
12
|
// deliberately NO value-retrieval tool — plaintext never crosses the MCP
|
|
@@ -105,6 +106,8 @@ const secretListSchema = z.looseObject({
|
|
|
105
106
|
|
|
106
107
|
const secretDeleteSchema = z.looseObject({
|
|
107
108
|
ref: secretRefField.describe('Vault ref to delete.'),
|
|
109
|
+
approvalToken: approvalTokenArg,
|
|
110
|
+
approvedByUser: approvedByUserArg,
|
|
108
111
|
});
|
|
109
112
|
|
|
110
113
|
export const SECRETS_TOOLS = [
|
|
@@ -125,7 +128,7 @@ export const SECRETS_TOOLS = [
|
|
|
125
128
|
{
|
|
126
129
|
name: 'huaweicloud_secret_delete',
|
|
127
130
|
description:
|
|
128
|
-
'Delete one secret from the local vault by ref. Idempotent: removed=1 when a secret was deleted, removed=0 when the ref was not stored (usually a typo in the ref — check with huaweicloud_secret_list).',
|
|
131
|
+
'Delete one secret from the local vault by ref. Destructive with no version history, so the approval gate mediates every call: in the default token mode a no-token call returns USER_CONFIRMATION_REQUIRED with the approve command line for the user\u2019s own terminal, and under DEVKIT_APPROVAL_MODE=ask the server raises the confirmation itself (form, or an ASK_CONFIRMATION_REQUIRED chat round-trip). Deleting a ref that S1 credentials.json points at breaks those credential reads until the operator re-stores it (the strict vault seam fails closed on the unresolvable ref). Idempotent: removed=1 when a secret was deleted, removed=0 when the ref was not stored (usually a typo in the ref — check with huaweicloud_secret_list).',
|
|
129
132
|
schema: secretDeleteSchema,
|
|
130
133
|
handler: handleSecretDelete,
|
|
131
134
|
},
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { hashArgs } from '../../lib/approval-tokens.ts';
|
|
2
|
+
import { redactSecrets } from '../../safety-policy.ts';
|
|
3
|
+
import { asString } from '../../lib/as-text.ts';
|
|
4
|
+
import { SUPPORTED_AGENT_TARGETS } from '../../auth/agent-registration.ts';
|
|
5
|
+
import type { ApprovalSpec } from '../../approval-types.ts';
|
|
6
|
+
import type { ToolArgs } from '../../tools.ts';
|
|
7
|
+
|
|
8
|
+
// The update pack's approval registration (PR-3c): huaweicloud_upgrade is
|
|
9
|
+
// ALWAYS gated — it replaces the package on disk for every installed
|
|
10
|
+
// target, which redirects every later tool call onto code the operator
|
|
11
|
+
// never reviewed, so the trunk's description-level consent line
|
|
12
|
+
// ("执行前必须先征得用户同意") becomes a mechanical gate. The binding is
|
|
13
|
+
// the {target, version} projection (never the gate fields), so the
|
|
14
|
+
// confirmation pins exactly what will be upgraded. check_update stays
|
|
15
|
+
// unregistered: it is the read-only face of the pair.
|
|
16
|
+
//
|
|
17
|
+
// Interrogate round 2, finding 2 — display/binding integrity:
|
|
18
|
+
// (a) An ABSENT version normalizes to the literal 'latest' INSIDE the
|
|
19
|
+
// binding, so the value the popup displays is the value the token
|
|
20
|
+
// binds: the natural retry with version:'latest' (what the user read)
|
|
21
|
+
// hashes identically to the unversioned mint and executes, instead
|
|
22
|
+
// of mismatch-burning the token.
|
|
23
|
+
// (b) assertArgsExecutable refuses every version shape the handler's own
|
|
24
|
+
// chain refuses (upgradePackage accepts 'latest' only): a concrete
|
|
25
|
+
// version and an empty string never mint a doomed approval.
|
|
26
|
+
// (c) 'latest' names the CHANNEL, not an artifact: the handler elects
|
|
27
|
+
// the actual tag after consent (a stable current → @latest, a
|
|
28
|
+
// prerelease current → @next). The summarize view says so. Residual,
|
|
29
|
+
// recorded: the tag can move between consent and execution (a
|
|
30
|
+
// registry publish lands mid-cycle); the consent pins the channel
|
|
31
|
+
// and the target, never the resolved artifact.
|
|
32
|
+
//
|
|
33
|
+
// Interrogate round 3, finding — the target half of the same doctrine:
|
|
34
|
+
// (a) An absent AND an empty target normalize to the literal 'all'
|
|
35
|
+
// (the handler's own default for both), so the displayed '(target
|
|
36
|
+
// all)' is the bound value and the natural retry with target:'all'
|
|
37
|
+
// consumes instead of mismatch-burning the confirmed token.
|
|
38
|
+
// (b) assertArgsExecutable also refuses targets outside the handler's
|
|
39
|
+
// SUPPORTED_AGENT_TARGETS allowlist (upgradePackage answers
|
|
40
|
+
// '不支持的升级目标' after the gate, review #717's shell-interpolation
|
|
41
|
+
// guard), so a bogus or case-variant target never mints a doomed
|
|
42
|
+
// approval.
|
|
43
|
+
function upgradeBinding(args: ToolArgs): Record<string, unknown> {
|
|
44
|
+
return {
|
|
45
|
+
target: args.target === undefined || args.target === '' ? 'all' : args.target,
|
|
46
|
+
version: args.version === undefined ? 'latest' : args.version,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function assertUpgradeExecutable(value: unknown): void {
|
|
51
|
+
const { target, version } = value as { target?: unknown; version?: unknown };
|
|
52
|
+
if (version !== 'latest') {
|
|
53
|
+
throw new Error(
|
|
54
|
+
`version must be "latest" (got ${JSON.stringify(version)}): the handler elects the actual dist tag from the channel. Send version: "latest" or omit it.`,
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
const targetStr = String(target);
|
|
58
|
+
if (targetStr !== 'all' && !SUPPORTED_AGENT_TARGETS.includes(targetStr)) {
|
|
59
|
+
throw new Error(`不支持的升级目标:${targetStr}(有效目标:all,或 ${SUPPORTED_AGENT_TARGETS.join(', ')} 之一)`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export const UPDATE_APPROVAL_SPECS: Readonly<Record<'huaweicloud_upgrade', ApprovalSpec>> = {
|
|
64
|
+
huaweicloud_upgrade: {
|
|
65
|
+
domain: 'update',
|
|
66
|
+
flavor: 'always',
|
|
67
|
+
tokenSource: 'gate',
|
|
68
|
+
normalizeArgs: upgradeBinding,
|
|
69
|
+
assertArgsExecutable: assertUpgradeExecutable,
|
|
70
|
+
// The view folds through the shared redaction vocabulary before any
|
|
71
|
+
// field reaches the summary or pin view (the ApprovalSpec contract:
|
|
72
|
+
// never the raw argument stream); the hash binds the raw content —
|
|
73
|
+
// here the normalized content, so the displayed value IS the bound
|
|
74
|
+
// value.
|
|
75
|
+
summarize: (value) => {
|
|
76
|
+
const safe = redactSecrets(value) as { target?: unknown; version?: unknown };
|
|
77
|
+
return {
|
|
78
|
+
summary:
|
|
79
|
+
`huaweicloud_upgrade: upgrade huaweicloud-devkit to version ${asString(safe.version) ?? 'latest'} ` +
|
|
80
|
+
`(target ${asString(safe.target) ?? 'all'}) — "latest" names the channel: the handler elects the stable ` +
|
|
81
|
+
'or prerelease dist tag (a stable current upgrades to @latest, a prerelease current to @next) after consent',
|
|
82
|
+
argsHash: hashArgs(value),
|
|
83
|
+
pinView: safe,
|
|
84
|
+
};
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
};
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
} from '../../update-check.ts';
|
|
14
14
|
import type { PackToolDefinition, LooseToolSchema } from '../../lib/pack-types.ts';
|
|
15
15
|
import type { CallToolOptions, ToolArgs } from '../../tools.ts';
|
|
16
|
+
import { approvalTokenArg, approvedByUserArg } from '../../lib/tool-schema-parts.ts';
|
|
16
17
|
|
|
17
18
|
// Handlers migrated verbatim from src/tools.ts; the doQuery injection seam on
|
|
18
19
|
// CallToolOptions is passed through unchanged (test/upgrade-session.test.ts
|
|
@@ -69,6 +70,8 @@ const upgradeSchema = z.looseObject({
|
|
|
69
70
|
.string()
|
|
70
71
|
.optional()
|
|
71
72
|
.describe('agent 目标(opencode/codex/codearts/.../all)。缺省时用 all(仅更新已安装的)。'),
|
|
73
|
+
approvalToken: approvalTokenArg,
|
|
74
|
+
approvedByUser: approvedByUserArg,
|
|
72
75
|
});
|
|
73
76
|
|
|
74
77
|
export const UPDATE_TOOLS = [
|
|
@@ -81,8 +84,12 @@ export const UPDATE_TOOLS = [
|
|
|
81
84
|
},
|
|
82
85
|
{
|
|
83
86
|
name: 'huaweicloud_upgrade',
|
|
87
|
+
// The mechanical approval gate enforces the consent this line used to
|
|
88
|
+
// only ask for (PR-3c): token mode runs the approve command from the
|
|
89
|
+
// gate's rejection envelope in the user's own terminal, ask mode lets
|
|
90
|
+
// the server raise the confirmation itself.
|
|
84
91
|
description:
|
|
85
|
-
'升级 huaweicloud-devkit
|
|
92
|
+
'升级 huaweicloud-devkit 到最新版本。升级会改写磁盘上的插件本体,因此由审批门机械把关:默认 token 模式下,无 token 调用会返回 USER_CONFIRMATION_REQUIRED 与 approve 命令行,用户在自己的终端确认后才可重试;DEVKIT_APPROVAL_MODE=ask 时由服务器在调用内弹出确认(表单或聊天往返)。version 仅支持 "latest"。完成后需重启会话生效。',
|
|
86
93
|
schema: upgradeSchema,
|
|
87
94
|
handler: handleUpgrade,
|
|
88
95
|
},
|
|
@@ -71,7 +71,7 @@ export const VOUCHER_TOOLS = [
|
|
|
71
71
|
{
|
|
72
72
|
name: 'huaweicloud_voucher_status',
|
|
73
73
|
description:
|
|
74
|
-
'查询代金券领取状态。当会话已处于华为云任务上下文(用户已指明华为云,或先前轮次已确认)且用户首次使用或询问插件能力时,主动调用本工具检查:未领取(claimed=false)则主动提示可领取一张代金券;已领取(claimed=true
|
|
74
|
+
'查询代金券领取状态。当会话已处于华为云任务上下文(用户已指明华为云,或先前轮次已确认)且用户首次使用或询问插件能力时,主动调用本工具检查:未领取(claimed=false)则主动提示可领取一张代金券;已领取(claimed=true)则不提示、不打扰;claimed=false 且 code=HDKIT_VERSION_TOO_OLD 表示客户端版本过旧——转述 remediation 升级引导,绝不提示领券。厂商未定(用户未指明、上下文无法推断)时不要调用——先问用户用的是哪家云。',
|
|
75
75
|
schema: voucherStatusSchema,
|
|
76
76
|
handler: handleVoucherStatus,
|
|
77
77
|
},
|
|
@@ -22,6 +22,10 @@ import {
|
|
|
22
22
|
} from './packs/enable.ts';
|
|
23
23
|
import { PACK_IDS, type PackId } from './lib/pack-types.ts';
|
|
24
24
|
import { closePackEnablement } from './lib/dependency-model.ts';
|
|
25
|
+
import { hashArgs } from './lib/approval-tokens.ts';
|
|
26
|
+
import { redactSecrets } from './safety-policy.ts';
|
|
27
|
+
import { asString } from './lib/as-text.ts';
|
|
28
|
+
import type { ApprovalSpec } from './approval-types.ts';
|
|
25
29
|
|
|
26
30
|
export function configurePacks(args: ToolArgs, opts: CallToolOptions): unknown {
|
|
27
31
|
const enable = (args.enable ?? []).map((id) => String(id));
|
|
@@ -102,3 +106,74 @@ export function configurePacks(args: ToolArgs, opts: CallToolOptions): unknown {
|
|
|
102
106
|
: 'The requested surface already applies.',
|
|
103
107
|
};
|
|
104
108
|
}
|
|
109
|
+
|
|
110
|
+
// The packs_configure approval registration (PR-3c). ALWAYS gated, because
|
|
111
|
+
// widening the session's disclosure face is the actual consequence — an
|
|
112
|
+
// enabled pack materializes its tools and skills for every later call — and
|
|
113
|
+
// the summarize view names the exact ids so the confirmation surface shows
|
|
114
|
+
// the consequence itself. requiresSessionSeam mirrors this handler's own
|
|
115
|
+
// stdio-only refusal: the gate checks opts.onPacksChanged BEFORE engaging
|
|
116
|
+
// (the refusal lives here, downstream of any dispatch-layer gate), so a
|
|
117
|
+
// no-seam call refuses with no token minted and no ledger entry — the
|
|
118
|
+
// ordering the gate's precheck exists to enforce. The binding is the
|
|
119
|
+
// {enable, disable, reset} projection, never the gate fields.
|
|
120
|
+
export const PACKS_CONFIGURE_APPROVAL_SPEC: Readonly<ApprovalSpec> = {
|
|
121
|
+
domain: 'packs',
|
|
122
|
+
flavor: 'always',
|
|
123
|
+
tokenSource: 'gate',
|
|
124
|
+
requiresSessionSeam: true,
|
|
125
|
+
normalizeArgs: (args: ToolArgs): Record<string, unknown> => ({
|
|
126
|
+
enable: args.enable,
|
|
127
|
+
disable: args.disable,
|
|
128
|
+
reset: args.reset,
|
|
129
|
+
}),
|
|
130
|
+
summarize: (value) => {
|
|
131
|
+
// The view folds through the shared redaction vocabulary before any
|
|
132
|
+
// field reaches the summary or pin view (the ApprovalSpec contract);
|
|
133
|
+
// the hash binds the raw content.
|
|
134
|
+
const safe = redactSecrets(value) as { enable?: unknown; disable?: unknown; reset?: unknown };
|
|
135
|
+
const list = (ids: unknown): string =>
|
|
136
|
+
Array.isArray(ids) ? ids.map((id) => String(id)).join(', ') : (asString(ids) ?? '');
|
|
137
|
+
const parts: string[] = [];
|
|
138
|
+
if (Array.isArray(safe.enable) && safe.enable.length > 0) parts.push(`enable pack(s) ${list(safe.enable)}`);
|
|
139
|
+
if (Array.isArray(safe.disable) && safe.disable.length > 0) parts.push(`disable pack(s) ${list(safe.disable)}`);
|
|
140
|
+
if (safe.reset === true) parts.push('reset the session override (restore the operator DEVKIT_PACKS posture)');
|
|
141
|
+
if (parts.length === 0) parts.push('no-op: provide enable, disable, or reset');
|
|
142
|
+
return {
|
|
143
|
+
summary: `huaweicloud_packs_configure: ${parts.join('; ')}`,
|
|
144
|
+
argsHash: hashArgs(value),
|
|
145
|
+
pinView: safe,
|
|
146
|
+
};
|
|
147
|
+
},
|
|
148
|
+
// NoDoomedToken (interrogate round 2, fix-in-pass i): the handler's own
|
|
149
|
+
// five pure validations, hoisted BEFORE the mint — a shape the handler
|
|
150
|
+
// refuses would burn the user's approval on a guaranteed refusal, so it
|
|
151
|
+
// never mints. Message texts mirror the handler's exactly, so the two
|
|
152
|
+
// layers can never drift into different teachings; the handler keeps its
|
|
153
|
+
// own copies as the belt behind this floor.
|
|
154
|
+
assertArgsExecutable: (value: unknown): void => {
|
|
155
|
+
const { enable, disable, reset } = value as { enable?: unknown; disable?: unknown; reset?: unknown };
|
|
156
|
+
const enableIds = Array.isArray(enable) ? enable.map((id) => String(id)) : [];
|
|
157
|
+
const disableIds = Array.isArray(disable) ? disable.map((id) => String(id)) : [];
|
|
158
|
+
const resetIs = reset === true;
|
|
159
|
+
if (!resetIs && enableIds.length === 0 && disableIds.length === 0) {
|
|
160
|
+
throw new Error('Provide at least one of enable, disable, or reset.');
|
|
161
|
+
}
|
|
162
|
+
const bogus = [...enableIds, ...disableIds].filter((id) => !(PACK_IDS as readonly string[]).includes(id));
|
|
163
|
+
if (bogus.length > 0) {
|
|
164
|
+
throw new Error('Unknown pack id(s): ' + bogus.join(', ') + '. Valid pack ids: ' + PACK_IDS.join(', ') + '.');
|
|
165
|
+
}
|
|
166
|
+
if (disableIds.includes('core')) {
|
|
167
|
+
throw new Error(
|
|
168
|
+
'core is always enabled (the pack meta, safety, and discovery surface is force-included) and cannot be disabled.',
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
const overlap = enableIds.filter((id) => disableIds.includes(id));
|
|
172
|
+
if (overlap.length > 0) {
|
|
173
|
+
throw new Error('Pack id(s) cannot be both enabled and disabled in one call: ' + overlap.join(', ') + '.');
|
|
174
|
+
}
|
|
175
|
+
if (resetIs && (enableIds.length > 0 || disableIds.length > 0)) {
|
|
176
|
+
throw new Error('reset drops the whole session override and cannot be combined with enable or disable.');
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
};
|
|
@@ -858,6 +858,46 @@ export function classifyTextCommand(command: unknown, options: ClassifyOptions =
|
|
|
858
858
|
};
|
|
859
859
|
}
|
|
860
860
|
|
|
861
|
+
// The account-switch CLI verbs (interrogate round 1, finding 1): `auth
|
|
862
|
+
// init`/`auth sync` write S1, the OBS config, and the KooCLI profile —
|
|
863
|
+
// the same account switch the MCP tools gate behind a human present
|
|
864
|
+
// (PR-3b). The hook blocks raw `hcloud configure set`, but the devkit's
|
|
865
|
+
// own wrapper was an open bypass: an agent that shells out to
|
|
866
|
+
// `npx huaweicloud-devkit auth init` switches every downstream approved
|
|
867
|
+
// write's account with no confirmation at all. Same anchoring doctrine
|
|
868
|
+
// as approve/pin: the patterns require a devkit binary spelling, so an
|
|
869
|
+
// hcloud operation or a plain file named auth-init never trips, and the
|
|
870
|
+
// read-only `auth status` stays allowed for the agent.
|
|
871
|
+
if (shadowCandidates.some((candidate) => matchesAny(candidate, policy.blockedAccountSwitchCliPatterns))) {
|
|
872
|
+
return {
|
|
873
|
+
decision: 'deny',
|
|
874
|
+
risk: 'approval',
|
|
875
|
+
reason:
|
|
876
|
+
"Running the account-switch CLI from the agent Bash face is blocked: switching the Huawei Cloud account is approval-gated, and the devkit's own confirmation must come from the user's own interactive terminal. Ask the user to run the auth init / auth sync command themselves, or use the gated MCP tools (huaweicloud_auth_init / huaweicloud_auth_switch), which confirm the target account with the user before switching.",
|
|
877
|
+
};
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
// The devkit's gated-mutation CLI twins (interrogate round 1, finding 1):
|
|
881
|
+
// `update`/`upgrade` rewrite the installed package, `secret rm` deletes a
|
|
882
|
+
// vault entry, and `packs enable|disable|all` rewrites the operator
|
|
883
|
+
// DEVKIT_PACKS posture — the exact mutations the MCP approval gate
|
|
884
|
+
// mediates on huaweicloud_upgrade, huaweicloud_secret_delete, and
|
|
885
|
+
// huaweicloud_packs_configure. The CLI path carries no gate at all, so an
|
|
886
|
+
// agent shelling to it performs the mutation with zero confirmation —
|
|
887
|
+
// the same bypass class the auth verbs established. The row shape mirrors
|
|
888
|
+
// the approve/pin family (a devkit bin spelling must be present, so a
|
|
889
|
+
// Huawei Cloud operation or a benign sentence containing the verb never
|
|
890
|
+
// trips), matched against the same two shadows. A human at their own
|
|
891
|
+
// terminal is unaffected: this is the agent Bash face.
|
|
892
|
+
if (shadowCandidates.some((candidate) => matchesAny(candidate, policy.blockedGatedCliPatterns))) {
|
|
893
|
+
return {
|
|
894
|
+
decision: 'deny',
|
|
895
|
+
risk: 'approval',
|
|
896
|
+
reason:
|
|
897
|
+
'Running the devkit update/upgrade, secret rm, and packs enable/disable CLI verbs from the agent Bash face is blocked: they perform the same mutations the MCP approval gate mediates (huaweicloud_upgrade, huaweicloud_secret_delete, huaweicloud_packs_configure), with no confirmation on this path. Call the MCP tool instead — its gate raises the confirmation (token, form, or chat round-trip) — or let the user run the CLI command in their own terminal.',
|
|
898
|
+
};
|
|
899
|
+
}
|
|
900
|
+
|
|
861
901
|
// Order-independent reveal pair: `echo secret get <ref> --stdout | xargs
|
|
862
902
|
// npx huaweicloud-devkit` reorders the argv through xargs while every word
|
|
863
903
|
// is literal in the text — the patterns above assume bin-before-
|
|
@@ -11,6 +11,8 @@ export interface Policy {
|
|
|
11
11
|
blockedSecretOperations: string[];
|
|
12
12
|
blockedSecretCliPatterns: string[];
|
|
13
13
|
blockedApprovalCliPatterns: string[];
|
|
14
|
+
blockedAccountSwitchCliPatterns: string[];
|
|
15
|
+
blockedGatedCliPatterns: string[];
|
|
14
16
|
writeOperationPrefixes: string[];
|
|
15
17
|
readOperationPrefixes: string[];
|
|
16
18
|
readOperationExceptions: string[];
|
|
@@ -64,6 +66,11 @@ export function loadPolicy(path: string): Policy {
|
|
|
64
66
|
blockedSecretOperations: toStringArray(raw.blockedSecretOperations, 'blockedSecretOperations'),
|
|
65
67
|
blockedSecretCliPatterns: toStringArray(raw.blockedSecretCliPatterns, 'blockedSecretCliPatterns'),
|
|
66
68
|
blockedApprovalCliPatterns: toStringArray(raw.blockedApprovalCliPatterns, 'blockedApprovalCliPatterns'),
|
|
69
|
+
blockedAccountSwitchCliPatterns: toStringArray(
|
|
70
|
+
raw.blockedAccountSwitchCliPatterns,
|
|
71
|
+
'blockedAccountSwitchCliPatterns',
|
|
72
|
+
),
|
|
73
|
+
blockedGatedCliPatterns: toStringArray(raw.blockedGatedCliPatterns, 'blockedGatedCliPatterns'),
|
|
67
74
|
writeOperationPrefixes,
|
|
68
75
|
readOperationPrefixes: toStringArray(raw.readOperationPrefixes, 'readOperationPrefixes'),
|
|
69
76
|
readOperationExceptions: toStringArray(raw.readOperationExceptions, 'readOperationExceptions'),
|
|
@@ -45,7 +45,7 @@ interface DeployCheckResult {
|
|
|
45
45
|
export const TUNNEL_URL_PATTERN = /TUNNEL_URL:(https:\/\/[A-Za-z0-9_-]+-\d+\.devbridge-s2\.hwtunnel\.com)/;
|
|
46
46
|
|
|
47
47
|
export function buildExposeRemediation(port: number): string {
|
|
48
|
-
return `In the sandbox: source /tmp/hw_api_key 2>/dev/null; devbridge
|
|
48
|
+
return `In the sandbox: source /tmp/hw_api_key 2>/dev/null; for T in $(devbridge list 2>/dev/null | awk '{gsub(/\\033\\]133;C\\007/, ""); if ($1 !~ /^Tunnel/ && $1 !~ /^No$/) print $1}'); do devbridge port list "$T" 2>/dev/null | awk -v P=${port} '{gsub(/\\033\\]133;C\\007/, ""); if ($1 == P) f=1} END {exit f ? 0 : 1}' && devbridge delete "$T" 2>/dev/null || true; done; devbridge create <name>; devbridge port create <tunnelId> -p ${port} --protocol http -a; if command -v setsid >/dev/null 2>&1; then setsid nohup devbridge host <tunnelId> -p ${port} -e 72 > /tmp/host.log 2>&1 < /dev/null & else nohup devbridge host <tunnelId> -p ${port} -e 72 > /tmp/host.log 2>&1 < /dev/null & fi; disown 2>/dev/null || true; the loop deletes ONLY the tunnels whose port list contains ${port} (any tunnel name — query each tunnel's ports with devbridge port list; a name-based match would miss the custom-named tunnels this flow itself creates), INCLUDING a keepalive-protected tunnel bound to THIS port — a port cannot have two tunnels, so the same-port tunnel is always replaced; all OTHER ports, other sessions and keepalive-protected tunnels on other ports are preserved (never wipe every tunnel here — a global delete kills every session's tunnels). The gsub strips OSC 133 shell-integration markers that wrap every output line on integration-enabled terminals — without it the CLI receives glued tunnel IDs it rejects and the delete silently no-ops. If deploy_nginx reported a different (auto-incremented) port in its "port" field, use THAT port instead of the one shown here. Full procedure in huawei-sandbox skill, Step 7 (Expose via DevBridge).`;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
// The deploy-check stdout contract as one exported pure function — the
|
|
@@ -3,6 +3,40 @@ import { runOneShot } from './devbridge-exec.ts';
|
|
|
3
3
|
import { evaluateDevbridgeVersion } from './devbridge-validation.ts';
|
|
4
4
|
import type { ExposeTunnelResult } from './devbridge-expose.ts';
|
|
5
5
|
import type { DevbridgeKeyResult, DevbridgeQuotaKeyHint } from './devbridge-key.ts';
|
|
6
|
+
import {
|
|
7
|
+
canonCode,
|
|
8
|
+
cleanMessage,
|
|
9
|
+
gateFoldPayload,
|
|
10
|
+
isVersionGateError,
|
|
11
|
+
safeMessageText,
|
|
12
|
+
safeReadField,
|
|
13
|
+
} from '../lib/hdkit/hdkit-gate.ts';
|
|
14
|
+
|
|
15
|
+
// 409 门禁在 relay 出口的统一折叠(v2 扩展,台账记录):三个 catch 位共用——
|
|
16
|
+
// 自动创建、自愈重建、配额清单读取。authMode/attempts 保留(探测到的真实状态,
|
|
17
|
+
// 与配额失败信封同款,台账记录该取舍)。
|
|
18
|
+
function versionGateFailure(
|
|
19
|
+
error: unknown,
|
|
20
|
+
port: number,
|
|
21
|
+
authMode: string,
|
|
22
|
+
attempts: Record<string, string>,
|
|
23
|
+
): { ok: false; failure: ExposeTunnelResult } {
|
|
24
|
+
const fold = gateFoldPayload(error);
|
|
25
|
+
return {
|
|
26
|
+
ok: false,
|
|
27
|
+
failure: {
|
|
28
|
+
ok: false,
|
|
29
|
+
port,
|
|
30
|
+
error: fold.message,
|
|
31
|
+
error_code: fold.code,
|
|
32
|
+
...(fold.clientVersion ? { clientVersion: fold.clientVersion } : {}),
|
|
33
|
+
...(fold.minVersion ? { minVersion: fold.minVersion } : {}),
|
|
34
|
+
gateRemediation: fold.remediation,
|
|
35
|
+
authMode: authMode || 'UNKNOWN',
|
|
36
|
+
attempts,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
6
40
|
|
|
7
41
|
// The DevBridge auth waterfall, extracted from devbridge-tunnel so the auth
|
|
8
42
|
// probe script, its stdout parser, and (with the devbridge-tunnel
|
|
@@ -20,8 +54,12 @@ import type { DevbridgeKeyResult, DevbridgeQuotaKeyHint } from './devbridge-key.
|
|
|
20
54
|
// fallback (devbridge-key.ts) when keyring injection is unavailable.
|
|
21
55
|
// AK/SK login (--access-key/--secret-key) was REMOVED: devbridge authentication is
|
|
22
56
|
// now fixed to API Key only (定稿决策,2026-11-04).
|
|
23
|
-
// Every tier performs a real `devbridge auth login --api-key`
|
|
24
|
-
// `auth status`
|
|
57
|
+
// Every tier performs a real `devbridge auth login --api-key` (exit code checked),
|
|
58
|
+
// then verifies with `auth status` AND a real authenticated API call
|
|
59
|
+
// (`devbridge list`); on failure the waterfall falls through. The list check is
|
|
60
|
+
// required because a stale key can leave a "Logged in" local token while
|
|
61
|
+
// server-side calls return 40100 — without it the probe reports a usable auth
|
|
62
|
+
// and the auto-create self-heal never triggers.
|
|
25
63
|
// DB_ATTEMPT_* lines are non-sensitive diagnostics for support escalation.
|
|
26
64
|
// The HOST orchestrates an auto-create fallback between probe rounds: when the
|
|
27
65
|
// first probe returns NO_CREDENTIAL, the host calls ensureDevbridgeKey() and
|
|
@@ -41,7 +79,13 @@ export function buildDevbridgeAuthProbe(): string {
|
|
|
41
79
|
`DB_VERSION=$(devbridge version 2>/dev/null | head -1)`,
|
|
42
80
|
`echo "DB_VERSION=\${DB_VERSION}"`,
|
|
43
81
|
`DB_OK=0`,
|
|
44
|
-
`db_login_ok() {
|
|
82
|
+
`db_login_ok() {`,
|
|
83
|
+
// 本地 token 可能仍显示 Logged in,但 API key 已在服务端失效(实测
|
|
84
|
+
// list/renew 返回 40100)。因此额外做一次真实鉴权 API 调用,确保探针
|
|
85
|
+
// 结果可用(否则 auto-create 自愈不会触发)。
|
|
86
|
+
` devbridge auth status 2>/dev/null | grep -q "Logged in" || return 1`,
|
|
87
|
+
` devbridge list >/dev/null 2>&1`,
|
|
88
|
+
`}`,
|
|
45
89
|
`db_diag() { echo "DB_ATTEMPT_$1=$2"; }`,
|
|
46
90
|
``,
|
|
47
91
|
`# ---- Tier 1: API Key from the sandbox keyring (platform auto-injection) ----`,
|
|
@@ -71,8 +115,7 @@ export function buildDevbridgeAuthProbe(): string {
|
|
|
71
115
|
` db_diag KEYRING "hwcloud-not-installed"`,
|
|
72
116
|
`fi`,
|
|
73
117
|
`if [ -n "$HW_DB_KEY" ]; then`,
|
|
74
|
-
` devbridge auth login --api-key "$HW_DB_KEY" >/tmp/db_auth.log 2>&1`,
|
|
75
|
-
` if db_login_ok; then`,
|
|
118
|
+
` if devbridge auth login --api-key "$HW_DB_KEY" >/tmp/db_auth.log 2>&1 && db_login_ok; then`,
|
|
76
119
|
` echo "DB_AUTH_MODE=API_KEY_KEYRING"`,
|
|
77
120
|
` DB_OK=1`,
|
|
78
121
|
` else`,
|
|
@@ -86,8 +129,7 @@ export function buildDevbridgeAuthProbe(): string {
|
|
|
86
129
|
`if [ "$DB_OK" -eq 0 ]; then`,
|
|
87
130
|
` source /tmp/hw_api_key 2>/dev/null`,
|
|
88
131
|
` if [ -n "$HW_API_KEY" ]; then`,
|
|
89
|
-
` devbridge auth login --api-key "$HW_API_KEY" >/tmp/db_auth.log 2>&1`,
|
|
90
|
-
` if db_login_ok; then`,
|
|
132
|
+
` if devbridge auth login --api-key "$HW_API_KEY" >/tmp/db_auth.log 2>&1 && db_login_ok; then`,
|
|
91
133
|
` echo "DB_AUTH_MODE=API_KEY_FILE"`,
|
|
92
134
|
` DB_OK=1`,
|
|
93
135
|
` else`,
|
|
@@ -232,8 +274,10 @@ export async function gateExposeAuth(
|
|
|
232
274
|
if (isUsableAuthMode(healParsed.authMode)) {
|
|
233
275
|
effectiveAuthMode = 'API_KEY_AUTO';
|
|
234
276
|
}
|
|
235
|
-
} catch {
|
|
236
|
-
//
|
|
277
|
+
} catch (error) {
|
|
278
|
+
// 409 门禁即时折叠:自愈 catch 原样吞掉会多跑一轮泛化 relay 调用才折
|
|
279
|
+
// 叠(round 3);其余自愈失败仍走泛化降级
|
|
280
|
+
if (isVersionGateError(error)) return versionGateFailure(error, port, authMode, attempts);
|
|
237
281
|
}
|
|
238
282
|
}
|
|
239
283
|
// keyring/文件均无 key → host 调 relay API 自动创建 → 注入沙箱 → 重跑 probe
|
|
@@ -247,15 +291,30 @@ export async function gateExposeAuth(
|
|
|
247
291
|
effectiveAuthMode = 'API_KEY_AUTO';
|
|
248
292
|
}
|
|
249
293
|
} catch (error) {
|
|
250
|
-
//
|
|
251
|
-
|
|
252
|
-
|
|
294
|
+
// 门禁先裁(round 25/MUST 4):配额比较此前先求值且自选分支——登记
|
|
295
|
+
// 过的载体 code 视图谎报配额码即被误路由进清 key 信封(配额 hint、空
|
|
296
|
+
// currentKeys、gateRemediation 丢失)。isVersionGateError 对登记载体零
|
|
297
|
+
// 读返回种类裁决(round 24),谎报视图无从介入;未登记载体照旧先经安
|
|
298
|
+
// 全读判配额——canonCode 读过卫队(round 14),抛出型 getter 按缺失
|
|
299
|
+
if (isVersionGateError(error)) return versionGateFailure(error, port, authMode, attempts);
|
|
300
|
+
if (canonCode(safeReadField(error, 'code')) === 'HDKIT_DEVBRIDGE_KEY_QUOTA_EXCEEDED') {
|
|
301
|
+
// 配额清单读取本身遭遇 409:门禁优先(清 key 引导拿不出 currentKeys);
|
|
302
|
+
// 其余读取失败仍降级为空清单
|
|
303
|
+
let keysHint: Awaited<ReturnType<typeof keyUpgrade.listKeysForQuotaHint>> = [];
|
|
304
|
+
try {
|
|
305
|
+
keysHint = await keyUpgrade.listKeysForQuotaHint();
|
|
306
|
+
} catch (listError) {
|
|
307
|
+
if (isVersionGateError(listError)) return versionGateFailure(listError, port, authMode, attempts);
|
|
308
|
+
}
|
|
309
|
+
// 消息读同样过卫队与清洗口(round 14):拒读/空白按缺失——字段缺省,
|
|
310
|
+
// 信封的 error_code/hint/currentKeys 不受影响
|
|
311
|
+
const quotaMessage = cleanMessage(safeMessageText(error));
|
|
253
312
|
return {
|
|
254
313
|
ok: false,
|
|
255
314
|
failure: {
|
|
256
315
|
ok: false,
|
|
257
316
|
port,
|
|
258
|
-
error:
|
|
317
|
+
...(quotaMessage ? { error: quotaMessage } : {}),
|
|
259
318
|
error_code: 'HDKIT_DEVBRIDGE_KEY_QUOTA_EXCEEDED',
|
|
260
319
|
authMode: authMode || 'UNKNOWN',
|
|
261
320
|
attempts,
|
|
@@ -264,7 +323,8 @@ export async function gateExposeAuth(
|
|
|
264
323
|
},
|
|
265
324
|
};
|
|
266
325
|
}
|
|
267
|
-
// 其他自动创建失败 → 继续走原有降级路径(可能 keyring/file
|
|
326
|
+
// 其他自动创建失败 → 继续走原有降级路径(可能 keyring/file 后续可用);
|
|
327
|
+
// 门禁折叠已在本 catch 顶部先裁(round 25/MUST 4)
|
|
268
328
|
}
|
|
269
329
|
}
|
|
270
330
|
}
|