huaweicloud-devkit 0.1.23 → 0.1.25-dev.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/package.json
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name":
|
|
3
|
-
"version":
|
|
4
|
-
"description":
|
|
5
|
-
"type":
|
|
6
|
-
"files":
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"bin":
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"repository":
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"scripts":
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"devDependencies":
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"keywords":
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"license":
|
|
40
|
-
"engines":
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
2
|
+
"name": "huaweicloud-devkit",
|
|
3
|
+
"version": "0.1.25-dev.0",
|
|
4
|
+
"description": "Agent toolkit that helps coding agents use Huawei Cloud Skills, KooCLI, APIs, SDKs, and future MCP capabilities safely and accurately.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"files": [
|
|
7
|
+
"bin",
|
|
8
|
+
".agents",
|
|
9
|
+
"plugins/huaweicloud-core",
|
|
10
|
+
"integrations/opencode"
|
|
11
|
+
],
|
|
12
|
+
"bin": {
|
|
13
|
+
"huaweicloud-devkit": "./bin/setup.cjs"
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/huaweicloud-mate/huaweicloud-devkit.git"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"test": "node --test",
|
|
21
|
+
"lint:md": "markdownlint-cli2 \"**/*.md\" \"#node_modules\" \"#.git\" \"#test/**\" \"#docs/**\"",
|
|
22
|
+
"lint": "npm run lint:md",
|
|
23
|
+
"validate": "node ./scripts/validate-package.mjs",
|
|
24
|
+
"postinstall": "node -e \"console.log('\\nHuaweiCloud DevKit installed. Run: npx huaweicloud-devkit install\\n')\""
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"markdownlint-cli2": "^0.23.2"
|
|
28
|
+
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"huaweicloud",
|
|
31
|
+
"huawei-cloud",
|
|
32
|
+
"agent",
|
|
33
|
+
"codex",
|
|
34
|
+
"opencode",
|
|
35
|
+
"mcp",
|
|
36
|
+
"koocli",
|
|
37
|
+
"hcloud"
|
|
38
|
+
],
|
|
39
|
+
"license": "Apache-2.0",
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=20"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -3,6 +3,7 @@ import { stdin, stdout } from 'node:process';
|
|
|
3
3
|
import { TOOL_DEFINITIONS, callTool } from './tools.mjs';
|
|
4
4
|
|
|
5
5
|
let buffer = Buffer.alloc(0);
|
|
6
|
+
let useContentLengthFraming = true;
|
|
6
7
|
|
|
7
8
|
stdin.on('data', (chunk) => {
|
|
8
9
|
buffer = Buffer.concat([buffer, chunk]);
|
|
@@ -12,23 +13,41 @@ stdin.on('data', (chunk) => {
|
|
|
12
13
|
function readFrames() {
|
|
13
14
|
while (true) {
|
|
14
15
|
const headerEnd = buffer.indexOf('\r\n\r\n');
|
|
15
|
-
if (headerEnd
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
buffer = Buffer.alloc(0);
|
|
20
|
-
return;
|
|
16
|
+
if (headerEnd !== -1) {
|
|
17
|
+
useContentLengthFraming = true;
|
|
18
|
+
parseContentLengthFrame(headerEnd);
|
|
19
|
+
continue;
|
|
21
20
|
}
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
|
|
22
|
+
const lf = buffer.indexOf('\n');
|
|
23
|
+
if (lf !== -1) {
|
|
24
|
+
useContentLengthFraming = false;
|
|
25
|
+
const line = buffer.subarray(0, lf).toString('utf8').trim();
|
|
26
|
+
buffer = buffer.subarray(lf + 1);
|
|
27
|
+
if (line) void handleMessage(JSON.parse(line));
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return;
|
|
29
32
|
}
|
|
30
33
|
}
|
|
31
34
|
|
|
35
|
+
function parseContentLengthFrame(headerEnd) {
|
|
36
|
+
const header = buffer.subarray(0, headerEnd).toString('utf8');
|
|
37
|
+
const match = header.match(/Content-Length:\s*(\d+)/i);
|
|
38
|
+
if (!match) {
|
|
39
|
+
buffer = Buffer.alloc(0);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const length = Number(match[1]);
|
|
43
|
+
const bodyStart = headerEnd + 4;
|
|
44
|
+
const bodyEnd = bodyStart + length;
|
|
45
|
+
if (buffer.length < bodyEnd) return;
|
|
46
|
+
const body = buffer.subarray(bodyStart, bodyEnd).toString('utf8');
|
|
47
|
+
buffer = buffer.subarray(bodyEnd);
|
|
48
|
+
void handleMessage(JSON.parse(body));
|
|
49
|
+
}
|
|
50
|
+
|
|
32
51
|
async function handleMessage(message) {
|
|
33
52
|
if (!Object.hasOwn(message, 'id')) {
|
|
34
53
|
if (message.method === 'notifications/initialized') return;
|
|
@@ -89,5 +108,9 @@ async function dispatch(method, params) {
|
|
|
89
108
|
|
|
90
109
|
function writeMessage(message) {
|
|
91
110
|
const json = JSON.stringify(message);
|
|
92
|
-
|
|
111
|
+
if (useContentLengthFraming) {
|
|
112
|
+
stdout.write(`Content-Length: ${Buffer.byteLength(json, 'utf8')}\r\n\r\n${json}`);
|
|
113
|
+
} else {
|
|
114
|
+
stdout.write(json + '\n');
|
|
115
|
+
}
|
|
93
116
|
}
|