bazilion 0.7.0 → 0.9.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.
- package/README.md +47 -5
- package/dist/cli.js +1257 -638
- package/dist/cli.js.map +1 -1
- package/dist/daemon.js +5334 -1594
- package/dist/daemon.js.map +1 -1
- package/dist/migrations/0001_init.sql +318 -88
- package/dist/web/client/assets/{FieldRow-CNKma5LE.js → FieldRow-DmwAFfbF.js} +1 -1
- package/dist/web/client/assets/ProductionTeamPolicyEditor-1a5jQqUB.js +7 -0
- package/dist/web/client/assets/ProductionTeamPolicyEditor-DLioOiRN.css +1 -0
- package/dist/web/client/assets/ProfileCommunicationEditor-D1OZ8WE5.js +1 -0
- package/dist/web/client/assets/RecoveryState-QfMSuwy3.js +1 -0
- package/dist/web/client/assets/TeamTabs-BViZ4sti.js +1 -0
- package/dist/web/client/assets/TemplatesTabs-DVcY9pMD.js +1 -0
- package/dist/web/client/assets/_id-8P7brhGy.js +1 -0
- package/dist/web/client/assets/_id-C3o3MHq8.js +1 -0
- package/dist/web/client/assets/_id-DGRrSF1e.js +1 -0
- package/dist/web/client/assets/_id-DGyKURCp.js +1 -0
- package/dist/web/client/assets/_id-KnJe-aW9.js +1 -0
- package/dist/web/client/assets/activity-DJuhhQCb.js +1 -0
- package/dist/web/client/assets/activity-WWvJSo4t.js +1 -0
- package/dist/web/client/assets/agents-C32T1voV.js +1 -0
- package/dist/web/client/assets/agents-nH4m4gZ1.js +1 -0
- package/dist/web/client/assets/approvals-DGi0PSx8.js +1 -0
- package/dist/web/client/assets/approvals-l8jIZjqz.js +1 -0
- package/dist/web/client/assets/{config-BSAVT-17.js → config-C7wvi1nR.js} +2 -2
- package/dist/web/client/assets/context-BEGWE3RC.js +1 -0
- package/dist/web/client/assets/inbox--4aBaAgG.js +1 -0
- package/dist/web/client/assets/index-BCXoh1c8.js +12 -0
- package/dist/web/client/assets/{login-D8lNr2SX.js → login-Bk2wwIHQ.js} +1 -1
- package/dist/web/client/assets/{mcp-BLnngDsj.js → mcp-vM7xgh9e.js} +1 -1
- package/dist/web/client/assets/members-cPKfnrSL.js +1 -0
- package/dist/web/client/assets/memory-BOcsaemD.js +1 -0
- package/dist/web/client/assets/policy-BGLCJYvS.js +1 -0
- package/dist/web/client/assets/policy-K4hIbbIN.js +1 -0
- package/dist/web/client/assets/{preload-helper-CvnapA2_.js → preload-helper-eOOCz1Fu.js} +1 -1
- package/dist/web/client/assets/routes-DnrP3dwv.js +1 -0
- package/dist/web/client/assets/services-C2_O3ifw.js +1 -0
- package/dist/web/client/assets/skills-B__fLZjx.js +1 -0
- package/dist/web/client/assets/styles-Dn24-ZvP.css +2 -0
- package/dist/web/client/assets/team-policy-BdX340m4.js +1 -0
- package/dist/web/client/assets/teams-CSNyLz3l.js +1 -0
- package/dist/web/client/assets/teams-DZMB4_iw.js +1 -0
- package/dist/web/client/assets/teams-rpaYKNIb.js +1 -0
- package/dist/web/client/assets/telegram-B1O4Ko0V.js +1 -0
- package/dist/web/client/assets/{tokens-D2_O9ARe.js → tokens-D7FH9VgA.js} +1 -1
- package/dist/web/client/assets/triggers-3PLy2_Fo.js +1 -0
- package/dist/web/client/assets/welcome-B-QQobzq.js +1 -0
- package/dist/web/client/assets/{ChatPane-DzEgOEqS.js → wire-constants-BY9Q9Z7d.js} +4 -4
- package/dist/web/server/assets/{ChatPane-BvpswYvF.js → ChatPane-Dh3qxzdb.js} +23 -12
- package/dist/web/server/assets/ProductionTeamPolicyEditor-Bke5doyl.js +1009 -0
- package/dist/web/server/assets/ProfileCommunicationEditor-C2RU-2QB.js +107 -0
- package/dist/web/server/assets/RecoveryState-B2SG-mrY.js +37 -0
- package/dist/web/server/assets/{Sidebar-DmEiewRN.js → Sidebar-CGmtCnYU.js} +372 -48
- package/dist/web/server/assets/TeamTabs-BPxDBfqy.js +50 -0
- package/dist/web/server/assets/{TemplatesTabs---7h5GYa.js → TemplatesTabs-zf4YhStd.js} +6 -6
- package/dist/web/server/assets/{_id-CXg-Blec.js → _id-5lLzLwcv.js} +52 -40
- package/dist/web/server/assets/_id-A8Xiv6Lc.js +11 -0
- package/dist/web/server/assets/{_id-BqnDy_Ca.js → _id-B04VaQlh.js} +6 -5
- package/dist/web/server/assets/{_id-D0ytyXGY.js → _id-B6g9wmPR.js} +167 -31
- package/dist/web/server/assets/_id-ButXHnRH.js +14 -0
- package/dist/web/server/assets/_id-C4AOhstq.js +44 -0
- package/dist/web/server/assets/{_id-DDixKEud.js → _id-CCHA0gdR.js} +72 -12
- package/dist/web/server/assets/{_id-D_Ew11ED.js → _id-CUWgTqMS.js} +8 -8
- package/dist/web/server/assets/_id-DJkzwHjM.js +42 -0
- package/dist/web/server/assets/{_id-CnQflrRv.js → _id-DdC9wpNN.js} +5 -5
- package/dist/web/server/assets/{_id-81NrHA5d.js → _id-DkFgCIb-.js} +9 -1
- package/dist/web/server/assets/{_id-D8duqgd5.js → _id-_nFwi9gD.js} +5 -4
- package/dist/web/server/assets/{_id-Sjw0zhA6.js → _id-fpFQ9_Ya.js} +4 -4
- package/dist/web/server/assets/_tanstack-start-manifest_v-Div-TukY.js +241 -0
- package/dist/web/server/assets/activity-C2ZKg1Q9.js +170 -0
- package/dist/web/server/assets/activity-CGCf8BQf.js +11 -0
- package/dist/web/server/assets/activity-DedraoFj.js +14 -0
- package/dist/web/server/assets/activity-GPx8NCeB.js +12 -0
- package/dist/web/server/assets/{profiles-CZ5NkmVw.js → agents-B8kinIPW.js} +4 -4
- package/dist/web/server/assets/{agents-k5QURC4I.js → agents-BR2qXlXF.js} +4 -4
- package/dist/web/server/assets/{agents-ChcAJUI5.js → agents-Bp1nsVs2.js} +1 -1
- package/dist/web/server/assets/{profiles-LxcC_L6n.js → agents-CUQmWhTp.js} +36 -10
- package/dist/web/server/assets/{agents-C7SBPN0M.js → agents-DU9Hqs58.js} +51 -12
- package/dist/web/server/assets/{profiles-C6a3RKgu.js → agents-LHowEI6S.js} +4 -4
- package/dist/web/server/assets/approvals-CbFXFvG8.js +11 -0
- package/dist/web/server/assets/approvals-DHgARzd8.js +242 -0
- package/dist/web/server/assets/approvals-Dw2LJoSA.js +14 -0
- package/dist/web/server/assets/approvals-VPc0YpLN.js +12 -0
- package/dist/web/server/assets/{auth-DzRAMwVt.js → auth-l-Vf8wlu.js} +5 -1
- package/dist/web/server/assets/{config-CdVjqjin.js → config-BvKctDOX.js} +4 -4
- package/dist/web/server/assets/{config-Bq3o924J.js → config-QvHaxGlP.js} +1 -1
- package/dist/web/server/assets/context-5lrf2ame.js +12 -0
- package/dist/web/server/assets/context-CEr4-xiA.js +49 -0
- package/dist/web/server/assets/context-D3Egm-vY.js +12 -0
- package/dist/web/server/assets/members-40DxRdVj.js +48 -0
- package/dist/web/server/assets/members-DlGBKZNl.js +12 -0
- package/dist/web/server/assets/members-ksELRsyk.js +12 -0
- package/dist/web/server/assets/{memory-Ns2-Z31p.js → memory-B5moRnnp.js} +5 -5
- package/dist/web/server/assets/{memory-BaYnfm7K.js → memory-CO0jKGzJ.js} +8 -8
- package/dist/web/server/assets/memory-CiTl4cN9.js +289 -0
- package/dist/web/server/assets/policy-BYVXqsan.js +11 -0
- package/dist/web/server/assets/policy-DNcGZLOB.js +21 -0
- package/dist/web/server/assets/policy-Dr55y-Mh.js +496 -0
- package/dist/web/server/assets/policy-Dxs78_GO.js +40 -0
- package/dist/web/server/assets/{router-BpBZgRwn.js → router-_izWQUeG.js} +156 -101
- package/dist/web/server/assets/{routes-Ce2VWrU9.js → routes-BSSKp3Rv.js} +4 -4
- package/dist/web/server/assets/{routes-C61gBiXa.js → routes-BrTOoeth.js} +5 -5
- package/dist/web/server/assets/{routes-V9URcp1v.js → routes-DOj6ljcm.js} +1 -1
- package/dist/web/server/assets/{services-B91w2f-X.js → services-CHe4ihJk.js} +11 -11
- package/dist/web/server/assets/{services-Ccc5s2bS.js → services-Pv_V88VA.js} +3 -3
- package/dist/web/server/assets/{skills-dLyBZb3B.js → skills-D89ND2kR.js} +67 -7
- package/dist/web/server/assets/{skills-CpsyR_WA.js → skills-l2cyQ3zS.js} +1 -1
- package/dist/web/server/assets/{start-CYDpZ6cb.js → start-DlHq0RaQ.js} +1 -1
- package/dist/web/server/assets/team-policy-Csvc5EDd.js +180 -0
- package/dist/web/server/assets/teams-35Oprf6e.js +14 -0
- package/dist/web/server/assets/teams-3im0oQnS.js +11 -0
- package/dist/web/server/assets/teams-B5IF65p2.js +12 -0
- package/dist/web/server/assets/teams-B9O-WDH5.js +108 -0
- package/dist/web/server/assets/teams-DFkN7ic7.js +36 -0
- package/dist/web/server/assets/teams-DH1CvWmT.js +12 -0
- package/dist/web/server/assets/teams-zcm9XaQU.js +174 -0
- package/dist/web/server/assets/{telegram-DfAddLdv.js → telegram-C9sQFwWj.js} +7 -7
- package/dist/web/server/assets/{telegram-T3l9KtiE.js → telegram-mTnJCOmn.js} +1 -1
- package/dist/web/server/assets/{welcome-CP4CZ9B6.js → welcome-CDGE2Sdk.js} +2 -2
- package/dist/web/server/assets/{wire-constants-Deb4NxBb.js → wire-constants-C8nBJcU3.js} +3 -3
- package/dist/web/server/server.js +64 -42
- package/dist/worker.js +180 -128
- package/dist/worker.js.map +1 -1
- package/package.json +7 -7
- package/dist/migrations/0002_profile_groups.sql +0 -38
- package/dist/migrations/0003_agent_telegram.sql +0 -40
- package/dist/migrations/0004_agent_mirror_mode.sql +0 -17
- package/dist/migrations/0005_group_topic_name_format.sql +0 -15
- package/dist/migrations/0006_telegram_acl.sql +0 -18
- package/dist/migrations/0007_mcp_servers.sql +0 -30
- package/dist/migrations/0008_seed_user_md.sql +0 -39
- package/dist/web/client/assets/MembersEditor-C6UpqDdV.js +0 -1
- package/dist/web/client/assets/SpawnTeamModal-BEkNCKXm.js +0 -1
- package/dist/web/client/assets/TemplatesTabs-Da7mg9FI.js +0 -1
- package/dist/web/client/assets/_id-BdKmo0gb.js +0 -1
- package/dist/web/client/assets/_id-LT6Ejjr0.js +0 -1
- package/dist/web/client/assets/_id-MR2XjWh0.js +0 -1
- package/dist/web/client/assets/_id-_6jIt0_-.js +0 -1
- package/dist/web/client/assets/agents-0arKbVYG.js +0 -1
- package/dist/web/client/assets/groups-BqTkhHes.js +0 -1
- package/dist/web/client/assets/inbox-ozoCXzr5.js +0 -1
- package/dist/web/client/assets/index-iayCEuU2.js +0 -12
- package/dist/web/client/assets/memory-D1GQjEvN.js +0 -1
- package/dist/web/client/assets/profile-groups-C2yJPTaE.js +0 -1
- package/dist/web/client/assets/profiles-BV7AAZjj.js +0 -1
- package/dist/web/client/assets/routes-DSHQLA7K.js +0 -1
- package/dist/web/client/assets/services-BbCJe1Du.js +0 -1
- package/dist/web/client/assets/skills-C6czKR5I.js +0 -1
- package/dist/web/client/assets/styles-C06axZZk.css +0 -2
- package/dist/web/client/assets/telegram-gE4j8gte.js +0 -1
- package/dist/web/client/assets/triggers-WljnfEfJ.js +0 -1
- package/dist/web/client/assets/welcome-Dn-zvmBE.js +0 -1
- package/dist/web/client/assets/wire-constants-BkT5-597.js +0 -1
- package/dist/web/server/assets/MembersEditor-BWQztvrX.js +0 -131
- package/dist/web/server/assets/SpawnTeamModal-dSN421k_.js +0 -107
- package/dist/web/server/assets/_id-BKev9H1p.js +0 -12
- package/dist/web/server/assets/_id-BNwlbWHP.js +0 -24
- package/dist/web/server/assets/_id-CRqqi8IE.js +0 -161
- package/dist/web/server/assets/_tanstack-start-manifest_v-DBlFH2gg.js +0 -178
- package/dist/web/server/assets/groups-CbSwND2r.js +0 -12
- package/dist/web/server/assets/groups-CeRRlZaZ.js +0 -150
- package/dist/web/server/assets/groups-pk4CYSuf.js +0 -21
- package/dist/web/server/assets/memory-CQaqWnyM.js +0 -284
- package/dist/web/server/assets/profile-groups-CiU06yN1.js +0 -28
- package/dist/web/server/assets/profile-groups-D21MYoLM.js +0 -208
- package/dist/web/server/assets/profile-groups-aoJleXHP.js +0 -12
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{$ as n,d as r}from"./preload-helper-eOOCz1Fu.js";import{m as i}from"./index-BCXoh1c8.js";import{t as a}from"./Button-ByiV6fpd.js";import{t as o}from"./TemplatesTabs-DVcY9pMD.js";var s=e(n()),c=t();function l(){let e=i.useLoaderData(),t=r();return(0,c.jsxs)(`div`,{children:[(0,c.jsx)(o,{}),(0,c.jsx)(`h1`,{children:`team templates`}),(0,c.jsx)(`p`,{className:`muted`,children:`The sole reusable Team roster. Every slot has stable identity and every saved definition has an immutable revision.`}),(0,c.jsx)(u,{onCreated:()=>t.invalidate()}),(0,c.jsx)(`div`,{className:`overflow-x-auto`,children:(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:`name`}),(0,c.jsx)(`th`,{children:`slots`}),(0,c.jsx)(`th`,{children:`revision`}),(0,c.jsx)(`th`,{children:`source state`})]})}),(0,c.jsxs)(`tbody`,{children:[e.map(e=>(0,c.jsxs)(`tr`,{children:[(0,c.jsx)(`td`,{children:(0,c.jsx)(`a`,{href:`/templates/teams/${encodeURIComponent(e.id)}`,children:(0,c.jsx)(`code`,{children:e.id})})}),(0,c.jsx)(`td`,{children:e.name}),(0,c.jsx)(`td`,{children:e.slotCount}),(0,c.jsx)(`td`,{children:e.currentRevision}),(0,c.jsx)(`td`,{children:e.deletedAt?`deleted source`:`canonical`})]},e.id)),e.length===0&&(0,c.jsx)(`tr`,{children:(0,c.jsx)(`td`,{colSpan:5,className:`muted`,children:`No team templates yet.`})})]})]})})]})}function u({onCreated:e}){let[t,n]=(0,s.useState)(``),[r,i]=(0,s.useState)(``),[o,l]=(0,s.useState)(null),[u,d]=(0,s.useState)(!1);async function f(a){a.preventDefault(),d(!0),l(null);try{let a=await fetch(`/api/team-templates`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({id:t.trim(),name:r.trim()})});if(!a.ok)throw Error((await a.json().catch(()=>null))?.error??a.statusText);n(``),i(``),await e()}catch(e){l(e.message)}finally{d(!1)}}return(0,c.jsxs)(`form`,{className:`card`,onSubmit:f,children:[(0,c.jsx)(`h2`,{className:`text-xl`,children:`new team template`}),o&&(0,c.jsx)(`p`,{className:`err`,children:o}),(0,c.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,c.jsxs)(`label`,{children:[`id`,(0,c.jsx)(`input`,{required:!0,value:t,onChange:e=>n(e.target.value),placeholder:`review-team`})]}),(0,c.jsxs)(`label`,{children:[`name`,(0,c.jsx)(`input`,{required:!0,value:r,onChange:e=>i(e.target.value),placeholder:`Review team`})]})]}),(0,c.jsx)(a,{variant:`primary`,type:`submit`,disabled:u,children:u?`creating…`:`create team template`})]})}export{l as component};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{$ as n,d as r}from"./preload-helper-eOOCz1Fu.js";import{S as i}from"./index-BCXoh1c8.js";var a=e(n()),o=t();function s(){let{teams:e,memberCounts:t,policies:n,readiness:a}=i.useLoaderData(),s=r();async function l(e){if(!confirm(`remove this team registration?`))return;let t=n[e]?.revision;if(!t)return;let r=await fetch(`/api/teams/${encodeURIComponent(e)}?expectedTeamPolicyRevision=${t}`,{method:`DELETE`});if(!r.ok&&r.status!==204){alert(r.statusText);return}await s.invalidate()}return(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`h1`,{children:`teams`}),(0,o.jsx)(`p`,{className:`muted`,children:`A Team owns one workspace, one live membership roster, and exactly one effective policy. Every agent belongs to exactly one Team.`}),(0,o.jsxs)(`aside`,{className:`card`,"aria-label":`TeamPolicy enforcement readiness`,children:[(0,o.jsx)(`strong`,{children:a.enforcementActive?`Team Policy enforcement is active.`:`Team Policy enforcement is currently off.`}),` `,(0,o.jsxs)(`span`,{className:`muted`,children:[`Management contract v`,a.contractVersion,` is release-ready. Set`,` `,(0,o.jsx)(`code`,{children:`BAZILION_TEAM_POLICY_ENFORCEMENT=on`}),` and restart the daemon to enforce it.`]})]}),(0,o.jsx)(c,{onRegistered:()=>s.invalidate()}),(0,o.jsx)(`div`,{className:`overflow-x-auto`,children:(0,o.jsxs)(`table`,{children:[(0,o.jsx)(`thead`,{children:(0,o.jsxs)(`tr`,{children:[(0,o.jsx)(`th`,{children:`id`}),(0,o.jsx)(`th`,{children:`name`}),(0,o.jsx)(`th`,{children:`members`}),(0,o.jsx)(`th`,{children:`policy`}),(0,o.jsx)(`th`,{children:`baseline`}),(0,o.jsx)(`th`,{})]})}),(0,o.jsxs)(`tbody`,{children:[e.length===0&&(0,o.jsx)(`tr`,{children:(0,o.jsx)(`td`,{colSpan:6,className:`muted`,children:`no teams registered`})}),e.map(e=>{let r=t[e.id]??0,i=n[e.id];return(0,o.jsxs)(`tr`,{children:[(0,o.jsx)(`td`,{children:(0,o.jsx)(`code`,{children:e.id})}),(0,o.jsx)(`td`,{children:e.name}),(0,o.jsx)(`td`,{children:r}),(0,o.jsx)(`td`,{children:(0,o.jsx)(`a`,{href:`/teams/${e.id}/policy`,children:i?`r${i.revision} · ${i.edges} edges`:`unavailable`})}),(0,o.jsx)(`td`,{children:i?.baseline??`none`}),(0,o.jsx)(`td`,{children:r===0?(0,o.jsx)(`button`,{type:`button`,className:`ghost-btn`,onClick:()=>l(e.id),children:`remove`}):(0,o.jsx)(`span`,{className:`muted`,title:`${r} agent(s) belong to this team`,children:`in use`})})]},e.id)})]})]})})]})}function c({onRegistered:e}){let[t,n]=(0,a.useState)(``),[r,i]=(0,a.useState)(``),[s,c]=(0,a.useState)(``),[l,u]=(0,a.useState)(null),[d,f]=(0,a.useState)(!1);async function p(a){if(a.preventDefault(),u(null),!t.trim()){u(`id is required`);return}f(!0);try{let a=await fetch(`/api/teams`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({id:t.trim(),name:r.trim()||void 0,link:s.trim()||void 0})});if(!a.ok){let e=await a.json().catch(()=>null);throw Error(e?.error??a.statusText)}n(``),i(``),c(``),e()}catch(e){u(e.message)}finally{f(!1)}}return(0,o.jsxs)(`form`,{className:`card`,onSubmit:p,children:[(0,o.jsx)(`h3`,{children:`register team`}),l&&(0,o.jsx)(`div`,{className:`err`,children:l}),(0,o.jsxs)(`p`,{className:`muted`,children:[`Teams always live under `,(0,o.jsx)(`code`,{children:`~/.bazilion/teams/<slug>/`}),`. Leave the link target blank to create a fresh directory; supply an absolute path to materialize the slot as a symlink to your existing project tree instead.`]}),(0,o.jsxs)(`div`,{className:`flex gap-4`,children:[(0,o.jsxs)(`label`,{className:`flex-1`,children:[`id (slug)`,(0,o.jsx)(`input`,{value:t,onChange:e=>n(e.target.value),required:!0,placeholder:`myproject`})]}),(0,o.jsxs)(`label`,{className:`flex-1`,children:[`name`,(0,o.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`My Project`})]})]}),(0,o.jsxs)(`label`,{children:[`link target (optional, absolute path)`,(0,o.jsx)(`input`,{value:s,onChange:e=>c(e.target.value),placeholder:`/home/user/projects/myproject`})]}),(0,o.jsx)(`button`,{type:`submit`,disabled:d,children:d?`registering…`:`register`})]})}export{s as component};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{$ as n,d as r}from"./preload-helper-eOOCz1Fu.js";import{a as i}from"./index-BCXoh1c8.js";import{t as a}from"./Button-ByiV6fpd.js";import{t as o}from"./ConfigTabs-pY-V0Rie.js";var s=e(n()),c=t();function l(){let e=i.useLoaderData(),t=r(),[n,l]=(0,s.useState)(``),[h,g]=(0,s.useState)(e.chatId),[_,v]=(0,s.useState)(!1),[y,b]=(0,s.useState)(null),[x,S]=(0,s.useState)(!1),[C,w]=(0,s.useState)(null),[T,E]=(0,s.useState)(!1);async function D(e){e.preventDefault(),v(!0),b(null),S(!1);try{let e=await fetch(`/api/config/telegram`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({botToken:n,chatId:h})});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error??`${e.status} ${e.statusText}`)}l(``),S(!0),await t.invalidate()}catch(e){b(e.message)}finally{v(!1)}}async function O(){if(confirm(`Clear the saved Telegram credentials?`))try{await fetch(`/api/config/telegram`,{method:`DELETE`}),l(``),g(``),w(null),S(!1),b(null),await t.invalidate()}catch(e){b(e.message)}}async function k(){E(!0),w(null);try{w(await(await fetch(`/api/config/telegram/health`)).json())}catch(e){w({configured:!0,preflight:null,error:{step:`getMe`,message:e.message},polling:null})}finally{E(!1)}}return(0,c.jsxs)(`main`,{className:`mx-auto max-w-3xl px-6 py-8`,children:[(0,c.jsx)(`h1`,{className:`font-serif text-3xl text-foreground mb-2`,children:`config`}),(0,c.jsx)(o,{active:`integrations`}),(0,c.jsxs)(`header`,{className:`mb-6`,children:[(0,c.jsx)(`h2`,{className:`text-xl font-semibold`,children:`Telegram`}),(0,c.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`One forum-supergroup bot, one topic per agent. Talk to any of your agents from a phone.`})]}),(0,c.jsx)(f,{}),e.migratedChatId&&(0,c.jsx)(d,{toChatId:e.migratedChatId}),(0,c.jsxs)(`section`,{className:`rounded-lg border bg-card p-5 mb-6`,children:[(0,c.jsx)(`h3`,{className:`text-sm font-semibold uppercase tracking-wide text-muted-foreground mb-3`,children:`Credentials`}),e.configured&&(0,c.jsxs)(`p`,{className:`text-xs text-emerald-700 mb-3`,children:[`✓ Stored: `,(0,c.jsx)(`code`,{className:`font-mono`,children:e.botTokenPreview}),` `,e.chatId&&(0,c.jsxs)(c.Fragment,{children:[`· chat `,(0,c.jsx)(`code`,{className:`font-mono`,children:e.chatId})]})]}),(0,c.jsxs)(`form`,{onSubmit:D,className:`space-y-3`,children:[(0,c.jsxs)(`label`,{className:`block`,children:[(0,c.jsx)(`span`,{className:`block text-sm font-medium mb-1`,children:`Bot token`}),(0,c.jsx)(`input`,{type:`password`,autoComplete:`off`,value:n,onChange:e=>l(e.target.value),placeholder:e.configured?`(leave blank to keep stored value)`:`1234567890:ABC...`,className:`w-full rounded-md border bg-background px-2 py-1.5 font-mono text-sm outline-none focus:ring-2 focus:ring-ring/30`,required:!e.configured}),(0,c.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:[`From @BotFather → /newbot. Disable Privacy Mode in `,(0,c.jsx)(`em`,{children:`Bot Settings → Team Privacy → Turn off`}),`.`]})]}),(0,c.jsxs)(`label`,{className:`block`,children:[(0,c.jsx)(`span`,{className:`block text-sm font-medium mb-1`,children:`Supergroup chat ID`}),(0,c.jsx)(`input`,{type:`text`,value:h,onChange:e=>g(e.target.value),placeholder:`-1001234567890`,className:`w-full rounded-md border bg-background px-2 py-1.5 font-mono text-sm outline-none focus:ring-2 focus:ring-ring/30`,required:!0}),(0,c.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:[`Forum-enabled supergroup the bot is admin in (with`,` `,(0,c.jsx)(`code`,{className:`font-mono`,children:`can_manage_topics`}),`).`]})]}),(0,c.jsxs)(`div`,{className:`flex items-center gap-3 pt-1`,children:[(0,c.jsx)(a,{variant:`primary`,type:`submit`,disabled:_,children:_?`saving…`:`save credentials`}),e.configured&&(0,c.jsx)(a,{variant:`danger`,onClick:O,children:`clear credentials`}),x&&(0,c.jsx)(`span`,{className:`text-xs text-emerald-700`,children:`saved ✓`}),y&&(0,c.jsxs)(`span`,{className:`text-xs text-rose-700`,children:[`error: `,y]})]})]})]}),(0,c.jsxs)(`section`,{className:`rounded-lg border bg-card p-5`,children:[(0,c.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,c.jsx)(`h3`,{className:`text-sm font-semibold uppercase tracking-wide text-muted-foreground`,children:`Preflight checks`}),(0,c.jsx)(a,{variant:`ghost`,onClick:k,disabled:T||!e.configured,children:T?`checking…`:`run preflight`})]}),!e.configured&&(0,c.jsx)(`p`,{className:`text-xs text-muted-foreground italic`,children:`Save credentials above first.`}),e.configured&&!C&&!T&&(0,c.jsxs)(`p`,{className:`text-xs text-muted-foreground italic`,children:[`Click `,(0,c.jsx)(`em`,{children:`run preflight`}),` to validate the stored credentials against the Telegram Bot API.`]}),C&&(0,c.jsx)(m,{health:C}),C?.polling&&(0,c.jsx)(p,{polling:C.polling})]}),e.configured&&(0,c.jsx)(u,{})]})}function u(){let[e,t]=(0,s.useState)(null),[n,r]=(0,s.useState)(``),[i,o]=(0,s.useState)(``),[l,u]=(0,s.useState)(!1),[d,f]=(0,s.useState)(null);async function p(){try{let e=await fetch(`/api/config/telegram/acl`);if(!e.ok)throw Error(e.statusText);t(await e.json())}catch(e){f(e.message)}}(0,s.useEffect)(()=>{p()},[]);async function m(e){e.preventDefault();let t=Number(n);if(!Number.isInteger(t)){f(`user id must be an integer`);return}u(!0),f(null);try{let e=await fetch(`/api/config/telegram/acl`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({userId:t,label:i.trim()||null})});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error??e.statusText)}r(``),o(``),await p()}catch(e){f(e.message)}finally{u(!1)}}async function h(e){f(null);try{let t=await fetch(`/api/config/telegram/acl/${e}`,{method:`DELETE`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??t.statusText)}await p()}catch(e){f(e.message)}}return(0,c.jsxs)(`section`,{className:`rounded-lg border bg-card p-5 mt-6`,children:[(0,c.jsx)(`h3`,{className:`text-sm font-semibold uppercase tracking-wide text-muted-foreground mb-1`,children:`Access control`}),(0,c.jsxs)(`p`,{className:`text-xs text-muted-foreground mb-3`,children:[`Allowlisted Telegram users can use the bot (commands + chat). While the list is empty the bot is open and the first person to message it becomes owner. Users find their id via`,` `,(0,c.jsx)(`code`,{className:`font-mono`,children:`/whoami`}),`.`]}),e===null?(0,c.jsx)(`p`,{className:`text-xs text-muted-foreground italic`,children:`loading…`}):e.length===0?(0,c.jsx)(`p`,{className:`text-xs text-amber-700 mb-3`,children:`Open — no allowlist yet. The first user to message the bot claims owner.`}):(0,c.jsx)(`ul`,{className:`mb-3 space-y-1 text-sm`,children:e.map(e=>(0,c.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,c.jsx)(`code`,{className:`font-mono`,children:e.userId}),(0,c.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.label??(e.username?`@${e.username}`:`—`),` · `,e.role]}),e.role!==`owner`&&(0,c.jsx)(`button`,{type:`button`,onClick:()=>void h(e.userId),className:`ghost-btn text-xs text-[#9B3D3D]`,children:`remove`})]},e.userId))}),(0,c.jsxs)(`form`,{onSubmit:m,className:`flex items-center gap-2`,children:[(0,c.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),placeholder:`user id`,className:`w-28 rounded-md border bg-background px-2 py-1 font-mono text-sm`}),(0,c.jsx)(`input`,{value:i,onChange:e=>o(e.target.value),placeholder:`label (optional)`,className:`w-40 rounded-md border bg-background px-2 py-1 text-sm`}),(0,c.jsx)(a,{variant:`ghost`,type:`submit`,disabled:l,children:`add`}),d&&(0,c.jsx)(`span`,{className:`text-xs text-rose-700`,children:d})]})]})}function d({toChatId:e}){let[t,n]=(0,s.useState)(!1),[r,i]=(0,s.useState)(null);async function o(){n(!0),i(null);try{let e=await fetch(`/api/config/telegram/reconnect`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error??e.statusText)}window.location.reload()}catch(e){i(e.message),n(!1)}}return(0,c.jsxs)(`div`,{className:`rounded-md border-2 border-rose-400 bg-rose-50 px-4 py-3 mb-6 text-sm`,children:[(0,c.jsx)(`div`,{className:`font-semibold text-rose-900 mb-1`,children:`Supergroup chat id changed`}),(0,c.jsxs)(`p`,{className:`text-rose-900 mb-2`,children:[`Telegram migrated this supergroup to a new chat id (`,(0,c.jsx)(`code`,{className:`font-mono`,children:e}),`). The bot is still pointed at the old id. Reconnect to repoint it and re-create the `,(0,c.jsx)(`code`,{className:`font-mono`,children:`⚙ bazilion`}),` `,`service chat in the new team. Agent topic bindings will reconcile on next use.`]}),(0,c.jsx)(a,{variant:`primary`,onClick:o,disabled:t,children:t?`reconnecting…`:`Reconnect to ${e}`}),r&&(0,c.jsx)(`span`,{className:`ml-3 text-xs text-rose-700`,children:r})]})}function f(){return(0,c.jsxs)(`div`,{className:`rounded-md border-2 border-amber-400 bg-amber-50 px-4 py-3 mb-6 text-sm`,children:[(0,c.jsx)(`div`,{className:`font-semibold text-amber-900 mb-1`,children:`Step 2 of the rollout`}),(0,c.jsxs)(`p`,{className:`text-amber-900`,children:[`The bot polls Telegram and creates the `,(0,c.jsx)(`code`,{className:`font-mono`,children:`⚙ bazilion`}),` `,`service chat on first start. Inbound messages are logged but not yet routed to agents —`,` `,`slash commands and per-agent topics ship in the next release. Outbound from agents ships after that.`]})]})}function p({polling:e}){let t=e.startedAt?new Date(e.startedAt).toISOString():null,n=e.lastSuccessfulPollAt?new Date(e.lastSuccessfulPollAt).toISOString():null;return(0,c.jsxs)(`div`,{className:`mt-4 rounded-md border bg-muted/30 px-3 py-2 text-xs space-y-1`,children:[(0,c.jsx)(`p`,{className:`font-semibold uppercase tracking-wide text-muted-foreground`,children:`Polling state`}),(0,c.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1 font-mono`,children:[(0,c.jsx)(`span`,{className:e.running?`text-emerald-700`:`text-rose-700`,children:e.running?`running`:`stopped`}),(0,c.jsx)(`span`,{className:e.activated?`text-emerald-700`:`text-amber-700`,children:e.activated?`activated`:`awaiting activation`}),e.lastUpdateId!==null&&(0,c.jsxs)(`span`,{children:[`last update `,e.lastUpdateId]}),t&&(0,c.jsxs)(`span`,{children:[`started `,t]}),n&&(0,c.jsxs)(`span`,{children:[`last poll `,n]})]}),e.error&&(0,c.jsxs)(`p`,{className:`text-rose-700`,children:[`error: `,e.error]})]})}function m({health:e}){if(e.error)return(0,c.jsxs)(`div`,{className:`rounded-md border border-rose-300 bg-rose-50 px-3 py-2 text-sm`,children:[(0,c.jsxs)(`p`,{className:`font-semibold text-rose-900`,children:[`Failed at `,(0,c.jsx)(`code`,{className:`font-mono`,children:e.error.step})]}),(0,c.jsx)(`p`,{className:`text-rose-900 mt-1`,children:e.error.message}),g(e.error.step)]});if(!e.preflight)return(0,c.jsx)(`p`,{className:`text-xs text-muted-foreground italic`,children:`No preflight data.`});let t=e.preflight;return(0,c.jsxs)(`ul`,{className:`space-y-1.5`,children:[(0,c.jsxs)(h,{ok:t.botUsername.length>0,label:`Bot identity`,children:[`@`,t.botUsername]}),(0,c.jsx)(h,{ok:t.chatTitle.length>0,label:`Supergroup reachable`,children:t.chatTitle}),(0,c.jsx)(h,{ok:t.isForum,label:`Forum topics enabled`,children:t.isForum?`is_forum: true`:`is_forum: false — the supergroup owner must enable Topics in team settings`}),(0,c.jsx)(h,{ok:t.hasManageTopics,label:`Bot has can_manage_topics`,children:t.hasManageTopics?`admin with can_manage_topics`:`promote the bot to admin in the supergroup with the "Manage topics" permission`}),(0,c.jsx)(h,{ok:t.privacyModeOff,label:`Privacy Mode is OFF`,children:t.privacyModeOff?`can_read_all_group_messages: true`:`BotFather → /mybots → select bot → Bot Settings → Team Privacy → Turn off`})]})}function h({ok:e,label:t,children:n}){return(0,c.jsxs)(`li`,{className:`flex items-start gap-2 text-sm`,children:[(0,c.jsx)(`span`,{className:`mt-0.5 inline-flex h-4 w-4 items-center justify-center rounded-full text-[10px] font-bold leading-none ${e?`bg-emerald-100 text-emerald-800`:`bg-rose-100 text-rose-800`}`,"aria-hidden":!0,children:e?`✓`:`✕`}),(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`span`,{className:`font-medium`,children:t}),(0,c.jsx)(`span`,{className:`ml-2 text-xs ${e?`text-muted-foreground`:`text-rose-800`}`,children:n})]})]})}function g(e){switch(e){case`getMe`:return(0,c.jsx)(`p`,{className:`text-xs text-rose-900 mt-1`,children:`The token is invalid or revoked. Re-issue with @BotFather → /token, or paste a fresh one above.`});case`getChat`:return(0,c.jsx)(`p`,{className:`text-xs text-rose-900 mt-1`,children:`The chat id either doesn't exist, points at a basic team (not a supergroup), or the bot isn't a member. Forward any message from the supergroup to the bot to double-check the id, then add the bot to the team.`});case`getChatMember`:return(0,c.jsx)(`p`,{className:`text-xs text-rose-900 mt-1`,children:`The bot is in the chat but the membership lookup failed. Usually means the bot was kicked or the chat id was migrated — confirm the bot is still in the supergroup.`})}}export{l as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{
|
|
1
|
+
import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{$ as n,d as r}from"./preload-helper-eOOCz1Fu.js";import{_ as i}from"./index-BCXoh1c8.js";import{t as a}from"./ConfigTabs-pY-V0Rie.js";var o=e(n()),s=t();function c(e){return new Date(e).toISOString().slice(0,16).replace(`T`,` `)}function l(){let{tokens:e}=i.useLoaderData(),{all:t}=i.useSearch(),n=t===`1`,l=r(),[u,d]=(0,o.useState)(``),[f,p]=(0,o.useState)(null),[m,h]=(0,o.useState)(null),[g,_]=(0,o.useState)(!1);async function v(e){e.preventDefault(),h(null),_(!0);try{let e=await fetch(`/api/tokens`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({label:u})});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error??`${e.status} ${e.statusText}`)}p((await e.json()).token),d(``),await l.invalidate()}catch(e){h(e.message)}finally{_(!1)}}async function y(e){await fetch(`/api/tokens/${e}`,{method:`DELETE`}),await l.invalidate()}return(0,s.jsxs)(`main`,{className:`mx-auto max-w-5xl px-6 py-8`,children:[(0,s.jsx)(`h1`,{className:`font-serif text-3xl text-foreground mb-2`,children:`config`}),(0,s.jsx)(a,{active:`tokens`}),(0,s.jsxs)(`p`,{className:`text-muted-foreground text-sm mb-6`,children:[`Per-client credentials for the HTTP API and CLI. The row labelled`,` `,(0,s.jsx)(`code`,{className:`font-mono`,children:`bootstrap`}),` is the loopback token in`,` `,(0,s.jsx)(`code`,{className:`font-mono`,children:`~/.bazilion/auth.json`}),` — revoking it locks the local CLI out, so it can't be revoked from this page. Mint additional tokens here for Tailscale/LAN clients (mobile, remote machines); revoke any of those at any time.`]}),(0,s.jsxs)(`section`,{className:`rounded-lg border bg-card p-5 mb-6`,children:[(0,s.jsx)(`h3`,{className:`font-serif text-xl mb-3`,children:`Mint a new token`}),(0,s.jsxs)(`form`,{onSubmit:v,className:`flex gap-2 items-end mb-3`,children:[(0,s.jsxs)(`label`,{className:`text-sm`,children:[`Label`,(0,s.jsx)(`input`,{type:`text`,value:u,onChange:e=>d(e.target.value),required:!0,placeholder:`e.g. laptop-tailscale`,autoComplete:`off`,className:`block mt-1 rounded-md border bg-background px-3 py-2 text-sm w-72`})]}),(0,s.jsx)(`button`,{type:`submit`,disabled:g,className:`rounded-md bg-primary px-3 py-2 text-sm font-medium text-primary-foreground disabled:opacity-50`,children:g?`creating…`:`create`})]}),f&&(0,s.jsxs)(`div`,{className:`rounded-md border border-amber-200 bg-amber-50 p-3`,children:[(0,s.jsx)(`p`,{className:`text-xs text-amber-800 mb-1`,children:`copy this token now — it is not recoverable later.`}),(0,s.jsx)(`pre`,{className:`font-mono text-xs whitespace-pre-wrap break-all`,children:f})]}),m&&(0,s.jsx)(`p`,{className:`text-sm text-rose-700`,children:m})]}),(0,s.jsx)(`div`,{className:`mb-3`,children:(0,s.jsxs)(`label`,{className:`text-sm flex items-center gap-2`,children:[(0,s.jsx)(`input`,{type:`checkbox`,checked:n,onChange:e=>{window.location.assign(e.target.checked?`/config/tokens?all=1`:`/config/tokens`)}}),`show revoked`]})}),(0,s.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,s.jsx)(`thead`,{className:`text-left text-muted-foreground border-b`,children:(0,s.jsxs)(`tr`,{children:[(0,s.jsx)(`th`,{className:`py-2`,children:`label`}),(0,s.jsx)(`th`,{children:`id`}),(0,s.jsx)(`th`,{children:`state`}),(0,s.jsx)(`th`,{children:`created`}),(0,s.jsx)(`th`,{children:`last used`}),(0,s.jsx)(`th`,{})]})}),(0,s.jsxs)(`tbody`,{children:[e.length===0&&(0,s.jsx)(`tr`,{children:(0,s.jsx)(`td`,{colSpan:6,className:`py-6 text-center text-muted-foreground italic`,children:`no tokens yet — mint one above`})}),e.map(e=>{let t=e.label===`bootstrap`;return(0,s.jsxs)(`tr`,{className:`border-b last:border-0 hover:bg-accent/30`,children:[(0,s.jsxs)(`td`,{className:`py-2`,children:[e.label,t&&(0,s.jsx)(`span`,{className:`ml-2 text-[0.7em] uppercase tracking-wide text-muted-foreground`,children:`auth.json`})]}),(0,s.jsx)(`td`,{children:(0,s.jsx)(`code`,{className:`font-mono text-xs`,children:e.id})}),(0,s.jsx)(`td`,{children:e.revokedAt?(0,s.jsx)(`span`,{className:`text-muted-foreground`,children:`revoked`}):(0,s.jsx)(`span`,{className:`text-emerald-700`,children:`active`})}),(0,s.jsx)(`td`,{className:`text-muted-foreground text-xs`,children:c(e.createdAt)}),(0,s.jsx)(`td`,{className:`text-muted-foreground text-xs`,children:e.lastUsedAt?c(e.lastUsedAt):`(never)`}),(0,s.jsx)(`td`,{children:!e.revokedAt&&!t&&(0,s.jsx)(`button`,{type:`button`,onClick:()=>y(e.id),className:`rounded-md border px-2 py-1 text-xs text-rose-700 hover:bg-rose-50`,children:`revoke`})})]},e.id)})]})]})]})}export{l as component};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{$ as n,d as r}from"./preload-helper-eOOCz1Fu.js";import{i}from"./index-BCXoh1c8.js";import{t as a}from"./AgentTabs-DioGqUVR.js";var o=e(n()),s=t();function c(){let{resolved:e,triggers:t}=i.useLoaderData(),n=r();async function o(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 c(e){confirm(`delete this trigger?`)&&(await fetch(`/api/triggers/${e}`,{method:`DELETE`}),await n.invalidate())}return(0,s.jsxs)(`div`,{children:[(0,s.jsx)(`header`,{className:`mb-6`,children:(0,s.jsx)(`h1`,{children:e.agent.name})}),(0,s.jsx)(a,{agentId:e.agent.id,active:`triggers`,archived:e.agent.status===`archived`}),(0,s.jsx)(l,{agentId:e.agent.id,onAdded:()=>n.invalidate()}),(0,s.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,s.jsx)(`p`,{className:`muted`,children:`no triggers yet — add one above.`}):(0,s.jsxs)(`table`,{children:[(0,s.jsx)(`thead`,{children:(0,s.jsxs)(`tr`,{children:[(0,s.jsx)(`th`,{children:`id`}),(0,s.jsx)(`th`,{children:`kind`}),(0,s.jsx)(`th`,{children:`spec`}),(0,s.jsx)(`th`,{children:`message`}),(0,s.jsx)(`th`,{children:`last fired`}),(0,s.jsx)(`th`,{})]})}),(0,s.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,s.jsxs)(`tr`,{className:e.enabled?``:`opacity-60`,children:[(0,s.jsx)(`td`,{children:(0,s.jsxs)(`code`,{children:[e.id.slice(0,8),`…`]})}),(0,s.jsx)(`td`,{children:(0,s.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,s.jsx)(`td`,{children:(0,s.jsx)(`code`,{children:t})}),(0,s.jsx)(`td`,{children:e.message.length>60?`${e.message.slice(0,60)}…`:e.message}),(0,s.jsx)(`td`,{className:`text-[0.82em] text-mocha-light`,children:n}),(0,s.jsx)(`td`,{children:(0,s.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,s.jsx)(`button`,{type:`button`,className:`ghost-btn`,onClick:()=>o(e),children:e.enabled?`disable`:`enable`}),(0,s.jsx)(`button`,{type:`button`,className:`ghost-btn`,onClick:()=>c(e.id),children:`delete`})]})})]},e.id)})})]})]})}function l({agentId:e,onAdded:t}){let[n,r]=(0,o.useState)(`interval`),[i,a]=(0,o.useState)(300),[c,l]=(0,o.useState)(``),[u,d]=(0,o.useState)(``),[f,p]=(0,o.useState)(null),[m,h]=(0,o.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`&&!c.trim()){p(`cron expression is required`);return}h(!0);try{let r={kind:n,message:u.trim()};n===`interval`?r.intervalSec=i:r.cronExpr=c.trim();let o=await fetch(`/api/agents/${encodeURIComponent(e)}/triggers`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(r)});if(!o.ok){let e=await o.json().catch(()=>null);throw Error(e?.error??o.statusText)}d(``),l(``),a(300),t()}catch(e){p(e.message)}finally{h(!1)}}return(0,s.jsxs)(`form`,{className:`card`,onSubmit:g,children:[(0,s.jsx)(`h3`,{children:`Add trigger`}),(0,s.jsxs)(`div`,{className:`mb-3 flex gap-3`,children:[(0,s.jsxs)(`label`,{className:`m-0 inline-flex cursor-pointer items-center gap-1`,children:[(0,s.jsx)(`input`,{type:`radio`,checked:n===`interval`,onChange:()=>r(`interval`)}),`interval (every N seconds)`]}),(0,s.jsxs)(`label`,{className:`m-0 inline-flex cursor-pointer items-center gap-1`,children:[(0,s.jsx)(`input`,{type:`radio`,checked:n===`cron`,onChange:()=>r(`cron`)}),`cron (5-field)`]})]}),n===`interval`?(0,s.jsxs)(`label`,{children:[`interval (seconds)`,(0,s.jsx)(`input`,{type:`number`,min:1,value:i,onChange:e=>a(Number(e.target.value))})]}):(0,s.jsxs)(`label`,{children:[`cron expression (minute hour dom month dow)`,(0,s.jsx)(`input`,{type:`text`,placeholder:`*/15 * * * *`,value:c,onChange:e=>l(e.target.value)})]}),(0,s.jsxs)(`label`,{children:[`message`,(0,s.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,s.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,s.jsx)(`button`,{type:`submit`,disabled:m,children:m?`adding…`:`add`}),f&&(0,s.jsx)(`span`,{className:`text-[0.85em] text-[#9B3D3D]`,children:f})]})]})}export{c as component};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./jsx-runtime-DGeXAQPT.js";var t=e();function n(){return(0,t.jsx)(`div`,{className:`mx-auto max-w-2xl`,children:(0,t.jsxs)(`div`,{className:`card`,children:[(0,t.jsx)(`h1`,{children:`Welcome to bazilion`}),(0,t.jsxs)(`p`,{className:`muted my-3`,children:[`Before you can spawn agents, enable a provider and save at least one concrete model id. Once you do, a `,(0,t.jsx)(`code`,{children:`default`}),` profile (and a `,(0,t.jsx)(`code`,{children:`default`}),` team directory) are created automatically and the rest of the app unlocks.`]}),(0,t.jsxs)(`ol`,{className:`my-5 space-y-4`,children:[(0,t.jsxs)(r,{n:1,children:[(0,t.jsx)(`strong`,{children:`Choose a provider.`}),` Head to the`,` `,(0,t.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,t.jsxs)(r,{n:2,children:[(0,t.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,t.jsx)(`code`,{children:`claude-opus-4-8`}),`, `,(0,t.jsx)(`code`,{children:`gpt-5.6-luna`}),`, or `,(0,t.jsx)(`code`,{children:`llama3.3`}),`) and press `,(0,t.jsx)(`em`,{children:`save models`}),`.`]}),(0,t.jsxs)(r,{n:3,children:[(0,t.jsx)(`strong`,{children:`Start chatting.`}),` You'll be redirected to the home page automatically, where a `,(0,t.jsx)(`code`,{children:`default`}),` profile is waiting for a first spawn.`]})]}),(0,t.jsx)(`a`,{href:`/config`,className:`inline-flex items-center gap-2 rounded-md bg-sapphire px-4 py-2 text-[0.92em] font-semibold text-snow no-underline transition-colors hover:bg-sapphire-deep`,children:`Go to config →`})]})})}function r({n:e,children:n}){return(0,t.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,t.jsx)(`span`,{className:`text-center font-display text-xl text-sapphire`,children:e}),(0,t.jsx)(`div`,{className:`text-[0.92em] leading-relaxed text-mocha`,children:n})]})}export{n as component};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{
|
|
1
|
+
import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{$ as n}from"./preload-helper-eOOCz1Fu.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={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},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){
|
|
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-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:`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-[#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`})}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};
|
|
@@ -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 (
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
setDragging(
|
|
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
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
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 {
|
|
@@ -877,7 +888,7 @@ function Bubble({ entry, isLastUser, isWillDrop, onEdit }) {
|
|
|
877
888
|
});
|
|
878
889
|
}
|
|
879
890
|
return /* @__PURE__ */ jsxs("div", {
|
|
880
|
-
className: `
|
|
891
|
+
className: `team relative my-4 flex flex-col items-end ${dropCls}`,
|
|
881
892
|
children: [
|
|
882
893
|
/* @__PURE__ */ jsx("span", {
|
|
883
894
|
className: "sr-only",
|
|
@@ -909,7 +920,7 @@ function Bubble({ entry, isLastUser, isWillDrop, onEdit }) {
|
|
|
909
920
|
type: "button",
|
|
910
921
|
onClick: onEdit,
|
|
911
922
|
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
|
|
923
|
+
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
924
|
children: "edit"
|
|
914
925
|
})
|
|
915
926
|
]
|