4.7 KiB
4.7 KiB
Jasmine BrainService Implementation
Phase 1: Foundation
- Migration: Add new fields to jasmine_inbox_configs
- Add ENV fallback for DEFAULT_JASMINE_DISTANCE_THRESHOLD
- Seed: Create intent_keywords for hotel/motel business
Phase 2: BrainService Core
- Create Jasmine::BrainService skeleton
- Create IntentDetector component
- Create StrategyDecider component
- Create PromptAssembler component
- Create StateUpdater component
Phase 3: Integration
- Hook BrainService to incoming messages
- Add logging for decisions (intent, strategy, RAG usage)
Phase 4: Testing
- Specs for IntentDetector
- Specs for StrategyDecider (RAG mandatory vs prohibited)
- Specs for threshold handling
- Specs for loop protection (rag_queries > 5)
Phase 5: UI
- [/] Add System Prompt field to config UI (Done)
- [/] Add Playbook field to config UI (Done)
- [/] Add threshold/model settings to config UI (Done)
Phase 6: Jasmine Tools (New)
- Backend: Create jasmine_tool_configs table and model
- Backend: Create ToolRunner service
- Backend: Create ToolsController
- Frontend: Add Tools API client
- Frontend: Add JasmineToolCard component
- Frontend: Add JasmineToolsTab component
- Frontend: Integrate with InboxDashboard
- UI Refinement: Improve scrolling and layout
- Tests: Add RSpec tests
Phase 7: Jasmine + Captain Unification (V1)
-
Correção da Instabilidade no Ambiente Local
- Identificar causa dos erros 500 intermitentes (Conflito de Porta DB 5432 vs 5438)
- Resolver problema de versão do Ruby/Bundler (
rbenv init) - corrigir formato do telefone no webhook (
Inactive Channel- falta do DDI 55) - Criar documentação de solução de problemas (
solucao_ambiente_wuzapi.md)
-
Phase 1: Architecture Mapping
- Map Message Entry Point
- Map Knowledge Base Decision Logic
- Map Prompt Assembly
- Map Tool Execution
- Deliver: Mapping Report & Injection Point Identification
-
Phase 2: Brain Layer Implementation
- Schema: Create
captain_tool_configstable - Schema: Update
captain_assistantsfor Multi-LLM (llm_provider,llm_model) - Backend:
AssistantChatServiceDynamic Provider Logic - File:
enterprise/app/services/captain/llm/jasmine_brain.rb(Skeleton) - Refactor:
JasmineBrainwith Real LLM Logic (Thinking Step) - File:
enterprise/app/services/captain/tools/definitions.rb - File:
enterprise/app/services/captain/tools/tool_runner.rb - File:
enterprise/app/services/captain/tools/parsers/status_suites_parser.rb - Inject:
AssistantChatService#generate_response
- Schema: Create
-
Phase 3: Tools Integration (UI)
- Backend: Create
Captain::ToolsController(or extend existing) to managecaptain_tool_configs - Frontend: Create "Ferramentas" tab inside Captain Assistant settings
- Frontend: Build form for Tool Key, Enabled, PlugPlay ID/Token, Webhook URL
- Backend: Create
-
Phase 4: Output Normalization
- Ensure normalized JSON output from tools
-
Phase 5: Webhook Tools & Handoff
- Implement Webhook Tools
- Implement Human Handoff (
escalar_humano)
-
Phase 6: Final Integration
- Inject Brain Layer into Captain Pipeline
- Final Verification
Phase 8: Native WuzAPI Channel (V1 Standard)
-
Security (Foundation)
- DB: Migration for
encrypted_wuzapi_user_token&admin_token - Model: Add
encryptstoChannel::Whatsapp - Code: Migrate checks from
provider_configto encrypted cols - Fix: Rename columns to match Rail convention (
wuzapi_user_token)
- DB: Migration for
-
Inbound (V1 Contract)
- Parser: Create
Wuzapi::PayloadParser(Strict Contract) - Service: Implement Strong Dedupe (Source ID Check)
- Service: Implement Loop Protection (
is_from_me) - Fix: Tunnel Connectivity & Webhook Config
- Parser: Create
-
Outbound (V1)
- Service: Switch to encrypted token usage
- Service: Ensure Text Sending works
- Service: Fix 401 Auth (Header/Token Logic)
-
Sync (V1.5)
- Implement Mobile Sync (Two-Way)
- Handle
from_memessages as Outgoing
-
Fix: Instability
- Update Webhook URL (New Tunnel)
- Verify
from_mesync reliability
Phase 9: Automation & Cleanup (VPS Ready)
-
Automation
- Job: Create
Wuzapi::ConfigureWebhookJob(Implemented as Model Callback) - Hook: Trigger on
Channel::Whatsappcreate/update - Logic: Set Webhook to
#{FRONTEND_URL}/webhooks/whatsapp/#{phone} - Logic: Set
Events: ['All']
- Job: Create
-
Documentation
- Update
wuzapi_walkthrough.mdwith final architecture.
- Update