@eum-agent/integration-mcp 1.1.0 → 1.2.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/dist/connection-sdk-DYfRLV61.js +114 -0
- package/dist/index.js +841 -751
- package/dist/limits-CiNML2zk.js +72 -0
- package/package.json +4 -4
- package/ui/ui.js +5431 -303
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
//#region src/transport/limits.ts
|
|
3
|
+
const RESPONSE_BYTES = 8388608;
|
|
4
|
+
const resourceBudget = new AsyncLocalStorage();
|
|
5
|
+
function withResourceBudget(maxBytes, request) {
|
|
6
|
+
return resourceBudget.run(maxBytes, request);
|
|
7
|
+
}
|
|
8
|
+
function responseBudget() {
|
|
9
|
+
const raw = resourceBudget.getStore();
|
|
10
|
+
return raw === void 0 ? RESPONSE_BYTES : Math.min(RESPONSE_BYTES, Math.max(6 * raw, 4 * Math.ceil(raw / 3)) + 65536);
|
|
11
|
+
}
|
|
12
|
+
function responseLimit() {
|
|
13
|
+
return Object.assign(/* @__PURE__ */ new Error("MCP response exceeds declared budget"), { code: "read-limit" });
|
|
14
|
+
}
|
|
15
|
+
function boundedFetch(fetch, maxBytes = RESPONSE_BYTES) {
|
|
16
|
+
return async (input, init) => {
|
|
17
|
+
const capacity = Math.min(maxBytes, responseBudget());
|
|
18
|
+
const response = await fetch(input, init);
|
|
19
|
+
if (!response.body) return response;
|
|
20
|
+
const sse = response.headers.get("content-type")?.includes("text/event-stream") ?? false;
|
|
21
|
+
const length = Number(response.headers.get("content-length"));
|
|
22
|
+
if (!sse && Number.isFinite(length) && length > capacity) {
|
|
23
|
+
await response.body.cancel();
|
|
24
|
+
throw responseLimit();
|
|
25
|
+
}
|
|
26
|
+
const reader = response.body.getReader();
|
|
27
|
+
let bytes = 0, lineBytes = 0;
|
|
28
|
+
const body = new ReadableStream({
|
|
29
|
+
async pull(controller) {
|
|
30
|
+
try {
|
|
31
|
+
const next = await reader.read();
|
|
32
|
+
if (next.done) {
|
|
33
|
+
controller.close();
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (sse) for (const byte of next.value) {
|
|
37
|
+
bytes++;
|
|
38
|
+
if (bytes > capacity) throw responseLimit();
|
|
39
|
+
if (byte === 10) {
|
|
40
|
+
if (lineBytes === 0 || lineBytes === 1 && previous === 13) bytes = 0;
|
|
41
|
+
lineBytes = 0;
|
|
42
|
+
} else lineBytes++;
|
|
43
|
+
previous = byte;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
bytes += next.value.byteLength;
|
|
47
|
+
if (bytes > capacity) throw responseLimit();
|
|
48
|
+
}
|
|
49
|
+
controller.enqueue(next.value);
|
|
50
|
+
} catch (error) {
|
|
51
|
+
await reader.cancel(error).catch(() => {});
|
|
52
|
+
controller.error(error);
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
cancel: (reason) => reader.cancel(reason)
|
|
56
|
+
});
|
|
57
|
+
let previous = -1;
|
|
58
|
+
const bounded = new Response(body, {
|
|
59
|
+
status: response.status,
|
|
60
|
+
statusText: response.statusText,
|
|
61
|
+
headers: response.headers
|
|
62
|
+
});
|
|
63
|
+
for (const key of [
|
|
64
|
+
"url",
|
|
65
|
+
"redirected",
|
|
66
|
+
"type"
|
|
67
|
+
]) Object.defineProperty(bounded, key, { value: response[key] });
|
|
68
|
+
return bounded;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
export { withResourceBudget as a, responseLimit as i, boundedFetch as n, responseBudget as r, RESPONSE_BYTES as t };
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"en-US": "MCP Tool Integration",
|
|
5
5
|
"zh-CN": "MCP 工具接入"
|
|
6
6
|
},
|
|
7
|
-
"version": "1.
|
|
7
|
+
"version": "1.2.0",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"description": "Tools, resources and prompts from Model Context Protocol servers",
|
|
10
10
|
"license": "MIT",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@eum-agent/container": "1.0.0",
|
|
28
28
|
"@eum-agent/kernel": "1.0.0",
|
|
29
|
-
"@eum-agent/plugin": "1.
|
|
29
|
+
"@eum-agent/plugin": "1.2.0",
|
|
30
30
|
"@eum-agent/runtime": "1.0.0",
|
|
31
31
|
"@types/react": "^19.2.18",
|
|
32
32
|
"@types/react-dom": "^19.2.5",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"dependencies": {},
|
|
45
45
|
"kind": "extension",
|
|
46
46
|
"foundationDependencies": {
|
|
47
|
-
"@eum-agent/infra-local": "1.0
|
|
48
|
-
"@eum-agent/storage-sqlite": "1.
|
|
47
|
+
"@eum-agent/infra-local": "1.2.0",
|
|
48
|
+
"@eum-agent/storage-sqlite": "1.2.0"
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|