@johpaz/hive-agents 0.0.43 → 0.0.45

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 (69) hide show
  1. package/README.md +16 -16
  2. package/dist/hive.js +2256 -1837
  3. package/dist/tool-worker.js +30 -0
  4. package/dist/ui/assets/AgentCreateForm-DzaIT-dA.js +1 -0
  5. package/dist/ui/assets/AgentDetailPage-DgqcJceY.js +1 -0
  6. package/dist/ui/assets/AgentNewPage-CNSpoOSA.js +1 -0
  7. package/dist/ui/assets/{AgentsPage-CGQerrQm.js → AgentsPage-BMUJzTD6.js} +1 -1
  8. package/dist/ui/assets/ApiClientPage-Cum_a_3j.js +3 -0
  9. package/dist/ui/assets/{CanvasPage-Bq8cMKEA.js → CanvasPage-o6oCP6uq.js} +4 -4
  10. package/dist/ui/assets/{ChannelsPage-O2s7RXvS.js → ChannelsPage-WrB0zwLq.js} +1 -1
  11. package/dist/ui/assets/DashboardPage-BCd6kNw0.js +6 -0
  12. package/dist/ui/assets/{LoginPage-B8_NhCDi.js → LoginPage-BTxJdFVG.js} +1 -1
  13. package/dist/ui/assets/{LogsPage-DrjHFxGj.js → LogsPage-DVV2eHbh.js} +1 -1
  14. package/dist/ui/assets/{MeetingPage-B2OPRLkn.js → MeetingPage-BULIAWzq.js} +1 -1
  15. package/dist/ui/assets/ModelSelector-BMYOChYb.js +1 -0
  16. package/dist/ui/assets/ProvidersPage-BVN5UZrI.js +1 -0
  17. package/dist/ui/assets/{RecoverPage-kVmp-hM5.js → RecoverPage-7YDQysBL.js} +1 -1
  18. package/dist/ui/assets/SettingsPage-CYmpFfDn.js +9 -0
  19. package/dist/ui/assets/SetupPage-Dnmb1Lbv.js +1 -0
  20. package/dist/ui/assets/{WebChatPage-Dg5mE1ex.js → WebChatPage-DmmdFhIC.js} +1 -1
  21. package/dist/ui/assets/{alert-BQRmSe5N.js → alert-B9J6KHmt.js} +1 -1
  22. package/dist/ui/assets/{alert-dialog-CdDNVtq1.js → alert-dialog-KcYQWcJ6.js} +1 -1
  23. package/dist/ui/assets/{badge-Cn2irDlB.js → badge-88dRb4M8.js} +1 -1
  24. package/dist/ui/assets/{dialog-Dlh5z8bZ.js → dialog-Jk4bieO4.js} +1 -1
  25. package/dist/ui/assets/{es-BnP6oQsd.js → es-4I-joeZz.js} +1 -1
  26. package/dist/ui/assets/{index-CpfjkhN8.js → index-Cyw7L0Li.js} +3 -3
  27. package/dist/ui/assets/{label-fxFZcU5G.js → label-B_15zZlR.js} +1 -1
  28. package/dist/ui/assets/useHiveAgentsModelLoad-BnC4jLE-.js +1 -0
  29. package/dist/ui/assets/useProviders-C1xVKLxB.js +1 -0
  30. package/dist/ui/index.html +1 -1
  31. package/package.json +1 -1
  32. package/packages/core/src/agent/goal-runner.ts +31 -2
  33. package/packages/core/src/agent/llm-client.ts +22 -1
  34. package/packages/core/src/agent/proof-packet.ts +59 -0
  35. package/packages/core/src/agent/run-epoch.ts +33 -0
  36. package/packages/core/src/agent/run-store.ts +50 -8
  37. package/packages/core/src/channels/telegram.ts +31 -2
  38. package/packages/core/src/config/loader.ts +34 -0
  39. package/packages/core/src/gateway/durable-queue.ts +49 -4
  40. package/packages/core/src/gateway/job-executors.ts +50 -11
  41. package/packages/core/src/gateway/job-store.ts +142 -4
  42. package/packages/core/src/gateway/routes/cron-api.ts +3 -2
  43. package/packages/core/src/gateway/routes/users.ts +1 -0
  44. package/packages/core/src/gateway/server.ts +24 -2
  45. package/packages/core/src/resilience/retry.ts +95 -0
  46. package/packages/core/src/scheduler/integration.ts +19 -0
  47. package/packages/core/src/storage/bootstrap.ts +3 -0
  48. package/packages/core/src/storage/collections.ts +36 -0
  49. package/packages/core/src/storage/seed.ts +16 -14
  50. package/packages/skills/src/bundled-data.generated.ts +1107 -1107
  51. package/dist/ui/assets/AgentCreateForm-yUipEHs7.js +0 -1
  52. package/dist/ui/assets/AgentDetailPage-JbsD35Ag.js +0 -1
  53. package/dist/ui/assets/AgentNewPage-CJMzvxcC.js +0 -1
  54. package/dist/ui/assets/ApiClientPage-rI7YUUc5.js +0 -3
  55. package/dist/ui/assets/DashboardPage-CR3CyUJ5.js +0 -6
  56. package/dist/ui/assets/ProvidersPage-Vxg6V3cE.js +0 -1
  57. package/dist/ui/assets/SettingsPage-CNdLt5P_.js +0 -9
  58. package/dist/ui/assets/SetupPage-Ci_Zs3BT.js +0 -1
  59. package/dist/ui/assets/cpu-KDy6-FAI.js +0 -1
  60. package/dist/ui/assets/save-hUmZhceG.js +0 -1
  61. package/dist/ui/assets/useHiveAgentsModelLoad-D9gkq-VO.js +0 -1
  62. package/dist/ui/assets/useProviders-Klaz5WFx.js +0 -1
  63. /package/dist/ui/assets/{NotFound-CZGGDBTp.js → NotFound-BIUDlIXU.js} +0 -0
  64. /package/dist/ui/assets/{accordion-BubmDfgS.js → accordion-CnLzKNHK.js} +0 -0
  65. /package/dist/ui/assets/{card-DFKnZ6ky.js → card-CNf6BS2e.js} +0 -0
  66. /package/dist/ui/assets/{format-BwdV8bB5.js → format-DsLPBxvt.js} +0 -0
  67. /package/dist/ui/assets/{progress-BaTQRPPu.js → progress-D5c-Eilm.js} +0 -0
  68. /package/dist/ui/assets/{scroll-area-8uM7g-LF.js → scroll-area-CihOx0cb.js} +0 -0
  69. /package/dist/ui/assets/{tabs-CqK5bFsS.js → tabs-LQidMKRS.js} +0 -0
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{_ as t}from"./vendor-charts-Bu2lyBKP.js";import{o as n}from"./vendor-query-DsWPbQdG.js";import{t as r}from"./utils-3pnRFmFe.js";import{c as i,i as a,n as o,o as s,s as c,t as l}from"./select-BQCOjM2j.js";import{t as u}from"./circle-alert-KuAm2FWh.js";import{t as d}from"./cpu-KDy6-FAI.js";import{t as f}from"./external-link-6sTlRDUR.js";import{t as p}from"./folder-open-DJBLDFjv.js";import{t as m}from"./loader-circle-BmBOgYze.js";import{t as h}from"./save-hUmZhceG.js";import{t as g}from"./shield-CxhcUT39.js";import{t as _}from"./sparkles-BhwlS1pc.js";import{A as v,L as y,R as b,f as x,h as S,j as C,m as w,s as T,t as E}from"./index-CpfjkhN8.js";import{t as D}from"./label-fxFZcU5G.js";import{t as O}from"./textarea-B6Z1Zc6W.js";import{t as k}from"./switch-BR30E4ej.js";import{a as A,c as j,i as M,n as N,o as P,r as F,s as I,t as L}from"./dialog-Dlh5z8bZ.js";import{t as R}from"./badge-Cn2irDlB.js";import{a as z,n as B,o as V,r as H,t as U}from"./card-DFKnZ6ky.js";import"./useProviders-Klaz5WFx.js";import{t as W}from"./useHiveAgentsModelLoad-D9gkq-VO.js";var G=e(t(),1),K=n();function q({selectedProviderId:e,selectedModelId:t,onProviderChange:n,onModelChange:r,disabled:i=!1,typeFilter:u}){let{providers:d,models:f}=T(),{load:p,cancel:m}=W(),h=e=>{if(e.id===`ollama`||e.id===`hiveagents`)return!0;let t=e.base_url||e.baseUrl||``;return t.includes(`localhost`)||t.includes(`127.0.0.1`)?!0:!!e.has_api_key},g=e=>{if(e.id===`ollama`)return!0;let t=e.base_url||e.baseUrl||``;return t.includes(`localhost`)||t.includes(`127.0.0.1`)},_=d.filter(e=>e.enabled&&e.active&&h(e)&&(e.category??`llm`)===`llm`),v=d.find(t=>t.id===e),b=!!v&&!_.some(e=>e.id===v.id),x=(0,G.useMemo)(()=>e?f.filter(t=>{let n=(t.provider_id||t.providerId)===e,r=!u||t.model_type===u;return n&&r}):[],[e,f,u]),C=(0,G.useMemo)(()=>x.filter(e=>e.enabled||e.active),[x]),w=x.find(e=>e.id===t),E=!!w&&!C.some(e=>e.id===w.id);(0,G.useEffect)(()=>{t&&x.length>0&&!x.find(e=>e.id===t)&&r(``)},[x,t,r]);let O=e=>{if(!e)return[];try{return JSON.parse(e)}catch{return[]}};return(0,G.useEffect)(()=>()=>m(),[e,t,m]),(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(D,{htmlFor:`provider`,children:`Proveedor de IA`}),(0,K.jsxs)(l,{value:e||``,onValueChange:n,disabled:i||_.length===0,children:[(0,K.jsx)(s,{id:`provider`,className:`w-full`,children:(0,K.jsx)(c,{placeholder:`Selecciona un proveedor`,children:e&&v?(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{children:v.name}),b&&(0,K.jsx)(`span`,{className:`text-[10px] text-amber-400/80`,children:`(inactivo)`}),g(v)?(0,K.jsx)(`span`,{className:`text-[9px] font-bold px-1.5 py-0.5 rounded-full bg-amber-500/20 text-amber-400`,children:`LOCAL`}):(0,K.jsx)(`span`,{className:`text-[9px] font-bold px-1.5 py-0.5 rounded-full bg-emerald-500/20 text-emerald-400`,children:`API`})]}):`Selecciona un proveedor`})}),(0,K.jsx)(o,{children:_.length===0?(0,K.jsx)(a,{value:`none`,disabled:!0,children:`No hay proveedores configurados`}):_.map(e=>(0,K.jsx)(a,{value:e.id,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{children:e.name}),g(e)?(0,K.jsx)(`span`,{className:`text-[9px] font-bold px-1.5 py-0.5 rounded-full bg-amber-500/20 text-amber-400`,children:`LOCAL`}):(0,K.jsx)(`span`,{className:`text-[9px] font-bold px-1.5 py-0.5 rounded-full bg-emerald-500/20 text-emerald-400`,children:`API`})]})},e.id))})]}),b&&v&&(0,K.jsxs)(`p`,{className:`text-[10px] text-amber-400/80`,children:[`El proveedor "`,v.name,`" está inactivo. Selecciona uno activo para cambiar.`]}),_.length===0&&(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Configura un proveedor en`,` `,(0,K.jsx)(`a`,{href:`/providers`,className:`text-primary underline`,children:`Settings > Providers`})]})]}),e&&(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(D,{htmlFor:`model`,children:`Modelo`}),(0,K.jsxs)(l,{value:t||``,onValueChange:async t=>{if(e===`hiveagents`&&t){let e=C.find(e=>e.id===t)?.contextWindow;if(!e){y.error(`No se pudo determinar el context_window del modelo`,{description:`Revisá la configuración del modelo en la base de datos.`});return}S.show(`Cargando modelo en HiveAgents…`);let n=await p(t,e);if(S.hide(),!n){y.error(`No se pudo confirmar la carga del modelo`,{description:`Intenta seleccionar el modelo nuevamente o verifica la conexión.`});return}y.success(`Modelo listo`,{description:`El modelo de HiveAgents ya está cargado y listo para usar.`})}r(t)},disabled:i||C.length===0,children:[(0,K.jsx)(s,{id:`model`,className:`w-full`,children:(0,K.jsx)(c,{placeholder:`Selecciona un modelo`,children:t&&w?(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{children:w.name}),E&&(0,K.jsx)(`span`,{className:`text-[10px] text-amber-400/80`,children:`(inactivo)`})]}):`Selecciona un modelo`})}),(0,K.jsx)(o,{children:C.length===0?(0,K.jsx)(a,{value:`none`,disabled:!0,children:`No hay modelos disponibles`}):C.map(e=>(0,K.jsx)(a,{value:e.id,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{children:e.name}),e.contextWindow&&(0,K.jsxs)(R,{variant:`secondary`,className:`text-[10px]`,children:[(e.contextWindow/1e3).toFixed(0),`K ctx`]})]})},e.id))})]}),E&&w&&(0,K.jsxs)(`p`,{className:`text-[10px] text-amber-400/80`,children:[`El modelo "`,w.name,`" está inactivo. Selecciona uno activo para cambiar.`]}),t&&x.find(e=>e.id===t)&&(0,K.jsx)(U,{className:`mt-2`,children:(0,K.jsxs)(B,{className:`p-3 space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium`,children:x.find(e=>e.id===t)?.name}),(0,K.jsx)(R,{variant:`outline`,children:d.find(t=>t.id===e)?.name})]}),(()=>{let e=O(x.find(e=>e.id===t)?.capabilities);return e.length>0?(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.slice(0,5).map(e=>(0,K.jsx)(R,{variant:`secondary`,className:`text-[10px]`,children:e},e))}):null})()]})})]})]})}var ee=[{value:`friendly`,label:`Amigable`},{value:`professional`,label:`Profesional`},{value:`casual`,label:`Casual`},{value:`formal`,label:`Formal`},{value:`creative`,label:`Creativo`}];function te({initialData:e,onSuccess:t,onCancel:n}){let{createAgent:y,updateAgent:S,isLoading:R,error:W}=E(),{activeProviders:te}=T(),[J,Y]=(0,G.useState)({isValidating:!1,exists:!1,accessible:!1}),[X,Z]=(0,G.useState)({name:``,description:``,tone:`professional`,provider_id:``,model_id:``,role:`coordinator`,enabled:!0,systemPrompt:``,workspace:e?.workspace||``});(0,G.useEffect)(()=>{e&&Z({...e,provider_id:e.provider_id||e.providerId||``,model_id:e.model_id||e.modelId||``})},[e]);let Q=async e=>{if(!e||e.trim()===``){Y({isValidating:!1,exists:!1,accessible:!1});return}Y({isValidating:!0,exists:!1,accessible:!1});try{let t=await x(`/api/workspace/validate`,{method:`POST`,body:{path:e}});Y({isValidating:!1,exists:t.exists,accessible:t.accessible,error:t.error,message:t.message})}catch(e){Y({isValidating:!1,exists:!1,accessible:!1,error:e.message})}},ne=async()=>{if(X.workspace)try{await x(`/api/workspace/create`,{method:`POST`,body:{path:X.workspace},showLoader:`Creando directorio...`,showSuccess:`Directorio creado exitosamente`}),await Q(X.workspace)}catch(e){w.fire(`Error`,e.message,`error`)}},re=async()=>{if(X.workspace)try{await x(`/api/workspace/open?path=${encodeURIComponent(X.workspace)}`,{method:`GET`})}catch(e){w.fire(`Error`,e.message,`error`)}},ie=async n=>{if(n.preventDefault(),!X.provider_id||!X.model_id){w.fire(`Incompleto`,`Por favor selecciona un proveedor y modelo`,`warning`);return}try{e?.id?await S(e.id,X):await y(X),t&&t()}catch(e){console.error(e)}},$=!!e?.id;return(0,K.jsxs)(U,{className:`hive-card--form group`,children:[(0,K.jsx)(`div`,{className:`hive-glow-blob--card absolute -top-24 -right-24 h-48 w-48 bg-blue-600/10 group-hover:bg-blue-600/20`,style:{borderRadius:`50%`,filter:`blur(80px)`}}),(0,K.jsx)(z,{className:`relative`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`hive-icon-wrap hive-icon-wrap--primary`,children:$?(0,K.jsx)(h,{className:`h-5 w-5`}):(0,K.jsx)(_,{className:`h-5 w-5`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(V,{className:`text-xl font-bold text-white/90`,children:$?`Configurar Nodo`:`Desplegar Nuevo Nodo`}),(0,K.jsx)(H,{className:`text-white/40`,children:$?`Ajusta los parámetros de tu agente inteligente.`:`Crea una nueva entidad inteligente para tu colmena.`})]})]}),n&&(0,K.jsx)(C,{variant:`ghost`,size:`icon`,onClick:n,className:`text-white/40 hover:text-white hover:bg-white/5`,children:(0,K.jsx)(b,{className:`h-5 w-5`})})]})}),(0,K.jsx)(B,{className:`relative space-y-6 pt-2`,children:(0,K.jsxs)(`form`,{onSubmit:ie,className:`space-y-8`,children:[(0,K.jsxs)(`div`,{className:`grid gap-6`,children:[(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(D,{htmlFor:`name`,className:`hive-label--field`,children:`Nombre del Agente`}),(0,K.jsx)(v,{id:`name`,placeholder:`Ej: Analista de Mercado`,className:`hive-input`,value:X.name,onChange:e=>Z({...X,name:e.target.value}),disabled:R,required:!0})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(D,{htmlFor:`description`,className:`hive-label--field`,children:`Descripción / Rol`}),(0,K.jsx)(O,{id:`description`,placeholder:`Describe qué hace este agente y cuáles son sus objetivos...`,className:`hive-textarea`,value:X.description,onChange:e=>Z({...X,description:e.target.value}),disabled:R})]})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(D,{htmlFor:`systemPrompt`,className:`hive-label--field`,children:`System Prompt`}),(0,K.jsxs)(L,{children:[(0,K.jsx)(j,{asChild:!0,children:(0,K.jsx)(C,{type:`button`,variant:`outline`,size:`sm`,className:`h-7 px-3 text-xs bg-blue-500/10 hover:bg-blue-500/20 text-blue-400 border-blue-500/30 transition-colors`,children:`Modifica acá el System Prompt`})}),(0,K.jsxs)(F,{className:`sm:max-w-3xl bg-[#0a0a0c] border-white/10 text-white shadow-2xl [&>button]:text-white/50 hover:[&>button]:text-white`,children:[(0,K.jsxs)(P,{children:[(0,K.jsx)(I,{className:`text-xl`,children:`Editar System Prompt`}),(0,K.jsx)(M,{className:`text-sm text-white/50`,children:`El prompt base de comportamiento del agente. Se recomienda formato Markdown.`})]}),(0,K.jsx)(`div`,{className:`py-2`,children:(0,K.jsx)(O,{value:X.systemPrompt||``,onChange:e=>Z({...X,systemPrompt:e.target.value}),className:`min-h-[400px] font-mono text-sm bg-black/40 border-white/10 text-white/90 focus-visible:ring-blue-500/50 resize-y`,placeholder:`Escribe el system prompt detallado aquí...`,disabled:R})}),(0,K.jsx)(A,{children:(0,K.jsx)(N,{asChild:!0,children:(0,K.jsx)(C,{type:`button`,className:`bg-blue-600 hover:bg-blue-500 text-white shadow-[0_0_15px_rgba(37,99,235,0.3)]`,children:`Guardar Cambios`})})})]})]})]}),X.systemPrompt?(0,K.jsxs)(`p`,{className:`text-xs text-white/40 line-clamp-1 italic border border-white/5 bg-white/[0.02] p-2 rounded-md`,children:[`"`,X.systemPrompt,`"`]}):(0,K.jsx)(`p`,{className:`text-xs text-white/30 italic`,children:`Sin system prompt configurado...`})]}),(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,K.jsx)(p,{className:`h-4 w-4 text-emerald-400`}),(0,K.jsx)(`h3`,{className:`hive-title-section`,children:`Workspace Directory`})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(D,{htmlFor:`workspace`,className:`hive-label--field`,children:`Directorio de Trabajo del Agente`}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(v,{id:`workspace`,placeholder:`Ej: /home/user/proyectos, D:\\Work, /Volumes/USB`,className:`hive-input flex-1 font-mono text-sm`,value:X.workspace,onChange:e=>{Z({...X,workspace:e.target.value}),Q(e.target.value)},disabled:R}),X.workspace&&J.exists&&J.accessible&&(0,K.jsx)(C,{type:`button`,variant:`outline`,size:`icon`,onClick:re,className:`shrink-0 border-emerald-500/30 text-emerald-400 hover:bg-emerald-500/10`,title:`Abrir en el explorador`,children:(0,K.jsx)(f,{className:`h-4 w-4`})})]}),(0,K.jsx)(`p`,{className:`text-xs text-white/40 leading-relaxed`,children:`Directorio donde el agente creará archivos, carpetas y ejecutará comandos. Puede ser cualquier ubicación en tu sistema (disco duro, USB, red, etc.).`}),X.workspace&&X.workspace.trim()!==``&&(0,K.jsxs)(`div`,{className:r(`flex items-center gap-2 text-xs p-2.5 rounded-lg border backdrop-blur-md transition-all`,J.isValidating&&`bg-blue-500/10 border-blue-500/20 text-blue-400`,!J.isValidating&&J.exists&&J.accessible&&`bg-emerald-500/10 border-emerald-500/20 text-emerald-400`,!J.isValidating&&J.exists&&!J.accessible&&`bg-amber-500/10 border-amber-500/20 text-amber-400`,!J.isValidating&&!J.exists&&`bg-purple-500/10 border-purple-500/20 text-purple-400`),children:[J.isValidating&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(m,{className:`h-3.5 w-3.5 animate-spin`}),(0,K.jsx)(`span`,{children:`Validando directorio...`})]}),!J.isValidating&&J.exists&&J.accessible&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(i,{className:`h-3.5 w-3.5`}),(0,K.jsx)(`span`,{children:J.message||`Directorio válido y accesible`})]}),!J.isValidating&&J.exists&&!J.accessible&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(u,{className:`h-3.5 w-3.5`}),(0,K.jsx)(`span`,{children:J.message||`El directorio existe pero no tiene permisos de lectura/escritura`})]}),!J.isValidating&&!J.exists&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(p,{className:`h-3.5 w-3.5`}),(0,K.jsx)(`span`,{children:J.message||`El directorio no existe`}),!J.error&&(0,K.jsx)(C,{type:`button`,variant:`outline`,size:`sm`,onClick:ne,className:`ml-auto h-6 px-2 text-xs bg-purple-500/20 hover:bg-purple-500/30 text-purple-300 border-purple-500/30`,children:`Crear directorio`})]})]})]})]}),(0,K.jsx)(`div`,{className:`hive-card-divider`}),(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,K.jsx)(d,{className:`h-4 w-4 text-blue-400`}),(0,K.jsx)(`h3`,{className:`hive-title-section`,children:`Motor de Inteligencia`})]}),(0,K.jsx)(q,{selectedProviderId:X.provider_id||void 0,selectedModelId:X.model_id||void 0,onProviderChange:e=>Z({...X,provider_id:e,model_id:``}),onModelChange:e=>Z({...X,model_id:e}),disabled:R,typeFilter:`llm`})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6`,children:[(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(D,{htmlFor:`tone`,className:`hive-label--field`,children:`Tono de Voz`}),(0,K.jsxs)(l,{value:X.tone,onValueChange:e=>Z({...X,tone:e}),disabled:R,children:[(0,K.jsx)(s,{className:`hive-select-trigger`,children:(0,K.jsx)(c,{placeholder:`Selecciona un tono`})}),(0,K.jsx)(o,{className:`hive-select-content`,children:ee.map(e=>(0,K.jsx)(a,{value:e.value,className:`hive-select-item`,children:e.label},e.value))})]})]}),(0,K.jsxs)(`div`,{className:`hive-toggle-panel`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(g,{className:`h-3.5 w-3.5 text-purple-400`}),(0,K.jsx)(D,{htmlFor:`role`,className:`text-xs font-medium text-white/70`,children:`Rol`})]}),(0,K.jsxs)(l,{value:X.role,onValueChange:e=>Z({...X,role:e}),disabled:R,children:[(0,K.jsx)(s,{className:`w-[120px] bg-white/5 border-white/10 text-white`,children:(0,K.jsx)(c,{})}),(0,K.jsxs)(o,{className:`bg-zinc-900 border-white/10`,children:[(0,K.jsx)(a,{value:`coordinator`,children:`Coordinador`}),(0,K.jsx)(a,{value:`worker`,children:`Worker`})]})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`div`,{className:`h-2 w-2 rounded-full ${X.enabled?`bg-blue-400`:`bg-zinc-600`}`}),(0,K.jsx)(D,{htmlFor:`enabled`,className:`text-xs font-medium text-white/70`,children:`Habilitado`})]}),(0,K.jsx)(k,{id:`enabled`,checked:X.enabled,onCheckedChange:e=>Z({...X,enabled:e}),disabled:R})]})]})]}),W&&(0,K.jsx)(`div`,{className:`hive-form-error`,children:W}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 pt-4`,children:[n&&(0,K.jsx)(C,{type:`button`,variant:`outline`,onClick:n,disabled:R,className:`hive-btn--form-cancel`,children:`Cancelar`}),(0,K.jsx)(C,{type:`submit`,disabled:R,className:`hive-btn--form-submit`,children:R?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(m,{className:`mr-2 h-4 w-4 animate-spin`}),`Procesando...`]}):(0,K.jsx)(K.Fragment,{children:$?`Actualizar Agente`:`Desplegar Agente`})})]})]})})]})}export{te as t};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{_ as t}from"./vendor-charts-Bu2lyBKP.js";import{o as n}from"./vendor-query-DsWPbQdG.js";import{r,t as i}from"./utils-3pnRFmFe.js";import{t as a}from"./activity-c3pNngT_.js";import{t as o}from"./calendar-B-KZ9RQO.js";import{c as s,i as c,n as l,o as u,s as d,t as f}from"./select-BQCOjM2j.js";import{t as p}from"./chevron-left-D4U-5A27.js";import{t as ee}from"./circle-alert-KuAm2FWh.js";import{t as m}from"./cpu-KDy6-FAI.js";import{t as te}from"./external-link-6sTlRDUR.js";import{t as h}from"./folder-open-DJBLDFjv.js";import{t as ne}from"./loader-circle-BmBOgYze.js";import{t as re}from"./save-hUmZhceG.js";import{t as ie}from"./shield-CxhcUT39.js";import{t as ae}from"./sparkles-BhwlS1pc.js";import{t as g}from"./zap-B4RaNNO5.js";import{c as _,l as v}from"./vendor-router-gqiZ7xhx.js";import{A as y,V as oe,f as b,h as x,j as S,o as C,p as w,q as se,s as T,t as E}from"./index-CpfjkhN8.js";import{t as D}from"./label-fxFZcU5G.js";import{t as O}from"./textarea-B6Z1Zc6W.js";import{t as k}from"./switch-BR30E4ej.js";import{a as A,c as j,i as M,n as N,o as P,r as F,s as ce,t as le}from"./dialog-Dlh5z8bZ.js";import{t as I}from"./badge-Cn2irDlB.js";import{n as L,t as R}from"./es-BnP6oQsd.js";import{t as z}from"./format-BwdV8bB5.js";var B=r(`Fingerprint`,[[`path`,{d:`M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4`,key:`1nerag`}],[`path`,{d:`M14 13.12c0 2.38 0 6.38-1 8.88`,key:`o46ks0`}],[`path`,{d:`M17.29 21.02c.12-.6.43-2.3.5-3.02`,key:`ptglia`}],[`path`,{d:`M2 12a10 10 0 0 1 18-6`,key:`ydlgp0`}],[`path`,{d:`M2 16h.01`,key:`1gqxmh`}],[`path`,{d:`M21.8 16c.2-2 .131-5.354 0-6`,key:`drycrb`}],[`path`,{d:`M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2`,key:`1tidbn`}],[`path`,{d:`M8.65 22c.21-.66.45-1.32.57-2`,key:`13wd9y`}],[`path`,{d:`M9 6.8a6 6 0 0 1 9 5.2v2`,key:`1fr1j5`}]]),V=r(`LayoutGrid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),H=e(t(),1),U=n();function W({icon:e,...t}){return(0,U.jsx)(e,{...t})}function G({agentId:e}){let{agents:t,updateAgent:n,fetchAgents:r}=E(),{providers:o,fetchProviders:p}=T(),{models:m,fetchModels:g}=C();(0,H.useEffect)(()=>{r(),p(),g()},[r,p,g]);let _=t.find(t=>t.id===e),[v,I]=(0,H.useState)({name:``,description:``,provider_id:``,model_id:``,tone:``,role:`coordinator`,enabled:!0,headers:``,systemPrompt:``,workspace:``}),[L,R]=(0,H.useState)({isValidating:!1,exists:!1,accessible:!1});(0,H.useEffect)(()=>{_&&(I({name:_.name||``,description:_.description||``,provider_id:_.provider_id||_.providerId||``,model_id:_.model_id||_.modelId||``,tone:_.tone||``,role:_.role||`coordinator`,enabled:!!_.enabled,headers:``,systemPrompt:_.systemPrompt||``,workspace:_.workspace||``}),_.workspace&&z(_.workspace))},[_]);let z=async e=>{if(!e||e.trim()===``){R({isValidating:!1,exists:!1,accessible:!1});return}R({isValidating:!0,exists:!1,accessible:!1});try{let t=await b(`/api/workspace/validate`,{method:`POST`,body:{path:e}});R({isValidating:!1,exists:t.exists,accessible:t.accessible,error:t.error,message:t.message})}catch(e){R({isValidating:!1,exists:!1,accessible:!1,error:e.message})}},B=async()=>{if(v.workspace)try{await b(`/api/workspace/create`,{method:`POST`,body:{path:v.workspace},showLoader:`Creando directorio...`,showSuccess:`Directorio creado exitosamente`}),await z(v.workspace)}catch(e){w.fire({icon:`error`,title:e.message})}},V=async()=>{if(v.workspace)try{await b(`/api/workspace/open?path=${encodeURIComponent(v.workspace)}`,{method:`GET`})}catch(e){w.fire({icon:`error`,title:e.message})}},G=async()=>{x.show(`Sincronizando configuración del agente...`);try{await n(e,{...v,role:v.role,enabled:+!!v.enabled,workspace:v.workspace||null}),w.fire({icon:`success`,title:`Cambios sincronizados correctamente`})}catch(e){w.fire({icon:`error`,title:e instanceof Error?e.message:`Error al sincronizar cambios`})}finally{x.hide()}};if(!_)return(0,U.jsxs)(`div`,{className:`flex flex-col items-center justify-center p-12 text-center space-y-4 rounded-3xl border border-dashed border-white/10 bg-white/5`,children:[(0,U.jsx)(W,{icon:a,className:`h-12 w-12 text-white/10 animate-pulse`}),(0,U.jsx)(`p`,{className:`text-white/40 font-medium`,children:`Buscando nodo en la colmena...`})]});let K=e=>{if(e.id===`ollama`||e.id===`hiveagents`)return!0;let t=e.base_url||e.baseUrl||``;return t.includes(`localhost`)||t.includes(`127.0.0.1`)?!0:!!e.has_api_key},q=e=>{if(e.id===`ollama`)return!0;let t=e.base_url||e.baseUrl||``;return t.includes(`localhost`)||t.includes(`127.0.0.1`)},J=o.filter(e=>e.enabled&&e.active&&K(e)&&(e.category??`llm`)===`llm`),Y=m.filter(e=>(e.provider_id||e.providerId)===v.provider_id&&(e.enabled||e.active)),X=o.find(e=>e.id===v.provider_id),Z=!!X&&!J.some(e=>e.id===X.id),Q=m.filter(e=>(e.provider_id||e.providerId)===v.provider_id).find(e=>e.id===v.model_id),$=!!Q&&!Y.some(e=>e.id===Q.id);return(0,U.jsx)(`div`,{className:`space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-500`,children:(0,U.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-3 gap-8`,children:[(0,U.jsxs)(`div`,{className:`lg:col-span-1 space-y-6`,children:[(0,U.jsxs)(`div`,{className:`p-6 rounded-3xl border border-white/10 bg-black/20 backdrop-blur-md space-y-6`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(`div`,{className:`p-2 rounded-xl bg-blue-500/10 border border-blue-500/20`,children:(0,U.jsx)(W,{icon:oe,className:`h-4 w-4 text-blue-400`})}),(0,U.jsx)(`h3`,{className:`font-bold text-white uppercase tracking-wider text-xs`,children:`Identidad Base`})]}),(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(D,{htmlFor:`name`,className:`text-xs text-white/40 uppercase tracking-widest pl-1`,children:`Nombre Público`}),(0,U.jsx)(y,{id:`name`,value:v.name,onChange:e=>I(t=>({...t,name:e.target.value})),className:`bg-white/5 border-white/10 focus:border-blue-500/50 rounded-xl h-11`,placeholder:`Nombre del nodo`})]}),(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(D,{htmlFor:`tone`,className:`text-xs text-white/40 uppercase tracking-widest pl-1`,children:`Tono Cognitivo`}),(0,U.jsx)(y,{id:`tone`,value:v.tone,onChange:e=>I(t=>({...t,tone:e.target.value})),className:`bg-white/5 border-white/10 focus:border-blue-500/50 rounded-xl h-11`,placeholder:`Ej: Analítico, Conciso...`})]})]})]}),(0,U.jsxs)(`div`,{className:`p-6 rounded-3xl border border-white/10 bg-black/20 backdrop-blur-md space-y-6`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(`div`,{className:`p-2 rounded-xl bg-purple-500/10 border border-purple-500/20`,children:(0,U.jsx)(W,{icon:ie,className:`h-4 w-4 text-purple-400`})}),(0,U.jsx)(`h3`,{className:`font-bold text-white uppercase tracking-wider text-xs`,children:`Permisos de Red`})]}),(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between p-3 rounded-2xl bg-white/5 hover:bg-white/10 transition-colors`,children:[(0,U.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,U.jsx)(D,{className:`text-sm font-semibold`,children:`Rol`}),(0,U.jsx)(`p`,{className:`text-[10px] text-white/30`,children:`Coordinador o Worker`})]}),(0,U.jsxs)(f,{value:v.role,onValueChange:e=>I(t=>({...t,role:e})),children:[(0,U.jsx)(u,{className:`w-[120px] bg-white/5 border-white/10 text-white`,children:(0,U.jsx)(d,{})}),(0,U.jsxs)(l,{className:`bg-zinc-900 border-white/10`,children:[(0,U.jsx)(c,{value:`coordinator`,children:`Coordinador`}),(0,U.jsx)(c,{value:`worker`,children:`Worker`})]})]})]}),(0,U.jsxs)(`div`,{className:`flex items-center justify-between p-3 rounded-2xl bg-white/5 hover:bg-white/10 transition-colors`,children:[(0,U.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,U.jsx)(D,{className:`text-sm font-semibold`,children:`Nodo Activo`}),(0,U.jsx)(`p`,{className:`text-[10px] text-white/30`,children:`Disponible para la colmena`})]}),(0,U.jsx)(k,{checked:v.enabled,onCheckedChange:e=>I(t=>({...t,enabled:e}))})]})]})]}),(0,U.jsxs)(`div`,{className:`p-6 rounded-3xl border border-white/10 bg-black/20 backdrop-blur-md space-y-6`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(`div`,{className:`p-2 rounded-xl bg-emerald-500/10 border border-emerald-500/20`,children:(0,U.jsx)(W,{icon:h,className:`h-4 w-4 text-emerald-400`})}),(0,U.jsx)(`h3`,{className:`font-bold text-white uppercase tracking-wider text-xs`,children:`Workspace Directory`})]}),(0,U.jsx)(`div`,{className:`space-y-4`,children:(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(D,{htmlFor:`workspace`,className:`text-xs text-white/40 uppercase tracking-widest pl-1`,children:`Directorio de Trabajo`}),(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(y,{id:`workspace`,value:v.workspace,onChange:e=>{I(t=>({...t,workspace:e.target.value})),z(e.target.value)},className:`bg-white/5 border-white/10 focus:border-emerald-500/50 rounded-xl h-11 font-mono text-sm flex-1`,placeholder:`Ej: /home/user/proyectos, D:\\Work`}),v.workspace&&L.exists&&L.accessible&&(0,U.jsx)(S,{type:`button`,variant:`outline`,size:`icon`,onClick:V,className:`shrink-0 border-emerald-500/30 text-emerald-400 hover:bg-emerald-500/10 h-11 w-11`,title:`Abrir en el explorador`,children:(0,U.jsx)(te,{className:`h-4 w-4`})})]}),(0,U.jsx)(`p`,{className:`text-xs text-white/40 leading-relaxed`,children:`Directorio donde el agente operará. Puede ser cualquier ubicación (disco, USB, red).`}),v.workspace&&v.workspace.trim()!==``&&(0,U.jsxs)(`div`,{className:i(`flex items-center gap-2 text-xs p-2.5 rounded-lg border backdrop-blur-md transition-all`,L.isValidating&&`bg-blue-500/10 border-blue-500/20 text-blue-400`,!L.isValidating&&L.exists&&L.accessible&&`bg-emerald-500/10 border-emerald-500/20 text-emerald-400`,!L.isValidating&&L.exists&&!L.accessible&&`bg-amber-500/10 border-amber-500/20 text-amber-400`,!L.isValidating&&!L.exists&&`bg-purple-500/10 border-purple-500/20 text-purple-400`),children:[L.isValidating&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(ne,{className:`h-3.5 w-3.5 animate-spin`}),(0,U.jsx)(`span`,{children:`Validando directorio...`})]}),!L.isValidating&&L.exists&&L.accessible&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(s,{className:`h-3.5 w-3.5`}),(0,U.jsx)(`span`,{children:L.message||`Directorio válido y accesible`})]}),!L.isValidating&&L.exists&&!L.accessible&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(ee,{className:`h-3.5 w-3.5`}),(0,U.jsx)(`span`,{children:L.message||`Sin permisos de lectura/escritura`})]}),!L.isValidating&&!L.exists&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(h,{className:`h-3.5 w-3.5`}),(0,U.jsx)(`span`,{children:L.message||`El directorio no existe`}),!L.error&&(0,U.jsx)(S,{type:`button`,variant:`outline`,size:`sm`,onClick:B,className:`ml-auto h-6 px-2 text-xs bg-purple-500/20 hover:bg-purple-500/30 text-purple-300 border-purple-500/30`,children:`Crear`})]})]})]})})]})]}),(0,U.jsx)(`div`,{className:`lg:col-span-2 space-y-6`,children:(0,U.jsxs)(`div`,{className:`p-8 rounded-3xl border border-white/10 bg-black/20 backdrop-blur-md space-y-8`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(`div`,{className:`p-2 rounded-xl bg-amber-500/10 border border-amber-500/20`,children:(0,U.jsx)(W,{icon:ae,className:`h-4 w-4 text-amber-400`})}),(0,U.jsx)(`h3`,{className:`font-bold text-white uppercase tracking-wider text-xs`,children:`Configuración Cognitiva`})]}),(0,U.jsxs)(S,{onClick:G,className:`bg-blue-600 hover:bg-blue-500 text-white font-bold rounded-xl px-6 shadow-[0_4px_15px_rgba(37,99,235,0.3)] transition-all active:scale-95 gap-2`,children:[(0,U.jsx)(W,{icon:re,className:`h-4 w-4`}),`Sincronizar Cambios`]})]}),(0,U.jsxs)(`div`,{className:`space-y-6`,children:[(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(D,{htmlFor:`description`,className:`text-xs text-white/40 uppercase tracking-widest pl-1`,children:`Directiva de Misión (Descripción)`}),(0,U.jsx)(O,{id:`description`,value:v.description,onChange:e=>I(t=>({...t,description:e.target.value})),className:`bg-white/5 border-white/10 focus:border-blue-500/50 rounded-2xl min-h-[80px] resize-none`,placeholder:`Define el propósito general de este nodo...`})]}),(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between pl-1`,children:[(0,U.jsx)(D,{className:`text-xs text-white/40 uppercase tracking-widest`,children:`System Prompt (Markdown)`}),(0,U.jsxs)(le,{children:[(0,U.jsx)(j,{asChild:!0,children:(0,U.jsx)(S,{type:`button`,variant:`outline`,size:`sm`,className:`h-7 px-3 text-xs bg-blue-500/10 hover:bg-blue-500/20 text-blue-400 border-blue-500/30 transition-colors`,children:`Modifica acá el System Prompt`})}),(0,U.jsxs)(F,{className:`sm:max-w-3xl bg-[#0a0a0c] border-white/10 text-white shadow-2xl [&>button]:text-white/50 hover:[&>button]:text-white`,children:[(0,U.jsxs)(P,{children:[(0,U.jsx)(ce,{className:`text-xl`,children:`Editar System Prompt`}),(0,U.jsx)(M,{className:`text-sm text-white/50`,children:`El comportamiento principal del agente. Se recomienda usar Markdown.`})]}),(0,U.jsx)(`div`,{className:`py-2`,children:(0,U.jsx)(O,{value:v.systemPrompt,onChange:e=>I(t=>({...t,systemPrompt:e.target.value})),className:`min-h-[400px] font-mono text-sm bg-black/40 border-white/10 text-white/90 focus-visible:ring-blue-500/50 resize-y`,placeholder:`Escribe el system prompt detallado aquí...`})}),(0,U.jsx)(A,{children:(0,U.jsx)(N,{asChild:!0,children:(0,U.jsx)(S,{type:`button`,className:`bg-blue-600 hover:bg-blue-500 text-white shadow-[0_0_15px_rgba(37,99,235,0.3)]`,children:`Listo`})})})]})]})]}),v.systemPrompt?(0,U.jsx)(`div`,{className:`bg-white/[0.02] border border-white/5 rounded-2xl p-4 max-h-[120px] overflow-y-auto custom-scrollbar`,children:(0,U.jsx)(`p`,{className:`text-xs text-white/60 font-mono whitespace-pre-wrap italic`,children:v.systemPrompt})}):(0,U.jsx)(`div`,{className:`bg-white/[0.02] border border-white/5 rounded-2xl p-4`,children:(0,U.jsx)(`p`,{className:`text-xs text-white/30 italic`,children:`Sin system prompt configurado...`})})]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6`,children:[(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between pl-1`,children:[(0,U.jsx)(D,{className:`text-xs text-white/40 uppercase tracking-widest`,children:`Proveedor`}),J.length===0&&(0,U.jsx)(`span`,{className:`text-[10px] text-amber-400/80`,children:`Sin providers activos`})]}),(0,U.jsxs)(f,{value:v.provider_id,onValueChange:e=>I(t=>({...t,provider_id:e,model_id:``})),children:[(0,U.jsx)(u,{className:`bg-white/5 border-white/10 rounded-xl h-11`,children:(0,U.jsx)(d,{placeholder:`Seleccionar proveedor`,children:v.provider_id&&X?(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`span`,{children:X.name}),Z&&(0,U.jsx)(`span`,{className:`text-[10px] text-amber-400/80`,children:`(inactivo)`}),q(X)?(0,U.jsx)(`span`,{className:`text-[9px] font-bold px-1.5 py-0.5 rounded-full bg-amber-500/20 text-amber-400`,children:`LOCAL`}):(0,U.jsx)(`span`,{className:`text-[9px] font-bold px-1.5 py-0.5 rounded-full bg-emerald-500/20 text-emerald-400`,children:`API`})]}):`Seleccionar proveedor`})}),(0,U.jsxs)(l,{className:`bg-zinc-900 border-white/10 text-white`,children:[J.length===0&&(0,U.jsx)(`div`,{className:`px-3 py-4 text-center text-xs text-white/30`,children:`Activa al menos un provider con API key en la sección de Providers`}),J.map(e=>{let t=q(e);return(0,U.jsx)(c,{value:e.id,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`span`,{children:e.name}),(0,U.jsx)(`span`,{className:`text-[9px] font-bold px-1.5 py-0.5 rounded-full ${t?`bg-amber-500/20 text-amber-400`:`bg-emerald-500/20 text-emerald-400`}`,children:t?`LOCAL`:`API`})]})},e.id)})]})]}),Z&&X&&(0,U.jsxs)(`p`,{className:`text-[10px] text-amber-400/80 pl-1`,children:[`El proveedor "`,X.name,`" está inactivo. Selecciona uno activo para cambiar.`]})]}),(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between pl-1`,children:[(0,U.jsx)(D,{className:`text-xs text-white/40 uppercase tracking-widest`,children:`Modelo`}),v.provider_id&&Y.length===0&&(0,U.jsx)(`span`,{className:`text-[10px] text-amber-400/80`,children:`Sin modelos activos`})]}),(0,U.jsxs)(f,{value:v.model_id,onValueChange:e=>I(t=>({...t,model_id:e})),disabled:!v.provider_id||Y.length===0,children:[(0,U.jsx)(u,{className:`bg-white/5 border-white/10 rounded-xl h-11 disabled:opacity-50`,children:(0,U.jsx)(d,{placeholder:v.provider_id?Y.length===0?`Activa modelos en el provider`:`Seleccionar modelo`:`Primero selecciona un proveedor`,children:v.model_id&&Q?(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`font-mono text-sm`,children:Q.name}),$&&(0,U.jsx)(`span`,{className:`text-[10px] text-amber-400/80`,children:`(inactivo)`})]}):void 0})}),(0,U.jsx)(l,{className:`bg-zinc-900 border-white/10 text-white`,children:Y.map(e=>(0,U.jsx)(c,{value:e.id,children:(0,U.jsx)(`span`,{className:`font-mono text-sm`,children:e.name})},e.id))})]}),$&&Q&&(0,U.jsxs)(`p`,{className:`text-[10px] text-amber-400/80 pl-1`,children:[`El modelo "`,Q.name,`" está inactivo. Selecciona uno activo para cambiar.`]})]})]})]}),(0,U.jsxs)(`div`,{className:`mt-8 p-4 rounded-2xl bg-white/[0.03] border border-white/5 flex items-start gap-4 italic`,children:[(0,U.jsx)(W,{icon:se,className:`h-5 w-5 text-white/20 mt-0.5`}),(0,U.jsx)(`p`,{className:`text-[11px] text-white/30 leading-relaxed`,children:`Las credenciales de acceso y llaves de cifrado para los headers personalizados se gestionan en una capa segura y no son visibles en texto plano para mantener la integridad de la red.`})]})]})})]})})}function K({agent:e}){let{providers:t}=T(),{models:n}=C(),r=e.role===`coordinator`,i=e.provider_id||e.providerId,s=e.model_id||e.modelId,c=e.created_at||e.createdAt,l=c?z(typeof c==`string`?new Date(c):new Date(c*1e3),`PPP`,{locale:R}):`Fecha desconocida`,u=t.find(e=>e.id===i)?.name||i,d=n.find(e=>e.id===s)?.name||s;return(0,U.jsxs)(`div`,{className:`hive-card--internal group ${e.enabled?`hive-card--internal-active`:`hive-card--internal-disabled`}`,children:[e.enabled&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{className:`absolute -top-24 -right-24 h-64 w-64 bg-blue-600/10 rounded-full blur-[100px] pointer-events-none group-hover:bg-blue-600/20 transition-all duration-700`}),(0,U.jsx)(`div`,{className:`absolute -bottom-24 -left-24 h-64 w-64 bg-purple-600/10 rounded-full blur-[100px] pointer-events-none group-hover:bg-purple-600/20 transition-all duration-700`})]}),(0,U.jsxs)(`div`,{className:`relative flex flex-col md:flex-row gap-8 items-start justify-between`,children:[(0,U.jsxs)(`div`,{className:`flex-1 space-y-6`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(`div`,{className:`hive-icon-wrap--internal ${e.enabled?`hive-icon-wrap--internal-active`:`hive-icon-wrap--internal-disabled`}`,children:(0,U.jsx)(B,{className:`h-6 w-6 ${e.enabled?`text-blue-400`:`text-white/20`}`})}),(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,U.jsx)(`span`,{className:`hive-page-header__label ${!e.enabled&&`text-white/20`}`,children:`Identidad de Nodo`}),r&&(0,U.jsx)(I,{className:`hive-tag--coordinator ${!e.enabled&&`bg-white/5 text-white/20 border-white/10`}`,children:`Coordinador`})]}),(0,U.jsx)(`h1`,{className:`text-4xl font-black tracking-tighter ${e.enabled?`text-white`:`text-white/40`}`,children:e.name})]})]}),(0,U.jsxs)(`p`,{className:`text-lg leading-relaxed max-w-2xl font-light italic ${e.enabled?`text-white/60`:`text-white/20`}`,children:[`"`,e.description||`Este agente no tiene una descripción definida aún.`,`"`]})]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4`,children:[(0,U.jsx)(q,{icon:m,label:`Infraestructura`,value:u,subValue:d,color:e.enabled?`text-blue-400`:`text-white/20`,enabled:e.enabled}),(0,U.jsx)(q,{icon:g,label:`Personalidad`,value:e.tone||`Neutral`,color:e.enabled?`text-purple-400`:`text-white/20`,enabled:e.enabled}),(0,U.jsx)(q,{icon:o,label:`Desplegado el`,value:l,color:e.enabled?`text-emerald-400`:`text-white/20`,enabled:e.enabled})]})]}),(0,U.jsxs)(`div`,{className:`flex flex-col items-center md:items-end gap-6 min-w-[200px]`,children:[(0,U.jsxs)(`div`,{className:`text-center md:text-right space-y-2`,children:[(0,U.jsx)(`span`,{className:`hive-label block`,children:`Estado Operativo`}),(0,U.jsx)(L,{status:e.enabled?e.status:`hibernated`,className:`px-6 py-2 text-sm border-2`})]}),(0,U.jsxs)(`div`,{className:`hive-network-panel md:w-auto`,children:[(0,U.jsxs)(`div`,{className:`flex-1`,children:[(0,U.jsx)(`p`,{className:`hive-label mb-1`,children:`Carga de Red`}),(0,U.jsx)(`div`,{className:`hive-network-track`,children:e.enabled&&(0,U.jsx)(`div`,{className:`hive-network-fill`})})]}),(0,U.jsx)(a,{className:`h-5 w-5 ${e.enabled?`text-blue-400 animate-pulse`:`text-white/10`}`})]})]})]}),(0,U.jsx)(`div`,{className:`hive-strip--bottom ${!e.enabled&&`opacity-20`}`}),(0,U.jsxs)(`div`,{className:`absolute top-4 right-8 hive-mono hidden md:block`,children:[`NODE_UID: `,e.id]})]})}function q({icon:e,label:t,value:n,subValue:r,color:i,enabled:a}){return(0,U.jsxs)(`div`,{className:`hive-info-card ${a?`hive-info-card--active`:`hive-info-card--disabled`}`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,U.jsx)(e,{className:`h-3.5 w-3.5 ${i}`}),(0,U.jsx)(`span`,{className:`hive-info-card__label`,children:t})]}),(0,U.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,U.jsx)(`p`,{className:`hive-info-card__value ${a?`text-white/80 group-hover/item:text-white`:`text-white/20`}`,children:n}),r&&(0,U.jsx)(`p`,{className:`hive-info-card__sub ${a?`text-white/40`:`text-white/10`}`,children:r})]})]})}function J(){let{id:e}=v(),t=_(),n=e??`unknown`,{agents:r,fetchAgents:i,isLoading:o}=E();(0,H.useEffect)(()=>{i()},[i]);let s=r.find(e=>e.id===n);return(0,U.jsx)(`div`,{className:`min-h-screen bg-transparent pb-20`,children:(0,U.jsxs)(`div`,{className:`max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8 animate-in fade-in slide-in-from-bottom-4 duration-700`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between mb-8`,children:[(0,U.jsxs)(S,{variant:`ghost`,onClick:()=>t(`/agents`),className:`group flex items-center gap-2 text-white/40 hover:text-white hover:bg-white/5 px-4 py-2 rounded-xl transition-all`,children:[(0,U.jsx)(p,{className:`h-4 w-4 transition-transform group-hover:-translate-x-1`}),(0,U.jsx)(`span`,{className:`text-sm font-bold uppercase tracking-widest`,children:`Volver a la Colmena`})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-4 text-white/20`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(V,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest`,children:`Agentes`})]}),(0,U.jsx)(`div`,{className:`h-4 w-px bg-white/10`}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(a,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest`,children:`Detalles Operativos`})]})]})]}),s?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(K,{agent:s}),(0,U.jsx)(`div`,{className:`grid grid-cols-1 gap-8`,children:(0,U.jsx)(G,{agentId:n})})]}):(0,U.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-[60vh] text-center space-y-6`,children:[(0,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsx)(`div`,{className:`h-24 w-24 rounded-full border-4 border-t-blue-500 border-white/5 animate-spin`}),(0,U.jsx)(a,{className:`absolute inset-0 m-auto h-8 w-8 text-blue-400 animate-pulse`})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h3`,{className:`text-xl font-bold text-white mb-2`,children:`Sincronizando con el Nodo`}),(0,U.jsx)(`p`,{className:`text-white/40 max-w-xs mx-auto`,children:`Estamos recuperando la configuración cuántica de este agente desde la base de datos central.`})]})]})]})})}export{J as AgentDetailPage};
@@ -1 +0,0 @@
1
- import{o as e}from"./vendor-query-DsWPbQdG.js";import{t}from"./AgentCreateForm-yUipEHs7.js";var n=e();function r(){return(0,n.jsx)(t,{})}export{r as AgentNewPage};
@@ -1,3 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{_ as t}from"./vendor-charts-Bu2lyBKP.js";import{o as n}from"./vendor-query-DsWPbQdG.js";import{t as r}from"./utils-3pnRFmFe.js";import{i,n as a,o,s,t as ee}from"./select-BQCOjM2j.js";import{t as c}from"./chevron-down-DIosfU_U.js";import{t as l}from"./chevron-right-CR4Skrf3.js";import{t as te}from"./circle-check-6Ard1-2z.js";import{t as u}from"./circle-x-DjLkFDO8.js";import{t as d}from"./copy-Bu5d7C-0.js";import{t as f}from"./history-CAF_R34_.js";import{t as ne}from"./plus-BZQX26Dr.js";import{t as re}from"./send-BPk9XbIq.js";import{t as p}from"./trash-2-xD2o4SgX.js";import{A as m,J as h,f as g,j as _,q as v}from"./index-CpfjkhN8.js";import{t as y}from"./textarea-B6Z1Zc6W.js";import{t as b}from"./badge-Cn2irDlB.js";import{a as x,n as S,o as C,t as w}from"./card-DFKnZ6ky.js";import{i as T,n as E,r as D,t as O}from"./tabs-CqK5bFsS.js";import{t as k}from"./scroll-area-8uM7g-LF.js";var A=e(t(),1),j=n(),ie=[`GET`,`POST`,`PUT`,`DELETE`,`PATCH`,`HEAD`,`OPTIONS`];function M(){return Math.random().toString(36).substring(2,9)}function N(){return{id:M(),key:``,value:``,enabled:!0}}function P(){let[e,t]=(0,A.useState)(`GET`),[n,P]=(0,A.useState)(``),[F,I]=(0,A.useState)([N()]),[L,R]=(0,A.useState)([N()]),[z,B]=(0,A.useState)(``),[V,H]=(0,A.useState)(null),[U,W]=(0,A.useState)(!1),[G,K]=(0,A.useState)(0),[q,J]=(0,A.useState)([]),[Y,ae]=(0,A.useState)(!1),[oe,se]=(0,A.useState)(`body`);(0,A.useEffect)(()=>{try{let e=localStorage.getItem(`hive-api-client-history`);e&&J(JSON.parse(e))}catch{}},[]);let ce=(0,A.useCallback)(e=>{localStorage.setItem(`hive-api-client-history`,JSON.stringify(e.slice(0,50)))},[]),X=(e,t,n,r,i)=>{t(e.map(e=>e.id===n?{...e,[r]:i}:e))},le=(e,t)=>{t([...e,N()])},ue=(e,t,n)=>{e.length===1?t([N()]):t(e.filter(e=>e.id!==n))},Z=()=>{let e={};for(let t of F)t.enabled&&t.key.trim()&&(e[t.key.trim()]=t.value);return e},de=()=>{let e={};for(let t of L)t.enabled&&t.key.trim()&&(e[t.key.trim()]=t.value);return e},Q=async()=>{if(!n.trim())return;W(!0),H(null);let t=performance.now();try{let r={method:e,url:n.trim(),headers:Z(),query_params:de()};z.trim()&&e!==`GET`&&e!==`HEAD`&&(r.body=z.trim());let i=await g(`/api/http-request`,{method:`POST`,body:r,showError:!1});K(Math.round(performance.now()-t)),H(i);let a=[{id:M(),method:e,url:n.trim(),timestamp:Date.now(),status:i.status,ok:i.ok},...q];J(a),ce(a)}catch(e){K(Math.round(performance.now()-t)),H({ok:!1,error:e.message||`Request failed`})}finally{W(!1)}},fe=e=>{t(e.method),P(e.url),H(null)},pe=e=>{navigator.clipboard.writeText(e)},me=e=>{if(e==null)return``;if(typeof e==`string`)try{let t=JSON.parse(e);return JSON.stringify(t,null,2)}catch{return e}return JSON.stringify(e,null,2)},he=e=>e?e>=200&&e<300?`bg-green-500`:e>=300&&e<400?`bg-yellow-500`:e>=400&&e<500?`bg-orange-500`:`bg-red-500`:`bg-gray-500`,$=(e,t,n,r)=>(0,j.jsxs)(`div`,{className:`space-y-2`,children:[e.map(i=>(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:i.enabled,onChange:n=>X(e,t,i.id,`enabled`,n.target.checked),className:`h-4 w-4 rounded border-white/20 bg-background`}),(0,j.jsx)(m,{placeholder:n,value:i.key,onChange:n=>X(e,t,i.id,`key`,n.target.value),className:`h-8 text-xs bg-background/50`}),(0,j.jsx)(m,{placeholder:r,value:i.value,onChange:n=>X(e,t,i.id,`value`,n.target.value),className:`h-8 text-xs bg-background/50`}),(0,j.jsx)(_,{variant:`ghost`,size:`icon`,className:`h-8 w-8 text-muted-foreground hover:text-red-400`,onClick:()=>ue(e,t,i.id),children:(0,j.jsx)(p,{className:`h-3.5 w-3.5`})})]},i.id)),(0,j.jsxs)(_,{variant:`ghost`,size:`sm`,className:`text-xs text-muted-foreground hover:text-primary`,onClick:()=>le(e,t),children:[(0,j.jsx)(ne,{className:`h-3.5 w-3.5 mr-1`}),`Agregar`]})]});return(0,j.jsxs)(`div`,{className:`hive-page-container animate-fade-in mt-10`,children:[(0,j.jsx)(`div`,{className:`hive-page-header mb-6`,children:(0,j.jsxs)(`div`,{className:`flex items-center gap-3 mb-2`,children:[(0,j.jsx)(`div`,{className:`h-10 w-10 rounded-xl bg-purple-500/10 border border-purple-500/20 flex items-center justify-center text-purple-400`,children:(0,j.jsx)(v,{className:`h-6 w-6`})}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h1`,{className:`text-3xl font-black text-white uppercase tracking-tighter`,children:`API Client`}),(0,j.jsx)(`p`,{className:`hive-subtitle`,children:`Cliente HTTP para probar endpoints REST directamente desde Hive.`})]})]})}),(0,j.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-[1fr_320px] gap-6`,children:[(0,j.jsxs)(`div`,{className:`space-y-4`,children:[(0,j.jsx)(w,{className:`border-white/10 bg-card/50`,children:(0,j.jsx)(S,{className:`p-4`,children:(0,j.jsxs)(`div`,{className:`flex gap-2`,children:[(0,j.jsxs)(ee,{value:e,onValueChange:t,children:[(0,j.jsx)(o,{className:`w-[110px] h-10 text-xs font-bold tracking-wider`,children:(0,j.jsx)(s,{})}),(0,j.jsx)(a,{children:ie.map(e=>(0,j.jsx)(i,{value:e,className:`text-xs font-bold`,children:e},e))})]}),(0,j.jsx)(m,{placeholder:`https://api.example.com/endpoint`,value:n,onChange:e=>P(e.target.value),onKeyDown:e=>e.key===`Enter`&&Q(),className:`h-10 text-sm bg-background/50 font-mono`}),(0,j.jsxs)(_,{onClick:Q,disabled:U||!n.trim(),className:`h-10 px-6 bg-purple-600 hover:bg-purple-500 text-white font-bold text-xs tracking-wider`,children:[U?(0,j.jsx)(h,{className:`h-4 w-4 animate-spin mr-2`}):(0,j.jsx)(re,{className:`h-4 w-4 mr-2`}),`ENVIAR`]})]})})}),(0,j.jsx)(w,{className:`border-white/10 bg-card/50`,children:(0,j.jsx)(S,{className:`p-4`,children:(0,j.jsxs)(O,{defaultValue:`headers`,className:`w-full`,children:[(0,j.jsxs)(D,{className:`bg-background/50 h-8`,children:[(0,j.jsxs)(T,{value:`headers`,className:`text-xs h-7`,children:[`Headers (`,F.filter(e=>e.enabled&&e.key.trim()).length,`)`]}),(0,j.jsxs)(T,{value:`query`,className:`text-xs h-7`,children:[`Query Params (`,L.filter(e=>e.enabled&&e.key.trim()).length,`)`]}),(0,j.jsx)(T,{value:`body`,className:`text-xs h-7`,children:`Body`})]}),(0,j.jsx)(E,{value:`headers`,className:`mt-3`,children:$(F,I,`Header`,`Value`)}),(0,j.jsx)(E,{value:`query`,className:`mt-3`,children:$(L,R,`Key`,`Value`)}),(0,j.jsxs)(E,{value:`body`,className:`mt-3`,children:[(0,j.jsx)(y,{placeholder:`{
2
- "key": "value"
3
- }`,value:z,onChange:e=>B(e.target.value),className:`min-h-[140px] font-mono text-xs bg-background/50`}),(0,j.jsx)(`p`,{className:`text-[10px] text-muted-foreground mt-2`,children:`Se enviará como string crudo. Para JSON, asegurate de que sea válido.`})]})]})})}),V&&(0,j.jsxs)(w,{className:r(`border-white/10`,V.ok?`bg-green-500/[0.02]`:`bg-red-500/[0.02]`),children:[(0,j.jsx)(x,{className:`pb-3`,children:(0,j.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,j.jsx)(C,{className:`text-sm font-bold tracking-wider`,children:`RESPUESTA`}),V.status!==void 0&&(0,j.jsxs)(b,{variant:`outline`,className:r(`text-xs font-bold border-none`,he(V.status),`text-white`),children:[V.status,` `,V.statusText||``]}),V.ok?(0,j.jsx)(te,{className:`h-4 w-4 text-green-500`}):(0,j.jsx)(u,{className:`h-4 w-4 text-red-500`}),(0,j.jsxs)(`span`,{className:`text-[10px] text-muted-foreground font-mono`,children:[G,`ms`]})]}),(0,j.jsxs)(_,{variant:`ghost`,size:`sm`,className:`h-7 text-xs`,onClick:()=>pe(JSON.stringify(V,null,2)),children:[(0,j.jsx)(d,{className:`h-3 w-3 mr-1`}),`Copiar`]})]})}),(0,j.jsx)(S,{className:`pt-0`,children:(0,j.jsxs)(O,{value:oe,onValueChange:se,children:[(0,j.jsxs)(D,{className:`bg-background/50 h-8`,children:[(0,j.jsx)(T,{value:`body`,className:`text-xs h-7`,children:`Body`}),(0,j.jsx)(T,{value:`headers`,className:`text-xs h-7`,children:`Headers`}),(0,j.jsx)(T,{value:`raw`,className:`text-xs h-7`,children:`Raw`})]}),(0,j.jsx)(E,{value:`body`,className:`mt-3`,children:(0,j.jsx)(k,{className:`h-[300px] w-full rounded-md border bg-black/40 p-3`,children:(0,j.jsx)(`pre`,{className:`font-mono text-xs text-green-400 whitespace-pre-wrap`,children:me(V.body??V)})})}),(0,j.jsx)(E,{value:`headers`,className:`mt-3`,children:(0,j.jsx)(k,{className:`h-[300px] w-full rounded-md border bg-black/40 p-3`,children:V.headers?(0,j.jsx)(`div`,{className:`space-y-1`,children:Object.entries(V.headers).map(([e,t])=>(0,j.jsxs)(`div`,{className:`flex gap-2 text-xs font-mono`,children:[(0,j.jsxs)(`span`,{className:`text-purple-400 shrink-0`,children:[e,`:`]}),(0,j.jsx)(`span`,{className:`text-white/70`,children:String(t)})]},e))}):(0,j.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No headers disponibles`})})}),(0,j.jsx)(E,{value:`raw`,className:`mt-3`,children:(0,j.jsx)(k,{className:`h-[300px] w-full rounded-md border bg-black/40 p-3`,children:(0,j.jsx)(`pre`,{className:`font-mono text-xs text-white/60 whitespace-pre-wrap`,children:JSON.stringify(V,null,2)})})})]})})]})]}),(0,j.jsx)(`div`,{children:(0,j.jsxs)(w,{className:`border-white/10 bg-card/50`,children:[(0,j.jsx)(x,{className:`pb-3`,children:(0,j.jsxs)(`button`,{onClick:()=>ae(!Y),className:`flex items-center justify-between w-full`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(f,{className:`h-4 w-4 text-muted-foreground`}),(0,j.jsx)(C,{className:`text-xs font-bold tracking-wider`,children:`HISTORIAL`})]}),Y?(0,j.jsx)(c,{className:`h-4 w-4 text-muted-foreground`}):(0,j.jsx)(l,{className:`h-4 w-4 text-muted-foreground`})]})}),Y&&(0,j.jsxs)(S,{className:`pt-0`,children:[q.length===0?(0,j.jsx)(`p`,{className:`text-xs text-muted-foreground text-center py-4`,children:`No hay requests en el historial`}):(0,j.jsx)(k,{className:`h-[calc(100vh-300px)]`,children:(0,j.jsx)(`div`,{className:`space-y-1`,children:q.map(e=>(0,j.jsxs)(`button`,{onClick:()=>fe(e),className:`w-full text-left p-2 rounded-lg hover:bg-white/5 transition-colors group`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(`span`,{className:r(`text-[10px] font-bold px-1.5 py-0.5 rounded`,e.ok?`bg-green-500/20 text-green-400`:`bg-red-500/20 text-red-400`),children:e.method}),e.status&&(0,j.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:e.status})]}),(0,j.jsx)(`p`,{className:`text-[10px] text-white/50 truncate mt-1 font-mono`,children:e.url}),(0,j.jsx)(`p`,{className:`text-[9px] text-white/30 mt-0.5`,children:new Date(e.timestamp).toLocaleTimeString()})]},e.id))})}),q.length>0&&(0,j.jsxs)(_,{variant:`ghost`,size:`sm`,className:`w-full mt-2 text-[10px] text-muted-foreground hover:text-red-400`,onClick:()=>{J([]),localStorage.removeItem(`hive-api-client-history`)},children:[(0,j.jsx)(p,{className:`h-3 w-3 mr-1`}),`Limpiar historial`]})]})]})})]})]})}export{P as ApiClientPage};
@@ -1,6 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{_ as t,a as n,f as r,l as i,m as a,o,p as s,r as c,s as l,t as u,u as d}from"./vendor-charts-Bu2lyBKP.js";import{i as f,n as p,o as m,t as h}from"./vendor-query-DsWPbQdG.js";import{r as g}from"./utils-3pnRFmFe.js";import{t as _}from"./activity-c3pNngT_.js";import{t as v}from"./circle-check-6Ard1-2z.js";import{t as y}from"./download-Cjbk4Rek.js";import{t as ee}from"./external-link-6sTlRDUR.js";import{t as b}from"./gauge-B8Tj43rC.js";import{t as te}from"./info-WjromB4Y.js";import{t as x}from"./loader-circle-BmBOgYze.js";import{t as S}from"./triangle-alert-pVIJGjga.js";import{t as C}from"./zap-B4RaNNO5.js";import{G as ne,K as re,W as w,Y as T,b as ie,f as E,j as ae,m as D,t as O}from"./index-CpfjkhN8.js";import{t as k}from"./badge-Cn2irDlB.js";import{a as A,n as j,o as M,r as N,t as P}from"./card-DFKnZ6ky.js";import{t as F}from"./progress-BaTQRPPu.js";import{a as I,c as L,i as R,n as z,o as B,r as oe,s as V,t as H}from"./alert-dialog-CdDNVtq1.js";var U=g(`ArrowUpRight`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),W=g(`Cable`,[[`path`,{d:`M17 21v-2a1 1 0 0 1-1-1v-1a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v1a1 1 0 0 1-1 1`,key:`10bnsj`}],[`path`,{d:`M19 15V6.5a1 1 0 0 0-7 0v11a1 1 0 0 1-7 0V9`,key:`1eqmu1`}],[`path`,{d:`M21 21v-2h-4`,key:`14zm7j`}],[`path`,{d:`M3 5h4V3`,key:`z442eg`}],[`path`,{d:`M7 5a1 1 0 0 1 1 1v1a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6a1 1 0 0 1 1-1V3`,key:`ebdjd7`}]]),G=g(`CircleArrowUp`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 12-4-4-4 4`,key:`177agl`}],[`path`,{d:`M12 16V8`,key:`1sbj14`}]]),K=g(`DollarSign`,[[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`22`,key:`7eqyqh`}],[`path`,{d:`M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6`,key:`1b0p4s`}]]),se=g(`HardDrive`,[[`line`,{x1:`22`,x2:`2`,y1:`12`,y2:`12`,key:`1y58io`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`oot6mr`}],[`line`,{x1:`6`,x2:`6.01`,y1:`16`,y2:`16`,key:`sgf278`}],[`line`,{x1:`10`,x2:`10.01`,y1:`16`,y2:`16`,key:`1l4acy`}]]),ce=g(`Hash`,[[`line`,{x1:`4`,x2:`20`,y1:`9`,y2:`9`,key:`4lhtct`}],[`line`,{x1:`4`,x2:`20`,y1:`15`,y2:`15`,key:`vyu0kd`}],[`line`,{x1:`10`,x2:`8`,y1:`3`,y2:`21`,key:`1ggp8o`}],[`line`,{x1:`16`,x2:`14`,y1:`3`,y2:`21`,key:`weycgp`}]]),le=g(`MemoryStick`,[[`path`,{d:`M6 19v-3`,key:`1nvgqn`}],[`path`,{d:`M10 19v-3`,key:`iu8nkm`}],[`path`,{d:`M14 19v-3`,key:`kcehxu`}],[`path`,{d:`M18 19v-3`,key:`1vh91z`}],[`path`,{d:`M8 11V9`,key:`63erz4`}],[`path`,{d:`M16 11V9`,key:`fru6f3`}],[`path`,{d:`M12 11V9`,key:`ha00sb`}],[`path`,{d:`M2 15h20`,key:`16ne18`}],[`path`,{d:`M2 7a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v1.1a2 2 0 0 0 0 3.837V17a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-5.1a2 2 0 0 0 0-3.837Z`,key:`lhddv3`}]]),ue=g(`TrendingUp`,[[`polyline`,{points:`22 7 13.5 15.5 8.5 10.5 2 17`,key:`126l90`}],[`polyline`,{points:`16 7 22 7 22 13`,key:`kwv8wd`}]]),q=e(t(),1);function de(){let{agents:e,isLoading:t,error:n,fetchAgents:r,createAgent:i,updateAgent:a,deleteAgent:o}=O(),[s,c]=(0,q.useState)(`all`);return(0,q.useEffect)(()=>{r()},[r]),{agents:(0,q.useMemo)(()=>Array.isArray(e)?s===`all`?e:e.filter(e=>e.status===s):[],[e,s]),allAgents:e||[],filter:s,setFilter:c,createAgent:i,updateAgent:a,deleteAgent:o,isLoading:t,error:n,refreshAgents:r}}var J=m();function fe(e){return e<50?`#22c55e`:e<80?`#eab308`:`#ef4444`}function pe(){let[e,t]=(0,q.useState)(()=>{let e=new Date;return Array.from({length:12},(t,n)=>({time:new Date(e.getTime()-(11-n)*5e3).toLocaleTimeString(`es`,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}),msgs:0,rss:0}))}),[r,i]=(0,q.useState)([]),{data:a}=p({queryKey:[`system-stats`],queryFn:()=>E(`/api/system-stats`),refetchInterval:5e3}),c=(0,q.useRef)(a);(0,q.useEffect)(()=>{c.current=a},[a]),(0,q.useEffect)(()=>{let e=setInterval(()=>{let e=c.current;if(!e)return;let n=new Date().toLocaleTimeString(`es`,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`});t(t=>[...t,{time:n,msgs:e.recentMessages,rss:e.memory.rss}].slice(-20))},5e3);return()=>clearInterval(e)},[]);let d=a?.memory.rss??0,f=a?.memory.heapUsed??0,m=a?.memory.external??0,h=a?.recentMessages??0;return(0,J.jsxs)(`div`,{className:`flex flex-col gap-4 mb-4`,children:[(0,J.jsxs)(P,{className:`overflow-hidden border-primary/10`,children:[(0,J.jsx)(A,{className:`pb-2 bg-gradient-to-r from-primary/5 to-transparent`,children:(0,J.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,J.jsxs)(M,{className:`text-base flex items-center gap-2`,children:[(0,J.jsx)(b,{className:`h-4 w-4 text-primary`}),`Monitor del Proceso Hive`]})})}),(0,J.jsxs)(j,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-4 pt-4`,children:[(0,J.jsx)(Y,{icon:ne,label:`Actividad reciente`,value:`${h}`,subValue:`mensajes últimos 5 min`,color:h>0?`#22c55e`:`hsl(var(--muted-foreground))`,progress:Math.min(100,h*10)}),(0,J.jsx)(Y,{icon:se,label:`Memoria Hive (RSS)`,value:`${d} MB`,subValue:`Heap JS: ${f} MB usados`,color:fe(Math.min(100,Math.round(d/1024*100))),progress:Math.min(100,Math.round(d/1024*100))}),(0,J.jsx)(Y,{icon:le,label:`Heap JS`,value:`${f} MB`,subValue:`External: ${m} MB`,color:`#3b82f6`,progress:Math.min(100,Math.round(f/512*100))}),(0,J.jsx)(Y,{icon:w,label:`Sesiones WS activas`,value:`${a?.connections??0}`,subValue:`conexiones WebSocket`,color:`#a855f7`,progress:Math.min(100,(a?.connections??0)*10)})]})]}),(0,J.jsxs)(P,{className:`border-primary/10`,children:[(0,J.jsx)(A,{className:`pb-2`,children:(0,J.jsxs)(M,{className:`text-sm flex items-center gap-2`,children:[(0,J.jsx)(_,{className:`h-4 w-4 text-primary`}),`Historial — `,(0,J.jsx)(`span`,{className:`text-green-400`,children:`Mensajes`}),` · `,(0,J.jsx)(`span`,{className:`text-purple-400`,children:`RSS MB`})]})}),(0,J.jsx)(j,{className:`h-[160px]`,children:(0,J.jsx)(s,{width:`100%`,height:`100%`,children:(0,J.jsxs)(u,{data:e,children:[(0,J.jsxs)(`defs`,{children:[(0,J.jsxs)(`linearGradient`,{id:`gMsgs`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,J.jsx)(`stop`,{offset:`5%`,stopColor:`#22c55e`,stopOpacity:.3}),(0,J.jsx)(`stop`,{offset:`95%`,stopColor:`#22c55e`,stopOpacity:0})]}),(0,J.jsxs)(`linearGradient`,{id:`gHeap`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,J.jsx)(`stop`,{offset:`5%`,stopColor:`#8b5cf6`,stopOpacity:.3}),(0,J.jsx)(`stop`,{offset:`95%`,stopColor:`#8b5cf6`,stopOpacity:0})]})]}),(0,J.jsx)(o,{dataKey:`time`,axisLine:!1,tickLine:!1,tick:{fill:`hsl(var(--muted-foreground))`,fontSize:9},interval:`preserveStartEnd`}),(0,J.jsx)(n,{axisLine:!1,tickLine:!1,tick:{fill:`hsl(var(--muted-foreground))`,fontSize:9}}),(0,J.jsx)(l,{type:`monotone`,dataKey:`msgs`,stroke:`#22c55e`,strokeWidth:2,fillOpacity:1,fill:`url(#gMsgs)`,name:`Mensajes`}),(0,J.jsx)(l,{type:`monotone`,dataKey:`rss`,stroke:`#8b5cf6`,strokeWidth:2,fillOpacity:1,fill:`url(#gHeap)`,name:`RSS MB`})]})})})]})]})}function Y({icon:e,label:t,value:n,subValue:r,color:i,progress:a}){return(0,J.jsxs)(`div`,{className:`rounded-lg border bg-card/50 p-3 space-y-2`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{style:{color:i},children:(0,J.jsx)(e,{className:`h-4 w-4`})}),(0,J.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:t})]}),(0,J.jsx)(`span`,{className:`text-lg font-bold font-mono`,style:{color:i},children:n})]}),(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsx)(`div`,{className:`h-1.5 w-full rounded-full bg-muted overflow-hidden`,children:(0,J.jsx)(`div`,{className:`h-full rounded-full transition-all duration-500`,style:{width:`${Math.min(a,100)}%`,backgroundColor:i}})}),(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r})]})]})}var X={anthropic:`#d97706`,openai:`#10b981`,google:`#3b82f6`,gemini:`#3b82f6`,deepseek:`#8b5cf6`,kimi:`#ec4899`,ollama:`#14b8a6`,openrouter:`#f59e0b`,mistral:`#6366f1`};function Z(e){return e>=1e6?(e/1e6).toFixed(2)+`M`:e>=1e3?(e/1e3).toFixed(1)+`K`:e.toString()}function Q(e){return e>=1?`$`+e.toFixed(2):e>=.01?`$`+e.toFixed(3):e>0?`$`+e.toFixed(5):`$0.00`}function $(e){return e>=10?e.toFixed(1)+`%`:e>=1?e.toFixed(2)+`%`:e>0?e.toFixed(3)+`%`:`0%`}function me(){let[e,t]=(0,q.useState)(24),{data:i,isLoading:l}=p({queryKey:[`usage-stats`,e],queryFn:async()=>await E(`/api/usage-stats?hours=${e}`),refetchInterval:6e4});if(l&&!i)return(0,J.jsxs)(P,{className:`border-primary/10`,children:[(0,J.jsx)(A,{children:(0,J.jsxs)(M,{className:`flex items-center gap-2`,children:[(0,J.jsx)(K,{className:`h-5 w-5 text-primary`}),`Uso y Costos de API`]})}),(0,J.jsx)(j,{children:(0,J.jsx)(`div`,{className:`h-40 flex items-center justify-center text-muted-foreground animate-pulse`,children:`Cargando estadísticas de uso...`})})]});let u=i&&(i.totalTokens>0||i.totalCostUsd>0),f=i?Object.entries(i.byProvider).map(([e,t])=>({name:e.charAt(0).toUpperCase()+e.slice(1),value:t.tokens,cost:t.costUsd,color:X[e.toLowerCase()]||`#6b7280`})):[],m=i?Object.entries(i.byModel).slice(0,8).map(([e,t])=>({name:e.length>20?e.slice(0,18)+`...`:e,tokens:t.tokens,cost:t.costUsd,fullName:e})):[];return(0,J.jsxs)(P,{className:`border-primary/10`,children:[(0,J.jsx)(A,{className:`pb-2`,children:(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(M,{className:`text-base flex items-center gap-2`,children:[(0,J.jsx)(K,{className:`h-5 w-5 text-primary`}),`Uso y Costos de API`]}),(0,J.jsx)(N,{children:`Tokens consumidos y costos por provider/modelo`})]}),(0,J.jsx)(`div`,{className:`flex gap-1`,children:[6,24,168].map(n=>(0,J.jsx)(`button`,{onClick:()=>t(n),className:`px-2 py-1 text-xs rounded-md transition-colors ${e===n?`bg-primary text-primary-foreground`:`bg-muted hover:bg-muted/80`}`,children:n===6?`6h`:n===24?`24h`:`7d`},n))})]})}),(0,J.jsxs)(j,{className:`space-y-4`,children:[(0,J.jsxs)(`div`,{className:`rounded-lg border p-3 ${i?.toonSavedTokens?`border-emerald-500/30 bg-emerald-500/5`:`bg-card/50`}`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,J.jsx)(C,{className:`h-3 w-3 ${i?.toonSavedTokens?`text-emerald-400`:``}`}),(0,J.jsx)(`span`,{className:`font-medium`,children:`TOON Optimización de Tokens`})]}),i?.toonSavingsPercent&&i.toonSavingsPercent>0?(0,J.jsxs)(`span`,{className:`text-xs font-bold text-emerald-400`,children:[$(i.toonSavingsPercent),` reducción`]}):null]}),(0,J.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 md:grid-cols-4 gap-3`,children:[(0,J.jsxs)(`div`,{className:`bg-emerald-500/5 rounded-md p-2`,children:[(0,J.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`Tokens Ahorrados`}),(0,J.jsx)(`div`,{className:`text-lg font-bold ${i?.toonSavedTokens?`text-emerald-400`:`text-muted-foreground`}`,children:i?Z(i.toonSavedTokens):`—`})]}),(0,J.jsxs)(`div`,{className:`bg-emerald-500/5 rounded-md p-2`,children:[(0,J.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`Costo Ahorrado`}),(0,J.jsx)(`div`,{className:`text-lg font-bold text-emerald-400`,children:i?Q(i.toonSavedCost):`—`})]}),(0,J.jsxs)(`div`,{className:`bg-emerald-500/5 rounded-md p-2`,children:[(0,J.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`Bytes Ahorrados`}),(0,J.jsx)(`div`,{className:`text-lg font-bold text-emerald-400`,children:i&&i.toonSavedBytes>0?Z(i.toonSavedBytes):`—`})]}),(0,J.jsxs)(`div`,{className:`bg-emerald-500/5 rounded-md p-2`,children:[(0,J.jsx)(`div`,{className:`text-xs text-muted-foreground mb-1`,children:`Reducción Bytes`}),(0,J.jsx)(`div`,{className:`text-lg font-bold text-emerald-400`,children:i?.toonSavedBytesPercent&&i.toonSavedBytesPercent>0?$(i.toonSavedBytesPercent):`—`})]})]}),i&&(i.toonJsonTokens>0||i.toonToonTokens>0)&&(0,J.jsx)(`div`,{className:`mt-3 pt-3 border-t border-emerald-500/20`,children:(0,J.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,J.jsxs)(`span`,{className:`text-muted-foreground`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`JSON:`}),` `,(0,J.jsx)(`span`,{className:`font-medium`,children:i.toonJsonTokens>0?Z(i.toonJsonTokens):`—`}),` `,(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`tokens`})]}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`→`}),(0,J.jsxs)(`span`,{className:`text-muted-foreground`,children:[(0,J.jsx)(`span`,{className:`text-emerald-400`,children:`TOON:`}),` `,(0,J.jsx)(`span`,{className:`font-medium text-emerald-400`,children:i.toonToonTokens>0?Z(i.toonToonTokens):`—`}),` `,(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`tokens`})]})]}),i?.toonSavingsPercent&&i.toonSavingsPercent>0?(0,J.jsxs)(`span`,{className:`text-xs font-bold text-emerald-400`,children:[$(i.toonSavingsPercent),` menos tokens`]}):null]})}),i&&!i.toonSavedTokens&&(0,J.jsx)(`div`,{className:`mt-2 text-xs text-muted-foreground italic`,children:`Sin optimizaciones TOON registradas aún`})]}),u?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[(0,J.jsxs)(`div`,{className:`rounded-lg border bg-card/50 p-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground mb-1`,children:[(0,J.jsx)(K,{className:`h-3 w-3`}),`Costo Total`]}),(0,J.jsx)(`div`,{className:`text-2xl font-bold text-green-500`,children:Q(i.totalCostUsd)})]}),(0,J.jsxs)(`div`,{className:`rounded-lg border bg-card/50 p-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground mb-1`,children:[(0,J.jsx)(ce,{className:`h-3 w-3`}),`Total Tokens`]}),(0,J.jsx)(`div`,{className:`text-2xl font-bold`,children:Z(i.totalTokens)})]}),(0,J.jsxs)(`div`,{className:`rounded-lg border bg-card/50 p-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground mb-1`,children:[(0,J.jsx)(ue,{className:`h-3 w-3`}),`Input / Output`]}),(0,J.jsxs)(`div`,{className:`text-lg font-semibold`,children:[(0,J.jsx)(`span`,{className:`text-blue-500`,children:Z(i.totalInputTokens)}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:` / `}),(0,J.jsx)(`span`,{className:`text-purple-500`,children:Z(i.totalOutputTokens)})]})]}),(0,J.jsxs)(`div`,{className:`rounded-lg border bg-card/50 p-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground mb-1`,children:[(0,J.jsx)(w,{className:`h-3 w-3`}),`Providers`]}),(0,J.jsx)(`div`,{className:`text-2xl font-bold`,children:Object.keys(i.byProvider).length})]})]}),(0,J.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`h4`,{className:`text-sm font-medium mb-2 flex items-center gap-2`,children:[(0,J.jsx)(w,{className:`h-4 w-4 text-muted-foreground`}),`Por Provider`]}),(0,J.jsx)(`div`,{className:`h-[180px]`,children:(0,J.jsx)(s,{width:`100%`,height:`100%`,children:(0,J.jsxs)(c,{data:f,layout:`vertical`,children:[(0,J.jsx)(o,{type:`number`,hide:!0}),(0,J.jsx)(n,{type:`category`,dataKey:`name`,axisLine:!1,tickLine:!1,tick:{fill:`hsl(var(--muted-foreground))`,fontSize:11},width:70}),(0,J.jsx)(a,{contentStyle:{backgroundColor:`hsl(var(--card))`,border:`1px solid hsl(var(--border))`,borderRadius:`8px`},formatter:(e,t)=>[t===`cost`?Q(e):Z(e),t===`cost`?`Costo`:`Tokens`]}),(0,J.jsx)(d,{dataKey:`value`,radius:[0,4,4,0],barSize:16,children:f.map(e=>(0,J.jsx)(r,{fill:e.color},e.name))})]})})})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`h4`,{className:`text-sm font-medium mb-2 flex items-center gap-2`,children:[(0,J.jsx)(T,{className:`h-4 w-4 text-muted-foreground`}),`Por Modelo (Top 8)`]}),(0,J.jsx)(`div`,{className:`h-[180px]`,children:(0,J.jsx)(s,{width:`100%`,height:`100%`,children:(0,J.jsxs)(c,{data:m,children:[(0,J.jsx)(o,{dataKey:`name`,axisLine:!1,tickLine:!1,tick:{fill:`hsl(var(--muted-foreground))`,fontSize:10},angle:-45,textAnchor:`end`,height:60}),(0,J.jsx)(n,{axisLine:!1,tickLine:!1,tick:{fill:`hsl(var(--muted-foreground))`,fontSize:10}}),(0,J.jsx)(a,{contentStyle:{backgroundColor:`hsl(var(--card))`,border:`1px solid hsl(var(--border))`,borderRadius:`8px`},formatter:e=>Q(e),labelFormatter:e=>m.find(t=>t.name===e)?.fullName||e}),(0,J.jsx)(d,{dataKey:`cost`,radius:[4,4,0,0],children:m.map(e=>(0,J.jsx)(r,{fill:X[e.fullName.split(`-`)[0]?.toLowerCase()]||`#6b7280`},e.fullName))})]})})})]})]}),f.length>0&&(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h4`,{className:`text-sm font-medium mb-2`,children:`Detalle por Provider`}),(0,J.jsx)(`div`,{className:`rounded-lg border overflow-hidden`,children:(0,J.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,J.jsx)(`thead`,{className:`bg-muted/50`,children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{className:`text-left p-2 font-medium`,children:`Provider`}),(0,J.jsx)(`th`,{className:`text-right p-2 font-medium`,children:`Input`}),(0,J.jsx)(`th`,{className:`text-right p-2 font-medium`,children:`Output`}),(0,J.jsx)(`th`,{className:`text-right p-2 font-medium`,children:`Total`}),(0,J.jsx)(`th`,{className:`text-right p-2 font-medium`,children:`Costo`})]})}),(0,J.jsx)(`tbody`,{children:Object.entries(i.byProvider).map(([e,t])=>(0,J.jsxs)(`tr`,{className:`border-t`,children:[(0,J.jsx)(`td`,{className:`p-2 font-medium`,children:e}),(0,J.jsx)(`td`,{className:`p-2 text-right text-blue-500`,children:Z(t.inputTokens)}),(0,J.jsx)(`td`,{className:`p-2 text-right text-purple-500`,children:Z(t.outputTokens)}),(0,J.jsx)(`td`,{className:`p-2 text-right`,children:Z(t.tokens)}),(0,J.jsx)(`td`,{className:`p-2 text-right font-medium text-green-500`,children:Q(t.costUsd)})]},e))})]})})]})]}):(0,J.jsx)(`div`,{className:`h-32 flex items-center justify-center text-muted-foreground`,children:(0,J.jsxs)(`div`,{className:`text-center`,children:[(0,J.jsx)(_,{className:`h-8 w-8 mx-auto mb-2 opacity-50`}),(0,J.jsx)(`p`,{children:`No hay datos de uso aún`}),(0,J.jsx)(`p`,{className:`text-xs`,children:`Los tokens se registrarán automáticamente`})]})})]})]})}function he(){let[e,t]=(0,q.useState)(!1),[n,r]=(0,q.useState)(0),[i,a]=(0,q.useState)([]),o=f(),{data:s,isLoading:c}=p({queryKey:[`version-check`],queryFn:()=>E(`/api/version`),refetchInterval:3e5,retry:2}),l=h({mutationFn:()=>E(`/api/update`,{method:`POST`,showLoader:`Actualizando Hive...`}),onSuccess:e=>{r(100),e.success?(a(e.instructions||[]),D.fire({title:`¡Actualización Completada!`,text:e.message||`Hive ha sido actualizado exitosamente.`,icon:`success`,confirmButtonText:`Continuar`})):(e.instructions&&a(e.instructions),D.fire({title:`Información de Actualización`,html:`
2
- <div class="text-left space-y-2">
3
- ${e.error?`<p class="mb-2">${e.error}</p>`:``}
4
- ${e.output?`<pre class="bg-muted p-2 rounded text-xs overflow-auto max-h-40">${e.output}</pre>`:``}
5
- </div>
6
- `,icon:e.instructions?`info`:`error`,confirmButtonText:`Entendido`})),setTimeout(()=>{o.invalidateQueries({queryKey:[`version-check`]})},2e3)},onError:e=>{r(0),console.error(`[UpdateChecker] Error:`,e)}}),u=()=>{t(!0)},d=()=>{t(!1),r(10),l.mutate();let e=setInterval(()=>{r(t=>t>=90?(clearInterval(e),t):t+10)},500)},m=e=>{switch(e){case`docker`:return`Docker`;case`binary`:return`Binario`;case`npm`:return`npm`;case`bun`:return`Bun`;default:return`Desconocida`}},g=()=>{if(!s)return null;switch(s.status){case`up-to-date`:return(0,J.jsxs)(k,{variant:`outline`,className:`flex items-center gap-1 bg-green-500/10 text-green-400 border-green-500/20`,children:[(0,J.jsx)(v,{className:`h-3 w-3`}),`Actualizado`]});case`update-available`:return(0,J.jsxs)(k,{className:`flex items-center gap-1 bg-blue-500 text-white border-blue-400 hover:bg-blue-600`,children:[(0,J.jsx)(G,{className:`h-3 w-3`}),`v`,s.latest,` disponible`]});case`checking`:return(0,J.jsxs)(k,{variant:`outline`,className:`flex items-center gap-1`,children:[(0,J.jsx)(x,{className:`h-3 w-3 animate-spin`}),`Verificando...`]});case`error`:return(0,J.jsxs)(k,{variant:`destructive`,className:`flex items-center gap-1`,children:[(0,J.jsx)(S,{className:`h-3 w-3`}),`Error`]})}},_=s?.status===`update-available`;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`flex flex-col items-end gap-1`,children:[(0,J.jsx)(`span`,{className:`hive-label mb-1`,children:`Versión`}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[g(),s&&(0,J.jsxs)(`span`,{className:`text-xs text-white/40 font-mono`,children:[`v`,s.current,` · `,m(s.installationType)]})]})]}),_&&(0,J.jsx)(ae,{size:`sm`,onClick:u,disabled:l.isPending,className:`bg-blue-600 hover:bg-blue-700 text-white shadow-lg shadow-blue-500/20`,children:l.isPending?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(x,{className:`h-4 w-4 mr-2 animate-spin`}),`Actualizando...`]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(y,{className:`h-4 w-4 mr-2`}),`Actualizar a v`,s.latest]})}),(0,J.jsx)(H,{open:e,onOpenChange:t,children:(0,J.jsxs)(R,{children:[(0,J.jsxs)(V,{children:[(0,J.jsxs)(L,{className:`flex items-center gap-2`,children:[(0,J.jsx)(y,{className:`h-5 w-5 text-blue-500`}),`Actualizar Hive`]}),(0,J.jsxs)(I,{className:`space-y-3`,children:[(0,J.jsxs)(`p`,{children:[`Se ha detectado una nueva versión disponible (`,(0,J.jsxs)(`strong`,{children:[`v`,s?.latest]}),`). Tu versión actual es `,(0,J.jsxs)(`strong`,{children:[`v`,s?.current]}),`.`]}),(0,J.jsx)(`div`,{className:`bg-muted p-3 rounded-lg space-y-2`,children:(0,J.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,J.jsx)(te,{className:`h-4 w-4 text-blue-500 mt-0.5`}),(0,J.jsxs)(`div`,{className:`text-sm`,children:[(0,J.jsxs)(`p`,{className:`font-semibold mb-1`,children:[`Tipo de instalación: `,m(s?.installationType)]}),s?.installationType===`docker`&&(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:`Para Docker, deberás ejecutar manualmente los comandos en tu terminal.`}),s?.installationType===`binary`&&(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:`Para el binario, serás redirigido a GitHub Releases para descargar la nueva versión.`}),(s?.installationType===`npm`||s?.installationType===`bun`)&&(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:`La actualización se realizará automáticamente. Deberás reiniciar el gateway después.`})]})]})}),l.isPending&&(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between text-sm`,children:[(0,J.jsx)(`span`,{children:`Progreso de actualización...`}),(0,J.jsxs)(`span`,{className:`text-muted-foreground`,children:[n,`%`]})]}),(0,J.jsx)(F,{value:n,className:`h-2`})]})]})]}),(0,J.jsxs)(B,{children:[(0,J.jsx)(oe,{disabled:l.isPending,children:`Cancelar`}),(0,J.jsx)(z,{onClick:d,disabled:l.isPending,className:`bg-blue-600 hover:bg-blue-700`,children:l.isPending?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(x,{className:`h-4 w-4 mr-2 animate-spin`}),`Actualizando...`]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(y,{className:`h-4 w-4 mr-2`}),`Confirmar actualización`]})})]})]})}),i.length>0&&(0,J.jsx)(H,{open:!0,onOpenChange:()=>a([]),children:(0,J.jsxs)(R,{children:[(0,J.jsxs)(V,{children:[(0,J.jsx)(L,{children:`Instrucciones de Actualización`}),(0,J.jsxs)(I,{className:`space-y-3`,children:[(0,J.jsx)(`p`,{children:`Sigue estos pasos para completar la actualización:`}),(0,J.jsx)(`ol`,{className:`list-decimal list-inside space-y-2 bg-muted p-4 rounded-lg`,children:i.map((e,t)=>(0,J.jsx)(`li`,{className:`text-sm`,children:e},t))}),(0,J.jsxs)(`div`,{className:`flex items-start gap-2 text-xs text-muted-foreground`,children:[(0,J.jsx)(ee,{className:`h-4 w-4 mt-0.5`}),(0,J.jsx)(`p`,{children:`Después de completar los pasos, recarga esta página para ver la nueva versión.`})]})]})]}),(0,J.jsx)(B,{children:(0,J.jsx)(z,{children:`Entendido`})})]})})]})}function ge({icon:e,...t}){return(0,J.jsx)(e,{...t})}function _e(){let{status:e}=ie(),{allAgents:t}=de(),{data:f}=p({queryKey:[`system-stats`],queryFn:()=>E(`/api/system-stats`),refetchInterval:5e3}),{data:m=[]}=p({queryKey:[`activity-stats`],queryFn:()=>E(`/api/activity-stats?hours=12`),refetchInterval:6e4}),h=(0,q.useMemo)(()=>t||[],[t]),g=[{label:`Agentes Activos`,value:h.length,icon:T,color:`text-blue-500`,trend:`${h.filter(e=>e.status===`active`||e.status===`thinking`).length} en uso`},{label:`Sesiones Canvas`,value:f?.connections??0,icon:re,color:`text-orange-500`,trend:`Live`},{label:`Procesos Bridge`,value:h.filter(e=>e.status===`thinking`).length,icon:W,color:`text-purple-500`,trend:`Estable`},{label:`Mensajes / 1h`,value:m.at(-1)?.count??0,icon:_,color:`text-green-500`,trend:`Última hora`}],v=(0,q.useMemo)(()=>{let e=h.filter(e=>e.status===`idle`||e.status===`hibernated`).length,t=h.filter(e=>e.status===`active`).length,n=h.filter(e=>e.status===`thinking`).length,r=h.filter(e=>e.status===`error`).length;return[{name:`Idle`,value:e||0,color:`hsl(var(--muted))`},{name:`Active`,value:t||0,color:`hsl(var(--primary))`},{name:`Thinking`,value:n||0,color:`hsl(var(--accent))`},...r>0?[{name:`Error`,value:r,color:`#ef4444`}]:[]].filter(e=>e.value>0||e.name===`Idle`)},[h]),y=m.reduce((e,t)=>e+t.count,0);return f?.memory?.percentage&&Math.max(0,Math.round(100-f.memory.percentage*.3-(f.cpu||0)*.2)),(0,J.jsxs)(`div`,{className:`hive-page-container`,children:[(0,J.jsxs)(`div`,{className:`hive-page-header`,children:[(0,J.jsxs)(`div`,{className:`relative z-10`,children:[(0,J.jsxs)(`div`,{className:`hive-page-header__eyebrow`,children:[(0,J.jsx)(`div`,{className:`hive-page-header__dot`}),(0,J.jsx)(`span`,{className:`hive-page-header__label`,children:`SISTEMA OPERATIVO HIVE`})]}),(0,J.jsxs)(`h2`,{className:`hive-title-page`,children:[`Centro de `,(0,J.jsx)(`span`,{className:`hive-title-page__accent`,children:`Control`})]}),(0,J.jsx)(`p`,{className:`hive-subtitle`,children:`Monitoreo en tiempo real del enjambre y estado de los nodos cognitivos.`})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-6 relative z-10`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col items-end`,children:[(0,J.jsx)(`span`,{className:`hive-label mb-1`,children:`Estado Hive`}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`div`,{className:e===`connected`?`hive-status-dot--active`:`hive-status-dot--disabled`}),(0,J.jsx)(`span`,{className:e===`connected`?`hive-status-label--active`:`hive-status-label--disabled`,children:e===`connected`?`EN LÍNEA`:`DESCONECTADO`})]})]}),(0,J.jsx)(`div`,{className:`h-10 w-px bg-white/10 hidden sm:block`}),(0,J.jsx)(he,{})]})]}),(0,J.jsx)(`div`,{className:`grid gap-6 sm:grid-cols-2 lg:grid-cols-4 mb-8`,children:g.map(e=>(0,J.jsxs)(`div`,{className:`hive-card hive-card--active group`,children:[(0,J.jsxs)(`div`,{className:`hive-card-body`,children:[(0,J.jsxs)(`div`,{className:`flex flex-row items-center justify-between mb-4`,children:[(0,J.jsx)(`span`,{className:`hive-title-section`,children:e.label}),(0,J.jsx)(`div`,{className:`p-2 rounded-lg bg-white/5 border border-white/5`,children:(0,J.jsx)(ge,{icon:e.icon,className:`h-4 w-4 ${e.color}`})})]}),(0,J.jsxs)(`div`,{className:`flex items-end justify-between`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`text-3xl font-black text-white group-hover:text-blue-400 transition-colors`,children:e.value}),(0,J.jsxs)(`p`,{className:`text-[10px] font-bold text-white/30 uppercase tracking-widest mt-1 flex items-center gap-1`,children:[(0,J.jsx)(U,{className:`h-2.5 w-2.5 text-green-500`}),e.trend]})]}),(0,J.jsx)(`div`,{className:`h-8 w-8 rounded-full border border-white/5 bg-white/5 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,J.jsx)(U,{className:`h-4 w-4 text-blue-400`})})]})]}),(0,J.jsx)(`div`,{className:`hive-strip--bottom`})]},e.label))}),(0,J.jsx)(pe,{}),(0,J.jsx)(me,{}),(0,J.jsxs)(`div`,{className:`grid gap-6 lg:grid-cols-3 mb-8`,children:[(0,J.jsx)(`div`,{className:`lg:col-span-2 hive-card`,children:(0,J.jsxs)(`div`,{className:`hive-card-body !pb-0`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between mb-6`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h3`,{className:`hive-title-section`,children:`Actividad del Enjambre`}),(0,J.jsxs)(`p`,{className:`text-[10px] text-white/40 uppercase tracking-widest font-bold`,children:[`Últimas 12 horas · `,y,` mensajes`]})]}),(0,J.jsx)(_,{className:`h-5 w-5 text-blue-500 animate-pulse shadow-blue-glow`})]}),(0,J.jsx)(`div`,{className:`h-[280px] w-full`,children:m.length>0?(0,J.jsx)(s,{width:`100%`,height:`100%`,children:(0,J.jsxs)(u,{data:m,children:[(0,J.jsx)(`defs`,{children:(0,J.jsxs)(`linearGradient`,{id:`colorCount`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,J.jsx)(`stop`,{offset:`5%`,stopColor:`#3b82f6`,stopOpacity:.2}),(0,J.jsx)(`stop`,{offset:`95%`,stopColor:`#3b82f6`,stopOpacity:0})]})}),(0,J.jsx)(i,{strokeDasharray:`3 3`,vertical:!1,stroke:`rgba(255,255,255,0.05)`}),(0,J.jsx)(o,{dataKey:`time`,axisLine:!1,tickLine:!1,tick:{fill:`rgba(255,255,255,0.3)`,fontSize:10,fontWeight:`bold`}}),(0,J.jsx)(n,{axisLine:!1,tickLine:!1,tick:{fill:`rgba(255,255,255,0.3)`,fontSize:10,fontWeight:`bold`},allowDecimals:!1}),(0,J.jsx)(a,{contentStyle:{backgroundColor:`#09090b`,borderRadius:`12px`,border:`1px solid rgba(255,255,255,0.1)`,color:`#fff`},itemStyle:{color:`#3b82f6`},formatter:e=>[e,`Mensajes`]}),(0,J.jsx)(l,{type:`monotone`,dataKey:`count`,stroke:`#3b82f6`,strokeWidth:4,fillOpacity:1,fill:`url(#colorCount)`})]})}):(0,J.jsx)(`div`,{className:`h-full flex items-center justify-center text-white/30 text-sm`,children:`Cargando actividad...`})})]})}),(0,J.jsx)(`div`,{className:`hive-card`,children:(0,J.jsxs)(`div`,{className:`hive-card-body`,children:[(0,J.jsx)(`h3`,{className:`hive-title-section mb-6`,children:`Distribución de Agentes`}),(0,J.jsx)(`div`,{className:`h-[210px]`,children:v.length>0?(0,J.jsx)(s,{width:`100%`,height:`100%`,children:(0,J.jsxs)(c,{data:v,layout:`vertical`,children:[(0,J.jsx)(o,{type:`number`,hide:!0,allowDecimals:!1}),(0,J.jsx)(n,{dataKey:`name`,type:`category`,axisLine:!1,tickLine:!1,tick:{fill:`rgba(255,255,255,0.5)`,fontSize:10,fontWeight:`bold`},width:70}),(0,J.jsx)(a,{cursor:{fill:`rgba(255,255,255,0.02)`}}),(0,J.jsx)(d,{dataKey:`value`,radius:[0,8,8,0],barSize:16,children:v.map(e=>(0,J.jsx)(r,{fill:e.color},e.name))})]})}):(0,J.jsx)(`div`,{className:`h-full flex items-center justify-center text-white/30 text-sm`,children:`Sin agentes configurados`})}),(0,J.jsxs)(`div`,{className:`mt-4 pt-4 border-t border-white/5 grid grid-cols-2 gap-4`,children:[(0,J.jsxs)(`div`,{className:`hive-stat`,children:[(0,J.jsx)(`span`,{className:`hive-stat__label`,children:`Salud Monitor`}),(0,J.jsx)(`span`,{className:`hive-stat__value hive-stat__value--active`,children:`Óptima`})]}),(0,J.jsxs)(`div`,{className:`hive-stat`,children:[(0,J.jsx)(`span`,{className:`hive-stat__label`,children:`Uptime`}),(0,J.jsx)(`span`,{className:`hive-stat__value hive-stat__value--active`,children:f?.uptime??`—`})]})]})]})})]})]})}export{_e as DashboardPage};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{_ as t}from"./vendor-charts-Bu2lyBKP.js";import{o as n}from"./vendor-query-DsWPbQdG.js";import{r}from"./utils-3pnRFmFe.js";import{c as i,i as a,n as o,o as s,s as c,t as l}from"./select-BQCOjM2j.js";import{t as u}from"./chevron-down-DIosfU_U.js";import{t as d}from"./chevron-right-CR4Skrf3.js";import{t as f}from"./circle-check-6Ard1-2z.js";import{t as p}from"./cpu-KDy6-FAI.js";import{t as m}from"./download-Cjbk4Rek.js";import{n as h,t as g}from"./eye-Df8o0tkC.js";import{t as _}from"./key-DyKOoQh5.js";import{t as v}from"./loader-circle-BmBOgYze.js";import{a as y,c as b,i as x,l as S,n as C,o as w,r as T,s as ee,t as E}from"./table-B3aGEaVp.js";import{t as D}from"./lock-BS6OLXPv.js";import{n as O,t as te}from"./square-DMNWw4Hi.js";import{n as k,t as A}from"./terminal--7G943As.js";import{t as j}from"./play-zJpWuhrr.js";import{t as M}from"./plus-BZQX26Dr.js";import{t as N}from"./refresh-cw-CCzDCAuz.js";import{t as ne}from"./search-DzDptO9s.js";import{t as re}from"./settings-BGfrZ_zM.js";import{t as P}from"./trash-2-xD2o4SgX.js";import{A as F,R as I,W as L,f as ie,i as ae,j as R,m as z,o as oe,q as se,r as ce,s as B,u as le}from"./index-CpfjkhN8.js";import{t as V}from"./label-fxFZcU5G.js";import{t as H}from"./switch-BR30E4ej.js";import{c as ue,i as U,o as de,r as W,s as G,t as K}from"./dialog-Dlh5z8bZ.js";import{t as q}from"./badge-Cn2irDlB.js";import{a as J,n as Y,o as fe,r as pe,t as X}from"./card-DFKnZ6ky.js";import"./useProviders-Klaz5WFx.js";import{i as me,n as he,r as ge,t as _e}from"./tabs-CqK5bFsS.js";import{t as ve}from"./scroll-area-8uM7g-LF.js";var ye=r(`KeyRound`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),be=r(`Package`,[[`path`,{d:`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z`,key:`1a0edw`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`path`,{d:`m3.3 7 7.703 4.734a2 2 0 0 0 1.994 0L20.7 7`,key:`yx3hmr`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}]]),Z=e(t(),1),Q=n();function xe({provider:e,onSave:t,onCancel:n}){let[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(e?.baseUrl||e?.base_url||``),[l,u]=(0,Z.useState)(e?.config?.headers?JSON.stringify(e.config.headers,null,2):``),[d,p]=(0,Z.useState)(e?.num_ctx?String(e.num_ctx):``),m=s||e?.baseUrl||e?.base_url||``,_=e?.id===`ollama`||m.includes(`localhost`)||m.includes(`127.0.0.1`),v=!!e?.has_api_key,y=!!e?.has_headers;return(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(V,{className:`hive-label`,children:`API Key`}),v&&(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] font-bold text-emerald-400`,children:[(0,Q.jsx)(f,{className:`h-3 w-3`}),`Configurada`]})]}),(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(F,{type:r?`text`:`password`,value:a,onChange:e=>o(e.target.value),placeholder:v?`•••••••••••••••• (dejar vacío para conservar)`:`sk-...`,className:`hive-input !h-8 text-xs pr-8`}),(0,Q.jsx)(R,{variant:`ghost`,size:`icon`,className:`absolute right-0 top-0 h-8 w-8 text-white/40 hover:text-white`,onClick:()=>i(!r),children:r?(0,Q.jsx)(h,{className:`h-3 w-3`}):(0,Q.jsx)(g,{className:`h-3 w-3`})})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(V,{className:`hive-label`,children:`Base URL (opcional)`}),(0,Q.jsx)(F,{value:s,onChange:e=>c(e.target.value),placeholder:`https://api.example.com`,className:`hive-input !h-8 text-xs`})]}),_&&(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(V,{className:`hive-label`,children:`Context Window (num_ctx)`}),(0,Q.jsx)(`span`,{className:`text-[10px] text-white/30`,children:`tokens — por defecto 32 768`})]}),(0,Q.jsx)(F,{type:`number`,value:d,onChange:e=>p(e.target.value),placeholder:`8192`,min:512,step:512,className:`hive-input !h-8 text-xs font-mono`}),(0,Q.jsx)(`p`,{className:`text-[10px] text-amber-400/60`,children:`Aumenta si ves errores de contexto. Tu modelo soporta hasta 262 144 tokens.`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(V,{className:`hive-label`,children:`Custom Headers (JSON)`}),y&&(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] font-bold text-emerald-400`,children:[(0,Q.jsx)(f,{className:`h-3 w-3`}),`Configurados`]})]}),(0,Q.jsx)(`textarea`,{value:l,onChange:e=>u(e.target.value),placeholder:y?`{ ... } (dejar vacío para conservar)`:`{ "x-custom-header": "value" }`,rows:3,className:`w-full bg-white/5 border border-white/10 rounded-md p-2 text-xs text-white/70 focus:outline-none focus:border-blue-500/50 transition-all font-mono`})]}),(0,Q.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[(0,Q.jsx)(`button`,{className:`hive-btn hive-btn--form-cancel flex-1`,onClick:n,children:`Cancelar`}),(0,Q.jsx)(`button`,{className:`hive-btn hive-btn--form-submit flex-1`,onClick:()=>{let e;if(l.trim())try{e=JSON.parse(l.trim())}catch{z.fire(`Error`,`JSON de Headers inválido`,`error`);return}t&&t({apiKey:a,baseUrl:s||void 0,headers:e,numCtx:d.trim()?Number(d.trim()):null})},children:`Guardar`})]}),(0,Q.jsx)(`p`,{className:`text-[10px] text-white/20 pt-2`,children:`La API key se guarda cifrada en la base de datos.`})]})}var Se=re,Ce=u,we=d,Te=p,Ee=M,De=ye,Oe=se,ke=N,Ae=k,je=P,Me=i,Ne=I;function Pe({provider:e,updateProvider:t,onManageModels:n}){let[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(``),[_,v]=(0,Z.useState)(``),[y,b]=(0,Z.useState)(null),{models:x,toggleModel:S,createModel:C,syncModels:w,deleteModel:T,updateModel:ee}=oe(),{toggleProvider:E}=B(),D=(0,Z.useMemo)(()=>{let t=x.filter(t=>(t.providerId||t.provider_id)===e.id);return t.length>0?t:e.models||[]},[x,e.id,e.models]),O=D.filter(e=>e.enabled||e.active),te=n=>{t(e.id,n),i(!1)},k=async t=>{try{await E(e.id,t)}catch(e){console.error(`Failed to toggle provider:`,e)}},A=async(e,t)=>{try{await S(e.id,t)}catch(e){console.error(`Failed to toggle model:`,e)}},j=async()=>{f(!0);try{await w(e.id),o(!0)}catch(e){console.error(`Failed to sync models:`,e)}finally{f(!1)}},M=e=>{m(e.id),g(e.name),v(e.id)},N=()=>{m(null),g(``),v(``)},ne=async e=>{let t=h.trim()||e.name,n=_.trim()||e.id;if(t===e.name&&n===e.id){N();return}try{await ee(e.id,{name:t,id:n}),N()}catch(e){console.error(`Failed to update model:`,e)}},re=async e=>{b(e.id);try{await T(e.id)}catch(e){console.error(`Failed to delete model:`,e)}finally{b(null)}},P=async()=>{let t=s.trim();if(t){u(!0);try{await C(e.id,t),c(``)}catch(e){console.error(`Failed to add model:`,e)}finally{u(!1)}}},F=!!e.active,I=e.base_url||e.baseUrl,L=e.id===`ollama`||I?.includes(`localhost`)||I?.includes(`127.0.0.1`);return(0,Q.jsxs)(`div`,{className:`hive-card group overflow-hidden flex flex-col gap-0 transition-all duration-500 ${F?`hive-card--active`:`opacity-70 grayscale-[0.5] hover:grayscale-0 hover:opacity-100`}`,children:[(0,Q.jsx)(`div`,{className:`hive-card-body pb-3`,children:(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,Q.jsx)(`div`,{className:`shrink-0 h-10 w-10 sm:h-11 sm:w-11 rounded-xl flex items-center justify-center border transition-all duration-500 ${F?`bg-blue-500/10 border-blue-500/30 text-blue-400 shadow-[0_0_16px_rgba(59,130,246,0.15)]`:`bg-white/5 border-white/10 text-white/30`}`,children:(0,Q.jsx)(Te,{className:`h-5 w-5`})}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mb-0.5`,children:[(0,Q.jsx)(`h3`,{className:`font-black text-white tracking-tight text-base sm:text-lg uppercase leading-none truncate`,children:e.name}),F&&(0,Q.jsx)(`div`,{className:`hive-status-dot--active h-1.5 w-1.5 shrink-0`})]}),(0,Q.jsx)(`p`,{className:`text-[11px] text-white/35 font-medium leading-none truncate`,children:e.id})]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,Q.jsx)(`span`,{className:`hidden sm:block text-[10px] font-black tracking-widest ${F?`text-blue-400`:`text-white/30`}`,children:F?`ON`:`OFF`}),(0,Q.jsx)(H,{checked:F,onCheckedChange:k,className:`data-[state=checked]:bg-blue-500`})]})]})}),(0,Q.jsxs)(`div`,{className:`px-5 pb-3 space-y-2 border-b border-white/5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,Q.jsx)(De,{className:`h-3.5 w-3.5 shrink-0 ${e.has_api_key?`text-emerald-400`:L?`text-amber-400`:`text-white/20`}`}),(0,Q.jsx)(`span`,{className:`text-[11px] font-mono truncate`,children:e.masked_api_key?(0,Q.jsx)(`span`,{className:`text-white/50`,children:e.masked_api_key}):e.has_api_key?(0,Q.jsx)(`span`,{className:`text-white/50`,children:`••••••••••••••••`}):L?(0,Q.jsx)(`span`,{className:`text-amber-400/70`,children:`Local — sin API key`}):(0,Q.jsx)(`span`,{className:`text-white/25`,children:`Sin API key`})})]}),I&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,Q.jsx)(Oe,{className:`h-3.5 w-3.5 shrink-0 text-white/20`}),(0,Q.jsx)(`span`,{className:`text-[11px] text-white/40 truncate font-mono`,children:I})]}),L&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,Q.jsx)(Te,{className:`h-3.5 w-3.5 shrink-0 text-white/20`}),(0,Q.jsxs)(`span`,{className:`text-[11px] text-white/40 font-mono`,children:[`ctx: `,(0,Q.jsx)(`span`,{className:e.num_ctx?`text-amber-400/70`:`text-white/25`,children:e.num_ctx?`${e.num_ctx.toLocaleString()} tokens`:`32 768 (default)`})]})]})]}),(0,Q.jsxs)(`div`,{className:`px-5 py-3 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,Q.jsxs)(`button`,{type:`button`,className:`flex items-center gap-2 flex-1 text-left text-[10px] font-black uppercase tracking-widest text-white/40 hover:text-white transition-colors`,onClick:()=>o(!a),children:[a?(0,Q.jsx)(Ce,{className:`h-3 w-3`}):(0,Q.jsx)(we,{className:`h-3 w-3`}),`MODELOS`,(0,Q.jsxs)(`span`,{className:`hive-tag scale-90 origin-left`,children:[O.length,`/`,D.length]})]}),L&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`text-[9px] font-semibold text-amber-400/70 bg-amber-400/10 border border-amber-400/20 rounded px-1.5 py-0.5 leading-none whitespace-nowrap`,children:`Actualiza modelos locales`}),(0,Q.jsx)(`button`,{type:`button`,onClick:j,disabled:d,title:`Sincronizar modelos instalados en Ollama`,className:`h-6 w-6 flex items-center justify-center rounded-md text-white/30 hover:text-amber-400 hover:bg-amber-400/10 disabled:opacity-40 transition-colors`,children:(0,Q.jsx)(ke,{className:`h-3 w-3 ${d?`animate-spin`:``}`})})]})]}),!a&&D.length>0&&(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-1 mt-1`,children:[D.slice(0,3).map(e=>(0,Q.jsx)(`span`,{className:`hive-tag text-[10px] ${e.enabled||e.active?``:`opacity-40`}`,children:e.name.split(`/`).pop()||e.name},e.id)),D.length>3&&(0,Q.jsxs)(`span`,{className:`hive-tag text-[10px] text-white/30`,children:[`+`,D.length-3]})]}),a&&(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsxs)(`div`,{className:`hive-scroll max-h-44 overflow-y-auto flex flex-col gap-0.5 pr-1`,children:[D.length===0&&(0,Q.jsx)(`p`,{className:`text-[11px] text-white/25 py-2 text-center`,children:`Sin modelos configurados`}),D.map(e=>{let t=e.enabled||!!e.active,n=p===e.id;return(0,Q.jsx)(`div`,{className:`rounded-lg transition-colors ${t&&!n||n?`bg-white/5`:`bg-transparent opacity-40`}`,children:n?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 px-2.5 py-1.5`,children:[(0,Q.jsx)(`input`,{type:`text`,value:h,onChange:e=>g(e.target.value),placeholder:`Display name`,className:`w-full bg-white/5 border border-white/10 rounded-md px-2 h-7 text-[11px] text-white/70 placeholder-white/20 focus:outline-none focus:border-blue-500/50 transition-all`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(`input`,{type:`text`,value:_,onChange:e=>v(e.target.value),placeholder:`API model ID`,className:`flex-1 min-w-0 bg-white/5 border border-white/10 rounded-md px-2 h-7 text-[11px] text-white/70 placeholder-white/20 focus:outline-none focus:border-blue-500/50 transition-all font-mono`}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>ne(e),className:`shrink-0 h-7 w-7 flex items-center justify-center rounded-md bg-emerald-500/10 border border-emerald-500/20 text-emerald-400 hover:bg-emerald-500/20 transition-colors`,children:(0,Q.jsx)(Me,{className:`h-3 w-3`})}),(0,Q.jsx)(`button`,{type:`button`,onClick:N,className:`shrink-0 h-7 w-7 flex items-center justify-center rounded-md bg-white/5 border border-white/10 text-white/40 hover:text-white hover:bg-white/10 transition-colors`,children:(0,Q.jsx)(Ne,{className:`h-3 w-3`})})]})]}):(0,Q.jsxs)(`div`,{className:`flex items-center justify-between px-2.5 py-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-[11px] font-medium text-white truncate flex-1 mr-2`,children:e.name}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>M(e),title:`Editar modelo`,className:`h-5 w-5 flex items-center justify-center rounded text-white/25 hover:text-blue-400 hover:bg-blue-400/10 transition-colors`,children:(0,Q.jsx)(Ae,{className:`h-3 w-3`})}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>re(e),disabled:y===e.id,title:`Eliminar modelo`,className:`h-5 w-5 flex items-center justify-center rounded text-white/25 hover:text-red-400 hover:bg-red-400/10 disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,children:(0,Q.jsx)(je,{className:`h-3 w-3`})}),(0,Q.jsx)(H,{checked:t,onCheckedChange:t=>A(e,t),className:`scale-[0.7] origin-right data-[state=checked]:bg-blue-400 ml-0.5`})]})]})},e.id)})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 pt-1.5 border-t border-white/5`,children:[(0,Q.jsx)(`input`,{type:`text`,value:s,onChange:e=>c(e.target.value),onKeyDown:e=>e.key===`Enter`&&P(),placeholder:`nombre-del-modelo`,className:`flex-1 min-w-0 bg-white/5 border border-white/10 rounded-md px-2 h-7 text-[11px] text-white/70 placeholder-white/20 focus:outline-none focus:border-blue-500/50 transition-all font-mono`}),(0,Q.jsxs)(`button`,{type:`button`,onClick:P,disabled:l||!s.trim(),className:`shrink-0 h-7 px-2.5 flex items-center gap-1 rounded-md bg-blue-500/10 border border-blue-500/20 text-blue-400 text-[10px] font-black uppercase tracking-wider hover:bg-blue-500/20 disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,children:[(0,Q.jsx)(Ee,{className:`h-3 w-3`}),(0,Q.jsx)(`span`,{className:`hidden xs:inline`,children:`ADD`})]})]})]})]}),(0,Q.jsxs)(`div`,{className:`px-4 py-3 border-t border-white/5 flex items-center justify-between gap-2 overflow-hidden`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 overflow-hidden`,children:[(0,Q.jsxs)(`div`,{className:`hive-stat shrink-0`,children:[(0,Q.jsx)(`span`,{className:`hive-stat__label`,children:`Uptime`}),(0,Q.jsx)(`span`,{className:`hive-stat__value`,children:`99.9%`})]}),(0,Q.jsxs)(`div`,{className:`hive-stat shrink-0`,children:[(0,Q.jsx)(`span`,{className:`hive-stat__label`,children:`Estado`}),(0,Q.jsx)(`span`,{className:`hive-stat__value ${F?`text-emerald-400`:`text-white/30`}`,children:F?`Activo`:`Inactivo`})]})]}),(0,Q.jsxs)(K,{open:r,onOpenChange:i,children:[(0,Q.jsx)(ue,{asChild:!0,children:(0,Q.jsxs)(`button`,{className:`hive-btn hive-btn--ghost h-8 px-2.5 text-[10px] font-black uppercase tracking-widest text-blue-400 shrink-0 flex items-center gap-1.5`,children:[(0,Q.jsx)(Se,{className:`h-3 w-3`}),(0,Q.jsx)(`span`,{children:`CONFIG`})]})}),(0,Q.jsxs)(W,{className:`rounded-xl border border-white/10 p-0 overflow-hidden w-[calc(100vw-2rem)] max-w-md bg-[#09090b]`,children:[(0,Q.jsxs)(`div`,{className:`p-5 border-b border-white/5 bg-white/5 relative overflow-hidden`,children:[(0,Q.jsx)(`div`,{className:`absolute -top-10 -right-10 h-32 w-32 bg-blue-600/10 rounded-full blur-[80px] pointer-events-none`}),(0,Q.jsx)(G,{className:`text-lg font-black text-white uppercase tracking-tighter`,children:e.name}),(0,Q.jsx)(U,{className:`text-xs text-white/40 font-medium mt-0.5`,children:`Autenticación y punto de enlace.`})]}),(0,Q.jsx)(`div`,{className:`p-5`,children:(0,Q.jsx)(xe,{provider:e,onSave:te,onCancel:()=>i(!1)})})]})]})]}),(0,Q.jsx)(`div`,{className:`hive-strip--bottom ${F?``:`opacity-20`}`})]})}function Fe(){let{providers:e,updateProvider:t}=B(),n=e.filter(e=>(e.category??`llm`)===`llm`),r=n.filter(e=>e.active).length;return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`h3`,{className:`hive-title-section`,children:`Providers de IA`}),(0,Q.jsxs)(`span`,{className:`hive-tag hive-tag--provider`,children:[r,` activos / `,n.length,` total`]})]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-3 gap-4 sm:gap-5`,children:[n.map(e=>(0,Q.jsx)(Pe,{provider:e,updateProvider:t},e.id)),n.length===0&&(0,Q.jsx)(`div`,{className:`hive-empty-state col-span-full`,children:`No hay providers disponibles.`})]})]})}function Ie({onSave:e,onCancel:t}){let[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(``),[o,s]=(0,Z.useState)(``),[c,l]=(0,Z.useState)(``),[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(``),[m,_]=(0,Z.useState)(``),v=o.toLowerCase()===`ollama`||u.includes(`localhost`)||u.includes(`127.0.0.1`);return(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(V,{className:`hive-label`,children:`Nombre del Provider`}),(0,Q.jsx)(F,{value:i,onChange:e=>a(e.target.value),placeholder:`Mi Provider Personalizado`,className:`hive-input !h-8 text-xs`}),(0,Q.jsx)(`p`,{className:`text-[10px] text-white/30`,children:`Se usará como identificador interno`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(V,{className:`hive-label`,children:`Tipo de Provider`}),(0,Q.jsx)(F,{value:o,onChange:e=>s(e.target.value),placeholder:`openai, anthropic, ollama...`,className:`hive-input !h-8 text-xs`}),(0,Q.jsx)(`p`,{className:`text-[10px] text-white/30`,children:`Ej: openai, anthropic, ollama, custom...`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,Q.jsx)(V,{className:`hive-label`,children:`API Key`})}),(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(F,{type:n?`text`:`password`,value:c,onChange:e=>l(e.target.value),placeholder:v?`Opcional para providers locales`:`sk-...`,className:`hive-input !h-8 text-xs pr-8`}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>r(!n),className:`absolute right-0 top-0 h-8 w-8 flex items-center justify-center text-white/40 hover:text-white`,children:n?(0,Q.jsx)(h,{className:`h-3 w-3`}):(0,Q.jsx)(g,{className:`h-3 w-3`})})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(V,{className:`hive-label`,children:`Base URL (opcional)`}),(0,Q.jsx)(F,{value:u,onChange:e=>d(e.target.value),placeholder:`https://api.example.com o http://localhost:11434`,className:`hive-input !h-8 text-xs`})]}),v&&(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(V,{className:`hive-label`,children:`Context Window (num_ctx)`}),(0,Q.jsx)(`span`,{className:`text-[10px] text-white/30`,children:`tokens — por defecto 32 768`})]}),(0,Q.jsx)(F,{type:`number`,value:m,onChange:e=>_(e.target.value),placeholder:`32768`,min:512,step:512,className:`hive-input !h-8 text-xs font-mono`}),(0,Q.jsx)(`p`,{className:`text-[10px] text-amber-400/60`,children:`Aumenta si ves errores de contexto.`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,Q.jsx)(V,{className:`hive-label`,children:`Custom Headers (JSON)`})}),(0,Q.jsx)(`textarea`,{value:f,onChange:e=>p(e.target.value),placeholder:`{ "x-custom-header": "value" }`,rows:3,className:`w-full bg-white/5 border border-white/10 rounded-md p-2 text-xs text-white/70 focus:outline-none focus:border-blue-500/50 transition-all font-mono`})]}),(0,Q.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[(0,Q.jsx)(`button`,{className:`hive-btn hive-btn--form-cancel flex-1`,onClick:t,children:`Cancelar`}),(0,Q.jsx)(`button`,{className:`hive-btn hive-btn--form-submit flex-1`,onClick:()=>{if(!i.trim()){z.fire(`Error`,`El nombre del provider es requerido`,`error`);return}if(!o){z.fire(`Error`,`Selecciona un tipo de provider`,`error`);return}if(!c.trim()&&!v){z.fire(`Error`,`La API Key es requerida para este provider`,`error`);return}let t;if(f.trim())try{t=JSON.parse(f.trim())}catch{z.fire(`Error`,`JSON de Headers inválido`,`error`);return}e({id:i.trim().toLowerCase().replace(/\s+/g,`-`),name:i.trim(),type:o,apiKey:c.trim()||``,baseUrl:u.trim()||void 0,headers:t,numCtx:m.trim()?Number(m.trim()):null})},children:`Crear Provider`})]}),(0,Q.jsx)(`p`,{className:`text-[10px] text-white/20 pt-2`,children:`La API key se guarda cifrada en la base de datos.`})]})}var Le={chat:`Chat`,vision:`Vision`,json_mode:`JSON`,function_calling:`Functions`,streaming:`Stream`,embeddings:`Embed`,image_generation:`Imagen`,code:`Codigo`,reasoning:`Razonamiento`,transcription:`STT`,translation:`Traduccion`,tts:`TTS`,speech:`Voz`,high_quality:`HQ`,ocr:`OCR`};function Re({capabilities:e}){let t=[];if(typeof e==`string`)try{t=JSON.parse(e)}catch{t=[]}else Array.isArray(e)&&(t=e);return t.length===0?null:(0,Q.jsx)(Q.Fragment,{children:t.map(e=>(0,Q.jsx)(q,{variant:`outline`,className:`text-[10px] py-0 h-4`,children:Le[e]??e},e))})}function ze({model:e}){let{toggleModel:t}=oe();return(0,Q.jsx)(X,{className:e.active?``:`opacity-70 bg-muted/30`,children:(0,Q.jsxs)(Y,{className:`flex items-center gap-4 p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex-1 space-y-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-semibold`,children:e.name}),(0,Q.jsx)(q,{variant:`secondary`,className:`text-[10px]`,children:e.providerId||e.provider_id})]}),e.contextWindow&&(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[(e.contextWindow/1e3).toFixed(0),`K tokens contexto`]}),(0,Q.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 pt-1`,children:(0,Q.jsx)(Re,{capabilities:e.capabilities})})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col items-end gap-2`,children:[(0,Q.jsx)(H,{checked:!!e.active,onCheckedChange:n=>t(e.id,n)}),(0,Q.jsx)(q,{variant:e.active?`default`:`secondary`,className:`text-[10px]`,children:e.active?`Activo`:`Inactivo`})]})]})})}function $(e){if(!e)return[];if(typeof e==`string`)try{return JSON.parse(e)}catch{return[]}return Array.isArray(e)?e:[]}function Be(){let{availableModels:e,activeProviders:t}=B(),n=ce(e=>e.fetchAll),[r,i]=(0,Z.useState)(``),[u,d]=(0,Z.useState)(`all`);(0,Z.useEffect)(()=>{n(!0)},[n]);let f=(0,Z.useMemo)(()=>e.filter(e=>{let t=$(e.capabilities),n=t.includes(`vision`)||t.includes(`image_generation`)||t.includes(`ocr`),i=e.name.toLowerCase().includes(r.toLowerCase())||e.id.toLowerCase().includes(r.toLowerCase()),a=u===`all`||e.providerId===u||e.provider_id===u;return n&&i&&a}),[e,r,u]);return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Q.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Modelos de Imagen / Vision`})}),(0,Q.jsx)(q,{variant:`secondary`,children:f.length})]}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Estos modelos pueden procesar imagenes y documentos visuales. Si el agente usa uno de estos modelos, las imagenes se envian directamente. Si no, se usa OCR para extraer el texto.`}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsxs)(`div`,{className:`relative flex-1`,children:[(0,Q.jsx)(ne,{className:`absolute left-2 top-2 h-4 w-4 text-muted-foreground`}),(0,Q.jsx)(F,{placeholder:`Buscar modelo...`,className:`h-8 pl-8 text-sm`,value:r,onChange:e=>i(e.target.value)})]}),(0,Q.jsxs)(l,{value:u,onValueChange:d,children:[(0,Q.jsx)(s,{className:`h-8 w-40 text-sm`,children:(0,Q.jsx)(c,{placeholder:`Provider`})}),(0,Q.jsxs)(o,{children:[(0,Q.jsx)(a,{value:`all`,children:`Todos`}),t.map(e=>(0,Q.jsx)(a,{value:e.id,children:e.name},e.id))]})]})]}),(0,Q.jsx)(ve,{className:`h-[calc(100vh-26rem)]`,children:(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[f.map(e=>(0,Q.jsx)(ze,{model:e},e.id)),f.length===0&&(0,Q.jsxs)(`div`,{className:`hive-empty-state`,children:[(0,Q.jsx)(g,{className:`h-8 w-8 mx-auto mb-2 text-muted-foreground`}),(0,Q.jsx)(`p`,{children:`No hay modelos con capacidad de vision.`}),(0,Q.jsx)(`p`,{className:`text-xs mt-1`,children:`Habilita modelos con capability "vision" en la tab Providers.`})]})]})})]})}function Ve({open:e,onOpenChange:t}){let{availableTTSModels:n,fetchAvailableTTSModels:r,downloadTTSModel:a,isDownloadingModel:o,downloadLogs:s,fetchDownloadLogs:c}=ae(),[l,u]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{e&&d()},[e]);let d=async()=>{u(!0),await r(),u(!1)},f=async e=>{await a(e)},p=e=>{switch(e){case`high`:return`bg-green-500/20 text-green-400 border-green-500/30`;case`medium`:return`bg-yellow-500/20 text-yellow-400 border-yellow-500/30`;case`low`:return`bg-zinc-500/20 text-zinc-400 border-zinc-500/30`}};return(0,Q.jsx)(K,{open:e,onOpenChange:t,children:(0,Q.jsxs)(W,{className:`max-w-3xl max-h-[80vh] overflow-hidden flex flex-col`,children:[(0,Q.jsxs)(de,{children:[(0,Q.jsx)(G,{className:`flex items-center gap-2`,children:`📦 Gestionar Modelos TTS`}),(0,Q.jsx)(U,{children:`Descarga modelos de voz adicionales para Piper TTS. Cada modelo incluye el archivo de voz (.onnx) y su configuración (.json).`})]}),(0,Q.jsxs)(`div`,{className:`flex-1 overflow-auto mt-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Q.jsxs)(q,{variant:`outline`,children:[n.filter(e=>e.installed).length,` / `,n.length,` instalados`]})}),(0,Q.jsxs)(R,{size:`sm`,variant:`ghost`,onClick:d,disabled:l||o,className:`gap-2`,children:[(0,Q.jsx)(N,{className:`h-4 w-4 ${l?`animate-spin`:``}`}),`Actualizar`]})]}),l&&!n.length?(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,Q.jsx)(v,{className:`h-6 w-6 animate-spin text-muted-foreground`})}):n.length===0?(0,Q.jsx)(`div`,{className:`text-center py-8 text-muted-foreground`,children:`No hay modelos disponibles`}):(0,Q.jsxs)(E,{children:[(0,Q.jsx)(y,{children:(0,Q.jsxs)(w,{children:[(0,Q.jsx)(x,{children:`Modelo`}),(0,Q.jsx)(x,{children:`Idioma`}),(0,Q.jsx)(x,{children:`Calidad`}),(0,Q.jsx)(x,{children:`Tamaño`}),(0,Q.jsx)(x,{children:`Estado`}),(0,Q.jsx)(x,{className:`text-right`,children:`Acciones`})]})}),(0,Q.jsx)(C,{children:n.map(e=>(0,Q.jsxs)(w,{children:[(0,Q.jsx)(T,{className:`font-medium`,children:e.name}),(0,Q.jsx)(T,{children:e.language}),(0,Q.jsx)(T,{children:(0,Q.jsx)(q,{className:p(e.quality),children:e.quality})}),(0,Q.jsx)(T,{className:`text-muted-foreground`,children:e.size}),(0,Q.jsx)(T,{children:e.installed?(0,Q.jsxs)(q,{className:`bg-green-500/20 text-green-400 border-green-500/30 gap-1`,children:[(0,Q.jsx)(i,{className:`h-3 w-3`}),`Instalado`]}):o&&s.some(t=>t.includes(e.name))?(0,Q.jsxs)(q,{className:`bg-blue-500/20 text-blue-400 border-blue-500/30 gap-1`,children:[(0,Q.jsx)(v,{className:`h-3 w-3 animate-spin`}),`Descargando`]}):(0,Q.jsx)(q,{variant:`secondary`,className:`bg-zinc-700/50 text-zinc-400`,children:`No instalado`})}),(0,Q.jsx)(T,{className:`text-right`,children:e.installed?(0,Q.jsxs)(R,{size:`sm`,variant:`ghost`,disabled:!0,className:`gap-2 opacity-50`,children:[(0,Q.jsx)(i,{className:`h-4 w-4`}),`Instalado`]}):(0,Q.jsxs)(R,{size:`sm`,onClick:()=>f(e.id),disabled:o,className:`gap-2`,children:[(0,Q.jsx)(m,{className:`h-4 w-4`}),`Descargar`]})})]},e.id))})]}),s.length>0&&(0,Q.jsxs)(`div`,{className:`mt-4`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-medium mb-2`,children:`Progreso de descarga:`}),(0,Q.jsx)(`div`,{className:`bg-black/40 rounded-md border border-zinc-700/50 p-3 h-32 overflow-y-auto font-mono text-xs text-zinc-300`,children:s.map((e,t)=>(0,Q.jsx)(`div`,{className:e.startsWith(`[error]`)?`text-red-400`:e.startsWith(`✓`)?`text-green-400`:``,children:e},t))})]})]})]})})}function He(){let{localTTS:e,fetchLocalTTSStatus:t,installLocalTTS:n,startLocalTTS:r,stopLocalTTS:i}=ae(),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)([]),[d,f]=(0,Z.useState)(``),[p,h]=(0,Z.useState)(!1),g=(0,Z.useRef)(null),_=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{t()},[t]),(0,Z.useEffect)(()=>(e.installing?g.current=setInterval(()=>{t(),s&&v()},3e3):g.current&&clearInterval(g.current),()=>{g.current&&clearInterval(g.current)}),[e.installing,s,t]),(0,Z.useEffect)(()=>{_.current&&(_.current.scrollTop=_.current.scrollHeight)},[l]);let v=async()=>{try{let e=await ie(`/api/tts-local/logs`);u(e.logs),f(e.ttsRoot)}catch{}},y=async()=>{o(!0),c(!0);try{await n(),await v()}finally{o(!1)}},x=async()=>{o(!0);try{await r()}finally{o(!1)}},S=async()=>{o(!0);try{await i()}finally{o(!1)}},C=async()=>{c(e=>!e),s||await v()},{installed:w,running:T,piperExists:E,voiceExists:D,port:O}=e,k=e.installing;return(0,Q.jsxs)(X,{className:`relative overflow-hidden col-span-full ${T?`border-blue-500/30 bg-blue-500/[0.02]`:``}`,children:[(0,Q.jsx)(J,{children:(0,Q.jsxs)(`div`,{className:`flex items-start justify-between flex-wrap gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(`span`,{className:`text-3xl`,children:`🎙️`}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(fe,{className:`text-lg flex items-center gap-2`,children:[`Piper TTS`,(0,Q.jsx)(q,{variant:`outline`,className:`text-[10px] px-1.5 py-0 font-normal border-zinc-600 text-zinc-400`,children:`Local · Offline`})]}),(0,Q.jsx)(pe,{className:`text-xs`,children:`TTS sin internet — binario nativo, sin Python, sin Docker. Fallback cuando no hay providers online.`})]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[k?(0,Q.jsxs)(q,{className:`bg-yellow-500/20 text-yellow-400 border-yellow-500/30 gap-1`,children:[(0,Q.jsx)(N,{className:`h-3 w-3 animate-spin`}),`Instalando…`]}):w?(0,Q.jsx)(q,{className:`bg-green-500/20 text-green-400 border-green-500/30`,children:`Instalado`}):(0,Q.jsx)(q,{variant:`secondary`,className:`bg-zinc-700/50 text-zinc-400`,children:`No instalado`}),w&&(T?(0,Q.jsxs)(q,{className:`bg-blue-500/20 text-blue-400 border-blue-500/30 gap-1`,children:[(0,Q.jsx)(ee,{className:`h-3 w-3`}),`Servidor :`,O]}):(0,Q.jsxs)(q,{variant:`secondary`,className:`bg-zinc-700/50 text-zinc-400 gap-1`,children:[(0,Q.jsx)(b,{className:`h-3 w-3`}),`Detenido`]}))]})]})}),(0,Q.jsxs)(Y,{className:`space-y-4`,children:[!w&&!k&&(0,Q.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 ${E?`text-green-400`:``}`,children:[(0,Q.jsx)(`span`,{children:E?`✓`:`○`}),` Binario Piper (~8 MB)`]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 ${D?`text-green-400`:``}`,children:[(0,Q.jsx)(`span`,{children:D?`✓`:`○`}),` Voz española (~60 MB)`]})]}),w&&(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Voz: `,(0,Q.jsx)(`code`,{className:`text-zinc-300`,children:e.voices?.[0]||`N/A`}),` · Puerto:`,` `,(0,Q.jsx)(`code`,{className:`text-zinc-300`,children:O}),` · Configurable con`,` `,(0,Q.jsx)(`code`,{className:`text-zinc-300`,children:`TTS_PORT`}),` / `,(0,Q.jsx)(`code`,{className:`text-zinc-300`,children:`TTS_VOICE`})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[!w&&!k&&(0,Q.jsxs)(R,{size:`sm`,onClick:y,disabled:a,className:`gap-2`,children:[(0,Q.jsx)(m,{className:`h-3.5 w-3.5`}),`Instalar Piper (~68 MB)`]}),k&&(0,Q.jsxs)(R,{size:`sm`,disabled:!0,className:`gap-2 opacity-70`,children:[(0,Q.jsx)(N,{className:`h-3.5 w-3.5 animate-spin`}),`Descargando…`]}),w&&!T&&(0,Q.jsxs)(R,{size:`sm`,onClick:x,disabled:a,className:`gap-2 bg-blue-600 hover:bg-blue-500 text-white`,children:[(0,Q.jsx)(j,{className:`h-3.5 w-3.5`}),`Iniciar servidor`]}),T&&(0,Q.jsxs)(R,{size:`sm`,variant:`outline`,onClick:S,disabled:a,className:`gap-2 border-red-500/40 text-red-400 hover:bg-red-500/10`,children:[(0,Q.jsx)(te,{className:`h-3.5 w-3.5`}),`Detener servidor`]}),w&&(0,Q.jsxs)(R,{size:`sm`,variant:`outline`,onClick:()=>h(!0),disabled:a,className:`gap-2`,children:[(0,Q.jsx)(be,{className:`h-3.5 w-3.5`}),`Gestionar modelos`,e.voices&&e.voices.length>0&&(0,Q.jsx)(q,{variant:`secondary`,className:`ml-1 text-[10px] px-1`,children:e.voices.length})]}),(0,Q.jsx)(R,{size:`sm`,variant:`ghost`,onClick:()=>t(),title:`Actualizar estado`,className:`text-zinc-400`,children:(0,Q.jsx)(N,{className:`h-3.5 w-3.5`})}),(0,Q.jsxs)(R,{size:`sm`,variant:`ghost`,onClick:C,className:`gap-1.5 text-zinc-400 text-xs`,children:[(0,Q.jsx)(A,{className:`h-3.5 w-3.5`}),s?`Ocultar log`:`Ver log`]})]}),k&&(0,Q.jsx)(`p`,{className:`text-xs text-yellow-400/80`,children:`Descargando binario y modelo de voz… puede tardar 1-3 min. El estado se actualiza automáticamente.`}),s&&(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[d&&(0,Q.jsxs)(`p`,{className:`text-[10px] text-zinc-500 font-mono`,children:[`ruta: `,d]}),(0,Q.jsx)(`div`,{ref:_,className:`bg-black/40 rounded-md border border-zinc-700/50 p-3 h-40 overflow-y-auto font-mono text-[11px] text-zinc-300 leading-relaxed`,children:l.length===0?(0,Q.jsx)(`span`,{className:`text-zinc-600`,children:`Sin registros aún. Inicia la instalación para ver el progreso.`}):l.map((e,t)=>(0,Q.jsx)(`div`,{className:e.startsWith(`[stderr]`)||e.startsWith(`[error]`)?`text-red-400`:``,children:e},t))})]}),(0,Q.jsx)(Ve,{open:p,onOpenChange:h})]})]})}var Ue={groq:{logo:`🔴`,consoleUrl:`https://console.groq.com/keys`},elevenlabs:{logo:`🎙️`,consoleUrl:`https://elevenlabs.io/app/settings/api-keys`},openai:{logo:`🟢`,consoleUrl:`https://platform.openai.com/api-keys`},gemini:{logo:`🔵`,consoleUrl:`https://aistudio.google.com/app/apikey`},qwen:{logo:`🟣`,consoleUrl:`https://dashscope.console.aliyun.com/apiKey`},piper:{logo:`🖥️`}};function We(){let{providers:e,availableModels:t,activeProviders:n}=B(),{voiceProviders:r,configuredVoiceProviders:u,fetchVoiceProviders:d,fetchConfiguredVoiceProviders:f,saveVoiceProviderKey:p}=le(),m=ce(e=>e.fetchAll),[h,g]=(0,Z.useState)(null),[v,y]=(0,Z.useState)(``),[b,x]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(!1),[T,ee]=(0,Z.useState)(``),[E,te]=(0,Z.useState)(`all`);(0,Z.useEffect)(()=>{d(),f(),m(!0)},[d,f,m]);let k=async e=>{if(v.trim()){x(!0);try{await p(e,v.trim()),await f(),g(null),y(``)}catch(e){console.error(`Failed to save API key:`,e)}finally{x(!1)}}},A=t=>{let n=e.find(e=>e.id===t),r=(n?.models||[]).filter(e=>e.model_type===`stt`||e.model_type===`tts`),i=r.some(e=>e.model_type===`stt`),a=r.some(e=>e.model_type===`tts`),o=r.some(e=>$(e.capabilities).includes(`local`)),s=Ue[t]||{logo:`🔌`};return{name:n?.name||t,description:[i&&`STT (Speech-to-Text)`,a&&`TTS (Text-to-Speech)`].filter(Boolean).join(` / `),logo:s.logo,consoleUrl:s.consoleUrl,noApiKey:o}},j=r.filter(e=>!A(e).noApiKey),M=(0,Z.useMemo)(()=>t.filter(e=>{let t=e.model_type===`stt`||e.model_type===`tts`,n=$(e.capabilities),r=n.includes(`transcription`)||n.includes(`tts`)||n.includes(`speech`),i=e.name.toLowerCase().includes(T.toLowerCase())||e.id.toLowerCase().includes(T.toLowerCase()),a=E===`all`||e.providerId===E||e.provider_id===E;return(t||r)&&i&&a}),[t,T,E]);return(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Modelos de Voz (STT / TTS)`}),(0,Q.jsx)(q,{variant:`secondary`,children:M.length})]}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsxs)(`div`,{className:`relative flex-1`,children:[(0,Q.jsx)(ne,{className:`absolute left-2 top-2 h-4 w-4 text-muted-foreground`}),(0,Q.jsx)(F,{placeholder:`Buscar modelo...`,className:`h-8 pl-8 text-sm`,value:T,onChange:e=>ee(e.target.value)})]}),(0,Q.jsxs)(l,{value:E,onValueChange:te,children:[(0,Q.jsx)(s,{className:`h-8 w-40 text-sm`,children:(0,Q.jsx)(c,{placeholder:`Provider`})}),(0,Q.jsxs)(o,{children:[(0,Q.jsx)(a,{value:`all`,children:`Todos`}),n.map(e=>(0,Q.jsx)(a,{value:e.id,children:e.name},e.id))]})]})]}),(0,Q.jsx)(ve,{className:`h-60`,children:(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[M.map(e=>(0,Q.jsx)(ze,{model:e},e.id)),M.length===0&&(0,Q.jsxs)(`div`,{className:`hive-empty-state`,children:[(0,Q.jsx)(O,{className:`h-8 w-8 mx-auto mb-2 text-muted-foreground`}),(0,Q.jsx)(`p`,{children:`No hay modelos de voz disponibles.`})]})]})})]}),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold`,children:`API Keys de Voz`}),(0,Q.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,Q.jsx)(He,{}),j.map(e=>{let t=A(e),n=u[e]===!0,r=h===e;return(0,Q.jsxs)(X,{className:`relative overflow-hidden ${n?`border-green-500/30 bg-green-500/[0.02]`:``}`,children:[(0,Q.jsx)(J,{children:(0,Q.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(`span`,{className:`text-3xl`,children:t.logo}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(fe,{className:`text-lg`,children:t.name}),(0,Q.jsx)(pe,{className:`text-xs`,children:t.description})]})]}),t.noApiKey?(0,Q.jsx)(q,{variant:`outline`,className:`bg-zinc-700/40 text-zinc-300 border-zinc-600`,children:`Sin API key`}):n?(0,Q.jsxs)(q,{variant:`default`,className:`bg-green-500/20 text-green-400 border-green-500/30`,children:[(0,Q.jsx)(i,{className:`h-3 w-3 mr-1`}),`Configurado`]}):(0,Q.jsx)(q,{variant:`secondary`,className:`bg-yellow-500/20 text-yellow-400 border-yellow-500/30`,children:`Sin configurar`})]})}),(0,Q.jsx)(Y,{className:`space-y-4`,children:t.noApiKey?(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t.description}):r?(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(V,{htmlFor:`api-key-${e}`,children:`API Key`}),(0,Q.jsxs)(`div`,{className:`flex gap-2 mt-1`,children:[(0,Q.jsx)(F,{id:`api-key-${e}`,type:C?`text`:`password`,placeholder:`sk-...`,value:v,onChange:e=>y(e.target.value),className:`flex-1 font-mono text-sm`,autoFocus:!0}),(0,Q.jsx)(R,{variant:`outline`,size:`icon`,onClick:()=>w(!C),title:C?`Ocultar`:`Mostrar`,children:C?(0,Q.jsx)(D,{className:`h-4 w-4`}):(0,Q.jsx)(S,{className:`h-4 w-4`})})]})]}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(R,{size:`sm`,onClick:()=>k(e),disabled:b||!v.trim(),className:`flex-1`,children:b?`Guardando...`:`Guardar`}),(0,Q.jsx)(R,{size:`sm`,variant:`outline`,onClick:()=>{g(null),y(``)},children:`Cancelar`})]})]}):(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[n?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,Q.jsx)(_,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{children:`API key guardada de forma segura (encriptada)`})]}):(0,Q.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Necesitas una API key de `,t.name,` para usar esta funcionalidad.`]}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[n?(0,Q.jsxs)(R,{size:`sm`,variant:`outline`,onClick:()=>{g(e),y(``)},className:`flex-1`,children:[(0,Q.jsx)(_,{className:`h-3 w-3 mr-2`}),`Actualizar API Key`]}):(0,Q.jsxs)(R,{size:`sm`,onClick:()=>{g(e),y(``)},className:`flex-1`,children:[(0,Q.jsx)(_,{className:`h-3 w-3 mr-2`}),`Configurar API Key`]}),t.consoleUrl&&(0,Q.jsx)(R,{size:`sm`,variant:`outline`,onClick:()=>window.open(t.consoleUrl,`_blank`),children:`Obtener Key`})]})]})})]},e)})]})]}),(0,Q.jsxs)(X,{children:[(0,Q.jsxs)(J,{children:[(0,Q.jsx)(fe,{className:`text-lg`,children:`Como funciona?`}),(0,Q.jsx)(pe,{children:`Configura las API keys de los providers de voz para habilitar STT y TTS en tus canales.`})]}),(0,Q.jsxs)(Y,{className:`space-y-4 text-sm text-muted-foreground`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`strong`,{className:`text-foreground`,children:`STT (Speech-to-Text):`}),` Convierte el audio entrante en texto. Groq Whisper es recomendado por su velocidad.`]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`strong`,{className:`text-foreground`,children:`TTS (Text-to-Speech):`}),` Convierte las respuestas de texto en audio. ElevenLabs ofrece las voces mas naturales.`]}),(0,Q.jsx)(`div`,{className:`pt-2 border-t`,children:(0,Q.jsx)(`p`,{className:`text-xs`,children:`Las API keys se guardan encriptadas en la base de datos local de Hive.`})})]})]})]})}var Ge=M,Ke=g,qe=O,Je=L;function Ye(){let{providers:e,createProvider:t}=B(),[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(`providers`);return(0,Q.jsxs)(`div`,{className:`space-y-4 mt-6 sm:mt-10`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 mb-2`,children:[(0,Q.jsx)(`div`,{className:`hive-page-header__dot`}),(0,Q.jsx)(`span`,{className:`hive-page-header__label`,children:`INFRAESTRUCTURA`})]}),(0,Q.jsxs)(`h2`,{className:`hive-title-page`,children:[`Providers de IA`,(0,Q.jsx)(`span`,{className:`hive-title-page__accent`,children:`.`})]})]}),(0,Q.jsxs)(K,{open:n,onOpenChange:e=>{r(e)},children:[(0,Q.jsx)(ue,{asChild:!0,children:(0,Q.jsxs)(`button`,{className:`hive-btn hive-btn--primary`,children:[(0,Q.jsx)(Ge,{className:`mr-1 h-4 w-4`}),`Añadir Provider`]})}),(0,Q.jsxs)(W,{className:`max-w-md`,children:[(0,Q.jsxs)(de,{className:`p-6 border-b border-white/5 bg-white/5 relative overflow-hidden`,children:[(0,Q.jsx)(`div`,{className:`hive-glow-blob hive-glow-blob--blue -top-10 -right-10 h-32 w-32 opacity-20`}),(0,Q.jsx)(G,{className:`text-xl font-black text-white uppercase tracking-tighter`,children:`Añadir Provider`}),(0,Q.jsx)(U,{className:`text-xs text-white/40 font-medium mt-1`,children:`Crea un nuevo provider de IA para tu infraestructura.`})]}),(0,Q.jsx)(`div`,{className:`p-6`,children:(0,Q.jsx)(Ie,{onSave:async e=>{try{await t({id:e.id,name:e.name,base_url:e.baseUrl,api_key:e.apiKey,headers:e.headers,num_ctx:e.numCtx}),r(!1)}catch(e){console.error(`Error creating provider:`,e)}},onCancel:()=>r(!1)})})]})]})]}),(0,Q.jsxs)(_e,{value:i,onValueChange:a,className:`w-full`,children:[(0,Q.jsxs)(ge,{className:`w-full grid grid-cols-3 h-10`,children:[(0,Q.jsxs)(me,{value:`providers`,className:`gap-1.5 text-xs`,children:[(0,Q.jsx)(Je,{className:`h-3.5 w-3.5`}),`Providers`]}),(0,Q.jsxs)(me,{value:`vision`,className:`gap-1.5 text-xs`,children:[(0,Q.jsx)(Ke,{className:`h-3.5 w-3.5`}),`Imagen`]}),(0,Q.jsxs)(me,{value:`voice`,className:`gap-1.5 text-xs`,children:[(0,Q.jsx)(qe,{className:`h-3.5 w-3.5`}),`Voz`]})]}),(0,Q.jsx)(he,{value:`providers`,className:`mt-4`,children:(0,Q.jsx)(Fe,{})}),(0,Q.jsx)(he,{value:`vision`,className:`mt-4`,children:(0,Q.jsx)(Be,{})}),(0,Q.jsx)(he,{value:`voice`,className:`mt-4`,children:(0,Q.jsx)(We,{})})]})]})}export{Ye as ProvidersPage};