@frumu/tandem-panel 0.5.3 → 0.5.5

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.
Files changed (58) hide show
  1. package/bin/setup.js +21 -4
  2. package/dist/assets/AutomationsPage-6mRHsh9V.js +946 -0
  3. package/dist/assets/BugMonitorPage-B9mcxV8k.js +4 -0
  4. package/dist/assets/ChannelsPage-oJ5a717t.js +1 -0
  5. package/dist/assets/ChatInterfacePanel-3nvwn0cJ.js +1 -0
  6. package/dist/assets/ChatPage-CGKFC9ev.js +1 -0
  7. package/dist/assets/CodingWorkflowsPage-DosUtoeO.js +8 -0
  8. package/dist/assets/ControlPanelDialogs-BBIPHXnw.js +1 -0
  9. package/dist/assets/DashboardPage-Cv9_TUZQ.js +1 -0
  10. package/dist/assets/ExperimentsPage-DuYHzo7d.js +84 -0
  11. package/dist/assets/FilesPage-NAInb3WU.js +1 -0
  12. package/dist/assets/IntentPlannerPage-BwlF9wfW.js +5 -0
  13. package/dist/assets/LazyJson-DYncL_RR.js +1 -0
  14. package/dist/assets/MarketplacePage-Wo7biaBa.js +1 -0
  15. package/dist/assets/McpToolAllowlistEditor-B3qCkiFT.js +1 -0
  16. package/dist/assets/MemoryImportDialog-BWT93PW1.js +1 -0
  17. package/dist/assets/MemoryPage-gSBH1OKG.js +1 -0
  18. package/dist/assets/OrchestratorPage-HDyjjwF-.js +3 -0
  19. package/dist/assets/PacksPage-BWnL4dRB.js +3 -0
  20. package/dist/assets/PlannerDiagnosticsPanel-VyacxaCM.js +1 -0
  21. package/dist/assets/ProviderModelSelector-B_IE0-e7.js +1 -0
  22. package/dist/assets/RunsPage-B6ttNeUJ.js +1 -0
  23. package/dist/assets/SettingsPage-DhAKDQHw.js +5 -0
  24. package/dist/assets/TaskBoard-DSRrmiyQ.js +1 -0
  25. package/dist/assets/TeamsPage-CwMnVES9.js +4472 -0
  26. package/dist/assets/TimezoneField-DKINpKxU.js +1 -0
  27. package/dist/assets/WorkflowStudioPage-CyWDhEEE.js +1854 -0
  28. package/dist/assets/WorkflowsPage-BWGWH8uD.js +2 -0
  29. package/dist/assets/api-CpR5ozpc.js +1 -0
  30. package/dist/assets/chatPageHelpers-D-NhHk4M.js +1 -0
  31. package/dist/assets/explorerHandoff-KpFRPNQc.js +1 -0
  32. package/dist/assets/format-CimuGHiH.js +1 -0
  33. package/dist/assets/fullcalendar-Bn75j0xM.js +1 -0
  34. package/dist/assets/index-DAWzCKcg.css +1 -0
  35. package/dist/assets/index-picB46b5.js +3 -0
  36. package/dist/assets/messages-AWZpX-Rw.js +3 -0
  37. package/dist/assets/motion-B3ZE8SGR.js +9 -0
  38. package/dist/assets/plannerShared-1kHFyAp-.js +1 -0
  39. package/dist/assets/preact-vendor-DaCG_P2o.js +1 -0
  40. package/dist/assets/react-query-BIbNygEJ.js +1 -0
  41. package/dist/assets/sse-B1wvyjPI.js +2 -0
  42. package/dist/assets/ui-CV-Z6sqF.js +1 -0
  43. package/dist/assets/useEngineStream-ChEkuUVV.js +1 -0
  44. package/dist/assets/vendor-DSaYtO9f.js +156 -0
  45. package/dist/assets/workflowStability-Dsk2DR6F.js +2 -0
  46. package/dist/index.html +10 -7
  47. package/lib/automations/workflow-list.js +147 -0
  48. package/lib/setup/control-panel-preferences.js +4 -0
  49. package/package.json +3 -3
  50. package/server/routes/capabilities.js +1 -0
  51. package/server/routes/knowledgebase.js +7 -1
  52. package/dist/assets/index-D6sUkBw6.css +0 -1
  53. package/dist/assets/index-gUgdIB3_.js +0 -7379
  54. package/dist/assets/motion-CBnf8hfk.js +0 -9
  55. package/dist/assets/preact-vendor-B239Onrg.js +0 -1
  56. package/dist/assets/react-query-_hsOQSt5.js +0 -1
  57. package/dist/assets/vendor-DeUDWccs.js +0 -156
  58. /package/dist/assets/{markdown-Dd89TVib.js → markdown-DJurGVIJ.js} +0 -0
@@ -0,0 +1,5 @@
1
+ import{C as e,E as t,g as n,h as r,v as i,x as a}from"./fullcalendar-Bn75j0xM.js";import{a as o,n as s,t as c}from"./react-query-BIbNygEJ.js";import{i as l,n as u,r as d}from"./motion-B3ZE8SGR.js";import{d as f,f as p,m,n as h,r as g,t as _,u as v,y}from"./ui-CV-Z6sqF.js";import{a as b,d as x,f as S,i as C,r as w,s as T,u as E}from"./index-picB46b5.js";import{n as D,t as O}from"./McpToolAllowlistEditor-B3qCkiFT.js";import{t as k}from"./ProviderModelSelector-B_IE0-e7.js";import{r as A}from"./plannerShared-1kHFyAp-.js";var j=`/workspace/repos`,M=`/workspace/aca/repos`,N=`/workspace/tandem-data`;function P(e){let t=String(e||``).trim().replace(/\.git$/i,``).split(/[/:]/).map(e=>e.trim()).filter(Boolean);return t[t.length-1]||``}function F(e){let t=P(e);return t?`${j}/${t}`:j}function I(e){let t=String(e||``).trim();return t===`/workspace/repos`?`Shared Coder checkouts`:t.startsWith(`/workspace/repos/`)?`Synced repo checkout`:t===`/workspace/aca/repos`?`Coder compatibility mount`:t.startsWith(`/workspace/aca/repos/`)?`Same repo via ACA path`:t===`/workspace/tandem-data`?`Runtime data, not source code`:``}function L(e,t){let n=String(e||``).trim();if(!n)return`Select the synced repo folder before enabling hosted Bug Monitor triage.`;if(n===`/workspace/repos`)return`Select the repo folder under ${j}, not the parent folder.`;if(n===`/workspace/aca/repos`)return`Select the repo folder under ${M}, not the parent folder.`;if(n===`/workspace/tandem-data`||n.startsWith(`/workspace/tandem-data/`))return`${N} stores runtime state. Bug Monitor needs the source checkout under ${j}.`;let r=P(t);return r&&(n.startsWith(`/workspace/repos/`)||n.startsWith(`/workspace/aca/repos/`))&&n.split(`/`).filter(Boolean).pop()!==r?`Target repo looks like \`${r}\`, but the selected folder is \`${n}\`. Confirm this is the intended checkout.`:``}var R=`tandem_control_panel_pending_provider_oauth`;function ee(){if(typeof window>`u`)return{};try{let e=window.sessionStorage.getItem(R)||``;if(!e)return{};let t=JSON.parse(e);return!t||typeof t!=`object`?{}:Object.fromEntries(Object.entries(t).map(([e,t])=>[String(e||``).trim().toLowerCase(),String(t||``).trim()]).filter(([e,t])=>!!e&&!!t))}catch{return{}}}function z(e){if(!(typeof window>`u`))try{let t=Object.fromEntries(Object.entries(e||{}).map(([e,t])=>[String(e||``).trim().toLowerCase(),String(t||``).trim()]).filter(([e,t])=>!!e&&!!t));if(!Object.keys(t).length){window.sessionStorage.removeItem(R);return}window.sessionStorage.setItem(R,JSON.stringify(t))}catch{}}var B=new Set([`openai`,`openai-codex`,`openrouter`,`anthropic`,`ollama`,`groq`,`mistral`,`together`,`azure`,`bedrock`,`vertex`,`copilot`,`cohere`]),V=`openai-codex`,H=[`telegram`,`discord`,`slack`];function U(e){let t=String(e||``).trim().toLowerCase();return t.startsWith(`mcp_header::`)||t.startsWith(`channel::`)}var W=[{label:`File`,tools:[`read`,`glob`,`ls`,`list`,`grep`,`codesearch`,`search`]},{label:`Web`,tools:[`websearch`,`webfetch`,`webfetch_html`]},{label:`Terminal`,tools:[`bash`,`write`,`edit`,`apply_patch`]},{label:`Memory`,tools:[`memory_search`,`memory_store`,`memory_list`]},{label:`Other`,tools:[`skill`,`task`,`question`,`pack_builder`]}],G=`tandem.workflow_planner`,te=[`websearch`,`webfetch`,`webfetch_html`,`memory_search`,`memory_store`,`memory_list`];function K(e){try{return new URL(e)}catch{return null}}function ne(e){return String(e||``).trim().toLowerCase().replace(/[^a-z0-9_-]+/g,`-`).replace(/^-+|-+$/g,``)||`mcp-server`}function re(e){let t=K(e);if(!t)return``;let n=String(t.hostname||``).toLowerCase();if(!n)return``;if(n.endsWith(`composio.dev`))return`composio`;let r=n.split(`.`).filter(Boolean);return r.length?ne([`backend`,`api`,`mcp`,`www`].includes(r[0])&&r[1]||r[0]):``}function q(e){let t=K(e);return t?String(t.hostname||``).toLowerCase().endsWith(`composio.dev`):!1}function ie(e){let t=K(e);if(!t)return!1;let n=String(t.hostname||``).toLowerCase();return n===`api.githubcopilot.com`||n.endsWith(`.githubcopilot.com`)}function ae(e){let t=K(e);if(!t)return!1;let n=String(t.hostname||``).toLowerCase();return n===`mcp.notion.com`||n.endsWith(`.notion.com`)}function J(e,t){return String(e||``).trim().toLowerCase()===`notion`||ae(t)?`Notion uses browser OAuth. Save the server, finish the Notion sign-in in your browser, then come back and click Mark sign-in complete. Token paste is not the right flow for this MCP.`:`This MCP server uses browser OAuth. Save it, complete the authorization page that opens in your browser, then come back and finish the connection in Tandem.`}function oe(e){return e.map(e=>({key:String(e?.key||``).trim(),value:String(e?.value||``).trim()}))}function se(e,t){let n={...e};for(let e of oe(t))!e.key||!e.value||(n[e.key]=e.value);return n}function ce({authMode:e,token:t,customHeader:n,transport:r}){let i=String(t||``).trim();if(e===`oauth`||!i||e===`none`)return{};if(e===`custom`){let e=String(n||``).trim();if(!e)throw Error(`Custom header name is required.`);return{[e]:i}}return e===`x-api-key`?{"x-api-key":i}:e===`bearer`?{Authorization:`Bearer ${i.replace(/^bearer\s+/i,``).trim()}`}:q(r)?{"x-api-key":i}:{Authorization:`Bearer ${i.replace(/^bearer\s+/i,``).trim()}`}}function Y(e,t,n,r){return e===`oauth`?`OAuth handoff: Tandem will open the server authorization flow on connect.`:!String(t||``).trim()||e===`none`?`No auth header will be sent.`:e===`custom`?n?`Header preview: ${n}: <token>`:`Set a custom header name.`:e===`x-api-key`?`Header preview: x-api-key: <token>`:e===`bearer`?`Header preview: Authorization: Bearer <token>`:q(r)?`Auto mode: selected x-api-key for this endpoint`:`Auto mode: using Authorization Bearer token`}function le(e,t=``){if(!e||typeof e!=`object`)return null;let n=e,r=String(n.name||t||``).trim();if(!r)return null;let i=n.last_auth_challenge||n.lastAuthChallenge||null;return{name:r,transport:String(n.transport||``).trim(),authKind:String(n.auth_kind||n.authKind||``).trim().toLowerCase(),connected:!!n.connected,enabled:n.enabled!==!1,lastError:String(n.last_error||n.lastError||``).trim(),lastAuthChallenge:i&&typeof i==`object`?i:null,authorizationUrl:String(n.authorization_url||n.authorizationUrl||``).trim(),headers:n.headers&&typeof n.headers==`object`?n.headers:{},toolCache:Array.isArray(n.tool_cache||n.toolCache)?n.tool_cache||n.toolCache:[],allowedTools:Array.isArray(n.allowed_tools||n.allowedTools)?(n.allowed_tools||n.allowedTools).map(e=>String(e||``).trim()).filter(Boolean):null}}function ue(e,t,n){let r=String(t||``).trim().toLowerCase(),i=String(n||``).trim().replace(/\/+$/,``).toLowerCase(),a=e.servers.find(e=>{let t=String(e.transportUrl||``).trim().replace(/\/+$/,``).toLowerCase(),n=String(e.slug||``).trim().toLowerCase(),a=String(e.serverConfigName||``).trim().toLowerCase();return i&&t&&t===i||i&&t&&t.includes(i)||i&&t&&i.includes(t)||!!r&&(n===r||a===r)});return String(a?.authKind||``).trim().toLowerCase()}function de(e){return Array.isArray(e)?e.map(e=>le(e)).filter(e=>!!e).sort((e,t)=>e.name.localeCompare(t.name)):!e||typeof e!=`object`?[]:Array.isArray(e.servers)?e.servers.map(e=>le(e)).filter(e=>!!e).sort((e,t)=>e.name.localeCompare(t.name)):Object.entries(e).map(([e,t])=>le(t&&typeof t==`object`?t:{transport:String(t||``)},e)).filter(e=>!!e).sort((e,t)=>e.name.localeCompare(t.name))}function fe(e){return(Array.isArray(e)?e:Array.isArray(e?.tools)?e.tools:[]).map(e=>typeof e==`string`?e:!e||typeof e!=`object`?``:String(e.namespaced_name||e.namespacedName||e.id||e.tool_name||e.toolName||``).trim()).filter(Boolean)}function pe(e){let t=e&&typeof e==`object`?e:{},n=Array.isArray(t.servers)?t.servers:[];return{generatedAt:String(t.generated_at||``).trim(),count:Number.isFinite(Number(t.count))?Number(t.count):n.length,servers:n.map(e=>!e||typeof e!=`object`?null:{slug:String(e.slug||``).trim(),name:String(e.name||e.slug||``).trim(),description:String(e.description||``).trim(),transportUrl:String(e.transport_url||``).trim(),serverConfigName:String(e.server_config_name||e.slug||``).trim(),documentationUrl:String(e.documentation_url||``).trim(),directoryUrl:String(e.directory_url||``).trim(),toolCount:Number.isFinite(Number(e.tool_count))?Number(e.tool_count):0,requiresAuth:e.requires_auth!==!1,requiresSetup:!!e.requires_setup,authKind:String(e.auth_kind||e.authKind||``).trim().toLowerCase()}).filter(e=>!!e&&!!e.slug&&!!e.transportUrl).sort((e,t)=>e.name.localeCompare(t.name))}}function me(e,t){let n=t&&typeof t==`object`?t:{};return{botToken:``,allowedUsers:Array.isArray(n.allowed_users)?n.allowed_users.join(`, `):``,mentionOnly:n.mention_only!==!1&&e===`discord`?!0:!!n.mention_only,strictKbGrounding:!!n.strict_kb_grounding,guildId:String(n.guild_id||``).trim(),channelId:String(n.channel_id||``).trim(),modelProviderId:String(n.model_provider_id||``).trim(),modelId:String(n.model_id||``).trim(),styleProfile:String(n.style_profile||`default`).trim()||`default`,securityProfile:String(n.security_profile||`operator`).trim()||`operator`}}function he(){return{enabled_tools:[],disabled_tools:[],enabled_mcp_servers:[],enabled_mcp_tools:[]}}function X(e){return Array.from(new Set(e.map(e=>e.trim()).filter(Boolean)))}function ge(e){let t=e&&typeof e==`object`?e:{};return{enabled_tools:Array.isArray(t.enabled_tools)?X(t.enabled_tools.map(e=>String(e))):[],disabled_tools:Array.isArray(t.disabled_tools)?X(t.disabled_tools.map(e=>String(e))):[],enabled_mcp_servers:Array.isArray(t.enabled_mcp_servers)?X(t.enabled_mcp_servers.map(e=>String(e))):[],enabled_mcp_tools:Array.isArray(t.enabled_mcp_tools)?X(t.enabled_mcp_tools.map(e=>String(e))):[]}}function _e(e){let t=e&&typeof e==`object`?e:{};return(Array.isArray(t.scopes)?t.scopes:[]).map(e=>{if(!e||typeof e!=`object`)return null;let t=String(e.scope_id||e.scopeId||``).trim();return t?{scope_id:t,scope_kind:String(e.scope_kind||e.scopeKind||``).trim(),session_count:Number.isFinite(Number(e.session_count))?Number(e.session_count):Number.isFinite(Number(e.sessionCount))?Number(e.sessionCount):0,sender_count:Number.isFinite(Number(e.sender_count))?Number(e.sender_count):Number.isFinite(Number(e.senderCount))?Number(e.senderCount):0,last_seen_at_ms:Number.isFinite(Number(e.last_seen_at_ms))?Number(e.last_seen_at_ms):Number.isFinite(Number(e.lastSeenAtMs))?Number(e.lastSeenAtMs):0}:null}).filter(e=>!!e).sort((e,t)=>e.last_seen_at_ms===t.last_seen_at_ms?e.scope_id.localeCompare(t.scope_id):t.last_seen_at_ms-e.last_seen_at_ms)}function ve(e){let t=[];return e.scope_kind&&t.push(e.scope_kind),t.push(e.scope_id),e.session_count>1?t.push(`${e.session_count} sessions`):e.session_count===1&&t.push(`1 session`),t.join(` · `)}function Z(e,t){let n=e.enabled_tools.filter(e=>e!==G);return t===`tandem.workflow_planner`?e.disabled_tools.includes(t)?!1:e.enabled_tools.includes(t):e.disabled_tools.includes(t)?!1:n.length===0||n.includes(t)}function ye(e,t,n){let r=e.disabled_tools.filter(e=>e!==t),i=e.enabled_tools.filter(e=>e!==G);return t===`tandem.workflow_planner`?n?{...e,disabled_tools:r,enabled_tools:X([...e.enabled_tools,t])}:{...e,disabled_tools:X([...r,t]),enabled_tools:e.enabled_tools.filter(e=>e!==t)}:n?{...e,disabled_tools:r,enabled_tools:i.length>0?X([...e.enabled_tools,t]):e.enabled_tools}:{...e,disabled_tools:X([...r,t]),enabled_tools:i.length>0?e.enabled_tools.filter(e=>e!==t):e.enabled_tools}}function Q(e,t,n){let r=e.enabled_mcp_servers.filter(e=>e!==t),i=`mcp.${D(t)}.`;return{...e,enabled_mcp_servers:n?X([...r,t]):r,enabled_mcp_tools:n?e.enabled_mcp_tools:e.enabled_mcp_tools.filter(e=>!e.startsWith(i))}}function be(e,t,n){if(!e.enabled_mcp_servers.includes(t))return null;let r=`mcp.${D(t)}.`,i=e.enabled_mcp_tools.filter(e=>e.startsWith(r));return i.length?n.some(e=>e.startsWith(r))?i:i.map(e=>e.slice(r.length)).filter(Boolean):null}function xe(e,t,n,r){let i=`mcp.${D(t)}.`;if(!e.enabled_mcp_servers.includes(t))return{...e,enabled_mcp_tools:e.enabled_mcp_tools.filter(e=>!e.startsWith(i))};let a=e=>{let t=String(e||``).trim();return t?t.startsWith(`mcp.`)?t:`${i}${t}`:``},o=X(n.map(a).filter(Boolean)),s=e.enabled_mcp_tools.filter(e=>!e.startsWith(i)),c=r===null?o:X(r.map(a).filter(Boolean));return{...e,enabled_mcp_tools:X([...s,...c])}}function Se(e,t){return e===`public_demo`?te.includes(t):!0}function Ce(e,t,n){return Se(n,t)&&Z(e,t)}function we(e){let t=String(e||``).split(`,`).map(e=>e.trim()).filter(Boolean);return t.length?t:[`*`]}function Te(e){let t=(Array.isArray(e)?e:String(e||``).split(`,`)).map(e=>String(e||``).trim()).filter(Boolean);return t.length?Array.from(new Set(t)):[`*`]}function Ee(e,t){let n=Te(e).slice().sort(),r=Te(t).slice().sort();return n.length===r.length?n.every((e,t)=>e===r[t]):!1}function De(e,t){let n=t&&typeof t==`object`?t:{},r=Te(n.allowed_users);return!!n.has_token||r.some(e=>e!==`*`)||!!n.mention_only||!!n.strict_kb_grounding||!!String(n.guild_id||``).trim()||!!String(n.channel_id||``).trim()||!!String(n.model_provider_id||``).trim()||!!String(n.model_id||``).trim()||String(n.style_profile||`default`).trim()!==`default`||String(n.security_profile||`operator`).trim()!==`operator`}function Oe(e,t,n){let r=me(e,n);return!String(t.botToken||``).trim()&&Ee(t.allowedUsers,r.allowedUsers)&&!!t.mentionOnly==!!r.mentionOnly&&!!t.strictKbGrounding==!!r.strictKbGrounding&&String(t.guildId||``).trim()===String(r.guildId||``).trim()&&String(t.channelId||``).trim()===String(r.channelId||``).trim()&&String(t.modelProviderId||``).trim()===String(r.modelProviderId||``).trim()&&String(t.modelId||``).trim()===String(r.modelId||``).trim()&&String(t.styleProfile||`default`).trim()===String(r.styleProfile||`default`).trim()&&String(t.securityProfile||`operator`).trim()===String(r.securityProfile||`operator`).trim()}function ke(e,t){let n=String(e?.catalog_source||``).trim().toLowerCase();return n===`remote`&&t>0?{tone:`ok`,text:`${t} models`}:n===`config`&&t>0?{tone:`info`,text:`configured models`}:{tone:`warn`,text:`manual entry`}}function Ae(e,t){return String(e?.catalog_message||``).trim()||`Default model: ${t||`none`}`}var je={dashboard:`Command status, activity, and fast paths.`,chat:`Session-driven conversation, uploads, and live responses.`,planner:`Advanced long-horizon planning and governed handoff.`,studio:`Advanced template-first workflow builder.`,automations:`Reusable routines, approvals, and execution history.`,experiments:`Opt-in automation experiments, optimization campaigns, and team approvals.`,coding:`ACA intake, task launchers, and coding runs.`,agents:`Reusable agent roles and workflow drafts.`,orchestrator:`Task board planning, approvals, and execution.`,memory:`Searchable memory records and operational context.`,files:`Managed files plus the hosted knowledgebase upload surface.`,runs:`Live operations overview with queue state and per-run inspection.`,settings:`Provider defaults, themes, and runtime diagnostics.`};function Me({client:t,api:l,toast:u,navigate:d,currentRoute:f,providerStatus:p,identity:m,themes:h,setTheme:g,themeId:_,refreshProviderStatus:v,refreshIdentityStatus:y,navigation:S}){let T=o(),E=r(null),[D,O]=i({}),[k,j]=i(String(m?.botName||`Tandem`)),[M,N]=i(String(m?.botAvatarUrl||``)),[P,R]=i(`Control Center`),[W,G]=i(p?.needsOnboarding?`providers`:S?.acaMode?`navigation`:`install`),[te,q]=i(()=>S?.routeVisibility||w(!!S?.acaMode)),[ae,oe]=i(``),[le,X]=i(``),[ve,Z]=i(`auto`),[ye,Q]=i(``),[be,xe]=i(``),[Se,Ce]=i(`10000`),[Te,Ee]=i(``),[De,Oe]=i(``),[ke,Ae]=i(`autonomous AI agentic workflows`),[Me,Ne]=i(null),[Pe,Fe]=i(`multi`),[Ie,Le]=i(``),[Re,ze]=i(!1),[Be,Ve]=i(!1),[He,Ue]=i(!0),[We,Ge]=i(!1),[Ke,qe]=i(()=>ee()),[Je,Ye]=i(`custom`),[Xe,Ze]=i(``),[Qe,$e]=i(``),[et,tt]=i(``),[nt,rt]=i(!0),[it,at]=i(``),[ot,st]=i({}),ct=r({telegram:!1,discord:!1,slack:!1}),[lt,ut]=i({telegram:``,discord:``,slack:``}),[dt,ft]=i({telegram:!1,discord:!1,slack:!1}),[pt,mt]=i({}),[ht,gt]=i(!1),[_t,vt]=i(``),[yt,bt]=i(``),[xt,St]=i(`none`),[Ct,wt]=i(``),[Tt,Et]=i(``),[Dt,Ot]=i(``),[kt,At]=i([]),[jt,Mt]=i(!0),[Nt,Pt]=i(``),[Ft,It]=i(`manual`),[Lt,Rt]=i(``),[zt,Bt]=i(!1),[Vt,Ht]=i(!1),[Ut,Wt]=i(``),[Gt,Kt]=i(``),[qt,Jt]=i(``),[Yt,Xt]=i(`auto`),[Zt,Qt]=i(``),[$t,en]=i(``),[tn,nn]=i(!0),[rn,an]=i(!1),[on,sn]=i(!0),[cn,ln]=i(`[]`),[un,dn]=i(``),[fn,pn]=i(``),[mn,hn]=i(``),[gn,_n]=i(``),[vn,yn]=i(``),[bn,xn]=i(null),[Sn,Cn]=i(``),[wn,Tn]=i(!1),[En,Dn]=i(0),[On,kn]=i(null),[An,jn]=i(!1),[Mn,Nn]=i(``),[Pn,Fn]=i(``),In=r(null),Ln=r(null),[Rn,zn]=i(``);e(()=>{z(Ke)},[Ke]);let Bn=async()=>{let e=t?.identity;return e?.get?e.get():l(`/api/engine/config/identity`,{method:`GET`})},Vn=async e=>{let n=t?.identity;return n?.patch?n.patch(e):l(`/api/engine/config/identity`,{method:`PATCH`,body:JSON.stringify(e)})},Hn=s({queryKey:[`settings`,`identity`,`config`],queryFn:()=>Bn().catch(()=>({identity:{}}))});e(()=>{let e=Hn.data?.identity?.bot||{},t=e?.aliases||{},n=String(e?.canonicalName||e?.canonical_name||m?.botName||`Tandem`).trim(),r=String(e?.avatarUrl||e?.avatar_url||m?.botAvatarUrl||``).trim(),i=String(t?.controlPanel||t?.control_panel||``).trim();j(n||`Tandem`),N(r),R(i||`Control Center`)},[m?.botAvatarUrl,m?.botName,Hn.data]),e(()=>{f===`mcp`&&G(`mcp`),f===`channels`&&G(`channels`),f===`bug-monitor`&&G(`bug_monitor`)},[f]);let Un=s({queryKey:[`settings`,`install`,`profile`],queryFn:()=>l(`/api/install/profile`,{method:`GET`}).catch(()=>null),refetchInterval:3e4}),Wn=s({queryKey:[`settings`,`install`,`config`],queryFn:()=>l(`/api/control-panel/config`,{method:`GET`}).catch(()=>null)});e(()=>{let e=Wn.data?.config||null;if(e)try{oe(JSON.stringify(e,null,2)),X(``)}catch{X(`Loaded config could not be rendered as JSON.`)}},[Wn.data]),e(()=>{if(f===`settings`){if(p?.needsOnboarding){G(`providers`),Ue(!0);return}if(!S?.acaMode){G(`install`);return}G(Un.data?.aca_integration!==!0||Un.data?.control_panel_config_ready!==!0?`install`:`navigation`)}},[f,S?.acaMode,p?.needsOnboarding,Un.data?.aca_integration,Un.data?.control_panel_config_ready]),e(()=>{W===`providers`&&Ue(!0)},[W]);let Gn=W===`providers`||W===`channels`||W===`bug_monitor`,Kn=s({queryKey:[`settings`,`providers`,`catalog`],enabled:Gn,staleTime:300*1e3,queryFn:()=>t.providers.catalog().catch(()=>({all:[],connected:[]}))}),$=s({queryKey:[`settings`,`providers`,`config`],queryFn:()=>t.providers.config().catch(()=>({default:``,providers:{}}))}),qn=s({queryKey:[`settings`,`providers`,`auth`],queryFn:()=>t.providers.authStatus().catch(()=>({providers:{}})),refetchInterval:15e3}),Jn=s({queryKey:[`settings`,`system`,`health`],queryFn:()=>l(`/api/system/health`,{method:`GET`}).catch(()=>null),refetchInterval:3e4}),Yn=n(()=>A({providerCatalog:Kn.data,providerConfig:$.data,defaultProvider:String($.data?.default||``).trim(),defaultModel:String($.data?.providers?.[String($.data?.default||``).trim()]?.default_model||$.data?.providers?.[String($.data?.default||``).trim()]?.defaultModel||``).trim(),includeUnconfiguredProviders:!0}),[Kn.data,$.data]),Xn=n(()=>{let e=qn.data?.providers;return e&&typeof e==`object`?e:qn.data&&typeof qn.data==`object`?qn.data:{}},[qn.data]),Zn=Jn.data?.localEngine===!0,Qn=Un.data?.hosted_managed===!0;e(()=>{let e=String(Jn.data?.workspace_root||``).trim();e&&Cn(t=>t.trim()?t:e)},[Jn.data?.workspace_root]);let $n=n(()=>{let e=String($.data?.default||``).trim();return{provider:e,model:String($.data?.providers?.[e]?.default_model||$.data?.providers?.[e]?.defaultModel||``).trim()}},[$.data]),er=n(()=>$.data?.providers||{},[$.data?.providers]),tr=n(()=>Object.entries(er).filter(([e])=>{let t=e.trim().toLowerCase();return t&&!B.has(t)&&!U(t)}).map(([e,t])=>({id:e,url:String(t?.url||``).trim(),model:String(t?.default_model||t?.defaultModel||``).trim(),isDefault:String($.data?.default||``).trim().toLowerCase()===e.trim().toLowerCase()})),[er,$.data?.default]),nr=s({queryKey:[`settings`,`search`,`config`],queryFn:()=>l(`/api/system/search-settings`,{method:`GET`}).catch(()=>null)}),rr=s({queryKey:[`settings`,`scheduler`,`config`],queryFn:()=>l(`/api/system/scheduler-settings`,{method:`GET`}).catch(()=>null)});e(()=>{let e=nr.data?.settings||null;e&&(Z(String(e.backend||`auto`).trim()||`auto`),Q(String(e.tandem_url||``).trim()),xe(String(e.searxng_url||``).trim()),Ce(String(e.timeout_ms||1e4)))},[nr.data]),e(()=>{let e=rr.data?.settings||null;e&&(Fe(String(e.mode||`multi`).trim()||`multi`),Le(e.max_concurrent_runs==null?``:String(e.max_concurrent_runs)))},[rr.data]);let ir=s({queryKey:[`settings`,`browser`,`status`],queryFn:()=>l(`/api/engine/browser/status`,{method:`GET`}).catch(()=>null),refetchInterval:3e4}),[ar,or]=i(null),sr=c({mutationFn:()=>l(`/api/engine/browser/install`,{method:`POST`}),onSuccess:async()=>{u(`ok`,`Browser sidecar installed on the engine host.`),await ir.refetch()},onError:e=>u(`err`,e instanceof Error?e.message:String(e))}),cr=c({mutationFn:()=>l(`/api/engine/browser/smoke-test`,{method:`POST`,body:JSON.stringify({url:`https://example.com`})}),onSuccess:async e=>{or(e),u(`ok`,`Browser smoke test passed.`),await ir.refetch()},onError:e=>{or(null),u(`err`,e instanceof Error?e.message:String(e))}}),lr=c({mutationFn:e=>l(`/api/engine/worktree/cleanup`,{method:`POST`,body:JSON.stringify({repo_root:e.repoRoot,dry_run:e.dryRun,remove_orphan_dirs:!0})}),onMutate:()=>{kn(null)},onSuccess:e=>{kn(e);let t=(e.cleaned_worktrees?.length||0)+(e.orphan_dirs_removed?.length||0),n=e.failures?.length||0;u(n?`warn`:e.dry_run?`info`:`ok`,e.dry_run?`Found ${e.stale_paths?.length||0} stale worktrees and ${e.orphan_dirs?.length||0} orphan directories.`:n?`Cleanup removed ${t} entries with ${n} failures.`:`Cleanup removed ${t} stale worktree entries.`)},onError:e=>{kn(null),u(`err`,e instanceof Error?e.message:String(e))}});e(()=>{if(!lr.isPending){Dn(0);return}let e=window.setInterval(()=>{Dn(e=>e+1)},800);return()=>window.clearInterval(e)},[lr.isPending]);let ur=s({queryKey:[`settings`,`mcp`,`servers`],queryFn:()=>t.mcp.list().catch(()=>({})),refetchInterval:1e4}),dr=s({queryKey:[`settings`,`mcp`,`tools`],queryFn:()=>t.mcp.listTools().catch(()=>[]),refetchInterval:15e3}),fr=s({queryKey:[`settings`,`mcp`,`catalog`],queryFn:()=>l(`/api/engine/mcp/catalog`,{method:`GET`}).catch(()=>null),refetchInterval:6e4}),pr=s({queryKey:[`settings`,`bug-monitor`,`config`],queryFn:()=>l(`/api/engine/config/bug-monitor`,{method:`GET`}).catch(()=>({bug_monitor:{}}))}),mr=s({queryKey:[`settings`,`bug-monitor`,`status`],queryFn:()=>l(`/api/engine/bug-monitor/status`,{method:`GET`}).catch(()=>({status:{}})),refetchInterval:1e4}),hr=s({queryKey:[`settings`,`bug-monitor`,`drafts`],queryFn:()=>l(`/api/engine/bug-monitor/drafts?limit=10`,{method:`GET`}).catch(()=>({drafts:[]})),refetchInterval:15e3}),gr=s({queryKey:[`settings`,`bug-monitor`,`incidents`],queryFn:()=>l(`/api/engine/bug-monitor/incidents?limit=10`,{method:`GET`}).catch(()=>({incidents:[]})),refetchInterval:1e4}),_r=s({queryKey:[`settings`,`bug-monitor`,`posts`],queryFn:()=>l(`/api/engine/bug-monitor/posts?limit=10`,{method:`GET`}).catch(()=>({posts:[]})),refetchInterval:15e3}),vr=s({queryKey:[`settings`,`bug-monitor`,`intake-keys`],queryFn:()=>l(`/api/engine/bug-monitor/intake/keys`,{method:`GET`}).catch(()=>({keys:[]})),refetchInterval:3e4}),yr=s({queryKey:[`settings`,`bug-monitor`,`workspace-browser`,Mn],enabled:An&&!!Mn,queryFn:()=>l(`/api/orchestrator/workspaces/list?dir=${encodeURIComponent(Mn)}`,{method:`GET`})}),br=s({queryKey:[`settings`,`channels`,`config`],queryFn:()=>t.channels.config().catch(()=>({})),refetchInterval:15e3}),xr=s({queryKey:[`settings`,`channels`,`status`],queryFn:()=>t.channels.status().catch(()=>({})),refetchInterval:6e3}),Sr=s({queryKey:[`settings`,`channels`,`scopes`],queryFn:async()=>{let e=await Promise.all(H.map(async e=>[e,_e(await l(`/api/engine/channels/${e}/scopes`,{method:`GET`}).catch(()=>({scopes:[]})))]));return Object.fromEntries(e)},refetchInterval:15e3}),Cr=s({queryKey:[`settings`,`channels`,`tool-preferences`,lt],queryFn:async()=>{let e=await Promise.all(H.map(async e=>{let t=String(lt[e]||``).trim();return[e,ge(await l(`/api/engine/channels/${e}/tool-preferences${t?`?scope_id=${encodeURIComponent(t)}`:``}`,{method:`GET`}).catch(()=>he()))]}));return Object.fromEntries(e)},refetchInterval:15e3}),wr=c({mutationFn:async({providerId:e,modelId:n})=>t.providers.setDefaults(e,n),onSuccess:async()=>{u(`ok`,`Updated provider defaults.`),await Promise.all([T.invalidateQueries({queryKey:[`settings`,`providers`]}),v()])},onError:e=>u(`err`,e instanceof Error?e.message:String(e))}),Tr=()=>String($.data?.providers?.[`openai-codex`]?.default_model||$.data?.providers?.[`openai-codex`]?.defaultModel||`gpt-5.4`).trim()||`gpt-5.4`,Er=async()=>{await t.providers.setDefaults(V,Tr())},Dr=c({mutationFn:async({providerId:e,url:n,modelId:r,apiKey:i,makeDefault:a})=>{let o=e.trim().toLowerCase(),s=n.trim(),c=r.trim();if(!o)throw Error(`Custom provider ID is required.`);if(!s)throw Error(`Custom provider URL is required.`);await l(`/api/engine/config`,{method:`PATCH`,body:JSON.stringify({...a?{default_provider:o}:{},providers:{[o]:{url:s,...c?{default_model:c}:{}}}})}),i.trim()&&await t.providers.setApiKey(o,i.trim())},onSuccess:async()=>{u(`ok`,`Custom provider saved.`),tt(``),await Promise.all([T.invalidateQueries({queryKey:[`settings`,`providers`]}),v()])},onError:e=>u(`err`,e instanceof Error?e.message:String(e))}),Or=c({mutationFn:async()=>{let e=[];try{let t=JSON.parse(cn||`[]`);if(!Array.isArray(t))throw Error(`monitored_projects must be a JSON array`);e=t,dn(``)}catch(e){let t=e instanceof Error?e.message:`monitored_projects JSON is invalid`;throw dn(t),Error(t)}return l(`/api/engine/config/bug-monitor`,{method:`PATCH`,body:JSON.stringify({bug_monitor:{enabled:zt,paused:Vt,workspace_root:String(Ut||``).trim()||null,repo:String(Gt||``).trim()||null,mcp_server:String(qt||``).trim()||null,provider_preference:String(Yt||`auto`).trim(),model_policy:Zt&&$t?{default_model:{provider_id:Zt,model_id:$t}}:null,auto_create_new_issues:tn,require_approval_for_new_issues:rn,auto_comment_on_matched_open_issues:on,label_mode:`reporter_only`,monitored_projects:e}})})},onSuccess:async()=>{u(`ok`,`Bug Monitor settings saved.`),await Promise.all([T.invalidateQueries({queryKey:[`settings`,`bug-monitor`]})])},onError:e=>{u(`err`,e instanceof Error?e.message:String(e?.detail||e?.error||e))}}),kr=c({mutationFn:async()=>l(`/api/engine/capabilities/bindings/refresh-builtins`,{method:`POST`}),onSuccess:async()=>{await Promise.all([T.invalidateQueries({queryKey:[`settings`,`bug-monitor`]}),T.invalidateQueries({queryKey:[`settings`,`mcp`]})]),u(`ok`,`Capability bindings refreshed from built-ins.`)},onError:e=>{u(`err`,e instanceof Error?e.message:String(e?.detail||e?.error||e))}}),Ar=c({mutationFn:async e=>l(`/api/engine/bug-monitor/intake/keys`,{method:`POST`,body:JSON.stringify({project_id:e.project_id,name:e.name,scopes:[`bug_monitor:report`]})}),onSuccess:async e=>{pn(String(e?.raw_key||``)),u(`ok`,`Bug Monitor intake key created.`),await T.invalidateQueries({queryKey:[`settings`,`bug-monitor`,`intake-keys`]})},onError:e=>{u(`err`,e instanceof Error?e.message:String(e?.detail||e?.error||e))}}),jr=c({mutationFn:async e=>(hn(e),l(`/api/engine/bug-monitor/intake/keys/${encodeURIComponent(e)}/disable`,{method:`POST`})),onSuccess:async()=>{u(`ok`,`Bug Monitor intake key disabled.`),await T.invalidateQueries({queryKey:[`settings`,`bug-monitor`,`intake-keys`]})},onError:e=>{u(`err`,e instanceof Error?e.message:String(e?.detail||e?.error||e))},onSettled:()=>hn(``)}),Mr=c({mutationFn:async e=>(_n(`${e.project_id||`project`}::${e.source_id||`source`}`),l(`/api/engine/bug-monitor/log-sources/${encodeURIComponent(e.project_id)}/${encodeURIComponent(e.source_id)}/reset-offset`,{method:`POST`})),onSuccess:async e=>{xn({action:`reset-offset`,project_id:e?.project_id,source_id:e?.source_id,offset:e?.state?.offset,path:e?.state?.path,updated_at_ms:e?.state?.updated_at_ms}),u(`ok`,`Bug Monitor log source offset reset.`),await T.invalidateQueries({queryKey:[`settings`,`bug-monitor`]})},onError:e=>{u(`err`,e instanceof Error?e.message:String(e?.detail||e?.error||e))},onSettled:()=>_n(``)}),Nr=c({mutationFn:async e=>(yn(`${e.project_id||`project`}::${e.source_id||`source`}`),l(`/api/engine/bug-monitor/log-sources/${encodeURIComponent(e.project_id)}/${encodeURIComponent(e.source_id)}/replay-latest`,{method:`POST`})),onSuccess:async e=>{xn({action:`replay-latest`,project_id:e?.project_id,source_id:e?.source_id,incident_id:e?.incident?.incident_id,occurrence_count:e?.incident?.occurrence_count,draft_id:e?.draft?.draft_id,draft_status:e?.draft?.status}),u(`ok`,`Bug Monitor latest log candidate replayed.`),await T.invalidateQueries({queryKey:[`settings`,`bug-monitor`]})},onError:e=>{u(`err`,e instanceof Error?e.message:String(e?.detail||e?.error||e))},onSettled:()=>yn(``)}),Pr=c({mutationFn:async({draftId:e,decision:t})=>l(`/api/engine/bug-monitor/drafts/${encodeURIComponent(e)}/${t}`,{method:`POST`,body:JSON.stringify({reason:`${t}d from control panel settings`})}),onSuccess:async(e,t)=>{await Promise.all([T.invalidateQueries({queryKey:[`settings`,`bug-monitor`]})]),u(`ok`,`Bug Monitor draft ${t.decision===`approve`?`approved`:`denied`}.`)},onError:e=>{u(`err`,e instanceof Error?e.message:String(e?.detail||e?.error||e))}}),Fr=c({mutationFn:async({draftId:e})=>l(`/api/engine/bug-monitor/drafts/${encodeURIComponent(e)}/triage-run`,{method:`POST`}),onSuccess:async e=>{await Promise.all([T.invalidateQueries({queryKey:[`settings`,`bug-monitor`]})]),u(`ok`,e?.deduped?`Bug Monitor triage run already exists: ${e?.run?.run_id||`unknown`}`:`Bug Monitor triage run created: ${e?.run?.run_id||`unknown`}`)},onError:e=>{u(`err`,e instanceof Error?e.message:String(e?.detail||e?.error||e))}}),Ir=c({mutationFn:async({action:e})=>l(`/api/engine/bug-monitor/${e}`,{method:`POST`}),onSuccess:async(e,t)=>{await Promise.all([T.invalidateQueries({queryKey:[`settings`,`bug-monitor`]})]),u(`ok`,`Bug Monitor ${t.action===`pause`?`paused`:`resumed`}.`)},onError:e=>{u(`err`,e instanceof Error?e.message:String(e?.detail||e?.error||e))}}),Lr=c({mutationFn:async({incidentId:e})=>l(`/api/engine/bug-monitor/incidents/${encodeURIComponent(e)}/replay`,{method:`POST`}),onSuccess:async e=>{await Promise.all([T.invalidateQueries({queryKey:[`settings`,`bug-monitor`]})]),u(`ok`,e?.deduped?`Bug Monitor triage run already exists: ${e?.run?.run_id||`unknown`}`:`Bug Monitor replay queued triage: ${e?.run?.run_id||`unknown`}`)},onError:e=>{u(`err`,e instanceof Error?e.message:String(e?.detail||e?.error||e))}}),Rr=c({mutationFn:async({draftId:e})=>l(`/api/engine/bug-monitor/drafts/${encodeURIComponent(e)}/publish`,{method:`POST`}),onSuccess:async e=>{await Promise.all([T.invalidateQueries({queryKey:[`settings`,`bug-monitor`]})]),u(`ok`,e?.action===`comment_issue`?`Bug Monitor commented on issue #${e?.draft?.issue_number||`unknown`}.`:`Bug Monitor published issue #${e?.draft?.issue_number||`unknown`}.`)},onError:e=>{u(`err`,e instanceof Error?e.message:String(e?.detail||e?.error||e))}}),zr=c({mutationFn:async({draftId:e})=>l(`/api/engine/bug-monitor/drafts/${encodeURIComponent(e)}/recheck-match`,{method:`POST`}),onSuccess:async e=>{await Promise.all([T.invalidateQueries({queryKey:[`settings`,`bug-monitor`]})]),u(`ok`,`GitHub match result: ${String(e?.action||`rechecked`).replaceAll(`_`,` `)}.`)},onError:e=>{u(`err`,e instanceof Error?e.message:String(e?.detail||e?.error||e))}}),Br=c({mutationFn:({providerId:e,apiKey:n})=>t.providers.setApiKey(e,n),onSuccess:async()=>{u(`ok`,`API key updated.`),await Promise.all([T.invalidateQueries({queryKey:[`settings`,`providers`]}),v()])},onError:e=>u(`err`,e instanceof Error?e.message:String(e))}),Vr=c({mutationFn:({providerId:e})=>t.providers.oauthAuthorize(e),onSuccess:async(e,t)=>{let n=String(t.providerId||``).trim().toLowerCase(),r=e?.ok!==!1,i=String(e?.error||e?.message||``).trim(),a=String(e?.session_id||e?.sessionId||``).trim(),o=String(e?.authorization_url||e?.authorizationUrl||e?.url||``).trim();if(!r||!n||!a||!o){u(`err`,i||`OAuth authorize response was incomplete.`);return}qe(e=>({...e,[n]:a})),window.open(o,`_blank`,`noopener,noreferrer`),u(`info`,n===`openai-codex`?`Browser sign-in opened for Codex. Finish the flow there, then return to Tandem.`:`Browser sign-in opened for ${n}.`),await T.invalidateQueries({queryKey:[`settings`,`providers`,`auth`]})},onError:e=>u(`err`,e instanceof Error?e.message:String(e))}),Hr=c({mutationFn:({providerId:e})=>t.providers.oauthDisconnect(e),onSuccess:async(e,t)=>{let n=String(t.providerId||``).trim().toLowerCase();qe(e=>{if(!e[n])return e;let t={...e};return delete t[n],t}),u(`ok`,n===`openai-codex`?`Codex account disconnected.`:`${n} disconnected.`),await Promise.all([T.invalidateQueries({queryKey:[`settings`,`providers`]}),v()])},onError:e=>u(`err`,e instanceof Error?e.message:String(e))}),Ur=c({mutationFn:({providerId:e})=>t.providers.oauthUseLocalSession(e),onSuccess:async(e,t)=>{let n=String(t.providerId||``).trim().toLowerCase(),r=e?.ok!==!1,i=String(e?.error||e?.message||``).trim();if(!r){u(`err`,i||`Unable to import the local Codex session. Make sure Codex CLI is signed in on this machine.`);return}qe(e=>{if(!e[n])return e;let t={...e};return delete t[n],t});let a=String(e?.email||``).trim();if(u(`ok`,n===`openai-codex`?a?`Local Codex session imported: ${a}`:`Local Codex session imported.`:`${n} local session imported.`),n===`openai-codex`)try{await Er(),u(`ok`,`Codex is now the default provider for Tandem runs.`)}catch(e){u(`warn`,e instanceof Error?e.message:`Codex session imported, but Tandem could not switch the default provider.`)}await Promise.all([T.invalidateQueries({queryKey:[`settings`,`providers`]}),v()])},onError:e=>u(`err`,e instanceof Error?e.message:String(e))}),Wr=c({mutationFn:({providerId:e,authJson:t})=>l(`/api/engine/provider/${encodeURIComponent(e)}/oauth/session/import`,{method:`POST`,body:JSON.stringify({auth_json:t})}),onSuccess:async(e,t)=>{let n=String(t.providerId||``).trim().toLowerCase(),r=e?.ok!==!1,i=String(e?.error||e?.message||``).trim();if(!r){u(`err`,i||`Unable to import the Codex auth.json file. Make sure it was copied from a signed-in Codex CLI session.`);return}at(``),qe(e=>{if(!e[n])return e;let t={...e};return delete t[n],t});let a=String(e?.email||``).trim();if(u(`ok`,n===`openai-codex`?a?`Codex auth.json imported: ${a}`:`Codex auth.json imported.`:`${n} auth.json imported.`),n===`openai-codex`)try{await Er(),u(`ok`,`Codex is now the default provider for Tandem runs.`)}catch(e){u(`warn`,e instanceof Error?e.message:`Codex auth.json imported, but Tandem could not switch the default provider.`)}await Promise.all([T.invalidateQueries({queryKey:[`settings`,`providers`]}),v()])},onError:e=>u(`err`,e instanceof Error?e.message:String(e))}),Gr=a(async(e,t)=>{if(t)try{let n=await t.text();if(zn(t.name||`auth.json`),at(n),!n.trim()){u(`warn`,`Selected auth.json file was empty.`);return}Wr.mutate({providerId:e,authJson:n})}catch(e){u(`err`,e instanceof Error?e.message:String(e))}finally{Ln.current&&(Ln.current.value=``)}},[Wr,u]);e(()=>{let e=Object.entries(Ke).filter(([e,t])=>!!e&&!!t);if(!e.length)return;let n=!1,r=new Set,i=async()=>{let i=await Promise.all(e.map(async([e,n])=>{try{return{providerId:e,sessionId:n,payload:await t.providers.oauthStatus(e,n),error:null}}catch(t){return{providerId:e,sessionId:n,payload:null,error:t instanceof Error?t:Error(String(t))}}}));for(let e of i){if(n||r.has(e.providerId))continue;if(e.error){r.add(e.providerId),qe(t=>{if(t[e.providerId]!==e.sessionId)return t;let n={...t};return delete n[e.providerId],n}),u(`err`,e.error.message);continue}let t=e.payload,i=String(t?.status||``).trim().toLowerCase();if(!(!i||i===`pending`)){if(r.add(e.providerId),qe(t=>{if(t[e.providerId]!==e.sessionId)return t;let n={...t};return delete n[e.providerId],n}),i===`connected`){let n=String(t?.email||``).trim();if(u(`ok`,n?`Codex account connected: ${n}`:`Codex account connected.`),e.providerId===`openai-codex`)try{await Er(),u(`ok`,`Codex is now the default provider for Tandem runs.`)}catch(e){u(`warn`,e instanceof Error?e.message:`Codex connected, but Tandem could not switch the default provider.`)}}else i===`expired`?u(`warn`,`Codex sign-in expired. Start the connection again.`):u(`err`,String(t?.error||t?.message||``).trim()||`Codex sign-in did not complete. Please try again.`);await Promise.all([T.invalidateQueries({queryKey:[`settings`,`providers`]}),v()])}}};i();let a=window.setInterval(()=>{i()},2e3);return()=>{n=!0,window.clearInterval(a)}},[t,Ke,T,v,u]);let Kr=c({mutationFn:async e=>l(`/api/system/search-settings`,{method:`PATCH`,body:JSON.stringify(e)}),onSuccess:async e=>{Ee(``),Oe(``),await T.invalidateQueries({queryKey:[`settings`,`search`]}),u(`ok`,e?.restart_required?`Search settings saved. Restart tandem-engine to apply them.`:`Search settings saved.`)},onError:e=>u(`err`,e instanceof Error?e.message:String(e))}),qr=c({mutationFn:async e=>l(`/api/system/scheduler-settings`,{method:`PATCH`,body:JSON.stringify(e)}),onSuccess:async e=>{await T.invalidateQueries({queryKey:[`settings`,`scheduler`]}),u(`ok`,e?.restart_required?`Scheduler settings saved. Restart tandem-engine to apply them.`:`Scheduler settings saved.`)},onError:e=>u(`err`,e instanceof Error?e.message:String(e))}),Jr=c({mutationFn:async({query:e})=>l(`/api/system/search-settings/test`,{method:`POST`,body:JSON.stringify({query:e,limit:5})}),onSuccess:e=>{Ne(e),u(`ok`,`Websearch test completed.`)},onError:e=>{Ne(null),u(`err`,e instanceof Error?e.message:String(e))}}),Yr=c({mutationFn:async()=>{let e;try{e=JSON.parse(ae)}catch(e){throw Error(e instanceof Error?`Config JSON is invalid: ${e.message}`:`Config JSON is invalid.`)}return l(`/api/control-panel/config`,{method:`PATCH`,body:JSON.stringify({config:e})})},onSuccess:async()=>{X(``),u(`ok`,`Control panel config saved.`),await T.invalidateQueries({queryKey:[`settings`,`install`]}),await T.invalidateQueries({queryKey:[`system`,`capabilities`]})},onError:e=>{let t=e instanceof Error?e.message:String(e);X(t),u(`err`,t)}}),Xr=c({mutationFn:async()=>{let e=(Hn.data?.identity?.bot||{})?.aliases||{},t=String(k||``).trim();if(!t)throw Error(`Bot name is required.`);let n=String(M||``).trim(),r=String(P||``).trim();return Vn({identity:{bot:{canonical_name:t,avatar_url:n||null,aliases:{...e,control_panel:r||void 0}}}})},onSuccess:async()=>{u(`ok`,`Identity updated.`),await Promise.all([T.invalidateQueries({queryKey:[`settings`,`identity`]}),y()])},onError:e=>u(`err`,e instanceof Error?e.message:String(e))}),Zr=a(async()=>Promise.all([T.invalidateQueries({queryKey:[`settings`,`channels`]}),T.invalidateQueries({queryKey:[`settings`,`channels`,`scopes`]}),T.invalidateQueries({queryKey:[`settings`,`channels`,`tool-preferences`]})]),[T]),Qr=c({mutationFn:async({channel:e,scopeId:t,payload:n})=>{let r=String(t||``).trim()?`?scope_id=${encodeURIComponent(String(t||``).trim())}`:``;return`reset`in n?l(`/api/engine/channels/${e}/tool-preferences${r}`,{method:`PUT`,body:JSON.stringify({reset:!0})}):l(`/api/engine/channels/${e}/tool-preferences${r}`,{method:`PUT`,body:JSON.stringify(n)})},onSuccess:async(e,t)=>{await T.invalidateQueries({queryKey:[`settings`,`channels`,`tool-preferences`]}),await T.invalidateQueries({queryKey:[`settings`,`channels`,`scopes`]});let n=String(t.scopeId||``).trim();u(`ok`,n?`Saved ${t.channel} scope ${n}.`:`Saved ${t.channel} channel tool scope.`)},onError:e=>u(`err`,e instanceof Error?e.message:String(e))}),$r=c({mutationFn:async e=>{let n=ot[e];if(!n)throw Error(`No draft found for ${e}.`);let r=String(n.modelProviderId||``).trim(),i=String(n.modelId||``).trim(),a={allowed_users:we(n.allowedUsers),mention_only:!!n.mentionOnly,strict_kb_grounding:!!n.strictKbGrounding,security_profile:String(n.securityProfile||`operator`).trim()||`operator`,model_provider_id:r||null,model_id:i||null},o=String(n.botToken||``).trim();if(o&&(a.bot_token=o),e===`telegram`&&(a.style_profile=String(n.styleProfile||`default`).trim()||`default`),e===`discord`&&(a.guild_id=String(n.guildId||``).trim()),e===`slack`){let e=String(n.channelId||``).trim();if(!e&&!br.data?.slack?.channel_id)throw Error(`Slack channel ID is required.`);e&&(a.channel_id=e)}return t.channels.put(e,a)},onSuccess:async(e,t)=>{u(`ok`,`Saved ${t} channel settings.`),mt(e=>({...e,[t]:null})),st(e=>({...e,[t]:{...e[t],botToken:``}})),await Zr()},onError:e=>u(`err`,e instanceof Error?e.message:String(e))}),ei=c({mutationFn:async e=>t.channels.delete(e),onSuccess:async(e,t)=>{u(`ok`,`Removed ${t} channel settings.`),mt(e=>({...e,[t]:null})),ut(e=>({...e,[t]:``})),ct.current[t]=!1,st(e=>({...e,[t]:me(t,null)})),await Zr()},onError:e=>u(`err`,e instanceof Error?e.message:String(e))}),ti=c({mutationFn:async e=>{let n=ot[e],r=String(n?.botToken||``).trim(),i={};return r&&(i.bot_token=r),t.channels.verify(e,i)},onSuccess:(e,t)=>{mt(n=>({...n,[t]:e})),u(`ok`,`${t} verification complete.`)},onError:e=>u(`err`,e instanceof Error?e.message:String(e))}),ni=a(async()=>T.invalidateQueries({queryKey:[`settings`,`mcp`]}),[T]),ri=c({mutationFn:async({serverName:e,allowedTools:n})=>t.mcp.patch(e,{allowed_tools:n??void 0,clear_allowed_tools:n===null}),onSuccess:async()=>{await ni(),u(`ok`,`MCP tool access updated.`)},onError:e=>u(`err`,e instanceof Error?e.message:String(e))}),ii=c({mutationFn:async({action:e,server:n})=>{if(!n)throw Error(`No MCP server selected.`);if(e===`connect`)return t.mcp.connect(n.name);if(e===`disconnect`)return t.mcp.disconnect(n.name);if(e===`refresh`)return t.mcp.refresh(n.name);if(e===`authenticate`)return l(`/api/engine/mcp/${encodeURIComponent(n.name)}/auth/authenticate`,{method:`POST`});if(e===`toggle-enabled`)return t.mcp.setEnabled(n.name,!n.enabled);if(e===`delete`)return l(`/api/engine/mcp/${encodeURIComponent(n.name)}`,{method:`DELETE`});throw Error(`Unknown action: ${e}`)},onSuccess:async(e,t)=>{await ni();let n=!!e?.pendingAuth||!!e?.lastAuthChallenge||!!e?.authorizationUrl,r=e?.ok!==!1,i=String(t.server?.authKind||``).trim().toLowerCase();if(t.action===`connect`)if(n||!r&&i===`oauth`){let n=e?.lastAuthChallenge||{},r=String(n?.message||``).trim();u(`warn`,r?`OAuth authorization required for ${t.server?.name}: ${r}`:`OAuth authorization required for ${t.server?.name}.`)}else if(r)u(`ok`,`Connected ${t.server?.name}.`);else{let n=String(e?.error?.message||e?.error||``).trim();u(`err`,n?`Failed to connect ${t.server?.name}: ${n}`:`Failed to connect ${t.server?.name}.`)}if(t.action===`disconnect`&&u(`ok`,`Disconnected ${t.server?.name}.`),t.action===`refresh`)if(n||!r&&i===`oauth`){let n=e?.lastAuthChallenge||{},r=String(n?.message||``).trim();u(`warn`,r?`OAuth authorization required for ${t.server?.name}: ${r}`:`OAuth authorization required for ${t.server?.name}.`)}else if(r)u(`ok`,`Refreshed ${t.server?.name}.`);else{let n=String(e?.error?.message||e?.error||``).trim();u(`err`,n?`Failed to refresh ${t.server?.name}: ${n}`:`Failed to refresh ${t.server?.name}.`)}if(t.action===`authenticate`){let r=e?.ok!==!1,i=String(e?.error?.message||e?.error||``).trim();if(!r&&!n)u(`err`,i?`OAuth authorization check failed for ${t.server?.name}: ${i}`:`OAuth authorization check failed for ${t.server?.name}.`);else if(n){let n=e?.lastAuthChallenge||{},r=String(n?.message||``).trim();u(`warn`,r?`OAuth authorization still pending for ${t.server?.name}: ${r}`:`OAuth authorization still pending for ${t.server?.name}.`)}else u(`ok`,`Marked ${t.server?.name} as signed in.`)}t.action===`toggle-enabled`&&u(`ok`,`${t.server?.enabled?`Disabled`:`Enabled`} ${t.server?.name}.`),t.action===`delete`&&u(`ok`,`Deleted ${t.server?.name}.`)},onError:e=>u(`err`,e instanceof Error?e.message:String(e))}),ai=c({mutationFn:async()=>{let e=String(yt||``).trim(),n=re(e),r=ne(_t||n);if(!e)throw Error(`Transport URL is required.`);if(!K(e)&&!e.startsWith(`stdio:`))throw Error(`Transport must be a valid URL or stdio:* transport.`);let i=se(ce({authMode:xt,token:Ct,customHeader:Tt,transport:e}),kt),a=String(Dt||``).trim();ie(e)&&a&&(i[`X-MCP-Toolsets`]=a);let o={name:r,transport:e,enabled:!0,auth_kind:xt===`oauth`?`oauth`:``};Object.keys(i).length&&(o.headers=i);let s=String(Nt||``).trim();if(s&&s!==r&&await l(`/api/engine/mcp/${encodeURIComponent(s)}`,{method:`DELETE`}).catch(()=>null),await t.mcp.add(o),jt){let e=await t.mcp.connect(o.name),n=e?.pendingAuth===!0||!!e?.lastAuthChallenge||!!e?.authorizationUrl;if(!e?.ok&&!n&&xt!==`oauth`)throw Error(`Added "${o.name}" but connect failed.`);return{name:o.name,connectResult:e,connectAfterAdd:!0,authKind:xt===`oauth`?`oauth`:``}}return{name:o.name,connectAfterAdd:!1,authKind:xt===`oauth`?`oauth`:``}},onSuccess:async e=>{await ni(),gt(!1),vt(``),bt(``),St(`none`),wt(``),Et(``),Ot(``),At([]),Mt(!0),Pt(``);let t=String(e?.name||``).trim(),n=e?.connectResult,r=String(e?.authKind||``).trim().toLowerCase(),i=!!n?.pendingAuth||!!n?.lastAuthChallenge||!!n?.authorizationUrl;if(e?.connectAfterAdd&&i){let e=n?.lastAuthChallenge||{},r=String(e?.message||``).trim();u(`warn`,r?`Saved MCP "${t}" and OAuth authorization is still required: ${r}`:`Saved MCP "${t}" and OAuth authorization is still required.`)}else e?.connectAfterAdd?r===`oauth`&&n&&n.ok!==!0?u(`warn`,`Saved MCP "${t}" as OAuth-backed. If it still needs authorization, open the auth link from the server row and refresh after signing in.`):u(`ok`,`Saved MCP "${t}" and connected it.`):u(`ok`,`Saved MCP "${t}".`)},onError:e=>u(`err`,e instanceof Error?e.message:String(e))}),oi=e=>{if(!e)return;if(e.size>10*1024*1024){u(`err`,`Avatar image is too large (max 10 MB).`);return}let t=new FileReader;t.onload=()=>{let e=typeof t.result==`string`?t.result:``;if(!e){u(`err`,`Failed to read avatar image.`);return}N(e)},t.onerror=()=>u(`err`,`Failed to read avatar image.`),t.readAsDataURL(e)},si=Array.isArray(Kn.data?.all)?Kn.data.all:[],ci=Array.isArray(p?.connected)?p.connected.length:0;e(()=>{let e=tr.find(e=>e.isDefault)||tr[0];e&&(Ye(t=>t.trim()&&t.trim().toLowerCase()!==`custom`?t:e.id),Ze(t=>t.trim()?t:e.url),$e(t=>t.trim()?t:e.model),rt(String($.data?.default||``).trim().toLowerCase()===e.id.trim().toLowerCase()))},[tr,$.data?.default]);let li=n(()=>de(ur.data),[ur.data]),ui=n(()=>fe(dr.data),[dr.data]),di=n(()=>pe(fr.data?.catalog||fr.data||null),[fr.data]),fi=n(()=>new Set(li.map(e=>e.name.toLowerCase())),[li]);e(()=>{let e=li.filter(e=>{let t=String(e.authKind||``).trim().toLowerCase(),n=String(e.lastAuthChallenge?.authorization_url||e.lastAuthChallenge?.authorizationUrl||e.authorizationUrl||``).trim();return t===`oauth`&&(!!e.lastAuthChallenge||!!n)});if(!e.length)return;let t=!1,n=!1,r=async()=>{if(!(t||n)){n=!0;try{let n=await Promise.all(e.map(async e=>{try{return{payload:await l(`/api/engine/mcp/${encodeURIComponent(e.name)}/auth/authenticate`,{method:`POST`}),error:null}}catch(e){return{payload:null,error:e instanceof Error?e:Error(String(e))}}}));if(t)return;n.some(({payload:e,error:t})=>t?!1:!(e?.pendingAuth===!0||e?.lastAuthChallenge||e?.authorizationUrl))&&await T.invalidateQueries({queryKey:[`settings`,`mcp`]})}finally{n=!1}}};r();let i=window.setInterval(()=>{r()},3e3);return()=>{t=!0,window.clearInterval(i)}},[l,li,T]);let pi=n(()=>{let e=String(Lt||``).trim().toLowerCase();return di.servers.filter(t=>e?t.name.toLowerCase().includes(e)||t.slug.toLowerCase().includes(e)||t.transportUrl.toLowerCase().includes(e):!0).slice(0,36)},[di.servers,Lt]),mi=li.filter(e=>e.connected).length,hi=n(()=>mr.data?.status||{},[mr.data]),gi=n(()=>{try{let e=JSON.parse(cn||`[]`);if(Array.isArray(e))return e}catch{}return Array.isArray(hi.config?.monitored_projects)?hi.config.monitored_projects:[]},[cn,hi.config?.monitored_projects]),_i=n(()=>hi.log_watcher||{},[hi.log_watcher]),vi=n(()=>Array.isArray(hr.data?.drafts)&&hr.data.drafts||[],[hr.data]),yi=n(()=>Array.isArray(gr.data?.incidents)&&gr.data.incidents||[],[gr.data]),bi=n(()=>Array.isArray(_r.data?.posts)&&_r.data.posts||[],[_r.data]),xi=n(()=>Array.isArray(vr.data?.keys)&&vr.data.keys||[],[vr.data]),Si=n(()=>li.find(e=>e.name.toLowerCase()===String(qt||``).trim().toLowerCase())||null,[qt,li]),Ci=n(()=>si.find(e=>String(e?.id||``).toLowerCase()===String(Zt||``).trim().toLowerCase())||null,[Zt,si]),wi=n(()=>{let e=Ci&&typeof Ci==`object`&&Ci.models||{};return Object.keys(e).sort((e,t)=>e.localeCompare(t))},[Ci]),Ti=Array.isArray(ir.data?.blocking_issues)&&ir.data?.blocking_issues||[],Ei=Array.isArray(ir.data?.recommendations)&&ir.data?.recommendations||[],Di=Array.isArray(ir.data?.install_hints)&&ir.data?.install_hints||[],Oi=H.filter(e=>!!xr.data?.[e]?.connected).length,ki=Array.isArray(yr.data?.directories)?yr.data.directories:[],Ai=String(Pn||``).trim().toLowerCase(),ji=n(()=>Ai?ki.filter(e=>String(e?.name||e?.path||``).trim().toLowerCase().includes(Ai)):ki,[ki,Ai]),Mi=String(yr.data?.parent||``).trim(),Ni=String(yr.data?.dir||Mn||``).trim(),Pi=n(()=>F(Gt),[Gt]),Fi=I(Ut),Ii=L(Ut,Gt);e(()=>{let e=pr.data?.bug_monitor&&typeof pr.data?.bug_monitor==`object`?pr.data.bug_monitor:{};Bt(!!e.enabled),Ht(!!e.paused),Wt(String(e.workspace_root||``).trim()),Kt(String(e.repo||``).trim()),Jt(String(e.mcp_server||``).trim()),Xt(String(e.provider_preference||`auto`).trim()||`auto`),Qt(String(e.model_policy?.default_model?.provider_id||``).trim()),en(String(e.model_policy?.default_model?.model_id||``).trim()),nn(e.auto_create_new_issues!==!1),an(!!e.require_approval_for_new_issues),sn(e.auto_comment_on_matched_open_issues!==!1);let t=Array.isArray(e.monitored_projects)?e.monitored_projects:[];ln(JSON.stringify(t,null,2)),dn(``)},[pr.data]),e(()=>{let e=br.data&&typeof br.data==`object`?br.data:{};!br.data||typeof br.data!=`object`||st(t=>{let n={...t};for(let t of H)n[t]||(n[t]=me(t,e[t]),ct.current[t]=!0);return n})},[br.data]);let Li=(e,t)=>{let n=String(t||``).trim();n&&wr.mutate({providerId:e,modelId:n})},Ri=e=>{if(e){It(`manual`);let t=e.headers&&typeof e.headers==`object`?e.headers:{},n=Object.keys(t),r=n.find(e=>String(e).toLowerCase()===`authorization`),i=n.find(e=>String(e).toLowerCase()===`x-api-key`),a=n.find(e=>String(e).toLowerCase()===`x-mcp-toolsets`),o=String(e.lastAuthChallenge?.authorization_url||e.lastAuthChallenge?.authorizationUrl||e.authorizationUrl||``).trim(),s=n.filter(e=>![r,i,a].filter(Boolean).map(e=>String(e).toLowerCase()).includes(String(e).toLowerCase())),c=String(e.authKind||``).trim().toLowerCase()||ue(di,e.name,e.transport),l=o||c===`oauth`?`oauth`:`none`,u=``,d=``;o?d=``:i?(l=`x-api-key`,d=String(t[i]||``).trim()):r?(l=`bearer`,d=String(t[r]||``).replace(/^bearer\s+/i,``).trim()):s.length===1&&(l=`custom`,u=s[0],d=String(t[s[0]]||``).trim()),Pt(e.name),vt(e.name),bt(e.transport||``),Mt(e.connected||!1),Ot(a?String(t[a]||``).trim():ie(e.transport||``)?`default`:``),St(l),Et(u),wt(d);let f=new Set([r,i,a,l===`custom`?u:``].filter(Boolean).map(e=>String(e).toLowerCase()));At(n.filter(e=>!f.has(String(e).toLowerCase())).map(e=>({key:e,value:String(t[e]||``).trim()})))}else It(`catalog`),Pt(``),vt(``),bt(``),St(`none`),Et(``),wt(``),Ot(``),At([]),Mt(!0);gt(!0)},zi=async()=>{let e=await l(`/api/engine/bug-monitor/debug`,{method:`GET`});await navigator.clipboard.writeText(JSON.stringify(e,null,2)),u(`ok`,`Bug Monitor debug payload copied.`)},Bi=[`Scanning registered Git worktrees...`,`Comparing managed worktrees against live runtime records...`,`Removing stale worktrees and orphan directories...`],Vi=Bi[En%Bi.length],Hi=n(()=>{let e=[];for(let t of On?.cleaned_worktrees||[])e.push({kind:`removed`,title:t.path||`Removed worktree`,detail:t.branch&&t.branch_deleted===!1&&t.branch_delete_error?`Removed worktree, but branch cleanup failed: ${t.branch_delete_error}`:t.branch?`Removed registered worktree and branch ${t.branch}.`:`Removed registered worktree.`,tone:`ok`});for(let t of On?.active_paths||[])e.push({kind:`active`,title:t,detail:`Skipped because the current Tandem runtime still tracks it as active.`,tone:`info`});for(let t of On?.stale_paths||[])(On?.cleaned_worktrees||[]).some(e=>e.path===t.path)||e.push({kind:`stale`,title:t.path||`Stale worktree`,detail:On?.dry_run?t.branch?`Would remove managed worktree and branch ${t.branch}.`:`Would remove managed worktree.`:`Marked stale but not removed.`,tone:`warn`});for(let t of On?.orphan_dirs_removed||[])e.push({kind:`orphan_removed`,title:t.path||`Removed orphan directory`,detail:`Removed an unregistered directory left behind under .tandem/worktrees.`,tone:`ok`});if(On?.dry_run)for(let t of On?.orphan_dirs||[])e.push({kind:`stale`,title:t,detail:`Would remove orphaned directory left on disk.`,tone:`warn`});for(let t of On?.failures||[])e.push({kind:`failure`,title:t.path||t.code||`Cleanup failure`,detail:t.error||t.stderr||t.branch_delete_error||`Cleanup failed.`,tone:`err`});return e},[On]),Ui=[{id:`install`,label:`Install`,icon:`clipboard-list`},{id:`navigation`,label:`Navigation`,icon:`panel-left`},{id:`providers`,label:`Providers`,icon:`cpu`},{id:`search`,label:`Web Search`,icon:`globe`},{id:`scheduler`,label:`Scheduler`,icon:`layers`},{id:`identity`,label:`Identity`,icon:`badge-check`},{id:`theme`,label:`Themes`,icon:`paint-bucket`},{id:`channels`,label:`Channels`,icon:`message-circle`},{id:`mcp`,label:`MCP`,icon:`plug-zap`},{id:`bug_monitor`,label:`Bug Monitor`,icon:`bug-play`},{id:`browser`,label:`Browser`,icon:`monitor-cog`},{id:`maintenance`,label:`Maintenance`,icon:`wrench`}],Wi=n(()=>Y(xt,Ct,Tt,yt),[xt,Tt,Ct,yt]),Gi=n(()=>J(_t,yt),[_t,yt]),Ki=xt===`oauth`&&jt,qi=n(()=>ie(yt),[yt]);e(()=>{S?.routeVisibility&&q(S.routeVisibility)},[S?.routeVisibility]);let Ji=a((e,t)=>{q(n=>{let r={...n,[e]:t};return C(r),r}),S?.setRouteVisibility(e,t)},[S]),Yi=a(()=>{let e=Object.fromEntries(x.map(([e])=>[e,!0]));q(e),C(e),S?.showAllSections()},[S]),Xi=a(()=>{let e=w(!!S?.acaMode);q(e),C(e),S?.resetNavigation()},[S]),Zi=te,Qi=w(!!S?.acaMode),$i=x.map(([e,t,n])=>{let r=e;return{routeId:e,label:t,icon:n,enabled:Zi[r]!==!1,defaultVisible:Qi[r]!==!1,description:je[e]||`Open the ${String(t||e).toLowerCase()} section.`}}),ea=$i.filter(e=>e.enabled).length,ta=$i.filter(e=>e.defaultVisible),na=$i.filter(e=>!e.defaultVisible),ra=na.filter(e=>!e.enabled).length;return e(()=>{let e=E.current;e?b(e):b()},[W,zt,Vt,Ut,qt,hi.readiness?.runtime_ready,hi.runtime?.monitoring_active,hi.runtime?.paused,hi.runtime?.pending_incidents,hi.pending_drafts,vi.length,yi.length,kr.isPending,Ir.isPending,Pr.isPending,Lr.isPending,Fr.isPending,Or.isPending,ii.isPending,Kr.isPending]),{activeSection:W,advancedNavigationRows:na,applyDefaultModel:Li,authorizeProviderOAuthMutation:Vr,avatarInputRef:In,botAvatarUrl:M,botControlPanelAlias:P,botName:k,browserInstallHints:Di,browserIssues:Ti,browserRecommendations:Ei,browserSmokeResult:ar,browserStatus:ir,bugMonitorAutoComment:on,bugMonitorAutoCreateIssues:tn,bugMonitorConfigQuery:pr,bugMonitorCreatedIntakeKey:fn,bugMonitorCurrentBrowseDir:Ni,bugMonitorDisablingIntakeKeyId:mn,bugMonitorDraftDecisionMutation:Pr,bugMonitorDrafts:vi,bugMonitorDraftsQuery:hr,bugMonitorEnabled:zt,bugMonitorIncidents:yi,bugMonitorIncidentsQuery:gr,bugMonitorIntakeKeys:xi,bugMonitorIntakeKeysQuery:vr,bugMonitorLogSourceActionResult:bn,bugMonitorLogWatcher:_i,bugMonitorMcpServer:qt,bugMonitorModelId:$t,bugMonitorMonitoredProjects:gi,bugMonitorMonitoredProjectsError:un,bugMonitorMonitoredProjectsJson:cn,bugMonitorPauseResumeMutation:Ir,bugMonitorPaused:Vt,bugMonitorPosts:bi,bugMonitorPostsQuery:_r,bugMonitorProviderId:Zt,bugMonitorProviderModels:wi,bugMonitorProviderPreference:Yt,bugMonitorPublishDraftMutation:Rr,bugMonitorRecheckMatchMutation:zr,bugMonitorReplayIncidentMutation:Lr,bugMonitorReplayingSourceKey:vn,bugMonitorRepo:Gt,bugMonitorRequireApproval:rn,bugMonitorResettingSourceKey:gn,bugMonitorStatus:hi,bugMonitorStatusQuery:mr,bugMonitorSuggestedWorkspaceRoot:Pi,bugMonitorTriageRunMutation:Fr,bugMonitorWorkspaceBrowserDir:Mn,bugMonitorWorkspaceBrowserOpen:An,bugMonitorWorkspaceBrowserQuery:yr,bugMonitorWorkspaceBrowserSearch:Pn,bugMonitorWorkspaceDirectories:ki,bugMonitorWorkspaceParentDir:Mi,bugMonitorWorkspaceRoot:Ut,bugMonitorWorkspaceRootHint:Fi,bugMonitorWorkspaceSearchQuery:Ai,bugMonitorWorkspaceSetupWarningText:Ii,channelDefaultModel:$n,channelDrafts:ot,channelDraftsHydratedRef:ct,channelProviderOptions:Yn,channelScopesQuery:Sr,channelToolPreferencesQuery:Cr,channelToolScopeOpen:dt,channelToolScopeSelection:lt,channelVerifyResult:pt,channelsConfigQuery:br,channelsStatusQuery:xr,codexAuthFileName:Rn,codexAuthInputRef:Ln,codexAuthJsonText:it,configuredMcpServerNames:fi,configuredProviders:er,connectedChannelCount:Oi,connectedMcpCount:mi,connectedProviderCount:ci,copyBugMonitorDebugPayload:zi,createBugMonitorIntakeKeyMutation:Ar,customConfiguredProviders:tr,customProviderApiKey:et,customProviderFormOpen:We,customProviderId:Je,customProviderMakeDefault:nt,customProviderModel:Qe,customProviderUrl:Xe,defaultNavigationRows:ta,defaultNavigationVisibility:Qi,deleteChannelMutation:ei,diagnosticsOpen:Re,disableBugMonitorIntakeKeyMutation:jr,disconnectProviderOAuthMutation:Hr,filteredBugMonitorWorkspaceDirectories:ji,filteredMcpCatalog:pi,getCodexDefaultModelId:Tr,githubMcpGuideOpen:Be,handleAvatarUpload:oi,hiddenAdvancedNavigationCount:ra,hostedManaged:Qn,identityConfig:Hn,importCodexAuthFile:Gr,importCodexAuthJsonMutation:Wr,installBrowserMutation:sr,installConfigError:le,installConfigQuery:Wn,installConfigText:ae,installProfileQuery:Un,invalidateChannels:Zr,invalidateMcp:ni,loadIdentityConfig:Bn,localEngine:Zn,mcpActionMutation:ii,mcpAuthMode:xt,mcpAuthPreviewText:Wi,mcpCatalog:di,mcpCatalogQuery:fr,mcpCatalogSearch:Lt,mcpConnectAfterAdd:jt,mcpCustomHeader:Tt,mcpEditingName:Nt,mcpExtraHeaders:kt,mcpGithubToolsets:Dt,mcpIsGithubTransport:qi,mcpModalOpen:ht,mcpModalTab:Ft,mcpName:_t,mcpOauthGuidanceText:Gi,mcpOauthStartsAfterSave:Ki,mcpSaveMutation:ai,mcpServers:li,mcpServersQuery:ur,mcpToken:Ct,mcpToolIds:ui,mcpToolPolicyMutation:ri,mcpToolsQuery:dr,mcpTransport:yt,modelSearchByProvider:D,navigationRows:$i,navigationVisibility:Zi,oauthSessionByProvider:Ke,openMcpModal:Ri,patchIdentityConfig:Vn,promoteCodexAsDefaultProvider:Er,providerAuthById:Xn,providerCatalogEnabled:Gn,providerDefaultsOpen:He,providers:si,providersAuth:qn,providersCatalog:Kn,providersConfig:$,queryClient:T,refreshBugMonitorBindingsMutation:kr,replayBugMonitorLogSourceMutation:Nr,resetNavigationSections:Xi,resetBugMonitorLogSourceMutation:Mr,rootRef:E,saveBugMonitorMutation:Or,saveChannelMutation:$r,saveChannelToolPreferencesMutation:Qr,saveCustomProviderMutation:Dr,saveIdentityMutation:Xr,saveInstallConfigMutation:Yr,saveSchedulerSettingsMutation:qr,saveSearchSettingsMutation:Kr,schedulerMaxConcurrent:Ie,schedulerMode:Pe,schedulerSettingsQuery:rr,searchBackend:ve,searchBraveKey:Te,searchExaKey:De,searchSearxngUrl:be,searchSettingsQuery:nr,searchTandemUrl:ye,searchTestQuery:ke,searchTestResult:Me,searchTimeoutMs:Se,sectionTabs:Ui,selectedBugMonitorProvider:Ci,selectedBugMonitorServer:Si,setActiveSection:G,setApiKeyMutation:Br,setBotAvatarUrl:N,setBotControlPanelAlias:R,setBotName:j,setBrowserSmokeResult:or,setBugMonitorAutoComment:sn,setBugMonitorAutoCreateIssues:nn,setBugMonitorCreatedIntakeKey:pn,setBugMonitorDisablingIntakeKeyId:hn,setBugMonitorEnabled:Bt,setBugMonitorLogSourceActionResult:xn,setBugMonitorMcpServer:Jt,setBugMonitorModelId:en,setBugMonitorMonitoredProjectsError:dn,setBugMonitorMonitoredProjectsJson:ln,setBugMonitorPaused:Ht,setBugMonitorProviderId:Qt,setBugMonitorProviderPreference:Xt,setBugMonitorReplayingSourceKey:yn,setBugMonitorRepo:Kt,setBugMonitorRequireApproval:an,setBugMonitorResettingSourceKey:_n,setBugMonitorWorkspaceBrowserDir:Nn,setBugMonitorWorkspaceBrowserOpen:jn,setBugMonitorWorkspaceBrowserSearch:Fn,setBugMonitorWorkspaceRoot:Wt,setChannelDrafts:st,setChannelToolScopeOpen:ft,setChannelToolScopeSelection:ut,setChannelVerifyResult:mt,setCodexAuthFileName:zn,setCodexAuthJsonText:at,setCustomProviderApiKey:tt,setCustomProviderFormOpen:Ge,setCustomProviderId:Ye,setCustomProviderMakeDefault:rt,setCustomProviderModel:$e,setCustomProviderUrl:Ze,setDefaultsMutation:wr,setDiagnosticsOpen:ze,setGithubMcpGuideOpen:Ve,setInstallConfigError:X,setInstallConfigText:oe,setMcpAuthMode:St,setMcpCatalogSearch:Rt,setMcpConnectAfterAdd:Mt,setMcpCustomHeader:Et,setMcpEditingName:Pt,setMcpExtraHeaders:At,setMcpGithubToolsets:Ot,setMcpModalOpen:gt,setMcpModalTab:It,setMcpName:vt,setMcpToken:wt,setMcpTransport:bt,setModelSearchByProvider:O,setNavigationRouteVisibility:Ji,setOauthSessionByProvider:qe,setProviderDefaultsOpen:Ue,setSchedulerMaxConcurrent:Le,setSchedulerMode:Fe,setSearchBackend:Z,setSearchBraveKey:Ee,setSearchExaKey:Oe,setSearchSearxngUrl:xe,setSearchTandemUrl:Q,setSearchTestQuery:Ae,setSearchTestResult:Ne,setSearchTimeoutMs:Ce,setWorktreeCleanupDryRun:Tn,setWorktreeCleanupPulse:Dn,setWorktreeCleanupRepoRoot:Cn,setWorktreeCleanupResult:kn,showAllNavigationSections:Yi,smokeTestBrowserMutation:cr,systemHealthQuery:Jn,testSearchMutation:Jr,useLocalCodexSessionMutation:Ur,verifyChannelMutation:ti,visibleNavigationCount:ea,worktreeCleanupActionRows:Hi,worktreeCleanupDryRun:wn,worktreeCleanupMutation:lr,worktreeCleanupPendingMessage:Vi,worktreeCleanupPendingMessages:Bi,worktreeCleanupPulse:En,worktreeCleanupRepoRoot:Sn,worktreeCleanupResult:On}}function Ne({controller:e}){let{activeSection:n,advancedNavigationRows:r,api:i,applyDefaultModel:a,authorizeProviderOAuthMutation:o,codexAuthFileName:s,codexAuthInputRef:c,codexAuthJsonText:f,connectedProviderCount:p,customConfiguredProviders:m,customProviderApiKey:g,customProviderFormOpen:_,customProviderId:y,customProviderMakeDefault:b,customProviderModel:x,customProviderUrl:C,defaultNavigationRows:w,disconnectProviderOAuthMutation:E,hiddenAdvancedNavigationCount:D,hostedManaged:O,importCodexAuthFile:k,importCodexAuthJsonMutation:A,installConfigError:j,installConfigQuery:M,installConfigText:N,installProfileQuery:P,localEngine:F,modelSearchByProvider:I,navigation:L,navigationRows:R,oauthSessionByProvider:ee,providerAuthById:z,providerDefaultsOpen:B,providers:H,providersCatalog:U,providersConfig:W,refreshProviderStatus:G,saveCustomProviderMutation:te,saveInstallConfigMutation:K,setActiveSection:ne,setApiKeyMutation:re,setCodexAuthJsonText:q,setCustomProviderApiKey:ie,setCustomProviderFormOpen:ae,setCustomProviderId:J,setCustomProviderMakeDefault:oe,setCustomProviderModel:se,setCustomProviderUrl:ce,setDefaultsMutation:Y,setInstallConfigText:le,setModelSearchByProvider:ue,setNavigationRouteVisibility:de,setOauthSessionByProvider:fe,setProviderDefaultsOpen:pe,resetNavigationSections:me,toast:he,useLocalCodexSessionMutation:X,visibleNavigationCount:ge,showAllNavigationSections:_e}=e,ve=Array.isArray(R)?R:[],Z=Array.isArray(w)?w:[],ye=Array.isArray(r)?r:[],Q=Array.isArray(m)?m:[],be=Array.isArray(H)?H:[];return l(t,{children:[n===`navigation`?l(v,{title:`Sidebar navigation`,subtitle:L?.acaMode?`ACA mode keeps Dashboard, Chat, Coder, and Settings visible by default.`:`Choose which sections appear in the sidebar. Advanced and experimental surfaces stay hidden until you turn them on.`,actions:l(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[l(h,{tone:L?.acaMode?`ok`:`info`,children:L?.acaMode?`ACA compact default`:`Core-first default`}),l(h,{tone:`ghost`,children:[ge,`/`,ve.length,` visible`]}),l(`button`,{className:`tcp-btn`,type:`button`,onClick:()=>_e(),children:`Show all sections`}),l(`button`,{className:`tcp-btn-primary`,type:`button`,onClick:()=>me(),children:[`Reset `,L?.acaMode?`ACA compact`:`default`]})]}),children:l(`div`,{className:`grid gap-4`,children:[l(`div`,{className:`rounded-2xl border border-slate-700/60 bg-slate-950/25 p-4`,children:[l(`div`,{className:`flex items-center justify-between gap-3`,children:[l(`div`,{children:[l(`div`,{className:`font-medium`,children:`Default sections`}),l(`div`,{className:`tcp-subtle mt-1 text-xs`,children:`These sections are part of the standard control panel and start on by default.`})]}),l(h,{tone:`ok`,children:[Z.filter(e=>e.enabled).length,`/`,Z.length,` shown`]})]}),l(`div`,{className:`mt-3 grid gap-2`,children:Z.map(e=>l(`button`,{type:`button`,"aria-pressed":e.enabled,title:`${e.enabled?`Hide`:`Show`} ${e.label} in the sidebar`,className:`flex items-center justify-between rounded-xl border px-3 py-3 text-left transition ${e.enabled?`border-lime-500/40 bg-lime-500/10 hover:border-lime-400/70`:`border-slate-700/60 bg-slate-900/20 hover:border-slate-500/70`}`,onClick:()=>de(e.routeId,!e.enabled),children:[l(`div`,{className:`flex min-w-0 items-center gap-3`,children:[l(`span`,{className:`flex h-9 w-9 items-center justify-center rounded-lg border ${e.enabled?`border-lime-500/30 bg-lime-500/10 text-lime-200`:`border-slate-700/70 bg-slate-950/30 text-slate-300`}`,children:l(`i`,{"data-lucide":e.icon})}),l(`div`,{className:`min-w-0`,children:[l(`div`,{className:`font-medium`,children:e.label}),l(`div`,{className:`tcp-subtle truncate text-xs`,children:e.description})]})]}),l(`div`,{className:`flex items-center gap-2`,children:[e.defaultVisible?l(h,{tone:`info`,children:`Default`}):null,l(h,{tone:e.enabled?`warn`:`ok`,children:e.enabled?`Hide`:`Show`})]})]},e.routeId))})]}),l(`div`,{className:`rounded-2xl border border-slate-700/60 bg-slate-950/25 p-4`,children:[l(`div`,{className:`flex items-center justify-between gap-3`,children:[l(`div`,{children:[l(`div`,{className:`font-medium`,children:`Advanced / experimental sections`}),l(`div`,{className:`tcp-subtle mt-1 text-xs`,children:`Only routes that ship hidden by default live here.`})]}),l(h,{tone:D>0?`warn`:`ok`,children:[D,` hidden`]})]}),l(`div`,{className:`mt-3 grid gap-2`,children:ye.map(e=>l(`button`,{type:`button`,"aria-pressed":e.enabled,title:`${e.enabled?`Hide`:`Show`} ${e.label} in the sidebar`,className:`flex items-center justify-between rounded-xl border px-3 py-3 text-left transition ${e.enabled?`border-lime-500/40 bg-lime-500/10 hover:border-lime-400/70`:`border-slate-700/60 bg-slate-900/20 hover:border-slate-500/70`}`,onClick:()=>de(e.routeId,!e.enabled),children:[l(`div`,{className:`flex min-w-0 items-center gap-3`,children:[l(`span`,{className:`flex h-9 w-9 items-center justify-center rounded-lg border ${e.enabled?`border-lime-500/30 bg-lime-500/10 text-lime-200`:`border-slate-700/70 bg-slate-950/30 text-slate-300`}`,children:l(`i`,{"data-lucide":e.icon})}),l(`div`,{className:`min-w-0`,children:[l(`div`,{className:`font-medium`,children:e.label}),l(`div`,{className:`tcp-subtle truncate text-xs`,children:e.description})]})]}),l(h,{tone:e.enabled?`warn`:`ok`,children:e.enabled?`Hide`:`Show`})]},e.routeId))})]}),l(`div`,{className:`tcp-subtle text-xs`,children:`These preferences are stored in this browser only.`})]})}):null,n===`install`?l(v,{title:`Install config`,subtitle:`Durable non-secret install preferences stored in tandem-data for Tandem startup and navigation defaults.`,actions:l(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[l(h,{tone:String(P.data?.control_panel_mode||``).trim().toLowerCase()===`aca`?`ok`:`info`,children:P.data?.control_panel_mode||`auto`}),l(h,{tone:P.data?.control_panel_config_ready?`ok`:`warn`,children:P.data?.control_panel_config_ready?`Ready`:`Needs setup`}),l(`button`,{type:`button`,className:`tcp-btn`,onClick:()=>M.refetch().then(()=>he(`ok`,`Install config refreshed.`)),children:[l(`i`,{"data-lucide":`refresh-cw`}),`Refresh`]}),l(`button`,{type:`button`,className:`tcp-btn-primary`,onClick:()=>K.mutate(),disabled:K.isPending,children:[l(`i`,{"data-lucide":`save`}),`Save config`]})]}),children:l(`div`,{className:`grid gap-4`,children:[l(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[l(`div`,{className:`rounded-2xl border border-slate-700/60 bg-slate-950/25 p-4`,children:[l(`div`,{className:`font-medium`,children:`Startup profile`}),l(`div`,{className:`tcp-subtle mt-1 text-xs`,children:P.data?.control_panel_mode_reason||`The control panel auto-detects its startup mode and can be overridden with TANDEM_CONTROL_PANEL_MODE.`}),l(`div`,{className:`mt-3 grid gap-2 text-xs`,children:[l(`div`,{className:`flex items-center justify-between gap-3`,children:[l(`span`,{className:`tcp-subtle`,children:`Mode source`}),l(`span`,{children:P.data?.control_panel_mode_source||`detected`})]}),l(`div`,{className:`flex items-center justify-between gap-3`,children:[l(`span`,{className:`tcp-subtle`,children:`Integration detected`}),l(`span`,{children:P.data?.aca_integration?`yes`:`no`})]}),l(`div`,{className:`flex items-center justify-between gap-3`,children:[l(`span`,{className:`tcp-subtle`,children:`Compact nav`}),l(`span`,{children:P.data?.control_panel_compact_nav?`on`:`off`})]})]})]}),l(`div`,{className:`rounded-2xl border border-slate-700/60 bg-slate-950/25 p-4`,children:[l(`div`,{className:`font-medium`,children:`Hosted management`}),l(`div`,{className:`tcp-subtle mt-1 text-xs`,children:`Detect whether this panel is running on a Tandem-managed hosted deployment so hosted-only update and notification UX can stay gated.`}),l(`div`,{className:`mt-3 grid gap-2 text-xs`,children:[l(`div`,{className:`flex items-center justify-between gap-3`,children:[l(`span`,{className:`tcp-subtle`,children:`Managed hosted server`}),l(`span`,{children:P.data?.hosted_managed?`yes`:`no`})]}),l(`div`,{className:`flex items-center justify-between gap-3`,children:[l(`span`,{className:`tcp-subtle`,children:`Provider`}),l(`span`,{children:P.data?.hosted_provider||`—`})]}),l(`div`,{className:`flex items-center justify-between gap-3`,children:[l(`span`,{className:`tcp-subtle`,children:`Deployment slug`}),l(`span`,{children:P.data?.hosted_deployment_slug||`—`})]}),l(`div`,{className:`flex items-center justify-between gap-3`,children:[l(`span`,{className:`tcp-subtle`,children:`Release`}),l(`span`,{children:[P.data?.hosted_release_version||`—`,P.data?.hosted_release_channel?` · ${P.data.hosted_release_channel}`:``]})]}),l(`div`,{className:`flex items-center justify-between gap-3`,children:[l(`span`,{className:`tcp-subtle`,children:`Update policy`}),l(`span`,{children:P.data?.hosted_update_policy||`—`})]})]}),P.data?.hosted_managed?l(`div`,{className:`mt-3 rounded-xl border border-lime-500/20 bg-lime-500/10 px-3 py-2 text-xs text-lime-200`,children:`Hosted-managed features can safely key off this signal instead of guessing from hostname or environment.`}):null]}),l(`div`,{className:`rounded-2xl border border-slate-700/60 bg-slate-950/25 p-4`,children:[l(`div`,{className:`font-medium`,children:`Config file`}),l(`div`,{className:`tcp-subtle mt-1 break-all text-xs`,children:P.data?.control_panel_config_path||M.data?.path||`control-panel-config.json`}),l(`div`,{className:`mt-3 grid gap-2 text-xs`,children:[l(`div`,{className:`flex items-center justify-between gap-3`,children:[l(`span`,{className:`tcp-subtle`,children:`Ready`}),l(`span`,{children:P.data?.control_panel_config_ready?`yes`:`no`})]}),l(`div`,{className:`flex items-center justify-between gap-3`,children:[l(`span`,{className:`tcp-subtle`,children:`Missing`}),l(`span`,{children:Array.isArray(P.data?.control_panel_config_missing)?P.data?.control_panel_config_missing.join(`, `)||`none`:`unknown`})]})]})]})]}),l(`label`,{className:`grid gap-2`,children:[l(`span`,{className:`text-sm font-medium`,children:`Control panel config JSON`}),l(`textarea`,{className:`tcp-input min-h-[28rem] font-mono text-xs leading-5`,value:N,onInput:e=>le(e.target.value),spellCheck:!1})]}),j?l(`div`,{className:`rounded-xl border border-rose-500/30 bg-rose-500/10 px-3 py-2 text-sm text-rose-200`,children:j}):null,l(`div`,{className:`tcp-subtle text-xs`,children:"This file holds non-secret install state: repo binding, provider defaults, task source, swarm policy, GitHub MCP preferences, and navigation defaults. Secrets should stay in `.env` or token files."})]})}):null,n===`providers`?l(v,{title:`Provider defaults`,subtitle:`Provider catalog, model selection, and API key entry.`,actions:l(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[l(h,{tone:String(W.data?.default||``).trim()?`ok`:`warn`,children:[`Default: `,String(W.data?.default||`none`)]}),l(h,{tone:`info`,children:[p,` connected`]}),l(`button`,{className:`tcp-btn`,onClick:()=>G().then(()=>he(`ok`,`Provider status refreshed.`)),children:[l(`i`,{"data-lucide":`refresh-cw`}),`Refresh provider`]})]}),children:l(`div`,{className:`grid gap-3`,children:[l(`button`,{type:`button`,className:`tcp-list-item text-left`,onClick:()=>pe(e=>!e),"aria-expanded":B,children:l(`div`,{className:`flex items-center justify-between gap-3`,children:[l(`div`,{children:[l(`div`,{className:`font-medium inline-flex items-center gap-2`,children:[l(`i`,{"data-lucide":B?`chevron-down`:`chevron-right`}),l(`span`,{children:B?`Hide provider catalog`:`Show provider catalog`})]}),l(`div`,{className:`tcp-subtle mt-1 text-xs`,children:[be.length,` providers available for configuration. Expand to change models and API keys.`]})]}),l(h,{tone:`info`,children:[p,` connected`]})]})}),l(d,{initial:!1,children:B?l(u.div,{className:`grid gap-3`,initial:{opacity:0,y:-8},animate:{opacity:1,y:0},exit:{opacity:0,y:-8},children:[l(`div`,{className:`tcp-list-item grid gap-3`,children:[l(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[l(`div`,{children:[l(`div`,{className:`font-medium`,children:`Custom OpenAI-compatible provider`}),l(`div`,{className:`tcp-subtle mt-1 text-xs`,children:`Add providers like MiniMax by ID, base URL, default model, and API key.`})]}),l(h,{tone:Q.length?`ok`:`info`,children:[Q.length,` configured`]})]}),l(`button`,{type:`button`,className:`tcp-list-item text-left`,onClick:()=>ae(e=>!e),"aria-expanded":_,children:l(`div`,{className:`flex items-center justify-between gap-3`,children:[l(`div`,{children:[l(`div`,{className:`font-medium inline-flex items-center gap-2`,children:[l(`i`,{"data-lucide":_?`chevron-down`:`chevron-right`}),l(`span`,{children:_?`Hide custom provider form`:`Show custom provider form`})]}),l(`div`,{className:`tcp-subtle mt-1 text-xs`,children:`Use this for OpenAI-compatible endpoints. Anthropic is handled by the built-in provider row below.`})]}),l(h,{tone:`info`,children:`OpenAI-compatible only`})]})}),l(d,{initial:!1,children:_?l(u.div,{className:`grid gap-3`,initial:{opacity:0,y:-8},animate:{opacity:1,y:0},exit:{opacity:0,y:-8},children:l(`form`,{className:`grid gap-3`,onSubmit:e=>{e.preventDefault(),te.mutate({providerId:y,url:C,modelId:x,apiKey:g,makeDefault:b})},children:[l(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[l(`div`,{className:`grid gap-2`,children:[l(`label`,{className:`text-sm font-medium`,children:`Provider ID`}),l(`input`,{className:`tcp-input`,value:y,onInput:e=>J(e.target.value),placeholder:`custom`})]}),l(`div`,{className:`grid gap-2`,children:[l(`label`,{className:`text-sm font-medium`,children:`Default model`}),l(`input`,{className:`tcp-input`,value:x,onInput:e=>se(e.target.value),placeholder:`MiniMax-M2`})]})]}),l(`div`,{className:`grid gap-2`,children:[l(`label`,{className:`text-sm font-medium`,children:`Base URL`}),l(`input`,{className:`tcp-input`,value:C,onInput:e=>ce(e.target.value),placeholder:`https://api.minimax.io/v1`})]}),l(`div`,{className:`grid gap-2`,children:[l(`label`,{className:`text-sm font-medium`,children:`API key`}),l(`input`,{className:`tcp-input`,type:`password`,value:g,onInput:e=>ie(e.target.value),placeholder:`Optional. Leave blank to keep the existing key.`})]}),l(`label`,{className:`inline-flex items-center gap-2 text-sm text-slate-200`,children:[l(`input`,{type:`checkbox`,className:`accent-slate-400`,checked:b,onChange:e=>oe(e.target.checked)}),`Make this the default provider`]}),l(`div`,{className:`flex flex-wrap justify-end gap-2`,children:l(`button`,{className:`tcp-btn-primary`,type:`submit`,disabled:te.isPending,children:[l(`i`,{"data-lucide":`plus`}),`Save custom provider`]})})]})}):null}),Q.length?l(`div`,{className:`grid gap-2`,children:Q.map(e=>l(`div`,{className:`flex flex-wrap items-start justify-between gap-2 rounded-xl border border-slate-700/60 bg-slate-900/20 px-3 py-2`,children:[l(`div`,{className:`min-w-0`,children:[l(`div`,{className:`font-medium`,children:e.id}),l(`div`,{className:`tcp-subtle break-all text-xs`,children:e.url||`No URL configured`}),l(`div`,{className:`tcp-subtle text-xs`,children:[`Model: `,e.model||`not set`]})]}),l(`div`,{className:`flex flex-wrap gap-2`,children:[e.isDefault?l(h,{tone:`ok`,children:`default`}):null,l(`button`,{type:`button`,className:`tcp-btn h-8 px-3 text-xs`,onClick:()=>{J(e.id),ce(e.url),se(e.model),oe(e.isDefault),ae(!0),pe(!0)},children:[l(`i`,{"data-lucide":`square-pen`}),`Edit`]})]})]},e.id))}):null]}),U.isPending?l(`div`,{className:`tcp-list-item grid gap-2`,children:[l(`div`,{className:`font-medium`,children:`Loading provider catalog`}),l(`div`,{className:`tcp-subtle text-xs`,children:`Tandem is checking live provider models and auth state now.`})]}):be.length?be.map(e=>{let t=String(e?.id||``),n=Object.keys(e?.models||{}),r=String(W.data?.providers?.[t]?.default_model||n[0]||``),i=String(I[t]??r).trim(),d=i.toLowerCase(),p=n.filter(e=>d?e.toLowerCase().includes(d):!0).slice(0,80),m=ke(e,n.length),g=Ae(e,r),_=S[t]||null,v=String(_?.keyUrl||``).trim(),y=z[t]||{},b=String(W.data?.default||``).trim().toLowerCase(),x=t===`openai-codex`&&b===`openai-codex`,C=String(y?.auth_kind||y?.authKind||``).trim().toLowerCase(),w=String(y?.status||``).trim().toLowerCase(),T=String(y?.email||``).trim(),D=String(y?.display_name||y?.displayName||``).trim(),j=String(y?.managed_by||y?.managedBy||``).trim(),M=Number(y?.expires_at_ms||y?.expiresAtMs||0),N=y?.local_session_available===!0||y?.localSessionAvailable===!0,P=!!String(ee[t]||``).trim()||o.isPending&&String(o.variables?.providerId||``).trim().toLowerCase()===t,L=C===`oauth`&&y?.connected===!0&&w!==`reauth_required`,R=t===V,B=!R||F||O,H=P?{tone:`info`,text:`sign-in pending`}:L?{tone:`ok`,text:`account connected`}:w===`reauth_required`?{tone:`warn`,text:`reauth required`}:{tone:`warn`,text:`not connected`},U=O&&t===`openai-codex`;return l(u.details,{layout:!0,className:`tcp-list-item`,children:[l(`summary`,{className:`cursor-pointer list-none`,children:l(`div`,{className:`flex items-center justify-between gap-3`,children:[l(`div`,{children:[l(`div`,{className:`font-medium`,children:t}),l(`div`,{className:`tcp-subtle text-xs`,children:g})]}),l(h,{tone:m.tone,children:m.text})]})}),l(`div`,{className:`mt-3 grid gap-3`,children:[v&&!R?l(`div`,{className:`flex justify-end`,children:l(`a`,{className:`tcp-btn h-8 px-3 text-xs`,href:v,target:`_blank`,rel:`noreferrer`,children:[l(`i`,{"data-lucide":`external-link`}),`Get API key`]})}):null,l(`form`,{className:`grid gap-2`,onSubmit:e=>{e.preventDefault(),a(t,i)},children:[l(`div`,{className:`flex gap-2`,children:[l(`input`,{className:`tcp-input`,value:i,placeholder:`Type model id for ${t}`,onInput:e=>ue(n=>({...n,[t]:e.target.value}))}),l(`button`,{className:`tcp-btn`,type:`submit`,children:[l(`i`,{"data-lucide":`badge-check`}),`Apply`]})]}),l(`div`,{className:`max-h-48 overflow-auto rounded-xl border border-slate-700/60 bg-slate-900/20 p-1`,children:p.length?p.map(e=>l(`button`,{type:`button`,className:`block w-full rounded-lg px-2 py-1.5 text-left text-sm hover:bg-slate-700/30 ${e===r?`bg-slate-700/40`:``}`,onClick:()=>{ue(n=>({...n,[t]:e})),a(t,e)},children:e},e)):l(`div`,{className:`tcp-subtle px-2 py-1 text-xs`,children:n.length?`No matching models.`:`No live catalog available. Type a model ID manually.`})})]}),R?l(`div`,{className:`grid gap-3 rounded-xl border border-slate-700/60 bg-slate-900/20 p-3`,children:[l(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[l(`div`,{className:`min-w-0`,children:[l(`div`,{className:`font-medium`,children:String(_?.label||`Codex Account`)}),l(`div`,{className:`tcp-subtle text-xs`,children:String(_?.description||`Use your ChatGPT/Codex subscription instead of a separate API key.`)})]}),l(h,{tone:H.tone,children:H.text})]}),l(`div`,{className:`grid gap-1 text-xs tcp-subtle`,children:[U?l(`div`,{className:`rounded-xl border border-sky-700/50 bg-sky-950/20 px-3 py-2 text-sky-100`,children:[l(`div`,{className:`font-medium`,children:`Recommended for hosted servers`}),l(`div`,{className:`mt-1`,children:[`Import a Codex `,l(`code`,{children:`auth.json`}),` from a signed-in machine. Browser OAuth on provisioned servers can stall after the consent screen, so the import path is the reliable v1 flow.`]})]}):null,P?l(`div`,{children:`Pending browser sign-in is saved in this browser session, so you can refresh this page and Tandem will keep checking when you come back.`}):null,L?l(`div`,{children:D||T?`Connected as ${D||T}.`:`Connected to a Codex account.`}):null,j?l(`div`,{children:[`Managed by`,` `,j===`codex-cli`?`the local Codex CLI session`:j===`codex-upload`?`an uploaded Codex auth.json`:`Tandem`,`.`]}):null,U&&L&&j===`codex-upload`?l(`div`,{children:[`This hosted server is currently using an imported Codex session stored on the VM. Import another`,` `,l(`code`,{children:`auth.json`}),` any time to replace it.`]}):null,M>0?l(`div`,{children:[`Session status refreshes through`,` `,new Date(M).toLocaleString(),`.`]}):null,t===`openai-codex`&&L&&!x?l(`div`,{children:`Tandem is connected to Codex, but new runs are still using a different default provider.`}):null,B?l(`div`,{children:U?`This Tandem-hosted server can import a Codex auth.json from a signed-in machine and keep the session on the VM.`:N?`Local Codex CLI session detected on this machine.`:`If the Codex CLI is already signed in on this machine, you can mirror that session here instead of starting a fresh browser login.`}):null,B?null:l(`div`,{children:`Codex account sign-in is only enabled when this control panel is connected to a local engine or a Tandem-hosted managed server.`})]}),U?l(`div`,{className:`grid gap-3`,children:[l(`input`,{ref:c,type:`file`,accept:`.json,application/json`,className:`hidden`,onChange:e=>{k(t,e.target.files?.[0]||null)}}),l(`textarea`,{className:`tcp-input min-h-40 resize-y rounded-xl p-3 font-mono text-xs leading-5`,value:f,onChange:e=>q(e.target.value),placeholder:`Paste the contents of ~/.codex/auth.json here.
2
+
3
+ Tandem will store it on this server and reuse it for Codex sessions.`}),l(`div`,{className:`grid gap-1 text-xs tcp-subtle`,children:[l(`div`,{children:`You can paste the JSON directly, or choose the file from a signed-in machine.`}),s?l(`div`,{children:[`Loaded file: `,s]}):null]}),l(`div`,{className:`flex flex-wrap gap-2`,children:[l(`button`,{type:`button`,className:`tcp-btn`,disabled:!B||!f.trim()||A.isPending||E.isPending,onClick:()=>A.mutate({providerId:t,authJson:f}),children:[l(`i`,{"data-lucide":`upload`}),L?`Replace hosted Codex session`:`Import pasted auth.json`]}),l(`button`,{type:`button`,className:`tcp-btn`,disabled:A.isPending||E.isPending,onClick:()=>c.current?.click(),children:[l(`i`,{"data-lucide":`file-up`}),`Choose auth.json file`]}),N?l(`button`,{type:`button`,className:`tcp-btn h-10 px-4 text-sm`,disabled:!B||o.isPending||X.isPending,onClick:()=>{fe(e=>{if(!e[t])return e;let n={...e};return delete n[t],n}),X.mutate({providerId:t})},children:[l(`i`,{"data-lucide":`link-2`}),`Use Local Codex Session`]}):null,t===`openai-codex`&&L&&!x?l(`button`,{type:`button`,className:`tcp-btn h-10 px-4 text-sm`,disabled:Y.isPending,onClick:()=>Y.mutate({providerId:t,modelId:r||`gpt-5.4`}),children:[l(`i`,{"data-lucide":`sparkles`}),`Use for Tandem Runs`]}):null,l(`button`,{type:`button`,className:`tcp-btn h-10 px-4 text-sm`,disabled:!L||E.isPending||A.isPending||P,onClick:()=>E.mutate({providerId:t}),children:[l(`i`,{"data-lucide":`unlink`}),`Disconnect`]})]})]}):l(`div`,{className:`flex flex-wrap gap-2`,children:[l(`button`,{type:`button`,className:`tcp-btn`,disabled:!B||P||E.isPending,onClick:()=>o.mutate({providerId:t}),children:[l(`i`,{"data-lucide":`log-in`}),L?`Reconnect Codex Account`:`Connect Codex Account`]}),F&&t===`openai-codex`&&N?l(`button`,{type:`button`,className:`tcp-btn h-10 px-4 text-sm`,disabled:!B||o.isPending||X.isPending,onClick:()=>{fe(e=>{if(!e[t])return e;let n={...e};return delete n[t],n}),X.mutate({providerId:t})},children:[l(`i`,{"data-lucide":`link-2`}),`Use Local Codex Session`]}):null,t===`openai-codex`&&L&&!x?l(`button`,{type:`button`,className:`tcp-btn h-10 px-4 text-sm`,disabled:Y.isPending,onClick:()=>Y.mutate({providerId:t,modelId:r||`gpt-5.4`}),children:[l(`i`,{"data-lucide":`sparkles`}),`Use for Tandem Runs`]}):null,l(`button`,{type:`button`,className:`tcp-btn h-10 px-4 text-sm`,disabled:!L||E.isPending||P,onClick:()=>E.mutate({providerId:t}),children:[l(`i`,{"data-lucide":`unlink`}),`Disconnect`]}),P?l(`button`,{type:`button`,className:`tcp-btn h-10 px-4 text-sm`,onClick:()=>window.open(`https://chatgpt.com/codex`,`_blank`,`noopener,noreferrer`),children:[l(`i`,{"data-lucide":`external-link`}),`Open Codex`]}):null]})]}):l(`form`,{onSubmit:e=>{e.preventDefault();let n=e.currentTarget.elements.namedItem(`apiKey`),r=String(n?.value||``).trim();r&&(re.mutate({providerId:t,apiKey:r}),n.value=``)},className:`flex gap-2`,children:[l(`input`,{name:`apiKey`,className:`tcp-input`,placeholder:String(_?.placeholder||`Set ${t} API key`)}),l(`button`,{className:`tcp-btn`,type:`submit`,children:[l(`i`,{"data-lucide":`save`}),`Save`]})]})]})]},t)}):l(T,{text:`No provider catalog is available yet. You can still enter a model ID manually for custom providers.`})]}):null})]})}):null]})}function Pe({theme:e}){let t=e?.cssVars?.[`--color-background`]||`#000000`,n=e?.cssVars?.[`--color-surface`]||`#111111`,r=e?.cssVars?.[`--color-primary`]||`#ffffff`,i=e?.cssVars?.[`--color-secondary`]||`#ffffff`;return l(`div`,{className:`flex items-center gap-2`,children:[l(`span`,{className:`tcp-theme-swatch`,style:{background:t},"aria-hidden":`true`}),l(`span`,{className:`tcp-theme-swatch`,style:{background:n},"aria-hidden":`true`}),l(`span`,{className:`tcp-theme-swatch`,style:{background:r},"aria-hidden":`true`}),l(`span`,{className:`tcp-theme-swatch`,style:{background:i},"aria-hidden":`true`})]})}function Fe({themes:e,themeId:t,onChange:n}){return l(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2`,children:e.map(e=>{let r=e.id===t;return l(u.button,{type:`button`,layout:!0,onClick:()=>n(e.id),className:`tcp-theme-tile ${r?`active`:``}`,whileHover:{y:-2},whileTap:{scale:.985},transition:y.spring.gentle,children:[l(`div`,{className:`tcp-theme-tile-top`,children:[l(`div`,{className:`min-w-0`,children:[l(`div`,{className:`tcp-theme-tile-title`,children:e.name}),l(`p`,{className:`tcp-subtle mt-1 text-xs`,children:e.description})]}),l(Pe,{theme:e})]}),l(`div`,{className:`tcp-theme-preview`,children:l(`div`,{className:`tcp-theme-preview-bg`,style:{background:e.cssVars[`--color-background`]||`#000`},children:l(`div`,{className:`tcp-theme-preview-card`,style:{background:e.cssVars[`--color-surface`]||`#111`,borderColor:e.cssVars[`--color-border`]||`rgba(255,255,255,0.1)`},children:[l(`div`,{className:`tcp-theme-preview-line short`,style:{background:e.cssVars[`--color-text`]||`#fff`}}),l(`div`,{className:`tcp-theme-preview-line`,style:{background:e.cssVars[`--color-text-muted`]||`#aaa`}}),l(`div`,{className:`tcp-theme-preview-pill`,style:{background:e.cssVars[`--color-primary`]||`#fff`}})]})})}),l(d,{initial:!1,children:r?l(u.span,{className:`tcp-theme-active`,initial:{opacity:0,scale:.86},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.86},transition:y.spring.snappy,children:[l(`i`,{"data-lucide":`badge-check`}),`Active`]}):null})]},e.id)})})}function Ie({controller:e}){let{activeSection:n,avatarInputRef:r,botAvatarUrl:i,botControlPanelAlias:a,botName:o,handleAvatarUpload:s,identity:c,refreshIdentityStatus:u,saveIdentityMutation:d,saveSchedulerSettingsMutation:f,saveSearchSettingsMutation:p,schedulerMaxConcurrent:g,schedulerMode:_,schedulerSettingsQuery:y,searchBackend:b,searchBraveKey:x,searchExaKey:S,searchSearxngUrl:C,searchSettingsQuery:w,searchTandemUrl:T,searchTestQuery:D,searchTestResult:O,searchTimeoutMs:k,setBotAvatarUrl:A,setBotControlPanelAlias:j,setBotName:M,setSchedulerMaxConcurrent:N,setSchedulerMode:P,setSearchBackend:F,setSearchBraveKey:I,setSearchExaKey:L,setSearchSearxngUrl:R,setSearchTandemUrl:ee,setSearchTestQuery:z,setSearchTimeoutMs:B,setTheme:V,testSearchMutation:H,themeId:U,themes:W,toast:G}=e;return l(t,{children:[n===`search`?l(v,{title:`Web Search`,subtitle:"Configure the engine's `websearch` backend and provider keys.",actions:l(m,{children:[l(h,{tone:w.data?.settings?.has_brave_key?`ok`:`warn`,children:[`Brave `,w.data?.settings?.has_brave_key?`configured`:`missing`]}),l(h,{tone:w.data?.settings?.has_exa_key?`ok`:`warn`,children:[`Exa `,w.data?.settings?.has_exa_key?`configured`:`missing`]}),l(`button`,{className:`tcp-btn`,onClick:()=>H.mutate({query:D.trim()}),disabled:!w.data?.available||!D.trim()||H.isPending,children:[l(`i`,{"data-lucide":H.isPending?`loader-circle`:`search`}),H.isPending?`Testing...`:`Test search`]}),l(`button`,{className:`tcp-btn-primary`,onClick:()=>p.mutate({backend:b,tandem_url:T,searxng_url:C,timeout_ms:Number.parseInt(k||`10000`,10),brave_api_key:x.trim()||void 0,exa_api_key:S.trim()||void 0}),disabled:!w.data?.available||p.isPending,children:[l(`i`,{"data-lucide":`save`}),`Save`]})]}),children:w.data?.available?l(`div`,{className:`grid gap-4`,children:[l(`div`,{className:`rounded-2xl border border-slate-700/60 bg-slate-950/25 p-4 text-sm`,children:[l(`div`,{className:`font-medium`,children:`Engine env file`}),l(`div`,{className:`tcp-subtle mt-1 break-all`,children:w.data?.managed_env_path||`/etc/tandem/engine.env`}),l(`div`,{className:`tcp-subtle mt-2 text-xs`,children:w.data?.restart_hint||`Changes apply immediately.`})]}),l(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[l(`label`,{className:`grid gap-1 text-sm`,children:[l(`span`,{className:`tcp-subtle text-xs uppercase tracking-[0.18em]`,children:`Backend`}),l(`select`,{className:`tcp-select`,value:b,onChange:e=>F(e.target.value),children:[l(`option`,{value:`auto`,children:`Auto failover`}),l(`option`,{value:`brave`,children:`Brave Search`}),l(`option`,{value:`exa`,children:`Exa`}),l(`option`,{value:`searxng`,children:`SearxNG`}),l(`option`,{value:`tandem`,children:`Tandem hosted search`}),l(`option`,{value:`none`,children:`Disable websearch`})]})]}),l(`label`,{className:`grid gap-1 text-sm`,children:[l(`span`,{className:`tcp-subtle text-xs uppercase tracking-[0.18em]`,children:`Timeout (ms)`}),l(`input`,{className:`tcp-input`,type:`number`,min:1e3,max:12e4,value:k,onInput:e=>B(e.target.value)})]})]}),l(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[l(`label`,{className:`grid gap-1 text-sm`,children:[l(`span`,{className:`tcp-subtle text-xs uppercase tracking-[0.18em]`,children:`Tandem search URL`}),l(`input`,{className:`tcp-input`,placeholder:`https://search.tandem.ac`,value:T,onInput:e=>ee(e.target.value)}),l(`span`,{className:`tcp-subtle text-xs`,children:"Only used when backend is set to `tandem` or `auto`. This is the hosted Tandem search router, not the SearXNG endpoint."})]}),l(`label`,{className:`grid gap-1 text-sm`,children:[l(`span`,{className:`tcp-subtle text-xs uppercase tracking-[0.18em]`,children:`SearxNG URL`}),l(`input`,{className:`tcp-input`,placeholder:`http://127.0.0.1:8080`,value:C,onInput:e=>R(e.target.value)}),l(`span`,{className:`tcp-subtle text-xs`,children:"Only used when backend is `searxng` or `auto`."})]})]}),l(`div`,{className:`grid gap-3 rounded-2xl border border-slate-700/60 bg-slate-950/25 p-4`,children:[l(`div`,{className:`flex items-center justify-between gap-3`,children:[l(`div`,{children:[l(`div`,{className:`font-medium`,children:`Search test`}),l(`div`,{className:`tcp-subtle mt-1 text-xs`,children:"Runs `websearch` against the currently running engine config and renders the result as markdown below."})]}),l(h,{tone:`warn`,children:`Tests live engine config`})]}),l(`div`,{className:`grid gap-3 md:grid-cols-[minmax(0,1fr)_auto]`,children:[l(`input`,{className:`tcp-input`,placeholder:`Try a test query like autonomous AI agentic workflows`,value:D,onInput:e=>z(e.target.value)}),l(`button`,{className:`tcp-btn`,onClick:()=>H.mutate({query:D.trim()}),disabled:!w.data?.available||!D.trim()||H.isPending,children:[l(`i`,{"data-lucide":H.isPending?`loader-circle`:`play`}),H.isPending?`Running...`:`Run test`]})]}),O?.markdown?l(`div`,{className:`grid gap-2`,children:[l(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[l(h,{tone:`ok`,children:[`Backend`,` `,String(O.parsed_output?.backend||O.metadata?.backend||`unknown`)]}),O.parsed_output?.configured_backend?l(h,{tone:`info`,children:[`Configured `,String(O.parsed_output.configured_backend)]}):null,O.metadata?.error?l(h,{tone:`warn`,children:String(O.metadata.error).replaceAll(`_`,` `)}):null]}),l(`div`,{className:`tcp-markdown tcp-markdown-ai max-h-[320px] overflow-auto rounded-xl border border-slate-700/60 bg-black/20 p-3 text-sm`,dangerouslySetInnerHTML:{__html:E(O.markdown||``)}})]}):null]}),l(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[l(`div`,{className:`grid gap-2 rounded-2xl border border-slate-700/60 bg-slate-950/25 p-4`,children:[l(`div`,{className:`flex items-center justify-between gap-2`,children:[l(`div`,{className:`font-medium`,children:`Brave Search key`}),l(h,{tone:w.data?.settings?.has_brave_key?`ok`:`warn`,children:w.data?.settings?.has_brave_key?`Saved`:`Missing`})]}),l(`input`,{className:`tcp-input`,type:`password`,placeholder:`Paste Brave Search key`,value:x,onInput:e=>I(e.target.value)}),l(`div`,{className:`flex flex-wrap gap-2`,children:[l(`button`,{className:`tcp-btn`,onClick:()=>p.mutate({backend:b,tandem_url:T,searxng_url:C,timeout_ms:Number.parseInt(k||`10000`,10),brave_api_key:x.trim()||void 0}),disabled:!x.trim()||p.isPending,children:`Save Brave Key`}),w.data?.settings?.has_brave_key?l(`button`,{className:`tcp-btn`,onClick:()=>p.mutate({backend:b,tandem_url:T,searxng_url:C,timeout_ms:Number.parseInt(k||`10000`,10),clear_brave_key:!0}),disabled:p.isPending,children:`Remove`}):null]})]}),l(`div`,{className:`grid gap-2 rounded-2xl border border-slate-700/60 bg-slate-950/25 p-4`,children:[l(`div`,{className:`flex items-center justify-between gap-2`,children:[l(`div`,{className:`font-medium`,children:`Exa key`}),l(h,{tone:w.data?.settings?.has_exa_key?`ok`:`warn`,children:w.data?.settings?.has_exa_key?`Saved`:`Missing`})]}),l(`input`,{className:`tcp-input`,type:`password`,placeholder:`Paste Exa API key`,value:S,onInput:e=>L(e.target.value)}),l(`div`,{className:`flex flex-wrap gap-2`,children:[l(`button`,{className:`tcp-btn`,onClick:()=>p.mutate({backend:b,tandem_url:T,searxng_url:C,timeout_ms:Number.parseInt(k||`10000`,10),exa_api_key:S.trim()||void 0}),disabled:!S.trim()||p.isPending,children:`Save Exa Key`}),w.data?.settings?.has_exa_key?l(`button`,{className:`tcp-btn`,onClick:()=>p.mutate({backend:b,tandem_url:T,searxng_url:C,timeout_ms:Number.parseInt(k||`10000`,10),clear_exa_key:!0}),disabled:p.isPending,children:`Remove`}):null]})]})]}),l(`div`,{className:`tcp-subtle text-xs`,children:"`auto` tries the configured backends with failover. If Brave is rate-limited and Exa is configured, the engine can continue with Exa instead of returning a generic unavailable message."})]}):l(EmptyState,{text:w.data?.reason||`Search settings are only editable here when the panel points at a local engine host or a Tandem-hosted managed server.`})}):null,n===`scheduler`?l(v,{title:`Automation Scheduler`,subtitle:`Controls parallel execution of automation runs. Restart tandem-engine after changing.`,actions:l(m,{children:l(`button`,{className:`tcp-btn-primary`,onClick:()=>f.mutate({mode:_,max_concurrent_runs:g?Number.parseInt(g,10):null}),disabled:!y.data?.available||f.isPending,children:[l(`i`,{"data-lucide":`save`}),`Save`]})}),children:y.data?.available?l(`div`,{className:`grid gap-4`,children:[l(`div`,{className:`rounded-2xl border border-slate-700/60 bg-slate-950/25 p-4 text-sm`,children:[l(`div`,{className:`font-medium`,children:`Engine env file`}),l(`div`,{className:`tcp-subtle mt-1 break-all`,children:y.data?.managed_env_path||`/etc/tandem/engine.env`}),l(`div`,{className:`tcp-subtle mt-2 text-xs`,children:y.data?.restart_hint||`Restart tandem-engine after changing scheduler mode.`})]}),l(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[l(`label`,{className:`grid gap-1 text-sm`,children:[l(`span`,{className:`tcp-subtle text-xs uppercase tracking-[0.18em]`,children:`Mode`}),l(`select`,{className:`tcp-select`,value:_,onChange:e=>P(e.target.value),children:[l(`option`,{value:`multi`,children:`Multi — parallel runs (recommended)`}),l(`option`,{value:`single`,children:`Single — one run at a time`})]})]}),l(`label`,{className:`grid gap-1 text-sm`,children:[l(`span`,{className:`tcp-subtle text-xs uppercase tracking-[0.18em]`,children:`Max concurrent runs`}),l(`input`,{className:`tcp-input`,type:`number`,min:1,max:32,placeholder:`8 (default)`,value:g,onInput:e=>N(e.target.value)})]})]}),l(`div`,{className:`tcp-subtle text-xs`,children:`Multi mode allows several automation runs to execute concurrently. Max concurrent runs caps parallelism. Changes require a tandem-engine restart to take effect.`})]}):l(EmptyState,{text:y.data?.reason||`Scheduler settings are only editable here when the panel points at a local engine host or a Tandem-hosted managed server.`})}):null,n===`identity`?l(v,{title:`Identity preview`,subtitle:`Live preview of how the assistant appears across the panel.`,actions:l(m,{children:[l(`button`,{className:`tcp-btn`,onClick:()=>u().then(()=>G(`ok`,`Identity refreshed.`)),children:[l(`i`,{"data-lucide":`refresh-cw`}),`Refresh identity`]}),l(`button`,{className:`tcp-btn-primary`,onClick:()=>d.mutate(),disabled:d.isPending,children:[l(`i`,{"data-lucide":`save`}),`Save`]})]}),children:l(`div`,{className:`grid gap-3`,children:[l(`div`,{className:`rounded-2xl border border-slate-700/60 bg-slate-950/25 p-4`,children:l(`div`,{className:`flex items-center justify-between gap-3`,children:[l(`div`,{className:`inline-flex items-center gap-3`,children:[l(`span`,{className:`tcp-brand-avatar inline-grid h-12 w-12 rounded-xl`,children:l(`img`,{src:i||`/icon.png`,alt:o||`Tandem`,className:`block h-full w-full object-contain p-1`})}),l(`div`,{children:[l(`div`,{className:`font-semibold`,children:o||`Tandem`}),l(`div`,{className:`tcp-subtle text-xs`,children:a||`Control Center`})]})]}),l(m,{children:[l(`button`,{className:`tcp-icon-btn`,title:`Upload avatar`,"aria-label":`Upload avatar`,onClick:()=>r.current?.click(),children:l(`i`,{"data-lucide":`pencil`})}),l(`button`,{className:`tcp-icon-btn`,title:`Clear avatar`,"aria-label":`Clear avatar`,onClick:()=>A(``),children:l(`i`,{"data-lucide":`trash-2`})})]})]})}),l(`input`,{className:`tcp-input`,value:o,onInput:e=>M(e.target.value),placeholder:`Bot name`}),l(`input`,{className:`tcp-input`,value:a,onInput:e=>j(e.target.value),placeholder:`Control panel alias`}),l(`input`,{className:`tcp-input`,value:i,onInput:e=>A(e.target.value),placeholder:`Avatar URL or data URL`}),l(`input`,{ref:r,type:`file`,accept:`image/*`,className:`hidden`,onChange:e=>s(e.target.files?.[0]||null)})]})}):null,n===`theme`?l(v,{title:`Theme studio`,subtitle:`Preview tiles with richer feedback and immediate switching.`,children:l(Fe,{themes:W,themeId:U,onChange:V})}):null]})}function Le({controller:e}){let{activeSection:n,channelDefaultModel:r,channelDrafts:i,channelProviderOptions:a,channelScopesQuery:o,channelToolPreferencesQuery:s,channelToolScopeOpen:c,channelToolScopeSelection:f,channelVerifyResult:p,channelsConfigQuery:g,channelsStatusQuery:_,connectedChannelCount:y,connectedMcpCount:b,deleteChannelMutation:x,invalidateChannels:S,invalidateMcp:C,mcpActionMutation:w,mcpServers:T,mcpToolIds:E,mcpToolPolicyMutation:A,openMcpModal:j,providers:M,saveChannelMutation:N,saveChannelToolPreferencesMutation:P,setActiveSection:F,setChannelDrafts:I,setChannelToolScopeOpen:L,setChannelToolScopeSelection:R,verifyChannelMutation:ee}=e,z=Array.isArray(T)?T:[];return l(t,{children:[n===`channels`?l(v,{title:`Channel connections`,subtitle:`Telegram, Discord, and Slack delivery setup and live listener status.`,actions:l(m,{children:[l(h,{tone:y?`ok`:`warn`,children:[y,`/`,H.length,` connected`]}),l(`button`,{className:`tcp-btn`,onClick:()=>void S(),children:[l(`i`,{"data-lucide":`refresh-cw`}),`Refresh channels`]})]}),children:l(`div`,{className:`grid gap-3`,children:H.map(e=>{let t=g.data?.[e]||{},n=_.data?.[e]||{},m=i[e]||me(e,t),v=p[e],y=(o.data||{})[e]?.slice()||[],b=String(f[e]||``).trim(),S=y.find(e=>e.scope_id===b)||null,C=S?ve(S):b||`Channel default`,w=b?`scope`:`channel`,T=ge(s.data?.[e]||he()),E=z.map(e=>`mcp.${D(e.name)}.`),A=new Set(T.enabled_mcp_tools.filter(e=>E.some(t=>e.startsWith(t)))),j=new Set(T.enabled_mcp_servers.map(e=>`mcp.${D(e)}.`)),M=T.enabled_mcp_tools.filter(e=>Array.from(j).some(t=>e.startsWith(t))),F=m.securityProfile===`public_demo`,B=De(e,t),V=!Oe(e,m,t);return l(`div`,{className:`tcp-list-item grid gap-3`,children:[l(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[l(`div`,{children:[l(`div`,{className:`font-semibold capitalize`,children:e}),l(`div`,{className:`tcp-subtle text-xs`,children:e===`telegram`?`Bot token, allowed users, style profile, and optional model override.`:e===`discord`?`Bot token, allowed users, mention policy, guild targeting, and optional model override.`:`Bot token, allowed users, mention policy, default channel, and optional model override.`})]}),l(`div`,{className:`flex flex-wrap gap-2`,children:[l(h,{tone:n.connected?`ok`:`warn`,children:n.connected?`Connected`:n.enabled?`Configured`:`Disconnected`}),l(h,{tone:t.has_token?`info`:`warn`,children:t.has_token?`Token saved`:`No token`})]})]}),l(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[l(`input`,{className:`tcp-input`,type:`password`,placeholder:t.has_token?String(t.token_masked||`****`):`Paste ${e} bot token`,value:m.botToken,onInput:t=>I(n=>({...n,[e]:{...m,botToken:t.target.value}}))}),t.has_token&&!m.botToken?l(`div`,{className:`tcp-subtle text-xs`,children:`Token is already stored. Enter a new token only if you want to replace it.`}):null,l(`input`,{className:`tcp-input`,placeholder:`Allowed users (comma separated)`,value:m.allowedUsers,onInput:t=>I(n=>({...n,[e]:{...m,allowedUsers:t.target.value}}))})]}),l(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[l(`select`,{className:`tcp-input`,value:m.securityProfile,onInput:t=>I(n=>({...n,[e]:{...m,securityProfile:t.target.value}})),children:[l(`option`,{value:`operator`,children:`Operator`}),l(`option`,{value:`trusted_team`,children:`Trusted team`}),l(`option`,{value:`public_demo`,children:`Public demo`})]}),e===`telegram`?l(`input`,{className:`tcp-input`,placeholder:`Style profile`,value:m.styleProfile,onInput:t=>I(n=>({...n,[e]:{...m,styleProfile:t.target.value}}))}):null,e===`discord`?l(`input`,{className:`tcp-input`,placeholder:`Guild ID (optional)`,value:m.guildId,onInput:t=>I(n=>({...n,[e]:{...m,guildId:t.target.value}}))}):null,e===`slack`?l(`input`,{className:`tcp-input`,placeholder:`Default channel ID`,value:m.channelId,onInput:t=>I(n=>({...n,[e]:{...m,channelId:t.target.value}}))}):null,l(`label`,{className:`inline-flex items-center gap-2 rounded-xl border border-slate-700/60 bg-slate-900/20 px-3 py-2 text-sm`,children:[l(`input`,{type:`checkbox`,checked:m.mentionOnly,onChange:t=>I(n=>({...n,[e]:{...m,mentionOnly:t.target.checked}}))}),`Mention only`]}),l(`label`,{className:`flex items-center justify-between gap-3 rounded-xl border border-slate-700/60 bg-slate-900/20 px-3 py-2 text-sm`,children:[l(`div`,{className:`flex flex-col`,children:[l(`span`,{children:`Strict KB grounding`}),l(`span`,{className:`tcp-subtle text-[11px]`,children:`Factual channel questions use selected MCP knowledge sources as the grounding path.`})]}),l(`input`,{type:`checkbox`,checked:m.strictKbGrounding,onChange:t=>I(n=>({...n,[e]:{...m,strictKbGrounding:t.target.checked}}))})]})]}),l(`div`,{className:`rounded-xl border border-slate-700/60 bg-slate-900/20 p-3`,children:[l(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-3`,children:[l(`div`,{children:[l(`div`,{className:`font-medium`,children:`Channel model override`}),l(`div`,{className:`tcp-subtle text-xs`,children:`Pick the provider and model this channel should use. Leave both blank to inherit Tandem's global default.`})]}),l(h,{tone:m.modelProviderId&&m.modelId?`ok`:`info`,children:m.modelProviderId&&m.modelId?`Custom model`:`Global default`})]}),l(k,{providerLabel:`Provider`,modelLabel:`Model`,draft:{provider:m.modelProviderId,model:m.modelId},providers:a,onChange:({provider:t,model:n})=>I(r=>({...r,[e]:{...m,modelProviderId:t,modelId:n}})),inheritLabel:`Use global default`}),l(`div`,{className:`mt-2 tcp-subtle text-xs`,children:m.modelProviderId&&m.modelId?l(`span`,{children:[`Selected model: `,l(`strong`,{children:m.modelProviderId}),` /`,` `,l(`strong`,{children:m.modelId})]}):r.provider&&r.model?l(`span`,{children:[`Inheriting Tandem default: `,l(`strong`,{children:r.provider}),` `,`/ `,l(`strong`,{children:r.model})]}):l(`span`,{children:`No global default model is configured yet.`})})]}),m.securityProfile===`public_demo`?l(`div`,{className:`tcp-subtle text-xs`,children:"Public demo mode blocks operator commands, file/workspace access, MCP access, shell access, and tool-scope widening. Memory stays confined to this channel's quarantined public namespace, and `/help` still advertises restricted capabilities for security."}):null,l(`div`,{className:`tcp-subtle text-xs`,children:[`Active sessions: `,Number(n.active_sessions||0),n.last_error?` · Last error: ${n.last_error}`:``]}),v?.hints?.length?l(`div`,{className:`rounded-xl border border-slate-700/60 bg-slate-900/20 p-3 text-xs`,children:[l(`div`,{className:`mb-1 font-medium`,children:`Verification hints`}),l(`div`,{className:`grid gap-1`,children:v.hints.map((t,n)=>l(`div`,{className:`tcp-subtle`,children:t},`${e}-hint-${n}`))})]}):null,l(`div`,{className:`flex flex-wrap gap-2`,children:[l(`button`,{className:`tcp-btn-primary`,disabled:N.isPending||!V,onClick:()=>N.mutate(e),children:[l(`i`,{"data-lucide":`save`}),`Save`]}),e===`discord`?l(`button`,{className:`tcp-btn`,disabled:ee.isPending,onClick:()=>ee.mutate(`discord`),children:[l(`i`,{"data-lucide":`shield-check`}),`Verify`]}):null,l(`button`,{className:`tcp-btn-danger`,disabled:x.isPending||!B,onClick:()=>x.mutate(e),children:[l(`i`,{"data-lucide":`trash-2`}),`Remove`]})]}),l(u.div,{layout:!0,className:`rounded-xl border border-slate-700/60 bg-slate-900/20 p-3`,children:[l(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-3`,children:[l(`div`,{children:[l(`div`,{className:`font-medium`,children:`Channel tool scope`}),l(`div`,{className:`tcp-subtle text-xs`,children:[`Built-in tools and MCP servers available to `,e,` sessions.`]}),T.enabled_tools.some(e=>e!==`tandem.workflow_planner`)?l(`div`,{className:`mt-1 text-xs text-amber-300`,children:[`Explicit built-in allowlist is active for this `,w,`.`]}):null,F?l(`div`,{className:`mt-1 text-xs text-slate-400`,children:`Public demo profile can only expose web and quarantined public-memory tools here. File, shell, MCP, and operator-facing tools stay disabled even if saved in channel preferences.`}):null]}),l(`div`,{className:`flex flex-wrap items-center gap-2`,children:[l(`button`,{className:`tcp-btn`,disabled:P.isPending,onClick:()=>P.mutate({channel:e,scopeId:b||null,payload:{reset:!0}}),children:`Reset scope`}),l(`button`,{className:`tcp-btn`,"aria-expanded":!!c[e],onClick:()=>L(t=>({...t,[e]:!t[e]})),children:[l(`span`,{children:c[e]?`Hide`:`Show`}),l(`i`,{"data-lucide":`chevron-down`,className:`h-4 w-4 transition-transform duration-200 ${c[e]?`rotate-180`:``}`})]})]})]}),l(`div`,{className:`mb-3 grid gap-3 md:grid-cols-[minmax(0,1fr)_320px] md:items-end`,children:[l(`div`,{className:`grid gap-1`,children:[l(`div`,{className:`tcp-subtle text-xs`,children:b?`Editing ${C}. Saving here stores a scope-specific override on top of the ${e} default.`:`Editing the ${e} default. Pick a conversation scope to override one specific ${e} thread, room, or chat.`}),l(`div`,{className:`tcp-subtle text-[11px]`,children:y.length?`${y.length} known scope${y.length===1?``:`s`} discovered from channel sessions.`:`No scoped conversations discovered yet.`})]}),l(`label`,{className:`grid gap-1`,children:[l(`span`,{className:`tcp-subtle text-[11px] uppercase tracking-[0.24em]`,children:`Conversation scope`}),l(`select`,{className:`tcp-input`,value:b,onChange:t=>R(n=>({...n,[e]:t.target.value})),children:[l(`option`,{value:``,children:`Channel default`}),b&&!y.some(e=>e.scope_id===b)?l(`option`,{value:b,children:C}):null,y.map(e=>l(`option`,{value:e.scope_id,children:ve(e)},e.scope_id))]})]})]}),l(`div`,{className:`tcp-subtle text-xs`,children:[T.enabled_mcp_servers.length?`${T.enabled_mcp_servers.length} MCP server${T.enabled_mcp_servers.length===1?``:`s`} enabled for this ${w}.`:F?`MCP servers stay disabled in public demo mode.`:`No MCP servers enabled for this ${w}.`,M.length?` ${M.length} exact MCP tool${M.length===1?``:`s`} also selected.`:``,` ${Se(m.securityProfile,`tandem.workflow_planner`)?Z(T,`tandem.workflow_planner`)?`Workflow drafts from chat are enabled.`:`Workflow drafts from chat are disabled.`:`Workflow drafts stay disabled in public demo mode.`}`]}),l(d,{initial:!1,children:c[e]?l(u.div,{initial:{opacity:0,height:0,y:-6},animate:{opacity:1,height:`auto`,y:0},exit:{opacity:0,height:0,y:-6},transition:{duration:.22,ease:[.22,1,.36,1]},className:`overflow-hidden`,children:l(`div`,{className:`grid gap-3 pt-3`,children:[l(`div`,{className:`grid gap-2`,children:[l(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-[0.24em]`,children:`Workflow planning`}),l(`label`,{className:`flex items-center justify-between rounded-xl border border-slate-700/60 bg-slate-950/30 px-3 py-2 text-sm`,children:[l(`div`,{className:`flex flex-col`,children:[l(`span`,{className:`font-mono text-xs`,children:`Allow workflow drafts from chat`}),l(`span`,{className:`tcp-subtle text-[11px]`,children:"Stores the `tandem.workflow_planner` pseudo-tool in this channel scope without changing the normal tool allowlist."})]}),l(`input`,{type:`checkbox`,checked:Z(T,G),disabled:P.isPending||!Se(m.securityProfile,`tandem.workflow_planner`),onChange:t=>P.mutate({channel:e,scopeId:b||null,payload:ye(T,G,t.currentTarget.checked)})})]})]}),W.map(t=>l(`div`,{className:`grid gap-2`,children:[l(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-[0.24em]`,children:t.label}),l(`div`,{className:`grid gap-2 md:grid-cols-2`,children:t.tools.map(t=>{let n=Se(m.securityProfile,t),r=Ce(T,t,m.securityProfile);return l(`label`,{className:`flex items-center justify-between rounded-xl border border-slate-700/60 bg-slate-950/30 px-3 py-2 text-sm`,children:[l(`div`,{className:`flex flex-col`,children:[l(`span`,{className:`font-mono text-xs`,children:t}),n?null:l(`span`,{className:`tcp-subtle text-[11px]`,children:`Disabled by security profile`})]}),l(`input`,{type:`checkbox`,checked:r,disabled:P.isPending||!n,onChange:n=>P.mutate({channel:e,scopeId:b||null,payload:ye(T,t,n.currentTarget.checked)})})]},`${e}-tool-${t}`)})})]},`${e}-${t.label}`)),l(`div`,{className:`grid gap-2`,children:[l(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-[0.24em]`,children:`MCP servers`}),z.length?l(`div`,{className:`grid gap-2 md:grid-cols-2`,children:z.map(t=>{let n=!F&&T.enabled_mcp_servers.includes(t.name);return l(`label`,{className:`flex items-center justify-between rounded-xl border border-slate-700/60 bg-slate-950/30 px-3 py-2 text-sm`,children:[l(`div`,{className:`flex flex-col`,children:[l(`span`,{className:`font-mono text-xs`,children:t.name}),F?l(`span`,{className:`tcp-subtle text-[11px]`,children:`Disabled by security profile`}):null]}),l(`input`,{type:`checkbox`,checked:n,disabled:P.isPending||F,onChange:n=>P.mutate({channel:e,scopeId:b||null,payload:Q(T,t.name,n.currentTarget.checked)})})]},`${e}-mcp-${t.name}`)})}):l(`div`,{className:`tcp-subtle text-xs`,children:F?`MCP servers stay disabled in public demo mode.`:`No MCP servers configured yet.`})]}),l(`div`,{className:`grid gap-2`,children:[l(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-[0.24em]`,children:`Exact MCP tools`}),l(`div`,{className:`tcp-subtle text-xs`,children:[`Choose exact tool names for this `,w,`. Exact tools only apply when their MCP server is enabled above.`]}),z.length?l(`div`,{className:`grid gap-3`,children:[z.map(t=>{let n=fe(Array.isArray(t.toolCache)?t.toolCache:[]),r=!F&&T.enabled_mcp_servers.includes(t.name),i=be(T,t.name,n);return l(O,{title:t.name,subtitle:r?t.connected?t.enabled?`Connected and enabled globally. Pick the exact tools this scope can use.`:`Connected, but disabled globally. Exact selections are saved here and will apply if the server is enabled.`:`This server is disconnected. Exact selections are saved here and will apply when it reconnects.`:`Server is disabled for this scope. Exact tool selections are inactive until you enable the server above.`,discoveredTools:n,value:r?i:[],disabled:P.isPending||F||!r,collapsible:!0,defaultCollapsed:!0,emptyText:`No MCP tools have been discovered for this server yet.`,onChange:r=>P.mutate({channel:e,scopeId:b||null,payload:xe(T,t.name,n,r)})},`${e}-exact-mcp-${t.name}`)}),T.enabled_mcp_tools.filter(e=>!A.has(e)).length?l(O,{title:`Saved exact tools not currently matched`,subtitle:`These exact MCP tools are still stored for this scope, but no discovered server is currently exposing them.`,discoveredTools:[],value:T.enabled_mcp_tools.filter(e=>!A.has(e)),disabled:P.isPending||F,emptyText:`All saved exact MCP tools currently match a discovered server.`,onChange:t=>P.mutate({channel:e,scopeId:b||null,payload:{...T,enabled_mcp_tools:X([...T.enabled_mcp_tools.filter(e=>A.has(e)),...t===null?[]:t])}})}):null]}):l(`div`,{className:`tcp-subtle text-xs`,children:F?`Exact MCP tools stay disabled in public demo mode.`:`No MCP servers configured yet.`})]})]})},`${e}-tool-scope-body`):null})]})]},e)})})}):null,n===`mcp`?l(v,{title:`MCP connections`,subtitle:`Configured MCP servers, connection state, and discovered tool coverage. Per-channel exact tool scopes live under Channels.`,actions:l(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[l(h,{tone:b?`ok`:`warn`,children:[b,`/`,z.length,` connected`]}),l(h,{tone:`info`,children:[E.length,` tools`]}),l(`button`,{className:`tcp-btn`,onClick:()=>F(`channels`),children:`Channel scopes`}),l(`button`,{className:`tcp-btn-primary`,onClick:()=>j(),children:[l(`i`,{"data-lucide":`plus`}),`Add MCP server`]}),l(`button`,{className:`tcp-btn`,onClick:()=>void C(),children:[l(`i`,{"data-lucide":`refresh-cw`}),`Reload`]})]}),children:l(`div`,{className:`grid gap-3`,children:[z.length?z.map(e=>{let t=Object.keys(e.headers||{}).filter(Boolean),n=Array.isArray(e.toolCache)?e.toolCache.length:0;return l(`div`,{className:`tcp-list-item grid gap-2`,children:[l(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[l(`div`,{children:[l(`div`,{className:`font-semibold`,children:e.name}),l(`div`,{className:`tcp-subtle text-sm`,children:e.transport||`No transport set`})]}),l(`div`,{className:`flex flex-wrap gap-2`,children:[l(h,{tone:e.connected?`ok`:`warn`,children:e.connected?`Connected`:`Disconnected`}),l(h,{tone:e.enabled?`info`:`warn`,children:e.enabled?`Enabled`:`Disabled`}),String(e.authKind||``).trim().toLowerCase()===`oauth`?l(h,{tone:`info`,children:`OAuth`}):null,l(h,{tone:`info`,children:[n,` tools`]})]})]}),e.lastError?l(`div`,{className:`rounded-xl border border-rose-700/60 bg-rose-950/20 px-2 py-1 text-xs text-rose-300`,children:e.lastError}):null,e.lastAuthChallenge?l(`div`,{className:`rounded-xl border border-amber-700/60 bg-amber-950/20 px-3 py-2 text-xs text-amber-100`,children:[l(`div`,{className:`font-medium`,children:`OAuth authorization pending`}),l(`div`,{className:`tcp-subtle mt-1`,children:String(e.lastAuthChallenge.message||``).trim()||`Open the authorization URL to finish connecting this MCP server.`}),l(`div`,{className:`tcp-subtle mt-1`,children:`Tandem will keep checking for completion automatically while this page is open.`}),String(e.lastAuthChallenge.authorization_url||e.lastAuthChallenge.authorizationUrl||e.authorizationUrl||``).trim()?l(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[l(`a`,{className:`tcp-btn inline-flex h-8 px-3 text-xs`,href:String(e.lastAuthChallenge.authorization_url||e.lastAuthChallenge.authorizationUrl||e.authorizationUrl||``).trim(),target:`_blank`,rel:`noreferrer`,children:`Open auth URL`}),l(`button`,{type:`button`,className:`tcp-btn inline-flex h-8 px-3 text-xs`,disabled:w.isPending,onClick:()=>w.mutate({action:`authenticate`,server:e}),children:`Mark sign-in complete`})]}):null]}):null,l(`div`,{className:`tcp-subtle text-xs`,children:t.length?`Auth headers: ${t.join(`, `)}`:`No stored auth headers.`}),l(O,{title:`Tool access`,subtitle:`Leave all discovered tools selected to expose the full MCP server, or uncheck tools to hide them from agents and workflows.`,discoveredTools:Array.isArray(e.toolCache)?e.toolCache:[],value:e.allowedTools,disabled:A.isPending,onChange:t=>A.mutate({serverName:e.name,allowedTools:t})}),l(`div`,{className:`flex flex-wrap gap-2`,children:[l(`button`,{className:`tcp-btn`,onClick:()=>j(e),children:`Edit`}),l(`button`,{className:`tcp-btn`,disabled:w.isPending,onClick:()=>w.mutate({action:e.connected?`disconnect`:`connect`,server:e}),children:e.connected?`Disconnect`:`Connect`}),l(`button`,{className:`tcp-btn`,disabled:w.isPending,onClick:()=>w.mutate({action:`refresh`,server:e}),children:`Refresh`}),l(`button`,{className:`tcp-btn`,disabled:w.isPending,onClick:()=>w.mutate({action:`toggle-enabled`,server:e}),children:e.enabled?`Disable`:`Enable`}),l(`button`,{className:`tcp-btn-danger`,disabled:w.isPending,onClick:()=>w.mutate({action:`delete`,server:e}),children:`Delete`})]})]},e.name)}):l(`div`,{className:`grid gap-3`,children:[l(EmptyState,{text:`No MCP servers configured.`}),l(`div`,{className:`flex justify-start`,children:l(`button`,{className:`tcp-btn-primary`,onClick:()=>j(),children:[l(`i`,{"data-lucide":`plus`}),`Add MCP server`]})})]}),l(`div`,{className:`rounded-xl border border-slate-700/60 bg-slate-900/20 p-3`,children:[l(`div`,{className:`mb-2 font-medium`,children:`Discovered tools`}),l(`pre`,{className:`tcp-code max-h-56 overflow-auto whitespace-pre-wrap break-words`,children:E.length?E.slice(0,250).join(`
4
+ `):`No MCP tools discovered yet. Connect a server first.`})]})]})}):null]})}function Re(e){let t=Number(e||0);return!Number.isFinite(t)||t<=0?`never`:new Date(t).toLocaleString()}function ze(e){let t=Number(e||0);return!Number.isFinite(t)||t<=0?`0 B`:t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Be(e,t){return`${e||`project`}::${t||`source`}`}function Ve({projects:e,watcher:t,projectsJson:r,projectsJsonError:a,intakeKeys:o,createdRawKey:s,isCreatingKey:c,disablingKeyId:u,resettingSourceKey:d,replayingSourceKey:f,actionResult:p,onProjectsJsonChange:m,onCreateKey:g,onDisableKey:_,onClearCreatedRawKey:v,onResetSourceOffset:y,onReplayLatestSourceCandidate:b}){let[x,S]=i(``),[C,w]=i(`external reporter`),[E,D]=i(`external-demo`),[O,k]=i(`owner/repo`),[A,j]=i(`/path/to/repo`),[M,N]=i(`app-log`),[P,F]=i(`logs/app.log`),[I,L]=i(`all`),R=Array.isArray(t.sources)?t.sources:[],ee=n(()=>new Map(R.map(e=>[Be(String(e.project_id||``),String(e.source_id||``)),e])),[R]),z=Number(t.enabled_projects||0),B=Number(t.enabled_sources||0),V=n(()=>e.map((e,t)=>({id:String(e.project_id||`project-${t+1}`).trim(),label:String(e.name||e.project_id||`project-${t+1}`).trim()})).filter(e=>e.id),[e]),H=x||V[0]?.id||``,U=n(()=>e.map((e,t)=>{let n=String(e.project_id||`project-${t+1}`),r=Array.isArray(e.log_sources)?e.log_sources:[],i=r.map((e,t)=>{let r=String(e.source_id||`source-${t+1}`);return ee.get(Be(n,r))}).filter(Boolean),a=i.filter(e=>e.healthy===!1).length,o=i.reduce((e,t)=>e+Number(t.total_candidates||0),0),s=i.reduce((e,t)=>e+Number(t.total_submitted||0),0);return{project:e,projectId:n,logSourceCount:r.length,observedSourceCount:i.length,unhealthyCount:a,candidateCount:o,submittedCount:s,lastPollAtMs:Math.max(...i.map(e=>Number(e.last_poll_at_ms||0)),0)}}),[e,ee]),W=n(()=>I===`all`?U:U.filter(e=>e.projectId===I),[I,U]);return l(`div`,{className:`grid gap-3 rounded-xl border border-slate-700/60 bg-slate-900/20 p-3`,children:[l(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[l(`div`,{children:[l(`div`,{className:`font-medium`,children:`External project log intake`}),l(`div`,{className:`tcp-subtle text-xs`,children:`Configure monitored projects as JSON, then watch source health here after saving.`})]}),l(`div`,{className:`flex flex-wrap gap-2`,children:[l(h,{tone:t.running?`ok`:B?`warn`:`info`,children:t.running?`Watcher running`:`Watcher idle`}),l(h,{tone:z?`info`:`warn`,children:[z,` projects`]}),l(h,{tone:B?`info`:`warn`,children:[B,` sources`]})]})]}),U.length?l(`div`,{className:`grid gap-2 md:grid-cols-[minmax(0,1fr)_auto]`,children:[l(`div`,{className:`grid gap-2 md:grid-cols-3`,children:U.slice(0,6).map(e=>l(`button`,{type:`button`,className:`tcp-list-item text-left ${I===e.projectId?`ring-1 ring-sky-400/50`:``}`,onClick:()=>{L(t=>t===e.projectId?`all`:e.projectId)},children:[l(`div`,{className:`flex items-center justify-between gap-2`,children:[l(`div`,{className:`truncate font-medium`,children:e.project.name||e.projectId}),l(h,{tone:e.unhealthyCount?`warn`:e.observedSourceCount?`ok`:`info`,children:e.unhealthyCount?`${e.unhealthyCount} unhealthy`:`ok`})]}),l(`div`,{className:`tcp-subtle mt-1 text-xs`,children:[e.observedSourceCount,`/`,e.logSourceCount,` observed · `,e.candidateCount,` `,`candidates · `,e.submittedCount,` submitted`]}),l(`div`,{className:`tcp-subtle mt-1 text-xs`,children:[`Last poll: `,Re(e.lastPollAtMs)]})]},e.projectId))}),l(`label`,{className:`grid min-w-48 gap-1`,children:[l(`span`,{className:`text-xs uppercase tracking-[0.24em] tcp-subtle`,children:`Project filter`}),l(`select`,{className:`tcp-input`,value:I,onChange:e=>L(e.currentTarget.value),children:[l(`option`,{value:`all`,children:`All projects`}),U.map(e=>l(`option`,{value:e.projectId,children:e.project.name||e.projectId},e.projectId))]})]})]}):null,t.last_error?l(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 p-3 text-xs text-amber-100`,children:t.last_error}):null,p?l(`div`,{className:`rounded-lg border border-sky-500/30 bg-sky-500/10 p-3`,children:[l(`div`,{className:`text-sm font-medium text-sky-100`,children:[String(p.action||`Log source action`),` completed`]}),l(`div`,{className:`tcp-subtle mt-1 text-xs`,children:[String(p.project_id||`unknown project`),` /`,` `,String(p.source_id||`unknown source`)]}),l(`pre`,{className:`tcp-code mt-2 max-h-40 overflow-auto whitespace-pre-wrap break-words text-xs`,children:JSON.stringify(p,null,2)})]}):null,l(`label`,{className:`grid gap-2`,children:[l(`span`,{className:`text-xs uppercase tracking-[0.24em] tcp-subtle`,children:`Monitored projects`}),l(`div`,{className:`grid gap-2 rounded-lg border border-slate-700/60 bg-slate-950/30 p-3 md:grid-cols-5`,children:[l(`input`,{className:`tcp-input text-xs`,value:E,onChange:e=>D(e.currentTarget.value),placeholder:`project_id`}),l(`input`,{className:`tcp-input text-xs`,value:O,onChange:e=>k(e.currentTarget.value),placeholder:`owner/repo`}),l(`input`,{className:`tcp-input text-xs`,value:A,onChange:e=>j(e.currentTarget.value),placeholder:`/path/to/repo`}),l(`input`,{className:`tcp-input text-xs`,value:P,onChange:e=>F(e.currentTarget.value),placeholder:`logs/app.log`}),l(`button`,{type:`button`,className:`tcp-btn`,onClick:()=>{let e=E.trim()||`external-demo`,t=M.trim()||`app-log`;m(JSON.stringify([{project_id:e,name:e,enabled:!0,repo:O.trim()||`owner/repo`,workspace_root:A.trim()||`/path/to/repo`,log_sources:[{source_id:t,path:P.trim()||`logs/app.log`,format:`auto`,minimum_level:`error`,start_position:`end`,watch_interval_seconds:5}]}],null,2))},children:`Generate starter`})]}),l(`div`,{className:`tcp-subtle text-xs`,children:[`Starter source id:`,` `,l(`input`,{className:`tcp-input ml-2 inline-block h-7 w-40 text-xs`,value:M,onChange:e=>N(e.currentTarget.value),placeholder:`source_id`})]}),l(`textarea`,{className:`tcp-input min-h-48 font-mono text-xs`,value:r,onChange:e=>m(e.currentTarget.value),spellCheck:!1,placeholder:`[{"project_id":"aca","repo":"owner/repo","workspace_root":"/path/to/repo","log_sources":[{"source_id":"ci","path":"logs/ci.jsonl"}]}]`}),l(`div`,{className:a?`text-xs text-amber-200`:`tcp-subtle text-xs`,children:a||`This PATCH payload is validated by the engine. Paths must stay under each workspace root.`})]}),W.length?l(`div`,{className:`grid gap-2`,children:W.map(({project:e,projectId:t})=>{let n=Array.isArray(e.log_sources)?e.log_sources:[];return l(`div`,{className:`tcp-list-item`,children:[l(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[l(`div`,{children:[l(`div`,{className:`font-medium`,children:e.name||t}),l(`div`,{className:`tcp-subtle text-xs`,children:[e.repo||`repo not set`,` ·`,` `,e.workspace_root||`workspace not set`]})]}),l(`div`,{className:`flex flex-wrap gap-2`,children:[l(h,{tone:e.enabled===!1||e.paused?`warn`:`ok`,children:e.enabled===!1?`Disabled`:e.paused?`Paused`:`Enabled`}),l(h,{tone:`info`,children:[n.length,` log sources`]})]})]}),l(`div`,{className:`tcp-subtle mt-2 text-xs`,children:[`MCP: `,e.mcp_server||`global default`,` · Posting:`,` `,e.require_approval_for_new_issues?`manual approval`:e.auto_create_new_issues===!1?`draft only`:`auto-create enabled`]}),n.length?l(`div`,{className:`mt-3 grid gap-2`,children:n.map((e,n)=>{let r=String(e.source_id||`source-${n+1}`),i=Be(t,r),a=ee.get(Be(t,r));return l(`div`,{className:`rounded-lg border border-slate-700/60 bg-slate-950/30 p-3`,children:[l(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[l(`div`,{children:[l(`div`,{className:`text-sm font-medium`,children:r}),l(`div`,{className:`tcp-subtle text-xs`,children:e.path||`path not set`})]}),l(`div`,{className:`flex flex-wrap gap-2`,children:[l(h,{tone:e.enabled===!1||e.paused||a?.healthy===!1?`warn`:a?`ok`:`info`,children:e.enabled===!1?`Disabled`:e.paused?`Paused`:a?.healthy===!1?`Unhealthy`:a?`Healthy`:`Waiting`}),l(h,{tone:`info`,children:e.format||`auto`}),l(h,{tone:`info`,children:[e.minimum_level||`error`,`+`]})]})]}),l(`div`,{className:`tcp-subtle mt-2 grid gap-1 text-xs md:grid-cols-2`,children:[l(`div`,{children:[`Offset: `,Number(a?.offset||0).toLocaleString(),` bytes`]}),l(`div`,{children:[`File size: `,ze(a?.file_size)]}),l(`div`,{children:[`Last poll: `,Re(a?.last_poll_at_ms)]}),l(`div`,{children:[`Last candidate: `,Re(a?.last_candidate_at_ms)]}),l(`div`,{children:[`Total candidates: `,Number(a?.total_candidates||0)]}),l(`div`,{children:[`Total submitted: `,Number(a?.total_submitted||0)]})]}),a?.last_error?l(`div`,{className:`mt-2 rounded border border-amber-500/30 bg-amber-500/10 p-2 text-xs text-amber-100`,children:a.last_error}):null,l(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[l(`button`,{type:`button`,className:`tcp-btn`,disabled:d===i,onClick:()=>y({project_id:t,source_id:r}),children:`Reset offset`}),l(`button`,{type:`button`,className:`tcp-btn`,disabled:f===i,onClick:()=>b({project_id:t,source_id:r}),children:`Replay latest`})]})]},`${t}-${r}`)})}):l(`div`,{className:`tcp-subtle mt-3 text-xs`,children:`No log sources configured.`})]},t)})}):e.length?l(T,{text:`No projects match the current filter.`}):l(T,{text:`No external projects configured yet. Paste a monitored_projects JSON array above and save.`}),l(`div`,{className:`grid gap-3 rounded-xl border border-slate-700/60 bg-slate-950/30 p-3`,children:[l(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[l(`div`,{children:[l(`div`,{className:`font-medium`,children:`Scoped intake keys`}),l(`div`,{className:`tcp-subtle text-xs`,children:`Create project-limited keys for CI or external reporters. Raw keys are shown once.`})]}),l(h,{tone:o.length?`info`:`warn`,children:[o.length,` keys`]})]}),s?l(`div`,{className:`rounded-lg border border-emerald-500/30 bg-emerald-500/10 p-3`,children:[l(`div`,{className:`text-sm font-medium text-emerald-100`,children:`New raw key`}),l(`div`,{className:`tcp-subtle mt-1 text-xs`,children:`Store this now. Tandem only keeps the hash after creation.`}),l(`pre`,{className:`tcp-code mt-2 overflow-auto whitespace-pre-wrap break-all text-xs`,children:s}),l(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[l(`button`,{type:`button`,className:`tcp-btn`,onClick:()=>navigator.clipboard?.writeText(s),children:`Copy`}),l(`button`,{type:`button`,className:`tcp-btn`,onClick:v,children:`Hide`})]})]}):null,l(`div`,{className:`grid gap-2 md:grid-cols-[1fr_1fr_auto]`,children:[l(`label`,{className:`grid gap-1`,children:[l(`span`,{className:`text-xs uppercase tracking-[0.24em] tcp-subtle`,children:`Project`}),l(`select`,{className:`tcp-input`,value:H,onChange:e=>S(e.currentTarget.value),disabled:!V.length,children:V.length?V.map(e=>l(`option`,{value:e.id,children:e.label},e.id)):l(`option`,{value:``,children:`Configure a project first`})})]}),l(`label`,{className:`grid gap-1`,children:[l(`span`,{className:`text-xs uppercase tracking-[0.24em] tcp-subtle`,children:`Key name`}),l(`input`,{className:`tcp-input`,value:C,onChange:e=>w(e.currentTarget.value),placeholder:`ci reporter`})]}),l(`div`,{className:`flex items-end`,children:l(`button`,{type:`button`,className:`tcp-btn-primary w-full`,disabled:!H||!C.trim()||c,onClick:()=>g({project_id:H,name:C.trim()}),children:`Create key`})})]}),o.length?l(`div`,{className:`grid gap-2`,children:o.map(e=>{let t=String(e.key_id||``);return l(`div`,{className:`tcp-list-item`,children:[l(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[l(`div`,{children:[l(`div`,{className:`font-medium`,children:e.name||t||`intake key`}),l(`div`,{className:`tcp-subtle text-xs`,children:[e.project_id||`unknown project`,` ·`,` `,(e.scopes||[`bug_monitor:report`]).join(`, `)]})]}),l(`div`,{className:`flex flex-wrap items-center gap-2`,children:[l(h,{tone:e.enabled===!1?`warn`:`ok`,children:e.enabled===!1?`Disabled`:`Enabled`}),e.enabled!==!1&&t?l(`button`,{type:`button`,className:`tcp-btn-danger`,disabled:u===t,onClick:()=>_(t),children:`Disable`}):null]})]}),l(`div`,{className:`tcp-subtle mt-2 grid gap-1 text-xs md:grid-cols-2`,children:[l(`div`,{children:[`Created: `,Re(e.created_at_ms)]}),l(`div`,{children:[`Last used: `,Re(e.last_used_at_ms)]}),l(`div`,{className:`md:col-span-2`,children:[`Hash: `,e.key_hash||`[redacted]`]})]})]},t||`${e.project_id}-${e.name}`)})}):l(T,{text:`No scoped intake keys yet.`})]})]})}function He({controller:e}){let{activeSection:n,bugMonitorAutoComment:r,bugMonitorAutoCreateIssues:i,bugMonitorCreatedIntakeKey:a,bugMonitorDisablingIntakeKeyId:o,bugMonitorDraftDecisionMutation:s,bugMonitorDrafts:c,bugMonitorDraftsQuery:u,bugMonitorEnabled:d,bugMonitorIncidents:f,bugMonitorIncidentsQuery:p,bugMonitorIntakeKeys:m,bugMonitorLogSourceActionResult:g,bugMonitorLogWatcher:_,bugMonitorMcpServer:y,bugMonitorModelId:b,bugMonitorMonitoredProjects:x,bugMonitorMonitoredProjectsError:S,bugMonitorMonitoredProjectsJson:C,bugMonitorPauseResumeMutation:w,bugMonitorPaused:E,bugMonitorPosts:D,bugMonitorPostsQuery:O,bugMonitorProviderId:k,bugMonitorProviderModels:A,bugMonitorProviderPreference:M,bugMonitorPublishDraftMutation:N,bugMonitorRecheckMatchMutation:P,bugMonitorReplayIncidentMutation:F,bugMonitorReplayingSourceKey:I,bugMonitorRepo:L,bugMonitorRequireApproval:R,bugMonitorResettingSourceKey:ee,bugMonitorStatus:z,bugMonitorStatusQuery:B,bugMonitorSuggestedWorkspaceRoot:V,bugMonitorTriageRunMutation:H,bugMonitorWorkspaceRoot:U,bugMonitorWorkspaceRootHint:W,bugMonitorWorkspaceSetupWarningText:G,copyBugMonitorDebugPayload:te,createBugMonitorIntakeKeyMutation:K,disableBugMonitorIntakeKeyMutation:ne,mcpActionMutation:re,mcpServers:q,openMcpModal:ie,providers:ae,refreshBugMonitorBindingsMutation:J,replayBugMonitorLogSourceMutation:oe,resetBugMonitorLogSourceMutation:se,saveBugMonitorMutation:ce,selectedBugMonitorServer:Y,setBugMonitorAutoComment:le,setBugMonitorAutoCreateIssues:ue,setBugMonitorCreatedIntakeKey:de,setBugMonitorEnabled:fe,setBugMonitorMcpServer:pe,setBugMonitorModelId:me,setBugMonitorMonitoredProjectsError:he,setBugMonitorMonitoredProjectsJson:X,setBugMonitorProviderId:ge,setBugMonitorProviderPreference:_e,setBugMonitorRepo:ve,setBugMonitorRequireApproval:Z,setBugMonitorWorkspaceBrowserDir:ye,setBugMonitorWorkspaceBrowserOpen:Q,setBugMonitorWorkspaceBrowserSearch:be,setBugMonitorWorkspaceRoot:xe,setGithubMcpGuideOpen:Se,toast:Ce}=e,we=Array.isArray(q)?q:[],Te=Array.isArray(ae)?ae:[],Ee=Array.isArray(A)?A:[],De=Array.isArray(f)?f:[],Oe=Array.isArray(c)?c:[],ke=Array.isArray(D)?D:[];return l(t,{children:n===`bug_monitor`?l(v,{title:`Bug monitor`,actions:l(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[l(h,{tone:z.runtime?.monitoring_active?z.readiness?.publish_ready?`ok`:`info`:z.readiness?.ingest_ready?`info`:`warn`,children:z.runtime?.monitoring_active?z.readiness?.publish_ready?`Monitoring`:`Watching locally`:z.readiness?.ingest_ready?`Ready`:`Not ready`}),E||z.runtime?.paused?l(h,{tone:`warn`,children:`Paused`}):null,l(h,{tone:`info`,children:[Number(z.runtime?.pending_incidents||0),` incidents`]}),l(h,{tone:`info`,children:[Number(z.pending_drafts||0),` pending drafts`]}),l(h,{tone:`info`,children:[Number(z.pending_posts||0),` post attempts`]}),l(`button`,{className:`tcp-icon-btn`,title:`Reload status`,"aria-label":`Reload status`,onClick:()=>Promise.all([B.refetch(),u.refetch(),p.refetch(),O.refetch()]).then(()=>Ce(`ok`,`Bug Monitor status refreshed.`)),children:l(`i`,{"data-lucide":`refresh-cw`})}),l(`button`,{className:`tcp-icon-btn`,title:E||z.runtime?.paused?`Resume monitoring`:`Pause monitoring`,"aria-label":E||z.runtime?.paused?`Resume monitoring`:`Pause monitoring`,disabled:w.isPending,onClick:()=>w.mutate({action:E||z.runtime?.paused?`resume`:`pause`}),children:l(`i`,{"data-lucide":E||z.runtime?.paused?`play`:`pause`})}),l(`button`,{className:`tcp-icon-btn`,title:`Refresh capability bindings`,"aria-label":`Refresh capability bindings`,disabled:J.isPending,onClick:()=>J.mutate(),children:l(`i`,{"data-lucide":`rotate-cw`})}),l(`button`,{className:`tcp-icon-btn`,title:`Copy debug payload`,"aria-label":`Copy debug payload`,onClick:()=>void te(),children:l(`i`,{"data-lucide":`copy`})}),l(`button`,{className:`tcp-icon-btn`,title:`Open GitHub MCP guide`,"aria-label":`Open GitHub MCP guide`,onClick:()=>Se(!0),children:l(`i`,{"data-lucide":`book-open`})})]}),children:l(`div`,{className:`grid gap-4`,children:[l(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[l(`label`,{className:`grid gap-2`,children:[l(`span`,{className:`text-xs uppercase tracking-[0.24em] tcp-subtle`,children:`Reporter state`}),l(`button`,{type:`button`,className:`tcp-list-item text-left ${d?`ring-1 ring-emerald-400/40`:``}`,onClick:()=>fe(e=>!e),children:[l(`div`,{className:`font-medium`,children:d?E?`Paused`:`Enabled`:`Disabled`}),l(`div`,{className:`tcp-subtle text-xs`,children:d?E?`Monitoring is paused. Resume to process new failures.`:`Failure events can be analyzed once readiness is green.`:`No reporter work will execute.`})]})]}),l(`label`,{className:`grid gap-2`,children:[l(`span`,{className:`text-xs uppercase tracking-[0.24em] tcp-subtle`,children:`Local directory`}),l(`div`,{className:`rounded-xl border border-sky-500/20 bg-sky-500/10 p-3 text-xs text-sky-100`,children:[l(`div`,{className:`font-semibold`,children:`Hosted path map`}),l(`div`,{className:`mt-1 tcp-subtle`,children:[`Coder syncs source checkouts into `,l(`code`,{children:j}),`. For Bug Monitor analysis, select the repo folder itself, usually`,` `,l(`code`,{children:V}),`.`]}),l(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[l(`button`,{className:`tcp-btn h-8 px-3 text-xs`,type:`button`,onClick:()=>xe(V),children:[l(`i`,{"data-lucide":`badge-check`}),`Use recommended path`]}),l(`button`,{className:`tcp-btn h-8 px-3 text-xs`,type:`button`,onClick:()=>{ye(j),be(``),Q(!0)},children:[l(`i`,{"data-lucide":`folder-open`}),`Browse synced repos`]})]})]}),l(`div`,{className:`grid gap-2 md:grid-cols-[auto_1fr_auto]`,children:[l(`button`,{className:`tcp-btn`,type:`button`,onClick:()=>{ye(String(U||`/`).trim()||`/`),be(``),Q(!0)},children:[l(`i`,{"data-lucide":`folder-open`}),`Browse`]}),l(`input`,{className:`tcp-input`,readOnly:!0,value:U,placeholder:`No local directory selected. Use Browse.`}),l(`button`,{className:`tcp-btn`,type:`button`,onClick:()=>xe(``),disabled:!U,children:[l(`i`,{"data-lucide":`x`}),`Clear`]})]}),l(`div`,{className:`tcp-subtle text-xs`,children:U?`Reporter analysis root: ${U}${W?` (${W})`:``}`:`Defaults to the engine workspace root if not set.`}),G?l(`div`,{className:`rounded-xl border border-amber-500/25 bg-amber-500/10 p-3 text-xs text-amber-100`,children:[l(`div`,{className:`font-semibold`,children:`Setup check`}),l(`div`,{className:`mt-1`,children:G})]}):l(`div`,{className:`rounded-xl border border-emerald-500/20 bg-emerald-500/10 p-3 text-xs text-emerald-100`,children:[l(`div`,{className:`font-semibold`,children:`Source checkout ready`}),l(`div`,{className:`mt-1`,children:`Bug Monitor triage will inspect this repo path and require concrete source-file reads before it marks research complete.`})]})]}),l(`label`,{className:`grid gap-2`,children:[l(`span`,{className:`text-xs uppercase tracking-[0.24em] tcp-subtle`,children:`Target repo`}),l(`input`,{className:`tcp-input`,value:L,onChange:e=>ve(e.target.value),placeholder:`owner/repo`})]}),l(`label`,{className:`grid gap-2`,children:[l(`span`,{className:`text-xs uppercase tracking-[0.24em] tcp-subtle`,children:`MCP server`}),l(`select`,{className:`tcp-input`,value:y,onChange:e=>pe(e.target.value),children:[l(`option`,{value:``,children:`Select an MCP server`}),we.map(e=>l(`option`,{value:e.name,children:e.name},e.name))]})]}),l(`label`,{className:`grid gap-2`,children:[l(`span`,{className:`text-xs uppercase tracking-[0.24em] tcp-subtle`,children:`Provider preference`}),l(`select`,{className:`tcp-input`,value:M,onChange:e=>_e(e.target.value),children:[l(`option`,{value:`auto`,children:`Auto`}),l(`option`,{value:`official_github`,children:`Official GitHub`}),l(`option`,{value:`composio`,children:`Composio`}),l(`option`,{value:`arcade`,children:`Arcade`})]})]}),l(`label`,{className:`grid gap-2`,children:[l(`span`,{className:`text-xs uppercase tracking-[0.24em] tcp-subtle`,children:`Provider`}),l(`select`,{className:`tcp-input`,value:k,onChange:e=>{let t=e.target.value;ge(t),me(``)},children:[l(`option`,{value:``,children:`Select a provider`}),Te.map(e=>l(`option`,{value:String(e?.id||``),children:String(e?.id||``)},String(e?.id||``)))]})]}),l(`label`,{className:`grid gap-2`,children:[l(`span`,{className:`text-xs uppercase tracking-[0.24em] tcp-subtle`,children:`Model`}),l(`input`,{className:`tcp-input`,value:b,onChange:e=>me(e.target.value),list:`bug-monitor-models`,disabled:!k,placeholder:k?`Type or paste a model id`:`Choose a provider first`,spellCheck:!1}),l(`datalist`,{id:`bug-monitor-models`,children:Ee.map(e=>l(`option`,{value:e},e))}),l(`div`,{className:`tcp-subtle text-xs`,children:k?Ee.length?`${Ee.length} suggested models from provider catalog`:`No provider catalog models available. Manual model ids are allowed.`:`Select a provider to load model suggestions.`})]}),l(`div`,{className:`grid gap-2 md:col-span-2`,children:[l(`span`,{className:`text-xs uppercase tracking-[0.24em] tcp-subtle`,children:`GitHub posting`}),l(`div`,{className:`grid gap-2 md:grid-cols-3`,children:[l(`button`,{type:`button`,className:`tcp-list-item text-left ${i&&!R?`ring-1 ring-emerald-400/40`:``}`,onClick:()=>{ue(e=>!e),R&&i&&Z(!1)},children:[l(`div`,{className:`font-medium`,children:`Auto-create new issues`}),l(`div`,{className:`tcp-subtle text-xs`,children:i?`New drafts post to GitHub automatically.`:`New drafts stay internal until published manually.`})]}),l(`button`,{type:`button`,className:`tcp-list-item text-left ${R?`ring-1 ring-amber-400/40`:``}`,onClick:()=>{Z(e=>{let t=!e;return t&&ue(!1),t})},children:[l(`div`,{className:`font-medium`,children:`Require approval`}),l(`div`,{className:`tcp-subtle text-xs`,children:R?`New drafts wait for a manual publish click.`:`Approval gate disabled.`})]}),l(`button`,{type:`button`,className:`tcp-list-item text-left ${r?`ring-1 ring-sky-400/40`:``}`,onClick:()=>le(e=>!e),children:[l(`div`,{className:`font-medium`,children:`Auto-comment matches`}),l(`div`,{className:`tcp-subtle text-xs`,children:r?`Open matching GitHub issues receive new evidence comments.`:`Matching issues are detected but not updated automatically.`})]})]})]})]}),l(`div`,{className:`flex flex-wrap gap-2`,children:[l(`button`,{className:`tcp-btn-primary`,disabled:ce.isPending,title:`Save Bug Monitor settings`,"aria-label":`Save Bug Monitor settings`,onClick:()=>ce.mutate(),children:[l(`i`,{"data-lucide":`save`}),ce.isPending?`Saving...`:null]}),l(`button`,{className:`tcp-icon-btn`,title:`Add MCP server`,"aria-label":`Add MCP server`,onClick:()=>ie(),children:l(`i`,{"data-lucide":`plus`})}),l(`button`,{className:`tcp-icon-btn`,title:`Open setup guide`,"aria-label":`Open setup guide`,onClick:()=>Se(!0),children:l(`i`,{"data-lucide":`external-link`})}),l(`button`,{className:`tcp-icon-btn`,title:`Refresh capability bindings`,"aria-label":`Refresh capability bindings`,disabled:J.isPending,onClick:()=>J.mutate(),children:l(`i`,{"data-lucide":`rotate-cw`})}),l(`button`,{className:`tcp-icon-btn`,title:`Copy debug payload`,"aria-label":`Copy debug payload`,onClick:()=>void te(),children:l(`i`,{"data-lucide":`copy`})}),Y?l(`button`,{className:`tcp-icon-btn`,title:Y.connected?`Refresh selected MCP`:`Connect selected MCP`,"aria-label":Y.connected?`Refresh selected MCP`:`Connect selected MCP`,disabled:re.isPending,onClick:()=>re.mutate({action:Y.connected?`refresh`:`connect`,server:Y}),children:l(`i`,{"data-lucide":Y.connected?`refresh-cw`:`plug-zap`})}):null]}),l(`div`,{className:`grid gap-3 md:grid-cols-3`,children:[l(`div`,{className:`tcp-list-item`,children:[l(`div`,{className:`text-sm font-medium`,children:`Readiness`}),l(`div`,{className:`mt-1 text-sm`,children:z.runtime?.monitoring_active?z.readiness?.publish_ready?`Monitoring`:`Watching locally`:z.runtime?.paused||E?`Paused`:z.readiness?.ingest_ready?`Ready`:`Blocked`}),l(`div`,{className:`tcp-subtle text-xs`,children:z.runtime?.last_runtime_error||z.last_error||`No blocking issue reported.`}),!z.readiness?.publish_ready&&Array.isArray(z.missing_required_capabilities)&&z.missing_required_capabilities.length?l(`div`,{className:`tcp-subtle mt-2 text-xs`,children:[`Missing: `,z.missing_required_capabilities.join(`, `)]}):null]}),l(`div`,{className:`tcp-list-item`,children:[l(`div`,{className:`text-sm font-medium`,children:`Selected MCP`}),l(`div`,{className:`mt-1 text-sm`,children:Y?.name||`None selected`}),l(`div`,{className:`tcp-subtle text-xs`,children:Y?Y.connected?`Connected`:`Disconnected`:`No server selected`}),l(`div`,{className:`tcp-subtle mt-2 text-xs`,children:[`Bindings: `,z.binding_source_version||`unknown version`,z.bindings_last_merged_at_ms?` · merged ${new Date(z.bindings_last_merged_at_ms).toLocaleString()}`:``]}),l(`div`,{className:`tcp-subtle mt-2 text-xs`,children:[`Local directory:`,` `,U||String(z.config?.workspace_root||``).trim()||`engine workspace root`]}),l(`div`,{className:`tcp-subtle mt-2 text-xs`,children:[`Last event:`,` `,String(z.runtime?.last_incident_event_type||``).trim()||`No incidents processed yet`]})]}),l(`div`,{className:`tcp-list-item`,children:[l(`div`,{className:`text-sm font-medium`,children:`Model route`}),l(`div`,{className:`mt-1 break-all text-sm`,children:z.selected_model?.provider_id&&z.selected_model?.model_id?`${z.selected_model.provider_id} / ${z.selected_model.model_id}`:`No dedicated model selected`}),l(`div`,{className:`tcp-subtle text-xs`,children:z.readiness?.selected_model_ready?`Available`:`Fail-closed when unavailable`}),l(`div`,{className:`tcp-subtle mt-2 text-xs`,children:[`Last processed:`,` `,z.runtime?.last_processed_at_ms?new Date(Number(z.runtime.last_processed_at_ms)).toLocaleString():`Not processed yet`]})]})]}),l(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[l(`div`,{className:`tcp-list-item`,children:[l(`div`,{className:`font-medium`,children:`Capability readiness`}),l(`div`,{className:`tcp-subtle mt-2 grid gap-1 text-xs`,children:[l(`div`,{children:[`github.list_issues:`,` `,z.required_capabilities?.github_list_issues?`ready`:`missing`]}),l(`div`,{children:[`github.get_issue:`,` `,z.required_capabilities?.github_get_issue?`ready`:`missing`]}),l(`div`,{children:[`github.create_issue:`,` `,z.required_capabilities?.github_create_issue?`ready`:`missing`]}),l(`div`,{children:[`github.comment_on_issue:`,` `,z.required_capabilities?.github_comment_on_issue?`ready`:`missing`]})]}),Array.isArray(z.resolved_capabilities)&&z.resolved_capabilities.length?l(`div`,{className:`tcp-subtle mt-3 grid gap-1 text-xs`,children:z.resolved_capabilities.map((e,t)=>l(`div`,{children:[String(e.capability_id||`unknown`),`:`,` `,String(e.tool_name||`unresolved`)]},`${e.capability_id||`cap`}-${t}`))}):null,Array.isArray(z.selected_server_binding_candidates)&&z.selected_server_binding_candidates.length?l(`div`,{className:`tcp-subtle mt-3 grid gap-1 text-xs`,children:z.selected_server_binding_candidates.map((e,t)=>l(`div`,{children:[String(e.capability_id||`unknown`),`:`,` `,String(e.binding_tool_name||`unknown`),e.matched?` · matched`:` · candidate`]},`${e.capability_id||`candidate`}-${t}`))}):null,Array.isArray(z.discovered_mcp_tools)&&z.discovered_mcp_tools.length?l(`div`,{className:`mt-3`,children:[l(`div`,{className:`tcp-subtle text-xs font-medium`,children:`Discovered MCP tools`}),l(`pre`,{className:`tcp-code mt-1 max-h-40 overflow-auto whitespace-pre-wrap break-words text-xs`,children:z.discovered_mcp_tools.join(`
5
+ `)})]}):l(`div`,{className:`tcp-subtle mt-3 text-xs`,children:`No MCP tools were discovered for the selected server.`})]}),l(`div`,{className:`tcp-list-item`,children:[l(`div`,{className:`font-medium`,children:`Posting policy`}),l(`div`,{className:`tcp-subtle mt-2 grid gap-1 text-xs`,children:[l(`div`,{children:[`New issues:`,` `,R?`Manual publish`:i?`Auto-create`:`Internal draft only`]}),l(`div`,{children:[`Matched open issues: `,r?`Auto-comment`:`Detect only`]}),l(`div`,{children:`Dedupe: Fingerprint marker + label`}),l(`div`,{children:`Labels: bug-monitor`}),l(`div`,{children:`Workspace write tools: Disabled`}),l(`div`,{children:`Model fallback: Fail closed`})]})]})]}),l(Ve,{projects:x,watcher:_,projectsJson:C,projectsJsonError:S,intakeKeys:m,createdRawKey:a,isCreatingKey:K.isPending,disablingKeyId:o,resettingSourceKey:ee,replayingSourceKey:I,actionResult:g,onProjectsJsonChange:e=>{X(e);try{let t=JSON.parse(e||`[]`);he(Array.isArray(t)?``:`monitored_projects must be a JSON array`)}catch(e){he(e instanceof Error?e.message:`Invalid JSON`)}},onCreateKey:e=>K.mutate(e),onDisableKey:e=>ne.mutate(e),onClearCreatedRawKey:()=>de(``),onResetSourceOffset:e=>se.mutate(e),onReplayLatestSourceCandidate:e=>oe.mutate(e)}),l(`div`,{className:`rounded-xl border border-slate-700/60 bg-slate-900/20 p-3`,children:[l(`div`,{className:`mb-2 font-medium`,children:`Recent incidents`}),De.length?l(`div`,{className:`grid gap-2`,children:De.map(e=>l(`div`,{className:`tcp-list-item`,children:[l(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[l(`div`,{className:`font-medium`,children:e.title||e.event_type}),l(h,{tone:e.last_error?`warn`:`info`,children:e.status})]}),l(`div`,{className:`tcp-subtle mt-1 text-xs`,children:[e.event_type,` · seen `,Number(e.occurrence_count||0),`x`,` · `,e.updated_at_ms?new Date(e.updated_at_ms).toLocaleString():`time unavailable`]}),l(`div`,{className:`tcp-subtle mt-1 text-xs`,children:e.workspace_root||`engine workspace root`}),e.last_error?l(`div`,{className:`tcp-subtle mt-1 text-xs`,children:e.last_error}):null,e.detail?l(`div`,{className:`tcp-subtle mt-1 text-xs`,children:e.detail}):null,l(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[l(`button`,{className:`tcp-icon-btn`,title:`Replay triage for this incident`,"aria-label":`Replay triage for this incident`,disabled:F.isPending,onClick:()=>F.mutate({incidentId:e.incident_id}),children:l(`i`,{"data-lucide":`rotate-cw`})}),e.triage_run_id?l(`span`,{className:`tcp-subtle text-xs`,children:[`triage run: `,e.triage_run_id]}):null,e.draft_id?l(`span`,{className:`tcp-subtle text-xs`,children:[`draft: `,e.draft_id]}):null]})]},e.incident_id))}):l(T,{text:`No Bug Monitor incidents yet.`})]}),l(`div`,{className:`rounded-xl border border-slate-700/60 bg-slate-900/20 p-3`,children:[l(`div`,{className:`mb-2 font-medium`,children:`Recent reporter drafts`}),Oe.length?l(`div`,{className:`grid gap-2`,children:Oe.map(e=>l(`div`,{className:`tcp-list-item`,children:[l(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[l(`div`,{className:`font-medium`,children:e.title||e.fingerprint}),l(h,{tone:e.status===`approval_required`?`warn`:`info`,children:e.status})]}),l(`div`,{className:`tcp-subtle mt-1 text-xs`,children:[e.repo,` ·`,` `,e.issue_number?`issue #${e.issue_number}`:`draft only`,` ·`,` `,e.created_at_ms?new Date(e.created_at_ms).toLocaleString():`time unavailable`]}),e.github_status?l(`div`,{className:`tcp-subtle mt-1 text-xs`,children:[`GitHub: `,e.github_status,e.matched_issue_number?` · matched #${e.matched_issue_number}${e.matched_issue_state?` (${e.matched_issue_state})`:``}`:``]}):null,e.detail?l(`div`,{className:`tcp-subtle mt-1 text-xs`,children:e.detail}):null,e.last_post_error?l(`div`,{className:`tcp-subtle mt-1 text-xs`,children:e.last_post_error}):null,e.triage_run_id?l(`div`,{className:`tcp-subtle mt-2 text-xs`,children:[`triage run: `,e.triage_run_id]}):null,e.status===`approval_required`?l(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[l(`button`,{className:`tcp-btn-primary`,disabled:s.isPending,title:`Approve draft`,"aria-label":`Approve draft`,onClick:()=>s.mutate({draftId:e.draft_id,decision:`approve`}),children:[l(`i`,{"data-lucide":`check`}),s.isPending?`Updating...`:null]}),l(`button`,{className:`tcp-icon-btn`,title:`Deny draft`,"aria-label":`Deny draft`,disabled:s.isPending,onClick:()=>s.mutate({draftId:e.draft_id,decision:`deny`}),children:l(`i`,{"data-lucide":`x`})})]}):null,e.issue_number?null:l(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[l(`button`,{className:`tcp-icon-btn`,title:`Publish this draft to GitHub now`,"aria-label":`Publish this draft to GitHub now`,disabled:N.isPending,onClick:()=>N.mutate({draftId:e.draft_id}),children:l(`i`,{"data-lucide":`bug-play`})}),l(`button`,{className:`tcp-icon-btn`,title:`Recheck GitHub for an existing matching issue`,"aria-label":`Recheck GitHub for an existing matching issue`,disabled:P.isPending,onClick:()=>P.mutate({draftId:e.draft_id}),children:l(`i`,{"data-lucide":`refresh-cw`})})]}),(e.github_issue_url||e.github_comment_url)&&l(`div`,{className:`mt-3 flex flex-wrap gap-2 text-xs`,children:[e.github_issue_url?l(`a`,{className:`tcp-btn`,href:e.github_issue_url,target:`_blank`,rel:`noreferrer`,children:[l(`i`,{"data-lucide":`external-link`}),`Open issue`]}):null,e.github_comment_url?l(`a`,{className:`tcp-btn`,href:e.github_comment_url,target:`_blank`,rel:`noreferrer`,children:[l(`i`,{"data-lucide":`message-square`}),`Open comment`]}):null]}),(e.status===`draft_ready`||e.status===`triage_queued`)&&!e.triage_run_id?l(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:l(`button`,{className:`tcp-icon-btn`,title:`Create triage run`,"aria-label":`Create triage run`,disabled:H.isPending,onClick:()=>H.mutate({draftId:e.draft_id}),children:l(`i`,{"data-lucide":`sparkles`})})}):null]},e.draft_id))}):l(T,{text:`No Bug Monitor drafts yet.`})]}),l(`div`,{className:`rounded-xl border border-slate-700/60 bg-slate-900/20 p-3`,children:[l(`div`,{className:`mb-2 font-medium`,children:`Recent GitHub posts`}),ke.length?l(`div`,{className:`grid gap-2`,children:ke.map(e=>l(`div`,{className:`tcp-list-item`,children:[l(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[l(`div`,{className:`font-medium`,children:e.operation}),l(h,{tone:e.status===`posted`?`ok`:`warn`,children:e.status})]}),l(`div`,{className:`tcp-subtle mt-1 text-xs`,children:[e.repo,e.issue_number?` · issue #${e.issue_number}`:``,e.updated_at_ms?` · ${new Date(e.updated_at_ms).toLocaleString()}`:``]}),e.error?l(`div`,{className:`tcp-subtle mt-1 text-xs`,children:e.error}):null,l(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[e.issue_url?l(`a`,{className:`tcp-btn`,href:e.issue_url,target:`_blank`,rel:`noreferrer`,children:[l(`i`,{"data-lucide":`external-link`}),`Open issue`]}):null,e.comment_url?l(`a`,{className:`tcp-btn`,href:e.comment_url,target:`_blank`,rel:`noreferrer`,children:[l(`i`,{"data-lucide":`message-square`}),`Open comment`]}):null]})]},e.post_id))}):l(T,{text:`No GitHub post attempts yet.`})]})]})}):null})}function Ue({controller:e}){let{activeSection:n,browserIssues:r,browserRecommendations:i,browserSmokeResult:a,browserStatus:o,setDiagnosticsOpen:s,hostedManaged:c,installBrowserMutation:d,localEngine:f,smokeTestBrowserMutation:p,systemHealthQuery:g,worktreeCleanupActionRows:_,worktreeCleanupDryRun:y,worktreeCleanupMutation:b,worktreeCleanupPendingMessage:x,worktreeCleanupRepoRoot:S,worktreeCleanupResult:C,setWorktreeCleanupDryRun:w,setWorktreeCleanupRepoRoot:T,setWorktreeCleanupResult:E}=e,D=Array.isArray(_)?_:[],O=Array.isArray(r)?r:[];return l(t,{children:[n===`maintenance`?l(v,{title:`Managed worktree cleanup`,subtitle:`Scan repo-local .tandem/worktrees entries, keep live runtime worktrees, and remove stale or orphaned leftovers.`,actions:l(m,{children:[l(`button`,{className:`tcp-btn`,onClick:()=>{E(null),g.refetch()},children:[l(`i`,{"data-lucide":`refresh-cw`}),`Refresh root`]}),l(`button`,{className:`tcp-btn`,onClick:()=>b.mutate({repoRoot:S.trim(),dryRun:!0}),disabled:b.isPending||!S.trim(),children:[l(`i`,{"data-lucide":`search`}),`Preview stale worktrees`]}),l(`button`,{className:`tcp-btn-primary`,onClick:()=>b.mutate({repoRoot:S.trim(),dryRun:y}),disabled:b.isPending||!S.trim(),children:[l(`i`,{"data-lucide":`trash-2`}),b.isPending?`Cleaning up...`:y?`Run preview`:`Clean stale worktrees`]})]}),children:l(`div`,{className:`grid gap-4`,children:[l(`label`,{className:`grid gap-2`,children:[l(`span`,{className:`text-sm font-medium`,children:`Repository root`}),l(`input`,{className:`tcp-input`,value:S,onInput:e=>T(e.target.value),placeholder:`/absolute/path/to/repo`})]}),l(`label`,{className:`flex items-center gap-3 text-sm`,children:[l(`input`,{type:`checkbox`,checked:y,onChange:e=>w(e.target.checked)}),`Use dry run when clicking the primary action`]}),l(`div`,{className:`grid gap-3 md:grid-cols-3`,children:[l(`div`,{className:`tcp-list-item`,children:[l(`div`,{className:`text-sm font-medium`,children:`Detected workspace root`}),l(`div`,{className:`mt-1 break-all text-xs`,children:String(g.data?.workspace_root||`Unavailable`)})]}),l(`div`,{className:`tcp-list-item`,children:[l(`div`,{className:`text-sm font-medium`,children:`Cleanup target`}),l(`div`,{className:`mt-1 break-all text-xs`,children:C?.managed_root||`${S||`repo`}/.tandem/worktrees`})]}),l(`div`,{className:`tcp-list-item`,children:[l(`div`,{className:`text-sm font-medium`,children:`Host mode`}),l(`div`,{className:`mt-1 text-xs`,children:[f?`Local engine`:`Remote engine`,` ·`,` `,c?`hosted-managed`:`self-managed`]})]})]}),b.isPending?l(u.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},className:`rounded-2xl border border-cyan-500/30 bg-cyan-500/10 px-4 py-3`,children:l(`div`,{className:`flex items-center justify-between gap-3`,children:[l(`div`,{children:[l(`div`,{className:`text-sm font-medium`,children:`Cleanup running`}),l(`div`,{className:`tcp-subtle mt-1 text-xs`,children:x})]}),l(u.div,{className:`h-2 w-24 overflow-hidden rounded-full bg-slate-800`,initial:!1,children:l(u.div,{className:`h-full rounded-full bg-cyan-400`,animate:{x:[`-100%`,`120%`]},transition:{duration:1.2,repeat:1/0,ease:`easeInOut`}})})]})}):null,C?l(`div`,{className:`grid gap-3`,children:[l(`div`,{className:`grid gap-3 md:grid-cols-4`,children:[l(`div`,{className:`tcp-list-item`,children:[l(`div`,{className:`text-sm font-medium`,children:`Tracked active`}),l(`div`,{className:`mt-1 text-2xl font-semibold`,children:C.active_paths?.length||0})]}),l(`div`,{className:`tcp-list-item`,children:[l(`div`,{className:`text-sm font-medium`,children:`Stale candidates`}),l(`div`,{className:`mt-1 text-2xl font-semibold`,children:C.stale_paths?.length||0})]}),l(`div`,{className:`tcp-list-item`,children:[l(`div`,{className:`text-sm font-medium`,children:`Removed`}),l(`div`,{className:`mt-1 text-2xl font-semibold`,children:(C.cleaned_worktrees?.length||0)+(C.orphan_dirs_removed?.length||0)})]}),l(`div`,{className:`tcp-list-item`,children:[l(`div`,{className:`text-sm font-medium`,children:`Failures`}),l(`div`,{className:`mt-1 text-2xl font-semibold`,children:C.failures?.length||0})]})]}),l(`div`,{className:`rounded-2xl border border-slate-700/60 bg-slate-950/25 p-4`,children:[l(`div`,{className:`flex items-center justify-between gap-3`,children:[l(`div`,{children:[l(`div`,{className:`font-medium`,children:C.dry_run?`Preview results`:`Cleanup log`}),l(`div`,{className:`tcp-subtle mt-1 text-xs`,children:C.repo_root||S})]}),l(h,{tone:(C.failures?.length||0)>0?`warn`:C.dry_run?`info`:`ok`,children:C.dry_run?`Dry run`:`Applied`})]}),l(`div`,{className:`mt-3 grid gap-2`,children:[l(AnimatePresence,{initial:!1,children:D.map((e,t)=>l(u.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-8},transition:{duration:.18,delay:t*.03},className:`tcp-list-item`,children:l(`div`,{className:`flex items-start justify-between gap-3`,children:[l(`div`,{className:`min-w-0`,children:[l(`div`,{className:`text-sm font-medium break-all`,children:e.title}),l(`div`,{className:`tcp-subtle mt-1 text-xs`,children:e.detail})]}),l(h,{tone:e.tone,children:e.kind===`orphan_removed`?`orphan`:e.kind.replaceAll(`_`,` `)})]})},`${e.kind}-${e.title}-${t}`))}),D.length?null:l(`div`,{className:`tcp-subtle text-xs`,children:`No stale managed worktrees were detected for this repository.`})]})]})]}):null,l(`div`,{className:`tcp-subtle text-xs`,children:[`This action only targets repo-local managed worktrees under`,` `,l(`code`,{children:`.tandem/worktrees`}),` and skips paths that the current Tandem process still tracks as active.`]})]})}):null,n===`browser`?l(v,{title:`Browser readiness`,subtitle:`Operational browser status, diagnostics, and recovery actions.`,actions:l(m,{children:[l(`button`,{className:`tcp-btn`,onClick:()=>void o.refetch(),children:[l(`i`,{"data-lucide":`refresh-cw`}),`Refresh browser status`]}),l(`button`,{className:`tcp-btn`,onClick:()=>d.mutate(),disabled:d.isPending,children:[l(`i`,{"data-lucide":`download`}),d.isPending?`Installing sidecar...`:`Install sidecar`]}),l(`button`,{className:`tcp-btn`,onClick:()=>p.mutate(),disabled:p.isPending,children:[l(`i`,{"data-lucide":`globe`}),p.isPending?`Running smoke test...`:`Run smoke test`]}),l(`button`,{className:`tcp-btn`,onClick:()=>s(!0),children:[l(`i`,{"data-lucide":`activity`}),`Diagnostics`]})]}),children:[l(`div`,{className:`grid gap-2 md:grid-cols-3`,children:[l(`div`,{className:`tcp-list-item`,children:[l(`div`,{className:`text-sm font-medium`,children:`Status`}),l(`div`,{className:`mt-1 text-sm`,children:o.data?o.data.runnable?`Ready`:o.data.enabled?`Blocked`:`Disabled`:`Unknown`}),l(`div`,{className:`tcp-subtle text-xs`,children:[`Headless default: `,o.data?.headless_default?`yes`:`no`]})]}),l(`div`,{className:`tcp-list-item`,children:[l(`div`,{className:`text-sm font-medium`,children:`Sidecar`}),l(`div`,{className:`mt-1 break-all text-sm`,children:o.data?.sidecar?.path||`Not found`}),l(`div`,{className:`tcp-subtle text-xs`,children:o.data?.sidecar?.version||`No version detected`})]}),l(`div`,{className:`tcp-list-item`,children:[l(`div`,{className:`text-sm font-medium`,children:`Browser`}),l(`div`,{className:`mt-1 break-all text-sm`,children:o.data?.browser?.path||`Not found`}),l(`div`,{className:`tcp-subtle text-xs`,children:o.data?.browser?.version||o.data?.browser?.channel||`No version detected`})]})]}),O.length?l(`div`,{className:`mt-3 grid gap-2`,children:O.map((e,t)=>l(`div`,{className:`tcp-list-item`,children:[l(`div`,{className:`text-sm font-medium`,children:e.code||`browser_issue`}),l(`div`,{className:`tcp-subtle text-xs`,children:e.message||`Unknown browser issue.`})]},`${e.code||`issue`}-${t}`))}):null,a?l(`div`,{className:`mt-3 rounded-xl border border-emerald-500/30 bg-emerald-500/10 p-3 text-sm`,children:[l(`div`,{className:`font-medium`,children:[`Smoke test passed`,a.title?`: ${a.title}`:``]}),l(`div`,{className:`tcp-subtle mt-1 text-xs`,children:a.final_url||a.url||`No URL returned`}),l(`div`,{className:`tcp-subtle text-xs`,children:[`Load state: `,a.load_state||`unknown`,` · elements:`,` `,String(a.element_count??0),` · closed:`,` `,a.closed?`yes`:`no`]}),a.excerpt?l(`pre`,{className:`tcp-code mt-2 max-h-32 overflow-auto whitespace-pre-wrap break-words`,children:a.excerpt}):null]}):null]}):null]})}function We({controller:e}){let{api:n,installBrowserMutation:r,browserInstallHints:i,browserIssues:a,browserRecommendations:o,browserSmokeResult:s,browserStatus:c,bugMonitorCurrentBrowseDir:f,bugMonitorSuggestedWorkspaceRoot:p,bugMonitorWorkspaceBrowserOpen:h,bugMonitorWorkspaceBrowserSearch:_,bugMonitorWorkspaceParentDir:v,bugMonitorWorkspaceSearchQuery:y,configuredMcpServerNames:b,diagnosticsOpen:x,filteredBugMonitorWorkspaceDirectories:S,filteredMcpCatalog:C,githubMcpGuideOpen:w,mcpAuthMode:E,mcpAuthPreviewText:D,mcpCatalog:O,mcpCatalogQuery:k,mcpCatalogSearch:A,mcpConnectAfterAdd:M,mcpCustomHeader:P,mcpEditingName:F,mcpExtraHeaders:L,mcpGithubToolsets:R,mcpIsGithubTransport:ee,mcpModalOpen:z,mcpModalTab:B,mcpName:V,mcpOauthGuidanceText:H,mcpOauthStartsAfterSave:U,mcpSaveMutation:W,mcpToken:G,mcpTransport:te,smokeTestBrowserMutation:K,setBugMonitorWorkspaceBrowserDir:q,setBugMonitorWorkspaceBrowserOpen:ae,setBugMonitorWorkspaceBrowserSearch:J,setBugMonitorWorkspaceRoot:oe,setGithubMcpGuideOpen:se,setMcpAuthMode:ce,setMcpCatalogSearch:Y,setMcpConnectAfterAdd:le,setMcpCustomHeader:de,setMcpExtraHeaders:fe,setMcpGithubToolsets:pe,setMcpModalOpen:me,setMcpModalTab:he,setMcpName:X,setMcpToken:ge,setDiagnosticsOpen:_e,setMcpTransport:ve,toast:Z}=e,ye=Array.isArray(S)?S:[],Q=Array.isArray(a)?a:[],be=Array.isArray(o)?o:[],xe=Array.isArray(i)?i:[],Se=Array.isArray(C)?C:[],Ce=Array.isArray(L)?L:[];return l(t,{children:[l(g,{open:w,onClose:()=>se(!1),title:`Official GitHub MCP guide`,children:l(`div`,{className:`grid gap-3`,children:[l(`div`,{className:`rounded-xl border border-emerald-500/30 bg-emerald-500/10 p-3 text-sm`,children:`Recommended for Bug Monitor: use the official GitHub MCP endpoint instead of a third-party wrapper when you want stable issue read/write operations.`}),l(`div`,{className:`grid gap-2 md:grid-cols-2`,children:[l(`div`,{className:`tcp-list-item`,children:[l(`div`,{className:`text-sm font-medium`,children:`Transport URL`}),l(`div`,{className:`mt-1 break-all text-sm`,children:`https://api.githubcopilot.com/mcp/`}),l(`div`,{className:`tcp-subtle text-xs`,children:`Use this as the MCP server transport in Tandem Settings.`})]}),l(`div`,{className:`tcp-list-item`,children:[l(`div`,{className:`text-sm font-medium`,children:`Auth mode`}),l(`div`,{className:`mt-1 text-sm`,children:`Authorization Bearer`}),l(`div`,{className:`tcp-subtle text-xs`,children:`Paste a GitHub token in the MCP server dialog and use bearer auth.`})]})]}),l(`div`,{className:`grid gap-2`,children:[l(`div`,{className:`text-sm font-medium`,children:`Recommended setup`}),l(`div`,{className:`tcp-list-item text-sm`,children:["1. Open `Add MCP server`.",l(`br`,{}),"2. Name it `github` or another stable name.",l(`br`,{}),"3. Set transport to `https://api.githubcopilot.com/mcp/`.",l(`br`,{}),"4. Set auth mode to `Authorization Bearer`.",l(`br`,{}),`5. Paste a GitHub Personal Access Token.`,l(`br`,{}),`6. Save, connect, then select that MCP server in Bug Monitor settings.`]})]}),l(`div`,{className:`grid gap-2`,children:[l(`div`,{className:`text-sm font-medium`,children:`Token guidance`}),l(`div`,{className:`tcp-list-item text-sm`,children:`For failure reporting, the token needs issue read/write access on the target repository so the runtime can create issues and add comments.`})]}),l(`div`,{className:`grid gap-2`,children:[l(`div`,{className:`text-sm font-medium`,children:`Direct links`}),l(`div`,{className:`flex flex-wrap gap-2`,children:[l(`a`,{className:`tcp-btn`,href:`https://github.com/github/github-mcp-server?tab=readme-ov-file`,target:`_blank`,rel:`noreferrer`,children:[l(`i`,{"data-lucide":`external-link`}),`GitHub MCP README`]}),l(`a`,{className:`tcp-btn`,href:`https://docs.github.com/en/copilot/how-tos/provide-context/use-mcp/use-the-github-mcp-server`,target:`_blank`,rel:`noreferrer`,children:[l(`i`,{"data-lucide":`external-link`}),`GitHub Docs`]})]})]}),l(`div`,{className:`grid gap-2`,children:[l(`div`,{className:`text-sm font-medium`,children:`Issue tools to expect`}),l(`div`,{className:`tcp-list-item text-sm`,children:`The reporter should be able to resolve issue-list, issue-read, issue-create, and issue-comment operations from the selected GitHub MCP server. If readiness still fails, compare the discovered MCP tools shown in Settings against those issue operations.`})]})]})}),l(d,{children:h?l(u.div,{className:`tcp-confirm-overlay`,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},children:[l(`button`,{type:`button`,className:`tcp-confirm-backdrop`,"aria-label":`Close Bug Monitor workspace dialog`,onClick:()=>{ae(!1),J(``)}}),l(u.div,{className:`tcp-confirm-dialog max-w-2xl`,initial:{opacity:0,y:8,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:6,scale:.98},children:[l(`h3`,{className:`tcp-confirm-title`,children:`Select Bug Monitor Directory`}),l(`p`,{className:`tcp-confirm-message`,children:[`Current: `,f||`n/a`]}),l(`div`,{className:`mb-3 rounded-xl border border-white/10 bg-black/20 p-3 text-xs`,children:[l(`div`,{className:`font-semibold text-slate-100`,children:`Where should I go?`}),l(`div`,{className:`tcp-subtle mt-1`,children:[`Hosted installs share Coder repositories at `,l(`code`,{children:j}),`. Choose the repo folder, for example`,` `,l(`code`,{children:p}),`. The`,` `,l(`code`,{children:N}),` folder is runtime state, not the source checkout.`]})]}),l(`div`,{className:`mb-2 flex flex-wrap gap-2`,children:[l(`button`,{className:`tcp-btn`,onClick:()=>{v&&q(v)},disabled:!v,children:[l(`i`,{"data-lucide":`arrow-up-circle`}),`Up`]}),l(`button`,{className:`tcp-btn`,onClick:()=>{q(j),J(``)},children:[l(`i`,{"data-lucide":`folder-git-2`}),`Synced repos`]}),l(`button`,{className:`tcp-btn-primary`,onClick:()=>{f&&(oe(f),ae(!1),J(``),Z(`ok`,`Bug Monitor directory selected: ${f}`))},children:[l(`i`,{"data-lucide":`badge-check`}),`Select This Folder`]}),l(`button`,{className:`tcp-btn`,onClick:()=>{ae(!1),J(``)},children:[l(`i`,{"data-lucide":`x`}),`Close`]})]}),l(`div`,{className:`mb-2`,children:l(`input`,{className:`tcp-input`,placeholder:`Type to filter folders...`,value:_,onInput:e=>J(e.target.value)})}),l(`div`,{className:`max-h-[360px] overflow-auto rounded-lg border border-slate-700/60 bg-slate-900/20 p-2`,children:ye.length?ye.map(e=>{let t=String(e?.path||``),n=I(t);return l(`button`,{className:`tcp-list-item mb-1 w-full text-left`,onClick:()=>q(t),children:[l(`i`,{"data-lucide":`folder-open`}),l(`span`,{className:`min-w-0`,children:[l(`span`,{className:`block truncate`,children:String(e?.name||e?.path||``)}),n?l(`span`,{className:`tcp-subtle block text-xs`,children:n}):null]})]},String(e?.path||e?.name))}):l(T,{text:y?`No folders match your search.`:`No subdirectories in this folder.`})})]})]}):null}),l(g,{open:x,onClose:()=>_e(!1),title:`Browser diagnostics`,children:l(`div`,{className:`grid gap-3`,children:[l(`div`,{className:`grid gap-2 md:grid-cols-3`,children:[l(`div`,{className:`tcp-list-item`,children:[l(`div`,{className:`text-sm font-medium`,children:`Status`}),l(`div`,{className:`mt-1 text-sm`,children:c.data?c.data.runnable?`Ready`:c.data.enabled?`Blocked`:`Disabled`:`Unknown`}),l(`div`,{className:`tcp-subtle text-xs`,children:[`Headless default: `,c.data?.headless_default?`yes`:`no`]})]}),l(`div`,{className:`tcp-list-item`,children:[l(`div`,{className:`text-sm font-medium`,children:`Sidecar`}),l(`div`,{className:`mt-1 break-all text-sm`,children:c.data?.sidecar?.path||`Not found`}),l(`div`,{className:`tcp-subtle text-xs`,children:c.data?.sidecar?.version||`No version detected`})]}),l(`div`,{className:`tcp-list-item`,children:[l(`div`,{className:`text-sm font-medium`,children:`Browser`}),l(`div`,{className:`mt-1 break-all text-sm`,children:c.data?.browser?.path||`Not found`}),l(`div`,{className:`tcp-subtle text-xs`,children:c.data?.browser?.version||c.data?.browser?.channel||`No version detected`})]})]}),l(m,{children:[l(`button`,{className:`tcp-btn`,onClick:()=>void c.refetch(),children:[l(`i`,{"data-lucide":`refresh-cw`}),`Refresh browser status`]}),l(`button`,{className:`tcp-btn`,onClick:()=>r.mutate(),disabled:r.isPending,children:[l(`i`,{"data-lucide":`download`}),r.isPending?`Installing sidecar...`:`Install sidecar`]}),l(`button`,{className:`tcp-btn`,onClick:()=>K.mutate(),disabled:K.isPending,children:[l(`i`,{"data-lucide":`globe`}),K.isPending?`Running smoke test...`:`Run smoke test`]}),l(`button`,{className:`tcp-btn`,onClick:()=>n(`/api/engine/browser/status`,{method:`GET`}).then(()=>Z(`ok`,`Browser diagnostics refreshed.`)).catch(e=>Z(`err`,e instanceof Error?e.message:String(e))),children:[l(`i`,{"data-lucide":`activity`}),`Re-run diagnostics`]})]}),c.isLoading?l(T,{text:`Loading browser diagnostics...`}):c.data?l(t,{children:[Q.length?l(`div`,{className:`grid gap-2`,children:[l(`div`,{className:`text-sm font-medium`,children:`Blocking issues`}),Q.map((e,t)=>l(`div`,{className:`tcp-list-item`,children:[l(`div`,{className:`text-sm font-medium`,children:e.code||`browser_issue`}),l(`div`,{className:`tcp-subtle text-xs`,children:e.message||`Unknown browser issue.`})]},`${e.code||`issue`}-${t}`))]}):l(`div`,{className:`rounded-xl border border-emerald-500/30 bg-emerald-500/10 p-3 text-sm`,children:`Browser automation is ready on this machine.`}),s?l(`div`,{className:`grid gap-2`,children:[l(`div`,{className:`text-sm font-medium`,children:`Latest smoke test`}),l(`div`,{className:`tcp-list-item`,children:[l(`div`,{className:`text-sm font-medium`,children:s.title||`Smoke test`}),l(`div`,{className:`tcp-subtle text-xs`,children:s.final_url||s.url||`No URL returned`}),l(`div`,{className:`tcp-subtle text-xs`,children:[`Load state: `,s.load_state||`unknown`,` · elements:`,` `,String(s.element_count??0),` · closed:`,` `,s.closed?`yes`:`no`]}),s.excerpt?l(`pre`,{className:`tcp-code mt-2 max-h-40 overflow-auto whitespace-pre-wrap break-words`,children:s.excerpt}):null]})]}):null,be.length?l(`div`,{className:`grid gap-2`,children:[l(`div`,{className:`text-sm font-medium`,children:`Recommendations`}),be.map((e,t)=>l(`div`,{className:`tcp-list-item text-sm`,children:e},`browser-recommendation-${t}`))]}):null,xe.length?l(`div`,{className:`grid gap-2`,children:[l(`div`,{className:`text-sm font-medium`,children:`Install hints`}),xe.map((e,t)=>l(`div`,{className:`tcp-list-item text-sm`,children:e},`browser-install-hint-${t}`))]}):null,c.data?.last_error?l(`div`,{className:`tcp-subtle rounded-lg border border-slate-700/60 bg-slate-900/20 p-3 text-xs`,children:[`Last error: `,c.data.last_error]}):null]}):l(T,{text:`Browser diagnostics are unavailable.`})]})}),l(d,{children:z?l(u.div,{className:`tcp-confirm-overlay`,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},children:[l(`button`,{type:`button`,className:`tcp-confirm-backdrop`,"aria-label":`Close MCP server dialog`,onClick:()=>me(!1)}),l(u.div,{className:`tcp-confirm-dialog tcp-verification-modal`,initial:{opacity:0,y:8,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:6,scale:.98},children:[l(`div`,{className:`mb-3 flex items-start justify-between gap-3`,children:[l(`div`,{children:[l(`h3`,{className:`tcp-confirm-title`,children:F?`Edit MCP Server`:`Add MCP Server`}),l(`p`,{className:`tcp-confirm-message`,children:`Configure transport and auth without leaving Settings.`})]}),l(`button`,{type:`button`,className:`tcp-btn h-8 px-2`,onClick:()=>me(!1),children:l(`i`,{"data-lucide":`x`})})]}),l(`form`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-hidden`,onSubmit:e=>{e.preventDefault(),W.mutate()},children:[l(`div`,{className:`tcp-settings-tabs`,children:[l(`button`,{type:`button`,className:`tcp-settings-tab tcp-settings-tab-underline ${B===`catalog`?`active`:``}`,onClick:()=>he(`catalog`),children:[l(`i`,{"data-lucide":`blocks`}),`Built-in packs`]}),l(`button`,{type:`button`,className:`tcp-settings-tab tcp-settings-tab-underline ${B===`manual`?`active`:``}`,onClick:()=>he(`manual`),children:[l(`i`,{"data-lucide":`square-pen`}),`Manual`]})]}),B===`catalog`?l(`div`,{className:`grid min-h-0 flex-1 content-start gap-3 overflow-hidden`,children:[l(`div`,{className:`flex items-center justify-between gap-3`,children:[l(`div`,{className:`tcp-subtle text-sm`,children:O.generatedAt?`Built-in MCP packs · generated ${O.generatedAt}`:`Built-in MCP packs`}),l(`button`,{type:`button`,className:`tcp-btn h-8 px-3 text-xs`,onClick:()=>void k.refetch(),children:[l(`i`,{"data-lucide":`refresh-cw`}),`Refresh`]})]}),l(`input`,{className:`tcp-input`,value:A,onInput:e=>Y(e.target.value),placeholder:`Search built-in MCP packs`}),l(`div`,{className:`grid min-h-0 flex-1 auto-rows-max content-start gap-2 overflow-y-auto pr-1 md:grid-cols-2`,children:Se.length?Se.map(e=>{let t=b.has(String(e.serverConfigName||e.slug||``).toLowerCase());return l(`div`,{className:`tcp-list-item grid h-full min-h-[8.5rem] content-start gap-2`,children:[l(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[l(`div`,{children:[l(`div`,{className:`font-semibold`,children:e.name}),l(`div`,{className:`tcp-subtle text-xs`,children:[e.slug,e.requiresSetup?` · setup required`:``]})]}),l(`div`,{className:`flex flex-wrap gap-2`,children:[l(Badge,{tone:`info`,children:[e.toolCount,` tools`]}),e.authKind===`oauth`?l(Badge,{tone:`info`,children:`OAuth`}):l(Badge,{tone:e.requiresAuth?`warn`:`ok`,children:e.requiresAuth?`Auth`:`Authless`})]})]}),l(`div`,{className:`tcp-subtle line-clamp-2 text-xs`,children:e.description||e.transportUrl}),l(`div`,{className:`tcp-subtle break-all text-xs`,children:e.transportUrl}),e.authKind===`oauth`?l(`div`,{className:`rounded-xl border border-sky-700/40 bg-sky-950/20 px-3 py-2 text-xs text-sky-100`,children:`Save this pack to start browser sign-in. Tandem will keep the MCP in a pending state until the authorization completes.`}):null,l(`div`,{className:`mt-auto flex flex-wrap gap-2`,children:[l(`button`,{type:`button`,className:`tcp-btn h-8 px-3 text-xs`,onClick:()=>{let t=e.transportUrl,n=ne(e.serverConfigName||e.slug||e.name);X(n),ve(t),ce(e.authKind===`oauth`?`oauth`:n===`github`||ie(t)?`bearer`:`none`),e.authKind===`oauth`&&ge(``),pe(n===`github`||ie(t)?`default`:``),fe([]),he(`manual`),Z(`ok`,e.authKind===`oauth`?`Loaded ${e.name}. Save to start browser sign-in.`:`Loaded ${e.name}. Review and save when ready.`)},children:`Use pack`}),e.documentationUrl?l(`a`,{className:`tcp-btn h-8 px-3 text-xs`,href:e.documentationUrl,target:`_blank`,rel:`noreferrer`,children:[l(`i`,{"data-lucide":`external-link`}),`Docs`]}):null,t?l(Badge,{tone:`ok`,children:`added`}):null]})]},e.slug)}):l(T,{text:`No built-in MCP packs match this search.`})})]}):l(t,{children:[l(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[l(`div`,{className:`grid gap-2`,children:[l(`label`,{className:`text-sm font-medium`,children:`Name`}),l(`input`,{className:`tcp-input`,value:V,onInput:e=>X(e.target.value),placeholder:`mcp-server`})]}),l(`div`,{className:`grid gap-2`,children:[l(`label`,{className:`text-sm font-medium`,children:`Auth mode`}),l(`select`,{className:`tcp-select`,value:E,onChange:e=>{let t=e.target.value;ce(t),t===`oauth`&&ge(``)},children:[l(`option`,{value:`none`,children:`No Auth Header`}),l(`option`,{value:`auto`,children:`Auto`}),l(`option`,{value:`oauth`,children:`OAuth`}),l(`option`,{value:`x-api-key`,children:`x-api-key`}),l(`option`,{value:`bearer`,children:`Authorization Bearer`}),l(`option`,{value:`custom`,children:`Custom Header`})]})]})]}),l(`div`,{className:`grid gap-2`,children:[l(`label`,{className:`text-sm font-medium`,children:`Transport URL`}),l(`input`,{className:`tcp-input`,value:te,onInput:e=>{let t=e.target.value;if(ve(t),ie(t)&&!String(R||``).trim()&&pe(`default`),!String(V||``).trim()||V===`mcp-server`){let e=re(t);e&&X(e)}ue(O,V,t)===`oauth`&&(E===`none`||E===`auto`)&&(ce(`oauth`),ge(``))},placeholder:`https://example.com/mcp`})]}),E===`custom`?l(`div`,{className:`grid gap-2`,children:[l(`label`,{className:`text-sm font-medium`,children:`Custom header name`}),l(`input`,{className:`tcp-input`,value:P,onInput:e=>de(e.target.value),placeholder:`X-My-Token`})]}):null,E===`oauth`?l(`div`,{className:`grid gap-2 rounded-xl border border-sky-700/50 bg-sky-950/20 px-3 py-3 text-xs text-sky-100`,children:[l(`div`,{className:`font-medium`,children:`OAuth sign-in flow`}),l(`div`,{children:H}),l(`div`,{className:`tcp-subtle text-xs text-sky-100/80`,children:U?`Saving this server will immediately start the browser handoff.`:"Turn on `Connect after save` to launch the authorization flow as soon as the server is saved."}),l(`div`,{className:`tcp-subtle text-xs text-sky-100/80`,children:D})]}):l(`div`,{className:`grid gap-2`,children:[l(`label`,{className:`text-sm font-medium`,children:`Token`}),l(`input`,{className:`tcp-input`,type:`password`,value:G,onInput:e=>ge(e.target.value),placeholder:`token`}),l(`div`,{className:`tcp-subtle text-xs`,children:D})]}),ee?l(`div`,{className:`grid gap-2`,children:[l(`label`,{className:`text-sm font-medium`,children:`GitHub toolsets`}),l(`input`,{className:`tcp-input`,value:R,onInput:e=>pe(e.target.value),placeholder:`default,projects`}),l(`div`,{className:`tcp-subtle text-xs`,children:"Sent as `X-MCP-Toolsets`. Built-in GitHub starts with `default`; add values like `projects`, `issues`, or `pull_requests`."})]}):null,l(`div`,{className:`grid gap-2`,children:[l(`div`,{className:`flex items-center justify-between gap-2`,children:[l(`label`,{className:`text-sm font-medium`,children:`Additional headers`}),l(`button`,{type:`button`,className:`tcp-btn h-8 px-3 text-xs`,onClick:()=>fe(e=>[...Array.isArray(e)?e:[],{key:``,value:``}]),children:[l(`i`,{"data-lucide":`plus`}),`Add header`]})]}),Ce.length?l(`div`,{className:`grid gap-2`,children:Ce.map((e,t)=>l(`div`,{className:`grid gap-2 md:grid-cols-[1fr_1fr_auto]`,children:[l(`input`,{className:`tcp-input`,value:e.key,onInput:e=>fe(n=>(Array.isArray(n)?n:[]).map((n,r)=>r===t?{...n,key:e.target.value}:n)),placeholder:`Header name`}),l(`input`,{className:`tcp-input`,value:e.value,onInput:e=>fe(n=>(Array.isArray(n)?n:[]).map((n,r)=>r===t?{...n,value:e.target.value}:n)),placeholder:`Header value`}),l(`button`,{type:`button`,className:`tcp-btn`,onClick:()=>fe(e=>(Array.isArray(e)?e:[]).filter((e,n)=>n!==t)),children:`Remove`})]},`mcp-header-${t}`))}):l(`div`,{className:`tcp-subtle text-xs`,children:"Add arbitrary request headers such as `X-MCP-Insiders` or vendor feature flags."})]}),l(`label`,{className:`inline-flex items-center gap-2 text-sm text-slate-200`,children:[l(`input`,{type:`checkbox`,className:`accent-slate-400`,checked:M,onChange:e=>le(e.target.checked)}),E===`oauth`?`Start sign-in after save`:`Connect after save`]})]}),l(`div`,{className:`tcp-confirm-actions mt-2`,children:[l(`button`,{type:`button`,className:`tcp-btn`,onClick:()=>me(!1),children:`Cancel`}),l(`button`,{type:`submit`,className:`tcp-btn-primary`,disabled:W.isPending,children:[l(`i`,{"data-lucide":`save`}),U?`Save MCP server and start sign-in`:`Save MCP server`]})]})]})]})]}):null})]})}function Ge(e){let t=Me(e),{rootRef:n,sectionTabs:r,activeSection:i,setActiveSection:a}=t;return l(_,{className:`grid gap-4`,children:l(`div`,{ref:n,className:`grid gap-4`,children:[l(`div`,{className:`tcp-settings-tabs`,children:(Array.isArray(r)?r:[]).map(e=>l(`button`,{type:`button`,className:`tcp-settings-tab tcp-settings-tab-underline ${i===e.id?`active`:``}`,onClick:()=>a(e.id),children:[l(`i`,{"data-lucide":e.icon}),e.label]},e.id))}),l(f,{main:l(p,{className:`grid gap-4`,children:[l(Ne,{controller:t}),l(Ie,{controller:t}),l(Le,{controller:t}),l(He,{controller:t}),l(Ue,{controller:t})]})}),l(We,{controller:t})]})})}export{Ge as SettingsPage};
@@ -0,0 +1 @@
1
+ import{C as e,E as t,g as n,h as r,v as i}from"./fullcalendar-Bn75j0xM.js";import{i as a,n as o,r as s,t as c}from"./motion-B3ZE8SGR.js";function l(e,t=new Set){let n=String(e||``).trim();if(!n)return``;if(t.has(n))return n;if(!n.startsWith(`node-`)){let e=`node-${n}`;if(t.has(e))return e}return n}function u(e,t=new Set){return Array.isArray(e)?e.map(e=>l(e,t)).filter(Boolean):[]}function d(e){let t=String(e||``).trim().toLowerCase();return t===`assigned`?`assigned`:t===`validated`?`validated`:t===`in_progress`||t===`running`?`in_progress`:t===`done`||t===`completed`?`done`:t===`failed`||t===`error`||t===`cancelled`||t===`canceled`?`failed`:t===`blocked`?`blocked`:t===`runnable`||t===`ready`?`runnable`:t===`created`?`created`:`pending`}function f(e){let t={};for(let n of Array.isArray(e)?e:[]){let e=String(n?.step_id||n?.payload?.task_id||``).trim();if(!e)continue;let r=n?.payload&&typeof n.payload==`object`?n.payload:{},i=t[e]||{assignedRole:``,errorMessage:``,runtimeDetail:``,runtimeStatus:``,sessionId:``};t[e]={assignedRole:String(r?.assigned_agent||r?.agent_id||i.assignedRole||``),errorMessage:String(r?.error||i.errorMessage||``),runtimeDetail:String(r?.why_next_step||i.runtimeDetail||``),runtimeStatus:String(r?.step_status||i.runtimeStatus||``),sessionId:String(r?.session_id||i.sessionId||``)}}return t}function p(e,t,n=new Set){let r=d(e?.status),i=e?.payload&&typeof e.payload==`object`?e.payload:{},a=Number(e?.lease_expires_at_ms||0)||0,o=Number(e?.next_retry_at_ms||0)||0,s=Date.now();return{id:l(String(e?.workflow_node_id||e?.workflowNodeId||``).trim()||e?.id||i?.task_id||i?.workflow_node_id,n),title:String(i?.title||e?.task_type||e?.id||`Untitled task`),description:String(i?.description||i?.objective||``),dependencies:u(e?.depends_on_task_ids,n),state:r,retry_count:Number(e?.attempt||e?.retry_count||0),error_message:r===`failed`||r===`blocked`?String(e?.last_error||t?.errorMessage||``):``,runtime_status:String(t?.runtimeStatus||``),runtime_detail:String(t?.runtimeDetail||``),assigned_role:String(e?.assigned_agent||e?.lease_owner||t?.assignedRole||``),workflow_id:String(e?.workflow_id||``),session_id:String(t?.sessionId||``),task_kind:String(i?.task_kind||``),backlog_task_id:String(i?.backlog_task_id||i?.task_id||``),repo_root:String(i?.repo_root||``),write_scope:String(i?.write_scope||``),acceptance_criteria:String(i?.acceptance_criteria||``),task_dependencies:Array.isArray(i?.task_dependencies)?i.task_dependencies.join(`, `):String(i?.task_dependencies||``),verification_state:String(i?.verification_state||``),task_owner:String(i?.task_owner||i?.owner||``),verification_command:String(i?.verification_command||``),output_path:String(i?.output_path||``),parent_task_id:l(e?.parent_task_id,n),task_type:String(e?.task_type||``),projects_backlog_tasks:!!i?.projects_backlog_tasks,lease_owner:String(e?.lease_owner||``),lease_expires_at_ms:a||void 0,next_retry_at_ms:o||void 0,max_attempts:Number(e?.max_attempts||0)||void 0,is_stale:r===`in_progress`&&a>0&&a<=s}}function m(e,t,n=new Set){let r=l(e?.taskId||e?.step_id,n),i=d(e?.stepStatus||e?.status);return{id:r,title:String(e?.title||e?.step_id||`Untitled step`),description:String(e?.description||``),dependencies:u(e?.dependsOn,n),state:i,retry_count:Number(e?.retry_count||0),error_message:i===`failed`||i===`blocked`?String(e?.error_message||t?.errorMessage||``):``,runtime_status:String(e?.runtime_status||t?.runtimeStatus||``),runtime_detail:String(e?.runtime_detail||t?.runtimeDetail||``),assigned_role:String(e?.assignedAgent||t?.assignedRole||``),workflow_id:String(e?.workflowId||``),session_id:String(e?.sessionId||e?.session_id||t?.sessionId||``)}}function h(e){let t=f(e?.events),n=Array.isArray(e?.run?.tasks)?e.run.tasks:[],r=n.length?n:Array.isArray(e?.blackboard?.tasks)?e.blackboard.tasks:[],i=Array.isArray(e?.tasks)?e.tasks:[],a=new Set;for(let e of r){let t=String(e?.workflow_node_id||e?.workflowNodeId||``).trim(),n=String(e?.id||``).trim();n&&a.add(n),t&&a.add(`node-${t}`)}let o=r.map(e=>p(e,t[String(e?.id||``).trim()],a)).filter(e=>e.id),s=i.map(e=>m(e,t[String(e?.taskId||e?.step_id||``).trim()],a)).filter(e=>e.id),c=new Map;for(let e of o)c.set(e.id,e);for(let e of s){if(!c.has(e.id)){c.set(e.id,e);continue}let t=c.get(e.id);t&&c.set(e.id,{...t,session_id:t.session_id||e.session_id,runtime_status:t.runtime_status||e.runtime_status,runtime_detail:t.runtime_detail||e.runtime_detail,assigned_role:t.assigned_role||e.assigned_role,error_message:t.error_message||e.error_message})}let u=[...c.values()];return{currentTaskId:l(String(e?.run?.current_step_id||``).trim(),a)||u.find(e=>e.state===`in_progress`||e.state===`assigned`)?.id||``,taskSource:o.length?s.length?`hybrid`:(n.length,`blackboard`):s.length?`context_steps`:`empty`,tasks:u}}var g={created:`Created`,pending:`Pending`,runnable:`Runnable`,assigned:`Assigned`,in_progress:`In Progress`,blocked:`Blocked`,done:`Done`,failed:`Failed`,validated:`Validated`};function _(e){return e===`done`||e===`validated`?`tcp-badge-ok`:e===`failed`?`tcp-badge-err`:e===`blocked`?`tcp-badge-blocked`:e===`in_progress`||e===`runnable`||e===`assigned`?`tcp-badge-warn`:`tcp-badge-info`}function v(e,t,n){return n?`border-cyan-400/70 bg-cyan-950/20`:e===`blocked`?`border-indigo-500/35 bg-indigo-950/18`:t?`border-emerald-400/70 bg-emerald-950/14`:`border-slate-700/60 bg-slate-900/20`}function y(e){return e===`in_progress`||e===`assigned`?a(`span`,{className:`inline-block h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent`,"aria-hidden":`true`}):null}function b({task:e,isCurrent:t,isSelected:n,workflowSummary:r,onTaskSelect:i,onRetryTask:l}){let u=c(),d=!!n,f=e.state===`failed`||e.state===`blocked`?String(e.error_message||``).trim():``,p=u?{duration:0}:{type:`spring`,stiffness:360,damping:34,mass:.8},m=v(e.state,t,!!n),h=[];return e.assigned_role&&h.push(`role: ${e.assigned_role}`),e.gate&&h.push(`gate: ${e.gate}`),r&&r.runs>0&&h.push(`workflow ${r.runs}`),e.dependencies.length&&h.push(`deps ${e.dependencies.length}`),a(o.div,{layout:!0,className:`min-w-0 cursor-pointer overflow-hidden rounded-lg border p-2 ${m}`,onClick:()=>i?.(e),role:`button`,tabIndex:0,onKeyDown:t=>{t.key!==`Enter`&&t.key!==` `||(t.preventDefault(),i?.(e))},animate:u?void 0:{opacity:1},transition:p,children:[a(`div`,{className:`flex min-w-0 items-start justify-between gap-2`,children:[a(`div`,{className:`min-w-0 flex-1`,children:[a(`div`,{className:`line-clamp-2 break-words text-xs font-medium leading-snug`,title:e.title,children:e.title}),!d&&e.description?a(`div`,{className:`tcp-subtle mt-1 line-clamp-1 break-words text-[11px]`,children:e.description}):null]}),a(`div`,{className:`flex shrink-0 flex-col items-end gap-1`,children:[a(`span`,{className:`${_(e.state)} inline-flex items-center gap-1`,children:[y(e.state),a(`span`,{children:g[e.state]})]}),a(`span`,{className:`tcp-subtle text-[10px]`,children:d?`Open`:`Tap to expand`})]})]}),h.length?a(`div`,{className:`mt-1 flex min-w-0 flex-wrap gap-1 text-[10px] text-slate-300`,children:[h.slice(0,3).map(e=>a(`span`,{className:`rounded border border-slate-700/60 bg-slate-950/20 px-1.5 py-0.5`,children:e},e)),h.length>3?a(`span`,{className:`rounded border border-slate-700/60 bg-slate-950/20 px-1.5 py-0.5`,children:[`+`,h.length-3]}):null]}):null,a(s,{initial:!1,mode:`popLayout`,children:d?a(o.div,{initial:u?{opacity:1}:{opacity:0,height:0},animate:u?{opacity:1}:{opacity:1,height:`auto`},exit:u?{opacity:1}:{opacity:0,height:0},transition:p,className:`overflow-hidden`,children:a(`div`,{className:`mt-2 grid gap-2 border-t border-slate-700/50 pt-2 text-xs`,children:[e.description?a(`div`,{className:`tcp-subtle whitespace-pre-wrap break-words`,children:e.description}):null,e.assigned_role||e.gate?a(`div`,{className:`flex min-w-0 flex-wrap gap-1 text-[10px] text-slate-300`,children:[e.assigned_role?a(`span`,{className:`rounded border border-cyan-600/50 bg-cyan-950/30 px-1.5 py-0.5`,children:[`role: `,e.assigned_role]}):null,e.gate?a(`span`,{className:`rounded border border-emerald-600/50 bg-emerald-950/30 px-1.5 py-0.5 text-emerald-200`,children:[`gate: `,e.gate]}):null]}):null,r&&r.runs>0?a(`div`,{className:`flex min-w-0 flex-wrap gap-1 text-[10px] text-slate-300`,children:[a(`span`,{className:`rounded border border-indigo-600/50 bg-indigo-950/30 px-1.5 py-0.5`,children:[`workflow runs: `,r.runs]}),r.failed>0?a(`span`,{className:`rounded border border-rose-600/50 bg-rose-950/30 px-1.5 py-0.5 text-rose-200`,children:[`workflow failed: `,r.failed]}):null]}):null,f?a(`div`,{className:`min-w-0 text-xs ${e.state===`blocked`?`text-emerald-200/90`:`text-rose-300`}`,children:a(`div`,{className:`whitespace-pre-wrap break-words`,children:f})}):null,e.dependencies.length?a(`div`,{className:`flex min-w-0 flex-wrap gap-1`,children:[e.dependencies.slice(0,4).map(e=>a(`span`,{className:`rounded border border-slate-700/60 px-1.5 py-0.5 text-[10px] text-slate-300`,children:[`<-`,` `,e]},e)),e.dependencies.length>4?a(`span`,{className:`rounded border border-slate-700/60 px-1.5 py-0.5 text-[10px] text-slate-300`,children:[`+`,e.dependencies.length-4,` more`]}):null]}):null,a(`div`,{className:`tcp-subtle text-[10px]`,children:`Details`}),a(`div`,{className:`flex flex-wrap gap-2`,children:e.state===`failed`&&l?a(`button`,{className:`tcp-btn h-7 px-2 text-xs`,onClick:t=>{t.stopPropagation(),l(e)},children:`Retry Task`}):null})]})},`expanded-task-card`):null})]})}function x({tasks:o,currentTaskId:s,selectedTaskId:c,activeAgentCount:l=0,workflowSummaryByTaskId:u,onTaskSelect:d,onRetryTask:f}){let[p,m]=i(`runnable`),h=r(null),g=r({}),_=n(()=>{let e={created:[],pending:[],runnable:[],assigned:[],in_progress:[],blocked:[],done:[],failed:[],validated:[]};for(let t of o)e[t.state].push(t);let t=new Set([...e.done,...e.validated].map(e=>e.id)),n=[...e.runnable],r=[];for(let i of[...e.created,...e.pending])i.dependencies.length===0||i.dependencies.every(e=>t.has(e))?n.push(i):r.push(i);return{runnable:n,waiting:r,assigned:e.assigned,in_progress:e.in_progress,blocked:e.blocked,done:[...e.done,...e.validated],failed:e.failed}},[o]),v=n(()=>[{key:`runnable`,label:`Ready`,tasks:_.runnable},{key:`waiting`,label:`Waiting on deps`,tasks:_.waiting},{key:`assigned`,label:`Assigned`,tasks:_.assigned},{key:`in_progress`,label:`In Progress`,tasks:_.in_progress},{key:`blocked`,label:`Blocked`,tasks:_.blocked},{key:`done`,label:`Done`,tasks:_.done},{key:`failed`,label:`Failed`,tasks:_.failed}].filter(e=>e.key===`waiting`||e.key===`assigned`?e.tasks.length>0:!0),[_]),y=n(()=>{let e=v.find(e=>e.tasks.some(e=>e.id===s));return e?e.key:v.find(e=>e.tasks.length>0)?.key||`runnable`},[v,s]),x=y;e(()=>{m(e=>v.some(t=>t.key===e)?e:y)},[v,y]);let S=e=>{let t=g.current[e];t&&t.scrollIntoView({behavior:`smooth`,inline:`start`,block:`nearest`})};return o.length?a(t,{children:[a(`div`,{className:`grid gap-3 xl:hidden`,children:[a(`div`,{className:`flex flex-wrap items-center gap-2`,children:[s?a(`button`,{type:`button`,className:`rounded-full border border-emerald-400/60 bg-emerald-400/10 px-3 py-1.5 text-[11px] font-medium text-emerald-200`,onClick:()=>m(x),children:`Jump to active task`}):null,l>0?a(`span`,{className:`rounded-full border border-cyan-400/50 bg-cyan-400/10 px-3 py-1.5 text-[11px] font-medium text-cyan-200`,children:[l,` agent`,l===1?``:`s`,` running`]}):null]}),a(`div`,{className:`flex gap-2 overflow-x-auto pb-1`,children:v.map(e=>a(`button`,{type:`button`,className:`shrink-0 rounded-full border px-3 py-1.5 text-[11px] font-medium ${e.key===p?`border-emerald-400/60 bg-emerald-400/10 text-emerald-200`:`border-slate-700/60 bg-slate-900/20 text-slate-300`}`,onClick:()=>m(e.key),children:[e.label,` (`,e.tasks.length,`)`]},e.key))}),v.filter(e=>e.key===p).map(e=>a(`div`,{className:`rounded-xl border border-slate-700/60 bg-slate-900/20 p-2`,children:[a(`div`,{className:`mb-2 flex items-center justify-between`,children:[a(`div`,{className:`text-xs font-semibold`,children:e.label}),a(`div`,{className:`tcp-subtle text-xs`,children:e.tasks.length})]}),a(`div`,{className:`grid gap-2`,children:[e.tasks.map(e=>a(b,{task:e,isCurrent:e.id===s,isSelected:e.id===c,workflowSummary:u?.[e.id],onTaskSelect:d,onRetryTask:f},e.id)),e.tasks.length?null:a(`div`,{className:`tcp-subtle text-xs`,children:`No tasks`})]})]},e.key))]}),a(`div`,{className:`hidden gap-3 xl:grid`,children:[a(`div`,{className:`flex flex-wrap items-center gap-2`,children:[s?a(`button`,{type:`button`,className:`rounded-full border border-emerald-400/60 bg-emerald-400/10 px-3 py-1.5 text-[11px] font-medium text-emerald-200`,onClick:()=>{x&&S(x)},children:`Jump to active task`}):null,l>0?a(`span`,{className:`rounded-full border border-cyan-400/50 bg-cyan-400/10 px-3 py-1.5 text-[11px] font-medium text-cyan-200`,children:[l,` agent`,l===1?``:`s`,` running`]}):null,a(`div`,{className:`flex flex-wrap gap-2`,children:v.map(e=>a(`button`,{type:`button`,className:`rounded-full border px-3 py-1.5 text-[11px] font-medium ${e.key===x?`border-emerald-400/60 bg-emerald-400/10 text-emerald-200`:`border-slate-700/60 bg-slate-900/20 text-slate-300`}`,onClick:()=>S(e.key),children:[e.label,` (`,e.tasks.length,`)`]},`desktop-tab-${e.key}`))})]}),a(`div`,{ref:h,className:`overflow-x-auto pb-2`,children:a(`div`,{className:`flex min-w-max gap-3`,children:v.map(e=>a(`div`,{ref:t=>{g.current[e.key]=t},className:`min-h-[16rem] w-[320px] shrink-0 rounded-xl border p-2 ${e.key===x?`border-emerald-400/60 bg-emerald-400/5`:`border-slate-700/60 bg-slate-900/20`}`,children:[a(`div`,{className:`mb-2 flex items-center justify-between`,children:[a(`div`,{className:`text-xs font-semibold`,children:e.label}),a(`div`,{className:`tcp-subtle text-xs`,children:e.tasks.length})]}),a(`div`,{className:`grid gap-2`,children:[e.tasks.map(e=>a(b,{task:e,isCurrent:e.id===s,isSelected:e.id===c,workflowSummary:u?.[e.id],onTaskSelect:d,onRetryTask:f},e.id)),e.tasks.length?null:a(`div`,{className:`tcp-subtle text-xs`,children:`No tasks`})]})]},e.key))})})]})]}):a(`div`,{className:`tcp-subtle rounded-lg border border-slate-700/60 bg-slate-900/20 p-4`,children:`No tasks yet.`})}export{h as n,x as t};