huaweicloud-devkit 1.0.2-next.6 → 1.0.2-next.7
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/package.json +1 -1
- package/plugins/huaweicloud-core/.claude-plugin/plugin.json +1 -1
- package/plugins/huaweicloud-core/.codex-plugin/plugin.json +1 -1
- package/plugins/huaweicloud-core/.cursor-plugin/plugin.json +1 -1
- package/plugins/huaweicloud-core/.workbuddy-plugin/plugin.json +1 -1
- package/plugins/huaweicloud-core/src/proxy/proxy-agent.mjs +9 -100
- package/plugins/huaweicloud-core/src/sandbox/session-manager.mjs +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "huaweicloud-devkit",
|
|
3
|
-
"version": "1.0.2-next.
|
|
3
|
+
"version": "1.0.2-next.7",
|
|
4
4
|
"description": "Agent toolkit that helps coding agents use Huawei Cloud Skills, KooCLI, APIs, SDKs, and future MCP capabilities safely and accurately.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"mcpServers": "./.mcp.json",
|
|
21
21
|
"description": "Guide coding agents to use Huawei Cloud Skills, KooCLI, APIs, SDKs, and future MCP capabilities with safer execution and less context.",
|
|
22
22
|
"skills": "./skills/",
|
|
23
|
-
"version": "1.0.2-next.
|
|
23
|
+
"version": "1.0.2-next.7",
|
|
24
24
|
"author": {
|
|
25
25
|
"name": "HuaweiCloud Mate",
|
|
26
26
|
"url": "https://github.com/huaweicloud"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "huaweicloud-core",
|
|
3
|
-
"version": "1.0.2-next.
|
|
3
|
+
"version": "1.0.2-next.7",
|
|
4
4
|
"description": "Guide coding agents to use Huawei Cloud Skills, KooCLI, APIs, SDKs, and future MCP capabilities with safer execution and less context.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "HuaweiCloud Mate",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"mcpServers": "./.mcp.json",
|
|
21
21
|
"description": "Guide coding agents to use Huawei Cloud Skills, KooCLI, APIs, SDKs, and future MCP capabilities with safer execution and less context.",
|
|
22
22
|
"skills": "./skills/",
|
|
23
|
-
"version": "1.0.2-next.
|
|
23
|
+
"version": "1.0.2-next.7",
|
|
24
24
|
"author": {
|
|
25
25
|
"name": "HuaweiCloud Mate",
|
|
26
26
|
"url": "https://github.com/huaweicloud"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "huaweicloud-core",
|
|
3
|
-
"version": "1.0.2-next.
|
|
3
|
+
"version": "1.0.2-next.7",
|
|
4
4
|
"description": "Guide coding agents to use Huawei Cloud Skills, KooCLI, APIs, SDKs, and future MCP capabilities with safer execution and less context.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "HuaweiCloud Mate",
|
|
@@ -48,113 +48,22 @@ export async function createProxyWebSocket(url, protocols) {
|
|
|
48
48
|
return new UndiciWebSocket(url, wsOptions);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
export function getWebSocketImpl(targetUrl) {
|
|
51
|
+
export async function getWebSocketImpl(targetUrl) {
|
|
52
52
|
const proxyUrl = getProxyUrlForTarget(targetUrl);
|
|
53
53
|
if (!proxyUrl) return globalThis.WebSocket;
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (!proxyUrlForTarget) {
|
|
58
|
-
return new globalThis.WebSocket(url, protocols);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const wsPromise = (async () => {
|
|
62
|
-
const dispatcher = await getProxyDispatcher(url);
|
|
63
|
-
const { WebSocket: UndiciWebSocket } = await importUndici();
|
|
55
|
+
const dispatcher = await getProxyDispatcher(targetUrl);
|
|
56
|
+
const { WebSocket: UndiciWebSocket } = await importUndici();
|
|
64
57
|
|
|
65
|
-
|
|
58
|
+
class ProxyWebSocket extends UndiciWebSocket {
|
|
59
|
+
constructor(url, protocols) {
|
|
60
|
+
const options = { dispatcher };
|
|
66
61
|
if (protocols) {
|
|
67
|
-
|
|
68
|
-
wsOptions.protocols = protocols;
|
|
69
|
-
} else {
|
|
70
|
-
wsOptions.protocols = [protocols];
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return new UndiciWebSocket(url, wsOptions);
|
|
75
|
-
})();
|
|
76
|
-
|
|
77
|
-
return createSyncProxyWebSocketWrapper(wsPromise);
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function createSyncProxyWebSocketWrapper(wsPromise) {
|
|
82
|
-
const pendingEvents = [];
|
|
83
|
-
const eventHandlers = new Map();
|
|
84
|
-
let ws = null;
|
|
85
|
-
let settled = false;
|
|
86
|
-
let readyState = 0;
|
|
87
|
-
let binaryType = 'arraybuffer';
|
|
88
|
-
|
|
89
|
-
const wrapper = {
|
|
90
|
-
get readyState() { return ws ? ws.readyState : readyState; },
|
|
91
|
-
get url() { return ws ? ws.url : ''; },
|
|
92
|
-
get protocol() { return ws ? ws.protocol : ''; },
|
|
93
|
-
get binaryType() { return ws ? ws.binaryType : binaryType; },
|
|
94
|
-
set binaryType(v) {
|
|
95
|
-
binaryType = v;
|
|
96
|
-
if (ws) ws.binaryType = v;
|
|
97
|
-
},
|
|
98
|
-
|
|
99
|
-
send(data, callback) {
|
|
100
|
-
if (ws) {
|
|
101
|
-
if (ws.send.length >= 2) return ws.send(data, callback);
|
|
102
|
-
try { ws.send(data); if (callback) callback(null); } catch (e) { if (callback) callback(e); }
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
pendingEvents.push({ type: 'send', data, callback });
|
|
106
|
-
},
|
|
107
|
-
|
|
108
|
-
close(code, reason) {
|
|
109
|
-
if (ws) { ws.close(code, reason); return; }
|
|
110
|
-
readyState = 3;
|
|
111
|
-
pendingEvents.push({ type: 'close', code, reason });
|
|
112
|
-
},
|
|
113
|
-
|
|
114
|
-
addEventListener(type, handler) {
|
|
115
|
-
if (!eventHandlers.has(type)) eventHandlers.set(type, new Set());
|
|
116
|
-
eventHandlers.get(type).add(handler);
|
|
117
|
-
if (ws) ws.addEventListener(type, handler);
|
|
118
|
-
},
|
|
119
|
-
|
|
120
|
-
removeEventListener(type, handler) {
|
|
121
|
-
const handlers = eventHandlers.get(type);
|
|
122
|
-
if (handlers) handlers.delete(handler);
|
|
123
|
-
if (ws) ws.removeEventListener(type, handler);
|
|
124
|
-
},
|
|
125
|
-
|
|
126
|
-
on(type, handler) { wrapper.addEventListener(type, handler); },
|
|
127
|
-
off(type, handler) { wrapper.removeEventListener(type, handler); },
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
function flushPendingEvents() {
|
|
131
|
-
for (const evt of pendingEvents) {
|
|
132
|
-
if (evt.type === 'send') {
|
|
133
|
-
if (ws.send.length >= 2) ws.send(evt.data, evt.callback);
|
|
134
|
-
else { try { ws.send(evt.data); if (evt.callback) evt.callback(null); } catch (e) { if (evt.callback) evt.callback(e); } }
|
|
135
|
-
} else if (evt.type === 'close') {
|
|
136
|
-
ws.close(evt.code, evt.reason);
|
|
62
|
+
options.protocols = Array.isArray(protocols) ? protocols : [protocols];
|
|
137
63
|
}
|
|
64
|
+
super(url, options);
|
|
138
65
|
}
|
|
139
|
-
pendingEvents.length = 0;
|
|
140
66
|
}
|
|
141
67
|
|
|
142
|
-
|
|
143
|
-
ws = resolvedWs;
|
|
144
|
-
if ('binaryType' in ws) ws.binaryType = binaryType;
|
|
145
|
-
for (const [type, handlers] of eventHandlers) {
|
|
146
|
-
for (const handler of handlers) {
|
|
147
|
-
ws.addEventListener(type, handler);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
flushPendingEvents();
|
|
151
|
-
}).catch((err) => {
|
|
152
|
-
readyState = 3;
|
|
153
|
-
const handlers = eventHandlers.get('error');
|
|
154
|
-
if (handlers) for (const h of handlers) h(err instanceof Error ? err : new Error(String(err)));
|
|
155
|
-
const closeHandlers = eventHandlers.get('close');
|
|
156
|
-
if (closeHandlers) for (const h of closeHandlers) h({ code: 1006, reason: err.message || String(err) });
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
return wrapper;
|
|
68
|
+
return ProxyWebSocket;
|
|
160
69
|
}
|
|
@@ -58,7 +58,7 @@ async function getSession(workspaceId, username, timeoutMs) {
|
|
|
58
58
|
const { ak, sk, securitytoken } = getCredentials();
|
|
59
59
|
const { wsUrl, source } = await createConnection(workspaceId, ak, sk, securitytoken);
|
|
60
60
|
|
|
61
|
-
const WebSocketImpl = getWebSocketImpl(wsUrl);
|
|
61
|
+
const WebSocketImpl = await getWebSocketImpl(wsUrl);
|
|
62
62
|
|
|
63
63
|
const { connectHwlinkTerminalSession } = await import(WS_EXEC_INDEX_URL);
|
|
64
64
|
const session = await connectHwlinkTerminalSession({
|
|
@@ -77,7 +77,7 @@ export async function execOneShot(workspaceId, command, username, timeoutMs) {
|
|
|
77
77
|
const { ak, sk, securitytoken } = getCredentials();
|
|
78
78
|
const { wsUrl, source } = await createConnection(workspaceId, ak, sk, securitytoken);
|
|
79
79
|
|
|
80
|
-
const WebSocketImpl = getWebSocketImpl(wsUrl);
|
|
80
|
+
const WebSocketImpl = await getWebSocketImpl(wsUrl);
|
|
81
81
|
|
|
82
82
|
const { executeHwlinkCommand } = await import(WS_EXEC_INDEX_URL);
|
|
83
83
|
return await executeHwlinkCommand({
|