@johpaz/hive-agents 1.1.5 → 1.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/hive.js +229813 -162547
- package/dist/tool-worker.js +68298 -1620
- package/dist/ui/assets/{A2UIPage-Dr3p75oE.js → A2UIPage-CxE3jH4_.js} +1 -1
- package/dist/ui/assets/{AgentCreateForm-DqYhH_gm.js → AgentCreateForm-SGj5AqAX.js} +1 -1
- package/dist/ui/assets/{AgentDetailPage-BVtE88U5.js → AgentDetailPage-CyYbqzHr.js} +1 -1
- package/dist/ui/assets/{AgentNewPage-BRpFxJIT.js → AgentNewPage-xvAmX6kw.js} +1 -1
- package/dist/ui/assets/{AgentsPage-BOIJ55cj.js → AgentsPage-CEWNs4Lt.js} +1 -1
- package/dist/ui/assets/{ApiClientPage-R9UDWfR2.js → ApiClientPage-NLw2wHjH.js} +1 -1
- package/dist/ui/assets/{ChannelsPage-C5V2BmjL.js → ChannelsPage-CmeXP-hI.js} +1 -1
- package/dist/ui/assets/{DashboardPage-B18gMzNj.js → DashboardPage-C3z4kZXD.js} +1 -1
- package/dist/ui/assets/{LoginPage-nrsYF9AY.js → LoginPage-DDisP8hm.js} +1 -1
- package/dist/ui/assets/{LogsPage-DICMU_7m.js → LogsPage-G9d2G1nL.js} +1 -1
- package/dist/ui/assets/{MeetingPage-xslJGfIz.js → MeetingPage-CKyjxtFr.js} +1 -1
- package/dist/ui/assets/{ModelSelector-BX4IvuYY.js → ModelSelector-VVwpDrYF.js} +1 -1
- package/dist/ui/assets/{Office3DPage-a6cuzt5X.js → Office3DPage-CYxB6z2p.js} +1 -1
- package/dist/ui/assets/ProvidersPage-CM9-E-Pf.js +1 -0
- package/dist/ui/assets/{RecoverPage-Blms3NBa.js → RecoverPage-Dr6qKgV5.js} +1 -1
- package/dist/ui/assets/{SettingsPage-BBeeq_QS.js → SettingsPage-BvD-vs5g.js} +1 -1
- package/dist/ui/assets/{SetupPage-CAjLseE_.js → SetupPage-BoVKIf4r.js} +1 -1
- package/dist/ui/assets/{VoicePage-BeSSYstD.js → VoicePage-CmudxYny.js} +1 -1
- package/dist/ui/assets/WebChatPage-CnoXpEOl.js +29 -0
- package/dist/ui/assets/{conversationsStore-DhM07qYi.js → conversationsStore-ns_ZfKgg.js} +1 -1
- package/dist/ui/assets/{dialog-BP3GTCPn.js → dialog-C3n2xYF2.js} +1 -1
- package/dist/ui/assets/{index-BG3nUPKq.js → index-C0W6p0lk.js} +3 -3
- package/dist/ui/assets/{useAudioDevices-zj0fuGwZ.js → useAudioDevices-CsPrtpWY.js} +1 -1
- package/dist/ui/assets/{useHiveAgentsModelLoad-Cd9p-bjs.js → useHiveAgentsModelLoad-nn4gON9g.js} +1 -1
- package/dist/ui/assets/{useProviders-Dj1k5PCk.js → useProviders-9tvEC3hX.js} +1 -1
- package/dist/ui/index.html +1 -1
- package/package.json +1 -1
- package/packages/cli/src/commands/onboard.ts +3 -2
- package/packages/core/src/agent/minimal-loadout.ts +1 -0
- package/packages/core/src/agent/tool-selector.ts +4 -0
- package/packages/core/src/artifacts/store.ts +8 -2
- package/packages/core/src/channels/base.ts +26 -0
- package/packages/core/src/channels/discord.ts +18 -2
- package/packages/core/src/channels/slack.ts +37 -7
- package/packages/core/src/channels/telegram.ts +39 -11
- package/packages/core/src/channels/whatsapp.ts +16 -1
- package/packages/core/src/gateway/channel-notify.ts +42 -0
- package/packages/core/src/gateway/routes/artifacts.ts +4 -0
- package/packages/core/src/gateway/routes/multimodal.ts +19 -0
- package/packages/core/src/gateway/server.ts +40 -17
- package/packages/core/src/gateway/webchat-turn.ts +15 -13
- package/packages/core/src/multimodal/attachment-ingest.ts +175 -0
- package/packages/core/src/multimodal/vision-analyzer.ts +94 -0
- package/packages/core/src/multimodal/vision-service.ts +25 -0
- package/packages/core/src/storage/seed.ts +26 -6
- package/packages/core/src/tool-runtime/index.ts +2 -0
- package/packages/core/src/tools/core/index.ts +79 -1
- package/packages/core/src/tools/office/index.ts +9 -0
- package/packages/core/src/tools/office/office-editar-docx.ts +184 -0
- package/packages/core/src/tools/office/office-editar-pptx.ts +126 -0
- package/packages/core/src/tools/office/office-editar-xlsx.ts +122 -0
- package/packages/core/src/tools/office/office-escribir-docx.ts +3 -2
- package/packages/core/src/tools/office/office-escribir-pdf.ts +3 -2
- package/packages/core/src/tools/office/office-escribir-pptx.ts +3 -2
- package/packages/core/src/tools/office/office-escribir-xlsx.ts +3 -2
- package/packages/core/src/tools/office/office-leer-docx.ts +6 -2
- package/packages/core/src/tools/office/office-leer-pdf.ts +41 -57
- package/packages/core/src/tools/office/office-leer-pptx.ts +51 -88
- package/packages/core/src/tools/office/office-leer-xlsx.ts +6 -2
- package/packages/core/src/tools/office/pdf-text.ts +186 -0
- package/packages/core/src/tools/office/pptx-slides.ts +83 -0
- package/packages/core/src/tools/office/resolve-input.ts +49 -0
- package/dist/ui/assets/ProvidersPage-C8-xGoeh.js +0 -1
- package/dist/ui/assets/WebChatPage-Bat7uUfd.js +0 -29
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{f as t}from"./vendor-charts-K3xcRl0X.js";import{t as n}from"./vendor-react-kUOwxn0g.js";import{o as r}from"./vendor-query-Dj8xYhQD.js";import{t as i}from"./createLucideIcon-BRaPSYgN.js";import{n as a,r as o}from"./gateway-url-BALS_wVh.js";import{a as s,i as c,n as l}from"./index-BG3nUPKq.js";import{t as u}from"./conversationsStore-DhM07qYi.js";var d=i(`Minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),f=i(`Settings2`,[[`path`,{d:`M20 7h-9`,key:`3s1dr2`}],[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),p=n(),m=r();function h(e){let t=(0,p.c)(18),{entradas:n,ocultas:r,onOcultar:i,onMostrar:a,className:o}=e,s,c,l,u;if(t[0]!==o||t[1]!==n||t[2]!==r||t[3]!==i){u=Symbol.for(`react.early_return_sentinel`);bb0:{let e=n.filter(g);if(e.length===0&&r.length===0){u=null;break bb0}s=o,c=`solo-altavoz`;let a;t[8]===i?a=t[9]:(a=e=>(0,m.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 py-0.5`,children:[(0,m.jsx)(`input`,{type:`checkbox`,checked:!1,onChange:()=>i(e),className:`mt-0.5`}),(0,m.jsxs)(`span`,{children:[(0,m.jsx)(`strong`,{children:e.nombre}),` es solo altavoz (no tiene micrófono). Un micrófono Bluetooth baja el sonido a calidad de llamada.`]})]},e.id),t[8]=i,t[9]=a),l=e.map(a)}t[0]=o,t[1]=n,t[2]=r,t[3]=i,t[4]=s,t[5]=c,t[6]=l,t[7]=u}else s=t[4],c=t[5],l=t[6],u=t[7];if(u!==Symbol.for(`react.early_return_sentinel`))return u;let d;t[10]!==r||t[11]!==a?(d=r.length>0&&(0,m.jsxs)(`p`,{className:`py-0.5`,children:[`Ocultos por ser solo altavoz:`,` `,r.map((e,t)=>(0,m.jsxs)(`span`,{children:[t>0&&`, `,e.nombre,` `,(0,m.jsx)(`button`,{type:`button`,className:`underline`,onClick:()=>a(e),children:`mostrar`})]},e.id))]}),t[10]=r,t[11]=a,t[12]=d):d=t[12];let f;return t[13]!==s||t[14]!==c||t[15]!==l||t[16]!==d?(f=(0,m.jsxs)(`div`,{className:s,"data-testid":c,children:[l,d]}),t[13]=s,t[14]=c,t[15]=l,t[16]=d,t[17]=f):f=t[17],f}function g(e){return e.bluetooth}var _=e(t(),1),v=`hive-voice-speaker-only`;function y(){try{let e=localStorage.getItem(v),t=e?JSON.parse(e):[];return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function b(e){try{e.length?localStorage.setItem(v,JSON.stringify(e)):localStorage.removeItem(v)}catch{}}function ee(e,t){let n=y().filter(t=>t!==e),r=t?[...n,e]:n;return b(r),r}function x(e,t){if(e.bluetooth)return!0;let n=e.nombre.trim().toLowerCase();return/bluetooth|bluez|hands-?free|\bheadset\b/.test(n)?!0:t.some(e=>{let t=e.trim().toLowerCase();return!!t&&(n===t||n.startsWith(`${t} `))})}function S(e,t,n){let r=e.map(e=>({...e,bluetooth:x(e,t)})),i=r.filter(e=>n.includes(e.nombre)),a=r.filter(e=>!n.includes(e.nombre));return{visibles:[...a.filter(e=>!e.bluetooth),...a.filter(e=>e.bluetooth)],ocultas:i}}function C(){return j?.element??null}function w(){return M?.element??null}function T(){return{mic:k?.spectrum??null,player:A?.spectrum??null}}function E(){return A?.lipsyncSource??null}function D(e){return e&&!l().cancelaEco&&!!A?.estaHablando()}var O=null,k=null,A=null,j=null,M=null,N=[{id:`Kore`,nombre:`Kore`,nota:`Femenina, firme`},{id:`Aoede`,nombre:`Aoede`,nota:`Femenina, cálida`},{id:`Leda`,nombre:`Leda`,nota:`Femenina, juvenil`},{id:`Zephyr`,nombre:`Zephyr`,nota:`Femenina, luminosa`},{id:`Autonoe`,nombre:`Autonoe`,nota:`Femenina, serena`},{id:`Despina`,nombre:`Despina`,nota:`Femenina, suave`},{id:`Puck`,nombre:`Puck`,nota:`Masculina, animada`},{id:`Charon`,nombre:`Charon`,nota:`Masculina, grave`},{id:`Fenrir`,nombre:`Fenrir`,nota:`Masculina, enérgica`},{id:`Orus`,nombre:`Orus`,nota:`Masculina, neutra`}],P=[{id:`es-CO`,nombre:`Español (Colombia)`},{id:`es-MX`,nombre:`Español (México)`},{id:`es-AR`,nombre:`Español (Argentina)`},{id:`es-ES`,nombre:`Español (España)`},{id:`es-US`,nombre:`Español (EE. UU.)`},{id:`en-US`,nombre:`Inglés (EE. UU.)`},{id:`pt-BR`,nombre:`Portugués (Brasil)`}],F=[{id:`foto`,nombre:`Retrato (mejor acabado)`},{id:`modelo`,nombre:`Modelo 3D (se gira con el ratón)`}],I=`hive-voice-avatar`,L=`hive-voice-persona`,R=`hive-voice-language`,z=`hive-voice-output`,B=`hive-voice-input`,V=`hive-voice-speaker`;function H(){return typeof localStorage>`u`?{voice:N[0].id,language:P[0].id,output:``,input:``,speaker:!1}:{voice:localStorage.getItem(L)||N[0].id,language:localStorage.getItem(R)||P[0].id,output:localStorage.getItem(z)||``,input:localStorage.getItem(B)||``,speaker:localStorage.getItem(V)===`1`}}function U(e){typeof localStorage>`u`||(e.voice&&localStorage.setItem(L,e.voice),e.language&&localStorage.setItem(R,e.language),W(z,e.output),W(B,e.input),e.speaker!==void 0&&localStorage.setItem(V,e.speaker?`1`:`0`))}function W(e,t){t!==void 0&&(t?localStorage.setItem(e,t):localStorage.removeItem(e))}function G(){if(typeof localStorage>`u`)return`modelo`;let e=localStorage.getItem(I);return e===`foto`||e===`modelo`?e:`modelo`}function K(e){typeof localStorage<`u`&&localStorage.setItem(I,e)}function q(e,t,n,r,i){let o=new URL(`${a()}/realtime`);o.searchParams.set(`session`,e);let s=typeof localStorage<`u`?localStorage.getItem(`hive-auth-token`):null;return s&&o.searchParams.set(`token`,s),t&&o.searchParams.set(`voice`,t),n&&o.searchParams.set(`lang`,n),r&&o.searchParams.set(`altavoz`,`1`),i&&o.searchParams.set(`conv`,i),o.toString()}var J={inputTokens:0,outputTokens:0,totalTokens:0},Y=0,X=o((e,t)=>({status:`idle`,error:null,model:null,voice:null,startedAt:null,transcripts:[],milestones:[],lastTool:null,working:!1,usage:J,latencyMs:null,cameraOn:!1,cameraError:null,screenOn:!1,screenError:null,modoAltavoz:H().speaker,toggleCamera:async()=>{if(j){j.stop(),j=null,e({cameraOn:!1,cameraError:null});return}try{let t=l().createCamera((e,t)=>{O?.readyState===WebSocket.OPEN&&O.send(JSON.stringify({type:`video`,data:e,mimeType:t}))});await t.start(),j=t,e({cameraOn:!0,cameraError:null})}catch(t){j=null,e({cameraOn:!1,cameraError:l().describeCameraError(t)})}},toggleScreen:async()=>{if(M){M.stop(),M=null,e({screenOn:!1,screenError:null});return}try{let t=l().createScreen((e,t)=>{O?.readyState===WebSocket.OPEN&&O.send(JSON.stringify({type:`video`,data:e,mimeType:t,source:`screen`}))},()=>{M=null,e({screenOn:!1})});await t.start(),M=t,e({screenOn:!0,screenError:null})}catch(t){M=null,e({screenOn:!1,screenError:l().describeScreenError(t)})}},prepararAudio:()=>{A||(A=l().createPlayer(),A.onIdle=()=>{t().status===`speaking`&&e({status:`listening`})}),A.resume()},usarModoAltavoz:t=>{U({speaker:t}),e({modoAltavoz:t})},micCallado:()=>t().modoAltavoz&&!l().cancelaEco&&!!A?.estaHablando(),usarSalida:async e=>{U({output:e}),e&&t().usarModoAltavoz(c(e)),await A?.usarSalida(e||null)},usarEntrada:async n=>{if(U({input:n}),!k)return;k.stop();let r=l().createMic(e=>{D(t().modoAltavoz)||O?.readyState===WebSocket.OPEN&&O.send(e)},n||null);k=r;try{await r.start()}catch(t){k=null,e({status:`error`,error:l().describeMicError(t)})}},probarSalida:async()=>{t().prepararAudio();let e=H();e.output&&A?.usarSalida(e.output),await A?.probar()},start:async(n,r,i)=>{if(t().status!==`idle`&&t().status!==`error`)return;e({status:`connecting`,error:null,transcripts:[],milestones:[],lastTool:null,working:!1,usage:J,latencyMs:null,startedAt:Date.now()}),t().prepararAudio();let a=H();a.output&&A?.usarSalida(a.output);try{if(await A?.resume(),!window.isSecureContext)throw Error(`El micrófono necesita una conexión segura (https o localhost).`);k=l().createMic(e=>{D(t().modoAltavoz)||O?.readyState===WebSocket.OPEN&&O.send(e)},a.input||null),await k.start()}catch(n){t().stop(),e({status:`error`,error:l().describeMicError(n)});return}O=new WebSocket(q(n,r??a.voice,i??a.language,t().modoAltavoz,u.getState().activeId)),O.binaryType=`arraybuffer`,O.onmessage=n=>{if(n.data instanceof ArrayBuffer){if(A?.enqueue(n.data),t().status===`listening`){let t=Y?Date.now()-Y:null;Y=0,e(t?{status:`speaking`,latencyMs:t}:{status:`speaking`})}return}let r;try{r=JSON.parse(n.data)}catch{return}switch(r.type){case`ready`:e({status:`listening`,model:r.model,voice:r.voice});break;case`transcript`:r.role===`user`&&(Y=Date.now()),e(e=>({transcripts:Z(e.transcripts,r.role,r.text)}));break;case`narration`:e(e=>({milestones:[...e.milestones,{id:`${r.at}-${e.milestones.length}`,kind:r.kind,status:r.status,label:r.label,detail:r.detail??null,agent:r.agent??``,at:r.at}].slice(-60),working:r.kind!==`group_ready`&&r.kind!==`failed`}));break;case`usage`:e({usage:{inputTokens:r.inputTokens,outputTokens:r.outputTokens,totalTokens:r.totalTokens}});break;case`interrupted`:A?.interrupt(),e({status:`listening`});break;case`turn_complete`:A?.isSpeaking||e({status:`listening`});break;case`tool`:e({lastTool:r.name,working:r.name===`consultar_a_bee`});break;case`error`:e({status:`error`,error:r.error});break;case`closed`:t().stop();break}},O.onerror=()=>e({status:`error`,error:`Se perdió la conexión con la voz.`}),O.onclose=()=>{t().status!==`error`&&t().stop()}},stop:()=>{k?.stop(),A?.stop(),j?.stop(),j=null,M?.stop(),M=null;try{O?.close()}catch{}k=null,A=null,O=null,Y=0,e({status:`idle`,model:null,voice:null,lastTool:null,working:!1,startedAt:null,cameraOn:!1,cameraError:null,screenOn:!1,screenError:null})},sendText:e=>{O?.readyState===WebSocket.OPEN&&O.send(JSON.stringify({type:`text`,content:e}))},interrupt:()=>{A?.interrupt(),O?.readyState===WebSocket.OPEN&&O.send(JSON.stringify({type:`interrupt`}))}}));function Z(e,t,n){let r=e[e.length-1];if(r&&r.role===t){let t=[...e];return t[t.length-1]={...r,text:r.text+n},t}return[...e,{role:t,text:n,at:Date.now()}].slice(-40)}var Q=`hive-audio-devices`;function $(){window.dispatchEvent(new Event(Q))}function te(e,t){ee(e,t),$()}function ne(){let e=(0,p.c)(10),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[0]=t):t=e[0];let[n,r]=(0,_.useState)(t),i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=[],e[1]=i):i=e[1];let[a,o]=(0,_.useState)(i),c;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=[],e[2]=c):c=e[2];let[u,d]=(0,_.useState)(c),[f,m]=(0,_.useState)(null),h,g;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>{let e=!0,t=()=>{let t=l();Promise.all([t.listInputs(),s()]).then(t=>{let[n,i]=t;if(!e)return;let{visibles:a,ocultas:s}=S(n,i,y());r(a),o(s)}),t.listOutputs().then(t=>{e&&(d(t.lista),m(t.motivo))})};return t(),navigator.mediaDevices?.addEventListener?.(`devicechange`,t),window.addEventListener(Q,t),()=>{e=!1,navigator.mediaDevices?.removeEventListener?.(`devicechange`,t),window.removeEventListener(Q,t)}},g=[],e[3]=h,e[4]=g):(h=e[3],g=e[4]),(0,_.useEffect)(h,g);let v;return e[5]!==n||e[6]!==f||e[7]!==a||e[8]!==u?(v={entradas:n,ocultas:a,salidas:u,motivoSalidas:f},e[5]=n,e[6]=f,e[7]=a,e[8]=u,e[9]=v):v=e[9],v}function re(e,t,n){let r=(0,p.c)(5),[i,a]=(0,_.useState)(0),o=(0,_.useRef)(0),s,c;return r[0]!==t||r[1]!==e||r[2]!==n?(s=()=>{if(!t){a(0);return}let r=!0,i=0,s=null,c=null,u=null,d=null,f=null,p=0,m=()=>{if(!r)return;let e=0;if(n)e=T().mic?.sample()??0;else if(f)e=Math.min(1,p*3.2);else if(u&&d){u.getByteFrequencyData(d);let t=0;for(let e of d)t+=e;e=Math.min(1,t/(d.length*255)*3.2)}o.current=e>o.current?o.current+(e-o.current)*.5:o.current+(e-o.current)*.12,a(o.current),i=requestAnimationFrame(m)};if(n)i=requestAnimationFrame(m);else if(l().kind===`native`){let t=l().createMic(e=>{p=se(e)},e||null);f=t,t.start().then(()=>{if(!r){t.stop();return}$(),i=requestAnimationFrame(m)}).catch(()=>{f=null})}else{let t={echoCancellation:!0,noiseSuppression:!0};e&&(t.deviceId={exact:e}),navigator.mediaDevices.getUserMedia({audio:t}).then(e=>{if(!r){e.getTracks().forEach(oe);return}s=e,$(),c=new AudioContext,u=c.createAnalyser(),u.fftSize=512,u.smoothingTimeConstant=.7,c.createMediaStreamSource(e).connect(u),d=new Uint8Array(new ArrayBuffer(u.frequencyBinCount)),i=requestAnimationFrame(m)}).catch(ae)}return()=>{r=!1,cancelAnimationFrame(i),s?.getTracks().forEach(ie),c?.close(),f?.stop(),o.current=0}},c=[e,t,n],r[0]=t,r[1]=e,r[2]=n,r[3]=s,r[4]=c):(s=r[3],c=r[4]),(0,_.useEffect)(s,c),i}function ie(e){return e.stop()}function ae(){}function oe(e){return e.stop()}function se(e){let t=new Int16Array(e);if(!t.length)return 0;let n=0;for(let e of t)n+=(e/32768)**2;return Math.sqrt(n/t.length)}var ce=.004,le=4e3;function ue(e,t){let n=(0,p.c)(9),[r,i]=(0,_.useState)(!1),a=(0,_.useRef)(0),o;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>{a.current=Date.now(),i(!1)},n[0]=o):o=n[0];let s;n[1]===t?s=n[2]:(s=[t],n[1]=t,n[2]=s),(0,_.useEffect)(o,s);let c,l;n[3]===e?(c=n[4],l=n[5]):(c=()=>{e>ce&&(a.current=Date.now(),i(de))},l=[e],n[3]=e,n[4]=c,n[5]=l),(0,_.useEffect)(c,l);let u,d;return n[6]===t?(u=n[7],d=n[8]):(u=()=>{if(!t)return;let e=setInterval(()=>{Date.now()-a.current>le&&i(!0)},500);return()=>clearInterval(e)},d=[t],n[6]=t,n[7]=u,n[8]=d),(0,_.useEffect)(u,d),t&&r}function de(e){return e&&!1}export{X as _,re as a,d as b,N as c,w as d,T as f,U as g,K as h,ue as i,C as l,H as m,te as n,F as o,G as p,ne as r,P as s,$ as t,E as u,h as v,f as y};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{f as t}from"./vendor-charts-K3xcRl0X.js";import{t as n}from"./vendor-react-kUOwxn0g.js";import{o as r}from"./vendor-query-Dj8xYhQD.js";import{t as i}from"./createLucideIcon-BRaPSYgN.js";import{n as a,r as o}from"./gateway-url-BALS_wVh.js";import{a as s,i as c,n as l}from"./index-C0W6p0lk.js";import{t as u}from"./conversationsStore-ns_ZfKgg.js";var d=i(`Minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),f=i(`Settings2`,[[`path`,{d:`M20 7h-9`,key:`3s1dr2`}],[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),p=n(),m=r();function h(e){let t=(0,p.c)(18),{entradas:n,ocultas:r,onOcultar:i,onMostrar:a,className:o}=e,s,c,l,u;if(t[0]!==o||t[1]!==n||t[2]!==r||t[3]!==i){u=Symbol.for(`react.early_return_sentinel`);bb0:{let e=n.filter(g);if(e.length===0&&r.length===0){u=null;break bb0}s=o,c=`solo-altavoz`;let a;t[8]===i?a=t[9]:(a=e=>(0,m.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 py-0.5`,children:[(0,m.jsx)(`input`,{type:`checkbox`,checked:!1,onChange:()=>i(e),className:`mt-0.5`}),(0,m.jsxs)(`span`,{children:[(0,m.jsx)(`strong`,{children:e.nombre}),` es solo altavoz (no tiene micrófono). Un micrófono Bluetooth baja el sonido a calidad de llamada.`]})]},e.id),t[8]=i,t[9]=a),l=e.map(a)}t[0]=o,t[1]=n,t[2]=r,t[3]=i,t[4]=s,t[5]=c,t[6]=l,t[7]=u}else s=t[4],c=t[5],l=t[6],u=t[7];if(u!==Symbol.for(`react.early_return_sentinel`))return u;let d;t[10]!==r||t[11]!==a?(d=r.length>0&&(0,m.jsxs)(`p`,{className:`py-0.5`,children:[`Ocultos por ser solo altavoz:`,` `,r.map((e,t)=>(0,m.jsxs)(`span`,{children:[t>0&&`, `,e.nombre,` `,(0,m.jsx)(`button`,{type:`button`,className:`underline`,onClick:()=>a(e),children:`mostrar`})]},e.id))]}),t[10]=r,t[11]=a,t[12]=d):d=t[12];let f;return t[13]!==s||t[14]!==c||t[15]!==l||t[16]!==d?(f=(0,m.jsxs)(`div`,{className:s,"data-testid":c,children:[l,d]}),t[13]=s,t[14]=c,t[15]=l,t[16]=d,t[17]=f):f=t[17],f}function g(e){return e.bluetooth}var _=e(t(),1),v=`hive-voice-speaker-only`;function y(){try{let e=localStorage.getItem(v),t=e?JSON.parse(e):[];return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function b(e){try{e.length?localStorage.setItem(v,JSON.stringify(e)):localStorage.removeItem(v)}catch{}}function ee(e,t){let n=y().filter(t=>t!==e),r=t?[...n,e]:n;return b(r),r}function x(e,t){if(e.bluetooth)return!0;let n=e.nombre.trim().toLowerCase();return/bluetooth|bluez|hands-?free|\bheadset\b/.test(n)?!0:t.some(e=>{let t=e.trim().toLowerCase();return!!t&&(n===t||n.startsWith(`${t} `))})}function S(e,t,n){let r=e.map(e=>({...e,bluetooth:x(e,t)})),i=r.filter(e=>n.includes(e.nombre)),a=r.filter(e=>!n.includes(e.nombre));return{visibles:[...a.filter(e=>!e.bluetooth),...a.filter(e=>e.bluetooth)],ocultas:i}}function C(){return j?.element??null}function w(){return M?.element??null}function T(){return{mic:k?.spectrum??null,player:A?.spectrum??null}}function E(){return A?.lipsyncSource??null}function D(e){return e&&!l().cancelaEco&&!!A?.estaHablando()}var O=null,k=null,A=null,j=null,M=null,N=[{id:`Kore`,nombre:`Kore`,nota:`Femenina, firme`},{id:`Aoede`,nombre:`Aoede`,nota:`Femenina, cálida`},{id:`Leda`,nombre:`Leda`,nota:`Femenina, juvenil`},{id:`Zephyr`,nombre:`Zephyr`,nota:`Femenina, luminosa`},{id:`Autonoe`,nombre:`Autonoe`,nota:`Femenina, serena`},{id:`Despina`,nombre:`Despina`,nota:`Femenina, suave`},{id:`Puck`,nombre:`Puck`,nota:`Masculina, animada`},{id:`Charon`,nombre:`Charon`,nota:`Masculina, grave`},{id:`Fenrir`,nombre:`Fenrir`,nota:`Masculina, enérgica`},{id:`Orus`,nombre:`Orus`,nota:`Masculina, neutra`}],P=[{id:`es-CO`,nombre:`Español (Colombia)`},{id:`es-MX`,nombre:`Español (México)`},{id:`es-AR`,nombre:`Español (Argentina)`},{id:`es-ES`,nombre:`Español (España)`},{id:`es-US`,nombre:`Español (EE. UU.)`},{id:`en-US`,nombre:`Inglés (EE. UU.)`},{id:`pt-BR`,nombre:`Portugués (Brasil)`}],F=[{id:`foto`,nombre:`Retrato (mejor acabado)`},{id:`modelo`,nombre:`Modelo 3D (se gira con el ratón)`}],I=`hive-voice-avatar`,L=`hive-voice-persona`,R=`hive-voice-language`,z=`hive-voice-output`,B=`hive-voice-input`,V=`hive-voice-speaker`;function H(){return typeof localStorage>`u`?{voice:N[0].id,language:P[0].id,output:``,input:``,speaker:!1}:{voice:localStorage.getItem(L)||N[0].id,language:localStorage.getItem(R)||P[0].id,output:localStorage.getItem(z)||``,input:localStorage.getItem(B)||``,speaker:localStorage.getItem(V)===`1`}}function U(e){typeof localStorage>`u`||(e.voice&&localStorage.setItem(L,e.voice),e.language&&localStorage.setItem(R,e.language),W(z,e.output),W(B,e.input),e.speaker!==void 0&&localStorage.setItem(V,e.speaker?`1`:`0`))}function W(e,t){t!==void 0&&(t?localStorage.setItem(e,t):localStorage.removeItem(e))}function G(){if(typeof localStorage>`u`)return`modelo`;let e=localStorage.getItem(I);return e===`foto`||e===`modelo`?e:`modelo`}function K(e){typeof localStorage<`u`&&localStorage.setItem(I,e)}function q(e,t,n,r,i){let o=new URL(`${a()}/realtime`);o.searchParams.set(`session`,e);let s=typeof localStorage<`u`?localStorage.getItem(`hive-auth-token`):null;return s&&o.searchParams.set(`token`,s),t&&o.searchParams.set(`voice`,t),n&&o.searchParams.set(`lang`,n),r&&o.searchParams.set(`altavoz`,`1`),i&&o.searchParams.set(`conv`,i),o.toString()}var J={inputTokens:0,outputTokens:0,totalTokens:0},Y=0,X=o((e,t)=>({status:`idle`,error:null,model:null,voice:null,startedAt:null,transcripts:[],milestones:[],lastTool:null,working:!1,usage:J,latencyMs:null,cameraOn:!1,cameraError:null,screenOn:!1,screenError:null,modoAltavoz:H().speaker,toggleCamera:async()=>{if(j){j.stop(),j=null,e({cameraOn:!1,cameraError:null});return}try{let t=l().createCamera((e,t)=>{O?.readyState===WebSocket.OPEN&&O.send(JSON.stringify({type:`video`,data:e,mimeType:t}))});await t.start(),j=t,e({cameraOn:!0,cameraError:null})}catch(t){j=null,e({cameraOn:!1,cameraError:l().describeCameraError(t)})}},toggleScreen:async()=>{if(M){M.stop(),M=null,e({screenOn:!1,screenError:null});return}try{let t=l().createScreen((e,t)=>{O?.readyState===WebSocket.OPEN&&O.send(JSON.stringify({type:`video`,data:e,mimeType:t,source:`screen`}))},()=>{M=null,e({screenOn:!1})});await t.start(),M=t,e({screenOn:!0,screenError:null})}catch(t){M=null,e({screenOn:!1,screenError:l().describeScreenError(t)})}},prepararAudio:()=>{A||(A=l().createPlayer(),A.onIdle=()=>{t().status===`speaking`&&e({status:`listening`})}),A.resume()},usarModoAltavoz:t=>{U({speaker:t}),e({modoAltavoz:t})},micCallado:()=>t().modoAltavoz&&!l().cancelaEco&&!!A?.estaHablando(),usarSalida:async e=>{U({output:e}),e&&t().usarModoAltavoz(c(e)),await A?.usarSalida(e||null)},usarEntrada:async n=>{if(U({input:n}),!k)return;k.stop();let r=l().createMic(e=>{D(t().modoAltavoz)||O?.readyState===WebSocket.OPEN&&O.send(e)},n||null);k=r;try{await r.start()}catch(t){k=null,e({status:`error`,error:l().describeMicError(t)})}},probarSalida:async()=>{t().prepararAudio();let e=H();e.output&&A?.usarSalida(e.output),await A?.probar()},start:async(n,r,i)=>{if(t().status!==`idle`&&t().status!==`error`)return;e({status:`connecting`,error:null,transcripts:[],milestones:[],lastTool:null,working:!1,usage:J,latencyMs:null,startedAt:Date.now()}),t().prepararAudio();let a=H();a.output&&A?.usarSalida(a.output);try{if(await A?.resume(),!window.isSecureContext)throw Error(`El micrófono necesita una conexión segura (https o localhost).`);k=l().createMic(e=>{D(t().modoAltavoz)||O?.readyState===WebSocket.OPEN&&O.send(e)},a.input||null),await k.start()}catch(n){t().stop(),e({status:`error`,error:l().describeMicError(n)});return}O=new WebSocket(q(n,r??a.voice,i??a.language,t().modoAltavoz,u.getState().activeId)),O.binaryType=`arraybuffer`,O.onmessage=n=>{if(n.data instanceof ArrayBuffer){if(A?.enqueue(n.data),t().status===`listening`){let t=Y?Date.now()-Y:null;Y=0,e(t?{status:`speaking`,latencyMs:t}:{status:`speaking`})}return}let r;try{r=JSON.parse(n.data)}catch{return}switch(r.type){case`ready`:e({status:`listening`,model:r.model,voice:r.voice});break;case`transcript`:r.role===`user`&&(Y=Date.now()),e(e=>({transcripts:Z(e.transcripts,r.role,r.text)}));break;case`narration`:e(e=>({milestones:[...e.milestones,{id:`${r.at}-${e.milestones.length}`,kind:r.kind,status:r.status,label:r.label,detail:r.detail??null,agent:r.agent??``,at:r.at}].slice(-60),working:r.kind!==`group_ready`&&r.kind!==`failed`}));break;case`usage`:e({usage:{inputTokens:r.inputTokens,outputTokens:r.outputTokens,totalTokens:r.totalTokens}});break;case`interrupted`:A?.interrupt(),e({status:`listening`});break;case`turn_complete`:A?.isSpeaking||e({status:`listening`});break;case`tool`:e({lastTool:r.name,working:r.name===`consultar_a_bee`});break;case`error`:e({status:`error`,error:r.error});break;case`closed`:t().stop();break}},O.onerror=()=>e({status:`error`,error:`Se perdió la conexión con la voz.`}),O.onclose=()=>{t().status!==`error`&&t().stop()}},stop:()=>{k?.stop(),A?.stop(),j?.stop(),j=null,M?.stop(),M=null;try{O?.close()}catch{}k=null,A=null,O=null,Y=0,e({status:`idle`,model:null,voice:null,lastTool:null,working:!1,startedAt:null,cameraOn:!1,cameraError:null,screenOn:!1,screenError:null})},sendText:e=>{O?.readyState===WebSocket.OPEN&&O.send(JSON.stringify({type:`text`,content:e}))},interrupt:()=>{A?.interrupt(),O?.readyState===WebSocket.OPEN&&O.send(JSON.stringify({type:`interrupt`}))}}));function Z(e,t,n){let r=e[e.length-1];if(r&&r.role===t){let t=[...e];return t[t.length-1]={...r,text:r.text+n},t}return[...e,{role:t,text:n,at:Date.now()}].slice(-40)}var Q=`hive-audio-devices`;function $(){window.dispatchEvent(new Event(Q))}function te(e,t){ee(e,t),$()}function ne(){let e=(0,p.c)(10),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[0]=t):t=e[0];let[n,r]=(0,_.useState)(t),i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=[],e[1]=i):i=e[1];let[a,o]=(0,_.useState)(i),c;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=[],e[2]=c):c=e[2];let[u,d]=(0,_.useState)(c),[f,m]=(0,_.useState)(null),h,g;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>{let e=!0,t=()=>{let t=l();Promise.all([t.listInputs(),s()]).then(t=>{let[n,i]=t;if(!e)return;let{visibles:a,ocultas:s}=S(n,i,y());r(a),o(s)}),t.listOutputs().then(t=>{e&&(d(t.lista),m(t.motivo))})};return t(),navigator.mediaDevices?.addEventListener?.(`devicechange`,t),window.addEventListener(Q,t),()=>{e=!1,navigator.mediaDevices?.removeEventListener?.(`devicechange`,t),window.removeEventListener(Q,t)}},g=[],e[3]=h,e[4]=g):(h=e[3],g=e[4]),(0,_.useEffect)(h,g);let v;return e[5]!==n||e[6]!==f||e[7]!==a||e[8]!==u?(v={entradas:n,ocultas:a,salidas:u,motivoSalidas:f},e[5]=n,e[6]=f,e[7]=a,e[8]=u,e[9]=v):v=e[9],v}function re(e,t,n){let r=(0,p.c)(5),[i,a]=(0,_.useState)(0),o=(0,_.useRef)(0),s,c;return r[0]!==t||r[1]!==e||r[2]!==n?(s=()=>{if(!t){a(0);return}let r=!0,i=0,s=null,c=null,u=null,d=null,f=null,p=0,m=()=>{if(!r)return;let e=0;if(n)e=T().mic?.sample()??0;else if(f)e=Math.min(1,p*3.2);else if(u&&d){u.getByteFrequencyData(d);let t=0;for(let e of d)t+=e;e=Math.min(1,t/(d.length*255)*3.2)}o.current=e>o.current?o.current+(e-o.current)*.5:o.current+(e-o.current)*.12,a(o.current),i=requestAnimationFrame(m)};if(n)i=requestAnimationFrame(m);else if(l().kind===`native`){let t=l().createMic(e=>{p=se(e)},e||null);f=t,t.start().then(()=>{if(!r){t.stop();return}$(),i=requestAnimationFrame(m)}).catch(()=>{f=null})}else{let t={echoCancellation:!0,noiseSuppression:!0};e&&(t.deviceId={exact:e}),navigator.mediaDevices.getUserMedia({audio:t}).then(e=>{if(!r){e.getTracks().forEach(oe);return}s=e,$(),c=new AudioContext,u=c.createAnalyser(),u.fftSize=512,u.smoothingTimeConstant=.7,c.createMediaStreamSource(e).connect(u),d=new Uint8Array(new ArrayBuffer(u.frequencyBinCount)),i=requestAnimationFrame(m)}).catch(ae)}return()=>{r=!1,cancelAnimationFrame(i),s?.getTracks().forEach(ie),c?.close(),f?.stop(),o.current=0}},c=[e,t,n],r[0]=t,r[1]=e,r[2]=n,r[3]=s,r[4]=c):(s=r[3],c=r[4]),(0,_.useEffect)(s,c),i}function ie(e){return e.stop()}function ae(){}function oe(e){return e.stop()}function se(e){let t=new Int16Array(e);if(!t.length)return 0;let n=0;for(let e of t)n+=(e/32768)**2;return Math.sqrt(n/t.length)}var ce=.004,le=4e3;function ue(e,t){let n=(0,p.c)(9),[r,i]=(0,_.useState)(!1),a=(0,_.useRef)(0),o;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>{a.current=Date.now(),i(!1)},n[0]=o):o=n[0];let s;n[1]===t?s=n[2]:(s=[t],n[1]=t,n[2]=s),(0,_.useEffect)(o,s);let c,l;n[3]===e?(c=n[4],l=n[5]):(c=()=>{e>ce&&(a.current=Date.now(),i(de))},l=[e],n[3]=e,n[4]=c,n[5]=l),(0,_.useEffect)(c,l);let u,d;return n[6]===t?(u=n[7],d=n[8]):(u=()=>{if(!t)return;let e=setInterval(()=>{Date.now()-a.current>le&&i(!0)},500);return()=>clearInterval(e)},d=[t],n[6]=t,n[7]=u,n[8]=d),(0,_.useEffect)(u,d),t&&r}function de(e){return e&&!1}export{X as _,re as a,d as b,N as c,w as d,T as f,U as g,K as h,ue as i,C as l,H as m,te as n,F as o,G as p,ne as r,P as s,$ as t,E as u,h as v,f as y};
|
package/dist/ui/assets/{useHiveAgentsModelLoad-Cd9p-bjs.js → useHiveAgentsModelLoad-nn4gON9g.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{f as t}from"./vendor-charts-K3xcRl0X.js";import{w as n}from"./index-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{f as t}from"./vendor-charts-K3xcRl0X.js";import{w as n}from"./index-C0W6p0lk.js";var r=e(t(),1),i=2500,a=48e4;function o(){let e=n(e=>e.loadHiveAgentsModel),t=n(e=>e.getHiveAgentsModelStatus),o=(0,r.useRef)(null);return{load:(0,r.useCallback)(async(n,r)=>{o.current&&(o.current.abort=!0);let s={abort:!1};o.current=s;let c=Date.now();try{await e(n,r)}catch{return!1}for(;!s.abort&&Date.now()-c<a;){try{let e=await t();if(e.loaded&&e.model?.name===n)return!0}catch{}await new Promise(e=>setTimeout(e,i))}return!1},[e,t]),cancel:(0,r.useCallback)(()=>{o.current&&=(o.current.abort=!0,null)},[])}}export{o as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./createLucideIcon-BRaPSYgN.js";import"./index-
|
|
1
|
+
import{t as e}from"./createLucideIcon-BRaPSYgN.js";import"./index-C0W6p0lk.js";var t=e(`Cpu`,[[`rect`,{width:`16`,height:`16`,x:`4`,y:`4`,rx:`2`,key:`14l7u7`}],[`rect`,{width:`6`,height:`6`,x:`9`,y:`9`,rx:`1`,key:`5aljv4`}],[`path`,{d:`M15 2v2`,key:`13l42r`}],[`path`,{d:`M15 20v2`,key:`15mkzm`}],[`path`,{d:`M2 15h2`,key:`1gxd5l`}],[`path`,{d:`M2 9h2`,key:`1bbxkp`}],[`path`,{d:`M20 15h2`,key:`19e6y8`}],[`path`,{d:`M20 9h2`,key:`19tzq7`}],[`path`,{d:`M9 2v2`,key:`165o2o`}],[`path`,{d:`M9 20v2`,key:`i2bqo8`}]]);export{t};
|
package/dist/ui/index.html
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
<meta name="twitter:title" content="Hive">
|
|
24
24
|
<meta property="og:description" content="Hive Agents">
|
|
25
25
|
<meta name="twitter:description" content="Hive Agents">
|
|
26
|
-
<script type="module" crossorigin src="/assets/index-
|
|
26
|
+
<script type="module" crossorigin src="/assets/index-C0W6p0lk.js"></script>
|
|
27
27
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-S-ySWqyJ.js">
|
|
28
28
|
<link rel="modulepreload" crossorigin href="/assets/vendor-charts-K3xcRl0X.js">
|
|
29
29
|
<link rel="modulepreload" crossorigin href="/assets/vendor-router-DSMCk-Ka.js">
|
package/package.json
CHANGED
|
@@ -209,8 +209,9 @@ const AVAILABLE_MODELS: Record<string, Array<{ value: string; label: string; hin
|
|
|
209
209
|
{ value: "MiniMax-M2.7", label: "MiniMax M2.7", hint: "200K contexto" },
|
|
210
210
|
],
|
|
211
211
|
hiveagents: [
|
|
212
|
-
{ value: "Qwen3.6-35B-A3B-UD-Q4_K_M.gguf", label: "Qwen3.6 35B MoE (Recomendado)", hint: "MoE 22.7GB — el más rápido: 62.7 t/s,
|
|
213
|
-
{ value: "Qwen3.8-27B-UD-
|
|
212
|
+
{ value: "Qwen3.6-35B-A3B-UD-Q4_K_M.gguf", label: "Qwen3.6 35B MoE (Recomendado)", hint: "MoE 22.7GB — el más rápido: 62.7 t/s, con visión" },
|
|
213
|
+
{ value: "Qwen3.8-27B-UD-Q6_K_XL.gguf", label: "Qwen3.8 27B Dense + MTP", hint: "Denso 25.9GB, con visión" },
|
|
214
|
+
{ value: "Qwen3.5-9B-UD-Q8_K_XL.gguf", label: "Qwen3.5 9B + MTP", hint: "Denso 13.2GB, ligero, con visión" },
|
|
214
215
|
{ value: "DeepSeek-V4-Flash-UD-IQ2_XXS-00001-of-00003.gguf", label: "DeepSeek V4 Flash 90 GB", hint: "MoE 90.9GB, sólo texto — 12.8 t/s y ~91s de carga" },
|
|
215
216
|
],
|
|
216
217
|
};
|
|
@@ -158,6 +158,7 @@ export const CORE_TOOL_CATALOG: ToolDescriptor[] = [
|
|
|
158
158
|
|
|
159
159
|
// Notifications/reporting
|
|
160
160
|
{ name: "notify", description: "Send system notification, alert user with message or alert. Spanish keywords: notificar, enviar notificación, alertar, aviso, alarma", category: "core", abstractionLevel: "atomic" },
|
|
161
|
+
{ name: "send_file", description: "Send a file (Word, Excel, PDF, image) to the user in the current chat, return a corrected document. Spanish keywords: enviar archivo, enviar documento, devolver archivo corregido, mandar excel, mandar word, mandar pdf", category: "core", abstractionLevel: "atomic" },
|
|
161
162
|
{ name: "report_progress", description: "Report progress to user, inform user of current status and completion. Spanish keywords: reportar progreso, informar estado, actualizar,报告进度, progreso", category: "core", abstractionLevel: "atomic" },
|
|
162
163
|
|
|
163
164
|
// Browser automation
|
|
@@ -256,6 +257,9 @@ export const CORE_TOOL_CATALOG: ToolDescriptor[] = [
|
|
|
256
257
|
{ name: "office_escribir_pdf", description: "Generate a PDF document. Spanish keywords: crear pdf, generar pdf, escribir pdf, exportar a pdf", category: "office", abstractionLevel: "atomic" },
|
|
257
258
|
{ name: "office_escribir_docx", description: "Generate a Word document. Spanish keywords: crear word, generar docx, escribir documento word, exportar a word", category: "office", abstractionLevel: "atomic" },
|
|
258
259
|
{ name: "office_escribir_xlsx", description: "Generate an Excel spreadsheet. Spanish keywords: crear excel, generar xlsx, escribir hoja de cálculo, exportar a excel, armar planilla", category: "office", abstractionLevel: "atomic" },
|
|
260
|
+
{ name: "office_editar_xlsx", description: "Edit an existing Excel file changing only given cells, keeping formatting; saves a copy. Spanish keywords: editar excel, corregir excel, modificar celdas, mejorar planilla", category: "office", abstractionLevel: "atomic" },
|
|
261
|
+
{ name: "office_editar_docx", description: "Edit an existing Word file: replace text and append paragraphs keeping styles; saves a copy. Spanish keywords: editar word, corregir word, reemplazar texto en documento, mejorar documento", category: "office", abstractionLevel: "atomic" },
|
|
262
|
+
{ name: "office_editar_pptx", description: "Edit an existing PowerPoint file replacing text in slides and notes, keeping design; saves a copy. Spanish keywords: editar powerpoint, corregir presentación, reemplazar texto en diapositivas, mejorar pptx", category: "office", abstractionLevel: "atomic" },
|
|
259
263
|
{ name: "office_escribir_pptx", description: "Generate a PowerPoint presentation. Spanish keywords: crear powerpoint, generar pptx, escribir presentación, armar diapositivas", category: "office", abstractionLevel: "atomic" },
|
|
260
264
|
]
|
|
261
265
|
|
|
@@ -14,7 +14,11 @@ import type { ArtifactDoc } from "../storage/collections";
|
|
|
14
14
|
|
|
15
15
|
const ARTIFACT_RETENTION_MS = 7 * 24 * 60 * 60 * 1000;
|
|
16
16
|
|
|
17
|
-
function extensionFor(mimeType: string): string {
|
|
17
|
+
function extensionFor(mimeType: string, hint?: string): string {
|
|
18
|
+
// Un adjunto del usuario conserva su extensión real (.docx, .xlsx, .pdf…): las
|
|
19
|
+
// tools office_leer_* deciden por extensión y un ".bin" no se abriría.
|
|
20
|
+
const clean = hint?.toLowerCase().replace(/^\./, "");
|
|
21
|
+
if (clean && /^[a-z0-9]{1,8}$/.test(clean)) return clean;
|
|
18
22
|
if (mimeType === "image/png") return "png";
|
|
19
23
|
if (mimeType === "image/jpeg") return "jpg";
|
|
20
24
|
if (mimeType === "image/webp") return "webp";
|
|
@@ -49,6 +53,8 @@ export async function createArtifact(input: {
|
|
|
49
53
|
runId?: string | null;
|
|
50
54
|
taskId?: string | null;
|
|
51
55
|
rootDir?: string;
|
|
56
|
+
/** Extensión original del archivo (sin punto), p. ej. "docx". */
|
|
57
|
+
extension?: string;
|
|
52
58
|
width?: number | null;
|
|
53
59
|
height?: number | null;
|
|
54
60
|
now?: number;
|
|
@@ -60,7 +66,7 @@ export async function createArtifact(input: {
|
|
|
60
66
|
const day = new Date(now).toISOString().slice(0, 10);
|
|
61
67
|
const dir = join(root, "artifacts", day);
|
|
62
68
|
mkdirSync(dir, { recursive: true });
|
|
63
|
-
const path = join(dir, `${id}.${extensionFor(mimeType)}`);
|
|
69
|
+
const path = join(dir, `${id}.${extensionFor(mimeType, input.extension)}`);
|
|
64
70
|
writeFileSync(path, input.bytes, { flag: "wx" });
|
|
65
71
|
|
|
66
72
|
const doc: ArtifactDoc = {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { readFileSync, existsSync } from "node:fs";
|
|
2
|
+
import { basename } from "node:path";
|
|
1
3
|
import { readArtifactBytes } from "../artifacts/store";
|
|
2
4
|
|
|
3
5
|
/**
|
|
@@ -17,6 +19,26 @@ export async function readOutboundImageBytes(
|
|
|
17
19
|
return null;
|
|
18
20
|
}
|
|
19
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Resuelve un OutboundMessage.document a bytes + nombre para los canales que
|
|
24
|
+
* suben el archivo directamente. Prefiere el artifact, luego la ruta en disco y
|
|
25
|
+
* al final el base64 en línea.
|
|
26
|
+
*/
|
|
27
|
+
export async function readOutboundDocument(
|
|
28
|
+
doc: NonNullable<OutboundMessage["document"]>,
|
|
29
|
+
): Promise<{ bytes: Buffer; filename: string; mimeType: string } | null> {
|
|
30
|
+
const filename = doc.filename || (doc.path ? basename(doc.path) : "documento");
|
|
31
|
+
if (doc.artifactId) {
|
|
32
|
+
const artifact = await readArtifactBytes(doc.artifactId);
|
|
33
|
+
if (artifact) return { bytes: artifact.bytes, filename, mimeType: doc.mimeType || artifact.mimeType };
|
|
34
|
+
}
|
|
35
|
+
if (doc.path && existsSync(doc.path)) {
|
|
36
|
+
return { bytes: readFileSync(doc.path), filename, mimeType: doc.mimeType || "application/octet-stream" };
|
|
37
|
+
}
|
|
38
|
+
if (doc.base64) return { bytes: Buffer.from(doc.base64, "base64"), filename, mimeType: doc.mimeType || "application/octet-stream" };
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
|
|
20
42
|
export interface OutboundMessage {
|
|
21
43
|
type: "message" | "stream" | "status" | "error" | "pong" | "command_result" | "log" | "typing" | "audio" | "process" | "progress" | "notification";
|
|
22
44
|
sessionId: string;
|
|
@@ -46,11 +68,15 @@ export interface OutboundMessage {
|
|
|
46
68
|
mimeType?: string;
|
|
47
69
|
caption?: string;
|
|
48
70
|
};
|
|
71
|
+
/** Archivo para el usuario (Word, Excel, PDF…). `artifactId` o `path` los leen los canales del servidor; `url` es para la web. */
|
|
49
72
|
document?: {
|
|
73
|
+
artifactId?: string;
|
|
74
|
+
path?: string;
|
|
50
75
|
url?: string;
|
|
51
76
|
base64?: string;
|
|
52
77
|
mimeType?: string;
|
|
53
78
|
filename?: string;
|
|
79
|
+
caption?: string;
|
|
54
80
|
};
|
|
55
81
|
status?: {
|
|
56
82
|
state: string;
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
type DMChannel,
|
|
8
8
|
type NewsChannel,
|
|
9
9
|
} from "discord.js";
|
|
10
|
-
import { BaseChannel, type ChannelConfig, type IncomingMessage, type OutboundMessage, readOutboundImageBytes } from "./base.ts";
|
|
10
|
+
import { BaseChannel, type ChannelConfig, type IncomingMessage, type OutboundMessage, readOutboundImageBytes, readOutboundDocument } from "./base.ts";
|
|
11
11
|
import { logger } from "../utils/logger.ts";
|
|
12
12
|
import { updateDoc } from "../storage/hive.ts";
|
|
13
13
|
import type { ChannelDoc } from "../storage/collections.ts";
|
|
@@ -101,7 +101,7 @@ export class DiscordChannel extends BaseChannel {
|
|
|
101
101
|
);
|
|
102
102
|
|
|
103
103
|
const documentAttachment = !audioAttachment && !imageAttachment
|
|
104
|
-
? message.attachments.find(a => a.contentType?.startsWith("application/") || a.
|
|
104
|
+
? message.attachments.find(a => a.contentType?.startsWith("application/") || a.contentType?.startsWith("text/") || /\.(pdf|docx?|xlsx?|xlsm|pptx?|csv|tsv|txt|md|json|rtf)(\?|$)/i.test(a.name ?? a.url))
|
|
105
105
|
: undefined;
|
|
106
106
|
|
|
107
107
|
const incomingMessage: IncomingMessage = {
|
|
@@ -224,6 +224,22 @@ export class DiscordChannel extends BaseChannel {
|
|
|
224
224
|
}
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
+
if (message.document) {
|
|
228
|
+
try {
|
|
229
|
+
const doc = await readOutboundDocument(message.document);
|
|
230
|
+
if (doc) {
|
|
231
|
+
await channel.send({
|
|
232
|
+
content: message.document.caption,
|
|
233
|
+
files: [{ attachment: doc.bytes, name: doc.filename }],
|
|
234
|
+
});
|
|
235
|
+
} else {
|
|
236
|
+
this.log.warn(`Document unavailable, skipping file send`, { sessionId });
|
|
237
|
+
}
|
|
238
|
+
} catch (error) {
|
|
239
|
+
this.log.error(`Failed to send Discord document: ${(error as Error).message}`);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
227
243
|
const content = message.content ?? "";
|
|
228
244
|
const maxLength = 2000;
|
|
229
245
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { App, ExpressReceiver, type SlashCommand } from "@slack/bolt";
|
|
2
2
|
import type { ChannelConfig, IncomingMessage, OutboundMessage } from "./base.ts";
|
|
3
|
-
import { BaseChannel, readOutboundImageBytes } from "./base.ts";
|
|
3
|
+
import { BaseChannel, readOutboundImageBytes, readOutboundDocument } from "./base.ts";
|
|
4
4
|
import { logger } from "../utils/logger.ts";
|
|
5
5
|
import { updateDoc } from "../storage/hive.ts";
|
|
6
6
|
import type { ChannelDoc } from "../storage/collections.ts";
|
|
@@ -18,6 +18,13 @@ export interface SlackConnectionState {
|
|
|
18
18
|
error?: string;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
const DOCUMENT_EXTENSIONS = /\.(pdf|docx?|xlsx?|xlsm|pptx?|csv|tsv|txt|md|json|rtf)$/i;
|
|
22
|
+
|
|
23
|
+
/** Qué cuenta como documento: cualquier application/*, text/* o una extensión de oficina conocida. */
|
|
24
|
+
function isDocumentFile(f: { mimetype?: string; name?: string }): boolean {
|
|
25
|
+
return !!(f.mimetype?.startsWith("application/") || f.mimetype?.startsWith("text/") || (f.name && DOCUMENT_EXTENSIONS.test(f.name)));
|
|
26
|
+
}
|
|
27
|
+
|
|
21
28
|
export class SlackChannel extends BaseChannel {
|
|
22
29
|
name = "slack";
|
|
23
30
|
accountId: string;
|
|
@@ -129,6 +136,13 @@ export class SlackChannel extends BaseChannel {
|
|
|
129
136
|
} catch { /* ignore DB errors */ }
|
|
130
137
|
}
|
|
131
138
|
|
|
139
|
+
/** Los archivos de Slack (url_private) solo se descargan con el token del bot: sin él devuelven una página de login. */
|
|
140
|
+
private async downloadPrivateFile(url: string): Promise<Buffer> {
|
|
141
|
+
const res = await fetch(url, { headers: { Authorization: `Bearer ${this.config.botToken}` }, signal: AbortSignal.timeout(60_000) });
|
|
142
|
+
if (!res.ok) throw new Error(`Slack no entregó el archivo (HTTP ${res.status})`);
|
|
143
|
+
return Buffer.from(await res.arrayBuffer());
|
|
144
|
+
}
|
|
145
|
+
|
|
132
146
|
private async handleMention(event: { user?: string; text?: string; channel?: string; ts?: string; files?: Array<{ url_private?: string; mimetype?: string; name?: string }> }): Promise<void> {
|
|
133
147
|
if (!event.user || !event.channel) return;
|
|
134
148
|
|
|
@@ -149,7 +163,7 @@ f.name?.endsWith(".png") || f.name?.endsWith(".gif") || f.name?.endsWith(".webp"
|
|
|
149
163
|
);
|
|
150
164
|
|
|
151
165
|
const docFile = !audioFile && !imageFile
|
|
152
|
-
? event.files?.find(f =>
|
|
166
|
+
? event.files?.find(f => isDocumentFile(f))
|
|
153
167
|
: undefined;
|
|
154
168
|
|
|
155
169
|
const incoming: IncomingMessage = {
|
|
@@ -160,8 +174,8 @@ peerId: event.channel,
|
|
|
160
174
|
peerKind: "group",
|
|
161
175
|
content,
|
|
162
176
|
audio: audioFile?.url_private ? { url: audioFile.url_private, mimeType: audioFile.mimetype || "audio/webm" } : undefined,
|
|
163
|
-
image: imageFile?.url_private ? {
|
|
164
|
-
document: docFile?.url_private ? {
|
|
177
|
+
image: imageFile?.url_private ? { buffer: await this.downloadPrivateFile(imageFile.url_private), mimeType: imageFile.mimetype || "image/png" } : undefined,
|
|
178
|
+
document: docFile?.url_private ? { buffer: await this.downloadPrivateFile(docFile.url_private), mimeType: docFile.mimetype || "application/octet-stream", fileName: docFile.name } : undefined,
|
|
165
179
|
metadata: {
|
|
166
180
|
userId: event.user,
|
|
167
181
|
timestamp: event.ts,
|
|
@@ -191,7 +205,7 @@ f.name?.endsWith(".png") || f.name?.endsWith(".gif") || f.name?.endsWith(".webp"
|
|
|
191
205
|
);
|
|
192
206
|
|
|
193
207
|
const docFile = !audioFile && !imageFile
|
|
194
|
-
? event.files?.find(f =>
|
|
208
|
+
? event.files?.find(f => isDocumentFile(f))
|
|
195
209
|
: undefined;
|
|
196
210
|
|
|
197
211
|
const incoming: IncomingMessage = {
|
|
@@ -202,8 +216,8 @@ peerId: event.user,
|
|
|
202
216
|
peerKind: "direct",
|
|
203
217
|
content: event.text || "",
|
|
204
218
|
audio: audioFile?.url_private ? { url: audioFile.url_private, mimeType: audioFile.mimetype || "audio/webm" } : undefined,
|
|
205
|
-
image: imageFile?.url_private ? {
|
|
206
|
-
document: docFile?.url_private ? {
|
|
219
|
+
image: imageFile?.url_private ? { buffer: await this.downloadPrivateFile(imageFile.url_private), mimeType: imageFile.mimetype || "image/png" } : undefined,
|
|
220
|
+
document: docFile?.url_private ? { buffer: await this.downloadPrivateFile(docFile.url_private), mimeType: docFile.mimetype || "application/octet-stream", fileName: docFile.name } : undefined,
|
|
207
221
|
metadata: {
|
|
208
222
|
channel: event.channel,
|
|
209
223
|
timestamp: event.ts,
|
|
@@ -280,6 +294,22 @@ await this.handleMessage(incoming);
|
|
|
280
294
|
}
|
|
281
295
|
}
|
|
282
296
|
|
|
297
|
+
if (message.document) {
|
|
298
|
+
try {
|
|
299
|
+
const doc = await readOutboundDocument(message.document);
|
|
300
|
+
if (doc) {
|
|
301
|
+
await this.app.client.files.uploadV2({
|
|
302
|
+
channel_id: peerId, file: doc.bytes, filename: doc.filename,
|
|
303
|
+
title: message.document.caption ?? doc.filename,
|
|
304
|
+
});
|
|
305
|
+
} else {
|
|
306
|
+
this.log.warn(`Document unavailable, skipping file send`, { sessionId });
|
|
307
|
+
}
|
|
308
|
+
} catch (error) {
|
|
309
|
+
this.log.error(`Failed to send Slack document: ${(error as Error).message}`);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
283
313
|
const text = message.content ?? message.chunk ?? "";
|
|
284
314
|
if (!text) return;
|
|
285
315
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Bot, GrammyError, InputFile, type Context } from "grammy";
|
|
2
|
-
import { BaseChannel, type ChannelConfig, type IncomingMessage, type OutboundMessage, readOutboundImageBytes } from "./base.ts";
|
|
2
|
+
import { BaseChannel, type ChannelConfig, type IncomingMessage, type OutboundMessage, readOutboundImageBytes, readOutboundDocument } from "./base.ts";
|
|
3
3
|
import { logger } from "../utils/logger.ts";
|
|
4
4
|
import { col, updateDoc } from "../storage/hive.ts";
|
|
5
5
|
import type { ChannelDoc, UserIdentityDoc } from "../storage/collections.ts";
|
|
@@ -10,6 +10,9 @@ export interface TelegramConfig extends ChannelConfig {
|
|
|
10
10
|
groups?: boolean;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
/** Límite de getFile para bots: https://core.telegram.org/bots/api#getfile */
|
|
14
|
+
const TELEGRAM_BOT_DOWNLOAD_LIMIT = 20 * 1024 * 1024;
|
|
15
|
+
|
|
13
16
|
export class TelegramChannel extends BaseChannel {
|
|
14
17
|
name = "telegram";
|
|
15
18
|
accountId: string;
|
|
@@ -230,6 +233,8 @@ export class TelegramChannel extends BaseChannel {
|
|
|
230
233
|
}
|
|
231
234
|
} catch (err) {
|
|
232
235
|
this.log.warn(`Failed to download photo: ${(err as Error).message}`);
|
|
236
|
+
await ctx.reply(`⚠️ No pude descargar la imagen: ${(err as Error).message}. Inténtalo de nuevo.`);
|
|
237
|
+
return;
|
|
233
238
|
}
|
|
234
239
|
content = caption || "";
|
|
235
240
|
}
|
|
@@ -288,19 +293,27 @@ export class TelegramChannel extends BaseChannel {
|
|
|
288
293
|
const docName = (message.document as any).file_name ?? "documento";
|
|
289
294
|
const caption = message.caption ?? "";
|
|
290
295
|
contentType = "document";
|
|
296
|
+
// La Bot API de Telegram solo deja descargar archivos de hasta 20 MB (getFile).
|
|
297
|
+
if ((message.document.file_size ?? 0) > TELEGRAM_BOT_DOWNLOAD_LIMIT) {
|
|
298
|
+
await ctx.reply(
|
|
299
|
+
`⚠️ «${docName}» pesa ${((message.document.file_size ?? 0) / 1048576).toFixed(1)} MB y Telegram solo permite que un bot descargue archivos de hasta 20 MB. ` +
|
|
300
|
+
`Envíalo comprimido o más liviano, o súbelo por el chat web.`,
|
|
301
|
+
);
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
291
304
|
try {
|
|
292
|
-
if (this.bot)
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
}
|
|
301
|
-
}
|
|
305
|
+
if (!this.bot) throw new Error("el bot no está conectado");
|
|
306
|
+
const file = await this.bot.api.getFile(message.document.file_id);
|
|
307
|
+
if (!file.file_path) throw new Error("Telegram no devolvió la ruta del archivo");
|
|
308
|
+
document_ = {
|
|
309
|
+
url: `https://api.telegram.org/file/bot${this.config.botToken}/${file.file_path}`,
|
|
310
|
+
mimeType: message.document.mime_type || "application/octet-stream",
|
|
311
|
+
fileName: docName,
|
|
312
|
+
};
|
|
302
313
|
} catch (err) {
|
|
303
314
|
this.log.warn(`Failed to download document: ${(err as Error).message}`);
|
|
315
|
+
await ctx.reply(`⚠️ No pude descargar «${docName}»: ${(err as Error).message}. Inténtalo de nuevo.`);
|
|
316
|
+
return;
|
|
304
317
|
}
|
|
305
318
|
content = caption || "";
|
|
306
319
|
}
|
|
@@ -437,6 +450,21 @@ export class TelegramChannel extends BaseChannel {
|
|
|
437
450
|
}
|
|
438
451
|
}
|
|
439
452
|
|
|
453
|
+
if (message.document) {
|
|
454
|
+
try {
|
|
455
|
+
const doc = await readOutboundDocument(message.document);
|
|
456
|
+
if (doc) {
|
|
457
|
+
await this.bot.api.sendDocument(chatId, new InputFile(doc.bytes, doc.filename), {
|
|
458
|
+
caption: message.document.caption,
|
|
459
|
+
});
|
|
460
|
+
} else {
|
|
461
|
+
this.log.warn(`Document unavailable, skipping file send`, { sessionId });
|
|
462
|
+
}
|
|
463
|
+
} catch (error) {
|
|
464
|
+
this.log.error(`Telegram sendDocument failed: ${(error as Error).message}`);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
|
|
440
468
|
const content = message.content ?? "";
|
|
441
469
|
|
|
442
470
|
if (!content || content.trim().length === 0) {
|
|
@@ -8,7 +8,7 @@ import makeWASocket, {
|
|
|
8
8
|
type WAMessage,
|
|
9
9
|
} from "@whiskeysockets/baileys";
|
|
10
10
|
import type { ChannelConfig, IncomingMessage, OutboundMessage } from "./base.ts";
|
|
11
|
-
import { BaseChannel, readOutboundImageBytes } from "./base.ts";
|
|
11
|
+
import { BaseChannel, readOutboundImageBytes, readOutboundDocument } from "./base.ts";
|
|
12
12
|
import { existsSync, mkdirSync, rmSync } from "node:fs";
|
|
13
13
|
import * as path from "node:path";
|
|
14
14
|
import { homedir } from "node:os";
|
|
@@ -503,6 +503,21 @@ export class WhatsAppChannel extends BaseChannel {
|
|
|
503
503
|
}
|
|
504
504
|
}
|
|
505
505
|
|
|
506
|
+
if (message.document) {
|
|
507
|
+
try {
|
|
508
|
+
const doc = await readOutboundDocument(message.document);
|
|
509
|
+
if (doc) {
|
|
510
|
+
await this.socket.sendMessage(jid, {
|
|
511
|
+
document: doc.bytes, fileName: doc.filename, mimetype: doc.mimeType, caption: message.document.caption,
|
|
512
|
+
});
|
|
513
|
+
} else {
|
|
514
|
+
this.log.warn(`Document unavailable, skipping file send`, { sessionId });
|
|
515
|
+
}
|
|
516
|
+
} catch (error) {
|
|
517
|
+
this.log.error(`Failed to send WhatsApp document: ${(error as Error).message}`);
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
|
|
506
521
|
const text = message.content ?? message.chunk ?? "";
|
|
507
522
|
if (!text) return;
|
|
508
523
|
|
|
@@ -23,7 +23,27 @@ type SendFn = (
|
|
|
23
23
|
metadata?: { notificationId?: string; accountId?: string },
|
|
24
24
|
) => Promise<void>
|
|
25
25
|
|
|
26
|
+
export interface OutboundFile {
|
|
27
|
+
artifactId: string
|
|
28
|
+
filename: string
|
|
29
|
+
mimeType: string
|
|
30
|
+
caption?: string
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
type SendFileFn = (
|
|
34
|
+
channel: string,
|
|
35
|
+
sessionId: string,
|
|
36
|
+
file: OutboundFile,
|
|
37
|
+
metadata?: { accountId?: string },
|
|
38
|
+
) => Promise<void>
|
|
39
|
+
|
|
26
40
|
let _sendFn: SendFn | null = null
|
|
41
|
+
let _sendFileFn: SendFileFn | null = null
|
|
42
|
+
|
|
43
|
+
/** Llamar en server.ts junto a setChannelSendFn: permite que la tool send_file entregue archivos. */
|
|
44
|
+
export function setChannelFileFn(fn: SendFileFn): void {
|
|
45
|
+
_sendFileFn = fn
|
|
46
|
+
}
|
|
27
47
|
|
|
28
48
|
/** Llamar en server.ts una vez que channelManager esté listo */
|
|
29
49
|
export function setChannelSendFn(fn: SendFn): void {
|
|
@@ -113,3 +133,25 @@ export async function sendToUserChannel(
|
|
|
113
133
|
return { ok: false, error: (err as Error).message }
|
|
114
134
|
}
|
|
115
135
|
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Entrega un archivo (Word, Excel, PDF…) al chat desde el que escribió el usuario.
|
|
139
|
+
* Misma resolución de destino que sendToUserChannel; sin socket vivo no hay cola
|
|
140
|
+
* (a diferencia del texto), así que un fallo se devuelve para que el agente avise.
|
|
141
|
+
*/
|
|
142
|
+
export async function sendFileToUserChannel(
|
|
143
|
+
channel: string,
|
|
144
|
+
userId: string,
|
|
145
|
+
file: OutboundFile,
|
|
146
|
+
opts?: { threadId?: string },
|
|
147
|
+
): Promise<{ ok: boolean; error?: string }> {
|
|
148
|
+
if (!_sendFileFn) return { ok: false, error: "El envío de archivos no está inicializado" }
|
|
149
|
+
const { sessionId, accountId } = await resolveSession(userId, channel, opts?.threadId)
|
|
150
|
+
try {
|
|
151
|
+
await _sendFileFn(channel, sessionId, file, { accountId })
|
|
152
|
+
return { ok: true }
|
|
153
|
+
} catch (err) {
|
|
154
|
+
log.warn(`[channel-notify] Falló el envío de archivo: ${(err as Error).message}`)
|
|
155
|
+
return { ok: false, error: (err as Error).message }
|
|
156
|
+
}
|
|
157
|
+
}
|
|
@@ -36,6 +36,7 @@ export async function handleDownloadArtifact(
|
|
|
36
36
|
return addCorsHeaders(Response.json({ ok: false, error: "Artifact not found" }, { status: 404 }), req);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
const downloadName = new URL(req.url).searchParams.get("name")?.replace(/[\\/\0\r\n]/g, "_").slice(0, 200);
|
|
39
40
|
const file = Bun.file(entry.doc.path);
|
|
40
41
|
if (!(await file.exists())) {
|
|
41
42
|
return addCorsHeaders(Response.json({ ok: false, error: "Artifact binary is missing" }, { status: 404 }), req);
|
|
@@ -59,6 +60,9 @@ export async function handleDownloadArtifact(
|
|
|
59
60
|
"Cache-Control": "private, max-age=3600",
|
|
60
61
|
ETag: etag,
|
|
61
62
|
"Accept-Ranges": "bytes",
|
|
63
|
+
...(downloadName
|
|
64
|
+
? { "Content-Disposition": `attachment; filename*=UTF-8''${encodeURIComponent(downloadName)}` }
|
|
65
|
+
: {}),
|
|
62
66
|
},
|
|
63
67
|
}),
|
|
64
68
|
req,
|
|
@@ -80,3 +80,22 @@ export async function handleOcrImage(req: Request, addCorsHeaders: (r: Response,
|
|
|
80
80
|
return addCorsHeaders(Response.json({ success: false, error: (error as Error).message }, { status: 500 }), req)
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
+
|
|
84
|
+
export async function handleGetVisionAnalyzer(req: Request, addCorsHeaders: (r: Response, req: Request) => Response): Promise<Response> {
|
|
85
|
+
const { getVisionAnalyzerModelId } = await import("../../multimodal/vision-analyzer")
|
|
86
|
+
return addCorsHeaders(Response.json({ modelId: await getVisionAnalyzerModelId() }), req)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export async function handleSetVisionAnalyzer(req: Request, addCorsHeaders: (r: Response, req: Request) => Response): Promise<Response> {
|
|
90
|
+
const body = await req.json().catch(() => ({})) as { modelId?: string | null }
|
|
91
|
+
if (body.modelId !== null && typeof body.modelId !== "string") {
|
|
92
|
+
return addCorsHeaders(Response.json({ success: false, error: "modelId debe ser un id o null" }, { status: 400 }), req)
|
|
93
|
+
}
|
|
94
|
+
const { setVisionAnalyzerModelId, getVisionAnalyzerModelId } = await import("../../multimodal/vision-analyzer")
|
|
95
|
+
try {
|
|
96
|
+
await setVisionAnalyzerModelId(body.modelId || null)
|
|
97
|
+
} catch (err) {
|
|
98
|
+
return addCorsHeaders(Response.json({ success: false, error: (err as Error).message }, { status: 400 }), req)
|
|
99
|
+
}
|
|
100
|
+
return addCorsHeaders(Response.json({ success: true, modelId: await getVisionAnalyzerModelId() }), req)
|
|
101
|
+
}
|