PTENES
Personal assistant Β· Telegram Β· local

A bot that works without exceeding the machine's memory

Durable SQLite queue, Ollama manager with RAM preflight, per-call cost with budget, and a brain that remembers in PT-BR. Runs alongside v2 until parity.

Illustration of openpcbot v3: personal assistant running locally

In summary

openpcbotv3 is a personal assistant you use through Telegram, the Jarvis dashboard, or other enabled channels. It organizes requests in a queue, maintains memory, and performs tasks with tools. You can choose between Claude Code and Codex subscriptions per chat, with Codex as the current default. To use subscription-based execution, you need to install the system and authenticate the desired CLIs.

What it is

Successor to openpcbot v2, designed from real pain points

v2 works, but it's a monolith with no queue, no per-call cost tracking, and no Ollama management, and it experienced two out-of-memory crashes in August. v3 builds on what's already been completed and tested in other local repos, and organizes it in layers.

🧱 A real queue

Atomic claim, heartbeat lease, backoff, idempotency, and graceful drain, ported from inemaccbot with the original 107 tests. Lanes by type of work, one Claude / Codex at a time.

🧠 Brain in PT-BR

Memories with salience and decay, FTS5 + bge-m3 vector search, nightly consolidation that detects contradictions, and a curated vault that only saves with your approval.

πŸ’Έ Cost and RAM under control

Every LLM call goes through a single gateway: local tier β†’ low-cost β†’ premium, monthly budget with a hard limit, and a preflight that refuses to load a large model without 40 GB free.

How it works

How a message flows

Channels only translate to an event bus. The orchestrator classifies with a small local model before spending any cloud tokens.

Telegram / CLI / HTTP→ Bus→ Router (llama3.2)→ Memory (3 layers)→ Direct local response or Claude/Codex agent→ Secrets guard→ Chat
1

Router

Returns JSON with route, agent, and tier. "direto" for conversation; "agente" when it needs a file, shell, repo, web, or skill.

2

LLM gateway

Budget β†’ provider β†’ RAM preflight β†’ call β†’ cost in chamadas_llm. Ollama costs nothing, but uses tokens and time.

3

Queue

The job runs in the queue with Claude Code or Codex through its subscription, according to the chat selection. The response and recorded usage return to the originating channel.

4

Learning

Every turn becomes a memory. A lasting fact generates a proposal for MEMORY.md / USER.md; you approve with a command.

Your Jarvis with multiple subscriptions

If one subscription reaches its usage limit, you can choose the other for future requests. openpcbotv3 already supports Claude Code and Codex through their subscriptions, with manual selection per chat.

You choose the engineThe request enters the queueClaude or Codex runs itThe response returns to the same chat

What is configured

How to switch in chat

CommandWhat happens
/motorShows the engine, model, and effort for this chat.
/motor codexSelects Codex through its subscription for future requests.
/motor claudeSelects Claude Code through its subscription for future requests.
/motor padraoReturns to the project's default configuration, currently Codex.
/status 12345Shows the status and engine of job 12345.
/job 12345 continue de onde parouCreates a continuation of the request using the engine currently selected. Replace 12345 with the actual ID.

Example: Codex has run out of quota. Wait for the current request to finish or check its status; then select Claude and continue using the job ID.

/status 12345
/motor claude
/job 12345 continue de onde parou

You do not need to restart the bot to change engines. Each subscription needs its own valid login and availability. Commands, files, and connectors depend on the tools enabled for each executor.

Configuration and local checks

The config/agentes-ia.yaml file stores the default. The chat preference takes priority; use /motor padrao to follow the file again.

motor: codex
codex:
  modelo: gpt-6.1-sol
  esforco: medium
npm run ia -- ver
npm run ia -- validar

These two commands only read and validate the configuration: they do not call models, test logins, or check balances. The CLIs use subscriptions; this adaptation did not enable any new model APIs.

What if switching were automatic?

This is a proposal for the next stage; it has not been implemented yet. The bot's code could detect an explicit Codex usage limit error and choose Claude without asking Codex to make that decision. Rule-based decisions do not consume AI tokens or require remaining Codex quota.

  1. The executor receives a usage limit refusal and classifies the error by code, type, or known message.
  2. The bot marks that engine as temporarily unavailable and checks whether the alternative is configured and has the required tools.
  3. Before resuming, it checks progress and any external effects already completed. A completed publication or delivery must not be repeated just because a later failure occurred.
  4. The bot opens a session on the other engine with the saved context, records the switch, and notifies the chat.

No tokens used for the decision does not mean execution uses none. The refused call may already have done part of the work; checking availability with a new call may also consume quota. Claude will use its own subscription to continue and receive the saved context. If both engines are limited, or the state of an external action is uncertain, the process should wait or request intervention.

Automatic resumption requires progress tracking independent of the model. There is currently no automatic switch when quota runs out. The API agent executor, with shell and connectors, is also NOT READY; the old message adapters are not equivalent to this complete agent.

Operations and limitations (in Portuguese) Β· Complete plan, subject to approval (in Portuguese)

Prerequisites

What needs to be live

Everything is local. Shared API keys are read at runtime from .env from v2; v3 only needs its own bot token.

Ollama as a service

HTTP only on 11434. Never a ollama serve in parallel.

# models used (same tags as v2)
ollama pull qwen3.8:27b
ollama pull llama3.2
ollama pull bge-m3

Node 20+ and an agent subscription

Install and authenticate Codex and/or Claude Code. Execution uses the CLI subscription; check the login before using the bot.

node -v
codex --version
claude --version

Your own Telegram bot

Create one in BotFather. The v2 token is rejected at boot (two getUpdates = 409 and the bot goes silent).

# ~/projetos/openpcbotv3/.env
TELEGRAM_BOT_TOKEN_V3=123456:AAH...
PORT_V3=3142
PISO_RAM_GB=40
User guide Β· step by step

From clone to a responsive bot

Five commands. The service starts even without a Telegram token, with HTTP and CLI.

1

Install and configure

Copy the example from .env and fill in only what belongs to v3.

git clone git@github.com:inematds/openpcbotv3.git && cd openpcbotv3
npm install
cp .env.exemplo .env   # TELEGRAM_BOT_TOKEN_V3, PORT_V3, PISO_RAM_GB, ORCAMENTO_MENSAL_USD
2

Run the doctor

Checks env, Ollama and models, RAM, CLIs, active v2, unit, and memory limit. Changes nothing.

npm run doctor
βœ… same general model as v2   v2=qwen3.8:27b v3=qwen3.8:27b
βœ… RAM                          63.8 GB available Β· minimum to load a large model: 40 GB
⚠️  TELEGRAM_BOT_TOKEN_V3        missing β€” Telegram channel disabled
3

Import memories from v2

Snapshot with VACUUM INTO: the v2 database is never opened for writing. Idempotent.

npx tsx src/cli/importar.ts
v2 memories: read 308 Β· inserted 291 Β· already existed 17
4

Install the service

User unit with Restart=on-failure, MemoryHigh=1.5G e MemoryMax=2G. The same script can be used to restart after changes src/ or .env.

bash scripts/instalar-servico.sh
# build + daemon-reload + enable + restart; no sudo
journalctl --user -u openpcbotv3 -f -o cat
5

Chat

On Telegram, or via HTTP and CLI until there's a token.

npm run cli -- "/health"
npm run cli -- "lembra que eu prefiro respostas curtas"
npm run cli -- "no projeto X, conta as linhas de src/app.ts"   # becomes an agent job
6

Operate through chat

Queue, cost, memory, tasks, and cron without leaving Telegram. The dashboard is at http://127.0.0.1:3142/.

/status [id]        # queue by lane or details for a job
/usage              # cost today/week/month, by tier and agent, budget
/health             # Ollama, RAM, RSS, queue, heartbeat, channels
/memoria lista|buscar|salvar|propostas|aprovar <id>
/tarefa add amanhΓ£ 9h revisar PR   # reminder + summary in /daily
/cron lista Β· /ollama status Β· /consolidar Β· /novo
Examples

What happened during the first live tests

Real exchanges from the day v3 went live, with v2 active on the same machine.

Memory across sessions

you> qual a capital do RS? e lembra que eu prefiro respostas curtas
bot>  Porto Alegre.
bot>  πŸ“ Guardar no vault? "…prefiro respostas curtas" β†’ /memoria aprovar 1
you> o que eu te disse que prefiro?
bot>  Respostas curtas.

Agent job with actual cost

you> no projeto openpcbotv3, conta as linhas de src/fila/worker.ts
bot>  🧠 lead β€” job #7. /status 7 acompanha.
bot>  419
# chamadas_llm: claude-cli Β· sonnet Β· premium Β· US$ 0,1465 Β· 7,8 s
# unit memory peak: 636 MB (2 G limit)

RAM preflight refusing

/ollama preflight qwen3.6:35b-a3b
β›” a large model is already resident (qwen3.8:27b) β€” 1-resident policy

/ollama descarregar qwen3.8:27b
β›” was not loaded by this process (may belong to v2) β€” rejected

Health consumed by the hub

GET /health
{ "ok": true, "rss_mb": 82, "canais": ["telegram","http"],
  "ram": { "disponivelGb": 35.3, "swapUsadoGb": 8.5 },
  "ollama": { "online": true, "carregados": ["qwen3.8:27b"] },
  "orcamento": { "pct": 0, "limite_usd": 50, "travado": false } }
Roadmap

Throttle, don't cut off abruptly

v3 launches with its own bot alongside v2. Nothing is deleted until parity is reached: all v2 commands working in v3, 7 days with no lost jobs, and weekly costs measured.

0–2 βœ“
Foundation, queue, Ollama, cost, telemetryBus, YAML config, unit with a memory limit; ported queue; Ollama manager with preflight; LLM gateway with budget; /status, /usage, /health, alerts.
3–5 βœ“
Channels, orchestrator, brain, tasksTelegram/CLI/HTTP; local router; CLI agent with session and actual cost; PT-BR memory imported from v2, embeddings, nightly consolidation, curated vault; cron as jobs, heartbeat, /tarefa, /daily.
6–7 βœ“
Slack, WhatsApp, dashboard, doctor, backupSlack via Web API (disabled until cutover); WhatsApp with a guard that refuses while v2 owns the session; single-page dashboard; doctor; encrypted nightly backup.
8
CutSwitch the production token, keep v2 read-only for 30 days, then archive it. Only with explicit authorization. Afterward: real WhatsApp in a separate daemon, enable Slack, set job table retention.