@cuongtran001/kanna 1.76.1 → 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-ClqCJi3S.js → BoardsPage-DCh9hj51.js} +1 -1
- package/dist/client/assets/{BoardsRoutePage-tILf5ZVU.js → BoardsRoutePage-DPw5ve6w.js} +1 -1
- package/dist/client/assets/ChatPage-CEeRSI6r.js +93 -0
- package/dist/client/assets/{CronJobRow-FbVVkka2.js → CronJobRow-D2ex-2ZV.js} +1 -1
- package/dist/client/assets/{CronJobsPage-Cjtn8F5l.js → CronJobsPage-BGk_HGOZ.js} +1 -1
- package/dist/client/assets/{FilePreviewSheet-D6Js0oz9.js → FilePreviewSheet-BnQeVNHq.js} +2 -2
- package/dist/client/assets/{FlowSurface-BD6Fv7KF.js → FlowSurface-RRPSX4vy.js} +1 -1
- package/dist/client/assets/{GenUIBlock-CCn7-ePE.js → GenUIBlock-DKGMRQmN.js} +2 -2
- package/dist/client/assets/{KannaSocketProvider-m8QFHU_F.js → KannaSocketProvider-CNmZYIUz.js} +1 -1
- package/dist/client/assets/{LocalProjectsPage-CPKymu8m.js → LocalProjectsPage-Dr5JrPMN.js} +1 -1
- package/dist/client/assets/SettingsPage-Bhy_51Vm.js +13 -0
- package/dist/client/assets/{StackBoardsRoutePage-CzojEmXE.js → StackBoardsRoutePage-B-O5uIvz.js} +1 -1
- package/dist/client/assets/{ToolCallMessage-BUbmvfUG.js → ToolCallMessage-C8Z9pIBo.js} +3 -3
- package/dist/client/assets/{VChartSurface-CeQqqBBu.js → VChartSurface-C_LuezMZ.js} +1 -1
- package/dist/client/assets/{WorkflowsPage-nsRU1QEm.js → WorkflowsPage-BmGlYGWF.js} +1 -1
- package/dist/client/assets/{WorkflowsSection-D5tluUkJ.js → WorkflowsSection-SjENofEr.js} +1 -1
- package/dist/client/assets/{chart-renderer-6tEMKXRu.js → chart-renderer-Ce4S2Bew.js} +1 -1
- package/dist/client/assets/{chatSounds-DHfUpC0L.js → chatSounds-ih86yh5r.js} +1 -1
- package/dist/client/assets/chevron-left-DZQr0sRY.js +1 -0
- package/dist/client/assets/{clipboard.adapter-CYn3H1oo.js → clipboard.adapter-BLu7Xx3Q.js} +1 -1
- package/dist/client/assets/{columnStyle-BOebgRHp.js → columnStyle-CXivQEvf.js} +1 -1
- package/dist/client/assets/{contextWindow-D1RRC1b-.js → contextWindow-Cpz1HmWo.js} +1 -1
- package/dist/client/assets/copyFeedbackStore-NslkB2Ap.js +1 -0
- package/dist/client/assets/{createScopedStore-C0pJOwR9.js → createScopedStore-CZBfIcri.js} +1 -1
- package/dist/client/assets/{dist-DRcJM7Lq.js → dist-DHxwilnY.js} +1 -1
- package/dist/client/assets/{ellipsis-BrvN3hX9.js → ellipsis-Ba-nFhTR.js} +1 -1
- package/dist/client/assets/{flow-kinds-CkaWSYYm.js → flow-kinds-BIh-hHN9.js} +1 -1
- package/dist/client/assets/{folder-BunWGsz1.js → folder-B34crHxE.js} +1 -1
- package/dist/client/assets/{formatDuration-SKek8N5u.js → formatDuration-JKx5LBF4.js} +1 -1
- package/dist/client/assets/{genui-td2w9ZBU.js → genui-DmCmYDHH.js} +1 -1
- package/dist/client/assets/{globe-BIvdtBFt.js → globe-DV73QVTP.js} +1 -1
- package/dist/client/assets/{host-6jbynfZo.js → host-FY7xgVKG.js} +1 -1
- package/dist/client/assets/index-BYus2o1t.css +1 -0
- package/dist/client/assets/{index-CVlOrRGa.js → index-MU4WHdaY.js} +3 -3
- package/dist/client/assets/{info-DhG2cfVg.js → info-COBF8Hkz.js} +1 -1
- package/dist/client/assets/{input-C3R4k6-W.js → input-BJRDZBOh.js} +1 -1
- package/dist/client/assets/{lexicalToReact-CfHucecr.js → lexicalToReact-BVHTqlu5.js} +3 -3
- package/dist/client/assets/{log-CYjZ_PZ1.js → log-7NXJbErN.js} +1 -1
- package/dist/client/assets/{monitor-DwO0L7DX.js → monitor-Wl8GxNgR.js} +1 -1
- package/dist/client/assets/{pendingActionsStore-By8_y_o0.js → pendingActionsStore-DDpYeRNm.js} +1 -1
- package/dist/client/assets/{play-B-vQkmFp.js → play-CmxvHVzO.js} +1 -1
- package/dist/client/assets/{plus-BDLscSN_.js → plus-C3QbbvBk.js} +1 -1
- package/dist/client/assets/{popover-104yTR95.js → popover-Dm-pdC4M.js} +1 -1
- package/dist/client/assets/{pushClient-DiLvwOUU.js → pushClient-COMO42mb.js} +1 -1
- package/dist/client/assets/runDetached-mjGecpjX.js +1 -0
- package/dist/client/assets/{segmented-control-CROY-CuD.js → segmented-control-CfauwRtX.js} +1 -1
- package/dist/client/assets/{select-BiDB8UlY.js → select-7zTZH1xA.js} +1 -1
- package/dist/client/assets/{settings-header-button-DrzrbXmr.js → settings-header-button-TMNvLQQs.js} +1 -1
- package/dist/client/assets/{sidebarPendingActions-Db0_daIj.js → sidebarPendingActions-Bd_2oNH_.js} +1 -1
- package/dist/client/assets/{square-pen-DXsycXBb.js → square-pen-BB5GlYSZ.js} +1 -1
- package/dist/client/assets/{state-mark-C1zpvAww.js → state-mark-x5ennY81.js} +1 -1
- package/dist/client/assets/{terminal-BSJXFRP8.js → terminal-D5pfyUjC.js} +1 -1
- package/dist/client/assets/{timer.adapter-DsZB_-cb.js → timer.adapter-C5oNrWbM.js} +1 -1
- package/dist/client/assets/{tools-MYv8-phR.js → tools-BlXGwwwh.js} +1 -1
- package/dist/client/assets/{triangle-alert-Ck2DCXSO.js → triangle-alert-BwAIBaGG.js} +1 -1
- package/dist/client/assets/{useAppGlobalState-BwEVtuo2.js → useAppGlobalState-BL9aCLak.js} +1 -1
- package/dist/client/assets/{useKannaState-DbEQQ6kC.js → useKannaState-DTILzHBb.js} +1 -1
- package/dist/client/assets/{useTheme-BHNSJGUC.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-C8syKflw.js +0 -93
- package/dist/client/assets/SettingsPage-04gXMi4Y.js +0 -13
- package/dist/client/assets/chevron-left-BO_O7rLs.js +0 -1
- package/dist/client/assets/copyFeedbackStore-DdNWcKCp.js +0 -1
- package/dist/client/assets/index-D8o_YX_z.css +0 -1
- package/dist/client/assets/runDetached-DtQs26wR.js +0 -1
|
@@ -0,0 +1,13 @@
|
|
|
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-BL9aCLak.js";import{a as ke,c as k,d as Ae,f as je,p as Me,s as Ne}from"./log-7NXJbErN.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-DDpYeRNm.js";import{C as Fe,S as Ie,_ as Le,a as Re,b as ze,d as Be,g as Ve,h as He,i as Ue,m as R,n as We,t as Ge,v as Ke,y as qe}from"./copyFeedbackStore-NslkB2Ap.js";import{Bt as Je,Vt as Ye,t as Xe,zt as Ze}from"./lexicalToReact-BVHTqlu5.js";import{n as Qe,r as $e,t as et}from"./clipboard.adapter-BLu7Xx3Q.js";import{r as tt}from"./dist-DHxwilnY.js";import{a as nt,i as z,n as rt,o as it,r as at,t as ot}from"./select-7zTZH1xA.js";import{a as st,c as ct,g as lt,h as ut,i as dt,m as ft,n as pt,o as mt,p as ht,t as gt,u as _t}from"./pushClient-COMO42mb.js";import{t as vt}from"./info-COBF8Hkz.js";import{t as yt}from"./monitor-Wl8GxNgR.js";import{i as bt,n as xt,t as St}from"./formatDuration-JKx5LBF4.js";import{t as B}from"./plus-C3QbbvBk.js";import{g as Ct,i as wt,n as Tt,o as Et,r as Dt,t as Ot,u as kt}from"./timer.adapter-C5oNrWbM.js";import{a as At,c as jt,o as Mt,s as Nt,t as Pt}from"./segmented-control-CfauwRtX.js";import{t as V}from"./input-BJRDZBOh.js";import{C as Ft,E as It,S as Lt,T as H,_ as Rt,b as zt,d as Bt,f as Vt,g as Ht,h as Ut,m as Wt,p as Gt,r as Kt,v as qt,w as Jt,x as Yt,y as Xt}from"./useTheme-9knhPtrR.js";import{t as Zt}from"./runDetached-mjGecpjX.js";import{t as Qt}from"./chatSounds-ih86yh5r.js";import{c as $t,l as U,o as en,r as tn}from"./contextWindow-Cpz1HmWo.js";import{n as nn}from"./state-mark-x5ennY81.js";import{n as rn,r as an,t as on}from"./popover-Dm-pdC4M.js";import{t as sn}from"./settings-header-button-TMNvLQQs.js";var cn={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`}]]};cn.node;var ln=N(cn),un={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`]};un.node;var dn=N(un),fn={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`]};fn.node;var pn=N(fn),W={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`}]]};W.node;var mn=N(W),hn={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`}]]};hn.node;var gn=N(hn),_n={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`}]]};_n.node;var vn=N(_n),yn={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`}]]};yn.node;var bn=N(yn),xn={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`}]]};xn.node;var Sn=N(xn),Cn={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`}]]};Cn.node;var G=N(Cn),K={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`}]]};K.node;var wn=N(K),Tn={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`}]]};Tn.node;var En=N(Tn),Dn={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`}]]};Dn.node;var On=N(Dn),kn={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`}]]};kn.node;var An=N(kn),jn={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`}]]};jn.node;var Mn=N(jn),Nn={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`}]]};Nn.node;var Pn=N(Nn),Fn={enabled:!1,cloudflaredPath:`cloudflared`,mode:`always-ask`},q=e(t(),1),J=e(i(),1);function In(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 Ln={maxFileSizeMb:2048},Rn=51200,zn=`gpt-5.4-mini`;function Bn(e){return e===`previous-assistant-reply`||e===`full-transcript`}function Vn(e){return e===`auto`||e===`manual`}var Hn=[`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`],Un=[`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 Wn(){return{name:``,provider:`claude`,model:D(`claude`).defaultModel,modelOptions:{...O},systemPrompt:``,contextScope:`previous-assistant-reply`,triggerMode:`auto`}}function Gn(){return{draft:Wn(),error:null,pending:!1,confirmDelete:!1}}var Kn=k()(e=>({editing:{kind:`list`},form:Gn(),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 Y(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 qn(e){let{draft:t,patchDraft:n}=e;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Y,{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)(Y,{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)(ht,{"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)(Y,{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 Jn(e){return`contextWindow`in e}function Yn(e){return`fastMode`in e}function Xn(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)(Zn,{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)($n,{subagents:e.subagents,editing:e.editing,onSelect:e.onSelect,onStartCreate:e.onStartCreate}),i?(0,J.jsx)(or,{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)(Qn,{})]})}function Zn(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 Qn(){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 $n(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)(er,{provider:n.provider})]}),(0,J.jsx)(`span`,{className:`w-full truncate text-xs text-muted-foreground`,children:r})]})},n.id)})})]})}function er({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 tr=[{value:`claude`,label:`Claude`},{value:`codex`,label:`Codex`},{value:`openrouter`,label:`OpenRouter`}],nr=[...tr,{value:`custom`,label:`Custom endpoints`}];function rr(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 ir=[{value:`previous-assistant-reply`,label:`Last reply`},{value:`full-transcript`,label:`Full transcript`}],ar=[{value:`auto`,label:`Auto`},{value:`manual`,label:`Manual`}];function or(e){let t=(0,q.useMemo)(()=>e.mode===`edit`&&e.subject?_r(e.subject):gr(`claude`,e.providerDefaults,e.availableProviders),[e.mode,e.subject,e.providerDefaults,e.availableProviders]),n=Kn(e=>e.resetForm),r=Kn(e=>e.form),i=Kn(e=>e.patchFormDraft),a=Kn(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`)?nr:tr,d=s?.field===`name`?s.message:null,f=s?.field===`general`?s.message:null,p=yr(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=gr(t,e.providerDefaults,e.availableProviders);i({provider:t,model:n.model,modelOptions:n.modelOptions})}function _(e){if(o.provider!==`claude`)return;let t=Jn(o.modelOptions)?o.modelOptions:O;i({modelOptions:{...O,...t,reasoningEffort:e}})}function v(e){if(o.provider!==`claude`)return;let t=Jn(o.modelOptions)?o.modelOptions:O;i({modelOptions:{...O,...t,contextWindow:e}})}function y(e){if(o.provider!==`codex`)return;let t=Yn(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:xr(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,...Jn(o.modelOptions)?o.modelOptions:{}}:null,S=o.provider===`codex`?{...Te,...Yn(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)(Y,{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:Sr(e.target.value)}),maxLength:64,placeholder:`reviewer`,className:`font-mono`})}),(0,J.jsx)(Y,{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)(Y,{label:`Provider`,children:(0,J.jsx)(Pt,{value:o.provider,onValueChange:e=>{ae(e)&&g(e)},options:u,size:`sm`})}),(0,J.jsx)(Y,{label:`Model`,children:(0,J.jsxs)(ot,{value:o.model,onValueChange:e=>h({model:e}),children:[(0,J.jsx)(nt,{"data-testid":`subagent-form-model`,className:`w-full md:w-72`,children:(0,J.jsx)(it,{placeholder:`Select a model`})}),(0,J.jsx)(rt,{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)(Y,{label:`Reasoning effort`,children:(0,J.jsx)(Pt,{value:ee.reasoningEffort,onValueChange:e=>{ie(e)&&_(e)},options:we.map(e=>({value:e.id,label:e.label})),size:`sm`})}),(0,J.jsx)(Y,{label:`Context window`,children:(0,J.jsx)(Pt,{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)(Y,{label:`Reasoning effort`,children:(0,J.jsx)(Pt,{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)(Y,{label:`Context scope`,children:(0,J.jsx)(Pt,{value:o.contextScope,onValueChange:e=>{Bn(e)&&h({contextScope:e})},options:ir,size:`sm`})}),(0,J.jsx)(Y,{label:`Trigger`,hint:`Auto: the main agent may delegate on its own. Manual: only runs when you @-mention it.`,children:(0,J.jsx)(Pt,{value:o.triggerMode??`auto`,onValueChange:e=>{Vn(e)&&h({triggerMode:e})},options:ar,size:`sm`})}),(0,J.jsx)(Y,{label:`System prompt`,hint:`What this persona should focus on. Plain text.`,children:(0,J.jsx)(ht,{"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)(Y,{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)(qn,{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 sr=[],cr={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 lr(e){let t=H(e=>e.settings?.subagents??sr),n=H(e=>e.settings?.providerDefaults??cr),r=H(Ut),i=H(Ht),a=pe(U(e=>e.models)),o=(0,q.useMemo)(()=>rr(d(oe([...ue],r),i),a),[r,i,a]),s=Kn(e=>e.editing),c=Kn(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)(mr,{subagents:t,handleWriteAppSettings:e.state.handleWriteAppSettings}),(0,J.jsx)(Xn,{subagents:t,providerDefaults:n,availableProviders:o,editing:s,onSelect:u,onStartCreate:f,onCancelEditing:p,handlers:l})]})}var ur=`__none__`,dr=30,fr=86400,pr=600;function mr(e){let t=H(e=>e.settings?.subagentRuntime),n=t?Math.round(t.runTimeoutMs/1e3):pr,r=t?.defaultLoopSubagentId??null,i=Kn(e=>e.timeoutDraft),a=Kn(e=>e.setTimeoutDraft),o=Kn(e=>e.loopError),s=Kn(e=>e.setLoopError);(0,q.useEffect)(()=>{a(String(n))},[n]);function c(){let t=Number(i);if(!Number.isInteger(t)||t<dr||t>fr){a(String(n)),s(`Timeout must be a whole number of seconds between ${dr} and ${fr}.`);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===ur?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)(Y,{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:dr,max:fr,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)(Y,{label:`Default loop subagent`,hint:`The subagent setup_loop delegates each chunk to when no explicit id is given.`,children:(0,J.jsxs)(ot,{value:r??ur,onValueChange:l,children:[(0,J.jsx)(nt,{className:`w-full md:w-72`,children:(0,J.jsx)(it,{placeholder:`None`})}),(0,J.jsxs)(rt,{children:[(0,J.jsx)(z,{value:ur,children:`None (require explicit id)`}),e.subagents.map(e=>(0,J.jsx)(z,{value:e.id,children:e.name},e.id))]})]})})]})}var hr=new Set([`EMPTY_NAME`,`INVALID_CHAR`,`RESERVED_NAME`,`DUPLICATE_NAME`,`TOO_LONG`]);function gr(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 _r(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 vr=(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 yr(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??``)||!vr(e.allowedPaths,t.allowedPaths)||(e.maxTurns??null)!==(t.maxTurns??null)||(e.allowBeaconTools??!1)!==(t.allowBeaconTools??!1)||!br(e.modelOptions,t.modelOptions)}function br(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 xr(e){return hr.has(e.code)?{field:`name`,message:e.message}:{field:`general`,message:e.message}}function Sr(e){return e.toLowerCase().replace(/[^a-z0-9_-]+/g,`-`).slice(0,64)}function X({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 Cr({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 wr({children:e}){return(0,J.jsx)(`ul`,{className:`flex flex-col divide-y rounded-md border`,children:e})}function Tr({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)(bt,{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 Er=new Set;function Dr(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 Or=k()(e=>({editing:{kind:`list`},testingServerIds:Er,editorForm:Dr(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?Er:r}}),resetEditorForm:t=>e({editorForm:Dr(t)}),patchEditorForm:t=>e(e=>({editorForm:{...e.editorForm,...t}}))}));function kr(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 Ar(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 jr(e){return e.submitting?`Saving…`:e.isEdit?`Save changes`:e.addLabel}function Mr({server:e,handlers:t,onEdit:n,dom:r=Ae}){let i=Or(t=>t.testingServerIds.has(e.id)),a=Or(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)(Nr,{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)(Pr,{result:e.lastTest,pending:i}),e.transport!==`stdio`&&(0,J.jsx)(Fr,{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)(Ye,{className:j(`h-4 w-4`,i&&`animate-spin`)})}),(0,J.jsx)(Tr,{label:e.name,onEdit:n,onDelete:f,deletePending:c})]})]})}function Nr({transport:e}){return(0,J.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-xs`,children:e})}function Pr({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)(ft,{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 Fr({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)(ft,{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 Ir=new Set([`stdio`,`http`,`sse`,`ws`]);function Lr(e){return Ir.has(e)}var Rr=`new`;function zr({pending:e,copied:t}){return e?(0,J.jsx)(I,{className:`size-3`}):t?(0,J.jsx)($e,{className:`h-3 w-3 text-success-text`}):(0,J.jsx)(Qe,{className:`h-3 w-3`})}var Br=e=>({customMcpServers:e});function Vr(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)(En,{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)(wr,{children:e.servers.map(t=>(0,J.jsx)(Mr,{server:t,handlers:e.handlers,onEdit:()=>e.onSelect(t.id)},t.id))})]}):(0,J.jsx)(Hr,{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 Hr({initial:e,existingNames:t,onCancel:n,handlers:r,clipboard:i=et}){let a=Or(e=>e.editorForm),o=Or(e=>e.resetEditorForm),s=Or(e=>e.patchEditorForm),c=(0,q.useCallback)(e=>{Lr(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??Rr,re=L(`mcpServers.toggleOAuth`,w),ie=F(re),ae=L(`mcpServers.copyAuthUrl`,w),oe=F(ae),se=We(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,()=>Ge(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 Ar({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=jr({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)(ot,{value:u,onValueChange:c,children:[(0,J.jsx)(nt,{children:(0,J.jsx)(it,{})}),(0,J.jsxs)(rt,{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)(ht,{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)(ht,{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)(ht,{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)(Ie,{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)(Fr,{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)(lt,{className:`h-3 w-3`})]}),(0,J.jsx)(ft,{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)(zr,{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 Ur(e){let t=H(Wt),n=Or(e=>e.editing),r=Or(e=>e.setEditing),i=kr(Br,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)(Vr,{servers:t,editing:n,onSelect:e=>r({kind:`edit`,id:e}),onStartCreate:()=>r({kind:`create`}),onCancelEditing:()=>r({kind:`list`}),handlers:a})}var Wr=new Set([`checking`,`downloading`,`installing`,`restarting`]);function Gr(e){return e!==null&&Wr.has(e.state)}function Kr(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 qr(e){switch(e.state){case`failed`:return`destructive`;case`current`:return`muted`;case`checking`:case`downloading`:case`installing`:case`restarting`:return`active`}}var Jr={},Yr={},Xr={},Zr={};function Qr(e,t){return`${e}:${t}`}function $r(e,t,n){let r=Object.fromEntries(Object.entries(e).filter(([e])=>e!==t));return Object.keys(r).length>0?r:n}var Z=k()(e=>({pairing:null,expandedId:null,drafts:Jr,updateErrors:Yr,aliasErrors:Xr,openExplanations:Zr,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=>({drafts:$r(e.drafts,t,Jr)})),setUpdateError:(t,n)=>e(e=>n===null?{updateErrors:$r(e.updateErrors,t,Yr)}:{updateErrors:{...e.updateErrors,[t]:n}}),beginAliasEdit:(t,n)=>e(e=>({drafts:{...e.drafts,[Qr(t,`alias`)]:n}})),endAliasEdit:t=>e(e=>({drafts:$r(e.drafts,Qr(t,`alias`),Jr),aliasErrors:$r(e.aliasErrors,t,Xr)})),setAliasError:(t,n)=>e(e=>n===null?{aliasErrors:$r(e.aliasErrors,t,Xr)}:{aliasErrors:{...e.aliasErrors,[t]:n}}),toggleExplanation:t=>e(e=>({openExplanations:t in e.openExplanations?$r(e.openExplanations,t,Zr):{...e.openExplanations,[t]:!0}}))})),ei=`kanna-beacon`,ti=`ABCDEFGHJKLMNPQRSTUVWXYZ23456789`,ni=`https://github.com/cuongtranba/kanna/releases/latest`;RegExp(`^[${ti}]{8}$`);function ri(e){return`${ei}://pair?url=${encodeURIComponent(e.kannaUrl)}&code=${encodeURIComponent(e.code)}`}function ii(e){return e.replace(/^v/,``).split(`-`)[0].split(`.`).map(e=>Number.parseInt(e,10))}function ai(e,t){if(e===t)return!1;let n=ii(e),r=ii(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 oi={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`};function si({beaconId:e,alias:t,displayName:n}){let r=Z(e=>e.beginAliasEdit),i=(0,q.useCallback)(()=>{r(e,t??``)},[t,e,r]);return(0,J.jsx)(ft,{label:`Set a short name`,children:(0,J.jsx)(A,{variant:`ghost`,size:`icon-sm`,onClick:i,"aria-label":`Set a short name for ${n}`,children:(0,J.jsx)(bt,{className:`h-3.5 w-3.5`})})})}function ci({beaconId:e,alias:t,displayName:n,onSetAlias:r}){let i=Qr(e,`alias`),a=Z(e=>e.drafts[i]),o=Z(t=>t.aliasErrors[e]??null),s=Z(e=>e.setDraft),c=Z(e=>e.setAliasError),l=Z(e=>e.endAliasEdit),u=L(`beacons.setAlias`,e),d=F(u),f=a??``,p=f.length===0?null:R(f),m=f.length>0&&p===null&&f!==t,h=p??o,g=(0,q.useCallback)(t=>{s(i,t.target.value.toLowerCase()),c(e,null)},[e,i,c,s]),_=(0,q.useCallback)(t=>{P(u,async()=>{try{await r(e,t),l(e)}catch(t){c(e,je(t))}})},[e,l,r,u,c]),v=(0,q.useCallback)(()=>{_(f)},[_,f]),y=(0,q.useCallback)(()=>{_(null)},[_]),b=(0,q.useCallback)(()=>{l(e)},[e,l]);return a===void 0?null:(0,J.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(V,{value:f,onChange:g,placeholder:`office-mac`,disabled:d,"aria-label":`Short name for ${n}`,"aria-invalid":h!==null||void 0,className:`w-48`}),(0,J.jsx)(A,{size:`sm`,onClick:v,pending:d,disabled:!m,children:`Save`}),(0,J.jsx)(A,{variant:`ghost`,size:`sm`,onClick:b,disabled:d,children:`Cancel`}),t!==null&&(0,J.jsx)(A,{variant:`ghost`,size:`sm`,onClick:y,disabled:d,children:`Clear alias`})]}),(0,J.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Type `,(0,J.jsxs)(`span`,{className:`font-mono`,children:[`@beacon/`,f.length>0?f:`name`]}),` in a message to refer to this machine.`]}),h!==null&&(0,J.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive-text`,children:h})]})}var li=`Lets the agent run commands and scripts on this machine. Off means every command and script is refused, and the agent can only read and copy files inside the folders below. When on, each command still waits for your approval unless it is on the always-run list or you switch on running without asking.`,ui=`Skips the approval prompt. Reads and writes inside the folders below, and every command and script, run immediately. Leave it off to review each action before it runs on this machine.`,di=`The agent can list, search, read and copy files off this machine only inside these folders and their subfolders. Anything outside is refused. With none listed it cannot read from this machine at all. Each read waits for your approval unless running without asking is on.`,fi=`The agent can copy files onto this machine only inside these folders and their subfolders. Leave empty and it cannot write to this machine at all. Each write waits for your approval unless running without asking is on.`,pi=`Command names, such as git, that run immediately once running commands is allowed. Matching uses the command name only, so git covers every git subcommand. Anything not listed asks you first.`;function mi(e){return`beacon-explain-${e}`}function hi({explanationKey:e,subject:t}){let n=Z(t=>e in t.openExplanations),r=Z(e=>e.toggleExplanation),i=(0,q.useCallback)(()=>{r(e)},[e,r]);return(0,J.jsx)(ft,{label:`What does this do?`,children:(0,J.jsx)(A,{variant:`ghost`,size:`icon-sm`,onClick:i,"aria-expanded":n,"aria-controls":mi(e),"aria-label":`What does "${t}" do?`,children:(0,J.jsx)(vt,{className:`h-4 w-4`})})})}function gi({explanationKey:e,text:t}){let n=Z(t=>e in t.openExplanations);return(0,J.jsx)(`p`,{id:mi(e),hidden:!n,className:`text-13 text-muted-foreground`,children:t})}function _i({beaconId:e,scope:t,onSetScope:n}){let r=L(`beacons.setScope`,e),i=F(r),a=(0,q.useCallback)(t=>{P(r,()=>n(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)(vi,{explanationKey:Qr(e,`exec`),checked:t.exec,disabled:i,onChange:o,title:`Allow running commands`,explanation:li}),(0,J.jsx)(vi,{explanationKey:Qr(e,`autoRunScripts`),checked:t.autoRunScripts,disabled:i,onChange:s,title:`Run commands and scripts from this chat without asking each time`,explanation:ui}),(0,J.jsx)(yi,{label:`Folders the agent may read`,explanation:di,placeholder:`/Users/me/projects`,draftKey:Qr(e,`readRoots`),items:t.readRoots,disabled:i,onChange:c}),(0,J.jsx)(yi,{label:`Folders the agent may write to`,explanation:fi,placeholder:`/Users/me/inbox`,draftKey:Qr(e,`writeRoots`),items:t.writeRoots,disabled:i,onChange:l}),(0,J.jsx)(yi,{label:`Commands that always run without asking`,explanation:pi,placeholder:`git`,draftKey:Qr(e,`execAllowlist`),items:t.execAllowlist,disabled:i,onChange:u})]})}function vi({explanationKey:e,checked:t,disabled:n,onChange:r,title:i,explanation:a}){return(0,J.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsxs)(`label`,{className:`flex min-w-0 cursor-pointer items-center gap-3`,children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:t,disabled:n,onChange:r}),(0,J.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:i})]}),(0,J.jsx)(hi,{explanationKey:e,subject:i})]}),(0,J.jsx)(`div`,{className:`pl-7`,children:(0,J.jsx)(gi,{explanationKey:e,text:a})})]})}function yi({label:e,explanation:t,placeholder:n,draftKey:r,items:i,disabled:a,onChange:o}){let s=Z(e=>e.drafts[r]??``),c=Z(e=>e.setDraft),l=Z(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.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:e}),(0,J.jsx)(hi,{explanationKey:r,subject:e})]}),(0,J.jsx)(gi,{explanationKey:r,text: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)(bi,{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 bi({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)(Ct,{className:`h-4 w-4`})})]})}var xi=ke.split(`/`)[1],Si=L(`beacons.mintPairingCode`);function Ci(e,t){let n=new Map(e.map(e=>[e.id,e]));return t.map(e=>{let t=n.get(e.id);return{id:e.id,label:e.label,alias:e.alias??null,os:e.os,enabled:e.enabled,online:t?.online??!1,lastSeenAt:t?.lastSeenAt??null,beaconVersion:t?.beaconVersion??null,canSelfUpdate:t?.canSelfUpdate??!1,update:t?.update??null}})}function wi({rows:e,configs:t,handlers:n,serverVersion:r,dom:i=Ae,clipboard:a=et,timer:o=Ot}){let s=ct(1e3),c=(0,q.useMemo)(()=>Ci(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)(Ti,{now:s,handlers:n,dom:i,clipboard:a,timer:o}),c.length===0?(0,J.jsx)(Cr,{icon:ze,message:`No machines paired yet. Pair a machine to let the agent read files and run approved commands there.`}):(0,J.jsx)(wr,{children:c.map(e=>(0,J.jsx)(ji,{row:e,scope:l.get(e.id)?.scope??null,now:s,serverVersion:r,handlers:n,dom:i},e.id))})]})}function Ti({now:e,handlers:t,dom:n,clipboard:r,timer:i}){let a=Z(e=>e.pairing),o=Z(e=>e.setPairing),s=F(Si),c=(0,q.useCallback)(()=>{P(Si,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)(Ei,{code:a.code,expiresAt:a.expiresAt,now:e,dom:n,clipboard:r,timer:i})]})}function Ei({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=ri({kannaUrl:s,code:e}),u=L(`beacons.copyPairCommand`,e),d=F(u),f=We(u),p=(0,q.useCallback)(()=>{P(u,()=>Ge(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 ${xt(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)(lt,{className:`mr-1 h-4 w-4`}),`Open in Kanna Beacon`]}),(0,J.jsx)(`a`,{href:ni,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)(ft,{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)($e,{className:`h-4 w-4 text-success-text`}):(0,J.jsx)(Qe,{className:`h-4 w-4`})})})]})]})}function Di(e,t){return e.lastSeenAt===null?`Never connected`:`Last seen ${St(t-e.lastSeenAt)} ago`}var Oi=`This beacon is too old to update itself. Reinstall it once from the download page; after that, updates are one click.`;function ki({canSelfUpdate:e}){let t=j(`rounded-full border px-2 py-0.5 text-xs`,oi.outdated);return e?(0,J.jsx)(`span`,{className:t,children:`Update available`}):(0,J.jsx)(ft,{label:Oi,children:(0,J.jsx)(`a`,{href:ni,target:`_blank`,rel:`noreferrer`,className:t,children:`Update available`})})}function Ai({row:e,updateAvailable:t,handlers:n}){let r=L(`beacons.update`,e.id),i=F(r),a=Z(t=>t.updateErrors[e.id]??null),o=Z(e=>e.setUpdateError),s=t&&e.online&&e.canSelfUpdate&&!Gr(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)(nn,{tone:qr(e.update),label:Kr(e.update)}),s&&(0,J.jsxs)(A,{variant:`secondary`,size:`sm`,onClick:c,pending:i,"aria-label":`Update ${Be(e)} now`,children:[(0,J.jsx)(dn,{className:`mr-1 h-4 w-4`}),`Update now`]}),a!==null&&(0,J.jsx)(`span`,{role:`alert`,className:`text-destructive-text`,children:a})]})}function ji({row:e,scope:t,now:n,serverVersion:r,handlers:i,dom:a}){let o=Z(t=>t.expandedId===e.id),s=Z(e=>e.toggleExpanded),c=L(`beacons.setEnabled`,e.id),l=F(c),u=L(`beacons.delete`,e.id),d=F(u),f=Be(e),p=e.beaconVersion!==null&&r!==void 0&&ai(e.beaconVersion,r),m=(0,q.useCallback)(t=>{let n=t.target.checked;P(c,()=>i.onSetEnabled(e.id,n))},[c,i,e.id]),h=(0,q.useCallback)(()=>{a.confirmDialog(`Revoke "${f}"? The agent will lose access to this machine until you pair it again.`)&&P(u,()=>i.onDelete(e.id))},[u,f,a,i,e.id]),g=(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.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[(0,J.jsx)(`span`,{className:`truncate font-medium`,children:f}),(0,J.jsx)(si,{beaconId:e.id,alias:e.alias,displayName:f})]}),e.alias!==null&&(0,J.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-3 text-xs text-muted-foreground`,children:[(0,J.jsx)(`span`,{className:`font-mono`,children:e.label}),(0,J.jsxs)(`span`,{className:`font-mono`,children:[`@beacon/`,e.alias]})]}),(0,J.jsx)(ci,{beaconId:e.id,alias:e.alias,displayName:f,onSetAlias:i.onSetAlias}),(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)(nn,{tone:e.online?`active`:`muted`,label:e.online?`Online`:`Offline`}),(0,J.jsx)(`span`,{className:`tabular-nums`,children:Di(e,n)}),e.beaconVersion!==null&&(0,J.jsxs)(`span`,{className:`font-mono tabular-nums`,children:[`v`,e.beaconVersion]}),p&&(0,J.jsx)(ki,{canSelfUpdate:e.canSelfUpdate}),(0,J.jsx)(Ai,{row:e,updateAvailable:p,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:m,"aria-label":`Enable ${f}`}),(0,J.jsx)(`span`,{children:e.enabled?`Enabled`:`Disabled`})]}),t!==null&&(0,J.jsxs)(A,{variant:`ghost`,size:`sm`,onClick:g,"aria-expanded":o,children:[`Scope`,(0,J.jsx)(tt,{className:j(`ml-1 h-4 w-4 transition-transform`,o&&`rotate-180`)})]}),(0,J.jsx)(ft,{label:`Revoke this machine`,children:(0,J.jsx)(A,{variant:`ghost`,size:`icon`,onClick:h,pending:d,"aria-label":`Revoke ${f}`,children:(0,J.jsx)(le,{className:`h-4 w-4`})})})]})]}),o&&t!==null&&(0,J.jsx)(_i,{beaconId:e.id,scope:t,onSetScope:i.onSetScope})]})}function Mi(e){let t=Se(_),n=H(Gt),{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}}})},onSetAlias:async(e,t)=>{await r({customBeacons:{update:{id:e,patch:{alias:t}}}})},onDelete:async e=>{await r({customBeacons:{delete:{id:e}}})},onUpdate:a}),[r,i,a]);return(0,J.jsx)(wi,{rows:t,configs:n,handlers:o,serverVersion:xi})}var Ni={id:``,label:``,modelProvider:`claude`,supportedEfforts:[],offersOneMillionContext:!1};function Pi(e){return{...e,submitting:!1,error:null}}var Fi=k()(e=>({editing:{kind:`list`},editorForm:Pi(Ni),setEditing:t=>e({editing:t}),resetEditorForm:t=>e({editorForm:Pi(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}}))})),Ii=e=>({customModels:e}),Li=new Set([`claude`,`codex`]);function Ri(e){return Li.has(e)}var zi={claude:`Claude`,codex:`Codex`};function Bi({models:e,handlers:t,dom:n=Ae}){let r=Fi(e=>e.editing),i=Fi(e=>e.setEditing),a=Fi(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)(Hi,{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:[zi[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)(Cr,{icon:gn,message:`No ${zi[r]} models configured.`}):(0,J.jsx)(wr,{children:i.map(e=>(0,J.jsx)(Vi,{model:e,onEdit:()=>o({kind:`edit`,id:e.id}),onDelete:t.onDelete,dom:n},e.id))})]},r)})})}function Vi({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)(Tr,{label:e.label,onEdit:t,onDelete:o,deletePending:a})]})]})}function Hi({initial:e,existing:t,handlers:n,onDone:r}){let i=Fi(e=>e.editorForm),a=Fi(e=>e.patchEditorForm),o=Fi(e=>e.toggleSupportedEffort),s=Fi(e=>e.toggleOneMillionContext),c=(0,q.useCallback)(e=>{Ri(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=()=>Ar({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=jr({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)(ot,{value:d,onValueChange:c,disabled:_,children:[(0,J.jsx)(nt,{className:`min-w-[180px]`,children:(0,J.jsx)(it,{})}),(0,J.jsxs)(rt,{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 Ui(e){let t=H(Ut),n=kr(Ii,e.state);return(0,J.jsx)(Bi,{models:t,handlers:n})}function Wi(){let e=H(Ut),t=H(Ht);return(0,q.useMemo)(()=>d(oe([...ue],e),t),[e,t])}var Gi=32,Ki=`-`;function qi(){return{id:``,idTouched:!1,label:``,baseUrl:``,apiKey:``,models:[Ji()],contextWindow:``,hint:null}}function Ji(){return{id:``,label:``}}function Yi(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^[^a-z]+/,``).replace(/-+$/,``).slice(0,Gi).replace(/-+$/,``)}function Xi(e,t){if(e.length===0||!t.includes(e))return e;for(let n=2;;n+=1){let r=`-${n}`,i=`${e.slice(0,Gi-r.length)}${r}`;if(!t.includes(i))return i}}function Zi(e,t){return{id:Xi(e.id,t),idTouched:!0,label:e.label,baseUrl:e.baseUrl,apiKey:e.defaultApiKey??``,models:e.models.length>0?e.models.map(e=>({...e})):[Ji()],contextWindow:e.contextWindow===void 0?``:String(e.contextWindow),hint:e.hint??null}}function Qi(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 $i(e,t){return Xi(Yi(e),t)}function ea(e){return e.map(e=>({id:e.id.trim(),label:e.label.trim()})).filter(e=>e.id.length>0||e.label.length>0)}function ta(e){let t=e.replace(/[\s,_]/g,``);return t.length===0?void 0:Number(t)}function na(e){let t=ta(e.contextWindow);return{id:e.id.trim(),label:e.label.trim(),baseUrl:e.baseUrl.trim(),apiKey:e.apiKey.trim(),models:ea(e.models),...t===void 0?{}:{contextWindow:t}}}function ra(e){let t=e.apiKey.trim();return{label:e.label.trim(),baseUrl:e.baseUrl.trim(),models:ea(e.models),contextWindow:ta(e.contextWindow)??null,...t.length>0?{apiKey:t}:{}}}function ia(e,t,n){let r=na(e),i=te({...r,apiKey:t===`edit`&&r.apiKey.length===0?Ki: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 ${Gi} characters (${x}).`:i.message}function aa(e){return`${e<1e6&&e%1024==0?`${e/1024}k`:tn(e)} context`}function oa(e){return e===null?`Key set`:`Key ••••${e}`}function sa(e,t){return e===`create`?`API key`:t===null?`Leave blank to keep the saved key`:`Leave blank to keep ••••${t}`}function ca(e){return{...e,submitting:!1,error:null}}var Q=k()(e=>({editing:{kind:`list`},menuOpen:!1,listError:null,editorForm:ca(qi()),setMenuOpen:t=>e({menuOpen:t}),setListError:t=>e({listError:t}),startEditing:(t,n)=>e({editing:t,menuOpen:!1,listError:null,editorForm:ca(n)}),discardEditor:()=>e({editing:{kind:`list`},menuOpen:!1,editorForm:ca(qi())}),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:$i(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)}}))})),la=[{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."}],ua=e=>({customProviders:e}),da=`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 fa(e){return`${e} ${e===1?`model`:`models`}`}function pa({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)(X,{title:`Custom endpoints`,description:da,bordered:!1,alignStart:!0,children:r.kind===`list`?(0,J.jsx)(ma,{providers:e}):null}),r.kind===`list`?(0,J.jsx)(ha,{providers:e,onDelete:t.onDelete,dom:n}):(0,J.jsx)(_a,{providers:e,editingId:r.kind===`edit`?r.id:null,handlers:t})]})}function ma({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`},Zi(e,i))},[r,i]),o=(0,q.useCallback)(()=>{r({kind:`create`},qi())},[r]);return(0,J.jsxs)(on,{open:t,onOpenChange:n,children:[(0,J.jsx)(an,{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)(rn,{align:`end`,className:`w-64 p-1`,children:(0,J.jsxs)(`div`,{className:`space-y-1`,children:[la.map(e=>(0,J.jsx)(Ve,{onClick:()=>a(e),selected:!1,icon:(0,J.jsx)(Ke,{className:`h-4 w-4 text-muted-foreground`}),label:e.label},e.id)),(0,J.jsx)(Ve,{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 ha({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)(Cr,{icon:Ke,message:`No custom endpoints yet.`}):(0,J.jsx)(wr,{children:e.map(e=>(0,J.jsx)(ga,{provider:e,onDelete:t,dom:n},e.id))})]})}function ga({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},Qi(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)(ut,{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:fa(e.models.length)}),e.contextWindow===void 0?null:(0,J.jsx)(`span`,{className:`tabular-nums`,children:aa(e.contextWindow)}),(0,J.jsx)(`span`,{children:oa(e.apiKeyHint)})]}),(0,J.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:(0,J.jsx)(Tr,{label:e.label,onEdit:s,onDelete:c,deletePending:o})})]})}function _a({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=ia(r,f,m);if(e!==null){i({error:e});return}P(h,()=>Ar({patch:i,save:async()=>{t===null?await n.onCreate(na(r)):await n.onUpdate(t,ra(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:sa(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)(Ct,{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:jr({submitting:b,isEdit:d,addLabel:`Add endpoint`})}),(0,J.jsx)(A,{variant:`ghost`,onClick:u,disabled:b,children:`Cancel`})]})]})}function va(e){let t=H(Ht),n=kr(ua,e.state);return(0,J.jsx)(pa,{providers:t,handlers:n})}function ya(e,t){return{shortcut:e,expansion:t,submitting:!1,error:null}}var ba=k()(e=>({editing:{kind:`list`},editorForm:ya(``,``),setEditing:t=>e({editing:t}),resetEditorForm:(t,n)=>e({editorForm:ya(t,n)}),patchEditorForm:t=>e(e=>({editorForm:{...e.editorForm,...t}}))})),xa=e=>({textSnippets:e}),Sa=/^\S{1,32}$/;function Ca({snippets:e,handlers:t,dom:n=Ae}){let r=ba(e=>e.editing),i=ba(e=>e.setEditing),a=ba(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)(Ta,{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)(Cr,{icon:Pn,message:`No snippets yet. Add one to expand a shortcut with Tab.`}):(0,J.jsx)(wr,{children:e.map(e=>(0,J.jsx)(wa,{snippet:e,onEdit:()=>o({kind:`edit`,id:e.id}),onDelete:t.onDelete,dom:n},e.id))})]})}function wa({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)(Tr,{label:e.shortcut,onEdit:t,onDelete:o,deletePending:a})})]})}function Ta({initial:e,existing:t,handlers:n,onDone:r}){let i=ba(e=>e.editorForm),a=ba(e=>e.patchEditorForm),{shortcut:o,expansion:s,submitting:c,error:l}=i,u=e!==null,d=o.trim(),f=Sa.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=()=>Ar({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=jr({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)(ht,{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 Ea(e){let t=H(Jt),n=kr(xa,e.state);return(0,J.jsx)(Ca,{snippets:t,handlers:n})}function Da(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 Oa(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 ka({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:Oa(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)(Nt,{children:(0,J.jsxs)(At,{children:[(0,J.jsx)(jt,{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)(Mt,{"aria-hidden":`true`,children:n})]})})}function Aa({entry:e,now:t,isCurrent:n,concurrencyDefault:r,onRemove:i,onToggleDisabled:a,onTest:o,onChangeMaxConcurrent:s,onChangeBaseUrl:c,ports:l}){let u=l?.timer??Ot,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?An:On,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:Da(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)(ka,{entry:e,now:t})})]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,J.jsx)(ft,{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)(vn,{className:`size-3`,"aria-hidden":`true`}),`Test`]}),(0,J.jsx)(Nt,{children:(0,J.jsxs)(At,{children:[(0,J.jsx)(jt,{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)(Mt,{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)(ft,{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 ja({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 Ma({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)(ft,{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)(Aa,{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)(ja,{tokens:e,onWrite:n})]})}function Na(e,t){e.key===`Enter`&&(t(),e.currentTarget.blur())}function Pa(e){let t={};for(let n of S)t[n]=Ce(e[n]??``);return{...u,...t}}function Fa(e){return L(`settings.writeKeybindings`,e)}function Ia({action:e,currentValue:t,bordered:n,onDraftChange:r,onCommit:i,onRestoreDefault:a}){let o=Fa(e),s=F(o),c=T(u[e]),l=t!==c,d=()=>{P(o,i)};return(0,J.jsx)(X,{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=>Na(e,d),className:`font-mono`}),s?(0,J.jsx)(I,{}):null]})})}function La({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:Pa(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)(Ia,{action:e,currentValue:t[e]??``,bordered:n!==0,onDraftChange:r,onCommit:l,onRestoreDefault:d},e))]})}var Ra=`always`,za=`funk`,Ba=[{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 Va(e){switch(e){case`never`:case`unfocused`:case`always`:return e;default:return Ra}}function Ha(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 za}}var Ua=k()(e=>({chatSoundPreference:Ra,chatSoundId:za,setChatSoundPreference:t=>e({chatSoundPreference:Va(t)}),setChatSoundId:t=>e({chatSoundId:Ha(t)})})),Wa=`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`,Ga=`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`,Ka=`rounded bg-muted px-1 py-0.5 font-mono text-12 text-foreground`,qa=`text-xs font-medium tracking-wide text-muted-foreground`,Ja=`gap-1.5 disabled:cursor-default disabled:opacity-60`,Ya=`push.enable`,Xa=`push.test`,Za=`push.disable`,Qa=`push.contactSubject`;async function $a(e){try{await e(),s.getState().setPushError(null)}catch(e){s.getState().setPushError(je(e))}}function eo(e,t){P(e,()=>$a(t))}function to(){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 no({pendingKey:e,onRun:t,className:n,label:r,children:i}){let a=F(e);return(0,J.jsxs)(`button`,{type:`button`,onClick:()=>eo(e,t),disabled:a,"aria-busy":a||void 0,"aria-label":r,className:j(n,Ja),children:[a?(0,J.jsx)(I,{}):null,i]})}function ro({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=>eo(r,()=>n(e,!t.target.checked)),className:`h-4 w-4 shrink-0 rounded border-border accent-foreground`}),(0,J.jsx)(ut,{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 io(e){let{permissionState:t}=e,n=F(Qa);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:Ka,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)(to,{})]});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)(no,{pendingKey:Ya,onRun:e.onEnable,className:Ga,children:`Enable on this device`}),(0,J.jsx)(to,{})]});let r=new Set(e.config.preferences.mutedProjectPaths),i=e.contactSubjectDraft.trim(),a=In(i),o=i!==e.contactSubject,s=()=>{a&&o&&eo(Qa,()=>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)(no,{pendingKey:Xa,onRun:e.onTest,className:Wa,children:`Send test`}),(0,J.jsx)(no,{pendingKey:Za,onRun:e.onDisable,className:Wa,children:`Disable`})]}),(0,J.jsx)(to,{}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsxs)(`div`,{className:j(qa,`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:Ka,children:`mailto:`}),` address or`,` `,(0,J.jsx)(`code`,{className:Ka,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:Ka,children:`mailto:`}),` or`,` `,(0,J.jsx)(`code`,{className:Ka,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:qa,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)(no,{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:qa,children:`Per-project`}),(0,J.jsx)(`ul`,{className:`flex flex-col`,children:e.projects.map(t=>(0,J.jsx)(`li`,{children:(0,J.jsx)(ro,{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:Ka,children:`kanna --share`}),` or open Kanna over your tunnel on the phone, then enable on that device.`]})]})}var ao=L(`packages.checkUpdates`);function oo(e){return L(`packages.update`,e)}async function so(e,t){try{await e.command(t),_t.getState().setCommandError(null)}catch(e){throw _t.getState().setCommandError(je(e)),e}}var co=[],lo=[],uo=[],fo=[];function po(e){return typeof e==`object`&&!!e&&`packages`in e&&`errors`in e}var mo={up_to_date:`Up to date`,outdated:`Outdated`,partial:`Partial`,unknown:`Unknown`};function ho({pkg:e,packageEntry:t,applying:n,onUpdate:r}){let i=F(oo(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`?oi[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:mo[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)(lt,{className:`h-4 w-4`})}):null]})]})}function go({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)(Ye,{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)(ho,{pkg:e,packageEntry:t,applying:r.includes(e.id),onUpdate:()=>o(e.id)},e.id)})})]})}function _o({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)(go,{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 vo({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(!po(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)(()=>{Zt(`packages.listInstalled`,d())},[d]);let f=(0,q.useCallback)(()=>{P(ao,()=>so(t,{type:`packages.checkUpdates`}))},[t]),p=(0,q.useCallback)(e=>{P(oo(e),()=>so(t,{type:`packages.update`,id:e}))},[t]),m=F(ao),h=u?.status===`checking`||m,g=u?.applying??fo,_=u?.packages.filter(e=>e.kind===`claude-plugin`||e.kind===`codex-plugin`)??uo,v=r?.packages??co,y=r?.errors??lo;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)(_o,{label:`Claude Code`,kind:`claude-plugin`,packages:v,errors:y,updateEntries:_,applying:g,isChecking:h,onCheckUpdates:f,onUpdate:p}),(0,J.jsx)(_o,{label:`Codex`,kind:`codex-plugin`,packages:v,errors:y,updateEntries:_,applying:g,isChecking:h,onCheckUpdates:f,onUpdate:p})]})}function yo(e){return e.map(e=>({...e,disabled:!0}))}function bo({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)(Pt,{value:t,onValueChange:t=>P(e,()=>n(t)),options:a?yo(r):r,size:i})]})}var xo=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. `,wo=`The URL must be https and reachable from the internet (a Cloudflare tunnel or --share).`;function To(e){return`${e}/mcp`}function Eo({publicOrigin:e,passwordConfigured:t}){let n=To(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. ${wo}`,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. ${wo}`,snippet:[`URL: ${n}`,`Authentication: OAuth`].join(`
|
|
13
|
+
`)}]}var Do=L(`settings.remoteMcp`,`enabled`),Oo=L(`settings.remoteMcp`,`publicUrl`),ko=2e3,Ao=[{value:`enabled`,label:`Enabled`},{value:`disabled`,label:`Disabled`}];function jo(e){try{return new URL(e).origin}catch{return``}}function Mo({snippet:e}){let t=xo(t=>t.copiedSnippetId===e.id),n=xo(e=>e.setCopiedSnippetId),r=(0,q.useCallback)(async()=>{await et.writeText(e.snippet),n(e.id),Ot.setTimeout(()=>n(null),ko)},[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:()=>Zt(`copy remote MCP setup`,r()),children:t?(0,J.jsx)($e,{className:`h-4 w-4 text-success-text`}):(0,J.jsx)(Qe,{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 No({state:e,dom:t=Ae}){let n=H(Lt),r=s(e=>e.authEnabled),i=xo(e=>e.publicUrlDraft),a=xo(e=>e.setPublicUrlDraft),o=xo(e=>e.error),c=xo(e=>e.setError),l=F(Oo),u=i??n.publicUrl??``,d=u.trim(),f=d!==``&&It(d)===null,p=d!==(n.publicUrl??``),m=n.publicUrl??It(jo(t.getHref())),h=Eo({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)(X,{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)(bo,{pendingKey:Do,value:n.enabled?`enabled`:`disabled`,onValueChange:g,options:Ao,size:`sm`})}),(0,J.jsx)(X,{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(Oo,_),pending:l,children:`Save`})]}),o?(0,J.jsx)(`div`,{className:`text-xs text-destructive-text`,children:o}):null]})}),(0,J.jsx)(X,{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)(Mo,{snippet:e},e.id))})]})]})}function Po(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 st({vapidPublicKey:t.vapidPublicKey,sendToServer:async e=>{let t=await n.command({type:`push.subscribe`,subscription:e.subscription,label:e.label,userAgent:e.userAgent});return dt(t.id),{id:t.id}}});i(e)}finally{a(pt().state)}},[t,n,i,a]),handleDisablePush:(0,q.useCallback)(async()=>{r&&(await mt({pushDeviceId:r,sendToServer:async e=>{await n.command({type:`push.unsubscribe`,pushDeviceId:e})}}),gt(),i(null))},[r,n,i])}}function Fo(e){return e===`openai`?zn:e===`openrouter`?ce:``}function Io(e,t){return{...e,provider:t,model:Fo(t),baseUrl:t===`custom`?e.baseUrl:``}}function Lo(e,t){if(!e.pinnedRef)return null;let n=t.latestVersion;return!n||n===e.pinnedRef?null:n}var Ro={up_to_date:`Up to date`,outdated:`Outdated`,partial:`Partial`,unknown:`Unknown`};function zo(e){if(!e)return null;let t=Lo(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 Bo({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`?oi[s]:null,u=t?.pinnedRef??null,d=zo(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:Ro[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)(lt,{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 Vo(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 Ho=L(`packages.checkUpdates`),Uo=L(`packages.updateAll`,`skill`);function Wo(e){return`skill:${e}`}function Go({skill:e,packageEntry:t,uninstalling:n,applying:r,onUninstall:i,onUpdate:a}){let o=Wo(e.name),s=F(L(`packages.update`,o)),c=F(L(`skills.uninstall`,e.name));return(0,J.jsx)(Bo,{skill:e,packageEntry:t,uninstalling:n||c,applying:r||s,onUninstall:()=>i(e),onUpdate:()=>a(o)})}function Ko({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 qo({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,` · `,Vo(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)(lt,{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 Jo({state:e,ports:t}){let n=t?.timer??Ot,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(Ho),D=F(Uo),pe=le||fe;async function me(e){try{C(null),await r.command(e)}catch(e){throw C(je(e)),e}}function he(){P(Ho,()=>me({type:`packages.checkUpdates`}))}function O(e){P(L(`packages.update`,e),()=>me({type:`packages.update`,id:e}))}function ge(){ue.length!==0&&P(Uo,()=>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)(()=>{Zt(`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`),Zt(`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),Zt(`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)(Go,{skill:e,packageEntry:T?.packages.find(t=>t.kind===`skill`&&t.name===e.name)??null,uninstalling:re===e.name,applying:T?.applying.includes(Wo(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)(Ko,{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)(Je,{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)(Ct,{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)(qo,{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 Yo(e){return{async onReload(t){if(!(await e(`/api/plugins/${t}/reload`,{})).ok)throw Error(`Failed to reload plugin ${t}`)}}}function Xo({plugins:e,handlers:t}){return e.length===0?(0,J.jsx)(Cr,{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)(wr,{children:e.map(e=>(0,J.jsx)(Zo,{plugin:e,onReload:t.onReload},e.id))})]})}function Zo({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),_t.getState().setCommandError(null)}catch(e){throw _t.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)(en,{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 Qo(e,t){return{ok:(await Ze.postJsonBody(e,t)).ok}}var $o=Yo(Qo);function es(){let e=H(Xt);return(0,J.jsx)(Xo,{plugins:e,handlers:$o})}var ts=[{id:`general`,label:`General`,icon:qe,subtitle:`Manage appearance, editor behavior, and embedded terminal defaults.`},{id:`skills`,label:`Skills`,icon:ln,subtitle:`Manage globally installed agent skills from the active skill lock file.`},{id:`plugins`,label:`Plugins`,icon:En,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:Sn,subtitle:`Manage the default chat provider and saved model defaults for Claude Code and Codex.`},{id:`models`,label:`Models`,icon:gn,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:En,subtitle:`Install custom MCP servers (stdio, http, sse, ws) and connect-test them.`},{id:`remote-mcp`,label:`Remote MCP`,icon:wn,subtitle:`Let Claude, Codex and ChatGPT drive Kanna over MCP, with setup snippets for each client.`},{id:`beacons`,label:`Beacons`,icon:ze,subtitle:`Pair your own machines so the agent can read files and run approved commands there.`},{id:`snippets`,label:`Text snippets`,icon:Pn,subtitle:`Define shortcuts that expand to full text in the chat composer with Tab.`},{id:`instructions`,label:`Instructions`,icon:Sn,subtitle:`Global instructions appended to every Claude and Codex turn (main + subagents).`},{id:`keybindings`,label:`Keybindings`,icon:mn,subtitle:`Edit global app shortcuts stored in the active keybindings file.`},{id:`changelog`,label:`Changelog`,icon:ln,subtitle:`Release notes pulled from the public GitHub releases feed.`}],ns={"mcp-servers":Ur,"remote-mcp":No,beacons:Mi};function rs(e){return e?ts.find(t=>t.id===e)?.id??null:null}function is(e){return e?ts:ts.filter(e=>e.id!==`kanna-plugins`)}var as=[{value:`light`,label:`Light`,icon:Mn},{value:`dark`,label:`Dark`,icon:G},{value:`system`,label:`System`,icon:yt}],os=[{value:`sm`,label:`Small`},{value:`md`,label:`Default`},{value:`lg`,label:`Large`},{value:`xl`,label:`Extra Large`},{value:`xxl`,label:`XX-Large`}],ss=[{value:`never`,label:`Never`},{value:`unfocused`,label:`When Unfocused`},{value:`always`,label:`Always`}],cs=[{value:`disabled`,label:`Off`},{value:`enabled`,label:`On`}],ls=[{value:`disabled`,label:`Off`},{value:`enabled`,label:`On`}],us=[{value:`always-ask`,label:`Always ask`},{value:`auto-expose`,label:`Auto-expose`}],ds=[{value:`openai`,label:`OpenAI`},{value:`openrouter`,label:`OpenRouter`},{value:`custom`,label:`Custom`}],fs=3e5,ps=null;function ms(e){return`Edit global app shortcuts stored in ${e}.`}function hs(e,t){return e!==t}function gs(){return ps?Date.now()>=ps.expiresAt?(ps=null,null):ps.releases:null}function _s(e){ps={releases:e,expiresAt:Date.now()+fs}}async function vs(e,t){let n=t?.force?null:gs();if(n)return n;let r=await e();return _s(r),r}function ys(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 bs(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 xs=`__redeploy__`,Ss=`settings.writeLlmProvider`,Cs=`appSettings.setCloudflareTunnel`,ws=L(Cs,`cloudflaredPath`);function Ts({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(xs);try{await l()}finally{f(null)}},[l,f]),S=d===xs||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)(sn,{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)(sn,{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:bs(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)(Es,{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`:ys(t,b)<0?`Rollback`:`Install`;let a;return a=n?`Updating…`:ys(t,b)<0?`Rolling back…`:`Installing…`,(0,J.jsx)(sn,{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)(pn,{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:Xe(e.body)}):(0,J.jsx)(`div`,{className:`mt-5 text-sm text-muted-foreground`,children:`No release notes were provided.`})]},e.id)}):null]})}function Es({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 Ds({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 Os({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)(X,{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 ks({ports:e,sectionId:t}={}){let i=e?.dom??Ae,l=n(),u=r(),{theme:d,setTheme:g}=Kt(),_=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=rs(t)??`general`,le=ns[T],ue=H(e=>e.hydrationStatus===`loading`&&e.settings===null),E=u.connectionStatus===`connecting`||!u.localProjectsReady||ue,de=F(Ss),D=F(ge),pe=de||D,he=F(ws),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(Ft),Ee=H(zt),Oe=H(qt),k=H(Rt),je=p(e=>e.setScrollbackLines),Me=p(e=>e.setMinColumnWidth),N=p(e=>e.setEditorPreset),Pe=p(e=>e.setEditorCommandTemplate),Fe=H(Vt),Ie=H(Bt),ze=Ua(e=>e.setChatSoundPreference),Be=Ua(e=>e.setChatSoundId),Ve=u.keybindings,R=H(e=>e.settings),We=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),Qe=w(e=>e.providerDefaults),$e=w(e=>e.setDefaultProvider),et=w(e=>e.setProviderDefaultModel),tt=w(e=>e.setProviderDefaultModelOptions),st=w(e=>e.setProviderDefaultPlanMode),ct=H(Yt),lt=Wi(),ut=(0,q.useMemo)(()=>_e(Ve),[Ve]).filePathDisplay||Ne(),dt=s(e=>e.pushPermissionState),mt=s(e=>e.setPushPermissionState),ht=s(e=>e.pushDeviceId),{handleEnablePush:gt,handleDisablePush:_t}=Po(u),yt=s(e=>e.scrollbackDraft),bt=s(e=>e.setScrollbackDraft),xt=s(e=>e.minColumnWidthDraft),St=s(e=>e.tabMinWidthDraft),B=s(e=>e.setMinColumnWidthDraft),Ct=s(e=>e.setTabMinWidthDraft),Ot=R?.panes.tabMinWidth??60,At=R?.uploads.maxFileSizeMb??Ln.maxFileSizeMb,jt=s(e=>e.uploadMaxFileSizeDraft),Mt=s(e=>e.setUploadMaxFileSizeDraft),Nt=Math.round((R?.claudeDriver.lifecycle.idleTimeoutMs??ne.idleTimeoutMs)/6e4),It=R?.claudeDriver.lifecycle.maxConcurrent??ne.maxConcurrent,Lt=s(e=>e.claudeIdleMinutesDraft),Ht=s(e=>e.setClaudeIdleMinutesDraft),Ut=s(e=>e.claudeMaxConcurrentDraft),Wt=s(e=>e.setClaudeMaxConcurrentDraft),Gt=s(e=>e.editorCommandDraft),Jt=s(e=>e.setEditorCommandDraft),Xt=s(e=>e.appSettingsError),U=s(e=>e.setAppSettingsError),en=s(e=>e.analyticsDialogOpen),tn=s(e=>e.setAnalyticsDialogOpen),nn=s(e=>e.tunnelError),rn=s(e=>e.setTunnelError),an=s(e=>e.cloudflaredPathDraft),on=s(e=>e.setCloudflaredPathDraft),cn=s(e=>e.pushContactSubjectDraft),ln=s(e=>e.setPushContactSubjectDraft),un=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),gn=s(e=>e.setLlmProviderError),_n=s(e=>e.llmValidationStatus),vn=s(e=>e.setLlmValidationStatus),yn=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)(()=>{bt(String(Te))},[Te,bt]),(0,q.useEffect)(()=>{B(String(Ee))},[Ee,B]),(0,q.useEffect)(()=>{Ct(String(Ot))},[Ot,Ct]),(0,q.useEffect)(()=>{Mt(String(At))},[At,Mt]),(0,q.useEffect)(()=>{Ht(String(Nt))},[Nt,Ht]),(0,q.useEffect)(()=>{Wt(String(It))},[It,Wt]),(0,q.useEffect)(()=>i.addWindowListener(`focus`,()=>mt(pt().state)),[i,mt]),(0,q.useEffect)(()=>{Jt(k)},[k,Jt]),(0,q.useEffect)(()=>{We&&mn({provider:We.provider,apiKey:We.apiKey,model:We.model,baseUrl:We.baseUrl})},[We,mn]),(0,q.useEffect)(()=>{vn(`idle`),xn(null)},[W.provider,W.apiKey,W.model,W.baseUrl,vn,xn]),(0,q.useEffect)(()=>{t&&(rs(t)||l(`/settings/general`,{replace:!0}))},[l,t]),(0,q.useEffect)(()=>{R&&on(R.cloudflareTunnel.cloudflaredPath)},[R,on]),(0,q.useEffect)(()=>{R&&ln(R.push.contactSubject)},[R,ln]),(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),vs(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(yt);if(!Number.isFinite(e)){bt(String(Te));return}je(e),K({terminal:{scrollbackLines:e}}).catch(e=>{U(e instanceof Error?e.message:`Unable to save terminal settings.`)})}function Nn(){let e=Number(xt);if(!Number.isFinite(e)){B(String(Ee));return}Me(e),K({terminal:{minColumnWidth:e}}).catch(e=>{U(e instanceof Error?e.message:`Unable to save terminal settings.`)})}function Pn(){let e=Number(St);if(!Number.isFinite(e)){Ct(String(Ot));return}K({panes:{tabMinWidth:Le(e)}}).catch(e=>{U(e instanceof Error?e.message:`Unable to save pane settings.`)})}function In(){let e=Number(jt);if(!Number.isFinite(e)||e<1||e>51200){Mt(String(At)),U(`Max file size must be between 1 and ${Rn} MB.`);return}if(Math.round(e)===At){Mt(String(At));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(Lt),t=Math.round(De/6e4),n=Math.round(c/6e4);if(!Number.isFinite(e)||e<t||e>n){Ht(String(Nt)),U(`Idle timeout must be between ${t} and ${n} minutes.`);return}if(Math.round(e)===Nt){Ht(String(Nt));return}K({claudeDriver:{lifecycle:{idleTimeoutMs:Math.round(e)*6e4}}}).catch(e=>{U(e instanceof Error?e.message:`Unable to save Claude lifecycle settings.`)})}function Bn(){let e=Number(Ut);if(!Number.isFinite(e)||e<1||e>16){Wt(String(It)),U(`Max concurrent sessions must be between 1 and 16.`);return}if(Math.round(e)===It){Wt(String(It));return}K({claudeDriver:{lifecycle:{maxConcurrent:Math.round(e)}}}).catch(e=>{U(e instanceof Error?e.message:`Unable to save Claude lifecycle settings.`)})}function Vn(){let e=Number(fn);if(!Number.isInteger(e)||e<1){pn(String(un)),U(`Default share link expiry must be a whole number of hours >= 1.`);return}if(e===un){pn(String(un));return}K({shareDefaultTtlHours:e}).catch(e=>{U(e instanceof Error?e.message:`Unable to save share settings.`)})}function Wn(e,t){e.key===`Enter`&&(t(),e.currentTarget.blur())}function Gn(){Pe(Gt),K({editor:{commandTemplate:Gt}}).catch(e=>{U(e instanceof Error?e.message:`Unable to save editor settings.`)})}function Kn(e){g(e),K({theme:e}).catch(e=>{U(e instanceof Error?e.message:`Unable to save theme settings.`)})}function Y(e){K({typography:{scale:e}}).catch(e=>{U(e instanceof Error?e.message:`Unable to save typography settings.`)})}function qn(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 Jn(e){hs(Fe,e)&&(ze(e),P(`settings.chatSoundPreference`,()=>K({chatSoundPreference:e}).catch(e=>{U(e instanceof Error?e.message:`Unable to save chat sound settings.`)})),Zt(`chat sound preview`,Qt(Ie,1)))}function Yn(e){hs(Ie,e)&&(Be(e),P(`settings.chatSoundId`,()=>K({chatSoundId:e}).catch(e=>{U(e instanceof Error?e.message:`Unable to save chat sound settings.`)})),Zt(`chat sound preview`,Qt(e,1)))}async function Xn(e){try{U(null),await K({analyticsEnabled:e===`enabled`})}catch(e){U(e instanceof Error?e.message:`Unable to save analytics settings.`)}}async function Zn(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 Qn(e){try{rn(null),await wn(e)}catch(e){rn(e instanceof Error?e.message:`Unable to save Cloudflare Tunnel settings.`)}}function $n(e){$e(e),K({defaultProvider:e}).catch(e=>{U(e instanceof Error?e.message:`Unable to save provider settings.`)})}function er(e,t){et(e,t),K({providerDefaults:{[e]:{model:t}}}).catch(e=>{U(e instanceof Error?e.message:`Unable to save provider settings.`)})}function tr(e,t){tt(e,t),K({providerDefaults:{[e]:{modelOptions:t}}}).catch(e=>{U(e instanceof Error?e.message:`Unable to save provider settings.`)})}function nr(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 rr(e=W){try{gn(null),await On(e);let t=await kn(e);vn(t.ok?`valid`:`invalid`),xn(t.error)}catch(e){let t=e instanceof Error?{name:e.name,message:e.message}:$t(e);vn(`invalid`),xn(t),gn(e instanceof Error?e.message:`Unable to save quick response provider settings.`)}}function ir(e){let t=Io(W,e);mn(t),ar(t)}function ar(e=W){P(Ss,()=>rr(e))}function or(){ps=null,y(`loading`),ce(null),vs(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=Gt.replaceAll(`{path}`,`/Users/jake/Projects/kanna/src/client/app/App.tsx`).replaceAll(`{line}`,`12`).replaceAll(`{column}`,`1`),cr=Hn,ur=R?.analyticsEnabled===!1?`disabled`:`enabled`,dr=R?.telemetry?.enabled===!1?`disabled`:`enabled`,fr=R?.cloudflareTunnel??Fn,pr=fr.enabled?`enabled`:`disabled`,mr=ts.find(e=>e.id===T)??ts[0],hr=(0,q.useMemo)(()=>is(ct),[ct]),gr=T===`keybindings`?ms(ut):mr.subtitle,_r=!E,vr=yn?JSON.stringify(yn,null,2):``,yr;yr=pe?`inline-flex items-center gap-1.5 text-muted-foreground`:_n===`valid`?`text-success-text`:_n===`invalid`?`text-destructive`:`hidden`;let br;br=pe?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(I,{}),de?`Saving…`:`Loading…`]}):_n===`valid`?`Credentials valid & saved`:_n===`invalid`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{children:`Credentials invalid.`}),yn?(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 xr=(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 `,We?.filePathDisplay??`the active llm-provider.json file`,`.`]}),(0,J.jsx)(`span`,{className:j(`mt-2 block text-sm font-medium`,yr),children:br})]});async function Sr(){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 ${_r?`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`}),hr.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)(dn,{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`,Sr),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)(bn,{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)(ft,{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)(ot,{value:T,onValueChange:e=>{l(`/settings/${e}`)},children:[(0,J.jsx)(nt,{className:`h-11 min-w-0 flex-1`,"aria-label":`Settings section`,children:(0,J.jsx)(it,{})}),(0,J.jsx)(rt,{children:(0,J.jsx)(at,{children:hr.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`,Sr),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)(bn,{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:mr.label}),T===`general`?(0,J.jsx)(sn,{variant:`outline`,onClick:()=>{l(`/settings/changelog`)},children:`Check for updates`}):null,T===`keybindings`?(0,J.jsxs)(sn,{onClick:()=>P(`keybindings.openEditor`,()=>u.handleOpenExternalPath(`open_editor`,ut)),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:gr})]}),T===`general`&&(0,J.jsxs)(J.Fragment,{children:[Xt?(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:Xt}):null,(0,J.jsxs)(`div`,{className:`border-b border-border`,children:[(0,J.jsx)(X,{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)(X,{title:`Theme`,description:`Choose between light, dark, or system appearance`,children:(0,J.jsx)(Pt,{value:d,onValueChange:Kn,options:as,size:`sm`})}),(0,J.jsx)(X,{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)(ot,{value:Xe,onValueChange:e=>{f(e)&&Y(e)},children:[(0,J.jsx)(nt,{className:`min-w-[180px]`,children:(0,J.jsx)(it,{})}),(0,J.jsx)(rt,{children:(0,J.jsx)(at,{children:os.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)(X,{title:`Chat Sounds`,description:`Play a pop when a chat starts waiting on you or the unread chat count increases`,children:(0,J.jsxs)(ot,{disabled:ye,value:Fe,onValueChange:e=>{me(e)&&Jn(e)},children:[(0,J.jsx)(nt,{className:`min-w-[180px]`,children:(0,J.jsx)(it,{})}),(0,J.jsx)(rt,{children:(0,J.jsx)(at,{children:ss.map(e=>(0,J.jsx)(z,{value:e.value,children:e.label},e.value))})})]})}),(0,J.jsx)(X,{title:`Chat Sound`,description:`The bundled sound used for chat notification playback and previews`,children:(0,J.jsxs)(ot,{disabled:xe,value:Ie,onValueChange:e=>{a(e)&&Yn(e)},children:[(0,J.jsx)(nt,{className:`min-w-[180px]`,children:(0,J.jsx)(it,{})}),(0,J.jsx)(rt,{children:(0,J.jsx)(at,{children:Ba.map(e=>(0,J.jsx)(z,{value:e.value,children:e.label},e.value))})})]})}),(0,J.jsx)(X,{title:`Default Editor`,description:`Used when opening transcript links or files from the git diff menu`,alignStart:!0,children:(0,J.jsxs)(ot,{value:Oe,onValueChange:e=>{b(e)&&qn(e)},children:[(0,J.jsx)(nt,{className:`min-w-[180px]`,children:(0,J.jsx)(it,{})}),(0,J.jsx)(rt,{children:(0,J.jsx)(at,{children:Ue.map(e=>(0,J.jsx)(z,{value:e.value,children:(0,J.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(Re,{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:Gt,onChange:e=>Jt(e.target.value),onBlur:Gn,onKeyDown:e=>Na(e,Gn),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)(X,{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:yt,onChange:e=>bt(e.target.value),onBlur:Mn,onKeyDown:e=>Wn(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)(X,{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:xt,onChange:e=>B(e.target.value),onBlur:Nn,onKeyDown:e=>Wn(e,Nn),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)(X,{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:St,onChange:e=>Ct(e.target.value),onBlur:Pn,onKeyDown:e=>Wn(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:[60,`-`,200,` px`,Ot===60?` (default)`:``]})]})}),(0,J.jsx)(X,{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:jt,onChange:e=>Mt(e.target.value),onBlur:In,onKeyDown:e=>Wn(e,In),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 `,Ln.maxFileSizeMb]})]})}),(0,J.jsx)(X,{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)(Ds,{checked:Ge,onChange:Ke})}),u.pushConfig?(0,J.jsx)(X,{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)(io,{permissionState:dt,config:u.pushConfig,projects:u.localProjects?.projects??[],currentDeviceId:ht,contactSubject:R?.push.contactSubject??``,contactSubjectDraft:cn,onContactSubjectDraftChange:ln,onContactSubjectSave:async e=>{await u.socket.command({type:`settings.writeAppSettingsPatch`,patch:{push:{contactSubject:e}}})},onEnable:gt,onDisable:_t,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)(X,{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)(bo,{pendingKey:`settings.analytics`,value:ur,onValueChange:Xn,options:cs,size:`sm`})}),(0,J.jsx)(X,{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)(bo,{pendingKey:`settings.telemetry`,value:dr,onValueChange:Zn,options:cs,size:`sm`})})]}),(0,J.jsxs)(`div`,{className:`border-b border-border`,children:[nn?(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:nn}):null,(0,J.jsx)(X,{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)(bo,{pendingKey:L(Cs,`enabled`),value:pr,onValueChange:e=>Qn({enabled:e===`enabled`}),options:ls,size:`sm`})}),fr.enabled&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(X,{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)(bo,{pendingKey:L(Cs,`mode`),value:fr.mode,onValueChange:e=>Qn({mode:e}),options:us,size:`sm`})}),(0,J.jsx)(X,{title:`cloudflared path`,description:`Path to the cloudflared binary. Defaults to the one found on $PATH.`,children:(0,J.jsx)(V,{value:an,onChange:e=>on(e.target.value),onBlur:()=>P(ws,()=>Qn({cloudflaredPath:an})),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)(X,{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:Vn,onKeyDown:e=>Wn(e,Vn),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)(X,{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)(Ma,{tokens:R?.claudeAuth.tokens??[],concurrencyDefault:R?.claudeAuth.concurrencyDefault??1,onWrite:Tn,onTest:En})})}),(0,J.jsx)(X,{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:Lt,onChange:e=>Ht(e.target.value),onBlur:zn,onKeyDown:e=>Wn(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)(X,{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:Ut,onChange:e=>Wt(e.target.value),onBlur:Bn,onKeyDown:e=>Wn(e,Bn),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)(X,{title:`Default Provider`,description:`The default harness used for new chats before a provider is locked by an existing session.`,children:(0,J.jsxs)(ot,{value:Ze,onValueChange:e=>{(e===`last_used`||ae(e))&&$n(e)},children:[(0,J.jsx)(nt,{className:`min-w-[180px]`,children:(0,J.jsx)(it,{})}),(0,J.jsx)(rt,{children:(0,J.jsxs)(at,{children:[(0,J.jsx)(z,{value:`last_used`,children:`Last Used`}),lt.map(e=>(0,J.jsx)(z,{value:e.id,children:e.label},e.id))]})})]})}),(0,J.jsx)(va,{state:u}),(0,J.jsx)(X,{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)(He,{availableProviders:lt,selectedProvider:`claude`,showProviderPicker:!1,model:Qe.claude.model,modelOptions:Qe.claude.modelOptions,onModelChange:(e,t)=>{er(`claude`,t)},onModelOptionChange:e=>{e.type===`claudeReasoningEffort`?tr(`claude`,{reasoningEffort:e.effort}):e.type===`contextWindow`&&tr(`claude`,{contextWindow:e.contextWindow})},planMode:Qe.claude.planMode,onPlanModeChange:e=>nr(`claude`,e),includePlanMode:!0,className:`justify-start flex-wrap`})})}),(0,J.jsx)(X,{title:`Codex Defaults`,description:`Saved defaults when using Codex.`,alignStart:!0,children:(0,J.jsx)(`div`,{className:`max-w-[420px]`,children:(0,J.jsx)(He,{availableProviders:lt,selectedProvider:`codex`,showProviderPicker:!1,model:Qe.codex.model,modelOptions:Qe.codex.modelOptions,onModelChange:(e,t)=>{er(`codex`,t)},onModelOptionChange:e=>{e.type===`codexReasoningEffort`?tr(`codex`,{reasoningEffort:e.effort}):e.type===`fastMode`&&tr(`codex`,{fastMode:e.fastMode})},planMode:Qe.codex.planMode,onPlanModeChange:e=>nr(`codex`,e),includePlanMode:!0,className:`justify-start flex-wrap`})})}),(0,J.jsx)(X,{title:`Quick Response SDK`,description:xr,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,We?.warning?(0,J.jsx)(`div`,{className:`rounded-lg border border-border bg-card/30 px-4 py-3 text-sm text-muted-foreground`,children:We.warning}):null,(0,J.jsxs)(ot,{value:W.provider,disabled:pe,onValueChange:e=>{ee(e)&&ir(e)},children:[(0,J.jsx)(nt,{className:`w-full`,children:(0,J.jsx)(it,{})}),(0,J.jsx)(rt,{children:(0,J.jsx)(at,{children:ds.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:()=>ar(),onKeyDown:e=>Na(e,ar),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:()=>ar(),onKeyDown:e=>Na(e,ar),readOnly:pe,placeholder:`API key`}),(0,J.jsx)(V,{value:W.model,onChange:e=>mn({...W,model:e.target.value}),onBlur:()=>ar(),onKeyDown:e=>Na(e,ar),readOnly:pe,placeholder:`Model id`})]})})]}),T===`keybindings`&&(0,J.jsx)(La,{state:u}),T===`skills`&&(0,J.jsx)(Jo,{state:u}),T===`plugins`&&(0,J.jsx)(vo,{state:u}),T===`kanna-plugins`&&ct&&(0,J.jsx)(es,{}),T===`subagents`&&(0,J.jsx)(lr,{state:u}),T===`models`&&(0,J.jsx)(Ui,{state:u}),le&&(0,J.jsx)(le,{state:u}),T===`snippets`&&(0,J.jsx)(Ea,{state:u}),T===`instructions`&&(0,J.jsx)(Os,{state:u}),![`general`,`providers`,`keybindings`,`skills`,`plugins`,`subagents`,`models`,`mcp-servers`,`remote-mcp`,`beacons`,`snippets`,`instructions`].includes(T)&&(0,J.jsx)(Ts,{status:_,releases:ie,error:se,onRetry:or,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)(vt,{className:`mt-0.5 h-4 w-4 flex-shrink-0`}),(0,J.jsx)(`span`,{children:u.commandError})]}):null]})]})]}),_r?(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)(Tt,{open:en,onOpenChange:tn,children:(0,J.jsxs)(wt,{size:`lg`,children:[(0,J.jsxs)(Dt,{className:`space-y-4`,children:[(0,J.jsx)(kt,{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:Un.map(e=>(0,J.jsx)(`li`,{className:`font-mono text-foreground`,children:e},e))})]})]}),(0,J.jsx)(Et,{children:(0,J.jsx)(A,{variant:`secondary`,size:`sm`,onClick:()=>tn(!1),children:`Close`})})]})}),(0,J.jsx)(Tt,{open:Sn,onOpenChange:Cn,children:(0,J.jsxs)(wt,{size:`lg`,children:[(0,J.jsxs)(Dt,{className:`space-y-4`,children:[(0,J.jsx)(kt,{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:vr})]}),(0,J.jsx)(Et,{children:(0,J.jsx)(A,{variant:`secondary`,size:`sm`,onClick:()=>Cn(!1),children:`Close`})})]})})]})}export{ks as SettingsPage};
|
package/dist/client/assets/{StackBoardsRoutePage-CzojEmXE.js → StackBoardsRoutePage-B-O5uIvz.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
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{t as a}from"./BoardsPage-
|
|
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{t as a}from"./BoardsPage-DCh9hj51.js";var o=e(t(),1),s=e(i(),1);function c({stackId:e}){let t=r(),i=n(),c=t.sidebarData.stacks.find(t=>t.id===e),l=c?c.title:`Stack`,u=(0,o.useCallback)(t=>{i(`/boards/stack/${e}/${t}`)},[i,e]);return(0,s.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col`,children:(0,s.jsx)(a,{ownerKind:`stack`,ownerId:e,ownerName:l,socket:t.socket,onOpenBoard:u})})}export{c as StackBoardsRoutePage};
|