Skip to content

Feat/restart no nanoclaw#2476

Open
andrefogelman wants to merge 224 commits into
nanocoai:mainfrom
andrefogelman:feat/restart-no-nanoclaw
Open

Feat/restart no nanoclaw#2476
andrefogelman wants to merge 224 commits into
nanocoai:mainfrom
andrefogelman:feat/restart-no-nanoclaw

Conversation

@andrefogelman
Copy link
Copy Markdown

Type of Change

  • Feature skill - adds a channel or integration (source code changes + SKILL.md)
  • Utility skill - adds a standalone tool (code files in .claude/skills/<name>/, no source changes)
  • Operational/container skill - adds a workflow or agent skill (SKILL.md only, no source changes)
  • Fix - bug fix or security fix to source code
  • Simplification - reduces or simplifies source code
  • Documentation - docs, README, or CONTRIBUTING changes only

Description

For Skills

  • SKILL.md contains instructions, not inline code (code goes in separate files)
  • SKILL.md is under 500 lines
  • I tested this skill on a fresh clone

andrefogelman and others added 30 commits March 31, 2026 08:05
…RAG, flow engine

- Add src/supabase-client.ts: bridge with supabase-js + WebSocket polyfill
- Add src/anf/: ANF agent modules (activity-log, agent-context, agent-registry,
  agent-runner, chat-handler, embeddings, flow-engine, health, memory,
  realtime-listener, router, scheduler, task-executor, whatsapp)
- Add src/anf/anf-config.ts: ANF config (Anthropic base URL, port, admin WA)
- Add src/anf/start.ts: ANF entry point with scheduled tasks for all 4 agents
- Add agents/: 4 domain agents (suprimentos, financeiro, engenharia, orquestrador)
- Fix all imports: db.js → supabase-client.js, channels/whatsapp.js → whatsapp.js
- Update tsconfig.json: rootDir=. and include agents/**/*
- Add .env.example with all required env vars

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- startAnfModules() chamado no main() após init
- NanoClaw roda em ANF-only mode quando sem channels
- Subsystems NanoClaw (scheduler, IPC, message loop) só iniciam com channels
- Módulos ANF (realtime, task executor, flow engine, chat, crons) rodam independente

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Rename package to orcabot v0.1.0
- Replace better-sqlite3 with @supabase/supabase-js, add pino, remove @onecli-sh/sdk
- Create OrcaBot config with Supabase/LLM proxy/API env vars
- Add OneCLI stub to keep existing code compiling
- Add @ts-nocheck to db.ts and db-migration.test.ts (pending Task 4 rewrite)
- Create directory structure: agents/, container/skills/, supabase/migrations/, tests/, frontend/
- Add .env.example with all env vars documented
- Replace CLAUDE.md with OrcaBot-specific instructions

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
7 migration files for OrcaBot schema on shared Supabase (baebsednxclzqukzxkbg):
- 001: ob_organizations, ob_org_members (auth & tenancy with RLS)
- 002: ob_projects, ob_project_files (RLS via org membership)
- 003: ob_pdf_jobs, ob_pdf_pages (PDF pipeline with RLS)
- 004: ob_quantitativos, ob_orcamento_items (budget with RLS)
- 005: ob_sinapi_composicoes (public read-only, pg_trgm fuzzy search), ob_cotacoes_mercado
- 006: ob_agent_activity_log, ob_agent_conversations (RLS)
- 007: ob_nc_* NanoClaw runtime tables (no RLS, service_role only)

All tables use ob_ prefix to avoid conflicts with anfconstrucoes tables.
Includes src/migrate.ts runner and "migrate" npm script.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Two clients (supabaseAdmin for server-side, supabaseAnon for RLS),
supabaseWithAuth(jwt) helper, legacy aliases for backward compat,
and test suite.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Replace all better-sqlite3 usage with supabaseAdmin client
- All db functions now async (return Promises)
- Update all callers (index.ts, ipc.ts, task-scheduler.ts) to await
- Update all tests to use async/await patterns
- Remove db-migration.test.ts (SQLite migrations no longer apply)
- Remove SQLite from setup/ files (environment, verify, groups, register)
- Add .env loading to vitest.config.ts for test env vars
- Zero SQLite references remaining in src/ and setup/

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add normalizeTimestamp() to handle Postgres timestamptz +00:00 format
- Fix test data with invalid dates (June 31+, Feb 30) for Postgres strict mode
- Make IpcDeps.registerGroup async to properly await Supabase writes
- Add fileParallelism: false to vitest config (shared remote DB)
- Rename migrations to timestamp format for Supabase CLI compatibility
- Add supabase config.toml and link to project

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Proxy listens on configurable port (default 8200) and forwards
container LLM requests to Anthropic with the correct auth headers.
Supports apikey mode (production) and max mode (dev, zero cost).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
HTTP server channel that bridges the OrcaBot frontend to NanoClaw.
Endpoints: POST /api/message, POST /api/job, GET /api/status/:id, GET /api/health.
Auth via Bearer token (API_SECRET). Self-registers with channel registry.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Dockerfile for main OrcaBot gateway, docker-compose with ports 8200/8300,
agent container image with PaddleOCR/tesseract, and rsync deploy script.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Health check verifies Supabase, LLM proxy, and API channel connectivity.
Integration tests validate ob_nc_chats CRUD and existence of ob_organizations,
ob_projects, and ob_sinapi_composicoes tables.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Container skill with 5-stage pipeline: ingestion, extraction,
classification, interpretation, and structured output. Includes
pdfjs-dist text extraction, PaddleOCR fallback, Claude Vision
interpretation, Zod-validated output schemas, and confidence scoring.
All 24 unit tests passing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Shared infrastructure: types.ts + supabase-helpers.ts for all agents
- Orcamentista (orchestrator): 8 tools (PDF results, quantitativos, delegation, SINAPI search, orcamento items, subtotals, review flags, project context)
- Estrutural (specialist): 4 tools (concreto, aco, forma, escavacao)
- Hidraulico (specialist): 3 tools (tubulacoes, conexoes, equipamentos)
- Eletricista (specialist): 4 tools (pontos, circuitos, eletrodutos, materiais)
- Agent registry with all 4 agents
- Delegation engine with Supabase-based IPC (poller + task processor)
- SINAPI import script (Python + openpyxl)
- SINAPI lookup container skill
- Migration for ob_delegation_tasks table
- 37 tests across 9 test files, all passing

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…wer, chat, export)

Complete web frontend with:
- Auth (Supabase login/session), protected routes
- Dashboard with project list, status cards, new project wizard
- Budget spreadsheet with inline editing, 3-level hierarchy, ANF format
- PDF upload (drag-and-drop), viewer (react-pdf), review panel
- Agent chat sidebar with Realtime subscriptions
- Quantitativos, Premissas, Curva ABC tabs
- Excel export (ExcelJS) matching ANF format
- Supabase Realtime for live updates on budget, PDFs, chat
- shadcn/ui components, TailwindCSS, TypeScript strict

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Database tables use ob_ prefix (ob_projects, ob_orcamento_items, etc.)
but frontend .from() calls and types referenced them without prefix.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add PDF job poller that processes pending jobs sequentially
- Fix table name mismatches (ob_ prefix) in pdf-pipeline supabase client
- Fix storage bucket creation and RLS policies for project-pdfs
- Fix auth.users permission error in storage avatar policies
- Implement delegation engine with real agent execution via Anthropic SDK
- Add OrcaBot agent runner for specialist agents (estrutural, hidraulico, eletricista)
- Implement Excel export skill with 3-sheet XLSX generation
- Add export_budget tool to orcamentista agent
- Create process-project Supabase Edge Function (serverless pipeline)
- Add "Iniciar Orçamento" button to ProjectPage header
- Wire job poller and delegation engine into main index.ts
- Add retry with backoff for Claude API rate limits
- Use King proxy (100.91.255.19:8100) for LLM calls

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…mpts

- Add PdfProcessPanel: chat-like interface for processing individual PDFs
- User selects a PDF, types what to extract, AI processes with that prompt
- Smart prompt suggestions based on filename (demolir, hidraulica, eletrica, etc.)
- Shows extracted results inline with confidence badges
- Replace ReviewPanel with PdfProcessPanel in PdfsTab
- Create process-single-pdf Edge Function for per-file processing
- Retry with backoff for rate limits

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…Funnel

- Add item selection table in PdfProcessPanel after extraction
- Checkbox per item, select all/none controls
- "Salvar na Planilha" button inserts selected items into ob_quantitativos
- No automatic SINAPI lookup — user fills costs manually
- Fix edge functions: use pdf-parse instead of pdfjs-dist (Deno compat)
- Add node:buffer import for Deno edge functions
- Route LLM calls through King Tailscale Funnel (zero API cost)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Create ob_processing_runs table to store every AI extraction attempt
- Each run saves: prompt, items, summary, needs_review, raw_response
- PdfProcessPanel shows full history of runs per file (expandable cards)
- Each run card shows items table with select/save to planilha
- Drastically improved system prompt: forces numeric quantities, includes
  calculation rules for walls/floors/pipes, never returns empty items
- Increased max_tokens to 8192 for longer extractions
- Warns when PDF has very little extractable text (scanned image)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
andre fogelman and others added 25 commits April 11, 2026 08:43
Paginated table with unit-match highlight (✓ badge), click to select,
double-click equivalent. Uses existing useSinapiSearch hook.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Mirror of SINAPI tab without pagination (1272 total, hook limits 100).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds BookOpen button per row that opens a shared PriceSourceDialog
hosted by BudgetTable. On apply, pushes an 'update' undo entry
with the previous cost snapshot so Ctrl+Z reverts cleanly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Was invisible with group-hover:visible, but design spec calls for
always-visible affordance (inline UI pattern).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Keep safeJsonParse (upstream), taskContent param name (upstream),
and console.error logging (upstream) over stashed local changes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Previously custo_total was set to just material + mao_obra without
multiplying by quantidade. Also fix TCPO search to match on descricao
and search_term (accent-insensitive).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Previously deleting a level-2 item would leave its level-3 children
orphaned. Now all descendants are deleted regardless of parent level.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When editing an etapa/item EAP code (e.g. 08 → 07), all children
are automatically renumbered (08.01 → 07.01, etc.) using the
existing renumber_eap_items RPC.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The React Query cache wasn't refreshed after the renumber RPC,
so the user had to manually reload to see updated EAP codes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- BudgetCell: single-click focus, type to edit, arrow/tab/enter navigation
- BudgetRow: pass focus state and navigation callbacks to each cell
- BudgetTable: manage focused cell state, flat row list, keyboard handler

Click selects cell, typing starts editing, arrows navigate,
Enter confirms+moves down, Tab confirms+moves right, Escape cancels.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When typing to start editing, cursor is placed at end instead of
selecting all, so the typed character is preserved.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Browser focus() auto-selects input text. Using requestAnimationFrame
to set selection after focus settles, and a ref (not state) to track
whether to select-all or cursor-at-end.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- TCPO search: each word matches descricao (accented) or search_term (stripped)
- SINAPI search: per-word ilike on descricao, filter composicao only
- SINAPI pricing: use custo_sem_desoneracao with fallback to custo_com_desoneracao
- Remove codigo from search fields (description-only search)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- TCPO demolições: 57 compositions (67 search terms)
- TCPO complementar: 552 compositions (142 new terms, all categories)
- SINAPI sem desoneração: 7712 prices updated from Caixa Excel CSD sheet
- SINAPI analítico: 38680 composition-insumo records imported
- Fix search_term: strip accents, use codigo+descricao for all 1850 TCPO rows
- Total TCPO: 1850 compositions, SINAPI analytical: 38680 records

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- New items inherit adm_percentual from project premissas (no hardcoded default)
- New projects require adm% to be set explicitly
- Excel export generates live formulas: SUM for parents, E+F for custo_total, SUMPRODUCT for administração

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds expandable chevron on each SINAPI/TCPO result row showing:
- Material vs Mão de Obra cost breakdown summary
- Full insumo table with código, descrição, classe, coeficiente, preço unitário, total
- TCPO: colored badges (MOD/MAT/EQH) + LS+BDI split
- SINAPI: fetches ob_sinapi_composicao_insumos with joined custo_sem_desoneracao

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Início do pivot do orcabot pra Orcamentista IA (SaaS de orçamento).

Mantém:
- frontend/ (Vite + React 18, páginas SINAPI/TCPO/Project/Dashboard)
- supabase/migrations/ (28 migrations, schema ob_* multi-tenant)
- scripts/ (data ingest SINAPI/TCPO — Python + TS scrapers)
- .vercel/project.json (prj_GWZ4A9...)
- .env.example, .gitignore, tsconfig, etc.

Apaga:
- src/ (NanoClaw Node runtime + LLM proxy + container runner)
- agents/ (9 agents NanoClaw)
- container/, groups/, launchd/, setup/, repo-tokens/, config-examples/ (infra NanoClaw)
- tests/ (testes do runtime NanoClaw)
- assets/ (branding NanoClaw)
- .github/ (workflows NanoClaw: bump-version, ci, label-pr, update-tokens)
- Dockerfiles, docker-compose, setup.sh
- READMEs ja/zh, CHANGELOG, CONTRIBUTING, CONTRIBUTORS, skills-lock.json
- vitest configs, .dockerignore, bun.lock (raiz)

Próximo: criar api/index.py (FastAPI ASGI Vercel Python).
Sprint 0 — esqueleto da Engine Python para Orcamentista IA.

Adiciona:
- api/index.py — FastAPI app entry (ASGI, detectado pelo @vercel/python@5.x)
- api/routers/{ask,extract,dxf,sinapi}.py — stubs 501 (Sprints 1-3)
- api/lib/supabase.py — service-role client com lru_cache
- api/lib/auth.py — dual auth: Supabase JWT OU ORCABOT_API_SECRET (compat com frontend)
- api/lib/cache.py — helpers de hash p/ ob_vision_cache (Sprint 1)
- api/schemas/{ask,extract,dxf}.py — Pydantic placeholders (ask.RespostaOutput pronto)
- api/engines/{vision,dxf,sinapi}.py — placeholders Sprints 1-3
- vercel.json (raiz) — buildCommand frontend Vite + função Python (60s, 1024MB)
- requirements.txt — fastapi, uvicorn, gaik[vision-extract], ezdxf, openpyxl,
  supabase-py, python-jose, sentence-transformers
- package.json (raiz) — minimal: dev:web, dev:api, build, typecheck

Atualiza:
- .env.example — vars Supabase/LLM/CORS/VITE_* documentadas
- .gitignore — adiciona Python (__pycache__, .venv) e remove regras NanoClaw

Apaga:
- tsconfig.json, eslint.config.js, .prettierrc (raiz) — apontavam pra src/ deletado;
  frontend/ tem suas próprias configs
- .husky/pre-commit — husky desinstalado junto com runtime NanoClaw

Endpoints expostos:
- GET  /api/healthz       → 200 (smoke)
- POST /api/ask           → 501 (Sprint 1)
- POST /api/extract       → 501 (Sprint 2)
- POST /api/dxf/{...}     → 501 (Sprint 2)
- POST /api/sinapi/match  → 501 (Sprint 3)

Vercel preview vai validar:
- Frontend builda e sobe (Login page renderiza)
- /api/healthz retorna 200 com payload JSON
- Páginas que chamavam /api/process, /api/agent-chat, /api/caderno-query
  vão dar 404 — esperado, migração no Sprint 1+.

Próximo: 0.9 inventário endpoints + 0.10 migration ob_vision_cache + 0.11 docs.
…e CLAUDE.md

- docs/ARCHITECTURE.md — diagrama Vercel + Supabase, decisões, restrições, roadmap 5 sprints
- docs/DEPLOY.md — projeto Vercel (prj_GWZ4A9...), env vars, smoke check, limites Hobby
- docs/DEV.md — setup local Vite + uvicorn, dev flow, convenções de commit
- docs/MIGRATION.md — mapeamento endpoints legados (/api/process, /api/agent-chat,
  /api/caderno-query) → novos (/api/ask, /api/extract, /api/sinapi/match) por página
- supabase/migrations/20260410000002_vision_cache_and_queries.sql —
  arquivo da migration que foi aplicada via MCP apply_migration no remoto.
  Tabelas ob_vision_cache (chave: pdf_sha256+question_hash) e ob_vision_queries
  (audit/memorial). RLS via padrão ob_org_members.user_id = auth.uid().
- README.md raiz reescrito — Orcamentista IA (sem NanoClaw)
- CLAUDE.md raiz reescrito — instruções pra futuras sessões Claude Code

Sprint 0 completo. Próximo: abrir PR draft pra main, validar preview Vercel verde,
parar para revisão antes de iniciar Sprint 1 (/api/ask).
Vercel project settings atualizados via API:
- rootDirectory: 'frontend' → null (raiz do repo)
- framework: 'vite' → null (vercel.json controla)
- buildCommand/devCommand/installCommand/outputDirectory → null (vercel.json controla)

Vercel agora consegue ler vercel.json raiz + ver pasta api/ pra publicar
a Python function. Build command vem do vercel.json:
'cd frontend && bun install && bun run build'.
…t from .py + requirements.txt

Vercel rejeitava 'Function Runtimes must have a valid version'.
A sintaxe correta seria pinning exato (ex: '@vercel/python@5.0.0').
Mais simples: remover o campo runtime e deixar Vercel auto-detectar
via extensao .py + requirements.txt na raiz.
Vercel deploy falhou: 'Total bundle size (5003.01 MB) exceeds Lambda
ephemeral storage limit (500 MB)'.

Causa: sentence-transformers puxa torch que puxa nvidia-cublas-cu12,
nvidia-cudnn-cu12, etc — explode pra 5GB. Sprint 0 nao usa embedding
mesmo (Sprint 3 task), entao removido por enquanto.

Sprint 3 vai usar OpenAI text-embedding-3-small com dimensions=384,
mantendo schema vector(384) atual. Re-embedar 13597 chunks single-shot
~$1.36, ~10min de runtime.

Tambem pinando Python 3.13 via .python-version (era 3.12 default,
3.13 recomendado nas Vercel knowledge updates 2026-02-27).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

follows-guidelines PR was created using the current contributing template

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant