From 017bd7a9589e892c9e67cd561cf3da8536109730 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Fri, 24 Apr 2026 22:35:02 +0000 Subject: [PATCH 1/6] Changes Co-authored-by: domfelipe <53182096+domfelipe@users.noreply.github.com> --- supabase/functions/provision-agent/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/supabase/functions/provision-agent/index.ts b/supabase/functions/provision-agent/index.ts index d23ca1a..9267811 100644 --- a/supabase/functions/provision-agent/index.ts +++ b/supabase/functions/provision-agent/index.ts @@ -12,7 +12,6 @@ import { deleteTelegramWebhook, getServiceContext, upsertRailwayVariableCollection, - HERMES_START_COMMAND, } from "../_shared/railway.ts"; interface RequestBody { From 2c31d16d8dc1e638f8cd7ca87e818c5d043c651d Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Fri, 24 Apr 2026 22:35:29 +0000 Subject: [PATCH 2/6] Changes Co-authored-by: domfelipe <53182096+domfelipe@users.noreply.github.com> --- supabase/functions/provision-agent/index.ts | 43 ++++++++++----------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/supabase/functions/provision-agent/index.ts b/supabase/functions/provision-agent/index.ts index 9267811..3e5f7a3 100644 --- a/supabase/functions/provision-agent/index.ts +++ b/supabase/functions/provision-agent/index.ts @@ -205,34 +205,32 @@ Deno.serve(async (req) => { console.warn("[provision-agent] deleteTelegramWebhook failed (continuing):", String(e)); } - // 6) Montar variáveis de ambiente do container - const hasChatId = !!agent.telegram_user_chat_id; - const defaultSoul = `Você se chama ${agentName}. Você é um assistente pessoal de IA criado pela DOMCO para ${fullName}. Você é proativo, direto e fala sempre em português brasileiro. Você ajuda ${firstName} a ser mais produtivo — gerenciando emails, agenda, tarefas e automatizando o que puder. Seja conciso nas respostas via Telegram. Nunca se identifique como Hermes ou como produto da Nous Research — você é Mika.`; - const soulContent = body.soul_content?.trim() || defaultSoul; - - const defaultModel = isPro - ? "openrouter/google/gemma-4-31b-it" - : "openrouter/google/gemma-4-27b-a4b-it"; - const model = body.model || defaultModel; + // 6) Montar variáveis de ambiente do container (imagem custom já contém SOUL.md) const sttProvider = body.stt_provider || "local"; const ttsProvider = body.tts_provider || "disabled"; + const hasChatId = !!agent.telegram_user_chat_id; + const chatIdStr = hasChatId ? String(agent.telegram_user_chat_id) : ""; const envVars: Record = { - TELEGRAM_BOT_TOKEN: telegramBotToken, - TELEGRAM_ALLOWED_USERS: hasChatId ? String(agent.telegram_user_chat_id) : "", - TELEGRAM_HOME_CHANNEL: hasChatId ? String(agent.telegram_user_chat_id) : "", - GATEWAY_ALLOW_ALL_USERS: hasChatId ? "false" : "true", - HERMES_SOUL_MD: soulContent, - HERMES_SOUL_OVERRIDE: soulContent, - HERMES_TTS_PROVIDER: ttsProvider, + HERMES_HOME: "/opt/data/.hermes", + API_SERVER_ENABLED: "true", + API_SERVER_KEY: Deno.env.get("HERMES_API_SERVER_KEY") ?? "", + GATEWAY_ALLOW_ALL_USERS: "false", HERMES_STT_PROVIDER: sttProvider, - OPENROUTER_API_KEY, - HERMES_MODEL: model, - HERMES_FALLBACK_MODEL: "openrouter/google/gemma-4-31b-it", - API_SERVER_ENABLED: "false", - HERMES_HOME: "/opt/data", + HERMES_TTS_PROVIDER: ttsProvider, + OLLAMA_API_KEY: Deno.env.get("OLLAMA_API_KEY") ?? "", + PORT: "8642", + TELEGRAM_ALLOWED_USERS: chatIdStr, + TELEGRAM_BOT_TOKEN: telegramBotToken, + TELEGRAM_HOME_CHANNEL: chatIdStr, }; + // Manter campos derivados para persistir em model_config + const agentNameFinal = agentName; + const modelFinal = isPro + ? "openrouter/google/gemma-4-31b-it" + : "openrouter/google/gemma-4-27b-a4b-it"; + // 7) Criar serviço no Railway const serviceName = `mika-${agent.uuid_tenant.replace(/-/g, "").slice(0, 8)}`; console.log(`[provision-agent] criando serviço Railway: ${serviceName}`); @@ -250,8 +248,7 @@ Deno.serve(async (req) => { token: RAILWAY_API_TOKEN, serviceId: railwayServiceId, environmentId: pool.railway_environment_id, - image: "nousresearch/hermes-agent:latest", - startCommand: HERMES_START_COMMAND, + image: "ghcr.io/domfelipe/hermes-agent-custom:latest", variables: envVars, }); console.log(`[provision-agent] serviço configurado com ${Object.keys(envVars).length} env vars`); From 6a94ccd943e45140c697be5367afc31b4ffe095b Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Fri, 24 Apr 2026 22:35:44 +0000 Subject: [PATCH 3/6] Changes Co-authored-by: domfelipe <53182096+domfelipe@users.noreply.github.com> --- supabase/functions/provision-agent/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/supabase/functions/provision-agent/index.ts b/supabase/functions/provision-agent/index.ts index 3e5f7a3..06f50e1 100644 --- a/supabase/functions/provision-agent/index.ts +++ b/supabase/functions/provision-agent/index.ts @@ -281,10 +281,10 @@ Deno.serve(async (req) => { railway_service_id: railwayServiceId, vps_pool_id: pool.id, model_config: { - provider: model, + provider: modelFinal, stt: sttProvider, tts: ttsProvider, - agent_name: agentName, + agent_name: agentNameFinal, }, }) .eq("id", agent.id); From 8c2036d2d9fccb03ce1f24a362ecbbf3ade9f945 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Fri, 24 Apr 2026 22:35:56 +0000 Subject: [PATCH 4/6] Changes Co-authored-by: domfelipe <53182096+domfelipe@users.noreply.github.com> --- supabase/functions/provision-agent/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/supabase/functions/provision-agent/index.ts b/supabase/functions/provision-agent/index.ts index 06f50e1..4ba2368 100644 --- a/supabase/functions/provision-agent/index.ts +++ b/supabase/functions/provision-agent/index.ts @@ -26,7 +26,7 @@ interface RequestBody { const SUPABASE_URL = Deno.env.get("SUPABASE_URL")!; const SUPABASE_SERVICE_ROLE_KEY = Deno.env.get("SUPABASE_SERVICE_ROLE_KEY")!; const RAILWAY_API_TOKEN = Deno.env.get("RAILWAY_API_TOKEN"); -const OPENROUTER_API_KEY = Deno.env.get("OPENROUTER_API_KEY") ?? ""; + const ADMIN_TELEGRAM_BOT_TOKEN = Deno.env.get("ADMIN_TELEGRAM_BOT_TOKEN"); const ADMIN_TELEGRAM_CHAT_ID = Deno.env.get("ADMIN_TELEGRAM_CHAT_ID"); From b08c92c8a3f0ccbaff2482fcb70019633e173019 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Fri, 24 Apr 2026 22:36:10 +0000 Subject: [PATCH 5/6] Changes Co-authored-by: domfelipe <53182096+domfelipe@users.noreply.github.com> --- supabase/functions/provision-agent/index.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/supabase/functions/provision-agent/index.ts b/supabase/functions/provision-agent/index.ts index 4ba2368..09792d0 100644 --- a/supabase/functions/provision-agent/index.ts +++ b/supabase/functions/provision-agent/index.ts @@ -57,10 +57,6 @@ Deno.serve(async (req) => { return jsonResponse(500, { error: "RAILWAY_API_TOKEN not configured" }); } - if (!OPENROUTER_API_KEY) { - return jsonResponse(500, { error: "OPENROUTER_API_KEY not configured" }); - } - let body: RequestBody; try { body = await req.json(); From 1093d789bffe1bb984a254c260c4992d7ae6f9d7 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Fri, 24 Apr 2026 22:36:28 +0000 Subject: [PATCH 6/6] Changes Co-authored-by: domfelipe <53182096+domfelipe@users.noreply.github.com> --- supabase/functions/update-agent-config/index.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/supabase/functions/update-agent-config/index.ts b/supabase/functions/update-agent-config/index.ts index f0637dc..b888bce 100644 --- a/supabase/functions/update-agent-config/index.ts +++ b/supabase/functions/update-agent-config/index.ts @@ -101,11 +101,12 @@ Deno.serve(async (req) => { return jsonResponse(500, { error: "failed to resolve railway project/environment" }); } - // 4) Upsert variáveis + // 4) Upsert variáveis (SOUL.md agora vive na imagem Docker — não sobrescrever via env) const variables: Record = { - HERMES_SOUL_OVERRIDE: body.soul_content, - HERMES_MODEL: body.model, - HERMES_FALLBACK_MODEL: "openrouter/google/gemma-4-31b-it", + OLLAMA_API_KEY: Deno.env.get("OLLAMA_API_KEY") ?? "", + TELEGRAM_BOT_TOKEN: Deno.env.get("TELEGRAM_BOT_TOKEN") ?? "", + TELEGRAM_ALLOWED_USERS: Deno.env.get("TELEGRAM_ALLOWED_USERS") ?? "", + TELEGRAM_HOME_CHANNEL: Deno.env.get("TELEGRAM_HOME_CHANNEL") ?? "", HERMES_STT_PROVIDER: body.stt_provider || "local", HERMES_TTS_PROVIDER: body.tts_provider || "disabled", };