@orbe-agro/client-core 5.6.324 → 5.6.326

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/@ecme/assets/styles/app.css +29 -0
  2. package/dist/@ecme/assets/styles/tailwind/index.css +29 -0
  3. package/dist/@ecme/components/template/Footer.js +1 -1
  4. package/dist/@ecme/components/template/OrbeAiWidget/OrbeAiWidget.js +7 -1
  5. package/dist/@ecme/components/template/OrbeAiWidget/OrbeAiWidget.js.map +1 -1
  6. package/dist/@ecme/components/ui/Alert/Alert.js +2 -0
  7. package/dist/@ecme/components/ui/Alert/Alert.js.map +1 -1
  8. package/dist/@ecme/components/ui/Tooltip/Tooltip.js.map +1 -1
  9. package/dist/@ecme/components/view/ChatBox/ChatBox.js +3 -1
  10. package/dist/@ecme/components/view/ChatBox/ChatBox.js.map +1 -1
  11. package/dist/@ecme/components/view/ChatBox/components/ChatInput.js +2 -1
  12. package/dist/@ecme/components/view/ChatBox/components/ChatInput.js.map +1 -1
  13. package/dist/@ecme/locales/lang/ptBR/nav.js +3 -0
  14. package/dist/@ecme/locales/lang/ptBR/nav.js.map +1 -1
  15. package/dist/@ecme/services/AiService.js +4 -2
  16. package/dist/@ecme/services/AiService.js.map +1 -1
  17. package/dist/@ecme/views/concepts/ai/Chat/components/ChatView.js +45 -3
  18. package/dist/@ecme/views/concepts/ai/Chat/components/ChatView.js.map +1 -1
  19. package/dist/@ecme/views/concepts/ai/Chat/components/EsforcoRaciocinio.js +85 -0
  20. package/dist/@ecme/views/concepts/ai/Chat/components/EsforcoRaciocinio.js.map +1 -0
  21. package/dist/@ecme/views/concepts/ai/Chat/hooks/useChatSend.js +20 -3
  22. package/dist/@ecme/views/concepts/ai/Chat/hooks/useChatSend.js.map +1 -1
  23. package/dist/@ecme/views/concepts/ai/Chat/store/esforcoStore.js +15 -0
  24. package/dist/@ecme/views/concepts/ai/Chat/store/esforcoStore.js.map +1 -0
  25. package/dist/@types/@ecme/components/template/OrbeAiWidget/OrbeAiWidget.d.ts.map +1 -1
  26. package/dist/@types/@ecme/components/ui/Alert/Alert.d.ts.map +1 -1
  27. package/dist/@types/@ecme/components/ui/Tooltip/Tooltip.d.ts.map +1 -1
  28. package/dist/@types/@ecme/components/view/ChatBox/ChatBox.d.ts.map +1 -1
  29. package/dist/@types/@ecme/components/view/ChatBox/components/ChatInput.d.ts +3 -1
  30. package/dist/@types/@ecme/components/view/ChatBox/components/ChatInput.d.ts.map +1 -1
  31. package/dist/@types/@ecme/locales/lang/ptBR/nav.d.ts.map +1 -1
  32. package/dist/@types/@ecme/services/AiService.d.ts +7 -3
  33. package/dist/@types/@ecme/services/AiService.d.ts.map +1 -1
  34. package/dist/@types/@ecme/views/concepts/ai/Chat/components/ChatView.d.ts +6 -1
  35. package/dist/@types/@ecme/views/concepts/ai/Chat/components/ChatView.d.ts.map +1 -1
  36. package/dist/@types/@ecme/views/concepts/ai/Chat/components/EsforcoRaciocinio.d.ts +14 -0
  37. package/dist/@types/@ecme/views/concepts/ai/Chat/components/EsforcoRaciocinio.d.ts.map +1 -0
  38. package/dist/@types/@ecme/views/concepts/ai/Chat/hooks/useChatSend.d.ts.map +1 -1
  39. package/dist/@types/@ecme/views/concepts/ai/Chat/store/esforcoStore.d.ts +27 -0
  40. package/dist/@types/@ecme/views/concepts/ai/Chat/store/esforcoStore.d.ts.map +1 -0
  41. package/dist/@types/@ecme/views/concepts/ai/Chat/types.d.ts +30 -0
  42. package/dist/@types/@ecme/views/concepts/ai/Chat/types.d.ts.map +1 -1
  43. package/dist/@types/base/configs/navigation.config/submenu/orcamento/relatorios/analiseVariacoes.submenu.d.ts +4 -0
  44. package/dist/@types/base/configs/navigation.config/submenu/orcamento/relatorios/analiseVariacoes.submenu.d.ts.map +1 -0
  45. package/dist/@types/base/configs/navigation.config/submenu/orcamento/relatorios/relatorios.submenu.d.ts.map +1 -1
  46. package/dist/base/assets/styles/init.css +33 -0
  47. package/dist/base/configs/navigation.config/submenu/orcamento/relatorios/analiseVariacoes.submenu.js +17 -0
  48. package/dist/base/configs/navigation.config/submenu/orcamento/relatorios/analiseVariacoes.submenu.js.map +1 -0
  49. package/dist/base/configs/navigation.config/submenu/orcamento/relatorios/relatorios.submenu.js +3 -1
  50. package/dist/base/configs/navigation.config/submenu/orcamento/relatorios/relatorios.submenu.js.map +1 -1
  51. package/lib/@ecme/components/template/OrbeAiWidget/OrbeAiWidget.tsx +4 -1
  52. package/lib/@ecme/components/ui/Alert/Alert.tsx +3 -0
  53. package/lib/@ecme/components/ui/Tooltip/Tooltip.tsx +2 -1
  54. package/lib/@ecme/components/view/ChatBox/ChatBox.tsx +2 -0
  55. package/lib/@ecme/components/view/ChatBox/components/ChatInput.tsx +5 -2
  56. package/lib/@ecme/locales/lang/ptBR/nav.ts +3 -0
  57. package/lib/@ecme/services/AiService.ts +9 -3
  58. package/lib/@ecme/views/concepts/ai/Chat/components/ChatView.tsx +49 -3
  59. package/lib/@ecme/views/concepts/ai/Chat/components/EsforcoRaciocinio.tsx +115 -0
  60. package/lib/@ecme/views/concepts/ai/Chat/hooks/useChatSend.ts +24 -3
  61. package/lib/@ecme/views/concepts/ai/Chat/store/esforcoStore.ts +25 -0
  62. package/lib/@ecme/views/concepts/ai/Chat/types.ts +32 -0
  63. package/lib/base/configs/navigation.config/submenu/orcamento/relatorios/analiseVariacoes.submenu.ts +17 -0
  64. package/lib/base/configs/navigation.config/submenu/orcamento/relatorios/relatorios.submenu.ts +2 -1
  65. package/package.json +2 -1
@@ -1,4 +1,5 @@
1
1
  import { usGenerativeChatStore } from '../store/generativeChatStore'
2
+ import { useEsforcoStore } from '../store/esforcoStore'
2
3
  import { resumeChat, streamChat } from '@/services/AiService'
3
4
  import { useAuth } from '@/auth'
4
5
  import dayjs from 'dayjs'
@@ -20,6 +21,8 @@ const useChatSend = () => {
20
21
  updateConversation,
21
22
  setIsTyping,
22
23
  } = usGenerativeChatStore()
24
+ // Vai em toda ida ao modelo: envio, aprovação e formulário.
25
+ const esforco = useEsforcoStore((state) => state.esforco)
23
26
 
24
27
  const creteMyMessage = (id: string, prompt: string) => {
25
28
  pushConversation(id, {
@@ -147,6 +150,12 @@ const useChatSend = () => {
147
150
  })
148
151
  break
149
152
 
153
+ case 'spreadsheet_data':
154
+ updateConversation(chatId, messageId, {
155
+ spreadsheet: evento.data as Conversation['spreadsheet'],
156
+ })
157
+ break
158
+
150
159
  case 'done':
151
160
  // O done é a fonte autoritativa do texto DESTA requisição —
152
161
  // se algum token se perdeu, ele corrige.
@@ -188,7 +197,13 @@ const useChatSend = () => {
188
197
  await consumirStream(
189
198
  chatId,
190
199
  messageId,
191
- (onEvent) => streamChat({ prompt, conversationId: chatId, onEvent }),
200
+ (onEvent) =>
201
+ streamChat({
202
+ prompt,
203
+ conversationId: chatId,
204
+ esforco,
205
+ onEvent,
206
+ }),
192
207
  { texto: '', tools: [] },
193
208
  )
194
209
  }
@@ -247,7 +262,12 @@ const useChatSend = () => {
247
262
  chatId,
248
263
  messageId,
249
264
  (onEvent) =>
250
- resumeChat({ approved, conversationId: chatId, onEvent }),
265
+ resumeChat({
266
+ approved,
267
+ conversationId: chatId,
268
+ esforco,
269
+ onEvent,
270
+ }),
251
271
  { texto: mensagem.content ?? '', tools: mensagem.tools ?? [] },
252
272
  )
253
273
  }
@@ -280,7 +300,8 @@ const useChatSend = () => {
280
300
  await consumirStream(
281
301
  chatId,
282
302
  messageId,
283
- (onEvent) => resumeChat({ dados, conversationId: chatId, onEvent }),
303
+ (onEvent) =>
304
+ resumeChat({ dados, conversationId: chatId, esforco, onEvent }),
284
305
  { texto: mensagem.content ?? '', tools: mensagem.tools ?? [] },
285
306
  )
286
307
  }
@@ -0,0 +1,25 @@
1
+ import { create } from 'zustand'
2
+ import { persist } from 'zustand/middleware'
3
+ import type { Esforco } from '../types'
4
+
5
+ type EsforcoState = {
6
+ esforco: Esforco
7
+ setEsforco: (payload: Esforco) => void
8
+ }
9
+
10
+ /**
11
+ * Nível de raciocínio escolhido no chat.
12
+ *
13
+ * Persistido no navegador, como tema e idioma: é preferência de uso, não dado
14
+ * da conversa. Por isso mora fora do `generativeChatStore`, que não persiste e
15
+ * é zerado quando o usuário da sessão muda.
16
+ */
17
+ export const useEsforcoStore = create<EsforcoState>()(
18
+ persist(
19
+ (set) => ({
20
+ esforco: 'medium',
21
+ setEsforco: (payload) => set(() => ({ esforco: payload })),
22
+ }),
23
+ { name: 'orbe-ai-esforco' },
24
+ ),
25
+ )
@@ -66,6 +66,15 @@ export type Conversation = {
66
66
  pendingApproval?: PendingApproval
67
67
  /** Preenchido quando o agente pausou pedindo os dados que faltam. */
68
68
  pendingInput?: PendingInput
69
+ /** Preenchido quando o agente gerou dados de planilha para download. */
70
+ spreadsheet?: {
71
+ titulo: string
72
+ abas: Array<{
73
+ nome: string
74
+ colunas: string[]
75
+ linhas: Record<string, unknown>[]
76
+ }>
77
+ }
69
78
  }
70
79
 
71
80
  /**
@@ -93,6 +102,21 @@ export type ChatEvent =
93
102
  is_error: boolean
94
103
  }
95
104
  }
105
+ | {
106
+ /**
107
+ * O agente gerou dados de planilha. O front gera o .xlsx no navegador
108
+ * (SheetJS) e mostra um botao de download.
109
+ */
110
+ type: 'spreadsheet_data'
111
+ data: {
112
+ titulo: string
113
+ abas: Array<{
114
+ nome: string
115
+ colunas: string[]
116
+ linhas: Record<string, unknown>[]
117
+ }>
118
+ }
119
+ }
96
120
  | {
97
121
  /**
98
122
  * O agente parou antes de uma operacao de escrita e espera decisao.
@@ -155,6 +179,14 @@ export type HistoryChat = Omit<ChatHistory, 'conversation'> & {
155
179
  conversation: HistoryMessage[]
156
180
  }
157
181
 
182
+ /**
183
+ * Nível de raciocínio do modelo, escolhido no chat e enviado em cada mensagem.
184
+ *
185
+ * Os valores são os do OpenRouter, sem tradução — o backend valida contra o
186
+ * mesmo conjunto (enum `Esforco`) e responde 422 para qualquer outro.
187
+ */
188
+ export type Esforco = 'minimal' | 'medium' | 'high' | 'max'
189
+
158
190
  /** Resumo de uma conversa, como vem do GET /ai/chat/conversations. */
159
191
  export type ConversationSummary = {
160
192
  id: string
@@ -0,0 +1,17 @@
1
+ import { NAV_ITEM_TYPE_ITEM } from '@/constants/navigation.constant'
2
+ import { ADMIN } from '@/constants/roles.constant'
3
+ import { NavigationTree } from '@/@types/navigation'
4
+
5
+ const analiseVariacoesSubmenu: NavigationTree = {
6
+ key: 'modules.orcamento.relatorios.analiseVariacoes',
7
+ path: '/orcamento/relatorio-variacoes',
8
+ title: 'Análise - Variações Relevantes',
9
+ translateKey: 'nav.modules.orcamento.relatorios.analiseVariacoes.title',
10
+ icon: 'chart',
11
+ type: NAV_ITEM_TYPE_ITEM,
12
+ forceShowTitle: true,
13
+ authority: [ADMIN],
14
+ subMenu: [],
15
+ }
16
+
17
+ export default analiseVariacoesSubmenu
@@ -2,12 +2,13 @@ import { NavigationTree } from '@/@types/navigation'
2
2
  import analiseDepartamentoSubmenu from './analiseDepartamento.submenu'
3
3
  import analiseContaContabilSubmenu from './analiseContaContabil.submenu'
4
4
  import analiseCentroDeCustosSubmenu from './analiseCentroDeCustos.submenu'
5
+ import analiseVariacoesSubmenu from './analiseVariacoes.submenu'
5
6
 
6
7
  const relatoriosSubmenu: NavigationTree[] = [
7
8
  analiseCentroDeCustosSubmenu,
8
9
  analiseContaContabilSubmenu,
9
10
  analiseDepartamentoSubmenu,
11
+ analiseVariacoesSubmenu,
10
12
  ]
11
13
 
12
14
  export default relatoriosSubmenu
13
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orbe-agro/client-core",
3
- "version": "5.6.324",
3
+ "version": "5.6.326",
4
4
  "description": "Biblioteca principal de componentes e utilidades para os microfrontends do Orbe Agro.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -117,6 +117,7 @@
117
117
  "simplebar-react": "^3.3.0",
118
118
  "swr": "^2.3.0",
119
119
  "tailwind-merge": "^2.5.2",
120
+ "xlsx": "^0.18.5",
120
121
  "yet-another-react-lightbox": "^3.21.7",
121
122
  "zod": "^3.23.8",
122
123
  "zustand": "^5.0.2"