@gaunt-sloth/agent 0.1.8 → 2.0.0-alpha.1

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 (80) hide show
  1. package/README.md +14 -5
  2. package/cli-acp.js +35 -0
  3. package/cli.js +35 -0
  4. package/dist/builtInToolsConfig.d.ts +26 -0
  5. package/dist/builtInToolsConfig.js +148 -0
  6. package/dist/builtInToolsConfig.js.map +1 -0
  7. package/dist/core/GthDeepAgent.d.ts +76 -0
  8. package/dist/core/GthDeepAgent.js +368 -0
  9. package/dist/core/GthDeepAgent.js.map +1 -0
  10. package/dist/core/debugCapture.d.ts +51 -0
  11. package/dist/core/debugCapture.js +2 -0
  12. package/dist/core/debugCapture.js.map +1 -0
  13. package/dist/core/deepAgentPermissions.d.ts +55 -0
  14. package/dist/core/deepAgentPermissions.js +120 -0
  15. package/dist/core/deepAgentPermissions.js.map +1 -0
  16. package/dist/core/gthAcpServer.d.ts +27 -0
  17. package/dist/core/gthAcpServer.js +71 -0
  18. package/dist/core/gthAcpServer.js.map +1 -0
  19. package/dist/core/gthDeepAgentFactory.d.ts +8 -0
  20. package/dist/core/gthDeepAgentFactory.js +9 -0
  21. package/dist/core/gthDeepAgentFactory.js.map +1 -0
  22. package/dist/index.d.ts +13 -0
  23. package/dist/index.js +16 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/mcp/OAuthClientProviderImpl.d.ts +37 -0
  26. package/dist/mcp/OAuthClientProviderImpl.js +223 -0
  27. package/dist/mcp/OAuthClientProviderImpl.js.map +1 -0
  28. package/dist/middleware/binaryContentInjectionMiddleware.d.ts +22 -0
  29. package/dist/middleware/binaryContentInjectionMiddleware.js +125 -0
  30. package/dist/middleware/binaryContentInjectionMiddleware.js.map +1 -0
  31. package/dist/middleware/registry.d.ts +34 -0
  32. package/dist/middleware/registry.js +124 -0
  33. package/dist/middleware/registry.js.map +1 -0
  34. package/dist/middleware/types.d.ts +89 -0
  35. package/dist/middleware/types.js +9 -0
  36. package/dist/middleware/types.js.map +1 -0
  37. package/dist/modules/a2a/A2AClientWrapper.d.ts +22 -0
  38. package/dist/modules/a2a/A2AClientWrapper.js +63 -0
  39. package/dist/modules/a2a/A2AClientWrapper.js.map +1 -0
  40. package/dist/modules/acpModule.d.ts +37 -0
  41. package/dist/modules/acpModule.js +67 -0
  42. package/dist/modules/acpModule.js.map +1 -0
  43. package/dist/modules/apiAgUiModule.d.ts +2 -0
  44. package/dist/modules/apiAgUiModule.js +417 -0
  45. package/dist/modules/apiAgUiModule.js.map +1 -0
  46. package/dist/modules/interactiveSessionModule.d.ts +9 -0
  47. package/dist/modules/interactiveSessionModule.js +99 -0
  48. package/dist/modules/interactiveSessionModule.js.map +1 -0
  49. package/dist/resolvers.d.ts +18 -0
  50. package/dist/resolvers.js +140 -0
  51. package/dist/resolvers.js.map +1 -0
  52. package/dist/tools/A2AAgentTool.d.ts +24 -0
  53. package/dist/tools/A2AAgentTool.js +37 -0
  54. package/dist/tools/A2AAgentTool.js.map +1 -0
  55. package/dist/tools/GthCustomToolkit.d.ts +41 -0
  56. package/dist/tools/GthCustomToolkit.js +289 -0
  57. package/dist/tools/GthCustomToolkit.js.map +1 -0
  58. package/dist/tools/GthDevToolkit.d.ts +24 -0
  59. package/dist/tools/GthDevToolkit.js +189 -0
  60. package/dist/tools/GthDevToolkit.js.map +1 -0
  61. package/dist/tools/GthFileSystemToolkit.d.ts +36 -0
  62. package/dist/tools/GthFileSystemToolkit.js +775 -0
  63. package/dist/tools/GthFileSystemToolkit.js.map +1 -0
  64. package/dist/tools/binaryUtils.d.ts +13 -0
  65. package/dist/tools/binaryUtils.js +55 -0
  66. package/dist/tools/binaryUtils.js.map +1 -0
  67. package/dist/tools/gthStatusUpdateTool.d.ts +2 -0
  68. package/dist/tools/gthStatusUpdateTool.js +15 -0
  69. package/dist/tools/gthStatusUpdateTool.js.map +1 -0
  70. package/dist/tools/gthWebFetchTool.d.ts +2 -0
  71. package/dist/tools/gthWebFetchTool.js +47 -0
  72. package/dist/tools/gthWebFetchTool.js.map +1 -0
  73. package/dist/tools/showA2UISurfaceTool.d.ts +9 -0
  74. package/dist/tools/showA2UISurfaceTool.js +25 -0
  75. package/dist/tools/showA2UISurfaceTool.js.map +1 -0
  76. package/dist/utils/mcpUtils.d.ts +13 -0
  77. package/dist/utils/mcpUtils.js +225 -0
  78. package/dist/utils/mcpUtils.js.map +1 -0
  79. package/package.json +49 -10
  80. package/index.js +0 -6
@@ -0,0 +1,189 @@
1
+ /**
2
+ * @module GthDevToolkit
3
+ */
4
+ import { BaseToolkit, tool } from '@langchain/core/tools';
5
+ import { z } from 'zod';
6
+ import { spawn } from 'child_process';
7
+ import path from 'node:path';
8
+ import { displayInfo, displayError } from '@gaunt-sloth/core/utils/consoleUtils.js';
9
+ import { stdout } from '@gaunt-sloth/core/utils/systemUtils.js';
10
+ // Helper function to create a tool with dev type
11
+ function createGthTool(fn, config, gthDevType) {
12
+ const toolInstance = tool(fn, config);
13
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
+ toolInstance.gthDevType = gthDevType;
15
+ return toolInstance;
16
+ }
17
+ // Schema definitions for built-in tools
18
+ const RunTestsArgsSchema = z.object({});
19
+ const RunLintArgsSchema = z.object({});
20
+ const RunBuildArgsSchema = z.object({});
21
+ const RunSingleTestArgsSchema = z.object({
22
+ testPath: z.string().describe('Relative path to the test file to run'),
23
+ });
24
+ const TEST_PATH_PLACEHOLDER = '${testPath}';
25
+ export default class GthDevToolkit extends BaseToolkit {
26
+ tools;
27
+ commands;
28
+ constructor(commands = {}) {
29
+ super();
30
+ this.commands = commands;
31
+ this.tools = this.createTools();
32
+ }
33
+ /**
34
+ * Get tools filtered by operation type
35
+ */
36
+ getFilteredTools(allowedOperations) {
37
+ return this.tools.filter((tool) => {
38
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
39
+ const toolType = tool.gthDevType;
40
+ return allowedOperations.includes(toolType);
41
+ });
42
+ }
43
+ /**
44
+ * Validate parameter value to prevent security issues
45
+ */
46
+ validateParameterValue(paramValue, paramName) {
47
+ // Check for absolute paths
48
+ if (path.isAbsolute(paramValue)) {
49
+ throw new Error(`Absolute paths are not allowed for parameter '${paramName}'`);
50
+ }
51
+ // Check for directory traversal attempts
52
+ if (paramValue.includes('..') || paramValue.includes('\\..\\') || paramValue.includes('/../')) {
53
+ throw new Error(`Directory traversal attempts are not allowed in parameter '${paramName}'`);
54
+ }
55
+ // Check for pipe attempts and other shell injection
56
+ if (paramValue.includes('|') ||
57
+ paramValue.includes('&') ||
58
+ paramValue.includes(';') ||
59
+ paramValue.includes('`') ||
60
+ paramValue.includes('$') ||
61
+ paramValue.includes('$(') ||
62
+ paramValue.includes('\n') ||
63
+ paramValue.includes('\r')) {
64
+ throw new Error(`Shell injection attempts are not allowed in parameter '${paramName}'`);
65
+ }
66
+ // Check for null bytes
67
+ if (paramValue.includes('\0')) {
68
+ throw new Error(`Null bytes are not allowed in parameter '${paramName}'`);
69
+ }
70
+ // Normalize the path to remove any redundant separators
71
+ const normalizedValue = path.normalize(paramValue);
72
+ // Double-check after normalization
73
+ if (normalizedValue.includes('..')) {
74
+ throw new Error(`Directory traversal attempts are not allowed in parameter '${paramName}'`);
75
+ }
76
+ return normalizedValue;
77
+ }
78
+ /**
79
+ * Build the command for running a single test file
80
+ */
81
+ buildSingleTestCommand(testPath) {
82
+ if (this.commands.run_single_test) {
83
+ if (this.commands.run_single_test.includes(TEST_PATH_PLACEHOLDER)) {
84
+ // Interpolate if placeholder is available
85
+ return this.commands.run_single_test.replace(TEST_PATH_PLACEHOLDER, testPath);
86
+ }
87
+ else {
88
+ // Concatenate if no placeholder
89
+ return `${this.commands.run_single_test} ${testPath}`;
90
+ }
91
+ }
92
+ else {
93
+ throw new Error('No test command configured');
94
+ }
95
+ }
96
+ async executeCommand(command, toolName) {
97
+ displayInfo(`\n🔧 Executing ${toolName}: ${command}`);
98
+ return new Promise((resolve, reject) => {
99
+ const child = spawn(command, {
100
+ shell: true,
101
+ });
102
+ let output = '';
103
+ // Capture output if available (when stdio is not 'inherit')
104
+ if (child.stdout) {
105
+ child.stdout.on('data', (data) => {
106
+ const chunk = data.toString();
107
+ stdout.write(chunk);
108
+ output += chunk;
109
+ });
110
+ }
111
+ if (child.stderr) {
112
+ child.stderr.on('data', (data) => {
113
+ const chunk = data.toString();
114
+ stdout.write(chunk);
115
+ output += chunk;
116
+ });
117
+ }
118
+ child.on('close', (code) => {
119
+ if (code === 0) {
120
+ resolve(`Executing '${command}'...\n\n` +
121
+ `<COMMAND_OUTPUT>\n` +
122
+ output +
123
+ `</COMMAND_OUTPUT>\n` +
124
+ `\n\nCommand '${command}' completed successfully`);
125
+ }
126
+ else {
127
+ resolve(`Executing '${command}'...\n\n` +
128
+ `<COMMAND_OUTPUT>\n` +
129
+ output +
130
+ `</COMMAND_OUTPUT>\n` +
131
+ `\n\nCommand '${command}' exited with code ${code}`);
132
+ }
133
+ });
134
+ child.on('error', (error) => {
135
+ const errorMsg = `Failed to execute command '${command}': ${error.message}`;
136
+ displayError(errorMsg);
137
+ reject(new Error(errorMsg));
138
+ });
139
+ });
140
+ }
141
+ createTools() {
142
+ const tools = [];
143
+ if (this.commands.run_tests) {
144
+ tools.push(createGthTool(async (_args) => {
145
+ return await this.executeCommand(this.commands.run_tests, 'run_tests');
146
+ }, {
147
+ name: 'run_tests',
148
+ description: 'Execute the test suite for this project. Runs the configured test command and returns the output.' +
149
+ `\nThe configured command is [${this.commands.run_tests}].`,
150
+ schema: RunTestsArgsSchema,
151
+ }, 'execute'));
152
+ }
153
+ if (this.commands.run_single_test) {
154
+ tools.push(createGthTool(async (args) => {
155
+ const validatedPath = this.validateParameterValue(args.testPath, 'testPath');
156
+ const command = this.buildSingleTestCommand(validatedPath);
157
+ return await this.executeCommand(command, 'run_single_test');
158
+ }, {
159
+ name: 'run_single_test',
160
+ description: 'Execute a single test file. Runs the configured test command with the specified test file path. ' +
161
+ 'The test path must be relative and cannot contain directory traversal attempts or shell injection. ' +
162
+ `\nThe base command is [${this.commands.run_single_test}].`,
163
+ schema: RunSingleTestArgsSchema,
164
+ }, 'execute'));
165
+ }
166
+ if (this.commands.run_lint) {
167
+ tools.push(createGthTool(async (_args) => {
168
+ return await this.executeCommand(this.commands.run_lint, 'run_lint');
169
+ }, {
170
+ name: 'run_lint',
171
+ description: 'Run the linter on the project code. Executes the configured lint command and returns any linting errors or warnings.' +
172
+ `\nThe configured command is [${this.commands.run_lint}].`,
173
+ schema: RunLintArgsSchema,
174
+ }, 'execute'));
175
+ }
176
+ if (this.commands.run_build) {
177
+ tools.push(createGthTool(async (_args) => {
178
+ return await this.executeCommand(this.commands.run_build, 'run_build');
179
+ }, {
180
+ name: 'run_build',
181
+ description: 'Build the project. Executes the configured build command and returns the build output.' +
182
+ `\nThe configured command is [${this.commands.run_build}].`,
183
+ schema: RunBuildArgsSchema,
184
+ }, 'execute'));
185
+ }
186
+ return tools;
187
+ }
188
+ }
189
+ //# sourceMappingURL=GthDevToolkit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GthDevToolkit.js","sourceRoot":"","sources":["../../src/tools/GthDevToolkit.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,WAAW,EAA2B,IAAI,EAAE,MAAM,uBAAuB,CAAC;AACnF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAEpF,OAAO,EAAE,MAAM,EAAE,MAAM,wCAAwC,CAAC;AAEhE,iDAAiD;AACjD,SAAS,aAAa,CACpB,EAAyC,EACzC,MAIC,EACD,UAAqB;IAErB,MAAM,YAAY,GAAG,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IACtC,8DAA8D;IAC7D,YAAoB,CAAC,UAAU,GAAG,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,CAAC,CAAC;YAC1E,CAAC,EACD;gBACE,IAAI,EAAE,WAAW;gBACjB,WAAW,EACT,wFAAwF;oBACxF,gCAAgC,IAAI,CAAC,QAAQ,CAAC,SAAU,IAAI;gBAC9D,MAAM,EAAE,kBAAkB;aAC3B,EACD,SAAS,CACV,CACF,CAAC;QACJ,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
@@ -0,0 +1,36 @@
1
+ import { BaseToolkit, StructuredToolInterface } from '@langchain/core/tools';
2
+ import type { BinaryFormatConfig } from '@gaunt-sloth/core/config.js';
3
+ export interface GthFileSystemToolkitOptions {
4
+ allowedDirectories?: string[];
5
+ aiignoreConfig?: {
6
+ enabled?: boolean;
7
+ patterns?: string[];
8
+ };
9
+ binaryFormats?: false | BinaryFormatConfig[];
10
+ }
11
+ export default class GthFileSystemToolkit extends BaseToolkit {
12
+ tools: StructuredToolInterface[];
13
+ private allowedDirectories;
14
+ private aiignoreConfig?;
15
+ private binaryFormats?;
16
+ constructor(options?: GthFileSystemToolkitOptions);
17
+ /**
18
+ * Get tools filtered by operation type
19
+ */
20
+ getFilteredTools(allowedOperations: ('read' | 'write')[]): StructuredToolInterface[];
21
+ private normalizePath;
22
+ private isProtectedDirectory;
23
+ private expandHome;
24
+ private sanitizeRequestedPath;
25
+ private validatePath;
26
+ private getFileStats;
27
+ private searchFiles;
28
+ private normalizeLineEndings;
29
+ private createUnifiedDiff;
30
+ private applyFileEdits;
31
+ private formatSize;
32
+ private tailFile;
33
+ private headFile;
34
+ private createReadBinaryTool;
35
+ private createTools;
36
+ }