bazilion 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (217) hide show
  1. package/README.md +47 -5
  2. package/dist/cli.js +1190 -640
  3. package/dist/cli.js.map +1 -1
  4. package/dist/daemon.js +5165 -1598
  5. package/dist/daemon.js.map +1 -1
  6. package/dist/migrations/0001_init.sql +318 -88
  7. package/dist/web/client/assets/AgentTabs-B3hq5a3e.js +1 -0
  8. package/dist/web/client/assets/ConfigPage-BCwfgyjD.js +1 -0
  9. package/dist/web/client/assets/FieldRow-avAFLgYW.js +1 -0
  10. package/dist/web/client/assets/Page-CwNuDhWz.js +1 -0
  11. package/dist/web/client/assets/ProductionTeamPolicyEditor-CiQ-VVDo.js +7 -0
  12. package/dist/web/client/assets/ProductionTeamPolicyEditor-DLioOiRN.css +1 -0
  13. package/dist/web/client/assets/ProfileCommunicationEditor-D84F5yfr.js +1 -0
  14. package/dist/web/client/assets/RecoveryState-QfMSuwy3.js +1 -0
  15. package/dist/web/client/assets/SectionTabs-DZzy01az.js +1 -0
  16. package/dist/web/client/assets/TeamTabs-Btoe_FAE.js +1 -0
  17. package/dist/web/client/assets/TemplatesTabs-CAYY03F5.js +1 -0
  18. package/dist/web/client/assets/_id-BeauECmk.js +1 -0
  19. package/dist/web/client/assets/_id-BqU2BodK.js +1 -0
  20. package/dist/web/client/assets/_id-CKtoio3t.js +1 -0
  21. package/dist/web/client/assets/_id-DGyKURCp.js +1 -0
  22. package/dist/web/client/assets/_id-Q98Of6k9.js +1 -0
  23. package/dist/web/client/assets/activity-DJuhhQCb.js +1 -0
  24. package/dist/web/client/assets/activity-DXN_N85w.js +1 -0
  25. package/dist/web/client/assets/agents-C5Xsdge1.js +1 -0
  26. package/dist/web/client/assets/agents-Cgxo4H5G.js +1 -0
  27. package/dist/web/client/assets/approvals-BnG7fbw-.js +1 -0
  28. package/dist/web/client/assets/approvals-DGi0PSx8.js +1 -0
  29. package/dist/web/client/assets/chevron-down-BhcBspw3.js +1 -0
  30. package/dist/web/client/assets/config-xw4NyrXF.js +3 -0
  31. package/dist/web/client/assets/context-D2V1Oi4z.js +1 -0
  32. package/dist/web/client/assets/inbox-DK6hWCMp.js +1 -0
  33. package/dist/web/client/assets/index-VdURSoM4.js +12 -0
  34. package/dist/web/client/assets/login-CvptUoMR.js +1 -0
  35. package/dist/web/client/assets/mcp-BDFM_sW-.js +1 -0
  36. package/dist/web/client/assets/members-BJvph_TR.js +1 -0
  37. package/dist/web/client/assets/memory-DRytqZCD.js +1 -0
  38. package/dist/web/client/assets/plus-C9ee3SIO.js +1 -0
  39. package/dist/web/client/assets/policy-CGP50OtQ.js +1 -0
  40. package/dist/web/client/assets/policy-K4hIbbIN.js +1 -0
  41. package/dist/web/client/assets/preload-helper-mNuBjNXU.js +1 -0
  42. package/dist/web/client/assets/react-3W8R1pOO.js +1 -0
  43. package/dist/web/client/assets/routes-DJnWYvC9.js +1 -0
  44. package/dist/web/client/assets/services-DHheiv7L.js +1 -0
  45. package/dist/web/client/assets/skills-DmsitluU.js +1 -0
  46. package/dist/web/client/assets/styles-B5eQAwLP.css +2 -0
  47. package/dist/web/client/assets/team-policy-D0jpnn2b.js +1 -0
  48. package/dist/web/client/assets/teams-BdC4gthq.js +1 -0
  49. package/dist/web/client/assets/teams-CSNyLz3l.js +1 -0
  50. package/dist/web/client/assets/teams-CbxSaorm.js +1 -0
  51. package/dist/web/client/assets/telegram-D61G_alO.js +1 -0
  52. package/dist/web/client/assets/tokens-CjRplDrJ.js +1 -0
  53. package/dist/web/client/assets/triggers-MLzTm_DM.js +1 -0
  54. package/dist/web/client/assets/welcome-wBfX9dAd.js +1 -0
  55. package/dist/web/client/assets/{ChatPane-DzEgOEqS.js → wire-constants-BxfyUMXB.js} +4 -4
  56. package/dist/web/server/assets/{AgentTabs-BOjTN7QF.js → AgentTabs-DoMDJBXH.js} +10 -7
  57. package/dist/web/server/assets/{ChatPane-BvpswYvF.js → ChatPane-eUY_dga3.js} +38 -20
  58. package/dist/web/server/assets/ConfigPage-BKlh5vOU.js +68 -0
  59. package/dist/web/server/assets/{FieldRow-DwyqycWI.js → FieldRow-B4eTegH9.js} +5 -5
  60. package/dist/web/server/assets/Page-LENulSXY.js +111 -0
  61. package/dist/web/server/assets/ProductionTeamPolicyEditor-Y4mzFFvR.js +1009 -0
  62. package/dist/web/server/assets/ProfileCommunicationEditor-C2RU-2QB.js +107 -0
  63. package/dist/web/server/assets/RecoveryState-B2SG-mrY.js +37 -0
  64. package/dist/web/server/assets/SectionTabs-BJTPr5nU.js +8 -0
  65. package/dist/web/server/assets/Sidebar-O_CH1-JD.js +964 -0
  66. package/dist/web/server/assets/TeamTabs-zZzbP1t_.js +51 -0
  67. package/dist/web/server/assets/{TemplatesTabs---7h5GYa.js → TemplatesTabs-CcRxZhJe.js} +9 -8
  68. package/dist/web/server/assets/_id-A8Xiv6Lc.js +11 -0
  69. package/dist/web/server/assets/{_id-Sjw0zhA6.js → _id-BhOB8Umi.js} +5 -5
  70. package/dist/web/server/assets/{_id-DDixKEud.js → _id-C3HY4lWg.js} +77 -20
  71. package/dist/web/server/assets/{_id-BdRiQb2H.js → _id-ClN9hY2x.js} +132 -39
  72. package/dist/web/server/assets/{_id-BqnDy_Ca.js → _id-CwyGjJeP.js} +7 -6
  73. package/dist/web/server/assets/{_id-D8duqgd5.js → _id-D27T85mU.js} +6 -5
  74. package/dist/web/server/assets/_id-D3Ap7zZA.js +377 -0
  75. package/dist/web/server/assets/_id-DinTp_7X.js +14 -0
  76. package/dist/web/server/assets/{_id-CnQflrRv.js → _id-Dj1yZ3zJ.js} +6 -6
  77. package/dist/web/server/assets/{_id-DUIrFV3G.js → _id-DkYodSkG.js} +10 -2
  78. package/dist/web/server/assets/{_id-D_Ew11ED.js → _id-IzadFZV9.js} +9 -9
  79. package/dist/web/server/assets/_id-LrvXU4Nr.js +45 -0
  80. package/dist/web/server/assets/_id-tB47Vsfp.js +42 -0
  81. package/dist/web/server/assets/_tanstack-start-manifest_v-D09Xu_6u.js +286 -0
  82. package/dist/web/server/assets/activity-BCI4mfNS.js +168 -0
  83. package/dist/web/server/assets/activity-CGCf8BQf.js +11 -0
  84. package/dist/web/server/assets/activity-D9SMqBhy.js +14 -0
  85. package/dist/web/server/assets/activity-DohitgwW.js +12 -0
  86. package/dist/web/server/assets/{agents-k5QURC4I.js → agents-BPKOshR5.js} +5 -5
  87. package/dist/web/server/assets/{profiles-C6a3RKgu.js → agents-BY74v7fM.js} +5 -5
  88. package/dist/web/server/assets/{profiles-CZ5NkmVw.js → agents-BvttypqB.js} +5 -5
  89. package/dist/web/server/assets/{agents-ChcAJUI5.js → agents-C9xlWK0Z.js} +2 -2
  90. package/dist/web/server/assets/agents-CgZMHj80.js +265 -0
  91. package/dist/web/server/assets/{profiles-LxcC_L6n.js → agents-DZuFEj0D.js} +87 -79
  92. package/dist/web/server/assets/approvals-BGU-XGIO.js +12 -0
  93. package/dist/web/server/assets/approvals-CWcFHlor.js +14 -0
  94. package/dist/web/server/assets/approvals-CbFXFvG8.js +11 -0
  95. package/dist/web/server/assets/approvals-DCaVw1Mz.js +280 -0
  96. package/dist/web/server/assets/{auth-DzRAMwVt.js → auth-byfSx6Ja.js} +6 -2
  97. package/dist/web/server/assets/{config-CHaCv89D.js → config-BDCJdtj2.js} +1 -1
  98. package/dist/web/server/assets/{config-CdVjqjin.js → config-D2LAsud2.js} +31 -52
  99. package/dist/web/server/assets/{config-Bq3o924J.js → config-TeIoyYYc.js} +2 -2
  100. package/dist/web/server/assets/context-B-XDf6Ym.js +12 -0
  101. package/dist/web/server/assets/context-BXGo5Vfi.js +12 -0
  102. package/dist/web/server/assets/context-DrkrIWun.js +47 -0
  103. package/dist/web/server/assets/{createServerRpc-CeKECg65.js → createServerRpc-pU-IQV2Y.js} +1 -1
  104. package/dist/web/server/assets/{createSsrRpc-ZBGxhl8t.js → createSsrRpc-DFsIAfFd.js} +1 -1
  105. package/dist/web/server/assets/{empty-plugin-adapters-DKUlnwwl.js → empty-plugin-adapters-Cq4--YW-.js} +1 -1
  106. package/dist/web/server/assets/{inbox-CkiSvD14.js → inbox-B3-TRsNI.js} +1 -1
  107. package/dist/web/server/assets/{inbox-Bxb3W04M.js → inbox-BardsGyy.js} +2 -2
  108. package/dist/web/server/assets/inbox-CUIyf9MT.js +131 -0
  109. package/dist/web/server/assets/login-Bx5LEyGP.js +118 -0
  110. package/dist/web/server/assets/login-CmWvxfTK.js +136 -0
  111. package/dist/web/server/assets/{mcp-BsFKEoXt.js → mcp-2pwT9HU8.js} +1 -1
  112. package/dist/web/server/assets/{mcp-BU_kKENi.js → mcp-BJjLIdP0.js} +105 -112
  113. package/dist/web/server/assets/{mcp-CKqwG4mt.js → mcp-DIWTogHM.js} +2 -2
  114. package/dist/web/server/assets/members-CCv17cjQ.js +46 -0
  115. package/dist/web/server/assets/members-CW5aBe81.js +12 -0
  116. package/dist/web/server/assets/members-VdPwD6CE.js +12 -0
  117. package/dist/web/server/assets/{memory-BaYnfm7K.js → memory-Dngc13Nw.js} +9 -9
  118. package/dist/web/server/assets/{memory-CQaqWnyM.js → memory-a8Kz57Kh.js} +22 -19
  119. package/dist/web/server/assets/{memory-Ns2-Z31p.js → memory-pZ4pZT7p.js} +6 -6
  120. package/dist/web/server/assets/policy-BYVXqsan.js +11 -0
  121. package/dist/web/server/assets/policy-Bb-vEgqg.js +40 -0
  122. package/dist/web/server/assets/policy-BcGELcc9.js +490 -0
  123. package/dist/web/server/assets/policy-C30AeFIb.js +21 -0
  124. package/dist/web/server/assets/router-DIdp8ZNt.js +504 -0
  125. package/dist/web/server/assets/{routes-C61gBiXa.js → routes-CXz4hTAr.js} +6 -6
  126. package/dist/web/server/assets/{routes-Ce2VWrU9.js → routes-Jb0zjKav.js} +16 -13
  127. package/dist/web/server/assets/{routes-V9URcp1v.js → routes-lIclH9Br.js} +2 -2
  128. package/dist/web/server/assets/services-B9yBWDX0.js +79 -0
  129. package/dist/web/server/assets/{services-Ccc5s2bS.js → services-C4szdhPx.js} +4 -4
  130. package/dist/web/server/assets/{services-DhRiNeq0.js → services-wG8I06oS.js} +1 -1
  131. package/dist/web/server/assets/skills-BZdqiDig.js +358 -0
  132. package/dist/web/server/assets/{skills-l2cyQ3zS.js → skills-C-UgkuCW.js} +2 -2
  133. package/dist/web/server/assets/{skills-CFIWVg32.js → skills-a9VSWHWq.js} +1 -1
  134. package/dist/web/server/assets/{start-CYDpZ6cb.js → start-WH8WzTL_.js} +1 -1
  135. package/dist/web/server/assets/team-policy-vPG01onj.js +180 -0
  136. package/dist/web/server/assets/teams-3im0oQnS.js +11 -0
  137. package/dist/web/server/assets/teams-CpQ0YgWf.js +112 -0
  138. package/dist/web/server/assets/teams-DEpQR2QA.js +14 -0
  139. package/dist/web/server/assets/teams-DqfrEoH6.js +36 -0
  140. package/dist/web/server/assets/teams-MjqgsmC3.js +12 -0
  141. package/dist/web/server/assets/teams-OIkHuxy1.js +12 -0
  142. package/dist/web/server/assets/teams-jBtvnk59.js +193 -0
  143. package/dist/web/server/assets/{telegram-DfAddLdv.js → telegram-7ub--6xz.js} +44 -56
  144. package/dist/web/server/assets/{telegram-T3l9KtiE.js → telegram-Bazhmpr4.js} +2 -2
  145. package/dist/web/server/assets/{telegram-BdaUIjvs.js → telegram-DNgCWebD.js} +1 -1
  146. package/dist/web/server/assets/{tokens-DdpnfV_Y.js → tokens-BnwFbV7T.js} +2 -2
  147. package/dist/web/server/assets/{tokens-BCz3PSoT.js → tokens-DPDMSN5O.js} +1 -1
  148. package/dist/web/server/assets/tokens-yyTSfBSN.js +186 -0
  149. package/dist/web/server/assets/{triggers-BzJG1nN5.js → triggers-BMpHsGIr.js} +5 -4
  150. package/dist/web/server/assets/{triggers-BcH_6PW1.js → triggers-C_0y6QV9.js} +1 -1
  151. package/dist/web/server/assets/{triggers-BcTTwMfy.js → triggers-Ca57_qym.js} +2 -2
  152. package/dist/web/server/assets/{welcome-CP4CZ9B6.js → welcome-IYHGurWx.js} +23 -15
  153. package/dist/web/server/assets/{wire-constants-Deb4NxBb.js → wire-constants-C8nBJcU3.js} +3 -3
  154. package/dist/web/server/server.js +126 -95
  155. package/dist/worker.js +185 -146
  156. package/dist/worker.js.map +1 -1
  157. package/package.json +8 -7
  158. package/dist/migrations/0002_profile_groups.sql +0 -38
  159. package/dist/migrations/0003_agent_telegram.sql +0 -40
  160. package/dist/migrations/0004_agent_mirror_mode.sql +0 -17
  161. package/dist/migrations/0005_group_topic_name_format.sql +0 -15
  162. package/dist/migrations/0006_telegram_acl.sql +0 -18
  163. package/dist/migrations/0007_mcp_servers.sql +0 -30
  164. package/dist/migrations/0008_seed_user_md.sql +0 -39
  165. package/dist/web/client/assets/AgentTabs-DioGqUVR.js +0 -1
  166. package/dist/web/client/assets/ConfigTabs-pY-V0Rie.js +0 -1
  167. package/dist/web/client/assets/FieldRow-CNKma5LE.js +0 -1
  168. package/dist/web/client/assets/MembersEditor-C6UpqDdV.js +0 -1
  169. package/dist/web/client/assets/SpawnTeamModal-BEkNCKXm.js +0 -1
  170. package/dist/web/client/assets/TemplatesTabs-UM04RMO9.js +0 -1
  171. package/dist/web/client/assets/_id-BNJapCT4.js +0 -1
  172. package/dist/web/client/assets/_id-CjGoV8Mr.js +0 -1
  173. package/dist/web/client/assets/_id-DehuCHUw.js +0 -1
  174. package/dist/web/client/assets/_id-Dz9fjcCM.js +0 -1
  175. package/dist/web/client/assets/agents-M6omAXcZ.js +0 -1
  176. package/dist/web/client/assets/config-DIuEc5bm.js +0 -3
  177. package/dist/web/client/assets/groups-DpE2d2zZ.js +0 -1
  178. package/dist/web/client/assets/inbox-BPnLsRNf.js +0 -1
  179. package/dist/web/client/assets/index-MAJuXnie.js +0 -12
  180. package/dist/web/client/assets/login-CawJX16E.js +0 -1
  181. package/dist/web/client/assets/mcp-DIrh9-v_.js +0 -1
  182. package/dist/web/client/assets/memory-BpHbdKsd.js +0 -1
  183. package/dist/web/client/assets/preload-helper-CvnapA2_.js +0 -1
  184. package/dist/web/client/assets/profile-groups-ByoKak0c.js +0 -1
  185. package/dist/web/client/assets/profiles-BEjv8LGo.js +0 -1
  186. package/dist/web/client/assets/routes-D2COHy7v.js +0 -1
  187. package/dist/web/client/assets/services-D212jSK_.js +0 -1
  188. package/dist/web/client/assets/skills-Da0MURjY.js +0 -1
  189. package/dist/web/client/assets/styles-BgE5bCHA.css +0 -2
  190. package/dist/web/client/assets/telegram-Czh2MdVm.js +0 -1
  191. package/dist/web/client/assets/tokens-E_JvO5JN.js +0 -1
  192. package/dist/web/client/assets/triggers-BBRZQOm7.js +0 -1
  193. package/dist/web/client/assets/welcome-Dn-zvmBE.js +0 -1
  194. package/dist/web/client/assets/wire-constants-BkT5-597.js +0 -1
  195. package/dist/web/server/assets/ConfigTabs-CyuxzesF.js +0 -41
  196. package/dist/web/server/assets/MembersEditor-BWQztvrX.js +0 -131
  197. package/dist/web/server/assets/Sidebar-DmEiewRN.js +0 -529
  198. package/dist/web/server/assets/SpawnTeamModal-dSN421k_.js +0 -107
  199. package/dist/web/server/assets/_id-BKev9H1p.js +0 -12
  200. package/dist/web/server/assets/_id-BNwlbWHP.js +0 -24
  201. package/dist/web/server/assets/_id-CRqqi8IE.js +0 -161
  202. package/dist/web/server/assets/_id-CXg-Blec.js +0 -367
  203. package/dist/web/server/assets/_tanstack-start-manifest_v-D9FLKShQ.js +0 -178
  204. package/dist/web/server/assets/agents-C7SBPN0M.js +0 -210
  205. package/dist/web/server/assets/groups-CbSwND2r.js +0 -12
  206. package/dist/web/server/assets/groups-CeRRlZaZ.js +0 -150
  207. package/dist/web/server/assets/groups-pk4CYSuf.js +0 -21
  208. package/dist/web/server/assets/inbox-DU27iHv_.js +0 -133
  209. package/dist/web/server/assets/login-CNznncgA.js +0 -58
  210. package/dist/web/server/assets/login-CQybKk7Y.js +0 -74
  211. package/dist/web/server/assets/profile-groups-CiU06yN1.js +0 -28
  212. package/dist/web/server/assets/profile-groups-D21MYoLM.js +0 -208
  213. package/dist/web/server/assets/profile-groups-aoJleXHP.js +0 -12
  214. package/dist/web/server/assets/router-BrDascdO.js +0 -460
  215. package/dist/web/server/assets/services-B91w2f-X.js +0 -94
  216. package/dist/web/server/assets/skills-D89ND2kR.js +0 -321
  217. package/dist/web/server/assets/tokens-CkKqrtk-.js +0 -193
@@ -0,0 +1 @@
1
+ import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";import{d as r}from"./preload-helper-mNuBjNXU.js";import{i}from"./index-VdURSoM4.js";import{r as a}from"./Page-CwNuDhWz.js";import{t as o}from"./AgentTabs-B3hq5a3e.js";var s=e(n()),c=t();function l(){let{resolved:e,triggers:t}=i.useLoaderData(),n=r();async function s(e){await fetch(`/api/triggers/${e.id}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify({enabled:!e.enabled})}),await n.invalidate()}async function l(e){confirm(`delete this trigger?`)&&(await fetch(`/api/triggers/${e}`,{method:`DELETE`}),await n.invalidate())}return(0,c.jsxs)(a,{children:[(0,c.jsx)(`header`,{className:`mb-6`,children:(0,c.jsx)(`h1`,{children:e.agent.name})}),(0,c.jsx)(o,{agentId:e.agent.id,active:`triggers`,archived:e.agent.status===`archived`}),(0,c.jsx)(u,{agentId:e.agent.id,onAdded:()=>n.invalidate()}),(0,c.jsx)(`h3`,{className:`mb-3 mt-6 font-body text-[0.85em] font-semibold uppercase tracking-wider text-mocha-light`,children:`Active triggers`}),t.length===0?(0,c.jsx)(`p`,{className:`muted`,children:`no triggers yet — add one above.`}):(0,c.jsxs)(`table`,{children:[(0,c.jsx)(`thead`,{children:(0,c.jsxs)(`tr`,{children:[(0,c.jsx)(`th`,{children:`id`}),(0,c.jsx)(`th`,{children:`kind`}),(0,c.jsx)(`th`,{children:`spec`}),(0,c.jsx)(`th`,{children:`message`}),(0,c.jsx)(`th`,{children:`last fired`}),(0,c.jsx)(`th`,{})]})}),(0,c.jsx)(`tbody`,{children:t.map(e=>{let t=e.kind===`interval`?`every ${e.intervalSec}s`:e.cronExpr,n=e.lastFiredAt?new Date(e.lastFiredAt).toLocaleString():`(never)`;return(0,c.jsxs)(`tr`,{className:e.enabled?``:`opacity-60`,children:[(0,c.jsx)(`td`,{children:(0,c.jsxs)(`code`,{children:[e.id.slice(0,8),`…`]})}),(0,c.jsx)(`td`,{children:(0,c.jsx)(`span`,{className:`inline-block rounded-sm border border-frost bg-ivory px-2 py-0.5 font-mono text-[0.8em] text-mocha`,children:e.kind})}),(0,c.jsx)(`td`,{children:(0,c.jsx)(`code`,{children:t})}),(0,c.jsx)(`td`,{children:e.message.length>60?`${e.message.slice(0,60)}…`:e.message}),(0,c.jsx)(`td`,{className:`text-[0.82em] text-mocha-light`,children:n}),(0,c.jsx)(`td`,{children:(0,c.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,c.jsx)(`button`,{type:`button`,className:`ghost-btn`,onClick:()=>s(e),children:e.enabled?`disable`:`enable`}),(0,c.jsx)(`button`,{type:`button`,className:`ghost-btn`,onClick:()=>l(e.id),children:`delete`})]})})]},e.id)})})]})]})}function u({agentId:e,onAdded:t}){let[n,r]=(0,s.useState)(`interval`),[i,a]=(0,s.useState)(300),[o,l]=(0,s.useState)(``),[u,d]=(0,s.useState)(``),[f,p]=(0,s.useState)(null),[m,h]=(0,s.useState)(!1);async function g(r){if(r.preventDefault(),p(null),!u.trim()){p(`message is required`);return}if(n===`interval`&&(!Number.isFinite(i)||i<=0)){p(`interval must be a positive number`);return}if(n===`cron`&&!o.trim()){p(`cron expression is required`);return}h(!0);try{let r={kind:n,message:u.trim()};n===`interval`?r.intervalSec=i:r.cronExpr=o.trim();let s=await fetch(`/api/agents/${encodeURIComponent(e)}/triggers`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(r)});if(!s.ok){let e=await s.json().catch(()=>null);throw Error(e?.error??s.statusText)}d(``),l(``),a(300),t()}catch(e){p(e.message)}finally{h(!1)}}return(0,c.jsxs)(`form`,{className:`card`,onSubmit:g,children:[(0,c.jsx)(`h3`,{children:`Add trigger`}),(0,c.jsxs)(`div`,{className:`mb-3 flex gap-3`,children:[(0,c.jsxs)(`label`,{className:`m-0 inline-flex cursor-pointer items-center gap-1`,children:[(0,c.jsx)(`input`,{type:`radio`,checked:n===`interval`,onChange:()=>r(`interval`)}),`interval (every N seconds)`]}),(0,c.jsxs)(`label`,{className:`m-0 inline-flex cursor-pointer items-center gap-1`,children:[(0,c.jsx)(`input`,{type:`radio`,checked:n===`cron`,onChange:()=>r(`cron`)}),`cron (5-field)`]})]}),n===`interval`?(0,c.jsxs)(`label`,{children:[`interval (seconds)`,(0,c.jsx)(`input`,{type:`number`,min:1,value:i,onChange:e=>a(Number(e.target.value))})]}):(0,c.jsxs)(`label`,{children:[`cron expression (minute hour dom month dow)`,(0,c.jsx)(`input`,{type:`text`,placeholder:`*/15 * * * *`,value:o,onChange:e=>l(e.target.value)})]}),(0,c.jsxs)(`label`,{children:[`message`,(0,c.jsx)(`textarea`,{placeholder:`e.g. check your inbox and act on anything new`,value:u,onChange:e=>d(e.target.value),className:`font-mono text-[0.9em] min-h-[80px]`})]}),(0,c.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,c.jsx)(`button`,{type:`submit`,disabled:m,children:m?`adding…`:`add`}),f&&(0,c.jsx)(`span`,{className:`text-[0.85em] text-danger`,children:f})]})]})}export{l as component};
@@ -0,0 +1 @@
1
+ import{t as e}from"./jsx-runtime-DGeXAQPT.js";import{O as t}from"./index-VdURSoM4.js";import{i as n,n as r,r as i}from"./Page-CwNuDhWz.js";var a=t(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),o=e();function s(){return(0,o.jsxs)(i,{size:`narrow`,children:[(0,o.jsx)(r,{eyebrow:`First run`,title:`Welcome to bazilion`,description:`Connect one model provider, then Bazilion will prepare your default Agent template and Team.`}),(0,o.jsxs)(n,{title:`Three steps to your first conversation`,children:[(0,o.jsxs)(`p`,{className:`text-sm leading-6 text-muted-foreground`,children:[`Before you can spawn agents, enable a provider and save at least one concrete model id. Once you do, a `,(0,o.jsx)(`code`,{children:`default`}),` Agent template (and a `,(0,o.jsx)(`code`,{children:`default`}),` team directory) are created automatically and the rest of the app unlocks.`]}),(0,o.jsxs)(`ol`,{className:`my-5 space-y-4`,children:[(0,o.jsxs)(c,{n:1,children:[(0,o.jsx)(`strong`,{children:`Choose a provider.`}),` Head to the`,` `,(0,o.jsx)(`a`,{href:`/config`,children:`providers tab`}),`, pick a provider, and set credentials or a local endpoint if that provider needs one. Local providers like Ollama and LM Studio can use their default loopback URLs.`]}),(0,o.jsxs)(c,{n:2,children:[(0,o.jsx)(`strong`,{children:`Enable it and save a model.`}),` Flip the provider's toggle on, then click a catalog chip or type one exact model id (for example`,` `,(0,o.jsx)(`code`,{children:`claude-opus-4-8`}),`, `,(0,o.jsx)(`code`,{children:`gpt-5.6-luna`}),`, or `,(0,o.jsx)(`code`,{children:`llama3.3`}),`) and press `,(0,o.jsx)(`em`,{children:`save models`}),`.`]}),(0,o.jsxs)(c,{n:3,children:[(0,o.jsx)(`strong`,{children:`Start chatting.`}),` You'll be redirected to the home page automatically, where the `,(0,o.jsx)(`code`,{children:`default`}),` Agent template is ready for your first spawn.`]})]}),(0,o.jsxs)(`a`,{href:`/config`,className:`btn-primary no-underline`,children:[`Configure providers `,(0,o.jsx)(a,{className:`h-4 w-4`,"aria-hidden":`true`})]})]})]})}function c({n:e,children:t}){return(0,o.jsxs)(`li`,{className:`grid grid-cols-[2rem_1fr] gap-3 border-t border-frost pt-3 first:border-t-0 first:pt-0`,children:[(0,o.jsx)(`span`,{className:`text-center font-display text-xl text-sapphire`,children:e}),(0,o.jsx)(`div`,{className:`text-[0.92em] leading-relaxed text-mocha`,children:t})]})}export{s as component};
@@ -1,4 +1,4 @@
1
- import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{Q as n}from"./preload-helper-CvnapA2_.js";var r=e(n(),1);function i(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function a(e){if(Array.isArray(e))return e}function o(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function s(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
1
+ import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{t as n}from"./react-3W8R1pOO.js";var r=e(n(),1);function i(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function a(e){if(Array.isArray(e))return e}function o(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function s(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function c(e,t){return a(e)||o(e,t)||l(e,t)||s()}function l(e,t){if(e){if(typeof e==`string`)return i(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(e,t):void 0}}var u=Object.entries,d=Object.setPrototypeOf,f=Object.isFrozen,p=Object.getPrototypeOf,m=Object.getOwnPropertyDescriptor,h=Object.freeze,g=Object.seal,_=Object.create,ee=typeof Reflect<`u`&&Reflect,v=ee.apply,y=ee.construct;h||=function(e){return e},g||=function(e){return e},v||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},y||=function(e){return new e(...[...arguments].slice(1))};var te=E(Array.prototype.forEach),ne=E(Array.prototype.lastIndexOf),re=E(Array.prototype.pop),ie=E(Array.prototype.push),ae=E(Array.prototype.splice),b=Array.isArray,oe=E(String.prototype.toLowerCase),se=E(String.prototype.toString),ce=E(String.prototype.match),le=E(String.prototype.replace),ue=E(String.prototype.indexOf),de=E(String.prototype.trim),fe=E(Number.prototype.toString),pe=E(Boolean.prototype.toString),x=typeof BigInt>`u`?null:E(BigInt.prototype.toString),S=typeof Symbol>`u`?null:E(Symbol.prototype.toString),C=E(Object.prototype.hasOwnProperty),w=E(Object.prototype.toString),T=E(RegExp.prototype.test),me=he(TypeError);function E(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return v(e,t,n)}}function he(e){return function(){return y(e,[...arguments])}}function D(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:oe;if(d&&d(e,null),!b(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(f(t)||(t[r]=e),i=e)}e[i]=!0}return e}function ge(e){for(let t=0;t<e.length;t++)C(e,t)||(e[t]=null);return e}function O(e){let t=_(null);for(let r of u(e)){var n=c(r,2);let i=n[0],a=n[1];C(e,i)&&(b(a)?t[i]=ge(a):a&&typeof a==`object`&&a.constructor===Object?t[i]=O(a):t[i]=a)}return t}function _e(e){switch(typeof e){case`string`:return e;case`number`:return fe(e);case`boolean`:return pe(e);case`bigint`:return x?x(e):`0`;case`symbol`:return S?S(e):`Symbol()`;case`undefined`:return w(e);case`function`:case`object`:{if(e===null)return w(e);let t=e,n=k(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:w(e)}return w(e)}default:return w(e)}}function k(e,t){for(;e!==null;){let n=m(e,t);if(n){if(n.get)return E(n.get);if(typeof n.value==`function`)return E(n.value)}e=p(e)}function n(){return null}return n}function ve(e){try{return T(e,``),!0}catch{return!1}}var ye=h(`a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),be=h(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),xe=h([`feBlend`,`feColorMatrix`,`feComponentTransfer`,`feComposite`,`feConvolveMatrix`,`feDiffuseLighting`,`feDisplacementMap`,`feDistantLight`,`feDropShadow`,`feFlood`,`feFuncA`,`feFuncB`,`feFuncG`,`feFuncR`,`feGaussianBlur`,`feImage`,`feMerge`,`feMergeNode`,`feMorphology`,`feOffset`,`fePointLight`,`feSpecularLighting`,`feSpotLight`,`feTile`,`feTurbulence`]),Se=h([`animate`,`color-profile`,`cursor`,`discard`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`foreignobject`,`hatch`,`hatchpath`,`mesh`,`meshgradient`,`meshpatch`,`meshrow`,`missing-glyph`,`script`,`set`,`solidcolor`,`unknown`,`use`]),A=h(`math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts`.split(`.`)),Ce=h([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),we=h([`#text`]),Te=h(`accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.command.commandfor.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns`.split(`.`)),Ee=h(`accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-rendering.textlength.type.u1.u2.unicode.values.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan`.split(`.`)),De=h(`accent.accentunder.align.bevelled.close.columnalign.columnlines.columnspacing.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lquote.lspace.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),Oe=h([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),ke=g(/{{[\w\W]*|^[\w\W]*}}/g),Ae=g(/<%[\w\W]*|^[\w\W]*%>/g),je=g(/\${[\w\W]*/g),Me=g(/^data-[\-\w.\u00B7-\uFFFF]+$/),Ne=g(/^aria-[\-\w]+$/),Pe=g(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Fe=g(/^(?:\w+script|data):/i),Ie=g(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Le=g(/^html$/i),Re=g(/^[a-z][.\w]*(-[.\w]+)+$/i),ze=g(/<[/\w!]/g),Be=g(/<[/\w]/g),Ve=g(/<\/no(script|embed|frames)/i),He=g(/\/>/i),j={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Ue=function(){return typeof window>`u`?null:window},We=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},Ge=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Ke=function(e,t,n,r){return C(e,t)&&b(e[t])?D(r.base?O(r.base):{},e[t],r.transform):n};function qe(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Ue(),t=e=>qe(e);if(t.version=`3.4.11`,t.removed=[],!e||!e.document||e.document.nodeType!==j.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let l=e.DOMParser,d=e.trustedTypes,f=s.prototype,p=k(f,`cloneNode`),m=k(f,`remove`),ee=k(f,`nextSibling`),v=k(f,`childNodes`),y=k(f,`parentNode`),fe=k(f,`shadowRoot`),pe=k(f,`attributes`),x=o&&o.prototype?k(o.prototype,`nodeType`):null,S=o&&o.prototype?k(o.prototype,`nodeName`):null;if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let w,E=``,he,ge=!1,Je=0,Ye=function(){if(Je>0)throw me(`A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.`)},M=function(e){Ye(),Je++;try{return w.createHTML(e)}finally{Je--}},Xe=function(e){Ye(),Je++;try{return w.createScriptURL(e)}finally{Je--}},Ze=function(){return ge||=(he=We(d,i),!0),he},N=n,P=N.implementation,Qe=N.createNodeIterator,F=N.createDocumentFragment,$e=N.getElementsByTagName,et=r.importNode,I=Ge();t.isSupported=typeof u==`function`&&typeof y==`function`&&P&&P.createHTMLDocument!==void 0;let tt=ke,nt=Ae,rt=je,it=Me,at=Ne,ot=Fe,st=Ie,ct=Re,lt=Pe,L=null,ut=D({},[...ye,...be,...xe,...A,...we]),R=null,dt=D({},[...Te,...Ee,...De,...Oe]),z=Object.seal(_(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),ft=null,pt=null,B=Object.seal(_(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),mt=!0,ht=!0,gt=!1,_t=!0,V=!1,vt=!0,H=!1,yt=!1,bt=null,xt=null,St=!1,Ct=!1,wt=!1,Tt=!1,Et=!0,Dt=!1,Ot=`user-content-`,kt=!0,At=!1,jt={},U=null,Mt=D({},`annotation-xml.audio.colgroup.desc.foreignobject.head.iframe.math.mi.mn.mo.ms.mtext.noembed.noframes.noscript.plaintext.script.selectedcontent.style.svg.template.thead.title.video.xmp`.split(`.`)),Nt=null,Pt=D({},[`audio`,`video`,`img`,`source`,`image`,`track`]),Ft=null,It=D({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),Lt=`http://www.w3.org/1998/Math/MathML`,Rt=`http://www.w3.org/2000/svg`,W=`http://www.w3.org/1999/xhtml`,zt=W,Bt=!1,Vt=null,Ht=D({},[Lt,Rt,W],se),Ut=h([`mi`,`mo`,`mn`,`ms`,`mtext`]),Wt=D({},Ut),Gt=h([`annotation-xml`]),Kt=D({},Gt),qt=D({},[`title`,`style`,`font`,`a`,`script`]),G=null,Jt=[`application/xhtml+xml`,`text/html`],K=null,q=null,Yt=n.createElement(`form`),Xt=function(e){return e instanceof RegExp||e instanceof Function},J=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(q&&q===e)return;(!e||typeof e!=`object`)&&(e={}),e=O(e),G=Jt.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,K=G===`application/xhtml+xml`?se:oe,L=Ke(e,`ALLOWED_TAGS`,ut,{transform:K}),R=Ke(e,`ALLOWED_ATTR`,dt,{transform:K}),Vt=Ke(e,`ALLOWED_NAMESPACES`,Ht,{transform:se}),Ft=Ke(e,`ADD_URI_SAFE_ATTR`,It,{transform:K,base:It}),Nt=Ke(e,`ADD_DATA_URI_TAGS`,Pt,{transform:K,base:Pt}),U=Ke(e,`FORBID_CONTENTS`,Mt,{transform:K}),ft=Ke(e,`FORBID_TAGS`,O({}),{transform:K}),pt=Ke(e,`FORBID_ATTR`,O({}),{transform:K}),jt=C(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?O(e.USE_PROFILES):e.USE_PROFILES:!1,mt=e.ALLOW_ARIA_ATTR!==!1,ht=e.ALLOW_DATA_ATTR!==!1,gt=e.ALLOW_UNKNOWN_PROTOCOLS||!1,_t=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,V=e.SAFE_FOR_TEMPLATES||!1,vt=e.SAFE_FOR_XML!==!1,H=e.WHOLE_DOCUMENT||!1,Ct=e.RETURN_DOM||!1,wt=e.RETURN_DOM_FRAGMENT||!1,Tt=e.RETURN_TRUSTED_TYPE||!1,St=e.FORCE_BODY||!1,Et=e.SANITIZE_DOM!==!1,Dt=e.SANITIZE_NAMED_PROPS||!1,kt=e.KEEP_CONTENT!==!1,At=e.IN_PLACE||!1,lt=ve(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:Pe,zt=typeof e.NAMESPACE==`string`?e.NAMESPACE:W,Wt=C(e,`MATHML_TEXT_INTEGRATION_POINTS`)&&e.MATHML_TEXT_INTEGRATION_POINTS&&typeof e.MATHML_TEXT_INTEGRATION_POINTS==`object`?O(e.MATHML_TEXT_INTEGRATION_POINTS):D({},Ut),Kt=C(e,`HTML_INTEGRATION_POINTS`)&&e.HTML_INTEGRATION_POINTS&&typeof e.HTML_INTEGRATION_POINTS==`object`?O(e.HTML_INTEGRATION_POINTS):D({},Gt);let t=C(e,`CUSTOM_ELEMENT_HANDLING`)&&e.CUSTOM_ELEMENT_HANDLING&&typeof e.CUSTOM_ELEMENT_HANDLING==`object`?O(e.CUSTOM_ELEMENT_HANDLING):_(null);if(z=_(null),C(t,`tagNameCheck`)&&Xt(t.tagNameCheck)&&(z.tagNameCheck=t.tagNameCheck),C(t,`attributeNameCheck`)&&Xt(t.attributeNameCheck)&&(z.attributeNameCheck=t.attributeNameCheck),C(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(z.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),g(z),V&&(ht=!1),wt&&(Ct=!0),jt&&(L=D({},we),R=_(null),jt.html===!0&&(D(L,ye),D(R,Te)),jt.svg===!0&&(D(L,be),D(R,Ee),D(R,Oe)),jt.svgFilters===!0&&(D(L,xe),D(R,Ee),D(R,Oe)),jt.mathMl===!0&&(D(L,A),D(R,De),D(R,Oe))),B.tagCheck=null,B.attributeCheck=null,C(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?B.tagCheck=e.ADD_TAGS:b(e.ADD_TAGS)&&(L===ut&&(L=O(L)),D(L,e.ADD_TAGS,K))),C(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?B.attributeCheck=e.ADD_ATTR:b(e.ADD_ATTR)&&(R===dt&&(R=O(R)),D(R,e.ADD_ATTR,K))),C(e,`ADD_URI_SAFE_ATTR`)&&b(e.ADD_URI_SAFE_ATTR)&&D(Ft,e.ADD_URI_SAFE_ATTR,K),C(e,`FORBID_CONTENTS`)&&b(e.FORBID_CONTENTS)&&(U===Mt&&(U=O(U)),D(U,e.FORBID_CONTENTS,K)),C(e,`ADD_FORBID_CONTENTS`)&&b(e.ADD_FORBID_CONTENTS)&&(U===Mt&&(U=O(U)),D(U,e.ADD_FORBID_CONTENTS,K)),kt&&(L[`#text`]=!0),H&&D(L,[`html`,`head`,`body`]),L.table&&(D(L,[`tbody`]),delete ft.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw me(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw me(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=w;w=e.TRUSTED_TYPES_POLICY;try{E=M(``)}catch(e){throw w=t,e}}else e.TRUSTED_TYPES_POLICY===null?(w=void 0,E=``):(w===void 0&&(w=Ze()),w&&typeof E==`string`&&(E=M(``)));h&&h(e),q=e},Zt=D({},[...be,...xe,...Se]),Qt=D({},[...A,...Ce]),$t=function(e,t,n){return t.namespaceURI===W?e===`svg`:t.namespaceURI===Lt?e===`svg`&&(n===`annotation-xml`||Wt[n]):!!Zt[e]},en=function(e,t,n){return t.namespaceURI===W?e===`math`:t.namespaceURI===Rt?e===`math`&&Kt[n]:!!Qt[e]},tn=function(e,t,n){return t.namespaceURI===Rt&&!Kt[n]||t.namespaceURI===Lt&&!Wt[n]?!1:!Qt[e]&&(qt[e]||!Zt[e])},nn=function(e){let t=y(e);(!t||!t.tagName)&&(t={namespaceURI:zt,tagName:`template`});let n=oe(e.tagName),r=oe(t.tagName);return Vt[e.namespaceURI]?e.namespaceURI===Rt?$t(n,t,r):e.namespaceURI===Lt?en(n,t,r):e.namespaceURI===W?tn(n,t,r):!!(G===`application/xhtml+xml`&&Vt[e.namespaceURI]):!1},Y=function(e){ie(t.removed,{element:e});try{y(e).removeChild(e)}catch{if(m(e),!y(e))throw me(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},rn=function(e){let t=v(e);if(t){let e=[];te(t,t=>{ie(e,t)}),te(e,e=>{try{m(e)}catch{}})}let n=pe(e);if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;if(typeof i==`string`)try{e.removeAttribute(i)}catch{}}},X=function(e,n){try{ie(t.removed,{attribute:n.getAttributeNode(e),from:n})}catch{ie(t.removed,{attribute:null,from:n})}if(n.removeAttribute(e),e===`is`)if(Ct||wt)try{Y(n)}catch{}else try{n.setAttribute(e,``)}catch{}},Z=function(e){let t=pe(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;if(!(typeof i!=`string`||R[K(i)]))try{e.removeAttribute(i)}catch{}}},an=function(e){let t=[e];for(;t.length>0;){let e=t.pop();(x?x(e):e.nodeType)===j.element&&Z(e);let n=v(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}},on=function(e){let t=null,r=null;if(St)e=`<remove></remove>`+e;else{let t=ce(e,/^[\r\n\t ]+/);r=t&&t[0]}G===`application/xhtml+xml`&&zt===W&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=w?M(e):e;if(zt===W)try{t=new l().parseFromString(i,G)}catch{}if(!t||!t.documentElement){t=P.createDocument(zt,`template`,null);try{t.documentElement.innerHTML=Bt?E:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),zt===W?$e.call(t,H?`html`:`body`)[0]:H?t.documentElement:a},Q=function(e){return Qe.call(e.ownerDocument||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},sn=function(e){return e=le(e,tt,` `),e=le(e,nt,` `),e=le(e,rt,` `),e},cn=function(e){e.normalize();let t=Qe.call(e.ownerDocument||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),n=t.nextNode();for(;n;)n.data=sn(n.data),n=t.nextNode();let r=e.querySelectorAll?.call(e,`template`);r&&te(r,e=>{un(e.content)&&cn(e.content)})},ln=function(e){let t=S?S(e):null;return typeof t!=`string`||K(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==pe(e)||typeof e.removeAttribute!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==x(e)||e.childNodes!==v(e)},un=function(e){if(!x||typeof e!=`object`||!e)return!1;try{return x(e)===j.documentFragment}catch{return!1}},$=function(e){if(!x||typeof e!=`object`||!e)return!1;try{return typeof x(e)==`number`}catch{return!1}};function dn(e,n,r){e.length!==0&&te(e,e=>{e.call(t,n,r,q)})}let fn=function(e,t){return!!(vt&&e.hasChildNodes()&&!$(e.firstElementChild)&&T(ze,e.textContent)&&T(ze,e.innerHTML)||vt&&e.namespaceURI===W&&t===`style`&&$(e.firstElementChild)||e.nodeType===j.processingInstruction||vt&&e.nodeType===j.comment&&T(Be,e.data))},pn=function(e,t){if(!ft[t]&&_n(t)&&(z.tagNameCheck instanceof RegExp&&T(z.tagNameCheck,t)||z.tagNameCheck instanceof Function&&z.tagNameCheck(t)))return!1;if(kt&&!U[t]){let t=y(e),n=v(e);if(n&&t){let r=n.length;for(let i=r-1;i>=0;--i){let r=At?n[i]:p(n[i],!0);t.insertBefore(r,ee(e))}}}return Y(e),!0},mn=function(e){if(dn(I.beforeSanitizeElements,e,null),ln(e))return Y(e),!0;let n=K(S?S(e):e.nodeName);if(dn(I.uponSanitizeElement,e,{tagName:n,allowedTags:L}),fn(e,n))return Y(e),!0;if(ft[n]||!(B.tagCheck instanceof Function&&B.tagCheck(n))&&!L[n])return pn(e,n);if((x?x(e):e.nodeType)===j.element&&!nn(e)||(n===`noscript`||n===`noembed`||n===`noframes`)&&T(Ve,e.innerHTML))return Y(e),!0;if(V&&e.nodeType===j.text){let n=sn(e.textContent);e.textContent!==n&&(ie(t.removed,{element:e.cloneNode()}),e.textContent=n)}return dn(I.afterSanitizeElements,e,null),!1},hn=function(e,t,r){if(pt[t]||Et&&(t===`id`||t===`name`)&&(r in n||r in Yt))return!1;let i=R[t]||B.attributeCheck instanceof Function&&B.attributeCheck(t,e);if(!(ht&&T(it,t))&&!(mt&&T(at,t))){if(!i){if(!(_n(e)&&(z.tagNameCheck instanceof RegExp&&T(z.tagNameCheck,e)||z.tagNameCheck instanceof Function&&z.tagNameCheck(e))&&(z.attributeNameCheck instanceof RegExp&&T(z.attributeNameCheck,t)||z.attributeNameCheck instanceof Function&&z.attributeNameCheck(t,e))||t===`is`&&z.allowCustomizedBuiltInElements&&(z.tagNameCheck instanceof RegExp&&T(z.tagNameCheck,r)||z.tagNameCheck instanceof Function&&z.tagNameCheck(r))))return!1}else if(!Ft[t]&&!T(lt,le(r,st,``))&&!((t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&ue(r,`data:`)===0&&Nt[e])&&!(gt&&!T(ot,le(r,st,``)))&&r)return!1}return!0},gn=D({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),_n=function(e){return!gn[oe(e)]&&T(ct,e)},vn=function(e,t,n,r){if(w&&typeof d==`object`&&typeof d.getAttributeType==`function`&&!n)switch(d.getAttributeType(e,t)){case`TrustedHTML`:return M(r);case`TrustedScriptURL`:return Xe(r)}return r},yn=function(e,n,r,i){try{r?e.setAttributeNS(r,n,i):e.setAttribute(n,i),ln(e)?Y(e):re(t.removed)}catch{X(n,e)}},bn=function(e){dn(I.beforeSanitizeAttributes,e,null);let t=e.attributes;if(!t||ln(e))return;let n={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:R,forceKeepAttr:void 0},r=t.length,i=K(e.nodeName);for(;r--;){let a=t[r],o=a.name,s=a.namespaceURI,c=a.value,l=K(o),u=c,d=o===`value`?u:de(u);if(n.attrName=l,n.attrValue=d,n.keepAttr=!0,n.forceKeepAttr=void 0,dn(I.uponSanitizeAttribute,e,n),d=n.attrValue,Dt&&(l===`id`||l===`name`)&&ue(d,Ot)!==0&&(X(o,e),d=Ot+d),vt&&T(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,d)){X(o,e);continue}if(l===`attributename`&&ce(d,`href`)){X(o,e);continue}if(!n.forceKeepAttr){if(!n.keepAttr){X(o,e);continue}if(!_t&&T(He,d)){X(o,e);continue}if(V&&(d=sn(d)),!hn(i,l,d)){X(o,e);continue}d=vn(i,l,s,d),d!==u&&yn(e,o,s,d)}}dn(I.afterSanitizeAttributes,e,null)},xn=function(e){let t=null,n=Q(e);for(dn(I.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(dn(I.uponSanitizeShadowNode,t,null),mn(t),bn(t),un(t.content)&&xn(t.content),(x?x(t):t.nodeType)===j.element){let e=fe(t);un(e)&&(Sn(e),xn(e))}dn(I.afterSanitizeShadowDOM,e,null)},Sn=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){xn(e.shadow);continue}let n=e.node,r=(x?x(n):n.nodeType)===j.element,i=v(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=S?S(n):null;if(typeof e==`string`&&K(e)===`template`){let e=n.content;un(e)&&t.push({node:e,shadow:null})}}if(r){let e=fe(n);un(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if(Bt=!e,Bt&&(e=`<!-->`),typeof e!=`string`&&!$(e)&&(e=_e(e),typeof e!=`string`))throw me(`dirty is not a string, aborting`);if(!t.isSupported)return e;yt?(L=bt,R=xt):J(n),(I.uponSanitizeElement.length>0||I.uponSanitizeAttribute.length>0)&&(L=O(L)),I.uponSanitizeAttribute.length>0&&(R=O(R)),t.removed=[];let c=At&&typeof e!=`string`&&$(e);if(c){let t=S?S(e):e.nodeName;if(typeof t==`string`){let e=K(t);if(!L[e]||ft[e])throw me(`root node is forbidden and cannot be sanitized in-place`)}if(ln(e))throw me(`root node is clobbered and cannot be sanitized in-place`);try{Sn(e)}catch(t){throw rn(e),t}}else if($(e))i=on(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===j.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),Sn(a);else{if(!Ct&&!V&&!H&&e.indexOf(`<`)===-1)return w&&Tt?M(e):e;if(i=on(e),!i)return Ct?null:Tt?E:``}i&&St&&Y(i.firstChild);let l=Q(c?e:i);try{for(;o=l.nextNode();)mn(o),bn(o),un(o.content)&&xn(o.content)}catch(t){throw c&&rn(e),t}if(c)return te(t.removed,e=>{e.element&&an(e.element)}),V&&cn(e),e;if(Ct){if(V&&cn(i),wt)for(s=F.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(R.shadowroot||R.shadowrootmode)&&(s=et.call(r,s,!0)),s}let u=H?i.outerHTML:i.innerHTML;return H&&L[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&T(Le,i.ownerDocument.doctype.name)&&(u=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
3
3
  `+u),V&&(u=sn(u)),w&&Tt?M(u):u},t.setConfig=function(){J(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}),yt=!0,bt=L,xt=R},t.clearConfig=function(){q=null,yt=!1,bt=null,xt=null,w=he,E=``},t.isValidAttribute=function(e,t,n){return q||J({}),hn(K(e),K(t),n)},t.addHook=function(e,t){typeof t==`function`&&C(I,e)&&ie(I[e],t)},t.removeHook=function(e,t){if(C(I,e)){if(t!==void 0){let n=ne(I[e],t);return n===-1?void 0:ae(I[e],n,1)[0]}return re(I[e])}},t.removeHooks=function(e){C(I,e)&&(I[e]=[])},t.removeAllHooks=function(){I=Ge()},t}var Je=qe();function Ye(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var M=Ye();function Xe(e){M=e}var Ze={exec:()=>null};function N(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=t[r];return i||(i=e(r),t[r]=i),i}}function P(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(F.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var Qe=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),F={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:N(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:N(e=>RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:N(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:N(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:N(e=>RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,`i`)),blockquoteBeginRegex:N(e=>RegExp(`^ {0,${e}}>`))},$e=/^(?:[ \t]*(?:\n|$))+/,et=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,I=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,tt=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,nt=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,rt=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,it=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,at=P(it).replace(/bull/g,rt).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),ot=P(it).replace(/bull/g,rt).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),st=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,ct=/^[^\n]+/,lt=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,L=P(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,lt).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),ut=P(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,rt).getRegex(),R=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,dt=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,z=P(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,dt).replace(`tag`,R).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ft=P(st).replace(`hr`,tt).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,R).getRegex(),pt={blockquote:P(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,ft).getRegex(),code:et,def:L,fences:I,heading:nt,hr:tt,html:z,lheading:at,list:ut,newline:$e,paragraph:ft,table:Ze,text:ct},B=P(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,tt).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,R).getRegex(),mt={...pt,lheading:ot,table:B,paragraph:P(st).replace(`hr`,tt).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,B).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,R).getRegex()},ht={...pt,html:P(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,dt).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Ze,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:P(st).replace(`hr`,tt).replace(`heading`,` *#{1,6} *[^
4
4
  ]`).replace(`lheading`,at).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},gt=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,_t=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,V=/^( {2,}|\\)\n(?!\s*$)/,vt=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,H=/[\p{P}\p{S}]/u,yt=/[\s\p{P}\p{S}]/u,bt=/[^\s\p{P}\p{S}]/u,xt=P(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,yt).getRegex(),St=/(?!~)[\p{P}\p{S}]/u,Ct=/(?!~)[\s\p{P}\p{S}]/u,wt=/(?:[^\s\p{P}\p{S}]|~)/u,Tt=P(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,Qe?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),Et=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Dt=P(Et,`u`).replace(/punct/g,H).getRegex(),Ot=P(Et,`u`).replace(/punct/g,St).getRegex(),kt=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,At=P(kt,`gu`).replace(/notPunctSpace/g,bt).replace(/punctSpace/g,yt).replace(/punct/g,H).getRegex(),jt=P(kt,`gu`).replace(/notPunctSpace/g,wt).replace(/punctSpace/g,Ct).replace(/punct/g,St).getRegex(),U=P(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,bt).replace(/punctSpace/g,yt).replace(/punct/g,H).getRegex(),Mt=P(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,H).getRegex(),Nt=P(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,bt).replace(/punctSpace/g,yt).replace(/punct/g,H).getRegex(),Pt=P(/\\(punct)/,`gu`).replace(/punct/g,H).getRegex(),Ft=P(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),It=P(dt).replace(`(?:-->|$)`,`-->`).getRegex(),Lt=P(`^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,It).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Rt=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,W=P(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,Rt).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),zt=P(/^!?\[(label)\]\[(ref)\]/).replace(`label`,Rt).replace(`ref`,lt).getRegex(),Bt=P(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,lt).getRegex(),Vt=P(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,zt).replace(`nolink`,Bt).getRegex(),Ht=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Ut={_backpedal:Ze,anyPunctuation:Pt,autolink:Ft,blockSkip:Tt,br:V,code:_t,del:Ze,delLDelim:Ze,delRDelim:Ze,emStrongLDelim:Dt,emStrongRDelimAst:At,emStrongRDelimUnd:U,escape:gt,link:W,nolink:Bt,punctuation:xt,reflink:zt,reflinkSearch:Vt,tag:Lt,text:vt,url:Ze},Wt={...Ut,link:P(/^!?\[(label)\]\((.*?)\)/).replace(`label`,Rt).getRegex(),reflink:P(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,Rt).getRegex()},Gt={...Ut,emStrongRDelimAst:jt,emStrongLDelim:Ot,delLDelim:Mt,delRDelim:Nt,url:P(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,Ht).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:P(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,Ht).getRegex()},Kt={...Gt,br:P(V).replace(`{2,}`,`*`).getRegex(),text:P(Gt.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},qt={normal:pt,gfm:mt,pedantic:ht},G={normal:Ut,gfm:Gt,breaks:Kt,pedantic:Wt},Jt={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},K=e=>Jt[e];function q(e,t){if(t){if(F.escapeTest.test(e))return e.replace(F.escapeReplace,K)}else if(F.escapeTestNoEncode.test(e))return e.replace(F.escapeReplaceNoEncode,K);return e}function Yt(e){try{e=encodeURI(e).replace(F.percentDecode,`%`)}catch{return null}return e}function Xt(e,t){let n=e.replace(F.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(F.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``);for(;r<n.length;r++)n[r]=n[r].trim().replace(F.slashPipe,`|`);return n}function J(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function Zt(e){let t=e.split(`
@@ -69,6 +69,6 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
69
69
  /compact [N] — summarize the head; keep the last N messages verbatim (default 10)
70
70
  /reset — reset chat history for this agent
71
71
  /help — show this list`;function vn(e){if(!e)return``;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function yn(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KiB`:`${(e/(1024*1024)).toFixed(2)} MiB`}function bn(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{let n=String(r.result),i=n.indexOf(`,`);t({name:e.name,data:i>=0?n.slice(i+1):n,mimeType:e.type||`application/octet-stream`})},r.onerror=()=>n(r.error),r.readAsDataURL(e)})}var xn=e=>e.startsWith(`image/`);function Sn(e){let t=[],n=null;for(let r of e)if(r.role===`user`)n=null,t.push({type:`user`,content:r.content,...r.images&&r.images.length>0?{images:r.images}:{}});else if(r.role===`assistant`){if(r.content&&(n=null,t.push({type:`assistant`,content:r.content})),r.toolCalls&&r.toolCalls.length>0){n||(n={type:`tool`,items:[]},t.push(n));for(let e of r.toolCalls)n.items.push({kind:`call`,id:e.id,name:e.name,body:e.arguments})}}else if(r.role===`tool`){n||(n={type:`tool`,items:[]},t.push(n));let e=r.content.startsWith(`Error:`)||r.content.startsWith(`error:`);n.items.push({kind:e?`error`:`result`,id:r.toolCallId??``,name:r.toolName??``,body:r.content}),r.images&&r.images.length>0&&(t.push({type:`images`,images:r.images}),n=null)}return t}function Cn({agentId:e,agentName:t,initialMessages:n,initialSessionHead:i}){let[a,o]=(0,r.useState)(n),[s,c]=(0,r.useState)([]),[l,u]=(0,r.useState)([]),[d,f]=(0,r.useState)(!1),[p,m]=(0,r.useState)(!1),[h,g]=(0,r.useState)(null),[_,ee]=(0,r.useState)(``),[v,y]=(0,r.useState)([]),[te,ne]=(0,r.useState)(!1),[re,ie]=(0,r.useState)(!1),ae=(0,r.useRef)(null),b=(0,r.useRef)(null),oe=(0,r.useRef)(null),se=(0,r.useRef)(null),ce=(0,r.useRef)(0),le=(0,r.useRef)(0),ue=(0,r.useRef)(i??{file:null,size:0}),de=(0,r.useRef)(!1);de.current=p,(0,r.useEffect)(()=>{o(n),c([]),u([]),g(null),ee(``),f(!1),m(!1),ie(!1),ue.current=i??{file:null,size:0}},[e]);let fe=(0,r.useRef)(!0);(0,r.useLayoutEffect)(()=>{let e=ae.current;e&&fe.current&&(e.scrollTop=e.scrollHeight)});function pe(){let e=ae.current;if(!e){fe.current=!0;return}fe.current=e.scrollHeight-e.scrollTop-e.clientHeight<pn}(0,r.useLayoutEffect)(()=>{let e=oe.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,gn)}px`)},[_]),(0,r.useEffect)(()=>{let t=`bz_pending_${e}`;function n(){document.visibilityState===`visible`&&sessionStorage.getItem(t)&&(sessionStorage.removeItem(t),window.location.reload())}return document.addEventListener(`visibilitychange`,n),()=>document.removeEventListener(`visibilitychange`,n)},[e]),(0,r.useEffect)(()=>{if(!i)return;let t=!1,n=null;async function r(){if(!t){if(!document.hidden&&!de.current&&!re)try{let t=await fetch(`/api/agents/${encodeURIComponent(e)}/sessions/head`);if(t.ok){let e=await t.json();if(typeof e.size==`number`){let t=ue.current;(e.file!==t.file||e.size!==t.size)&&ie(!0)}}}catch{}n=setTimeout(r,mn)}}return n=setTimeout(r,mn),()=>{t=!0,n&&clearTimeout(n)}},[e,i,re]);async function x(){try{let t=await fetch(`/api/agents/${encodeURIComponent(e)}/sessions/head`);if(!t.ok)return;let n=await t.json();typeof n.size==`number`&&(ue.current={file:n.file??null,size:n.size})}catch{}}function S(e){pe(),u(t=>[...t,{id:ce.current++,content:e,afterIdx:le.current}])}async function C(){try{let t=await fetch(`/api/agents/${encodeURIComponent(e)}/chat/context`);if(!t.ok){S(`/context failed: ${t.statusText}`);return}let n=await t.json(),r=(e,t)=>`${e.toLocaleString()} chars (~${t.toLocaleString()} tok)`,i=[];i.push(`context for ${n.agentId}`),i.push(`model: ${n.model}`),i.push(``),i.push(`system prompt: ${r(n.systemPrompt.chars,n.systemPrompt.tokens)}`);for(let e of n.systemPrompt.files)i.push(` - ${e.name}: ${e.chars.toLocaleString()} chars`);i.push(``),i.push(`tools: ${n.tools.count} (${n.tools.schemaChars.toLocaleString()} chars of schema)`);for(let e of n.tools.entries.slice(0,5))i.push(` - ${e.name}: ${e.schemaChars.toLocaleString()} chars`);if(n.skills.count>0){i.push(``),i.push(`skills: ${n.skills.count}`);for(let e of n.skills.entries.slice(0,10))i.push(` - ${e.name}: ${e.blockChars.toLocaleString()} chars`)}i.push(``),i.push(`history: ${n.history.messageEntries} messages / ${n.history.compactionEntries} compactions`),i.push(` ${r(n.history.chars,n.history.tokensEstimate)}`),i.push(` bytes on disk: ${yn(n.history.bytes)}`),i.push(``),i.push(`TOTAL: ${r(n.totals.chars,n.totals.tokens)}`),S(i.join(`
72
- `))}catch(e){S(`/context failed: ${e.message}`)}}async function w(){if(a.length===0){S(`/reset: history already empty`);return}if(confirm(`reset chat history for this agent?`)){D();try{let t=await fetch(`/api/agents/${encodeURIComponent(e)}/chat/reset`,{method:`POST`});if(!t.ok){let e=t.statusText;try{e=(await t.json()).error||e}catch{}S(`/reset failed: ${e}`);return}o([]),c([]),u([]),S(`/reset: history wiped`)}catch(e){S(`/reset failed: ${e.message}`)}}}async function T(t){if(a.length<2){S(`/compact: need ≥2 messages to compact`);return}let n,r=t.trim();if(r){let e=Number(r);Number.isFinite(e)&&e>=0&&(n=Math.floor(e))}D(),m(!0),f(!0);try{let t=await fetch(`/api/agents/${encodeURIComponent(e)}/chat/compact`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(n===void 0?{}:{keepTail:n})});if(!t.ok){let e=t.statusText;try{e=(await t.json()).error||e}catch{}S(`/compact failed: ${e}`);return}let r=await t.json();S(`/compact: ${r.before} → ${r.after} entries (${r.summarized} summarized, ${r.keptTail} kept verbatim; ~${r.tokensBefore.toLocaleString()} → ~${r.tokensAfter.toLocaleString()} tok). reloading…`),setTimeout(()=>window.location.reload(),400)}catch(e){S(`/compact failed: ${e.message}`)}finally{f(!1),m(!1)}}async function me(e){let t=e.trim();if(!t.startsWith(`/`))return!1;let n=t.split(/\s+/),r=(n[0]??``).toLowerCase(),i=n.slice(1).join(` `);switch(r){case`/help`:return S(_n),!0;case`/context`:return await C(),!0;case`/reset`:return await w(),!0;case`/compact`:return await T(i),!0;default:return!1}}function E(){for(let e=a.length-1;e>=0;e--)if(a[e]?.role===`user`)return e;return-1}function he(){if(s.length>0||p)return;let e=E();if(e===-1)return;let t=a[e];t&&(g(e),ee(t.content),oe.current?.focus())}function D(){g(null)}async function ge(e){if(!e)return;let t=Array.from(e);if(t.length===0)return;let n=await Promise.all(t.map(bn));y(e=>[...e,...n].slice(0,16))}function O(e){let t=Array.from(e.clipboardData.files);t.some(e=>e.type.startsWith(`image/`))&&(e.preventDefault(),ge(t))}function _e(e){p||Array.from(e.dataTransfer.types).includes(`Files`)&&(e.preventDefault(),ne(!0))}function k(e){e.currentTarget===e.target&&ne(!1)}function ve(e){e.dataTransfer.files.length>0&&(e.preventDefault(),ne(!1),ge(e.dataTransfer.files))}let ye=(0,r.useCallback)(async t=>{let n=v;if(!t.trim()&&n.length===0||p||(ee(``),await me(t)))return;y([]);let r=null;if(h!==null){let n=h;try{let i=await fetch(`/api/agents/${encodeURIComponent(e)}/chat/truncate`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({keepCount:n})});if(!i.ok){let e=i.statusText;try{e=(await i.json()).error||e}catch{}ee(t),alert(`failed to replace last turn: ${e}`);return}r=a.slice(0,n),o(r),g(null)}catch(e){ee(t),alert(`failed to replace last turn: ${e.message}`);return}}pe();let i=n.filter(e=>xn(e.mimeType)),s=n.filter(e=>!xn(e.mimeType));c([{type:`user`,content:t,...i.length>0?{images:i}:{},...s.length>0?{files:s.map(e=>({name:e.name??`file`}))}:{}}]),sessionStorage.setItem(`bz_pending_${e}`,`1`);let l=new AbortController;se.current=l,m(!0),f(!0);try{let r=await fetch(`/api/agents/${encodeURIComponent(e)}/chat`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({message:t,attachments:n}),signal:l.signal});if(!r.ok||!r.body){let e=r.statusText;try{e=(await r.json()).error||e}catch{}c(t=>[...t,{type:`error`,content:`[error] ${e}`}]);return}let i=r.body.getReader(),a=new TextDecoder,o=``;for(;;){let{done:e,value:t}=await i.read();if(e)break;o+=a.decode(t,{stream:!0});let n=o.split(`
73
- `);o=n.pop()??``;for(let e of n){if(!e.trim())continue;let t;try{t=JSON.parse(e)}catch{continue}be(t)}}if(o.trim())try{be(JSON.parse(o))}catch{}await x(),sessionStorage.removeItem(`bz_pending_${e}`)}catch(t){t.name!==`AbortError`&&c(e=>[...e,{type:`error`,content:`[network error] ${t.message}`}]),sessionStorage.removeItem(`bz_pending_${e}`)}finally{f(!1),m(!1),se.current=null}},[e,h,a,p,v]);function be(e){if(e.kind===`fatal`){c(t=>[...t,{type:`error`,content:`[fatal] ${e.error}`}]);return}if(e.kind===`done`){o(e.messages),c([]);return}if(e.kind!==`event`)return;let t=e.event;if(pe(),t.type!==`user_message`){if(t.type===`assistant_delta`){f(!1),c(e=>{let n=[...e],r=n[n.length-1];return r?.type===`assistant`?n[n.length-1]={type:`assistant`,content:r.content+t.delta}:n.push({type:`assistant`,content:t.delta}),n});return}if(t.type===`assistant_message`){f(!1),c(e=>{let n=[...e];return n[n.length-1]?.type===`assistant`?n[n.length-1]={type:`assistant`,content:t.text}:n.push({type:`assistant`,content:t.text}),n});return}if(t.type===`tool_call`||t.type===`tool_result`||t.type===`tool_error`){f(t.type!==`tool_call`);let e=t.type===`tool_call`?{kind:`call`,id:t.id,name:t.name,body:t.arguments}:t.type===`tool_result`?{kind:`result`,id:t.id,name:t.name,body:t.result}:{kind:`error`,id:t.id,name:t.name,body:t.error},n=t.type===`tool_result`?t.images:void 0;c(t=>{let r=[...t],i=r[r.length-1];return i?.type===`tool`?r[r.length-1]={type:`tool`,items:[...i.items,e]}:r.push({type:`tool`,items:[e]}),n&&n.length>0&&r.push({type:`images`,images:n}),r});return}if(t.type===`file`){c(e=>[...e,{type:`file`,name:t.name,mimeType:t.mimeType,data:t.data}]);return}t.type===`error`&&c(e=>[...e,{type:`error`,content:`[error] ${t.error}`}])}}async function xe(){try{let t=await fetch(`/api/agents/${encodeURIComponent(e)}/cancel`,{method:`POST`});if(t.ok||t.status===204)return}catch{}se.current?.abort()}function Se(e){e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),ye(_))}let A=Sn(a);le.current=A.length+s.length;let Ce=(()=>{if(s.length>0||p)return-1;for(let e=A.length-1;e>=0;e--)if(A[e]?.type===`user`)return e;return-1})(),we=(()=>{if(h===null)return-1;let e=0;for(let t=0;t<A.length;t++)if(A[t]?.type===`user`){if(e===a.slice(0,h+1).filter(e=>e.role===`user`).length-1)return t;e++}return Ce})();return(0,$.jsxs)(`div`,{className:`relative flex h-full flex-col overflow-hidden rounded-[16px] border border-frost bg-snow shadow-baziu-sm`,onDragOver:_e,onDragLeave:k,onDrop:ve,children:[te&&(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-10 flex items-center justify-center rounded-[16px] border-2 border-dashed border-sapphire bg-sapphire-glow/80 text-[0.95em] font-medium text-sapphire-deep`,children:`drop images or files to attach`}),(0,$.jsxs)(`div`,{className:`flex items-baseline justify-between border-b border-frost px-4 py-2.5`,children:[(0,$.jsx)(`h1`,{className:`font-display text-[1.2rem] text-charcoal`,children:t}),(0,$.jsx)(`a`,{href:`/agents/${e}`,className:`text-xs text-mocha-light hover:text-sapphire`,children:`settings →`})]}),re&&(0,$.jsxs)(`div`,{className:`mx-5 mt-2 flex items-center gap-2 rounded-md border border-sapphire bg-frost px-4 py-2 text-[0.86em] text-mocha`,children:[(0,$.jsx)(`span`,{className:`h-2 w-2 flex-none rounded-full bg-sapphire`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`flex-1`,children:`new activity from another source — reload to see it`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),className:`rounded-sm bg-sapphire px-3 py-1 text-[0.92em] text-snow hover:opacity-90`,children:`reload`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>ie(!1),className:`px-1 text-mocha-light hover:text-mocha`,"aria-label":`dismiss`,children:`×`})]}),(0,$.jsxs)(`div`,{ref:ae,onScroll:pe,className:`min-h-[240px] flex-1 overflow-y-auto px-5 py-5 ${h===null?``:`is-editing`}`,children:[A.length===0&&s.length===0&&l.length===0&&(0,$.jsx)(`p`,{className:`py-12 text-center italic text-fawn`,children:`start a conversation…`}),(()=>{let e=[],t=0,n=n=>{for(;t<l.length&&l[t].afterIdx<=n;){let n=l[t];e.push((0,$.jsx)(wn,{entry:{type:`system`,content:n.content}},`y-${n.id}`)),t++}};n(0);for(let t=0;t<A.length;t++){let r=A[t];e.push((0,$.jsx)(wn,{entry:r,isLastUser:t===Ce&&h===null,isWillDrop:we!==-1&&t>=we,onEdit:he},`s-${t}`)),n(t+1)}for(let t=0;t<s.length;t++){let r=s[t];e.push((0,$.jsx)(wn,{entry:r},`l-${t}`)),n(A.length+t+1)}for(;t<l.length;){let n=l[t];e.push((0,$.jsx)(wn,{entry:{type:`system`,content:n.content}},`y-${n.id}`)),t++}return e})(),d&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-1 py-1 text-[0.85em] text-mocha-light`,children:[(0,$.jsx)(Dn,{}),(0,$.jsx)(Dn,{delay:`0.15s`}),(0,$.jsx)(Dn,{delay:`0.3s`}),(0,$.jsx)(`span`,{children:`agent is thinking…`})]})]}),h!==null&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-frost bg-sapphire-glow px-5 py-2 text-[0.85em] text-sapphire-deep`,children:[(0,$.jsx)(`span`,{children:`editing last message — submit to replace, or`}),(0,$.jsx)(`button`,{type:`button`,onClick:D,className:`ml-auto rounded-sm border border-sapphire-light bg-transparent px-2 py-0.5 text-[0.92em] text-sapphire-deep hover:bg-snow`,children:`cancel`})]}),v.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2 border-t border-frost bg-ivory px-5 pt-3`,children:v.map((e,t)=>{let n=()=>y(e=>e.filter((e,n)=>n!==t));return xn(e.mimeType)?(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:`pending attachment`,className:`h-16 w-16 rounded-md border border-frost object-cover`}),(0,$.jsx)(`button`,{type:`button`,onClick:n,className:`absolute -right-1.5 -top-1.5 flex h-5 w-5 items-center justify-center rounded-full border border-frost bg-snow text-[0.7em] text-mocha hover:border-sapphire hover:text-sapphire`,"aria-label":`remove attachment`,children:`✕`})]},`${e.mimeType}-${t}`):(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 rounded-md border border-frost bg-snow px-2 py-1 text-[0.82em] text-mocha`,children:[(0,$.jsx)(`span`,{children:`📄`}),(0,$.jsx)(`span`,{className:`max-w-[160px] truncate`,children:e.name??`file`}),(0,$.jsx)(`button`,{type:`button`,onClick:n,className:`text-[0.85em] text-mocha hover:text-sapphire`,"aria-label":`remove attachment`,children:`✕`})]},`${e.name??`file`}-${t}`)})}),(0,$.jsxs)(`form`,{className:`flex items-end gap-2 border-t border-frost bg-ivory px-5 py-3`,onSubmit:e=>{e.preventDefault(),ye(_)},children:[(0,$.jsx)(`input`,{ref:b,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{ge(e.target.files),e.target.value=``}}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>b.current?.click(),disabled:p,title:`attach images or files`,"aria-label":`attach files`,className:`rounded-md border-[1.5px] border-frost bg-snow px-3 py-2 text-[1em] text-mocha transition-colors hover:border-sapphire hover:text-sapphire disabled:cursor-not-allowed disabled:opacity-50`,children:`📎`}),(0,$.jsx)(`textarea`,{ref:oe,rows:1,value:_,onChange:e=>ee(e.target.value),onKeyDown:Se,onPaste:O,disabled:p,placeholder:`say something… (Shift+Enter for newline; paste or 📎 to attach images/files)`,autoComplete:`off`,className:`max-h-[200px] min-h-[2.4rem] flex-1 resize-none overflow-y-auto rounded-md border-[1.5px] border-frost bg-snow px-3 py-2 text-[0.93em] leading-[1.45] text-chocolate outline-none transition-colors focus:border-sapphire focus:shadow-[0_0_0_3px_var(--color-sapphire-glow)]`}),(0,$.jsx)(`button`,{type:`submit`,disabled:p||!_.trim()&&v.length===0,className:`rounded-md bg-sapphire px-4 py-2 text-[0.92em] font-semibold text-snow transition-colors hover:bg-sapphire-deep disabled:cursor-not-allowed disabled:opacity-50`,children:`send`}),p&&(0,$.jsx)(`button`,{type:`button`,onClick:xe,className:`rounded-md border-[1.5px] border-frost bg-transparent px-3 py-1.5 text-[0.92em] font-medium text-mocha hover:border-sapphire-light hover:bg-sapphire-glow hover:text-sapphire`,children:`cancel`})]})]})}function wn({entry:e,isLastUser:t,isWillDrop:n,onEdit:r}){let i=n?`opacity-40 [&_.bubble-content]:line-through`:``;if(e.type===`user`){if(e.content.startsWith(dn)){let t=e.content.slice(24);return(0,$.jsxs)(`div`,{className:`my-4 flex flex-col items-end ${i}`,children:[(0,$.jsx)(`span`,{className:`mb-1 text-[0.72em] font-semibold uppercase tracking-wider text-mocha opacity-90`,children:`inbox`}),(0,$.jsx)(`div`,{className:`bubble-content max-w-[85%] whitespace-pre-wrap break-words rounded-[14px_14px_4px_14px] border border-fawn border-l-[3px] border-l-mocha-light bg-ivory px-3 py-2 font-mono text-[0.88em] leading-[1.5] text-mocha`,children:t})]})}return(0,$.jsxs)(`div`,{className:`group relative my-4 flex flex-col items-end ${i}`,children:[(0,$.jsx)(`span`,{className:`sr-only`,children:`you`}),e.images&&e.images.length>0&&(0,$.jsx)(`div`,{className:`mb-1 flex max-w-[85%] flex-wrap justify-end gap-1`,children:e.images.map((e,t)=>(0,$.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:`attachment`,className:`max-h-48 rounded-lg border border-sapphire-light`},t))}),e.files&&e.files.length>0&&(0,$.jsx)(`div`,{className:`mb-1 flex max-w-[85%] flex-wrap justify-end gap-1`,children:e.files.map((e,t)=>(0,$.jsxs)(`span`,{className:`flex items-center gap-1 rounded-md border border-sapphire-light bg-sapphire-glow px-2 py-1 text-[0.8em] text-chocolate`,children:[`📄 `,(0,$.jsx)(`span`,{className:`max-w-[180px] truncate`,children:e.name})]},t))}),e.content&&(0,$.jsx)(`div`,{className:`bubble-content max-w-[85%] whitespace-pre-wrap break-words rounded-[14px_14px_4px_14px] border border-sapphire-light bg-sapphire-glow px-3 py-2 text-chocolate`,children:e.content}),t&&r&&(0,$.jsx)(`button`,{type:`button`,onClick:r,title:`edit and resend — replaces the last turn`,className:`absolute left-1 top-1 rounded-sm border border-fawn bg-ivory px-2 py-0.5 text-[0.78em] font-medium text-mocha opacity-65 transition hover:border-sapphire hover:bg-sapphire-glow hover:text-sapphire hover:opacity-100 group-hover:opacity-100 group-focus-within:opacity-100`,children:`edit`})]})}if(e.type===`assistant`){if(e.content.startsWith(fn)){let t=e.content.slice(22).trim();return(0,$.jsx)(`div`,{className:`my-3 border-y border-dashed border-frost py-2 text-[0.85em] italic text-mocha-light ${i}`,children:(0,$.jsxs)(`details`,{children:[(0,$.jsx)(`summary`,{className:`cursor-pointer select-none text-center [&::-webkit-details-marker]:hidden`,children:`— conversation summary (click to expand) —`}),(0,$.jsx)(`div`,{className:`md-content mt-2 rounded-sm bg-frost/40 p-2 not-italic`,dangerouslySetInnerHTML:{__html:ln(t)}})]})})}return e.content.startsWith(`[error]`)||e.content.startsWith(`[fatal]`)||e.content.startsWith(`[network error]`)?(0,$.jsxs)(`div`,{className:`my-4 flex flex-col items-start ${i}`,children:[(0,$.jsx)(`span`,{className:`mb-1 text-[0.72em] font-semibold uppercase tracking-wider text-[#9B3D3D]`,children:`error`}),(0,$.jsx)(`div`,{className:`bubble-content rounded-r-sm border-l-[3px] border-l-[#9B3D3D] bg-[rgba(196,135,138,0.06)] py-1 pl-3 pr-2 leading-[1.55]`,dangerouslySetInnerHTML:{__html:ln(e.content)}})]}):(0,$.jsxs)(`div`,{className:`my-4 flex flex-col items-start ${i}`,children:[(0,$.jsx)(`span`,{className:`sr-only`,children:`agent`}),(0,$.jsx)(`div`,{className:`md-content bubble-content w-full leading-[1.55] text-chocolate`,dangerouslySetInnerHTML:{__html:ln(e.content)}})]})}if(e.type===`tool`)return(0,$.jsx)(Tn,{items:e.items,dropCls:i});if(e.type===`images`)return(0,$.jsx)(`div`,{className:`my-2 space-y-2 ${i}`,children:e.images.map((e,t)=>(0,$.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:`screenshot`,className:`block max-w-full rounded-lg border border-fawn`},t))});if(e.type===`file`){let t=e.mimeType.startsWith(`image/`),n=`data:${e.mimeType};base64,${e.data}`;return(0,$.jsxs)(`div`,{className:`my-2 ${i}`,children:[t&&(0,$.jsx)(`img`,{src:n,alt:e.name,className:`mb-1 block max-w-full rounded-lg border border-fawn`}),(0,$.jsxs)(`a`,{href:n,download:e.name,className:`inline-flex items-center gap-2 rounded-md border border-fawn bg-ivory px-3 py-2 text-[0.88em] text-mocha hover:border-sapphire hover:text-sapphire`,children:[(0,$.jsx)(`span`,{children:`📄`}),(0,$.jsx)(`span`,{className:`max-w-[260px] truncate`,children:e.name}),(0,$.jsx)(`span`,{className:`text-[0.85em] opacity-70`,children:`download`})]})]})}return e.type===`system`?(0,$.jsxs)(`div`,{className:`my-3 rounded-r-sm border-l-[3px] border-sapphire bg-sapphire-glow px-3 py-1 font-mono text-[0.88em] text-sapphire-deep ${i}`,children:[(0,$.jsx)(`span`,{className:`mr-2 font-semibold uppercase tracking-wider opacity-80`,children:`system`}),(0,$.jsx)(`span`,{className:`whitespace-pre-wrap`,children:e.content})]}):e.type===`error`?(0,$.jsx)(`div`,{className:`my-3 rounded-r-sm border-l-[3px] border-[#9B3D3D] bg-[rgba(196,135,138,0.08)] px-3 py-1 text-[0.92em] text-[#9B3D3D] ${i}`,children:e.content}):null}function Tn({items:e,dropCls:t}){let[n,i]=(0,r.useState)(!1),a=(0,r.useRef)(null),[o,s]=(0,r.useState)(!1);return(0,r.useLayoutEffect)(()=>{let e=a.current;e&&s(e.scrollHeight>324)},[e.length]),(0,$.jsxs)(`div`,{className:`my-1.5 rounded-r-sm border-l-[3px] border-fawn bg-ivory px-3 py-2 font-mono text-[0.82em] leading-[1.5] text-mocha-light ${t}`,children:[(0,$.jsxs)(`div`,{ref:a,className:`relative overflow-hidden`,style:{maxHeight:n?`none`:`${hn}px`},children:[e.map((e,t)=>(0,$.jsx)(En,{item:e},t)),o&&!n&&(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 h-10`,style:{background:`linear-gradient(to bottom, rgba(247,240,229,0), var(--color-ivory))`}})]}),o&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>i(e=>!e),className:`mt-2 rounded-sm border border-fawn bg-transparent px-2 py-0.5 text-[0.9em] text-mocha hover:border-sapphire hover:text-sapphire-deep`,children:n?`show less ↑`:`show more ↓`})]})}function En({item:e}){if(e.kind===`call`){let t=vn(e.body),n=t.includes(`
74
- `);return(0,$.jsxs)(`div`,{className:`whitespace-pre-wrap break-words py-0.5`,children:[(0,$.jsx)(`span`,{className:`mr-1 opacity-45`,children:`→`}),(0,$.jsx)(`span`,{className:`font-medium text-mocha`,children:e.name}),n?(0,$.jsx)(`pre`,{className:`ml-4 mt-0.5 rounded-sm bg-[rgba(42,31,22,0.04)] px-2 py-1 font-mono text-[0.95em] leading-[1.4] text-mocha`,children:t}):t?(0,$.jsxs)(`span`,{children:[` (`,t,`)`]}):null]})}return e.kind===`error`?(0,$.jsxs)(`div`,{className:`whitespace-pre-wrap break-words py-0.5 text-rose-baziu`,children:[(0,$.jsx)(`span`,{className:`mr-1 opacity-45`,children:`←`}),e.body]}):(0,$.jsxs)(`div`,{className:`whitespace-pre-wrap break-words py-0.5`,children:[(0,$.jsx)(`span`,{className:`mr-1 opacity-45`,children:`←`}),e.body]})}function Dn({delay:e=`0s`}){return(0,$.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 animate-pulse rounded-full bg-mocha-light/60`,style:{animationDelay:e},"aria-hidden":`true`})}export{Cn as t};
72
+ `))}catch(e){S(`/context failed: ${e.message}`)}}async function w(){if(a.length===0){S(`/reset: history already empty`);return}if(confirm(`reset chat history for this agent?`)){D();try{let t=await fetch(`/api/agents/${encodeURIComponent(e)}/chat/reset`,{method:`POST`});if(!t.ok){let e=t.statusText;try{e=(await t.json()).error||e}catch{}S(`/reset failed: ${e}`);return}o([]),c([]),u([]),S(`/reset: history wiped`)}catch(e){S(`/reset failed: ${e.message}`)}}}async function T(t){if(a.length<2){S(`/compact: need ≥2 messages to compact`);return}let n,r=t.trim();if(r){let e=Number(r);Number.isFinite(e)&&e>=0&&(n=Math.floor(e))}D(),m(!0),f(!0);try{let t=await fetch(`/api/agents/${encodeURIComponent(e)}/chat/compact`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(n===void 0?{}:{keepTail:n})});if(!t.ok){let e=t.statusText;try{e=(await t.json()).error||e}catch{}S(`/compact failed: ${e}`);return}let r=await t.json();S(`/compact: ${r.before} → ${r.after} entries (${r.summarized} summarized, ${r.keptTail} kept verbatim; ~${r.tokensBefore.toLocaleString()} → ~${r.tokensAfter.toLocaleString()} tok). reloading…`),setTimeout(()=>window.location.reload(),400)}catch(e){S(`/compact failed: ${e.message}`)}finally{f(!1),m(!1)}}async function me(e){let t=e.trim();if(!t.startsWith(`/`))return!1;let n=t.split(/\s+/),r=(n[0]??``).toLowerCase(),i=n.slice(1).join(` `);switch(r){case`/help`:return S(_n),!0;case`/context`:return await C(),!0;case`/reset`:return await w(),!0;case`/compact`:return await T(i),!0;default:return!1}}function E(){for(let e=a.length-1;e>=0;e--)if(a[e]?.role===`user`)return e;return-1}function he(){if(s.length>0||p)return;let e=E();if(e===-1)return;let t=a[e];t&&(g(e),ee(t.content),oe.current?.focus())}function D(){g(null)}async function ge(e){if(!e||p)return;let t=Array.from(e);if(t.length===0)return;let n=await Promise.all(t.map(bn));y(e=>[...e,...n].slice(0,16))}function O(e){let t=Array.from(e.clipboardData.files);t.some(e=>e.type.startsWith(`image/`))&&(e.preventDefault(),ge(t))}function _e(e){if(Array.from(e.dataTransfer.types).includes(`Files`)){if(e.preventDefault(),p){ne(!1);return}ne(!0)}}function k(e){e.currentTarget===e.target&&ne(!1)}function ve(e){e.dataTransfer.files.length!==0&&(e.preventDefault(),ne(!1),!p&&ge(e.dataTransfer.files))}let ye=(0,r.useCallback)(async t=>{let n=v;if(!t.trim()&&n.length===0||p||(ee(``),await me(t)))return;y([]);let r=null;if(h!==null){let n=h;try{let i=await fetch(`/api/agents/${encodeURIComponent(e)}/chat/truncate`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({keepCount:n})});if(!i.ok){let e=i.statusText;try{e=(await i.json()).error||e}catch{}ee(t),alert(`failed to replace last turn: ${e}`);return}r=a.slice(0,n),o(r),g(null)}catch(e){ee(t),alert(`failed to replace last turn: ${e.message}`);return}}pe();let i=n.filter(e=>xn(e.mimeType)),s=n.filter(e=>!xn(e.mimeType));c([{type:`user`,content:t,...i.length>0?{images:i}:{},...s.length>0?{files:s.map(e=>({name:e.name??`file`}))}:{}}]),sessionStorage.setItem(`bz_pending_${e}`,`1`);let l=new AbortController;se.current=l,m(!0),f(!0);try{let r=await fetch(`/api/agents/${encodeURIComponent(e)}/chat`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({message:t,attachments:n}),signal:l.signal});if(r.status===202){let t=await r.json();c(e=>[...e,{type:`error`,content:`[approval pending] ${t.approvalId} · expires ${new Date(t.expiresAt).toLocaleString()} · review in /approvals`}]),sessionStorage.removeItem(`bz_pending_${e}`);return}if(!r.ok||!r.body){let e=r.statusText;try{e=(await r.json()).error||e}catch{}c(t=>[...t,{type:`error`,content:`[error] ${e}`}]);return}let i=r.body.getReader(),a=new TextDecoder,o=``;for(;;){let{done:e,value:t}=await i.read();if(e)break;o+=a.decode(t,{stream:!0});let n=o.split(`
73
+ `);o=n.pop()??``;for(let e of n){if(!e.trim())continue;let t;try{t=JSON.parse(e)}catch{continue}be(t)}}if(o.trim())try{be(JSON.parse(o))}catch{}await x(),sessionStorage.removeItem(`bz_pending_${e}`)}catch(t){t.name!==`AbortError`&&c(e=>[...e,{type:`error`,content:`[network error] ${t.message}`}]),sessionStorage.removeItem(`bz_pending_${e}`)}finally{f(!1),m(!1),se.current=null}},[e,h,a,p,v]);function be(e){if(e.kind===`fatal`){c(t=>[...t,{type:`error`,content:`[fatal] ${e.error}`}]);return}if(e.kind===`done`){o(e.messages),c([]);return}if(e.kind!==`event`)return;let t=e.event;if(pe(),t.type!==`user_message`){if(t.type===`assistant_delta`){f(!1),c(e=>{let n=[...e],r=n[n.length-1];return r?.type===`assistant`?n[n.length-1]={type:`assistant`,content:r.content+t.delta}:n.push({type:`assistant`,content:t.delta}),n});return}if(t.type===`assistant_message`){f(!1),c(e=>{let n=[...e];return n[n.length-1]?.type===`assistant`?n[n.length-1]={type:`assistant`,content:t.text}:n.push({type:`assistant`,content:t.text}),n});return}if(t.type===`tool_call`||t.type===`tool_result`||t.type===`tool_error`){f(t.type!==`tool_call`);let e=t.type===`tool_call`?{kind:`call`,id:t.id,name:t.name,body:t.arguments}:t.type===`tool_result`?{kind:`result`,id:t.id,name:t.name,body:t.result}:{kind:`error`,id:t.id,name:t.name,body:t.error},n=t.type===`tool_result`?t.images:void 0;c(t=>{let r=[...t],i=r[r.length-1];return i?.type===`tool`?r[r.length-1]={type:`tool`,items:[...i.items,e]}:r.push({type:`tool`,items:[e]}),n&&n.length>0&&r.push({type:`images`,images:n}),r});return}if(t.type===`file`){c(e=>[...e,{type:`file`,name:t.name,mimeType:t.mimeType,data:t.data}]);return}t.type===`error`&&c(e=>[...e,{type:`error`,content:`[error] ${t.error}`}])}}async function xe(){try{let t=await fetch(`/api/agents/${encodeURIComponent(e)}/cancel`,{method:`POST`});if(t.ok||t.status===204)return}catch{}se.current?.abort()}function Se(e){e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),ye(_))}let A=Sn(a);le.current=A.length+s.length;let Ce=(()=>{if(s.length>0||p)return-1;for(let e=A.length-1;e>=0;e--)if(A[e]?.type===`user`)return e;return-1})(),we=(()=>{if(h===null)return-1;let e=0;for(let t=0;t<A.length;t++)if(A[t]?.type===`user`){if(e===a.slice(0,h+1).filter(e=>e.role===`user`).length-1)return t;e++}return Ce})();return(0,$.jsxs)(`div`,{className:`relative flex h-full flex-col overflow-hidden rounded-[16px] border border-frost bg-snow shadow-baziu-sm`,onDragOver:_e,onDragLeave:k,onDrop:ve,children:[te&&(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-10 flex items-center justify-center rounded-[16px] border-2 border-dashed border-sapphire bg-sapphire-glow/80 text-[0.95em] font-medium text-sapphire-deep`,children:`drop images or files to attach`}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-frost px-4 py-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`a`,{href:`/`,className:`inline-flex h-7 items-center rounded-md border border-frost px-2 text-xs font-semibold text-mocha lg:hidden`,children:`← agents`}),(0,$.jsx)(`h1`,{className:`truncate font-display text-[1.2rem] text-charcoal`,children:t})]}),(0,$.jsx)(`a`,{href:`/agents/${e}`,className:`shrink-0 text-xs text-mocha-light hover:text-sapphire`,children:`settings →`})]}),re&&(0,$.jsxs)(`div`,{className:`mx-5 mt-2 flex items-center gap-2 rounded-md border border-sapphire bg-frost px-4 py-2 text-[0.86em] text-mocha`,children:[(0,$.jsx)(`span`,{className:`h-2 w-2 flex-none rounded-full bg-sapphire`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`flex-1`,children:`new activity from another source — reload to see it`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),className:`rounded-sm bg-sapphire px-3 py-1 text-[0.92em] text-snow hover:opacity-90`,children:`reload`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>ie(!1),className:`px-1 text-mocha-light hover:text-mocha`,"aria-label":`dismiss`,children:`×`})]}),(0,$.jsxs)(`div`,{ref:ae,onScroll:pe,className:`min-h-[240px] flex-1 overflow-y-auto px-5 py-5 ${h===null?``:`is-editing`}`,children:[A.length===0&&s.length===0&&l.length===0&&(0,$.jsx)(`p`,{className:`py-12 text-center italic text-fawn`,children:`start a conversation…`}),(()=>{let e=[],t=0,n=n=>{for(;t<l.length&&l[t].afterIdx<=n;){let n=l[t];e.push((0,$.jsx)(wn,{entry:{type:`system`,content:n.content}},`y-${n.id}`)),t++}};n(0);for(let t=0;t<A.length;t++){let r=A[t];e.push((0,$.jsx)(wn,{entry:r,isLastUser:t===Ce&&h===null,isWillDrop:we!==-1&&t>=we,onEdit:he},`s-${t}`)),n(t+1)}for(let t=0;t<s.length;t++){let r=s[t];e.push((0,$.jsx)(wn,{entry:r},`l-${t}`)),n(A.length+t+1)}for(;t<l.length;){let n=l[t];e.push((0,$.jsx)(wn,{entry:{type:`system`,content:n.content}},`y-${n.id}`)),t++}return e})(),d&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-1 py-1 text-[0.85em] text-mocha-light`,children:[(0,$.jsx)(Dn,{}),(0,$.jsx)(Dn,{delay:`0.15s`}),(0,$.jsx)(Dn,{delay:`0.3s`}),(0,$.jsx)(`span`,{children:`agent is thinking…`})]})]}),h!==null&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-frost bg-sapphire-glow px-5 py-2 text-[0.85em] text-sapphire-deep`,children:[(0,$.jsx)(`span`,{children:`editing last message — submit to replace, or`}),(0,$.jsx)(`button`,{type:`button`,onClick:D,className:`ml-auto rounded-sm border border-sapphire-light bg-transparent px-2 py-0.5 text-[0.92em] text-sapphire-deep hover:bg-snow`,children:`cancel`})]}),v.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2 border-t border-frost bg-ivory px-5 pt-3`,children:v.map((e,t)=>{let n=()=>y(e=>e.filter((e,n)=>n!==t));return xn(e.mimeType)?(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:`pending attachment`,className:`h-16 w-16 rounded-md border border-frost object-cover`}),(0,$.jsx)(`button`,{type:`button`,onClick:n,className:`absolute -right-1.5 -top-1.5 flex h-5 w-5 items-center justify-center rounded-full border border-frost bg-snow text-[0.7em] text-mocha hover:border-sapphire hover:text-sapphire`,"aria-label":`remove attachment`,children:`✕`})]},`${e.mimeType}-${t}`):(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 rounded-md border border-frost bg-snow px-2 py-1 text-[0.82em] text-mocha`,children:[(0,$.jsx)(`span`,{children:`📄`}),(0,$.jsx)(`span`,{className:`max-w-[160px] truncate`,children:e.name??`file`}),(0,$.jsx)(`button`,{type:`button`,onClick:n,className:`text-[0.85em] text-mocha hover:text-sapphire`,"aria-label":`remove attachment`,children:`✕`})]},`${e.name??`file`}-${t}`)})}),(0,$.jsxs)(`form`,{className:`flex items-end gap-2 border-t border-frost bg-ivory px-5 py-3`,onSubmit:e=>{e.preventDefault(),ye(_)},children:[(0,$.jsx)(`input`,{ref:b,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{ge(e.target.files),e.target.value=``}}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>b.current?.click(),disabled:p,title:`attach images or files`,"aria-label":`attach files`,className:`rounded-md border-[1.5px] border-frost bg-snow px-3 py-2 text-[1em] text-mocha transition-colors hover:border-sapphire hover:text-sapphire disabled:cursor-not-allowed disabled:opacity-50`,children:`📎`}),(0,$.jsx)(`textarea`,{ref:oe,rows:1,value:_,onChange:e=>ee(e.target.value),onKeyDown:Se,onPaste:O,disabled:p,placeholder:`say something… (Shift+Enter for newline; paste or 📎 to attach images/files)`,autoComplete:`off`,className:`max-h-[200px] min-h-[2.4rem] flex-1 resize-none overflow-y-auto rounded-md border-[1.5px] border-frost bg-snow px-3 py-2 text-[0.93em] leading-[1.45] text-chocolate outline-none transition-colors focus:border-sapphire focus:shadow-[0_0_0_3px_var(--color-sapphire-glow)]`}),(0,$.jsx)(`button`,{type:`submit`,disabled:p||!_.trim()&&v.length===0,className:`rounded-md bg-sapphire px-4 py-2 text-[0.92em] font-semibold text-snow transition-colors hover:bg-sapphire-deep disabled:cursor-not-allowed disabled:opacity-50`,children:`send`}),p&&(0,$.jsx)(`button`,{type:`button`,onClick:xe,className:`rounded-md border-[1.5px] border-frost bg-transparent px-3 py-1.5 text-[0.92em] font-medium text-mocha hover:border-sapphire-light hover:bg-sapphire-glow hover:text-sapphire`,children:`cancel`})]})]})}function wn({entry:e,isLastUser:t,isWillDrop:n,onEdit:r}){let i=n?`opacity-40 [&_.bubble-content]:line-through`:``;if(e.type===`user`){if(e.content.startsWith(dn)){let t=e.content.slice(24);return(0,$.jsxs)(`div`,{className:`my-4 flex flex-col items-end ${i}`,children:[(0,$.jsx)(`span`,{className:`mb-1 text-[0.72em] font-semibold uppercase tracking-wider text-mocha opacity-90`,children:`inbox`}),(0,$.jsx)(`div`,{className:`bubble-content max-w-[85%] whitespace-pre-wrap break-words rounded-[14px_14px_4px_14px] border border-fawn border-l-[3px] border-l-mocha-light bg-ivory px-3 py-2 font-mono text-[0.88em] leading-[1.5] text-mocha`,children:t})]})}return(0,$.jsxs)(`div`,{className:`team relative my-4 flex flex-col items-end ${i}`,children:[(0,$.jsx)(`span`,{className:`sr-only`,children:`you`}),e.images&&e.images.length>0&&(0,$.jsx)(`div`,{className:`mb-1 flex max-w-[85%] flex-wrap justify-end gap-1`,children:e.images.map((e,t)=>(0,$.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:`attachment`,className:`max-h-48 rounded-lg border border-sapphire-light`},t))}),e.files&&e.files.length>0&&(0,$.jsx)(`div`,{className:`mb-1 flex max-w-[85%] flex-wrap justify-end gap-1`,children:e.files.map((e,t)=>(0,$.jsxs)(`span`,{className:`flex items-center gap-1 rounded-md border border-sapphire-light bg-sapphire-glow px-2 py-1 text-[0.8em] text-chocolate`,children:[`📄 `,(0,$.jsx)(`span`,{className:`max-w-[180px] truncate`,children:e.name})]},t))}),e.content&&(0,$.jsx)(`div`,{className:`bubble-content max-w-[85%] whitespace-pre-wrap break-words rounded-[14px_14px_4px_14px] border border-sapphire-light bg-sapphire-glow px-3 py-2 text-chocolate`,children:e.content}),t&&r&&(0,$.jsx)(`button`,{type:`button`,onClick:r,title:`edit and resend — replaces the last turn`,className:`absolute left-1 top-1 rounded-sm border border-fawn bg-ivory px-2 py-0.5 text-[0.78em] font-medium text-mocha opacity-65 transition hover:border-sapphire hover:bg-sapphire-glow hover:text-sapphire hover:opacity-100 team-hover:opacity-100 team-focus-within:opacity-100`,children:`edit`})]})}if(e.type===`assistant`){if(e.content.startsWith(fn)){let t=e.content.slice(22).trim();return(0,$.jsx)(`div`,{className:`my-3 border-y border-dashed border-frost py-2 text-[0.85em] italic text-mocha-light ${i}`,children:(0,$.jsxs)(`details`,{children:[(0,$.jsx)(`summary`,{className:`cursor-pointer select-none text-center [&::-webkit-details-marker]:hidden`,children:`— conversation summary (click to expand) —`}),(0,$.jsx)(`div`,{className:`md-content mt-2 rounded-sm bg-frost/40 p-2 not-italic`,dangerouslySetInnerHTML:{__html:ln(t)}})]})})}return e.content.startsWith(`[error]`)||e.content.startsWith(`[fatal]`)||e.content.startsWith(`[network error]`)?(0,$.jsxs)(`div`,{className:`my-4 flex flex-col items-start ${i}`,children:[(0,$.jsx)(`span`,{className:`mb-1 text-[0.72em] font-semibold uppercase tracking-wider text-danger`,children:`error`}),(0,$.jsx)(`div`,{className:`bubble-content rounded-r-sm border-l-[3px] border-l-danger bg-danger/10 py-1 pl-3 pr-2 leading-[1.55]`,dangerouslySetInnerHTML:{__html:ln(e.content)}})]}):(0,$.jsxs)(`div`,{className:`my-4 flex flex-col items-start ${i}`,children:[(0,$.jsx)(`span`,{className:`sr-only`,children:`agent`}),(0,$.jsx)(`div`,{className:`md-content bubble-content w-full leading-[1.55] text-chocolate`,dangerouslySetInnerHTML:{__html:ln(e.content)}})]})}if(e.type===`tool`)return(0,$.jsx)(Tn,{items:e.items,dropCls:i});if(e.type===`images`)return(0,$.jsx)(`div`,{className:`my-2 space-y-2 ${i}`,children:e.images.map((e,t)=>(0,$.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:`screenshot`,className:`block max-w-full rounded-lg border border-fawn`},t))});if(e.type===`file`){let t=e.mimeType.startsWith(`image/`),n=`data:${e.mimeType};base64,${e.data}`;return(0,$.jsxs)(`div`,{className:`my-2 ${i}`,children:[t&&(0,$.jsx)(`img`,{src:n,alt:e.name,className:`mb-1 block max-w-full rounded-lg border border-fawn`}),(0,$.jsxs)(`a`,{href:n,download:e.name,className:`inline-flex items-center gap-2 rounded-md border border-fawn bg-ivory px-3 py-2 text-[0.88em] text-mocha hover:border-sapphire hover:text-sapphire`,children:[(0,$.jsx)(`span`,{children:`📄`}),(0,$.jsx)(`span`,{className:`max-w-[260px] truncate`,children:e.name}),(0,$.jsx)(`span`,{className:`text-[0.85em] opacity-70`,children:`download`})]})]})}return e.type===`system`?(0,$.jsxs)(`div`,{className:`my-3 rounded-r-sm border-l-[3px] border-sapphire bg-sapphire-glow px-3 py-1 font-mono text-[0.88em] text-sapphire-deep ${i}`,children:[(0,$.jsx)(`span`,{className:`mr-2 font-semibold uppercase tracking-wider opacity-80`,children:`system`}),(0,$.jsx)(`span`,{className:`whitespace-pre-wrap`,children:e.content})]}):e.type===`error`?(0,$.jsx)(`div`,{className:`my-3 rounded-r-sm border-l-[3px] border-danger bg-danger/10 px-3 py-1 text-[0.92em] text-danger ${i}`,children:e.content}):null}function Tn({items:e,dropCls:t}){let[n,i]=(0,r.useState)(!1),a=(0,r.useRef)(null),[o,s]=(0,r.useState)(!1);return(0,r.useLayoutEffect)(()=>{let e=a.current;e&&s(e.scrollHeight>324)},[e.length]),(0,$.jsxs)(`div`,{className:`my-1.5 rounded-r-sm border-l-[3px] border-fawn bg-ivory px-3 py-2 font-mono text-[0.82em] leading-[1.5] text-mocha-light ${t}`,children:[(0,$.jsxs)(`div`,{ref:a,className:`relative overflow-hidden`,style:{maxHeight:n?`none`:`${hn}px`},children:[e.map((e,t)=>(0,$.jsx)(En,{item:e},t)),o&&!n&&(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 h-10`,style:{background:`linear-gradient(to bottom, rgba(247,240,229,0), var(--color-ivory))`}})]}),o&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>i(e=>!e),className:`mt-2 rounded-sm border border-fawn bg-transparent px-2 py-0.5 text-[0.9em] text-mocha hover:border-sapphire hover:text-sapphire-deep`,children:n?`show less ↑`:`show more ↓`})]})}function En({item:e}){if(e.kind===`call`){let t=vn(e.body),n=t.includes(`
74
+ `);return(0,$.jsxs)(`div`,{className:`whitespace-pre-wrap break-words py-0.5`,children:[(0,$.jsx)(`span`,{className:`mr-1 opacity-45`,children:`→`}),(0,$.jsx)(`span`,{className:`font-medium text-mocha`,children:e.name}),n?(0,$.jsx)(`pre`,{className:`ml-4 mt-0.5 rounded-sm bg-[rgba(42,31,22,0.04)] px-2 py-1 font-mono text-[0.95em] leading-[1.4] text-mocha`,children:t}):t?(0,$.jsxs)(`span`,{children:[` (`,t,`)`]}):null]})}return e.kind===`error`?(0,$.jsxs)(`div`,{className:`whitespace-pre-wrap break-words py-0.5 text-rose-baziu`,children:[(0,$.jsx)(`span`,{className:`mr-1 opacity-45`,children:`←`}),e.body]}):(0,$.jsxs)(`div`,{className:`whitespace-pre-wrap break-words py-0.5`,children:[(0,$.jsx)(`span`,{className:`mr-1 opacity-45`,children:`←`}),e.body]})}function Dn({delay:e=`0s`}){return(0,$.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 animate-pulse rounded-full bg-mocha-light/60`,style:{animationDelay:e},"aria-hidden":`true`})}var On=`default`,kn=`default`,An=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`];export{Cn as i,kn as n,An as r,On as t};
@@ -1,31 +1,34 @@
1
+ import { a as StatusBadge } from "./Page-LENulSXY.js";
2
+ import { n as sectionTabClass, t as SECTION_TABS_CLASS } from "./SectionTabs-BJTPr5nU.js";
1
3
  import { jsx, jsxs } from "react/jsx-runtime";
2
4
  //#region src/components/AgentTabs.tsx
3
5
  var TABS = [
4
6
  {
5
7
  key: "chat",
6
8
  href: (id) => `/agents/${id}`,
7
- label: "chat"
9
+ label: "Chat"
8
10
  },
9
11
  {
10
12
  key: "inbox",
11
13
  href: (id) => `/agents/${id}/inbox`,
12
- label: "inbox"
14
+ label: "Inbox"
13
15
  },
14
16
  {
15
17
  key: "triggers",
16
18
  href: (id) => `/agents/${id}/triggers`,
17
- label: "triggers"
19
+ label: "Triggers"
18
20
  }
19
21
  ];
20
22
  function AgentTabs({ agentId, active, archived }) {
21
23
  return /* @__PURE__ */ jsxs("nav", {
22
- className: "flex gap-1 border-b mb-6",
24
+ className: SECTION_TABS_CLASS,
23
25
  children: [TABS.map((t) => /* @__PURE__ */ jsx("a", {
24
26
  href: t.href(agentId),
25
- className: `px-3 py-2 text-sm border-b-2 -mb-px ${t.key === active ? "border-primary text-primary font-semibold" : "border-transparent text-muted-foreground hover:text-foreground"}`,
27
+ className: sectionTabClass(t.key === active),
26
28
  children: t.label
27
- }, t.key)), archived && /* @__PURE__ */ jsx("span", {
28
- className: "ml-auto self-center text-xs uppercase tracking-wide text-amber-700 bg-amber-50 border border-amber-200 rounded px-2 py-0.5",
29
+ }, t.key)), archived && /* @__PURE__ */ jsx(StatusBadge, {
30
+ variant: "warning",
31
+ className: "ml-auto self-center uppercase tracking-wide",
29
32
  children: "archived"
30
33
  })]
31
34
  });
@@ -382,7 +382,7 @@ function ChatPane({ agentId, agentName, initialMessages, initialSessionHead }) {
382
382
  setEditIdx(null);
383
383
  }
384
384
  async function addFiles(files) {
385
- if (!files) return;
385
+ if (!files || streaming) return;
386
386
  const arr = Array.from(files);
387
387
  if (arr.length === 0) return;
388
388
  const encoded = await Promise.all(arr.map(fileToAttachment));
@@ -396,21 +396,23 @@ function ChatPane({ agentId, agentName, initialMessages, initialSessionHead }) {
396
396
  }
397
397
  }
398
398
  function onDragOver(e) {
399
- if (streaming) return;
400
- if (Array.from(e.dataTransfer.types).includes("Files")) {
401
- e.preventDefault();
402
- setDragging(true);
399
+ if (!Array.from(e.dataTransfer.types).includes("Files")) return;
400
+ e.preventDefault();
401
+ if (streaming) {
402
+ setDragging(false);
403
+ return;
403
404
  }
405
+ setDragging(true);
404
406
  }
405
407
  function onDragLeave(e) {
406
408
  if (e.currentTarget === e.target) setDragging(false);
407
409
  }
408
410
  function onDrop(e) {
409
- if (e.dataTransfer.files.length > 0) {
410
- e.preventDefault();
411
- setDragging(false);
412
- addFiles(e.dataTransfer.files);
413
- }
411
+ if (e.dataTransfer.files.length === 0) return;
412
+ e.preventDefault();
413
+ setDragging(false);
414
+ if (streaming) return;
415
+ addFiles(e.dataTransfer.files);
414
416
  }
415
417
  const send = useCallback(async (text) => {
416
418
  const atts = attachments;
@@ -469,6 +471,15 @@ function ChatPane({ agentId, agentName, initialMessages, initialSessionHead }) {
469
471
  }),
470
472
  signal: abort.signal
471
473
  });
474
+ if (res.status === 202) {
475
+ const pending = await res.json();
476
+ setLiveEntries((prev) => [...prev, {
477
+ type: "error",
478
+ content: `[approval pending] ${pending.approvalId} · expires ${new Date(pending.expiresAt).toLocaleString()} · review in /approvals`
479
+ }]);
480
+ sessionStorage.removeItem(`bz_pending_${agentId}`);
481
+ return;
482
+ }
472
483
  if (!res.ok || !res.body) {
473
484
  let err = res.statusText;
474
485
  try {
@@ -665,13 +676,20 @@ function ChatPane({ agentId, agentName, initialMessages, initialSessionHead }) {
665
676
  children: "drop images or files to attach"
666
677
  }),
667
678
  /* @__PURE__ */ jsxs("div", {
668
- className: "flex items-baseline justify-between border-b border-frost px-4 py-2.5",
669
- children: [/* @__PURE__ */ jsx("h1", {
670
- className: "font-display text-[1.2rem] text-charcoal",
671
- children: agentName
679
+ className: "flex items-center justify-between gap-3 border-b border-frost px-4 py-2.5",
680
+ children: [/* @__PURE__ */ jsxs("div", {
681
+ className: "flex min-w-0 items-center gap-2",
682
+ children: [/* @__PURE__ */ jsx("a", {
683
+ href: "/",
684
+ className: "inline-flex h-7 items-center rounded-md border border-frost px-2 text-xs font-semibold text-mocha lg:hidden",
685
+ children: "← agents"
686
+ }), /* @__PURE__ */ jsx("h1", {
687
+ className: "truncate font-display text-[1.2rem] text-charcoal",
688
+ children: agentName
689
+ })]
672
690
  }), /* @__PURE__ */ jsx("a", {
673
691
  href: `/agents/${agentId}`,
674
- className: "text-xs text-mocha-light hover:text-sapphire",
692
+ className: "shrink-0 text-xs text-mocha-light hover:text-sapphire",
675
693
  children: "settings →"
676
694
  })]
677
695
  }),
@@ -877,7 +895,7 @@ function Bubble({ entry, isLastUser, isWillDrop, onEdit }) {
877
895
  });
878
896
  }
879
897
  return /* @__PURE__ */ jsxs("div", {
880
- className: `group relative my-4 flex flex-col items-end ${dropCls}`,
898
+ className: `team relative my-4 flex flex-col items-end ${dropCls}`,
881
899
  children: [
882
900
  /* @__PURE__ */ jsx("span", {
883
901
  className: "sr-only",
@@ -909,7 +927,7 @@ function Bubble({ entry, isLastUser, isWillDrop, onEdit }) {
909
927
  type: "button",
910
928
  onClick: onEdit,
911
929
  title: "edit and resend — replaces the last turn",
912
- className: "absolute left-1 top-1 rounded-sm border border-fawn bg-ivory px-2 py-0.5 text-[0.78em] font-medium text-mocha opacity-65 transition hover:border-sapphire hover:bg-sapphire-glow hover:text-sapphire hover:opacity-100 group-hover:opacity-100 group-focus-within:opacity-100",
930
+ className: "absolute left-1 top-1 rounded-sm border border-fawn bg-ivory px-2 py-0.5 text-[0.78em] font-medium text-mocha opacity-65 transition hover:border-sapphire hover:bg-sapphire-glow hover:text-sapphire hover:opacity-100 team-hover:opacity-100 team-focus-within:opacity-100",
913
931
  children: "edit"
914
932
  })
915
933
  ]
@@ -932,10 +950,10 @@ function Bubble({ entry, isLastUser, isWillDrop, onEdit }) {
932
950
  if (entry.content.startsWith("[error]") || entry.content.startsWith("[fatal]") || entry.content.startsWith("[network error]")) return /* @__PURE__ */ jsxs("div", {
933
951
  className: `my-4 flex flex-col items-start ${dropCls}`,
934
952
  children: [/* @__PURE__ */ jsx("span", {
935
- className: "mb-1 text-[0.72em] font-semibold uppercase tracking-wider text-[#9B3D3D]",
953
+ className: "mb-1 text-[0.72em] font-semibold uppercase tracking-wider text-danger",
936
954
  children: "error"
937
955
  }), /* @__PURE__ */ jsx("div", {
938
- className: "bubble-content rounded-r-sm border-l-[3px] border-l-[#9B3D3D] bg-[rgba(196,135,138,0.06)] py-1 pl-3 pr-2 leading-[1.55]",
956
+ className: "bubble-content rounded-r-sm border-l-[3px] border-l-danger bg-danger/10 py-1 pl-3 pr-2 leading-[1.55]",
939
957
  dangerouslySetInnerHTML: { __html: renderMd(entry.content) }
940
958
  })]
941
959
  });
@@ -1000,7 +1018,7 @@ function Bubble({ entry, isLastUser, isWillDrop, onEdit }) {
1000
1018
  })]
1001
1019
  });
1002
1020
  if (entry.type === "error") return /* @__PURE__ */ jsx("div", {
1003
- className: `my-3 rounded-r-sm border-l-[3px] border-[#9B3D3D] bg-[rgba(196,135,138,0.08)] px-3 py-1 text-[0.92em] text-[#9B3D3D] ${dropCls}`,
1021
+ className: `my-3 rounded-r-sm border-l-[3px] border-danger bg-danger/10 px-3 py-1 text-[0.92em] text-danger ${dropCls}`,
1004
1022
  children: entry.content
1005
1023
  });
1006
1024
  return null;
@@ -0,0 +1,68 @@
1
+ import { n as PageHeader, o as cn, r as PageShell } from "./Page-LENulSXY.js";
2
+ import { n as sectionTabClass, t as SECTION_TABS_CLASS } from "./SectionTabs-BJTPr5nU.js";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ //#region src/components/ConfigTabs.tsx
5
+ var TABS = [
6
+ {
7
+ key: "providers",
8
+ href: "/config",
9
+ label: "Providers"
10
+ },
11
+ {
12
+ key: "services",
13
+ href: "/config/services",
14
+ label: "Services"
15
+ },
16
+ {
17
+ key: "mcp",
18
+ href: "/config/mcp",
19
+ label: "MCP"
20
+ },
21
+ {
22
+ key: "integrations",
23
+ href: "/config/integrations/telegram",
24
+ label: "Integrations"
25
+ },
26
+ {
27
+ key: "tokens",
28
+ href: "/config/tokens",
29
+ label: "Tokens"
30
+ }
31
+ ];
32
+ function ConfigTabs({ active, className }) {
33
+ return /* @__PURE__ */ jsx("nav", {
34
+ "aria-label": "Configuration sections",
35
+ className: cn(SECTION_TABS_CLASS, className),
36
+ children: TABS.map((t) => /* @__PURE__ */ jsx("a", {
37
+ href: t.href,
38
+ "aria-current": t.key === active ? "page" : void 0,
39
+ className: sectionTabClass(t.key === active),
40
+ children: t.label
41
+ }, t.key))
42
+ });
43
+ }
44
+ //#endregion
45
+ //#region src/components/ConfigPage.tsx
46
+ function ConfigPage({ active, title, description, children, actions, size = "default" }) {
47
+ return /* @__PURE__ */ jsxs(PageShell, {
48
+ size,
49
+ children: [
50
+ /* @__PURE__ */ jsx(PageHeader, {
51
+ eyebrow: "Configuration",
52
+ title,
53
+ description,
54
+ actions
55
+ }),
56
+ /* @__PURE__ */ jsx(ConfigTabs, {
57
+ active,
58
+ className: "mb-0"
59
+ }),
60
+ /* @__PURE__ */ jsx("div", {
61
+ className: "space-y-6",
62
+ children
63
+ })
64
+ ]
65
+ });
66
+ }
67
+ //#endregion
68
+ export { ConfigPage as t };
@@ -33,7 +33,7 @@ function FieldRow({ field }) {
33
33
  }
34
34
  return /* @__PURE__ */ jsxs("form", {
35
35
  onSubmit: save,
36
- className: "grid grid-cols-[12rem_minmax(14rem,1fr)_auto_auto] gap-2 items-center py-2 border-b last:border-0",
36
+ className: "grid grid-cols-1 gap-2 border-b py-3 last:border-0 md:grid-cols-[12rem_minmax(0,1fr)_auto_auto] md:items-center",
37
37
  children: [
38
38
  /* @__PURE__ */ jsxs("div", {
39
39
  className: "min-w-0",
@@ -69,22 +69,22 @@ function FieldRow({ field }) {
69
69
  /* @__PURE__ */ jsxs("span", {
70
70
  className: "text-xs",
71
71
  children: [field.kind === "secret" && field.set && /* @__PURE__ */ jsx("span", {
72
- className: "rounded-full bg-emerald-100 text-emerald-800 px-1.5 py-0.5",
72
+ className: "rounded-full bg-success/10 text-success px-1.5 py-0.5",
73
73
  title: `preview: ${field.preview ?? ""}`,
74
74
  children: "set"
75
75
  }), savedAt && Date.now() - savedAt < 2e3 && /* @__PURE__ */ jsx("span", {
76
- className: "text-emerald-700 ml-2",
76
+ className: "text-success ml-2",
77
77
  children: "saved ✓"
78
78
  })]
79
79
  }),
80
80
  /* @__PURE__ */ jsx("button", {
81
81
  type: "submit",
82
82
  disabled: busy,
83
- className: "unstyled rounded-md border bg-background px-2 py-1.5 text-xs text-foreground hover:bg-accent disabled:opacity-50",
83
+ className: "unstyled justify-self-start rounded-md border bg-background px-2 py-1.5 text-xs text-foreground hover:bg-accent disabled:opacity-50 md:justify-self-auto",
84
84
  children: "save"
85
85
  }),
86
86
  err && /* @__PURE__ */ jsx("p", {
87
- className: "col-span-4 text-xs text-rose-700",
87
+ className: "text-xs text-danger md:col-span-4",
88
88
  children: err
89
89
  })
90
90
  ]
@@ -0,0 +1,111 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { clsx } from "clsx";
3
+ import { twMerge } from "tailwind-merge";
4
+ //#region src/lib/utils.ts
5
+ function cn(...inputs) {
6
+ return twMerge(clsx(inputs));
7
+ }
8
+ //#endregion
9
+ //#region src/components/Page.tsx
10
+ var PAGE_SIZE_CLASS = {
11
+ narrow: "max-w-3xl",
12
+ default: "max-w-5xl",
13
+ wide: "max-w-[1500px]"
14
+ };
15
+ function PageShell({ size = "default", className, ...props }) {
16
+ return /* @__PURE__ */ jsx("div", {
17
+ className: cn("mx-auto w-full space-y-6", PAGE_SIZE_CLASS[size], className),
18
+ ...props
19
+ });
20
+ }
21
+ function PageHeader({ eyebrow, title, description, actions, className, ...props }) {
22
+ return /* @__PURE__ */ jsxs("header", {
23
+ className: cn("flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between", className),
24
+ ...props,
25
+ children: [/* @__PURE__ */ jsxs("div", {
26
+ className: "min-w-0",
27
+ children: [
28
+ eyebrow && /* @__PURE__ */ jsx("div", {
29
+ className: "mb-1 text-xs font-semibold uppercase tracking-[0.12em] text-primary",
30
+ children: eyebrow
31
+ }),
32
+ title && /* @__PURE__ */ jsx("h1", {
33
+ className: "m-0 font-display text-3xl leading-tight text-foreground sm:text-[2.1rem]",
34
+ children: title
35
+ }),
36
+ description && /* @__PURE__ */ jsx("div", {
37
+ className: "mt-2 max-w-3xl text-sm leading-6 text-muted-foreground",
38
+ children: description
39
+ })
40
+ ]
41
+ }), actions && /* @__PURE__ */ jsx("div", {
42
+ className: "flex shrink-0 flex-wrap items-center gap-2",
43
+ children: actions
44
+ })]
45
+ });
46
+ }
47
+ function SectionCard({ title, description, actions, children, className, ...props }) {
48
+ const hasHeader = title || description || actions;
49
+ return /* @__PURE__ */ jsxs("section", {
50
+ className: cn("rounded-2xl border border-border bg-card p-5 text-card-foreground shadow-baziu-sm sm:p-6", className),
51
+ ...props,
52
+ children: [hasHeader && /* @__PURE__ */ jsxs("div", {
53
+ className: "flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",
54
+ children: [/* @__PURE__ */ jsxs("div", {
55
+ className: "min-w-0",
56
+ children: [title && /* @__PURE__ */ jsx("h2", {
57
+ className: "m-0 font-body text-base font-semibold text-foreground",
58
+ children: title
59
+ }), description && /* @__PURE__ */ jsx("div", {
60
+ className: "mt-1 text-sm leading-6 text-muted-foreground",
61
+ children: description
62
+ })]
63
+ }), actions && /* @__PURE__ */ jsx("div", {
64
+ className: "flex shrink-0 flex-wrap items-center gap-2",
65
+ children: actions
66
+ })]
67
+ }), children && /* @__PURE__ */ jsx("div", {
68
+ className: cn(hasHeader && "mt-5"),
69
+ children
70
+ })]
71
+ });
72
+ }
73
+ function EmptyState({ title, description, icon, actions, className, ...props }) {
74
+ return /* @__PURE__ */ jsxs("div", {
75
+ className: cn("flex min-h-40 flex-col items-center justify-center rounded-2xl border border-dashed border-border bg-muted/30 px-6 py-10 text-center", className),
76
+ ...props,
77
+ children: [
78
+ icon && /* @__PURE__ */ jsx("div", {
79
+ className: "mb-3 flex size-10 items-center justify-center rounded-full bg-accent text-accent-foreground",
80
+ children: icon
81
+ }),
82
+ /* @__PURE__ */ jsx("h2", {
83
+ className: "m-0 font-body text-base font-semibold text-foreground",
84
+ children: title
85
+ }),
86
+ description && /* @__PURE__ */ jsx("div", {
87
+ className: "mt-1 max-w-lg text-sm leading-6 text-muted-foreground",
88
+ children: description
89
+ }),
90
+ actions && /* @__PURE__ */ jsx("div", {
91
+ className: "mt-4 flex flex-wrap items-center justify-center gap-2",
92
+ children: actions
93
+ })
94
+ ]
95
+ });
96
+ }
97
+ var STATUS_BADGE_CLASS = {
98
+ neutral: "border-border bg-muted text-muted-foreground",
99
+ info: "border-primary/20 bg-accent text-accent-foreground",
100
+ success: "border-success/25 bg-success/10 text-success",
101
+ warning: "border-warning/25 bg-warning/10 text-warning",
102
+ danger: "border-danger/25 bg-danger/10 text-danger"
103
+ };
104
+ function StatusBadge({ variant = "neutral", className, ...props }) {
105
+ return /* @__PURE__ */ jsx("span", {
106
+ className: cn("inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-xs font-semibold leading-5", STATUS_BADGE_CLASS[variant], className),
107
+ ...props
108
+ });
109
+ }
110
+ //#endregion
111
+ export { StatusBadge as a, SectionCard as i, PageHeader as n, cn as o, PageShell as r, EmptyState as t };