@frumu/tandem-panel 0.5.4 → 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 (56) hide show
  1. package/bin/setup.js +1 -0
  2. package/dist/assets/AutomationsPage-BGqpmilp.js +946 -0
  3. package/dist/assets/BugMonitorPage-BVzdj9y-.js +4 -0
  4. package/dist/assets/ChannelsPage-B-InJ4Yh.js +1 -0
  5. package/dist/assets/ChatInterfacePanel-BrMo4cXg.js +1 -0
  6. package/dist/assets/ChatPage-Bc-BfOG1.js +1 -0
  7. package/dist/assets/CodingWorkflowsPage-xgfwLRlt.js +8 -0
  8. package/dist/assets/ControlPanelDialogs-yFfCht3Y.js +1 -0
  9. package/dist/assets/DashboardPage-CrA1itFc.js +1 -0
  10. package/dist/assets/ExperimentsPage-Bkg1_6rw.js +84 -0
  11. package/dist/assets/FilesPage-DChyHlO_.js +1 -0
  12. package/dist/assets/IntentPlannerPage-Dti1h8Tm.js +5 -0
  13. package/dist/assets/LazyJson-vfWw7G9F.js +1 -0
  14. package/dist/assets/MarketplacePage-90fAVNGg.js +1 -0
  15. package/dist/assets/McpToolAllowlistEditor-BzQ64HrZ.js +1 -0
  16. package/dist/assets/MemoryImportDialog-DSpS1JF5.js +1 -0
  17. package/dist/assets/MemoryPage-DRRLgoc0.js +1 -0
  18. package/dist/assets/OrchestratorPage-CYU-ESPI.js +3 -0
  19. package/dist/assets/PacksPage-dRmjjdKD.js +3 -0
  20. package/dist/assets/PlannerDiagnosticsPanel-C1uIuRIx.js +1 -0
  21. package/dist/assets/ProviderModelSelector-BdtOpkJR.js +1 -0
  22. package/dist/assets/RunsPage-DEy8vbRT.js +1 -0
  23. package/dist/assets/SettingsPage-CwH_FzOs.js +5 -0
  24. package/dist/assets/TaskBoard-CCY_Qy5S.js +1 -0
  25. package/dist/assets/TeamsPage-Dn81V0EB.js +4472 -0
  26. package/dist/assets/TimezoneField-B5i---lF.js +1 -0
  27. package/dist/assets/WorkflowStudioPage-yFhlA4KV.js +1854 -0
  28. package/dist/assets/WorkflowsPage-vmaKHFox.js +2 -0
  29. package/dist/assets/chatPageHelpers-Dmb4waDk.js +1 -0
  30. package/dist/assets/explorerHandoff-BPKxMR82.js +1 -0
  31. package/dist/assets/format-DyX5imzJ.js +1 -0
  32. package/dist/assets/fullcalendar-Bn75j0xM.js +1 -0
  33. package/dist/assets/index-C8Bjo7hU.css +1 -0
  34. package/dist/assets/index-TvymvGva.js +3 -0
  35. package/dist/assets/messages-uD0aB_MZ.js +3 -0
  36. package/dist/assets/motion-B3ZE8SGR.js +9 -0
  37. package/dist/assets/plannerShared-Dx7-Sxpc.js +1 -0
  38. package/dist/assets/preact-vendor-DaCG_P2o.js +1 -0
  39. package/dist/assets/react-query-BIbNygEJ.js +1 -0
  40. package/dist/assets/sse-B4A2m-Nk.js +2 -0
  41. package/dist/assets/useEngineStream-Diqri33l.js +1 -0
  42. package/dist/assets/vendor-DSaYtO9f.js +156 -0
  43. package/dist/assets/workflowStability-C8USyGOY.js +2 -0
  44. package/dist/index.html +8 -7
  45. package/lib/automations/workflow-list.js +147 -0
  46. package/lib/setup/control-panel-preferences.js +4 -0
  47. package/package.json +3 -3
  48. package/server/routes/capabilities.js +1 -0
  49. package/server/routes/knowledgebase.js +7 -1
  50. package/dist/assets/index-BL-9rGEh.css +0 -1
  51. package/dist/assets/index-DhoScTZK.js +0 -7379
  52. package/dist/assets/motion-CBnf8hfk.js +0 -9
  53. package/dist/assets/preact-vendor-B239Onrg.js +0 -1
  54. package/dist/assets/react-query-_hsOQSt5.js +0 -1
  55. package/dist/assets/vendor-DZYPF2Pz.js +0 -156
  56. /package/dist/assets/{markdown-Dd89TVib.js → markdown-Dwwtq3bu.js} +0 -0
@@ -0,0 +1,946 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/fullcalendar-Bn75j0xM.js","assets/rolldown-runtime-Dgq8h090.js"])))=>i.map(i=>d[i]);
2
+ import{C as e,E as t,_ as n,g as r,h as i,v as a,x as o}from"./fullcalendar-Bn75j0xM.js";import{a as s,n as c,r as l,t as u}from"./react-query-BIbNygEJ.js";import{t as d}from"./vendor-DSaYtO9f.js";import{i as f,n as p,r as m}from"./motion-B3ZE8SGR.js";import{a as h,c as g,d as _,l as v,o as y,s as b,u as x,v as S,w as C}from"./index-TvymvGva.js";import{d as w}from"./chatPageHelpers-Dmb4waDk.js";import{A as T,C as E,D,E as O,M as ee,N as te,O as k,P as ne,S as A,T as j,_ as re,a as M,b as N,c as P,d as ie,f as F,h as ae,i as oe,j as I,k as se,l as L,m as R,n as ce,o as le,p as ue,r as de,s as fe,t as pe,u as z,v as me,w as he,x as ge,y as _e}from"./workflowStability-C8USyGOY.js";import{n as ve,t as B}from"./TaskBoard-CCY_Qy5S.js";import{a as V,i as H,n as ye,r as U,t as be}from"./TimezoneField-B5i---lF.js";import{r as xe,t as Se}from"./McpToolAllowlistEditor-BzQ64HrZ.js";import{t as W}from"./ProviderModelSelector-BdtOpkJR.js";import{n as G,t as Ce}from"./LazyJson-vfWw7G9F.js";import{n as we,r as Te}from"./explorerHandoff-BPKxMR82.js";import{t as Ee}from"./format-DyX5imzJ.js";import{t as De}from"./useEngineStream-Diqri33l.js";import{i as Oe,n as ke,r as Ae,t as je}from"./plannerShared-Dx7-Sxpc.js";import{t as Me}from"./ChatInterfacePanel-BrMo4cXg.js";function Ne({icon:e,label:t}){return f(`span`,{className:`inline-flex items-center gap-2`,children:[f(`i`,{"data-lucide":e,className:`h-4 w-4 text-amber-300/90`}),f(`span`,{children:t})]})}function Pe({payload:e,toast:t,setAdvancedEditAutomation:n,setCreateMode:r,setTab:i,composerEnabled:a}){let o=String(e?.prompt||``).trim();if(!o){t(`err`,`No original prompt was found for this workflow.`);return}w({prompt:o,plan_source:`workflow_recreate`}),n(null),r(a?`composer`:`simple`),i(`create`),t(`ok`,a?`Opened AI Composer with the recovered workflow prompt.`:`Opened Create with the recovered workflow prompt.`)}function Fe({tab:n,setTab:r,createMode:i,setCreateMode:a,selectedRunId:o,setSelectedRunId:s,advancedEditAutomation:c,setAdvancedEditAutomation:l,navigationLocked:u,onNavigationLockChange:d,client:p,api:m,toast:g,navigate:_,providerStatus:v,composerEnabled:y,PageCardComponent:b,CreateWizardComponent:x,AutomationComposerPanelComponent:S,MyAutomationsComponent:C,AdvancedMissionBuilderPanelComponent:w}){e(()=>{try{h()}catch{}},[n,i,y]);let T=[{id:`create`,label:`Create`,icon:`sparkles`},{id:`calendar`,label:`Calendar`,icon:`calendar`},{id:`list`,label:`Library`,icon:`book-open`},{id:`running`,label:`Run History`,icon:`history`}],E=e=>{e!==`running`&&s(``),r(e)},D=e=>Pe({payload:e,toast:g,setAdvancedEditAutomation:l,setCreateMode:a,setTab:r,composerEnabled:y});return f(`div`,{className:`flex flex-col h-full gap-4`,children:[f(`div`,{className:`flex gap-1 rounded-xl border border-slate-700/50 bg-slate-900/40 p-1`,children:T.map(e=>f(`button`,{onClick:()=>E(e.id),disabled:u,className:`flex flex-1 items-center justify-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium transition-all ${n===e.id?`bg-amber-500/20 text-amber-300 shadow-sm`:`text-slate-400 hover:text-slate-200`}`,children:[f(`i`,{"data-lucide":e.icon}),f(`span`,{children:e.label})]},e.id))}),f(`div`,{className:`flex-1 flex flex-col min-h-0`,children:n===`create`?f(b,{title:f(Ne,{icon:`sparkles`,label:`Create an Automation`}),subtitle:`Describe what you want, pick a schedule, and Tandem handles the rest`,fullHeight:!0,children:f(`div`,{className:`flex flex-col flex-1 min-h-0 h-full gap-4`,children:i===`composer`&&y?f(S,{client:p,api:m,toast:g,defaultProvider:v.defaultProvider,defaultModel:v.defaultModel,onNavigationLockChange:d,onShowAutomations:()=>{l(null),r(`list`)},onShowRuns:()=>{l(null),r(`running`)}}):f(t,{children:[f(`div`,{className:`rounded-xl border border-slate-700/50 bg-slate-950/50 p-4 shrink-0`,children:[f(`div`,{className:`mb-2 text-xs font-medium uppercase tracking-[0.24em] text-slate-500`,children:`Builder Mode`}),f(`div`,{className:`tcp-subtle text-xs`,children:`Keep the simple wizard for quick automations, or switch to Mission Builder for generated multi-step missions you can tune before launch.`}),f(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[f(`button`,{type:`button`,disabled:u,className:`tcp-btn h-9 px-3 text-sm ${i===`simple`?`border-amber-400/60 bg-amber-400/10 text-amber-300`:``}`,onClick:()=>{a(`simple`),l(null)},children:`Simple Wizard`}),f(`button`,{type:`button`,disabled:u,className:`tcp-btn h-9 px-3 text-sm ${i===`advanced`?`border-amber-400/60 bg-amber-400/10 text-amber-300`:``}`,onClick:()=>a(`advanced`),children:`Mission Builder`}),y?f(`button`,{type:`button`,disabled:u,className:`tcp-btn h-9 px-3 text-sm ${i===`composer`?`border-amber-400/60 bg-amber-400/10 text-amber-300`:``}`,onClick:()=>{a(`composer`),l(null)},children:`AI Composer`}):null]})]}),i===`advanced`?f(w,{client:p,api:m,toast:g,defaultProvider:v.defaultProvider,defaultModel:v.defaultModel,editingAutomation:c,onShowAutomations:()=>{l(null),r(`list`)},onShowRuns:()=>{l(null),r(`running`)},onClearEditing:()=>l(null),onNavigationLockChange:d}):f(x,{client:p,api:m,toast:g,navigate:_,defaultProvider:v.defaultProvider,defaultModel:v.defaultModel,onNavigationLockChange:d,onCreated:()=>{l(null),r(`list`)}})]})})}):n===`calendar`?f(b,{title:f(Ne,{icon:`calendar`,label:`Automation Calendar`}),subtitle:`Weekly schedule view for cron automations`,children:f(C,{client:p,toast:g,navigate:_,viewMode:`calendar`,selectedRunId:o,onSelectRunId:s,onOpenRunningView:()=>r(`running`),onOpenAdvancedEdit:e=>{l(e),a(`advanced`),r(`create`)},onRecreateWorkflowAutomation:D,defaultRunningSectionsOpen:{active:!0,issues:!0,history:!0}})}):n===`list`?f(b,{title:f(Ne,{icon:`book-open`,label:`Library`}),subtitle:`Installed packs, routines and run history`,children:f(C,{client:p,toast:g,navigate:_,viewMode:`list`,selectedRunId:o,onSelectRunId:s,onOpenRunningView:()=>r(`running`),onOpenAdvancedEdit:e=>{l(e),a(`advanced`),r(`create`)},onRecreateWorkflowAutomation:D})}):n===`running`?f(b,{title:f(Ne,{icon:`history`,label:`Run History`}),subtitle:`Inspect active runs and open detailed event logs for each run`,children:f(C,{client:p,toast:g,navigate:_,viewMode:`running`,selectedRunId:o,onSelectRunId:s,onOpenRunningView:()=>r(`running`),onOpenAdvancedEdit:e=>{l(e),a(`advanced`),r(`create`)},onRecreateWorkflowAutomation:D})}):f(b,{title:f(Ne,{icon:`book-open`,label:`Library`}),subtitle:`Saved automations, routines, and run history`,children:f(C,{client:p,toast:g,navigate:_,viewMode:`list`,selectedRunId:o,onSelectRunId:s,onOpenRunningView:()=>r(`running`),onOpenAdvancedEdit:e=>{l(e),a(`advanced`),r(`create`)},onRecreateWorkflowAutomation:D})})})]})}function Ie(e){return e===`yolo`?`Lenient`:e===`guided`?`Guided`:`Strict`}function Le(e){return e===`yolo`?`Lenient experimental run. Runtime logging, receipts, spend caps, and approvals remain active.`:e===`guided`?`Assisted iteration. Non-critical validation failures become warnings; critical failures still block.`:`Production discipline. All validators enforced.`}function Re(e){let t=String(e?.effective_execution_profile||e?.effectiveExecutionProfile||e?.requested_execution_profile||e?.requestedExecutionProfile||``).trim().toLowerCase();return t===`guided`||t===`yolo`?t:`strict`}function ze(e){let t=String(e?.requested_execution_profile||e?.requestedExecutionProfile||``).trim().toLowerCase();return t===`strict`||t===`guided`||t===`yolo`?t:null}function K(e){return!e||typeof e!=`object`?!1:e.experimental===!0||String(e.effective_outcome||e.effectiveOutcome||``).trim().toLowerCase()===`experimental`}function Be(e){if(!e||typeof e!=`object`)return[];let t=e.relaxed_validator_classes||e.relaxedValidatorClasses||[];return Array.isArray(t)?t.filter(e=>!!(e&&typeof e==`object`)).map(e=>({class:String(e.class??``),detail:typeof e.detail==`string`?e.detail:void 0,original_outcome:typeof e.original_outcome==`string`?e.original_outcome:void 0,effective_outcome:typeof e.effective_outcome==`string`?e.effective_outcome:void 0})).filter(e=>e.class.length>0):[]}function Ve(e){let t=String(e||``).trim().toLowerCase();return[`queued`,`running`,`in_progress`,`executing`,`pending_approval`,`awaiting_approval`].includes(t)}function He(e){return String(e?.scheduler?.queue_reason||e?.scheduler?.queueReason||e?.scheduler?.reason||``).trim().toLowerCase()}function Ue(e){return String(e?.scheduler?.resource_key||e?.scheduler?.resourceKey||``).trim()}function We(e){if(!e)return`time unavailable`;let t=Math.max(0,Date.now()-e),n=Math.floor(t/1e3);return n<60?`${n}s ago`:n<3600?`${Math.floor(n/60)}m ago`:`${Math.floor(n/3600)}h ago`}function q(e){let t=P(e);if(t!==`queued`)return t||`unknown`;let n=He(e);if(n===`workspace_lock`)return`queued (workspace lock)`;if(n===`capacity`)return`queued (capacity)`;if(n===`rate_limit`){let t=String(e?.scheduler?.rate_limited_provider||e?.scheduler?.rateLimitedProvider||``).trim();return t?`queued (rate limit: ${t})`:`queued (rate limit)`}return`queued`}function Ge(e){if(k(e))return`Run was paused automatically after provider activity stopped`;if(O(e)){let t=ce(e);return t>0?`Waiting on ${t} active session${t===1?``:`s`}; last provider activity ${We(D(e))}`:`Run is possibly stale: last provider activity ${We(D(e))}`}if(P(e)===`stalled`)return`Run appears stalled: last provider activity ${We(D(e))}`;let t=He(e);if(!t)return``;if(t===`workspace_lock`){let t=Ue(e);return t?`Waiting for workspace lock: ${t}`:`Waiting for workspace lock`}if(t===`capacity`)return`Waiting for scheduler capacity`;if(t===`rate_limit`){let t=String(e?.scheduler?.rate_limited_provider||e?.scheduler?.rateLimitedProvider||``).trim();return t?`Waiting for provider rate limit: ${t}`:`Waiting for provider rate limit`}return``}function Ke(e){let t=Number(e?.started_at_ms||e?.fired_at_ms||e?.created_at_ms||0);if(!Number.isFinite(t)||t<=0)return`time unavailable`;let n=Date.now()-t,r=Math.max(0,Math.floor(n/1e3));return r<60?`${r}s`:r<3600?`${Math.floor(r/60)}m`:`${Math.floor(r/3600)}h`}function qe(e,t){let n=[],r=P(e);return k(e)?n.push(`Run was paused automatically after provider activity stopped.`):O(e)&&n.push(`Run may be stale. Check the latest lifecycle event and provider activity.`),(r===`pending_approval`||r===`awaiting_approval`)&&n.push(`Run is waiting for approval before external actions.`),r===`blocked_policy`&&n.push(`Run was blocked by policy. Check tool allowlist and integration permissions.`),(r===`failed`||r===`error`)&&n.push(`Run failed. Inspect detail/error fields for root cause.`),(r===`completed`||r===`done`)&&!t.length&&n.push(`Run completed but produced no artifacts. Verify output target and tool actions.`),e?.requires_approval===!0&&n.push(`Automation policy requires human approval. Disable it for fully automated runs.`),n}function Je(e){let t=Number(e||0);return!Number.isFinite(t)||t<=0?Date.now():t<0xe8d4a51000?t*1e3:t}function Ye(e){let t=Number(e||0);return!Number.isFinite(t)||t<=0?null:t<0xe8d4a51000?t*1e3:t}function Xe(e){let t=Ye(e);return t?new Date(t).toLocaleTimeString():`time unavailable`}function Ze(e,t=28){let n=String(e||``).trim();if(!n)return``;if(n.length<=t)return n;let r=Math.max(8,Math.floor((t-1)/2)),i=Math.max(6,t-r-1);return`${n.slice(0,r)}…${n.slice(-i)}`}function Qe(e,t=88){let n=String(e||``).replace(/\s+/g,` `).trim();return n?n.length>t?`${n.slice(0,t-1).trimEnd()}…`:n:``}function $e(e){return String(e?.mission_snapshot?.objective||e?.mission?.objective||e?.objective||e?.name||``).replace(/\s+/g,` `).trim()}function et(e){let t=String(e||``).trim();return t?!!(/^automation-v2(?:-run)?-[0-9a-f]{8,}(?:-[0-9a-f]{4,}){1,}$/i.test(t)||/^run-[0-9a-f]{8,}(?:-[0-9a-f]{4,}){1,}$/i.test(t)||/^[0-9a-f]{8,}(?:-[0-9a-f]{4,}){2,}$/i.test(t)):!1}function tt(e){let t=[e?.display_title,e?.displayTitle,e?.automation_name,e?.automationName,e?.automation_title,e?.automationTitle,e?.mission_snapshot?.title,e?.mission?.title,e?.title,e?.name].map(e=>String(e||``).trim()).filter(Boolean),n=t.find(e=>!et(e));if(n)return n;let r=$e(e);return r?Qe(r,96):t[0]||String(e?.automation_id||e?.routine_id||``).trim()||`Run`}function nt(e){let t=Number(e||0);return!Number.isFinite(t)||t<=0?``:new Date(Je(t)).toLocaleString()}function rt(e){let t=new Set,n=[];for(let r of e){let e=String(r||``).trim();!e||t.has(e)||(t.add(e),n.push(e))}return n}function it(e){let t=String(e||``).trim();return t?t.includes(`/`)||t.includes(`\\`)?!0:/\.[a-z0-9]{1,8}$/i.test(t):!1}function at(e,t=``,n=0){if(n>4||e==null)return[];if(typeof e==`string`){let n=e.trim();return n&&(/(path|file|artifact)/i.test(t)||it(n))?[n]:[]}return Array.isArray(e)?e.flatMap(e=>at(e,t,n+1)):typeof e==`object`?Object.entries(e).flatMap(([e,t])=>at(t,e,n+1)):[]}function ot(e){return(Array.isArray(e?.parts)?e.parts:[]).map(e=>{let t=String(e?.type||``).trim();if(t===`text`||t===`reasoning`)return String(e?.text||``).trim();if(t===`tool`){let t=String(e?.tool||`tool`).trim(),n=String(e?.error||``).trim(),r=e?.result?v(e.result):``;return[`tool: ${t}`,n?`error: ${n}`:``,r].filter(Boolean).join(`
3
+ `)}return String(e?.text||``).trim()}).filter(Boolean).join(`
4
+
5
+ `).trim()}function st(e){let t=String(e?.info?.role||``).trim().toLowerCase();if(t===`user`)return`user`;if(t===`assistant`)return`assistant`;let n=ot(e).toLowerCase();return n.includes(`engine_error`)||n.includes(`error`)?`error`:`system`}function ct(e){return Array.isArray(e?.parts)?e.parts:[]}function lt(e){return Je(e?.info?.time?.created||e?.info?.created_at_ms||e?.created_at_ms||0)}function ut(e,t){return String(e?.info?.id||e?.id||`message-${t}`).trim()||`message-${t}`}function dt(e){let t=String(e||``).trim();return t?`session ${Ze(t,18)}`:`session`}function ft(e){let t=String(e||``).trim();return t?t.startsWith(`node-`)?t:`node-${t}`:``}function pt(e){let t=String(e||``).trim();if(!t)return``;for(let e of[/node id:\s*([a-z0-9._-]+)/i,/step[_\s]id:\s*([a-z0-9._-]+)/i,/task[_\s]id:\s*(?:node-)?([a-z0-9._-]+)/i]){let n=t.match(e);if(n?.[1])return ft(n[1])}return``}function mt(e,t){let n=String(t||``).trim();if(!n)return[];let r=new Set([n]),i=!0;for(;i;){i=!1;for(let t of Array.isArray(e)?e:[]){let e=String(t?.id||``).trim();!e||r.has(e)||(Array.isArray(t?.dependencies)?t.dependencies.map(e=>String(e||``).trim()).filter(Boolean):[]).some(e=>r.has(e))&&(r.add(e),i=!0)}}return Array.from(r)}function ht(e,t,n){let r=gt(e,t,n);return r.length?r[0]:``}function gt(e,t,n){let r=String(e?.status||``).trim().toLowerCase();if(![`running`,`pausing`,`paused`].includes(r))return[];let i=pe(e);if(i.length)return i;let a=ae(e);if(a)return[a];for(let e=n.length-1;e>=0;--e){let t=n[e]?.event?.properties||n[e]?.event||{},r=ft(String(t?.task_id||t?.step_id||t?.node_id||``).trim());if(r)return[r];let i=pt(String(t?.message||t?.detail||t?.reason||``));if(i)return[i]}for(let e=t.length-1;e>=0;--e){let n=pt(ot(t[e]?.message));if(n)return[n]}let o=R(e);return o?[o]:[]}function _t(e){let t=String(e?.detail||``).trim();return t?t.includes(`BASH_COMMAND_MISSING`)?"This workflow failed because the agent called the `bash` tool without providing a shell command. The tool was available, but the request payload was missing its required `command` field.":t.includes(`WEBFETCH_URL_MISSING`)?`This workflow failed because a web fetch tool call was made without a URL.`:t.includes(`No such file or directory`)?`This workflow failed because the agent tried to read a path that does not exist from the configured workspace root.`:t:``}function vt(e,t,n){let r=[],i=(e,t,n,i,a)=>{n.trim()&&(r.some(t=>t.key===e)||r.push({key:e,title:t,reason:n,source:i,at:a}))};if((e?.requires_approval===!0||String(e?.status||``).trim()===`pending_approval`)&&i(`approval-required`,`Approval required`,String(e?.approval_reason||`Manual approval required before external side effects.`).trim(),`policy`),String(e?.denial_reason||``).trim()&&i(`denied`,`Run denied`,String(e.denial_reason).trim(),`run`),String(e?.paused_reason||``).trim()&&i(`paused`,`Run paused`,String(e.paused_reason).trim(),`run`),String(e?.detail||``).trim()){let t=String(e.detail).trim();(t.toLowerCase().includes(`tool`)||t.toLowerCase().includes(`bash_command_missing`)||t.toLowerCase().includes(`command_missing`)||t.toLowerCase().includes(`permission`)||t.toLowerCase().includes(`approval`)||t.toLowerCase().includes(`mcp`)||t.toLowerCase().includes(`auth`)||t.toLowerCase().includes(`failed after`))&&i(`detail`,`Failure reason`,_t(e),`run`)}se(e).length||i(`missing-session`,`No linked session transcript`,`This run does not expose a linked session transcript, so only telemetry/history are available.`,`run`);for(let t of _e(e)){let e=N(t.value),n=ge(t.value),r=de(t.value);if(String(t?.value?.status||``).trim().toLowerCase()===`blocked`){let e=Array.isArray(n?.executed_tools)?n.executed_tools.join(`, `):``,a=Array.isArray(n?.requested_tools)?n.requested_tools.join(`, `):``;i(`node-status-${t.nodeId}`,`Node blocked: ${t.nodeId}`,[String(t?.value?.blocked_reason||t?.value?.blockedReason||``).trim(),String(t?.value?.blocker_category||t?.value?.blockerCategory||``).trim()?`blocker category: ${String(t?.value?.blocker_category||t?.value?.blockerCategory||``).trim()}`:``,a?`offered tools: ${a}`:``,e?`executed tools: ${e}`:``,String(t?.value?.preflight?.budget_status||t?.value?.preflight?.budgetStatus||``)?`preflight budget: ${String(t?.value?.preflight?.budget_status||t?.value?.preflight?.budgetStatus||``).trim()}`:``,Array.isArray(t?.value?.capability_resolution?.missing_capabilities)&&t.value.capability_resolution.missing_capabilities.length?`missing capabilities: ${t.value.capability_resolution.missing_capabilities.join(`, `)}`:``,t?.value?.capability_resolution?.email_tool_diagnostics?`selected mcp servers: ${Array.isArray(t.value.capability_resolution.email_tool_diagnostics.selected_servers)&&t.value.capability_resolution.email_tool_diagnostics.selected_servers.length?t.value.capability_resolution.email_tool_diagnostics.selected_servers.join(`, `):`none`}`:``,t?.value?.capability_resolution?.email_tool_diagnostics?`email-like tools discovered: ${Array.isArray(t.value.capability_resolution.email_tool_diagnostics.available_tools)&&t.value.capability_resolution.email_tool_diagnostics.available_tools.length?t.value.capability_resolution.email_tool_diagnostics.available_tools.join(`, `):`none`}`:``,t?.value?.capability_resolution?.email_tool_diagnostics?`email-like tools offered: ${Array.isArray(t.value.capability_resolution.email_tool_diagnostics.offered_tools)&&t.value.capability_resolution.email_tool_diagnostics.offered_tools.length?t.value.capability_resolution.email_tool_diagnostics.offered_tools.join(`, `):`none`}`:``,t?.value?.capability_resolution?.mcp_tool_diagnostics?`mcp remote tools: ${Array.isArray(t.value.capability_resolution.mcp_tool_diagnostics.remote_tools)&&t.value.capability_resolution.mcp_tool_diagnostics.remote_tools.length?t.value.capability_resolution.mcp_tool_diagnostics.remote_tools.join(`, `):`none`}`:``,t?.value?.capability_resolution?.mcp_tool_diagnostics?`registered mcp tools: ${Array.isArray(t.value.capability_resolution.mcp_tool_diagnostics.registered_tools)&&t.value.capability_resolution.mcp_tool_diagnostics.registered_tools.length?t.value.capability_resolution.mcp_tool_diagnostics.registered_tools.join(`, `):`none`}`:``,String(r?.semantic_block_reason||``).trim()?`research validation: ${String(r?.semantic_block_reason||``).trim()}`:``,String(r?.rejected_artifact_reason||``).trim()?`artifact validation: ${String(r?.rejected_artifact_reason||``).trim()}`:``,Array.isArray(r?.unmet_requirements)&&r.unmet_requirements.length?`unmet requirements: ${r.unmet_requirements.join(`, `)}`:``,Array.isArray(r?.undeclared_files_created)&&r.undeclared_files_created.length?`undeclared files created: ${r.undeclared_files_created.join(`, `)}`:``,r?.auto_cleaned?`artifact cleanup was applied`:``,n&&!n?.web_research_used?`web research was not used`:``,n&&!n?.workspace_inspection_used?`workspace inspection was not used`:``].filter(Boolean).join(`
6
+ `),t.nodeId)}if(!e)continue;let a=e.toLowerCase();(a.includes(`could not complete`)||a.includes(`invalid attachment`)||a.includes(`timed out`)||a.includes(`blocked`)||a.includes(`no email delivery tool`)||a.includes(`auth was not approved`))&&i(`node-output-${t.nodeId}`,`Node issue: ${t.nodeId}`,Qe(e,360),t.nodeId,Number(t.value?.created_at_ms||t.value?.createdAtMs||0))}return z([...t,...n]).forEach(e=>{i(e.key,e.title,e.reason,e.source,e.at)}),r.sort((e,t)=>(t.at||0)-(e.at||0))}var yt=[{value:`created_desc`,label:`Created: newest first`},{value:`created_asc`,label:`Created: oldest first`},{value:`name_asc`,label:`Name: A to Z`},{value:`name_desc`,label:`Name: Z to A`}],bt=yt[0].value,xt=[{value:`user_created`,label:`User`},{value:`agent_created`,label:`Agent`},{value:`bug_monitor`,label:`Bug Monitor`},{value:`system`,label:`System`}],St=[{value:`active`,label:`Active`},{value:`paused`,label:`Paused`},{value:`draft`,label:`Draft`}],Ct={sources:{user_created:!0,agent_created:!0,bug_monitor:!1,system:!1},statuses:{active:!0,paused:!0,draft:!0}};function wt(e){let t=String(e||``).trim().toLowerCase();return yt.some(e=>e.value===t)?t:bt}function Tt(e){return String(e?.automation_id||e?.automationId||e?.id||e?.routine_id||``).trim()}function Et(e){return String(e?.name||e?.title||e?.label||Tt(e)||`Automation`).trim()}function Dt(e){if(!e)return 0;if(typeof e==`number`)return Number.isFinite(e)?e:0;if(typeof e==`string`){let t=e.trim();if(!t)return 0;let n=Number(t);if(Number.isFinite(n)&&t===String(n))return n;let r=Date.parse(t);return Number.isFinite(r)?r:0}return 0}function Ot(e){let t=[e?.created_at_ms,e?.createdAtMs,e?.created_at,e?.createdAt,e?.updated_at_ms,e?.updatedAtMs,e?.updated_at,e?.updatedAt];for(let e of t){let t=Dt(e);if(t>0)return t}return 0}function kt(e){return String(e||``).trim().toLowerCase().replace(/[\s-]+/g,`_`)}function At(e,t,n){let r=e&&typeof e==`object`?e:{},i={};for(let e of t){let t=e.value,a=r[t];i[t]=typeof a==`boolean`?a:!!n[t]}return i}function jt(e={}){let t=e&&typeof e==`object`?e:{},n=t.sources||t.source_filters||t.sourceFilters||{},r=t.statuses||t.status_filters||t.statusFilters||{};return{sources:At(n,xt,Ct.sources),statuses:At(r,St,Ct.statuses)}}function Mt(e,t){let n=jt(e),r=jt(t);for(let e of xt)if(n.sources[e.value]!==r.sources[e.value])return!1;for(let e of St)if(n.statuses[e.value]!==r.statuses[e.value])return!1;return!0}function Nt(e){return kt(e?.metadata?.source||e?.metadata?.origin||e?.metadata?.plan_source||e?.metadata?.planSource||e?.source||e?.origin)}function Pt(e){let t=Nt(e),n=kt(e?.creator_id||e?.creatorId||e?.created_by||e?.createdBy),r=Et(e).toLowerCase();return t===`bug_monitor`||t===`bug_monitor_approval`||n===`bug_monitor`||r.startsWith(`bug monitor triage:`)?{key:`bug_monitor`,label:`Bug Monitor`}:t.includes(`workflow_planner`)||t.includes(`planner`)||t.includes(`agent`)||n.includes(`workflow_planner`)||n.includes(`agent`)?{key:`agent_created`,label:`Agent`}:t===`system`||t.startsWith(`system_`)||n===`system`||n===`tandem`?{key:`system`,label:`System`}:{key:`user_created`,label:`User`}}function Ft(e){let t=kt(e?.status||`draft`);return t===`paused`||t===`disabled`?`paused`:t===`active`||t===`enabled`||t===`running`?`active`:`draft`}function It(e,t=Ct){let n=jt(t);return Array.isArray(e)?e.filter(e=>{let t=Pt(e).key,r=Ft(e);return n.sources[t]!==!1&&n.statuses[r]!==!1}):[]}function Lt(e){let t=Ot(e);if(!t)return``;let n=new Date(t);return`${new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`,year:`numeric`}).format(n)} · ${new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`2-digit`}).format(n)}`}function Rt(e){let t=new Set,n=[];for(let r of Array.isArray(e)?e:[]){let e=String(r||``).trim();!e||t.has(e)||(t.add(e),n.push(e))}return n}function zt(e,t){let n=String(t||``).trim();if(!n)return Rt(e);let r=Rt(e);return r.includes(n)?r.filter(e=>e!==n):[...r,n]}function Bt(e,t,n,r){let i=Tt(e),a=Tt(t),o=!!r?.has?.(i);if(o!==!!r?.has?.(a))return o?-1:1;let s=Et(e),c=Et(t),l=Ot(e),u=Ot(t);if(n===`name_asc`||n===`name_desc`){let e=s.localeCompare(c,void 0,{sensitivity:`base`});return e?n===`name_desc`?-e:e:l===u?i.localeCompare(a):u-l}return l===u?s.localeCompare(c,void 0,{sensitivity:`base`})||i.localeCompare(a):n===`created_asc`?l-u:u-l}function Vt(e,t={}){let n=wt(t.sortMode),r=t.favoriteAutomationIds instanceof Set?t.favoriteAutomationIds:new Set(Rt(t.favoriteAutomationIds));return Array.isArray(e)?[...e].sort((e,t)=>Bt(e,t,n,r)):[]}var Ht=`style[data-fullcalendar]`,Ut=8;function Wt(){return new Promise(e=>{if(typeof window<`u`&&typeof window.requestAnimationFrame==`function`){window.requestAnimationFrame(()=>e());return}setTimeout(e,0)})}async function Gt(){if(typeof document>`u`)return;let e=document.head||document.documentElement;if(!e)return;let t=document.querySelector(Ht);t?t.isConnected||e.appendChild(t):(t=document.createElement(`style`),t.setAttribute(`data-fullcalendar`,``),e.appendChild(t));for(let e=0;e<Ut;e+=1){if(t.sheet)return;await Wt()}if(!t.sheet)throw Error(`FullCalendar stylesheet is not available yet.`)}var Kt=`09:00:00`,qt=1800*1e3,Jt=H();function Yt(e){return String(e).padStart(2,`0`)}function Xt(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),0,0)}function Zt(e){return`${Yt(e.getHours())}:${Yt(e.getMinutes())}:00`}function Qt(e){let[t,n]=String(e||Kt).split(`:`);return{hour:Number.parseInt(t||`9`,10)||9,minute:Number.parseInt(n||`0`,10)||0}}function $t(e){return new Date(Math.floor(e.getTime()/qt)*qt)}function en(e){if(!e)return``;let t=$t(e),n=new Date(t.getTime()+qt);return`${new Intl.DateTimeFormat(`en-US`,{weekday:`short`,month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`,timeZone:Jt}).format(t)} - ${new Intl.DateTimeFormat(`en-US`,{hour:`numeric`,minute:`2-digit`,timeZone:Jt,timeZoneName:`short`}).format(n)}`}function tn(e){if(!e)return``;let t=$t(e),n=new Date(t.getTime()+qt),r=new Intl.DateTimeFormat(`en-US`,{weekday:`short`,month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`,timeZone:Jt}),i=new Intl.DateTimeFormat(`en-US`,{hour:`numeric`,minute:`2-digit`,timeZone:Jt,timeZoneName:`short`});return`${r.format(t)} - ${i.format(n)}`}function nn(e){if(e instanceof Date)return e;let t=new Date(String(e||``));return Number.isNaN(t.getTime())?null:t}function rn(e){let t=String(e||``).trim().toLowerCase();return t===`v2`?`workflow`:t===`legacy`?`routine`:t||`task`}function an(e){let t=String(e||``).trim().toLowerCase();return t===`v2`?{shell:`border-amber-400/40 bg-amber-400/12 text-amber-100`,chip:`border-amber-400/30 bg-amber-400/12 text-amber-100`,dot:`bg-amber-300`}:t===`legacy`?{shell:`border-sky-400/30 bg-sky-400/10 text-sky-100`,chip:`border-sky-400/30 bg-sky-400/10 text-sky-100`,dot:`bg-sky-300`}:{shell:`border-slate-500/40 bg-slate-500/10 text-slate-100`,chip:`border-slate-500/40 bg-slate-500/10 text-slate-100`,dot:`bg-slate-300`}}function on(e){let t=String(e||``).trim().toLowerCase();return t===`in_progress`?`running`:t===`done`?`completed`:t===`error`?`failed`:t||`active`}function sn(e){let t=String(e||``).trim().toLowerCase();return t===`active`||t===`running`||t===`in_progress`||t===`completed`||t===`done`?{shell:`border-emerald-400/35 bg-emerald-400/12 text-emerald-100`,chip:`border-emerald-400/30 bg-emerald-400/12 text-emerald-100`,dot:`bg-emerald-300`}:t===`paused`?{shell:`border-slate-500/40 bg-slate-500/10 text-slate-100`,chip:`border-slate-500/40 bg-slate-500/10 text-slate-100`,dot:`bg-slate-300`}:t===`blocked`||t===`queued`||t===`awaiting_approval`?{shell:`border-amber-400/35 bg-amber-400/12 text-amber-100`,chip:`border-amber-400/30 bg-amber-400/12 text-amber-100`,dot:`bg-amber-300`}:t===`failed`||t===`error`||t===`stalled`?{shell:`border-rose-400/35 bg-rose-400/12 text-rose-100`,chip:`border-rose-400/30 bg-rose-400/12 text-rose-100`,dot:`bg-rose-300`}:{shell:`border-slate-500/40 bg-slate-500/10 text-slate-100`,chip:`border-slate-500/40 bg-slate-500/10 text-slate-100`,dot:`bg-slate-300`}}function cn({events:t,onRangeChange:n,onOpenAutomation:o}){let s=i(null),c=i(null),l=i(``),u=i(null),[d,p]=a(`timeGridWeek`),[m,h]=a(null),[g,_]=a(null),[v,b]=a(``),x=g?.FullCalendar;e(()=>{let e=!1;async function t(){try{if(await Gt(),e)return;let[t,n,r]=await Promise.all([y(()=>import(`./fullcalendar-Bn75j0xM.js`).then(e=>e.n),__vite__mapDeps([0,1])),y(()=>import(`./fullcalendar-Bn75j0xM.js`).then(e=>e.r),__vite__mapDeps([0,1])),y(()=>import(`./fullcalendar-Bn75j0xM.js`).then(e=>e.t),__vite__mapDeps([0,1]))]);if(e)return;_({FullCalendar:t.default,interactionPlugin:n.default,timeGridPlugin:r.default}),b(``)}catch(t){if(e)return;b(t instanceof Error?t.message:String(t))}}return t(),()=>{e=!0}},[]);let S=r(()=>en(m),[m]),C=r(()=>tn(m),[m]),w=r(()=>{let e=new Map;for(let n of t){let t=nn(n?.start);if(!t)continue;let r=$t(t).getTime(),i=e.get(r)||[];i.push({event:n,start:t,blockStartMs:r}),e.set(r,i)}return Array.from(e.entries()).sort((e,t)=>e[0]-t[0]).map(([e,t])=>{let n=t.slice().sort((e,t)=>{let n=e.start?.getTime()||0,r=t.start?.getTime()||0;return n===r?String(e.event?.title||``).localeCompare(String(t.event?.title||``)):n-r}),r=new Date(e),i=new Date(e+qt),a={},o={},s=n.slice(0,3).map(({event:e})=>{let t=String(e?.title||e?.extendedProps?.automation?.name||e?.extendedProps?.automation?.automation_id||`Automation`).trim(),n=String(e?.extendedProps?.family||`legacy`).trim(),r=on(String(e?.extendedProps?.status||`active`).trim()),i=String(e?.extendedProps?.scheduleLabel||``).trim();return a[n]=(a[n]||0)+1,o[r]=(o[r]||0)+1,{title:t,family:n,status:r,scheduleLabel:i}}),c=Object.entries(a).sort((e,t)=>e[1]===t[1]?e[0].localeCompare(t[0]):t[1]-e[1])[0]?.[0]||`legacy`,l=Object.entries(o).sort((e,t)=>e[1]===t[1]?e[0].localeCompare(t[0]):t[1]-e[1])[0]?.[0]||`active`,u=s.map(e=>e.title).filter(Boolean)[0]||String(n[0]?.event?.title||n[0]?.event?.extendedProps?.automation?.name||n[0]?.event?.extendedProps?.automation?.automation_id||`Automation`).trim(),d=Math.max(0,n.length-s.length),f=`${n.length} ${n.length===1?`task`:`tasks`}`,p=[`${en(r)} · ${f}`,...n.slice(0,4).map(({event:e})=>[String(e?.title||e?.extendedProps?.automation?.name||e?.extendedProps?.automation?.automation_id||`Automation`).trim(),String(e?.extendedProps?.family||`legacy`).trim(),String(e?.extendedProps?.status||`active`).trim(),String(e?.extendedProps?.scheduleLabel||``).trim()].filter(Boolean).join(` · `)),n.length>4?`+${n.length-4} more`:``].filter(Boolean).join(`
7
+ `);return{blockStartMs:e,blockEndMs:i.getTime(),start:r,end:i,items:n,count:n.length,title:f,hint:p,previewItems:s,previewText:u,overflowCount:d,dominantFamily:c,dominantStatus:l,familyCounts:a,statusCounts:o}})},[t]),T=r(()=>m&&w.find(({blockStartMs:e})=>e===m.getTime())?.items||[],[m,w]),E=e=>{if(!e){h(null),l.current=``,u.current=null;return}let t=Xt(e);h(t),u.current=t,l.current=Zt(t)},D=()=>{window.requestAnimationFrame(()=>{c.current?.scrollIntoView({behavior:`smooth`,block:`start`})})},O=e=>{E($t(Xt(e))),D()},ee=e=>{let t=$t(Xt(e));E(t);let n=s.current?.getApi();n&&(u.current=t,n.changeView(`timeGridDay`),n.gotoDate(t),window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>{let e=s.current?.getApi();!e||!u.current||(e.gotoDate(u.current),l.current&&e.scrollToTime(l.current))})}))};return f(`div`,{className:`grid gap-3`,children:[f(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[f(`div`,{className:`grid gap-1`,children:[f(`p`,{className:`text-xs font-medium uppercase tracking-wide text-slate-500`,children:`Scheduled automations`}),f(`div`,{className:`tcp-subtle text-xs`,children:[`Automations are grouped into 30-minute blocks so crowded times stay readable. Hover a block for a preview, click it to inspect the workflows inside, and use the block details below to open individual editors. The calendar is shown in your local time (`,Jt,`). Cron and interval automations are shown here.`]})]}),f(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[S?f(`span`,{className:`tcp-badge-info`,children:S}):null,f(`span`,{className:`tcp-badge-info`,children:[w.length,` scheduled block`,w.length===1?``:`s`]})]})]}),f(`div`,{className:`overflow-hidden rounded-2xl border border-slate-800/80 bg-slate-950/35 p-2`,children:x&&g?f(x,{ref:s,plugins:[g.timeGridPlugin,g.interactionPlugin],initialView:`timeGridWeek`,timeZone:`local`,firstDay:0,height:`auto`,expandRows:!0,nowIndicator:!0,editable:!1,eventStartEditable:!1,eventDurationEditable:!1,eventOverlap:!0,slotEventOverlap:!0,allDaySlot:!1,slotMinTime:`00:00:00`,slotMaxTime:`24:00:00`,scrollTimeReset:!1,stickyHeaderDates:!0,navLinks:!0,headerToolbar:{left:`prev,next today`,center:`title`,right:`timeGridWeek,timeGridDay`},buttonText:{timeGridWeek:`week`,timeGridDay:`day`,today:`today`},views:{timeGridWeek:{eventMaxStack:1},timeGridDay:{slotDuration:`00:30:00`,slotLabelInterval:`00:30:00`}},events:w,datesSet:e=>{p(e.view.type),n({startMs:e.start.getTime(),endMs:e.end.getTime()}),!(e.view.type!==`timeGridDay`||!l.current)&&window.requestAnimationFrame(()=>{let e=s.current?.getApi();e&&(u.current&&e.gotoDate(u.current),e.scrollToTime(l.current),l.current=``)})},navLinkDayClick:e=>{let{hour:t,minute:n}=Qt(m?Zt(m):Kt);ee(new Date(e.getFullYear(),e.getMonth(),e.getDate(),t,n,0,0))},dateClick:e=>{O(e.date)},moreLinkClick:e=>{e.jsEvent?.preventDefault?.(),O(e.date)},moreLinkClassNames:()=>[`tcp-calendar-more-link`],moreLinkContent:e=>f(`span`,{children:[`+`,e.num,` more`]}),eventClick:e=>{e.jsEvent?.preventDefault?.();let t=e.event?.start||null;t&&O(t)},eventContent:e=>{let t=Number(e?.event?.extendedProps?.count||0)||0,n=m?.getTime()===Number(e?.event?.extendedProps?.blockStartMs||0),r=e?.event?.extendedProps?.familyCounts||{},i=e?.event?.extendedProps?.statusCounts||{},a=String(e?.event?.extendedProps?.previewText||``).trim(),o=Number(e?.event?.extendedProps?.overflowCount||0)||0,s=Object.entries(r).sort((e,t)=>e[1]===t[1]?e[0].localeCompare(t[0]):t[1]-e[1]).slice(0,3).map(([e,t])=>({family:e,count:t,tone:an(e)})),c=Object.entries(i).sort((e,t)=>e[1]===t[1]?e[0].localeCompare(t[0]):t[1]-e[1])[0]?.[0]||`active`,l=sn(c);return f(`div`,{className:`group relative flex h-full min-h-0 items-center overflow-hidden rounded-[0.65rem] border px-2 py-1 text-xs shadow-sm transition-colors ${n?`border-amber-400/80 bg-amber-400/14 text-amber-100`:`border-slate-700/60 bg-slate-950/86 text-slate-100`}`,children:[f(`div`,{className:`absolute inset-y-0 left-0 w-0.5 ${n?`bg-amber-300`:s[0]?.tone?.dot||l.dot||`bg-slate-500`}`}),f(`div`,{className:`relative flex min-w-0 w-full items-center gap-2 pl-1`,children:[f(`div`,{className:`flex shrink-0 items-center gap-1`,children:s.length?s.map((e,t)=>f(`span`,{className:`inline-flex h-2.5 rounded-full border ${n?`border-amber-300/80 bg-amber-300/35`:e.tone.chip}`,style:{width:t===0?`1.4rem`:t===1?`0.95rem`:`0.7rem`},title:`${rn(e.family)} · ${e.count}`,"aria-hidden":`true`},`${e.family}-${t}`)):f(`span`,{className:`inline-flex h-2.5 w-3 rounded-full border ${n?`border-amber-300/80 bg-amber-300/35`:l.chip}`,title:c,"aria-hidden":`true`})}),f(`span`,{className:`min-w-0 flex-1 truncate text-[11px] font-medium leading-none text-slate-100`,children:a}),o>0?f(`span`,{className:`inline-flex shrink-0 items-center rounded-full border border-slate-600/70 bg-slate-950/80 px-1.5 py-0.5 text-[9px] font-semibold uppercase tracking-[0.18em] text-slate-200`,children:[`+`,o]}):null,f(`span`,{className:`inline-flex shrink-0 items-center rounded-md border px-1.5 py-0.5 text-[11px] font-semibold tabular-nums ${n?`border-amber-300/70 bg-amber-300/18 text-amber-50`:`border-slate-600/70 bg-slate-950/70 text-slate-100`}`,children:t}),f(`span`,{className:`inline-flex shrink-0 h-2 w-2 rounded-full border ${n?`border-amber-200/80 bg-amber-300`:l.dot+` border-slate-900/0`}`,title:c,"aria-hidden":`true`})]})]})},eventDidMount:e=>{let t=String(e?.event?.extendedProps?.hint||``).trim();t&&(e.el.title=t,e.el.setAttribute(`aria-label`,t))},slotLaneClassNames:e=>{if(d!==`timeGridDay`||!m||!e.date)return[];let t=e.date.getTime(),n=m.getTime(),r=n+qt;return t>=n&&t<r?[`tcp-calendar-slot-focus`]:[]},eventClassNames:()=>[`tcp-calendar-event`]}):f(`div`,{className:`grid min-h-[24rem] place-items-center px-4 text-center text-sm text-slate-400`,children:v?`Calendar failed to load: ${v}`:`Loading calendar...`})}),f(`div`,{ref:c,className:`rounded-2xl border border-slate-800/80 bg-slate-950/45 p-3 scroll-mt-24`,children:[f(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[f(`div`,{className:`grid gap-1`,children:[f(`p`,{className:`text-xs font-medium uppercase tracking-wide text-slate-500`,children:`30-minute block drill-down`}),f(`div`,{className:`tcp-subtle text-xs`,children:`Click a block or a day slot to inspect the automations in that local window, then click any workflow in the list to open its editor.`})]}),f(`div`,{className:`flex flex-wrap items-center gap-2`,children:[S?f(`span`,{className:`tcp-badge-info`,children:S}):null,m?f(`button`,{type:`button`,className:`tcp-btn h-7 px-2.5 text-[11px]`,onClick:()=>E(null),children:`Clear`}):null]})]}),m?f(`div`,{className:`mt-3 grid gap-2`,children:[f(`div`,{className:`text-sm font-medium text-slate-200`,children:[C||`Selected block`,T.length?` · ${T.length} item${T.length===1?``:`s`}`:``]}),T.length?f(`div`,{className:`grid gap-2 max-h-80 overflow-auto pr-1`,children:T.map(({event:e,start:t})=>{let n=e?.extendedProps?.automation,r=String(e?.title||n?.name||n?.automation_id||`Automation`).trim(),i=String(e?.extendedProps?.scheduleLabel||``).trim(),a=String(e?.extendedProps?.status||`active`).trim()||`active`,s=String(e?.extendedProps?.family||`legacy`).trim(),c=t?new Intl.DateTimeFormat(`en-US`,{hour:`numeric`,minute:`2-digit`,timeZone:Jt,timeZoneName:`short`}).format(t):`time unavailable`;return f(`button`,{type:`button`,className:`grid gap-1 rounded-xl border border-slate-700/60 bg-slate-900/60 px-3 py-2 text-left transition-colors hover:border-amber-400/60 hover:bg-amber-400/10`,onClick:()=>n&&o(n),children:[f(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[f(`div`,{className:`min-w-0`,children:[f(`div`,{className:`truncate text-sm font-medium text-slate-100`,children:r}),f(`div`,{className:`text-xs text-slate-400`,children:[c,` · `,s===`v2`?`workflow`:`routine`]})]}),f(`div`,{className:`flex flex-wrap items-center gap-1`,children:[f(`span`,{className:`tcp-badge-info`,children:s}),f(`span`,{className:`tcp-badge-info`,children:a})]})]}),i?f(`div`,{className:`text-xs text-slate-500`,children:i}):null]},String(e?.id||`${r}-${c}`))})}):f(`div`,{className:`rounded-xl border border-dashed border-slate-700/60 bg-slate-900/30 p-3 text-xs text-slate-500`,children:`No automations are scheduled in this block.`})]}):f(`div`,{className:`mt-3 rounded-xl border border-dashed border-slate-700/60 bg-slate-900/30 p-3 text-xs text-slate-500`,children:`Select any slot or click a block to drill into the exact automations.`})]})]})}function ln(e){return String(e||``).trim()}function un(e){return Array.isArray(e)?e:[]}function dn(e){return e.resolved?f(`span`,{className:`tcp-badge-success`,children:`mapped`}):e.required?f(`span`,{className:`tcp-badge-warning`,children:`required`}):f(`span`,{className:`tcp-badge-info`,children:`optional`})}function fn(e){return e.resolved?`mapped`:e.required?`bind now`:e.degraded_mode_allowed?`safe to defer`:`optional`}function pn(e){return e.resolved?`success`:e.required?`warning`:`info`}function mn(e){let t=pn(e);return f(`span`,{className:t===`success`?`tcp-badge-success`:t===`warning`?`tcp-badge-warning`:`tcp-badge-info`,children:fn(e)})}function hn(e,t){return ln(e?.capability||`intent-${t+1}`)}function gn(e){return e==null?`n/a`:typeof e==`boolean`?e?`yes`:`no`:String(e)}function _n(e){let t=un(e?.connector_intents),n=un(e?.connector_binding_resolution?.entries),r=new Map(t.map(e=>[ln(e?.capability),e])),i=new Set,a=n.length?n.map(e=>{let t=ln(e?.capability),n=r.get(t);return i.add(t),{capability:t,intent:n,entry:e}}):t.map((e,t)=>{let n=hn(e,t);return{capability:n,intent:e,entry:{capability:n,why:e?.why,required:e?.required,degraded_mode_allowed:e?.degraded_mode_allowed,resolved:!1,status:e?.required?`unresolved_required`:`unresolved_optional`,binding_type:null,binding_id:null,allowlist_pattern:null}}});return t.forEach(e=>{let t=ln(e?.capability);!t||i.has(t)||a.push({capability:t,intent:e,entry:{capability:t,why:e?.why,required:e?.required,degraded_mode_allowed:e?.degraded_mode_allowed,resolved:!1,status:e?.required?`unresolved_required`:`unresolved_optional`,binding_type:null,binding_id:null,allowlist_pattern:null}})}),a.sort((e,t)=>Number(t.entry.required)-Number(e.entry.required)||Number(e.entry.resolved)-Number(t.entry.resolved)||e.capability.localeCompare(t.capability))}function vn(e){return{required:e.filter(e=>e.entry.required),optional:e.filter(e=>!e.entry.required)}}function yn({planPackage:e}){if(!e)return null;let t=_n(e),{required:n,optional:r}=vn(t),i=t.filter(e=>e.entry.resolved).length,a=t.filter(e=>e.entry.required&&!e.entry.resolved).length,o=t.filter(e=>!e.entry.required&&!e.entry.resolved).length;return f(`div`,{className:`grid gap-2`,children:[f(`div`,{className:`font-medium text-slate-200`,children:`Connector suggestions`}),f(`div`,{className:`rounded-lg border border-slate-800/80 bg-slate-950/30 p-3`,children:f(`div`,{className:`grid gap-2 sm:grid-cols-4`,children:[f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`required intents`}),f(`div`,{className:`mt-1 text-slate-100`,children:n.length})]}),f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`mapped`}),f(`div`,{className:`mt-1 text-slate-100`,children:i})]}),f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`unresolved required`}),f(`div`,{className:`mt-1 text-slate-100`,children:a})]}),f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`unresolved optional`}),f(`div`,{className:`mt-1 text-slate-100`,children:o})]})]})}),f(`div`,{className:`grid gap-3`,children:[f(`div`,{className:`grid gap-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`Required`}),n.length?n.map(({capability:e,intent:t,entry:n})=>f(`div`,{className:`rounded-lg border border-slate-800/80 bg-slate-950/30 p-3`,children:[f(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[f(`div`,{className:`font-medium text-slate-100`,children:e}),f(`div`,{className:`flex flex-wrap items-center gap-2`,children:[dn(n),mn(n)]})]}),f(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`why`}),f(`div`,{className:`mt-1 break-words text-slate-100`,children:ln(t?.why||n?.why||`n/a`)})]}),f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`operator action`}),f(`div`,{className:`mt-1 text-slate-100`,children:n.resolved?`Connector is already mapped.`:`Add a binding before activation.`})]})]}),f(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-3`,children:[f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`binding type`}),f(`div`,{className:`mt-1 text-slate-100`,children:gn(n?.binding_type)})]}),f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`binding id`}),f(`div`,{className:`mt-1 text-slate-100`,children:gn(n?.binding_id)})]}),f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`allowlist pattern`}),f(`div`,{className:`mt-1 break-words text-slate-100`,children:gn(n?.allowlist_pattern)})]})]})]},`required-${e}`)):f(`div`,{className:`tcp-subtle text-xs`,children:`No required connector intents are declared.`})]}),f(`div`,{className:`grid gap-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`Optional`}),r.length?r.map(({capability:e,intent:t,entry:n})=>f(`div`,{className:`rounded-lg border border-slate-800/80 bg-slate-950/30 p-3`,children:[f(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[f(`div`,{className:`font-medium text-slate-100`,children:e}),f(`div`,{className:`flex flex-wrap items-center gap-2`,children:[dn(n),mn(n)]})]}),f(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`why`}),f(`div`,{className:`mt-1 break-words text-slate-100`,children:ln(t?.why||n?.why||`n/a`)})]}),f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`operator action`}),f(`div`,{className:`mt-1 text-slate-100`,children:n.resolved?`Connector is already mapped.`:n.degraded_mode_allowed?`Optional now; can stay unbound in degraded mode.`:`Optional now; bind only if the workflow needs it.`})]})]}),f(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-3`,children:[f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`degraded mode`}),f(`div`,{className:`mt-1 text-slate-100`,children:gn(n?.degraded_mode_allowed)})]}),f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`binding type`}),f(`div`,{className:`mt-1 text-slate-100`,children:gn(n?.binding_type)})]}),f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`binding id`}),f(`div`,{className:`mt-1 text-slate-100`,children:gn(n?.binding_id)})]})]})]},`optional-${e}`)):f(`div`,{className:`tcp-subtle text-xs`,children:`No optional connector intents are declared.`})]})]}),f(`div`,{className:`tcp-subtle text-[11px]`,children:`Connector suggestions are read-only and derived from the current plan package.`})]})}var bn=[`plan metadata`,`scope/runtime`,`routines`,`credentials`,`context objects`,`other`];function xn(e){return String(e||``).trim()}function Sn(e){return Array.isArray(e)?e:[]}function Cn(e){return e==null?`n/a`:typeof e==`string`?e:v(e)}function wn(e){return e.blocking?`warning`:e.preserved?`success`:`info`}function Tn(e){let t=wn(e);return f(`span`,{className:t===`success`?`tcp-badge-success`:t===`warning`?`tcp-badge-warning`:`tcp-badge-info`,children:e.preserved?`preserved`:`changed`})}function En(e){return f(`span`,{className:e.blocking?`tcp-badge-warning`:`tcp-badge-success`,children:e.blocking?`blocking`:`warning`})}function Dn(e){let t=xn(e).toLowerCase();return t===`plan_id`||t===`plan_revision`||t===`lifecycle_state`||t.startsWith(`owner`)||t.startsWith(`mission`)||t.startsWith(`metadata`)?`plan metadata`:t.startsWith(`output_roots`)||t.startsWith(`inter_routine_policy`)||t.startsWith(`approval_policy`)||t.startsWith(`trigger_policy`)||t.startsWith(`validation_state`)?`scope/runtime`:t.startsWith(`routine_graph`)||t.startsWith(`routine_scopes`)||t.startsWith(`dependency_resolution`)||t.startsWith(`model_routing_resolution`)?`routines`:t.startsWith(`connector_bindings`)||t.startsWith(`connector_binding_resolution`)||t.startsWith(`credential_envelopes`)||t.startsWith(`credential`)?`credentials`:t.startsWith(`context_object`)||t.startsWith(`context_objects`)?`context objects`:`other`}function On(e){let t=new Map;return e.forEach(e=>{let n=Dn(xn(e.path));t.has(n)||t.set(n,[]),t.get(n)?.push(e)}),bn.map(e=>({key:e,label:e,entries:t.get(e)||[]})).filter(e=>e.entries.length>0)}function kn(e){return e==null?`n/a`:typeof e==`boolean`?e?`yes`:`no`:String(e)}function An({planPackageReplay:e}){let t=Sn(e?.diff_summary),n=Sn(e?.issues),r=n.filter(e=>e?.blocking),i=On(t),a=n.slice().sort((e,t)=>Number(t?.blocking)-Number(e?.blocking));return e?f(`div`,{className:`grid gap-2`,children:[f(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[f(`div`,{className:`font-medium text-slate-200`,children:`Revision compare`}),f(`span`,{className:e.compatible?`tcp-badge-success`:`tcp-badge-warning`,children:e.compatible?`compatible`:`drift detected`})]}),f(`div`,{className:`rounded-lg border border-slate-800/80 bg-slate-950/30 p-3`,children:[f(`div`,{className:`grid gap-2 sm:grid-cols-4`,children:[f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`previous plan`}),f(`div`,{className:`mt-1 break-words text-slate-100`,children:kn(e?.previous_plan_id)||`n/a`}),f(`div`,{className:`tcp-subtle text-[11px]`,children:[`rev `,kn(e?.previous_plan_revision)]})]}),f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`next plan`}),f(`div`,{className:`mt-1 break-words text-slate-100`,children:kn(e?.next_plan_id)||`n/a`}),f(`div`,{className:`tcp-subtle text-[11px]`,children:[`rev `,kn(e?.next_plan_revision)]})]}),f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`changed paths`}),f(`div`,{className:`mt-1 text-slate-100`,children:t.length})]}),f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`blocking issues`}),f(`div`,{className:`mt-1 text-slate-100`,children:r.length})]})]}),f(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-3`,children:[f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`scope metadata`}),f(`div`,{className:`mt-1 text-slate-100`,children:kn(e?.scope_metadata_preserved)})]}),f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`handoff rules`}),f(`div`,{className:`mt-1 text-slate-100`,children:kn(e?.handoff_rules_preserved)})]}),f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`credential isolation`}),f(`div`,{className:`mt-1 text-slate-100`,children:kn(e?.credential_isolation_preserved)})]})]})]}),n.length?f(`div`,{className:`rounded-lg border border-slate-800/80 bg-slate-950/30 p-3`,children:[f(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[f(`div`,{className:`font-medium text-slate-100`,children:`Replay issues`}),f(`span`,{className:`tcp-badge-info`,children:[n.length,` issue`,n.length===1?``:`s`]})]}),f(`div`,{className:`mt-2 grid gap-2`,children:a.map((e,t)=>f(`div`,{className:e?.blocking?`rounded-md border border-amber-500/40 bg-amber-500/10 p-2 text-[11px] text-amber-50`:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2 text-[11px] text-slate-200`,children:[f(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f(`span`,{className:`font-medium`,children:xn(e?.code)||`issue`}),f(`span`,{className:`tcp-subtle`,children:[`path: `,xn(e?.path)||`n/a`]}),En(e)]}),f(`div`,{className:`mt-1 text-slate-100`,children:xn(e?.message)||`n/a`})]},`${xn(e?.code)||`issue`}-${t}`))})]}):null,f(`div`,{className:`grid gap-2`,children:i.length?i.map(e=>{let t=e.entries.filter(e=>e.blocking).length;return f(`div`,{className:`rounded-lg border border-slate-800/80 bg-slate-950/30 p-3`,children:[f(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[f(`div`,{className:`font-medium text-slate-100`,children:e.label}),f(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f(`span`,{className:`tcp-badge-info`,children:[e.entries.length,` change`,e.entries.length===1?``:`s`]}),t?f(`span`,{className:`tcp-badge-warning`,children:[t,` blocking`]}):null]})]}),f(`div`,{className:`mt-2 grid gap-2`,children:e.entries.map((e,t)=>f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[f(`div`,{className:`font-medium text-slate-100`,children:xn(e.path)||`unknown path`}),Tn(e)]}),f(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[f(`div`,{children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`previous`}),f(`pre`,{className:`tcp-code mt-1 max-h-24 overflow-auto text-[11px]`,children:Cn(e.previous_value)})]}),f(`div`,{children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`next`}),f(`pre`,{className:`tcp-code mt-1 max-h-24 overflow-auto text-[11px]`,children:Cn(e.next_value)})]})]})]},`${xn(e.path)||`diff`}-${t}`))})]},e.key)}):f(`div`,{className:`tcp-subtle text-xs`,children:`No replay diff summary is available.`})})]}):null}function J(e){return String(e||``).trim()}function Y(e){return Array.isArray(e)?e:[]}function jn(e){let t=Y(e).map(e=>J(e)).filter(Boolean);return t.length?t.join(`, `):`none`}function X(e,t){return f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:e}),f(`div`,{className:`mt-1 break-words text-sm text-slate-100`,children:String(t||`n/a`)})]})}function Mn(e,t){let n=new Blob([JSON.stringify(t,null,2)],{type:`application/json;charset=utf-8`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e,i.rel=`noopener noreferrer`,i.click(),window.setTimeout(()=>URL.revokeObjectURL(r),1e3)}function Nn(e){let t=J(e).toLowerCase();return t===`routine_only`?`Routine only`:t===`plan_owner`?`Plan owner`:t===`named_roles`?`Named roles`:`Unknown`}function Pn(e){let t=J(e).toLowerCase();return t===`routine_only`?`Routine only`:t===`declared_consumers`?`Declared consumers`:t===`plan_owner`?`Plan owner`:t===`workspace`?`Workspace`:`Unknown`}function Fn(e){let t=J(e);return t?t.replace(/[_-]+/g,` `).replace(/\s+/g,` `).trim().replace(/\b\w/g,e=>e.toUpperCase()):`n/a`}function In(e){let t=J(e).toLowerCase();return t===`project_allowlist`?`Project allowlist`:t===`same_project`?`Same project`:Fn(e)}function Ln(e,t){let n=J(e).toLowerCase();return n===`revoked`?`revoked`:n===`superseded`?`superseded`:n===`published`&&t?`stale`:n||`unknown`}function Rn(e,t){return J(e).toLowerCase()===`published`&&!t?`success`:`warning`}function zn(e){if(!e?.pack)return``;if(e.pack.isStale)return`Freshness window has elapsed; rebinding is recommended before reuse.`;if(e.pack.state===`superseded`){let t=J(e.pack.raw?.superseded_by_pack_id);return t?`This shared workflow context has been superseded by ${t}. Rebind to the replacement before creating new runs.`:`This shared workflow context has been superseded. Rebind to the replacement before creating new runs.`}return e.pack.state===`published`?``:`This shared workflow context is not published. New runs will be blocked until a published context is selected.`}function Bn(e){let t=J(e).toLowerCase();return t?[`ok`,`ready`,`complete`,`completed`,`defined`,`satisfied`,`met`,`covered`,`valid`,`pass`,`passing`].includes(t)?`success`:[`blocked`,`missing`,`incomplete`,`unmet`,`invalid`,`unsatisfied`,`failed`,`error`].includes(t)?`warning`:`info`:`info`}function Vn(e){let t=J(e)||`unknown`,n=Bn(e);return f(`span`,{className:n===`success`?`tcp-badge-success`:n===`warning`?`tcp-badge-warning`:`tcp-badge-info`,children:t})}function Hn(e){let t=Number(e||0);return!Number.isFinite(t)||t<=0?`n/a`:new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(t))}function Un(e){return J(e).toLowerCase().split(/[^a-z0-9]+/g).map(e=>e.trim()).filter(e=>e.length>=4)}function Wn(e){return Array.from(new Set(e.split(/[\n,]/g).map(e=>J(e)).filter(Boolean)))}function Gn(e,t,n){let r=[];t&&e.sourcePlanId===t&&r.push(`same source plan`);let i=new Set([...Un(e.title),...Un(e.raw?.summary)]),a=n.filter(e=>i.has(e));return a.length&&r.push(`title overlap: ${a.slice(0,2).join(`, `)}`),!e.isStale&&e.updatedAtMs&&r.push(`recent`),r.length?r.join(` · `):`recent workspace context`}function Z(e){return e?.status||e?.coverage_status||e?.state||e?.readiness||e?.result||e?.evaluation||null}function Kn(e){if(e==null)return f(`span`,{className:`tcp-badge-info`,children:`n/a`});let t=e===!0||String(e).toLowerCase()===`true`;return f(`span`,{className:t?`tcp-badge-success`:`tcp-badge-warning`,children:t?`true`:`false`})}function qn(e){let t=Fn(e);return t.toLowerCase()===`n/a`?`n/a`:t}function Jn(e,t){return!Number.isFinite(e)||!Number.isFinite(t)||t<=0?`n/a`:`${Math.round(e/t*100)}%`}function Yn(e){return[{key:`public_posts`,label:`public posts`,value:e?.public_posts},{key:`public_replies`,label:`public replies`,value:e?.public_replies},{key:`outbound_email`,label:`outbound email`,value:e?.outbound_email},{key:`internal_reports`,label:`internal reports`,value:e?.internal_reports},{key:`connector_mutations`,label:`connector mutations`,value:e?.connector_mutations},{key:`destructive_actions`,label:`destructive actions`,value:e?.destructive_actions}]}function Q(e){return e==null?`n/a`:typeof e==`string`?e:v(e)}function Xn({workspaceRoot:e,projectKey:t,sharedContextBindingRows:n,supersededContextBindingRows:r,contextPacks:i,selectedContextPack:a,suggestedContextPacks:o,sharedContextAllowlistInput:s,contextPackStatus:c,onAllowlistChange:l,onSelectContextPack:u,onPublishCurrentContextPack:d,onContextPackStatusChange:p,onReplaceSharedContextPack:m}){async function h(e){try{await navigator.clipboard.writeText(e),p(`Copied ${e}.`)}catch(e){p(e instanceof Error?e.message:`Copy failed.`)}}return f(`div`,{className:`grid gap-2`,children:[n.length?f(`div`,{className:`grid gap-2`,children:[f(`div`,{className:`font-medium text-slate-200`,children:`Shared context bindings`}),r.length?f(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 p-3 text-xs text-amber-100`,children:[f(`div`,{className:`font-medium text-amber-50`,children:`Replacement available`}),f(`div`,{className:`mt-1`,children:`One or more bindings point at superseded packs. Rebind them to the suggested replacement pack before saving this workflow.`})]}):null,f(`div`,{className:`grid gap-2`,children:n.map(e=>f(`div`,{className:`rounded-lg border border-slate-800/80 bg-slate-950/30 p-3`,children:[f(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[f(`div`,{className:`font-medium text-slate-100`,children:e.alias||e.pack?.title||e.packId}),f(`div`,{className:`flex flex-wrap items-center gap-1`,children:[f(`span`,{className:e.required?`tcp-badge-warning`:`tcp-badge-info`,children:e.required?`required`:`optional`}),e.pack?f(`span`,{className:Rn(e.pack.state,e.pack.isStale)===`success`?`tcp-badge-success`:`tcp-badge-warning`,children:Ln(e.pack.state,e.pack.isStale)}):f(`span`,{className:`tcp-badge-info`,children:`unresolved`})]})]}),f(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[X(`context id`,e.packId),X(`source plan`,e.pack?.sourcePlanId||`n/a`),X(`workspace`,e.pack?.raw?.workspace_root||`n/a`),X(`project`,e.pack?.projectKey||`n/a`)]}),zn(e)?f(`div`,{className:`mt-2 rounded-md border border-amber-500/40 bg-amber-500/10 p-2 text-[11px] text-amber-100`,children:zn(e)}):null,e.pack?.state===`superseded`&&J(e.pack?.raw?.superseded_by_pack_id)?f(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 rounded-md border border-amber-500/30 bg-amber-500/5 p-2`,children:[f(`div`,{className:`text-[11px] text-amber-100`,children:[`Suggested replacement:`,` `,f(`span`,{className:`font-medium`,children:J(e.pack.raw.superseded_by_pack_id)})]}),m?f(`button`,{type:`button`,className:`tcp-btn h-7 px-2 text-[11px]`,onClick:()=>m(e.packId,J(e.pack.raw.superseded_by_pack_id)),children:[f(`i`,{"data-lucide":`refresh-cw`}),`Swap to replacement`]}):null]}):null]},e.packId))})]}):null,f(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[f(`div`,{className:`font-medium text-slate-200`,children:`Shared workflow context`}),f(`button`,{type:`button`,className:`tcp-btn h-7 px-2 text-[11px]`,onClick:d,disabled:!e,children:[f(`i`,{"data-lucide":`package-plus`}),`Publish shared workflow context`]})]}),f(`div`,{className:`tcp-subtle text-[11px]`,children:[`workspace: `,e||`n/a`,t?` · project: ${t}`:``]}),f(`div`,{className:`rounded-lg border border-slate-800/80 bg-slate-950/30 p-3`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`cross-project allowlist`}),f(`input`,{type:`text`,className:`tcp-input mt-2`,value:s,onChange:e=>l(e.currentTarget.value),placeholder:`project-b, project-c`}),f(`div`,{className:`tcp-subtle mt-2 text-[11px]`,children:`Optional comma-separated project keys for future cross-project reuse. Leave blank for same-project only.`})]}),c?f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2 text-[11px] text-slate-200`,children:c}):null,f(`div`,{className:`grid gap-2`,children:[i.length?f(`div`,{className:`grid gap-3 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]`,children:[f(`div`,{className:`grid gap-2`,children:i.map(e=>f(`button`,{type:`button`,className:[`rounded-lg border p-3 text-left transition`,a?.packId===e.packId?`border-blue-500/80 bg-blue-500/10`:`border-slate-800/80 bg-slate-950/30 hover:border-slate-700`].join(` `),onClick:()=>u(e.packId),children:[f(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[f(`div`,{className:`font-medium text-slate-100`,children:e.title}),f(`div`,{className:`flex flex-wrap items-center gap-1`,children:[e.visibilityScope===`project_allowlist`?f(`span`,{className:`tcp-badge-info`,children:`allowlist`}):null,e.isStale?f(`span`,{className:`tcp-badge-warning`,children:`stale`}):null,f(`span`,{className:`tcp-badge-info`,children:e.state})]})]}),f(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[X(`context id`,e.packId),X(`source plan`,e.sourcePlanId||`n/a`),X(`bindings`,e.bindings.length),X(`freshness`,e.freshnessWindowHours||`n/a`)]})]},e.packId))}),f(`div`,{className:`rounded-lg border border-slate-800/80 bg-slate-950/30 p-3`,children:a?f(`div`,{className:`grid gap-3`,children:[f(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[f(`div`,{children:[f(`div`,{className:`font-medium text-slate-100`,children:a.title}),f(`div`,{className:`tcp-subtle text-[11px]`,children:[`Published `,Hn(a.raw?.published_at_ms)]})]}),f(`div`,{className:`flex flex-wrap items-center gap-1`,children:[a.isStale?f(`span`,{className:`tcp-badge-warning`,children:`stale`}):null,f(`span`,{className:`tcp-badge-info`,children:a.state}),f(`button`,{type:`button`,className:`tcp-btn h-7 px-2 text-[11px]`,onClick:()=>void h(a.packId),children:[f(`i`,{"data-lucide":`copy`}),`Copy context id`]})]})]}),f(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[X(`context id`,a.packId),X(`workspace`,a.raw?.workspace_root||`n/a`),X(`project`,a.projectKey||`n/a`),X(`visibility`,In(a.raw?.visibility_scope)),X(`source plan`,a.sourcePlanId||`n/a`),X(`source automation`,a.raw?.source_automation_id||`n/a`),X(`source run`,a.raw?.source_run_id||`n/a`),X(`source context run`,a.raw?.source_context_run_id||`n/a`)]}),f(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[X(`freshness window`,a.freshnessWindowHours||`n/a`),X(`updated`,Hn(a.updatedAtMs)),X(`superseded by`,a.raw?.superseded_by_pack_id||`n/a`)]}),f(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[X(`allowed projects`,a.allowedProjectKeys.length?a.allowedProjectKeys.join(`, `):`n/a`),X(`visibility scope`,In(a.raw?.visibility_scope))]}),a.raw?.summary?f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`summary`}),f(`div`,{className:`mt-1 break-words text-sm text-slate-100`,children:a.raw.summary})]}):null,f(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[X(`approved materialization`,a.raw?.manifest?.approved_plan_materialization?`present`:`n/a`),X(`plan package`,a.raw?.manifest?.plan_package?`present`:`n/a`),X(`runtime context`,a.raw?.manifest?.runtime_context?`present`:`n/a`)]}),f(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[X(`context refs`,Y(a.raw?.manifest?.context_object_refs).length),X(`artifact refs`,Y(a.raw?.manifest?.artifact_refs).length),X(`memory refs`,Y(a.raw?.manifest?.governed_memory_refs).length)]}),f(`div`,{className:`grid gap-2`,children:[f(`div`,{className:`font-medium text-slate-200`,children:`Bind history`}),a.bindings.length?f(`div`,{className:`grid gap-2`,children:a.bindings.map(e=>f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[f(`div`,{className:`font-medium text-slate-100`,children:e.alias||e.binding_id}),f(`div`,{className:`flex flex-wrap items-center gap-1`,children:f(`span`,{className:e.required?`tcp-badge-warning`:`tcp-badge-info`,children:e.required?`required`:`optional`})})]}),f(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[X(`consumer plan`,e.consumer_plan_id||`n/a`),X(`consumer project`,e.consumer_project_key||`n/a`),X(`consumer workspace`,e.consumer_workspace_root||`n/a`),X(`created`,Hn(e.created_at_ms))]}),e.actor_metadata?f(`div`,{className:`mt-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`actor metadata`}),f(G,{value:e.actor_metadata,className:`mt-1`,preClassName:`tcp-code mt-1 max-h-28 overflow-auto text-[11px]`})]}):null]},e.binding_id))}):f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2 text-[11px] text-slate-400`,children:`No bindings recorded on this shared workflow context yet.`})]})]}):f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-3 text-[11px] text-slate-400`,children:`Select a shared workflow context to inspect its provenance and bind history.`})})]}):f(`div`,{className:`rounded-lg border border-slate-800/80 bg-slate-950/30 p-3 text-[11px] text-slate-400`,children:`No shared workflow contexts have been published for this workspace yet.`}),o.length?f(`div`,{className:`rounded-lg border border-emerald-500/20 bg-emerald-500/5 p-3`,children:[f(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[f(`div`,{className:`font-medium text-emerald-100`,children:`Suggested recent shared workflow contexts`}),f(`span`,{className:`tcp-badge-info`,children:`copy only, no auto-bind`})]}),f(`div`,{className:`mt-2 grid gap-2`,children:o.map(e=>f(`div`,{className:`rounded-md border border-emerald-500/20 bg-slate-950/30 p-2`,children:[f(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[f(`div`,{children:[f(`div`,{className:`font-medium text-slate-100`,children:e.title}),f(`div`,{className:`tcp-subtle text-[11px]`,children:e.reason})]}),f(`div`,{className:`flex flex-wrap items-center gap-1`,children:[f(`span`,{className:`tcp-badge-info`,children:e.state}),f(`button`,{type:`button`,className:`tcp-btn h-7 px-2 text-[11px]`,onClick:()=>void h(e.packId),children:[f(`i`,{"data-lucide":`copy`}),`Copy context id`]})]})]}),f(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[X(`context id`,e.packId),X(`source plan`,e.sourcePlanId||`n/a`),X(`updated`,Hn(e.updatedAtMs)),X(`freshness`,e.freshnessWindowHours||`n/a`)]})]},e.packId))})]}):null]})]})}function Zn({planPackageReplay:e,replayIssues:t,replayRecommendation:n,showReplayIssues:r,onToggleShowReplayIssues:i}){return f(`div`,{className:`grid gap-1 rounded-lg border border-slate-800/70 bg-slate-950/20 p-2 text-[11px]`,children:[f(`div`,{className:`tcp-subtle uppercase tracking-wide`,children:`Replay check`}),f(`div`,{className:`flex flex-wrap items-center gap-2 text-slate-100`,children:[f(`span`,{className:e.compatible?`text-emerald-300`:`text-amber-300`,children:e.compatible?`Compatible`:`Drift detected`}),f(`span`,{children:[`scope: `,String(e.scope_metadata_preserved??`n/a`)]}),f(`span`,{children:[`handoff: `,String(e.handoff_rules_preserved??`n/a`)]}),f(`span`,{children:[`credentials: `,String(e.credential_isolation_preserved??`n/a`)]}),f(`span`,{children:[`issues: `,t.length]})]}),n?f(`div`,{className:`mt-1 flex flex-wrap items-center gap-2 text-slate-200`,children:[f(`span`,{className:n.tone===`success`?`tcp-badge-success`:n.tone===`warning`?`tcp-badge-warning`:`tcp-badge-info`,children:[`recommend: `,n.label]}),f(`span`,{className:`tcp-subtle`,children:n.reason})]}):null,J(e?.previous_plan_id)||J(e?.next_plan_id)?f(`div`,{className:`tcp-subtle text-[11px]`,children:[J(e?.previous_plan_id)||`unknown`,` · rev`,` `,String(e?.previous_plan_revision??`n/a`),` `,`->`,` `,J(e?.next_plan_id)||`unknown`,` · rev`,` `,String(e?.next_plan_revision??`n/a`)]}):null,Y(e?.diff_summary).length?f(`div`,{className:`mt-2 grid gap-2`,children:[f(`div`,{className:`tcp-subtle uppercase tracking-wide`,children:`Plan diff summary`}),Y(e.diff_summary).map((e,t)=>f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[f(`div`,{className:`font-medium text-slate-100`,children:J(e?.path)||`unknown path`}),f(`span`,{className:e?.blocking?`tcp-badge-warning`:`tcp-badge-success`,children:e?.preserved?`preserved`:`changed`})]}),f(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[f(`div`,{children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`previous`}),f(`pre`,{className:`tcp-code mt-1 max-h-24 overflow-auto text-[11px]`,children:Q(e?.previous_value)})]}),f(`div`,{children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`next`}),f(`pre`,{className:`tcp-code mt-1 max-h-24 overflow-auto text-[11px]`,children:Q(e?.next_value)})]})]})]},`${J(e?.path)||`diff`}-${t}`))]}):null,t.length?f(`div`,{className:`mt-2 grid gap-2`,children:[f(`button`,{type:`button`,onClick:i,className:`inline-flex w-fit items-center gap-2 rounded-md border border-slate-700/80 bg-slate-900/70 px-2 py-1 text-[11px] font-medium text-slate-100 transition hover:border-slate-500 hover:bg-slate-800`,children:[f(`i`,{"data-lucide":r?`chevron-up`:`chevron-down`}),r?`Hide issues`:`Show issues`]}),r?f(`div`,{className:`grid gap-2`,children:t.slice().sort((e,t)=>Number(t?.blocking)-Number(e?.blocking)).map((e,t)=>f(`div`,{className:e?.blocking?`rounded-md border border-amber-500/40 bg-amber-500/10 p-2 text-[11px] text-amber-50`:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2 text-[11px] text-slate-200`,children:[f(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f(`span`,{className:`font-medium`,children:J(e?.code)||`issue`}),f(`span`,{className:`tcp-subtle`,children:[`path: `,J(e?.path)||`n/a`]}),f(`span`,{className:e?.blocking?`tcp-badge-warning`:`tcp-badge-success`,children:e?.blocking?`blocking`:`warning`})]}),f(`div`,{className:`mt-1 text-slate-100`,children:J(e?.message)||`n/a`})]},`${J(e?.code)||`issue`}-${t}`))}):null]}):null]})}function Qn({planPackage:n,planPackageBundle:i,planPackageReplay:o,validationReport:s,runtimeContext:l,approvedPlanMaterialization:u,overlapHistoryEntries:d,title:p=`Scope inspector`,onOpenPromptEditor:m,onOpenModelRoutingEditor:h,onOpenConnectorBindingsEditor:g,onReplaceSharedContextPack:y}){let[b,x]=a(`all`),[S,C]=a(`all`),[w,T]=a(`all`),[E,D]=a(``),[O,ee]=a(``),[te,k]=a(``),[ne,A]=a(``),[j,re]=a(``),M=r(()=>Y(n?.routine_graph),[n]),N=r(()=>J(n?.workspace_root||n?.workspaceRoot||u?.workspace_root||u?.workspaceRoot),[u,n]),P=r(()=>J(n?.project_key||n?.projectKey||u?.project_key||u?.projectKey),[u,n]),ie=c({queryKey:[`context-packs`,`scope-inspector`,N,P],enabled:!!N,queryFn:()=>_(`/api/engine/context/packs?workspace_root=${encodeURIComponent(N)}${P?`&project_key=${encodeURIComponent(P)}`:``}`).catch(()=>({context_packs:[]}))}),F=r(()=>n?.connector_binding_resolution||null,[n]),ae=r(()=>n?.model_routing_resolution||null,[n]),oe=r(()=>{let e=M.map((e,t)=>[J(e?.routine_id||e?.id||`routine-${t+1}`),e]),t=new Map(e),n=new Map;e.forEach(([e,t])=>{Y(t?.dependencies).forEach(t=>{let r=J(t?.routine_id);r&&(n.has(r)||n.set(r,new Set),n.get(r)?.add(e))})});let r=new Map,i=new Set;function a(e){if(r.has(e))return r.get(e)||0;let n=t.get(e);if(!n)return r.set(e,0),0;if(i.has(e))return 0;i.add(e);let o=0;for(let e of Y(n?.dependencies)){let n=J(e?.routine_id);!n||!t.has(n)||(o=Math.max(o,a(n)+1))}return i.delete(e),r.set(e,o),o}let o=e.map(([e,r],i)=>{let o=Y(r?.dependencies).map(e=>{let n=J(e?.routine_id);return n?{routineId:n,dependencyType:Fn(e?.dependency_type||e?.type),mode:Fn(e?.mode),resolved:t.has(n)}:null}).filter(Boolean);return{routineId:e,routine:r,index:i,layer:a(e),stepCount:Y(r?.steps).length,downstreamCount:n.get(e)?.size||0,dependencies:o}}).sort((e,t)=>e.layer-t.layer||e.routineId.localeCompare(t.routineId));return{nodes:o,layers:Array.from(o.reduce((e,t)=>(e.has(t.layer)||e.set(t.layer,[]),e.get(t.layer)?.push(t),e),new Map)).map(([e,t])=>({layer:e,items:t})).sort((e,t)=>e.layer-t.layer)}},[M]),I=r(()=>n?.success_criteria_report||n?.success_criteria_evaluation||n?.validation_state?.success_criteria_evaluation||s?.success_criteria_report||s?.success_criteria_evaluation||null,[n,s]),se=r(()=>Y(I?.entries),[I]),L=r(()=>I?.plan||I?.plan_summary||I?.plan_evaluation||I?.plan_coverage||se.find(e=>J(e?.subject)===`plan`)||null,[se,I]),R=r(()=>Y(I?.routines||I?.routine_evaluations||I?.routine_coverage).length?Y(I?.routines||I?.routine_evaluations||I?.routine_coverage):se.filter(e=>J(e?.subject)===`routine`),[se,I]),ce=r(()=>Y(I?.steps||I?.step_evaluations||I?.step_coverage).length?Y(I?.steps||I?.step_evaluations||I?.step_coverage):se.filter(e=>J(e?.subject)===`step`),[se,I]),le=r(()=>Y(n?.credential_envelopes),[n]),ue=r(()=>Y(n?.context_objects),[n]),de=r(()=>Y(l?.routines),[l]),fe=r(()=>Y(u?.routines),[u]),pe=r(()=>n?.approval_policy||null,[n]),z=r(()=>Y(o?.issues),[o]),me=r(()=>{if(!o)return null;let e=o.scope_metadata_preserved===!0,t=o.handoff_rules_preserved===!0,n=o.credential_isolation_preserved===!0,r=z.some(e=>e?.blocking?!0:J(e?.severity).toLowerCase()===`error`);return o.compatible&&e&&t&&n?{label:`reuse`,tone:`success`,reason:`Replay is compatible and scope, handoff, and credential preservation are intact.`}:!e||!t||!n||r?{label:`fork`,tone:`warning`,reason:r?`Replay issues include blocking or error entries.`:`Scope, handoff, or credential preservation was not maintained.`}:{label:`refresh`,tone:`info`,reason:`Drift detected without an isolation break; refresh the plan while keeping lineage.`}},[o,z]),[he,ge]=a(!1),_e=r(()=>(Y(d).length?Y(d):Y(n?.overlap_policy?.overlap_log).map((e,t)=>({sourceLabel:J(n?.name||n?.title||p||`Current plan`),sourceAutomationId:J(n?.plan_id||n?.planId||``),sourcePlanId:J(n?.plan_id||n?.planId||``),sourcePlanRevision:Number(n?.plan_revision||n?.planRevision||0),sourceLifecycleState:J(n?.lifecycle_state||n?.lifecycleState||`unknown`),matchedPlanId:J(e?.matched_plan_id||e?.matchedPlanId||``),matchedPlanRevision:Number(e?.matched_plan_revision||e?.matchedPlanRevision||0),matchLayer:J(e?.match_layer||e?.matchLayer||``),similarityScore:e?.similarity_score??e?.similarityScore??null,decision:J(e?.decision||``),decidedBy:J(e?.decided_by||e?.decidedBy||``),decidedAt:J(e?.decided_at||e?.decidedAt||``),rowKey:`${J(n?.plan_id||n?.planId||p||`plan`)}-${t}`}))).map((e,t)=>({sourceLabel:J(e?.sourceLabel||e?.automation_name||e?.automationName||e?.sourceAutomationName||e?.automationId||e?.sourceAutomationId||p),sourceAutomationId:J(e?.sourceAutomationId||e?.automation_id||e?.automationId||``),sourcePlanId:J(e?.sourcePlanId||e?.plan_id||e?.planId||``),sourcePlanRevision:Number(e?.sourcePlanRevision??e?.plan_revision??e?.planRevision??0),sourceLifecycleState:J(e?.sourceLifecycleState||e?.lifecycle_state||e?.lifecycleState||`unknown`),matchedPlanId:J(e?.matchedPlanId||e?.matched_plan_id||e?.matchedPlanID||``),matchedPlanRevision:Number(e?.matchedPlanRevision??e?.matched_plan_revision??0),matchLayer:J(e?.matchLayer||e?.match_layer||``),similarityScore:e?.similarityScore??e?.similarity_score??null,decision:J(e?.decision||``),decidedBy:J(e?.decidedBy||e?.decided_by||``),decidedAt:J(e?.decidedAt||e?.decided_at||``),rowKey:J(e?.rowKey||e?.key||e?.id)||`${J(e?.matchedPlanId||e?.matched_plan_id||`overlap`)}-${t}`})).sort((e,t)=>{let n=Number(Date.parse(e.decidedAt||``)),r=Number(Date.parse(t.decidedAt||``));return Number.isFinite(n)&&Number.isFinite(r)&&n!==r?r-n:String(e.sourcePlanId||e.sourceAutomationId||e.rowKey).localeCompare(String(t.sourcePlanId||t.sourceAutomationId||t.rowKey))}),[d,n,p]),ve=r(()=>{let e=J(E).toLowerCase();return e?_e.filter(t=>[t.sourceLabel,t.sourceAutomationId,t.sourcePlanId,t.sourcePlanRevision,t.sourceLifecycleState,t.matchedPlanId,t.matchedPlanRevision,t.matchLayer,t.similarityScore,t.decision,t.decidedBy,t.decidedAt].map(e=>J(e).toLowerCase()).join(` `).includes(e)):_e},[_e,E]),B=r(()=>S===`all`&&w===`all`?M:M.filter(e=>{let t=J(e?.audit_scope?.run_history_visibility).toLowerCase(),n=J(e?.audit_scope?.final_artifact_visibility).toLowerCase();return(S===`all`||t===S)&&(w===`all`||n===w)}),[w,S,M]),V=s?.validation_state||s?.validationState||n?.validation_state||n?.validationState||s||null,H=r(()=>[[`ready for apply`,s?.ready_for_apply],[`ready for activation`,s?.ready_for_activation],[`approvals complete`,V?.approvals_complete],[`activation ready`,V?.compartmentalized_activation_ready],[`blockers`,s?.blocker_count],[`warnings`,s?.warning_count]],[V,s]),ye=r(()=>[L,...R,...ce].filter(Boolean).reduce((e,t)=>e+Y(t?.missing_required_artifacts||t?.missing_artifacts||t?.missing_required||t?.missing).length,0),[L,R,ce]),U=r(()=>{let e=I?.defined_count??null,t=I?.total_subjects??null,r=Y(n?.overlap_policy?.overlap_log),i=r.filter(e=>J(e?.decision).toLowerCase()===`fork`).length;return{successCoverage:e!==null&&t?{label:Jn(e,t),detail:`${e}/${t} subjects defined`}:null,approvalReadiness:V?.approvals_complete===!0||V?.approvals_complete===!1?{label:V.approvals_complete?`100%`:`0%`,detail:V.approvals_complete?`approvals complete`:`approvals still pending`}:null,overlapForkRate:r.length?{label:Jn(i,r.length),detail:`${i}/${r.length} overlap decisions forked`}:null}},[n,V,I]),be=r(()=>{let e=Date.now();return Y(ie.data?.context_packs).map(t=>({packId:J(t?.pack_id),title:J(t?.title||t?.summary||t?.pack_id||`shared context`),state:J(t?.state||`published`),sourcePlanId:J(t?.source_plan_id||t?.manifest?.plan_package?.plan_id),projectKey:J(t?.project_key||``),visibilityScope:J(t?.visibility_scope||`same_project`),allowedProjectKeys:Y(t?.allowed_project_keys).map(e=>J(e)).filter(Boolean),bindings:Y(t?.bindings),freshnessWindowHours:t?.freshness_window_hours,updatedAtMs:Number(t?.updated_at_ms||t?.published_at_ms||0),isStale:Number(t?.freshness_window_hours||0)>0&&Number(t?.updated_at_ms||t?.published_at_ms||0)>0&&e-Number(t?.updated_at_ms||t?.published_at_ms||0)>Number(t?.freshness_window_hours||0)*60*60*1e3,raw:t})).sort((e,t)=>t.updatedAtMs-e.updatedAtMs)},[ie.data]);e(()=>{if(!be.length){ne&&A(``);return}(!ne||!be.some(e=>e.packId===ne))&&A(be[0].packId)},[be,ne]);let xe=r(()=>be.find(e=>e.packId===ne)||null,[be,ne]),Se=r(()=>{let e=new Map(be.map(e=>[e.packId,e])),t=[n?.shared_context_bindings,n?.sharedContextBindings,n?.shared_context_pack_ids,n?.sharedContextPackIds,u?.shared_context_bindings,u?.sharedContextBindings,u?.shared_context_pack_ids,u?.sharedContextPackIds],r=[];for(let e of t)if(Array.isArray(e))for(let t of e){if(typeof t==`string`){let e=J(t);if(!e)continue;r.some(t=>t.packId===e)||r.push({packId:e,required:!0,alias:``});continue}if(!t||typeof t!=`object`)continue;let e=J(t.pack_id||t.packId||t.context_pack_id||t.contextPackId||t.id);!e||r.some(t=>t.packId===e)||r.push({packId:e,required:t.required!==!1,alias:J(t.alias||t.name||t.label||``)})}return r.map(t=>({...t,pack:e.get(t.packId)||null}))},[u,be,n]),W=r(()=>{let e=J(n?.source_plan_id||n?.sourcePlanId||u?.source_plan_id||u?.sourcePlanId||n?.plan_id||n?.planId||u?.plan_id||u?.planId),t=[...Un(n?.title),...Un(n?.name),...Un(u?.title)],r=new Set(Se.map(e=>e.packId));return be.filter(e=>!r.has(e.packId)).filter(e=>J(e.state)===`published`).filter(e=>!e.isStale).map(n=>{let r=0;e&&n.sourcePlanId===e&&(r+=6),n.updatedAtMs&&(r+=1);let i=new Set([...Un(n.title),...Un(n.raw?.summary)]),a=t.filter(e=>i.has(e));return r+=Math.min(3,a.length),{...n,score:r,reason:Gn(n,e,t)}}).sort((e,t)=>t.score-e.score||t.updatedAtMs-e.updatedAtMs).slice(0,3)},[u,be,n,Se]),Ce=r(()=>Se.filter(e=>e.pack?.state===`superseded`&&J(e.pack?.raw?.superseded_by_pack_id)),[Se]);async function we(){if(!N){k(`Workspace root is not available for this plan.`);return}k(`Publishing shared workflow context...`);try{let e=Y(n?.context_objects).map(e=>J(e?.context_object_id||e?.contextObjectId)).filter(Boolean),t=Y(u?.artifact_refs||u?.artifactRefs||n?.artifact_refs||n?.artifactRefs).map(e=>J(e)).filter(Boolean),r=Y(n?.governed_memory_refs||n?.governedMemoryRefs).map(e=>J(e)).filter(Boolean),i={title:J(n?.title||n?.name||u?.title||u?.name||n?.plan_id||`Shared workflow context`),summary:J(n?.summary||u?.summary||`Shared workflow context`),workspace_root:N,...P?{project_key:P}:{},source_plan_id:J(n?.plan_id||n?.planId||u?.plan_id||``),source_context_run_id:J(u?.context_run_id||u?.contextRunId||n?.context_run_id||n?.contextRunId||``),plan_package:n,approved_plan_materialization:u,runtime_context:l,context_object_refs:e,artifact_refs:t,governed_memory_refs:r,allowed_project_keys:Wn(j)};k(`Published ${J((await _(`/api/engine/context/packs`,{method:`POST`,body:JSON.stringify(i)}))?.context_pack?.pack_id||i.title)}.`)}catch(e){k(e instanceof Error?e.message:`Publish failed.`)}}return n?f(`div`,{className:`grid gap-3 rounded-xl border border-slate-700/60 bg-slate-950/20 p-3 text-xs text-slate-300`,children:[f(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[f(`div`,{children:[f(`div`,{className:`font-medium text-slate-100`,children:p}),f(`div`,{className:`tcp-subtle`,children:[`plan: `,J(n?.plan_id)||`n/a`,` · revision:`,` `,J(n?.plan_revision)||`n/a`,` · routines: `,M.length]})]}),f(`div`,{className:`flex flex-wrap items-center gap-1`,children:[[`all`,`scope`,`graph`,`compare`,`credentials`,`handoffs`,`runtime`,`audit`].map(e=>f(`button`,{type:`button`,"aria-pressed":b===e,className:`tcp-btn h-7 px-2 text-[11px] ${b===e?`border-amber-400/60 bg-amber-400/10 text-amber-300`:``}`,onClick:()=>x(e),children:e===`all`?`All`:e.charAt(0).toUpperCase()+e.slice(1)},e)),i?f(t,{children:[f(`button`,{type:`button`,className:`tcp-btn h-7 px-2 text-[11px]`,onClick:()=>Mn(`${J(n?.plan_id)||`plan`}-bundle.json`,i),children:[f(`i`,{"data-lucide":`download`}),`Export bundle`]}),f(`button`,{type:`button`,className:`tcp-btn h-7 px-2 text-[11px]`,onClick:async()=>{try{await navigator.clipboard.writeText(v(i)),ee(`Copied bundle JSON.`)}catch(e){ee(e instanceof Error?e.message:`Copy failed.`)}},children:[f(`i`,{"data-lucide":`copy`}),`Copy bundle`]}),O?f(`span`,{className:`tcp-subtle text-[11px]`,children:O}):null]}):null]})]}),o?f(Zn,{planPackageReplay:o,replayIssues:z,replayRecommendation:me,showReplayIssues:he,onToggleShowReplayIssues:()=>ge(e=>!e)}):null,(b===`all`||b===`compare`)&&o?f(An,{planPackageReplay:o}):null,(b===`all`||b===`scope`)&&M.length?f(`div`,{className:`grid gap-2`,children:[f(`div`,{className:`font-medium text-slate-200`,children:`Routine scope preview`}),f(`div`,{className:`grid gap-2`,children:M.map((e,t)=>f(`div`,{className:`rounded-lg border border-slate-800/80 bg-slate-950/30 p-3`,children:[f(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[f(`div`,{className:`font-medium text-slate-100`,children:J(e?.routine_id||e?.id||`routine-${t+1}`)}),f(`span`,{className:`tcp-badge-info`,children:J(e?.kind||e?.semantic_kind||`routine`)})]}),f(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[X(`mission context`,e?.data_scope?.mission_context_scope),X(`cross-routine visibility`,e?.data_scope?.cross_routine_visibility),X(`inter-routine model`,n?.inter_routine_policy?.communication_model),X(`artifact handoff validation`,n?.inter_routine_policy?.artifact_handoff_validation)]}),f(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:[f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`readable paths`}),f(`div`,{className:`mt-1 break-words text-slate-100`,children:jn(e?.data_scope?.readable_paths)})]}),f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`writable paths`}),f(`div`,{className:`mt-1 break-words text-slate-100`,children:jn(e?.data_scope?.writable_paths)})]})]}),f(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`denied paths`}),f(`div`,{className:`mt-1 break-words text-slate-100`,children:jn(e?.data_scope?.denied_paths)})]}),f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`audit visibility`}),f(`div`,{className:`mt-1 break-words text-slate-100`,children:[J(e?.audit_scope?.run_history_visibility)||`n/a`,` ·`,` `,J(e?.audit_scope?.intermediate_artifact_visibility)||`n/a`,` `,`· `,J(e?.audit_scope?.final_artifact_visibility)||`n/a`]})]})]}),Array.isArray(e?.steps)&&e.steps.length?f(`div`,{className:`mt-2 text-[11px] text-slate-400`,children:[`steps: `,e.steps.length,` · dependencies:`,` `,e.steps.map(e=>J(e?.step_id||e?.id)).filter(Boolean).join(`, `)]}):null]},String(e?.routine_id||e?.id||t)))})]}):null,(b===`all`||b===`graph`)&&M.length?f(`div`,{className:`grid gap-2`,children:[f(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[f(`div`,{className:`font-medium text-slate-200`,children:`Routine dependency graph`}),f(`div`,{className:`tcp-subtle text-[11px]`,children:"Read-only graph derived from `routine_graph.dependencies`"})]}),ae?f(`div`,{className:`rounded-lg border border-slate-800/80 bg-slate-950/30 p-3`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`Model routing summary`}),f(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-3`,children:[X(`tier assigned`,ae?.tier_assigned_count),X(`provider unresolved`,ae?.provider_unresolved_count),X(`steps`,Y(ae?.entries).length)]})]}):null,f(`div`,{className:`overflow-x-auto pb-1`,children:f(`div`,{className:`flex min-w-max items-start gap-3`,children:oe.layers.map(({layer:e,items:t})=>f(`div`,{className:`grid min-w-[20rem] max-w-[24rem] flex-1 gap-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:[`Layer `,e,` · `,t.length,` routine`,t.length===1?``:`s`]}),f(`div`,{className:`grid gap-2`,children:t.map(e=>{let t=Y(e.routine?.step_ids).length?Y(e.routine?.step_ids).map(e=>J(e)).filter(Boolean):Y(e.routine?.steps).map(e=>J(e?.step_id||e?.stepId||e?.id)).filter(Boolean);return f(`div`,{className:`rounded-lg border border-slate-800/80 bg-slate-950/30 p-3`,children:[f(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[f(`div`,{className:`font-medium text-slate-100`,children:e.routineId}),f(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f(`span`,{className:`tcp-badge-info`,children:Fn(e.routine?.semantic_kind||`routine`)}),f(`span`,{className:`tcp-badge-success`,children:[e.stepCount,` step`,e.stepCount===1?``:`s`]}),f(`span`,{className:`tcp-badge-info`,children:[e.downstreamCount,` downstream`]}),m?f(`button`,{type:`button`,className:`tcp-btn h-7 px-2 text-[11px]`,onClick:m,children:[f(`i`,{"data-lucide":`arrow-right`}),`Open in editor`]}):null]})]}),t.length?f(`div`,{className:`mt-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`step ids`}),f(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:t.map(t=>f(`span`,{className:`rounded-full border border-slate-700/80 bg-slate-900/80 px-2 py-1 text-[11px] text-slate-100`,children:t},`${e.routineId}-${t}`))})]}):null,f(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[X(`dependency resolution`,e.routine?.dependency_resolution?.strategy?[Fn(e.routine?.dependency_resolution?.strategy),Fn(e.routine?.dependency_resolution?.partial_failure_mode),Fn(e.routine?.dependency_resolution?.reentry_point)].filter(Boolean).join(` · `):`n/a`),X(`trigger`,Fn(e.routine?.trigger?.trigger_type||`n/a`))]}),f(`div`,{className:`mt-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`Upstream dependencies`}),e.dependencies.length?f(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:e.dependencies.map(t=>f(`span`,{className:t.resolved?`rounded-full border border-slate-700/80 bg-slate-900/80 px-2 py-1 text-[11px] text-slate-100`:`rounded-full border border-amber-500/40 bg-amber-500/10 px-2 py-1 text-[11px] text-amber-50`,children:[f(`span`,{className:`font-medium`,children:t.routineId}),f(`span`,{className:`tcp-subtle`,children:` · `}),f(`span`,{children:t.dependencyType}),f(`span`,{className:`tcp-subtle`,children:` · `}),f(`span`,{children:t.mode})]},`${e.routineId}-${t.routineId}`))}):f(`div`,{className:`mt-1 text-sm text-slate-400`,children:`No upstream dependencies.`})]})]},e.routineId)})})]},`layer-${e}`))})})]}):null,(b===`all`||b===`credentials`)&&le.length?f(`div`,{className:`grid gap-2`,children:[f(`div`,{className:`font-medium text-slate-200`,children:`Credential envelopes`}),f(`div`,{className:`grid gap-2`,children:le.map((e,t)=>f(`div`,{className:`rounded-lg border border-slate-800/80 bg-slate-950/30 p-3`,children:[f(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[f(`div`,{className:`font-medium text-slate-100`,children:J(e?.routine_id||`routine-${t+1}`)}),f(`span`,{className:`tcp-badge-info`,children:J(e?.issuing_authority||`engine`)})]}),f(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[f(`div`,{children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`entitled connectors`}),f(G,{value:e?.entitled_connectors||[],className:`mt-1`,preClassName:`tcp-code mt-1 max-h-28 overflow-auto text-[11px]`})]}),f(`div`,{children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`denied connectors`}),f(G,{value:e?.denied_connectors||[],className:`mt-1`,preClassName:`tcp-code mt-1 max-h-28 overflow-auto text-[11px]`})]})]})]},String(e?.routine_id||t)))})]}):null,(b===`all`||b===`credentials`)&&(F||Y(n?.connector_intents).length)?f(`div`,{className:`grid gap-2`,children:[f(yn,{planPackage:n}),f(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[f(`div`,{className:`font-medium text-slate-200`,children:`Connector binding resolution`}),g?f(`button`,{type:`button`,className:`tcp-btn h-7 px-2 text-[11px]`,onClick:g,children:[f(`i`,{"data-lucide":`settings-2`}),`Edit connectors`]}):null]}),f(`div`,{className:`tcp-subtle text-[11px]`,children:`Read-only summary. Edit bindings in the workflow connector bindings block.`}),f(`div`,{className:`rounded-lg border border-slate-800/80 bg-slate-950/30 p-3`,children:f(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[X(`mapped`,F?.mapped_count),X(`unresolved required`,F?.unresolved_required_count),X(`unresolved optional`,F?.unresolved_optional_count)]})}),f(`div`,{className:`grid gap-2`,children:Y(F?.entries).map((e,t)=>f(`div`,{className:`rounded-lg border border-slate-800/80 bg-slate-950/30 p-3`,children:[f(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[f(`div`,{className:`font-medium text-slate-100`,children:J(e?.capability||`binding-${t+1}`)}),f(`span`,{className:e?.resolved?`tcp-badge-success`:e?.required?`tcp-badge-warning`:`tcp-badge-info`,children:J(e?.status||`unresolved`)})]}),f(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[X(`required`,e?.required),X(`degraded mode`,e?.degraded_mode_allowed)]}),f(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[X(`binding type`,e?.binding_type),X(`binding id`,e?.binding_id)]}),f(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[X(`why`,e?.why),X(`allowlist pattern`,e?.allowlist_pattern)]})]},String(e?.capability||t)))})]}):null,(b===`all`||b===`runtime`)&&ae?f(`div`,{className:`grid gap-2`,children:[f(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[f(`div`,{className:`font-medium text-slate-200`,children:`Model routing`}),h?f(`button`,{type:`button`,className:`tcp-btn h-7 px-2 text-[11px]`,onClick:h,children:[f(`i`,{"data-lucide":`settings-2`}),`Edit routing`]}):null]}),f(`div`,{className:`tcp-subtle text-[11px]`,children:`Read-only summary. Edit the workflow default provider/model in the workflow model selection block, and per-step overrides in the prompt editor cards.`}),f(`div`,{className:`rounded-lg border border-slate-800/80 bg-slate-950/30 p-3`,children:f(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[X(`tier assigned`,ae?.tier_assigned_count),X(`provider unresolved`,ae?.provider_unresolved_count),X(`steps`,Y(ae?.entries).length)]})}),f(`div`,{className:`grid gap-2`,children:Y(ae?.entries).map((e,t)=>f(`div`,{className:`rounded-lg border border-slate-800/80 bg-slate-950/30 p-3`,children:[f(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[f(`div`,{className:`font-medium text-slate-100`,children:J(e?.step_id||`step-${t+1}`)}),f(`span`,{className:e?.resolved?`tcp-badge-success`:`tcp-badge-warning`,children:J(e?.status||`unresolved`)})]}),f(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[X(`tier`,e?.tier),X(`provider id`,e?.provider_id)]}),f(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[X(`model id`,e?.model_id),X(`reason`,e?.reason)]})]},String(e?.step_id||t)))})]}):null,(b===`all`||b===`audit`)&&I?f(`div`,{className:`grid gap-2`,children:[f(`div`,{className:`font-medium text-slate-200`,children:`Success criteria coverage`}),f(`div`,{className:`rounded-lg border border-slate-800/80 bg-slate-950/30 p-3`,children:f(`div`,{className:`grid gap-2 sm:grid-cols-4`,children:[X(`plan status`,Z(L)),X(`routines reported`,R.length),X(`steps reported`,ce.length),X(`missing artifacts`,ye)]})}),f(`div`,{className:`grid gap-2`,children:f(`div`,{className:`rounded-lg border border-slate-800/80 bg-slate-950/30 p-3`,children:[f(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[f(`div`,{className:`font-medium text-slate-100`,children:`Plan success criteria`}),Vn(Z(L))]}),L?f(t,{children:[f(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-3`,children:[X(`required artifacts`,Y(L?.required_artifacts||L?.required_artifact_ids||L?.required).length),X(`missing artifacts`,Y(L?.missing_required_artifacts||L?.missing_artifacts||L?.missing_required||L?.missing).length),X(`freshness window`,L?.freshness_window_hours??L?.freshness_window)]}),f(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`required artifacts`}),f(`div`,{className:`mt-1 break-words text-slate-100`,children:jn(L?.required_artifacts||L?.required_artifact_ids||L?.required)})]}),f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`missing artifacts`}),f(`div`,{className:`mt-1 break-words text-slate-100`,children:jn(L?.missing_required_artifacts||L?.missing_artifacts||L?.missing_required||L?.missing)})]})]}),J(L?.minimum_viable_completion||L?.minimum_output)?f(`div`,{className:`mt-2 text-slate-100`,children:[`minimum:`,` `,J(L?.minimum_viable_completion||L?.minimum_output)]}):null]}):f(`div`,{className:`mt-2 text-slate-400`,children:`No plan-level criteria reported.`})]})}),f(`div`,{className:`grid gap-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`Routine criteria`}),R.length?R.map((e,t)=>{let n=J(e?.routine_id||e?.id||`routine-${t+1}`);return f(`div`,{className:`rounded-lg border border-slate-800/80 bg-slate-950/30 p-3`,children:[f(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[f(`div`,{className:`font-medium text-slate-100`,children:n}),Vn(Z(e))]}),f(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-3`,children:[X(`required artifacts`,Y(e?.required_artifacts||e?.required_artifact_ids||e?.required).length),X(`missing artifacts`,Y(e?.missing_required_artifacts||e?.missing_artifacts||e?.missing_required||e?.missing).length),X(`freshness window`,e?.freshness_window_hours??e?.freshness_window)]}),f(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`required artifacts`}),f(`div`,{className:`mt-1 break-words text-slate-100`,children:jn(e?.required_artifacts||e?.required_artifact_ids||e?.required)})]}),f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`missing artifacts`}),f(`div`,{className:`mt-1 break-words text-slate-100`,children:jn(e?.missing_required_artifacts||e?.missing_artifacts||e?.missing_required||e?.missing)})]})]}),J(e?.minimum_viable_completion||e?.minimum_output||e?.summary)?f(`div`,{className:`mt-2 text-slate-100`,children:[`minimum:`,` `,J(e?.minimum_viable_completion||e?.minimum_output||e?.summary)]}):null]},n)}):f(`div`,{className:`tcp-subtle text-xs`,children:`No routine-level criteria reported.`})]}),f(`div`,{className:`grid gap-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`Step criteria`}),ce.length?ce.map((e,t)=>{let n=J(e?.step_id||e?.id||`step-${t+1}`);return f(`div`,{className:`rounded-lg border border-slate-800/80 bg-slate-950/30 p-3`,children:[f(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[f(`div`,{className:`font-medium text-slate-100`,children:n}),Vn(Z(e))]}),f(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-3`,children:[X(`required artifacts`,Y(e?.required_artifacts||e?.required_artifact_ids||e?.required).length),X(`missing artifacts`,Y(e?.missing_required_artifacts||e?.missing_artifacts||e?.missing_required||e?.missing).length),X(`freshness window`,e?.freshness_window_hours??e?.freshness_window)]}),f(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`required artifacts`}),f(`div`,{className:`mt-1 break-words text-slate-100`,children:jn(e?.required_artifacts||e?.required_artifact_ids||e?.required)})]}),f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`missing artifacts`}),f(`div`,{className:`mt-1 break-words text-slate-100`,children:jn(e?.missing_required_artifacts||e?.missing_artifacts||e?.missing_required||e?.missing)})]})]}),J(e?.minimum_viable_completion||e?.minimum_output||e?.summary)?f(`div`,{className:`mt-2 text-slate-100`,children:[`minimum:`,` `,J(e?.minimum_viable_completion||e?.minimum_output||e?.summary)]}):null]},n)}):f(`div`,{className:`tcp-subtle text-xs`,children:`No step-level criteria reported.`})]})]}):null,(b===`all`||b===`handoffs`)&&ue.length?f(`div`,{className:`grid gap-2`,children:[f(`div`,{className:`font-medium text-slate-200`,children:`Handoff contracts`}),f(`div`,{className:`grid gap-2`,children:ue.map((e,t)=>f(`div`,{className:`rounded-lg border border-slate-800/80 bg-slate-950/30 p-3`,children:[f(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[f(`div`,{className:`font-medium text-slate-100`,children:J(e?.context_object_id||`context-${t+1}`)}),f(`span`,{className:`tcp-badge-info`,children:J(e?.kind||e?.scope||`context`)})]}),f(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[X(`owner routine`,e?.owner_routine_id),X(`producer step`,e?.producer_step_id),X(`scope`,e?.scope),X(`validation`,e?.validation_status)]}),f(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`declared consumers`}),f(`div`,{className:`mt-1 break-words text-slate-100`,children:jn(e?.declared_consumers)})]}),f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`data scope refs`}),f(`div`,{className:`mt-1 break-words text-slate-100`,children:jn(e?.data_scope_refs)})]})]}),f(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`artifact ref`}),f(`div`,{className:`mt-1 break-words text-slate-100`,children:J(e?.artifact_ref)||`n/a`})]}),f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`freshness window`}),f(`div`,{className:`mt-1 break-words text-slate-100`,children:[J(e?.freshness_window_hours)||`n/a`,` hours`]})]})]})]},String(e?.context_object_id||t)))})]}):null,(b===`all`||b===`runtime`)&&de.length?f(`div`,{className:`grid gap-2`,children:[f(`div`,{className:`font-medium text-slate-200`,children:`Runtime context partitions`}),f(`div`,{className:`grid gap-2`,children:de.map((e,t)=>f(`div`,{className:`rounded-lg border border-slate-800/80 bg-slate-950/30 p-3`,children:[f(`div`,{className:`font-medium text-slate-100`,children:J(e?.routine_id||`routine-${t+1}`)}),f(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[f(`div`,{children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`visible context objects`}),f(G,{value:e?.visible_context_objects||[],className:`mt-1`,preClassName:`tcp-code mt-1 max-h-28 overflow-auto text-[11px]`})]}),f(`div`,{children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`step context bindings`}),f(G,{value:e?.step_context_bindings||[],className:`mt-1`,preClassName:`tcp-code mt-1 max-h-28 overflow-auto text-[11px]`})]})]})]},String(e?.routine_id||t)))})]}):null,(b===`all`||b===`runtime`)&&u?f(`div`,{className:`grid gap-2`,children:[f(`div`,{className:`font-medium text-slate-200`,children:`Approved plan materialization`}),f(`div`,{className:`rounded-lg border border-slate-800/80 bg-slate-950/30 p-3`,children:[f(`div`,{className:`grid gap-2 sm:grid-cols-4`,children:[X(`plan id`,u?.plan_id),X(`revision`,u?.plan_revision),X(`routines`,u?.routine_count),X(`context objects`,u?.context_object_count)]}),X(`lifecycle state`,u?.lifecycle_state),de.length?f(`div`,{className:`mt-2 text-[11px] text-slate-400`,children:`The runtime context below is derived from the approved materialization.`}):null]}),f(`div`,{className:`grid gap-2`,children:fe.map((e,t)=>f(`div`,{className:`rounded-lg border border-slate-800/80 bg-slate-950/30 p-3`,children:[f(`div`,{className:`font-medium text-slate-100`,children:J(e?.routine_id||`routine-${t+1}`)}),f(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`step ids`}),f(`div`,{className:`mt-1 break-words text-slate-100`,children:jn(e?.step_ids)})]}),f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`visible context objects`}),f(`div`,{className:`mt-1 break-words text-slate-100`,children:jn(e?.visible_context_object_ids)})]})]}),f(`div`,{className:`mt-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`step context bindings`}),f(G,{value:e?.step_context_bindings||[],className:`mt-1`,preClassName:`tcp-code mt-1 max-h-28 overflow-auto text-[11px]`})]})]},String(e?.routine_id||t)))})]}):null,N?f(Xn,{workspaceRoot:N,projectKey:P,sharedContextBindingRows:Se,supersededContextBindingRows:Ce,contextPacks:be,selectedContextPack:xe,suggestedContextPacks:W,sharedContextAllowlistInput:j,contextPackStatus:te,onAllowlistChange:re,onSelectContextPack:A,onPublishCurrentContextPack:()=>{we()},onContextPackStatusChange:k,onReplaceSharedContextPack:y}):null,(b===`all`||b===`audit`)&&V?f(`div`,{className:`grid gap-2`,role:`region`,"aria-label":`Validation and history visibility`,children:[f(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[f(`div`,{className:`font-medium text-slate-200`,children:`Audit / provenance`}),f(`div`,{className:`flex flex-wrap items-center gap-1`,children:[`all`,`routine_only`,`plan_owner`,`named_roles`].map(e=>f(`button`,{type:`button`,"aria-pressed":S===e,className:`tcp-btn h-7 px-2 text-[11px] ${S===e?`border-amber-400/60 bg-amber-400/10 text-amber-300`:``}`,onClick:()=>C(e),children:e===`all`?`All`:Nn(e).replace(/\s+/g,` `)},e))})]}),f(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`Artifact visibility`}),f(`div`,{className:`flex flex-wrap items-center gap-1`,children:[`all`,`routine_only`,`declared_consumers`,`plan_owner`,`workspace`].map(e=>f(`button`,{type:`button`,"aria-pressed":w===e,className:`tcp-btn h-7 px-2 text-[11px] ${w===e?`border-amber-400/60 bg-amber-400/10 text-amber-300`:``}`,onClick:()=>T(e),children:e===`all`?`All`:Pn(e)},e))})]}),f(`div`,{className:`tcp-subtle text-[11px]`,children:[`Validation and history visibility, `,B.length,` routine`,B.length===1?``:`s`,` visible.`]}),f(`div`,{className:`grid gap-2 sm:grid-cols-2 xl:grid-cols-4`,children:[X(`data scopes valid`,V?.data_scopes_valid),X(`audit scopes valid`,V?.audit_scopes_valid),X(`credential envelopes valid`,V?.credential_envelopes_valid),X(`context objects valid`,V?.context_objects_valid)]}),f(`div`,{className:`grid gap-2 sm:grid-cols-2 xl:grid-cols-4`,children:[X(`connector mappings`,V?.required_connectors_mapped===!0?`mapped`:V?.required_connectors_mapped===!1?`unmapped`:`n/a`),X(`directories writable`,V?.directories_writable===!0?`yes`:V?.directories_writable===!1?`no`:`n/a`),X(`schedules valid`,V?.schedules_valid===!0?`yes`:V?.schedules_valid===!1?`no`:`n/a`),X(`models resolved`,V?.models_resolved===!0?`yes`:V?.models_resolved===!1?`no`:`n/a`)]}),f(`div`,{className:`grid gap-2 sm:grid-cols-2 xl:grid-cols-4`,children:[X(`dependencies resolvable`,V?.dependencies_resolvable===!0?`yes`:V?.dependencies_resolvable===!1?`no`:`n/a`),X(`approvals complete`,V?.approvals_complete===!0?`yes`:V?.approvals_complete===!1?`no`:`n/a`),X(`activation ready`,V?.compartmentalized_activation_ready===!0?`yes`:V?.compartmentalized_activation_ready===!1?`no`:`n/a`),X(`degraded modes acknowledged`,V?.degraded_modes_acknowledged===!0?`yes`:V?.degraded_modes_acknowledged===!1?`no`:`n/a`)]}),f(`div`,{className:`rounded-lg border border-slate-800/80 bg-slate-950/30 p-3`,children:[f(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[f(`div`,{className:`font-medium text-slate-100`,children:`Validation summary`}),f(`span`,{className:`tcp-badge-info`,children:`apply / activation`})]}),f(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2 xl:grid-cols-3`,children:H.map(([e,t])=>f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:e}),f(`div`,{className:`mt-1`,children:typeof t==`boolean`?Kn(t):f(`span`,{className:`tcp-badge-info`,children:t==null?`n/a`:String(t)})})]},e))})]}),U?f(`div`,{className:`rounded-lg border border-slate-800/80 bg-slate-950/30 p-3`,children:[f(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[f(`div`,{className:`font-medium text-slate-100`,children:`Analytics summary`}),f(`span`,{className:`tcp-badge-info`,children:`derived from current snapshot`})]}),f(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2 xl:grid-cols-4`,children:[U.successCoverage?f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`success coverage`}),f(`div`,{className:`mt-1 text-slate-100`,children:U.successCoverage.label}),f(`div`,{className:`tcp-subtle text-[11px]`,children:U.successCoverage.detail})]}):null,U.approvalReadiness?f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`approval readiness`}),f(`div`,{className:`mt-1 text-slate-100`,children:U.approvalReadiness.label}),f(`div`,{className:`tcp-subtle text-[11px]`,children:U.approvalReadiness.detail})]}):null,U.overlapForkRate?f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`overlap fork rate`}),f(`div`,{className:`mt-1 text-slate-100`,children:U.overlapForkRate.label}),f(`div`,{className:`tcp-subtle text-[11px]`,children:U.overlapForkRate.detail})]}):null]})]}):null,_e.length?f(`div`,{className:`rounded-lg border border-slate-800/80 bg-slate-950/30 p-3`,children:[f(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[f(`div`,{className:`font-medium text-slate-100`,children:`Searchable overlap history`}),f(`span`,{className:`tcp-badge-info`,children:[ve.length,`/`,_e.length,` decisions`]})]}),f(`div`,{className:`mt-2 grid gap-2`,children:[f(`div`,{className:`grid gap-1`,children:[f(`label`,{className:`text-xs text-slate-400`,children:`Search overlap history`}),f(`input`,{className:`tcp-input`,value:E,onInput:e=>D(e.target.value),placeholder:`Search automation id, plan id, revision, decision, decided by, or source`})]}),f(`div`,{className:`text-xs text-slate-500`,children:`Searchable across loaded workflow plans. Use it to find prior reuse, merge, fork, and new decisions by plan or source.`}),ve.length?ve.map((e,t)=>f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[f(`div`,{className:`font-medium text-slate-100`,children:J(e?.sourcePlanId||e?.sourceAutomationId||e?.matchedPlanId||`overlap-${t+1}`)}),f(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f(`span`,{className:`tcp-badge-info`,children:J(e?.decision||`unknown`)}),J(e?.sourceLifecycleState)?f(`span`,{className:`tcp-badge-info`,children:J(e?.sourceLifecycleState)}):null]})]}),f(`div`,{className:`mt-2 text-xs text-slate-400`,children:[`source`,` `,J(e?.sourceLabel||e?.sourceAutomationId||`n/a`)]}),f(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-4`,children:[X(`plan revision`,e?.sourcePlanRevision),X(`matched plan`,e?.matchedPlanId),X(`matched revision`,e?.matchedPlanRevision),X(`match layer`,e?.matchLayer),X(`similarity`,e?.similarityScore),X(`decided by`,e?.decidedBy)]}),J(e?.decidedAt)?f(`div`,{className:`mt-2 text-xs text-slate-400`,children:[`decided at `,J(e?.decidedAt)]}):null]},`${J(e?.rowKey||e?.matchedPlanId||e?.sourcePlanId||t)}-${t}`)):f(`div`,{className:`rounded-md border border-dashed border-slate-800/80 bg-slate-950/20 p-3 text-xs text-slate-400`,children:`No overlap decisions match the current search.`})]})]}):null,pe?f(`div`,{className:`rounded-lg border border-slate-800/80 bg-slate-950/30 p-3`,children:[f(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[f(`div`,{className:`font-medium text-slate-100`,children:`Approval matrix`}),f(`span`,{className:`tcp-badge-info`,children:`plan level`})]}),f(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2 xl:grid-cols-3`,children:Yn(pe).map(e=>f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:e.label}),f(`div`,{className:`mt-1`,children:f(`span`,{className:`tcp-badge-info`,children:qn(e.value)})})]},e.key))})]}):null,f(`div`,{className:`grid gap-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`Routine history visibility`}),f(`div`,{className:`grid gap-2`,children:B.length?B.map((e,t)=>{let n=J(e?.routine_id||e?.id||`routine-${t+1}`),r=ue.filter(e=>J(e?.owner_routine_id)===n);return f(`div`,{className:`rounded-lg border border-slate-800/80 bg-slate-950/30 p-3`,children:[f(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[f(`div`,{className:`font-medium text-slate-100`,children:n}),f(`span`,{className:`tcp-badge-info`,children:Nn(e?.audit_scope?.run_history_visibility)})]}),f(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-3`,children:[X(`history visibility`,e?.audit_scope?.run_history_visibility),X(`intermediate artifacts`,e?.audit_scope?.intermediate_artifact_visibility),X(`final artifacts`,e?.audit_scope?.final_artifact_visibility),X(`visible context objects`,r.length)]}),f(`div`,{className:`mt-2`,children:[f(`div`,{className:`tcp-subtle text-[11px] uppercase tracking-wide`,children:`visible context objects`}),f(`div`,{className:`mt-1 break-words text-slate-100`,children:r.length?r.map(e=>J(e?.context_object_id||e?.name||``)).filter(Boolean).join(`, `):`none`})]})]},n)}):f(`div`,{className:`tcp-subtle text-xs`,children:`No routines match the selected history visibility.`})})]}),f(G,{value:s||V,label:`Raw validation payload`,className:`rounded-lg border border-slate-800/80 bg-slate-950/30 p-3`,preClassName:`tcp-code mt-2 max-h-64 overflow-auto text-[11px]`})]}):null,!M.length&&!le.length&&!ue.length?f(`div`,{className:`tcp-subtle`,children:`Scope data is present, but the plan package does not yet contain routine, credential, or handoff details to inspect.`}):null]}):f(`div`,{className:`grid gap-2 rounded-xl border border-slate-700/60 bg-slate-950/20 p-3 text-xs text-slate-300`,children:[f(`div`,{className:`font-medium text-slate-100`,children:p}),f(`div`,{className:`tcp-subtle`,children:`No stored plan package is available yet. Apply a workflow plan first to inspect scope, credential envelopes, and handoff contracts here.`})]})}function $n(){return{kind:`handoff_available`,source_automation_id:null,artifact_type:null}}function er({value:e,onChange:t,automations:n=[]}){let[r,i]=a(!1),o=(n,r)=>{t(e.map((e,t)=>t===n?{...e,...r}:e))},s=n=>{t(e.filter((e,t)=>t!==n))};return f(`div`,{className:`grid gap-3 rounded-xl border border-slate-700/50 bg-slate-900/30 p-4`,children:[f(`div`,{className:`flex items-center justify-between gap-2`,children:[f(`div`,{children:[f(`div`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:`Watch conditions`}),f(`div`,{className:`mt-0.5 text-xs text-slate-500`,children:`Trigger this automation when specific handoffs become available.`})]}),e.length>0&&f(`span`,{className:`rounded-full bg-amber-400/15 px-2 py-0.5 text-xs font-medium text-amber-400`,children:`⚡ watch-triggered`})]}),e.length===0&&f(`div`,{className:`rounded-lg border border-dashed border-slate-700/40 p-3 text-center text-xs text-slate-500`,children:`No watch conditions — this automation is scheduled or manual only.`}),e.map((e,t)=>f(`div`,{className:`grid gap-2 rounded-lg border border-amber-400/20 bg-amber-400/5 p-3`,children:[f(`div`,{className:`flex items-center justify-between`,children:[f(`div`,{className:`flex items-center gap-2`,children:[f(`i`,{"data-lucide":`zap`,className:`h-3.5 w-3.5 text-amber-400`}),f(`span`,{className:`text-xs font-medium text-amber-300`,children:`HandoffAvailable`})]}),f(`button`,{type:`button`,className:`tcp-btn h-6 w-6 px-0 text-red-400/70 hover:text-red-300`,onClick:()=>s(t),title:`Remove condition`,children:f(`i`,{"data-lucide":`x`})})]}),f(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[f(`div`,{className:`grid gap-1`,children:[f(`label`,{className:`text-xs text-slate-400`,children:`Source automation`}),f(`select`,{className:`tcp-select text-xs`,value:e.source_automation_id??``,onChange:e=>o(t,{source_automation_id:e.target.value||null}),children:[f(`option`,{value:``,children:`Any automation`}),n.map(e=>{let t=e.automation_id??e.id??``;return f(`option`,{value:t,children:e.name??t},t)})]})]}),f(`div`,{className:`grid gap-1`,children:[f(`label`,{className:`text-xs text-slate-400`,children:`Artifact type filter`}),f(`input`,{className:`tcp-input text-xs`,placeholder:`e.g. shortlist, brief, report`,value:e.artifact_type??``,onInput:e=>o(t,{artifact_type:e.target.value||null})})]})]})]},t)),r?f(`div`,{className:`flex gap-2`,children:[f(`button`,{type:`button`,className:`tcp-btn flex-1`,onClick:()=>{t([...e,$n()]),i(!1)},children:[f(`i`,{"data-lucide":`zap`}),`Add HandoffAvailable condition`]}),f(`button`,{type:`button`,className:`tcp-btn`,onClick:()=>i(!1),children:f(`i`,{"data-lucide":`x`})})]}):f(`button`,{type:`button`,className:`tcp-btn w-full text-xs`,onClick:()=>i(!0),children:[f(`i`,{"data-lucide":`plus`}),`Add watch condition`]})]})}function tr(e){return(e??[]).join(`
8
+ `)}function nr(e){let t=e.split(`
9
+ `).map(e=>e.trim()).filter(Boolean);return t.length>0?t:null}function rr(e){if(!e)return!0;let{readable_paths:t,writable_paths:n,denied_paths:r,watch_paths:i}=e;return(!t||t.length===0)&&(!n||n.length===0)&&(!r||r.length===0)&&(!i||i.length===0)}function ir({value:e,onChange:t}){let n=rr(e),r=(n,r)=>{let i=nr(r),a={...e??{},[n]:i};rr(a)?t(null):t(a)};return f(`div`,{className:`grid gap-3 rounded-xl border border-slate-700/50 bg-slate-900/30 p-4`,children:[f(`div`,{className:`flex items-center justify-between gap-2`,children:[f(`div`,{children:[f(`div`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:`Scope policy`}),f(`div`,{className:`mt-0.5 text-xs text-slate-500`,children:`Filesystem sandbox for agents in this automation. Empty = fully open.`})]}),!n&&f(`button`,{type:`button`,className:`tcp-btn h-7 px-2 text-xs text-slate-400`,onClick:()=>t(null),title:`Clear all paths (open policy)`,children:[f(`i`,{"data-lucide":`shield-off`}),`Clear`]})]}),n?f(`div`,{className:`rounded-lg border border-dashed border-slate-700/40 p-3 text-center`,children:[f(`div`,{className:`text-xs font-medium text-slate-400`,children:`Open policy — no restrictions`}),f(`div`,{className:`mt-1 text-xs text-slate-500`,children:`Fill in any path list below to restrict agent filesystem access.`})]}):f(`div`,{className:`flex flex-wrap gap-1.5`,children:[(e?.denied_paths??[]).length>0&&f(`span`,{className:`rounded-full border border-red-400/30 bg-red-400/10 px-2 py-0.5 text-xs text-red-400`,children:[e?.denied_paths?.length,` denied`]}),(e?.readable_paths??[]).length>0&&f(`span`,{className:`rounded-full border border-sky-400/30 bg-sky-400/10 px-2 py-0.5 text-xs text-sky-400`,children:[e?.readable_paths?.length,` readable`]}),(e?.writable_paths??[]).length>0&&f(`span`,{className:`rounded-full border border-amber-400/30 bg-amber-400/10 px-2 py-0.5 text-xs text-amber-400`,children:[e?.writable_paths?.length,` writable`]}),(e?.watch_paths??[]).length>0&&f(`span`,{className:`rounded-full border border-violet-400/30 bg-violet-400/10 px-2 py-0.5 text-xs text-violet-400`,children:[e?.watch_paths?.length,` watch`]})]}),f(`div`,{className:`grid gap-3`,children:[f(ar,{label:`Readable paths`,hint:`Agents may read these paths. Empty = all paths readable.`,color:`sky`,value:tr(e?.readable_paths),onChange:e=>r(`readable_paths`,e)}),f(ar,{label:`Writable paths`,hint:`Agents may write to these paths. Must be a subset of readable.`,color:`amber`,value:tr(e?.writable_paths),onChange:e=>r(`writable_paths`,e)}),f(ar,{label:`Denied paths`,hint:`Always blocked, even if listed in readable/writable. Takes priority.`,color:`red`,value:tr(e?.denied_paths),onChange:e=>r(`denied_paths`,e)}),f(ar,{label:`Watch paths`,hint:`Paths the watch evaluator may scan. Defaults to readable_paths if empty.`,color:`violet`,value:tr(e?.watch_paths),onChange:e=>r(`watch_paths`,e)})]})]})}function ar({label:e,hint:t,color:n,value:r,onChange:i}){return f(`div`,{className:`grid gap-1`,children:[f(`label`,{className:`text-xs text-slate-400`,children:e}),f(`textarea`,{className:`tcp-input min-h-[72px] font-mono text-xs leading-5 transition-colors ${n===`sky`?`focus-within:border-sky-400/60`:n===`amber`?`focus-within:border-amber-400/60`:n===`red`?`focus-within:border-red-400/60`:`focus-within:border-violet-400/60`}`,value:r,placeholder:`shared/handoffs/
10
+ job-search/reports/`,onInput:e=>i(e.target.value)}),f(`div`,{className:`text-xs text-slate-600`,children:[t,` One path per line, prefix matching.`]})]})}var or={inbox_dir:`shared/handoffs/inbox`,approved_dir:`shared/handoffs/approved`,archived_dir:`shared/handoffs/archived`,auto_approve:!0};function sr({value:e,onChange:t}){let n={inbox_dir:e?.inbox_dir??or.inbox_dir,approved_dir:e?.approved_dir??or.approved_dir,archived_dir:e?.archived_dir??or.archived_dir,auto_approve:e?.auto_approve??or.auto_approve},r=e=>t({...n,...e});return f(`div`,{className:`grid gap-3 rounded-xl border border-slate-700/50 bg-slate-900/30 p-4`,children:[f(`div`,{className:`flex items-center justify-between gap-2`,children:[f(`div`,{children:[f(`div`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:`Handoff config`}),f(`div`,{className:`mt-0.5 text-xs text-slate-500`,children:`Directory layout for handoff artifacts. Relative to workspace root.`})]}),f(`button`,{type:`button`,className:`tcp-btn h-7 px-2 text-xs text-slate-400`,onClick:()=>t({...or}),title:`Reset to defaults`,children:[f(`i`,{"data-lucide":`rotate-ccw`}),`Reset`]})]}),f(`button`,{type:`button`,className:`tcp-list-item flex h-10 items-center justify-between px-3 text-left text-xs ${n.auto_approve?`border-emerald-400/60 bg-emerald-400/10`:`border-amber-400/60 bg-amber-400/10`}`,role:`switch`,"aria-checked":!!n.auto_approve,onClick:()=>r({auto_approve:!n.auto_approve}),children:[f(`span`,{className:`flex items-center gap-2`,children:[f(`i`,{"data-lucide":n.auto_approve?`zap`:`lock`,className:`h-3.5 w-3.5`}),n.auto_approve?`Auto-approve — handoffs move directly to approved/`:`Manual approval — handoffs wait in inbox/ until reviewed`]}),f(`span`,{className:`relative h-5 w-9 rounded-full transition ${n.auto_approve?`bg-emerald-500/40`:`bg-amber-500/40`}`,children:f(`span`,{className:`absolute left-0.5 top-0.5 h-4 w-4 rounded-full bg-slate-100 transition ${n.auto_approve?`translate-x-4`:``}`})})]}),f(`div`,{className:`grid gap-2`,children:[{key:`inbox_dir`,label:`Inbox directory`,color:`text-amber-400`},{key:`approved_dir`,label:`Approved directory`,color:`text-emerald-400`},{key:`archived_dir`,label:`Archived directory`,color:`text-slate-400`}].map(({key:e,label:t,color:i})=>f(`div`,{className:`grid gap-1`,children:[f(`label`,{className:`text-xs ${i}`,children:t}),f(`input`,{className:`tcp-input font-mono text-xs`,value:n[e]??``,onInput:t=>r({[e]:t.target.value||null}),placeholder:or[e]})]},e))})]})}function cr(e){return e?new Date(e).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}):`—`}function lr({handoff:e,bucket:t}){let[n,r]=a(!1);return f(`div`,{className:`rounded-lg border p-3 ${t===`inbox`?`text-amber-400 border-amber-400/30 bg-amber-400/10`:t===`approved`?`text-emerald-400 border-emerald-400/30 bg-emerald-400/10`:`text-slate-400 border-slate-600/40 bg-slate-800/40`} transition-colors`,children:[f(`button`,{className:`flex w-full items-start justify-between gap-3 text-left`,onClick:()=>r(e=>!e),children:[f(`div`,{className:`min-w-0 flex-1`,children:[f(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f(`code`,{className:`rounded bg-slate-950/50 px-1.5 py-0.5 font-mono text-xs text-slate-200`,children:e.handoff_id}),e.artifact_type&&f(`span`,{className:`rounded border border-current/40 bg-current/10 px-1.5 py-0.5 text-xs font-medium`,children:e.artifact_type})]}),f(`div`,{className:`mt-1 text-xs text-slate-400`,children:[`From `,f(`span`,{className:`font-mono text-slate-300`,children:e.source_automation_id}),` ·`,` `,cr(e.created_at_ms),e.consumed_at_ms&&f(`span`,{className:`ml-2 text-slate-500`,children:[`consumed `,cr(e.consumed_at_ms)]})]})]}),f(`i`,{"data-lucide":n?`chevron-up`:`chevron-down`,className:`mt-0.5 h-4 w-4 shrink-0 opacity-60`})]}),f(m,{children:n&&f(p.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},className:`overflow-hidden`,children:f(`div`,{className:`mt-3 rounded-lg border border-slate-700/40 bg-slate-950/60 p-3 font-mono text-xs text-slate-300`,children:f(`pre`,{className:`max-h-60 overflow-auto whitespace-pre-wrap break-all`,children:JSON.stringify(e,null,2)})})})})]})}var ur=[`inbox`,`approved`,`archived`],dr={inbox:`Inbox`,approved:`Approved`,archived:`Archived`},fr={inbox:`text-amber-400 border-amber-400`,approved:`text-emerald-400 border-emerald-400`,archived:`text-slate-400 border-slate-500`};function pr({automationId:e,client:t}){let[n,r]=a(`approved`),i=c({queryKey:[`automations`,`v2`,e,`handoffs`],enabled:!!e&&!!t?.automationsV2?.listHandoffs,queryFn:()=>t.automationsV2.listHandoffs(e),refetchInterval:15e3}),o=i.data,s=o?.counts??{inbox:0,approved:0,archived:0,total:0},l=o?.[n]??[];return f(`div`,{className:`grid gap-3 rounded-xl border border-slate-700/50 bg-slate-900/30 p-4`,children:[f(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[f(`div`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:`Handoff Inbox`}),i.isLoading&&f(`span`,{className:`text-xs text-slate-500`,children:`Loading…`}),i.isError&&f(`span`,{className:`text-xs text-red-400`,children:`Failed to load handoffs`}),o&&f(`span`,{className:`rounded-full bg-slate-800/60 px-2 py-0.5 text-xs text-slate-400`,children:[s.total,` total`]})]}),f(`div`,{className:`flex gap-1 border-b border-slate-800/60 pb-0`,children:ur.map(e=>f(`button`,{className:`border-b-2 px-3 pb-2 pt-1 text-xs font-medium transition-colors ${n===e?`${fr[e]} border-current`:`border-transparent text-slate-500 hover:text-slate-300`}`,onClick:()=>r(e),children:[dr[e],s[e]>0&&f(`span`,{className:`ml-1.5 rounded-full bg-current/20 px-1.5 py-0.5 text-xs`,children:s[e]})]},e))}),f(`div`,{className:`grid gap-2`,children:i.isPending?f(`div`,{className:`text-xs text-slate-500`,children:`Loading handoffs…`}):l.length===0?f(`div`,{className:`rounded-lg border border-dashed border-slate-700/50 p-4 text-center text-xs text-slate-500`,children:[`No `,dr[n].toLowerCase(),` handoffs for this automation.`]}):l.map(e=>f(lr,{handoff:e,bucket:n},e.handoff_id))}),o?.handoff_config&&f(`div`,{className:`rounded-lg border border-slate-800/50 bg-slate-950/30 p-3`,children:[f(`div`,{className:`mb-2 text-xs uppercase tracking-wide text-slate-600`,children:`Directory config`}),f(`div`,{className:`grid gap-1 font-mono text-xs text-slate-500`,children:[f(`div`,{children:[f(`span`,{className:`text-amber-400/70`,children:`inbox`}),` /`,o.handoff_config.inbox_dir]}),f(`div`,{children:[f(`span`,{className:`text-emerald-400/70`,children:`approved`}),` /`,o.handoff_config.approved_dir]}),f(`div`,{children:[f(`span`,{className:`text-slate-400/70`,children:`archived`}),` /`,o.handoff_config.archived_dir]}),f(`div`,{className:`mt-1`,children:o.handoff_config.auto_approve?f(`span`,{className:`text-emerald-400/70`,children:`⚡ auto-approve enabled`}):f(`span`,{className:`text-amber-400/70`,children:`🔒 manual approval required`})})]})]})]})}var mr=[{value:``,label:`System default`,tooltip:`Uses the tenant default execution profile. If no tenant default is configured, Tandem runs this workflow as Guided.`,accentClass:`bg-sky-300 shadow-[0_0_0_3px_rgba(125,211,252,0.2)]`},{value:`strict`,label:`Strict`,tooltip:`All validators enforced. Use Guided/Lenient during validator hardening to unblock recoverable runs.`,accentClass:`bg-emerald-300 shadow-[0_0_0_3px_rgba(110,231,183,0.18)]`},{value:`guided`,label:`Guided`,tooltip:`Non-critical validation failures become warnings; critical failures (auth, secret access, destructive-action approval, budget caps) still block.`,accentClass:`bg-amber-300 shadow-[0_0_0_3px_rgba(252,211,77,0.18)]`},{value:`yolo`,label:`Lenient`,tooltip:`Non-critical validation failures continue as experimental; spend caps and approvals still enforced. Downstream nodes inherit the experimental flag.`,accentClass:`bg-rose-300 shadow-[0_0_0_3px_rgba(253,164,175,0.18)]`}];function hr(e){return mr.find(t=>t.value===e)||null}function gr({value:e,onChange:t,disabled:n=!1,pendingValue:r=null,clearable:o=!1,className:s=``,size:c=`md`,showGuidance:l=!0}){let[u,d]=a(null),[p,m]=a(null),h=i({}),g=hr(e)?e:``,_=hr(g),v=c===`sm`?16:22,y=c===`sm`?`h-2.5 w-2.5`:`h-3.5 w-3.5`,b=c===`sm`?`h-1.5 w-1.5`:`h-2 w-2`,x=e=>{let t=e||`default`,n=h.current[t];if(n){let e=n.getBoundingClientRect();m({top:e.bottom+8,left:e.left+e.width/2})}d(e)},S=()=>{d(null),m(null)},C=u===null?null:hr(u);return f(`div`,{className:`grid gap-1.5 ${s}`,children:[f(`div`,{className:`flex items-center gap-3`,children:[f(`div`,{role:`radiogroup`,"aria-label":`Execution profile`,className:`relative inline-flex items-center rounded-full border border-sky-500/30 bg-slate-950/80 shadow-[inset_0_0_0_1px_rgba(148,163,184,0.08),0_0_18px_rgba(56,189,248,0.08)] ${c===`sm`?`gap-1 px-1.5 py-1`:`gap-1.5 px-2 py-1.5`}`,children:[f(`span`,{className:`pointer-events-none absolute left-4 right-4 top-1/2 h-px -translate-y-1/2 bg-gradient-to-r from-sky-500/45 via-slate-500/45 to-rose-400/45`}),mr.map(e=>{let i=e.value||`default`,a=g===e.value,o=r===e.value;return f(`button`,{ref:e=>{h.current[i]=e},type:`button`,role:`radio`,"aria-checked":a,"aria-label":e.label,disabled:n,className:`relative z-10 flex items-center justify-center rounded-full border transition focus:outline-none focus:ring-2 focus:ring-sky-400/70 ${a?`border-slate-200/45 bg-slate-800`:`border-slate-600/60 bg-slate-950 hover:border-slate-300/60 hover:bg-slate-800`} ${n?`cursor-not-allowed opacity-60`:`cursor-pointer`}`,style:{width:v,height:v},onMouseEnter:()=>x(e.value),onMouseLeave:S,onFocus:()=>x(e.value),onBlur:S,onClick:()=>{n||t(e.value)},children:f(`span`,{className:`block rounded-full transition ${a?`${y} ${e.accentClass}`:o?`${b} animate-pulse bg-slate-300`:`${b} bg-slate-500 hover:bg-slate-300`}`})},e.value||`default`)})]}),f(`div`,{className:`grid gap-0.5 text-left`,children:[f(`div`,{className:`text-xs font-semibold uppercase tracking-wide text-slate-100`,children:_?_.label:`System default`}),f(`div`,{className:`text-[11px] text-slate-400`,children:_?.value?_.tooltip:`Falls back to tenant default · Guided if none set`})]})]}),o&&e!==``?f(`button`,{type:`button`,className:`w-fit text-[11px] text-slate-400 underline-offset-2 hover:text-slate-200 hover:underline`,disabled:n,onClick:()=>t(``),children:`Use system default`}):null,l?f(`div`,{className:`rounded-md border border-amber-400/20 bg-amber-950/20 px-2.5 py-2 text-[11px] leading-snug text-amber-100/90`,children:[`If workflow runs keep failing on validation or artifact review, try loosening this profile: `,f(`span`,{className:`font-semibold text-amber-100`,children:`Guided`}),` turns recoverable checks into warnings, while `,f(`span`,{className:`font-semibold text-rose-100`,children:`Lenient`}),` `,`is the most permissive experimental mode.`]}):null,C&&p?f(`div`,{role:`tooltip`,className:`pointer-events-none fixed z-[1000] w-64 -translate-x-1/2 rounded-md border border-slate-700/70 bg-slate-950/95 p-2.5 text-[11px] leading-snug text-slate-200 shadow-xl`,style:{top:p.top,left:p.left},children:[f(`div`,{className:`mb-1 font-semibold uppercase tracking-wide text-slate-100`,children:C.label}),C.tooltip]}):null]})}function _r(e){let t=``,n=!1;for(let r of String(e||``).trim())/^[a-z0-9]$/i.test(r)?(t+=r.toLowerCase(),n=!1):n||=(t+=`_`,!0);return t.replace(/^_+|_+$/g,``)||`mcp`}function vr(e){return Array.from(new Set(e.map(e=>String(e||``).trim()).filter(Boolean))).sort()}function yr(e){return Array.isArray(e?.toolCache)?e.toolCache.map(e=>String(e||``).trim()).filter(Boolean):[]}function br(e,t){let n=`mcp.${_r(t)}.`;return String(e||``).startsWith(n)}function xr(e,t){return vr(t.filter(t=>e.some(e=>br(e,t.name))).map(e=>e.name))}function Sr(e,t){let n=new Set(t);return e.filter(e=>n.has(e.name)).flatMap(e=>yr(e))}function Cr(t){let n=i(null);return e(()=>{t&&n.current&&h(n.current)},[t]),n}function wr(e){return String(e||`workflow-automation`).trim().toLowerCase().replace(/[^a-z0-9._-]+/g,`-`).replace(/^-+|-+$/g,``)||`workflow-automation`}function Tr(e){let t=String(e?.automationId||``).trim(),n={exported_at:new Date().toISOString(),export_kind:`tandem_workflow_recovery_bundle`,export_version:1,automation_id:t,name:String(e?.name||t||`Workflow automation`).trim(),description:String(e?.description||``).trim(),recovery_prompt:String(e?.recoveryPrompt||``).trim(),source_automation:e?.sourceAutomation||null,editable_snapshot:{schedule_kind:e?.scheduleKind||``,workspace_root:e?.workspaceRoot||``,execution_mode:e?.executionMode||``,selected_mcp_servers:e?.selectedMcpServers||[],selected_mcp_tools:e?.selectedMcpTools||null,nodes:e?.nodes||[]}},r=new Blob([JSON.stringify(n,null,2)],{type:`application/json;charset=utf-8`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=`${wr(t||e?.name)}-recovery.json`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(i)}function Er(e){let t=String(e||``).toLowerCase();return/\bsend\b/.test(t)||t.includes(`_send`)||t.includes(`send_`)}function Dr({editDraft:e,setEditDraft:t,updateAutomationMutation:n}){let r=Cr(!!e);return e?f(p.div,{ref:r,className:`tcp-confirm-overlay`,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>t(null),children:f(p.div,{className:`tcp-confirm-dialog w-[min(40rem,96vw)]`,initial:{opacity:0,y:8,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:6,scale:.98},onClick:e=>e.stopPropagation(),children:[f(`h3`,{className:`tcp-confirm-title`,children:`Edit automation`}),f(`div`,{className:`grid gap-3`,children:[f(`div`,{className:`grid gap-1`,children:[f(`label`,{className:`text-xs text-slate-400`,children:`Name`}),f(`input`,{className:`tcp-input`,value:e.name,onInput:e=>t(t=>t&&{...t,name:e.target.value})})]}),f(`div`,{className:`grid gap-1`,children:[f(`label`,{className:`text-xs text-slate-400`,children:`Objective`}),f(`textarea`,{className:`tcp-input min-h-[96px]`,value:e.objective,onInput:e=>t(t=>t&&{...t,objective:e.target.value})})]}),f(`div`,{className:`grid gap-1 sm:grid-cols-2 sm:gap-2`,children:[f(`div`,{className:`grid gap-1`,children:[f(`label`,{className:`text-xs text-slate-400`,children:`Mode`}),f(`select`,{className:`tcp-input`,value:e.mode,onInput:e=>t(t=>t&&{...t,mode:e.target.value}),children:[f(`option`,{value:`standalone`,children:`standalone`}),f(`option`,{value:`orchestrated`,children:`orchestrated`})]})]}),f(`div`,{className:`grid gap-1`,children:[f(`label`,{className:`text-xs text-slate-400`,children:`Approval policy`}),f(`button`,{className:`tcp-input flex h-10 items-center justify-between px-3 text-xs ${e.requiresApproval?`border-amber-400/60 bg-amber-400/10`:``}`,role:`switch`,"aria-checked":e.requiresApproval,onClick:()=>t(e=>e&&{...e,requiresApproval:!e.requiresApproval}),children:[f(`span`,{className:`flex items-center gap-2`,children:[f(`i`,{"data-lucide":e.requiresApproval?`shield-alert`:`shield-check`}),e.requiresApproval?`Manual approvals enabled`:`Fully automated enabled`]}),f(`span`,{className:`relative h-5 w-9 rounded-full transition ${e.requiresApproval?`bg-amber-500/40`:`bg-emerald-500/30`}`,children:f(`span`,{className:`absolute left-0.5 top-0.5 h-4 w-4 rounded-full bg-slate-100 transition ${e.requiresApproval?``:`translate-x-4`}`})})]})]})]}),f(`div`,{className:`grid gap-1 sm:grid-cols-2 sm:gap-2`,children:f(`div`,{className:`grid gap-1`,children:[f(`label`,{className:`text-xs text-slate-400`,children:`Schedule type`}),f(`select`,{className:`tcp-input`,value:e.scheduleKind,onInput:e=>t(t=>t&&{...t,scheduleKind:e.target.value}),children:[f(`option`,{value:`interval`,children:`interval`}),f(`option`,{value:`cron`,children:`cron`})]})]})}),e.scheduleKind===`cron`?f(`div`,{className:`grid gap-1`,children:[f(`label`,{className:`text-xs text-slate-400`,children:`Cron expression`}),f(`input`,{className:`tcp-input font-mono`,value:e.cronExpression,onInput:e=>t(t=>t&&{...t,cronExpression:e.target.value}),placeholder:`0 9 * * *`})]}):f(`div`,{className:`grid gap-1`,children:[f(`label`,{className:`text-xs text-slate-400`,children:`Interval seconds`}),f(`input`,{type:`number`,min:`1`,className:`tcp-input`,value:e.intervalSeconds,onInput:e=>t(t=>t&&{...t,intervalSeconds:e.target.value})})]})]}),f(`div`,{className:`tcp-confirm-actions mt-3`,children:[f(`button`,{className:`tcp-btn`,onClick:()=>t(null),children:[f(`i`,{"data-lucide":`x-circle`}),`Cancel`]}),f(`button`,{className:`tcp-btn-primary`,onClick:()=>e&&n.mutate(e),disabled:n.isPending,children:[f(`i`,{"data-lucide":`check`}),`Save`]})]})]})}):null}function Or({title:e,defaultOpen:t=!1,children:n,description:r=``,headerStyle:i=``,icon:o=``}){let[s,c]=a(t);return f(`div`,{className:`rounded-xl border border-slate-700/50 bg-slate-900/30 overflow-hidden ${i===`violet`?`border-violet-500/20 bg-violet-900/5`:``}`,children:[f(`button`,{type:`button`,className:`w-full flex items-center justify-between px-4 py-3 text-left hover:bg-slate-800/40 transition-colors focus:outline-none`,onClick:()=>c(!s),children:[f(`div`,{className:`flex items-center gap-2`,children:[o&&f(`i`,{"data-lucide":o,className:`h-4 w-4 ${i===`violet`?`text-violet-400`:`text-slate-400`}`}),f(`div`,{children:[f(`div`,{className:`text-xs uppercase tracking-wide font-medium ${i===`violet`?`text-violet-300`:`text-slate-500`}`,children:e}),r&&s&&f(`div`,{className:`text-xs mt-0.5 ${i===`violet`?`text-slate-500`:`text-slate-400`}`,children:r})]})]}),f(`i`,{"data-lucide":s?`chevron-up`:`chevron-down`,className:`h-4 w-4 text-slate-500 shrink-0 ml-4`})]}),s&&f(`div`,{className:`px-4 pb-4 border-t ${i===`violet`?`border-violet-900/40`:`border-slate-800/60`} pt-3`,children:f(`div`,{className:`grid gap-3`,children:n})})]})}function kr({workflowEditDraft:e,setWorkflowEditDraft:n,validateWorkspaceRootInput:r,validateModelInput:i,validatePlannerModelInput:a,automationWizardConfig:o,providerOptions:s,mcpServers:c,overlapHistoryEntries:l,runNowV2Mutation:u,updateWorkflowAutomationMutation:d,automationsV2List:m=[],client:h,onRecreateWorkflowAutomation:g}){let _=Cr(!!e);if(!e)return null;let v=o.executionModes.find(t=>t.id===e.executionMode)||o.executionModes[0],y={single:`One focused operator handles the full workflow from start to finish.`,team:`A planner coordinates a small set of specialized agents. This is best when the work has multiple steps but still needs tight sequencing and review.`,swarm:`Tandem fans work out into parallel sub-tasks. Use this when breadth and throughput matter more than one tightly coordinated thread.`};return f(p.div,{ref:_,className:`tcp-confirm-overlay`,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>n(null),children:f(p.div,{className:`tcp-confirm-dialog tcp-workflow-editor-modal`,initial:{opacity:0,y:8,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:6,scale:.98},onClick:e=>e.stopPropagation(),children:[f(`div`,{className:`flex items-start justify-between gap-3 border-b border-slate-800/70 px-4 py-4`,children:[f(`div`,{children:[f(`h3`,{className:`tcp-confirm-title`,children:`Edit workflow automation`}),f(`div`,{className:`mt-1 text-sm text-slate-400`,children:`Update scheduling, model routing, MCP access, and the actual step prompts.`})]}),f(`button`,{className:`tcp-btn h-9 w-9 px-0`,onClick:()=>n(null),children:f(`i`,{"data-lucide":`x`})})]}),f(`div`,{className:`flex flex-1 flex-col gap-4 overflow-y-auto px-4 py-4`,children:f(`div`,{className:`grid content-start gap-4 min-w-0`,children:[f(Or,{title:`General setup`,defaultOpen:!0,children:[f(`div`,{className:`grid gap-1`,children:[f(`label`,{className:`text-xs text-slate-400`,children:`Automation name`}),f(`input`,{className:`tcp-input`,value:e.name,onInput:e=>n(t=>t&&{...t,name:e.target.value})})]}),f(`div`,{className:`grid gap-1`,children:[f(`label`,{className:`text-xs text-slate-400`,children:`Notes / description`}),f(`textarea`,{className:`tcp-input min-h-[120px]`,value:e.description,onInput:e=>n(t=>t&&{...t,description:e.target.value}),placeholder:`Add notes, delivery expectations, or operator guidance.`})]}),f(`div`,{className:`grid gap-1`,children:[f(`label`,{className:`text-xs text-slate-400`,children:`Workspace root`}),f(`input`,{className:`tcp-input ${r(e.workspaceRoot)?`border-red-500/70 text-red-100`:``}`,value:e.workspaceRoot,onInput:e=>n(t=>t&&{...t,workspaceRoot:e.target.value})}),r(e.workspaceRoot)?f(`div`,{className:`text-xs text-red-300`,children:r(e.workspaceRoot)}):null]})]}),f(Or,{title:`Recovery`,description:`Export the compiled workflow and preserved planning metadata, or seed a clean workflow generation from the original prompt.`,icon:`archive`,children:[f(`div`,{className:`rounded-lg border border-slate-800/70 bg-slate-950/30 p-3`,children:[f(`div`,{className:`text-xs uppercase tracking-[0.16em] text-slate-500`,children:`Original prompt`}),String(e.recoveryPrompt||``).trim()?f(`pre`,{className:`mt-2 max-h-36 overflow-auto whitespace-pre-wrap rounded-md border border-slate-800/70 bg-black/20 p-3 text-xs leading-5 text-slate-300`,children:String(e.recoveryPrompt||``).trim()}):f(`div`,{className:`mt-2 text-xs text-amber-200`,children:`No original workflow prompt was found in this automation metadata. Export still includes the compiled automation for manual recovery.`})]}),f(`div`,{className:`flex flex-wrap gap-2`,children:[f(`button`,{type:`button`,className:`tcp-btn h-9 px-3 text-sm`,onClick:()=>Tr(e),children:[f(`i`,{"data-lucide":`download`}),`Export recovery JSON`]}),f(`button`,{type:`button`,className:`tcp-btn h-9 px-3 text-sm`,onClick:()=>g?.({automationId:e.automationId,prompt:e.recoveryPrompt}),disabled:!String(e.recoveryPrompt||``).trim(),children:[f(`i`,{"data-lucide":`refresh-cw`}),`Re-create from prompt`]})]}),f(`div`,{className:`text-xs text-slate-500`,children:`Re-create does not mutate this automation. It opens the current workflow generator with the recovered prompt so upgrades to the compiler/runtime can produce a fresh workflow.`})]}),f(Or,{title:`Execution`,defaultOpen:!0,children:[f(`div`,{className:`grid gap-3`,children:[f(`div`,{className:`grid gap-1`,children:[f(`label`,{className:`text-xs text-slate-400`,children:`Execution profile`}),f(gr,{value:e.executionProfile||``,clearable:!0,onChange:e=>n(t=>t&&{...t,executionProfile:e})}),f(`div`,{className:`text-xs text-slate-500`,children:e.executionProfile===`yolo`?`Non-critical validation failures continue as experimental; spend caps and approvals still enforced.`:e.executionProfile===`guided`?`Non-critical validation failures become warnings; critical failures still block.`:e.executionProfile===`strict`?`All validators enforced.`:`System default is selected. Guided is the fallback when no tenant default is set; use Lenient when recoverable checks are still blocking runs.`})]}),f(`div`,{className:`grid gap-1`,children:[f(`label`,{className:`text-xs text-slate-400`,children:`Schedule`}),f(ye,{value:{scheduleKind:e.scheduleKind,cronExpression:e.cronExpression,intervalSeconds:e.intervalSeconds},timezone:e.timezone,onChange:e=>n(t=>t&&{...t,scheduleKind:e.scheduleKind,cronExpression:e.cronExpression,intervalSeconds:e.intervalSeconds})})]}),f(be,{value:e.timezone,onChange:e=>n(t=>t&&{...t,timezone:e}),hint:`Use the timezone that matches when this workflow should fire.`})]}),f(`div`,{className:`grid gap-2`,children:[f(`label`,{className:`text-xs text-slate-400`,children:`Agent type`}),f(`div`,{className:`grid gap-2`,children:o.executionModes.map(t=>{let r=e.executionMode===t.id;return f(`button`,{type:`button`,className:`tcp-list-item text-left ${r?`border-amber-400/60 bg-amber-400/10`:``}`,onClick:()=>n(e=>e&&{...e,executionMode:t.id}),children:f(`div`,{className:`flex items-start justify-between gap-3`,children:[f(`div`,{className:`flex items-start gap-3`,children:[f(`div`,{className:`text-xl leading-none`,children:t.icon}),f(`div`,{className:`grid gap-1`,children:[f(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f(`span`,{className:`text-sm font-semibold text-slate-100`,children:t.label}),t.id===`team`?f(`span`,{className:`rounded-full border border-amber-400/40 bg-amber-400/10 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.16em] text-amber-200`,children:`Recommended`}):null]}),f(`div`,{className:`text-sm text-slate-300`,children:t.desc}),f(`div`,{className:`text-xs text-slate-500`,children:t.bestFor})]})]}),f(`span`,{className:`mt-1 h-3 w-3 rounded-full border ${r?`border-amber-300 bg-amber-300 shadow-[0_0_0_3px_rgba(251,191,36,0.12)]`:`border-slate-600 bg-transparent`}`,"aria-hidden":`true`})]})},t.id)})}),f(`div`,{className:`rounded-lg border border-slate-800/70 bg-slate-950/30 px-3 py-3 text-xs text-slate-400`,children:[f(`div`,{className:`font-medium uppercase tracking-[0.16em] text-slate-500`,children:`Execution behavior`}),f(`div`,{className:`mt-1 text-sm text-slate-300`,children:v?.label}),f(`div`,{className:`mt-1`,children:y[v?.id||`single`]||y.single})]})]}),f(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[f(`div`,{className:`grid gap-1`,children:[f(`label`,{className:`text-xs text-slate-400`,children:`Execution mode key`}),f(`div`,{className:`tcp-input flex h-10 items-center text-sm text-slate-300`,children:e.executionMode})]}),f(`div`,{className:`grid gap-1`,children:[f(`label`,{className:`text-xs text-slate-400`,children:`Max parallel agents`}),f(`input`,{type:`number`,min:`2`,max:`16`,className:`tcp-input`,value:e.maxParallelAgents,onInput:e=>n(t=>t&&{...t,maxParallelAgents:e.target.value}),disabled:e.executionMode===`single`}),f(`div`,{className:`text-xs text-slate-500`,children:e.executionMode===`single`?`Single Agent ignores this value because it stays on one coordinated thread.`:`Team and swarm runs use this value as the concurrency cap for parallel sub-tasks.`})]})]})]}),f(`div`,{id:`workflow-model-selection`,children:f(Or,{title:`Model Selection`,children:[f(W,{providerLabel:`Model provider`,modelLabel:`Model`,draft:{provider:e.modelProvider,model:e.modelId},providers:s,onChange:e=>n(t=>t&&{...t,modelProvider:e.provider,modelId:e.model}),inheritLabel:`Workspace default`}),i(e.modelProvider,e.modelId)?f(`div`,{className:`text-xs text-red-300`,children:i(e.modelProvider,e.modelId)}):null,f(`div`,{className:`grid gap-2 rounded-lg border border-slate-800/70 bg-slate-950/30 p-3`,children:[f(`div`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:`Planner fallback model`}),f(`div`,{className:`text-xs text-slate-400`,children:`Optional. Leave blank to use the workflow default model for planning and revisions.`}),f(W,{providerLabel:`Planner provider`,modelLabel:`Planner model`,draft:{provider:e.plannerModelProvider,model:e.plannerModelId},providers:s,onChange:e=>n(t=>t&&{...t,plannerModelProvider:e.provider,plannerModelId:e.model}),inheritLabel:`Use workflow model`}),a(e.plannerModelProvider,e.plannerModelId)?f(`div`,{className:`text-xs text-red-300`,children:a(e.plannerModelProvider,e.plannerModelId)}):null]})]})}),f(Or,{title:`Tool Access`,children:[f(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[f(`button`,{type:`button`,className:`tcp-list-item text-left ${e.toolAccessMode===`all`?`border-amber-400/60 bg-amber-400/10`:``}`,onClick:()=>n(e=>e&&{...e,toolAccessMode:`all`}),children:[f(`div`,{className:`font-medium`,children:`All tools`}),f(`div`,{className:`tcp-subtle text-xs`,children:`Grant full built-in tool access to workflow agents.`})]}),f(`button`,{type:`button`,className:`tcp-list-item text-left ${e.toolAccessMode===`custom`?`border-amber-400/60 bg-amber-400/10`:``}`,onClick:()=>n(e=>e&&{...e,toolAccessMode:`custom`}),children:[f(`div`,{className:`font-medium`,children:`Custom allowlist`}),f(`div`,{className:`tcp-subtle text-xs`,children:`Restrict built-in tools manually. MCP tools still follow the selected servers.`})]})]}),e.toolAccessMode===`custom`?f(`div`,{className:`grid gap-1`,children:[f(`label`,{className:`text-xs text-slate-400`,children:`Allowed built-in tools`}),f(`textarea`,{className:`tcp-input min-h-[96px] font-mono text-xs`,value:e.customToolsText,onInput:e=>n(t=>t&&{...t,customToolsText:e.target.value}),placeholder:`read
11
+ write
12
+ edit
13
+ bash
14
+ ls
15
+ glob
16
+ websearch`})]}):f(`div`,{className:`text-xs text-slate-500`,children:`All built-in tools are allowed for this automation.`})]}),f(`div`,{id:`workflow-connector-bindings`,children:f(Or,{title:`Connector bindings`,description:`Edit the connector binding snapshot that the scope inspector reads back. Save will persist the new binding set into the automation metadata. Each binding must include an explicit status (mapped, unresolved_required, or unresolved_optional).`,children:[f(`textarea`,{className:`tcp-input min-h-[220px] font-mono text-xs leading-5`,value:e.connectorBindingsJson,onInput:e=>n(t=>t&&{...t,connectorBindingsJson:e.target.value}),placeholder:`[
17
+ {
18
+ "capability": "github",
19
+ "binding_type": "oauth",
20
+ "binding_id": "github-primary",
21
+ "allowlist_pattern": "github.com/*",
22
+ "status": "mapped"
23
+ },
24
+ {
25
+ "capability": "slack",
26
+ "binding_type": null,
27
+ "binding_id": null,
28
+ "allowlist_pattern": null,
29
+ "status": "unresolved_required"
30
+ }
31
+ ]`}),f(`div`,{className:`text-xs text-slate-500`,children:`Keep this as a JSON array of binding objects with capability, binding_type, binding_id, allowlist_pattern, and an explicit status: mapped, unresolved_required, or unresolved_optional.`})]})}),f(Or,{title:`Shared workflow context`,description:`Bind approved shared workflow contexts here, one context id per line. The ids are validated against this workflow's workspace and kept on the saved automation metadata so later runs can reuse the same approved context.`,children:[f(`textarea`,{className:`tcp-input min-h-[120px] font-mono text-xs leading-5`,value:e.sharedContextPackIdsText,onInput:e=>n(t=>t&&{...t,sharedContextPackIdsText:e.target.value}),placeholder:`context-context-123
32
+ context-context-456`}),f(`div`,{className:`text-xs text-slate-500`,children:`Use the copy context id button in the Shared workflow context panel to paste ids quickly.`})]}),f(Or,{title:`MCP Servers`,children:c.length?f(`div`,{className:`grid gap-3`,children:[f(`div`,{className:`flex flex-wrap gap-2`,children:c.map(t=>{let r=e.selectedMcpServers.includes(t.name);return f(`button`,{className:`tcp-btn h-7 px-2 text-xs ${r?`border-amber-400/60 bg-amber-400/10 text-amber-300`:``}`,onClick:()=>n(e=>{if(!e)return e;let n=`mcp.${_r(t.name)}.`,i=r?e.selectedMcpServers.filter(e=>e!==t.name):[...e.selectedMcpServers,t.name].sort(),a=r&&Array.isArray(e.selectedMcpTools)?e.selectedMcpTools.filter(e=>!String(e||``).startsWith(n)):e.selectedMcpTools;return{...e,selectedMcpServers:i,selectedMcpTools:a}}),children:[t.name,` `,t.connected?`• connected`:`• disconnected`]},t.name)})}),e.selectedMcpServers.length?f(Se,{title:`Workflow MCP tool access`,subtitle:`Leave all discovered tools selected to inherit full access from the chosen MCP servers, or uncheck tools to save an exact MCP allowlist for this workflow.`,discoveredTools:c.filter(t=>e.selectedMcpServers.includes(t.name)).flatMap(e=>Array.isArray(e.toolCache)?e.toolCache:[]),value:e.selectedMcpTools,onChange:e=>n(t=>t&&{...t,selectedMcpTools:e})}):null]}):f(`div`,{className:`text-xs text-slate-400`,children:`No MCP servers configured yet.`})}),f(Or,{title:`Connected agents`,icon:`network`,headerStyle:`violet`,description:`Handoff configuration, watch conditions, and scope policy for agent-to-agent messaging.`,children:[f(sr,{value:e.handoffConfig,onChange:e=>n(t=>t&&{...t,handoffConfig:e})}),f(er,{value:e.watchConditions??[],automations:m,onChange:e=>n(t=>t&&{...t,watchConditions:e})}),f(ir,{value:e.scopePolicy,onChange:e=>n(t=>t&&{...t,scopePolicy:e})}),e.automationId&&h?.automationsV2?.listHandoffs&&f(pr,{automationId:e.automationId,client:h})]}),f(Or,{title:`Scope Inspector`,children:f(Qn,{title:``,planPackage:e.scopeSnapshot,planPackageBundle:e.planPackageBundle,planPackageReplay:e.planPackageReplay,validationReport:e.scopeValidation,runtimeContext:e.runtimeContext,approvedPlanMaterialization:e.approvedPlanMaterialization,overlapHistoryEntries:l,onOpenPromptEditor:()=>{document.getElementById(`workflow-prompt-editor`)?.scrollIntoView({behavior:`smooth`,block:`start`})},onOpenModelRoutingEditor:()=>{document.getElementById(`workflow-model-selection`)?.scrollIntoView({behavior:`smooth`,block:`start`})},onOpenConnectorBindingsEditor:()=>{document.getElementById(`workflow-connector-bindings`)?.scrollIntoView({behavior:`smooth`,block:`start`})},onReplaceSharedContextPack:(e,t)=>{!e||!t||n(n=>n&&{...n,sharedContextPackIdsText:String(n.sharedContextPackIdsText||``).split(/[\n,]/g).map(e=>String(e||``).trim()).filter(Boolean).map(n=>n===e?t:n).filter((e,t,n)=>n.indexOf(e)===t).join(`
33
+ `)})}})}),f(`div`,{id:`workflow-prompt-editor`,children:f(Or,{title:`Prompt Editor`,description:`Edit the actual prompts Tandem sends for each workflow step. These objectives control what every node does at runtime.`,defaultOpen:!1,children:e.nodes.length?f(`div`,{className:`grid gap-3`,children:e.nodes.map((r,a)=>{let o=r.toolAccessMode||`inherit`,l=o===`custom`?r.mcpAllowedTools===null?(r.mcpAllowedServers||[]).map(e=>`mcp.${_r(e)}.*`):[...r.mcpOtherAllowedTools||[],...r.mcpAllowedTools||[]]:e.selectedMcpTools===null?(e.selectedMcpServers||[]).map(e=>`mcp.${_r(e)}.*`):[...e.mcpOtherAllowedTools||[],...e.selectedMcpTools||[]],u=xr(vr([...r.mcpOtherAllowedTools||[],...r.mcpAllowedTools||[]]),c),d=vr([...r.mcpAllowedServers||[],...u]),p=l.some(Er);return f(`div`,{className:`rounded-lg border border-slate-700/60 bg-slate-950/30 p-3`,children:[f(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[f(`strong`,{className:`text-sm text-slate-100`,children:r.nodeId||r.title||`Step ${a+1}`}),r.agentId?f(`span`,{className:`tcp-badge-info`,children:[`agent: `,r.agentId]}):null]}),f(`textarea`,{className:`tcp-input min-h-[180px] text-sm leading-6`,value:r.objective,onInput:e=>n(t=>t&&{...t,nodes:t.nodes.map(t=>t.nodeId===r.nodeId?{...t,objective:e.target.value}:t)}),placeholder:`Describe exactly what this step should do.`}),f(`details`,{className:`mt-3 rounded-lg border border-slate-800/70 bg-slate-950/30 p-3`,children:[f(`summary`,{className:`cursor-pointer list-none`,children:f(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[f(`div`,{className:`inline-flex items-center gap-2 text-xs font-semibold uppercase tracking-wide text-slate-300`,children:[f(`i`,{"data-lucide":`shield-check`}),f(`span`,{children:`Approval override`})]}),f(`div`,{className:`flex flex-wrap gap-2 text-[11px]`,children:f(`span`,{className:r.approvalOverride===`skip`?`tcp-badge-danger`:`tcp-badge-info`,children:r.approvalOverride===`skip`?`skip`:r.approvalOverride===`auto`?`auto`:`default`})})]})}),f(`div`,{className:`mt-3 grid gap-3`,children:[f(`div`,{className:`flex flex-wrap gap-2`,children:[f(`button`,{className:`tcp-btn h-7 px-2 text-xs ${!r.approvalOverride||r.approvalOverride===`default`?`border-amber-400/60 bg-amber-400/10 text-amber-300`:``}`,onClick:()=>n(e=>e&&{...e,nodes:e.nodes.map(e=>e.nodeId===r.nodeId?{...e,approvalOverride:`default`,approvalCondition:``}:e)}),children:`Default`}),f(`button`,{className:`tcp-btn h-7 px-2 text-xs ${r.approvalOverride===`auto`?`border-amber-400/60 bg-amber-400/10 text-amber-300`:``}`,onClick:()=>n(e=>e&&{...e,nodes:e.nodes.map(e=>e.nodeId===r.nodeId?{...e,approvalOverride:`auto`}:e)}),children:`Auto`}),f(`button`,{className:`tcp-btn h-7 px-2 text-xs ${r.approvalOverride===`skip`?`border-red-400/60 bg-red-400/10 text-red-300`:``}`,onClick:()=>{let e=r.title||r.nodeId||`this step`;window.confirm(`Skip approval for ${e}? This can allow external actions to run without review.`)&&n(e=>e&&{...e,nodes:e.nodes.map(e=>e.nodeId===r.nodeId?{...e,approvalOverride:`skip`,approvalCondition:``}:e)})},children:`Skip`})]}),r.approvalOverride===`auto`?f(`div`,{className:`grid gap-1`,children:[f(`label`,{className:`text-xs text-slate-400`,children:`Auto-approve condition`}),f(`input`,{className:`tcp-input font-mono text-xs`,value:r.approvalCondition||``,onInput:e=>n(t=>t&&{...t,nodes:t.nodes.map(t=>t.nodeId===r.nodeId?{...t,approvalCondition:e.target.value}:t)})})]}):null]})]}),f(`details`,{className:`mt-3 rounded-lg border border-slate-800/70 bg-slate-950/30 p-3`,children:[f(`summary`,{className:`cursor-pointer list-none`,children:f(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[f(`div`,{className:`inline-flex items-center gap-2 text-xs font-semibold uppercase tracking-wide text-slate-300`,children:[f(`i`,{"data-lucide":`cpu`}),f(`span`,{children:`Step model & provider`})]}),f(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px]`,children:[r.modelProvider||r.modelId?f(`span`,{className:`tcp-badge-info`,children:`overrides workflow model`}):f(`span`,{className:`tcp-badge-info`,children:`inherits workflow model`}),f(`span`,{className:`text-slate-500`,children:`Expand to change this task's model.`})]})]})}),f(`div`,{className:`mt-3 grid gap-2`,children:[f(W,{providerLabel:`Step model provider`,modelLabel:`Step model`,draft:{provider:r.modelProvider,model:r.modelId},providers:s,onChange:e=>n(t=>t&&{...t,nodes:t.nodes.map(t=>t.nodeId===r.nodeId?{...t,modelProvider:e.provider,modelId:e.model}:t)}),inheritLabel:`Use workflow model`}),i(r.modelProvider,r.modelId)?f(`div`,{className:`text-xs text-red-300`,children:i(r.modelProvider,r.modelId)}):f(`div`,{className:`text-xs text-slate-500`,children:`Leave both fields blank to inherit the workflow model.`})]})]}),f(`details`,{className:`mt-3 rounded-lg border border-slate-800/70 bg-slate-950/30 p-3`,children:[f(`summary`,{className:`cursor-pointer list-none`,children:f(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[f(`div`,{className:`inline-flex items-center gap-2 text-xs font-semibold uppercase tracking-wide text-slate-300`,children:[f(`i`,{"data-lucide":`wrench`}),f(`span`,{children:`Task tool access`})]}),f(`div`,{className:`flex flex-wrap gap-2 text-[11px]`,children:[f(`span`,{className:`tcp-badge-info`,children:o===`custom`?`custom task tools`:`inherits workflow tools`}),f(`span`,{className:p?`tcp-badge-danger`:`tcp-badge-info`,children:p?`send-capable`:`no send tools selected`}),f(`span`,{className:`text-slate-500`,children:`Expand to change tools for this task only.`})]})]})}),f(`div`,{className:`mt-3 grid gap-3`,children:[f(`div`,{className:`flex flex-wrap gap-2`,children:[f(`button`,{className:`tcp-btn h-7 px-2 text-xs ${o===`inherit`?`border-amber-400/60 bg-amber-400/10 text-amber-300`:``}`,onClick:()=>n(e=>e&&{...e,nodes:e.nodes.map(e=>e.nodeId===r.nodeId?{...e,toolAccessMode:`inherit`,toolAllowlist:[],toolDenylist:[],mcpAllowedServers:[],mcpAllowedTools:null,mcpOtherAllowedTools:[]}:e)}),children:`Inherit workflow tools`}),f(`button`,{className:`tcp-btn h-7 px-2 text-xs ${o===`custom`?`border-amber-400/60 bg-amber-400/10 text-amber-300`:``}`,onClick:()=>n(e=>e&&{...e,nodes:e.nodes.map(t=>t.nodeId===r.nodeId?{...t,toolAccessMode:`custom`,toolAllowlist:t.toolAllowlist?.length?t.toolAllowlist:String(e.customToolsText||``).split(/[\n,]/g).map(e=>String(e||``).trim()).filter(Boolean),mcpAllowedServers:t.mcpAllowedServers?.length?t.mcpAllowedServers:e.selectedMcpServers||[],mcpAllowedTools:t.mcpAllowedTools===void 0?e.selectedMcpTools:t.mcpAllowedTools,mcpOtherAllowedTools:t.mcpOtherAllowedTools||e.mcpOtherAllowedTools||[]}:t)}),children:`Customize this task`})]}),o===`custom`?f(t,{children:[f(`div`,{className:`grid gap-1`,children:[f(`label`,{className:`text-xs text-slate-400`,children:`Task tool allowlist`}),f(`textarea`,{className:`tcp-input min-h-[96px] font-mono text-xs`,value:(r.toolAllowlist||[]).join(`
34
+ `),onInput:e=>n(t=>t&&{...t,nodes:t.nodes.map(t=>t.nodeId===r.nodeId?{...t,toolAllowlist:e.target.value.split(/[\n,]/g).map(e=>String(e||``).trim()).filter(Boolean)}:t)})})]}),f(`div`,{className:`grid gap-2`,children:[f(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[f(`label`,{className:`text-xs text-slate-400`,children:`Task MCP servers`}),f(`span`,{className:`text-[11px] text-slate-500`,children:`Select runtime servers to reveal all available task tools.`})]}),c.length?f(`div`,{className:`flex flex-wrap gap-2`,children:c.map(e=>{let t=d.includes(e.name);return f(`button`,{type:`button`,className:`tcp-btn h-7 px-2 text-xs ${t?`border-amber-400/60 bg-amber-400/10 text-amber-300`:``}`,onClick:()=>n(n=>n&&{...n,nodes:n.nodes.map(n=>{if(n.nodeId!==r.nodeId)return n;let i=vr([...n.mcpAllowedServers||[],...xr([...n.mcpOtherAllowedTools||[],...n.mcpAllowedTools||[]],c)]),a=t?i.filter(t=>t!==e.name):vr([...i,e.name]),o=Array.isArray(n.mcpAllowedTools)?n.mcpAllowedTools.filter(n=>!t||!br(n,e.name)):n.mcpAllowedTools;return{...n,mcpAllowedServers:a,mcpAllowedTools:o}})}),children:[e.name,` `,e.connected?`• connected`:`• disconnected`]},e.name)})}):f(`div`,{className:`text-xs text-slate-500`,children:`No MCP servers are currently visible to the runtime.`})]}),f(`div`,{className:`grid gap-1`,children:[f(`label`,{className:`text-xs text-slate-400`,children:`Task tool denylist`}),f(`input`,{className:`tcp-input font-mono text-xs`,value:(r.toolDenylist||[]).join(`, `),onInput:e=>n(t=>t&&{...t,nodes:t.nodes.map(t=>t.nodeId===r.nodeId?{...t,toolDenylist:e.target.value.split(/[\n,]/g).map(e=>String(e||``).trim()).filter(Boolean)}:t)})})]}),f(Se,{title:`Task MCP tool access`,subtitle:`This task-level allowlist overrides the workflow MCP selection for only this step.`,discoveredTools:Sr(c,d),value:r.mcpAllowedTools,onChange:e=>n(t=>t&&{...t,nodes:t.nodes.map(t=>t.nodeId===r.nodeId?{...t,mcpAllowedTools:e}:t)}),collapsible:!0,defaultCollapsed:!0})]}):null]})]})]},r.nodeId||a)})}):f(`div`,{className:`text-xs text-slate-400`,children:`This workflow does not currently expose editable node objectives.`})})})]})}),f(`div`,{className:`tcp-confirm-actions border-t border-slate-800/70 px-4 py-3`,children:[f(`button`,{className:`tcp-btn`,onClick:()=>n(null),children:[f(`i`,{"data-lucide":`x-circle`}),`Cancel`]}),f(`button`,{className:`tcp-btn`,onClick:()=>e&&e.automationId&&u.mutate({id:e.automationId}),disabled:!e?.automationId||u.isPending,children:[f(`i`,{"data-lucide":`play`}),u.isPending?`Starting...`:`Run now`]}),f(`button`,{className:`tcp-btn-primary`,onClick:()=>e&&d.mutate(e),disabled:d.isPending,children:[f(`i`,{"data-lucide":`check`}),d.isPending?`Saving...`:`Save`]})]})]})})}function Ar({deleteConfirm:e,setDeleteConfirm:t,automationActionMutation:n}){let r=Cr(!!e);return e?f(p.div,{ref:r,className:`tcp-confirm-overlay`,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>t(null),children:f(p.div,{className:`tcp-confirm-dialog w-[min(34rem,96vw)]`,initial:{opacity:0,y:8,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:6,scale:.98},onClick:e=>e.stopPropagation(),children:[f(`h3`,{className:`tcp-confirm-title`,children:`Delete automation`}),f(`p`,{className:`tcp-confirm-message`,children:[`This will permanently remove `,f(`strong`,{children:e.title}),`.`]}),f(`div`,{className:`tcp-confirm-actions mt-3`,children:[f(`button`,{className:`tcp-btn`,onClick:()=>t(null),children:[f(`i`,{"data-lucide":`x`}),`Cancel`]}),f(`button`,{className:`tcp-btn-danger`,disabled:n.isPending,onClick:()=>n.mutate({action:`delete`,automationId:e.automationId,family:e.family},{onSettled:()=>t(null)}),children:[f(`i`,{"data-lucide":`trash-2`}),n.isPending?`Deleting...`:`Delete automation`]})]})]})}):null}function jr(){return f(`span`,{"aria-hidden":`true`,className:`inline-block h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent`})}function Mr({selectedBoardTask:e,selectedBoardTaskIsWorkflowNode:n,selectedBoardTaskIsProjectedBacklogItem:r,selectedBoardTaskNodeId:i,selectedBoardTaskStateNormalized:a,selectedBoardTaskImpactSummary:o,selectedBoardTaskResetOutputPaths:s,selectedRunId:c,canTaskContinue:l,canTaskRetry:u,runDebuggerRetryNodeId:d,continueBlockedNodeId:p,selectedBoardTaskServerActionMessage:m,canTaskRequeue:h,canBacklogTaskClaim:g,canBacklogTaskRequeue:_,canRecoverWorkflowRun:v,backlogTaskClaimMutation:y,backlogTaskRequeueMutation:b,workflowTaskContinueMutation:x,workflowTaskRetryMutation:S,workflowTaskRequeueMutation:C,workflowRepairMutation:w,workflowRecoverMutation:T,taskResetPreviewQuery:E}){let D=n&&!!i&&a===`blocked`,O=n&&!!i&&[`blocked`,`failed`].includes(a);return!c||!(D||O||l||u||h||g||_||v)?null:f(`div`,{className:`mt-3 space-y-3`,children:[n?f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2 text-[11px] text-slate-300`,children:[f(`div`,{className:`font-medium text-slate-100`,children:`Action impact`}),f(`div`,{className:`mt-1 tcp-subtle`,children:E.isLoading?`Loading engine preview...`:o.previewBacked?`Engine preview`:`UI-estimated preview`}),f(`div`,{className:`mt-1`,children:[`Selected task: `,o.rootTitle]}),f(`div`,{children:[`Reset scope:`,` `,l?`minimal reset of the blocked task`:`${o.subtreeCount} task${o.subtreeCount===1?``:`s`}${o.descendantCount>0?` (${o.descendantCount} descendant${o.descendantCount===1?``:`s`})`:``}`]}),f(`div`,{children:[`Preserves:`,` `,o.preservesUpstreamOutputs?`completed upstream outputs outside this subtree`:`n/a`]}),f(`div`,{children:[`Clears: stale outputs for `,o.outputCount,` declared artifact`,o.outputCount===1?``:`s`]}),s.length?f(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:s.map(e=>f(`span`,{className:`rounded-full border border-slate-700/70 bg-slate-950/30 px-2 py-1 font-mono text-[11px] text-slate-300`,children:e},e))}):null]}):r?f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2 text-[11px] text-slate-300`,children:[f(`div`,{className:`font-medium text-slate-100`,children:`Action impact`}),f(`div`,{className:`mt-1`,children:`Claiming assigns this backlog task to an agent without resetting any workflow nodes.`}),f(`div`,{children:`Requeueing clears stale lease state and returns the task to the runnable queue.`}),f(`div`,{children:`Upstream workflow artifacts are preserved because this acts on the projected backlog task only.`})]}):null,f(`div`,{className:`flex flex-wrap gap-2`,children:[g?f(`div`,{className:`space-y-1`,children:[f(`button`,{type:`button`,className:`tcp-btn h-8 px-3 text-xs`,onClick:()=>y.mutate({runId:c,taskId:String(e.id||``),agentId:String(e.task_owner||``).trim()||void 0,reason:`claimed backlog task ${String(e.id||``)} from debugger`}),disabled:y.isPending||b.isPending,children:y.isPending?f(t,{children:[f(jr,{}),` Claiming...`]}):`Claim Task`}),f(`div`,{className:`tcp-subtle text-[11px]`,children:`Assign this projected coding task and start its lease.`})]}):null,_?f(`div`,{className:`space-y-1`,children:[f(`button`,{type:`button`,className:`tcp-btn h-8 px-3 text-xs`,onClick:()=>b.mutate({runId:c,taskId:String(e.id||``),reason:`requeued backlog task ${String(e.id||``)} from debugger`}),disabled:y.isPending||b.isPending,children:b.isPending?f(t,{children:[f(jr,{}),` Requeueing...`]}):`Requeue Backlog Task`}),f(`div`,{className:`tcp-subtle text-[11px]`,children:`Use when the task is blocked, failed, or its lease went stale.`})]}):null,D?f(`div`,{className:`space-y-1`,children:[f(`button`,{type:`button`,className:`tcp-btn h-8 px-3 text-xs`,onClick:()=>x.mutate({runId:c,nodeId:p,reason:`continued blocked task ${p} from debugger`}),title:l?``:m,disabled:!l||x.isPending||S.isPending||C.isPending||y.isPending||b.isPending,children:x.isPending?f(t,{children:[f(jr,{}),` Continuing...`]}):`Continue Task`}),f(`div`,{className:`tcp-subtle text-[11px]`,children:l?`Minimal reset: reruns the blocked task itself and preserves descendants unless they need to rerun later.`:m})]}):null,O?f(`div`,{className:`space-y-1`,children:[f(`button`,{type:`button`,className:`tcp-btn h-8 px-3 text-xs`,onClick:()=>S.mutate({runId:c,nodeId:d,reason:`retried task ${d} from debugger`}),title:u?``:m,disabled:!u||x.isPending||S.isPending||C.isPending||y.isPending||b.isPending,children:S.isPending?f(t,{children:[f(jr,{}),` Retrying task...`]}):`Retry Task`}),f(`div`,{className:`tcp-subtle text-[11px]`,children:u?`Best for blocked or failed work that should rerun from this task downward.`:m})]}):null,h?f(`div`,{className:`space-y-1`,children:[f(`button`,{type:`button`,className:`tcp-btn h-8 px-3 text-xs`,onClick:()=>C.mutate({runId:c,nodeId:i,reason:`requeued task ${i} from debugger`}),disabled:x.isPending||S.isPending||C.isPending||y.isPending||b.isPending,children:C.isPending?f(t,{children:[f(jr,{}),` Requeueing...`]}):`Requeue Task`}),f(`div`,{className:`tcp-subtle text-[11px]`,children:`Use when this task should go back onto the queue with its descendants reset.`})]}):null,l&&a===`blocked`&&p?f(`div`,{className:`space-y-1`,children:[f(`button`,{type:`button`,className:`tcp-btn h-8 px-3 text-xs`,onClick:()=>w.mutate({runId:c,nodeId:p,reason:`continued from blocked node ${p}`}),disabled:x.isPending||w.isPending||!p,children:w.isPending?f(t,{children:[f(jr,{}),` Repairing...`]}):`Repair Blocked Step`}),f(`div`,{className:`tcp-subtle text-[11px]`,children:`Heavier reset/repair flow for blocked nodes when minimal continue is not enough.`})]}):null,v?f(`div`,{className:`space-y-1`,children:[f(`button`,{type:`button`,className:`tcp-btn h-8 px-3 text-xs`,onClick:()=>T.mutate({runId:c,reason:`retried from task ${String(e.id||``).replace(/^node-/,``)}`}),disabled:T.isPending,children:T.isPending?f(t,{children:[f(jr,{}),` Retrying...`]}):`Retry Workflow`}),f(`div`,{className:`tcp-subtle text-[11px]`,children:`Recover the whole run, not just this task subtree.`})]}):null]})]})}var Nr={strict:`tcp-badge-info`,guided:`tcp-badge-success`,yolo:`tcp-badge-warning`};function Pr(e){let t=String(e||``).trim().toLowerCase();return t===`yolo`||t===`guided`?t:`strict`}function Fr({profile:e,requested:t,className:n}){let r=Pr(e),i=t?Pr(t):null,a=[`tcp-badge`,Nr[r],n].filter(Boolean).join(` `),o=Ie(r);return f(`span`,{className:a,title:`${Le(r)}${i&&i!==r?` (requested ${Ie(i)})`:``}`,children:o})}function Ir({validation:e,className:t}){if(!K(e))return null;let n=Be(e),r=[`${Ie(String(e?.execution_profile||e?.executionProfile||``).toLowerCase())} run accepted this artifact under relaxed validation.`];n.length>0&&r.push(`Relaxed: ${n.map(e=>e.detail?`${e.class}: ${e.detail}`:e.class).join(`; `)}`);let i=String(e?.original_validator_outcome||e?.originalValidatorOutcome||``),a=String(e?.effective_outcome||e?.effectiveOutcome||``);return i&&a&&r.push(`Original ${i} → effective ${a}.`),f(`span`,{className:[`tcp-badge`,`tcp-badge-warning`,t].filter(Boolean).join(` `),title:r.join(` `),children:`Experimental`})}function Lr({validation:e,className:t}){let n=Be(e);if(n.length===0)return null;let r=String(e?.original_validator_outcome||e?.originalValidatorOutcome||``),i=String(e?.effective_outcome||e?.effectiveOutcome||``);return f(`div`,{className:[`tcp-relaxation-summary`,t].filter(Boolean).join(` `),children:[r&&i?f(`div`,{className:`tcp-text-muted`,children:[`Validator outcome: `,f(`strong`,{children:r}),` → `,f(`strong`,{children:i})]}):null,f(`ul`,{className:`tcp-list-tight`,children:n.map((e,t)=>f(`li`,{children:[f(`code`,{children:e.class}),e.detail?f(`span`,{className:`tcp-text-muted`,children:[`: `,e.detail]}):null]},`${e.class}-${t}`))})]})}function Rr(e){if(!e||typeof e!=`object`)return null;let t=e;return t.artifact_validation||t.artifactValidation||(t.validation&&typeof t.validation==`object`?t.validation:null)||null}function zr({artifactCount:e,artifactEntries:t,selectedArtifactKey:n,isWorkflowRun:r,onToggleArtifact:i,onOpenPath:a}){return f(`div`,{className:`tcp-list-item overflow-visible`,children:[f(`div`,{className:`font-medium`,children:[`Artifacts (`,e,`)`]}),e?f(`div`,{className:`mt-2 grid gap-2 overflow-auto pr-1 sm:max-h-40`,children:t.map(e=>f(`details`,{open:n===e.key?!0:void 0,className:n===e.key?`rounded-lg border border-sky-500/40 bg-sky-950/10 p-2`:`rounded-lg border border-slate-700/40 bg-slate-900/25 p-2`,children:[f(`summary`,{className:`cursor-pointer list-none`,onClick:()=>i(e.key),children:f(`div`,{className:`flex items-center justify-between gap-2`,children:[f(`span`,{className:`text-xs font-medium text-slate-200`,children:e.name}),f(`span`,{className:`flex items-center gap-1 text-[11px]`,children:[f(Ir,{validation:Rr(e.artifact)}),f(`span`,{className:`tcp-subtle`,children:e.kind||`artifact`})]})]})}),e.paths.length?f(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:e.paths.map(e=>f(`button`,{type:`button`,className:`rounded-full border border-slate-700/70 bg-slate-950/30 px-2 py-1 font-mono text-[11px] text-slate-300 ${we(e)&&a?`cursor-pointer hover:border-sky-500/40 hover:text-sky-100`:`cursor-default`}`.trim(),onClick:()=>{let t=we(e);!t||!a||a(t)},disabled:!we(e)||!a,children:e},e))}):null,f(Ce,{value:e.artifact,open:n===e.key,className:`tcp-code mt-2 max-h-32 overflow-auto text-[11px]`})]},e.key))}):f(`div`,{className:`tcp-subtle mt-2 text-xs`,children:r?`No blackboard artifacts have been recorded for this workflow run yet.`:`No run artifacts were persisted for this automation.`})]})}function Br({blockers:e}){return e.length?f(`div`,{className:`tcp-list-item overflow-visible`,children:[f(`div`,{className:`mb-2 font-medium`,children:`Blockers`}),f(`div`,{className:`grid gap-2`,children:e.map(e=>f(`div`,{className:`rounded-lg border border-emerald-500/30 bg-emerald-950/20 p-3`,children:[f(`div`,{className:`mb-1 flex flex-wrap items-center gap-2`,children:[f(`strong`,{children:e.title}),f(`span`,{className:`border border-emerald-400/60 bg-emerald-400/10 text-emerald-200 tcp-badge`,children:e.source}),e.at?f(`span`,{className:`tcp-subtle text-[11px]`,children:new Date(e.at).toLocaleTimeString()}):null]}),f(`div`,{className:`whitespace-pre-wrap break-words text-sm text-emerald-100/90`,children:e.reason})]},e.key))})]}):null}function Vr({runHints:e}){return e.length?f(`div`,{className:`tcp-list-item overflow-visible`,children:[f(`div`,{className:`mb-1 font-medium`,children:`Debug hints`}),f(`div`,{className:`grid gap-1 text-xs text-slate-300`,children:e.map(e=>f(`div`,{children:e},e))})]}):null}function Hr({selectedSessionId:e,selectedSessionFilterId:t,availableSessionIds:n,sessionLogEntries:r,sessionLogRef:a,compactIdentifier:o,sessionLabel:s,onSessionFilterChange:c,onCopySessionLog:l,onJumpToLatest:u,onPinnedStateChange:d}){let p=i(0);return f(`div`,{className:`tcp-list-item min-h-0 xl:order-2`,children:[f(`div`,{className:`mb-2 flex flex-wrap items-center justify-between gap-2`,children:[f(`div`,{children:[f(`div`,{className:`font-medium`,children:`Live Session Log`}),f(`div`,{className:`tcp-subtle text-xs`,children:e?t===`all`?`Merged timeline across ${n.length||1} session${n.length===1?``:`s`}`:`Filtered to ${t}`:`This run does not expose a session transcript.`})]}),f(`div`,{className:`flex flex-wrap gap-2`,children:[n.length>1?f(`select`,{className:`tcp-select h-7 min-w-[12rem] max-w-full shrink-0 text-xs sm:min-w-[14rem]`,value:t,onInput:e=>c(e.target.value),children:[f(`option`,{value:`all`,children:`All sessions`}),n.map(e=>f(`option`,{value:e,title:e,children:s(e)},e))]}):e?f(`span`,{className:`tcp-badge-info`,title:e,children:s(e)}):null,e?f(`span`,{className:`tcp-badge-info`,title:e,children:[`live: `,o(e,24)]}):null,f(`button`,{className:`tcp-btn h-7 px-2 text-xs`,disabled:!r.length,onClick:l,children:[f(`i`,{"data-lucide":`copy`}),`Copy session log`]}),f(`button`,{className:`tcp-btn h-7 px-2 text-xs`,onClick:u,children:[f(`i`,{"data-lucide":`arrow-down`}),`Jump to latest`]})]})]}),f(`div`,{ref:a,className:`grid min-h-[12rem] gap-2 overflow-auto overscroll-contain pr-1 sm:min-h-[14rem] sm:max-h-[18rem]`,tabIndex:0,"aria-label":`Live session log`,onWheel:e=>{e.deltaY<0&&d(!1)},onKeyDown:e=>{[`ArrowUp`,`PageUp`,`Home`].includes(e.key)&&d(!1)},onScroll:e=>{let t=e.currentTarget,n=t.scrollHeight-(t.scrollTop+t.clientHeight),r=t.scrollTop<p.current;p.current=t.scrollTop,d(!r&&n<48)},children:r.length?r.map(e=>f(`div`,{className:`rounded-lg border p-3 ${e.variant===`assistant`?`border-sky-500/30 bg-sky-950/10`:e.variant===`user`?`border-slate-600/60 bg-slate-900/35`:e.variant===`error`?`border-rose-500/35 bg-rose-950/20`:`border-slate-700/50 bg-slate-900/25`}`,children:[f(`div`,{className:`mb-1 flex flex-wrap items-center justify-between gap-2`,children:[f(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f(`span`,{className:`text-xs font-medium uppercase tracking-wide text-slate-200`,children:e.label}),e.sessionId?f(`span`,{className:`tcp-badge-info text-[10px]`,children:e.sessionLabel}):null]}),f(`span`,{className:`tcp-subtle text-[11px]`,children:new Date(e.at).toLocaleTimeString()})]}),e.body?f(`div`,{className:`whitespace-pre-wrap break-words text-sm text-slate-100`,children:e.body}):f(`div`,{className:`tcp-subtle text-xs`,children:`No textual body.`}),e.kind===`message`&&e.parts.some(e=>String(e?.type||``)===`tool`)?f(G,{value:e.parts,label:`Tool payloads`,className:`mt-2`,preClassName:`tcp-code mt-2 max-h-40 overflow-auto text-[11px]`}):null,e.kind===`event`?f(G,{value:e.raw,label:`Raw event`,className:`mt-2`,preClassName:`tcp-code mt-2 max-h-40 overflow-auto text-[11px]`}):null]},e.id)):f(`div`,{className:`tcp-subtle text-xs`,children:n.length?`Waiting for session transcript or live session events.`:`This run does not expose a session transcript.`})})]})}function Ur({objective:e}){return f(`div`,{className:`tcp-list-item overflow-visible`,children:[f(`div`,{className:`font-medium`,children:`Mission Objective`}),f(`pre`,{className:`tcp-code mt-2 max-h-40 overflow-auto whitespace-pre-wrap break-words`,children:e})]})}function Wr({runRepairGuidanceEntries:e,blockedNodeIds:t,needsRepairNodeIds:n,isWorkflowRun:r,selectedRunId:i,hasActiveSessions:a,onFocusNode:o,workflowTaskRetryMutation:s,workflowTaskContinueMutation:c,workflowTaskRequeueMutation:l}){let u=Array.isArray(t)?t:[],d=Array.isArray(n)?n:[],p=e.filter(({nodeId:e,guidance:t})=>{let n=String(t?.status||``).trim().toLowerCase();return u.includes(e)&&[`blocked`,`needs_repair`].includes(n)});return p.length?f(`div`,{className:`tcp-list-item overflow-visible`,children:[f(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[f(`div`,{className:`font-medium`,children:`Next Required Actions`}),f(`span`,{className:`border border-emerald-400/60 bg-emerald-400/10 text-emerald-200 tcp-badge`,children:[p.length,` node`,p.length===1?``:`s`]})]}),f(`div`,{className:`grid gap-2`,children:p.map(({nodeId:e,guidance:t})=>{let n=Array.isArray(t?.requiredNextToolActions)?t.requiredNextToolActions:[],p=Array.isArray(t?.unmetRequirements)?t.unmetRequirements:[],m=String(t?.reason||``).trim(),h=String(t?.blockingClassification||``).trim(),g=String(t?.failureKind||``).trim(),_=String(t?.status||``).trim(),v=_.toLowerCase(),y=r&&!!i&&!a&&(u.includes(e)||d.includes(e)||v===`failed`),b=r&&!!i&&!a&&u.includes(e)&&[`blocked`,`needs_repair`].includes(v);return f(`div`,{className:`rounded-lg border border-emerald-500/30 bg-emerald-950/20 p-3`,children:[f(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[f(`strong`,{children:e}),_?f(`span`,{className:`border border-emerald-400/60 bg-emerald-400/10 text-emerald-200 tcp-badge`,children:_}):null,h?f(`span`,{className:`tcp-subtle text-[11px]`,children:h.replace(/_/g,` `)}):null,t?.repairAttemptsRemaining!==null&&t?.repairAttemptsRemaining!==void 0?f(`span`,{className:`tcp-subtle text-[11px]`,children:[String(t.repairAttemptsRemaining),` repair attempt`,Number(t.repairAttemptsRemaining)===1?``:`s`,` left`]}):null]}),f(`div`,{className:`mb-2 flex flex-wrap gap-2`,children:[f(`button`,{type:`button`,className:`tcp-btn h-7 px-2 text-xs`,onClick:()=>o(e),children:`Focus`}),y?f(`button`,{type:`button`,className:`tcp-btn h-7 px-2 text-xs`,onClick:()=>s.mutate({runId:i,nodeId:e,reason:`retried task ${e} from repair guidance`}),disabled:s.isPending||c.isPending||l.isPending,children:s.isPending?`Retrying...`:`Retry`}):null,b?f(`button`,{type:`button`,className:`tcp-btn h-7 px-2 text-xs`,onClick:()=>c.mutate({runId:i,nodeId:e,reason:`continued task ${e} from repair guidance`}),disabled:s.isPending||c.isPending||l.isPending,children:c.isPending?`Continuing...`:`Continue`}):null]}),m?f(`div`,{className:`mb-2 whitespace-pre-wrap break-words text-sm text-emerald-100/90`,children:m}):null,n.length?f(`div`,{className:`grid gap-1`,children:n.map((t,n)=>f(`div`,{className:`rounded-md border border-emerald-400/20 bg-black/20 px-2 py-1 text-xs text-emerald-50`,children:String(t||``)},`${e}-action-${n}`))}):null,!n.length&&p.length?f(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:p.map(t=>f(`span`,{className:`rounded-full border border-emerald-400/25 bg-black/20 px-2 py-1 text-[11px] text-emerald-100/90`,children:String(t||``).replace(/_/g,` `)},`${e}-${String(t)}`))}):null,g?f(`div`,{className:`tcp-subtle mt-2 text-[11px]`,children:[`failure kind: `,g]}):null]},e)})})]}):null}function Gr({item:e,formatTimestampLabel:t}){let[n,r]=a(!1);return f(`details`,{className:`rounded-lg border border-slate-700/40 bg-slate-900/30 p-2`,onToggle:e=>r(e.currentTarget.open),children:[f(`summary`,{className:`cursor-pointer list-none`,children:[f(`div`,{className:`flex items-center justify-between gap-2`,children:[f(`span`,{className:`text-xs font-medium text-slate-200`,children:e.label}),f(`span`,{className:`tcp-subtle text-[11px]`,children:[t(e.at),` · `,e.source]})]}),f(`div`,{className:`tcp-subtle mt-1 text-xs`,children:e.detail})]}),f(Ce,{value:e.raw,open:n,className:`tcp-code mt-2 max-h-40 overflow-auto text-[11px]`})]})}function Kr({selectedLogSource:e,telemetryEvents:t,isWorkflowRun:n,filteredRunEventEntries:r,formatTimestampLabel:i,onSelectLogSource:a}){return f(`div`,{className:`tcp-list-item min-h-0 xl:order-3`,children:[f(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[f(`div`,{className:`font-medium`,children:`Run Telemetry`}),f(`div`,{className:`flex w-full flex-wrap gap-1 sm:w-auto`,children:[f(`button`,{className:`tcp-btn h-7 flex-1 px-2 text-[11px] sm:flex-none ${e===`all`?`border-amber-400/60 bg-amber-400/10 text-amber-300`:``}`,onClick:()=>a(`all`),children:[`all (`,t.length,`)`]}),f(`button`,{className:`tcp-btn h-7 flex-1 px-2 text-[11px] sm:flex-none ${e===`automations`?`border-amber-400/60 bg-amber-400/10 text-amber-300`:``}`,onClick:()=>a(`automations`),children:`automations`}),n?f(`button`,{className:`tcp-btn h-7 flex-1 px-2 text-[11px] sm:flex-none ${e===`context`?`border-amber-400/60 bg-amber-400/10 text-amber-300`:``}`,onClick:()=>a(`context`),children:`context`}):null,f(`button`,{className:`tcp-btn h-7 flex-1 px-2 text-[11px] sm:flex-none ${e===`global`?`border-amber-400/60 bg-amber-400/10 text-amber-300`:``}`,onClick:()=>a(`global`),children:`global`})]})]}),r.length?f(`div`,{className:`grid gap-2 overflow-auto pr-1 sm:max-h-[12rem]`,children:r.slice(-40).reverse().map(e=>f(Gr,{item:e,formatTimestampLabel:i},e.id))}):f(`div`,{className:`tcp-subtle text-xs`,children:`No telemetry entries captured yet.`})]})}function qr({runSummaryRows:e}){return f(`div`,{className:`tcp-list-item overflow-visible`,children:[f(`div`,{className:`font-medium`,children:`Run Summary`}),f(`div`,{className:`mt-2 grid gap-2 text-xs text-slate-300 sm:grid-cols-2 xl:grid-cols-4`,children:e.map(e=>f(`div`,{className:`break-words`,children:[e.label,`: `,e.value]},e.label))})]})}function Jr({entry:e,index:t}){let[n,r]=a(!1);return f(`details`,{className:`rounded-md border border-slate-700/60 bg-slate-950/20 px-2 py-1.5`,onToggle:e=>r(e.currentTarget.open),children:[f(`summary`,{className:`cursor-pointer list-none`,children:[f(`div`,{className:`flex items-center justify-between gap-2`,children:[f(`span`,{className:`text-[11px] font-medium text-slate-200`,children:String(e?.eventType||e?.event_type||e?.receiptKind||`receipt`)}),f(`span`,{className:`tcp-subtle text-[10px]`,children:[`seq `,String(e?.seq||t+1)]})]}),f(`div`,{className:`tcp-subtle mt-0.5 text-[11px]`,children:String(e?.detail||e?.summary||``).trim()||`No summary available.`})]}),f(Ce,{value:e?.raw||e,open:n,className:`tcp-code mt-2 max-h-32 overflow-auto text-[10px]`})]})}function Yr({selectedBoardTask:e,selectedBoardTaskTelemetry:n,selectedBoardTaskArtifactValidation:r,selectedBoardTaskTouchedFiles:i,selectedBoardTaskUndeclaredFiles:a,selectedBoardTaskRequestedQualityMode:o,selectedBoardTaskEmergencyRollbackEnabled:s,selectedBoardTaskBlockerCategory:c,selectedBoardTaskValidationBasis:l,selectedBoardTaskReceiptTimeline:u,onOpenPath:d}){return f(t,{children:[r||n||i.length||a.length?f(`div`,{className:`rounded-lg border border-slate-700/60 bg-slate-950/20 p-3 text-xs text-slate-300`,children:[f(`div`,{className:`font-medium text-slate-200`,children:`Coding Signals`}),f(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:[f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle`,children:`execution mode`}),f(`div`,{className:`mt-1 font-medium text-slate-100`,children:String(r?.execution_policy?.mode||``).trim()||`n/a`})]}),f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle`,children:`git diff`}),f(`div`,{className:`mt-1 font-medium text-slate-100`,children:String(r?.git_diff_summary?.stat||``).trim()||`n/a`})]}),f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle`,children:`workspace inspection`}),f(`div`,{className:`mt-1 font-medium text-slate-100`,children:n?.workspace_inspection_used?`yes`:`no`})]}),f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle`,children:`web research`}),f(`div`,{className:`mt-1 font-medium text-slate-100`,children:n?.web_research_used?`yes`:`no`})]})]}),f(`div`,{className:`mt-3 space-y-2`,children:[f(`div`,{children:[f(`div`,{className:`tcp-subtle mb-1`,children:`touched files`}),i.length?f(`div`,{className:`flex flex-wrap gap-1`,children:i.map(e=>f(`button`,{type:`button`,className:`rounded-full border border-slate-700/70 bg-slate-950/30 px-2 py-1 font-mono text-[11px] text-slate-300 ${we(e)&&d?`cursor-pointer hover:border-sky-500/40 hover:text-sky-100`:`cursor-default`}`.trim(),onClick:()=>{let t=we(e);!t||!d||d(t)},disabled:!we(e)||!d,children:e},e))}):f(`div`,{className:`tcp-subtle`,children:`none`})]}),f(`div`,{children:[f(`div`,{className:`tcp-subtle mb-1`,children:`undeclared files`}),a.length?f(`div`,{className:`flex flex-wrap gap-1`,children:a.map(e=>f(`span`,{className:`rounded-full border border-amber-500/30 bg-amber-950/20 px-2 py-1 font-mono text-[11px] text-amber-100`,children:e},e))}):f(`div`,{className:`tcp-subtle`,children:`none`})]})]})]}):null,String(e?.state||``).toLowerCase()===`blocked`?f(`div`,{className:`rounded-lg border border-slate-700/60 bg-slate-950/30 p-3 text-xs text-slate-300`,children:`Continue resets this blocked step and its descendants, preserves valid upstream outputs, and clears stale descendant artifacts before requeue.`}):null,n?f(`div`,{className:`rounded-lg border border-slate-700/60 bg-slate-950/30 p-3 text-xs text-slate-300`,children:[f(`div`,{className:`mb-2 font-medium text-slate-100`,children:`Node Tooling`}),f(`div`,{className:`grid gap-1`,children:[f(`div`,{children:[`offered:`,` `,Array.isArray(n?.requested_tools)&&n.requested_tools.join(`, `)||`n/a`]}),f(`div`,{children:[`executed:`,` `,Array.isArray(n?.executed_tools)&&n.executed_tools.join(`, `)||`none`]}),f(`div`,{children:[`workspace inspection:`,` `,n?.workspace_inspection_used?`yes`:`no`]}),f(`div`,{children:[`web research: `,n?.web_research_used?`yes`:`no`]})]})]}):null,r?f(`div`,{className:`rounded-lg border border-slate-700/60 bg-slate-950/30 p-3 text-xs text-slate-300`,children:[f(`div`,{className:`mb-2 font-medium text-slate-100`,children:`Artifact Validation`}),f(`div`,{className:`grid gap-1`,children:[f(`div`,{children:[`accepted path:`,` `,String(r?.accepted_artifact_path||``).trim()||`n/a`,we(String(r?.accepted_artifact_path||``))&&d?f(`button`,{type:`button`,className:`ml-2 rounded-md border border-sky-500/30 bg-sky-950/20 px-2 py-0.5 text-[10px] text-sky-100`,onClick:()=>d(we(String(r?.accepted_artifact_path||``))),children:`Open in Files`}):null]}),f(`div`,{children:[`rejected reason:`,` `,String(r?.rejected_artifact_reason||``).trim()||`none`]}),f(`div`,{children:[`auto-cleaned: `,String(!!r?.auto_cleaned)]}),f(`div`,{children:[`undeclared files:`,` `,a.length?a.join(`, `):`none`]}),f(`div`,{children:[`execution policy:`,` `,String(r?.execution_policy?.mode||``).trim()||`n/a`]}),f(`div`,{children:[`blocker category: `,c||`none`]}),f(`div`,{children:[`validation basis:`,` `,l?String(l?.authority||l?.mode||l?.status||``).trim()||`present`:`none`]}),f(`div`,{children:[`touched files:`,` `,i.length?i.join(`, `):`none`]}),f(`div`,{children:[`git diff:`,` `,String(r?.git_diff_summary?.stat||``).trim()||`n/a`]})]}),f(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[f(`div`,{className:`rounded-md border border-slate-700/60 bg-black/10 p-2`,children:[f(`div`,{className:`tcp-subtle`,children:`requested quality mode`}),f(`div`,{className:`mt-1 font-medium text-slate-100`,children:o||`none`})]}),f(`div`,{className:`rounded-md border border-slate-700/60 bg-black/10 p-2`,children:[f(`div`,{className:`tcp-subtle`,children:`emergency rollback`}),f(`div`,{className:`mt-1 font-medium text-slate-100`,children:s===null?`n/a`:s?`enabled`:`disabled`})]})]}),l?f(G,{value:l,label:`Validation basis`,className:`mt-2 rounded-md border border-slate-700/60 bg-black/10 p-2`,preClassName:`tcp-code mt-2 max-h-40 overflow-auto text-[11px]`}):null,f(`div`,{className:`mt-3`,children:[f(`div`,{className:`tcp-subtle mb-1`,children:`receipt timeline`}),u.length?f(`div`,{className:`grid max-h-56 gap-1 overflow-auto pr-1`,children:u.slice(-12).map((e,t)=>f(Jr,{entry:e,index:t},`${String(e?.seq||t)}:${String(e?.eventType||e?.event_type||`receipt`)}`))}):f(`div`,{className:`tcp-subtle text-xs`,children:`none`})]})]}):null]})}function Xr({event:e,index:t,formatTimestampLabel:n}){let[r,i]=a(!1);return f(`details`,{className:`rounded-lg border border-slate-700/40 bg-slate-900/25 p-2`,onToggle:e=>i(e.currentTarget.open),children:[f(`summary`,{className:`cursor-pointer list-none`,children:[f(`div`,{className:`flex items-center justify-between gap-2`,children:[f(`span`,{className:`text-xs font-medium text-slate-200`,children:String(e?.type||e?.event||e?.status||`history`)}),f(`span`,{className:`tcp-subtle text-[11px]`,children:n(e?.ts_ms||e?.tsMs||e?.at||e?.timestamp_ms)})]}),f(`div`,{className:`tcp-subtle mt-1 text-xs`,children:String(e?.detail||e?.reason||e?.family||e?.status||`No summary available.`)})]}),f(Ce,{value:e,open:r,className:`tcp-code mt-2 max-h-32 overflow-auto text-[11px]`})]},`${String(e?.id||e?.event||e?.type||`history`)}-${t}`)}function Zr({state:e,actions:t,helpers:n}){let{selectedRunId:r,selectedRun:i,isWorkflowRun:a,runStatus:o,runStatusDerivedNote:s,canContinueBlockedWorkflow:c,continueBlockedNodeId:l,canRecoverWorkflowRun:u,runDebuggerRetryNodeId:d,serverBlockedNodeIds:m,serverNeedsRepairNodeIds:h,selectedContextRunId:g,runSummaryRows:_,workflowProjection:v,runArtifacts:y,selectedBoardTaskId:b,selectedBoardTask:x,boardDetailRef:S,selectedBoardTaskOutput:C,selectedBoardTaskValidationOutcome:w,selectedBoardTaskWarningCount:T,selectedBoardTaskTelemetry:E,selectedBoardTaskArtifactValidation:D,selectedBoardTaskIsWorkflowNode:O,selectedBoardTaskIsProjectedBacklogItem:ee,selectedBoardTaskWorkflowClass:te,selectedBoardTaskPhase:k,selectedBoardTaskFailureKind:ne,selectedBoardTaskQualityMode:A,selectedBoardTaskEmergencyRollbackEnabled:j,selectedBoardTaskBlockerCategory:re,selectedBoardTaskValidationBasis:M,selectedBoardTaskReceiptLedger:N,selectedBoardTaskArtifactCandidates:P,selectedBoardTaskWarningRequirements:ie,selectedBoardTaskReceiptTimeline:F,selectedBoardTaskLifecycleEvents:ae,selectedBoardTaskResearchReadPaths:I,selectedBoardTaskDiscoveredRelevantPaths:se,selectedBoardTaskUnmetResearchRequirements:L,selectedBoardTaskReviewedPathsBackedByRead:R,selectedBoardTaskUnreviewedRelevantPaths:ue,selectedBoardTaskVerificationOutcome:de,selectedBoardTaskVerificationPassed:fe,selectedBoardTaskVerificationResults:pe,selectedBoardTaskFailureDetail:z,selectedBoardTaskRelatedPaths:me,selectedBoardTaskRelatedArtifacts:he,selectedBoardTaskNodeId:ge,selectedBoardTaskStateNormalized:_e,selectedBoardTaskImpactSummary:ve,selectedBoardTaskResetOutputPaths:V,canTaskContinue:H,canTaskRetry:ye,selectedBoardTaskServerActionMessage:U,canTaskRequeue:be,canBacklogTaskClaim:xe,canBacklogTaskRequeue:Se,selectedBoardTaskTouchedFiles:W,selectedBoardTaskUndeclaredFiles:Ce,selectedBoardTaskRequestedQualityMode:De,selectedSessionId:Oe,selectedSessionFilterId:ke,availableSessionIds:Ae,sessionLogEntries:je,sessionLogRef:Me,selectedLogSource:Ne,telemetryEvents:Pe,filteredRunEventEntries:Fe,blockers:Ie,runHints:Le,runRepairGuidanceEntries:Re,artifactsSectionRef:ze,runArtifactEntries:K,selectedRunArtifactKey:Ve,runHistoryEvents:He,workflowContextRun:Ue,workflowBlackboard:We}=e,{onSelectRunId:q,onRefresh:Ge,onClose:Ke,onSelectBoardTaskId:qe,focusArtifactEntry:Je,onSessionFilterChange:Ye,onCopySessionLog:Xe,onJumpToLatest:Ze,onPinnedStateChange:Qe,onSelectLogSource:$e,onFocusNode:et,onToggleArtifact:tt,onCopyFullDebugContext:nt,navigate:rt,workflowTaskContinueMutation:it,workflowTaskRetryMutation:at,workflowTaskRequeueMutation:ot,workflowTaskDispositionMutation:st,workflowRepairMutation:ct,workflowRecoverMutation:lt,backlogTaskClaimMutation:ut,backlogTaskRequeueMutation:dt,runActionMutation:ft,taskResetPreviewQuery:pt}=t,{runTimeLabel:mt,workflowCompletedNodeCount:ht,workflowBlockedNodeCount:gt,workflowActiveSessionCount:_t,statusColor:vt,isActiveRunStatus:yt,compactIdentifier:bt,sessionLabel:xt,formatTimestampLabel:St}=n,Ct=typeof ht==`function`?ht:le,wt=typeof gt==`function`?gt:oe,Tt=typeof _t==`function`?_t:ce,Et=e=>{let t=we(e);!t||!rt||Te(rt,{path:t})},Dt=String(x?.output_path||``).trim(),Ot=ft.isPending?String(ft.variables?.action||``).trim():``,kt=Ot===`cancel`?`Cancelling...`:Ot===`resume`?`Resuming...`:Ot===`pause`?`Pausing...`:`Working...`,At=Ot?`Waiting for ${Ot} request to finish.`:``,jt=a?Tt(i):0;return r?f(p.div,{className:`tcp-confirm-overlay`,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:()=>q(``),children:f(p.div,{className:`tcp-confirm-dialog tcp-run-debugger-modal`,initial:{opacity:0,y:8,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:6,scale:.98},onClick:e=>e.stopPropagation(),children:[f(`div`,{className:`mb-3 flex flex-col gap-3 lg:flex-row lg:items-start lg:justify-between`,children:[f(`div`,{className:`grid gap-1`,children:[f(`h3`,{className:`tcp-confirm-title`,children:`Run Debugger`}),f(`div`,{className:`tcp-subtle text-xs`,children:[`automation:`,` `,String(i?.automation_id||i?.routine_id||`unknown`),` · `,`run: `,r,` · `,`running for `,mt(i)]}),a?f(`div`,{className:`tcp-subtle text-xs`,children:[`completed nodes: `,Ct(i),` · `,`blocked nodes: `,wt(i),` · `,`active sessions: `,Tt(i)]}):null,f(`div`,{className:`tcp-subtle text-xs`,children:[`tokens: `,Ee(Number(i?.total_tokens||0)),` (`,`prompt `,Ee(Number(i?.prompt_tokens||0)),` · `,`completion `,Ee(Number(i?.completion_tokens||0)),`)`]})]}),f(`div`,{className:`flex w-full flex-col gap-2 sm:flex-row sm:flex-wrap sm:items-center lg:w-auto`,children:[f(`span`,{className:vt(o),children:o||`unknown`}),s?f(`span`,{className:`tcp-subtle`,children:s}):null,c?f(`button`,{type:`button`,className:`tcp-btn h-8 w-full px-2 text-xs sm:w-auto`,onClick:()=>it.mutate({runId:r,nodeId:l,reason:`continued blocked task ${l} from run debugger`}),disabled:!l||it.isPending||ft.isPending,title:At||(l?`Continue blocked task ${l} with minimal reset`:`Select a blocked node to continue`),children:[it.isPending?f(`span`,{"aria-hidden":`true`,className:`inline-block h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent`}):f(`i`,{"data-lucide":`skip-forward`}),it.isPending?`Continuing...`:`Continue`]}):null,u?f(`button`,{type:`button`,className:`tcp-btn h-8 w-full px-2 text-xs sm:w-auto`,onClick:()=>d?at.mutate({runId:r,nodeId:d,reason:`retried task ${d} from run debugger`}):lt.mutate({runId:r,reason:`retried from run debugger`}),disabled:!r||lt.isPending||at.isPending||ft.isPending,title:At||(d?`Retry selected task ${d}`:`Retry the whole run`),children:[at.isPending||lt.isPending?f(`span`,{"aria-hidden":`true`,className:`inline-block h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent`}):f(`i`,{"data-lucide":`rotate-ccw`}),d?at.isPending?`Retrying task...`:`Retry Task`:lt.isPending?`Retrying...`:`Retry`]}):null,f(`button`,{type:`button`,className:`tcp-btn h-8 w-full px-2 text-xs sm:w-auto`,onClick:()=>ft.mutate({action:o===`paused`?`resume`:`pause`,runId:r,family:a?`v2`:`legacy`}),disabled:!r||ft.isPending||!(o===`paused`||yt(o)),children:[f(`i`,{"data-lucide":o===`paused`?`play`:`pause`}),o===`paused`?`Resume`:`Pause`]}),a?f(`button`,{type:`button`,className:`tcp-btn h-8 w-full px-2 text-xs sm:w-auto`,onClick:()=>ft.mutate({action:`cancel`,runId:r,family:`v2`,reason:`cancelled from run debugger`}),disabled:!r||ft.isPending||o===`cancelled`,title:`Force stop this workflow run and clear active sessions`,children:[f(`i`,{"data-lucide":`square`}),ft.isPending?kt:`Cancel`]}):null,f(`button`,{className:`tcp-btn h-8 w-full px-2 text-xs sm:w-auto`,onClick:Ge,children:[f(`i`,{"data-lucide":`refresh-cw`}),`Refresh`]}),f(`button`,{className:`tcp-btn h-8 w-full px-2 text-xs sm:w-auto`,onClick:Ke,children:[f(`i`,{"data-lucide":`x`}),`Close`]})]})]}),f(`div`,{className:`flex-1 min-h-0 overflow-y-auto pr-1`,children:f(`div`,{className:`grid min-h-full content-start gap-3`,children:[f(qr,{runSummaryRows:_}),a?f(`div`,{className:`tcp-list-item`,children:[f(`div`,{className:`mb-2 flex flex-wrap items-center justify-between gap-2`,children:[f(`div`,{children:[f(`div`,{className:`font-medium`,children:`Workflow Board`}),f(`div`,{className:`tcp-subtle text-xs`,children:[`context run: `,bt(g||`unlinked`,44),` · `,`tasks: `,v.tasks.length,` · `,`agents running: `,jt,` · `,`artifacts: `,y.length]})]}),f(`span`,{className:`tcp-badge-info`,children:v.taskSource===`hybrid`?`blackboard + context`:v.taskSource===`checkpoint`?`run checkpoint`:v.taskSource})]}),f(B,{tasks:v.tasks,currentTaskId:v.currentTaskId,selectedTaskId:b,activeAgentCount:jt,onTaskSelect:e=>qe(t=>t===e.id?``:e.id)})]}):null,f(`div`,{className:`grid min-h-0 items-start gap-3 xl:grid-cols-[1.62fr_1fr]`,children:[f(`div`,{className:`grid min-h-0 gap-3`,children:[x?f(`div`,{ref:S,className:`tcp-list-item relative max-h-[56vh] overflow-y-auto sm:max-h-[28rem]`,children:[f(`div`,{className:`sticky -top-3 z-10 -mx-3 -mt-3 mb-2 flex items-center justify-between gap-2 rounded-t-xl border-b border-slate-800/80 bg-[color:color-mix(in_srgb,var(--color-surface-elevated)_96%,#000_4%)] px-3 py-3 backdrop-blur-sm`,children:[f(`div`,{className:`font-medium`,children:`Task Details`}),f(`button`,{type:`button`,className:`chat-icon-btn h-7 w-7`,"aria-label":`Close task details`,onClick:()=>qe(``),children:f(`i`,{"data-lucide":`x-circle`})})]}),f(`div`,{className:`grid gap-2 pr-1 text-sm text-slate-200`,children:[f(`div`,{className:`whitespace-pre-wrap break-words font-medium leading-snug`,children:x.title}),x.description?f(`div`,{className:`tcp-subtle whitespace-pre-wrap break-words`,children:x.description}):null,f(`div`,{className:`flex flex-wrap gap-2 text-xs`,children:[f(`span`,{className:`tcp-badge-info`,children:x.state}),x.assigned_role?f(`span`,{className:`tcp-badge-info`,children:[`agent: `,x.assigned_role]}):null,String(x.task_kind||``).trim()?f(`span`,{className:`tcp-badge-info`,children:[`task: `,String(x.task_kind).trim()]}):null,String(x.backlog_task_id||``).trim()?f(`span`,{className:`tcp-badge-info`,children:[`backlog: `,String(x.backlog_task_id).trim()]}):null,String(x.task_owner||``).trim()?f(`span`,{className:`tcp-badge-info`,children:[`owner: `,String(x.task_owner).trim()]}):null,x.session_id?f(`span`,{className:`tcp-badge-info`,children:xt(x.session_id)}):null]}),C?f(`div`,{className:`flex flex-wrap gap-2 text-xs`,children:[String(C?.status||``).trim()?f(`span`,{className:String(C?.status||``).trim().toLowerCase()===`blocked`?`tcp-badge-blocked`:w===`accepted_with_warnings`?`tcp-badge-warn`:`tcp-badge-ok`,children:[`status:`,` `,w===`accepted_with_warnings`?`completed with warnings`:String(C?.status||``).trim()]}):null,T>0?f(`span`,{className:`tcp-badge-warn`,children:[T,` warning`,T===1?``:`s`]}):null,typeof C?.approved==`boolean`?f(`span`,{className:C.approved?`tcp-badge-ok`:`tcp-badge-warn`,children:[`approved: `,String(C.approved)]}):null,E?.workspace_inspection_used?f(`span`,{className:`tcp-badge-info`,children:`workspace inspected`}):null,E?.web_research_used?f(`span`,{className:`tcp-badge-info`,children:`web research used`}):null,String(D?.rejected_artifact_reason||``).trim()?f(`span`,{className:`tcp-badge-warn`,children:`artifact rejected`}):null]}):null,C?.cost_provenance?f(`div`,{className:`tcp-subtle text-xs`,children:[`node tokens:`,` `,Ee(Number(C.cost_provenance.tokens_in||0)+Number(C.cost_provenance.tokens_out||0)),` (in `,Ee(Number(C.cost_provenance.tokens_in||0)),` · out `,Ee(Number(C.cost_provenance.tokens_out||0)),`)`]}):null,O?null:f(`div`,{className:`rounded-lg border border-slate-700/60 bg-slate-950/20 p-3 text-xs text-slate-300`,children:ee?`This is a projected backlog task derived from workflow output. You can claim or requeue it here without resetting the source workflow node.`:`This is a projected backlog task derived from workflow output, not a direct automation node. Inspect it here, but use the source workflow stage for retry, continue, or requeue actions.`}),x.runtime_detail?f(`div`,{className:`whitespace-pre-wrap break-words rounded-lg border border-slate-700/60 bg-slate-950/30 p-3 text-xs text-slate-300`,children:x.runtime_detail}):null,te||k||ne||T||P.length?f(`div`,{className:`rounded-lg border border-slate-700/60 bg-slate-950/20 p-3 text-xs text-slate-300`,children:[f(`div`,{className:`font-medium text-slate-200`,children:`Stability Contract`}),f(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:[f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle`,children:`workflow class`}),f(`div`,{className:`mt-1 font-medium text-slate-100`,children:te||`n/a`})]}),f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle`,children:`phase`}),f(`div`,{className:`mt-1 font-medium text-slate-100`,children:k||`n/a`})]}),f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle`,children:`failure kind`}),f(`div`,{className:`mt-1 font-medium text-slate-100`,children:ne||`n/a`})]}),f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle`,children:`validation outcome`}),f(`div`,{className:`mt-1 flex items-center gap-2 font-medium text-slate-100`,children:[f(`span`,{children:w||`n/a`}),f(Ir,{validation:D})]})]}),f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle`,children:`quality mode`}),f(`div`,{className:`mt-1 font-medium text-slate-100`,children:A||`n/a`})]}),f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle`,children:`rollback`}),f(`div`,{className:`mt-1 font-medium text-slate-100`,children:j===null?`n/a`:j?`enabled`:`disabled`})]}),f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle`,children:`blocker category`}),f(`div`,{className:`mt-1 font-medium text-slate-100`,children:re||`n/a`})]}),f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2 sm:col-span-2`,children:[f(`div`,{className:`tcp-subtle`,children:`validation basis`}),M?f(G,{value:M,className:`mt-1`,preClassName:`tcp-code mt-1 max-h-40 overflow-auto text-[11px]`}):f(`div`,{className:`mt-1 font-medium text-slate-100`,children:`n/a`})]}),(()=>{if(Be(D).length===0)return null;let e=D||{},t=String(e.human_disposition||e.humanDisposition||`unmarked`),n=st?.isPending??!1,i=String(st?.variables?.disposition||``),a=String(st?.variables?.nodeId||``),o=[{value:`accepted`,label:`Accept`},{value:`rejected`,label:`Reject`},{value:`re_ran_strict`,label:`Re-ran Strict`}],s=e=>{let t=String(r||``).trim(),n=String(ge||``).trim();!t||!n||!st?.mutate||st.mutate({runId:t,nodeId:n,disposition:e})};return f(`div`,{className:`rounded-md border border-amber-700/40 bg-amber-950/20 p-2 sm:col-span-2`,children:[f(`div`,{className:`tcp-subtle`,children:`profile relaxation`}),f(`div`,{className:`mt-1`,children:f(Lr,{validation:D})}),ge?f(`div`,{className:`mt-2 grid gap-2`,children:[f(`div`,{className:`tcp-subtle text-[11px]`,children:[`graduation review · current:`,` `,f(`span`,{className:`font-medium text-slate-100`,children:t.replace(/_/g,` `)})]}),f(`div`,{className:`flex flex-wrap gap-2`,children:[o.map(e=>{let o=t===e.value,c=n&&i===e.value&&a===ge;return f(`button`,{type:`button`,className:o?`tcp-btn-primary`:`tcp-btn`,disabled:o||n||!r,onClick:()=>s(e.value),children:c?`Saving...`:e.label},e.value)}),t===`unmarked`?null:f(`button`,{type:`button`,className:`tcp-btn`,disabled:n||!r,onClick:()=>s(`unmarked`),children:n&&i===`unmarked`?`Saving...`:`Clear`})]})]}):null]})})(),f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2 sm:col-span-2`,children:[f(`div`,{className:`tcp-subtle`,children:`receipt ledger`}),N?f(G,{value:N,className:`mt-1`,preClassName:`tcp-code mt-1 max-h-40 overflow-auto text-[11px]`}):f(`div`,{className:`mt-1 font-medium text-slate-100`,children:`n/a`})]}),f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle`,children:`artifact candidates`}),f(`div`,{className:`mt-1 font-medium text-slate-100`,children:P.length})]})]}),ie.length?f(`div`,{className:`mt-3 rounded-md border border-amber-500/30 bg-amber-500/10 p-3`,children:[f(`div`,{className:`mb-2 font-medium text-amber-100`,children:`Non-blocking warnings`}),f(`div`,{className:`flex flex-wrap gap-2`,children:ie.map(e=>f(`span`,{className:`tcp-badge-warn`,children:e.replace(/_/g,` `)},e))})]}):null,P.length?f(`div`,{className:`mt-3 grid gap-2`,children:P.map((e,t)=>f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f(`span`,{className:`tcp-badge-info`,children:String(e?.source||`candidate`)}),e?.accepted?f(`span`,{className:`tcp-badge-ok`,children:`accepted`}):null,e?.substantive?f(`span`,{className:`tcp-badge-ok`,children:`substantive`}):f(`span`,{className:`tcp-badge-warn`,children:`non-substantive`}),e?.placeholder_like?f(`span`,{className:`tcp-badge-warn`,children:`placeholder-like`}):null]}),f(`div`,{className:`mt-1 tcp-subtle`,children:[Number(e?.length||0),` chars`]})]},`${String(e?.source||`candidate`)}-${t}`))}):null,F.length?f(`div`,{className:`mt-3 grid gap-2`,children:[f(`div`,{className:`tcp-subtle`,children:`receipt timeline`}),F.map((e,t)=>f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f(`span`,{className:`tcp-badge-info`,children:[`seq `,String(e?.seq||t+1)]}),String(e?.eventType||``).trim()?f(`span`,{className:`tcp-badge-info`,children:String(e.eventType).trim()}):null,String(e?.receiptKind||``).trim()?f(`span`,{className:`tcp-badge-info`,children:String(e.receiptKind).trim()}):null,String(e?.attempt||``).trim()?f(`span`,{className:`tcp-badge-info`,children:[`attempt `,String(e.attempt).trim()]}):null,Number(e?.at||0)>0?f(`span`,{className:`tcp-subtle text-[11px]`,children:St(e.at)}):null]}),f(`div`,{className:`mt-1 text-slate-300`,children:String(e?.detail||``).trim()||`receipt`}),f(G,{value:e?.raw||e,label:`raw record`,className:`mt-2`,preClassName:`tcp-code mt-2 max-h-40 overflow-auto text-[11px]`})]},`${String(e?.seq||t)}:${String(e?.eventType||e?.event_type||``)}`))]}):null,ae.length?f(`div`,{className:`mt-3 grid gap-2`,children:[f(`div`,{className:`tcp-subtle`,children:`recent workflow events`}),ae.map((e,t)=>f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f(`span`,{className:`tcp-badge-info`,children:e.event}),e.phase?f(`span`,{className:`tcp-badge-info`,children:e.phase}):null,e.failureKind?f(`span`,{className:`tcp-badge-warn`,children:e.failureKind}):null]}),f(`div`,{className:`mt-1 text-slate-300`,children:e.reason})]},`${e.event}-${String(e.recordedAtMs||t)}`))]}):null]}):null,String(x.write_scope||``).trim()||String(x.repo_root||``).trim()||String(x.acceptance_criteria||``).trim()||String(x.task_dependencies||``).trim()||String(x.verification_state||``).trim()||String(x.verification_command||``).trim()||String(x.output_path||``).trim()?f(`div`,{className:`rounded-lg border border-slate-700/60 bg-slate-950/20 p-3 text-xs text-slate-300`,children:[f(`div`,{className:`font-medium text-slate-200`,children:`Coding Task Context`}),f(`div`,{className:`mt-2 space-y-1`,children:[f(`div`,{children:[`backlog task:`,` `,String(x.backlog_task_id||``).trim()||`n/a`]}),f(`div`,{children:[`repo root:`,` `,String(x.repo_root||``).trim()||`n/a`]}),f(`div`,{children:[f(`span`,{children:`output path: `}),f(`span`,{className:`break-all`,children:Dt||`n/a`}),Dt&&we(Dt)?f(`button`,{type:`button`,className:`ml-2 rounded-md border border-sky-500/30 bg-sky-950/20 px-2 py-0.5 text-[10px] text-sky-100`,onClick:()=>Et(Dt),children:`Open in Files`}):null]}),f(`div`,{children:[`write scope:`,` `,String(x.write_scope||``).trim()||`n/a`]}),f(`div`,{children:[`acceptance criteria:`,` `,String(x.acceptance_criteria||``).trim()||`n/a`]}),f(`div`,{children:[`task dependencies:`,` `,String(x.task_dependencies||``).trim()||`n/a`]}),f(`div`,{children:[`verification state:`,` `,String(x.verification_state||``).trim()||`n/a`]}),f(`div`,{children:[`owner:`,` `,String(x.task_owner||``).trim()||`n/a`]}),f(`div`,{children:[`lease owner:`,` `,String(x.lease_owner||``).trim()||`n/a`]}),f(`div`,{children:[`lease expires:`,` `,x.lease_expires_at_ms?St(x.lease_expires_at_ms):`n/a`]}),f(`div`,{children:[`stale lease: `,x.stale_lease?`yes`:`no`]}),f(`div`,{children:[`verification:`,` `,String(x.verification_command||``).trim()||`n/a`]})]})]}):null,I.length||se.length||L.length||D?.repair_attempted?f(`div`,{className:`rounded-lg border border-slate-700/60 bg-slate-950/20 p-3 text-xs text-slate-300`,children:[f(`div`,{className:`font-medium text-slate-200`,children:`Research Requirement Status`}),f(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:[f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle`,children:`discovered relevant files`}),f(`div`,{className:`mt-1 font-medium text-slate-100`,children:se.length})]}),f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle`,children:`actual read calls backed by path`}),f(`div`,{className:`mt-1 font-medium text-slate-100`,children:I.length})]}),f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle`,children:`reviewed paths backed by read`}),f(`div`,{className:`mt-1 font-medium text-slate-100`,children:R.length})]}),f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle`,children:`web research`}),f(`div`,{className:`mt-1 font-medium text-slate-100`,children:D?.web_research_attempted?D?.web_research_succeeded?`attempted and succeeded`:`attempted but not successful`:`not attempted`})]})]}),f(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:[f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle`,children:`repair pass`}),f(`div`,{className:`mt-1 font-medium text-slate-100`,children:D?.repair_attempted?D?.repair_succeeded?`attempted and satisfied`:D?.repair_exhausted?`attempted and exhausted`:`attempted and still active`:`not needed or not attempted`}),D?.repair_attempted?f(`div`,{className:`mt-1 tcp-subtle`,children:[`attempt`,` `,Number(D?.repair_attempt||0),` `,`of`,` `,Number(D?.repair_attempt||0)+Number(D?.repair_attempts_remaining||0)]}):null]}),f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle`,children:`missing / unreviewed relevant files`}),f(`div`,{className:`mt-1 font-medium text-slate-100`,children:ue.length})]})]}),L.length?f(`div`,{className:`mt-3`,children:[f(`div`,{className:`tcp-subtle mb-1`,children:`unmet requirements`}),f(`div`,{className:`flex flex-wrap gap-1`,children:L.map(e=>f(`span`,{className:`rounded-full border border-emerald-500/30 bg-emerald-950/20 px-2 py-1 text-[11px] text-emerald-100/90`,children:e},e))})]}):null,ue.length?f(`div`,{className:`mt-3`,children:[f(`div`,{className:`tcp-subtle mb-1`,children:`unreviewed relevant files`}),f(`div`,{className:`flex flex-wrap gap-1`,children:ue.map(e=>f(`span`,{className:`rounded-full border border-slate-700/70 bg-slate-950/30 px-2 py-1 font-mono text-[11px] text-slate-300`,children:e},e))})]}):null]}):null,C||me.length||z?f(`div`,{className:`rounded-lg border border-slate-700/60 bg-slate-950/20 p-3 text-xs text-slate-300`,children:[f(`div`,{className:`font-medium text-slate-200`,children:`Coding Verification & Failures`}),f(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:[f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle`,children:`verification outcome`}),f(`div`,{className:`mt-1 font-medium text-slate-100`,children:de})]}),f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle`,children:`verification passed`}),f(`div`,{className:`mt-1 font-medium text-slate-100`,children:typeof fe==`boolean`?fe?`yes`:`no`:`n/a`})]})]}),E?.verification_expected?f(`div`,{className:`mt-3 rounded-md border border-slate-800/80 bg-slate-950/30 p-2`,children:[f(`div`,{className:`tcp-subtle mb-2`,children:`verification plan`}),f(`div`,{className:`mb-2 text-slate-200/80`,children:[Number(E?.verification_completed||0),` /`,` `,Number(E?.verification_total||0),` checks ran`]}),pe.length?f(`div`,{className:`grid gap-2`,children:pe.map((e,t)=>f(`div`,{className:`rounded-md border border-slate-800/80 bg-slate-950/40 p-2`,children:[f(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f(`span`,{className:`tcp-badge-info`,children:String(e?.kind||`verify`)}),f(`span`,{className:e?.failed?`tcp-badge-warn`:e?.ran?`tcp-badge-ok`:`tcp-badge-info`,children:e?.failed?`failed`:e?.ran?`passed`:`not run`})]}),f(`div`,{className:`mt-1 break-words font-mono text-[11px] text-slate-200`,children:String(e?.command||``).trim()||`n/a`}),String(e?.failure||``).trim()?f(`div`,{className:`mt-1 whitespace-pre-wrap break-words text-[11px] text-emerald-100/90`,children:String(e?.failure||``).trim()}):null]},`${String(e?.command||t)}-${t}`))}):null]}):null,z?f(`div`,{className:`mt-3 rounded-md border border-emerald-500/30 bg-emerald-950/20 p-2 text-emerald-100/90`,children:[f(`div`,{className:`tcp-subtle mb-1 text-emerald-100/70`,children:`failure detail`}),f(`div`,{className:`whitespace-pre-wrap break-words`,children:z})]}):null,me.length?f(`div`,{className:`mt-3`,children:[f(`div`,{className:`tcp-subtle mb-1`,children:`related artifacts`}),f(`div`,{className:`flex flex-wrap gap-2`,children:me.map(e=>f(`button`,{type:`button`,className:`rounded-full border border-slate-700/70 bg-slate-950/30 px-2 py-1 font-mono text-[11px] text-slate-200 transition hover:border-sky-500/40 hover:text-sky-100`,onClick:()=>Je(e),title:e,children:[`Open `,bt(e,44)]},e))}),he.length?f(`div`,{className:`mt-2 tcp-subtle`,children:[`matched run artifacts:`,` `,he.map(e=>e.name).join(`, `)]}):f(`div`,{className:`mt-2 tcp-subtle`,children:`No matching run artifact found yet. The button will still jump to the artifacts section.`})]}):null,f(Mr,{selectedBoardTask:x,selectedBoardTaskIsWorkflowNode:O,selectedBoardTaskIsProjectedBacklogItem:ee,selectedBoardTaskNodeId:ge,selectedBoardTaskStateNormalized:_e,selectedBoardTaskImpactSummary:ve,selectedBoardTaskResetOutputPaths:V,selectedRunId:r,canTaskContinue:H,canTaskRetry:ye,runDebuggerRetryNodeId:d,continueBlockedNodeId:l,selectedBoardTaskServerActionMessage:U,canTaskRequeue:be,canBacklogTaskClaim:xe,canBacklogTaskRequeue:Se,canRecoverWorkflowRun:u,backlogTaskClaimMutation:ut,backlogTaskRequeueMutation:dt,workflowTaskContinueMutation:it,workflowTaskRetryMutation:at,workflowTaskRequeueMutation:ot,workflowRepairMutation:ct,workflowRecoverMutation:lt,taskResetPreviewQuery:pt})]}):null,f(Yr,{selectedBoardTask:x,selectedBoardTaskTelemetry:E,selectedBoardTaskArtifactValidation:D,selectedBoardTaskTouchedFiles:W,selectedBoardTaskUndeclaredFiles:Ce,selectedBoardTaskRequestedQualityMode:De,selectedBoardTaskEmergencyRollbackEnabled:j,selectedBoardTaskBlockerCategory:re,selectedBoardTaskValidationBasis:M,selectedBoardTaskReceiptTimeline:F,onOpenPath:Et}),x.error_message?f(`div`,{className:`whitespace-pre-wrap break-words rounded-lg border border-rose-500/30 bg-rose-950/20 p-3 text-xs text-rose-200`,children:x.error_message}):null,x.dependencies.length?f(`div`,{className:`flex flex-wrap gap-1 text-xs`,children:x.dependencies.map(e=>f(`span`,{className:`tcp-badge-info`,children:[`depends on `,e]},e))}):null]})]}):null,f(Hr,{selectedSessionId:Oe,selectedSessionFilterId:ke,availableSessionIds:Ae,sessionLogEntries:je,sessionLogRef:Me,compactIdentifier:bt,sessionLabel:xt,onSessionFilterChange:Ye,onCopySessionLog:Xe,onJumpToLatest:Ze,onPinnedStateChange:Qe}),f(Kr,{selectedLogSource:Ne,telemetryEvents:Pe,isWorkflowRun:a,filteredRunEventEntries:Fe,formatTimestampLabel:St,onSelectLogSource:$e})]}),f(`div`,{className:`grid min-h-0 content-start gap-3 overflow-visible`,children:[f(Br,{blockers:Ie}),f(Vr,{runHints:Le}),f(Wr,{runRepairGuidanceEntries:Re,blockedNodeIds:m,needsRepairNodeIds:h,isWorkflowRun:a,selectedRunId:r,hasActiveSessions:Tt(i)>0,onFocusNode:et,workflowTaskRetryMutation:at,workflowTaskContinueMutation:it,workflowTaskRequeueMutation:ot}),f(Ur,{objective:String(i?.mission_snapshot?.objective||`n/a`)}),f(`div`,{ref:ze,children:f(zr,{artifactCount:y.length,artifactEntries:K,selectedArtifactKey:Ve,isWorkflowRun:a,onToggleArtifact:tt,onOpenPath:Et})}),f(`div`,{className:`tcp-list-item min-h-0`,children:[f(`div`,{className:`font-medium`,children:a?`Run History`:`Persisted History`}),He.length?f(`div`,{className:`mt-2 grid gap-2 overflow-auto pr-1 sm:max-h-[14rem]`,children:He.map((e,t)=>f(Xr,{event:e,index:t,formatTimestampLabel:St},`${String(e?.id||e?.event||e?.type||`history`)}-${t}`))}):f(`div`,{className:`tcp-subtle mt-2 text-xs`,children:a?`No context-run history has been persisted for this workflow run yet.`:`No persisted history rows returned for this automation.`})]}),f(`div`,{className:`tcp-list-item min-h-0`,children:[f(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[f(`div`,{className:`font-medium`,children:`Raw Run Payload`}),f(`button`,{className:`tcp-btn h-7 px-2 text-xs`,onClick:nt,children:[f(`i`,{"data-lucide":`copy-plus`}),`Copy all debug context`]})]}),f(G,{value:{run:i,contextRun:Ue,blackboard:We},label:`Show raw run payload`,preClassName:`tcp-code overflow-auto sm:max-h-[18rem]`})]})]})]})]})}),f(`div`,{className:`tcp-confirm-actions mt-3`,children:f(`button`,{className:`tcp-btn`,onClick:()=>q(``),children:[f(`i`,{"data-lucide":`x`}),`Close`]})})]})}):null}function Qr({state:t,actions:n,helpers:r}){let[i,o]=a(()=>({active:!!t?.defaultRunningSectionsOpen?.active,issues:!!t?.defaultRunningSectionsOpen?.issues,history:!!t?.defaultRunningSectionsOpen?.history})),{rootRef:s,viewMode:c,calendarEvents:l,workflowAutomationCount:u,workflowAutomationVisibleCount:d,workflowAutomationSections:p,legacyAutomationRows:m,totalSavedAutomations:g,legacyAutomationCount:_,workflowLibraryFilters:v,workflowLibraryFilteringActive:y,workflowSortMode:x,workflowPreferencesLoading:w,packs:T,activeRuns:E,workflowQueueCounts:D,failedRuns:O,runsLoading:ee,runsRefreshing:te,runs:k,selectedRunId:ne,selectedRun:A,isWorkflowRun:j,runStatus:re,runStatusDerivedNote:M,canContinueBlockedWorkflow:N,continueBlockedNodeId:P,canRecoverWorkflowRun:ie,runDebuggerRetryNodeId:F,selectedContextRunId:ae,runSummaryRows:I,workflowProjection:se,runArtifacts:L,selectedBoardTaskId:R,selectedBoardTask:ce,boardDetailRef:ue,selectedBoardTaskOutput:de,selectedBoardTaskValidationOutcome:fe,selectedBoardTaskWarningCount:pe,selectedBoardTaskTelemetry:z,selectedBoardTaskArtifactValidation:me,selectedBoardTaskIsWorkflowNode:he,selectedBoardTaskIsProjectedBacklogItem:ge,selectedBoardTaskWorkflowClass:_e,selectedBoardTaskPhase:ve,selectedBoardTaskFailureKind:B,selectedBoardTaskQualityMode:V,selectedBoardTaskEmergencyRollbackEnabled:H,selectedBoardTaskBlockerCategory:ye,selectedBoardTaskValidationBasis:U,selectedBoardTaskReceiptLedger:be,selectedBoardTaskArtifactCandidates:xe,selectedBoardTaskWarningRequirements:Se,selectedBoardTaskReceiptTimeline:W,selectedBoardTaskLifecycleEvents:G,selectedBoardTaskResearchReadPaths:Ce,selectedBoardTaskDiscoveredRelevantPaths:we,selectedBoardTaskUnmetResearchRequirements:Te,selectedBoardTaskReviewedPathsBackedByRead:Ee,selectedBoardTaskUnreviewedRelevantPaths:De,selectedBoardTaskVerificationOutcome:Oe,selectedBoardTaskVerificationPassed:ke,selectedBoardTaskVerificationResults:Ae,selectedBoardTaskFailureDetail:je,selectedBoardTaskRelatedPaths:Me,selectedBoardTaskRelatedArtifacts:Ne,selectedBoardTaskNodeId:Pe,selectedBoardTaskStateNormalized:Fe,selectedBoardTaskImpactSummary:Ie,selectedBoardTaskResetOutputPaths:Le,canTaskContinue:Re,canTaskRetry:ze,canTaskRequeue:K,canBacklogTaskClaim:Be,canBacklogTaskRequeue:Ve,selectedBoardTaskTouchedFiles:He,selectedBoardTaskUndeclaredFiles:Ue,selectedBoardTaskRequestedQualityMode:We,selectedSessionId:q,selectedSessionFilterId:Ge,availableSessionIds:Ke,sessionLogEntries:qe,sessionLogRef:Je,selectedLogSource:Ye,telemetryEvents:Xe,filteredRunEventEntries:Ze,blockers:Qe,runHints:$e,runRepairGuidanceEntries:et,artifactsSectionRef:tt,runArtifactEntries:nt,selectedRunArtifactKey:rt,runHistoryEvents:it,workflowContextRun:at,workflowBlackboard:ot,editDraft:st,workflowEditDraft:ct,deleteConfirm:lt,overlapHistoryEntries:ut,providerOptions:dt,mcpServers:ft,automationsV2:pt,client:mt}=t,{setCalendarRange:ht,openCalendarAutomationEdit:gt,onOpenAdvancedEdit:_t,setWorkflowEditDraft:vt,runNowV2Mutation:bt,automationActionMutation:Ct,beginEdit:wt,toggleWorkflowFavorite:Tt,setWorkflowSortMode:Et,toggleWorkflowLibrarySourceFilter:Dt,toggleWorkflowLibraryStatusFilter:Ot,resetWorkflowLibraryFilters:kt,runNowMutation:At,isPausedAutomation:jt,onSelectRunId:Mt,onOpenRunningView:Nt,onRecreateWorkflowAutomation:Pt,toast:Ft,setDeleteConfirm:It,navigate:Rt,setEditDraft:zt,updateAutomationMutation:Bt,validateWorkspaceRootInput:Vt,validateModelInput:Ht,validatePlannerModelInput:Ut,automationWizardConfig:Wt,updateWorkflowAutomationMutation:Gt,onRefreshRunDebugger:Kt,setSelectedBoardTaskId:qt,focusArtifactEntry:Jt,setSelectedSessionFilterId:Yt,onCopySessionLog:Xt,setSessionLogPinnedToBottom:Zt,setSelectedLogSource:Qt,setSelectedRunArtifactKey:$t,onCopyFullDebugContext:en,workflowTaskContinueMutation:tn,workflowTaskRetryMutation:nn,workflowTaskRequeueMutation:rn,workflowTaskDispositionMutation:an,workflowRepairMutation:on,workflowRecoverMutation:sn,backlogTaskClaimMutation:ln,backlogTaskRequeueMutation:un,runActionMutation:dn,taskResetPreviewQuery:fn}=n,{statusColor:pn,isMissionBlueprintAutomation:mn,workflowAutomationToEditDraft:hn,formatAutomationV2ScheduleLabel:gn,formatScheduleLabel:_n,workflowStatusDisplay:vn,workflowStatusSubtleDetail:yn,runDisplayTitle:bn,formatRunDateTime:xn,runObjectiveText:Sn,shortText:Cn,runTimeLabel:wn,workflowCompletedNodeCount:Tn,workflowBlockedNodeCount:En,workflowActiveSessionCount:Dn,workflowTotalNodeCount:On,isActiveRunStatus:kn,compactIdentifier:An,sessionLabel:J,formatTimestampLabel:Y}=r,jn=typeof Tn==`function`?Tn:le,X=typeof En==`function`?En:oe,Mn=e=>o(t=>({...t,[e]:!t[e]}));e(()=>{s.current&&h(s.current)},[s,i]);let Nn=yt.find(e=>e.value===x)?.label||`Created: newest first`,Pn=e=>{let t=jn(e),n=On(e),r=X(e),i=Dn(e),a=[];return n>0?a.push(`${t}/${n} nodes`):t>0&&a.push(`${t} completed`),i>0&&a.push(`${i} worker${i===1?``:`s`}`),r>0&&a.push(`${r} blocked`),a.join(` · `)},Fn=e=>{let t=e?.automation||e,n=String(e?.id||t?.automation_id||t?.automationId||``).trim(),r=String(e?.status||t?.status||`draft`).trim(),i=!!e?.paused||r.toLowerCase()===`paused`,a=!!e?.isFavorite,o=String(e?.categoryLabel||``).trim(),s=String(e?.sourceLabel||``).trim(),c=Number(e?.createdAtMs||0)||0;return f(`div`,{className:`tcp-card flex flex-col gap-3 group`,children:[f(`div`,{className:`flex items-start justify-between gap-2`,children:[f(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[f(`span`,{className:`text-xl`,children:`🧩`}),f(`div`,{className:`min-w-0`,children:[f(`strong`,{className:`block truncate text-sm font-bold tracking-tight text-white mb-0.5`,children:String(t?.name||n||`Workflow automation`)}),f(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[o?f(`span`,{className:`tcp-badge-ok text-[10px] py-0 px-1.5`,children:o}):null,s?f(`span`,{className:`tcp-badge-ghost text-[10px] py-0 px-1.5`,children:s}):null,String(t?.description||``).trim()?null:f(`span`,{className:`text-[10px] text-slate-500 uppercase tracking-[0.2em]`,children:`No description`})]})]})]}),f(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[f(`button`,{type:`button`,className:`tcp-icon-btn h-8 w-8 ${a?`text-amber-300`:`text-slate-400`}`,onClick:()=>Tt(n),disabled:!n||w,title:a?`Remove from favorites`:`Add to favorites`,"aria-label":a?`Remove from favorites`:`Add to favorites`,"aria-pressed":a,children:f(`i`,{"data-lucide":`star`,className:`w-3.5 h-3.5 ${a?`fill-current`:``}`})}),f(`button`,{className:`tcp-icon-btn h-8 w-8 opacity-100 md:opacity-0 group-hover:opacity-100 transition-opacity`,onClick:()=>{if(mn(t)){_t(t);return}vt(hn(t))},disabled:!n,title:`Edit workflow automation`,"aria-label":`Edit workflow automation`,children:f(`i`,{"data-lucide":`pencil`,className:`w-3.5 h-3.5`})}),f(`span`,{className:`text-[10px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded ${pn(r)}`,children:r})]})]}),String(t?.description||``).trim()?f(`div`,{className:`tcp-subtle text-xs line-clamp-2 leading-relaxed`,children:String(t.description)}):f(`div`,{className:`tcp-subtle text-xs italic opacity-40`,children:`No description provided`}),String(t?.metadata?.standup?.report_path_template||``).trim()?f(`div`,{className:`text-[10px] text-emerald-300/80 font-mono tracking-tight bg-emerald-500/10 p-1.5 rounded-md truncate`,children:[`report: `,String(t?.metadata?.standup?.report_path_template||``)]}):null,f(`div`,{className:`tcp-subtle text-[11px] font-medium flex items-center gap-1.5`,children:[f(`i`,{"data-lucide":`calendar`,className:`w-3 h-3`}),gn(t?.schedule)]}),(()=>{let e=String(t?.execution?.profile||``).toLowerCase();return!e||e===`strict`?null:f(`div`,{className:`tcp-subtle text-[11px] font-medium flex items-center gap-1.5`,children:[f(`i`,{"data-lucide":`shield`,className:`w-3 h-3`}),f(`span`,{children:[`Profile: `,f(Fr,{profile:e})]})]})})(),c?f(`div`,{className:`tcp-subtle text-[11px] font-medium flex items-center gap-1.5`,children:[f(`i`,{"data-lucide":`clock`,className:`w-3 h-3`}),`Created `,Lt(t)]}):null,f(`div`,{className:`mt-auto pt-3 flex flex-wrap gap-2 border-t border-white/5`,children:[f(`button`,{className:`tcp-btn-primary flex-1 h-8 px-2 text-[11px]`,onClick:()=>bt.mutate({id:n}),disabled:!n||bt.isPending,title:`Run with the automation's saved execution profile`,children:[f(`i`,{"data-lucide":`play`,className:`w-3 h-3`}),bt.isPending?`Starting...`:`Run`]}),f(`details`,{className:`relative`,children:[f(`summary`,{className:`tcp-btn h-8 px-2 text-[11px] list-none cursor-pointer flex items-center`,title:`Run once with a profile override (does not change the saved automation)`,children:f(`i`,{"data-lucide":`chevrons-up-down`,className:`w-3 h-3`})}),f(`div`,{className:`absolute right-0 top-9 z-10 grid gap-1 rounded border border-slate-700/60 bg-slate-900/95 p-2 shadow-lg`,children:[f(`div`,{className:`text-[10px] uppercase tracking-wide text-slate-400`,children:`Run once as`}),f(gr,{size:`sm`,value:``,showGuidance:!1,disabled:!n||bt.isPending,pendingValue:bt.isPending&&bt.variables?.id===n&&bt.variables?.executionProfile?bt.variables.executionProfile:null,onChange:e=>{e&&bt.mutate({id:n,executionProfile:e})}}),f(`div`,{className:`text-[10px] text-slate-500`,children:`Override applies to this run only.`})]})]}),f(`button`,{className:`tcp-btn h-8 px-2 text-[11px]`,onClick:()=>Ct.mutate({action:i?`resume`:`pause`,automationId:n,family:`v2`}),disabled:!n||Ct.isPending,children:[f(`i`,{"data-lucide":i?`play`:`pause`,className:`w-3 h-3`}),i?`Resume`:`Pause`]}),f(`button`,{className:`tcp-btn-danger h-8 w-8 px-0 flex items-center justify-center`,onClick:()=>It({automationId:n,family:`v2`,title:String(t?.name||n||`workflow automation`)}),disabled:!n||Ct.isPending,title:`Remove`,children:f(`i`,{"data-lucide":`trash-2`,className:`w-3.5 h-3.5`})})]})]},n)},In=e=>{let t=e?.automation||e,n=String(e?.id||t?.automation_id||t?.id||t?.routine_id||``).trim(),r=!!e?.isFavorite,i=String(e?.status||t?.status||`active`).trim(),a=jt(t),o=Number(e?.createdAtMs||0)||0;return f(`div`,{className:`tcp-list-item`,children:[f(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[f(`div`,{className:`flex items-center gap-2 min-w-0`,children:[f(`span`,{children:`⏰`}),f(`strong`,{className:`truncate`,children:String(t?.name||n||`Automation`)})]}),f(`div`,{className:`flex items-center gap-2`,children:[f(`button`,{type:`button`,className:`tcp-icon-btn h-7 w-7 ${r?`text-amber-300`:``}`,onClick:()=>Tt(n),disabled:!n||w,title:r?`Remove from favorites`:`Add to favorites`,"aria-label":r?`Remove from favorites`:`Add to favorites`,"aria-pressed":r,children:f(`i`,{"data-lucide":`star`,className:`w-3.5 h-3.5 ${r?`fill-current`:``}`})}),f(`button`,{className:`tcp-btn h-7 px-2 text-xs`,onClick:()=>wt(t),children:f(`i`,{"data-lucide":`pencil`})}),f(`span`,{className:pn(i),children:i})]})]}),o?f(`div`,{className:`tcp-subtle text-xs mb-1 flex items-center gap-1.5`,children:[f(`i`,{"data-lucide":`clock`,className:`w-3 h-3`}),`Created `,Lt(t)]}):null,f(`div`,{className:`tcp-subtle text-xs`,children:_n(t?.schedule)}),f(`div`,{className:`mt-2`,children:f(`div`,{className:`flex flex-wrap gap-2`,children:[f(`button`,{className:`tcp-btn h-7 px-2 text-xs`,onClick:()=>At.mutate(n),children:[f(`i`,{"data-lucide":`play`}),`Run now`]}),f(`button`,{className:`tcp-btn h-7 px-2 text-xs`,onClick:()=>Ct.mutate({action:a?`resume`:`pause`,automationId:n,family:`legacy`}),disabled:!n||Ct.isPending,children:[f(`i`,{"data-lucide":a?`play`:`pause`}),a?`Resume`:`Pause`]}),f(`button`,{className:`tcp-btn h-7 px-2 text-xs`,onClick:()=>{let e=k.find(e=>String(e?.automation_id||e?.routine_id||e?.id||``).trim()===n),t=String(e?.run_id||e?.id||``).trim();t?(Mt(t),Nt()):Ft(`info`,`No runs yet for this automation.`)},children:[f(`i`,{"data-lucide":`info`}),`Debug latest`]}),f(`button`,{className:`tcp-btn-danger h-7 px-2 text-xs`,onClick:()=>It({automationId:n,family:`legacy`,title:String(t?.name||t?.label||n||`automation`)}),disabled:!n||Ct.isPending,children:[f(`i`,{"data-lucide":`trash-2`}),`Remove`]})]})})]},n)},Ln=!!(ee||te),Rn=c===`running`&&Ln&&!k.length;return f(`div`,{ref:s,className:`grid gap-4`,children:[c===`calendar`?f(cn,{events:l,onRangeChange:ht,onOpenAutomation:gt}):null,c===`list`?f(`div`,{className:`space-y-5 mb-4`,children:[f(`div`,{className:`flex items-start justify-between gap-2`,children:[f(`div`,{className:`space-y-1`,children:[f(`p`,{className:`text-[11px] font-medium uppercase tracking-[0.24em] text-slate-500`,children:`Library`}),f(`p`,{className:`tcp-subtle text-xs`,children:`Saved workflow definitions stay pinned first, and the rest follow your saved sort preference.`})]}),f(`span`,{className:`tcp-badge-ghost text-xs tracking-wide`,children:[d,` of `,u,` items`]})]}),f(`div`,{className:`tcp-card flex flex-col gap-3`,children:[f(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[f(`div`,{className:`space-y-1`,children:[f(`p`,{className:`text-[11px] font-medium uppercase tracking-[0.24em] text-slate-500`,children:`Filters & Sort`}),f(`p`,{className:`tcp-subtle text-xs`,children:[`Showing `,d,` of `,u,`. Current sort: `,Nn,`.`]})]}),f(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f(`label`,{className:`tcp-subtle text-xs uppercase tracking-[0.2em]`,children:`Sort`}),f(`select`,{className:`tcp-input h-8 min-w-[190px] py-1 text-xs`,value:x,onChange:e=>Et(e.target.value),disabled:w,children:yt.map(e=>f(`option`,{value:e.value,children:e.label},e.value))})]})]}),f(`div`,{className:`flex flex-wrap items-center gap-x-5 gap-y-3 border-t border-white/5 pt-3`,children:[f(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f(`span`,{className:`tcp-subtle text-xs uppercase tracking-[0.2em]`,children:`Source`}),xt.map(e=>{let t=v?.sources?.[e.value]!==!1;return f(`label`,{className:`inline-flex h-8 items-center gap-1.5 rounded border px-2 text-xs ${t?`border-blue-400/40 bg-blue-500/10 text-blue-100`:`border-white/10 bg-white/[0.02] text-slate-500`}`,children:[f(`input`,{type:`checkbox`,className:`sr-only`,checked:t,onChange:()=>Dt(e.value),disabled:w}),f(`span`,{className:`flex h-3.5 w-3.5 items-center justify-center rounded-sm border text-[10px] font-bold leading-none ${t?`border-blue-300 bg-blue-400 text-slate-950`:`border-white/10 bg-slate-950/70 text-transparent`}`,"aria-hidden":`true`,children:t?`✓`:``}),e.label]},e.value)})]}),f(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f(`span`,{className:`tcp-subtle text-xs uppercase tracking-[0.2em]`,children:`Status`}),St.map(e=>{let t=v?.statuses?.[e.value]!==!1;return f(`label`,{className:`inline-flex h-8 items-center gap-1.5 rounded border px-2 text-xs ${t?`border-emerald-400/40 bg-emerald-500/10 text-emerald-100`:`border-white/10 bg-white/[0.02] text-slate-500`}`,children:[f(`input`,{type:`checkbox`,className:`sr-only`,checked:t,onChange:()=>Ot(e.value),disabled:w}),f(`span`,{className:`flex h-3.5 w-3.5 items-center justify-center rounded-sm border text-[10px] font-bold leading-none ${t?`border-emerald-300 bg-emerald-400 text-slate-950`:`border-white/10 bg-slate-950/70 text-transparent`}`,"aria-hidden":`true`,children:t?`✓`:``}),e.label]},e.value)})]}),f(`button`,{type:`button`,className:`tcp-btn h-8 px-2 text-xs`,onClick:kt,disabled:w||!y,title:`Reset library filters`,"aria-label":`Reset library filters`,children:[f(`i`,{"data-lucide":`rotate-ccw`,className:`w-3 h-3`}),`Reset`]})]})]}),p.length>0?f(`div`,{className:`space-y-5`,children:p.map(e=>f(`section`,{className:`space-y-3`,children:[f(`div`,{className:`flex items-start justify-between gap-2`,children:[f(`div`,{className:`space-y-1`,children:[f(`p`,{className:`text-[11px] font-medium uppercase tracking-[0.24em] text-slate-500`,children:e.label}),f(`p`,{className:`tcp-subtle text-xs`,children:e.description})]}),f(`span`,{className:`tcp-badge-ghost text-xs tracking-wide`,children:[e.count,` items`]})]}),f(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4`,children:e.rows.map(e=>Fn(e))})]},e.key))}):f(`div`,{className:`tcp-list-item`,children:[f(`div`,{className:`font-medium`,children:u>0?`No library items match these filters`:`No library items saved yet`}),f(`div`,{className:`tcp-subtle mt-1 text-xs`,children:u>0?`Adjust the source or status filters to bring hidden workflow definitions back.`:`This section is separate from run history and only shows saved workflow definitions.`})]})]}):null,c===`list`?f(`div`,{className:`grid gap-2 mb-4`,children:[f(`div`,{className:`flex items-center justify-between gap-2`,children:[f(`p`,{className:`text-xs text-slate-500 uppercase tracking-wide font-medium`,children:`Saved Automations`}),f(`span`,{className:`tcp-badge-info`,children:[g,` saved`]})]}),f(`div`,{className:`grid gap-2`,children:[f(`div`,{className:`flex items-start justify-between gap-2`,children:[f(`div`,{className:`space-y-1`,children:[f(`p`,{className:`text-[11px] font-medium uppercase tracking-[0.24em] text-slate-500`,children:`Scheduled Automations`}),f(`p`,{className:`tcp-subtle text-xs`,children:`Legacy routines remain here with run, pause, and debug actions. Pause and resume only affect future scheduled runs.`})]}),f(`span`,{className:`tcp-subtle text-xs`,children:[_,` items`]})]}),m.length>0?f(`div`,{className:`grid gap-2`,children:m.map(e=>In(e))}):f(`div`,{className:`tcp-list-item`,children:[f(`div`,{className:`font-medium`,children:`No scheduled automations saved yet`}),f(`div`,{className:`tcp-subtle mt-1 text-xs`,children:`This section shows automation definitions, not execution history.`})]})]})]}):null,c===`list`&&T.length>0?f(`div`,{className:`mt-12 pt-8 border-t border-white/5 opacity-60 hover:opacity-100 transition-opacity`,children:[f(`p`,{className:`text-[10px] text-slate-500 uppercase tracking-widest font-bold mb-3`,children:`System: Installed Packs`}),f(`div`,{className:`grid gap-2`,children:T.map((e,t)=>f(`div`,{className:`tcp-list-item py-2`,children:f(`div`,{className:`flex items-center justify-between gap-2`,children:[f(`div`,{className:`flex items-center gap-2`,children:[f(`span`,{className:`text-sm opacity-70`,children:`📦`}),f(`strong`,{className:`text-xs`,children:String(e?.name||e?.id||`Pack`)})]}),f(`span`,{className:`text-[10px] text-slate-500`,children:String(e?.version||`1.0.0`)})]})},String(e?.id||e?.name||t)))})]}):null,Rn?f(S,{title:`Loading run history…`,text:`Fetching active, blocked, and recent automation runs`}):null,c===`running`&&!Rn?f(`div`,{className:`grid gap-2`,children:[f(`button`,{type:`button`,className:`tcp-list-item text-left`,onClick:()=>Mn(`active`),"aria-expanded":i.active,children:f(`div`,{className:`flex items-start justify-between gap-3`,children:[f(`div`,{className:`grid gap-1`,children:[f(`div`,{className:`flex items-center gap-2`,children:[f(`i`,{"data-lucide":i.active?`chevron-down`:`chevron-right`}),f(`p`,{className:`text-xs font-medium uppercase tracking-wide text-slate-500`,children:`Active Runs`})]}),f(`div`,{className:`flex flex-wrap gap-2`,children:[f(`span`,{className:`tcp-badge-warn`,children:[D.active,` active`]}),f(`span`,{className:`tcp-badge-info`,children:[D.queuedCapacity,` queued for capacity`]}),f(`span`,{className:`tcp-badge-info`,children:[D.queuedWorkspaceLock,` queued for workspace lock`]}),D.queuedOther>0?f(`span`,{className:`tcp-badge-info`,children:[D.queuedOther,` other queued`]}):null]})]}),f(`span`,{className:`tcp-subtle text-xs`,children:i.active?`Collapse`:`Expand`})]})}),i.active?E.length>0?E.slice(0,14).map((e,t)=>{let n=String(e?.run_id||e?.id||t).trim(),r=vn(e),i=e?.started_at_ms||e?.startedAtMs||e?.created_at_ms||e?.createdAtMs,a=yn(e),o=Pn(e);return f(`div`,{className:`tcp-list-item`,children:[f(`div`,{className:`flex items-center justify-between gap-2`,children:[f(`div`,{className:`grid gap-0.5`,children:[f(`span`,{className:`font-medium text-sm`,children:bn(e)}),f(`span`,{className:`tcp-subtle text-xs`,children:[n||`unknown run`,` · running for `,wn(e)]}),xn(i)?f(`span`,{className:`tcp-subtle text-xs`,children:[`Started: `,xn(i)]}):null,o?f(`span`,{className:`tcp-subtle text-xs`,children:o}):null,Sn(e)?f(`span`,{className:`text-xs text-slate-400`,children:Cn(Sn(e),160)}):null,a?f(`span`,{className:`tcp-subtle text-xs`,children:a}):null]}),f(`span`,{className:pn(r),children:r||`unknown`})]}),f(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[f(`button`,{className:`tcp-btn h-7 px-2 text-xs`,onClick:()=>Mt(n),children:[f(`i`,{"data-lucide":`bug`}),`Inspect`]}),f(`button`,{className:`tcp-btn h-7 px-2 text-xs`,onClick:()=>dn.mutate({action:`pause`,runId:n,family:n.startsWith(`automation-v2-run-`)?`v2`:`legacy`}),disabled:!n||dn.isPending,children:[f(`i`,{"data-lucide":`pause`}),`Pause`]}),f(`button`,{className:`tcp-btn h-7 px-2 text-xs`,onClick:()=>dn.mutate({action:`resume`,runId:n,family:n.startsWith(`automation-v2-run-`)?`v2`:`legacy`}),disabled:!n||dn.isPending,children:[f(`i`,{"data-lucide":`play`}),`Resume`]}),n.startsWith(`automation-v2-run-`)?f(`button`,{className:`tcp-btn h-7 px-2 text-xs`,onClick:()=>dn.mutate({action:`cancel`,runId:n,family:`v2`,reason:`cancelled from active runs panel`}),disabled:!n||dn.isPending,children:[f(`i`,{"data-lucide":`square`}),`Cancel`]}):null]})]},n||t)}):f(`div`,{className:`tcp-list-item`,children:[f(`div`,{className:`font-medium`,children:`Active Runs`}),f(`div`,{className:`tcp-subtle mt-1 text-xs`,children:`No active runs right now. Start a run to inspect live task execution.`})]}):null]}):null,c===`running`&&O.length>0?f(`div`,{className:`grid gap-2`,children:[f(`button`,{type:`button`,className:`tcp-list-item text-left`,onClick:()=>Mn(`issues`),"aria-expanded":i.issues,children:f(`div`,{className:`flex items-center justify-between gap-2`,children:[f(`div`,{className:`flex items-center gap-2`,children:[f(`i`,{"data-lucide":i.issues?`chevron-down`:`chevron-right`}),f(`p`,{className:`text-xs font-medium uppercase tracking-wide text-slate-500`,children:`Blocked or Failed Runs`})]}),f(`div`,{className:`flex items-center gap-2`,children:[f(`span`,{className:`tcp-badge-err`,children:[O.length,` issues`]}),f(`span`,{className:`tcp-subtle text-xs`,children:i.issues?`Collapse`:`Expand`})]})]})}),i.issues?O.slice(0,10).map((e,t)=>{let n=String(e?.run_id||e?.id||t).trim(),r=vn(e),i=yn(e),a=Pn(e);return f(`div`,{className:`tcp-list-item`,children:f(`div`,{className:`flex items-center justify-between gap-2`,children:[f(`div`,{className:`grid gap-0.5`,children:[f(`span`,{className:`font-medium text-sm`,children:bn(e)}),f(`span`,{className:`tcp-subtle text-xs`,children:n||`unknown run`}),a?f(`span`,{className:`tcp-subtle text-xs`,children:a}):null,xn(e?.finished_at_ms||e?.finishedAtMs||e?.updated_at_ms||e?.updatedAtMs)?f(`span`,{className:`tcp-subtle text-xs`,children:[`Finished:`,` `,xn(e?.finished_at_ms||e?.finishedAtMs||e?.updated_at_ms||e?.updatedAtMs)]}):null,Sn(e)?f(`span`,{className:`text-xs text-slate-400`,children:Cn(Sn(e),160)}):null,i?f(`span`,{className:`tcp-subtle text-xs`,children:i}):null]}),f(`div`,{className:`flex items-center gap-2`,children:[f(`span`,{className:pn(r),children:r||`failed`}),f(`button`,{className:`tcp-btn h-7 px-2 text-xs`,onClick:()=>Mt(n),children:[f(`i`,{"data-lucide":`bug`}),`Inspect`]})]})]})},`failed-${n||t}`)}):null]}):null,(k.length>0||Ln)&&c===`running`?f(`div`,{className:`grid gap-2`,children:[f(`button`,{type:`button`,className:`tcp-list-item text-left`,onClick:()=>Mn(`history`),"aria-expanded":i.history,children:f(`div`,{className:`flex items-center justify-between gap-2`,children:[f(`div`,{className:`flex items-center gap-2`,children:[f(`i`,{"data-lucide":i.history?`chevron-down`:`chevron-right`}),f(`p`,{className:`text-xs text-slate-500 uppercase tracking-wide font-medium`,children:`Run History`})]}),f(`span`,{className:`flex items-center gap-2`,children:[te?f(C,{tone:`live`,text:`refreshing`}):null,f(`span`,{className:`tcp-subtle text-xs`,children:Ln&&!k.length?`Loading runs`:`${k.length} runs · ${i.history?`Collapse`:`Expand`}`})]})]})}),i.history?Ln&&!k.length?f(S,{title:`Loading automation history…`,text:`Fetching recent legacy and workflow runs`,className:`min-h-[10rem]`}):k.slice(0,12).map((e,t)=>{let n=Pn(e);return f(`div`,{className:`tcp-list-item`,children:[f(`div`,{className:`flex items-center justify-between gap-2`,children:[f(`span`,{className:`font-medium text-sm`,children:bn(e)}),f(`span`,{className:pn(vn(e)),children:vn(e)||`unknown`})]}),f(`div`,{className:`mt-1 flex items-center justify-between gap-2`,children:[f(`div`,{className:`grid gap-0.5`,children:[f(`span`,{className:`tcp-subtle text-xs`,children:String(e?.run_id||e?.id||``)}),n?f(`span`,{className:`tcp-subtle text-xs`,children:n}):null,xn(e?.started_at_ms||e?.startedAtMs||e?.created_at_ms||e?.createdAtMs)?f(`span`,{className:`tcp-subtle text-xs`,children:[`Started:`,` `,xn(e?.started_at_ms||e?.startedAtMs||e?.created_at_ms||e?.createdAtMs)]}):null,e?.finished_at_ms||e?.finishedAtMs?f(`span`,{className:`tcp-subtle text-xs`,children:[`Finished: `,xn(e?.finished_at_ms||e?.finishedAtMs)]}):null,Sn(e)?f(`span`,{className:`text-xs text-slate-400`,children:Cn(Sn(e),160)}):null,yn(e)?f(`span`,{className:`tcp-subtle text-xs`,children:yn(e)}):null]}),f(`button`,{className:`tcp-btn h-7 px-2 text-xs`,onClick:()=>{Mt(String(e?.run_id||e?.id||``).trim()),Nt()},children:[f(`i`,{"data-lucide":`info`}),c===`running`?`Logs`:`Details`]})]})]},String(e?.run_id||e?.id||t))}):null]}):null,!Ln&&!k.length&&c===`running`?f(b,{text:`Run one automation, then use Logs to inspect full execution events.`}):null,!g&&!T.length&&!k.length&&c===`list`?f(b,{text:`No automations yet. Create your first one with the wizard!`}):null,f(Zr,{state:{selectedRunId:c===`running`?ne:``,selectedRun:A,isWorkflowRun:j,runStatus:re,runStatusDerivedNote:M,canContinueBlockedWorkflow:N,continueBlockedNodeId:P,canRecoverWorkflowRun:ie,runDebuggerRetryNodeId:F,selectedContextRunId:ae,runSummaryRows:I,workflowProjection:se,runArtifacts:L,selectedBoardTaskId:R,selectedBoardTask:ce,boardDetailRef:ue,selectedBoardTaskOutput:de,selectedBoardTaskValidationOutcome:fe,selectedBoardTaskWarningCount:pe,selectedBoardTaskTelemetry:z,selectedBoardTaskArtifactValidation:me,selectedBoardTaskIsWorkflowNode:he,selectedBoardTaskIsProjectedBacklogItem:ge,selectedBoardTaskWorkflowClass:_e,selectedBoardTaskPhase:ve,selectedBoardTaskFailureKind:B,selectedBoardTaskQualityMode:V,selectedBoardTaskEmergencyRollbackEnabled:H,selectedBoardTaskBlockerCategory:ye,selectedBoardTaskValidationBasis:U,selectedBoardTaskReceiptLedger:be,selectedBoardTaskArtifactCandidates:xe,selectedBoardTaskWarningRequirements:Se,selectedBoardTaskReceiptTimeline:W,selectedBoardTaskLifecycleEvents:G,selectedBoardTaskResearchReadPaths:Ce,selectedBoardTaskDiscoveredRelevantPaths:we,selectedBoardTaskUnmetResearchRequirements:Te,selectedBoardTaskReviewedPathsBackedByRead:Ee,selectedBoardTaskUnreviewedRelevantPaths:De,selectedBoardTaskVerificationOutcome:Oe,selectedBoardTaskVerificationPassed:ke,selectedBoardTaskVerificationResults:Ae,selectedBoardTaskFailureDetail:je,selectedBoardTaskRelatedPaths:Me,selectedBoardTaskRelatedArtifacts:Ne,selectedBoardTaskNodeId:Pe,selectedBoardTaskStateNormalized:Fe,selectedBoardTaskImpactSummary:Ie,selectedBoardTaskResetOutputPaths:Le,canTaskContinue:Re,canTaskRetry:ze,canTaskRequeue:K,canBacklogTaskClaim:Be,canBacklogTaskRequeue:Ve,selectedBoardTaskTouchedFiles:He,selectedBoardTaskUndeclaredFiles:Ue,selectedBoardTaskRequestedQualityMode:We,selectedSessionId:q,selectedSessionFilterId:Ge,availableSessionIds:Ke,sessionLogEntries:qe,sessionLogRef:Je,selectedLogSource:Ye,telemetryEvents:Xe,filteredRunEventEntries:Ze,blockers:Qe,runHints:$e,runRepairGuidanceEntries:et,artifactsSectionRef:tt,runArtifactEntries:nt,selectedRunArtifactKey:rt,runHistoryEvents:it,workflowContextRun:at,workflowBlackboard:ot},actions:{onSelectRunId:Mt,onRefresh:Kt,onClose:()=>{qt(``),Mt(``)},onSelectBoardTaskId:qt,focusArtifactEntry:Jt,onSessionFilterChange:Yt,onCopySessionLog:Xt,onJumpToLatest:()=>{Zt(!0);let e=Je.current;e&&(e.scrollTop=e.scrollHeight)},onPinnedStateChange:Zt,onSelectLogSource:Qt,onFocusNode:e=>qt(`node-${e}`),onToggleArtifact:e=>$t(t=>t===e?``:e),onCopyFullDebugContext:en,navigate:Rt,workflowTaskContinueMutation:tn,workflowTaskRetryMutation:nn,workflowTaskRequeueMutation:rn,workflowTaskDispositionMutation:an,workflowRepairMutation:on,workflowRecoverMutation:sn,backlogTaskClaimMutation:ln,backlogTaskRequeueMutation:un,runActionMutation:dn,taskResetPreviewQuery:fn},helpers:{runTimeLabel:wn,workflowCompletedNodeCount:Tn,workflowBlockedNodeCount:En,workflowActiveSessionCount:Dn,statusColor:pn,isActiveRunStatus:kn,compactIdentifier:An,sessionLabel:J,formatTimestampLabel:Y}}),f(Dr,{editDraft:st,setEditDraft:zt,updateAutomationMutation:Bt}),f(kr,{workflowEditDraft:ct,setWorkflowEditDraft:vt,validateWorkspaceRootInput:Vt,validateModelInput:Ht,validatePlannerModelInput:Ut,automationWizardConfig:Wt,providerOptions:dt,mcpServers:ft,overlapHistoryEntries:ut,runNowV2Mutation:bt,updateWorkflowAutomationMutation:Gt,automationsV2List:pt??[],client:mt,onRecreateWorkflowAutomation:Pt}),f(Ar,{deleteConfirm:lt,setDeleteConfirm:It,automationActionMutation:Ct})]})}function $r(t,{cap:n,getId:r}){let a=i([]),s=i(null),c=i(t);c.current=t;let l=o(()=>{s.current=null;let e=a.current;e.length&&(a.current=[],c.current(t=>{let i=r?new Set(t.map(r)):null,a=null;for(let n of e){if(r&&i){let e=r(n);if(i.has(e))continue;i.add(e)}a||=t.slice(),a.push(n)}if(!a)return t;let o=a.length-n;return o>0&&a.splice(0,o),a}))},[n,r]);return e(()=>()=>{s.current!=null&&(cancelAnimationFrame(s.current),s.current=null)},[]),o(e=>{a.current.push(e),s.current??=requestAnimationFrame(l)},[l])}function ei({enabled:t,availableSessionIds:n,queryClient:r,selectedRunId:i,selectedContextRunId:a,onSelectRunId:o,setSelectedSessionId:s,setSelectedSessionFilterId:c,setRunEvents:l,setSelectedLogSource:u,setSelectedBoardTaskId:d,setSessionEvents:f,setSessionLogPinnedToBottom:p}){e(()=>{t&&s(e=>e&&n.includes(e)?e:n[0]||``)},[n,t,s]),e(()=>{t&&c(e=>e===`all`||e&&n.includes(e)?e:`all`)},[n,t,c]),e(()=>{t&&(l([]),u(`all`),d(``),f([]),p(!0))},[i,a,l,u,d,f,p,t]),e(()=>{if(!t||!i)return;let e=()=>{Promise.all([r.invalidateQueries({queryKey:[`automations`,`run`,i]}),r.invalidateQueries({queryKey:[`automations`,`run`,`events`,i]}),r.invalidateQueries({queryKey:[`automations`,`run`,`artifacts`,i]}),a?r.invalidateQueries({queryKey:[`automations`,`run`,`context`,a]}):Promise.resolve(),a?r.invalidateQueries({queryKey:[`automations`,`run`,`context`,a,`blackboard`]}):Promise.resolve(),a?r.invalidateQueries({queryKey:[`automations`,`run`,`context`,a,`events`]}):Promise.resolve(),a?r.invalidateQueries({queryKey:[`automations`,`run`,`context`,a,`patches`]}):Promise.resolve(),r.invalidateQueries({queryKey:[`automations`,`run`,`session`,i]})])},n=()=>{document.visibilityState===`visible`&&e()};return window.addEventListener(`focus`,e),document.addEventListener(`visibilitychange`,n),()=>{window.removeEventListener(`focus`,e),document.removeEventListener(`visibilitychange`,n)}},[t,r,a,i]),e(()=>{if(!t||!i)return;let e=e=>{e.key===`Escape`&&o(``)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,o,i])}function ti({client:t,toast:n,queryClient:r,selectedRunId:i,selectedBoardTaskId:a,onSelectRunId:o,onOpenRunningView:s}){let c=u({mutationFn:e=>t?.automations?.runNow?.(e),onSuccess:async()=>{n(`ok`,`Automation triggered.`),await r.invalidateQueries({queryKey:[`automations`]})},onError:e=>n(`err`,e instanceof Error?e.message:String(e))}),l=u({mutationFn:async({id:e,executionProfile:n})=>{if(!t?.automationsV2?.runNow)throw Error(`Workflow run now is not available in this client.`);return t.automationsV2.runNow(e,n?{executionProfile:n}:void 0)},onSuccess:async e=>{let t=String(e?.run?.run_id||e?.run?.runId||``).trim();n(`ok`,`Workflow automation triggered.`),await r.invalidateQueries({queryKey:[`automations`]}),t&&(o(t),s())},onError:e=>n(`err`,e instanceof Error?e.message:String(e))}),d=e=>{let t=e instanceof Error?e.message:String(e??``),n=t.indexOf(`{`);if(n>=0)try{let e=JSON.parse(t.slice(n));return{code:String(e?.code||``).trim(),message:String(e?.error||e?.message||``).trim()}}catch{}return{code:``,message:t}},f=(e,t)=>{let{code:n,message:r}=d(e);return n===`AUTOMATION_V2_RUN_TASK_NOT_MUTABLE`||n===`AUTOMATION_V2_RUN_NOT_RECOVERABLE`?`Run is still active. Pause or cancel it first, then retry.`:r||t},p=e=>{let{code:t}=d(e);return t===`AUTOMATION_V2_RUN_TASK_NOT_MUTABLE`||t===`AUTOMATION_V2_RUN_NOT_RECOVERABLE`},m=async(e,n)=>{try{return await n()}catch(r){if(!p(r)||!t?.automationsV2?.pauseRun)throw r;try{await t.automationsV2.pauseRun(e,`auto-pause for retry`)}catch{}return await new Promise(e=>setTimeout(e,400)),await n()}},h=u({mutationFn:async({action:e,runId:n,family:r,reason:i})=>{if(r===`v2`)return e===`cancel`?t.automationsV2.cancelRun(n,i):e===`pause`?t.automationsV2.pauseRun(n,i):t.automationsV2.resumeRun(n,i);if(e===`cancel`)throw Error(`Cancel is only available for workflow runs in this client.`);return e===`pause`?t.automations.pauseRun(n,i):t.automations.resumeRun(n,i)},onSuccess:async(e,t)=>{t.action===`cancel`?n(`ok`,`Run cancelled.`):n(`ok`,`Run action applied.`),await r.invalidateQueries({queryKey:[`automations`]})},onError:e=>n(`err`,e instanceof Error?e.message:String(e))}),g=u({mutationFn:async({runId:e,nodeId:n,reason:r})=>{if(!t?.automationsV2?.repairRun)throw Error(`Workflow repair is not available in this client.`);return m(e,()=>t.automationsV2.repairRun(e,{node_id:n,reason:r??``}))},onSuccess:async e=>{let t=String(e?.run?.run_id||e?.run?.runId||i||``).trim();n(`ok`,`Workflow continued from blocked step.`),await r.invalidateQueries({queryKey:[`automations`]}),t&&(o(t),s())},onError:e=>n(`err`,f(e,`Workflow repair failed.`))}),_=u({mutationFn:async({runId:e,reason:n})=>{if(!t?.automationsV2?.recoverRun)throw Error(`Workflow retry is not available in this client.`);return m(e,()=>t.automationsV2.recoverRun(e,n))},onSuccess:async e=>{let t=String(e?.run?.run_id||e?.run?.runId||i||``).trim();n(`ok`,`Workflow run queued again.`),await r.invalidateQueries({queryKey:[`automations`]}),t&&(o(t),s())},onError:e=>n(`err`,f(e,`Workflow retry failed.`))}),v=u({mutationFn:async({runId:e,nodeId:n,reason:r})=>{if(!t?.automationsV2?.retryTask)throw Error(`Task retry is not available in this client.`);return m(e,()=>t.automationsV2.retryTask(e,n,r))},onSuccess:async e=>{let t=String(e?.run?.run_id||e?.run?.runId||i||``).trim();n(`ok`,`Task retried and subtree requeued.`),await r.invalidateQueries({queryKey:[`automations`]}),t&&(o(t),s())},onError:e=>n(`err`,f(e,`Task retry failed.`))}),y=u({mutationFn:async({runId:e,nodeId:n,reason:r})=>{if(!t?.automationsV2?.continueTask)throw Error(`Task continue is not available in this client.`);return m(e,()=>t.automationsV2.continueTask(e,n,r))},onSuccess:async e=>{let t=String(e?.run?.run_id||e?.run?.runId||i||``).trim();n(`ok`,`Blocked task continued with minimal reset.`),await r.invalidateQueries({queryKey:[`automations`]}),t&&(o(t),s())},onError:e=>n(`err`,f(e,`Task continue failed.`))}),b=u({mutationFn:async({runId:e,nodeId:n,reason:r})=>{if(!t?.automationsV2?.requeueTask)throw Error(`Task requeue is not available in this client.`);return m(e,()=>t.automationsV2.requeueTask(e,n,r))},onSuccess:async e=>{let t=String(e?.run?.run_id||e?.run?.runId||i||``).trim();n(`ok`,`Task requeued and subtree reset.`),await r.invalidateQueries({queryKey:[`automations`]}),t&&(o(t),s())},onError:e=>n(`err`,f(e,`Task requeue failed.`))}),x=u({mutationFn:async({runId:e,nodeId:n,disposition:r,reason:i})=>{if(!t?.automationsV2?.setTaskDisposition)throw Error(`Task disposition is not available in this client.`);return t.automationsV2.setTaskDisposition(e,n,r,i)},onSuccess:async e=>{let t=String(e?.run?.run_id||e?.run?.runId||i||``).trim(),a=String(e?.disposition||``);n(`ok`,e?.changed===!0?`Marked artifact as ${a.replace(/_/g,` `)}.`:`Already marked ${a.replace(/_/g,` `)}.`),await r.invalidateQueries({queryKey:[`automations`]}),t&&o(t)},onError:e=>n(`err`,f(e,`Disposition update failed.`))}),S=u({mutationFn:async({runId:e,taskId:n,agentId:r,reason:i})=>{if(!t?.automationsV2?.claimBacklogTask)throw Error(`Backlog task claim is not available in this client.`);return t.automationsV2.claimBacklogTask(e,n,{agent_id:r,reason:i})},onSuccess:async()=>{n(`ok`,`Backlog task claimed.`),await r.invalidateQueries({queryKey:[`automations`]}),i&&(o(i),s())},onError:e=>n(`err`,e instanceof Error?e.message:String(e))}),C=u({mutationFn:async({runId:e,taskId:n,reason:r})=>{if(!t?.automationsV2?.requeueBacklogTask)throw Error(`Backlog task requeue is not available in this client.`);return t.automationsV2.requeueBacklogTask(e,n,r)},onSuccess:async()=>{n(`ok`,`Backlog task requeued.`),await r.invalidateQueries({queryKey:[`automations`]}),i&&(o(i),s())},onError:e=>n(`err`,e instanceof Error?e.message:String(e))});return e(()=>{h.reset(),g.reset(),_.reset(),v.reset(),y.reset(),b.reset(),x.reset(),S.reset(),C.reset()},[S,C,h,a,i,_,g,y,x,b,v]),{runNowMutation:c,runNowV2Mutation:l,runActionMutation:h,workflowRepairMutation:g,workflowRecoverMutation:_,workflowTaskRetryMutation:v,workflowTaskContinueMutation:y,workflowTaskRequeueMutation:b,workflowTaskDispositionMutation:x,backlogTaskClaimMutation:S,backlogTaskRequeueMutation:C}}function ni({selectedRunId:t,selectedSessionId:n,selectedContextRunId:r,isWorkflowRun:a,runInspectorActive:s,timestampOrNull:c,appendRunEvent:l,appendSessionEvent:u,queryClient:d}){let f=i(null),p=i({run:!1,blackboard:!1,events:!1,patches:!1}),m=i(()=>{});m.current=()=>{f.current=null;let e=p.current;p.current={run:!1,blackboard:!1,events:!1,patches:!1};let n=[];e.run&&r&&n.push(d.invalidateQueries({queryKey:[`automations`,`run`,`context`,r]})),e.blackboard&&r&&n.push(d.invalidateQueries({queryKey:[`automations`,`run`,`context`,r,`blackboard`]})),e.events&&r&&n.push(d.invalidateQueries({queryKey:[`automations`,`run`,`context`,r,`events`]})),e.patches&&r&&n.push(d.invalidateQueries({queryKey:[`automations`,`run`,`context`,r,`patches`]})),e.run&&t&&n.push(d.invalidateQueries({queryKey:[`automations`,`run`,t]})),n.length&&Promise.all(n)};let h=o(e=>{let t=p.current;e.run&&(t.run=!0),e.blackboard&&(t.blackboard=!0),e.events&&(t.events=!0),e.patches&&(t.patches=!0),f.current??=requestAnimationFrame(()=>m.current())},[]);e(()=>()=>{f.current!=null&&(cancelAnimationFrame(f.current),f.current=null)},[]),De(t?a?`/api/engine/automations/v2/events?run_id=${encodeURIComponent(t)}`:`/api/engine/automations/events?run_id=${encodeURIComponent(t)}`:``,e=>{try{let n=JSON.parse(String(e?.data||`{}`));if(!n||n.status===`ready`)return;let r=ie(n);if(!r||r!==t)return;let i=ue(n),a=L(n);if(l({id:`automations:${r}:${i}:${a}:${Math.random().toString(16).slice(2,8)}`,source:`automations`,at:a,event:n}),i){let e=String(i).toLowerCase();(e.includes(`artifact`)||e.includes(`blackboard`)||e.includes(`patch`))&&h({blackboard:!0,patches:!0}),(e.includes(`task`)||e.includes(`node`)||e.endsWith(`.updated`))&&h({run:!0})}}catch{return}},{enabled:s}),De(r?`/api/engine/context/runs/${encodeURIComponent(r)}/events/stream?tail=50`:``,e=>{try{let t=JSON.parse(String(e?.data||`{}`));if(!t||t.status===`ready`)return;l({id:`context:${String(t?.seq||``)}:${String(t?.event_type||``)}`,source:`context`,at:c(t?.created_at_ms||t?.timestamp_ms||t?.timestampMs)||Date.now(),event:t});let n=String(t?.event_type||``).toLowerCase(),r={events:!0};(n.includes(`blackboard`)||n.includes(`patch`)||n.includes(`artifact`)||n.includes(`task`))&&(r.blackboard=!0,r.patches=!0),(n.includes(`run`)||n.includes(`status`)||n.includes(`phase`))&&(r.run=!0),h(r)}catch{return}},{enabled:s&&!!r}),De(t&&n?`/api/engine/event?sessionID=${encodeURIComponent(n)}&runID=${encodeURIComponent(t)}`:``,e=>{try{let r=JSON.parse(String(e?.data||`{}`));if(!r)return;let i=ue(r),a=L(r);u({id:[i||`event`,String(r?.properties?.sessionID||r?.sessionID||n||``),String(r?.properties?.runID||r?.runID||t||``),String(r?.properties?.messageID||r?.messageID||``),String(r?.properties?.part?.id||r?.properties?.seq||r?.timestamp_ms||a)].join(`:`),at:a,event:r})}catch{return}},{enabled:s&&!!n}),De(t?`/api/global/event`:``,e=>{try{let n=JSON.parse(String(e?.data||`{}`)),r=ie(n);if(!r||r!==t)return;let i=ue(n);if(!i||i===`server.connected`||i===`engine.lifecycle.ready`)return;let a=L(n);l({id:`global:${r}:${i}:${a}:${Math.random().toString(16).slice(2,8)}`,source:`global`,at:a,event:n})}catch{return}},{enabled:s})}function ri({toast:e,scheduleToEditor:t,setEditDraft:n,isMissionBlueprintAutomation:r,onOpenAdvancedEdit:i,getAutomationCalendarFamily:a,workflowAutomationToEditDraft:o,setWorkflowEditDraft:s,rewriteCronForDroppedStart:c,updateAutomationMutation:l,updateWorkflowAutomationMutation:u}){let d=r=>{let i=String(r?.automation_id||r?.id||r?.routine_id||``).trim();if(!i){e(`err`,`Cannot edit automation without an id.`);return}let a=t(r?.schedule);n({automationId:i,name:String(r?.name||i||``).trim(),objective:String(r?.mission?.objective||r?.mission_snapshot?.objective||``).trim(),mode:String(r?.mode||``).toLowerCase()===`standalone`?`standalone`:`orchestrated`,requiresApproval:r?.requires_approval===!0||r?.policy?.approval?.requires_approval===!0,scheduleKind:a.scheduleKind===`cron`?`cron`:`interval`,cronExpression:a.cronExpression,intervalSeconds:String(a.intervalSeconds)})};return{beginEdit:d,isPausedAutomation:e=>{let t=String(e?.status||``).trim().toLowerCase();return t===`paused`||t===`disabled`},openCalendarAutomationEdit:t=>{if(!t)return;if(r(t)){i(t);return}if(a(t)===`legacy`){d(t);return}let n=o(t);if(!n){e(`err`,`Cannot open this workflow automation for editing.`);return}s(n)},updateCalendarAutomationFromEvent:async n=>{let r=n?.event,i=r?.extendedProps?.automation,a=String(r?.extendedProps?.family||`legacy`).trim()===`v2`?`v2`:`legacy`,s=String(r?.extendedProps?.cronExpression||``).trim(),d=r?.start?new Date(r.start):null,f=d?c(s,d):null;if(!i||!d||!f){n?.revert?.(),e(`info`,`That schedule cannot be moved from the calendar yet.`);return}try{if(a===`legacy`){let e=String(i?.automation_id||i?.id||i?.routine_id||``).trim(),n=t(i?.schedule);await l.mutateAsync({automationId:e,name:String(i?.name||e||``).trim(),objective:String(i?.mission?.objective||i?.mission_snapshot?.objective||``).trim(),mode:String(i?.mode||``).toLowerCase()===`standalone`?`standalone`:`orchestrated`,requiresApproval:i?.requires_approval===!0||i?.policy?.approval?.requires_approval===!0,scheduleKind:`cron`,cronExpression:f,intervalSeconds:String(n.intervalSeconds||3600)});return}let e=o(i);if(!e)throw Error(`Workflow automation draft could not be created.`);await u.mutateAsync({...e,scheduleKind:`cron`,cronExpression:f,intervalSeconds:e.intervalSeconds||`3600`})}catch(t){n?.revert?.(),e(`err`,t instanceof Error?t.message:String(t))}}}}function ii(e,t){return r(()=>{let n=[];for(let r of e){let e=String(r?.automation_id||r?.automationId||r?.id||``).trim(),i=String(r?.name||``).trim(),a=r?.metadata?.plan_package||r?.metadata?.planPackage,o=t(a?.overlap_policy,`overlap_log`),s=String(a?.plan_id||a?.planId||e||``).trim(),c=Number(a?.plan_revision||a?.planRevision||0),l=String(a?.lifecycle_state||a?.lifecycleState||r?.status||``).trim();for(let t of o)n.push({rowKey:[e||s||`automation`,String(t?.matched_plan_id||t?.matchedPlanId||``),String(t?.matched_plan_revision||t?.matchedPlanRevision||``),String(t?.decision||``),String(t?.decided_at||t?.decidedAt||``)].join(`:`),sourceLabel:i||e||s||`workflow plan`,sourceAutomationId:e,sourcePlanId:s,sourcePlanRevision:Number.isFinite(c)?c:0,sourceLifecycleState:l,matchedPlanId:String(t?.matched_plan_id||t?.matchedPlanId||``).trim(),matchedPlanRevision:Number(t?.matched_plan_revision||t?.matchedPlanRevision||0),matchLayer:String(t?.match_layer||t?.matchLayer||``).trim(),similarityScore:t?.similarity_score??t?.similarityScore??null,decision:String(t?.decision||``).trim(),decidedBy:String(t?.decided_by||t?.decidedBy||``).trim(),decidedAt:String(t?.decided_at||t?.decidedAt||``).trim()})}return n.sort((e,t)=>{let n=Number(Date.parse(String(e.decidedAt||``))),r=Number(Date.parse(String(t.decidedAt||``)));return Number.isFinite(n)&&Number.isFinite(r)&&n!==r?r-n:String(e.sourcePlanId||e.sourceAutomationId||e.rowKey).localeCompare(String(t.sourcePlanId||t.sourceAutomationId||t.rowKey))})},[e,t])}function ai({isWorkflowRun:e,runArtifacts:t,runStatus:n,runStatusDerivedNote:i,selectedRun:a,workflowContextEvents:o,workflowContextPatches:s,workflowProjection:c}){return r(()=>{let r=[];r.push({label:`status`,value:n||`unknown`}),i&&r.push({label:`status note`,value:i});let l=Re(a),u=ze(a),d=u&&u!==l?`${Ie(l)} (requested ${Ie(u)})`:Ie(l);return r.push({label:`execution profile`,value:d}),r.push({label:`artifacts`,value:String(t.length)}),e&&(r.push({label:`tasks`,value:String(c.tasks.length)}),r.push({label:`context events`,value:String(o.length)}),r.push({label:`blackboard patches`,value:String(s.length)}),r.push({label:`completed nodes`,value:String(le(a))}),r.push({label:`pending nodes`,value:String(A(a))}),r.push({label:`blocked nodes`,value:String(oe(a))})),String(a?.detail||``).trim()&&r.push({label:`detail`,value:String(a.detail).trim()}),a?.requires_approval!==void 0&&r.push({label:`requires approval`,value:String(!!a?.requires_approval)}),String(a?.approval_reason||``).trim()&&r.push({label:`approval reason`,value:String(a.approval_reason).trim()}),String(a?.denial_reason||``).trim()&&r.push({label:`denial reason`,value:String(a.denial_reason).trim()}),String(a?.paused_reason||``).trim()&&r.push({label:`paused reason`,value:String(a.paused_reason).trim()}),r},[e,t.length,n,i,a,o.length,s.length,c.tasks.length])}function oi({selectedSessionFilterId:t,selectedSessionId:n,sessionMessageCreatedAt:i,sessionMessageId:a,sessionMessageParts:o,sessionMessageText:s,sessionMessageVariant:c,sessionMessages:l,sessionEvents:u,sessionLabel:d,sessionLogRef:f,sessionLogPinnedToBottom:p}){let m=r(()=>{let e=l.map(({sessionId:e,message:t},n)=>({id:`message:${e}:${a(t,n)}`,kind:`message`,sessionId:e,at:i(t),variant:c(t),label:String(t?.info?.role||`session`).trim()||`session`,body:s(t),raw:t,parts:o(t),sessionLabel:d(e)})),r=T(u,n).map(e=>({...e,sessionLabel:d(F(e.raw,n))})),f=[...e,...r].sort((e,t)=>e.at-t.at);return t===`all`?f:f.filter(e=>e.sessionId===t)},[t,n,i,a,o,s,c,l,u,d]);return e(()=>{let e=f.current;!e||!p||(e.scrollTop=e.scrollHeight)},[m,p]),m}function si(t,n){e(()=>{let e=t.current;e&&h(e)},n)}function ci({client:t,toast:n,navigate:o,viewMode:d,selectedRunId:p,onSelectRunId:m,onOpenRunningView:h,onOpenAdvancedEdit:g,onRecreateWorkflowAutomation:y,defaultRunningSectionsOpen:b,helperFns:x,automationWizardConfig:S}){let{toArray:C,normalizeMcpServers:w,validateModelInput:T,validatePlannerModelInput:D,validateWorkspaceRootInput:O,workflowEditToOperatorPreferences:A,compileWorkflowModelPolicy:N,cloneJsonValue:ie,compileWorkflowToolAllowlist:F,parseConnectorBindingsJson:ae,workflowNodeModelPolicyWithOverride:oe,deriveConnectorBindingResolutionFromPlanPackage:L,workflowAutomationToEditDraft:R,isMissionBlueprintAutomation:le,workflowEditToSchedule:ue,buildCalendarOccurrences:pe,normalizeTimestamp:z,workflowQueueReason:_e,detectWorkflowActiveTaskId:B,detectWorkflowActiveTaskIds:V,workflowDescendantTaskIds:H,deriveRunDebugHints:ye,explainRunFailure:U,buildRunBlockers:be,isStandupAutomation:xe,getAutomationCalendarFamily:Se,rewriteCronForDroppedStart:W,statusColor:G,formatScheduleLabel:Ce,formatAutomationV2ScheduleLabel:we,workflowStatusDisplay:Te,workflowStatusSubtleDetail:Ee,runDisplayTitle:De,formatRunDateTime:Oe,runObjectiveText:ke,shortText:je,runTimeLabel:Me,compactIdentifier:Ne,sessionLabel:Pe,formatTimestampLabel:Fe,isActiveRunStatus:Ie,scheduleToEditor:Le,uniqueStrings:Re,collectPathStrings:ze,timestampOrNull:K,sessionMessageId:Be,sessionMessageCreatedAt:Ve,sessionMessageVariant:He,sessionMessageText:Ue,sessionMessageParts:We}=x,q=s(),Ge=i(null),[Ke,qe]=a(null),[Je,Ye]=a(null),[Xe,Ze]=a(`all`),[Qe,$e]=a([]),[et,tt]=a(``),[nt,rt]=a(`all`),[it,at]=a(``),[ot,st]=a(``),[ct,lt]=a([]),ut=i(null),dt=i(null),ft=i(null),[pt,mt]=a(!1),[ht,gt]=a(null),[_t,vt]=a(()=>{let e=new Date,t=e.getUTCDay(),n=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()-t,0,0,0,0));return{startMs:n.getTime(),endMs:n.getTime()+10080*60*1e3}}),yt=p.startsWith(`automation-v2-run-`),xt=d===`running`&&!!p,St=c({queryKey:[`automations`,`list`],queryFn:()=>t?.automations?.list?.().catch(()=>({automations:[]}))??Promise.resolve({automations:[]}),refetchInterval:2e4}),Dt=c({queryKey:[`automations`,`v2`,`list`],queryFn:()=>t?.automationsV2?.list?.().catch(()=>({automations:[]}))??Promise.resolve({automations:[]}),refetchInterval:2e4}),kt=r(()=>{let e=C(Dt.data,`automations`),t=new Map;for(let n of e){let e=String(n?.automation_id||n?.automationId||n?.id||``).trim();e&&(t.has(e)||t.set(e,n))}return Array.from(t.values())},[Dt.data,C]),At=ii(kt,C),Nt=c({queryKey:[`providers`,`catalog`,`workflow-edit`],queryFn:()=>t?.providers?.catalog?.().catch(()=>({all:[]}))??Promise.resolve({all:[]}),refetchInterval:3e4}),Ft=c({queryKey:[`providers`,`config`,`workflow-edit`],queryFn:()=>t?.providers?.config?.().catch(()=>({providers:{}}))??Promise.resolve({providers:{}}),refetchInterval:3e4}),Lt=c({queryKey:[`mcp`,`servers`,`workflow-edit`],queryFn:()=>t?.mcp?.list?.().catch(()=>({servers:[]}))??Promise.resolve({servers:[]}),refetchInterval:15e3}),Bt=c({queryKey:[`automations`,`runs`],queryFn:()=>t?.automations?.listRuns?.({limit:20}).catch(()=>({runs:[]}))??Promise.resolve({runs:[]}),refetchInterval:9e3}),Ht=c({queryKey:[`automations`,`v2`,`runs`,`all`],queryFn:()=>_(`/api/engine/automations/v2/runs?limit=40`).catch(()=>({runs:[]})),refetchInterval:9e3}),Ut=c({queryKey:[`automations`,`run`,p],enabled:xt,queryFn:()=>(yt?t?.automationsV2?.getRun?.(p):t?.automations?.getRun?.(p))?.catch(()=>({run:null}))??Promise.resolve({run:null}),refetchInterval:xt?5e3:!1}),Wt=c({queryKey:[`automations`,`run`,`artifacts`,p],enabled:xt&&!yt,queryFn:()=>t?.automations?.listArtifacts?.(p).catch(()=>({artifacts:[]})),refetchInterval:xt?8e3:!1}),Gt=c({queryKey:[`automations`,`run`,`task-reset-preview`,p,it],enabled:xt&&yt&&String(it||``).startsWith(`node-`)&&!!String(it||``).trim()&&!!t?.automationsV2?.previewTaskReset,queryFn:()=>t?.automationsV2?.previewTaskReset(p,String(it||``).replace(/^node-/,``).trim()).catch(()=>({preview:null}))??Promise.resolve({preview:null}),refetchInterval:!1}),Kt=r(()=>se(Ut.data?.run),[Ut.data]),qt=l({queries:Kt.map(e=>({queryKey:[`automations`,`run`,`session`,p,e,`messages`],enabled:xt&&!!e,queryFn:()=>t?.sessions?.messages?.(e).catch(()=>[])??Promise.resolve([]),refetchInterval:xt&&e&&Ie(Ut.data?.run?.status)?4e3:!1}))}),Jt=String(Ut.data?.run?.automation_id||Ut.data?.run?.routine_id||``).trim(),Yt=String((xt?Ut.data?.contextRunID:``)||(xt&&yt&&p?`automation-v2-${p}`:``)).trim(),Xt=c({queryKey:[`automations`,`history`,Jt],enabled:xt&&!!Jt&&!yt,queryFn:()=>t?.automations?.history?.(Jt,80).catch(()=>({events:[]})),refetchInterval:xt?1e4:!1}),Zt=c({queryKey:[`automations`,`run`,`events`,p],enabled:xt&&!!t?.runEvents,queryFn:()=>t.runEvents(p,{tail:400}).catch(()=>[]),refetchInterval:xt&&Ie(Ut.data?.run?.status)?5e3:!1}),Qt=Yt&&Ie(Ut.data?.run?.status)?3e4:!1,$t=c({queryKey:[`automations`,`run`,`context`,Yt],enabled:xt&&!!Yt,queryFn:()=>_(`/api/engine/context/runs/${encodeURIComponent(Yt)}`).catch(()=>({run:null})),refetchInterval:Qt}),en=c({queryKey:[`automations`,`run`,`context`,Yt,`blackboard`],enabled:xt&&!!Yt,queryFn:()=>_(`/api/engine/context/runs/${encodeURIComponent(Yt)}/blackboard`).catch(()=>({blackboard:null})),refetchInterval:!1}),tn=c({queryKey:[`automations`,`run`,`context`,Yt,`events`],enabled:xt&&!!Yt,queryFn:()=>_(`/api/engine/context/runs/${encodeURIComponent(Yt)}/events`).catch(()=>({events:[]})),refetchInterval:Qt}),nn=c({queryKey:[`automations`,`run`,`context`,Yt,`patches`],enabled:xt&&!!Yt,queryFn:()=>_(`/api/engine/context/runs/${encodeURIComponent(Yt)}/blackboard/patches`).catch(()=>({patches:[]})),refetchInterval:Qt}),rn=c({queryKey:[`automations`,`packs`],queryFn:()=>t?.packs?.list?.().catch(()=>({packs:[]}))??Promise.resolve({packs:[]}),refetchInterval:3e4}),{runNowMutation:an,runNowV2Mutation:on,runActionMutation:sn,workflowRepairMutation:cn,workflowRecoverMutation:ln,workflowTaskRetryMutation:un,workflowTaskContinueMutation:dn,workflowTaskRequeueMutation:fn,workflowTaskDispositionMutation:pn,backlogTaskClaimMutation:mn,backlogTaskRequeueMutation:hn}=ti({client:t,toast:n,queryClient:q,selectedRunId:p,selectedBoardTaskId:it,onSelectRunId:m,onOpenRunningView:h}),gn=u({mutationFn:async e=>{let n=String(e.name||``).trim(),r=String(e.objective||``).trim(),i=String(e.cronExpression||``).trim(),a=Number(e.intervalSeconds);if(!n)throw Error(`Automation name is required.`);if(!r)throw Error(`Objective is required.`);if(e.scheduleKind===`cron`&&!i)throw Error(`Cron expression is required.`);if(e.scheduleKind===`interval`&&(!Number.isFinite(a)||a<=0))throw Error(`Interval seconds must be greater than zero.`);return t.automations.update(e.automationId,{name:n,mode:e.mode,mission:{objective:r},policy:{approval:{requires_approval:!!e.requiresApproval}},schedule:e.scheduleKind===`cron`?{cron:{expression:i}}:{interval_seconds:{seconds:Math.round(a)}}})},onSuccess:async()=>{n(`ok`,`Automation updated.`),Ye(null),await q.invalidateQueries({queryKey:[`automations`]})},onError:e=>n(`err`,e instanceof Error?e.message:String(e))}),_n=u({mutationFn:async e=>{let n=String(e.name||``).trim(),r=String(e.description||``).trim(),i=String(e.workspaceRoot||``).trim(),a=T(e.modelProvider,e.modelId),o=D(e.plannerModelProvider,e.plannerModelId),s=O(i);if(!n)throw Error(`Automation name is required.`);if(s)throw Error(s);if(a)throw Error(a);if(o)throw Error(o);if(e.scheduleKind===`cron`&&!String(e.cronExpression||``).trim())throw Error(`Cron expression is required.`);if(e.scheduleKind===`interval`&&(!Number.isFinite(Number(e.intervalSeconds))||Number(e.intervalSeconds)<=0))throw Error(`Interval seconds must be greater than zero.`);let c=A(e),l=N(c),u=l?ie(l):null,d=e.selectedMcpServers.map(e=>String(e||``).trim()).filter(Boolean),f=F(d,e.toolAccessMode,e.customToolsText,e.selectedMcpTools,e.mcpOtherAllowedTools),p=ae(e.connectorBindingsJson),m=Re(String(e.sharedContextPackIdsText||``).split(/[\n,]/g).map(e=>String(e||``).trim()).filter(Boolean)),h=m.map(e=>({pack_id:e,required:!0})),g=new Map;for(let t of e.nodes){let e=String(t.agentId||``).trim();if(!e)continue;let n=String(t.modelProvider||``).trim(),r=String(t.modelId||``).trim(),i=T(n,r);if(i)throw Error(`${t.title||t.nodeId||e}: ${i}`);g.set(e,oe(u,n,r))}let _=e.scopeSnapshot?ie(e.scopeSnapshot):null;_&&typeof _==`object`&&(_.connector_bindings=p,_.connector_binding_resolution=L(_,p));let v=kt.find(t=>String(t?.automation_id||t?.automationId||t?.id||``).trim()===e.automationId),y=Array.isArray(v?.agents)?v.agents.map(t=>{let n=String(t?.agent_id||t?.agentId||``).trim(),r=g.has(n)?g.get(n):t?.model_policy||t?.modelPolicy||l;return{...t,model_policy:r?ie(r):null,modelPolicy:void 0,tool_policy:{...t?.tool_policy||{},allowlist:f,denylist:Array.isArray(t?.tool_policy?.denylist)?t.tool_policy.denylist:[]},mcp_policy:{...t?.mcp_policy||{},allowed_servers:d,allowed_tools:e.toolAccessMode===`all`?null:Array.isArray(e.selectedMcpTools)?[...e.mcpOtherAllowedTools,...e.selectedMcpTools]:e.mcpOtherAllowedTools}}}):[],b=Array.isArray(v?.flow?.nodes)?v.flow.nodes.map((t,n)=>{let r=String(t?.node_id||t?.nodeId||t?.id||`node-${n}`).trim(),i=e.nodes.find(e=>e.nodeId===r),a=i?.toolAccessMode===`custom`?Array.isArray(i.mcpAllowedTools)?[...i.mcpOtherAllowedTools||[],...i.mcpAllowedTools]:i.mcpOtherAllowedTools||[]:[],o=t?.metadata&&typeof t.metadata==`object`?ie(t.metadata):{},s=o?.approval&&typeof o.approval==`object`?{...o.approval}:{};if(i?.approvalOverride===`skip`)s.skip_approval=!0,delete s.auto_approve_when,delete s.autoApproveWhen;else if(i?.approvalOverride===`auto`){let e=String(i.approvalCondition||``).trim();delete s.skip_approval,delete s.skipApproval,e?s.auto_approve_when=e:(delete s.auto_approve_when,delete s.autoApproveWhen)}else i&&(delete s.skip_approval,delete s.skipApproval,delete s.auto_approve_when,delete s.autoApproveWhen);let c={...o};return Object.keys(s).length>0?c.approval=s:delete c.approval,i?{...t,objective:String(i.objective||``).trim(),metadata:c,...i.approvalOverride===`skip`?{gate:null}:{},tool_policy:i.toolAccessMode===`custom`?{allowlist:[...i.toolAllowlist||[],...i.mcpAllowedTools===null?(i.mcpAllowedServers||[]).map(e=>`mcp.${String(e||``).trim().toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``)||`mcp`}.*`):a].map(e=>String(e||``).trim()).filter(Boolean),denylist:(i.toolDenylist||[]).map(e=>String(e||``).trim()).filter(Boolean)}:void 0,toolPolicy:void 0,mcp_policy:i.toolAccessMode===`custom`?{allowed_servers:(i.mcpAllowedServers||[]).map(e=>String(e||``).trim()).filter(Boolean),allowed_tools:i.mcpAllowedTools===null?null:a.map(e=>String(e||``).trim()).filter(Boolean)}:void 0,mcpPolicy:void 0}:t}):[],x=v?.metadata&&typeof v.metadata==`object`?v.metadata:{},S=_?{...ie(x?.plan_package)||{},..._}:x?.plan_package,C=String(_?.project_key||_?.projectKey||x?.shared_context_project_key||x?.sharedContextProjectKey||``).trim();_&&typeof _==`object`&&(_.shared_context_pack_ids=m,_.shared_context_bindings=h,C&&(_.shared_context_project_key=C),_.shared_context_workspace_root=i);let w=_&&x?.plan_package_bundle?{...ie(x.plan_package_bundle),scope_snapshot:_}:x?.plan_package_bundle;return t.automationsV2.update(e.automationId,{name:n,description:r||null,schedule:ue(e),workspace_root:i,execution:{...v?.execution||{},max_parallel_agents:e.executionMode===`single`?1:Math.max(2,Math.min(16,Number.parseInt(String(e.maxParallelAgents||`4`),10)||4)),...e.executionProfile===`strict`||e.executionProfile===`guided`||e.executionProfile===`yolo`?{profile:e.executionProfile}:{profile:null}},flow:v?.flow?{...v.flow,nodes:b}:v?.flow,agents:y,...e.handoffConfig==null?{}:{handoff_config:e.handoffConfig},...Array.isArray(e.watchConditions)&&e.watchConditions.length>0?{watch_conditions:e.watchConditions}:{},...e.scopePolicy==null?{}:{scope_policy:e.scopePolicy},metadata:{...x,workspace_root:i,operator_preferences:c,allowed_mcp_servers:d,...S?{plan_package:S}:{},...w?{plan_package:w}:{},shared_context_pack_ids:m,shared_context_bindings:h,...C?{shared_context_project_key:C}:{},shared_context_workspace_root:i}})},onSuccess:async()=>{n(`ok`,`Workflow automation updated.`),gt(null),await q.invalidateQueries({queryKey:[`automations`]})},onError:e=>n(`err`,e instanceof Error?e.message:String(e))}),vn=u({mutationFn:async({action:e,automationId:n,family:r})=>r===`v2`?e===`delete`?t.automationsV2.delete(n):e===`pause`?t.automationsV2.pause(n):t.automationsV2.resume(n):e===`delete`?t.automations.delete(n):t.automations.update(n,{status:e===`pause`?`paused`:`enabled`}),onSuccess:async(e,t)=>{t.action===`delete`&&n(`ok`,`Automation removed.`),t.action===`pause`&&n(`ok`,`Automation paused.`),t.action===`resume`&&n(`ok`,`Automation resumed.`),await q.invalidateQueries({queryKey:[`automations`]})},onError:e=>n(`err`,e instanceof Error?e.message:String(e))}),yn=r(()=>{let e=[...C(St.data,`automations`),...C(St.data,`routines`)],t=new Map;for(let n of e){let e=String(n?.automation_id||n?.routine_id||n?.id||``).trim();e&&(t.has(e)||t.set(e,n))}return Array.from(t.values())},[St.data,C]),bn=c({queryKey:[`control-panel`,`preferences`],queryFn:()=>_(`/api/control-panel/preferences`,{method:`GET`}).catch(()=>({preferences:{favorite_automation_ids:[],workflow_library_filters:Ct,workflow_sort_mode:bt}})),retry:!1,staleTime:6e4,refetchInterval:6e4}),xn=bn.data?.preferences||{},Sn=wt(xn.workflow_sort_mode||bt),Cn=r(()=>jt(xn.workflow_library_filters||xn.workflowLibraryFilters||{}),[xn.workflow_library_filters,xn.workflowLibraryFilters]),wn=r(()=>!Mt(Cn,Ct),[Cn]),Tn=r(()=>Rt(xn.favorite_automation_ids||[]),[xn.favorite_automation_ids]),En=r(()=>new Set(Tn),[Tn]),Dn=u({mutationFn:async e=>_(`/api/control-panel/preferences`,{method:`PATCH`,body:JSON.stringify({preferences:e})}),onMutate:async e=>{await q.cancelQueries({queryKey:[`control-panel`,`preferences`]});let t=q.getQueryData([`control-panel`,`preferences`]);return q.setQueryData([`control-panel`,`preferences`],t=>({...t||{},ok:!0,preferences:{...t?.preferences||{},...e}})),{previous:t}},onError:(e,t,n)=>{n?.previous!==void 0&&q.setQueryData([`control-panel`,`preferences`],n.previous)},onSuccess:e=>{q.setQueryData([`control-panel`,`preferences`],e)}}),On=e=>{Dn.mutate({workflow_sort_mode:wt(e),favorite_automation_ids:Tn,workflow_library_filters:Cn})},kn=e=>{Dn.mutate({workflow_library_filters:jt(e),workflow_sort_mode:Sn,favorite_automation_ids:Tn})},An=e=>{let t=String(e||``).trim();t&&kn({...Cn,sources:{...Cn.sources,[t]:!Cn.sources?.[t]}})},J=e=>{let t=String(e||``).trim();t&&kn({...Cn,statuses:{...Cn.statuses,[t]:!Cn.statuses?.[t]}})},Y=()=>{kn(Ct)},jn=e=>{let t=zt(Tn,e);Dn.mutate({favorite_automation_ids:t,workflow_sort_mode:Sn,workflow_library_filters:Cn})},X=r(()=>e=>xe(e)?{key:`standup`,label:`Standup`}:le(e)?{key:`mission_blueprint`,label:`Mission Blueprint`}:e?.schedule?{key:`scheduled`,label:`Scheduled`}:String(e?.mode||``).trim().toLowerCase()===`standalone`?{key:`manual`,label:`Manual`}:{key:`other`,label:`Other`},[le,xe]),Mn=r(()=>Vt(It(kt,Cn),{sortMode:Sn,favoriteAutomationIds:En}).map(e=>{let t=Tt(e),n=X(e),r=Pt(e);return{automation:e,id:t,name:Et(e),createdAtMs:Ot(e),isFavorite:En.has(t),status:String(e?.status||`draft`).trim(),paused:String(e?.status||`draft`).trim().toLowerCase()===`paused`,categoryKey:n.key,categoryLabel:n.label,sourceKey:r.key,sourceLabel:r.label}}),[kt,X,En,Cn,Sn]),Nn=r(()=>{let e=[{key:`standup`,label:`Standup`},{key:`mission_blueprint`,label:`Mission Blueprint`},{key:`scheduled`,label:`Scheduled`},{key:`manual`,label:`Manual`},{key:`other`,label:`Other`}],t=Mn.filter(e=>e.isFavorite),n=[];t.length>0&&n.push({key:`favorites`,label:`Favorites`,description:`Pinned here for this profile.`,count:t.length,rows:t});let r=Mn.filter(e=>!e.isFavorite);for(let t of e){let e=r.filter(e=>e.categoryKey===t.key);e.length&&n.push({key:t.key,label:t.label,description:t.key===`standup`?`Standup and daily workflow automations.`:t.key===`mission_blueprint`?`Blueprint-style workflow automations.`:t.key===`scheduled`?`Automations driven by schedules or recurring triggers.`:t.key===`manual`?`Automations that are usually started by hand.`:`Workflow automations that do not fit the other groups yet.`,count:e.length,rows:e})}return n},[Mn]),Pn=r(()=>Vt(yn,{sortMode:Sn,favoriteAutomationIds:En}).map(e=>{let t=String(e?.automation_id||e?.id||e?.routine_id||``).trim();return{automation:e,id:t,name:Et(e),createdAtMs:Ot(e),isFavorite:En.has(t),status:String(e?.status||`active`).trim()}}),[yn,En,Sn]),Fn=bn.isLoading||Dn.isPending,In=r(()=>{let e=yn.flatMap(e=>pe({automation:e,family:`legacy`,rangeStartMs:_t.startMs,rangeEndMs:_t.endMs})),t=kt.flatMap(e=>pe({automation:e,family:`v2`,rangeStartMs:_t.startMs,rangeEndMs:_t.endMs}));return[...e,...t]},[yn,kt,pe,_t.endMs,_t.startMs]),Ln=C(Bt.data,`runs`),Rn=r(()=>Ae({providerCatalog:Nt.data,providerConfig:Ft.data,defaultProvider:``,defaultModel:``}),[Nt.data,Ft.data]),zn=r(()=>w(Lt.data),[Lt.data,w]),Bn=C(Ht.data,`runs`),Vn=r(()=>{let e=new Map;for(let t of yn){let n=String(t?.automation_id||t?.routine_id||t?.id||``).trim(),r=String(t?.name||t?.title||``).trim();n&&r&&!e.has(n)&&e.set(n,r)}for(let t of kt){let n=String(t?.automation_id||t?.automationId||t?.id||``).trim(),r=String(t?.name||t?.title||``).trim();n&&r&&!e.has(n)&&e.set(n,r)}let t=[...Ln,...Bn],n=new Map;for(let r of t){let t=String(r?.run_id||r?.runId||r?.id||``).trim();if(!t||n.has(t))continue;let i=String(r?.automation_id||r?.routine_id||``).trim(),a=String(r?.automation_name||r?.automationName||``).trim()||e.get(i)||``;n.set(t,a?{...r,automation_name:a,automationName:a}:r)}return Array.from(n.values()).sort((e,t)=>{let n=z(e?.started_at_ms||e?.startedAtMs||e?.created_at_ms||e?.createdAtMs||0);return z(t?.started_at_ms||t?.startedAtMs||t?.created_at_ms||t?.createdAtMs||0)-n})},[yn,kt,Ln,z,Bn]),Hn=C(rn.data,`packs`),Un=Vn.filter(e=>Ie(P(e))),Wn=r(()=>{let e=0,t=0,n=0,r=0;return Bn.forEach(i=>{let a=P(i),o=_e(i);if(a===`queued`){o===`capacity`?t+=1:o===`workspace_lock`?n+=1:r+=1;return}Ie(a)&&(e+=1)}),{active:e,queuedCapacity:t,queuedWorkspaceLock:n,queuedOther:r}},[Ie,_e,Bn]),Gn=Vn.filter(e=>{let t=P(e);return t===`failed`||t===`error`||t===`blocked`||t===`stalled`||k(e)}),Z=Ut.data?.run||null,Kn=en.data?.blackboard||null,qn=Array.isArray(tn.data?.events)?tn.data.events:[],Jn=Array.isArray(nn.data?.patches)?nn.data.patches:[],Yn=r(()=>{if(!yt)return{tasks:[],currentTaskId:``,taskSource:`empty`};let e=V(Z,[],ct),t=e[0]||``,n=new Set(e),r=ve({run:$t.data?.run||null,tasks:Array.isArray($t.data?.run?.steps)?$t.data?.run.steps:[],blackboard:Kn,events:qn});if(r.tasks.length){let e=n.size?r.tasks.map(e=>n.has(e.id)&&[`pending`,`runnable`,`assigned`].includes(e.state)?{...e,state:`in_progress`}:e):r.tasks;return{...r,tasks:e,currentTaskId:r.currentTaskId||t}}let i=he(Z,t),a=n.size?i.tasks.map(e=>n.has(e.id)&&[`pending`,`runnable`,`assigned`].includes(e.state)?{...e,state:`in_progress`}:e):i.tasks;return{...i,tasks:a,currentTaskId:i.currentTaskId||t}},[B,V,yt,Z,ct,Kn,qn,$t.data]),Q=r(()=>Yn.tasks.find(e=>e.id===it)||null,[it,Yn.tasks]),Xn=r(()=>Yn.tasks.find(e=>String(e.state||``).toLowerCase()===`blocked`)||null,[Yn.tasks]),Zn=r(()=>Q?me(Z,String(Q.id||``).replace(/^node-/,``)):null,[Q,Z]),Qn=r(()=>ge(Zn),[Zn]),$n=r(()=>de(Zn),[Zn]),{validationBasis:er=null,qualityMode:tr=``,requestedQualityMode:nr=``,emergencyRollbackEnabled:rr=null,blockerCategory:ir=``,receiptLedger:ar=null,receiptTimeline:or=[],touchedFiles:sr=[],undeclaredFiles:cr=[],researchReadPaths:lr=[],discoveredRelevantPaths:ur=[],reviewedPathsBackedByRead:dr=[],unreviewedRelevantPaths:fr=[],unmetResearchRequirements:pr=[],verificationOutcome:mr=``,verificationPassed:hr=null,verificationResults:gr=[],failureDetail:_r=``,workflowClass:vr=``,phase:yr=``,failureKind:br=``,warningCount:xr=0,warningRequirements:Sr=[],validationOutcome:Cr=``,artifactCandidates:wr=[]}=r(()=>I(Q,Zn)||{},[Q,Zn]),Tr=String(Z?.status||``).trim().toLowerCase(),Er=P(Z),Dr=Yn.tasks.map(e=>String(e?.state||``).trim().toLowerCase()),Or=Er,kr=``;Tr!==Er&&(Tr===`completed`||Tr===`done`)&&workflowBlockedNodeCount(Z)>0&&(kr=`derived from blocked nodes`),yt&&(Tr===`completed`||Tr===`done`)&&Dr.some(e=>![`done`,`validated`].includes(e))&&(Dr.includes(`failed`)?Or=`failed`:Dr.includes(`blocked`)?Or=`blocked`:Dr.some(e=>[`created`,`pending`,`runnable`,`assigned`,`in_progress`].includes(e))&&(Or=`running`),kr=`derived from projected task board`);let Ar=r(()=>{let e=Z?.nodeRepairGuidance,t=e&&typeof e==`object`&&!Array.isArray(e)?Object.entries(e).map(([e,t])=>({nodeId:String(e||``).trim(),guidance:t||{}})).filter(e=>e.nodeId):[];if(t.length)return t;let n=Z?.checkpoint?.node_outputs||Z?.checkpoint?.nodeOutputs||{};return Object.entries(n).map(([e,t])=>{let n=t?.artifact_validation||t?.artifactValidation||{},r=t?.validator_summary||t?.validatorSummary||{},i=Array.isArray(n?.required_next_tool_actions||n?.requiredNextToolActions)?n.required_next_tool_actions||n.requiredNextToolActions:[],a=Array.isArray(r?.unmet_requirements||r?.unmetRequirements)?r.unmet_requirements||r.unmetRequirements:[],o=String(r?.reason||t?.blocked_reason||t?.blockedReason||``).trim(),s=String(n?.blocking_classification||n?.blockingClassification||``).trim();return!i.length&&!a.length&&!o&&!s?null:{nodeId:String(e||``).trim(),guidance:{status:t?.status||``,failureKind:t?.failure_kind||t?.failureKind||``,reason:o,unmetRequirements:a,blockingClassification:s,requiredNextToolActions:i,repairAttempt:n?.repair_attempt??n?.repairAttempt??null,repairAttemptsRemaining:n?.repair_attempts_remaining??n?.repairAttemptsRemaining??null}}}).filter(Boolean)},[Z]);e(()=>{st(``)},[p,it]);let jr=yt?Array.isArray(Kn?.artifacts)?Kn.artifacts:[]:C(Wt.data,`artifacts`),Mr=r(()=>jr.map((e,t)=>{let n=String(e?.id||e?.artifact_id||`artifact-${t+1}`).trim(),r=String(e?.name||e?.label||e?.kind||e?.type||e?.path||n).trim(),i=String(e?.kind||e?.type||e?.path||``).trim(),a=Re(ze(e));return{key:n,name:r||n,kind:i,artifact:e,paths:a}}),[ze,jr,Re]),Nr=r(()=>Q?Re([...ze(Zn),...ze($n),String(Q.output_path||``).trim()]):[],[ze,Q,$n,Zn,Re]),Pr=r(()=>Nr.length?Mr.filter(e=>e.paths.some(e=>Nr.includes(e))):[],[Mr,Nr]),Fr=r(()=>String(Q?.id||``).startsWith(`node-`)?String(Q?.id||``).replace(/^node-/,``).trim():``,[Q]),Ir=r(()=>String(Q?.id||``).startsWith(`node-`),[Q]),Lr=r(()=>String(Q?.task_type||``).trim()===`automation_backlog_item`,[Q]),Rr=r(()=>String(Q?.state||``).trim().toLowerCase(),[Q]),zr=r(()=>M(Z),[Z]),Br=r(()=>re(Z),[Z]),Vr=String(Or||``).trim().toLowerCase(),Hr=yt&&!!p&&!!Vr&&![`running`,`queued`,`pausing`].includes(Vr),Ur=Rr===`blocked`,Wr=Ur||Rr===`failed`,Gr=sn.isPending?String(sn.variables?.action||``).trim():``,Kr=Gr?`Waiting for ${Gr} request to finish.`:``,qr=!!Fr&&zr.includes(Fr),Jr=!!Fr&&Br.includes(Fr),Yr=qr?Q:Yn.tasks.find(e=>zr.includes(String(e?.id||``).replace(/^node-/,``).trim()))||Xn,Xr=qr?Fr:String(Yr?.id||``).replace(/^node-/,``).trim(),Zr=String(Q?.id||``).startsWith(`node-`)&&(qr||Jr||Rr===`failed`),ci=Hr&&(Vr===`failed`||zr.length>0||Zr),li=Hr&&zr.length>0&&!!Xr,ui=r(()=>Number(Q?.lease_expires_at_ms||0)||0,[Q]),di=r(()=>!!Q?.is_stale||Rr===`in_progress`&&ui>0&&ui<=Date.now(),[Q,ui,Rr]),fi=r(()=>j(Z,Fr,8),[Fr,Z]),pi=r(()=>H(Yn.tasks,Q?.id||``),[Q,H,Yn.tasks]),mi=r(()=>pi.map(e=>Yn.tasks.find(t=>t.id===e)||null).filter(Boolean),[pi,Yn.tasks]),hi=r(()=>{let e=Gt.data?.preview,t=Array.isArray(e?.reset_nodes)?e.reset_nodes.map(e=>String(e||``).trim()).filter(Boolean):[];return t.length?t:pi.map(e=>e.replace(/^node-/,``).trim()).filter(Boolean)},[pi,Gt.data]),gi=r(()=>{let e=Gt.data?.preview,t=Array.isArray(e?.cleared_outputs)?e.cleared_outputs.map(e=>String(e||``).trim()).filter(Boolean):[];return t.length?Re(t):Re(mi.map(e=>String(e?.output_path||``).trim()))},[mi,Gt.data,Re]),_i=e=>{let t=String(e||``).trim();st(Mr.find(e=>e.paths.includes(t))?.key||``),dt.current&&dt.current.scrollIntoView({block:`nearest`,behavior:`smooth`})},vi=Hr&&Ir&&!!Fr&&(qr||Jr||Rr===`failed`),yi=Rr===`failed`||qr||Jr?Fr:``,bi=Hr&&Ir&&!!Fr&&qr,xi=Kr||(Vr?!Hr&&Ir?`This workflow is still running. Wait until it is paused, blocked, failed, completed, or cancelled before mutating tasks.`:``:`Loading run status...`)||(Ir&&Fr&&(Ur&&!qr||Wr&&Rr!==`failed`&&!qr&&!Jr)?`This node is not currently blocked on the server.`:``),Si=Hr&&Ir&&!!Fr&&![`in_progress`,`done`,`blocked`,`failed`].includes(Rr),Ci=yt&&!!p&&Lr&&!Ir&&[`pending`,`runnable`].includes(Rr),wi=yt&&!!p&&Lr&&!Ir&&([`blocked`,`failed`].includes(Rr)||di),Ti=r(()=>{let e=Gt.data?.preview,t=String(Q?.title||Fr||`task`).trim(),n=hi.length;return{rootTitle:t,subtreeCount:n,descendantCount:Math.max(0,n-+!!Fr),outputCount:gi.length,previewBacked:!!Gt.data?.preview,preservesUpstreamOutputs:typeof e?.preserves_upstream_outputs==`boolean`?e.preserves_upstream_outputs:!0}},[Q,Fr,hi.length,gi.length,Gt.data]),Ei=ye(Z,jr),Di=yt?(()=>{let e=fe(qn,Jn);return e.length?e:E(Array.isArray(Zt.data)?Zt.data:[],p)})():Array.isArray(Xt.data?.events)?Xt.data.events:Array.isArray(Xt.data?.history)?Xt.data.history:[],Oi=r(()=>te(Array.isArray(Zt.data)?Zt.data:[],qn,yt,p),[yt,Zt.data,p,qn]),ki=r(()=>{let e=[...Oi,...Qe],t=new Set;return e.filter(e=>!e?.id||t.has(e.id)?!1:(t.add(e.id),!0)).sort((e,t)=>Number(e.at||0)-Number(t.at||0))},[Oi,Qe]),Ai=ki.filter(e=>Xe===`all`?!0:e.source===Xe),ji=r(()=>ee(Ai),[Ai]),Mi=r(()=>qt.flatMap((e,t)=>{let n=Kt[t]||``;return(Array.isArray(e.data)?e.data:[]).map(e=>({sessionId:n,message:e}))}),[Kt,qt]),Ni=ai({isWorkflowRun:yt,runArtifacts:jr,runStatus:Or,runStatusDerivedNote:kr,selectedRun:Z,workflowContextEvents:qn,workflowContextPatches:Jn,workflowProjection:Yn});r(()=>U(Z),[U,Z]),ei({enabled:xt,availableSessionIds:Kt,queryClient:q,selectedRunId:p,selectedContextRunId:Yt,onSelectRunId:m,setSelectedSessionId:tt,setSelectedSessionFilterId:rt,setRunEvents:$e,setSelectedLogSource:Ze,setSelectedBoardTaskId:at,setSessionEvents:lt,setSessionLogPinnedToBottom:mt});let Pi=i(``);e(()=>{!p||!Yn.tasks.length||Pi.current!==p&&(Pi.current=p,at(Yn.currentTaskId||Yn.tasks.find(e=>[`in_progress`,`blocked`,`assigned`,`runnable`,`pending`].includes(String(e.state||``).toLowerCase()))?.id||Yn.tasks[0]?.id||``))},[p,Yn.currentTaskId,Yn.tasks]),ni({selectedRunId:p,selectedSessionId:et,selectedContextRunId:Yt,isWorkflowRun:yt,runInspectorActive:xt,timestampOrNull:K,appendRunEvent:$r($e,{cap:300,getId:e=>e.id}),appendSessionEvent:$r(lt,{cap:500,getId:e=>e.id}),queryClient:q}),si(Ge,[Un.length,yn.length,kt.length,Gn.length,Hn.length,sn.isPending,Qe.length,an.isPending,on.isPending,Vn.length,ct.length,Nn.length,Pn.length,Sn,Fn,gn.isPending,Bn.length,!!Je,!!Q,!!p,!!et]);let{beginEdit:Fi,isPausedAutomation:Ii,openCalendarAutomationEdit:Li,updateCalendarAutomationFromEvent:Ri}=ri({toast:n,scheduleToEditor:Le,setEditDraft:Ye,isMissionBlueprintAutomation:le,onOpenAdvancedEdit:g,getAutomationCalendarFamily:Se,workflowAutomationToEditDraft:R,setWorkflowEditDraft:gt,rewriteCronForDroppedStart:W,updateAutomationMutation:gn,updateWorkflowAutomationMutation:_n}),zi=yn.length,Bi=kt.length,Vi=Mn.length,Hi=zi+Bi,Ui=r(()=>be(Z,ct,Qe),[be,Qe,Z,ct]),Wi=oi({selectedSessionFilterId:nt,selectedSessionId:et,sessionMessageCreatedAt:Ve,sessionMessageId:Be,sessionMessageParts:We,sessionMessageText:Ue,sessionMessageVariant:He,sessionMessages:Mi,sessionEvents:ct,sessionLabel:Pe,sessionLogRef:ft,sessionLogPinnedToBottom:pt});return f(Qr,{state:{rootRef:Ge,viewMode:d,defaultRunningSectionsOpen:b,calendarEvents:In,workflowAutomationCount:Bi,workflowAutomationVisibleCount:Vi,automationsV2:kt,workflowAutomationSections:Nn,legacyAutomationRows:Pn,totalSavedAutomations:Hi,legacyAutomationCount:zi,automations:yn,workflowLibraryFilters:Cn,workflowLibraryFilteringActive:wn,workflowSortMode:Sn,workflowPreferencesLoading:Fn,packs:Hn,activeRuns:Un,workflowQueueCounts:Wn,failedRuns:Gn,runsLoading:Bt.isLoading||Ht.isLoading,runsRefreshing:Bt.isFetching||Ht.isFetching,runs:Vn,selectedRunId:p,selectedRun:Z,isWorkflowRun:yt,runStatus:Or,runStatusDerivedNote:kr,canContinueBlockedWorkflow:li,continueBlockedNodeId:Xr,canRecoverWorkflowRun:ci,runDebuggerRetryNodeId:yi,serverBlockedNodeIds:zr,serverNeedsRepairNodeIds:Br,selectedContextRunId:Yt,runSummaryRows:Ni,workflowProjection:Yn,runArtifacts:jr,selectedBoardTaskId:it,selectedBoardTask:Q,boardDetailRef:ut,selectedBoardTaskOutput:Zn,selectedBoardTaskValidationOutcome:Cr,selectedBoardTaskWarningCount:xr,selectedBoardTaskTelemetry:Qn,selectedBoardTaskArtifactValidation:$n,selectedBoardTaskIsWorkflowNode:Ir,selectedBoardTaskIsProjectedBacklogItem:Lr,selectedBoardTaskWorkflowClass:vr,selectedBoardTaskPhase:yr,selectedBoardTaskFailureKind:br,selectedBoardTaskQualityMode:tr,selectedBoardTaskEmergencyRollbackEnabled:rr,selectedBoardTaskBlockerCategory:ir,selectedBoardTaskValidationBasis:er,selectedBoardTaskReceiptLedger:ar,selectedBoardTaskArtifactCandidates:wr,selectedBoardTaskWarningRequirements:Sr,selectedBoardTaskReceiptTimeline:or,selectedBoardTaskLifecycleEvents:fi,selectedBoardTaskResearchReadPaths:lr,selectedBoardTaskDiscoveredRelevantPaths:ur,selectedBoardTaskUnmetResearchRequirements:pr,selectedBoardTaskReviewedPathsBackedByRead:dr,selectedBoardTaskUnreviewedRelevantPaths:fr,selectedBoardTaskVerificationOutcome:mr,selectedBoardTaskVerificationPassed:hr,selectedBoardTaskVerificationResults:gr,selectedBoardTaskFailureDetail:_r,selectedBoardTaskRelatedPaths:Nr,selectedBoardTaskRelatedArtifacts:Pr,selectedBoardTaskNodeId:Fr,selectedBoardTaskStateNormalized:Rr,selectedBoardTaskImpactSummary:Ti,selectedBoardTaskResetOutputPaths:gi,canTaskContinue:bi,canTaskRetry:vi,selectedBoardTaskServerActionMessage:xi,canTaskRequeue:Si,canBacklogTaskClaim:Ci,canBacklogTaskRequeue:wi,selectedBoardTaskTouchedFiles:sr,selectedBoardTaskUndeclaredFiles:cr,selectedBoardTaskRequestedQualityMode:nr,selectedSessionId:et,selectedSessionFilterId:nt,availableSessionIds:Kt,sessionLogEntries:Wi,sessionLogRef:ft,selectedLogSource:Xe,telemetryEvents:ki,filteredRunEventEntries:ji,blockers:Ui,runHints:Ei,runRepairGuidanceEntries:Ar,artifactsSectionRef:dt,runArtifactEntries:Mr,selectedRunArtifactKey:ot,runHistoryEvents:Di,workflowContextRun:$t.data?.run||null,workflowBlackboard:Kn,editDraft:Je,workflowEditDraft:ht,deleteConfirm:Ke,overlapHistoryEntries:At,providerOptions:Rn,mcpServers:zn,client:t},actions:{setCalendarRange:vt,openCalendarAutomationEdit:Li,onRunCalendarAutomation:(e,t)=>{let n=String(e?.automation_id||e?.automationId||e?.id||``).trim();if(n){if(t===`v2`){on.mutate({id:n});return}an.mutate(n)}},updateCalendarAutomationFromEvent:Ri,onOpenAdvancedEdit:g,setWorkflowEditDraft:gt,runNowV2Mutation:on,automationActionMutation:vn,beginEdit:Fi,runNowMutation:an,isPausedAutomation:Ii,onSelectRunId:m,onOpenRunningView:h,onRecreateWorkflowAutomation:y,toast:n,setDeleteConfirm:qe,navigate:o,setEditDraft:Ye,updateAutomationMutation:gn,validateWorkspaceRootInput:O,validateModelInput:T,validatePlannerModelInput:D,automationWizardConfig:S,updateWorkflowAutomationMutation:_n,onRefreshRunDebugger:()=>{sn.reset(),cn.reset(),ln.reset(),un.reset(),dn.reset(),fn.reset(),pn.reset(),mn.reset(),hn.reset(),Promise.all([q.invalidateQueries({queryKey:[`automations`,`run`,p]}),q.invalidateQueries({queryKey:[`automations`,`run`,`artifacts`,p]}),Yt?q.invalidateQueries({queryKey:[`automations`,`run`,`context`,Yt]}):Promise.resolve(),Yt?q.invalidateQueries({queryKey:[`automations`,`run`,`context`,Yt,`blackboard`]}):Promise.resolve(),Yt?q.invalidateQueries({queryKey:[`automations`,`run`,`context`,Yt,`events`]}):Promise.resolve(),Yt?q.invalidateQueries({queryKey:[`automations`,`run`,`context`,Yt,`patches`]}):Promise.resolve(),p?q.invalidateQueries({queryKey:[`automations`,`run`,`session`,p]}):Promise.resolve()])},setSelectedBoardTaskId:at,focusArtifactEntry:_i,setSelectedSessionFilterId:rt,onCopySessionLog:async()=>{try{await navigator.clipboard.writeText(Wi.map(e=>{let t=new Date(e.at).toLocaleTimeString(),n=e.sessionId?` · ${e.sessionLabel}`:``;return`[${t}] ${e.label}${n}\n${e.body||v(e.raw)}`}).join(`
35
+
36
+ `)),n(`ok`,`Copied session log.`)}catch(e){n(`err`,e instanceof Error?e.message:`Copy failed.`)}},setSessionLogPinnedToBottom:mt,setSelectedLogSource:Ze,setSelectedRunArtifactKey:st,onCopyFullDebugContext:async()=>{try{await navigator.clipboard.writeText([`=== RUN ===`,v(Z),`=== ARTIFACTS ===`,v(jr),`=== TELEMETRY ===`,v(Ai.map(e=>e.event)),`=== CONTEXT RUN ===`,v($t.data?.run||null),`=== BLACKBOARD ===`,v(Kn),`=== HISTORY ===`,v(Di),`=== SESSION MESSAGES ===`,v(Mi)].join(`
37
+
38
+ `)),n(`ok`,`Copied full debug context.`)}catch(e){n(`err`,e instanceof Error?e.message:`Copy failed.`)}},workflowTaskContinueMutation:dn,workflowTaskRetryMutation:un,workflowTaskRequeueMutation:fn,workflowTaskDispositionMutation:pn,workflowRepairMutation:cn,workflowRecoverMutation:ln,backlogTaskClaimMutation:mn,backlogTaskRequeueMutation:hn,runActionMutation:sn,taskResetPreviewQuery:Gt,toggleWorkflowFavorite:jn,toggleWorkflowLibrarySourceFilter:An,toggleWorkflowLibraryStatusFilter:J,resetWorkflowLibraryFilters:Y,setWorkflowSortMode:On},helpers:{statusColor:G,isStandupAutomation:xe,isMissionBlueprintAutomation:le,workflowAutomationToEditDraft:R,formatAutomationV2ScheduleLabel:we,formatScheduleLabel:Ce,workflowStatusDisplay:Te,workflowStatusSubtleDetail:Ee,runDisplayTitle:De,formatRunDateTime:Oe,runObjectiveText:ke,shortText:je,runTimeLabel:Me,workflowActiveSessionCount:ce,workflowTotalNodeCount:ne,isActiveRunStatus:Ie,compactIdentifier:Ne,sessionLabel:Pe,formatTimestampLabel:Fe}})}var li=`tandem.automations.studioHandoff`,ui=`tandem.automations.composer.enabled`;function di(){if(typeof window>`u`)return!1;try{let e=new URL(window.location.href).searchParams.get(`composer`);if(!e)return!1;let t=e.trim().toLowerCase();return t===`1`||t===`true`||t===`on`||t===`yes`}catch{return!1}}function fi(){if(typeof window>`u`||typeof localStorage>`u`)return!1;try{return localStorage.getItem(ui)===`1`}catch{return!1}}function pi(e){if(!e||typeof window>`u`)return`simple`;try{if(window.location.hash.includes(`composer=true`))return`composer`}catch{}return`simple`}function mi(){let[t,n]=a(()=>di()?`create`:`calendar`),[r,i]=a(()=>pi(fi()||di())),[o,s]=a(``),[c,l]=a(null),u=fi()||di();return e(()=>{try{let e=sessionStorage.getItem(li);if(!e)return;sessionStorage.removeItem(li);let t=JSON.parse(e||`{}`);t?.tab===`running`&&n(`running`);let r=String(t?.runId||``).trim();r&&s(r)}catch{return}},[]),{tab:t,setTab:n,createMode:r,setCreateMode:i,selectedRunId:o,setSelectedRunId:s,advancedEditAutomation:c,setAdvancedEditAutomation:l,composerEnabled:u}}var hi=`defaults:
39
+ schedulePreset: Every morning
40
+ mode: team
41
+ maxAgents: "4"
42
+ steps:
43
+ - What?
44
+ - When?
45
+ - How?
46
+ - Review
47
+ goalExamples:
48
+ - Check my email every morning and send me a summary of what's important
49
+ - Monitor GitHub issues and post daily standup updates to Slack
50
+ - Summarize my calendar each Sunday and plan the upcoming week
51
+ - Watch for price changes on competitor products and alert me
52
+ - Generate a weekly report from our Notion workspace
53
+ - Monitor my inbox for urgent emails and draft responses immediately
54
+ - Watch for new pull requests every hour and summarize what changed
55
+ - Scan Slack channels for unanswered questions and draft replies
56
+ - Check for new mentions of our product on Reddit and alert me
57
+ - Watch our repo for new issues tagged 'bug' and triage them automatically
58
+ schedulePresets:
59
+ - label: Every X hours
60
+ desc: Set a 1, 2, 4, 6, or other hour interval for monitoring & alerts
61
+ icon: "⏰"
62
+ cron: ""
63
+ intervalSeconds: 3600
64
+ - label: Every morning
65
+ desc: Daily digest at 9 AM
66
+ icon: "☀️"
67
+ cron: "0 9 * * *"
68
+ - label: Every evening
69
+ desc: End-of-day summary at 6 PM
70
+ icon: "🌙"
71
+ cron: "0 18 * * *"
72
+ - label: Daily at midnight
73
+ desc: Nightly data processing
74
+ icon: "🔄"
75
+ cron: "0 0 * * *"
76
+ - label: Weekly Monday
77
+ desc: Weekly reports & reviews
78
+ icon: "📋"
79
+ cron: "0 9 * * 1"
80
+ - label: Manual only
81
+ desc: Run whenever you want
82
+ icon: "🎯"
83
+ cron: ""
84
+ executionModes:
85
+ - id: single
86
+ label: Single Agent
87
+ icon: "🤖"
88
+ desc: One focused AI handles the whole task
89
+ bestFor: Simple, well-defined tasks
90
+ - id: team
91
+ label: Agent Team
92
+ icon: "👥"
93
+ desc: Multiple specialized AIs collaborate with a planner and workers
94
+ bestFor: Complex multi-step tasks (recommended)
95
+ - id: swarm
96
+ label: Swarm
97
+ icon: "🐝"
98
+ desc: A swarm of AIs work in parallel on sub-tasks
99
+ bestFor: Large-scale parallel work
100
+ `;function gi(e){let{value:t,onChange:n,routedSkill:i,routingConfidence:a,validationBadge:o,generatedSkill:s,advancedMode:c,customSkillName:l,customSkillDescription:u,customWorkflowKind:d,onToggleAdvancedMode:p,onChangeCustomSkillName:m,onChangeCustomSkillDescription:h,onChangeCustomWorkflowKind:g,showArtifactPreview:_,onToggleArtifactPreview:v,artifactPreviewKey:y,onSelectArtifactPreviewKey:b,onGenerateSkill:x,onInstallGeneratedSkill:S,isGeneratingSkill:C,isInstallingSkill:w,installStatus:T,topMatches:E,isMatching:D,goalPlaceholder:O}=e,ee=Object.keys(s?.artifacts||{}),te=r(()=>{let e=t.toLowerCase();return[`monitor`,`watch for`,`watch our`,`check for`,`check my`,`scan for`,`scan our`,`alert me`,`alert me when`].some(t=>e.includes(t))},[t]);return f(`div`,{className:`flex flex-col h-full gap-4 overflow-y-auto`,children:[f(`p`,{className:`text-sm text-slate-400`,children:`Describe what you want the AI to do — in plain English. No technical knowledge needed.`}),f(`textarea`,{className:`tcp-input flex-1 min-h-[200px] text-base`,placeholder:`e.g. "${O}"`,value:t,onInput:e=>n(e.target.value),autoFocus:!0}),te?f(`div`,{className:`flex items-start gap-2 rounded-lg border border-blue-500/30 bg-blue-500/10 px-3 py-2 text-xs text-blue-200`,children:[f(`span`,{className:`mt-0.5 shrink-0 text-base leading-none`,children:`⚡`}),f(`span`,{children:[f(`strong`,{className:`text-blue-100`,children:`Smart scheduling`}),` — Tandem will use a lightweight model to check if there's new work before running the full automation. No tokens wasted when there's nothing new.`]})]}):null,f(`div`,{className:`rounded-xl border border-slate-700/50 bg-slate-900/30 p-3 text-xs text-slate-300`,children:[f(`div`,{className:`flex items-center justify-between gap-2`,children:[f(`span`,{className:`uppercase tracking-wide text-slate-500`,children:`Reusable Flows`}),f(`span`,{className:`text-slate-500`,children:D?`Analyzing…`:`Ready`})]}),i?f(`p`,{className:`mt-1`,children:[`Reusable flow match: `,f(`strong`,{children:i}),` `,a?`(${a})`:``,o?f(`span`,{className:`ml-2 ${o===`validated`?`tcp-badge-ok`:`tcp-badge-warn`}`,children:o===`validated`?`Validated`:`Not validated`}):null]}):f(`p`,{className:`mt-1 text-slate-400`,children:`No reusable flow selected. Tandem will create and run a workflow plan in the engine.`}),E.length?f(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:E.slice(0,3).map((e,t)=>f(`span`,{className:`tcp-badge-info`,children:[String(e?.skill_name||`unknown`),` `,typeof e?.confidence==`number`?`${Math.round(e.confidence*100)}%`:``]},`${String(e?.skill_name||`match`)}-${t}`))}):null]}),f(`div`,{className:`rounded-xl border border-slate-700/50 bg-slate-900/30 p-3 text-xs text-slate-300`,children:[f(`div`,{className:`flex items-center justify-between gap-2`,children:[f(`span`,{className:`uppercase tracking-wide text-slate-500`,children:`Optional: Reusable Skill Export`}),f(`div`,{className:`flex items-center gap-2`,children:[f(`button`,{className:`tcp-btn h-7 px-2 text-xs`,onClick:p,children:c?`Hide Export Options`:`Show Export Options`}),f(`button`,{className:`tcp-btn h-7 px-2 text-xs`,onClick:x,disabled:!t.trim()||C,children:C?`Generating…`:`Generate Reusable Skill Draft`}),f(`button`,{className:`tcp-btn h-7 px-2 text-xs`,onClick:S,disabled:!s?.artifacts||w,children:w?`Installing…`:`Save Reusable Skill`})]})]}),f(`p`,{className:`mt-1 text-slate-400`,children:`This is a secondary prompt-based export path. It does not power the default automation flow, and it does not automatically track planner-chat revisions to the workflow plan.`}),f(`div`,{className:`mt-2 rounded-lg border border-slate-800/70 bg-slate-950/30 px-3 py-2 text-xs text-slate-400`,children:`Recommended flow: review and finalize the workflow plan first, then generate or regenerate the reusable skill draft if you want a reusable export from the current prompt.`}),c?f(`div`,{className:`mt-2 grid gap-2`,children:[f(`input`,{className:`tcp-input text-xs`,placeholder:`skill-name`,value:l,onInput:e=>m(e.target.value)}),f(`input`,{className:`tcp-input text-xs`,placeholder:`Short skill description`,value:u,onInput:e=>h(e.target.value)}),f(`select`,{className:`tcp-input text-xs`,value:d,onInput:e=>g(e.target.value),children:[f(`option`,{value:`pack_builder_recipe`,children:`pack_builder_recipe`}),f(`option`,{value:`automation_v2_dag`,children:`automation_v2_dag`})]})]}):null,s?f(`div`,{className:`mt-2 grid gap-1`,children:[f(`p`,{children:[`Optional scaffold status:`,` `,f(`strong`,{children:String(s?.status||`generated`)})]}),f(`p`,{className:`text-amber-200`,children:`This draft was generated from the prompt and export options. If you revise the workflow plan later in review, regenerate this draft before saving it.`}),f(`p`,{children:[`Suggested skill:`,` `,f(`strong`,{children:String(s?.router?.skill_name||`new optional skill`)})]}),f(`p`,{className:`text-slate-400`,children:[`Artifacts:`,` `,ee.join(`, `)||`SKILL.md, workflow.yaml, automation.example.yaml`]}),f(`div`,{className:`mt-1 flex items-center gap-2`,children:[f(`button`,{className:`tcp-btn h-7 px-2 text-xs`,onClick:v,children:_?`Hide Raw`:`Show Raw`}),_?f(`select`,{className:`tcp-input h-7 text-xs`,value:y,onInput:e=>b(e.target.value),children:Object.keys(s?.artifacts||{}).map(e=>f(`option`,{value:e,children:e},e))}):null]}),_?f(`textarea`,{className:`tcp-input min-h-[140px] font-mono text-[11px]`,readOnly:!0,value:String(s?.artifacts?.[y]||``)}):null]}):f(`p`,{className:`mt-1 text-slate-400`,children:`Generate a reusable skill draft from this prompt if you want to save it for later reuse.`}),T?f(`p`,{className:`mt-2 text-slate-300`,children:T}):null]})]})}function _i({selected:e,presets:t,onSelect:n,scheduleValue:r,onScheduleChange:i,timezone:a,timezoneError:o,onTimezoneChange:s}){return f(`div`,{className:`grid gap-3`,children:[f(`p`,{className:`text-sm text-slate-400`,children:`When should this automation run?`}),f(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:t.map(t=>f(`button`,{onClick:()=>n(t),className:`tcp-list-item flex flex-col items-start gap-1 text-left transition-all ${e===t.label?`border-amber-400/60 bg-amber-400/10`:``}`,children:[f(`div`,{className:`flex items-center gap-2 font-medium`,children:[f(`span`,{children:t.icon}),f(`span`,{children:t.label})]}),f(`span`,{className:`tcp-subtle text-xs`,children:t.desc}),t.cron?f(`code`,{className:`rounded bg-slate-800/60 px-1.5 py-0.5 text-xs text-slate-400`,children:t.cron}):null]},t.label))}),f(ye,{value:r,onChange:i,timezone:a}),f(be,{value:a,onChange:s,error:o,hint:`Use the timezone that matches when this automation should fire.`})]})}function vi(e){let{selected:t,onSelect:n,executionModes:r,maxAgents:i,onMaxAgents:a,executionProfile:o,onExecutionProfileChange:s,workspaceRoot:c,onWorkspaceRootChange:l,providerOptions:u,providerId:d,modelId:h,plannerProviderId:g,plannerModelId:_,onProviderChange:v,onModelChange:y,onPlannerProviderChange:x,onPlannerModelChange:S,roleModelsJson:C,onRoleModelsChange:w,roleModelsError:T,toolAccessMode:E,customToolsText:D,onToolAccessModeChange:O,onCustomToolsTextChange:ee,mcpServers:te,selectedMcpServers:k,onToggleMcpServer:ne,onConnectMcpServer:A,onCompleteMcpSignIn:j,onRefreshMcpServers:re,onOpenMcpSettings:M,activeMcpAction:N,workspaceRootError:P,plannerModelError:ie,workspaceBrowserOpen:F,workspaceBrowserDir:ae,workspaceBrowserSearch:oe,onWorkspaceBrowserSearchChange:I,onOpenWorkspaceBrowser:se,onCloseWorkspaceBrowser:L,onBrowseWorkspaceParent:R,onBrowseWorkspaceDirectory:ce,onSelectWorkspaceDirectory:le,workspaceBrowserParentDir:ue,workspaceCurrentBrowseDir:de,filteredWorkspaceDirectories:fe}=e,pe=String(oe||``).trim().toLowerCase();return f(`div`,{className:`grid gap-4`,children:[f(`p`,{className:`text-sm text-slate-400`,children:`How should the AI handle this task? (You can always change this later.)`}),f(`div`,{className:`grid gap-3`,children:r.map(e=>f(`button`,{onClick:()=>n(e.id),className:`tcp-list-item flex items-start gap-4 text-left transition-all ${t===e.id?`border-amber-400/60 bg-amber-400/10`:``}`,children:[f(`span`,{className:`mt-0.5 text-2xl`,children:e.icon}),f(`div`,{className:`grid gap-1`,children:[f(`div`,{className:`flex items-center gap-2`,children:[f(`span`,{className:`font-semibold`,children:e.label}),e.id===`team`?f(`span`,{className:`rounded-full bg-amber-500/20 px-2 py-0.5 text-xs text-amber-300`,children:`Recommended`}):null]}),f(`span`,{className:`text-sm text-slate-300`,children:e.desc}),f(`span`,{className:`tcp-subtle text-xs`,children:[`Best for: `,e.bestFor]})]}),f(`div`,{className:`ml-auto mt-1 h-4 w-4 shrink-0 rounded-full border-2 border-slate-600 transition-all data-[checked]:border-amber-400 data-[checked]:bg-amber-400/30`,"data-checked":t===e.id?!0:void 0})]},e.id))}),t===`single`?null:f(`div`,{className:`grid gap-1`,children:[f(`label`,{className:`text-xs text-slate-400`,children:`Max parallel agents`}),f(`input`,{type:`number`,min:`2`,max:`16`,className:`tcp-input w-24`,value:i,onInput:e=>a(e.target.value)}),f(`div`,{className:`text-xs text-slate-500`,children:t===`team`?`Team mode uses this as the concurrency cap for a small set of specialized agents.`:`Swarm mode uses this as the concurrency cap when Tandem fans work out in parallel.`})]}),f(`div`,{className:`grid gap-2 rounded-xl border border-amber-500/30 bg-amber-500/10 p-3 shadow-[0_0_24px_rgba(245,158,11,0.08)]`,children:[f(`div`,{className:`grid gap-1`,children:[f(`div`,{className:`text-xs uppercase tracking-wide text-amber-200/80`,children:`Execution Profile`}),f(`div`,{className:`text-xs text-slate-300`,children:`Choose how strictly Tandem validates this automation. If a workflow keeps failing on artifact review or validator noise, use Guided or Lenient to keep recoverable work moving.`})]}),f(gr,{value:o,onChange:s,clearable:!0})]}),f(`div`,{className:`grid gap-2 rounded-xl border border-slate-700/50 bg-slate-900/30 p-3`,children:[f(`div`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:`Execution Directory`}),f(`div`,{className:`grid gap-1`,children:[f(`label`,{className:`text-xs text-slate-400`,children:`Workspace root`}),f(`div`,{className:`grid gap-2 md:grid-cols-[auto_1fr_auto]`,children:[f(`button`,{className:`tcp-btn`,type:`button`,onClick:se,children:`Browse`}),f(`input`,{className:`tcp-input text-sm ${P?`border-red-500/70 text-red-100`:``}`,value:c,readOnly:!0,placeholder:`No local directory selected. Use Browse.`}),f(`button`,{className:`tcp-btn`,type:`button`,onClick:()=>l(``),disabled:!c,children:`Clear`})]}),f(`div`,{className:`text-xs text-slate-500`,children:`Tandem will run this automation from this workspace directory.`}),P?f(`div`,{className:`text-xs text-red-300`,children:P}):null]})]}),f(m,{children:F?f(p.div,{className:`fixed inset-0 z-50 flex items-center justify-center p-4`,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},children:[f(`button`,{type:`button`,className:`tcp-confirm-backdrop`,"aria-label":`Close workspace directory dialog`,onClick:L}),f(p.div,{className:`tcp-confirm-dialog max-w-2xl`,initial:{opacity:0,y:8,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:6,scale:.98},children:[f(`h3`,{className:`tcp-confirm-title`,children:`Select Workspace Folder`}),f(`p`,{className:`tcp-confirm-message`,children:[`Current: `,de||`n/a`]}),f(`div`,{className:`mb-2 flex flex-wrap gap-2`,children:[f(`button`,{className:`tcp-btn`,type:`button`,onClick:R,disabled:!ue,children:`Up`}),f(`button`,{className:`tcp-btn-primary`,type:`button`,onClick:le,disabled:!de,children:`Select This Folder`}),f(`button`,{className:`tcp-btn`,type:`button`,onClick:L,children:`Close`})]}),f(`div`,{className:`mb-2`,children:f(`input`,{className:`tcp-input`,placeholder:`Type to filter folders...`,value:oe,onInput:e=>I(e.target.value)})}),f(`div`,{className:`max-h-[360px] overflow-auto rounded-lg border border-slate-700/60 bg-slate-900/20 p-2`,children:fe.length?fe.map(e=>f(`button`,{className:`tcp-list-item mb-1 w-full text-left`,type:`button`,onClick:()=>ce(String(e?.path||``)),children:String(e?.name||e?.path||``)},String(e?.path||e?.name))):f(b,{text:pe?`No folders match your search.`:`No subdirectories in this folder.`})})]})]}):null}),f(`div`,{className:`grid gap-2 rounded-xl border border-slate-700/50 bg-slate-900/30 p-3`,children:[f(`div`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:`Model Selection`}),f(W,{providerLabel:`Provider`,modelLabel:`Model`,draft:{provider:d,model:h},providers:u,onChange:e=>{v(e.provider),y(e.model)},inheritLabel:`Use workspace default`}),f(`div`,{className:`grid gap-2 rounded-lg border border-slate-800/70 bg-slate-950/30 p-3`,children:[f(`div`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:`Planner fallback model`}),f(`div`,{className:`text-xs text-slate-400`,children:`Optional. Leave blank to use the workflow default model for planning and revisions.`}),f(W,{providerLabel:`Planner provider`,modelLabel:`Planner model`,draft:{provider:g,model:_},providers:u,onChange:e=>{x(e.provider),S(e.model)},inheritLabel:`Disabled`}),ie?f(`div`,{className:`text-xs text-red-300`,children:ie}):null]}),f(`div`,{className:`grid gap-1`,children:[f(`label`,{className:`text-xs text-slate-400`,children:`Role model overrides (advanced JSON)`}),f(`textarea`,{className:`tcp-input min-h-[72px] font-mono text-xs ${T?`border-red-500/70 text-red-100`:``}`,value:C,onInput:e=>w(e.target.value),placeholder:`{"planner":{"provider_id":"openai","model_id":"gpt-5"},"worker":{"provider_id":"anthropic","model_id":"claude-sonnet-4"}}`}),T?f(`div`,{className:`text-xs text-red-300`,children:T}):null]})]}),f(`div`,{className:`grid gap-3 rounded-xl border border-slate-700/50 bg-slate-900/30 p-3`,children:[f(`div`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:`Tool Access`}),f(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[f(`button`,{type:`button`,className:`tcp-list-item text-left ${E===`all`?`border-amber-400/60 bg-amber-400/10`:``}`,onClick:()=>O(`all`),children:[f(`div`,{className:`font-medium`,children:`All tools`}),f(`div`,{className:`tcp-subtle text-xs`,children:`Grant full built-in tool access.`})]}),f(`button`,{type:`button`,className:`tcp-list-item text-left ${E===`custom`?`border-amber-400/60 bg-amber-400/10`:``}`,onClick:()=>O(`custom`),children:[f(`div`,{className:`font-medium`,children:`Custom allowlist`}),f(`div`,{className:`tcp-subtle text-xs`,children:`Restrict built-in tools manually.`})]})]}),E===`custom`?f(`div`,{className:`grid gap-1`,children:[f(`label`,{className:`text-xs text-slate-400`,children:`Allowed built-in tools`}),f(`textarea`,{className:`tcp-input min-h-[96px] font-mono text-xs`,value:D,onInput:e=>ee(e.target.value),placeholder:`read
101
+ write
102
+ edit
103
+ bash
104
+ ls
105
+ glob
106
+ websearch`})]}):f(`div`,{className:`text-xs text-slate-500`,children:`All built-in tools are allowed.`})]}),f(`div`,{className:`grid gap-2 rounded-xl border border-slate-700/50 bg-slate-900/30 p-3`,children:[f(`div`,{className:`flex items-center justify-between gap-2`,children:[f(`div`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:`MCP Servers`}),f(`div`,{className:`flex flex-wrap gap-2`,children:[f(`button`,{className:`tcp-btn h-7 px-2 text-xs`,type:`button`,onClick:re,children:`Reload`}),f(`button`,{className:`tcp-btn h-7 px-2 text-xs`,type:`button`,onClick:M,children:`Open MCP Settings`})]})]}),f(`div`,{className:`text-xs text-slate-500`,children:`Select the servers this automation may use. You can connect existing servers here, or open MCP Settings to add/edit servers without losing this draft.`}),te.length?f(`div`,{className:`grid gap-2`,children:te.map(e=>{let t=k.includes(e.name),n=N?.name===e.name,r=n&&N?.action===`connect`,i=n&&N?.action===`authenticate`;return f(`div`,{className:`grid gap-2 rounded-lg border px-3 py-3 ${t?`border-amber-400/50 bg-amber-400/10`:`border-slate-700/60 bg-slate-950/20`}`,children:[f(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[f(`button`,{type:`button`,className:`text-left ${t?`text-amber-200`:`text-slate-100`}`,onClick:()=>ne(e.name),children:[f(`div`,{className:`font-medium`,children:e.name}),f(`div`,{className:`text-xs text-slate-400`,children:t?`Selected for this automation`:`Click to allow this automation to use the server`})]}),f(`div`,{className:`flex flex-wrap gap-2 text-xs`,children:[f(`span`,{className:e.connected?`tcp-badge-ok`:`tcp-badge-warn`,children:e.connected?`Connected`:`Disconnected`}),f(`span`,{className:e.enabled?`tcp-badge-info`:`tcp-badge-warn`,children:e.enabled?`Enabled`:`Disabled`})]})]}),e.lastError?f(`div`,{className:`rounded-lg border border-rose-700/60 bg-rose-950/20 px-3 py-2 text-xs text-rose-200`,children:e.lastError}):null,e.pendingAuth?f(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs text-amber-100`,children:e.authMessage||`Browser sign-in is still required for this MCP server.`}):null,f(`div`,{className:`flex flex-wrap gap-2`,children:[e.connected?null:f(`button`,{type:`button`,className:`tcp-btn h-7 px-2 text-xs`,onClick:()=>A(e.name),disabled:n,children:r?`Connecting...`:`Connect`}),(e.pendingAuth||e.authKind===`oauth`)&&!e.connected?f(`button`,{type:`button`,className:`tcp-btn h-7 px-2 text-xs`,onClick:()=>j(e.name),disabled:n,children:i?`Checking...`:`Mark Sign-In Complete`}):null,e.authorizationUrl?f(`a`,{className:`tcp-btn h-7 px-2 text-xs`,href:e.authorizationUrl,target:`_blank`,rel:`noreferrer`,children:`Open Sign-In`}):null]})]},e.name)})}):f(`div`,{className:`text-xs text-slate-400`,children:`No MCP servers configured yet.`})]})]})}function yi(e){let t=new Set,n=[];for(let r of e){let e=String(r||``).trim();!e||t.has(e)||(t.add(e),n.push(e))}return n}function bi(e){return yi(String(e||``).split(/[\n,]/g).map(e=>String(e||``).trim()).filter(Boolean))}function xi(e){return String(e||``).trim()}function Si({wizard:e,onToggleExportPackDraft:n,onSubmit:r,overlapAnalysis:i,overlapDecision:o,onSelectOverlapDecision:s,isPending:c,planPreview:l,isPreviewing:u,planningConversation:d,planningChangeSummary:p,onSendPlanningMessage:m,isSendingPlanningMessage:h,onResetPlanningChat:g,isResettingPlanningChat:_,planningClarification:v,plannerLatencyAdvisory:y,plannerError:b,plannerDiagnostics:S,generatedSkill:C,installStatus:w,executionModes:T}){let[E,D]=a(``),[O,ee]=a(!1),[te,k]=a({}),ne=U({scheduleKind:e.scheduleKind,cronExpression:e.cron,intervalSeconds:e.intervalSeconds},{timezone:e.timezone}),A=String(e.timezone||l?.schedule?.timezone||l?.timezone||`UTC`).trim(),j=l&&typeof l==`object`&&(l.operator_preferences||l.operatorPreferences)||{},re=j?.knowledge||{},M=ke(e.goal).rollout,N=String(j?.execution_mode||e.mode||`team`).trim(),P=T.find(e=>e.id===N),ie=Number(j?.max_parallel_agents??j?.maxParallelAgents??(N===`single`?1:e.maxAgents)),F=String(l?.execution?.profile||l?.execution_profile||l?.executionProfile||j?.execution_profile||j?.executionProfile||e.executionProfile||``).trim().toLowerCase(),ae=F?Ie(F):`System default`,oe=F?Le(F):`Falls back to the tenant default execution profile. If no tenant default is configured, Tandem runs as Guided.`,I=!!l,se=String(I?j?.model_provider||j?.modelProvider||``:e.modelProvider||``).trim(),L=String(I?j?.model_id||j?.modelId||``:e.modelId||``).trim(),R=j?.role_models?.planner||j?.roleModels?.planner,ce=String(I?R?.provider_id||R?.providerId||``:e.plannerModelProvider||``).trim(),le=String(I?R?.model_id||R?.modelId||``:e.plannerModelId||``).trim(),ue=String(l?.workspace_root||l?.workspaceRoot||e.workspaceRoot||``).trim(),de=Array.isArray(l?.allowed_mcp_servers||l?.allowedMcpServers)?l?.allowed_mcp_servers||l?.allowedMcpServers:e.selectedMcpServers,fe=String(I?j?.tool_access_mode||j?.toolAccessMode||`all`:e.toolAccessMode||`all`).trim(),pe=I?yi((j?.tool_allowlist||j?.toolAllowlist||[]).map(e=>String(e||``).trim())):bi(e.customToolsText),z=l?.schedule?U({scheduleKind:l.schedule.type===`cron`?`cron`:l.schedule.type===`interval`?`interval`:`manual`,cronExpression:l.schedule.cron_expression||l.schedule.cronExpression||``,intervalSeconds:String(l.schedule.interval_seconds||l.schedule.intervalSeconds||`3600`)},{timezone:A}):ne,me=String(l?.title||``).trim(),he=String(S?.fallback_reason||S?.fallbackReason||``).trim(),ge=String(S?.detail||``).trim(),_e=v.status===`waiting`,ve=!!he,B=String(i?.match_layer||i?.matchLayer||``).trim().toLowerCase(),V=!!(i?.requires_user_confirmation||i?.requiresUserConfirmation),H=Number(i?.similarity_score??i?.similarityScore??NaN),ye=e=>k(t=>({...t,[e]:!t[e]}));return f(`div`,{className:`grid gap-4`,children:[f(`p`,{className:`text-sm text-slate-400`,children:`Review your automation before deploying.`}),f(`div`,{className:`grid gap-3 rounded-xl border border-slate-700/60 bg-slate-900/40 p-4`,children:[me?f(`div`,{className:`grid gap-1`,children:[f(`span`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:`Plan Title`}),f(`span`,{className:`text-sm font-semibold text-slate-100`,children:me})]}):null,f(`div`,{className:`grid grid-cols-2 gap-3`,children:[f(`div`,{className:`grid gap-1`,children:[f(`span`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:`Schedule`}),f(`span`,{className:`text-sm font-medium text-slate-200`,children:z})]}),f(`div`,{className:`grid gap-1`,children:[f(`span`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:`Timezone`}),f(`span`,{className:`text-sm font-medium text-slate-200`,children:A||`UTC`})]}),f(`div`,{className:`grid gap-1`,children:[f(`span`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:`Execution Mode`}),f(`span`,{className:`text-sm font-medium text-slate-200`,children:[P?.icon,` `,P?.label||N,Number.isFinite(ie)&&ie>1?` · ${ie} agents`:``]})]}),f(`div`,{className:`grid gap-1`,children:[f(`span`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:`Execution Profile`}),f(`span`,{className:`text-sm font-medium text-slate-200`,children:ae}),f(`span`,{className:`text-xs text-slate-500`,children:oe})]})]}),I||se||L?f(`div`,{className:`grid gap-1`,children:[f(`span`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:`Model Override`}),f(`span`,{className:`text-sm font-medium text-slate-200`,children:se||L?`${se||`default provider`} / ${L||`default model`}`:`Workspace default`})]}):null,I||ce||le?f(`div`,{className:`grid gap-1`,children:[f(`span`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:`Planner Model`}),f(`span`,{className:`text-sm font-medium text-slate-200`,children:ce||le?`${ce||`default provider`} / ${le||`default model`}`:`Using model override`})]}):null,f(`div`,{className:`grid gap-2 rounded-md border border-cyan-500/10 bg-cyan-500/5 p-3`,children:[f(`span`,{className:`text-xs uppercase tracking-wide text-cyan-200/80`,children:`Knowledge defaults`}),f(`div`,{className:`flex flex-wrap gap-1`,children:[f(`span`,{className:`tcp-badge-info`,children:[`reuse: `,xi(re.reuse_mode||`preflight`)]}),f(`span`,{className:`tcp-badge-info`,children:[`trust: `,xi(re.trust_floor||`promoted`)]}),f(`span`,{className:`tcp-badge-info`,children:`scope: project`}),f(`span`,{className:`tcp-badge-info`,children:[`subject: `,xi(re.subject||e.goal||`inferred`)]})]}),f(`div`,{className:`tcp-subtle text-xs`,children:`The wizard starts from project-scoped promoted knowledge, then promotes reusable outcomes only after validation.`})]}),f(`div`,{className:`grid gap-2 rounded-md border border-amber-500/15 bg-amber-500/5 p-3`,children:[f(`span`,{className:`text-xs uppercase tracking-wide text-amber-200/80`,children:`Rollout guardrails`}),f(`div`,{className:`flex flex-wrap gap-1`,children:[f(`span`,{className:`tcp-badge-warn`,children:`project-first pilot`}),f(`span`,{className:`tcp-badge-warn`,children:`promoted only`}),f(`span`,{className:`tcp-badge-warn`,children:`approved_default rare`})]}),f(`ul`,{className:`space-y-1 text-xs text-slate-300`,children:M.guardrails.map(e=>f(`li`,{children:[`• `,e]},e))})]}),f(`div`,{className:`grid gap-1`,children:[f(`span`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:`Workspace Root`}),f(`code`,{className:`rounded bg-slate-800/60 px-2 py-1 text-xs text-slate-300`,children:ue||`engine workspace root`})]}),I||de.length?f(`div`,{className:`grid gap-1`,children:[f(`span`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:`MCP Servers`}),de.length?f(`div`,{className:`flex flex-wrap gap-1`,children:de.map(e=>f(`span`,{className:`tcp-badge-info`,children:e},e))}):f(`span`,{className:`text-sm font-medium text-slate-400`,children:`None`})]}):null,f(`div`,{className:`grid gap-1`,children:[f(`span`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:`Tool Access`}),fe===`custom`?pe.length?f(`div`,{className:`flex flex-wrap gap-1`,children:pe.map(e=>f(`span`,{className:`tcp-badge-info`,children:e},e))}):f(`span`,{className:`text-sm font-medium text-slate-400`,children:`Custom allowlist`}):f(`span`,{className:`text-sm font-medium text-slate-200`,children:`All tools`})]}),e.scheduleKind===`cron`&&e.cron?f(`div`,{className:`grid gap-1`,children:[f(`span`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:`Cron`}),f(`code`,{className:`rounded bg-slate-800/60 px-2 py-1 text-xs text-slate-300`,children:e.cron})]}):null,f(`div`,{className:`grid gap-1`,children:[f(`span`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:`Workflow Plan`}),u?f(`div`,{className:`grid gap-2`,children:[f(`span`,{className:`text-sm text-slate-300`,children:`Planning workflow…`}),y?f(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs text-amber-100`,children:y}):null]}):_e?f(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-3 text-sm text-amber-100`,children:[f(`div`,{className:`font-medium text-amber-200`,children:`Planner is waiting for clarification`}),f(`div`,{className:`mt-1`,children:v.question}),f(`div`,{className:`mt-2 text-xs text-amber-100/80`,children:`The generic scaffold is being hidden because it is only a fallback draft, not a real workflow plan yet.`})]}):ve?f(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-3 text-sm text-amber-100`,children:[f(`div`,{className:`font-medium text-amber-200`,children:`Planner returned a fallback draft`}),f(`div`,{className:`mt-1`,children:he.replace(/_/g,` `)||`fallback draft`}),ge?f(`div`,{className:`mt-2 text-xs text-amber-100/80`,children:ge}):null,f(`div`,{className:`mt-2 text-xs text-amber-100/80`,children:`Tandem is hiding the scaffolded workflow here so we do not accidentally create a generic automation from a failed planning run.`})]}):l?f(`div`,{className:`grid gap-1 text-sm text-slate-300`,children:[f(`span`,{children:[`Confidence: `,f(`strong`,{children:String(l?.confidence||`unknown`)})]}),f(`span`,{children:[`Execution target:`,` `,f(`strong`,{children:String(l?.execution_target||`automation_v2`)})]}),me?f(`span`,{children:[`Title: `,f(`strong`,{children:me})]}):null,f(`span`,{children:[`Steps:`,` `,f(`strong`,{children:Array.isArray(l?.steps)?l.steps.length:0})]}),Array.isArray(l?.steps)&&l.steps.length?f(`div`,{className:`mt-1 grid gap-1`,children:l.steps.map((e,t)=>{let n=String(e?.step_id||e?.stepId||`step-${t+1}`),r=!!te[n];return f(`div`,{className:`rounded-lg border border-slate-800 bg-slate-950/40`,children:[f(`button`,{className:`flex w-full items-center justify-between gap-3 px-3 py-2 text-left`,onClick:()=>ye(n),children:[f(`div`,{className:`min-w-0`,children:f(`div`,{className:`text-xs font-medium text-slate-200`,children:[n,e?.kind?f(`span`,{className:`ml-2 text-[11px] uppercase tracking-wide text-slate-500`,children:String(e.kind)}):null]})}),f(`span`,{className:`tcp-subtle shrink-0 text-xs`,children:r?`Hide`:`Details`})]}),r&&typeof e?.objective==`string`&&e.objective.trim()?f(`div`,{className:`border-t border-slate-800 px-3 py-3`,children:f(`div`,{className:`text-sm text-slate-300`,dangerouslySetInnerHTML:{__html:x(e.objective||``)}})}):null]},`${n}-${t}`)})}):null]}):f(`span`,{className:`text-sm text-slate-400`,children:`Workflow preview has not been generated yet.`})]})]}),b&&!_e?f(`div`,{className:`rounded-xl border border-red-500/40 bg-red-950/30 p-3 text-sm text-red-200`,children:b}):null,i?.matched_plan_id||i?.matchedPlanId?f(`div`,{className:`rounded-xl border border-indigo-500/30 bg-indigo-950/20 p-3 text-sm text-indigo-100`,children:[f(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[f(`div`,{className:`font-medium text-indigo-200`,children:`Overlap review`}),f(`span`,{className:V?`tcp-badge-warning`:`tcp-badge-info`,children:V?`confirmation required`:`decision ready`})]}),f(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2 xl:grid-cols-4`,children:[f(`div`,{children:[`prior plan:`,` `,f(`strong`,{children:String(i?.matched_plan_id||i?.matchedPlanId)})]}),f(`div`,{children:[`revision:`,` `,f(`strong`,{children:String(i?.matched_plan_revision||i?.matchedPlanRevision||`n/a`)})]}),f(`div`,{children:[`match layer: `,f(`strong`,{children:B||`n/a`})]}),f(`div`,{children:[`recommended decision:`,` `,f(`strong`,{children:String(i?.decision||`new`).toLowerCase()})]})]}),Number.isFinite(H)?f(`div`,{className:`mt-2 text-xs text-indigo-200/80`,children:[`Similarity score: `,(H*100).toFixed(0),`%`]}):null,V?f(`div`,{className:`mt-3 grid gap-2`,children:[f(`div`,{className:`text-xs uppercase tracking-wide text-indigo-200/80`,children:`Choose how to handle this overlap`}),f(`div`,{className:`flex flex-wrap gap-2`,children:[`reuse`,`merge`,`fork`,`new`].map(e=>f(`button`,{type:`button`,className:o===e?`tcp-btn-primary h-8 px-3 text-xs`:`tcp-btn h-8 px-3 text-xs`,onClick:()=>s(e),children:e},e))}),o?null:f(`div`,{className:`text-xs text-amber-200`,children:`Select a decision before creating the automation.`})]}):null]}):null,p.length?f(`div`,{className:`rounded-xl border border-emerald-500/30 bg-emerald-950/20 p-3`,children:[f(`div`,{className:`text-xs uppercase tracking-wide text-emerald-300`,children:`Latest Plan Changes`}),f(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:p.map((e,t)=>f(`span`,{className:`tcp-badge-ok`,children:e},`${e}-${t}`))})]}):null,l?f(`div`,{className:`grid gap-3 rounded-xl border border-slate-700/60 bg-slate-900/40 p-4`,children:[f(`div`,{className:`flex items-center justify-between gap-2`,children:[f(`span`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:`Planning Chat`}),f(`button`,{className:`tcp-btn h-7 px-2 text-xs`,disabled:_||!l?.plan_id,onClick:g,children:_?`Resetting…`:`Reset Plan`})]}),f(`div`,{className:`max-h-56 overflow-auto rounded-lg border border-slate-800 bg-slate-950/50 p-3`,children:Array.isArray(d?.messages)&&d.messages.length?f(`div`,{className:`grid gap-3`,children:d.messages.map((e,t)=>f(`div`,{className:`grid gap-1`,children:[f(`span`,{className:`text-[11px] uppercase tracking-wide text-slate-500`,children:String(e?.role||`assistant`)}),f(`div`,{className:`text-sm text-slate-200`,children:String(e?.text||``).trim()})]},`${e?.created_at_ms||t}-${t}`))}):f(`div`,{className:`text-sm text-slate-400`,children:`Add planning notes here to revise the workflow before creating it.`})}),f(`textarea`,{className:`tcp-input min-h-[84px] text-sm`,value:E,onInput:e=>D(e.target.value),placeholder:`Example: "Make this weekly, run it from /srv/acme/app, and remove notifications."`}),f(`div`,{className:`flex justify-end`,children:f(`button`,{className:`tcp-btn-primary`,disabled:h||!E.trim()||!l?.plan_id,onClick:()=>{let e=E.trim();e&&(m(e),D(``))},children:h?`Updating plan…`:`Update Plan`})})]}):null,f(`div`,{className:`rounded-xl border border-slate-700/40 bg-slate-800/20 p-3 text-xs text-slate-400`,children:f(`label`,{className:`flex items-start gap-3 rounded-lg border border-slate-700/50 bg-slate-900/30 p-3 text-sm text-slate-300`,children:[f(`input`,{type:`checkbox`,className:`mt-0.5`,checked:e.exportPackDraft,onChange:n}),f(`span`,{className:`grid gap-1`,children:[f(`span`,{className:`font-medium text-slate-200`,children:`Also export a reusable pack draft`}),f(`span`,{className:`text-xs text-slate-400`,children:`After creating the automation, Tandem will also create a Pack Builder draft so this workflow can be saved and reused later.`})]})]})}),C||w?f(`div`,{className:`rounded-xl border border-slate-700/40 bg-slate-800/20 p-3 text-xs text-slate-400`,children:[f(`div`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:`Reusable Skill Export`}),f(`div`,{className:`mt-1 grid gap-1`,children:[C?f(t,{children:[f(`span`,{children:[`Draft status:`,` `,f(`strong`,{className:`text-slate-300`,children:String(C?.status||`generated`)})]}),f(`span`,{className:`text-amber-200`,children:`This draft is prompt-based and may be stale if you changed the workflow plan in planning chat.`})]}):null,w?f(`span`,{children:w}):null]})]}):null,f(`div`,{className:`rounded-xl border border-slate-700/40 bg-slate-800/20 p-3 text-xs text-slate-400`,children:[`💡 Tandem will save this automation and schedule a`,` `,f(`strong`,{className:`text-slate-300`,children:P?.label||N}),` that runs`,` `,f(`strong`,{className:`text-slate-300`,children:z}),`. You can pause, edit or delete it anytime.`]}),f(`button`,{className:`tcp-btn-primary`,disabled:c||u||!e.goal.trim()||!l||_e||ve||V&&!o,onClick:r,children:c?`Creating automation…`:`🚀 Create Automation`})]})}var Ci=Object.assign({"../../../pages/automation-wizard.yaml":hi});function wi(e){if(!String(e||``).trim())throw Error(`Automation wizard config file could not be loaded.`);let t=d.parse(e);if(!t||typeof t!=`object`)throw Error(`Invalid automation wizard config: expected a YAML object.`);let n=t,r=n.defaults||{},i=n.steps,a=n.schedulePresets,o=n.executionModes,s=n.goalExamples;if(!Array.isArray(i)||!i.length)throw Error(`Invalid automation wizard config: steps must be a non-empty array.`);if(!Array.isArray(a)||!a.length)throw Error(`Invalid automation wizard config: schedulePresets must be a non-empty array.`);if(!Array.isArray(o)||!o.length)throw Error(`Invalid automation wizard config: executionModes must be a non-empty array.`);if(!Array.isArray(s)||!s.length)throw Error(`Invalid automation wizard config: goalExamples must be a non-empty array.`);return{defaults:{schedulePreset:String(r.schedulePreset||``).trim()||`Every morning`,mode:r.mode===`single`||r.mode===`team`||r.mode===`swarm`?r.mode:`team`,maxAgents:String(r.maxAgents||``).trim()||`4`},steps:i.map(e=>String(e||``).trim()).filter(Boolean),schedulePresets:a.map(e=>({label:String(e?.label||``).trim(),desc:String(e?.desc||``).trim(),icon:String(e?.icon||``).trim(),cron:String(e?.cron||``).trim(),intervalSeconds:e?.intervalSeconds===void 0||e?.intervalSeconds===null?void 0:Number(e.intervalSeconds)})),executionModes:o.map(e=>({id:e?.id===`single`||e?.id===`team`||e?.id===`swarm`?e.id:`team`,label:String(e?.label||``).trim(),icon:String(e?.icon||``).trim(),desc:String(e?.desc||``).trim(),bestFor:String(e?.bestFor||``).trim()})),goalExamples:s.map(e=>String(e||``).trim()).filter(Boolean)}}var Ti=Object.values(Ci).find(e=>typeof e==`string`&&e.trim().length>0);function Ei(e){return String(e||``).trim()}function Di(e){let t=e?.parentElement||null;for(;t;){let e=window.getComputedStyle(t).overflowY.toLowerCase();if((e===`auto`||e===`scroll`||e===`overlay`)&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement}return null}function Oi(e){let t=Ei(e?.clarifier?.question);return t?{status:`waiting`,question:t}:{status:`none`,question:``}}function ki(e){let t=Ei(e.goal);if(!t)return``;let n=t.toLowerCase(),r=[`reddit`,`notion`,`github`,`slack`,`jira`,`airtable`,`gmail`,`mcp`].filter(e=>n.includes(e)).length;return t.length>=2500||e.selectedMcpServers.length>=2||r>=2||e.scheduleKind!==`manual`&&(t.length>=1500||e.selectedMcpServers.length>=1)?`This workflow is connector-heavy or unusually detailed, so plan generation can take a few minutes.`:``}var Ai=wi(Ti||``),ji=`tandem.automations.plannerSeed`,Mi=`tandem.automations.createWizardDraft`;function Ni(e,t,n=``,r=H()){let i=Ai.schedulePresets.find(e=>e.label===Ai.defaults.schedulePreset),a=i?.intervalSeconds!==void 0&&i.intervalSeconds!==null?{scheduleKind:`interval`,cron:``,intervalSeconds:String(i.intervalSeconds)}:i?.cron?{scheduleKind:`cron`,cron:i.cron,intervalSeconds:`3600`}:{scheduleKind:`manual`,cron:``,intervalSeconds:`3600`};return{goal:``,workspaceRoot:n,timezone:String(r||``).trim()||H(),schedulePreset:Ai.defaults.schedulePreset,scheduleKind:a.scheduleKind,cron:a.cron,intervalSeconds:a.intervalSeconds,mode:Ai.defaults.mode,executionProfile:``,maxAgents:Ai.defaults.maxAgents,routedSkill:``,routingConfidence:``,modelProvider:String(e||``),modelId:String(t||``),plannerModelProvider:``,plannerModelId:``,roleModelsJson:``,toolAccessMode:`all`,customToolsText:``,selectedMcpServers:[],exportPackDraft:!1,advancedMode:!1,customSkillName:``,customSkillDescription:``,customWorkflowKind:`pack_builder_recipe`}}function Pi(e){return Array.isArray(e?.servers)?e.servers.map(e=>{let t=String(e?.name||``).trim();if(!t)return null;let n=e?.last_auth_challenge||e?.lastAuthChallenge||null,r=Ei(n?.authorization_url||n?.authorizationUrl||e?.authorization_url||e?.authorizationUrl),i=Ei(n?.message);return{name:t,connected:!!e?.connected,enabled:e?.enabled!==!1,authKind:Ei(e?.auth_kind||e?.authKind).toLowerCase(),lastError:Ei(e?.last_error||e?.lastError),pendingAuth:!!n||!!r,authMessage:i,authorizationUrl:r}}).filter(e=>!!e).sort((e,t)=>e.name.localeCompare(t.name)):e&&typeof e==`object`?Object.entries(e).map(([e,t])=>{let n=String(e||``).trim();if(!n)return null;let r=t&&typeof t==`object`?t:{},i=r?.last_auth_challenge||r?.lastAuthChallenge||null,a=Ei(i?.authorization_url||i?.authorizationUrl||r?.authorization_url||r?.authorizationUrl),o=Ei(i?.message);return{name:n,connected:!!r.connected,enabled:r.enabled!==!1,authKind:Ei(r.auth_kind||r.authKind).toLowerCase(),lastError:Ei(r.last_error||r.lastError),pendingAuth:!!i||!!a,authMessage:o,authorizationUrl:a}}).filter(e=>!!e).sort((e,t)=>e.name.localeCompare(t.name)):[]}function Fi(e){try{sessionStorage.setItem(Mi,JSON.stringify({wizard:e.wizard,step:e.step,plan_source:Ei(e.planSource)||`automations_page`,saved_at:Date.now()}))}catch{}}function Ii(e){let t=String(e.timezone||``).trim()||`UTC`;if(e.scheduleKind===`manual`)return{type:`manual`,timezone:t};if(e.scheduleKind===`interval`)return{interval_seconds:{seconds:Math.max(1,Number.parseInt(String(e.intervalSeconds||`3600`),10)||3600)},timezone:t};let n=String(e.cron||``).trim();if(n)return{cron:{expression:n},timezone:t};let r=Ai.schedulePresets.find(t=>t.label===e.schedulePreset);return r?.intervalSeconds?{interval_seconds:{seconds:r.intervalSeconds},timezone:t}:r?.cron?{cron:{expression:r.cron},timezone:t}:{type:`manual`,timezone:t}}function Li(e){let t=String(e||``).trim().toLowerCase();return t===`strict`||t===`guided`||t===`yolo`?t:null}function Ri(e,t){if(!e||typeof e!=`object`)return e;let n=String(t.timezone||``).trim(),r=Li(t.executionProfile),i={...e};return n&&i.schedule&&typeof i.schedule==`object`&&(i.schedule={...i.schedule,timezone:n}),r&&(i.execution={...i.execution&&typeof i.execution==`object`?i.execution:{},profile:r}),i}function zi(e){let t=String(e||``).trim();return t?t.startsWith(`/`)?``:`Workspace root must be an absolute path.`:`Workspace root is required.`}function Bi(e,t){let n=String(e||``).trim(),r=String(t||``).trim();return!n&&!r?``:n?r?``:`Planner model is required when a planner provider is set.`:`Planner model provider is required when a planner model is set.`}function Vi(e){let t=String(e||``).trim();if(!t)return``;try{let e=JSON.parse(t);return!e||typeof e!=`object`||Array.isArray(e)?`Role model overrides must be a JSON object.`:``}catch{return`Role model overrides must be valid JSON.`}}function Hi(e){let t,n=String(e.roleModelsJson||``).trim();if(n)try{let e=JSON.parse(n);e&&typeof e==`object`&&!Array.isArray(e)&&(t=e)}catch{t=void 0}let r=String(e.plannerModelProvider||``).trim(),i=String(e.plannerModelId||``).trim();r&&i&&(t={...t||{}},t.planner={provider_id:r,model_id:i});let a=e.mode===`single`?1:Math.max(2,Math.min(16,Number.parseInt(String(e.maxAgents||`4`),10)||4)),o={execution_mode:e.mode,max_parallel_agents:a},s=Li(e.executionProfile);return s&&(o.execution_profile=s),String(e.modelProvider||``).trim()&&(o.model_provider=String(e.modelProvider).trim()),String(e.modelId||``).trim()&&(o.model_id=String(e.modelId).trim()),t&&Object.keys(t).length&&(o.role_models=t),Object.assign(o,je(e.goal)),o}function Ui({client:t,api:o,toast:l,navigate:d,defaultProvider:h,defaultModel:g,onNavigationLockChange:_,onCreated:v}){let y=s(),b=i(null),[x,S]=a(1),[C,w]=a(`automations_page`),[T,E]=a([]),[D,O]=a(null),[ee,te]=a(null),[k,ne]=a(``),[A,j]=a(null),[re,M]=a([]),[N,P]=a({status:`none`,question:``}),[ie,F]=a(``),[ae,oe]=a(null),[I,se]=a(!1),[L,R]=a(``),[ce,le]=a(``),[ue,de]=a(``),[fe,pe]=a(null),[z,me]=a(!1),[he,ge]=a(`SKILL.md`),[_e,ve]=a(``),[B,H]=a(()=>Ni(h,g)),ye=c({queryKey:[`settings`,`providers`,`catalog`],queryFn:()=>t.providers.catalog().catch(()=>({all:[]})),refetchInterval:3e4}),U=c({queryKey:[`settings`,`providers`,`config`],queryFn:()=>t.providers.config().catch(()=>({})),refetchInterval:3e4}),be=c({queryKey:[`mcp`,`servers`],queryFn:()=>t.mcp.list().catch(()=>({})),refetchInterval:12e3}),xe=c({queryKey:[`global`,`health`],queryFn:()=>t.health().catch(()=>({})),refetchInterval:3e4}),Se=c({queryKey:[`automations`,`workspace-browser`,L],enabled:I&&!!L,queryFn:()=>o(`/api/orchestrator/workspaces/list?dir=${encodeURIComponent(L)}`,{method:`GET`})}),W=r(()=>Ae({providerCatalog:ye.data,providerConfig:U.data,defaultProvider:String(U.data?.default||h||``).trim(),defaultModel:String(U.data?.providers?.[String(U.data?.default||h||``).trim()]?.default_model||U.data?.providers?.[String(U.data?.default||h||``).trim()]?.defaultModel||g||``).trim()}),[g,h,ye.data,U.data]),G=r(()=>Pi(be.data),[be.data]),Ce=Array.isArray(Se.data?.directories)?Se.data.directories:[],we=String(Se.data?.parent||``).trim(),Te=String(Se.data?.dir||L||``).trim(),Ee=String(ce||``).trim().toLowerCase(),De=r(()=>Ee?Ce.filter(e=>String(e?.name||e?.path||``).trim().toLowerCase().includes(Ee)):Ce,[Ce,Ee]),Oe=r(()=>ki(B),[B]),ke=async()=>{await y.invalidateQueries({queryKey:[`mcp`]})};e(()=>{let e=String(U.data?.default||h||``).trim();if(!e)return;let t=W.find(t=>t.id===e)?.id||W[0]?.id||``;if(!t)return;let n=W.find(e=>e.id===t)?.models||[],r=String(U.data?.providers?.[t]?.default_model||g||n[0]||``).trim();H(e=>e.modelProvider&&e.modelId?e:{...e,modelProvider:e.modelProvider||t,modelId:e.modelId||r})},[g,h,W,U.data]),e(()=>{let e=String(xe.data?.workspaceRoot||xe.data?.workspace_root||``).trim();e&&H(t=>String(t.workspaceRoot||``).trim()?t:{...t,workspaceRoot:e})},[xe.data]);let je=u({mutationFn:async e=>!e.trim()||!t?.skills?.match?null:t.skills.match({goal:e,maxMatches:3,threshold:.35})}),Me=u({mutationFn:async()=>{if(!t?.workflowPlans?.chatStart)throw Error(`This control panel build is missing workflow planner client support. Rebuild the control panel against the local tandem client package.`);return await t.workflowPlans.chatStart({prompt:B.goal,schedule:Ii(B),plan_source:C,allowed_mcp_servers:B.selectedMcpServers,workspace_root:B.workspaceRoot,operator_preferences:Hi(B)})||null},onSuccess:e=>{let t=Oi(e);O(e?.plan||null),te(e?.overlap_analysis||e?.overlapAnalysis||null),ne(``),j(e?.conversation||null),M([]),P(t),F(``),oe(e?.planner_diagnostics||e?.plannerDiagnostics||null)},onError:e=>{O(null),te(null),ne(``),j(null),M([]),P({status:`none`,question:``});let t=e instanceof Error?e.message:String(e);F(t),oe(null),l(`err`,t)}}),Ne=u({mutationFn:async e=>!t?.workflowPlans?.chatMessage||!D?.plan_id?null:t.workflowPlans.chatMessage({plan_id:D.plan_id,message:e}),onSuccess:e=>{let t=Oi(e);O(e?.plan||null),te(e?.overlap_analysis||e?.overlapAnalysis||null),ne(``),j(e?.conversation||null),M(Array.isArray(e?.change_summary)?e.change_summary.map(e=>String(e||``).trim()).filter(Boolean):[]),P(t),F(``),oe(e?.planner_diagnostics||e?.plannerDiagnostics||null)},onError:e=>{let t=e instanceof Error?e.message:String(e);P({status:`none`,question:``}),F(t),l(`err`,t)}}),Pe=u({mutationFn:async()=>!t?.workflowPlans?.chatReset||!D?.plan_id?null:t.workflowPlans.chatReset({plan_id:D.plan_id}),onSuccess:e=>{let t=Oi(e);O(e?.plan||null),te(e?.overlap_analysis||e?.overlapAnalysis||null),ne(``),j(e?.conversation||null),M([]),P(t),F(``),oe(e?.planner_diagnostics||e?.plannerDiagnostics||null)},onError:e=>{let t=e instanceof Error?e.message:String(e);P({status:`none`,question:``}),F(t),l(`err`,t)}}),Fe=u({mutationFn:async({action:e,server:n})=>e===`connect`?t.mcp.connect(n.name):o(`/api/engine/mcp/${encodeURIComponent(n.name)}/auth/authenticate`,{method:`POST`}),onSuccess:async(e,t)=>{await ke();let n=!!e?.pendingAuth||!!e?.lastAuthChallenge||!!e?.authorizationUrl,r=e?.ok!==!1,i=e?.lastAuthChallenge||{},a=Ei(i?.authorization_url||i?.authorizationUrl||e?.authorizationUrl||t.server.authorizationUrl),o=Ei(i?.message||t.server.authMessage);if(t.action===`connect`){if(n||!r&&t.server.authKind===`oauth`){a&&window.open(a,`_blank`,`noopener,noreferrer`),l(`warn`,o?`OAuth authorization required for ${t.server.name}: ${o}`:`OAuth authorization required for ${t.server.name}. Finish sign-in in your browser, then click Mark sign-in complete.`);return}if(!r){let n=Ei(e?.error?.message||e?.error);l(`err`,n?`Failed to connect ${t.server.name}: ${n}`:`Failed to connect ${t.server.name}.`);return}l(`ok`,`Connected ${t.server.name}.`);return}if(!r&&!n){let n=Ei(e?.error?.message||e?.error);l(`err`,n?`OAuth authorization check failed for ${t.server.name}: ${n}`:`OAuth authorization check failed for ${t.server.name}.`);return}if(n){a&&window.open(a,`_blank`,`noopener,noreferrer`),l(`warn`,o?`OAuth authorization still pending for ${t.server.name}: ${o}`:`OAuth authorization still pending for ${t.server.name}.`);return}l(`ok`,`Marked ${t.server.name} as signed in.`)},onError:e=>{l(`err`,e instanceof Error?e.message:String(e))}}),Ie=u({mutationFn:async e=>{if(!t?.skills?.get||!t?.skills?.validate)return null;let n=(await t.skills.get(e))?.content;return n?t.skills.validate({content:n}):null},onSuccess:e=>de(e?e.invalid>0?`not_validated`:`validated`:``),onError:()=>de(`not_validated`)}),Le=u({mutationFn:async()=>{if(!t?.skills?.generate||!B.goal.trim())return null;let e=B.advancedMode?[B.goal.trim(),B.customSkillName?`Skill name: ${B.customSkillName}`:``,B.customSkillDescription?`Description: ${B.customSkillDescription}`:``,`Workflow kind: ${B.customWorkflowKind}`].filter(Boolean).join(`
107
+ `):B.goal;return t.skills.generate({prompt:e})},onSuccess:e=>{pe(e);let t=Object.keys(e?.artifacts||{})[0];ge(t||`SKILL.md`),me(!1),ve(``)},onError:()=>{pe(null),me(!1),ve(`Optional skill generation failed.`)}}),Re=u({mutationFn:async()=>{if(!t?.skills?.generateInstall)return null;let e=fe?.artifacts;if(!e||!e[`SKILL.md`])throw Error(`No generated artifacts available to install.`);return t.skills.generateInstall({location:`project`,conflictPolicy:`rename`,artifacts:{"SKILL.md":e[`SKILL.md`],"workflow.yaml":e[`workflow.yaml`],"automation.example.yaml":e[`automation.example.yaml`]}})},onSuccess:e=>{let t=e?.skill?.name;ve(t?`Installed optional skill as '${String(t)}' in project skills.`:`Installed optional skill in project skills.`),y.invalidateQueries({queryKey:[`automations`]})},onError:e=>ve(`Install failed: ${e instanceof Error?e.message:String(e)}`)}),ze=u({mutationFn:async()=>{if(!B.goal.trim())throw Error(`Please describe your goal first.`);if(N.status===`waiting`)throw Error(N.question||`Planner needs clarification before this automation can be created.`);if(Ei(ae?.fallback_reason||ae?.fallbackReason))throw Error(`Planner returned a fallback draft instead of a real workflow plan. Regenerate the plan before creating the automation.`);let e=D||await Me.mutateAsync().catch(e=>{throw e instanceof Error?e:Error(String(e))}),n=Ri(e?.plan||e,B);if(!n)throw Error(`Workflow plan preview failed.`);if((ee?.requires_user_confirmation||ee?.requiresUserConfirmation)&&!k.trim())throw Error(`Select an overlap decision before creating the automation.`);return t.workflowPlans.apply({plan:n,creator_id:`control-panel`,overlap_decision:k.trim()||void 0,...B.exportPackDraft?{pack_builder_export:{enabled:!0,auto_apply:!1}}:{}})},onSuccess:async e=>{try{sessionStorage.removeItem(Mi)}catch{}let t=e?.pack_builder_export?.status;l(`ok`,t===`preview_pending`?`🎉 Automation created and reusable pack draft exported. Check Pack Builder to continue.`:`🎉 Automation created! Check 'Library' to see it running.`),await Promise.all([y.invalidateQueries({queryKey:[`automations`]}),y.invalidateQueries({queryKey:[`mcp`]})]),H(Ni(h,g,String(xe.data?.workspaceRoot||xe.data?.workspace_root||``).trim())),E([]),w(`automations_page`),O(null),te(null),ne(``),j(null),M([]),P({status:`none`,question:``}),F(``),de(``),pe(null),me(!1),ge(`SKILL.md`),ve(``),S(1),v?.()},onError:e=>{let t=e instanceof Error?e.message:String(e);F(t),l(`err`,t)}}),K=zi(B.workspaceRoot),Be=Bi(B.plannerModelProvider,B.plannerModelId),Ve=Vi(B.roleModelsJson),He=r(()=>Me.isPending?{title:`Generating mission plan`,message:`Tandem is drafting the workflow plan. Stay on this page until it finishes.`}:Le.isPending||Re.isPending?{title:`Generating reusable skill`,message:`Tandem is drafting the reusable skill. Stay on this page until it finishes.`}:Ne.isPending||Pe.isPending?{title:`Updating planning draft`,message:`Tandem is revising the draft. Stay on this page until it finishes.`}:ze.isPending?{title:`Creating automation`,message:`Tandem is creating the automation. Stay on this page until it finishes.`}:null,[Me.isPending,ze.isPending,Le.isPending,Re.isPending,Ne.isPending,Pe.isPending]);n(()=>(_?.(He),()=>{_?.(null)}),[He,_]),n(()=>{let e=b.current;if(!e)return;e.scrollIntoView({block:`start`,behavior:`auto`});let t=Di(e);if(t){t.scrollTo({top:0,behavior:`auto`});return}window.scrollTo({top:0,behavior:`auto`})},[x]);let Ue=String(B.timezone||``).trim().length>0&&!V(B.timezone)?`Timezone must be a valid IANA timezone like Europe/Berlin.`:``,We=x===1?B.goal.trim().length>8:x===2?(B.scheduleKind===`manual`||B.scheduleKind===`cron`&&!!B.cron.trim()||B.scheduleKind===`interval`&&(Number.parseInt(String(B.intervalSeconds||`0`),10)||0)>0||!!B.schedulePreset)&&!Ue:x===3?!!B.mode&&!K&&!Be&&!Ve:!0,q=async()=>{if(x===1){let e=await je.mutateAsync(B.goal);e&&e.decision===`match`&&e.skill_name?(Ie.mutateAsync(String(e.skill_name)),H(t=>({...t,routedSkill:String(e.skill_name),routingConfidence:typeof e.confidence==`number`?`${Math.round(e.confidence*100)}%`:``}))):(de(``),H(e=>({...e,routedSkill:``,routingConfidence:``}))),E(Array.isArray(e?.top_matches)?e.top_matches:[])}let e=x+1;if(e===4){F(``),O(null),j(null),M([]),P({status:`none`,question:``}),oe(null),Oe&&l(`info`,Oe);try{await Me.mutateAsync()}catch{return}}S(e)};return e(()=>{try{let e=sessionStorage.getItem(Mi);if(e){sessionStorage.removeItem(Mi);let t=JSON.parse(e),n=t?.wizard;if(n&&typeof n==`object`){H(e=>({...e,...n}));let e=Number(t?.step);e>=1&&e<=4&&S(e);let r=Ei(t?.plan_source);r&&w(r),l(`info`,`Restored your automation draft after returning from MCP setup.`);return}}}catch{}try{let e=sessionStorage.getItem(ji);if(!e)return;sessionStorage.removeItem(ji);let t=JSON.parse(e),n=String(t?.prompt||``).trim();if(!n)return;w(String(t?.plan_source||`chat_setup`).trim()||`chat_setup`),H(e=>({...e,goal:n}))}catch{return}},[l]),f(`div`,{ref:b,className:`flex flex-col h-full gap-4 min-h-0 relative`,children:[f(`div`,{className:`flex items-center gap-2`,children:Ai.steps.map((e,t)=>{let n=t+1,r=n===x,i=n<x;return f(`div`,{className:`flex-1`,children:[f(`button`,{className:`mb-1 flex w-full items-center gap-1.5 rounded-lg px-2 py-1 text-xs font-medium transition-all ${r?`bg-amber-500/20 text-amber-300`:i?`text-slate-400`:`text-slate-600`}`,onClick:()=>i&&S(n),children:[f(`span`,{className:`flex h-5 w-5 items-center justify-center rounded-full text-xs font-bold ${r?`bg-amber-500 text-black`:i?`bg-slate-600 text-white`:`bg-slate-800 text-slate-500`}`,children:i?`✓`:n}),e]}),f(`div`,{className:`h-0.5 w-full rounded-full bg-slate-800`,children:f(`div`,{className:`h-full rounded-full bg-amber-500 transition-all`,style:{width:i?`100%`:r?`50%`:`0%`}})})]},e)})}),f(m,{mode:`wait`,children:f(p.div,{className:`flex-1 flex flex-col min-h-0 overflow-hidden`,initial:{opacity:0,x:16},animate:{opacity:1,x:0},exit:{opacity:0,x:-16},transition:{duration:.18},children:x===1?f(gi,{value:B.goal,onChange:e=>H(t=>({...t,goal:e})),routedSkill:B.routedSkill,routingConfidence:B.routingConfidence,validationBadge:ue,generatedSkill:fe,advancedMode:B.advancedMode,customSkillName:B.customSkillName,customSkillDescription:B.customSkillDescription,customWorkflowKind:B.customWorkflowKind,onToggleAdvancedMode:()=>H(e=>({...e,advancedMode:!e.advancedMode})),onChangeCustomSkillName:e=>H(t=>({...t,customSkillName:e})),onChangeCustomSkillDescription:e=>H(t=>({...t,customSkillDescription:e})),onChangeCustomWorkflowKind:e=>H(t=>({...t,customWorkflowKind:e})),showArtifactPreview:z,onToggleArtifactPreview:()=>me(e=>!e),artifactPreviewKey:he,onSelectArtifactPreviewKey:e=>ge(e),onGenerateSkill:()=>void Le.mutateAsync(),onInstallGeneratedSkill:()=>void Re.mutateAsync(),isGeneratingSkill:Le.isPending,isInstallingSkill:Re.isPending,installStatus:_e,topMatches:T,isMatching:je.isPending,goalPlaceholder:Ai.goalExamples[0]}):x===2?f(_i,{selected:B.schedulePreset,presets:Ai.schedulePresets,onSelect:e=>H(t=>({...t,schedulePreset:e.label,scheduleKind:e.intervalSeconds!==void 0&&e.intervalSeconds!==null?`interval`:e.cron?`cron`:`manual`,cron:e.cron,intervalSeconds:e.intervalSeconds!==void 0&&e.intervalSeconds!==null?String(e.intervalSeconds):t.intervalSeconds})),scheduleValue:{scheduleKind:B.scheduleKind,cronExpression:B.cron,intervalSeconds:B.intervalSeconds},timezone:B.timezone,timezoneError:Ue,onScheduleChange:e=>H(t=>({...t,schedulePreset:``,scheduleKind:e.scheduleKind,cron:e.cronExpression,intervalSeconds:e.intervalSeconds})),onTimezoneChange:e=>H(t=>({...t,timezone:e}))}):x===3?f(vi,{selected:B.mode,onSelect:e=>H(t=>({...t,mode:e})),executionModes:Ai.executionModes,maxAgents:B.maxAgents,onMaxAgents:e=>H(t=>({...t,maxAgents:e})),executionProfile:B.executionProfile,onExecutionProfileChange:e=>H(t=>({...t,executionProfile:e})),workspaceRoot:B.workspaceRoot,onWorkspaceRootChange:e=>H(t=>({...t,workspaceRoot:e})),providerOptions:W,providerId:B.modelProvider,modelId:B.modelId,plannerProviderId:B.plannerModelProvider,plannerModelId:B.plannerModelId,onProviderChange:e=>H(t=>({...t,modelProvider:e,modelId:e===t.modelProvider?t.modelId:``})),onModelChange:e=>H(t=>({...t,modelId:e})),onPlannerProviderChange:e=>H(t=>({...t,plannerModelProvider:e,plannerModelId:e===t.plannerModelProvider?t.plannerModelId:``})),onPlannerModelChange:e=>H(t=>({...t,plannerModelId:e})),roleModelsJson:B.roleModelsJson,onRoleModelsChange:e=>H(t=>({...t,roleModelsJson:e})),roleModelsError:Ve,toolAccessMode:B.toolAccessMode,customToolsText:B.customToolsText,onToolAccessModeChange:e=>H(t=>({...t,toolAccessMode:e})),onCustomToolsTextChange:e=>H(t=>({...t,customToolsText:e})),mcpServers:G,selectedMcpServers:B.selectedMcpServers,onToggleMcpServer:e=>H(t=>({...t,selectedMcpServers:t.selectedMcpServers.includes(e)?t.selectedMcpServers.filter(t=>t!==e):[...t.selectedMcpServers,e]})),onConnectMcpServer:e=>{let t=G.find(t=>t.name===e);t&&Fe.mutateAsync({action:`connect`,server:t})},onCompleteMcpSignIn:e=>{let t=G.find(t=>t.name===e);t&&Fe.mutateAsync({action:`authenticate`,server:t})},onRefreshMcpServers:()=>{ke()},onOpenMcpSettings:()=>{Fi({wizard:B,step:x,planSource:C}),l(`info`,`Saved this automation draft. After connecting your MCPs, return to Automations and the wizard will restore where you left off.`),d(`mcp`)},activeMcpAction:Fe.isPending?{name:Fe.variables?.server?.name||``,action:Fe.variables?.action||``}:null,workspaceRootError:K,plannerModelError:Be,workspaceBrowserOpen:I,workspaceBrowserDir:L,workspaceBrowserSearch:ce,onWorkspaceBrowserSearchChange:le,onOpenWorkspaceBrowser:()=>{R(String(B.workspaceRoot||xe.data?.workspaceRoot||xe.data?.workspace_root||`/`).trim()||`/`),le(``),se(!0)},onCloseWorkspaceBrowser:()=>{se(!1),le(``)},onBrowseWorkspaceParent:()=>{we&&R(we)},onBrowseWorkspaceDirectory:e=>R(e),onSelectWorkspaceDirectory:()=>{Te&&(H(e=>({...e,workspaceRoot:Te})),se(!1),le(``),l(`ok`,`Workspace selected: ${Te}`))},workspaceBrowserParentDir:we,workspaceCurrentBrowseDir:Te,filteredWorkspaceDirectories:De}):f(Si,{wizard:B,onToggleExportPackDraft:()=>H(e=>({...e,exportPackDraft:!e.exportPackDraft})),onSubmit:()=>ze.mutate(),overlapAnalysis:ee,overlapDecision:k,onSelectOverlapDecision:ne,isPending:ze.isPending,planPreview:D,isPreviewing:Me.isPending,planningConversation:A,planningChangeSummary:re,onSendPlanningMessage:e=>{Ne.mutateAsync(e)},isSendingPlanningMessage:Ne.isPending,onResetPlanningChat:()=>{Pe.mutateAsync()},isResettingPlanningChat:Pe.isPending,planningClarification:N,plannerLatencyAdvisory:Oe,plannerError:ie,plannerDiagnostics:ae,generatedSkill:fe,installStatus:_e,executionModes:Ai.executionModes})},x)}),x<4?f(`div`,{className:`flex justify-between gap-2 shrink-0`,children:[f(`button`,{className:`tcp-btn`,disabled:x===1||Me.isPending,onClick:()=>S(e=>e-1),children:`← Back`}),f(`button`,{className:`tcp-btn-primary`,disabled:!We||Me.isPending,onClick:()=>void q(),children:Me.isPending?`Generating Plan...`:`Next →`})]}):null]})}var Wi=`tandem.automations.composer.v1`,Gi=`control-panel-agent`;function $(e){return String(e||``).trim()}function Ki(e){return $(e).toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`step`}function qi(e){let t=$(e);return t?t.split(/[_\-\s]+/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `):`Worker`}function Ji(e){let t=Array.isArray(e)?e:[],n=new Set,r=[];for(let e of t){let t=$(e);!t||n.has(t)||(n.add(t),r.push(t))}return r}function Yi(e){return Array.isArray(e?.servers)?e.servers.map(e=>$(e?.name)).filter(Boolean).sort((e,t)=>e.localeCompare(t)):Object.keys(e||{}).map(e=>$(e)).filter(Boolean).sort((e,t)=>e.localeCompare(t))}function Xi(e){let t=$(e?.type||``).toLowerCase(),n=$(e?.timezone||`UTC`)||`UTC`;return t===`cron`?{type:`cron`,cron_expression:$(e?.cron_expression||e?.cronExpression||``),timezone:n,misfire_policy:{type:`run_once`}}:t===`interval`?{type:`interval`,interval_seconds:Math.max(1,Number.parseInt(String(e?.interval_seconds||e?.intervalSeconds||`3600`),10)||3600),timezone:n,misfire_policy:{type:`run_once`}}:{type:`manual`,timezone:n,misfire_policy:{type:`run_once`}}}function Zi(e){return/write|create|update|edit|patch|publish|report|summar|artifact|save|export/i.test($(e))}function Qi(e){return/notify|send|slack|mcp|webhook|post/i.test($(e))}function $i(e,t,n,r){let i=$(e)||`worker`,a=Ji(n);return{agent_id:Ki(i),display_name:qi(i),skills:[],model_policy:r.provider&&r.model?{default_model:{provider_id:r.provider,model_id:r.model}}:void 0,tool_policy:{allowlist:Zi(t)?[`read`,`write`]:[`read`]},mcp_policy:{allowed_servers:Qi(t)?a:[],allowed_tools:Qi(t)?[`send_message`]:[]},approval_policy:`auto`}}function ea(e){let t=e.plan||{},n=Array.isArray(t?.steps)?t.steps:[],r=$(e.draftName||t?.title||e.prompt||`AI-first automation`),i=$(t?.plan_id||t?.planId),a=$(t?.workspace_root||t?.workspaceRoot||e.workspaceRoot),o=Ji(t?.allowed_mcp_servers||t?.allowedMcpServers||e.allowedMcpServers),s=o.length?o:Ji(e.allowedMcpServers),c={provider:$(e.defaultProvider),model:$(e.defaultModel)},l=[],u=new Set,d=new Map;n.forEach((e,t)=>{let n=$(e?.agent_role||e?.agentRole||`worker`)||`worker`,r=Ki(e?.step_id||e?.stepId||e?.objective||`step-${t+1}`),i=r,a=2;for(;u.has(i);)i=`${r}-${a}`,a+=1;u.add(i);let o=$(e?.objective||`${n} step ${t+1}`),f=Ji(e?.depends_on||e?.dependsOn),p=l[l.length-1]?.nodeId,m=f.length?f:p?[p]:[];if(!d.has(n))d.set(n,$i(n,o,s,c));else if(Qi(o)){let e=d.get(n);e.mcp_policy={allowed_servers:s,allowed_tools:[`send_message`]},d.set(n,e)}l.push({node_id:i,agent_id:Ki(n),objective:o,depends_on:m,input_refs:Array.isArray(e?.input_refs||e?.inputRefs)?(e?.input_refs||e?.inputRefs).map(e=>({from_step_id:$(e?.from_step_id||e?.fromStepId),alias:$(e?.alias)})).filter(e=>e.from_step_id&&e.alias):void 0,output_contract:e?.output_contract||e?.outputContract||{kind:`artifact`},retry_policy:e?.retry_policy||e?.retryPolicy||void 0,timeout_ms:e?.timeout_ms||e?.timeoutMs||void 0})});let f=Array.from(d.values());!f.length&&r&&(f.push($i(`worker`,r,s,c)),l.push({node_id:Ki(r),agent_id:Ki(`worker`),objective:r,depends_on:[],output_contract:{kind:`artifact`}}));let p={...je(r||e.prompt),...ke(r||e.prompt)};return{name:r,description:$(t?.description||e.prompt)||void 0,status:`active`,schedule:Xi(t?.schedule),workspace_root:a,creator_id:e.creatorId||`control-panel-composer`,agents:f,flow:{nodes:l},metadata:{composer:{source_plan_id:i||void 0,draft_name:e.draftName||void 0,prompt:e.prompt,created_from:`control-panel-composer`,allowed_mcp_servers:s},operator_preferences:p,docs:{handbook:`/docs/automation-composer-workflows/`}}}}function ta(e){return $(e?.automation?.automation_id||e?.automation?.automationId||e?.id)}function na(e){let t=$(e?.clarifier?.question),n=Array.isArray(e?.clarifier?.options)?e.clarifier.options.map(e=>({id:$(e?.id),label:$(e?.label)})).filter(e=>e.id&&e.label):[];return t&&n.length>0?{status:`waiting`,question:t,options:n}:{status:`none`}}function ra(e){return JSON.stringify(e,null,2)}function ia(e){try{return d.stringify(e)}catch{return``}}function aa(e){return typeof navigator>`u`||!navigator.clipboard?.writeText?Promise.resolve(!1):navigator.clipboard.writeText(e).then(()=>!0).catch(()=>!1)}function oa({client:t,api:i,toast:o,defaultProvider:l,defaultModel:d,onShowAutomations:p,onShowRuns:m,onNavigationLockChange:h}){let g=s(),[v,y]=a(``),[b,x]=a(``),[S,C]=a(``),[w,T]=a(`intent_capture`),[E,D]=a(null),[O,ee]=a(null),[te,k]=a({status:`none`}),[ne,A]=a(null),[j,re]=a(``),[M,N]=a(`json`),[P,ie]=a(``),[F,ae]=a(!1),[oe,I]=a(Gi),[se,L]=a(``),R=c({queryKey:[`automations`,`composer`,`health`],queryFn:()=>t.health().catch(()=>({})),refetchInterval:3e4}),ce=c({queryKey:[`automations`,`composer`,`mcp`],queryFn:()=>t.mcp.list().catch(()=>({})),refetchInterval:12e3}),le=c({queryKey:[`automations`,`composer`,`runs`,j],enabled:!!j&&!!t?.automationsV2?.listRuns,queryFn:async()=>t.automationsV2.listRuns(j,10),refetchInterval:5e3}),ue=r(()=>Yi(ce.data),[ce.data]),de=r(()=>$(R.data?.workspaceRoot||R.data?.workspace_root||``),[R.data]),fe=r(()=>$(S||de),[de,S]),pe=r(()=>Oe(O,!0),[O]),z=r(()=>E?ea({plan:E,prompt:v,draftName:b,workspaceRoot:fe,defaultProvider:l,defaultModel:d,allowedMcpServers:ue,creatorId:F?$(oe)||Gi:`control-panel-composer`}):null,[ue,d,l,b,v,E,fe,oe,F]),me=r(()=>z?ra(z):``,[z]),he=r(()=>z?ia(z):``,[z]),ge=M===`yaml`?he:me,_e=M===`yaml`?`YAML`:`JSON`,ve=r(()=>{let e=[];return!$(v)&&!$(E?.title)&&e.push(`Describe the automation goal first.`),$(fe)||e.push(`Workspace root is required before creating an automation.`),fe&&!fe.startsWith(`/`)&&e.push(`Workspace root must be an absolute path.`),z?.agents?.length||e.push(`The generated payload did not produce any agents.`),z?.flow?.nodes?.length||e.push(`The generated payload did not produce any workflow nodes.`),F&&!$(oe)&&e.push(`Agent test mode requires an agent id.`),!F&&!t?.automationsV2?.create&&e.push(`This control panel build does not expose automationsV2.create.`),e},[oe,F,t?.automationsV2?.create,z,v,E?.title,fe]),B=r(()=>(Array.isArray(le.data?.runs)?le.data.runs:[])[0]||null,[le.data]);e(()=>{try{let e=localStorage.getItem(Wi);if(!e)return;let t=JSON.parse(e);typeof t.input==`string`&&y(t.input),typeof t.draftName==`string`&&x(t.draftName),typeof t.workspaceRoot==`string`&&C(t.workspaceRoot),t.planPreview&&D(t.planPreview),t.conversation&&ee(t.conversation),t.clarification&&k(t.clarification),t.createdAutomation&&A(t.createdAutomation),typeof t.createdAutomationId==`string`&&re(t.createdAutomationId),t.phase&&T(t.phase),t.payloadMode&&N(t.payloadMode),typeof t.agentTestMode==`boolean`&&ae(t.agentTestMode),typeof t.agentTestAgentId==`string`&&I(t.agentTestAgentId)}catch{}},[]),e(()=>{!S&&de&&C(de)},[de,S]),e(()=>{try{localStorage.setItem(Wi,JSON.stringify({input:v,phase:w,draftName:b,workspaceRoot:S,planPreview:E,conversation:O,clarification:te,createdAutomation:ne,createdAutomationId:j,payloadMode:M,agentTestMode:F,agentTestAgentId:oe}))}catch{}},[te,O,ne,j,b,v,M,oe,F,w,E,S]);let V=()=>{y(``),x(``),T(`intent_capture`),D(null),ee(null),k({status:`none`}),A(null),re(``),ae(!1),I(Gi),L(``);try{localStorage.removeItem(Wi)}catch{}},H=u({mutationFn:async e=>{if(!t?.workflowPlans?.chatStart)throw Error(`Planner chat support is unavailable in this build.`);let n=$(e);if(!n)throw Error(`Describe the automation you want to build.`);if(!fe)throw Error(`Workspace root is required before starting a composer draft.`);return t.workflowPlans.chatStart({prompt:[`You are Tandem's AI-first workflow composer.`,`Generate a governed automation with explicit nodes, agents, and a final artifact or MCP handoff.`,`User goal: ${n}`,fe?`Workspace root: ${fe}`:``,ue.length?`Available MCP servers: ${ue.join(`, `)}`:`No MCP servers are available.`,`If anything is ambiguous, ask a short clarification question and offer options when possible.`].filter(Boolean).join(`
108
+ `),schedule:{type:`manual`,timezone:`UTC`,misfire_policy:{type:`run_once`}},plan_source:`automation_composer`,allowed_mcp_servers:ue,workspace_root:fe,operator_preferences:{...je(n),...ke(n)}})},onSuccess:(e,t)=>{let n=na(e);D(e?.plan||null),ee(e?.conversation||null),k(n),T(n.status===`waiting`?`clarification`:`draft_ready`),y(``),A(null),re(``),L(``),b.trim()||x($(e?.plan?.title||t||`AI-first automation`)),o(`ok`,n.status===`waiting`?`The composer needs one clarification before it can draft the final automation.`:`The composer drafted an automation plan.`)},onError:e=>{let t=e instanceof Error?e.message:String(e);L(t),o(`err`,t)}}),ye=u({mutationFn:async e=>{if(!t?.workflowPlans?.chatMessage||!$(E?.plan_id||E?.planId))throw Error(`Start a composer draft first.`);return t.workflowPlans.chatMessage({plan_id:$(E?.plan_id||E?.planId),message:e})},onSuccess:e=>{let t=na(e);D(e?.plan||null),ee(e?.conversation||null),k(t),T(t.status===`waiting`?`clarification`:`draft_ready`),y(``),A(null),re(``),L(``),o(`ok`,`Composer draft updated.`)},onError:e=>{let t=e instanceof Error?e.message:String(e);L(t),o(`err`,t)}}),U=u({mutationFn:async()=>{let e=$(E?.plan_id||E?.planId);return!t?.workflowPlans?.chatReset||!e?null:t.workflowPlans.chatReset({plan_id:e})},onSuccess:()=>{V(),o(`ok`,`Composer draft reset.`)},onError:e=>{let t=e instanceof Error?e.message:String(e);L(t),o(`err`,t)}}),be=r(()=>F?{"x-tandem-agent-test-mode":`1`,"x-tandem-request-source":`agent`,"x-tandem-agent-id":$(oe)||Gi}:{},[oe,F]),xe=async e=>_(`/api/engine/automations/v2`,{method:`POST`,headers:{"content-type":`application/json`,...be||{}},body:JSON.stringify(e)}),Se=async e=>{let t=encodeURIComponent(e),n={"content-type":`application/json`,...be||{}};return _(`/api/engine/automations/v2/${t}/run_now`,{method:`POST`,headers:n})},W=u({mutationFn:async e=>{if(!z)throw Error(`Generate a draft first before creating an automation.`);if(ve.length)throw Error(ve[0]);let n=P===`strict`||P===`guided`||P===`yolo`?{...z,execution:{...z.execution||{},profile:P}}:z,r=F?await xe(n):await t.automationsV2.create(n);return{response:r,automationId:ta(r),automation:r?.automation||r?.automation_v2||r||null,runAfterCreate:e}},onSuccess:async({automationId:e,automation:t,runAfterCreate:n})=>{if(re(e),A(t),T(`created`),L(``),o(`ok`,n?`Automation created. Starting the first run...`:`Automation created.`),await Promise.all([g.invalidateQueries({queryKey:[`automations`]}),g.invalidateQueries({queryKey:[`studio`,`automations`]})]),n||p(),n&&e)try{await G.mutateAsync(e)}catch{}},onError:e=>{let t=e instanceof Error?e.message:String(e);L(t),o(`err`,t)}}),G=u({mutationFn:async e=>{if(!F&&!t?.automationsV2?.runNow)throw Error(`This control panel build does not expose automationsV2.runNow.`);let n=$(e);if(!n)throw Error(`Create an automation first before running it.`);return F?await Se(n):await t.automationsV2.runNow(n)},onSuccess:async()=>{L(``),o(`ok`,`Run started. Check run history for live status.`),await Promise.all([g.invalidateQueries({queryKey:[`automations`]}),g.invalidateQueries({queryKey:[`studio`,`automations`]})]),m()},onError:e=>{let t=e instanceof Error?e.message:String(e);L(t),o(`err`,t)}}),Ce=r(()=>H.isPending||ye.isPending?{title:`Generating automation draft`,message:`Tandem is drafting the automation. Stay on this page until it finishes.`}:W.isPending?{title:`Creating automation`,message:`Tandem is creating the automation. Stay on this page until it finishes.`}:G.isPending?{title:`Starting the first run`,message:`Tandem is starting the run. Stay on this page until it finishes.`}:null,[W.isPending,ye.isPending,G.isPending,H.isPending]);n(()=>(h?.(Ce),()=>{h?.(null)}),[Ce,h]);let we=r(()=>z?JSON.stringify({phase:w,draftName:b,workspaceRoot:fe,prompt:v,planId:$(E?.plan_id||E?.planId),planTitle:$(E?.title),clarification:te,payload:z,lastAssistantMessages:pe.filter(e=>e.role===`assistant`||e.role===`system`).slice(-6)},null,2):``,[te,b,z,v,pe,w,E?.planId,E?.plan_id,E?.title,fe]),Te=r(()=>te.status===`waiting`?te.options.map(e=>({id:e.id,label:e.label})):[],[te]);return f(`div`,{className:`flex min-h-0 flex-col gap-4`,children:[f(`div`,{className:`rounded-2xl border border-slate-700/60 bg-slate-950/40 p-4`,children:[f(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[f(`div`,{className:`grid gap-1`,children:[f(`div`,{className:`text-xs uppercase tracking-[0.24em] text-amber-200/80`,children:`AI-first workflow composer`}),f(`h3`,{className:`text-lg font-semibold text-white`,children:`Build automations by talking to Tandem`}),f(`p`,{className:`max-w-2xl text-sm text-slate-300`,children:`Pick a workspace root first, then start with a prompt and Tandem will draft a governed automation payload.`})]}),f(`div`,{className:`flex flex-wrap gap-2 text-xs`,children:[f(`span`,{className:`tcp-badge-info`,children:[`phase: `,w]}),f(`span`,{className:`tcp-badge-info`,children:[`workspace: `,fe||`not set`]})]})]}),f(`div`,{className:`mt-4 grid gap-3 rounded-xl border border-white/10 bg-black/20 p-3`,children:[f(`div`,{className:`grid gap-2 sm:grid-cols-[minmax(0,1fr)_auto] sm:items-end`,children:[f(`label`,{className:`grid gap-1`,children:[f(`span`,{className:`text-xs uppercase tracking-[0.2em] text-slate-400`,children:`Workspace root`}),f(`input`,{className:`tcp-input h-10`,value:S,onChange:e=>{C(e.target.value),se&&L(``)},placeholder:`/workspace/repos/my-repo`})]}),f(`button`,{type:`button`,className:`tcp-btn h-10 px-3 text-sm`,onClick:()=>C(de),disabled:!de,children:`Use current workspace`})]}),f(`div`,{className:`text-xs text-slate-400`,children:`Tandem will scope the generated workflow to this workspace before it drafts or creates anything.`})]}),f(`div`,{className:`mt-4 grid gap-3 rounded-xl border border-white/10 bg-black/25 p-3`,children:[f(`label`,{className:`flex items-start gap-2`,children:[f(`input`,{type:`checkbox`,className:`mt-1 accent-amber-400`,checked:F,onChange:e=>{ae(e.target.checked),e.target.checked||(I(Gi),L(``))}}),f(`div`,{className:`grid gap-1`,children:[f(`span`,{className:`text-xs uppercase tracking-[0.2em] text-slate-400`,children:`Testing mode`}),f(`span`,{className:`text-sm text-slate-200`,children:`Send create/run requests as a synthetic agent`}),f(`span`,{className:`text-xs text-slate-400`,children:`Enable this to exercise agent permission checks in governance and capability review flows.`})]})]}),F?f(`label`,{className:`grid gap-1`,children:[f(`span`,{className:`text-xs uppercase tracking-[0.2em] text-slate-400`,children:`Agent id`}),f(`input`,{className:`tcp-input h-9`,value:oe,onChange:e=>I(e.target.value),placeholder:`control-panel-agent`})]}):null]})]}),f(Me,{messages:pe,emptyText:`Pick a workspace root, then start with a prompt and Tandem will draft a governed automation plan.`,inputValue:v,inputPlaceholder:`Describe the automation you want Tandem to compose.`,sendLabel:w===`intent_capture`?`Draft`:`Send`,onInputChange:y,onSend:()=>{if(te.status===`waiting`&&$(v)){ye.mutateAsync(v);return}if(!$(E?.plan_id||E?.planId)){H.mutateAsync(v);return}ye.mutateAsync(v)},sendDisabled:H.isPending||ye.isPending||W.isPending||G.isPending||!$(v),inputDisabled:H.isPending||ye.isPending||W.isPending||G.isPending,statusTitle:H.isPending||ye.isPending?`Composer is drafting a plan`:W.isPending?`Creating automation`:G.isPending?`Starting the first run`:w===`created`?`Automation created`:``,statusDetail:H.isPending||ye.isPending?`The planner is generating or revising the workflow graph.`:W.isPending?`The generated payload is being submitted to automationsV2.create.`:G.isPending?`The first run is being queued now.`:w===`created`?`Created ${$(j||ta(ne))||`automation`}`:``,questionTitle:te.status===`waiting`?`Clarification needed`:``,questionText:te.status===`waiting`?te.question:``,quickReplies:Te,onQuickReply:e=>{ye.mutateAsync(e.label)},questionHint:te.status===`waiting`?`Pick one of the suggested answers, or type your own response below.`:`Use the chat input to refine the draft after the first plan is generated.`,autoFocusKey:w}),z&&w===`draft_ready`?f(`div`,{className:`rounded-2xl border border-slate-700/60 bg-slate-950/40 p-4`,children:[f(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[f(`div`,{children:[f(`div`,{className:`text-xs uppercase tracking-[0.24em] text-slate-500`,children:`Draft ready`}),f(`div`,{className:`text-sm font-semibold text-white`,children:`Review and create the automation`})]}),f(`div`,{className:`flex flex-wrap gap-2`,children:[f(`button`,{type:`button`,className:`tcp-btn h-9 px-3 text-sm`,disabled:W.isPending||!!ve.length,onClick:()=>void W.mutateAsync(!1),children:`Create automation`}),f(`button`,{type:`button`,className:`tcp-btn h-9 px-3 text-sm`,disabled:W.isPending||!!ve.length,onClick:()=>void W.mutateAsync(!0),children:`Create + run now`})]})]}),f(`div`,{className:`mt-3 grid gap-1`,children:[f(`label`,{className:`text-xs text-slate-400`,children:`Execution profile (saved default)`}),f(gr,{value:P,clearable:!0,disabled:W.isPending,onChange:e=>ie(e)}),f(`div`,{className:`text-xs text-slate-500`,children:P===`yolo`?`Non-critical validation continues as experimental; spend caps and approvals still enforced.`:P===`guided`?`Non-critical validation becomes warnings; critical failures still block.`:P===`strict`?`All validators enforced.`:`System default is selected. Guided is the fallback when no tenant default is set; use Lenient if recoverable validation or artifact-review checks still block this workflow.`})]})]}):null,se?f(`div`,{className:`rounded-xl border border-rose-500/30 bg-rose-950/20 p-3 text-sm text-rose-100`,children:se}):null,f(`details`,{className:`rounded-2xl border border-slate-700/60 bg-slate-950/40 p-4`,children:[f(`summary`,{className:`cursor-pointer list-none text-sm font-medium text-slate-200`,children:`Advanced preview and handoff`}),f(`div`,{className:`mt-4 grid gap-4`,children:[f(`div`,{className:`rounded-xl border border-slate-700/50 bg-slate-900/40 p-4`,children:[f(`div`,{className:`text-xs uppercase tracking-[0.24em] text-slate-500`,children:`Suggested prompts`}),f(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[f(`button`,{type:`button`,className:`tcp-btn h-9 px-3 text-sm`,onClick:()=>y(`Build a governed automation named "Todo digest + notify" that scans src/ and docs/ for TODO/FIXME items, writes docs/todo_digest.md, then sends a short Slack summary with the report path.`),children:`TODO digest + notify`}),f(`button`,{type:`button`,className:`tcp-btn h-9 px-3 text-sm`,onClick:()=>y(`Create a workflow that reads key repo files, summarizes risks in docs/repo_audit.md, and posts a final MCP notification when the report is ready.`),children:`Repo audit`}),f(`button`,{type:`button`,className:`tcp-btn h-9 px-3 text-sm`,onClick:()=>y(`Draft an automation that collects release-ready changes, writes release notes, and sends a final message to the release channel.`),children:`Release notes`}),f(`button`,{type:`button`,className:`tcp-btn h-9 px-3 text-sm`,onClick:()=>{if(!$(E?.plan_id||E?.planId)){V(),o(`ok`,`Composer draft reset.`);return}U.mutateAsync()},disabled:U.isPending||H.isPending||ye.isPending||W.isPending||G.isPending,children:`Reset draft`}),f(`button`,{type:`button`,className:`tcp-btn h-9 px-3 text-sm`,onClick:()=>N(e=>e===`json`?`yaml`:`json`),children:[`Show `,M===`json`?`YAML`:`JSON`]})]})]}),f(`div`,{className:`rounded-xl border border-slate-700/50 bg-slate-900/40 p-4`,children:[f(`div`,{className:`flex items-center justify-between gap-3`,children:[f(`div`,{children:[f(`div`,{className:`text-xs uppercase tracking-[0.24em] text-slate-500`,children:`Runbook replay`}),f(`h4`,{className:`text-sm font-semibold text-white`,children:`What the automation will do`})]}),f(`button`,{type:`button`,className:`tcp-btn h-9 px-3 text-sm`,onClick:()=>void aa(we).then(e=>e&&o(`ok`,`Handoff export copied.`)),disabled:!z,children:`Handoff export`})]}),f(`div`,{className:`mt-3 grid gap-2`,children:(Array.isArray(E?.steps)?E.steps:[]).length?(E.steps||[]).map((e,t)=>{let n=$(e?.step_id||e?.stepId||`step-${t+1}`),r=$(e?.objective||`Step ${t+1}`),i=$(e?.agent_role||e?.agentRole||`worker`),a=Ji(e?.depends_on||e?.dependsOn);return f(`div`,{className:`rounded-xl border border-white/10 bg-black/20 p-3`,children:[f(`div`,{className:`flex items-center justify-between gap-2`,children:[f(`div`,{className:`text-sm font-medium text-white`,children:[t+1,`. `,r]}),f(`span`,{className:`tcp-badge-info`,children:qi(i)})]}),f(`div`,{className:`mt-1 text-xs text-slate-400`,children:a.length?`Depends on ${a.join(`, `)}`:`First step in the chain`}),f(`div`,{className:`mt-2 text-xs text-slate-300`,children:[`Node: `,f(`code`,{children:n})]})]},n)}):f(`div`,{className:`rounded-xl border border-dashed border-slate-700/70 bg-slate-950/20 p-4 text-sm text-slate-400`,children:`No draft yet. Start from the prompt and the runbook will appear here.`})})]}),f(`div`,{className:`rounded-xl border border-slate-700/50 bg-slate-900/40 p-4`,children:[f(`div`,{className:`flex items-center justify-between gap-3`,children:[f(`div`,{children:[f(`div`,{className:`text-xs uppercase tracking-[0.24em] text-slate-500`,children:`Payload preview`}),f(`h4`,{className:`text-sm font-semibold text-white`,children:`automationV2.create body`})]}),f(`div`,{className:`flex items-center gap-2`,children:[f(`button`,{type:`button`,className:`tcp-btn h-8 px-2 text-xs ${M===`json`?`border-amber-400/60 bg-amber-400/10 text-amber-300`:``}`,onClick:()=>N(`json`),children:`JSON`}),f(`button`,{type:`button`,className:`tcp-btn h-8 px-2 text-xs ${M===`yaml`?`border-amber-400/60 bg-amber-400/10 text-amber-300`:``}`,onClick:()=>N(`yaml`),children:`YAML`})]})]}),f(`div`,{className:`mt-3 flex flex-wrap gap-2 text-xs`,children:[f(`span`,{className:`tcp-badge-info`,children:`apply preview`}),f(`span`,{className:`tcp-badge-info`,children:`validate before create`}),f(`span`,{className:`tcp-badge-info`,children:`runNow after create`})]}),f(`pre`,{className:`mt-3 max-h-[20rem] overflow-auto rounded-xl border border-white/10 bg-black/40 p-3 text-[11px] leading-5 text-slate-200`,children:ge||`Generate a draft to see the payload.`}),f(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[f(`button`,{type:`button`,className:`tcp-btn h-9 px-3 text-sm`,disabled:!z,onClick:()=>void aa(ge).then(e=>e&&o(`ok`,`${_e} copied.`)),children:[`Copy `,_e]}),f(`button`,{type:`button`,className:`tcp-btn h-9 px-3 text-sm`,disabled:!z,onClick:()=>{if(!ve.length){L(`Payload looks ready for create.`),o(`ok`,`Validation passed.`);return}L(ve[0]),o(`warn`,ve[0])},children:`Validate`}),f(`button`,{type:`button`,className:`tcp-btn h-9 px-3 text-sm`,disabled:!z,onClick:()=>{T(`draft_ready`),o(`ok`,`Preview applied.`)},children:`Apply preview`})]}),ve.length?f(`div`,{className:`mt-3 rounded-xl border border-rose-500/30 bg-rose-950/20 p-3 text-sm text-rose-100`,children:ve[0]}):null]}),f(`div`,{className:`rounded-xl border border-slate-700/50 bg-slate-900/40 p-4`,children:[f(`div`,{className:`text-xs uppercase tracking-[0.24em] text-slate-500`,children:`Docs-aware context`}),f(`div`,{className:`mt-2 text-sm font-semibold text-white`,children:`Resources for agents and developers`}),f(`div`,{className:`mt-3 grid gap-2 text-sm text-slate-300`,children:[f(`a`,{className:`text-amber-300 hover:text-amber-200`,href:`/docs/automation-composer-workflows/`,children:`Build an automation with the AI assistant`}),f(`a`,{className:`text-amber-300 hover:text-amber-200`,href:`/docs/automation-examples-for-teams/`,children:`Automation Examples For Teams`}),f(`a`,{className:`text-amber-300 hover:text-amber-200`,href:`/docs/sdk/typescript/`,children:`TypeScript SDK automation examples`}),f(`a`,{className:`text-amber-300 hover:text-amber-200`,href:`/docs/sdk/python/`,children:`Python SDK automation examples`})]}),f(`div`,{className:`mt-3 text-xs text-slate-400`,children:`The production agent path can pre-connect Tandem Docs MCP so clarifications and schema lookups stay grounded in the canonical docs.`})]}),j?f(`div`,{className:`rounded-xl border border-slate-700/50 bg-slate-900/40 p-4`,children:[f(`div`,{className:`text-xs uppercase tracking-[0.24em] text-slate-500`,children:`Created automation`}),f(`div`,{className:`mt-2 grid gap-2`,children:[f(`div`,{className:`text-sm text-white`,children:[`Automation ID: `,f(`code`,{children:j})]}),f(`div`,{className:`text-sm text-slate-300`,children:$(ne?.name||E?.title||b||`Automation`)}),f(`div`,{className:`flex flex-wrap gap-2 text-xs`,children:[f(`span`,{className:`tcp-badge-ok`,children:[`latest run: `,B?$(B.status||`queued`):`waiting`]}),B?.run_id?f(`span`,{className:`tcp-badge-info`,children:[`run `,$(B.run_id)]}):null]}),B?.run_id?f(`div`,{className:`rounded-xl border border-white/10 bg-black/20 p-3 text-sm text-slate-300`,children:`The run is visible in the standard run history. Open the running tasks tab to follow it end to end.`}):null,f(`div`,{className:`flex flex-wrap gap-2`,children:[f(`button`,{type:`button`,className:`tcp-btn h-9 px-3 text-sm`,onClick:p,children:`Open automations`}),f(`button`,{type:`button`,className:`tcp-btn h-9 px-3 text-sm`,onClick:m,children:`View runs`}),f(`button`,{type:`button`,className:`tcp-btn h-9 px-3 text-sm`,disabled:!j||G.isPending||H.isPending||ye.isPending||W.isPending,onClick:()=>void G.mutateAsync(j),children:`Run now`})]})]})]}):null]})]})]})}var sa=`id: agentic-design
109
+ label: Agentic Design
110
+ description: Design a multi-agent workflow with explicit orchestration, gates, and operator controls.
111
+ blueprint:
112
+ mission_id: mission_agentic_design
113
+ title: Agentic system design mission
114
+ goal: Design a multi-agent workflow for a target operation, including orchestration, handoffs, models, tools, and safeguards.
115
+ success_criteria:
116
+ - Agent roles and responsibilities are clearly defined
117
+ - Handoffs, gates, and dependencies are explicit
118
+ - The design includes observability, stop controls, and repair flow
119
+ shared_context: This is a design mission, not code generation. Optimize for robust orchestration, role clarity, bounded autonomy, and human trust. Make model/tool choices explicit where they matter.
120
+ workspace_root: ""
121
+ orchestrator_template_id: ""
122
+ phases:
123
+ - phase_id: architecture
124
+ title: Architecture
125
+ execution_mode: soft
126
+ - phase_id: governance
127
+ title: Governance
128
+ execution_mode: barrier
129
+ milestones:
130
+ - milestone_id: design-basis-ready
131
+ title: Design basis ready
132
+ phase_id: architecture
133
+ required_stage_ids:
134
+ - role-design
135
+ - flow-design
136
+ team:
137
+ allowed_template_ids: []
138
+ default_model_policy: null
139
+ allowed_mcp_servers: []
140
+ max_parallel_agents: 4
141
+ mission_budget: {}
142
+ orchestrator_only_tool_calls: false
143
+ workstreams:
144
+ - workstream_id: role-design
145
+ title: Role and agent design
146
+ objective: Define the orchestrator and worker roles with clear responsibilities and escalation boundaries.
147
+ role: architect
148
+ prompt: Design the agent roles for this system. Define the orchestrator, specialized workers, reviewers, testers, and approval actors. Be explicit about what each role owns, when it should escalate, and what outputs it produces.
149
+ priority: 1
150
+ phase_id: architecture
151
+ lane: roles
152
+ milestone: design-basis-ready
153
+ depends_on: []
154
+ input_refs: []
155
+ tool_allowlist_override: []
156
+ mcp_servers_override: []
157
+ output_contract:
158
+ kind: report_markdown
159
+ summary_guidance: Agent roster, role boundaries, escalation points, and expected outputs.
160
+ - workstream_id: flow-design
161
+ title: Flow and handoff design
162
+ objective: Design the mission graph, dependencies, handoffs, and artifact contracts.
163
+ role: analyst
164
+ prompt: Design the multi-agent workflow graph. Specify phases, dependencies, artifact contracts, fan-out and fan-in points, and where review or approval gates should exist. Make the handoffs explicit and operationally understandable.
165
+ priority: 1
166
+ phase_id: architecture
167
+ lane: flow
168
+ milestone: design-basis-ready
169
+ depends_on: []
170
+ input_refs: []
171
+ tool_allowlist_override: []
172
+ mcp_servers_override: []
173
+ output_contract:
174
+ kind: report_markdown
175
+ summary_guidance: Mission graph, dependencies, handoffs, and output contracts.
176
+ - workstream_id: governance-design
177
+ title: Governance and safety design
178
+ objective: Define runtime controls, observability, kill switches, and repair mechanisms.
179
+ role: coordinator
180
+ prompt: Design the governance layer for the system. Specify approval gates, model and tool boundaries, logging, token or budget guardrails, kill switch semantics, pause and resume behavior, and step-level repair expectations.
181
+ priority: 1
182
+ phase_id: governance
183
+ lane: governance
184
+ depends_on:
185
+ - role-design
186
+ - flow-design
187
+ input_refs: []
188
+ tool_allowlist_override: []
189
+ mcp_servers_override: []
190
+ output_contract:
191
+ kind: plan_markdown
192
+ summary_guidance: Safety model, review points, observability, recovery, and operator controls.
193
+ review_stages:
194
+ - stage_id: design-approval
195
+ stage_kind: approval
196
+ title: Agentic design review
197
+ target_ids:
198
+ - governance-design
199
+ role: approver
200
+ prompt: Review the complete agentic design for coherence. Reject designs with unclear role boundaries, missing observability, or unbounded autonomy.
201
+ checklist:
202
+ - Role boundaries are clear
203
+ - Handoffs and gates are explicit
204
+ - Safety and repair paths are credible
205
+ priority: 1
206
+ phase_id: governance
207
+ lane: approval
208
+ tool_allowlist_override: []
209
+ mcp_servers_override: []
210
+ gate:
211
+ required: true
212
+ decisions:
213
+ - approve
214
+ - rework
215
+ - cancel
216
+ rework_targets:
217
+ - governance-design
218
+ instructions: Use rework if the design lacks control boundaries, clear outputs, or repairability.
219
+ metadata: null
220
+ `,ca=`id: ai-opportunity
221
+ label: AI Opportunities
222
+ description: Map workflow pain points to realistic AI, copilot, and agentic opportunities.
223
+ blueprint:
224
+ mission_id: mission_ai_opportunity
225
+ title: AI opportunity assessment
226
+ goal: Identify the highest-value AI opportunities in the target business process and produce a prioritized implementation brief.
227
+ success_criteria:
228
+ - Workflow bottlenecks and repetitive work are identified
229
+ - AI opportunities are ranked by value, feasibility, and risk
230
+ - Final brief recommends concrete next pilots
231
+ shared_context: Audience is operators and product leadership. Focus on realistic AI leverage, not hype. Separate automation, copilots, and fully agentic opportunities. Flag data, tooling, and approval constraints explicitly.
232
+ workspace_root: ""
233
+ orchestrator_template_id: ""
234
+ phases:
235
+ - phase_id: discovery
236
+ title: Discovery
237
+ execution_mode: soft
238
+ - phase_id: recommendation
239
+ title: Recommendation
240
+ execution_mode: barrier
241
+ milestones:
242
+ - milestone_id: opportunity-map-ready
243
+ title: Opportunity map ready
244
+ phase_id: discovery
245
+ required_stage_ids:
246
+ - workflow-analysis
247
+ - capability-map
248
+ team:
249
+ allowed_template_ids: []
250
+ default_model_policy: null
251
+ allowed_mcp_servers: []
252
+ max_parallel_agents: 4
253
+ mission_budget: {}
254
+ orchestrator_only_tool_calls: false
255
+ workstreams:
256
+ - workstream_id: workflow-analysis
257
+ title: Workflow analysis
258
+ objective: Break down the current workflow, identify friction, handoffs, delays, and repeated manual work.
259
+ role: analyst
260
+ prompt: Act as an AI workflow analyst. Map the current workflow step by step, identify where humans are spending time, where handoffs fail, where decisions bottleneck, and where information must be gathered, transformed, or checked. Produce a workflow analysis memo that distinguishes repetitive work, judgment-heavy work, and coordination-heavy work.
261
+ priority: 1
262
+ phase_id: discovery
263
+ lane: workflow
264
+ milestone: opportunity-map-ready
265
+ depends_on: []
266
+ input_refs: []
267
+ tool_allowlist_override: []
268
+ mcp_servers_override: []
269
+ output_contract:
270
+ kind: report_markdown
271
+ summary_guidance: Workflow steps, bottlenecks, repeated work, approval points, and observed failure modes.
272
+ - workstream_id: capability-map
273
+ title: AI capability map
274
+ objective: Match workflow problems to realistic AI patterns such as extraction, triage, drafting, routing, review, and autonomous follow-through.
275
+ role: strategist
276
+ prompt: Act as an agentic systems strategist. Review the workflow analysis context and map each major problem to practical AI patterns. Distinguish simple automation, LLM copilots, tool-using agents, and multi-agent orchestration. Be explicit about prerequisites, risks, and where human approval is still required.
277
+ priority: 2
278
+ phase_id: discovery
279
+ lane: capability
280
+ milestone: opportunity-map-ready
281
+ depends_on: []
282
+ input_refs: []
283
+ tool_allowlist_override: []
284
+ mcp_servers_override: []
285
+ output_contract:
286
+ kind: report_markdown
287
+ summary_guidance: Problem-to-capability map with candidate AI patterns, prerequisites, and operational risks.
288
+ - workstream_id: opportunity-brief
289
+ title: Opportunity brief
290
+ objective: Synthesize the findings into a prioritized AI opportunity brief with clear next pilots.
291
+ role: analyst
292
+ prompt: Synthesize the workflow analysis and capability map into an executive-ready AI opportunity brief. Rank candidates by expected value, implementation complexity, operator trust requirements, and data/tool prerequisites. Recommend the best near-term pilots and explain why weaker options were not prioritized.
293
+ priority: 1
294
+ phase_id: recommendation
295
+ lane: synthesis
296
+ depends_on:
297
+ - workflow-analysis
298
+ - capability-map
299
+ input_refs: []
300
+ tool_allowlist_override: []
301
+ mcp_servers_override: []
302
+ output_contract:
303
+ kind: brief_markdown
304
+ summary_guidance: Ranked AI opportunities, reasoning, operational implications, and recommended pilots.
305
+ review_stages:
306
+ - stage_id: opportunity-review
307
+ stage_kind: review
308
+ title: Feasibility and trust review
309
+ target_ids:
310
+ - opportunity-brief
311
+ role: reviewer
312
+ prompt: Review the opportunity brief for realism. Reject vague AI claims, hidden implementation assumptions, and missing trust or approval considerations. The brief should make clear what can be automated, what needs a copilot, and what still requires strong human judgment.
313
+ checklist:
314
+ - Opportunities are realistically scoped
315
+ - Human approval needs are explicit
316
+ - Recommended pilots are specific and actionable
317
+ priority: 1
318
+ phase_id: recommendation
319
+ lane: review
320
+ tool_allowlist_override: []
321
+ mcp_servers_override: []
322
+ metadata: null
323
+ `,la=`id: automation-rollout
324
+ label: Rollout
325
+ description: Plan rollout, enablement, controls, and measurement for an automation initiative.
326
+ blueprint:
327
+ mission_id: mission_automation_rollout
328
+ title: Automation rollout mission
329
+ goal: Plan the rollout of an AI or agentic automation initiative across process, tooling, operating model, and measurement.
330
+ success_criteria:
331
+ - Rollout plan includes sequencing, owners, risks, and readiness needs
332
+ - Metrics and operator controls are explicit
333
+ - Human change-management needs are addressed
334
+ shared_context: Optimize for actual operational rollout. Include enablement, communications, governance, training, and success measurement. Avoid purely technical plans.
335
+ workspace_root: ""
336
+ orchestrator_template_id: ""
337
+ phases:
338
+ - phase_id: readiness
339
+ title: Readiness
340
+ execution_mode: soft
341
+ - phase_id: launch
342
+ title: Launch
343
+ execution_mode: barrier
344
+ milestones: []
345
+ team:
346
+ allowed_template_ids: []
347
+ default_model_policy: null
348
+ allowed_mcp_servers: []
349
+ max_parallel_agents: 4
350
+ mission_budget: {}
351
+ orchestrator_only_tool_calls: false
352
+ workstreams:
353
+ - workstream_id: process-readiness
354
+ title: Process readiness
355
+ objective: Define the target operating process, roles, and readiness gaps.
356
+ role: operator
357
+ prompt: Plan the operating-process changes required to adopt the automation. Identify role changes, review points, ownership, runbooks, and readiness blockers.
358
+ priority: 1
359
+ phase_id: readiness
360
+ lane: operations
361
+ depends_on: []
362
+ input_refs: []
363
+ tool_allowlist_override: []
364
+ mcp_servers_override: []
365
+ output_contract:
366
+ kind: plan_markdown
367
+ summary_guidance: Operating model changes, ownership, readiness blockers, and process notes.
368
+ - workstream_id: platform-readiness
369
+ title: Platform and tooling readiness
370
+ objective: Define the tooling, integration, data, and observability requirements for launch.
371
+ role: planner
372
+ prompt: "Plan the platform requirements for rollout: integrations, tools, permissions, logs, metrics, data dependencies, guardrails, and monitoring expectations."
373
+ priority: 1
374
+ phase_id: readiness
375
+ lane: platform
376
+ depends_on: []
377
+ input_refs: []
378
+ tool_allowlist_override: []
379
+ mcp_servers_override: []
380
+ output_contract:
381
+ kind: plan_markdown
382
+ summary_guidance: Tooling, integrations, observability, and launch prerequisites.
383
+ - workstream_id: launch-plan
384
+ title: Rollout and adoption plan
385
+ objective: Create the rollout sequence, communications, operator enablement, and measurement plan.
386
+ role: coordinator
387
+ prompt: Using the readiness work, create a rollout plan with phases, launch criteria, internal communications, operator training, fallback plans, and success metrics. Make the rollout sequence explicit.
388
+ priority: 2
389
+ phase_id: launch
390
+ lane: rollout
391
+ depends_on:
392
+ - process-readiness
393
+ - platform-readiness
394
+ input_refs: []
395
+ tool_allowlist_override: []
396
+ mcp_servers_override: []
397
+ output_contract:
398
+ kind: plan_markdown
399
+ summary_guidance: Rollout sequencing, enablement, communications, fallback, and success metrics.
400
+ review_stages:
401
+ - stage_id: launch-gate
402
+ stage_kind: approval
403
+ title: Launch readiness gate
404
+ target_ids:
405
+ - launch-plan
406
+ role: approver
407
+ prompt: Review the rollout plan for operational readiness. Confirm that controls, training, communications, fallback, and measurement are credible before launch.
408
+ checklist:
409
+ - Launch prerequisites are explicit
410
+ - Operator enablement is covered
411
+ - Fallback and measurement are defined
412
+ priority: 1
413
+ phase_id: launch
414
+ lane: approval
415
+ tool_allowlist_override: []
416
+ mcp_servers_override: []
417
+ gate:
418
+ required: true
419
+ decisions:
420
+ - approve
421
+ - rework
422
+ - cancel
423
+ rework_targets:
424
+ - launch-plan
425
+ instructions: Use rework if the rollout plan lacks readiness criteria, operator enablement, or fallback handling.
426
+ metadata: null
427
+ `,ua=`id: collect-consolidate-update-notify
428
+ label: Collect -> Consolidate -> Update State -> Notify
429
+ description: Run a recurring state-refresh mission that gathers inputs, consolidates them, updates the shared state, and notifies the right audience.
430
+ schedule_defaults:
431
+ type: cron
432
+ cron_expression: "0 9 * * *"
433
+ timezone: UTC
434
+ blueprint:
435
+ mission_id: mission_collect_consolidate_update_notify
436
+ title: State refresh mission
437
+ goal: Collect recurring inputs, consolidate them into a validated state update, refresh the shared record, and send a clear downstream notification.
438
+ success_criteria:
439
+ - Inputs are gathered from the intended sources
440
+ - Consolidation removes duplication and ambiguity
441
+ - The shared state is updated in a traceable way
442
+ - Notification summarizes what changed and what matters next
443
+ shared_context: Optimize for recurring state maintenance. Favor stable, inspectable state updates over ad hoc narrative summaries. Distinguish raw collected inputs from the validated state that later runs should build upon.
444
+ workspace_root: ""
445
+ orchestrator_template_id: ""
446
+ phases:
447
+ - phase_id: collect
448
+ title: Collect
449
+ execution_mode: soft
450
+ - phase_id: publish
451
+ title: Publish
452
+ execution_mode: barrier
453
+ milestones:
454
+ - milestone_id: state-update-ready
455
+ title: State update ready
456
+ phase_id: collect
457
+ required_stage_ids:
458
+ - collect-inputs
459
+ - consolidate-state
460
+ team:
461
+ allowed_template_ids: []
462
+ default_model_policy: null
463
+ allowed_mcp_servers: []
464
+ max_parallel_agents: 4
465
+ mission_budget: {}
466
+ orchestrator_only_tool_calls: false
467
+ workstreams:
468
+ - workstream_id: collect-inputs
469
+ title: Collect inputs
470
+ objective: Gather the current raw inputs and source records needed for this run.
471
+ role: collector
472
+ prompt: Act as a collection operator. Gather the current run inputs from the allowed sources, preserve source references, and produce a collection package that later stages can consolidate without re-collecting the same material.
473
+ priority: 2
474
+ phase_id: collect
475
+ lane: collection
476
+ milestone: state-update-ready
477
+ depends_on: []
478
+ input_refs: []
479
+ tool_allowlist_override: []
480
+ mcp_servers_override: []
481
+ output_contract:
482
+ kind: structured_json
483
+ summary_guidance: Raw collected inputs with source references, timestamps, and collection notes.
484
+ - workstream_id: consolidate-state
485
+ title: Consolidate state
486
+ objective: Turn the collected inputs into one validated state update that can become the new reference point.
487
+ role: analyst
488
+ prompt: Act as a consolidation analyst. Use the collected input package to merge duplicates, resolve inconsistencies where possible, identify missing fields, and produce one coherent state update with explicit evidence and uncertainty.
489
+ priority: 1
490
+ phase_id: collect
491
+ lane: consolidation
492
+ milestone: state-update-ready
493
+ depends_on:
494
+ - collect-inputs
495
+ input_refs:
496
+ - from_step_id: collect-inputs
497
+ alias: collected_inputs
498
+ tool_allowlist_override: []
499
+ mcp_servers_override: []
500
+ output_contract:
501
+ kind: structured_json
502
+ summary_guidance: Consolidated state update with validated fields, deltas, unresolved ambiguity, and evidence links.
503
+ - workstream_id: update-shared-state
504
+ title: Update shared state
505
+ objective: Convert the consolidated state into the canonical update payload or artifact for this run.
506
+ role: operator
507
+ prompt: Act as a state-update operator. Transform the consolidated state into the artifact or update package that should become the new shared state for this mission. Preserve change history, explicit deltas, and anything needed for the next run to start from the new baseline.
508
+ priority: 2
509
+ phase_id: publish
510
+ lane: state
511
+ depends_on:
512
+ - consolidate-state
513
+ input_refs:
514
+ - from_step_id: consolidate-state
515
+ alias: consolidated_state
516
+ tool_allowlist_override: []
517
+ mcp_servers_override: []
518
+ output_contract:
519
+ kind: structured_json
520
+ summary_guidance: Validated shared-state update package with deltas, retained fields, and provenance.
521
+ - workstream_id: notify-stakeholders
522
+ title: Notify stakeholders
523
+ objective: Summarize the update for the downstream audience with emphasis on what changed and what action is required.
524
+ role: notifier
525
+ prompt: Act as a notification operator. Use the validated state update to produce a concise downstream notification that explains what changed, why it matters, what if anything needs action, and where to look for the full update package.
526
+ priority: 1
527
+ phase_id: publish
528
+ lane: notify
529
+ depends_on:
530
+ - update-shared-state
531
+ input_refs:
532
+ - from_step_id: update-shared-state
533
+ alias: state_update
534
+ tool_allowlist_override: []
535
+ mcp_servers_override: []
536
+ output_contract:
537
+ kind: handoff_markdown
538
+ summary_guidance: Notification summary with key changes, impact, required actions, and links to the updated state package.
539
+ review_stages:
540
+ - stage_id: state-review
541
+ stage_kind: review
542
+ title: State update review
543
+ target_ids:
544
+ - update-shared-state
545
+ role: reviewer
546
+ prompt: Review the state update for consistency, traceability, and suitability as the next baseline. Reject updates that merge ambiguous input into shared truth without evidence or clear uncertainty markers.
547
+ checklist:
548
+ - State update is traceable to collected inputs
549
+ - Deltas are explicit
550
+ - Uncertainty is not hidden
551
+ priority: 1
552
+ phase_id: publish
553
+ lane: review
554
+ tool_allowlist_override: []
555
+ mcp_servers_override: []
556
+ metadata: null
557
+ `,da=`id: intake-plan-execute-verify-review
558
+ label: Intake -> Plan -> Execute -> Verify -> Review
559
+ description: Run a structured operational pipeline from intake through execution, verification, and final review.
560
+ schedule_defaults:
561
+ type: interval
562
+ interval_seconds: 86400
563
+ timezone: UTC
564
+ blueprint:
565
+ mission_id: mission_intake_plan_execute_verify_review
566
+ title: Intake to verified delivery mission
567
+ goal: Turn recurring inbound work into a planned, executed, verified, and review-ready outcome with clear traceability across stages.
568
+ success_criteria:
569
+ - Intake is normalized into a clear scoped brief
570
+ - A concrete execution plan exists before work begins
571
+ - Execution stays inside the planned scope
572
+ - Verification records what was actually checked
573
+ - Final review states readiness and remaining follow-up
574
+ shared_context: Optimize for repeatable delivery work. Use staged artifacts so later runs and later stages do not need to reconstruct context. Raw intake should not become reusable truth until it has been validated downstream.
575
+ workspace_root: ""
576
+ orchestrator_template_id: ""
577
+ phases:
578
+ - phase_id: intake
579
+ title: Intake
580
+ execution_mode: soft
581
+ - phase_id: delivery
582
+ title: Delivery
583
+ execution_mode: barrier
584
+ milestones:
585
+ - milestone_id: execution-basis-ready
586
+ title: Execution basis ready
587
+ phase_id: intake
588
+ required_stage_ids:
589
+ - normalize-intake
590
+ - build-plan
591
+ team:
592
+ allowed_template_ids: []
593
+ default_model_policy: null
594
+ allowed_mcp_servers: []
595
+ max_parallel_agents: 4
596
+ mission_budget: {}
597
+ orchestrator_only_tool_calls: false
598
+ workstreams:
599
+ - workstream_id: normalize-intake
600
+ title: Normalize intake
601
+ objective: Turn the incoming request, signal, or backlog item into a scoped brief with facts, constraints, and open questions.
602
+ role: operator
603
+ prompt: Act as an intake operator. Normalize the incoming work into a structured brief that captures what is known, what is required, what is unclear, and what should stay out of scope. Preserve source facts and avoid jumping prematurely into solution design.
604
+ priority: 2
605
+ phase_id: intake
606
+ lane: intake
607
+ milestone: execution-basis-ready
608
+ depends_on: []
609
+ input_refs: []
610
+ tool_allowlist_override: []
611
+ mcp_servers_override: []
612
+ output_contract:
613
+ kind: structured_json
614
+ summary_guidance: Scoped intake brief with facts, constraints, open questions, and source references.
615
+ - workstream_id: build-plan
616
+ title: Build plan
617
+ objective: Turn the scoped intake brief into a concrete plan with dependencies, execution scope, and verification approach.
618
+ role: planner
619
+ prompt: Act as a planning lead. Convert the intake brief into a practical execution plan with stages, dependencies, scope boundaries, risks, and how success will be verified. Do not execute the plan in this stage.
620
+ priority: 1
621
+ phase_id: intake
622
+ lane: planning
623
+ milestone: execution-basis-ready
624
+ depends_on:
625
+ - normalize-intake
626
+ input_refs:
627
+ - from_step_id: normalize-intake
628
+ alias: intake_brief
629
+ tool_allowlist_override: []
630
+ mcp_servers_override: []
631
+ output_contract:
632
+ kind: plan_markdown
633
+ summary_guidance: Execution plan, scope boundaries, dependencies, risks, and verification approach.
634
+ - workstream_id: execute-work
635
+ title: Execute work
636
+ objective: Carry out the planned work inside the declared scope and produce the required deliverable.
637
+ role: worker
638
+ prompt: Act as an execution specialist. Use the approved intake brief and plan to carry out the scoped task. Preserve traceability to the plan, avoid widening scope unnecessarily, and record material deviations if they become necessary.
639
+ priority: 2
640
+ phase_id: delivery
641
+ lane: execution
642
+ depends_on:
643
+ - build-plan
644
+ input_refs:
645
+ - from_step_id: build-plan
646
+ alias: execution_plan
647
+ tool_allowlist_override: []
648
+ mcp_servers_override: []
649
+ output_contract:
650
+ kind: report_markdown
651
+ summary_guidance: Execution result, deliverable summary, changed scope if any, and unresolved issues.
652
+ - workstream_id: verify-work
653
+ title: Verify work
654
+ objective: Verify the execution result against the plan and record what was actually checked.
655
+ role: tester
656
+ prompt: Act as a verification operator. Check whether the execution result matches the planned scope and stated success criteria. Record exactly what was verified, what failed, and what remains blocked or uncertain.
657
+ priority: 1
658
+ phase_id: delivery
659
+ lane: verification
660
+ depends_on:
661
+ - execute-work
662
+ input_refs:
663
+ - from_step_id: execute-work
664
+ alias: execution_result
665
+ tool_allowlist_override: []
666
+ mcp_servers_override: []
667
+ output_contract:
668
+ kind: verification_report
669
+ summary_guidance: Verification steps, pass/fail findings, blockers, and clear readiness status.
670
+ review_stages:
671
+ - stage_id: delivery-review
672
+ stage_kind: approval
673
+ title: Delivery review gate
674
+ target_ids:
675
+ - verify-work
676
+ role: approver
677
+ prompt: Review the verified output for readiness. Approve only when the execution result is scoped correctly, verification is credible, and remaining risk is acceptable for downstream reuse or handoff.
678
+ checklist:
679
+ - Intake, plan, execution, and verification form one coherent chain
680
+ - Verification is factual and specific
681
+ - Residual risk is explicit
682
+ priority: 1
683
+ phase_id: delivery
684
+ lane: approval
685
+ tool_allowlist_override: []
686
+ mcp_servers_override: []
687
+ gate:
688
+ required: true
689
+ decisions:
690
+ - approve
691
+ - rework
692
+ - cancel
693
+ rework_targets:
694
+ - execute-work
695
+ - verify-work
696
+ instructions: Use rework when execution drifted from plan, verification is weak, or the final result is not ready for trusted downstream use.
697
+ metadata: null
698
+ `,fa=`id: monitor-analyze-decide-handoff
699
+ label: Monitor -> Analyze -> Decide -> Handoff
700
+ description: Run a recurring signal loop that watches for changes, analyzes impact, prepares decisions, and hands off a validated update.
701
+ schedule_defaults:
702
+ type: cron
703
+ cron_expression: "0 8 * * 1-5"
704
+ timezone: UTC
705
+ blueprint:
706
+ mission_id: mission_monitor_analyze_decide_handoff
707
+ title: Signal monitoring mission
708
+ goal: Monitor a recurring source of operational signals, analyze meaningful changes, recommend clear decisions, and produce a validated handoff for the next operator or system.
709
+ success_criteria:
710
+ - Important changes are detected and separated from noise
711
+ - Analysis explains why each change matters and to whom
712
+ - Decision recommendations are concrete and actionable
713
+ - Final handoff is ready for downstream use without repeating the same analysis
714
+ shared_context: Optimize for recurring operation over time. Preserve continuity between runs through validated outputs, not raw notes. Be explicit about uncertainty, signal quality, and when no action is needed.
715
+ workspace_root: ""
716
+ orchestrator_template_id: ""
717
+ phases:
718
+ - phase_id: monitor
719
+ title: Monitor
720
+ execution_mode: soft
721
+ - phase_id: decision
722
+ title: Decision
723
+ execution_mode: barrier
724
+ milestones:
725
+ - milestone_id: signal-package-ready
726
+ title: Signal package ready
727
+ phase_id: monitor
728
+ required_stage_ids:
729
+ - monitor-signals
730
+ - analyze-impact
731
+ team:
732
+ allowed_template_ids: []
733
+ default_model_policy: null
734
+ allowed_mcp_servers: []
735
+ max_parallel_agents: 4
736
+ mission_budget: {}
737
+ orchestrator_only_tool_calls: false
738
+ workstreams:
739
+ - workstream_id: monitor-signals
740
+ title: Monitor signals
741
+ objective: Observe the current inputs and identify changes, anomalies, or meaningful events since the prior validated state.
742
+ role: analyst
743
+ prompt: Act as a recurring monitoring operator. Inspect the allowed inputs, detect what materially changed, separate important signals from routine noise, and produce a structured signal log that later stages can trust without repeating broad discovery.
744
+ priority: 2
745
+ phase_id: monitor
746
+ lane: sensing
747
+ milestone: signal-package-ready
748
+ depends_on: []
749
+ input_refs: []
750
+ tool_allowlist_override: []
751
+ mcp_servers_override: []
752
+ output_contract:
753
+ kind: report_markdown
754
+ summary_guidance: Detected changes, evidence, confidence, and clear separation of material signals from noise.
755
+ - workstream_id: analyze-impact
756
+ title: Analyze impact
757
+ objective: Explain what the detected changes mean, which actors or systems are affected, and what risks or opportunities they create.
758
+ role: reviewer
759
+ prompt: Act as an impact analyst. Use the monitored signal package to explain significance, affected stakeholders, urgency, confidence, and possible consequences. Preserve evidence, distinguish facts from inference, and avoid proposing actions before the decision stage.
760
+ priority: 1
761
+ phase_id: monitor
762
+ lane: analysis
763
+ milestone: signal-package-ready
764
+ depends_on:
765
+ - monitor-signals
766
+ input_refs:
767
+ - from_step_id: monitor-signals
768
+ alias: signal_log
769
+ tool_allowlist_override: []
770
+ mcp_servers_override: []
771
+ output_contract:
772
+ kind: brief_markdown
773
+ summary_guidance: Impact summary, affected areas, urgency, confidence, and key open questions.
774
+ - workstream_id: recommend-decisions
775
+ title: Recommend decisions
776
+ objective: Turn the signal and impact analysis into concrete recommended actions, decisions, or escalations.
777
+ role: planner
778
+ prompt: Act as a decision-support planner. Use the upstream signal log and impact summary to recommend concrete next actions, explicit decisions, and no-action cases where appropriate. Make the rationale inspectable and avoid ambiguous recommendations.
779
+ priority: 2
780
+ phase_id: decision
781
+ lane: decision
782
+ depends_on:
783
+ - monitor-signals
784
+ - analyze-impact
785
+ input_refs:
786
+ - from_step_id: analyze-impact
787
+ alias: impact_summary
788
+ tool_allowlist_override: []
789
+ mcp_servers_override: []
790
+ output_contract:
791
+ kind: plan_markdown
792
+ summary_guidance: Recommended decisions, action rationale, urgency, owners, and cases where no action is required.
793
+ - workstream_id: prepare-handoff
794
+ title: Prepare handoff
795
+ objective: Package the validated signal, analysis, and decision output into a downstream-ready handoff.
796
+ role: coordinator
797
+ prompt: Act as a handoff coordinator. Package the validated findings and decision recommendations into a concise operational handoff that names the important change, what it means, what should happen next, and what still needs human judgment.
798
+ priority: 1
799
+ phase_id: decision
800
+ lane: handoff
801
+ depends_on:
802
+ - recommend-decisions
803
+ input_refs:
804
+ - from_step_id: recommend-decisions
805
+ alias: decision_package
806
+ tool_allowlist_override: []
807
+ mcp_servers_override: []
808
+ output_contract:
809
+ kind: handoff_markdown
810
+ summary_guidance: Final signal handoff with validated changes, decision recommendations, owners, and residual uncertainty.
811
+ review_stages:
812
+ - stage_id: handoff-review
813
+ stage_kind: review
814
+ title: Handoff quality review
815
+ target_ids:
816
+ - prepare-handoff
817
+ role: reviewer
818
+ prompt: Review the final handoff for evidence quality, internal consistency, decision clarity, and downstream usability. Reject handoffs that hide uncertainty or force later stages to rediscover context.
819
+ checklist:
820
+ - Material changes are clearly identified
821
+ - Recommendations are concrete
822
+ - Evidence and uncertainty are explicit
823
+ priority: 1
824
+ phase_id: decision
825
+ lane: review
826
+ tool_allowlist_override: []
827
+ mcp_servers_override: []
828
+ metadata: null
829
+ `,pa=`id: workflow-audit
830
+ label: Workflow Audit
831
+ description: Audit an existing workflow and design a safer, observable automation model.
832
+ blueprint:
833
+ mission_id: mission_workflow_audit
834
+ title: Workflow automation audit
835
+ goal: Audit an existing workflow and produce a concrete automation design with failure points, control points, and implementation recommendations.
836
+ success_criteria:
837
+ - Current-state workflow is documented
838
+ - Automation candidates include controls and failure handling
839
+ - A practical implementation plan is produced
840
+ shared_context: Focus on operational reliability. Make human approvals, logging needs, repair loops, and recovery paths explicit. Favor concrete workflow shapes over abstract transformation language.
841
+ workspace_root: ""
842
+ orchestrator_template_id: ""
843
+ phases:
844
+ - phase_id: audit
845
+ title: Audit
846
+ execution_mode: soft
847
+ - phase_id: design
848
+ title: Design
849
+ execution_mode: barrier
850
+ milestones:
851
+ - milestone_id: audit-complete
852
+ title: Audit complete
853
+ phase_id: audit
854
+ required_stage_ids:
855
+ - current-state
856
+ - failure-analysis
857
+ team:
858
+ allowed_template_ids: []
859
+ default_model_policy: null
860
+ allowed_mcp_servers: []
861
+ max_parallel_agents: 4
862
+ mission_budget: {}
863
+ orchestrator_only_tool_calls: false
864
+ workstreams:
865
+ - workstream_id: current-state
866
+ title: Current-state workflow
867
+ objective: Document the current workflow, actors, triggers, tools, and handoffs.
868
+ role: operator
869
+ prompt: "Act as an operations architect. Document the workflow as it exists today: triggers, inputs, outputs, handoffs, approvals, tools, data dependencies, and places where work stalls or gets retried."
870
+ priority: 1
871
+ phase_id: audit
872
+ lane: mapping
873
+ milestone: audit-complete
874
+ depends_on: []
875
+ input_refs: []
876
+ tool_allowlist_override: []
877
+ mcp_servers_override: []
878
+ output_contract:
879
+ kind: report_markdown
880
+ summary_guidance: Current-state workflow map, actors, tools, handoffs, and bottlenecks.
881
+ - workstream_id: failure-analysis
882
+ title: Failure and control analysis
883
+ objective: Identify where workflow automation can fail, what needs approval, and what must be observable.
884
+ role: reviewer
885
+ prompt: Act as a workflow reliability reviewer. Inspect the current-state map and identify failure modes, ambiguous steps, risky autonomous actions, missing approvals, recovery gaps, and required logging or metrics.
886
+ priority: 1
887
+ phase_id: audit
888
+ lane: controls
889
+ milestone: audit-complete
890
+ depends_on: []
891
+ input_refs: []
892
+ tool_allowlist_override: []
893
+ mcp_servers_override: []
894
+ output_contract:
895
+ kind: brief_markdown
896
+ summary_guidance: Failure modes, control points, approval needs, logging, and recovery requirements.
897
+ - workstream_id: automation-design
898
+ title: Automation design
899
+ objective: Turn the audit into a practical automation architecture and rollout plan.
900
+ role: planner
901
+ prompt: Design the target workflow automation. Specify which steps remain human, which become deterministic automation, which should use agents, and where review gates, kill switches, repair loops, and observability are required. Produce a rollout plan that can be implemented incrementally.
902
+ priority: 2
903
+ phase_id: design
904
+ lane: design
905
+ depends_on:
906
+ - current-state
907
+ - failure-analysis
908
+ input_refs: []
909
+ tool_allowlist_override: []
910
+ mcp_servers_override: []
911
+ output_contract:
912
+ kind: plan_markdown
913
+ summary_guidance: Target workflow design, control model, observability plan, and incremental rollout steps.
914
+ review_stages:
915
+ - stage_id: automation-review
916
+ stage_kind: approval
917
+ title: Automation readiness review
918
+ target_ids:
919
+ - automation-design
920
+ role: approver
921
+ prompt: Review the automation design for realism, controllability, operator trust, and failure recovery. Reject designs that automate too aggressively without approvals or observability.
922
+ checklist:
923
+ - Control points are explicit
924
+ - Failure recovery is defined
925
+ - Rollout is incremental and realistic
926
+ priority: 1
927
+ phase_id: design
928
+ lane: approval
929
+ tool_allowlist_override: []
930
+ mcp_servers_override: []
931
+ gate:
932
+ required: true
933
+ decisions:
934
+ - approve
935
+ - rework
936
+ - cancel
937
+ rework_targets:
938
+ - automation-design
939
+ instructions: Approve only when the automation design is safe, observable, and realistically deployable.
940
+ metadata: null
941
+ `;function ma(e){return String(e||``).trim()}function ha(e){let t=String(e||``).trim(),n=t.match(/^```(?:ya?ml|json)?\s*([\s\S]*?)\s*```$/i);return n?n[1].trim():t}function ga(e,t,n){if(e===`cron`){let e=ma(n);return e?`cron:${e}`:`cron`}if(e===`interval`){let e=Number.parseInt(String(t||`0`),10)||0;return e>0?`interval:${e}s`:`interval`}return`manual`}function _a(e){let t=ma(e.humanIntent),n=ma(e.missionTitle),r=ma(e.missionGoal),i=ma(e.sharedContext),a=ma(e.workspaceRoot),o=ma(e.archetypeLabel),s=Array.isArray(e.successCriteria)?e.successCriteria.map(ma).filter(Boolean):[];return[`Design one Tandem MissionBlueprint for the following human intent.`,``,`Return valid YAML only.`,`Do not return explanation, commentary, markdown fences, or notes outside the YAML.`,``,`Mission compiler requirements:`,`- Produce one shared mission goal, not a checklist.`,`- Use 3 to 7 scoped workstreams with one responsibility each.`,"- Use explicit `depends_on` only for real handoffs.","- Use explicit `input_refs` when a stage needs named upstream outputs.","- Every workstream must include a strong `prompt` and a concrete `output_contract`.",`- Add review, test, or approval stages only where they materially improve quality, verification, or promotion control.`,`- Keep outputs reusable by later stages and future runs.`,`- Assume this mission may run repeatedly over weeks or months.`,`- Default to project-scoped knowledge reuse through validated stage outputs, not raw intermediate notes.`,"- Avoid vague stages like `do work`, `analyze everything`, or `final thoughts`.",`- Prefer explicit phases, milestones, and barriers when they improve operational sequencing.`,``,`Prompt-writing requirements for each workstream:`,`- State the local role clearly.`,`- State the local objective clearly.`,`- Specify what inputs are allowed.`,`- Specify what output must be produced.`,`- Include guardrails against repeating earlier work, inventing facts, or widening scope unnecessarily.`,``,`Scheduling and recurrence guidance:`,`- Intended cadence: ${ga(e.scheduleKind,e.intervalSeconds,e.cronExpression)}.`,`- If the cadence suggests a recurring mission, design outputs and review points so later runs can build on prior validated state.`,`- Do not force a review or approval stage after every workstream; place them only where promotion, external action, or downstream trust requires it.`,``,`Human intent:`,t?`- Raw mission intent: ${t}`:``,n?`- Mission title hint: ${n}`:`- Mission title hint: derive a concise operator-friendly title.`,r?`- Mission goal: ${r}`:`- Mission goal: derive from the implied objective.`,i?`- Shared context: ${i}`:`- Shared context: infer only stable cross-cutting constraints.`,a?`- Workspace root: ${a}`:`- Workspace root: use the provided workspace root.`,o?`- Archetype hint: ${o}`:`- Archetype hint: choose the smallest suitable staged pattern.`,s.length?`- Success criteria:
942
+ `+s.map(e=>` - ${e}`).join(`
943
+ `):`- Success criteria: infer measurable outcomes from the goal.`,``,`Return YAML with this shape:`,`- id`,`- label`,`- description`,`- schedule_defaults`,`- blueprint`,``,"The `blueprint` must contain:",`- mission_id`,`- title`,`- goal`,`- success_criteria`,`- shared_context`,`- workspace_root`,`- phases`,`- milestones`,`- team`,`- workstreams`,`- review_stages`,``,`Choose realistic roles, dependencies, outputs, and review gates. Optimize for durable staged execution rather than a one-off chat response.`].join(`
944
+ `)}function va(e){let t=ha(e);if(!t)return{blueprint:null,error:`Paste YAML or JSON containing a mission blueprint draft.`};let n;try{n=d.parse(t)}catch(e){return{blueprint:null,error:e instanceof Error?e.message:`Unable to parse YAML/JSON draft.`}}if(!n||typeof n!=`object`)return{blueprint:null,error:`The imported draft must be a YAML or JSON object.`};let r=n,i=r.blueprint&&typeof r.blueprint==`object`?r.blueprint:r;return!i||typeof i!=`object`?{blueprint:null,error:`No mission blueprint object was found in the draft.`}:{blueprint:i,scheduleDefaults:r.schedule_defaults&&typeof r.schedule_defaults==`object`?r.schedule_defaults:void 0}}function ya(e){let t=ma(e?.type).toLowerCase();if(t===`cron`)return{scheduleKind:`cron`,intervalSeconds:`3600`,cronExpression:ma(e?.cron_expression)};if(t===`interval`){let t=Number(e?.interval_seconds||3600);return{scheduleKind:`interval`,intervalSeconds:String(Math.max(1,Number.isFinite(t)?t:3600)),cronExpression:``}}return{scheduleKind:`manual`,intervalSeconds:`3600`,cronExpression:``}}function ba(){return[`Generated missions should start from project-scoped promoted knowledge.`,`Validated outputs should feed later stages and future runs; raw intermediate notes should not.`,`Recurring missions should prefer stable stage outputs and explicit handoffs over re-discovery.`]}function xa(){let e=globalThis.crypto;if(e?.randomUUID)return e.randomUUID().slice(0,8);if(e?.getRandomValues){let t=new Uint32Array(1);return e.getRandomValues(t),t[0].toString(16).padStart(8,`0`).slice(0,8)}return Math.random().toString(16).slice(2,10).padEnd(8,`0`).slice(0,8)}var Sa={"ai-opportunity":`sparkles`,"workflow-audit":`workflow`,"agentic-design":`bot`,"automation-rollout":`arrow-up-circle`,"monitor-analyze-decide-handoff":`radar`,"intake-plan-execute-verify-review":`list-checks`,"collect-consolidate-update-notify":`database-zap`},Ca=Object.assign({"../presets/mission-builder/agentic-design.yaml":sa,"../presets/mission-builder/ai-opportunity.yaml":ca,"../presets/mission-builder/automation-rollout.yaml":la,"../presets/mission-builder/collect-consolidate-update-notify.yaml":ua,"../presets/mission-builder/intake-plan-execute-verify-review.yaml":da,"../presets/mission-builder/monitor-analyze-decide-handoff.yaml":fa,"../presets/mission-builder/workflow-audit.yaml":pa});function wa(e){return Array.isArray(e?.servers)?e.servers.map(e=>{let t=String(e?.name||``).trim();return t?{name:t,connected:!!e?.connected,enabled:e?.enabled!==!1}:null}).filter(Boolean):e&&typeof e==`object`?Object.entries(e).map(([e,t])=>{let n=String(e||``).trim();return n?{name:n,connected:!!t?.connected,enabled:t?.enabled!==!1}:null}).filter(Boolean):[]}function Ta(e){return String(e||``).split(`,`).map(e=>e.trim()).filter(Boolean)}function Ea(e){let t=String(e.provider||``).trim(),n=String(e.model||``).trim();return!t||!n?null:{default_model:{provider_id:t,model_id:n}}}function Da(e){let t=e?.default_model||e?.defaultModel||{};return{provider:String(t?.provider_id||t?.providerId||``).trim(),model:String(t?.model_id||t?.modelId||``).trim()}}function Oa(e,t,n){let r={type:`run_once`};return e===`cron`?{type:`cron`,cron_expression:String(n||``).trim(),timezone:`UTC`,misfire_policy:r}:e===`interval`?{type:`interval`,interval_seconds:Math.max(1,Number.parseInt(String(t||`3600`),10)||3600),timezone:`UTC`,misfire_policy:r}:{type:`manual`,timezone:`UTC`,misfire_policy:r}}function ka(e){let t=String(e?.type||``).trim().toLowerCase();if(t===`cron`)return{scheduleKind:`cron`,intervalSeconds:`3600`,cronExpression:String(e?.cron_expression||``).trim()};if(t===`interval`){let t=Math.max(1,Number.parseInt(String(e?.interval_seconds||`3600`),10)||3600);return{scheduleKind:`interval`,intervalSeconds:String(t),cronExpression:``}}return{scheduleKind:`manual`,intervalSeconds:`3600`,cronExpression:``}}function Aa(e){return{mission_id:`mission_${xa()}`,title:``,goal:``,success_criteria:[],shared_context:``,workspace_root:e,orchestrator_template_id:``,phases:[{phase_id:`phase_1`,title:`Phase 1`,description:``,execution_mode:`soft`}],milestones:[],team:{allowed_template_ids:[],default_model_policy:null,allowed_mcp_servers:[],max_parallel_agents:4,mission_budget:{},orchestrator_only_tool_calls:!1},workstreams:[{workstream_id:`workstream_${xa()}`,title:`Workstream 1`,objective:``,role:`worker`,prompt:``,priority:1,phase_id:`phase_1`,lane:`lane_1`,milestone:``,depends_on:[],input_refs:[],tool_allowlist_override:[],mcp_servers_override:[],output_contract:{kind:`report_markdown`,summary_guidance:``}}],review_stages:[],metadata:null}}function ja(e,t){let n=d.parse(e);if(!n||typeof n!=`object`)throw Error(`Invalid mission preset at ${t}: expected a YAML object.`);let r=n,i=String(r.id||``).trim(),a=String(r.label||``).trim(),o=String(r.description||``).trim(),s=r.schedule_defaults&&typeof r.schedule_defaults==`object`?r.schedule_defaults:void 0,c=r.blueprint;if(!i)throw Error(`Invalid mission preset at ${t}: missing id.`);if(!a)throw Error(`Invalid mission preset at ${t}: missing label.`);if(!o)throw Error(`Invalid mission preset at ${t}: missing description.`);if(!c||typeof c!=`object`)throw Error(`Invalid mission preset at ${t}: missing blueprint.`);return{id:i,label:a,description:o,schedule_defaults:s,blueprint:c}}var Ma=Object.entries(Ca).map(([e,t])=>ja(t,e)).sort((e,t)=>e.label.localeCompare(t.label,void 0,{sensitivity:`base`}));function Na(e){let t=String(e||``).trim();return t?t.startsWith(`/`)?``:`Workspace root must be an absolute path.`:`Workspace root is required.`}function Pa(e){let t=[];String(e.title||``).trim()||t.push(`Mission title is required.`),String(e.goal||``).trim()||t.push(`Mission goal is required.`);let n=Na(e.workspace_root);return n&&t.push(n),(!Array.isArray(e.workstreams)||e.workstreams.length===0)&&t.push(`At least one workstream is required.`),t}function Fa(e,t){let n=e?.metadata&&typeof e.metadata==`object`?e.metadata:{},r=n.mission_blueprint||n.missionBlueprint||n.mission_blueprint_v1;if(!r||typeof r!=`object`)return null;let i=r;return{...Aa(t),...i,workspace_root:String(i.workspace_root||t||``).trim(),phases:Array.isArray(i.phases)&&i.phases.length?i.phases:Aa(t).phases,milestones:Array.isArray(i.milestones)?i.milestones:[],workstreams:Array.isArray(i.workstreams)?i.workstreams:[],review_stages:Array.isArray(i.review_stages)?i.review_stages:[]}}function Ia({title:e,subtitle:t,icon:n,children:r}){return f(`div`,{className:`rounded-xl border border-slate-700/50 bg-slate-950/50 p-4`,children:[f(`div`,{className:`mb-3`,children:[f(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-slate-100`,children:[n?f(`i`,{"data-lucide":n}):null,f(`span`,{children:e})]}),t?f(`div`,{className:`tcp-subtle mt-1 text-xs`,children:t}):null]}),f(`div`,{className:`grid gap-3`,children:r})]})}function La({label:e,value:t,onInput:n,placeholder:r,type:i=`text`}){return f(`label`,{className:`block text-sm`,children:[f(`div`,{className:`mb-1 font-medium text-slate-200`,children:e}),f(`input`,{type:i,value:t,placeholder:r,onInput:e=>n(e.target.value),className:`h-10 w-full rounded-lg border border-slate-700 bg-slate-950/80 px-3 text-sm text-slate-100 outline-none focus:border-amber-400`})]})}function Ra({label:e,value:t,onInput:n,placeholder:r,rows:i=5,readOnly:a=!1}){return f(`label`,{className:`block text-sm`,children:[f(`div`,{className:`mb-1 font-medium text-slate-200`,children:e}),f(`textarea`,{rows:i,value:t,readOnly:a,placeholder:r,onInput:e=>n(e.target.value),className:`min-h-[108px] w-full rounded-lg border border-slate-700 bg-slate-950/80 px-3 py-2 text-sm text-slate-100 outline-none focus:border-amber-400`})]})}function za({active:e,label:t,icon:n,onClick:r,disabled:i=!1}){return f(`button`,{className:`tcp-btn h-8 px-3 text-xs ${e?`border-amber-400/60 bg-amber-400/10 text-amber-300`:``} ${i?`cursor-not-allowed opacity-50`:``}`,onClick:r,type:`button`,disabled:i,children:f(`span`,{className:`inline-flex items-center gap-2`,children:[n?f(`i`,{"data-lucide":n}):null,f(`span`,{children:t})]})})}function Ba({children:e}){return f(`div`,{className:`tcp-subtle -mt-1 text-xs`,children:e})}function Va({text:e}){return f(`div`,{className:`tcp-subtle rounded-lg border border-slate-800 bg-slate-950/50 p-3 text-xs`,children:e})}function Ha({value:e,error:n,open:r,browseDir:i,search:a,parentDir:o,currentDir:s,directories:c,onOpen:l,onClose:u,onClear:d,onSearchChange:p,onBrowseParent:m,onBrowseDirectory:h,onSelectDirectory:g}){let _=String(a||``).trim().toLowerCase();return f(t,{children:[f(`label`,{className:`block text-sm`,children:[f(`div`,{className:`mb-1 font-medium text-slate-200`,children:`Workspace root`}),f(`div`,{className:`grid gap-2 md:grid-cols-[auto_1fr_auto]`,children:[f(`button`,{className:`tcp-btn h-10 px-3`,type:`button`,onClick:l,children:[f(`i`,{"data-lucide":`folder-open`}),`Browse`]}),f(`input`,{className:`tcp-input text-sm ${n?`border-red-500/70 text-red-100`:``}`,value:e,readOnly:!0,placeholder:`No local directory selected. Use Browse.`}),f(`button`,{className:`tcp-btn h-10 px-3`,type:`button`,onClick:d,disabled:!e,children:[f(`i`,{"data-lucide":`x`}),`Clear`]})]})]}),r?f(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center p-4`,children:[f(`button`,{type:`button`,className:`tcp-confirm-backdrop`,"aria-label":`Close workspace directory dialog`,onClick:u}),f(`div`,{className:`tcp-confirm-dialog max-w-2xl`,children:[f(`h3`,{className:`tcp-confirm-title`,children:`Select Workspace Folder`}),f(`p`,{className:`tcp-confirm-message`,children:[`Current: `,s||i||`n/a`]}),f(`div`,{className:`mb-2 flex flex-wrap gap-2`,children:[f(`button`,{className:`tcp-btn`,type:`button`,onClick:m,disabled:!o,children:[f(`i`,{"data-lucide":`arrow-left-to-line`}),`Up`]}),f(`button`,{className:`tcp-btn-primary`,type:`button`,onClick:g,disabled:!s,children:[f(`i`,{"data-lucide":`badge-check`}),`Select This Folder`]}),f(`button`,{className:`tcp-btn`,type:`button`,onClick:u,children:[f(`i`,{"data-lucide":`x`}),`Close`]})]}),f(`div`,{className:`mb-2`,children:f(`input`,{className:`tcp-input`,placeholder:`Type to filter folders...`,value:a,onInput:e=>p(e.target.value)})}),f(`div`,{className:`max-h-[360px] overflow-auto rounded-lg border border-slate-700/60 bg-slate-900/20 p-2`,children:c.length?c.map(e=>f(`button`,{className:`tcp-list-item mb-1 w-full text-left`,type:`button`,onClick:()=>h(String(e?.path||``)),children:f(`span`,{className:`inline-flex items-center gap-2`,children:[f(`i`,{"data-lucide":`folder-open`}),f(`span`,{children:String(e?.name||e?.path||``)})]})},String(e?.path||e?.name))):f(Va,{text:_?`No folders match your search.`:`No subdirectories in this folder.`})})]})]}):null]})}function Ua({client:o,api:l,toast:u,defaultProvider:d,defaultModel:p,editingAutomation:m=null,onShowAutomations:g,onShowRuns:_,onClearEditing:v,onNavigationLockChange:y}){let b=s(),x=i(null),[S,C]=a(`mission`),[w,T]=a(`manual`),[E,D]=a(`3600`),[O,ee]=a(``),[te,k]=a(!0),[ne,A]=a(``),[j,re]=a(``),[M,N]=a(null),[P,ie]=a(``),[F,ae]=a(``),[oe,I]=a(!1),[se,L]=a([]),[R,ce]=a(Aa(``)),[le,ue]=a({provider:d,model:p}),[de,fe]=a({}),[pe,z]=a({}),[me,he]=a(!1),[ge,_e]=a(``),[ve,B]=a(``),[V,H]=a(!1),[ye,U]=a(``),[be,xe]=a(``),Se=c({queryKey:[`settings`,`providers`,`catalog`],queryFn:()=>o.providers.catalog().catch(()=>({all:[]})),refetchInterval:3e4}),G=c({queryKey:[`settings`,`providers`,`config`],queryFn:()=>o.providers.config().catch(()=>({})),refetchInterval:3e4}),Ce=c({queryKey:[`mcp`,`servers`],queryFn:()=>o.mcp.list().catch(()=>({})),refetchInterval:12e3}),we=c({queryKey:[`tool`,`ids`],queryFn:()=>o.listToolIds().catch(()=>[]),refetchInterval:3e4}),Te=c({queryKey:[`agent-team`,`templates`],queryFn:async()=>{let e=await o.agentTeams.listTemplates().catch(()=>({templates:[]}));return Array.isArray(e?.templates)?e.templates:[]},refetchInterval:3e4}),Ee=c({queryKey:[`global`,`health`],queryFn:()=>o.health().catch(()=>({})),refetchInterval:3e4}),De=c({queryKey:[`advanced-mission-builder`,`workspace-browser`,ye],enabled:V&&!!ye,queryFn:()=>l(`/api/orchestrator/workspaces/list?dir=${encodeURIComponent(ye)}`,{method:`GET`})}),Oe=r(()=>j?j===`generate`?{title:`Generating mission draft`,message:`Tandem is drafting the mission. Stay on this page until it finishes.`}:j===`preview`?{title:`Compiling preview`,message:`Tandem is compiling the preview. Stay on this page until it finishes.`}:{title:`Applying mission draft`,message:`Tandem is creating the automation. Stay on this page until it finishes.`}:null,[j]);e(()=>{let e=String(Ee.data?.workspaceRoot||Ee.data?.workspace_root||``).trim();e&&(ie(e),ce(t=>t.workspace_root?t:{...Aa(e),workspace_root:e}))},[Ee.data]),n(()=>(y?.(Oe),()=>{y?.(null)}),[Oe,y]),e(()=>{let e=P||String(Ee.data?.workspaceRoot||Ee.data?.workspace_root||``).trim();if(!m){ce(Aa(e)),N(null),A(``),C(`mission`),k(!0),ae(``),I(!1),L([]),T(`manual`),D(`3600`),ee(``),_e(``),B(``),ue({provider:d,model:p}),fe({}),z({});return}let t=Fa(m,e);if(!t)return;ce(t),ae(String(t.goal||``).trim()),I(!0),L([]),ue(Da(t.team.default_model_policy));let n={};for(let e of t.workstreams)n[e.workstream_id]=Da(e.model_override);fe(n);let r={};for(let e of t.review_stages)r[e.stage_id]=Da(e.model_override);z(r);let i=m?.schedule||{},a=String(i?.type||``).trim().toLowerCase();a===`cron`?(T(`cron`),ee(String(i?.cron_expression||``).trim())):a===`interval`?(T(`interval`),D(String(i?.interval_seconds||3600))):(T(`manual`),ee(``),D(`3600`)),k(!1),_e(``),B(``),N(null),A(``)},[m?.automation_id,P,d,p,Ee.data]);let ke=r(()=>Ae({providerCatalog:Se.data,providerConfig:G.data,defaultProvider:d,defaultModel:p}),[p,d,Se.data,G.data]),je=r(()=>wa(Ce.data),[Ce.data]),Me=r(()=>(Array.isArray(we.data)?we.data:[]).map(e=>String(e||``).trim()).filter(Boolean).sort(),[we.data]),Ne=r(()=>(Array.isArray(Te.data)?Te.data:[]).map(e=>({template_id:String(e?.template_id||e?.templateId||``).trim(),role:String(e?.role||``).trim()})).filter(e=>e.template_id),[Te.data]),Pe=Array.isArray(De.data?.directories)?De.data.directories:[],Fe=String(De.data?.parent||``).trim(),Ie=String(De.data?.dir||ye||``).trim(),Le=r(()=>{let e=String(be||``).trim().toLowerCase();return e?Pe.filter(t=>String(t?.name||t?.path||``).trim().toLowerCase().includes(e)):Pe},[be,Pe]),Re=Na(R.workspace_root||P),ze=oe||!!m;e(()=>{try{x.current?h(x.current):h()}catch{}},[S,me,M,j,R,le,de,pe]);let K=r(()=>({...R,workspace_root:R.workspace_root||P,team:{...R.team,default_model_policy:Ea(le)},workstreams:R.workstreams.map(e=>({...e,model_override:Ea(de[e.workstream_id]||{provider:``,model:``})})),review_stages:R.review_stages.map(e=>({...e,model_override:Ea(pe[e.stage_id]||{provider:``,model:``})}))}),[R,P,le,de,pe]),Be=r(()=>Pa(K),[K]),Ve=r(()=>Ma.find(e=>e.id===ge)||null,[ge]),He=r(()=>ba(),[]),Ue=r(()=>_a({humanIntent:F,missionTitle:K.title,missionGoal:K.goal,sharedContext:K.shared_context||``,successCriteria:K.success_criteria,workspaceRoot:K.workspace_root||P,archetypeLabel:Ve?.label||``,scheduleKind:w,intervalSeconds:E,cronExpression:O}),[K.goal,K.shared_context,K.success_criteria,K.title,K.workspace_root,F,P,Ve?.label,w,E,O]),We=r(()=>[...K.workstreams.map(e=>e.workstream_id),...K.review_stages.map(e=>e.stage_id)],[K]);function q(e){ce(t=>({...t,...e})),N(null)}function Ge(){ce(e=>({...e,workstreams:[...e.workstreams,{workstream_id:`workstream_${xa()}`,title:`Workstream ${e.workstreams.length+1}`,objective:``,role:`worker`,prompt:``,priority:e.workstreams.length+1,phase_id:e.phases[0]?.phase_id||``,lane:`lane_${e.workstreams.length+1}`,milestone:``,depends_on:[],input_refs:[],tool_allowlist_override:[],mcp_servers_override:[],output_contract:{kind:`report_markdown`,summary_guidance:``}}]})),N(null)}function Ke(){ce(e=>({...e,review_stages:[...e.review_stages,{stage_id:`review_${xa()}`,stage_kind:`approval`,title:`Gate ${e.review_stages.length+1}`,target_ids:[],role:`reviewer`,prompt:``,checklist:[],priority:e.review_stages.length+1,phase_id:e.phases[0]?.phase_id||``,lane:`review`,milestone:``,tool_allowlist_override:[],mcp_servers_override:[],gate:{required:!0,decisions:[`approve`,`rework`,`cancel`],rework_targets:[],instructions:``}}]})),N(null)}function qe(e){let t=ya(e);T(t.scheduleKind),D(t.intervalSeconds),ee(t.cronExpression)}function Je(e){let t=Ma.find(t=>t.id===e);t&&(ce({...Aa(R.workspace_root||P),...t.blueprint,mission_id:`mission_${xa()}`,workspace_root:R.workspace_root||P}),N(null),A(``),C(`mission`),_e(t.id),ae(t.description),I(!0),L([]),qe(t.schedule_defaults),ue({provider:d,model:p}),fe({}),z({}),u(`info`,`Loaded ${t.label}. Review the prompts and adapt them to your mission.`))}function Ye(){let e=va(ve);if(!e.blueprint){let t=e.error||`Unable to import mission draft.`;A(t),u(`err`,t);return}let t={...Aa(R.workspace_root||P),...e.blueprint,workspace_root:String(e.blueprint?.workspace_root||R.workspace_root||P).trim()||R.workspace_root||P};ce(t),I(!0),ae(String(t.goal||``).trim()),L([]),qe(e.scheduleDefaults),N(null),A(``),u(`ok`,`Imported mission blueprint draft.`)}async function Xe(){try{await navigator.clipboard.writeText(Ue),u(`ok`,`Mission authoring prompt copied.`)}catch{u(`warn`,`Unable to copy automatically. The prompt is still shown below.`)}}async function Ze(){let e=String(F||``).trim(),t=String(R.workspace_root||P||``).trim();if(!e){let e=`Mission intent is required.`;A(e),u(`err`,e);return}let n=Na(t);if(n){A(n),u(`err`,n);return}re(`generate`),A(``);try{let n=await l(`/api/engine/mission-builder/generate-draft`,{method:`POST`,body:JSON.stringify({intent:e,workspace_root:t,archetype_id:ge||void 0,creator_id:`control-panel`})}),r={...Aa(t),...n?.blueprint||{},workspace_root:t},i=ka(n?.suggested_schedule);ce(r),T(i.scheduleKind),D(i.intervalSeconds),ee(i.cronExpression),I(!0),L(Array.isArray(n?.generation_warnings)?n.generation_warnings.map(e=>String(e||``).trim()).filter(Boolean):[]),N(null),C(`mission`),u(`ok`,`Mission draft generated.`)}catch(e){let t=e instanceof Error?e.message:String(e||`Unable to generate mission draft.`);A(t),u(`err`,t)}finally{re(``)}}async function Qe(){if(Be.length){let e=Be.join(` `);A(e),u(`err`,e),C(`mission`);return}re(`preview`),A(``);try{N(await l(`/api/engine/mission-builder/compile-preview`,{method:`POST`,body:JSON.stringify({blueprint:K,schedule:Oa(w,E,O)})})),C(`compile`)}catch(e){let t=e instanceof Error?e.message:String(e||``),n=t===`mission blueprint validation failed`&&Be.length?Be.join(` `):t;A(n),u(`err`,n)}finally{re(``)}}async function $e(){if(Be.length){let e=Be.join(` `);A(e),u(`err`,e),C(`mission`);return}re(`apply`),A(``);try{let e=Oa(w,E,O);if(m?.automation_id){let t=await l(`/api/engine/mission-builder/compile-preview`,{method:`POST`,body:JSON.stringify({blueprint:K,schedule:e})});await o.automationsV2.update(m.automation_id,{name:t?.automation?.name,description:t?.automation?.description||null,schedule:t?.automation?.schedule,agents:t?.automation?.agents,flow:t?.automation?.flow,execution:t?.automation?.execution,workspace_root:t?.automation?.workspace_root,metadata:t?.automation?.metadata}),await Promise.all([b.invalidateQueries({queryKey:[`automations`]}),b.invalidateQueries({queryKey:[`automations`,`v2`,`list`]})]),u(`ok`,`Advanced mission updated.`),v?.(),g();return}let t=await l(`/api/engine/mission-builder/apply`,{method:`POST`,body:JSON.stringify({blueprint:K,creator_id:`control-panel`,schedule:e})});await Promise.all([b.invalidateQueries({queryKey:[`automations`]}),b.invalidateQueries({queryKey:[`automations`,`v2`,`list`]})]);let n=String(t?.automation?.automation_id||``).trim();te&&n?(await o.automationsV2.runNow(n),u(`ok`,`Advanced mission created and started.`),_()):(u(`ok`,`Advanced mission created.`),g()),ce(Aa(P)),ae(``),I(!1),L([]),N(null),k(!0)}catch(e){let t=e instanceof Error?e.message:String(e||``),n=t===`mission blueprint validation failed`&&Be.length?Be.join(` `):t;A(n),u(`err`,n)}finally{re(``)}}return f(`div`,{ref:x,className:`grid gap-4`,children:[f(`div`,{className:`rounded-xl border border-slate-700/50 bg-slate-950/50 p-3`,children:[f(`div`,{className:`mb-2 text-xs font-medium uppercase tracking-[0.24em] text-slate-500`,children:`Mission Builder`}),f(`div`,{className:`tcp-subtle text-xs`,children:`Describe what you want to accomplish, let Tandem generate the mission setup, then review and tweak the details before launch.`}),f(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[f(`button`,{className:`tcp-btn h-8 px-3 text-xs`,onClick:()=>he(!0),children:[f(`i`,{"data-lucide":`book-open`}),`How this works`]}),f(`span`,{className:`tcp-subtle text-xs`,children:`Start from example:`}),Ma.map(e=>f(`button`,{className:`tcp-btn h-8 px-3 text-xs`,onClick:()=>Je(e.id),children:[f(`i`,{"data-lucide":Sa[e.id]||`sparkles`}),e.label]},e.id))]}),f(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[[`mission`,`clipboard-list`],[`team`,`users`],[`workstreams`,`workflow`],[`review`,`shield-check`],[`compile`,`binary`]].map(([e,t])=>f(za,{active:S===e,label:e===`workstreams`?`workstreams`:e,icon:t,disabled:e!==`mission`&&!ze,onClick:()=>{if(e!==`mission`&&!ze){u(`warn`,`Generate or import a mission draft first.`),C(`mission`);return}C(e)}},e))})]}),ne?f(`div`,{className:`rounded-xl border border-red-500/40 bg-red-500/10 p-3 text-sm text-red-200`,children:ne}):null,m?f(`div`,{className:`rounded-xl border border-amber-500/30 bg-amber-500/10 p-3 text-sm text-amber-200`,children:[`Editing mission:`,` `,f(`strong`,{children:String(m?.name||m?.automation_id||``)})]}):null,me?f(`div`,{className:`fixed inset-0 z-50 flex items-start justify-center bg-slate-950/80 p-4 backdrop-blur-sm`,children:f(`div`,{className:`max-h-[90vh] w-full max-w-4xl overflow-y-auto rounded-2xl border border-slate-700 bg-slate-950 p-5 shadow-2xl`,children:[f(`div`,{className:`mb-4 flex items-start justify-between gap-4`,children:[f(`div`,{children:[f(`div`,{className:`text-lg font-semibold text-slate-100`,children:`How Mission Builder Works`}),f(`div`,{className:`tcp-subtle mt-1 text-sm`,children:`Start with a human mission intent, let Tandem generate the mission draft, then refine the details, handoffs, and review gates before launch.`})]}),f(`button`,{className:`tcp-btn h-9 px-3 text-sm`,onClick:()=>he(!1),children:`Close`})]}),f(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[f(Ia,{title:`What goes where`,subtitle:`Use the right field for the right level of instruction.`,children:f(`div`,{className:`grid gap-2 text-sm text-slate-300`,children:[f(`div`,{children:[f(`strong`,{className:`text-slate-100`,children:`Mission goal:`}),` the one shared outcome for the whole operation.`]}),f(`div`,{children:[f(`strong`,{className:`text-slate-100`,children:`Success criteria:`}),` concrete checks for whether the mission is done well.`]}),f(`div`,{children:[f(`strong`,{className:`text-slate-100`,children:`Shared context:`}),` facts, constraints, tone, audience, deadlines, approved sources.`]}),f(`div`,{children:[f(`strong`,{className:`text-slate-100`,children:`Workstream objective:`}),` the local assignment for that lane.`]}),f(`div`,{children:[f(`strong`,{className:`text-slate-100`,children:`Workstream prompt:`}),` the operating instructions for how that lane should work.`]}),f(`div`,{children:[f(`strong`,{className:`text-slate-100`,children:`Output contract:`}),` the artifact that downstream work expects to receive.`]}),f(`div`,{children:[f(`strong`,{className:`text-slate-100`,children:`Review / gate prompt:`}),` what a reviewer or approver must check before promotion.`]})]})}),f(Ia,{title:`How to get good results`,subtitle:`The builder works best when each stage is explicit.`,children:f(`div`,{className:`grid gap-2 text-sm text-slate-300`,children:[f(`div`,{children:`Keep the mission goal outcome-based, not a long checklist.`}),f(`div`,{children:`Make success criteria measurable.`}),f(`div`,{children:`Give each workstream one clear responsibility.`}),f(`div`,{children:`Use dependencies only for real handoffs.`}),f(`div`,{children:`Define outputs as concrete artifacts, not vague intentions.`}),f(`div`,{children:`Use review gates for quality and promotion, not for every step.`}),f(`div`,{children:`Prefer prompts that say what evidence, format, and audience the step should target.`})]})}),f(Ia,{title:`Prompt pattern`,subtitle:`A reliable starting scaffold for most workstreams.`,children:f(`div`,{className:`rounded-lg border border-slate-800 bg-slate-900/70 p-3 text-xs text-slate-300`,children:[f(`div`,{children:f(`strong`,{className:`text-slate-100`,children:`Mission goal`})}),f(`div`,{className:`mt-1`,children:`Produce a coordinated launch plan for Product X for the next 30 days.`}),f(`div`,{className:`mt-3`,children:f(`strong`,{className:`text-slate-100`,children:`Shared context`})}),f(`div`,{className:`mt-1`,children:`Audience is SMB owners. Tone is clear and practical. Use approved workspace and MCP sources only. Avoid speculative claims.`}),f(`div`,{className:`mt-3`,children:f(`strong`,{className:`text-slate-100`,children:`Workstream objective`})}),f(`div`,{className:`mt-1`,children:`Analyze the target workflow and identify the 3 highest-value AI opportunities for a near-term pilot.`}),f(`div`,{className:`mt-3`,children:f(`strong`,{className:`text-slate-100`,children:`Workstream prompt`})}),f(`div`,{className:`mt-1`,children:`Act as an AI workflow strategist. Map the current process, identify repeated manual work, decision bottlenecks, and coordination pain, then recommend realistic AI patterns with evidence and operational caveats.`}),f(`div`,{className:`mt-3`,children:f(`strong`,{className:`text-slate-100`,children:`Output contract`})}),f(`div`,{className:`mt-1`,children:`A markdown memo with sections: workflow summary, AI opportunities, feasibility constraints, risks, and recommended pilots.`})]})}),f(Ia,{title:`Starter examples`,subtitle:`Use these when you do not want to begin from a blank blueprint.`,children:f(`div`,{className:`grid gap-2 text-sm text-slate-300`,children:[f(`div`,{children:[f(`strong`,{className:`text-slate-100`,children:`AI Opportunities:`}),` workflow analysis and capability mapping feeding a ranked pilot brief.`]}),f(`div`,{children:[f(`strong`,{className:`text-slate-100`,children:`Workflow Audit:`}),` current-state mapping and failure analysis feeding an automation design review.`]}),f(`div`,{children:[f(`strong`,{className:`text-slate-100`,children:`Agentic Design:`}),` role design and flow design feeding governance and safety review.`]}),f(`div`,{children:[f(`strong`,{className:`text-slate-100`,children:`Rollout:`}),` process readiness and platform readiness feeding a launch plan and approval gate.`]})]})})]})]})}):null,S===`mission`?f(Ia,{title:`Mission`,subtitle:`Start with intent, then review the generated mission details.`,icon:`clipboard-list`,children:[f(`div`,{className:`rounded-xl border border-amber-500/20 bg-amber-500/5 p-3`,children:[f(`div`,{className:`mb-2 text-sm font-semibold text-slate-100`,children:`Mission intent`}),f(`div`,{className:`tcp-subtle text-xs`,children:`Describe what you want to accomplish and Tandem will generate the mission goal, shared context, success criteria, workstreams, reviews, and schedule draft.`}),f(`div`,{className:`mt-3 grid gap-3 lg:grid-cols-[minmax(0,2fr)_minmax(0,1fr)]`,children:[f(Ra,{label:`Mission intent`,value:F,onInput:ae,rows:8,placeholder:`Describe the outcome, audience, constraints, timing, and any recurring rhythm you want the mission to handle.`}),f(`div`,{className:`grid gap-3`,children:[f(`label`,{className:`block text-sm`,children:[f(`div`,{className:`mb-1 font-medium text-slate-200`,children:`Archetype hint`}),f(`select`,{value:ge,onInput:e=>_e(e.target.value),className:`h-10 w-full rounded-lg border border-slate-700 bg-slate-950/80 px-3 text-sm text-slate-100 outline-none focus:border-amber-400`,children:[f(`option`,{value:``,children:`None`}),Ma.map(e=>f(`option`,{value:e.id,children:e.label},e.id))]})]}),f(Ha,{value:R.workspace_root,error:Re,open:V,browseDir:ye,search:be,parentDir:Fe,currentDir:Ie,directories:Le,onOpen:()=>{U(String(R.workspace_root||P||`/`).trim()||`/`),xe(``),H(!0)},onClose:()=>{H(!1),xe(``)},onClear:()=>q({workspace_root:``}),onSearchChange:xe,onBrowseParent:()=>{Fe&&U(Fe)},onBrowseDirectory:e=>U(e),onSelectDirectory:()=>{Ie&&(q({workspace_root:Ie}),H(!1),xe(``),u(`ok`,`Workspace selected: ${Ie}`))}})]})]}),f(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[f(`button`,{className:`tcp-btn-primary h-10 px-3 text-sm`,type:`button`,onClick:()=>void Ze(),disabled:j===`generate`,children:[f(`i`,{"data-lucide":j===`generate`?`loader-circle`:`sparkles`}),j===`generate`?`Generating...`:`Generate mission draft`]}),f(`button`,{className:`tcp-btn h-10 px-3 text-sm`,type:`button`,onClick:()=>{ge&&Je(ge)},disabled:!ge,children:[f(`i`,{"data-lucide":`sparkles`}),`Load example draft`]})]}),Ve?f(`div`,{className:`tcp-subtle mt-2 text-xs`,children:Ve.description}):null,f(`div`,{className:`mt-3 grid gap-1 text-xs text-slate-300`,children:He.map(e=>f(`div`,{children:e},e))})]}),se.length?f(`div`,{className:`rounded-xl border border-amber-500/30 bg-amber-500/10 p-3 text-xs text-amber-100`,children:se.map((e,t)=>f(`div`,{children:e},`${e}-${t}`))}):null,f(`div`,{className:`rounded-xl border border-slate-700/50 bg-slate-950/40 p-3`,children:[f(`div`,{className:`mb-2 text-sm font-semibold text-slate-100`,children:`Advanced import / authoring`}),f(`div`,{className:`tcp-subtle text-xs`,children:`Power users can still copy an LLM authoring prompt or paste a generated YAML or JSON draft directly into Mission Builder.`}),f(`div`,{className:`mt-3 grid gap-3 md:grid-cols-2`,children:[f(`label`,{className:`block text-sm`,children:[f(`div`,{className:`mb-1 font-medium text-slate-200`,children:`Archetype hint`}),f(`select`,{value:ge,onInput:e=>_e(e.target.value),className:`h-10 w-full rounded-lg border border-slate-700 bg-slate-950/80 px-3 text-sm text-slate-100 outline-none focus:border-amber-400`,children:[f(`option`,{value:``,children:`None`}),Ma.map(e=>f(`option`,{value:e.id,children:e.label},e.id))]})]}),f(`div`,{className:`flex items-end gap-2`,children:f(`button`,{className:`tcp-btn h-10 px-3 text-sm`,type:`button`,onClick:Xe,children:[f(`i`,{"data-lucide":`copy`}),`Copy authoring prompt`]})})]}),Ve?f(`div`,{className:`tcp-subtle mt-2 text-xs`,children:Ve.description}):null,f(`div`,{className:`mt-3 grid gap-3 lg:grid-cols-2`,children:[f(Ra,{label:`LLM authoring prompt`,value:Ue,onInput:()=>{},rows:14,readOnly:!0,placeholder:``}),f(Ra,{label:`Paste LLM-generated YAML or JSON blueprint draft`,value:ve,onInput:B,rows:14,placeholder:`Paste a mission preset-shaped YAML object or a raw MissionBlueprint object.`})]}),f(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:f(`button`,{className:`tcp-btn h-8 px-3 text-xs`,type:`button`,onClick:Ye,children:[f(`i`,{"data-lucide":`file-input`}),`Import draft`]})})]}),ze?f(t,{children:[f(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[f(La,{label:`Mission title`,value:R.title,onInput:e=>q({title:e})}),f(La,{label:`Mission ID`,value:R.mission_id,onInput:e=>q({mission_id:e})})]}),f(Ba,{children:`Use a short title a human operator would recognize later in the automation list.`}),Re?f(`div`,{className:`text-xs text-red-300`,children:Re}):null,f(Ra,{label:`Mission goal`,value:R.goal,onInput:e=>q({goal:e}),placeholder:`Describe the shared objective all participants are working toward.`}),f(Ba,{children:`Write the one shared outcome for the whole mission, not a list of steps.`}),f(Ra,{label:`Shared context`,value:R.shared_context||``,onInput:e=>q({shared_context:e}),placeholder:`Shared constraints, references, context, and operator guidance.`}),f(Ba,{children:`Put the facts every lane should inherit here: audience, constraints, tone, deadlines, approved sources, and things to avoid.`}),f(La,{label:`Success criteria`,value:R.success_criteria.join(`, `),onInput:e=>q({success_criteria:Ta(e)}),placeholder:`comma-separated`}),f(Ba,{children:`These should be measurable checks like “brief includes 5 competitors” or “plan contains owner, timeline, and risks”.`}),f(`div`,{className:`grid gap-3 md:grid-cols-3`,children:[f(`label`,{className:`block text-sm`,children:[f(`div`,{className:`mb-1 font-medium text-slate-200`,children:`Schedule`}),f(`select`,{value:w,onInput:e=>T(e.target.value),className:`h-10 w-full rounded-lg border border-slate-700 bg-slate-950/80 px-3 text-sm text-slate-100 outline-none focus:border-amber-400`,children:[f(`option`,{value:`manual`,children:`Manual`}),f(`option`,{value:`interval`,children:`Interval`}),f(`option`,{value:`cron`,children:`Cron`})]})]}),w===`interval`?f(La,{label:`Interval seconds`,value:E,onInput:D}):null,w===`cron`?f(La,{label:`Cron expression`,value:O,onInput:ee}):null]})]}):f(Va,{text:`Generate or import a mission draft to review and tweak the mission details.`})]}):null,S===`team`?f(Ia,{title:`Team`,subtitle:`Templates, default model, concurrency, and mission limits.`,icon:`users`,children:[f(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[f(`label`,{className:`block text-sm`,children:[f(`div`,{className:`mb-1 font-medium text-slate-200`,children:`Orchestrator template`}),f(`select`,{value:R.orchestrator_template_id||``,onInput:e=>q({orchestrator_template_id:e.target.value}),className:`h-10 w-full rounded-lg border border-slate-700 bg-slate-950/80 px-3 text-sm text-slate-100 outline-none focus:border-amber-400`,children:[f(`option`,{value:``,children:`None`}),Ne.map(e=>f(`option`,{value:e.template_id,children:[e.template_id,` (`,e.role||`role`,`)`]},e.template_id))]})]}),f(La,{label:`Allowed templates`,value:(R.team.allowed_template_ids||[]).join(`, `),onInput:e=>q({team:{...R.team,allowed_template_ids:Ta(e)}}),placeholder:`comma-separated`})]}),f(Ba,{children:`The orchestrator keeps the mission coherent. Allowed templates restrict which reusable agent profiles lanes are permitted to use.`}),f(W,{providerLabel:`Default model provider`,modelLabel:`Default model`,draft:le,providers:ke,inheritLabel:`No team default`,onChange:ue}),f(`div`,{className:`grid gap-3 md:grid-cols-2 lg:grid-cols-4`,children:[f(La,{label:`Max parallel agents`,value:String(R.team.max_parallel_agents||4),onInput:e=>q({team:{...R.team,max_parallel_agents:Math.max(1,Number.parseInt(String(e||`4`),10)||4)}}),type:`number`}),f(La,{label:`Token ceiling`,value:String(R.team.mission_budget?.max_total_tokens||``),onInput:e=>q({team:{...R.team,mission_budget:{...R.team.mission_budget||{},max_total_tokens:e?Number(e):void 0}}}),type:`number`}),f(La,{label:`Cost ceiling USD`,value:String(R.team.mission_budget?.max_total_cost_usd||``),onInput:e=>q({team:{...R.team,mission_budget:{...R.team.mission_budget||{},max_total_cost_usd:e?Number(e):void 0}}}),type:`number`}),f(La,{label:`Tool-call ceiling`,value:String(R.team.mission_budget?.max_total_tool_calls||``),onInput:e=>q({team:{...R.team,mission_budget:{...R.team.mission_budget||{},max_total_tool_calls:e?Number(e):void 0}}}),type:`number`})]}),f(La,{label:`Allowed MCP servers`,value:(R.team.allowed_mcp_servers||[]).join(`, `),onInput:e=>q({team:{...R.team,allowed_mcp_servers:Ta(e)}}),placeholder:je.map(e=>e.name).join(`, `)}),f(Ba,{children:`Team defaults apply everywhere unless a workstream or review stage overrides its own tool or MCP scope.`})]}):null,S===`workstreams`?f(Ia,{title:`Workstreams`,subtitle:`Scoped sub-objectives, dependencies, tools, MCP, and output contracts.`,icon:`workflow`,children:[f(Ba,{children:`A workstream is one scoped lane of work. Give it one responsibility, one artifact to produce, and only the dependencies it truly needs.`}),f(`div`,{className:`flex justify-end`,children:f(`button`,{className:`tcp-btn h-8 px-3 text-xs`,onClick:Ge,children:[f(`i`,{"data-lucide":`plus`}),`Add workstream`]})}),K.workstreams.map((e,t)=>{let n=de[e.workstream_id]||{provider:``,model:``};return f(`div`,{className:`rounded-xl border border-slate-800 bg-slate-900/70 p-3`,children:[f(`div`,{className:`mb-3 flex items-center justify-between gap-2`,children:[f(`div`,{className:`text-sm font-semibold text-slate-100`,children:e.title||`Workstream ${t+1}`}),f(`button`,{className:`tcp-btn-danger h-7 px-2 text-xs`,onClick:()=>q({workstreams:K.workstreams.filter(t=>t.workstream_id!==e.workstream_id)}),children:`Remove`})]}),f(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[f(La,{label:`Title`,value:e.title,onInput:t=>q({workstreams:K.workstreams.map(n=>n.workstream_id===e.workstream_id?{...n,title:t}:n)})}),f(La,{label:`Role`,value:e.role,onInput:t=>q({workstreams:K.workstreams.map(n=>n.workstream_id===e.workstream_id?{...n,role:t}:n)})})]}),f(`div`,{className:`grid gap-3 md:grid-cols-3`,children:[f(La,{label:`Phase`,value:e.phase_id||``,onInput:t=>q({workstreams:K.workstreams.map(n=>n.workstream_id===e.workstream_id?{...n,phase_id:t}:n)})}),f(La,{label:`Lane`,value:e.lane||``,onInput:t=>q({workstreams:K.workstreams.map(n=>n.workstream_id===e.workstream_id?{...n,lane:t}:n)})}),f(La,{label:`Priority`,value:String(e.priority||0),onInput:t=>q({workstreams:K.workstreams.map(n=>n.workstream_id===e.workstream_id?{...n,priority:Number(t)||0}:n)}),type:`number`})]}),f(Ba,{children:"`Phase` says when this lane belongs in the mission. `Lane` groups related work. `Priority` decides ordering among runnable work in the same open phase."}),f(Ra,{label:`Objective`,value:e.objective,onInput:t=>q({workstreams:K.workstreams.map(n=>n.workstream_id===e.workstream_id?{...n,objective:t}:n)}),rows:3}),f(Ba,{children:`Objective is the local assignment. Keep it crisp: what this lane must accomplish.`}),f(Ra,{label:`Prompt`,value:e.prompt,onInput:t=>q({workstreams:K.workstreams.map(n=>n.workstream_id===e.workstream_id?{...n,prompt:t}:n)}),rows:5}),f(Ba,{children:`Prompt is how the lane should operate: role, evidence standard, audience, format, and what good work looks like.`}),f(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[f(La,{label:`Depends on`,value:e.depends_on.join(`, `),onInput:t=>q({workstreams:K.workstreams.map(n=>n.workstream_id===e.workstream_id?{...n,depends_on:Ta(t)}:n)}),placeholder:`comma-separated stage ids`}),f(La,{label:`Output contract kind`,value:e.output_contract.kind,onInput:t=>q({workstreams:K.workstreams.map(n=>n.workstream_id===e.workstream_id?{...n,output_contract:{...n.output_contract,kind:t}}:n)})})]}),f(Ba,{children:"`Depends on` should list upstream stage IDs that must finish first. `Output contract kind` names the artifact downstream lanes expect."}),f(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[f(La,{label:`Tool allowlist override`,value:(e.tool_allowlist_override||[]).join(`, `),onInput:t=>q({workstreams:K.workstreams.map(n=>n.workstream_id===e.workstream_id?{...n,tool_allowlist_override:Ta(t)}:n)}),placeholder:Me.join(`, `)}),f(La,{label:`MCP servers override`,value:(e.mcp_servers_override||[]).join(`, `),onInput:t=>q({workstreams:K.workstreams.map(n=>n.workstream_id===e.workstream_id?{...n,mcp_servers_override:Ta(t)}:n)}),placeholder:je.map(e=>e.name).join(`, `)})]}),f(Ba,{children:`Leave tool and MCP overrides empty to inherit team defaults. Override only when this lane needs a narrower or different scope.`}),f(W,{providerLabel:`Model provider`,modelLabel:`Model`,draft:n,providers:ke,onChange:t=>fe(n=>({...n,[e.workstream_id]:t}))})]},e.workstream_id)})]}):null,S===`review`?f(Ia,{title:`Review & Gates`,subtitle:`Reviewer, tester, and approval stages.`,icon:`shield-check`,children:[f(Ba,{children:`Use review stages to check quality or readiness before later work is promoted. Approval stages are the right place for human checkpoints.`}),f(`div`,{className:`flex justify-between gap-2`,children:[f(`button`,{className:`tcp-btn h-8 px-3 text-xs`,onClick:Ke,children:[f(`i`,{"data-lucide":`plus`}),`Add review stage`]}),f(`button`,{className:`tcp-btn h-8 px-3 text-xs`,onClick:()=>q({phases:[...K.phases,{phase_id:`phase_${K.phases.length+1}`,title:`Phase ${K.phases.length+1}`,description:``,execution_mode:`soft`}]}),children:[f(`i`,{"data-lucide":`copy-plus`}),`Add phase`]})]}),f(`div`,{className:`grid gap-2`,children:K.phases.map((e,t)=>f(`div`,{className:`rounded-lg border border-slate-800 bg-slate-900/70 p-3`,children:f(`div`,{className:`grid gap-3 md:grid-cols-4`,children:[f(La,{label:`Phase ID`,value:e.phase_id,onInput:e=>q({phases:K.phases.map((n,r)=>r===t?{...n,phase_id:e}:n)})}),f(La,{label:`Title`,value:e.title,onInput:e=>q({phases:K.phases.map((n,r)=>r===t?{...n,title:e}:n)})}),f(La,{label:`Description`,value:e.description||``,onInput:e=>q({phases:K.phases.map((n,r)=>r===t?{...n,description:e}:n)})}),f(`label`,{className:`block text-sm`,children:[f(`div`,{className:`mb-1 font-medium text-slate-200`,children:`Execution mode`}),f(`select`,{value:e.execution_mode||`soft`,onInput:e=>q({phases:K.phases.map((n,r)=>r===t?{...n,execution_mode:e.target.value}:n)}),className:`h-10 w-full rounded-lg border border-slate-700 bg-slate-950/80 px-3 text-sm text-slate-100 outline-none focus:border-amber-400`,children:[f(`option`,{value:`soft`,children:`soft`}),f(`option`,{value:`barrier`,children:`barrier`})]})]})]})},e.phase_id))}),f(Ba,{children:"`soft` phases prefer the current open phase first. `barrier` phases hold later phases closed until earlier required work is complete."}),K.review_stages.map((e,t)=>{let n=pe[e.stage_id]||{provider:``,model:``};return f(`div`,{className:`rounded-xl border border-slate-800 bg-slate-900/70 p-3`,children:[f(`div`,{className:`mb-3 flex items-center justify-between gap-2`,children:[f(`div`,{className:`text-sm font-semibold text-slate-100`,children:e.title||`Review stage ${t+1}`}),f(`button`,{className:`tcp-btn-danger h-7 px-2 text-xs`,onClick:()=>q({review_stages:K.review_stages.filter(t=>t.stage_id!==e.stage_id)}),children:`Remove`})]}),f(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[f(La,{label:`Title`,value:e.title,onInput:t=>q({review_stages:K.review_stages.map(n=>n.stage_id===e.stage_id?{...n,title:t}:n)})}),f(`label`,{className:`block text-sm`,children:[f(`div`,{className:`mb-1 font-medium text-slate-200`,children:`Stage kind`}),f(`select`,{value:e.stage_kind,onInput:t=>q({review_stages:K.review_stages.map(n=>n.stage_id===e.stage_id?{...n,stage_kind:t.target.value}:n)}),className:`h-10 w-full rounded-lg border border-slate-700 bg-slate-950/80 px-3 text-sm text-slate-100 outline-none focus:border-amber-400`,children:[f(`option`,{value:`review`,children:`review`}),f(`option`,{value:`test`,children:`test`}),f(`option`,{value:`approval`,children:`approval`})]})]})]}),f(`div`,{className:`grid gap-3 md:grid-cols-3`,children:[f(La,{label:`Targets`,value:e.target_ids.join(`, `),onInput:t=>q({review_stages:K.review_stages.map(n=>n.stage_id===e.stage_id?{...n,target_ids:Ta(t)}:n)}),placeholder:We.join(`, `)}),f(La,{label:`Phase`,value:e.phase_id||``,onInput:t=>q({review_stages:K.review_stages.map(n=>n.stage_id===e.stage_id?{...n,phase_id:t}:n)})}),f(La,{label:`Lane`,value:e.lane||``,onInput:t=>q({review_stages:K.review_stages.map(n=>n.stage_id===e.stage_id?{...n,lane:t}:n)})})]}),f(Ba,{children:`Targets are the stages this review or gate is checking. Put the review in the phase where that checkpoint should happen.`}),f(Ra,{label:`Prompt`,value:e.prompt,onInput:t=>q({review_stages:K.review_stages.map(n=>n.stage_id===e.stage_id?{...n,prompt:t}:n)}),rows:4}),f(Ba,{children:`Use the prompt to define what must be checked and what should trigger approve, rework, or fail.`}),f(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[f(La,{label:`Checklist`,value:(e.checklist||[]).join(`, `),onInput:t=>q({review_stages:K.review_stages.map(n=>n.stage_id===e.stage_id?{...n,checklist:Ta(t)}:n)}),placeholder:`comma-separated`}),f(La,{label:`MCP servers override`,value:(e.mcp_servers_override||[]).join(`, `),onInput:t=>q({review_stages:K.review_stages.map(n=>n.stage_id===e.stage_id?{...n,mcp_servers_override:Ta(t)}:n)}),placeholder:je.map(e=>e.name).join(`, `)})]}),f(Ba,{children:`Checklist items should be concrete pass/fail checks, not broad wishes.`}),f(W,{providerLabel:`Model provider`,modelLabel:`Model`,draft:n,providers:ke,onChange:t=>z(n=>({...n,[e.stage_id]:t}))})]},e.stage_id)})]}):null,S===`compile`?f(Ia,{title:`Compile & Run`,subtitle:`Validate the mission graph before launch.`,icon:`binary`,children:[f(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f(`button`,{className:`tcp-btn h-8 px-3 text-xs`,disabled:j===`preview`,onClick:()=>void Qe(),children:[f(`i`,{"data-lucide":`refresh-cw`}),j===`preview`?`Compiling...`:`Compile preview`]}),f(`button`,{className:`tcp-btn-primary h-8 px-3 text-xs`,disabled:j===`apply`,onClick:()=>void $e(),children:[f(`i`,{"data-lucide":m?`save`:`arrow-up-circle`}),j===`apply`?`Saving...`:m?`Save automation`:te?`Create and run`:`Create draft`]}),m?null:f(t,{children:f(`label`,{className:`ml-2 inline-flex items-center gap-2 text-xs text-slate-300`,children:[f(`input`,{type:`checkbox`,checked:te,onChange:e=>k(e.target.checked)}),`Run immediately after create`]})}),m&&v?f(`button`,{className:`tcp-btn h-8 px-3 text-xs`,onClick:()=>v(),children:`Cancel edit`}):null]}),M?f(t,{children:[f(`div`,{className:`grid gap-3 lg:grid-cols-2`,children:[f(`div`,{className:`rounded-lg border border-slate-800 bg-slate-900/70 p-3`,children:[f(`div`,{className:`mb-2 text-sm font-semibold text-slate-100`,children:`Validation`}),Array.isArray(M?.validation)&&M.validation.length?f(`div`,{className:`grid gap-2`,children:M.validation.map((e,t)=>f(`div`,{className:`rounded-lg border px-3 py-2 text-xs ${String(e?.severity||``).toLowerCase()===`warning`?`border-amber-500/40 bg-amber-500/10 text-amber-200`:`border-slate-700 bg-slate-950/60 text-slate-200`}`,children:[f(`div`,{className:`font-medium`,children:String(e?.code||e?.severity||`validation`)}),f(`div`,{className:`mt-1`,children:String(e?.message||``)})]},`${e?.code||`message`}-${t}`))}):f(`div`,{className:`tcp-subtle text-xs`,children:`No validation warnings.`})]}),f(`div`,{className:`rounded-lg border border-slate-800 bg-slate-900/70 p-3`,children:[f(`div`,{className:`mb-2 text-sm font-semibold text-slate-100`,children:`Compiled automation`}),f(`div`,{className:`grid gap-1 text-xs text-slate-300`,children:[f(`div`,{children:[`name: `,String(M?.automation?.name||`—`)]}),f(`div`,{children:[`nodes:`,` `,Array.isArray(M?.automation?.flow?.nodes)?M.automation.flow.nodes.length:0]}),f(`div`,{children:[`agents:`,` `,Array.isArray(M?.automation?.agents)?M.automation.agents.length:0]}),f(`div`,{children:[`max parallel:`,` `,String(M?.automation?.execution?.max_parallel_agents??`—`)]})]})]})]}),f(`div`,{className:`rounded-lg border border-slate-800 bg-slate-900/70 p-3`,children:[f(`div`,{className:`mb-2 text-sm font-semibold text-slate-100`,children:`Node preview`}),f(`div`,{className:`grid gap-2`,children:(Array.isArray(M?.node_previews)?M.node_previews:[]).map(e=>f(`div`,{className:`rounded-lg border border-slate-800 bg-slate-950/70 p-3 text-xs text-slate-300`,children:[f(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f(`strong`,{className:`text-slate-100`,children:String(e?.title||e?.node_id||`node`)}),f(`span`,{className:`tcp-subtle`,children:String(e?.node_id||``)}),f(`span`,{className:`tcp-subtle`,children:[`phase: `,String(e?.phase_id||`—`)]}),f(`span`,{className:`tcp-subtle`,children:[`lane: `,String(e?.lane||`—`)]}),f(`span`,{className:`tcp-subtle`,children:[`priority: `,String(e?.priority??`—`)]})]}),f(`div`,{className:`mt-1`,children:[`depends on:`,` `,Array.isArray(e?.depends_on)&&e.depends_on.length?e.depends_on.join(`, `):`none`]}),f(`div`,{className:`mt-1`,children:[`tools:`,` `,Array.isArray(e?.tool_allowlist)&&e.tool_allowlist.length?e.tool_allowlist.join(`, `):`default`]}),f(`div`,{className:`mt-1`,children:[`MCP:`,` `,Array.isArray(e?.mcp_servers)&&e.mcp_servers.length?e.mcp_servers.join(`, `):`default`]})]},String(e?.node_id||``)))})]}),f(`div`,{className:`grid gap-3 lg:grid-cols-2`,children:[f(`div`,{className:`rounded-lg border border-slate-800 bg-slate-900/70 p-3`,children:[f(`div`,{className:`mb-2 text-sm font-semibold text-slate-100`,children:`Compiled mission spec`}),f(`div`,{className:`grid gap-1 text-xs text-slate-300`,children:[f(`div`,{children:[`mission id: `,String(M?.mission_spec?.mission_id||`—`)]}),f(`div`,{children:[`title: `,String(M?.mission_spec?.title||`—`)]}),f(`div`,{children:[`goal: `,String(M?.mission_spec?.goal||`—`)]}),f(`div`,{children:[`entrypoint: `,String(M?.mission_spec?.entrypoint||`—`)]}),f(`div`,{children:[`phases: `,Array.isArray(R?.phases)?R.phases.length:0]}),f(`div`,{children:[`milestones:`,` `,Array.isArray(R?.milestones)?R.milestones.length:0]}),f(`div`,{children:[`success criteria:`,` `,Array.isArray(M?.mission_spec?.success_criteria)?M.mission_spec.success_criteria.length:0]})]}),Array.isArray(M?.mission_spec?.success_criteria)&&M.mission_spec.success_criteria.length?f(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:M.mission_spec.success_criteria.map((e,t)=>f(`span`,{className:`rounded-full border border-slate-700 bg-slate-950/70 px-2 py-1 text-[11px] text-slate-300`,children:String(e||``)},`${String(e||`criterion`)}-${t}`))}):null]}),f(`div`,{className:`rounded-lg border border-slate-800 bg-slate-900/70 p-3`,children:[f(`div`,{className:`mb-2 text-sm font-semibold text-slate-100`,children:`Compiled work items`}),Array.isArray(M?.work_items)&&M.work_items.length?f(`div`,{className:`grid gap-2`,children:M.work_items.map((e,t)=>f(`div`,{className:`rounded-lg border border-slate-800 bg-slate-950/70 p-3 text-xs text-slate-300`,children:[f(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f(`strong`,{className:`text-slate-100`,children:String(e?.title||e?.work_item_id||`work item`)}),f(`span`,{className:`tcp-subtle`,children:String(e?.work_item_id||``)}),f(`span`,{className:`tcp-subtle`,children:[`status: `,String(e?.status||`—`)]})]}),e?.detail?f(`div`,{className:`mt-1`,children:String(e.detail)}):null,f(`div`,{className:`mt-1`,children:[`assigned agent: `,String(e?.assigned_agent||`—`)]}),f(`div`,{className:`mt-1`,children:[`depends on:`,` `,Array.isArray(e?.depends_on)&&e.depends_on.length?e.depends_on.join(`, `):`none`]}),e?.metadata&&typeof e.metadata==`object`?f(`div`,{className:`mt-2 grid gap-1 sm:grid-cols-2`,children:[f(`div`,{children:[`phase: `,String(e.metadata.phase_id||`—`)]}),f(`div`,{children:[`lane: `,String(e.metadata.lane||`—`)]}),f(`div`,{children:[`milestone: `,String(e.metadata.milestone||`—`)]}),f(`div`,{children:[`stage: `,String(e.metadata.stage_kind||`—`)]})]}):null]},String(e?.work_item_id||`work-item-${t+1}`)))}):f(`div`,{className:`tcp-subtle text-xs`,children:`No compiled work items returned.`})]})]})]}):f(`div`,{className:`tcp-subtle text-xs`,children:`Compile the mission to inspect validation, compiled mission spec, work items, and execution shape.`})]}):null]})}function Wa(e,t){return Array.isArray(e)?e:Array.isArray(e?.[t])?e[t]:[]}function Ga(e){return Array.isArray(e?.servers)?e.servers.map(e=>{let t=String(e?.name||``).trim();return t?{name:t,connected:!!e?.connected,enabled:e?.enabled!==!1,toolCache:Array.isArray(e?.tool_cache||e?.toolCache)?(e.tool_cache||e.toolCache).map(e=>String(e?.namespaced_name||e?.namespacedName||e?.tool_name||e?.name||``).trim()).filter(Boolean):[],allowedTools:Array.isArray(e?.allowed_tools||e?.allowedTools)?(e.allowed_tools||e.allowedTools).map(e=>String(e||``).trim()).filter(Boolean):null}:null}).filter(e=>!!e).sort((e,t)=>e.name.localeCompare(t.name)):e&&typeof e==`object`?Object.entries(e).map(([e,t])=>{let n=String(e||``).trim();if(!n)return null;let r=t&&typeof t==`object`?t:{};return{name:n,connected:!!r.connected,enabled:r.enabled!==!1,toolCache:Array.isArray(r.tool_cache||r.toolCache)?(r.tool_cache||r.toolCache).map(e=>String(e?.namespaced_name||e?.namespacedName||e?.tool_name||e?.name||``).trim()).filter(Boolean):[],allowedTools:Array.isArray(r.allowed_tools||r.allowedTools)?(r.allowed_tools||r.allowedTools).map(e=>String(e||``).trim()).filter(Boolean):null}}).filter(e=>!!e).sort((e,t)=>e.name.localeCompare(t.name)):[]}function Ka(e){let t=String(e?.cron?.expression||e?.cron_expression||``).trim(),n=String(e?.timezone||`UTC`).trim()||`UTC`;if(t)return U({scheduleKind:`cron`,cronExpression:t,intervalSeconds:`3600`},{timezone:n});let r=Number(e?.interval_seconds?.seconds);return Number.isFinite(r)&&r>0?U({scheduleKind:`interval`,cronExpression:``,intervalSeconds:String(r)}):`manual`}function qa(e){let t=String(e?.type||``).trim().toLowerCase(),n=String(e?.timezone||`UTC`).trim()||`UTC`;if(t===`cron`)return U({scheduleKind:`cron`,cronExpression:String(e?.cron_expression||e?.cronExpression||``),intervalSeconds:`3600`},{timezone:n});if(t===`interval`){let t=Number(e?.interval_seconds||e?.intervalSeconds||0);return!Number.isFinite(t)||t<=0?`interval`:U({scheduleKind:`interval`,cronExpression:``,intervalSeconds:String(t)})}return`manual`}function Ja(e){let t=e?.next_fire_at_ms||e?.nextFireAtMs||e?.created_at_ms||e?.createdAtMs||0,n=Number(t);return Number.isFinite(n)&&n>0?n:0}function Ya(e,t,n,r){let i=Math.max(1,Math.round(Math.max(1,e)*1e3)),a=Math.max(0,Math.min(t,n)),o=Math.max(t,n);if(!Number.isFinite(i)||i<=0||o<=0)return[];let s=r>0?r:a;if(o<s)return[];let c=s;if(s<a){let e=a-s;c=s+Math.ceil(e/i)*i}let l=[];for(let e=c;e<o&&(e>=a&&l.push(e),!(l.length>=400));e+=i);return l}function Xa(e){let t=String(e||``).trim();return t?t.startsWith(`/`)?``:`Workspace root must be an absolute path.`:`Workspace root is required.`}function Za(e,t){let n=String(e||``).trim(),r=String(t||``).trim();return!n&&!r?``:n?r?``:`Planner model is required when a planner provider is set.`:`Planner model provider is required when a planner model is set.`}function Qa(e,t){let n=String(e||``).trim(),r=String(t||``).trim();return!n&&!r?``:n?r?``:`Model is required when a provider is set.`:`Model provider is required when a model is set.`}function $a(e){let t=String(e?.type||``).trim().toLowerCase(),n=String(e?.cron?.expression||e?.cron_expression||e?.cron||``).trim(),r=Number(e?.interval_seconds?.seconds||e?.interval_seconds||e?.intervalSeconds||3600);return{scheduleKind:t===`manual`?`manual`:n?`cron`:`interval`,cronExpression:n,intervalSeconds:Number.isFinite(r)&&r>0?Math.round(r):3600}}function eo(e){let t=``,n=!1;for(let r of String(e||``).trim())/^[a-z0-9]$/i.test(r)?(t+=r.toLowerCase(),n=!1):n||=(t+=`_`,!0);return t.replace(/^_+|_+$/g,``)||`mcp`}function to(e){let t=new Set,n=[];for(let r of e){let e=String(r||``).trim();!e||t.has(e)||(t.add(e),n.push(e))}return n}function no(e){return to(String(e||``).split(/[\n,]/g).map(e=>String(e||``).trim()).filter(Boolean))}function ro(e){return to(e).join(`
945
+ `)}function io(e,t,n,r,i){if(t===`all`)return[`*`];let a=r===null?e.map(e=>`mcp.${eo(e)}.*`):r;return to([...no(n),...i,...a])}function ao(e){let t=e?.metadata?.operator_preferences||e?.metadata?.operatorPreferences;if(t&&typeof t==`object`)return t;let n=Array.isArray(e?.agents)?e.agents[0]:null,r=n?.model_policy?.default_model||n?.modelPolicy?.defaultModel||null,i=n?.model_policy?.role_models||n?.modelPolicy?.roleModels||null,a={};return(r?.provider_id||r?.providerId)&&(a.model_provider=r.provider_id||r.providerId),(r?.model_id||r?.modelId)&&(a.model_id=r.model_id||r.modelId),i&&typeof i==`object`&&(a.role_models=i),(e?.execution?.max_parallel_agents||e?.execution?.maxParallelAgents)&&(a.max_parallel_agents=e.execution.max_parallel_agents||e.execution.maxParallelAgents),a}function oo(e){let t=to((Array.isArray(e?.agents)?e.agents.flatMap(e=>Array.isArray(e?.tool_policy?.allowlist)?e.tool_policy.allowlist:[]):[]).map(e=>String(e||``).trim()).filter(Boolean));if(!t.length||t.includes(`*`))return{toolAccessMode:`all`,customToolsText:``,selectedMcpTools:null,mcpOtherAllowedTools:[]};let{mcpTools:n,otherTools:r}=xe(t);return{toolAccessMode:`custom`,customToolsText:ro(r),selectedMcpTools:n.length?n:null,mcpOtherAllowedTools:r}}function so(e){let t=e?.metadata&&typeof e.metadata==`object`?e.metadata:{},n=e?.tool_policy||e?.toolPolicy||null,r=e?.mcp_policy||e?.mcpPolicy||null,i=Array.isArray(t?.tool_allowlist||t?.toolAllowlist)?t.tool_allowlist||t.toolAllowlist:[],a=Array.isArray(n?.allowlist)?n.allowlist:i,o=Array.isArray(n?.denylist)?n.denylist:[],s=Array.isArray(r?.allowed_servers||r?.allowedServers)?r.allowed_servers||r.allowedServers:[],c=r?r.allowed_tools===null||r.allowedTools===null?null:Array.isArray(r.allowed_tools||r.allowedTools)?r.allowed_tools||r.allowedTools:[]:a,l=xe(to(a.map(e=>String(e||``)))),u=c===null?{mcpTools:[],otherTools:[]}:xe(to((c||[]).map(e=>String(e||``))));return{toolAccessMode:n||r||i.length?`custom`:`inherit`,toolAllowlist:l.otherTools,toolDenylist:to(o.map(e=>String(e||``))),mcpAllowedServers:to(s.map(e=>String(e||``))),mcpAllowedTools:c===null?null:u.mcpTools.length?u.mcpTools:r?[]:null,mcpOtherAllowedTools:u.otherTools}}function co(e){return v(Array.isArray(e?.connector_bindings)?e.connector_bindings:[])}function lo(e){let t=Array.isArray(e)?e:[],n=new Set,r=[];for(let e of t){let t=String(e||``).trim();!t||n.has(t)||(n.add(t),r.push(t))}return r}function uo(e){let t=e?.metadata&&typeof e.metadata==`object`?e.metadata:{},n=[t?.shared_context_bindings,t?.sharedContextBindings,t?.shared_context_pack_ids,t?.sharedContextPackIds,t?.plan_package?.shared_context_bindings,t?.planPackage?.shared_context_bindings,t?.plan_package?.shared_context_pack_ids,t?.planPackage?.shared_context_pack_ids],r=[];for(let e of n)if(Array.isArray(e))for(let t of e){if(typeof t==`string`){r.push(t);continue}!t||typeof t!=`object`||r.push(String(t.pack_id||t.packId||t.context_pack_id||t.contextPackId||t.id||``).trim())}return lo(r)}function fo(e){return e===void 0?e:JSON.parse(JSON.stringify(e))}function po(e,t){let n=Array.isArray(e?.connector_intents)?e.connector_intents:[],r=new Map;for(let e of n){let t=String(e?.capability||``).trim();t&&r.set(t,{capability:t,why:String(e?.why||``).trim()||null,required:e?.required===!0,degraded_mode_allowed:e?.degraded_mode_allowed===!0,resolved:!1,status:e?.required===!0?`unresolved_required`:`unresolved_optional`,binding_type:null,binding_id:null,allowlist_pattern:null})}for(let e of t){let t=String(e?.capability||``).trim();if(!t)continue;let n=String(e?.status||``).trim().toLowerCase()===`mapped`,i=r.get(t)||{capability:t,why:null,required:!1,degraded_mode_allowed:!1,resolved:!1,status:`unresolved_optional`,binding_type:null,binding_id:null,allowlist_pattern:null};i.binding_type=String(e?.binding_type||``).trim()||null,i.binding_id=String(e?.binding_id||``).trim()||null,i.allowlist_pattern=String(e?.allowlist_pattern||``).trim()||null,i.resolved=n,i.status=n?`mapped`:i.required?`unresolved_required`:`unresolved_optional`,r.set(t,i)}let i=Array.from(r.values()).sort((e,t)=>e.capability.localeCompare(t.capability));return{mapped_count:i.filter(e=>e.resolved).length,unresolved_required_count:i.filter(e=>!e.resolved&&e.required).length,unresolved_optional_count:i.filter(e=>!e.resolved&&!e.required).length,entries:i}}function mo(e){let t=String(e||``).trim();if(!t)return[];let n=JSON.parse(t);if(!Array.isArray(n))throw Error(`Connector bindings must be a JSON array.`);let r=new Set;return n.map((e,t)=>{if(!e||typeof e!=`object`)throw Error(`Connector binding ${t+1} must be an object.`);let n=String(e.capability||``).trim();if(!n)throw Error(`Connector binding ${t+1} is missing a capability.`);if(r.has(n))throw Error(`Connector binding capability \`${n}\` is declared more than once.`);r.add(n);let i=String(e.binding_type||e.bindingType||``).trim(),a=String(e.binding_id||e.bindingId||``).trim(),o=String(e.allowlist_pattern||e.allowlistPattern||``).trim(),s=String(e.status||``).trim().toLowerCase();if(!s)throw Error(`Connector binding \`${n}\` must include an explicit status of mapped, unresolved_required, or unresolved_optional.`);let c=s===`mapped`||s===`unresolved_required`||s===`unresolved_optional`?s:null;if(!c)throw Error(`Connector binding \`${n}\` has unsupported status \`${s}\`. Use mapped, unresolved_required, or unresolved_optional.`);if(c===`mapped`&&(!i||!a))throw Error(`Connector binding \`${n}\` must include binding_type and binding_id when status is mapped.`);return{capability:n,binding_type:i,binding_id:a,allowlist_pattern:o||null,status:c}})}function ho(e){let t=String(e?.automation_id||e?.automationId||e?.id||``).trim();if(!t)return null;let n=$a(e?.schedule),r=ao(e),i=r?.role_models?.planner||r?.roleModels?.planner||{},a=Number(r?.max_parallel_agents??r?.maxParallelAgents??e?.execution?.max_parallel_agents??e?.execution?.maxParallelAgents??1),o=String(r?.execution_mode||r?.executionMode||``).trim(),s=Array.isArray(e?.metadata?.allowed_mcp_servers)?e.metadata.allowed_mcp_servers:Array.isArray(e?.agents?.[0]?.mcp_policy?.allowed_servers)?e.agents[0].mcp_policy.allowed_servers:[],c=oo(e),l=String(r?.model_provider||r?.modelProvider||``).trim(),u=String(r?.model_id||r?.modelId||``).trim(),d=new Map(Array.isArray(e?.agents)?e.agents.map(e=>[String(e?.agent_id||e?.agentId||``).trim(),e]):[]),f=Array.isArray(e?.flow?.nodes)?e.flow.nodes.map((e,t)=>{let n=e?.metadata?.approval&&typeof e.metadata.approval==`object`?e.metadata.approval:{},r=String(n?.auto_approve_when||n?.autoApproveWhen||``).trim(),i=n?.skip_approval===!0||n?.skipApproval===!0?`skip`:r?`auto`:`default`;return{nodeId:String(e?.node_id||e?.nodeId||e?.id||`node-${t}`).trim(),title:String(e?.title||e?.name||e?.objective||e?.node_id||e?.id||`Workflow step`).trim(),objective:String(e?.objective||``).trim(),agentId:String(e?.agent_id||e?.agentId||``).trim(),approvalOverride:i,approvalCondition:r,...so(e),...(()=>{let t=d.get(String(e?.agent_id||e?.agentId||``).trim());return Wo(t?.model_policy||t?.modelPolicy||null,l,u)})()}}):[],p=e?.metadata?.plan_package||e?.metadata?.planPackage||null,m=e?.metadata?.plan_package_bundle||e?.metadata?.planPackageBundle||null,h=e?.metadata?.plan_package_replay||e?.metadata?.planPackageReplay||null,g=e?.metadata?.plan_package_validation||e?.metadata?.planPackageValidation||null,_=e?.metadata?.context_materialization||e?.runtime_context||null,v=e?.metadata?.approved_plan_materialization||e?.metadata?.approvedPlanMaterialization||null,y=co(p),b=uo(e).join(`
946
+ `);return{automationId:t,name:String(e?.name||t).trim(),description:String(e?.description||``).trim(),recoveryPrompt:qo(e),sourceAutomation:fo(e),scheduleKind:n.scheduleKind,cronExpression:n.cronExpression,intervalSeconds:String(n.intervalSeconds),timezone:Oo(e),workspaceRoot:String(e?.workspace_root||e?.workspaceRoot||e?.metadata?.workspace_root||``).trim(),executionMode:o===`single`||o===`swarm`||o===`team`?o:a>1?`swarm`:`team`,maxParallelAgents:String(Number.isFinite(a)&&a>0?Math.round(a):1),executionProfile:(()=>{let t=String(e?.execution?.profile||e?.execution?.executionProfile||``).trim().toLowerCase();return t===`strict`||t===`guided`||t===`yolo`?t:``})(),modelProvider:l,modelId:u,plannerModelProvider:String(i?.provider_id||i?.providerId||``).trim(),plannerModelId:String(i?.model_id||i?.modelId||``).trim(),toolAccessMode:c.toolAccessMode,customToolsText:c.customToolsText,selectedMcpServers:s.map(e=>String(e||``).trim()).filter(Boolean),selectedMcpTools:c.selectedMcpTools,mcpOtherAllowedTools:c.mcpOtherAllowedTools,nodes:f,scopeSnapshot:p,planPackageBundle:m,planPackageReplay:h,scopeValidation:g,runtimeContext:_,approvedPlanMaterialization:v,connectorBindingsJson:y,sharedContextPackIdsText:b,handoffConfig:e?.handoff_config||e?.handoffConfig||null,watchConditions:Array.isArray(e?.watch_conditions)?e.watch_conditions:Array.isArray(e?.watchConditions)?e.watchConditions:[],scopePolicy:e?.scope_policy||e?.scopePolicy||null}}function go(e){let t=e?.metadata&&typeof e.metadata==`object`?e.metadata:{};return String(t.builder_kind||t.builderKind||e?.builder_kind||``).trim().toLowerCase()===`mission_blueprint`?!0:!!(t.mission_blueprint||t.missionBlueprint||t.mission_blueprint_v1||t.mission)}function _o(e){let t=Co(e.timezone),n={type:`run_once`};return e.scheduleKind===`manual`?{type:`manual`,timezone:t,misfire_policy:n}:e.scheduleKind===`cron`?{type:`cron`,cron_expression:String(e.cronExpression||``).trim(),timezone:t,misfire_policy:n}:{type:`interval`,interval_seconds:Math.max(1,Number.parseInt(String(e.intervalSeconds||`3600`),10)||3600),timezone:t,misfire_policy:n}}var vo=1800*1e3,yo=60*1e3,bo={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6},xo=new Map,So=new Map;function Co(e){return String(e||``).trim()||`UTC`}function wo(e){let t=Co(e),n=xo.get(t);return n||(n=new Intl.DateTimeFormat(`en-US`,{timeZone:t,year:`numeric`,month:`numeric`,day:`numeric`,hour:`numeric`,minute:`numeric`,hourCycle:`h23`}),xo.set(t,n)),n}function To(e){let t=Co(e),n=So.get(t);return n||(n=new Intl.DateTimeFormat(`en-US`,{timeZone:t,weekday:`short`}),So.set(t,n)),n}function Eo(e,t){return Number.parseInt(e.find(e=>e.type===t)?.value||`0`,10)}function Do(e,t){let n=Co(t),r=wo(n).formatToParts(e),i=To(n).format(e);return{year:Eo(r,`year`),month:Eo(r,`month`),day:Eo(r,`day`),hour:Eo(r,`hour`),minute:Eo(r,`minute`),weekday:bo[i]??0}}function Oo(e){return String(e?.schedule?.timezone||e?.timezone||e?.schedule?.timeZone||`UTC`).trim()||`UTC`}function ko(e){return String(e?.cron?.expression||e?.cron_expression||e?.cronExpression||e?.cron||``).trim()}function Ao(e){return String(e||``).trim().split(`,`).map(e=>e.trim()).filter(Boolean)}function jo(e,t,n,r){let i=String(e||``).trim();if(!i||i===`*`)return!0;let a=i.split(`/`),o=a[0]||`*`,s=a[1]?Number.parseInt(a[1],10):1,c=Number.isFinite(s)&&s>0?s:1,l=o.split(`-`),u=n,d=r;if(o!==`*`&&(l.length===2?(u=Number.parseInt(l[0],10),d=Number.parseInt(l[1],10)):(u=Number.parseInt(o,10),d=u)),!Number.isFinite(u)||!Number.isFinite(d))return!1;let f=Math.max(n,Math.min(r,u));return t<f||t>Math.max(n,Math.min(r,d))?!1:(t-f)%c===0}function Mo(e,t,n,r){let i=Ao(e);return i.length?i.some(e=>jo(e,t,n,r)):!0}function No(e,t,n){let r=String(t||``).trim().split(/\s+/).filter(Boolean);if(r.length!==5)return!1;let[i,a,o,s,c]=r,{minute:l,hour:u,day:d,month:f,weekday:p}=Do(e,n),m=Mo(i,l,0,59),h=Mo(a,u,0,23),g=Mo(s,f,1,12),_=!o||o===`*`,v=!c||c===`*`,y=_||Mo(o,d,1,31),b=v||Mo(c,p===0?7:p,0,7);return m&&h&&g&&(_||v?y&&b:y||b)}function Po(e,t,n,r){let i=[],a=Math.max(0,Math.min(t,n)),o=Math.max(t,n),s=new Date(Math.floor(a/yo)*yo);for(;s.getTime()<o;)No(s,e,r)&&i.push(s.getTime()),s.setTime(s.getTime()+yo);return i}function Fo(e){let t=String(e||``).trim().split(/\s+/).filter(Boolean);if(t.length!==5)return!1;let[n,r,i,a,o]=t,s=/^\d+$/.test(n),c=/^\d+$/.test(r),l=i===`*`,u=a===`*`,d=o===`*`||/^[0-7]$/.test(o);return s&&c&&l&&u&&d}function Io(e,t){let n=String(e||``).trim().split(/\s+/).filter(Boolean);if(n.length!==5)return null;let[r,i,a,o,s]=n;if(a!==`*`||o!==`*`||!/^\d+$/.test(r)||!/^\d+$/.test(i))return null;let c=String(t.getUTCMinutes()).padStart(2,`0`),l=String(t.getUTCHours()),u=String(t.getUTCDay());return`${c} ${l} ${a} ${o} ${s===`*`?`*`:u===`0`?`0`:u}`}function Lo(e){return String(e?.name||e?.mission?.objective||e?.description||e?.automation_id||e?.automationId||`Automation`).trim()}function Ro(e){return String(e?.automation_id||e?.automationId||e?.id||``).trim().startsWith(`automation-v2-`)?`v2`:`legacy`}function zo(e){return String(e?.status||`active`).trim()||`active`}function Bo({automation:e,family:t,rangeStartMs:n,rangeEndMs:r}){let i=String(e?.automation_id||e?.automationId||e?.id||``).trim();if(!i)return[];let a=e?.schedule||{},o=String(a?.type||``).trim().toLowerCase(),s=ko(a),c=Number(a?.interval_seconds?.seconds||a?.interval_seconds||a?.intervalSeconds||0),l=Lo(e),u=t===`legacy`?Ka(a):qa(a),d=zo(e),f=Oo(e),p=String(e?.metadata?.approved_plan_materialization?.lifecycle_state||e?.metadata?.approvedPlanMaterialization?.lifecycleState||e?.metadata?.plan_package?.lifecycle_state||e?.metadata?.planPackage?.lifecycleState||e?.lifecycle_state||e?.lifecycleState||``).trim().toLowerCase(),m=e?.requires_approval===!0||e?.policy?.approval?.requires_approval===!0,h=e?.metadata?.plan_package_validation?.ready_for_activation,g=Fo(s),_=o===`cron`&&s?Po(s,n,r,f):o===`interval`&&Number.isFinite(c)&&c>0?Ya(c,n,r,Ja(e)):[];return _.length?_.map(n=>({id:`${i}:${n}`,title:l,start:new Date(n),end:new Date(n+vo),allDay:!1,editable:g,startEditable:g,durationEditable:!1,extendedProps:{automation:e,automationId:i,family:t,scheduleLabel:u,scheduleType:o,cronExpression:s,intervalSeconds:Number.isFinite(c)&&c>0?c:null,status:d,timezone:f,lifecycleState:p,approvalRequired:m,approvalState:m?`approval required`:`approval optional`,activationReady:h}})):[]}function Vo(e){return String(e?.metadata?.feature||``).trim()===`agent_standup`}function Ho(e){let t={execution_mode:e.executionMode,max_parallel_agents:e.executionMode===`single`?1:Math.max(2,Math.min(16,Number.parseInt(String(e.maxParallelAgents||`4`),10)||4))},n=String(e.modelProvider||``).trim(),r=String(e.modelId||``).trim();n&&(t.model_provider=n),r&&(t.model_id=r);let i=String(e.plannerModelProvider||``).trim(),a=String(e.plannerModelId||``).trim();return i&&a&&(t.role_models={planner:{provider_id:i,model_id:a}}),t.tool_access_mode=e.toolAccessMode,e.toolAccessMode===`custom`&&(t.tool_allowlist=no(e.customToolsText)),t}function Uo(e){let t={};return e.model_provider&&e.model_id&&(t.default_model={provider_id:e.model_provider,model_id:e.model_id}),e.role_models&&typeof e.role_models==`object`&&(t.role_models=e.role_models),Object.keys(t).length?t:null}function Wo(e,t,n){let r=e?.default_model||e?.defaultModel||null,i=String(r?.provider_id||r?.providerId||``).trim(),a=String(r?.model_id||r?.modelId||``).trim();return i&&a&&i===String(t||``).trim()&&a===String(n||``).trim()?{modelProvider:``,modelId:``}:{modelProvider:i,modelId:a}}function Go(e,t,n){let r=String(t||``).trim(),i=String(n||``).trim();if(!r&&!i)return e?fo(e):null;let a=e?fo(e):{};return a.default_model={provider_id:r,model_id:i},a}function Ko(...e){for(let t of e){let e=String(t||``).trim();if(e)return e}return``}function qo(e){let t=e?.metadata&&typeof e.metadata==`object`?e.metadata:{};return Ko(t?.original_prompt,t?.originalPrompt,t?.normalized_prompt,t?.normalizedPrompt,t?.plan_package_bundle?.plan?.mission?.goal,t?.planPackageBundle?.plan?.mission?.goal,t?.plan_package?.plan?.mission?.goal,t?.planPackage?.plan?.mission?.goal,t?.plan_package?.scope_snapshot?.plan?.mission?.goal,t?.planPackage?.scopeSnapshot?.plan?.mission?.goal,t?.plan_package_bundle?.scope_snapshot?.mission?.goal,t?.planPackageBundle?.scopeSnapshot?.mission?.goal,e?.mission?.goal,e?.mission?.objective,e?.objective)}function Jo({client:e,toast:t,navigate:n,viewMode:r,selectedRunId:i,onSelectRunId:a,onOpenRunningView:o,onOpenAdvancedEdit:s,onRecreateWorkflowAutomation:c,defaultRunningSectionsOpen:l}){return f(ci,{client:e,toast:t,navigate:n,viewMode:r,selectedRunId:i,onSelectRunId:a,onOpenRunningView:o,onOpenAdvancedEdit:s,onRecreateWorkflowAutomation:c,defaultRunningSectionsOpen:l,automationWizardConfig:Ai,helperFns:{toArray:Wa,normalizeMcpServers:Ga,validateModelInput:Qa,validatePlannerModelInput:Za,validateWorkspaceRootInput:Xa,workflowEditToOperatorPreferences:Ho,compileWorkflowModelPolicy:Uo,cloneJsonValue:fo,compileWorkflowToolAllowlist:io,parseConnectorBindingsJson:mo,workflowNodeModelPolicyWithOverride:Go,deriveConnectorBindingResolutionFromPlanPackage:po,workflowAutomationToEditDraft:ho,isMissionBlueprintAutomation:go,workflowEditToSchedule:_o,buildCalendarOccurrences:Bo,normalizeTimestamp:Je,workflowQueueReason:He,detectWorkflowActiveTaskId:ht,detectWorkflowActiveTaskIds:gt,workflowDescendantTaskIds:mt,deriveRunDebugHints:qe,explainRunFailure:_t,buildRunBlockers:vt,isStandupAutomation:Vo,getAutomationCalendarFamily:Ro,rewriteCronForDroppedStart:Io,statusColor:e=>{let t=String(e||``).toLowerCase();return t===`active`||t===`completed`||t===`done`?`tcp-badge-ok`:t===`running`||t===`in_progress`?`tcp-badge-warn`:t===`blocked`?`border border-emerald-400/60 bg-emerald-400/10 text-emerald-200`:t===`failed`||t===`error`||t===`stalled`?`tcp-badge-err`:`tcp-badge-info`},formatScheduleLabel:Ka,formatAutomationV2ScheduleLabel:qa,workflowStatusDisplay:q,workflowStatusSubtleDetail:Ge,runDisplayTitle:tt,formatRunDateTime:nt,runObjectiveText:$e,shortText:Qe,runTimeLabel:Ke,compactIdentifier:Ze,sessionLabel:dt,formatTimestampLabel:Xe,isActiveRunStatus:Ve,scheduleToEditor:$a,uniqueStrings:rt,collectPathStrings:at,timestampOrNull:Ye,sessionMessageId:ut,sessionMessageCreatedAt:lt,sessionMessageVariant:st,sessionMessageText:ot,sessionMessageParts:ct}})}function Yo({client:e,api:t,toast:n,navigate:r,providerStatus:i,navigationLock:a,setNavigationLock:o}){let{tab:s,setTab:c,createMode:l,setCreateMode:u,selectedRunId:d,setSelectedRunId:p,advancedEditAutomation:m,setAdvancedEditAutomation:h,composerEnabled:_}=mi();return f(Fe,{tab:s,setTab:c,createMode:l,setCreateMode:u,selectedRunId:d,setSelectedRunId:p,advancedEditAutomation:m,setAdvancedEditAutomation:h,navigationLocked:!!a,onNavigationLockChange:o,client:e,api:t,toast:n,navigate:r,providerStatus:i,composerEnabled:_,PageCardComponent:g,CreateWizardComponent:Ui,AutomationComposerPanelComponent:oa,MyAutomationsComponent:Jo,AdvancedMissionBuilderPanelComponent:Ua})}export{Yo as AutomationsPage,Jo as MyAutomations};