orbitx 0.0.3 → 0.0.4
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/{src/core/ai-provider.ts → dist/core/ai-provider.d.ts} +19 -25
- package/dist/core/ai-provider.d.ts.map +1 -0
- package/dist/core/ai-provider.js +4 -0
- package/dist/core/ai-provider.js.map +1 -0
- package/dist/core/base-agent.d.ts +53 -0
- package/dist/core/base-agent.d.ts.map +1 -0
- package/{src/core/base-agent.ts → dist/core/base-agent.js} +197 -269
- package/dist/core/base-agent.js.map +1 -0
- package/dist/core/deepseek-provider.d.ts +9 -0
- package/dist/core/deepseek-provider.d.ts.map +1 -0
- package/{src/core/deepseek-provider.ts → dist/core/deepseek-provider.js} +60 -71
- package/dist/core/deepseek-provider.js.map +1 -0
- package/dist/core/mcp-client.d.ts +21 -0
- package/dist/core/mcp-client.d.ts.map +1 -0
- package/{src/core/mcp-client.ts → dist/core/mcp-client.js} +90 -113
- package/dist/core/mcp-client.js.map +1 -0
- package/dist/core/mcp-computer.d.ts +4 -0
- package/dist/core/mcp-computer.d.ts.map +1 -0
- package/{src/core/mcp-computer.ts → dist/core/mcp-computer.js} +5 -5
- package/dist/core/mcp-computer.js.map +1 -0
- package/dist/core/mcp-connection.d.ts +6 -0
- package/dist/core/mcp-connection.d.ts.map +1 -0
- package/dist/core/mcp-connection.js +10 -0
- package/dist/core/mcp-connection.js.map +1 -0
- package/dist/core/mcp-ipc-connection.d.ts +20 -0
- package/dist/core/mcp-ipc-connection.d.ts.map +1 -0
- package/{src/core/mcp-ipc-connection.ts → dist/core/mcp-ipc-connection.js} +126 -153
- package/dist/core/mcp-ipc-connection.js.map +1 -0
- package/dist/core/mcp-server.d.ts +9 -0
- package/dist/core/mcp-server.d.ts.map +1 -0
- package/{src/core/mcp-server.ts → dist/core/mcp-server.js} +45 -49
- package/dist/core/mcp-server.js.map +1 -0
- package/dist/core/mcp.d.ts +29 -0
- package/dist/core/mcp.d.ts.map +1 -0
- package/dist/core/mcp.js +11 -0
- package/dist/core/mcp.js.map +1 -0
- package/dist/core/ollama-provider.d.ts +9 -0
- package/dist/core/ollama-provider.d.ts.map +1 -0
- package/{src/core/ollama-provider.ts → dist/core/ollama-provider.js} +59 -70
- package/dist/core/ollama-provider.js.map +1 -0
- package/dist/core/skill.d.ts +15 -0
- package/dist/core/skill.d.ts.map +1 -0
- package/dist/core/skill.js +11 -0
- package/dist/core/skill.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/{src/index.ts → dist/index.js} +16 -17
- package/dist/index.js.map +1 -0
- package/dist/templates/researcher.d.ts +27 -0
- package/dist/templates/researcher.d.ts.map +1 -0
- package/dist/templates/researcher.js +70 -0
- package/dist/templates/researcher.js.map +1 -0
- package/dist/templates/simple.d.ts +27 -0
- package/dist/templates/simple.d.ts.map +1 -0
- package/dist/templates/simple.js +35 -0
- package/dist/templates/simple.js.map +1 -0
- package/dist/tests/mcp.test.d.ts +2 -0
- package/dist/tests/mcp.test.d.ts.map +1 -0
- package/{src/tests/mcp.test.ts → dist/tests/mcp.test.js} +55 -73
- package/dist/tests/mcp.test.js.map +1 -0
- package/dist/tools/fs/index.d.ts +3 -0
- package/dist/tools/fs/index.d.ts.map +1 -0
- package/dist/tools/fs/index.js +3 -0
- package/dist/tools/fs/index.js.map +1 -0
- package/dist/tools/fs/read-file.d.ts +4 -0
- package/dist/tools/fs/read-file.d.ts.map +1 -0
- package/{src/tools/fs/read-file.ts → dist/tools/fs/read-file.js} +49 -54
- package/dist/tools/fs/read-file.js.map +1 -0
- package/dist/tools/fs/write-file.d.ts +4 -0
- package/dist/tools/fs/write-file.d.ts.map +1 -0
- package/{src/tools/fs/write-file.ts → dist/tools/fs/write-file.js} +68 -73
- package/dist/tools/fs/write-file.js.map +1 -0
- package/dist/tools/utils/get-current-time.d.ts +4 -0
- package/dist/tools/utils/get-current-time.d.ts.map +1 -0
- package/{src/tools/utils/get-current-time.ts → dist/tools/utils/get-current-time.js} +40 -45
- package/dist/tools/utils/get-current-time.js.map +1 -0
- package/dist/tools/utils/index.d.ts +2 -0
- package/dist/tools/utils/index.d.ts.map +1 -0
- package/dist/tools/utils/index.js +2 -0
- package/dist/tools/utils/index.js.map +1 -0
- package/dist/tools/www/fetch.d.ts +4 -0
- package/dist/tools/www/fetch.d.ts.map +1 -0
- package/{src/tools/www/fetch.ts → dist/tools/www/fetch.js} +147 -161
- package/dist/tools/www/fetch.js.map +1 -0
- package/dist/tools/www/index.d.ts +4 -0
- package/dist/tools/www/index.d.ts.map +1 -0
- package/dist/tools/www/index.js +4 -0
- package/dist/tools/www/index.js.map +1 -0
- package/dist/tools/www/read-web-page.d.ts +4 -0
- package/dist/tools/www/read-web-page.d.ts.map +1 -0
- package/{src/tools/www/read-web-page.ts → dist/tools/www/read-web-page.js} +330 -350
- package/dist/tools/www/read-web-page.js.map +1 -0
- package/dist/tools/www/web-search.d.ts +4 -0
- package/dist/tools/www/web-search.d.ts.map +1 -0
- package/{src/tools/www/web-search.ts → dist/tools/www/web-search.js} +82 -102
- package/dist/tools/www/web-search.js.map +1 -0
- package/package.json +19 -5
- package/.env.example +0 -1
- package/orbitx.png +0 -0
- package/public/index.html +0 -397
- package/src/core/mcp-connection.ts +0 -12
- package/src/core/mcp.ts +0 -23
- package/src/core/skill.ts +0 -16
- package/src/templates/researcher.ts +0 -73
- package/src/templates/simple.ts +0 -64
- package/src/tools/fs/index.ts +0 -2
- package/src/tools/utils/index.ts +0 -1
- package/src/tools/www/index.ts +0 -3
- package/tsconfig.json +0 -34
|
@@ -1,73 +1,68 @@
|
|
|
1
|
-
import MCPTool from "../../core/mcp";
|
|
2
|
-
import fs from "fs/promises";
|
|
3
|
-
import path from "path";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (err.code === "
|
|
52
|
-
errorMessage = `
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
errorMessage = `
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
export default WriteFileTool;
|
|
1
|
+
import MCPTool from "../../core/mcp";
|
|
2
|
+
import fs from "fs/promises";
|
|
3
|
+
import path from "path";
|
|
4
|
+
export const WriteFileTool = new MCPTool({
|
|
5
|
+
name: "write-file",
|
|
6
|
+
description: "Writes text content to a file at the specified path. Creates new file or overwrites existing.",
|
|
7
|
+
inputs: [{
|
|
8
|
+
name: "filePath",
|
|
9
|
+
type: "string",
|
|
10
|
+
description: `Absolute or relative path to the file (e.g., "/home/user/doc.txt" or "./file.txt")`,
|
|
11
|
+
required: true,
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: "data",
|
|
15
|
+
type: "string",
|
|
16
|
+
description: "Text content to write (supports multi-line)",
|
|
17
|
+
required: true,
|
|
18
|
+
}],
|
|
19
|
+
execute: async (_, inputs) => {
|
|
20
|
+
try {
|
|
21
|
+
const { filePath, data } = inputs;
|
|
22
|
+
if (!filePath || typeof filePath !== "string") {
|
|
23
|
+
throw new Error("filePath must be a non-empty string");
|
|
24
|
+
}
|
|
25
|
+
if (typeof data !== "string") {
|
|
26
|
+
throw new Error("data must be a string");
|
|
27
|
+
}
|
|
28
|
+
const normalizedPath = path.normalize(filePath);
|
|
29
|
+
const dir = path.dirname(normalizedPath);
|
|
30
|
+
await fs.mkdir(dir, { recursive: true });
|
|
31
|
+
await fs.writeFile(normalizedPath, data, "utf-8");
|
|
32
|
+
return {
|
|
33
|
+
message: `File written: ${normalizedPath}`,
|
|
34
|
+
path: normalizedPath,
|
|
35
|
+
size: data.length
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
let errorMessage = error instanceof Error ? error.message : String(error);
|
|
40
|
+
if (error instanceof Error && "code" in error) {
|
|
41
|
+
const err = error;
|
|
42
|
+
if (err.code === "EACCES") {
|
|
43
|
+
errorMessage = `Permission denied: Cannot write to ${inputs.filePath}`;
|
|
44
|
+
}
|
|
45
|
+
else if (err.code === "ENOENT") {
|
|
46
|
+
errorMessage = `Directory does not exist or cannot be created: ${path.dirname(inputs.filePath)}`;
|
|
47
|
+
}
|
|
48
|
+
else if (err.code === "EISDIR") {
|
|
49
|
+
errorMessage = `Path is a directory, cannot write file: ${inputs.filePath}`;
|
|
50
|
+
}
|
|
51
|
+
else if (err.code === "ENOSPC") {
|
|
52
|
+
errorMessage = `No space left on device: Cannot write to ${inputs.filePath}`;
|
|
53
|
+
}
|
|
54
|
+
else if (err.code === "EROFS") {
|
|
55
|
+
errorMessage = `Read-only file system: Cannot write to ${inputs.filePath}`;
|
|
56
|
+
}
|
|
57
|
+
else if (err.code === "ENAMETOOLONG") {
|
|
58
|
+
errorMessage = `File path is too long: ${inputs.filePath}`;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
error: errorMessage
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
export default WriteFileTool;
|
|
68
|
+
//# sourceMappingURL=write-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-file.js","sourceRoot":"","sources":["../../../src/tools/fs/write-file.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,OAAO,CAAC;IACrC,IAAI,EAAE,YAAY;IAClB,WAAW,EAAE,+FAA+F;IAC5G,MAAM,EAAE,CAAC;YACL,IAAI,EAAE,UAAU;YAChB,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,oFAAoF;YACjG,QAAQ,EAAE,IAAI;SACjB;QACD;YACI,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,6CAA6C;YAC1D,QAAQ,EAAE,IAAI;SACjB,CAAC;IACF,OAAO,EAAE,KAAK,EAAE,CAAS,EAAE,MAA2B,EAAgB,EAAE;QACpE,IAAI,CAAC;YACD,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC;YAElC,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;gBAC5C,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;YAC3D,CAAC;YAED,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAC3B,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;YAC7C,CAAC;YAED,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;YAEhD,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;YACzC,MAAM,EAAE,CAA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AAM,IAAI,GAAG,CAAC,IAAI,KAAK,cAAc,EAAE,CAAC;oBACrC,YAAY,GAAG,0BAA0B,MAAM,CAAC,QAAQ,EAAE,CAAC;gBAC/D,CAAC;YACL,CAAC;YAED,OAAO;gBACH,KAAK,EAAE,YAAY;aACtB,CAAC;QACN,CAAC;IACL,CAAC;CACJ,CAAC,CAAC;AAEH,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-current-time.d.ts","sourceRoot":"","sources":["../../../src/tools/utils/get-current-time.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,gBAAgB,CAAC;AAErC,eAAO,MAAM,kBAAkB,SAwC7B,CAAC;AAEH,eAAe,kBAAkB,CAAC"}
|
|
@@ -1,45 +1,40 @@
|
|
|
1
|
-
import MCPTool from "../../core/mcp";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
};
|
|
42
|
-
},
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
export default GetCurrentTimeTool;
|
|
1
|
+
import MCPTool from "../../core/mcp";
|
|
2
|
+
export const GetCurrentTimeTool = new MCPTool({
|
|
3
|
+
name: "get-current-time",
|
|
4
|
+
description: "Returns current time (24h) and today's date in Gregorian, Persian, and Islamic calendars.",
|
|
5
|
+
inputs: [],
|
|
6
|
+
execute: async (_, __) => {
|
|
7
|
+
const now = new Date();
|
|
8
|
+
const time = now.toLocaleTimeString("en-US", {
|
|
9
|
+
hour: "2-digit",
|
|
10
|
+
minute: "2-digit",
|
|
11
|
+
hour12: false
|
|
12
|
+
});
|
|
13
|
+
const gregorian = now.toLocaleDateString("en-US", {
|
|
14
|
+
weekday: "long",
|
|
15
|
+
year: "numeric",
|
|
16
|
+
month: "long",
|
|
17
|
+
day: "numeric"
|
|
18
|
+
});
|
|
19
|
+
const persian = now.toLocaleDateString("fa-IR-u-ca-persian", {
|
|
20
|
+
weekday: "long",
|
|
21
|
+
year: "numeric",
|
|
22
|
+
month: "long",
|
|
23
|
+
day: "numeric"
|
|
24
|
+
});
|
|
25
|
+
const hijri = now.toLocaleDateString("ar-SA-u-ca-islamic", {
|
|
26
|
+
weekday: "long",
|
|
27
|
+
year: "numeric",
|
|
28
|
+
month: "long",
|
|
29
|
+
day: "numeric"
|
|
30
|
+
});
|
|
31
|
+
return {
|
|
32
|
+
time,
|
|
33
|
+
gregorian,
|
|
34
|
+
persian,
|
|
35
|
+
hijri
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
export default GetCurrentTimeTool;
|
|
40
|
+
//# sourceMappingURL=get-current-time.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-current-time.js","sourceRoot":"","sources":["../../../src/tools/utils/get-current-time.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,gBAAgB,CAAC;AAErC,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,OAAO,CAAC;IAC1C,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,2FAA2F;IACxG,MAAM,EAAE,EAAE;IACV,OAAO,EAAE,KAAK,EAAE,CAAS,EAAE,EAAuB,EAAgB,EAAE;QAChE,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,IAAI,GAAG,GAAG,CAAC,kBAAkB,CAAC,OAAO,EAAE;YACzC,IAAI,EAAE,SAAS;YACf,MAAM,EAAE,SAAS;YACjB,MAAM,EAAE,KAAK;SAChB,CAAC,CAAC;QAEH,MAAM,SAAS,GAAG,GAAG,CAAC,kBAAkB,CAAC,OAAO,EAAE;YAC9C,OAAO,EAAE,MAAM;YACf,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,MAAM;YACb,GAAG,EAAE,SAAS;SACjB,CAAC,CAAC;QAEH,MAAM,OAAO,GAAG,GAAG,CAAC,kBAAkB,CAAC,oBAAoB,EAAE;YACzD,OAAO,EAAE,MAAM;YACf,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,MAAM;YACb,GAAG,EAAE,SAAS;SACjB,CAAC,CAAC;QAEH,MAAM,KAAK,GAAG,GAAG,CAAC,kBAAkB,CAAC,oBAAoB,EAAE;YACvD,OAAO,EAAE,MAAM;YACf,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,MAAM;YACb,GAAG,EAAE,SAAS;SACjB,CAAC,CAAC;QAEH,OAAO;YACH,IAAI;YACJ,SAAS;YACT,OAAO;YACP,KAAK;SACR,CAAC;IACN,CAAC;CACJ,CAAC,CAAC;AAEH,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../src/tools/www/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,gBAAgB,CAAC;AAErC,eAAO,MAAM,SAAS,SA4JpB,CAAC;AAEH,eAAe,SAAS,CAAC"}
|
|
@@ -1,161 +1,147 @@
|
|
|
1
|
-
import MCPTool from "../../core/mcp";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
new URL
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (
|
|
55
|
-
throw new Error(
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
if (
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
errorMessage = `Connection reset by peer: ${inputs.url}`;
|
|
149
|
-
} else if (error.message.includes("ETIMEDOUT")) {
|
|
150
|
-
errorMessage = `Connection timed out: ${inputs.url}`;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
return {
|
|
155
|
-
error: errorMessage,
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
export default FetchTool;
|
|
1
|
+
import MCPTool from "../../core/mcp";
|
|
2
|
+
export const FetchTool = new MCPTool({
|
|
3
|
+
name: "fetch",
|
|
4
|
+
description: "Makes HTTP requests to APIs or endpoints. For testing APIs, fetching data, or making web requests. Not intended for reading web pages (HTML).",
|
|
5
|
+
inputs: [{
|
|
6
|
+
name: "url",
|
|
7
|
+
type: "string",
|
|
8
|
+
description: "The URL to fetch (e.g., 'https://api.example.com/data')",
|
|
9
|
+
required: true,
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
name: "method",
|
|
13
|
+
type: "string",
|
|
14
|
+
description: "HTTP method (GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS)",
|
|
15
|
+
required: false,
|
|
16
|
+
default: "GET"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: "headers",
|
|
20
|
+
type: "object",
|
|
21
|
+
description: "HTTP headers as key-value pairs (e.g., {'Authorization': 'Bearer token', 'Content-Type': 'application/json'})",
|
|
22
|
+
required: false,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: "body",
|
|
26
|
+
type: "string",
|
|
27
|
+
description: "Request body (required for POST, PUT, PATCH methods). Can be JSON string or form data.",
|
|
28
|
+
required: false,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: "timeout",
|
|
32
|
+
type: "number",
|
|
33
|
+
description: "Request timeout in milliseconds (default: 30000)",
|
|
34
|
+
required: false,
|
|
35
|
+
default: 30000
|
|
36
|
+
}],
|
|
37
|
+
execute: async (_, inputs) => {
|
|
38
|
+
try {
|
|
39
|
+
const { url, method = "GET", headers = {}, body, timeout = 30000 } = inputs;
|
|
40
|
+
if (!url || typeof url !== "string") {
|
|
41
|
+
throw new Error("url must be a non-empty string");
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
new URL(url);
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
throw new Error(`Invalid URL format: ${url}`);
|
|
48
|
+
}
|
|
49
|
+
const validMethods = ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"];
|
|
50
|
+
const normalizedMethod = method.toUpperCase();
|
|
51
|
+
if (!validMethods.includes(normalizedMethod)) {
|
|
52
|
+
throw new Error(`Invalid HTTP method: ${method}. Must be one of: ${validMethods.join(", ")}`);
|
|
53
|
+
}
|
|
54
|
+
if (body && ["GET", "HEAD", "OPTIONS"].includes(normalizedMethod)) {
|
|
55
|
+
throw new Error(`${normalizedMethod} requests cannot have a body`);
|
|
56
|
+
}
|
|
57
|
+
let parsedHeaders = headers;
|
|
58
|
+
if (typeof headers === "string") {
|
|
59
|
+
try {
|
|
60
|
+
parsedHeaders = JSON.parse(headers);
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
throw new Error("headers must be a valid JSON object");
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (parsedHeaders && typeof parsedHeaders !== "object") {
|
|
67
|
+
throw new Error("headers must be an object or JSON string");
|
|
68
|
+
}
|
|
69
|
+
const controller = new AbortController();
|
|
70
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
71
|
+
try {
|
|
72
|
+
const fetchOptions = {
|
|
73
|
+
method: normalizedMethod,
|
|
74
|
+
headers: parsedHeaders || {},
|
|
75
|
+
signal: controller.signal,
|
|
76
|
+
};
|
|
77
|
+
if (body) {
|
|
78
|
+
const isJson = typeof body === "string" && (body.trim().startsWith("{") ||
|
|
79
|
+
body.trim().startsWith("["));
|
|
80
|
+
if (isJson && !parsedHeaders?.["Content-Type"] && !parsedHeaders?.["content-type"]) {
|
|
81
|
+
fetchOptions.headers = {
|
|
82
|
+
...parsedHeaders,
|
|
83
|
+
"Content-Type": "application/json"
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
fetchOptions.body = body;
|
|
87
|
+
}
|
|
88
|
+
const response = await fetch(url, fetchOptions);
|
|
89
|
+
clearTimeout(timeoutId);
|
|
90
|
+
const contentType = response.headers.get("content-type") || "";
|
|
91
|
+
let data;
|
|
92
|
+
if (contentType.includes("application/json")) {
|
|
93
|
+
try {
|
|
94
|
+
data = await response.json();
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
data = await response.text();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
data = await response.text();
|
|
102
|
+
}
|
|
103
|
+
const result = {
|
|
104
|
+
status: response.status,
|
|
105
|
+
statusText: response.statusText,
|
|
106
|
+
headers: Object.fromEntries(response.headers.entries()),
|
|
107
|
+
data: data,
|
|
108
|
+
};
|
|
109
|
+
if (!response.ok) {
|
|
110
|
+
return {
|
|
111
|
+
...result,
|
|
112
|
+
error: `HTTP ${response.status}: ${response.statusText}`,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
return result;
|
|
116
|
+
}
|
|
117
|
+
finally {
|
|
118
|
+
clearTimeout(timeoutId);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
let errorMessage = error instanceof Error ? error.message : String(error);
|
|
123
|
+
if (error instanceof Error) {
|
|
124
|
+
if (error.name === "AbortError") {
|
|
125
|
+
errorMessage = `Request timed out after ${inputs.timeout || 30000}ms`;
|
|
126
|
+
}
|
|
127
|
+
else if (error.message.includes("ENOTFOUND")) {
|
|
128
|
+
errorMessage = `DNS resolution failed: ${inputs.url}`;
|
|
129
|
+
}
|
|
130
|
+
else if (error.message.includes("ECONNREFUSED")) {
|
|
131
|
+
errorMessage = `Connection refused: ${inputs.url}`;
|
|
132
|
+
}
|
|
133
|
+
else if (error.message.includes("ECONNRESET")) {
|
|
134
|
+
errorMessage = `Connection reset by peer: ${inputs.url}`;
|
|
135
|
+
}
|
|
136
|
+
else if (error.message.includes("ETIMEDOUT")) {
|
|
137
|
+
errorMessage = `Connection timed out: ${inputs.url}`;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
error: errorMessage,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
export default FetchTool;
|
|
147
|
+
//# sourceMappingURL=fetch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../../src/tools/www/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,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AAW,CAAC,EAAE,CAAC;oBAC7C,YAAY,GAAG,yBAAyB,MAAM,CAAC,GAAG,EAAE,CAAC;gBACzD,CAAC;YACL,CAAC;YAED,OAAO;gBACH,KAAK,EAAE,YAAY;aACtB,CAAC;QACN,CAAC;IACL,CAAC;CACJ,CAAC,CAAC;AAEH,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/www/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/www/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA"}
|