concevent-ai-agent-sdk 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/README.md +279 -0
  2. package/dist/core/orchestrator.d.ts.map +1 -1
  3. package/dist/core/orchestrator.js.map +1 -1
  4. package/dist/index.d.ts +5 -0
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +9 -0
  7. package/dist/index.js.map +1 -1
  8. package/dist/tools/bash-output.d.ts +19 -0
  9. package/dist/tools/bash-output.d.ts.map +1 -0
  10. package/dist/tools/bash-output.js +47 -0
  11. package/dist/tools/bash-output.js.map +1 -0
  12. package/dist/tools/bash.d.ts +25 -0
  13. package/dist/tools/bash.d.ts.map +1 -0
  14. package/dist/tools/bash.js +79 -0
  15. package/dist/tools/bash.js.map +1 -0
  16. package/dist/tools/edit.d.ts +28 -0
  17. package/dist/tools/edit.d.ts.map +1 -0
  18. package/dist/tools/edit.js +97 -0
  19. package/dist/tools/edit.js.map +1 -0
  20. package/dist/tools/glob.d.ts +25 -0
  21. package/dist/tools/glob.d.ts.map +1 -0
  22. package/dist/tools/glob.js +88 -0
  23. package/dist/tools/glob.js.map +1 -0
  24. package/dist/tools/grep.d.ts +31 -0
  25. package/dist/tools/grep.d.ts.map +1 -0
  26. package/dist/tools/grep.js +195 -0
  27. package/dist/tools/grep.js.map +1 -0
  28. package/dist/tools/index.d.ts +85 -0
  29. package/dist/tools/index.d.ts.map +1 -0
  30. package/dist/tools/index.js +141 -0
  31. package/dist/tools/index.js.map +1 -0
  32. package/dist/tools/kill-bash.d.ts +19 -0
  33. package/dist/tools/kill-bash.d.ts.map +1 -0
  34. package/dist/tools/kill-bash.js +49 -0
  35. package/dist/tools/kill-bash.js.map +1 -0
  36. package/dist/tools/read.d.ts +25 -0
  37. package/dist/tools/read.d.ts.map +1 -0
  38. package/dist/tools/read.js +103 -0
  39. package/dist/tools/read.js.map +1 -0
  40. package/dist/tools/task.d.ts +25 -0
  41. package/dist/tools/task.d.ts.map +1 -0
  42. package/dist/tools/task.js +71 -0
  43. package/dist/tools/task.js.map +1 -0
  44. package/dist/tools/todo-write.d.ts +46 -0
  45. package/dist/tools/todo-write.d.ts.map +1 -0
  46. package/dist/tools/todo-write.js +151 -0
  47. package/dist/tools/todo-write.js.map +1 -0
  48. package/dist/tools/types.d.ts +147 -0
  49. package/dist/tools/types.d.ts.map +1 -0
  50. package/dist/tools/types.js +16 -0
  51. package/dist/tools/types.js.map +1 -0
  52. package/dist/tools/utils/index.d.ts +3 -0
  53. package/dist/tools/utils/index.d.ts.map +1 -0
  54. package/dist/tools/utils/index.js +3 -0
  55. package/dist/tools/utils/index.js.map +1 -0
  56. package/dist/tools/utils/path.d.ts +40 -0
  57. package/dist/tools/utils/path.d.ts.map +1 -0
  58. package/dist/tools/utils/path.js +146 -0
  59. package/dist/tools/utils/path.js.map +1 -0
  60. package/dist/tools/utils/shell.d.ts +49 -0
  61. package/dist/tools/utils/shell.d.ts.map +1 -0
  62. package/dist/tools/utils/shell.js +232 -0
  63. package/dist/tools/utils/shell.js.map +1 -0
  64. package/dist/tools/write.d.ts +22 -0
  65. package/dist/tools/write.d.ts.map +1 -0
  66. package/dist/tools/write.js +70 -0
  67. package/dist/tools/write.js.map +1 -0
  68. package/package.json +2 -2
@@ -0,0 +1,97 @@
1
+ import * as fs from 'fs/promises';
2
+ import { z } from 'zod';
3
+ import { zodToJsonSchema } from 'zod-to-json-schema';
4
+ import { resolvePath, isPathAllowed, isPathSafe } from './utils/path.js';
5
+ /**
6
+ * Schema for the Edit tool parameters
7
+ */
8
+ export const editSchema = z.object({
9
+ file_path: z
10
+ .string()
11
+ .describe('The path to the file to edit. Can be absolute or relative to working directory.'),
12
+ old_string: z
13
+ .string()
14
+ .describe('The exact string to find and replace. Must match exactly including whitespace and indentation.'),
15
+ new_string: z.string().describe('The string to replace old_string with.'),
16
+ replace_all: z
17
+ .boolean()
18
+ .optional()
19
+ .default(false)
20
+ .describe('If true, replace all occurrences. If false (default), replace only the first occurrence.'),
21
+ });
22
+ /**
23
+ * Creates the Edit tool for targeted string replacement in files
24
+ */
25
+ export function createEditTool(config = {}) {
26
+ const workingDirectory = config.workingDirectory || process.cwd();
27
+ return {
28
+ declaration: {
29
+ name: 'Edit',
30
+ description: `Performs targeted string replacement in a file.
31
+ The old_string must match exactly (including whitespace and indentation).
32
+ By default, only the first occurrence is replaced. Set replace_all to true to replace all occurrences.
33
+ The edit will FAIL if old_string is not found in the file.
34
+ TIP: Include enough context in old_string to make it unique within the file.`,
35
+ parametersJsonSchema: zodToJsonSchema(editSchema),
36
+ },
37
+ executor: async (args) => {
38
+ const params = editSchema.parse(args);
39
+ const resolvedPath = resolvePath(params.file_path, workingDirectory);
40
+ // Security checks
41
+ if (!isPathSafe(params.file_path, workingDirectory)) {
42
+ throw new Error(`Path traversal detected: ${params.file_path}`);
43
+ }
44
+ if (!isPathAllowed(resolvedPath, config.allowedPaths)) {
45
+ throw new Error(`Access denied: ${params.file_path} is outside allowed paths`);
46
+ }
47
+ // Check if file exists
48
+ try {
49
+ const stat = await fs.stat(resolvedPath);
50
+ if (!stat.isFile()) {
51
+ throw new Error(`Not a file: ${params.file_path}`);
52
+ }
53
+ }
54
+ catch (error) {
55
+ if (error.code === 'ENOENT') {
56
+ throw new Error(`File not found: ${params.file_path}`);
57
+ }
58
+ throw error;
59
+ }
60
+ // Read current content
61
+ const content = await fs.readFile(resolvedPath, 'utf-8');
62
+ // Check if old_string exists
63
+ if (!content.includes(params.old_string)) {
64
+ throw new Error(`String not found in file: The specified old_string was not found in ${params.file_path}. ` +
65
+ `Make sure the string matches exactly, including whitespace and indentation.`);
66
+ }
67
+ // Count occurrences before replacement
68
+ const occurrences = content.split(params.old_string).length - 1;
69
+ // Check for uniqueness if not replacing all
70
+ if (!params.replace_all && occurrences > 1) {
71
+ throw new Error(`Multiple occurrences found: old_string appears ${occurrences} times in the file. ` +
72
+ `Either provide more context to make it unique, or set replace_all to true.`);
73
+ }
74
+ // Perform replacement
75
+ let newContent;
76
+ let replacementCount;
77
+ if (params.replace_all) {
78
+ newContent = content.split(params.old_string).join(params.new_string);
79
+ replacementCount = occurrences;
80
+ }
81
+ else {
82
+ newContent = content.replace(params.old_string, params.new_string);
83
+ replacementCount = 1;
84
+ }
85
+ // Write the updated content
86
+ await fs.writeFile(resolvedPath, newContent, 'utf-8');
87
+ return {
88
+ success: true,
89
+ file_path: params.file_path,
90
+ replacements_made: replacementCount,
91
+ message: `Successfully replaced ${replacementCount} occurrence${replacementCount > 1 ? 's' : ''} in ${params.file_path}`,
92
+ };
93
+ },
94
+ parallel: false, // Editing should be sequential to avoid conflicts
95
+ };
96
+ }
97
+ //# sourceMappingURL=edit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edit.js","sourceRoot":"","sources":["../../src/tools/edit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGrD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAEzE;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,SAAS,EAAE,CAAC;SACT,MAAM,EAAE;SACR,QAAQ,CAAC,iFAAiF,CAAC;IAC9F,UAAU,EAAE,CAAC;SACV,MAAM,EAAE;SACR,QAAQ,CACP,gGAAgG,CACjG;IACH,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,wCAAwC,CAAC;IACzE,WAAW,EAAE,CAAC;SACX,OAAO,EAAE;SACT,QAAQ,EAAE;SACV,OAAO,CAAC,KAAK,CAAC;SACd,QAAQ,CACP,0FAA0F,CAC3F;CACJ,CAAC,CAAC;AAIH;;GAEG;AACH,MAAM,UA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E,gBAAgB;gBACnC,OAAO,EAAE,yBAAyB,gBAAgB,cAAc,gBAAgB,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,OAAO,MAAM,CAAC,SAAS,EAAE;aACzH,CAAC;QACJ,CAAC;QACD,QAAQ,EAAE,KAAK,EAAE,kDAAkD;KACpE,CAAC;AACJ,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { z } from 'zod';
2
+ import type { ToolDefinition } from '../types/index.js';
3
+ import type { ToolConfig } from './types.js';
4
+ /**
5
+ * Schema for the Glob tool parameters
6
+ */
7
+ export declare const globSchema: z.ZodObject<{
8
+ pattern: z.ZodString;
9
+ cwd: z.ZodOptional<z.ZodString>;
10
+ ignore: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
11
+ }, "strip", z.ZodTypeAny, {
12
+ pattern: string;
13
+ cwd?: string | undefined;
14
+ ignore?: string[] | undefined;
15
+ }, {
16
+ pattern: string;
17
+ cwd?: string | undefined;
18
+ ignore?: string[] | undefined;
19
+ }>;
20
+ export type GlobParams = z.infer<typeof globSchema>;
21
+ /**
22
+ * Creates the Glob tool for finding files matching patterns
23
+ */
24
+ export declare function createGlobTool(config?: ToolConfig): ToolDefinition;
25
+ //# sourceMappingURL=glob.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glob.d.ts","sourceRoot":"","sources":["../../src/tools/glob.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAS7C;;GAEG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;EAWrB,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAkBpD;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,GAAE,UAAe,GAAG,cAAc,CA+DtE"}
@@ -0,0 +1,88 @@
1
+ import { z } from 'zod';
2
+ import { zodToJsonSchema } from 'zod-to-json-schema';
3
+ import { resolvePath, isPathAllowed, walkDirectory, matchGlobPattern, getRelativePath, } from './utils/path.js';
4
+ /**
5
+ * Schema for the Glob tool parameters
6
+ */
7
+ export const globSchema = z.object({
8
+ pattern: z
9
+ .string()
10
+ .describe('Glob pattern to match files. Supports *, **, and ? wildcards. Examples: "*.ts", "src/**/*.js", "test_?.py"'),
11
+ cwd: z.string().optional().describe('Directory to search in. Defaults to working directory.'),
12
+ ignore: z
13
+ .array(z.string())
14
+ .optional()
15
+ .describe('Array of patterns to ignore. Example: ["node_modules/**", "*.test.ts"]'),
16
+ });
17
+ /**
18
+ * Default ignore patterns
19
+ */
20
+ const DEFAULT_IGNORE_PATTERNS = [
21
+ 'node_modules/**',
22
+ '.git/**',
23
+ '.next/**',
24
+ 'dist/**',
25
+ 'build/**',
26
+ 'coverage/**',
27
+ '__pycache__/**',
28
+ '.cache/**',
29
+ '.idea/**',
30
+ '.vscode/**',
31
+ ];
32
+ /**
33
+ * Creates the Glob tool for finding files matching patterns
34
+ */
35
+ export function createGlobTool(config = {}) {
36
+ const workingDirectory = config.workingDirectory || process.cwd();
37
+ return {
38
+ declaration: {
39
+ name: 'Glob',
40
+ description: `Finds files matching a glob pattern.
41
+ Supports wildcards:
42
+ - * matches any characters except path separators
43
+ - ** matches any characters including path separators (for recursive matching)
44
+ - ? matches any single character
45
+
46
+ By default ignores common directories like node_modules, .git, dist, etc.
47
+ Returns file paths relative to the search directory.`,
48
+ parametersJsonSchema: zodToJsonSchema(globSchema),
49
+ },
50
+ executor: async (args) => {
51
+ const params = globSchema.parse(args);
52
+ // Resolve the search directory
53
+ const searchDir = params.cwd ? resolvePath(params.cwd, workingDirectory) : workingDirectory;
54
+ // Security check
55
+ if (!isPathAllowed(searchDir, config.allowedPaths)) {
56
+ throw new Error(`Access denied: ${params.cwd || '.'} is outside allowed paths`);
57
+ }
58
+ // Combine default and custom ignore patterns
59
+ const ignorePatterns = [...DEFAULT_IGNORE_PATTERNS, ...(params.ignore || [])];
60
+ // Walk the directory
61
+ const allFiles = await walkDirectory(searchDir, {
62
+ ignore: ignorePatterns,
63
+ maxDepth: 50,
64
+ });
65
+ // Filter files matching the pattern
66
+ const matchingFiles = [];
67
+ for (const filePath of allFiles) {
68
+ const relativePath = getRelativePath(filePath, searchDir);
69
+ if (matchGlobPattern(params.pattern, relativePath)) {
70
+ matchingFiles.push(relativePath);
71
+ }
72
+ }
73
+ // Sort results for consistent output
74
+ matchingFiles.sort();
75
+ return {
76
+ pattern: params.pattern,
77
+ search_directory: params.cwd || '.',
78
+ matches: matchingFiles,
79
+ count: matchingFiles.length,
80
+ message: matchingFiles.length > 0
81
+ ? `Found ${matchingFiles.length} file${matchingFiles.length > 1 ? 's' : ''} matching "${params.pattern}"`
82
+ : `No files found matching "${params.pattern}"`,
83
+ };
84
+ },
85
+ parallel: true, // Glob is read-only and safe to run in parallel
86
+ };
87
+ }
88
+ //# sourceMappingURL=glob.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glob.js","sourceRoot":"","sources":["../../src/tools/glob.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGrD,OAAO,EACL,WAAW,EACX,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,eAAe,GAChB,MAAM,iBAAiB,CAAC;AAEzB;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,OAAO,EAAE,CAAC;SACP,MAAM,EAAE;SACR,QAAQ,CACP,4GAA4G,CAC7G;IACH,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,wDAAwD,CAAC;IAC7F,MAAM,EAAE,CAA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C9C,MAAM,EAAE,cAAc;gBACtB,QAAQ,EAAE,EAAE;aACb,CAAC,CAAC;YAEH,oCAAoC;YACpC,MAAM,aAAa,GAAa,EAAE,CAAC;YAEnC,KAAK,MAAM,QAAQ,IAAI,QAAQ,EAAE,CAAC;gBAChC,MAAM,YAAY,GAAG,eAAe,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;gBAE1D,IAAI,gBAAgB,CAAC,MAAM,CAAC,OAAO,EAAE,YAAY,CAAC,EAAE,CAAC;oBACnD,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;gBACnC,CAAC;YACH,CAAC;YAED,qCAAqC;YACrC,aAAa,CAAC,IAAI,EAAE,CAAC;YAErB,OAAO;gBACL,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,gBAAgB,EAAE,MAAM,CAAC,GAAG,IAAI,GAAG;gBACnC,OAAO,EAAE,aAAa;gBACtB,KAAK,EAAE,aAAa,CAAC,MAAM;gBAC3B,OAAO,EACL,aAAa,CAAC,MAAM,GAAG,CAAC;oBACtB,CAAC,CAAC,SAAS,aAAa,CAAC,MAAM,QAAQ,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,cAAc,MAAM,CAAC,OAAO,GAAG;oBACzG,CAAC,CAAC,4BAA4B,MAAM,CAAC,OAAO,GAAG;aACpD,CAAC;QACJ,CAAC;QACD,QAAQ,EAAE,IAAI,EAAE,gDAAgD;KACjE,CAAC;AACJ,CAAC"}
@@ -0,0 +1,31 @@
1
+ import { z } from 'zod';
2
+ import type { ToolDefinition } from '../types/index.js';
3
+ import type { ToolConfig } from './types.js';
4
+ /**
5
+ * Schema for the Grep tool parameters
6
+ */
7
+ export declare const grepSchema: z.ZodObject<{
8
+ pattern: z.ZodString;
9
+ path: z.ZodOptional<z.ZodString>;
10
+ include: z.ZodOptional<z.ZodString>;
11
+ context_lines: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
12
+ case_insensitive: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
13
+ }, "strip", z.ZodTypeAny, {
14
+ pattern: string;
15
+ context_lines: number;
16
+ case_insensitive: boolean;
17
+ path?: string | undefined;
18
+ include?: string | undefined;
19
+ }, {
20
+ pattern: string;
21
+ path?: string | undefined;
22
+ include?: string | undefined;
23
+ context_lines?: number | undefined;
24
+ case_insensitive?: boolean | undefined;
25
+ }>;
26
+ export type GrepParams = z.infer<typeof grepSchema>;
27
+ /**
28
+ * Creates the Grep tool for searching patterns in files
29
+ */
30
+ export declare function createGrepTool(config?: ToolConfig): ToolDefinition;
31
+ //# sourceMappingURL=grep.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grep.d.ts","sourceRoot":"","sources":["../../src/tools/grep.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAS7C;;GAEG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;EAwBrB,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAwBpD;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,GAAE,UAAe,GAAG,cAAc,CA0KtE"}
@@ -0,0 +1,195 @@
1
+ import * as fs from 'fs/promises';
2
+ import * as path from 'path';
3
+ import { z } from 'zod';
4
+ import { zodToJsonSchema } from 'zod-to-json-schema';
5
+ import { resolvePath, isPathAllowed, walkDirectory, matchGlobPattern, getRelativePath, } from './utils/path.js';
6
+ /**
7
+ * Schema for the Grep tool parameters
8
+ */
9
+ export const grepSchema = z.object({
10
+ pattern: z
11
+ .string()
12
+ .describe('Regular expression pattern to search for. Use string literals for exact matches.'),
13
+ path: z
14
+ .string()
15
+ .optional()
16
+ .describe('File or directory path to search in. Defaults to working directory.'),
17
+ include: z
18
+ .string()
19
+ .optional()
20
+ .describe('Glob pattern to filter which files to search. Example: "*.ts" to only search TypeScript files.'),
21
+ context_lines: z
22
+ .number()
23
+ .optional()
24
+ .default(0)
25
+ .describe('Number of lines to show before and after each match. Default is 0.'),
26
+ case_insensitive: z
27
+ .boolean()
28
+ .optional()
29
+ .default(false)
30
+ .describe('If true, perform case-insensitive matching.'),
31
+ });
32
+ /**
33
+ * Default ignore patterns for grep
34
+ */
35
+ const DEFAULT_IGNORE_PATTERNS = [
36
+ 'node_modules/**',
37
+ '.git/**',
38
+ '.next/**',
39
+ 'dist/**',
40
+ 'build/**',
41
+ 'coverage/**',
42
+ '__pycache__/**',
43
+ '.cache/**',
44
+ ];
45
+ /**
46
+ * Creates the Grep tool for searching patterns in files
47
+ */
48
+ export function createGrepTool(config = {}) {
49
+ const workingDirectory = config.workingDirectory || process.cwd();
50
+ return {
51
+ declaration: {
52
+ name: 'Grep',
53
+ description: `Searches for a pattern in file contents using regular expressions.
54
+ Returns matching lines with file paths and line numbers.
55
+ Use context_lines to show surrounding context.
56
+
57
+ Examples:
58
+ - pattern: "function\\s+\\w+" - Find function declarations
59
+ - pattern: "TODO|FIXME" with case_insensitive: true - Find todo comments
60
+ - pattern: "import.*from" with include: "*.ts" - Find imports in TypeScript files`,
61
+ parametersJsonSchema: zodToJsonSchema(grepSchema),
62
+ },
63
+ executor: async (args) => {
64
+ const params = grepSchema.parse(args);
65
+ // Resolve the search path
66
+ const searchPath = params.path
67
+ ? resolvePath(params.path, workingDirectory)
68
+ : workingDirectory;
69
+ // Security check
70
+ if (!isPathAllowed(searchPath, config.allowedPaths)) {
71
+ throw new Error(`Access denied: ${params.path || '.'} is outside allowed paths`);
72
+ }
73
+ // Compile the regex
74
+ let regex;
75
+ try {
76
+ regex = new RegExp(params.pattern, params.case_insensitive ? 'gi' : 'g');
77
+ }
78
+ catch (error) {
79
+ throw new Error(`Invalid regex pattern: ${error.message}`);
80
+ }
81
+ // Get files to search
82
+ let filesToSearch = [];
83
+ try {
84
+ const stat = await fs.stat(searchPath);
85
+ if (stat.isFile()) {
86
+ filesToSearch = [searchPath];
87
+ }
88
+ else if (stat.isDirectory()) {
89
+ filesToSearch = await walkDirectory(searchPath, {
90
+ ignore: DEFAULT_IGNORE_PATTERNS,
91
+ maxDepth: 30,
92
+ });
93
+ }
94
+ }
95
+ catch (error) {
96
+ if (error.code === 'ENOENT') {
97
+ throw new Error(`Path not found: ${params.path || '.'}`);
98
+ }
99
+ throw error;
100
+ }
101
+ // Apply include filter if specified
102
+ if (params.include) {
103
+ filesToSearch = filesToSearch.filter((file) => {
104
+ const relativePath = getRelativePath(file, workingDirectory);
105
+ const fileName = path.basename(file);
106
+ return (matchGlobPattern(params.include, relativePath) ||
107
+ matchGlobPattern(params.include, fileName));
108
+ });
109
+ }
110
+ // Search each file
111
+ const matches = [];
112
+ const maxMatches = 500; // Limit to prevent overwhelming output
113
+ let truncated = false;
114
+ for (const filePath of filesToSearch) {
115
+ if (matches.length >= maxMatches) {
116
+ truncated = true;
117
+ break;
118
+ }
119
+ try {
120
+ const content = await fs.readFile(filePath, 'utf-8');
121
+ const lines = content.split('\n');
122
+ for (let i = 0; i < lines.length; i++) {
123
+ if (matches.length >= maxMatches) {
124
+ truncated = true;
125
+ break;
126
+ }
127
+ // Reset regex lastIndex for global regex
128
+ regex.lastIndex = 0;
129
+ if (regex.test(lines[i])) {
130
+ const match = {
131
+ file: getRelativePath(filePath, workingDirectory),
132
+ line_number: i + 1,
133
+ line: lines[i],
134
+ };
135
+ // Add context if requested
136
+ if (params.context_lines && params.context_lines > 0) {
137
+ const contextBefore = [];
138
+ const contextAfter = [];
139
+ for (let j = Math.max(0, i - params.context_lines); j < i; j++) {
140
+ contextBefore.push(lines[j]);
141
+ }
142
+ for (let j = i + 1; j <= Math.min(lines.length - 1, i + params.context_lines); j++) {
143
+ contextAfter.push(lines[j]);
144
+ }
145
+ if (contextBefore.length > 0) {
146
+ match.context_before = contextBefore;
147
+ }
148
+ if (contextAfter.length > 0) {
149
+ match.context_after = contextAfter;
150
+ }
151
+ }
152
+ matches.push(match);
153
+ }
154
+ }
155
+ }
156
+ catch {
157
+ // Skip files that can't be read (binary files, permission issues, etc.)
158
+ }
159
+ }
160
+ // Format output
161
+ const formattedMatches = matches.map((m) => {
162
+ let output = `${m.file}:${m.line_number}:${m.line}`;
163
+ if (m.context_before || m.context_after) {
164
+ const parts = [];
165
+ if (m.context_before) {
166
+ m.context_before.forEach((line, idx) => {
167
+ parts.push(`${m.file}:${m.line_number - m.context_before.length + idx}-${line}`);
168
+ });
169
+ }
170
+ parts.push(`${m.file}:${m.line_number}:${m.line}`);
171
+ if (m.context_after) {
172
+ m.context_after.forEach((line, idx) => {
173
+ parts.push(`${m.file}:${m.line_number + idx + 1}-${line}`);
174
+ });
175
+ }
176
+ output = parts.join('\n');
177
+ }
178
+ return output;
179
+ });
180
+ return {
181
+ pattern: params.pattern,
182
+ search_path: params.path || '.',
183
+ matches: formattedMatches,
184
+ match_count: matches.length,
185
+ files_searched: filesToSearch.length,
186
+ truncated,
187
+ message: matches.length > 0
188
+ ? `Found ${matches.length} match${matches.length > 1 ? 'es' : ''} in ${filesToSearch.length} file${filesToSearch.length > 1 ? 's' : ''}${truncated ? ' (results truncated)' : ''}`
189
+ : `No matches found for "${params.pattern}"`,
190
+ };
191
+ },
192
+ parallel: true, // Grep is read-only and safe to run in parallel
193
+ };
194
+ }
195
+ //# sourceMappingURL=grep.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grep.js","sourceRoot":"","sources":["../../src/tools/grep.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGrD,OAAO,EACL,W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AC,CAAC;gBAC5B,CAAC;gBACD,OAAO,MAAM,CAAC;YAChB,CAAC,CAAC,CAAC;YAEH,OAAO;gBACL,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,WAAW,EAAE,MAAM,CAAC,IAAI,IAAI,GAAG;gBAC/B,OAAO,EAAE,gBAAgB;gBACzB,WAAW,EAAE,OAAO,CAAC,MAAM;gBAC3B,cAAc,EAAE,aAAa,CAAC,MAAM;gBACpC,SAAS;gBACT,OAAO,EACL,OAAO,CAAC,MAAM,GAAG,CAAC;oBAChB,CAAC,CAAC,SAAS,OAAO,CAAC,MAAM,SAAS,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,OAAO,aAAa,CAAC,MAAM,QAAQ,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,EAAE,EAAE;oBAClL,CAAC,CAAC,yBAAyB,MAAM,CAAC,OAAO,GAAG;aACjD,CAAC;QACJ,CAAC;QACD,QAAQ,EAAE,IAAI,EAAE,gDAAgD;KACjE,CAAC;AACJ,CAAC"}
@@ -0,0 +1,85 @@
1
+ import type { ToolDefinition } from '../types/index.js';
2
+ import type { BuiltInToolsConfig, ProcessManager, ToolConfig, ToolName } from './types.js';
3
+ export { createReadTool } from './read.js';
4
+ export { createWriteTool } from './write.js';
5
+ export { createEditTool } from './edit.js';
6
+ export { createGlobTool } from './glob.js';
7
+ export { createGrepTool } from './grep.js';
8
+ export { createBashTool } from './bash.js';
9
+ export { createBashOutputTool } from './bash-output.js';
10
+ export { createKillBashTool } from './kill-bash.js';
11
+ export { createTaskTool } from './task.js';
12
+ export { createTodoWriteTool, createTodoReadTool } from './todo-write.js';
13
+ export type { ToolConfig, BuiltInToolsConfig, ToolName, TodoStorage, TodoItem, TodoStatus, ProcessManager, ProcessInfo, AgentFactory, TaskAgentConfig, ShellResult, ToolCreator, } from './types.js';
14
+ export { TOOL_NAMES } from './types.js';
15
+ export { readSchema, type ReadParams } from './read.js';
16
+ export { writeSchema, type WriteParams } from './write.js';
17
+ export { editSchema, type EditParams } from './edit.js';
18
+ export { globSchema, type GlobParams } from './glob.js';
19
+ export { grepSchema, type GrepParams } from './grep.js';
20
+ export { bashSchema, type BashParams } from './bash.js';
21
+ export { bashOutputSchema, type BashOutputParams } from './bash-output.js';
22
+ export { killBashSchema, type KillBashParams } from './kill-bash.js';
23
+ export { taskSchema, type TaskParams } from './task.js';
24
+ export { todoWriteSchema, type TodoWriteParams } from './todo-write.js';
25
+ /**
26
+ * Result of createBuiltInTools including tools and the process manager
27
+ */
28
+ export interface BuiltInToolsResult {
29
+ /** Array of tool definitions ready to use with an agent */
30
+ tools: ToolDefinition[];
31
+ /** Process manager for background processes (for cleanup) */
32
+ processManager: ProcessManager;
33
+ /** Cleanup function to terminate all background processes */
34
+ cleanup: () => Promise<void>;
35
+ }
36
+ /**
37
+ * Creates an array of built-in tools based on configuration.
38
+ * You must explicitly specify which tools you need using the `tools` property.
39
+ * Tool names are strongly typed with autocomplete support.
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * import { createBuiltInTools } from 'concevent-ai-agent-sdk';
44
+ *
45
+ * // Specify exactly which tools you need
46
+ * const { tools, cleanup } = createBuiltInTools({
47
+ * workingDirectory: '/project',
48
+ * tools: ['Read', 'Write', 'Glob'],
49
+ * });
50
+ *
51
+ * // For shell tools
52
+ * const { tools: shellTools } = createBuiltInTools({
53
+ * workingDirectory: '/project',
54
+ * tools: ['Bash'],
55
+ * defaultTimeout: 60000,
56
+ * });
57
+ *
58
+ * // Don't forget to cleanup when done
59
+ * process.on('exit', () => cleanup());
60
+ * ```
61
+ */
62
+ export declare function createBuiltInTools(config: BuiltInToolsConfig): BuiltInToolsResult;
63
+ /**
64
+ * Creates a single built-in tool by name.
65
+ * Tool names are strongly typed with autocomplete support.
66
+ *
67
+ * @example
68
+ * ```typescript
69
+ * import { createBuiltInTool } from 'concevent-ai-agent-sdk';
70
+ *
71
+ * const readTool = createBuiltInTool('Read', {
72
+ * workingDirectory: '/project'
73
+ * });
74
+ * ```
75
+ */
76
+ export declare function createBuiltInTool(name: ToolName, config?: ToolConfig, processManager?: ProcessManager): ToolDefinition;
77
+ /**
78
+ * Gets the names of all available built-in tools.
79
+ */
80
+ export declare function getBuiltInToolNames(): string[];
81
+ /**
82
+ * Checks if a tool name is a built-in tool.
83
+ */
84
+ export declare function isBuiltInTool(name: string): boolean;
85
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAK3F,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAG1E,YAAY,EACV,UAAU,EACV,kBAAkB,EAClB,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,UAAU,E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