@frumu/tandem-panel 0.5.5 → 0.5.6

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 (54) hide show
  1. package/dist/assets/{AutomationsPage-6mRHsh9V.js → AutomationsPage-BGqpmilp.js} +12 -12
  2. package/dist/assets/BugMonitorPage-BVzdj9y-.js +4 -0
  3. package/dist/assets/{ChannelsPage-oJ5a717t.js → ChannelsPage-B-InJ4Yh.js} +1 -1
  4. package/dist/assets/{ChatInterfacePanel-3nvwn0cJ.js → ChatInterfacePanel-BrMo4cXg.js} +1 -1
  5. package/dist/assets/{ChatPage-CGKFC9ev.js → ChatPage-Bc-BfOG1.js} +1 -1
  6. package/dist/assets/CodingWorkflowsPage-xgfwLRlt.js +8 -0
  7. package/dist/assets/{ControlPanelDialogs-BBIPHXnw.js → ControlPanelDialogs-yFfCht3Y.js} +1 -1
  8. package/dist/assets/DashboardPage-CrA1itFc.js +1 -0
  9. package/dist/assets/{ExperimentsPage-DuYHzo7d.js → ExperimentsPage-Bkg1_6rw.js} +2 -2
  10. package/dist/assets/FilesPage-DChyHlO_.js +1 -0
  11. package/dist/assets/{IntentPlannerPage-BwlF9wfW.js → IntentPlannerPage-Dti1h8Tm.js} +4 -4
  12. package/dist/assets/MarketplacePage-90fAVNGg.js +1 -0
  13. package/dist/assets/{McpToolAllowlistEditor-B3qCkiFT.js → McpToolAllowlistEditor-BzQ64HrZ.js} +1 -1
  14. package/dist/assets/{MemoryImportDialog-BWT93PW1.js → MemoryImportDialog-DSpS1JF5.js} +1 -1
  15. package/dist/assets/MemoryPage-DRRLgoc0.js +1 -0
  16. package/dist/assets/{OrchestratorPage-HDyjjwF-.js → OrchestratorPage-CYU-ESPI.js} +1 -1
  17. package/dist/assets/PacksPage-dRmjjdKD.js +3 -0
  18. package/dist/assets/PlannerDiagnosticsPanel-C1uIuRIx.js +1 -0
  19. package/dist/assets/RunsPage-DEy8vbRT.js +1 -0
  20. package/dist/assets/SettingsPage-CwH_FzOs.js +5 -0
  21. package/dist/assets/{TeamsPage-CwMnVES9.js → TeamsPage-Dn81V0EB.js} +3 -3
  22. package/dist/assets/{WorkflowStudioPage-CyWDhEEE.js → WorkflowStudioPage-yFhlA4KV.js} +1 -1
  23. package/dist/assets/WorkflowsPage-vmaKHFox.js +2 -0
  24. package/dist/assets/{index-DAWzCKcg.css → index-C8Bjo7hU.css} +1 -1
  25. package/dist/assets/index-TvymvGva.js +3 -0
  26. package/dist/assets/{useEngineStream-ChEkuUVV.js → useEngineStream-Diqri33l.js} +1 -1
  27. package/dist/index.html +3 -5
  28. package/package.json +3 -3
  29. package/dist/assets/BugMonitorPage-B9mcxV8k.js +0 -4
  30. package/dist/assets/CodingWorkflowsPage-DosUtoeO.js +0 -8
  31. package/dist/assets/DashboardPage-Cv9_TUZQ.js +0 -1
  32. package/dist/assets/FilesPage-NAInb3WU.js +0 -1
  33. package/dist/assets/MarketplacePage-Wo7biaBa.js +0 -1
  34. package/dist/assets/MemoryPage-gSBH1OKG.js +0 -1
  35. package/dist/assets/PacksPage-BWnL4dRB.js +0 -3
  36. package/dist/assets/PlannerDiagnosticsPanel-VyacxaCM.js +0 -1
  37. package/dist/assets/RunsPage-B6ttNeUJ.js +0 -1
  38. package/dist/assets/SettingsPage-DhAKDQHw.js +0 -5
  39. package/dist/assets/WorkflowsPage-BWGWH8uD.js +0 -2
  40. package/dist/assets/api-CpR5ozpc.js +0 -1
  41. package/dist/assets/index-picB46b5.js +0 -3
  42. package/dist/assets/ui-CV-Z6sqF.js +0 -1
  43. /package/dist/assets/{LazyJson-DYncL_RR.js → LazyJson-vfWw7G9F.js} +0 -0
  44. /package/dist/assets/{ProviderModelSelector-B_IE0-e7.js → ProviderModelSelector-BdtOpkJR.js} +0 -0
  45. /package/dist/assets/{TaskBoard-DSRrmiyQ.js → TaskBoard-CCY_Qy5S.js} +0 -0
  46. /package/dist/assets/{TimezoneField-DKINpKxU.js → TimezoneField-B5i---lF.js} +0 -0
  47. /package/dist/assets/{chatPageHelpers-D-NhHk4M.js → chatPageHelpers-Dmb4waDk.js} +0 -0
  48. /package/dist/assets/{explorerHandoff-KpFRPNQc.js → explorerHandoff-BPKxMR82.js} +0 -0
  49. /package/dist/assets/{format-CimuGHiH.js → format-DyX5imzJ.js} +0 -0
  50. /package/dist/assets/{markdown-DJurGVIJ.js → markdown-Dwwtq3bu.js} +0 -0
  51. /package/dist/assets/{messages-AWZpX-Rw.js → messages-uD0aB_MZ.js} +0 -0
  52. /package/dist/assets/{plannerShared-1kHFyAp-.js → plannerShared-Dx7-Sxpc.js} +0 -0
  53. /package/dist/assets/{sse-B1wvyjPI.js → sse-B4A2m-Nk.js} +0 -0
  54. /package/dist/assets/{workflowStability-Dsk2DR6F.js → workflowStability-C8USyGOY.js} +0 -0
@@ -1,8 +0,0 @@
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}from"./react-query-BIbNygEJ.js";import{i as c}from"./motion-B3ZE8SGR.js";import{n as l,p as u,r as d,t as f,u as p}from"./ui-CV-Z6sqF.js";import{a as m,s as h,t as g,u as ee}from"./index-picB46b5.js";import{t as te}from"./ProviderModelSelector-B_IE0-e7.js";import{n as _}from"./LazyJson-DYncL_RR.js";import{t as ne}from"./sse-B1wvyjPI.js";import{a as v,i as re,n as y,o as b,r as ie,s as x,t as S}from"./plannerShared-1kHFyAp-.js";import{t as C}from"./ChatInterfacePanel-3nvwn0cJ.js";import{n as w,t as ae}from"./ControlPanelDialogs-BBIPHXnw.js";import{t as oe}from"./PlannerDiagnosticsPanel-VyacxaCM.js";function T({label:e,value:t,helper:n,tone:r=`info`}){return c(`div`,{className:`rounded-2xl border border-white/10 bg-black/20 p-4 shadow-[0_12px_36px_rgba(0,0,0,0.12)]`,children:[c(`div`,{className:`flex items-start justify-between gap-3`,children:[c(`div`,{className:`tcp-kpi-label text-sm`,children:e}),c(l,{tone:r,children:n})]}),c(`div`,{className:`mt-3 text-2xl font-semibold tracking-tight`,children:t})]})}function E(e){return String(e||`unknown`).replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function D(e,t=`unknown`){return String(e??``).trim()||t}function O(e){return Array.isArray(e)?e.map(e=>String(e||``).trim()).filter(Boolean):[]}function k(e){let t=Number(e||0);return t?new Date(t).toLocaleString():`not refreshed yet`}function se(e){return String(e?.run_id||e?.aca_run_id||e?.id||``).trim()}function A(e){return String(e?.coder_run_id||e?.tandem_run_id||e?.coder_supervision?.coder_run_id||``).trim()}function j(e){return String(e?.coder_supervision?.tandem_status||e?.status||`unknown`).trim()}function M(e){return String(e?.coder_supervision?.tandem_phase||e?.phase||``).trim()}function ce(e){return Number(e?.coder_supervision?.last_checked_at_ms||e?.updated_at_ms||e?.started_at_ms||0)}function N(e){let t=j(e).toLowerCase();return![`completed`,`failed`,`cancelled`,`canceled`,`terminal`].includes(t)}function le({projects:e,selectedProjectSlug:n,setSelectedProjectSlug:r,selectedProject:i,acaOverview:a,projectTasksQuery:o,refreshTaskPreview:s,taskPreviewRefreshAt:u,coderRuns:d,coderRunsQuery:f,reconcileCoderRun:m,cancelCoderRun:g,visibleRunsCount:ee,activeRunsCount:te,connectedMcpServersCount:_,registeredToolsCount:ne}){let v=d.filter(N);return c(t,{children:c(`div`,{className:`grid gap-4`,children:[c(p,{title:`Project selector`,subtitle:`Choose the repository context before intake`,children:e.length?c(`div`,{className:`grid gap-3`,children:[c(`select`,{className:`tcp-input`,value:n,onChange:e=>r(e.target.value),children:[e.length?null:c(`option`,{value:``,children:`No ACA projects found`}),e.map(e=>c(`option`,{value:e.slug,children:e.slug},e.slug))]}),c(`div`,{className:`rounded-2xl border border-white/10 bg-black/20 p-4`,children:[c(`div`,{className:`text-sm font-semibold`,children:i?.slug||`No project selected`}),c(`div`,{className:`tcp-subtle mt-1 text-xs`,children:i?.repoUrl||`No repo URL stored`}),c(`div`,{className:`tcp-subtle mt-2 text-xs`,children:[`Task source: `,String(i?.taskSource?.type||`unknown`)]})]})]}):c(h,{text:`Register an ACA project to start using Coder.`})}),c(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-4`,children:[c(T,{label:`Registered projects`,value:e.length,helper:n?`Focused on ${n}`:`No project selected`,tone:e.length?`ok`:`warn`}),c(T,{label:`Coder runs`,value:d.length||ee,helper:v.length||te?`${v.length||te} active`:`Idle`,tone:v.length||te?`warn`:`ok`}),c(T,{label:`Connected MCP servers`,value:_,helper:_?`GitHub available`:`MCP pending`,tone:_?`ok`:`warn`}),c(T,{label:`Registered tools`,value:ne,helper:`Engine tool surface`,tone:ne?`info`:`ghost`})]}),c(`div`,{className:`grid gap-4`,children:[c(p,{title:`Coder runs`,subtitle:`Long-running repository work supervised by ACA`,actions:c(l,{tone:v.length?`warn`:`ok`,children:v.length?`${v.length} active`:`Idle`}),children:f.isLoading?c(`div`,{className:`tcp-subtle text-sm`,children:`Loading coder runs...`}):f.isError?c(`div`,{className:`rounded-2xl border border-red-500/20 bg-red-500/10 p-4 text-sm text-red-200`,children:f.error instanceof Error?f.error.message:`Could not load coder runs.`}):d.length?c(`div`,{className:`grid gap-3`,children:d.map((e,t)=>{let r=se(e)||`coder-run-${t}`,i=A(e),a=M(e),o=String(e?.coder_supervision?.last_error||e?.error||``).trim();return c(`div`,{className:`rounded-2xl border border-white/10 bg-black/20 p-4`,children:[c(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[c(`div`,{className:`min-w-0`,children:[c(`div`,{className:`break-words text-sm font-semibold`,children:D(e?.task_title||e?.title,r)}),c(`div`,{className:`tcp-subtle mt-1 break-words text-xs leading-5`,children:[`ACA run `,r,i?` · Coder ${i}`:``]}),c(`div`,{className:`tcp-subtle mt-1 break-words text-xs leading-5`,children:[D(e?.repo_slug||e?.project_slug||n,`No project`),e?.repo_path?` · ${D(e.repo_path)}`:``]})]}),c(`div`,{className:`flex flex-wrap gap-2`,children:[c(l,{tone:N(e)?`info`:`ok`,children:E(j(e))}),a?c(l,{tone:`ghost`,children:E(a)}):null]})]}),c(`div`,{className:`mt-3 flex flex-wrap items-center justify-between gap-3`,children:[c(`div`,{className:`tcp-subtle text-xs`,children:[`Last checked `,k(ce(e))]}),c(`div`,{className:`flex flex-wrap gap-2`,children:[c(`button`,{type:`button`,className:`tcp-btn h-8 px-3 text-xs`,onClick:()=>m(r),children:`Reconcile`}),c(`button`,{type:`button`,className:`tcp-btn h-8 px-3 text-xs`,onClick:()=>g(r),disabled:!N(e),children:`Cancel`})]})]}),o?c(`div`,{className:`mt-3 rounded-2xl border border-amber-500/20 bg-amber-500/10 p-3 text-xs leading-5 text-amber-100`,children:o}):null]},r)})}):c(h,{text:`No active coder runs. New repository work will appear here while it is supervised.`})}),c(p,{title:`Coder runtime snapshot`,subtitle:`Read-only ACA runtime view the agent can use before intake`,actions:c(l,{tone:a.data?`ok`:`warn`,children:a.data?`Live`:`Loading`}),children:a.isLoading?c(`div`,{className:`tcp-subtle text-sm`,children:`Loading ACA snapshot...`}):a.isError?c(`div`,{className:`rounded-2xl border border-red-500/20 bg-red-500/10 p-4 text-sm text-red-200`,children:a.error instanceof Error?a.error.message:`Could not load ACA snapshot.`}):a.data?.overview?c(`div`,{className:`grid gap-3`,children:[c(`div`,{className:`flex flex-wrap gap-2`,children:[c(l,{tone:a.data.overview.auth?.required?`ok`:`warn`,children:D(a.data.overview.auth?.mode,`bearer_api_key`)}),c(l,{tone:a.data.overview.validation?.ok?`ok`:`warn`,children:a.data.overview.validation?.ok?`Config valid`:`Needs attention`}),c(l,{tone:a.data.overview.engine?.healthy?`ok`:`warn`,children:a.data.overview.engine?.healthy?`Engine healthy`:`Engine issue`}),c(l,{tone:a.data.overview.github_mcp?.connected?`ok`:`warn`,children:a.data.overview.github_mcp?.connected?`GitHub MCP connected`:`GitHub MCP pending`})]}),c(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[c(`div`,{className:`rounded-2xl border border-white/10 bg-black/20 p-4`,children:[c(`div`,{className:`text-xs uppercase tracking-[0.2em] text-slate-400`,children:`Task source`}),c(`div`,{className:`mt-1 text-sm font-semibold`,children:D(a.data.overview.task_source?.type,`unset`)}),c(`div`,{className:`tcp-subtle mt-1 text-xs`,children:a.data.overview.task_source?.owner?`${D(a.data.overview.task_source.owner)} / ${D(a.data.overview.task_source.repo)}`:D(a.data.overview.task_source?.source_name,`No source details`)}),c(`div`,{className:`tcp-subtle mt-1 text-xs`,children:[`Project `,D(a.data.overview.task_source?.project,`n/a`),a.data.overview.task_source?.item?` · Item ${D(a.data.overview.task_source.item)}`:``]})]}),c(`div`,{className:`rounded-2xl border border-white/10 bg-black/20 p-4`,children:[c(`div`,{className:`text-xs uppercase tracking-[0.2em] text-slate-400`,children:`Repository`}),c(`div`,{className:`mt-1 text-sm font-semibold`,children:D(a.data.overview.repository?.slug||a.data.overview.repository?.path,`Unbound`)}),c(`div`,{className:`tcp-subtle mt-1 text-xs`,children:a.data.overview.repository?.path?`Path ${D(a.data.overview.repository.path)}`:`Repository path unavailable`}),c(`div`,{className:`tcp-subtle mt-1 text-xs`,children:[`Branch`,` `,D(a.data.overview.repository?.default_branch,`main`),a.data.overview.repository?.remote_name?` · Remote ${D(a.data.overview.repository.remote_name,`origin`)}`:``]})]}),c(`div`,{className:`rounded-2xl border border-white/10 bg-black/20 p-4`,children:[c(`div`,{className:`text-xs uppercase tracking-[0.2em] text-slate-400`,children:`Engine and GitHub`}),c(`div`,{className:`mt-1 text-sm font-semibold`,children:[D(a.data.overview.engine?.status,`unknown`),` engine`]}),c(`div`,{className:`tcp-subtle mt-1 text-xs`,children:a.data.overview.engine?.base_url?`Engine ${D(a.data.overview.engine.base_url)}`:`Engine URL unavailable`}),c(`div`,{className:`tcp-subtle mt-1 text-xs`,children:[`GitHub MCP `,D(a.data.overview.github_mcp?.scope,`unset`),a.data.overview.github_mcp?.remote_sync?` · Sync ${D(a.data.overview.github_mcp.remote_sync)}`:``]})]}),c(`div`,{className:`rounded-2xl border border-white/10 bg-black/20 p-4`,children:[c(`div`,{className:`text-xs uppercase tracking-[0.2em] text-slate-400`,children:`Latest run`}),c(`div`,{className:`mt-1 text-sm font-semibold`,children:D(a.data.overview.latest_run?.run_id,`No run yet`)}),c(`div`,{className:`tcp-subtle mt-1 text-xs`,children:a.data.overview.latest_run?.status?`Status ${D(a.data.overview.latest_run.status)}`:`No run status`}),c(`div`,{className:`tcp-subtle mt-1 text-xs`,children:a.data.overview.latest_run?.phase?`Phase ${D(a.data.overview.latest_run.phase)}`:`No phase recorded`})]})]}),c(`div`,{className:`rounded-2xl border border-white/10 bg-black/20 p-4`,children:[c(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[c(`div`,{children:[c(`div`,{className:`text-sm font-semibold`,children:`Allowed next actions`}),c(`div`,{className:`tcp-subtle mt-1 text-xs`,children:`The agent should choose from these safe follow-ups.`})]}),c(l,{tone:`ghost`,children:[`Refreshed `,k(a.dataUpdatedAt)]})]}),c(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:O(a.data.overview.allowed_next_actions).length?O(a.data.overview.allowed_next_actions).map(e=>c(l,{tone:`info`,children:E(e)},e)):c(`span`,{className:`tcp-subtle text-xs`,children:`No suggested actions.`})})]}),c(`details`,{className:`rounded-2xl border border-white/10 bg-black/20 p-4`,children:[c(`summary`,{className:`cursor-pointer text-sm font-semibold`,children:`Raw snapshot`}),c(`pre`,{className:`mt-3 max-h-64 overflow-auto whitespace-pre-wrap text-xs leading-6 text-slate-200`,children:JSON.stringify(a.data.overview,null,2)})]})]}):c(h,{text:`No ACA snapshot available yet.`})}),c(p,{title:`Task intake preview`,subtitle:`What ACA will try to pick up next`,children:n?o.isLoading?c(`div`,{className:`tcp-subtle text-sm`,children:`Loading task preview...`}):o.isError?c(`div`,{className:`rounded-2xl border border-red-500/20 bg-red-500/10 p-4 text-sm text-red-200`,children:o.error instanceof Error?o.error.message:`Could not load task preview.`}):o.data?.task?c(`div`,{className:`grid gap-3`,children:[c(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-2xl border border-white/10 bg-black/20 p-3`,children:[c(`div`,{className:`tcp-subtle text-xs`,children:[`GitHub Project intake is refreshed on demand through Tandem's GitHub MCP. It does not auto-update here so we can keep GitHub calls down.`,u?` Last refreshed ${new Date(u).toLocaleTimeString()}.`:``]}),c(`button`,{type:`button`,className:`tcp-btn tcp-btn-secondary`,onClick:s,disabled:o.isFetching,children:o.isFetching?`Refreshing...`:`Refresh from GitHub`})]}),c(`div`,{className:`rounded-2xl border border-white/10 bg-black/20 p-4`,children:[c(`div`,{className:`text-sm font-semibold`,children:String(o.data.task.title||`Untitled task`)}),c(`div`,{className:`tcp-subtle mt-1 text-xs`,children:[String(o.data.source_type||`unknown`),o.data.board_path?` · ${String(o.data.board_path)}`:``]}),c(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[c(l,{tone:o.data.eligible?`ok`:`warn`,children:o.data.eligible?`Eligible`:`Not eligible`}),c(l,{tone:`info`,children:[`ACA intake lane`,` `,E(String(o.data.task.lane||`ready`))]}),o.data.task?.source?o.data.task.source.status?c(l,{tone:`ghost`,children:[`GitHub status `,String(o.data.task.source.status)]}):c(l,{tone:`ghost`,children:`GitHub status unavailable from MCP`}):null]})]}),o.data?.board_summary?c(`div`,{className:`flex flex-wrap gap-2`,children:Object.entries(o.data.board_summary).map(([e,t])=>c(l,{tone:`ghost`,children:[e,`: `,String(t)]},e))}):null,String(o.data?.warning||``).trim()?c(`div`,{className:`rounded-2xl border border-amber-500/30 bg-amber-500/10 p-3 text-sm text-amber-100`,children:String(o.data.warning)}):null]}):c(h,{text:`No task preview available yet.`}):c(h,{text:`Select a project to preview task intake.`})})]})]})})}var P=`tcp.coding-planner.session.v1`,F=`tcp.coding-planner.composer.v1`;function I(e){return String(e||``).trim()}function L(e,t,n=``){let r=I(t)||`default`,i=I(n);return i?`${e}:${r}:${i}`:`${e}:${r}`}function R(e){return L(P,e)}function ue(e){try{return localStorage.getItem(R(e))||``}catch{return``}}function de(e,t){try{let n=R(e),r=I(t);r?localStorage.setItem(n,r):localStorage.removeItem(n)}catch{}}function fe(e){de(e,``)}function z(e,t){return L(F,e,t)}function pe(e,t){try{return sessionStorage.getItem(z(e,t))||``}catch{return``}}function me(e,t,n){try{let r=z(e,t),i=I(n);i?sessionStorage.setItem(r,i):sessionStorage.removeItem(r)}catch{}}function he(e,t){me(e,t,``)}function ge({sessions:e,selectedSessionId:t,onSelectSession:n,onCreateSession:r,onRenameSession:i,onDuplicateSession:a,onDeleteSession:o,className:s=``}){return c(`section`,{className:`flex min-h-0 flex-col rounded-2xl border border-white/10 bg-black/20 p-3 ${s}`.trim(),children:[c(`div`,{className:`flex items-start justify-between gap-3`,children:[c(`div`,{className:`min-w-0`,children:[c(`div`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:`Planner sessions`}),c(`div`,{className:`tcp-subtle text-xs`,children:`Draft threads only. Model work starts when you generate or revise a plan.`})]}),c(`button`,{type:`button`,className:`tcp-btn shrink-0`,onClick:r,children:[c(`i`,{"data-lucide":`plus`}),`New plan`]})]}),c(`div`,{className:`mt-3 min-h-0 flex-1 space-y-2 overflow-auto pr-1`,children:e.length?e.map(e=>c(`article`,{className:`rounded-xl border p-2 transition ${e.id===t?`border-sky-500/40 bg-sky-500/10`:`border-white/10 bg-black/10 hover:border-white/20 hover:bg-black/20`}`,children:[c(`button`,{type:`button`,className:`block w-full text-left`,onClick:()=>n(e.id),title:e.title,children:[c(`div`,{className:`flex items-start justify-between gap-2`,children:[c(`div`,{className:`min-w-0`,children:[c(`div`,{className:`truncate text-sm font-medium text-slate-100`,children:e.title||`Untitled plan`}),c(`div`,{className:`mt-1 flex flex-wrap items-center gap-2 text-[11px] text-slate-500`,children:[c(`span`,{children:e.updatedAtLabel}),e.revisionCount?c(`span`,{children:[e.revisionCount,` rev`]}):null]})]}),c(l,{tone:b(e.status),className:`shrink-0`,children:v(e.status)})]}),c(`p`,{className:`mt-2 line-clamp-2 text-xs text-slate-400`,children:e.previewText})]}),c(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[c(`button`,{type:`button`,className:`tcp-btn h-7 px-2 text-[11px]`,onClick:()=>i(e.id),title:`Rename session`,children:c(`i`,{"data-lucide":`pencil`})}),c(`button`,{type:`button`,className:`tcp-btn h-7 px-2 text-[11px]`,onClick:()=>a(e.id),title:`Duplicate session`,children:c(`i`,{"data-lucide":`copy`})}),c(`button`,{type:`button`,className:`tcp-btn h-7 px-2 text-[11px]`,onClick:()=>o(e.id),title:`Delete session`,children:c(`i`,{"data-lucide":`trash-2`})})]})]},e.id)):c(`div`,{className:`rounded-xl border border-dashed border-white/10 bg-black/10 p-3`,children:[c(`div`,{className:`text-sm text-slate-100`,children:`No planner sessions yet.`}),c(`div`,{className:`mt-1 text-xs text-slate-500`,children:`Start a new plan when you are ready to create the first draft thread.`}),c(`button`,{type:`button`,className:`tcp-btn mt-3`,onClick:r,children:[c(`i`,{"data-lucide":`plus`}),`Start new plan`]})]})})]})}function _e(e){let{rootRef:t,session:n,planner:r,status:i,provider:a,actions:o,dialogs:s}=e,{plannerSessions:u,selectedSessionId:f,sessionsOpen:m,plannerSessionSummaries:g,activePlannerSessionSummary:_,plannerTitle:ne}=n,{goal:v,workspaceRoot:re,notes:y,plannerInput:b,plannerProvider:ie,plannerModel:x,planPreview:S,planningConversation:T,planningChangeSummary:E,plannerError:D,plannerDiagnostics:O,publishing:k,resetting:se,clarification:A,saveStatus:j,publishStatus:M,lastSavedAtMs:ce,publishedAtMs:N,publishedTasks:le,plannerChatMessages:P,plannerInputPlaceholder:F,plannerStatusTitle:I,plannerStatusDetail:L,exportMarkdown:R,plannerFallbackReason:ue,hasPlannerResponse:de,displayTasks:fe}=r,{isGitHubProject:z,taskSourceType:pe,engineHealthy:me,plannerCanUseLlm:he,hasExplicitPlannerOverride:_e,hasBasePlannerModel:B,plannerSelectionMatchesWorkspaceDefault:ve,resolvedWorkspaceRoot:V,canPublishToGitHub:ye,plannerTimedOut:be,clarificationNeeded:xe,planIsFallbackOnly:Se,isPlanning:H}=i,{providerOptions:Ce,providerStatus:we,selectedProjectSlug:U,selectedProject:Te,githubProjectBoardSnapshot:W,connectedMcpServers:Ee}=a,De=O?.task_budget||O?.taskBudget||O?.decomposition_observation?.task_budget||O?.decompositionObservation?.taskBudget||O?.observation?.task_budget||O?.observation?.taskBudget||null,Oe=String(De?.status||``).trim()===`rejected`,{activatePlannerSession:ke,createNewPlannerSession:Ae,renamePlannerSession:G,duplicatePlannerSession:je,deletePlannerSession:Me,setSessionsOpen:K,previewMutation:Ne,reviseMutation:q,resetMutation:Pe,patchActivePlannerSession:Fe,setPlannerInput:Ie,setGoal:J,setWorkspaceRoot:Le,setNotes:Re,setPlannerProvider:ze,setPlannerModel:Be,setPlannerError:Ve,setPlannerDiagnostics:He,setClarification:Ue,setSaveStatus:We,publishTasks:Ge,plannerOperatorPreferences:Ke,plannerSessionTitle:qe}=o,{renameSessionDialog:Je,deleteSessionDialog:Ye,confirmRenamePlannerSession:Xe,confirmDeletePlannerSession:Ze,setRenameSessionDialog:Y,setDeleteSessionDialog:Qe}=s;return c(`div`,{ref:t,className:`grid gap-4 xl:grid-cols-[320px_minmax(0,1fr)]`,children:[c(d,{open:m,title:`Planner sessions`,onClose:()=>K(!1),children:c(ge,{sessions:g,selectedSessionId:f,onSelectSession:ke,onCreateSession:()=>void Ae(),onRenameSession:e=>void G(e),onDuplicateSession:e=>void je(e),onDeleteSession:e=>void Me(e)})}),c(`div`,{className:`hidden min-h-0 xl:block xl:self-start xl:sticky xl:top-4`,children:c(ge,{sessions:g,selectedSessionId:f,onSelectSession:ke,onCreateSession:()=>void Ae(),onRenameSession:e=>void G(e),onDuplicateSession:e=>void je(e),onDeleteSession:e=>void Me(e)})}),c(`div`,{className:`grid gap-4 min-w-0`,children:[c(p,{title:ne,subtitle:`Use the built-in scrum-master planner to turn a goal into reviewable implementation tasks.`,actions:c(`button`,{type:`button`,className:`tcp-btn xl:hidden`,onClick:()=>K(!0),children:[c(`i`,{"data-lucide":`history`}),`Sessions`]}),children:c(`div`,{className:`grid gap-4`,children:[c(`div`,{className:`rounded-2xl border border-emerald-500/20 bg-emerald-500/5 p-4`,children:[c(`div`,{className:`flex flex-wrap items-center gap-2`,children:[c(l,{tone:`ok`,children:`scrum-master`}),c(l,{tone:z?`info`:`warn`,children:pe||`unknown task source`}),c(l,{tone:me?`ok`:`warn`,children:me?`Engine ready`:`Engine unavailable`})]}),c(`p`,{className:`tcp-subtle mt-3 text-sm`,children:`Describe the work once, let the planner break it into repo-aware tasks, then revise it with comments before publishing. GitHub Project approval creates issues and moves them into the board. Local kanban approval saves a durable export bundle.`})]}),c(`div`,{className:`grid gap-3 xl:grid-cols-2`,children:[c(`div`,{className:`rounded-2xl border border-white/10 bg-black/20 p-4 xl:col-span-2`,children:[c(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[c(`div`,{children:[c(`div`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:`Planner model`}),c(`div`,{className:`tcp-subtle text-xs`,children:`Leave this on workspace default to use the base provider and model, or pick an explicit planner override for richer revisions.`})]}),c(l,{tone:he?`ok`:`warn`,children:_e?`Planner override active`:B?`Workspace default active`:`No planner model configured`})]}),c(te,{providerLabel:`Planner provider`,modelLabel:`Planner model`,draft:{provider:ie,model:x},providers:Ce,onChange:({provider:e,model:t})=>{ze(e),Be(t)},inheritLabel:`Workspace default`,disabled:H}),c(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[c(`button`,{type:`button`,className:`tcp-btn`,onClick:()=>{ze(``),Be(``)},disabled:H||!ie&&!x,children:`Use workspace default`}),c(`button`,{type:`button`,className:`tcp-btn`,onClick:()=>{ze(we.defaultProvider||``),Be(we.defaultModel||``)},disabled:H||!B||ve,children:`Restore workspace model`}),c(`button`,{type:`button`,className:`tcp-btn`,onClick:()=>{Ve(``),He(null),We(``)},disabled:H||!D&&!O,children:`Clear diagnostics`})]}),c(`div`,{className:`mt-2 text-xs text-slate-500`,children:[`Base model:`,` `,B?`${String(we.defaultProvider||``)} / ${String(we.defaultModel||``)}`:`not configured`]})]}),c(`label`,{className:`grid gap-2 xl:col-span-2`,children:[c(`span`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:`Workspace root`}),c(`input`,{className:`tcp-input text-sm`,value:re,onInput:e=>Le(e.target.value),placeholder:`/absolute/path/to/the/repo/checkout`,disabled:H}),V?c(`span`,{className:`tcp-subtle text-xs`,children:[`Resolved from the selected project: `,V]}):null,c(`span`,{className:`tcp-subtle text-xs`,children:`The planner uses this checkout to inspect files and glob directories for the selected project.`})]}),c(`label`,{className:`grid gap-2 xl:col-span-2`,children:c(`span`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:`Planner chat`})}),c(`div`,{className:`xl:col-span-2 rounded-2xl border border-white/10 bg-black/20 p-4`,children:c(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[c(`div`,{className:`min-w-0`,children:[c(`div`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:`Active session`}),c(`div`,{className:`truncate text-lg font-semibold text-slate-100`,children:_?.title||`Untitled plan`}),c(`div`,{className:`mt-1 flex flex-wrap gap-2 text-xs text-slate-500`,children:[c(`span`,{children:_?.projectSlug||U||`unbound`}),c(`span`,{children:`·`}),c(`span`,{children:_?.updatedAtLabel||(ce?new Date(ce).toLocaleString():`unknown`)}),c(`span`,{children:`·`}),c(`span`,{children:[_?.revisionCount||0,` rev`]})]})]}),c(`div`,{className:`flex flex-wrap items-center gap-2`,children:[c(l,{tone:_?.statusTone||`ghost`,children:_?.statusLabel||`Draft`}),c(`button`,{type:`button`,className:`tcp-btn h-8 px-2 text-xs`,onClick:()=>f?void G(f):void 0,disabled:!f||H,children:[c(`i`,{"data-lucide":`pencil`}),`Rename`]}),c(`button`,{type:`button`,className:`tcp-btn h-8 px-2 text-xs`,onClick:()=>f?void je(f):void 0,disabled:!f||H,children:[c(`i`,{"data-lucide":`copy`}),`Duplicate`]}),c(`button`,{type:`button`,className:`tcp-btn h-8 px-2 text-xs`,onClick:()=>f?void Me(f):void 0,disabled:!f||H,children:[c(`i`,{"data-lucide":`trash-2`}),`Delete`]}),c(`button`,{type:`button`,className:`tcp-btn h-8 px-2 text-xs xl:hidden`,onClick:()=>K(!0),children:[c(`i`,{"data-lucide":`history`}),`Sessions`]})]})]})}),de?null:c(`div`,{className:`xl:col-span-2 rounded-2xl border border-dashed border-white/10 bg-black/10 p-4`,children:[c(`div`,{className:`text-sm font-medium text-slate-100`,children:`Start a plan with a short prompt`}),c(`div`,{className:`mt-1 text-xs text-slate-500`,children:`Use one of the prompts below, then start a new plan when you are ready to create a draft thread.`}),c(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[`Plan the implementation for this bug fix.`,`Break this feature into backend, frontend, and verification tasks.`,`Review this idea and suggest an implementation plan.`,`Refine the plan to reduce risk and unknowns.`].map(e=>c(`button`,{type:`button`,className:`tcp-btn text-sm`,onClick:()=>{Ie(e)},disabled:H,children:e},e))}),c(`div`,{className:`mt-3`,children:c(`button`,{type:`button`,className:`tcp-btn-primary`,onClick:Ae,disabled:H,children:[c(`i`,{"data-lucide":`plus`}),`Start new plan`]})})]})]}),c(C,{messages:P,emptyText:f?`No plan yet. Use a starter prompt or describe the work.`:`No planner session selected. Start a new plan to create a draft thread.`,inputValue:b,inputPlaceholder:F,sendLabel:S?`Send to planner`:`Generate plan`,onInputChange:Ie,onSend:()=>void(S?q(b):Ne(b)),sendDisabled:H||!f||!String(b||``).trim(),inputDisabled:H||!f,statusTitle:I,statusDetail:H?L:``,questionTitle:`Planner question`,questionText:A.status===`waiting`?A.question:``,quickReplies:A.status===`waiting`?A.options:[],onQuickReply:e=>void q(e.label),questionHint:`Reply in the planner chat box below or choose a suggested answer.`,autoFocusKey:f}),c(`div`,{className:`flex flex-wrap gap-2`,children:[S?c(`button`,{type:`button`,className:`tcp-btn`,onClick:()=>void Ne(b||v),disabled:H,children:[c(`i`,{"data-lucide":`refresh-cw`}),`Regenerate plan`]}):null,c(`button`,{type:`button`,className:`tcp-btn`,onClick:()=>void Pe(),disabled:se||H,children:[c(`i`,{"data-lucide":`rotate-ccw`}),se?`Resetting…`:`Reset plan`]}),c(`button`,{type:`button`,className:`tcp-btn`,onClick:()=>{Ie(``),Re(``),Ve(``),He(null),Ue({status:`none`}),We(``)},disabled:H||!b&&!y&&!D&&!O,children:[c(`i`,{"data-lucide":`eraser`}),`Clear composer and warnings`]}),c(`button`,{type:`button`,className:`tcp-btn`,onClick:()=>{Fe({title:qe({goal:v,plan:S,fallbackTime:ce||Date.now()}),workspace_root:re,goal:v,notes:y,planner_provider:ie,planner_model:x,plan_source:`coding_task_planning`,allowed_mcp_servers:Ee,operator_preferences:Ke({plannerProvider:ie,plannerModel:x,defaultProvider:we.defaultProvider,defaultModel:we.defaultModel,selectedProjectSlug:U,taskSourceType:pe,selectedProject:Te,goal:v,notes:y}),current_plan_id:S?.plan_id,draft:S?{initial_plan:S,current_plan:S,plan_revision:Number(S.plan_revision||1)||1,conversation:T||{conversation_id:`wfchat-${f}`,plan_id:S.plan_id,created_at_ms:Date.now(),updated_at_ms:Date.now(),messages:[]},planner_diagnostics:O,last_success_materialization:null}:void 0,published_at_ms:N||void 0,published_tasks:le.length?le:void 0}),We(`Planner session synced.`)},disabled:H,children:[c(`i`,{"data-lucide":`save`}),`Sync session`]}),c(`button`,{type:`button`,className:`tcp-btn`,onClick:async()=>{try{await navigator.clipboard.writeText(R)}catch{}},disabled:H,children:[c(`i`,{"data-lucide":`copy`}),`Copy markdown`]})]}),D&&!xe?c(`div`,{className:`rounded-2xl p-3 text-sm ${be||xe?`border border-amber-500/40 bg-amber-950/30 text-amber-100`:`border border-red-500/40 bg-red-950/30 text-red-200`}`,children:[be?c(`div`,{className:`mb-1 text-xs uppercase tracking-wide text-amber-300`,children:`Planner timed out`}):xe?c(`div`,{className:`mb-1 text-xs uppercase tracking-wide text-amber-300`,children:`Planner question`}):null,D]}):null,O||E.length?c(oe,{plannerDiagnostics:{...O,summary:O?.summary||O?.detail||(ue===`no_planner_model`?`The planner fell back because no usable planner model reached the backend for this generated plan.`:ue===`clarification_needed`?`The planner needs one more answer before it can generate a richer repo-aware plan.`:``)},teachingLibrary:null,planningChangeSummary:E}):null,j||M?c(`div`,{className:`rounded-2xl border border-white/10 bg-black/20 p-3 text-sm text-slate-300`,children:[j?c(`div`,{children:j}):null,M?c(`div`,{className:`mt-1`,children:M}):null,ce?c(`div`,{className:`mt-1 text-xs text-slate-500`,children:[`Last saved `,new Date(ce).toLocaleString()]}):null]}):null]})}),de?c(`div`,{className:`grid gap-4`,children:[c(p,{title:`Plan details`,subtitle:`Planner metadata and markdown stay visible here`,children:S?c(`div`,{className:`grid gap-3`,children:[c(`div`,{className:`grid gap-2 text-sm text-slate-300`,children:[c(`div`,{children:[c(`span`,{className:`tcp-subtle`,children:`Title:`}),` `,String(S?.title||``)||`Untitled plan`]}),c(`div`,{children:[c(`span`,{className:`tcp-subtle`,children:`Confidence:`}),` `,String(S?.confidence||``)||`unknown`]}),c(`div`,{children:[c(`span`,{className:`tcp-subtle`,children:`Plan source:`}),` `,String(S?.plan_source||S?.planSource||``)||`coding_task_planning`]})]}),typeof S?.description==`string`&&S.description.trim()?c(`div`,{className:`rounded-2xl border border-white/10 bg-black/20 p-3`,children:[c(`div`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:`Planner markdown`}),c(`div`,{className:`tcp-markdown tcp-markdown-ai mt-2 text-sm`,dangerouslySetInnerHTML:{__html:ee(String(S.description||``))}})]}):null,c(`div`,{className:`grid gap-2`,children:[c(`button`,{type:`button`,className:`tcp-btn-primary`,disabled:k||H||!v.trim()||!re.trim()||xe||be||Se||Oe,onClick:()=>void Ge(),children:[c(`i`,{"data-lucide":z&&ye?`badge-check`:`arrow-up-circle`}),k?`Publishing…`:z&&ye?`Approve and publish to GitHub Project`:`Save local task bundle`]}),c(`div`,{className:`text-xs text-slate-500`,children:xe?`Answer the planner's question before approving or publishing tasks.`:be?`Retry the planner revision or switch models before approving tasks.`:Oe?`Regenerate the plan so Tandem can compact it into the generated 8-task budget before publishing.`:Se?`Wait for a real task breakdown before approving or publishing tasks.`:z&&ye?`This will create GitHub issues, add each issue to the selected project board, and move it into Ready when the board metadata is available.`:`Local kanban mode saves the plan locally so you can apply it to the board file or keep it as a durable draft.`})]})]}):c(h,{text:`No plan has been generated yet.`})}),c(p,{title:`Planned tasks`,subtitle:`Review the generated backlog before publishing`,children:fe.length?c(`div`,{className:`grid gap-3`,children:fe.map((e,t)=>c(`div`,{className:`rounded-2xl border border-white/10 bg-black/20 p-4`,children:[c(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[c(`div`,{className:`min-w-0`,children:[c(`div`,{className:`text-sm font-semibold text-slate-100`,children:e.title}),c(`div`,{className:`mt-1 text-xs text-slate-500`,children:[e.kind||`task`,e.dependsOn.length?` · depends on ${e.dependsOn.join(`, `)}`:``]})]}),c(l,{tone:`info`,children:[`Step `,t+1]})]}),c(`div`,{className:`mt-3 grid gap-2 text-sm text-slate-300`,children:[c(`div`,{children:[c(`span`,{className:`tcp-subtle`,children:`Summary:`}),` `,e.objective]}),e.outputContract?c(`div`,{children:[c(`span`,{className:`tcp-subtle`,children:`Expected result:`}),` `,e.outputContract]}):null,e.inputRefs.length?c(`div`,{className:`text-xs text-slate-500`,children:[c(`span`,{className:`tcp-subtle`,children:`Inputs:`}),` `,e.inputRefs.map(e=>`${e.alias} <- ${e.fromStepId}`).join(`, `)]}):null]})]},`${e.id}-${t}`))}):S?c(h,{text:xe?`Answer the planner's question to generate a real task breakdown.`:be?`The last revision timed out, so the planner kept the current fallback draft.`:`The planner returned a plan, but no usable step list was available.`}):c(h,{text:`Generate a plan to see task drafts here.`})})]}):null,c(w,{open:!!Je,title:`Rename planner session`,message:c(`span`,{children:[`Choose a new name for`,` `,c(`strong`,{children:Je?.sessionId&&u.find(e=>e.id===Je.sessionId)?.title||`this session`}),`.`]}),label:`Session name`,value:Je?.value||``,placeholder:`Untitled plan`,confirmLabel:`Rename`,confirmIcon:`square-pen`,confirmDisabled:!String(Je?.value||``).trim(),onCancel:()=>Y(null),onChange:e=>Y(t=>t&&{...t,value:e}),onConfirm:()=>void Xe()}),c(ae,{open:!!Ye,title:`Delete session`,message:c(`span`,{children:[`This will permanently remove`,` `,c(`strong`,{children:Ye?.title||`this session`}),` and all its messages.`]}),confirmLabel:`Delete session`,confirmIcon:`trash-2`,confirmTone:`danger`,onCancel:()=>Qe(null),onConfirm:()=>void Ze()})]})]})}function B(e,t){return Array.isArray(e)?e:Array.isArray(e?.[t])?e[t]:[]}function ve(e){return(Array.isArray(e)?e:Array.isArray(e?.servers)?e.servers:e&&typeof e==`object`?Object.entries(e).map(([e,t])=>({name:e,...t})):[]).map(e=>({name:String(e?.name||``).trim(),connected:!!e?.connected,enabled:e?.enabled!==!1,transport:String(e?.transport||``).trim(),lastError:String(e?.last_error||e?.lastError||``).trim()})).filter(e=>e.name).sort((e,t)=>e.name.localeCompare(t.name))}function V(e){return(Array.isArray(e)?e:Array.isArray(e?.tools)?e.tools:[]).map(e=>typeof e==`string`?e:String(e?.namespaced_name||e?.namespacedName||e?.id||``).trim()).filter(Boolean)}function ye(e){let t=Array.isArray(e)?e:e&&typeof e==`object`?Object.entries(e).map(([e,t])=>({slug:e,...t})):[],n=new Map;for(let e of t){let t=e?.task_source||e?.taskSource||{},r=String(t?.type||``).trim(),i=e?.repo||{},a=String(e?.repo_url||e?.repoUrl||i?.clone_url||i?.cloneUrl||``).trim(),o=r===`github_project`&&String(t?.owner||``).trim()&&String(t?.repo||``).trim()&&String(t?.project||``).trim()?`github:${String(t.owner).trim().toLowerCase()}/${String(t.repo).trim().toLowerCase()}#${String(t.project).trim()}`:a?`repo:${a.toLowerCase()}`:`slug:${e.slug}`,s=n.get(o);if(!s){n.set(o,e);continue}let c=s?.repo||{},l=String(s?.repo_url||s?.repoUrl||c?.clone_url||c?.cloneUrl||``).trim(),u=(s.implicit?0:10)+ +!!l;(e.implicit?0:10)+ +!!a>u&&n.set(o,e)}return Array.from(n.values()).map(e=>{let t=e?.repo||{},n=e?.task_source||e?.taskSource||{};return{slug:String(e?.slug||``).trim(),name:String(e?.name||e?.display_name||e?.displayName||e?.slug||``).trim(),repoUrl:String(e?.repo_url||e?.repoUrl||t?.clone_url||t?.cloneUrl||``).trim(),repoPath:String(t?.path||e?.repo_path||e?.repoPath||``).trim(),worktreeRoot:String(t?.worktree_root||e?.worktree_root||e?.worktreeRoot||``).trim(),defaultBranch:String(t?.default_branch||e?.default_branch||e?.defaultBranch||`main`).trim(),remoteName:String(t?.remote_name||e?.remote_name||e?.remoteName||`origin`).trim(),credentialFile:String(t?.credential_file||e?.credential_file||e?.credentialFile||``).trim(),taskSource:n,implicit:e?.implicit===!0}}).filter(e=>e.slug).sort((e,t)=>e.implicit===t.implicit?e.slug.localeCompare(t.slug):e.implicit?1:-1)}function be(e){return{items:Array.isArray(e?.items)?e.items.map((e,t)=>({id:String(e?.id||e?.project_item_id||`item-${t}`).trim(),projectItemId:String(e?.project_item_id||e?.projectItemId||``).trim(),title:String(e?.title||`Untitled item`).trim(),statusKey:String(e?.status_key||e?.statusKey||`unknown`).trim(),statusName:String(e?.status_name||e?.statusName||`Unknown`).trim(),issueNumber:e?.issue_number||e?.issueNumber||null,issueUrl:String(e?.issue_url||e?.issueUrl||``).trim(),repoName:String(e?.repo_name||e?.repoName||``).trim(),actionable:e?.actionable===!0,selector:String(e?.project_item_id||e?.projectItemId||e?.issue_number||e?.issueNumber||e?.id||``).trim()})).filter(e=>e.id):[],source:String(e?.source||``).trim(),warning:String(e?.warning||``).trim(),isStale:e?.is_stale===!0,lastSyncedAtMs:Number(e?.last_synced_at_ms||e?.lastSyncedAtMs||0)}}function xe(e,t){return String(e?.run_id||e?.runId||e?.id||`run-${t}`).trim()}function Se(e){return String(e?.title||e?.summary||e?.run_id||e?.runId||`Untitled run`).trim()}function H(e){let t=Number(e?.updated_at_ms||e?.created_at_ms||e?.snapshot?.updated_at_ms||e?.snapshot?.created_at_ms||0);return Number.isFinite(t)?t:0}function Ce(e){return String(e?.status||e?.snapshot?.status||e?.status?.run?.status||`unknown`).trim().toLowerCase()}function we(e){return String(e?.phase?.name||e?.snapshot?.phase?.name||e?.status?.phase?.name||``).trim().toLowerCase()}function U(e){return String(e||`unknown`).replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}var Te=1800*1e3,W=15*1e3;function Ee(e){return e?.is_running===!0||e?.snapshot?.is_running===!0}function De(e){let t=Ce(e);if([`completed`,`done`,`failed`,`cancelled`,`blocked`,`archived`].includes(t))return!1;if(Ee(e))return!0;let n=H(e);return n?Date.now()-n<Te:!1}function Oe(e,t){let n=e?.blackboard?.task||e?.snapshot?.blackboard?.task||{},r=n?.source||{},i=n?.repo||{};return String(r?.issue_url||r?.url||r?.item_url||r?.project_item_id||r?.card_id||n?.task_id||`${i?.slug||e?.project_slug||`project`}:${Se(e)}:${t}`).trim()}function ke(e){return String(e?.issueUrl||e?.projectItemId||e?.id||``).trim()}function Ae(e){return String(e||``).trim().toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``)}function G(e){let t=Ae(e);return t===`todos`?`TODOS`:t===`todo`?`Todo`:t.split(`_`).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function je(e){let t=Ae(e?.statusKey),n=Ae(e?.statusName),r=t&&t!==`unknown`?t:n;return!e?.selector||[`blocked`,`cancelled`,`closed`,`complete`,`completed`,`done`,`failed`,`in_progress`,`in_review`,`on_hold`,`stalled`].includes(r)?!1:e?.actionable===!0||[`ready`,`backlog`,`todo`,`todos`].includes(r)}function Me(e){let t=Number(e?.status_field_id||e?.statusFieldId||0),n=e?.status_option_map||e?.statusOptionMap||{},r=new Map;Object.entries(n||{}).forEach(([e,t])=>{let n=Ae(e),i=String(t||``).trim();n&&i&&r.set(n,i)});let i=Array.isArray(e?.columns)?e.columns:[];for(let e of[`todos`,`todo`,`to_do`,`ready`,`backlog`]){let n=r.get(e);if(!n)continue;let a=i.find(t=>Ae(t?.key)===e||Ae(t?.name)===e);return{statusFieldId:t,optionId:n,label:String(a?.name||``).trim()||G(e)}}return{statusFieldId:t,optionId:``,label:``}}function K(e){let t=new Map;return e.forEach((e,n)=>{let r=Oe(e,n),i=t.get(r);(!i||H(e)>=H(i))&&t.set(r,e)}),Array.from(t.values()).sort((e,t)=>H(t)-H(e))}function Ne(e){let t=String(e||``).trim();if(!t)return null;let n=e=>{let t=e.replace(/^\/+/,``).replace(/\.git$/i,``).split(`/`).map(e=>e.trim()).filter(Boolean);if(t.length<2)return null;let[n,r]=t;return!n||!r?null:{owner:n,repo:r,slug:`${n}/${r}`}},r=t.match(/^git@github\.com:([^/]+)\/(.+?)(?:\.git)?$/i);if(r?.[1]&&r?.[2])return n(`${r[1]}/${r[2]}`);try{let e=new URL(t);return e.hostname.toLowerCase()===`github.com`?n(e.pathname):null}catch{return n(t)}}function q(e,{prompt:t,path:n,repoRef:r,projectNumber:i}){return e===`manual`?{type:`manual`,prompt:t.trim()}:e===`kanban_board`?{type:`kanban_board`,path:n.trim()}:e===`local_backlog`?{type:`local_backlog`,path:n.trim()}:{type:`github_project`,owner:r?.owner||``,repo:r?.repo||``,project:i.trim()}}function Pe(e){let t=String(e||``).trim().replace(/\\/g,`/`);if(!t)return!0;if(t.startsWith(`/`)||/^[A-Za-z]:/.test(t))return!1;let n=t.split(`/`).filter(Boolean);return n.length>0&&!n.some(e=>e===`.`||e===`..`)}function Fe(e){try{let t=JSON.parse(String(e||`{}`));return t&&typeof t==`object`?t:null}catch{return null}}var Ie=`tandem.intent-planner.codingTaskHandoff.v1`;function J(e){return String(e||``).trim()}function Le(e){let t=J(e).toLowerCase();return t.includes(`workflow_plan_not_found`)||t.includes(`workflow plan not found`)}function Re(e){let t=J(e?.taskSource?.repo);if(t)return`/workspace/repos/${t.split(`/`).pop()||t}`;let n=J(e?.repoUrl);if(!n)return``;try{let e=new URL(n).pathname.split(`/`).filter(Boolean),t=(e[e.length-1]||``).replace(/\.git$/,``);return t?`/workspace/repos/${t}`:``}catch{let e=n.match(/\/([^/]+?)(?:\.git)?(?:\?.*)?$/);return e?.[1]?`/workspace/repos/${e[1]}`:``}}function ze(e){let t=J(e.plan?.title);if(t)return t;let n=J(e.goal);return n?n.length>48?`${n.slice(0,47).trimEnd()}…`:n:e.existingTitle?e.existingTitle:`Plan ${new Date(e.fallbackTime||Date.now()).toLocaleTimeString()}`}function Be(e){return{id:J(e?.session_id||e?.sessionId),title:J(e?.title||`Untitled plan`),updatedAtMs:Number(e?.updated_at_ms||e?.updatedAtMs||0)||0,projectSlug:J(e?.project_slug||e?.projectSlug),workspaceRoot:J(e?.workspace_root||e?.workspaceRoot),currentPlanId:J(e?.current_plan_id||e?.currentPlanId),goal:J(e?.goal||``),plannerProvider:J(e?.planner_provider||e?.plannerProvider),plannerModel:J(e?.planner_model||e?.plannerModel),publishedAtMs:Number(e?.published_at_ms||e?.publishedAtMs||0)||null,draft:e?.draft||null}}function Ve(e){return{id:J(e?.session_id||e?.sessionId),title:J(e?.title||`Untitled plan`),updatedAtMs:Number(e?.updated_at_ms||e?.updatedAtMs||0)||0,projectSlug:J(e?.project_slug||e?.projectSlug),workspaceRoot:J(e?.workspace_root||e?.workspaceRoot),currentPlanId:J(e?.current_plan_id||e?.currentPlanId),goal:J(e?.goal||``),plannerProvider:J(e?.planner_provider||e?.plannerProvider),plannerModel:J(e?.planner_model||e?.plannerModel),publishedAtMs:Number(e?.published_at_ms||e?.publishedAtMs||0)||null,draft:e?.draft||null}}function He(e,t){return x({session:{...e,...t?.session||{}},draft:t?.draft||e.draft||null,clarificationState:t?.clarification||{status:`none`}})}function Ue(){return{session:null,draft:null,clarification:{status:`none`},planPreview:null,planningConversation:null,planningChangeSummary:[],plannerDiagnostics:null,publishedTasks:[]}}function We(e){return(Array.isArray(e?.steps)?e.steps:[]).map((e,t)=>{let n=J(e?.step_id||e?.stepId||`step-${t+1}`),r=J(e?.objective),i=J(e?.kind||`task`),a=Array.isArray(e?.depends_on||e?.dependsOn)?(e?.depends_on||e?.dependsOn).map(e=>J(e)).filter(Boolean):[],o=Array.isArray(e?.input_refs||e?.inputRefs)?(e?.input_refs||e?.inputRefs).map(e=>({fromStepId:J(e?.from_step_id||e?.fromStepId),alias:J(e?.alias)})):[],s=J(e?.output_contract?.kind||e?.outputContract?.kind||``);return{id:n,title:r||`${i} ${t+1}`,objective:r||`${i} ${t+1}`,kind:i,dependsOn:a,inputRefs:o,outputContract:s}}).filter(e=>e.title||e.objective)}function Ge(e){let t=[e?.output],n=e?.metadata?.result;if(n){t.push(n);let e=n?.content;if(Array.isArray(e))for(let n of e)n&&typeof n==`object`&&(t.push(n?.text),t.push(n))}for(let e of t){if(e==null)continue;if(typeof e==`number`&&Number.isFinite(e))return Number(e);if(typeof e==`object`){let t=e,n=t.issue_number??t.issueNumber??t.number??t.issue?.number??t.data?.number;if(typeof n==`number`&&Number.isFinite(n))return Number(n);if(typeof n==`string`&&n.trim()){let e=Number.parseInt(n,10);if(Number.isFinite(e))return e}continue}let t=String(e||``).trim();if(t)try{let e=JSON.parse(t);if(e&&typeof e==`object`){let t=e.issue_number??e.issueNumber??e.number??e.data?.number;if(typeof t==`number`&&Number.isFinite(t))return Number(t);if(typeof t==`string`&&t.trim()){let e=Number.parseInt(t,10);if(Number.isFinite(e))return e}}}catch{let e=t.match(/"issue_number"\s*:\s*(\d+)/i)||t.match(/"issueNumber"\s*:\s*(\d+)/i)||t.match(/"number"\s*:\s*(\d+)/i)||t.match(/#(\d+)/);if(e){let t=Number.parseInt(e[1],10);if(Number.isFinite(t))return t}}}return null}function Ke(e){let t=[e?.output],n=e?.metadata?.result;if(n){t.push(n);let e=n?.content;if(Array.isArray(e))for(let n of e)n&&typeof n==`object`&&(t.push(n?.text),t.push(n))}for(let e of t){if(e==null)continue;if(typeof e==`number`&&Number.isFinite(e))return Number(e);if(typeof e==`object`){let t=e,n=t.project_item_id??t.projectItemId??t.item_id??t.itemId??t.id;if(typeof n==`number`&&Number.isFinite(n))return Number(n);if(typeof n==`string`&&n.trim()){let e=Number.parseInt(n,10);if(Number.isFinite(e))return e}continue}let t=String(e||``).trim();if(t)try{let e=JSON.parse(t);if(e&&typeof e==`object`){let t=e.project_item_id??e.projectItemId??e.item_id??e.itemId??e.id;if(typeof t==`number`&&Number.isFinite(t))return Number(t);if(typeof t==`string`&&t.trim()){let e=Number.parseInt(t,10);if(Number.isFinite(e))return e}}}catch{let e=t.match(/"project_item_id"\s*:\s*(\d+)/i)||t.match(/"projectItemId"\s*:\s*(\d+)/i)||t.match(/"item_id"\s*:\s*(\d+)/i)||t.match(/"itemId"\s*:\s*(\d+)/i)||t.match(/"id"\s*:\s*(\d+)/i);if(e){let t=Number.parseInt(e[1],10);if(Number.isFinite(t))return t}}}return null}function qe(e,t,n,r){let i=J(e?.description),a=t.inputRefs.length?t.inputRefs.map(e=>`- ${e.alias||`ref`} <- ${e.fromStepId}`).join(`
2
- `):`- None`,o=t.dependsOn.length?t.dependsOn.map(e=>`- ${e}`).join(`
3
- `):`- None`,s=J(r.selectedProject?.repoUrl),c=r.selectedProject?.taskSource||{},l=r.taskSourceType===`github_project`?`GitHub Project ${J(c.owner)}/${J(c.repo)} #${J(c.project)}`:r.taskSourceType===`kanban_board`||r.taskSourceType===`local_backlog`?J(c.path)||`local task source`:`manual`;return[`# ${t.title}`,``,`## Summary`,t.objective||`Planned repository task.`,``,`## Context`,`- Project: ${r.projectSlug||`unbound`}`,`- Task source: ${l}`,`- Workspace root: ${r.workspaceRoot||`engine workspace root`}`,s?`- Repo URL: ${s}`:``,`- Planner persona: scrum-master`,`- Planner provider: ${r.plannerProvider||`workspace default`}`,`- Planner model: ${r.plannerModel||`workspace default`}`,`- Step kind: ${t.kind||`task`}`,``,`## Expected Results`,i||`Follow the goal and preserve existing behavior unless the plan says otherwise.`,``,`## Implementation Notes`,`- Depends on:\n${o}`,`- Input refs:\n${a}`,t.outputContract?`- Output contract: ${t.outputContract}`:`- Output contract: not specified`,``,`## Verification`,`- Validate the touched files in the workspace.`,`- Run the smallest relevant build or test command for the repo area.`,`- Confirm the user-visible behavior described by the plan.`,``,`## Rework Notes`,r.notes?r.notes:`None`,``,`## Planner Snapshot`,"```json",JSON.stringify({task_number:n+1,task_title:t.title,task_kind:t.kind,step_id:t.id,workspace_root:r.workspaceRoot,project_slug:r.projectSlug,planner_provider:r.plannerProvider,planner_model:r.plannerModel},null,2),"```"].filter(Boolean).join(`
4
- `)}function Je(e,t,n){return[`# Task Plan`,``,`- Project: ${n.projectSlug||`unbound`}`,`- Workspace root: ${n.workspaceRoot||`engine workspace root`}`,n.goal?`- Goal: ${n.goal}`:`- Goal: (none)`,`- Planner provider: ${n.plannerProvider||`workspace default`}`,`- Planner model: ${n.plannerModel||`workspace default`}`,n.notes?`- Rework notes: ${n.notes}`:``,e?.title?`- Plan title: ${e.title}`:``,``,`## Tasks`,...t.flatMap((e,t)=>[`### ${t+1}. ${e.title}`,``,e.objective||``,``,e.outputContract?`- Expected result: ${e.outputContract}`:``,e.dependsOn.length?`- Depends on: ${e.dependsOn.join(`, `)}`:``,``]),``,`## Raw Plan`,"```json",JSON.stringify(e||{},null,2),"```"].filter(Boolean).join(`
5
- `)}function Ye(e){let t=J(e.defaultProvider),n=J(e.defaultModel),r=J(e.plannerProvider),i=J(e.plannerModel),a={};return t&&n&&(a.model_provider=t,a.model_id=n),r&&i&&(a.role_models={planner:{provider_id:r,model_id:i}}),Object.assign(a,S(e.goal)),Object.assign(a,y(e.goal)),a}function Xe({client:t,api:l,toast:u,selectedProjectSlug:d,selectedProject:f,githubProjectBoardSnapshot:p,taskSourceType:h,workspaceRootSeed:g,connectedMcpServers:ee,engineHealthy:te,providerStatus:_}){let ne=r(null),v=o(),[y,b]=i([]),[x,S]=i({}),[C,w]=i(``),[ae,oe]=i(!1),[T,E]=i(``),[D,O]=i(``),[k,se]=i(``),[A,j]=i(``),[M,ce]=i(``),[N,le]=i(``),[P,F]=i(null),[I,L]=i(null),[R,z]=i([]),[ge,B]=i(``),[ve,V]=i(null),[ye,be]=i(!1),[xe,Se]=i(!1),[H,Ce]=i(!1),[we,U]=i(`idle`),[Te,W]=i({status:`none`}),[Ee,De]=i(null),[Oe,ke]=i(null),[Ae,G]=i(``),[je,K]=i(``),[Ne,q]=i(null),[Pe,Fe]=i(null),[Xe,Ze]=i([]),Y=r(``),Qe=s({queryKey:[`coding-workflows`,`control-panel-config`,d],queryFn:()=>l(`/api/control-panel/config`)}),$e=s({queryKey:[`coding-workflows`,`providers`,`catalog`],queryFn:()=>t.providers.catalog().catch(()=>({all:[]})),refetchInterval:3e4}),et=s({queryKey:[`coding-workflows`,`providers`,`config`],queryFn:()=>t.providers.config().catch(()=>({})),refetchInterval:3e4}),tt=n(()=>We(P),[P]),nt=String(h||``).trim()===`github_project`,rt=n(()=>ie({providerCatalog:$e.data,providerConfig:et.data,defaultProvider:_.defaultProvider,defaultModel:_.defaultModel}),[_.defaultModel,_.defaultProvider,$e.data,et.data]),it=J(Qe.data?.config?.repository?.path||Qe.data?.config?.repository?.worktree_root||``),at=n(()=>nt?it||Re(f)||g||``:String(h||``).trim()===`kanban_board`||String(h||``).trim()===`local_backlog`?J(f?.taskSource?.path||g||``):g||``,[it,nt,f,h,g]),X=nt&&!!J(f?.taskSource?.owner)&&!!J(f?.taskSource?.repo)&&Number.isFinite(Number(f?.taskSource?.project||0)),ot=!!(J(_.defaultProvider)&&J(_.defaultModel)),st=!!(J(M)&&J(N)),ct=J(M)===J(_.defaultProvider)&&J(N)===J(_.defaultModel),lt=ot||st,ut=we===`generating`,dt=we===`clarifying`,ft=we!==`idle`,pt=J(ve?.fallback_reason||ve?.fallbackReason),mt=pt===`clarification_needed`,ht=J(Array.isArray(I?.messages)?[...I.messages].reverse().find(e=>J(e?.role).toLowerCase()===`assistant`)?.text:``),gt=/timed out before completion/i.test(J(ge))||/timed out before completion/i.test(ht),_t=n(()=>re(I,!1),[I]),Z=ft?ut?`Generating task plan…`:dt?`Waiting for planner…`:`Revising task plan…`:``,vt=dt?`The planner is thinking. You'll be able to answer its question shortly.`:`The request is running against the engine now. Repo-aware planning can take a bit longer while the model inspects files and drafts the task breakdown.`,yt=P?`Send a follow-up message or revision request to the planner. (Enter to send, Shift+Enter newline)`:`Describe the outcome you want and send to planner. (Enter to send, Shift+Enter newline)`,bt=tt.length===1&&J(tt[0]?.id)===`execute_goal`&&(!!pt||/fallback draft/i.test(J(P?.description))),xt=bt?[]:tt;e(()=>{Y.current=C},[C]);let St=n(()=>{let e=y.find(e=>e.id===C);if(!e)return null;let t=x[e.id];return He(e,{...t||{session:null,draft:null,clarification:{status:`none`},planPreview:null,planningConversation:null,planningChangeSummary:[],plannerDiagnostics:null,publishedTasks:[]},clarification:C===e.id?Te:t?.clarification||{status:`none`}})},[Te,x,y,C]),Ct=n(()=>y.map(e=>He(e,x[e.id])),[x,y]),wt=a(e=>{let t=Y.current;t&&t!==e&&me(d,t,A),w(e),oe(!1)},[A,d]),Tt=a(e=>{let t=Y.current;if(!t)return;let{session:n,...r}=e;S(e=>({...e,[t]:{...Ue(),...e[t]||{},session:n?{...e[t]?.session||{},...n||{}}:e[t]?.session||null,...r}}))},[]),Q=e=>{if(e){E(e.goal),O(e.workspaceRoot||at||g||``),se(e.notes),ce(e.plannerProvider||_.defaultProvider||``),le(e.plannerModel||_.defaultModel||``),F(e.plan),L(e.conversation),z(e.changeSummary||[]),B(e.plannerError||``),V(e.plannerDiagnostics||null),K(e.publishedAtMs?`Last published ${new Date(e.publishedAtMs).toLocaleString()}`:``),Fe(e.publishedAtMs||null),q(e.updatedAtMs||e.publishedAtMs||null),Ze(e.publishedTasks||[]),W({status:`none`});return}E(``),j(``),O(at||g||``),se(``),ce(_.defaultProvider||``),le(_.defaultModel||``),F(null),L(null),z([]),B(``),V(null),W({status:`none`}),K(``),q(null),Fe(null),Ze([]),j(``)},Et=a(e=>{if(!e)return null;let t=e?.draft||null,n=t?.current_plan||t?.currentPlan||null;return{goal:J(e?.goal||n?.title||``),workspaceRoot:J(e?.workspace_root||e?.workspaceRoot||``),notes:J(e?.notes||``),plannerProvider:J(e?.planner_provider||e?.plannerProvider||``),plannerModel:J(e?.planner_model||e?.plannerModel||``),plan:n,conversation:t?.conversation||null,changeSummary:[],plannerError:``,plannerDiagnostics:t?.planner_diagnostics||t?.plannerDiagnostics||null,publishedAtMs:Number(e?.published_at_ms||e?.publishedAtMs||0)||null,updatedAtMs:Number(e?.updated_at_ms||e?.updatedAtMs||0)||Date.now(),publishedTasks:Array.isArray(e?.published_tasks||e?.publishedTasks)?e?.published_tasks||e?.publishedTasks:[]}},[at,_.defaultModel,_.defaultProvider,g]),Dt=a(async()=>{if(!t?.workflowPlannerSessions?.list)return[];let e=await t.workflowPlannerSessions.list({project_slug:d}),n=Array.isArray(e?.sessions)?e.sessions:[];return b(n.map(Be).filter(e=>e.id).sort((e,t)=>t.updatedAtMs-e.updatedAtMs)),n},[t?.workflowPlannerSessions?.list,d]),$=a(async e=>{if(!t?.workflowPlannerSessions?.get||!e)return;let n=(await t.workflowPlannerSessions.get(e))?.session||null;if(!n)return;let r=Et(n);Q(r),j(pe(d,e)),K(n.published_at_ms?`Last published ${new Date(n.published_at_ms).toLocaleString()}`:``),Fe(Number(n.published_at_ms||0)||null),q(Number(n.updated_at_ms||0)||null),S(t=>({...t,[e]:{session:n,draft:r,clarification:t[e]?.clarification||{status:`none`},planPreview:t[e]?.planPreview||null,planningConversation:t[e]?.planningConversation||null,planningChangeSummary:t[e]?.planningChangeSummary||[],plannerDiagnostics:t[e]?.plannerDiagnostics||null,publishedTasks:t[e]?.publishedTasks||r?.publishedTasks||[]}})),b(e=>{let t=e.filter(e=>e.id!==n.session_id);return t.unshift(Ve(n)),t.sort((e,t)=>t.updatedAtMs-e.updatedAtMs)})},[t?.workflowPlannerSessions?.get,Et,d]),Ot=a(async e=>{if(!(!C||!t?.workflowPlannerSessions?.patch))try{let n=e,r=(await t.workflowPlannerSessions.patch(C,n))?.session;r?.session_id&&(b(e=>{let t=e.filter(e=>e.id!==r.session_id);return t.unshift(Ve(r)),t.sort((e,t)=>t.updatedAtMs-e.updatedAtMs)}),S(e=>({...e,[r.session_id]:{...e[r.session_id]||{session:null,draft:null,clarification:{status:`none`},planPreview:null,planningConversation:null,planningChangeSummary:[],plannerDiagnostics:null,publishedTasks:[]},session:r,draft:n.draft?n.draft:e[r.session_id]?.draft||null,publishedTasks:Array.isArray(n.published_tasks||n.publishedTasks)?n.published_tasks||n.publishedTasks:e[r.session_id]?.publishedTasks||[]}})))}catch{}},[t?.workflowPlannerSessions?.patch,C]);e(()=>{let e=!1;return Ce(!0),(async()=>{try{let e=await Dt(),t=ue(d),n=Y.current,r=!!n&&e.some(e=>J(e?.session_id||e?.sessionId)===n),i=!!t&&e.some(e=>J(e?.session_id||e?.sessionId)===t),a=r?n:i?t:J(e[0]?.session_id||e[0]?.sessionId||``);a&&a!==n?w(a):a||(w(``),fe(d))}catch{}finally{e||Ce(!1)}})(),()=>{e=!0}},[t?.workflowPlannerSessions,Dt,d]),e(()=>{if(!C){Q(null),j(``);return}de(d,C);let e=!1;return Ce(!0),(async()=>{try{if(await $(C),e)return}catch{e||Q(null)}finally{e||Ce(!1)}})(),()=>{e=!0}},[$,d,C]),e(()=>{if(!C)return;let e=!1;return Ce(!0),(async()=>{try{await $(C)}catch{Q(null)}finally{e||Ce(!1)}})(),()=>{e=!0}},[C,$,at,g,_.defaultProvider,_.defaultModel]),e(()=>{if(!(typeof sessionStorage>`u`))try{let e=sessionStorage.getItem(Ie);if(!e)return;sessionStorage.removeItem(Ie);let n=JSON.parse(e);if(!t?.workflowPlannerSessions?.create)return;(async()=>{let e=(await t.workflowPlannerSessions.create({project_slug:d,title:ze({goal:n?.goal,plan:n?.plan,fallbackTime:Date.now()}),workspace_root:J(n?.workspaceRoot||n?.workspace_root||g),goal:J(n?.goal),notes:J(n?.notes),planner_provider:J(n?.plannerProvider||n?.planner_provider),planner_model:J(n?.plannerModel||n?.planner_model),plan_source:`coding_task_planning`,plan:n?.plan??null,conversation:n?.conversation??null,planner_diagnostics:n?.plannerDiagnostics??null,plan_revision:n?.plan?.plan_revision??1,last_success_materialization:n?.lastSuccessMaterialization??null,allowed_mcp_servers:Array.isArray(n?.allowedMcpServers)?n.allowedMcpServers:ee,operator_preferences:n?.operatorPreferences??null}))?.session;e?.session_id&&(b(t=>[Ve(e),...t.filter(t=>t.id!==e.session_id)].sort((e,t)=>t.updatedAtMs-e.updatedAtMs)),w(e.session_id),Q(Et(e)),K(`Planner handoff loaded from Planner page.`))})()}catch{}},[t?.workflowPlannerSessions?.create,ee,Et,d,g]),e(()=>{!D&&at&&O(at)},[at,D]),e(()=>{B(``),V(null),G(``)},[M,N]),e(()=>{if(H||!C)return;let e=P||null,t=J(e?.plan_id||``),n=e&&e.plan_id?{initial_plan:e,current_plan:e,plan_revision:Number(e.plan_revision||1)||1,conversation:I||{conversation_id:`wfchat-${C}`,plan_id:e.plan_id,created_at_ms:Date.now(),updated_at_ms:Date.now(),messages:[]},planner_diagnostics:ve,last_success_materialization:null}:void 0;Ot({title:ze({goal:T,plan:e,fallbackTime:Ne||Date.now()}),workspace_root:D,goal:T,notes:k,planner_provider:M,planner_model:N,plan_source:`coding_task_planning`,allowed_mcp_servers:ee,operator_preferences:Ye({plannerProvider:M,plannerModel:N,defaultProvider:_.defaultProvider,defaultModel:_.defaultModel,selectedProjectSlug:d,taskSourceType:h,selectedProject:f,goal:T,notes:k}),current_plan_id:t||void 0,draft:n,published_at_ms:Pe||void 0,published_tasks:Xe.length?Xe:void 0})},[ee,T,Ne,H,k,P,ve,ge,R,I,Xe,Pe,d,C,h,N,M,Ot,D,_.defaultProvider,_.defaultModel,f]);let kt=async()=>{if(t?.workflowPlannerSessions?.create)try{Y.current&&me(d,Y.current,A);let e=Y.current?``:A,n=(await t.workflowPlannerSessions.create({project_slug:d,title:ze({goal:``,fallbackTime:Date.now()}),workspace_root:at||g||D||``,goal:``,notes:``,planner_provider:M,planner_model:N,plan_source:`coding_task_planning`,allowed_mcp_servers:ee,operator_preferences:Ye({plannerProvider:M,plannerModel:N,defaultProvider:_.defaultProvider,defaultModel:_.defaultModel,selectedProjectSlug:d,taskSourceType:h,selectedProject:f,goal:``,notes:``})}))?.session;n?.session_id&&(b(e=>[Ve(n),...e.filter(e=>e.id!==n.session_id)].sort((e,t)=>t.updatedAtMs-e.updatedAtMs)),he(d,n.session_id),wt(n.session_id),Q(Et(n)),j(e||pe(d,n.session_id)),u(`ok`,`Started a new planner session.`))}catch(e){u(`err`,e instanceof Error?e.message:String(e))}},At=async e=>{let n=y.find(t=>t.id===e);!n||!t?.workflowPlannerSessions?.patch||De({sessionId:e,value:n.title||`Untitled plan`})},jt=async()=>{let e=Ee;if(!e||!t?.workflowPlannerSessions?.patch)return;let n=J(e.value);if(!n){u(`warn`,`Enter a session name.`);return}try{let r=(await t.workflowPlannerSessions.patch(e.sessionId,{title:n}))?.session;r?.session_id&&(b(e=>e.filter(e=>e.id!==r.session_id).concat(Ve(r)).sort((e,t)=>t.updatedAtMs-e.updatedAtMs)),S(e=>({...e,[r.session_id]:{...e[r.session_id]||{session:null,draft:null,clarification:{status:`none`},planPreview:null,planningConversation:null,planningChangeSummary:[],plannerDiagnostics:null,publishedTasks:[]},session:r}})),Y.current===e.sessionId&&wt(r.session_id)),De(null),u(`ok`,`Planner session renamed.`)}catch(e){u(`err`,e instanceof Error?e.message:String(e))}},Mt=async e=>{let n=y.find(t=>t.id===e);if(!(!n||!t?.workflowPlannerSessions?.duplicate))try{let r=(await t.workflowPlannerSessions.duplicate(e,{title:`Copy of ${n.title||`Untitled plan`}`}))?.session;r?.session_id&&(b(e=>e.filter(e=>e.id!==r.session_id).concat(Ve(r)).sort((e,t)=>t.updatedAtMs-e.updatedAtMs)),he(d,r.session_id),wt(r.session_id)),u(`ok`,`Planner session duplicated.`)}catch(e){u(`err`,e instanceof Error?e.message:String(e))}},Nt=async e=>{let t=y.find(t=>t.id===e);t&&ke({sessionId:e,title:t.title||`Untitled plan`})},Pt=async()=>{let e=Oe;if(e)try{await t.workflowPlannerSessions.delete(e.sessionId);let n=y.filter(t=>t.id!==e.sessionId);if(b(n),S(t=>{let n={...t};return delete n[e.sessionId],n}),he(d,e.sessionId),Y.current===e.sessionId){let e=n[0]?.id||``;e?wt(e):kt()}ke(null),u(`ok`,`Planner session deleted.`)}catch(e){u(`err`,e instanceof Error?e.message:String(e))}},Ft=async e=>{let n=J(e??A??T),r=J(D);if(!n){u(`warn`,`Describe the goal you want to turn into tasks.`);return}if(!r){u(`warn`,`Workspace root is required so the planner can inspect the repo.`);return}if(!r.startsWith(`/`)){u(`warn`,`Workspace root must be an absolute path.`);return}if(!C){u(`warn`,`Start a planner session first.`);return}if(!t?.workflowPlannerSessions?.start){u(`err`,`This control panel build is missing workflow planner support.`);return}G(``),B(``),V(null),E(n);let i=`idle`;U(`generating`);try{let e=await t.workflowPlannerSessions.start(C,{prompt:[`Create a Tandem workflow plan for the repo at ${r} to implement this goal: ${n}`,`Use small ordered implementation steps.`,`Prefer step objectives that mention likely files, modules, or repo areas to inspect or change.`,`If the target or desired outcome is ambiguous, return a clarification question instead of guessing.`,J(f?.repoUrl)?`Repo URL: ${J(f?.repoUrl)}`:``,d?`Selected project: ${d}`:``,k?`User feedback / revision notes:\n${k}`:``].filter(Boolean).join(`
6
- `),plan_source:`coding_task_planning`,workspace_root:r,allowed_mcp_servers:ee,operator_preferences:Ye({plannerProvider:M,plannerModel:N,defaultProvider:_.defaultProvider,defaultModel:_.defaultModel,selectedProjectSlug:d,taskSourceType:h,selectedProject:f,goal:n,notes:k})});F(e?.plan||null),L(e?.conversation||null),z([]),V(e?.planner_diagnostics||e?.plannerDiagnostics||null);let a=typeof e?.clarifier?.question==`string`?String(e.clarifier.question):``,o=Array.isArray(e?.clarifier?.options)?e.clarifier.options.map(e=>({id:String(e?.id||``),label:String(e?.label||``)})).filter(e=>e.id&&e.label):[];B(a),a&&o.length>0?(W({status:`waiting`,question:a,options:o}),i=`clarifying`):W({status:`none`}),q(Date.now()),Ze([]),G(`Plan synced to session.`),j(``),he(d,C),Tt({session:e?.session||null,draft:e?.session?Et(e.session):null,clarification:a&&o.length>0?{status:`waiting`,question:a,options:o}:{status:`none`},planPreview:e?.plan||null,planningConversation:e?.conversation||null,planningChangeSummary:[],plannerDiagnostics:e?.planner_diagnostics||e?.plannerDiagnostics||null,publishedTasks:[]}),u(`ok`,typeof e?.clarifier?.question==`string`?`Planner needs clarification before it can draft richer tasks.`:`Planner generated a task draft.`)}catch(e){let t=e instanceof Error?e.message:String(e);if(Le(t)){F(null),L(null),z([]),B(``),V(null),W({status:`none`}),u(`info`,`The previous planner session expired. Starting a fresh planning chat.`),await Ft(n);return}B(t),W({status:`none`}),G(t.includes(`Request timed out after`)?`The panel timed out before the planner finished. The engine may still be working, so wait a moment before retrying.`:``),u(`err`,t)}finally{U(i)}},It=async e=>{if(!t?.workflowPlannerSessions?.message||!C){u(`warn`,`Generate a plan first before revising it.`);return}let n=J(e??A??k);if(!n){u(`warn`,`Add a message for the planner first.`);return}G(``),B(``),V(null),se(n);let r=`idle`;U(`revising`);try{let e=await t.workflowPlannerSessions.message(C,{message:mt?n:[`Revise the workflow plan for repo ${J(D)}.`,`Goal: ${J(T)}`,d?`Selected project: ${d}`:``,`Keep the workflow valid and machine-parseable.`,`Prefer concrete repo-aware implementation steps.`,`If the request is ambiguous, return a clarification question.`,``,`Revision notes:`,n].filter(Boolean).join(`
7
- `)});F(e?.plan||null),L(e?.conversation||null),z(Array.isArray(e?.change_summary)?e.change_summary.map(e=>J(e)).filter(Boolean):[]),V(e?.planner_diagnostics||e?.plannerDiagnostics||null);let i=typeof e?.clarifier?.question==`string`?String(e.clarifier.question):``,a=Array.isArray(e?.clarifier?.options)?e.clarifier.options.map(e=>({id:String(e?.id||``),label:String(e?.label||``)})).filter(e=>e.id&&e.label):[];B(i),i&&a.length>0?(W({status:`waiting`,question:i,options:a}),r=`clarifying`):W({status:`none`}),q(Date.now()),Ze([]),G(`Revision synced to session.`),j(``),he(d,C),Tt({session:e?.session||null,draft:e?.session?Et(e.session):null,clarification:i&&a.length>0?{status:`waiting`,question:i,options:a}:{status:`none`},planPreview:e?.plan||null,planningConversation:e?.conversation||null,planningChangeSummary:Array.isArray(e?.change_summary)?e.change_summary.map(e=>J(e)).filter(Boolean):[],plannerDiagnostics:e?.planner_diagnostics||e?.plannerDiagnostics||null,publishedTasks:[]}),u(`ok`,`Plan revised.`)}catch(e){let t=e instanceof Error?e.message:String(e);if(Le(t)){F(null),L(null),z([]),B(``),V(null),W({status:`none`}),u(`info`,`The previous planner session expired. Starting a fresh planning chat.`),await Ft(n);return}B(t),W({status:`none`}),G(t.includes(`Request timed out after`)?`The panel timed out before the planner revision finished. The engine may still be working, so wait a moment before retrying.`:``),u(`err`,t)}finally{U(r)}},Lt=async()=>{if(!t?.workflowPlannerSessions?.reset||!C){E(``),j(``),se(``),F(null),L(null),z([]),B(``),V(null),W({status:`none`}),K(``),Fe(null),q(null),G(`Draft cleared.`);return}Se(!0);try{let e=await t.workflowPlannerSessions.reset(C);F(e?.plan||null),L(e?.conversation||null),j(``),z([]),B(``),V(e?.planner_diagnostics||e?.plannerDiagnostics||null),Ze([]),K(``),Fe(null),G(`Plan reset.`),q(Date.now()),he(d,C),Tt({session:e?.session?{...e.session,published_at_ms:null}:null,draft:e?.session?Et(e.session):null,clarification:{status:`none`},planPreview:e?.plan||null,planningConversation:e?.conversation||null,planningChangeSummary:[],plannerDiagnostics:e?.planner_diagnostics||e?.plannerDiagnostics||null,publishedTasks:[]}),u(`ok`,`Plan reset.`)}catch(e){let t=e instanceof Error?e.message:String(e);if(Le(t)){E(``),j(``),se(``),F(null),L(null),z([]),B(``),V(null),W({status:`none`}),K(``),Fe(null),q(null),G(`The expired planner session was cleared locally.`),u(`info`,`The previous planner session had expired, so the local draft was reset.`);return}B(t),u(`err`,t)}finally{Se(!1)}},Rt=async()=>{let e=tt.length?tt:T.trim()?[{id:`task-1`,title:T.trim(),objective:T.trim(),kind:`task`,dependsOn:[],inputRefs:[],outputContract:``}]:[];if(!e.length){u(`warn`,`Generate a plan before publishing tasks.`);return}be(!0),K(``);try{if(nt&&X){let n=f?.taskSource||{},r=J(n.owner),i=J(n.repo),a=Number(n.project),o=p,s=Me(o);if((!s.statusFieldId||!s.optionId)&&J(d))try{o=await l(`/api/aca/projects/${encodeURIComponent(d)}/board?refresh=true`),s=Me(o)}catch{}let c=[];for(let n=0;n<e.length;n+=1){let o=e[n],l=qe(P,o,n,{goal:T,workspaceRoot:D,projectSlug:d,taskSourceType:h,selectedProject:f,notes:k,plannerProvider:M,plannerModel:N}),u=Ge(await t.executeTool(`mcp.github.issue_write`,{method:`create`,owner:r,repo:i,title:o.title,body:l,labels:[`tandem`,`planned-task`,`todo`]}));if(!u)throw Error(`Created GitHub issue for "${o.title}" but could not determine the issue number from the engine response.`);let p=Ke(await t.executeTool(`mcp.github.projects_write`,{method:`add_project_item`,owner:r,project_number:a,item_type:`issue`,item_owner:r,item_repo:i,issue_number:u}));p&&s.statusFieldId&&s.optionId&&await t.executeTool(`mcp.github.projects_write`,{method:`update_project_item`,owner:r,project_number:a,item_id:p,updated_field:{id:s.statusFieldId,value:s.optionId}}),c.push({title:o.title,issueNumber:u,issueUrl:`https://github.com/${r}/${i}/issues/${u}`,publishedAtMs:Date.now()})}let m=Date.now();Ze(c),K(`Published ${c.length} GitHub tasks${s.label?` into ${s.label}`:``}.`),Fe(m),q(m),Tt({session:{published_at_ms:m,published_tasks:c},publishedTasks:c}),await Promise.all([v.invalidateQueries({queryKey:[`coding-workflows`,`aca-project-board`,d]}),v.invalidateQueries({queryKey:[`coding-workflows`,`aca-project-tasks`,d]}),v.invalidateQueries({queryKey:[`coding-workflows`,`aca-projects`]})]),u(`ok`,`Published ${c.length} task(s) to the GitHub Project.`)}else{let t=Je(P,e,{goal:T,workspaceRoot:D,projectSlug:d,notes:k,plannerProvider:M,plannerModel:N}),n=Date.now();Ze(e.map(e=>({title:e.title,publishedAtMs:n}))),K(`Saved a local task bundle. Use the exported markdown to update your kanban file.`),Fe(n),q(n),Tt({session:{published_at_ms:n,published_tasks:e},publishedTasks:e.map(e=>({title:e.title,publishedAtMs:n}))}),navigator.clipboard?.writeText&&await navigator.clipboard.writeText(t),u(`ok`,`Saved a local task bundle. The plan markdown has been copied to your clipboard.`)}}catch(e){let t=e instanceof Error?e.message:String(e);K(t),u(`err`,t)}finally{be(!1)}},zt=n(()=>Je(P,tt,{goal:T,workspaceRoot:D,projectSlug:d,notes:k,plannerProvider:M,plannerModel:N}),[T,k,P,tt,N,M,d,D]),Bt=nt?`GitHub Project task planning`:`Local kanban task planning`,Vt=!!P||!!ve||R.length>0||Array.isArray(I?.messages)&&I.messages.length>0;return e(()=>{ne.current&&m(ne.current)},[Te.status,xt.length,Vt,ft,ge,P,R.length,I,Ct.length,C,ae,je,Ae]),c(_e,{rootRef:ne,session:{plannerSessions:y,selectedSessionId:C,sessionsOpen:ae,plannerSessionSummaries:Ct,activePlannerSessionSummary:St,plannerTitle:Bt},planner:{goal:T,workspaceRoot:D,notes:k,plannerInput:A,plannerProvider:M,plannerModel:N,planPreview:P,planningConversation:I,planningChangeSummary:R,plannerError:ge,plannerDiagnostics:ve,publishing:ye,resetting:xe,clarification:Te,saveStatus:Ae,publishStatus:je,lastSavedAtMs:Ne,publishedAtMs:Pe,publishedTasks:Xe,plannerChatMessages:_t,plannerInputPlaceholder:yt,plannerStatusTitle:Z,plannerStatusDetail:vt,exportMarkdown:zt,plannerFallbackReason:pt,hasPlannerResponse:Vt,displayTasks:xt},status:{isGitHubProject:nt,taskSourceType:h,engineHealthy:te,plannerCanUseLlm:lt,hasExplicitPlannerOverride:st,hasBasePlannerModel:ot,plannerSelectionMatchesWorkspaceDefault:ct,resolvedWorkspaceRoot:at,canPublishToGitHub:X,plannerTimedOut:gt,clarificationNeeded:mt,planIsFallbackOnly:bt,isPlanning:ft},provider:{providerOptions:rt,providerStatus:_,selectedProjectSlug:d,selectedProject:f,githubProjectBoardSnapshot:p,connectedMcpServers:ee},actions:{activatePlannerSession:wt,createNewPlannerSession:kt,renamePlannerSession:At,duplicatePlannerSession:Mt,deletePlannerSession:Nt,setSessionsOpen:oe,previewMutation:Ft,reviseMutation:It,resetMutation:Lt,patchActivePlannerSession:Ot,setPlannerInput:j,setGoal:E,setWorkspaceRoot:O,setNotes:se,setPlannerProvider:ce,setPlannerModel:le,setPlannerError:B,setPlannerDiagnostics:V,setClarification:W,setSaveStatus:G,publishTasks:Rt,plannerOperatorPreferences:Ye,plannerSessionTitle:ze},dialogs:{renameSessionDialog:Ee,deleteSessionDialog:Oe,confirmRenamePlannerSession:jt,confirmDeletePlannerSession:Pt,setRenameSessionDialog:De,setDeleteSessionDialog:ke}})}function Ze({api:r,client:a,toast:d,providerStatus:m,navigate:ee}){let v=o(),[re,y]=i(`overview`),[b,x]=i(``),[S,C]=i(``),[w,ae]=i(``),[oe,T]=i(``),[E,D]=i(``),[O,k]=i(``),[se,A]=i(``),[j,M]=i(``),[ce,N]=i(`main`),[P,F]=i(`origin`),[I,L]=i(``),[R,ue]=i(`github_project`),[de,fe]=i(``),[z,pe]=i(``),[me,he]=i(``),[ge,_e]=i(``),[H,Te]=i(``),[Ee,Ae]=i(``),[G,Me]=i(!1),[Ie,J]=i(!1),[Le,Re]=i(``),[ze,Be]=i(``),[Ve,He]=i(null),[Ue,We]=i(null),[Ge,Ke]=i(!1),[qe,Je]=i(null),[Ye,Ze]=i(!1),[Y,Qe]=i(!1),[$e,et]=i([]),[tt,nt]=i({}),[rt,it]=i(!1),at=g(),X=at.data?.aca_integration===!0,ot=at.data?.engine_healthy===!0,st=at.data?.hosted_managed===!0,ct=X||ot,lt=s({queryKey:[`coding-workflows`,`health`],queryFn:()=>r(`/api/system/health`),refetchInterval:15e3}),ut=s({queryKey:[`coding-workflows`,`aca-health`],queryFn:()=>r(`/api/aca/health`),enabled:X}),dt=s({queryKey:[`coding-workflows`,`aca-overview`],queryFn:()=>r(`/api/aca/overview`),enabled:X,refetchInterval:X?3e4:!1}),ft=s({queryKey:[`coding-workflows`,`aca-projects`],queryFn:()=>r(`/api/aca/projects`),enabled:X}),pt=s({queryKey:[`coding-workflows`,`aca-workspace-guide`],queryFn:()=>r(`/api/aca/workspace/guide`),enabled:X}),mt=s({queryKey:[`coding-workflows`,`aca-runs`],queryFn:()=>r(`/api/aca/runs`),enabled:X}),ht=s({queryKey:[`coding-workflows`,`coder-runs`],queryFn:()=>r(`/api/aca/operator/coder-runs`),enabled:X,refetchInterval:X?15e3:!1}),gt=s({queryKey:[`coding-workflows`,`aca-project-tasks`,b],queryFn:()=>r(`/api/aca/projects/${encodeURIComponent(b)}/tasks`),enabled:X&&!!b}),_t=s({queryKey:[`coding-workflows`,`aca-project-board`,b],queryFn:()=>r(`/api/aca/projects/${encodeURIComponent(b)}/board`),enabled:X&&!!b&&ye(ft.data).some(e=>e.slug===b&&String(e?.taskSource?.type||``).trim()===`github_project`),refetchInterval:X&&b&&ye(ft.data).some(e=>e.slug===b&&String(e?.taskSource?.type||``).trim()===`github_project`)?12e4:!1}),Z=s({queryKey:[`coding-workflows`,`aca-run-detail`,S],queryFn:()=>r(`/api/aca/runs/${encodeURIComponent(S)}`),enabled:X&&!!S}),vt=s({queryKey:[`coding-workflows`,`aca-run-logs`,S],queryFn:()=>r(`/api/aca/runs/${encodeURIComponent(S)}/logs`),enabled:X&&!!S}),yt=s({queryKey:[`coding-workflows`,`aca-run-log-tail`,S,w],queryFn:()=>r(`/api/aca/runs/${encodeURIComponent(S)}/logs/${encodeURIComponent(w)}?tail=120`),enabled:X&&!!S&&!!w}),bt=s({queryKey:[`coding-workflows`,`mcp-servers`],queryFn:()=>a.mcp.list().catch(()=>({})),refetchInterval:ct?1e4:!1,enabled:ct}),xt=s({queryKey:[`coding-workflows`,`mcp-tools`],queryFn:()=>a.mcp.listTools().catch(()=>[]),refetchInterval:ct?15e3:!1,enabled:ct}),St=s({queryKey:[`coding-workflows`,`providers`,`catalog`],queryFn:()=>a.providers.catalog().catch(()=>({all:[]})),refetchInterval:ct?3e4:!1,enabled:ct}),Ct=s({queryKey:[`coding-workflows`,`providers`,`config`],queryFn:()=>a.providers.config().catch(()=>({})),refetchInterval:ct?3e4:!1,enabled:ct}),wt=n(()=>ve(bt.data),[bt.data]),Tt=n(()=>V(xt.data),[xt.data]),Q=n(()=>ye(ft.data),[ft.data]),Et=n(()=>B(mt.data,`runs`),[mt.data]),Dt=n(()=>B(ht.data,`coder_runs`),[ht.data]),$=n(()=>be(_t.data),[_t.data]),Ot=n(()=>ie({providerCatalog:St.data,providerConfig:Ct.data,defaultProvider:m.defaultProvider,defaultModel:m.defaultModel}),[m.defaultModel,m.defaultProvider,St.data,Ct.data]),kt=n(()=>Ne(O),[O]);e(()=>{Q.length&&(!b||!Q.some(e=>e.slug===b))&&x(Q[0].slug)},[Q,b]);let At=n(()=>b?Et.filter(e=>String(e?.project_slug||``).trim()===b):Et,[Et,b]),jt=n(()=>K(At),[At]),Mt=n(()=>jt.filter(De),[jt]);e(()=>{if(!jt.length){C(``);return}let e=Mt.map((e,t)=>xe(e,t)),t=jt.some((e,t)=>xe(e,t)===S),n=e.includes(S);if(e.length&&(!S||!n)){C(e[0]);return}(!S||!t)&&C(xe(jt[0],0))},[Mt,S,jt]);let Nt=n(()=>B(vt.data,`logs`),[vt.data]);e(()=>{if(!Nt.length){ae(``);return}(!w||!Nt.some(e=>String(e?.name||``)===w))&&ae(String(Nt[0]?.name||``))},[Nt,w]);let Pt=!!(lt.data?.engine?.ready||lt.data?.engine?.healthy),Ft=wt.some(e=>e.name.toLowerCase().includes(`github`)),It=Q.find(e=>e.slug===b)||null,Lt=It?.repo||{},Rt=String(It?.taskSource?.type||``).trim(),zt=String(lt.data?.workspaceRoot||lt.data?.workspace_root||(Rt===`kanban_board`||Rt===`local_backlog`)&&It?.taskSource?.path||``).trim(),Bt=wt.filter(e=>e.connected).map(e=>e.name),Vt=n(()=>$.items.filter(e=>$e.includes(String(e.id||``))),[$.items,$e]),Ht=n(()=>$.items.filter(e=>je(e)),[$.items]),Ut=n(()=>new Set(Object.keys(tt)),[tt]),Wt=m.defaultProvider&&m.defaultModel?`ACA default (${m.defaultProvider} / ${m.defaultModel})`:`ACA default`,Gt=(e=!1)=>c(`div`,{className:`grid gap-2`,children:[c(te,{providerLabel:`ACA provider`,modelLabel:`ACA model`,draft:{provider:H,model:Ee},providers:Ot,onChange:({provider:e,model:t})=>{Te(e),Ae(t)},inheritLabel:Wt,disabled:e}),c(`div`,{className:`tcp-subtle text-xs`,children:`Leave blank to inherit the base ACA provider and model for this run.`})]}),Kt=n(()=>new Set(Mt.map((e,t)=>Oe(e,t)).map(e=>String(e||``).trim()).filter(Boolean)),[Mt]),qt=jt.find((e,t)=>xe(e,t)===S)||null,Jt=String(Z.data?.summary||``).trim(),Yt=Z.data?.blackboard||null;e(()=>{Be(``)},[S]),e(()=>{if(!X)return;let e=ne(`/api/aca/events`,e=>{let t=Fe(String(e?.data||``));if(!t||t.event_type===`ping`)return;Re(String(t.event_type||`event`).trim()),v.invalidateQueries({queryKey:[`coding-workflows`,`aca-runs`]}),v.invalidateQueries({queryKey:[`coding-workflows`,`coder-runs`]}),v.invalidateQueries({queryKey:[`coding-workflows`,`aca-overview`]}),v.invalidateQueries({queryKey:[`coding-workflows`,`aca-projects`]}),b&&(v.invalidateQueries({queryKey:[`coding-workflows`,`aca-project-board`,b]}),v.invalidateQueries({queryKey:[`coding-workflows`,`aca-project-tasks`,b]}));let n=String(t?.payload?.run_id||t?.payload?.event?.run_id||``).trim();S&&n&&n===S&&v.invalidateQueries({queryKey:[`coding-workflows`,`aca-run-detail`,S]})});return()=>e()},[X,v,b,S]),e(()=>{if(!X||!S||!qt?.is_running)return;let e=ne(`/api/aca/runs/${encodeURIComponent(S)}/events`,e=>{let t=Fe(String(e?.data||``));!t||t.event_type===`ping`||(Be(String(t.event_type||`event`).trim()),v.invalidateQueries({queryKey:[`coding-workflows`,`aca-runs`]}),v.invalidateQueries({queryKey:[`coding-workflows`,`coder-runs`]}),v.invalidateQueries({queryKey:[`coding-workflows`,`aca-run-detail`,S]}),v.invalidateQueries({queryKey:[`coding-workflows`,`aca-run-logs`,S]}),w&&v.invalidateQueries({queryKey:[`coding-workflows`,`aca-run-log-tail`,S,w]}))});return()=>e()},[X,v,w,qt?.is_running,S]),e(()=>{gt.data&&He(Date.now())},[gt.data]),e(()=>{_t.data&&We(Number(_t.data?.last_synced_at_ms||Date.now()))},[_t.data]),e(()=>{et([])},[b]),e(()=>{nt({})},[b]),e(()=>{let e=Object.entries(tt);if(!e.length)return;let t=e.map(([e,t])=>{let n=Date.now()-Number(t||0),r=Math.max(0,W-n);return window.setTimeout(()=>{nt(t=>{if(!t[e])return t;let n={...t};return delete n[e],n})},r)});return()=>{t.forEach(e=>window.clearTimeout(e))}},[tt]),e(()=>{!Object.keys(tt).length||!$.items.length||nt(e=>{let t=!1,n={...e};return $.items.forEach(e=>{let r=String(e?.id||``).trim();!r||n[r]===void 0||Kt.has(ke(e))&&(delete n[r],t=!0)}),t?n:e})},[Kt,$.items,tt]),e(()=>{let e=new Set($.items.map(e=>String(e.id||``)));et(t=>t.filter(t=>e.has(t)))},[$.items]);let Xt=[{id:`overview`,label:`Overview`,icon:`layout-dashboard`},{id:`board`,label:`Intake`,icon:`list-checks`},{id:`planning`,label:`Planning`,icon:`clipboard-list`},{id:`manual`,label:`Manual tasks`,icon:`code`},{id:`integrations`,label:`Integrations`,icon:`plug-zap`}];async function Zt(e){let t=String(e||``).trim();if(t)try{await r(`/api/aca/operator/coder-runs/${encodeURIComponent(t)}/reconcile`,{method:`POST`}),await v.invalidateQueries({queryKey:[`coding-workflows`,`coder-runs`]}),await v.invalidateQueries({queryKey:[`coding-workflows`,`aca-runs`]}),d(`ok`,`Reconciled coder run ${t}.`)}catch(e){d(`err`,e instanceof Error?e.message:String(e))}}async function Qt(e){let t=String(e||``).trim();if(t&&window.confirm(`Cancel coder run ${t}?`))try{await r(`/api/aca/operator/coder-runs/${encodeURIComponent(t)}/cancel`,{method:`POST`,body:JSON.stringify({reason:`cancelled from Tandem Control Panel Coder view`})}),await v.invalidateQueries({queryKey:[`coding-workflows`,`coder-runs`]}),await v.invalidateQueries({queryKey:[`coding-workflows`,`aca-runs`]}),d(`ok`,`Cancelled coder run ${t}.`)}catch(e){d(`err`,e instanceof Error?e.message:String(e))}}async function $t(){let e=Ne(O),t=oe.trim()||R===`github_project`&&e?.slug||``,n=E.trim(),i=O.trim(),a=se.trim(),o=j.trim(),s=ce.trim(),c=P.trim(),l=I.trim();if(R===`github_project`&&!e){d(`warn`,`Paste a GitHub repository URL like https://github.com/owner/repo.`);return}if(!t){d(`warn`,`Project slug is required.`);return}if(a&&!Pe(a)||o&&!Pe(o)){d(`warn`,`Repo paths must stay within the managed workspace root.`);return}let u=q(R,{prompt:de,path:z,repoRef:e,projectNumber:me});if(u.type===`manual`&&!u.prompt){d(`warn`,`Manual task source requires a prompt.`);return}if([`kanban_board`,`local_backlog`].includes(u.type)&&!u.path){d(`warn`,`This task source requires a path.`);return}if(u.type===`github_project`&&(!u.owner||!u.repo||!u.project)){d(`warn`,`GitHub Project task sources require a repo URL and project number.`);return}Me(!0);try{let e=new URLSearchParams({slug:t});i&&e.set(`repo_url`,i),n&&e.set(`name`,n),a&&e.set(`repo_path`,a),o&&e.set(`worktree_root`,o),s&&e.set(`default_branch`,s),c&&e.set(`remote_name`,c),l&&e.set(`credential_file`,l),await r(`/api/aca/projects?${e.toString()}`,{method:`POST`,body:JSON.stringify(u)}),await v.invalidateQueries({queryKey:[`coding-workflows`,`aca-projects`]}),await v.invalidateQueries({queryKey:[`coding-workflows`,`aca-workspace-guide`]}),x(t),T(``),D(``),k(``),A(``),M(``),N(`main`),F(`origin`),L(``),d(`ok`,`Registered ACA project ${t}.`)}catch(e){d(`err`,e instanceof Error?e.message:String(e))}finally{Me(!1)}}async function en(){if(!b){d(`warn`,`Select a project before triggering a run.`);return}let e={};H.trim()&&(e.ACA_PROVIDER=H.trim()),Ee.trim()&&(e.ACA_MODEL=Ee.trim()),J(!0);try{let t=new URLSearchParams({project_slug:b});ge.trim()&&t.set(`item`,ge.trim());let n=await r(`/api/aca/runs/trigger?${t.toString()}`,{method:`POST`,body:JSON.stringify(e)});await v.invalidateQueries({queryKey:[`coding-workflows`,`aca-runs`]});let i=String(n?.run_id||``).trim();i&&(C(i),y(`board`)),d(`ok`,`ACA run started${i?`: ${i}`:`.`}`)}catch(e){d(`err`,e instanceof Error?e.message:String(e))}finally{J(!1)}}function tn(e){et(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])}function nn(){et($.items.filter(e=>je(e)&&!Kt.has(ke(e))&&!Ut.has(String(e.id||``))).map(e=>String(e.id||``)))}function rn(){et([])}async function an(e){if(!b){d(`warn`,`Select a project before starting ACA runs.`);return}let t=e.filter(e=>je(e)&&!Kt.has(ke(e))&&!Ut.has(String(e.id||``))),n=t.map(e=>String(e?.selector||``).trim()).filter(Boolean);if(!n.length){d(`warn`,`Those GitHub items are already running or are not launchable from ACA intake.`);return}let i={};H.trim()&&(i.ACA_PROVIDER=H.trim()),Ee.trim()&&(i.ACA_MODEL=Ee.trim()),nt(e=>{let n={...e},r=Date.now();return t.forEach(e=>{let t=String(e?.id||``).trim();t&&(n[t]=r)}),n}),it(!0);try{let e=await r(`/api/aca/runs/trigger-batch`,{method:`POST`,body:JSON.stringify({project_slug:b,items:n,overrides:i})});await v.invalidateQueries({queryKey:[`coding-workflows`,`aca-runs`]});let t=B(e,`runs`),a=String(t?.[0]?.run_id||``).trim();a&&(C(a),y(`board`)),d(`ok`,`Started ${n.length} ACA run${n.length===1?``:`s`}.`),et([])}catch(e){nt(e=>{let n={...e};return t.forEach(e=>{let t=String(e?.id||``).trim();t&&delete n[t]}),n}),d(`err`,e instanceof Error?e.message:String(e))}finally{it(!1)}}async function on(){if(!b){d(`warn`,`Select a project before refreshing GitHub intake.`);return}try{await gt.refetch(),He(Date.now()),d(`ok`,`Refreshed task intake from GitHub MCP.`)}catch(e){d(`err`,e instanceof Error?e.message:String(e))}}async function sn(){if(!b){d(`warn`,`Select a GitHub-backed project before refreshing the board.`);return}try{let e=await r(`/api/aca/projects/${encodeURIComponent(b)}/board?refresh=true`);v.setQueryData([`coding-workflows`,`aca-project-board`,b],e),We(Number(e?.last_synced_at_ms||Date.now())),d(`ok`,`Refreshed GitHub Project items through Tandem MCP.`)}catch(e){d(`err`,e instanceof Error?e.message:String(e))}}async function cn(){if(!b){d(`warn`,`Select a project before syncing its repository.`);return}Ke(!0),Je(null);try{let e=await r(`/api/aca/projects/${encodeURIComponent(b)}/repo/sync`,{method:`POST`});Je(e),await v.invalidateQueries({queryKey:[`coding-workflows`,`aca-projects`]}),await v.invalidateQueries({queryKey:[`coding-workflows`,`aca-workspace-guide`]}),await v.invalidateQueries({queryKey:[`coding-workflows`,`aca-project-tasks`,b]}),d(`ok`,`Repository ready at ${String(e?.repo?.path||`managed checkout`)}.`)}catch(e){d(`err`,e instanceof Error?e.message:String(e))}finally{Ke(!1)}}return X?c(f,{className:`grid gap-4`,children:[c(p,{className:`overflow-hidden`,children:c(`div`,{className:`grid gap-5 xl:grid-cols-[minmax(0,1.3fr)_minmax(320px,0.9fr)] xl:items-start`,children:[c(`div`,{className:`min-w-0`,children:[c(`div`,{className:`tcp-page-eyebrow`,children:`Coder`}),c(`h1`,{className:`tcp-page-title`,children:`Coder project intake and run dashboard`}),c(`p`,{className:`tcp-subtle mt-2 max-w-3xl`,children:`This view talks to the ACA control plane for project registration, task preview, durable coder runs, live logs, and final handoff artifacts.`}),c(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[c(l,{tone:ut.data?.status===`healthy`?`ok`:`warn`,children:ut.data?.status===`healthy`?`ACA healthy`:`ACA checking`}),c(l,{tone:Pt?`ok`:`warn`,children:Pt?`Engine healthy`:`Engine checking`}),c(l,{tone:Ft?`ok`:`warn`,children:Ft?`GitHub MCP connected`:`GitHub MCP pending`}),c(u,{tone:Mt.length?`live`:`info`,text:`${Mt.length} active runs`}),Le?c(l,{tone:`ghost`,children:[`Live `,U(Le)]}):null]})]}),c(`div`,{className:`grid gap-3 rounded-2xl border border-white/10 bg-black/20 p-3`,children:[c(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[c(`div`,{className:`min-w-0`,children:[c(`div`,{className:`text-sm font-semibold text-slate-100`,children:`Repository`}),c(`div`,{className:`tcp-subtle mt-1 truncate text-xs`,children:b?String(Lt?.path||Lt?.clone_url||It?.repo_url||b):`Select a project to sync its checkout.`})]}),c(`button`,{type:`button`,className:`tcp-btn h-8 px-3 text-xs`,onClick:cn,disabled:!b||Ge,children:[c(`i`,{"data-lucide":Ge?`loader-circle`:`refresh-cw`}),Ge?`Syncing`:`Sync repo`]})]}),c(`div`,{className:`grid gap-2 text-xs`,children:[c(`div`,{className:`flex flex-wrap gap-2`,children:[c(l,{tone:Lt?.clone_url?`ok`:`ghost`,children:Lt?.clone_url?`remote git`:`local git`}),c(l,{tone:`ghost`,children:String(Lt?.default_branch||`main`)}),qe?.repo?.dirty?c(l,{tone:`warn`,children:`dirty`}):null]}),qe?.repo?.commit?c(`div`,{className:`grid gap-2`,children:[c(`div`,{className:`tcp-subtle truncate`,children:[`Ready at `,String(qe.repo.path),` ·`,` `,String(qe.repo.commit).slice(0,7)]}),c(`div`,{className:`rounded-xl border border-sky-500/20 bg-sky-500/10 p-2 text-sky-100`,children:`Bug Monitor should use this checkout as its local directory when reporting issues for this repo.`})]}):null]})]})]})}),c(`div`,{className:`tcp-settings-tabs`,children:Xt.map(e=>c(`button`,{type:`button`,className:`tcp-settings-tab tcp-settings-tab-underline ${re===e.id?`active`:``}`,onClick:()=>y(e.id),children:[c(`i`,{"data-lucide":e.icon}),e.label]},e.id))}),re===`overview`?c(le,{projects:Q,selectedProjectSlug:b,setSelectedProjectSlug:x,selectedProject:It,acaOverview:dt,projectTasksQuery:gt,refreshTaskPreview:on,taskPreviewRefreshAt:Ve,coderRuns:Dt,coderRunsQuery:ht,reconcileCoderRun:Zt,cancelCoderRun:Qt,visibleRunsCount:At.length,activeRunsCount:Mt.length,connectedMcpServersCount:wt.length,registeredToolsCount:Tt.length}):null,re===`board`?c(`div`,{className:`grid gap-4`,children:c(`div`,{className:`grid gap-4`,children:[c(p,{title:`GitHub Project intake`,subtitle:`GitHub items ACA can launch`,children:[c(`div`,{className:`mb-4`,children:c(`select`,{className:`tcp-input`,value:b,onChange:e=>x(e.target.value),children:[Q.length?null:c(`option`,{value:``,children:`No ACA projects found`}),Q.map(e=>c(`option`,{value:e.slug,children:e.name?`${e.name} · ${e.slug}`:e.slug},e.slug))]})}),String(It?.taskSource?.type||``).trim()===`github_project`?_t.isLoading?c(`div`,{className:`tcp-subtle text-sm`,children:`Loading GitHub Project items...`}):_t.isError?c(`div`,{className:`rounded-2xl border border-red-500/20 bg-red-500/10 p-4 text-sm text-red-200`,children:_t.error instanceof Error?_t.error.message:`Could not load the GitHub Project items.`}):c(`div`,{className:`grid gap-3`,children:[c(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-2xl border border-white/10 bg-black/20 p-3`,children:[c(`div`,{className:`tcp-subtle text-xs`,children:[`Items are listed by ACA launchability with direct run controls.`,Ue?` Last synced ${new Date(Ue).toLocaleTimeString()}.`:``]}),c(`div`,{className:`flex flex-wrap items-center gap-2`,children:[c(l,{tone:$.isStale?`warn`:`ok`,children:$.isStale?`Cached snapshot`:U($.source||`live`)}),c(`button`,{type:`button`,className:`tcp-btn tcp-btn-secondary`,onClick:sn,disabled:_t.isFetching,children:_t.isFetching?`Refreshing...`:`Refresh from GitHub`})]})]}),c(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-2xl border border-cyan-500/20 bg-cyan-500/10 p-3`,children:[c(`div`,{className:`tcp-subtle text-xs`,children:`Select GitHub items here to start ACA runs directly from the board. This creates one ACA run per selected item and starts them immediately.`}),c(`div`,{className:`min-w-[320px] flex-1`,children:Gt(rt)}),c(`div`,{className:`flex flex-wrap gap-2`,children:[c(`button`,{type:`button`,className:`tcp-btn tcp-btn-secondary`,onClick:nn,disabled:!Ht.length||rt,children:`Select actionable`}),c(`button`,{type:`button`,className:`tcp-btn tcp-btn-secondary`,onClick:rn,disabled:!$e.length||rt,children:`Clear selection`}),c(`button`,{type:`button`,className:`tcp-btn-primary`,onClick:()=>an(Vt),disabled:!Vt.length||rt,children:rt?`Starting...`:`Run selected${Vt.length?` (${Vt.length})`:``}`})]})]}),$.warning?c(`div`,{className:`rounded-2xl border border-yellow-500/20 bg-yellow-500/10 p-4 text-sm text-yellow-100`,children:$.warning}):null,$.items.length?c(`div`,{className:`grid gap-3`,children:$.items.map(e=>{let t=je(e),n=String(e.id||``),r=t&&Kt.has(ke(e)),i=Ut.has(n),a=r||i||rt;return c(`div`,{className:`rounded-2xl border px-4 py-3 transition ${$e.includes(n)?`border-cyan-400/60 bg-cyan-500/10`:`border-white/10 bg-black/20`}`,children:[c(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[c(`div`,{className:`flex min-w-0 flex-1 items-start gap-3`,children:[c(`input`,{type:`checkbox`,className:`mt-1 h-4 w-4 shrink-0`,checked:$e.includes(n),disabled:!t||a,onChange:()=>tn(n)}),c(`div`,{className:`min-w-0`,children:[c(`div`,{className:`break-words text-sm font-semibold leading-5`,children:String(e.title||`Untitled item`)}),c(`div`,{className:`tcp-subtle mt-1 break-words text-xs leading-5`,children:[e.repoName?String(e.repoName):b,e.issueNumber?` #${String(e.issueNumber)}`:``]})]})]}),c(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[e.actionable?c(l,{tone:`ok`,children:`Actionable`}):null,c(l,{tone:`ghost`,children:U(String(e.statusName||e.statusKey||`Unknown`))}),r?c(l,{tone:`info`,children:`Run active`}):null,i&&!r?c(l,{tone:`warn`,children:`Starting`}):null]})]}),c(`div`,{className:`mt-3 flex flex-wrap gap-2 pl-7`,children:[e.issueUrl?c(`a`,{className:`tcp-btn h-8 px-3 text-xs`,href:e.issueUrl,target:`_blank`,rel:`noreferrer`,children:`Open in GitHub`}):null,c(`button`,{type:`button`,className:`tcp-btn h-8 px-3 text-xs`,onClick:()=>an([e]),disabled:!t||a,children:t?r?`Already running`:i?`Starting...`:`Run task`:`Not launchable`})]})]},n)})}):c(h,{text:`No GitHub Project items returned for this project.`})]}):c(h,{text:`The selected project is not backed by a GitHub Project task source.`})]}),c(p,{title:`ACA execution history`,subtitle:`Recent runs for the selected project`,children:jt.length?c(`div`,{className:`grid gap-2`,children:jt.map((e,t)=>{let n=xe(e,t);return c(`button`,{type:`button`,className:`rounded-2xl border px-3 py-3 text-left transition ${n===S?`border-cyan-400/60 bg-cyan-500/10`:`border-white/10 bg-black/20 hover:border-white/20`}`,onClick:()=>C(n),children:[c(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[c(`div`,{className:`min-w-0`,children:[c(`div`,{className:`truncate text-sm font-semibold`,children:Se(e)}),c(`div`,{className:`tcp-subtle mt-1 text-xs`,children:[String(e?.project_slug||`unknown`),e?.branch?` · ${String(e.branch)}`:``]})]}),c(`div`,{className:`flex flex-wrap gap-2`,children:[c(l,{tone:De(e)?`info`:`ok`,children:U(Ce(e))}),we(e)?c(l,{tone:`ghost`,children:U(we(e))}):null]})]}),c(`div`,{className:`tcp-subtle mt-2 text-xs`,children:n})]},n)})}):c(h,{text:`No ACA runs for this project yet.`})}),c(p,{title:`Run detail`,subtitle:S?`ACA detail for ${S}`:`Select a run`,actions:c(`button`,{type:`button`,className:`tcp-btn h-8 px-3 text-xs`,onClick:()=>Ze(e=>!e),children:[c(`i`,{"data-lucide":Ye?`chevron-down`:`chevron-right`}),Ye?`Collapse`:`Expand`]}),children:Ye?S?Z.isLoading?c(`div`,{className:`tcp-subtle text-sm`,children:`Loading run detail...`}):Z.isError?c(`div`,{className:`rounded-2xl border border-red-500/20 bg-red-500/10 p-4 text-sm text-red-200`,children:Z.error instanceof Error?Z.error.message:`Could not load run detail.`}):c(`div`,{className:`grid gap-3`,children:[c(`div`,{className:`rounded-2xl border border-white/10 bg-black/20 p-4`,children:[c(`div`,{className:`flex items-start justify-between gap-3`,children:[c(`div`,{className:`min-w-0`,children:[c(`div`,{className:`text-sm font-semibold`,children:String(Z.data?.status?.task?.title||qt?.title||S)}),c(`div`,{className:`tcp-subtle mt-1 text-xs`,children:String(Z.data?.project_slug||qt?.project_slug||`unknown`)})]}),c(l,{tone:Z.data?.is_running?`info`:`ok`,children:U(String(Z.data?.status?.run?.status||qt?.status||`unknown`))})]}),c(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[Z.data?.status?.phase?.name?c(l,{tone:`info`,children:[`Phase `,U(String(Z.data.status.phase.name))]}):null,ze?c(l,{tone:`ghost`,children:[`Latest `,U(ze)]}):null,Z.data?.snapshot?.summary_available?c(l,{tone:`ok`,children:`Summary ready`}):null,Z.data?.error?c(l,{tone:`warn`,children:`Has error`}):null]})]}),Jt?c(`div`,{className:`rounded-2xl border border-white/10 bg-black/20 p-4`,children:[c(`div`,{className:`mb-2 text-sm font-semibold`,children:`Summary`}),c(`pre`,{className:`max-h-56 overflow-auto whitespace-pre-wrap text-xs leading-6 text-slate-200`,children:Jt})]}):null,c(`div`,{className:`rounded-2xl border border-white/10 bg-black/20 p-4`,children:[c(`div`,{className:`mb-2 text-sm font-semibold`,children:`Blackboard`}),c(_,{value:Yt||{},label:`Show blackboard`,preClassName:`max-h-72 overflow-auto whitespace-pre-wrap text-xs leading-6 text-slate-200`})]})]}):c(h,{text:`Select a run from the board to inspect its status, summary, and blackboard.`}):null}),c(p,{title:`Live logs`,subtitle:`Tail ACA worker and manager logs`,actions:c(`button`,{type:`button`,className:`tcp-btn h-8 px-3 text-xs`,onClick:()=>Qe(e=>!e),children:[c(`i`,{"data-lucide":Y?`chevron-down`:`chevron-right`}),Y?`Collapse`:`Expand`]}),children:Y?S?c(`div`,{className:`grid gap-3`,children:[Nt.length?c(`select`,{className:`tcp-input`,value:w,onChange:e=>ae(e.target.value),children:Nt.map(e=>c(`option`,{value:String(e?.name||``),children:String(e?.name||``)},String(e?.name||``)))}):c(`div`,{className:`tcp-subtle text-sm`,children:`No logs available yet.`}),w&&yt.data?.lines?c(`pre`,{className:`max-h-80 overflow-auto rounded-2xl border border-white/10 bg-black/30 p-4 text-xs leading-6 text-slate-200`,children:B(yt.data,`lines`).join(`
8
- `)}):null]}):c(h,{text:`Choose a run to inspect log output.`}):null})]})}):null,re===`manual`?c(`div`,{className:`grid gap-4`,children:c(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[c(p,{title:`Register project`,subtitle:`Bind a repository, managed checkout, and task source into ACA`,children:c(`div`,{className:`grid gap-3`,children:[R===`github_project`?c(t,{children:[c(`input`,{className:`tcp-input`,placeholder:`GitHub repo URL, e.g. https://github.com/frumu-ai/tandem`,value:O,onInput:e=>k(e.target.value)}),c(`div`,{className:`rounded-2xl border border-cyan-500/20 bg-cyan-500/10 px-3 py-2 text-xs text-cyan-100`,children:kt?`Detected ${kt.owner}/${kt.repo}. ACA will use this for the GitHub Project owner/repo binding.`:`Paste a GitHub repository URL and ACA will derive the owner, repo, and default project slug.`})]}):c(`input`,{className:`tcp-input`,placeholder:`Repo URL (optional)`,value:O,onInput:e=>k(e.target.value)}),st?c(t,{children:[c(`input`,{className:`tcp-input`,placeholder:`Managed checkout path, e.g. repos/team-alpha`,value:se,onInput:e=>A(e.target.value)}),c(`input`,{className:`tcp-input`,placeholder:`Worktree root (optional)`,value:j,onInput:e=>M(e.target.value)}),c(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[c(`input`,{className:`tcp-input`,placeholder:`Default branch (optional)`,value:ce,onInput:e=>N(e.target.value)}),c(`input`,{className:`tcp-input`,placeholder:`Remote name (optional)`,value:P,onInput:e=>F(e.target.value)})]}),c(`input`,{className:`tcp-input`,placeholder:`Token file for private repos (optional)`,value:I,onInput:e=>L(e.target.value)})]}):null,st?c(`div`,{className:`rounded-2xl border border-lime-500/20 bg-lime-500/10 px-3 py-2 text-xs text-lime-100`,children:`Hosted installs can use these fields to register named repos and managed checkout directories without exposing an interactive shell.`}):null,c(`input`,{className:`tcp-input`,placeholder:R===`github_project`?`Project slug (optional, defaults to owner/repo)`:`Project slug`,value:oe,onInput:e=>T(e.target.value)}),c(`input`,{className:`tcp-input`,placeholder:`Project display name (optional)`,value:E,onInput:e=>D(e.target.value)}),c(`select`,{className:`tcp-input`,value:R,onChange:e=>ue(e.target.value),children:[c(`option`,{value:`manual`,children:`Manual prompt`}),c(`option`,{value:`kanban_board`,children:`Kanban board`}),c(`option`,{value:`local_backlog`,children:`Local backlog`}),c(`option`,{value:`github_project`,children:`GitHub Project`})]}),R===`manual`?c(`textarea`,{className:`tcp-input min-h-[120px]`,placeholder:`Manual task prompt`,value:de,onInput:e=>fe(e.target.value)}):null,R===`kanban_board`||R===`local_backlog`?c(`input`,{className:`tcp-input`,placeholder:`Absolute file path`,value:z,onInput:e=>pe(e.target.value)}):null,R===`github_project`?c(t,{children:[c(`input`,{className:`tcp-input`,placeholder:`GitHub Project number`,value:me,onInput:e=>he(e.target.value)}),c(`div`,{className:`tcp-subtle text-xs`,children:`Only GitHub Project board tasks are imported. Public issues that are not on this project board remain outside ACA intake.`})]}):null,c(`button`,{type:`button`,className:`tcp-btn`,disabled:G,onClick:$t,children:G?`Registering...`:`Register Project`})]})}),c(p,{title:`Trigger run`,subtitle:`Launch an ACA coding session for the selected project`,children:c(`div`,{className:`grid gap-3`,children:[c(`select`,{className:`tcp-input`,value:b,onChange:e=>x(e.target.value),children:[Q.length?null:c(`option`,{value:``,children:`No ACA projects found`}),Q.map(e=>c(`option`,{value:e.slug,children:e.slug},e.slug))]}),c(`input`,{className:`tcp-input`,placeholder:`Specific item or card id (optional)`,value:ge,onInput:e=>_e(e.target.value)}),Gt(Ie),c(`button`,{type:`button`,className:`tcp-btn-primary`,disabled:Ie,onClick:en,children:Ie?`Starting...`:`Trigger ACA Run`})]})})]})}):null,re===`planning`?c(Xe,{client:a,api:r,toast:d,selectedProjectSlug:b,selectedProject:It,githubProjectBoardSnapshot:_t.data||null,taskSourceType:Rt,workspaceRootSeed:zt,connectedMcpServers:Bt,engineHealthy:Pt,providerStatus:m}):null,re===`integrations`?c(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[c(p,{title:`ACA connection`,subtitle:`Control-plane endpoint the coding page uses`,children:c(`div`,{className:`grid gap-3`,children:[c(`div`,{className:`rounded-2xl border border-white/10 bg-black/20 p-4`,children:[c(`div`,{className:`text-sm font-semibold`,children:`Health`}),c(`div`,{className:`tcp-subtle mt-1 text-xs`,children:[ut.data?.status||`Unavailable`,ut.data?.version?` · ${String(ut.data.version)}`:``]})]}),c(`div`,{className:`rounded-2xl border border-white/10 bg-black/20 p-4`,children:[c(`div`,{className:`text-sm font-semibold`,children:`Projects`}),c(`div`,{className:`tcp-subtle mt-1 text-xs`,children:[Q.length,` registered`]})]}),c(`div`,{className:`rounded-2xl border border-white/10 bg-black/20 p-4`,children:[c(`div`,{className:`text-sm font-semibold`,children:`Runs`}),c(`div`,{className:`tcp-subtle mt-1 text-xs`,children:[Et.length,` visible through ACA`]})]})]})}),c(p,{title:`Workspace guide`,subtitle:`What the agent should inspect first`,children:pt.data?c(`div`,{className:`grid gap-3`,children:[c(`div`,{className:`rounded-2xl border border-white/10 bg-black/20 p-4`,children:[c(`div`,{className:`text-sm font-semibold`,children:`Active project`}),c(`div`,{className:`tcp-subtle mt-1 text-xs`,children:[String(pt.data?.active_project?.name||`None`).trim(),pt.data?.active_project?.repo?.path?` · ${String(pt.data.active_project.repo.path)}`:``]})]}),c(`div`,{className:`rounded-2xl border border-white/10 bg-black/20 p-4`,children:[c(`div`,{className:`text-sm font-semibold`,children:`Layout`}),c(`div`,{className:`tcp-subtle mt-1 text-xs`,children:String(pt.data?.layout?.worktree_root||`managed root`)})]}),c(`ul`,{className:`grid gap-2 text-xs text-slate-200`,children:(Array.isArray(pt.data?.instructions)?pt.data.instructions:[]).map((e,t)=>c(`li`,{className:`rounded-xl border border-white/10 bg-black/10 px-3 py-2`,children:e},`${t}-${e}`))})]}):c(h,{text:`Workspace guide unavailable yet.`})}),c(p,{title:`Connected MCP servers`,subtitle:`Engine integrations still available alongside ACA`,children:wt.length?c(`div`,{className:`grid gap-2`,children:wt.map(e=>c(`div`,{className:`flex items-center justify-between gap-3 rounded-2xl border border-white/10 bg-black/20 px-3 py-2`,children:[c(`div`,{className:`min-w-0`,children:[c(`div`,{className:`truncate text-sm font-semibold`,children:e.name}),c(`div`,{className:`tcp-subtle text-xs`,children:[e.transport||`transport pending`,e.lastError?` · ${e.lastError}`:``]})]}),c(l,{tone:e.connected?`ok`:e.enabled?`warn`:`ghost`,children:e.connected?`Connected`:e.enabled?`Configured`:`Disabled`})]},e.name))}):c(h,{text:`No MCP servers detected yet.`})})]}):null]}):c(f,{className:`grid gap-4`,children:c(p,{className:`overflow-hidden`,children:c(`div`,{className:`grid gap-5 xl:grid-cols-[minmax(0,1.3fr)_minmax(320px,0.9fr)] xl:items-start`,children:c(`div`,{className:`min-w-0`,children:[c(`div`,{className:`tcp-page-eyebrow`,children:`Coder`}),c(`h1`,{className:`tcp-page-title`,children:`Coder dashboard`}),c(`p`,{className:`tcp-subtle mt-2 max-w-3xl`,children:`ACA integration is required for Coder. Connect the ACA control plane so this workspace can load registered projects, task intake, and live run details.`}),c(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[c(l,{tone:ot?`ok`:`warn`,children:ot?`Engine healthy`:`Engine unavailable`}),c(l,{tone:`warn`,children:`ACA disconnected`})]}),c(`div`,{className:`mt-4 rounded-2xl border border-yellow-500/20 bg-yellow-500/10 p-4`,children:[c(`p`,{className:`text-sm text-yellow-200`,children:[c(`strong`,{children:`ACA integration required.`})," Set `ACA_BASE_URL` and make sure the control panel can authenticate to ACA with `ACA_API_TOKEN` or `ACA_API_TOKEN_FILE`."]}),c(`button`,{type:`button`,className:`tcp-btn mt-3`,onClick:()=>ee(`settings`),children:`Open ACA setup`})]})]})})})})}export{Ze as CodingWorkflowsPage};
@@ -1 +0,0 @@
1
- import{g as e,v as t}from"./fullcalendar-Bn75j0xM.js";import{n}from"./react-query-BIbNygEJ.js";import{i as r}from"./motion-B3ZE8SGR.js";import{c as i,d as a,m as o,n as s,p as c,r as l,t as u,u as d}from"./ui-CV-Z6sqF.js";import{s as f}from"./index-picB46b5.js";import{n as p}from"./LazyJson-DYncL_RR.js";import{t as m}from"./format-CimuGHiH.js";var h=[{label:`24h`,hours:24},{label:`7d`,hours:168},{label:`30d`,hours:720}],g={missing_required_section:`Missing required section`,weak_markdown_structure:`Weak markdown structure`,missing_optional_evidence:`Missing optional evidence`,artifact_word_count_below_minimum:`Word count below minimum`,missing_nonconsumed_workspace_files:`Workspace files missing`,missing_required_artifact_path:`Missing required artifact path`,validator_kind_specific_soft_check:`Validator soft check`,repair_budget_exhausted:`Repair budget exhausted`};function _(e){return g[e]||e.replace(/_/g,` `)}function v(e){return(Number(e.accepted)||0)+(Number(e.rejected)||0)+(Number(e.re_ran_strict)||0)}function y(e){return v(e)+(Number(e.unmarked)||0)}function b(e){let t=v(e);return t===0?null:(Number(e.accepted)||0)/t}function x(e){return e===null?`—`:`${(e*100).toFixed(1)}%`}function S({client:i,automationId:a,className:o=``}){let[s,c]=t(168),l=n({queryKey:[`graduation`,`summary`,s,a||``],enabled:!!i?.automationsV2?.graduationSummary,queryFn:async()=>i?.automationsV2?.graduationSummary?i.automationsV2.graduationSummary({windowHours:s,automationId:a,limit:200}):null,refetchInterval:6e4,staleTime:3e4}),u=l.data||null,d=u?.summary||{},f=d?.by_class||{},p=e(()=>Object.entries(f).map(([e,t])=>({key:e,counts:t,total:y(t),reviewed:v(t),acceptRate:b(t)})).sort((e,t)=>t.reviewed===e.reviewed?t.total-e.total:t.reviewed-e.reviewed),[f]),m=Number(d?.total_outputs_scanned||0),g=Number(d?.total_relaxed_outputs||0),S=Number(u?.scanned_runs||0);return r(`div`,{className:`grid gap-3 ${o}`,children:[r(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[r(`div`,{children:[r(`div`,{className:`text-sm font-medium text-slate-100`,children:`Graduation summary`}),r(`div`,{className:`tcp-subtle text-xs`,children:[`Per-class accept rate over the last`,` `,h.find(e=>e.hours===s)?.label||`${s}h`,`.`]})]}),r(`div`,{className:`flex flex-wrap gap-1`,children:h.map(e=>r(`button`,{type:`button`,className:s===e.hours?`tcp-btn-primary`:`tcp-btn`,onClick:()=>c(e.hours),disabled:l.isFetching,children:e.label},e.hours))})]}),r(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-3`,children:[r(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[r(`div`,{className:`tcp-subtle text-[11px]`,children:`runs scanned`}),r(`div`,{className:`mt-1 font-medium text-slate-100`,children:S})]}),r(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[r(`div`,{className:`tcp-subtle text-[11px]`,children:`node outputs scanned`}),r(`div`,{className:`mt-1 font-medium text-slate-100`,children:m})]}),r(`div`,{className:`rounded-md border border-amber-700/40 bg-amber-950/20 p-2`,children:[r(`div`,{className:`tcp-subtle text-[11px]`,children:`relaxed outputs`}),r(`div`,{className:`mt-1 font-medium text-amber-200`,children:g})]})]}),l.isError?r(`div`,{className:`rounded-md border border-rose-700/40 bg-rose-950/20 p-2 text-xs text-rose-200`,children:`Failed to load graduation summary.`}):null,p.length===0?r(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-3 text-sm text-slate-300`,children:l.isLoading?`Loading…`:m===0?`No automation runs scanned in this window.`:`No relaxed outputs in this window. Strict-only runs do not show up here.`}):r(`div`,{className:`overflow-hidden rounded-md border border-slate-800/80`,children:r(`table`,{className:`w-full text-left text-xs`,children:[r(`thead`,{className:`bg-slate-900/40 text-[11px] uppercase tracking-wide text-slate-400`,children:r(`tr`,{children:[r(`th`,{className:`px-2 py-1.5`,children:`Validator class`}),r(`th`,{className:`px-2 py-1.5 text-right`,children:`Accepted`}),r(`th`,{className:`px-2 py-1.5 text-right`,children:`Rejected`}),r(`th`,{className:`px-2 py-1.5 text-right`,children:`Re-ran Strict`}),r(`th`,{className:`px-2 py-1.5 text-right`,children:`Unmarked`}),r(`th`,{className:`px-2 py-1.5 text-right`,children:`Accept rate`})]})}),r(`tbody`,{children:p.map(e=>{let t=e.reviewed===0?r(`span`,{className:`tcp-subtle italic`,children:`insufficient signal`}):r(`span`,{className:(e.acceptRate??0)>=.8?`font-semibold text-emerald-300`:(e.acceptRate??0)<=.4?`font-semibold text-rose-300`:`font-semibold text-amber-200`,children:x(e.acceptRate)});return r(`tr`,{className:`border-t border-slate-800/60 text-slate-200`,children:[r(`td`,{className:`px-2 py-1.5`,children:[r(`div`,{className:`font-medium`,children:_(e.key)}),r(`code`,{className:`tcp-subtle text-[10px]`,children:e.key})]}),r(`td`,{className:`px-2 py-1.5 text-right`,children:e.counts.accepted||0}),r(`td`,{className:`px-2 py-1.5 text-right`,children:e.counts.rejected||0}),r(`td`,{className:`px-2 py-1.5 text-right`,children:e.counts.re_ran_strict||0}),r(`td`,{className:`px-2 py-1.5 text-right tcp-subtle`,children:e.counts.unmarked||0}),r(`td`,{className:`px-2 py-1.5 text-right`,children:t})]},e.key)})})]})})]})}function C(e,t){return Array.isArray(e)?e:Array.isArray(e?.[t])?e[t]:[]}function w(e){return String(e||``).trim().replace(/([a-z0-9])([A-Z])/g,`$1_$2`).replace(/[\s-]+/g,`_`).toLowerCase()}function T(e){return e.ready?e.defaultProvider===`openai-codex`?e.defaultProviderManagedBy===`codex-upload`?`Imported auth.json on hosted server`:e.defaultProviderManagedBy===`codex-cli`?`Mirrored from local Codex CLI`:e.defaultProviderAuthKind===`oauth`?`Codex account session active`:``:e.defaultProviderAuthKind===`oauth`?`OAuth session active`:e.defaultProviderSource===`env`?`Env-managed credentials`:e.defaultProviderSource===`persisted`?`Stored credentials`:``:``}function E(h){let{api:g,client:_,navigate:v,providerStatus:y}=h,[b,x]=t(``),[E,D]=t(`day`),O=new Set([`workflow`,`bug_monitor_triage`]),k=n({queryKey:[`dashboard`,`health`],queryFn:()=>g(`/api/system/health`),refetchInterval:15e3}),A=n({queryKey:[`dashboard`,`sessions`],queryFn:()=>_.sessions.list({pageSize:8,source:`chat`}).catch(()=>[]),refetchInterval:15e3}),j=n({queryKey:[`dashboard`,`routines`],queryFn:()=>_.routines.list().catch(()=>({routines:[]})),refetchInterval:2e4}),M=n({queryKey:[`dashboard`,`automation-v2-runs`],queryFn:()=>g(`/api/engine/automations/v2/runs?limit=200`).catch(()=>({runs:[]})),refetchInterval:15e3}),N=n({queryKey:[`dashboard`,`swarm`],queryFn:()=>g(`/api/swarm/status`).catch(()=>({status:`unknown`,activeRuns:0})),refetchInterval:6e3}),P=n({queryKey:[`dashboard`,`workflow-context-runs`],queryFn:()=>g(`/api/engine/context/runs?limit=12`).catch(()=>({runs:[]})),refetchInterval:6e3}),F=n({queryKey:[`dashboard`,`workflow-context-run`,b],enabled:!!b,queryFn:()=>g(`/api/engine/context/runs/${encodeURIComponent(b)}`).catch(()=>({run:null}))}),I=n({queryKey:[`dashboard`,`workflow-context-blackboard`,b],enabled:!!b,queryFn:()=>g(`/api/engine/context/runs/${encodeURIComponent(b)}/blackboard`).catch(()=>({blackboard:null}))}),L=C(A.data,`sessions`),R=C(j.data,`routines`),z=C(M.data,`runs`),B=C(P.data,`runs`).filter(e=>O.has(String(e?.run_type||``).trim().toLowerCase())),V=!!(k.data?.engine?.ready||k.data?.engine?.healthy),H=String(N.data?.status||`unknown`),U=[`planning`,`awaiting_approval`,`running`,`executing`].includes(H.toLowerCase()),W=z.filter(e=>[`queued`,`running`,`pausing`,`awaiting_approval`,`blocked`].includes(w(e?.status))),G=z.filter(e=>Number(e?.total_tokens||0)>0),K=z.reduce((e,t)=>({prompt:e.prompt+Number(t?.prompt_tokens||0),completion:e.completion+Number(t?.completion_tokens||0),total:e.total+Number(t?.total_tokens||0)}),{prompt:0,completion:0,total:0}),q=B.filter(e=>[`queued`,`planning`,`running`,`awaiting_approval`].includes(String(e?.status||``).trim().toLowerCase())),J=T(y),Y=e(()=>{let e=new Map,t=Date.now(),n,r,i,a;E===`day`?(n=336*60*60*1e3,r=14,i=e=>e.toISOString().slice(0,10),a=e=>{let[,t,n]=e.split(`-`);return`${t}/${n}`}):E===`week`?(n=1344*60*60*1e3,r=8,i=e=>{let t=new Date(e);return t.setDate(e.getDate()-(e.getDay()+6)%7),t.toISOString().slice(0,10)},a=e=>{let[,t,n]=e.split(`-`);return`w/${t}/${n}`}):(n=4320*60*60*1e3,r=6,i=e=>e.toISOString().slice(0,7),a=e=>{let[t,n]=e.split(`-`);return`${n}/${t.slice(2)}`});let o=t-n;for(let t of z){let n=Number(t?.created_at_ms||t?.updated_at_ms||0);if(!n||n<o)continue;let r=new Date(n),s=i(r),c=e.get(s)??{label:a(s),runs:0,tokens:0};c.runs+=1,c.tokens+=Number(t?.total_tokens||0),e.set(s,c)}let s=[...e.entries()].sort((e,t)=>e[0].localeCompare(t[0])),c=Math.max(1,...s.map(([,e])=>e.tokens));return{buckets:s.map(([,e])=>e),maxTokens:c,bucketCount:r}},[z,E]),X=e(()=>[{label:`Recent sessions`,value:L.length,tone:`info`,helper:`Latest active conversation surfaces`},{label:`Stored runs`,value:z.length,tone:`ok`,helper:`Persisted automation-v2 history`},{label:`Live runs`,value:W.length,tone:W.length?`warn`:`ghost`,helper:`Queued, running, blocked, awaiting approval`},{label:`Tracked tokens`,value:K.total,tone:K.total?`info`:`ghost`,helper:`${G.length} runs with usage`},{label:`Context runs`,value:B.length,tone:q.length?`warn`:`info`,helper:q.length?`${q.length} active`:`Workflow + triage visibility`}],[q.length,z.length,K.total,W.length,L.length,B.length,G.length]);return r(u,{className:`grid gap-4`,children:[r(d,{className:`overflow-hidden`,children:[r(`div`,{className:`grid gap-5 xl:grid-cols-[minmax(0,1.3fr)_minmax(320px,0.9fr)] xl:items-start`,children:r(`div`,{className:`min-w-0`,children:[r(`div`,{className:`tcp-page-eyebrow`,children:`Overview`}),r(`h1`,{className:`tcp-page-title`,children:`Command center`}),r(`p`,{className:`tcp-subtle mt-2 max-w-3xl`,children:`A higher-signal home screen with animated state and a clearer read on what the system is doing right now.`}),r(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[r(s,{tone:V?`ok`:`warn`,children:V?`Engine healthy`:`Engine checking`}),r(s,{tone:y.ready?`ok`:`warn`,children:y.ready?y.defaultProvider:`Provider setup required`}),J?r(s,{tone:`info`,children:J}):null,U?r(c,{tone:`live`,text:`Swarm ${H}`}):r(s,{tone:`ghost`,children:[`Swarm `,H]})]})]})}),r(`div`,{className:`mt-5`,children:[r(`div`,{className:`dashboard-kpis`,children:X.map(e=>r(`div`,{children:[r(`div`,{className:`flex items-start justify-between gap-3`,children:[r(`span`,{className:`dashboard-kpi-label`,children:e.label}),r(s,{tone:e.tone,children:e.helper})]}),r(`strong`,{children:r(i,{value:e.value,format:e.format??m})})]},e.label))}),r(`p`,{className:`tcp-subtle mt-3 text-xs`,children:`Usage totals are aggregated from stored automation-v2 run history, so they reflect real executions instead of inferred activity.`}),r(`div`,{className:`mt-4 dashboard-bars`,children:[r(`div`,{className:`dashboard-bar-row`,children:[r(`div`,{className:`dashboard-bar-meta`,children:[r(`span`,{children:`Engine readiness`}),r(`span`,{className:`dashboard-bar-count`,children:V?`100%`:`45%`})]}),r(`div`,{className:`dashboard-bar-track`,children:r(`span`,{className:`dashboard-bar-fill completed`,style:{width:V?`100%`:`45%`}})})]}),r(`div`,{className:`dashboard-bar-row`,children:[r(`div`,{className:`dashboard-bar-meta`,children:[r(`span`,{children:`Provider confidence`}),r(`span`,{className:`dashboard-bar-count`,children:y.ready?`100%`:`30%`})]}),r(`div`,{className:`dashboard-bar-track`,children:r(`span`,{className:`dashboard-bar-fill ${y.ready?`running`:`queued`}`,style:{width:y.ready?`100%`:`30%`}})})]}),r(`div`,{className:`dashboard-bar-row`,children:[r(`div`,{className:`dashboard-bar-meta`,children:[r(`span`,{children:`Automation activity`}),r(`span`,{className:`dashboard-bar-count`,children:[W.length,` live`]})]}),r(`div`,{className:`dashboard-bar-track`,children:r(`span`,{className:`dashboard-bar-fill ${W.length?`running`:`manual`}`,style:{width:`${z.length?Math.min(100,Math.max(12,W.length/z.length*100)):12}%`}})})]})]})]})]}),r(d,{children:[r(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[r(`div`,{children:[r(`div`,{className:`tcp-page-eyebrow`,children:`Usage`}),r(`h2`,{className:`font-semibold`,children:`Token usage over time`})]}),r(`div`,{className:`flex gap-1`,children:[`day`,`week`,`month`].map(e=>r(`button`,{type:`button`,className:`tcp-btn h-7 px-2 text-xs capitalize ${E===e?`tcp-btn-active`:``}`,onClick:()=>D(e),children:e},e))})]}),Y.buckets.length===0?r(`p`,{className:`tcp-subtle text-xs`,children:`No token data in this window yet.`}):r(`div`,{className:`grid gap-2`,children:Y.buckets.map(e=>r(`div`,{className:`dashboard-bar-row`,children:[r(`div`,{className:`dashboard-bar-meta`,children:[r(`span`,{className:`font-mono text-xs`,children:e.label}),r(`span`,{className:`dashboard-bar-count`,children:[m(e.tokens),` tok`,` · `,r(`span`,{className:`tcp-subtle`,children:[e.runs,` run`,e.runs===1?``:`s`]})]})]}),r(`div`,{className:`dashboard-bar-track`,children:r(`span`,{className:`dashboard-bar-fill ${e.tokens>0?`running`:`manual`}`,style:{width:`${Math.max(4,e.tokens/Y.maxTokens*100)}%`}})})]},e.label))})]}),r(d,{title:`Graduation review`,subtitle:`Per-class accept rate for relaxed Guided/Lenient outputs.`,children:r(S,{client:_})}),r(a,{main:r(d,{title:`Recent sessions`,subtitle:`Latest conversations, ready to reopen.`,children:r(`div`,{className:`grid gap-2`,children:L.length?L.map(e=>r(`button`,{className:`tcp-list-item text-left`,onClick:()=>v(`chat`),children:[r(`div`,{className:`font-medium inline-flex items-center gap-2`,children:[r(`i`,{"data-lucide":`messages-square`}),String(e.title||e.id||`Session`)]}),r(`div`,{className:`tcp-subtle mt-1 text-xs`,children:String(e.id||e.session_id||``)})]},String(e.id||e.session_id||Math.random()))):r(f,{text:`Start a conversation to populate recent sessions here.`})})}),aside:r(`div`,{className:`grid gap-4`,children:[r(d,{title:`Context visibility`,subtitle:`Recent workflow and failure-triage context runs with their current projection state.`,children:[r(o,{className:`mb-3`,children:[r(s,{tone:q.length?`warn`:`info`,children:[B.length,` recent`]}),r(`button`,{className:`tcp-btn`,onClick:()=>v(`orchestrator`),children:[r(`i`,{"data-lucide":`workflow`}),`Open task board`]})]}),r(`div`,{className:`grid gap-2`,children:B.length?B.slice(0,5).map(e=>r(`button`,{className:`tcp-list-item text-left`,onClick:()=>x(String(e?.run_id||``).trim()),children:[r(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[r(`div`,{className:`font-medium`,children:String(e?.objective||e?.run_id||`Context run`)}),r(`div`,{className:`flex flex-wrap items-center gap-2`,children:[r(s,{tone:`ghost`,children:String(e?.run_type||`context`)}),r(s,{tone:[`failed`,`cancelled`].includes(String(e?.status||``).toLowerCase())?`err`:[`running`,`queued`,`planning`].includes(String(e?.status||``).toLowerCase())?`warn`:`ok`,children:String(e?.status||`unknown`)})]})]}),r(`div`,{className:`tcp-subtle text-xs`,children:String(e?.run_id||``)}),r(`div`,{className:`tcp-subtle mt-1 text-xs`,children:[Array.isArray(e?.tasks)?e.tasks.length:0,` tasks ·`,` `,Array.isArray(e?.steps)?e.steps.length:0,` steps`]})]},String(e?.run_id||Math.random()))):r(f,{text:`Workflow and failure-triage context runs will appear here once they execute.`})})]}),r(d,{title:`Automation snapshot`,subtitle:`Schedules and run-ready routines.`,children:[r(o,{className:`mb-3`,children:[r(s,{tone:`info`,children:[R.length,` loaded`]}),r(`button`,{className:`tcp-btn`,onClick:()=>v(`automations`),children:[r(`i`,{"data-lucide":`bot`}),`Manage`]})]}),r(`div`,{className:`grid gap-2`,children:R.length?R.slice(0,4).map(e=>r(`div`,{className:`tcp-list-item`,children:[r(`div`,{className:`font-medium`,children:String(e.name||e.id||`Routine`)}),r(`div`,{className:`tcp-subtle mt-1 text-xs`,children:String(e.schedule||e.status||`manual`)})]},String(e.id||e.routine_id||Math.random()))):r(f,{text:`No routines are configured yet.`})})]}),r(d,{title:`Health notes`,subtitle:`Direct links for the next likely action.`,children:r(`div`,{className:`grid gap-2`,children:[r(`div`,{className:`tcp-list-item`,children:[r(`div`,{className:`font-medium inline-flex items-center gap-2`,children:[r(`i`,{"data-lucide":`activity`}),`Engine endpoint`]}),r(`div`,{className:`tcp-subtle mt-1 text-xs`,children:String(k.data?.engineUrl||`Unavailable`)})]}),r(`div`,{className:`tcp-list-item`,children:[r(`div`,{className:`font-medium inline-flex items-center gap-2`,children:[r(`i`,{"data-lucide":`radio`}),`Swarm`]}),r(`div`,{className:`tcp-subtle mt-1 text-xs`,children:[`Status: `,H]})]}),r(`div`,{className:`tcp-list-item`,children:[r(`div`,{className:`font-medium inline-flex items-center gap-2`,children:[r(`i`,{"data-lucide":`database`}),`Memory & runs`]}),r(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[r(`button`,{className:`tcp-btn h-8 px-3 text-xs`,onClick:()=>v(`memory`),children:`Open memory`}),r(`button`,{className:`tcp-btn h-8 px-3 text-xs`,onClick:()=>v(`runs`),children:`Open runs`})]})]})]})})]})}),r(l,{open:!!b,onClose:()=>x(``),title:b||`Workflow context run`,children:b?r(`div`,{className:`grid gap-3`,children:[r(`div`,{className:`tcp-list-item`,children:[r(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[r(`strong`,{children:String(F.data?.run?.objective||b)}),r(s,{tone:`info`,children:String(F.data?.run?.status||`unknown`)})]}),r(`div`,{className:`tcp-subtle text-xs`,children:[`type: `,String(F.data?.run?.run_type||`workflow`)]})]}),r(`div`,{className:`tcp-list-item`,children:[r(`div`,{className:`font-medium mb-2`,children:`Projected blackboard`}),r(`div`,{className:`tcp-subtle text-xs`,children:[`tasks:`,` `,Array.isArray(I.data?.blackboard?.tasks)?I.data.blackboard.tasks.length:0,` · `,`artifacts:`,` `,Array.isArray(I.data?.blackboard?.artifacts)?I.data.blackboard.artifacts.length:0]})]}),r(p,{value:{run:F.data?.run||null,blackboard:I.data?.blackboard||null},label:`Show run + blackboard`})]}):null})]})}export{E as DashboardPage};
@@ -1 +0,0 @@
1
- import{C as e,E as t,g as n,h as r,v as i}from"./fullcalendar-Bn75j0xM.js";import{a,n as o,t as s}from"./react-query-BIbNygEJ.js";import{i as c,n as ee,r as l}from"./motion-B3ZE8SGR.js";import{i as u,m as d,n as f,t as p,u as te}from"./ui-CV-Z6sqF.js";import{a as ne,s as m,t as h,u as re}from"./index-picB46b5.js";import{i as g,n as ie,t as ae}from"./explorerHandoff-KpFRPNQc.js";import{n as _,t as oe}from"./ControlPanelDialogs-BBIPHXnw.js";import{t as se}from"./MemoryImportDialog-BWT93PW1.js";var v=3,y=`.md,.markdown,.txt,text/plain,text/markdown`,b=[10,25,50,100],ce=25;function le(){return`${Date.now()}-${Math.random().toString(16).slice(2)}`}function ue(e){let t=String(e||``).trim();if(!t)return``;let n=t.split(`/`);return(n[n.length-1]||t).replace(/\.[^.]+$/,``)}function x(e){return Array.isArray(e)?e:Array.isArray(e?.documents)?e.documents:Array.isArray(e?.items)?e.items:e?.document&&typeof e.document==`object`?[e.document]:[]}function S(e){let t=String(e.collection_id||``).trim();if(t)return t;let n=String(e.doc_id||e.id||``).trim(),r=n.indexOf(`/`);return r>0?n.slice(0,r):``}function de(e){let t=S(e),n=String(e.doc_id||e.id||``).trim();return!t||!n?``:`${t}|${n}`}function fe(e){let t=Number(e||0);return t?new Date(t).toLocaleString():`n/a`}function pe(e){let t=Number(e||0);if(!t)return`n/a`;if(t<1024)return`${t} B`;let n=[`KB`,`MB`,`GB`,`TB`],r=t/1024,i=0;for(;r>=1024&&i<n.length-1;)r/=1024,i+=1;return`${r.toFixed(r>=10?0:1)} ${n[i]}`}function me(e){let t=String(e?.content_type||``).toLowerCase(),n=String(e?.title||e?.filename||e?.file_name||``).toLowerCase();return t.includes(`markdown`)||n.endsWith(`.md`)||n.endsWith(`.markdown`)?`markdown`:t.includes(`json`)||n.endsWith(`.json`)?`json`:`text`}function C(e){let t=S(e||{}),n=String(e?.doc_id||e?.id||``).trim();return!t||!n?``:n.startsWith(`${t}/`)?n.slice(t.length+1):n}function w(e,t){return!Number.isFinite(e)||e<1||!Number.isFinite(t)||t<1?1:Math.min(e,t)}function T(e,t,n){if(!n)return`0 of 0`;let r=w(e,Math.max(1,Math.ceil(n/Math.max(1,t)))),i=Math.max(1,t);return`${(r-1)*i+1}-${Math.min(n,r*i)} of ${n}`}function he({api:t,toast:p,defaultCollectionId:m}){let h=a(),g=r(null),ie=r(null),ae=r(null),_=r(new Map),se=r(new Map),he=r(0),[E,D]=i(``),[O,ge]=i(!1),[_e,ve]=i(!1),[ye,be]=i(!1),[xe,Se]=i(``),[k,Ce]=i(``),[we,A]=i(!1),[Te,j]=i(!1),[Ee,M]=i(``),[De,N]=i(``),[P,Oe]=i(1),[F,ke]=i(ce),[I,Ae]=i(null),[je,Me]=i([]),[Ne,Pe]=i(null),[L,Fe]=i(null),[R,z]=i([]),[Ie,B]=i(!1),V=o({queryKey:[`knowledgebase`,`config`],queryFn:async()=>t(`/api/knowledgebase/config`).catch(()=>({configured:!1})),staleTime:6e4}).data?.configured===!0,Le=o({queryKey:[`knowledgebase`,`collections`],enabled:V,queryFn:async()=>t(`/api/knowledgebase/collections`).catch(()=>({collections:[]})),staleTime:3e4,refetchInterval:6e4}),Re=Array.isArray(Le.data?.collections)?Le.data.collections:[];e(()=>{if(O)return;let e=String(m||``).trim();!E.trim()&&e&&D(e)},[E,O,m]),e(()=>{if(O||E.trim())return;let e=String(Re[0]?.collection_id||``).trim();e&&D(e)},[E,O,Re]),e(()=>{let e=ae.current;e&&(e.setAttribute(`webkitdirectory`,``),e.setAttribute(`directory`,``))},[]);let H=E.trim();e(()=>{Oe(1),Me([]),Ae(null),Ce(``),A(!0),j(!1),N(``)},[H]),e(()=>{Oe(1)},[xe]);let ze=(Math.max(1,P)-1)*Math.max(1,F),U=xe.trim(),W=o({queryKey:[`knowledgebase`,`documents`,H||`__all__`,U,P,F],enabled:V,queryFn:async()=>{let e=new URLSearchParams;return H&&e.set(`collection_id`,H),e.set(`limit`,String(Math.max(1,F))),e.set(`offset`,String(Math.max(0,ze))),U&&e.set(`query`,U),t(`/api/knowledgebase/documents?${e.toString()}`).catch(()=>({collection_id:H||null,documents:[],total:0,offset:ze,limit:F,has_more:!1}))},staleTime:15e3,refetchInterval:H?3e4:!1}),Be=W.data||{},G=n(()=>x(Be),[Be]),Ve=Math.max(0,Number(Be.total??G.length??0)),K=Math.max(1,Number(Be.limit??F)||F),q=Math.max(0,Number(Be.offset??ze)||ze),He=Math.max(1,Math.ceil(Math.max(Ve,G.length)/Math.max(1,F))),J=w(P,He),Ue=q,We=G,Ge=T(J,K,Ve);e(()=>{P!==J&&Oe(J)},[P,J]),e(()=>{k&&A(!0)},[k]);let Ke=Re,qe=n(()=>[...Ke].sort((e,t)=>String(e.collection_id).localeCompare(String(t.collection_id))),[Ke]),Je=n(()=>{let e=new Map,t=t=>{let n=typeof t==`string`?t.trim():String(t?.collection_id||``).trim();!n||e.has(n)||e.set(n,typeof t==`string`?{collection_id:n}:{...t,collection_id:n})};t(m);for(let e of qe)t(e);return t(H),Array.from(e.values()).sort((e,t)=>String(e.collection_id).localeCompare(String(t.collection_id)))},[qe,H,m]),Ye=Je.some(e=>String(e.collection_id||``).trim()===H)?H:`__custom__`,Xe=Ye===`__custom__`,Ze=n(()=>new Set(je.map(e=>e.key)),[je]),Qe=je,$e=Qe.length,Y=n(()=>I||null,[I]),et=String(Y?.slug||``).trim(),X=String(Y?.collection||``).trim(),Z=o({queryKey:[`knowledgebase`,`document`,X,et],enabled:V&&!!X&&!!et,queryFn:async()=>t(`/api/knowledgebase/documents/${encodeURIComponent(X)}/${encodeURIComponent(et)}`),staleTime:3e4}),Q=Z.data?.document||Z.data||null,tt=me(Q||Y),nt=String(Q?.title||Q?.filename||Q?.file_name||Y?.title||Y?.slug||`Document`).trim(),rt=String(Q?.path||Q?.doc_id||(Y?`${Y.collection}/${Y.slug}`:``)||``).trim(),$=String(Q?.content||Q?.excerpt||``),it=Z.error?Z.error instanceof Error?Z.error.message:String(Z.error):``,at=Number(Q?.updated_at||Q?.created_at||0),ot=Number(Q?.size_bytes||0),st=!!(X&&et),ct=Y?c(`div`,{className:`flex min-h-0 flex-col rounded-xl border border-white/10 bg-black/20 p-3`,children:[c(`div`,{className:`flex items-start justify-between gap-3`,children:[c(`div`,{className:`min-w-0`,children:[c(`div`,{className:`truncate text-sm font-semibold text-slate-100`,children:nt}),c(`div`,{className:`tcp-subtle mt-1 truncate text-xs`,children:rt||et||H})]}),c(`div`,{className:`flex flex-col items-end gap-2`,children:[c(f,{tone:`info`,children:X||H}),c(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[c(`button`,{type:`button`,className:`tcp-btn h-7 w-7 justify-center px-0`,title:`Refresh preview`,"aria-label":`Refresh preview`,onClick:()=>void Z.refetch(),disabled:!k,children:[c(`i`,{"data-lucide":`refresh-cw`}),c(`span`,{className:`sr-only`,children:`Refresh preview`})]}),c(`button`,{type:`button`,className:`tcp-btn h-7 w-7 justify-center px-0`,title:`Copy document content`,"aria-label":`Copy document content`,onClick:()=>void vt(),disabled:!$.trim(),children:[c(`i`,{"data-lucide":`copy`}),c(`span`,{className:`sr-only`,children:`Copy document content`})]}),c(`button`,{type:`button`,className:`tcp-btn h-7 w-7 justify-center border-rose-500/30 px-0 text-rose-200 hover:bg-rose-950/20`,title:`Delete document`,"aria-label":`Delete document`,onClick:()=>Pe({collection:X,slug:et,title:nt}),disabled:!st,children:[c(`i`,{"data-lucide":`trash-2`}),c(`span`,{className:`sr-only`,children:`Delete document`})]})]})]})]}),c(`div`,{className:`mt-3 grid grid-cols-3 gap-2 text-xs`,children:[c(`div`,{className:`rounded-lg border border-white/10 bg-black/10 p-2`,children:[c(`div`,{className:`tcp-subtle`,children:`Type`}),c(`div`,{className:`mt-1 font-medium`,children:String(Q?.content_type||tt||`text`)})]}),c(`div`,{className:`rounded-lg border border-white/10 bg-black/10 p-2`,children:[c(`div`,{className:`tcp-subtle`,children:`Updated`}),c(`div`,{className:`mt-1 font-medium`,children:fe(at)})]}),c(`div`,{className:`rounded-lg border border-white/10 bg-black/10 p-2`,children:[c(`div`,{className:`tcp-subtle`,children:`Size`}),c(`div`,{className:`mt-1 font-medium`,children:pe(ot)})]})]}),c(`div`,{className:`mt-3 rounded-xl border border-white/10 bg-black/10 p-3 text-xs`,children:[c(`div`,{className:`tcp-subtle uppercase tracking-wide`,children:`Excerpt`}),c(`div`,{className:`mt-1 whitespace-pre-wrap break-words text-slate-200`,children:String(Q?.excerpt||$.slice(0,600)||`No excerpt returned.`)})]}),Z.isLoading&&!Q?c(`div`,{className:`mt-3 rounded-xl border border-white/10 bg-black/20 p-3 text-sm tcp-subtle`,children:`Loading preview...`}):it?c(`div`,{className:`mt-3`,children:c(u,{title:`Preview unavailable`,text:it})}):Te?c(`div`,{className:`mt-3 flex min-h-0 flex-1 flex-col gap-3 rounded-xl border border-sky-500/30 bg-sky-950/10 p-3`,children:[c(`div`,{className:`flex items-center justify-between gap-3`,children:[c(`div`,{className:`tcp-subtle text-xs uppercase tracking-wide`,children:`Edit document in place`}),c(`div`,{className:`flex flex-wrap gap-2`,children:[c(`button`,{type:`button`,className:`tcp-btn h-7 px-2 text-xs`,onClick:()=>{j(!1),N(``),M(String($||``))},children:`Cancel`}),c(`button`,{type:`button`,className:`tcp-btn h-7 px-2 text-xs`,onClick:()=>void yt(),children:[c(`i`,{"data-lucide":`save`}),`Save`]})]})]}),De?c(`div`,{className:`rounded-lg border border-rose-500/30 bg-rose-950/20 p-2 text-xs text-rose-200`,children:De}):null,c(`textarea`,{className:`tcp-input min-h-[340px] flex-1 resize-none font-mono text-xs leading-6`,value:Ee,onChange:e=>M(e.target.value),spellCheck:!1})]}):we?c(`div`,{className:`mt-3 flex min-h-0 flex-1 flex-col gap-3 rounded-xl border border-white/10 bg-black/20 p-3`,children:[c(`div`,{className:`flex items-center justify-between gap-3`,children:[c(`div`,{className:`tcp-subtle text-xs uppercase tracking-wide`,children:`Document content`}),c(`div`,{className:`flex flex-wrap gap-2`,children:[c(`button`,{type:`button`,className:`tcp-btn h-7 w-7 justify-center px-0`,title:`Edit document`,"aria-label":`Edit document`,onClick:()=>{N(``),j(!0),M(String($||``))},disabled:!$.trim(),children:[c(`i`,{"data-lucide":`square-pen`}),c(`span`,{className:`sr-only`,children:`Edit document`})]}),c(`button`,{type:`button`,className:`tcp-btn h-7 w-7 justify-center px-0`,title:`Collapse preview`,"aria-label":`Collapse preview`,onClick:()=>A(!1),children:[c(`i`,{"data-lucide":`chevron-up`}),c(`span`,{className:`sr-only`,children:`Collapse preview`})]})]})]}),c(`div`,{className:`min-h-0 flex-1 overflow-auto rounded-xl border border-white/10 bg-black/20 p-3`,children:$?tt===`markdown`?c(`div`,{className:`tcp-markdown tcp-markdown-ai`,dangerouslySetInnerHTML:{__html:re($)}}):c(`pre`,{className:`tcp-code whitespace-pre-wrap break-words`,children:$}):c(u,{title:`No preview content`,text:`This document did not return preview text from the KB service.`})})]}):c(u,{title:`Preview collapsed`,text:`Open the document content when you want to inspect or edit it. The list stays compact until you expand a file.`,action:c(`div`,{className:`flex flex-wrap gap-2`,children:[c(`button`,{type:`button`,className:`tcp-btn h-8 w-8 justify-center px-0`,title:`Open content`,"aria-label":`Open content`,onClick:()=>A(!0),children:[c(`i`,{"data-lucide":`chevron-down`}),c(`span`,{className:`sr-only`,children:`Open content`})]}),c(`button`,{type:`button`,className:`tcp-btn h-8 w-8 justify-center px-0`,title:`Edit in place`,"aria-label":`Edit in place`,onClick:()=>{A(!0),N(``),j(!0),M(String($||``))},disabled:!$.trim(),children:[c(`i`,{"data-lucide":`square-pen`}),c(`span`,{className:`sr-only`,children:`Edit in place`})]})]})})]}):null;e(()=>{Te||M(String($||``))},[Te,$,k]);let lt=R.filter(e=>e.status===`done`||e.status===`error`);e(()=>{for(let e of R){if(e.status!==`done`&&e.status!==`error`||_.current.has(e.id))continue;let t=se.current.get(e.id)??he.current++%6;se.current.set(e.id,t);let n=3e3+t*350,r=window.setTimeout(()=>{z(t=>t.filter(t=>t.id!==e.id)),_.current.delete(e.id),se.current.delete(e.id)},n);_.current.set(e.id,r)}let e=new Set(R.map(e=>e.id));for(let[t,n]of _.current.entries())e.has(t)||(window.clearTimeout(n),_.current.delete(t),se.current.delete(t))},[R]),e(()=>()=>{for(let e of _.current.values())window.clearTimeout(e);_.current.clear(),se.current.clear()},[]),e(()=>{g.current&&ne(g.current)},[qe.length,Je.length,R.length,P,F,Ve,q,K,H,Ie,V,G.length,We.length,k,I,$e,xe,Z.data,Z.isFetching,we,Te,_e,ye]);let ut=()=>{for(let e of R){if(e.status!==`done`&&e.status!==`error`)continue;let t=_.current.get(e.id);typeof t==`number`&&window.clearTimeout(t),_.current.delete(e.id),se.current.delete(e.id)}z(e=>e.filter(e=>e.status===`queued`||e.status===`uploading`))},dt=s({mutationFn:({file:e,targetCollection:t})=>new Promise((n,r)=>{let i=le();z(t=>[...t,{id:i,name:e.name,progress:0,status:`queued`,error:``}]);let a=new XMLHttpRequest;a.open(`POST`,`/api/knowledgebase/documents`),a.withCredentials=!0,a.responseType=`json`;let o=new FormData;o.set(`collection_id`,t),o.set(`title`,ue(e.name)),o.set(`file`,e,e.name),a.upload.onprogress=e=>{if(!e.lengthComputable)return;let t=e.loaded/e.total*100;z(e=>e.map(e=>e.id===i?{...e,status:`uploading`,progress:t}:e))},a.onerror=()=>{z(e=>e.map(e=>e.id===i?{...e,status:`error`,error:`Network error`,progress:Math.max(e.progress,4)}:e)),r(Error(`KB upload failed: ${e.name}`))},a.onload=()=>{let o=a.response||{};if(a.status<200||a.status>=300||o?.ok===!1){let e=String(o?.error||`Upload failed (${a.status})`);z(t=>t.map(t=>t.id===i?{...t,status:`error`,error:e,progress:Math.max(t.progress,4)}:t)),r(Error(e));return}let s=o?.document&&typeof o.document==`object`?o.document:o?.doc||o?.item||{},c=String(s?.doc_id||s?.id||o?.doc_id||``).trim(),ee=String(s?.collection_id||t).trim(),l=String(s?.title||s?.filename||s?.file_name||ue(e.name)||e.name).trim();z(e=>e.map(e=>e.id===i?{...e,status:`done`,progress:100,error:``,result:{docId:c,collectionId:ee,title:l}}:e)),n(o)},z(e=>e.map(e=>e.id===i?{...e,status:`uploading`}:e)),a.send(o)})}),ft=async e=>{let t=[...e||[]],n=E.trim();if(!V||!t.length)return;if(!n){p(`warn`,`Choose a knowledgebase collection first.`);return}B(!0);let r=0,i=0,a=0;try{let e=Array.from({length:Math.min(v,t.length)},async()=>{for(;;){let e=a;if(a+=1,e>=t.length)return;let o=t[e];try{await dt.mutateAsync({file:o,targetCollection:n}),r+=1}catch{i+=1}}});await Promise.all(e),await h.invalidateQueries({queryKey:[`knowledgebase`,`collections`]}),await h.invalidateQueries({queryKey:[`knowledgebase`,`documents`]}),r&&i?p(`warn`,`Uploaded ${r} file(s) to ${n}; ${i} failed.`):r?p(`ok`,`Uploaded ${r} file(s) to ${n}.`):i&&p(`err`,`All ${i} KB upload(s) failed.`)}finally{B(!1)}},pt=async()=>{try{await t(`/api/knowledgebase/reindex`,{method:`POST`}),p(`ok`,`Knowledgebase reindex requested.`)}catch(e){p(`err`,e instanceof Error?e.message:String(e))}},mt=e=>{let t=String(S(e)||H).trim(),n=C(e),r=de(e);return!t||!n||!r?null:{collection:t,slug:n,title:String(e.title||e.filename||e.file_name||e.doc_id||n).trim(),key:r}},ht=e=>{let t=mt(e);t&&Me(e=>e.some(e=>e.key===t.key)?e.filter(e=>e.key!==t.key):[...e,t])},gt=()=>{let e=G.map(e=>mt(e)).filter(e=>!!e);Me(t=>{let n=new Map(t.map(e=>[e.key,e]));for(let t of e)n.set(t.key,t);return[...n.values()]})},_t=()=>{Me([])},vt=async()=>{let e=String($||``).trim();if(!e){p(`warn`,`No document content is available to copy.`);return}try{await navigator.clipboard.writeText(e),p(`ok`,`Document content copied to clipboard.`)}catch{p(`warn`,`Could not copy the document content.`)}},yt=async()=>{let e=String(X||``).trim(),t=String(et||``).trim();if(!e||!t){p(`warn`,`Pick a document before saving edits.`);return}N(``);try{let n=new FormData;n.set(`title`,String(nt||``).trim()||t),n.set(`content`,Ee);let r=await fetch(`/api/knowledgebase/documents/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{method:`PUT`,credentials:`include`,body:n}),i=await r.text(),a={};if(i)try{a=JSON.parse(i)}catch{a={}}if(!r.ok||a?.ok===!1){let e=String(a?.error||i||`Update failed (${r.status})`);throw Error(e)}j(!1),A(!0),p(`ok`,`Document updated.`),await h.invalidateQueries({queryKey:[`knowledgebase`,`documents`]}),await h.invalidateQueries({queryKey:[`knowledgebase`,`document`]}),await W.refetch(),await Z.refetch()}catch(e){let t=e instanceof Error?e.message:String(e);N(t),p(`err`,t)}},bt=()=>{if(!Qe.length){p(`warn`,`Select one or more documents first.`);return}Fe({documents:Qe.map(({collection:e,slug:t,title:n,key:r})=>({collection:e,slug:t,title:n,key:r}))})},xt=async()=>{let e=String(Ne?.collection||``).trim(),t=String(Ne?.slug||``).trim();if(!e||!t){p(`warn`,`Pick a document before deleting it.`);return}try{let n=await fetch(`/api/knowledgebase/documents/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{method:`DELETE`,credentials:`include`}),r=await n.text(),i={};if(r)try{i=JSON.parse(r)}catch{i={}}if(!n.ok||i?.ok===!1){let e=String(i?.error||r||`Delete failed (${n.status})`);throw Error(e)}let a=I?.key||``;Ce(``),Ae(null),Me(e=>e.filter(e=>e.key!==a)),A(!1),j(!1),M(``),N(``),Pe(null),p(`ok`,`Document deleted.`),await h.invalidateQueries({queryKey:[`knowledgebase`,`collections`]}),await h.invalidateQueries({queryKey:[`knowledgebase`,`documents`]}),await W.refetch()}catch(e){p(`err`,e instanceof Error?e.message:String(e))}},St=async()=>{let e=L?.documents||[];if(!e.length){p(`warn`,`Select one or more documents first.`);return}let t=new Map(je.map(e=>[e.key,e])),n=0,r=0;try{for(let i of e)try{let e=await fetch(`/api/knowledgebase/documents/${encodeURIComponent(i.collection)}/${encodeURIComponent(i.slug)}`,{method:`DELETE`,credentials:`include`}),r=await e.text(),a={};if(r)try{a=JSON.parse(r)}catch{a={}}if(!e.ok||a?.ok===!1){let t=String(a?.error||r||`Delete failed (${e.status})`);throw Error(t)}n+=1,t.delete(i.key)}catch{r+=1}Me([...t.values()]),I?.key&&!t.has(I.key)&&(Ce(``),Ae(null),A(!1),j(!1),M(``),N(``)),Fe(null),n&&r?p(`warn`,`Deleted ${n} document(s); ${r} failed.`):n?p(`ok`,`Deleted ${n} document(s).`):p(`err`,`All ${r} selected document deletions failed.`),await h.invalidateQueries({queryKey:[`knowledgebase`,`collections`]}),await h.invalidateQueries({queryKey:[`knowledgebase`,`documents`]}),await W.refetch()}catch(e){p(`err`,e instanceof Error?e.message:String(e))}};return V?c(te,{className:`overflow-hidden`,title:`Knowledgebase`,subtitle:`Provisioned-server docs live in KB collections searched through MCP, not in the file buckets below.`,actions:c(d,{className:`justify-start`,children:[c(`button`,{type:`button`,className:`tcp-icon-btn`,title:`Upload documents`,"aria-label":`Upload documents`,onClick:()=>ie.current?.click(),disabled:Ie,children:c(`i`,{"data-lucide":`upload`})}),c(`button`,{type:`button`,className:`tcp-icon-btn`,title:`Upload folder`,"aria-label":`Upload folder`,onClick:()=>ae.current?.click(),disabled:Ie,children:c(`i`,{"data-lucide":`folder-up`})}),c(`button`,{type:`button`,className:`tcp-icon-btn`,title:`Refresh collections`,"aria-label":`Refresh collections`,onClick:()=>void Le.refetch(),children:c(`i`,{"data-lucide":`refresh-cw`})}),c(`button`,{type:`button`,className:`tcp-icon-btn`,title:`Reindex knowledgebase`,"aria-label":`Reindex knowledgebase`,onClick:pt,children:c(`i`,{"data-lucide":`sparkles`})}),c(`button`,{type:`button`,className:`tcp-icon-btn`,title:_e?`Expand knowledgebase`:`Collapse knowledgebase`,"aria-label":_e?`Expand knowledgebase`:`Collapse knowledgebase`,onClick:()=>ve(e=>!e),children:c(`i`,{"data-lucide":_e?`chevron-down`:`chevron-up`})})]}),children:c(`div`,{ref:g,className:_e?`hidden`:`grid gap-4 p-4`,children:[c(`div`,{className:`grid gap-2`,children:[c(`label`,{className:`tcp-subtle text-xs uppercase tracking-wide`,htmlFor:`kb-collection-select`,children:`Collection`}),c(`div`,{className:`flex flex-col gap-2 lg:flex-row lg:items-center`,children:[c(`div`,{className:`relative min-w-[min(100%,18rem)] flex-1`,children:[c(`select`,{id:`kb-collection-select`,className:`tcp-select h-10 w-full appearance-none pr-10 font-semibold text-slate-100`,value:Ye,onChange:e=>{let t=e.target.value;if(ge(!0),t===`__custom__`){D(``);return}D(t)},children:[Je.length?Je.map(e=>{let t=String(e.collection_id||``).trim();return c(`option`,{value:t,children:[t,typeof e.document_count==`number`?` (${e.document_count})`:``]},t)}):c(`option`,{value:``,children:`No collections yet`}),c(`option`,{value:`__custom__`,children:`Create new collection...`})]}),c(`i`,{"data-lucide":`chevron-down`,className:`pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 text-slate-400`})]}),Xe?c(`input`,{id:`kb-collection-id`,className:`tcp-input h-10 min-w-[min(100%,18rem)] flex-1`,value:E,onChange:e=>{ge(!0),D(e.target.value)},placeholder:`new-customer-collection`,spellCheck:!1}):c(`button`,{type:`button`,className:`tcp-icon-btn h-10 w-10 shrink-0`,title:`Create a new collection`,"aria-label":`Create a new collection`,onClick:()=>{ge(!0),D(``)},children:c(`i`,{"data-lucide":`plus`})}),c(`div`,{className:`flex shrink-0 gap-2`,children:[c(`input`,{ref:ie,type:`file`,multiple:!0,accept:y,className:`hidden`,onChange:e=>{ft(e.target.files),e.currentTarget.value=``}}),c(`input`,{ref:ae,type:`file`,multiple:!0,accept:y,className:`hidden`,onChange:e=>{ft(e.target.files),e.currentTarget.value=``}}),c(`button`,{type:`button`,className:`tcp-icon-btn h-10 w-10`,title:`Select files`,"aria-label":`Select files`,onClick:()=>ie.current?.click(),disabled:!H||Ie,children:c(`i`,{"data-lucide":`files`})}),c(`button`,{type:`button`,className:`tcp-icon-btn h-10 w-10`,onClick:()=>ae.current?.click(),disabled:!H||Ie,title:`Select a local folder and upload all matching docs inside it`,"aria-label":`Select a local folder`,children:c(`i`,{"data-lucide":`folder-open`})})]})]}),c(`div`,{className:`tcp-subtle text-xs`,children:`Pick an existing KB MCP collection, or type a new collection ID before uploading.`})]}),c(`div`,{className:`rounded-xl border border-white/10 bg-black/20 p-3 text-sm`,children:[c(`div`,{className:`font-medium text-slate-100`,children:`How this works`}),c(`div`,{className:`tcp-subtle mt-1`,children:"The KB MCP reads from collections in the hosted knowledgebase service. It does not browse a raw server folder directly, so uploads here will not appear in the managed `Files` buckets below unless you upload them there separately."})]}),R.length?c(`div`,{className:`grid gap-2`,children:[c(`div`,{className:`flex items-center justify-between gap-3`,children:[c(`div`,{className:`tcp-subtle text-xs uppercase tracking-wide`,children:`Upload history`}),lt.length?c(`button`,{type:`button`,className:`tcp-icon-btn h-7 w-7`,title:`Clear finished uploads`,"aria-label":`Clear finished uploads`,onClick:ut,children:c(`i`,{"data-lucide":`x`})}):null]}),c(`div`,{className:`grid gap-2`,children:R.map(e=>c(`div`,{className:`rounded-xl border border-white/10 bg-black/20 p-3 text-xs`,children:[c(`div`,{className:`flex items-center justify-between gap-3`,children:[c(`div`,{className:`min-w-0`,children:[c(`div`,{className:`truncate font-medium`,children:e.name}),c(`div`,{className:`tcp-subtle mt-1 truncate`,children:[e.result?.collectionId||H||`collection`,` •`,` `,e.status]}),e.result?.docId?c(`div`,{className:`tcp-subtle mt-1 truncate text-[11px]`,children:e.result.docId}):null]}),c(f,{tone:e.status===`done`?`ok`:e.status===`error`?`err`:`info`,children:[Math.round(e.progress),`%`]})]}),c(`div`,{className:`mt-2 h-1.5 overflow-hidden rounded-full bg-white/10`,children:c(`div`,{className:`h-full rounded-full ${e.status===`error`?`bg-rose-400`:e.status===`done`?`bg-emerald-400`:`bg-sky-400`}`,style:{width:`${Math.max(4,Math.min(100,e.progress||0))}%`}})}),e.error?c(`div`,{className:`mt-2 text-rose-200`,children:e.error}):null]},e.id))})]}):null,c(`div`,{className:`grid gap-2`,children:[c(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[c(`div`,{children:[c(`div`,{className:`tcp-subtle text-xs uppercase tracking-wide`,children:`Collection documents`}),c(`div`,{className:`tcp-subtle mt-1 text-xs`,children:`Showing what the selected KB collection currently contains.`})]}),c(`div`,{className:`flex flex-wrap items-center gap-2`,children:[c(f,{tone:`ghost`,children:Ve}),c(f,{tone:$e?`info`:`ghost`,children:[$e,` selected`]}),c(`button`,{type:`button`,className:`tcp-icon-btn h-8 w-8`,title:`Refresh documents`,"aria-label":`Refresh documents`,onClick:()=>void W.refetch(),disabled:!H,children:c(`i`,{"data-lucide":`refresh-cw`})}),c(`button`,{type:`button`,className:`tcp-icon-btn h-8 w-8`,title:ye?`Expand collection documents`:`Collapse collection documents`,"aria-label":ye?`Expand collection documents`:`Collapse collection documents`,onClick:()=>be(e=>!e),children:c(`i`,{"data-lucide":ye?`chevron-down`:`chevron-up`})})]})]}),ye?c(`div`,{className:`rounded-xl border border-white/10 bg-black/20 p-3 text-sm tcp-subtle`,children:`Collection documents are collapsed.`}):H?W.isFetching&&!G.length?c(`div`,{className:`rounded-xl border border-white/10 bg-black/20 p-3 text-sm tcp-subtle`,children:[`Loading documents from`,` `,c(`span`,{className:`font-medium text-slate-200`,children:H}),`.`]}):G.length?c(`div`,{className:`grid gap-4`,children:c(`div`,{className:`grid min-h-0 gap-3`,children:[c(`div`,{className:`grid gap-2 rounded-xl border border-white/10 bg-black/20 p-3`,children:[c(`div`,{className:`flex flex-wrap items-center gap-2`,children:[c(`input`,{className:`tcp-input h-9 min-w-[220px] flex-1`,value:xe,onChange:e=>Se(e.target.value),placeholder:`Filter documents`,spellCheck:!1}),c(f,{tone:`ghost`,children:Ge})]}),c(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[c(`div`,{className:`flex flex-wrap items-center gap-2`,children:[c(`button`,{type:`button`,className:`tcp-icon-btn h-8 w-8`,title:`Select all visible documents`,"aria-label":`Select all visible documents`,onClick:gt,disabled:!G.length,children:c(`i`,{"data-lucide":`square-check-big`})}),c(`button`,{type:`button`,className:`tcp-icon-btn h-8 w-8`,title:`Clear selected documents`,"aria-label":`Clear selected documents`,onClick:_t,disabled:!$e,children:c(`i`,{"data-lucide":`x`})}),c(`button`,{type:`button`,className:`tcp-icon-btn h-8 w-8 border-rose-500/30 text-rose-100 hover:bg-rose-950/20 disabled:opacity-50`,title:`Delete selected documents`,"aria-label":`Delete selected documents`,onClick:bt,disabled:!$e,children:c(`i`,{"data-lucide":`trash-2`})})]}),c(`div`,{className:`flex flex-wrap items-center gap-2`,children:[c(`label`,{className:`flex items-center gap-2 text-[11px] uppercase tracking-wide text-slate-500`,children:[c(`span`,{children:`Per page`}),c(`select`,{className:`tcp-select h-8 min-w-[5.5rem] px-3 text-center text-sm font-semibold tabular-nums text-slate-100 [text-align-last:center]`,value:F,onChange:e=>{ke(Number(e.target.value)||ce),Oe(1)},children:b.map(e=>c(`option`,{value:e,children:e},e))})]}),c(`button`,{type:`button`,className:`tcp-icon-btn h-8 w-8`,title:`Previous page`,"aria-label":`Previous page`,onClick:()=>Oe(e=>w(e-1,He)),disabled:J<=1,children:c(`i`,{"data-lucide":`chevron-left`})}),c(`button`,{type:`button`,className:`tcp-icon-btn h-8 w-8`,title:`Next page`,"aria-label":`Next page`,onClick:()=>Oe(e=>w(e+1,He)),disabled:J>=He,children:c(`i`,{"data-lucide":`chevron-right`})})]})]})]}),We.length?c(`div`,{className:`grid gap-2`,children:We.map((e,t)=>{let n=String(e.doc_id||e.id||``).trim(),r=String(e.title||e.filename||e.file_name||n||`Document ${Ue+t+1}`).trim(),i=String(e.collection_id||H).trim(),a=Number(e.updated_at||e.created_at||0),o=de(e),s=!!o,u=s&&Ze.has(o),d=o===k;return c(ee.div,{layout:!0,children:c(`div`,{className:`flex items-start gap-3`,children:[c(`label`,{className:`mt-3 flex h-6 w-6 items-center justify-center rounded border ${s?`border-white/15 bg-black/20 text-slate-200 cursor-pointer hover:border-sky-500/40`:`border-white/10 bg-black/10 text-slate-500`}`,children:c(`input`,{type:`checkbox`,className:`h-4 w-4 accent-sky-400`,checked:u,disabled:!s,onChange:()=>ht(e),"aria-label":`Select ${r}`})}),c(`div`,{className:`min-w-0 flex-1`,children:[c(`button`,{type:`button`,className:`w-full rounded-xl border p-3 text-left text-sm transition ${d?`border-sky-500/50 bg-sky-950/20`:u?`border-emerald-500/40 bg-emerald-950/20 hover:border-emerald-400/50 hover:bg-emerald-950/30`:`border-white/10 bg-black/20 hover:border-white/20 hover:bg-black/30`}`.trim(),onClick:()=>{let t=mt(e);if(d){Ce(``),Ae(null),A(!1),j(!1),N(``);return}Ce(o),t&&Ae(t),A(!0),j(!1),N(``)},"aria-expanded":d,children:[c(`div`,{className:`flex items-start justify-between gap-3`,children:[c(`div`,{className:`min-w-0`,children:[c(`div`,{className:`truncate font-medium text-slate-100`,children:r}),c(`div`,{className:`tcp-subtle mt-1 truncate text-xs`,children:n||`${i}/${r}`})]}),c(f,{tone:d?`ok`:u?`info`:`ghost`,children:i})]}),c(`div`,{className:`mt-2 flex flex-wrap gap-2 text-xs tcp-subtle`,children:[c(`span`,{children:[`Updated: `,fe(a)]}),e.content_type?c(`span`,{children:e.content_type}):null]})]}),c(l,{initial:!1,children:d?c(ee.div,{initial:{opacity:0,height:0,y:-8},animate:{opacity:1,height:`auto`,y:0},exit:{opacity:0,height:0,y:-8},transition:{duration:.22,ease:`easeOut`},className:`overflow-hidden`,children:c(`div`,{className:`mt-2`,children:ct})},`${k}-expanded`):null})]})]})},n||`${i}-${r}-${t}`)})}):c(u,{title:U?`No documents match your filter`:`No documents found`,text:U?`Try another search term or clear the filter to show the full collection.`:`This collection does not contain any documents yet.`,action:U?c(`button`,{type:`button`,className:`tcp-btn h-8 px-3 text-xs`,onClick:()=>Se(``),children:`Clear filter`}):null})]})}):c(`div`,{className:`rounded-xl border border-white/10 bg-black/20 p-3 text-sm tcp-subtle`,children:[`No visible documents returned for`,` `,c(`span`,{className:`font-medium text-slate-200`,children:H}),`. If you just uploaded a file, refresh docs or reindex and confirm the KB admin service exposes document listing for that collection.`]}):c(`div`,{className:`rounded-xl border border-white/10 bg-black/20 p-3 text-sm tcp-subtle`,children:`Pick or type a collection ID to inspect its documents.`})]}),c(oe,{open:!!Ne,title:`Delete document`,message:c(`span`,{children:[`This will permanently remove`,` `,c(`strong`,{children:Ne?.title||`this document`}),` from`,` `,c(`strong`,{children:Ne?.collection||H||`the selected collection`}),`.`]}),confirmLabel:`Delete document`,confirmIcon:`trash-2`,confirmTone:`danger`,onCancel:()=>Pe(null),onConfirm:()=>void xt()}),c(oe,{open:!!L,title:`Delete selected documents`,message:c(`span`,{children:[`This will permanently remove`,` `,c(`strong`,{children:[L?.documents.length||0,` selected document(s)`]}),` from`,` `,c(`strong`,{children:H||`the selected collection`}),`.`]}),confirmLabel:`Delete selected`,confirmIcon:`trash-2`,confirmTone:`danger`,widthClassName:`w-[min(42rem,96vw)]`,onCancel:()=>Fe(null),onConfirm:()=>void St(),children:L?.documents.length?c(`div`,{className:`mt-3 grid gap-2 rounded-xl border border-white/10 bg-black/20 p-3 text-left text-xs`,children:[c(`div`,{className:`tcp-subtle uppercase tracking-wide`,children:`Selected documents`}),c(`div`,{className:`max-h-40 overflow-auto`,children:[L.documents.slice(0,12).map(e=>c(`div`,{className:`truncate py-1`,children:[c(`span`,{className:`font-medium text-slate-100`,children:e.title||e.slug}),c(`span`,{className:`tcp-subtle`,children:[` `,`· `,e.collection,`/`,e.slug]})]},`${e.collection}|${e.slug}`)),L.documents.length>12?c(`div`,{className:`pt-1 text-slate-400`,children:[`+`,L.documents.length-12,` more`]}):null]})]}):null})]})}):null}var E=`__global__`;function D(e){return e===`collection`?`Collection override`:e===`global`?`Global override`:`Default`}function O(e){return e===`collection`?`ok`:e===`global`?`info`:`warn`}function ge({api:r,toast:ee}){let l=a(),[u,p]=i(!0),[m,h]=i(E),[re,g]=i({}),[ie,ae]=i({}),[_,se]=i({}),[v,y]=i(null),b=o({queryKey:[`knowledgebase`,`config`],queryFn:async()=>r(`/api/knowledgebase/config`).catch(()=>({configured:!1})),staleTime:6e4}).data?.configured===!0,ce=o({queryKey:[`knowledgebase`,`collections`],enabled:b,queryFn:async()=>r(`/api/knowledgebase/collections`).catch(()=>({collections:[]})),staleTime:3e4}),le=Array.isArray(ce.data?.collections)?ce.data.collections:[],ue=m===E?``:m,x=o({queryKey:[`knowledgebase`,`prompts`,ue||`__global__`],enabled:b&&!u,queryFn:async()=>await r(`/api/knowledgebase/prompts${ue?`?collection_id=${encodeURIComponent(ue)}`:``}`)}),S=x.data?.prompts||[];e(()=>{let e=x.data?.prompts||[];e.length&&g(t=>{let n={...t};for(let t of e)t.key in n||(n[t.key]=m===E?t.global_override??t.default:t.collection_override??t.global_override??t.default);return n})},[x.dataUpdatedAt,m]),e(()=>{g({})},[m]);let de=s({mutationFn:async({key:e,value:t,collection_id:n})=>{let i={value:t};return n&&(i.collection_id=n),r(`/api/knowledgebase/prompts/${encodeURIComponent(e)}`,{method:`PUT`,body:JSON.stringify(i)})},onSuccess:async(e,t)=>{ee(`ok`,`Saved prompt "${t.key}".`),await l.invalidateQueries({queryKey:[`knowledgebase`,`prompts`]}),g(e=>{let n={...e};return delete n[t.key],n})},onError:e=>{ee(`err`,`Save failed: ${e?.message||`Save failed.`}`)}}),fe=s({mutationFn:async({key:e,collection_id:t})=>{let n=t?`?collection_id=${encodeURIComponent(t)}`:``;return r(`/api/knowledgebase/prompts/${encodeURIComponent(e)}${n}`,{method:`DELETE`})},onSuccess:async(e,t)=>{ee(`ok`,t.collection_id?`Reverted "${t.key}" for collection "${t.collection_id}".`:`Reverted global "${t.key}" to default.`),await l.invalidateQueries({queryKey:[`knowledgebase`,`prompts`]}),g(e=>{let n={...e};return delete n[t.key],n})},onError:e=>{ee(`err`,`Reset failed: ${e?.message||`Reset failed.`}`)}}),pe=n(()=>le.map(e=>String(e.collection_id||``).trim()).filter(Boolean).sort(),[le]);return b?c(te,{title:`Agent prompts`,subtitle:`Edit how the AI agent answers questions from this knowledgebase. Defaults are shipped in code; overrides take effect on the next agent session or answer_question call.`,actions:c(d,{className:`justify-end`,children:c(`button`,{type:`button`,className:`tcp-btn h-8 w-8 justify-center px-0`,title:u?`Expand prompts`:`Collapse prompts`,"aria-label":u?`Expand prompts`:`Collapse prompts`,onClick:()=>p(e=>!e),ref:e=>{e&&ne(e)},children:c(`i`,{"data-lucide":u?`chevron-down`:`chevron-up`,"aria-hidden":`true`})})}),children:[u?null:c(`div`,{className:`flex flex-col gap-4`,children:[c(`div`,{className:`flex flex-wrap items-center gap-3 rounded-lg border border-white/10 bg-black/20 p-3 text-sm`,children:[c(`label`,{className:`flex items-center gap-2`,children:[c(`span`,{className:`tcp-subtle`,children:`Scope:`}),c(`select`,{className:`tcp-input h-8 px-2`,value:m,onChange:e=>h(e.target.value),children:[c(`option`,{value:E,children:`Global (all collections)`}),pe.map(e=>c(`option`,{value:e,children:[`Collection: `,e]},e))]})]}),c(`span`,{className:`tcp-subtle text-xs`,children:m===E?`Global overrides apply to every collection unless a collection-specific override exists.`:`Editing overrides for collection "${m}". Collection overrides take precedence over global ones.`})]}),x.isLoading?c(`div`,{className:`tcp-subtle p-4 text-sm`,children:`Loading prompts…`}):x.isError?c(`div`,{className:`rounded-lg border border-rose-500/30 bg-rose-950/20 p-3 text-sm text-rose-200`,children:[`Failed to load prompts: `,x.error?.message||`Unknown error.`]}):S.length===0?c(`div`,{className:`tcp-subtle p-4 text-sm`,children:`No prompts available.`}):c(`div`,{className:`flex flex-col gap-3`,children:S.map(e=>{let t=!!ie[e.key],n=re[e.key]??e.current,r=m!==E&&!e.supports_collection_override,i=m===E?e.global_override!==null:e.collection_override!==null,a=!!_[e.key],o=n!==(m===E?e.global_override??e.default:e.collection_override??e.global_override??e.default);return c(`div`,{className:`rounded-lg border border-white/10 bg-black/20 p-3`,children:[c(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[c(`div`,{className:`flex flex-col`,children:[c(`div`,{className:`flex flex-wrap items-center gap-2`,children:[c(`span`,{className:`font-mono text-sm`,children:e.key}),c(f,{tone:O(e.scope),children:D(e.scope)}),e.supports_collection_override?null:c(f,{tone:`warn`,children:`Global only`}),e.collection_overrides.length>0?c(`span`,{className:`tcp-subtle text-xs`,children:[e.collection_overrides.length,` collection override`,e.collection_overrides.length===1?``:`s`]}):null]}),c(`div`,{className:`tcp-subtle mt-1 text-xs`,children:e.description})]}),c(d,{className:`justify-end`,children:c(`button`,{type:`button`,className:`tcp-btn h-7 px-2 text-xs`,onClick:()=>ae(t=>({...t,[e.key]:!t[e.key]})),children:t?`Collapse`:`Edit`})})]}),t?c(`div`,{className:`mt-3 flex flex-col gap-2`,children:[r?c(`div`,{className:`rounded border border-amber-500/30 bg-amber-950/20 p-2 text-xs text-amber-200`,children:`This prompt is global only — it is sent before any collection is selected, so per-collection overrides are not supported. Switch scope back to Global to edit it.`}):null,c(`div`,{className:`flex items-center gap-2`,children:[c(`button`,{type:`button`,className:`tcp-btn h-7 px-2 text-xs`,onClick:()=>se(t=>({...t,[e.key]:!t[e.key]})),children:a?`Hide default`:`Show default`}),e.global_override!==null&&m!==E?c(`span`,{className:`tcp-subtle text-xs`,children:`Inherits a global override when no collection override is set.`}):null]}),a?c(`div`,{className:`rounded border border-white/10 bg-black/30 p-2`,children:[c(`div`,{className:`tcp-subtle text-[10px] uppercase tracking-wide`,children:`Built-in default`}),c(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs leading-5`,children:e.default})]}):null,c(`textarea`,{className:`tcp-input min-h-[200px] resize-y font-mono text-xs leading-6`,value:n,disabled:r,onChange:t=>g(n=>({...n,[e.key]:t.target.value}))}),c(`div`,{className:`flex flex-wrap items-center gap-2`,children:[c(`button`,{type:`button`,className:`tcp-btn h-8 px-3 text-xs`,disabled:r||!o||!n.trim()||de.isPending,onClick:()=>de.mutate({key:e.key,value:n,collection_id:m===E?void 0:m}),children:[`Save `,m===E?`global`:`collection`,` override`]}),c(`button`,{type:`button`,className:`tcp-btn h-8 px-3 text-xs`,disabled:r||!i||fe.isPending,onClick:()=>y({key:e.key,collectionId:m===E?null:m}),children:[`Reset `,m===E?`global`:`collection`,` to default`]}),o?c(`button`,{type:`button`,className:`tcp-btn h-8 px-3 text-xs`,onClick:()=>g(t=>{let n={...t};return delete n[e.key],n}),children:`Discard changes`}):null]}),e.collection_overrides.length>0?c(`div`,{className:`mt-1 rounded border border-white/10 bg-black/30 p-2 text-xs`,children:[c(`div`,{className:`tcp-subtle uppercase tracking-wide`,children:`Collections with overrides`}),c(`ul`,{className:`mt-1 flex flex-wrap gap-2`,children:e.collection_overrides.map(e=>c(`li`,{children:c(`button`,{type:`button`,className:`tcp-btn h-6 px-2 text-[11px]`,onClick:()=>h(e.collection_id),children:e.collection_id})},e.collection_id))})]}):null]}):null]},e.key)})})]}),c(oe,{open:v!==null,title:`Reset prompt to default?`,message:v?c(`span`,{children:v.collectionId?c(t,{children:[`This removes the override for `,c(`code`,{children:v.key}),` on collection`,` `,c(`code`,{children:v.collectionId}),`. The agent will fall back to the global override (if any) or the built-in default for this collection. Other collections are unaffected.`]}):c(t,{children:[`This removes the global override for `,c(`code`,{children:v.key}),`. The agent will fall back to the built-in default. Per-collection overrides for this prompt remain in place.`]})}):``,confirmLabel:`Reset`,confirmIcon:`rotate-ccw`,confirmTone:`danger`,confirmDisabled:fe.isPending,onCancel:()=>y(null),onConfirm:()=>{v&&(fe.mutate({key:v.key,collection_id:v.collectionId??void 0}),y(null))}})]}):null}var _e=[`uploads`,`artifacts`,`exports`],ve=new Set([`text`,`markdown`,`json`,`yaml`]),ye=[10,25,50,100],be=25;function xe(e){let t=Number(e||0);return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/1024/1024).toFixed(1)} MB`}function Se(e){let t=Number(e||0);return t?new Date(t).toLocaleString():`n/a`}function k(e,t){return Array.isArray(e)?e:Array.isArray(e?.[t])?e[t]:[]}function Ce(e){let t=String(e||``).trim();return t?t.split(`/`).filter(Boolean).length:0}function we(e,t=!0){let n=String(e||``).trim().replace(/\\/g,`/`).replace(/^\/+/,``).replace(/\/+$/,``);if(!n)return t?``:null;if(n.includes(`\0`))return null;let r=n.split(`/`).filter(Boolean);return r.length?r.some(e=>e===`.`||e===`..`)?null:r.join(`/`):t?``:null}function A(e){let t=String(e||``).trim().replace(/\\/g,`/`).replace(/\/+$/g,``);return!t||!t.includes(`/`)?``:t.split(`/`).slice(0,-1).join(`/`)}function Te(e,t){return!Number.isFinite(e)||e<1||!Number.isFinite(t)||t<1?1:Math.min(e,t)}function j(e,t,n){if(!n)return`0 of 0`;let r=Te(e,Math.max(1,Math.ceil(n/Math.max(1,t)))),i=Math.max(1,t);return`${(r-1)*i+1}-${Math.min(n,r*i)} of ${n}`}function Ee({api:l,client:u,toast:v}){let y=a(),b=h(),ce=r(null),le=r(null),ue=r(null),[x,S]=i(`managed`),[de,fe]=i(!1),[pe,me]=i(!1),[C,w]=i(``),[T,E]=i(``),[D,O]=i(null),[Ee,M]=i([]),[De,N]=i(1),[P,Oe]=i(be),[F,ke]=i([]),[I,Ae]=i(null),[je,Me]=i(null);e(()=>{let e=ae();e&&(S(`managed`),e.dir?w(e.dir):e.path&&w(g(e.path)),E(e.path||e.dir||``))},[]);let Ne=b.data?.workspace_files_api_available===!0,Pe=Ne&&b.data?.workspace_files_available===!0&&!de;e(()=>{Pe&&(x!==`managed`||C||T||S(`workspace`))},[Pe,x,C,T]);let L=x===`workspace`,Fe=L?`/api/workspace/files`:`/api/files`,R=o({queryKey:[`files`,x,C],queryFn:async()=>l(`${Fe}/list?dir=${encodeURIComponent(C)}`).catch(e=>(L&&Number(e?.status||0)===404&&(fe(!0),S(`managed`),w(``)),{dir:C,parent:null,directories:[],files:[]})),refetchInterval:15e3}),z=String(R.data?.dir||``).trim(),Ie=String(R.data?.parent||``).trim(),B=k(R.data,`directories`),V=k(R.data,`files`);e(()=>{let e=new Set(V.map(e=>String(e.path||``).trim()).filter(Boolean));ke(t=>t.filter(t=>e.has(t)))},[V]),e(()=>{N(1)},[C]);let Le=n(()=>new Set(F),[F]),Re=n(()=>V.filter(e=>Le.has(String(e.path||``).trim())),[V,Le]),H=Re.length,ze=Math.max(1,Math.ceil(V.length/Math.max(1,P))),U=Te(De,ze),W=(U-1)*Math.max(1,P),Be=V.slice(W,W+Math.max(1,P)),G=j(U,P,V.length);e(()=>{De!==U&&N(U)},[De,U]);let Ve=n(()=>V.find(e=>String(e?.path||``)===T)||B.find(e=>String(e?.path||``)===T)||null,[R.data,T]),K=!!Ve&&String(Ve?.previewKind||``)===`directory`||!!z&&T===z,q=Ve&&!K?Ve:null,He=String(q?.mime||``).trim(),J=String(q?.previewKind||``).trim(),Ue=q?.downloadUrl||`${Fe}/download?path=${encodeURIComponent(T)}`,We=o({queryKey:[`files`,x,`read`,T],enabled:!!q&&ve.has(J),queryFn:async()=>l(`${Fe}/read?path=${encodeURIComponent(T)}`).catch(e=>({ok:!1,previewable:!1,reason:`unavailable`,error:e instanceof Error?e.message:String(e)}))}),Ge=B.length+V.length,Ke=Ce(z),qe=!!q&&ve.has(J)&&We.data?.previewable!==!1,Je=We.isFetching&&qe;e(()=>{ce.current&&ne(ce.current)},[Ge,B.length,V.length,De,P,Be.length,H,T,J,K,Ee.length,z,x,pe,We.data?.previewable]);let Ye=s({mutationFn:({file:e,targetDir:t,surface:n,relativePath:r})=>new Promise((i,a)=>{let o=`${Date.now()}-${Math.random().toString(16).slice(2)}`;M(t=>[...t,{id:o,name:e.name,progress:0,error:``}]);let s=new XMLHttpRequest,c=n===`workspace`?`/api/workspace/files/upload`:`/api/files/upload`;s.open(`POST`,`${c}?dir=${encodeURIComponent(t)}`),s.withCredentials=!0,s.responseType=`json`,s.setRequestHeader(`x-file-name`,encodeURIComponent(e.name)),n===`workspace`&&r&&s.setRequestHeader(`x-relative-path`,encodeURIComponent(r)),s.upload.onprogress=e=>{if(!e.lengthComputable)return;let t=e.loaded/e.total*100;M(e=>e.map(e=>e.id===o?{...e,progress:t}:e))},s.onerror=()=>{M(e=>e.map(e=>e.id===o?{...e,error:`Network error`}:e)),window.setTimeout(()=>{M(e=>e.filter(e=>e.id!==o))},1200),a(Error(`Upload failed: ${e.name}`))},s.onload=()=>{let e=s.response||{};if(s.status<200||s.status>=300||e?.ok===!1){let t=String(e?.error||`Upload failed (${s.status})`);M(e=>e.map(e=>e.id===o?{...e,error:t}:e)),window.setTimeout(()=>{M(e=>e.filter(e=>e.id!==o))},1600),a(Error(t));return}M(e=>e.filter(e=>e.id!==o)),i(e)},s.send(e)}),onSuccess:async(e,t)=>{let n=String(e?.path||``).trim();if(n){let e=String(t.targetDir||``).trim()||g(n);t.surface===`managed`&&!C&&e===`uploads`&&w(`uploads`),E(n)}await y.invalidateQueries({queryKey:[`files`]}),v(`ok`,`Uploaded ${String(t.file?.name||`file`)} into ${t.targetDir||(t.surface===`workspace`?`Workspace`:`uploads`)}.`)},onError:e=>v(`err`,e instanceof Error?e.message:String(e))}),Xe=s({mutationFn:async e=>l(`${Fe}/mkdir`,{method:`POST`,body:JSON.stringify({path:e})}),onSuccess:async e=>{let t=String(e?.path||``).trim();t&&(w(t),E(t)),await y.invalidateQueries({queryKey:[`files`]}),v(`ok`,`Created folder ${t||`folder`}.`)},onError:e=>v(`err`,e instanceof Error?e.message:String(e))}),Ze=async e=>{let t=[...e||[]];if(!t.length)return;let n=L?C:C||`uploads`;for(let e of t){let t=L?String(e.webkitRelativePath||e.name):void 0;await Ye.mutateAsync({file:e,targetDir:n,surface:x,relativePath:t}).catch(()=>void 0)}!L&&!C&&w(`uploads`)},Qe=()=>{let e=String(C||``).trim();if(!L&&!e){v(`warn`,`Choose a bucket before creating folders.`);return}O({baseDir:e,value:L?`new-folder`:`knowledgebooks/new-collection`})},$e=async()=>{let e=D;if(!e)return;let t=String(e.value||``).trim().replace(/^\/+|\/+$/g,``).replace(/\/{2,}/g,`/`);if(!t){v(`warn`,`Enter a folder name.`);return}O(null),await Xe.mutateAsync(e.baseDir?`${e.baseDir}/${t}`:t)},Y=e=>{let t=L?we(e,!0):ie(e);t&&(w(t),E(t))},et=()=>{if(!Ie){w(``),E(``);return}w(Ie),E(Ie)},X=()=>{w(``),E(``)},Z=e=>{let t=String(e||``).trim();t&&ke(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},Q=()=>{let e=V.map(e=>String(e.path||``).trim()).filter(Boolean);ke(Array.from(new Set(e)))},tt=()=>{ke([])},nt=()=>{if(!Re.length){v(`warn`,`Select one or more files first.`);return}Ae({files:Re.map(e=>({path:String(e.path||``).trim(),name:String(e.name||e.path||``).trim()}))})},rt=()=>{let e=``,t=``;K&&T?e=T:H?(e=A(Re[0]?.path||``),t=`Import the containing folder for now.`):q?(e=A(q.path||T),t=`Import the containing folder for now.`):z?e=z:L&&(e=`.`),Me({path:e,note:t})},$=async()=>{let e=I?.files||[];if(!e.length){v(`warn`,`Select one or more files first.`);return}let t=new Set(F),n=0,r=0;for(let i of e)try{await l(`${Fe}/delete`,{method:`POST`,body:JSON.stringify({path:i.path})}),n+=1,t.delete(i.path)}catch{r+=1}ke(Array.from(t)),E(t=>e.some(e=>e.path===t)?``:t),Ae(null),await y.invalidateQueries({queryKey:[`files`]}),n&&r?v(`warn`,`Deleted ${n} file(s); ${r} failed.`):n?v(`ok`,`Deleted ${n} file(s).`):v(`err`,`All ${r} selected file deletions failed.`)},it=e=>{e!==x&&(S(e),w(``),E(``),ke([]),N(1))},at=L?z||`Workspace`:z||`Root`,ot=String(We.data?.reason||``).trim(),st=String(We.data?.text||``).trim(),ct=_e.length,lt=String(b.data?.hosted_deployment_slug||b.data?.hosted_hostname||``).trim(),ut=lt,dt=ut?`project`:`global`;return c(p,{className:`grid h-full min-h-0 gap-4`,children:[c(he,{api:l,toast:v,defaultCollectionId:lt}),c(ge,{api:l,toast:v}),c(te,{fullHeight:!0,title:`Files`,subtitle:L?`Browse and edit the hosted workspace.`:`Browse managed uploads, published artifacts, and exports.`,actions:c(d,{className:`justify-start`,children:[c(`button`,{type:`button`,className:`tcp-icon-btn`,title:`Upload files`,"aria-label":`Upload files`,onClick:()=>le.current?.click(),disabled:Ye.isPending,children:c(`i`,{"data-lucide":`upload`})}),L?c(`button`,{type:`button`,className:`tcp-icon-btn`,title:`Upload folder`,"aria-label":`Upload folder`,onClick:()=>ue.current?.click(),disabled:Ye.isPending,children:c(`i`,{"data-lucide":`folder-up`})}):null,c(`button`,{type:`button`,className:`tcp-icon-btn`,onClick:Qe,disabled:Xe.isPending||!L&&!C,title:!L&&!C?`Choose a bucket first`:`Create a folder inside the current path`,"aria-label":`Create folder`,children:c(`i`,{"data-lucide":`folder-plus`})}),c(`button`,{type:`button`,className:`tcp-icon-btn`,title:`Import to Memory`,"aria-label":`Import to Memory`,onClick:rt,children:c(`i`,{"data-lucide":`database-zap`})}),c(`button`,{type:`button`,className:`tcp-icon-btn`,title:`Refresh files`,"aria-label":`Refresh files`,onClick:()=>void R.refetch(),children:c(`i`,{"data-lucide":`refresh-cw`})}),c(`button`,{type:`button`,className:`tcp-icon-btn`,title:`Go up one folder`,"aria-label":`Go up one folder`,onClick:et,disabled:!z,children:c(`i`,{"data-lucide":`corner-up-left`})}),c(`button`,{type:`button`,className:`tcp-icon-btn`,title:pe?`Expand files`:`Collapse files`,"aria-label":pe?`Expand files`:`Collapse files`,onClick:()=>me(e=>!e),children:c(`i`,{"data-lucide":pe?`chevron-down`:`chevron-up`})})]}),children:c(`div`,{ref:ce,className:pe?`hidden`:`grid min-h-0 gap-4 xl:grid-cols-[280px_minmax(0,1fr)_360px]`,children:[c(te,{fullHeight:!0,className:`overflow-hidden`,title:`Locations`,subtitle:L?`Hosted workspace root.`:`Managed file buckets.`,actions:c(f,{tone:`ghost`,children:L?`workspace`:ct}),children:c(`div`,{className:`grid min-h-0 gap-3 p-4`,children:[c(`div`,{className:`grid grid-cols-2 gap-2`,children:[c(`button`,{type:`button`,className:`tcp-btn h-9 justify-center px-2 text-xs ${L?`border-sky-500/40 bg-sky-950/20`:``}`.trim(),onClick:()=>it(`workspace`),disabled:!Pe,title:Pe?`Browse the workspace`:Ne?`Workspace root is not configured`:`Workspace file browsing is not available on this deployment`,children:[c(`i`,{"data-lucide":`folder-code`}),`Workspace`]}),c(`button`,{type:`button`,className:`tcp-btn h-9 justify-center px-2 text-xs ${L?``:`border-sky-500/40 bg-sky-950/20`}`.trim(),onClick:()=>it(`managed`),children:[c(`i`,{"data-lucide":`archive`}),`Managed`]})]}),c(`div`,{className:`grid gap-1`,children:[c(`button`,{type:`button`,className:`tcp-list-item w-full text-left ${z?``:`border-sky-500/40 bg-sky-950/20`}`,onClick:X,children:[c(`i`,{"data-lucide":`hard-drive`}),L?`Workspace root`:`Root`]}),L?null:_e.map(e=>c(`button`,{type:`button`,className:`tcp-list-item w-full text-left ${z===e?`border-sky-500/40 bg-sky-950/20`:``}`,onClick:()=>Y(e),children:[c(`i`,{"data-lucide":`folder-open`}),c(`span`,{className:`flex min-w-0 flex-1 items-center justify-between gap-2`,children:[c(`span`,{className:`truncate`,children:e}),c(`span`,{className:`tcp-subtle text-[11px]`,children:e===`uploads`?`managed`:e})]})]},e))]}),c(`div`,{className:`rounded-xl border border-white/10 bg-black/20 p-3`,children:[c(`div`,{className:`tcp-subtle text-xs uppercase tracking-wide`,children:`Path`}),c(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[c(`button`,{type:`button`,className:`tcp-btn h-7 px-2 text-xs`,onClick:X,children:L?`Workspace`:`Root`}),z.split(`/`).filter(Boolean).reduce((e,t)=>{let n=e.length?`${e[e.length-1]}/${t}`:t;return e.push(n),e},[]).map(e=>c(`button`,{type:`button`,className:`tcp-btn h-7 px-2 text-xs ${e===z?`border-sky-500/40 bg-sky-950/20`:``}`.trim(),onClick:()=>Y(e),children:e.split(`/`).pop()||e},e))]})]}),Ee.length?c(`div`,{className:`grid gap-2`,children:[c(`div`,{className:`tcp-subtle text-xs uppercase tracking-wide`,children:`Uploads`}),c(`div`,{className:`grid gap-2`,children:Ee.map(e=>c(`div`,{className:`rounded-xl border border-white/10 bg-black/20 p-2 text-xs`,children:[c(`div`,{className:`flex items-center justify-between gap-2`,children:[c(`span`,{className:`truncate`,children:e.name}),c(`span`,{className:`tcp-subtle`,children:[Math.round(e.progress),`%`]})]}),c(`div`,{className:`mt-2 h-1.5 overflow-hidden rounded-full bg-white/10`,children:c(`div`,{className:`h-full rounded-full ${e.error?`bg-rose-400`:`bg-sky-400`}`,style:{width:`${Math.max(4,Math.min(100,e.progress||0))}%`}})}),e.error?c(`div`,{className:`mt-1 text-rose-200`,children:e.error}):null]},e.id))})]}):null]})}),c(te,{fullHeight:!0,className:`overflow-hidden`,title:at,subtitle:!L&&Ke===0?`Select a bucket to browse its files.`:`${B.length} folder${B.length===1?``:`s`} and ${V.length} file${V.length===1?``:`s`}`,actions:c(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[c(`span`,{className:`tcp-badge tcp-badge-ghost`,children:at}),J?c(f,{tone:`info`,children:J}):null,K?c(f,{tone:`ghost`,children:`folder`}):null]}),children:c(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 p-4`,children:[c(`div`,{className:`tcp-toolbar`,children:[c(`span`,{className:`tcp-badge-info`,children:[B.length,` folder`,B.length===1?``:`s`]}),c(`span`,{className:`tcp-badge-info`,children:[V.length,` file`,V.length===1?``:`s`]}),c(`span`,{className:C?`tcp-badge-ok`:`tcp-badge tcp-badge-ghost`,children:C?`browsing`:`root`})]}),c(`div`,{className:`grid min-h-0 gap-2 overflow-auto pr-1`,children:!L&&Ke===0?c(m,{text:`Pick a bucket on the left, or upload a file to start browsing.`,title:`No folder selected`}):B.length||V.length?c(t,{children:[B.map(e=>{let t=String(e?.path||``);return c(`button`,{type:`button`,className:`tcp-list-item w-full text-left ${t===T?`border-sky-500/40 bg-sky-950/20`:``}`,onClick:()=>Y(t),children:[c(`i`,{"data-lucide":`folder-open`}),c(`div`,{className:`min-w-0 flex-1`,children:[c(`div`,{className:`flex items-center justify-between gap-2`,children:[c(`strong`,{className:`truncate`,children:String(e?.name||t)}),c(`span`,{className:`tcp-subtle text-xs`,children:`folder`})]}),c(`div`,{className:`mt-1 flex items-center justify-between gap-2 text-xs tcp-subtle`,children:[c(`span`,{className:`truncate`,children:t}),c(`span`,{children:Se(Number(e?.updatedAt||0))})]})]})]},`dir-${t}`)}),c(`div`,{className:`grid gap-2 rounded-xl border border-white/10 bg-black/20 p-3`,children:[c(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[c(`div`,{className:`flex flex-wrap items-center gap-2`,children:[c(f,{tone:`ghost`,children:G}),c(f,{tone:H?`info`:`ghost`,children:[H,` selected`]})]}),c(`div`,{className:`flex flex-wrap items-center gap-2`,children:[c(`button`,{type:`button`,className:`tcp-icon-btn h-8 w-8`,title:`Import selected file folder to memory`,"aria-label":`Import selected file folder to memory`,onClick:rt,disabled:!H,children:c(`i`,{"data-lucide":`database-zap`})}),c(`button`,{type:`button`,className:`tcp-icon-btn h-8 w-8`,title:`Select all visible files`,"aria-label":`Select all visible files`,onClick:Q,disabled:!V.length,children:c(`i`,{"data-lucide":`square-check-big`})}),c(`button`,{type:`button`,className:`tcp-icon-btn h-8 w-8`,title:`Clear selected files`,"aria-label":`Clear selected files`,onClick:tt,disabled:!H,children:c(`i`,{"data-lucide":`x`})}),c(`button`,{type:`button`,className:`tcp-icon-btn h-8 w-8 border-rose-500/30 text-rose-100 hover:bg-rose-950/20 disabled:opacity-50`,title:`Delete selected files`,"aria-label":`Delete selected files`,onClick:nt,disabled:!H,children:c(`i`,{"data-lucide":`trash-2`})}),c(`label`,{className:`flex items-center gap-2 text-[11px] uppercase tracking-wide text-slate-500`,children:[c(`span`,{children:`Per page`}),c(`select`,{className:`tcp-select h-8 min-w-[5.5rem] px-3 text-center text-sm font-semibold tabular-nums text-slate-100 [text-align-last:center]`,value:P,onChange:e=>{Oe(Number(e.target.value)||be),N(1)},children:ye.map(e=>c(`option`,{value:e,children:e},e))})]}),c(`button`,{type:`button`,className:`tcp-icon-btn h-8 w-8`,title:`Previous page`,"aria-label":`Previous page`,onClick:()=>N(e=>Te(e-1,ze)),disabled:U<=1,children:c(`i`,{"data-lucide":`chevron-left`})}),c(`button`,{type:`button`,className:`tcp-icon-btn h-8 w-8`,title:`Next page`,"aria-label":`Next page`,onClick:()=>N(e=>Te(e+1,ze)),disabled:U>=ze,children:c(`i`,{"data-lucide":`chevron-right`})})]})]}),c(`div`,{className:`grid gap-2`,children:Be.map(e=>{let t=String(e?.path||``),n=t===T,r=Le.has(t),i=String(e?.previewKind||`file`);return c(ee.div,{layout:!0,children:c(`div`,{className:`flex items-start gap-3`,children:[c(`label`,{className:`mt-3 flex h-6 w-6 items-center justify-center rounded border ${t?`border-white/15 bg-black/20 text-slate-200 cursor-pointer hover:border-sky-500/40`:`border-white/10 bg-black/10 text-slate-500`}`,children:c(`input`,{type:`checkbox`,className:`h-4 w-4 accent-sky-400`,checked:r,onChange:()=>Z(t),"aria-label":`Select ${e.name||t}`})}),c(`button`,{type:`button`,className:`tcp-list-item min-w-0 flex-1 text-left ${n?`border-sky-500/40 bg-sky-950/20`:``}`,onClick:()=>E(e=>e===t?``:t),children:[c(`i`,{"data-lucide":`file-text`}),c(`div`,{className:`min-w-0 flex-1`,children:[c(`div`,{className:`flex items-center justify-between gap-2`,children:[c(`strong`,{className:`truncate`,children:e.name||t}),c(`span`,{className:`tcp-subtle text-xs`,children:i})]}),c(`div`,{className:`mt-1 flex flex-wrap items-center gap-2 text-xs tcp-subtle`,children:[c(`span`,{className:`truncate`,children:t}),c(`span`,{children:xe(Number(e?.size||0))}),c(`span`,{children:Se(Number(e?.updatedAt||0))})]})]})]})]})},`file-${t}`)})})]})]}):c(m,{text:`This folder does not contain any files yet.`})})]})}),c(te,{fullHeight:!0,className:`overflow-hidden`,title:`Preview`,subtitle:q?q.path:K?T:`Select a file`,actions:q?c(`a`,{className:`tcp-icon-btn h-8 w-8`,href:Ue,target:`_blank`,rel:`noreferrer`,title:`Download file`,"aria-label":`Download file`,children:c(`i`,{"data-lucide":`download`})}):K?c(`button`,{type:`button`,className:`tcp-icon-btn h-8 w-8`,title:`Open folder`,"aria-label":`Open folder`,onClick:()=>Y(T),children:c(`i`,{"data-lucide":`folder-open`})}):null,children:c(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 p-4`,children:q?c(t,{children:[c(`div`,{className:`rounded-xl border border-white/10 bg-black/20 p-3`,children:[c(`div`,{className:`flex items-start justify-between gap-3`,children:[c(`div`,{className:`min-w-0`,children:[c(`div`,{className:`truncate text-sm font-semibold`,children:q.name}),c(`div`,{className:`tcp-subtle mt-1 text-xs`,children:q.path})]}),c(`div`,{className:`flex flex-col items-end gap-1`,children:[c(f,{tone:`info`,children:J||`file`}),c(`span`,{className:`tcp-subtle text-xs`,children:He||`application/octet-stream`})]})]}),c(`div`,{className:`mt-3 grid grid-cols-2 gap-2 text-xs`,children:[c(`div`,{className:`rounded-lg border border-white/10 bg-black/10 p-2`,children:[c(`div`,{className:`tcp-subtle`,children:`Size`}),c(`div`,{className:`mt-1 font-medium`,children:xe(Number(q.size||0))})]}),c(`div`,{className:`rounded-lg border border-white/10 bg-black/10 p-2`,children:[c(`div`,{className:`tcp-subtle`,children:`Updated`}),c(`div`,{className:`mt-1 font-medium`,children:Se(Number(q.updatedAt||0))})]})]})]}),J===`image`?c(`div`,{className:`min-h-0 flex-1 overflow-auto rounded-xl border border-white/10 bg-black/20 p-3`,children:c(`img`,{src:Ue,alt:q.name,className:`max-h-full max-w-full rounded-lg object-contain`})}):J===`pdf`?c(`div`,{className:`min-h-0 flex-1 overflow-hidden rounded-xl border border-white/10 bg-black/20`,children:c(`iframe`,{title:q.name,src:Ue,className:`h-full w-full`})}):qe?c(`div`,{className:`min-h-0 flex-1 overflow-auto rounded-xl border border-white/10 bg-black/20 p-3`,children:Je?c(`div`,{className:`tcp-subtle text-sm`,children:`Loading preview...`}):J===`markdown`?c(`div`,{className:`tcp-markdown tcp-markdown-ai`,dangerouslySetInnerHTML:{__html:re(st||` `)}}):c(`pre`,{className:`tcp-code whitespace-pre-wrap break-words`,children:st||` `})}):c(`div`,{className:`grid min-h-0 flex-1 gap-3`,children:[c(m,{title:`Preview unavailable`,text:ot===`too_large`?`This file is larger than ${xe(2*1024*1024)} for inline preview.`:ot===`unavailable`?`The preview request failed or the file is no longer available.`:`This file type is not previewed inline.`}),c(`div`,{className:`rounded-xl border border-white/10 bg-black/20 p-3 text-xs`,children:[c(`div`,{className:`tcp-subtle`,children:`Download URL`}),c(`a`,{className:`mt-1 block truncate text-sky-200`,href:Ue,children:Ue})]})]})]}):K?c(`div`,{className:`grid gap-3`,children:[c(`div`,{className:`rounded-xl border border-white/10 bg-black/20 p-3`,children:[c(`div`,{className:`flex items-start justify-between gap-3`,children:[c(`div`,{children:[c(`div`,{className:`text-sm font-semibold`,children:T||`Folder`}),c(`div`,{className:`tcp-subtle mt-1 text-xs`,children:`Folder preview`})]}),c(f,{tone:`ghost`,children:`folder`})]}),c(`div`,{className:`mt-3 grid grid-cols-2 gap-2 text-xs`,children:[c(`div`,{className:`rounded-lg border border-white/10 bg-black/10 p-2`,children:[c(`div`,{className:`tcp-subtle`,children:`Folders`}),c(`div`,{className:`mt-1 font-medium`,children:B.length})]}),c(`div`,{className:`rounded-lg border border-white/10 bg-black/10 p-2`,children:[c(`div`,{className:`tcp-subtle`,children:`Files`}),c(`div`,{className:`mt-1 font-medium`,children:V.length})]})]})]}),c(`div`,{className:`rounded-xl border border-white/10 bg-black/20 p-3 text-xs`,children:[c(`div`,{className:`tcp-subtle`,children:`Folder path`}),c(`div`,{className:`mt-1 break-all`,children:T})]}),c(`button`,{type:`button`,className:`tcp-btn-primary justify-center`,onClick:rt,children:[c(`i`,{"data-lucide":`database-zap`}),`Import to Memory`]})]}):c(m,{title:`No selection`,text:`Pick a file to preview it here, or select a folder to see its details.`})})})]})}),c(`input`,{ref:le,type:`file`,className:`hidden`,multiple:!0,onChange:e=>{Ze(e.target.files),e.target.value=``}}),c(`input`,{ref:ue,type:`file`,className:`hidden`,multiple:!0,webkitdirectory:``,directory:``,onChange:e=>{Ze(e.target.files),e.target.value=``}}),c(_,{open:!!D,title:`Create folder`,message:c(`span`,{children:[`Create a new folder inside`,` `,c(`strong`,{children:D?.baseDir||(L?`Workspace`:`current path`)}),`.`]}),label:`Folder path`,value:D?.value||``,placeholder:L?`new-folder`:`knowledgebooks/new-collection`,confirmLabel:`Create folder`,confirmIcon:`folder-plus`,confirmDisabled:!String(D?.value||``).trim(),onCancel:()=>O(null),onChange:e=>O(t=>t&&{...t,value:e}),onConfirm:()=>void $e()}),c(oe,{open:!!I,title:`Delete selected files`,message:c(`span`,{children:[`This will permanently remove`,` `,c(`strong`,{children:[I?.files.length||0,` selected file(s)`]}),` from`,` `,c(`strong`,{children:at||`the current folder`}),`.`]}),confirmLabel:`Delete selected`,confirmIcon:`trash-2`,confirmTone:`danger`,widthClassName:`w-[min(42rem,96vw)]`,onCancel:()=>Ae(null),onConfirm:()=>void $(),children:I?.files.length?c(`div`,{className:`mt-3 grid gap-2 rounded-xl border border-white/10 bg-black/20 p-3 text-left text-xs`,children:[c(`div`,{className:`tcp-subtle uppercase tracking-wide`,children:`Selected files`}),c(`div`,{className:`max-h-40 overflow-auto`,children:[I.files.slice(0,12).map(e=>c(`div`,{className:`truncate py-1`,children:[c(`span`,{className:`font-medium text-slate-100`,children:e.name||e.path}),c(`span`,{className:`tcp-subtle`,children:[` · `,e.path]})]},e.path)),I.files.length>12?c(`div`,{className:`pt-1 text-slate-400`,children:[`+`,I.files.length-12,` more`]}):null]})]}):null}),c(se,{open:!!je,client:u,initialPath:je?.path||``,initialTier:dt,initialProjectId:ut,note:je?.note||``,toast:v,onCancel:()=>Me(null),onSuccess:async()=>{await y.invalidateQueries({queryKey:[`memory`]})}})]})}export{Ee as FilesPage};
@@ -1 +0,0 @@
1
- import{E as e,g as t,v as n}from"./fullcalendar-Bn75j0xM.js";import{i as r}from"./motion-B3ZE8SGR.js";import{d as i,l as a,n as o,t as s,u as c}from"./ui-CV-Z6sqF.js";import{s as l}from"./index-picB46b5.js";var u=[{packId:`planning-pack`,title:`Planning Pack`,summary:`Kickoff, weekly status, meeting notes, and action tracking for teams that need clarity fast.`,audience:`Project leads, operators, and team managers`,categories:[`planning`,`project management`,`operations`],tags:[`kickoff`,`weekly status`,`action tracking`],highlight:`Best starting point for general-purpose planning workflows.`},{packId:`writing-pack`,title:`Writing Pack`,summary:`Draft, polish, and repurpose articles with an SEO-aware workflow that keeps the story readable.`,audience:`Writers, editors, and marketers`,categories:[`writing`,`seo`,`content marketing`],tags:[`blog drafts`,`copy editing`,`content refresh`],highlight:`Useful when the output needs to read well and rank well.`},{packId:`research-pack`,title:`Research Pack`,summary:`Turn rough questions into structured briefs, source checks, and comparative analysis.`,audience:`Researchers, analysts, and product teams`,categories:[`research`,`analysis`,`fact finding`],tags:[`briefs`,`source verification`,`competitive scan`],highlight:`Good for turning uncertainty into a clear evidence trail.`},{packId:`build-pack`,title:`Build Pack`,summary:`Break features into implementation tasks, review changes, and keep engineering work moving.`,audience:`Developers, reviewers, and release teams`,categories:[`engineering`,`delivery`,`release`],tags:[`feature breakdown`,`bug triage`,`pr review`],highlight:`Best when you want a workflow that maps directly to coding work.`}];function d(d){let[f,p]=n(u[0]?.packId||``),m=t(()=>u.find(e=>e.packId===f)||u[0],[f]);return r(s,{className:`grid gap-4`,children:[r(a,{eyebrow:`Marketplace`,title:`Marketplace coming soon`,subtitle:`This route is intentionally hidden by default. If someone enables it manually, it stays a placeholder until the tandem.ac marketplace is live.`,badges:r(e,{children:[r(o,{tone:`info`,children:`coming soon`}),r(o,{tone:`ghost`,children:[u.length,` seed concepts`]}),r(o,{tone:`ghost`,children:`disabled by default`})]})}),r(c,{title:`Marketplace not live yet`,subtitle:`The public store will live on tandem.ac. This page is a placeholder until search, login, and purchase are ready.`,children:r(`div`,{className:`grid gap-3`,children:[r(`div`,{className:`tcp-list-item`,children:[r(`div`,{className:`tcp-subtle text-xs uppercase tracking-[0.24em]`,children:`Status`}),r(`div`,{className:`mt-2 text-sm`,children:`The marketplace page is intentionally a placeholder until the tandem.ac catalog API and listing pages go live.`})]}),r(`div`,{className:`flex flex-wrap gap-2`,children:[r(`button`,{className:`tcp-btn-primary`,type:`button`,disabled:!0,children:[r(`i`,{"data-lucide":`search`}),`Search marketplace`]}),r(`button`,{className:`tcp-btn`,type:`button`,disabled:!0,children:[r(`i`,{"data-lucide":`external-link`}),`Open tandem.ac`]})]})]})}),r(i,{main:r(`div`,{className:`grid gap-4`,children:[r(c,{title:`Seed concepts`,subtitle:`These are planning concepts, not published marketplace listings.`,children:r(`div`,{className:`grid gap-3`,children:u.map(e=>r(`button`,{type:`button`,className:`tcp-list-item text-left ${m?.packId===e.packId?`border-amber-400/70`:``}`,onClick:()=>p(e.packId),children:r(`div`,{className:`flex items-start justify-between gap-3`,children:[r(`div`,{className:`min-w-0 flex-1`,children:[r(`div`,{className:`mb-1 flex items-center gap-2`,children:[r(`strong`,{children:e.title}),r(o,{tone:`info`,children:e.packId}),r(o,{tone:`ghost`,children:`planned seed`})]}),r(`div`,{className:`tcp-subtle text-sm`,children:e.summary}),r(`div`,{className:`mt-2 flex flex-wrap gap-2 text-xs`,children:[r(o,{tone:`ghost`,children:e.audience}),e.categories.map(t=>r(o,{tone:`ghost`,children:t},`${e.packId}-${t}`))]})]}),r(o,{tone:`ghost`,children:e.highlight})]})},e.packId))})}),r(c,{title:`What tandem.ac will own later`,subtitle:`The store belongs on the web, not inside the control panel.`,children:r(`div`,{className:`grid gap-2 text-sm tcp-subtle`,children:[r(`div`,{children:`• login and account state`}),r(`div`,{children:`• pricing and purchase`}),r(`div`,{children:`• pack detail pages and publisher pages`}),r(`div`,{children:`• public search and browse results`}),r(`div`,{children:`• future entitlement and redemption flows`})]})})]}),aside:r(c,{title:`Selected concept`,subtitle:`This is a seed idea that will become a real listing later.`,children:m?r(`div`,{className:`grid gap-3`,children:[r(`div`,{className:`tcp-list-item`,children:[r(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[r(`strong`,{children:m.title}),r(o,{tone:`info`,children:m.packId}),r(o,{tone:`ghost`,children:`concept only`})]}),r(`div`,{className:`tcp-subtle text-sm`,children:m.summary}),r(`div`,{className:`mt-2 flex flex-wrap gap-2 text-xs`,children:[m.categories.map(e=>r(o,{tone:`ghost`,children:e},`${m.packId}-${e}-aside`)),m.tags.map(e=>r(o,{tone:`ghost`,children:e},`${m.packId}-${e}`))]})]}),r(`div`,{className:`tcp-list-item`,children:[r(`div`,{className:`tcp-subtle text-xs uppercase tracking-[0.24em]`,children:`Why it exists`}),r(`div`,{className:`mt-2 text-sm`,children:m.highlight})]})]}):r(l,{text:`Select a featured concept.`})})})]})}export{d as MarketplacePage};
@@ -1 +0,0 @@
1
- import{E as e,g as t,v as n}from"./fullcalendar-Bn75j0xM.js";import{a as r,n as i,t as a}from"./react-query-BIbNygEJ.js";import{i as o,n as s,r as c}from"./motion-B3ZE8SGR.js";import{m as l,n as u,t as d,u as f}from"./ui-CV-Z6sqF.js";import{s as p,u as m}from"./index-picB46b5.js";import{t as h}from"./MemoryImportDialog-BWT93PW1.js";var g=new Set([`user_message`,`assistant_message`,`assistant_response`,`assistant_final`,`channel_message`,`session_message`]);function _(e,t){return Array.isArray(e)?e:Array.isArray(e?.[t])?e[t]:[]}function v(e,t){let n=t.trim().toLowerCase();if(g.has(n)||n.endsWith(`_message`)||n.includes(`message`))return!0;let r=e?.metadata||{},i=e?.provenance||{},a=String(r?.origin||i?.origin_event_type||``).toLowerCase();return a.includes(`message`)||a.includes(`channel`)}function y({api:g,client:y,toast:b}){let x=r(),[S,C]=n(``),[w,T]=n(`knowledge`),[E,D]=n(null),[O,k]=n(!1),[A,j]=n(!1),[M,N]=n(``),[P,F]=n(`note`),[I,L]=n(``),[R,z]=n(`private`),B=i({queryKey:[`memory`,S],queryFn:()=>(S.trim()?y.memory.search({query:S,limit:40}):y.memory.list({q:``,limit:40})).catch(()=>({items:[]})),refetchInterval:15e3}),V=a({mutationFn:e=>y.memory.delete(e),onSuccess:async()=>{b(`ok`,`Memory record deleted.`),await x.invalidateQueries({queryKey:[`memory`]})},onError:e=>b(`err`,e instanceof Error?e.message:String(e))}),H=a({mutationFn:async()=>{let e=I.trim()||`default`,t=R===`shared`?`project`:`session`,n=`manual-memory-${Date.now()}`;return g(`/api/engine/memory/put`,{method:`POST`,body:JSON.stringify({run_id:n,partition:{org_id:`local`,workspace_id:`control-panel`,project_id:e,tier:t},kind:P,content:M.trim(),classification:`internal`,metadata:{origin:`control_panel_manual_add`,visibility:R},capability:{run_id:n,subject:`control-panel`,org_id:`local`,workspace_id:`control-panel`,project_id:e,memory:{read_tiers:[`session`,`project`],write_tiers:[t],promote_targets:[`project`],require_review_for_promote:!1,allow_auto_use_tiers:[`curated`]},expires_at:9007199254740991}})})},onSuccess:async()=>{b(`ok`,`Memory saved.`),N(``),j(!1),await x.invalidateQueries({queryKey:[`memory`]})},onError:e=>b(`err`,e instanceof Error?e.message:String(e))}),U=_(B.data,`items`),W=_(B.data,`results`),G=U.length?U:W,K=t(()=>G.map((e,t)=>{let n=String(e?.id||`mem-${t}`),r=String(e?.text||e?.content||e?.value||``),i=r.length>340?`${r.slice(0,340)}...`:r,a=e?.metadata||{},o=e?.linkage||{},s=String(e?.source_path||e?.sourcePath||a?.path||a?.source_path||a?.import_root||``),c=String(e?.source_type||e?.sourceType||e?.kind||e?.source||``),l=String(e?.project_tag||e?.projectTag||e?.project_id||e?.projectId||o?.project_id||a?.project_id||``),u=String(e?.visibility||a?.visibility||``),d=String(e?.run_id||e?.runId||o?.run_id||``);return{id:n,text:r,compact:i,html:m(r),sourcePath:s,sourceType:c,project:l,visibility:u,runId:d,runtime:v(e,c)}}),[G]),q=K.filter(e=>!e.runtime).length,J=K.filter(e=>e.runtime).length,Y=K.filter(e=>w===`knowledge`?!e.runtime:w===`runtime`?e.runtime:!0),X=w===`knowledge`?`No governed knowledge records found. Import docs or add memory to seed this view.`:w===`runtime`?`No runtime message records found.`:`No memory records found.`;return o(d,{className:`grid gap-4`,children:[o(f,{title:`Memory`,subtitle:`Search recent records and open full entry details inline.`,actions:o(e,{children:[o(u,{tone:`info`,children:[Y.length,` results`]}),S.trim()?o(u,{tone:`ghost`,children:[`Filter: `,S]}):o(u,{tone:`ghost`,children:w===`knowledge`?`Governed knowledge`:w===`runtime`?`Runtime messages`:`All memory`}),o(`button`,{type:`button`,className:`tcp-btn-primary`,onClick:()=>k(!0),children:[o(`i`,{"data-lucide":`database-zap`}),`Import Knowledge`]}),o(`button`,{type:`button`,className:`tcp-btn`,onClick:()=>j(e=>!e),children:[o(`i`,{"data-lucide":`plus`}),`Add Memory`]})]}),children:[A?o(`div`,{className:`mb-3 grid gap-3 rounded-xl border border-white/10 bg-black/20 p-3`,children:[o(`textarea`,{className:`tcp-input min-h-28 resize-y`,value:M,onChange:e=>N(e.target.value),placeholder:`Store a durable note, fact, or solution capsule.`}),o(`div`,{className:`grid gap-3 md:grid-cols-[1fr_1fr_1fr_auto]`,children:[o(`select`,{className:`tcp-select`,value:P,onChange:e=>F(e.target.value),children:[o(`option`,{value:`note`,children:`note`}),o(`option`,{value:`fact`,children:`fact`}),o(`option`,{value:`solution_capsule`,children:`solution_capsule`})]}),o(`input`,{className:`tcp-input`,value:I,onChange:e=>L(e.target.value),placeholder:`project id`}),o(`select`,{className:`tcp-select`,value:R,onChange:e=>z(e.target.value),children:[o(`option`,{value:`private`,children:`private`}),o(`option`,{value:`shared`,children:`shared`})]}),o(`button`,{type:`button`,className:`tcp-btn-primary`,disabled:!M.trim()||H.isPending,onClick:()=>H.mutate(),children:[o(`i`,{"data-lucide":`save`}),`Save`]})]})]}):null,o(`div`,{className:`mb-3 flex flex-wrap items-center gap-2`,children:[[`knowledge`,`Knowledge`,q],[`runtime`,`Runtime`,J],[`all`,`All`,K.length]].map(([e,t,n])=>o(`button`,{type:`button`,className:`tcp-btn h-8 px-3 text-xs ${w===e?`border-sky-500/40 bg-sky-950/20 text-sky-100`:``}`.trim(),onClick:()=>T(e),children:[t,o(`span`,{className:`tcp-badge tcp-badge-ghost ml-1`,children:n})]},String(e)))}),o(l,{className:`mb-3`,children:[o(`input`,{className:`tcp-input flex-1`,value:S,onInput:e=>C(e.target.value),placeholder:`Search memory`}),o(`button`,{className:`tcp-btn`,onClick:()=>B.refetch(),children:[o(`i`,{"data-lucide":`search`}),`Search`]})]}),o(`div`,{className:`grid gap-2`,children:Y.length?Y.map(e=>{let t=E===e.id;return o(s.article,{layout:!0,className:`tcp-list-item cursor-pointer ${t?`border-amber-500/60`:``}`,onClick:()=>D(t?null:e.id),children:[o(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[o(`strong`,{className:`truncate`,children:e.id}),o(`div`,{className:`flex items-center gap-2`,children:[o(u,{tone:t?`info`:`ghost`,children:t?`expanded`:`compact`}),o(`button`,{className:`tcp-btn-danger h-7 px-2 text-xs`,onClick:t=>{t.stopPropagation(),V.mutate(e.id)},children:[o(`i`,{"data-lucide":`trash-2`}),`Delete`]})]})]}),o(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[e.sourceType?o(u,{tone:`ghost`,children:e.sourceType}):null,e.project?o(u,{tone:`info`,children:e.project}):null,e.visibility?o(u,{tone:`ghost`,children:e.visibility}):null,e.runId?o(u,{tone:`ghost`,children:e.runId}):null]}),e.sourcePath?o(`div`,{className:`tcp-subtle mb-2 truncate text-[11px]`,children:e.sourcePath}):null,o(c,{initial:!1,mode:`wait`,children:t?o(s.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:`auto`},exit:{opacity:0,height:0},transition:{duration:.18,ease:`easeOut`},className:`overflow-hidden`,children:o(`div`,{className:`tcp-markdown tcp-markdown-ai rounded-lg border border-slate-700/60 bg-black/20 p-3 text-sm`,dangerouslySetInnerHTML:{__html:e.html}})},`expanded`):o(s.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.14,ease:`easeOut`},className:`tcp-subtle whitespace-pre-wrap text-xs`,children:e.compact||`(empty)`},`compact`)})]},e.id)}):o(p,{text:X})})]}),o(h,{open:O,client:y,initialTier:`global`,toast:b,onCancel:()=>k(!1),onSuccess:async()=>{await x.invalidateQueries({queryKey:[`memory`]})}})]})}export{y as MemoryPage};
@@ -1,3 +0,0 @@
1
- import{E as e,g as t,v as n}from"./fullcalendar-Bn75j0xM.js";import{a as r,n as i,t as a}from"./react-query-BIbNygEJ.js";import{i as o}from"./motion-B3ZE8SGR.js";import{d as s,l as ee,n as c,t as l,u}from"./ui-CV-Z6sqF.js";import{s as d,u as te}from"./index-picB46b5.js";import{n as f}from"./LazyJson-DYncL_RR.js";import{t as p}from"./useEngineStream-ChEkuUVV.js";function m(e,t){return Array.isArray(e)?e:Array.isArray(e?.[t])?e[t]:[]}function h(e){return String(e||``).trim()}function ne(e){return e?`ok`:`ghost`}function g(e){return h(e?.event_type||e?.type||e?.event||`workflow.event`)}function _(e,t){return`/api/engine/packs/${encodeURIComponent(h(e))}/files/${encodeURI(h(t))}`}function v({api:v,toast:y}){let b=r(),[x,S]=n(``),[C,w]=n(``),[T,E]=n(``),[D,re]=n(`context.task.created`),[O,ie]=n(`{
2
- "event_id": "demo-task-1"
3
- }`),[k,A]=n([]),ae=i({queryKey:[`packs`,`list`],queryFn:()=>v(`/api/engine/packs`,{method:`GET`}).catch(()=>({packs:[]})),refetchInterval:15e3}),j=i({queryKey:[`workflows`,`list`],queryFn:()=>v(`/api/engine/workflows`,{method:`GET`}).catch(()=>({workflows:[]})),refetchInterval:15e3}),M=i({queryKey:[`workflows`,`hooks`],queryFn:()=>v(`/api/engine/workflow-hooks`,{method:`GET`}).catch(()=>({hooks:[]})),refetchInterval:15e3}),N=m(ae.data,`packs`),P=m(j.data,`workflows`),oe=m(M.data,`hooks`),F=t(()=>C||h(N[0]?.pack_id||N[0]?.name),[N,C]),I=t(()=>T||h(P[0]?.workflow_id),[T,P]),L=m(i({queryKey:[`workflows`,`runs`,I],queryFn:()=>v(`/api/engine/workflows/runs${I?`?workflow_id=${encodeURIComponent(I)}&limit=20`:`?limit=20`}`,{method:`GET`}).catch(()=>({runs:[]})),refetchInterval:6e3}).data,`runs`),se=i({queryKey:[`packs`,`detail`,F],enabled:!!F,queryFn:()=>v(`/api/engine/packs/${encodeURIComponent(F)}`,{method:`GET`})}),R=i({queryKey:[`workflows`,`detail`,I],enabled:!!I,queryFn:()=>v(`/api/engine/workflows/${encodeURIComponent(I)}`,{method:`GET`})}),z=a({mutationFn:()=>v(`/api/engine/packs/install`,{method:`POST`,body:JSON.stringify({path:x,source:{kind:`control-panel`}})}),onSuccess:async()=>{y(`ok`,`Pack installed.`),S(``),await Promise.all([b.invalidateQueries({queryKey:[`packs`]}),b.invalidateQueries({queryKey:[`workflows`]})])},onError:e=>y(`err`,e instanceof Error?e.message:String(e))}),B=a({mutationFn:e=>v(`/api/engine/workflows/${encodeURIComponent(e)}/run`,{method:`POST`}),onSuccess:async e=>{y(`ok`,`Workflow ${h(e?.run?.workflow_id||I)} started.`),await Promise.all([b.invalidateQueries({queryKey:[`workflows`]}),b.invalidateQueries({queryKey:[`workflows`,`runs`]})])},onError:e=>y(`err`,e instanceof Error?e.message:String(e))}),V=a({mutationFn:async()=>{let e={},t=h(O);return t&&(e=JSON.parse(t)),v(`/api/engine/workflows/simulate`,{method:`POST`,body:JSON.stringify({event_type:D,properties:e})})},onError:e=>y(`err`,e instanceof Error?e.message:String(e))}),H=a({mutationFn:({bindingId:e,enabled:t})=>v(`/api/engine/workflow-hooks/${encodeURIComponent(e)}`,{method:`PATCH`,body:JSON.stringify({enabled:t})}),onSuccess:async()=>{await Promise.all([b.invalidateQueries({queryKey:[`workflows`,`hooks`]}),b.invalidateQueries({queryKey:[`workflows`,`detail`]})])},onError:e=>y(`err`,e instanceof Error?e.message:String(e))}),U=se.data?.pack||null,W=R.data?.workflow||null,G=m(R.data,`hooks`),K=V.data?.simulation||null,q=U?.manifest?.marketplace||null,J=q?.publisher||null,Y=q?.listing||null,X=h(Y?.icon||``),Z=h(i({queryKey:[`packs`,`readme`,F],enabled:!!F,queryFn:async()=>{let e=await fetch(_(F,`README.md`),{credentials:`include`});return e.ok?e.text():``}}).data||``),Q=X?_(F,X):``,$=m(Y,`screenshots`).map(e=>h(e));return p(`/api/engine/workflows/events${I?`?workflow_id=${encodeURIComponent(I)}`:``}`,e=>{try{let t=JSON.parse(e.data);if(t?.status===`ready`)return;A(e=>[...e.slice(-59),{at:Date.now(),data:t}])}catch{}},{enabled:!0}),o(l,{className:`grid gap-4`,children:[o(ee,{eyebrow:`Operations`,title:`Pack library and workflow lab`,subtitle:`Inspect installed packs, see workflow extensions, toggle hooks, simulate lifecycle events, and run workflow definitions without leaving the control panel.`,badges:o(e,{children:[o(c,{tone:`info`,children:[N.length,` installed packs`]}),o(c,{tone:`warn`,children:[P.length,` workflows`]}),o(c,{tone:`ghost`,children:[oe.length,` hooks`]})]})}),o(s,{main:o(`div`,{className:`grid gap-4`,children:[o(u,{title:`Installed packs`,subtitle:`Select a pack to inspect its manifest, declared workflow contents, and hook contributions.`,children:o(`div`,{className:`grid gap-2`,children:N.length?N.map((e,t)=>{let n=h(e?.pack_id||e?.name||t);return o(`button`,{type:`button`,className:`tcp-list-item text-left ${n===F?`border-amber-400/70`:``}`,onClick:()=>w(n),children:[o(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[o(`strong`,{children:h(e?.name||n)}),o(`span`,{className:`tcp-badge-info`,children:h(e?.version||`-`)})]}),o(`div`,{className:`flex flex-wrap gap-2 text-xs`,children:[o(`span`,{className:`tcp-subtle`,children:h(e?.pack_type||`pack`)}),o(`span`,{className:`tcp-subtle`,children:h(e?.install_path||``)})]})]},n)}):o(d,{text:`No packs are installed yet.`})})}),o(u,{title:`Workflow registry`,subtitle:`This is the live workflow registry resolved from built-ins, installed packs, and workspace-local overrides.`,children:o(`div`,{className:`grid gap-2`,children:P.length?P.map(e=>{let t=h(e?.workflow_id),n=t===I,r=h(e?.source?.kind||`unknown`);return o(`button`,{type:`button`,className:`tcp-list-item text-left ${n?`border-amber-400/70`:``}`,onClick:()=>E(t),children:[o(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[o(`strong`,{children:h(e?.name||t)}),o(`span`,{className:`tcp-badge-${r===`pack`?`warn`:`info`}`,children:r})]}),o(`div`,{className:`tcp-subtle text-xs`,children:[t,` · `,m(e?.steps,`steps`).length,` steps`]})]},t)}):o(d,{text:`No workflows are currently registered.`})})})]}),aside:o(`div`,{className:`grid gap-4`,children:[o(u,{title:`Install pack`,subtitle:`Install a local pack path and reload workflow contributions automatically.`,children:o(`div`,{className:`grid gap-3`,children:[o(`input`,{className:`tcp-input`,value:x,onInput:e=>S(e.target.value),placeholder:`/path/to/pack.zip`}),o(`button`,{className:`tcp-btn-primary`,disabled:!x.trim()||z.isPending,onClick:()=>z.mutate(),children:[o(`i`,{"data-lucide":`download`}),`Install from path`]})]})}),o(u,{title:`Pack inspector`,subtitle:`Shows which workflows and hooks a pack contributes, alongside its current capability surface.`,children:U?o(`div`,{className:`grid gap-3`,children:[o(`div`,{className:`tcp-list-item`,children:[o(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[o(`strong`,{children:h(U?.installed?.name||F)}),o(c,{tone:`info`,children:h(U?.installed?.version||`-`)})]}),o(`div`,{className:`flex flex-wrap gap-2 text-xs`,children:[o(c,{tone:`ghost`,children:[Number(U?.workflow_extensions?.workflow_count||0),` `,`workflows`]}),o(c,{tone:`ghost`,children:[Number(U?.workflow_extensions?.workflow_hook_count||0),` `,`hooks`]}),o(c,{tone:`ghost`,children:[Number(U?.risk?.required_capabilities_count||0),` `,`required caps`]})]})]}),Y?o(`div`,{className:`tcp-list-item grid gap-3`,children:[o(`div`,{className:`flex items-start gap-3`,children:[Q?o(`img`,{src:Q,alt:`${h(Y?.display_name||U?.installed?.name||F)} cover art`,className:`h-24 w-24 rounded-2xl border border-white/10 object-cover`}):null,o(`div`,{className:`min-w-0 flex-1`,children:[o(`div`,{className:`mb-1 flex flex-wrap items-center gap-2`,children:[o(`strong`,{children:h(Y?.display_name||F)}),o(c,{tone:`info`,children:h(J?.verification_tier||`unverified`)})]}),o(`div`,{className:`tcp-subtle text-sm`,children:h(Y?.description||``)}),o(`div`,{className:`mt-2 flex flex-wrap gap-2 text-xs`,children:[o(c,{tone:`ghost`,children:h(J?.display_name||`Unknown publisher`)}),m(Y,`categories`).map(e=>o(c,{tone:`ghost`,children:h(e)},h(e))),m(Y,`tags`).map(e=>o(c,{tone:`ghost`,children:h(e)},h(e)))]})]})]}),$.length?o(`div`,{className:`grid gap-2`,children:[o(`div`,{className:`tcp-subtle text-xs uppercase tracking-[0.24em]`,children:`Screenshots`}),o(`div`,{className:`grid gap-2 md:grid-cols-2`,children:$.map(e=>o(`img`,{src:_(F,e),alt:`${h(Y?.display_name||F)} screenshot`,className:`rounded-2xl border border-white/10`},e))})]}):null,o(`div`,{className:`grid gap-2`,children:[o(`div`,{className:`tcp-subtle text-xs uppercase tracking-[0.24em]`,children:`README Preview`}),Z?o(`div`,{className:`prose prose-invert max-w-none rounded-2xl border border-white/10 bg-black/20 p-4`,dangerouslySetInnerHTML:{__html:te(Z)}}):o(d,{text:`No README preview is available for this pack.`})]})]}):null,o(`div`,{className:`grid gap-2`,children:[o(`div`,{className:`tcp-subtle text-xs uppercase tracking-[0.24em]`,children:`Workflow Entry Points`}),m(U?.workflow_extensions,`workflow_entrypoints`).length?m(U?.workflow_extensions,`workflow_entrypoints`).map((e,t)=>o(`div`,{className:`tcp-list-item text-sm`,children:h(e)},`${h(e)}-${t}`)):o(d,{text:`This pack does not declare workflow entrypoints.`})]}),o(f,{value:U?.manifest||{},label:`Manifest`,className:`tcp-list-item`,preClassName:`tcp-subtle mt-3 overflow-x-auto text-xs`})]}):o(d,{text:`Select an installed pack to inspect workflow extensions.`})})]})}),o(s,{main:o(u,{title:`Workflow viewer`,subtitle:`Structured view of workflow steps and source provenance for the selected workflow.`,actions:o(`button`,{className:`tcp-btn`,disabled:!I||B.isPending,onClick:()=>I&&B.mutate(I),children:[o(`i`,{"data-lucide":`play`}),`Run workflow`]}),children:W?o(`div`,{className:`grid gap-3`,children:[o(`div`,{className:`tcp-list-item`,children:[o(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[o(`strong`,{children:h(W?.name||I)}),o(c,{tone:`info`,children:h(W?.source?.kind||`unknown`)})]}),o(`div`,{className:`tcp-subtle text-sm`,children:h(W?.description||`No description provided.`)})]}),o(`div`,{className:`grid gap-2`,children:m(W,`steps`).length?m(W,`steps`).map((e,t)=>o(`div`,{className:`tcp-list-item`,children:[o(`div`,{className:`mb-1 text-xs uppercase tracking-[0.24em] text-slate-400`,children:[`Step `,t+1]}),o(`div`,{className:`font-medium`,children:h(e?.action||`unknown`)}),e?.with?o(f,{value:e.with,label:`Show step config`,preClassName:`tcp-subtle mt-2 overflow-x-auto text-xs`}):null]},h(e?.step_id||t))):o(d,{text:`This workflow does not define any linear steps.`})})]}):o(d,{text:`Select a workflow to inspect its current resolved definition.`})}),aside:o(`div`,{className:`grid gap-4`,children:[o(u,{title:`Hook manager`,subtitle:`Enable or disable hook bindings on the live registry and inspect the attached actions.`,children:o(`div`,{className:`grid gap-2`,children:G.length?G.map(e=>{let t=h(e?.binding_id),n=!!e?.enabled;return o(`div`,{className:`tcp-list-item`,children:[o(`div`,{className:`mb-2 flex items-start justify-between gap-2`,children:[o(`div`,{children:[o(`div`,{className:`font-medium`,children:h(e?.event||t)}),o(`div`,{className:`tcp-subtle text-xs`,children:t})]}),o(`button`,{className:`tcp-btn`,disabled:H.isPending,onClick:()=>H.mutate({bindingId:t,enabled:!n}),children:n?`Disable`:`Enable`})]}),o(`div`,{className:`mb-2 flex flex-wrap gap-2`,children:[o(c,{tone:ne(n),children:n?`Enabled`:`Disabled`}),o(c,{tone:`ghost`,children:[m(e,`actions`).length,` actions`]})]}),o(`div`,{className:`grid gap-1`,children:m(e,`actions`).map((e,n)=>o(`div`,{className:`tcp-subtle text-xs`,children:h(e?.action||e)},`${t}-${n}`))})]},t)}):o(d,{text:`The selected workflow has no registered hooks.`})})}),o(u,{title:`Recent workflow runs`,subtitle:`Latest workflow executions for the selected workflow, including hook-triggered runs.`,children:o(`div`,{className:`grid gap-2`,children:L.length?L.map((e,t)=>{let n=h(e?.status||`unknown`),r=n===`completed`?`ok`:n===`failed`?`err`:n===`running`?`warn`:`ghost`;return o(`div`,{className:`tcp-list-item`,children:[o(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[o(`strong`,{children:h(e?.run_id||`run-${t+1}`)}),o(c,{tone:r,children:n})]}),o(`div`,{className:`tcp-subtle text-xs`,children:[`trigger: `,h(e?.trigger_event||`manual`)]}),o(`div`,{className:`tcp-subtle text-xs`,children:[`actions: `,m(e,`actions`).length]})]},h(e?.run_id||t))}):o(d,{text:`No workflow runs have been recorded yet.`})})})]})}),o(s,{main:o(u,{title:`Workflow testing mode`,subtitle:`Simulate a source event to see which hooks will match before triggering real actions.`,actions:o(`button`,{className:`tcp-btn-primary`,disabled:!D.trim()||V.isPending,onClick:()=>V.mutate(),children:[o(`i`,{"data-lucide":`flask-conical`}),`Simulate`]}),children:o(`div`,{className:`grid gap-3`,children:[o(`input`,{className:`tcp-input`,value:D,onInput:e=>re(e.target.value),placeholder:`context.task.created`}),o(`textarea`,{className:`tcp-input min-h-[180px] font-mono text-xs`,value:O,onInput:e=>ie(e.target.value),spellCheck:!1}),K?o(`div`,{className:`grid gap-3`,children:[o(`div`,{className:`flex flex-wrap gap-2`,children:m(K,`canonical_events`).map((e,t)=>o(c,{tone:`info`,children:h(e)},`${h(e)}-${t}`))}),o(`div`,{className:`grid gap-2`,children:m(K,`matched_bindings`).length?m(K,`matched_bindings`).map(e=>o(`div`,{className:`tcp-list-item`,children:[o(`div`,{className:`font-medium`,children:h(e?.binding_id)}),o(`div`,{className:`tcp-subtle text-xs`,children:[h(e?.event),` · `,m(e,`actions`).length,` `,`actions`]})]},h(e?.binding_id))):o(d,{text:`No workflow hooks matched this event.`})})]}):o(d,{text:`Run a simulation to inspect canonical events, matched bindings, and planned actions.`})]})}),aside:o(u,{title:`Triggered actions`,subtitle:`Preview of actions the engine plans to execute for the simulated event.`,children:o(`div`,{className:`grid gap-2`,children:m(K,`planned_actions`).length?m(K,`planned_actions`).map((e,t)=>o(`div`,{className:`tcp-list-item`,children:[o(`div`,{className:`font-medium`,children:h(e?.action||e)}),e?.with?o(f,{value:e.with,label:`Show action config`,preClassName:`tcp-subtle mt-2 overflow-x-auto text-xs`}):null]},`${h(e?.action||e)}-${t}`)):o(d,{text:`No planned actions yet.`})})})}),o(u,{title:`Live workflow events`,subtitle:"Real-time `workflow.*` events for the selected workflow, including run start, action completion, and failures.",actions:o(`button`,{className:`tcp-btn`,onClick:()=>A([]),children:[o(`i`,{"data-lucide":`trash-2`}),`Clear stream`]}),children:o(`div`,{className:`grid max-h-[28rem] gap-2 overflow-auto rounded-2xl border border-slate-700/60 bg-black/20 p-2`,children:k.length?[...k].reverse().map((e,t)=>{let n=g(e.data),r=n.endsWith(`.failed`)?`err`:n.endsWith(`.completed`)?`ok`:n.endsWith(`.started`)?`warn`:`info`;return o(`div`,{className:`tcp-list-item`,children:[o(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[o(`strong`,{children:n}),o(c,{tone:r,children:new Date(e.at).toLocaleTimeString()})]}),o(`div`,{className:`tcp-subtle text-xs`,children:[`run: `,h(e.data?.properties?.runID||`n/a`)]}),o(`div`,{className:`tcp-subtle text-xs`,children:[`action:`,` `,h(e.data?.properties?.action||e.data?.properties?.actionID||`-`)]})]},`${e.at}-${t}`)}):o(d,{text:`Run a workflow or trigger a hook to watch live workflow events here.`})})})]})}export{v as PacksPage};
@@ -1 +0,0 @@
1
- import{i as e}from"./motion-B3ZE8SGR.js";import{n as t,u as n}from"./ui-CV-Z6sqF.js";function r({title:t,description:n,children:r,className:i=``}){return e(`div`,{className:`rounded-xl border border-white/10 bg-black/20 p-3 ${i}`.trim(),children:[e(`div`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:t}),n?e(`div`,{className:`mt-1 text-xs text-slate-400`,children:n}):null,e(`div`,{className:`mt-2`,children:r})]})}function i({metrics:t,columns:n=`sm:grid-cols-2`}){return e(`div`,{className:`grid gap-2 ${n}`.trim(),children:t.map(t=>e(r,{title:t.label,children:[e(`div`,{className:`text-slate-100`,children:t.value}),t.detail?e(`div`,{className:`mt-1 text-xs text-slate-400`,children:t.detail}):null]},t.label))})}function a(e){return String(e||``).trim()}function o(e){return Array.isArray(e)?e.map(e=>a(e)).filter(Boolean):[]}function s({plannerDiagnostics:i,teachingLibrary:s,planningChangeSummary:c}){let l=o(s?.explanations||s?.explanation||[]),u=o(s?.objections||[]),d=o(s?.proof_points||s?.proofPoints||[]),f=a(i?.fallback_reason||i?.fallbackReason||``),p=a(i?.summary||i?.detail||``),m=i?.task_budget||i?.taskBudget||i?.decomposition_observation?.task_budget||i?.decompositionObservation?.taskBudget||i?.observation?.task_budget||i?.observation?.taskBudget||null,h=a(m?.status||``),g=Number(m?.original_step_count??m?.originalStepCount),_=Number(m?.generated_step_count??m?.generatedStepCount),v=Number(m?.max_generated_steps??m?.maxGeneratedSteps),y=h===`compacted`&&Number.isFinite(g)&&Number.isFinite(_)?`Planner compacted ${g} generated tasks into ${_} runnable workflow steps.`:h===`rejected`&&Number.isFinite(_)&&Number.isFinite(v)?`Generated plan has ${_} tasks, above the ${v} task budget.`:h===`within_budget`&&Number.isFinite(_)&&Number.isFinite(v)?`Generated plan is within budget: ${_}/${v} tasks.`:``;return e(n,{title:`Diagnostics`,subtitle:`Planner guidance, change summary, and compiler notes.`,children:e(`div`,{className:`grid gap-3 text-sm`,children:[e(`div`,{className:`flex flex-wrap gap-2`,children:[e(t,{tone:i?`ok`:`warn`,children:i?`diagnostics ready`:`diagnostics pending`}),e(t,{tone:l.length?`ok`:`warn`,children:l.length?`teaching library ready`:`teaching library pending`}),f?e(t,{tone:`info`,children:f.replace(/_/g,` `)}):null,h?e(t,{tone:h===`rejected`?`warn`:`ok`,children:[`task budget `,h.replace(/_/g,` `)]}):null]}),e(r,{title:`Planner diagnostics`,children:[e(`div`,{className:`text-slate-200`,children:p||`No planner diagnostics yet.`}),y?e(`div`,{className:`mt-2 rounded-lg border border-lime-400/30 bg-lime-400/10 p-2 text-lime-100`,children:y}):null]}),c.length?e(r,{title:`Latest changes`,children:e(`ul`,{className:`mt-2 grid gap-2 text-slate-200`,children:c.map(t=>e(`li`,{className:`rounded-lg border border-white/10 bg-black/20 p-2`,children:t},t))})}):null,l.length||u.length||d.length?e(`div`,{className:`grid gap-3 lg:grid-cols-3`,children:[e(r,{title:`Explanations`,children:e(`ul`,{className:`mt-2 grid gap-2 text-slate-200`,children:l.length?l.map(t=>e(`li`,{className:`rounded-lg border border-white/10 bg-black/20 p-2`,children:t},t)):e(`li`,{className:`tcp-subtle text-xs`,children:`No explanation guidance yet.`})})}),e(r,{title:`Objections`,children:e(`ul`,{className:`mt-2 grid gap-2 text-slate-200`,children:u.length?u.map(t=>e(`li`,{className:`rounded-lg border border-white/10 bg-black/20 p-2`,children:t},t)):e(`li`,{className:`tcp-subtle text-xs`,children:`No objection guidance yet.`})})}),e(r,{title:`Proof points`,children:e(`ul`,{className:`mt-2 grid gap-2 text-slate-200`,children:d.length?d.map(t=>e(`li`,{className:`rounded-lg border border-white/10 bg-black/20 p-2`,children:t},t)):e(`li`,{className:`tcp-subtle text-xs`,children:`No proof-point guidance yet.`})})})]}):null]})})}export{i as n,r,s as t};
@@ -1 +0,0 @@
1
- import{v as e}from"./fullcalendar-Bn75j0xM.js";import{i as t}from"./motion-B3ZE8SGR.js";import{t as n}from"./ui-CV-Z6sqF.js";import{c as r}from"./index-picB46b5.js";import{MyAutomations as i}from"./AutomationsPage-6mRHsh9V.js";function a({client:a,toast:o,navigate:s}){let[c,l]=e(``);return t(n,{className:`grid h-full min-h-0 gap-4`,children:t(r,{title:`Run Overview`,subtitle:`Watch active and blocked runs together, then open the full debugger for any individual automation run.`,actions:t(`div`,{className:`flex flex-wrap items-center gap-2`,children:t(`button`,{className:`tcp-btn h-8 px-3 text-xs`,onClick:()=>s(`automations`),children:[t(`i`,{"data-lucide":`bot`}),`Open automations`]})}),fullHeight:!0,children:t(i,{client:a,toast:o,navigate:s,viewMode:`running`,selectedRunId:c,onSelectRunId:l,onOpenRunningView:()=>void 0,onOpenAdvancedEdit:()=>void 0,defaultRunningSectionsOpen:{active:!0,issues:!0,history:!0}})})})}export{a as RunsPage};