huaweicloud-devkit 1.0.2-dev.9 → 1.1.2-next.0
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 +29 -4
- package/README.zh-CN.md +27 -4
- package/bin/setup.cjs +0 -0
- 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/.workbuddy-plugin/plugin.json +1 -1
- package/plugins/huaweicloud-core/skills/huawei-obs/SKILL.md +6 -0
- package/plugins/huaweicloud-core/skills/huawei-sandbox/SKILL.md +13 -8
- package/plugins/huaweicloud-core/skills/huaweicloud-capability-discovery/SKILL.md +4 -0
- package/plugins/huaweicloud-core/skills/huaweicloud-core/SKILL.md +18 -3
- package/plugins/huaweicloud-core/src/auth/agent-registration.mjs +19 -1
- package/plugins/huaweicloud-core/src/proxy/proxy-agent.mjs +155 -0
- package/plugins/huaweicloud-core/src/proxy/proxy-config.mjs +87 -0
- package/plugins/huaweicloud-core/src/sandbox/hdkitservice-api.mjs +7 -3
- package/plugins/huaweicloud-core/src/sandbox/hwlink-api.mjs +12 -3
- package/plugins/huaweicloud-core/src/sandbox/session-manager.mjs +7 -0
- package/plugins/huaweicloud-core/src/search-market.mjs +7 -2
- package/plugins/huaweicloud-core/src/setup-cli.mjs +433 -10
- package/plugins/huaweicloud-core/src/tools.mjs +21 -6
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import crypto from 'node:crypto';
|
|
2
2
|
import { resolveCredentials } from '../auth/credentials.mjs';
|
|
3
|
+
import { getProxyDispatcher } from '../proxy/proxy-agent.mjs';
|
|
3
4
|
|
|
4
5
|
const BASE_URL = process.env.HWLINK_ENDPOINT || 'https://devstation.myhuaweicloud.com';
|
|
5
6
|
|
|
@@ -96,17 +97,25 @@ async function apiGet(path, query, ak, sk, securitytoken) {
|
|
|
96
97
|
const qs = sortedQs(query);
|
|
97
98
|
const fullPath = qs ? `${path}?${qs}` : path;
|
|
98
99
|
const headers = signRequest('GET', path, query, undefined, ak, sk, securitytoken);
|
|
99
|
-
const
|
|
100
|
+
const url = `${BASE_URL}${fullPath}`;
|
|
101
|
+
const dispatcher = await getProxyDispatcher(url);
|
|
102
|
+
const fetchOpts = { headers };
|
|
103
|
+
if (dispatcher) fetchOpts.dispatcher = dispatcher;
|
|
104
|
+
const resp = await fetch(url, fetchOpts);
|
|
100
105
|
return { status: resp.status, data: await resp.json() };
|
|
101
106
|
}
|
|
102
107
|
|
|
103
108
|
async function apiPost(path, body, ak, sk, securitytoken) {
|
|
104
109
|
const headers = signRequest('POST', path, {}, body, ak, sk, securitytoken);
|
|
105
|
-
const
|
|
110
|
+
const url = `${BASE_URL}${path}`;
|
|
111
|
+
const dispatcher = await getProxyDispatcher(url);
|
|
112
|
+
const fetchOpts = {
|
|
106
113
|
method: 'POST',
|
|
107
114
|
headers: { ...headers, 'Content-Type': 'application/json' },
|
|
108
115
|
body: JSON.stringify(body),
|
|
109
|
-
}
|
|
116
|
+
};
|
|
117
|
+
if (dispatcher) fetchOpts.dispatcher = dispatcher;
|
|
118
|
+
const resp = await fetch(url, fetchOpts);
|
|
110
119
|
return { status: resp.status, data: await resp.json() };
|
|
111
120
|
}
|
|
112
121
|
|
|
@@ -2,6 +2,7 @@ import { spawn } from 'node:child_process';
|
|
|
2
2
|
import { join, dirname } from 'node:path';
|
|
3
3
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
4
4
|
import { createConnection, getCredentials } from './hwlink-api.mjs';
|
|
5
|
+
import { getWebSocketImpl } from '../proxy/proxy-agent.mjs';
|
|
5
6
|
|
|
6
7
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
7
8
|
export const WS_EXEC_INDEX_URL = pathToFileURL(join(__dirname, '..', 'ws-exec', 'index.js')).href;
|
|
@@ -55,12 +56,15 @@ async function getSession(workspaceId, username, timeoutMs) {
|
|
|
55
56
|
const { ak, sk, securitytoken } = getCredentials();
|
|
56
57
|
const { wsUrl, source } = await createConnection(workspaceId, ak, sk, securitytoken);
|
|
57
58
|
|
|
59
|
+
const WebSocketImpl = getWebSocketImpl(wsUrl);
|
|
60
|
+
|
|
58
61
|
const { connectHwlinkTerminalSession } = await import(WS_EXEC_INDEX_URL);
|
|
59
62
|
const session = await connectHwlinkTerminalSession({
|
|
60
63
|
url: wsUrl,
|
|
61
64
|
source,
|
|
62
65
|
username,
|
|
63
66
|
timeoutMs,
|
|
67
|
+
WebSocketImpl,
|
|
64
68
|
});
|
|
65
69
|
|
|
66
70
|
sessions.set(key, session);
|
|
@@ -71,6 +75,8 @@ export async function execOneShot(workspaceId, command, username, timeoutMs) {
|
|
|
71
75
|
const { ak, sk, securitytoken } = getCredentials();
|
|
72
76
|
const { wsUrl, source } = await createConnection(workspaceId, ak, sk, securitytoken);
|
|
73
77
|
|
|
78
|
+
const WebSocketImpl = getWebSocketImpl(wsUrl);
|
|
79
|
+
|
|
74
80
|
const { executeHwlinkCommand } = await import(WS_EXEC_INDEX_URL);
|
|
75
81
|
return await executeHwlinkCommand({
|
|
76
82
|
url: wsUrl,
|
|
@@ -78,6 +84,7 @@ export async function execOneShot(workspaceId, command, username, timeoutMs) {
|
|
|
78
84
|
username,
|
|
79
85
|
command,
|
|
80
86
|
timeoutMs,
|
|
87
|
+
WebSocketImpl,
|
|
81
88
|
});
|
|
82
89
|
}
|
|
83
90
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { getProxyDispatcher } from './proxy/proxy-agent.mjs';
|
|
2
|
+
|
|
1
3
|
const INDEX_URL = 'https://gitcode.com/api/v5/repos/2501_91318609/skills-for-index/contents/skills-index/index.json?ref=main';
|
|
2
4
|
const CN_EN_MAP_URL = 'https://gitcode.com/api/v5/repos/2501_91318609/skills-for-index/contents/skills-index/cn-en-map.json?ref=main';
|
|
3
5
|
const HTTP_TIMEOUT_MS = 10000;
|
|
@@ -19,10 +21,13 @@ async function fetchJson(url, label = '') {
|
|
|
19
21
|
const controller = new AbortController();
|
|
20
22
|
const timer = setTimeout(() => controller.abort(), HTTP_TIMEOUT_MS);
|
|
21
23
|
try {
|
|
22
|
-
const
|
|
24
|
+
const dispatcher = await getProxyDispatcher(url);
|
|
25
|
+
const fetchOpts = {
|
|
23
26
|
headers: { 'User-Agent': 'huaweicloud-devkit/1.0' },
|
|
24
27
|
signal: controller.signal,
|
|
25
|
-
}
|
|
28
|
+
};
|
|
29
|
+
if (dispatcher) fetchOpts.dispatcher = dispatcher;
|
|
30
|
+
const resp = await fetch(url, fetchOpts);
|
|
26
31
|
const data = await resp.json();
|
|
27
32
|
if (data && data.encoding === 'base64' && data.content) {
|
|
28
33
|
const decoded = Buffer.from(data.content, 'base64').toString('utf8');
|