@johpaz/hive-agents 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -9
- package/dist/hive.js +2925 -1871
- package/dist/ui/assets/{A2UIPage-CS0VPY6a.js → A2UIPage-BOR7GzYi.js} +1 -1
- package/dist/ui/assets/{AgentCreateForm-DXkjtXaS.js → AgentCreateForm-Btza1Kiv.js} +1 -1
- package/dist/ui/assets/{AgentDetailPage-DUIX_cuQ.js → AgentDetailPage-D435IX8G.js} +1 -1
- package/dist/ui/assets/{AgentNewPage-SNXz2wik.js → AgentNewPage-DvP05Ap5.js} +1 -1
- package/dist/ui/assets/{AgentsPage-CGsdgx5F.js → AgentsPage-BT9CssIN.js} +1 -1
- package/dist/ui/assets/{ApiClientPage-MNMjfSDs.js → ApiClientPage-Cmo0XBwk.js} +1 -1
- package/dist/ui/assets/{ChannelsPage-BEwxWUcE.js → ChannelsPage-C53NCtXi.js} +1 -1
- package/dist/ui/assets/{DashboardPage-D6cRFKWW.js → DashboardPage-DpI54Ot0.js} +1 -1
- package/dist/ui/assets/{LoginPage-ByYmIa2p.js → LoginPage-CTc-MbtG.js} +1 -1
- package/dist/ui/assets/{LogsPage-Bmk9rohg.js → LogsPage-D-2DgTQh.js} +1 -1
- package/dist/ui/assets/{MeetingPage-Dm97Mbiw.js → MeetingPage-B8Xb1z_0.js} +1 -1
- package/dist/ui/assets/{ModelSelector-gubC8j_Q.js → ModelSelector-BcaASPWF.js} +1 -1
- package/dist/ui/assets/Office3DPage-6bDnybWI.js +727 -0
- package/dist/ui/assets/ProvidersPage-CVK-nKxE.js +1 -0
- package/dist/ui/assets/{RecoverPage-YY2QU-qh.js → RecoverPage-UL782VIG.js} +1 -1
- package/dist/ui/assets/SettingsPage-CHJfutPk.js +9 -0
- package/dist/ui/assets/{SetupPage-LXnd2XbV.js → SetupPage-B_fXVcuJ.js} +1 -1
- package/dist/ui/assets/{Vignette-BcPWkNhm.js → Vignette-bSrGVyRd.js} +1 -1
- package/dist/ui/assets/{VoicePage-uLWdtoD4.css → VoicePage-CADecxhn.css} +1 -1
- package/dist/ui/assets/VoicePage-CdBZrLAm.js +307 -0
- package/dist/ui/assets/{WebChatPage-B61ZDjQ8.js → WebChatPage-D8KsJqMf.js} +1 -1
- package/dist/ui/assets/{bia-BFcUpOu3.glb → bia-csMImkVQ.glb} +0 -0
- package/dist/ui/assets/{conversationsStore-BlwA3yd2.js → conversationsStore-8WwqUOpe.js} +1 -1
- package/dist/ui/assets/{dialog-B04KpdNt.js → dialog-DcgGvP2g.js} +1 -1
- package/dist/ui/assets/headworklet.min-Bi87kUoI.mjs +1 -0
- package/dist/ui/assets/{index-DKJFLL3a.js → index-C5Hhusqq.js} +2 -2
- package/dist/ui/assets/index-DmFPF9xQ.css +2 -0
- package/dist/ui/assets/model-en-mixed-CfUSaeKF.bin +0 -0
- package/dist/ui/assets/useAudioDevices-BO-kUbtK.js +41 -0
- package/dist/ui/assets/{useHiveAgentsModelLoad-B4EjHvj4.js → useHiveAgentsModelLoad-IOqfYcrC.js} +1 -1
- package/dist/ui/assets/{useProviders-B1NS24md.js → useProviders-DsFqfiyM.js} +1 -1
- package/dist/ui/index.html +2 -2
- package/package.json +2 -2
- package/packages/cli/src/commands/onboard.ts +1 -1
- package/packages/core/src/agent/acceptance-checks.ts +25 -0
- package/packages/core/src/agent/agent-catalog.ts +23 -3
- package/packages/core/src/agent/jev-decisions.ts +125 -31
- package/packages/core/src/agent/jev-planner.ts +3 -3
- package/packages/core/src/agent/tool-selector.ts +41 -0
- package/packages/core/src/gateway/routes/providers.ts +4 -4
- package/packages/core/src/storage/bootstrap.ts +1 -1
- package/packages/core/src/storage/crypto.ts +110 -28
- package/packages/core/src/storage/seed.ts +38 -0
- package/packages/core/src/tools/code-agent/adapters.ts +110 -0
- package/packages/core/src/tools/code-agent/index.ts +193 -0
- package/packages/core/src/tools/index.ts +8 -0
- package/packages/core/src/tools/web/browser-backend.ts +22 -2
- package/packages/core/src/tools/web/index.ts +4 -0
- package/packages/core/src/tools/web/obscura.ts +860 -0
- package/packages/core/src/tools/web/webview-backend.ts +28 -6
- package/packages/skills/src/bundled/cli/external_code_agent/SKILL.md +69 -0
- package/packages/skills/src/bundled/web/obscura_browser/SKILL.md +69 -0
- package/packages/skills/src/bundled-data.generated.ts +837 -819
- package/dist/ui/assets/Office3DPage-Bfi-S2kG.js +0 -727
- package/dist/ui/assets/ProvidersPage-CSo0MYxd.js +0 -1
- package/dist/ui/assets/SettingsPage-DrafhhKw.js +0 -9
- package/dist/ui/assets/VoicePage-p-hTMAq7.js +0 -307
- package/dist/ui/assets/index-ByTufXPh.css +0 -2
- package/dist/ui/assets/useAudioDevices-B2stUHvr.js +0 -41
- /package/dist/ui/assets/{agentCapabilities-PfTEVxG1.js → agentCapabilities-CDSfJWhw.js} +0 -0
- /package/dist/ui/assets/{pause-Cm9LzIZK.js → pause-BAMsNQkh.js} +0 -0
- /package/dist/ui/assets/{pencil-L3Li7_pz.js → pencil-CKritjT_.js} +0 -0
- /package/dist/ui/assets/{play-zqogwA2l.js → play-Cwpe4tp6.js} +0 -0
- /package/dist/ui/assets/{plus-Bm08ABhc.js → plus-RD44ce15.js} +0 -0
- /package/dist/ui/assets/{radio-Cii1BjMt.js → radio-lFPMHi6-.js} +0 -0
- /package/dist/ui/assets/{refresh-cw-DXv3XgEt.js → refresh-cw-DtJMHRHO.js} +0 -0
- /package/dist/ui/assets/{rotate-ccw-LoM1AuqK.js → rotate-ccw-b3E_4PoX.js} +0 -0
- /package/dist/ui/assets/{search-BMwCI-pX.js → search-z2oZt00P.js} +0 -0
- /package/dist/ui/assets/{send-D6fgWV7m.js → send-CpoY_2F-.js} +0 -0
|
@@ -0,0 +1,41 @@
|
|
|
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{t as r}from"./createLucideIcon-BRaPSYgN.js";import{u as i}from"./vendor-router-DP84b3LQ.js";import{n as a,r as o}from"./gateway-url-BALS_wVh.js";import{o as s}from"./index-C5Hhusqq.js";import{t as c}from"./conversationsStore-8WwqUOpe.js";var l=r(`Minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),u=r(`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`}]]),d=e(t(),1),f=n();function p(){return typeof AudioContext<`u`&&`setSinkId`in AudioContext.prototype}async function m(){return g(`audioinput`)}async function h(){if(p()){let e=await g(`audiooutput`);return{lista:e,motivo:e.length?null:`El navegador todavía no reporta salidas. Concede el permiso de micrófono y vuelve a abrir esta pantalla.`}}if(!s())return{lista:[],motivo:`Este navegador no deja elegir la salida: se usa la del sistema.`};try{let{invoke:e}=await i(async()=>{let{invoke:e}=await import(`./core-B_5cyOSV.js`);return{invoke:e}},[]),t=await e(`audio_outputs`);return{lista:t,motivo:t.length?null:`El sistema no reportó ninguna salida de audio.`}}catch(e){return{lista:[],motivo:e?.message??String(e)}}}async function g(e){try{let t=(await navigator.mediaDevices.enumerateDevices()).filter(t=>t.kind===e),n=t.find(e=>e.deviceId===`default`)?.groupId;return t.filter(e=>e.deviceId!==`default`&&e.deviceId!==`communications`&&e.deviceId).map((t,r)=>({id:t.deviceId,nombre:t.label||`${e===`audioinput`?`Micrófono`:`Salida`} ${r+1}`,porDefecto:!!n&&t.groupId===n}))}catch{return[]}}async function _(e,t){if(p()){let n=t;return n?.setSinkId?(await n.setSinkId(e),!0):!1}if(!s())return!1;let{invoke:n}=await i(async()=>{let{invoke:e}=await import(`./core-B_5cyOSV.js`);return{invoke:e}},[]);return await n(`set_audio_output`,{id:e})>0}function v(e){let t=e.split(`|`)[1]??``;return/headphone|headset|hf-output/.test(t)?!1:/hdmi|speaker|spdif|tv|line-out/.test(t)}var y=16e3,b=24e3,x=640,S=`
|
|
2
|
+
class PCMCapture extends AudioWorkletProcessor {
|
|
3
|
+
constructor(options) {
|
|
4
|
+
super();
|
|
5
|
+
this.target = options.processorOptions.targetRate;
|
|
6
|
+
this.frame = options.processorOptions.frameSamples;
|
|
7
|
+
this.ratio = sampleRate / this.target;
|
|
8
|
+
this.acc = [];
|
|
9
|
+
this.pos = 0;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
process(inputs) {
|
|
13
|
+
const input = inputs[0] && inputs[0][0];
|
|
14
|
+
if (!input) return true;
|
|
15
|
+
|
|
16
|
+
// Remuestreo lineal al vuelo: el navegador no siempre concede el sampleRate
|
|
17
|
+
// pedido (WebKitGTK, por ejemplo, entrega el del dispositivo).
|
|
18
|
+
while (this.pos < input.length) {
|
|
19
|
+
const idx = Math.floor(this.pos);
|
|
20
|
+
const frac = this.pos - idx;
|
|
21
|
+
const a = input[idx];
|
|
22
|
+
const b = idx + 1 < input.length ? input[idx + 1] : a;
|
|
23
|
+
this.acc.push(a + (b - a) * frac);
|
|
24
|
+
this.pos += this.ratio;
|
|
25
|
+
|
|
26
|
+
if (this.acc.length >= this.frame) {
|
|
27
|
+
const pcm = new Int16Array(this.acc.length);
|
|
28
|
+
for (let i = 0; i < this.acc.length; i++) {
|
|
29
|
+
const s = Math.max(-1, Math.min(1, this.acc[i]));
|
|
30
|
+
pcm[i] = s < 0 ? s * 0x8000 : s * 0x7fff;
|
|
31
|
+
}
|
|
32
|
+
this.port.postMessage(pcm.buffer, [pcm.buffer]);
|
|
33
|
+
this.acc = [];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
this.pos -= input.length;
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
registerProcessor('pcm-capture', PCMCapture);
|
|
41
|
+
`,C=700,w=4e3,T=class{bins=new Uint8Array(128);analyser=null;raw=null;smoothedLevel=0;attach(e,t){let n=e.createAnalyser();return n.fftSize=512,n.smoothingTimeConstant=.72,n.minDecibels=-85,n.maxDecibels=-12,t.connect(n),this.analyser=n,this.raw=new Uint8Array(new ArrayBuffer(n.frequencyBinCount)),n}sample(){if(!this.analyser||!this.raw)return 0;this.analyser.getByteFrequencyData(this.raw);let e=Math.floor(this.raw.length*.62),t=0;for(let n=0;n<128;n++){let r=n/127,i=Math.min(e-1,Math.round(r**1.6*(e-1))),a=this.raw[i]??0;this.bins[n]=a,t+=a}let n=Math.min(1,t/32640*3.2);return this.smoothedLevel=n>this.smoothedLevel?this.smoothedLevel+(n-this.smoothedLevel)*.55:this.smoothedLevel+(n-this.smoothedLevel)*.12,this.smoothedLevel}detach(){try{this.analyser?.disconnect()}catch{}this.analyser=null,this.raw=null,this.bins.fill(0),this.smoothedLevel=0}},E=class{onFrame;deviceId;context=null;stream=null;node=null;source=null;spectrum=new T;constructor(e,t=null){this.onFrame=e,this.deviceId=t}async start(){this.stream=await O(this.deviceId),this.context=new AudioContext({sampleRate:y});let e=new Blob([S],{type:`application/javascript`}),t=URL.createObjectURL(e);try{await this.context.audioWorklet.addModule(t)}finally{URL.revokeObjectURL(t)}this.node=new AudioWorkletNode(this.context,`pcm-capture`,{numberOfInputs:1,numberOfOutputs:0,processorOptions:{targetRate:y,frameSamples:x}}),this.node.port.onmessage=e=>this.onFrame(e.data),this.source=this.context.createMediaStreamSource(this.stream),this.source.connect(this.node),this.spectrum.attach(this.context,this.source),this.context.state!==`running`&&this.context.resume().catch(()=>{})}stop(){this.spectrum.detach(),this.node?.port.close(),this.node?.disconnect(),this.source?.disconnect(),this.stream?.getTracks().forEach(e=>e.stop()),this.context?.close(),this.node=null,this.source=null,this.stream=null,this.context=null}},D=class{context=null;nextStartAt=0;playing=new Set;bus=null;spectrum=new T;onIdle;get lipsyncSource(){return this.context&&this.bus?{context:this.context,node:this.bus}:null}hablaHasta=0;salidaId=null;salidaLista=!1;aplicandoSalida=!1;ultimoIntento=0;async resume(){this.context||(this.context=new AudioContext,this.bus=this.context.createGain(),this.bus.connect(this.context.destination),this.spectrum.attach(this.context,this.bus),this.context.addEventListener(`statechange`,()=>this.despertar())),this.context.state===`suspended`?await this.context.resume():this.despertar()}despertar(){let e=this.context;!e||e.state===`running`||e.state===`closed`||e.resume().catch(()=>{})}async usarSalida(e){this.salidaId=e,this.salidaLista=!1,this.ultimoIntento=0,await this.encaminar()}async encaminar(){if(!this.salidaId||this.salidaLista||this.aplicandoSalida)return;let e=Date.now();if(!(e-this.ultimoIntento<900)){this.ultimoIntento=e,this.aplicandoSalida=!0;try{this.salidaLista=await _(this.salidaId,this.context)}catch{}finally{this.aplicandoSalida=!1}}}enqueue(e){if(!this.context||!this.bus)return;this.encaminar();let t=new Int16Array(e);if(!t.length)return;let n=this.context.createBuffer(1,t.length,b),r=n.getChannelData(0);for(let e=0;e<t.length;e++)r[e]=t[e]/32768;let i=this.context.createBufferSource();i.buffer=n,i.connect(this.bus);let a=this.context.currentTime,o=Math.max(a+.02,this.nextStartAt);i.start(o),this.nextStartAt=o+n.duration;let s=Math.min(w,Math.max(0,(this.nextStartAt-a)*1e3));this.hablaHasta=Math.max(this.hablaHasta,Date.now()+s+C),this.playing.add(i),i.onended=()=>{this.playing.delete(i),this.playing.size||this.onIdle?.()}}async probar(){if(await this.resume(),!this.context||!this.bus)return;this.encaminar();let e=this.context.currentTime+.05;for(let[t,n]of[660,990].entries()){let r=this.context.createOscillator(),i=this.context.createGain();r.type=`sine`,r.frequency.value=n;let a=e+t*.18;i.gain.setValueAtTime(0,a),i.gain.linearRampToValueAtTime(.16,a+.02),i.gain.setValueAtTime(.16,a+.12),i.gain.linearRampToValueAtTime(0,a+.17),r.connect(i),i.connect(this.bus),r.start(a),r.stop(a+.18)}}estaHablando(){return Date.now()<this.hablaHasta}interrupt(){this.hablaHasta=0;for(let e of this.playing)try{e.stop()}catch{}this.playing.clear(),this.nextStartAt=0}get isSpeaking(){return this.playing.size>0}stop(){this.interrupt(),this.hablaHasta=0,this.spectrum.detach();try{this.bus?.disconnect()}catch{}this.bus=null,this.context?.close(),this.context=null}};async function O(e){let t={echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0};if(!e)return navigator.mediaDevices.getUserMedia({audio:t});try{return await navigator.mediaDevices.getUserMedia({audio:{...t,deviceId:{exact:e}}})}catch(e){let n=e?.name;if(n!==`OverconstrainedError`&&n!==`NotFoundError`)throw e;return navigator.mediaDevices.getUserMedia({audio:t})}}function k(e){switch(e?.name){case`NotAllowedError`:case`SecurityError`:return`Permiso de micrófono denegado. Habilítalo para este sitio y vuelve a intentar.`;case`NotFoundError`:case`OverconstrainedError`:return`No se encontró ningún micrófono conectado.`;case`NotReadableError`:return`Otra aplicación está usando el micrófono.`;default:return`No se pudo acceder al micrófono: ${e?.message??`error desconocido`}`}}var ee=1,te=640,ne=.6,re=class{onFrame;stream=null;video=null;canvas=null;timer=null;constructor(e){this.onFrame=e}get element(){return this.video}async start(){this.stream=await navigator.mediaDevices.getUserMedia({video:{width:{ideal:1280},height:{ideal:720},facingMode:`user`}});let e=document.createElement(`video`);e.srcObject=this.stream,e.muted=!0,e.playsInline=!0,await e.play(),this.video=e,this.canvas=document.createElement(`canvas`),this.timer=setInterval(()=>this.capture(),1e3/ee)}capture(){let e=this.video,t=this.canvas;if(!e||!t||!e.videoWidth)return;let n=Math.min(1,te/e.videoWidth);t.width=Math.round(e.videoWidth*n),t.height=Math.round(e.videoHeight*n);let r=t.getContext(`2d`);if(!r)return;r.drawImage(e,0,0,t.width,t.height);let i=t.toDataURL(`image/jpeg`,ne),a=i.slice(i.indexOf(`,`)+1);a&&this.onFrame(a,`image/jpeg`)}stop(){this.timer&&clearInterval(this.timer),this.timer=null,this.stream?.getTracks().forEach(e=>e.stop()),this.video&&=(this.video.srcObject=null,null),this.stream=null,this.canvas=null}};function ie(e){switch(e?.name){case`NotAllowedError`:case`SecurityError`:return`Permiso de cámara denegado. Habilítalo para este sitio y vuelve a intentar.`;case`NotFoundError`:case`OverconstrainedError`:return`No se encontró ninguna cámara conectada.`;case`NotReadableError`:return`Otra aplicación está usando la cámara.`;default:return`No se pudo acceder a la cámara: ${e?.message??`error desconocido`}`}}var ae=1,oe=1280,se=.72,ce=class{onFrame;onEnded;stream=null;video=null;canvas=null;timer=null;constructor(e,t){this.onFrame=e,this.onEnded=t}get element(){return this.video}async start(){this.stream=await navigator.mediaDevices.getDisplayMedia({video:{frameRate:{ideal:1,max:5}},audio:!1});let[e]=this.stream.getVideoTracks();e&&e.addEventListener(`ended`,()=>{this.stop(),this.onEnded?.()});let t=document.createElement(`video`);t.srcObject=this.stream,t.muted=!0,t.playsInline=!0,await t.play(),this.video=t,this.canvas=document.createElement(`canvas`),this.timer=setInterval(()=>this.capture(),1e3/ae)}capture(){let e=this.video,t=this.canvas;if(!e||!t||!e.videoWidth)return;let n=Math.min(1,oe/e.videoWidth);t.width=Math.round(e.videoWidth*n),t.height=Math.round(e.videoHeight*n);let r=t.getContext(`2d`);if(!r)return;r.drawImage(e,0,0,t.width,t.height);let i=t.toDataURL(`image/jpeg`,se),a=i.slice(i.indexOf(`,`)+1);a&&this.onFrame(a,`image/jpeg`)}stop(){this.timer&&clearInterval(this.timer),this.timer=null,this.stream?.getTracks().forEach(e=>e.stop()),this.video&&=(this.video.srcObject=null,null),this.stream=null,this.canvas=null}};function le(e){switch(e?.name){case`NotAllowedError`:return`No se compartió ninguna pantalla.`;case`NotFoundError`:return`No hay ninguna pantalla o ventana disponible para compartir.`;case`NotReadableError`:return`El sistema no dejó capturar la pantalla. En Linux puede faltar el portal de escritorio.`;default:return`No se pudo compartir la pantalla: ${e?.message??`error desconocido`}`}}function ue(){return I?.element??null}function A(){return L?.element??null}function j(){return{mic:P?.spectrum??null,player:F?.spectrum??null}}function M(){return F?.lipsyncSource??null}var N=null,P=null,F=null,I=null,L=null,R=[{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`}],z=[{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)`}],B=[{id:`foto`,nombre:`Retrato (mejor acabado)`},{id:`modelo`,nombre:`Modelo 3D (se gira con el ratón)`}],V=`hive-voice-avatar`,H=`hive-voice-persona`,U=`hive-voice-language`,W=`hive-voice-output`,G=`hive-voice-input`,K=`hive-voice-speaker`;function q(){return typeof localStorage>`u`?{voice:R[0].id,language:z[0].id,output:``,input:``,speaker:!1}:{voice:localStorage.getItem(H)||R[0].id,language:localStorage.getItem(U)||z[0].id,output:localStorage.getItem(W)||``,input:localStorage.getItem(G)||``,speaker:localStorage.getItem(K)===`1`}}function J(e){typeof localStorage>`u`||(e.voice&&localStorage.setItem(H,e.voice),e.language&&localStorage.setItem(U,e.language),Y(W,e.output),Y(G,e.input),e.speaker!==void 0&&localStorage.setItem(K,e.speaker?`1`:`0`))}function Y(e,t){t!==void 0&&(t?localStorage.setItem(e,t):localStorage.removeItem(e))}function de(){if(typeof localStorage>`u`)return`modelo`;let e=localStorage.getItem(V);return e===`foto`||e===`modelo`?e:`modelo`}function fe(e){typeof localStorage<`u`&&localStorage.setItem(V,e)}function pe(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 X={inputTokens:0,outputTokens:0,totalTokens:0},Z=0,me=o((e,t)=>({status:`idle`,error:null,model:null,voice:null,startedAt:null,transcripts:[],milestones:[],lastTool:null,working:!1,usage:X,latencyMs:null,cameraOn:!1,cameraError:null,screenOn:!1,screenError:null,modoAltavoz:q().speaker,toggleCamera:async()=>{if(I){I.stop(),I=null,e({cameraOn:!1,cameraError:null});return}try{let t=new re((e,t)=>{N?.readyState===WebSocket.OPEN&&N.send(JSON.stringify({type:`video`,data:e,mimeType:t}))});await t.start(),I=t,e({cameraOn:!0,cameraError:null})}catch(t){I=null,e({cameraOn:!1,cameraError:ie(t)})}},toggleScreen:async()=>{if(L){L.stop(),L=null,e({screenOn:!1,screenError:null});return}try{let t=new ce((e,t)=>{N?.readyState===WebSocket.OPEN&&N.send(JSON.stringify({type:`video`,data:e,mimeType:t,source:`screen`}))},()=>{L=null,e({screenOn:!1})});await t.start(),L=t,e({screenOn:!0,screenError:null})}catch(t){L=null,e({screenOn:!1,screenError:le(t)})}},prepararAudio:()=>{F||(F=new D,F.onIdle=()=>{t().status===`speaking`&&e({status:`listening`})}),F.resume()},usarModoAltavoz:t=>{J({speaker:t}),e({modoAltavoz:t})},micCallado:()=>t().modoAltavoz&&!!F?.estaHablando(),usarSalida:async e=>{J({output:e}),e&&t().usarModoAltavoz(v(e)),await F?.usarSalida(e||null)},usarEntrada:async n=>{if(J({input:n}),!P)return;P.stop();let r=new E(e=>{t().modoAltavoz&&F?.estaHablando()||N?.readyState===WebSocket.OPEN&&N.send(e)},n||null);P=r;try{await r.start()}catch(t){P=null,e({status:`error`,error:k(t)})}},probarSalida:async()=>{t().prepararAudio();let e=q();e.output&&F?.usarSalida(e.output),await F?.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:X,latencyMs:null,startedAt:Date.now()}),t().prepararAudio();let a=q();a.output&&F?.usarSalida(a.output);try{if(await F?.resume(),!window.isSecureContext)throw Error(`El micrófono necesita una conexión segura (https o localhost).`);P=new E(e=>{t().modoAltavoz&&F?.estaHablando()||N?.readyState===WebSocket.OPEN&&N.send(e)},a.input||null),await P.start()}catch(n){t().stop(),e({status:`error`,error:k(n)});return}N=new WebSocket(pe(n,r??a.voice,i??a.language,t().modoAltavoz,c.getState().activeId)),N.binaryType=`arraybuffer`,N.onmessage=n=>{if(n.data instanceof ArrayBuffer){if(F?.enqueue(n.data),t().status===`listening`){let t=Z?Date.now()-Z:null;Z=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`&&(Z=Date.now()),e(e=>({transcripts:Q(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`:F?.interrupt(),e({status:`listening`});break;case`turn_complete`:F?.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}},N.onerror=()=>e({status:`error`,error:`Se perdió la conexión con la voz.`}),N.onclose=()=>{t().status!==`error`&&t().stop()}},stop:()=>{P?.stop(),F?.stop(),I?.stop(),I=null,L?.stop(),L=null;try{N?.close()}catch{}P=null,F=null,N=null,Z=0,e({status:`idle`,model:null,voice:null,lastTool:null,working:!1,startedAt:null,cameraOn:!1,cameraError:null,screenOn:!1,screenError:null})},sendText:e=>{N?.readyState===WebSocket.OPEN&&N.send(JSON.stringify({type:`text`,content:e}))},interrupt:()=>{F?.interrupt(),N?.readyState===WebSocket.OPEN&&N.send(JSON.stringify({type:`interrupt`}))}}));function Q(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 $=`hive-audio-devices`;function he(){window.dispatchEvent(new Event($))}function ge(){let e=(0,f.c)(8),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[0]=t):t=e[0];let[n,r]=(0,d.useState)(t),i;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(i=[],e[1]=i):i=e[1];let[a,o]=(0,d.useState)(i),[s,c]=(0,d.useState)(null),l,u;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>{let e=!0,t=()=>{m().then(t=>{e&&r(t)}),h().then(t=>{e&&(o(t.lista),c(t.motivo))})};return t(),navigator.mediaDevices?.addEventListener?.(`devicechange`,t),window.addEventListener($,t),()=>{e=!1,navigator.mediaDevices?.removeEventListener?.(`devicechange`,t),window.removeEventListener($,t)}},u=[],e[2]=l,e[3]=u):(l=e[2],u=e[3]),(0,d.useEffect)(l,u);let p;return e[4]!==n||e[5]!==s||e[6]!==a?(p={entradas:n,salidas:a,motivoSalidas:s},e[4]=n,e[5]=s,e[6]=a,e[7]=p):p=e[7],p}function _e(e,t,n){let r=(0,f.c)(5),[i,a]=(0,d.useState)(0),o=(0,d.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,l=null,u=null,d=()=>{if(!r)return;let e=0;if(n)e=j().mic?.sample()??0;else if(l&&u){l.getByteFrequencyData(u);let t=0;for(let e of u)t+=e;e=Math.min(1,t/(u.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(d)};if(n)i=requestAnimationFrame(d);else{let t={echoCancellation:!0,noiseSuppression:!0};e&&(t.deviceId={exact:e}),navigator.mediaDevices.getUserMedia({audio:t}).then(e=>{if(!r){e.getTracks().forEach(be);return}s=e,he(),c=new AudioContext,l=c.createAnalyser(),l.fftSize=512,l.smoothingTimeConstant=.7,c.createMediaStreamSource(e).connect(l),u=new Uint8Array(new ArrayBuffer(l.frequencyBinCount)),i=requestAnimationFrame(d)}).catch(ye)}return()=>{r=!1,cancelAnimationFrame(i),s?.getTracks().forEach(ve),c?.close(),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,d.useEffect)(s,c),i}function ve(e){return e.stop()}function ye(){}function be(e){return e.stop()}export{R as a,A as c,q as d,fe as f,l as g,u as h,z as i,j as l,me as m,_e as n,ue as o,J as p,B as r,M as s,ge as t,de as u};
|
package/dist/ui/assets/{useHiveAgentsModelLoad-B4EjHvj4.js → useHiveAgentsModelLoad-IOqfYcrC.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{y 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{y as n}from"./index-C5Hhusqq.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-C5Hhusqq.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-C5Hhusqq.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-DP84b3LQ.js">
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
<link rel="modulepreload" crossorigin href="/assets/vendor-react-kUOwxn0g.js">
|
|
35
35
|
<link rel="modulepreload" crossorigin href="/assets/utils-DEmd_M8c.js">
|
|
36
36
|
<link rel="modulepreload" crossorigin href="/assets/gateway-url-BALS_wVh.js">
|
|
37
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
37
|
+
<link rel="stylesheet" crossorigin href="/assets/index-DmFPF9xQ.css">
|
|
38
38
|
</head>
|
|
39
39
|
|
|
40
40
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@johpaz/hive-agents",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Tu colmena de agentes IA. Local-first. Multi-canal. Open source. Construido desde Colombia para el mundo.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"bin": {
|
|
@@ -132,7 +132,7 @@
|
|
|
132
132
|
"@anthropic-ai/sdk": "^0.74.0",
|
|
133
133
|
"@clack/prompts": "^0.5.0",
|
|
134
134
|
"@google/genai": "^1.43.0",
|
|
135
|
-
"@johpaz/hive-db": "0.
|
|
135
|
+
"@johpaz/hive-db": "0.6.1",
|
|
136
136
|
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
137
137
|
"@slack/bolt": "^4.7.2",
|
|
138
138
|
"@vitejs/plugin-react": "^6.1.1",
|
|
@@ -1632,7 +1632,7 @@ async function runFullWizard(): Promise<void> {
|
|
|
1632
1632
|
`💡 DESDE EL DASHBOARD puedes activar:\n` +
|
|
1633
1633
|
` • Canales adicionales (Discord, Slack, WhatsApp, etc.)\n` +
|
|
1634
1634
|
` • Voz (STT/TTS) para audio en tiempo real\n` +
|
|
1635
|
-
` •
|
|
1635
|
+
` • Agentes de código externos (Claude Code, Codex, OpenCode, Kimi)\n` +
|
|
1636
1636
|
` • MCP servers para herramientas externas\n` +
|
|
1637
1637
|
` • Tools y funciones personalizadas\n` +
|
|
1638
1638
|
`\n` +
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* to judge using this checks result plus the raw evidence.
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
+
import * as fs from "node:fs";
|
|
16
17
|
import { col } from "../storage/hive";
|
|
17
18
|
import type { AgentDoc } from "../storage/collections";
|
|
18
19
|
import type { AcceptanceCriterion } from "./run-store";
|
|
@@ -83,6 +84,28 @@ async function runCheckTool(criterion: AcceptanceCriterion, objective: string):
|
|
|
83
84
|
}
|
|
84
85
|
}
|
|
85
86
|
|
|
87
|
+
/**
|
|
88
|
+
* external_code_agent's "diff_checks" criterion: code_agent_run leaves a patch
|
|
89
|
+
* file for every non-empty diff, so the delivery must point to one that exists
|
|
90
|
+
* and has content. A claim of success with no real diff is a failure.
|
|
91
|
+
*/
|
|
92
|
+
function codeAgentPatchGate(criterion: AcceptanceCriterion, texts: string[]): AcceptanceCheckResult | null {
|
|
93
|
+
if (criterion.id !== "diff_checks") return null;
|
|
94
|
+
const paths = new Set<string>();
|
|
95
|
+
for (const text of texts) {
|
|
96
|
+
for (const m of String(text).matchAll(/[^\s"'`]*hive-code-agent-\d+\.patch/g)) paths.add(m[0]);
|
|
97
|
+
}
|
|
98
|
+
const real = [...paths].find((p) => {
|
|
99
|
+
try { return fs.statSync(p).size > 0; } catch { return false; }
|
|
100
|
+
});
|
|
101
|
+
return {
|
|
102
|
+
criterion_id: criterion.id,
|
|
103
|
+
check: "code_agent_patch",
|
|
104
|
+
met: real !== undefined,
|
|
105
|
+
detail: real ? `Patch no vacío: ${real}` : "La entrega no referencia ningún patch existente y no vacío de code_agent_run",
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
86
109
|
async function artifactChecks(evidence: string[]): Promise<AcceptanceCheckResult[]> {
|
|
87
110
|
const artifactIds = new Set<string>();
|
|
88
111
|
for (const item of evidence) {
|
|
@@ -131,6 +154,8 @@ export async function runAcceptanceChecks(input: {
|
|
|
131
154
|
for (const criterion of criteria) {
|
|
132
155
|
const checked = await runCheckTool(criterion, input.objective);
|
|
133
156
|
if (checked) results.push(checked);
|
|
157
|
+
const patchGate = codeAgentPatchGate(criterion, [input.delivery, ...evidence]);
|
|
158
|
+
if (patchGate) results.push(patchGate);
|
|
134
159
|
}
|
|
135
160
|
|
|
136
161
|
results.push(...(await artifactChecks(evidence)));
|
|
@@ -93,15 +93,15 @@ const CATALOG_PERSONAS: CatalogPersona[] = [
|
|
|
93
93
|
receives: "Una acción web autorizada, URL inicial, datos permitidos, estado final esperado y límites de seguridad.",
|
|
94
94
|
workflow: [
|
|
95
95
|
"Abre el sitio y verifica que corresponda al objetivo.",
|
|
96
|
-
"Inspecciona el estado antes de interactuar y usa selectores estables.",
|
|
96
|
+
"Inspecciona el estado antes de interactuar y usa selectores estables o refs de elementos.",
|
|
97
97
|
"Ejecuta solamente los clicks, escritura y esperas necesarios.",
|
|
98
98
|
"Verifica el estado final mediante extracción y captura de pantalla.",
|
|
99
99
|
],
|
|
100
100
|
prohibitions: [...COMMON_PROHIBITIONS, "No confirmas compras, envíos, borrados o publicaciones si el principal no autorizó explícitamente ese efecto."],
|
|
101
101
|
quality: "La entrega incluye URL final, estado observado y evidencia visual o estructurada posterior a la acción.",
|
|
102
102
|
routingExamples: ["llenar un formulario", "iniciar sesión", "hacer clic y verificar una página"],
|
|
103
|
-
tools: ["browser_*", "web_fetch"],
|
|
104
|
-
skills: ["browser_automate", "browser_scrape"],
|
|
103
|
+
tools: ["browser_*", "obscura_*", "web_fetch"],
|
|
104
|
+
skills: ["obscura_browser", "browser_automate", "browser_scrape"],
|
|
105
105
|
workspaceScope: { kind: "none" },
|
|
106
106
|
acceptance: [{ id: "final_state", description: "El estado final del sitio fue comprobado visual o estructuralmente." }],
|
|
107
107
|
},
|
|
@@ -146,6 +146,26 @@ const CATALOG_PERSONAS: CatalogPersona[] = [
|
|
|
146
146
|
acceptance: [{ id: "checks", description: "Las pruebas o checks relevantes pasan y los cambios están acotados al objetivo." }],
|
|
147
147
|
modelOverride: CODE_MODEL,
|
|
148
148
|
},
|
|
149
|
+
{
|
|
150
|
+
id: "external_code_agent",
|
|
151
|
+
name: "Agente de código externo",
|
|
152
|
+
description: "Delega implementación y refactors a un CLI de código externo (Claude Code, Codex, OpenCode, Kimi) y verifica el resultado.",
|
|
153
|
+
role: "Tu dominio es coordinar agentes de código externos: redactar la tarea, ejecutarla con code_agent_run y comprobar el diff resultante.",
|
|
154
|
+
receives: "Objetivo técnico, repositorio, CLI preferido (claude, codex, opencode o kimi), restricciones y comandos de validación.",
|
|
155
|
+
workflow: [
|
|
156
|
+
"Redacta un prompt autocontenido: objetivo, archivos relevantes, restricciones y cómo validar.",
|
|
157
|
+
"Ejecuta code_agent_run con el CLI pedido; si no está instalado, usa otro de los disponibles.",
|
|
158
|
+
"Revisa el diff y los archivos cambiados; descarta cambios fuera del alcance.",
|
|
159
|
+
"Verifica con cli_exec los tests o checks relevantes y entrega el patch_path y la evidencia.",
|
|
160
|
+
],
|
|
161
|
+
prohibitions: [...COMMON_PROHIBITIONS, "No aplicas el patch al workspace principal sin que el objetivo lo pida, y no publicas."],
|
|
162
|
+
quality: "El diff cumple el objetivo, está acotado al alcance y los checks relevantes pasan.",
|
|
163
|
+
routingExamples: ["usa codex para implementar esto", "pídele a claude code que refactorice el módulo", "delega este bug a kimi u opencode"],
|
|
164
|
+
tools: ["code_agent_run", "fs_read", "fs_list", "fs_glob", "fs_exists", "cli_exec"],
|
|
165
|
+
skills: ["external_code_agent", "software_engineering", "cli_safe_exec"],
|
|
166
|
+
workspaceScope: { kind: "workspace", read_globs: ["**/*"], write_globs: ["**/*"] },
|
|
167
|
+
acceptance: [{ id: "diff_checks", description: "El diff resultante está acotado al objetivo y las pruebas o checks relevantes pasan." }],
|
|
168
|
+
},
|
|
149
169
|
{
|
|
150
170
|
id: "office_document_agent",
|
|
151
171
|
name: "Operador de Office",
|
|
@@ -12,10 +12,20 @@ export const JEV_MODEL = "typesafe/jev-1.13"
|
|
|
12
12
|
const ENDPOINT = "https://openrouter.ai/api/alpha/decisions"
|
|
13
13
|
const TIMEOUT_MS = 3000
|
|
14
14
|
const COOLDOWN_MS = 60_000
|
|
15
|
+
/** Kev: same oracle served from the HiveAgents LLM host (llm.hiveagents.io), tried before Jev. */
|
|
16
|
+
export const KEV_MODEL = "Kev-9B-Q8_0.gguf"
|
|
17
|
+
const KEV_DEFAULT_BASE = "https://llm.hiveagents.io"
|
|
18
|
+
const KEV_READY_TTL_MS = 30_000
|
|
19
|
+
const KEV_STATUS_TIMEOUT_MS = 2000
|
|
20
|
+
export type DecisionBackend = "kev" | "jev"
|
|
15
21
|
let failures = 0
|
|
16
22
|
let cooldownUntil = 0
|
|
17
23
|
let lastError: string | null = null
|
|
18
24
|
let lastSuccessAt: number | null = null
|
|
25
|
+
let kevFailures = 0
|
|
26
|
+
let kevCooldownUntil = 0
|
|
27
|
+
let kevReadyCache: { at: number; ready: boolean } | null = null
|
|
28
|
+
let lastBackend: DecisionBackend | null = null
|
|
19
29
|
let decisionSequence = 0
|
|
20
30
|
/** Since gateway boot; the office shows them as the oracle's running contribution. */
|
|
21
31
|
const totals = { decisions: 0, savedTokens: 0, costUsd: 0 }
|
|
@@ -23,16 +33,19 @@ const totals = { decisions: 0, savedTokens: 0, costUsd: 0 }
|
|
|
23
33
|
export type JevQuestion =
|
|
24
34
|
| { type: "choice"; instructions: string; criteria: Record<string, string> }
|
|
25
35
|
| { type: "noul"; instructions: string; criteria?: { true: string; false: string } }
|
|
36
|
+
| { type: "score"; instructions: string; criteria?: Record<string, string> }
|
|
26
37
|
|
|
27
38
|
export type JevAnswer =
|
|
28
39
|
| { type: "choice"; choice: string; confidence: number; probabilities: Record<string, number> }
|
|
29
40
|
| { type: "noul"; noul: number }
|
|
41
|
+
| { type: "score"; score: number }
|
|
30
42
|
|
|
31
43
|
export interface JevResult {
|
|
32
44
|
answers: Record<string, JevAnswer>
|
|
33
45
|
inputTokens: number
|
|
34
46
|
costUsd: number
|
|
35
47
|
latencyMs: number
|
|
48
|
+
backend: DecisionBackend
|
|
36
49
|
}
|
|
37
50
|
|
|
38
51
|
export async function getJevKey(): Promise<string | null> {
|
|
@@ -41,8 +54,45 @@ export async function getJevKey(): Promise<string | null> {
|
|
|
41
54
|
return (await loadProviderApiKey("openrouter")) || process.env.OPENROUTER_API_KEY || null
|
|
42
55
|
}
|
|
43
56
|
|
|
57
|
+
/** Kev is available when the HiveAgents LLM provider is on and has a key; readiness is checked separately. */
|
|
58
|
+
async function getKevConfig(): Promise<{ key: string; base: string } | null> {
|
|
59
|
+
const provider = await (await col<ProviderDoc>("providers")).get("hiveagents")
|
|
60
|
+
if (!provider?.doc.enabled || !provider.doc.active) return null
|
|
61
|
+
const key = (await loadProviderApiKey("hiveagents")) || process.env.HIVEAGENTS_API_KEY || null
|
|
62
|
+
if (!key) return null
|
|
63
|
+
return { key, base: provider.doc.base_url?.replace(/\/v1\/?$/, "").replace(/\/$/, "") || KEV_DEFAULT_BASE }
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** `kev-decision.service` is toggled with systemd on the lab PC, so ask the host; cached to spare every turn a request. */
|
|
67
|
+
async function isKevReady(cfg: { key: string; base: string }, fetcher: typeof fetch): Promise<boolean> {
|
|
68
|
+
if (Date.now() < kevCooldownUntil) return false
|
|
69
|
+
if (kevReadyCache && Date.now() - kevReadyCache.at < KEV_READY_TTL_MS) return kevReadyCache.ready
|
|
70
|
+
let ready = false
|
|
71
|
+
try {
|
|
72
|
+
const response = await fetcher(`${cfg.base}/api/decisions/status`, {
|
|
73
|
+
headers: { Authorization: `Bearer ${cfg.key}` },
|
|
74
|
+
signal: AbortSignal.timeout(KEV_STATUS_TIMEOUT_MS),
|
|
75
|
+
})
|
|
76
|
+
if (response.status === 401 || response.status === 403) kevCooldownUntil = Date.now() + COOLDOWN_MS
|
|
77
|
+
else if (response.ok) {
|
|
78
|
+
const data = await response.json().catch(() => null) as { ready?: unknown } | null
|
|
79
|
+
ready = data?.ready === true
|
|
80
|
+
}
|
|
81
|
+
} catch { /* host unreachable: Kev is simply off */ }
|
|
82
|
+
kevReadyCache = { at: Date.now(), ready }
|
|
83
|
+
return ready
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** True when any decision backend could answer; callers use it to skip building questions. */
|
|
87
|
+
export async function hasDecisionBackend(): Promise<boolean> {
|
|
88
|
+
if (await getJevKey().catch(() => null)) return true
|
|
89
|
+
const kev = await getKevConfig().catch(() => null)
|
|
90
|
+
return !!kev && Date.now() >= kevCooldownUntil
|
|
91
|
+
}
|
|
92
|
+
|
|
44
93
|
export interface JevStatus {
|
|
45
94
|
state: "off" | "ready" | "fallback"
|
|
95
|
+
backend: DecisionBackend | null
|
|
46
96
|
lastError: string | null
|
|
47
97
|
lastSuccessAt: number | null
|
|
48
98
|
totals: { decisions: number; savedTokens: number; costUsd: number }
|
|
@@ -50,10 +100,16 @@ export interface JevStatus {
|
|
|
50
100
|
|
|
51
101
|
export async function getJevStatus(): Promise<JevStatus> {
|
|
52
102
|
const key = await getJevKey().catch(() => null)
|
|
103
|
+
const kev = await getKevConfig().catch(() => null)
|
|
104
|
+
const jevOk = !!key && Date.now() >= cooldownUntil && !lastError
|
|
105
|
+
const kevOk = !!kev && Date.now() >= kevCooldownUntil && kevFailures === 0
|
|
106
|
+
// Before any decision has been served, report who would answer: Kev only when its host says ready.
|
|
107
|
+
const kevReady = kevOk && kev ? await isKevReady(kev, fetch).catch(() => false) : false
|
|
53
108
|
return {
|
|
54
|
-
state: !key ? "off" :
|
|
55
|
-
|
|
56
|
-
|
|
109
|
+
state: !key && !kev ? "off" : jevOk || kevReady ? "ready" : "fallback",
|
|
110
|
+
backend: kevReady ? "kev" : lastBackend ?? (jevOk ? "jev" : null),
|
|
111
|
+
lastError: key || kev ? lastError : null,
|
|
112
|
+
lastSuccessAt: key || kev ? lastSuccessAt : null,
|
|
57
113
|
totals: { ...totals },
|
|
58
114
|
}
|
|
59
115
|
}
|
|
@@ -85,63 +141,101 @@ export function resetJevStatus(): void {
|
|
|
85
141
|
cooldownUntil = 0
|
|
86
142
|
lastError = null
|
|
87
143
|
lastSuccessAt = null
|
|
144
|
+
kevFailures = 0
|
|
145
|
+
kevCooldownUntil = 0
|
|
146
|
+
kevReadyCache = null
|
|
147
|
+
lastBackend = null
|
|
88
148
|
broadcastStatus()
|
|
89
149
|
}
|
|
90
150
|
|
|
151
|
+
function validateAnswers(questions: Record<string, JevQuestion>, data: { answers?: Record<string, JevAnswer> }): Record<string, JevAnswer> {
|
|
152
|
+
const answers: Record<string, JevAnswer> = {}
|
|
153
|
+
const unit = (n: unknown): n is number => typeof n === "number" && Number.isFinite(n) && n >= 0 && n <= 1
|
|
154
|
+
for (const [name, question] of Object.entries(questions)) {
|
|
155
|
+
const answer = data.answers?.[name]
|
|
156
|
+
if (question.type === "choice") {
|
|
157
|
+
if (answer?.type !== "choice" || !Object.hasOwn(question.criteria, answer.choice) || !unit(answer.confidence)) {
|
|
158
|
+
throw new Error(`Invalid choice answer: ${name}`)
|
|
159
|
+
}
|
|
160
|
+
} else if (question.type === "score") {
|
|
161
|
+
if (answer?.type !== "score" || !unit(answer.score)) throw new Error(`Invalid score answer: ${name}`)
|
|
162
|
+
} else if (answer?.type !== "noul" || !unit(answer.noul)) {
|
|
163
|
+
throw new Error(`Invalid noul answer: ${name}`)
|
|
164
|
+
}
|
|
165
|
+
answers[name] = answer
|
|
166
|
+
}
|
|
167
|
+
return answers
|
|
168
|
+
}
|
|
169
|
+
|
|
91
170
|
export async function askJev(
|
|
92
171
|
state: unknown,
|
|
93
172
|
questions: Record<string, JevQuestion>,
|
|
94
173
|
options: { fetcher?: typeof fetch; signal?: AbortSignal } = {},
|
|
95
174
|
): Promise<JevResult | null> {
|
|
175
|
+
if (Object.keys(questions).length === 0) return null
|
|
176
|
+
const fetcher = options.fetcher ?? fetch
|
|
177
|
+
const kev = await getKevConfig().catch(() => null)
|
|
178
|
+
if (kev && await isKevReady(kev, fetcher)) {
|
|
179
|
+
const result = await requestDecision("kev", `${kev.base}/v1/systemone`, kev.key, KEV_MODEL, state, questions, options)
|
|
180
|
+
if (result || options.signal?.aborted) return result
|
|
181
|
+
}
|
|
96
182
|
const key = await getJevKey().catch(() => null)
|
|
97
|
-
if (!key || Date.now() < cooldownUntil
|
|
183
|
+
if (!key || Date.now() < cooldownUntil) return null
|
|
184
|
+
return requestDecision("jev", ENDPOINT, key, JEV_MODEL, state, questions, options)
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
async function requestDecision(
|
|
188
|
+
backend: DecisionBackend,
|
|
189
|
+
endpoint: string,
|
|
190
|
+
key: string,
|
|
191
|
+
model: string,
|
|
192
|
+
state: unknown,
|
|
193
|
+
questions: Record<string, JevQuestion>,
|
|
194
|
+
options: { fetcher?: typeof fetch; signal?: AbortSignal },
|
|
195
|
+
): Promise<JevResult | null> {
|
|
98
196
|
const started = performance.now()
|
|
197
|
+
const label = backend === "kev" ? "Kev" : "OpenRouter"
|
|
99
198
|
try {
|
|
100
|
-
const response = await (options.fetcher ?? fetch)(
|
|
199
|
+
const response = await (options.fetcher ?? fetch)(endpoint, {
|
|
101
200
|
method: "POST",
|
|
102
201
|
headers: { Authorization: `Bearer ${key}`, "Content-Type": "application/json" },
|
|
103
|
-
body: JSON.stringify({ model
|
|
202
|
+
body: JSON.stringify({ model, state, questions }),
|
|
104
203
|
signal: options.signal ? AbortSignal.any([options.signal, AbortSignal.timeout(TIMEOUT_MS)]) : AbortSignal.timeout(TIMEOUT_MS),
|
|
105
204
|
})
|
|
106
205
|
if (!response.ok) {
|
|
107
|
-
if (response.status === 401 || response.status === 403)
|
|
108
|
-
|
|
206
|
+
if (response.status === 401 || response.status === 403) {
|
|
207
|
+
if (backend === "kev") kevCooldownUntil = Date.now() + COOLDOWN_MS
|
|
208
|
+
else cooldownUntil = Date.now() + COOLDOWN_MS
|
|
209
|
+
}
|
|
210
|
+
throw new Error(`${label} HTTP ${response.status}`)
|
|
109
211
|
}
|
|
110
212
|
const data = await response.json() as {
|
|
111
213
|
answers?: Record<string, JevAnswer>
|
|
112
214
|
usage?: { input_tokens?: number; output_tokens?: number; cost?: number }
|
|
113
215
|
}
|
|
114
|
-
const answers
|
|
115
|
-
for (const [name, question] of Object.entries(questions)) {
|
|
116
|
-
const answer = data.answers?.[name]
|
|
117
|
-
if (question.type === "choice") {
|
|
118
|
-
if (answer?.type !== "choice" || !Object.hasOwn(question.criteria, answer.choice) ||
|
|
119
|
-
!Number.isFinite(answer.confidence) || answer.confidence < 0 || answer.confidence > 1) {
|
|
120
|
-
throw new Error(`Invalid choice answer: ${name}`)
|
|
121
|
-
}
|
|
122
|
-
} else if (answer?.type !== "noul" || !Number.isFinite(answer.noul) || answer.noul < 0 || answer.noul > 1) {
|
|
123
|
-
throw new Error(`Invalid noul answer: ${name}`)
|
|
124
|
-
}
|
|
125
|
-
answers[name] = answer
|
|
126
|
-
}
|
|
216
|
+
const answers = validateAnswers(questions, data)
|
|
127
217
|
const recovered = lastError !== null
|
|
128
|
-
|
|
218
|
+
if (backend === "kev") kevFailures = 0
|
|
219
|
+
else failures = 0
|
|
129
220
|
lastError = null
|
|
130
221
|
lastSuccessAt = Date.now()
|
|
131
|
-
if (recovered) broadcastStatus()
|
|
222
|
+
if (recovered || lastBackend !== backend) { lastBackend = backend; broadcastStatus() }
|
|
132
223
|
const inputTokens = data.usage?.input_tokens ?? 0
|
|
133
|
-
|
|
134
|
-
|
|
224
|
+
// Kev runs on our own hardware: no per-token cost.
|
|
225
|
+
const costUsd = backend === "kev" ? 0 : data.usage?.cost ?? inputTokens * 0.042 / 1_000_000
|
|
226
|
+
log.info(`Decision served: backend=${backend} questions=${Object.keys(questions).join(",")} latency_ms=${Math.round(performance.now() - started)} input_tokens=${inputTokens} cost_usd=${costUsd}`)
|
|
135
227
|
if (inputTokens > 0) {
|
|
136
|
-
|
|
228
|
+
const provider = backend === "kev" ? "hiveagents" : "openrouter"
|
|
229
|
+
recordUsage({ provider, model: catalogModelKey(provider, model), inputTokens, outputTokens: data.usage?.output_tokens ?? 0, latencyMs: Math.round(performance.now() - started) })
|
|
137
230
|
}
|
|
138
|
-
return { answers, inputTokens, costUsd, latencyMs: Math.round(performance.now() - started) }
|
|
231
|
+
return { answers, inputTokens, costUsd, latencyMs: Math.round(performance.now() - started), backend }
|
|
139
232
|
} catch (error) {
|
|
140
233
|
if (options.signal?.aborted) return null
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
234
|
+
lastError = error instanceof Error ? error.message : `${label} unavailable`
|
|
235
|
+
if (backend === "kev") {
|
|
236
|
+
if (++kevFailures >= 3) { kevCooldownUntil = Date.now() + COOLDOWN_MS; kevReadyCache = null }
|
|
237
|
+
} else if (++failures >= 3) cooldownUntil = Date.now() + COOLDOWN_MS
|
|
238
|
+
log.warn(`Decision fallback (${backend}): ${lastError}`)
|
|
145
239
|
broadcastStatus()
|
|
146
240
|
return null
|
|
147
241
|
}
|
|
@@ -5,7 +5,7 @@ import type { PlaybookRule } from "./playbook-selector"
|
|
|
5
5
|
import { MINIMAL_TOOLS } from "./minimal-loadout"
|
|
6
6
|
import { searchCapabilities } from "./capability-search"
|
|
7
7
|
import { mcpToolFullName } from "./tool-selector"
|
|
8
|
-
import { askJev,
|
|
8
|
+
import { askJev, hasDecisionBackend, type JevAnswer, type JevQuestion } from "./jev-decisions"
|
|
9
9
|
import { col } from "../storage/hive"
|
|
10
10
|
import type { AgentDoc, McpServerDoc, McpToolDoc } from "../storage/collections"
|
|
11
11
|
|
|
@@ -112,7 +112,7 @@ export async function planJevContext(input: {
|
|
|
112
112
|
/** From describeSwarmCapabilities; absent means "unknown", not "none". */
|
|
113
113
|
swarm?: { mcpServers: JevMcpServer[]; specialists: JevSpecialist[] }
|
|
114
114
|
}): Promise<JevContextPlan | null> {
|
|
115
|
-
if (!await
|
|
115
|
+
if (!await hasDecisionBackend().catch(() => false)) return null
|
|
116
116
|
const { objective, messages, tools, allTools, skills, isWorker } = input
|
|
117
117
|
const mandatoryMessages = new Set<number>()
|
|
118
118
|
// The last two exchanges carry the thread's immediate referents ("hazlo otra
|
|
@@ -218,7 +218,7 @@ export async function planJevContext(input: {
|
|
|
218
218
|
*/
|
|
219
219
|
export async function jevWantsParallel(calls: Array<{ function: { name: string; arguments: unknown } }>): Promise<{ parallel: boolean; decision?: JevDecisionMetrics } | null> {
|
|
220
220
|
if (calls.length < 2) return null
|
|
221
|
-
if (!await
|
|
221
|
+
if (!await hasDecisionBackend().catch(() => false)) return null
|
|
222
222
|
const names = calls.map(c => c.function.name)
|
|
223
223
|
const readOnly = names.every(n => /^(fs_read|fs_list|fs_glob|fs_exists|web_search|web_fetch|memory_read|memory_search|artifact_read|artifact_inspect|task_status|agent_find)$/.test(n))
|
|
224
224
|
const delegated = names.every(n => n === "task_delegate")
|
|
@@ -135,6 +135,8 @@ export const CORE_TOOL_CATALOG: ToolDescriptor[] = [
|
|
|
135
135
|
// Code execution
|
|
136
136
|
{ name: "cli_exec", description: "Execute shell commands, run bash scripts and system commands. Spanish keywords: ejecutar comando, terminal, línea de comandos, bash, script, comando del sistema", category: "cli", abstractionLevel: "atomic" },
|
|
137
137
|
|
|
138
|
+
{ name: "code_agent_run", description: "Delegate a coding task to an external coding-agent CLI (Claude Code, Codex, OpenCode, Kimi) in an isolated git worktree; returns summary, changed files and diff. Spanish keywords: agente de código, delegar programación, codex, claude code, opencode, kimi, implementar con otro agente", category: "cli", abstractionLevel: "atomic" },
|
|
139
|
+
|
|
138
140
|
// Web tools
|
|
139
141
|
{ name: "web_search", description: "Search web for current information, find up-to-date news facts and research. Spanish keywords: buscar en internet, buscar web, información, noticias, investigación, buscar", category: "web", abstractionLevel: "atomic" },
|
|
140
142
|
{ name: "web_fetch", description: "Fetch content from URL, download and extract content from web pages. Spanish keywords: obtener página, descargar web, extraer contenido, obtener contenido, página web", category: "web", abstractionLevel: "atomic" },
|
|
@@ -168,6 +170,45 @@ export const CORE_TOOL_CATALOG: ToolDescriptor[] = [
|
|
|
168
170
|
{ name: "browser_script", description: "Execute arbitrary JavaScript in the browser page context and get the result. Spanish keywords: ejecutar javascript, script, código, función, evaluar, js en página", category: "browser", abstractionLevel: "atomic" },
|
|
169
171
|
{ name: "browser_wait", description: "Wait for an element to appear or condition to be met on the page. Spanish keywords: esperar, wait, condición, elemento, selector, aguardar carga", category: "browser", abstractionLevel: "atomic" },
|
|
170
172
|
|
|
173
|
+
// Obscura (headless browser, live session, element refs)
|
|
174
|
+
{ name: "obscura_navigate", description: "Navigate to a URL and wait for the page to load, keeping a live browser session for subsequent obscura_* tools. Returns the final URL and title only: read the page next with obscura_snapshot or obscura_markdown. Spanish keywords: navegar, abrir página, ir a sitio web, cargar url, visitar", category: "browser", abstractionLevel: "atomic" },
|
|
175
|
+
{ name: "obscura_back", description: "Navigate back in the page history (browser back button). Requires an active session from obscura_navigate. Spanish keywords: atrás, volver, página anterior, regresar", category: "browser", abstractionLevel: "atomic" },
|
|
176
|
+
{ name: "obscura_forward", description: "Navigate forward in the page history. Requires an active session from obscura_navigate. Spanish keywords: adelante, página siguiente, avanzar", category: "browser", abstractionLevel: "atomic" },
|
|
177
|
+
{ name: "obscura_reload", description: "Reload the current page. Requires an active session from obscura_navigate. Spanish keywords: recargar, refrescar página, actualizar página, f5", category: "browser", abstractionLevel: "atomic" },
|
|
178
|
+
{ name: "obscura_close", description: "Close the current browser page and reset the session state. Spanish keywords: cerrar navegador, cerrar página, terminar sesión", category: "browser", abstractionLevel: "atomic" },
|
|
179
|
+
{ name: "obscura_snapshot", description: "Get the current page as text: URL, title, readable body text and interactive element refs. Preferred first read after navigating. Spanish keywords: snapshot página, contenido página, ver página, texto página, captura textual", category: "browser", abstractionLevel: "atomic" },
|
|
180
|
+
{ name: "obscura_markdown", description: "Extract the current page as Markdown (headings, paragraphs, lists, links, code blocks). Token-dense structured content instead of plain text. Spanish keywords: markdown, extraer markdown, contenido estructurado, página en markdown", category: "browser", abstractionLevel: "atomic" },
|
|
181
|
+
{ name: "obscura_links", description: "List every anchor link on the current page as one JSON object per line {text, href}. Spanish keywords: listar enlaces, ver links, urls página, hipervínculos, enlaces", category: "browser", abstractionLevel: "atomic" },
|
|
182
|
+
{ name: "obscura_interactive_elements", description: "List every clickable/typeable element with a stable ref ID and a brief description. Use BEFORE clicking or filling to act by ref instead of guessing CSS selectors. Spanish keywords: elementos interactivos, botones, campos, inputs, refs, elementos clicables", category: "browser", abstractionLevel: "atomic" },
|
|
183
|
+
{ name: "obscura_detect_forms", description: "List every <form> on the page with its action URL, method and a description of each input/textarea/select. Understand a form before filling it. Spanish keywords: detectar formularios, ver formularios, campos formulario, estructura formulario", category: "browser", abstractionLevel: "atomic" },
|
|
184
|
+
{ name: "obscura_extract", description: "Extract a structured object from the page given a map of {field_name: css_selector}. Use 'selector@attr' for attributes (e.g. 'a@href') and 'field[]' suffix for arrays. Spanish keywords: extraer datos, scraping, extraer estructura, datos página, seleccionar campos", category: "browser", abstractionLevel: "atomic" },
|
|
185
|
+
{ name: "obscura_get_attribute", description: "Read an attribute of an element (href, src, value, class, data-*). Returns the raw value or empty string. Spanish keywords: leer atributo, obtener atributo, href, valor elemento, atributo html", category: "browser", abstractionLevel: "atomic" },
|
|
186
|
+
{ name: "obscura_count", description: "Count how many elements on the page match a CSS selector. Cheap existence/pagination probe. Spanish keywords: contar elementos, cuántos, número de elementos, contar coincidencias", category: "browser", abstractionLevel: "atomic" },
|
|
187
|
+
{ name: "obscura_search", description: "Find substring matches in the visible page text with surrounding context. Spanish keywords: buscar en página, encontrar texto, buscar contenido, texto en página", category: "browser", abstractionLevel: "atomic" },
|
|
188
|
+
{ name: "obscura_click", description: "Click an element by ref (preferred, from obscura_snapshot/obscura_interactive_elements) or CSS selector. Spanish keywords: hacer clic, presionar botón, clickear, pulsar, click", category: "browser", abstractionLevel: "atomic" },
|
|
189
|
+
{ name: "obscura_fill", description: "Set the value of an input element (replaces existing value). Pass ref (preferred) or selector. Spanish keywords: llenar campo, rellenar input, establecer valor, completar campo", category: "browser", abstractionLevel: "atomic" },
|
|
190
|
+
{ name: "obscura_type", description: "Type text into an input element (appends to existing value). Pass ref (preferred) or selector. Spanish keywords: escribir en campo, teclear texto, introducir texto, escribir input", category: "browser", abstractionLevel: "atomic" },
|
|
191
|
+
{ name: "obscura_fill_form", description: "Fill multiple inputs in one call: fields is an array of {ref?, selector?, value, type?} where type is text (default), check, uncheck or select. Optional submit_ref/submit_selector clicks after filling. Spanish keywords: llenar formulario, completar formulario, rellenar form, enviar formulario", category: "browser", abstractionLevel: "atomic" },
|
|
192
|
+
{ name: "obscura_press_key", description: "Dispatch a keyboard event (Enter, Tab, Escape…) on an element or the document. Spanish keywords: presionar tecla, pulsar enter, teclado, keydown", category: "browser", abstractionLevel: "atomic" },
|
|
193
|
+
{ name: "obscura_select_option", description: "Select an option from a <select> element by value or visible text. Spanish keywords: seleccionar opción, elegir opción, dropdown, lista desplegable, select", category: "browser", abstractionLevel: "atomic" },
|
|
194
|
+
{ name: "obscura_scroll", description: "Scroll the page or an element: direction top/bottom/up/down/left/right, amount in pixels. Use 'bottom' to trigger infinite-scroll loaders. Spanish keywords: scroll, desplazar, bajar página, subir página, desplazamiento", category: "browser", abstractionLevel: "atomic" },
|
|
195
|
+
{ name: "obscura_wait_for", description: "Wait for a CSS selector to appear in the DOM (default 30s). Spanish keywords: esperar elemento, aguardar selector, wait selector, esperar carga", category: "browser", abstractionLevel: "atomic" },
|
|
196
|
+
{ name: "obscura_wait_for_text", description: "Wait until a substring appears anywhere in the rendered page text — for result messages and notifications. Spanish keywords: esperar texto, aguardar mensaje, esperar resultado, wait texto", category: "browser", abstractionLevel: "atomic" },
|
|
197
|
+
{ name: "obscura_evaluate", description: "Evaluate a JavaScript expression in the page context and return the result as JSON. Spanish keywords: ejecutar javascript, evaluar expresión, js en página, script navegador, eval", category: "browser", abstractionLevel: "atomic" },
|
|
198
|
+
{ name: "obscura_network_requests", description: "List the network requests made by the current page (URLs, statuses, timings). Spanish keywords: ver peticiones red, requests, tráfico red, llamadas http página, network", category: "browser", abstractionLevel: "atomic" },
|
|
199
|
+
{ name: "obscura_console_messages", description: "List the console messages logged by the current page (logs, warnings, errors). Spanish keywords: ver consola, logs página, mensajes consola, errores javascript, console", category: "browser", abstractionLevel: "atomic" },
|
|
200
|
+
{ name: "obscura_screenshot", description: "Capture the current rendered viewport as a PNG (saved to ~/.hivecode/screenshots/, returned with path + base64). Use for canvas/visual verification; prefer obscura_snapshot for text. Spanish keywords: captura de pantalla, screenshot, fotografiar página, imagen página, png", category: "browser", abstractionLevel: "atomic" },
|
|
201
|
+
{ name: "obscura_pdf", description: "Export the current rendered document as a paginated PDF (saved to ~/.hivecode/screenshots/). Spanish keywords: exportar pdf, guardar pdf, página a pdf, documento pdf", category: "browser", abstractionLevel: "atomic" },
|
|
202
|
+
{ name: "obscura_get_cookies", description: "Return all cookies in the browser's cookie jar as one JSON object per line. Spanish keywords: ver cookies, obtener cookies, cookies sesión, leer cookies", category: "browser", abstractionLevel: "atomic" },
|
|
203
|
+
{ name: "obscura_set_cookie", description: "Add or replace a cookie in the jar — skip a login flow when you already have a session token. Spanish keywords: setear cookie, establecer cookie, inyectar cookie, cookie sesión", category: "browser", abstractionLevel: "atomic" },
|
|
204
|
+
{ name: "obscura_clear_cookies", description: "Wipe every cookie from the jar. Spanish keywords: borrar cookies, limpiar cookies, eliminar cookies", category: "browser", abstractionLevel: "atomic" },
|
|
205
|
+
{ name: "obscura_storage_state", description: "Export the full session state (cookies + localStorage + sessionStorage) as JSON — save it to skip a login on a later run. Spanish keywords: exportar sesión, estado sesión, guardar sesión, storage state", category: "browser", abstractionLevel: "atomic" },
|
|
206
|
+
{ name: "obscura_set_storage_state", description: "Restore a session state previously returned by obscura_storage_state to bring an authenticated session back. Spanish keywords: restaurar sesión, importar sesión, cargar sesión guardada, login guardado", category: "browser", abstractionLevel: "atomic" },
|
|
207
|
+
{ name: "obscura_tab_new", description: "Open a new tab (isolated browser page); subsequent tool calls operate on the most recent tab. Spanish keywords: nueva pestaña, abrir pestaña, nuevo tab", category: "browser", abstractionLevel: "atomic" },
|
|
208
|
+
{ name: "obscura_tab_list", description: "List all open tabs with their ID, URL, title and which one is active. Spanish keywords: listar pestañas, ver pestañas, tabs abiertos", category: "browser", abstractionLevel: "atomic" },
|
|
209
|
+
{ name: "obscura_tab_switch", description: "Switch the active tab — all subsequent tool calls target this tab. Spanish keywords: cambiar pestaña, cambiar tab, activar pestaña", category: "browser", abstractionLevel: "atomic" },
|
|
210
|
+
{ name: "obscura_tab_close", description: "Close a tab by ID (default: the active tab). Spanish keywords: cerrar pestaña, cerrar tab", category: "browser", abstractionLevel: "atomic" },
|
|
211
|
+
|
|
171
212
|
// A2UI v0.9 rich interactive surfaces
|
|
172
213
|
{ name: "a2ui_create_surface", description: "Create A2UI v0.9 surface for rich interactive UIs with forms, dashboards, and workflows. Spanish keywords: crear superficie A2UI, iniciar UI interactiva, crear formulario rico, interfaz A2UI, crear surface", category: "a2ui", abstractionLevel: "orchestration" },
|
|
173
214
|
{ name: "a2ui_update_components", description: "Send A2UI v0.9 components to an existing surface (Text, Button, TextField, Row, Column, Card, etc.). Spanish keywords: enviar componentes A2UI, actualizar UI, renderizar componentes, A2UI componentes, update components", category: "a2ui", abstractionLevel: "atomic" },
|
|
@@ -42,7 +42,7 @@ export async function handleGetProviders(req: Request, addCorsHeaders: (r: Respo
|
|
|
42
42
|
has_api_key: apiKey ? 1 : 0,
|
|
43
43
|
has_headers: Object.keys(headers).length > 0 ? 1 : 0,
|
|
44
44
|
masked_api_key: apiKey ? maskApiKey(apiKey) : null,
|
|
45
|
-
...(p.doc.id === "openrouter" ? { jev: jevStatus } : {}),
|
|
45
|
+
...(p.doc.id === "openrouter" || p.doc.id === "hiveagents" ? { jev: jevStatus } : {}),
|
|
46
46
|
models: providerModels,
|
|
47
47
|
}
|
|
48
48
|
}))
|
|
@@ -78,7 +78,7 @@ export async function handleToggleProvider(req: Request, addCorsHeaders: (r: Res
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
await updateDoc<ProviderDoc>("providers", providerId, { active: !!active, enabled: !!active })
|
|
81
|
-
if (providerId === "openrouter") resetJevStatus()
|
|
81
|
+
if (providerId === "openrouter" || providerId === "hiveagents") resetJevStatus()
|
|
82
82
|
|
|
83
83
|
// Cascade: activate/deactivate all models for this provider
|
|
84
84
|
await updateManyByIndex<ModelDoc>("models", "provider_id", providerId, { active: !!active, enabled: !!active })
|
|
@@ -113,7 +113,7 @@ export async function handleUpdateProvider(req: Request, addCorsHeaders: (r: Res
|
|
|
113
113
|
}
|
|
114
114
|
if (body.clearApiKey === true) {
|
|
115
115
|
await deleteProviderApiKey(id)
|
|
116
|
-
if (id === "openrouter") resetJevStatus()
|
|
116
|
+
if (id === "openrouter" || id === "hiveagents") resetJevStatus()
|
|
117
117
|
}
|
|
118
118
|
if (body.headers) {
|
|
119
119
|
await storeProviderHeaders(id, body.headers)
|
|
@@ -123,7 +123,7 @@ export async function handleUpdateProvider(req: Request, addCorsHeaders: (r: Res
|
|
|
123
123
|
|
|
124
124
|
if (Object.keys(patch).length > 0) {
|
|
125
125
|
await updateDoc<ProviderDoc>("providers", id, patch).catch(() => { /* provider not found */ })
|
|
126
|
-
if (id === "openrouter" && (patch.active !== undefined || patch.enabled !== undefined)) resetJevStatus()
|
|
126
|
+
if ((id === "openrouter" || id === "hiveagents") && (patch.active !== undefined || patch.enabled !== undefined)) resetJevStatus()
|
|
127
127
|
|
|
128
128
|
// Cascade active/enabled changes to models
|
|
129
129
|
if (patch.active !== undefined) {
|
|
@@ -160,7 +160,7 @@ export async function ensureHiveDb(): Promise<void> {
|
|
|
160
160
|
// Mint the master key before anything can save an API key, so a fresh
|
|
161
161
|
// install is durable from the first keystroke rather than after a restart
|
|
162
162
|
// has already dropped the secret.
|
|
163
|
-
ensureSecretsBackend();
|
|
163
|
+
await ensureSecretsBackend();
|
|
164
164
|
await ensureSeedData();
|
|
165
165
|
|
|
166
166
|
await ensureLegacyThreads();
|