Adicionar campo diretório de trabalho no modal de execução

- Campo execute-workdir no modal com valor pré-preenchido do agente
- Frontend envia workingDirectory na API de execução
- Backend aceita e aplica override de workingDirectory via metadata
- Pré-preenche com config do agente selecionado ao abrir modal
- Adiciona stopAll ao scheduler e limpa README
This commit is contained in:
Frederico Castro
2026-02-28 02:20:09 -03:00
parent 7a4ab2279d
commit fa47538a8f
8 changed files with 38 additions and 17 deletions

View File

@@ -180,8 +180,13 @@ export function executeTask(agentId, task, instructions, wsCallback, metadata =
effectiveInstructions += `\n\n<agentes_disponiveis>\n${agentList}\n</agentes_disponiveis>`;
}
const effectiveConfig = { ...agent.config };
if (metadata.workingDirectoryOverride) {
effectiveConfig.workingDirectory = metadata.workingDirectoryOverride;
}
const executionId = executor.execute(
agent.config,
effectiveConfig,
{ description: task, instructions: effectiveInstructions },
{
onData: (parsed, execId) => {

View File

@@ -160,6 +160,13 @@ export function restoreSchedules(executeFn) {
if (restored > 0) console.log(`[scheduler] ${restored} agendamento(s) restaurado(s)`);
}
export function stopAll() {
for (const [, entry] of schedules) {
entry.task.stop();
}
schedules.clear();
}
export function on(event, listener) {
emitter.on(event, listener);
}

View File

@@ -167,12 +167,14 @@ function buildContextFilesPrompt(contextFiles) {
router.post('/agents/:id/execute', (req, res) => {
try {
const { task, instructions, contextFiles } = req.body;
const { task, instructions, contextFiles, workingDirectory } = req.body;
if (!task) return res.status(400).json({ error: 'task é obrigatório' });
const clientId = req.headers['x-client-id'] || null;
const filesPrompt = buildContextFilesPrompt(contextFiles);
const fullTask = task + filesPrompt;
const executionId = manager.executeTask(req.params.id, fullTask, instructions, (msg) => wsCallback(msg, clientId));
const metadata = {};
if (workingDirectory) metadata.workingDirectoryOverride = workingDirectory;
const executionId = manager.executeTask(req.params.id, fullTask, instructions, (msg) => wsCallback(msg, clientId), metadata);
res.status(202).json({ executionId, status: 'started' });
} catch (err) {
const status = err.message.includes('não encontrado') ? 404 : 400;