@cloudbase/agent-tools 0.0.2

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 (194) hide show
  1. package/CHANGELOG.md +416 -0
  2. package/dist/agent_tool.d.ts +7 -0
  3. package/dist/agent_tool.d.ts.map +1 -0
  4. package/dist/agent_tool.js +16 -0
  5. package/dist/agent_tool.js.map +1 -0
  6. package/dist/bash/bash-tool.d.ts +61 -0
  7. package/dist/bash/bash-tool.d.ts.map +1 -0
  8. package/dist/bash/bash-tool.js +191 -0
  9. package/dist/bash/bash-tool.js.map +1 -0
  10. package/dist/bash/index.d.ts +7 -0
  11. package/dist/bash/index.d.ts.map +1 -0
  12. package/dist/bash/index.js +17 -0
  13. package/dist/bash/index.js.map +1 -0
  14. package/dist/bash/operator/base-operator.d.ts +44 -0
  15. package/dist/bash/operator/base-operator.d.ts.map +1 -0
  16. package/dist/bash/operator/base-operator.js +14 -0
  17. package/dist/bash/operator/base-operator.js.map +1 -0
  18. package/dist/bash/operator/local-operator.d.ts +15 -0
  19. package/dist/bash/operator/local-operator.d.ts.map +1 -0
  20. package/dist/bash/operator/local-operator.js +145 -0
  21. package/dist/bash/operator/local-operator.js.map +1 -0
  22. package/dist/bash/operator/sandbox-operator.d.ts +22 -0
  23. package/dist/bash/operator/sandbox-operator.d.ts.map +1 -0
  24. package/dist/bash/operator/sandbox-operator.js +112 -0
  25. package/dist/bash/operator/sandbox-operator.js.map +1 -0
  26. package/dist/bash/utils.d.ts +106 -0
  27. package/dist/bash/utils.d.ts.map +1 -0
  28. package/dist/bash/utils.js +197 -0
  29. package/dist/bash/utils.js.map +1 -0
  30. package/dist/browser/browser-instance-manager.d.ts +79 -0
  31. package/dist/browser/browser-instance-manager.d.ts.map +1 -0
  32. package/dist/browser/browser-instance-manager.js +242 -0
  33. package/dist/browser/browser-instance-manager.js.map +1 -0
  34. package/dist/browser/browser-tool-executor.d.ts +57 -0
  35. package/dist/browser/browser-tool-executor.d.ts.map +1 -0
  36. package/dist/browser/browser-tool-executor.js +205 -0
  37. package/dist/browser/browser-tool-executor.js.map +1 -0
  38. package/dist/browser/browser_client_unified.d.ts +52 -0
  39. package/dist/browser/browser_client_unified.d.ts.map +1 -0
  40. package/dist/browser/browser_client_unified.js +381 -0
  41. package/dist/browser/browser_client_unified.js.map +1 -0
  42. package/dist/browser/browser_tool_unified.d.ts +93 -0
  43. package/dist/browser/browser_tool_unified.d.ts.map +1 -0
  44. package/dist/browser/browser_tool_unified.js +181 -0
  45. package/dist/browser/browser_tool_unified.js.map +1 -0
  46. package/dist/browser/index.d.ts +7 -0
  47. package/dist/browser/index.d.ts.map +1 -0
  48. package/dist/browser/index.js +19 -0
  49. package/dist/browser/index.js.map +1 -0
  50. package/dist/browser/sandbox-connector.d.ts +93 -0
  51. package/dist/browser/sandbox-connector.d.ts.map +1 -0
  52. package/dist/browser/sandbox-connector.js +272 -0
  53. package/dist/browser/sandbox-connector.js.map +1 -0
  54. package/dist/browser/types.d.ts +53 -0
  55. package/dist/browser/types.d.ts.map +1 -0
  56. package/dist/browser/types.js +3 -0
  57. package/dist/browser/types.js.map +1 -0
  58. package/dist/code_executers/base_code_executor.d.ts +17 -0
  59. package/dist/code_executers/base_code_executor.d.ts.map +1 -0
  60. package/dist/code_executers/base_code_executor.js +20 -0
  61. package/dist/code_executers/base_code_executor.js.map +1 -0
  62. package/dist/code_executers/built_in_code_executor.d.ts +25 -0
  63. package/dist/code_executers/built_in_code_executor.d.ts.map +1 -0
  64. package/dist/code_executers/built_in_code_executor.js +106 -0
  65. package/dist/code_executers/built_in_code_executor.js.map +1 -0
  66. package/dist/code_executers/unsafe_local_code_executor.d.ts +118 -0
  67. package/dist/code_executers/unsafe_local_code_executor.d.ts.map +1 -0
  68. package/dist/code_executers/unsafe_local_code_executor.js +605 -0
  69. package/dist/code_executers/unsafe_local_code_executor.js.map +1 -0
  70. package/dist/fs/edit-tool.d.ts +26 -0
  71. package/dist/fs/edit-tool.d.ts.map +1 -0
  72. package/dist/fs/edit-tool.js +202 -0
  73. package/dist/fs/edit-tool.js.map +1 -0
  74. package/dist/fs/glob-tool.d.ts +31 -0
  75. package/dist/fs/glob-tool.d.ts.map +1 -0
  76. package/dist/fs/glob-tool.js +287 -0
  77. package/dist/fs/glob-tool.js.map +1 -0
  78. package/dist/fs/grep-tool.d.ts +32 -0
  79. package/dist/fs/grep-tool.d.ts.map +1 -0
  80. package/dist/fs/grep-tool.js +353 -0
  81. package/dist/fs/grep-tool.js.map +1 -0
  82. package/dist/fs/index.d.ts +11 -0
  83. package/dist/fs/index.d.ts.map +1 -0
  84. package/dist/fs/index.js +38 -0
  85. package/dist/fs/index.js.map +1 -0
  86. package/dist/fs/ls-tool.d.ts +26 -0
  87. package/dist/fs/ls-tool.d.ts.map +1 -0
  88. package/dist/fs/ls-tool.js +235 -0
  89. package/dist/fs/ls-tool.js.map +1 -0
  90. package/dist/fs/multiedit-tool.d.ts +34 -0
  91. package/dist/fs/multiedit-tool.d.ts.map +1 -0
  92. package/dist/fs/multiedit-tool.js +158 -0
  93. package/dist/fs/multiedit-tool.js.map +1 -0
  94. package/dist/fs/operator/base-operator.d.ts +28 -0
  95. package/dist/fs/operator/base-operator.d.ts.map +1 -0
  96. package/dist/fs/operator/base-operator.js +21 -0
  97. package/dist/fs/operator/base-operator.js.map +1 -0
  98. package/dist/fs/operator/in-memory-operator.d.ts +39 -0
  99. package/dist/fs/operator/in-memory-operator.d.ts.map +1 -0
  100. package/dist/fs/operator/in-memory-operator.js +115 -0
  101. package/dist/fs/operator/in-memory-operator.js.map +1 -0
  102. package/dist/fs/operator/index.d.ts +6 -0
  103. package/dist/fs/operator/index.d.ts.map +1 -0
  104. package/dist/fs/operator/index.js +28 -0
  105. package/dist/fs/operator/index.js.map +1 -0
  106. package/dist/fs/operator/local-operator.d.ts +25 -0
  107. package/dist/fs/operator/local-operator.d.ts.map +1 -0
  108. package/dist/fs/operator/local-operator.js +62 -0
  109. package/dist/fs/operator/local-operator.js.map +1 -0
  110. package/dist/fs/operator/sanbox-operator.d.ts +31 -0
  111. package/dist/fs/operator/sanbox-operator.d.ts.map +1 -0
  112. package/dist/fs/operator/sanbox-operator.js +172 -0
  113. package/dist/fs/operator/sanbox-operator.js.map +1 -0
  114. package/dist/fs/operator/transaction/index.d.ts +6 -0
  115. package/dist/fs/operator/transaction/index.d.ts.map +1 -0
  116. package/dist/fs/operator/transaction/index.js +28 -0
  117. package/dist/fs/operator/transaction/index.js.map +1 -0
  118. package/dist/fs/operator/transaction/snapshot-strategies.d.ts +54 -0
  119. package/dist/fs/operator/transaction/snapshot-strategies.d.ts.map +1 -0
  120. package/dist/fs/operator/transaction/snapshot-strategies.js +278 -0
  121. package/dist/fs/operator/transaction/snapshot-strategies.js.map +1 -0
  122. package/dist/fs/operator/transaction/transaction-operator.d.ts +53 -0
  123. package/dist/fs/operator/transaction/transaction-operator.d.ts.map +1 -0
  124. package/dist/fs/operator/transaction/transaction-operator.js +195 -0
  125. package/dist/fs/operator/transaction/transaction-operator.js.map +1 -0
  126. package/dist/fs/operator/transaction/transaction-utils.d.ts +80 -0
  127. package/dist/fs/operator/transaction/transaction-utils.d.ts.map +1 -0
  128. package/dist/fs/operator/transaction/transaction-utils.js +156 -0
  129. package/dist/fs/operator/transaction/transaction-utils.js.map +1 -0
  130. package/dist/fs/read-tool.d.ts +32 -0
  131. package/dist/fs/read-tool.d.ts.map +1 -0
  132. package/dist/fs/read-tool.js +271 -0
  133. package/dist/fs/read-tool.js.map +1 -0
  134. package/dist/fs/str-replace-editor.d.ts +23 -0
  135. package/dist/fs/str-replace-editor.d.ts.map +1 -0
  136. package/dist/fs/str-replace-editor.js +74 -0
  137. package/dist/fs/str-replace-editor.js.map +1 -0
  138. package/dist/fs/toolkit.d.ts +61 -0
  139. package/dist/fs/toolkit.d.ts.map +1 -0
  140. package/dist/fs/toolkit.js +113 -0
  141. package/dist/fs/toolkit.js.map +1 -0
  142. package/dist/fs/utils.d.ts +32 -0
  143. package/dist/fs/utils.d.ts.map +1 -0
  144. package/dist/fs/utils.js +133 -0
  145. package/dist/fs/utils.js.map +1 -0
  146. package/dist/fs/write-tool.d.ts +26 -0
  147. package/dist/fs/write-tool.d.ts.map +1 -0
  148. package/dist/fs/write-tool.js +110 -0
  149. package/dist/fs/write-tool.js.map +1 -0
  150. package/dist/index.d.ts +10 -0
  151. package/dist/index.d.ts.map +1 -0
  152. package/dist/index.js +40 -0
  153. package/dist/index.js.map +1 -0
  154. package/dist/mcp/agkit-mcp-server.d.ts +291 -0
  155. package/dist/mcp/agkit-mcp-server.d.ts.map +1 -0
  156. package/dist/mcp/agkit-mcp-server.js +821 -0
  157. package/dist/mcp/agkit-mcp-server.js.map +1 -0
  158. package/dist/mcp/client-tool.d.ts +65 -0
  159. package/dist/mcp/client-tool.d.ts.map +1 -0
  160. package/dist/mcp/client-tool.js +220 -0
  161. package/dist/mcp/client-tool.js.map +1 -0
  162. package/dist/mcp/index.d.ts +14 -0
  163. package/dist/mcp/index.d.ts.map +1 -0
  164. package/dist/mcp/index.js +26 -0
  165. package/dist/mcp/index.js.map +1 -0
  166. package/dist/mcp/mcp-client-manager.d.ts +153 -0
  167. package/dist/mcp/mcp-client-manager.d.ts.map +1 -0
  168. package/dist/mcp/mcp-client-manager.js +606 -0
  169. package/dist/mcp/mcp-client-manager.js.map +1 -0
  170. package/dist/mcp/mcp-toolkit.d.ts +112 -0
  171. package/dist/mcp/mcp-toolkit.d.ts.map +1 -0
  172. package/dist/mcp/mcp-toolkit.js +188 -0
  173. package/dist/mcp/mcp-toolkit.js.map +1 -0
  174. package/dist/mcp/types.d.ts +157 -0
  175. package/dist/mcp/types.d.ts.map +1 -0
  176. package/dist/mcp/types.js +34 -0
  177. package/dist/mcp/types.js.map +1 -0
  178. package/dist/mcp/utils.d.ts +17 -0
  179. package/dist/mcp/utils.d.ts.map +1 -0
  180. package/dist/mcp/utils.js +48 -0
  181. package/dist/mcp/utils.js.map +1 -0
  182. package/dist/types/index.d.ts +31 -0
  183. package/dist/types/index.d.ts.map +1 -0
  184. package/dist/types/index.js +3 -0
  185. package/dist/types/index.js.map +1 -0
  186. package/dist/types/zod.d.ts +18 -0
  187. package/dist/types/zod.d.ts.map +1 -0
  188. package/dist/types/zod.js +3 -0
  189. package/dist/types/zod.js.map +1 -0
  190. package/dist/utils.d.ts +141 -0
  191. package/dist/utils.d.ts.map +1 -0
  192. package/dist/utils.js +379 -0
  193. package/dist/utils.js.map +1 -0
  194. package/package.json +46 -0
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FilesystemToolkit = void 0;
4
+ const read_tool_1 = require("./read-tool");
5
+ const write_tool_1 = require("./write-tool");
6
+ const edit_tool_1 = require("./edit-tool");
7
+ const glob_tool_1 = require("./glob-tool");
8
+ const grep_tool_1 = require("./grep-tool");
9
+ const ls_tool_1 = require("./ls-tool");
10
+ const str_replace_editor_1 = require("./str-replace-editor");
11
+ const utils_1 = require("../utils");
12
+ /**
13
+ * FilesystemToolkit provides a comprehensive set of file system tools
14
+ * with configurable modes for different use cases.
15
+ */
16
+ class FilesystemToolkit extends utils_1.BaseToolkit {
17
+ constructor(options) {
18
+ super({
19
+ name: options.name || "filesystem-toolkit",
20
+ description: options.description || "Comprehensive file system operations toolkit",
21
+ context: options.context,
22
+ });
23
+ this.context = {
24
+ workingDirectory: "",
25
+ fsOperator: null,
26
+ };
27
+ this.context = options.context;
28
+ this.config = {
29
+ mode: options.config?.mode || "atomic",
30
+ };
31
+ options.context.fsOperator.setWorkspaceRoot(options.context.workingDirectory);
32
+ this.initialize();
33
+ }
34
+ /**
35
+ * Initialize toolkit and add tools
36
+ */
37
+ async onInitialize() {
38
+ this.initializeTools();
39
+ }
40
+ /**
41
+ * Initialize tools based on configuration
42
+ */
43
+ initializeTools() {
44
+ // Clear existing tools
45
+ this.getTools().forEach((tool) => {
46
+ this.removeTool(tool.name);
47
+ });
48
+ // Add file operation tools based on mode
49
+ if (this.config.mode === "integrated") {
50
+ // Integrated mode: use str-replace-editor
51
+ const strReplaceEditor = (0, str_replace_editor_1.createStrReplaceEditorTool)(this.context);
52
+ this.addTool(strReplaceEditor);
53
+ }
54
+ else {
55
+ // Atomic mode: use separate read, write, edit tools
56
+ const readTool = (0, read_tool_1.createReadTool)(this.context);
57
+ this.addTool(readTool);
58
+ const writeTool = (0, write_tool_1.createWriteTool)(this.context);
59
+ this.addTool(writeTool);
60
+ const editTool = (0, edit_tool_1.createEditTool)(this.context);
61
+ this.addTool(editTool);
62
+ }
63
+ // Always add utility tools
64
+ const globTool = (0, glob_tool_1.createGlobTool)(this.context);
65
+ this.addTool(globTool);
66
+ const grepTool = (0, grep_tool_1.createGrepTool)(this.context);
67
+ this.addTool(grepTool);
68
+ const lsTool = (0, ls_tool_1.createLsTool)(this.context);
69
+ this.addTool(lsTool);
70
+ }
71
+ /**
72
+ * Get tools by category
73
+ */
74
+ getFileOperationTools() {
75
+ if (this.config.mode === "integrated") {
76
+ return this.getTools().filter((tool) => tool.name === "str_replace_editor");
77
+ }
78
+ else {
79
+ return this.getTools().filter((tool) => ["read", "write", "edit"].includes(tool.name));
80
+ }
81
+ }
82
+ /**
83
+ * Get utility tools (glob, grep, ls)
84
+ */
85
+ getUtilityTools() {
86
+ return this.getTools().filter((tool) => ["glob", "grep", "ls"].includes(tool.name));
87
+ }
88
+ /**
89
+ * Get current configuration
90
+ */
91
+ getConfig() {
92
+ return { ...this.config };
93
+ }
94
+ /**
95
+ * Switch between integrated and atomic modes
96
+ */
97
+ switchMode(mode) {
98
+ if (this.config.mode !== mode) {
99
+ this.config.mode = mode;
100
+ this.initializeTools();
101
+ }
102
+ }
103
+ /**
104
+ * Get toolkit statistics
105
+ */
106
+ getStats() {
107
+ return {
108
+ mode: this.config.mode,
109
+ };
110
+ }
111
+ }
112
+ exports.FilesystemToolkit = FilesystemToolkit;
113
+ //# sourceMappingURL=toolkit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"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EAAE,CACrC,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAC9C,CAAC;QACJ,CAAC;IACH,CAAC;IAED;;OAEG;IACH,eAAe;QACb,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CACrC,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAC3C,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,SAAS;QACP,OAAO,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,IAA6B;QACtC,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;YAC9B,IAAI,CAAC,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC;YACxB,IAAI,CAAC,eAAe,EAAE,CAAC;QACzB,CAAC;IACH,CAAC;IAED;;OAEG;IACH,QAAQ;QAGN,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI;SACvB,CAAC;IACJ,CAAC;CACF;AA1HD,8CA0HC"}
@@ -0,0 +1,32 @@
1
+ import { BaseFileOperator } from "./operator/base-operator";
2
+ import { ToolResult } from "../utils";
3
+ export interface ExecutionContext {
4
+ workingDirectory: string;
5
+ fsOperator: BaseFileOperator;
6
+ messageHandler?: any;
7
+ }
8
+ /**
9
+ * Validate if a path is within the workspace directory (supports both absolute and relative paths)
10
+ */
11
+ export declare function validateWorkspacePath(filePath: string, context: ExecutionContext): ToolResult | null;
12
+ /**
13
+ * Safely resolve a file path (supports both absolute and relative paths)
14
+ */
15
+ export declare function resolveWorkspacePath(filePath: string, context: ExecutionContext): string;
16
+ /**
17
+ * Create a success response with typed data
18
+ */
19
+ export declare function createSuccessResponse<TOutput = any>(data: TOutput): ToolResult<TOutput>;
20
+ /**
21
+ * Validation helper for required string parameters
22
+ */
23
+ export declare function validateRequiredString(value: any, paramName: string): ToolResult | null;
24
+ /**
25
+ * Validation helper for file existence
26
+ */
27
+ export declare function validateFileExists(context: ExecutionContext, absolutePath: string, filePath: string): Promise<ToolResult | null>;
28
+ /**
29
+ * Validation helper for directory existence
30
+ */
31
+ export declare function validateDirectoryExists(context: ExecutionContext, absolutePath: string, dirPath: string): Promise<ToolResult | null>;
32
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/fs/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAmB,UAAU,EAAE,MAAM,UAAU,CAAC;AAEvD,MAAM,WAAW,gBAAgB;IAC/B,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,gBAAgB,CAAC;IAC7B,cAAc,CAAC,EAAE,GAAG,CAA2B;CAChD;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,gBAAgB,GACxB,UAAU,GAAG,IAAI,CAoCnB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,gBAAgB,GACxB,MAAM,CAMR;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,GAAG,GAAG,EACjD,IAAI,EAAE,OAAO,GACZ,UAAU,CAAC,OAAO,CAAC,CAKrB;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,GAAG,EACV,SAAS,EAAE,MAAM,GAChB,UAAU,GAAG,IAAI,CASnB;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,gBAAgB,EACzB,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAa5B;AAED;;GAEG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,gBAAgB,EACzB,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAuB5B"}
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.validateWorkspacePath = validateWorkspacePath;
37
+ exports.resolveWorkspacePath = resolveWorkspacePath;
38
+ exports.createSuccessResponse = createSuccessResponse;
39
+ exports.validateRequiredString = validateRequiredString;
40
+ exports.validateFileExists = validateFileExists;
41
+ exports.validateDirectoryExists = validateDirectoryExists;
42
+ const path = __importStar(require("path"));
43
+ const utils_1 = require("../utils");
44
+ /**
45
+ * Validate if a path is within the workspace directory (supports both absolute and relative paths)
46
+ */
47
+ function validateWorkspacePath(filePath, context) {
48
+ try {
49
+ // Prevent directory traversal attacks
50
+ if (filePath.includes("..")) {
51
+ return (0, utils_1.handleToolError)('Path cannot contain ".." for security reasons', "Path validation", "security");
52
+ }
53
+ const normalizedWorkspace = path.normalize(path.resolve(context.workingDirectory));
54
+ // Handle both absolute and relative paths
55
+ let resolvedPath;
56
+ if (path.isAbsolute(filePath)) {
57
+ resolvedPath = path.normalize(filePath);
58
+ }
59
+ else {
60
+ resolvedPath = path.resolve(context.workingDirectory, filePath);
61
+ }
62
+ // Check if path is within workspace boundary
63
+ if (!resolvedPath.startsWith(normalizedWorkspace)) {
64
+ return (0, utils_1.handleToolError)(`Path must be within workspace directory: ${filePath}`, "Security check", "security");
65
+ }
66
+ return null; // No error
67
+ }
68
+ catch (error) {
69
+ return (0, utils_1.handleToolError)(error, "Path validation", "validation");
70
+ }
71
+ }
72
+ /**
73
+ * Safely resolve a file path (supports both absolute and relative paths)
74
+ */
75
+ function resolveWorkspacePath(filePath, context) {
76
+ if (path.isAbsolute(filePath)) {
77
+ return path.normalize(filePath);
78
+ }
79
+ else {
80
+ return path.resolve(context.workingDirectory, filePath);
81
+ }
82
+ }
83
+ /**
84
+ * Create a success response with typed data
85
+ */
86
+ function createSuccessResponse(data) {
87
+ return new utils_1.ToolResult({
88
+ success: true,
89
+ data,
90
+ });
91
+ }
92
+ /**
93
+ * Validation helper for required string parameters
94
+ */
95
+ function validateRequiredString(value, paramName) {
96
+ if (!value || typeof value !== "string" || value.trim() === "") {
97
+ return (0, utils_1.handleToolError)(`${paramName} is required and must be a non-empty string`, "Parameter validation", "validation");
98
+ }
99
+ return null;
100
+ }
101
+ /**
102
+ * Validation helper for file existence
103
+ */
104
+ async function validateFileExists(context, absolutePath, filePath) {
105
+ try {
106
+ if (!(await context.fsOperator.exists(absolutePath))) {
107
+ return (0, utils_1.handleToolError)(`File not found: ${filePath}`, "File existence check", "file_not_found");
108
+ }
109
+ return null;
110
+ }
111
+ catch (error) {
112
+ return (0, utils_1.handleToolError)(error, "File existence check", "permission");
113
+ }
114
+ }
115
+ /**
116
+ * Validation helper for directory existence
117
+ */
118
+ async function validateDirectoryExists(context, absolutePath, dirPath) {
119
+ try {
120
+ if (!(await context.fsOperator.exists(absolutePath))) {
121
+ return (0, utils_1.handleToolError)(`Directory not found: ${dirPath}`, "Directory existence check", "file_not_found");
122
+ }
123
+ const stats = await context.fsOperator.stat(absolutePath);
124
+ if (!stats.isDirectory()) {
125
+ return (0, utils_1.handleToolError)(`Path is not a directory: ${dirPath}`, "Directory validation", "validation");
126
+ }
127
+ return null;
128
+ }
129
+ catch (error) {
130
+ return (0, utils_1.handleToolError)(error, "Directory validation", "permission");
131
+ }
132
+ }
133
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/fs/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,sDAuCC;AAKD,oDASC;AAKD,sDAOC;AAKD,wDAYC;AAKD,gDAiBC;AAKD,0DA2BC;AArJD,2CAA6B;AAE7B,oCAAuD;AAQvD;;GAEG;AACH,SAAgB,qBAAqB,CACnC,QAAgB,EAChB,OAAyB;IAEzB,IAAI,CAAC;QACH,sCAAsC;QACtC,IAAI,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YAC5B,OAAO,IAAA,uBAAe,EACpB,+CAA+C,EAC/C,iBAAiB,EACjB,UAAU,CACX,CAAC;QACJ,CAAC;QAED,MAAM,mBAAmB,GAAG,IAAI,CAAC,SAAS,CACxC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,gBAAgB,CAAC,CACvC,CAAC;QAEF,0CAA0C;QAC1C,IAAI,YAA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AAE,sBAAsB,EAAE,YAAY,CAAC,CAAC;IACtE,CAAC;AACH,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { z } from "zod/v4";
2
+ import { ExecutionContext } from "./utils";
3
+ import { ToolResult } from "../utils";
4
+ /**
5
+ * Write tool result with metadata
6
+ */
7
+ export interface IFileWriteResult {
8
+ file_path: string;
9
+ absolute_path: string;
10
+ is_new_file: boolean;
11
+ lines_written: number;
12
+ bytes_written: number;
13
+ }
14
+ export declare function write(context: ExecutionContext, { file_path, content, create_dirs }: {
15
+ file_path?: string;
16
+ content?: string;
17
+ create_dirs?: boolean;
18
+ }): Promise<ToolResult<IFileWriteResult>>;
19
+ /**
20
+ * Create SuperDesign write tool with execution context
21
+ */
22
+ export declare function createWriteTool(context: ExecutionContext): import("../utils").DynamicTool<z.ZodObject<{
23
+ file_path: z.ZodString;
24
+ content: z.ZodString;
25
+ }, z.core.$strip>, Record<string, unknown>, IFileWriteResult>;
26
+ //# sourceMappingURL=write-tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"write-tool.d.ts","sourceRoot":"","sources":["../../src/fs/write-tool.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAC3B,OAAO,EACL,gBAAgB,EAIjB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAQ,UAAU,EAAmB,MAAM,UAAU,CAAC;AAE7D;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,OAAO,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,wBAAsB,KAAK,CACzB,OAAO,EAAE,gBAAgB,EACzB,EAAE,SAAc,EAAE,OAAY,EAAE,WAAkB,EAAE;;;;CAAA,GACnD,OAAO,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC,CA0EvC;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,gBAAgB;;;8DAiBxD"}
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.write = write;
37
+ exports.createWriteTool = createWriteTool;
38
+ const path = __importStar(require("path"));
39
+ const v4_1 = require("zod/v4");
40
+ const utils_1 = require("./utils");
41
+ const utils_2 = require("../utils");
42
+ async function write(context, { file_path = "", content = "", create_dirs = true }) {
43
+ const startTime = Date.now();
44
+ try {
45
+ // Validate workspace path (handles both absolute and relative paths)
46
+ const pathError = (0, utils_1.validateWorkspacePath)(file_path, context);
47
+ if (pathError) {
48
+ return pathError;
49
+ }
50
+ // Resolve absolute path within workspace
51
+ const absolutePath = (0, utils_1.resolveWorkspacePath)(file_path, context);
52
+ context.messageHandler?.currentText.append(`\n[write] Writing to file: ${file_path}\n`);
53
+ // Check if target is a directory
54
+ if (await context.fsOperator.exists(absolutePath)) {
55
+ const stats = await context.fsOperator.stat(absolutePath);
56
+ if (stats.isDirectory()) {
57
+ return (0, utils_2.handleToolError)(`Target path is a directory, not a file: ${file_path}`, "Path validation", "validation");
58
+ }
59
+ }
60
+ // Create parent directories if needed and requested
61
+ if (create_dirs) {
62
+ const dirName = path.dirname(absolutePath);
63
+ if (!(await context.fsOperator.exists(dirName))) {
64
+ await context.fsOperator.mkdir(dirName, { recursive: true });
65
+ context.messageHandler?.currentText.append(`\n[write] Created parent directories for: ${file_path}\n`);
66
+ }
67
+ }
68
+ // Determine if this is a new file or overwrite
69
+ const isNewFile = !(await context.fsOperator.exists(absolutePath));
70
+ // Write the file
71
+ await context.fsOperator.writeFile(absolutePath, content, "utf8");
72
+ const duration = Date.now() - startTime;
73
+ const lines = content.split("\n").length;
74
+ const size = Buffer.byteLength(content, "utf8");
75
+ context.messageHandler?.currentText.append(`\n[write] ${isNewFile ? "Created" : "Updated"} file: ${file_path} (${lines} lines, ${size} bytes) in ${duration}ms\n`);
76
+ const result = {
77
+ file_path,
78
+ absolute_path: absolutePath,
79
+ is_new_file: isNewFile,
80
+ lines_written: lines,
81
+ bytes_written: size,
82
+ };
83
+ return (0, utils_1.createSuccessResponse)(result);
84
+ }
85
+ catch (error) {
86
+ const duration = Date.now() - startTime;
87
+ const errorMessage = error instanceof Error ? error.message : String(error);
88
+ context.messageHandler?.currentText.append(`\n[write] Error writing file: ${errorMessage} (${duration}ms)\n`);
89
+ return (0, utils_2.handleToolError)(error, "Write tool execution", "execution");
90
+ }
91
+ }
92
+ /**
93
+ * Create SuperDesign write tool with execution context
94
+ */
95
+ function createWriteTool(context) {
96
+ return (0, utils_2.tool)((params) => write(context, params), {
97
+ name: "Write",
98
+ description: "Writes a file to the local filesystem.\n\nUsage:\n- This tool will overwrite the existing file if there is one at the provided path.\n- If this is an existing file, you MUST use the Read tool first to read the file's contents. This tool will fail if you did not read the file first.\n- ALWAYS prefer editing existing files in the codebase. NEVER write new files unless explicitly required.\n- NEVER proactively create documentation files (*.md) or README files. Only create documentation files if explicitly requested by the User.",
99
+ schema: v4_1.z.object({
100
+ file_path: v4_1.z
101
+ .string()
102
+ .describe("The absolute path to the file to write (must be absolute, not relative)"),
103
+ content: v4_1.z.string().describe("Content to write to the file"),
104
+ }),
105
+ getDisplay: ({ name, input }) => {
106
+ return `> Using ${name} for tool call: ${input.file_path || ""}`;
107
+ },
108
+ });
109
+ }
110
+ //# sourceMappingURL=write-tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"write-tool.js","sourceRoot":"","sources":["../../src/fs/write-tool.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,sBA6EC;AAKD,0CAiBC;AA1HD,2CAA6B;AAE7B,+BAA2B;AAC3B,mCAKiB;AAEjB,oCAA6D;AAatD,KAAK,UAAU,KAAK,CACzB,OAAyB,EACzB,EAAE,SAAS,GAAG,EAAE,EAAE,OAAO,GAAG,EAAE,EAAE,WAAW,GAAG,IAAI,EAAE;IAEpD,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE7B,IAAI,CAAC;QACH,qEAAqE;QACrE,MAAM,SAAS,GAAG,IAAA,6BAAqB,EAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAC5D,IAAI,SAAS,EAAE,CAAC;YACd,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,yCAAyC;QACzC,MAAM,YAAY,GAAG,IAAA,4BAAoB,EAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAE9D,OAAO,CAAC,cAAc,EAAE,WAAW,CAAC,MAAM,CACxC,8BAA8B,SAAS,IAAI,CAC5C,CAAC;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KAAK,EAAE,EAAE,EAAE;YAC9B,OAAO,WAAW,IAAI,mBAAmB,KAAK,CAAC,SAAS,IAAI,EAAE,EAAE,CAAC;QACnE,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,10 @@
1
+ export { BaseTool, BaseToolkit, DynamicTool, tool, toolkitManager, ToolkitManager, ToolResult, } from "./utils";
2
+ export { BuiltInCodeExecutor } from "./code_executers/built_in_code_executor";
3
+ export { UnsafeLocalCodeExecutor } from "./code_executers/unsafe_local_code_executor";
4
+ export * from "./bash";
5
+ export * from "./fs";
6
+ export * from "./browser";
7
+ export * from "./mcp";
8
+ export type * from "./types";
9
+ export type { ToolkitEvent, ToolkitEventListener } from "./utils";
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,EACR,WAAW,EACX,WAAW,EACX,IAAI,EACJ,cAAc,EACd,cAAc,EACd,UAAU,GACX,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAC;AAGtF,cAAc,QAAQ,CAAC;AAGvB,cAAc,MAAM,CAAC;AAGrB,cAAc,WAAW,CAAC;AAG1B,cAAc,OAAO,CAAC;AAEtB,mBAAmB,SAAS,CAAC;AAC7B,YAAY,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.UnsafeLocalCodeExecutor = exports.BuiltInCodeExecutor = exports.ToolResult = exports.ToolkitManager = exports.toolkitManager = exports.tool = exports.DynamicTool = exports.BaseToolkit = exports.BaseTool = void 0;
18
+ // Core tool system
19
+ var utils_1 = require("./utils");
20
+ Object.defineProperty(exports, "BaseTool", { enumerable: true, get: function () { return utils_1.BaseTool; } });
21
+ Object.defineProperty(exports, "BaseToolkit", { enumerable: true, get: function () { return utils_1.BaseToolkit; } });
22
+ Object.defineProperty(exports, "DynamicTool", { enumerable: true, get: function () { return utils_1.DynamicTool; } });
23
+ Object.defineProperty(exports, "tool", { enumerable: true, get: function () { return utils_1.tool; } });
24
+ Object.defineProperty(exports, "toolkitManager", { enumerable: true, get: function () { return utils_1.toolkitManager; } });
25
+ Object.defineProperty(exports, "ToolkitManager", { enumerable: true, get: function () { return utils_1.ToolkitManager; } });
26
+ Object.defineProperty(exports, "ToolResult", { enumerable: true, get: function () { return utils_1.ToolResult; } });
27
+ // Code executors
28
+ var built_in_code_executor_1 = require("./code_executers/built_in_code_executor");
29
+ Object.defineProperty(exports, "BuiltInCodeExecutor", { enumerable: true, get: function () { return built_in_code_executor_1.BuiltInCodeExecutor; } });
30
+ var unsafe_local_code_executor_1 = require("./code_executers/unsafe_local_code_executor");
31
+ Object.defineProperty(exports, "UnsafeLocalCodeExecutor", { enumerable: true, get: function () { return unsafe_local_code_executor_1.UnsafeLocalCodeExecutor; } });
32
+ // Bash tools
33
+ __exportStar(require("./bash"), exports);
34
+ // File system tools
35
+ __exportStar(require("./fs"), exports);
36
+ // Browser tools
37
+ __exportStar(require("./browser"), exports);
38
+ // MCP integration
39
+ __exportStar(require("./mcp"), exports);
40
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,mBAAmB;AACnB,iCAQiB;AAPf,iGAAA,QAAQ,OAAA;AACR,oGAAA,WAAW,OAAA;AACX,oGAAA,WAAW,OAAA;AACX,6FAAA,IAAI,OAAA;AACJ,uGAAA,cAAc,OAAA;AACd,uGAAA,cAAc,OAAA;AACd,mGAAA,UAAU,OAAA;AAGZ,iBAAiB;AACjB,kFAA8E;AAArE,6HAAA,mBAAmB,OAAA;AAC5B,0FAAsF;AAA7E,qIAAA,uBAAuB,OAAA;AAEhC,aAAa;AACb,yCAAuB;AAEvB,oBAAoB;AACpB,uCAAqB;AAErB,gBAAgB;AAChB,4CAA0B;AAE1B,kBAAkB;AAClB,wCAAsB"}