@cuongtran001/kanna 1.63.2 → 1.63.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/README.md +5 -9
- package/dist/client/assets/{BoardsPage-BJalB-bc.js → BoardsPage-AckCuswi.js} +1 -1
- package/dist/client/assets/BoardsRoutePage-DzKwKy3f.js +1 -0
- package/dist/client/assets/ChatPage-DsaH8CTz.js +93 -0
- package/dist/client/assets/{CronJobRow-CPbO_jwU.js → CronJobRow-Bx9gRqKW.js} +1 -1
- package/dist/client/assets/{CronJobsPage-Ck3SNgGi.js → CronJobsPage-v0-2X1oX.js} +1 -1
- package/dist/client/assets/{FilePreviewSheet-XEuUtDPn.js → FilePreviewSheet-B6SDxSD0.js} +2 -2
- package/dist/client/assets/{FlowSurface-BCbeMTJe.js → FlowSurface-CLC-ZFar.js} +1 -1
- package/dist/client/assets/{GenUIBlock-BJy_dfs-.js → GenUIBlock-CC79Ujro.js} +2 -2
- package/dist/client/assets/{KannaSocketProvider-D7Lzlt35.js → KannaSocketProvider-B2sHsWP5.js} +1 -1
- package/dist/client/assets/{LocalProjectsPage-9LJkQjhT.js → LocalProjectsPage-DYBkcEAm.js} +1 -1
- package/dist/client/assets/SettingsPage-CZqMkMRW.js +9 -0
- package/dist/client/assets/{StackBoardsRoutePage-t_EaFNG4.js → StackBoardsRoutePage-Clviz0hX.js} +1 -1
- package/dist/client/assets/{ToolCallMessage-RbF9XT2B.js → ToolCallMessage-BfNbWGmc.js} +1 -1
- package/dist/client/assets/{VChartSurface-CKuPelsn.js → VChartSurface-CUbxyBo3.js} +1 -1
- package/dist/client/assets/{WorkflowsPage-B6qUmQA3.js → WorkflowsPage-rengzb97.js} +1 -1
- package/dist/client/assets/{WorkflowsSection-DxO0S4An.js → WorkflowsSection-DuXdLsMO.js} +1 -1
- package/dist/client/assets/{chart-renderer-DjYZvNxh.js → chart-renderer-D7ukB2wg.js} +1 -1
- package/dist/client/assets/{chatSounds-FD2DQzF6.js → chatSounds-BLg2xPDZ.js} +1 -1
- package/dist/client/assets/chevron-left-RbFvmeyK.js +1 -0
- package/dist/client/assets/{clipboard.adapter-GN9nnYak.js → clipboard.adapter-CgdNwn-1.js} +1 -1
- package/dist/client/assets/{columnStyle-DjA7hA9k.js → columnStyle-CMCF0ds6.js} +1 -1
- package/dist/client/assets/{createScopedStore-BoLB9Rhc.js → createScopedStore-BrD5NHWx.js} +1 -1
- package/dist/client/assets/{dist-CimtOoGK.js → dist-DNSTHlSo.js} +1 -1
- package/dist/client/assets/editor-icons-DY4uKeEY.js +1 -0
- package/dist/client/assets/{ellipsis-Cd7sO0LO.js → ellipsis-OHg0x_x1.js} +1 -1
- package/dist/client/assets/{flow-kinds-CW2TU_83.js → flow-kinds-Ki2DP9nP.js} +1 -1
- package/dist/client/assets/{folder-C7sXCaHj.js → folder-CnWzWIG5.js} +1 -1
- package/dist/client/assets/{formatters-wSVyvDFZ.js → formatters-BGORekd-.js} +1 -1
- package/dist/client/assets/{genui-EzBIAYFE.js → genui-C9i6j0XZ.js} +1 -1
- package/dist/client/assets/{globe-xmRpmpma.js → globe-BjR1tyE4.js} +1 -1
- package/dist/client/assets/{host-DCaA9W-Z.js → host-D9tJwZXl.js} +1 -1
- package/dist/client/assets/{index-CDqjh7nt.js → index-CesRxZ0X.js} +7 -7
- package/dist/client/assets/index-CxDE9VOy.css +1 -0
- package/dist/client/assets/{info-D4MMvZFe.js → info-DNYekoE-.js} +1 -1
- package/dist/client/assets/{input-C4fvDiQ4.js → input-DgW9uRZN.js} +1 -1
- package/dist/client/assets/{lexicalToReact-sPUyOWk6.js → lexicalToReact-CZvp9Pgz.js} +3 -3
- package/dist/client/assets/{log-aTaDVF_e.js → log-DnEvbp3E.js} +1 -1
- package/dist/client/assets/{monitor-_CRKcV1h.js → monitor-qbWfUdBG.js} +1 -1
- package/dist/client/assets/{pencil-fNBeUUCf.js → pencil-C965rrpd.js} +1 -1
- package/dist/client/assets/{pendingActionsStore-COTh4Ztq.js → pendingActionsStore-CxhI19V9.js} +1 -1
- package/dist/client/assets/{play-BAmkJfn6.js → play-uofLR7yT.js} +1 -1
- package/dist/client/assets/{plus-c75CkNEO.js → plus-D4CI6rj1.js} +1 -1
- package/dist/client/assets/{popover-CHM4skzh.js → popover-Bc646hKn.js} +1 -1
- package/dist/client/assets/{pushClient-BJH_ITRB.js → pushClient-CxnHu9h4.js} +1 -1
- package/dist/client/assets/runDetached-DfQXHAaY.js +1 -0
- package/dist/client/assets/{segmented-control-DNOwRupT.js → segmented-control-CKGX29Kl.js} +1 -1
- package/dist/client/assets/{select-dLHiAls6.js → select-BjeajpVt.js} +1 -1
- package/dist/client/assets/{settings-header-button-CGKCzFyk.js → settings-header-button-BYvHR6Xl.js} +1 -1
- package/dist/client/assets/{sidebarPendingActions-Dyp80Lv_.js → sidebarPendingActions-xgMTnfRY.js} +1 -1
- package/dist/client/assets/{square-pen-B1IxmScM.js → square-pen-DmppQdTd.js} +1 -1
- package/dist/client/assets/{state-mark-BhTZfcYe.js → state-mark-C3kEL1hX.js} +1 -1
- package/dist/client/assets/{status-pill-CwhJhaMy.js → status-pill-Bo1Nb6HX.js} +1 -1
- package/dist/client/assets/{terminal-Bnj7qFGw.js → terminal-DfCF-J4p.js} +1 -1
- package/dist/client/assets/{timer.adapter-DHt2zwsL.js → timer.adapter-C2RhP4d6.js} +1 -1
- package/dist/client/assets/{tools-3gJcj3hK.js → tools-t5T_3UBg.js} +1 -1
- package/dist/client/assets/{triangle-alert-CWrc0CIO.js → triangle-alert-CYQhobyY.js} +1 -1
- package/dist/client/assets/useAppGlobalState-DUa3pkCF.js +1 -0
- package/dist/client/assets/useKannaState-FcieR5qb.js +5 -0
- package/dist/client/assets/useTheme-D9sKDPEm.js +1 -0
- package/dist/client/index.html +35 -35
- package/package.json +2 -2
- package/src/server/agent-coordinator-types.ts +0 -6
- package/src/server/agent-coordinator.ts +6 -45
- package/src/server/agent.compaction.test.ts +1 -13
- package/src/server/agent.oauth-account-info.test.ts +0 -3
- package/src/server/agent.oauth-release.test.ts +0 -2
- package/src/server/agent.oauth-rotation.test.ts +0 -9
- package/src/server/agent.oauth-token-share-cap.test.ts +0 -1
- package/src/server/agent.openrouter-model.test.ts +0 -2
- package/src/server/agent.openrouter-watchdog.test.ts +0 -3
- package/src/server/agent.sdk-workflow-register.test.ts +2 -64
- package/src/server/agent.test.ts +1 -319
- package/src/server/app-settings.test.ts +14 -17
- package/src/server/app-settings.ts +22 -37
- package/src/server/auto-continue/e2e.test.ts +0 -1
- package/src/server/background-task-output-registry.test.ts +1 -1
- package/src/server/background-task-output-registry.ts +1 -1
- package/src/server/claude-cancel-handler.test.ts +0 -58
- package/src/server/claude-cancel-handler.ts +1 -17
- package/src/server/claude-harness-stream.test.ts +134 -0
- package/src/server/{claude-pty/jsonl-path.test.ts → claude-projects-path.adapter.test.ts} +1 -19
- package/src/server/{claude-pty/jsonl-path.adapter.ts → claude-projects-path.adapter.ts} +0 -11
- package/src/server/claude-send-command.test.ts +0 -1
- package/src/server/claude-session-config-helpers.test.ts +1 -90
- package/src/server/claude-session-config-helpers.ts +1 -38
- package/src/server/claude-session-error-handler.test.ts +0 -1
- package/src/server/claude-session-lifecycle.test.ts +2 -36
- package/src/server/claude-session-lifecycle.ts +2 -8
- package/src/server/claude-session-runner.test.ts +8 -36
- package/src/server/claude-session-runner.ts +1 -26
- package/src/server/claude-session-spawner.test.ts +5 -64
- package/src/server/claude-session-spawner.ts +49 -115
- package/src/server/claude-session-start.test.ts +1 -14
- package/src/server/claude-session-start.ts +0 -8
- package/src/server/claude-session-state-queries.test.ts +1 -2
- package/src/server/claude-session-state.test.ts +0 -1
- package/src/server/claude-session-state.ts +0 -4
- package/src/server/claude-subagent-wiring.test.ts +2 -68
- package/src/server/claude-subagent-wiring.ts +3 -50
- package/src/server/claude-turn-starter-types.ts +0 -3
- package/src/server/claude-turn-starter.test.ts +0 -28
- package/src/server/claude-turn-starter.ts +0 -5
- package/src/server/event-store.test.ts +0 -2
- package/src/server/events.ts +1 -2
- package/src/server/harness-types.ts +1 -2
- package/src/server/import-subagent-drill.e2e.test.ts +1 -1
- package/src/server/imported-subagents-dir.test.ts +1 -1
- package/src/server/imported-subagents-dir.ts +1 -1
- package/src/server/kanna-mcp.test.ts +0 -75
- package/src/server/kanna-mcp.ts +1 -47
- package/src/server/server.test.ts +5 -7
- package/src/server/server.ts +2 -18
- package/src/server/subagent-orchestrator.test.ts +0 -1
- package/src/server/subagent-provider-run.test.ts +48 -10
- package/src/server/subagent-provider-run.ts +12 -3
- package/src/server/tool-callback.test.ts +1 -1
- package/src/server/ws-router-agent-ctrl.test.ts +0 -45
- package/src/server/ws-router-agent-ctrl.ts +1 -31
- package/src/server/ws-router-broadcast.ts +0 -27
- package/src/server/ws-router-defaults.test.ts +2 -3
- package/src/server/ws-router-defaults.ts +2 -3
- package/src/server/ws-router-envelope.ts +0 -15
- package/src/server/ws-router-observability.test.ts +1 -1
- package/src/server/ws-router-settings.test.ts +2 -2
- package/src/server/ws-router.test.ts +2 -2
- package/src/server/ws-router.ts +0 -8
- package/src/shared/app-settings-types.ts +9 -20
- package/src/shared/claude-api-error-classification.ts +1 -1
- package/src/shared/protocol.ts +1 -11
- package/dist/client/assets/BoardsRoutePage-BTTjJX-Y.js +0 -1
- package/dist/client/assets/ChatPage-DH8wtQyD.js +0 -93
- package/dist/client/assets/SettingsPage-CKrZ6dGQ.js +0 -9
- package/dist/client/assets/chevron-left-CJ0qv9kF.js +0 -1
- package/dist/client/assets/editor-icons-CONDQZof.js +0 -1
- package/dist/client/assets/index-C-UYaDk6.css +0 -1
- package/dist/client/assets/runDetached-DqQ3k2ji.js +0 -1
- package/dist/client/assets/useAppGlobalState-DKOGrO5l.js +0 -1
- package/dist/client/assets/useKannaState-D7R_-dM6.js +0 -5
- package/dist/client/assets/useTheme-B57LIKyx.js +0 -1
- package/src/server/agent.pty-rotation.test.ts +0 -322
- package/src/server/claude-pty/auth.test.ts +0 -38
- package/src/server/claude-pty/auth.ts +0 -17
- package/src/server/claude-pty/claude-session-registry.adapter.ts +0 -68
- package/src/server/claude-pty/claude-session-registry.test.ts +0 -149
- package/src/server/claude-pty/driver.test.ts +0 -1153
- package/src/server/claude-pty/driver.ts +0 -829
- package/src/server/claude-pty/env.test.ts +0 -79
- package/src/server/claude-pty/env.ts +0 -20
- package/src/server/claude-pty/jsonl-to-event.test.ts +0 -882
- package/src/server/claude-pty/jsonl-to-event.ts +0 -357
- package/src/server/claude-pty/parity-matrix.test.ts +0 -437
- package/src/server/claude-pty/pid-registry.adapter.ts +0 -164
- package/src/server/claude-pty/pid-registry.test.ts +0 -178
- package/src/server/claude-pty/preflight/binary-fingerprint.adapter.ts +0 -20
- package/src/server/claude-pty/preflight/binary-fingerprint.test.ts +0 -32
- package/src/server/claude-pty/pty-instance-registry.test.ts +0 -208
- package/src/server/claude-pty/pty-instance-registry.ts +0 -172
- package/src/server/claude-pty/pty-memory-sampler.adapter.test.ts +0 -103
- package/src/server/claude-pty/pty-memory-sampler.adapter.ts +0 -86
- package/src/server/claude-pty/pty-process.adapter.ts +0 -60
- package/src/server/claude-pty/pty-process.test.ts +0 -49
- package/src/server/claude-pty/resolve-binary.adapter.ts +0 -106
- package/src/server/claude-pty/resolve-binary.test.ts +0 -118
- package/src/server/claude-pty/runtime-dir.adapter.ts +0 -19
- package/src/server/claude-pty/sandbox/detect.adapter.ts +0 -17
- package/src/server/claude-pty/sandbox/detect.test.ts +0 -17
- package/src/server/claude-pty/sandbox/platform.test.ts +0 -35
- package/src/server/claude-pty/sandbox/platform.ts +0 -27
- package/src/server/claude-pty/sandbox/preflight-io.adapter.ts +0 -14
- package/src/server/claude-pty/sandbox/preflight.test.ts +0 -69
- package/src/server/claude-pty/sandbox/preflight.ts +0 -44
- package/src/server/claude-pty/sandbox/profile-linux.adapter.ts +0 -63
- package/src/server/claude-pty/sandbox/profile-linux.test.ts +0 -90
- package/src/server/claude-pty/sandbox/profile-macos.adapter.ts +0 -72
- package/src/server/claude-pty/sandbox/profile-macos.test.ts +0 -68
- package/src/server/claude-pty/sandbox/wrap.adapter.ts +0 -58
- package/src/server/claude-pty/sandbox/wrap.test.ts +0 -82
- package/src/server/claude-pty/settings-writer.adapter.ts +0 -23
- package/src/server/claude-pty/settings-writer.test.ts +0 -22
- package/src/server/claude-pty/smoke-test-io.adapter.ts +0 -28
- package/src/server/claude-pty/smoke-test.test.ts +0 -199
- package/src/server/claude-pty/smoke-test.ts +0 -182
- package/src/server/claude-pty/tui-control.test.ts +0 -300
- package/src/server/claude-pty/tui-control.ts +0 -174
- package/src/server/claude-pty/tui-source.adapter.test.ts +0 -374
- package/src/server/claude-pty/tui-source.adapter.ts +0 -294
- package/src/server/http-server.adapter.test.ts +0 -18
- package/src/server/http-server.adapter.ts +0 -39
- package/src/server/kanna-mcp-http.test.ts +0 -274
- package/src/server/kanna-mcp-http.ts +0 -194
- package/src/server/kanna-mcp-tools/ask-user-question.test.ts +0 -108
- package/src/server/kanna-mcp-tools/ask-user-question.ts +0 -55
- package/src/server/kanna-mcp-tools/exit-plan-mode.test.ts +0 -61
- package/src/server/kanna-mcp-tools/exit-plan-mode.ts +0 -49
- package/src/server/mcp-zod-compat.adapter.ts +0 -20
- package/src/shared/pty-instance.ts +0 -43
- /package/src/server/{claude-pty/output-ring.test.ts → output-ring.test.ts} +0 -0
- /package/src/server/{claude-pty/output-ring.ts → output-ring.ts} +0 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{t}from"./react-DiVRNtpo.js";import{c as n,l as r,u as i}from"./chunk-OB3PAWPO-mARpRU1A.js";import{t as a}from"./jsx-runtime-BdxMnOeJ.js";import{$ as o,Ct as s,F as c,Ft as l,K as u,L as d,N as f,O as p,Q as m,R as h,St as g,Tt as _,W as v,X as y,Y as b,Z as x,_t as S,an as C,at as w,b as T,bt as ee,ct as E,et as D,ft as O,gt as k,ht as A,in as te,k as ne,lt as j,mt as re,n as ie,nn as ae,nt as oe,o as se,on as ce,ot as le,pt as ue,q as de,rt as fe,st as pe,tn as me,tt as he,vt as ge,wt as _e,xt as ve,yt as ye}from"./useAppGlobalState-DUa3pkCF.js";import{a as be,c as xe,d as Se,f as Ce,p as we,s as Te}from"./log-DnEvbp3E.js";import{a as M,c as N,d as P,f as F,n as I,o as Ee,r as L,s as R,t as z}from"./pendingActionsStore-CxhI19V9.js";import{c as De,f as Oe,l as ke,n as Ae,p as je,r as Me,u as Ne}from"./editor-icons-DY4uKeEY.js";import{Bt as Pe,Vt as Fe,t as Ie,zt as Le}from"./lexicalToReact-CZvp9Pgz.js";import{n as Re,t as ze}from"./clipboard.adapter-CgdNwn-1.js";import{a as Be,i as B,n as Ve,o as He,r as Ue,t as We}from"./select-BjeajpVt.js";import{a as Ge,f as Ke,h as qe,i as Je,l as Ye,m as Xe,n as Ze,o as Qe,p as $e,t as et}from"./pushClient-CxnHu9h4.js";import{t as tt}from"./info-DNYekoE-.js";import{t as V}from"./monitor-qbWfUdBG.js";import{t as nt}from"./pencil-C965rrpd.js";import{t as rt}from"./plus-D4CI6rj1.js";import{g as it,i as at,n as ot,o as st,r as ct,t as lt,u as ut}from"./timer.adapter-C2RhP4d6.js";import{a as dt,c as ft,o as pt,s as mt,t as ht}from"./segmented-control-CKGX29Kl.js";import{t as H}from"./input-DgW9uRZN.js";import{S as U,_ as gt,b as _t,d as vt,f as yt,g as bt,h as xt,m as St,p as Ct,r as wt,v as Tt,x as Et,y as Dt}from"./useTheme-D9sKDPEm.js";import{t as Ot}from"./runDetached-DfQXHAaY.js";import{t as kt}from"./chatSounds-BLg2xPDZ.js";import{i as At,r as jt,t as Mt}from"./status-pill-Bo1Nb6HX.js";import{t as Nt}from"./settings-header-button-BYvHR6Xl.js";var Pt={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`}]]};Pt.node;var Ft=F(Pt),It={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`]};It.node;var Lt=F(It),Rt={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`]};Rt.node;var zt=F(Rt),Bt={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`}]]};Bt.node;var Vt=F(Bt),Ht={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`}]]};Ht.node;var Ut=F(Ht),Wt={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`}]]};Wt.node;var Gt=F(Wt),Kt={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`}]]};Kt.node;var qt=F(Kt),Jt={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`}]]};Jt.node;var Yt=F(Jt),Xt={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`}]]};Xt.node;var Zt=F(Xt),Qt={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`}]]};Qt.node;var $t=F(Qt),en={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`}]]};en.node;var tn=F(en),nn={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`}]]};nn.node;var rn=F(nn),an={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`}]]};an.node;var on=F(an),sn={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`}]]};sn.node;var cn=F(sn),ln={enabled:!1,cloudflaredPath:`cloudflared`,mode:`always-ask`},W=e(t(),1),G=e(a(),1);function un(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 dn={maxFileSizeMb:100},fn=2048,pn=`gpt-5.4-mini`;function mn(e){return e===`previous-assistant-reply`||e===`full-transcript`}function K(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`],gn=[`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 _n(){return{name:``,provider:`claude`,model:w(`claude`).defaultModel,modelOptions:{...o},systemPrompt:``,contextScope:`previous-assistant-reply`,triggerMode:`auto`}}function vn(){return{draft:_n(),error:null,pending:!1,confirmDelete:!1}}var q=xe()(e=>({editing:{kind:`list`},form:vn(),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 yn(e){return`contextWindow`in e}function bn(e){return`fastMode`in e}function xn(e){let t=e.editing,n=(0,W.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,G.jsx)(Sn,{onStartCreate:e.onStartCreate}):(0,G.jsxs)(`div`,{className:`flex flex-col gap-6 md:flex-row md:items-start md:gap-8`,children:[a?null:(0,G.jsx)(wn,{subagents:e.subagents,editing:e.editing,onSelect:e.onSelect,onStartCreate:e.onStartCreate}),i?(0,G.jsx)(kn,{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,G.jsx)(Cn,{})]})}function Sn(e){return(0,G.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,G.jsx)(`div`,{className:`flex size-10 items-center justify-center rounded-full bg-muted text-muted-foreground`,children:(0,G.jsx)(je,{className:`size-5`,"aria-hidden":!0})}),(0,G.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`No subagents yet`}),(0,G.jsxs)(M,{variant:`default`,size:`sm`,onClick:e.onStartCreate,children:[(0,G.jsx)(rt,{className:`mr-1.5 size-4`}),` Create subagent`]})]})}function Cn(){return(0,G.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 wn(e){let t=e.editing.kind===`edit`?e.editing.id:null;return(0,G.jsxs)(`aside`,{className:`flex w-full flex-col gap-2 md:w-64 md:flex-shrink-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.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,G.jsxs)(M,{variant:`ghost`,size:`sm`,onClick:e.onStartCreate,"data-testid":`subagent-create`,children:[(0,G.jsx)(rt,{className:`size-4`}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Create subagent`})]})]}),(0,G.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,G.jsx)(`li`,{children:(0,G.jsxs)(`button`,{type:`button`,"data-testid":`subagent-row:${n.id}`,onClick:()=>e.onSelect(n.id),className:N(`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,G.jsxs)(`span`,{className:`flex w-full items-center justify-between gap-2`,children:[(0,G.jsx)(`span`,{className:`truncate text-sm font-medium text-foreground`,children:n.name}),(0,G.jsx)(Tn,{provider:n.provider})]}),(0,G.jsx)(`span`,{className:`w-full truncate text-xs text-muted-foreground`,children:r})]})},n.id)})})]})}function Tn({provider:e}){let t=w(e).label;return(0,G.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,G.jsx)(je,{className:`size-3`}),` `,t]})}var En=[{value:`claude`,label:`Claude`},{value:`codex`,label:`Codex`},{value:`openrouter`,label:`OpenRouter`}];function J(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 Dn=[{value:`previous-assistant-reply`,label:`Last reply`},{value:`full-transcript`,label:`Full transcript`}],On=[{value:`auto`,label:`Auto`},{value:`manual`,label:`Manual`}];function kn(e){let t=(0,W.useMemo)(()=>e.mode===`edit`&&e.subject?Rn(e.subject):Ln(`claude`,e.providerDefaults,e.availableProviders),[e.mode,e.subject,e.providerDefaults,e.availableProviders]),n=q(e=>e.resetForm),r=q(e=>e.form),i=q(e=>e.patchFormDraft),a=q(e=>e.patchForm);(0,W.useEffect)(()=>{n(t)},[]);let{draft:s,error:c,pending:l,confirmDelete:u}=r,d=c?.field===`name`?c.message:null,f=c?.field===`general`?c.message:null,p=Bn(s,t),h=s.name.trim().length>0&&(e.mode===`create`||p);function g(e){i(e),c?.field===`name`&&`name`in e&&a({error:null})}function _(t){if(t===s.provider)return;let n=Ln(t,e.providerDefaults,e.availableProviders);i({provider:t,model:n.model,modelOptions:n.modelOptions})}function v(e){if(s.provider!==`claude`)return;let t=yn(s.modelOptions)?s.modelOptions:o;i({modelOptions:{...o,...t,reasoningEffort:e}})}function S(e){if(s.provider!==`claude`)return;let t=yn(s.modelOptions)?s.modelOptions:o;i({modelOptions:{...o,...t,contextWindow:e}})}function C(e){if(s.provider!==`codex`)return;let t=bn(s.modelOptions)?s.modelOptions:D;i({modelOptions:{...D,...t,reasoningEffort:e}})}async function T(){if(h&&!l){a({pending:!0,error:null,confirmDelete:!1});try{let t=e.mode===`create`?await e.handlers.onCreate(s):await e.handlers.onUpdate(e.subject.id,s);t.ok||a({error:Hn(t.error)})}catch(e){a({error:{field:`general`,message:Ce(e)}})}finally{a({pending:!1})}}}async function ee(){if(e.mode===`edit`&&e.subject){if(!u){a({confirmDelete:!0});return}a({pending:!0,error:null});try{await e.handlers.onDelete(e.subject.id)}catch(e){a({error:{field:`general`,message:Ce(e)}})}finally{a({pending:!1,confirmDelete:!1})}}}let O=s.provider===`claude`?{...o,...yn(s.modelOptions)?s.modelOptions:{}}:null,k=s.provider===`codex`?{...D,...bn(s.modelOptions)?s.modelOptions:{}}:null,A=e.availableProviders.find(e=>e.id===s.provider)??w(s.provider);return(0,G.jsxs)(`section`,{className:`flex w-full flex-1 flex-col gap-4`,children:[(0,G.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(`h3`,{className:`text-base font-medium text-foreground`,children:e.mode===`create`?`New subagent`:s.name||`Subagent`}),(0,G.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Mention with `,(0,G.jsxs)(`code`,{className:`rounded bg-muted px-1 py-0.5 font-mono text-xs`,children:[`@agent/`,s.name||`<name>`]}),` in chat.`]})]}),f?(0,G.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-sm text-destructive`,children:f}):null,(0,G.jsx)(Y,{label:`Name`,hint:d,hintTone:d?`destructive`:`muted`,children:(0,G.jsx)(H,{"data-testid":`subagent-form-name`,value:s.name,onChange:e=>g({name:Un(e.target.value)}),maxLength:64,placeholder:`reviewer`,className:`font-mono`})}),(0,G.jsx)(Y,{label:`Description`,hint:`Optional. Shown next to the name.`,children:(0,G.jsx)(H,{"data-testid":`subagent-form-description`,value:s.description??``,onChange:e=>g({description:e.target.value}),placeholder:`Reviews diffs against the repo style`})}),(0,G.jsx)(Y,{label:`Provider`,children:(0,G.jsx)(ht,{value:s.provider,onValueChange:e=>{b(e)&&_(e)},options:En,size:`sm`})}),(0,G.jsx)(Y,{label:`Model`,children:(0,G.jsxs)(We,{value:s.model,onValueChange:e=>g({model:e}),children:[(0,G.jsx)(Be,{"data-testid":`subagent-form-model`,className:`w-full md:w-72`,children:(0,G.jsx)(He,{placeholder:`Select a model`})}),(0,G.jsx)(Ve,{children:A.models.map(e=>(0,G.jsx)(B,{value:e.id,children:e.label},e.id))})]})}),O?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{label:`Reasoning effort`,children:(0,G.jsx)(ht,{value:O.reasoningEffort,onValueChange:e=>{pe(e)&&v(e)},options:x.map(e=>({value:e.id,label:e.label})),size:`sm`})}),(0,G.jsx)(Y,{label:`Context window`,children:(0,G.jsx)(ht,{value:O.contextWindow,onValueChange:e=>{le(e)&&S(e)},options:y.map(e=>({value:e.id,label:e.label})),size:`sm`})})]}):null,k?(0,G.jsx)(Y,{label:`Reasoning effort`,children:(0,G.jsx)(ht,{value:k.reasoningEffort,onValueChange:e=>{E(e)&&C(e)},options:m.map(e=>({value:e.id,label:e.label})),size:`sm`})}):null,(0,G.jsx)(Y,{label:`Context scope`,children:(0,G.jsx)(ht,{value:s.contextScope,onValueChange:e=>{mn(e)&&g({contextScope:e})},options:Dn,size:`sm`})}),(0,G.jsx)(Y,{label:`Trigger`,hint:`Auto: the main agent may delegate on its own. Manual: only runs when you @-mention it.`,children:(0,G.jsx)(ht,{value:s.triggerMode??`auto`,onValueChange:e=>{K(e)&&g({triggerMode:e})},options:On,size:`sm`})}),(0,G.jsx)(Y,{label:`System prompt`,hint:`What this persona should focus on. Plain text.`,children:(0,G.jsx)(Ke,{"data-testid":`subagent-form-system-prompt`,value:s.systemPrompt,onChange:e=>g({systemPrompt:e.target.value}),placeholder:`You are a careful code reviewer...`,rows:6,className:`min-h-32`})}),(0,G.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,G.jsx)(H,{"data-testid":`subagent-form-max-turns`,type:`number`,min:1,step:1,value:s.maxTurns?.toString()??``,onChange:e=>{let t=Number.parseInt(e.target.value,10);g({maxTurns:Number.isInteger(t)&&t>0?t:void 0})},placeholder:`unbounded`,className:`w-36`})}),s.provider===`claude`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{label:`Working directory`,hint:`Optional. Relative to the parent chat cwd. Restricts the subagent's filesystem access to this subtree.`,children:(0,G.jsx)(H,{"data-testid":`subagent-form-working-dir`,value:s.workingDir??``,onChange:e=>{let t=e.target.value;g({workingDir:t.length>0?t:void 0})},placeholder:`docs`})}),(0,G.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,G.jsx)(Ke,{"data-testid":`subagent-form-allowed-paths`,value:(s.allowedPaths??[]).join(`
|
|
2
|
+
`),onChange:e=>{let t=e.target.value.split(/\r?\n/).map(e=>e.trim()).filter(e=>e.length>0);g({allowedPaths:t.length>0?t:void 0})},placeholder:`docs
|
|
3
|
+
wiki`,rows:3})})]}):null,(0,G.jsxs)(`footer`,{className:`flex flex-wrap items-center justify-end gap-2 pt-2`,children:[(0,G.jsx)(M,{variant:`ghost`,size:`sm`,onClick:e.onCancelEditing,children:`Cancel`}),e.mode===`edit`?(0,G.jsx)(M,{variant:`destructive`,size:`sm`,"data-testid":`subagent-form-delete`,disabled:l,pending:l&&u,onClick:()=>{I(z(`subagent.delete`,e.subject?.id??``),ee)},children:u?`Confirm delete`:`Delete`}):null,(0,G.jsx)(M,{variant:`default`,size:`sm`,"data-testid":`subagent-form-save`,disabled:!h||l,pending:l&&!u,onClick:()=>{I(z(`subagent.save`,e.subject?.id??`new`),T)},children:l?`Saving…`:`Save`})]})]})}function Y(e){return(0,G.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:e.label}),e.children,e.hint?(0,G.jsx)(`span`,{className:N(`text-xs`,e.hintTone===`destructive`?`text-destructive`:`text-muted-foreground`),children:e.hint}):null]})}var An=[],jn={claude:{model:w(`claude`).defaultModel,modelOptions:{...o},planMode:!1},codex:{model:w(`codex`).defaultModel,modelOptions:{...D},planMode:!1},openrouter:{model:he,modelOptions:{},planMode:!1}};function Mn(e){let t=U(e=>e.settings?.subagents??An),n=U(e=>e.settings?.providerDefaults??jn),r=U(St),i=p(At(e=>e.models)),a=(0,W.useMemo)(()=>J(j([...oe],r),i),[r,i]),o=q(e=>e.editing),s=q(e=>e.setEditing),c=(0,W.useMemo)(()=>({onCreate:async t=>{let n=await e.state.socket.command({type:`subagent.create`,input:t});return n.ok&&s({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}),s({kind:`list`})}}),[e.state.socket,s]),l=(0,W.useCallback)(e=>{s({kind:`edit`,id:e})},[s]),u=(0,W.useCallback)(()=>{s({kind:`create`})},[s]),d=(0,W.useCallback)(()=>{s({kind:`list`})},[s]);return(0,G.jsxs)(`div`,{className:`flex flex-col gap-6 px-6 py-6`,children:[(0,G.jsx)(Z,{subagents:t,handleWriteAppSettings:e.state.handleWriteAppSettings}),(0,G.jsx)(xn,{subagents:t,providerDefaults:n,availableProviders:a,editing:o,onSelect:l,onStartCreate:u,onCancelEditing:d,handlers:c})]})}var Nn=`__none__`,Pn=30,Fn=86400,X=600;function Z(e){let t=U(e=>e.settings?.subagentRuntime),n=t?Math.round(t.runTimeoutMs/1e3):X,r=t?.defaultLoopSubagentId??null,i=q(e=>e.timeoutDraft),a=q(e=>e.setTimeoutDraft),o=q(e=>e.loopError),s=q(e=>e.setLoopError);(0,W.useEffect)(()=>{a(String(n))},[n]);function c(){let t=Number(i);if(!Number.isInteger(t)||t<Pn||t>Fn){a(String(n)),s(`Timeout must be a whole number of seconds between ${Pn} and ${Fn}.`);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===Nn?null:t;e.handleWriteAppSettings({subagentRuntime:{defaultLoopSubagentId:n}}).catch(e=>s(e instanceof Error?e.message:`Unable to save default loop subagent.`))}return(0,G.jsxs)(`section`,{className:`flex flex-col gap-4 rounded-lg border border-border/60 bg-card/40 p-4`,children:[(0,G.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(`h3`,{className:`text-sm font-medium text-foreground`,children:`Loop & runtime`}),(0,G.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Applies to background subagent runs and the autonomous `,(0,G.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 font-mono`,children:`/loop`}),`.`]})]}),o?(0,G.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-xs text-destructive`,children:o}):null,(0,G.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,G.jsx)(H,{type:`number`,inputMode:`numeric`,min:Pn,max:Fn,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,G.jsx)(Y,{label:`Default loop subagent`,hint:`The subagent setup_loop delegates each chunk to when no explicit id is given.`,children:(0,G.jsxs)(We,{value:r??Nn,onValueChange:l,children:[(0,G.jsx)(Be,{className:`w-full md:w-72`,children:(0,G.jsx)(He,{placeholder:`None`})}),(0,G.jsxs)(Ve,{children:[(0,G.jsx)(B,{value:Nn,children:`None (require explicit id)`}),e.subagents.map(e=>(0,G.jsx)(B,{value:e.id,children:e.name},e.id))]})]})})]})}var In=new Set([`EMPTY_NAME`,`INVALID_CHAR`,`RESERVED_NAME`,`DUPLICATE_NAME`,`TOO_LONG`]);function Ln(e,t,n){if(e===`claude`){let r=t?.claude;return{name:``,provider:e,model:r?.model??n?.find(e=>e.id===`claude`)?.defaultModel??w(`claude`).defaultModel,modelOptions:{...r?.modelOptions??{...o}},systemPrompt:``,contextScope:`previous-assistant-reply`,triggerMode:`auto`}}if(e===`openrouter`)return{name:``,provider:e,model:t?.openrouter?.model??n?.find(e=>e.id===`openrouter`)?.defaultModel??w(`openrouter`).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??w(`codex`).defaultModel,modelOptions:{...r?.modelOptions??{...D}},systemPrompt:``,contextScope:`previous-assistant-reply`,triggerMode:`auto`}}function Rn(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}}var zn=(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 Bn(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??``)||!zn(e.allowedPaths,t.allowedPaths)||(e.maxTurns??null)!==(t.maxTurns??null)||!Vn(e.modelOptions,t.modelOptions)}function Vn(e,t){if(!we(e)||!we(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 Hn(e){return In.has(e.code)?{field:`name`,message:e.message}:{field:`general`,message:e.message}}function Un(e){return e.toLowerCase().replace(/[^a-z0-9_-]+/g,`-`).slice(0,64)}function Q({title:e,description:t,children:n,bordered:r=!0,alignStart:i=!1}){return(0,G.jsx)(`div`,{className:r?`border-t border-border`:void 0,children:(0,G.jsxs)(`div`,{className:N(`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,G.jsxs)(`div`,{className:`min-w-0 max-w-xl`,children:[(0,G.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:e}),(0,G.jsx)(`div`,{className:`mt-1 text-13 text-muted-foreground`,children:t})]}),(0,G.jsx)(`div`,{className:`flex items-center justify-start md:shrink-0 md:justify-end`,children:n})]})})}function Wn({icon:e,message:t}){return(0,G.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-md border border-dashed px-6 py-10 text-center`,children:[(0,G.jsx)(e,{className:`mb-3 h-8 w-8 text-muted-foreground`,"aria-hidden":!0}),(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t})]})}function Gn({children:e}){return(0,G.jsx)(`ul`,{className:`flex flex-col divide-y rounded-md border`,children:e})}function Kn({label:e,onEdit:t,onDelete:n,deletePending:r=!1}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(M,{variant:`ghost`,size:`sm`,onClick:t,"aria-label":`Edit ${e}`,children:(0,G.jsx)(nt,{className:`h-4 w-4`})}),(0,G.jsx)(M,{variant:`ghost`,size:`sm`,onClick:n,pending:r,"aria-label":`Delete ${e}`,children:(0,G.jsx)(me,{className:`h-4 w-4`})})]})}var qn=new Set;function Jn(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 Yn=xe()(e=>({editing:{kind:`list`},testingServerIds:qn,editorForm:Jn(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?qn:r}}),resetEditorForm:t=>e({editorForm:Jn(t)}),patchEditorForm:t=>e(e=>({editorForm:{...e.editorForm,...t}}))}));function Xn(e,t){return(0,W.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 Zn(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 Qn(e){return e.submitting?`Saving…`:e.isEdit?`Save changes`:e.addLabel}function $n({server:e,handlers:t,onEdit:n,dom:r=Se}){let i=Yn(t=>t.testingServerIds.has(e.id)),a=Yn(e=>e.setServerTesting),o=(0,W.useCallback)(async()=>{a(e.id,!0);try{await t.onTest(e.id)}finally{a(e.id,!1)}},[t,e.id,a]),s=z(`mcpServers.delete`,e.id),c=L(s),l=z(`mcpServers.setEnabled`,e.id),u=L(l),d=z(`settings.testMcpServer`,e.id),f=(0,W.useCallback)(()=>{r.confirmDialog(`Delete MCP server "${e.name}"?`)&&I(s,()=>t.onDelete(e.id))},[s,r,t,e.id,e.name]),p=(0,W.useCallback)(n=>{let r=n.target.checked;I(l,()=>t.onSetEnabled(e.id,r))},[t,e.id,l]),m=(0,W.useCallback)(()=>{I(d,o)},[o,d]);return(0,G.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-3`,"aria-busy":c||void 0,children:[(0,G.jsxs)(`div`,{className:`flex flex-col`,children:[(0,G.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,G.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[(0,G.jsx)(er,{transport:e.transport}),(0,G.jsx)(`span`,{className:`ml-2`,children:e.transport===`stdio`?e.command:e.url})]})]}),(0,G.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,G.jsx)(tr,{result:e.lastTest,pending:i}),e.transport!==`stdio`&&(0,G.jsx)(nr,{oauth:e.oauth}),(0,G.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-1 text-xs text-muted-foreground`,children:[u?(0,G.jsx)(R,{}):null,(0,G.jsx)(`input`,{type:`checkbox`,checked:e.enabled,disabled:u,"aria-busy":u||void 0,onChange:p,"aria-label":`Enabled`}),(0,G.jsx)(`span`,{children:`On`})]}),(0,G.jsx)(M,{variant:`ghost`,size:`sm`,onClick:m,disabled:i,"aria-busy":i||void 0,title:`Test connection`,children:(0,G.jsx)(Fe,{className:N(`h-4 w-4`,i&&`animate-spin`)})}),(0,G.jsx)(Kn,{label:e.name,onEdit:n,onDelete:f,deletePending:c})]})]})}function er({transport:e}){return(0,G.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-xs`,children:e})}function tr({result:e,pending:t}){if(t||e.status===`pending`)return(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Testing…`});switch(e.status){case`ok`:return(0,G.jsxs)(`span`,{className:`text-xs text-green-600`,children:[`OK · `,e.toolCount,` tools`]});case`error`:return(0,G.jsx)($e,{label:e.message,children:(0,G.jsx)(`span`,{className:`text-xs text-red-600`,children:`Failed`})});default:return(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Untested`})}}function nr({oauth:e}){if(!e?.enabled)return null;switch(e.status){case`authenticated`:return(0,G.jsx)(`span`,{className:`text-xs text-green-600`,children:`OAuth ✓`});case`error`:return(0,G.jsx)($e,{label:e.errorMessage,children:(0,G.jsx)(`span`,{className:`text-xs text-red-600`,children:`OAuth error`})});default:return(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`OAuth: unauth`})}}var rr=new Set([`stdio`,`http`,`sse`,`ws`]);function ir(e){return rr.has(e)}var ar=`new`,or=e=>({customMcpServers:e});function sr(e){return e.editing.kind===`list`?e.servers.length===0?(0,G.jsxs)(`div`,{className:`flex flex-col items-center justify-center px-6 py-16 text-center`,children:[(0,G.jsx)($t,{className:`mb-4 h-10 w-10 text-muted-foreground`,"aria-hidden":!0}),(0,G.jsx)(`h2`,{className:`text-lg font-medium`,children:`No custom MCP servers`}),(0,G.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,G.jsxs)(M,{className:`mt-6`,onClick:e.onStartCreate,children:[(0,G.jsx)(rt,{className:`mr-1 h-4 w-4`}),`Add server`]})]}):(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 px-6 py-6`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`h2`,{className:`text-base font-medium`,children:`Custom MCP servers`}),(0,G.jsxs)(M,{size:`sm`,onClick:e.onStartCreate,children:[(0,G.jsx)(rt,{className:`mr-1 h-4 w-4`}),`Add server`]})]}),(0,G.jsx)(Gn,{children:e.servers.map(t=>(0,G.jsx)($n,{server:t,handlers:e.handlers,onEdit:()=>e.onSelect(t.id)},t.id))})]}):(0,G.jsx)(cr,{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 cr({initial:e,existingNames:t,onCancel:n,handlers:r,clipboard:i=ze}){let a=Yn(e=>e.editorForm),o=Yn(e=>e.resetEditorForm),s=Yn(e=>e.patchEditorForm),c=(0,W.useCallback)(e=>{ir(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:S,authenticating:C,completing:w}=a,T=(0,W.useRef)(e);(0,W.useEffect)(()=>{o(T.current)},[o]);let ee=e!==null&&e.transport!==`stdio`?e.oauth:void 0,E=e?.id??ar,D=z(`mcpServers.toggleOAuth`,E),O=L(D),k=z(`mcpServers.copyAuthUrl`,E),A=L(k),te=(0,W.useCallback)(async t=>{s(t?{oauthEnabled:!0}:{oauthEnabled:!1,authFlowUrl:null,callbackInput:``,oauthError:null}),e&&await r.onUpdate(e.id,{oauth:{...ee??{status:`unauthenticated`},enabled:t}})},[e,ee,r,s]),ne=(0,W.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]),j=(0,W.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]),re=(0,W.useCallback)(e=>{let t=e.target.checked;I(D,()=>te(t))},[te,D]),ie=(0,W.useCallback)(()=>{I(z(`settings.startMcpOAuth`,E),ne)},[E,ne]),ae=(0,W.useCallback)(()=>{I(z(`settings.completeMcpOAuth`,E),j)},[j,E]),oe=(0,W.useCallback)(()=>{b&&I(k,()=>i.writeText(b))},[b,i,k]),se=(0,W.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]),ce=(0,W.useCallback)(async()=>{se||await Zn({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,se,n,u,h,s]),le=(0,W.useCallback)(()=>{I(z(`mcpServers.save`,E),ce)},[E,ce]),ue=Qn({submitting:v,isEdit:e!==null,addLabel:`Add server`});return(0,G.jsxs)(`div`,{className:`flex flex-col gap-4 px-6 py-6 max-w-2xl`,children:[(0,G.jsx)(`h2`,{className:`text-base font-medium`,children:e?`Edit MCP server`:`Add MCP server`}),(0,G.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`Name`}),(0,G.jsx)(H,{value:l,onChange:e=>s({name:e.target.value}),placeholder:`fs`}),se&&(0,G.jsx)(`p`,{className:`text-xs text-red-600`,children:se})]}),(0,G.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`Transport`}),(0,G.jsxs)(We,{value:u,onValueChange:c,children:[(0,G.jsx)(Be,{children:(0,G.jsx)(He,{})}),(0,G.jsxs)(Ve,{children:[(0,G.jsx)(B,{value:`stdio`,children:`stdio (spawn local command)`}),(0,G.jsx)(B,{value:`http`,children:`http (Streamable HTTP)`}),(0,G.jsx)(B,{value:`sse`,children:`sse (Server-Sent Events)`}),(0,G.jsx)(B,{value:`ws`,children:`ws (WebSocket)`})]})]})]}),u===`stdio`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`Command`}),(0,G.jsx)(H,{value:d,onChange:e=>s({command:e.target.value}),placeholder:`/usr/local/bin/mcp-filesystem`})]}),(0,G.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`Args (one per line)`}),(0,G.jsx)(Ke,{value:f,onChange:e=>s({argsText:e.target.value}),rows:3,className:`font-mono text-sm`})]}),(0,G.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`Env (KEY=value, one per line)`}),(0,G.jsx)(Ke,{value:p,onChange:e=>s({envText:e.target.value}),rows:3,className:`font-mono text-sm`})]}),(0,G.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`cwd (optional)`}),(0,G.jsx)(H,{value:m,onChange:e=>s({cwd:e.target.value}),placeholder:`/optional/working/dir`})]})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`URL`}),(0,G.jsx)(H,{value:h,onChange:e=>s({url:e.target.value}),placeholder:u===`ws`?`wss://example.com/mcp`:`https://example.com/mcp`})]}),u===`ws`?(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Headers are not supported on the ws transport.`}):(0,G.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`Headers (Key: value, one per line)`}),(0,G.jsx)(Ke,{value:g,onChange:e=>s({headersText:e.target.value}),rows:3,className:`font-mono text-sm`,disabled:y}),y&&(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Authorization header is managed by OAuth when enabled.`})]}),(u===`http`||u===`sse`)&&(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-md border p-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(Oe,{className:`h-4 w-4 text-muted-foreground`,"aria-hidden":!0}),(0,G.jsx)(`span`,{className:`text-xs font-medium`,children:`OAuth 2.1`}),(0,G.jsxs)(`label`,{className:`ml-auto flex cursor-pointer items-center gap-1 text-xs text-muted-foreground`,children:[O?(0,G.jsx)(R,{}):null,(0,G.jsx)(`input`,{type:`checkbox`,checked:y,disabled:O,"aria-busy":O||void 0,onChange:re,"aria-label":`Enable OAuth`}),(0,G.jsx)(`span`,{children:`Enable`})]})]}),y&&!e&&(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Save the server first, then authenticate.`}),y&&e&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(nr,{oauth:ee}),ee?.status===`authenticated`&&(0,G.jsx)(M,{variant:`ghost`,size:`sm`,onClick:ie,pending:C,children:`Re-authenticate`})]}),(ee?.status!==`authenticated`||b)&&(b?(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.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,G.jsx)(qe,{className:`h-3 w-3`})]}),(0,G.jsx)($e,{label:`Copy URL`,children:(0,G.jsx)(`button`,{type:`button`,onClick:oe,disabled:A,"aria-busy":A||void 0,className:`ml-1 text-muted-foreground hover:text-foreground`,"aria-label":`Copy authorization URL`,children:A?(0,G.jsx)(R,{className:`size-3`}):(0,G.jsx)(Re,{className:`h-3 w-3`})})})]}),(0,G.jsxs)(`div`,{className:`grid gap-1`,children:[(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`After authorizing, paste the callback URL here:`}),(0,G.jsx)(H,{value:x,onChange:e=>s({callbackInput:e.target.value}),placeholder:`http://localhost:…/callback?code=…`,className:`font-mono text-xs`})]}),(0,G.jsx)(M,{variant:`outline`,size:`sm`,className:`w-fit`,onClick:ae,pending:w,disabled:x.length===0,children:w?`Completing…`:`Complete`})]}):(0,G.jsx)(M,{variant:`outline`,size:`sm`,className:`w-fit`,onClick:ie,pending:C,children:C?`Starting…`:`Authenticate`})),S&&(0,G.jsx)(`p`,{className:`text-xs text-red-600`,children:S})]})]})]}),_&&(0,G.jsx)(`p`,{className:`text-xs text-red-600`,children:_}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,G.jsx)(M,{variant:`ghost`,onClick:n,disabled:v,children:`Cancel`}),(0,G.jsx)(M,{onClick:le,pending:v,disabled:!!se||l.length===0,children:ue})]})]})}function lr(e){let t=U(Ct),n=Yn(e=>e.editing),r=Yn(e=>e.setEditing),i=Xn(or,e.state),a=(0,W.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,G.jsx)(sr,{servers:t,editing:n,onSelect:e=>r({kind:`edit`,id:e}),onStartCreate:()=>r({kind:`create`}),onCancelEditing:()=>r({kind:`list`}),handlers:a})}var ur={id:``,label:``,modelProvider:`claude`,supportedEfforts:[],offersOneMillionContext:!1};function dr(e){return{...e,submitting:!1,error:null}}var fr=xe()(e=>({editing:{kind:`list`},editorForm:dr(ur),setEditing:t=>e({editing:t}),resetEditorForm:t=>e({editorForm:dr(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}}))})),pr=e=>({customModels:e}),mr=new Set([`claude`,`codex`]);function hr(e){return mr.has(e)}var gr={claude:`Claude`,codex:`Codex`};function _r({models:e,handlers:t,dom:n=Se}){let r=fr(e=>e.editing),i=fr(e=>e.setEditing),a=fr(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:fe(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,G.jsx)(yr,{initial:n,existing:e.map(e=>({id:e.id,provider:e.provider})),handlers:t,onDone:()=>i({kind:`list`})})}return(0,G.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,G.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`h2`,{className:`text-base font-medium`,children:[gr[r],` models`]}),(0,G.jsxs)(M,{size:`sm`,onClick:()=>o({kind:`create`,provider:r}),children:[(0,G.jsx)(rt,{className:`mr-1 h-4 w-4`}),`Add model`]})]}),i.length===0?(0,G.jsx)(Wn,{icon:Ut,message:`No ${gr[r]} models configured.`}):(0,G.jsx)(Gn,{children:i.map(e=>(0,G.jsx)(vr,{model:e,onEdit:()=>o({kind:`edit`,id:e.id}),onDelete:t.onDelete,dom:n},e.id))})]},r)})})}function vr({model:e,onEdit:t,onDelete:n,dom:r}){let i=z(`models.delete`,e.provider,e.id),a=L(i),o=(0,W.useCallback)(()=>{r.confirmDialog(`Delete model "${e.label}"?`)&&I(i,()=>n(e.id))},[i,r,e.id,e.label,n]);return(0,G.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-3`,"aria-busy":a||void 0,children:[(0,G.jsxs)(`div`,{className:`flex flex-col`,children:[(0,G.jsx)(`span`,{className:`font-medium`,children:e.label}),(0,G.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:e.id})]}),(0,G.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(e.supportedEfforts?.length??0)>0&&(0,G.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-xs`,children:`effort`}),e.supportedEfforts?.includes(`max`)&&(0,G.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-xs`,children:`max`}),(0,G.jsx)(Kn,{label:e.label,onEdit:t,onDelete:o,deletePending:a})]})]})}function yr({initial:e,existing:t,handlers:n,onDone:r}){let i=fr(e=>e.editorForm),a=fr(e=>e.patchEditorForm),o=fr(e=>e.toggleSupportedEffort),s=fr(e=>e.toggleOneMillionContext),c=(0,W.useCallback)(e=>{hr(e)&&a({modelProvider:e})},[a]),{id:l,label:u,modelProvider:d,supportedEfforts:f,offersOneMillionContext:p,submitting:m,error:h}=i,g=p?y:y.filter(e=>e.id===`200k`),_=e!==null,v=(0,W.useMemo)(()=>!_&&t.some(e=>e.id===l.trim()&&e.provider===d),[t,l,_,d]),b=l.trim().length>0&&u.trim().length>0&&!v&&!m,S=()=>Zn({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`}),C=Qn({submitting:m,isEdit:_,addLabel:`Add model`});return(0,G.jsxs)(`div`,{className:`flex flex-col gap-4 px-6 py-6`,children:[(0,G.jsx)(`h2`,{className:`text-base font-medium`,children:_?`Edit model`:`Add model`}),(0,G.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium`,children:`Provider`}),(0,G.jsxs)(We,{value:d,onValueChange:c,disabled:_,children:[(0,G.jsx)(Be,{className:`min-w-[180px]`,children:(0,G.jsx)(He,{})}),(0,G.jsxs)(Ve,{children:[(0,G.jsx)(B,{value:`claude`,children:`Claude`}),(0,G.jsx)(B,{value:`codex`,children:`Codex`})]})]})]}),(0,G.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium`,children:`Model ID`}),(0,G.jsx)(H,{value:l,onChange:e=>a({id:e.target.value}),placeholder:`claude-opus-4-9`,disabled:_,className:`font-mono`}),v&&(0,G.jsx)(`span`,{className:`text-xs text-red-600`,children:`A model with this id already exists.`})]}),(0,G.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium`,children:`Label`}),(0,G.jsx)(H,{value:u,onChange:e=>a({label:e.target.value}),placeholder:`Opus 4.9`})]}),d===`claude`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium`,children:`Supported effort levels`}),x.map(e=>(0,G.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-2 text-sm`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:f.includes(e.id),onChange:()=>o(e.id)}),(0,G.jsx)(`span`,{children:e.label})]},e.id))]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium`,children:`Context window`}),(0,G.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-2 text-sm`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:p,onChange:s}),(0,G.jsx)(`span`,{children:`Offer the 1M context window`})]}),(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Off means every turn on this model runs on the 200k window.`})]})]}),h&&(0,G.jsx)(`span`,{className:`text-xs text-red-600`,children:h}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(M,{onClick:()=>{I(z(`models.save`,e?.id??`new`),S)},pending:m,disabled:!b,children:C}),(0,G.jsx)(M,{variant:`ghost`,onClick:r,disabled:m,children:`Cancel`})]})]})}function br(e){let t=U(St),n=Xn(pr,e.state);return(0,G.jsx)(_r,{models:t,handlers:n})}function xr(e,t){return{shortcut:e,expansion:t,submitting:!1,error:null}}var Sr=xe()(e=>({editing:{kind:`list`},editorForm:xr(``,``),setEditing:t=>e({editing:t}),resetEditorForm:(t,n)=>e({editorForm:xr(t,n)}),patchEditorForm:t=>e(e=>({editorForm:{...e.editorForm,...t}}))})),Cr=e=>({textSnippets:e}),wr=/^\S{1,32}$/;function Tr({snippets:e,handlers:t,dom:n=Se}){let r=Sr(e=>e.editing),i=Sr(e=>e.setEditing),a=Sr(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,G.jsx)(Dr,{initial:n,existing:e.map(e=>({id:e.id,shortcut:e.shortcut})),handlers:t,onDone:()=>i({kind:`list`})})}return(0,G.jsxs)(`div`,{className:`flex flex-col gap-4 px-6 py-6`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(`h2`,{className:`text-base font-medium`,children:`Text snippets`}),(0,G.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,G.jsxs)(M,{size:`sm`,onClick:()=>o({kind:`create`}),children:[(0,G.jsx)(rt,{className:`mr-1 h-4 w-4`}),`Add snippet`]})]}),e.length===0?(0,G.jsx)(Wn,{icon:cn,message:`No snippets yet. Add one to expand a shortcut with Tab.`}):(0,G.jsx)(Gn,{children:e.map(e=>(0,G.jsx)(Er,{snippet:e,onEdit:()=>o({kind:`edit`,id:e.id}),onDelete:t.onDelete,dom:n},e.id))})]})}function Er({snippet:e,onEdit:t,onDelete:n,dom:r}){let i=z(`textSnippets.delete`,e.id),a=L(i),o=(0,W.useCallback)(()=>{r.confirmDialog(`Delete snippet "${e.shortcut}"?`)&&I(i,()=>n(e.id))},[i,r,n,e.id,e.shortcut]);return(0,G.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-3`,"aria-busy":a||void 0,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,G.jsx)(`span`,{className:`font-mono text-sm`,children:e.shortcut}),(0,G.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e.expansion})]}),(0,G.jsx)(`div`,{className:`ml-auto flex items-center gap-2`,children:(0,G.jsx)(Kn,{label:e.shortcut,onEdit:t,onDelete:o,deletePending:a})})]})}function Dr({initial:e,existing:t,handlers:n,onDone:r}){let i=Sr(e=>e.editorForm),a=Sr(e=>e.patchEditorForm),{shortcut:o,expansion:s,submitting:c,error:l}=i,u=e!==null,d=o.trim(),f=wr.test(d),p=(0,W.useMemo)(()=>t.some(t=>t.shortcut===d&&t.id!==e?.id),[t,d,e?.id]),m=f&&!p&&s.length>0&&!c,h=()=>Zn({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=Qn({submitting:c,isEdit:u,addLabel:`Add snippet`});return(0,G.jsxs)(`div`,{className:`flex flex-col gap-4 px-6 py-6`,children:[(0,G.jsx)(`h2`,{className:`text-base font-medium`,children:u?`Edit snippet`:`Add snippet`}),(0,G.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium`,children:`Shortcut`}),(0,G.jsx)(H,{value:o,onChange:e=>a({shortcut:e.target.value}),placeholder:`pgm`,className:`font-mono`,autoFocus:!0}),o.length>0&&!f&&(0,G.jsx)(`span`,{className:`text-xs text-destructive`,children:`Shortcut must be 1-32 characters with no spaces.`}),p&&(0,G.jsx)(`span`,{className:`text-xs text-destructive`,children:`A snippet with this shortcut already exists.`})]}),(0,G.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium`,children:`Expands to`}),(0,G.jsx)(Ke,{value:s,onChange:e=>a({expansion:e.target.value}),placeholder:`pull request green then merge`,rows:4})]}),l&&(0,G.jsx)(`span`,{className:`text-xs text-destructive`,children:l}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(M,{onClick:()=>{I(z(`textSnippets.save`,e?.id??`new`),h)},pending:c,disabled:!m,children:g}),(0,G.jsx)(M,{variant:`ghost`,onClick:r,disabled:c,children:`Cancel`})]})]})}function Or(e){let t=U(Et),n=Xn(Cr,e.state);return(0,G.jsx)(Tr,{snippets:t,handlers:n})}function kr(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 $=xe()(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 Ar(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 jr({entry:e,now:t}){if(e.status===`active`)return(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,G.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:Ar(e.limitedUntil-t);return(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-amber-600 dark:text-amber-400`,children:[(0,G.jsx)(`span`,{className:`size-1.5 rounded-full bg-amber-500`,"aria-hidden":`true`}),`Limited`,n!==null&&(0,G.jsxs)(G.Fragment,{children:[` `,`(`,(0,G.jsx)(`span`,{className:`tabular-nums`,children:n}),`)`]})]})}if(e.status===`disabled`)return(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-muted-foreground/60`,children:[(0,G.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/30`,"aria-hidden":`true`}),`Disabled`]});let n=e.lastErrorMessage??`Unknown error`;return(0,G.jsx)(mt,{children:(0,G.jsxs)(dt,{children:[(0,G.jsx)(ft,{asChild:!0,children:(0,G.jsxs)(`span`,{className:`inline-flex cursor-default items-center gap-1.5 text-xs text-destructive`,children:[(0,G.jsx)(`span`,{className:`size-1.5 rounded-full bg-destructive`,"aria-hidden":`true`}),`Error`,(0,G.jsx)(`span`,{className:`sr-only`,children:n})]})}),(0,G.jsx)(pt,{"aria-hidden":`true`,children:n})]})})}function Mr({entry:e,now:t,isCurrent:n,concurrencyDefault:r,onRemove:i,onToggleDisabled:a,onTest:o,onChangeMaxConcurrent:c,onChangeBaseUrl:l,ports:u}){let d=u?.timer??lt,f=$(e=>e.tokenRowStates),p=$(e=>e.setTokenRowTesting),m=$(e=>e.setTokenRowTestResult),h=$(e=>e.baseUrlDrafts),g=$(e=>e.setBaseUrlDraft),_=f[e.id],v=_?.testResult??null,y=_?.testing??!1,b=h[e.id]??e.baseUrl??``,x=b.trim().length>0&&s(b)===null,S=z(`oauthPool.remove`,e.id),C=z(`oauthPool.toggle`,e.id),w=z(`oauthPool.concurrency`,e.id),T=z(`oauthPool.baseUrl`,e.id),ee=z(`oauthPool.test`,e.id),E=L(S),D=L(C),O=L(w),k=L(T),A=()=>I(T,()=>l(e.id,b)),te=e=>{e.key===`Enter`&&e.currentTarget.blur()},ne=async()=>{p(e.id,!0),m(e.id,null);try{let t=await o(e.token,e.baseUrl),n=t.ok?`OK`:t.error??`Error`;m(e.id,n),d.setTimeout(()=>m(e.id,null),3e3)}catch{m(e.id,`Error`),d.setTimeout(()=>m(e.id,null),3e3)}finally{p(e.id,!1)}},j=e.status===`disabled`,re=j?rn:tn,ie=e.maxConcurrent??r;return(0,G.jsxs)(`div`,{className:`border-t border-border py-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium ${j?`text-muted-foreground/60`:`text-foreground`}`,children:e.label}),(0,G.jsx)(`code`,{className:`text-xs font-mono text-muted-foreground`,children:kr(e.token)}),n&&(0,G.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,G.jsx)(`div`,{className:`mt-0.5`,children:(0,G.jsx)(jr,{entry:e,now:t})})]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,G.jsx)($e,{label:`Maximum concurrent chats sharing this OAuth token. Higher = risks Anthropic rate limits.`,children:(0,G.jsxs)(`label`,{className:`inline-flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,G.jsx)(`span`,{children:`Concurrent`}),O?(0,G.jsx)(R,{className:`size-3`}):null,(0,G.jsx)(H,{type:`number`,value:ie,readOnly:O,"aria-busy":O||void 0,onChange:t=>I(w,()=>c(e.id,ge(Number(t.target.value)))),min:1,"aria-label":`Max concurrent chats`,className:`h-7 w-14 text-xs`,disabled:j})]})}),v!==null&&(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:v}),(0,G.jsxs)(`button`,{type:`button`,"aria-label":`Test`,onClick:()=>I(ee,ne),disabled:y||j,"aria-busy":y||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:[y?(0,G.jsx)(R,{className:`size-3`}):(0,G.jsx)(Gt,{className:`size-3`,"aria-hidden":`true`}),`Test`]}),(0,G.jsx)(mt,{children:(0,G.jsxs)(dt,{children:[(0,G.jsx)(ft,{asChild:!0,children:(0,G.jsxs)(`button`,{type:`button`,"aria-label":j?`Enable`:`Disable`,onClick:()=>I(C,a),disabled:D,"aria-busy":D||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:[D?(0,G.jsx)(R,{}):(0,G.jsx)(re,{"aria-hidden":`true`,className:`size-3.5`}),(0,G.jsx)(`span`,{className:`sr-only`,children:j?`Enable`:`Disable`})]})}),(0,G.jsx)(pt,{children:j?`Enable`:`Disable`})]})}),(0,G.jsxs)(`button`,{type:`button`,"aria-label":`Remove`,onClick:()=>I(S,i),disabled:E,"aria-busy":E||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:[E?(0,G.jsx)(R,{}):(0,G.jsx)(me,{className:`size-3.5`,"aria-hidden":`true`}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Remove`})]})]})]}),(0,G.jsx)($e,{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,G.jsxs)(`label`,{className:`mt-2 flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,G.jsx)(`span`,{className:`shrink-0`,children:`Base URL`}),k?(0,G.jsx)(R,{className:`size-3`}):null,(0,G.jsx)(H,{value:b,readOnly:k,"aria-busy":k||void 0,onChange:t=>g(e.id,t.target.value),onBlur:A,onKeyDown:te,placeholder:`(default)`,maxLength:512,"aria-label":`Anthropic base URL for ${e.label}`,className:`h-7 flex-1 text-xs font-mono`,disabled:j})]})}),x&&(0,G.jsx)(`div`,{className:`mt-1 text-xs text-destructive`,children:`Must start with http:// or https://`})]})}function Nr({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),c=$(e=>e.setAddToken),l=$(e=>e.setAddBaseUrl),u=$(e=>e.setAddSubmitting),d=$(e=>e.resetAddForm),f=s(i),p=i.trim().length>0&&f===null,m=n.trim().length>0&&r.trim().length>0&&!p&&!a,h=async()=>{if(m){u(!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(),...f===null?{}:{baseUrl:f}};await t({tokens:[...e,i]}),d()}finally{u(!1)}}};return(0,G.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-end sm:gap-3`,children:[(0,G.jsx)(`div`,{className:`flex-1`,children:(0,G.jsx)(H,{value:n,onChange:e=>o(e.target.value),placeholder:`e.g. personal`,maxLength:64,className:`text-sm`,"aria-label":`Token label`})}),(0,G.jsx)(`div`,{className:`flex-[2]`,children:(0,G.jsx)(H,{value:r,onChange:e=>c(e.target.value),type:`password`,placeholder:`sk-ant-...`,maxLength:1024,className:`text-sm font-mono`,"aria-label":`OAuth token`})}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>I(`oauthPool.add`,h),disabled:!m,"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,G.jsx)(R,{}):null,`Add token`]})]}),(0,G.jsxs)(`div`,{className:`mt-2`,children:[(0,G.jsx)(H,{value:i,onChange:e=>l(e.target.value),placeholder:`Base URL — leave empty for api.anthropic.com`,maxLength:512,className:`text-sm font-mono`,"aria-label":`Anthropic base URL`}),p&&(0,G.jsx)(`div`,{className:`mt-1 text-xs text-destructive`,children:`Must start with http:// or https://`})]})]})}function Pr({tokens:e,concurrencyDefault:t,onWrite:n,onTest:r,now:i,ports:a}){let o=i??Date.now(),c=$(e=>e.clearBaseUrlDraft),l=e.reduce((e,t)=>t.lastUsedAt!==null&&(e===null||t.lastUsedAt>(e.lastUsedAt??0))?t:e,null)?.id??null,u=t=>n({tokens:e.filter(e=>e.id!==t)}),d=t=>n({tokens:e.map(e=>e.id===t?{...e,status:e.status===`disabled`?`active`:`disabled`}:e)}),f=(t,r)=>n({tokens:e.map(e=>e.id===t?{...e,maxConcurrent:r}:e)}),p=async(t,r)=>{let i=e.find(e=>e.id===t);if(!i)return;let a=s(r);a===null&&r.trim().length>0||(c(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}})}))},m=L(`oauthPool.concurrencyDefault`),h=e=>{I(`oauthPool.concurrencyDefault`,()=>n({concurrencyDefault:ge(e)}))};return(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 pb-3`,children:[(0,G.jsx)($e,{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,G.jsxs)(`label`,{className:`flex flex-col gap-0.5 text-sm`,children:[(0,G.jsx)(`span`,{className:`font-medium text-foreground`,children:`Default concurrency per token`}),(0,G.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Cap for tokens without an explicit per-row override. Minimum `,1,`, no upper limit.`]})]})}),m?(0,G.jsx)(R,{className:`ml-auto text-muted-foreground`}):null,(0,G.jsx)(H,{type:`number`,value:t,readOnly:m,"aria-busy":m||void 0,onChange:e=>h(Number(e.target.value)),min:1,"aria-label":`Default concurrency per token`,className:`h-8 w-16 text-sm`})]}),e.map(e=>(0,G.jsx)(Mr,{entry:e,now:o,isCurrent:e.id===l,concurrencyDefault:t,onRemove:()=>u(e.id),onToggleDisabled:()=>d(e.id),onTest:r,onChangeMaxConcurrent:f,onChangeBaseUrl:p,ports:a},e.id)),(0,G.jsx)(Nr,{tokens:e,onWrite:n})]})}function Fr(e,t){e.key===`Enter`&&(t(),e.currentTarget.blur())}function Ir(e){let t={};for(let n of S)t[n]=de(e[n]??``);return{...A,...t}}function Lr(e){return z(`settings.writeKeybindings`,e)}function Rr({action:e,currentValue:t,bordered:n,onDraftChange:r,onCommit:i,onRestoreDefault:a}){let o=Lr(e),s=L(o),c=v(A[e]),l=t!==c,u=()=>{I(o,i)};return(0,G.jsx)(Q,{title:h[e],description:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{children:`Comma-separated shortcuts.`}),l?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{children:` `}),(0,G.jsxs)(`button`,{type:`button`,disabled:s,"aria-busy":s||void 0,onClick:()=>{I(o,()=>a(e))},className:`inline rounded text-foreground hover:text-foreground/80 disabled:opacity-60`,children:[`Restore: `,c]})]}):null]}),bordered:n,children:(0,G.jsxs)(`div`,{className:`flex min-w-0 max-w-[420px] flex-1 items-center gap-2`,children:[(0,G.jsx)(H,{type:`text`,value:t,"aria-busy":s||void 0,onChange:t=>r(e,t.target.value),onBlur:u,onKeyDown:e=>Fr(e,u),className:`font-mono`}),s?(0,G.jsx)(R,{}):null]})})}function zr({state:e}){let t=T(e=>e.keybindingDrafts),n=T(e=>e.setKeybindingDrafts),r=T(e=>e.setKeybindingDraft),i=T(e=>e.keybindingsError),a=T(e=>e.setKeybindingsError),o=(0,W.useMemo)(()=>u(e.keybindings),[e.keybindings]);(0,W.useEffect)(()=>{n(Object.fromEntries(S.map(e=>[e,v(o.bindings[e])])))},[o,n]);async function s(t){try{a(null),await e.socket.command({type:`settings.writeKeybindings`,bindings:Ir(t)})}catch(e){a(e instanceof Error?e.message:`Unable to save keybindings.`)}}async function c(){await s(t)}async function l(e){let r={...t,[e]:v(A[e])};n(r),await s(r)}return(0,G.jsxs)(`div`,{className:`border-b border-border`,children:[i?(0,G.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,G.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,G.jsx)(Rr,{action:e,currentValue:t[e]??``,bordered:n!==0,onDraftChange:r,onCommit:c,onRestoreDefault:l},e))]})}var Br=`always`,Vr=`funk`,Hr=[{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 Ur(e){switch(e){case`never`:case`unfocused`:case`always`:return e;default:return Br}}function Wr(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 Vr}}var Gr=xe()(e=>({chatSoundPreference:Br,chatSoundId:Vr,setChatSoundPreference:t=>e({chatSoundPreference:Ur(t)}),setChatSoundId:t=>e({chatSoundId:Wr(t)})})),Kr=`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`,qr=`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`,Jr=`rounded bg-muted px-1 py-0.5 font-mono text-12 text-foreground`,Yr=`text-xs font-medium tracking-wide text-muted-foreground`,Xr=`gap-1.5 disabled:cursor-default disabled:opacity-60`,Zr=`push.enable`,Qr=`push.test`,$r=`push.disable`,ei=`push.contactSubject`;async function ti(e){try{await e(),Ye.getState().setCommandError(null)}catch(e){Ye.getState().setCommandError(Ce(e))}}function ni(e,t){I(e,()=>ti(t))}function ri({pendingKey:e,onRun:t,className:n,label:r,children:i}){let a=L(e);return(0,G.jsxs)(`button`,{type:`button`,onClick:()=>ni(e,t),disabled:a,"aria-busy":a||void 0,"aria-label":r,className:N(n,Xr),children:[a?(0,G.jsx)(R,{}):null,i]})}function ii({localPath:e,muted:t,onMuteToggle:n}){let r=z(`push.setProjectMute`,e),i=L(r);return(0,G.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,G.jsx)(`input`,{type:`checkbox`,checked:!t,disabled:i,onChange:t=>ni(r,()=>n(e,!t.target.checked)),className:`h-4 w-4 shrink-0 rounded border-border accent-foreground`}),(0,G.jsx)(Xe,{inline:!0,className:`min-w-0 flex-1 font-mono text-12 text-foreground`,tooltip:e,children:e}),i?(0,G.jsx)(R,{className:`text-muted-foreground`}):null]})}function ai(e){let{permissionState:t}=e,n=L(ei);if(t===`unsupported`)return(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Push notifications are not supported in this browser.`});if(t===`insecure-context`)return(0,G.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Push requires HTTPS. Run `,(0,G.jsx)(`code`,{className:Jr,children:`kanna --share`}),` or open Kanna over a tunnel, then enable on this device.`]});if(t===`denied`)return(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`You blocked notifications for this site. Re-enable them in your browser settings, then reload.`});if(!(t===`granted`&&e.config.devices.some(t=>t.id===e.currentDeviceId)))return(0,G.jsx)(ri,{pendingKey:Zr,onRun:e.onEnable,className:qr,children:`Enable on this device`});let r=new Set(e.config.preferences.mutedProjectPaths),i=e.contactSubjectDraft.trim(),a=un(i),o=i!==e.contactSubject,s=()=>{a&&o&&ni(ei,()=>e.onContactSubjectSave(i))};return(0,G.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col gap-5 md:w-[440px]`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.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,G.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-emerald-500`,"aria-hidden":!0}),`Enabled on this device`]}),(0,G.jsx)(ri,{pendingKey:Qr,onRun:e.onTest,className:Kr,children:`Send test`}),(0,G.jsx)(ri,{pendingKey:$r,onRun:e.onDisable,className:Kr,children:`Disable`})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,G.jsxs)(`div`,{className:N(Yr,`flex items-center gap-1.5`),children:[`Contact for delivery`,n?(0,G.jsx)(R,{}):null]}),(0,G.jsx)(H,{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:N(`font-mono`,i!==``&&!a&&`border-destructive`)}),i!==``&&!a?(0,G.jsxs)(`p`,{className:`text-xs text-destructive`,children:[`Must be a `,(0,G.jsx)(`code`,{className:Jr,children:`mailto:`}),` address or`,` `,(0,G.jsx)(`code`,{className:Jr,children:`https:`}),` URL with a routable domain (not localhost).`]}):(0,G.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Push services require a contact `,(0,G.jsx)(`code`,{className:Jr,children:`mailto:`}),` or`,` `,(0,G.jsx)(`code`,{className:Jr,children:`https:`}),` URL to sign notifications. Set your own so delivery isn’t rejected.`]})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,G.jsx)(`div`,{className:Yr,children:`Devices`}),(0,G.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:e.config.devices.map(t=>(0,G.jsxs)(`li`,{className:`flex items-start justify-between gap-3 rounded-lg border border-border bg-card/40 px-3 py-2`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,G.jsx)(`span`,{className:`truncate text-sm font-medium text-foreground`,children:t.label}),(0,G.jsx)(`span`,{className:`line-clamp-2 break-all text-xs leading-snug text-muted-foreground`,children:t.userAgent})]}),!t.isCurrentDevice&&(0,G.jsx)(ri,{pendingKey:z(`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,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,G.jsx)(`div`,{className:Yr,children:`Per-project`}),(0,G.jsx)(`ul`,{className:`flex flex-col`,children:e.projects.map(t=>(0,G.jsx)(`li`,{children:(0,G.jsx)(ii,{localPath:t.localPath,muted:r.has(t.localPath),onMuteToggle:e.onMuteToggle})},t.localPath))})]}),(0,G.jsxs)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:[`Phone setup: this page must be reachable over HTTPS. Run`,` `,(0,G.jsx)(`code`,{className:Jr,children:`kanna --share`}),` or open Kanna over your tunnel on the phone, then enable on that device.`]})]})}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`},si=z(`packages.checkUpdates`);function ci(e){return z(`packages.update`,e)}async function li(e,t){try{await e.command(t),Ye.getState().setCommandError(null)}catch(e){throw Ye.getState().setCommandError(Ce(e)),e}}var ui=[],di=[],fi=[],pi=[];function mi(e){return typeof e==`object`&&!!e&&`packages`in e&&`errors`in e}var hi={up_to_date:`Up to date`,outdated:`Outdated`,partial:`Partial`,unknown:`Unknown`};function gi({pkg:e,packageEntry:t,applying:n,onUpdate:r}){let i=L(ci(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,G.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,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:e.name}),s?(0,G.jsx)(`div`,{className:`font-mono tabular-nums text-xs text-muted-foreground/70`,children:s}):null]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2`,children:[c?(0,G.jsx)(`span`,{className:N(`rounded-full border px-2 py-0.5 text-xs font-medium`,c),children:hi[o]}):null,o===`outdated`||o===`partial`?(0,G.jsxs)(M,{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,G.jsx)(P,{className:`mr-1 h-3 w-3 animate-spin`}):null,`Update`]}):null,e.sourceUrl?(0,G.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,G.jsx)(qe,{className:`h-4 w-4`})}):null]})]})}function _i({source:e,packages:t,updateEntries:n,applying:r,isChecking:i,onCheckUpdates:a,onUpdate:o}){return(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsx)(`div`,{className:`text-xs font-medium tracking-wide text-muted-foreground`,children:e}),(0,G.jsxs)(M,{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,G.jsx)(P,{className:`mr-1 h-3 w-3 animate-spin`}):(0,G.jsx)(Fe,{className:`mr-1 h-3 w-3`}),`Refresh`]})]}),(0,G.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,G.jsx)(gi,{pkg:e,packageEntry:t,applying:r.includes(e.id),onUpdate:()=>o(e.id)},e.id)})})]})}function vi({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,G.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,G.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/30 p-3 text-sm text-muted-foreground`,children:[`No `,e,` plugins installed.`]}):(0,G.jsx)(`div`,{className:`flex flex-col gap-4`,children:[...d.entries()].map(([e,t])=>(0,G.jsx)(_i,{source:e,packages:t,updateEntries:i,applying:a,isChecking:o,onCheckUpdates:s,onUpdate:c},e))}),(0,G.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,G.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:e}),p]})}function yi({state:e}){let{socket:t,connectionStatus:n}=e,r=T(e=>e.pluginInventory),i=T(e=>e.pluginInventoryLoading),a=T(e=>e.pluginInventoryError),o=T(e=>e.setPluginInventory),s=T(e=>e.setPluginInventoryLoading),c=T(e=>e.setPluginInventoryError),l=T(e=>e.packageUpdateSnapshot),u=(0,W.useCallback)(async()=>{if(n!==`connected`){o(null),c(null),s(!1);return}try{s(!0),c(null);let e=await t.command({type:`packages.listInstalled`});if(!mi(e))throw Error(`packages.listInstalled: unexpected response`);o(e)}catch(e){c(e instanceof Error?e.message:`Unable to load plugins.`)}finally{s(!1)}},[n,t,o,s,c]);(0,W.useEffect)(()=>{Ot(`packages.listInstalled`,u())},[u]);let d=(0,W.useCallback)(()=>{I(si,()=>li(t,{type:`packages.checkUpdates`}))},[t]),f=(0,W.useCallback)(e=>{I(ci(e),()=>li(t,{type:`packages.update`,id:e}))},[t]),p=L(si),m=l?.status===`checking`||p,h=l?.applying??pi,g=l?.packages.filter(e=>e.kind===`claude-plugin`||e.kind===`codex-plugin`)??fi,_=r?.packages??ui,v=r?.errors??di;return a?(0,G.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,G.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,G.jsx)(P,{className:`h-3.5 w-3.5 animate-spin`}),`Loading…`]}):(0,G.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,G.jsx)(vi,{label:`Claude Code`,kind:`claude-plugin`,packages:_,errors:v,updateEntries:g,applying:h,isChecking:m,onCheckUpdates:d,onUpdate:f}),(0,G.jsx)(vi,{label:`Codex`,kind:`codex-plugin`,packages:_,errors:v,updateEntries:g,applying:h,isChecking:m,onCheckUpdates:d,onUpdate:f})]})}function bi(e){return e===`openai`?pn:e===`openrouter`?he:``}function xi(e,t){return{...e,provider:t,model:bi(t),baseUrl:t===`custom`?e.baseUrl:``}}function Si(e,t){if(!e.pinnedRef)return null;let n=t.latestVersion;return!n||n===e.pinnedRef?null:n}var Ci={up_to_date:`Up to date`,outdated:`Outdated`,partial:`Partial`,unknown:`Unknown`};function wi(e){if(!e)return null;let t=Si(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 Ti({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=wi(t);return(0,G.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,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:e.name}),(0,G.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.source||`Unknown source`}),c?(0,G.jsx)(`div`,{className:`font-mono tabular-nums text-xs text-muted-foreground/70`,children:c}):null,u?(0,G.jsxs)(`div`,{className:`truncate font-mono tabular-nums text-xs text-muted-foreground/70`,children:[`Pinned `,u]}):null]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2`,children:[l?(0,G.jsx)(`span`,{className:N(`rounded-full border px-2 py-0.5 text-xs font-medium`,l),children:Ci[s]}):null,d?(0,G.jsxs)(M,{type:`button`,size:`sm`,variant:`secondary`,disabled:r,onClick:a,className:`h-6 rounded-full px-2 text-xs`,children:[r?(0,G.jsx)(P,{className:`mr-1 h-3 w-3 animate-spin`}):null,d]}):null,o?(0,G.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,G.jsx)(qe,{className:`h-4 w-4`})}):null,(0,G.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,G.jsx)(P,{className:`h-4 w-4 animate-spin`}):(0,G.jsx)(me,{className:`h-4 w-4`})})]})]})}function Ei(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 Di=z(`packages.checkUpdates`),Oi=z(`packages.updateAll`,`skill`);function ki(e){return`skill:${e}`}function Ai({skill:e,packageEntry:t,uninstalling:n,applying:r,onUninstall:i,onUpdate:a}){let o=ki(e.name),s=L(z(`packages.update`,o)),c=L(z(`skills.uninstall`,e.name));return(0,G.jsx)(Ti,{skill:e,packageEntry:t,uninstalling:n||c,applying:r||s,onUninstall:()=>i(e),onUpdate:()=>a(o)})}function ji({message:e}){return(0,G.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 Mi({skill:e,installing:t,installed:n,message:r,onInstall:i}){let a;return a=n?`Installed`:t?`Installing`:`Get`,(0,G.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,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:e.name}),(0,G.jsxs)(`div`,{className:`truncate text-xs text-muted-foreground`,children:[e.source,` · `,Ei(e.installs)]}),n&&r?(0,G.jsx)(`div`,{className:`mt-1 truncate text-xs text-emerald-500`,children:r}):null]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,G.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,G.jsx)(qe,{className:`h-4 w-4`})}),(0,G.jsxs)(M,{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,G.jsx)(P,{className:`mr-1.5 h-3.5 w-3.5 animate-spin`}):null,a]})]})]})}function Ni({state:e,ports:t}){let n=t?.timer??lt,r=e.socket,i=e.connectionStatus,a=T(e=>e.skillQuery),o=T(e=>e.setSkillQuery),s=T(e=>e.skillResults),c=T(e=>e.setSkillResults),l=T(e=>e.skillSearchLoading),u=T(e=>e.setSkillSearchLoading),d=T(e=>e.skillSearchError),f=T(e=>e.setSkillSearchError),p=T(e=>e.installedSkills),m=T(e=>e.setInstalledSkills),h=T(e=>e.installedSkillIds),g=T(e=>e.setInstalledSkillIds),_=T(e=>e.addInstalledSkillId),v=T(e=>e.removeInstalledSkillId),y=T(e=>e.installedLoading),b=T(e=>e.setInstalledLoading),x=T(e=>e.installedError),S=T(e=>e.setInstalledError),C=T(e=>e.skillOperationError),w=T(e=>e.setSkillOperationError),ee=T(e=>e.installingSkillId),E=T(e=>e.setInstallingSkillId),D=T(e=>e.uninstallingSkillId),O=T(e=>e.setUninstallingSkillId),k=T(e=>e.installMessages),A=T(e=>e.setInstallMessage),te=T(e=>e.clearInstallMessage),ne=T(e=>e.clearInstallMessagesForSkill),j=T(e=>e.packageUpdateSnapshot),re=j?.status===`checking`,ie=j?.packages.filter(e=>e.kind===`skill`&&!e.pinnedRef).filter(e=>e.update.availability===`outdated`||e.update.availability===`partial`).map(e=>e.id)??[],ae=ie.length,oe=j?.lastCheckedAt?new Date(j.lastCheckedAt).toLocaleTimeString():null,se=L(Di),ce=L(Oi),le=re||se;async function ue(e){try{w(null),await r.command(e)}catch(e){throw w(Ce(e)),e}}function de(){I(Di,()=>ue({type:`packages.checkUpdates`}))}function fe(e){I(z(`packages.update`,e),()=>ue({type:`packages.update`,id:e}))}function pe(){ie.length!==0&&I(Oi,()=>ue({type:`packages.updateAll`,ids:ie}))}function me(e){I(z(`skills.install`,e.id),()=>_e(e))}function he(e){I(z(`skills.uninstall`,e.name),()=>ve(e))}let ge=(0,W.useCallback)(async()=>{if(i!==`connected`){m([]),g(new Set),S(null),b(!1);return}try{b(!0),S(null);let e=await r.command({type:`skills.listInstalled`});m(e.skills),g(new Set(e.skills.map(e=>e.name)))}catch(e){m([]),g(new Set),S(e instanceof Error?e.message:`Unable to read installed skills.`)}finally{b(!1)}},[i,r,m,g,S,b]);(0,W.useEffect)(()=>{Ot(`skills.listInstalled`,ge())},[i,ge,r]),(0,W.useEffect)(()=>{let e=a.trim();if(e.length<2){c([]),f(null),u(!1);return}if(i!==`connected`){c([]),u(!1),f(`Backend connection required.`);return}let t=!1;u(!0),f(null);let o=n.setTimeout(()=>{r.command({type:`skills.search`,query:e,limit:100}).then(e=>{t||c(e.skills)}).catch(e=>{t||(c([]),f(e instanceof Error?e.message:`Unable to search skills.`))}).finally(()=>{t||u(!1)})},250);return()=>{t=!0,n.clearTimeout(o)}},[i,a,r,c,f,u,n]);async function _e(e){if(i!==`connected`){w(`Backend connection required.`);return}try{E(e.id),w(null),te(e.id),await r.command({type:`skills.install`,source:e.source,skillId:e.skillId}),_(e.skillId),A(e.id,`Installed globally`),Ot(`skills.listInstalled`,ge())}catch(e){w(e instanceof Error?e.message:`Install failed.`)}finally{E(null)}}async function ve(e){if(i!==`connected`){w(`Backend connection required.`);return}try{O(e.name),w(null),await r.command({type:`skills.uninstall`,skillId:e.name}),m(p.filter(t=>t.name!==e.name)),v(e.name),ne(e.name),Ot(`skills.listInstalled`,ge())}catch(e){w(e instanceof Error?e.message:`Uninstall failed.`)}finally{O(null)}}let ye;return ye=p.length>0?(0,G.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:p.map(e=>(0,G.jsx)(Ai,{skill:e,packageEntry:j?.packages.find(t=>t.kind===`skill`&&t.name===e.name)??null,uninstalling:D===e.name,applying:j?.applying.includes(ki(e.name))??!1,onUninstall:he,onUpdate:fe},`${e.source}/${e.name}`))}):y?null:(0,G.jsx)(`div`,{className:`rounded-lg border border-border bg-card/30 p-3 text-sm text-muted-foreground`,children:`No global skills installed.`}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[C?(0,G.jsx)(ji,{message:C}):null,(0,G.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,G.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:`Installed`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[oe?(0,G.jsxs)(`span`,{className:`tabular-nums text-xs text-muted-foreground`,children:[`Checked `,oe]}):null,ae>0?(0,G.jsxs)(M,{size:`sm`,variant:`secondary`,className:`h-6 rounded-full px-2 text-xs`,pending:ce,onClick:pe,children:[`Update all (`,ae,`)`]}):null,(0,G.jsxs)(M,{size:`sm`,variant:`ghost`,className:`h-6 rounded-full px-2 text-xs`,disabled:le,"aria-busy":le||void 0,onClick:de,children:[le?(0,G.jsx)(P,{className:`mr-1 h-3 w-3 animate-spin`}):null,`Check`]}),y?(0,G.jsx)(P,{className:`h-3.5 w-3.5 animate-spin text-muted-foreground`}):null]})]}),x?(0,G.jsx)(`div`,{className:`text-xs text-destructive`,children:x}):null,ye]}),(0,G.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,G.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:`Discover`}),(0,G.jsxs)(`div`,{className:`flex h-10 items-center gap-2 rounded-lg border border-border bg-card/30 px-3`,children:[(0,G.jsx)(Pe,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,G.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,G.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,G.jsx)(it,{className:`h-3.5 w-3.5`})}):null,l?(0,G.jsx)(P,{className:`h-4 w-4 shrink-0 animate-spin text-muted-foreground`}):null]}),d?(0,G.jsx)(`div`,{className:`text-xs text-destructive`,children:d}):null,(0,G.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:s.map(e=>(0,G.jsx)(Mi,{skill:e,installing:ee===e.id,installed:h.has(e.skillId),message:k[e.id],onInstall:()=>{me(e)}},e.id))}),!l&&!d&&a.trim().length>=2&&s.length===0?(0,G.jsx)(`div`,{className:`rounded-lg border border-border bg-card/30 p-3 text-sm text-muted-foreground`,children:`No skills found.`}):null]})]})}function Pi(e){return e.map(e=>({...e,disabled:!0}))}function Fi({pendingKey:e,value:t,onValueChange:n,options:r,size:i}){let a=L(e);return(0,G.jsxs)(`div`,{className:`inline-flex items-center gap-2`,"aria-busy":a||void 0,children:[a?(0,G.jsx)(R,{className:`text-muted-foreground`}):null,(0,G.jsx)(ht,{value:t,onValueChange:t=>I(e,()=>n(t)),options:a?Pi(r):r,size:i})]})}function Ii(e){return{async onReload(t){if(!(await e(`/api/plugins/${t}/reload`,{})).ok)throw Error(`Failed to reload plugin ${t}`)}}}function Li({plugins:e,handlers:t}){return e.length===0?(0,G.jsx)(Wn,{icon:C,message:`No plugins installed yet.`}):(0,G.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:`Plugins`}),(0,G.jsx)(Gn,{children:e.map(e=>(0,G.jsx)(Ri,{plugin:e,onReload:t.onReload},e.id))})]})}function Ri({plugin:e,onReload:t}){let n=z(`plugins.reload`,e.id),r=L(n),i=(0,W.useCallback)(()=>{I(n,async()=>{try{await t(e.id),Ye.getState().setCommandError(null)}catch(e){throw Ye.getState().setCommandError(Ce(e)),e}})},[t,e.id,n]);return(0,G.jsxs)(`li`,{className:`flex items-center justify-between gap-3 px-4 py-3`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`truncate text-sm font-medium text-foreground`,children:e.id}),(0,G.jsx)(Mt,{tone:e.enabled?`active`:`muted`,label:e.enabled?`Enabled`:`Disabled`})]}),(0,G.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e.sourceDir})]}),(0,G.jsx)(M,{variant:`ghost`,size:`sm`,"data-testid":`plugin-reload:${e.id}`,pending:r,onClick:i,children:`Reload`})]})}async function zi(e,t){return{ok:(await Le.postJsonBody(e,t)).ok}}var Bi=Ii(zi);function Vi(){let e=U(gt);return(0,G.jsx)(Li,{plugins:e,handlers:Bi})}var Hi=[{id:`general`,label:`General`,icon:Ne,subtitle:`Manage appearance, editor behavior, and embedded terminal defaults.`},{id:`skills`,label:`Skills`,icon:Ft,subtitle:`Manage globally installed agent skills from the active skill lock file.`},{id:`plugins`,label:`Plugins`,icon:$t,subtitle:`View and update globally installed Claude Code and Codex plugins.`},{id:`kanna-plugins`,label:`Kanna plugins`,icon:C,subtitle:`Install local Kanna plugins that contribute UI surfaces and daemon behavior.`},{id:`providers`,label:`Providers`,icon:Yt,subtitle:`Manage the default chat provider and saved model defaults for Claude Code and Codex.`},{id:`models`,label:`Models`,icon:Ut,subtitle:`Add, edit, and remove Claude and Codex models available in the model picker.`},{id:`subagents`,label:`Subagents`,icon:je,subtitle:`Define reusable agent personas. Mention them in chat with @agent/<name>.`},{id:`mcp-servers`,label:`MCP servers`,icon:$t,subtitle:`Install custom MCP servers (stdio, http, sse, ws) and connect-test them.`},{id:`snippets`,label:`Text snippets`,icon:cn,subtitle:`Define shortcuts that expand to full text in the chat composer with Tab.`},{id:`instructions`,label:`Instructions`,icon:Yt,subtitle:`Global instructions appended to every Claude and Codex turn (main + subagents).`},{id:`keybindings`,label:`Keybindings`,icon:Vt,subtitle:`Edit global app shortcuts stored in the active keybindings file.`},{id:`changelog`,label:`Changelog`,icon:Ft,subtitle:`Release notes pulled from the public GitHub releases feed.`}];function Ui(e){return e?Hi.find(t=>t.id===e)?.id??null:null}function Wi(e){return e?Hi:Hi.filter(e=>e.id!==`kanna-plugins`)}var Gi=[{value:`light`,label:`Light`,icon:on},{value:`dark`,label:`Dark`,icon:Zt},{value:`system`,label:`System`,icon:V}],Ki=[{value:`sm`,label:`Small`},{value:`md`,label:`Default`},{value:`lg`,label:`Large`},{value:`xl`,label:`Extra Large`},{value:`xxl`,label:`XX-Large`}],qi=[{value:`never`,label:`Never`},{value:`unfocused`,label:`When Unfocused`},{value:`always`,label:`Always`}],Ji=[{value:`disabled`,label:`Off`},{value:`enabled`,label:`On`}],Yi=[{value:`disabled`,label:`Off`},{value:`enabled`,label:`On`}],Xi=[{value:`always-ask`,label:`Always ask`},{value:`auto-expose`,label:`Auto-expose`}],Zi=[{value:`openai`,label:`OpenAI`},{value:`openrouter`,label:`OpenRouter`},{value:`custom`,label:`Custom`}],Qi=3e5,$i=null;function ea(e){return`Edit global app shortcuts stored in ${e}.`}function ta(e,t){return e!==t}function na(){return $i?Date.now()>=$i.expiresAt?($i=null,null):$i.releases:null}function ra(e){$i={releases:e,expiresAt:Date.now()+Qi}}async function ia(e,t){let n=t?.force?null:na();if(n)return n;let r=await e();return ra(r),r}function aa(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 oa(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 sa=`__redeploy__`,ca=`settings.writeLlmProvider`,la=`appSettings.setCloudflareTunnel`,ua=z(la,`cloudflaredPath`);function da({status:e,releases:t,error:n,onRetry:r,updateSnapshot:i,currentVersion:a,onInstallUpdate:o,onCheckForUpdates:s,onForceReload:c}){let l=L(`update.check`),u=T(e=>e.changelogPendingAction),d=T(e=>e.setChangelogPendingAction),f=i?.latestVersion??t[0]?.tag_name??`Unknown`,p=i?.currentVersion??a,m=i?.status===`checking`||l,h=i?.status===`updating`||i?.status===`restart_pending`,g=h||u!==null,_=i?.updateAvailable===!0,v=f.replace(/^v/i,``),y=p.replace(/^v/i,``),b=(0,W.useCallback)(async e=>{d(e);try{await o(e)}finally{d(null)}},[o,d]),x=(0,W.useCallback)(async()=>{d(sa);try{await c()}finally{d(null)}},[c,d]),S=u===sa||h;return(0,G.jsxs)(`div`,{className:`space-y-4`,children:[e===`loading`||e===`idle`?(0,G.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,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(P,{className:`h-4 w-4 animate-spin`}),(0,G.jsx)(`span`,{children:`Loading release notes…`})]})}):null,e===`error`?(0,G.jsx)(`div`,{className:`rounded-lg border border-destructive/20 bg-destructive/5 px-6 py-5`,children:(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:`Could not load changelog`}),(0,G.jsx)(`div`,{className:`mt-1 text-sm text-muted-foreground`,children:n??`Unable to load changelog.`})]}),(0,G.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,G.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/30 px-6 py-8`,children:[(0,G.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:`No releases yet`}),(0,G.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,G.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(Nt,{variant:`outline`,onClick:()=>I(`update.redeploy`,x),disabled:g,children:S?(0,G.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(P,{className:`h-3.5 w-3.5 animate-spin`}),`Re-deploying…`]}):`Re-deploy`}),(0,G.jsx)(Nt,{variant:`outline`,onClick:()=>I(`update.check`,s),disabled:m||g,children:m?(0,G.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(P,{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===v,r=t===y;return(0,G.jsxs)(`article`,{className:N(`rounded-xl border bg-card/30 pl-6 pr-4 py-4`,n?`border-border bg-muted`:`border-border`),children:[(0,G.jsxs)(`div`,{className:`flex flex-row items-center min-w-0 flex-1 gap-3 `,children:[(0,G.jsxs)(`div`,{className:`flex flex-row items-center min-w-0 flex-1 gap-2 `,children:[(0,G.jsx)(`div`,{className:`text-lg font-semibold tracking-[-0.2px] text-foreground`,children:e.name?.trim()||e.tag_name}),(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2 text-sm text-muted-foreground`,children:[(0,G.jsx)(`span`,{children:oa(e.published_at)}),e.prerelease?(0,G.jsx)(`span`,{className:`rounded-full border border-border px-2.5 py-1 tracking-wide`,children:`Prerelease`}):null]})]}),(0,G.jsxs)(`div`,{className:`flex flex-row items-center justify-end min-w-0 flex-1 gap-2 `,children:[(0,G.jsx)(`a`,{href:e.html_url,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`View release on GitHub`,className:N(Ee({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,G.jsx)(fa,{className:`h-4 w-4`})}),r?(0,G.jsx)(`span`,{className:N(`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&&_||!n&&!r?(()=>{let r=u===e.tag_name||h&&u===null,i;i=n?`Update`:aa(t,y)<0?`Rollback`:`Install`;let a;return a=n?`Updating…`:aa(t,y)<0?`Rolling back…`:`Installing…`,(0,G.jsx)(Nt,{variant:`default`,className:``,onClick:()=>I(z(`update.install`,e.tag_name),()=>b(e.tag_name)),disabled:g,children:(0,G.jsxs)(`div`,{className:`flex flex-row items-center justify-center gap-2`,children:[r?(0,G.jsx)(P,{className:`size-4 animate-spin`}):(0,G.jsx)(zt,{className:`size-4`}),r?a:i]})})})():null]})]}),e.body?.trim()?(0,G.jsx)(`div`,{className:`prose prose-sm mt-5 max-w-none text-foreground dark:prose-invert`,children:Ie(e.body)}):(0,G.jsx)(`div`,{className:`mt-5 text-sm text-muted-foreground`,children:`No release notes were provided.`})]},e.id)}):null]})}function fa({className:e}){return(0,G.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,className:e,children:(0,G.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 pa({checked:e,onChange:t}){return(0,G.jsxs)(`label`,{className:`inline-flex items-center gap-2`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:e,onChange:e=>t(e.target.checked)}),`Enabled`]})}function ma({state:e}){let t=U(e=>e.settings?.globalPromptAppend??``),n=T(e=>e.globalInstructionsDraft),r=T(e=>e.setGlobalInstructionsDraft),i=T(e=>e.globalInstructionsPersistedAtMount),a=T(e=>e.globalInstructionsSaving),o=T(e=>e.setGlobalInstructionsSaving),s=T(e=>e.globalInstructionsError),c=T(e=>e.setGlobalInstructionsError);(0,W.useEffect)(()=>{t!==i&&T.setState({globalInstructionsPersistedAtMount:t,globalInstructionsDraft:t})},[t,i]);let l=n.replace(/\s+$/u,``),u=l.length>k,d=l!==t,f=a||u||!d,p=(0,W.useCallback)(async()=>{if(!f){c(null),o(!0);try{await e.handleWriteAppSettings({globalPromptAppend:l})}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(!1)}}},[f,e,l,c,o]),m;return m=a?`Saving…`:d?`Save`:`Saved`,(0,G.jsx)(`div`,{className:`border-b border-border`,children:(0,G.jsx)(Q,{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,G.jsxs)(`div`,{className:`flex w-full flex-col gap-2 md:w-[420px]`,children:[(0,G.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:N(`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`,u?`border-destructive`:`border-input`),disabled:a}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,G.jsxs)(`span`,{className:u?`text-destructive`:`text-muted-foreground`,children:[l.length,` / `,k,` characters`,u?` — over limit`:``]}),(0,G.jsx)(M,{type:`button`,size:`sm`,onClick:()=>I(`settings.globalInstructions`,p),disabled:f,pending:a,children:m})]}),s?(0,G.jsx)(`div`,{className:`text-xs text-destructive`,children:s}):null]})})})}function ha({ports:e}={}){let t=e?.dom??Se,a=n(),{sectionId:o}=i(),s=r(),{theme:p,setTheme:m}=wt(),h=T(e=>e.changelogStatus),v=T(e=>e.setChangelogStatus),y=T(e=>e.signingOut),x=T(e=>e.setSigningOut),S=T(e=>e.authEnabled),C=T(e=>e.setAuthEnabled),w=T(e=>e.releases),E=T(e=>e.setReleases),D=T(e=>e.changelogError),k=T(e=>e.setChangelogError),A=Ui(o)??`general`,le=U(e=>e.hydrationStatus===`loading`&&e.settings===null),de=s.connectionStatus===`connecting`||!s.localProjectsReady||le,fe=L(ca),pe=L(ie),me=fe||pe,he=L(ua),ge=L(`keybindings.openEditor`),xe=L(`settings.chatSoundPreference`),Ce=L(`settings.chatSoundId`),we=s.localProjects?.machine.displayName??`Unavailable`,F=s.localProjects?.projects.length??0,Ee=be.split(`/`)[1]??`unknown`,Oe=U(_t),je=U(Tt),Ne=U(bt),Pe=U(xt),Fe=c(e=>e.setScrollbackLines),Ie=c(e=>e.setMinColumnWidth),Le=c(e=>e.setEditorPreset),Re=c(e=>e.setEditorCommandTemplate),ze=U(yt),Ke=U(vt),qe=Gr(e=>e.setChatSoundPreference),Ye=Gr(e=>e.setChatSoundId),Xe=s.keybindings,V=U(e=>e.settings),nt=s.llmProvider,rt=ne(e=>e.autoResumeOnRateLimit),it=ne(e=>e.setAutoResumeOnRateLimit),lt=ne(e=>e.typographyOverride),dt=ne(e=>e.clearTypographyOverride),ft=U(e=>e.settings?.typography.scale),pt=_(lt,ft),mt=d(e=>e.defaultProvider),gt=d(e=>e.providerDefaults),Ct=d(e=>e.setDefaultProvider),Et=d(e=>e.setProviderDefaultModel),At=d(e=>e.setProviderDefaultModelOptions),Mt=d(e=>e.setProviderDefaultPlanMode),Pt=U(St),Ft=U(Dt),It=(0,W.useMemo)(()=>j([...oe],Pt),[Pt]),Rt=(0,W.useMemo)(()=>u(Xe),[Xe]).filePathDisplay||Te(),zt=T(e=>e.pushPermissionState),Bt=T(e=>e.setPushPermissionState),Vt=T(e=>e.pushDeviceId),Ht=T(e=>e.setPushDeviceId),Ut=(0,W.useCallback)(async()=>{if(!s.pushConfig)return;let e=await Ge({vapidPublicKey:s.pushConfig.vapidPublicKey,sendToServer:async e=>{let t=await s.socket.command({type:`push.subscribe`,subscription:e.subscription,label:e.label,userAgent:e.userAgent});return Je(t.id),{id:t.id}}});Ht(e)},[s.pushConfig,s.socket,Ht]),Wt=(0,W.useCallback)(async()=>{Vt&&(await Qe({pushDeviceId:Vt,sendToServer:async e=>{await s.socket.command({type:`push.unsubscribe`,pushDeviceId:e})}}),et(),Ht(null))},[Vt,s.socket,Ht]),Gt=T(e=>e.scrollbackDraft),Kt=T(e=>e.setScrollbackDraft),Jt=T(e=>e.minColumnWidthDraft),Yt=T(e=>e.tabMinWidthDraft),Xt=T(e=>e.setMinColumnWidthDraft),Zt=T(e=>e.setTabMinWidthDraft),Qt=V?.panes.tabMinWidth??60,$t=V?.uploads.maxFileSizeMb??dn.maxFileSizeMb,en=T(e=>e.uploadMaxFileSizeDraft),tn=T(e=>e.setUploadMaxFileSizeDraft),nn=Math.round((V?.claudeDriver.lifecycle.idleTimeoutMs??re.idleTimeoutMs)/6e4),rn=V?.claudeDriver.lifecycle.maxConcurrent??re.maxConcurrent,an=T(e=>e.claudeIdleMinutesDraft),on=T(e=>e.setClaudeIdleMinutesDraft),sn=T(e=>e.claudeMaxConcurrentDraft),cn=T(e=>e.setClaudeMaxConcurrentDraft),un=T(e=>e.editorCommandDraft),pn=T(e=>e.setEditorCommandDraft),mn=T(e=>e.appSettingsError),K=T(e=>e.setAppSettingsError),_n=T(e=>e.analyticsDialogOpen),vn=T(e=>e.setAnalyticsDialogOpen),q=T(e=>e.tunnelError),yn=T(e=>e.setTunnelError),bn=T(e=>e.cloudflaredPathDraft),xn=T(e=>e.setCloudflaredPathDraft),Sn=T(e=>e.pushContactSubjectDraft),Cn=T(e=>e.setPushContactSubjectDraft),wn=V?.shareDefaultTtlHours??24,Tn=T(e=>e.shareDefaultTtlDraft),En=T(e=>e.setShareDefaultTtlDraft),J=T(e=>e.llmProviderDraft),Dn=T(e=>e.setLlmProviderDraft),On=T(e=>e.llmProviderError),kn=T(e=>e.setLlmProviderError),Y=T(e=>e.llmValidationStatus),An=T(e=>e.setLlmValidationStatus),jn=T(e=>e.llmValidationError),Nn=T(e=>e.setLlmValidationError),Pn=T(e=>e.llmValidationDialogOpen),Fn=T(e=>e.setLlmValidationDialogOpen),X=s.updateSnapshot,Z=s.handleWriteAppSettings,In=s.handleWriteCloudflareTunnel,Ln=s.handleWriteClaudeAuth,Rn=s.handleTestOAuthToken,zn=s.handleReadLlmProvider,Bn=s.handleWriteLlmProvider,Vn=s.handleValidateLlmProvider,Hn;Hn=X?.status===`checking`?`Checking for updates…`:X?.status===`updating`?`Installing update…`:X?.status===`restart_pending`?`Restarting Kanna…`:X?.status===`available`?`Update available${X.latestVersion?`: ${X.latestVersion}`:``}`:X?.status===`up_to_date`?`Up to date`:X?.status===`error`?`Update check failed`:`Not checked yet`,(0,W.useEffect)(()=>{Kt(String(Oe))},[Oe,Kt]),(0,W.useEffect)(()=>{Xt(String(je))},[je,Xt]),(0,W.useEffect)(()=>{Zt(String(Qt))},[Qt,Zt]),(0,W.useEffect)(()=>{tn(String($t))},[$t,tn]),(0,W.useEffect)(()=>{on(String(nn))},[nn,on]),(0,W.useEffect)(()=>{cn(String(rn))},[rn,cn]),(0,W.useEffect)(()=>t.addWindowListener(`focus`,()=>Bt(Ze().state)),[t,Bt]),(0,W.useEffect)(()=>{pn(Pe)},[Pe,pn]),(0,W.useEffect)(()=>{nt&&Dn({provider:nt.provider,apiKey:nt.apiKey,model:nt.model,baseUrl:nt.baseUrl})},[nt,Dn]),(0,W.useEffect)(()=>{An(`idle`),Nn(null)},[J.provider,J.apiKey,J.model,J.baseUrl,An,Nn]),(0,W.useEffect)(()=>{o&&(Ui(o)||a(`/settings/general`,{replace:!0}))},[a,o]),(0,W.useEffect)(()=>{V&&xn(V.cloudflareTunnel.cloudflaredPath)},[V,xn]),(0,W.useEffect)(()=>{V&&Cn(V.push.contactSubject)},[V,Cn]),(0,W.useEffect)(()=>{let e=!1;return se().then(t=>{e||C(t.enabled===!0)}).catch(()=>{e||C(!1)}),()=>{e=!0}},[C]),(0,W.useEffect)(()=>{A!==`providers`||de||I(ie,zn)},[zn,de,A]);let Un=(0,W.useCallback)(()=>s.socket.command({type:`settings.getChangelog`}),[s.socket]);(0,W.useEffect)(()=>{if(A!==`changelog`||de)return;let e=!1;return v(`loading`),k(null),ia(Un).then(t=>{e||(E(t),v(`success`))}).catch(t=>{e||(k(t instanceof Error?t.message:`Unable to load changelog.`),v(`error`))}),()=>{e=!0}},[de,A,v,k,E,Un]);function Wn(){let e=Number(Gt);if(!Number.isFinite(e)){Kt(String(Oe));return}Fe(e),Z({terminal:{scrollbackLines:e}}).catch(e=>{K(e instanceof Error?e.message:`Unable to save terminal settings.`)})}function Gn(){let e=Number(Jt);if(!Number.isFinite(e)){Xt(String(je));return}Ie(e),Z({terminal:{minColumnWidth:e}}).catch(e=>{K(e instanceof Error?e.message:`Unable to save terminal settings.`)})}function Kn(){let e=Number(Yt);if(!Number.isFinite(e)){Zt(String(Qt));return}Z({panes:{tabMinWidth:ke(e)}}).catch(e=>{K(e instanceof Error?e.message:`Unable to save pane settings.`)})}function qn(){let e=Number(en);if(!Number.isFinite(e)||e<1||e>2048){tn(String($t)),K(`Max file size must be between 1 and ${fn} MB.`);return}if(Math.round(e)===$t){tn(String($t));return}Z({uploads:{maxFileSizeMb:Math.round(e)}}).catch(e=>{K(e instanceof Error?e.message:`Unable to save upload settings.`)})}function Jn(){let e=Number(an),t=Math.round(ue/6e4),n=Math.round(O/6e4);if(!Number.isFinite(e)||e<t||e>n){on(String(nn)),K(`Idle timeout must be between ${t} and ${n} minutes.`);return}if(Math.round(e)===nn){on(String(nn));return}Z({claudeDriver:{lifecycle:{idleTimeoutMs:Math.round(e)*6e4}}}).catch(e=>{K(e instanceof Error?e.message:`Unable to save Claude lifecycle settings.`)})}function Yn(){let e=Number(sn);if(!Number.isFinite(e)||e<1||e>16){cn(String(rn)),K(`Max concurrent sessions must be between 1 and 16.`);return}if(Math.round(e)===rn){cn(String(rn));return}Z({claudeDriver:{lifecycle:{maxConcurrent:Math.round(e)}}}).catch(e=>{K(e instanceof Error?e.message:`Unable to save Claude lifecycle settings.`)})}function Xn(){let e=Number(Tn);if(!Number.isInteger(e)||e<1){En(String(wn)),K(`Default share link expiry must be a whole number of hours >= 1.`);return}if(e===wn){En(String(wn));return}Z({shareDefaultTtlHours:e}).catch(e=>{K(e instanceof Error?e.message:`Unable to save share settings.`)})}function Zn(e,t){e.key===`Enter`&&(t(),e.currentTarget.blur())}function Qn(){Re(un),Z({editor:{commandTemplate:un}}).catch(e=>{K(e instanceof Error?e.message:`Unable to save editor settings.`)})}function $n(e){m(e),Z({theme:e}).catch(e=>{K(e instanceof Error?e.message:`Unable to save theme settings.`)})}function er(e){Z({typography:{scale:e}}).catch(e=>{K(e instanceof Error?e.message:`Unable to save typography settings.`)})}function tr(e){Le(e);let t=e===`custom`?Pe:f(e);Z({editor:{preset:e,commandTemplate:t}}).catch(e=>{K(e instanceof Error?e.message:`Unable to save editor settings.`)})}function nr(e){ta(ze,e)&&(qe(e),I(`settings.chatSoundPreference`,()=>Z({chatSoundPreference:e}).catch(e=>{K(e instanceof Error?e.message:`Unable to save chat sound settings.`)})),Ot(`chat sound preview`,kt(Ke,1)))}function rr(e){ta(Ke,e)&&(Ye(e),I(`settings.chatSoundId`,()=>Z({chatSoundId:e}).catch(e=>{K(e instanceof Error?e.message:`Unable to save chat sound settings.`)})),Ot(`chat sound preview`,kt(e,1)))}async function ir(e){try{K(null),await Z({analyticsEnabled:e===`enabled`})}catch(e){K(e instanceof Error?e.message:`Unable to save analytics settings.`)}}async function ar(e){try{K(null),await Z({telemetry:{enabled:e===`enabled`}})}catch(e){K(e instanceof Error?e.message:`Unable to save telemetry settings.`)}}async function or(e){try{yn(null),await In(e)}catch(e){yn(e instanceof Error?e.message:`Unable to save Cloudflare Tunnel settings.`)}}function sr(e){Ct(e),Z({defaultProvider:e}).catch(e=>{K(e instanceof Error?e.message:`Unable to save provider settings.`)})}function cr(e,t){Et(e,t),Z({providerDefaults:{[e]:{model:t}}}).catch(e=>{K(e instanceof Error?e.message:`Unable to save provider settings.`)})}function ur(e,t){At(e,t),Z({providerDefaults:{[e]:{modelOptions:t}}}).catch(e=>{K(e instanceof Error?e.message:`Unable to save provider settings.`)})}function dr(e,t){Mt(e,t),Z({providerDefaults:{[e]:{planMode:t}}}).catch(e=>{K(e instanceof Error?e.message:`Unable to save provider settings.`)})}async function fr(e=J){try{kn(null),await Bn(e);let t=await Vn(e);An(t.ok?`valid`:`invalid`),Nn(t.error)}catch(e){let t=e instanceof Error?{name:e.name,message:e.message}:jt(e);An(`invalid`),Nn(t),kn(e instanceof Error?e.message:`Unable to save quick response provider settings.`)}}function pr(e){let t=xi(J,e);Dn(t),mr(t)}function mr(e=J){I(ca,()=>fr(e))}function hr(){$i=null,v(`loading`),k(null),ia(Un,{force:!0}).then(e=>{E(e),v(`success`)}).catch(e=>{k(e instanceof Error?e.message:`Unable to load changelog.`),v(`error`)})}let gr=un.replaceAll(`{path}`,`/Users/jake/Projects/kanna/src/client/app/App.tsx`).replaceAll(`{line}`,`12`).replaceAll(`{column}`,`1`),_r=hn,vr=V?.analyticsEnabled===!1?`disabled`:`enabled`,yr=V?.telemetry?.enabled===!1?`disabled`:`enabled`,xr=V?.cloudflareTunnel??ln,Sr=xr.enabled?`enabled`:`disabled`,Cr=Hi.find(e=>e.id===A)??Hi[0],wr=(0,W.useMemo)(()=>Wi(Ft),[Ft]),Tr=A===`keybindings`?ea(Rt):Cr.subtitle,Er=!de,Dr=jn?JSON.stringify(jn,null,2):``,kr;kr=me?`inline-flex items-center gap-1.5 text-muted-foreground`:Y===`valid`?`text-success-text`:Y===`invalid`?`text-destructive`:`hidden`;let $;$=me?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(R,{}),fe?`Saving…`:`Loading…`]}):Y===`valid`?`Credentials valid & saved`:Y===`invalid`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{children:`Credentials invalid.`}),jn?(0,G.jsxs)(G.Fragment,{children:[` `,(0,G.jsx)(`button`,{type:`button`,onClick:()=>Fn(!0),className:`underline underline-offset-2`,children:`See error`})]}):null]}):null;let Ar=(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`span`,{children:[`Use an OpenAI-compatible API for title and commit message generation before Claude and Codex. Stored in `,nt?.filePathDisplay??`the active llm-provider.json file`,`.`]}),(0,G.jsx)(`span`,{className:N(`mt-2 block text-sm font-medium`,kr),children:$})]});async function jr(){if(!y){x(!0);try{await s.handleSignOut()}finally{x(!1)}}}return(0,G.jsxs)(`div`,{className:`relative flex h-full flex-1 min-w-0 bg-background`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1`,children:[(0,G.jsx)(`aside`,{className:`hidden w-[200px] shrink-0 md:block ${Er?`pb-[89px]`:``}`,children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-1 px-4 py-6`,children:[(0,G.jsx)(`div`,{className:`px-3 pb-5 text-22 font-extrabold tracking-[-0.5px] text-foreground`,children:`Settings`}),wr.map(e=>{let t=e.id===`changelog`&&X?.updateAvailable===!0;return(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{a(`/settings/${e.id}`)},className:`relative cursor-pointer rounded-lg px-3 py-2 text-sm ${e.id===A?`font-medium text-foreground`:`text-muted-foreground hover:bg-muted/50 hover:text-foreground`}`,children:[e.id===A?(0,G.jsx)(ce.span,{layoutId:`settings-nav-indicator`,className:`absolute inset-0 rounded-lg bg-muted`,transition:{type:`spring`,...l.indicator}}):null,(0,G.jsxs)(`div`,{className:`relative flex items-center gap-2.5`,children:[(0,G.jsx)(e.icon,{className:`h-4 w-4 shrink-0`}),(0,G.jsx)(`span`,{className:`min-w-0 truncate`,children:e.label}),t?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Lt,{className:`ml-auto size-3.5 shrink-0 text-warning-text`,"aria-hidden":`true`}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Update available`})]}):null]})]},e.label)}),S?(0,G.jsx)(`button`,{type:`button`,onClick:()=>I(`auth.signOut`,jr),disabled:y,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,G.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[y?(0,G.jsx)(R,{className:`h-4 w-4`}):(0,G.jsx)(qt,{className:`h-4 w-4 shrink-0`}),(0,G.jsx)(`span`,{children:y?`Signing out...`:`Sign out`})]})}):null]})}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-y-auto`,children:[(0,G.jsx)(`div`,{className:`sticky top-0 z-20 border-b border-border bg-background px-2 py-2 md:hidden`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)($e,{label:`Open sidebar`,children:(0,G.jsx)(`button`,{type:`button`,onClick:s.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,G.jsx)(ae,{className:`h-4 w-4 shrink-0`})})}),(0,G.jsxs)(We,{value:A,onValueChange:e=>{a(`/settings/${e}`)},children:[(0,G.jsx)(Be,{className:`h-11 min-w-0 flex-1`,"aria-label":`Settings section`,children:(0,G.jsx)(He,{})}),(0,G.jsx)(Ve,{children:(0,G.jsx)(Ue,{children:wr.map(e=>(0,G.jsx)(B,{value:e.id,children:e.label},e.id))})})]}),S?(0,G.jsxs)(`button`,{type:`button`,onClick:()=>I(`auth.signOut`,jr),disabled:y,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:[y?(0,G.jsx)(R,{className:`h-4 w-4`}):(0,G.jsx)(qt,{className:`h-4 w-4 shrink-0`}),(0,G.jsx)(`span`,{className:`sr-only`,children:y?`Signing out...`:`Sign out`})]}):null]})}),(0,G.jsxs)(`div`,{className:`w-full px-4 pb-32 pt-8 md:px-6 md:pt-16`,children:[de?(0,G.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,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(P,{className:`h-4 w-4 animate-spin`}),(0,G.jsx)(`span`,{children:`Loading machine settings…`})]})}):(0,G.jsxs)(`div`,{className:`mx-auto max-w-4xl kanna-settings-section-in`,children:[(0,G.jsxs)(`div`,{className:`pb-6`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4 min-h-[34px]`,children:[(0,G.jsx)(`div`,{className:`text-lg font-semibold tracking-[-0.2px] text-foreground`,children:Cr.label}),A===`general`?(0,G.jsx)(Nt,{variant:`outline`,onClick:()=>{a(`/settings/changelog`)},children:`Check for updates`}):null,A===`keybindings`?(0,G.jsxs)(Nt,{onClick:()=>I(`keybindings.openEditor`,()=>s.handleOpenExternalPath(`open_editor`,Rt)),disabled:ge,"aria-busy":ge||void 0,icon:ge?(0,G.jsx)(R,{className:`h-4 w-4`}):(0,G.jsx)(te,{className:`h-4 w-4`}),children:[`Open in `,s.editorLabel]}):null]}),(0,G.jsx)(`div`,{className:`mt-1 text-sm text-muted-foreground`,children:Tr})]}),A===`general`&&(0,G.jsxs)(G.Fragment,{children:[mn?(0,G.jsx)(`div`,{className:`mb-4 rounded-lg border border-destructive/20 bg-destructive/5 px-4 py-3 text-sm text-destructive`,children:mn}):null,(0,G.jsxs)(`div`,{className:`border-b border-border`,children:[(0,G.jsx)(Q,{title:`Application Update`,description:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`span`,{children:[Hn,`.`]}),X?.lastCheckedAt?(0,G.jsxs)(`span`,{children:[` Last checked `,new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`}).format(X.lastCheckedAt),`.`]}):null,X?.error?(0,G.jsxs)(`span`,{children:[` `,X.error]}):null]}),bordered:!1,children:(0,G.jsxs)(`div`,{className:`text-right text-sm text-foreground`,children:[(0,G.jsxs)(`div`,{children:[`Current: `,X?.currentVersion??Ee]}),(0,G.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Latest: `,X?.latestVersion??`Unknown`]})]})}),(0,G.jsx)(Q,{title:`Theme`,description:`Choose between light, dark, or system appearance`,children:(0,G.jsx)(ht,{value:p,onValueChange:$n,options:Gi,size:`sm`})}),(0,G.jsx)(Q,{title:`Typography Scale`,description:lt?`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,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsxs)(We,{value:pt,onValueChange:e=>{_e(e)&&er(e)},children:[(0,G.jsx)(Be,{className:`min-w-[180px]`,children:(0,G.jsx)(He,{})}),(0,G.jsx)(Ve,{children:(0,G.jsx)(Ue,{children:Ki.map(e=>(0,G.jsx)(B,{value:e.value,children:e.label},e.value))})})]}),lt?(0,G.jsx)(M,{type:`button`,variant:`link`,size:`sm`,onClick:dt,children:`Use account default`}):null]})}),(0,G.jsx)(Q,{title:`Chat Sounds`,description:`Play a pop when a chat starts waiting on you or the unread chat count increases`,children:(0,G.jsxs)(We,{disabled:xe,value:ze,onValueChange:e=>{ee(e)&&nr(e)},children:[(0,G.jsx)(Be,{className:`min-w-[180px]`,children:(0,G.jsx)(He,{})}),(0,G.jsx)(Ve,{children:(0,G.jsx)(Ue,{children:qi.map(e=>(0,G.jsx)(B,{value:e.value,children:e.label},e.value))})})]})}),(0,G.jsx)(Q,{title:`Chat Sound`,description:`The bundled sound used for chat notification playback and previews`,children:(0,G.jsxs)(We,{disabled:Ce,value:Ke,onValueChange:e=>{ye(e)&&rr(e)},children:[(0,G.jsx)(Be,{className:`min-w-[180px]`,children:(0,G.jsx)(He,{})}),(0,G.jsx)(Ve,{children:(0,G.jsx)(Ue,{children:Hr.map(e=>(0,G.jsx)(B,{value:e.value,children:e.label},e.value))})})]})}),(0,G.jsx)(Q,{title:`Default Editor`,description:`Used when opening transcript links or files from the git diff menu`,alignStart:!0,children:(0,G.jsxs)(We,{value:Ne,onValueChange:e=>{ve(e)&&tr(e)},children:[(0,G.jsx)(Be,{className:`min-w-[180px]`,children:(0,G.jsx)(He,{})}),(0,G.jsx)(Ve,{children:(0,G.jsx)(Ue,{children:Ae.map(e=>(0,G.jsx)(B,{value:e.value,children:(0,G.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(Me,{preset:e.value,className:`h-4 w-4 shrink-0`}),(0,G.jsx)(`span`,{children:e.label})]})},e.value))})})]})}),Ne===`custom`?(0,G.jsx)(`div`,{className:`border-t border-border`,children:(0,G.jsxs)(`div`,{className:`flex justify-between gap-8 py-5 pl-6`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 max-w-xl`,children:[(0,G.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:`Command Template`}),(0,G.jsxs)(`div`,{className:`mt-1 text-13 text-muted-foreground`,children:[`Include `,`{path}`,` and optionally `,`{line}`,` and `,`{column}`,` in your command.`]})]}),(0,G.jsxs)(`div`,{className:`flex min-w-0 max-w-[420px] flex-1 flex-col items-stretch gap-2`,children:[(0,G.jsx)(H,{type:`text`,value:un,onChange:e=>pn(e.target.value),onBlur:Qn,onKeyDown:e=>Fr(e,Qn),className:`font-mono`}),(0,G.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Preview: `,(0,G.jsx)(`span`,{className:`font-mono`,children:gr})]})]})]})}):null,(0,G.jsx)(Q,{title:`Terminal Scrollback`,description:`Lines retained for embedded terminal history`,children:(0,G.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col items-stretch gap-2 md:w-auto md:items-end`,children:[(0,G.jsx)(H,{type:`number`,min:500,max:5e3,step:100,value:Gt,onChange:e=>Kt(e.target.value),onBlur:Wn,onKeyDown:e=>Zn(e,Wn),className:`hide-number-steppers w-full text-left font-mono md:w-28 md:text-right`}),(0,G.jsxs)(`div`,{className:`text-left text-xs text-muted-foreground md:text-right`,children:[500,`-`,5e3,` lines`,Oe===1e3?` (default)`:``]})]})}),(0,G.jsx)(Q,{title:`Terminal Min Column Width`,description:`Minimum width for each terminal pane`,children:(0,G.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col items-stretch gap-2 md:w-auto md:items-end`,children:[(0,G.jsx)(H,{type:`number`,min:250,max:900,step:10,value:Jt,onChange:e=>Xt(e.target.value),onBlur:Gn,onKeyDown:e=>Zn(e,Gn),className:`hide-number-steppers w-full text-left font-mono md:w-28 md:text-right`}),(0,G.jsxs)(`div`,{className:`text-left text-xs text-muted-foreground md:text-right`,children:[250,`-`,900,` px`,je===450?` (default)`:``]})]})}),(0,G.jsx)(Q,{title:`Tab Minimum Width`,description:`How narrow a pane tab may get before the strip scrolls instead of shrinking`,children:(0,G.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col items-stretch gap-2 md:w-auto md:items-end`,children:[(0,G.jsx)(H,{type:`number`,min:60,max:200,step:10,value:Yt,onChange:e=>Zt(e.target.value),onBlur:Kn,onKeyDown:e=>Zn(e,Kn),className:`hide-number-steppers w-full text-left font-mono md:w-28 md:text-right`}),(0,G.jsxs)(`div`,{className:`text-left text-xs text-muted-foreground md:text-right`,children:[60,`-`,200,` px`,Qt===60?` (default)`:``]})]})}),(0,G.jsx)(Q,{title:`Max upload file size`,description:`Largest single file the chat upload endpoint accepts.`,children:(0,G.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col items-stretch gap-1.5 md:w-auto md:items-end`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 md:justify-end`,children:[(0,G.jsx)(H,{type:`number`,min:1,max:2048,step:1,value:en,onChange:e=>tn(e.target.value),onBlur:qn,onKeyDown:e=>Zn(e,qn),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,G.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`MB`})]}),(0,G.jsxs)(`div`,{className:`text-left text-xs text-muted-foreground tabular-nums md:text-right`,children:[1,`–`,2048,` MB · default `,dn.maxFileSizeMb]})]})}),(0,G.jsx)(Q,{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,G.jsx)(pa,{checked:rt,onChange:it})}),s.pushConfig?(0,G.jsx)(Q,{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,G.jsx)(ai,{permissionState:zt,config:s.pushConfig,projects:s.localProjects?.projects??[],currentDeviceId:Vt,contactSubject:V?.push.contactSubject??``,contactSubjectDraft:Sn,onContactSubjectDraftChange:Cn,onContactSubjectSave:async e=>{await s.socket.command({type:`settings.writeAppSettingsPatch`,patch:{push:{contactSubject:e}}})},onEnable:Ut,onDisable:Wt,onTest:async()=>{await s.socket.command({type:`push.test`})},onMuteToggle:async(e,t)=>{await s.socket.command({type:`push.setProjectMute`,localPath:e,muted:t})},onRemoveDevice:async e=>{await s.socket.command({type:`push.unsubscribe`,pushDeviceId:e})}})}):null,(0,G.jsx)(Q,{title:`Anonymous Analytics`,description:(0,G.jsxs)(G.Fragment,{children:[(0,G.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,G.jsxs)(`span`,{className:`mt-1 block`,children:[`Stored in `,V?.filePathDisplay??`~/.kanna/data/settings.json`,`.`,` `,(0,G.jsx)(`button`,{type:`button`,onClick:()=>vn(!0),className:`underline underline-offset-2 text-foreground hover:text-foreground/80`,children:`View tracked events`})]}),V?.warning?(0,G.jsx)(`span`,{className:`mt-1 block`,children:V.warning}):null]}),children:(0,G.jsx)(Fi,{pendingKey:`settings.analytics`,value:vr,onValueChange:ir,options:Ji,size:`sm`})}),(0,G.jsx)(Q,{title:`Telemetry Tracing`,description:(0,G.jsxs)(G.Fragment,{children:[(0,G.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,G.jsxs)(`span`,{className:`mt-1 block`,children:[`Collector: `,V?.telemetry?.endpoint??`not configured`,`. Stored in `,V?.filePathDisplay??`~/.kanna/data/settings.json`,`.`]})]}),children:(0,G.jsx)(Fi,{pendingKey:`settings.telemetry`,value:yr,onValueChange:ar,options:Ji,size:`sm`})})]}),(0,G.jsxs)(`div`,{className:`border-b border-border`,children:[q?(0,G.jsx)(`div`,{className:`mb-4 rounded-lg border border-destructive/20 bg-destructive/5 px-4 py-3 text-sm text-destructive`,children:q}):null,(0,G.jsx)(Q,{title:`Cloudflare Tunnel`,description:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`span`,{children:[`When enabled, Claude can call the `,(0,G.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,G.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 font-mono text-xs`,children:`cloudflared`}),` `,`to be installed.`]}),(0,G.jsxs)(`span`,{className:`mt-1 block`,children:[`Stored in `,V?.filePathDisplay??`~/.kanna/data/settings.json`,`.`]})]}),bordered:!1,children:(0,G.jsx)(Fi,{pendingKey:z(la,`enabled`),value:Sr,onValueChange:e=>or({enabled:e===`enabled`}),options:Yi,size:`sm`})}),xr.enabled&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Q,{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,G.jsx)(Fi,{pendingKey:z(la,`mode`),value:xr.mode,onValueChange:e=>or({mode:e}),options:Xi,size:`sm`})}),(0,G.jsx)(Q,{title:`cloudflared path`,description:`Path to the cloudflared binary. Defaults to the one found on $PATH.`,children:(0,G.jsx)(H,{value:bn,onChange:e=>xn(e.target.value),onBlur:()=>I(ua,()=>or({cloudflaredPath:bn})),readOnly:he,"aria-busy":he||void 0,placeholder:`cloudflared`,className:`w-full font-mono md:w-64`})})]})]}),(0,G.jsx)(`div`,{className:`border-b border-border`,children:(0,G.jsx)(Q,{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,G.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col items-stretch gap-2 md:w-auto md:items-end`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 md:justify-end`,children:[(0,G.jsx)(H,{type:`number`,min:1,step:1,value:Tn,onChange:e=>En(e.target.value),onBlur:Xn,onKeyDown:e=>Zn(e,Xn),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,G.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`hours`})]}),(0,G.jsx)(`div`,{className:`text-left text-xs text-muted-foreground tabular-nums md:text-right`,children:`Minimum 1 hour · default 24`})]})})})]}),A===`providers`&&(0,G.jsxs)(`div`,{className:`border-b border-border`,children:[(0,G.jsx)(Q,{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,G.jsx)(`div`,{className:`w-full md:w-[420px]`,children:(0,G.jsx)(Pr,{tokens:V?.claudeAuth.tokens??[],concurrencyDefault:V?.claudeAuth.concurrencyDefault??1,onWrite:Ln,onTest:Rn})})}),(0,G.jsx)(Q,{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,G.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col items-stretch gap-2 md:w-auto md:items-end`,children:[(0,G.jsx)(H,{type:`number`,min:1,max:60,step:1,value:an,onChange:e=>on(e.target.value),onBlur:Jn,onKeyDown:e=>Zn(e,Jn),className:`hide-number-steppers w-full text-left font-mono md:w-28 md:text-right`}),(0,G.jsxs)(`div`,{className:`text-left text-xs text-muted-foreground md:text-right`,children:[1,`–`,60,` min · default `,Math.round(re.idleTimeoutMs/6e4)]})]})}),(0,G.jsx)(Q,{title:`Max concurrent Claude sessions`,description:`Hard cap on resident Claude processes. Excess sessions are evicted LRU; their next activation cold-starts.`,children:(0,G.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col items-stretch gap-2 md:w-auto md:items-end`,children:[(0,G.jsx)(H,{type:`number`,min:1,max:16,step:1,value:sn,onChange:e=>cn(e.target.value),onBlur:Yn,onKeyDown:e=>Zn(e,Yn),className:`hide-number-steppers w-full text-left font-mono md:w-28 md:text-right`}),(0,G.jsxs)(`div`,{className:`text-left text-xs text-muted-foreground md:text-right`,children:[1,`–`,16,` · default `,re.maxConcurrent]})]})}),(0,G.jsx)(Q,{title:`Default Provider`,description:`The default harness used for new chats before a provider is locked by an existing session.`,children:(0,G.jsxs)(We,{value:mt,onValueChange:e=>{(e===`last_used`||b(e))&&sr(e)},children:[(0,G.jsx)(Be,{className:`min-w-[180px]`,children:(0,G.jsx)(He,{})}),(0,G.jsx)(Ve,{children:(0,G.jsxs)(Ue,{children:[(0,G.jsx)(B,{value:`last_used`,children:`Last Used`}),oe.map(e=>(0,G.jsx)(B,{value:e.id,children:e.label},e.id))]})})]})}),(0,G.jsx)(Q,{title:`Claude Code Defaults`,description:`Saved defaults when using Claude Code.`,alignStart:!0,children:(0,G.jsx)(`div`,{className:`max-w-[420px]`,children:(0,G.jsx)(De,{availableProviders:It,selectedProvider:`claude`,showProviderPicker:!1,model:gt.claude.model,modelOptions:gt.claude.modelOptions,onModelChange:(e,t)=>{cr(`claude`,t)},onModelOptionChange:e=>{e.type===`claudeReasoningEffort`?ur(`claude`,{reasoningEffort:e.effort}):e.type===`contextWindow`&&ur(`claude`,{contextWindow:e.contextWindow})},planMode:gt.claude.planMode,onPlanModeChange:e=>dr(`claude`,e),includePlanMode:!0,className:`justify-start flex-wrap`})})}),(0,G.jsx)(Q,{title:`Codex Defaults`,description:`Saved defaults when using Codex.`,alignStart:!0,children:(0,G.jsx)(`div`,{className:`max-w-[420px]`,children:(0,G.jsx)(De,{availableProviders:It,selectedProvider:`codex`,showProviderPicker:!1,model:gt.codex.model,modelOptions:gt.codex.modelOptions,onModelChange:(e,t)=>{cr(`codex`,t)},onModelOptionChange:e=>{e.type===`codexReasoningEffort`?ur(`codex`,{reasoningEffort:e.effort}):e.type===`fastMode`&&ur(`codex`,{fastMode:e.fastMode})},planMode:gt.codex.planMode,onPlanModeChange:e=>dr(`codex`,e),includePlanMode:!0,className:`justify-start flex-wrap`})})}),(0,G.jsx)(Q,{title:`Quick Response SDK`,description:Ar,alignStart:!0,children:(0,G.jsxs)(`div`,{className:`flex w-full max-w-[420px] flex-col gap-3`,children:[On?(0,G.jsx)(`div`,{className:`rounded-lg border border-destructive/20 bg-destructive/5 px-4 py-3 text-sm text-destructive`,children:On}):null,nt?.warning?(0,G.jsx)(`div`,{className:`rounded-lg border border-border bg-card/30 px-4 py-3 text-sm text-muted-foreground`,children:nt.warning}):null,(0,G.jsxs)(We,{value:J.provider,disabled:me,onValueChange:e=>{g(e)&&pr(e)},children:[(0,G.jsx)(Be,{className:`w-full`,children:(0,G.jsx)(He,{})}),(0,G.jsx)(Ve,{children:(0,G.jsx)(Ue,{children:Zi.map(e=>(0,G.jsx)(B,{value:e.value,children:e.label},e.value))})})]}),J.provider===`custom`?(0,G.jsx)(H,{value:J.baseUrl,onChange:e=>Dn({...J,baseUrl:e.target.value}),onBlur:()=>mr(),onKeyDown:e=>Fr(e,mr),readOnly:me,placeholder:`https://your-provider.example/v1`}):null,(0,G.jsx)(H,{type:`password`,value:J.apiKey,onChange:e=>Dn({...J,apiKey:e.target.value}),onBlur:()=>mr(),onKeyDown:e=>Fr(e,mr),readOnly:me,placeholder:`API key`}),(0,G.jsx)(H,{value:J.model,onChange:e=>Dn({...J,model:e.target.value}),onBlur:()=>mr(),onKeyDown:e=>Fr(e,mr),readOnly:me,placeholder:`Model id`})]})})]}),A===`keybindings`&&(0,G.jsx)(zr,{state:s}),A===`skills`&&(0,G.jsx)(Ni,{state:s}),A===`plugins`&&(0,G.jsx)(yi,{state:s}),A===`kanna-plugins`&&Ft&&(0,G.jsx)(Vi,{}),A===`subagents`&&(0,G.jsx)(Mn,{state:s}),A===`models`&&(0,G.jsx)(br,{state:s}),A===`mcp-servers`&&(0,G.jsx)(lr,{state:s}),A===`snippets`&&(0,G.jsx)(Or,{state:s}),A===`instructions`&&(0,G.jsx)(ma,{state:s}),![`general`,`providers`,`keybindings`,`skills`,`plugins`,`subagents`,`models`,`mcp-servers`,`snippets`,`instructions`].includes(A)&&(0,G.jsx)(da,{status:h,releases:w,error:D,onRetry:hr,updateSnapshot:X,currentVersion:Ee,onInstallUpdate:e=>s.handleInstallUpdate(e),onCheckForUpdates:()=>s.handleCheckForUpdates({force:!0}),onForceReload:()=>s.handleForceReload()})]},A),s.commandError?(0,G.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,G.jsx)(tt,{className:`mt-0.5 h-4 w-4 flex-shrink-0`}),(0,G.jsx)(`span`,{children:s.commandError})]}):null]})]})]}),Er?(0,G.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 border-t border-border bg-background`,children:(0,G.jsx)(`div`,{className:`px-6 py-[14.25px]`,children:(0,G.jsxs)(`div`,{className:`grid gap-3 text-xs text-muted-foreground grid-cols-2 lg:grid-cols-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`mb-1 tracking-wide text-xs text-muted-foreground/80`,children:`Machine`}),(0,G.jsx)(`div`,{className:`text-foreground/80`,children:we})]}),(0,G.jsxs)(`div`,{className:`hidden md:block`,children:[(0,G.jsx)(`div`,{className:`mb-1 tracking-wide text-xs text-muted-foreground/80`,children:`Connection`}),(0,G.jsx)(`div`,{className:`text-foreground/80`,children:s.connectionStatus})]}),(0,G.jsxs)(`div`,{className:`hidden md:block`,children:[(0,G.jsx)(`div`,{className:`mb-1 tracking-wide text-xs text-muted-foreground/80`,children:`Projects Indexed`}),(0,G.jsx)(`div`,{className:`text-foreground/80`,children:F})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`mb-1 tracking-wide text-xs text-muted-foreground/80`,children:`App Version`}),(0,G.jsx)(`div`,{className:`text-foreground/80`,children:Ee})]})]})})}):null,(0,G.jsx)(ot,{open:_n,onOpenChange:vn,children:(0,G.jsxs)(at,{size:`lg`,children:[(0,G.jsxs)(ct,{className:`space-y-4`,children:[(0,G.jsx)(ut,{children:`Tracked Events`}),(0,G.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,G.jsxs)(`div`,{className:`max-h-[60vh] overflow-auto rounded-lg border border-border bg-muted/40 p-3`,children:[(0,G.jsx)(`div`,{className:`text-xs font-medium tracking-wide text-muted-foreground`,children:`Event Names`}),(0,G.jsx)(`ul`,{className:`mt-3 space-y-2 text-sm`,children:_r.map(e=>(0,G.jsx)(`li`,{className:`font-mono text-foreground`,children:e},e))}),(0,G.jsx)(`div`,{className:`mt-6 text-xs font-medium tracking-wide text-muted-foreground`,children:`Property Keys`}),(0,G.jsx)(`ul`,{className:`mt-3 space-y-2 text-sm`,children:gn.map(e=>(0,G.jsx)(`li`,{className:`font-mono text-foreground`,children:e},e))})]})]}),(0,G.jsx)(st,{children:(0,G.jsx)(M,{variant:`secondary`,size:`sm`,onClick:()=>vn(!1),children:`Close`})})]})}),(0,G.jsx)(ot,{open:Pn,onOpenChange:Fn,children:(0,G.jsxs)(at,{size:`lg`,children:[(0,G.jsxs)(ct,{className:`space-y-4`,children:[(0,G.jsx)(ut,{children:`Validation Error`}),(0,G.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:Dr})]}),(0,G.jsx)(st,{children:(0,G.jsx)(M,{variant:`secondary`,size:`sm`,onClick:()=>Fn(!1),children:`Close`})})]})})]})}export{ha as SettingsPage};
|
package/dist/client/assets/{StackBoardsRoutePage-t_EaFNG4.js → StackBoardsRoutePage-Clviz0hX.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{t}from"./react-DiVRNtpo.js";import{c as n,l as r,u as i}from"./chunk-OB3PAWPO-mARpRU1A.js";import{t as a}from"./jsx-runtime-BdxMnOeJ.js";import{t as o}from"./BoardsPage-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{t}from"./react-DiVRNtpo.js";import{c as n,l as r,u as i}from"./chunk-OB3PAWPO-mARpRU1A.js";import{t as a}from"./jsx-runtime-BdxMnOeJ.js";import{t as o}from"./BoardsPage-AckCuswi.js";var s=e(t(),1),c=e(a(),1);function l(){let e=r(),t=n(),{stackId:a=``}=i(),l=e.sidebarData.stacks.find(e=>e.id===a),u=l?l.title:`Stack`,d=(0,s.useCallback)(e=>{t(`/boards/stack/${a}/${e}`)},[t,a]);return(0,c.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col`,children:(0,c.jsx)(o,{ownerKind:`stack`,ownerId:a,ownerName:u,socket:e.socket,onOpenBoard:d})})}export{l as StackBoardsRoutePage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{t}from"./react-DiVRNtpo.js";import{n}from"./chunk-OB3PAWPO-mARpRU1A.js";import{t as r}from"./jsx-runtime-BdxMnOeJ.js";import{c as i,f as a,l as o,m as s,p as c,t as l,u}from"./log-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{t}from"./react-DiVRNtpo.js";import{n}from"./chunk-OB3PAWPO-mARpRU1A.js";import{t as r}from"./jsx-runtime-BdxMnOeJ.js";import{c as i,f as a,l as o,m as s,p as c,t as l,u}from"./log-DnEvbp3E.js";import{a as d,c as f,d as p,f as m}from"./pendingActionsStore-CxhI19V9.js";import{A as h,D as g,F as _,I as v,N as y,O as b,S as x,_ as S,b as C,c as w,h as T,l as E,m as D,o as ee,r as te,t as ne,v as re,w as ie,y as ae}from"./FilePreviewSheet-B6SDxSD0.js";import{r as oe}from"./terminal-DfCF-J4p.js";import{g as se}from"./timer.adapter-C2RhP4d6.js";import{t as O}from"./createScopedStore-BrD5NHWx.js";import{l as ce}from"./useTheme-D9sKDPEm.js";import{i as le,n as ue,r as de,t as fe}from"./status-pill-Bo1Nb6HX.js";import{n as pe,o as me}from"./formatters-BGORekd-.js";import{t as he}from"./formatDuration-BbWTR_M_.js";import{n as ge,r as _e}from"./tools-t5T_3UBg.js";var k={name:`arrow-up`,size:24,node:[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]};k.node;var A=m(k),j={name:`git-branch`,size:24,node:[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]};j.node;var M=m(j),N={name:`image`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]};N.node;var ve=m(N),P={name:`user-round`,size:24,node:[[`circle`,{cx:`12`,cy:`8`,r:`5`,key:`1hypcn`}],[`path`,{d:`M20 21a8 8 0 0 0-16 0`,key:`rfgkzh`}]],aliases:[`user-2`]};P.node;var F=m(P),I={name:`workflow`,size:24,node:[[`rect`,{width:`8`,height:`8`,x:`3`,y:`3`,rx:`2`,key:`by2w9f`}],[`path`,{d:`M7 11v4a2 2 0 0 0 2 2h4`,key:`xkn7yn`}],[`rect`,{width:`8`,height:`8`,x:`13`,y:`13`,rx:`2`,key:`1cgmvn`}]]};I.node;var ye=m(I);function be(e){return e.kind===`tool`}function L(e){return new Date(e).toISOString()}function R(e){return{id:e._id,messageId:e.messageId,timestamp:L(e.createdAt),hidden:e.hidden}}function xe(e){return{id:e._id,messageId:e.messageId,hidden:e.hidden,kind:`tool`,toolKind:e.tool.toolKind,toolName:e.tool.toolName,toolId:e.tool.toolId,input:e.tool.input,timestamp:L(e.createdAt)}}function Se(e){if(!e.debugRaw)return;let t;try{t=JSON.parse(e.debugRaw).tool_use_result??void 0}catch{return}if(t!==void 0&&typeof t!=`number`&&typeof t!=`boolean`)return t}function z(e){return typeof e==`number`?e:void 0}function B(e){return typeof e==`string`?e:void 0}function Ce(e){if(e===void 0||!ce(e))return;let t=e,n={readCount:z(t.readCount),searchCount:z(t.searchCount),bashCount:z(t.bashCount),editFileCount:z(t.editFileCount),linesAdded:z(t.linesAdded),linesRemoved:z(t.linesRemoved),otherToolCount:z(t.otherToolCount)};return Object.values(n).some(e=>e!==void 0)?n:void 0}function we(e){if(!e.debugRaw)return;let t;try{t=JSON.parse(e.debugRaw).toolUseResult}catch{return}if(t===void 0||!ce(t))return;let n=t,r={agentId:B(n.agentId),agentType:B(n.agentType),status:B(n.status),totalTokens:z(n.totalTokens),totalDurationMs:z(n.totalDurationMs),totalToolUseCount:z(n.totalToolUseCount),toolStats:Ce(n.toolStats),content:B(n.content)};return r.agentId!==void 0||r.agentType!==void 0||r.totalTokens!==void 0||r.totalDurationMs!==void 0||r.status!==void 0?r:void 0}function V(e){let t=new Map,n=[];for(let r of e)switch(r.kind){case`user_prompt`:n.push({...R(r),kind:`user_prompt`,content:r.content,attachments:r.attachments??[],steered:r.steered,autoContinue:r.autoContinue,expandedCommand:r.expandedCommand});break;case`system_init`:n.push({...R(r),kind:`system_init`,provider:r.provider,model:r.model,tools:r.tools,agents:r.agents,slashCommands:r.slashCommands,mcpServers:r.mcpServers,debugRaw:r.debugRaw});break;case`account_info`:n.push({...R(r),kind:`account_info`,accountInfo:r.accountInfo});break;case`assistant_text`:n.push({...R(r),kind:`assistant_text`,text:r.text});break;case`assistant_thinking`:n.push({...R(r),kind:`assistant_thinking`,text:r.text,signature:r.signature});break;case`api_error`:n.push({...R(r),kind:`api_error`,status:r.status,text:r.text,requestId:r.requestId,apiErrorReason:r.apiErrorReason});break;case`policy_refusal`:n.push({...R(r),kind:`policy_refusal`,text:r.text,requestId:r.requestId});break;case`tool_call`:{let e=xe(r);t.set(r.tool.toolId,{hydrated:e,normalized:r.tool}),be(e)&&n.push(e);break}case`tool_result`:{let e=t.get(r.toolId);if(e){let t=ge.has(e.normalized.toolKind)?Se(r)??r.content:r.content;e.normalized.toolKind===`subagent_task`?e.hydrated.result=we(r):e.hydrated.result=_e(e.normalized,de(t)),e.hydrated.rawResult=t,e.hydrated.isError=r.isError,r.persisted&&(e.hydrated.persisted=r.persisted)}break}case`result`:n.push({...R(r),kind:`result`,success:!r.isError,cancelled:r.subtype===`cancelled`,result:r.result,durationMs:r.durationMs,costUsd:r.costUsd,codexErrorInfo:r.codexErrorInfo});break;case`status`:n.push({...R(r),kind:`status`,status:r.status});break;case`context_window_updated`:n.push({...R(r),kind:`context_window_updated`,usage:r.usage});break;case`compact_boundary`:n.push({...R(r),kind:`compact_boundary`});break;case`compact_summary`:n.push({...R(r),kind:`compact_summary`,summary:r.summary});break;case`context_cleared`:n.push({...R(r),kind:`context_cleared`});break;case`interrupted`:n.push({...R(r),kind:`interrupted`});break;case`memory_loaded`:n.push({...R(r),kind:`memory_loaded`,path:r.path});break;case`auto_continue_prompt`:n.push({...R(r),kind:`auto_continue_prompt`,scheduleId:r.scheduleId});break;case`pending_tool_request`:n.push({...R(r),kind:`pending_tool_request`,toolRequestId:r.toolRequestId,toolName:r.toolName,arguments:r.arguments});break;case`tool_request_resolved`:break;case`cron_armed`:n.push({...R(r),kind:`cron_armed`,jobId:r.jobId,instruction:r.instruction,mode:r.mode,scheduleText:r.scheduleText,scheduleHuman:r.scheduleHuman,nextFireAt:r.nextFireAt,...r.model===void 0?{}:{model:r.model},...r.upcomingFires===void 0?{}:{upcomingFires:r.upcomingFires},...r.cwd===void 0?{}:{cwd:r.cwd}});break;case`cron_command_error`:n.push({...R(r),kind:`cron_command_error`,message:r.message,...r.input===void 0?{}:{input:r.input},...r.suggestion===void 0?{}:{suggestion:r.suggestion}});break;case`cron_run`:n.push({...R(r),kind:`cron_run`,jobId:r.jobId,runId:r.runId,instruction:r.instruction,...r.spawnedChatId===void 0?{}:{spawnedChatId:r.spawnedChatId},firedAt:r.firedAt});break;case`cron_run_skipped`:n.push({...R(r),kind:`cron_run_skipped`,jobId:r.jobId,reason:r.reason,...r.missedCount===void 0?{}:{missedCount:r.missedCount}});break;case`cron_list`:n.push({...R(r),kind:`cron_list`,...r.help===void 0?{}:{help:r.help}});break;case`cron_job_change`:n.push({...R(r),kind:`cron_job_change`,jobId:r.jobId,change:r.change});break;case`loop_disarmed`:n.push({...R(r),kind:`loop_disarmed`,reason:r.reason,resumable:r.resumable,...r.trackingFileRel===void 0?{}:{trackingFileRel:r.trackingFileRel},...r.workdirAbs===void 0?{}:{workdirAbs:r.workdirAbs}});break;default:n.push({...R(r),kind:`unknown`,json:JSON.stringify(r,null,2)})}return n}var H=e(t(),1),U=e(r(),1),Te=(0,H.memo)(({message:e})=>(0,U.jsx)(`div`,{className:`text-pretty prose prose-sm dark:prose-invert px-0.5 w-full max-w-[70ch] space-y-4`,children:te(e.text)})),Ee=(0,H.memo)(({message:e})=>(0,U.jsx)(`div`,{className:`px-0.5 w-full max-w-[70ch]`,children:(0,U.jsx)(D,{content:e.text})})),De=({children:e,className:t,animate:n=!0,shimmerWidth:r,...i})=>(0,U.jsx)(`span`,{className:f(`mx-auto max-w-md text-foreground/60`,n&&`animate-shiny-pulse`,t),...i,children:e});function Oe(e){let t=e.split(`
|
|
2
2
|
`),n=/^\s*(\d+)→(.*)$/;return t.map(e=>{let t=e.match(n);return t?{lineNumber:parseInt(t[1],10),content:t[2]}:{lineNumber:null,content:e}})}function ke(e){return e.replace(/<[^>]+>/g,``)}function Ae(e,t){let n=e.split(`
|
|
3
3
|
`),r=t.split(`
|
|
4
4
|
`);return Ne(Me(n,r,je(n,r)))}function je(e,t){let n=e.length,r=t.length,i=Array.from({length:n+1},()=>Array(r+1).fill(0));for(let a=1;a<=n;a++)for(let n=1;n<=r;n++)i[a][n]=e[a-1]===t[n-1]?i[a-1][n-1]+1:Math.max(i[a-1][n],i[a][n-1]);return i}function Me(e,t,n){let r=[],i=e.length,a=t.length;for(;i>0||a>0;)i>0&&a>0&&e[i-1]===t[a-1]?(r.push({type:`context`,text:e[i-1],oldIdx:i,newIdx:a}),i--,a--):a>0&&(i===0||n[i][a-1]>=n[i-1][a])?(r.push({type:`added`,text:t[a-1],oldIdx:i,newIdx:a}),a--):(r.push({type:`removed`,text:e[i-1],oldIdx:i,newIdx:a}),i--);return r.reverse()}function Ne(e){return e.map(e=>{let t;return t=e.type===`removed`?`-`:e.type===`added`?`+`:` `,{type:e.type,content:`${t}${e.text}`}})}function W({content:e,isDiff:t=!1,oldString:n,newString:r}){let i=(0,H.useMemo)(()=>t&&n!==void 0&&r!==void 0?Ae(n,r):[],[t,n,r]),a=(0,H.useMemo)(()=>t?[]:Oe(e),[e,t]),o=(0,H.useMemo)(()=>a.some(e=>e.lineNumber!==null),[a]);return t&&i.length>0?(0,U.jsx)(`div`,{className:`my-1 rounded-lg border border-border overflow-hidden`,children:(0,U.jsx)(`div`,{className:`overflow-auto max-h-64 md:max-h-[50vh]`,children:(0,U.jsx)(`table`,{className:`w-full border-collapse text-xs font-mono`,children:(0,U.jsx)(`tbody`,{children:i.map((e,t)=>{let n;n=e.type===`removed`?`bg-destructive/10 dark:bg-destructive/15`:e.type===`added`?`bg-success/10 dark:bg-success/15`:``;let r;r=e.type===`removed`?`text-destructive`:e.type===`added`?`text-success`:`text-foreground`;let i;i=e.type===`removed`?`text-destructive/50`:e.type===`added`?`text-success/50`:`text-muted-foreground/50`;let a;return a=e.type===`removed`?`-`:e.type===`added`?`+`:` `,(0,U.jsxs)(`tr`,{className:n,children:[(0,U.jsx)(`td`,{className:`px-2 py-0 select-none w-0 whitespace-nowrap ${i}`,children:a}),(0,U.jsx)(`td`,{className:`px-2 py-0 whitespace-pre select-all ${r}`,children:e.content.slice(1)})]},t)})})})})}):(0,U.jsx)(`div`,{className:`my-1 rounded-lg border border-border overflow-hidden`,children:(0,U.jsx)(`div`,{className:`overflow-auto max-h-64 md:max-h-[50vh]`,children:(0,U.jsx)(`table`,{className:`w-full border-collapse text-xs font-mono`,children:(0,U.jsx)(`tbody`,{children:a.map((e,t)=>(0,U.jsxs)(`tr`,{children:[o&&(0,U.jsx)(`td`,{className:`px-2 py-0 select-none w-0 whitespace-nowrap text-muted-foreground/50 text-right`,children:e.lineNumber===null?``:e.lineNumber}),(0,U.jsx)(`td`,{className:`px-2 py-0 whitespace-pre select-all text-foreground`,children:ke(e.content)})]},t))})})})})}var Pe=new Map;function G(e,t){if(!t)return;let n=Pe.get(e);return n===void 0?void 0:t(n)}function Fe(e){return{state:e===void 0?`idle`:`ready`,data:e===void 0?null:e,error:null}}function Ie(e){let{cacheKey:t,enabled:n,ref:r,fetcher:i,rootMargin:a,fromCache:c}=e,l=G(t,c),d=(0,H.useMemo)(()=>u(()=>Fe(G(t,c))),[t,c]),f=o(d,e=>e.state),p=o(d,e=>e.data),m=o(d,e=>e.error),h=(0,H.useRef)(t),g=(0,H.useRef)(null),_=(0,H.useRef)(t);return(0,H.useEffect)(()=>{_.current=t},[t]),(0,H.useEffect)(()=>{h.current!==t&&(h.current=t,d.setState(Fe(G(t,c))))},[t,c,d]),(0,H.useEffect)(()=>{if(!n||l!==void 0)return;let e=r.current;if(!e||typeof IntersectionObserver>`u`)return;let o=!1,c=t,u=new IntersectionObserver(e=>{for(let t of e){if(!t.isIntersecting)continue;if(u.disconnect(),o)return;let e=new AbortController;g.current=e,d.setState({state:`loading`}),i(e.signal).then(e=>{o||_.current!==c||(Pe.set(c,e),d.setState({data:e,state:`ready`}))}).catch(s(t=>{o||e.signal.aborted||_.current!==c||d.setState({error:t,state:`error`})}));break}},{rootMargin:a??`200px`});return u.observe(e),()=>{o=!0,u.disconnect(),g.current?.abort(),g.current=null}},[l,t,n,r,i,a,d]),(0,H.useMemo)(()=>({state:f,data:p,error:m}),[f,p,m])}function Le(e){return typeof e==`string`?e:void 0}function Re({source:e,onOpen:t,variant:n}){let r={id:e.id,kind:`file`,displayName:e.displayName,mimeType:e.mimeType,size:e.size??0,contentUrl:e.contentUrl,relativePath:e.relativePath??``,absolutePath:``},i=y(r),a=v(i,e.mimeType),o=e.size&&e.size>0?S(e.size):null;return i===`image`?(0,U.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`Preview ${e.displayName}`,className:`touch-manipulation overflow-hidden rounded-xl border border-border bg-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background`,children:(0,U.jsx)(`img`,{src:e.contentUrl,alt:e.altText??e.displayName,loading:`lazy`,className:`max-h-64 w-auto max-w-full object-contain`})}):n===`expanded`&&(i===`text`||i===`code`||i===`markdown`||i===`json`||i===`table`)?(0,U.jsx)(ze,{source:e,onOpen:t,friendlyType:a,sizeLabel:o}):(0,U.jsx)(T,{attachment:r,onClick:t,meta:(0,U.jsxs)(U.Fragment,{children:[a,o?(0,U.jsxs)(U.Fragment,{children:[` · `,(0,U.jsx)(`span`,{className:`tabular-nums`,children:o})]}):null]}),ariaLabel:`Preview ${e.displayName}, ${a}${o?`, ${o}`:``}`})}var ze=function({source:e,onOpen:t,friendlyType:n,sizeLabel:r}){let i=(0,H.useRef)(null),a=e.contentUrl,o=(0,H.useCallback)(async e=>{let t=await _(a,4096);if(e.aborted)throw Error(`aborted`);return t.content.slice(0,200)},[a]),s=Ie({ref:i,enabled:!0,cacheKey:`snippet:${e.id}|${e.contentUrl}|${e.size??0}`,fetcher:o,fromCache:Le}),c=s.state===`ready`&&typeof s.data==`string`?s.data:``;return(0,U.jsxs)(`button`,{ref:i,type:`button`,onClick:t,"aria-label":`Preview ${e.displayName}`,className:`flex w-full max-w-md flex-col items-start gap-1 rounded-xl border border-border bg-background p-3 text-left hover:bg-accent/40`,children:[(0,U.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:e.displayName}),(0,U.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[n,r?` · ${r}`:``]}),c?(0,U.jsx)(`pre`,{className:`line-clamp-3 max-h-16 w-full whitespace-pre-wrap break-words text-xs text-muted-foreground`,children:c}):null]})},K=O(`ImageViewMessage`,()=>e=>({open:!1,setOpen:t=>e({open:t})}));function Be({toolId:e,path:t,contentUrl:n,mimeType:r}){let i=K.useScopedStore(e=>e.open),a=K.useScopedStore(e=>e.setOpen),o=ee(t);if(!n)return(0,U.jsx)(`div`,{className:`rounded-lg border border-border bg-muted/20 px-3 py-2 text-sm text-muted-foreground`,children:t});let s={id:`image-view-${e}`,contentUrl:n,displayName:o,fileName:o,relativePath:t,mimeType:r,origin:`image_view`};return(0,U.jsxs)(`figure`,{className:`flex flex-col gap-2`,"data-testid":`image-view`,children:[(0,U.jsx)(Re,{source:s,onOpen:()=>a(!0),variant:`expanded`}),(0,U.jsx)(ne,{source:i?s:null,open:i,onOpenChange:a})]})}function Ve(e){return(0,U.jsx)(K.Provider,{init:void 0,children:(0,U.jsx)(Be,{...e})})}function He(){return(0,U.jsx)(`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:`started…`})}function Ue({name:e,description:t,run:n}){return(0,U.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,U.jsx)(M,{className:`size-4 text-muted-icon shrink-0`}),(0,U.jsxs)(`div`,{className:`flex flex-1 items-center gap-2 min-w-0 overflow-hidden`,children:[(0,U.jsx)(`span`,{className:`font-medium text-foreground/80 text-sm truncate`,children:e??`Workflow`}),t&&(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:t}),n?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(ue,{status:n.status}),n.agentCount!=null&&n.agentCount>0&&(0,U.jsxs)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:[n.agentCount,` agents`]})]}):(0,U.jsx)(He,{})]})]})}function We(e,t,n){let r=typeof e.maxTokens==`number`&&Number.isFinite(e.maxTokens)?e.maxTokens:null,i=r&&r>0?Math.min(100,e.usedTokens/r*100):null,a=r===null?null:Math.max(0,Math.round(r-e.usedTokens)),o=i===null?null:Math.max(0,100-i);return{...e,compactsAutomatically:e.compactsAutomatically||n,maxTokens:r??void 0,remainingTokens:a,usedPercentage:i,remainingPercentage:o,updatedAt:t}}function Ge(e){let t=e.some(e=>e.kind===`compact_boundary`||e.kind===`compact_summary`||e.kind===`context_cleared`);for(let n=e.length-1;n>=0;--n){let r=e[n];if(r&&!(r.kind!==`context_window_updated`||r.usage.usedTokens<=0))return We(r.usage,new Date(r.createdAt).toISOString(),t)}return null}function Ke(e,t){return!e||t===null||!Number.isFinite(t)||t<=0?e:We({...e,maxTokens:t},e.updatedAt,e.compactsAutomatically)}function q(e){return e===void 0||!Number.isFinite(e)||e<0?0:e}function qe(e,t){let n=0,r=0,i=0,a=0;for(let t of e){if(t.kind!==`result`)continue;let e=t.usage;e&&(n+=q(e.inputTokens),r+=q(e.outputTokens),i+=q(e.cachedInputTokens)),a+=q(t.costUsd??e?.costUsd)}for(let e of t){let t=e.usage;t&&(n+=q(t.inputTokens),r+=q(t.outputTokens),i+=q(t.cachedInputTokens),a+=q(t.costUsd))}if(n===0&&r===0&&i===0&&a===0)return null;let o=n>0?i/n*100:null;return{inputTokens:n,outputTokens:r,cachedTokens:i,costUsd:a,cacheHitPercentage:o}}function Je(e){return!Number.isFinite(e)||e<=0?`$0.00`:e<.01?`<$0.01`:`$${e.toFixed(2)}`}function Ye(e){return e==null||!Number.isFinite(e)?`0`:e<1e3?`${Math.round(e)}`:e<1e4?`${(e/1e3).toFixed(1).replace(/\.0$/,``)}k`:e<1e6?`${Math.round(e/1e3)}k`:`${(e/1e6).toFixed(1).replace(/\.0$/,``)}m`}var Xe={serverOverloaded:`transient`,internalServerError:`transient`,httpConnectionFailed:`transient`,responseStreamConnectionFailed:`transient`,responseStreamDisconnected:`transient`,responseTooManyFailedAttempts:`transient`,usageLimitExceeded:`quota`,sessionBudgetExceeded:`quota`,unauthorized:`auth`,contextWindowExceeded:`fatal`,badRequest:`fatal`,cyberPolicy:`fatal`,sandboxError:`fatal`,threadRollbackFailed:`fatal`,activeTurnNotSteerable:`fatal`,other:`unknown`},Ze=new Set([`httpConnectionFailed`,`responseStreamConnectionFailed`,`responseStreamDisconnected`,`responseTooManyFailedAttempts`,`activeTurnNotSteerable`]);function J(e){return e in Xe}function Qe(e){if(e==null)return null;if(typeof e==`string`)return J(e)&&!Ze.has(e)?e:null;if(typeof e!=`object`)return null;let t=Object.keys(e);if(t.length!==1)return null;let[n]=t;return Ze.has(n)&&J(n)?n:null}function $e(e){return typeof e==`string`?J(e)?e:null:Qe(e)}function et(e){let t=$e(e);return t===null?`unknown`:Xe[t]}function tt(e){return et(e)===`transient`}var nt={serverOverloaded:e=>`${e} is temporarily at capacity. Retry, or switch to another model.`,internalServerError:e=>`${e} hit a server-side error. Retrying usually clears it.`,httpConnectionFailed:()=>`Could not reach the model provider. Check your connection, then retry.`,responseStreamConnectionFailed:()=>`The response stream failed to connect. Retry to start a new stream.`,responseStreamDisconnected:()=>`The response stream disconnected mid-turn. Retry to pick up from where it stopped.`,responseTooManyFailedAttempts:e=>`${e} failed repeatedly while streaming. Retry, or switch to another model.`,usageLimitExceeded:()=>`You have reached your Codex usage limit. Access returns when the limit window resets.`,sessionBudgetExceeded:()=>`This session reached its configured token budget.`,unauthorized:()=>"Codex rejected the credentials for this request. Re-authenticate with `codex login`.",contextWindowExceeded:e=>`The conversation no longer fits in ${e}'s context window. Start a new chat or compact this one.`,badRequest:()=>`Codex rejected the request as malformed.`,cyberPolicy:()=>`Codex declined this request under its usage policy.`,sandboxError:()=>`The Codex sandbox failed to run the requested command.`,threadRollbackFailed:()=>`Codex could not roll the conversation back to the requested point.`,activeTurnNotSteerable:()=>`The running turn cannot accept new input. Wait for it to finish, or stop it.`},rt=`The selected model`;function it(e,t){let n=$e(e);if(n===null)return null;let r=nt[n];return r===void 0?null:r(t??rt)}var Y=O(`TranscriptActionCard`,()=>e=>({busyId:null,actionError:null,setBusyId:t=>e({busyId:t}),setActionError:t=>e({actionError:t})})),at={neutral:`border-border bg-card`,muted:`border-border/50 bg-card/50 opacity-75`,success:`border-emerald-500/30 bg-emerald-500/5`,error:`border-destructive/40 bg-destructive/5`},ot={primary:`default`,secondary:`secondary`,ghost:`ghost`,destructive:`destructive`};function st(e){return(0,U.jsx)(Y.Provider,{init:void 0,children:(0,U.jsx)(ct,{...e})})}function ct({title:e,description:t,body:n,errorMessage:r,tone:i=`neutral`,actions:o=[]}){let c=Y.useScopedStore(e=>e.busyId),u=Y.useScopedStore(e=>e.actionError),p=Y.useScopedStoreApi(),m=(0,H.useCallback)(e=>{let t=p.getState();if(t.busyId)return;t.setActionError(null);let n;try{n=e.onClick()}catch(e){l.error(`[transcript-action-card] sync click threw`,String(e)),p.getState().setActionError(a(e));return}n instanceof Promise&&(t.setBusyId(e.id),n.then(()=>p.getState().setBusyId(null),s(e=>{l.error(`[transcript-action-card] async click rejected`,e.message),p.getState().setActionError(e.message),p.getState().setBusyId(null)})))},[p]),h=c!==null;return(0,U.jsxs)(`div`,{"data-focus-fallback-ignore":!0,className:f(`rounded-lg border px-4 py-3 text-sm space-y-2 transition-colors`,at[i]),children:[(0,U.jsx)(`div`,{className:`flex items-start justify-between gap-3`,children:(0,U.jsxs)(`div`,{className:`space-y-1 min-w-0 flex-1`,children:[(0,U.jsx)(`div`,{className:`font-medium leading-tight`,children:e}),t?(0,U.jsx)(`div`,{className:`text-muted-foreground text-xs leading-snug`,children:t}):null]})}),n?(0,U.jsx)(`div`,{className:`text-xs leading-snug`,children:n}):null,r?(0,U.jsx)(`div`,{className:`text-destructive text-xs leading-snug`,children:r}):null,u?(0,U.jsx)(`div`,{className:`text-destructive text-xs leading-snug`,role:`alert`,children:u}):null,o.length>0?(0,U.jsx)(`div`,{className:`flex flex-wrap gap-2 pt-1`,children:o.map(e=>{let t=c===e.id;return(0,U.jsx)(d,{type:`button`,size:`sm`,variant:ot[e.variant??`ghost`],disabled:e.disabled||h&&!t,pending:t,onClick:()=>m(e),className:`gap-1.5`,children:e.label},e.id)})}):null]})}function lt(e){if(e<1e3)return`${e}ms`;let t=Math.floor(e/1e3),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60;return n>0?`${n}h${r>0?` ${r}m`:``}`:r>0?`${r}m${i>0?` ${i}s`:``}`:`${i}s`}function ut({durationMs:e,prefix:t=`Worked for`}){return e<=0?null:(0,U.jsxs)(g,{children:[t,` `,lt(e)]})}var X=/\[([^\]]+)\]\(\/chat\/([0-9a-fA-F][0-9a-fA-F-]{7,})\)/g;function dt(e,t){let r=[],i=0,a=0;X.lastIndex=0;for(let o=X.exec(e);o!==null;o=X.exec(e))o.index>i&&r.push(e.slice(i,o.index)),r.push((0,U.jsx)(n,{to:`/chat/${o[2]}`,className:t??`underline decoration-destructive/40 hover:decoration-destructive`,children:o[1]},`chat-link-${a++}`)),i=o.index+o[0].length;return i<e.length&&r.push(e.slice(i)),r.length===0?e:r}function ft({resultMessageId:e,body:t,onRetry:n}){let r=[{id:`retry`,label:`Retry`,variant:`primary`,onClick:(0,H.useCallback)(()=>n(e),[n,e])}];return(0,U.jsx)(`div`,{className:`mx-2 my-1`,children:(0,U.jsx)(st,{title:`Turn failed`,tone:`error`,body:t,actions:r})})}function pt({message:e,onRetry:t}){if(!e.success){let n=e.codexErrorInfo,r=(n?it(n,null):null)??e.result??``,i=r.trim().length>0,a=n!==void 0&&tt(n),o=null;return a&&t?o=(0,U.jsx)(ft,{resultMessageId:e.id,body:r,onRetry:t}):i&&(o=(0,U.jsx)(`div`,{className:`px-4 py-3 mx-2 my-1 rounded-lg bg-destructive/10 border border-destructive/20 text-destructive text-sm whitespace-pre-wrap`,children:dt(r)})),(0,U.jsxs)(U.Fragment,{children:[o,e.durationMs>0?(0,U.jsx)(ut,{durationMs:e.durationMs,prefix:`Failed after`}):null]})}return(0,U.jsx)(ut,{durationMs:e.durationMs})}function mt(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}function ht(e){return typeof e==`string`?e:JSON.stringify(e,null,2)}function gt(e){return e.replace(/<persisted-output>\n?/g,``).replace(/\n?<\/persisted-output>/g,``)}function _t({message:e,localPath:t,isRunning:n=!1}){if(e.kind===`tool`&&e.persisted){let t=gt(ht(e.rawResult??``));return(0,U.jsxs)(`div`,{className:`animate-in fade-in-0 duration-200 rounded-md border border-border bg-muted/30 p-2 space-y-1 text-xs`,children:[(0,U.jsxs)(`div`,{className:`font-medium`,children:[e.toolName,`: output too large (`,mt(e.persisted.originalSize),`) — saved to disk`]}),(0,U.jsx)(`pre`,{className:`text-xs whitespace-pre-wrap overflow-hidden max-h-48`,children:t}),(0,U.jsxs)(`a`,{href:E(e.persisted.filePath),className:`text-blue-500 hover:underline break-all`,target:`_blank`,rel:`noreferrer`,children:[`View full output (`,e.persisted.filePath,`)`]})]})}let r;switch(e.kind){case`assistant_text`:r=(0,U.jsx)(Te,{message:e});break;case`assistant_thinking`:r=(0,U.jsx)(Ee,{message:e});break;case`tool`:r=(0,U.jsx)($,{message:e,isLoading:n,localPath:t});break;case`result`:r=(0,U.jsx)(pt,{message:e});break;default:return null}return(0,U.jsx)(`div`,{className:`animate-in fade-in-0 duration-200`,children:r})}var vt=(0,H.createContext)(null);function yt({children:e,value:t}){return(0,U.jsx)(vt.Provider,{value:t,children:e})}function bt(){return(0,H.useContext)(vt)}var xt=[],Z=O(`SubagentTaskMessage`,()=>e=>({expanded:!1,loading:!1,loaded:!1,children:xt,error:null,setExpanded:t=>e({expanded:t}),setLoading:t=>e({loading:t}),setLoaded:t=>e({loaded:t}),setChildren:t=>e({children:t}),setError:t=>e({error:t})}));function St(e,t){return t||e===`failed`||e===`error`?`destructive`:e===`in_progress`||e===`running`?`active`:`muted`}function Ct(e){if(!e)return``;let t=[],n=(e,n,r)=>{e&&e>0&&t.push(`${e} ${e===1?n:r}`)};return n(e.readCount,`read`,`reads`),n(e.editFileCount,`edit`,`edits`),n(e.bashCount,`cmd`,`cmds`),n(e.searchCount,`search`,`searches`),n(e.otherToolCount,`tool`,`tools`),t.join(` · `)}function wt({subagentType:e,result:t,isError:n,localPath:r}){let i=e||`Agent`,a=St(t?.status,n),o=Ct(t?.toolStats),c=bt(),l=t?.agentId,u=!!(c&&l),d=Z.useScopedStore(e=>e.expanded),m=Z.useScopedStore(e=>e.loading),h=Z.useScopedStore(e=>e.loaded),g=Z.useScopedStore(e=>e.children),_=Z.useScopedStore(e=>e.error),v=Z.useScopedStore(e=>e.setExpanded),y=Z.useScopedStore(e=>e.setLoading),b=Z.useScopedStore(e=>e.setLoaded),x=Z.useScopedStore(e=>e.setChildren),S=Z.useScopedStore(e=>e.setError),C=(0,H.useCallback)(()=>{if(!c||!l)return;let e=!d;v(e),e&&!h&&!m&&(y(!0),S(null),c(l).then(e=>{x(V(e)),b(!0)}).catch(s(e=>S(e.message))).finally(()=>y(!1)))},[c,l,d,h,m,v,y,S,x,b]),w=(0,U.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[u?(0,U.jsx)(oe,{className:f(`size-4 text-muted-icon shrink-0 transition-transform`,d&&`rotate-90`),"aria-hidden":!0}):(0,U.jsx)(F,{className:`size-4 text-muted-icon shrink-0`}),(0,U.jsxs)(`div`,{className:`flex flex-1 items-center gap-2 min-w-0 overflow-hidden`,children:[(0,U.jsx)(`span`,{className:`font-medium text-foreground/80 text-sm truncate`,children:i}),t?.status&&(0,U.jsx)(fe,{tone:a,label:t.status}),t?.totalTokens!=null&&t.totalTokens>0&&(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-xs text-muted-foreground tabular-nums`,children:[(0,U.jsx)(A,{className:`size-3`,"aria-hidden":!0}),Ye(t.totalTokens),` tokens`]}),t?.totalDurationMs!=null&&t.totalDurationMs>0&&(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:he(t.totalDurationMs)}),o&&(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums truncate`,children:o}),m&&(0,U.jsx)(p,{className:`size-3 animate-spin text-muted-foreground`,"aria-label":`Loading`})]})]});return u?(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`button`,{type:`button`,onClick:C,"aria-expanded":d,className:`w-full text-left cursor-pointer`,children:w}),d&&(0,U.jsxs)(`div`,{className:`mt-2 ml-2 border-l-2 border-muted-foreground/20 pl-3 space-y-2`,children:[_&&(0,U.jsx)(`div`,{className:`text-xs text-destructive`,children:_}),!_&&h&&g.length===0&&(0,U.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No subagent activity recorded.`}),g.map(e=>(0,U.jsx)(_t,{message:e,localPath:r??``},e.id))]})]}):w}function Tt({subagentType:e,result:t,isError:n,localPath:r}){return(0,U.jsx)(Z.Provider,{init:void 0,children:(0,U.jsx)(wt,{subagentType:e,result:t,isError:n,localPath:r})})}var Et=[],Q=i()(e=>({byChat:{},setRuns:(t,n)=>e(e=>({byChat:{...e.byChat,[t]:n}}))}));function Dt(e){return t=>t.byChat[e]??Et}function Ot(e){return((c(e)&&Array.isArray(e.content)?e.content:null)??(Array.isArray(e)?e:[])).flatMap(e=>!e||typeof e!=`object`||!(`type`in e)||e.type!==`image`?[]:`data`in e&&typeof e.data==`string`?[{type:`image`,data:e.data,mimeType:`mimeType`in e&&typeof e.mimeType==`string`?e.mimeType:void 0}]:`source`in e&&e.source&&typeof e.source==`object`&&`type`in e.source&&e.source.type===`base64`&&`data`in e.source&&typeof e.source.data==`string`?[{type:`image`,data:e.source.data,mimeType:`media_type`in e.source&&typeof e.source.media_type==`string`?e.source.media_type:void 0}]:[])}function kt({images:e}){return(0,U.jsx)(`div`,{className:`flex flex-col gap-3`,children:e.map((e,t)=>{let n=e.mimeType||`image/png`;return(0,U.jsx)(`div`,{className:`overflow-hidden rounded-lg border border-border bg-muted/20`,children:(0,U.jsx)(`img`,{src:`data:${n};base64,${e.data}`,alt:`Read result ${t+1}`,className:`max-h-[50vh] w-full object-contain bg-background`})},`${n}:${t}`)})})}function $({message:e,isLoading:t=!1,localPath:n,chatId:r=``}){let i=e.result!==void 0,a=!i&&t,o=Q(le(Dt(r))),s=(0,H.useMemo)(()=>{if(e.toolKind===`skill`)return e.input.skill;if(e.toolKind===`glob`)return`Search files ${e.input.pattern===`**/*`?`in all directories`:`matching ${e.input.pattern}`}`;if(e.toolKind===`grep`){let t=e.input.pattern,n=e.input.outputMode;return n===`count`?`Count \`${t}\` occurrences`:n===`content`?`Find \`${t}\` in text`:`Find \`${t}\` in files`}return e.toolKind===`bash`?e.input.description||(e.input.command?pe(e.input.command):`Bash`):e.toolKind===`web_search`?e.input.query||`Web Search`:e.toolKind===`read_file`?`Read ${w(e.input.filePath,n)}`:e.toolKind===`image_view`?`View ${w(e.input.path,n)||e.input.path}`:e.toolKind===`write_file`?`Write ${w(e.input.filePath,n)}`:e.toolKind===`edit_file`?`Edit ${w(e.input.filePath,n)}`:e.toolKind===`delete_file`?`Delete ${w(e.input.filePath,n)}`:e.toolKind===`mcp_generic`?`${me(e.input.tool)} from ${me(e.input.server)}`:e.toolKind===`subagent_task`?e.input.subagentType||e.toolName:e.toolKind===`workflow`?e.input.name??`Workflow`:e.toolName},[e.input,e.toolKind,e.toolName,n]),l=(0,H.useMemo)(()=>e.toolKind===`subagent_task`,[e.toolKind]),u=(0,H.useMemo)(()=>{if(e.toolKind===`skill`)return e.input.skill},[e.input,e.toolKind]),d=e.toolKind===`bash`,f=e.toolKind===`write_file`,p=e.toolKind===`edit_file`,m=e.toolKind===`delete_file`,g=e.toolKind===`read_file`,_=e.toolKind===`image_view`,v=(0,H.useMemo)(()=>{if(typeof e.result==`string`)return e.result;if(!e.result)return``;if(c(e.result)){let t=e.result.content;if(typeof t==`string`)return t}return JSON.stringify(e.result,null,2)},[e.result]),y=(0,H.useMemo)(()=>{if(!g)return[];if(c(e.result)){let t=e.result.blocks;if(Array.isArray(t)){let e=Ot(t);if(e.length>0)return e}}return Ot(e.rawResult)},[g,e.rawResult,e.result]),S=(0,H.useMemo)(()=>{switch(e.toolKind){case`bash`:return e.input.command;case`write_file`:case`delete_file`:return e.input.content;default:return JSON.stringify(e.input,null,2)}},[e]),T;T=d?(0,U.jsxs)(`span`,{className:`flex items-center gap-2 w-full`,children:[(0,U.jsx)(`span`,{children:`Command`}),!!e.input.timeoutMs&&(0,U.jsxs)(`span`,{className:`text-muted-foreground`,children:[`timeout: `,String(e.input.timeoutMs),`ms`]}),!!e.input.runInBackground&&(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:`background`})]}):f?`Contents`:`Input`;let E;E=p?(0,U.jsx)(W,{content:``,isDiff:!0,oldString:e.input.oldString,newString:e.input.newString}):m?(0,U.jsx)(W,{content:e.input.content}):!g&&!f&&!_?(0,U.jsx)(C,{label:T,copyText:S,children:S}):null;let D;if(e.toolKind===`workflow`&&!e.isError){let t=(c(e.result)&&typeof e.result.text==`string`?{taskId:typeof e.result.taskId==`string`?e.result.taskId:void 0,text:e.result.text}:void 0)?.taskId,n=t?o.find(e=>e.taskId===t):void 0;D=(0,U.jsx)(Ue,{name:e.input.name,description:e.input.description,run:n})}else D=e.toolKind===`subagent_task`&&e.result?(0,U.jsx)(Tt,{subagentType:e.input.subagentType,result:e.result,isError:e.isError,localPath:n}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{className:`w-5 h-5 relative flex items-center justify-center`,children:e.isError?(0,U.jsx)(se,{className:`size-4 text-destructive`}):l?(0,U.jsx)(F,{className:`size-4 text-muted-icon`}):e.toolKind===`image_view`?(0,U.jsx)(ve,{className:`size-4 text-muted-icon`}):e.toolKind===`workflow`?(0,U.jsx)(M,{className:`size-4 text-muted-icon`}):(0,U.jsx)(ae,{icon:h(e.toolName),className:`size-4 text-muted-icon`})}),(0,U.jsx)(x,{className:`text-left transition-opacity duration-200 truncate`,children:(0,U.jsx)(De,{animate:a,shimmerWidth:Math.max(20,((u||s)?.length??33)*3),children:u||s})})]});return(0,U.jsx)(ie,{className:`w-full`,children:(0,U.jsx)(re,{expandedContent:(0,U.jsx)(b,{className:`my-4 text-sm`,children:(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[E,i&&g&&!e.isError&&(y.length>0?(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`Image`}),(0,U.jsx)(`div`,{className:`mt-1`,children:(0,U.jsx)(kt,{images:y})})]}):(0,U.jsx)(W,{content:v})),_&&!e.isError&&(0,U.jsx)(Ve,{toolId:e.toolId,path:e.input.path,contentUrl:e.input.contentUrl,mimeType:e.input.mimeType}),f&&!e.isError&&(0,U.jsx)(W,{content:e.input.content}),i&&!g&&!(_&&!e.isError)&&!(f&&!e.isError)&&!(p&&!e.isError)&&!(m&&!e.isError)&&(0,U.jsx)(C,{label:e.isError?`Error`:`Result`,copyText:v,children:v})]})}),children:D})})}export{A as S,Te as _,_t as a,F as b,st as c,Ye as d,Je as f,Ee as g,De as h,yt as i,qe as l,Re as m,Dt as n,pt as o,Ke as p,Q as r,dt as s,$ as t,Ge as u,V as v,M as x,ye as y};
|