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.
Files changed (109) hide show
  1. package/{src/core/ai-provider.ts → dist/core/ai-provider.d.ts} +19 -25
  2. package/dist/core/ai-provider.d.ts.map +1 -0
  3. package/dist/core/ai-provider.js +4 -0
  4. package/dist/core/ai-provider.js.map +1 -0
  5. package/dist/core/base-agent.d.ts +53 -0
  6. package/dist/core/base-agent.d.ts.map +1 -0
  7. package/{src/core/base-agent.ts → dist/core/base-agent.js} +197 -269
  8. package/dist/core/base-agent.js.map +1 -0
  9. package/dist/core/deepseek-provider.d.ts +9 -0
  10. package/dist/core/deepseek-provider.d.ts.map +1 -0
  11. package/{src/core/deepseek-provider.ts → dist/core/deepseek-provider.js} +60 -71
  12. package/dist/core/deepseek-provider.js.map +1 -0
  13. package/dist/core/mcp-client.d.ts +21 -0
  14. package/dist/core/mcp-client.d.ts.map +1 -0
  15. package/{src/core/mcp-client.ts → dist/core/mcp-client.js} +90 -113
  16. package/dist/core/mcp-client.js.map +1 -0
  17. package/dist/core/mcp-computer.d.ts +4 -0
  18. package/dist/core/mcp-computer.d.ts.map +1 -0
  19. package/{src/core/mcp-computer.ts → dist/core/mcp-computer.js} +5 -5
  20. package/dist/core/mcp-computer.js.map +1 -0
  21. package/dist/core/mcp-connection.d.ts +6 -0
  22. package/dist/core/mcp-connection.d.ts.map +1 -0
  23. package/dist/core/mcp-connection.js +10 -0
  24. package/dist/core/mcp-connection.js.map +1 -0
  25. package/dist/core/mcp-ipc-connection.d.ts +20 -0
  26. package/dist/core/mcp-ipc-connection.d.ts.map +1 -0
  27. package/{src/core/mcp-ipc-connection.ts → dist/core/mcp-ipc-connection.js} +126 -153
  28. package/dist/core/mcp-ipc-connection.js.map +1 -0
  29. package/dist/core/mcp-server.d.ts +9 -0
  30. package/dist/core/mcp-server.d.ts.map +1 -0
  31. package/{src/core/mcp-server.ts → dist/core/mcp-server.js} +45 -49
  32. package/dist/core/mcp-server.js.map +1 -0
  33. package/dist/core/mcp.d.ts +29 -0
  34. package/dist/core/mcp.d.ts.map +1 -0
  35. package/dist/core/mcp.js +11 -0
  36. package/dist/core/mcp.js.map +1 -0
  37. package/dist/core/ollama-provider.d.ts +9 -0
  38. package/dist/core/ollama-provider.d.ts.map +1 -0
  39. package/{src/core/ollama-provider.ts → dist/core/ollama-provider.js} +59 -70
  40. package/dist/core/ollama-provider.js.map +1 -0
  41. package/dist/core/skill.d.ts +15 -0
  42. package/dist/core/skill.d.ts.map +1 -0
  43. package/dist/core/skill.js +11 -0
  44. package/dist/core/skill.js.map +1 -0
  45. package/dist/index.d.ts +18 -0
  46. package/dist/index.d.ts.map +1 -0
  47. package/{src/index.ts → dist/index.js} +16 -17
  48. package/dist/index.js.map +1 -0
  49. package/dist/templates/researcher.d.ts +27 -0
  50. package/dist/templates/researcher.d.ts.map +1 -0
  51. package/dist/templates/researcher.js +70 -0
  52. package/dist/templates/researcher.js.map +1 -0
  53. package/dist/templates/simple.d.ts +27 -0
  54. package/dist/templates/simple.d.ts.map +1 -0
  55. package/dist/templates/simple.js +35 -0
  56. package/dist/templates/simple.js.map +1 -0
  57. package/dist/tests/mcp.test.d.ts +2 -0
  58. package/dist/tests/mcp.test.d.ts.map +1 -0
  59. package/{src/tests/mcp.test.ts → dist/tests/mcp.test.js} +55 -73
  60. package/dist/tests/mcp.test.js.map +1 -0
  61. package/dist/tools/fs/index.d.ts +3 -0
  62. package/dist/tools/fs/index.d.ts.map +1 -0
  63. package/dist/tools/fs/index.js +3 -0
  64. package/dist/tools/fs/index.js.map +1 -0
  65. package/dist/tools/fs/read-file.d.ts +4 -0
  66. package/dist/tools/fs/read-file.d.ts.map +1 -0
  67. package/{src/tools/fs/read-file.ts → dist/tools/fs/read-file.js} +49 -54
  68. package/dist/tools/fs/read-file.js.map +1 -0
  69. package/dist/tools/fs/write-file.d.ts +4 -0
  70. package/dist/tools/fs/write-file.d.ts.map +1 -0
  71. package/{src/tools/fs/write-file.ts → dist/tools/fs/write-file.js} +68 -73
  72. package/dist/tools/fs/write-file.js.map +1 -0
  73. package/dist/tools/utils/get-current-time.d.ts +4 -0
  74. package/dist/tools/utils/get-current-time.d.ts.map +1 -0
  75. package/{src/tools/utils/get-current-time.ts → dist/tools/utils/get-current-time.js} +40 -45
  76. package/dist/tools/utils/get-current-time.js.map +1 -0
  77. package/dist/tools/utils/index.d.ts +2 -0
  78. package/dist/tools/utils/index.d.ts.map +1 -0
  79. package/dist/tools/utils/index.js +2 -0
  80. package/dist/tools/utils/index.js.map +1 -0
  81. package/dist/tools/www/fetch.d.ts +4 -0
  82. package/dist/tools/www/fetch.d.ts.map +1 -0
  83. package/{src/tools/www/fetch.ts → dist/tools/www/fetch.js} +147 -161
  84. package/dist/tools/www/fetch.js.map +1 -0
  85. package/dist/tools/www/index.d.ts +4 -0
  86. package/dist/tools/www/index.d.ts.map +1 -0
  87. package/dist/tools/www/index.js +4 -0
  88. package/dist/tools/www/index.js.map +1 -0
  89. package/dist/tools/www/read-web-page.d.ts +4 -0
  90. package/dist/tools/www/read-web-page.d.ts.map +1 -0
  91. package/{src/tools/www/read-web-page.ts → dist/tools/www/read-web-page.js} +330 -350
  92. package/dist/tools/www/read-web-page.js.map +1 -0
  93. package/dist/tools/www/web-search.d.ts +4 -0
  94. package/dist/tools/www/web-search.d.ts.map +1 -0
  95. package/{src/tools/www/web-search.ts → dist/tools/www/web-search.js} +82 -102
  96. package/dist/tools/www/web-search.js.map +1 -0
  97. package/package.json +19 -5
  98. package/.env.example +0 -1
  99. package/orbitx.png +0 -0
  100. package/public/index.html +0 -397
  101. package/src/core/mcp-connection.ts +0 -12
  102. package/src/core/mcp.ts +0 -23
  103. package/src/core/skill.ts +0 -16
  104. package/src/templates/researcher.ts +0 -73
  105. package/src/templates/simple.ts +0 -64
  106. package/src/tools/fs/index.ts +0 -2
  107. package/src/tools/utils/index.ts +0 -1
  108. package/src/tools/www/index.ts +0 -3
  109. 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
- export const WriteFileTool = new MCPTool({
6
- name: "write-file",
7
- description: "Writes text content to a file at the specified path. Creates new file or overwrites existing.",
8
- inputs: [{
9
- name: "filePath",
10
- type: "string",
11
- description: `Absolute or relative path to the file (e.g., "/home/user/doc.txt" or "./file.txt")`,
12
- required: true,
13
- },
14
- {
15
- name: "data",
16
- type: "string",
17
- description: "Text content to write (supports multi-line)",
18
- required: true,
19
- }],
20
- execute: async (_: string, inputs: Record<string, any>): Promise<any> => {
21
- try {
22
- const { filePath, data } = inputs;
23
-
24
- if (!filePath || typeof filePath !== "string") {
25
- throw new Error("filePath must be a non-empty string");
26
- }
27
-
28
- if (typeof data !== "string") {
29
- throw new Error("data must be a string");
30
- }
31
-
32
- const normalizedPath = path.normalize(filePath);
33
-
34
- const dir = path.dirname(normalizedPath);
35
- await fs.mkdir(dir, { recursive: true });
36
-
37
- await fs.writeFile(normalizedPath, data, "utf-8");
38
-
39
- return {
40
- message: `File written: ${normalizedPath}`,
41
- path: normalizedPath,
42
- size: data.length
43
- };
44
-
45
- } catch (error) {
46
- let errorMessage = error instanceof Error ? error.message : String(error);
47
-
48
- if (error instanceof Error && "code" in error) {
49
- const err = error as NodeJS.ErrnoException;
50
-
51
- if (err.code === "EACCES") {
52
- errorMessage = `Permission denied: Cannot write to ${inputs.filePath}`;
53
- } else if (err.code === "ENOENT") {
54
- errorMessage = `Directory does not exist or cannot be created: ${path.dirname(inputs.filePath)}`;
55
- } else if (err.code === "EISDIR") {
56
- errorMessage = `Path is a directory, cannot write file: ${inputs.filePath}`;
57
- } else if (err.code === "ENOSPC") {
58
- errorMessage = `No space left on device: Cannot write to ${inputs.filePath}`;
59
- } else if (err.code === "EROFS") {
60
- errorMessage = `Read-only file system: Cannot write to ${inputs.filePath}`;
61
- } else if (err.code === "ENAMETOOLONG") {
62
- errorMessage = `File path is too long: ${inputs.filePath}`;
63
- }
64
- }
65
-
66
- return {
67
- error: errorMessage
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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CAAC;oBAC9B,YAAY,GAAG,0CAA0C,MAAM,CAAC,QAAQ,EAAE,CAAC;gBAC/E,CAAC;qBAAM,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,4 @@
1
+ import MCPTool from "../../core/mcp";
2
+ export declare const GetCurrentTimeTool: MCPTool;
3
+ export default GetCurrentTimeTool;
4
+ //# sourceMappingURL=get-current-time.d.ts.map
@@ -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
- export const GetCurrentTimeTool = new MCPTool({
4
- name: "get-current-time",
5
- description: "Returns current time (24h) and today's date in Gregorian, Persian, and Islamic calendars.",
6
- inputs: [],
7
- execute: async (_: string, __: Record<string, any>): Promise<any> => {
8
- const now = new Date();
9
- const time = now.toLocaleTimeString("en-US", {
10
- hour: "2-digit",
11
- minute: "2-digit",
12
- hour12: false
13
- });
14
-
15
- const gregorian = now.toLocaleDateString("en-US", {
16
- weekday: "long",
17
- year: "numeric",
18
- month: "long",
19
- day: "numeric"
20
- });
21
-
22
- const persian = now.toLocaleDateString("fa-IR-u-ca-persian", {
23
- weekday: "long",
24
- year: "numeric",
25
- month: "long",
26
- day: "numeric"
27
- });
28
-
29
- const hijri = now.toLocaleDateString("ar-SA-u-ca-islamic", {
30
- weekday: "long",
31
- year: "numeric",
32
- month: "long",
33
- day: "numeric"
34
- });
35
-
36
- return {
37
- time,
38
- gregorian,
39
- persian,
40
- hijri
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,2 @@
1
+ export { GetCurrentTimeTool } from "./get-current-time";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -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,2 @@
1
+ export { GetCurrentTimeTool } from "./get-current-time";
2
+ //# sourceMappingURL=index.js.map
@@ -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,4 @@
1
+ import MCPTool from "../../core/mcp";
2
+ export declare const FetchTool: MCPTool;
3
+ export default FetchTool;
4
+ //# sourceMappingURL=fetch.d.ts.map
@@ -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
- export const FetchTool = new MCPTool({
4
- name: "fetch",
5
- description: "Makes HTTP requests to APIs or endpoints. For testing APIs, fetching data, or making web requests. Not intended for reading web pages (HTML).",
6
- inputs: [{
7
- name: "url",
8
- type: "string",
9
- description: "The URL to fetch (e.g., 'https://api.example.com/data')",
10
- required: true,
11
- },
12
- {
13
- name: "method",
14
- type: "string",
15
- description: "HTTP method (GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS)",
16
- required: false,
17
- default: "GET"
18
- },
19
- {
20
- name: "headers",
21
- type: "object",
22
- description: "HTTP headers as key-value pairs (e.g., {'Authorization': 'Bearer token', 'Content-Type': 'application/json'})",
23
- required: false,
24
- },
25
- {
26
- name: "body",
27
- type: "string",
28
- description: "Request body (required for POST, PUT, PATCH methods). Can be JSON string or form data.",
29
- required: false,
30
- },
31
- {
32
- name: "timeout",
33
- type: "number",
34
- description: "Request timeout in milliseconds (default: 30000)",
35
- required: false,
36
- default: 30000
37
- }],
38
- execute: async (_: string, inputs: Record<string, any>): Promise<any> => {
39
- try {
40
- const { url, method = "GET", headers = {}, body, timeout = 30000 } = inputs;
41
-
42
- if (!url || typeof url !== "string") {
43
- throw new Error("url must be a non-empty string");
44
- }
45
-
46
- try {
47
- new URL(url);
48
- } catch {
49
- throw new Error(`Invalid URL format: ${url}`);
50
- }
51
-
52
- const validMethods = ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"];
53
- const normalizedMethod = method.toUpperCase();
54
- if (!validMethods.includes(normalizedMethod)) {
55
- throw new Error(`Invalid HTTP method: ${method}. Must be one of: ${validMethods.join(", ")}`);
56
- }
57
-
58
- if (body && ["GET", "HEAD", "OPTIONS"].includes(normalizedMethod)) {
59
- throw new Error(`${normalizedMethod} requests cannot have a body`);
60
- }
61
-
62
- let parsedHeaders = headers;
63
- if (typeof headers === "string") {
64
- try {
65
- parsedHeaders = JSON.parse(headers);
66
- } catch {
67
- throw new Error("headers must be a valid JSON object");
68
- }
69
- }
70
-
71
- if (parsedHeaders && typeof parsedHeaders !== "object") {
72
- throw new Error("headers must be an object or JSON string");
73
- }
74
-
75
- const controller = new AbortController();
76
- const timeoutId = setTimeout(() => controller.abort(), timeout);
77
-
78
- try {
79
- const fetchOptions: RequestInit = {
80
- method: normalizedMethod,
81
- headers: parsedHeaders || {},
82
- signal: controller.signal,
83
- };
84
-
85
- if (body) {
86
- const isJson = typeof body === "string" && (
87
- body.trim().startsWith("{") ||
88
- body.trim().startsWith("[")
89
- );
90
-
91
- if (isJson && !parsedHeaders?.["Content-Type"] && !parsedHeaders?.["content-type"]) {
92
- fetchOptions.headers = {
93
- ...parsedHeaders,
94
- "Content-Type": "application/json"
95
- };
96
- }
97
- fetchOptions.body = body;
98
- }
99
-
100
- const response = await fetch(url, fetchOptions);
101
-
102
- clearTimeout(timeoutId);
103
-
104
- const contentType = response.headers.get("content-type") || "";
105
- let data;
106
-
107
- if (contentType.includes("application/json")) {
108
- try {
109
- data = await response.json();
110
- } catch {
111
- data = await response.text();
112
- }
113
- } else {
114
- data = await response.text();
115
- }
116
-
117
- const result = {
118
- status: response.status,
119
- statusText: response.statusText,
120
- headers: Object.fromEntries(response.headers.entries()),
121
- data: data,
122
- };
123
-
124
- if (!response.ok) {
125
- return {
126
- ...result,
127
- error: `HTTP ${response.status}: ${response.statusText}`,
128
- };
129
- }
130
-
131
- return result;
132
-
133
- } finally {
134
- clearTimeout(timeoutId);
135
- }
136
-
137
- } catch (error) {
138
- let errorMessage = error instanceof Error ? error.message : String(error);
139
-
140
- if (error instanceof Error) {
141
- if (error.name === "AbortError") {
142
- errorMessage = `Request timed out after ${inputs.timeout || 30000}ms`;
143
- } else if (error.message.includes("ENOTFOUND")) {
144
- errorMessage = `DNS resolution failed: ${inputs.url}`;
145
- } else if (error.message.includes("ECONNREFUSED")) {
146
- errorMessage = `Connection refused: ${inputs.url}`;
147
- } else if (error.message.includes("ECONNRESET")) {
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,gBAAgB,CAAC;AAErC,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,OAAO,CAAC;IACjC,IAAI,EAAE,OAAO;IACb,WAAW,EAAE,+IAA+I;IAC5J,MAAM,EAAE,CAAC;YACL,IAAI,EAAE,KAAK;YACX,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,yDAAyD;YACtE,QAAQ,EAAE,IAAI;SACjB;QACD;YACI,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,4DAA4D;YACzE,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE,KAAK;SACjB;QACD;YACI,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AEL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,IAAI,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAE1E,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;gBACzB,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;oBAC9B,YAAY,GAAG,2BAA2B,MAAM,CAAC,OAAO,IAAI,KAAK,IAAI,CAAC;gBAC1E,CAAC;qBAAM,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;oBAC7C,YAAY,GAAG,0BAA0B,MAAM,CAAC,GAAG,EAAE,CAAC;gBAC1D,CAAC;qBAAM,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;oBAChD,YAAY,GAAG,uBAAuB,MAAM,CAAC,GAAG,EAAE,CAAC;gBACvD,CAAC;qBAAM,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;oBAC9C,YAAY,GAAG,6BAA6B,MAAM,CAAC,GAAG,EAAE,CAAC;gBAC7D,CAAC;qBAAM,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,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,4 @@
1
+ export { FetchTool } from "./fetch";
2
+ export { WebSearchTool } from "./web-search";
3
+ export { ReadWebPageTool } from "./read-web-page";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -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,4 @@
1
+ export { FetchTool } from "./fetch";
2
+ export { WebSearchTool } from "./web-search";
3
+ export { ReadWebPageTool } from "./read-web-page";
4
+ //# sourceMappingURL=index.js.map
@@ -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"}