bazilion 0.57.0 → 0.57.1
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/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/web/client/assets/{AddProviderDialog-DwUu2FGE.js → AddProviderDialog-D8VvDmbM.js} +1 -1
- package/dist/web/client/assets/{AgentTemplateParts-C3BasVck.js → AgentTemplateParts-BWorU6-F.js} +1 -1
- package/dist/web/client/assets/{ConfirmDialog-BCOfW63x.js → ConfirmDialog-DrN26lN_.js} +1 -1
- package/dist/web/client/assets/{ConnectionsView-BbpY5YbI.js → ConnectionsView-DcO7RJZ7.js} +1 -1
- package/dist/web/client/assets/{SkillsParts-DoygBgF2.js → SkillsParts-BueR3HoP.js} +1 -1
- package/dist/web/client/assets/{SpawnTeamModal-BVf4yN9X.js → SpawnTeamModal-B65eQyzu.js} +1 -1
- package/dist/web/client/assets/{TeamForm-Bfb5hVUX.js → TeamForm-BhI9FbjV.js} +1 -1
- package/dist/web/client/assets/{TeamThread-BFmaBj82.js → TeamThread-FPpHlVFc.js} +1 -1
- package/dist/web/client/assets/{UnsavedChangesGuard-BUsIHSxO.js → UnsavedChangesGuard-CYz0AopL.js} +1 -1
- package/dist/web/client/assets/{_id-BapVoTMJ.js → _id-5mTcKU2j.js} +1 -1
- package/dist/web/client/assets/{_id-BRD3kxrX.js → _id-DKgyyyeX.js} +1 -1
- package/dist/web/client/assets/{access-CqcKius1.js → access-BGtASxet.js} +1 -1
- package/dist/web/client/assets/{agents-DQ8nQnD6.js → agents-BAODfMcm.js} +1 -1
- package/dist/web/client/assets/{agents-BC_ITk28.js → agents-Bfwz3dl5.js} +1 -1
- package/dist/web/client/assets/{attention-BnCihfi0.js → attention-BIC0TL8d.js} +1 -1
- package/dist/web/client/assets/{config-DYS8bkQl.js → config-kMzM8kdp.js} +1 -1
- package/dist/web/client/assets/index-DuLpyCSP.js +14 -0
- package/dist/web/client/assets/{login-DFVsVP0s.js → login-q9O7dqRe.js} +1 -1
- package/dist/web/client/assets/{manage-CpXaObuS.js → manage-DdCiSgG9.js} +1 -1
- package/dist/web/client/assets/{mcp-DslGDHmN.js → mcp-B3LzNtrr.js} +1 -1
- package/dist/web/client/assets/{routes-D1wFPm0n.js → routes-BDdLZEGO.js} +3 -3
- package/dist/web/client/assets/{skills-DmIo3vN3.js → skills-VEtq-MQJ.js} +1 -1
- package/dist/web/client/assets/{style-CqkCFvvz.js → style-J8ypSsCb.js} +1 -1
- package/dist/web/client/assets/{system-CUW9JZ9c.js → system-DtBBeAjO.js} +1 -1
- package/dist/web/client/assets/{teams-DrhG8KiS.js → teams-D4X9oNx8.js} +1 -1
- package/dist/web/client/assets/{teams-DJzYsuh9.js → teams-QlaY2Sxd.js} +1 -1
- package/dist/web/client/assets/{telegram-Bk_kg8hb.js → telegram-B7vlTQbt.js} +1 -1
- package/dist/web/client/assets/{tools-z9Ixmuu2.js → tools-C0FIeAL1.js} +1 -1
- package/dist/web/client/assets/{usage-DGe3x1m7.js → usage-3mYfS5C-.js} +1 -1
- package/dist/web/client/assets/{welcome-DDKqxHkF.js → welcome-CkmanVa_.js} +1 -1
- package/dist/web/server/assets/{_tanstack-start-manifest_v-w2xn07aY.js → _tanstack-start-manifest_v-DIMayzEa.js} +57 -57
- package/dist/web/server/assets/{router-Ci_9VxDk.js → router-DizFxqh-.js} +59 -1
- package/dist/web/server/server.js +2 -2
- package/package.json +1 -1
- package/dist/web/client/assets/index-CxXsZzDC.js +0 -14
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as e,Z as t,a as n,d as r,h as i,s as a,t as o}from"./createLucideIcon-CZHSSDYA.js";import{t as s}from"./Button-CoKQRO-s.js";import{a as c,d as l,f as u,g as d,h as f,l as p,o as m,p as h,r as g,s as _,t as v,u as y,x as b,y as x}from"./parts-C104qEuC.js";import{t as S}from"./bot-BHky7KAX.js";import{t as C}from"./list-checks-DdTdAQXS.js";import{A as w,D as T,E,I as D,M as O,Mt as ee,N as k,S as A,T as j,c as M}from"./index-CxXsZzDC.js";import{r as te}from"./use-resource-qjIkNQDY.js";import{t as N}from"./ConfirmDialog-BCOfW63x.js";import{t as ne}from"./ConfigPage-DFmHgEaL.js";var P=o(`shield-check`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),F=o(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),I=e(t(),1),L={label:`Running`,tone:`success`},R={label:`Not running`,tone:`warning`};function re({configured:e,restarting:t,health:n,ready:r}){if(!e)return{label:`Not connected`,tone:`neutral`};if(t)return{label:`Restarting…`,tone:`neutral`};if(n){let e=n.polling;return e?.running?n.error||e.error?{label:`Failing`,tone:`warning`}:e.activated?L:{label:`Setting up the group`,tone:`warning`}:R}return r===void 0?null:r?L:R}function z(e){let t=[{ok:e.botUsername.length>0,label:`Bot identity`,detail:`@${e.botUsername}`},{ok:e.chatTitle.length>0,label:`Supergroup reachable`,detail:e.chatTitle},{ok:e.isForum,label:`Forum topics enabled`,detail:e.isForum?`is_forum: true`:`is_forum: false — the supergroup owner must enable Topics in group settings`},{ok:e.hasManageTopics,label:`Bot has can_manage_topics`,detail:e.hasManageTopics?`admin with can_manage_topics`:`promote the bot to admin in the supergroup with the "Manage topics" permission`},{ok:e.privacyModeOff,label:`Privacy Mode is OFF`,detail:e.privacyModeOff?`can_read_all_group_messages: true`:`BotFather → /mybots → select bot → Bot Settings → Group Privacy → Turn off`},{ok:e.chatIsPrivate,label:`Supergroup is private`,detail:e.chatIsPrivate?`no public @username`:`public groups expose topic content to readers`}];return e.ownerPresent!==null&&t.push({ok:e.ownerPresent,label:`Paired owner is present`,detail:e.ownerPresent?`owner membership confirmed`:`owner missing — Telegram ingress is degraded`}),t}function ie(e){switch(e){case`getMe`:return`The token is invalid or revoked. Re-issue it with @BotFather → /token, or paste a fresh one above.`;case`getChat`:return`The chat id either does not exist, points at a basic group (not a supergroup), or the bot is not a member. Forward any message from the supergroup to the bot to double-check the id, then add the bot to the group.`;case`getChatMember`:return`The bot is in the chat but the membership lookup failed. This usually means the bot was removed or the chat id was migrated: confirm the bot is still in the supergroup.`}}function ae(e){if(!e)return null;if(e.error)return{label:`Failed`,tone:`warning`};if(!e.preflight)return null;let t=z(e.preflight).filter(e=>!e.ok).length;return t===0?{label:`All passed`,tone:`success`}:{label:t===1?`1 to put right`:`${t} to put right`,tone:`warning`}}function B(e){return e?e.paired?{label:`Paired`,tone:`success`}:{label:e.challengeActive?`Waiting for the code`:`Not paired`,tone:`warning`}:null}function V(e){return e.some(e=>e.role===`owner`)}function H(e){return e?V(e)?{label:e.length===1?`1 person`:`${e.length} people`,tone:`neutral`}:{label:`Closed`,tone:`warning`}:null}function U(e){return e.label??(e.username?`@${e.username}`:String(e.userId))}function W(e){return e?e.enabled?e.telegramReady?{label:`On`,tone:`success`}:{label:`Waiting for the bot`,tone:`warning`}:{label:`Off`,tone:`neutral`}:null}var G=/^\d+:[A-Za-z0-9_-]+$/,K=/^-?\d+$/;function q(e,t){let n=t.token.trim(),r=t.chatId.trim(),i=r!==e.chatId,a={};n&&!G.test(n)&&(a.token=`A token from @BotFather looks like 1234567890:ABC…`),r&&!K.test(r)?a.chatId=`A supergroup’s id is a number, like -1001234567890.`:!r&&e.configured&&(a.chatId=`The bot needs a group. To remove Telegram, disconnect it below.`);let o=!a.token&&!a.chatId,s=n!==``||i,c=J(e)&&i,l=c&&r!==``&&n===``&&o,u=n!==``&&r!==``;return{dirty:s,problems:a,needsToken:l,tokenOpen:c,incomplete:s&&o&&!u&&!l,body:o&&u?{botToken:n,chatId:r}:null}}function J(e){return e.botTokenPreview!==``}function oe(e,t){return{enabled:e.enabled,kinds:e.kinds,quiet:e.quietHours!==null,start:e.quietHours?.start??`22:00`,end:e.quietHours?.end??`07:00`,timezone:e.enabled||e.quietHours?e.timezone:t}}function Y(e){return{enabled:e.enabled,kinds:e.kinds,timezone:e.timezone.trim(),quietHours:e.quiet?{start:e.start,end:e.end}:null}}function se(e,t){let n=e=>{let{kinds:t,...n}=Y(e);return JSON.stringify({...n,kinds:[...t].sort()})};return n(e)===n(t)}var X=i(),Z={lesson_proposal:`Lesson proposals`,review_failure:`Review failures`,trigger_failure:`Scheduled trigger failures`,agent_loop_break:`Agent message loop breaks`,queue_interrupted:`Queues paused after restart`,turn_failure:`Failed background turns`};function ce(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`}catch{return`UTC`}}function le({settings:e,error:t,onSaved:n}){let[r,i]=(0,I.useState)(0),a=W(e);return(0,X.jsx)(x,{labelledBy:`telegram-notifications`,icon:(0,X.jsx)(ee,{className:`size-5`}),title:`Attention notifications`,description:`Posts each new Attention item of the kinds you choose to the bot’s service topic, once. Items that were already open when you switch this on are not sent.`,action:a&&(0,X.jsx)(l,{tone:a.tone,children:a.label}),children:e?(0,X.jsx)(ue,{settings:e,justSaved:r>0,onSaved:async()=>{await n(),i(e=>e+1)}},r):(0,X.jsx)(g,{children:t?(0,X.jsx)(d,{tone:`warning`,role:`alert`,title:`The settings could not be loaded.`,children:t}):(0,X.jsx)(b,{children:`Loading…`})})})}function ue({settings:e,justSaved:t,onSaved:r}){let[i]=(0,I.useState)(()=>oe(e,ce())),[o,s]=(0,I.useState)(i),[l,u]=(0,I.useState)(!1),[f,p]=(0,I.useState)(null),[m,h]=(0,I.useState)(!1),g=!se(i,o),_=o.kinds.length===0,v=o.quiet&&o.timezone.trim()===``,y=e=>{h(!0),p(null),s(t=>({...t,...e}))};async function b(e){if(e.preventDefault(),!(!g||_||v||l)){u(!0),p(null);try{await n(`/api/notifications`,{method:`PUT`,body:Y(o)}),await r()}catch(e){p(a(e))}finally{u(!1)}}}return(0,X.jsxs)(c,{onSubmit:b,children:[!e.telegramReady&&(0,X.jsx)(d,{tone:`neutral`,children:`The bot is not running yet; notices go out once it is connected and activated.`}),(0,X.jsx)(w,{label:`Send Attention notifications to Telegram`,checked:o.enabled,disabled:l,onChange:e=>y({enabled:e})}),(0,X.jsxs)(`fieldset`,{className:`m-0 min-w-0 border-0 p-0`,disabled:l,children:[(0,X.jsx)(`legend`,{className:`mb-2 p-0 text-sm font-semibold text-foreground`,children:`Kinds`}),(0,X.jsx)(`div`,{className:`grid gap-x-6 gap-y-2.5 sm:grid-cols-2`,children:Object.keys(Z).map(e=>(0,X.jsx)(A,{label:Z[e],checked:o.kinds.includes(e),onChange:t=>y({kinds:t?[...o.kinds,e]:o.kinds.filter(t=>t!==e)})},e))}),_&&(0,X.jsx)(j,{children:`Choose at least one kind.`})]}),(0,X.jsx)(w,{label:`Quiet hours`,description:`Notices wait until they end.`,checked:o.quiet,disabled:l,onChange:e=>y({quiet:e})}),o.quiet&&(0,X.jsxs)(`div`,{className:`grid items-start gap-x-3 gap-y-4 sm:grid-cols-[8.5rem_8.5rem_minmax(0,18rem)]`,children:[(0,X.jsx)(O,{label:`From`,type:`time`,value:o.start,disabled:l,required:!0,onChange:e=>y({start:e})}),(0,X.jsx)(O,{label:`To`,type:`time`,value:o.end,disabled:l,required:!0,onChange:e=>y({end:e})}),(0,X.jsx)(O,{label:`Timezone`,value:o.timezone,disabled:l,required:!0,placeholder:`Europe/Warsaw`,problem:v?`Quiet hours need a timezone.`:void 0,onChange:e=>y({timezone:e})})]}),(0,X.jsx)(E,{busy:l,disabled:!g||_||v,status:k({error:f,dirty:g,saved:t&&!m})})]})}var Q=`/api/config/telegram`;function $({state:e}){return e&&(0,X.jsx)(l,{tone:e.tone,children:e.label})}function de(){let[e,t]=(0,I.useState)(null),[r,i]=(0,I.useState)(``),[o,l]=(0,I.useState)(``),[u,p]=(0,I.useState)(!1),[h,v]=(0,I.useState)(null),[y,S]=(0,I.useState)(null),C=`${Q}/acl`,w=async()=>t(await n(C));(0,I.useEffect)(()=>{w().catch(e=>v(a(e)))},[]);let T=r.trim(),E=T!==``&&!/^\d+$/.test(T)?`A Telegram user id is a number, like 123456789.`:void 0;async function D(e){if(e.preventDefault(),!(T===``||E||u)){p(!0),v(null);try{await n(C,{body:{userId:Number(T),label:o.trim()||null}}),i(``),l(``),await w()}catch(e){v(a(e))}finally{p(!1)}}}return(0,X.jsxs)(x,{labelledBy:`telegram-allowed`,icon:(0,X.jsx)(F,{className:`size-5`}),title:`Allowed users`,description:(0,X.jsxs)(X.Fragment,{children:[`The Telegram users who can use the bot, for commands and chat. Anyone finds their id by sending `,(0,X.jsx)(`code`,{children:`/whoami`}),`.`]}),action:(0,X.jsx)($,{state:H(e)}),children:[e===null&&!h&&(0,X.jsx)(_,{className:`py-4`,children:(0,X.jsx)(b,{children:`Loading…`})}),e&&!V(e)&&(0,X.jsx)(_,{className:`py-4 text-sm text-muted-foreground`,children:`Closed: the bot has no owner yet. Others can be added once the owner is paired above.`}),e&&e.length>0&&(0,X.jsx)(m,{children:e.map(e=>{let t=U(e);return(0,X.jsx)(f,{title:t,meta:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{children:e.role===`owner`?`Owner`:`Member`}),t!==String(e.userId)&&(0,X.jsx)(`code`,{children:e.userId})]}),actions:e.role!==`owner`&&(0,X.jsx)(s,{variant:`danger`,disabled:u,"aria-label":`Remove ${t}`,onClick:()=>S(e),children:`Remove`})},e.userId)})}),e&&V(e)&&(0,X.jsxs)(c,{onSubmit:D,children:[(0,X.jsxs)(`div`,{className:`grid items-start gap-x-3 gap-y-4 sm:grid-cols-[minmax(0,14rem)_minmax(0,18rem)]`,children:[(0,X.jsx)(O,{label:`Telegram user ID`,value:r,disabled:u,placeholder:`123456789`,mono:!0,inputMode:`numeric`,problem:E,onChange:i}),(0,X.jsx)(O,{label:`Label (optional)`,value:o,disabled:u,placeholder:`e.g. Pat`,onChange:l})]}),(0,X.jsx)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:(0,X.jsx)(s,{variant:`primary`,type:`submit`,disabled:u||T===``||E!==void 0,children:u?`Adding…`:`Add user`})})]}),h&&(0,X.jsx)(g,{children:(0,X.jsx)(d,{tone:`warning`,role:`alert`,title:`That did not work.`,children:h})}),(0,X.jsx)(N,{open:y!==null,onOpenChange:e=>{e||S(null)},title:`Remove ${y?U(y):``}?`,description:(0,X.jsxs)(`p`,{className:`m-0`,children:[`Telegram user `,(0,X.jsx)(`code`,{children:y?.userId}),` immediately loses command and chat access. Their Telegram account is not changed, and they can be allowed again later.`]}),confirmLabel:`Remove Telegram access`,onConfirm:async()=>{y&&(await n(`${C}/${y.userId}`,{method:`DELETE`}),await w())}})]})}function fe({stored:e,state:t,justSaved:r,onSaved:i,onDisconnected:o}){let[l,u]=(0,I.useState)({token:``,chatId:e.chatId}),[d,f]=(0,I.useState)(!1),[p,m]=(0,I.useState)(null),[h,g]=(0,I.useState)(!1),[v,y]=(0,I.useState)(!1),b=q(e,l),C=e=>{g(!0),m(null),u(t=>({...t,...e}))};async function w(e){if(e.preventDefault(),!(!b.body||d)){f(!0),m(null);try{await n(Q,{method:`PUT`,body:b.body}),await i()}catch(e){m(a(e))}finally{f(!1)}}}let D=b.incomplete?{text:`The token and the group’s id are saved together: fill in both.`,tone:`warning`}:k({error:p,dirty:b.dirty,saved:r&&!h,savedText:`Saved. A new token or group restarts the bot: run the preflight in a few seconds.`,footnote:e.configured?`A new token or group restarts the bot and starts pairing over: the owner and the allowed users are forgotten.`:`Saving starts the bot.`});return(0,X.jsxs)(x,{labelledBy:`telegram-bot`,icon:(0,X.jsx)(S,{className:`size-5`}),title:`Bot`,description:`The bot your Agents speak through, and the forum supergroup it works in.`,action:(0,X.jsx)($,{state:t}),children:[(0,X.jsxs)(c,{onSubmit:w,children:[(0,X.jsx)(T,{label:`Bot token`,saved:J(e),preview:e.botTokenPreview,value:l.token,open:b.tokenOpen,disabled:d,placeholder:`1234567890:ABC…`,hint:(0,X.jsxs)(X.Fragment,{children:[`From @BotFather → /newbot. Disable Privacy Mode in`,` `,(0,X.jsx)(`em`,{children:`Bot Settings → Group Privacy → Turn off`}),`.`]}),notes:b.problems.token?(0,X.jsx)(j,{children:b.problems.token}):b.needsToken&&(0,X.jsx)(j,{children:`Type the bot token again: a new group is saved together with it.`}),onChange:e=>C({token:e})}),(0,X.jsx)(O,{label:`Supergroup chat ID`,value:l.chatId,disabled:d,placeholder:`-1001234567890`,mono:!0,hint:(0,X.jsxs)(X.Fragment,{children:[`Forum-enabled supergroup the bot is admin in (with `,(0,X.jsx)(`code`,{children:`can_manage_topics`}),`).`]}),problem:b.problems.chatId,onChange:e=>C({chatId:e})}),(0,X.jsx)(E,{busy:d,disabled:!b.body,status:D})]}),e.configured&&(0,X.jsxs)(_,{className:`py-3`,children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1 basis-64 text-sm text-muted-foreground`,children:`Disconnecting removes the token and the group, and stops the bot.`}),(0,X.jsx)(s,{variant:`danger`,disabled:d,onClick:()=>y(!0),children:`Disconnect Telegram`})]}),(0,X.jsx)(N,{open:v,onOpenChange:y,title:`Disconnect Telegram?`,description:(0,X.jsx)(`p`,{className:`m-0`,children:`This permanently removes the saved bot token and supergroup ID. Telegram polling, ingress, and outbound delivery stop until new credentials are saved and pairing is completed again.`}),confirmLabel:`Disconnect Telegram`,onConfirm:async()=>{await n(Q,{method:`DELETE`}),await o()}})]})}function pe({toChatId:e,onReconnected:t}){let[r,i]=(0,I.useState)(!1),[o,c]=(0,I.useState)(null);async function l(){i(!0),c(null);try{await n(`${Q}/reconnect`,{method:`POST`}),await t()}catch(e){c(a(e))}finally{i(!1)}}return(0,X.jsxs)(`div`,{className:`grid gap-2`,children:[(0,X.jsxs)(v,{tone:`warning`,lead:(0,X.jsxs)(X.Fragment,{children:[`Telegram moved this group to a new chat id, `,(0,X.jsx)(`code`,{children:e}),`.`]}),action:(0,X.jsx)(s,{variant:`primary`,disabled:r,onClick:()=>void l(),children:r?`Reconnecting…`:`Reconnect`}),children:[`The bot still points at the old id. Reconnecting moves it over and creates the`,` `,(0,X.jsx)(`code`,{children:`⚙ bazilion`}),` service topic again in the new group; each Agent’s topic follows when it is next used.`]}),o&&(0,X.jsx)(v,{tone:`warning`,role:`alert`,lead:`The bot was not reconnected.`,children:o})]})}function me({onOwnerChange:e}){let[t,r]=(0,I.useState)(null),[i,o]=(0,I.useState)(null),[c,l]=(0,I.useState)(null),[u,f]=(0,I.useState)(!1),[p,m]=(0,I.useState)(!1),h=`${Q}/pairing`,_=async()=>r(await n(h));(0,I.useEffect)(()=>{_().catch(e=>l(a(e)))},[]);let v=t!==null&&!t.paired&&t.challengeActive;(0,I.useEffect)(()=>{if(!v)return;let t=window.setInterval(()=>{n(h).then(t=>{r(t),t.paired&&(o(null),e())}).catch(()=>{})},4e3);return()=>window.clearInterval(t)},[v]);async function y(e){f(!0),l(null);try{await e()}catch(e){l(a(e))}finally{f(!1)}}let S=()=>y(async()=>{let e=await n(`${h}/challenge`,{method:`POST`});o(e.code),r(e)}),C=()=>y(async()=>{await n(`${h}/challenge`,{method:`DELETE`}),o(null),await _()});return(0,X.jsxs)(x,{labelledBy:`telegram-pairing`,icon:(0,X.jsx)(P,{className:`size-5`}),title:`Owner pairing`,description:(0,X.jsxs)(X.Fragment,{children:[`Telegram stays closed until one owner sends a short-lived code in the`,` `,(0,X.jsx)(`code`,{children:`⚙ bazilion`}),` service topic.`]}),action:(0,X.jsx)($,{state:B(t)}),children:[(0,X.jsxs)(g,{children:[t===null&&!c&&(0,X.jsx)(b,{children:`Loading…`}),t?.paired&&(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[(0,X.jsxs)(`p`,{className:`m-0 min-w-0 flex-1 basis-64 text-sm text-foreground`,children:[`The owner is paired`,t.ownerUserId!==null&&(0,X.jsxs)(X.Fragment,{children:[`: Telegram user `,(0,X.jsx)(`span`,{className:`font-mono`,children:t.ownerUserId})]}),`.`]}),(0,X.jsx)(s,{variant:`danger`,disabled:u,onClick:()=>m(!0),children:`Reset owner`})]}),t&&!t.paired&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`m-0 text-sm text-warning`,children:`Unpaired: nothing sent to the bot is accepted.`}),i&&(0,X.jsxs)(d,{tone:`neutral`,title:`Send this in the service topic`,children:[(0,X.jsxs)(`code`,{className:`text-[0.95em]`,children:[`/pair `,i]}),(0,X.jsx)(`p`,{className:`m-0 mt-1 text-muted-foreground`,children:`The code is shown once and expires in ten minutes.`})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,X.jsx)(s,{variant:`primary`,disabled:u,onClick:()=>void S(),children:i||t.challengeActive?`Generate a new pairing code`:`Generate pairing code`}),t.challengeActive&&(0,X.jsx)(s,{variant:`ghost`,disabled:u,onClick:()=>void C(),children:`Cancel code`})]})]}),c&&(0,X.jsx)(d,{tone:`warning`,role:`alert`,title:`That did not work.`,children:c})]}),(0,X.jsx)(N,{open:p,onOpenChange:m,title:`Revoke the paired Telegram owner?`,description:(0,X.jsx)(`p`,{className:`m-0`,children:`This immediately revokes the current owner, removes everyone else from the allowed users and closes all Telegram ingress. No one can use the bot until a new one-time pairing code is generated and consumed.`}),confirmLabel:`Revoke owner and close ingress`,onConfirm:async()=>{await n(`${h}/reset`,{body:{confirm:!0}}),o(null),await _(),e()}})]})}function he({configured:e,health:t,working:n,note:r,error:i,now:a,onRun:o,onRestart:c}){return(0,X.jsxs)(x,{labelledBy:`telegram-preflight`,icon:(0,X.jsx)(C,{className:`size-5`}),title:`Preflight checks`,description:`Asks Telegram whether the bot and its group are set up the way Bazilion needs.`,action:(0,X.jsx)($,{state:ae(t)}),children:[(0,X.jsxs)(g,{children:[e?(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(s,{variant:`primary`,disabled:n!==null,onClick:o,children:n===`check`?`Checking…`:`Run preflight`}),(0,X.jsx)(s,{variant:`ghost`,disabled:n!==null,onClick:c,children:n===`restart`?`Restarting…`:`Restart bot`})]}):(0,X.jsx)(`p`,{className:`m-0 text-sm text-muted-foreground`,children:`Save the bot’s credentials above first.`}),n===`check`&&(0,X.jsx)(b,{children:`Asking Telegram…`}),r&&(0,X.jsx)(d,{tone:`neutral`,children:r}),i&&(0,X.jsx)(d,{tone:`warning`,role:`alert`,title:`That did not work.`,children:i}),t?.error&&(0,X.jsxs)(d,{tone:`warning`,role:`alert`,title:(0,X.jsxs)(X.Fragment,{children:[`Failed at `,(0,X.jsx)(`code`,{children:t.error.step})]}),children:[(0,X.jsx)(`p`,{className:`m-0`,children:t.error.message}),(0,X.jsx)(`p`,{className:`m-0 mt-1 text-muted-foreground`,children:ie(t.error.step)})]}),t?.preflight&&(0,X.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`grid gap-3`,children:[(0,X.jsx)(y,{children:z(t.preflight).map(e=>(0,X.jsx)(p,{ok:e.ok,label:e.label,children:e.detail},e.label))}),(0,X.jsxs)(`p`,{className:`m-0 text-sm text-muted-foreground`,children:[`Group members: `,t.preflight.memberCount??`unknown`,`. Everyone in the group can read the Agents’ replies.`]})]}),t&&!t.error&&!t.preflight&&(0,X.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted-foreground`,children:`No preflight data.`})]}),t?.polling&&(0,X.jsx)(ge,{polling:t.polling,now:a})]})}function ge({polling:e,now:t}){let n=e=>(0,X.jsx)(`time`,{dateTime:new Date(e).toISOString(),children:D(e,t)});return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(_,{className:`bg-muted/50 py-2 text-xs font-bold uppercase tracking-[0.08em] text-muted-foreground`,children:`The running bot`}),(0,X.jsxs)(h,{className:`border-t-0`,children:[(0,X.jsx)(u,{label:`Polling`,tone:e.running?`success`:`warning`,children:e.running?`Running`:`Stopped`}),(0,X.jsx)(u,{label:`Group setup`,tone:e.activated?`success`:`warning`,children:e.activated?`Activated`:`Awaiting activation`}),e.startedAt!==null&&(0,X.jsx)(u,{label:`Started`,children:n(e.startedAt)}),e.lastSuccessfulPollAt!==null&&(0,X.jsx)(u,{label:`Last poll`,children:n(e.lastSuccessfulPollAt)}),e.lastUpdateId!==null&&(0,X.jsx)(u,{label:`Last update`,children:(0,X.jsx)(`span`,{className:`font-mono text-[0.9em]`,children:e.lastUpdateId})}),e.error&&(0,X.jsx)(u,{label:`Error`,tone:`warning`,children:e.error})]})]})}function _e(){let e=M.useLoaderData(),t=r(),i=te(e=>n(`/api/notifications`,{signal:e}),[]),[o,s]=(0,I.useState)(null),[c,l]=(0,I.useState)(null),[u,d]=(0,I.useState)(!1),[f,p]=(0,I.useState)(null),[m,h]=(0,I.useState)(null),[g,_]=(0,I.useState)(0),[v,y]=(0,I.useState)(!1),[b,x]=(0,I.useState)(0);async function S(){l(`check`),s(null),p(null),h(null);try{s({health:await n(`${Q}/health`),at:Date.now()}),d(!1),i.reload()}catch(e){h(a(e))}finally{l(null)}}async function C(){l(`restart`),s(null),p(null),h(null);try{await n(`${Q}/restart`,{method:`POST`}),d(!0),p(`Restarting. Run the preflight in a few seconds to see how the bot is doing.`)}catch(e){h(a(e))}finally{l(null)}}async function w(e){await t.invalidate({sync:!0}),s(null),p(null),h(null),d(e.restarting),y(e.saved),_(e=>e+1),i.reload()}return(0,X.jsxs)(ne,{title:`Telegram`,description:`Connect one forum-supergroup bot with one topic per Agent, so conversations stay reachable from your phone.`,children:[e.migratedChatId&&(0,X.jsx)(pe,{toChatId:e.migratedChatId,onReconnected:()=>w({saved:!1,restarting:!0})}),(0,X.jsx)(fe,{stored:e,state:re({configured:e.configured,restarting:u,health:o?.health??null,ready:i.data?.telegramReady}),justSaved:v,onSaved:()=>w({saved:!0,restarting:!1}),onDisconnected:()=>w({saved:!1,restarting:!1})},`bot:${g}`),(0,X.jsx)(he,{configured:e.configured,health:o?.health??null,now:o?.at??0,working:c,note:f,error:m,onRun:()=>void S(),onRestart:()=>void C()}),e.configured&&(0,X.jsx)(me,{onOwnerChange:()=>x(e=>e+1)},`pairing:${g}`),(0,X.jsx)(le,{settings:i.data,error:i.error,onSaved:i.reload}),e.configured&&(0,X.jsx)(de,{},`allowed:${g}:${b}`)]})}export{_e as component};
|
|
1
|
+
import{$ as e,Z as t,a as n,d as r,h as i,s as a,t as o}from"./createLucideIcon-CZHSSDYA.js";import{t as s}from"./Button-CoKQRO-s.js";import{a as c,d as l,f as u,g as d,h as f,l as p,o as m,p as h,r as g,s as _,t as v,u as y,x as b,y as x}from"./parts-C104qEuC.js";import{t as S}from"./bot-BHky7KAX.js";import{t as C}from"./list-checks-DdTdAQXS.js";import{A as w,D as T,E,I as D,M as O,Mt as ee,N as k,S as A,T as j,c as M}from"./index-DuLpyCSP.js";import{r as te}from"./use-resource-qjIkNQDY.js";import{t as N}from"./ConfirmDialog-DrN26lN_.js";import{t as ne}from"./ConfigPage-DFmHgEaL.js";var P=o(`shield-check`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),F=o(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),I=e(t(),1),L={label:`Running`,tone:`success`},R={label:`Not running`,tone:`warning`};function re({configured:e,restarting:t,health:n,ready:r}){if(!e)return{label:`Not connected`,tone:`neutral`};if(t)return{label:`Restarting…`,tone:`neutral`};if(n){let e=n.polling;return e?.running?n.error||e.error?{label:`Failing`,tone:`warning`}:e.activated?L:{label:`Setting up the group`,tone:`warning`}:R}return r===void 0?null:r?L:R}function z(e){let t=[{ok:e.botUsername.length>0,label:`Bot identity`,detail:`@${e.botUsername}`},{ok:e.chatTitle.length>0,label:`Supergroup reachable`,detail:e.chatTitle},{ok:e.isForum,label:`Forum topics enabled`,detail:e.isForum?`is_forum: true`:`is_forum: false — the supergroup owner must enable Topics in group settings`},{ok:e.hasManageTopics,label:`Bot has can_manage_topics`,detail:e.hasManageTopics?`admin with can_manage_topics`:`promote the bot to admin in the supergroup with the "Manage topics" permission`},{ok:e.privacyModeOff,label:`Privacy Mode is OFF`,detail:e.privacyModeOff?`can_read_all_group_messages: true`:`BotFather → /mybots → select bot → Bot Settings → Group Privacy → Turn off`},{ok:e.chatIsPrivate,label:`Supergroup is private`,detail:e.chatIsPrivate?`no public @username`:`public groups expose topic content to readers`}];return e.ownerPresent!==null&&t.push({ok:e.ownerPresent,label:`Paired owner is present`,detail:e.ownerPresent?`owner membership confirmed`:`owner missing — Telegram ingress is degraded`}),t}function ie(e){switch(e){case`getMe`:return`The token is invalid or revoked. Re-issue it with @BotFather → /token, or paste a fresh one above.`;case`getChat`:return`The chat id either does not exist, points at a basic group (not a supergroup), or the bot is not a member. Forward any message from the supergroup to the bot to double-check the id, then add the bot to the group.`;case`getChatMember`:return`The bot is in the chat but the membership lookup failed. This usually means the bot was removed or the chat id was migrated: confirm the bot is still in the supergroup.`}}function ae(e){if(!e)return null;if(e.error)return{label:`Failed`,tone:`warning`};if(!e.preflight)return null;let t=z(e.preflight).filter(e=>!e.ok).length;return t===0?{label:`All passed`,tone:`success`}:{label:t===1?`1 to put right`:`${t} to put right`,tone:`warning`}}function B(e){return e?e.paired?{label:`Paired`,tone:`success`}:{label:e.challengeActive?`Waiting for the code`:`Not paired`,tone:`warning`}:null}function V(e){return e.some(e=>e.role===`owner`)}function H(e){return e?V(e)?{label:e.length===1?`1 person`:`${e.length} people`,tone:`neutral`}:{label:`Closed`,tone:`warning`}:null}function U(e){return e.label??(e.username?`@${e.username}`:String(e.userId))}function W(e){return e?e.enabled?e.telegramReady?{label:`On`,tone:`success`}:{label:`Waiting for the bot`,tone:`warning`}:{label:`Off`,tone:`neutral`}:null}var G=/^\d+:[A-Za-z0-9_-]+$/,K=/^-?\d+$/;function q(e,t){let n=t.token.trim(),r=t.chatId.trim(),i=r!==e.chatId,a={};n&&!G.test(n)&&(a.token=`A token from @BotFather looks like 1234567890:ABC…`),r&&!K.test(r)?a.chatId=`A supergroup’s id is a number, like -1001234567890.`:!r&&e.configured&&(a.chatId=`The bot needs a group. To remove Telegram, disconnect it below.`);let o=!a.token&&!a.chatId,s=n!==``||i,c=J(e)&&i,l=c&&r!==``&&n===``&&o,u=n!==``&&r!==``;return{dirty:s,problems:a,needsToken:l,tokenOpen:c,incomplete:s&&o&&!u&&!l,body:o&&u?{botToken:n,chatId:r}:null}}function J(e){return e.botTokenPreview!==``}function oe(e,t){return{enabled:e.enabled,kinds:e.kinds,quiet:e.quietHours!==null,start:e.quietHours?.start??`22:00`,end:e.quietHours?.end??`07:00`,timezone:e.enabled||e.quietHours?e.timezone:t}}function Y(e){return{enabled:e.enabled,kinds:e.kinds,timezone:e.timezone.trim(),quietHours:e.quiet?{start:e.start,end:e.end}:null}}function se(e,t){let n=e=>{let{kinds:t,...n}=Y(e);return JSON.stringify({...n,kinds:[...t].sort()})};return n(e)===n(t)}var X=i(),Z={lesson_proposal:`Lesson proposals`,review_failure:`Review failures`,trigger_failure:`Scheduled trigger failures`,agent_loop_break:`Agent message loop breaks`,queue_interrupted:`Queues paused after restart`,turn_failure:`Failed background turns`};function ce(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`}catch{return`UTC`}}function le({settings:e,error:t,onSaved:n}){let[r,i]=(0,I.useState)(0),a=W(e);return(0,X.jsx)(x,{labelledBy:`telegram-notifications`,icon:(0,X.jsx)(ee,{className:`size-5`}),title:`Attention notifications`,description:`Posts each new Attention item of the kinds you choose to the bot’s service topic, once. Items that were already open when you switch this on are not sent.`,action:a&&(0,X.jsx)(l,{tone:a.tone,children:a.label}),children:e?(0,X.jsx)(ue,{settings:e,justSaved:r>0,onSaved:async()=>{await n(),i(e=>e+1)}},r):(0,X.jsx)(g,{children:t?(0,X.jsx)(d,{tone:`warning`,role:`alert`,title:`The settings could not be loaded.`,children:t}):(0,X.jsx)(b,{children:`Loading…`})})})}function ue({settings:e,justSaved:t,onSaved:r}){let[i]=(0,I.useState)(()=>oe(e,ce())),[o,s]=(0,I.useState)(i),[l,u]=(0,I.useState)(!1),[f,p]=(0,I.useState)(null),[m,h]=(0,I.useState)(!1),g=!se(i,o),_=o.kinds.length===0,v=o.quiet&&o.timezone.trim()===``,y=e=>{h(!0),p(null),s(t=>({...t,...e}))};async function b(e){if(e.preventDefault(),!(!g||_||v||l)){u(!0),p(null);try{await n(`/api/notifications`,{method:`PUT`,body:Y(o)}),await r()}catch(e){p(a(e))}finally{u(!1)}}}return(0,X.jsxs)(c,{onSubmit:b,children:[!e.telegramReady&&(0,X.jsx)(d,{tone:`neutral`,children:`The bot is not running yet; notices go out once it is connected and activated.`}),(0,X.jsx)(w,{label:`Send Attention notifications to Telegram`,checked:o.enabled,disabled:l,onChange:e=>y({enabled:e})}),(0,X.jsxs)(`fieldset`,{className:`m-0 min-w-0 border-0 p-0`,disabled:l,children:[(0,X.jsx)(`legend`,{className:`mb-2 p-0 text-sm font-semibold text-foreground`,children:`Kinds`}),(0,X.jsx)(`div`,{className:`grid gap-x-6 gap-y-2.5 sm:grid-cols-2`,children:Object.keys(Z).map(e=>(0,X.jsx)(A,{label:Z[e],checked:o.kinds.includes(e),onChange:t=>y({kinds:t?[...o.kinds,e]:o.kinds.filter(t=>t!==e)})},e))}),_&&(0,X.jsx)(j,{children:`Choose at least one kind.`})]}),(0,X.jsx)(w,{label:`Quiet hours`,description:`Notices wait until they end.`,checked:o.quiet,disabled:l,onChange:e=>y({quiet:e})}),o.quiet&&(0,X.jsxs)(`div`,{className:`grid items-start gap-x-3 gap-y-4 sm:grid-cols-[8.5rem_8.5rem_minmax(0,18rem)]`,children:[(0,X.jsx)(O,{label:`From`,type:`time`,value:o.start,disabled:l,required:!0,onChange:e=>y({start:e})}),(0,X.jsx)(O,{label:`To`,type:`time`,value:o.end,disabled:l,required:!0,onChange:e=>y({end:e})}),(0,X.jsx)(O,{label:`Timezone`,value:o.timezone,disabled:l,required:!0,placeholder:`Europe/Warsaw`,problem:v?`Quiet hours need a timezone.`:void 0,onChange:e=>y({timezone:e})})]}),(0,X.jsx)(E,{busy:l,disabled:!g||_||v,status:k({error:f,dirty:g,saved:t&&!m})})]})}var Q=`/api/config/telegram`;function $({state:e}){return e&&(0,X.jsx)(l,{tone:e.tone,children:e.label})}function de(){let[e,t]=(0,I.useState)(null),[r,i]=(0,I.useState)(``),[o,l]=(0,I.useState)(``),[u,p]=(0,I.useState)(!1),[h,v]=(0,I.useState)(null),[y,S]=(0,I.useState)(null),C=`${Q}/acl`,w=async()=>t(await n(C));(0,I.useEffect)(()=>{w().catch(e=>v(a(e)))},[]);let T=r.trim(),E=T!==``&&!/^\d+$/.test(T)?`A Telegram user id is a number, like 123456789.`:void 0;async function D(e){if(e.preventDefault(),!(T===``||E||u)){p(!0),v(null);try{await n(C,{body:{userId:Number(T),label:o.trim()||null}}),i(``),l(``),await w()}catch(e){v(a(e))}finally{p(!1)}}}return(0,X.jsxs)(x,{labelledBy:`telegram-allowed`,icon:(0,X.jsx)(F,{className:`size-5`}),title:`Allowed users`,description:(0,X.jsxs)(X.Fragment,{children:[`The Telegram users who can use the bot, for commands and chat. Anyone finds their id by sending `,(0,X.jsx)(`code`,{children:`/whoami`}),`.`]}),action:(0,X.jsx)($,{state:H(e)}),children:[e===null&&!h&&(0,X.jsx)(_,{className:`py-4`,children:(0,X.jsx)(b,{children:`Loading…`})}),e&&!V(e)&&(0,X.jsx)(_,{className:`py-4 text-sm text-muted-foreground`,children:`Closed: the bot has no owner yet. Others can be added once the owner is paired above.`}),e&&e.length>0&&(0,X.jsx)(m,{children:e.map(e=>{let t=U(e);return(0,X.jsx)(f,{title:t,meta:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{children:e.role===`owner`?`Owner`:`Member`}),t!==String(e.userId)&&(0,X.jsx)(`code`,{children:e.userId})]}),actions:e.role!==`owner`&&(0,X.jsx)(s,{variant:`danger`,disabled:u,"aria-label":`Remove ${t}`,onClick:()=>S(e),children:`Remove`})},e.userId)})}),e&&V(e)&&(0,X.jsxs)(c,{onSubmit:D,children:[(0,X.jsxs)(`div`,{className:`grid items-start gap-x-3 gap-y-4 sm:grid-cols-[minmax(0,14rem)_minmax(0,18rem)]`,children:[(0,X.jsx)(O,{label:`Telegram user ID`,value:r,disabled:u,placeholder:`123456789`,mono:!0,inputMode:`numeric`,problem:E,onChange:i}),(0,X.jsx)(O,{label:`Label (optional)`,value:o,disabled:u,placeholder:`e.g. Pat`,onChange:l})]}),(0,X.jsx)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:(0,X.jsx)(s,{variant:`primary`,type:`submit`,disabled:u||T===``||E!==void 0,children:u?`Adding…`:`Add user`})})]}),h&&(0,X.jsx)(g,{children:(0,X.jsx)(d,{tone:`warning`,role:`alert`,title:`That did not work.`,children:h})}),(0,X.jsx)(N,{open:y!==null,onOpenChange:e=>{e||S(null)},title:`Remove ${y?U(y):``}?`,description:(0,X.jsxs)(`p`,{className:`m-0`,children:[`Telegram user `,(0,X.jsx)(`code`,{children:y?.userId}),` immediately loses command and chat access. Their Telegram account is not changed, and they can be allowed again later.`]}),confirmLabel:`Remove Telegram access`,onConfirm:async()=>{y&&(await n(`${C}/${y.userId}`,{method:`DELETE`}),await w())}})]})}function fe({stored:e,state:t,justSaved:r,onSaved:i,onDisconnected:o}){let[l,u]=(0,I.useState)({token:``,chatId:e.chatId}),[d,f]=(0,I.useState)(!1),[p,m]=(0,I.useState)(null),[h,g]=(0,I.useState)(!1),[v,y]=(0,I.useState)(!1),b=q(e,l),C=e=>{g(!0),m(null),u(t=>({...t,...e}))};async function w(e){if(e.preventDefault(),!(!b.body||d)){f(!0),m(null);try{await n(Q,{method:`PUT`,body:b.body}),await i()}catch(e){m(a(e))}finally{f(!1)}}}let D=b.incomplete?{text:`The token and the group’s id are saved together: fill in both.`,tone:`warning`}:k({error:p,dirty:b.dirty,saved:r&&!h,savedText:`Saved. A new token or group restarts the bot: run the preflight in a few seconds.`,footnote:e.configured?`A new token or group restarts the bot and starts pairing over: the owner and the allowed users are forgotten.`:`Saving starts the bot.`});return(0,X.jsxs)(x,{labelledBy:`telegram-bot`,icon:(0,X.jsx)(S,{className:`size-5`}),title:`Bot`,description:`The bot your Agents speak through, and the forum supergroup it works in.`,action:(0,X.jsx)($,{state:t}),children:[(0,X.jsxs)(c,{onSubmit:w,children:[(0,X.jsx)(T,{label:`Bot token`,saved:J(e),preview:e.botTokenPreview,value:l.token,open:b.tokenOpen,disabled:d,placeholder:`1234567890:ABC…`,hint:(0,X.jsxs)(X.Fragment,{children:[`From @BotFather → /newbot. Disable Privacy Mode in`,` `,(0,X.jsx)(`em`,{children:`Bot Settings → Group Privacy → Turn off`}),`.`]}),notes:b.problems.token?(0,X.jsx)(j,{children:b.problems.token}):b.needsToken&&(0,X.jsx)(j,{children:`Type the bot token again: a new group is saved together with it.`}),onChange:e=>C({token:e})}),(0,X.jsx)(O,{label:`Supergroup chat ID`,value:l.chatId,disabled:d,placeholder:`-1001234567890`,mono:!0,hint:(0,X.jsxs)(X.Fragment,{children:[`Forum-enabled supergroup the bot is admin in (with `,(0,X.jsx)(`code`,{children:`can_manage_topics`}),`).`]}),problem:b.problems.chatId,onChange:e=>C({chatId:e})}),(0,X.jsx)(E,{busy:d,disabled:!b.body,status:D})]}),e.configured&&(0,X.jsxs)(_,{className:`py-3`,children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1 basis-64 text-sm text-muted-foreground`,children:`Disconnecting removes the token and the group, and stops the bot.`}),(0,X.jsx)(s,{variant:`danger`,disabled:d,onClick:()=>y(!0),children:`Disconnect Telegram`})]}),(0,X.jsx)(N,{open:v,onOpenChange:y,title:`Disconnect Telegram?`,description:(0,X.jsx)(`p`,{className:`m-0`,children:`This permanently removes the saved bot token and supergroup ID. Telegram polling, ingress, and outbound delivery stop until new credentials are saved and pairing is completed again.`}),confirmLabel:`Disconnect Telegram`,onConfirm:async()=>{await n(Q,{method:`DELETE`}),await o()}})]})}function pe({toChatId:e,onReconnected:t}){let[r,i]=(0,I.useState)(!1),[o,c]=(0,I.useState)(null);async function l(){i(!0),c(null);try{await n(`${Q}/reconnect`,{method:`POST`}),await t()}catch(e){c(a(e))}finally{i(!1)}}return(0,X.jsxs)(`div`,{className:`grid gap-2`,children:[(0,X.jsxs)(v,{tone:`warning`,lead:(0,X.jsxs)(X.Fragment,{children:[`Telegram moved this group to a new chat id, `,(0,X.jsx)(`code`,{children:e}),`.`]}),action:(0,X.jsx)(s,{variant:`primary`,disabled:r,onClick:()=>void l(),children:r?`Reconnecting…`:`Reconnect`}),children:[`The bot still points at the old id. Reconnecting moves it over and creates the`,` `,(0,X.jsx)(`code`,{children:`⚙ bazilion`}),` service topic again in the new group; each Agent’s topic follows when it is next used.`]}),o&&(0,X.jsx)(v,{tone:`warning`,role:`alert`,lead:`The bot was not reconnected.`,children:o})]})}function me({onOwnerChange:e}){let[t,r]=(0,I.useState)(null),[i,o]=(0,I.useState)(null),[c,l]=(0,I.useState)(null),[u,f]=(0,I.useState)(!1),[p,m]=(0,I.useState)(!1),h=`${Q}/pairing`,_=async()=>r(await n(h));(0,I.useEffect)(()=>{_().catch(e=>l(a(e)))},[]);let v=t!==null&&!t.paired&&t.challengeActive;(0,I.useEffect)(()=>{if(!v)return;let t=window.setInterval(()=>{n(h).then(t=>{r(t),t.paired&&(o(null),e())}).catch(()=>{})},4e3);return()=>window.clearInterval(t)},[v]);async function y(e){f(!0),l(null);try{await e()}catch(e){l(a(e))}finally{f(!1)}}let S=()=>y(async()=>{let e=await n(`${h}/challenge`,{method:`POST`});o(e.code),r(e)}),C=()=>y(async()=>{await n(`${h}/challenge`,{method:`DELETE`}),o(null),await _()});return(0,X.jsxs)(x,{labelledBy:`telegram-pairing`,icon:(0,X.jsx)(P,{className:`size-5`}),title:`Owner pairing`,description:(0,X.jsxs)(X.Fragment,{children:[`Telegram stays closed until one owner sends a short-lived code in the`,` `,(0,X.jsx)(`code`,{children:`⚙ bazilion`}),` service topic.`]}),action:(0,X.jsx)($,{state:B(t)}),children:[(0,X.jsxs)(g,{children:[t===null&&!c&&(0,X.jsx)(b,{children:`Loading…`}),t?.paired&&(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[(0,X.jsxs)(`p`,{className:`m-0 min-w-0 flex-1 basis-64 text-sm text-foreground`,children:[`The owner is paired`,t.ownerUserId!==null&&(0,X.jsxs)(X.Fragment,{children:[`: Telegram user `,(0,X.jsx)(`span`,{className:`font-mono`,children:t.ownerUserId})]}),`.`]}),(0,X.jsx)(s,{variant:`danger`,disabled:u,onClick:()=>m(!0),children:`Reset owner`})]}),t&&!t.paired&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`m-0 text-sm text-warning`,children:`Unpaired: nothing sent to the bot is accepted.`}),i&&(0,X.jsxs)(d,{tone:`neutral`,title:`Send this in the service topic`,children:[(0,X.jsxs)(`code`,{className:`text-[0.95em]`,children:[`/pair `,i]}),(0,X.jsx)(`p`,{className:`m-0 mt-1 text-muted-foreground`,children:`The code is shown once and expires in ten minutes.`})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,X.jsx)(s,{variant:`primary`,disabled:u,onClick:()=>void S(),children:i||t.challengeActive?`Generate a new pairing code`:`Generate pairing code`}),t.challengeActive&&(0,X.jsx)(s,{variant:`ghost`,disabled:u,onClick:()=>void C(),children:`Cancel code`})]})]}),c&&(0,X.jsx)(d,{tone:`warning`,role:`alert`,title:`That did not work.`,children:c})]}),(0,X.jsx)(N,{open:p,onOpenChange:m,title:`Revoke the paired Telegram owner?`,description:(0,X.jsx)(`p`,{className:`m-0`,children:`This immediately revokes the current owner, removes everyone else from the allowed users and closes all Telegram ingress. No one can use the bot until a new one-time pairing code is generated and consumed.`}),confirmLabel:`Revoke owner and close ingress`,onConfirm:async()=>{await n(`${h}/reset`,{body:{confirm:!0}}),o(null),await _(),e()}})]})}function he({configured:e,health:t,working:n,note:r,error:i,now:a,onRun:o,onRestart:c}){return(0,X.jsxs)(x,{labelledBy:`telegram-preflight`,icon:(0,X.jsx)(C,{className:`size-5`}),title:`Preflight checks`,description:`Asks Telegram whether the bot and its group are set up the way Bazilion needs.`,action:(0,X.jsx)($,{state:ae(t)}),children:[(0,X.jsxs)(g,{children:[e?(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(s,{variant:`primary`,disabled:n!==null,onClick:o,children:n===`check`?`Checking…`:`Run preflight`}),(0,X.jsx)(s,{variant:`ghost`,disabled:n!==null,onClick:c,children:n===`restart`?`Restarting…`:`Restart bot`})]}):(0,X.jsx)(`p`,{className:`m-0 text-sm text-muted-foreground`,children:`Save the bot’s credentials above first.`}),n===`check`&&(0,X.jsx)(b,{children:`Asking Telegram…`}),r&&(0,X.jsx)(d,{tone:`neutral`,children:r}),i&&(0,X.jsx)(d,{tone:`warning`,role:`alert`,title:`That did not work.`,children:i}),t?.error&&(0,X.jsxs)(d,{tone:`warning`,role:`alert`,title:(0,X.jsxs)(X.Fragment,{children:[`Failed at `,(0,X.jsx)(`code`,{children:t.error.step})]}),children:[(0,X.jsx)(`p`,{className:`m-0`,children:t.error.message}),(0,X.jsx)(`p`,{className:`m-0 mt-1 text-muted-foreground`,children:ie(t.error.step)})]}),t?.preflight&&(0,X.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`grid gap-3`,children:[(0,X.jsx)(y,{children:z(t.preflight).map(e=>(0,X.jsx)(p,{ok:e.ok,label:e.label,children:e.detail},e.label))}),(0,X.jsxs)(`p`,{className:`m-0 text-sm text-muted-foreground`,children:[`Group members: `,t.preflight.memberCount??`unknown`,`. Everyone in the group can read the Agents’ replies.`]})]}),t&&!t.error&&!t.preflight&&(0,X.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted-foreground`,children:`No preflight data.`})]}),t?.polling&&(0,X.jsx)(ge,{polling:t.polling,now:a})]})}function ge({polling:e,now:t}){let n=e=>(0,X.jsx)(`time`,{dateTime:new Date(e).toISOString(),children:D(e,t)});return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(_,{className:`bg-muted/50 py-2 text-xs font-bold uppercase tracking-[0.08em] text-muted-foreground`,children:`The running bot`}),(0,X.jsxs)(h,{className:`border-t-0`,children:[(0,X.jsx)(u,{label:`Polling`,tone:e.running?`success`:`warning`,children:e.running?`Running`:`Stopped`}),(0,X.jsx)(u,{label:`Group setup`,tone:e.activated?`success`:`warning`,children:e.activated?`Activated`:`Awaiting activation`}),e.startedAt!==null&&(0,X.jsx)(u,{label:`Started`,children:n(e.startedAt)}),e.lastSuccessfulPollAt!==null&&(0,X.jsx)(u,{label:`Last poll`,children:n(e.lastSuccessfulPollAt)}),e.lastUpdateId!==null&&(0,X.jsx)(u,{label:`Last update`,children:(0,X.jsx)(`span`,{className:`font-mono text-[0.9em]`,children:e.lastUpdateId})}),e.error&&(0,X.jsx)(u,{label:`Error`,tone:`warning`,children:e.error})]})]})}function _e(){let e=M.useLoaderData(),t=r(),i=te(e=>n(`/api/notifications`,{signal:e}),[]),[o,s]=(0,I.useState)(null),[c,l]=(0,I.useState)(null),[u,d]=(0,I.useState)(!1),[f,p]=(0,I.useState)(null),[m,h]=(0,I.useState)(null),[g,_]=(0,I.useState)(0),[v,y]=(0,I.useState)(!1),[b,x]=(0,I.useState)(0);async function S(){l(`check`),s(null),p(null),h(null);try{s({health:await n(`${Q}/health`),at:Date.now()}),d(!1),i.reload()}catch(e){h(a(e))}finally{l(null)}}async function C(){l(`restart`),s(null),p(null),h(null);try{await n(`${Q}/restart`,{method:`POST`}),d(!0),p(`Restarting. Run the preflight in a few seconds to see how the bot is doing.`)}catch(e){h(a(e))}finally{l(null)}}async function w(e){await t.invalidate({sync:!0}),s(null),p(null),h(null),d(e.restarting),y(e.saved),_(e=>e+1),i.reload()}return(0,X.jsxs)(ne,{title:`Telegram`,description:`Connect one forum-supergroup bot with one topic per Agent, so conversations stay reachable from your phone.`,children:[e.migratedChatId&&(0,X.jsx)(pe,{toChatId:e.migratedChatId,onReconnected:()=>w({saved:!1,restarting:!0})}),(0,X.jsx)(fe,{stored:e,state:re({configured:e.configured,restarting:u,health:o?.health??null,ready:i.data?.telegramReady}),justSaved:v,onSaved:()=>w({saved:!0,restarting:!1}),onDisconnected:()=>w({saved:!1,restarting:!1})},`bot:${g}`),(0,X.jsx)(he,{configured:e.configured,health:o?.health??null,now:o?.at??0,working:c,note:f,error:m,onRun:()=>void S(),onRestart:()=>void C()}),e.configured&&(0,X.jsx)(me,{onOwnerChange:()=>x(e=>e+1)},`pairing:${g}`),(0,X.jsx)(le,{settings:i.data,error:i.error,onSaved:i.reload}),e.configured&&(0,X.jsx)(de,{},`allowed:${g}:${b}`)]})}export{_e as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as e,Z as t,a as n,d as r,h as i,i as a,s as o,t as s}from"./createLucideIcon-CZHSSDYA.js";import{S as c}from"./es2015-DZDOQ3kj.js";import{B as l,a as u,d,g as f,y as p}from"./parts-C104qEuC.js";import{t as m}from"./chevron-right-D1shxvdo.js";import{t as h}from"./file-text-D6OTHixJ.js";import{n as g,t as _}from"./wrench-BLEJjETg.js";import{t as v}from"./square-terminal-CYfGBHPC.js";import{A as y,C as b,D as x,E as S,M as C,N as w,T,l as E}from"./index-
|
|
1
|
+
import{$ as e,Z as t,a as n,d as r,h as i,i as a,s as o,t as s}from"./createLucideIcon-CZHSSDYA.js";import{S as c}from"./es2015-DZDOQ3kj.js";import{B as l,a as u,d,g as f,y as p}from"./parts-C104qEuC.js";import{t as m}from"./chevron-right-D1shxvdo.js";import{t as h}from"./file-text-D6OTHixJ.js";import{n as g,t as _}from"./wrench-BLEJjETg.js";import{t as v}from"./square-terminal-CYfGBHPC.js";import{A as y,C as b,D as x,E as S,M as C,N as w,T,l as E}from"./index-DuLpyCSP.js";import{t as D}from"./ConfigPage-DFmHgEaL.js";var O=s(`app-window`,[[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}],[`path`,{d:`M10 4v4`,key:`pp8u80`}],[`path`,{d:`M2 8h20`,key:`d11cs7`}],[`path`,{d:`M6 4v4`,key:`1svtjw`}]]),k=e(t(),1);function A(e,t){let n=e.input;if(n.type!==`number`)return t;let r=n.scale??1,i=Number(t)/r;return String(Number.isInteger(i)?i:Math.round(i*100)/100)}function j(e,t){let n=e.input;return n.type===`number`?/^\d+$/.test(t.trim())?String(Number(t.trim())*(n.scale??1)):null:t}function M(e){if(e.kind===`secret`)return``;switch(e.input.type){case`number`:return A(e,e.effective??String(e.input.default));case`text`:return e.environment?e.effective??``:e.value??``;default:return e.effective??``}}function N(e){return{values:Object.fromEntries(e.fields.map(e=>[e.envVar,M(e)])),removed:[]}}function P(e,t){return(e.when??[]).every(e=>e.is.includes(t.values[e.envVar]??``))}function F(e,t){let n={};for(let r of e.fields){let e=r.input;if(e.type!==`number`||r.environment||!P(r,t))continue;let i=t.values[r.envVar]??``;if(i===M(r)&&!r.unusable)continue;let a=e.scale??1,o=j(r,i),s=`from ${e.min/a} to ${e.max/a}`;o===null?n[r.envVar]=`A whole number ${s}.`:(Number(o)<e.min||Number(o)>e.max)&&(n[r.envVar]=`It has to be ${s}.`)}return n}function I(e,t){let n={};for(let r of e.fields){if(r.environment&&r.kind!==`secret`)continue;let e=t.values[r.envVar]??``;if(r.kind===`secret`){e.trim()?n[r.envVar]=e.trim():t.removed.includes(r.envVar)&&r.set&&(n[r.envVar]=``);continue}e===M(r)&&!r.unusable||!P(r,t)||(n[r.envVar]=r.input.type===`number`?j(r,e)??e:e.trim())}return n}var L=i(),R={"web-search":l,"web-pages":h,browser:O,commands:v,"agent-messages":g};function z(e,t){return t?.startsWith(`${e} `)?`It ${t.slice(e.length+1)}.`:t}var B={on:`success`,warning:`warning`,off:`neutral`};function V({card:e,justSaved:t,onSaved:r}){let[i,s]=(0,k.useState)(()=>N(e)),[l,h]=(0,k.useState)(!1),[g,v]=(0,k.useState)(!1),[y,b]=(0,k.useState)({}),[x,C]=(0,k.useState)(null),[T,E]=(0,k.useState)(!1),D=R[e.id]??_,O=`tool-${e.id}`,A=F(e,i),j=I(e,i),M=Object.keys(j).length>0,V=e.fields.filter(e=>P(e,i)),U=V.filter(e=>!e.advanced),W=V.filter(e=>e.advanced),G=W.some(e=>y[e.envVar]||A[e.envVar]||e.unusable),K=()=>{E(!0),b({}),C(null)},q=(e,t)=>{K(),s(n=>({values:{...n.values,[e]:t},removed:n.removed.filter(t=>t!==e)}))},J=(e,t)=>{K(),s(n=>({values:{...n.values,[e]:``},removed:t?[...n.removed,e]:n.removed.filter(t=>t!==e)}))};async function Y(e){if(e.preventDefault(),!(!M||g||Object.keys(A).length>0)){v(!0),C(null),b({});try{await n(`/api/config/fields`,{method:`PUT`,body:{values:j}}),await r()}catch(e){let t=e instanceof a&&e.body&&typeof e.body==`object`&&`errors`in e.body?e.body.errors:null;t?b(t):C(o(e))}finally{v(!1)}}}let X=e=>(0,L.jsx)(H,{field:e,value:i.values[e.envVar]??``,removed:i.removed.includes(e.envVar),problem:z(e.envVar,y[e.envVar])??A[e.envVar],disabled:g,onChange:t=>q(e.envVar,t),onRemove:t=>J(e.envVar,t)},e.envVar),Z=w({refused:Object.keys(y).length>0,error:x,dirty:M,saved:t&&!T,savedText:`Saved. It applies from the next turn.`,footnote:e.footnote});return(0,L.jsx)(p,{icon:(0,L.jsx)(D,{className:`size-5`}),title:e.displayName,description:e.hint??``,labelledBy:O,action:e.state&&(0,L.jsx)(d,{tone:B[e.state.tone],children:e.state.label}),children:(0,L.jsxs)(u,{onSubmit:Y,children:[e.note&&(0,L.jsx)(f,{tone:`warning`,children:e.note}),U.map(X),W.length>0&&(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`button`,{type:`button`,"aria-expanded":l||G,onClick:()=>h(e=>!e),className:`flex min-h-9 items-center gap-1.5 text-sm font-semibold text-foreground`,children:[(0,L.jsx)(m,{className:c(`size-4 text-muted-foreground transition-transform`,(l||G)&&`rotate-90`),"aria-hidden":`true`}),`More settings`]}),(l||G)&&(0,L.jsx)(`div`,{className:`mt-2 grid gap-4 rounded-xl border border-border bg-muted/40 p-3.5`,children:W.map(X)})]}),(0,L.jsx)(S,{busy:g,disabled:!M||Object.keys(A).length>0,status:Z})]})})}function H({field:e,value:t,removed:n,problem:r,disabled:i,onChange:a,onRemove:o}){let s=(0,k.useId)(),c=i||e.environment===!0&&e.kind!==`secret`,l=(0,L.jsxs)(L.Fragment,{children:[e.unusable&&!e.environment&&(0,L.jsxs)(`span`,{className:`mt-1 block text-xs font-semibold text-warning`,children:[`The stored value “`,e.value,`” cannot be used, so this is what applies. Save to replace it.`]}),e.environment&&(0,L.jsxs)(`span`,{className:`mt-1 block text-xs font-medium text-muted-foreground`,children:[`Set in the daemon’s environment as `,(0,L.jsx)(`code`,{children:e.envVar}),`, which wins over this page.`]}),r&&(0,L.jsx)(T,{children:r})]}),u=e.input;if(e.kind===`secret`)return(0,L.jsx)(x,{label:e.label,saved:e.set,preview:e.preview,value:t,removed:n,disabled:i,placeholder:e.placeholder,hint:e.description,notes:l,onChange:a,onRemove:o});if(u.type===`choice`)return(0,L.jsx)(b,{legend:e.label,name:e.envVar,value:t,options:u.options,disabled:c,notes:l,onChange:a});if(u.type===`switch`)return(0,L.jsx)(y,{label:e.label,description:e.description,notes:l,checked:t===u.on,disabled:c,onChange:e=>a(e?u.on:u.off)});if(u.type===`number`){let n=u.scale??1;return(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-1.5`,children:[(0,L.jsxs)(`div`,{className:`min-w-0 flex-1 basis-52`,children:[(0,L.jsx)(`label`,{htmlFor:s,className:`m-0 text-sm font-semibold text-foreground`,children:e.label}),e.description&&(0,L.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:e.description}),l]}),(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 text-sm text-muted-foreground`,children:[(0,L.jsx)(`input`,{id:s,type:`number`,inputMode:`numeric`,min:u.min/n,max:u.max/n,step:1,value:t,disabled:c,"aria-invalid":r?!0:void 0,onChange:e=>a(e.target.value),className:`w-24 text-right`}),u.unit&&(0,L.jsx)(`span`,{children:u.unit})]})]})}return(0,L.jsx)(C,{label:e.label,value:t,disabled:c,placeholder:e.placeholder,hint:e.description,notes:l,invalid:!!r,mono:!0,onChange:a})}function U(){let{tools:e}=E.useLoaderData(),t=r(),[n,i]=(0,k.useState)({}),[a,o]=(0,k.useState)(null);return(0,L.jsx)(D,{title:`Tools`,description:`What Agents can do besides thinking: search, read pages, browse and run commands. Every setting here applies to all Agents.`,children:e.map(e=>(0,L.jsx)(V,{card:e,justSaved:a===e.id,onSaved:async()=>{await t.invalidate({sync:!0}),o(e.id),i(t=>({...t,[e.id]:(t[e.id]??0)+1}))}},`${e.id}:${n[e.id]??0}`))})}export{U as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as e,Z as t,a as n,c as r,h as i,t as a}from"./createLucideIcon-CZHSSDYA.js";import{u as o}from"./preload-helper-CZOd_z6l.js";import{t as s}from"./Button-CoKQRO-s.js";import{d as c,g as l,h as u,i as d,o as f,r as p,t as m,y as h}from"./parts-C104qEuC.js";import{t as g}from"./bot-BHky7KAX.js";import{t as _}from"./chart-column-DTsDbzL0.js";import{t as v}from"./users-round-cxQ5HF-C.js";import{J as y,K as b,_ as x,g as S,h as C,q as w}from"./index-CxXsZzDC.js";import{t as T}from"./Segmented-iylzLwE6.js";import{t as E}from"./ManagePage-BzyMHGqs.js";var D=a(`cpu`,[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]),O=e(t(),1),k=i(),A=160;function j(e,t={}){return new Date(`${e}T12:00:00Z`).toLocaleDateString(void 0,{weekday:`short`,day:`numeric`,month:`short`,timeZone:`UTC`,...t})}var M=(e,t)=>t===`cost`?e.cost:e.totalTokens,N=(e,t)=>t===`cost`?b(e):`${w(e)} tokens`;function P({days:e,metric:t}){let[n,r]=(0,O.useState)(null),i=(0,O.useId)(),a=Math.max(...e.map(e=>M(e,t)),0),o=n===null?null:e[n],s=e.reduce((e,n)=>e+M(n,t),0),c=e.reduce((e,n)=>!e||M(n,t)>M(e,t)?n:e,null),l=e[0],u=e.at(-1);return(0,k.jsxs)(`div`,{className:`grid gap-2`,children:[(0,k.jsxs)(`div`,{className:`flex items-baseline justify-between text-xs text-muted-foreground`,children:[(0,k.jsx)(`span`,{className:`tabular-nums`,children:a>0?N(a,t):``}),(0,k.jsx)(`span`,{"aria-hidden":`true`,className:`font-medium text-foreground`,children:o?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`strong`,{className:`font-semibold`,children:N(M(o,t),t)}),` `,(0,k.jsx)(`span`,{className:`text-muted-foreground`,children:j(o.day)})]}):(0,k.jsx)(`span`,{className:`text-muted-foreground`,children:`Point at a day, or use the arrow keys`})})]}),(0,k.jsxs)(`div`,{role:`slider`,tabIndex:0,"aria-label":`${t===`cost`?`Spent`:`Tokens`} per day, ${N(s,t)} in all${c&&M(c,t)>0?`; most on ${j(c.day)}, ${N(M(c,t),t)}`:``}`,"aria-describedby":i,"aria-valuemin":0,"aria-valuemax":Math.max(e.length-1,0),"aria-valuenow":n??Math.max(e.length-1,0),"aria-valuetext":(()=>{let r=e[n??e.length-1];return r?`${j(r.day)}: ${N(M(r,t),t)}`:``})(),onKeyDown:t=>{if(e.length===0)return;let i=n??e.length-1,a=null;t.key===`ArrowLeft`?a=Math.max(i-1,0):t.key===`ArrowRight`?a=Math.min(i+1,e.length-1):t.key===`Home`?a=0:t.key===`End`&&(a=e.length-1),a!==null&&(t.preventDefault(),r(a))},onFocus:()=>r(t=>t??e.length-1),onBlur:()=>r(null),onPointerLeave:()=>r(null),className:`relative flex items-end gap-0.5 rounded-md border-b border-border outline-offset-4`,style:{height:A},children:[(0,k.jsx)(`span`,{id:i,className:`sr-only`,children:`The table under the chart lists every day.`}),e.map((e,i)=>{let o=M(e,t),s=a>0&&o>0?Math.max(o/a*A,2):0;return(0,k.jsx)(`div`,{onPointerEnter:()=>r(i),className:`flex h-full min-w-0 flex-1 items-end justify-center`,children:(0,k.jsx)(`div`,{className:`w-full max-w-6 rounded-t-[4px] transition-opacity ${n!==null&&n!==i?`opacity-55`:``} bg-chart-bar`,style:{height:s}})},e.day)})]}),(0,k.jsxs)(`div`,{className:`flex justify-between text-xs text-muted-foreground`,children:[(0,k.jsx)(`span`,{children:l?j(l.day):``}),(0,k.jsx)(`span`,{children:u&&u!==l?j(u.day):``})]})]})}function F(e){let[t,r]=(0,O.useState)(null),[i,a]=(0,O.useState)(null),o=String(e.days??30);return(0,O.useEffect)(()=>{let t=new AbortController,i=new URLSearchParams({days:o,tz:Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`});return e.agent&&i.set(`agent`,e.agent),e.team&&i.set(`team`,e.team),a(null),n(`/api/usage?${i}`,{signal:t.signal}).then(r).catch(e=>{t.signal.aborted||a(e instanceof Error?e.message:String(e))}),()=>t.abort()},[o,e.agent,e.team]),{report:t,error:i}}function I(){let e=C.useSearch(),t=o({from:`/usage/`}),{report:n,error:r}=F(e),i=String(e.days??30);return(0,k.jsxs)(E,{title:`Usage`,description:`What your Agents' model calls used, read from the saved conversations: the money spent on providers paid per use, and the tokens of subscriptions and of models on this computer.`,actions:(0,k.jsx)(T,{label:`Period`,value:i,options:S,onChange:e=>void t({search:t=>({...t,days:x(e)})})}),children:[n?.scope&&(0,k.jsxs)(m,{tone:`neutral`,lead:`Only ${n.scope.name}`,action:(0,k.jsx)(s,{variant:`ghost`,onClick:()=>void t({search:e=>({days:e.days})}),children:`Show every Agent`}),children:[n.scope.kind===`agent`?`One Agent`:`The Agents of one Team`,`, as Usage counts them below.`]}),r&&(0,k.jsx)(l,{tone:`danger`,title:`Usage could not be read`,children:r}),!n&&!r&&(0,k.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Counting…`}),n&&(0,k.jsx)(L,{report:n,period:i})]})}function L({report:e,period:t}){let{totals:n}=e,[i,a]=(0,O.useState)(null),o=i??(n.cost>0?`cost`:`tokens`),s=e.days!==null&&e.days>1;return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(B,{report:e}),e.unreadable>0&&(0,k.jsxs)(l,{tone:`warning`,title:`Some conversations are not counted`,children:[e.unreadable,` saved conversation`,e.unreadable===1?``:`s`,` could not be read.`]}),n.calls===0?(0,k.jsx)(h,{labelledBy:`usage-empty`,icon:(0,k.jsx)(_,{className:`size-5`}),title:`By day`,description:R(e),children:(0,k.jsx)(d,{icon:(0,k.jsx)(_,{className:`size-5`}),title:`No model calls in this period`,children:t===`all`?`Nothing is counted until an Agent answers in a conversation.`:`Pick a longer period to see earlier use.`})}):(0,k.jsxs)(k.Fragment,{children:[s&&(0,k.jsx)(h,{labelledBy:`usage-days`,icon:(0,k.jsx)(_,{className:`size-5`}),title:`By day`,description:R(e),action:(0,k.jsx)(T,{label:`Show`,value:o,options:[{id:`cost`,label:`Spent`},{id:`tokens`,label:`Tokens`}],onChange:a}),children:(0,k.jsxs)(p,{children:[(0,k.jsx)(P,{days:e.byDay,metric:o}),(0,k.jsxs)(`details`,{className:`text-sm`,children:[(0,k.jsx)(`summary`,{className:`cursor-pointer text-muted-foreground`,children:`The days as a table`}),(0,k.jsxs)(`table`,{className:`mt-2 w-full text-left tabular-nums`,children:[(0,k.jsx)(`thead`,{className:`text-xs text-muted-foreground`,children:(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`th`,{className:`py-1 font-medium`,children:`Day`}),(0,k.jsx)(`th`,{className:`py-1 font-medium`,children:`Spent`}),(0,k.jsx)(`th`,{className:`py-1 font-medium`,children:`Tokens`}),(0,k.jsx)(`th`,{className:`py-1 font-medium`,children:`Model calls`})]})}),(0,k.jsx)(`tbody`,{children:e.byDay.toReversed().map(e=>(0,k.jsxs)(`tr`,{className:`border-t border-border`,children:[(0,k.jsx)(`td`,{className:`py-1`,children:j(e.day,{year:`numeric`})}),(0,k.jsx)(`td`,{className:`py-1`,children:b(e.cost)}),(0,k.jsx)(`td`,{className:`py-1`,children:w(e.totalTokens)}),(0,k.jsx)(`td`,{className:`py-1`,children:e.calls})]},e.day))})]})]}),o===`cost`&&z(e,o)]})}),(0,k.jsx)(H,{id:`usage-teams`,icon:(0,k.jsx)(v,{className:`size-5`}),title:`By Team`,description:`Each Agent's use counts for the Team it is in now.`,rows:e.byTeam.map(e=>({key:e.teamId,title:(0,k.jsx)(r,{to:`/usage`,search:{days:x(t),team:e.teamId},children:e.teamName}),totals:e}))}),(0,k.jsx)(H,{id:`usage-agents`,icon:(0,k.jsx)(g,{className:`size-5`}),title:`By Agent`,description:`Open one for only its use.`,rows:e.byAgent.map(e=>({key:e.agentId,title:(0,k.jsx)(r,{to:`/usage`,search:{days:x(t),agent:e.agentId},children:e.agentName}),chip:e.archived?(0,k.jsx)(c,{tone:`neutral`,children:`Archived`}):void 0,meta:e.teamName,totals:e}))}),(0,k.jsx)(H,{id:`usage-models`,icon:(0,k.jsx)(D,{className:`size-5`}),title:`By model`,description:`Subscriptions and models on this computer cost nothing per use.`,rows:e.byModel.map(e=>({key:`${e.provider}/${e.model}`,title:(0,k.jsx)(`span`,{className:`break-all`,children:e.model}),chip:e.billing===`plan`?(0,k.jsx)(c,{tone:`neutral`,children:`Subscription`}):e.billing===`local`?(0,k.jsx)(c,{tone:`neutral`,children:`This computer`}):void 0,meta:e.providerName,totals:e}))})]})]})}function R(e){return e.days===null?`Everything in the saved conversations.`:e.days===1?`Today, ${j(e.to)}.`:`${e.from?j(e.from):``} to ${j(e.to)}, in this browser's time zone.`}function z(e,t){let n=e.byDay.reduce((e,n)=>!e||M(n,t)>M(e,t)?n:e,null);return!n||M(n,t)===0?null:(0,k.jsxs)(`p`,{className:`m-0 text-sm text-muted-foreground`,children:[`The most was spent on `,j(n.day),`: `,N(M(n,t),t),`.`]})}function B({report:e}){let{totals:t}=e;return(0,k.jsxs)(`section`,{"aria-labelledby":`usage-totals`,className:`grid gap-4 rounded-2xl border border-border bg-card p-5 shadow-baziu-sm sm:grid-cols-[minmax(0,1.4fr)_minmax(0,2fr)]`,children:[(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsx)(`h2`,{id:`usage-totals`,className:`m-0 font-body text-sm font-medium text-muted-foreground`,children:`Spent`}),(0,k.jsx)(`p`,{className:`m-0 font-body text-5xl font-semibold leading-tight text-foreground`,children:b(t.cost)}),(0,k.jsxs)(`p`,{className:`m-0 mt-1 text-sm text-muted-foreground`,children:[t.cost===0?`On providers paid per use.`:t.estimated?`Estimated from catalog prices, except what a provider reported it billed.`:`As the providers reported it billed.`,t.unpricedTokens>0&&` ${w(t.unpricedTokens)} tokens on models with no known price are not in it.`]})]}),(0,k.jsxs)(`dl`,{className:`m-0 grid grid-cols-2 gap-3 self-start sm:grid-cols-4`,children:[(0,k.jsx)(V,{label:`Tokens`,value:w(t.totalTokens)}),(0,k.jsx)(V,{label:`On a subscription`,value:w(t.planTokens)}),(0,k.jsx)(V,{label:`On this computer`,value:w(t.localTokens)}),(0,k.jsx)(V,{label:`Model calls`,value:t.calls.toLocaleString()})]})]})}function V({label:e,value:t}){return(0,k.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-muted px-3 py-2.5`,children:[(0,k.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:e}),(0,k.jsx)(`dd`,{className:`m-0 text-xl font-semibold text-foreground`,children:t})]})}function H({id:e,icon:t,title:n,description:r,rows:i}){return i.length===0?null:(0,k.jsx)(h,{labelledBy:e,icon:t,title:n,description:r,children:(0,k.jsx)(f,{children:i.map(e=>(0,k.jsx)(u,{inline:!0,title:e.title,chip:e.chip,meta:(0,k.jsxs)(k.Fragment,{children:[e.meta&&(0,k.jsx)(`span`,{children:e.meta}),(0,k.jsxs)(`span`,{children:[w(e.totals.inputTokens+e.totals.cacheReadTokens),` in ·`,` `,w(e.totals.outputTokens),` out · `,e.totals.calls.toLocaleString(),` `,`call`,e.totals.calls===1?``:`s`]})]}),actions:(0,k.jsx)(`span`,{className:`text-sm font-semibold tabular-nums text-foreground`,children:y(e.totals)})},e.key))})})}export{I as component};
|
|
1
|
+
import{$ as e,Z as t,a as n,c as r,h as i,t as a}from"./createLucideIcon-CZHSSDYA.js";import{u as o}from"./preload-helper-CZOd_z6l.js";import{t as s}from"./Button-CoKQRO-s.js";import{d as c,g as l,h as u,i as d,o as f,r as p,t as m,y as h}from"./parts-C104qEuC.js";import{t as g}from"./bot-BHky7KAX.js";import{t as _}from"./chart-column-DTsDbzL0.js";import{t as v}from"./users-round-cxQ5HF-C.js";import{J as y,K as b,_ as x,g as S,h as C,q as w}from"./index-DuLpyCSP.js";import{t as T}from"./Segmented-iylzLwE6.js";import{t as E}from"./ManagePage-BzyMHGqs.js";var D=a(`cpu`,[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]),O=e(t(),1),k=i(),A=160;function j(e,t={}){return new Date(`${e}T12:00:00Z`).toLocaleDateString(void 0,{weekday:`short`,day:`numeric`,month:`short`,timeZone:`UTC`,...t})}var M=(e,t)=>t===`cost`?e.cost:e.totalTokens,N=(e,t)=>t===`cost`?b(e):`${w(e)} tokens`;function P({days:e,metric:t}){let[n,r]=(0,O.useState)(null),i=(0,O.useId)(),a=Math.max(...e.map(e=>M(e,t)),0),o=n===null?null:e[n],s=e.reduce((e,n)=>e+M(n,t),0),c=e.reduce((e,n)=>!e||M(n,t)>M(e,t)?n:e,null),l=e[0],u=e.at(-1);return(0,k.jsxs)(`div`,{className:`grid gap-2`,children:[(0,k.jsxs)(`div`,{className:`flex items-baseline justify-between text-xs text-muted-foreground`,children:[(0,k.jsx)(`span`,{className:`tabular-nums`,children:a>0?N(a,t):``}),(0,k.jsx)(`span`,{"aria-hidden":`true`,className:`font-medium text-foreground`,children:o?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`strong`,{className:`font-semibold`,children:N(M(o,t),t)}),` `,(0,k.jsx)(`span`,{className:`text-muted-foreground`,children:j(o.day)})]}):(0,k.jsx)(`span`,{className:`text-muted-foreground`,children:`Point at a day, or use the arrow keys`})})]}),(0,k.jsxs)(`div`,{role:`slider`,tabIndex:0,"aria-label":`${t===`cost`?`Spent`:`Tokens`} per day, ${N(s,t)} in all${c&&M(c,t)>0?`; most on ${j(c.day)}, ${N(M(c,t),t)}`:``}`,"aria-describedby":i,"aria-valuemin":0,"aria-valuemax":Math.max(e.length-1,0),"aria-valuenow":n??Math.max(e.length-1,0),"aria-valuetext":(()=>{let r=e[n??e.length-1];return r?`${j(r.day)}: ${N(M(r,t),t)}`:``})(),onKeyDown:t=>{if(e.length===0)return;let i=n??e.length-1,a=null;t.key===`ArrowLeft`?a=Math.max(i-1,0):t.key===`ArrowRight`?a=Math.min(i+1,e.length-1):t.key===`Home`?a=0:t.key===`End`&&(a=e.length-1),a!==null&&(t.preventDefault(),r(a))},onFocus:()=>r(t=>t??e.length-1),onBlur:()=>r(null),onPointerLeave:()=>r(null),className:`relative flex items-end gap-0.5 rounded-md border-b border-border outline-offset-4`,style:{height:A},children:[(0,k.jsx)(`span`,{id:i,className:`sr-only`,children:`The table under the chart lists every day.`}),e.map((e,i)=>{let o=M(e,t),s=a>0&&o>0?Math.max(o/a*A,2):0;return(0,k.jsx)(`div`,{onPointerEnter:()=>r(i),className:`flex h-full min-w-0 flex-1 items-end justify-center`,children:(0,k.jsx)(`div`,{className:`w-full max-w-6 rounded-t-[4px] transition-opacity ${n!==null&&n!==i?`opacity-55`:``} bg-chart-bar`,style:{height:s}})},e.day)})]}),(0,k.jsxs)(`div`,{className:`flex justify-between text-xs text-muted-foreground`,children:[(0,k.jsx)(`span`,{children:l?j(l.day):``}),(0,k.jsx)(`span`,{children:u&&u!==l?j(u.day):``})]})]})}function F(e){let[t,r]=(0,O.useState)(null),[i,a]=(0,O.useState)(null),o=String(e.days??30);return(0,O.useEffect)(()=>{let t=new AbortController,i=new URLSearchParams({days:o,tz:Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`});return e.agent&&i.set(`agent`,e.agent),e.team&&i.set(`team`,e.team),a(null),n(`/api/usage?${i}`,{signal:t.signal}).then(r).catch(e=>{t.signal.aborted||a(e instanceof Error?e.message:String(e))}),()=>t.abort()},[o,e.agent,e.team]),{report:t,error:i}}function I(){let e=C.useSearch(),t=o({from:`/usage/`}),{report:n,error:r}=F(e),i=String(e.days??30);return(0,k.jsxs)(E,{title:`Usage`,description:`What your Agents' model calls used, read from the saved conversations: the money spent on providers paid per use, and the tokens of subscriptions and of models on this computer.`,actions:(0,k.jsx)(T,{label:`Period`,value:i,options:S,onChange:e=>void t({search:t=>({...t,days:x(e)})})}),children:[n?.scope&&(0,k.jsxs)(m,{tone:`neutral`,lead:`Only ${n.scope.name}`,action:(0,k.jsx)(s,{variant:`ghost`,onClick:()=>void t({search:e=>({days:e.days})}),children:`Show every Agent`}),children:[n.scope.kind===`agent`?`One Agent`:`The Agents of one Team`,`, as Usage counts them below.`]}),r&&(0,k.jsx)(l,{tone:`danger`,title:`Usage could not be read`,children:r}),!n&&!r&&(0,k.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Counting…`}),n&&(0,k.jsx)(L,{report:n,period:i})]})}function L({report:e,period:t}){let{totals:n}=e,[i,a]=(0,O.useState)(null),o=i??(n.cost>0?`cost`:`tokens`),s=e.days!==null&&e.days>1;return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(B,{report:e}),e.unreadable>0&&(0,k.jsxs)(l,{tone:`warning`,title:`Some conversations are not counted`,children:[e.unreadable,` saved conversation`,e.unreadable===1?``:`s`,` could not be read.`]}),n.calls===0?(0,k.jsx)(h,{labelledBy:`usage-empty`,icon:(0,k.jsx)(_,{className:`size-5`}),title:`By day`,description:R(e),children:(0,k.jsx)(d,{icon:(0,k.jsx)(_,{className:`size-5`}),title:`No model calls in this period`,children:t===`all`?`Nothing is counted until an Agent answers in a conversation.`:`Pick a longer period to see earlier use.`})}):(0,k.jsxs)(k.Fragment,{children:[s&&(0,k.jsx)(h,{labelledBy:`usage-days`,icon:(0,k.jsx)(_,{className:`size-5`}),title:`By day`,description:R(e),action:(0,k.jsx)(T,{label:`Show`,value:o,options:[{id:`cost`,label:`Spent`},{id:`tokens`,label:`Tokens`}],onChange:a}),children:(0,k.jsxs)(p,{children:[(0,k.jsx)(P,{days:e.byDay,metric:o}),(0,k.jsxs)(`details`,{className:`text-sm`,children:[(0,k.jsx)(`summary`,{className:`cursor-pointer text-muted-foreground`,children:`The days as a table`}),(0,k.jsxs)(`table`,{className:`mt-2 w-full text-left tabular-nums`,children:[(0,k.jsx)(`thead`,{className:`text-xs text-muted-foreground`,children:(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`th`,{className:`py-1 font-medium`,children:`Day`}),(0,k.jsx)(`th`,{className:`py-1 font-medium`,children:`Spent`}),(0,k.jsx)(`th`,{className:`py-1 font-medium`,children:`Tokens`}),(0,k.jsx)(`th`,{className:`py-1 font-medium`,children:`Model calls`})]})}),(0,k.jsx)(`tbody`,{children:e.byDay.toReversed().map(e=>(0,k.jsxs)(`tr`,{className:`border-t border-border`,children:[(0,k.jsx)(`td`,{className:`py-1`,children:j(e.day,{year:`numeric`})}),(0,k.jsx)(`td`,{className:`py-1`,children:b(e.cost)}),(0,k.jsx)(`td`,{className:`py-1`,children:w(e.totalTokens)}),(0,k.jsx)(`td`,{className:`py-1`,children:e.calls})]},e.day))})]})]}),o===`cost`&&z(e,o)]})}),(0,k.jsx)(H,{id:`usage-teams`,icon:(0,k.jsx)(v,{className:`size-5`}),title:`By Team`,description:`Each Agent's use counts for the Team it is in now.`,rows:e.byTeam.map(e=>({key:e.teamId,title:(0,k.jsx)(r,{to:`/usage`,search:{days:x(t),team:e.teamId},children:e.teamName}),totals:e}))}),(0,k.jsx)(H,{id:`usage-agents`,icon:(0,k.jsx)(g,{className:`size-5`}),title:`By Agent`,description:`Open one for only its use.`,rows:e.byAgent.map(e=>({key:e.agentId,title:(0,k.jsx)(r,{to:`/usage`,search:{days:x(t),agent:e.agentId},children:e.agentName}),chip:e.archived?(0,k.jsx)(c,{tone:`neutral`,children:`Archived`}):void 0,meta:e.teamName,totals:e}))}),(0,k.jsx)(H,{id:`usage-models`,icon:(0,k.jsx)(D,{className:`size-5`}),title:`By model`,description:`Subscriptions and models on this computer cost nothing per use.`,rows:e.byModel.map(e=>({key:`${e.provider}/${e.model}`,title:(0,k.jsx)(`span`,{className:`break-all`,children:e.model}),chip:e.billing===`plan`?(0,k.jsx)(c,{tone:`neutral`,children:`Subscription`}):e.billing===`local`?(0,k.jsx)(c,{tone:`neutral`,children:`This computer`}):void 0,meta:e.providerName,totals:e}))})]})]})}function R(e){return e.days===null?`Everything in the saved conversations.`:e.days===1?`Today, ${j(e.to)}.`:`${e.from?j(e.from):``} to ${j(e.to)}, in this browser's time zone.`}function z(e,t){let n=e.byDay.reduce((e,n)=>!e||M(n,t)>M(e,t)?n:e,null);return!n||M(n,t)===0?null:(0,k.jsxs)(`p`,{className:`m-0 text-sm text-muted-foreground`,children:[`The most was spent on `,j(n.day),`: `,N(M(n,t),t),`.`]})}function B({report:e}){let{totals:t}=e;return(0,k.jsxs)(`section`,{"aria-labelledby":`usage-totals`,className:`grid gap-4 rounded-2xl border border-border bg-card p-5 shadow-baziu-sm sm:grid-cols-[minmax(0,1.4fr)_minmax(0,2fr)]`,children:[(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsx)(`h2`,{id:`usage-totals`,className:`m-0 font-body text-sm font-medium text-muted-foreground`,children:`Spent`}),(0,k.jsx)(`p`,{className:`m-0 font-body text-5xl font-semibold leading-tight text-foreground`,children:b(t.cost)}),(0,k.jsxs)(`p`,{className:`m-0 mt-1 text-sm text-muted-foreground`,children:[t.cost===0?`On providers paid per use.`:t.estimated?`Estimated from catalog prices, except what a provider reported it billed.`:`As the providers reported it billed.`,t.unpricedTokens>0&&` ${w(t.unpricedTokens)} tokens on models with no known price are not in it.`]})]}),(0,k.jsxs)(`dl`,{className:`m-0 grid grid-cols-2 gap-3 self-start sm:grid-cols-4`,children:[(0,k.jsx)(V,{label:`Tokens`,value:w(t.totalTokens)}),(0,k.jsx)(V,{label:`On a subscription`,value:w(t.planTokens)}),(0,k.jsx)(V,{label:`On this computer`,value:w(t.localTokens)}),(0,k.jsx)(V,{label:`Model calls`,value:t.calls.toLocaleString()})]})]})}function V({label:e,value:t}){return(0,k.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-muted px-3 py-2.5`,children:[(0,k.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:e}),(0,k.jsx)(`dd`,{className:`m-0 text-xl font-semibold text-foreground`,children:t})]})}function H({id:e,icon:t,title:n,description:r,rows:i}){return i.length===0?null:(0,k.jsx)(h,{labelledBy:e,icon:t,title:n,description:r,children:(0,k.jsx)(f,{children:i.map(e=>(0,k.jsx)(u,{inline:!0,title:e.title,chip:e.chip,meta:(0,k.jsxs)(k.Fragment,{children:[e.meta&&(0,k.jsx)(`span`,{children:e.meta}),(0,k.jsxs)(`span`,{children:[w(e.totals.inputTokens+e.totals.cacheReadTokens),` in ·`,` `,w(e.totals.outputTokens),` out · `,e.totals.calls.toLocaleString(),` `,`call`,e.totals.calls===1?``:`s`]})]}),actions:(0,k.jsx)(`span`,{className:`text-sm font-semibold tabular-nums text-foreground`,children:y(e.totals)})},e.key))})})}export{I as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as e,Z as t,a as n,h as r}from"./createLucideIcon-CZHSSDYA.js";import{r as i,u as a}from"./preload-helper-CZOd_z6l.js";import{t as o}from"./Button-CoKQRO-s.js";import{x as s}from"./es2015-DZDOQ3kj.js";import{B as c,U as l}from"./parts-C104qEuC.js";import{t as u}from"./arrow-right-BqqfPqVi.js";import{X as d,b as f,kt as p}from"./index-
|
|
1
|
+
import{$ as e,Z as t,a as n,h as r}from"./createLucideIcon-CZHSSDYA.js";import{r as i,u as a}from"./preload-helper-CZOd_z6l.js";import{t as o}from"./Button-CoKQRO-s.js";import{x as s}from"./es2015-DZDOQ3kj.js";import{B as c,U as l}from"./parts-C104qEuC.js";import{t as u}from"./arrow-right-BqqfPqVi.js";import{X as d,b as f,kt as p}from"./index-DuLpyCSP.js";import{r as m}from"./use-resource-qjIkNQDY.js";import{a as h,c as g,i as _,n as v,r as y}from"./AddProviderDialog-D8VvDmbM.js";var b=e(t()),x=r(),S=`rounded-2xl border border-border bg-card shadow-baziu-sm`;function C(){let e=f.useLoaderData();i(`Welcome`);let t=a(),[r,m]=(0,b.useState)({at:`choose`}),[_,C]=(0,b.useState)(!1),O=e.filter(e=>e.group===`popular`).slice(0,4),k=e.filter(e=>e.group!==`local`&&!O.includes(e)),A=r.at===`done`?3:r.at===`connect`?2:1,j=r.at===`connect`?e.find(e=>e.id===r.id):void 0;async function M(){C(!0);try{let{agent:e}=await n(`/api/agents`,{body:{profileId:d}});await t({to:`/`,search:{agent:e.id}})}catch{await t({to:`/`})}}return(0,x.jsxs)(l,{className:`max-w-4xl`,children:[(0,x.jsxs)(`header`,{children:[(0,x.jsx)(`div`,{className:`mb-1 text-xs font-semibold uppercase tracking-[0.12em] text-primary`,children:`First run`}),(0,x.jsx)(`h1`,{className:`m-0 font-display text-4xl leading-tight text-foreground`,children:`Connect a model to start`}),(0,x.jsx)(`p`,{className:`mt-3 max-w-2xl text-base leading-6 text-muted-foreground`,children:`Bazilion needs one provider to think with. More providers, web search, the browser and Telegram can wait until you want them.`})]}),(0,x.jsx)(`ol`,{"aria-label":`Steps`,className:`flex list-none flex-wrap items-center gap-x-3 gap-y-2 p-0`,children:[`Choose a provider`,`Connect`,`Start chatting`].map((e,t)=>{let n=t+1,r=n<A,i=n===A;return(0,x.jsxs)(`li`,{"aria-current":i?`step`:void 0,className:`flex items-center gap-2.5`,children:[(0,x.jsx)(`span`,{className:`flex size-7 items-center justify-center rounded-full border-[1.5px] text-sm font-bold ${r?`border-success bg-success text-white`:i?`border-primary bg-primary text-primary-foreground`:`border-fawn text-muted-foreground`}`,children:r?(0,x.jsx)(s,{className:`size-3.5`,"aria-label":`Done`}):n}),(0,x.jsx)(`span`,{className:`text-sm font-semibold ${i?`text-foreground`:`text-muted-foreground`}`,children:e}),n<3&&(0,x.jsx)(`span`,{"aria-hidden":`true`,className:`h-px w-10 bg-fawn`})]},e)})}),r.at===`choose`&&(0,x.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[O.map(e=>(0,x.jsx)(T,{icon:(0,x.jsx)(g,{name:e.displayName,tone:`accent`,className:`size-10`}),title:e.connect===`signin`?`ChatGPT account`:e.displayName,sub:e.hint??``,foot:e.connect===`signin`?`Sign in`:`Paste an API key`,onClick:()=>m({at:`connect`,id:e.id,from:`choose`})},e.id)),(0,x.jsx)(T,{icon:(0,x.jsx)(w,{icon:(0,x.jsx)(p,{className:`size-5`})}),title:`On this computer`,sub:`Ollama, LM Studio or llama.cpp.`,foot:`No account needed`,onClick:()=>m({at:`local`})}),(0,x.jsx)(T,{icon:(0,x.jsx)(w,{icon:(0,x.jsx)(c,{className:`size-5`})}),title:`Another provider`,sub:`${k.slice(0,3).map(e=>e.displayName).join(`, `)} and ${k.length-3} more.`,foot:`Search`,onClick:()=>m({at:`more`})})]}),r.at===`local`&&(0,x.jsx)(D,{providers:e,onBack:()=>m({at:`choose`}),onUse:e=>m({at:`connect`,id:e,from:`local`})}),r.at===`more`&&(0,x.jsxs)(`section`,{"aria-label":`Another provider`,className:`${S} p-5`,children:[(0,x.jsx)(E,{title:`Another provider`,onBack:()=>m({at:`choose`})}),(0,x.jsx)(y,{providers:k,expanded:!0,onPick:e=>m({at:`connect`,id:e.id,from:`more`})})]}),r.at===`connect`&&j&&(0,x.jsxs)(`section`,{"aria-label":`Connect ${j.displayName}`,className:`${S} p-5`,children:[(0,x.jsx)(E,{title:`Connect ${j.displayName}`,icon:(0,x.jsx)(g,{name:j.displayName,tone:`accent`,className:`size-10`}),onBack:()=>m({at:r.from})}),(0,x.jsx)(`div`,{className:`max-w-2xl`,children:(0,x.jsx)(h,{provider:j,onConnected:e=>m({at:`done`,result:e})},j.id)})]}),r.at===`done`&&(0,x.jsxs)(`section`,{className:`${S} p-6`,children:[(0,x.jsx)(v,{result:r.result,imageRoutes:[]}),(0,x.jsxs)(`p`,{className:`m-0 mt-3 pl-[3.75rem] text-sm text-muted-foreground`,children:[`Bazilion made a Default team and a Default Agent template`,r.result.provider.models[0]?` on ${r.result.provider.models[0]}`:``,`.`]}),(0,x.jsxs)(`div`,{className:`mt-6 flex flex-wrap items-center gap-x-4 gap-y-3 border-t border-frost pt-5`,children:[(0,x.jsxs)(o,{variant:`primary`,disabled:_,onClick:()=>void M(),className:`min-h-12 px-6 text-base`,children:[_?`Opening…`:`Start chatting`,(0,x.jsx)(u,{className:`size-4`,"aria-hidden":`true`})]}),(0,x.jsx)(`a`,{href:`/config?add=new`,className:`text-sm font-semibold`,children:`Add another provider`}),(0,x.jsx)(`span`,{className:`min-w-0 flex-1 basis-56 text-sm text-muted-foreground sm:text-right`,children:`Web search, the browser and Telegram: later, under Manage, Setup.`})]})]})]})}function w({icon:e}){return(0,x.jsx)(`span`,{"aria-hidden":`true`,className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-muted text-muted-foreground`,children:e})}function T({icon:e,title:t,sub:n,foot:r,onClick:i}){return(0,x.jsxs)(`button`,{type:`button`,onClick:i,className:`${S} flex min-h-36 flex-col items-start gap-2.5 p-4 text-left transition-colors hover:border-primary/40 hover:bg-accent/30`,children:[e,(0,x.jsxs)(`span`,{children:[(0,x.jsx)(`span`,{className:`block text-base font-semibold text-foreground`,children:t}),(0,x.jsx)(`span`,{className:`mt-0.5 block text-sm text-muted-foreground`,children:n})]}),(0,x.jsx)(`span`,{className:`mt-auto text-xs font-semibold text-primary`,children:r})]})}function E({title:e,icon:t,onBack:n}){return(0,x.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-3`,children:[t,(0,x.jsx)(`h2`,{className:`m-0 min-w-0 flex-1 basis-48 font-display text-2xl text-foreground`,children:e}),(0,x.jsx)(o,{variant:`ghost`,onClick:n,children:`Choose another`})]})}function D({providers:e,onBack:t,onUse:r}){let i=m(e=>n(`/api/config/providers/local`,{signal:e}),[]),a=i.data?.servers??[],s=a.filter(e=>e.found).length;return(0,x.jsxs)(`section`,{"aria-label":`On this computer`,className:`${S} overflow-hidden`,children:[(0,x.jsxs)(`div`,{className:`px-5 pt-5`,children:[(0,x.jsx)(E,{title:`On this computer`,onBack:t}),(0,x.jsx)(`p`,{className:`m-0 -mt-2 mb-4 text-sm text-muted-foreground`,children:i.loading?`Looking at the usual addresses…`:i.error?i.error:s===0?`No model server answered at the usual addresses.`:`Bazilion looked at the usual addresses and found ${s===1?`one server`:`${s} servers`}.`})]}),e.filter(e=>e.group===`local`).map(e=>{let t=a.find(t=>t.id===e.id);return(0,x.jsxs)(`div`,{className:`flex min-h-[4.5rem] flex-wrap items-center gap-3 border-t border-border px-5 py-3`,children:[(0,x.jsx)(g,{name:e.displayName,tone:t?.found?`success`:`neutral`}),(0,x.jsxs)(`div`,{className:`min-w-0 flex-1 basis-56`,children:[(0,x.jsx)(`div`,{className:`text-base font-semibold text-foreground`,children:e.displayName}),(0,x.jsx)(`div`,{className:`text-sm ${t?.found?`text-success`:`text-muted-foreground`}`,children:t?t.found?`Running at ${_(t.address)}, with ${t.models.length===1?`1 model`:`${t.models.length} models`}`:`Nothing at ${_(t.address)}. Start it and switch its server on.`:`Looking…`})]}),(0,x.jsx)(o,{variant:t?.found?`primary`:`ghost`,onClick:()=>r(e.id),children:t?.found?`Use ${e.displayName}`:`Type its address`})]},e.id)}),(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 border-t border-border bg-muted/50 px-5 py-3`,children:[(0,x.jsx)(`span`,{className:`min-w-0 flex-1 basis-56 text-sm text-muted-foreground`,children:`These are the usual addresses on this computer. A server on another machine needs its address typed.`}),(0,x.jsx)(o,{variant:`ghost`,disabled:i.loading,onClick:()=>void i.reload(),children:i.loading?`Looking…`:`Look again`})]})]})}export{C as component};
|
|
@@ -26,7 +26,7 @@ var tsrStartManifest = () => ({ routes: {
|
|
|
26
26
|
],
|
|
27
27
|
css: ["/assets/index-Cofc7zhl.css"],
|
|
28
28
|
preloads: [
|
|
29
|
-
"/assets/index-
|
|
29
|
+
"/assets/index-DuLpyCSP.js",
|
|
30
30
|
"/assets/createLucideIcon-CZHSSDYA.js",
|
|
31
31
|
"/assets/preload-helper-CZOd_z6l.js",
|
|
32
32
|
"/assets/Button-CoKQRO-s.js",
|
|
@@ -36,23 +36,23 @@ var tsrStartManifest = () => ({ routes: {
|
|
|
36
36
|
scripts: [{ attrs: {
|
|
37
37
|
type: "module",
|
|
38
38
|
async: !0,
|
|
39
|
-
src: "/assets/index-
|
|
39
|
+
src: "/assets/index-DuLpyCSP.js"
|
|
40
40
|
} }]
|
|
41
41
|
},
|
|
42
42
|
"/": {
|
|
43
43
|
filePath: "/home/runner/work/bazilion/bazilion/apps/web/src/routes/index.tsx",
|
|
44
44
|
children: void 0,
|
|
45
45
|
preloads: [
|
|
46
|
-
"/assets/routes-
|
|
47
|
-
"/assets/ConfirmDialog-
|
|
46
|
+
"/assets/routes-BDdLZEGO.js",
|
|
47
|
+
"/assets/ConfirmDialog-DrN26lN_.js",
|
|
48
48
|
"/assets/Segmented-iylzLwE6.js",
|
|
49
|
-
"/assets/SpawnTeamModal-
|
|
50
|
-
"/assets/TeamForm-
|
|
51
|
-
"/assets/UnsavedChangesGuard-
|
|
52
|
-
"/assets/TeamThread-
|
|
53
|
-
"/assets/SkillsParts-
|
|
49
|
+
"/assets/SpawnTeamModal-B65eQyzu.js",
|
|
50
|
+
"/assets/TeamForm-BhI9FbjV.js",
|
|
51
|
+
"/assets/UnsavedChangesGuard-CYz0AopL.js",
|
|
52
|
+
"/assets/TeamThread-FPpHlVFc.js",
|
|
53
|
+
"/assets/SkillsParts-BueR3HoP.js",
|
|
54
54
|
"/assets/agent-actions-B-9KIwn6.js",
|
|
55
|
-
"/assets/manage-
|
|
55
|
+
"/assets/manage-DdCiSgG9.js",
|
|
56
56
|
"/assets/use-resource-qjIkNQDY.js",
|
|
57
57
|
"/assets/download-Dr0PgyMr.js",
|
|
58
58
|
"/assets/images-BULrW-FC.js",
|
|
@@ -73,7 +73,7 @@ var tsrStartManifest = () => ({ routes: {
|
|
|
73
73
|
filePath: "/home/runner/work/bazilion/bazilion/apps/web/src/routes/login.tsx",
|
|
74
74
|
children: void 0,
|
|
75
75
|
preloads: [
|
|
76
|
-
"/assets/login-
|
|
76
|
+
"/assets/login-q9O7dqRe.js",
|
|
77
77
|
"/assets/key-round-DmSZN0Kq.js",
|
|
78
78
|
"/assets/users-round-cxQ5HF-C.js"
|
|
79
79
|
]
|
|
@@ -82,8 +82,8 @@ var tsrStartManifest = () => ({ routes: {
|
|
|
82
82
|
filePath: "/home/runner/work/bazilion/bazilion/apps/web/src/routes/welcome.tsx",
|
|
83
83
|
children: void 0,
|
|
84
84
|
preloads: [
|
|
85
|
-
"/assets/welcome-
|
|
86
|
-
"/assets/AddProviderDialog-
|
|
85
|
+
"/assets/welcome-CkmanVa_.js",
|
|
86
|
+
"/assets/AddProviderDialog-D8VvDmbM.js",
|
|
87
87
|
"/assets/use-resource-qjIkNQDY.js",
|
|
88
88
|
"/assets/arrow-right-BqqfPqVi.js"
|
|
89
89
|
]
|
|
@@ -92,9 +92,9 @@ var tsrStartManifest = () => ({ routes: {
|
|
|
92
92
|
filePath: "/home/runner/work/bazilion/bazilion/apps/web/src/routes/config/access.tsx",
|
|
93
93
|
children: void 0,
|
|
94
94
|
preloads: [
|
|
95
|
-
"/assets/access-
|
|
95
|
+
"/assets/access-BGtASxet.js",
|
|
96
96
|
"/assets/ConfigPage-DFmHgEaL.js",
|
|
97
|
-
"/assets/ConfirmDialog-
|
|
97
|
+
"/assets/ConfirmDialog-DrN26lN_.js",
|
|
98
98
|
"/assets/key-round-DmSZN0Kq.js",
|
|
99
99
|
"/assets/plus-CEKaHPBw.js"
|
|
100
100
|
]
|
|
@@ -103,9 +103,9 @@ var tsrStartManifest = () => ({ routes: {
|
|
|
103
103
|
filePath: "/home/runner/work/bazilion/bazilion/apps/web/src/routes/config/mcp.tsx",
|
|
104
104
|
children: void 0,
|
|
105
105
|
preloads: [
|
|
106
|
-
"/assets/mcp-
|
|
106
|
+
"/assets/mcp-B3LzNtrr.js",
|
|
107
107
|
"/assets/ConfigPage-DFmHgEaL.js",
|
|
108
|
-
"/assets/ConfirmDialog-
|
|
108
|
+
"/assets/ConfirmDialog-DrN26lN_.js",
|
|
109
109
|
"/assets/plus-CEKaHPBw.js"
|
|
110
110
|
]
|
|
111
111
|
},
|
|
@@ -113,7 +113,7 @@ var tsrStartManifest = () => ({ routes: {
|
|
|
113
113
|
filePath: "/home/runner/work/bazilion/bazilion/apps/web/src/routes/config/system.tsx",
|
|
114
114
|
children: void 0,
|
|
115
115
|
preloads: [
|
|
116
|
-
"/assets/system-
|
|
116
|
+
"/assets/system-DtBBeAjO.js",
|
|
117
117
|
"/assets/ConfigPage-DFmHgEaL.js",
|
|
118
118
|
"/assets/download-Dr0PgyMr.js",
|
|
119
119
|
"/assets/square-terminal-CYfGBHPC.js"
|
|
@@ -123,9 +123,9 @@ var tsrStartManifest = () => ({ routes: {
|
|
|
123
123
|
filePath: "/home/runner/work/bazilion/bazilion/apps/web/src/routes/config/telegram.tsx",
|
|
124
124
|
children: void 0,
|
|
125
125
|
preloads: [
|
|
126
|
-
"/assets/telegram-
|
|
126
|
+
"/assets/telegram-B7vlTQbt.js",
|
|
127
127
|
"/assets/ConfigPage-DFmHgEaL.js",
|
|
128
|
-
"/assets/ConfirmDialog-
|
|
128
|
+
"/assets/ConfirmDialog-DrN26lN_.js",
|
|
129
129
|
"/assets/use-resource-qjIkNQDY.js",
|
|
130
130
|
"/assets/bot-BHky7KAX.js",
|
|
131
131
|
"/assets/list-checks-DdTdAQXS.js"
|
|
@@ -135,7 +135,7 @@ var tsrStartManifest = () => ({ routes: {
|
|
|
135
135
|
filePath: "/home/runner/work/bazilion/bazilion/apps/web/src/routes/config/tools.tsx",
|
|
136
136
|
children: void 0,
|
|
137
137
|
preloads: [
|
|
138
|
-
"/assets/tools-
|
|
138
|
+
"/assets/tools-C0FIeAL1.js",
|
|
139
139
|
"/assets/ConfigPage-DFmHgEaL.js",
|
|
140
140
|
"/assets/chevron-right-D1shxvdo.js",
|
|
141
141
|
"/assets/file-text-D6OTHixJ.js",
|
|
@@ -147,12 +147,12 @@ var tsrStartManifest = () => ({ routes: {
|
|
|
147
147
|
filePath: "/home/runner/work/bazilion/bazilion/apps/web/src/routes/agents/index.tsx",
|
|
148
148
|
children: void 0,
|
|
149
149
|
preloads: [
|
|
150
|
-
"/assets/agents-
|
|
151
|
-
"/assets/ConfirmDialog-
|
|
150
|
+
"/assets/agents-Bfwz3dl5.js",
|
|
151
|
+
"/assets/ConfirmDialog-DrN26lN_.js",
|
|
152
152
|
"/assets/ManagePage-BzyMHGqs.js",
|
|
153
153
|
"/assets/Segmented-iylzLwE6.js",
|
|
154
154
|
"/assets/agent-actions-B-9KIwn6.js",
|
|
155
|
-
"/assets/manage-
|
|
155
|
+
"/assets/manage-DdCiSgG9.js",
|
|
156
156
|
"/assets/bot-BHky7KAX.js"
|
|
157
157
|
]
|
|
158
158
|
},
|
|
@@ -160,9 +160,9 @@ var tsrStartManifest = () => ({ routes: {
|
|
|
160
160
|
filePath: "/home/runner/work/bazilion/bazilion/apps/web/src/routes/attention/index.tsx",
|
|
161
161
|
children: void 0,
|
|
162
162
|
preloads: [
|
|
163
|
-
"/assets/attention-
|
|
163
|
+
"/assets/attention-BIC0TL8d.js",
|
|
164
164
|
"/assets/Segmented-iylzLwE6.js",
|
|
165
|
-
"/assets/manage-
|
|
165
|
+
"/assets/manage-DdCiSgG9.js",
|
|
166
166
|
"/assets/use-resource-qjIkNQDY.js"
|
|
167
167
|
]
|
|
168
168
|
},
|
|
@@ -170,11 +170,11 @@ var tsrStartManifest = () => ({ routes: {
|
|
|
170
170
|
filePath: "/home/runner/work/bazilion/bazilion/apps/web/src/routes/config/index.tsx",
|
|
171
171
|
children: void 0,
|
|
172
172
|
preloads: [
|
|
173
|
-
"/assets/config-
|
|
173
|
+
"/assets/config-kMzM8kdp.js",
|
|
174
174
|
"/assets/ConfigPage-DFmHgEaL.js",
|
|
175
|
-
"/assets/ConfirmDialog-
|
|
175
|
+
"/assets/ConfirmDialog-DrN26lN_.js",
|
|
176
176
|
"/assets/Segmented-iylzLwE6.js",
|
|
177
|
-
"/assets/AddProviderDialog-
|
|
177
|
+
"/assets/AddProviderDialog-D8VvDmbM.js",
|
|
178
178
|
"/assets/use-resource-qjIkNQDY.js",
|
|
179
179
|
"/assets/images-BULrW-FC.js",
|
|
180
180
|
"/assets/chevron-right-D1shxvdo.js",
|
|
@@ -186,22 +186,22 @@ var tsrStartManifest = () => ({ routes: {
|
|
|
186
186
|
filePath: "/home/runner/work/bazilion/bazilion/apps/web/src/routes/skills/index.tsx",
|
|
187
187
|
children: void 0,
|
|
188
188
|
preloads: [
|
|
189
|
-
"/assets/skills-
|
|
190
|
-
"/assets/ConfirmDialog-
|
|
189
|
+
"/assets/skills-VEtq-MQJ.js",
|
|
190
|
+
"/assets/ConfirmDialog-DrN26lN_.js",
|
|
191
191
|
"/assets/ManagePage-BzyMHGqs.js",
|
|
192
|
-
"/assets/SkillsParts-
|
|
193
|
-
"/assets/manage-
|
|
192
|
+
"/assets/SkillsParts-BueR3HoP.js",
|
|
193
|
+
"/assets/manage-DdCiSgG9.js"
|
|
194
194
|
]
|
|
195
195
|
},
|
|
196
196
|
"/teams/": {
|
|
197
197
|
filePath: "/home/runner/work/bazilion/bazilion/apps/web/src/routes/teams/index.tsx",
|
|
198
198
|
children: void 0,
|
|
199
199
|
preloads: [
|
|
200
|
-
"/assets/teams-
|
|
201
|
-
"/assets/ConfirmDialog-
|
|
200
|
+
"/assets/teams-QlaY2Sxd.js",
|
|
201
|
+
"/assets/ConfirmDialog-DrN26lN_.js",
|
|
202
202
|
"/assets/ManagePage-BzyMHGqs.js",
|
|
203
|
-
"/assets/TeamForm-
|
|
204
|
-
"/assets/manage-
|
|
203
|
+
"/assets/TeamForm-BhI9FbjV.js",
|
|
204
|
+
"/assets/manage-DdCiSgG9.js",
|
|
205
205
|
"/assets/users-round-cxQ5HF-C.js"
|
|
206
206
|
]
|
|
207
207
|
},
|
|
@@ -209,7 +209,7 @@ var tsrStartManifest = () => ({ routes: {
|
|
|
209
209
|
filePath: "/home/runner/work/bazilion/bazilion/apps/web/src/routes/usage/index.tsx",
|
|
210
210
|
children: void 0,
|
|
211
211
|
preloads: [
|
|
212
|
-
"/assets/usage-
|
|
212
|
+
"/assets/usage-3mYfS5C-.js",
|
|
213
213
|
"/assets/ManagePage-BzyMHGqs.js",
|
|
214
214
|
"/assets/Segmented-iylzLwE6.js",
|
|
215
215
|
"/assets/bot-BHky7KAX.js",
|
|
@@ -221,11 +221,11 @@ var tsrStartManifest = () => ({ routes: {
|
|
|
221
221
|
filePath: "/home/runner/work/bazilion/bazilion/apps/web/src/routes/templates/agents/index.tsx",
|
|
222
222
|
children: void 0,
|
|
223
223
|
preloads: [
|
|
224
|
-
"/assets/agents-
|
|
225
|
-
"/assets/ConfirmDialog-
|
|
224
|
+
"/assets/agents-BAODfMcm.js",
|
|
225
|
+
"/assets/ConfirmDialog-DrN26lN_.js",
|
|
226
226
|
"/assets/ManagePage-BzyMHGqs.js",
|
|
227
|
-
"/assets/AgentTemplateParts-
|
|
228
|
-
"/assets/manage-
|
|
227
|
+
"/assets/AgentTemplateParts-BWorU6-F.js",
|
|
228
|
+
"/assets/manage-DdCiSgG9.js",
|
|
229
229
|
"/assets/file-text-D6OTHixJ.js"
|
|
230
230
|
]
|
|
231
231
|
},
|
|
@@ -233,11 +233,11 @@ var tsrStartManifest = () => ({ routes: {
|
|
|
233
233
|
filePath: "/home/runner/work/bazilion/bazilion/apps/web/src/routes/templates/teams/index.tsx",
|
|
234
234
|
children: void 0,
|
|
235
235
|
preloads: [
|
|
236
|
-
"/assets/teams-
|
|
237
|
-
"/assets/ConfirmDialog-
|
|
236
|
+
"/assets/teams-D4X9oNx8.js",
|
|
237
|
+
"/assets/ConfirmDialog-DrN26lN_.js",
|
|
238
238
|
"/assets/ManagePage-BzyMHGqs.js",
|
|
239
|
-
"/assets/SpawnTeamModal-
|
|
240
|
-
"/assets/manage-
|
|
239
|
+
"/assets/SpawnTeamModal-B65eQyzu.js",
|
|
240
|
+
"/assets/manage-DdCiSgG9.js",
|
|
241
241
|
"/assets/network-BqmVqC4_.js"
|
|
242
242
|
]
|
|
243
243
|
},
|
|
@@ -245,12 +245,12 @@ var tsrStartManifest = () => ({ routes: {
|
|
|
245
245
|
filePath: "/home/runner/work/bazilion/bazilion/apps/web/src/routes/templates/agents/$id/index.tsx",
|
|
246
246
|
children: void 0,
|
|
247
247
|
preloads: [
|
|
248
|
-
"/assets/_id-
|
|
249
|
-
"/assets/ConfirmDialog-
|
|
248
|
+
"/assets/_id-DKgyyyeX.js",
|
|
249
|
+
"/assets/ConfirmDialog-DrN26lN_.js",
|
|
250
250
|
"/assets/ManagePage-BzyMHGqs.js",
|
|
251
|
-
"/assets/UnsavedChangesGuard-
|
|
252
|
-
"/assets/AgentTemplateParts-
|
|
253
|
-
"/assets/manage-
|
|
251
|
+
"/assets/UnsavedChangesGuard-CYz0AopL.js",
|
|
252
|
+
"/assets/AgentTemplateParts-BWorU6-F.js",
|
|
253
|
+
"/assets/manage-DdCiSgG9.js"
|
|
254
254
|
]
|
|
255
255
|
},
|
|
256
256
|
"/templates/teams/$id/": {
|
|
@@ -258,14 +258,14 @@ var tsrStartManifest = () => ({ routes: {
|
|
|
258
258
|
children: void 0,
|
|
259
259
|
css: ["/assets/style-DLioOiRN.css"],
|
|
260
260
|
preloads: [
|
|
261
|
-
"/assets/_id-
|
|
262
|
-
"/assets/ConfirmDialog-
|
|
261
|
+
"/assets/_id-5mTcKU2j.js",
|
|
262
|
+
"/assets/ConfirmDialog-DrN26lN_.js",
|
|
263
263
|
"/assets/ManagePage-BzyMHGqs.js",
|
|
264
264
|
"/assets/Segmented-iylzLwE6.js",
|
|
265
|
-
"/assets/SpawnTeamModal-
|
|
266
|
-
"/assets/UnsavedChangesGuard-
|
|
267
|
-
"/assets/style-
|
|
268
|
-
"/assets/manage-
|
|
265
|
+
"/assets/SpawnTeamModal-B65eQyzu.js",
|
|
266
|
+
"/assets/UnsavedChangesGuard-CYz0AopL.js",
|
|
267
|
+
"/assets/style-J8ypSsCb.js",
|
|
268
|
+
"/assets/manage-DdCiSgG9.js",
|
|
269
269
|
"/assets/bot-BHky7KAX.js",
|
|
270
270
|
"/assets/plus-CEKaHPBw.js"
|
|
271
271
|
]
|
|
@@ -33,10 +33,67 @@ import { HeadContent, Link, Outlet, Scripts, createFileRoute, createRootRoute, c
|
|
|
33
33
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
34
34
|
import { Bell, BellOff, BellRing, Check, Keyboard, LayoutGrid, LogOut, MessageSquarePlus, Monitor, Moon, Search, Settings2, Sun, UserPlus, UserRound } from "lucide-react";
|
|
35
35
|
import { Dialog, DropdownMenu } from "radix-ui";
|
|
36
|
+
//#region src/lib/stale-build.ts
|
|
37
|
+
var KEY$1 = "bz_stale_build_reload_at";
|
|
38
|
+
var ONCE_WITHIN_MS = 6e4;
|
|
39
|
+
/** The browser could not load a part of the page's own build (a script or its styles). */
|
|
40
|
+
function isStaleBuildError(error) {
|
|
41
|
+
const message = error instanceof Error ? error.message : String(error ?? "");
|
|
42
|
+
return /Failed to fetch dynamically imported module|Importing a module script failed|error loading dynamically imported module|Unable to preload CSS/i.test(message);
|
|
43
|
+
}
|
|
44
|
+
/** Reload to get the new build, unless that was just tried; true when the page reloads. */
|
|
45
|
+
function reloadForNewBuild(now = Date.now()) {
|
|
46
|
+
try {
|
|
47
|
+
if (now - Number(window.sessionStorage.getItem(KEY$1) ?? 0) < ONCE_WITHIN_MS) return false;
|
|
48
|
+
window.sessionStorage.setItem(KEY$1, String(now));
|
|
49
|
+
} catch {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
window.location.reload();
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
/** Reloads the page when Vite reports a part of the old build missing. */
|
|
56
|
+
function StaleBuildReloader() {
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
const onPreloadError = () => {
|
|
59
|
+
reloadForNewBuild();
|
|
60
|
+
};
|
|
61
|
+
window.addEventListener("vite:preloadError", onPreloadError);
|
|
62
|
+
return () => window.removeEventListener("vite:preloadError", onPreloadError);
|
|
63
|
+
}, []);
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
//#endregion
|
|
36
67
|
//#region src/components/RouteStates.tsx
|
|
37
68
|
/** The router's error view for every route: a loader failed. The top nav stays usable. */
|
|
38
69
|
function RouteErrorState({ error }) {
|
|
39
70
|
const router = useRouter();
|
|
71
|
+
const stale = isStaleBuildError(error);
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
if (stale) reloadForNewBuild();
|
|
74
|
+
}, [stale]);
|
|
75
|
+
if (stale) return /* @__PURE__ */ jsx(PageShell, { children: /* @__PURE__ */ jsxs("section", {
|
|
76
|
+
role: "alert",
|
|
77
|
+
className: "mx-auto my-10 w-full max-w-2xl rounded-md border border-border bg-snow p-6",
|
|
78
|
+
children: [
|
|
79
|
+
/* @__PURE__ */ jsx("h1", {
|
|
80
|
+
className: "text-2xl",
|
|
81
|
+
children: "Bazilion was updated"
|
|
82
|
+
}),
|
|
83
|
+
/* @__PURE__ */ jsx("p", {
|
|
84
|
+
className: "mt-3 text-sm text-mocha",
|
|
85
|
+
children: "This page was opened before the update, and the part it asked for belongs to the version before. Reload the page to use the new one."
|
|
86
|
+
}),
|
|
87
|
+
/* @__PURE__ */ jsx("div", {
|
|
88
|
+
className: "mt-4 flex flex-wrap gap-2",
|
|
89
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
90
|
+
variant: "primary",
|
|
91
|
+
onClick: () => window.location.reload(),
|
|
92
|
+
children: "Reload"
|
|
93
|
+
})
|
|
94
|
+
})
|
|
95
|
+
]
|
|
96
|
+
}) });
|
|
40
97
|
return /* @__PURE__ */ jsx(PageShell, { children: /* @__PURE__ */ jsxs("section", {
|
|
41
98
|
role: "alert",
|
|
42
99
|
className: "mx-auto my-10 w-full max-w-2xl rounded-md border border-rose-baziu bg-snow p-6",
|
|
@@ -720,7 +777,7 @@ function TopBar() {
|
|
|
720
777
|
const onKey = (event) => {
|
|
721
778
|
if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "k") {
|
|
722
779
|
event.preventDefault();
|
|
723
|
-
if (!Array.from(document.querySelectorAll("[role=\"dialog\"], [role=\"alertdialog\"]")).some((dialog) => !dialog.hasAttribute("data-jump-palette"))) setPaletteOpen((open) => !open);
|
|
780
|
+
if (!Array.from(document.querySelectorAll("[role=\"dialog\"]:not([data-state=\"closed\"]), [role=\"alertdialog\"]:not([data-state=\"closed\"])")).some((dialog) => !dialog.hasAttribute("data-jump-palette"))) setPaletteOpen((open) => !open);
|
|
724
781
|
} else if (!event.defaultPrevented && event.key === "?" && !event.metaKey && !event.ctrlKey && !event.altKey && !isTyping(event.target) && !document.querySelector("[role=\"dialog\"]")) {
|
|
725
782
|
event.preventDefault();
|
|
726
783
|
setShortcutsOpen(true);
|
|
@@ -1055,6 +1112,7 @@ function RootComponent() {
|
|
|
1055
1112
|
children: [
|
|
1056
1113
|
/* @__PURE__ */ jsx(DesktopNotifier, {}),
|
|
1057
1114
|
/* @__PURE__ */ jsx(RosterWatcher, {}),
|
|
1115
|
+
/* @__PURE__ */ jsx(StaleBuildReloader, {}),
|
|
1058
1116
|
/* @__PURE__ */ jsx(PageTitleProvider, { children: isLogin ? /* @__PURE__ */ jsx(Outlet, {}) : isWorkspace ? /* @__PURE__ */ jsxs("div", {
|
|
1059
1117
|
className: "flex h-dvh flex-col",
|
|
1060
1118
|
children: [/* @__PURE__ */ jsx("div", {
|
|
@@ -3558,7 +3558,7 @@ var defaultSerovalPlugins = [
|
|
|
3558
3558
|
* the dev styles URL for route-scoped CSS collection.
|
|
3559
3559
|
*/
|
|
3560
3560
|
async function getStartManifest(matchedRoutes) {
|
|
3561
|
-
const { tsrStartManifest } = await import("./assets/_tanstack-start-manifest_v-
|
|
3561
|
+
const { tsrStartManifest } = await import("./assets/_tanstack-start-manifest_v-DIMayzEa.js");
|
|
3562
3562
|
const startManifest = tsrStartManifest();
|
|
3563
3563
|
let routes = startManifest.routes;
|
|
3564
3564
|
routes[rootRouteId];
|
|
@@ -5524,7 +5524,7 @@ var getBaseManifest = getProdBaseManifest;
|
|
|
5524
5524
|
var createEarlyHintsForRequest = createEarlyHintsCollector;
|
|
5525
5525
|
async function loadEntries() {
|
|
5526
5526
|
const [routerEntry, startEntry, pluginAdapters] = await Promise.all([
|
|
5527
|
-
import("./assets/router-
|
|
5527
|
+
import("./assets/router-DizFxqh-.js"),
|
|
5528
5528
|
import("./assets/start-2MvkBRdC.js"),
|
|
5529
5529
|
import("./assets/empty-plugin-adapters-Cq4--YW-.js")
|
|
5530
5530
|
]);
|