@johpaz/hive-agents 1.0.2 → 1.0.3
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 +1014 -644
- package/dist/ui/assets/{A2UIPage-BRpjnMss.js → A2UIPage-DExwevBV.js} +1 -1
- package/dist/ui/assets/{AgentCreateForm-ASjKD7Js.js → AgentCreateForm-7PPShsUn.js} +1 -1
- package/dist/ui/assets/{AgentDetailPage-bqJ-MS40.js → AgentDetailPage-CiV4tz4P.js} +1 -1
- package/dist/ui/assets/AgentNewPage-D3TtVwQf.js +1 -0
- package/dist/ui/assets/{AgentsPage-BIpLG0V6.js → AgentsPage-C2DThet7.js} +1 -1
- package/dist/ui/assets/{ApiClientPage-dRckcgrN.js → ApiClientPage-Cowdq-0f.js} +1 -1
- package/dist/ui/assets/{ChannelsPage-BX_hPtiN.js → ChannelsPage-D4IgglwJ.js} +1 -1
- package/dist/ui/assets/{DashboardPage-KMaMaFf4.js → DashboardPage-DAgVB7Iy.js} +1 -1
- package/dist/ui/assets/{LoginPage-Zchu-f16.js → LoginPage-CpU61b3u.js} +1 -1
- package/dist/ui/assets/{LogsPage-6Po7_T2u.js → LogsPage-DyJOGQNy.js} +1 -1
- package/dist/ui/assets/{MeetingPage-qrpYGVD-.js → MeetingPage-DLmqHmm2.js} +1 -1
- package/dist/ui/assets/{ModelSelector-C8ny_pxu.js → ModelSelector-D4OaICwN.js} +1 -1
- package/dist/ui/assets/{Office3DPage-BYwLMTCl.js → Office3DPage-BvO66B0h.js} +1 -1
- package/dist/ui/assets/{ProvidersPage-DP9v_1ko.js → ProvidersPage-Bhb6Qr87.js} +1 -1
- package/dist/ui/assets/{RecoverPage-BXwjLfap.js → RecoverPage-DaZrCpdB.js} +1 -1
- package/dist/ui/assets/{SettingsPage-DD7GKtS6.js → SettingsPage-BRD2F7up.js} +1 -1
- package/dist/ui/assets/{SetupPage-D7YX2io-.js → SetupPage-DKppgTja.js} +1 -1
- package/dist/ui/assets/WebChatPage-CPtETNL5.js +29 -0
- package/dist/ui/assets/{activity-DZKL7dg4.js → activity-BSosMryb.js} +1 -1
- package/dist/ui/assets/{agentCapabilities-DuGs07XP.js → agentCapabilities-VqxLmrF6.js} +1 -1
- package/dist/ui/assets/arrow-left-C9Y6p4Jt.js +1 -0
- package/dist/ui/assets/arrow-right-BYfOLnTB.js +1 -0
- package/dist/ui/assets/arrow-up-right-D2trA3Ob.js +1 -0
- package/dist/ui/assets/{calendar-CkDsc4OJ.js → calendar-rdd4nvY1.js} +1 -1
- package/dist/ui/assets/check-DUq9uoNQ.js +1 -0
- package/dist/ui/assets/chevron-down-rPF4Pr1n.js +1 -0
- package/dist/ui/assets/chevron-left-Crzzf2sY.js +1 -0
- package/dist/ui/assets/chevron-right-DtMIvG9A.js +1 -0
- package/dist/ui/assets/chevron-up-CG0_KGBy.js +1 -0
- package/dist/ui/assets/{circle-alert-BkP6x0zQ.js → circle-alert-CYt6gsDA.js} +1 -1
- package/dist/ui/assets/circle-check-Zl32-jCa.js +1 -0
- package/dist/ui/assets/{circle-x-h4OJiHV3.js → circle-x-BJXzKGmx.js} +1 -1
- package/dist/ui/assets/{copy-BtpYEEvV.js → copy-BmtJXmDe.js} +1 -1
- package/dist/ui/assets/{dialog-CO1WrPJc.js → dialog-Dn9hGPYl.js} +1 -1
- package/dist/ui/assets/{download-aPuVaZik.js → download-D3mYhuuL.js} +1 -1
- package/dist/ui/assets/{earth-sc8YJMc0.js → earth-BZzdDXFC.js} +1 -1
- package/dist/ui/assets/{ellipsis-vertical-DEBZJGzY.js → ellipsis-vertical-BF705XvB.js} +1 -1
- package/dist/ui/assets/{external-link-D_C_678M.js → external-link-gdpMTHUV.js} +1 -1
- package/dist/ui/assets/{eye-BfN613fx.js → eye-lSG04hI7.js} +1 -1
- package/dist/ui/assets/{file-text-Bth5pPZX.js → file-text-CjQxcJvN.js} +1 -1
- package/dist/ui/assets/gauge-DBryKhDK.js +1 -0
- package/dist/ui/assets/{history-njH_sPSo.js → history-BC6ir9qU.js} +1 -1
- package/dist/ui/assets/{index-D-9yCvjP.js → index-DyxoAvTq.js} +2 -2
- package/dist/ui/assets/{info-Def2ZFeP.js → info-BGBaIyKc.js} +1 -1
- package/dist/ui/assets/{key-D8bkDl83.js → key-D_CNJTY2.js} +1 -1
- package/dist/ui/assets/loader-circle-RXdrfPsH.js +1 -0
- package/dist/ui/assets/{lock-open-Cdopbw1b.js → lock-open-UB61lorP.js} +1 -1
- package/dist/ui/assets/{mail-BQ_YA9_b.js → mail-C5bJ_dBt.js} +1 -1
- package/dist/ui/assets/{pause-CvS_LzKx.js → pause-BSTJvxDu.js} +1 -1
- package/dist/ui/assets/{pencil-C3tPvnCk.js → pencil-C2B1Q7y2.js} +1 -1
- package/dist/ui/assets/play-tcMbj-0p.js +1 -0
- package/dist/ui/assets/plus-BSZvyMND.js +1 -0
- package/dist/ui/assets/{radio-dsaiFxuT.js → radio-D9CrjAar.js} +1 -1
- package/dist/ui/assets/{refresh-cw-BmYQwOhh.js → refresh-cw-D7EB_fVv.js} +1 -1
- package/dist/ui/assets/search-5S6LY69I.js +1 -0
- package/dist/ui/assets/{select-BfRyBbi9.js → select-ot0a6art.js} +1 -1
- package/dist/ui/assets/{send-C3o2wpLi.js → send-Dax1tJ5b.js} +1 -1
- package/dist/ui/assets/{settings-DEpdBuf2.js → settings-97CL32lC.js} +1 -1
- package/dist/ui/assets/{shield-gbUkSqfi.js → shield-DwbCEZbF.js} +1 -1
- package/dist/ui/assets/{sparkles-Ccd1JZ3s.js → sparkles-CWMAzkpD.js} +1 -1
- package/dist/ui/assets/{square-BrwQ6Mun.js → square-B4dgTXI3.js} +1 -1
- package/dist/ui/assets/terminal-DoLedTPM.js +1 -0
- package/dist/ui/assets/{trash-2-CfCs7RhJ.js → trash-2-DxnVYOz8.js} +1 -1
- package/dist/ui/assets/{triangle-alert-C3lWSnRr.js → triangle-alert-Cka-BeIE.js} +1 -1
- package/dist/ui/assets/{useHiveAgentsModelLoad-D3s2U82M.js → useHiveAgentsModelLoad-BjnIsQKR.js} +1 -1
- package/dist/ui/assets/{useProviders-B3rT_xU9.js → useProviders-CueMz_mL.js} +1 -1
- package/dist/ui/assets/{volume-x-D2h9cyml.js → volume-x-DLsli9cf.js} +1 -1
- package/dist/ui/assets/{wifi-CGQECzu2.js → wifi-BQRJGfLZ.js} +1 -1
- package/dist/ui/assets/{zap-B1azpiE7.js → zap-DSR3CEce.js} +1 -1
- package/dist/ui/index.html +1 -1
- package/package.json +1 -1
- package/packages/core/src/agent/agent-loop.ts +29 -3
- package/packages/core/src/agent/context-compiler.ts +13 -2
- package/packages/core/src/agent/mcp-result-normalizer.ts +150 -0
- package/packages/core/src/agent/providers/index.ts +8 -0
- package/packages/core/src/artifacts/store.ts +16 -0
- package/packages/core/src/channels/base.ts +33 -0
- package/packages/core/src/channels/discord.ts +20 -1
- package/packages/core/src/channels/slack.ts +21 -2
- package/packages/core/src/channels/telegram.ts +16 -1
- package/packages/core/src/channels/whatsapp.ts +16 -3
- package/packages/core/src/gateway/durable-queue.ts +2 -1
- package/packages/core/src/gateway/failure-notify.ts +78 -0
- package/packages/core/src/gateway/job-executors.ts +1 -0
- package/packages/core/src/gateway/job-store.ts +6 -0
- package/packages/core/src/gateway/process-safety.ts +40 -0
- package/packages/core/src/gateway/routes/artifacts.ts +60 -0
- package/packages/core/src/gateway/server.ts +36 -5
- package/packages/core/src/gateway/webchat-turn.ts +40 -1
- package/packages/core/src/utils/redact-binary.ts +17 -0
- package/dist/ui/assets/AgentNewPage-CPaf2C3u.js +0 -1
- package/dist/ui/assets/WebChatPage-C3cgimxd.js +0 -29
- package/dist/ui/assets/arrow-left-12JaXVoH.js +0 -1
- package/dist/ui/assets/arrow-right-Dbui5p0d.js +0 -1
- package/dist/ui/assets/arrow-up-right-CJBtXRrp.js +0 -1
- package/dist/ui/assets/check-DxOMIDcl.js +0 -1
- package/dist/ui/assets/chevron-down-CObv-xyx.js +0 -1
- package/dist/ui/assets/chevron-left-C0mqwhLU.js +0 -1
- package/dist/ui/assets/chevron-right-jCt1h8Kw.js +0 -1
- package/dist/ui/assets/chevron-up-DX_5iw7O.js +0 -1
- package/dist/ui/assets/circle-check-CXC2AiMS.js +0 -1
- package/dist/ui/assets/gauge-DypSzSOE.js +0 -1
- package/dist/ui/assets/loader-circle-wLVzSdML.js +0 -1
- package/dist/ui/assets/play-C-oR-PMH.js +0 -1
- package/dist/ui/assets/plus-CF9No2td.js +0 -1
- package/dist/ui/assets/search-CTONpTyl.js +0 -1
- package/dist/ui/assets/terminal-DP9j3HjM.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{f as t}from"./vendor-charts-K3xcRl0X.js";import{B as n,F as r,G as i,H as a,I as o,K as s,L as c,M as l,N as u,P as d,R as f,U as p,V as m,W as h,z as g}from"./vendor-radix-D0s_k6Gp.js";import{o as _}from"./vendor-query-Dj8xYhQD.js";import{t as v}from"./check-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{f as t}from"./vendor-charts-K3xcRl0X.js";import{B as n,F as r,G as i,H as a,I as o,K as s,L as c,M as l,N as u,P as d,R as f,U as p,V as m,W as h,z as g}from"./vendor-radix-D0s_k6Gp.js";import{o as _}from"./vendor-query-Dj8xYhQD.js";import{t as v}from"./check-DUq9uoNQ.js";import{t as y}from"./chevron-down-rPF4Pr1n.js";import{t as b}from"./chevron-up-CG0_KGBy.js";import{t as x}from"./utils-Dyb7SC2_.js";var S=e(t(),1),C=_(),w=n,T=u,E=i,D=S.forwardRef(({className:e,children:t,...n},r)=>(0,C.jsxs)(h,{ref:r,className:x(`flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1 cursor-pointer`,e),...n,children:[t,(0,C.jsx)(d,{asChild:!0,children:(0,C.jsx)(y,{className:`h-4 w-4 opacity-50`})})]}));D.displayName=h.displayName;var O=S.forwardRef(({className:e,...t},n)=>(0,C.jsx)(a,{ref:n,className:x(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,C.jsx)(b,{className:`h-4 w-4`})}));O.displayName=a.displayName;var k=S.forwardRef(({className:e,...t},n)=>(0,C.jsx)(m,{ref:n,className:x(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,C.jsx)(y,{className:`h-4 w-4`})}));k.displayName=m.displayName;var A=S.forwardRef(({className:e,children:t,position:n=`popper`,align:r=`center`,...i},a)=>(0,C.jsx)(g,{children:(0,C.jsxs)(l,{ref:a,className:x(`relative z-[10001] max-h-[--radix-select-content-available-height] min-w-[8rem] origin-[--radix-select-content-transform-origin] overflow-x-hidden overflow-y-auto rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,align:r,...i,children:[(0,C.jsx)(O,{}),(0,C.jsx)(s,{className:x(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1`),children:t}),(0,C.jsx)(k,{})]})}));A.displayName=l.displayName;var j=S.forwardRef(({className:e,...t},n)=>(0,C.jsx)(f,{ref:n,className:x(`py-1.5 pl-8 pr-2 text-sm font-semibold`,e),...t}));j.displayName=f.displayName;var M=S.forwardRef(({className:e,children:t,...n},i)=>(0,C.jsxs)(r,{ref:i,className:x(`relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground`,e),...n,children:[(0,C.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,C.jsx)(o,{children:(0,C.jsx)(v,{className:`h-4 w-4`})})}),(0,C.jsx)(c,{children:t})]}));M.displayName=r.displayName;var N=S.forwardRef(({className:e,...t},n)=>(0,C.jsx)(p,{ref:n,className:x(`-mx-1 my-1 h-px bg-muted`,e),...t}));N.displayName=p.displayName;export{j as a,M as i,A as n,D as o,T as r,E as s,w as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as e}from"./index-
|
|
1
|
+
import{K as e}from"./index-DyxoAvTq.js";var t=e(`Send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]);export{t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as e}from"./index-
|
|
1
|
+
import{K as e}from"./index-DyxoAvTq.js";var t=e(`Settings`,[[`path`,{d:`M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z`,key:`1qme2f`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]);export{t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as e}from"./index-
|
|
1
|
+
import{K as e}from"./index-DyxoAvTq.js";var t=e(`Shield`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]);export{t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as e}from"./index-
|
|
1
|
+
import{K as e}from"./index-DyxoAvTq.js";var t=e(`Sparkles`,[[`path`,{d:`M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z`,key:`4pj2yx`}],[`path`,{d:`M20 3v4`,key:`1olli1`}],[`path`,{d:`M22 5h-4`,key:`1gvqau`}],[`path`,{d:`M4 17v2`,key:`vumght`}],[`path`,{d:`M5 18H3`,key:`zchphs`}]]);export{t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as e}from"./index-
|
|
1
|
+
import{K as e}from"./index-DyxoAvTq.js";var t=e(`Mic`,[[`path`,{d:`M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z`,key:`131961`}],[`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`,key:`1vc78b`}],[`line`,{x1:`12`,x2:`12`,y1:`19`,y2:`22`,key:`x3vr5v`}]]),n=e(`Square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]);export{t as n,n as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{K as e}from"./index-DyxoAvTq.js";var t=e(`Terminal`,[[`polyline`,{points:`4 17 10 11 4 5`,key:`akl6gq`}],[`line`,{x1:`12`,x2:`20`,y1:`19`,y2:`19`,key:`q2wloq`}]]);export{t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as e}from"./index-
|
|
1
|
+
import{K as e}from"./index-DyxoAvTq.js";var t=e(`Trash2`,[[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6`,key:`4alrt4`}],[`path`,{d:`M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2`,key:`v07s0e`}],[`line`,{x1:`10`,x2:`10`,y1:`11`,y2:`17`,key:`1uufr5`}],[`line`,{x1:`14`,x2:`14`,y1:`11`,y2:`17`,key:`xtxkd`}]]);export{t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as e}from"./index-
|
|
1
|
+
import{K as e}from"./index-DyxoAvTq.js";var t=e(`TriangleAlert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]);export{t};
|
package/dist/ui/assets/{useHiveAgentsModelLoad-D3s2U82M.js → useHiveAgentsModelLoad-BjnIsQKR.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{r 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{r as n}from"./index-DyxoAvTq.js";var r=e(t(),1),i=2500,a=3e5;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{K as e}from"./index-
|
|
1
|
+
import{K as e}from"./index-DyxoAvTq.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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as e}from"./index-
|
|
1
|
+
import{K as e}from"./index-DyxoAvTq.js";var t=e(`Volume2`,[[`path`,{d:`M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z`,key:`uqj9uw`}],[`path`,{d:`M16 9a5 5 0 0 1 0 6`,key:`1q6k2b`}],[`path`,{d:`M19.364 18.364a9 9 0 0 0 0-12.728`,key:`ijwkga`}]]),n=e(`VolumeX`,[[`path`,{d:`M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z`,key:`uqj9uw`}],[`line`,{x1:`22`,x2:`16`,y1:`9`,y2:`15`,key:`1ewh16`}],[`line`,{x1:`16`,x2:`22`,y1:`9`,y2:`15`,key:`5ykzw1`}]]);export{t as n,n as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as e}from"./index-
|
|
1
|
+
import{K as e}from"./index-DyxoAvTq.js";var t=e(`WifiOff`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),n=e(`Wifi`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M2 8.82a15 15 0 0 1 20 0`,key:`dnpr2z`}],[`path`,{d:`M5 12.859a10 10 0 0 1 14 0`,key:`1x1e6c`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}]]);export{t as n,n as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as e}from"./index-
|
|
1
|
+
import{K as e}from"./index-DyxoAvTq.js";var t=e(`Zap`,[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]]);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-DyxoAvTq.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-zpB-76nT.js">
|
package/package.json
CHANGED
|
@@ -26,6 +26,7 @@ import { emitCanvas } from "../canvas/emitter"
|
|
|
26
26
|
import type { MCPClientManager } from "@johpaz/hive-agents-mcp"
|
|
27
27
|
import { compileContext } from "./context-compiler"
|
|
28
28
|
import { formatToolResult } from "../utils/toon"
|
|
29
|
+
import { redactBinaryStrings } from "../utils/redact-binary"
|
|
29
30
|
import { resolveUserId, resolveAgentId } from "../storage/onboarding"
|
|
30
31
|
import type { ContentPart } from "../multimodal/types"
|
|
31
32
|
import { loadConfig } from "../config/loader"
|
|
@@ -215,6 +216,8 @@ export interface StreamChunk {
|
|
|
215
216
|
agent?: { messages: any[]; streamed?: boolean }
|
|
216
217
|
tools?: { messages: any[] }
|
|
217
218
|
usage?: { input_tokens: number; output_tokens: number }
|
|
219
|
+
/** Image artifacts (mcp-result-normalizer.ts) produced by tools this turn. */
|
|
220
|
+
artifacts?: { images: Array<{ artifactId: string; mimeType: string }> }
|
|
218
221
|
}
|
|
219
222
|
|
|
220
223
|
// ─── Main agent loop ──────────────────────────────────────────────────────────
|
|
@@ -360,6 +363,10 @@ export async function* runAgent(
|
|
|
360
363
|
let iterations = 0
|
|
361
364
|
let totalInputTokens = 0
|
|
362
365
|
let totalOutputTokens = 0
|
|
366
|
+
// Image artifacts produced by tool results this turn (post mcp-result-normalizer.ts) —
|
|
367
|
+
// surfaced in the final chunk so callers (webchat-turn.ts) can attach them to the
|
|
368
|
+
// outbound message instead of the model having to describe them in text.
|
|
369
|
+
const turnImageArtifacts: Array<{ artifactId: string; mimeType: string }> = []
|
|
363
370
|
let lastToolSignature = ""
|
|
364
371
|
let consecutiveRepeat = 0
|
|
365
372
|
let idleIterations = 0
|
|
@@ -648,6 +655,23 @@ export async function* runAgent(
|
|
|
648
655
|
const toolResultJS = batchResult.result
|
|
649
656
|
const toolMs = batchResult.durationMs
|
|
650
657
|
|
|
658
|
+
// Surface image artifacts (see mcp-result-normalizer.ts) so the final
|
|
659
|
+
// response can carry them to the UI/channel — before TOON-encoding,
|
|
660
|
+
// while toolResultJS is still structured.
|
|
661
|
+
if (Array.isArray(toolResultJS)) {
|
|
662
|
+
for (const block of toolResultJS) {
|
|
663
|
+
if (
|
|
664
|
+
block && typeof block === "object" &&
|
|
665
|
+
(block as { type?: unknown }).type === "artifact_ref" &&
|
|
666
|
+
typeof (block as { mime_type?: unknown }).mime_type === "string" &&
|
|
667
|
+
(block as { mime_type: string }).mime_type.startsWith("image/")
|
|
668
|
+
) {
|
|
669
|
+
const ref = block as { artifact_id: string; mime_type: string }
|
|
670
|
+
turnImageArtifacts.push({ artifactId: ref.artifact_id, mimeType: ref.mime_type })
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
|
|
651
675
|
// Encode TOON only for LLM consumption (with cost calculation)
|
|
652
676
|
const toolResultLLM = formatToolResult(toolResultJS, cleanModel)
|
|
653
677
|
|
|
@@ -1085,6 +1109,10 @@ export async function* runAgent(
|
|
|
1085
1109
|
yield { usage: { input_tokens: totalInputTokens, output_tokens: totalOutputTokens } }
|
|
1086
1110
|
}
|
|
1087
1111
|
|
|
1112
|
+
if (turnImageArtifacts.length > 0) {
|
|
1113
|
+
yield { artifacts: { images: turnImageArtifacts } }
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1088
1116
|
// ── Post-loop ────────────────────────────────────────────────────────────
|
|
1089
1117
|
const durationMs = Math.round(performance.now() - t0)
|
|
1090
1118
|
|
|
@@ -1232,9 +1260,7 @@ export async function runAgentIsolatedDetailed(
|
|
|
1232
1260
|
}
|
|
1233
1261
|
for (const message of chunk.tools?.messages ?? []) {
|
|
1234
1262
|
const raw = typeof message.content === "string" ? message.content : JSON.stringify(message.content)
|
|
1235
|
-
const safe = raw
|
|
1236
|
-
.replace(/data:[a-z0-9.+-]+\/[a-z0-9.+-]+;base64,[a-z0-9+/=\s]+/gi, "[REDACTED_BINARY]")
|
|
1237
|
-
.replace(/[A-Za-z0-9+/]{1000,}={0,2}/g, "[REDACTED_BINARY]")
|
|
1263
|
+
const safe = redactBinaryStrings(raw)
|
|
1238
1264
|
toolEvidence.push(`${message.name ?? "tool"}: ${safe.slice(0, 4000)}`)
|
|
1239
1265
|
if (toolEvidence.length > 8) toolEvidence.shift()
|
|
1240
1266
|
}
|
|
@@ -36,6 +36,7 @@ import { createAllTools } from "../tools/index.ts"
|
|
|
36
36
|
import { resolveUserId } from "../storage/onboarding"
|
|
37
37
|
import { getMCPManager as getSingletonMCPManager } from "../mcp/singleton"
|
|
38
38
|
import { syncMCPToolsToDB, syncMCPToolsToIndex } from "../mcp/tool-sync"
|
|
39
|
+
import { normalizeMcpResult } from "./mcp-result-normalizer"
|
|
39
40
|
import { getUserDate, getUserTime } from "../utils/date"
|
|
40
41
|
import { loadConfig } from "../config/loader"
|
|
41
42
|
import { getHiveDb } from "../storage/hivedb"
|
|
@@ -293,10 +294,20 @@ export async function compileContext(opts: {
|
|
|
293
294
|
name: fullName,
|
|
294
295
|
description: mcpTool.description || `Tool from ${server.name}`,
|
|
295
296
|
parameters: mcpTool.inputSchema || { type: "object", properties: {} },
|
|
296
|
-
execute: async (params: Record<string, unknown>) => {
|
|
297
|
+
execute: async (params: Record<string, unknown>, config?: { configurable?: Record<string, unknown> }) => {
|
|
297
298
|
// Return raw JS value — agent-loop will TOON-encode via formatToolResult.
|
|
298
299
|
// Never pre-stringify here: formatToolResult(string) double-encodes.
|
|
299
|
-
|
|
300
|
+
const raw = await effectiveMcpManager.callTool(resolvedServerKey, mcpTool.name, params)
|
|
301
|
+
// MCP results can carry base64 image/audio/blob content blocks —
|
|
302
|
+
// normalize those into artifact_ref pointers so a large binary
|
|
303
|
+
// result never gets serialized whole into the LLM context (see
|
|
304
|
+
// mcp-result-normalizer.ts for the incident this prevents).
|
|
305
|
+
const configurable = config?.configurable ?? {}
|
|
306
|
+
return await normalizeMcpResult(raw, {
|
|
307
|
+
userId: configurable.user_id ? String(configurable.user_id) : undefined,
|
|
308
|
+
runId: configurable.run_id ? String(configurable.run_id) : null,
|
|
309
|
+
taskId: configurable.task_id ? String(configurable.task_id) : null,
|
|
310
|
+
})
|
|
300
311
|
},
|
|
301
312
|
})
|
|
302
313
|
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mcp-result-normalizer — keeps large/binary MCP tool results out of the LLM
|
|
3
|
+
* context window.
|
|
4
|
+
*
|
|
5
|
+
* `MCPClientManager.callTool()` (packages/mcp/src/manager.ts) returns the raw
|
|
6
|
+
* `content` array from the MCP SDK's CallToolResult. Per the MCP spec that
|
|
7
|
+
* array can contain `image`/`audio` blocks (base64 `data`) or `resource`
|
|
8
|
+
* blocks (base64 `blob`) alongside plain `text` blocks. Nothing downstream
|
|
9
|
+
* (agent-loop.ts's formatToolResult) inspects those blocks — a base64 image
|
|
10
|
+
* would be serialized whole into a `role:"tool"` message and sent to the
|
|
11
|
+
* model, which is exactly what filled the context window and hung the agent
|
|
12
|
+
* in the incident this module fixes.
|
|
13
|
+
*
|
|
14
|
+
* This mirrors the pattern already used by browser-screenshot.ts: binary
|
|
15
|
+
* content gets persisted via createArtifact() (artifacts/store.ts) and the
|
|
16
|
+
* model only ever sees a lightweight { type: "artifact_ref", ... } reference.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { createArtifact } from "../artifacts/store";
|
|
20
|
+
import { logger } from "../utils/logger";
|
|
21
|
+
|
|
22
|
+
const log = logger.child("mcp-result-normalizer");
|
|
23
|
+
|
|
24
|
+
/** Blocks longer than this (in chars) get materialized as a text artifact instead of inlined. Override via HIVE_MCP_INLINE_MAX_CHARS. */
|
|
25
|
+
const MCP_INLINE_MAX_CHARS = Number(process.env.HIVE_MCP_INLINE_MAX_CHARS) || 20_000;
|
|
26
|
+
|
|
27
|
+
export interface McpNormalizeContext {
|
|
28
|
+
userId?: string;
|
|
29
|
+
runId?: string | null;
|
|
30
|
+
taskId?: string | null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
type McpContentBlock = Record<string, unknown> & { type?: unknown };
|
|
34
|
+
|
|
35
|
+
function isBinaryBlock(block: McpContentBlock): block is McpContentBlock & { type: "image" | "audio"; data: string; mimeType: string } {
|
|
36
|
+
return (block.type === "image" || block.type === "audio") && typeof block.data === "string";
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function isBlobResourceBlock(block: McpContentBlock): block is McpContentBlock & { type: "resource"; resource: { blob: string; mimeType?: string; uri?: string } } {
|
|
40
|
+
if (block.type !== "resource") return false;
|
|
41
|
+
const resource = block.resource as Record<string, unknown> | undefined;
|
|
42
|
+
return !!resource && typeof resource.blob === "string";
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function isOversizedTextBlock(block: McpContentBlock): block is McpContentBlock & { type: "text"; text: string } {
|
|
46
|
+
return block.type === "text" && typeof block.text === "string" && block.text.length > MCP_INLINE_MAX_CHARS;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async function materializeBinary(
|
|
50
|
+
bytesBase64: string,
|
|
51
|
+
mimeType: string,
|
|
52
|
+
kind: string,
|
|
53
|
+
ctx: McpNormalizeContext,
|
|
54
|
+
): Promise<Record<string, unknown>> {
|
|
55
|
+
if (!ctx.userId) {
|
|
56
|
+
// Without a user_id we can't set ownership on the artifact (inspectArtifact
|
|
57
|
+
// would reject any read against it later) — never let raw base64 through,
|
|
58
|
+
// just describe what was omitted.
|
|
59
|
+
const approxBytes = Math.floor((bytesBase64.length * 3) / 4);
|
|
60
|
+
log.warn(`[materializeBinary] No user_id in tool context — omitting ${mimeType} block (${approxBytes} bytes) instead of creating an artifact`);
|
|
61
|
+
return { type: "artifact_omitted", mime_type: mimeType, approx_size: approxBytes, reason: "no user_id in tool context" };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const bytes = Buffer.from(bytesBase64, "base64");
|
|
65
|
+
const artifact = await createArtifact({
|
|
66
|
+
bytes,
|
|
67
|
+
mimeType,
|
|
68
|
+
kind,
|
|
69
|
+
userId: ctx.userId,
|
|
70
|
+
runId: ctx.runId ?? null,
|
|
71
|
+
taskId: ctx.taskId ?? null,
|
|
72
|
+
});
|
|
73
|
+
log.info(`[materializeBinary] Stored ${kind} as artifact ${artifact.id} (${artifact.size} bytes, ${artifact.mime_type})`);
|
|
74
|
+
return {
|
|
75
|
+
type: "artifact_ref",
|
|
76
|
+
artifact_id: artifact.id,
|
|
77
|
+
mime_type: artifact.mime_type,
|
|
78
|
+
size: artifact.size,
|
|
79
|
+
sha256: artifact.sha256,
|
|
80
|
+
expires_at: artifact.expires_at,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async function materializeText(text: string, ctx: McpNormalizeContext): Promise<Record<string, unknown>> {
|
|
85
|
+
if (!ctx.userId) {
|
|
86
|
+
log.warn(`[materializeText] No user_id in tool context — truncating oversized text block (${text.length} chars) instead of creating an artifact`);
|
|
87
|
+
return { type: "text", text: `${text.slice(0, 500)}… [truncated: ${text.length} chars total, no user_id to persist full text as artifact]` };
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const artifact = await createArtifact({
|
|
91
|
+
bytes: Buffer.from(text, "utf-8"),
|
|
92
|
+
mimeType: "text/plain",
|
|
93
|
+
kind: "mcp_text_result",
|
|
94
|
+
userId: ctx.userId,
|
|
95
|
+
runId: ctx.runId ?? null,
|
|
96
|
+
taskId: ctx.taskId ?? null,
|
|
97
|
+
});
|
|
98
|
+
log.info(`[materializeText] Stored oversized text result as artifact ${artifact.id} (${artifact.size} bytes)`);
|
|
99
|
+
return {
|
|
100
|
+
type: "artifact_ref",
|
|
101
|
+
artifact_id: artifact.id,
|
|
102
|
+
mime_type: "text/plain",
|
|
103
|
+
size: artifact.size,
|
|
104
|
+
preview: text.length > 500 ? `${text.slice(0, 500)}…` : text,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Normalizes a raw MCP CallToolResult.content array: binary blocks (image,
|
|
110
|
+
* audio, resource-with-blob) become { type: "artifact_ref", ... }, oversized
|
|
111
|
+
* text blocks are persisted the same way with a short preview kept inline,
|
|
112
|
+
* everything else (text, resource_link) passes through unchanged.
|
|
113
|
+
*
|
|
114
|
+
* Never pre-stringifies — returns JS values so formatToolResult (toon.ts)
|
|
115
|
+
* keeps doing the actual TOON/JSON encoding, same contract context-compiler.ts
|
|
116
|
+
* already documents for MCP tool executors.
|
|
117
|
+
*/
|
|
118
|
+
export async function normalizeMcpResult(content: unknown, ctx: McpNormalizeContext): Promise<unknown> {
|
|
119
|
+
if (!Array.isArray(content)) return content;
|
|
120
|
+
|
|
121
|
+
const out: unknown[] = [];
|
|
122
|
+
for (const raw of content) {
|
|
123
|
+
if (!raw || typeof raw !== "object") {
|
|
124
|
+
out.push(raw);
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
const block = raw as McpContentBlock;
|
|
128
|
+
try {
|
|
129
|
+
if (isBinaryBlock(block)) {
|
|
130
|
+
out.push(await materializeBinary(block.data, block.mimeType, "mcp_result", ctx));
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
if (isBlobResourceBlock(block)) {
|
|
134
|
+
const mimeType = block.resource.mimeType || "application/octet-stream";
|
|
135
|
+
out.push(await materializeBinary(block.resource.blob, mimeType, "mcp_result", ctx));
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
if (isOversizedTextBlock(block)) {
|
|
139
|
+
out.push(await materializeText(block.text, ctx));
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
} catch (err) {
|
|
143
|
+
log.error(`[normalizeMcpResult] Failed to materialize block (type=${String(block.type)}): ${(err as Error).message}`);
|
|
144
|
+
out.push({ type: "artifact_error", mime_type: (block as { mimeType?: string }).mimeType, error: (err as Error).message });
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
out.push(block);
|
|
148
|
+
}
|
|
149
|
+
return out;
|
|
150
|
+
}
|
|
@@ -62,6 +62,8 @@ export interface ModelResponse {
|
|
|
62
62
|
totalTokens: number
|
|
63
63
|
}
|
|
64
64
|
finishReason?: string
|
|
65
|
+
/** Image artifacts (mcp-result-normalizer.ts, agent-loop.ts's turnImageArtifacts) produced by tools this turn. */
|
|
66
|
+
imageArtifacts?: Array<{ artifactId: string; mimeType: string }>
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
export class AgentRunner {
|
|
@@ -92,6 +94,7 @@ export class AgentRunner {
|
|
|
92
94
|
let toolCalls: ModelResponse["toolCalls"] = []
|
|
93
95
|
let totalInputTokens = 0
|
|
94
96
|
let totalOutputTokens = 0
|
|
97
|
+
let imageArtifacts: ModelResponse["imageArtifacts"]
|
|
95
98
|
|
|
96
99
|
try {
|
|
97
100
|
const stream = agentLoop.stream(
|
|
@@ -190,6 +193,10 @@ export class AgentRunner {
|
|
|
190
193
|
totalInputTokens += chunk.usage.input_tokens
|
|
191
194
|
totalOutputTokens += chunk.usage.output_tokens
|
|
192
195
|
}
|
|
196
|
+
|
|
197
|
+
if (chunk.artifacts?.images?.length) {
|
|
198
|
+
imageArtifacts = [...(imageArtifacts ?? []), ...chunk.artifacts.images]
|
|
199
|
+
}
|
|
193
200
|
}
|
|
194
201
|
|
|
195
202
|
logger.debug(`[STREAM] done. totalChunks=${chunkCount} lastAgentContent length=${lastAgentContent.length}, accumulated length=${accumulatedAgentContent.length}`)
|
|
@@ -208,6 +215,7 @@ export class AgentRunner {
|
|
|
208
215
|
totalTokens: totalInputTokens + totalOutputTokens,
|
|
209
216
|
},
|
|
210
217
|
finishReason: "stop",
|
|
218
|
+
imageArtifacts,
|
|
211
219
|
}
|
|
212
220
|
} catch (error) {
|
|
213
221
|
logger.error("AgentRunner error:", error)
|
|
@@ -91,6 +91,22 @@ export async function createArtifact(input: {
|
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
/**
|
|
95
|
+
* Reads an artifact's bytes straight off disk — for server-side consumers
|
|
96
|
+
* that don't need an HTTP round trip (routes/artifacts.ts is for the
|
|
97
|
+
* browser; channels/*.ts send()s use this directly to build a Telegram/
|
|
98
|
+
* Discord/Slack/WhatsApp photo attachment from the same file).
|
|
99
|
+
*/
|
|
100
|
+
export async function readArtifactBytes(
|
|
101
|
+
artifactId: string,
|
|
102
|
+
): Promise<{ bytes: Buffer; mimeType: string } | null> {
|
|
103
|
+
const artifacts = await col<ArtifactDoc>("artifacts");
|
|
104
|
+
const entry = await artifacts.get(artifactId);
|
|
105
|
+
if (!entry || entry.doc.status !== "active") return null;
|
|
106
|
+
if (!existsSync(entry.doc.path)) return null;
|
|
107
|
+
return { bytes: readFileSync(entry.doc.path), mimeType: entry.doc.mime_type };
|
|
108
|
+
}
|
|
109
|
+
|
|
94
110
|
export async function inspectArtifact(
|
|
95
111
|
artifactId: string,
|
|
96
112
|
options: { userId?: string } = {},
|
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
import { readArtifactBytes } from "../artifacts/store";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Resolves an OutboundMessage.image to raw bytes for channels that need to
|
|
5
|
+
* upload a photo directly (Telegram/Discord/Slack/WhatsApp) — prefers the
|
|
6
|
+
* artifact on disk (artifactId, the common path from mcp-result-normalizer.ts
|
|
7
|
+
* results) over an inline base64 payload.
|
|
8
|
+
*/
|
|
9
|
+
export async function readOutboundImageBytes(
|
|
10
|
+
image: NonNullable<OutboundMessage["image"]>,
|
|
11
|
+
): Promise<Buffer | null> {
|
|
12
|
+
if (image.artifactId) {
|
|
13
|
+
const artifact = await readArtifactBytes(image.artifactId);
|
|
14
|
+
if (artifact) return artifact.bytes;
|
|
15
|
+
}
|
|
16
|
+
if (image.base64) return Buffer.from(image.base64, "base64");
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
|
|
1
20
|
export interface OutboundMessage {
|
|
2
21
|
type: "message" | "stream" | "status" | "error" | "pong" | "command_result" | "log" | "typing" | "audio" | "process" | "progress" | "notification";
|
|
3
22
|
sessionId: string;
|
|
@@ -19,6 +38,20 @@ export interface OutboundMessage {
|
|
|
19
38
|
base64?: string;
|
|
20
39
|
mimeType?: string;
|
|
21
40
|
};
|
|
41
|
+
/** Image artifact to show alongside the response (e.g. an MCP image-generation tool's result — see mcp-result-normalizer.ts). `url` points at the artifacts download endpoint (webchat/HTTP consumers); `artifactId` lets server-side channels (Telegram/Discord/Slack/WhatsApp) read the bytes straight off disk via artifacts/store.ts's readArtifactBytes — no HTTP round trip needed since they run in the same process. */
|
|
42
|
+
image?: {
|
|
43
|
+
artifactId?: string;
|
|
44
|
+
url?: string;
|
|
45
|
+
base64?: string;
|
|
46
|
+
mimeType?: string;
|
|
47
|
+
caption?: string;
|
|
48
|
+
};
|
|
49
|
+
document?: {
|
|
50
|
+
url?: string;
|
|
51
|
+
base64?: string;
|
|
52
|
+
mimeType?: string;
|
|
53
|
+
filename?: string;
|
|
54
|
+
};
|
|
22
55
|
status?: {
|
|
23
56
|
state: string;
|
|
24
57
|
model?: 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 } from "./base.ts";
|
|
10
|
+
import { BaseChannel, type ChannelConfig, type IncomingMessage, type OutboundMessage, readOutboundImageBytes } 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";
|
|
@@ -207,9 +207,28 @@ export class DiscordChannel extends BaseChannel {
|
|
|
207
207
|
throw new Error(`Channel not found for session: ${sessionId}`);
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
+
if (message.image) {
|
|
211
|
+
try {
|
|
212
|
+
const bytes = await readOutboundImageBytes(message.image);
|
|
213
|
+
if (bytes) {
|
|
214
|
+
const ext = message.image.mimeType === "image/jpeg" ? "jpg" : message.image.mimeType === "image/webp" ? "webp" : "png";
|
|
215
|
+
await channel.send({
|
|
216
|
+
content: message.image.caption,
|
|
217
|
+
files: [{ attachment: bytes, name: `image.${ext}` }],
|
|
218
|
+
});
|
|
219
|
+
} else {
|
|
220
|
+
this.log.warn(`Image artifact unavailable, skipping photo send`, { sessionId });
|
|
221
|
+
}
|
|
222
|
+
} catch (error) {
|
|
223
|
+
this.log.error(`Failed to send Discord image: ${(error as Error).message}`);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
210
227
|
const content = message.content ?? "";
|
|
211
228
|
const maxLength = 2000;
|
|
212
229
|
|
|
230
|
+
if (!content) return;
|
|
231
|
+
|
|
213
232
|
try {
|
|
214
233
|
if (content.length <= maxLength) {
|
|
215
234
|
await channel.send(content);
|
|
@@ -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 } from "./base.ts";
|
|
3
|
+
import { BaseChannel, readOutboundImageBytes } 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";
|
|
@@ -260,10 +260,29 @@ await this.handleMessage(incoming);
|
|
|
260
260
|
throw new Error("Slack not connected");
|
|
261
261
|
}
|
|
262
262
|
|
|
263
|
+
const peerId = this.extractPeerId(sessionId);
|
|
264
|
+
|
|
265
|
+
if (message.image) {
|
|
266
|
+
try {
|
|
267
|
+
const bytes = await readOutboundImageBytes(message.image);
|
|
268
|
+
if (bytes) {
|
|
269
|
+
await this.app.client.files.uploadV2({
|
|
270
|
+
channel_id: peerId,
|
|
271
|
+
file: bytes,
|
|
272
|
+
filename: `image.${message.image.mimeType === "image/jpeg" ? "jpg" : message.image.mimeType === "image/webp" ? "webp" : "png"}`,
|
|
273
|
+
title: message.image.caption ?? "Image response",
|
|
274
|
+
});
|
|
275
|
+
} else {
|
|
276
|
+
this.log.warn(`Image artifact unavailable, skipping photo send`, { sessionId });
|
|
277
|
+
}
|
|
278
|
+
} catch (error) {
|
|
279
|
+
this.log.error(`Failed to send Slack image: ${(error as Error).message}`);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
263
283
|
const text = message.content ?? message.chunk ?? "";
|
|
264
284
|
if (!text) return;
|
|
265
285
|
|
|
266
|
-
const peerId = this.extractPeerId(sessionId);
|
|
267
286
|
const pending = this.pendingMessages.get(sessionId);
|
|
268
287
|
|
|
269
288
|
try {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Bot, GrammyError, InputFile, type Context } from "grammy";
|
|
2
|
-
import { BaseChannel, type ChannelConfig, type IncomingMessage, type OutboundMessage } from "./base.ts";
|
|
2
|
+
import { BaseChannel, type ChannelConfig, type IncomingMessage, type OutboundMessage, readOutboundImageBytes } 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";
|
|
@@ -404,6 +404,21 @@ export class TelegramChannel extends BaseChannel {
|
|
|
404
404
|
throw new Error(`Invalid chat ID from session: ${sessionId}`);
|
|
405
405
|
}
|
|
406
406
|
|
|
407
|
+
if (message.image) {
|
|
408
|
+
try {
|
|
409
|
+
const bytes = await readOutboundImageBytes(message.image);
|
|
410
|
+
if (bytes) {
|
|
411
|
+
await this.bot.api.sendPhoto(chatId, new InputFile(bytes), {
|
|
412
|
+
caption: message.image.caption,
|
|
413
|
+
});
|
|
414
|
+
} else {
|
|
415
|
+
this.log.warn(`Image artifact unavailable, skipping photo send`, { sessionId });
|
|
416
|
+
}
|
|
417
|
+
} catch (error) {
|
|
418
|
+
this.log.error(`Telegram sendPhoto failed: ${(error as Error).message}`);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
407
422
|
const content = message.content ?? "";
|
|
408
423
|
|
|
409
424
|
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 } from "./base.ts";
|
|
11
|
+
import { BaseChannel, readOutboundImageBytes } 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";
|
|
@@ -488,11 +488,24 @@ export class WhatsAppChannel extends BaseChannel {
|
|
|
488
488
|
const isInterim = message.type === "progress";
|
|
489
489
|
if (!isInterim) await this.stopTyping(sessionId);
|
|
490
490
|
|
|
491
|
+
const jid = this.getJid(sessionId);
|
|
492
|
+
|
|
493
|
+
if (message.image) {
|
|
494
|
+
try {
|
|
495
|
+
const bytes = await readOutboundImageBytes(message.image);
|
|
496
|
+
if (bytes) {
|
|
497
|
+
await this.socket.sendMessage(jid, { image: bytes, caption: message.image.caption });
|
|
498
|
+
} else {
|
|
499
|
+
this.log.warn(`Image artifact unavailable, skipping photo send`, { sessionId });
|
|
500
|
+
}
|
|
501
|
+
} catch (error) {
|
|
502
|
+
this.log.error(`Failed to send WhatsApp image: ${(error as Error).message}`);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
|
|
491
506
|
const text = message.content ?? message.chunk ?? "";
|
|
492
507
|
if (!text) return;
|
|
493
508
|
|
|
494
|
-
const jid = this.getJid(sessionId);
|
|
495
|
-
|
|
496
509
|
await this.socket.sendMessage(jid, { text });
|
|
497
510
|
if (isInterim) await this.startTyping(sessionId);
|
|
498
511
|
this.log.debug(`Sent message to ${jid}`);
|
|
@@ -92,7 +92,8 @@ export function registerTerminalHook(type: JobType, hook: JobTerminalHook): void
|
|
|
92
92
|
terminalHooks.set(type, hook);
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
|
|
95
|
+
/** Exported so job-store.ts's reclaimOrInterrupt can fire it too (dynamic import there — see its call site — avoids a static circular import since this module already imports reclaimOrInterrupt from job-store.ts). */
|
|
96
|
+
export async function runTerminalHook(job: JobDoc, outcome: JobTerminalOutcome): Promise<void> {
|
|
96
97
|
const hook = terminalHooks.get(job.type);
|
|
97
98
|
if (!hook) return;
|
|
98
99
|
try {
|