@cuongtran001/kanna 1.76.2 → 1.76.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/{BoardsPage-BvYUo0PD.js → BoardsPage-DCh9hj51.js} +1 -1
- package/dist/client/assets/{BoardsRoutePage-D5hLNJ2q.js → BoardsRoutePage-DPw5ve6w.js} +1 -1
- package/dist/client/assets/ChatPage-CEeRSI6r.js +93 -0
- package/dist/client/assets/{CronJobRow-VCv0jyI2.js → CronJobRow-D2ex-2ZV.js} +1 -1
- package/dist/client/assets/{CronJobsPage-8FE4cO2q.js → CronJobsPage-BGk_HGOZ.js} +1 -1
- package/dist/client/assets/{FilePreviewSheet-B5b8L-4e.js → FilePreviewSheet-BnQeVNHq.js} +2 -2
- package/dist/client/assets/{FlowSurface-DmNZQO7Z.js → FlowSurface-RRPSX4vy.js} +1 -1
- package/dist/client/assets/{GenUIBlock-DX1nLbtf.js → GenUIBlock-DKGMRQmN.js} +2 -2
- package/dist/client/assets/{KannaSocketProvider-CiuKyRYE.js → KannaSocketProvider-CNmZYIUz.js} +1 -1
- package/dist/client/assets/{LocalProjectsPage-DjCZmQ8c.js → LocalProjectsPage-Dr5JrPMN.js} +1 -1
- package/dist/client/assets/SettingsPage-Bhy_51Vm.js +13 -0
- package/dist/client/assets/{StackBoardsRoutePage-i7WMqsk0.js → StackBoardsRoutePage-B-O5uIvz.js} +1 -1
- package/dist/client/assets/{ToolCallMessage-BhxowUjs.js → ToolCallMessage-C8Z9pIBo.js} +1 -1
- package/dist/client/assets/{VChartSurface-DQ6HIQXe.js → VChartSurface-C_LuezMZ.js} +1 -1
- package/dist/client/assets/{WorkflowsPage-BCIsFa6f.js → WorkflowsPage-BmGlYGWF.js} +1 -1
- package/dist/client/assets/{WorkflowsSection-B5TkVqRA.js → WorkflowsSection-SjENofEr.js} +1 -1
- package/dist/client/assets/{chart-renderer-DQLdORyQ.js → chart-renderer-Ce4S2Bew.js} +1 -1
- package/dist/client/assets/{chatSounds-CUN4vZG0.js → chatSounds-ih86yh5r.js} +1 -1
- package/dist/client/assets/chevron-left-DZQr0sRY.js +1 -0
- package/dist/client/assets/{clipboard.adapter-BvW6oQa_.js → clipboard.adapter-BLu7Xx3Q.js} +1 -1
- package/dist/client/assets/{columnStyle-C0IvZxLY.js → columnStyle-CXivQEvf.js} +1 -1
- package/dist/client/assets/{contextWindow-WJUHfP_d.js → contextWindow-Cpz1HmWo.js} +1 -1
- package/dist/client/assets/copyFeedbackStore-NslkB2Ap.js +1 -0
- package/dist/client/assets/{createScopedStore-DW4wfjbM.js → createScopedStore-CZBfIcri.js} +1 -1
- package/dist/client/assets/{dist-Q8elClTa.js → dist-DHxwilnY.js} +1 -1
- package/dist/client/assets/{ellipsis-D_1qLZbX.js → ellipsis-Ba-nFhTR.js} +1 -1
- package/dist/client/assets/{flow-kinds-Df0GmP61.js → flow-kinds-BIh-hHN9.js} +1 -1
- package/dist/client/assets/{folder-UHukK2MD.js → folder-B34crHxE.js} +1 -1
- package/dist/client/assets/{formatDuration-BA1K5CFs.js → formatDuration-JKx5LBF4.js} +1 -1
- package/dist/client/assets/{genui-CZI72r1O.js → genui-DmCmYDHH.js} +1 -1
- package/dist/client/assets/{globe-CQI7GjsK.js → globe-DV73QVTP.js} +1 -1
- package/dist/client/assets/{host-C0p_56Re.js → host-FY7xgVKG.js} +1 -1
- package/dist/client/assets/index-BYus2o1t.css +1 -0
- package/dist/client/assets/{index-3lHvRekg.js → index-MU4WHdaY.js} +3 -3
- package/dist/client/assets/{info-BXzVPePc.js → info-COBF8Hkz.js} +1 -1
- package/dist/client/assets/{input-BerPPEIs.js → input-BJRDZBOh.js} +1 -1
- package/dist/client/assets/{lexicalToReact-DdXqoi0d.js → lexicalToReact-BVHTqlu5.js} +3 -3
- package/dist/client/assets/{log-7fGlFSON.js → log-7NXJbErN.js} +1 -1
- package/dist/client/assets/{monitor-BOFtyQiW.js → monitor-Wl8GxNgR.js} +1 -1
- package/dist/client/assets/{pendingActionsStore-idc6m2Ya.js → pendingActionsStore-DDpYeRNm.js} +1 -1
- package/dist/client/assets/{play-DltDjX9H.js → play-CmxvHVzO.js} +1 -1
- package/dist/client/assets/{plus-CwWMJ0a-.js → plus-C3QbbvBk.js} +1 -1
- package/dist/client/assets/{popover-gn1uvc-1.js → popover-Dm-pdC4M.js} +1 -1
- package/dist/client/assets/{pushClient-NeXrldi-.js → pushClient-COMO42mb.js} +1 -1
- package/dist/client/assets/runDetached-mjGecpjX.js +1 -0
- package/dist/client/assets/{segmented-control-3UDSwswP.js → segmented-control-CfauwRtX.js} +1 -1
- package/dist/client/assets/{select-Df67vheJ.js → select-7zTZH1xA.js} +1 -1
- package/dist/client/assets/{settings-header-button-CKZHCdXh.js → settings-header-button-TMNvLQQs.js} +1 -1
- package/dist/client/assets/{sidebarPendingActions-B8iNQJfE.js → sidebarPendingActions-Bd_2oNH_.js} +1 -1
- package/dist/client/assets/{square-pen-DJjPW4f4.js → square-pen-BB5GlYSZ.js} +1 -1
- package/dist/client/assets/{state-mark-CU2hw5D9.js → state-mark-x5ennY81.js} +1 -1
- package/dist/client/assets/{terminal-8Bxl5uZh.js → terminal-D5pfyUjC.js} +1 -1
- package/dist/client/assets/{timer.adapter-BD7zwXEm.js → timer.adapter-C5oNrWbM.js} +1 -1
- package/dist/client/assets/{tools-Lo2VrFmM.js → tools-BlXGwwwh.js} +1 -1
- package/dist/client/assets/{triangle-alert-CQwDyl4K.js → triangle-alert-BwAIBaGG.js} +1 -1
- package/dist/client/assets/{useAppGlobalState-uP5C1BG8.js → useAppGlobalState-BL9aCLak.js} +1 -1
- package/dist/client/assets/{useKannaState-B2eDC-Dw.js → useKannaState-DTILzHBb.js} +1 -1
- package/dist/client/assets/{useTheme-B_JDh31l.js → useTheme-9knhPtrR.js} +1 -1
- package/dist/client/index.html +34 -34
- package/package.json +1 -1
- package/src/server/agent-coordinator-types.ts +1 -0
- package/src/server/agent-coordinator.ts +4 -0
- package/src/server/beacon-mention-prompt.test.ts +33 -0
- package/src/server/beacon-mention-prompt.ts +33 -0
- package/src/server/beacon-registry.test.ts +1 -0
- package/src/server/beacon-registry.ts +9 -1
- package/src/server/beacon-services.test.ts +11 -1
- package/src/server/beacon-services.ts +4 -0
- package/src/server/beacon-settings.test.ts +74 -1
- package/src/server/beacon-settings.ts +54 -3
- package/src/server/claude-turn-starter-types.ts +3 -0
- package/src/server/claude-turn-starter.test.ts +85 -0
- package/src/server/claude-turn-starter.ts +5 -1
- package/src/server/kanna-mcp-beacon-transfer.test.ts +1 -0
- package/src/server/kanna-mcp-beacon.test.ts +4 -1
- package/src/server/kanna-mcp-beacon.ts +16 -5
- package/src/server/push/push-manager.test.ts +39 -0
- package/src/server/push/push-manager.ts +45 -1
- package/src/server/server.ts +1 -0
- package/src/server/ws-router-broadcast.ts +1 -1
- package/src/server/ws-router-envelope.ts +2 -0
- package/src/server/ws-router-settings.test.ts +1 -0
- package/src/server/ws-router.test.ts +68 -0
- package/src/shared/beacon-alias.test.ts +64 -0
- package/src/shared/beacon-alias.ts +120 -0
- package/src/shared/beacon-config.ts +2 -0
- package/src/shared/beacon-status.test.ts +2 -0
- package/src/shared/beacon-status.ts +2 -0
- package/src/shared/chat-activity.ts +8 -0
- package/dist/client/assets/ChatPage-zfy8nznW.js +0 -93
- package/dist/client/assets/SettingsPage-ELjbPQEw.js +0 -13
- package/dist/client/assets/chevron-left-DpI8tMxJ.js +0 -1
- package/dist/client/assets/copyFeedbackStore-BsjXKW0-.js +0 -1
- package/dist/client/assets/index-D8o_YX_z.css +0 -1
- package/dist/client/assets/runDetached-BWsF_7Xo.js +0 -1
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{t}from"./react-DiVRNtpo.js";import{l as n,u as r}from"./chunk-OB3PAWPO-CCBUsQEH.js";import{t as i}from"./jsx-runtime-BdxMnOeJ.js";import{At as a,B as o,C as s,Ct as c,Dt as l,Et as u,F as d,Ft as f,H as p,I as m,It as h,J as g,K as _,Kt as v,M as y,Mt as b,N as x,Nt as ee,Ot as S,P as te,Pt as C,Tt as ne,W as w,_n as re,_t as ie,at as ae,bt as oe,ct as se,dt as ce,et as T,fn as le,ft as ue,gn as E,gt as de,hn as fe,ht as D,j as pe,jt as me,kt as he,lt as O,n as ge,nt as _e,o as ve,ot as ye,pn as be,pt as xe,q as Se,rt as Ce,st as we,ut as Te,vt as Ee,wt as De,yt as Oe}from"./useAppGlobalState-uP5C1BG8.js";import{a as ke,c as k,d as Ae,f as je,p as Me,s as Ne}from"./log-7fGlFSON.js";import{a as A,c as j,d as M,f as N,n as P,o as Pe,r as F,s as I,t as L}from"./pendingActionsStore-idc6m2Ya.js";import{_ as Fe,a as Ie,d as Le,f as Re,g as ze,i as Be,m as Ve,n as He,p as R,t as Ue,u as We}from"./copyFeedbackStore-BsjXKW0-.js";import{Bt as Ge,Vt as Ke,t as qe,zt as Je}from"./lexicalToReact-DdXqoi0d.js";import{n as Ye,r as Xe,t as Ze}from"./clipboard.adapter-BvW6oQa_.js";import{a as Qe,i as z,n as $e,o as et,r as tt,t as nt}from"./select-Df67vheJ.js";import{a as rt,c as it,g as at,h as ot,i as st,m as ct,n as lt,o as ut,p as dt,t as ft,u as pt}from"./pushClient-NeXrldi-.js";import{t as mt}from"./info-BXzVPePc.js";import{t as ht}from"./monitor-BOFtyQiW.js";import{i as gt,n as _t,t as vt}from"./formatDuration-BA1K5CFs.js";import{t as B}from"./plus-CwWMJ0a-.js";import{g as yt,i as bt,n as xt,o as St,r as Ct,t as wt,u as Tt}from"./timer.adapter-BD7zwXEm.js";import{a as Et,c as Dt,o as Ot,s as kt,t as At}from"./segmented-control-3UDSwswP.js";import{t as V}from"./input-BerPPEIs.js";import{C as jt,E as Mt,S as Nt,T as H,_ as Pt,b as Ft,d as It,f as Lt,g as Rt,h as zt,m as Bt,p as Vt,r as Ht,v as Ut,w as Wt,x as Gt,y as Kt}from"./useTheme-B_JDh31l.js";import{t as qt}from"./runDetached-BWsF_7Xo.js";import{t as Jt}from"./chatSounds-CUN4vZG0.js";import{c as Yt,l as Xt,o as Zt,r as Qt}from"./contextWindow-WJUHfP_d.js";import{n as $t}from"./state-mark-CU2hw5D9.js";import{n as U,r as en,t as tn}from"./popover-gn1uvc-1.js";import{t as nn}from"./settings-header-button-CKZHCdXh.js";var rn={name:`book-text`,size:24,node:[[`path`,{d:`M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20`,key:`k3hazp`}],[`path`,{d:`M8 11h8`,key:`vwpz6n`}],[`path`,{d:`M8 7h6`,key:`1f0q6e`}]]};rn.node;var an=N(rn),on={name:`circle-arrow-up`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 12-4-4-4 4`,key:`177agl`}],[`path`,{d:`M12 16V8`,key:`1sbj14`}]],aliases:[`arrow-up-circle`]};on.node;var sn=N(on),cn={name:`cloud-download`,size:24,node:[[`path`,{d:`M12 13v8l-4-4`,key:`1f5nwf`}],[`path`,{d:`m12 21 4-4`,key:`1lfcce`}],[`path`,{d:`M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284`,key:`ui1hmy`}]],aliases:[`download-cloud`]};cn.node;var ln=N(cn),un={name:`command`,size:24,node:[[`path`,{d:`M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3`,key:`11bfej`}]]};un.node;var dn=N(un),fn={name:`cpu`,size:24,node:[[`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`}]]};fn.node;var pn=N(fn),W={name:`flask-conical`,size:24,node:[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]};W.node;var mn=N(W),hn={name:`log-out`,size:24,node:[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]};hn.node;var gn=N(hn),_n={name:`message-square-quote`,size:24,node:[[`path`,{d:`M14 14a2 2 0 0 0 2-2V8h-2`,key:`1r06pg`}],[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M8 14a2 2 0 0 0 2-2V8H8`,key:`1jzu5j`}]]};_n.node;var vn=N(_n),yn={name:`moon`,size:24,node:[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]};yn.node;var bn=N(yn),xn={name:`network`,size:24,node:[[`rect`,{x:`16`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`4q2zg0`}],[`rect`,{x:`2`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`8cvhb9`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`6`,rx:`1`,key:`1egb70`}],[`path`,{d:`M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3`,key:`1jsf9p`}],[`path`,{d:`M12 12V8`,key:`2874zd`}]]};xn.node;var Sn=N(xn),Cn={name:`plug`,size:24,node:[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]};Cn.node;var G=N(Cn),K={name:`power-off`,size:24,node:[[`path`,{d:`M18.36 6.64A9 9 0 0 1 20.77 15`,key:`dxknvb`}],[`path`,{d:`M6.16 6.16a9 9 0 1 0 12.68 12.68`,key:`1x7qb5`}],[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};K.node;var wn=N(K),Tn={name:`power`,size:24,node:[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]};Tn.node;var En=N(Tn),Dn={name:`radio`,size:24,node:[[`path`,{d:`M16.247 7.761a6 6 0 0 1 0 8.478`,key:`1fwjs5`}],[`path`,{d:`M19.075 4.933a10 10 0 0 1 0 14.134`,key:`ehdyv1`}],[`path`,{d:`M4.925 19.067a10 10 0 0 1 0-14.134`,key:`1q22gi`}],[`path`,{d:`M7.753 16.239a6 6 0 0 1 0-8.478`,key:`r2q7qm`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]};Dn.node;var On=N(Dn),kn={name:`sun`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]};kn.node;var An=N(kn),jn={name:`type`,size:24,node:[[`path`,{d:`M12 4v16`,key:`1654pz`}],[`path`,{d:`M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2`,key:`e0r10z`}],[`path`,{d:`M9 20h6`,key:`s66wpe`}]]};jn.node;var Mn=N(jn),Nn={enabled:!1,cloudflaredPath:`cloudflared`,mode:`always-ask`},q=e(t(),1),J=e(i(),1);function Pn(e){let t=e.trim();if(t.startsWith(`https://`))try{let e=new URL(t);if(e.protocol!==`https:`)return!1;let n=e.hostname.toLowerCase();return!(n===`localhost`||!n.includes(`.`)||n.startsWith(`.`)||n.endsWith(`.`))}catch{return!1}if(t.startsWith(`mailto:`)){let e=t.slice(7),n=/^[^\s@]+@([^\s@]+)$/.exec(e);if(!n)return!1;let r=n[1].toLowerCase();return!(r===`localhost`||!r.includes(`.`)||r.startsWith(`.`)||r.endsWith(`.`))}return!1}var Fn={maxFileSizeMb:2048},In=51200,Ln=`gpt-5.4-mini`;function Rn(e){return e===`previous-assistant-reply`||e===`full-transcript`}function zn(e){return e===`auto`||e===`manual`}var Bn=[`app_launch`,`project_opened`,`project_created`,`project_removed`,`project_deleted`,`chat_created`,`chat_deleted`,`message_sent`,`update_checked`,`update_installed`,`update_failed`,`analytics_enabled`,`analytics_disabled`],Vn=[`current_version`,`environment`,`latest_version`,`custom_port_enabled`,`no_open_enabled`,`password_enabled`,`strict_port_enabled`,`remote_enabled`,`host_enabled`,`share_quick_enabled`,`share_token_enabled`];function Hn(){return{name:``,provider:`claude`,model:D(`claude`).defaultModel,modelOptions:{...O},systemPrompt:``,contextScope:`previous-assistant-reply`,triggerMode:`auto`}}function Un(){return{draft:Hn(),error:null,pending:!1,confirmDelete:!1}}var Y=k()(e=>({editing:{kind:`list`},form:Un(),timeoutDraft:``,loopError:null,setEditing:t=>e({editing:t}),resetForm:t=>e({form:{draft:t,error:null,pending:!1,confirmDelete:!1}}),patchForm:t=>e(e=>({form:{...e.form,...t}})),patchFormDraft:t=>e(e=>({form:{...e.form,draft:{...e.form.draft,...t}}})),setTimeoutDraft:t=>e({timeoutDraft:t}),setLoopError:t=>e({loopError:t})}));function X(e){return(0,J.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,J.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:e.label}),e.children,e.hint?(0,J.jsx)(`span`,{className:j(`text-xs`,e.hintTone===`destructive`?`text-destructive`:`text-muted-foreground`),children:e.hint}):null]})}function Wn(e){let{draft:t,patchDraft:n}=e;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(X,{label:`Working directory`,hint:`Optional. Relative to the parent chat cwd. Restricts the subagent's filesystem access to this subtree.`,children:(0,J.jsx)(V,{"data-testid":`subagent-form-working-dir`,value:t.workingDir??``,onChange:e=>{let t=e.target.value;n({workingDir:t.length>0?t:void 0})},placeholder:`docs`})}),(0,J.jsx)(X,{label:`Allowed paths`,hint:`Optional. Newline-separated, relative to the parent chat cwd. When set, file tools can only read/write inside these roots.`,children:(0,J.jsx)(dt,{"data-testid":`subagent-form-allowed-paths`,value:(t.allowedPaths??[]).join(`
|
|
2
|
-
`),onChange:e=>{let t=e.target.value.split(/\r?\n/).map(e=>e.trim()).filter(e=>e.length>0);n({allowedPaths:t.length>0?t:void 0})},placeholder:`docs
|
|
3
|
-
wiki`,rows:3})}),(0,J.jsx)(X,{label:`Beacon tools`,hint:`Off by default. When on, this subagent can run commands and read files on your paired machines. Each call still asks for your approval.`,children:(0,J.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-foreground`,children:[(0,J.jsx)(`input`,{type:`checkbox`,"data-testid":`subagent-form-allow-beacon-tools`,checked:t.allowBeaconTools===!0,onChange:e=>{n({allowBeaconTools:e.target.checked})}}),(0,J.jsx)(`span`,{children:`Allow this subagent to use beacon tools (run on your paired machines)`})]})})]})}function Gn(e){return`contextWindow`in e}function Kn(e){return`fastMode`in e}function qn(e){let t=e.editing,n=(0,q.useMemo)(()=>t.kind===`edit`?e.subagents.find(e=>e.id===t.id)??null:null,[t,e.subagents]),r=t.kind,i=r!==`list`,a=e.subagents.length===0;return a&&!i?(0,J.jsx)(Jn,{onStartCreate:e.onStartCreate}):(0,J.jsxs)(`div`,{className:`flex flex-col gap-6 md:flex-row md:items-start md:gap-8`,children:[a?null:(0,J.jsx)(Xn,{subagents:e.subagents,editing:e.editing,onSelect:e.onSelect,onStartCreate:e.onStartCreate}),i?(0,J.jsx)(rr,{mode:r,subject:r===`edit`?n:null,providerDefaults:e.providerDefaults,availableProviders:e.availableProviders,handlers:e.handlers,onCancelEditing:e.onCancelEditing},r===`edit`?n?.id??`edit`:`create`):(0,J.jsx)(Yn,{})]})}function Jn(e){return(0,J.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-4 rounded-lg border border-dashed border-border px-6 py-14 text-center`,"data-testid":`subagent-empty`,children:[(0,J.jsx)(`div`,{className:`flex size-10 items-center justify-center rounded-full bg-muted text-muted-foreground`,children:(0,J.jsx)(Fe,{className:`size-5`,"aria-hidden":!0})}),(0,J.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`No subagents yet`}),(0,J.jsxs)(A,{variant:`default`,size:`sm`,onClick:e.onStartCreate,children:[(0,J.jsx)(B,{className:`mr-1.5 size-4`}),` Create subagent`]})]})}function Yn(){return(0,J.jsx)(`div`,{className:`hidden flex-1 items-center justify-center rounded-lg border border-dashed border-border px-6 py-12 text-center text-sm text-muted-foreground md:flex`,children:`Select a subagent to edit, or create a new one.`})}function Xn(e){let t=e.editing.kind===`edit`?e.editing.id:null;return(0,J.jsxs)(`aside`,{className:`flex w-full flex-col gap-2 md:w-64 md:flex-shrink-0`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,J.jsxs)(`span`,{className:`text-xs font-medium tracking-wide text-muted-foreground`,style:{fontVariantNumeric:`tabular-nums`},children:[e.subagents.length,` `,e.subagents.length===1?`agent`:`agents`]}),(0,J.jsxs)(A,{variant:`ghost`,size:`sm`,onClick:e.onStartCreate,"data-testid":`subagent-create`,children:[(0,J.jsx)(B,{className:`size-4`}),(0,J.jsx)(`span`,{className:`sr-only`,children:`Create subagent`})]})]}),(0,J.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:e.subagents.map(n=>{let r=n.description?.trim()||(n.contextScope===`previous-assistant-reply`?`Last reply`:`Full transcript`);return(0,J.jsx)(`li`,{children:(0,J.jsxs)(`button`,{type:`button`,"data-testid":`subagent-row:${n.id}`,onClick:()=>e.onSelect(n.id),className:j(`flex w-full flex-col items-start gap-0.5 rounded-md px-2 py-1.5 text-left transition-colors hover:bg-muted`,t===n.id&&`bg-muted`),children:[(0,J.jsxs)(`span`,{className:`flex w-full items-center justify-between gap-2`,children:[(0,J.jsx)(`span`,{className:`truncate text-sm font-medium text-foreground`,children:n.name}),(0,J.jsx)(Zn,{provider:n.provider})]}),(0,J.jsx)(`span`,{className:`w-full truncate text-xs text-muted-foreground`,children:r})]})},n.id)})})]})}function Zn({provider:e}){let t=D(e).label;return(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded border border-border bg-card px-1.5 py-0.5 text-xs font-medium tracking-wide text-muted-foreground`,children:[(0,J.jsx)(Fe,{className:`size-3`}),` `,t]})}var Qn=[{value:`claude`,label:`Claude`},{value:`codex`,label:`Codex`},{value:`openrouter`,label:`OpenRouter`}],$n=[...Qn,{value:`custom`,label:`Custom endpoints`}];function er(e,t){return t.length===0?e:e.map(e=>e.id===`openrouter`?{...e,models:t.map(e=>({id:e.id,label:e.label}))}:e)}var tr=[{value:`previous-assistant-reply`,label:`Last reply`},{value:`full-transcript`,label:`Full transcript`}],nr=[{value:`auto`,label:`Auto`},{value:`manual`,label:`Manual`}];function rr(e){let t=(0,q.useMemo)(()=>e.mode===`edit`&&e.subject?mr(e.subject):pr(`claude`,e.providerDefaults,e.availableProviders),[e.mode,e.subject,e.providerDefaults,e.availableProviders]),n=Y(e=>e.resetForm),r=Y(e=>e.form),i=Y(e=>e.patchFormDraft),a=Y(e=>e.patchForm);(0,q.useEffect)(()=>{n(t)},[]);let{draft:o,error:s,pending:c,confirmDelete:l}=r,u=o.provider===`custom`||e.availableProviders.some(e=>e.id===`custom`)?$n:Qn,d=s?.field===`name`?s.message:null,f=s?.field===`general`?s.message:null,p=gr(o,t),m=o.name.trim().length>0&&(e.mode===`create`||p);function h(e){i(e),s?.field===`name`&&`name`in e&&a({error:null})}function g(t){if(t===o.provider)return;let n=pr(t,e.providerDefaults,e.availableProviders);i({provider:t,model:n.model,modelOptions:n.modelOptions})}function _(e){if(o.provider!==`claude`)return;let t=Gn(o.modelOptions)?o.modelOptions:O;i({modelOptions:{...O,...t,reasoningEffort:e}})}function v(e){if(o.provider!==`claude`)return;let t=Gn(o.modelOptions)?o.modelOptions:O;i({modelOptions:{...O,...t,contextWindow:e}})}function y(e){if(o.provider!==`codex`)return;let t=Kn(o.modelOptions)?o.modelOptions:Te;i({modelOptions:{...Te,...t,reasoningEffort:e}})}async function b(){if(m&&!c){a({pending:!0,error:null,confirmDelete:!1});try{let t=e.mode===`create`?await e.handlers.onCreate(o):await e.handlers.onUpdate(e.subject.id,o);t.ok||a({error:vr(t.error)})}catch(e){a({error:{field:`general`,message:je(e)}})}finally{a({pending:!1})}}}async function x(){if(e.mode===`edit`&&e.subject){if(!l){a({confirmDelete:!0});return}a({pending:!0,error:null});try{await e.handlers.onDelete(e.subject.id)}catch(e){a({error:{field:`general`,message:je(e)}})}finally{a({pending:!1,confirmDelete:!1})}}}let ee=o.provider===`claude`?{...O,...Gn(o.modelOptions)?o.modelOptions:{}}:null,S=o.provider===`codex`?{...Te,...Kn(o.modelOptions)?o.modelOptions:{}}:null,te=e.availableProviders.find(e=>e.id===o.provider)??D(o.provider);return(0,J.jsxs)(`section`,{className:`flex w-full flex-1 flex-col gap-4`,children:[(0,J.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`h3`,{className:`text-base font-medium text-foreground`,children:e.mode===`create`?`New subagent`:o.name||`Subagent`}),(0,J.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Mention with `,(0,J.jsxs)(`code`,{className:`rounded bg-muted px-1 py-0.5 font-mono text-xs`,children:[`@agent/`,o.name||`<name>`]}),` in chat.`]})]}),f?(0,J.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-sm text-destructive`,children:f}):null,(0,J.jsx)(X,{label:`Name`,hint:d,hintTone:d?`destructive`:`muted`,children:(0,J.jsx)(V,{"data-testid":`subagent-form-name`,value:o.name,onChange:e=>h({name:yr(e.target.value)}),maxLength:64,placeholder:`reviewer`,className:`font-mono`})}),(0,J.jsx)(X,{label:`Description`,hint:`Optional. Shown next to the name.`,children:(0,J.jsx)(V,{"data-testid":`subagent-form-description`,value:o.description??``,onChange:e=>h({description:e.target.value}),placeholder:`Reviews diffs against the repo style`})}),(0,J.jsx)(X,{label:`Provider`,children:(0,J.jsx)(At,{value:o.provider,onValueChange:e=>{ae(e)&&g(e)},options:u,size:`sm`})}),(0,J.jsx)(X,{label:`Model`,children:(0,J.jsxs)(nt,{value:o.model,onValueChange:e=>h({model:e}),children:[(0,J.jsx)(Qe,{"data-testid":`subagent-form-model`,className:`w-full md:w-72`,children:(0,J.jsx)(et,{placeholder:`Select a model`})}),(0,J.jsx)($e,{children:te.models.map(e=>(0,J.jsx)(z,{value:e.id,children:e.label},e.id))})]})}),ee?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(X,{label:`Reasoning effort`,children:(0,J.jsx)(At,{value:ee.reasoningEffort,onValueChange:e=>{ie(e)&&_(e)},options:we.map(e=>({value:e.id,label:e.label})),size:`sm`})}),(0,J.jsx)(X,{label:`Context window`,children:(0,J.jsx)(At,{value:ee.contextWindow,onValueChange:e=>{de(e)&&v(e)},options:ye.map(e=>({value:e.id,label:e.label})),size:`sm`})})]}):null,S?(0,J.jsx)(X,{label:`Reasoning effort`,children:(0,J.jsx)(At,{value:S.reasoningEffort,onValueChange:e=>{Ee(e)&&y(e)},options:se.map(e=>({value:e.id,label:e.label})),size:`sm`})}):null,(0,J.jsx)(X,{label:`Context scope`,children:(0,J.jsx)(At,{value:o.contextScope,onValueChange:e=>{Rn(e)&&h({contextScope:e})},options:tr,size:`sm`})}),(0,J.jsx)(X,{label:`Trigger`,hint:`Auto: the main agent may delegate on its own. Manual: only runs when you @-mention it.`,children:(0,J.jsx)(At,{value:o.triggerMode??`auto`,onValueChange:e=>{zn(e)&&h({triggerMode:e})},options:nr,size:`sm`})}),(0,J.jsx)(X,{label:`System prompt`,hint:`What this persona should focus on. Plain text.`,children:(0,J.jsx)(dt,{"data-testid":`subagent-form-system-prompt`,value:o.systemPrompt,onChange:e=>h({systemPrompt:e.target.value}),placeholder:`You are a careful code reviewer...`,rows:6,className:`min-h-32`})}),(0,J.jsx)(X,{label:`Max turns`,hint:`Optional. Caps the agentic turns per run (like Claude Code's per-agent maxTurns). Empty = unbounded. Claude SDK runs stop gracefully at the limit; Codex runs are aborted.`,children:(0,J.jsx)(V,{"data-testid":`subagent-form-max-turns`,type:`number`,min:1,step:1,value:o.maxTurns?.toString()??``,onChange:e=>{let t=Number.parseInt(e.target.value,10);h({maxTurns:Number.isInteger(t)&&t>0?t:void 0})},placeholder:`unbounded`,className:`w-36`})}),o.provider===`claude`?(0,J.jsx)(Wn,{draft:o,patchDraft:h}):null,(0,J.jsxs)(`footer`,{className:`flex flex-wrap items-center justify-end gap-2 pt-2`,children:[(0,J.jsx)(A,{variant:`ghost`,size:`sm`,onClick:e.onCancelEditing,children:`Cancel`}),e.mode===`edit`?(0,J.jsx)(A,{variant:`destructive`,size:`sm`,"data-testid":`subagent-form-delete`,disabled:c,pending:c&&l,onClick:()=>{P(L(`subagent.delete`,e.subject?.id??``),x)},children:l?`Confirm delete`:`Delete`}):null,(0,J.jsx)(A,{variant:`default`,size:`sm`,"data-testid":`subagent-form-save`,disabled:!m||c,pending:c&&!l,onClick:()=>{P(L(`subagent.save`,e.subject?.id??`new`),b)},children:c?`Saving…`:`Save`})]})]})}var ir=[],ar={claude:{model:D(`claude`).defaultModel,modelOptions:{...O},planMode:!1},codex:{model:D(`codex`).defaultModel,modelOptions:{...Te},planMode:!1},openrouter:{model:ce,modelOptions:{},planMode:!1},custom:{model:``,modelOptions:{},planMode:!1}};function or(e){let t=H(e=>e.settings?.subagents??ir),n=H(e=>e.settings?.providerDefaults??ar),r=H(zt),i=H(Rt),a=pe(Xt(e=>e.models)),o=(0,q.useMemo)(()=>er(d(oe([...ue],r),i),a),[r,i,a]),s=Y(e=>e.editing),c=Y(e=>e.setEditing),l=(0,q.useMemo)(()=>({onCreate:async t=>{let n=await e.state.socket.command({type:`subagent.create`,input:t});return n.ok&&c({kind:`edit`,id:n.subagent.id}),n},onUpdate:async(t,n)=>await e.state.socket.command({type:`subagent.update`,id:t,patch:{...n,maxTurns:n.maxTurns??null}}),onDelete:async t=>{await e.state.socket.command({type:`subagent.delete`,id:t}),c({kind:`list`})}}),[e.state.socket,c]),u=(0,q.useCallback)(e=>{c({kind:`edit`,id:e})},[c]),f=(0,q.useCallback)(()=>{c({kind:`create`})},[c]),p=(0,q.useCallback)(()=>{c({kind:`list`})},[c]);return(0,J.jsxs)(`div`,{className:`flex flex-col gap-6 px-6 py-6`,children:[(0,J.jsx)(dr,{subagents:t,handleWriteAppSettings:e.state.handleWriteAppSettings}),(0,J.jsx)(qn,{subagents:t,providerDefaults:n,availableProviders:o,editing:s,onSelect:u,onStartCreate:f,onCancelEditing:p,handlers:l})]})}var sr=`__none__`,cr=30,lr=86400,ur=600;function dr(e){let t=H(e=>e.settings?.subagentRuntime),n=t?Math.round(t.runTimeoutMs/1e3):ur,r=t?.defaultLoopSubagentId??null,i=Y(e=>e.timeoutDraft),a=Y(e=>e.setTimeoutDraft),o=Y(e=>e.loopError),s=Y(e=>e.setLoopError);(0,q.useEffect)(()=>{a(String(n))},[n]);function c(){let t=Number(i);if(!Number.isInteger(t)||t<cr||t>lr){a(String(n)),s(`Timeout must be a whole number of seconds between ${cr} and ${lr}.`);return}s(null),t!==n&&e.handleWriteAppSettings({subagentRuntime:{runTimeoutMs:t*1e3}}).catch(e=>s(e instanceof Error?e.message:`Unable to save subagent runtime settings.`))}function l(t){s(null);let n=t===sr?null:t;e.handleWriteAppSettings({subagentRuntime:{defaultLoopSubagentId:n}}).catch(e=>s(e instanceof Error?e.message:`Unable to save default loop subagent.`))}return(0,J.jsxs)(`section`,{className:`flex flex-col gap-4 rounded-lg border border-border/60 bg-card/40 p-4`,children:[(0,J.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`h3`,{className:`text-sm font-medium text-foreground`,children:`Loop & runtime`}),(0,J.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Applies to background subagent runs and the autonomous `,(0,J.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 font-mono`,children:`/loop`}),`.`]})]}),o?(0,J.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-xs text-destructive`,children:o}):null,(0,J.jsx)(X,{label:`Stall timeout (seconds)`,hint:`A subagent run is aborted only after this long with no streamed activity — not a total wall-clock cap. A steadily-working run is never killed.`,children:(0,J.jsx)(V,{type:`number`,inputMode:`numeric`,min:cr,max:lr,value:i,onChange:e=>a(e.target.value),onBlur:c,onKeyDown:e=>{e.key===`Enter`&&(c(),e.currentTarget.blur())},className:`w-full md:w-48 tabular-nums`})}),(0,J.jsx)(X,{label:`Default loop subagent`,hint:`The subagent setup_loop delegates each chunk to when no explicit id is given.`,children:(0,J.jsxs)(nt,{value:r??sr,onValueChange:l,children:[(0,J.jsx)(Qe,{className:`w-full md:w-72`,children:(0,J.jsx)(et,{placeholder:`None`})}),(0,J.jsxs)($e,{children:[(0,J.jsx)(z,{value:sr,children:`None (require explicit id)`}),e.subagents.map(e=>(0,J.jsx)(z,{value:e.id,children:e.name},e.id))]})]})})]})}var fr=new Set([`EMPTY_NAME`,`INVALID_CHAR`,`RESERVED_NAME`,`DUPLICATE_NAME`,`TOO_LONG`]);function pr(e,t,n){if(e===`claude`){let r=t?.claude;return{name:``,provider:e,model:r?.model??n?.find(e=>e.id===`claude`)?.defaultModel??D(`claude`).defaultModel,modelOptions:{...r?.modelOptions??{...O}},systemPrompt:``,contextScope:`previous-assistant-reply`,triggerMode:`auto`}}if(Oe(e))return{name:``,provider:e,model:t?.[e]?.model||n?.find(t=>t.id===e)?.defaultModel||D(e).defaultModel,modelOptions:{},systemPrompt:``,contextScope:`previous-assistant-reply`,triggerMode:`auto`};let r=t?.codex;return{name:``,provider:e,model:r?.model??n?.find(e=>e.id===`codex`)?.defaultModel??D(`codex`).defaultModel,modelOptions:{...r?.modelOptions??{...Te}},systemPrompt:``,contextScope:`previous-assistant-reply`,triggerMode:`auto`}}function mr(e){return{name:e.name,description:e.description,provider:e.provider,model:e.model,modelOptions:e.modelOptions,systemPrompt:e.systemPrompt,contextScope:e.contextScope,triggerMode:e.triggerMode,workingDir:e.workingDir,allowedPaths:e.allowedPaths,maxTurns:e.maxTurns,allowBeaconTools:e.allowBeaconTools}}var hr=(e,t)=>{if(e===t)return!0;if(!e||!t||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0};function gr(e,t){return e.name!==t.name||(e.description??``)!==(t.description??``)||e.provider!==t.provider||e.model!==t.model||e.systemPrompt!==t.systemPrompt||e.contextScope!==t.contextScope||(e.triggerMode??`auto`)!==(t.triggerMode??`auto`)||(e.workingDir??``)!==(t.workingDir??``)||!hr(e.allowedPaths,t.allowedPaths)||(e.maxTurns??null)!==(t.maxTurns??null)||(e.allowBeaconTools??!1)!==(t.allowBeaconTools??!1)||!_r(e.modelOptions,t.modelOptions)}function _r(e,t){if(!Me(e)||!Me(t))return!1;let n=new Set([...Object.keys(e),...Object.keys(t)]);for(let r of n)if(e[r]!==t[r])return!1;return!0}function vr(e){return fr.has(e.code)?{field:`name`,message:e.message}:{field:`general`,message:e.message}}function yr(e){return e.toLowerCase().replace(/[^a-z0-9_-]+/g,`-`).slice(0,64)}function Z({title:e,description:t,children:n,bordered:r=!0,alignStart:i=!1}){return(0,J.jsx)(`div`,{className:r?`border-t border-border`:void 0,children:(0,J.jsxs)(`div`,{className:j(`flex flex-col gap-4 py-5 md:flex-row md:justify-between md:gap-8`,i?`md:items-start`:`md:items-center`),children:[(0,J.jsxs)(`div`,{className:`min-w-0 max-w-xl`,children:[(0,J.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:e}),(0,J.jsx)(`div`,{className:`mt-1 text-13 text-muted-foreground`,children:t})]}),(0,J.jsx)(`div`,{className:`flex items-center justify-start md:shrink-0 md:justify-end`,children:n})]})})}function br({icon:e,message:t}){return(0,J.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-md border border-dashed px-6 py-10 text-center`,children:[(0,J.jsx)(e,{className:`mb-3 h-8 w-8 text-muted-foreground`,"aria-hidden":!0}),(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t})]})}function xr({children:e}){return(0,J.jsx)(`ul`,{className:`flex flex-col divide-y rounded-md border`,children:e})}function Sr({label:e,onEdit:t,onDelete:n,deletePending:r=!1}){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(A,{variant:`ghost`,size:`sm`,onClick:t,"aria-label":`Edit ${e}`,children:(0,J.jsx)(gt,{className:`h-4 w-4`})}),(0,J.jsx)(A,{variant:`ghost`,size:`sm`,onClick:n,pending:r,"aria-label":`Delete ${e}`,children:(0,J.jsx)(le,{className:`h-4 w-4`})})]})}var Cr=new Set;function wr(e){return{name:e?.name??``,transport:e?.transport??`stdio`,command:e?.transport===`stdio`?e.command:``,argsText:e?.transport===`stdio`?e.args.join(`
|
|
4
|
-
`):``,envText:e?.transport===`stdio`?Object.entries(e.env).map(([e,t])=>`${e}=${t}`).join(`
|
|
5
|
-
`):``,cwd:e?.transport===`stdio`?e.cwd??``:``,url:e!==null&&e.transport!==`stdio`?e.url:``,headersText:e!==null&&e.transport!==`stdio`?Object.entries(e.headers).map(([e,t])=>`${e}: ${t}`).join(`
|
|
6
|
-
`):``,error:null,submitting:!1,oauthEnabled:e!==null&&e.transport!==`stdio`?e.oauth?.enabled??!1:!1,authFlowUrl:null,callbackInput:``,oauthError:null,authenticating:!1,completing:!1}}var Tr=k()(e=>({editing:{kind:`list`},testingServerIds:Cr,editorForm:wr(null),setEditing:t=>e({editing:t}),setServerTesting:(t,n)=>e(e=>{let r=new Set(e.testingServerIds);return n?r.add(t):r.delete(t),{testingServerIds:r.size===0?Cr:r}}),resetEditorForm:t=>e({editorForm:wr(t)}),patchEditorForm:t=>e(e=>({editorForm:{...e.editorForm,...t}}))}));function Er(e,t){return(0,q.useMemo)(()=>({onCreate:async n=>{await t.handleWriteAppSettings(e({create:n}))},onUpdate:async(n,r)=>{await t.handleWriteAppSettings(e({update:{id:n,patch:r}}))},onDelete:async n=>{await t.handleWriteAppSettings(e({delete:{id:n}}))}}),[e,t])}async function Dr(e){e.patch({submitting:!0,error:null});try{await e.save(),e.onDone()}catch(t){e.patch({error:t instanceof Error?t.message:e.fallbackMessage})}finally{e.patch({submitting:!1})}}function Or(e){return e.submitting?`Saving…`:e.isEdit?`Save changes`:e.addLabel}function kr({server:e,handlers:t,onEdit:n,dom:r=Ae}){let i=Tr(t=>t.testingServerIds.has(e.id)),a=Tr(e=>e.setServerTesting),o=(0,q.useCallback)(async()=>{a(e.id,!0);try{await t.onTest(e.id)}finally{a(e.id,!1)}},[t,e.id,a]),s=L(`mcpServers.delete`,e.id),c=F(s),l=L(`mcpServers.setEnabled`,e.id),u=F(l),d=L(`settings.testMcpServer`,e.id),f=(0,q.useCallback)(()=>{r.confirmDialog(`Delete MCP server "${e.name}"?`)&&P(s,()=>t.onDelete(e.id))},[s,r,t,e.id,e.name]),p=(0,q.useCallback)(n=>{let r=n.target.checked;P(l,()=>t.onSetEnabled(e.id,r))},[t,e.id,l]),m=(0,q.useCallback)(()=>{P(d,o)},[o,d]);return(0,J.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-3`,"aria-busy":c||void 0,children:[(0,J.jsxs)(`div`,{className:`flex flex-col`,children:[(0,J.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,J.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[(0,J.jsx)(Ar,{transport:e.transport}),(0,J.jsx)(`span`,{className:`ml-2`,children:e.transport===`stdio`?e.command:e.url})]})]}),(0,J.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,J.jsx)(jr,{result:e.lastTest,pending:i}),e.transport!==`stdio`&&(0,J.jsx)(Mr,{oauth:e.oauth}),(0,J.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-1 text-xs text-muted-foreground`,children:[u?(0,J.jsx)(I,{}):null,(0,J.jsx)(`input`,{type:`checkbox`,checked:e.enabled,disabled:u,"aria-busy":u||void 0,onChange:p,"aria-label":`Enabled`}),(0,J.jsx)(`span`,{children:`On`})]}),(0,J.jsx)(A,{variant:`ghost`,size:`sm`,onClick:m,disabled:i,"aria-busy":i||void 0,title:`Test connection`,children:(0,J.jsx)(Ke,{className:j(`h-4 w-4`,i&&`animate-spin`)})}),(0,J.jsx)(Sr,{label:e.name,onEdit:n,onDelete:f,deletePending:c})]})]})}function Ar({transport:e}){return(0,J.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-xs`,children:e})}function jr({result:e,pending:t}){if(t||e.status===`pending`)return(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Testing…`});switch(e.status){case`ok`:return(0,J.jsxs)(`span`,{className:`text-xs text-green-600`,children:[`OK · `,e.toolCount,` tools`]});case`error`:return(0,J.jsx)(ct,{label:e.message,children:(0,J.jsx)(`span`,{className:`text-xs text-red-600`,children:`Failed`})});default:return(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Untested`})}}function Mr({oauth:e}){if(!e?.enabled)return null;switch(e.status){case`authenticated`:return(0,J.jsx)(`span`,{className:`text-xs text-green-600`,children:`OAuth ✓`});case`error`:return(0,J.jsx)(ct,{label:e.errorMessage,children:(0,J.jsx)(`span`,{className:`text-xs text-red-600`,children:`OAuth error`})});default:return(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`OAuth: unauth`})}}var Nr=new Set([`stdio`,`http`,`sse`,`ws`]);function Pr(e){return Nr.has(e)}var Fr=`new`;function Ir({pending:e,copied:t}){return e?(0,J.jsx)(I,{className:`size-3`}):t?(0,J.jsx)(Xe,{className:`h-3 w-3 text-success-text`}):(0,J.jsx)(Ye,{className:`h-3 w-3`})}var Lr=e=>({customMcpServers:e});function Rr(e){return e.editing.kind===`list`?e.servers.length===0?(0,J.jsxs)(`div`,{className:`flex flex-col items-center justify-center px-6 py-16 text-center`,children:[(0,J.jsx)(G,{className:`mb-4 h-10 w-10 text-muted-foreground`,"aria-hidden":!0}),(0,J.jsx)(`h2`,{className:`text-lg font-medium`,children:`No custom MCP servers`}),(0,J.jsx)(`p`,{className:`mt-2 max-w-md text-sm text-muted-foreground`,children:`Install MCP servers to extend the model's tool surface. Supports stdio, http, sse, and ws transports.`}),(0,J.jsxs)(A,{className:`mt-6`,onClick:e.onStartCreate,children:[(0,J.jsx)(B,{className:`mr-1 h-4 w-4`}),`Add server`]})]}):(0,J.jsxs)(`div`,{className:`flex flex-col gap-3 px-6 py-6`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsx)(`h2`,{className:`text-base font-medium`,children:`Custom MCP servers`}),(0,J.jsxs)(A,{size:`sm`,onClick:e.onStartCreate,children:[(0,J.jsx)(B,{className:`mr-1 h-4 w-4`}),`Add server`]})]}),(0,J.jsx)(xr,{children:e.servers.map(t=>(0,J.jsx)(kr,{server:t,handlers:e.handlers,onEdit:()=>e.onSelect(t.id)},t.id))})]}):(0,J.jsx)(zr,{initial:e.editing.kind===`edit`?e.servers.find(t=>e.editing.kind===`edit`&&t.id===e.editing.id)??null:null,existingNames:e.servers.map(e=>({id:e.id,name:e.name})),onCancel:e.onCancelEditing,handlers:e.handlers})}function zr({initial:e,existingNames:t,onCancel:n,handlers:r,clipboard:i=Ze}){let a=Tr(e=>e.editorForm),o=Tr(e=>e.resetEditorForm),s=Tr(e=>e.patchEditorForm),c=(0,q.useCallback)(e=>{Pr(e)&&s({transport:e})},[s]),{name:l,transport:u,command:d,argsText:f,envText:p,cwd:m,url:h,headersText:g,error:_,submitting:v,oauthEnabled:y,authFlowUrl:b,callbackInput:x,oauthError:ee,authenticating:S,completing:te}=a,C=(0,q.useRef)(e);(0,q.useEffect)(()=>{o(C.current)},[o]);let ne=e!==null&&e.transport!==`stdio`?e.oauth:void 0,w=e?.id??Fr,re=L(`mcpServers.toggleOAuth`,w),ie=F(re),ae=L(`mcpServers.copyAuthUrl`,w),oe=F(ae),se=He(ae),ce=(0,q.useCallback)(async t=>{s(t?{oauthEnabled:!0}:{oauthEnabled:!1,authFlowUrl:null,callbackInput:``,oauthError:null}),e&&await r.onUpdate(e.id,{oauth:{...ne??{status:`unauthenticated`},enabled:t}})},[e,ne,r,s]),T=(0,q.useCallback)(async()=>{if(e){s({authenticating:!0,oauthError:null});try{let t=await r.onStartMcpOAuth(e.id);t.ok&&t.authorizationUrl?s({authFlowUrl:t.authorizationUrl}):t.ok&&t.alreadyAuthenticated?s({authFlowUrl:null}):s({oauthError:t.error??`Failed to start OAuth flow`})}finally{s({authenticating:!1})}}},[e,r,s]),le=(0,q.useCallback)(async()=>{if(e){s({completing:!0,oauthError:null});try{let t=await r.onCompleteMcpOAuth(e.id,x);t.ok?s({authFlowUrl:null,callbackInput:``}):s({oauthError:t.error??`Failed to complete OAuth flow`})}finally{s({completing:!1})}}},[e,x,r,s]),ue=(0,q.useCallback)(e=>{let t=e.target.checked;P(re,()=>ce(t))},[ce,re]),E=(0,q.useCallback)(()=>{P(L(`settings.startMcpOAuth`,w),T)},[w,T]),de=(0,q.useCallback)(()=>{P(L(`settings.completeMcpOAuth`,w),le)},[le,w]),fe=(0,q.useCallback)(()=>{b&&P(ae,()=>Ue(ae,()=>i.writeText(b)))},[b,i,ae]),D=(0,q.useMemo)(()=>l.length===0?null:/^[a-zA-Z][a-zA-Z0-9_-]{0,31}$/.test(l)?l===`kanna`?`'kanna' is reserved.`:t.find(t=>t.name===l&&t.id!==e?.id)?`Name already taken.`:null:`Name must start with a letter and contain only letters, digits, '_' or '-' (max 32 chars).`,[l,t,e?.id]),pe=(0,q.useCallback)(async()=>{D||await Dr({patch:s,save:async()=>{let t=f.split(`
|
|
7
|
-
`).map(e=>e.trim()).filter(e=>e.length>0),n={};for(let e of p.split(`
|
|
8
|
-
`)){let t=e.indexOf(`=`);t>0&&(n[e.slice(0,t).trim()]=e.slice(t+1))}let i={};for(let e of g.split(`
|
|
9
|
-
`)){let t=e.indexOf(`:`);t>0&&(i[e.slice(0,t).trim()]=e.slice(t+1).trim())}if(e){let a=u===`stdio`?{name:l,transport:u,command:d,args:t,env:n,cwd:m||void 0}:{name:l,transport:u,url:h,headers:i};await r.onUpdate(e.id,a)}else{let e=u===`stdio`?{name:l,transport:`stdio`,command:d,args:t,env:n,cwd:m||void 0}:{name:l,transport:u,url:h,headers:i};await r.onCreate(e)}},onDone:n,fallbackMessage:`Failed to save MCP server`})},[f,d,m,p,r,g,e,l,D,n,u,h,s]),me=(0,q.useCallback)(()=>{P(L(`mcpServers.save`,w),pe)},[w,pe]),he=Or({submitting:v,isEdit:e!==null,addLabel:`Add server`});return(0,J.jsxs)(`div`,{className:`flex flex-col gap-4 px-6 py-6 max-w-2xl`,children:[(0,J.jsx)(`h2`,{className:`text-base font-medium`,children:e?`Edit MCP server`:`Add MCP server`}),(0,J.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,J.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`Name`}),(0,J.jsx)(V,{value:l,onChange:e=>s({name:e.target.value}),placeholder:`fs`}),D&&(0,J.jsx)(`p`,{className:`text-xs text-red-600`,children:D})]}),(0,J.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,J.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`Transport`}),(0,J.jsxs)(nt,{value:u,onValueChange:c,children:[(0,J.jsx)(Qe,{children:(0,J.jsx)(et,{})}),(0,J.jsxs)($e,{children:[(0,J.jsx)(z,{value:`stdio`,children:`stdio (spawn local command)`}),(0,J.jsx)(z,{value:`http`,children:`http (Streamable HTTP)`}),(0,J.jsx)(z,{value:`sse`,children:`sse (Server-Sent Events)`}),(0,J.jsx)(z,{value:`ws`,children:`ws (WebSocket)`})]})]})]}),u===`stdio`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,J.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`Command`}),(0,J.jsx)(V,{value:d,onChange:e=>s({command:e.target.value}),placeholder:`/usr/local/bin/mcp-filesystem`})]}),(0,J.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,J.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`Args (one per line)`}),(0,J.jsx)(dt,{value:f,onChange:e=>s({argsText:e.target.value}),rows:3,className:`font-mono text-sm`})]}),(0,J.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,J.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`Env (KEY=value, one per line)`}),(0,J.jsx)(dt,{value:p,onChange:e=>s({envText:e.target.value}),rows:3,className:`font-mono text-sm`})]}),(0,J.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,J.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`cwd (optional)`}),(0,J.jsx)(V,{value:m,onChange:e=>s({cwd:e.target.value}),placeholder:`/optional/working/dir`})]})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,J.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`URL`}),(0,J.jsx)(V,{value:h,onChange:e=>s({url:e.target.value}),placeholder:u===`ws`?`wss://example.com/mcp`:`https://example.com/mcp`})]}),u===`ws`?(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Headers are not supported on the ws transport.`}):(0,J.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,J.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`Headers (Key: value, one per line)`}),(0,J.jsx)(dt,{value:g,onChange:e=>s({headersText:e.target.value}),rows:3,className:`font-mono text-sm`,disabled:y}),y&&(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Authorization header is managed by OAuth when enabled.`})]}),(u===`http`||u===`sse`)&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-md border p-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(ze,{className:`h-4 w-4 text-muted-foreground`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`text-xs font-medium`,children:`OAuth 2.1`}),(0,J.jsxs)(`label`,{className:`ml-auto flex cursor-pointer items-center gap-1 text-xs text-muted-foreground`,children:[ie?(0,J.jsx)(I,{}):null,(0,J.jsx)(`input`,{type:`checkbox`,checked:y,disabled:ie,"aria-busy":ie||void 0,onChange:ue,"aria-label":`Enable OAuth`}),(0,J.jsx)(`span`,{children:`Enable`})]})]}),y&&!e&&(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Save the server first, then authenticate.`}),y&&e&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(Mr,{oauth:ne}),ne?.status===`authenticated`&&(0,J.jsx)(A,{variant:`ghost`,size:`sm`,onClick:E,pending:S,children:`Re-authenticate`})]}),(ne?.status!==`authenticated`||b)&&(b?(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsxs)(`a`,{href:b,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1 text-xs text-blue-600 underline`,children:[`Open authorization URL`,(0,J.jsx)(at,{className:`h-3 w-3`})]}),(0,J.jsx)(ct,{label:se?`Copied`:`Copy URL`,children:(0,J.jsx)(`button`,{type:`button`,onClick:fe,disabled:oe,"aria-busy":oe||void 0,className:`ml-1 text-muted-foreground hover:text-foreground`,"aria-label":se?`Copied`:`Copy authorization URL`,children:(0,J.jsx)(Ir,{pending:oe,copied:se})})})]}),(0,J.jsxs)(`div`,{className:`grid gap-1`,children:[(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`After authorizing, paste the callback URL here:`}),(0,J.jsx)(V,{value:x,onChange:e=>s({callbackInput:e.target.value}),placeholder:`http://localhost:…/callback?code=…`,className:`font-mono text-xs`})]}),(0,J.jsx)(A,{variant:`outline`,size:`sm`,className:`w-fit`,onClick:de,pending:te,disabled:x.length===0,children:te?`Completing…`:`Complete`})]}):(0,J.jsx)(A,{variant:`outline`,size:`sm`,className:`w-fit`,onClick:E,pending:S,children:S?`Starting…`:`Authenticate`})),ee&&(0,J.jsx)(`p`,{className:`text-xs text-red-600`,children:ee})]})]})]}),_&&(0,J.jsx)(`p`,{className:`text-xs text-red-600`,children:_}),(0,J.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,J.jsx)(A,{variant:`ghost`,onClick:n,disabled:v,children:`Cancel`}),(0,J.jsx)(A,{onClick:me,pending:v,disabled:!!D||l.length===0,children:he})]})]})}function Br(e){let t=H(Bt),n=Tr(e=>e.editing),r=Tr(e=>e.setEditing),i=Er(Lr,e.state),a=(0,q.useMemo)(()=>({...i,onDelete:async e=>{await i.onDelete(e),r({kind:`list`})},onSetEnabled:async(t,n)=>{await e.state.handleWriteAppSettings({customMcpServers:{setEnabled:{id:t,enabled:n}}})},onTest:async t=>{await e.state.handleTestMcpServer(t)},onStartMcpOAuth:async t=>e.state.handleStartMcpOAuth(t),onCompleteMcpOAuth:async(t,n)=>e.state.handleCompleteMcpOAuth(t,n)}),[i,e.state,r]);return(0,J.jsx)(Rr,{servers:t,editing:n,onSelect:e=>r({kind:`edit`,id:e}),onStartCreate:()=>r({kind:`create`}),onCancelEditing:()=>r({kind:`list`}),handlers:a})}var Vr=new Set([`checking`,`downloading`,`installing`,`restarting`]);function Hr(e){return e!==null&&Vr.has(e.state)}function Ur(e){switch(e.state){case`checking`:return`Checking ${e.version}…`;case`downloading`:return`Downloading ${e.version}…`;case`installing`:return`Installing ${e.version}…`;case`restarting`:return`Restarting…`;case`current`:return`Up to date`;case`failed`:return e.message===void 0?`Update failed`:`Update failed: ${e.message}`}}function Wr(e){switch(e.state){case`failed`:return`destructive`;case`current`:return`muted`;case`checking`:case`downloading`:case`installing`:case`restarting`:return`active`}}var Gr={},Kr={};function qr(e,t){return`${e}:${t}`}var Jr=k()(e=>({pairing:null,expandedId:null,drafts:Gr,updateErrors:Kr,setPairing:t=>e({pairing:t}),toggleExpanded:t=>e(e=>({expandedId:e.expandedId===t?null:t})),setDraft:(t,n)=>e(e=>({drafts:{...e.drafts,[t]:n}})),clearDraft:t=>e(e=>{let n=Object.fromEntries(Object.entries(e.drafts).filter(([e])=>e!==t));return{drafts:Object.keys(n).length>0?n:Gr}}),setUpdateError:(t,n)=>e(e=>{if(n!==null)return{updateErrors:{...e.updateErrors,[t]:n}};let r=Object.fromEntries(Object.entries(e.updateErrors).filter(([e])=>e!==t));return{updateErrors:Object.keys(r).length>0?r:Kr}})})),Yr=`kanna-beacon`,Xr=`ABCDEFGHJKLMNPQRSTUVWXYZ23456789`,Zr=`https://github.com/cuongtranba/kanna/releases/latest`;RegExp(`^[${Xr}]{8}$`);function Qr(e){return`${Yr}://pair?url=${encodeURIComponent(e.kannaUrl)}&code=${encodeURIComponent(e.code)}`}function $r(e,t){let n=new Map;for(let e of t)n.set(e.beaconId,e);return e.map(e=>{let t=n.get(e.id);return{id:e.id,label:e.label,os:e.os,enabled:e.enabled,online:t?.online??!1,lastSeenAt:t?.lastSeenAt??null,beaconVersion:t?.beaconVersion??null,canSelfUpdate:t?.canSelfUpdate??!1,update:t?.updateStatus??null}})}function ei(e){return e.replace(/^v/,``).split(`-`)[0].split(`.`).map(e=>Number.parseInt(e,10))}function ti(e,t){if(e===t)return!1;let n=ei(e),r=ei(t),i=Math.max(n.length,r.length);for(let a=0;a<i;a+=1){let i=n[a]??0,o=r[a]??0;if(Number.isNaN(i)||Number.isNaN(o))return e<t;if(i!==o)return i<o}return!1}var ni={outdated:`border-warning/40 text-warning-text bg-warning/10`,partial:`border-warning/40 text-warning-text bg-warning/10`,unknown:`border-border text-muted-foreground bg-muted/40`},ri=ke.split(`/`)[1],ii=L(`beacons.mintPairingCode`);function ai(e,t){let n=new Set(e.map(e=>e.id)),r=t.filter(e=>!n.has(e.id));return r.length===0?e:[...e,...$r(r,[])]}function oi({rows:e,configs:t,handlers:n,serverVersion:r,dom:i=Ae,clipboard:a=Ze,timer:o=wt}){let s=it(1e3),c=(0,q.useMemo)(()=>ai(e,t),[e,t]),l=(0,q.useMemo)(()=>new Map(t.map(e=>[e.id,e])),[t]);return(0,J.jsxs)(`div`,{className:`flex flex-col gap-4 px-6 py-6`,children:[(0,J.jsx)(si,{now:s,handlers:n,dom:i,clipboard:a,timer:o}),c.length===0?(0,J.jsx)(br,{icon:On,message:`No machines paired yet. Pair a machine to let the agent read files and run approved commands there.`}):(0,J.jsx)(xr,{children:c.map(e=>(0,J.jsx)(pi,{row:e,scope:l.get(e.id)?.scope??null,now:s,serverVersion:r,handlers:n,dom:i},e.id))})]})}function si({now:e,handlers:t,dom:n,clipboard:r,timer:i}){let a=Jr(e=>e.pairing),o=Jr(e=>e.setPairing),s=F(ii),c=(0,q.useCallback)(()=>{P(ii,async()=>{o(await t.onMint())})},[t,o]);return(0,J.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg border border-border bg-card p-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`h2`,{className:`text-base font-medium`,children:`Beacons`}),(0,J.jsx)(`p`,{className:`mt-1 text-13 text-muted-foreground`,children:`A beacon is a small program on your own machine. Once paired, the agent can read files and run commands there, only within the scope you grant below.`})]}),(0,J.jsxs)(A,{size:`sm`,variant:a?.ok===!0?`secondary`:`default`,onClick:c,pending:s,children:[(0,J.jsx)(B,{className:`mr-1 h-4 w-4`}),`Pair a machine`]})]}),a?.ok===!1&&(0,J.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive-text`,children:a.error}),a?.ok===!0&&(0,J.jsx)(ci,{code:a.code,expiresAt:a.expiresAt,now:e,dom:n,clipboard:r,timer:i})]})}function ci({code:e,expiresAt:t,now:n,dom:r,clipboard:i,timer:a}){let o=t-n,s=r.getOrigin(),c=`kanna-beacon pair ${s} ${e}`,l=Qr({kannaUrl:s,code:e}),u=L(`beacons.copyPairCommand`,e),d=F(u),f=He(u),p=(0,q.useCallback)(()=>{P(u,()=>Ue(u,()=>i.writeText(c),a))},[i,c,u,a]);return(0,J.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-border pt-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-baseline gap-3`,children:[(0,J.jsx)(`span`,{className:`font-mono text-2xl font-medium tabular-nums tracking-widest`,children:e}),(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:o>0?`Expires in ${_t(o)}`:`Expired. Pair again for a new code.`})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[(0,J.jsxs)(`a`,{href:l,className:Pe({size:`sm`}),children:[(0,J.jsx)(at,{className:`mr-1 h-4 w-4`}),`Open in Kanna Beacon`]}),(0,J.jsx)(`a`,{href:Zr,target:`_blank`,rel:`noreferrer`,className:`text-13 text-muted-foreground underline underline-offset-2 hover:text-foreground`,children:`Download Kanna Beacon`})]}),(0,J.jsx)(`p`,{className:`text-13 text-muted-foreground`,children:`Or run this on the machine you want to pair:`}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`code`,{className:`min-w-0 flex-1 break-all rounded-md border border-border bg-muted px-3 py-2 font-mono text-13`,children:c}),(0,J.jsx)(ct,{label:f?`Copied`:`Copy command`,children:(0,J.jsx)(A,{variant:`ghost`,size:`icon`,onClick:p,pending:d,"aria-label":f?`Copied`:`Copy pairing command`,children:f?(0,J.jsx)(Xe,{className:`h-4 w-4 text-success-text`}):(0,J.jsx)(Ye,{className:`h-4 w-4`})})})]})]})}function li(e,t){return e.lastSeenAt===null?`Never connected`:`Last seen ${vt(t-e.lastSeenAt)} ago`}var ui=`This beacon is too old to update itself. Reinstall it once from the download page; after that, updates are one click.`;function di({canSelfUpdate:e}){let t=j(`rounded-full border px-2 py-0.5 text-xs`,ni.outdated);return e?(0,J.jsx)(`span`,{className:t,children:`Update available`}):(0,J.jsx)(ct,{label:ui,children:(0,J.jsx)(`a`,{href:Zr,target:`_blank`,rel:`noreferrer`,className:t,children:`Update available`})})}function fi({row:e,updateAvailable:t,handlers:n}){let r=L(`beacons.update`,e.id),i=F(r),a=Jr(t=>t.updateErrors[e.id]??null),o=Jr(e=>e.setUpdateError),s=t&&e.online&&e.canSelfUpdate&&!Hr(e.update),c=(0,q.useCallback)(()=>{P(r,async()=>{let t=await n.onUpdate(e.id);o(e.id,t.ok?null:t.error)})},[n,e.id,o,r]);return(0,J.jsxs)(J.Fragment,{children:[e.update!==null&&(0,J.jsx)($t,{tone:Wr(e.update),label:Ur(e.update)}),s&&(0,J.jsxs)(A,{variant:`secondary`,size:`sm`,onClick:c,pending:i,"aria-label":`Update ${e.label} now`,children:[(0,J.jsx)(sn,{className:`mr-1 h-4 w-4`}),`Update now`]}),a!==null&&(0,J.jsx)(`span`,{role:`alert`,className:`text-destructive-text`,children:a})]})}function pi({row:e,scope:t,now:n,serverVersion:r,handlers:i,dom:a}){let o=Jr(t=>t.expandedId===e.id),s=Jr(e=>e.toggleExpanded),c=L(`beacons.setEnabled`,e.id),l=F(c),u=L(`beacons.delete`,e.id),d=F(u),f=e.beaconVersion!==null&&r!==void 0&&ti(e.beaconVersion,r),p=(0,q.useCallback)(t=>{let n=t.target.checked;P(c,()=>i.onSetEnabled(e.id,n))},[c,i,e.id]),m=(0,q.useCallback)(()=>{a.confirmDialog(`Revoke "${e.label}"? The agent will lose access to this machine until you pair it again.`)&&P(u,()=>i.onDelete(e.id))},[u,a,i,e.id,e.label]),h=(0,q.useCallback)(()=>{s(e.id)},[e.id,s]);return(0,J.jsxs)(`li`,{className:`flex flex-col`,"aria-busy":d||void 0,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 px-4 py-3`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,J.jsx)(`span`,{className:`truncate font-medium`,children:e.label}),(0,J.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground`,children:[(0,J.jsx)($t,{tone:e.online?`active`:`muted`,label:e.online?`Online`:`Offline`}),(0,J.jsx)(`span`,{className:`tabular-nums`,children:li(e,n)}),e.beaconVersion!==null&&(0,J.jsxs)(`span`,{className:`font-mono tabular-nums`,children:[`v`,e.beaconVersion]}),f&&(0,J.jsx)(di,{canSelfUpdate:e.canSelfUpdate}),(0,J.jsx)(fi,{row:e,updateAvailable:f,handlers:i}),(0,J.jsx)(`span`,{children:e.os})]})]}),(0,J.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,J.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-1 text-xs text-muted-foreground`,children:[l?(0,J.jsx)(I,{}):null,(0,J.jsx)(`input`,{type:`checkbox`,checked:e.enabled,disabled:l,"aria-busy":l||void 0,onChange:p,"aria-label":`Enable ${e.label}`}),(0,J.jsx)(`span`,{children:e.enabled?`Enabled`:`Disabled`})]}),t!==null&&(0,J.jsx)(A,{variant:`ghost`,size:`sm`,onClick:h,"aria-expanded":o,children:`Scope`}),(0,J.jsx)(ct,{label:`Revoke this machine`,children:(0,J.jsx)(A,{variant:`ghost`,size:`icon`,onClick:m,pending:d,"aria-label":`Revoke ${e.label}`,children:(0,J.jsx)(le,{className:`h-4 w-4`})})})]})]}),o&&t!==null&&(0,J.jsx)(mi,{beaconId:e.id,scope:t,handlers:i})]})}function mi({beaconId:e,scope:t,handlers:n}){let r=L(`beacons.setScope`,e),i=F(r),a=(0,q.useCallback)(t=>{P(r,()=>n.onSetScope(e,t))},[e,n,r]),o=(0,q.useCallback)(e=>{a({...t,exec:e.target.checked})},[a,t]),s=(0,q.useCallback)(e=>{a({...t,autoRunScripts:e.target.checked})},[a,t]),c=(0,q.useCallback)(e=>{a({...t,readRoots:e})},[a,t]),l=(0,q.useCallback)(e=>{a({...t,writeRoots:e})},[a,t]),u=(0,q.useCallback)(e=>{a({...t,execAllowlist:e})},[a,t]);return(0,J.jsxs)(`div`,{className:`flex flex-col gap-4 border-t border-border bg-muted/40 px-4 py-4`,"aria-busy":i||void 0,children:[(0,J.jsx)(hi,{checked:t.exec,disabled:i,onChange:o,title:`Allow running commands`,description:`Without this, the agent can only read files inside the folders below.`}),(0,J.jsx)(hi,{checked:t.autoRunScripts,disabled:i,onChange:s,title:`Run commands and scripts from this chat without asking each time`,description:`Reads inside your folders and commands you have enabled run immediately, with no approval prompt.`}),(0,J.jsx)(gi,{label:`Folders the agent may read`,placeholder:`/Users/me/projects`,draftKey:qr(e,`readRoots`),items:t.readRoots,disabled:i,onChange:c}),(0,J.jsx)(gi,{label:`Folders the agent may write to`,description:`beacon_push can only put files inside these folders. Leave empty and the agent cannot write to this machine.`,placeholder:`/Users/me/inbox`,draftKey:qr(e,`writeRoots`),items:t.writeRoots,disabled:i,onChange:l}),(0,J.jsx)(gi,{label:`Commands that always run without asking`,placeholder:`git`,draftKey:qr(e,`execAllowlist`),items:t.execAllowlist,disabled:i,onChange:u})]})}function hi({checked:e,disabled:t,onChange:n,title:r,description:i}){return(0,J.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3`,children:[(0,J.jsx)(`input`,{type:`checkbox`,className:`mt-1`,checked:e,disabled:t,onChange:n}),(0,J.jsxs)(`span`,{className:`flex flex-col`,children:[(0,J.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:r}),(0,J.jsx)(`span`,{className:`text-13 text-muted-foreground`,children:i})]})]})}function gi({label:e,description:t,placeholder:n,draftKey:r,items:i,disabled:a,onChange:o}){let s=Jr(e=>e.drafts[r]??``),c=Jr(e=>e.setDraft),l=Jr(e=>e.clearDraft),u=s.trim(),d=u.length>0&&!i.includes(u),f=(0,q.useCallback)(e=>{c(r,e.target.value)},[r,c]),p=(0,q.useCallback)(()=>{o([...i,u]),l(r)},[l,r,i,o,u]),m=(0,q.useCallback)(e=>{o(i.filter(t=>t!==e))},[i,o]);return(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:e}),t!==void 0&&(0,J.jsx)(`span`,{className:`text-13 text-muted-foreground`,children:t}),i.length===0?(0,J.jsx)(`span`,{className:`text-13 text-muted-foreground`,children:`None`}):(0,J.jsx)(`ul`,{className:`flex flex-col gap-1`,children:i.map(e=>(0,J.jsx)(_i,{item:e,disabled:a,onRemove:m},e))}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(V,{value:s,onChange:f,placeholder:n,disabled:a,"aria-label":e}),(0,J.jsx)(A,{variant:`secondary`,size:`sm`,onClick:p,disabled:a||!d,children:`Add`})]})]})}function _i({item:e,disabled:t,onRemove:n}){let r=(0,q.useCallback)(()=>{n(e)},[e,n]);return(0,J.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`code`,{className:`min-w-0 flex-1 break-all rounded-md border border-border bg-muted px-2 py-1 font-mono text-13`,children:e}),(0,J.jsx)(A,{variant:`ghost`,size:`icon-sm`,onClick:r,disabled:t,"aria-label":`Remove ${e}`,children:(0,J.jsx)(yt,{className:`h-4 w-4`})})]})}function vi(e){let t=Se(_),n=H(Vt),{handleWriteAppSettings:r,handleMintBeaconPairingCode:i,handleUpdateBeacon:a}=e.state,o=(0,q.useMemo)(()=>({onMint:i,onSetEnabled:async(e,t)=>{await r({customBeacons:{setEnabled:{id:e,enabled:t}}})},onSetScope:async(e,t)=>{await r({customBeacons:{setScope:{id:e,scope:t}}})},onDelete:async e=>{await r({customBeacons:{delete:{id:e}}})},onUpdate:a}),[r,i,a]);return(0,J.jsx)(oi,{rows:t,configs:n,handlers:o,serverVersion:ri})}var yi={id:``,label:``,modelProvider:`claude`,supportedEfforts:[],offersOneMillionContext:!1};function bi(e){return{...e,submitting:!1,error:null}}var xi=k()(e=>({editing:{kind:`list`},editorForm:bi(yi),setEditing:t=>e({editing:t}),resetEditorForm:t=>e({editorForm:bi(t)}),patchEditorForm:t=>e(e=>({editorForm:{...e.editorForm,...t}})),toggleSupportedEffort:t=>e(e=>{let n=e.editorForm.supportedEfforts,r=n.includes(t)?n.filter(e=>e!==t):[...n,t];return{editorForm:{...e.editorForm,supportedEfforts:r}}}),toggleOneMillionContext:()=>e(e=>({editorForm:{...e.editorForm,offersOneMillionContext:!e.editorForm.offersOneMillionContext}}))})),Si=e=>({customModels:e}),Ci=new Set([`claude`,`codex`]);function wi(e){return Ci.has(e)}var Ti={claude:`Claude`,codex:`Codex`};function Ei({models:e,handlers:t,dom:n=Ae}){let r=xi(e=>e.editing),i=xi(e=>e.setEditing),a=xi(e=>e.resetEditorForm);function o(t){if(t.kind===`create`)a({id:``,label:``,modelProvider:t.provider,supportedEfforts:[],offersOneMillionContext:!1});else if(t.kind===`edit`){let n=e.find(e=>e.id===t.id)??null;n&&a({id:n.id,label:n.label,modelProvider:n.provider,supportedEfforts:n.supportedEfforts??[],offersOneMillionContext:xe(n.provider,n.id,n.contextWindowOptions).some(e=>e.id===`1m`)})}i(t)}if(r.kind!==`list`){let n=r.kind===`edit`?e.find(e=>e.id===r.id)??null:null;return(0,J.jsx)(Oi,{initial:n,existing:e.map(e=>({id:e.id,provider:e.provider})),handlers:t,onDone:()=>i({kind:`list`})})}return(0,J.jsx)(`div`,{className:`flex flex-col gap-6 px-6 py-6`,children:[`claude`,`codex`].map(r=>{let i=e.filter(e=>e.provider===r);return(0,J.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsxs)(`h2`,{className:`text-base font-medium`,children:[Ti[r],` models`]}),(0,J.jsxs)(A,{size:`sm`,onClick:()=>o({kind:`create`,provider:r}),children:[(0,J.jsx)(B,{className:`mr-1 h-4 w-4`}),`Add model`]})]}),i.length===0?(0,J.jsx)(br,{icon:pn,message:`No ${Ti[r]} models configured.`}):(0,J.jsx)(xr,{children:i.map(e=>(0,J.jsx)(Di,{model:e,onEdit:()=>o({kind:`edit`,id:e.id}),onDelete:t.onDelete,dom:n},e.id))})]},r)})})}function Di({model:e,onEdit:t,onDelete:n,dom:r}){let i=L(`models.delete`,e.provider,e.id),a=F(i),o=(0,q.useCallback)(()=>{r.confirmDialog(`Delete model "${e.label}"?`)&&P(i,()=>n(e.id))},[i,r,e.id,e.label,n]);return(0,J.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-3`,"aria-busy":a||void 0,children:[(0,J.jsxs)(`div`,{className:`flex flex-col`,children:[(0,J.jsx)(`span`,{className:`font-medium`,children:e.label}),(0,J.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:e.id})]}),(0,J.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(e.supportedEfforts?.length??0)>0&&(0,J.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-xs`,children:`effort`}),e.supportedEfforts?.includes(`max`)&&(0,J.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-xs`,children:`max`}),(0,J.jsx)(Sr,{label:e.label,onEdit:t,onDelete:o,deletePending:a})]})]})}function Oi({initial:e,existing:t,handlers:n,onDone:r}){let i=xi(e=>e.editorForm),a=xi(e=>e.patchEditorForm),o=xi(e=>e.toggleSupportedEffort),s=xi(e=>e.toggleOneMillionContext),c=(0,q.useCallback)(e=>{wi(e)&&a({modelProvider:e})},[a]),{id:l,label:u,modelProvider:d,supportedEfforts:f,offersOneMillionContext:p,submitting:m,error:h}=i,g=p?ye:ye.filter(e=>e.id===`200k`),_=e!==null,v=(0,q.useMemo)(()=>!_&&t.some(e=>e.id===l.trim()&&e.provider===d),[t,l,_,d]),y=l.trim().length>0&&u.trim().length>0&&!v&&!m,b=()=>Dr({patch:a,save:async()=>{_&&e?await n.onUpdate(e.id,{label:u.trim(),supportedEfforts:f.length>0?f:null,...d===`claude`?{contextWindowOptions:g}:{}}):await n.onCreate({id:l.trim(),label:u.trim(),provider:d,...f.length>0?{supportedEfforts:f}:{},...d===`claude`?{contextWindowOptions:g}:{}})},onDone:r,fallbackMessage:`Failed to save model`}),x=Or({submitting:m,isEdit:_,addLabel:`Add model`});return(0,J.jsxs)(`div`,{className:`flex flex-col gap-4 px-6 py-6`,children:[(0,J.jsx)(`h2`,{className:`text-base font-medium`,children:_?`Edit model`:`Add model`}),(0,J.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`span`,{className:`text-sm font-medium`,children:`Provider`}),(0,J.jsxs)(nt,{value:d,onValueChange:c,disabled:_,children:[(0,J.jsx)(Qe,{className:`min-w-[180px]`,children:(0,J.jsx)(et,{})}),(0,J.jsxs)($e,{children:[(0,J.jsx)(z,{value:`claude`,children:`Claude`}),(0,J.jsx)(z,{value:`codex`,children:`Codex`})]})]})]}),(0,J.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`span`,{className:`text-sm font-medium`,children:`Model ID`}),(0,J.jsx)(V,{value:l,onChange:e=>a({id:e.target.value}),placeholder:`claude-opus-4-9`,disabled:_,className:`font-mono`}),v&&(0,J.jsx)(`span`,{className:`text-xs text-red-600`,children:`A model with this id already exists.`})]}),(0,J.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`span`,{className:`text-sm font-medium`,children:`Label`}),(0,J.jsx)(V,{value:u,onChange:e=>a({label:e.target.value}),placeholder:`Opus 4.9`})]}),d===`claude`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(`span`,{className:`text-sm font-medium`,children:`Supported effort levels`}),we.map(e=>(0,J.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-2 text-sm`,children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:f.includes(e.id),onChange:()=>o(e.id)}),(0,J.jsx)(`span`,{children:e.label})]},e.id))]}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`span`,{className:`text-sm font-medium`,children:`Context window`}),(0,J.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-2 text-sm`,children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:p,onChange:s}),(0,J.jsx)(`span`,{children:`Offer the 1M context window`})]}),(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Off means every turn on this model runs on the 200k window.`})]})]}),h&&(0,J.jsx)(`span`,{className:`text-xs text-red-600`,children:h}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(A,{onClick:()=>{P(L(`models.save`,e?.id??`new`),b)},pending:m,disabled:!y,children:x}),(0,J.jsx)(A,{variant:`ghost`,onClick:r,disabled:m,children:`Cancel`})]})]})}function ki(e){let t=H(zt),n=Er(Si,e.state);return(0,J.jsx)(Ei,{models:t,handlers:n})}function Ai(){let e=H(zt),t=H(Rt);return(0,q.useMemo)(()=>d(oe([...ue],e),t),[e,t])}var ji=32,Mi=`-`;function Ni(){return{id:``,idTouched:!1,label:``,baseUrl:``,apiKey:``,models:[Pi()],contextWindow:``,hint:null}}function Pi(){return{id:``,label:``}}function Fi(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^[^a-z]+/,``).replace(/-+$/,``).slice(0,ji).replace(/-+$/,``)}function Ii(e,t){if(e.length===0||!t.includes(e))return e;for(let n=2;;n+=1){let r=`-${n}`,i=`${e.slice(0,ji-r.length)}${r}`;if(!t.includes(i))return i}}function Li(e,t){return{id:Ii(e.id,t),idTouched:!0,label:e.label,baseUrl:e.baseUrl,apiKey:e.defaultApiKey??``,models:e.models.length>0?e.models.map(e=>({...e})):[Pi()],contextWindow:e.contextWindow===void 0?``:String(e.contextWindow),hint:e.hint??null}}function Ri(e){return{id:e.id,idTouched:!0,label:e.label,baseUrl:e.baseUrl,apiKey:``,models:e.models.map(e=>({...e})),contextWindow:e.contextWindow===void 0?``:String(e.contextWindow),hint:null}}function zi(e,t){return Ii(Fi(e),t)}function Bi(e){return e.map(e=>({id:e.id.trim(),label:e.label.trim()})).filter(e=>e.id.length>0||e.label.length>0)}function Vi(e){let t=e.replace(/[\s,_]/g,``);return t.length===0?void 0:Number(t)}function Hi(e){let t=Vi(e.contextWindow);return{id:e.id.trim(),label:e.label.trim(),baseUrl:e.baseUrl.trim(),apiKey:e.apiKey.trim(),models:Bi(e.models),...t===void 0?{}:{contextWindow:t}}}function Ui(e){let t=e.apiKey.trim();return{label:e.label.trim(),baseUrl:e.baseUrl.trim(),models:Bi(e.models),contextWindow:Vi(e.contextWindow)??null,...t.length>0?{apiKey:t}:{}}}function Wi(e,t,n){let r=Hi(e),i=te({...r,apiKey:t===`edit`&&r.apiKey.length===0?Mi:r.apiKey},n);return i===null?null:i.code===`INVALID_ID`?`Id must be lowercase letters, digits or dashes, start with a letter, and be at most ${ji} characters (${x}).`:i.message}function Gi(e){return`${e<1e6&&e%1024==0?`${e/1024}k`:Qt(e)} context`}function Ki(e){return e===null?`Key set`:`Key ••••${e}`}function qi(e,t){return e===`create`?`API key`:t===null?`Leave blank to keep the saved key`:`Leave blank to keep ••••${t}`}function Ji(e){return{...e,submitting:!1,error:null}}var Q=k()(e=>({editing:{kind:`list`},menuOpen:!1,listError:null,editorForm:Ji(Ni()),setMenuOpen:t=>e({menuOpen:t}),setListError:t=>e({listError:t}),startEditing:(t,n)=>e({editing:t,menuOpen:!1,listError:null,editorForm:Ji(n)}),discardEditor:()=>e({editing:{kind:`list`},menuOpen:!1,editorForm:Ji(Ni())}),patchEditorForm:t=>e(e=>({editorForm:{...e.editorForm,...t}})),setLabel:(t,n)=>e(e=>({editorForm:{...e.editorForm,label:t,id:e.editorForm.idTouched?e.editorForm.id:zi(t,n)}})),setId:t=>e(e=>({editorForm:{...e.editorForm,id:t.toLowerCase(),idTouched:!0}})),setModelField:(t,n,r)=>e(e=>({editorForm:{...e.editorForm,models:e.editorForm.models.map((e,i)=>i===t?{...e,[n]:r}:e)}})),addModelRow:()=>e(e=>({editorForm:{...e.editorForm,models:[...e.editorForm.models,{id:``,label:``}]}})),removeModelRow:t=>e(e=>({editorForm:{...e.editorForm,models:e.editorForm.models.filter((e,n)=>n!==t)}}))})),Yi=[{id:`glm`,label:`GLM (Z.AI)`,baseUrl:`https://api.z.ai/api/anthropic`,models:[{id:`glm-5.3`,label:`GLM-5.3`},{id:`glm-5.3-flash`,label:`GLM-5.3 Flash`}]},{id:`qwen`,label:`Qwen (Alibaba Model Studio)`,baseUrl:`https://coding-intl.dashscope.aliyuncs.com/apps/anthropic`,models:[{id:`qwen3.7-plus`,label:`Qwen3.7 Plus`},{id:`qwen3.7-max`,label:`Qwen3.7 Max`}],hint:`Coding Plan endpoint. Pay-as-you-go uses https://{WorkspaceId}.<region>.maas.aliyuncs.com/apps/anthropic.`},{id:`kimi`,label:`Kimi (Moonshot)`,baseUrl:`https://api.moonshot.ai/anthropic`,models:[{id:`kimi-k3`,label:`Kimi K3`},{id:`kimi-k2.7-code`,label:`Kimi K2.7 Code`}]},{id:`deepseek`,label:`DeepSeek`,baseUrl:`https://api.deepseek.com/anthropic`,models:[{id:`deepseek-v4-pro`,label:`DeepSeek V4 Pro`},{id:`deepseek-flash`,label:`DeepSeek Flash`}]},{id:`minimax`,label:`MiniMax`,baseUrl:`https://api.minimax.io/anthropic`,models:[{id:`MiniMax-M3.1`,label:`MiniMax M3.1`}],hint:`Mainland China: https://api.minimaxi.com/anthropic`},{id:`ollama`,label:`Ollama (local)`,baseUrl:`http://localhost:11434`,models:[],contextWindow:65536,defaultApiKey:`ollama`,hint:"Runs on this machine. Ollama ignores the API key, so any value works. Add the exact model names from `ollama list`, and set Context window to your OLLAMA_CONTEXT_LENGTH."}],Xi=e=>({customProviders:e}),Zi=`Anthropic-compatible endpoints such as GLM, Qwen, Kimi, DeepSeek or MiniMax. They run through the Claude agent, so tools, skills and MCP work as usual. Pick them in the chat composer under Custom endpoints.`;function Qi(e){return`${e} ${e===1?`model`:`models`}`}function $i({providers:e,handlers:t,dom:n=Ae}){let r=Q(e=>e.editing),i=Q(e=>e.discardEditor);return(0,q.useEffect)(()=>{i()},[i]),(0,J.jsxs)(`div`,{className:`border-t border-border pb-5`,children:[(0,J.jsx)(Z,{title:`Custom endpoints`,description:Zi,bordered:!1,alignStart:!0,children:r.kind===`list`?(0,J.jsx)(ea,{providers:e}):null}),r.kind===`list`?(0,J.jsx)(ta,{providers:e,onDelete:t.onDelete,dom:n}):(0,J.jsx)(ra,{providers:e,editingId:r.kind===`edit`?r.id:null,handlers:t})]})}function ea({providers:e}){let t=Q(e=>e.menuOpen),n=Q(e=>e.setMenuOpen),r=Q(e=>e.startEditing),i=(0,q.useMemo)(()=>e.map(e=>e.id),[e]),a=(0,q.useCallback)(e=>{r({kind:`create`},Li(e,i))},[r,i]),o=(0,q.useCallback)(()=>{r({kind:`create`},Ni())},[r]);return(0,J.jsxs)(tn,{open:t,onOpenChange:n,children:[(0,J.jsx)(en,{asChild:!0,children:(0,J.jsxs)(A,{size:`sm`,children:[(0,J.jsx)(B,{className:`mr-1 h-4 w-4`}),`Add endpoint`]})}),(0,J.jsx)(U,{align:`end`,className:`w-64 p-1`,children:(0,J.jsxs)(`div`,{className:`space-y-1`,children:[Yi.map(e=>(0,J.jsx)(Le,{onClick:()=>a(e),selected:!1,icon:(0,J.jsx)(R,{className:`h-4 w-4 text-muted-foreground`}),label:e.label},e.id)),(0,J.jsx)(Le,{onClick:o,selected:!1,icon:(0,J.jsx)(B,{className:`h-4 w-4 text-muted-foreground`}),label:`Custom…`,description:`Any Anthropic-compatible URL`})]})})]})}function ta({providers:e,onDelete:t,dom:n}){let r=Q(e=>e.listError);return(0,J.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[r?(0,J.jsx)(`div`,{role:`alert`,className:`rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-sm text-destructive`,children:r}):null,e.length===0?(0,J.jsx)(br,{icon:R,message:`No custom endpoints yet.`}):(0,J.jsx)(xr,{children:e.map(e=>(0,J.jsx)(na,{provider:e,onDelete:t,dom:n},e.id))})]})}function na({provider:e,onDelete:t,dom:n}){let r=Q(e=>e.startEditing),i=Q(e=>e.setListError),a=L(`settings.customProviders.delete`,e.id),o=F(a),s=(0,q.useCallback)(()=>{r({kind:`edit`,id:e.id},Ri(e))},[e,r]),c=(0,q.useCallback)(()=>{n.confirmDialog(`Delete endpoint "${e.label}"?`)&&P(a,async()=>{i(null);try{await t(e.id)}catch(e){i(je(e))}})},[a,n,t,e.id,e.label,i]);return(0,J.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-3`,"aria-busy":o||void 0,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,J.jsx)(`span`,{className:`truncate font-medium`,children:e.label}),(0,J.jsx)(ot,{tooltip:e.baseUrl,className:`font-mono text-xs text-muted-foreground`,children:e.baseUrl})]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-0.5 text-xs text-muted-foreground`,children:[(0,J.jsx)(`span`,{className:`tabular-nums`,children:Qi(e.models.length)}),e.contextWindow===void 0?null:(0,J.jsx)(`span`,{className:`tabular-nums`,children:Gi(e.contextWindow)}),(0,J.jsx)(`span`,{children:Ki(e.apiKeyHint)})]}),(0,J.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:(0,J.jsx)(Sr,{label:e.label,onEdit:s,onDelete:c,deletePending:o})})]})}function ra({providers:e,editingId:t,handlers:n}){let r=Q(e=>e.editorForm),i=Q(e=>e.patchEditorForm),a=Q(e=>e.setLabel),o=Q(e=>e.setId),s=Q(e=>e.setModelField),c=Q(e=>e.addModelRow),l=Q(e=>e.removeModelRow),u=Q(e=>e.discardEditor),d=t!==null,f=d?`edit`:`create`,p=(0,q.useMemo)(()=>e.find(e=>e.id===t)??null,[e,t]),m=(0,q.useMemo)(()=>e.filter(e=>e.id!==t).map(e=>e.id),[e,t]),h=L(`settings.customProviders`,t??(r.id||`new`)),g=F(h),_=(0,q.useCallback)(e=>{a(e,m)},[m,a]),v=(0,q.useCallback)(()=>{let e=Wi(r,f,m);if(e!==null){i({error:e});return}P(h,()=>Dr({patch:i,save:async()=>{t===null?await n.onCreate(Hi(r)):await n.onUpdate(t,Ui(r))},onDone:u,fallbackMessage:`Failed to save endpoint`}))},[u,t,r,n,f,m,i,h]),b=r.submitting||g;return(0,J.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-md border border-border px-4 py-4`,children:[(0,J.jsx)(`h3`,{className:`text-sm font-medium`,children:d?`Edit ${p?.label??t}`:`Add endpoint`}),r.hint?(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r.hint}):null,(0,J.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`span`,{className:`text-sm font-medium`,children:`Label`}),(0,J.jsx)(V,{value:r.label,onChange:e=>_(e.target.value),maxLength:64,placeholder:`GLM (Z.AI)`})]}),(0,J.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`span`,{className:`text-sm font-medium`,children:`Id`}),(0,J.jsx)(V,{value:r.id,onChange:e=>o(e.target.value),disabled:d,placeholder:`glm`,className:`font-mono`}),(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Part of every model id, so it cannot change after the endpoint is created.`})]}),(0,J.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`span`,{className:`text-sm font-medium`,children:`Base URL`}),(0,J.jsx)(V,{value:r.baseUrl,onChange:e=>i({baseUrl:e.target.value}),placeholder:`https://api.example.com/anthropic`,className:`font-mono`})]}),(0,J.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`span`,{className:`text-sm font-medium`,children:`API key`}),(0,J.jsx)(V,{type:`password`,autoComplete:`off`,value:r.apiKey,onChange:e=>i({apiKey:e.target.value}),maxLength:y,placeholder:qi(f,p?.apiKeyHint??null),className:`font-mono`})]}),(0,J.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`span`,{className:`text-sm font-medium`,children:`Context window (tokens)`}),(0,J.jsx)(V,{inputMode:`numeric`,value:r.contextWindow,onChange:e=>i({contextWindow:e.target.value}),placeholder:`200000`,className:`font-mono tabular-nums`}),(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`The model's real context window. The agent compacts the conversation before reaching it. Leave empty to assume 200,000. For Ollama use your OLLAMA_CONTEXT_LENGTH.`})]}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(`span`,{className:`text-sm font-medium`,children:`Models`}),r.models.map((e,t)=>(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(V,{value:e.id,onChange:e=>s(t,`id`,e.target.value),maxLength:128,placeholder:`Model id`,"aria-label":`Model ${t+1} id`,className:`font-mono`}),(0,J.jsx)(V,{value:e.label,onChange:e=>s(t,`label`,e.target.value),maxLength:64,placeholder:`Label (optional)`,"aria-label":`Model ${t+1} label`}),(0,J.jsx)(A,{variant:`ghost`,size:`sm`,onClick:()=>l(t),"aria-label":`Remove model ${t+1}`,children:(0,J.jsx)(yt,{className:`h-4 w-4`})})]},t)),(0,J.jsx)(`div`,{children:(0,J.jsxs)(A,{variant:`ghost`,size:`sm`,onClick:c,children:[(0,J.jsx)(B,{className:`mr-1 h-4 w-4`}),`Add model`]})})]}),r.error?(0,J.jsx)(`div`,{role:`alert`,className:`rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-sm text-destructive`,children:r.error}):null,(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(A,{onClick:v,pending:b,children:Or({submitting:b,isEdit:d,addLabel:`Add endpoint`})}),(0,J.jsx)(A,{variant:`ghost`,onClick:u,disabled:b,children:`Cancel`})]})]})}function ia(e){let t=H(Rt),n=Er(Xi,e.state);return(0,J.jsx)($i,{providers:t,handlers:n})}function aa(e,t){return{shortcut:e,expansion:t,submitting:!1,error:null}}var oa=k()(e=>({editing:{kind:`list`},editorForm:aa(``,``),setEditing:t=>e({editing:t}),resetEditorForm:(t,n)=>e({editorForm:aa(t,n)}),patchEditorForm:t=>e(e=>({editorForm:{...e.editorForm,...t}}))})),sa=e=>({textSnippets:e}),ca=/^\S{1,32}$/;function la({snippets:e,handlers:t,dom:n=Ae}){let r=oa(e=>e.editing),i=oa(e=>e.setEditing),a=oa(e=>e.resetEditorForm);function o(t){if(t.kind===`create`)a(``,``);else if(t.kind===`edit`){let n=e.find(e=>e.id===t.id)??null;n&&a(n.shortcut,n.expansion)}i(t)}if(r.kind!==`list`){let n=r.kind===`edit`?e.find(e=>e.id===r.id)??null:null;return(0,J.jsx)(da,{initial:n,existing:e.map(e=>({id:e.id,shortcut:e.shortcut})),handlers:t,onDone:()=>i({kind:`list`})})}return(0,J.jsxs)(`div`,{className:`flex flex-col gap-4 px-6 py-6`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`h2`,{className:`text-base font-medium`,children:`Text snippets`}),(0,J.jsx)(`p`,{className:`max-w-[65ch] text-sm text-muted-foreground`,children:`Type a shortcut in the chat composer and press Tab to expand it into the full text. Handy for prompts you send often.`})]}),(0,J.jsxs)(A,{size:`sm`,onClick:()=>o({kind:`create`}),children:[(0,J.jsx)(B,{className:`mr-1 h-4 w-4`}),`Add snippet`]})]}),e.length===0?(0,J.jsx)(br,{icon:Mn,message:`No snippets yet. Add one to expand a shortcut with Tab.`}):(0,J.jsx)(xr,{children:e.map(e=>(0,J.jsx)(ua,{snippet:e,onEdit:()=>o({kind:`edit`,id:e.id}),onDelete:t.onDelete,dom:n},e.id))})]})}function ua({snippet:e,onEdit:t,onDelete:n,dom:r}){let i=L(`textSnippets.delete`,e.id),a=F(i),o=(0,q.useCallback)(()=>{r.confirmDialog(`Delete snippet "${e.shortcut}"?`)&&P(i,()=>n(e.id))},[i,r,n,e.id,e.shortcut]);return(0,J.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-3`,"aria-busy":a||void 0,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,J.jsx)(`span`,{className:`font-mono text-sm`,children:e.shortcut}),(0,J.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e.expansion})]}),(0,J.jsx)(`div`,{className:`ml-auto flex items-center gap-2`,children:(0,J.jsx)(Sr,{label:e.shortcut,onEdit:t,onDelete:o,deletePending:a})})]})}function da({initial:e,existing:t,handlers:n,onDone:r}){let i=oa(e=>e.editorForm),a=oa(e=>e.patchEditorForm),{shortcut:o,expansion:s,submitting:c,error:l}=i,u=e!==null,d=o.trim(),f=ca.test(d),p=(0,q.useMemo)(()=>t.some(t=>t.shortcut===d&&t.id!==e?.id),[t,d,e?.id]),m=f&&!p&&s.length>0&&!c,h=()=>Dr({patch:a,save:async()=>{u&&e?await n.onUpdate(e.id,{shortcut:d,expansion:s}):await n.onCreate({shortcut:d,expansion:s})},onDone:r,fallbackMessage:`Failed to save snippet`}),g=Or({submitting:c,isEdit:u,addLabel:`Add snippet`});return(0,J.jsxs)(`div`,{className:`flex flex-col gap-4 px-6 py-6`,children:[(0,J.jsx)(`h2`,{className:`text-base font-medium`,children:u?`Edit snippet`:`Add snippet`}),(0,J.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`span`,{className:`text-sm font-medium`,children:`Shortcut`}),(0,J.jsx)(V,{value:o,onChange:e=>a({shortcut:e.target.value}),placeholder:`pgm`,className:`font-mono`,autoFocus:!0}),o.length>0&&!f&&(0,J.jsx)(`span`,{className:`text-xs text-destructive`,children:`Shortcut must be 1-32 characters with no spaces.`}),p&&(0,J.jsx)(`span`,{className:`text-xs text-destructive`,children:`A snippet with this shortcut already exists.`})]}),(0,J.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`span`,{className:`text-sm font-medium`,children:`Expands to`}),(0,J.jsx)(dt,{value:s,onChange:e=>a({expansion:e.target.value}),placeholder:`pull request green then merge`,rows:4})]}),l&&(0,J.jsx)(`span`,{className:`text-xs text-destructive`,children:l}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(A,{onClick:()=>{P(L(`textSnippets.save`,e?.id??`new`),h)},pending:c,disabled:!m,children:g}),(0,J.jsx)(A,{variant:`ghost`,onClick:r,disabled:c,children:`Cancel`})]})]})}function fa(e){let t=H(Wt),n=Er(sa,e.state);return(0,J.jsx)(la,{snippets:t,handlers:n})}function pa(e){if(!e)return`—`;let t=e.trim();if(!t)return`—`;let n=t.slice(-4);return`${t.startsWith(`sk-ant-`)?`sk-ant-`:``}…${n}`}var $=k()(e=>({addLabel:``,addToken:``,addBaseUrl:``,addSubmitting:!1,tokenRowStates:{},baseUrlDrafts:{},setAddLabel:t=>e({addLabel:t}),setAddToken:t=>e({addToken:t}),setAddBaseUrl:t=>e({addBaseUrl:t}),setAddSubmitting:t=>e({addSubmitting:t}),resetAddForm:()=>e({addLabel:``,addToken:``,addBaseUrl:``}),setTokenRowTesting:(t,n)=>e(e=>({tokenRowStates:{...e.tokenRowStates,[t]:{...e.tokenRowStates[t]??{testResult:null,testing:!1},testing:n}}})),setTokenRowTestResult:(t,n)=>e(e=>({tokenRowStates:{...e.tokenRowStates,[t]:{...e.tokenRowStates[t]??{testResult:null,testing:!1},testResult:n}}})),clearTokenRowState:t=>e(e=>{let{[t]:n,...r}=e.tokenRowStates;return{tokenRowStates:r}}),setBaseUrlDraft:(t,n)=>e(e=>({baseUrlDrafts:{...e.baseUrlDrafts,[t]:n}})),clearBaseUrlDraft:t=>e(e=>{let{[t]:n,...r}=e.baseUrlDrafts;return{baseUrlDrafts:r}})}));function ma(e){if(e<=0)return`reset now`;let t=Math.ceil(e/1e3),n=Math.floor(t/60),r=t%60;return n<60?`reset in ${n}m ${r.toString().padStart(2,`0`)}s`:`reset in ${Math.floor(n/60)}h ${(n%60).toString().padStart(2,`00`)}m`}function ha({entry:e,now:t}){if(e.status===`active`)return(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,J.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/50`,"aria-hidden":`true`}),`Active`]});if(e.status===`limited`){let n=e.limitedUntil===null?null:ma(e.limitedUntil-t);return(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-amber-600 dark:text-amber-400`,children:[(0,J.jsx)(`span`,{className:`size-1.5 rounded-full bg-amber-500`,"aria-hidden":`true`}),`Limited`,n!==null&&(0,J.jsxs)(J.Fragment,{children:[` `,`(`,(0,J.jsx)(`span`,{className:`tabular-nums`,children:n}),`)`]})]})}if(e.status===`disabled`)return(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-muted-foreground/60`,children:[(0,J.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/30`,"aria-hidden":`true`}),`Disabled`]});let n=e.lastErrorMessage??`Unknown error`;return(0,J.jsx)(kt,{children:(0,J.jsxs)(Et,{children:[(0,J.jsx)(Dt,{asChild:!0,children:(0,J.jsxs)(`span`,{className:`inline-flex cursor-default items-center gap-1.5 text-xs text-destructive`,children:[(0,J.jsx)(`span`,{className:`size-1.5 rounded-full bg-destructive`,"aria-hidden":`true`}),`Error`,(0,J.jsx)(`span`,{className:`sr-only`,children:n})]})}),(0,J.jsx)(Ot,{"aria-hidden":`true`,children:n})]})})}function ga({entry:e,now:t,isCurrent:n,concurrencyDefault:r,onRemove:i,onToggleDisabled:a,onTest:o,onChangeMaxConcurrent:s,onChangeBaseUrl:c,ports:l}){let u=l?.timer??wt,d=$(e=>e.tokenRowStates),f=$(e=>e.setTokenRowTesting),p=$(e=>e.setTokenRowTestResult),m=$(e=>e.baseUrlDrafts),h=$(e=>e.setBaseUrlDraft),g=d[e.id],_=g?.testResult??null,v=g?.testing??!1,y=m[e.id]??e.baseUrl??``,b=y.trim().length>0&&C(y)===null,x=L(`oauthPool.remove`,e.id),ee=L(`oauthPool.toggle`,e.id),S=L(`oauthPool.concurrency`,e.id),te=L(`oauthPool.baseUrl`,e.id),ne=L(`oauthPool.test`,e.id),w=F(x),re=F(ee),ie=F(S),ae=F(te),oe=()=>P(te,()=>c(e.id,y)),se=e=>{e.key===`Enter`&&e.currentTarget.blur()},ce=async()=>{f(e.id,!0),p(e.id,null);try{let t=await o(e.token,e.baseUrl),n=t.ok?`OK`:t.error??`Error`;p(e.id,n),u.setTimeout(()=>p(e.id,null),3e3)}catch{p(e.id,`Error`),u.setTimeout(()=>p(e.id,null),3e3)}finally{f(e.id,!1)}},T=e.status===`disabled`,ue=T?En:wn,E=e.maxConcurrent??r;return(0,J.jsxs)(`div`,{className:`border-t border-border py-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,J.jsx)(`span`,{className:`text-sm font-medium ${T?`text-muted-foreground/60`:`text-foreground`}`,children:e.label}),(0,J.jsx)(`code`,{className:`text-xs font-mono text-muted-foreground`,children:pa(e.token)}),n&&(0,J.jsx)(`span`,{className:`inline-flex shrink-0 items-center whitespace-nowrap rounded-full border border-primary/40 bg-primary/10 px-1.5 py-0.5 text-xs font-medium tracking-wide text-primary`,children:`In use`})]}),(0,J.jsx)(`div`,{className:`mt-0.5`,children:(0,J.jsx)(ha,{entry:e,now:t})})]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,J.jsx)(ct,{label:`Maximum concurrent chats sharing this OAuth token. Higher = risks Anthropic rate limits.`,children:(0,J.jsxs)(`label`,{className:`inline-flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,J.jsx)(`span`,{children:`Concurrent`}),ie?(0,J.jsx)(I,{className:`size-3`}):null,(0,J.jsx)(V,{type:`number`,value:E,readOnly:ie,"aria-busy":ie||void 0,onChange:t=>P(S,()=>s(e.id,he(Number(t.target.value)))),min:1,"aria-label":`Max concurrent chats`,className:`h-7 w-14 text-xs`,disabled:T})]})}),_!==null&&(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:_}),(0,J.jsxs)(`button`,{type:`button`,"aria-label":`Test`,onClick:()=>P(ne,ce),disabled:v||T,"aria-busy":v||void 0,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-xs text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50`,children:[v?(0,J.jsx)(I,{className:`size-3`}):(0,J.jsx)(mn,{className:`size-3`,"aria-hidden":`true`}),`Test`]}),(0,J.jsx)(kt,{children:(0,J.jsxs)(Et,{children:[(0,J.jsx)(Dt,{asChild:!0,children:(0,J.jsxs)(`button`,{type:`button`,"aria-label":T?`Enable`:`Disable`,onClick:()=>P(ee,a),disabled:re,"aria-busy":re||void 0,className:`rounded p-1 text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-default`,children:[re?(0,J.jsx)(I,{}):(0,J.jsx)(ue,{"aria-hidden":`true`,className:`size-3.5`}),(0,J.jsx)(`span`,{className:`sr-only`,children:T?`Enable`:`Disable`})]})}),(0,J.jsx)(Ot,{children:T?`Enable`:`Disable`})]})}),(0,J.jsxs)(`button`,{type:`button`,"aria-label":`Remove`,onClick:()=>P(x,i),disabled:w,"aria-busy":w||void 0,className:`rounded p-1 text-muted-foreground transition-colors hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-default`,children:[w?(0,J.jsx)(I,{}):(0,J.jsx)(le,{className:`size-3.5`,"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:`sr-only`,children:`Remove`})]})]})]}),(0,J.jsx)(ct,{label:`Anthropic API endpoint this token authenticates against. Leave empty for the default api.anthropic.com; set it to route this credential through a proxy.`,children:(0,J.jsxs)(`label`,{className:`mt-2 flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,J.jsx)(`span`,{className:`shrink-0`,children:`Base URL`}),ae?(0,J.jsx)(I,{className:`size-3`}):null,(0,J.jsx)(V,{value:y,readOnly:ae,"aria-busy":ae||void 0,onChange:t=>h(e.id,t.target.value),onBlur:oe,onKeyDown:se,placeholder:`(default)`,maxLength:512,"aria-label":`Anthropic base URL for ${e.label}`,className:`h-7 flex-1 text-xs font-mono`,disabled:T})]})}),b&&(0,J.jsx)(`div`,{className:`mt-1 text-xs text-destructive`,children:`Must start with http:// or https://`})]})}function _a({tokens:e,onWrite:t}){let n=$(e=>e.addLabel),r=$(e=>e.addToken),i=$(e=>e.addBaseUrl),a=$(e=>e.addSubmitting),o=$(e=>e.setAddLabel),s=$(e=>e.setAddToken),c=$(e=>e.setAddBaseUrl),l=$(e=>e.setAddSubmitting),u=$(e=>e.resetAddForm),d=C(i),f=i.trim().length>0&&d===null,p=n.trim().length>0&&r.trim().length>0&&!f&&!a,m=async()=>{if(p){l(!0);try{let i={id:crypto.randomUUID(),label:n.trim(),token:r.trim(),status:`active`,limitedUntil:null,lastUsedAt:null,lastErrorAt:null,lastErrorMessage:null,addedAt:Date.now(),...d===null?{}:{baseUrl:d}};await t({tokens:[...e,i]}),u()}finally{l(!1)}}};return(0,J.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-end sm:gap-3`,children:[(0,J.jsx)(`div`,{className:`flex-1`,children:(0,J.jsx)(V,{value:n,onChange:e=>o(e.target.value),placeholder:`e.g. personal`,maxLength:64,className:`text-sm`,"aria-label":`Token label`})}),(0,J.jsx)(`div`,{className:`flex-[2]`,children:(0,J.jsx)(V,{value:r,onChange:e=>s(e.target.value),type:`password`,placeholder:`sk-ant-...`,maxLength:1024,className:`text-sm font-mono`,"aria-label":`OAuth token`})}),(0,J.jsxs)(`button`,{type:`button`,onClick:()=>P(`oauthPool.add`,m),disabled:!p,"aria-busy":a||void 0,className:`inline-flex shrink-0 items-center gap-1.5 rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50`,children:[a?(0,J.jsx)(I,{}):null,`Add token`]})]}),(0,J.jsxs)(`div`,{className:`mt-2`,children:[(0,J.jsx)(V,{value:i,onChange:e=>c(e.target.value),placeholder:`Base URL — leave empty for api.anthropic.com`,maxLength:512,className:`text-sm font-mono`,"aria-label":`Anthropic base URL`}),f&&(0,J.jsx)(`div`,{className:`mt-1 text-xs text-destructive`,children:`Must start with http:// or https://`})]})]})}function va({tokens:e,concurrencyDefault:t,onWrite:n,onTest:r,now:i,ports:a}){let o=i??Date.now(),s=$(e=>e.clearBaseUrlDraft),c=e.reduce((e,t)=>t.lastUsedAt!==null&&(e===null||t.lastUsedAt>(e.lastUsedAt??0))?t:e,null)?.id??null,l=t=>n({tokens:e.filter(e=>e.id!==t)}),u=t=>n({tokens:e.map(e=>e.id===t?{...e,status:e.status===`disabled`?`active`:`disabled`}:e)}),d=(t,r)=>n({tokens:e.map(e=>e.id===t?{...e,maxConcurrent:r}:e)}),f=async(t,r)=>{let i=e.find(e=>e.id===t);if(!i)return;let a=C(r);a===null&&r.trim().length>0||(s(t),a!==(i.baseUrl??null)&&await n({tokens:e.map(e=>{if(e.id!==t)return e;let{baseUrl:n,...r}=e;return a===null?r:{...e,baseUrl:a}})}))},p=F(`oauthPool.concurrencyDefault`),m=e=>{P(`oauthPool.concurrencyDefault`,()=>n({concurrencyDefault:he(e)}))};return(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3 pb-3`,children:[(0,J.jsx)(ct,{label:`Default concurrent-chat cap applied to any OAuth token whose row does not override it. Sharing across N chats burns Anthropic quota and risks 429s.`,children:(0,J.jsxs)(`label`,{className:`flex flex-col gap-0.5 text-sm`,children:[(0,J.jsx)(`span`,{className:`font-medium text-foreground`,children:`Default concurrency per token`}),(0,J.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Cap for tokens without an explicit per-row override. Minimum `,1,`, no upper limit.`]})]})}),p?(0,J.jsx)(I,{className:`ml-auto text-muted-foreground`}):null,(0,J.jsx)(V,{type:`number`,value:t,readOnly:p,"aria-busy":p||void 0,onChange:e=>m(Number(e.target.value)),min:1,"aria-label":`Default concurrency per token`,className:`h-8 w-16 text-sm`})]}),e.map(e=>(0,J.jsx)(ga,{entry:e,now:o,isCurrent:e.id===c,concurrencyDefault:t,onRemove:()=>l(e.id),onToggleDisabled:()=>u(e.id),onTest:r,onChangeMaxConcurrent:d,onChangeBaseUrl:f,ports:a},e.id)),(0,J.jsx)(_a,{tokens:e,onWrite:n})]})}function ya(e,t){e.key===`Enter`&&(t(),e.currentTarget.blur())}function ba(e){let t={};for(let n of S)t[n]=Ce(e[n]??``);return{...u,...t}}function xa(e){return L(`settings.writeKeybindings`,e)}function Sa({action:e,currentValue:t,bordered:n,onDraftChange:r,onCommit:i,onRestoreDefault:a}){let o=xa(e),s=F(o),c=T(u[e]),l=t!==c,d=()=>{P(o,i)};return(0,J.jsx)(Z,{title:g[e],description:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{children:`Comma-separated shortcuts.`}),l?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{children:` `}),(0,J.jsxs)(`button`,{type:`button`,disabled:s,"aria-busy":s||void 0,onClick:()=>{P(o,()=>a(e))},className:`inline rounded text-foreground hover:text-foreground/80 disabled:opacity-60`,children:[`Restore: `,c]})]}):null]}),bordered:n,children:(0,J.jsxs)(`div`,{className:`flex min-w-0 max-w-[420px] flex-1 items-center gap-2`,children:[(0,J.jsx)(V,{type:`text`,value:t,"aria-busy":s||void 0,onChange:t=>r(e,t.target.value),onBlur:d,onKeyDown:e=>ya(e,d),className:`font-mono`}),s?(0,J.jsx)(I,{}):null]})})}function Ca({state:e}){let t=s(e=>e.keybindingDrafts),n=s(e=>e.setKeybindingDrafts),r=s(e=>e.setKeybindingDraft),i=s(e=>e.keybindingsError),a=s(e=>e.setKeybindingsError),o=(0,q.useMemo)(()=>_e(e.keybindings),[e.keybindings]);(0,q.useEffect)(()=>{n(Object.fromEntries(S.map(e=>[e,T(o.bindings[e])])))},[o,n]);async function c(t){try{a(null),await e.socket.command({type:`settings.writeKeybindings`,bindings:ba(t)})}catch(e){a(e instanceof Error?e.message:`Unable to save keybindings.`)}}async function l(){await c(t)}async function d(e){let r={...t,[e]:T(u[e])};n(r),await c(r)}return(0,J.jsxs)(`div`,{className:`border-b border-border`,children:[i?(0,J.jsx)(`div`,{className:`mb-4 rounded-lg border border-destructive/20 bg-destructive/5 px-4 py-3 text-sm text-destructive`,children:i}):null,o.warning?(0,J.jsx)(`div`,{className:`mb-4 rounded-lg border border-border bg-card/30 px-4 py-3 text-sm text-muted-foreground`,children:o.warning}):null,S.map((e,n)=>(0,J.jsx)(Sa,{action:e,currentValue:t[e]??``,bordered:n!==0,onDraftChange:r,onCommit:l,onRestoreDefault:d},e))]})}var wa=`always`,Ta=`funk`,Ea=[{value:`blow`,label:`Blow`},{value:`bottle`,label:`Bottle`},{value:`frog`,label:`Frog`},{value:`funk`,label:`Funk`},{value:`glass`,label:`Glass`},{value:`ping`,label:`Ping`},{value:`pop`,label:`Pop`},{value:`purr`,label:`Purr`},{value:`tink`,label:`Tink`}];function Da(e){switch(e){case`never`:case`unfocused`:case`always`:return e;default:return wa}}function Oa(e){switch(e){case`blow`:case`bottle`:case`frog`:case`funk`:case`glass`:case`ping`:case`pop`:case`purr`:case`tink`:return e;default:return Ta}}var ka=k()(e=>({chatSoundPreference:wa,chatSoundId:Ta,setChatSoundPreference:t=>e({chatSoundPreference:Da(t)}),setChatSoundId:t=>e({chatSoundId:Oa(t)})})),Aa=`inline-flex items-center justify-center rounded-lg border border-border bg-background px-3 py-1.5 text-sm font-medium text-foreground transition-colors hover:bg-muted`,ja=`inline-flex items-center justify-center rounded-lg bg-foreground px-3 py-1.5 text-sm font-medium text-background transition-colors hover:bg-foreground/90`,Ma=`rounded bg-muted px-1 py-0.5 font-mono text-12 text-foreground`,Na=`text-xs font-medium tracking-wide text-muted-foreground`,Pa=`gap-1.5 disabled:cursor-default disabled:opacity-60`,Fa=`push.enable`,Ia=`push.test`,La=`push.disable`,Ra=`push.contactSubject`;async function za(e){try{await e(),s.getState().setPushError(null)}catch(e){s.getState().setPushError(je(e))}}function Ba(e,t){P(e,()=>za(t))}function Va(){let e=s(e=>e.pushError);return e?(0,J.jsx)(`p`,{role:`alert`,className:`rounded-lg border border-destructive/20 bg-destructive/10 px-3 py-2 text-sm text-destructive-text`,children:e}):null}function Ha({pendingKey:e,onRun:t,className:n,label:r,children:i}){let a=F(e);return(0,J.jsxs)(`button`,{type:`button`,onClick:()=>Ba(e,t),disabled:a,"aria-busy":a||void 0,"aria-label":r,className:j(n,Pa),children:[a?(0,J.jsx)(I,{}):null,i]})}function Ua({localPath:e,muted:t,onMuteToggle:n}){let r=L(`push.setProjectMute`,e),i=F(r);return(0,J.jsxs)(`label`,{"aria-busy":i||void 0,className:`flex cursor-pointer items-center gap-3 rounded-md px-2 py-1.5 transition-colors hover:bg-muted/50`,children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:!t,disabled:i,onChange:t=>Ba(r,()=>n(e,!t.target.checked)),className:`h-4 w-4 shrink-0 rounded border-border accent-foreground`}),(0,J.jsx)(ot,{inline:!0,className:`min-w-0 flex-1 font-mono text-12 text-foreground`,tooltip:e,children:e}),i?(0,J.jsx)(I,{className:`text-muted-foreground`}):null]})}function Wa(e){let{permissionState:t}=e,n=F(Ra);if(t===`unsupported`)return(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Push notifications are not supported in this browser.`});if(t===`insecure-context`)return(0,J.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Push requires HTTPS. Run `,(0,J.jsx)(`code`,{className:Ma,children:`kanna --share`}),` or open Kanna over a tunnel, then enable on this device.`]});if(t===`denied`)return(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`You blocked notifications for this site. Re-enable them in your browser settings, then reload.`}),(0,J.jsx)(Va,{})]});if(!(t===`granted`&&e.config.devices.some(t=>t.id===e.currentDeviceId)))return(0,J.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col items-start gap-2 md:w-[440px]`,children:[(0,J.jsx)(Ha,{pendingKey:Fa,onRun:e.onEnable,className:ja,children:`Enable on this device`}),(0,J.jsx)(Va,{})]});let r=new Set(e.config.preferences.mutedProjectPaths),i=e.contactSubjectDraft.trim(),a=Pn(i),o=i!==e.contactSubject,s=()=>{a&&o&&Ba(Ra,()=>e.onContactSubjectSave(i))};return(0,J.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col gap-5 md:w-[440px]`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-2 rounded-full border border-border bg-card/40 px-3 py-1 text-xs font-medium text-foreground`,children:[(0,J.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-emerald-500`,"aria-hidden":!0}),`Enabled on this device`]}),(0,J.jsx)(Ha,{pendingKey:Ia,onRun:e.onTest,className:Aa,children:`Send test`}),(0,J.jsx)(Ha,{pendingKey:La,onRun:e.onDisable,className:Aa,children:`Disable`})]}),(0,J.jsx)(Va,{}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsxs)(`div`,{className:j(Na,`flex items-center gap-1.5`),children:[`Contact for delivery`,n?(0,J.jsx)(I,{}):null]}),(0,J.jsx)(V,{type:`text`,inputMode:`email`,spellCheck:!1,autoCapitalize:`none`,value:e.contactSubjectDraft,readOnly:n,"aria-busy":n||void 0,onChange:t=>e.onContactSubjectDraftChange(t.target.value),onBlur:s,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),s())},placeholder:`mailto:you@example.com`,"aria-label":`Push contact subject`,"aria-invalid":i!==``&&!a,className:j(`font-mono`,i!==``&&!a&&`border-destructive`)}),i!==``&&!a?(0,J.jsxs)(`p`,{className:`text-xs text-destructive`,children:[`Must be a `,(0,J.jsx)(`code`,{className:Ma,children:`mailto:`}),` address or`,` `,(0,J.jsx)(`code`,{className:Ma,children:`https:`}),` URL with a routable domain (not localhost).`]}):(0,J.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Push services require a contact `,(0,J.jsx)(`code`,{className:Ma,children:`mailto:`}),` or`,` `,(0,J.jsx)(`code`,{className:Ma,children:`https:`}),` URL to sign notifications. Set your own so delivery isn’t rejected.`]})]}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(`div`,{className:Na,children:`Devices`}),(0,J.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:e.config.devices.map(t=>(0,J.jsxs)(`li`,{className:`flex items-start justify-between gap-3 rounded-lg border border-border bg-card/40 px-3 py-2`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,J.jsx)(`span`,{className:`truncate text-sm font-medium text-foreground`,children:t.label}),(0,J.jsx)(`span`,{className:`line-clamp-2 break-all text-xs leading-snug text-muted-foreground`,children:t.userAgent})]}),!t.isCurrentDevice&&(0,J.jsx)(Ha,{pendingKey:L(`push.unsubscribe`,t.id),onRun:()=>e.onRemoveDevice(t.id),label:`Remove ${t.label}`,className:`inline-flex shrink-0 items-center rounded-md border border-border bg-background px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:`Remove`})]},t.id))})]}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(`div`,{className:Na,children:`Per-project`}),(0,J.jsx)(`ul`,{className:`flex flex-col`,children:e.projects.map(t=>(0,J.jsx)(`li`,{children:(0,J.jsx)(Ua,{localPath:t.localPath,muted:r.has(t.localPath),onMuteToggle:e.onMuteToggle})},t.localPath))})]}),(0,J.jsxs)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:[`Phone setup: this page must be reachable over HTTPS. Run`,` `,(0,J.jsx)(`code`,{className:Ma,children:`kanna --share`}),` or open Kanna over your tunnel on the phone, then enable on that device.`]})]})}var Ga=L(`packages.checkUpdates`);function Ka(e){return L(`packages.update`,e)}async function qa(e,t){try{await e.command(t),pt.getState().setCommandError(null)}catch(e){throw pt.getState().setCommandError(je(e)),e}}var Ja=[],Ya=[],Xa=[],Za=[];function Qa(e){return typeof e==`object`&&!!e&&`packages`in e&&`errors`in e}var $a={up_to_date:`Up to date`,outdated:`Outdated`,partial:`Partial`,unknown:`Unknown`};function eo({pkg:e,packageEntry:t,applying:n,onUpdate:r}){let i=F(Ka(e.id)),a=n||i,o=t?.update.availability,s=e.versionLabel??e.version??e.revision?.slice(0,7)??null,c=o&&o!==`up_to_date`?ni[o]:null;return(0,J.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3 rounded-lg border border-border bg-card/30 p-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:e.name}),s?(0,J.jsx)(`div`,{className:`font-mono tabular-nums text-xs text-muted-foreground/70`,children:s}):null]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2`,children:[c?(0,J.jsx)(`span`,{className:j(`rounded-full border px-2 py-0.5 text-xs font-medium`,c),children:$a[o]}):null,o===`outdated`||o===`partial`?(0,J.jsxs)(A,{type:`button`,size:`sm`,variant:`secondary`,disabled:a,"aria-busy":a||void 0,onClick:r,className:`h-6 rounded-full px-2 text-xs`,children:[a?(0,J.jsx)(M,{className:`mr-1 h-3 w-3 animate-spin`}):null,`Update`]}):null,e.sourceUrl?(0,J.jsx)(`a`,{href:e.sourceUrl,target:`_blank`,rel:`noreferrer`,"aria-label":`View ${e.name} source`,className:`touch-manipulation inline-flex h-8 w-8 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,J.jsx)(at,{className:`h-4 w-4`})}):null]})]})}function to({source:e,packages:t,updateEntries:n,applying:r,isChecking:i,onCheckUpdates:a,onUpdate:o}){return(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,J.jsx)(`div`,{className:`text-xs font-medium tracking-wide text-muted-foreground`,children:e}),(0,J.jsxs)(A,{size:`sm`,variant:`ghost`,className:`h-6 rounded-full px-2 text-xs`,disabled:i,"aria-busy":i||void 0,onClick:a,children:[i?(0,J.jsx)(M,{className:`mr-1 h-3 w-3 animate-spin`}):(0,J.jsx)(Ke,{className:`mr-1 h-3 w-3`}),`Refresh`]})]}),(0,J.jsx)(`div`,{className:`grid gap-2 md:grid-cols-2`,children:t.map(e=>{let t=n.find(t=>t.id===e.id)??null;return(0,J.jsx)(eo,{pkg:e,packageEntry:t,applying:r.includes(e.id),onUpdate:()=>o(e.id)},e.id)})})]})}function no({label:e,kind:t,packages:n,errors:r,updateEntries:i,applying:a,isChecking:o,onCheckUpdates:s,onUpdate:c}){let l=r.find(e=>e.kind===t),u=n.filter(e=>e.kind===t),d=new Map;for(let e of u){let t=e.source||`Unknown`,n=d.get(t);n?n.push(e):d.set(t,[e])}let f=t===`claude-plugin`?`Claude Code CLI`:`Codex CLI`,p;return p=l?(0,J.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/30 p-3 text-sm text-muted-foreground`,children:[f,` not found — install it to manage `,e,` plugins.`]}):u.length===0?(0,J.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/30 p-3 text-sm text-muted-foreground`,children:[`No `,e,` plugins installed.`]}):(0,J.jsx)(`div`,{className:`flex flex-col gap-4`,children:[...d.entries()].map(([e,t])=>(0,J.jsx)(to,{source:e,packages:t,updateEntries:i,applying:a,isChecking:o,onCheckUpdates:s,onUpdate:c},e))}),(0,J.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,J.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:e}),p]})}function ro({state:e}){let{socket:t,connectionStatus:n}=e,r=s(e=>e.pluginInventory),i=s(e=>e.pluginInventoryLoading),a=s(e=>e.pluginInventoryError),o=s(e=>e.setPluginInventory),c=s(e=>e.setPluginInventoryLoading),l=s(e=>e.setPluginInventoryError),u=s(e=>e.packageUpdateSnapshot),d=(0,q.useCallback)(async()=>{if(n!==`connected`){o(null),l(null),c(!1);return}try{c(!0),l(null);let e=await t.command({type:`packages.listInstalled`});if(!Qa(e))throw Error(`packages.listInstalled: unexpected response`);o(e)}catch(e){l(e instanceof Error?e.message:`Unable to load plugins.`)}finally{c(!1)}},[n,t,o,c,l]);(0,q.useEffect)(()=>{qt(`packages.listInstalled`,d())},[d]);let f=(0,q.useCallback)(()=>{P(Ga,()=>qa(t,{type:`packages.checkUpdates`}))},[t]),p=(0,q.useCallback)(e=>{P(Ka(e),()=>qa(t,{type:`packages.update`,id:e}))},[t]),m=F(Ga),h=u?.status===`checking`||m,g=u?.applying??Za,_=u?.packages.filter(e=>e.kind===`claude-plugin`||e.kind===`codex-plugin`)??Xa,v=r?.packages??Ja,y=r?.errors??Ya;return a?(0,J.jsx)(`div`,{className:`rounded-lg border border-destructive/20 bg-destructive/5 px-4 py-3 text-sm text-destructive`,children:a}):i&&!r?(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,J.jsx)(M,{className:`h-3.5 w-3.5 animate-spin`}),`Loading…`]}):(0,J.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,J.jsx)(no,{label:`Claude Code`,kind:`claude-plugin`,packages:v,errors:y,updateEntries:_,applying:g,isChecking:h,onCheckUpdates:f,onUpdate:p}),(0,J.jsx)(no,{label:`Codex`,kind:`codex-plugin`,packages:v,errors:y,updateEntries:_,applying:g,isChecking:h,onCheckUpdates:f,onUpdate:p})]})}function io(e){return e.map(e=>({...e,disabled:!0}))}function ao({pendingKey:e,value:t,onValueChange:n,options:r,size:i}){let a=F(e);return(0,J.jsxs)(`div`,{className:`inline-flex items-center gap-2`,"aria-busy":a||void 0,children:[a?(0,J.jsx)(I,{className:`text-muted-foreground`}):null,(0,J.jsx)(At,{value:t,onValueChange:t=>P(e,()=>n(t)),options:a?io(r):r,size:i})]})}var oo=k()(e=>({publicUrlDraft:null,copiedSnippetId:null,error:null,setPublicUrlDraft:t=>e({publicUrlDraft:t}),setCopiedSnippetId:t=>e({copiedSnippetId:t}),setError:t=>e({error:t})})),so=`<your Kanna password>`,co=`Start Kanna with --password first; the remote MCP server is off without it. `,lo=`The URL must be https and reachable from the internet (a Cloudflare tunnel or --share).`;function uo(e){return`${e}/mcp`}function fo({publicOrigin:e,passwordConfigured:t}){let n=uo(e??`https://<your-public-kanna-url>`),r=t?``:co;return[{id:`claude-code`,client:`claude-code`,title:`Claude Code`,instructions:`${r}Add the server with your Kanna password as a bearer header, or add it without one and sign in through OAuth.`,snippet:[`claude mcp add --transport http kanna ${n} --header "Authorization: Bearer ${so}"`,``,`claude mcp add --transport http kanna ${n}`,`# then run /mcp inside Claude Code and choose Authenticate to sign in with OAuth`].join(`
|
|
10
|
-
`)},{id:`codex`,client:`codex`,title:`Codex`,instructions:`${r}Put the block in ~/.codex/config.toml and export your Kanna password as KANNA_PASSWORD, or sign in through OAuth instead.`,snippet:[`[mcp_servers.kanna]`,`url = "${n}"`,`bearer_token_env_var = "KANNA_PASSWORD"`,``,`# OAuth alternative: drop bearer_token_env_var and run`,`codex mcp login kanna`].join(`
|
|
11
|
-
`)},{id:`claude-desktop`,client:`claude-desktop`,title:`Claude Desktop and claude.ai`,instructions:`${r}Open Settings, Connectors, Add custom connector and enter the URL. Add the request header below, or leave it empty to sign in through OAuth. ${lo}`,snippet:[`URL: ${n}`,`Header: Authorization: Bearer ${so}`].join(`
|
|
12
|
-
`)},{id:`chatgpt`,client:`chatgpt`,title:`ChatGPT`,instructions:`${r}Open chatgpt.com/plugins, select the plus button, then Add custom MCP server; enter the URL and choose OAuth as the authentication. ${lo}`,snippet:[`URL: ${n}`,`Authentication: OAuth`].join(`
|
|
13
|
-
`)}]}var po=L(`settings.remoteMcp`,`enabled`),mo=L(`settings.remoteMcp`,`publicUrl`),ho=2e3,go=[{value:`enabled`,label:`Enabled`},{value:`disabled`,label:`Disabled`}];function _o(e){try{return new URL(e).origin}catch{return``}}function vo({snippet:e}){let t=oo(t=>t.copiedSnippetId===e.id),n=oo(e=>e.setCopiedSnippetId),r=(0,q.useCallback)(async()=>{await Ze.writeText(e.snippet),n(e.id),wt.setTimeout(()=>n(null),ho)},[e.id,e.snippet,n]);return(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-card/30 p-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,J.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:e.title}),(0,J.jsx)(A,{type:`button`,variant:`ghost`,size:`icon-mobile`,"aria-label":t?`Copied ${e.title} setup`:`Copy ${e.title} setup`,className:`text-muted-foreground hover:text-foreground`,onClick:()=>qt(`copy remote MCP setup`,r()),children:t?(0,J.jsx)(Xe,{className:`h-4 w-4 text-success-text`}):(0,J.jsx)(Ye,{className:`h-4 w-4`})})]}),(0,J.jsx)(`p`,{className:`text-13 text-muted-foreground`,children:e.instructions}),(0,J.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap break-all rounded-md border border-border bg-muted p-2 font-mono text-xs text-foreground`,children:e.snippet})]})}function yo({state:e,dom:t=Ae}){let n=H(Nt),r=s(e=>e.authEnabled),i=oo(e=>e.publicUrlDraft),a=oo(e=>e.setPublicUrlDraft),o=oo(e=>e.error),c=oo(e=>e.setError),l=F(mo),u=i??n.publicUrl??``,d=u.trim(),f=d!==``&&Mt(d)===null,p=d!==(n.publicUrl??``),m=n.publicUrl??Mt(_o(t.getHref())),h=fo({publicOrigin:m,passwordConfigured:r}),g=(0,q.useCallback)(t=>e.handleWriteAppSettings({remoteMcp:{enabled:t===`enabled`}}),[e]),_=(0,q.useCallback)(async()=>{c(null);try{await e.handleWriteAppSettings({remoteMcp:{publicUrl:d===``?null:d}}),a(null)}catch(e){c(je(e))}},[e,d,a,c]);return(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-1 pb-2`,children:[(0,J.jsx)(`h2`,{className:`text-base font-medium`,children:`Remote MCP`}),(0,J.jsx)(`p`,{className:`max-w-[65ch] text-sm text-muted-foreground`,children:`Let other agents and apps drive Kanna over the Model Context Protocol: Claude Code, Codex, Claude Desktop and ChatGPT can list projects, run chats, move board cards and more.`})]}),r?null:(0,J.jsx)(`div`,{className:`rounded-lg border border-border bg-card/30 px-4 py-3 text-sm text-muted-foreground`,children:`Set --password when starting Kanna to enable the remote MCP server`}),(0,J.jsxs)(`div`,{className:`border-b border-border`,children:[(0,J.jsx)(Z,{title:`Remote MCP server`,description:`Serves the /mcp endpoint and the OAuth sign-in pages. Turn it off to answer 404 on all of them.`,children:(0,J.jsx)(ao,{pendingKey:po,value:n.enabled?`enabled`:`disabled`,onValueChange:g,options:go,size:`sm`})}),(0,J.jsx)(Z,{title:`Public URL`,description:`https URL, or http on localhost; the OAuth issuer and resource are derived from it. Leave empty to use this machine's loopback address.`,alignStart:!0,children:(0,J.jsxs)(`div`,{className:`flex w-full flex-col gap-2 md:w-[420px]`,children:[(0,J.jsx)(V,{value:u,onChange:e=>a(e.target.value),placeholder:`https://kanna.example.com`,"aria-label":`Public URL`,"aria-invalid":f||void 0,spellCheck:!1}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-xs`,children:[(0,J.jsx)(`span`,{className:f?`text-destructive-text`:`text-muted-foreground`,children:f?`Enter an https URL, or an http URL on localhost`:`Path, query and trailing slash are dropped`}),(0,J.jsx)(A,{type:`button`,size:`sm`,disabled:!p||f,onClick:()=>P(mo,_),pending:l,children:`Save`})]}),o?(0,J.jsx)(`div`,{className:`text-xs text-destructive-text`,children:o}):null]})}),(0,J.jsx)(Z,{title:`Endpoint`,description:`Give this URL to your MCP client.`,bordered:!0,children:m?(0,J.jsxs)(`code`,{className:`break-all rounded-md border border-border bg-muted px-2 py-1 font-mono text-xs`,children:[m,`/mcp`]}):(0,J.jsx)(`span`,{className:`text-13 text-muted-foreground`,children:`Set a public URL to see the endpoint`})})]}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-3 pt-4`,children:[(0,J.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:`Connect a client`}),(0,J.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:h.map(e=>(0,J.jsx)(vo,{snippet:e},e.id))})]})]})}function bo(e){let{pushConfig:t,socket:n}=e,r=s(e=>e.pushDeviceId),i=s(e=>e.setPushDeviceId),a=s(e=>e.setPushPermissionState);return{handleEnablePush:(0,q.useCallback)(async()=>{if(t)try{let e=await rt({vapidPublicKey:t.vapidPublicKey,sendToServer:async e=>{let t=await n.command({type:`push.subscribe`,subscription:e.subscription,label:e.label,userAgent:e.userAgent});return st(t.id),{id:t.id}}});i(e)}finally{a(lt().state)}},[t,n,i,a]),handleDisablePush:(0,q.useCallback)(async()=>{r&&(await ut({pushDeviceId:r,sendToServer:async e=>{await n.command({type:`push.unsubscribe`,pushDeviceId:e})}}),ft(),i(null))},[r,n,i])}}function xo(e){return e===`openai`?Ln:e===`openrouter`?ce:``}function So(e,t){return{...e,provider:t,model:xo(t),baseUrl:t===`custom`?e.baseUrl:``}}function Co(e,t){if(!e.pinnedRef)return null;let n=t.latestVersion;return!n||n===e.pinnedRef?null:n}var wo={up_to_date:`Up to date`,outdated:`Outdated`,partial:`Partial`,unknown:`Unknown`};function To(e){if(!e)return null;let t=Co(e,e.update);if(t)return`Re-pin to ${t}`;if(e.pinnedRef)return null;let n=e.update.availability;return n===`outdated`||n===`partial`?`Update`:null}function Eo({skill:e,packageEntry:t,uninstalling:n,applying:r,onUninstall:i,onUpdate:a}){let o=e.source?`https://skills.sh/${e.source}/${e.name}`:null,s=t?.update.availability,c=t?.versionLabel??t?.revision?.slice(0,7)??t?.updatedAt??null,l=s&&s!==`up_to_date`?ni[s]:null,u=t?.pinnedRef??null,d=To(t);return(0,J.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3 rounded-lg border border-border bg-card/30 p-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:e.name}),(0,J.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.source||`Unknown source`}),c?(0,J.jsx)(`div`,{className:`font-mono tabular-nums text-xs text-muted-foreground/70`,children:c}):null,u?(0,J.jsxs)(`div`,{className:`truncate font-mono tabular-nums text-xs text-muted-foreground/70`,children:[`Pinned `,u]}):null]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2`,children:[l?(0,J.jsx)(`span`,{className:j(`rounded-full border px-2 py-0.5 text-xs font-medium`,l),children:wo[s]}):null,d?(0,J.jsxs)(A,{type:`button`,size:`sm`,variant:`secondary`,disabled:r,onClick:a,className:`h-6 rounded-full px-2 text-xs`,children:[r?(0,J.jsx)(M,{className:`mr-1 h-3 w-3 animate-spin`}):null,d]}):null,o?(0,J.jsx)(`a`,{href:o,target:`_blank`,rel:`noreferrer`,"aria-label":`View ${e.name} on skills.sh`,className:`touch-manipulation inline-flex h-8 w-8 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,J.jsx)(at,{className:`h-4 w-4`})}):null,(0,J.jsx)(`button`,{type:`button`,"aria-label":`Uninstall ${e.name}`,disabled:n,onClick:i,className:`touch-manipulation inline-flex h-8 w-8 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive disabled:pointer-events-none disabled:opacity-50`,children:n?(0,J.jsx)(M,{className:`h-4 w-4 animate-spin`}):(0,J.jsx)(le,{className:`h-4 w-4`})})]})]})}function Do(e){return!e||e<=0?`0 installs`:e>=1e6?`${(e/1e6).toFixed(1).replace(/\.0$/,``)}M installs`:e>=1e3?`${(e/1e3).toFixed(1).replace(/\.0$/,``)}K installs`:`${e} install${e===1?``:`s`}`}var Oo=L(`packages.checkUpdates`),ko=L(`packages.updateAll`,`skill`);function Ao(e){return`skill:${e}`}function jo({skill:e,packageEntry:t,uninstalling:n,applying:r,onUninstall:i,onUpdate:a}){let o=Ao(e.name),s=F(L(`packages.update`,o)),c=F(L(`skills.uninstall`,e.name));return(0,J.jsx)(Eo,{skill:e,packageEntry:t,uninstalling:n||c,applying:r||s,onUninstall:()=>i(e),onUpdate:()=>a(o)})}function Mo({message:e}){return(0,J.jsx)(`pre`,{className:`max-w-full overflow-x-auto whitespace-pre-wrap rounded-lg border border-destructive/20 bg-destructive/5 px-4 py-3 text-xs text-destructive`,children:e})}function No({skill:e,installing:t,installed:n,message:r,onInstall:i}){let a;return a=n?`Installed`:t?`Installing`:`Get`,(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3 rounded-lg border border-border bg-card/30 p-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:e.name}),(0,J.jsxs)(`div`,{className:`truncate text-xs text-muted-foreground`,children:[e.source,` · `,Do(e.installs)]}),n&&r?(0,J.jsx)(`div`,{className:`mt-1 truncate text-xs text-emerald-500`,children:r}):null]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,J.jsx)(`a`,{href:`https://skills.sh/${e.id}`,target:`_blank`,rel:`noreferrer`,"aria-label":`View ${e.name} on skills.sh`,className:`touch-manipulation inline-flex h-8 w-8 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,J.jsx)(at,{className:`h-4 w-4`})}),(0,J.jsxs)(A,{type:`button`,size:`sm`,variant:n?`secondary`:`default`,disabled:t||n,onClick:i,className:`h-6 rounded-full px-2 text-xs`,children:[t?(0,J.jsx)(M,{className:`mr-1.5 h-3.5 w-3.5 animate-spin`}):null,a]})]})]})}function Po({state:e,ports:t}){let n=t?.timer??wt,r=e.socket,i=e.connectionStatus,a=s(e=>e.skillQuery),o=s(e=>e.setSkillQuery),c=s(e=>e.skillResults),l=s(e=>e.setSkillResults),u=s(e=>e.skillSearchLoading),d=s(e=>e.setSkillSearchLoading),f=s(e=>e.skillSearchError),p=s(e=>e.setSkillSearchError),m=s(e=>e.installedSkills),h=s(e=>e.setInstalledSkills),g=s(e=>e.installedSkillIds),_=s(e=>e.setInstalledSkillIds),v=s(e=>e.addInstalledSkillId),y=s(e=>e.removeInstalledSkillId),b=s(e=>e.installedLoading),x=s(e=>e.setInstalledLoading),ee=s(e=>e.installedError),S=s(e=>e.setInstalledError),te=s(e=>e.skillOperationError),C=s(e=>e.setSkillOperationError),ne=s(e=>e.installingSkillId),w=s(e=>e.setInstallingSkillId),re=s(e=>e.uninstallingSkillId),ie=s(e=>e.setUninstallingSkillId),ae=s(e=>e.installMessages),oe=s(e=>e.setInstallMessage),se=s(e=>e.clearInstallMessage),ce=s(e=>e.clearInstallMessagesForSkill),T=s(e=>e.packageUpdateSnapshot),le=T?.status===`checking`,ue=T?.packages.filter(e=>e.kind===`skill`&&!e.pinnedRef).filter(e=>e.update.availability===`outdated`||e.update.availability===`partial`).map(e=>e.id)??[],E=ue.length,de=T?.lastCheckedAt?new Date(T.lastCheckedAt).toLocaleTimeString():null,fe=F(Oo),D=F(ko),pe=le||fe;async function me(e){try{C(null),await r.command(e)}catch(e){throw C(je(e)),e}}function he(){P(Oo,()=>me({type:`packages.checkUpdates`}))}function O(e){P(L(`packages.update`,e),()=>me({type:`packages.update`,id:e}))}function ge(){ue.length!==0&&P(ko,()=>me({type:`packages.updateAll`,ids:ue}))}function _e(e){P(L(`skills.install`,e.id),()=>be(e))}function ve(e){P(L(`skills.uninstall`,e.name),()=>xe(e))}let ye=(0,q.useCallback)(async()=>{if(i!==`connected`){h([]),_(new Set),S(null),x(!1);return}try{x(!0),S(null);let e=await r.command({type:`skills.listInstalled`});h(e.skills),_(new Set(e.skills.map(e=>e.name)))}catch(e){h([]),_(new Set),S(e instanceof Error?e.message:`Unable to read installed skills.`)}finally{x(!1)}},[i,r,h,_,S,x]);(0,q.useEffect)(()=>{qt(`skills.listInstalled`,ye())},[i,ye,r]),(0,q.useEffect)(()=>{let e=a.trim();if(e.length<2){l([]),p(null),d(!1);return}if(i!==`connected`){l([]),d(!1),p(`Backend connection required.`);return}let t=!1;d(!0),p(null);let o=n.setTimeout(()=>{r.command({type:`skills.search`,query:e,limit:100}).then(e=>{t||l(e.skills)}).catch(e=>{t||(l([]),p(e instanceof Error?e.message:`Unable to search skills.`))}).finally(()=>{t||d(!1)})},250);return()=>{t=!0,n.clearTimeout(o)}},[i,a,r,l,p,d,n]);async function be(e){if(i!==`connected`){C(`Backend connection required.`);return}try{w(e.id),C(null),se(e.id),await r.command({type:`skills.install`,source:e.source,skillId:e.skillId}),v(e.skillId),oe(e.id,`Installed globally`),qt(`skills.listInstalled`,ye())}catch(e){C(e instanceof Error?e.message:`Install failed.`)}finally{w(null)}}async function xe(e){if(i!==`connected`){C(`Backend connection required.`);return}try{ie(e.name),C(null),await r.command({type:`skills.uninstall`,skillId:e.name}),h(m.filter(t=>t.name!==e.name)),y(e.name),ce(e.name),qt(`skills.listInstalled`,ye())}catch(e){C(e instanceof Error?e.message:`Uninstall failed.`)}finally{ie(null)}}let Se;return Se=m.length>0?(0,J.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:m.map(e=>(0,J.jsx)(jo,{skill:e,packageEntry:T?.packages.find(t=>t.kind===`skill`&&t.name===e.name)??null,uninstalling:re===e.name,applying:T?.applying.includes(Ao(e.name))??!1,onUninstall:ve,onUpdate:O},`${e.source}/${e.name}`))}):b?null:(0,J.jsx)(`div`,{className:`rounded-lg border border-border bg-card/30 p-3 text-sm text-muted-foreground`,children:`No global skills installed.`}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[te?(0,J.jsx)(Mo,{message:te}):null,(0,J.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,J.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:`Installed`}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[de?(0,J.jsxs)(`span`,{className:`tabular-nums text-xs text-muted-foreground`,children:[`Checked `,de]}):null,E>0?(0,J.jsxs)(A,{size:`sm`,variant:`secondary`,className:`h-6 rounded-full px-2 text-xs`,pending:D,onClick:ge,children:[`Update all (`,E,`)`]}):null,(0,J.jsxs)(A,{size:`sm`,variant:`ghost`,className:`h-6 rounded-full px-2 text-xs`,disabled:pe,"aria-busy":pe||void 0,onClick:he,children:[pe?(0,J.jsx)(M,{className:`mr-1 h-3 w-3 animate-spin`}):null,`Check`]}),b?(0,J.jsx)(M,{className:`h-3.5 w-3.5 animate-spin text-muted-foreground`}):null]})]}),ee?(0,J.jsx)(`div`,{className:`text-xs text-destructive`,children:ee}):null,Se]}),(0,J.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,J.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:`Discover`}),(0,J.jsxs)(`div`,{className:`flex h-10 items-center gap-2 rounded-lg border border-border bg-card/30 px-3`,children:[(0,J.jsx)(Ge,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,J.jsx)(`input`,{type:`text`,role:`searchbox`,value:a,onChange:e=>o(e.target.value),placeholder:`Search skills`,className:`min-w-0 flex-1 bg-transparent text-sm text-foreground outline-none placeholder:text-muted-foreground`}),a?(0,J.jsx)(`button`,{type:`button`,"aria-label":`Clear skills search`,onClick:()=>o(``),className:`touch-manipulation inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,J.jsx)(yt,{className:`h-3.5 w-3.5`})}):null,u?(0,J.jsx)(M,{className:`h-4 w-4 shrink-0 animate-spin text-muted-foreground`}):null]}),f?(0,J.jsx)(`div`,{className:`text-xs text-destructive`,children:f}):null,(0,J.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:c.map(e=>(0,J.jsx)(No,{skill:e,installing:ne===e.id,installed:g.has(e.skillId),message:ae[e.id],onInstall:()=>{_e(e)}},e.id))}),!u&&!f&&a.trim().length>=2&&c.length===0?(0,J.jsx)(`div`,{className:`rounded-lg border border-border bg-card/30 p-3 text-sm text-muted-foreground`,children:`No skills found.`}):null]})]})}function Fo(e){return{async onReload(t){if(!(await e(`/api/plugins/${t}/reload`,{})).ok)throw Error(`Failed to reload plugin ${t}`)}}}function Io({plugins:e,handlers:t}){return e.length===0?(0,J.jsx)(br,{icon:E,message:`No plugins installed yet.`}):(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:`Plugins`}),(0,J.jsx)(xr,{children:e.map(e=>(0,J.jsx)(Lo,{plugin:e,onReload:t.onReload},e.id))})]})}function Lo({plugin:e,onReload:t}){let n=L(`plugins.reload`,e.id),r=F(n),i=(0,q.useCallback)(()=>{P(n,async()=>{try{await t(e.id),pt.getState().setCommandError(null)}catch(e){throw pt.getState().setCommandError(je(e)),e}})},[t,e.id,n]);return(0,J.jsxs)(`li`,{className:`flex items-center justify-between gap-3 px-4 py-3`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,J.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`truncate text-sm font-medium text-foreground`,children:e.id}),(0,J.jsx)(Zt,{tone:e.enabled?`active`:`muted`,label:e.enabled?`Enabled`:`Disabled`})]}),(0,J.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e.sourceDir})]}),(0,J.jsx)(A,{variant:`ghost`,size:`sm`,"data-testid":`plugin-reload:${e.id}`,pending:r,onClick:i,children:`Reload`})]})}async function Ro(e,t){return{ok:(await Je.postJsonBody(e,t)).ok}}var zo=Fo(Ro);function Bo(){let e=H(Kt);return(0,J.jsx)(Io,{plugins:e,handlers:zo})}var Vo=[{id:`general`,label:`General`,icon:Ve,subtitle:`Manage appearance, editor behavior, and embedded terminal defaults.`},{id:`skills`,label:`Skills`,icon:an,subtitle:`Manage globally installed agent skills from the active skill lock file.`},{id:`plugins`,label:`Plugins`,icon:G,subtitle:`View and update globally installed Claude Code and Codex plugins.`},{id:`kanna-plugins`,label:`Kanna plugins`,icon:E,subtitle:`Install local Kanna plugins that contribute UI surfaces and daemon behavior.`},{id:`providers`,label:`Providers`,icon:vn,subtitle:`Manage the default chat provider and saved model defaults for Claude Code and Codex.`},{id:`models`,label:`Models`,icon:pn,subtitle:`Add, edit, and remove Claude and Codex models available in the model picker.`},{id:`subagents`,label:`Subagents`,icon:Fe,subtitle:`Define reusable agent personas. Mention them in chat with @agent/<name>.`},{id:`mcp-servers`,label:`MCP servers`,icon:G,subtitle:`Install custom MCP servers (stdio, http, sse, ws) and connect-test them.`},{id:`remote-mcp`,label:`Remote MCP`,icon:Sn,subtitle:`Let Claude, Codex and ChatGPT drive Kanna over MCP, with setup snippets for each client.`},{id:`beacons`,label:`Beacons`,icon:On,subtitle:`Pair your own machines so the agent can read files and run approved commands there.`},{id:`snippets`,label:`Text snippets`,icon:Mn,subtitle:`Define shortcuts that expand to full text in the chat composer with Tab.`},{id:`instructions`,label:`Instructions`,icon:vn,subtitle:`Global instructions appended to every Claude and Codex turn (main + subagents).`},{id:`keybindings`,label:`Keybindings`,icon:dn,subtitle:`Edit global app shortcuts stored in the active keybindings file.`},{id:`changelog`,label:`Changelog`,icon:an,subtitle:`Release notes pulled from the public GitHub releases feed.`}],Ho={"mcp-servers":Br,"remote-mcp":yo,beacons:vi};function Uo(e){return e?Vo.find(t=>t.id===e)?.id??null:null}function Wo(e){return e?Vo:Vo.filter(e=>e.id!==`kanna-plugins`)}var Go=[{value:`light`,label:`Light`,icon:An},{value:`dark`,label:`Dark`,icon:bn},{value:`system`,label:`System`,icon:ht}],Ko=[{value:`sm`,label:`Small`},{value:`md`,label:`Default`},{value:`lg`,label:`Large`},{value:`xl`,label:`Extra Large`},{value:`xxl`,label:`XX-Large`}],qo=[{value:`never`,label:`Never`},{value:`unfocused`,label:`When Unfocused`},{value:`always`,label:`Always`}],Jo=[{value:`disabled`,label:`Off`},{value:`enabled`,label:`On`}],Yo=[{value:`disabled`,label:`Off`},{value:`enabled`,label:`On`}],Xo=[{value:`always-ask`,label:`Always ask`},{value:`auto-expose`,label:`Auto-expose`}],Zo=[{value:`openai`,label:`OpenAI`},{value:`openrouter`,label:`OpenRouter`},{value:`custom`,label:`Custom`}],Qo=3e5,$o=null;function es(e){return`Edit global app shortcuts stored in ${e}.`}function ts(e,t){return e!==t}function ns(){return $o?Date.now()>=$o.expiresAt?($o=null,null):$o.releases:null}function rs(e){$o={releases:e,expiresAt:Date.now()+Qo}}async function is(e,t){let n=t?.force?null:ns();if(n)return n;let r=await e();return rs(r),r}function as(e,t){let n=e=>e.trim().replace(/^v/i,``).split(`-`)[0].split(`.`).map(e=>Number.parseInt(e,10)).filter(e=>Number.isFinite(e)),r=n(e),i=n(t),a=Math.max(r.length,i.length);for(let e=0;e<a;e+=1){let t=r[e]??0,n=i[e]??0;if(t!==n)return t<n?-1:1}return 0}function os(e){if(!e)return`Unpublished`;let t=new Date(e);return Number.isNaN(t.getTime())?`Unknown date`:new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`,year:`numeric`}).format(t)}var ss=`__redeploy__`,cs=`settings.writeLlmProvider`,ls=`appSettings.setCloudflareTunnel`,us=L(ls,`cloudflaredPath`);function ds({status:e,releases:t,error:n,onRetry:r,updateSnapshot:i,currentVersion:a,onInstallUpdate:o,onCheckForUpdates:c,onForceReload:l}){let u=F(`update.check`),d=s(e=>e.changelogPendingAction),f=s(e=>e.setChangelogPendingAction),p=i?.latestVersion??t[0]?.tag_name??`Unknown`,m=i?.currentVersion??a,h=i?.status===`checking`||u,g=i?.status===`updating`||i?.status===`restart_pending`,_=g||d!==null,v=i?.updateAvailable===!0,y=p.replace(/^v/i,``),b=m.replace(/^v/i,``),x=(0,q.useCallback)(async e=>{f(e);try{await o(e)}finally{f(null)}},[o,f]),ee=(0,q.useCallback)(async()=>{f(ss);try{await l()}finally{f(null)}},[l,f]),S=d===ss||g;return(0,J.jsxs)(`div`,{className:`space-y-4`,children:[e===`loading`||e===`idle`?(0,J.jsx)(`div`,{className:`flex min-h-[180px] items-center justify-center rounded-2xl border border-border bg-card/40 px-6 py-8 text-sm text-muted-foreground`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,J.jsx)(M,{className:`h-4 w-4 animate-spin`}),(0,J.jsx)(`span`,{children:`Loading release notes…`})]})}):null,e===`error`?(0,J.jsx)(`div`,{className:`rounded-lg border border-destructive/20 bg-destructive/5 px-6 py-5`,children:(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:`Could not load changelog`}),(0,J.jsx)(`div`,{className:`mt-1 text-sm text-muted-foreground`,children:n??`Unable to load changelog.`})]}),(0,J.jsx)(`button`,{type:`button`,onClick:r,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground transition-colors hover:bg-muted`,children:`Retry`})]})}):null,e===`success`&&t.length===0?(0,J.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/30 px-6 py-8`,children:[(0,J.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:`No releases yet`}),(0,J.jsx)(`div`,{className:`mt-2 text-sm text-muted-foreground`,children:`GitHub did not return any published releases for this repository.`})]}):null,e===`success`?(0,J.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,J.jsx)(nn,{variant:`outline`,onClick:()=>P(`update.redeploy`,ee),disabled:_,children:S?(0,J.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(M,{className:`h-3.5 w-3.5 animate-spin`}),`Re-deploying…`]}):`Re-deploy`}),(0,J.jsx)(nn,{variant:`outline`,onClick:()=>P(`update.check`,c),disabled:h||_,children:h?(0,J.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(M,{className:`h-3.5 w-3.5 animate-spin`}),`Checking…`]}):`Check for updates`})]}):null,e===`success`&&t.length>0?t.map(e=>{let t=e.tag_name.replace(/^v/i,``),n=t===y,r=t===b;return(0,J.jsxs)(`article`,{className:j(`rounded-xl border bg-card/30 pl-6 pr-4 py-4`,n?`border-border bg-muted`:`border-border`),children:[(0,J.jsxs)(`div`,{className:`flex flex-row items-center min-w-0 flex-1 gap-3 `,children:[(0,J.jsxs)(`div`,{className:`flex flex-row items-center min-w-0 flex-1 gap-2 `,children:[(0,J.jsx)(`div`,{className:`text-lg font-semibold tracking-[-0.2px] text-foreground`,children:e.name?.trim()||e.tag_name}),(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2 text-sm text-muted-foreground`,children:[(0,J.jsx)(`span`,{children:os(e.published_at)}),e.prerelease?(0,J.jsx)(`span`,{className:`rounded-full border border-border px-2.5 py-1 tracking-wide`,children:`Prerelease`}):null]})]}),(0,J.jsxs)(`div`,{className:`flex flex-row items-center justify-end min-w-0 flex-1 gap-2 `,children:[(0,J.jsx)(`a`,{href:e.html_url,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`View release on GitHub`,className:j(Pe({variant:`ghost`,size:`icon-sm`}),`h-11 w-11 md:h-8 md:w-8 shrink-0 rounded-md hover:!bg-transparent hover:border-border/0`),children:(0,J.jsx)(fs,{className:`h-4 w-4`})}),r?(0,J.jsx)(`span`,{className:j(`bg-transparent border border-border text-secondary-foreground`,`h-9 rounded-full px-3 text-sm`,`h-auto gap-1.5 px-3 py-1.5`),children:`Current`}):null,n&&v||!n&&!r?(()=>{let r=d===e.tag_name||g&&d===null,i;i=n?`Update`:as(t,b)<0?`Rollback`:`Install`;let a;return a=n?`Updating…`:as(t,b)<0?`Rolling back…`:`Installing…`,(0,J.jsx)(nn,{variant:`default`,className:``,onClick:()=>P(L(`update.install`,e.tag_name),()=>x(e.tag_name)),disabled:_,children:(0,J.jsxs)(`div`,{className:`flex flex-row items-center justify-center gap-2`,children:[r?(0,J.jsx)(M,{className:`size-4 animate-spin`}):(0,J.jsx)(ln,{className:`size-4`}),r?a:i]})})})():null]})]}),e.body?.trim()?(0,J.jsx)(`div`,{className:`prose prose-sm mt-5 max-w-none text-foreground dark:prose-invert`,children:qe(e.body)}):(0,J.jsx)(`div`,{className:`mt-5 text-sm text-muted-foreground`,children:`No release notes were provided.`})]},e.id)}):null]})}function fs({className:e}){return(0,J.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,className:e,children:(0,J.jsx)(`path`,{d:`M12 .5C5.649.5.5 5.649.5 12A11.5 11.5 0 0 0 8.36 22.04c.575.106.785-.25.785-.556 0-.274-.01-1-.015-1.962-3.181.691-3.853-1.532-3.853-1.532-.52-1.322-1.27-1.674-1.27-1.674-1.038-.71.08-.695.08-.695 1.148.08 1.752 1.178 1.752 1.178 1.02 1.748 2.676 1.243 3.328.95.103-.738.399-1.243.725-1.53-2.54-.289-5.211-1.27-5.211-5.65 0-1.248.446-2.27 1.177-3.07-.118-.288-.51-1.45.112-3.024 0 0 .96-.307 3.145 1.173A10.91 10.91 0 0 1 12 6.03c.973.004 1.954.132 2.87.387 2.182-1.48 3.14-1.173 3.14-1.173.625 1.573.233 2.736.115 3.024.734.8 1.175 1.822 1.175 3.07 0 4.39-2.676 5.358-5.224 5.642.41.353.776 1.05.776 2.117 0 1.528-.014 2.761-.014 3.136 0 .309.207.668.79.555A11.502 11.502 0 0 0 23.5 12C23.5 5.649 18.351.5 12 .5Z`})})}function ps({checked:e,onChange:t}){return(0,J.jsxs)(`label`,{className:`inline-flex items-center gap-2`,children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:e,onChange:e=>t(e.target.checked)}),`Enabled`]})}function ms({state:e}){let t=H(e=>e.settings?.globalPromptAppend??``),n=s(e=>e.globalInstructionsDraft),r=s(e=>e.setGlobalInstructionsDraft),i=s(e=>e.globalInstructionsPersistedAtMount),a=s(e=>e.globalInstructionsSaving),o=s(e=>e.setGlobalInstructionsSaving),c=s(e=>e.globalInstructionsError),u=s(e=>e.setGlobalInstructionsError);(0,q.useEffect)(()=>{t!==i&&s.setState({globalInstructionsPersistedAtMount:t,globalInstructionsDraft:t})},[t,i]);let d=n.replace(/\s+$/u,``),f=d.length>l,p=d!==t,m=a||f||!p,h=(0,q.useCallback)(async()=>{if(!m){u(null),o(!0);try{await e.handleWriteAppSettings({globalPromptAppend:d})}catch(e){u(e instanceof Error?e.message:String(e))}finally{o(!1)}}},[m,e,d,u,o]),g;return g=a?`Saving…`:p?`Save`:`Saved`,(0,J.jsx)(`div`,{className:`border-b border-border`,children:(0,J.jsx)(Z,{title:`Global Instructions`,description:`Appended to every Claude and Codex turn — including subagent turns — as “Workspace instructions”. Kanna does not read CLAUDE.md or AGENTS.md from disk; paste your global instructions here. For rules that apply to one project only, use “Edit instructions” in that project's sidebar menu. Leave blank to disable.`,bordered:!1,alignStart:!0,children:(0,J.jsxs)(`div`,{className:`flex w-full flex-col gap-2 md:w-[420px]`,children:[(0,J.jsx)(`textarea`,{value:n,onChange:e=>r(e.target.value),placeholder:`e.g. Always write tests before implementation. Prefer Tailwind classes over inline styles.`,rows:8,"aria-label":`Global instructions`,className:j(`min-h-[160px] w-full resize-y rounded-md border bg-background px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50`,f?`border-destructive`:`border-input`),disabled:a}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,J.jsxs)(`span`,{className:f?`text-destructive`:`text-muted-foreground`,children:[d.length,` / `,l,` characters`,f?` — over limit`:``]}),(0,J.jsx)(A,{type:`button`,size:`sm`,onClick:()=>P(`settings.globalInstructions`,h),disabled:m,pending:a,children:g})]}),c?(0,J.jsx)(`div`,{className:`text-xs text-destructive`,children:c}):null]})})})}function hs({ports:e,sectionId:t}={}){let i=e?.dom??Ae,l=n(),u=r(),{theme:d,setTheme:g}=Ht(),_=s(e=>e.changelogStatus),y=s(e=>e.setChangelogStatus),x=s(e=>e.signingOut),S=s(e=>e.setSigningOut),te=s(e=>e.authEnabled),C=s(e=>e.setAuthEnabled),ie=s(e=>e.releases),oe=s(e=>e.setReleases),se=s(e=>e.changelogError),ce=s(e=>e.setChangelogError),T=Uo(t)??`general`,le=Ho[T],ue=H(e=>e.hydrationStatus===`loading`&&e.settings===null),E=u.connectionStatus===`connecting`||!u.localProjectsReady||ue,de=F(cs),D=F(ge),pe=de||D,he=F(us),O=F(`keybindings.openEditor`),ye=F(`settings.chatSoundPreference`),xe=F(`settings.chatSoundId`),Se=u.localProjects?.machine.displayName??`Unavailable`,Ce=u.localProjects?.projects.length??0,we=ke.split(`/`)[1]??`unknown`,Te=H(jt),Ee=H(Ft),Oe=H(Ut),k=H(Pt),je=p(e=>e.setScrollbackLines),Me=p(e=>e.setMinColumnWidth),N=p(e=>e.setEditorPreset),Pe=p(e=>e.setEditorCommandTemplate),Fe=H(Lt),Le=H(It),ze=ka(e=>e.setChatSoundPreference),Ve=ka(e=>e.setChatSoundId),He=u.keybindings,R=H(e=>e.settings),Ue=u.llmProvider,Ge=m(e=>e.autoResumeOnRateLimit),Ke=m(e=>e.setAutoResumeOnRateLimit),qe=m(e=>e.typographyOverride),Je=m(e=>e.clearTypographyOverride),Ye=H(e=>e.settings?.typography.scale),Xe=h(qe,Ye),Ze=w(e=>e.defaultProvider),rt=w(e=>e.providerDefaults),it=w(e=>e.setDefaultProvider),at=w(e=>e.setProviderDefaultModel),ot=w(e=>e.setProviderDefaultModelOptions),st=w(e=>e.setProviderDefaultPlanMode),ut=H(Gt),dt=Ai(),ft=(0,q.useMemo)(()=>_e(He),[He]).filePathDisplay||Ne(),pt=s(e=>e.pushPermissionState),ht=s(e=>e.setPushPermissionState),gt=s(e=>e.pushDeviceId),{handleEnablePush:_t,handleDisablePush:vt}=bo(u),B=s(e=>e.scrollbackDraft),yt=s(e=>e.setScrollbackDraft),wt=s(e=>e.minColumnWidthDraft),Et=s(e=>e.tabMinWidthDraft),Dt=s(e=>e.setMinColumnWidthDraft),Ot=s(e=>e.setTabMinWidthDraft),kt=R?.panes.tabMinWidth??60,Mt=R?.uploads.maxFileSizeMb??Fn.maxFileSizeMb,Nt=s(e=>e.uploadMaxFileSizeDraft),Rt=s(e=>e.setUploadMaxFileSizeDraft),zt=Math.round((R?.claudeDriver.lifecycle.idleTimeoutMs??ne.idleTimeoutMs)/6e4),Bt=R?.claudeDriver.lifecycle.maxConcurrent??ne.maxConcurrent,Vt=s(e=>e.claudeIdleMinutesDraft),Wt=s(e=>e.setClaudeIdleMinutesDraft),Kt=s(e=>e.claudeMaxConcurrentDraft),Xt=s(e=>e.setClaudeMaxConcurrentDraft),Zt=s(e=>e.editorCommandDraft),Qt=s(e=>e.setEditorCommandDraft),$t=s(e=>e.appSettingsError),U=s(e=>e.setAppSettingsError),en=s(e=>e.analyticsDialogOpen),tn=s(e=>e.setAnalyticsDialogOpen),rn=s(e=>e.tunnelError),an=s(e=>e.setTunnelError),on=s(e=>e.cloudflaredPathDraft),cn=s(e=>e.setCloudflaredPathDraft),ln=s(e=>e.pushContactSubjectDraft),un=s(e=>e.setPushContactSubjectDraft),dn=R?.shareDefaultTtlHours??24,fn=s(e=>e.shareDefaultTtlDraft),pn=s(e=>e.setShareDefaultTtlDraft),W=s(e=>e.llmProviderDraft),mn=s(e=>e.setLlmProviderDraft),hn=s(e=>e.llmProviderError),_n=s(e=>e.setLlmProviderError),vn=s(e=>e.llmValidationStatus),yn=s(e=>e.setLlmValidationStatus),bn=s(e=>e.llmValidationError),xn=s(e=>e.setLlmValidationError),Sn=s(e=>e.llmValidationDialogOpen),Cn=s(e=>e.setLlmValidationDialogOpen),G=u.updateSnapshot,K=u.handleWriteAppSettings,wn=u.handleWriteCloudflareTunnel,Tn=u.handleWriteClaudeAuth,En=u.handleTestOAuthToken,Dn=u.handleReadLlmProvider,On=u.handleWriteLlmProvider,kn=u.handleValidateLlmProvider,An;An=G?.status===`checking`?`Checking for updates…`:G?.status===`updating`?`Installing update…`:G?.status===`restart_pending`?`Restarting Kanna…`:G?.status===`available`?`Update available${G.latestVersion?`: ${G.latestVersion}`:``}`:G?.status===`up_to_date`?`Up to date`:G?.status===`error`?`Update check failed`:`Not checked yet`,(0,q.useEffect)(()=>{yt(String(Te))},[Te,yt]),(0,q.useEffect)(()=>{Dt(String(Ee))},[Ee,Dt]),(0,q.useEffect)(()=>{Ot(String(kt))},[kt,Ot]),(0,q.useEffect)(()=>{Rt(String(Mt))},[Mt,Rt]),(0,q.useEffect)(()=>{Wt(String(zt))},[zt,Wt]),(0,q.useEffect)(()=>{Xt(String(Bt))},[Bt,Xt]),(0,q.useEffect)(()=>i.addWindowListener(`focus`,()=>ht(lt().state)),[i,ht]),(0,q.useEffect)(()=>{Qt(k)},[k,Qt]),(0,q.useEffect)(()=>{Ue&&mn({provider:Ue.provider,apiKey:Ue.apiKey,model:Ue.model,baseUrl:Ue.baseUrl})},[Ue,mn]),(0,q.useEffect)(()=>{yn(`idle`),xn(null)},[W.provider,W.apiKey,W.model,W.baseUrl,yn,xn]),(0,q.useEffect)(()=>{t&&(Uo(t)||l(`/settings/general`,{replace:!0}))},[l,t]),(0,q.useEffect)(()=>{R&&cn(R.cloudflareTunnel.cloudflaredPath)},[R,cn]),(0,q.useEffect)(()=>{R&&un(R.push.contactSubject)},[R,un]),(0,q.useEffect)(()=>{let e=!1;return ve().then(t=>{e||C(t.enabled===!0)}).catch(()=>{e||C(!1)}),()=>{e=!0}},[C]),(0,q.useEffect)(()=>{T!==`providers`||E||P(ge,Dn)},[Dn,E,T]);let jn=(0,q.useCallback)(()=>u.socket.command({type:`settings.getChangelog`}),[u.socket]);(0,q.useEffect)(()=>{if(T!==`changelog`||E)return;let e=!1;return y(`loading`),ce(null),is(jn).then(t=>{e||(oe(t),y(`success`))}).catch(t=>{e||(ce(t instanceof Error?t.message:`Unable to load changelog.`),y(`error`))}),()=>{e=!0}},[E,T,y,ce,oe,jn]);function Mn(){let e=Number(B);if(!Number.isFinite(e)){yt(String(Te));return}je(e),K({terminal:{scrollbackLines:e}}).catch(e=>{U(e instanceof Error?e.message:`Unable to save terminal settings.`)})}function Pn(){let e=Number(wt);if(!Number.isFinite(e)){Dt(String(Ee));return}Me(e),K({terminal:{minColumnWidth:e}}).catch(e=>{U(e instanceof Error?e.message:`Unable to save terminal settings.`)})}function Ln(){let e=Number(Et);if(!Number.isFinite(e)){Ot(String(kt));return}K({panes:{tabMinWidth:Re(e)}}).catch(e=>{U(e instanceof Error?e.message:`Unable to save pane settings.`)})}function Rn(){let e=Number(Nt);if(!Number.isFinite(e)||e<1||e>51200){Rt(String(Mt)),U(`Max file size must be between 1 and ${In} MB.`);return}if(Math.round(e)===Mt){Rt(String(Mt));return}K({uploads:{maxFileSizeMb:Math.round(e)}}).catch(e=>{U(e instanceof Error?e.message:`Unable to save upload settings.`)})}function zn(){let e=Number(Vt),t=Math.round(De/6e4),n=Math.round(c/6e4);if(!Number.isFinite(e)||e<t||e>n){Wt(String(zt)),U(`Idle timeout must be between ${t} and ${n} minutes.`);return}if(Math.round(e)===zt){Wt(String(zt));return}K({claudeDriver:{lifecycle:{idleTimeoutMs:Math.round(e)*6e4}}}).catch(e=>{U(e instanceof Error?e.message:`Unable to save Claude lifecycle settings.`)})}function Hn(){let e=Number(Kt);if(!Number.isFinite(e)||e<1||e>16){Xt(String(Bt)),U(`Max concurrent sessions must be between 1 and 16.`);return}if(Math.round(e)===Bt){Xt(String(Bt));return}K({claudeDriver:{lifecycle:{maxConcurrent:Math.round(e)}}}).catch(e=>{U(e instanceof Error?e.message:`Unable to save Claude lifecycle settings.`)})}function Un(){let e=Number(fn);if(!Number.isInteger(e)||e<1){pn(String(dn)),U(`Default share link expiry must be a whole number of hours >= 1.`);return}if(e===dn){pn(String(dn));return}K({shareDefaultTtlHours:e}).catch(e=>{U(e instanceof Error?e.message:`Unable to save share settings.`)})}function Y(e,t){e.key===`Enter`&&(t(),e.currentTarget.blur())}function X(){Pe(Zt),K({editor:{commandTemplate:Zt}}).catch(e=>{U(e instanceof Error?e.message:`Unable to save editor settings.`)})}function Wn(e){g(e),K({theme:e}).catch(e=>{U(e instanceof Error?e.message:`Unable to save theme settings.`)})}function Gn(e){K({typography:{scale:e}}).catch(e=>{U(e instanceof Error?e.message:`Unable to save typography settings.`)})}function Kn(e){N(e);let t=e===`custom`?k:o(e);K({editor:{preset:e,commandTemplate:t}}).catch(e=>{U(e instanceof Error?e.message:`Unable to save editor settings.`)})}function qn(e){ts(Fe,e)&&(ze(e),P(`settings.chatSoundPreference`,()=>K({chatSoundPreference:e}).catch(e=>{U(e instanceof Error?e.message:`Unable to save chat sound settings.`)})),qt(`chat sound preview`,Jt(Le,1)))}function Jn(e){ts(Le,e)&&(Ve(e),P(`settings.chatSoundId`,()=>K({chatSoundId:e}).catch(e=>{U(e instanceof Error?e.message:`Unable to save chat sound settings.`)})),qt(`chat sound preview`,Jt(e,1)))}async function Yn(e){try{U(null),await K({analyticsEnabled:e===`enabled`})}catch(e){U(e instanceof Error?e.message:`Unable to save analytics settings.`)}}async function Xn(e){try{U(null),await K({telemetry:{enabled:e===`enabled`}})}catch(e){U(e instanceof Error?e.message:`Unable to save telemetry settings.`)}}async function Zn(e){try{an(null),await wn(e)}catch(e){an(e instanceof Error?e.message:`Unable to save Cloudflare Tunnel settings.`)}}function Qn(e){it(e),K({defaultProvider:e}).catch(e=>{U(e instanceof Error?e.message:`Unable to save provider settings.`)})}function $n(e,t){at(e,t),K({providerDefaults:{[e]:{model:t}}}).catch(e=>{U(e instanceof Error?e.message:`Unable to save provider settings.`)})}function er(e,t){ot(e,t),K({providerDefaults:{[e]:{modelOptions:t}}}).catch(e=>{U(e instanceof Error?e.message:`Unable to save provider settings.`)})}function tr(e,t){st(e,t),K({providerDefaults:{[e]:{planMode:t}}}).catch(e=>{U(e instanceof Error?e.message:`Unable to save provider settings.`)})}async function nr(e=W){try{_n(null),await On(e);let t=await kn(e);yn(t.ok?`valid`:`invalid`),xn(t.error)}catch(e){let t=e instanceof Error?{name:e.name,message:e.message}:Yt(e);yn(`invalid`),xn(t),_n(e instanceof Error?e.message:`Unable to save quick response provider settings.`)}}function rr(e){let t=So(W,e);mn(t),ir(t)}function ir(e=W){P(cs,()=>nr(e))}function ar(){$o=null,y(`loading`),ce(null),is(jn,{force:!0}).then(e=>{oe(e),y(`success`)}).catch(e=>{ce(e instanceof Error?e.message:`Unable to load changelog.`),y(`error`)})}let sr=Zt.replaceAll(`{path}`,`/Users/jake/Projects/kanna/src/client/app/App.tsx`).replaceAll(`{line}`,`12`).replaceAll(`{column}`,`1`),cr=Bn,lr=R?.analyticsEnabled===!1?`disabled`:`enabled`,ur=R?.telemetry?.enabled===!1?`disabled`:`enabled`,dr=R?.cloudflareTunnel??Nn,fr=dr.enabled?`enabled`:`disabled`,pr=Vo.find(e=>e.id===T)??Vo[0],mr=(0,q.useMemo)(()=>Wo(ut),[ut]),hr=T===`keybindings`?es(ft):pr.subtitle,gr=!E,_r=bn?JSON.stringify(bn,null,2):``,vr;vr=pe?`inline-flex items-center gap-1.5 text-muted-foreground`:vn===`valid`?`text-success-text`:vn===`invalid`?`text-destructive`:`hidden`;let yr;yr=pe?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(I,{}),de?`Saving…`:`Loading…`]}):vn===`valid`?`Credentials valid & saved`:vn===`invalid`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{children:`Credentials invalid.`}),bn?(0,J.jsxs)(J.Fragment,{children:[` `,(0,J.jsx)(`button`,{type:`button`,onClick:()=>Cn(!0),className:`underline underline-offset-2`,children:`See error`})]}):null]}):null;let br=(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`span`,{children:[`Use an OpenAI-compatible API for title and commit message generation before Claude and Codex. Stored in `,Ue?.filePathDisplay??`the active llm-provider.json file`,`.`]}),(0,J.jsx)(`span`,{className:j(`mt-2 block text-sm font-medium`,vr),children:yr})]});async function xr(){if(!x){S(!0);try{await u.handleSignOut()}finally{S(!1)}}}return(0,J.jsxs)(`div`,{className:`relative flex h-full flex-1 min-w-0 bg-background`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1`,children:[(0,J.jsx)(`aside`,{className:`hidden w-[200px] shrink-0 md:block ${gr?`pb-[89px]`:``}`,children:(0,J.jsxs)(`div`,{className:`flex flex-col gap-1 px-4 py-6`,children:[(0,J.jsx)(`div`,{className:`px-3 pb-5 text-22 font-extrabold tracking-[-0.5px] text-foreground`,children:`Settings`}),mr.map(e=>{let t=e.id===`changelog`&&G?.updateAvailable===!0;return(0,J.jsxs)(`button`,{type:`button`,onClick:()=>{l(`/settings/${e.id}`)},className:`relative cursor-pointer rounded-lg px-3 py-2 text-sm ${e.id===T?`font-medium text-foreground`:`text-muted-foreground hover:bg-muted/50 hover:text-foreground`}`,children:[e.id===T?(0,J.jsx)(re.span,{layoutId:`settings-nav-indicator`,className:`absolute inset-0 rounded-lg bg-muted`,transition:{type:`spring`,...v.indicator}}):null,(0,J.jsxs)(`div`,{className:`relative flex items-center gap-2.5`,children:[(0,J.jsx)(e.icon,{className:`h-4 w-4 shrink-0`}),(0,J.jsx)(`span`,{className:`min-w-0 truncate`,children:e.label}),t?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(sn,{className:`ml-auto size-3.5 shrink-0 text-warning-text`,"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:`sr-only`,children:`Update available`})]}):null]})]},e.label)}),te?(0,J.jsx)(`button`,{type:`button`,onClick:()=>P(`auth.signOut`,xr),disabled:x,className:`cursor-pointer rounded-lg px-3 py-2 text-sm text-muted-foreground hover:bg-muted/50 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[x?(0,J.jsx)(I,{className:`h-4 w-4`}):(0,J.jsx)(gn,{className:`h-4 w-4 shrink-0`}),(0,J.jsx)(`span`,{children:x?`Signing out...`:`Sign out`})]})}):null]})}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-y-auto`,children:[(0,J.jsx)(`div`,{className:`sticky top-0 z-20 border-b border-border bg-background px-2 py-2 md:hidden`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(ct,{label:`Open sidebar`,children:(0,J.jsx)(`button`,{type:`button`,onClick:u.openSidebar,className:`flex size-11 shrink-0 items-center justify-center rounded-md text-sm text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground`,"aria-label":`Open sidebar`,children:(0,J.jsx)(be,{className:`h-4 w-4 shrink-0`})})}),(0,J.jsxs)(nt,{value:T,onValueChange:e=>{l(`/settings/${e}`)},children:[(0,J.jsx)(Qe,{className:`h-11 min-w-0 flex-1`,"aria-label":`Settings section`,children:(0,J.jsx)(et,{})}),(0,J.jsx)($e,{children:(0,J.jsx)(tt,{children:mr.map(e=>(0,J.jsx)(z,{value:e.id,children:e.label},e.id))})})]}),te?(0,J.jsxs)(`button`,{type:`button`,onClick:()=>P(`auth.signOut`,xr),disabled:x,className:`flex min-h-11 shrink-0 items-center gap-2 rounded-md border border-border bg-background px-3 py-2 text-sm text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,children:[x?(0,J.jsx)(I,{className:`h-4 w-4`}):(0,J.jsx)(gn,{className:`h-4 w-4 shrink-0`}),(0,J.jsx)(`span`,{className:`sr-only`,children:x?`Signing out...`:`Sign out`})]}):null]})}),(0,J.jsxs)(`div`,{className:`w-full px-4 pb-32 pt-8 md:px-6 md:pt-16`,children:[E?(0,J.jsx)(`div`,{className:`flex min-h-[240px] items-center justify-center rounded-2xl border border-border bg-card/40 px-4 py-6 text-sm text-muted-foreground`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,J.jsx)(M,{className:`h-4 w-4 animate-spin`}),(0,J.jsx)(`span`,{children:`Loading machine settings…`})]})}):(0,J.jsxs)(`div`,{className:`mx-auto max-w-4xl kanna-settings-section-in`,children:[(0,J.jsxs)(`div`,{className:`pb-6`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-4 min-h-[34px]`,children:[(0,J.jsx)(`div`,{className:`text-lg font-semibold tracking-[-0.2px] text-foreground`,children:pr.label}),T===`general`?(0,J.jsx)(nn,{variant:`outline`,onClick:()=>{l(`/settings/changelog`)},children:`Check for updates`}):null,T===`keybindings`?(0,J.jsxs)(nn,{onClick:()=>P(`keybindings.openEditor`,()=>u.handleOpenExternalPath(`open_editor`,ft)),disabled:O,"aria-busy":O||void 0,icon:O?(0,J.jsx)(I,{className:`h-4 w-4`}):(0,J.jsx)(fe,{className:`h-4 w-4`}),children:[`Open in `,u.editorLabel]}):null]}),(0,J.jsx)(`div`,{className:`mt-1 text-sm text-muted-foreground`,children:hr})]}),T===`general`&&(0,J.jsxs)(J.Fragment,{children:[$t?(0,J.jsx)(`div`,{className:`mb-4 rounded-lg border border-destructive/20 bg-destructive/5 px-4 py-3 text-sm text-destructive`,children:$t}):null,(0,J.jsxs)(`div`,{className:`border-b border-border`,children:[(0,J.jsx)(Z,{title:`Application Update`,description:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`span`,{children:[An,`.`]}),G?.lastCheckedAt?(0,J.jsxs)(`span`,{children:[` Last checked `,new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`}).format(G.lastCheckedAt),`.`]}):null,G?.error?(0,J.jsxs)(`span`,{children:[` `,G.error]}):null]}),bordered:!1,children:(0,J.jsxs)(`div`,{className:`text-right text-sm text-foreground`,children:[(0,J.jsxs)(`div`,{children:[`Current: `,G?.currentVersion??we]}),(0,J.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Latest: `,G?.latestVersion??`Unknown`]})]})}),(0,J.jsx)(Z,{title:`Theme`,description:`Choose between light, dark, or system appearance`,children:(0,J.jsx)(At,{value:d,onValueChange:Wn,options:Go,size:`sm`})}),(0,J.jsx)(Z,{title:`Typography Scale`,description:qe?`This device uses its own text size instead of the account default.`:`Choose how large text and UI elements appear across the app.`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,J.jsxs)(nt,{value:Xe,onValueChange:e=>{f(e)&&Gn(e)},children:[(0,J.jsx)(Qe,{className:`min-w-[180px]`,children:(0,J.jsx)(et,{})}),(0,J.jsx)($e,{children:(0,J.jsx)(tt,{children:Ko.map(e=>(0,J.jsx)(z,{value:e.value,children:e.label},e.value))})})]}),qe?(0,J.jsx)(A,{type:`button`,variant:`link`,size:`sm`,onClick:Je,children:`Use account default`}):null]})}),(0,J.jsx)(Z,{title:`Chat Sounds`,description:`Play a pop when a chat starts waiting on you or the unread chat count increases`,children:(0,J.jsxs)(nt,{disabled:ye,value:Fe,onValueChange:e=>{me(e)&&qn(e)},children:[(0,J.jsx)(Qe,{className:`min-w-[180px]`,children:(0,J.jsx)(et,{})}),(0,J.jsx)($e,{children:(0,J.jsx)(tt,{children:qo.map(e=>(0,J.jsx)(z,{value:e.value,children:e.label},e.value))})})]})}),(0,J.jsx)(Z,{title:`Chat Sound`,description:`The bundled sound used for chat notification playback and previews`,children:(0,J.jsxs)(nt,{disabled:xe,value:Le,onValueChange:e=>{a(e)&&Jn(e)},children:[(0,J.jsx)(Qe,{className:`min-w-[180px]`,children:(0,J.jsx)(et,{})}),(0,J.jsx)($e,{children:(0,J.jsx)(tt,{children:Ea.map(e=>(0,J.jsx)(z,{value:e.value,children:e.label},e.value))})})]})}),(0,J.jsx)(Z,{title:`Default Editor`,description:`Used when opening transcript links or files from the git diff menu`,alignStart:!0,children:(0,J.jsxs)(nt,{value:Oe,onValueChange:e=>{b(e)&&Kn(e)},children:[(0,J.jsx)(Qe,{className:`min-w-[180px]`,children:(0,J.jsx)(et,{})}),(0,J.jsx)($e,{children:(0,J.jsx)(tt,{children:Be.map(e=>(0,J.jsx)(z,{value:e.value,children:(0,J.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(Ie,{preset:e.value,className:`h-4 w-4 shrink-0`}),(0,J.jsx)(`span`,{children:e.label})]})},e.value))})})]})}),Oe===`custom`?(0,J.jsx)(`div`,{className:`border-t border-border`,children:(0,J.jsxs)(`div`,{className:`flex justify-between gap-8 py-5 pl-6`,children:[(0,J.jsxs)(`div`,{className:`min-w-0 max-w-xl`,children:[(0,J.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:`Command Template`}),(0,J.jsxs)(`div`,{className:`mt-1 text-13 text-muted-foreground`,children:[`Include `,`{path}`,` and optionally `,`{line}`,` and `,`{column}`,` in your command.`]})]}),(0,J.jsxs)(`div`,{className:`flex min-w-0 max-w-[420px] flex-1 flex-col items-stretch gap-2`,children:[(0,J.jsx)(V,{type:`text`,value:Zt,onChange:e=>Qt(e.target.value),onBlur:X,onKeyDown:e=>ya(e,X),className:`font-mono`}),(0,J.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Preview: `,(0,J.jsx)(`span`,{className:`font-mono`,children:sr})]})]})]})}):null,(0,J.jsx)(Z,{title:`Terminal Scrollback`,description:`Lines retained for embedded terminal history`,children:(0,J.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col items-stretch gap-2 md:w-auto md:items-end`,children:[(0,J.jsx)(V,{type:`number`,min:500,max:5e3,step:100,value:B,onChange:e=>yt(e.target.value),onBlur:Mn,onKeyDown:e=>Y(e,Mn),className:`hide-number-steppers w-full text-left font-mono md:w-28 md:text-right`}),(0,J.jsxs)(`div`,{className:`text-left text-xs text-muted-foreground md:text-right`,children:[500,`-`,5e3,` lines`,Te===1e3?` (default)`:``]})]})}),(0,J.jsx)(Z,{title:`Terminal Min Column Width`,description:`Minimum width for each terminal pane`,children:(0,J.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col items-stretch gap-2 md:w-auto md:items-end`,children:[(0,J.jsx)(V,{type:`number`,min:250,max:900,step:10,value:wt,onChange:e=>Dt(e.target.value),onBlur:Pn,onKeyDown:e=>Y(e,Pn),className:`hide-number-steppers w-full text-left font-mono md:w-28 md:text-right`}),(0,J.jsxs)(`div`,{className:`text-left text-xs text-muted-foreground md:text-right`,children:[250,`-`,900,` px`,Ee===450?` (default)`:``]})]})}),(0,J.jsx)(Z,{title:`Tab Minimum Width`,description:`How narrow a pane tab may get before the strip scrolls instead of shrinking`,children:(0,J.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col items-stretch gap-2 md:w-auto md:items-end`,children:[(0,J.jsx)(V,{type:`number`,min:60,max:200,step:10,value:Et,onChange:e=>Ot(e.target.value),onBlur:Ln,onKeyDown:e=>Y(e,Ln),className:`hide-number-steppers w-full text-left font-mono md:w-28 md:text-right`}),(0,J.jsxs)(`div`,{className:`text-left text-xs text-muted-foreground md:text-right`,children:[60,`-`,200,` px`,kt===60?` (default)`:``]})]})}),(0,J.jsx)(Z,{title:`Max upload file size`,description:`Largest single file the chat upload endpoint accepts.`,children:(0,J.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col items-stretch gap-1.5 md:w-auto md:items-end`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 md:justify-end`,children:[(0,J.jsx)(V,{type:`number`,min:1,max:51200,step:1,value:Nt,onChange:e=>Rt(e.target.value),onBlur:Rn,onKeyDown:e=>Y(e,Rn),className:`hide-number-steppers w-full text-left font-mono tabular-nums md:w-24 md:text-right`,"aria-label":`Max upload file size in megabytes`}),(0,J.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`MB`})]}),(0,J.jsxs)(`div`,{className:`text-left text-xs text-muted-foreground tabular-nums md:text-right`,children:[1,`–`,51200,` MB · default `,Fn.maxFileSizeMb]})]})}),(0,J.jsx)(Z,{title:`Auto-resume on rate limit`,description:`When you hit a rate limit, automatically schedule "continue" at the reset time instead of asking. You can still cancel each one from the chat.`,children:(0,J.jsx)(ps,{checked:Ge,onChange:Ke})}),u.pushConfig?(0,J.jsx)(Z,{title:`Push notifications`,description:`Get notified when a chat is waiting for you, finishes, or fails. Works on iPhone (after Add to Home Screen), Android, and desktop browsers.`,bordered:!1,alignStart:!0,children:(0,J.jsx)(Wa,{permissionState:pt,config:u.pushConfig,projects:u.localProjects?.projects??[],currentDeviceId:gt,contactSubject:R?.push.contactSubject??``,contactSubjectDraft:ln,onContactSubjectDraftChange:un,onContactSubjectSave:async e=>{await u.socket.command({type:`settings.writeAppSettingsPatch`,patch:{push:{contactSubject:e}}})},onEnable:_t,onDisable:vt,onTest:async()=>{await u.socket.command({type:`push.test`})},onMuteToggle:async(e,t)=>{await u.socket.command({type:`push.setProjectMute`,localPath:e,muted:t})},onRemoveDevice:async e=>{await u.socket.command({type:`push.unsubscribe`,pushDeviceId:e})}})}):null,(0,J.jsx)(Z,{title:`Anonymous Analytics`,description:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{children:`Help improve Kanna with anonymous product analytics. Kanna sends tracked event names plus a small set of event properties like current version, environment, update version info, and launch flags. No message content, prompts, file paths, or provider credentials are sent.`}),(0,J.jsxs)(`span`,{className:`mt-1 block`,children:[`Stored in `,R?.filePathDisplay??`~/.kanna/data/settings.json`,`.`,` `,(0,J.jsx)(`button`,{type:`button`,onClick:()=>tn(!0),className:`underline underline-offset-2 text-foreground hover:text-foreground/80`,children:`View tracked events`})]}),R?.warning?(0,J.jsx)(`span`,{className:`mt-1 block`,children:R.warning}):null]}),children:(0,J.jsx)(ao,{pendingKey:`settings.analytics`,value:lr,onValueChange:Yn,options:Jo,size:`sm`})}),(0,J.jsx)(Z,{title:`Telemetry Tracing`,description:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{children:`Export OpenTelemetry traces and metrics (turn timings, subagent runs, process memory) to Kanna's observability collector so each install can be monitored. This machine reports under its computer name. Turning it off stops the export immediately.`}),(0,J.jsxs)(`span`,{className:`mt-1 block`,children:[`Collector: `,R?.telemetry?.endpoint??`not configured`,`. Stored in `,R?.filePathDisplay??`~/.kanna/data/settings.json`,`.`]})]}),children:(0,J.jsx)(ao,{pendingKey:`settings.telemetry`,value:ur,onValueChange:Xn,options:Jo,size:`sm`})})]}),(0,J.jsxs)(`div`,{className:`border-b border-border`,children:[rn?(0,J.jsx)(`div`,{className:`mb-4 rounded-lg border border-destructive/20 bg-destructive/5 px-4 py-3 text-sm text-destructive`,children:rn}):null,(0,J.jsx)(Z,{title:`Cloudflare Tunnel`,description:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`span`,{children:[`When enabled, Claude can call the `,(0,J.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 font-mono text-xs`,children:`expose_port`}),` tool to expose a local port via Cloudflare Tunnel. The mode below controls whether each call requires your approval or is exposed automatically. Requires`,` `,(0,J.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 font-mono text-xs`,children:`cloudflared`}),` `,`to be installed.`]}),(0,J.jsxs)(`span`,{className:`mt-1 block`,children:[`Stored in `,R?.filePathDisplay??`~/.kanna/data/settings.json`,`.`]})]}),bordered:!1,children:(0,J.jsx)(ao,{pendingKey:L(ls,`enabled`),value:fr,onValueChange:e=>Zn({enabled:e===`enabled`}),options:Yo,size:`sm`})}),dr.enabled&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Z,{title:`Tool mode`,description:`Always ask: each expose_port call shows an accept card. Auto-expose: expose_port calls spawn cloudflared immediately without prompting.`,children:(0,J.jsx)(ao,{pendingKey:L(ls,`mode`),value:dr.mode,onValueChange:e=>Zn({mode:e}),options:Xo,size:`sm`})}),(0,J.jsx)(Z,{title:`cloudflared path`,description:`Path to the cloudflared binary. Defaults to the one found on $PATH.`,children:(0,J.jsx)(V,{value:on,onChange:e=>cn(e.target.value),onBlur:()=>P(us,()=>Zn({cloudflaredPath:on})),readOnly:he,"aria-busy":he||void 0,placeholder:`cloudflared`,className:`w-full font-mono md:w-64`})})]})]}),(0,J.jsx)(`div`,{className:`border-b border-border`,children:(0,J.jsx)(Z,{title:`Public share links`,description:`Default expiry for read-only chat share links. Owners can revoke any link manually at any time.`,bordered:!1,children:(0,J.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col items-stretch gap-2 md:w-auto md:items-end`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 md:justify-end`,children:[(0,J.jsx)(V,{type:`number`,min:1,step:1,value:fn,onChange:e=>pn(e.target.value),onBlur:Un,onKeyDown:e=>Y(e,Un),className:`hide-number-steppers w-full text-left font-mono tabular-nums md:w-24 md:text-right`,"aria-label":`Default share link expiry in hours`}),(0,J.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`hours`})]}),(0,J.jsx)(`div`,{className:`text-left text-xs text-muted-foreground tabular-nums md:text-right`,children:`Minimum 1 hour · default 24`})]})})})]}),T===`providers`&&(0,J.jsxs)(`div`,{className:`border-b border-border`,children:[(0,J.jsx)(Z,{title:`Claude OAuth tokens`,description:`Manage multiple Claude OAuth tokens. Kanna switches automatically when one hits its rate limit.`,bordered:!1,alignStart:!0,children:(0,J.jsx)(`div`,{className:`w-full md:w-[420px]`,children:(0,J.jsx)(va,{tokens:R?.claudeAuth.tokens??[],concurrencyDefault:R?.claudeAuth.concurrencyDefault??1,onWrite:Tn,onTest:En})})}),(0,J.jsx)(Z,{title:`Claude session idle timeout`,description:`Stop a Claude session after this many minutes without user activity. Lower values free memory sooner; higher values keep cold-start latency low.`,children:(0,J.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col items-stretch gap-2 md:w-auto md:items-end`,children:[(0,J.jsx)(V,{type:`number`,min:1,max:60,step:1,value:Vt,onChange:e=>Wt(e.target.value),onBlur:zn,onKeyDown:e=>Y(e,zn),className:`hide-number-steppers w-full text-left font-mono md:w-28 md:text-right`}),(0,J.jsxs)(`div`,{className:`text-left text-xs text-muted-foreground md:text-right`,children:[1,`–`,60,` min · default `,Math.round(ne.idleTimeoutMs/6e4)]})]})}),(0,J.jsx)(Z,{title:`Max concurrent Claude sessions`,description:`Hard cap on resident Claude processes. Excess sessions are evicted LRU; their next activation cold-starts.`,children:(0,J.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col items-stretch gap-2 md:w-auto md:items-end`,children:[(0,J.jsx)(V,{type:`number`,min:1,max:16,step:1,value:Kt,onChange:e=>Xt(e.target.value),onBlur:Hn,onKeyDown:e=>Y(e,Hn),className:`hide-number-steppers w-full text-left font-mono md:w-28 md:text-right`}),(0,J.jsxs)(`div`,{className:`text-left text-xs text-muted-foreground md:text-right`,children:[1,`–`,16,` · default `,ne.maxConcurrent]})]})}),(0,J.jsx)(Z,{title:`Default Provider`,description:`The default harness used for new chats before a provider is locked by an existing session.`,children:(0,J.jsxs)(nt,{value:Ze,onValueChange:e=>{(e===`last_used`||ae(e))&&Qn(e)},children:[(0,J.jsx)(Qe,{className:`min-w-[180px]`,children:(0,J.jsx)(et,{})}),(0,J.jsx)($e,{children:(0,J.jsxs)(tt,{children:[(0,J.jsx)(z,{value:`last_used`,children:`Last Used`}),dt.map(e=>(0,J.jsx)(z,{value:e.id,children:e.label},e.id))]})})]})}),(0,J.jsx)(ia,{state:u}),(0,J.jsx)(Z,{title:`Claude Code Defaults`,description:`Saved defaults when using Claude Code.`,alignStart:!0,children:(0,J.jsx)(`div`,{className:`max-w-[420px]`,children:(0,J.jsx)(We,{availableProviders:dt,selectedProvider:`claude`,showProviderPicker:!1,model:rt.claude.model,modelOptions:rt.claude.modelOptions,onModelChange:(e,t)=>{$n(`claude`,t)},onModelOptionChange:e=>{e.type===`claudeReasoningEffort`?er(`claude`,{reasoningEffort:e.effort}):e.type===`contextWindow`&&er(`claude`,{contextWindow:e.contextWindow})},planMode:rt.claude.planMode,onPlanModeChange:e=>tr(`claude`,e),includePlanMode:!0,className:`justify-start flex-wrap`})})}),(0,J.jsx)(Z,{title:`Codex Defaults`,description:`Saved defaults when using Codex.`,alignStart:!0,children:(0,J.jsx)(`div`,{className:`max-w-[420px]`,children:(0,J.jsx)(We,{availableProviders:dt,selectedProvider:`codex`,showProviderPicker:!1,model:rt.codex.model,modelOptions:rt.codex.modelOptions,onModelChange:(e,t)=>{$n(`codex`,t)},onModelOptionChange:e=>{e.type===`codexReasoningEffort`?er(`codex`,{reasoningEffort:e.effort}):e.type===`fastMode`&&er(`codex`,{fastMode:e.fastMode})},planMode:rt.codex.planMode,onPlanModeChange:e=>tr(`codex`,e),includePlanMode:!0,className:`justify-start flex-wrap`})})}),(0,J.jsx)(Z,{title:`Quick Response SDK`,description:br,alignStart:!0,children:(0,J.jsxs)(`div`,{className:`flex w-full max-w-[420px] flex-col gap-3`,children:[hn?(0,J.jsx)(`div`,{className:`rounded-lg border border-destructive/20 bg-destructive/5 px-4 py-3 text-sm text-destructive`,children:hn}):null,Ue?.warning?(0,J.jsx)(`div`,{className:`rounded-lg border border-border bg-card/30 px-4 py-3 text-sm text-muted-foreground`,children:Ue.warning}):null,(0,J.jsxs)(nt,{value:W.provider,disabled:pe,onValueChange:e=>{ee(e)&&rr(e)},children:[(0,J.jsx)(Qe,{className:`w-full`,children:(0,J.jsx)(et,{})}),(0,J.jsx)($e,{children:(0,J.jsx)(tt,{children:Zo.map(e=>(0,J.jsx)(z,{value:e.value,children:e.label},e.value))})})]}),W.provider===`custom`?(0,J.jsx)(V,{value:W.baseUrl,onChange:e=>mn({...W,baseUrl:e.target.value}),onBlur:()=>ir(),onKeyDown:e=>ya(e,ir),readOnly:pe,placeholder:`https://your-provider.example/v1`}):null,(0,J.jsx)(V,{type:`password`,value:W.apiKey,onChange:e=>mn({...W,apiKey:e.target.value}),onBlur:()=>ir(),onKeyDown:e=>ya(e,ir),readOnly:pe,placeholder:`API key`}),(0,J.jsx)(V,{value:W.model,onChange:e=>mn({...W,model:e.target.value}),onBlur:()=>ir(),onKeyDown:e=>ya(e,ir),readOnly:pe,placeholder:`Model id`})]})})]}),T===`keybindings`&&(0,J.jsx)(Ca,{state:u}),T===`skills`&&(0,J.jsx)(Po,{state:u}),T===`plugins`&&(0,J.jsx)(ro,{state:u}),T===`kanna-plugins`&&ut&&(0,J.jsx)(Bo,{}),T===`subagents`&&(0,J.jsx)(or,{state:u}),T===`models`&&(0,J.jsx)(ki,{state:u}),le&&(0,J.jsx)(le,{state:u}),T===`snippets`&&(0,J.jsx)(fa,{state:u}),T===`instructions`&&(0,J.jsx)(ms,{state:u}),![`general`,`providers`,`keybindings`,`skills`,`plugins`,`subagents`,`models`,`mcp-servers`,`remote-mcp`,`beacons`,`snippets`,`instructions`].includes(T)&&(0,J.jsx)(ds,{status:_,releases:ie,error:se,onRetry:ar,updateSnapshot:G,currentVersion:we,onInstallUpdate:e=>u.handleInstallUpdate(e),onCheckForUpdates:()=>u.handleCheckForUpdates({force:!0}),onForceReload:()=>u.handleForceReload()})]},T),u.commandError?(0,J.jsxs)(`div`,{className:`mx-auto mt-4 flex max-w-4xl items-start gap-3 rounded-lg border border-destructive/20 bg-destructive/5 px-4 py-3 text-sm text-destructive`,children:[(0,J.jsx)(mt,{className:`mt-0.5 h-4 w-4 flex-shrink-0`}),(0,J.jsx)(`span`,{children:u.commandError})]}):null]})]})]}),gr?(0,J.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 border-t border-border bg-background`,children:(0,J.jsx)(`div`,{className:`px-6 py-[14.25px]`,children:(0,J.jsxs)(`div`,{className:`grid gap-3 text-xs text-muted-foreground grid-cols-2 lg:grid-cols-4`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`mb-1 tracking-wide text-xs text-muted-foreground/80`,children:`Machine`}),(0,J.jsx)(`div`,{className:`text-foreground/80`,children:Se})]}),(0,J.jsxs)(`div`,{className:`hidden md:block`,children:[(0,J.jsx)(`div`,{className:`mb-1 tracking-wide text-xs text-muted-foreground/80`,children:`Connection`}),(0,J.jsx)(`div`,{className:`text-foreground/80`,children:u.connectionStatus})]}),(0,J.jsxs)(`div`,{className:`hidden md:block`,children:[(0,J.jsx)(`div`,{className:`mb-1 tracking-wide text-xs text-muted-foreground/80`,children:`Projects Indexed`}),(0,J.jsx)(`div`,{className:`text-foreground/80`,children:Ce})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`mb-1 tracking-wide text-xs text-muted-foreground/80`,children:`App Version`}),(0,J.jsx)(`div`,{className:`text-foreground/80`,children:we})]})]})})}):null,(0,J.jsx)(xt,{open:en,onOpenChange:tn,children:(0,J.jsxs)(bt,{size:`lg`,children:[(0,J.jsxs)(Ct,{className:`space-y-4`,children:[(0,J.jsx)(Tt,{children:`Tracked Events`}),(0,J.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Kanna sends these event names plus the limited property keys below, depending on the event type.`}),(0,J.jsxs)(`div`,{className:`max-h-[60vh] overflow-auto rounded-lg border border-border bg-muted/40 p-3`,children:[(0,J.jsx)(`div`,{className:`text-xs font-medium tracking-wide text-muted-foreground`,children:`Event Names`}),(0,J.jsx)(`ul`,{className:`mt-3 space-y-2 text-sm`,children:cr.map(e=>(0,J.jsx)(`li`,{className:`font-mono text-foreground`,children:e},e))}),(0,J.jsx)(`div`,{className:`mt-6 text-xs font-medium tracking-wide text-muted-foreground`,children:`Property Keys`}),(0,J.jsx)(`ul`,{className:`mt-3 space-y-2 text-sm`,children:Vn.map(e=>(0,J.jsx)(`li`,{className:`font-mono text-foreground`,children:e},e))})]})]}),(0,J.jsx)(St,{children:(0,J.jsx)(A,{variant:`secondary`,size:`sm`,onClick:()=>tn(!1),children:`Close`})})]})}),(0,J.jsx)(xt,{open:Sn,onOpenChange:Cn,children:(0,J.jsxs)(bt,{size:`lg`,children:[(0,J.jsxs)(Ct,{className:`space-y-4`,children:[(0,J.jsx)(Tt,{children:`Validation Error`}),(0,J.jsx)(`pre`,{className:`max-h-[60vh] overflow-auto rounded-lg border border-border bg-muted p-3 text-xs font-mono whitespace-pre-wrap break-words`,children:_r})]}),(0,J.jsx)(St,{children:(0,J.jsx)(A,{variant:`secondary`,size:`sm`,onClick:()=>Cn(!1),children:`Close`})})]})})]})}export{hs as SettingsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{f as e}from"./pendingActionsStore-idc6m2Ya.js";var t={name:`chevron-left`,size:24,node:[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]};t.node;var n=e(t);export{n as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{t}from"./react-DiVRNtpo.js";import{t as n}from"./jsx-runtime-BdxMnOeJ.js";import{ct as r,mn as i,mt as a,ot as o,st as s,yt as c}from"./useAppGlobalState-uP5C1BG8.js";import{c as l}from"./log-7fGlFSON.js";import{c as u,f as d}from"./pendingActionsStore-idc6m2Ya.js";import{Bt as f,Ht as p,Ut as m}from"./lexicalToReact-DdXqoi0d.js";import{m as h}from"./pushClient-NeXrldi-.js";import{t as g}from"./timer.adapter-BD7zwXEm.js";import{t as _}from"./createScopedStore-DW4wfjbM.js";import{T as ee,h as v}from"./useTheme-B_JDh31l.js";import{n as y,r as b,t as x}from"./popover-gn1uvc-1.js";var S={name:`bot`,size:24,node:[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]};S.node;var C=d(S),w={name:`box`,size:24,node:[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]};w.node;var T=d(w),E={name:`gauge`,size:24,node:[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]};E.node;var D=d(E),O={name:`key-round`,size:24,node:[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]};O.node;var k=d(O),A={name:`lock-open`,size:24,node:[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 9.9-1`,key:`1mm8w8`}]],aliases:[`unlock`]};A.node;var j=d(A),M={name:`lock`,size:24,node:[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]};M.node;var N=d(M),P={name:`settings-2`,size:24,node:[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]};P.node;var F=d(P),I={name:`server`,size:24,node:[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]};I.node;var L=d(I),R={name:`square-menu`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M7 8h10`,key:`1jw688`}],[`path`,{d:`M7 12h10`,key:`b7w52i`}],[`path`,{d:`M7 16h10`,key:`wp8him`}]],aliases:[`menu-square`]};R.node;var z=d(R),B={name:`square-minus`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}]],aliases:[`minus-square`]};B.node;var V=d(B);function H(e){let t=typeof e==`number`?e:Number(e);return Number.isFinite(t)?Math.min(200,Math.max(60,Math.round(t))):60}var U=e(t(),1),W=_(`InputPopover`,()=>e=>({open:!1,setOpen:t=>e({open:t})}));function te(){return e=>({open:!1,query:``,setQuery:t=>e({query:t}),setPopoverOpen:t=>e(t?{open:!0}:{open:!1,query:``}),closeAndClearQuery:()=>e({open:!1,query:``})})}var G=_(`SearchableModelPopover`,te),K=e(n(),1),ne=[],re={openrouter:`Loading models… verify OpenRouter API key in Settings.`,custom:`No models configured. Add an endpoint in Settings → Providers.`};function ie({className:e,...t}){return(0,K.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,className:u(`shrink-0`,e),...t,children:(0,K.jsx)(`path`,{d:`M17.3041 3.541h-3.6718l6.696 16.918H24Zm-10.6082 0L0 20.459h3.7442l1.3693-3.5527h7.0052l1.3693 3.5528h3.7442L10.5363 3.5409Zm-.3712 10.2232 2.2914-5.9456 2.2914 5.9456Z`})})}function ae({className:e,...t}){return(0,K.jsx)(`svg`,{viewBox:`0 0 158.7128 157.296`,fill:`currentColor`,"aria-hidden":`true`,className:u(`shrink-0`,e),...t,children:(0,K.jsx)(`path`,{d:`M60.8734 57.2556V42.3124c0-1.2586.4722-2.2029 1.5728-2.8314l30.0443-17.3023c4.0899-2.3593 8.9662-3.4599 13.9988-3.4599 18.8759 0 30.8307 14.6289 30.8307 30.2006 0 1.1007 0 2.3593-.158 3.6178l-31.1446-18.2467c-1.8872-1.1006-3.7754-1.1006-5.6629 0L60.8734 57.2556Zm70.1542 58.2005V79.7487c0-2.2028-.9446-3.7756-2.8318-4.8763l-39.481-22.9651 12.8982-7.3934c1.1007-.6285 2.0453-.6285 3.1458 0l30.0441 17.3024c8.6523 5.0341 14.4708 15.7296 14.4708 26.1107 0 11.9539-7.0769 22.965-18.2461 27.527ZM51.593 83.9964l-12.8982-7.5497c-1.1007-.6285-1.5728-1.5728-1.5728-2.8314V39.0105c0-16.8303 12.8982-29.5722 30.3585-29.5722 6.607 0 12.7403 2.2029 17.9324 6.1349l-30.987 17.9324c-1.8871 1.1007-2.8314 2.6735-2.8314 4.8764v45.6159ZM79.3562 100.0403 60.8733 89.6592V67.6383l18.4829-10.3811 18.4812 10.3811v22.0209l-18.4812 10.3811Zm11.8757 47.8188c-6.607 0-12.7403-2.2031-17.9324-6.1344l30.9866-17.9333c1.8872-1.1005 2.8318-2.6728 2.8318-4.8759v-45.616l13.0564 7.5498c1.1005.6285 1.5723 1.5728 1.5723 2.8314v34.6051c0 16.8297-13.0564 29.5723-30.5147 29.5723ZM53.9522 112.7822 23.9079 95.4798c-8.652-5.0343-14.471-15.7296-14.471-26.1107 0-12.1119 7.2356-22.9652 18.403-27.5272v35.8634c0 2.2028.9443 3.7756 2.8314 4.8763l39.3248 22.8068-12.8982 7.3938c-1.1007.6287-2.045.6287-3.1456 0ZM52.2229 138.5791c-17.7745 0-30.8306-13.3713-30.8306-29.8871 0-1.2585.1578-2.5169.3143-3.7754l30.987 17.9323c1.8871 1.1005 3.7757 1.1005 5.6628 0l39.4811-22.807v14.9435c0 1.2585-.4721 2.2021-1.5728 2.8308l-30.0443 17.3025c-4.0898 2.359-8.9662 3.4605-13.9989 3.4605h.0014ZM91.2319 157.296c19.0327 0 34.9188-13.5272 38.5383-31.4594 17.6164-4.562 28.9425-21.0779 28.9425-37.908 0-11.0112-4.719-21.7066-13.2133-29.4143.7867-3.3035 1.2595-6.607 1.2595-9.909 0-22.4929-18.2471-39.3247-39.3251-39.3247-4.2461 0-8.3363.6285-12.4262 2.045-7.0792-6.9213-16.8318-11.3254-27.5271-11.3254-19.0331 0-34.9191 13.5268-38.5384 31.4591C11.3255 36.0212 0 52.5373 0 69.3675c0 11.0112 4.7184 21.7065 13.2125 29.4142-.7865 3.3035-1.2586 6.6067-1.2586 9.9092 0 22.4923 18.2466 39.3241 39.3248 39.3241 4.2462 0 8.3362-.6277 12.426-2.0441 7.0776 6.921 16.8302 11.3251 27.5271 11.3251Z`})})}function oe({className:e,...t}){return(0,K.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:u(`shrink-0`,e),...t,children:[(0,K.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,K.jsx)(`path`,{d:`M6.3 6.3a8 8 0 1 0 11.4 11.4`}),(0,K.jsx)(`path`,{d:`M17.7 6.3a8 8 0 0 1 0 11.4`}),(0,K.jsx)(`path`,{d:`M2 12h4`}),(0,K.jsx)(`path`,{d:`M18 12h4`})]})}var q={claude:ie,codex:ae,openrouter:oe,custom:L};function J({onClick:e,selected:t,icon:n,label:r,description:i,disabled:a}){return(0,K.jsxs)(`button`,{onClick:e,disabled:a,className:u(`w-full flex items-center gap-2 p-2 border border-border/0 rounded-lg text-left transition-opacity`,t?`bg-muted border-border`:`hover:opacity-60`,a&&`opacity-40 cursor-not-allowed`),children:[n,(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-sm font-medium`,children:r}),i?(0,K.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:i}):null]})]})}function Y({trigger:e,triggerClassName:t,disabled:n=!1,children:r}){return n?(0,K.jsx)(`button`,{disabled:!0,className:u(`flex min-h-[36px] items-center gap-1.5 px-2 py-1 text-sm rounded-md text-muted-foreground [&>svg]:shrink-0 opacity-70 cursor-default [&>span]:whitespace-nowrap`,t),children:e}):(0,K.jsx)(W.Provider,{init:void 0,children:(0,K.jsx)(se,{trigger:e,triggerClassName:t,children:r})})}function se({trigger:e,triggerClassName:t,children:n}){let r=W.useScopedStore(e=>e.open),i=W.useScopedStore(e=>e.setOpen);return(0,K.jsxs)(x,{open:r,onOpenChange:i,children:[(0,K.jsx)(b,{asChild:!0,children:(0,K.jsx)(`button`,{type:`button`,className:u(`flex min-h-[36px] cursor-pointer touch-manipulation items-center gap-1.5 px-2 py-1 text-sm rounded-md transition-colors text-muted-foreground [&>svg]:shrink-0 [&>span]:whitespace-nowrap`,`hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,t),children:e})}),(0,K.jsx)(y,{align:`center`,className:`w-64 p-1`,children:(0,K.jsx)(`div`,{className:`space-y-1`,children:typeof n==`function`?n(()=>i(!1)):n})})]})}function ce({models:e,selectedModel:t,onSelect:n,ModelIcon:r,emptyMessage:i}){return(0,K.jsx)(G.Provider,{init:void 0,children:(0,K.jsx)(le,{models:e,selectedModel:t,onSelect:n,ModelIcon:r,emptyMessage:i})})}function le({models:e,selectedModel:t,onSelect:n,ModelIcon:r,emptyMessage:i}){let a=G.useScopedStore(e=>e.open),o=G.useScopedStore(e=>e.query),s=G.useScopedStore(e=>e.setPopoverOpen),c=G.useScopedStore(e=>e.setQuery),l=G.useScopedStore(e=>e.closeAndClearQuery),d=(0,U.useCallback)(e=>{n(e),l()},[n,l]),p=e.find(e=>e.id===t)?.label??t,m=(0,U.useMemo)(()=>{let t=o.trim().toLowerCase();return t?e.filter(e=>e.id.toLowerCase().includes(t)||e.label.toLowerCase().includes(t)):e},[e,o]),h;return h=e.length===0?(0,K.jsx)(`div`,{className:`px-2 py-3 text-xs text-muted-foreground text-center`,children:i}):m.length===0?(0,K.jsx)(`div`,{className:`px-2 py-3 text-xs text-muted-foreground text-center`,children:`No matches`}):m.map(e=>(0,K.jsx)(J,{onClick:()=>d(e.id),selected:t===e.id,icon:(0,K.jsx)(T,{className:`h-4 w-4 text-muted-foreground`}),label:e.label,description:e.id},e.id)),(0,K.jsxs)(x,{open:a,onOpenChange:s,children:[(0,K.jsx)(b,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,className:u(`flex min-h-[36px] cursor-pointer touch-manipulation items-center gap-1.5 px-2 py-1 text-sm rounded-md transition-colors text-muted-foreground [&>svg]:shrink-0 [&>span]:whitespace-nowrap`,`hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`),children:[(0,K.jsx)(r,{className:`h-3.5 w-3.5`}),(0,K.jsx)(`span`,{className:`max-w-[200px] truncate`,children:p})]})}),(0,K.jsxs)(y,{align:`center`,className:`w-80 p-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 border-b border-border/50`,children:[(0,K.jsx)(f,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,K.jsx)(`input`,{type:`text`,value:o,onChange:e=>c(e.target.value),placeholder:`Search models...`,autoFocus:!0,className:`flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground`})]}),(0,K.jsx)(`div`,{className:`max-h-72 overflow-y-auto py-1 space-y-1`,children:h})]})]})}function ue({availableProviders:e,selectedProvider:t,showProviderPicker:n=!0,showCodexCliRequirementHints:i=!1,model:l,modelOptions:d,onProviderChange:f,onModelChange:g,onModelOptionChange:_,planMode:y=!1,onPlanModeChange:b,includePlanMode:x=!0,className:S}){let C=ee(v),w=e.find(e=>e.id===t)??e[0],E=w?.id??t,O=q[E],k=T,A=x&&w?.supportsPlanMode&&b,M=E===`claude`&&`contextWindow`in d?d:null,P=E===`codex`&&`fastMode`in d?d:null,F=w?.models??ne,I=F.find(e=>e.id===l)?.contextWindowOptions??[],L=M?.contextWindow??o[0].id,R=L===`1m`?z:V,B=F.find(e=>e.id===l)?.label??l,H=c(E)?(0,K.jsx)(ce,{models:F,selectedModel:l,onSelect:e=>g?.(E,e),ModelIcon:k,emptyMessage:re[E]}):(0,K.jsx)(Y,{trigger:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(k,{className:`h-3.5 w-3.5`}),(0,K.jsx)(`span`,{children:B})]}),children:e=>F.map(t=>{let n=T;return(0,K.jsx)(J,{onClick:()=>{g?.(E,t.id),e()},selected:l===t.id,icon:(0,K.jsx)(n,{className:`h-4 w-4 text-muted-foreground`}),label:i&&E===`codex`&&t.id===`gpt-5.5`?(0,K.jsxs)(K.Fragment,{children:[t.label,` `,(0,K.jsx)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:`codex-cli >= 0.124`})]}):t.label},t.id)})});return(0,K.jsxs)(`div`,{className:u(`flex md:justify-center items-center gap-0.5`,S),children:[n?(0,K.jsx)(Y,{disabled:!f,trigger:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(O,{className:`h-3.5 w-3.5`}),(0,K.jsx)(`span`,{children:w?.label??E})]}),children:t=>e.map(e=>{let n=q[e.id];return(0,K.jsx)(J,{onClick:()=>{f?.(e.id),t()},selected:E===e.id,icon:(0,K.jsx)(n,{className:`h-4 w-4 text-muted-foreground`}),label:e.label},e.id)})}):null,g==null?(0,K.jsx)(h,{label:`Model is locked while a cron job is running — pause or remove the cron job to change it`,side:`top`,children:(0,K.jsxs)(`span`,{"aria-disabled":`true`,className:`flex min-h-[36px] items-center gap-1.5 px-2 py-1 text-sm rounded-md text-muted-foreground [&>svg]:shrink-0 opacity-70 cursor-default [&>span]:whitespace-nowrap`,children:[(0,K.jsx)(N,{className:`h-3.5 w-3.5`}),(0,K.jsx)(`span`,{children:B})]})}):H,c(E)?null:(0,K.jsx)(Y,{trigger:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(m,{className:`h-3.5 w-3.5`}),(0,K.jsx)(`span`,{children:E===`claude`?s.find(e=>e.id===d.reasoningEffort)?.label??d.reasoningEffort:r.find(e=>e.id===d.reasoningEffort)?.label??d.reasoningEffort})]}),children:e=>E===`claude`?a(l,C).map(t=>(0,K.jsx)(J,{onClick:()=>{_({type:`claudeReasoningEffort`,effort:t.id}),e()},selected:d.reasoningEffort===t.id,icon:(0,K.jsx)(m,{className:`h-4 w-4 text-muted-foreground`}),label:t.label},t.id)):r.map(t=>(0,K.jsx)(J,{onClick:()=>{_({type:`codexReasoningEffort`,effort:t.id}),e()},selected:d.reasoningEffort===t.id,icon:(0,K.jsx)(m,{className:`h-4 w-4 text-muted-foreground`}),label:t.label},t.id))}),E===`claude`&&I.length>1?(0,K.jsx)(Y,{trigger:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(R,{className:`h-3.5 w-3.5`}),(0,K.jsx)(`span`,{children:I.find(e=>e.id===L)?.label??L})]}),children:e=>I.map(t=>(0,K.jsx)(J,{onClick:()=>{_({type:`contextWindow`,contextWindow:t.id}),e()},selected:L===t.id,icon:t.id===`1m`?(0,K.jsx)(z,{className:`h-4 w-4 text-muted-foreground`}):(0,K.jsx)(V,{className:`h-4 w-4 text-muted-foreground`}),label:t.label,description:t.id===`1m`?`Expanded context window`:`Standard context window`},t.id))}):null,E===`codex`?(0,K.jsx)(Y,{trigger:(0,K.jsxs)(K.Fragment,{children:[P?.fastMode?(0,K.jsx)(D,{className:`h-3.5 w-3.5`}):(0,K.jsx)(D,{className:`h-3.5 w-3.5 -scale-x-100`}),(0,K.jsx)(`span`,{children:P?.fastMode?`Fast Mode`:`Standard`})]}),triggerClassName:P?.fastMode?`text-success-text`:void 0,children:e=>(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(J,{onClick:()=>{_({type:`fastMode`,fastMode:!1}),e()},selected:!P?.fastMode,icon:(0,K.jsx)(D,{className:`h-4 w-4 text-muted-foreground -scale-x-100`}),label:`Standard`}),(0,K.jsx)(J,{onClick:()=>{_({type:`fastMode`,fastMode:!0}),e()},selected:!!P?.fastMode,icon:(0,K.jsx)(D,{className:`h-4 w-4 text-muted-foreground`}),label:`Fast Mode`})]})}):null,A?(0,K.jsx)(Y,{trigger:(0,K.jsxs)(K.Fragment,{children:[y?(0,K.jsx)(p,{className:`h-3.5 w-3.5`}):(0,K.jsx)(j,{className:`h-3.5 w-3.5`}),(0,K.jsx)(`span`,{children:y?`Plan Mode`:`Full Access`})]}),triggerClassName:y?`text-info-text`:void 0,children:e=>(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(J,{onClick:()=>{b(!1),e()},selected:!y,icon:(0,K.jsx)(j,{className:`h-4 w-4 text-muted-foreground`}),label:`Full Access`,description:`Execution without approval`}),(0,K.jsx)(J,{onClick:()=>{b(!0),e()},selected:y,icon:(0,K.jsx)(p,{className:`h-4 w-4 text-muted-foreground`}),label:`Plan Mode`,description:`Review a plan before execution`})]})}):null]})}var de=[{value:`cursor`,label:`Cursor`},{value:`xcode`,label:`Xcode`},{value:`windsurf`,label:`Windsurf`},{value:`custom`,label:`Custom`}],X={cursor:`/editor-icons/cursor.png`,defaultApp:`/editor-icons/default-app.png`,finder:`/editor-icons/finder.png`,preview:`/editor-icons/preview.png`,xcode:`/editor-icons/xcode.png`,terminal:`/editor-icons/terminal.png`,windsurf:`/editor-icons/windsurf.png`,custom:`/editor-icons/custom.png`};function Z({src:e,className:t}){return(0,K.jsx)(`img`,{src:e,alt:``,"aria-hidden":`true`,draggable:!1,className:t})}function fe({preset:e,className:t}){switch(e){case`xcode`:return(0,K.jsx)(Z,{src:X.xcode,className:t});case`windsurf`:return(0,K.jsx)(Z,{src:X.windsurf,className:t});case`custom`:return(0,K.jsx)(Z,{src:X.custom,className:t});default:return(0,K.jsx)(Z,{src:X.cursor,className:t})}}function pe({className:e}){return(0,K.jsx)(Z,{src:X.finder,className:e})}function me({className:e}){return(0,K.jsx)(Z,{src:X.preview,className:e})}function he({className:e}){return(0,K.jsx)(Z,{src:X.defaultApp,className:e})}function ge({className:e}){return(0,K.jsx)(i,{className:e})}function _e({className:e}){return(0,K.jsx)(Z,{src:X.terminal,className:e})}var ve=2e3,Q={},$=l()((e,t)=>({copiedTokens:Q,nextToken:1,markCopied:n=>{let r=t().nextToken;return e(e=>({nextToken:r+1,copiedTokens:{...e.copiedTokens,[n]:r}})),r},clearCopied:(n,r)=>{let{copiedTokens:i}=t();if(i[n]!==r)return;let a=Object.fromEntries(Object.entries(i).filter(([e])=>e!==n));e({copiedTokens:Object.keys(a).length>0?a:Q})}}));async function ye(e,t,n=g){await t();let r=$.getState().markCopied(e);n.setTimeout(()=>$.getState().clearCopied(e,r),ve)}function be(e){return $(t=>t.copiedTokens[e]!==void 0)}export{C as _,fe as a,me as c,J as d,H as f,k as g,N as h,de as i,_e as l,F as m,be as n,pe as o,L as p,he as r,ge as s,ye as t,ue as u};
|