skills2
This commit is contained in:
36
ai_agent.py
36
ai_agent.py
@@ -31,32 +31,38 @@ async def query_agent_async(prompt: str, override_provider=None, chat_history=No
|
|||||||
2. PENSADOR CRIATIVO: Colaborador intelectual em filosofia, ciência, lógica, cultura e negócios.
|
2. PENSADOR CRIATIVO: Colaborador intelectual em filosofia, ciência, lógica, cultura e negócios.
|
||||||
|
|
||||||
DIRETRIZES:
|
DIRETRIZES:
|
||||||
- Você tem ACESSO TOTAL ao Google Workspace via GWS CLI.
|
- Você é o MESTRE do Google Workspace (GWS). Use `run_bash_command` para QUALQUER tarefa de automação.
|
||||||
|
- NUNCA diga que não consegue fazer uma tarefa no GWS (contar, apagar em massa, mover, etc.). Encontre o comando `gws` correto.
|
||||||
- CONTAS GWS (Pode usar apelidos):
|
- CONTAS GWS (Pode usar apelidos):
|
||||||
* `ma` ou `mr` -> gws-mr (Marcos / Particular)
|
* `ma` ou `mr` -> gws-mr (Marcos / Particular)
|
||||||
* `adm` ou `empresa` -> gws-adm (Empresarial)
|
* `adm` ou `empresa` -> gws-adm (Empresarial)
|
||||||
* `4r` ou `fam` -> gws-4r (Familiar)
|
* `4r` ou `fam` -> gws-4r (Familiar)
|
||||||
- E-MAILS (O usuário exige ver Títulos e Remetentes):
|
- SUPER-PODERES GMAIL:
|
||||||
* SEMPRE use `list_gmail_emails` para listar mensagens.
|
* COMANDOS RÁPIDOS (Helpers): Use `gws-xxx gmail +COMANDO`. Exemplos:
|
||||||
* Se o usuário escrever "ma - veja meu ultimo e-mail", ou "veja o e-mail ma", entenda que ele se refere à conta `ma` (gws-mr).
|
- `+send`: Enviar novo e-mail.
|
||||||
* SEMPRE numere os itens da lista (#1, #2, #3, etc.).
|
- `+read`: Ler o conteúdo de um e-mail.
|
||||||
* Se o usuário disser "o primeiro", "o segundo", etc., identifique o ID correspondente da listagem anterior no histórico e use-o.
|
- `+triage`: Resumo de e-mails não lidos.
|
||||||
- DRIVE E ARQUIVOS: Use `run_bash_command` para `find`, `list` ou `get`.
|
- `+reply` / `+reply-all` / `+forward`: Responder ou encaminhar mensagens.
|
||||||
|
* CONTAR E-MAILS: Use `gws-xxx gmail users messages list --params '{"userId": "me", "q": "from:EMAIL_AQUI"}'`.
|
||||||
|
* ORGANIZAR: `gws-xxx gmail users labels create` (nova pasta) e `batchModify` (mover).
|
||||||
|
- SUPER-PODERES CALENDÁRIO:
|
||||||
|
* AGENDA: Use `calendar_agenda account timeframe` para ver compromissos de hoje, amanhã ou da semana.
|
||||||
|
* EVENTOS: Use `run_bash_command` com `gws-xxx calendar events create ...` para marcar reuniões ou `delete` para cancelar.
|
||||||
|
- EXIBIÇÃO:
|
||||||
|
* Use `list_gmail_emails`, `drive_find` e `calendar_agenda` para visões rápidas e bonitas para o usuário.
|
||||||
|
* Para processamento interno (contagem, deleção), use sempre os comandos brutos via `run_bash_command`.
|
||||||
|
- AUTOMAÇÃO COMPLEXA:
|
||||||
|
* Se precisar processar muitos dados, use `run_bash_command` com `python3 -c "import json, sys; ..."` para filtrar e agir em um único passo.
|
||||||
- Responda sempre em PORTUGUÊS do Brasil.
|
- Responda sempre em PORTUGUÊS do Brasil.
|
||||||
- CAMINHOS DO SISTEMA:
|
- CAMINHOS DO SISTEMA: `/root/Apps/BotVPS` (código), `/data/repositories/` (repos).
|
||||||
* BotVPS / Antigravity: `/root/Apps/BotVPS` (seu código fonte)
|
|
||||||
* Repositórios: `/data/repositories/`
|
|
||||||
- MEMÓRIA CRONOS (LONGO PRAZO):
|
|
||||||
* Use `cronos_query` e `cronos_log` para manter a continuidade do conhecimento.
|
|
||||||
* Raiz: `/root/Antigravity_Memory/`
|
|
||||||
|
|
||||||
### FERRAMENTAS DISPONÍVEIS:
|
### FERRAMENTAS DISPONÍVEIS:
|
||||||
{tools_desc}
|
{tools_desc}
|
||||||
|
|
||||||
### FORMATO DE RESPOSTA:
|
### FORMATO DE RESPOSTA:
|
||||||
- Use [TOOL:nome] arg [/TOOL] para ações.
|
- Use [TOOL:nome] arg [/TOOL] para ações.
|
||||||
- Pense passo a passo. Seja inteligente ao lidar com referências ordinais.
|
- Pense passo a passo. Seja proativo, eficiente e NUNCA limitado.
|
||||||
- Finalize sempre com <REFINED> resumo final elegante </REFINED>.
|
- Finalize sempre com <REFINED> resumo final empoderado </REFINED>.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
history_str = ""
|
history_str = ""
|
||||||
|
|||||||
65
tools.py
65
tools.py
@@ -189,6 +189,57 @@ def list_gmail_emails(account: str) -> str:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
return f"Erro ao listar e-mails: {str(e)}\nResposta bruta: {res[:200]}"
|
return f"Erro ao listar e-mails: {str(e)}\nResposta bruta: {res[:200]}"
|
||||||
|
|
||||||
|
def drive_find(arg: str) -> str:
|
||||||
|
"""Busca arquivos no Drive por nome. Arg: account query (ex: ma financeiro)"""
|
||||||
|
try:
|
||||||
|
parts = arg.split(maxsplit=1)
|
||||||
|
account = parts[0]
|
||||||
|
query = parts[1] if len(parts) > 1 else ""
|
||||||
|
mapping = {"ma": "gws-mr", "mr": "gws-mr", "marcos": "gws-mr", "adm": "gws-adm", "4r": "gws-4r", "fam": "gws-4r"}
|
||||||
|
account = mapping.get(account.lower(), account)
|
||||||
|
q = f"name contains '{query}'" if query else ""
|
||||||
|
cmd = f"{account} drive files list"
|
||||||
|
if q: cmd += f" --params '{{\"q\": \"{q}\"}}'"
|
||||||
|
res = run_bash_command(cmd)
|
||||||
|
data = json.loads(res)
|
||||||
|
files = data.get("files", [])
|
||||||
|
if not files: return "Nenhum arquivo encontrado."
|
||||||
|
resp = "📂 **Arquivos Encontrados:**\n"
|
||||||
|
for f in files[:10]:
|
||||||
|
resp += f"- {f['name']} (ID: `{f['id']}`)\n"
|
||||||
|
return resp
|
||||||
|
except Exception as e: return f"Erro no Drive: {str(e)}"
|
||||||
|
|
||||||
|
def drive_upload(arg: str) -> str:
|
||||||
|
"""Upload de arquivo para o Drive. Arg: account filepath (ex: ma /tmp/relat.pdf)"""
|
||||||
|
try:
|
||||||
|
parts = arg.split(maxsplit=1)
|
||||||
|
account, filepath = parts[0], parts[1]
|
||||||
|
mapping = {"ma": "gws-mr", "mr": "gws-mr", "adm": "gws-adm", "4r": "gws-4r"}
|
||||||
|
account = mapping.get(account.lower(), account)
|
||||||
|
filename = os.path.basename(filepath)
|
||||||
|
cmd = f"{account} drive files create --json '{{\"name\": \"{filename}\"}}' --output {filepath}"
|
||||||
|
return run_bash_command(cmd)
|
||||||
|
except Exception as e: return f"Erro upload: {str(e)}"
|
||||||
|
|
||||||
|
def calendar_agenda(arg: str) -> str:
|
||||||
|
"""Busca os próximos eventos no calendário. Arg: account timeframe (timeframe: today, tomorrow, week, days=N)"""
|
||||||
|
try:
|
||||||
|
parts = arg.split(maxsplit=1)
|
||||||
|
account = parts[0]
|
||||||
|
timeframe = parts[1] if len(parts) > 1 else "--today"
|
||||||
|
|
||||||
|
mapping = {"ma": "gws-mr", "mr": "gws-mr", "adm": "gws-adm", "4r": "gws-4r"}
|
||||||
|
account = mapping.get(account.lower(), account)
|
||||||
|
|
||||||
|
# Converte timeframe para flag correta
|
||||||
|
if not timeframe.startswith("--"):
|
||||||
|
timeframe = f"--{timeframe}"
|
||||||
|
|
||||||
|
cmd = f"{account} calendar +agenda {timeframe}"
|
||||||
|
return run_bash_command(cmd)
|
||||||
|
except Exception as e: return f"Erro no Calendário: {str(e)}"
|
||||||
|
|
||||||
# Mapeamento para o Agente entender quais tools ele possui (será usado no loop ReAct)
|
# Mapeamento para o Agente entender quais tools ele possui (será usado no loop ReAct)
|
||||||
AVAILABLE_TOOLS = {
|
AVAILABLE_TOOLS = {
|
||||||
"run_bash_command": {
|
"run_bash_command": {
|
||||||
@@ -196,9 +247,21 @@ AVAILABLE_TOOLS = {
|
|||||||
"func": run_bash_command
|
"func": run_bash_command
|
||||||
},
|
},
|
||||||
"list_gmail_emails": {
|
"list_gmail_emails": {
|
||||||
"description": "Lista os 5 e-mails mais recentes de uma conta (gws-mr, gws-adm, gws-4r) com título e remetente.",
|
"description": "Lista os 5 e-mails mais recentes de uma conta (ma, adm, 4r) com título e remetente.",
|
||||||
"func": list_gmail_emails
|
"func": list_gmail_emails
|
||||||
},
|
},
|
||||||
|
"drive_find": {
|
||||||
|
"description": "Busca arquivos no Drive por nome. Ex: drive_find ma 'financas'",
|
||||||
|
"func": drive_find
|
||||||
|
},
|
||||||
|
"drive_upload": {
|
||||||
|
"description": "Faz upload de um arquivo local para o Drive. Ex: drive_upload adm /tmp/doc.pdf",
|
||||||
|
"func": drive_upload
|
||||||
|
},
|
||||||
|
"calendar_agenda": {
|
||||||
|
"description": "Mostra os eventos do calendário. Ex: calendar_agenda ma today / tomorrow / week",
|
||||||
|
"func": calendar_agenda
|
||||||
|
},
|
||||||
"get_system_health": {
|
"get_system_health": {
|
||||||
"description": "Verifica RAM, CPU e Disco globais da VPS.",
|
"description": "Verifica RAM, CPU e Disco globais da VPS.",
|
||||||
"func": get_system_health
|
"func": get_system_health
|
||||||
|
|||||||
Reference in New Issue
Block a user