@ericnunes/frame-code-cli 0.0.1 → 0.0.3

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 (72) hide show
  1. package/dist/agent-runtime/index.js +0 -1
  2. package/dist/agent-runtime/registry/AgentRegistry.js +108 -36
  3. package/dist/agent-runtime/registry/index.js +1 -11
  4. package/dist/app/cli.js +3 -5
  5. package/dist/cli/commands/autonomous.js +8 -6
  6. package/dist/cli/commands/interactive.js +63 -146
  7. package/dist/cli/commands/memory.js +247 -76
  8. package/dist/content/agents/README.md +36 -32
  9. package/dist/content/agents/architect.md +1 -1
  10. package/dist/content/agents/builder.md +11 -15
  11. package/dist/content/agents/code-agent.md +1 -95
  12. package/dist/index.js +0 -6
  13. package/dist/infrastructure/config/config.js +40 -0
  14. package/dist/tools/index.js +0 -2
  15. package/dist/tools/registry/ToolInitializer.js +15 -55
  16. package/dist/tools/registry/index.js +1 -7
  17. package/package.json +11 -23
  18. package/dist/agent-runtime/AgentFacade.js +0 -33
  19. package/dist/agent-runtime/context/hooks/compressionHook.js +0 -56
  20. package/dist/agent-runtime/context/hooks/index.js +0 -5
  21. package/dist/agent-runtime/context/project-rules/loader.js +0 -72
  22. package/dist/agent-runtime/context/system-prompts/index.js +0 -5
  23. package/dist/agent-runtime/context/system-prompts/loader.js +0 -88
  24. package/dist/agent-runtime/flows/templates/ReactAgentFlow.js +0 -49
  25. package/dist/agent-runtime/registry/agentParser.js +0 -515
  26. package/dist/agent-runtime/registry/enums/agentType.enum.js +0 -8
  27. package/dist/agent-runtime/registry/interfaces/agentDependencies.interface.js +0 -2
  28. package/dist/agent-runtime/registry/interfaces/agentRegistry.interface.js +0 -2
  29. package/dist/app/bootstrap.js +0 -22
  30. package/dist/app/index.js +0 -9
  31. package/dist/cli/commands/index.js +0 -11
  32. package/dist/cli/commands/multi-agent.js +0 -131
  33. package/dist/cli/index.js +0 -18
  34. package/dist/cli/input/images/imageInput.js +0 -77
  35. package/dist/cli/input/images/readImageAttachment.js +0 -56
  36. package/dist/cli/input/index.js +0 -14
  37. package/dist/infrastructure/compression/CompressionManager.js +0 -315
  38. package/dist/infrastructure/compression/LLMCompressionService.js +0 -211
  39. package/dist/infrastructure/compression/index.js +0 -11
  40. package/dist/infrastructure/compression/promptBuilder.js +0 -132
  41. package/dist/infrastructure/config/agentConfig.interface.js +0 -2
  42. package/dist/infrastructure/config/agentConfig.js +0 -134
  43. package/dist/infrastructure/logging/index.js +0 -5
  44. package/dist/infrastructure/logging/logger.interface.js +0 -2
  45. package/dist/infrastructure/logging/raw-output-logger.js +0 -35
  46. package/dist/infrastructure/skills/index.js +0 -5
  47. package/dist/infrastructure/skills/loader.js +0 -104
  48. package/dist/infrastructure/telemetry/index.js +0 -9
  49. package/dist/infrastructure/telemetry/telemetry.interface.js +0 -2
  50. package/dist/infrastructure/telemetry/telemetryConfig.js +0 -30
  51. package/dist/infrastructure/telemetry/traceEventFormatter.js +0 -90
  52. package/dist/infrastructure/telemetry/traceSinkConsole.js +0 -17
  53. package/dist/scripts/_validate/telemetry-autonomous.js +0 -23
  54. package/dist/scripts/_validate/telemetry-multi-agent.js +0 -50
  55. package/dist/scripts/_validate/test-agents-md-dynamic-dir.js +0 -104
  56. package/dist/scripts/_validate/test-agents-md-injection.js +0 -125
  57. package/dist/scripts/_validate/test-agents-md-loader.js +0 -71
  58. package/dist/scripts/_validate/test-agents-md-priority.js +0 -121
  59. package/dist/scripts/_validate/test-chrome-mcp-agent.js +0 -89
  60. package/dist/tools/mcp/discoverer.js +0 -95
  61. package/dist/tools/mcp/index.js +0 -9
  62. package/dist/tools/mcp/loader.js +0 -36
  63. package/dist/tools/mcp/mcpConfig.interface.js +0 -2
  64. package/dist/tools/mcp/mcpMetadata.js +0 -2
  65. package/dist/tools/mcp/register.js +0 -269
  66. package/dist/tools/native/capabilities.js +0 -155
  67. package/dist/tools/native/file-outline.js +0 -301
  68. package/dist/tools/native/index.js +0 -20
  69. package/dist/tools/native/list-directory.js +0 -148
  70. package/dist/tools/native/read-image.js +0 -140
  71. package/dist/tools/registry/toolFilter.js +0 -52
  72. package/dist/tools/registry/toolRegistry.interface.js +0 -2
@@ -1,301 +0,0 @@
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.fileOutlineTool = void 0;
37
- const frame_agent_sdk_1 = require("@ericnunes/frame-agent-sdk");
38
- const fs = __importStar(require("fs"));
39
- const path = __importStar(require("path"));
40
- const typescript_estree_1 = require("@typescript-eslint/typescript-estree");
41
- const logger_1 = require("../../infrastructure/logging/logger");
42
- const SHOW_TOOL_LOGS_INLINE = (process.env.SHOW_TOOL_LOGS_INLINE || '').toLowerCase() === 'true';
43
- const toolLog = (...args) => {
44
- if (SHOW_TOOL_LOGS_INLINE) {
45
- const message = args.map(arg => typeof arg === 'object' ? JSON.stringify(arg) : String(arg)).join(' ');
46
- logger_1.logger.info(message);
47
- }
48
- };
49
- const errorLog = (...args) => {
50
- if (SHOW_TOOL_LOGS_INLINE) {
51
- const message = args.map(arg => typeof arg === 'object' ? JSON.stringify(arg) : String(arg)).join(' ');
52
- logger_1.logger.error(message);
53
- }
54
- };
55
- const TOOL_ID = '[file_outline]';
56
- class FileOutlineParams {
57
- }
58
- FileOutlineParams.schemaProperties = {
59
- filePath: 'string',
60
- };
61
- var SymbolType;
62
- (function (SymbolType) {
63
- SymbolType["CLASS"] = "class";
64
- SymbolType["INTERFACE"] = "interface";
65
- SymbolType["FUNCTION"] = "function";
66
- SymbolType["METHOD"] = "method";
67
- SymbolType["VARIABLE"] = "variable";
68
- SymbolType["ENUM"] = "enum";
69
- SymbolType["TYPE_ALIAS"] = "type_alias";
70
- })(SymbolType || (SymbolType = {}));
71
- exports.fileOutlineTool = new class extends frame_agent_sdk_1.ToolBase {
72
- constructor() {
73
- super(...arguments);
74
- this.name = 'file_outline';
75
- this.description = 'Extrai estrutura hierárquica de arquivos TypeScript/JavaScript (classes, interfaces, funções, métodos)';
76
- this.parameterSchema = FileOutlineParams;
77
- }
78
- validarParametros(params) {
79
- if (!params.filePath || params.filePath.trim() === '') {
80
- throw new Error('✗ Caminho do arquivo é obrigatório');
81
- }
82
- }
83
- extrairAssinaturaFuncao(node) {
84
- const nome = node.id?.name || node.key?.name || 'anonymous';
85
- const parametros = node.params?.map((param) => {
86
- if (param.type === 'Identifier') {
87
- return param.name;
88
- }
89
- if (param.type === 'AssignmentPattern') {
90
- return `${param.left.name} = ${this.extrairValorPadrao(param.right)}`;
91
- }
92
- return 'param';
93
- }).join(', ') || '';
94
- const tipoRetorno = node.returnType ? `: ${this.extrairTipo(node.returnType.typeAnnotation)}` : '';
95
- return `${nome}(${parametros})${tipoRetorno}`;
96
- }
97
- extrairValorPadrao(node) {
98
- if (node.type === 'Literal') {
99
- return node.raw || String(node.value);
100
- }
101
- if (node.type === 'Identifier') {
102
- return node.name;
103
- }
104
- return '...';
105
- }
106
- extrairTipo(node) {
107
- if (node.type === 'TSAnyKeyword')
108
- return 'any';
109
- if (node.type === 'TSStringKeyword')
110
- return 'string';
111
- if (node.type === 'TSNumberKeyword')
112
- return 'number';
113
- if (node.type === 'TSBooleanKeyword')
114
- return 'boolean';
115
- if (node.type === 'TSVoidKeyword')
116
- return 'void';
117
- if (node.type === 'TSTypeReference' && node.typeName) {
118
- return node.typeName.name;
119
- }
120
- return 'unknown';
121
- }
122
- extrairSimbolos(node, simbolos, nivel = 0) {
123
- if (!node || typeof node !== 'object')
124
- return;
125
- if (node.type === 'ClassDeclaration' && node.id) {
126
- const simbolo = {
127
- name: node.id.name,
128
- type: SymbolType.CLASS,
129
- line: node.loc.start.line,
130
- signature: `class ${node.id.name}`,
131
- children: []
132
- };
133
- if (node.body?.body) {
134
- node.body.body.forEach((member) => {
135
- if (member.type === 'MethodDefinition' && member.key) {
136
- const metodo = {
137
- name: member.key.name,
138
- type: SymbolType.METHOD,
139
- line: member.loc.start.line,
140
- signature: this.extrairAssinaturaFuncao(member)
141
- };
142
- simbolo.children?.push(metodo);
143
- }
144
- });
145
- }
146
- simbolos.push(simbolo);
147
- return;
148
- }
149
- if (node.type === 'TSInterfaceDeclaration' && node.id) {
150
- const simbolo = {
151
- name: node.id.name,
152
- type: SymbolType.INTERFACE,
153
- line: node.loc.start.line,
154
- signature: `interface ${node.id.name}`
155
- };
156
- simbolos.push(simbolo);
157
- return;
158
- }
159
- if (node.type === 'FunctionDeclaration' && node.id) {
160
- const simbolo = {
161
- name: node.id.name,
162
- type: SymbolType.FUNCTION,
163
- line: node.loc.start.line,
164
- signature: this.extrairAssinaturaFuncao(node)
165
- };
166
- simbolos.push(simbolo);
167
- return;
168
- }
169
- if ((node.type === 'VariableDeclaration') && node.declarations) {
170
- node.declarations.forEach((decl) => {
171
- if (decl.id && decl.init?.type === 'FunctionExpression' || decl.init?.type === 'ArrowFunctionExpression') {
172
- const simbolo = {
173
- name: decl.id.name,
174
- type: SymbolType.FUNCTION,
175
- line: node.loc.start.line,
176
- signature: this.extrairAssinaturaFuncao(decl.init)
177
- };
178
- simbolos.push(simbolo);
179
- }
180
- });
181
- return;
182
- }
183
- if (node.type === 'TSEnumDeclaration' && node.id) {
184
- const simbolo = {
185
- name: node.id.name,
186
- type: SymbolType.ENUM,
187
- line: node.loc.start.line,
188
- signature: `enum ${node.id.name}`
189
- };
190
- simbolos.push(simbolo);
191
- return;
192
- }
193
- if (node.type === 'TSTypeAliasDeclaration' && node.id) {
194
- const simbolo = {
195
- name: node.id.name,
196
- type: SymbolType.TYPE_ALIAS,
197
- line: node.loc.start.line,
198
- signature: `type ${node.id.name}`
199
- };
200
- simbolos.push(simbolo);
201
- return;
202
- }
203
- for (const key in node) {
204
- if (node[key] && typeof node[key] === 'object') {
205
- if (Array.isArray(node[key])) {
206
- node[key].forEach((child) => this.extrairSimbolos(child, simbolos, nivel));
207
- }
208
- else {
209
- this.extrairSimbolos(node[key], simbolos, nivel);
210
- }
211
- }
212
- }
213
- }
214
- formatarEstrutura(simbolos, nivel = 0) {
215
- const indentacao = ' '.repeat(nivel);
216
- let resultado = '';
217
- simbolos.forEach((simbolo, index) => {
218
- const prefixo = nivel === 0 ? '📁 ' : '📄 ';
219
- resultado += `${indentacao}${prefixo}${simbolo.signature} (${simbolo.type}, linha ${simbolo.line})\n`;
220
- if (simbolo.children && simbolo.children.length > 0) {
221
- resultado += this.formatarEstrutura(simbolo.children, nivel + 1);
222
- }
223
- });
224
- return resultado;
225
- }
226
- async execute(params) {
227
- try {
228
- toolLog(`${TOOL_ID} ▶ Extraindo estrutura do arquivo`);
229
- toolLog(`${TOOL_ID} → Caminho: ${params.filePath}`);
230
- this.validarParametros(params);
231
- const resolvedPath = path.resolve(params.filePath);
232
- if (!fs.existsSync(resolvedPath)) {
233
- const message = `Arquivo não encontrado: ${resolvedPath}`;
234
- errorLog(`${TOOL_ID} ✗ ${message}`);
235
- return {
236
- success: false,
237
- message: `✗ ${message}`,
238
- symbolsCount: 0
239
- };
240
- }
241
- const stats = fs.statSync(resolvedPath);
242
- if (!stats.isFile()) {
243
- const message = `Caminho não é um arquivo: ${resolvedPath}`;
244
- errorLog(`${TOOL_ID} ✗ ${message}`);
245
- return {
246
- success: false,
247
- message: `✗ ${message}`,
248
- symbolsCount: 0
249
- };
250
- }
251
- const conteudo = fs.readFileSync(resolvedPath, 'utf-8');
252
- if (!conteudo.trim()) {
253
- const message = 'Arquivo vazio';
254
- toolLog(`${TOOL_ID} ⚠ ${message}`);
255
- return {
256
- success: true,
257
- message: `✓ ${message}`,
258
- outline: 'Arquivo vazio - nenhum símbolo encontrado',
259
- symbolsCount: 0
260
- };
261
- }
262
- const ast = (0, typescript_estree_1.parse)(conteudo, {
263
- loc: true,
264
- range: true,
265
- jsx: true
266
- });
267
- const simbolos = [];
268
- this.extrairSimbolos(ast, simbolos);
269
- if (simbolos.length === 0) {
270
- const message = 'Nenhum símbolo encontrado no arquivo';
271
- toolLog(`${TOOL_ID} ⚠ ${message}`);
272
- return {
273
- success: true,
274
- message: `✓ ${message}`,
275
- outline: 'Nenhum símbolo encontrado (arquivo pode conter apenas código de execução)',
276
- symbolsCount: 0
277
- };
278
- }
279
- const outline = this.formatarEstrutura(simbolos);
280
- const symbolsCount = simbolos.reduce((count, simbolo) => {
281
- return count + 1 + (simbolo.children?.length || 0);
282
- }, 0);
283
- toolLog(`${TOOL_ID} ✓ Estrutura extraída (${symbolsCount} símbolo(s))`);
284
- return {
285
- success: true,
286
- message: `✓ Estrutura extraída com ${symbolsCount} símbolo(s)`,
287
- outline,
288
- symbolsCount
289
- };
290
- }
291
- catch (error) {
292
- const message = error?.message ?? 'motivo desconhecido';
293
- errorLog(`${TOOL_ID} ✗ Erro ao extrair estrutura (${message})`);
294
- return {
295
- success: false,
296
- message: `✗ Erro ao extrair estrutura de ${params.filePath}: ${message}`,
297
- symbolsCount: 0
298
- };
299
- }
300
- }
301
- }();
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.readImageTool = exports.listDirectoryTool = exports.enableCapabilityTool = exports.listCapabilitiesTool = exports.fileOutlineTool = exports.sleepTool = exports.toDoIstTool = exports.fileCreateTool = exports.searchTool = exports.terminalTool = exports.fileEditTool = exports.fileReadTool = void 0;
4
- const frame_agent_sdk_1 = require("@ericnunes/frame-agent-sdk");
5
- exports.fileReadTool = frame_agent_sdk_1.FileReadTool;
6
- exports.fileEditTool = frame_agent_sdk_1.FileEditTool;
7
- exports.terminalTool = frame_agent_sdk_1.TerminalTool;
8
- exports.searchTool = frame_agent_sdk_1.SearchTool;
9
- exports.fileCreateTool = frame_agent_sdk_1.FileCreateTool;
10
- exports.toDoIstTool = new frame_agent_sdk_1.ToDoIstTool();
11
- exports.sleepTool = frame_agent_sdk_1.SleepTool;
12
- var file_outline_1 = require("./file-outline");
13
- Object.defineProperty(exports, "fileOutlineTool", { enumerable: true, get: function () { return file_outline_1.fileOutlineTool; } });
14
- var capabilities_1 = require("./capabilities");
15
- Object.defineProperty(exports, "listCapabilitiesTool", { enumerable: true, get: function () { return capabilities_1.listCapabilitiesTool; } });
16
- Object.defineProperty(exports, "enableCapabilityTool", { enumerable: true, get: function () { return capabilities_1.enableCapabilityTool; } });
17
- var list_directory_1 = require("./list-directory");
18
- Object.defineProperty(exports, "listDirectoryTool", { enumerable: true, get: function () { return list_directory_1.listDirectoryTool; } });
19
- var read_image_1 = require("./read-image");
20
- Object.defineProperty(exports, "readImageTool", { enumerable: true, get: function () { return read_image_1.readImageTool; } });
@@ -1,148 +0,0 @@
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.listDirectoryTool = void 0;
37
- const frame_agent_sdk_1 = require("@ericnunes/frame-agent-sdk");
38
- const fs_1 = require("fs");
39
- const path = __importStar(require("path"));
40
- class ListDirectoryParamsSchema {
41
- }
42
- ListDirectoryParamsSchema.schemaProperties = {
43
- 'directory?': 'string',
44
- 'recursive?': 'boolean',
45
- 'maxDepth?': 'number',
46
- 'includeFiles?': 'boolean',
47
- 'includeDirs?': 'boolean',
48
- 'maxEntries?': 'number',
49
- };
50
- async function existsReadable(targetPath) {
51
- try {
52
- await fs_1.promises.access(targetPath);
53
- return true;
54
- }
55
- catch {
56
- return false;
57
- }
58
- }
59
- async function walkDirectory(options) {
60
- const { root, relativeRoot, recursive, maxDepth, includeFiles, includeDirs, maxEntries, } = options;
61
- const entries = [];
62
- let truncated = false;
63
- const queue = [{ dir: root, depth: 0 }];
64
- while (queue.length > 0) {
65
- const current = queue.shift();
66
- if (!current)
67
- break;
68
- const { dir, depth } = current;
69
- if (entries.length >= maxEntries) {
70
- truncated = true;
71
- break;
72
- }
73
- let dirents;
74
- try {
75
- dirents = await fs_1.promises.readdir(dir, { withFileTypes: true });
76
- }
77
- catch {
78
- continue;
79
- }
80
- for (const dirent of dirents) {
81
- if (entries.length >= maxEntries) {
82
- truncated = true;
83
- break;
84
- }
85
- const absolutePath = path.join(dir, dirent.name);
86
- const relativePath = path.relative(relativeRoot, absolutePath).split(path.sep).join('/');
87
- if (dirent.isDirectory()) {
88
- if (includeDirs) {
89
- entries.push({ path: relativePath, type: 'dir' });
90
- }
91
- if (recursive && depth < maxDepth) {
92
- queue.push({ dir: absolutePath, depth: depth + 1 });
93
- }
94
- }
95
- else if (dirent.isFile()) {
96
- if (includeFiles) {
97
- entries.push({ path: relativePath, type: 'file' });
98
- }
99
- }
100
- }
101
- }
102
- return { entries, truncated };
103
- }
104
- exports.listDirectoryTool = new class extends frame_agent_sdk_1.ToolBase {
105
- constructor() {
106
- super(...arguments);
107
- this.name = 'list_directory';
108
- this.description = 'Lista arquivos e diretórios (read-only), com opção de recursão.';
109
- this.parameterSchema = ListDirectoryParamsSchema;
110
- }
111
- async execute(params) {
112
- const directory = params.directory?.trim() || '.';
113
- const recursive = params.recursive ?? false;
114
- const maxDepth = Number.isFinite(params.maxDepth) ? Math.max(0, Number(params.maxDepth)) : 2;
115
- const includeFiles = params.includeFiles ?? true;
116
- const includeDirs = params.includeDirs ?? true;
117
- const maxEntries = Number.isFinite(params.maxEntries) ? Math.max(1, Number(params.maxEntries)) : 500;
118
- const absolute = path.isAbsolute(directory) ? directory : path.resolve(process.cwd(), directory);
119
- const ok = await existsReadable(absolute);
120
- if (!ok) {
121
- return {
122
- success: false,
123
- message: `Diretório não encontrado ou sem permissão: ${directory}`,
124
- directory,
125
- entries: [],
126
- total: 0,
127
- truncated: false,
128
- };
129
- }
130
- const { entries, truncated } = await walkDirectory({
131
- root: absolute,
132
- relativeRoot: absolute,
133
- recursive,
134
- maxDepth,
135
- includeFiles,
136
- includeDirs,
137
- maxEntries,
138
- });
139
- return {
140
- success: true,
141
- message: truncated ? 'Lista truncada por limite de entradas' : 'OK',
142
- directory,
143
- entries,
144
- total: entries.length,
145
- truncated,
146
- };
147
- }
148
- }();
@@ -1,140 +0,0 @@
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.readImageTool = void 0;
37
- const frame_agent_sdk_1 = require("@ericnunes/frame-agent-sdk");
38
- const fs_1 = require("fs");
39
- const path = __importStar(require("path"));
40
- const crypto_1 = require("crypto");
41
- class ReadImageParamsSchema {
42
- }
43
- ReadImageParamsSchema.schemaProperties = {
44
- source: 'string',
45
- 'path?': 'string',
46
- 'region?': 'object',
47
- 'detail?': 'string',
48
- 'maxBytes?': 'number',
49
- };
50
- function inferMimeType(filePath) {
51
- const ext = path.extname(filePath).toLowerCase();
52
- switch (ext) {
53
- case '.png':
54
- return 'image/png';
55
- case '.jpg':
56
- case '.jpeg':
57
- return 'image/jpeg';
58
- case '.webp':
59
- return 'image/webp';
60
- case '.gif':
61
- return 'image/gif';
62
- case '.bmp':
63
- return 'image/bmp';
64
- default:
65
- return 'application/octet-stream';
66
- }
67
- }
68
- function toSafeAbsolutePath(inputPath) {
69
- return path.isAbsolute(inputPath) ? inputPath : path.resolve(process.cwd(), inputPath);
70
- }
71
- exports.readImageTool = new class extends frame_agent_sdk_1.ToolBase {
72
- constructor() {
73
- super(...arguments);
74
- this.name = 'read_image';
75
- this.description = 'Read an image from the host environment. This tool only returns a safe reference + metadata; the host attaches the image to the next LLM call.';
76
- this.parameterSchema = ReadImageParamsSchema;
77
- }
78
- async execute(params) {
79
- if (params.source !== 'path') {
80
- return {
81
- observation: `Unsupported source "${params.source}". Only "path" is supported in frame-code-cli.`,
82
- metadata: {
83
- readImage: {
84
- path: '',
85
- mimeType: '',
86
- bytes: 0,
87
- detail: params.detail,
88
- },
89
- },
90
- };
91
- }
92
- const rawPath = params.path?.trim();
93
- if (!rawPath) {
94
- return {
95
- observation: 'Missing required param: path (when source="path").',
96
- metadata: {
97
- readImage: {
98
- path: '',
99
- mimeType: '',
100
- bytes: 0,
101
- detail: params.detail,
102
- },
103
- },
104
- };
105
- }
106
- const absolutePath = toSafeAbsolutePath(rawPath);
107
- const stat = await fs_1.promises.stat(absolutePath);
108
- const bytes = stat.size;
109
- const maxBytes = Number.isFinite(params.maxBytes) ? Math.max(1, Number(params.maxBytes)) : 12 * 1024 * 1024;
110
- if (bytes > maxBytes) {
111
- return {
112
- observation: `Image too large (${bytes} bytes). Max allowed is ${maxBytes} bytes.`,
113
- metadata: {
114
- readImage: {
115
- path: absolutePath,
116
- mimeType: inferMimeType(absolutePath),
117
- bytes,
118
- detail: params.detail,
119
- },
120
- },
121
- };
122
- }
123
- const buffer = await fs_1.promises.readFile(absolutePath);
124
- const hash = (0, crypto_1.createHash)('sha256').update(buffer).digest('hex');
125
- const mimeType = inferMimeType(absolutePath);
126
- const detail = params.detail;
127
- return {
128
- observation: `Image loaded. path="${absolutePath}", mimeType="${mimeType}", bytes=${bytes}, sha256=${hash.slice(0, 12)}…`,
129
- metadata: {
130
- readImage: {
131
- path: absolutePath,
132
- mimeType,
133
- bytes,
134
- detail,
135
- hash,
136
- },
137
- },
138
- };
139
- }
140
- }();
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getToolFilterConfig = getToolFilterConfig;
4
- exports.shouldIncludeTool = shouldIncludeTool;
5
- exports.filterTools = filterTools;
6
- exports.filterToolsByPolicy = filterToolsByPolicy;
7
- function getToolFilterConfig() {
8
- const mode = process.env.AGENT_MODE === 'autonomous' ? 'autonomous' : 'interactive';
9
- return {
10
- mode,
11
- mcpToolsEnabled: process.env.MCP_TOOLS_ENABLED !== 'false',
12
- excludedTools: getExcludedToolsList(),
13
- allowAskUser: mode !== 'autonomous'
14
- };
15
- }
16
- function getExcludedToolsList() {
17
- const excluded = process.env.EXCLUDED_TOOLS || '';
18
- return excluded.split(',').map(tool => tool.trim()).filter(tool => tool.length > 0);
19
- }
20
- function shouldIncludeTool(tool, config) {
21
- if (config.excludedTools.includes(tool.name)) {
22
- return false;
23
- }
24
- if (!config.allowAskUser && (tool.name === 'ask_user' || tool.name === 'askUser')) {
25
- return false;
26
- }
27
- if (!config.mcpToolsEnabled && tool.name.startsWith('mcp_')) {
28
- return false;
29
- }
30
- if (tool.name === 'approval') {
31
- return false;
32
- }
33
- return true;
34
- }
35
- function filterTools(tools, config) {
36
- const filterConfig = config || getToolFilterConfig();
37
- return tools.filter(tool => shouldIncludeTool(tool, filterConfig));
38
- }
39
- function filterToolsByPolicy(tools, policy, config) {
40
- const base = filterTools(tools, config);
41
- const allow = policy?.allow?.filter(Boolean);
42
- const deny = policy?.deny?.filter(Boolean);
43
- if (allow && allow.length > 0) {
44
- const allowSet = new Set(allow);
45
- return base.filter((tool) => allowSet.has(tool.name));
46
- }
47
- if (deny && deny.length > 0) {
48
- const denySet = new Set(deny);
49
- return base.filter((tool) => !denySet.has(tool.name));
50
- }
51
- return base;
52
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });