@johpaz/hive-agents 1.0.1 → 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 +1286 -764
- package/dist/ui/assets/A2UIPage-DExwevBV.js +8 -0
- package/dist/ui/assets/{AgentCreateForm-M2RhjeA1.js → AgentCreateForm-7PPShsUn.js} +1 -1
- package/dist/ui/assets/{AgentDetailPage-DkFRtj8g.js → AgentDetailPage-CiV4tz4P.js} +1 -1
- package/dist/ui/assets/AgentNewPage-D3TtVwQf.js +1 -0
- package/dist/ui/assets/{AgentsPage-Ctzq2LWx.js → AgentsPage-C2DThet7.js} +1 -1
- package/dist/ui/assets/{ApiClientPage-DKbGO1QW.js → ApiClientPage-Cowdq-0f.js} +1 -1
- package/dist/ui/assets/{ChannelsPage-H6rgr8DQ.js → ChannelsPage-D4IgglwJ.js} +1 -1
- package/dist/ui/assets/{DashboardPage-BIjYGf4m.js → DashboardPage-DAgVB7Iy.js} +1 -1
- package/dist/ui/assets/{LoginPage-DazoxtBJ.js → LoginPage-CpU61b3u.js} +1 -1
- package/dist/ui/assets/{LogsPage-DMZ6KtQ3.js → LogsPage-DyJOGQNy.js} +1 -1
- package/dist/ui/assets/{MeetingPage-CSLFvHL7.js → MeetingPage-DLmqHmm2.js} +1 -1
- package/dist/ui/assets/{ModelSelector-BCfvugHB.js → ModelSelector-D4OaICwN.js} +1 -1
- package/dist/ui/assets/{Office3DPage-BE6Epe0d.js → Office3DPage-BvO66B0h.js} +1 -1
- package/dist/ui/assets/{ProvidersPage-D0cApfM1.js → ProvidersPage-Bhb6Qr87.js} +1 -1
- package/dist/ui/assets/{RecoverPage-BVUPHG9z.js → RecoverPage-DaZrCpdB.js} +1 -1
- package/dist/ui/assets/SettingsPage-BRD2F7up.js +9 -0
- package/dist/ui/assets/{SetupPage-In19p30M.js → SetupPage-DKppgTja.js} +1 -1
- package/dist/ui/assets/WebChatPage-CPtETNL5.js +29 -0
- package/dist/ui/assets/{activity-BIIli7ET.js → activity-BSosMryb.js} +1 -1
- package/dist/ui/assets/{agentCapabilities-D1PD9yFH.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-S9-_Q6QR.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-DTVW4R94.js → circle-alert-CYt6gsDA.js} +1 -1
- package/dist/ui/assets/circle-check-Zl32-jCa.js +1 -0
- package/dist/ui/assets/{circle-x-CJXbXzRh.js → circle-x-BJXzKGmx.js} +1 -1
- package/dist/ui/assets/{copy-X_TPpA-A.js → copy-BmtJXmDe.js} +1 -1
- package/dist/ui/assets/{dialog-uUBz_NIB.js → dialog-Dn9hGPYl.js} +1 -1
- package/dist/ui/assets/{download-C-fXu08w.js → download-D3mYhuuL.js} +1 -1
- package/dist/ui/assets/{earth-CTsVjCmp.js → earth-BZzdDXFC.js} +1 -1
- package/dist/ui/assets/{ellipsis-vertical-5zBh5yzc.js → ellipsis-vertical-BF705XvB.js} +1 -1
- package/dist/ui/assets/{external-link-CvpRhwC_.js → external-link-gdpMTHUV.js} +1 -1
- package/dist/ui/assets/{eye-CM-HQEWU.js → eye-lSG04hI7.js} +1 -1
- package/dist/ui/assets/{file-text-lwkvYGtA.js → file-text-CjQxcJvN.js} +1 -1
- package/dist/ui/assets/gauge-DBryKhDK.js +1 -0
- package/dist/ui/assets/{history-eSHspWRr.js → history-BC6ir9qU.js} +1 -1
- package/dist/ui/assets/{index-ZjAc-KQS.js → index-DyxoAvTq.js} +2 -2
- package/dist/ui/assets/index-wML8DaUo.css +2 -0
- package/dist/ui/assets/{info-DTgFQ_jA.js → info-BGBaIyKc.js} +1 -1
- package/dist/ui/assets/{key-CeM9JJkq.js → key-D_CNJTY2.js} +1 -1
- package/dist/ui/assets/loader-circle-RXdrfPsH.js +1 -0
- package/dist/ui/assets/{lock-open-B089GUAJ.js → lock-open-UB61lorP.js} +1 -1
- package/dist/ui/assets/{mail--gNFIe4M.js → mail-C5bJ_dBt.js} +1 -1
- package/dist/ui/assets/{pause-DjT1nwQM.js → pause-BSTJvxDu.js} +1 -1
- package/dist/ui/assets/{pencil-6PRgdjiU.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-D-joO9J0.js → radio-D9CrjAar.js} +1 -1
- package/dist/ui/assets/{refresh-cw-BRrzoHQW.js → refresh-cw-D7EB_fVv.js} +1 -1
- package/dist/ui/assets/search-5S6LY69I.js +1 -0
- package/dist/ui/assets/{select-BOR8MsSL.js → select-ot0a6art.js} +1 -1
- package/dist/ui/assets/{send-DIlj81PT.js → send-Dax1tJ5b.js} +1 -1
- package/dist/ui/assets/{settings-CkBjgAEm.js → settings-97CL32lC.js} +1 -1
- package/dist/ui/assets/{shield-U0hIjGzm.js → shield-DwbCEZbF.js} +1 -1
- package/dist/ui/assets/{sparkles-VXHGDbNh.js → sparkles-CWMAzkpD.js} +1 -1
- package/dist/ui/assets/{square-OHeetvN3.js → square-B4dgTXI3.js} +1 -1
- package/dist/ui/assets/terminal-DoLedTPM.js +1 -0
- package/dist/ui/assets/{trash-2-DQxm7DUM.js → trash-2-DxnVYOz8.js} +1 -1
- package/dist/ui/assets/{triangle-alert-Dj8ZhmWj.js → triangle-alert-Cka-BeIE.js} +1 -1
- package/dist/ui/assets/{useHiveAgentsModelLoad-COLvs-Ho.js → useHiveAgentsModelLoad-BjnIsQKR.js} +1 -1
- package/dist/ui/assets/{useProviders-q6iROeWE.js → useProviders-CueMz_mL.js} +1 -1
- package/dist/ui/assets/{volume-x-Bm735CXN.js → volume-x-DLsli9cf.js} +1 -1
- package/dist/ui/assets/{wifi-DklBfOZ6.js → wifi-BQRJGfLZ.js} +1 -1
- package/dist/ui/assets/{zap-BEZNJ0i0.js → zap-DSR3CEce.js} +1 -1
- package/dist/ui/index.html +2 -2
- package/package.json +1 -1
- package/packages/cli/src/index.ts +23 -17
- 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/canvas/canvas-manager.ts +36 -7
- 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/a2ui.ts +43 -0
- package/packages/core/src/gateway/routes/artifacts.ts +60 -0
- package/packages/core/src/gateway/routes/runtime.ts +58 -0
- package/packages/core/src/gateway/routes/setup.ts +127 -108
- package/packages/core/src/gateway/server.ts +52 -5
- package/packages/core/src/gateway/webchat-turn.ts +40 -1
- package/packages/core/src/storage/onboarding.ts +23 -7
- package/packages/core/src/storage/seed.ts +31 -2
- package/packages/core/src/utils/redact-binary.ts +17 -0
- package/dist/ui/assets/A2UIPage-D4nzp5NV.js +0 -8
- package/dist/ui/assets/AgentNewPage-CfBU7puz.js +0 -1
- package/dist/ui/assets/SettingsPage-DCZ4nql4.js +0 -9
- package/dist/ui/assets/WebChatPage-ByVBSzxL.js +0 -29
- package/dist/ui/assets/arrow-left-BfcnX8Er.js +0 -1
- package/dist/ui/assets/arrow-right-Q-dzAn8k.js +0 -1
- package/dist/ui/assets/arrow-up-right-Bf-8wrUQ.js +0 -1
- package/dist/ui/assets/check-CryV78SQ.js +0 -1
- package/dist/ui/assets/chevron-down-QCtMs-Af.js +0 -1
- package/dist/ui/assets/chevron-left-dTGbyl5G.js +0 -1
- package/dist/ui/assets/chevron-right-D0GjXbnO.js +0 -1
- package/dist/ui/assets/chevron-up-Cg0jO8uT.js +0 -1
- package/dist/ui/assets/circle-check-BAolxswA.js +0 -1
- package/dist/ui/assets/gauge-CB-cas-h.js +0 -1
- package/dist/ui/assets/index-D489S18g.css +0 -2
- package/dist/ui/assets/loader-circle-Dtfz4FWw.js +0 -1
- package/dist/ui/assets/play-tOrP0xUJ.js +0 -1
- package/dist/ui/assets/plus-Cnom3j47.js +0 -1
- package/dist/ui/assets/search-D277MUP0.js +0 -1
- package/dist/ui/assets/terminal-C6YPcJl_.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-COLvs-Ho.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">
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
<link rel="modulepreload" crossorigin href="/assets/vendor-react-CPJEWbIG.js">
|
|
34
34
|
<link rel="modulepreload" crossorigin href="/assets/utils-Dyb7SC2_.js">
|
|
35
35
|
<link rel="modulepreload" crossorigin href="/assets/gateway-url-BlnabM5e.js">
|
|
36
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
36
|
+
<link rel="stylesheet" crossorigin href="/assets/index-wML8DaUo.css">
|
|
37
37
|
</head>
|
|
38
38
|
|
|
39
39
|
<body>
|
package/package.json
CHANGED
|
@@ -109,17 +109,23 @@ Examples:
|
|
|
109
109
|
`;
|
|
110
110
|
|
|
111
111
|
async function main(): Promise<void> {
|
|
112
|
-
//
|
|
113
|
-
//
|
|
114
|
-
//
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
112
|
+
// Bun uses different argv layouts for `bun script.ts`, `bun run`, and
|
|
113
|
+
// compiled binaries. A compiled binary can inject its bundled entrypoint
|
|
114
|
+
// (for example `/$bunfs/root/index.js`) before the real arguments. Find the
|
|
115
|
+
// first known CLI token instead of assuming a fixed offset.
|
|
116
|
+
const commandTokens = new Set([
|
|
117
|
+
"dev", "start", "stop", "reload", "status", "chat", "logs", "message",
|
|
118
|
+
"agent", "agents", "mcp", "skills", "config", "sessions", "cron", "causal",
|
|
119
|
+
"doctor", "security", "install-service", "update", "migrate",
|
|
120
|
+
"--version", "-v", "version", "--help", "-h", "help",
|
|
121
|
+
]);
|
|
122
|
+
const rawArgs = process.argv.slice(1);
|
|
123
|
+
const commandIndex = rawArgs.findIndex((arg) => commandTokens.has(arg));
|
|
124
|
+
const normalizedArgs = commandIndex >= 0 ? rawArgs.slice(commandIndex) : rawArgs;
|
|
120
125
|
const command = normalizedArgs[0];
|
|
121
126
|
const subcommand = normalizedArgs[1];
|
|
122
127
|
const flags = normalizedArgs.filter((a) => a.startsWith("--"));
|
|
128
|
+
const commandArgs = normalizedArgs.slice(2);
|
|
123
129
|
|
|
124
130
|
switch (command) {
|
|
125
131
|
case "dev":
|
|
@@ -144,31 +150,31 @@ async function main(): Promise<void> {
|
|
|
144
150
|
await logs(flags);
|
|
145
151
|
break;
|
|
146
152
|
case "message":
|
|
147
|
-
await message(subcommand,
|
|
153
|
+
await message(subcommand, commandArgs);
|
|
148
154
|
break;
|
|
149
155
|
case "agent":
|
|
150
|
-
await agent(subcommand,
|
|
156
|
+
await agent(subcommand, commandArgs);
|
|
151
157
|
break;
|
|
152
158
|
case "agents":
|
|
153
|
-
await agents(subcommand,
|
|
159
|
+
await agents(subcommand, commandArgs);
|
|
154
160
|
break;
|
|
155
161
|
case "mcp":
|
|
156
|
-
await mcp(subcommand,
|
|
162
|
+
await mcp(subcommand, commandArgs);
|
|
157
163
|
break;
|
|
158
164
|
case "skills":
|
|
159
|
-
await skills(subcommand,
|
|
165
|
+
await skills(subcommand, commandArgs);
|
|
160
166
|
break;
|
|
161
167
|
case "config":
|
|
162
|
-
await config(subcommand,
|
|
168
|
+
await config(subcommand, commandArgs);
|
|
163
169
|
break;
|
|
164
170
|
case "sessions":
|
|
165
|
-
await sessions(subcommand,
|
|
171
|
+
await sessions(subcommand, commandArgs);
|
|
166
172
|
break;
|
|
167
173
|
case "cron":
|
|
168
|
-
await cron(subcommand,
|
|
174
|
+
await cron(subcommand, commandArgs);
|
|
169
175
|
break;
|
|
170
176
|
case "causal":
|
|
171
|
-
await causal(subcommand,
|
|
177
|
+
await causal(subcommand, commandArgs);
|
|
172
178
|
break;
|
|
173
179
|
case "doctor":
|
|
174
180
|
await doctor();
|
|
@@ -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 } = {},
|
|
@@ -7,6 +7,14 @@ export interface WebSocketLike {
|
|
|
7
7
|
close(code?: number, reason?: string): void;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
export interface A2UISurfaceInfo {
|
|
11
|
+
surfaceId: string;
|
|
12
|
+
catalogId?: string;
|
|
13
|
+
theme?: Record<string, unknown>;
|
|
14
|
+
hasComponents: boolean;
|
|
15
|
+
hasDataModel: boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
10
18
|
export const WebSocketState = {
|
|
11
19
|
CONNECTING: 0,
|
|
12
20
|
OPEN: 1,
|
|
@@ -22,7 +30,10 @@ interface A2UISurfaceCache {
|
|
|
22
30
|
|
|
23
31
|
export class CanvasManager {
|
|
24
32
|
private sessions: Map<string, WebSocketLike> = new Map();
|
|
25
|
-
|
|
33
|
+
// Surfaces belong to a canvas session. Keeping this scoped prevents a
|
|
34
|
+
// desktop reconnect (or another user) from receiving a surface addressed
|
|
35
|
+
// to a different session and makes surface discovery deterministic.
|
|
36
|
+
private a2uiCache: Map<string, Map<string, A2UISurfaceCache>> = new Map();
|
|
26
37
|
private log = logger.child("canvas");
|
|
27
38
|
private heartbeatInterval: ReturnType<typeof setInterval> | null = null;
|
|
28
39
|
|
|
@@ -69,8 +80,11 @@ export class CanvasManager {
|
|
|
69
80
|
// Notify the client that the session is registered
|
|
70
81
|
ws.send(JSON.stringify({ type: "canvas:connected", sessionId }));
|
|
71
82
|
|
|
72
|
-
// Replay
|
|
73
|
-
|
|
83
|
+
// Replay cached A2UI surfaces for this session so late-connecting clients
|
|
84
|
+
// get current state without leaking another session's surfaces.
|
|
85
|
+
const sessionSurfaces = this.a2uiCache.get(sessionId) ?? new Map();
|
|
86
|
+
this.a2uiCache.set(sessionId, sessionSurfaces);
|
|
87
|
+
for (const [surfaceId, cache] of sessionSurfaces) {
|
|
74
88
|
try {
|
|
75
89
|
ws.send(JSON.stringify({ type: "a2ui:createSurface", data: cache.createData }));
|
|
76
90
|
if (cache.components && cache.components.length > 0) {
|
|
@@ -96,13 +110,15 @@ export class CanvasManager {
|
|
|
96
110
|
// Update A2UI cache so late-connecting clients can receive current state
|
|
97
111
|
const surfaceId = data.surfaceId as string | undefined;
|
|
98
112
|
if (surfaceId) {
|
|
113
|
+
const sessionSurfaces = this.a2uiCache.get(sessionId) ?? new Map<string, A2UISurfaceCache>();
|
|
114
|
+
this.a2uiCache.set(sessionId, sessionSurfaces);
|
|
99
115
|
if (messageType === "a2ui:createSurface") {
|
|
100
|
-
|
|
116
|
+
sessionSurfaces.set(surfaceId, { createData: data });
|
|
101
117
|
} else if (messageType === "a2ui:updateComponents") {
|
|
102
|
-
const cached =
|
|
118
|
+
const cached = sessionSurfaces.get(surfaceId);
|
|
103
119
|
if (cached) cached.components = data.components as unknown[];
|
|
104
120
|
} else if (messageType === "a2ui:updateDataModel") {
|
|
105
|
-
const cached =
|
|
121
|
+
const cached = sessionSurfaces.get(surfaceId);
|
|
106
122
|
if (cached) {
|
|
107
123
|
const path = data.path as string | undefined;
|
|
108
124
|
const value = data.value as Record<string, unknown>;
|
|
@@ -116,7 +132,7 @@ export class CanvasManager {
|
|
|
116
132
|
}
|
|
117
133
|
}
|
|
118
134
|
} else if (messageType === "a2ui:deleteSurface") {
|
|
119
|
-
|
|
135
|
+
sessionSurfaces.delete(surfaceId);
|
|
120
136
|
}
|
|
121
137
|
}
|
|
122
138
|
|
|
@@ -150,6 +166,19 @@ export class CanvasManager {
|
|
|
150
166
|
};
|
|
151
167
|
}
|
|
152
168
|
|
|
169
|
+
getA2UISurfaces(sessionId: string): A2UISurfaceInfo[] {
|
|
170
|
+
const surfaces = this.a2uiCache.get(sessionId);
|
|
171
|
+
if (!surfaces) return [];
|
|
172
|
+
|
|
173
|
+
return Array.from(surfaces.entries()).map(([surfaceId, cache]) => ({
|
|
174
|
+
surfaceId,
|
|
175
|
+
catalogId: cache.createData.catalogId as string | undefined,
|
|
176
|
+
theme: cache.createData.theme as Record<string, unknown> | undefined,
|
|
177
|
+
hasComponents: Boolean(cache.components?.length),
|
|
178
|
+
hasDataModel: Boolean(cache.dataModel && Object.keys(cache.dataModel).length > 0),
|
|
179
|
+
}));
|
|
180
|
+
}
|
|
181
|
+
|
|
153
182
|
clearAll(): void {
|
|
154
183
|
this.stopHeartbeat();
|
|
155
184
|
this.sessions.clear();
|
|
@@ -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;
|