@framers/agentos-ext-cli-executor 1.1.0 → 1.2.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.
- package/LICENSE +23 -0
- package/README.md +80 -28
- package/dist/index.d.ts +68 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +78 -18
- package/dist/index.js.map +1 -1
- package/dist/services/shellService.d.ts +15 -1
- package/dist/services/shellService.d.ts.map +1 -1
- package/dist/services/shellService.js +96 -10
- package/dist/services/shellService.js.map +1 -1
- package/dist/tools/createPdf.d.ts +32 -0
- package/dist/tools/createPdf.d.ts.map +1 -0
- package/dist/tools/createPdf.js +215 -0
- package/dist/tools/createPdf.js.map +1 -0
- package/dist/tools/execute.d.ts +15 -18
- package/dist/tools/execute.d.ts.map +1 -1
- package/dist/tools/execute.js +36 -36
- package/dist/tools/execute.js.map +1 -1
- package/dist/tools/fileRead.d.ts +15 -18
- package/dist/tools/fileRead.d.ts.map +1 -1
- package/dist/tools/fileRead.js +63 -39
- package/dist/tools/fileRead.js.map +1 -1
- package/dist/tools/fileWrite.d.ts +15 -18
- package/dist/tools/fileWrite.d.ts.map +1 -1
- package/dist/tools/fileWrite.js +47 -40
- package/dist/tools/fileWrite.js.map +1 -1
- package/dist/tools/listDir.d.ts +15 -18
- package/dist/tools/listDir.d.ts.map +1 -1
- package/dist/tools/listDir.js +45 -45
- package/dist/tools/listDir.js.map +1 -1
- package/dist/tools/readDocument.d.ts +41 -0
- package/dist/tools/readDocument.d.ts.map +1 -0
- package/dist/tools/readDocument.js +252 -0
- package/dist/tools/readDocument.js.map +1 -0
- package/dist/types.d.ts +63 -0
- package/dist/types.d.ts.map +1 -1
- package/manifest.json +20 -14
- package/package.json +15 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.js","sourceRoot":"","sources":["../../src/tools/execute.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;GAEG;AACH,MAAM,OAAO,WAAW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AE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAC9E,CAAC;CACF"}
|
package/dist/tools/fileRead.d.ts
CHANGED
|
@@ -4,17 +4,22 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @module @framers/agentos-ext-cli-executor
|
|
6
6
|
*/
|
|
7
|
-
import type { ITool } from '@framers/agentos';
|
|
8
|
-
import type { ShellService } from '../services/shellService';
|
|
9
|
-
import type { FileReadResult } from '../types';
|
|
7
|
+
import type { ITool, JSONSchemaObject, ToolExecutionContext, ToolExecutionResult } from '@framers/agentos';
|
|
8
|
+
import type { ShellService } from '../services/shellService.js';
|
|
9
|
+
import type { FileReadResult } from '../types.js';
|
|
10
10
|
/**
|
|
11
11
|
* Tool for reading files
|
|
12
12
|
*/
|
|
13
13
|
export declare class FileReadTool implements ITool {
|
|
14
14
|
private shellService;
|
|
15
|
-
readonly id = "
|
|
16
|
-
|
|
17
|
-
readonly
|
|
15
|
+
readonly id = "cli-file-read-v1";
|
|
16
|
+
/** Tool call name used by the LLM / ToolExecutor. */
|
|
17
|
+
readonly name = "file_read";
|
|
18
|
+
readonly displayName = "Read File";
|
|
19
|
+
readonly description = "Read the contents of a file from disk.";
|
|
20
|
+
readonly category = "system";
|
|
21
|
+
readonly hasSideEffects = false;
|
|
22
|
+
readonly inputSchema: JSONSchemaObject;
|
|
18
23
|
constructor(shellService: ShellService);
|
|
19
24
|
/**
|
|
20
25
|
* Read file
|
|
@@ -25,21 +30,13 @@ export declare class FileReadTool implements ITool {
|
|
|
25
30
|
maxBytes?: number;
|
|
26
31
|
lines?: number;
|
|
27
32
|
fromEnd?: boolean;
|
|
28
|
-
}): Promise<
|
|
29
|
-
success: boolean;
|
|
30
|
-
output?: FileReadResult;
|
|
31
|
-
error?: string;
|
|
32
|
-
}>;
|
|
33
|
+
}, _context: ToolExecutionContext): Promise<ToolExecutionResult<FileReadResult>>;
|
|
33
34
|
/**
|
|
34
35
|
* Validate input
|
|
35
36
|
*/
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
errors
|
|
37
|
+
validateArgs(input: Record<string, any>): {
|
|
38
|
+
isValid: boolean;
|
|
39
|
+
errors?: any[];
|
|
39
40
|
};
|
|
40
|
-
/**
|
|
41
|
-
* Get JSON schema for tool
|
|
42
|
-
*/
|
|
43
|
-
getSchema(): any;
|
|
44
41
|
}
|
|
45
42
|
//# sourceMappingURL=fileRead.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileRead.d.ts","sourceRoot":"","sources":["../../src/tools/fileRead.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"fileRead.d.ts","sourceRoot":"","sources":["../../src/tools/fileRead.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC3G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD;;GAEG;AACH,qBAAa,YAAa,YAAW,KAAK;IAuC5B,OAAO,CAAC,YAAY;IAtChC,SAAgB,EAAE,sBAAsB;IACxC,qDAAqD;IACrD,SAAgB,IAAI,eAAe;IACnC,SAAgB,WAAW,eAAe;IAC1C,SAAgB,WAAW,4CAA4C;IACvE,SAAgB,QAAQ,YAAY;IACpC,SAAgB,cAAc,SAAS;IAEvC,SAAgB,WAAW,EAAE,gBAAgB,CA4B3C;gBAEkB,YAAY,EAAE,YAAY;IAE9C;;OAEG;IACG,OAAO,CACX,KAAK,EAAE;QACP,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,CAAC,EAAE,cAAc,CAAC;QAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,OAAO,CAAC;KACjB,EACD,QAAQ,EAAE,oBAAoB,GAC7B,OAAO,CAAC,mBAAmB,CAAC,cAAc,CAAC,CAAC;IAsC/C;;OAEG;IACH,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,GAAG,EAAE,CAAA;KAAE;CAW/E"}
|
package/dist/tools/fileRead.js
CHANGED
|
@@ -4,22 +4,79 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @module @framers/agentos-ext-cli-executor
|
|
6
6
|
*/
|
|
7
|
+
import { stat } from 'node:fs/promises';
|
|
8
|
+
import { resolve } from 'node:path';
|
|
7
9
|
/**
|
|
8
10
|
* Tool for reading files
|
|
9
11
|
*/
|
|
10
12
|
export class FileReadTool {
|
|
11
13
|
shellService;
|
|
12
|
-
id = '
|
|
13
|
-
name
|
|
14
|
-
|
|
14
|
+
id = 'cli-file-read-v1';
|
|
15
|
+
/** Tool call name used by the LLM / ToolExecutor. */
|
|
16
|
+
name = 'file_read';
|
|
17
|
+
displayName = 'Read File';
|
|
18
|
+
description = 'Read the contents of a file from disk.';
|
|
19
|
+
category = 'system';
|
|
20
|
+
hasSideEffects = false;
|
|
21
|
+
inputSchema = {
|
|
22
|
+
type: 'object',
|
|
23
|
+
required: ['path'],
|
|
24
|
+
properties: {
|
|
25
|
+
path: {
|
|
26
|
+
type: 'string',
|
|
27
|
+
description: 'File path to read',
|
|
28
|
+
},
|
|
29
|
+
encoding: {
|
|
30
|
+
type: 'string',
|
|
31
|
+
default: 'utf-8',
|
|
32
|
+
description: 'File encoding',
|
|
33
|
+
},
|
|
34
|
+
maxBytes: {
|
|
35
|
+
type: 'number',
|
|
36
|
+
description: 'Maximum bytes to read',
|
|
37
|
+
},
|
|
38
|
+
lines: {
|
|
39
|
+
type: 'number',
|
|
40
|
+
description: 'Number of lines to read',
|
|
41
|
+
},
|
|
42
|
+
fromEnd: {
|
|
43
|
+
type: 'boolean',
|
|
44
|
+
default: false,
|
|
45
|
+
description: 'Read lines from end of file',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
additionalProperties: false,
|
|
49
|
+
};
|
|
15
50
|
constructor(shellService) {
|
|
16
51
|
this.shellService = shellService;
|
|
17
52
|
}
|
|
18
53
|
/**
|
|
19
54
|
* Read file
|
|
20
55
|
*/
|
|
21
|
-
async execute(input) {
|
|
56
|
+
async execute(input, _context) {
|
|
22
57
|
try {
|
|
58
|
+
// Redirect binary document formats to read_document tool
|
|
59
|
+
if (input.path && /\.(xlsx?|docx|pdf)$/i.test(input.path)) {
|
|
60
|
+
const ext = input.path.match(/\.[^.]+$/)?.[0] || '';
|
|
61
|
+
return {
|
|
62
|
+
success: false,
|
|
63
|
+
error: `Cannot read binary document "${input.path}" with file_read — this will return garbled content. Use the read_document tool instead to parse ${ext} files and extract their text content.`,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
// Fail-fast: detect directories before requesting any permissions or doing I/O
|
|
67
|
+
try {
|
|
68
|
+
const resolved = resolve(input.path);
|
|
69
|
+
const stats = await stat(resolved);
|
|
70
|
+
if (stats.isDirectory()) {
|
|
71
|
+
return {
|
|
72
|
+
success: false,
|
|
73
|
+
error: `"${input.path}" is a directory, not a file. Use list_directory to view directory contents.`,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
// Path doesn't exist or can't be stat'd — let readFile handle it
|
|
79
|
+
}
|
|
23
80
|
const result = await this.shellService.readFile(input.path, {
|
|
24
81
|
encoding: input.encoding,
|
|
25
82
|
maxBytes: input.maxBytes,
|
|
@@ -35,7 +92,7 @@ export class FileReadTool {
|
|
|
35
92
|
/**
|
|
36
93
|
* Validate input
|
|
37
94
|
*/
|
|
38
|
-
|
|
95
|
+
validateArgs(input) {
|
|
39
96
|
const errors = [];
|
|
40
97
|
if (!input.path) {
|
|
41
98
|
errors.push('Path is required');
|
|
@@ -43,40 +100,7 @@ export class FileReadTool {
|
|
|
43
100
|
else if (typeof input.path !== 'string') {
|
|
44
101
|
errors.push('Path must be a string');
|
|
45
102
|
}
|
|
46
|
-
return
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Get JSON schema for tool
|
|
50
|
-
*/
|
|
51
|
-
getSchema() {
|
|
52
|
-
return {
|
|
53
|
-
type: 'object',
|
|
54
|
-
required: ['path'],
|
|
55
|
-
properties: {
|
|
56
|
-
path: {
|
|
57
|
-
type: 'string',
|
|
58
|
-
description: 'File path to read',
|
|
59
|
-
},
|
|
60
|
-
encoding: {
|
|
61
|
-
type: 'string',
|
|
62
|
-
default: 'utf-8',
|
|
63
|
-
description: 'File encoding',
|
|
64
|
-
},
|
|
65
|
-
maxBytes: {
|
|
66
|
-
type: 'number',
|
|
67
|
-
description: 'Maximum bytes to read',
|
|
68
|
-
},
|
|
69
|
-
lines: {
|
|
70
|
-
type: 'number',
|
|
71
|
-
description: 'Number of lines to read',
|
|
72
|
-
},
|
|
73
|
-
fromEnd: {
|
|
74
|
-
type: 'boolean',
|
|
75
|
-
default: false,
|
|
76
|
-
description: 'Read lines from end of file',
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
};
|
|
103
|
+
return errors.length === 0 ? { isValid: true } : { isValid: false, errors };
|
|
80
104
|
}
|
|
81
105
|
}
|
|
82
106
|
//# sourceMappingURL=fileRead.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileRead.js","sourceRoot":"","sources":["../../src/tools/fileRead.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"fileRead.js","sourceRoot":"","sources":["../../src/tools/fileRead.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC;;GAEG;A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,CAAC;QACvC,CAAC;QAED,OAAO,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAC9E,CAAC;CACF"}
|
|
@@ -4,17 +4,22 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @module @framers/agentos-ext-cli-executor
|
|
6
6
|
*/
|
|
7
|
-
import type { ITool } from '@framers/agentos';
|
|
8
|
-
import type { ShellService } from '../services/shellService';
|
|
9
|
-
import type { FileWriteResult } from '../types';
|
|
7
|
+
import type { ITool, JSONSchemaObject, ToolExecutionContext, ToolExecutionResult } from '@framers/agentos';
|
|
8
|
+
import type { ShellService } from '../services/shellService.js';
|
|
9
|
+
import type { FileWriteResult } from '../types.js';
|
|
10
10
|
/**
|
|
11
11
|
* Tool for writing files
|
|
12
12
|
*/
|
|
13
13
|
export declare class FileWriteTool implements ITool {
|
|
14
14
|
private shellService;
|
|
15
|
-
readonly id = "
|
|
16
|
-
|
|
17
|
-
readonly
|
|
15
|
+
readonly id = "cli-file-write-v1";
|
|
16
|
+
/** Tool call name used by the LLM / ToolExecutor. */
|
|
17
|
+
readonly name = "file_write";
|
|
18
|
+
readonly displayName = "Write File";
|
|
19
|
+
readonly description = "Write or append content to a file on disk.";
|
|
20
|
+
readonly category = "system";
|
|
21
|
+
readonly hasSideEffects = true;
|
|
22
|
+
readonly inputSchema: JSONSchemaObject;
|
|
18
23
|
constructor(shellService: ShellService);
|
|
19
24
|
/**
|
|
20
25
|
* Write file
|
|
@@ -25,21 +30,13 @@ export declare class FileWriteTool implements ITool {
|
|
|
25
30
|
encoding?: BufferEncoding;
|
|
26
31
|
append?: boolean;
|
|
27
32
|
createDirs?: boolean;
|
|
28
|
-
}): Promise<
|
|
29
|
-
success: boolean;
|
|
30
|
-
output?: FileWriteResult;
|
|
31
|
-
error?: string;
|
|
32
|
-
}>;
|
|
33
|
+
}, _context: ToolExecutionContext): Promise<ToolExecutionResult<FileWriteResult>>;
|
|
33
34
|
/**
|
|
34
35
|
* Validate input
|
|
35
36
|
*/
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
errors
|
|
37
|
+
validateArgs(input: Record<string, any>): {
|
|
38
|
+
isValid: boolean;
|
|
39
|
+
errors?: any[];
|
|
39
40
|
};
|
|
40
|
-
/**
|
|
41
|
-
* Get JSON schema for tool
|
|
42
|
-
*/
|
|
43
|
-
getSchema(): any;
|
|
44
41
|
}
|
|
45
42
|
//# sourceMappingURL=fileWrite.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileWrite.d.ts","sourceRoot":"","sources":["../../src/tools/fileWrite.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"fileWrite.d.ts","sourceRoot":"","sources":["../../src/tools/fileWrite.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC3G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD;;GAEG;AACH,qBAAa,aAAc,YAAW,KAAK;IAwC7B,OAAO,CAAC,YAAY;IAvChC,SAAgB,EAAE,uBAAuB;IACzC,qDAAqD;IACrD,SAAgB,IAAI,gBAAgB;IACpC,SAAgB,WAAW,gBAAgB;IAC3C,SAAgB,WAAW,gDAAgD;IAC3E,SAAgB,QAAQ,YAAY;IACpC,SAAgB,cAAc,QAAQ;IAEtC,SAAgB,WAAW,EAAE,gBAAgB,CA6B3C;gBAEkB,YAAY,EAAE,YAAY;IAE9C;;OAEG;IACG,OAAO,CACX,KAAK,EAAE;QACP,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,CAAC,EAAE,cAAc,CAAC;QAC1B,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,UAAU,CAAC,EAAE,OAAO,CAAC;KACpB,EACD,QAAQ,EAAE,oBAAoB,GAC7B,OAAO,CAAC,mBAAmB,CAAC,eAAe,CAAC,CAAC;IAsBhD;;OAEG;IACH,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,GAAG,EAAE,CAAA;KAAE;CAe/E"}
|
package/dist/tools/fileWrite.js
CHANGED
|
@@ -9,17 +9,58 @@
|
|
|
9
9
|
*/
|
|
10
10
|
export class FileWriteTool {
|
|
11
11
|
shellService;
|
|
12
|
-
id = '
|
|
13
|
-
name
|
|
14
|
-
|
|
12
|
+
id = 'cli-file-write-v1';
|
|
13
|
+
/** Tool call name used by the LLM / ToolExecutor. */
|
|
14
|
+
name = 'file_write';
|
|
15
|
+
displayName = 'Write File';
|
|
16
|
+
description = 'Write or append content to a file on disk.';
|
|
17
|
+
category = 'system';
|
|
18
|
+
hasSideEffects = true;
|
|
19
|
+
inputSchema = {
|
|
20
|
+
type: 'object',
|
|
21
|
+
required: ['path', 'content'],
|
|
22
|
+
properties: {
|
|
23
|
+
path: {
|
|
24
|
+
type: 'string',
|
|
25
|
+
description: 'File path to write',
|
|
26
|
+
},
|
|
27
|
+
content: {
|
|
28
|
+
type: 'string',
|
|
29
|
+
description: 'Content to write',
|
|
30
|
+
},
|
|
31
|
+
encoding: {
|
|
32
|
+
type: 'string',
|
|
33
|
+
default: 'utf-8',
|
|
34
|
+
description: 'File encoding',
|
|
35
|
+
},
|
|
36
|
+
append: {
|
|
37
|
+
type: 'boolean',
|
|
38
|
+
default: false,
|
|
39
|
+
description: 'Append to file instead of overwriting',
|
|
40
|
+
},
|
|
41
|
+
createDirs: {
|
|
42
|
+
type: 'boolean',
|
|
43
|
+
default: true,
|
|
44
|
+
description: 'Create parent directories if needed',
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
additionalProperties: false,
|
|
48
|
+
};
|
|
15
49
|
constructor(shellService) {
|
|
16
50
|
this.shellService = shellService;
|
|
17
51
|
}
|
|
18
52
|
/**
|
|
19
53
|
* Write file
|
|
20
54
|
*/
|
|
21
|
-
async execute(input) {
|
|
55
|
+
async execute(input, _context) {
|
|
22
56
|
try {
|
|
57
|
+
// Redirect PDF writes to create_pdf tool
|
|
58
|
+
if (input.path && /\.pdf$/i.test(input.path)) {
|
|
59
|
+
return {
|
|
60
|
+
success: false,
|
|
61
|
+
error: 'Cannot write PDF files with file_write — this produces a plain text file with a .pdf extension. Use the create_pdf tool instead to generate a real PDF document.',
|
|
62
|
+
};
|
|
63
|
+
}
|
|
23
64
|
const result = await this.shellService.writeFile(input.path, input.content, {
|
|
24
65
|
encoding: input.encoding,
|
|
25
66
|
append: input.append,
|
|
@@ -34,7 +75,7 @@ export class FileWriteTool {
|
|
|
34
75
|
/**
|
|
35
76
|
* Validate input
|
|
36
77
|
*/
|
|
37
|
-
|
|
78
|
+
validateArgs(input) {
|
|
38
79
|
const errors = [];
|
|
39
80
|
if (!input.path) {
|
|
40
81
|
errors.push('Path is required');
|
|
@@ -45,41 +86,7 @@ export class FileWriteTool {
|
|
|
45
86
|
if (input.content === undefined || input.content === null) {
|
|
46
87
|
errors.push('Content is required');
|
|
47
88
|
}
|
|
48
|
-
return
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Get JSON schema for tool
|
|
52
|
-
*/
|
|
53
|
-
getSchema() {
|
|
54
|
-
return {
|
|
55
|
-
type: 'object',
|
|
56
|
-
required: ['path', 'content'],
|
|
57
|
-
properties: {
|
|
58
|
-
path: {
|
|
59
|
-
type: 'string',
|
|
60
|
-
description: 'File path to write',
|
|
61
|
-
},
|
|
62
|
-
content: {
|
|
63
|
-
type: 'string',
|
|
64
|
-
description: 'Content to write',
|
|
65
|
-
},
|
|
66
|
-
encoding: {
|
|
67
|
-
type: 'string',
|
|
68
|
-
default: 'utf-8',
|
|
69
|
-
description: 'File encoding',
|
|
70
|
-
},
|
|
71
|
-
append: {
|
|
72
|
-
type: 'boolean',
|
|
73
|
-
default: false,
|
|
74
|
-
description: 'Append to file instead of overwriting',
|
|
75
|
-
},
|
|
76
|
-
createDirs: {
|
|
77
|
-
type: 'boolean',
|
|
78
|
-
default: true,
|
|
79
|
-
description: 'Create parent directories if needed',
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
};
|
|
89
|
+
return errors.length === 0 ? { isValid: true } : { isValid: false, errors };
|
|
83
90
|
}
|
|
84
91
|
}
|
|
85
92
|
//# sourceMappingURL=fileWrite.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileWrite.js","sourceRoot":"","sources":["../../src/tools/fileWrite.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;GAEG;AACH,MAAM,OAAO,aAAa;
|
|
1
|
+
{"version":3,"file":"fileWrite.js","sourceRoot":"","sources":["../../src/tools/fileWrite.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;GAEG;AACH,MAAM,OAAO,aAAa;IAwCJ;IAvCJ,EAAE,GAAG,mBAAmB,CAAC;IACzC,qDAAqD;IACrC,IAAI,GAAG,YAAY,CAAC;IACpB,WAAW,GAAG,YAAY,CAAC;IAC3B,WAAW,GAAG,4CAA4C,CAAC;IAC3D,QAAQ,GAAG,QAAQ,CAAC;IACpB,cAAc,GAAG,IAAI,CAAC;IAEtB,WAAW,GAAqB;QAC9C,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC;QAC7B,UAAU,EAAE;YACV,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,oBAAoB;aAClC;YACD,OAAO,EAAE;gB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CAAC,KAA0B;QACrC,MAAM,MAAM,GAAa,EAAE,CAAC;QAE5B,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;YAChB,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAClC,CAAC;aAAM,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC1C,MAAM,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;QACvC,CAAC;QAED,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS,IAAI,KAAK,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;YAC1D,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;QACrC,CAAC;QAED,OAAO,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAC9E,CAAC;CACF"}
|
package/dist/tools/listDir.d.ts
CHANGED
|
@@ -4,17 +4,22 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @module @framers/agentos-ext-cli-executor
|
|
6
6
|
*/
|
|
7
|
-
import type { ITool } from '@framers/agentos';
|
|
8
|
-
import type { ShellService } from '../services/shellService';
|
|
9
|
-
import type { ListDirectoryResult } from '../types';
|
|
7
|
+
import type { ITool, JSONSchemaObject, ToolExecutionContext, ToolExecutionResult } from '@framers/agentos';
|
|
8
|
+
import type { ShellService } from '../services/shellService.js';
|
|
9
|
+
import type { ListDirectoryResult } from '../types.js';
|
|
10
10
|
/**
|
|
11
11
|
* Tool for listing directories
|
|
12
12
|
*/
|
|
13
13
|
export declare class ListDirectoryTool implements ITool {
|
|
14
14
|
private shellService;
|
|
15
|
-
readonly id = "
|
|
16
|
-
|
|
17
|
-
readonly
|
|
15
|
+
readonly id = "cli-list-directory-v1";
|
|
16
|
+
/** Tool call name used by the LLM / ToolExecutor. */
|
|
17
|
+
readonly name = "list_directory";
|
|
18
|
+
readonly displayName = "List Directory";
|
|
19
|
+
readonly description = "List files and directories within a path.";
|
|
20
|
+
readonly category = "system";
|
|
21
|
+
readonly hasSideEffects = false;
|
|
22
|
+
readonly inputSchema: JSONSchemaObject;
|
|
18
23
|
constructor(shellService: ShellService);
|
|
19
24
|
/**
|
|
20
25
|
* List directory
|
|
@@ -26,21 +31,13 @@ export declare class ListDirectoryTool implements ITool {
|
|
|
26
31
|
maxDepth?: number;
|
|
27
32
|
pattern?: string;
|
|
28
33
|
includeStats?: boolean;
|
|
29
|
-
}): Promise<
|
|
30
|
-
success: boolean;
|
|
31
|
-
output?: ListDirectoryResult;
|
|
32
|
-
error?: string;
|
|
33
|
-
}>;
|
|
34
|
+
}, _context: ToolExecutionContext): Promise<ToolExecutionResult<ListDirectoryResult>>;
|
|
34
35
|
/**
|
|
35
36
|
* Validate input
|
|
36
37
|
*/
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
errors
|
|
38
|
+
validateArgs(input: Record<string, any>): {
|
|
39
|
+
isValid: boolean;
|
|
40
|
+
errors?: any[];
|
|
40
41
|
};
|
|
41
|
-
/**
|
|
42
|
-
* Get JSON schema for tool
|
|
43
|
-
*/
|
|
44
|
-
getSchema(): any;
|
|
45
42
|
}
|
|
46
43
|
//# sourceMappingURL=listDir.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listDir.d.ts","sourceRoot":"","sources":["../../src/tools/listDir.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"listDir.d.ts","sourceRoot":"","sources":["../../src/tools/listDir.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC3G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD;;GAEG;AACH,qBAAa,iBAAkB,YAAW,KAAK;IA6CjC,OAAO,CAAC,YAAY;IA5ChC,SAAgB,EAAE,2BAA2B;IAC7C,qDAAqD;IACrD,SAAgB,IAAI,oBAAoB;IACxC,SAAgB,WAAW,oBAAoB;IAC/C,SAAgB,WAAW,+CAA+C;IAC1E,SAAgB,QAAQ,YAAY;IACpC,SAAgB,cAAc,SAAS;IAEvC,SAAgB,WAAW,EAAE,gBAAgB,CAkC3C;gBAEkB,YAAY,EAAE,YAAY;IAE9C;;OAEG;IACG,OAAO,CACX,KAAK,EAAE;QACP,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,YAAY,CAAC,EAAE,OAAO,CAAC;KACtB,EACD,QAAQ,EAAE,oBAAoB,GAC7B,OAAO,CAAC,mBAAmB,CAAC,mBAAmB,CAAC,CAAC;IAgBpD;;OAEG;IACH,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,GAAG,EAAE,CAAA;KAAE;CAW/E"}
|
package/dist/tools/listDir.js
CHANGED
|
@@ -9,16 +9,55 @@
|
|
|
9
9
|
*/
|
|
10
10
|
export class ListDirectoryTool {
|
|
11
11
|
shellService;
|
|
12
|
-
id = '
|
|
13
|
-
name
|
|
14
|
-
|
|
12
|
+
id = 'cli-list-directory-v1';
|
|
13
|
+
/** Tool call name used by the LLM / ToolExecutor. */
|
|
14
|
+
name = 'list_directory';
|
|
15
|
+
displayName = 'List Directory';
|
|
16
|
+
description = 'List files and directories within a path.';
|
|
17
|
+
category = 'system';
|
|
18
|
+
hasSideEffects = false;
|
|
19
|
+
inputSchema = {
|
|
20
|
+
type: 'object',
|
|
21
|
+
required: ['path'],
|
|
22
|
+
properties: {
|
|
23
|
+
path: {
|
|
24
|
+
type: 'string',
|
|
25
|
+
description: 'Directory path to list',
|
|
26
|
+
},
|
|
27
|
+
showHidden: {
|
|
28
|
+
type: 'boolean',
|
|
29
|
+
default: false,
|
|
30
|
+
description: 'Include hidden files',
|
|
31
|
+
},
|
|
32
|
+
recursive: {
|
|
33
|
+
type: 'boolean',
|
|
34
|
+
default: false,
|
|
35
|
+
description: 'Recursive listing',
|
|
36
|
+
},
|
|
37
|
+
maxDepth: {
|
|
38
|
+
type: 'number',
|
|
39
|
+
default: 10,
|
|
40
|
+
description: 'Maximum depth for recursive listing',
|
|
41
|
+
},
|
|
42
|
+
pattern: {
|
|
43
|
+
type: 'string',
|
|
44
|
+
description: 'Filter pattern (glob)',
|
|
45
|
+
},
|
|
46
|
+
includeStats: {
|
|
47
|
+
type: 'boolean',
|
|
48
|
+
default: false,
|
|
49
|
+
description: 'Include file stats (size, dates)',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
additionalProperties: false,
|
|
53
|
+
};
|
|
15
54
|
constructor(shellService) {
|
|
16
55
|
this.shellService = shellService;
|
|
17
56
|
}
|
|
18
57
|
/**
|
|
19
58
|
* List directory
|
|
20
59
|
*/
|
|
21
|
-
async execute(input) {
|
|
60
|
+
async execute(input, _context) {
|
|
22
61
|
try {
|
|
23
62
|
const result = await this.shellService.listDirectory(input.path, {
|
|
24
63
|
showHidden: input.showHidden,
|
|
@@ -36,7 +75,7 @@ export class ListDirectoryTool {
|
|
|
36
75
|
/**
|
|
37
76
|
* Validate input
|
|
38
77
|
*/
|
|
39
|
-
|
|
78
|
+
validateArgs(input) {
|
|
40
79
|
const errors = [];
|
|
41
80
|
if (!input.path) {
|
|
42
81
|
errors.push('Path is required');
|
|
@@ -44,46 +83,7 @@ export class ListDirectoryTool {
|
|
|
44
83
|
else if (typeof input.path !== 'string') {
|
|
45
84
|
errors.push('Path must be a string');
|
|
46
85
|
}
|
|
47
|
-
return
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Get JSON schema for tool
|
|
51
|
-
*/
|
|
52
|
-
getSchema() {
|
|
53
|
-
return {
|
|
54
|
-
type: 'object',
|
|
55
|
-
required: ['path'],
|
|
56
|
-
properties: {
|
|
57
|
-
path: {
|
|
58
|
-
type: 'string',
|
|
59
|
-
description: 'Directory path to list',
|
|
60
|
-
},
|
|
61
|
-
showHidden: {
|
|
62
|
-
type: 'boolean',
|
|
63
|
-
default: false,
|
|
64
|
-
description: 'Include hidden files',
|
|
65
|
-
},
|
|
66
|
-
recursive: {
|
|
67
|
-
type: 'boolean',
|
|
68
|
-
default: false,
|
|
69
|
-
description: 'Recursive listing',
|
|
70
|
-
},
|
|
71
|
-
maxDepth: {
|
|
72
|
-
type: 'number',
|
|
73
|
-
default: 10,
|
|
74
|
-
description: 'Maximum depth for recursive listing',
|
|
75
|
-
},
|
|
76
|
-
pattern: {
|
|
77
|
-
type: 'string',
|
|
78
|
-
description: 'Filter pattern (glob)',
|
|
79
|
-
},
|
|
80
|
-
includeStats: {
|
|
81
|
-
type: 'boolean',
|
|
82
|
-
default: false,
|
|
83
|
-
description: 'Include file stats (size, dates)',
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
};
|
|
86
|
+
return errors.length === 0 ? { isValid: true } : { isValid: false, errors };
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
//# sourceMappingURL=listDir.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listDir.js","sourceRoot":"","sources":["../../src/tools/listDir.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;GAEG;AACH,MAAM,OAAO,iBAAiB;
|
|
1
|
+
{"version":3,"file":"listDir.js","sourceRoot":"","sources":["../../src/tools/listDir.ts"],"names":[],"mappings":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AAU;gBAC5B,SAAS,EAAE,KAAK,CAAC,SAAS;gBAC1B,QAAQ,EAAE,KAAK,CAAC,QAAQ;gBACxB,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,YAAY,EAAE,KAAK,CAAC,YAAY;aACjC,CAAC,CAAC;YAEH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;QAC3C,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;QAClD,CAAC;IACH,CAAC;IAED;;OAEG;IACH,YAAY,CAAC,KAA0B;QACrC,MAAM,MAAM,GAAa,EAAE,CAAC;QAE5B,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;YAChB,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAClC,CAAC;aAAM,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC1C,MAAM,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;QACvC,CAAC;QAED,OAAO,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAC9E,CAAC;CACF"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read Document Tool
|
|
3
|
+
* Extract text content from binary document formats (xlsx, csv, docx, pdf).
|
|
4
|
+
*
|
|
5
|
+
* @module @framers/agentos-ext-cli-executor
|
|
6
|
+
*/
|
|
7
|
+
import type { ITool, JSONSchemaObject, ToolExecutionContext, ToolExecutionResult } from '@framers/agentos';
|
|
8
|
+
import type { ShellService } from '../services/shellService.js';
|
|
9
|
+
import type { DocumentReadResult } from '../types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Tool for reading binary document formats
|
|
12
|
+
*/
|
|
13
|
+
export declare class ReadDocumentTool implements ITool {
|
|
14
|
+
private shellService;
|
|
15
|
+
readonly id = "cli-read-document-v1";
|
|
16
|
+
/** Tool call name used by the LLM / ToolExecutor. */
|
|
17
|
+
readonly name = "read_document";
|
|
18
|
+
readonly displayName = "Read Document";
|
|
19
|
+
readonly description: string;
|
|
20
|
+
readonly category = "system";
|
|
21
|
+
readonly hasSideEffects = false;
|
|
22
|
+
readonly inputSchema: JSONSchemaObject;
|
|
23
|
+
constructor(shellService: ShellService);
|
|
24
|
+
/**
|
|
25
|
+
* Read and parse a document
|
|
26
|
+
*/
|
|
27
|
+
execute(input: {
|
|
28
|
+
path: string;
|
|
29
|
+
format?: string;
|
|
30
|
+
sheet?: string;
|
|
31
|
+
maxRows?: number;
|
|
32
|
+
}, _context: ToolExecutionContext): Promise<ToolExecutionResult<DocumentReadResult>>;
|
|
33
|
+
/**
|
|
34
|
+
* Validate input
|
|
35
|
+
*/
|
|
36
|
+
validateArgs(input: Record<string, any>): {
|
|
37
|
+
isValid: boolean;
|
|
38
|
+
errors?: any[];
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=readDocument.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readDocument.d.ts","sourceRoot":"","sources":["../../src/tools/readDocument.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC3G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AA4JtD;;GAEG;AACH,qBAAa,gBAAiB,YAAW,KAAK;IAwChC,OAAO,CAAC,YAAY;IAvChC,SAAgB,EAAE,0BAA0B;IAC5C,qDAAqD;IACrD,SAAgB,IAAI,mBAAmB;IACvC,SAAgB,WAAW,mBAAmB;IAC9C,SAAgB,WAAW,SAK+C;IAC1E,SAAgB,QAAQ,YAAY;IACpC,SAAgB,cAAc,SAAS;IAEvC,SAAgB,WAAW,EAAE,gBAAgB,CAwB3C;gBAEkB,YAAY,EAAE,YAAY;IAE9C;;OAEG;IACG,OAAO,CACX,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,EACD,QAAQ,EAAE,oBAAoB,GAC7B,OAAO,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,CAAC;IAgEnD;;OAEG;IACH,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,GAAG,EAAE,CAAA;KAAE;CAe/E"}
|