huaweicloud-devkit 2.0.0-next.3 → 2.0.0-next.5
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 +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/.mcp.json +55 -1
- package/plugins/huaweicloud-core/.workbuddy-plugin/plugin.json +1 -1
- 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 +141 -86
- package/plugins/huaweicloud-core/dist/agents/opencode.js +106 -39
- 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/explain-error.js +9 -1
- package/plugins/huaweicloud-core/dist/hcloud-cli.js +1 -1
- package/plugins/huaweicloud-core/dist/hcloud-plan.js +68 -62
- package/plugins/huaweicloud-core/dist/lib/approval-mode.js +7 -5
- 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 +371 -32
- package/plugins/huaweicloud-core/dist/lib/hdkit/sandbox-pool.js +6 -16
- package/plugins/huaweicloud-core/dist/lib/opencode-ask-rule.js +224 -78
- 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 +68 -16
- package/plugins/huaweicloud-core/dist/mcp-server.js +6933 -1186
- 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 +85 -130
- 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 +20 -1
- package/plugins/huaweicloud-core/dist/packs/sandbox/approval.js +245 -0
- package/plugins/huaweicloud-core/dist/packs/sandbox/expose-task.js +71 -0
- package/plugins/huaweicloud-core/dist/packs/sandbox/handlers-account.js +180 -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 +29 -3
- package/plugins/huaweicloud-core/dist/packs/sandbox/schemas.js +93 -9
- package/plugins/huaweicloud-core/dist/packs/sandbox/tools.js +37 -10
- 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/risk-rule-engine.js +20 -4
- package/plugins/huaweicloud-core/dist/safety/classify-hcloud.js +6 -6
- 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/safety/redact.js +21 -3
- package/plugins/huaweicloud-core/dist/safety/risk-merge.js +24 -4
- 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 +36 -1
- package/plugins/huaweicloud-core/dist/tool-definitions.js +13 -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 +67 -4
- package/plugins/huaweicloud-core/openclaw.plugin.json +2 -2
- package/plugins/huaweicloud-core/safety/policy.json +18 -11
- package/plugins/huaweicloud-core/safety/rules/cloud-risk-rules.json +115 -11
- package/plugins/huaweicloud-core/skills/huawei-sandbox/SKILL.md +198 -143
- 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 +2 -2
- package/plugins/huaweicloud-core/skills/huaweicloud-safety/SKILL.md +11 -7
- package/plugins/huaweicloud-core/skills/huaweicloud-safety/references/approvals.md +74 -29
- 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 +176 -88
- package/plugins/huaweicloud-core/src/agents/opencode.ts +125 -54
- 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/explain-error.ts +9 -1
- package/plugins/huaweicloud-core/src/hcloud-cli.ts +3 -0
- package/plugins/huaweicloud-core/src/hcloud-plan.ts +74 -71
- package/plugins/huaweicloud-core/src/lib/approval-mode.ts +7 -5
- 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 +408 -30
- package/plugins/huaweicloud-core/src/lib/hdkit/sandbox-pool.ts +8 -15
- package/plugins/huaweicloud-core/src/lib/opencode-ask-rule.ts +302 -83
- 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 +81 -17
- package/plugins/huaweicloud-core/src/mcp-server.ts +7 -7
- 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 +99 -137
- 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 +43 -1
- package/plugins/huaweicloud-core/src/packs/sandbox/approval.ts +296 -0
- package/plugins/huaweicloud-core/src/packs/sandbox/expose-task.ts +105 -0
- package/plugins/huaweicloud-core/src/packs/sandbox/handlers-account.ts +195 -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 +41 -14
- package/plugins/huaweicloud-core/src/packs/sandbox/schemas.ts +120 -8
- package/plugins/huaweicloud-core/src/packs/sandbox/tools.ts +42 -9
- 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/risk-rule-engine.ts +20 -7
- package/plugins/huaweicloud-core/src/safety/classify-hcloud.ts +28 -16
- 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/safety/redact.ts +24 -6
- package/plugins/huaweicloud-core/src/safety/risk-merge.ts +26 -5
- 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 +511 -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 +39 -1
- package/plugins/huaweicloud-core/src/tool-definitions.ts +13 -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
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// The approval-gate roster: which tools the dispatch-layer approval gate
|
|
2
|
+
// covers. A const string tuple, zod-free, import-free — the .mjs hook twin
|
|
3
|
+
// and the opencode ask-rule writer both import this shape from the compiled
|
|
4
|
+
// tree, and neither may pull the SDK/zod graph (the hook runs before dist
|
|
5
|
+
// exists in a raw checkout; the writer lives in the unbundled setup-cli
|
|
6
|
+
// graph). The gate (approval-gate.ts) resolves specs from packs/registry.ts's
|
|
7
|
+
// APPROVAL_SPECS merge, whose satisfies check is keyed by THIS tuple's
|
|
8
|
+
// literal union — that coupling is the reason for `as const`: a
|
|
9
|
+
// ReadonlyArray<string> widens the key type to string and silently inerts
|
|
10
|
+
// the compile-time closure (an interrogate-round-1 finding).
|
|
11
|
+
//
|
|
12
|
+
// PR-1 populated the roster with the hcloud pair's run face; PR-3a added
|
|
13
|
+
// the sandbox pack's eight mutating faces (connect, the two exec tools,
|
|
14
|
+
// the three tunnel faces, sign_agreement, credentials); the port-pr6 wave
|
|
15
|
+
// added shutdown — the irreversible core-hour stop (an unrostered shutdown
|
|
16
|
+
// is a safety hole: the tool exists but nothing gates it); PR-3b adds the auth
|
|
17
|
+
// account-switch pair — the account switch can redirect every downstream
|
|
18
|
+
// approved write to a different account, so it earns a human present on
|
|
19
|
+
// every call; PR-3c adds the obs pair as the first classified members
|
|
20
|
+
// (action=get is a signed read and must never confirm) and the three
|
|
21
|
+
// always tools (upgrade replaces its description-level consent with the
|
|
22
|
+
// mechanical gate; secret_delete is destructive with no version history;
|
|
23
|
+
// packs_configure widens the disclosure face). secret_set stays OFF the
|
|
24
|
+
// roster — the user is the plaintext source and is therefore present —
|
|
25
|
+
// and setup_obs_config stays off as the flagged boundary item. Two
|
|
26
|
+
// lists, not one, because the two flavors need different downstream
|
|
27
|
+
// facts: always tools get client allow rules on install (the yield
|
|
28
|
+
// posture), classified tools additionally need a classify in their spec
|
|
29
|
+
// (pinned by structure.test.ts: every APPROVAL_CLASSIFIED_TOOLS entry
|
|
30
|
+
// must provide one).
|
|
31
|
+
export const APPROVAL_TOOLS = [
|
|
32
|
+
'huaweicloud_run_approved_command',
|
|
33
|
+
'huaweicloud_sandbox_connect',
|
|
34
|
+
'huaweicloud_sandbox_exec_with_session',
|
|
35
|
+
'huaweicloud_sandbox_exec_one_shot',
|
|
36
|
+
'huaweicloud_sandbox_expose_tunnel',
|
|
37
|
+
'huaweicloud_sandbox_renew_tunnel',
|
|
38
|
+
'huaweicloud_sandbox_keepalive_watchdog',
|
|
39
|
+
'huaweicloud_sandbox_sign_agreement',
|
|
40
|
+
'huaweicloud_sandbox_credentials',
|
|
41
|
+
'huaweicloud_sandbox_shutdown',
|
|
42
|
+
'huaweicloud_auth_init',
|
|
43
|
+
'huaweicloud_auth_switch',
|
|
44
|
+
'huaweicloud_obs_set_website_config',
|
|
45
|
+
'huaweicloud_obs_set_cors',
|
|
46
|
+
'huaweicloud_upgrade',
|
|
47
|
+
'huaweicloud_secret_delete',
|
|
48
|
+
'huaweicloud_packs_configure',
|
|
49
|
+
];
|
|
50
|
+
// The classified members: PR-3a's exec pair and PR-3c's obs pair. A const
|
|
51
|
+
// tuple by the same round-1..5 widening doctrine as APPROVAL_TOOLS (the
|
|
52
|
+
// compile-time classified-provides-classify consumers key on the runtime
|
|
53
|
+
// list, and a widened element would inert them) — structure.test.ts pins
|
|
54
|
+
// the shape.
|
|
55
|
+
export const APPROVAL_CLASSIFIED_TOOLS = [
|
|
56
|
+
'huaweicloud_sandbox_exec_with_session',
|
|
57
|
+
'huaweicloud_sandbox_exec_one_shot',
|
|
58
|
+
'huaweicloud_obs_set_website_config',
|
|
59
|
+
'huaweicloud_obs_set_cors',
|
|
60
|
+
];
|
|
61
|
+
export const APPROVAL_TOOL_INPUT_SHAPES = {
|
|
62
|
+
huaweicloud_run_approved_command: 'argsArray',
|
|
63
|
+
huaweicloud_sandbox_connect: 'structured',
|
|
64
|
+
huaweicloud_sandbox_exec_with_session: 'commandString',
|
|
65
|
+
huaweicloud_sandbox_exec_one_shot: 'commandString',
|
|
66
|
+
huaweicloud_sandbox_expose_tunnel: 'structured',
|
|
67
|
+
huaweicloud_sandbox_renew_tunnel: 'structured',
|
|
68
|
+
huaweicloud_sandbox_keepalive_watchdog: 'structured',
|
|
69
|
+
huaweicloud_sandbox_sign_agreement: 'structured',
|
|
70
|
+
huaweicloud_sandbox_credentials: 'structured',
|
|
71
|
+
huaweicloud_sandbox_shutdown: 'structured',
|
|
72
|
+
huaweicloud_auth_init: 'structured',
|
|
73
|
+
huaweicloud_auth_switch: 'structured',
|
|
74
|
+
huaweicloud_obs_set_website_config: 'structured',
|
|
75
|
+
huaweicloud_obs_set_cors: 'structured',
|
|
76
|
+
huaweicloud_upgrade: 'structured',
|
|
77
|
+
huaweicloud_secret_delete: 'structured',
|
|
78
|
+
huaweicloud_packs_configure: 'structured',
|
|
79
|
+
};
|
|
80
|
+
// The client-facing permission action opencode namespaces a roster tool
|
|
81
|
+
// under: `<mcp server key>_<tool>`, the key being our `.mcp.json` server name
|
|
82
|
+
// (measured on 2.2.7, and byte-identical across the 1.19 V1 key and the 2.x
|
|
83
|
+
// permission action). One home for the derivation, so the doctor's hygiene
|
|
84
|
+
// reader (lib/opencode-saved-perms.ts), the ask-rule writer, and the doctor
|
|
85
|
+
// can never drift onto different spellings of the same grant.
|
|
86
|
+
export const APPROVAL_MCP_SERVER = 'huaweicloud-devkit';
|
|
87
|
+
export function approvalToolAction(tool) {
|
|
88
|
+
return `${APPROVAL_MCP_SERVER}_${tool}`;
|
|
89
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -43,7 +43,7 @@ function printRefusal(io, inspectionState) {
|
|
|
43
43
|
io.write('No pending approval matches that token.\n');
|
|
44
44
|
}
|
|
45
45
|
else if (inspectionState === 'expired') {
|
|
46
|
-
io.write('That approval expired. A confirmation must happen within 5 minutes of the
|
|
46
|
+
io.write('That approval expired. A confirmation must happen within 5 minutes of the mint; ask the agent to make the approved call again for a fresh approval.\n');
|
|
47
47
|
}
|
|
48
48
|
else {
|
|
49
49
|
io.write('This approval was already used.\n');
|
|
@@ -86,16 +86,16 @@ async function verifyPin(io) {
|
|
|
86
86
|
function printConfirmResult(io, status, reason) {
|
|
87
87
|
switch (status) {
|
|
88
88
|
case 'confirmed':
|
|
89
|
-
io.write('Confirmed. The agent may now run this
|
|
89
|
+
io.write('Confirmed. The agent may now run this approved call once.\n');
|
|
90
90
|
return 0;
|
|
91
91
|
case 'already_confirmed':
|
|
92
|
-
io.write('This approval was already confirmed. The agent may run this
|
|
92
|
+
io.write('This approval was already confirmed. The agent may run this approved call once.\n');
|
|
93
93
|
return 0;
|
|
94
94
|
case 'already_consumed':
|
|
95
95
|
io.write('This approval was already used.\n');
|
|
96
96
|
return 0;
|
|
97
97
|
case 'expired':
|
|
98
|
-
io.write('That approval expired. A confirmation must happen within 5 minutes of the
|
|
98
|
+
io.write('That approval expired. A confirmation must happen within 5 minutes of the mint; ask the agent to make the approved call again for a fresh approval.\n');
|
|
99
99
|
return 1;
|
|
100
100
|
case 'custody_unavailable':
|
|
101
101
|
io.write(`Cannot record the confirmation: ${reason ?? 'the vault master key is unavailable'}.\n`);
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"icons": [
|
|
6
6
|
{
|
|
7
7
|
"id": "codeartsdoer",
|
|
8
|
-
"name": "
|
|
8
|
+
"name": "华为云码道CodeArts代码智能体",
|
|
9
9
|
"category": "人工智能",
|
|
10
10
|
"subcategory": "智能体",
|
|
11
11
|
"description": "更懂你编码需求的AI研发专家",
|
|
@@ -41,13 +41,13 @@
|
|
|
41
41
|
},
|
|
42
42
|
{
|
|
43
43
|
"id": "modelarts",
|
|
44
|
-
"name": "魔坊(ModelArts
|
|
44
|
+
"name": "魔坊(ModelArts)",
|
|
45
45
|
"category": "人工智能",
|
|
46
46
|
"subcategory": "模型开发平台",
|
|
47
47
|
"description": "“数-训-推-强”,一站式AI开发平台",
|
|
48
48
|
"product_url": "https://www.huaweicloud.com/product/modelarts.html",
|
|
49
49
|
"logo": {
|
|
50
|
-
"source_url": "https://res-static.hc-cdn.cn/cloudbu-site/public/
|
|
50
|
+
"source_url": "https://res-static.hc-cdn.cn/cloudbu-site/public/%E6%96%B0%E7%89%88/CF057503-AE1E-48CA-E8C1-1919F51A1261.png",
|
|
51
51
|
"local_path": "icons/assets/logo/modelarts.png"
|
|
52
52
|
},
|
|
53
53
|
"architecture": {
|
|
@@ -155,8 +155,8 @@
|
|
|
155
155
|
"description": "高效敏捷安全的一站式企业级智能体平台",
|
|
156
156
|
"product_url": "https://www.huaweicloud.com/product/agentarts.html",
|
|
157
157
|
"logo": {
|
|
158
|
-
"source_url": "https://res-static.hc-cdn.cn/cloudbu-site/
|
|
159
|
-
"local_path": "icons/assets/logo/agentarts.
|
|
158
|
+
"source_url": "https://res-static.hc-cdn.cn/cloudbu-site/china/zh-cn/%E6%99%BA%E6%9E%9CAgentArts/AgentArts-%E5%AE%98%E7%BD%91%E4%BA%A7%E5%93%81%E9%A1%B5%E5%88%87%E5%9B%BE/bannerlogo.png",
|
|
159
|
+
"local_path": "icons/assets/logo/agentarts.png"
|
|
160
160
|
},
|
|
161
161
|
"architecture": {
|
|
162
162
|
"status": "planned",
|
|
@@ -165,6 +165,24 @@
|
|
|
165
165
|
"aliases": ["agentarts"],
|
|
166
166
|
"tags": ["人工智能", "智能体平台", "agentarts"]
|
|
167
167
|
},
|
|
168
|
+
{
|
|
169
|
+
"id": "officeace",
|
|
170
|
+
"name": "果办OfficeAce 办公智能体",
|
|
171
|
+
"category": "人工智能",
|
|
172
|
+
"subcategory": "智能体",
|
|
173
|
+
"description": "专业办公级AI助手,PPT一键生成、专家团研讨,安全高效随时待命",
|
|
174
|
+
"product_url": "https://www.huaweicloud.com/product/agentarts/officeace.html",
|
|
175
|
+
"logo": {
|
|
176
|
+
"source_url": "https://res-static.hc-cdn.cn/cloudbu-site/china/zh-cn/yunying/product/OfficeAce-v2.svg",
|
|
177
|
+
"local_path": "icons/assets/logo/officeace.svg"
|
|
178
|
+
},
|
|
179
|
+
"architecture": {
|
|
180
|
+
"status": "planned",
|
|
181
|
+
"local_path": "icons/assets/architecture/officeace.svg"
|
|
182
|
+
},
|
|
183
|
+
"aliases": ["officeace", "office-ace"],
|
|
184
|
+
"tags": ["人工智能", "智能体", "办公", "officeace"]
|
|
185
|
+
},
|
|
168
186
|
{
|
|
169
187
|
"id": "pangu-nlp",
|
|
170
188
|
"name": "LLM大模型",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
1
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync, statSync, utimesSync, writeFileSync, } from 'node:fs';
|
|
2
2
|
import { homedir } from 'node:os';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
|
+
import { Worker } from 'node:worker_threads';
|
|
4
5
|
import { DEPENDENCIES } from "../lib/dependency-model.js";
|
|
5
6
|
export function receiptDir(base = process.env.HUAWEICLOUD_HOME || homedir()) {
|
|
6
7
|
return join(base, '.config', 'huaweicloud', 'deps');
|
|
@@ -116,7 +117,13 @@ const LOCK_POLL_MS = 50;
|
|
|
116
117
|
// window is taken over anyway — the guard must never block forever. The
|
|
117
118
|
// window must exceed the longest critical section (the tier uninstall's
|
|
118
119
|
// 60s spawnSync) plus resolution margin, or a legitimate holder still
|
|
119
|
-
// inside its section gets its lock taken over mid-flight.
|
|
120
|
+
// inside its section gets its lock taken over mid-flight. A holder whose
|
|
121
|
+
// claim goes stale while its pid is STILL alive is judged wedged by this
|
|
122
|
+
// same window — correct for the installer's bounded sections, wrong for
|
|
123
|
+
// a caller whose section cost is unbounded: such callers pass the
|
|
124
|
+
// heartbeatMs option (below), which refreshes the claim's mtime for the
|
|
125
|
+
// duration of the section so a live productive holder never goes stale
|
|
126
|
+
// however long its section runs.
|
|
120
127
|
const LOCK_TAKEOVER_MS = 90_000;
|
|
121
128
|
const lockDepth = new Map();
|
|
122
129
|
const heldDirs = new Set();
|
|
@@ -196,12 +203,37 @@ function sweepStaleStashes(dir) {
|
|
|
196
203
|
// unreadable or absent receipt dir: the claim below will recreate it
|
|
197
204
|
}
|
|
198
205
|
}
|
|
199
|
-
|
|
206
|
+
// Thrown by acquireLock when the opt-in wait budget expires: the caller's
|
|
207
|
+
// documented posture for this error is degrade-and-proceed (the ledger
|
|
208
|
+
// runs the append unlocked), never fail the approved call. Only the
|
|
209
|
+
// opt-in maxWaitMs path can produce it; the dep installer never passes
|
|
210
|
+
// one and keeps today's unbounded wait.
|
|
211
|
+
export class LockWaitBudgetExceeded extends Error {
|
|
212
|
+
waitedMs;
|
|
213
|
+
constructor(waitedMs) {
|
|
214
|
+
super(`lock wait budget exceeded after ${waitedMs}ms (holder still alive)`);
|
|
215
|
+
this.name = 'LockWaitBudgetExceeded';
|
|
216
|
+
this.waitedMs = waitedMs;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
function acquireLock(dir, takeoverMs = LOCK_TAKEOVER_MS, maxWaitMs = 0) {
|
|
200
220
|
mkdirSync(dir, { recursive: true });
|
|
201
221
|
sweepStaleStashes(dir);
|
|
202
222
|
const lock = lockDirPath(dir);
|
|
203
223
|
const deadline = Date.now() + takeoverMs;
|
|
224
|
+
const acquireStarted = Date.now();
|
|
204
225
|
for (;;) {
|
|
226
|
+
// The opt-in TOTAL wait cap (interrogate round 5, finding 1): the
|
|
227
|
+
// heartbeat keeps a live-but-wedged holder's claim fresh forever —
|
|
228
|
+
// its worker thread beats while its main thread hangs — so a waiter
|
|
229
|
+
// with no cap would block the caller's event loop for the wedge's
|
|
230
|
+
// whole duration, unbounded. A caller that passes maxWaitMs gets a
|
|
231
|
+
// bounded wait instead: past the cap with the lock still held, this
|
|
232
|
+
// throw hands the caller its documented degradation. Checked at the
|
|
233
|
+
// loop top only, so a claim that succeeded never throws.
|
|
234
|
+
if (maxWaitMs > 0 && Date.now() - acquireStarted > maxWaitMs) {
|
|
235
|
+
throw new LockWaitBudgetExceeded(Date.now() - acquireStarted);
|
|
236
|
+
}
|
|
205
237
|
// Identity of the directory THIS iteration creates at the lock path —
|
|
206
238
|
// the claim is only complete once the pid file lands in THAT directory.
|
|
207
239
|
// Round-9 (CI, live-reproduced under CPU load): a past-deadline rival
|
|
@@ -359,7 +391,32 @@ function installExitCleanup() {
|
|
|
359
391
|
releaseLock(dir);
|
|
360
392
|
});
|
|
361
393
|
}
|
|
362
|
-
|
|
394
|
+
// The opt-in claim heartbeat (interrogate round 4): a worker thread that
|
|
395
|
+
// refreshes the claim pid file's mtime every intervalMs for the duration
|
|
396
|
+
// of the section. The acquire loop judges liveness by that mtime, so a
|
|
397
|
+
// beating holder never goes stale however long its section runs — the
|
|
398
|
+
// worker's timer fires on its own OS thread while the holder's main
|
|
399
|
+
// thread is blocked in a multi-second parse/write, which no in-section
|
|
400
|
+
// refresh could cover. Opt-in only: the dep installer's call sites pass
|
|
401
|
+
// no heartbeat and keep exactly today's semantics (bounded sections,
|
|
402
|
+
// window-sized takeover). A worker that fails to spawn degrades to the
|
|
403
|
+
// no-heartbeat behavior — the documented residual for that path.
|
|
404
|
+
function startClaimHeartbeat(lock, heartbeatMs) {
|
|
405
|
+
try {
|
|
406
|
+
return new Worker([
|
|
407
|
+
"const { utimesSync } = require('node:fs');",
|
|
408
|
+
"const { workerData } = require('node:worker_threads');",
|
|
409
|
+
'setInterval(() => {',
|
|
410
|
+
' const now = Date.now() / 1000;',
|
|
411
|
+
' try { utimesSync(workerData.pidFile, now, now); } catch {}',
|
|
412
|
+
'}, workerData.intervalMs);',
|
|
413
|
+
].join('\n'), { eval: true, workerData: { pidFile: join(lock, LOCK_PID_FILE), intervalMs: heartbeatMs } });
|
|
414
|
+
}
|
|
415
|
+
catch {
|
|
416
|
+
return undefined;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
export function withDepLock(fn, dir = receiptDir(), takeoverMs = LOCK_TAKEOVER_MS, heartbeatMs = 0, maxWaitMs = 0) {
|
|
363
420
|
const depth = lockDepth.get(dir) ?? 0;
|
|
364
421
|
if (depth > 0) {
|
|
365
422
|
lockDepth.set(dir, depth + 1);
|
|
@@ -370,14 +427,17 @@ export function withDepLock(fn, dir = receiptDir(), takeoverMs = LOCK_TAKEOVER_M
|
|
|
370
427
|
lockDepth.set(dir, depth - 1);
|
|
371
428
|
}
|
|
372
429
|
}
|
|
373
|
-
acquireLock(dir, takeoverMs);
|
|
430
|
+
acquireLock(dir, takeoverMs, maxWaitMs);
|
|
374
431
|
installExitCleanup();
|
|
375
432
|
heldDirs.add(dir);
|
|
376
433
|
lockDepth.set(dir, 1);
|
|
434
|
+
const heartbeat = heartbeatMs > 0 ? startClaimHeartbeat(lockDirPath(dir), heartbeatMs) : undefined;
|
|
377
435
|
try {
|
|
378
436
|
return fn();
|
|
379
437
|
}
|
|
380
438
|
finally {
|
|
439
|
+
if (heartbeat)
|
|
440
|
+
heartbeat.terminate().catch(() => { });
|
|
381
441
|
lockDepth.set(dir, 0);
|
|
382
442
|
releaseLock(dir);
|
|
383
443
|
heldDirs.delete(dir);
|
|
@@ -200,8 +200,16 @@ export function explainError({ service = 'unknown', errorCode = '', code = '', m
|
|
|
200
200
|
const uniqueSuggestions = suggestions.filter((s, i, arr) => {
|
|
201
201
|
return !arr.slice(0, i).some((prev) => prev.substring(0, 50).toLowerCase() === s.substring(0, 50).toLowerCase());
|
|
202
202
|
});
|
|
203
|
+
// The response names the service the error was RESOLVED to, not a raw
|
|
204
|
+
// `unknown`/wrong pasted name: `code`-only calls and a pasted service whose
|
|
205
|
+
// own pattern table is empty derive their key from the code prefix (the
|
|
206
|
+
// suggestions already walked that table). A valid explicit service keeps
|
|
207
|
+
// its exact spelling — the pre-existing contract and its #935 regression
|
|
208
|
+
// pin (AX report D-05).
|
|
209
|
+
const providedKnown = Boolean(service) && svc !== 'unknown';
|
|
210
|
+
const responseService = !providedKnown || !hwErrorPatterns[patternKey] ? effectiveKey : service;
|
|
203
211
|
return {
|
|
204
|
-
service,
|
|
212
|
+
service: responseService,
|
|
205
213
|
errorCode: resolvedCode,
|
|
206
214
|
requestId,
|
|
207
215
|
suggestions: uniqueSuggestions,
|
|
@@ -20,5 +20,5 @@ export { resolveStsInjectArgs } from "./hcloud-sts.js";
|
|
|
20
20
|
// The plan and run engine. stripLeadingHcloudBinArgs rides the face so the
|
|
21
21
|
// approval handler hashes the same effective args the plan minted its token
|
|
22
22
|
// over (the 2026-11-05 UX report #6 seam).
|
|
23
|
-
export { planHcloudCommand, stripLeadingHcloudBinArgs, firstPlaceholderSecretArg, pinViewArgs, } from "./hcloud-plan.js";
|
|
23
|
+
export { planHcloudCommand, stripLeadingHcloudBinArgs, firstPlaceholderSecretArg, pinViewArgs, needsUserConfirmation, quoteShellArg, hcloudExecutableLines, } from "./hcloud-plan.js";
|
|
24
24
|
export { runHcloud } from "./hcloud-run.js";
|
|
@@ -6,14 +6,16 @@
|
|
|
6
6
|
// src/lib/approval-tokens.ts.
|
|
7
7
|
//
|
|
8
8
|
// The plan's approval posture is mode-dependent (HcloudPlanOptions.
|
|
9
|
-
// approvalMode): 'ask' (DEVKIT_APPROVAL_MODE=ask) plans for the
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
// line
|
|
9
|
+
// approvalMode): 'ask' (DEVKIT_APPROVAL_MODE=ask) plans for the SERVER-run
|
|
10
|
+
// confirmation — the approval gate raises an elicitation form, or the T3
|
|
11
|
+
// chat round-trip on a client that cannot render one — so no token is
|
|
12
|
+
// minted and userConfirmation carries the ask note instead of a terminal
|
|
13
|
+
// approve line; 'token' (the default) keeps the mint + approve line
|
|
14
|
+
// contract above.
|
|
14
15
|
import { classifyHcloudArgs, redactSecrets, stripExecutable } from "./safety-policy.js";
|
|
15
16
|
import { isHcloudToken } from "./safety/tokens.js";
|
|
16
17
|
import { createApprovalToken } from "./lib/approval-tokens.js";
|
|
18
|
+
import { foldSecretTokens, SECRET_KEY_TOKEN_RE, secretSegments } from "./lib/supplemental-redaction.js";
|
|
17
19
|
import { obsWriteHint } from "./hcloud-obs-redact.js";
|
|
18
20
|
import { applyPreflightFindings, preflightSecurityGroupCheck } from "./hcloud-sg-preflight.js";
|
|
19
21
|
import { triageUnknownService } from "./hcloud-triage.js";
|
|
@@ -27,7 +29,7 @@ export function needsUserConfirmation(args, options = {}) {
|
|
|
27
29
|
const strict = classifyHcloudArgs(args, { ...options, allowWrites: false });
|
|
28
30
|
return strict.decision === 'deny' && (strict.risk === 'write' || strict.risk === 'execution');
|
|
29
31
|
}
|
|
30
|
-
function quoteShellArg(value) {
|
|
32
|
+
export function quoteShellArg(value) {
|
|
31
33
|
const text = String(value);
|
|
32
34
|
if (!text)
|
|
33
35
|
return '""';
|
|
@@ -35,6 +37,28 @@ function quoteShellArg(value) {
|
|
|
35
37
|
return text;
|
|
36
38
|
return `"${text.replace(/(["\\])/g, '\\$1')}"`;
|
|
37
39
|
}
|
|
40
|
+
// One redacted echo argument: the real argument's quoting shape with the
|
|
41
|
+
// value text replaced. A real argument quoteShellArg leaves bare stays bare
|
|
42
|
+
// (so a safe-charset substitution is the gate's plain line); one it would
|
|
43
|
+
// quote gets the same wrapper around the redacted spelling (so a
|
|
44
|
+
// shell-special substitution is the gate's quoted line).
|
|
45
|
+
function redactedCommandArg(raw, redacted) {
|
|
46
|
+
if (quoteShellArg(raw) === raw)
|
|
47
|
+
return redacted;
|
|
48
|
+
return `"${redacted.replace(/(["\\])/g, '\\$1')}"`;
|
|
49
|
+
}
|
|
50
|
+
// The accepted executable lines for a normalized argument list: the
|
|
51
|
+
// command-forward `command` field must equal one of them exactly. The plain
|
|
52
|
+
// space-joined line is the contract's stated anchor; the shell-quoted line is
|
|
53
|
+
// this module's own echo (plan.command), so a model that forwards the plan's
|
|
54
|
+
// echo verbatim passes too. The two coincide for the ordinary case (service,
|
|
55
|
+
// operation, --key=value) and differ only where an argument carries a space,
|
|
56
|
+
// a quote, or another character the echo has to quote.
|
|
57
|
+
export function hcloudExecutableLines(normalizedArgs) {
|
|
58
|
+
const plain = ['hcloud', ...normalizedArgs].join(' ');
|
|
59
|
+
const quoted = ['hcloud', ...normalizedArgs].map((arg) => quoteShellArg(arg)).join(' ');
|
|
60
|
+
return plain === quoted ? [plain] : [plain, quoted];
|
|
61
|
+
}
|
|
38
62
|
function planningWarnings(args) {
|
|
39
63
|
const joined = args.join(' ');
|
|
40
64
|
const warnings = [];
|
|
@@ -133,26 +157,13 @@ function leadingBinWarning(stripped) {
|
|
|
133
157
|
// pinning message no longer claims a reason. Free-form JSON bodies with
|
|
134
158
|
// real secrets should go through plan→approve with literal values (hash
|
|
135
159
|
// path), not the substitution flow.
|
|
136
|
-
|
|
137
|
-
//
|
|
138
|
-
//
|
|
139
|
-
//
|
|
140
|
-
|
|
160
|
+
// The secret-token fold's primitives (the key vocabulary, the scanner, the
|
|
161
|
+
// argv fold) live in lib/supplemental-redaction.ts since PR-3a round 3 —
|
|
162
|
+
// one canonical home shared with the exec views and the token store, which
|
|
163
|
+
// cannot import this module's face (approval-tokens ← hcloud-cli would be
|
|
164
|
+
// a value cycle). The detector comments below describe THEIR semantics and
|
|
165
|
+
// stay authoritative for the substitution flow.
|
|
141
166
|
const PLACEHOLDER_SECRET_VALUE_RE = /^["']?<{1,2}[A-Za-z0-9_ -]{1,40}>{1,2}["']?/;
|
|
142
|
-
// Shared key+separator scanner (loop round 8): ONE global split drives every
|
|
143
|
-
// consumer. The value segment of a key runs to the NEXT key occurrence — a
|
|
144
|
-
// multi-key body (`{"token":"<x>","password":"Real"}`) yields one segment
|
|
145
|
-
// per key, so a mixed placeholder/real body can no longer hide a real value
|
|
146
|
-
// behind a lazy first match (loop round 7, seat-1 B1).
|
|
147
|
-
const SECRET_KEY_SEP_RE = new RegExp('((?:(?:' + SECRET_KEY_ALT + ')|\\b(?:AK|SK))["\'\\\\]*\\s*(?:[=:]|\\s|(?=["\']))\\s*)', 'gi');
|
|
148
|
-
function secretSegments(arg) {
|
|
149
|
-
const parts = String(arg).split(SECRET_KEY_SEP_RE);
|
|
150
|
-
const segments = [];
|
|
151
|
-
for (let i = 1; i < parts.length; i += 2) {
|
|
152
|
-
segments.push({ sep: parts[i] ?? '', value: parts[i + 1] ?? '' });
|
|
153
|
-
}
|
|
154
|
-
return segments;
|
|
155
|
-
}
|
|
156
167
|
function placeholderShaped(value) {
|
|
157
168
|
return PLACEHOLDER_SECRET_VALUE_RE.test(value.trim());
|
|
158
169
|
}
|
|
@@ -205,34 +216,12 @@ export function firstPlaceholderSecretArg(args) {
|
|
|
205
216
|
// the map-only version dropped the two-token branch and let cross-form
|
|
206
217
|
// swaps through). The redactor's own output cannot serve here — it never
|
|
207
218
|
// folds the two-token/glued forms, so the substitution flow dead-ended in
|
|
208
|
-
// a mismatch (loop round 4, seat-1 B2).
|
|
219
|
+
// a mismatch (loop round 4, seat-1 B2). Since PR-3a round 3 the fold body
|
|
220
|
+
// lives in the shared leaf (lib/supplemental-redaction.ts) with the exec
|
|
221
|
+
// views and the token store as its co-consumers; this export keeps the
|
|
222
|
+
// run face's canonical name.
|
|
209
223
|
export function pinViewArgs(args) {
|
|
210
|
-
|
|
211
|
-
for (let i = 0; i < args.length; i += 1) {
|
|
212
|
-
const arg = String(args[i]);
|
|
213
|
-
const segments = secretSegments(arg);
|
|
214
|
-
if (segments.length > 0) {
|
|
215
|
-
const parts = String(arg).split(SECRET_KEY_SEP_RE);
|
|
216
|
-
let folded = parts[0] ?? '';
|
|
217
|
-
for (let j = 1; j < parts.length; j += 2) {
|
|
218
|
-
folded += parts[j] + '<redacted>';
|
|
219
|
-
}
|
|
220
|
-
out.push(folded);
|
|
221
|
-
continue;
|
|
222
|
-
}
|
|
223
|
-
const next = i + 1 < args.length ? String(args[i + 1]) : undefined;
|
|
224
|
-
if (SECRET_KEY_TOKEN_RE.test(arg) && next !== undefined && !SECRET_KEY_TOKEN_RE.test(next)) {
|
|
225
|
-
// Bare key token with its value riding the next argv element — fold
|
|
226
|
-
// the value, keep the key. A CHAINED bare key (`--password --token x`)
|
|
227
|
-
// is left for its own iteration so no real value hides behind the
|
|
228
|
-
// skip (loop round 7, seat-1 residual).
|
|
229
|
-
out.push(arg, '<redacted>');
|
|
230
|
-
i += 1;
|
|
231
|
-
continue;
|
|
232
|
-
}
|
|
233
|
-
out.push(arg);
|
|
234
|
-
}
|
|
235
|
-
return out;
|
|
224
|
+
return foldSecretTokens(args);
|
|
236
225
|
}
|
|
237
226
|
function validateRequiredParams(args) {
|
|
238
227
|
if (!args || args.length < 2)
|
|
@@ -250,7 +239,18 @@ export function planHcloudCommand(args, options = {}) {
|
|
|
250
239
|
const inputArgs = Array.isArray(args) ? args.map(String) : [];
|
|
251
240
|
const { args: normalizedArgs, stripped } = stripLeadingHcloudBinArgs(inputArgs);
|
|
252
241
|
const classification = classifyHcloudArgs(normalizedArgs, options);
|
|
253
|
-
|
|
242
|
+
// The echo reproduces the REAL argument's quoting SHAPE and redacts only the
|
|
243
|
+
// value text inside it, so replacing `<redacted>` with the real value yields
|
|
244
|
+
// exactly the line the approval gate accepts for every charset family.
|
|
245
|
+
// Quoting must be decided from the raw argument: the placeholder itself is
|
|
246
|
+
// not charset-safe (`<` and `>` sit outside quoteShellArg's safe set), so
|
|
247
|
+
// quoting the redacted spelling unconditionally would wrap a safe-charset
|
|
248
|
+
// value the real line leaves bare and dead-end the substitution on the most
|
|
249
|
+
// common family (alphanumeric password, hex token). The old post-quote
|
|
250
|
+
// redaction had the mirror defect on the shell-special family (an
|
|
251
|
+
// unbalanced quote), so this one construction now serves both.
|
|
252
|
+
const redactedArgs = normalizedArgs.map((arg) => redactSecrets(arg));
|
|
253
|
+
const command = ['hcloud', ...normalizedArgs.map((raw, i) => redactedCommandArg(raw, redactedArgs[i] ?? ''))].join(' ');
|
|
254
254
|
const warnings = planningWarnings(normalizedArgs);
|
|
255
255
|
if (stripped !== null)
|
|
256
256
|
warnings.unshift(leadingBinWarning(stripped));
|
|
@@ -295,10 +295,10 @@ export function planHcloudCommand(args, options = {}) {
|
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
297
|
const approvalMode = options.approvalMode ?? 'token';
|
|
298
|
-
// Ask mode never mints: the confirmation is the
|
|
299
|
-
//
|
|
300
|
-
//
|
|
301
|
-
//
|
|
298
|
+
// Ask mode never mints: the confirmation is the server-run gate inside
|
|
299
|
+
// the run call, so there is no token to hand the model and nothing lands
|
|
300
|
+
// in the approvals store. Run paths keep mintApprovalToken:false in both
|
|
301
|
+
// modes.
|
|
302
302
|
const approvalToken = approvalMode === 'ask' || options.mintApprovalToken === false
|
|
303
303
|
? undefined
|
|
304
304
|
: createApprovalToken(normalizedArgs, {
|
|
@@ -312,9 +312,10 @@ export function planHcloudCommand(args, options = {}) {
|
|
|
312
312
|
// The plan echo is a COMMAND string, not child-process output — banner
|
|
313
313
|
// stripping is an output concern, and an argument VALUE that happens to
|
|
314
314
|
// carry banner-shaped text must never blank the command the user is asked
|
|
315
|
-
// to approve (
|
|
316
|
-
|
|
317
|
-
|
|
315
|
+
// to approve (redaction only, already applied per arg above so the
|
|
316
|
+
// quoting stays balanced).
|
|
317
|
+
command,
|
|
318
|
+
executableBlock: command,
|
|
318
319
|
warnings,
|
|
319
320
|
classification: applyPreflightFindings(effectiveClassification, sgFindings),
|
|
320
321
|
sgFindings,
|
|
@@ -328,13 +329,18 @@ export function planHcloudCommand(args, options = {}) {
|
|
|
328
329
|
? {
|
|
329
330
|
needed: true,
|
|
330
331
|
mode: 'ask',
|
|
331
|
-
note: 'The
|
|
332
|
+
note: 'The confirmation happens on the server when huaweicloud_run_approved_command is called: an elicitation-capable client renders a form with this command line, and any other client returns ASK_CONFIRMATION_REQUIRED, which you answer by showing the user this command in chat and retrying with approvedByUser: true. Send the same args on every call. This command field is the display line: where it shows <redacted>, substitute the real values, and the args array spelled out is always accepted as the command. No terminal approval line or token is needed.',
|
|
332
333
|
}
|
|
333
334
|
: {
|
|
334
335
|
needed: true,
|
|
335
336
|
...(approvalToken !== undefined ? { command: `npx huaweicloud-devkit approve ${approvalToken}` } : {}),
|
|
336
337
|
}
|
|
337
338
|
: { needed: false },
|
|
338
|
-
|
|
339
|
+
// "Safe to run NOW": a caller-supplied allowWrites:true only unlocks the
|
|
340
|
+
// classification — the strict view still demands the user's confirmation
|
|
341
|
+
// (the approval token/form), so a plan showing decision:"allow" must not
|
|
342
|
+
// also read as runnable while userConfirmation.needed is true (AX D-02
|
|
343
|
+
// display-layer alignment).
|
|
344
|
+
safeToRun: effectiveClassification.decision === 'allow' && !needsConfirmation,
|
|
339
345
|
};
|
|
340
346
|
}
|
|
@@ -4,11 +4,13 @@
|
|
|
4
4
|
// an approval token, the user confirms it in their own terminal
|
|
5
5
|
// (`npx huaweicloud-devkit approve <uuid>`), and run_approved_command
|
|
6
6
|
// consumes the token before executing. 'ask' moves the confirmation onto
|
|
7
|
-
// the
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
7
|
+
// the SERVER (PR-1.5): the operator opts in via the env var (normally
|
|
8
|
+
// written by the installer together with the client's ask rule), and the
|
|
9
|
+
// approval gate runs the confirmation itself inside the run call — an
|
|
10
|
+
// elicitation form on a client that declared the form capability, or the
|
|
11
|
+
// ASK_CONFIRMATION_REQUIRED chat round-trip whose retry carries
|
|
12
|
+
// approvedByUser. No terminal trip and no UUID in the model's context; the
|
|
13
|
+
// plan mints nothing.
|
|
12
14
|
//
|
|
13
15
|
// Resolution is exact-match and fail-loud, mirroring the DEVKIT_PACKS
|
|
14
16
|
// unknown-id doctrine: a typo'd mode must not silently fall back to the
|
|
@@ -2,6 +2,7 @@ import { createHash, createHmac, randomUUID, timingSafeEqual } from 'node:crypto
|
|
|
2
2
|
import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, statSync, unlinkSync, writeFileSync, } from 'node:fs';
|
|
3
3
|
import { dirname, join } from 'node:path';
|
|
4
4
|
import { redactSecrets } from "../safety-policy.js";
|
|
5
|
+
import { redactWithSupplementalKeys } from "./supplemental-redaction.js";
|
|
5
6
|
import { ensureMasterKey, resolveMasterKey } from "./secret-vault/custody.js";
|
|
6
7
|
import { devkitStateBase } from "./pack-state.js";
|
|
7
8
|
const APPROVAL_TTL_MS = 5 * 60_000;
|
|
@@ -185,7 +186,11 @@ export function createApprovalToken(rawArgs, opts = {}) {
|
|
|
185
186
|
const map = readApprovals();
|
|
186
187
|
map[token] = {
|
|
187
188
|
argsHash: hashArgs(rawArgs),
|
|
188
|
-
|
|
189
|
+
// The same supplemental-key pass the trace face and the gate's pin views
|
|
190
|
+
// run (lib/supplemental-redaction.ts): redactSecrets alone lets a
|
|
191
|
+
// long-lived key under api_key ride the store entry and the approve
|
|
192
|
+
// CLI's Confirming line in plaintext (interrogate round 2, F2).
|
|
193
|
+
argsRedacted: redactWithSupplementalKeys(redactSecrets(rawArgs)),
|
|
189
194
|
createdAt: Date.now(),
|
|
190
195
|
...(opts.secretsSubstitutable === true ? { secretsSubstitutable: true } : {}),
|
|
191
196
|
...(opts.argsPinView !== undefined ? { argsPinView: opts.argsPinView } : {}),
|
|
@@ -266,6 +271,17 @@ export function consumeApprovalToken(token, opts = {}) {
|
|
|
266
271
|
// (argsHash, argsPinView, argsRedacted, secretsSubstitutable, createdAt)
|
|
267
272
|
// breaks verification, not just an argsHash swap.
|
|
268
273
|
const GRANT_MAC_DOMAIN = 'huaweicloud-approval-grant';
|
|
274
|
+
// The reusable custody-HMAC grant primitive: the evidence stamp shared by
|
|
275
|
+
// every confirmation channel (terminal today; elicitation and memo stamps
|
|
276
|
+
// in the later approval-chain PRs, each under its own domain). Custody
|
|
277
|
+
// material from one domain never verifies in another, so a grant proves
|
|
278
|
+
// both WHO confirmed (possession of the custody key) and WHAT they
|
|
279
|
+
// confirmed (the subject) and WHEN (the timestamp rides the message).
|
|
280
|
+
export function custodyGrantMac(masterKey, domain, subject, confirmedAt) {
|
|
281
|
+
return createHmac('sha256', masterKey)
|
|
282
|
+
.update(`${domain}\x00${subject}\x00${String(confirmedAt)}`)
|
|
283
|
+
.digest('hex');
|
|
284
|
+
}
|
|
269
285
|
// The shape digests through hashArgs (the module's canonical-JSON machinery),
|
|
270
286
|
// so the confirm side and the verify side agree no matter how the store was
|
|
271
287
|
// re-serialized between them. undefined-valued keys drop on both sides.
|
|
@@ -279,9 +295,7 @@ function grantMac(masterKey, token, entry, confirmedAt) {
|
|
|
279
295
|
secretsSubstitutable: entry.secretsSubstitutable,
|
|
280
296
|
createdAt: entry.createdAt,
|
|
281
297
|
});
|
|
282
|
-
return
|
|
283
|
-
.update(`${GRANT_MAC_DOMAIN}\x00${token}\x00${shapeDigest}\x00${String(confirmedAt)}`)
|
|
284
|
-
.digest('hex');
|
|
298
|
+
return custodyGrantMac(masterKey, GRANT_MAC_DOMAIN, `${token}\x00${shapeDigest}`, confirmedAt);
|
|
285
299
|
}
|
|
286
300
|
export function confirmApprovalToken(token) {
|
|
287
301
|
if (!TOKEN_SHAPE.test(token))
|
|
@@ -26,6 +26,10 @@
|
|
|
26
26
|
// Permissions: the file is created 0600 on first write.
|
|
27
27
|
import { appendFileSync, existsSync, writeFileSync } from 'node:fs';
|
|
28
28
|
import { redactSecrets } from "../safety-policy.js";
|
|
29
|
+
// The supplemental-key pass (api_key/apiKey/value): one shared leaf so
|
|
30
|
+
// every redaction consumer — the trace here, the approval gate's pin views —
|
|
31
|
+
// runs the same vocabulary.
|
|
32
|
+
import { redactWithSupplementalKeys } from "./supplemental-redaction.js";
|
|
29
33
|
const TRACE_ENV = 'HUAWEICLOUD_DEVKIT_TRACE';
|
|
30
34
|
const TRACE_VERSION = 1;
|
|
31
35
|
const MAX_ERROR_LENGTH = 300;
|
|
@@ -34,21 +38,10 @@ const MAX_ERROR_LENGTH = 300;
|
|
|
34
38
|
// gateway_call toolArgs) and the secrets pack's set tool carries the
|
|
35
39
|
// plaintext itself under value (channel=value) — no other tool schema uses
|
|
36
40
|
// that arg name, so the denylist entry is collision-free. Trace redaction
|
|
37
|
-
// must be a superset of the product's, so
|
|
38
|
-
|
|
39
|
-
function redactSupplemental(value) {
|
|
40
|
-
if (Array.isArray(value))
|
|
41
|
-
return value.map((item) => redactSupplemental(item));
|
|
42
|
-
if (value && typeof value === 'object') {
|
|
43
|
-
return Object.fromEntries(Object.entries(value).map(([key, val]) => [
|
|
44
|
-
key,
|
|
45
|
-
SUPPLEMENTAL_SECRET_KEYS.has(key.toLowerCase()) ? '<redacted>' : redactSupplemental(val),
|
|
46
|
-
]));
|
|
47
|
-
}
|
|
48
|
-
return value;
|
|
49
|
-
}
|
|
41
|
+
// must be a superset of the product's, so the supplemental keys get their
|
|
42
|
+
// own pass (imported above from the shared leaf).
|
|
50
43
|
export function redactForTrace(args) {
|
|
51
|
-
return
|
|
44
|
+
return redactWithSupplementalKeys(redactSecrets(args));
|
|
52
45
|
}
|
|
53
46
|
export function traceEnabled() {
|
|
54
47
|
return Boolean(process.env[TRACE_ENV]);
|