nubot-lite 0.1.0 → 0.1.2
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.
- package/README.md +6 -5
- package/lib/api.mjs +6 -2
- package/lib/cloudflare.mjs +13 -12
- package/lib/commands/init.mjs +260 -251
- package/package.json +1 -1
- package/template/.claude/skills/nubot-lite/SKILL.md +7 -1
- package/template/panel/PANEL.md +1 -1
- package/template/panel/assets/AgendarDemoPage-Bn_BvTp1.js +1 -0
- package/template/panel/assets/{AgentDatasetsPage-D8vQhRWO.js → AgentDatasetsPage-wLtBtSB2.js} +2 -2
- package/template/panel/assets/AgentKnowledgeGroupsPage-BGHNFj-e.js +1 -0
- package/template/panel/assets/AgentListPage-F3ja9_o_.js +1 -0
- package/template/panel/assets/AgentQaTrainingPage-CojiU8_W.js +1 -0
- package/template/panel/assets/AiAgentWhatsappPage-Bn_BvTp1.js +1 -0
- package/template/panel/assets/BlogPage-Bn_BvTp1.js +1 -0
- package/template/panel/assets/BlogPostPage-Bn_BvTp1.js +1 -0
- package/template/panel/assets/CalculadoraTiempoRespuestaPage-Bn_BvTp1.js +1 -0
- package/template/panel/assets/{CampaignDetailPage-DFMctNEj.js → CampaignDetailPage-DUNnckvn.js} +1 -1
- package/template/panel/assets/CampaignsPage-CS60yZBd.js +1 -0
- package/template/panel/assets/ChannelSelector-C7R9zqrt.js +1 -0
- package/template/panel/assets/ChatbotParaWhatsappPage-Bn_BvTp1.js +1 -0
- package/template/panel/assets/ConfirmModal-B27OBQdm.js +1 -0
- package/template/panel/assets/ContactsPage-CvoDlFUN.js +14 -0
- package/template/panel/assets/CreateAgentPage-CbhikMY1.js +19 -0
- package/template/panel/assets/CreditLimitBanner-j72L7jgK.js +1 -0
- package/template/panel/assets/CrmParaWhatsappPage-Bn_BvTp1.js +1 -0
- package/template/panel/assets/DashboardPage-BGWkXY7W.js +1 -0
- package/template/panel/assets/{EmojiPicker-BToAe-MT.js → EmojiPicker-ByTMSXTj.js} +1 -1
- package/template/panel/assets/{EventTypesSettingsPage-DCedeQzM.js → EventTypesSettingsPage-CLpO1VBL.js} +1 -1
- package/template/panel/assets/GeneradorEnlacesPage-Bn_BvTp1.js +1 -0
- package/template/panel/assets/GeneradorQrWhatsappPage-Bn_BvTp1.js +1 -0
- package/template/panel/assets/{GeneralSettingsPage-B04ozcHb.js → GeneralSettingsPage-CY-5aGgL.js} +1 -1
- package/template/panel/assets/GoogleCalendarManagePage-oX7DuErV.js +1 -0
- package/template/panel/assets/{InvitationAcceptancePage-BPgtBFl5.js → InvitationAcceptancePage-BYllrAYs.js} +1 -1
- package/template/panel/assets/IrAlSitioPublico-Bn_BvTp1.js +1 -0
- package/template/panel/assets/LiteAiUsagePage-Dzm8jBL2.js +1 -0
- package/template/panel/assets/{LiteSetupPage-42rgAdnG.js → LiteSetupPage-CMSAur_e.js} +1 -1
- package/template/panel/assets/MarkdownRenderer-C3TD9KYa.js +3 -0
- package/template/panel/assets/MediaProcessingService-CG2DdSyN.js +1 -0
- package/template/panel/assets/NewCampaignPage-BfSEd075.js +1 -0
- package/template/panel/assets/OrdersConfigPage-BAKKaX0L.js +1 -0
- package/template/panel/assets/OrdersPage-CXiPOCXP.js +1 -0
- package/template/panel/assets/{PasswordStrengthIndicator-HZK_oU0W.js → PasswordStrengthIndicator-4h-Y0s2r.js} +1 -1
- package/template/panel/assets/PlantillaDetailPage-Bn_BvTp1.js +1 -0
- package/template/panel/assets/PlantillasIndexPage-Bn_BvTp1.js +1 -0
- package/template/panel/assets/PrivacyPolicy-Bn_BvTp1.js +1 -0
- package/template/panel/assets/{ProductManagementPage-DNM7DEgt.js → ProductManagementPage-CRkNTicv.js} +4 -4
- package/template/panel/assets/PublicFormPage-BxPxJ3Pq.js +1 -0
- package/template/panel/assets/QaForm-Px-cmakA.js +5 -0
- package/template/panel/assets/SelectPlanPage-Gyo5C1Hq.js +1 -0
- package/template/panel/assets/SignatureEditor-DIhmrXow.js +1 -0
- package/template/panel/assets/{TagSelector-ChoKzvjW.js → TagSelector-o6tVpRs9.js} +1 -1
- package/template/panel/assets/TagsSettingsPage-DT8MfW1H.js +2 -0
- package/template/panel/assets/TeamsPage-BuWuGxZo.js +1 -0
- package/template/panel/assets/WhatsappBusinessApiPage-Bn_BvTp1.js +1 -0
- package/template/panel/assets/WhatsappMultiagentePage-Bn_BvTp1.js +1 -0
- package/template/panel/assets/{account-D2ltXC_U.js → account-G3WXxisG.js} +1 -1
- package/template/panel/assets/{admin-lEgqZTsa.js → admin-CSMlOMR8.js} +1 -1
- package/template/panel/assets/{agent.service-BcAkMU7j.js → agent.service-BE2rJG_o.js} +1 -1
- package/template/panel/assets/{alert-dialog-D8P69s-m.js → alert-dialog-gzZZoAiu.js} +2 -2
- package/template/panel/assets/{alert-DI3GBLi1.js → alert-seLKo73M.js} +1 -1
- package/template/panel/assets/api-keys-BF33GS2N.js +1 -0
- package/template/panel/assets/{archive-LUe5bKi5.js → archive-CxUKRJwu.js} +1 -1
- package/template/panel/assets/{arrow-left-BeDdBs_Q.js → arrow-left-CI7mH7bD.js} +1 -1
- package/template/panel/assets/{arrow-up-BiBq8Pvx.js → arrow-up-DJzXCc8_.js} +1 -1
- package/template/panel/assets/{arrow-up-down-CaG2BONN.js → arrow-up-down-DkSCsCjR.js} +1 -1
- package/template/panel/assets/audit-slljESxh.js +1 -0
- package/template/panel/assets/{authService-Cbm8LdlJ.js → authService-CtvlzCDa.js} +1 -1
- package/template/panel/assets/{avatar-CILB1zwS.js → avatar-BXhSKQGY.js} +1 -1
- package/template/panel/assets/{billing-IVLNopU2.js → billing-Cy2XUBeY.js} +1 -1
- package/template/panel/assets/{brain-B9z7jZ7A.js → brain-BmrjUpsb.js} +1 -1
- package/template/panel/assets/{calendar-CIHhMjNy.js → calendar-Bu0aDtW1.js} +1 -1
- package/template/panel/assets/{calendar-days-BwJfOz8M.js → calendar-days-CXtOZxOF.js} +1 -1
- package/template/panel/assets/{card-DcKsxjXK.js → card-DdbmSh-v.js} +1 -1
- package/template/panel/assets/{checkbox-pcbjC0d3.js → checkbox-CuJh5AMO.js} +1 -1
- package/template/panel/assets/{chevrons-up-down-DC-BWTrj.js → chevrons-up-down-DNNdNhV8.js} +1 -1
- package/template/panel/assets/{circle-check-big-DzPo5zZX.js → circle-check-big-BOZQ_2Kv.js} +1 -1
- package/template/panel/assets/{circle-x-BwMKIs8b.js → circle-x-decmm7ip.js} +1 -1
- package/template/panel/assets/cloud-B3m0_VpL.js +1 -0
- package/template/panel/assets/{code-BMAyHFJe.js → code-C-UH-ZD-.js} +1 -1
- package/template/panel/assets/{cog-M7j64wa2.js → cog-BS-_-U4F.js} +1 -1
- package/template/panel/assets/{collapsible-B22t1J-V.js → collapsible-Ce_8EeFJ.js} +1 -1
- package/template/panel/assets/{command-COdSmSIB.js → command-aHRTWaYV.js} +1 -1
- package/template/panel/assets/connectionsService-BJg4S1e9.js +1 -0
- package/template/panel/assets/contactsApi-DI5dcMLo.js +1 -0
- package/template/panel/assets/creditErrors-DSbswjsG.js +1 -0
- package/template/panel/assets/{database-C1qvt3Py.js → database-Brb7Omak.js} +1 -1
- package/template/panel/assets/{datapath-C12uI_pT.js → datapath-CHeKabeh.js} +1 -1
- package/template/panel/assets/{datetime-BuZosCVk.js → datetime-D72Uxhjs.js} +1 -1
- package/template/panel/assets/{download-CiVQHPeB.js → download-CyfdxFCW.js} +1 -1
- package/template/panel/assets/{ellipsis-CMEJnUfK.js → ellipsis-GLu0u4ze.js} +1 -1
- package/template/panel/assets/{ellipsis-vertical-DTqbEYYp.js → ellipsis-vertical-CskGwbgN.js} +1 -1
- package/template/panel/assets/email-inbox-kyJ2qML5.js +1 -0
- package/template/panel/assets/es-BDgg6unH.js +1 -0
- package/template/panel/assets/external-link-w7K66ae2.js +1 -0
- package/template/panel/assets/{eye-HfQCUjxJ.js → eye-CR5C6hVv.js} +1 -1
- package/template/panel/assets/{eye-off-v1Z_lKS0.js → eye-off-CBiJXw4j.js} +1 -1
- package/template/panel/assets/facebook-D0SQMea2.js +1 -0
- package/template/panel/assets/{file-DMzjdlTL.js → file-CTZ8-xmL.js} +1 -1
- package/template/panel/assets/file-braces-54MsOnzo.js +1 -0
- package/template/panel/assets/file-spreadsheet-DpekIaV8.js +1 -0
- package/template/panel/assets/{folder-D0GKakGp.js → folder-DxTHNhQ_.js} +1 -1
- package/template/panel/assets/{folder-open-DQFc4qTJ.js → folder-open-BM4rA96e.js} +1 -1
- package/template/panel/assets/format-BG1mN6C0.js +1 -0
- package/template/panel/assets/{grip-vertical-FN-eTC2C.js → grip-vertical-CS-dU0tJ.js} +1 -1
- package/template/panel/assets/{hash-BoTE56iw.js → hash-ByrjK6gt.js} +1 -1
- package/template/panel/assets/{help-center-B1MAIBWA.js → help-center-fmvvoAkD.js} +1 -1
- package/template/panel/assets/{history-DhHayxUg.js → history-97D1GT_9.js} +1 -1
- package/template/panel/assets/house-CXew5LB-.js +1 -0
- package/template/panel/assets/{index-DsyZ_FlA.js → index-43NA2pdZ.js} +23 -23
- package/template/panel/assets/index-BG59-Kyv.js +6 -0
- package/template/panel/assets/{index-DUnioqCT.js → index-BGvtgHY3.js} +1 -1
- package/template/panel/assets/index-BL76lyPt.js +2 -0
- package/template/panel/assets/index-BUA9lP4J.js +1 -0
- package/template/panel/assets/index-Bfvq4Q3v.js +1 -0
- package/template/panel/assets/index-CK793Wzl.css +1 -0
- package/template/panel/assets/{index-BTxe6gLJ.js → index-ChrvveQm.js} +1 -1
- package/template/panel/assets/index-CoJIvJ6y.js +1 -0
- package/template/panel/assets/{index-CMEeV9dO.js → index-CsV1u-Y7.js} +2 -2
- package/template/panel/assets/{index-BiSc3WD9.js → index-DIxON2Dm.js} +1 -1
- package/template/panel/assets/index-DtoSJTyl.js +1 -0
- package/template/panel/assets/index-FBuxpbGF.js +36 -0
- package/template/panel/assets/index-YR5X3nd4.js +1 -0
- package/template/panel/assets/{instagram-CC7iYt7V.js → instagram-Bm17x-Fs.js} +1 -1
- package/template/panel/assets/interactiveLimits-C7Sx7s9W.js +1 -0
- package/template/panel/assets/landing-CEUFhLJ9.js +1 -0
- package/template/panel/assets/{layout-grid-Cm6hfBWZ.js → layout-grid-DN-t2Wjd.js} +1 -1
- package/template/panel/assets/{list-BKc6EXnV.js → list-B0uLKf1b.js} +1 -1
- package/template/panel/assets/{map-pin-CPmcofD3.js → map-pin-COYHwobx.js} +1 -1
- package/template/panel/assets/{maximize-2-WdbM7Kdx.js → maximize-2-SbmXBBYe.js} +1 -1
- package/template/panel/assets/mediaLimits-CAYdWqeQ.js +1 -0
- package/template/panel/assets/mediaValidation-Bg0xHQrv.js +1 -0
- package/template/panel/assets/message-circle-tNSzOeOW.js +1 -0
- package/template/panel/assets/{message-square-Dfn16oHc.js → message-square-B1_OirdW.js} +1 -1
- package/template/panel/assets/{meta-templates-C7yEjSOI.js → meta-templates-hhDdxBOR.js} +1 -1
- package/template/panel/assets/metadataSchemasApi-BmJko2eC.js +1 -0
- package/template/panel/assets/{mic-CT4vyzLZ.js → mic-ClFq9hMZ.js} +1 -1
- package/template/panel/assets/minus-vh4a51Mn.js +1 -0
- package/template/panel/assets/{music-Cu8AQMFp.js → music-CgtkroYi.js} +1 -1
- package/template/panel/assets/{page-components-o2TF52HV.js → page-components-DXOKtt_M.js} +1 -1
- package/template/panel/assets/{pages-Cj5Qd1QO.js → pages-BcYbyh_-.js} +1 -1
- package/template/panel/assets/{pages-B7digtXi.js → pages-BuibyrnC.js} +1 -1
- package/template/panel/assets/{pages-Dw7dvmaS.js → pages-CGXCBdff.js} +1 -1
- package/template/panel/assets/paperclip-DVRbzE7C.js +1 -0
- package/template/panel/assets/{pen-line-DLnhkIuw.js → pen-line-Cr0YFjAs.js} +1 -1
- package/template/panel/assets/{pencil-Cx8u1N8t.js → pencil-aqjc7AWb.js} +1 -1
- package/template/panel/assets/{popover-MyuU-yAK.js → popover-cWIhNmod.js} +1 -1
- package/template/panel/assets/{power-CdR2OkIX.js → power-CVFzhVJx.js} +1 -1
- package/template/panel/assets/{product.service-CRLZOQsr.js → product.service-FClit10f.js} +1 -1
- package/template/panel/assets/products.types-nZIsk2w8.js +1 -0
- package/template/panel/assets/proxy-CvX2KM2u.js +1 -0
- package/template/panel/assets/{save-Dua2yhWl.js → save-mwkHDnDL.js} +1 -1
- package/template/panel/assets/scroll-area-CSCo4HHB.js +1 -0
- package/template/panel/assets/{select-DlB_BbfM.js → select-DCY_lg9j.js} +1 -1
- package/template/panel/assets/{send-Dxmdupsl.js → send-DBQH77K9.js} +1 -1
- package/template/panel/assets/{separator-CPT3uVRM.js → separator-DznqP68l.js} +1 -1
- package/template/panel/assets/{settings-2-C-c8ECWW.js → settings-2-PhKPMrsj.js} +1 -1
- package/template/panel/assets/shield-alert-Fv3j9Wbv.js +1 -0
- package/template/panel/assets/{skeleton-B0zh8s_y.js → skeleton-CN6xlRXP.js} +1 -1
- package/template/panel/assets/{slider-CY71MXOW.js → slider-D0QB_Lme.js} +1 -1
- package/template/panel/assets/{square-BuGqLxJB.js → square-Dm5VC71z.js} +1 -1
- package/template/panel/assets/{square-pen-CJajoyrm.js → square-pen-Dbn7xmc-.js} +1 -1
- package/template/panel/assets/{star-Cuegk1GF.js → star-BMD3HmS6.js} +1 -1
- package/template/panel/assets/stat-card-W7s_-fHW.js +1 -0
- package/template/panel/assets/storage.api-C0ZJBoSz.js +20 -0
- package/template/panel/assets/{switch-ODBa0fCT.js → switch-C7XmAU1c.js} +1 -1
- package/template/panel/assets/{table-CvSELOPi.js → table-7NGq0kRw.js} +1 -1
- package/template/panel/assets/{tabs-DqXhuAr6.js → tabs-BGCKrmVw.js} +1 -1
- package/template/panel/assets/{tags-By_tlh_r.js → tags-HU2fuPFH.js} +1 -1
- package/template/panel/assets/{target-DEuCdeUI.js → target-CG_g4_Fj.js} +1 -1
- package/template/panel/assets/{textarea-BYtcLsMD.js → textarea-B1anutjq.js} +1 -1
- package/template/panel/assets/{ticket-CWba7G1i.js → ticket-CHs1Xojr.js} +1 -1
- package/template/panel/assets/{trash-2-Du2vmQCH.js → trash-2-D_kmHMwn.js} +1 -1
- package/template/panel/assets/{trending-up-Ba4HSvuW.js → trending-up-BnHeLWFs.js} +1 -1
- package/template/panel/assets/{upload-C7TwpdyA.js → upload-CQg4_W5r.js} +1 -1
- package/template/panel/assets/{useAiAgentsQuery-Bm6aRHKj.js → useAiAgentsQuery-CXo6TmU6.js} +1 -1
- package/template/panel/assets/useFunnelStats-Bk8wTET5.js +1 -0
- package/template/panel/assets/useFunnelsQuery-vDrahaDr.js +1 -0
- package/template/panel/assets/{useInfiniteQuery-BXUM1Z9V.js → useInfiniteQuery-D0sFT2K2.js} +1 -1
- package/template/panel/assets/{useMutation-a5tIBvQY.js → useMutation-0ypmz8SO.js} +1 -1
- package/template/panel/assets/useOrgSyncedFetch-FSgwRhpR.js +1 -0
- package/template/panel/assets/usePipelineBoardQuery-BysscZXI.js +9 -0
- package/template/panel/assets/{useUploadConfig-BuiF0X-3.js → useUploadConfig-CvVmSc6S.js} +1 -1
- package/template/panel/assets/{user-DwCALzIG.js → user-l48WDfDH.js} +1 -1
- package/template/panel/assets/{user-plus-BiUjcHil.js → user-plus-CWaaUP-O.js} +1 -1
- package/template/panel/assets/{video-VfwKgB6z.js → video-CILE66CA.js} +1 -1
- package/template/panel/assets/{volume-2-C5DMdOVq.js → volume-2-DfFqN0dw.js} +1 -1
- package/template/panel/assets/wrench-Dcbk4scY.js +1 -0
- package/template/panel/index.html +2 -2
- package/template/panel/version.json +2 -2
- package/template/worker/migrations/0006_ai_usage.sql +33 -0
- package/template/worker/migrations/0007_channels.sql +18 -0
- package/template/worker/src/agent/pricing.ts +37 -0
- package/template/worker/src/agent/prompt.ts +137 -134
- package/template/worker/src/agent/run.ts +350 -243
- package/template/worker/src/agent/sandbox.ts +2 -2
- package/template/worker/src/agent/tools.ts +463 -463
- package/template/worker/src/channels/accounts.ts +177 -0
- package/template/worker/src/channels/zernio.ts +161 -148
- package/template/worker/src/inbox/contacts.ts +2 -0
- package/template/worker/src/inbox/store.ts +199 -187
- package/template/worker/src/index.ts +2 -0
- package/template/worker/src/nubot/account.ts +163 -178
- package/template/worker/src/nubot/ai-usage.ts +197 -0
- package/template/worker/src/nubot/channels.ts +159 -0
- package/template/worker/src/nubot/contacts.ts +387 -386
- package/template/worker/src/nubot/funnels.ts +672 -670
- package/template/worker/src/nubot/inbox.ts +623 -616
- package/template/worker/src/nubot/index.ts +127 -122
- package/template/worker/src/nubot/mappers.ts +12 -5
- package/template/worker/src/routes/channels.ts +13 -0
- package/template/worker/src/routes/system.ts +110 -100
- package/template/worker/src/webhooks/zernio.ts +154 -125
- package/template/panel/assets/AgendarDemoPage-DOiS40FL.js +0 -1
- package/template/panel/assets/AgentKnowledgeGroupsPage-DEPS1lsk.js +0 -1
- package/template/panel/assets/AgentListPage-DqY9rze5.js +0 -1
- package/template/panel/assets/AgentQaTrainingPage-Ecis7xoc.js +0 -1
- package/template/panel/assets/AiAgentWhatsappPage-DOiS40FL.js +0 -1
- package/template/panel/assets/AiMetricsPage-DEPS1lsk.js +0 -1
- package/template/panel/assets/BlogPage-DOiS40FL.js +0 -1
- package/template/panel/assets/BlogPostPage-DOiS40FL.js +0 -1
- package/template/panel/assets/CalculadoraTiempoRespuestaPage-DOiS40FL.js +0 -1
- package/template/panel/assets/CampaignsPage-CLRaXGlj.js +0 -1
- package/template/panel/assets/ChannelSelector-q9tTirNo.js +0 -1
- package/template/panel/assets/ChatbotParaWhatsappPage-DOiS40FL.js +0 -1
- package/template/panel/assets/ConfirmModal-W7VUI3Z_.js +0 -1
- package/template/panel/assets/ContactsPage-CsOFsOPw.js +0 -14
- package/template/panel/assets/CreateAgentPage-Ifxx6_UX.js +0 -19
- package/template/panel/assets/CreditLimitBanner-J49rSVEn.js +0 -1
- package/template/panel/assets/CrmParaWhatsappPage-DOiS40FL.js +0 -1
- package/template/panel/assets/DashboardPage-3Viy83dd.js +0 -1
- package/template/panel/assets/GeneradorEnlacesPage-DOiS40FL.js +0 -1
- package/template/panel/assets/GeneradorQrWhatsappPage-DOiS40FL.js +0 -1
- package/template/panel/assets/IrAlSitioPublico-DOiS40FL.js +0 -1
- package/template/panel/assets/MediaProcessingService-glHGiE_o.js +0 -1
- package/template/panel/assets/NewCampaignPage-Cw99m3W8.js +0 -1
- package/template/panel/assets/OrdersConfigPage-B6BfM3lf.js +0 -1
- package/template/panel/assets/OrdersPage-Du7CJjty.js +0 -1
- package/template/panel/assets/PlantillaDetailPage-DOiS40FL.js +0 -1
- package/template/panel/assets/PlantillasIndexPage-DOiS40FL.js +0 -1
- package/template/panel/assets/PrivacyPolicy-DOiS40FL.js +0 -1
- package/template/panel/assets/PublicFormPage-DDb4OXEM.js +0 -1
- package/template/panel/assets/QaForm-BDboHNKo.js +0 -5
- package/template/panel/assets/SelectPlanPage-DALaf8E5.js +0 -1
- package/template/panel/assets/TagsSettingsPage-DYCKveQq.js +0 -2
- package/template/panel/assets/TeamsPage-DPUcRdlh.js +0 -1
- package/template/panel/assets/WhatsappBusinessApiPage-DOiS40FL.js +0 -1
- package/template/panel/assets/WhatsappMultiagentePage-DOiS40FL.js +0 -1
- package/template/panel/assets/api-keys-B0UQNR5E.js +0 -1
- package/template/panel/assets/audit-BrdHcTNl.js +0 -1
- package/template/panel/assets/connections-Dqwd01UI.js +0 -1
- package/template/panel/assets/connectionsService-BsJf8pFz.js +0 -3
- package/template/panel/assets/contactsApi-B851NME_.js +0 -1
- package/template/panel/assets/creditErrors-CrpkwwUI.js +0 -1
- package/template/panel/assets/email-inbox-LbGeQCty.js +0 -1
- package/template/panel/assets/es-BG480iA5.js +0 -1
- package/template/panel/assets/facebook-RxMBweMB.js +0 -1
- package/template/panel/assets/index-B183O0S5.js +0 -1
- package/template/panel/assets/index-BJCPaymI.css +0 -1
- package/template/panel/assets/index-BtxJGfLL.js +0 -6
- package/template/panel/assets/index-Bz-ixwph.js +0 -1
- package/template/panel/assets/index-CjQSv8hF.js +0 -2
- package/template/panel/assets/index-D3vkHHjD.js +0 -9
- package/template/panel/assets/index-D4WhIkMN.js +0 -1
- package/template/panel/assets/interactiveLimits-CfLJ1O4_.js +0 -1
- package/template/panel/assets/landing-If3oVsS0.js +0 -1
- package/template/panel/assets/mediaValidation-BR-ZOj5w.js +0 -1
- package/template/panel/assets/minus-CyVEzdqL.js +0 -1
- package/template/panel/assets/products.types-46xSxBS8.js +0 -1
- package/template/panel/assets/scroll-area-CavEOIyz.js +0 -1
- package/template/panel/assets/shield-alert-04pSYngI.js +0 -1
- package/template/panel/assets/storage.api-CFU3KJNp.js +0 -20
- package/template/panel/assets/useFunnelStats-tvjpmWIC.js +0 -1
|
@@ -1,125 +1,154 @@
|
|
|
1
|
-
// Webhook de Zernio. Zernio reintenta si no recibe 2xx en 5 s y puede entregar
|
|
2
|
-
// el mismo evento dos veces: aquí solo se guarda, se avisa y se delega el agente.
|
|
3
|
-
|
|
4
|
-
import type { Env } from "../env";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"message.
|
|
19
|
-
"message.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const inbound = msg.direction === "incoming";
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
const
|
|
112
|
-
if (
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
1
|
+
// Webhook de Zernio. Zernio reintenta si no recibe 2xx en 5 s y puede entregar
|
|
2
|
+
// el mismo evento dos veces: aquí solo se guarda, se avisa y se delega el agente.
|
|
3
|
+
|
|
4
|
+
import type { Env } from "../env";
|
|
5
|
+
import { channelByAccount, isPlatform, PLATFORM_NAMES, saveChannel, type Platform } from "../channels/accounts";
|
|
6
|
+
import { verifyZernioSignature, type ZernioMessage, type ZernioWebhookPayload } from "../channels/zernio";
|
|
7
|
+
import {
|
|
8
|
+
claimWebhookEvent,
|
|
9
|
+
insertMessage,
|
|
10
|
+
updateMessageStatus,
|
|
11
|
+
upsertContact,
|
|
12
|
+
upsertConversation,
|
|
13
|
+
} from "../inbox/store";
|
|
14
|
+
import { notifyPanel } from "../do/inbox-hub";
|
|
15
|
+
import { fromZernio, rememberPublicOrigin } from "../media/files";
|
|
16
|
+
|
|
17
|
+
const STATUS_EVENTS: Record<string, string> = {
|
|
18
|
+
"message.delivered": "delivered",
|
|
19
|
+
"message.read": "read",
|
|
20
|
+
"message.failed": "failed",
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
let knownOrigin: string | null = null;
|
|
24
|
+
|
|
25
|
+
export async function handleZernioWebhook(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
|
|
26
|
+
const raw = await request.text();
|
|
27
|
+
const signature = request.headers.get("X-Zernio-Signature");
|
|
28
|
+
if (!(await verifyZernioSignature(raw, signature, env.ZERNIO_WEBHOOK_SECRET))) {
|
|
29
|
+
return new Response("firma inválida", { status: 401 });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
let payload: ZernioWebhookPayload;
|
|
33
|
+
try {
|
|
34
|
+
payload = JSON.parse(raw);
|
|
35
|
+
} catch {
|
|
36
|
+
return new Response("JSON inválido", { status: 400 });
|
|
37
|
+
}
|
|
38
|
+
if (payload.test) return Response.json({ ok: true, test: true });
|
|
39
|
+
|
|
40
|
+
// Zernio llama a la dirección pública del Worker: sirve para armar enlaces a archivos fuera de una petición.
|
|
41
|
+
const origin = new URL(request.url).origin;
|
|
42
|
+
if (origin !== knownOrigin) {
|
|
43
|
+
knownOrigin = origin;
|
|
44
|
+
ctx.waitUntil(rememberPublicOrigin(env, origin));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const now = Date.now();
|
|
48
|
+
const eventId = request.headers.get("X-Zernio-Event-Id") ?? payload.id;
|
|
49
|
+
if (!(await claimWebhookEvent(env.DB, eventId, payload.event, now))) {
|
|
50
|
+
return Response.json({ ok: true, duplicate: true });
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (payload.event === "message.received" || payload.event === "message.sent") {
|
|
54
|
+
await ingestMessage(payload, env, ctx, now);
|
|
55
|
+
} else if (payload.event in STATUS_EVENTS && payload.message) {
|
|
56
|
+
const error = payload.error ? (payload.error.explanation ?? payload.error.message ?? payload.error.title ?? null) : null;
|
|
57
|
+
const updated = await updateMessageStatus(env.DB, payload.message.platformMessageId, STATUS_EVENTS[payload.event], error);
|
|
58
|
+
if (updated) {
|
|
59
|
+
ctx.waitUntil(
|
|
60
|
+
notifyPanel(env, {
|
|
61
|
+
type: "message:update",
|
|
62
|
+
conversationId: updated.conversation_id,
|
|
63
|
+
messageId: updated.id,
|
|
64
|
+
}),
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return Response.json({ ok: true });
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Prefijo de la identidad del cliente en Instagram y Facebook: su id solo es único dentro de cada red. */
|
|
72
|
+
const ID_PREFIX: Record<Platform, string> = { whatsapp: "", instagram: "ig:", facebook: "fb:" };
|
|
73
|
+
|
|
74
|
+
/** Quién es el cliente. En un mensaje saliente el remitente es la empresa: el cliente es el participante. */
|
|
75
|
+
function customerOf(payload: ZernioWebhookPayload, msg: ZernioMessage, platform: Platform) {
|
|
76
|
+
const inbound = msg.direction === "incoming";
|
|
77
|
+
if (platform === "whatsapp") {
|
|
78
|
+
return inbound
|
|
79
|
+
? {
|
|
80
|
+
externalId: msg.sender.businessScopedUserId ?? msg.sender.phoneNumber ?? msg.sender.id,
|
|
81
|
+
phone: msg.sender.phoneNumber ?? null,
|
|
82
|
+
name: msg.sender.name ?? null,
|
|
83
|
+
}
|
|
84
|
+
: {
|
|
85
|
+
externalId: payload.conversation?.participantId ?? msg.conversationId,
|
|
86
|
+
phone: null,
|
|
87
|
+
name: payload.conversation?.participantName ?? null,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
const id = inbound ? msg.sender.id : (payload.conversation?.participantId ?? msg.conversationId);
|
|
91
|
+
const username = inbound ? msg.sender.username : payload.conversation?.participantUsername;
|
|
92
|
+
const name = (inbound ? msg.sender.name : payload.conversation?.participantName) ?? (username ? `@${username}` : null);
|
|
93
|
+
return {
|
|
94
|
+
externalId: `${ID_PREFIX[platform]}${id}`,
|
|
95
|
+
phone: null,
|
|
96
|
+
name,
|
|
97
|
+
metadata: username ? { [platform]: `@${username}` } : undefined,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** La cuenta por la que llegó el mensaje. Si no estaba registrada (por ejemplo, el número de WhatsApp), se registra. */
|
|
102
|
+
async function channelFor(env: Env, platform: Platform, accountId: string, account: ZernioWebhookPayload["account"], now: number) {
|
|
103
|
+
const known = await channelByAccount(env, accountId);
|
|
104
|
+
if (known) return known;
|
|
105
|
+
return saveChannel(env, { platform, accountId, name: account?.displayName ?? PLATFORM_NAMES[platform], username: account?.username }, now);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
async function ingestMessage(payload: ZernioWebhookPayload, env: Env, ctx: ExecutionContext, now: number) {
|
|
109
|
+
const msg = payload.message;
|
|
110
|
+
if (!msg || !isPlatform(msg.platform)) return;
|
|
111
|
+
const accountId = payload.account?.accountId ?? payload.account?.id;
|
|
112
|
+
if (!accountId) return;
|
|
113
|
+
const channel = await channelFor(env, msg.platform, accountId, payload.account, now);
|
|
114
|
+
// Una cuenta desconectada desde el panel ya no entra a la bandeja.
|
|
115
|
+
if (!channel.active) return;
|
|
116
|
+
|
|
117
|
+
const inbound = msg.direction === "incoming";
|
|
118
|
+
const contactId = await upsertContact(env.DB, customerOf(payload, msg, msg.platform), now);
|
|
119
|
+
const conversation = await upsertConversation(
|
|
120
|
+
env.DB,
|
|
121
|
+
{ contactId, zernioConversationId: msg.conversationId, zernioAccountId: accountId, channel: msg.platform },
|
|
122
|
+
now,
|
|
123
|
+
);
|
|
124
|
+
const saved = await insertMessage(
|
|
125
|
+
env.DB,
|
|
126
|
+
{
|
|
127
|
+
conversationId: conversation.id,
|
|
128
|
+
// Saliente que no salió de Nubot Lite: lo escribió un asesor desde la app de WhatsApp Business, Instagram o Facebook.
|
|
129
|
+
senderType: inbound ? "contact" : "agent",
|
|
130
|
+
content: msg.text,
|
|
131
|
+
attachments: fromZernio(msg.attachments),
|
|
132
|
+
status: inbound ? "received" : "sent",
|
|
133
|
+
externalId: msg.platformMessageId,
|
|
134
|
+
},
|
|
135
|
+
now,
|
|
136
|
+
);
|
|
137
|
+
if (!saved) return;
|
|
138
|
+
|
|
139
|
+
const stub = env.CONVERSATION.get(env.CONVERSATION.idFromName(conversation.id));
|
|
140
|
+
if (msg.attachments.length > 0) {
|
|
141
|
+
ctx.waitUntil(stub.copyMedia({ id: saved.id, conversationId: conversation.id }, msg.attachments));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
ctx.waitUntil(
|
|
145
|
+
notifyPanel(env, {
|
|
146
|
+
type: "message:new",
|
|
147
|
+
conversationId: conversation.id,
|
|
148
|
+
message: saved,
|
|
149
|
+
}),
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
// En standby otra app tiene la conversación (por ejemplo la bandeja de la página): el agente no podría responder.
|
|
153
|
+
if (inbound && conversation.status === "ai" && !msg.metadata?.standby) await stub.enqueue(conversation.id, now);
|
|
154
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{aA as e}from"./index-DsyZ_FlA.js";import"./recharts-DrC5kNsx.js";export{e as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{aA as e}from"./index-DsyZ_FlA.js";import"./recharts-DrC5kNsx.js";export{e as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e,B as h,l as m,a3 as O,a4 as q,a5 as J,a6 as Z,a7 as _,o as H,y as U,r as c,J as S,ac as W,b as X,t as k,u as ee,h as se,a0 as ae,T as z,v as M,at as te,x as E,R as re,Y as le,I as ie,aC as oe,a2 as ne,a9 as ce}from"./index-DsyZ_FlA.js";import{b as o}from"./recharts-DrC5kNsx.js";import{a as K}from"./agent.service-BcAkMU7j.js";import{u as de}from"./useAiAgentsQuery-Bm6aRHKj.js";import{P as xe,a as me,b as he}from"./page-components-o2TF52HV.js";import{S as pe,a as ue,b as ge,c as be,d as R}from"./select-DlB_BbfM.js";import{L as je}from"./layout-grid-Cm6hfBWZ.js";import{L as ve}from"./list-BKc6EXnV.js";import{T as fe,a as Ne,b as $,c as N,d as we,e as w}from"./table-CvSELOPi.js";import{A as B,b as F}from"./alert-DI3GBLi1.js";import{C as ke}from"./checkbox-pcbjC0d3.js";import{T as I}from"./trash-2-Du2vmQCH.js";import{A as G}from"./archive-LUe5bKi5.js";import{D as ye}from"./database-C1qvt3Py.js";import{u as Ce,h as Ae}from"./creditErrors-CrpkwwUI.js";import{P as Q}from"./power-CdR2OkIX.js";import{B as Se}from"./brain-B9z7jZ7A.js";import"./index-KbFmSzBE.js";const Te=({mode:l,onChange:p})=>e.jsxs("div",{className:"flex items-center gap-1 bg-slate-100 dark:bg-slate-800 p-1 rounded-xl border border-slate-200 dark:border-slate-700",children:[e.jsxs(h,{variant:"ghost",size:"sm",onClick:()=>p("cards"),className:m("h-8 px-3 rounded-lg flex items-center gap-2 transition-all",l==="cards"?"bg-white dark:bg-slate-900 shadow-sm text-primary":"text-slate-500 hover:text-slate-900 dark:hover:text-white"),children:[e.jsx(je,{className:"w-4 h-4"}),e.jsx("span",{className:"text-xs font-bold uppercase tracking-wider",children:"Fichas"})]}),e.jsxs(h,{variant:"ghost",size:"sm",onClick:()=>p("table"),className:m("h-8 px-3 rounded-lg flex items-center gap-2 transition-all",l==="table"?"bg-white dark:bg-slate-900 shadow-sm text-primary":"text-slate-500 hover:text-slate-900 dark:hover:text-white"),children:[e.jsx(ve,{className:"w-4 h-4"}),e.jsx("span",{className:"text-xs font-bold uppercase tracking-wider",children:"Tabla"})]})]});function Le({agentId:l,agentName:p,open:u,onOpenChange:v,onDeleted:y}){const[t,T]=o.useState(null),[n,L]=o.useState(!1),[d,C]=o.useState(null),[g,f]=o.useState(!1),[i,A]=o.useState(!1);o.useEffect(()=>{if(!u||!l){T(null),C(null);return}(async()=>{L(!0),C(null),A(!1);try{const{data:x}=await X.get(`/ai-agents/delete-preview/${l}`);T(x)}catch(x){C(x.response?.data?.message||"No se pudo obtener la vista previa de eliminación.")}finally{L(!1)}})()},[u,l]);const r=t&&t.totalSessions===0,P=async()=>{if(l){f(!0);try{await K.deleteAgent(l,!!(r&&i)),k.success(r?i?"Agente y su dataset eliminados — 1 crédito liberado":"Agente eliminado permanentemente — 1 crédito liberado":"Agente archivado — 1 crédito de Agentes IA liberado"),y()}catch(b){const x=b.response?.data?.message||b.message||"No se pudo eliminar el agente. Es posible que tenga sesiones o tickets asociados.";k.error(x)}finally{f(!1)}}};return e.jsx(O,{open:u,onOpenChange:v,children:e.jsxs(q,{className:"sm:max-w-[480px]",children:[e.jsxs(J,{children:[e.jsxs(Z,{className:"flex items-center gap-2",children:[r?e.jsx(I,{className:"h-5 w-5 text-rose-500"}):e.jsx(G,{className:"h-5 w-5 text-amber-500"}),r?"Eliminar Agente IA":"Archivar Agente IA"]}),e.jsx(_,{children:p?e.jsxs(e.Fragment,{children:["Estás a punto de ",r?"eliminar permanentemente":"archivar"," el agente"," ",e.jsxs("span",{className:"font-semibold text-slate-700 dark:text-slate-200",children:['"',p,'"']})]}):`Estás a punto de ${r?"eliminar permanentemente":"archivar"} este agente`})]}),e.jsxs("div",{className:"py-3 space-y-4",children:[n&&e.jsxs("div",{className:"flex items-center justify-center py-6",children:[e.jsx(H,{className:"h-6 w-6 animate-spin text-slate-400"}),e.jsx("span",{className:"ml-2 text-sm text-slate-500",children:"Analizando agente..."})]}),d&&e.jsxs(B,{variant:"destructive",children:[e.jsx(U,{className:"h-4 w-4"}),e.jsx(F,{children:d})]}),t&&!n&&(r?e.jsxs(B,{className:"border-rose-200 bg-rose-50 dark:border-rose-800 dark:bg-rose-950",children:[e.jsx(I,{className:"h-4 w-4 text-rose-600"}),e.jsxs(F,{className:"space-y-2 text-rose-800 dark:text-rose-200",children:[e.jsx("p",{className:"font-medium",children:"El agente será eliminado permanentemente y se liberará 1 crédito de Agentes IA. No hay sesiones ni historial asociado."}),e.jsxs("div",{className:"flex flex-wrap gap-2 mt-2",children:[e.jsxs(c,{variant:"outline",className:"text-xs bg-rose-100 text-rose-700 border-rose-300",children:[e.jsx(S,{className:"w-3 h-3 mr-1"}),t.status==="active"?"Activo":"Inactivo"]}),e.jsx(c,{variant:"outline",className:"text-xs bg-slate-50 text-slate-600 border-slate-200",children:"Sin sesiones — eliminación permanente"})]})]})]}):e.jsxs(B,{className:"border-amber-200 bg-amber-50 dark:border-amber-800 dark:bg-amber-950",children:[e.jsx(G,{className:"h-4 w-4 text-amber-600"}),e.jsxs(F,{className:"space-y-2 text-amber-800 dark:text-amber-200",children:[e.jsx("p",{className:"font-medium",children:"El agente será archivado y se liberará 1 crédito de Agentes IA. El historial de sesiones y conversaciones se conservará."}),e.jsxs("div",{className:"flex flex-wrap gap-2 mt-2",children:[e.jsxs(c,{variant:"outline",className:"text-xs bg-amber-100 text-amber-700 border-amber-300",children:[e.jsx(S,{className:"w-3 h-3 mr-1"}),t.status==="active"?"Activo":"Inactivo"]}),e.jsxs(c,{variant:"outline",className:"text-xs bg-amber-100 text-amber-700 border-amber-300",children:[t.totalSessions," sesiones (",t.activeSessions," activas)"]})]})]})]})),t&&!n&&r&&t.hasKnowledgeBox&&e.jsxs("label",{className:"flex items-start gap-3 rounded-md border border-slate-200 dark:border-slate-700 p-3 cursor-pointer",children:[e.jsx(ke,{checked:i,onCheckedChange:b=>A(b===!0),className:"mt-0.5"}),e.jsxs("div",{className:"text-sm",children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-medium",children:[e.jsx(ye,{className:"h-3.5 w-3.5 text-slate-500"}),"También eliminar su dataset (",t.knowledgeSourceCount??0," ",(t.knowledgeSourceCount??0)===1?"fuente":"fuentes",")"]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Si lo dejas sin marcar, el dataset se conserva y pasa a ser un dataset compartido (visible en Datasets). Los Q&A y documentos no se borran."})]})]})]}),e.jsxs(W,{children:[e.jsx(h,{variant:"outline",onClick:()=>v(!1),disabled:g,children:"Cancelar"}),e.jsx(h,{onClick:P,disabled:n||g||!!d||!t,className:r?"bg-rose-500 hover:bg-rose-600 text-white":"bg-amber-500 hover:bg-amber-600 text-white",children:g?e.jsxs(e.Fragment,{children:[e.jsx(H,{className:"mr-2 h-4 w-4 animate-spin"}),r?"Eliminando...":"Archivando..."]}):e.jsxs(e.Fragment,{children:[r?e.jsx(I,{className:"mr-2 h-4 w-4"}):e.jsx(G,{className:"mr-2 h-4 w-4"}),r?"Eliminar permanentemente":"Archivar y liberar crédito"]})})]})]})})}function Je(){const l=ee(),{currentOrganization:p}=se(),{data:u=[],isLoading:v,refetch:y}=de(p?.id),[t,T]=o.useState("cards"),[n,L]=o.useState(""),[d,C]=o.useState("ALL"),[g,f]=o.useState(null),{pool:i,limitReached:A,refetch:r}=Ce({resourceType:"AI_AGENTS",enabled:!0}),P=u.find(s=>s.id===g),b=(s,a)=>{a&&a.stopPropagation(),f(s)},x=async(s,a)=>{a.stopPropagation();const j=s.status==="active"?"inactive":"active";try{await K.updateAgent(s.id,{status:j}),y(),k.success(`Agente ${j==="active"?"activado":"desactivado"}`)}catch(Y){Ae(Y,{title:"Limite de Agentes IA Alcanzado"})||k.error("Error al cambiar el estado")}},D=o.useMemo(()=>u.filter(s=>{const a=s.name.toLowerCase().includes(n.toLowerCase())||s.assistantRole?.toLowerCase().includes(n.toLowerCase()),j=d==="ALL"||s.status===d.toLowerCase();return a&&j}),[u,n,d]),V=(s,a=!1)=>{const j=s?.toLowerCase()||"draft";if(a)switch(j){case"active":return"bg-emerald-500";case"inactive":return"bg-slate-400";default:return"bg-slate-400"}switch(j){case"active":return"bg-emerald-50 text-emerald-700 border-emerald-200";case"inactive":return"bg-slate-100 text-slate-600 border-slate-200";default:return"bg-slate-100 text-slate-700"}};return e.jsx(ae,{children:e.jsxs(xe,{children:[e.jsxs("div",{className:"h-full overflow-y-auto no-scrollbar",children:[e.jsx(me,{title:"Mis Agentes IA",description:"Gestiona y entrena a tus asistentes virtuales inteligentes.",icon:S,actions:e.jsxs(z,{children:[e.jsx(M,{asChild:!0,children:e.jsx("span",{children:e.jsxs(h,{onClick:()=>{if(A){k.error("Limite de agentes IA alcanzado. Elimina un agente existente o actualiza tu plan.");return}l("/ai-agents/create")},className:m("bg-primary hover:bg-primary/90 text-white shadow-lg shadow-primary/20 rounded-full","opacity-60"),children:[e.jsx(te,{className:"mr-2 h-4 w-4"}),"Nuevo Agente"]})})}),e.jsx(E,{children:e.jsx("p",{children:"Nubot Lite trae un solo agente. Varios agentes: disponible en Nubot."})}),A&&i&&e.jsx(E,{children:e.jsxs("p",{children:["Límite alcanzado (",i.usedCredits??0,"/",i.totalCredits,"). Elimina un agente para crear otro."]})})]})}),e.jsxs(he,{children:[e.jsxs("div",{className:"bg-white dark:bg-slate-900 p-4 rounded-2xl border border-slate-100 dark:border-slate-800 shadow-sm mb-8 flex flex-col md:flex-row items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-4 w-full md:w-auto",children:[e.jsx(Te,{mode:t,onChange:T}),e.jsx(h,{variant:"ghost",size:"icon",onClick:()=>{y(),r()},disabled:v,className:"rounded-xl hover:bg-slate-100 dark:hover:bg-slate-800 text-slate-400 hover:text-primary",children:e.jsx(re,{className:m("h-4 w-4",v&&"animate-spin")})}),e.jsx("div",{className:"h-8 w-[1px] bg-slate-100 dark:bg-slate-800 hidden md:block"}),e.jsxs("div",{className:"relative flex-1 md:w-64",children:[e.jsx(le,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),e.jsx(ie,{placeholder:"Buscar por nombre...",value:n,onChange:s=>L(s.target.value),className:"h-10 pl-10 bg-slate-50 dark:bg-slate-950 border-none rounded-xl text-sm focus-visible:ring-1 focus-visible:ring-primary/20"})]})]}),e.jsxs("div",{className:"flex items-center gap-3 w-full md:w-auto",children:[e.jsxs(pe,{value:d,onValueChange:C,children:[e.jsx(ue,{className:"h-10 w-full md:w-40 bg-slate-50 dark:bg-slate-950 border-none rounded-xl text-sm",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(oe,{className:"w-3.5 h-3.5 text-slate-400"}),e.jsx(ge,{placeholder:"Estado"})]})}),e.jsxs(be,{children:[e.jsx(R,{value:"ALL",children:"Todos"}),e.jsx(R,{value:"active",children:"Activos"}),e.jsx(R,{value:"inactive",children:"Inactivos"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 px-2",children:[e.jsxs("span",{className:"text-xs text-slate-400",children:[e.jsx("span",{className:"font-bold text-slate-700 dark:text-slate-200",children:D.length})," ","agentes"]}),i&&e.jsxs(c,{variant:"outline",className:m("text-xs font-bold px-3 py-1 rounded-xl",(i.usedCredits??0)>=i.totalCredits?"border-rose-200 bg-rose-50 text-rose-600 dark:border-rose-800 dark:bg-rose-900/20 dark:text-rose-400":"border-primary/20 bg-primary/5 text-primary"),children:["Límite: ",i.usedCredits??0," / ",i.totalCredits]})]})]})]}),v?e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 gap-4",children:[e.jsx(H,{className:"w-8 h-8 animate-spin text-primary"}),e.jsx("p",{className:"text-sm font-medium text-slate-500",children:"Cargando agentes..."})]}):D.length===0?e.jsxs("div",{className:"text-center py-20 border-2 border-dashed rounded-3xl border-slate-100 dark:border-slate-800",children:[e.jsx("div",{className:"bg-primary/10 w-16 h-16 rounded-3xl flex items-center justify-center mx-auto mb-4",children:e.jsx(S,{className:"h-8 w-8 text-primary"})}),e.jsx("h3",{className:"text-lg font-bold",children:"No se encontraron agentes"}),e.jsx("p",{className:"text-slate-500 mb-6 text-sm",children:"Ajusta los filtros o crea tu primer asistente virtual."}),e.jsx(h,{onClick:()=>l("/ai-agents/create"),className:"rounded-full px-8",children:"Crear Agente"})]}):t==="cards"?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:D.map(s=>e.jsxs("div",{className:"group relative bg-white dark:bg-slate-900 rounded-3xl border border-slate-100 dark:border-slate-800 shadow-sm hover:shadow-2xl hover:shadow-primary/10 hover:border-primary/30 transition-all duration-500 cursor-pointer overflow-hidden transform hover:-translate-y-2 hover:scale-[1.01]",onClick:()=>l(`/ai-agents/${s.id}`),children:[e.jsxs("div",{className:"p-7",children:[e.jsxs("div",{className:"flex justify-between items-start mb-6",children:[e.jsxs("div",{className:"space-y-1.5 overflow-hidden",children:[e.jsx("h3",{className:"text-lg font-bold text-slate-900 dark:text-white leading-tight group-hover:text-primary transition-colors truncate pr-2",children:s.name}),e.jsx("p",{className:"text-[10px] font-bold text-slate-400 flex items-center gap-1.5 uppercase tracking-widest truncate",children:s.assistantRole||"Asistente General"})]}),e.jsxs(z,{children:[e.jsx(M,{asChild:!0,children:e.jsxs(c,{variant:"secondary",className:m(V(s.status||"inactive"),"border font-bold px-3 py-1 rounded-lg text-[10px] shadow-sm uppercase shrink-0 cursor-pointer hover:opacity-80 transition-opacity flex items-center gap-1.5"),onClick:a=>x(s,a),children:[e.jsx(Q,{className:"w-3 h-3"}),s.status==="active"?"Activo":"Inactivo"]})}),e.jsx(E,{side:"left",children:e.jsxs("p",{children:["Click para ",s.status==="active"?"desactivar":"activar"]})})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 min-h-[40px] mb-6",children:s.description||"Sin descripción disponible para este agente."}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-6",children:[e.jsxs("div",{className:"bg-slate-50 dark:bg-slate-800/50 rounded-2xl p-3 text-center border border-transparent group-hover:bg-blue-50/50 dark:group-hover:bg-blue-900/10 group-hover:border-blue-100 transition-all",children:[e.jsx(Se,{className:"w-4 h-4 mx-auto mb-2 text-blue-500"}),e.jsx("p",{className:"text-xs font-bold text-slate-900 dark:text-white truncate",children:s.model}),e.jsx("p",{className:"text-[9px] uppercase font-black text-slate-400 mt-1 tracking-tighter",children:"Modelo"})]}),e.jsxs("div",{className:"bg-slate-50 dark:bg-slate-800/50 rounded-2xl p-3 text-center border border-transparent group-hover:bg-violet-50/50 dark:group-hover:bg-violet-900/10 group-hover:border-violet-100 transition-all",children:[e.jsx(ne,{className:"w-4 h-4 mx-auto mb-2 text-violet-500"}),e.jsx("p",{className:"text-xs font-bold text-slate-900 dark:text-white",children:s.tools?.length||0}),e.jsx("p",{className:"text-[9px] uppercase font-black text-slate-400 mt-1 tracking-tighter",children:"Tools"})]})]})]}),e.jsxs("div",{className:"px-7 py-4 bg-slate-50/50 dark:bg-slate-800/30 border-t border-slate-50 dark:border-slate-800 flex items-center justify-between group-hover:bg-white dark:group-hover:bg-slate-900 transition-colors duration-300",children:[e.jsx("div",{className:"flex flex-col gap-1",children:e.jsxs("span",{className:"text-[10px] font-bold text-slate-400 flex items-center gap-1.5 tracking-wider cursor-pointer hover:text-primary transition-colors",onClick:a=>{a.stopPropagation(),navigator.clipboard.writeText(s.id),k.success("ID copiado")},children:[e.jsx(S,{className:"w-3 h-3"}),"ID: ",s.id.substring(0,8),"..."]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(h,{variant:"ghost",size:"icon",className:"h-8 w-8 hover:bg-rose-50 hover:text-rose-600 rounded-full opacity-0 group-hover:opacity-100 transition-all duration-300",onClick:a=>b(s.id,a),children:e.jsx(I,{className:"h-4 w-4"})}),e.jsxs("span",{className:"text-[10px] font-black text-primary flex items-center gap-1 opacity-0 group-hover:opacity-100 transform translate-x-4 group-hover:translate-x-0 transition-all duration-500 uppercase tracking-widest pl-2 border-l border-slate-200 ml-2",children:["Editar",e.jsx(ce,{className:"w-4 h-4"})]})]})]})]},s.id))}):e.jsx("div",{className:"bg-white dark:bg-slate-900 rounded-3xl border border-slate-100 dark:border-slate-800 shadow-sm overflow-hidden",children:e.jsxs(fe,{children:[e.jsx(Ne,{children:e.jsxs($,{className:"bg-slate-50/50 dark:bg-slate-800/50 hover:bg-slate-50/50 border-slate-100 dark:border-slate-800",children:[e.jsx(N,{className:"py-5 font-bold uppercase text-[10px] tracking-widest pl-7 w-[30%]",children:"Agente"}),e.jsx(N,{className:"font-bold uppercase text-[10px] tracking-widest",children:"Rol"}),e.jsx(N,{className:"font-bold uppercase text-[10px] tracking-widest text-center",children:"Modelo"}),e.jsx(N,{className:"font-bold uppercase text-[10px] tracking-widest text-center",children:"Modo"}),e.jsx(N,{className:"font-bold uppercase text-[10px] tracking-widest text-center",children:"Tools"}),e.jsx(N,{className:"font-bold uppercase text-[10px] tracking-widest text-right pr-7",children:"Estado"})]})}),e.jsx(we,{children:D.map(s=>e.jsxs($,{className:"cursor-pointer hover:bg-slate-50/50 dark:hover:bg-slate-800/50 border-slate-50 dark:border-slate-800 transition-colors",onClick:()=>l(`/ai-agents/${s.id}`),children:[e.jsx(w,{className:"py-5 pl-7",children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"font-bold text-slate-900 dark:text-white line-clamp-1",children:s.name}),e.jsxs("span",{className:"text-[10px] text-slate-400 font-medium font-mono",children:["#",s.id.substring(0,8)]})]})}),e.jsx(w,{className:"text-sm text-slate-600 dark:text-slate-400",children:s.assistantRole||"-"}),e.jsx(w,{className:"text-center",children:e.jsx(c,{variant:"outline",className:"font-mono text-[10px] bg-blue-50 text-blue-700 border-blue-100",children:s.model})}),e.jsx(w,{className:"text-center",children:e.jsx(c,{variant:"outline",className:m("text-[10px]",s.processingMode==="async"?"bg-orange-50 text-orange-700 border-orange-100":"bg-green-50 text-green-700 border-green-100"),children:s.processingMode==="async"?"ASYNC":"SYNC"})}),e.jsx(w,{className:"text-center font-bold text-slate-500",children:s.tools?.length||0}),e.jsx(w,{className:"text-right pr-7",children:e.jsxs(z,{children:[e.jsx(M,{asChild:!0,children:e.jsxs(c,{variant:"secondary",className:m(V(s.status||"inactive"),"border font-bold rounded-lg text-[10px] px-2.5 py-1 whitespace-nowrap uppercase cursor-pointer hover:opacity-80 transition-opacity flex items-center gap-1"),onClick:a=>x(s,a),children:[e.jsx(Q,{className:"w-3 h-3"}),s.status==="active"?"Activo":"Inactivo"]})}),e.jsx(E,{children:e.jsxs("p",{children:["Click para ",s.status==="active"?"desactivar":"activar"]})})]})})]},s.id))})]})})]})]}),e.jsx(Le,{agentId:g,agentName:P?.name??null,open:!!g,onOpenChange:s=>!s&&f(null),onDeleted:()=>{f(null),y(),r()}})]})})}export{Je as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as U,j as e,af as B,ag as F,ah as H,ai as $,h as _,t as d,c2 as K,B as b,ab as G,Y as W,I as Y,r as P,aC as Z,o as k,C as J,Z as V}from"./index-DsyZ_FlA.js";import{b as r}from"./recharts-DrC5kNsx.js";import{a as f}from"./agent.service-BcAkMU7j.js";import{A as X,b as ee,c as se,d as ae,e as re,f as te,g as le,h as ne}from"./alert-dialog-D8P69s-m.js";import{T as de,a as ie,b as j,c as N,d as oe,e as i}from"./table-CvSELOPi.js";import{P as ce,a as me,b as xe}from"./page-components-o2TF52HV.js";import{Q as he}from"./QaForm-BDboHNKo.js";import{M as ue}from"./mediaValidation-BR-ZOj5w.js";import{M as ge}from"./message-square-Dfn16oHc.js";import{P as pe}from"./pencil-Cx8u1N8t.js";import{T as E}from"./trash-2-Du2vmQCH.js";import{f as be,e as fe}from"./es-BG480iA5.js";import"./storage.api-CFU3KJNp.js";import"./textarea-BYtcLsMD.js";import"./code-BMAyHFJe.js";import"./list-BKc6EXnV.js";import"./eye-HfQCUjxJ.js";import"./music-Cu8AQMFp.js";import"./upload-C7TwpdyA.js";import"./save-Dua2yhWl.js";const je=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],L=U("wrench",je);function Ne({open:t,onOpenChange:o,item:c,onSaved:x,organizationId:m}){const n=!!c;return e.jsx(B,{open:t,onOpenChange:o,children:e.jsxs(F,{className:"w-full sm:max-w-lg p-0 flex flex-col",side:"right",children:[e.jsx("div",{className:"p-6 pb-4 bg-muted/20 border-b border-border/40",children:e.jsx(H,{children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-xl bg-primary/10 flex items-center justify-center shrink-0 border border-primary/20",children:e.jsx(ue,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx($,{className:"text-xl font-bold tracking-tight",children:n?"Editar Q&A":"Nuevo Q&A"}),e.jsx("p",{className:"text-xs text-muted-foreground/80 font-medium mt-1",children:"Define una pregunta y su respuesta directa."})]})]})})}),e.jsx("div",{className:"flex-1 p-6 overflow-y-auto bg-slate-50/50 dark:bg-slate-900/20",children:e.jsx(he,{item:c,organizationId:m,onSaved:h=>{x(h),o(!1)},onCancel:()=>o(!1)})})]})})}function Be(){const{currentOrganization:t}=_(),[o,c]=r.useState(!0),[x,m]=r.useState([]),[n,h]=r.useState(""),[D,u]=r.useState(!1),[R,v]=r.useState(null),[T,w]=r.useState(!1),[g,p]=r.useState(!1),[a,y]=r.useState(null),C=r.useRef(null);r.useEffect(()=>{if(t?.id){if(C.current===t.id)return;C.current=t.id,m([]),h(""),v(null),u(!1),Q()}},[t?.id]);const Q=async()=>{if(t)try{c(!0);const s=await f.getQaList(t.id);m(s)}catch(s){console.error(s),d.error("Error cargando lista de Q&A")}finally{c(!1)}},z=()=>{v(null),u(!0)},A=s=>{v(s),u(!0)},q=async()=>{w(!0),y(null),p(!0);try{const s=await f.reconcileKnowledgeDryRun();y(s)}catch(s){d.error(s?.response?.data?.message||"No se pudo analizar el índice"),w(!1)}finally{p(!1)}},I=async()=>{p(!0);try{const s=await f.reconcileKnowledgeExecute();y(s),d.success(`Limpieza completada: ${s.deleted} puntos huérfanos eliminados`)}catch(s){d.error(s?.response?.data?.message||"Error al limpiar el índice")}finally{p(!1)}},M=async s=>{if(confirm("¿Estás seguro de eliminar este entrenamiento?"))try{await f.deleteQa(s),d.success("Entrenamiento eliminado"),m(l=>l.filter(O=>O.id!==s))}catch{d.error("No se pudo eliminar")}},S=x.filter(s=>s.question.toLowerCase().includes(n.toLowerCase())||s.answer.toLowerCase().includes(n.toLowerCase()));return e.jsxs(ce,{children:[e.jsx(me,{title:"Entrenamiento Q&A",description:"Gestiona las preguntas y respuestas directas de tus agentes.",icon:K,actions:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(b,{variant:"outline",className:"rounded-full font-medium",onClick:q,title:"Analiza el índice de búsqueda y elimina puntos huérfanos",children:[e.jsx(L,{className:"h-4 w-4 mr-2"})," Limpiar índice"]}),e.jsxs(b,{className:"bg-primary hover:bg-primary/90 text-white shadow-lg shadow-primary/20 rounded-full font-bold px-6",onClick:z,children:[e.jsx(G,{className:"h-4 w-4 mr-2"})," Nuevo Q&A"]})]})}),e.jsxs(xe,{children:[e.jsxs("div",{className:"bg-white dark:bg-slate-900 p-4 rounded-2xl border border-slate-200 dark:border-slate-800 shadow-sm mb-6 flex flex-col md:flex-row items-center justify-between gap-4",children:[e.jsx("div",{className:"flex items-center gap-4 w-full md:w-auto flex-1",children:e.jsxs("div",{className:"relative w-full md:w-96",children:[e.jsx(W,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400"}),e.jsx(Y,{placeholder:"Buscar en preguntas y respuestas...",className:"pl-10 h-10 bg-slate-50 dark:bg-slate-950 border-slate-200 dark:border-slate-800 rounded-xl w-full focus-visible:ring-primary/20",value:n,onChange:s=>h(s.target.value)})]})}),e.jsx("div",{className:"flex items-center gap-3 w-full md:w-auto",children:e.jsxs(P,{variant:"outline",className:"px-3 py-1.5 h-10 rounded-xl border-slate-200 dark:border-slate-800 bg-slate-50 dark:bg-slate-950 text-slate-500 gap-2 font-medium",children:[e.jsx(Z,{className:"w-3.5 h-3.5"}),e.jsxs("span",{children:["Total: ",x.length]})]})})]}),e.jsx("div",{className:"rounded-3xl border border-slate-200 dark:border-slate-800 bg-white dark:bg-slate-900 shadow-sm overflow-hidden",children:e.jsxs(de,{children:[e.jsx(ie,{className:"bg-slate-50/50 dark:bg-slate-950/50",children:e.jsxs(j,{className:"hover:bg-transparent border-slate-100 dark:border-slate-800",children:[e.jsx(N,{className:"w-[40%] font-bold text-xs uppercase tracking-wider text-slate-500 pl-6 h-12",children:"Pregunta"}),e.jsx(N,{className:"w-[40%] font-bold text-xs uppercase tracking-wider text-slate-500 h-12",children:"Respuesta"}),e.jsx(N,{className:"font-bold text-xs uppercase tracking-wider text-slate-500 h-12",children:"Fecha"}),e.jsx(N,{className:"text-right font-bold text-xs uppercase tracking-wider text-slate-500 pr-6 h-12",children:"Acciones"})]})}),e.jsx(oe,{children:o?e.jsx(j,{children:e.jsx(i,{colSpan:4,className:"h-32 text-center",children:e.jsxs("div",{className:"flex justify-center items-center gap-2 text-muted-foreground",children:[e.jsx(k,{className:"h-5 w-5 animate-spin text-primary"}),e.jsx("span",{className:"text-sm font-medium",children:"Cargando base de conocimiento..."})]})})}):S.length===0?e.jsx(j,{children:e.jsx(i,{colSpan:4,className:"h-64 text-center",children:e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 text-muted-foreground",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-slate-100 dark:bg-slate-800 flex items-center justify-center mb-2",children:e.jsx(J,{className:"h-6 w-6 text-slate-400"})}),e.jsx("p",{className:"font-medium text-slate-900 dark:text-white",children:"No se encontraron resultados"}),e.jsx("p",{className:"text-sm max-w-xs",children:n?"Prueba con otros términos de búsqueda":"Comienza agregando preguntas frecuentes para entrenar a tu agente."})]})})}):S.map(s=>e.jsxs(j,{className:"group hover:bg-slate-50/50 dark:hover:bg-slate-800/50 border-slate-100 dark:border-slate-800 transition-colors cursor-pointer",onClick:()=>A(s),children:[e.jsx(i,{className:"pl-6 py-4 align-top",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"mt-1 bg-violet-100 dark:bg-violet-500/10 p-1.5 rounded-lg shrink-0",children:e.jsx(ge,{className:"h-4 w-4 text-violet-600 dark:text-violet-400"})}),e.jsx("span",{className:"font-medium text-slate-700 dark:text-slate-200 text-sm leading-relaxed mt-0.5",children:s.question})]})}),e.jsxs(i,{className:"py-4 align-top",children:[e.jsx("div",{className:"text-slate-500 dark:text-slate-400 text-sm leading-relaxed line-clamp-3 max-w-md",title:s.answer,children:s.answer}),(s.thumbnailUrl||s.signedUrl||s.mediaUrl)&&e.jsx("div",{className:"mt-2 flex items-center gap-2",children:s.thumbnailUrl||s.signedUrl?e.jsx("img",{src:s.thumbnailUrl||s.signedUrl,alt:"Media adjunta",className:"h-10 w-10 rounded-md object-cover border cursor-pointer hover:opacity-80 transition-opacity",onClick:l=>{l.stopPropagation(),s.signedUrl&&window.open(s.signedUrl,"_blank")}}):e.jsxs(P,{variant:"secondary",className:"text-[10px] bg-slate-100 dark:bg-slate-800 hover:bg-slate-200",children:[e.jsx(V,{className:"w-3 h-3 mr-1"}),"Adjunto"]})})]}),e.jsx(i,{className:"py-4 align-top",children:e.jsx("span",{className:"text-xs font-medium text-slate-400",children:be(new Date(s.createdAt),"d MMM yyyy",{locale:fe})})}),e.jsx(i,{className:"py-4 align-top text-right pr-6",children:e.jsxs("div",{className:"flex justify-end gap-1 opacity-0 group-hover:opacity-100 transition-all",children:[e.jsx(b,{variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-400 hover:text-primary hover:bg-primary/10 rounded-lg",onClick:l=>{l.stopPropagation(),A(s)},children:e.jsx(pe,{className:"h-4 w-4"})}),e.jsx(b,{variant:"ghost",size:"icon",className:"h-8 w-8 text-slate-400 hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/10 rounded-lg",onClick:l=>{l.stopPropagation(),M(s.id)},children:e.jsx(E,{className:"h-4 w-4"})})]})})]},s.id))})]})})]}),e.jsx(Ne,{open:D,onOpenChange:u,item:R,onSaved:()=>Q(),organizationId:t?.id||""}),e.jsx(X,{open:T,onOpenChange:w,children:e.jsxs(ee,{className:"max-w-lg",children:[e.jsxs(se,{children:[e.jsxs(ae,{className:"flex items-center gap-2",children:[e.jsx(L,{className:"h-5 w-5 text-primary"}),"Limpiar índice de búsqueda"]}),e.jsx(re,{children:"Compara la base de datos con el índice de búsqueda (Qdrant) y elimina puntos huérfanos que quedaron de registros eliminados anteriormente."})]}),e.jsx("div",{className:"py-4",children:g&&!a?e.jsxs("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:[e.jsx(k,{className:"h-5 w-5 animate-spin mr-2"}),"Analizando índice..."]}):a?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"rounded-lg border border-border/60 bg-muted/30 p-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground font-medium",children:"Puntos en Qdrant"}),e.jsx("div",{className:"text-2xl font-bold mt-1",children:a.totalQdrantPoints})]}),e.jsxs("div",{className:"rounded-lg border border-border/60 bg-muted/30 p-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground font-medium",children:"Registros en BD"}),e.jsx("div",{className:"text-2xl font-bold mt-1",children:a.totalDbSources})]}),e.jsxs("div",{className:`rounded-lg border p-3 ${a.orphanedPoints>0?"border-amber-500/40 bg-amber-500/10":"border-emerald-500/40 bg-emerald-500/10"}`,children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Puntos huérfanos"}),e.jsx("div",{className:`text-2xl font-bold mt-1 ${a.orphanedPoints>0?"text-amber-600":"text-emerald-600"}`,children:a.orphanedPoints})]}),e.jsxs("div",{className:`rounded-lg border p-3 ${a.missingInQdrant.length>0?"border-red-500/40 bg-red-500/10":"border-emerald-500/40 bg-emerald-500/10"}`,children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Faltantes en índice"}),e.jsx("div",{className:`text-2xl font-bold mt-1 ${a.missingInQdrant.length>0?"text-red-600":"text-emerald-600"}`,children:a.missingInQdrant.length})]})]}),a.deleted>0&&e.jsxs("div",{className:"rounded-lg border border-emerald-500/40 bg-emerald-500/10 p-3 text-sm text-emerald-700 dark:text-emerald-400",children:["✓ Se eliminaron ",e.jsx("strong",{children:a.deleted})," puntos huérfanos del índice."]}),a.dryRun&&a.orphanedPoints===0&&e.jsx("div",{className:"rounded-lg border border-emerald-500/40 bg-emerald-500/10 p-3 text-sm text-emerald-700 dark:text-emerald-400",children:"✓ El índice está limpio, no se encontraron puntos huérfanos."}),a.missingInQdrant.length>0&&e.jsxs("div",{className:"rounded-lg border border-red-500/40 bg-red-500/10 p-3 text-xs text-red-700 dark:text-red-400",children:[e.jsx("strong",{children:"Advertencia:"})," ",a.missingInQdrant.length," registro(s) están en la BD pero no indexados. Edita y guarda la Q&A para re-indexar."]})]}):null}),e.jsxs(te,{children:[e.jsx(le,{disabled:g,children:"Cerrar"}),a&&a.dryRun&&a.orphanedPoints>0&&e.jsx(ne,{onClick:s=>{s.preventDefault(),I()},disabled:g,className:"bg-amber-600 hover:bg-amber-700",children:g?e.jsxs(e.Fragment,{children:[e.jsx(k,{className:"h-4 w-4 animate-spin mr-2"})," Eliminando..."]}):e.jsxs(e.Fragment,{children:[e.jsx(E,{className:"h-4 w-4 mr-2"})," Eliminar ",a.orphanedPoints," huérfano(s)"]})})]})]})})]})}export{Be as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{aA as e}from"./index-DsyZ_FlA.js";import"./recharts-DrC5kNsx.js";export{e as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{aA as e}from"./index-DsyZ_FlA.js";import"./recharts-DrC5kNsx.js";export{e as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{aA as e}from"./index-DsyZ_FlA.js";import"./recharts-DrC5kNsx.js";export{e as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{aA as e}from"./index-DsyZ_FlA.js";import"./recharts-DrC5kNsx.js";export{e as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{aA as e}from"./index-DsyZ_FlA.js";import"./recharts-DrC5kNsx.js";export{e as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{aA as e}from"./index-DsyZ_FlA.js";import"./recharts-DrC5kNsx.js";export{e as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as H,b as f,i as D,g as R,w as S,j as n,l as x,o as P,av as j,y as B}from"./index-DsyZ_FlA.js";import{b as M,R as p}from"./recharts-DrC5kNsx.js";import{S as F,a as k,c as G,d as z}from"./select-DlB_BbfM.js";import{M as g}from"./message-square-Dfn16oHc.js";import{I as $}from"./instagram-CC7iYt7V.js";const q=[["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",key:"9njp5v"}]],K=H("phone",q),Q={list:async()=>(await f.get("/channels")).data,getById:async e=>(await f.get(`/channels/${e}`)).data,deactivate:async e=>(await f.post(`/channels/${e}/deactivate`)).data,reactivate:async e=>(await f.post(`/channels/${e}/reactivate`)).data,getMediaConfig:async e=>(await f.get(`/channels/${e}/media-config`)).data,uploadMedia:async(e,t,a)=>{const r=new FormData;return a&&r.append("originalHash",a),r.append("file",t,t.name),(await f.post(`/channels/${e}/upload-media`,r,{headers:{"Content-Type":"multipart/form-data"}})).data}},U=()=>{const e=D(),{data:t=[],isLoading:a,refetch:r}=R({queryKey:["channels"],queryFn:()=>Q.list(),staleTime:300*1e3,gcTime:600*1e3,refetchOnWindowFocus:!1});return M.useEffect(()=>{const i=()=>{console.log("[useChannels] Invalidation triggered by WebSocket"),e.invalidateQueries({queryKey:["channels"]})},o=S.onChannelsUpdate(i),u=S.onChannelStatus(i);return()=>{o(),u()}},[e]),{channels:t,loading:a,refetch:r}};function J(e){const t=e.config?.health?.senderStatus;return t==="DISCONNECTED"||t==="PERMISSION_ERROR"}var A={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},L=p.createContext&&p.createContext(A),X=["attr","size","title"];function Y(e,t){if(e==null)return{};var a=Z(e,t),r,i;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)r=o[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}function Z(e,t){if(e==null)return{};var a={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;a[r]=e[r]}return a}function y(){return y=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var r in a)Object.prototype.hasOwnProperty.call(a,r)&&(e[r]=a[r])}return e},y.apply(this,arguments)}function T(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),a.push.apply(a,r)}return a}function w(e){for(var t=1;t<arguments.length;t++){var a=arguments[t]!=null?arguments[t]:{};t%2?T(Object(a),!0).forEach(function(r){ee(e,r,a[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):T(Object(a)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(a,r))})}return e}function ee(e,t,a){return t=te(t),t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function te(e){var t=ae(e,"string");return typeof t=="symbol"?t:t+""}function ae(e,t){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var r=a.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function I(e){return e&&e.map((t,a)=>p.createElement(t.tag,w({key:a},t.attr),I(t.child)))}function b(e){return t=>p.createElement(re,y({attr:w({},e.attr)},t),I(e.child))}function re(e){var t=a=>{var{attr:r,size:i,title:o}=e,u=Y(e,X),d=i||a.size||"1em",m;return a.className&&(m=a.className),e.className&&(m=(m?m+" ":"")+e.className),p.createElement("svg",y({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},a.attr,r,u,{className:m,style:w(w({color:e.color||a.color},a.style),e.style),height:d,width:d,xmlns:"http://www.w3.org/2000/svg"}),o&&p.createElement("title",null,o),e.children)};return L!==void 0?p.createElement(L.Consumer,null,a=>t(a)):t(A)}function ne(e){return b({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M0 32h214.6v214.6H0V32zm233.4 0H448v214.6H233.4V32zM0 265.4h214.6V480H0V265.4zm233.4 0H448V480H233.4V265.4z"},child:[]}]})(e)}function he(e){return b({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M380.9 97.1C339 55.1 283.2 32 223.9 32c-122.4 0-222 99.6-222 222 0 39.1 10.2 77.3 29.6 111L0 480l117.7-30.9c32.4 17.7 68.9 27 106.1 27h.1c122.3 0 224.1-99.6 224.1-222 0-59.3-25.2-115-67.1-157zm-157 341.6c-33.2 0-65.7-8.9-94-25.7l-6.7-4-69.8 18.3L72 359.2l-4.4-7c-18.5-29.4-28.2-63.3-28.2-98.2 0-101.7 82.8-184.5 184.6-184.5 49.3 0 95.6 19.2 130.4 54.1 34.8 34.9 56.2 81.2 56.1 130.5 0 101.8-84.9 184.6-186.6 184.6zm101.2-138.2c-5.5-2.8-32.8-16.2-37.9-18-5.1-1.9-8.8-2.8-12.5 2.8-3.7 5.6-14.3 18-17.6 21.8-3.2 3.7-6.5 4.2-12 1.4-32.6-16.3-54-29.1-75.5-66-5.7-9.8 5.7-9.1 16.3-30.3 1.8-3.7.9-6.9-.5-9.7-1.4-2.8-12.5-30.1-17.1-41.2-4.5-10.8-9.1-9.3-12.5-9.5-3.2-.2-6.9-.2-10.6-.2-3.7 0-9.7 1.4-14.8 6.9-5.1 5.6-19.4 19-19.4 46.3 0 27.3 19.9 53.7 22.6 57.4 2.8 3.7 39.1 59.7 94.8 83.8 35.2 15.2 49 16.5 66.6 13.9 10.7-1.6 32.8-13.4 37.4-26.4 4.6-13 4.6-24.1 3.2-26.4-1.3-2.5-5-3.9-10.5-6.6z"},child:[]}]})(e)}function se(e){return b({attr:{role:"img",viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M24 5.457v13.909c0 .904-.732 1.636-1.636 1.636h-3.819V11.73L12 16.64l-6.545-4.91v9.273H1.636A1.636 1.636 0 0 1 0 19.366V5.457c0-2.023 2.309-3.178 3.927-1.964L5.455 4.64 12 9.548l6.545-4.91 1.528-1.145C21.69 2.28 24 3.434 24 5.457z"},child:[]}]})(e)}function fe(e){return b({attr:{role:"img",viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M18.316 5.684H24v12.632h-5.684V5.684zM5.684 24h12.632v-5.684H5.684V24zM18.316 5.684V0H1.895A1.894 1.894 0 0 0 0 1.895v16.421h5.684V5.684h12.632zm-7.207 6.25v-.065c.272-.144.5-.349.687-.617s.279-.595.279-.982c0-.379-.099-.72-.3-1.025a2.05 2.05 0 0 0-.832-.714 2.703 2.703 0 0 0-1.197-.257c-.6 0-1.094.156-1.481.467-.386.311-.65.671-.793 1.078l1.085.452c.086-.249.224-.461.413-.633.189-.172.445-.257.767-.257.33 0 .602.088.816.264a.86.86 0 0 1 .322.703c0 .33-.12.589-.36.778-.24.19-.535.284-.886.284h-.567v1.085h.633c.407 0 .748.109 1.02.327.272.218.407.499.407.843 0 .336-.129.614-.387.832s-.565.327-.924.327c-.351 0-.651-.103-.897-.311-.248-.208-.422-.502-.521-.881l-1.096.452c.178.616.505 1.082.977 1.401.472.319.984.478 1.538.477a2.84 2.84 0 0 0 1.293-.291c.382-.193.684-.458.902-.794.218-.336.327-.72.327-1.149 0-.429-.115-.797-.344-1.105a2.067 2.067 0 0 0-.881-.689zm2.093-1.931l.602.913L15 10.045v5.744h1.187V8.446h-.827l-2.158 1.557zM22.105 0h-3.289v5.184H24V1.895A1.894 1.894 0 0 0 22.105 0zm-3.289 23.5l4.684-4.684h-4.684V23.5zM0 22.105C0 23.152.848 24 1.895 24h3.289v-5.184H0v3.289z"},child:[]}]})(e)}const V=e=>e==="all"?{filterType:"all",value:"all"}:e.startsWith("type:")?{filterType:"type",value:e.replace("type:","")}:e.startsWith("id:")?{filterType:"id",value:e.replace("id:","")}:{filterType:"all",value:"all"},ie=e=>e?e.providerId?.endsWith("@gmail.com")||e.credentials?.email?.endsWith("@gmail.com")||e.name?.toLowerCase().includes("gmail"):!1,N=(e,t)=>{const a=e.toLowerCase();if(a==="email"&&t)return ie(t)?n.jsx(se,{className:"w-4 h-4 text-[#EA4335]"}):n.jsx(ne,{className:"w-4 h-4 text-[#0078D4]"});switch(a){case"whatsapp":case"whatsapp_cloud":return n.jsx(g,{className:"w-4 h-4 text-green-500"});case"instagram":return n.jsx($,{className:"w-4 h-4 text-pink-500"});case"messenger":return n.jsx(g,{className:"w-4 h-4 text-blue-500"});case"waba":return n.jsx(g,{className:"w-4 h-4 text-green-600"});case"sms":return n.jsx(g,{className:"w-4 h-4 text-slate-500"});case"voice":return n.jsx(K,{className:"w-4 h-4 text-purple-500"});default:return n.jsx(g,{className:"w-4 h-4 text-slate-400"})}},E=e=>({whatsapp:"WhatsApp",whatsapp_cloud:"WhatsApp Cloud",instagram:"Instagram",messenger:"Messenger",waba:"WABA",sms:"SMS",voice:"Voz",email:"Email",webchat:"Webchat",telegram:"Telegram",google_business:"G. Business",line:"Line",viber:"Viber",wechat:"WeChat",twitter:"Twitter",calendar:"Citas"})[e.toLowerCase()]||e,le=M.memo(({value:e,onChange:t,className:a,showInactive:r=!1,excludeTypes:i,disableUnreachable:o=!1})=>{const{channels:u,loading:d}=U(),m=new Set((i??[]).map(s=>s.toLowerCase())),C=u.filter(s=>m.has(s.type.toLowerCase())?!1:r?!0:s.isActive&&!s.deletedAt&&!s.disconnectedFromMetaAt&&!s.deactivatedAt&&!s.archivedAt).reduce((s,c)=>{const l=c.type.toLowerCase();return s[l]||(s[l]=[]),s[l].push(c),s},{}),O=Object.keys(C).sort(),W=()=>{if(e==="all")return"Todos";const{filterType:s,value:c}=V(e);return s==="type"?E(c):s==="id"?u.find(h=>h.id===c)?.name||"Canal":"Todos"},_=()=>{if(e==="all")return n.jsx(j,{className:"w-4 h-4"});const{filterType:s,value:c}=V(e);if(s==="type")return N(c);if(s==="id"){const l=u.find(h=>h.id===c);return l?N(l.type,l):n.jsx(g,{className:"w-4 h-4"})}return n.jsx(j,{className:"w-4 h-4"})};return n.jsxs(F,{value:e,onValueChange:t,children:[n.jsx(k,{className:x("h-9 gap-2 px-3 rounded-lg border border-border bg-background hover:bg-muted/50 transition-all text-sm font-medium","focus:ring-1 focus:ring-primary/20",a),children:n.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[d?n.jsx(P,{className:"w-4 h-4 animate-spin text-muted-foreground"}):n.jsx("span",{className:"text-primary shrink-0",children:_()}),n.jsx("span",{className:"truncate",children:W()})]})}),n.jsxs(G,{align:"start",className:"min-w-[220px] max-h-[320px]",children:[n.jsx(z,{value:"all",className:"cursor-pointer",children:n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("span",{className:x("text-muted-foreground",e==="all"&&"text-primary"),children:n.jsx(j,{className:"w-4 h-4"})}),n.jsx("span",{className:"font-medium",children:"Todos los canales"})]})}),!d&&O.map(s=>{const c=C[s];return n.jsxs("div",{children:[n.jsx("div",{className:"px-2 py-1.5 text-[10px] font-semibold text-muted-foreground uppercase tracking-wider mt-1 border-t border-border pt-2",children:E(s)}),c.map(l=>{const h=`id:${l.id}`,v=o&&J(l);return n.jsx(z,{value:h,disabled:v,className:x("cursor-pointer pl-4",v&&"opacity-70"),children:n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("span",{className:x("text-muted-foreground",e===h&&"text-primary"),children:N(s,l)}),n.jsx("span",{className:x("font-medium truncate",v?"max-w-[110px]":"max-w-[150px]"),children:l.name}),v&&n.jsxs("span",{className:"ml-auto flex items-center gap-1 text-[10px] font-medium text-amber-600 dark:text-amber-400 shrink-0",children:[n.jsx(B,{className:"w-3 h-3"}),"Reconectar"]})]})},l.id)})]},s)}),d&&n.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[n.jsx(P,{className:"w-3 h-3 animate-spin"}),"Cargando canales..."]}),!d&&O.length===0&&n.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No hay canales configurados"})]})]})});le.displayName="ChannelSelector";export{le as C,ne as F,b as G,K as P,se as S,fe as a,he as b,Q as c,V as p,U as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{aA as e}from"./index-DsyZ_FlA.js";import"./recharts-DrC5kNsx.js";export{e as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as a,a3 as x,a4 as j,a5 as m,a6 as f,a7 as h,ac as D,B as e}from"./index-DsyZ_FlA.js";function C({open:l,onOpenChange:i,onConfirm:r,title:o,description:n,confirmText:c="Confirmar",cancelText:t="Cancelar",variant:d="default",loading:s=!1}){return a.jsx(x,{open:l,onOpenChange:i,children:a.jsxs(j,{className:"sm:max-w-[425px]",children:[a.jsxs(m,{children:[a.jsx(f,{children:o}),a.jsx(h,{children:n})]}),a.jsxs(D,{children:[a.jsx(e,{variant:"outline",onClick:()=>i(!1),disabled:s,children:t}),a.jsx(e,{variant:d,onClick:r,disabled:s,children:s?"Procesando...":c})]})]})})}export{C};
|