@hearsay-tools/squawk 0.19.0-pr4482.8837 → 0.19.0-pr4484.8849

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 (125) hide show
  1. package/dist/ci-wait/controller.d.ts +7 -7
  2. package/dist/contract/index.d.ts +1 -0
  3. package/dist/contract/index.js +33 -7
  4. package/dist/contract/pull-request-urls.d.ts +20 -0
  5. package/dist/contract/runs.d.ts +10 -1
  6. package/dist/core/backend-detect.d.ts +1 -0
  7. package/dist/core/backend-detect.js +1 -1
  8. package/dist/core/backend-detect.js.map +1 -1
  9. package/dist/delegation/routes.d.ts +4 -4
  10. package/dist/delegation/transport.d.ts +69 -69
  11. package/dist/runs/pull-requests.d.ts +10 -0
  12. package/dist/runs/pull-requests.js +30 -19
  13. package/dist/runs/pull-requests.js.map +1 -1
  14. package/dist/runs/run-archive.d.ts +1 -0
  15. package/dist/runs/run-archive.js +14 -4
  16. package/dist/runs/run-archive.js.map +1 -1
  17. package/dist/runs/run-decode.d.ts +74 -72
  18. package/dist/runs/run-exits.d.ts +6 -0
  19. package/dist/runs/run-references.d.ts +1 -0
  20. package/dist/runs/run-references.js +7 -6
  21. package/dist/runs/run-references.js.map +1 -1
  22. package/dist/runs/store-open.d.ts +7 -1
  23. package/dist/runs/store-open.js +8 -2
  24. package/dist/runs/store-open.js.map +1 -1
  25. package/dist/runs/task-markers.js +1 -1
  26. package/dist/runs/task-markers.js.map +1 -1
  27. package/dist/runs/task-refs.d.ts +14 -7
  28. package/dist/runs/task-refs.js +32 -18
  29. package/dist/runs/task-refs.js.map +1 -1
  30. package/dist/server/activity-routes.d.ts +23 -23
  31. package/dist/server/completion-actions.js +3 -3
  32. package/dist/server/completion-actions.js.map +1 -1
  33. package/dist/server/forge/github-mutations.js +4 -2
  34. package/dist/server/forge/github-mutations.js.map +1 -1
  35. package/dist/server/forge/github-shared.js +4 -0
  36. package/dist/server/forge/github-shared.js.map +1 -1
  37. package/dist/server/project-settings-routes.d.ts +107 -107
  38. package/dist/server/providers-routes.d.ts +57 -57
  39. package/dist/server/repo-routes.d.ts +34 -34
  40. package/dist/server/runner-install-routes.d.ts +10 -10
  41. package/dist/server/runs-routes.d.ts +702 -693
  42. package/dist/server/server.d.ts +1366 -1348
  43. package/dist/server/workspace-routes.d.ts +84 -84
  44. package/dist/workflows/continuation-admission.d.ts +1 -0
  45. package/dist/workflows/run/wait-engine.d.ts +73 -72
  46. package/package.json +4 -4
  47. package/web/dist/assets/accounts-section-BeOGiodx.js +1 -0
  48. package/web/dist/assets/{activity-motion-BKEnbaU3.js → activity-motion-BraTC90V.js} +1 -1
  49. package/web/dist/assets/{activity-route-BktC7K27.js → activity-route-BxxLXnNb.js} +1 -1
  50. package/web/dist/assets/agent-config-section-iEj2kh_m.js +7 -0
  51. package/web/dist/assets/{agent-defaults-section-Bja_7urR.js → agent-defaults-section-CV2XEvs5.js} +1 -1
  52. package/web/dist/assets/{appearance-DCnUfFut.js → appearance-DEmDeQ3l.js} +1 -1
  53. package/web/dist/assets/{archive-on-merge-field-B0qWUHNs.js → archive-on-merge-field-BkwRlcuT.js} +1 -1
  54. package/web/dist/assets/attention-ILOaW2-t.js +1 -0
  55. package/web/dist/assets/automations-route-OZkTyuRX.js +2 -0
  56. package/web/dist/assets/{commit-list-BWK9da82.js → commit-list-PAtV8gyX.js} +1 -1
  57. package/web/dist/assets/{diff-BVH_RWBz.js → diff-DQk0ICL-.js} +2 -2
  58. package/web/dist/assets/{diff-controls-DuDm8Ywc.js → diff-controls-Dd5I6mOy.js} +1 -1
  59. package/web/dist/assets/{diff-view-CGSmQHjf.js → diff-view-B3e1YF2x.js} +1 -1
  60. package/web/dist/assets/discard-changes-dialog-BoWRfvhX.js +1 -0
  61. package/web/dist/assets/{file-preview-dLUnWpCG.js → file-preview-ifi0Ad8c.js} +1 -1
  62. package/web/dist/assets/{folder-browser-sASDxPXD.js → folder-browser-B_jJl4is.js} +1 -1
  63. package/web/dist/assets/{git-toolbar-C7waT1AJ.js → git-toolbar-D6uMb1LN.js} +1 -1
  64. package/web/dist/assets/{github-BkLTCoB7.js → github-A5MyAvjo.js} +1 -1
  65. package/web/dist/assets/{global-activity-route-CXm2vmR-.js → global-activity-route-BkuMl-UC.js} +1 -1
  66. package/web/dist/assets/index-9mlyFHVt.css +1 -0
  67. package/web/dist/assets/index-VBdx5s7U.js +21 -0
  68. package/web/dist/assets/{label-DF0V6WoC.js → label-DMC9mkYa.js} +1 -1
  69. package/web/dist/assets/{markdown-BODUip-p.js → markdown-CsP_OLyU.js} +1 -1
  70. package/web/dist/assets/{notifications-section-BoMwLKQj.js → notifications-section-KQJtCs-m.js} +1 -1
  71. package/web/dist/assets/{open-in-menu-D9VOIWhI.js → open-in-menu-VhRao_Jk.js} +1 -1
  72. package/web/dist/assets/{preview-pane-connected-BncD5HPr.js → preview-pane-connected-VjTQEceM.js} +3 -3
  73. package/web/dist/assets/{project-location-BKXBQJPm.js → project-location-DATkk1gA.js} +1 -1
  74. package/web/dist/assets/{project-router-p_FJwg-L.js → project-router-B9FTk0rB.js} +1 -1
  75. package/web/dist/assets/{projects-section-C2mLLBLO.js → projects-section-BhabP8vd.js} +1 -1
  76. package/web/dist/assets/{prompt-templates-section-CwWAsTg5.js → prompt-templates-section-AYpiCjmf.js} +1 -1
  77. package/web/dist/assets/{queries-C0l1puJe.js → queries-hzlF788B.js} +1 -1
  78. package/web/dist/assets/{reference-chip--9aRttZG.js → reference-chip-Dgo5aKeb.js} +1 -1
  79. package/web/dist/assets/{remote-settings-notice-B9h38exH.js → remote-settings-notice-C3iWEGmH.js} +1 -1
  80. package/web/dist/assets/repo-git-C01PFB-E.js +1 -0
  81. package/web/dist/assets/{report-reader-B7knRXaW.js → report-reader-nz3V3Lz7.js} +1 -1
  82. package/web/dist/assets/{report-selection-DQsrMoxl.js → report-selection-C-2DJb8L.js} +1 -1
  83. package/web/dist/assets/{reports-Dpn_dl7x.js → reports-DtZK4jOB.js} +1 -1
  84. package/web/dist/assets/{resources-section-BTRVTMVx.js → resources-section-BRzB_Bhb.js} +1 -1
  85. package/web/dist/assets/review-panel-DHJjHeaB.js +11 -0
  86. package/web/dist/assets/{run-detail-refresh-DyeLywhA.js → run-detail-refresh-Ye2jcT7n.js} +1 -1
  87. package/web/dist/assets/run-header-CSijv-YH.js +2 -0
  88. package/web/dist/assets/{select-B_nJiiFA.js → select-DlNVtWqZ.js} +1 -1
  89. package/web/dist/assets/{session-context-section-CaYkntsJ.js → session-context-section-Dv1cDixc.js} +2 -2
  90. package/web/dist/assets/{settings-agent-picker-Dl49O0Uz.js → settings-agent-picker-MdqbXV9H.js} +1 -1
  91. package/web/dist/assets/settings-shell-CjvGzEXE.js +1 -0
  92. package/web/dist/assets/{sidebar-section-bs9nIVDs.js → sidebar-section-DZuA4Izw.js} +1 -1
  93. package/web/dist/assets/{skills-B9orSgbp.js → skills-t0jRn0UI.js} +1 -1
  94. package/web/dist/assets/{tab-link-9ky9_HfJ.js → tab-link-BlZX-nKP.js} +1 -1
  95. package/web/dist/assets/{task-changes-CXTuG2Cn.js → task-changes-BNpDXPcl.js} +1 -1
  96. package/web/dist/assets/{task-commits-B2u2A-CY.js → task-commits-DPP79bjM.js} +1 -1
  97. package/web/dist/assets/{task-file-scope-Xr7UxjvR.js → task-file-scope-BpAU1GLy.js} +1 -1
  98. package/web/dist/assets/{task-files-BJnVrRlr.js → task-files-CcXwu4EQ.js} +1 -1
  99. package/web/dist/assets/task-github-item-DMFboxqX.js +1 -0
  100. package/web/dist/assets/{task-groups-DDxVSOHs.js → task-groups-DD46syqv.js} +1 -1
  101. package/web/dist/assets/task-thread-CoRkm48o.js +2 -0
  102. package/web/dist/assets/tasks-table-D17JLOhe.js +1 -0
  103. package/web/dist/assets/thread-state-BNR1qG2X.js +4 -0
  104. package/web/dist/assets/toaster-fWyfEGWF.js +4 -0
  105. package/web/dist/assets/{use-hand-to-agent-state-BCjGdF1N.js → use-hand-to-agent-state-BFEdVZQu.js} +1 -1
  106. package/web/dist/assets/workflows-D9I4QGot.js +7 -0
  107. package/web/dist/assets/{workspace-tools-CW9ltpbo.js → workspace-tools-Jy35o1XD.js} +1 -1
  108. package/web/dist/assets/{worktrees-section-DleqD_YR.js → worktrees-section-DjWQgjF3.js} +4 -4
  109. package/web/dist/index.html +14 -14
  110. package/web/dist/assets/accounts-section-COJzKqsN.js +0 -1
  111. package/web/dist/assets/agent-config-section-CUbXvXBE.js +0 -7
  112. package/web/dist/assets/attention-D3JmzDQv.js +0 -1
  113. package/web/dist/assets/automations-route-BUrEq0VH.js +0 -2
  114. package/web/dist/assets/index-CDd7AdAu.js +0 -21
  115. package/web/dist/assets/index-DNgBNd8o.css +0 -1
  116. package/web/dist/assets/repo-git-CgQA2pWS.js +0 -1
  117. package/web/dist/assets/review-panel-CuPvmcQp.js +0 -11
  118. package/web/dist/assets/run-header-UEj20eIu.js +0 -2
  119. package/web/dist/assets/settings-shell-DZOsC9Iv.js +0 -1
  120. package/web/dist/assets/task-github-item-DiU77rbk.js +0 -1
  121. package/web/dist/assets/task-thread-CWZI9Pb7.js +0 -2
  122. package/web/dist/assets/tasks-table-aF1_yUcS.js +0 -1
  123. package/web/dist/assets/thread-state-Bfa3qy5W.js +0 -4
  124. package/web/dist/assets/toaster-BYPWDBoi.js +0 -4
  125. package/web/dist/assets/workflows-Crhe2aKn.js +0 -7
@@ -0,0 +1,7 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{t as r}from"./utils-DSMR_WLb.js";import{A as i,Jt as a,Wt as o,dn as s,k as c}from"./queries-hzlF788B.js";import{A as l,Fn as u,hi as d,k as f,n as p,p as ee,u as te}from"./toaster-fWyfEGWF.js";import{h as m}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{J as ne,L as h,S as g,X as _,at as re,b as ie,c as ae,ft as oe,i as v,l as se,lt as y,n as ce,ot as le,st as b,tt as ue,v as x}from"./design-icons-CzEoMH9c.js";import{t as S}from"./button-B7MKxYjT.js";import{i as C,o as w,r as de,s as T,t as E}from"./dialog-B531GGAo.js";import{i as D,l as fe,o as pe}from"./skills-pM_PouEs.js";import{d as me,l as he,s as ge}from"./page-shell-7pLJMOgh.js";import{t as _e}from"./centered-state-V15AR_qo.js";import{Gt as O,Ht as k,Jt as ve,Kt as A,Qn as j,Ut as M,Wt as N,Yt as P,mn as F,qt as I,w as ye}from"./index-VBdx5s7U.js";import{_ as L,a as be,c as xe,f as Se,g as Ce,h as we,i as Te,m as R,n as Ee,o as De,p as Oe,r as z,t as ke,u as Ae}from"./sortable.esm-CAVTYaA3.js";import{t as B}from"./textarea-vJt9undk.js";import{t as je}from"./discard-changes-dialog-BoWRfvhX.js";var V=e(t(),1);function H(e){let t=[];for(let n of e){if(n.kind===`plugin`||n.command||!n.skill||n.prompt!==void 0&&n.prompt!==`{{task}}`||n.name!==void 0&&n.name!==n.skill||n.timeoutMs!==void 0||n.model||n.effort!==void 0||n.runner||n.agentProfile||n.allowedTools||n.bashAllowlist||n.onFail)return null;t.push(n.skill)}return t.length?t:null}function Me(e,t){let n=new Set(t.map(e=>e.id)),r=e;for(let t=2;n.has(r);t++)r=`${e}-${t}`;return{id:r,name:e,skill:e,prompt:`{{task}}`}}function Ne(e,t,n){let r=[...e];return r.splice(Math.max(0,Math.min(n,r.length)),0,t),r}function Pe(e,t,n){if(t===n||t<0||t>=e.length||n<0||n>=e.length)return[...e];let r=[...e],[i]=r.splice(t,1);return i===void 0?[...e]:(r.splice(n,0,i),r)}function Fe(e,t){return e.filter((e,n)=>n!==t)}function U(e){let t=String(e),n=/^[A-Za-z0-9._][A-Za-z0-9 ._/-]*$/.test(t)&&!t.endsWith(` `),r=/^(true|false|yes|no|on|off|null|~)$/i.test(t)||/^[-+.]?\d/.test(t);return n&&!r?t:JSON.stringify(t)}function W(e,t,n){let r=` `.repeat(n);return t.includes(`
2
+ `)?[`${r}${e}: |`,...t.split(`
3
+ `).map(e=>`${r} ${e}`)]:[`${r}${e}: ${U(t)}`]}function G(e){let t=[];return e.name&&e.name!==e.id&&t.push(` name: ${U(e.name)}`),e.skill&&t.push(` skill: ${U(e.skill)}`),t}function Ie(e){let t=[];return e.model&&t.push(` model: ${U(e.model)}`),e.timeoutMs!==void 0&&t.push(` timeoutMs: ${e.timeoutMs}`),e.effort!==void 0&&t.push(` effort: ${U(e.effort)}`),e.runner&&t.push(` runner: ${U(e.runner)}`),e.agentProfile&&t.push(` agentProfile: ${U(e.agentProfile)}`),t}function Le(e){let t=[];return e.allowedTools&&t.push(` allowedTools: [${e.allowedTools.map(U).join(`, `)}]`),e.bashAllowlist&&t.push(` bashAllowlist: [${e.bashAllowlist.map(U).join(`, `)}]`),t}function K(e){return e.onFail?[` onFail:`,` retry: ${U(e.onFail.retry)}`,` max: ${e.onFail.max??2}`]:[]}function q(e){return[` - id: ${U(e.id)}`,...G(e),...e.prompt?W(`prompt`,e.prompt,4):[],...e.kind===`plugin`?[` kind: plugin`,` pluginKind: ${U(e.pluginKind)}`,...e.config===void 0?[]:[` config: ${JSON.stringify(e.config)}`]]:[],...Ie(e),...Le(e),...e.command?W(`command`,e.command,4):[],...K(e)]}function Re(e,t,n){let r=[`name: ${U(e.trim()||`my-workflow`)}`];t.trim()&&r.push(...W(`description`,t.trim(),0));let i=H(n);if(i){r.push(`skills:`);for(let e of i)r.push(` - ${U(e)}`)}else if(n.length){r.push(`steps:`);for(let e of n)r.push(...q(e))}else r.push(`skills: []`);return`${r.join(`
4
+ `)}\n`}function ze(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`chain`}function Be(e){let t=H(e)?`skill`:`step`;return`${e.length} ${t}${e.length===1?``:`s`}`}function Ve(e,t){let n=new Set,r=[];for(let t of e.steps.slice(0,8)){let e=t.id||`step`,i=e;for(let t=2;n.has(i);t++)i=`${e}-${t}`;n.add(i),r.push({...t,id:i})}return{name:e.name?.trim()||t,steps:r}}function He(e,t,n){let r=H(n);return{name:e.trim(),...t.trim()?{description:t.trim()}:{},...r?{skills:r}:{steps:[...n]}}}var J=n();function Ue({workflows:e,draft:t,trimmedName:n,nameRef:r,onDraft:i,onLoadWorkflow:a,renamedFrom:o}){return(0,J.jsxs)(`section`,{"data-slot":`wb-metadata`,className:`grid min-w-0 grid-cols-1 gap-3 @xl:grid-cols-2 @4xl:grid-cols-[minmax(180px,240px)_minmax(200px,280px)_minmax(0,1fr)] @xl:items-start`,children:[(0,J.jsxs)(`div`,{"data-slot":`wb-load`,className:`flex min-w-0 flex-col gap-1.5`,children:[(0,J.jsx)(`label`,{htmlFor:`workflow-load`,className:`text-xs font-medium text-foreground`,children:`Load an existing workflow`}),(0,J.jsxs)(`div`,{className:`relative flex min-w-0 items-center`,children:[(0,J.jsxs)(`select`,{id:`workflow-load`,value:e.some(e=>e.name===n)?n:``,onChange:t=>{let n=e.find(e=>e.name===t.target.value);n&&a(n)},className:`h-10 w-full min-w-0 appearance-none rounded-lg border border-border bg-card pr-9 pl-3.5 text-xs font-medium text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:h-11`,children:[(0,J.jsx)(`option`,{value:``,disabled:!0,children:`Choose a workflow`}),e.map(e=>(0,J.jsx)(`option`,{value:e.name,"data-slot":`wb-load-option`,"data-name":e.name,children:e.name},e.name))]}),(0,J.jsx)(se,{"aria-hidden":`true`,className:`pointer-events-none absolute right-3 size-4 text-muted-foreground`})]})]}),(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,J.jsx)(`label`,{htmlFor:`workflow-name`,className:`text-xs font-medium text-foreground`,children:`Workflow name`}),(0,J.jsx)(j,{id:`workflow-name`,ref:r,"data-slot":`wb-name`,"aria-label":`Workflow name`,spellCheck:!1,value:t.name,"aria-describedby":o===void 0?void 0:`workflow-rename-note`,onChange:e=>i({...t,name:e.target.value}),className:`h-10 bg-card text-sm max-md:h-11`}),(0,J.jsx)(`p`,{id:`workflow-rename-note`,"aria-live":`polite`,className:`text-xs text-muted-foreground empty:hidden`,children:o===void 0?null:(0,J.jsxs)(`span`,{"data-slot":`wb-rename-note`,children:[`Saving creates a new workflow “`,n,`”. “`,o,`” stays as it is.`]})})]}),(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5 @xl:col-span-2 @4xl:col-span-1`,children:[(0,J.jsx)(`label`,{htmlFor:`workflow-description`,className:`text-xs font-medium text-foreground`,children:`Description`}),(0,J.jsx)(B,{id:`workflow-description`,"data-slot":`wb-description`,"aria-label":`Description`,rows:1,value:t.description,onChange:e=>i({...t,description:e.target.value}),className:`min-h-10 bg-card px-3 py-2 text-sm max-md:min-h-11`})]})]})}function We({savedFile:e,autoOpen:t,onImportToggle:n,onExport:r,onAutoToggle:i,onDeleteRequest:a}){return(0,J.jsxs)(`div`,{"data-slot":`wb-actions`,className:`grid grid-cols-[max-content_max-content] items-center justify-start gap-2 sm:flex sm:flex-wrap [&_button]:min-h-11 [&_button]:border [&_button]:border-border [&_button]:bg-card`,children:[(0,J.jsxs)(S,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`wb-import`,className:`col-span-2 justify-self-start`,onClick:n,children:[(0,J.jsx)(b,{"aria-hidden":`true`,className:`size-3`}),`Import`]}),(0,J.jsxs)(S,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`wb-export`,className:`col-span-2 justify-self-start`,title:`Download workflow.yaml`,onClick:r,children:[(0,J.jsx)(ie,{"aria-hidden":`true`,className:`size-3`}),`Export`]}),(0,J.jsxs)(S,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`wb-auto`,"aria-expanded":t,"aria-describedby":`wb-auto-hint`,title:`Auto-build: describe the chain in words and an agent drafts its steps for you to review`,onClick:i,children:[(0,J.jsx)(y,{"aria-hidden":`true`,className:`size-3`}),`Auto-build`]}),(0,J.jsx)(`span`,{id:`wb-auto-hint`,className:`sr-only`,children:`Describe the chain in words and an agent drafts its steps for you to review.`}),e?(0,J.jsxs)(S,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`wb-delete`,className:`relative text-danger hover:text-danger sm:ms-3 sm:before:absolute sm:before:-start-[13px] sm:before:top-1/2 sm:before:h-5 sm:before:w-px sm:before:-translate-y-1/2 sm:before:bg-border sm:before:content-['']`,title:`Delete the saved workflow file`,onClick:a,children:[(0,J.jsx)(re,{"aria-hidden":`true`,className:`size-3`}),`Delete`]}):null]})}function Ge({text:e,onTextChange:t,pending:n,onRun:r,onCancel:i}){return(0,J.jsxs)(`div`,{"data-slot":`wb-auto-panel`,className:`rounded-xl border border-border bg-card p-5 [&_button]:min-h-11`,children:[(0,J.jsx)(`h2`,{className:`text-lg font-normal`,children:`Build a chain from a prompt`}),(0,J.jsx)(`p`,{className:`mt-4 text-[13px] leading-relaxed text-muted-foreground`,children:`Describe the outcome. An agent proposes a title and ordered skill/check steps. Review the result, edit it, then Save.`}),(0,J.jsx)(B,{"data-slot":`wb-auto-text`,"aria-label":`Describe the chain to build`,rows:3,autoFocus:!0,placeholder:`e.g. Fix the bug, run the tests, then review the diff for regressions.`,value:e,onChange:e=>t(e.target.value),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),r())},className:`mt-4 min-h-[108px] bg-background p-4 text-sm`}),(0,J.jsxs)(`div`,{className:`mt-3 flex items-center gap-1.5`,children:[(0,J.jsxs)(S,{type:`button`,variant:`primary`,size:`sm`,"data-slot":`wb-auto-run`,disabled:n||e.trim()===``,onClick:r,children:[(0,J.jsx)(y,{"aria-hidden":`true`,className:`size-3`}),n?`Building…`:`Build chain`]}),(0,J.jsxs)(S,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`wb-auto-cancel`,onClick:i,children:[(0,J.jsx)(oe,{"aria-hidden":`true`,className:`size-4`}),`Cancel`]})]}),(0,J.jsx)(`p`,{className:`mt-4 text-xs text-muted-foreground`,children:`Creates an editable draft. Review the generated name and steps before saving.`})]})}function Ke({open:e,onOpenChange:t,text:n,onTextChange:r,error:i,pending:a,onRun:o,onCancel:s}){return(0,J.jsx)(E,{open:e,onOpenChange:t,children:(0,J.jsxs)(de,{showCloseButton:!1,"data-slot":`wb-import-panel`,className:`max-md:translate-x-0 max-md:translate-y-0 sm:max-w-[660px] rounded-xl border border-border bg-card p-5 [&_button]:min-h-11`,children:[(0,J.jsx)(T,{className:`text-xl font-normal`,children:`Import workflow YAML`}),(0,J.jsx)(C,{className:`sr-only`,children:`Paste a portable workflow definition to import.`}),(0,J.jsx)(B,{"data-slot":`wb-import-text`,"aria-label":`Workflow YAML to import`,rows:4,spellCheck:!1,placeholder:`name: my-flow
5
+ skills:
6
+ - test-conventions
7
+ - commit-style`,value:n,onChange:e=>r(e.target.value),className:`mt-4 min-h-[124px] bg-background p-4 font-mono text-[13px] leading-relaxed`}),(0,J.jsx)(`p`,{className:`mt-4 text-[13px] text-muted-foreground`,children:`Paste a portable workflow definition. Imported steps appear in execution order.`}),i===``?null:(0,J.jsx)(`p`,{"data-slot":`wb-import-error`,role:`alert`,className:`mt-2 text-xs text-danger`,children:i}),(0,J.jsxs)(`div`,{className:`mt-3 flex items-center gap-1.5`,children:[(0,J.jsx)(S,{type:`button`,variant:`primary`,size:`sm`,"data-slot":`wb-import-run`,disabled:a,onClick:o,children:`Import`}),(0,J.jsx)(S,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`wb-import-cancel`,onClick:s,children:`Cancel`})]})]})})}function qe({paletteSkills:e,query:t,onQueryChange:n,error:r,inFlow:i,onAdd:a,yaml:o}){return(0,J.jsxs)(`aside`,{"data-slot":`wb-aside`,className:`min-w-0 rounded-xl border border-border bg-card p-5`,children:[(0,J.jsx)(`h2`,{className:`text-[16px] font-semibold`,children:`Available skills`}),(0,J.jsxs)(`div`,{className:`sw-search relative mt-4`,children:[(0,J.jsx)(_,{"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3.5 size-4 text-muted-foreground`}),(0,J.jsx)(j,{"data-slot":`wb-filter`,placeholder:`Find a skill…`,"aria-label":`Filter skills`,value:t,onChange:e=>n(e.target.value),className:`h-11 pl-9 text-xs`})]}),(0,J.jsx)(it,{skills:e,query:t,error:r,inFlow:i,onAdd:a}),(0,J.jsx)(`h3`,{className:`mt-5 text-sm font-semibold`,children:`workflow.yaml`}),(0,J.jsx)(`p`,{className:`mt-3 text-xs leading-relaxed text-muted-foreground`,children:`Export the workflow to use this chain in another project.`}),(0,J.jsxs)(`details`,{className:`mt-4 min-w-0`,children:[(0,J.jsxs)(`summary`,{"data-slot":`wb-yaml-toggle`,className:`inline-flex min-h-[44px] cursor-pointer items-center rounded-lg border border-border px-3 text-xs font-medium focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,J.jsx)(g,{"aria-hidden":`true`,className:`mr-2 size-4`}),`View YAML`]}),(0,J.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,J.jsx)(ot,{yaml:o})}),(0,J.jsx)(`pre`,{"data-slot":`wb-yaml`,className:`mt-2 max-h-96 overflow-auto rounded-lg border border-border bg-background p-3 font-mono text-xs leading-relaxed whitespace-pre text-muted-foreground`,children:o})]})]})}function Y({dragging:e,steps:t,skills:n}){return e?.type===`palette`?(0,J.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border bg-card px-2.5 py-1.5 font-mono text-[13px] font-medium shadow-md`,children:[(0,J.jsx)(ue,{"aria-hidden":`true`,className:`size-3.5 text-link-foreground`}),e.skill]}):e?.type===`step`?(0,J.jsx)(rt,{step:e.step,index:t.findIndex(t=>t.id===e.step.id),skills:n,overlay:!0}):null}function Je({open:e,onOpenChange:t,query:n,onQueryChange:r,matches:i,skillsCount:a,error:o,selectedSkill:s,onSelectSkill:c,stepsCount:l,onCloseAutoFocus:u,onCancel:d,onAdd:f}){return(0,J.jsx)(E,{open:e,onOpenChange:t,children:(0,J.jsxs)(de,{"data-slot":`wb-add-dialog`,onCloseAutoFocus:u,className:`max-h-[85dvh] overflow-y-auto sm:max-w-[660px] [&_button]:min-h-11`,children:[(0,J.jsxs)(w,{children:[(0,J.jsx)(T,{className:`text-xl font-normal`,children:`Add step`}),(0,J.jsx)(C,{className:`sr-only`,children:`Choose a skill to append to this workflow.`})]}),(0,J.jsx)(j,{"aria-label":`Filter skills`,placeholder:`Filter skills…`,value:n,onChange:e=>r(e.target.value)}),o===null?(0,J.jsxs)(`div`,{role:`radiogroup`,"aria-label":`Available skills`,className:`grid max-h-80 gap-2 overflow-y-auto`,children:[i.map(e=>(0,J.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 rounded-lg py-2 has-[:checked]:bg-accent-strong/10 has-[:focus-visible]:outline-2`,children:[(0,J.jsx)(`input`,{type:`radio`,name:`workflow-add-skill`,className:`sr-only`,value:e.id,checked:s===e.id,onChange:()=>c(e.id)}),(0,J.jsxs)(`span`,{className:`min-w-0 break-words text-sm`,children:[(0,J.jsx)(`span`,{className:`block`,children:e.name}),(0,J.jsx)(`span`,{className:`mt-2 block text-xs text-muted-foreground`,children:e.description}),e.path?(0,J.jsx)(`span`,{className:`block break-all text-xs`,children:e.path}):null]})]},JSON.stringify([e.id,e.path]))),i.length===0?(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:a===0?`No skills available in this project.`:`No matching skills.`}):null]}):(0,J.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[`Could not load skills: `,o]}),n.trim()&&!i.some(e=>e.id===n.trim())?(0,J.jsxs)(S,{onClick:()=>c(n.trim()),children:[`Use skill id “`,n.trim(),`” (unchecked)`]}):null,(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,J.jsx)(S,{variant:`outline`,onClick:d,children:`Cancel`}),(0,J.jsx)(S,{variant:`primary`,disabled:!s||l>=8,onClick:()=>{s&&f(s)},children:`Add selected skill`})]}),(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Append the selected skill, then reorder it in the existing canvas.`}),l>=8?(0,J.jsxs)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:[`A workflow can contain up to `,8,` steps. Remove a step before adding another.`]}):null]})})}function Ye({trimmedName:e,savedFile:t,overwriteOpen:n,onOverwriteDismiss:r,deleteOpen:i,onDeleteDismiss:a,onOverwrite:o,onDelete:s}){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(k,{open:n,onOpenChange:e=>!e&&r(),children:(0,J.jsxs)(O,{"data-slot":`wb-overwrite-dialog`,className:`sw-workflow-confirm sm:max-w-[660px]`,children:[(0,J.jsxs)(ve,{children:[(0,J.jsxs)(P,{children:[`“`,e,`” already exists`]}),(0,J.jsx)(A,{children:`Saving overwrites the existing workflow file. There is no undo.`})]}),(0,J.jsxs)(I,{children:[(0,J.jsx)(N,{children:`Keep the file`}),(0,J.jsx)(M,{"data-slot":`wb-overwrite-confirm`,className:`bg-danger text-danger-foreground`,onClick:o,children:`Overwrite`})]})]})}),(0,J.jsx)(k,{open:i,onOpenChange:e=>!e&&a(),children:(0,J.jsxs)(O,{"data-slot":`wb-delete-dialog`,className:`sw-workflow-confirm sm:max-w-[660px]`,children:[(0,J.jsxs)(ve,{children:[(0,J.jsxs)(P,{children:[`Delete workflow “`,e,`”?`]}),(0,J.jsxs)(A,{children:[`Removes `,t?.path?.split(`/`).pop()??`the saved file`,` from`,` `,(0,J.jsx)(`span`,{className:`font-mono`,children:`.ai/cezar/workflows/`}),`. There is no undo.`]})]}),(0,J.jsxs)(I,{children:[(0,J.jsx)(N,{children:`Keep the file`}),(0,J.jsx)(M,{"data-slot":`wb-delete-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:s,children:`Delete workflow`})]})]})})]})}function X(e){return e.name??e.skill??e.id}function Z(e){return e.skill&&e.name&&e.name!==e.skill?e.skill:void 0}function Q(e){return e.prompt?.trim()===`{{task}}`?void 0:e.prompt?.trim()}function Xe(e){let t=e.onFail?` — on fail retry from "${e.onFail.retry}" (×${e.onFail.max??2})`:``;return`$ ${e.command}${t}`}function Ze(e,t){return Q(e)||t?.description||`Not listed by this runner and account. Step open will check the skill id.`}function Qe(e,t){return e.command?Xe(e):e.skill?Ze(e,t):e.prompt??``}function $e(e,t){return e.skill&&!t?`unknown`:null}function et(e){return e.command?`Command step${e.onFail?` · Retry ×${e.onFail.max??2}`:``}`:e.skill?`Skill step`:`Prompt step`}function tt({index:e,title:t,badge:n,onRemove:i,gripProps:a}){return(0,J.jsxs)(`div`,{"data-slot":`wb-step-heading`,className:`flex min-w-0 items-center gap-2.5`,children:[(0,J.jsxs)(`button`,{type:`button`,"data-slot":`wb-step-grip`,"aria-label":`Reorder step ${e+1}: ${t}`,className:`group/grip inline-flex h-[26px] shrink-0 cursor-grab items-center justify-center gap-0.5 rounded-md text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 active:cursor-grabbing`,...a,children:[(0,J.jsx)(h,{"aria-hidden":`true`,className:`size-4 opacity-70 transition-opacity group-hover/grip:opacity-100`}),(0,J.jsx)(`span`,{className:`rounded bg-accent-strong/10 px-2 py-1 font-mono text-[12px] text-link-foreground`,children:String(e+1).padStart(2,`0`)})]}),(0,J.jsx)(`div`,{className:`min-w-0 flex-1 break-words text-sm font-medium [overflow-wrap:anywhere]`,children:t}),n?(0,J.jsx)(`span`,{"data-slot":`wb-step-badge`,className:r(`shrink-0 rounded-full border px-2 py-px font-mono text-xs`,n===`unknown`&&`border-danger/35 text-danger`),children:n}):null,i?(0,J.jsxs)(S,{"data-slot":`wb-step-remove`,variant:`ghost`,size:`sm`,className:`shrink-0`,"aria-label":`Remove step ${e+1}: ${t}`,onClick:i,children:[(0,J.jsx)(re,{"aria-hidden":`true`}),` Remove`]}):null]})}function nt({index:e,onMoveUp:t,onMoveDown:n}){return(0,J.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 @min-[900px]:hidden`,children:[(0,J.jsxs)(S,{variant:`outline`,size:`sm`,className:`min-h-11`,"aria-label":`Move step ${e+1} up`,disabled:!t,onClick:t,children:[(0,J.jsx)(v,{"aria-hidden":`true`,className:`size-4`}),`Move up`]}),(0,J.jsxs)(S,{variant:`outline`,size:`sm`,className:`min-h-11`,"aria-label":`Move step ${e+1} down`,disabled:!n,onClick:n,children:[(0,J.jsx)(ce,{"aria-hidden":`true`,className:`size-4`}),`Move down`]})]})}function rt({step:e,index:t,skills:n,onRemove:i,gripProps:a,onMoveUp:o,onMoveDown:s,overlay:c=!1}){let l=n.find(t=>t.id===e.skill),u=X(e),d=Qe(e,l),f=$e(e,l);return(0,J.jsxs)(`div`,{"data-slot":`wb-step`,"data-id":e.id,"data-index":t,className:r(`rounded-lg border border-border bg-background p-4`,c&&`shadow-md`),children:[(0,J.jsx)(tt,{index:t,title:u,badge:f,onRemove:i,gripProps:a}),d?(0,J.jsx)(`div`,{"data-slot":`wb-step-summary`,className:`mt-1.5 break-words text-xs leading-relaxed text-muted-foreground`,children:d}):null,(0,J.jsx)(`p`,{"data-slot":`wb-step-kind`,className:`mt-1.5 text-xs text-link-foreground`,children:et(e)}),Z(e)?(0,J.jsx)(`p`,{"data-slot":`wb-step-skill`,className:`mt-1 font-mono text-xs text-muted-foreground`,children:Z(e)}):null,c?null:(0,J.jsx)(nt,{index:t,onMoveUp:o,onMoveDown:s})]})}function it({skills:e,query:t,error:n,inFlow:r,onAdd:i}){if(n!==null)return(0,J.jsxs)(`p`,{"data-slot":`wb-palette`,className:`mt-2.5 text-xs text-danger`,children:[`Could not load skills: `,n]});let a=fe(e,t);return(0,J.jsx)(`div`,{"data-slot":`wb-palette`,className:`mt-2.5 flex flex-col gap-1`,children:a.length>0?a.map(e=>(0,J.jsx)(at,{skill:e,inFlow:r.has(e.id),onAdd:i},JSON.stringify([e.id,e.path]))):(0,J.jsx)(`p`,{className:`py-1 text-xs leading-relaxed text-soft-foreground`,children:e.length>0?`No skills match.`:`This runner reports no skills.`})})}function at({skill:e,inFlow:t,onAdd:n}){let{listeners:i,setNodeRef:a,isDragging:o}=Oe({id:`palette:${JSON.stringify([e.id,e.path])}`,data:{type:`palette`,skill:e.id}});return(0,J.jsxs)(`div`,{ref:a,"data-slot":`wb-skill`,"data-skill":e.id,"data-in-flow":t||void 0,title:e.description??``,className:r(`flex min-h-11 cursor-grab items-center gap-2 rounded-md py-1 transition-colors hover:bg-muted`,o&&`opacity-40`),...i,children:[(0,J.jsxs)(`span`,{className:r(`min-w-0 flex-1 break-words text-xs`,D(e)?`font-semibold text-foreground`:`font-medium text-muted-foreground`),children:[e.name,e.path?(0,J.jsx)(`span`,{className:`block break-all text-xs text-soft-foreground`,children:e.path}):null]}),(0,J.jsx)(`button`,{type:`button`,"data-slot":`wb-skill-add`,"aria-label":`Add ${e.name} to the flow`,title:`Add to the flow`,onClick:()=>n(e.id),className:`inline-flex size-11 shrink-0 items-center justify-center rounded-md text-link-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50`,children:(0,J.jsx)(ne,{"aria-hidden":`true`,className:`size-3.5`})})]})}function ot({yaml:e}){let[t,n]=(0,V.useState)(!1),r=(0,V.useRef)(null);return(0,V.useEffect)(()=>()=>{r.current!==null&&clearTimeout(r.current)},[]),(0,J.jsx)(`button`,{type:`button`,"data-slot":`wb-copy`,title:`Copy the YAML`,onClick:()=>{navigator.clipboard?.writeText(e).catch(()=>{}),n(!0),r.current!==null&&clearTimeout(r.current),r.current=setTimeout(()=>n(!1),1600)},className:`flex items-center gap-1 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground`,children:t?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(ae,{"aria-hidden":`true`,className:`size-3 text-success`}),`Copied`]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(x,{"aria-hidden":`true`,className:`size-3`}),`Copy`]})})}function st(e,t){return{yaml:Re(e.name,e.description,e.steps),loadedName:t}}function ct(){let[e,t]=(0,V.useState)(null),[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(null),o=e!==null&&n!==null&&st(e,void 0).yaml!==n.yaml;F(o);let s=(e,n)=>{t(e),r(st(e,n))};return{draft:e,setDraft:t,dirty:o,replace:s,guardedReplace:(e,t)=>{o?a({draft:e,loadedName:t}):s(e,t)},sending:()=>e===null?null:st(e,e.name.trim()),saved:e=>{e&&r(e)},renamedFrom:e=>{let t=n?.loadedName;if(!(t===void 0||e===``))return ze(e)===ze(t)?void 0:t},discardOpen:i!==null,keepEditing:()=>a(null),discard:()=>{i&&s(i.draft,i.loadedName),a(null)}}}var lt=`wb-canvas`;function $(){return{name:`my-workflow`,description:``,steps:[]}}function ut(e){return{name:e.name,description:e.description??``,steps:structuredClone(e.steps??[])}}function dt(){let{name:e}=m();return(0,J.jsx)(ft,{routeName:e},e??``)}function ft({routeName:e}){let t=i(),n=a(),r=c(),m=d(),h=ct(),{draft:g,setDraft:_}=h,[re,ie]=(0,V.useState)(``),[oe,v]=(0,V.useState)(!1),[se,y]=(0,V.useState)(``),[ce,b]=(0,V.useState)(null),[ue,x]=(0,V.useState)(!1),[C,w]=(0,V.useState)(``),[de,T]=(0,V.useState)(``),[E,D]=(0,V.useState)(!1),[O,k]=(0,V.useState)(``),[ve,A]=(0,V.useState)(!1),[j,M]=(0,V.useState)(!1),N=(0,V.useId)(),[P,F]=(0,V.useState)(null),[I,L]=(0,V.useState)(null),Te=(0,V.useRef)(null),R=(0,V.useRef)(null),Oe=t.data?.workflows??[],z=n.data??[],ke=pe(z,r.data?.skillUsage),B=fe(ke,se,r.data?.skillUsage);(0,V.useEffect)(()=>{if(g!==null||t.data===void 0)return;let n=t.data.workflows,r=(e?n.find(t=>t.name===e):void 0)??n.find(e=>e.source===`file`);h.replace(r?ut(r):$(),r?.name)},[g,t.data,e,h.replace]);let H=e=>_(t=>t===null?t:{...t,steps:e}),U=s({mutationFn:e=>f(e),onSuccess:e=>{_({name:e.name,description:e.description??``,steps:e.steps}),x(!1),w(``),T(``),p(`Imported "${e.name}" — review, then Save.`)},onError:e=>T(e.message)}),W=s({mutationFn:e=>l(e),onSuccess:e=>{_(t=>{let n=t??$(),{name:r,steps:i}=Ve(e,n.name);return{...n,name:r,steps:i}}),D(!1),k(``),p(e.fallback?`Planner unavailable — added a single step. Edit, then Save.`:`Built "${e.name??g?.name??`workflow`}" — review, tweak, then Save.`,e.fallback?{tone:`danger`}:void 0)},onError:e=>p(e instanceof Error?e.message:String(e),{tone:`danger`})}),G=s({onMutate:()=>h.sending(),mutationFn:e=>te({...He(g?.name??``,g?.description??``,g?.steps??[]),...e?{overwrite:!0}:{}}),onSuccess:(e,t,n)=>{A(!1),h.saved(n),p(`Saved — ${e.path.split(`/`).pop()??e.path}`),m.invalidateQueries({queryKey:o.workflows})},onError:e=>{e instanceof u&&e.exists===!0?A(!0):p(e instanceof Error?e.message:String(e),{tone:`danger`})}}),Ie=s({mutationFn:e=>ee(e),onSuccess:(e,t)=>{M(!1),p(`Deleted "${t}".`),h.replace($(),void 0),m.invalidateQueries({queryKey:o.workflows})},onError:e=>{M(!1),p(e instanceof Error?e.message:String(e),{tone:`danger`})}}),Le=Ce(we(Ae,{activationConstraint:{distance:4}}),we(xe,{coordinateGetter:Ee}));if(t.isError)return(0,J.jsx)(he,{route:`workflows`,density:`empty`,className:`@container`,children:(0,J.jsx)(_e,{icon:(0,J.jsx)(le,{}),tone:`danger`,title:`Could not load workflows`,subtitle:t.error.message})});if(g===null)return(0,J.jsx)(ye,{});let K=g.steps,q=g.name.trim(),Y=Oe.find(e=>e.name===q&&e.source===`file`),X=Re(g.name,g.description,K),Z=Y!==void 0&&Re(Y.name,Y.description??``,Y.steps??[])===X,Q=(e,t=K.length)=>{if(K.length>=8){p(`A workflow holds at most 8 steps.`,{tone:`danger`});return}H(Ne(K,Me(e,K),t))};return(0,J.jsxs)(he,{route:`workflows`,density:me(K.length),className:`@container`,header:{title:`Workflows`,subtitle:`Portable skill chains. Steps run from top to bottom.`,status:Z?(0,J.jsx)(`span`,{id:N,"data-slot":`wb-save-cue`,className:`whitespace-nowrap text-xs text-muted-foreground`,children:`No unsaved changes`}):void 0,secondaryActions:(0,J.jsxs)(ge,{type:`button`,variant:`outline`,"data-slot":`wb-new`,onClick:()=>h.guardedReplace($(),void 0),children:[(0,J.jsx)(ne,{"aria-hidden":`true`,className:`size-4`}),`New workflow`]}),primaryAction:(0,J.jsxs)(ge,{type:`button`,variant:`primary`,"data-slot":`wb-save`,disabled:G.isPending||Z,"aria-describedby":Z?N:void 0,onClick:()=>{if(q===``){Te.current?.focus();return}if(K.length===0){p(`Add at least one step first.`,{tone:`danger`});return}G.mutate(!1)},children:[(0,J.jsx)(ae,{"aria-hidden":`true`,className:`size-4`}),`Save workflow`]})},children:[(0,J.jsxs)(be,{sensors:Le,collisionDetection:Se,onDragStart:e=>{let t=e.active.data.current;F(t??null)},onDragOver:e=>{L(e.over?String(e.over.id):null)},onDragEnd:e=>{F(null),L(null);let{active:t,over:n}=e;if(n===null)return;let r=t.data.current;if(r?.type===`palette`){let e=n.id===lt?K.length:K.findIndex(e=>e.id===n.id);Q(r.skill,e===-1?K.length:e);return}if(n.id===t.id)return;let i=K.findIndex(e=>e.id===t.id),a=K.findIndex(e=>e.id===n.id);i!==-1&&a!==-1&&H(Pe(K,i,a))},onDragCancel:()=>{F(null),L(null)},children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4 pb-[calc(32px+env(safe-area-inset-bottom))]`,children:[(0,J.jsx)(Ue,{workflows:Oe,draft:g,trimmedName:q,nameRef:Te,onDraft:_,onLoadWorkflow:e=>h.guardedReplace(ut(e),e.name),renamedFrom:h.renamedFrom(q)}),(0,J.jsx)(We,{savedFile:Y,autoOpen:E,onImportToggle:()=>{T(``),D(!1),x(e=>!e)},onExport:()=>{let e=new Blob([X],{type:`text/yaml`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`${ze(g.name)}.yaml`,document.body.appendChild(n),n.click(),n.remove(),setTimeout(()=>URL.revokeObjectURL(t),1e3)},onAutoToggle:()=>{x(!1),D(e=>!e)},onDeleteRequest:()=>M(!0)}),E?(0,J.jsx)(Ge,{text:O,onTextChange:k,pending:W.isPending,onRun:()=>{let e=O.trim();e===``||W.isPending||W.mutate(e)},onCancel:()=>{D(!1),k(``)}}):null,(0,J.jsx)(Ke,{open:ue,onOpenChange:x,text:C,onTextChange:w,error:de,pending:U.isPending,onRun:()=>{let e=C.trim();e!==``&&U.mutate(e)},onCancel:()=>{x(!1),w(``),T(``)}}),(0,J.jsxs)(`div`,{className:`grid min-w-0 items-start gap-[22px] @min-[700px]:grid-cols-[minmax(0,1fr)_300px]`,children:[(0,J.jsxs)(`section`,{"data-slot":`wb-main`,className:`min-w-0 rounded-xl border border-border bg-card p-5`,children:[(0,J.jsxs)(`p`,{className:`text-xs text-muted-foreground`,title:`A workflow holds at most 8 steps`,children:[`Steps · `,K.length,` of `,8,` max`,(0,J.jsx)(`span`,{"data-slot":`wb-count`,className:`sr-only`,children:Be(K)})]}),(0,J.jsx)(pt,{steps:K,skills:z,dragging:P!==null,overId:I,activeStepId:P?.type===`step`?P.step.id:null,onRemove:e=>H(Fe(K,e)),onMove:(e,t)=>H(Pe(K,e,t))}),(0,J.jsxs)(S,{ref:R,variant:`outline`,className:`mt-4 min-h-11`,onClick:()=>{b(null),y(``),v(!0)},children:[(0,J.jsx)(ne,{"aria-hidden":`true`,className:`size-4`}),`Add step`]}),(0,J.jsxs)(`p`,{className:`mt-4 text-xs leading-relaxed text-muted-foreground`,children:[(0,J.jsx)(`span`,{className:`hidden @min-[900px]:inline`,children:`Drag to reorder. The agent follows this sequence from top to bottom.`}),(0,J.jsx)(`span`,{className:`@min-[900px]:hidden`,children:`Use Move up / Move down to reorder without dragging.`})]})]}),(0,J.jsx)(qe,{paletteSkills:ke,query:re,onQueryChange:ie,error:n.isError?n.error.message:null,inFlow:new Set(K.map(e=>e.skill).filter(e=>!!e)),onAdd:e=>Q(e),yaml:X})]})]}),(0,J.jsx)(De,{children:(0,J.jsx)(ht,{dragging:P,steps:K,skills:z})})]}),(0,J.jsx)(Je,{open:oe,onOpenChange:v,query:se,onQueryChange:y,matches:B,skillsCount:z.length,error:n.isError?n.error.message:null,selectedSkill:ce,onSelectSkill:b,stepsCount:K.length,onCloseAutoFocus:e=>{e.preventDefault(),R.current?.focus()},onCancel:()=>v(!1),onAdd:e=>{Q(e),v(!1)}}),(0,J.jsx)(Ye,{trimmedName:q,savedFile:Y,overwriteOpen:ve,onOverwriteDismiss:()=>A(!1),deleteOpen:j,onDeleteDismiss:()=>M(!1),onOverwrite:()=>G.mutate(!0),onDelete:()=>Ie.mutate(q)}),(0,J.jsx)(je,{open:h.discardOpen,subject:q===``?`this workflow`:`“${q}”`,onKeep:h.keepEditing,onDiscard:h.discard})]})}function pt({steps:e,skills:t,dragging:n,overId:i,activeStepId:a,onRemove:o,onMove:s}){let{setNodeRef:c,isOver:l}=R({id:lt}),u=n&&i===lt;return(0,J.jsx)(`div`,{ref:c,"data-slot":`wb-steps`,"data-dragging":n||void 0,className:r(`relative mt-3 rounded-lg transition-colors`,l?`border-accent-strong/60 bg-accent-strong/5`:`border-muted-foreground/25`),children:e.length===0?(0,J.jsx)(`p`,{className:r(`rounded-md px-3 py-10 text-center text-[13px] transition-colors`,l?`text-link-foreground`:`text-muted-foreground`),children:`Drop a skill here — or Import a workflow.yaml`}):(0,J.jsxs)(ke,{items:e.map(e=>e.id),strategy:Te,children:[(0,J.jsx)(`ol`,{className:`flex flex-col gap-2.5`,children:e.map((r,c)=>(0,J.jsx)(mt,{step:r,index:c,skills:t,dragging:n,insertBefore:n&&i===r.id&&a!==r.id,onRemove:()=>o(c),onMoveUp:c>0?()=>s(c,c-1):void 0,onMoveDown:c<e.length-1?()=>s(c,c+1):void 0},r.id))}),(0,J.jsx)(`div`,{"aria-hidden":`true`,className:r(`absolute inset-x-0 mt-1 h-[3px] rounded-full transition-colors`,u?`bg-accent-strong`:`bg-transparent`)})]})})}function mt({step:e,index:t,insertBefore:n,onRemove:i,onMoveUp:o,onMoveDown:s}){let c=a(e.runner,e.agentProfile),{attributes:l,listeners:u,setNodeRef:d,transform:f,transition:p,isDragging:ee}=z({id:e.id,data:{type:`step`,step:e}});return(0,J.jsxs)(`li`,{ref:d,style:{transform:L.Transform.toString(f),transition:p},className:r(`relative`,ee&&`opacity-40`),children:[n?(0,J.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`wb-drop-line`,className:`pointer-events-none absolute -top-[7px] right-0 left-0 h-[3px] rounded-full bg-accent-strong`}):null,(0,J.jsx)(rt,{step:e,index:t,skills:c.data??[],onRemove:i,onMoveUp:o,onMoveDown:s,gripProps:{...l,...u}})]})}function ht(e){let t=e.dragging?.type===`step`?e.dragging.step:void 0,n=a(t?.runner,t?.agentProfile,!!t);return(0,J.jsx)(Y,{...e,skills:t?n.data??[]:e.skills})}export{dt as WorkflowsRoute};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Qt as r,St as i,Vt as a,rn as o,yt as s}from"./queries-C0l1puJe.js";import{n as c}from"./toaster-BYPWDBoi.js";import{n as l}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import"./tasks-table-aF1_yUcS.js";import{t as u}from"./chevron-right-BENZ-1ZN.js";import{t as d}from"./button-B7MKxYjT.js";import{t as f}from"./status-dot-BRzVlF2X.js";import{r as p,t as m}from"./agents-settings-path-7X6_cvUg.js";import{a as h,d as g}from"./page-shell-7pLJMOgh.js";import{Jn as _,Qn as v,Xn as y,Xt as b,kn as x}from"./index-CDd7AdAu.js";var S=e(t(),1),C=n();function w(e){let t=e.replace(/\binstall\b/g,(e,t)=>t===0?`Install`:e),n=t.split(/(`[^`]+`)/g);if(n.length===1){let e=t.split(/(\bgh auth login\b)/g);return e.length===1?t:e.map((e,t)=>e===`gh auth login`?(0,C.jsx)(`code`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground`,children:e},t):(0,C.jsx)(`span`,{children:e},t))}return n.map((e,t)=>e.startsWith("`")&&e.endsWith("`")&&e.length>2?(0,C.jsx)(`code`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground`,children:e.slice(1,-1)},t):e?(0,C.jsx)(`span`,{children:e},t):null)}function T(e,t){let n=r(t,e);return n?{label:n.displayName,isAgent:!0}:{label:e,isAgent:!1}}function E({mode:e,version:t,rawVersion:n}){return e?(0,C.jsx)(`span`,{"data-slot":`tool-dry-run`,title:n,className:`shrink-0 rounded-full border border-border bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground`,children:e.label}):t?(0,C.jsxs)(`span`,{className:`min-w-0 break-words`,children:[`· `,t]}):null}var D=`h-8 text-xs font-medium max-md:h-11 no-hover:h-11`;function O({health:e,projects:t,repository:n,onAction:r}){let i=!!(e.data?.repoRoot||n||t.data?.projectsDir);return(0,C.jsxs)(`section`,{className:`space-y-4 rounded-xl border border-card-edge bg-card p-6 shadow-card max-md:p-4`,"aria-labelledby":`add-project-heading`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h2`,{id:`add-project-heading`,className:`text-base font-semibold text-foreground`,children:`Add project`}),(0,C.jsx)(`p`,{className:`mt-1 text-[13px] leading-[1.5] text-muted-foreground`,children:`Start a new repository, open an existing local folder, or clone a GitHub repository.`})]}),i?(0,C.jsxs)(`div`,{className:`border-y border-border py-3.5`,children:[(0,C.jsx)(`h3`,{className:`mb-2.5 text-xs font-semibold tracking-wide text-muted-foreground uppercase`,children:`Active project`}),(0,C.jsxs)(`dl`,{className:`space-y-2 text-[13px] leading-[1.5] text-muted-foreground`,children:[e.data?.repoRoot?(0,C.jsxs)(`div`,{className:`grid grid-cols-1 gap-x-4 gap-y-0.5 sm:grid-cols-[160px_minmax(0,1fr)]`,children:[(0,C.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Local folder`}),(0,C.jsx)(`dd`,{className:`min-w-0 font-mono text-xs break-all`,children:e.data.repo?.root??e.data.repoRoot})]}):null,n?(0,C.jsxs)(`div`,{className:`grid grid-cols-1 gap-x-4 gap-y-0.5 sm:grid-cols-[160px_minmax(0,1fr)]`,children:[(0,C.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Repository`}),(0,C.jsx)(`dd`,{className:`min-w-0 font-mono text-xs break-all`,children:n.replace(/^https:\/\//,``)})]}):null,t.data?.projectsDir?(0,C.jsxs)(`div`,{className:`grid grid-cols-1 gap-x-4 gap-y-0.5 sm:grid-cols-[160px_minmax(0,1fr)]`,children:[(0,C.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Checkout folder`}),(0,C.jsx)(`dd`,{className:`min-w-0 font-mono text-xs break-all`,children:t.data.projectsDir})]}):null]})]}):null,(0,C.jsxs)(`div`,{className:`flex flex-wrap gap-2.5`,children:[(0,C.jsx)(d,{variant:`outline`,className:`h-10 rounded-lg px-3.5 text-xs font-medium max-md:h-11`,"data-action":`new-project`,onClick:()=>r(`new`),children:`New project`}),(0,C.jsx)(d,{variant:`outline`,className:`h-10 rounded-lg px-3.5 text-xs font-medium max-md:h-11`,onClick:()=>r(`local`),children:`Open local folder`}),(0,C.jsx)(d,{variant:`outline`,className:`h-10 rounded-lg px-3.5 text-xs font-medium max-md:h-11`,onClick:()=>r(`clone`),children:`Clone from GitHub`})]})]})}function k({health:e,runners:t,copying:n,onCopy:r}){return(0,C.jsxs)(`section`,{className:`space-y-4 rounded-xl border border-card-edge bg-card p-6 shadow-card max-md:p-4`,"aria-labelledby":`tools-heading`,children:[(0,C.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h2`,{id:`tools-heading`,className:`text-base font-semibold text-foreground`,children:`Tools diagnostics`}),(0,C.jsx)(`p`,{className:`mt-1 text-[13px] leading-[1.5] text-muted-foreground`,children:`Check the tools available to this local workspace.`})]}),(0,C.jsx)(d,{asChild:!0,variant:`outline`,size:`sm`,className:D,children:(0,C.jsxs)(l,{to:m,"data-slot":`tools-settings`,children:[`Tool settings`,(0,C.jsx)(u,{className:`size-3.5 shrink-0`,"aria-hidden":`true`})]})})]}),e.isError?(0,C.jsx)(`p`,{role:`alert`,className:`text-sm text-semantic-red`,children:`Could not refresh tool diagnostics. Recheck to retry.`}):null,!e.data&&!e.isError?(0,C.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Checking installed tools…`}):null,e.data?(0,C.jsx)(`dl`,{className:`divide-y divide-border border-y border-border text-[13px] leading-[1.5] text-muted-foreground`,children:e.data.checks.map(e=>{let n=b(e),r=T(e.name,t),i=x(e);return(0,C.jsxs)(`div`,{"data-slot":`tool-row`,"data-tool":e.name,"data-available":e.available,className:`grid grid-cols-1 gap-x-4 gap-y-1 py-3 sm:grid-cols-[160px_minmax(0,1fr)] sm:items-center`,children:[(0,C.jsxs)(`dt`,{className:`flex items-center gap-2.5`,children:[(0,C.jsx)(f,{tone:i.availability.tone,shape:i.availability.shape}),(0,C.jsx)(`span`,{className:r.isAgent?`text-[14px] font-semibold text-foreground`:`font-mono text-[13px] font-semibold text-foreground`,children:r.label})]}),(0,C.jsxs)(`dd`,{className:`flex min-w-0 items-center gap-x-1.5 text-muted-foreground`,children:[(0,C.jsx)(`span`,{className:`shrink-0`,children:i.availability.label}),(0,C.jsx)(E,{mode:i.mode,version:i.version,rawVersion:i.rawVersion}),e.available?null:(0,C.jsx)(d,{asChild:!0,variant:`outline`,size:`sm`,className:`${D} ml-auto`,children:(0,C.jsxs)(l,{to:p(e.name),"data-slot":`tool-setup`,children:[`Set up`,(0,C.jsx)(u,{className:`size-3.5 shrink-0`,"aria-hidden":`true`})]})})]}),n?(0,C.jsx)(`dd`,{"data-slot":`tool-hint`,className:`min-w-0 break-words text-xs leading-relaxed text-muted-foreground sm:col-start-2`,children:w(n)}):null]},e.name)})}):null,e.data?.checks.length===0?(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No tool diagnostics reported by this server.`}):null,(0,C.jsxs)(`div`,{className:`flex flex-wrap gap-2.5`,children:[(0,C.jsx)(d,{variant:`outline`,className:`h-10 rounded-lg px-3.5 text-xs font-medium max-md:h-11`,disabled:e.isFetching,onClick:()=>void e.refetch(),children:e.isFetching?`Checking tools…`:`Recheck tools`}),(0,C.jsx)(d,{variant:`outline`,className:`h-10 rounded-lg px-3.5 text-xs font-medium max-md:h-11`,disabled:!e.data||n,onClick:()=>void r(),children:n?`Copying…`:`Copy diagnostics`})]})]})}function A(){let e=s(),t=i(),n=o().data,r=a(e.data?.repo?.remote),[l,u]=(0,S.useState)(null),[d,f]=(0,S.useState)(!1),p=async()=>{if(!(!e.data||d)){f(!0);try{await navigator.clipboard.writeText(JSON.stringify({version:e.data.version,checks:e.data.checks},null,2)),c(`Diagnostics copied`)}catch{c(`Could not copy diagnostics. Please try again.`,{tone:`danger`})}finally{f(!1)}}},m=e.data?.checks.length??4;return(0,C.jsxs)(h,{route:`workspace-tools`,density:e.data?g(m):`full`,bodyClassName:`gap-5`,header:{title:`Workspace tools`,subtitle:`Add projects and inspect local workspace CLI diagnostics.`},children:[(0,C.jsx)(O,{health:e,projects:t,repository:r,onAction:u}),(0,C.jsx)(k,{health:e,runners:n,copying:d,onCopy:p}),l===`new`?(0,C.jsx)(_,{open:!0,onOpenChange:e=>{e||u(null)}}):null,l===`local`?(0,C.jsx)(v,{open:!0,onOpenChange:e=>{e||u(null)}}):null,l===`clone`?(0,C.jsx)(y,{open:!0,onOpenChange:e=>{e||u(null)}}):null]})}export{A as WorkspaceToolsRoute};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Qt as r,St as i,Vt as a,rn as o,yt as s}from"./queries-hzlF788B.js";import{n as c}from"./toaster-fWyfEGWF.js";import{n as l}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import"./tasks-table-D17JLOhe.js";import{t as u}from"./chevron-right-BENZ-1ZN.js";import{t as d}from"./button-B7MKxYjT.js";import{t as f}from"./status-dot-BRzVlF2X.js";import{r as p,t as m}from"./agents-settings-path-7X6_cvUg.js";import{a as h,d as g}from"./page-shell-7pLJMOgh.js";import{$n as _,An as v,Xt as y,Yn as b,Zn as x}from"./index-VBdx5s7U.js";var S=e(t(),1),C=n();function w(e){let t=e.replace(/\binstall\b/g,(e,t)=>t===0?`Install`:e),n=t.split(/(`[^`]+`)/g);if(n.length===1){let e=t.split(/(\bgh auth login\b)/g);return e.length===1?t:e.map((e,t)=>e===`gh auth login`?(0,C.jsx)(`code`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground`,children:e},t):(0,C.jsx)(`span`,{children:e},t))}return n.map((e,t)=>e.startsWith("`")&&e.endsWith("`")&&e.length>2?(0,C.jsx)(`code`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground`,children:e.slice(1,-1)},t):e?(0,C.jsx)(`span`,{children:e},t):null)}function T(e,t){let n=r(t,e);return n?{label:n.displayName,isAgent:!0}:{label:e,isAgent:!1}}function E({mode:e,version:t,rawVersion:n}){return e?(0,C.jsx)(`span`,{"data-slot":`tool-dry-run`,title:n,className:`shrink-0 rounded-full border border-border bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground`,children:e.label}):t?(0,C.jsxs)(`span`,{className:`min-w-0 break-words`,children:[`· `,t]}):null}var D=`h-8 text-xs font-medium max-md:h-11 no-hover:h-11`;function O({health:e,projects:t,repository:n,onAction:r}){let i=!!(e.data?.repoRoot||n||t.data?.projectsDir);return(0,C.jsxs)(`section`,{className:`space-y-4 rounded-xl border border-card-edge bg-card p-6 shadow-card max-md:p-4`,"aria-labelledby":`add-project-heading`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h2`,{id:`add-project-heading`,className:`text-base font-semibold text-foreground`,children:`Add project`}),(0,C.jsx)(`p`,{className:`mt-1 text-[13px] leading-[1.5] text-muted-foreground`,children:`Start a new repository, open an existing local folder, or clone a GitHub repository.`})]}),i?(0,C.jsxs)(`div`,{className:`border-y border-border py-3.5`,children:[(0,C.jsx)(`h3`,{className:`mb-2.5 text-xs font-semibold tracking-wide text-muted-foreground uppercase`,children:`Active project`}),(0,C.jsxs)(`dl`,{className:`space-y-2 text-[13px] leading-[1.5] text-muted-foreground`,children:[e.data?.repoRoot?(0,C.jsxs)(`div`,{className:`grid grid-cols-1 gap-x-4 gap-y-0.5 sm:grid-cols-[160px_minmax(0,1fr)]`,children:[(0,C.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Local folder`}),(0,C.jsx)(`dd`,{className:`min-w-0 font-mono text-xs break-all`,children:e.data.repo?.root??e.data.repoRoot})]}):null,n?(0,C.jsxs)(`div`,{className:`grid grid-cols-1 gap-x-4 gap-y-0.5 sm:grid-cols-[160px_minmax(0,1fr)]`,children:[(0,C.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Repository`}),(0,C.jsx)(`dd`,{className:`min-w-0 font-mono text-xs break-all`,children:n.replace(/^https:\/\//,``)})]}):null,t.data?.projectsDir?(0,C.jsxs)(`div`,{className:`grid grid-cols-1 gap-x-4 gap-y-0.5 sm:grid-cols-[160px_minmax(0,1fr)]`,children:[(0,C.jsx)(`dt`,{className:`font-medium text-foreground`,children:`Checkout folder`}),(0,C.jsx)(`dd`,{className:`min-w-0 font-mono text-xs break-all`,children:t.data.projectsDir})]}):null]})]}):null,(0,C.jsxs)(`div`,{className:`flex flex-wrap gap-2.5`,children:[(0,C.jsx)(d,{variant:`outline`,className:`h-10 rounded-lg px-3.5 text-xs font-medium max-md:h-11`,"data-action":`new-project`,onClick:()=>r(`new`),children:`New project`}),(0,C.jsx)(d,{variant:`outline`,className:`h-10 rounded-lg px-3.5 text-xs font-medium max-md:h-11`,onClick:()=>r(`local`),children:`Open local folder`}),(0,C.jsx)(d,{variant:`outline`,className:`h-10 rounded-lg px-3.5 text-xs font-medium max-md:h-11`,onClick:()=>r(`clone`),children:`Clone from GitHub`})]})]})}function k({health:e,runners:t,copying:n,onCopy:r}){return(0,C.jsxs)(`section`,{className:`space-y-4 rounded-xl border border-card-edge bg-card p-6 shadow-card max-md:p-4`,"aria-labelledby":`tools-heading`,children:[(0,C.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h2`,{id:`tools-heading`,className:`text-base font-semibold text-foreground`,children:`Tools diagnostics`}),(0,C.jsx)(`p`,{className:`mt-1 text-[13px] leading-[1.5] text-muted-foreground`,children:`Check the tools available to this local workspace.`})]}),(0,C.jsx)(d,{asChild:!0,variant:`outline`,size:`sm`,className:D,children:(0,C.jsxs)(l,{to:m,"data-slot":`tools-settings`,children:[`Tool settings`,(0,C.jsx)(u,{className:`size-3.5 shrink-0`,"aria-hidden":`true`})]})})]}),e.isError?(0,C.jsx)(`p`,{role:`alert`,className:`text-sm text-semantic-red`,children:`Could not refresh tool diagnostics. Recheck to retry.`}):null,!e.data&&!e.isError?(0,C.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Checking installed tools…`}):null,e.data?(0,C.jsx)(`dl`,{className:`divide-y divide-border border-y border-border text-[13px] leading-[1.5] text-muted-foreground`,children:e.data.checks.map(e=>{let n=y(e),r=T(e.name,t),i=v(e);return(0,C.jsxs)(`div`,{"data-slot":`tool-row`,"data-tool":e.name,"data-available":e.available,className:`grid grid-cols-1 gap-x-4 gap-y-1 py-3 sm:grid-cols-[160px_minmax(0,1fr)] sm:items-center`,children:[(0,C.jsxs)(`dt`,{className:`flex items-center gap-2.5`,children:[(0,C.jsx)(f,{tone:i.availability.tone,shape:i.availability.shape}),(0,C.jsx)(`span`,{className:r.isAgent?`text-[14px] font-semibold text-foreground`:`font-mono text-[13px] font-semibold text-foreground`,children:r.label})]}),(0,C.jsxs)(`dd`,{className:`flex min-w-0 items-center gap-x-1.5 text-muted-foreground`,children:[(0,C.jsx)(`span`,{className:`shrink-0`,children:i.availability.label}),(0,C.jsx)(E,{mode:i.mode,version:i.version,rawVersion:i.rawVersion}),e.available?null:(0,C.jsx)(d,{asChild:!0,variant:`outline`,size:`sm`,className:`${D} ml-auto`,children:(0,C.jsxs)(l,{to:p(e.name),"data-slot":`tool-setup`,children:[`Set up`,(0,C.jsx)(u,{className:`size-3.5 shrink-0`,"aria-hidden":`true`})]})})]}),n?(0,C.jsx)(`dd`,{"data-slot":`tool-hint`,className:`min-w-0 break-words text-xs leading-relaxed text-muted-foreground sm:col-start-2`,children:w(n)}):null]},e.name)})}):null,e.data?.checks.length===0?(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No tool diagnostics reported by this server.`}):null,(0,C.jsxs)(`div`,{className:`flex flex-wrap gap-2.5`,children:[(0,C.jsx)(d,{variant:`outline`,className:`h-10 rounded-lg px-3.5 text-xs font-medium max-md:h-11`,disabled:e.isFetching,onClick:()=>void e.refetch(),children:e.isFetching?`Checking tools…`:`Recheck tools`}),(0,C.jsx)(d,{variant:`outline`,className:`h-10 rounded-lg px-3.5 text-xs font-medium max-md:h-11`,disabled:!e.data||n,onClick:()=>void r(),children:n?`Copying…`:`Copy diagnostics`})]})]})}function A(){let e=s(),t=i(),n=o().data,r=a(e.data?.repo?.remote),[l,u]=(0,S.useState)(null),[d,f]=(0,S.useState)(!1),p=async()=>{if(!(!e.data||d)){f(!0);try{await navigator.clipboard.writeText(JSON.stringify({version:e.data.version,checks:e.data.checks},null,2)),c(`Diagnostics copied`)}catch{c(`Could not copy diagnostics. Please try again.`,{tone:`danger`})}finally{f(!1)}}},m=e.data?.checks.length??4;return(0,C.jsxs)(h,{route:`workspace-tools`,density:e.data?g(m):`full`,bodyClassName:`gap-5`,header:{title:`Workspace tools`,subtitle:`Add projects and inspect local workspace CLI diagnostics.`},children:[(0,C.jsx)(O,{health:e,projects:t,repository:r,onAction:u}),(0,C.jsx)(k,{health:e,runners:n,copying:d,onCopy:p}),l===`new`?(0,C.jsx)(b,{open:!0,onOpenChange:e=>{e||u(null)}}):null,l===`local`?(0,C.jsx)(_,{open:!0,onOpenChange:e=>{e||u(null)}}):null,l===`clone`?(0,C.jsx)(x,{open:!0,onOpenChange:e=>{e||u(null)}}):null]})}export{A as WorkspaceToolsRoute};
@@ -1,4 +1,4 @@
1
- import{t as e}from"./react-runtime-CCIEwYL0.js";import{Wt as t,_ as n,dn as r,yt as i}from"./queries-C0l1puJe.js";import{Fn as a,Ir as o,Lr as s,P as c,hi as l,n as u}from"./toaster-BYPWDBoi.js";import{u as d}from"./design-icons-CzEoMH9c.js";import{t as f}from"./button-B7MKxYjT.js";import{t as p}from"./project-router-p_FJwg-L.js";import{t as m}from"./centered-state-V15AR_qo.js";import{ar as h,pn as g}from"./index-CDd7AdAu.js";import{n as _,r as v,t as y}from"./remote-settings-notice-B9h38exH.js";import{n as b}from"./saved-draft-BwzBc-_Y.js";import{t as x}from"./save-cue-Cd3ZAPBS.js";import{n as S}from"./settings-field-DP9sYv5a.js";import{n as C}from"./project-location-BKXBQJPm.js";var w=e();function T({copy:e,savedCommandCount:t,settingsAdmin:n,configPath:r,issue:i,invalid:a,children:o}){let s=e.slot;return(0,w.jsxs)(w.Fragment,{children:[t===0&&i===null?(0,w.jsx)(`p`,{"data-slot":`${s}-empty`,className:`text-xs text-muted-foreground`,children:e.empty}):null,o,n===!1?(0,w.jsxs)(`p`,{"data-slot":`${s}-readonly`,className:`text-xs text-foreground`,children:[`Edit `,(0,w.jsxs)(`code`,{children:[e.key,`.commands`]}),` in`,` `,r===null?(0,w.jsxs)(w.Fragment,{children:[`the project’s `,(0,w.jsx)(`code`,{children:`.ai/cezar/config.json`})]}):(0,w.jsx)(`code`,{className:`break-all`,children:r}),` `,`on the machine running Squawk. `,e.fileEditApplies,` No restart is needed. To edit here, the host operator runs `,(0,w.jsx)(`code`,{children:y}),`.`]}):null,i===null?null:(0,w.jsxs)(`p`,{"data-slot":`${s}-issue`,className:`text-xs text-danger`,children:[`config.json has an invalid `,e.key,` (`,i,`) — saving replaces it.`]}),a===null?null:(0,w.jsx)(`p`,{"data-slot":`${s}-invalid`,className:`text-xs text-danger`,children:a})]})}function E(e,t){let n=e.split(`
2
- `).map(e=>e.trim()).filter(e=>e!==``),r=Number(t);return{commands:n,timeoutSeconds:r,invalid:n.length>20?`Enter at most 20 commands.`:n.some(e=>e.length>4e3)?`Keep each command under ${o.toLocaleString(`en-US`)} characters.`:t.trim()===``||!Number.isInteger(r)||r<1||r>7200?`Enter a whole number of seconds from 1 to ${s}.`:null}}var D={setup:{key:`worktreeSetup`,issueKey:`worktreeSetupIssue`,slot:`worktree-setup`,title:`Prepare new worktrees`,hint:`Runs in order in every new task and worker worktree before the agent starts. The first failure stops setup.`,empty:`No setup commands configured. No commands will run in new worktrees.`,label:`Worktree setup commands, one per line`,example:`npm ci`,fileEditApplies:`Valid file edits apply to new worktrees.`,saved:`Worktree setup saved`,cleared:`Worktree setup cleared`,save:`Save setup`},teardown:{key:`worktreeTeardown`,issueKey:`worktreeTeardownIssue`,slot:`worktree-teardown`,title:`Stop worker services before destroy`,hint:`Runs in order in a worker’s worktree when the worker is destroyed, before its processes stop. The first failure stops teardown; destroy goes on and records it on the worker.`,empty:`No teardown commands configured. Destroy runs no commands in worker worktrees.`,label:`Worktree teardown commands, one per line`,example:`docker compose down`,fileEditApplies:`Valid file edits apply to the next worker destroy.`,saved:`Worktree teardown saved`,cleared:`Worktree teardown cleared`,save:`Save teardown`}};function O(e,t){return t?`One command per line, for example: ${e.example}`:void 0}function k({config:e,copy:n}){let o=l(),d=i(),p=v(),m=C(),h=m===null?null:`${m.replace(/\/$/,``)}/.ai/cezar/config.json`,y=d.data?.capabilities?.settingsAdmin===!0,D=e[n.key],k=e[n.issueKey],A=D?.commands??[],j=D?.timeoutSeconds??900,[M,N]=b(A.join(`
3
- `)),[P,F]=b(String(j)),{commands:I,timeoutSeconds:L,invalid:R}=E(M,P),z=I.length===A.length&&I.every((e,t)=>e===A[t])&&(I.length===0||L===j),B=k===null&&z;g(y&&!z);let V=r({mutationFn:e=>c(e),onSuccess:e=>{o.setQueryData(t.config,e),N(I.join(`
4
- `)),u(I.length===0?n.cleared:n.saved)},onError:e=>{u(e.message,{tone:`danger`}),e instanceof a&&e.status===409&&p()}}),H=()=>V.mutate({[n.key]:I.length===0?null:{commands:I,...L===900?{}:{timeoutSeconds:L}}}),U=`block rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50 read-only:bg-muted read-only:text-muted-foreground`;return(0,w.jsxs)(S,{title:n.title,hint:n.hint,children:[(0,w.jsx)(_,{risk:`These commands run on the machine running Squawk`}),(0,w.jsxs)(T,{copy:n,savedCommandCount:A.length,settingsAdmin:d.data?.capabilities?.settingsAdmin,configPath:h,issue:k,invalid:R,children:[(0,w.jsx)(`textarea`,{"data-slot":`${n.slot}-commands`,"data-reports-dirty":``,"aria-label":n.label,rows:4,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,value:M,placeholder:O(n,y),readOnly:!y,disabled:V.isPending,onChange:e=>N(e.target.value),className:`${U} field-sizing-content min-h-24 max-h-[min(24rem,60dvh)] w-full resize-none overflow-y-auto font-mono text-[13px] leading-relaxed`}),(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,w.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,w.jsx)(`span`,{children:`Timeout per command`}),(0,w.jsx)(`input`,{type:`number`,inputMode:`numeric`,min:1,max:s,step:1,"data-slot":`${n.slot}-timeout`,"data-reports-dirty":``,value:P,readOnly:!y,disabled:V.isPending,onChange:e=>F(e.target.value),className:`${U} min-h-11 w-28 md:min-h-0`}),(0,w.jsx)(`span`,{children:`seconds`})]}),(0,w.jsx)(x,{show:y&&B&&!V.isPending,children:(0,w.jsx)(f,{type:`button`,variant:`primary`,size:`sm`,className:`min-h-11 md:min-h-0`,"data-action":`${n.slot}-save`,disabled:!y||B||R!==null||V.isPending,onClick:H,children:n.save})})]})]})]})}var A=0,j=1e3;function M(){let e=n();return e.isPending?(0,w.jsx)(`p`,{"data-slot":`worktrees-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading worktree settings…`}):e.isError?(0,w.jsx)(m,{icon:(0,w.jsx)(h,{}),tone:`danger`,title:`Worktree settings did not load`,subtitle:e.error.message,heading:`h2`}):(0,w.jsx)(N,{config:e.data})}function N({config:e}){let n=l(),i=r({mutationFn:e=>c(e),onSuccess:e=>n.setQueryData(t.config,e),onError:e=>u(e.message,{tone:`danger`})}),[a,o]=b(String(e.worktreeRetention)),s=Number(a),m=a.trim()===``||!Number.isInteger(s)||s<A||s>j,h=e.worktreeRetention===(m?-1:s);return g(!h),(0,w.jsxs)(`div`,{"data-slot":`worktrees-section`,className:`mx-auto flex w-full max-w-2xl flex-col gap-7 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:[(0,w.jsxs)(S,{title:`Keep N finished worktrees`,hint:`Older finished worktrees are removed to free disk; their branch stays, so the work is recoverable. 0 keeps all. Running and in-review tasks are never removed.`,children:[(0,w.jsxs)(`div`,{"data-reports-dirty":``,className:`flex items-center gap-2`,children:[(0,w.jsx)(`input`,{type:`number`,inputMode:`numeric`,min:A,max:j,step:1,"aria-label":`Keep last N finished worktrees`,"data-slot":`resources-worktree-retention`,value:a,disabled:i.isPending,onChange:e=>o(e.target.value),className:`block w-32 rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`}),(0,w.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`worktrees`}),(0,w.jsx)(x,{show:h&&!m&&!i.isPending,children:(0,w.jsx)(f,{type:`button`,variant:`primary`,size:`sm`,"data-action":`resources-save-retention`,disabled:h||m||i.isPending,onClick:()=>i.mutate({worktreeRetention:s},{onSuccess:()=>{n.invalidateQueries({queryKey:t.worktrees}),u(s===0?`Keeping all worktrees (unlimited)`:`Keeping the last ${s} finished worktree${s===1?``:`s`}`)}}),children:`Save retention`})})]}),m?(0,w.jsxs)(`p`,{"data-slot":`resources-retention-invalid`,className:`text-xs text-danger`,children:[`Enter a whole number from `,A,` to `,j,` (0 = unlimited).`]}):(0,w.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:s===0?`Keeping every finished worktree.`:`Keeping the last ${s} finished worktree${s===1?``:`s`} on disk.`})]}),(0,w.jsx)(k,{config:e,copy:D.setup}),(0,w.jsx)(k,{config:e,copy:D.teardown}),(0,w.jsxs)(p,{to:`/git/cleanup`,"data-slot":`worktrees-manage-link`,className:`inline-flex min-h-11 items-center gap-1 self-start text-[13px] font-medium text-link-foreground hover:underline focus-visible:outline-2 focus-visible:outline-ring md:min-h-0`,children:[`Manage worktrees on Git`,(0,w.jsx)(d,{"aria-hidden":`true`,className:`size-[14px]`})]})]})}export{M as WorktreesSection};
1
+ import{t as e}from"./react-runtime-CCIEwYL0.js";import{Wt as t,_ as n,dn as r,yt as i}from"./queries-hzlF788B.js";import{Fn as a,Ir as o,Lr as s,P as c,hi as l,n as u}from"./toaster-fWyfEGWF.js";import{u as d}from"./design-icons-CzEoMH9c.js";import{t as f}from"./button-B7MKxYjT.js";import{t as p}from"./project-router-B9FTk0rB.js";import{t as m}from"./centered-state-V15AR_qo.js";import{mn as h,or as g}from"./index-VBdx5s7U.js";import{n as _,r as v,t as y}from"./remote-settings-notice-C3iWEGmH.js";import{n as b}from"./saved-draft-BwzBc-_Y.js";import{t as x}from"./save-cue-Cd3ZAPBS.js";import{n as S}from"./settings-field-DP9sYv5a.js";import{n as C}from"./project-location-DATkk1gA.js";var w=e();function T({copy:e,savedCommandCount:t,settingsAdmin:n,configPath:r,issue:i,invalid:a,children:o}){let s=e.slot;return(0,w.jsxs)(w.Fragment,{children:[t===0&&i===null?(0,w.jsx)(`p`,{"data-slot":`${s}-empty`,className:`text-xs text-muted-foreground`,children:e.empty}):null,o,n===!1?(0,w.jsxs)(`p`,{"data-slot":`${s}-readonly`,className:`text-xs text-foreground`,children:[`Edit `,(0,w.jsxs)(`code`,{children:[e.key,`.commands`]}),` in`,` `,r===null?(0,w.jsxs)(w.Fragment,{children:[`the project’s `,(0,w.jsx)(`code`,{children:`.ai/cezar/config.json`})]}):(0,w.jsx)(`code`,{className:`break-all`,children:r}),` `,`on the machine running Squawk. `,e.fileEditApplies,` No restart is needed. To edit here, the host operator runs `,(0,w.jsx)(`code`,{children:y}),`.`]}):null,i===null?null:(0,w.jsxs)(`p`,{"data-slot":`${s}-issue`,className:`text-xs text-danger`,children:[`config.json has an invalid `,e.key,` (`,i,`) — saving replaces it.`]}),a===null?null:(0,w.jsx)(`p`,{"data-slot":`${s}-invalid`,className:`text-xs text-danger`,children:a})]})}function E(e,t){let n=e.split(`
2
+ `).map(e=>e.trim()).filter(e=>e!==``),r=Number(t);return{commands:n,timeoutSeconds:r,invalid:n.length>20?`Enter at most 20 commands.`:n.some(e=>e.length>4e3)?`Keep each command under ${o.toLocaleString(`en-US`)} characters.`:t.trim()===``||!Number.isInteger(r)||r<1||r>7200?`Enter a whole number of seconds from 1 to ${s}.`:null}}var D={setup:{key:`worktreeSetup`,issueKey:`worktreeSetupIssue`,slot:`worktree-setup`,title:`Prepare new worktrees`,hint:`Runs in order in every new task and worker worktree before the agent starts. The first failure stops setup.`,empty:`No setup commands configured. No commands will run in new worktrees.`,label:`Worktree setup commands, one per line`,example:`npm ci`,fileEditApplies:`Valid file edits apply to new worktrees.`,saved:`Worktree setup saved`,cleared:`Worktree setup cleared`,save:`Save setup`},teardown:{key:`worktreeTeardown`,issueKey:`worktreeTeardownIssue`,slot:`worktree-teardown`,title:`Stop worker services before destroy`,hint:`Runs in order in a worker’s worktree when the worker is destroyed, before its processes stop. The first failure stops teardown; destroy goes on and records it on the worker.`,empty:`No teardown commands configured. Destroy runs no commands in worker worktrees.`,label:`Worktree teardown commands, one per line`,example:`docker compose down`,fileEditApplies:`Valid file edits apply to the next worker destroy.`,saved:`Worktree teardown saved`,cleared:`Worktree teardown cleared`,save:`Save teardown`}};function O(e,t){return t?`One command per line, for example: ${e.example}`:void 0}function k({config:e,copy:n}){let o=l(),d=i(),p=v(),m=C(),g=m===null?null:`${m.replace(/\/$/,``)}/.ai/cezar/config.json`,y=d.data?.capabilities?.settingsAdmin===!0,D=e[n.key],k=e[n.issueKey],A=D?.commands??[],j=D?.timeoutSeconds??900,[M,N]=b(A.join(`
3
+ `)),[P,F]=b(String(j)),{commands:I,timeoutSeconds:L,invalid:R}=E(M,P),z=I.length===A.length&&I.every((e,t)=>e===A[t])&&(I.length===0||L===j),B=k===null&&z;h(y&&!z);let V=r({mutationFn:e=>c(e),onSuccess:e=>{o.setQueryData(t.config,e),N(I.join(`
4
+ `)),u(I.length===0?n.cleared:n.saved)},onError:e=>{u(e.message,{tone:`danger`}),e instanceof a&&e.status===409&&p()}}),H=()=>V.mutate({[n.key]:I.length===0?null:{commands:I,...L===900?{}:{timeoutSeconds:L}}}),U=`block rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50 read-only:bg-muted read-only:text-muted-foreground`;return(0,w.jsxs)(S,{title:n.title,hint:n.hint,children:[(0,w.jsx)(_,{risk:`These commands run on the machine running Squawk`}),(0,w.jsxs)(T,{copy:n,savedCommandCount:A.length,settingsAdmin:d.data?.capabilities?.settingsAdmin,configPath:g,issue:k,invalid:R,children:[(0,w.jsx)(`textarea`,{"data-slot":`${n.slot}-commands`,"data-reports-dirty":``,"aria-label":n.label,rows:4,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,value:M,placeholder:O(n,y),readOnly:!y,disabled:V.isPending,onChange:e=>N(e.target.value),className:`${U} field-sizing-content min-h-24 max-h-[min(24rem,60dvh)] w-full resize-none overflow-y-auto font-mono text-[13px] leading-relaxed`}),(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,w.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,w.jsx)(`span`,{children:`Timeout per command`}),(0,w.jsx)(`input`,{type:`number`,inputMode:`numeric`,min:1,max:s,step:1,"data-slot":`${n.slot}-timeout`,"data-reports-dirty":``,value:P,readOnly:!y,disabled:V.isPending,onChange:e=>F(e.target.value),className:`${U} min-h-11 w-28 md:min-h-0`}),(0,w.jsx)(`span`,{children:`seconds`})]}),(0,w.jsx)(x,{show:y&&B&&!V.isPending,children:(0,w.jsx)(f,{type:`button`,variant:`primary`,size:`sm`,className:`min-h-11 md:min-h-0`,"data-action":`${n.slot}-save`,disabled:!y||B||R!==null||V.isPending,onClick:H,children:n.save})})]})]})]})}var A=0,j=1e3;function M(){let e=n();return e.isPending?(0,w.jsx)(`p`,{"data-slot":`worktrees-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading worktree settings…`}):e.isError?(0,w.jsx)(m,{icon:(0,w.jsx)(g,{}),tone:`danger`,title:`Worktree settings did not load`,subtitle:e.error.message,heading:`h2`}):(0,w.jsx)(N,{config:e.data})}function N({config:e}){let n=l(),i=r({mutationFn:e=>c(e),onSuccess:e=>n.setQueryData(t.config,e),onError:e=>u(e.message,{tone:`danger`})}),[a,o]=b(String(e.worktreeRetention)),s=Number(a),m=a.trim()===``||!Number.isInteger(s)||s<A||s>j,g=e.worktreeRetention===(m?-1:s);return h(!g),(0,w.jsxs)(`div`,{"data-slot":`worktrees-section`,className:`mx-auto flex w-full max-w-2xl flex-col gap-7 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:[(0,w.jsxs)(S,{title:`Keep N finished worktrees`,hint:`Older finished worktrees are removed to free disk; their branch stays, so the work is recoverable. 0 keeps all. Running and in-review tasks are never removed.`,children:[(0,w.jsxs)(`div`,{"data-reports-dirty":``,className:`flex items-center gap-2`,children:[(0,w.jsx)(`input`,{type:`number`,inputMode:`numeric`,min:A,max:j,step:1,"aria-label":`Keep last N finished worktrees`,"data-slot":`resources-worktree-retention`,value:a,disabled:i.isPending,onChange:e=>o(e.target.value),className:`block w-32 rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`}),(0,w.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`worktrees`}),(0,w.jsx)(x,{show:g&&!m&&!i.isPending,children:(0,w.jsx)(f,{type:`button`,variant:`primary`,size:`sm`,"data-action":`resources-save-retention`,disabled:g||m||i.isPending,onClick:()=>i.mutate({worktreeRetention:s},{onSuccess:()=>{n.invalidateQueries({queryKey:t.worktrees}),u(s===0?`Keeping all worktrees (unlimited)`:`Keeping the last ${s} finished worktree${s===1?``:`s`}`)}}),children:`Save retention`})})]}),m?(0,w.jsxs)(`p`,{"data-slot":`resources-retention-invalid`,className:`text-xs text-danger`,children:[`Enter a whole number from `,A,` to `,j,` (0 = unlimited).`]}):(0,w.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:s===0?`Keeping every finished worktree.`:`Keeping the last ${s} finished worktree${s===1?``:`s`} on disk.`})]}),(0,w.jsx)(k,{config:e,copy:D.setup}),(0,w.jsx)(k,{config:e,copy:D.teardown}),(0,w.jsxs)(p,{to:`/git/cleanup`,"data-slot":`worktrees-manage-link`,className:`inline-flex min-h-11 items-center gap-1 self-start text-[13px] font-medium text-link-foreground hover:underline focus-visible:outline-2 focus-visible:outline-ring md:min-h-0`,children:[`Manage worktrees on Git`,(0,w.jsx)(d,{"aria-hidden":`true`,className:`size-[14px]`})]})]})}export{M as WorktreesSection};
@@ -59,24 +59,24 @@
59
59
  }
60
60
  })()
61
61
  </script>
62
- <script type="module" crossorigin src="/assets/index-CDd7AdAu.js"></script>
62
+ <script type="module" crossorigin src="/assets/index-VBdx5s7U.js"></script>
63
63
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-QTnfLwEv.js">
64
64
  <link rel="modulepreload" crossorigin href="/assets/react-runtime-CCIEwYL0.js">
65
65
  <link rel="modulepreload" crossorigin href="/assets/bundle-mjs-rHxsej31.js">
66
66
  <link rel="modulepreload" crossorigin href="/assets/utils-DSMR_WLb.js">
67
67
  <link rel="modulepreload" crossorigin href="/assets/live-protocol-DMhTnCmf.js">
68
- <link rel="modulepreload" crossorigin href="/assets/toaster-BYPWDBoi.js">
69
- <link rel="modulepreload" crossorigin href="/assets/queries-C0l1puJe.js">
68
+ <link rel="modulepreload" crossorigin href="/assets/toaster-fWyfEGWF.js">
69
+ <link rel="modulepreload" crossorigin href="/assets/queries-hzlF788B.js">
70
70
  <link rel="modulepreload" crossorigin href="/assets/preload-helper-Czpn1I53.js">
71
71
  <link rel="modulepreload" crossorigin href="/assets/chunk-KS7C4IRE-Cg8l-LDN.js">
72
72
  <link rel="modulepreload" crossorigin href="/assets/cez-idle-CdswdDRd.js">
73
- <link rel="modulepreload" crossorigin href="/assets/run-detail-refresh-DyeLywhA.js">
73
+ <link rel="modulepreload" crossorigin href="/assets/run-detail-refresh-Ye2jcT7n.js">
74
74
  <link rel="modulepreload" crossorigin href="/assets/dist-BW234Kg5.js">
75
75
  <link rel="modulepreload" crossorigin href="/assets/dist-C5mlVBmd.js">
76
- <link rel="modulepreload" crossorigin href="/assets/label-DF0V6WoC.js">
77
- <link rel="modulepreload" crossorigin href="/assets/attention-D3JmzDQv.js">
78
- <link rel="modulepreload" crossorigin href="/assets/task-groups-DDxVSOHs.js">
79
- <link rel="modulepreload" crossorigin href="/assets/tasks-table-aF1_yUcS.js">
76
+ <link rel="modulepreload" crossorigin href="/assets/label-DMC9mkYa.js">
77
+ <link rel="modulepreload" crossorigin href="/assets/attention-ILOaW2-t.js">
78
+ <link rel="modulepreload" crossorigin href="/assets/task-groups-DD46syqv.js">
79
+ <link rel="modulepreload" crossorigin href="/assets/tasks-table-D17JLOhe.js">
80
80
  <link rel="modulepreload" crossorigin href="/assets/design-icons-CzEoMH9c.js">
81
81
  <link rel="modulepreload" crossorigin href="/assets/createLucideIcon-BHp8sXmF.js">
82
82
  <link rel="modulepreload" crossorigin href="/assets/bot-TkDIw4y-.js">
@@ -90,26 +90,26 @@
90
90
  <link rel="modulepreload" crossorigin href="/assets/dist-BAoXdNsT.js">
91
91
  <link rel="modulepreload" crossorigin href="/assets/dropdown-menu-4e2iKSMT.js">
92
92
  <link rel="modulepreload" crossorigin href="/assets/own-lookup-DS54wXvD.js">
93
- <link rel="modulepreload" crossorigin href="/assets/open-in-menu-D9VOIWhI.js">
93
+ <link rel="modulepreload" crossorigin href="/assets/open-in-menu-VhRao_Jk.js">
94
94
  <link rel="modulepreload" crossorigin href="/assets/check-OP-CVgZG.js">
95
95
  <link rel="modulepreload" crossorigin href="/assets/chevron-down-CHGyCDBH.js">
96
96
  <link rel="modulepreload" crossorigin href="/assets/nav-row-styles-D5HpOmDZ.js">
97
97
  <link rel="modulepreload" crossorigin href="/assets/chevron-right-BENZ-1ZN.js">
98
- <link rel="modulepreload" crossorigin href="/assets/folder-browser-sASDxPXD.js">
98
+ <link rel="modulepreload" crossorigin href="/assets/folder-browser-B_jJl4is.js">
99
99
  <link rel="modulepreload" crossorigin href="/assets/eye-B8okNWXU.js">
100
100
  <link rel="modulepreload" crossorigin href="/assets/loader-circle-CPBhhDbB.js">
101
101
  <link rel="modulepreload" crossorigin href="/assets/play-CmVAj_fu.js">
102
102
  <link rel="modulepreload" crossorigin href="/assets/popover-CZV6tz9i.js">
103
- <link rel="modulepreload" crossorigin href="/assets/reference-chip--9aRttZG.js">
103
+ <link rel="modulepreload" crossorigin href="/assets/reference-chip-Dgo5aKeb.js">
104
104
  <link rel="modulepreload" crossorigin href="/assets/dist-Da4ckcJG.js">
105
105
  <link rel="modulepreload" crossorigin href="/assets/dist-Czz3Y5qH.js">
106
106
  <link rel="modulepreload" crossorigin href="/assets/switch-DKqVf8-p.js">
107
107
  <link rel="modulepreload" crossorigin href="/assets/badge-DQ3U69Ht.js">
108
108
  <link rel="modulepreload" crossorigin href="/assets/dialog-B531GGAo.js">
109
- <link rel="modulepreload" crossorigin href="/assets/project-router-p_FJwg-L.js">
109
+ <link rel="modulepreload" crossorigin href="/assets/project-router-B9FTk0rB.js">
110
110
  <link rel="modulepreload" crossorigin href="/assets/status-dot-BRzVlF2X.js">
111
111
  <link rel="modulepreload" crossorigin href="/assets/use-search-params-writer-ClMScnNe.js">
112
- <link rel="modulepreload" crossorigin href="/assets/report-selection-DQsrMoxl.js">
112
+ <link rel="modulepreload" crossorigin href="/assets/report-selection-C-2DJb8L.js">
113
113
  <link rel="modulepreload" crossorigin href="/assets/diff-stat-C7KB1kDX.js">
114
114
  <link rel="modulepreload" crossorigin href="/assets/format-BU7D3IfE.js">
115
115
  <link rel="modulepreload" crossorigin href="/assets/command-KdW7aO0N.js">
@@ -119,7 +119,7 @@
119
119
  <link rel="modulepreload" crossorigin href="/assets/page-shell-7pLJMOgh.js">
120
120
  <link rel="modulepreload" crossorigin href="/assets/centered-state-V15AR_qo.js">
121
121
  <link rel="stylesheet" crossorigin href="/assets/page-shell-DQPYcKyL.css">
122
- <link rel="stylesheet" crossorigin href="/assets/index-DNgBNd8o.css">
122
+ <link rel="stylesheet" crossorigin href="/assets/index-9mlyFHVt.css">
123
123
  </head>
124
124
  <body>
125
125
  <div id="root"></div>
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{$t as r,Ct as i,Dt as a,Gt as o,It as s,Nt as c,Qt as l,Xt as u,Yt as d,dn as f,dt as p,mt as m,on as h,pt as g,rn as _,ut as v,wt as y,yt as b}from"./queries-C0l1puJe.js";import{Fn as x,Fr as S,In as C,hi as w,ii as T,n as E,sn as ee,zn as D}from"./toaster-BYPWDBoi.js";import{f as O}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{y as k}from"./design-icons-CzEoMH9c.js";import{t as te}from"./createLucideIcon-BHp8sXmF.js";import{t as ne}from"./folder-browser-sASDxPXD.js";import{t as A}from"./button-B7MKxYjT.js";import{t as re}from"./badge-DQ3U69Ht.js";import{a as ie,i as ae,o as oe,r as se,s as ce,t as j}from"./dialog-B531GGAo.js";import{t as M}from"./status-dot-BRzVlF2X.js";import{n as N}from"./agents-settings-path-7X6_cvUg.js";import{t as P}from"./centered-state-V15AR_qo.js";import{Gt as F,Ht as I,Jt as L,Kt as R,N as z,Tn as B,Ut as V,Wt as H,Yt as U,j as W,qt as G,wn as K,xn as le}from"./index-CDd7AdAu.js";import{t as q}from"./settings-select-CCIMGnyA.js";import{n as J,r as ue,t as de}from"./settings-agent-picker-Dl49O0Uz.js";import{n as fe,r as pe,t as me}from"./remote-settings-notice-B9h38exH.js";var he=te(`id-card`,[[`path`,{d:`M16 10h2`,key:`8sgtl7`}],[`path`,{d:`M16 14h2`,key:`epxaof`}],[`path`,{d:`M6.17 15a3 3 0 0 1 5.66 0`,key:`n6f512`}],[`circle`,{cx:`9`,cy:`11`,r:`2`,key:`yxgjnd`}],[`rect`,{x:`2`,y:`5`,width:`20`,height:`14`,rx:`2`,key:`qneu4z`}]]),Y=e(t(),1),X=n(),ge=`~/.claude-second`;function _e({open:e,onOpenChange:t,providers:n,initialProvider:r}){let i=_().data,[a,o]=(0,Y.useState)(null),[s,c]=(0,Y.useState)(null),[d,f]=(0,Y.useState)(r??n[0]??`claude`),[p,h]=(0,Y.useState)(``),[g,v]=(0,Y.useState)(``),[y,b]=(0,Y.useState)(!1),x=m(),S=g.trim();return(0,X.jsx)(j,{open:e,onOpenChange:t,children:(0,X.jsxs)(se,{"data-slot":`add-account-dialog`,className:`sm:max-w-lg`,children:[(0,X.jsxs)(oe,{children:[(0,X.jsx)(ce,{children:`Add agent account`}),(0,X.jsx)(ae,{children:`The config folder this account uses. It does not have to exist yet — Connect signs in and the CLI creates it.`})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(`label`,{className:`flex items-center gap-2 text-[13px]`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:`Agent`}),(0,X.jsx)(q,{"aria-label":`Agent`,"data-slot":`add-account-provider`,value:d,onChange:e=>f(e.target.value),className:`rounded-md border border-input bg-card px-2 py-1 text-[13px] outline-none focus-visible:border-ring`,children:n.map(e=>(0,X.jsx)(`option`,{value:e,children:u(i,e)},e))})]}),(0,X.jsxs)(`label`,{className:`flex min-w-0 flex-1 items-center gap-2 text-[13px]`,children:[(0,X.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:`Name`}),(0,X.jsx)(`input`,{type:`text`,"aria-label":`Account name`,"data-slot":`add-account-label`,value:p,placeholder:`Work`,onChange:e=>h(e.target.value),className:`min-w-0 flex-1 rounded-md border border-input bg-card px-2 py-1 text-[13px] outline-none focus-visible:border-ring`})]})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,X.jsxs)(`label`,{className:`flex min-w-0 items-center gap-2 text-[13px]`,children:[(0,X.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:`Folder`}),(0,X.jsx)(`input`,{type:`text`,spellCheck:!1,autoComplete:`off`,"aria-label":`Config folder`,"data-slot":`add-account-dir`,value:g,placeholder:l(i,d)?.accountFolderExample??ge,onChange:e=>{v(e.target.value),c(null),x.reset()},className:`min-w-0 flex-1 rounded-md border border-input bg-card px-2 py-1 font-mono text-[13px] outline-none focus-visible:border-ring`}),(0,X.jsx)(A,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`add-account-browse`,"aria-expanded":y,onClick:()=>b(e=>!e),children:y?`Hide folders`:`Browse…`})]}),(0,X.jsxs)(`p`,{className:`text-xs text-soft-foreground`,children:[`A `,(0,X.jsx)(`code`,{children:`~`}),` is kept as written and expanded when the agent runs.`]})]}),y?(0,X.jsx)(ne,{path:a,selected:s,onSelect:e=>{c(e),v(e.path),x.reset()},onEnter:e=>{o(e),c(null),x.reset()},showHidden:!0,emptyHint:`No subfolders here — pick this folder by typing its path above.`}):null,x.isError?(0,X.jsx)(`p`,{"data-slot":`add-account-error`,className:`min-w-0 break-words text-[13px] text-danger`,children:x.error instanceof Error?x.error.message:`could not add that folder`}):null,(0,X.jsxs)(ie,{className:`min-w-0 sm:items-center sm:justify-end`,children:[(0,X.jsx)(A,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,X.jsx)(A,{"data-slot":`add-account-confirm`,disabled:S===``||x.isPending,onClick:()=>{S===``||x.isPending||x.mutate({provider:d,configDir:S,...p.trim()?{label:p.trim()}:{}},{onSuccess:()=>{t(!1),h(``),v(``),c(null),b(!1),E(`Account added — use Connect to sign in`)}})},children:x.isPending?`Adding…`:`Add account`})]})]})})}async function ve(e){return D(await C.api.v1[`runner-install`][`:runner`].$get({param:{runner:e}}),`/runner-install/:runner`)}async function ye(e,t){return D(await C.api.v1[`runner-install`][`:runner`].$post({param:{runner:e},json:{action:t}}),`/runner-install/:runner`)}var be={idle:``,checking:`Checking for updates…`,downloading:`Downloading CLI…`,verifying:`Verifying CLI…`,extracting:`Extracting CLI…`,activating:`Activating CLI…`,removing:`Removing CLI…`,failed:``};function xe(e){let t=b().data?.capabilities?.settingsAdmin===!0,n=w(),r=[`runner-install`,e],i=T({queryKey:r,queryFn:()=>ve(e),enabled:t,retry:!1,refetchInterval:e=>{if(e.state.error)return!1;let t=e.state.data?.phase;return t&&t!==`idle`&&t!==`failed`?1e3:6e4}}),a=f({mutationFn:t=>ye(e,t),retry:!1,onSuccess:e=>{n.setQueryData(r,e)}}),o=i.data;return{allowed:t,data:o,busy:a.isPending||!!o&&o.phase!==`idle`&&o.phase!==`failed`,error:a.error?.message??i.error?.message??o?.error,action:a,status:i}}function Se({state:e}){let{data:t,busy:n,action:r,status:i}=e;if(t?.supported===!1)return(0,X.jsx)(`p`,{children:`This host is not supported by the CLI installer.`});let a=!!t?.installedVersion;return(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,X.jsx)(A,{className:`min-h-11 active:opacity-80`,disabled:n||!t,onClick:()=>r.mutate(a?`update`:`install`),children:a?`Update CLI`:`Install CLI`}),a?(0,X.jsx)(A,{className:`min-h-11 active:opacity-80`,variant:`outline`,disabled:n,onClick:()=>r.mutate(`remove`),children:`Remove CLI`}):null,(0,X.jsx)(A,{className:`min-h-11 active:opacity-80`,variant:`outline`,disabled:n,onClick:()=>{i.isError?i.refetch():r.mutate(`check`)},children:`Check for updates`})]})}function Ce({runner:e}){let t=xe(e),{allowed:n,data:r,busy:i,error:a}=t;return n?(0,X.jsxs)(`section`,{"aria-label":`CLI installation`,className:`grid gap-3`,children:[(0,X.jsxs)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:[r?.installedVersion?`Installed CLI ${r.installedVersion}`:`CLI not installed`,r?.latestVersion?` · Latest ${r.latestVersion}`:``,i&&r?` · ${be[r.phase]}`:``]}),a?(0,X.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:a}):null,(0,X.jsx)(Se,{state:t}),r?.installedVersion?(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Removing the CLI keeps account data and lets running tasks finish.`}):null]}):null}var we={connected:B(`connected`),disconnected:B(`disconnected`),"not-installed":B(`not-installed`),unknown:B(`unknown`)};function Te(){let e=p(),t=_();if(e.isPending||t.isPending)return(0,X.jsx)(`p`,{"data-slot":`accounts-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading agents…`});let n=e.error??t.error;return n?(0,X.jsx)(P,{icon:(0,X.jsx)(he,{}),tone:`danger`,title:`Agents did not load`,subtitle:n.message,heading:`h2`}):(0,X.jsx)(Oe,{data:e.data,runners:t.data})}function Ee(e){let t=e.replace(/^\/(?:home|Users)\/[^/]+/,`~`),n=t.split(`/`);return n.length>4?`…/${n.slice(-3).join(`/`)}`:t}function De(){let{hash:e}=O();(0,Y.useEffect)(()=>{if(!e)return;let t=document.getElementById(decodeURIComponent(e.slice(1)));t&&(t.scrollIntoView?.({block:`start`}),t.focus({preventScroll:!0}))},[e])}function Oe({data:e,runners:t}){let n=b(),[r,i]=(0,Y.useState)(null),[o,s]=(0,Y.useState)(null),c=a();return De(),pe(),(0,X.jsxs)(`div`,{"data-slot":`accounts-section`,className:`mx-auto flex w-full max-w-2xl flex-col gap-5 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:[(0,X.jsx)(fe,{risk:`Agent accounts run each CLI with the configured host folder`}),e.editable?null:(0,X.jsxs)(`p`,{"data-slot":`accounts-hosted`,className:`text-[13px] text-muted-foreground`,children:[`Agent accounts are read-only on this remote cockpit. Run`,` `,(0,X.jsx)(`code`,{children:me}),` on the host to add, edit, or sign in to accounts here.`]}),(0,X.jsx)(`div`,{"data-slot":`agent-cards`,className:`flex flex-col gap-3`,children:t.runners.map(r=>(0,X.jsx)(je,{entry:r,check:n.data?.checks?.find(e=>e.name===r.id),settingsAdmin:n.data?.capabilities?.settingsAdmin===!0,runners:t,editable:e.editable,accounts:e.profiles.filter(e=>e.provider===r.id),canCarryAccounts:e.profileCapableProviders.includes(r.id),onAdd:()=>i(r.id),onRemove:s},r.id))}),(0,X.jsx)(Me,{runners:t}),r===null?null:(0,X.jsx)(_e,{open:!0,onOpenChange:e=>!e&&i(null),providers:e.profileCapableProviders,initialProvider:r},r),(0,X.jsx)(I,{open:o!==null,onOpenChange:e=>!e&&s(null),children:(0,X.jsxs)(F,{"data-slot":`accounts-remove-confirm`,children:[(0,X.jsxs)(L,{children:[(0,X.jsxs)(U,{children:[`Remove “`,o?.label,`”?`]}),(0,X.jsxs)(R,{children:[`This only forgets the account. Nothing in `,o?.configDir??`this account’s folder`,` is deleted — not your login, not your sessions. Projects using it fall back to the default account, and tasks that ran under it can no longer be resumed from here.`]})]}),(0,X.jsxs)(G,{children:[(0,X.jsx)(H,{children:`Cancel`}),(0,X.jsx)(V,{"data-action":`accounts-remove-confirm`,disabled:c.isPending,onClick:()=>{let e=o;e&&c.mutate(e.id,{onSuccess:()=>{s(null),E(`Removed ${e.label}`)},onError:e=>E(e.message,{tone:`danger`})})},children:`Remove`})]})]})})]})}function ke({entry:e,check:t}){return t===void 0?(0,X.jsx)(`span`,{"data-slot":`agent-installed`,children:`Checking CLI…`}):t.available?(0,X.jsxs)(`span`,{className:`whitespace-nowrap`,children:[(0,X.jsx)(`span`,{"data-slot":`agent-installed`,children:K(t.version)?`CLI simulated`:`CLI installed`}),t.version?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`settings-agent-summary-sep`,children:`·`}),(0,X.jsx)(Z,{version:t.version})]}):null]}):(0,X.jsxs)(`span`,{"data-slot":`agent-installed`,children:[`CLI not installed`,e.installHint?(0,X.jsxs)(X.Fragment,{children:[` — `,(0,X.jsx)(`code`,{className:`break-all`,children:e.installHint})]}):null]})}function Z({version:e}){return K(e)?(0,X.jsx)(`span`,{"data-slot":`agent-version`,"data-dry-run":``,title:e,className:`rounded-full border border-border bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground`,children:le.label}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`sr-only`,children:`, version `}),(0,X.jsx)(`span`,{"data-slot":`agent-version`,className:`text-muted-foreground`,children:e})]})}function Ae({items:e}){let t=e.filter(e=>e!=null&&e!==!1);return t.length===0?null:(0,X.jsx)(`p`,{"data-slot":`agent-summary`,className:`settings-agent-summary`,children:t.map((e,t)=>(0,X.jsxs)(`span`,{className:`settings-agent-summary-item`,children:[t>0?(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`settings-agent-summary-sep`,children:`·`}):null,e]},t))})}function Q({titleId:e,title:t,summary:n,actions:r,actionsSlot:i}){return(0,X.jsxs)(`div`,{"data-slot":`agent-head`,className:`settings-agent-head`,children:[(0,X.jsxs)(`div`,{className:`settings-agent-heading`,children:[(0,X.jsx)(`h3`,{id:e,className:`settings-account-provider-title`,children:t}),(0,X.jsx)(Ae,{items:n})]}),r?(0,X.jsx)(`div`,{"data-slot":i,className:`settings-account-actions`,children:r}):null]})}function je({entry:e,check:t,settingsAdmin:n,runners:r,editable:i,accounts:a,canCarryAccounts:o,onAdd:s,onRemove:c}){let l=e.id,u=e.displayName,d=e.managedInstall===!0&&n,f=a.filter(e=>e.isDefault).length,p=`${N(l)}-title`,m=i&&o?(0,X.jsx)(A,{type:`button`,variant:`outline`,size:`sm`,"data-action":`accounts-add`,"data-provider":l,onClick:s,children:`Add account`}):null,h={titleId:p,title:u,facts:[d?null:(0,X.jsx)(ke,{entry:e,check:t}),i||a.length>0?(0,X.jsxs)(`span`,{className:`settings-account-count`,title:`${f} discovered, ${a.length-f} added`,children:[a.length,` `,a.length===1?`account`:`accounts`]}):null],addButton:m},[g,..._]=a;return(0,X.jsxs)(`section`,{id:N(l),tabIndex:-1,"aria-labelledby":p,"data-slot":`accounts-provider`,"data-provider":l,className:`settings-agent-card flex flex-col rounded-lg border border-border bg-card`,children:[g===void 0?(0,X.jsx)(Q,{titleId:p,title:u,summary:h.facts,actions:m,actionsSlot:`accounts-actions`}):null,d?(0,X.jsx)(Ce,{runner:l}):null,g===void 0?null:(0,X.jsxs)(`ul`,{className:`settings-agent-accounts`,children:[(0,X.jsx)($,{account:g,runners:r,editable:i,onRemove:()=>c(g),agent:h}),_.map(e=>(0,X.jsx)($,{account:e,runners:r,editable:i,onRemove:()=>c(e)},e.id))]}),i&&!o?(0,X.jsxs)(`p`,{"data-slot":`accounts-single-only`,className:`settings-agent-note`,children:[`One account only: `,u,` keeps its login outside its config folder, so a second folder would change settings without changing who is billed.`]}):!i&&a.length===0&&e.browserLogin?(0,X.jsxs)(`div`,{"data-slot":`hosted-sign-in`,className:`settings-agent-note flex flex-wrap items-center gap-3`,children:[(0,X.jsx)(`span`,{children:`Discovered account`}),(0,X.jsx)(J,{provider:l,label:u})]}):null]})}function Me({runners:e}){let[t,n]=(0,Y.useState)(null),a=w(),c=s(),l=i(),u=h(r(e)),p=f({mutationFn:e=>ee(e),onSuccess:e=>a.setQueryData(o.config,e),onError:e=>E(e.message,{tone:`danger`})});if(c.data===void 0)return null;let m=ue([],e),g=c.data.agentDefaults.runner??`claude`,_=d(t??g,r(e))??t??g,v=c.data.agentDefaults.models??{};return(0,X.jsxs)(`section`,{"data-slot":`accounts-defaults`,className:`flex flex-col gap-3 rounded-lg border border-border bg-card/40 p-3.5`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h3`,{className:`text-[13px] font-semibold text-foreground`,children:`Defaults for new projects`}),(0,X.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`What a project runs when it has not chosen for itself — set once instead of per repository. A project that has chosen keeps its own.`})]}),(0,X.jsx)(de,{rows:m,runner:g,accountFor:()=>null,providerStatus:l,disabled:p.isPending,onPick:e=>{e!==g&&p.mutate({agentDefaults:{runner:e}})}}),(0,X.jsxs)(`div`,{className:`settings-account-models flex flex-col gap-2`,children:[(0,X.jsxs)(`label`,{className:`settings-model-agent-choice`,children:[(0,X.jsx)(`span`,{children:`Default model for`}),(0,X.jsx)(q,{"aria-label":`Model agent`,value:_,onChange:e=>n(e.target.value),children:e.runners.map(e=>(0,X.jsx)(`option`,{value:e.id,children:e.displayName},e.id))})]}),e.runners.filter(e=>e.id===_).map(t=>(0,X.jsxs)(`label`,{className:`settings-account-model flex flex-wrap items-center gap-3`,children:[(0,X.jsx)(k,{className:`size-4 text-accent-icon shrink-0`}),(0,X.jsx)(`span`,{className:`w-28 shrink-0 text-xs text-muted-foreground`,children:t.displayName}),(0,X.jsxs)(q,{"aria-label":`Default model for ${t.pickerLabel}`,"data-slot":`accounts-default-model`,"data-runner":t.id,value:v[t.id]??``,disabled:p.isPending,onChange:e=>p.mutate({agentDefaults:{models:{[t.id]:e.target.value||null}}}),className:`block w-64 max-w-full rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,children:[z(t.id,e,u[t.id]?.data,[v[t.id]]).map(e=>(0,X.jsx)(`option`,{value:e.id,children:e.id===``?`Native default`:e.label},e.id)),(0,X.jsx)(Ne,{runner:t.id,runners:e,catalog:u[t.id]})]})]},t.id))]})]})}function Ne({runner:e,runners:t,catalog:n}){let r=W(e,t,n);return r?(0,X.jsx)(`option`,{disabled:!0,children:r}):null}function Pe({account:e,runners:t,status:n,editable:r}){let i=g();return(0,X.jsxs)(X.Fragment,{children:[n&&n.status!==`connected`&&l(t,e.provider)?.browserLogin?(0,X.jsx)(J,{provider:e.provider,...e.isDefault?{}:{profileId:e.id},label:e.label}):null,r&&n&&n.status!==`connected`&&l(t,e.provider)?.terminalLogin!==!1?(0,X.jsx)(A,{type:`button`,size:`sm`,"data-action":`account-connect`,disabled:i.isPending,onClick:()=>i.mutate({provider:e.provider,...e.isDefault?{}:{profileId:e.id}},{onSuccess:e=>E(e.opened?`Finish signing in in the terminal, then Check again.`:`This account is already connected.`),onError:e=>E(e instanceof x&&e.command?`${e.message} — run: ${e.command}`:e.message,{tone:`danger`})}),children:`Connect`}):null]})}function Fe(e,t,n,r){return!n||n.requiresAccountHome===!1?null:e.exists?!e.looksValid&&e.configDir?{slot:`account-unrecognised`,label:`Unrecognized folder`,guidance:`This folder does not look like ${u(t,e.provider)} config yet.`}:null:{slot:`account-missing`,label:`Not initialized`,guidance:r?n.status===`connected`?`Folder not created yet. Use Check again to refresh.`:`Folder not created yet. Connect will make it.`:`Folder not created on the host yet.`}}function $({account:e,runners:t,editable:n,onRemove:r,agent:i}){let a=S(e),o=y(),s=v(a,e.status===void 0),c=e.status??s.data?.status,l=c?we[c.status]:void 0,u=Fe(e,t,c,n),d=u?(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,title:l?`Sign-in: ${l.label}`:void 0,children:[(0,X.jsx)(M,{tone:`pending`}),(0,X.jsx)(`span`,{"data-slot":u.slot,className:`text-foreground`,children:u.label})]}):(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,X.jsx)(M,{tone:l?.tone??`neutral`,pulse:l===void 0}),(0,X.jsx)(`span`,{"data-slot":`account-status`,className:`text-foreground`,children:l?.label??`Checking…`})]}),f=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Pe,{account:e,runners:t,status:c,editable:n}),(0,X.jsx)(A,{type:`button`,variant:`outline`,size:`sm`,"data-action":`account-recheck`,disabled:o.isPending,title:`Re-probe this account's login now, instead of waiting for the cached answer`,onClick:()=>o.mutate(a,{onError:e=>E(e.message,{tone:`danger`})}),children:`Check again`})]}),p=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`settings-account-label`,children:e.label}),e.isDefault?(0,X.jsx)(re,{variant:`outline`,"data-slot":`account-discovered`,className:`shrink-0 text-xs font-normal text-muted-foreground`,children:`discovered`}):null]}),m=e.configDir?(0,X.jsx)(`span`,{"data-slot":`account-path`,className:`settings-account-path`,title:e.path,children:Ee(e.configDir)}):null,h=u?(0,X.jsx)(`p`,{"data-slot":`account-folder-guidance`,className:`settings-account-hint`,children:u.guidance}):null,g=c?.hint?(0,X.jsx)(`p`,{className:`settings-account-hint`,children:c.hint}):null,_=n&&!e.isDefault?(0,X.jsx)(Ie,{account:e,onRemove:r}):null,b=(0,X.jsxs)(`div`,{className:`settings-account-readout`,children:[(0,X.jsxs)(`div`,{className:`settings-account-meta-line`,children:[p,d]}),m,h,g]});return i?(0,X.jsxs)(`li`,{"data-slot":`account-row`,"data-account":e.id,"data-primary":``,className:`settings-account-primary`,children:[(0,X.jsx)(Q,{titleId:i.titleId,title:i.title,summary:i.facts,actions:(0,X.jsxs)(X.Fragment,{children:[f,i.addButton]}),actionsSlot:`account-actions`}),(0,X.jsxs)(`div`,{className:`settings-account-meta`,children:[b,_?(0,X.jsx)(`div`,{className:`settings-account-actions`,children:_}):null]})]}):(0,X.jsxs)(`li`,{"data-slot":`account-row`,"data-account":e.id,className:`settings-account-line`,children:[b,(0,X.jsxs)(`div`,{"data-slot":`account-actions`,className:`settings-account-actions`,children:[f,_]})]})}function Ie({account:e,onRemove:t}){let[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(e.label),o=c();return(0,X.jsx)(X.Fragment,{children:e.isDefault?null:(0,X.jsx)(`div`,{"data-slot":`account-manage`,className:`settings-account-management`,children:n?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`input`,{type:`text`,autoFocus:!0,"aria-label":`Name for ${e.label}`,"data-slot":`account-rename-input`,value:i,onChange:e=>a(e.target.value),className:`w-48 rounded-md border border-input bg-card px-2 py-1 text-xs outline-none focus-visible:border-ring`}),(0,X.jsx)(A,{type:`button`,size:`sm`,"data-action":`account-rename-save`,disabled:o.isPending||i.trim()===``||i.trim()===e.label,onClick:()=>o.mutate({id:e.id,label:i.trim()},{onSuccess:()=>r(!1),onError:e=>E(e.message,{tone:`danger`})}),children:`Save`}),(0,X.jsx)(A,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>{a(e.label),r(!1)},children:`Cancel`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(A,{type:`button`,variant:`outline`,size:`sm`,"data-action":`account-rename`,onClick:()=>r(!0),children:`Rename`}),(0,X.jsx)(A,{type:`button`,variant:`outline`,size:`sm`,"data-action":`account-remove`,onClick:t,children:`Remove account`}),(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Renaming changes what Squawk calls this account, not its folder.`})]})})})}export{Te as GlobalAgentsSection};
@@ -1,7 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{t as r}from"./utils-DSMR_WLb.js";import{$t as i,Wt as a,Zt as o,g as s,h as c,rn as l,x as u,yt as d}from"./queries-C0l1puJe.js";import{Fn as f,hi as p,n as m}from"./toaster-BYPWDBoi.js";import{t as h}from"./button-B7MKxYjT.js";import{t as g}from"./badge-DQ3U69Ht.js";import{t as _}from"./centered-state-V15AR_qo.js";import{A as v,cr as y,pn as b}from"./index-CDd7AdAu.js";import{n as x,r as S,t as C}from"./remote-settings-notice-B9h38exH.js";import{t as w}from"./code-editor-B4baSOhz.js";var T=e(t(),1);function E(e){return t=>t.runners.includes(e)}function D(e,t){let n=E(e);return e=>n(e)&&e.kind===t}function O(e){let{label:t,note:n,groups:r}=e.agentConfig;return{id:e.id,label:t,note:n,groups:r.map(({id:t,label:n,note:r,empty:i,showsUserMcp:a})=>({id:t,label:n,note:r,...i?{empty:i}:{},...a?{showsUserMcp:a}:{},files:D(e.id,t)}))}}function k(e){return o(e).map(O)}var A=n();function j(e){return e.seeded?`Copied into each run’s worktree — takes effect on your next run.`:e.tracked===`tracked`?`Runs read the committed copy — this edit applies after you commit it.`:e.tracked===`outside-repo`?`Applies to every session on this machine.`:`Personal, git-ignored.`}function M(){let e=c(),t=S(),n=d(),r=l(),a=r.data,o=(0,T.useMemo)(()=>k(a),[a]),s=(0,T.useMemo)(()=>n.data?v(n.data.checks,a):i(a),[n.data,a]);return r.isError?(0,A.jsx)(_,{icon:(0,A.jsx)(y,{}),tone:`danger`,title:`Runners did not load`,subtitle:r.error.message,heading:`h2`}):e.isError?(0,A.jsx)(_,{icon:(0,A.jsx)(y,{}),tone:`danger`,title:`Agent config did not load`,subtitle:e.error.message,heading:`h2`}):e.isPending||a===void 0?(0,A.jsx)(`p`,{"data-slot":`agent-config-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading agent config…`}):(0,A.jsx)(N,{listing:e.data,descriptors:o,installed:s,onOpenFile:t})}function N({listing:e,descriptors:t,installed:n,onOpenFile:i}){let[a,o]=(0,T.useState)(`claude`),[s,c]=(0,T.useState)(null),l=t.find(e=>e.id===a)??t[0];if(l===void 0)return null;let u=P(l,e),d=u.find(e=>e.id===s)??F(u),f=e=>{o(e),c(null)};return(0,A.jsxs)(`div`,{"data-slot":`agent-config`,className:`flex flex-col gap-5 p-4 md:p-6`,children:[(0,A.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Edit project, local, and user-wide config files for each coding agent.`}),!e.editable&&(0,A.jsxs)(`div`,{"data-slot":`agent-config-readonly`,className:`rounded-md border border-border bg-muted/40 px-3 py-2 text-[13px] text-muted-foreground`,children:[`Read-only: this remote cockpit cannot edit agent config. You can still see every file and which one wins. To edit here, the host operator runs `,(0,A.jsx)(`code`,{children:C}),`.`]}),(0,A.jsx)(x,{risk:`Agent config can define hooks and MCP servers that run commands on the machine running Squawk`}),(0,A.jsx)(`div`,{"data-slot":`agent-config-agents`,role:`tablist`,className:`flex flex-wrap gap-1`,children:t.map(e=>(0,A.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":e.id===l.id,"data-slot":`agent-config-agent`,"data-agent":e.id,"data-selected":e.id===l.id,onClick:()=>f(e.id),className:r(`flex min-w-11 items-center justify-center gap-2 rounded-md px-3 py-1.5 text-[13px] transition-colors`,e.id===l.id?`bg-background font-semibold shadow-sm`:`hover:bg-muted/60`),children:[e.label,!n.includes(e.id)&&(0,A.jsx)(g,{variant:`outline`,className:`text-xs text-soft-foreground`,children:`Not installed`})]},e.id))}),l.note&&(0,A.jsx)(`p`,{"data-slot":`agent-config-agent-note`,className:`text-xs text-muted-foreground`,children:l.note}),(0,A.jsxs)(`div`,{className:`grid min-w-0 gap-6 lg:grid-cols-[minmax(17rem,24rem)_minmax(0,1fr)]`,children:[(0,A.jsx)(`nav`,{"data-slot":`agent-config-nav`,className:`flex min-w-0 flex-col gap-5`,children:(0,A.jsx)(R,{agent:l,listing:e,selectedId:d?.id??null,onSelect:e=>{c(e),i()}})}),(0,A.jsx)(`div`,{"data-slot":`agent-config-editor-pane`,className:`min-w-0`,children:d?(0,A.jsx)(B,{file:d},d.id):(0,A.jsx)(`p`,{"data-slot":`agent-config-editor-empty`,className:`rounded-md border border-border bg-muted/40 px-4 py-3 text-[13px] text-soft-foreground`,children:`This agent has no config files to show.`})})]})]})}function P(e,t){return e.groups.flatMap(e=>t.files.filter(e.files))}function F(e){return e.find(e=>e.scope===`project`)??e[0]??null}var I={project:`Project scope`,local:`Local scope`,user:`User scope`};function L(e,t){for(let n of t){if(!n.label.startsWith(`~/`))continue;let t=n.label.slice(1);if(!n.path.endsWith(t))continue;let r=n.path.slice(0,n.path.length-t.length);if(r&&(e===r||e.startsWith(`${r}/`)))return`~${e.slice(r.length)}`}return e.replace(/^\/(?:home|Users)\/[^/]+(?=\/|$)/,`~`)}function R({agent:e,listing:t,selectedId:n,onSelect:i}){return(0,A.jsx)(A.Fragment,{children:e.groups.map(a=>{let o=t.files.filter(a.files),s=a.showsUserMcp?t.userMcp:void 0;return o.length===0&&!s&&!a.empty?null:(0,A.jsxs)(`section`,{"data-slot":`agent-config-group`,"data-group":a.id,"data-agent":e.id,children:[(0,A.jsx)(`p`,{className:`mb-1 text-xs font-medium uppercase tracking-wide text-soft-foreground`,children:a.label}),a.note&&(0,A.jsx)(`p`,{className:`mb-2 text-xs text-muted-foreground`,children:a.note}),o.length===0&&a.empty&&(0,A.jsx)(`p`,{"data-slot":`agent-config-group-empty`,className:`rounded-md border border-dashed border-border px-3 py-2 text-xs text-muted-foreground`,children:a.empty}),(0,A.jsx)(`ul`,{className:`flex flex-col gap-1`,children:o.map(e=>(0,A.jsx)(`li`,{children:(0,A.jsxs)(`button`,{type:`button`,"data-slot":`agent-config-file`,"data-selected":e.id===n,onClick:()=>i(e.id),title:e.label,className:r(`flex w-full flex-col items-start gap-1 rounded-md px-2 py-1.5 text-left text-[13px] transition-colors`,e.id===n?`bg-accent-strong/15 text-foreground`:`hover:bg-muted/60`),children:[(0,A.jsx)(`span`,{"data-slot":`agent-config-file-name`,className:`min-w-0 max-w-full break-all font-mono text-[12px]`,children:e.label}),e.seeded||!e.exists?(0,A.jsxs)(`span`,{"data-slot":`agent-config-file-meta`,className:`flex flex-wrap items-center gap-1.5`,children:[e.seeded&&(0,A.jsx)(g,{variant:`outline`,className:`text-xs`,children:`Default template`}),!e.exists&&(0,A.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Not created`})]}):null]})},e.id))}),s&&(0,A.jsx)(z,{userMcp:s,path:L(s.path,t.files)})]},a.id)})})}function z({userMcp:e,path:t}){return(0,A.jsxs)(`div`,{"data-slot":`agent-config-user-mcp`,className:`mt-3`,children:[(0,A.jsx)(`h4`,{className:`mb-1 text-[12px] font-semibold`,children:`User & local scopes`}),(0,A.jsxs)(`p`,{className:`mb-2 text-xs text-muted-foreground`,children:[`Managed by `,(0,A.jsx)(`code`,{"data-slot":`agent-config-user-mcp-command`,className:`whitespace-nowrap font-mono`,children:`claude mcp add`}),` in`,` `,(0,A.jsx)(`code`,{"data-slot":`agent-config-user-mcp-path`,title:e.path,className:`break-all font-mono text-foreground`,children:t}),` — Squawk does not edit Claude’s state file.`]}),e.readable?e.servers.length>0?(0,A.jsx)(`ul`,{className:`flex flex-wrap gap-1`,children:e.servers.map(e=>(0,A.jsx)(`li`,{children:(0,A.jsx)(g,{variant:`outline`,className:`font-mono text-xs`,children:e})},e))}):(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No user-scoped MCP servers.`}):(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Could not read the file.`})]})}function B({file:e}){let t=s(e.id),[n,r]=(0,T.useState)(null),[i,a]=(0,T.useState)(!1),[o,c]=(0,T.useState)(null),l=t.data?.version??null,u=n??t.data?.content??``,d=t.data?u!==t.data.content:!1,f=e.writable,p=e.kind===`mcp`||e.holdsMcp;b(f&&d);let{save:m,isSaving:h}=K({file:e,content:u,loadedVersion:l,setDraft:r,setConflict:a,setFormatError:c});return(0,T.useEffect)(()=>{t.data&&(r(t.data.content),a(!1),c(null))},[t.data?.version,t.data]),(0,A.jsxs)(`div`,{"data-slot":`settings-config-editor`,"data-reports-dirty":``,className:`flex flex-col gap-3`,children:[(0,A.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,A.jsx)(`h3`,{className:`text-sm`,children:`Configuration file`}),(0,A.jsx)(g,{variant:`outline`,"data-slot":`agent-config-scope`,"data-scope":e.scope,className:`text-[12px]`,children:I[e.scope]})]}),(0,A.jsx)(`p`,{"data-slot":`agent-config-path`,title:e.path,className:`font-mono text-xs text-foreground`,children:L(e.path,[e])}),(0,A.jsxs)(`div`,{className:`settings-readout flex flex-wrap items-center gap-2`,children:[(0,A.jsx)(`span`,{className:`font-mono text-[13px]`,children:e.label}),(0,A.jsx)(g,{variant:`outline`,className:`text-[12px] uppercase`,children:e.format}),(0,A.jsx)(`a`,{href:e.docsUrl,target:`_blank`,rel:`noreferrer`,className:`text-[12px] text-soft-foreground underline hover:text-foreground`,children:`docs`})]}),(0,A.jsxs)(`div`,{className:`settings-config-content-heading`,children:[(0,A.jsx)(`h3`,{children:p?`MCP configuration`:`File contents`}),p&&(0,A.jsx)(`p`,{children:`Review server commands before saving. MCP servers execute locally.`})]}),t.isPending?(0,A.jsx)(`p`,{className:`text-[13px] text-soft-foreground`,children:`Loading file…`}):t.isError?(0,A.jsx)(`p`,{className:`text-[13px] text-destructive`,children:t.error.message}):(0,A.jsx)(V,{file:e,content:u,isMcp:p,onChange:r}),(0,A.jsx)(W,{formatError:o,conflict:i,onReload:()=>void t.refetch()}),f&&(0,A.jsx)(H,{exists:e.exists,dirty:d,isSaving:h,onSave:m,onReset:()=>r(null)}),(0,A.jsxs)(`div`,{className:`settings-config-save-help`,children:[(0,A.jsx)(`p`,{"data-slot":`agent-config-precedence`,className:`text-xs text-muted-foreground`,children:e.precedence}),(0,A.jsxs)(`p`,{"data-slot":`agent-config-effect`,className:`text-xs text-foreground`,children:[j(e),e.hotReload?` ${e.hotReload}`:``]}),(0,A.jsx)(G,{reason:e.readOnlyReason})]})]})}function V({file:e,content:t,isMcp:n,onChange:r}){return(0,A.jsxs)(`div`,{"data-slot":`agent-config-editor-frame`,className:`relative`,children:[(0,A.jsx)(w,{value:t,language:e.format,readOnly:!e.writable,onChange:r,"aria-label":`${e.label} contents`,className:`h-[210px]`}),!e.exists&&t===``&&(0,A.jsx)(`pre`,{"data-slot":`agent-config-placeholder`,"aria-hidden":`true`,className:`pointer-events-none absolute inset-px m-0 overflow-hidden whitespace-pre px-3 py-2 font-mono text-xs leading-[1.7] text-soft-foreground`,children:U(e,n)})]})}function H({exists:e,dirty:t,isSaving:n,onSave:r,onReset:i}){return(0,A.jsxs)(`div`,{className:`settings-form-actions`,children:[(0,A.jsx)(h,{size:`sm`,onClick:r,disabled:!t||n,children:e?`Save file`:`Create file`}),(0,A.jsx)(h,{size:`sm`,variant:`outline`,onClick:i,disabled:!t||n,children:`Reset`}),!n&&(0,A.jsx)(`span`,{"data-slot":`agent-config-save-cue`,className:`self-center text-xs text-muted-foreground`,children:t?`Unsaved changes`:e?`No unsaved changes`:`Enter content above to create this file`})]})}function U(e,t){switch(e.format){case`json`:case`jsonc`:return`// File not created yet — example:\n${t?`{
2
- "mcpServers": {}
3
- }`:`{
4
- "permissions": {}
5
- }`}`;case`markdown`:return`<!-- File not created yet — write instructions here -->`;case`toml`:return`# File not created yet — example:
6
- # key = "value"`;case`yaml`:return`# File not created yet — example:
7
- # key: value`}}function W({formatError:e,conflict:t,onReload:n}){return(0,A.jsxs)(A.Fragment,{children:[e&&(0,A.jsx)(`p`,{"data-slot":`agent-config-format-error`,className:`text-[12px] text-destructive`,children:e}),t&&(0,A.jsxs)(`div`,{"data-slot":`agent-config-conflict`,className:`flex items-center justify-between gap-2 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-[12px]`,children:[(0,A.jsx)(`span`,{children:`The file changed on disk since you opened it.`}),(0,A.jsx)(h,{size:`sm`,variant:`outline`,onClick:n,children:`Reload from disk`})]})]})}function G({reason:e}){return e&&(0,A.jsx)(`p`,{children:e})}function K({file:e,content:t,loadedVersion:n,setDraft:r,setConflict:i,setFormatError:o}){let s=u(e.id),c=p(),l=S();return{save:()=>{o(null),i(!1),s.mutate({content:t,version:n},{onSuccess:()=>{r(null),m(`${e.exists?`Saved`:`Created`} ${e.label}`)},onError:e=>{e instanceof f&&e.status===409?l().then(()=>{c.getQueryData(a.health)?.capabilities.settingsAdmin===!1?m(e.message,{tone:`danger`}):i(!0)}):e instanceof f&&e.status===400?o(e.message):m(e.message,{tone:`danger`})}})},isSaving:s.isPending}}export{M as AgentConfigSection};
@@ -1 +0,0 @@
1
- import{An as e,Tn as t}from"./toaster-BYPWDBoi.js";function n(n){return t[e(n).bucket]<=t.waiting}export{n as t};
@@ -1,2 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{t as r}from"./utils-DSMR_WLb.js";import{A as i,_ as a,nn as o,rn as s,sn as c,tn as l}from"./queries-C0l1puJe.js";import{B as u,Fn as d,H as f,Ur as p,V as m,_ as h,ar as g,c as ee,d as _,g as v,ir as y,ni as b,nr as x,o as te,s as S,sr as ne,ti as re,v as ie,z as ae}from"./toaster-BYPWDBoi.js";import{B as C,G as oe,H as w,I as T,K as se,N as E,P as D,V as ce,W as O,j as k,z as A}from"./live-protocol-DMhTnCmf.js";import{h as le}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{r as ue,t as j}from"./label-DF0V6WoC.js";import{I as de,J as fe,Y as pe,it as me,l as he,pt as ge,ut as _e,y as ve}from"./design-icons-CzEoMH9c.js";import{t as ye}from"./check-OP-CVgZG.js";import{t as M}from"./button-B7MKxYjT.js";import{n as be,r as xe,t as Se}from"./collapsible-BEV4FO-1.js";import{a as N,i as P,n as F,r as I,t as L}from"./select-B_nJiiFA.js";import{t as Ce}from"./switch-DKqVf8-p.js";import{c as we,s as Te,t as R}from"./project-router-p_FJwg-L.js";import{a as Ee,c as De,d as Oe,n as ke,s as z,u as B}from"./page-shell-7pLJMOgh.js";import{t as Ae}from"./centered-state-V15AR_qo.js";import{D as je,G as Me,In as Ne,Ln as Pe,N as Fe,O as Ie,Sn as Le,W as Re,Zn as V,k as ze,mn as Be,q as Ve,r as He,t as Ue,ur as We,vn as Ge}from"./index-CDd7AdAu.js";import{t as Ke}from"./textarea-vJt9undk.js";import{_ as qe,a as Je,c as Ye,d as Xe,f as Ze,g as Qe,h as $e,i as et,l as tt,m as nt,n as rt,o as it,p as at,r as ot,s as st,t as H,u as ct,v as lt}from"./automation-format-DB34jUyF.js";var U=e(t(),1),W=k([`pull_request.opened`,`issue.opened`,`issue.labeled`,`issue.unlabeled`]),ut=C({includeExisting:D().optional(),authors:E(O()).optional(),assignees:E(O()).optional(),requireCurrentLabels:D().optional(),allLabels:E(O()).optional(),anyLabels:E(O()).optional(),excludeLabels:E(O()).optional(),changedLabels:E(O()).optional(),lookbackDays:A(),maxRecords:A()}),dt=k([`github`,`schedule`]),ft=x.omit({task:!0,images:!0,systemPrompt:!0}).extend({prompt:O(),variants:oe([T(1),T(2),T(3)]).optional(),systemPrompt:O().optional()}),pt=C({at:O(),outcome:k([`launched`,`cancelled`]),runId:O().optional(),receiptId:O().optional(),trigger:k([`schedule`,`late`,`manual`,`retry`]).optional()}),G=C({id:O(),revision:A(),name:O(),description:O().optional(),enabled:D(),kind:dt,events:E(W).optional(),intervalSeconds:A().optional(),filters:ut.optional(),schedule:Ye.optional(),task:ft,archived:pt.optional(),createdAt:O(),updatedAt:O()}),K=C({timestamp:O(),tieBreaker:O().optional()}),mt=C({since:O().datetime(),until:O().datetime(),source:A().int().min(0).max(2),page:A().int().min(1).max(10),item:A().int().min(0).max(100),event:A().int().min(0).max(1e3),cursor:K.optional()}),ht={lastError:O().max(1e3).optional(),lastErrorAt:O().datetime().optional()},gt=C({revision:A().optional(),baselineAt:O().optional(),armedAt:O().optional(),historyScan:mt.optional(),cursor:K.optional(),frozenHighWatermark:K.extend({tieBreaker:O()}).optional(),backlogAfter:K.extend({tieBreaker:O()}).optional(),nextCheckAt:O().optional(),lastSuccessAt:O().optional(),nextRunAt:O().optional(),lastRunAt:O().optional(),etags:w(O(),O()).optional(),backoffUntil:O().optional(),consecutiveFailures:A().optional(),...ht,onceOutcome:k([`failed`,`missed`]).optional()});function _t(e){let t=e?.consecutiveFailures??0;if(!(t<3||!e?.lastError))return{consecutiveFailures:t,lastError:e.lastError,...e.lastErrorAt?{lastErrorAt:e.lastErrorAt}:{},...e.backoffUntil?{retryAt:e.backoffUntil}:{}}}var vt=k([`launched`,`no-match`,`duplicate`,`rate-limited`,`error`,`baseline`,`preview`,`skipped`,`manual`,`catch-up`,`failed`,`missed`]),yt=C({seq:A(),ts:O(),automationId:O(),revision:A(),event:W.optional(),result:vt,reason:O().optional(),durationMs:A().optional(),receiptId:O().optional(),runId:O().optional(),githubNumber:A().optional(),githubTitle:O().optional(),githubUrl:O().optional(),rateLimit:C({bucket:k([`core`,`search`]),remaining:A().optional(),resetAt:O().optional()}).optional()}),bt=C({matches:A(),launched:A(),duplicates:A(),errors:A()}),xt=G.extend({state:gt.optional(),latestLog:yt.optional(),counts:bt,nextRunAt:O().optional(),onceStatus:at.optional()});C({available:D(),reason:O().optional(),timeZone:O(),scheduler:C({state:k([`scheduled`,`idle`]),nextDue:O().optional()}),automations:E(xt)}),C({automation:G}).extend({once:C({dueAt:O(),timeZone:O(),resolvedInstant:O(),note:O()}).optional()}),C({automation:G,state:gt.optional(),latestLog:yt.optional(),onceStatus:at.optional()}),C({id:O(),automationId:O(),mode:k([`preview`,`execute`]),status:k([`queued`,`running`,`complete`,`error`]),createdAt:O(),completedAt:O().optional(),matches:A().optional(),truncated:D().optional(),error:O().optional()}),C({checkId:O()}),C({records:E(yt)}),C({receiptId:O(),runId:O()}),C({runId:O()}),G.omit({id:!0,revision:!0,createdAt:!0,updatedAt:!0,enabled:!0,kind:!0,archived:!0}).extend({kind:dt.optional(),task:ft.omit({variants:!0}).strict(),enable:D().optional()}).omit({enable:!0}).extend({enabled:D().optional(),expectedRevision:A()}),C({archived:k([`include`,`only`]).optional()}),C({mode:k([`preview`,`execute`])});var q=n();function J({text:e}){return(0,q.jsx)(`div`,{role:`status`,className:`rounded-xl border border-border bg-card p-6 text-sm text-muted-foreground`,children:e})}var St={launched:`success`,manual:`success`,"catch-up":`success`,skipped:`neutral`,missed:`pending`,"no-match":`neutral`,preview:`neutral`,baseline:`neutral`,duplicate:`neutral`,failed:`danger`,error:`danger`,"rate-limited":`danger`},Ct={launched:`Launched`,manual:`Manual`,"catch-up":`Catch up`,skipped:`Skipped`,missed:`Missed`,"no-match":`No match`,preview:`Preview`,baseline:`Baseline`,duplicate:`Duplicate`,failed:`Failed`,error:`Error`,"rate-limited":`Rate limited`};function wt(e){let[t,n]=(0,U.useState)(),[r,i]=(0,U.useState)(``),a=(0,U.useCallback)(t=>h(e,{signal:t}).then(({records:e})=>{t?.aborted||(n(e),i(``))}).catch(e=>{t?.aborted||i(String(e))}),[e]);return(0,U.useEffect)(()=>{a()},[a]),(0,U.useEffect)(()=>p(a),[a]),(0,U.useEffect)(()=>ue((t,n)=>{t===`automation-change`&&n.automationId===e&&a()}),[e,a]),{records:t,error:r,refresh:a}}function Tt(e,t){return e.result!==`failed`&&e.result!==`error`||!e.receiptId||e.runId?!1:!t.some(t=>t.receiptId===e.receiptId&&(t.runId||t.seq>e.seq))}function Et({records:e,all:t,timeZone:n,onRetried:r,readOnly:i=!1}){let a=e=>!i&&Tt(e,t),[o,s]=(0,U.useState)(),[c,l]=(0,U.useState)(),u=Date.now(),d=async e=>{s(e),l(void 0);try{await ae(e),r()}catch(t){l({receiptId:e,message:t instanceof Error?t.message:String(t)})}finally{s(void 0)}};return(0,q.jsx)(`ol`,{className:`grid gap-3`,"aria-label":`Automation execution log`,children:e.map(e=>(0,q.jsxs)(`li`,{className:`min-w-0 rounded-xl border border-card-edge bg-card p-4 shadow-card`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,q.jsx)(He,{dot:St[e.result],children:Ct[e.result]}),(0,q.jsx)(`time`,{className:`text-xs text-muted-foreground`,dateTime:e.ts,title:e.ts,children:rt(e.ts,n,u)})]}),e.reason?(0,q.jsx)(`p`,{className:`mt-2 text-sm break-words text-muted-foreground`,children:e.reason}):null,e.githubUrl||e.runId||a(e)?(0,q.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-4 gap-y-2 text-sm`,children:[e.githubUrl?(0,q.jsx)(`a`,{className:`inline-flex min-h-11 items-center underline underline-offset-4 break-all`,href:e.githubUrl,target:`_blank`,rel:`noreferrer`,children:e.githubTitle??`GitHub #${e.githubNumber??``}`}):null,e.runId?(0,q.jsx)(R,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${e.runId}`,children:`Open task`}):null,a(e)?(0,q.jsx)(M,{variant:`outline`,disabled:o===e.receiptId,onClick:()=>void d(e.receiptId),children:`Retry task`}):null]}):null,c&&c.receiptId===e.receiptId?(0,q.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm break-words text-destructive`,children:c.message}):null]},e.seq))})}var Y=`all`;function Dt({label:e,value:t,onChange:n,options:r}){return(0,q.jsxs)(L,{value:t,onValueChange:n,children:[(0,q.jsx)(P,{"aria-label":e,className:`w-full sm:w-52`,children:(0,q.jsx)(N,{})}),(0,q.jsx)(F,{children:r.map(e=>(0,q.jsx)(I,{value:e.value,children:e.label},e.value))})]})}function Ot({automationId:e,automationName:t,timeZone:n,readOnly:r=!1}){let{records:i,error:a,refresh:o}=wt(e),[s,c]=(0,U.useState)(Y),[l,u]=(0,U.useState)(Y),d=(0,U.useMemo)(()=>(i??[]).filter(e=>(s===Y||e.result===s)&&(l===Y||e.event===l)),[i,s,l]),f=(i??[]).some(e=>e.event);return(0,q.jsx)(De,{route:`automations`,density:i?Oe(d.length):`full`,header:{title:`Execution log`,subtitle:t??`Automation activity`,secondaryActions:(0,q.jsx)(z,{variant:`outline`,asChild:!0,children:(0,q.jsx)(R,{to:`/automations`,children:`Back to automations`})})},children:a&&!i?(0,q.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,q.jsx)(J,{text:a}),(0,q.jsx)(M,{variant:`outline`,onClick:()=>void o(),children:`Retry`})]}):i?i.length===0?(0,q.jsx)(J,{text:`Nothing has run yet.`}):(0,q.jsxs)(`div`,{className:`grid gap-4`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,q.jsx)(Dt,{label:`Result`,value:s,onChange:c,options:[{value:Y,label:`All results`},...vt.options.map(e=>({value:e,label:Ct[e]}))]}),f?(0,q.jsx)(Dt,{label:`Event`,value:l,onChange:u,options:[{value:Y,label:`All events`},...W.options.map(e=>({value:e,label:e}))]}):null]}),d.length===0?(0,q.jsx)(J,{text:`No rows match these filters.`}):(0,q.jsx)(Et,{records:d,all:i,timeZone:n,onRetried:()=>void o(),readOnly:r})]}):(0,q.jsx)(J,{text:`Loading execution log…`})})}function kt({automationId:e,automationName:t,timeZone:n,showName:r=!1,readOnly:i=!1}){let{records:a,error:o,refresh:s}=wt(e),c=`Recent activity${r&&t?` · ${t}`:``}`;return!o&&a&&a.length===0?(0,q.jsxs)(`section`,{"data-slot":`automation-inline-log`,className:`flex flex-wrap items-center gap-x-2 border-t border-border pt-2.5 text-xs text-muted-foreground`,children:[(0,q.jsx)(`h3`,{className:`font-medium text-foreground`,children:c}),(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,q.jsx)(`p`,{children:`Nothing has run yet.`})]}):(0,q.jsxs)(`section`,{"data-slot":`automation-inline-log`,className:`min-w-0 border-t border-border pt-2.5`,children:[(0,q.jsx)(`h3`,{className:`mb-1.5 text-xs font-medium text-muted-foreground`,children:c}),o&&!a?(0,q.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[(0,q.jsx)(J,{text:o}),(0,q.jsx)(M,{variant:`outline`,onClick:()=>void s(),children:`Retry`})]}):a?(0,q.jsx)(Et,{records:a.slice(0,5),all:a,timeZone:n,onRetried:()=>void s(),readOnly:i}):(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Loading activity…`})]})}function At({automation:e,timeZone:t,onDeleted:n}){let r=e.archived,i=e.schedule,a=i?ot(i):null,[o,s]=(0,U.useState)(!1),[c,l]=(0,U.useState)(!1),[u,d]=(0,U.useState)(``),f=(0,U.useRef)(null),p=(0,U.useRef)(null),m=(0,U.useRef)(null);(0,U.useEffect)(()=>{let e=m.current===`keep`?p.current:m.current===`delete`?f.current:null;m.current=null,e?.focus()},[o]);let h=async()=>{l(!0);try{await _(e.id),n()}catch(e){d(e instanceof Error?e.message:String(e)),l(!1)}},g=[[`Workflow`,e.task.workflow],[`Runner`,e.task.runner],[`Model`,e.task.model],[`Effort`,e.task.effort]];return(0,q.jsx)(De,{route:`automations`,density:`sparse`,header:{title:e.name,subtitle:`Archived one-time schedule. It cannot change; delete it when you no longer need the record.`},children:(0,q.jsxs)(`div`,{className:`grid min-w-0 gap-5`,children:[(0,q.jsxs)(`section`,{className:`min-w-0 rounded-xl border border-card-edge bg-card shadow-card p-4`,children:[(0,q.jsxs)(`p`,{className:`text-sm break-words`,children:[(0,q.jsx)(`span`,{children:r.outcome===`launched`?`Started its task.`:`Cancelled — no task was started.`}),r.runId?(0,q.jsxs)(q.Fragment,{children:[` · `,(0,q.jsx)(R,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${r.runId}`,children:`Open task`})]}):null]}),(0,q.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Archived ${H(r.at,t)} (${t}).`}),a&&i?.timeZone?(0,q.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Was due ${a.date} ${a.time} (${i.timeZone}).`}):null]}),(0,q.jsxs)(`section`,{"aria-labelledby":`archived-inputs`,className:`min-w-0 rounded-xl border border-card-edge bg-card shadow-card p-4`,children:[(0,q.jsx)(`h2`,{id:`archived-inputs`,className:`mb-3 text-[15px] font-medium`,children:`What it ran with`}),(0,q.jsxs)(`dl`,{className:`grid gap-3 text-sm`,children:[(0,q.jsxs)(`div`,{className:`grid gap-1`,children:[(0,q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Prompt`}),(0,q.jsx)(`dd`,{className:`break-words whitespace-pre-wrap`,children:e.task.prompt})]}),g.filter(([,e])=>e).map(([e,t])=>(0,q.jsxs)(`div`,{className:`grid gap-1`,children:[(0,q.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,q.jsx)(`dd`,{className:`break-words`,children:t})]},e))]})]}),(0,q.jsxs)(`section`,{className:`min-w-0`,children:[(0,q.jsx)(kt,{automationId:e.id,automationName:e.name,timeZone:t,readOnly:!0}),(0,q.jsx)(M,{variant:`outline`,asChild:!0,className:`mt-3`,children:(0,q.jsx)(R,{to:`/automations/${e.id}/log`,children:`Execution log`})})]}),(0,q.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[o?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`text-sm break-words`,children:`Delete “${e.name}”? Its record and log are removed; the task stays.`}),(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,q.jsx)(M,{variant:`danger-ghost`,"data-action":`automation-delete-confirm`,disabled:c,onClick:()=>void h(),children:`Delete schedule`}),(0,q.jsx)(M,{ref:p,variant:`outline`,disabled:c,onClick:()=>{m.current=`delete`,s(!1)},children:`Keep`})]})]}):(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,q.jsx)(M,{ref:f,variant:`outline`,"data-action":`automation-delete`,onClick:()=>{m.current=`keep`,s(!0)},children:`Delete`}),(0,q.jsx)(M,{variant:`outline`,asChild:!0,children:(0,q.jsx)(R,{to:`/automations`,children:`Back to automations`})})]}),u?(0,q.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:u}):null]})]})})}var jt=k([`pull_request.opened`,`issue.opened`,`issue.labeled`,`issue.unlabeled`]),X=E(O().trim().min(1).max(200)).max(100).optional(),Mt=C({includeExisting:D().optional(),requireCurrentLabels:D().optional(),authors:X,assignees:X,allLabels:X,anyLabels:X,excludeLabels:X,changedLabels:X,lookbackDays:A().int().min(1).max(90).default(7),maxRecords:A().int().min(1).max(100).default(25)}).passthrough(),Nt=C({prompt:O().min(1).max(1e5),workflow:O().trim().min(1).max(200).optional(),steps:E(y).min(1).max(100).optional(),runner:re.optional(),model:O().trim().min(1).max(200).optional(),effort:O().trim().min(1).max(32).optional(),variants:oe([T(1),T(2),T(3)]).optional(),worktree:D().optional(),autonomous:D().optional(),...g,...ne,systemPrompt:O().max(1e5).optional()}).passthrough().refine(e=>!(e.workflow&&e.steps),{message:`task selects either a named workflow or inline steps, not both`}),Pt=new Set(Object.keys(Nt.shape).filter(e=>e!==`variants`));function Ft(e){return Object.fromEntries(Object.entries(e).filter(([e])=>Pt.has(e)))}ce(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return e;let t=e;return t.kind===`schedule`?e:{...t,intervalSeconds:t.intervalSeconds??300,filters:t.filters??{}}},C({id:O().min(1).max(100),revision:A().int().positive(),name:O().trim().min(1).max(200),description:O().max(2e3).optional(),enabled:D().default(!1),kind:dt.default(`github`),events:E(jt).min(1).max(4).optional(),intervalSeconds:A().int().min(60).max(86400).optional(),filters:Mt.optional(),schedule:Ye.passthrough().optional(),task:Nt,archived:C({at:O().datetime(),outcome:k([`launched`,`cancelled`]),runId:O().optional(),receiptId:O().optional(),trigger:k([`schedule`,`late`,`manual`,`retry`]).optional()}).passthrough().optional(),createdAt:O().datetime(),updatedAt:O().datetime()}).passthrough().superRefine((e,t)=>{if(e.kind===`schedule`){e.schedule||t.addIssue({code:b.custom,path:[`schedule`],message:`a scheduled automation needs a schedule`});return}e.events?.length||t.addIssue({code:b.custom,path:[`events`],message:`a GitHub automation needs at least one event`}),e.intervalSeconds===void 0&&t.addIssue({code:b.custom,path:[`intervalSeconds`],message:`a GitHub automation needs a poll interval`}),e.filters||t.addIssue({code:b.custom,path:[`filters`],message:`a GitHub automation needs its bounded filter`}),e.events?.some(e=>e===`issue.labeled`||e===`issue.unlabeled`)&&!e.filters?.changedLabels?.length&&t.addIssue({code:b.custom,path:[`filters`,`changedLabels`],message:`changedLabels is required for issue label events`})})),C({version:T(1).default(1),automations:E(se()).default([]),tombstones:w(O(),O().datetime()).optional()}).passthrough();var It=C({timestamp:O().datetime(),tieBreaker:O().optional()}).passthrough(),Lt=mt.extend({cursor:It.optional()}),Rt=C({revision:A().int().positive().optional(),baselineAt:O().datetime().optional(),armedAt:O().datetime().optional(),historyScan:Lt.optional(),cursor:It.optional(),frozenHighWatermark:It.extend({tieBreaker:O()}).optional(),backlogAfter:It.extend({tieBreaker:O()}).optional(),nextCheckAt:O().datetime().optional(),lastSuccessAt:O().datetime().optional(),nextRunAt:O().datetime().optional(),lastRunAt:O().datetime().optional(),etags:w(O(),O()).optional(),backoffUntil:O().datetime().optional(),consecutiveFailures:A().int().nonnegative().optional(),...ht,onceOutcome:k([`failed`,`missed`]).optional()}).passthrough();C({version:T(1).default(1),states:w(O(),Rt).default({})}).passthrough(),C({receiptId:O().min(1),receiptKey:O().min(1),eventId:O().min(1),automationId:O().min(1),revision:A().int().positive(),status:k([`reserved`,`launched`,`launch-error`,`released`]),runId:O().optional(),observedAt:O().datetime(),updatedAt:O().datetime(),error:O().max(2e3).optional(),occurrenceAt:O().datetime().optional(),candidate:C({eventId:O(),event:jt,timestamp:O().datetime(),tieBreaker:O(),repo:O(),nodeId:O(),number:A().int().positive(),title:O().max(500),url:O().url(),author:O().max(200),assignees:E(O().max(200)).max(100),labels:E(O().max(200)).max(100),changedLabel:O().max(200).optional()}).passthrough().optional()}).passthrough();var zt=k([`launched`,`no-match`,`duplicate`,`rate-limited`,`error`,`baseline`,`preview`,`skipped`,`manual`,`catch-up`,`failed`,`missed`]);C({seq:A().int().positive(),ts:O().datetime(),automationId:O().min(1),revision:A().int().positive(),event:jt.optional(),result:zt,reason:O().max(2e3).optional(),durationMs:A().int().nonnegative().optional(),receiptId:O().optional(),runId:O().optional(),githubNumber:A().int().positive().optional(),githubTitle:O().max(500).optional(),githubUrl:O().url().optional(),rateLimit:C({bucket:k([`core`,`search`]),remaining:A().int().nonnegative().optional(),resetAt:O().datetime().optional()}).passthrough().optional()}).passthrough();var Bt=`quick-task`;function Vt(e={}){let{prompt:t,workflow:n,runner:r,model:i,autonomous:a,archiveWhenDone:o,autoMergePr:s,allowWorkers:c,allowMessaging:l,...u}=Ft(e.task??{prompt:``}),d=e.task===void 0;return{name:e.name??``,description:e.description??``,kind:e.kind??`schedule`,schedule:ct(e.schedule??{type:`daily`}),events:e.events??[`issue.opened`],intervalSeconds:e.intervalSeconds??300,filters:e.filters??{lookbackDays:7,maxRecords:25},prompt:t,...n===void 0?d?{workflow:Bt}:{}:{workflow:n},...r===void 0?{}:{runner:r},...i===void 0?{}:{model:i},autonomous:a??!0,archiveWhenDone:o??!1,autoMergePr:s??!1,allowWorkers:c!==!1,allowMessaging:l!==!1,enabled:e.enabled??e.enable??!1,taskExtra:u}}function Ht(e){switch(e.type){case`daily`:case`weekdays`:return{type:e.type,hour:e.hour,minute:e.minute};case`weekly`:return{type:`weekly`,hour:e.hour,minute:e.minute,day:e.day};case`hours`:return{type:`hours`,every:e.every};case`once`:return{type:`once`,at:e.at??``,timeZone:e.timeZone??``,...e.latestStartMinutes===void 0?{}:{latestStartMinutes:e.latestStartMinutes}}}}function Ut(e){return{...e.taskExtra,prompt:e.prompt,...e.workflow?{workflow:e.workflow}:{},...e.runner?{runner:e.runner}:{},...e.model?{model:e.model}:{},autonomous:e.autonomous,...e.archiveWhenDone?{archiveWhenDone:!0}:{},...e.autoMergePr?{autoMergePr:!0}:{},...e.allowWorkers?{}:{allowWorkers:!1},...e.allowMessaging?{}:{allowMessaging:!1}}}function Wt(e){return{name:e.name.trim(),...e.description.trim()?{description:e.description.trim()}:{},kind:e.kind,...e.kind===`schedule`?{schedule:Ht(e.schedule)}:{events:e.events,intervalSeconds:e.intervalSeconds,filters:e.filters},task:Ut(e)}}function Gt(e){return{...Wt(e),enable:e.enabled}}function Kt(e,t){return{...Wt(e),task:{...Ut(e),archiveWhenDone:e.archiveWhenDone,autoMergePr:e.autoMergePr,allowWorkers:e.allowWorkers,allowMessaging:e.allowMessaging},enabled:e.enabled,expectedRevision:t}}function Z(e){return`'${e.replace(/'/g,`'\\''`)}'`}var qt=new Set([`prompt`,`workflow`,`runner`,`model`,`autonomous`,`worktree`,`archiveWhenDone`,`autoMergePr`,`allowWorkers`,`allowMessaging`]),Jt=new Set([`anyLabels`,`authors`,`changedLabels`]);function Yt(e){if(e.description!==void 0||!e.name.trim()||!e.task.prompt.trim())return!1;let t=e.task;if(Object.keys(t).some(e=>!qt.has(e))||t.archiveWhenDone===!1||t.autoMergePr===!1||t.allowWorkers===!0||t.allowMessaging===!0||t.worktree!==!0)return!1;if(e.kind===`schedule`)return e.schedule!==void 0;let{events:n,filters:r}=e;return!n?.length||n.some(e=>e.includes(`,`))||!r||r.lookbackDays!==7||r.maxRecords!==25?!1:Object.entries(r).every(([e,t])=>e===`lookbackDays`||e===`maxRecords`||e===`includeExisting`&&t===!0||Jt.has(e)&&Array.isArray(t)&&t.length>0)}function Xt(e){return e%3600==0?`${e/3600}h`:e%60==0?`${e/60}m`:`${e}s`}function Zt(e){return e%1440==0?`${e/1440}d`:e%60==0?`${e/60}h`:`${e}m`}function Q(e,t){return t.startsWith(`-`)?`--${e}=${Z(t)}`:`--${e} ${Z(t)}`}function Qt(e){let t=[`${Be()} automation add`,Q(`name`,e.name)];if(e.schedule?.type===`once`)t.push(Q(`at`,e.schedule.at),Q(`tz`,e.schedule.timeZone)),e.schedule.latestStartMinutes!==void 0&&t.push(Q(`latest-start`,Zt(e.schedule.latestStartMinutes)));else if(e.kind===`schedule`)t.push(Q(`cron`,tt(e.schedule)));else{t.push(Q(`on`,e.events.join(`,`)),`--every ${Xt(e.intervalSeconds??300)}`),e.filters?.includeExisting&&t.push(`--include-existing`);for(let n of e.filters?.anyLabels??[])t.push(Q(`label`,n));for(let n of e.filters?.authors??[])t.push(Q(`author`,n));for(let n of e.filters?.changedLabels??[])t.push(Q(`changed-label`,n))}return t.push(...$t(e.task)),e.enable===!0&&t.push(`--enable`),t.push(Q(`prompt`,e.task.prompt)),t.join(` `)}function $t(e){let t=[];return e.workflow&&t.push(Q(`workflow`,e.workflow)),e.runner&&t.push(Q(`runner`,e.runner)),e.model&&t.push(Q(`model`,e.model)),e.autonomous===!1&&t.push(`--no-autonomous`),e.archiveWhenDone&&t.push(`--archive-when-done`),e.autoMergePr&&t.push(`--auto-merge-pr`),e.allowWorkers===!1&&t.push(`--no-workers`),e.allowMessaging===!1&&t.push(`--no-messaging`),t}function en(e,t){let n=Gt(e),r=Yt(n)?Qt(n):`${Be()} automation create --json ${Z(JSON.stringify(n))}`;return t?`CEZ_COCKPIT_URL=${Z(t.origin)} CEZ_PROJECT_ID=${Z(t.projectId)} HSQ_COCKPIT_URL=${Z(t.origin)} HSQ_PROJECT_ID=${Z(t.projectId)} ${r}`:r}function tn(e){let t=[],n=!1;for(let r of nn(e)){let e=t.length-1;!n&&/^[A-Z_][A-Z0-9_]*=/.test(r)?t.push(r):r.startsWith(`--`)||!n?(t.push(r),n=!0):t[e]=`${t[e]} ${r}`}return t.map((e,t)=>t===0?e:` ${e}`).join(` \\
2
- `)}function nn(e){let t=[],n=``,r=!1;for(let i=0;i<e.length;i+=1){let a=e[i];!r&&a===`\\`&&i+1<e.length?(n+=a+e[i+1],i+=1):a===`'`?(r=!r,n+=a):a===` `&&!r?(n&&t.push(n),n=``):n+=a}return n&&t.push(n),t}function rn({draft:e}){let t=Te(),n=window.location.origin,i=(0,U.useMemo)(()=>{let r=en(e);return t?`HSQ_COCKPIT_URL=${Z(n)} HSQ_PROJECT_ID=${Z(t)} ${r}`:r},[e,n,t]),a=(0,U.useMemo)(()=>tn(i),[i]),[o,s]=(0,U.useState)(`idle`),[c,l]=(0,U.useState)(!1),u=(0,U.useId)(),d=(0,U.useRef)(void 0);(0,U.useEffect)(()=>()=>clearTimeout(d.current),[]),(0,U.useEffect)(()=>s(`idle`),[i]);let f=async()=>{clearTimeout(d.current);try{await navigator.clipboard.writeText(a),s(`copied`),d.current=setTimeout(()=>s(`idle`),1600)}catch{s(`failed`)}};return(0,q.jsxs)(`section`,{"aria-labelledby":`copy-as-cli-heading`,"data-slot":`copy-as-cli`,className:`min-w-0 max-w-full overflow-hidden rounded-xl border border-card-edge bg-card shadow-card px-4 py-3.5`,children:[(0,q.jsxs)(`div`,{className:`flex min-h-8 min-w-0 flex-nowrap items-center justify-between gap-x-2`,children:[(0,q.jsx)(`h2`,{id:`copy-as-cli-heading`,className:`shrink-0 text-[13px] font-medium text-muted-foreground`,children:`Copy as CLI`}),(0,q.jsxs)(M,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`copy-as-cli-toggle`,"aria-expanded":c,"aria-controls":u,"aria-label":c?`Hide command`:`Show command`,className:`min-w-0 shrink gap-1 px-1.5 text-[12px] font-medium max-md:h-11 no-hover:h-11`,onClick:()=>l(e=>!e),children:[(0,q.jsx)(`span`,{className:`truncate`,children:c?`Hide`:`Show`}),(0,q.jsx)(he,{"aria-hidden":`true`,className:r(`size-3.5 transition-transform`,c&&`rotate-180`)})]}),(0,q.jsxs)(M,{type:`button`,variant:`outline`,size:`sm`,className:`ms-auto gap-1.5 px-2 text-[12px] font-medium max-md:h-11 no-hover:h-11`,onClick:()=>void f(),children:[o===`copied`?(0,q.jsx)(ye,{"aria-hidden":`true`,className:`size-3.5`}):(0,q.jsx)(We,{"aria-hidden":`true`,className:`size-3.5`}),o===`copied`?`Copied`:`Copy`]})]}),(0,q.jsx)(`div`,{id:u,hidden:!c,className:`mbs-2 max-w-full rounded-lg border border-border bg-muted has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-ring`,children:(0,q.jsx)(`pre`,{"data-slot":`copy-as-cli-line`,tabIndex:0,"aria-label":`Command line`,className:`m-0 max-w-full px-3 pt-2.5 pb-3 font-mono text-xs leading-5 break-all whitespace-pre-wrap text-muted-foreground outline-none`,children:a})}),(0,q.jsx)(`p`,{role:`status`,className:`mbs-2 text-xs break-words text-muted-foreground`,children:o===`failed`?`Could not copy — select the line and copy it by hand.`:(0,q.jsxs)(q.Fragment,{children:[`The definition Save paused would create. `,(0,q.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-px font-mono text-xs whitespace-nowrap text-foreground [word-spacing:-0.2em]`,children:`${Be()} automation schema`}),` prints its shape.`]})})]})}function an({pressed:e,onClick:t,disabled:n,children:i}){return(0,q.jsx)(`button`,{type:`button`,"aria-pressed":e,disabled:n,onClick:t,className:r(`inline-flex min-h-11 items-center justify-center rounded-md border px-3.5 text-[13px] font-medium transition-colors outline-hidden focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50`,e?`border-border bg-card font-semibold text-foreground shadow-xs`:`border-transparent bg-transparent text-muted-foreground hover:text-foreground`),children:i})}var on={"pull_request.opened":`a pull request opens`,"issue.opened":`an issue opens`,"issue.labeled":`an issue is labeled`,"issue.unlabeled":`an issue is unlabeled`},sn={"pull_request.opened":`Pull request opened`,"issue.opened":`Issue opened`,"issue.labeled":`Issue labeled`,"issue.unlabeled":`Issue unlabeled`};function cn(e){let t=e.map(e=>on[e]);if(t.length===0)return`When GitHub changes`;let n=t.slice(0,-1),r=t[t.length-1];return`When ${n.length>0?`${n.join(`, `)} or ${r}`:r}`}var ln=W.options,un=[{seconds:60,label:`1 minute`},{seconds:300,label:`5 minutes`},{seconds:900,label:`15 minutes`},{seconds:1800,label:`30 minutes`},{seconds:3600,label:`1 hour`}],dn=[{key:`authors`,label:`Authors`},{key:`assignees`,label:`Assignees`},{key:`allLabels`,label:`Has all labels`},{key:`anyLabels`,label:`Has any label`},{key:`excludeLabels`,label:`Excludes labels`},{key:`changedLabels`,label:`Changed labels`,hint:`Required for the two label events.`}],fn=e=>(e??[]).join(`, `),pn=e=>e.split(`,`).map(e=>e.trim()).filter(Boolean);function mn(e){return e?`Existing matches within the lookback are eligible on the next check. Previously processed matches will not run again.`:`Enabling starts from a current-time baseline. Existing matches will not launch tasks.`}function hn(e){let t=Math.max(1,Math.round(e.intervalSeconds/60));return`Polls GitHub every ${t} minute${t===1?``:`s`} for ${e.events.join(`, `)||`no events`}. ${mn(e.filters.includeExisting)}`}function gn({draft:e,onChange:t,disabledReason:n}){let r=n=>{t({events:e.events.includes(n)?e.events.filter(e=>e!==n):[...e.events,n]})},i=n=>t({filters:{...e.filters,...n}}),a=(n,r)=>{let i=pn(r),{[n]:a,...o}=e.filters;t({filters:i.length?{...o,[n]:i}:o})},o=un.some(t=>t.seconds===e.intervalSeconds)?un:[...un,{seconds:e.intervalSeconds,label:`${Math.round(e.intervalSeconds/60)} minutes`}].sort((e,t)=>e.seconds-t.seconds);return(0,q.jsxs)(`div`,{className:`grid gap-4`,children:[n?(0,q.jsx)(`p`,{className:`text-xs text-pending-strong`,children:`GitHub unavailable · ${n}`}):null,(0,q.jsx)(`div`,{role:`group`,"aria-label":`GitHub events`,className:`inline-flex w-fit max-w-full flex-wrap gap-1 rounded-lg border border-border bg-muted/60 p-1`,children:ln.map(t=>(0,q.jsx)(an,{pressed:e.events.includes(t),onClick:()=>r(t),children:sn[t]},t))}),(0,q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,q.jsx)(j,{htmlFor:`automation-interval`,children:`Check every`}),(0,q.jsxs)(L,{value:String(e.intervalSeconds),onValueChange:e=>t({intervalSeconds:Number(e)}),children:[(0,q.jsx)(P,{id:`automation-interval`,className:`w-full sm:w-48`,"aria-label":`Check every`,children:(0,q.jsx)(N,{})}),(0,q.jsx)(F,{children:o.map(e=>(0,q.jsx)(I,{value:String(e.seconds),children:e.label},e.seconds))})]})]}),(0,q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,q.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm`,children:[(0,q.jsx)(Ce,{"aria-label":`Include existing items`,"aria-describedby":`automation-history-hint`,checked:e.filters.includeExisting??!1,onCheckedChange:e=>i({includeExisting:e})}),(0,q.jsx)(`span`,{children:`Include existing items`})]}),(0,q.jsx)(`p`,{id:`automation-history-hint`,className:`text-xs text-muted-foreground`,children:mn(e.filters.includeExisting)})]}),(0,q.jsxs)(Se,{children:[(0,q.jsxs)(xe,{className:`group flex min-h-11 items-center gap-2 text-sm font-medium`,children:[`Filters`,(0,q.jsx)(he,{"aria-hidden":`true`,className:`size-4 text-soft-foreground transition-transform motion-reduce:transition-none group-data-[state=open]:rotate-180`})]}),(0,q.jsx)(be,{children:(0,q.jsxs)(`div`,{className:`grid gap-4 pt-2 sm:grid-cols-2`,children:[dn.map(t=>(0,q.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,q.jsx)(j,{htmlFor:`automation-filter-${t.key}`,children:t.label}),(0,q.jsx)(V,{id:`automation-filter-${t.key}`,className:`border-border`,placeholder:`comma separated`,value:fn(e.filters[t.key]),onChange:e=>a(t.key,e.target.value)}),t.hint?(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.hint}):null]},t.key)),(0,q.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,q.jsx)(j,{htmlFor:`automation-filter-lookback`,children:`Look back (days)`}),(0,q.jsx)(V,{id:`automation-filter-lookback`,className:`border-border`,type:`number`,min:1,value:e.filters.lookbackDays,onChange:e=>i({lookbackDays:Math.max(1,Number(e.target.value)||1)})})]}),(0,q.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,q.jsx)(j,{htmlFor:`automation-filter-max`,children:`Max records per check`}),(0,q.jsx)(V,{id:`automation-filter-max`,className:`border-border`,type:`number`,min:1,value:e.filters.maxRecords,onChange:e=>i({maxRecords:Math.max(1,Number(e.target.value)||1)})})]})]})})]})]})}var _n=e=>String(e).padStart(2,`0`);function vn({label:e,value:t,max:n,onCommit:r}){let[i,a]=(0,U.useState)(_n(t)),o=(0,U.useRef)(null),s=!(/^\d{1,2}$/.test(i)&&Number(i)===t),c=`${e} must be 00–${_n(n)}.`,l=(0,U.useId)();return(0,U.useEffect)(()=>{o.current?.setCustomValidity(s?c:``)},[s,c]),(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(V,{ref:o,"aria-label":e,"aria-invalid":s||void 0,"aria-describedby":s?l:void 0,inputMode:`numeric`,maxLength:2,className:`w-20 border-border text-center tabular-nums`,value:i,onChange:e=>{a(e.target.value),/^\d{1,2}$/.test(e.target.value)&&Number(e.target.value)<=n&&r(Number(e.target.value))},onBlur:()=>a(_n(t))}),s?(0,q.jsx)(`p`,{id:l,className:`order-last basis-full text-xs text-destructive`,children:c}):null]})}var yn=[{minutes:void 0,label:`No limit`},{minutes:30,label:`30 minutes`},{minutes:120,label:`2 hours`},{minutes:360,label:`6 hours`},{minutes:1440,label:`1 day`},{minutes:10080,label:`7 days`}],bn=`none`,xn=e=>String(e).padStart(2,`0`);function Sn(e,t=Date.now()){let n=lt(t,e)??lt(t,`UTC`),r=new Date(Date.UTC(n.year,n.month-1,n.day+1));return`${r.getUTCFullYear()}-${xn(r.getUTCMonth()+1)}-${xn(r.getUTCDate())}T09:00`}function Cn(){let e=typeof Intl.supportedValuesOf==`function`?Intl.supportedValuesOf(`timeZone`):[];return e.includes(`UTC`)?e:[`UTC`,...e]}function wn({value:e,stored:t,onChange:n}){let r=t=>n({...e,...t}),i=e.at?nt(e.at):null,a=e.at?.slice(0,10)??``,o=i?.hour??9,s=i?.minute??0,c=(e,t,n)=>r({at:`${e}T${xn(t)}:${xn(n)}`}),l=(0,U.useRef)(null),u=(0,U.useId)(),d=Ze(e),f=!(t?.type===`once`&&t.at===e.at&&t.timeZone===e.timeZone)&&d!==null&&d<=Date.now();(0,U.useEffect)(()=>{l.current?.setCustomValidity(f?Je:``)},[f]);let p=ot(e);return(0,q.jsxs)(`div`,{className:`grid gap-4`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-end gap-x-4 gap-y-3`,children:[(0,q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,q.jsx)(j,{htmlFor:`automation-once-date`,children:`Date`}),(0,q.jsx)(V,{ref:l,id:`automation-once-date`,type:`date`,className:`w-44 max-w-full border-border`,value:a,"aria-invalid":f||void 0,"aria-describedby":f?u:void 0,onChange:e=>{/^\d{4}-\d{2}-\d{2}$/.test(e.target.value)&&c(e.target.value,o,s)},required:!0})]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`at`}),(0,q.jsx)(vn,{label:`Hour`,value:o,max:23,onCommit:e=>c(a,e,s)}),(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`:`}),(0,q.jsx)(vn,{label:`Minute`,value:s,max:59,onCommit:e=>c(a,o,e)})]})]}),f?(0,q.jsx)(`p`,{id:u,className:`text-xs text-destructive`,children:Je}):null,(0,q.jsx)(En,{value:e.timeZone??``,onCommit:e=>r({timeZone:e})}),(0,q.jsx)(Dn,{value:e.latestStartMinutes,onChange:t=>n(Tn(e,t))}),p?(0,q.jsx)(`p`,{className:`text-sm break-words`,children:`Runs once at ${p.time} on ${p.date} (${e.timeZone}). ${p.note?`${p.note} `:``}Squawk must be running then.`}):null]})}function Tn(e,t){let{latestStartMinutes:n,...r}=e;return t===void 0?r:{...r,latestStartMinutes:t}}function En({value:e,onCommit:t}){let[n,r]=(0,U.useState)(e),i=(0,U.useRef)(null),a=(0,U.useId)(),o=(0,U.useId)(),[s]=(0,U.useState)(Cn),c=n!==e||!qe(n),l=Qe(n);return(0,U.useEffect)(()=>{i.current?.setCustomValidity(c?l:``)},[c,l]),(0,q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,q.jsx)(j,{htmlFor:`automation-once-zone`,children:`Time zone`}),(0,q.jsx)(V,{ref:i,id:`automation-once-zone`,list:a,autoComplete:`off`,spellCheck:!1,className:`w-full border-border sm:w-72`,value:n,"aria-invalid":c||void 0,"aria-describedby":c?o:void 0,onChange:e=>{r(e.target.value),qe(e.target.value)&&t(e.target.value)}}),(0,q.jsx)(`datalist`,{id:a,children:s.map(e=>(0,q.jsx)(`option`,{value:e},e))}),c?(0,q.jsx)(`p`,{id:o,className:`text-xs break-words text-destructive`,children:l}):null]})}function Dn({value:e,onChange:t}){let n=yn.some(t=>t.minutes===e)||e===void 0?yn:[...yn,{minutes:e,label:`${e} minutes`}];return(0,q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,q.jsx)(j,{htmlFor:`automation-once-latest`,children:`Latest start`}),(0,q.jsxs)(L,{value:e===void 0?bn:String(e),onValueChange:e=>t(e===bn?void 0:Number(e)),children:[(0,q.jsx)(P,{id:`automation-once-latest`,className:`w-full sm:w-48`,"aria-label":`Latest start`,children:(0,q.jsx)(N,{})}),(0,q.jsx)(F,{children:n.map(e=>(0,q.jsx)(I,{value:e.minutes===void 0?bn:String(e.minutes),children:e.label},e.label))})]}),(0,q.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:`If Squawk was not running at the time, it still starts the task this long afterwards; later, the schedule is marked missed.`})]})}var On=[{type:`daily`,label:`Every day`},{type:`weekdays`,label:`Weekdays`},{type:`weekly`,label:`Weekly`},{type:`hours`,label:`Every N hours`},{type:`once`,label:`Once`}];function kn({value:e,stored:t,onChange:n,timeZone:r}){let i=t=>n({...e,...t}),a=t=>i(t===`once`?{type:t,at:e.at??Sn(r),timeZone:e.timeZone??r}:{type:t});return(0,q.jsxs)(`div`,{className:`grid gap-4`,children:[(0,q.jsx)(`div`,{role:`group`,"aria-label":`Repeat`,className:`inline-flex w-fit max-w-full flex-wrap gap-1 rounded-lg border border-border bg-muted/60 p-1`,children:On.map(t=>(0,q.jsx)(an,{pressed:e.type===t.type,onClick:()=>a(t.type),children:t.label},t.type))}),e.type===`once`?(0,q.jsx)(wn,{value:e,stored:t,onChange:n}):null,e.type===`weekly`?(0,q.jsx)(`div`,{role:`group`,"aria-label":`Day of the week`,className:`inline-flex w-fit max-w-full flex-wrap gap-1 rounded-lg border border-border bg-muted/60 p-1`,children:st.map((t,n)=>(0,q.jsx)(an,{pressed:e.day===n+1,onClick:()=>i({day:n+1}),children:t},t))}):null,e.type===`once`?null:e.type===`hours`?(0,q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,q.jsx)(j,{htmlFor:`automation-every`,children:`Run every`}),(0,q.jsxs)(L,{value:String(e.every),onValueChange:e=>i({every:Number(e)}),children:[(0,q.jsx)(P,{id:`automation-every`,className:`w-full sm:w-48`,"aria-label":`Run every`,children:(0,q.jsx)(N,{})}),(0,q.jsx)(F,{children:it.map(e=>(0,q.jsx)(I,{value:String(e),children:e===1?`hour`:`${e} hours`},e))})]}),(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Counted from midnight, so “every 6 hours” runs at 00:00, 06:00, 12:00 and 18:00.`})]}):(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`at`}),(0,q.jsx)(vn,{label:`Hour`,value:e.hour,max:23,onCommit:e=>i({hour:e})}),(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`:`}),(0,q.jsx)(vn,{label:`Minute`,value:e.minute,max:59,onCommit:e=>i({minute:e})}),(0,q.jsx)(`span`,{className:`text-sm break-all text-muted-foreground`,children:r})]}),e.type===`once`?null:(0,q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Cron: `,(0,q.jsx)(`code`,{className:`font-mono text-foreground`,children:tt(e)})]})]})}var An=40*864e5,jn=5;function Mn({schedule:e,timeZone:t,now:n=Date.now()}){if(e.type===`once`)return(0,q.jsx)(Nn,{schedule:e,now:n});let r=Xe(e,n+1,n+An,t,jn);return(0,q.jsxs)(`section`,{"aria-labelledby":`next-runs-heading`,"data-slot":`next-runs`,className:`min-w-0 rounded-xl border bg-card p-5`,children:[(0,q.jsx)(`h2`,{id:`next-runs-heading`,className:`mb-2 text-base font-semibold`,children:`Next 5 runs`}),r.length===0?(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No runs in the next 40 days.`}):(0,q.jsx)(`ol`,{"aria-label":`Next 5 runs`,className:`grid divide-y divide-border text-sm`,children:r.map((e,r)=>(0,q.jsxs)(`li`,{className:`flex min-h-10 items-center justify-between gap-3 py-1.5`,children:[(0,q.jsx)(`span`,{className:r===0?`font-semibold tabular-nums text-foreground`:`font-medium tabular-nums`,children:H(new Date(e).toISOString(),t)}),(0,q.jsx)(`span`,{className:r===0?`font-medium text-accent-text`:`text-muted-foreground`,children:et(n,e)})]},e))}),(0,q.jsxs)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:[`Times are in `,t,`, the zone this Squawk runs in.`]})]})}function Nn({schedule:e,now:t}){let n=Ze(e),r=ot(e);return(0,q.jsxs)(`section`,{"aria-labelledby":`next-runs-heading`,"data-slot":`next-runs`,className:`min-w-0 rounded-xl border bg-card p-5`,children:[(0,q.jsx)(`h2`,{id:`next-runs-heading`,className:`mb-3 text-base font-semibold`,children:`Runs once`}),n===null||!r?(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Pick a date, a time and a time zone.`}):(0,q.jsxs)(`p`,{className:`flex flex-wrap items-baseline justify-between gap-x-3 text-sm`,children:[(0,q.jsx)(`span`,{className:`font-medium tabular-nums`,children:`${r.date} ${r.time}`}),n>t?(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:et(t,n)}):null]}),r?.note?(0,q.jsx)(`p`,{className:`mt-2 text-sm break-words`,children:r.note}):null,n!==null&&n<=t?(0,q.jsx)(`p`,{className:`mt-2 text-sm text-destructive`,children:`The due time has passed.`}):null,(0,q.jsx)(`p`,{className:`mt-3 text-xs break-words text-muted-foreground`,children:`Times are in ${e.timeZone??`UTC`}. Squawk must be running then; afterwards the schedule is archived with its task.`})]})}var Pn={schedule:`On a schedule`,github:`When GitHub changes`};function Fn(e){return/time zone|due time/i.test(e)?`when`:/placeholder|prompt|workflow|runner|model|task|autonomous/i.test(e)?`run`:/\bname\b/i.test(e)?`name`:/schedule|github|event|filter|label|interval|remote|forge|lookback|records?|hour|minute|poll|kind|archived/i.test(e)?`when`:`form`}function In({title:e,hideLegend:t=!1,failure:n,section:r,children:i}){let a=(0,U.useId)();return(0,q.jsxs)(`section`,{role:t?void 0:`group`,"aria-labelledby":t?void 0:a,className:`grid min-w-0 gap-3.5 rounded-xl border border-card-edge bg-card shadow-card p-5`,children:[t?null:(0,q.jsx)(`h2`,{id:a,className:`text-sm font-semibold text-foreground`,children:e}),i,n?.section===r&&!n.conflict?(0,q.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:n.message}):null]})}function Ln({draft:e,patch:t,forge:n,automation:r}){return(0,q.jsx)(q.Fragment,{children:r?(0,q.jsxs)(`p`,{className:`text-sm`,children:[(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:`Trigger · `}),Pn[e.kind]]}):(0,q.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[(0,q.jsx)(Ue,{slot:`automation-kind`,label:`Trigger`,size:`touch`,value:e.kind,onChange:e=>t({kind:e}),options:[{value:`schedule`,label:Pn.schedule},{value:`github`,label:Pn.github,disabled:!n.available,...n.available?{}:{title:n.reason??`GitHub is unavailable`}}]}),n.available?null:(0,q.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:`GitHub unavailable · ${n.reason??`no GitHub access`}`})]})})}function Rn({draft:e,patch:t,forge:n,timeZone:r,automation:i}){return e.kind===`schedule`?(0,q.jsx)(kn,{value:e.schedule,stored:i?.schedule,onChange:e=>t({schedule:e}),timeZone:r}):(0,q.jsx)(gn,{draft:e,onChange:t,...n.available?{}:{disabledReason:n.reason??`no GitHub access`}})}function zn({draft:e,patch:t,saving:n,automation:r}){return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,q.jsx)(j,{htmlFor:`automation-prompt`,children:`Prompt`}),(0,q.jsx)(Ke,{id:`automation-prompt`,value:e.prompt,onChange:e=>t({prompt:e.target.value}),rows:3,className:`[field-sizing:fixed] min-h-[88px] resize-none border-border bg-background`,required:!0}),(0,q.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:e.kind===`schedule`?(0,q.jsxs)(q.Fragment,{children:[`Available: `,`{{date}}`,` `,`{{time}}`,` `,`{{project}}`,` `,`{{automation}}`,`. A run-context block is appended automatically.`]}):(0,q.jsxs)(q.Fragment,{children:[`Available: `,`{{github.number}}`,` `,`{{github.title}}`,` `,`{{github.url}}`,` `,`{{github.labels}}`,`. GitHub content is appended as untrusted context.`]})})]}),(0,q.jsx)(Wn,{draft:e,patch:t}),(0,q.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm`,children:[(0,q.jsx)(Ce,{"aria-label":`Autonomous`,checked:e.autonomous,onCheckedChange:e=>t({autonomous:e})}),(0,q.jsxs)(`span`,{children:[`Autonomous `,(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:`· runs without waiting for answers`})]})]}),(0,q.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:`Each run is an ordinary task in its own worktree, queued behind the parallel cap.`}),(0,q.jsx)(ze,{archiveWhenDone:e.archiveWhenDone,autoMergePr:e.autoMergePr,onChange:t,disabled:n}),(0,q.jsx)(Ie,{allowWorkers:e.allowWorkers,allowMessaging:e.allowMessaging,onChange:t,disabled:n}),r?(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`These settings apply to future tasks. Existing tasks keep their settings.`}):null]})}function Bn({draft:e,patch:t,automation:n}){let r=e.kind===`schedule`;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm`,children:[(0,q.jsx)(Ce,{"aria-label":n?`Enabled`:`Enable after saving`,checked:e.enabled,onCheckedChange:e=>t({enabled:e})}),(0,q.jsx)(`span`,{children:n?`Enabled`:`Enable after saving`})]}),(0,q.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:r&&e.schedule.type===`once`?`It runs once at the time set above, then moves to Archived with its task.`:r?`The first run is the next occurrence shown beside the schedule.`:mn(e.filters.includeExisting)})]})}function Vn({automation:e,forge:t,timeZone:n,onSaved:r,onReload:i}){let[a,o]=(0,U.useState)(()=>Vt(e)),[s,c]=(0,U.useState)(e?.revision),[l,u]=(0,U.useState)(),[p,h]=(0,U.useState)(!1),[g,v]=(0,U.useState)(!1),[y,b]=(0,U.useState)(!1),[x,te]=(0,U.useState)(``),S=e=>o(t=>({...t,...e})),ne=async t=>{if(t.preventDefault(),p)return;let n=t.currentTarget;if(n instanceof HTMLFormElement&&!n.checkValidity()){n.reportValidity();return}h(!0),u(void 0);let i=`save`;try{if(e&&s!==void 0){let{automation:t}=await f(e.id,Kt({...a,enabled:e.enabled},s));c(t.revision),a.enabled!==e.enabled&&(i=`enable`,await m(e.id,a.enabled))}else await ee(Gt(a));r()}catch(t){let n=t instanceof Error?t.message:String(t);i===`save`&&e&&t instanceof d&&t.status===409&&/revision conflict/i.test(n)?u({section:`form`,message:`Edited elsewhere — reload to see the latest version`,conflict:!0}):u({section:i===`enable`?`enable`:Fn(n),message:n})}finally{h(!1)}},re=async()=>{if(!(!e||y)){b(!0),te(``);try{await _(e.id),r()}catch(e){te(e instanceof Error?e.message:String(e))}finally{b(!1)}}},ie=(0,U.useId)(),ae=(0,U.useId)(),C=a.kind===`schedule`;return(0,q.jsx)(Ee,{route:`automations`,density:a.name.trim()===``&&a.prompt.trim()===``?`sparse`:`full`,header:Un({automation:e,draft:a,formId:ie,saveHintId:ae,saving:p}),children:(0,q.jsxs)(`form`,{id:ie,className:`automation-editor grid min-w-0 gap-4 md:grid-cols-[minmax(0,1fr)_320px] md:items-start`,onSubmit:ne,children:[(0,q.jsxs)(`div`,{className:`grid min-w-0 gap-3.5`,children:[(0,q.jsx)(In,{title:`Name`,hideLegend:!0,section:`name`,failure:l,children:(0,q.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,q.jsx)(j,{htmlFor:`automation-name`,className:`text-sm font-semibold text-foreground`,children:`Name`}),(0,q.jsx)(V,{id:`automation-name`,className:`border-border`,value:a.name,placeholder:`Daily dependency audit`,onChange:e=>S({name:e.target.value}),required:!0})]})}),(0,q.jsxs)(In,{title:`When`,section:`when`,failure:l,children:[(0,q.jsx)(Ln,{draft:a,patch:S,forge:t,automation:e}),(0,q.jsx)(Rn,{draft:a,patch:S,forge:t,timeZone:n,automation:e})]}),(0,q.jsx)(In,{title:`What to run`,section:`run`,failure:l,children:(0,q.jsx)(zn,{draft:a,patch:S,saving:p,automation:e})}),(0,q.jsx)(In,{title:`Enable`,section:`enable`,failure:l,children:(0,q.jsx)(Bn,{draft:a,patch:S,automation:e})}),l?.section===`form`?(0,q.jsxs)(`div`,{role:`alert`,className:`flex flex-wrap items-center gap-3 text-sm text-destructive`,children:[(0,q.jsx)(`span`,{className:`break-words`,children:l.message}),l.conflict&&i?(0,q.jsx)(M,{type:`button`,variant:`outline`,onClick:i,children:`Reload`}):null]}):null,e?(0,q.jsxs)(`div`,{className:`grid justify-items-start gap-2 border-t pt-4`,children:[g?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`text-sm break-words`,children:`Delete “${e.name}”? It will stop running and cannot be restored.`}),(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,q.jsx)(M,{type:`button`,variant:`danger-ghost`,"data-action":`automation-delete-confirm`,disabled:y,onClick:()=>void re(),children:`Delete automation`}),(0,q.jsx)(M,{type:`button`,variant:`outline`,disabled:y,onClick:()=>{v(!1),te(``)},children:`Keep`})]})]}):(0,q.jsx)(M,{type:`button`,variant:`outline`,"data-action":`automation-delete`,onClick:()=>v(!0),children:`Delete`}),x?(0,q.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:x}):null]}):null]}),(0,q.jsxs)(`aside`,{className:`grid min-w-0 max-w-full grid-cols-[minmax(0,1fr)] gap-4 md:sticky md:top-4`,children:[C?(0,q.jsx)(Mn,{schedule:a.schedule,timeZone:n}):(0,q.jsxs)(`section`,{className:`min-w-0 rounded-xl border border-card-edge bg-card shadow-card p-5`,children:[(0,q.jsx)(`h2`,{className:`mb-2 text-base font-semibold`,children:`How it polls`}),(0,q.jsx)(`p`,{className:`text-sm break-words text-muted-foreground`,children:hn(a)})]}),(0,q.jsx)(rn,{draft:a})]})]})})}function Hn(e){let t=[!e.name.trim()&&`a name`,!e.prompt.trim()&&`a prompt`].filter(Boolean);return t.length?`Add ${t.join(` and `)} to save.`:``}function Un({automation:e,draft:t,formId:n,saveHintId:r,saving:i}){let a=t.name.trim()?t.prompt.trim()?``:`Prompt`:`Name`,o=Hn(t),s=e?`Save changes`:t.enabled?`Save and enable`:`Save paused`;return{title:e?`Edit automation`:`New automation`,subtitle:`Define when it runs and the ordinary task it launches.`,status:o?(0,q.jsx)(`p`,{id:r,"data-slot":`automation-save-hint`,className:`text-xs text-muted-foreground`,children:o}):void 0,secondaryActions:(0,q.jsx)(z,{type:`button`,variant:`outline`,asChild:!0,children:(0,q.jsx)(R,{to:`/automations`,children:`Cancel`})}),primaryAction:(0,q.jsx)(z,{type:`submit`,form:n,variant:`primary`,disabled:i||a!==``,title:a?`${a} is required`:void 0,"aria-describedby":o?r:void 0,children:i?`Saving…`:s})}}function Wn({draft:e,patch:t}){let n=i(),r=Ge(),{runners:u,signedOut:d}=r.runnersOn(e=>r.repoAccount?.[e]),f=a(),p=s(),{runner:m,ready:h}=o(e.runner??f.data?.defaultRunner??`claude`),g=c(m,h,r.repoAccount?.[m]),ee=[...new Set([...(n.data?.workflows??[]).map(e=>e.name),...e.workflow?[e.workflow]:[]])],_=[...new Set([...u,...e.runner?[e.runner]:[]])],v=Fe(m,p.data,g.data,[e.model]),y=v.find(t=>t.id===(e.model??``))?.label??e.model??`auto`,b=e=>(0,q.jsx)(e,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`});return(0,q.jsx)(Me,{children:(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,q.jsx)(Re,{slot:`automation-workflow-pill`,icon:b(_e),fieldLabel:!0,ariaLabel:`Workflow`,label:e.workflow??`inline steps`,value:e.workflow??``,disabled:e.workflow===void 0,disabledHint:`This automation carries its own steps.`,options:ee.map(e=>({value:e,label:e})),onPick:e=>t({workflow:e})}),(0,q.jsx)(Re,{slot:`automation-runner-pill`,icon:b(me),fieldLabel:!0,ariaLabel:`Runner`,label:e.runner?l(p.data,e.runner):`default`,value:e.runner??``,disabled:!p.data,options:[{value:``,label:`default`,desc:`The project’s default runner`},..._.map(e=>({value:e,label:l(p.data,e)}))],footer:(0,q.jsx)(Ve,{uninstalled:r.uninstalled,signedOut:d.filter(t=>t!==e.runner)}),onPick:e=>{t({runner:e||void 0,model:void 0})}}),(0,q.jsx)(Re,{slot:`automation-model-pill`,icon:b(ve),fieldLabel:!0,ariaLabel:`Model`,label:y,value:e.model??``,options:v.map(e=>({value:e.id,label:e.label,desc:e.desc})),onPick:e=>t({model:e||void 0})})]})})}function Gn({data:e,error:t,refresh:n,archived:i=!1,onArchivedChange:a}){let[o,s]=(0,U.useState)({}),[c,l]=(0,U.useState)({}),d=(e,t)=>s(n=>{let{[e]:r,...i}=n;return t?{...i,[e]:t}:i}),f=async(e,t)=>{l(t=>({...t,[e]:!0}));try{await t()}catch(t){d(e,{text:t instanceof Error?t.message:String(t),tone:`error`})}finally{l(t=>({...t,[e]:!1}))}},p=e=>f(e.id,async()=>{d(e.id,{text:`Starting…`,tone:`info`});let{runId:t}=await u(e.id);d(e.id,{text:`Started task`,tone:`info`,runId:t}),n()}),h=e=>f(e.id,async()=>{d(e.id,void 0),await m(e.id,!e.enabled),await n()}),g=e=>f(e.id,async()=>{d(e.id,void 0),await te(e.id),await n()}),ee=e=>f(e.id,async()=>{d(e.id,{text:`Checking…`,tone:`info`});let{checkId:t}=await S(e.id,`preview`);for(let r=0;r<60;r+=1){let r=await v(t);if(r.status===`complete`){d(e.id,{text:`${r.matches??0} filter match${r.matches===1?``:`es`} found; no tasks launched. Counts can include closed items and previously processed events.`,tone:`info`}),n();return}if(r.status===`error`)throw Error(r.error??`Preview failed`);await new Promise(e=>setTimeout(e,500))}throw Error(`Preview is still running`)}),_=e?.automations??[],y=_.filter(e=>!e.archived),b=_.filter(e=>!!e.archived),x=i?b:y;return(0,q.jsx)(B,{route:`automations`,density:e?Oe(x.length):`full`,headerSpacing:`compact`,header:{title:`Automations`,subtitle:`Schedules and GitHub checks run while Squawk is open.`,primaryAction:(0,q.jsx)(z,{variant:`primary`,asChild:!0,children:(0,q.jsxs)(R,{to:`/automations/new`,children:[(0,q.jsx)(fe,{"aria-hidden":`true`,className:`size-4`}),`New automation`]})})},sparseFooter:e&&x.length>0&&!i?(0,q.jsx)(ke,{summary:`${x.length} active ${x.length===1?`automation`:`automations`} configured. New automations start paused so you can test filters before enabling them.`,actions:(0,q.jsx)(M,{variant:`outline`,size:`sm`,asChild:!0,className:`max-md:min-h-11`,children:(0,q.jsx)(R,{to:`/automations/new`,children:`Add another`})})}):void 0,children:t&&!e?(0,q.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,q.jsx)(J,{text:t}),(0,q.jsx)(M,{variant:`outline`,onClick:()=>void n(),children:`Retry`})]}):e?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-end justify-between gap-3 border-b border-border`,children:[a?(0,q.jsxs)(`div`,{className:`flex gap-6`,role:`group`,"aria-label":`Filter automations`,children:[(0,q.jsxs)(`button`,{type:`button`,"data-slot":`automations-tab`,"data-view":`active`,"aria-pressed":!i,onClick:()=>a(!1),className:r(`-mb-px flex min-h-11 items-center justify-center gap-1.5 border-b-2 border-transparent text-[13px] font-medium text-muted-foreground transition-colors hover:text-foreground`,!i&&`border-accent-text text-foreground`),children:[`Current`,(0,q.jsx)(Kn,{count:y.length})]}),(0,q.jsxs)(`button`,{type:`button`,"data-slot":`automations-tab`,"data-view":`archived`,"aria-pressed":i,onClick:()=>a(!0),className:r(`-mb-px flex min-h-11 items-center justify-center gap-1.5 border-b-2 border-transparent text-[13px] font-medium text-muted-foreground transition-colors hover:text-foreground`,i&&`border-accent-text text-foreground`),children:[`Archived`,(0,q.jsx)(Kn,{count:b.length})]})]}):(0,q.jsx)(`span`,{}),(0,q.jsx)(`div`,{className:`pb-2.5`,children:(0,q.jsx)(qn,{data:e})})]}),i&&x.length===0?(0,q.jsx)(J,{text:`No archived one-time schedules.`}):x.length===0?(0,q.jsx)(Ae,{icon:(0,q.jsx)(ge,{}),tone:`neutral`,title:`No automations yet`,subtitle:`Create one paused, preview it, then enable it.`,heading:`h2`,actions:(0,q.jsx)(M,{variant:`primary`,asChild:!0,children:(0,q.jsxs)(R,{to:`/automations/new`,children:[(0,q.jsx)(fe,{"aria-hidden":`true`,className:`size-4`}),`New automation`]})})}):(0,q.jsx)(`ul`,{className:`grid gap-3`,"aria-label":`Automations`,children:x.map(t=>(0,q.jsx)(nr,{automation:t,timeZone:e.timeZone,note:o[t.id],busy:c[t.id]===!0,onRun:()=>void p(t),onToggle:()=>void h(t),onPreview:()=>void ee(t),onCancel:()=>void g(t)},t.id))})]}):(0,q.jsx)(J,{text:`Loading automations…`})})}function Kn({count:e}){return e===0?null:(0,q.jsx)(`span`,{"data-slot":`automations-tab-count`,className:`tabular-nums text-muted-foreground`,children:`· ${e}`})}function qn({data:e}){return(0,q.jsx)(`p`,{"data-slot":`automation-scheduler`,className:r(`text-xs break-words`,e.scheduler.state===`scheduled`?`text-success`:`text-muted-foreground`),children:`Scheduler ${e.scheduler.state===`scheduled`?`running`:`idle`} · GitHub ${e.available?`available`:`unavailable`}${e.reason?` · ${e.reason}`:``} · ${e.timeZone}`})}function Jn(e){return e.kind===`schedule`&&e.schedule?$e(e.schedule):`${cn(e.events??[])} · every ${Math.round((e.intervalSeconds??300)/60)} min`}function Yn({automation:e,nextRun:t}){let n=e.kind===`schedule`?pe:de,r=Le(e);return(0,q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsxs)(`h2`,{className:`flex items-center gap-2 font-semibold break-words`,children:[(0,q.jsx)(n,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`}),e.name]}),(0,q.jsxs)(`p`,{"data-slot":`automation-meta`,className:`mt-1 flex flex-wrap items-baseline gap-x-1.5 ps-6 text-xs break-words text-muted-foreground`,children:[(0,q.jsx)(`span`,{children:Jn(e)}),t?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),t]}):null]})]}),(0,q.jsx)(He,{dot:r.tone,shape:r.shape,pulse:r.pulse,children:r.label})]})}function Xn({automation:e,archive:t}){return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`p`,{className:`text-sm break-words`,children:[t.outcome===`launched`?`Started its task.`:`Cancelled — no task was started.`,t.runId?(0,q.jsxs)(q.Fragment,{children:[` · `,(0,q.jsx)(R,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${t.runId}`,children:`Open task`})]}):null]}),(0,q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,q.jsx)(M,{variant:`outline`,asChild:!0,children:(0,q.jsx)(R,{to:`/automations/${e.id}`,children:`Details`})})})]})}function Zn({automation:e,timeZone:t}){let n=e.kind===`schedule`,r=e.enabled&&n?e.nextRunAt:void 0;return!n&&e.enabled?(0,q.jsx)(`span`,{children:`continuous`}):r?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`text-foreground`,children:`Next run: ${H(r,t)}`}),(0,q.jsx)(`span`,{children:`· ${et(Date.now(),Date.parse(r))}`})]}):(0,q.jsx)(`span`,{children:`Next run: —`})}function Qn({automation:e,timeZone:t}){let n=e.enabled?_t(e.state):void 0;return n?(0,q.jsxs)(`p`,{role:`alert`,"data-slot":`automation-failing`,className:`text-sm break-words text-destructive`,children:[`The last ${n.consecutiveFailures} checks failed: ${n.lastError}`,n.retryAt?(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:` · Next try ${H(n.retryAt,t)}`}):null]}):null}var $=`h-8 px-3 max-md:h-11 no-hover:h-11`;function $n({automation:e,busy:t,confirmingCancel:n,cancelRef:i,onToggle:a,onRun:o,onPreview:s,onOpenCancel:c}){let l=e.kind===`schedule`,u=e.schedule?.type===`once`;return(0,q.jsxs)(`div`,{"data-slot":`automation-actions`,className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(M,{variant:`outline`,size:`sm`,className:$,"data-action":`automation-toggle`,disabled:t,onClick:a,children:e.enabled?`Pause`:`Enable`}),l?(0,q.jsx)(M,{variant:`outline`,size:`sm`,className:$,"data-action":`automation-run`,disabled:t,onClick:o,children:`Run now`}):(0,q.jsx)(M,{variant:`outline`,size:`sm`,className:$,"data-action":`automation-preview`,disabled:t,onClick:s,children:`Test filter`}),(0,q.jsx)(M,{variant:`outline`,size:`sm`,className:$,asChild:!0,children:(0,q.jsx)(R,{to:`/automations/${e.id}`,children:`Edit`})}),u&&!n?(0,q.jsx)(M,{variant:`outline`,size:`sm`,className:r($,`text-destructive`),ref:i,"data-action":`automation-cancel`,disabled:t,onClick:c,children:`Cancel`}):null,(0,q.jsx)(M,{variant:`outline`,size:`sm`,className:r($,`sm:ms-auto`),asChild:!0,children:(0,q.jsx)(R,{to:`/automations/${e.id}/log`,children:`Execution log`})})]})}function er({automation:e,busy:t,keepRef:n,onConfirm:r,onKeep:i}){return(0,q.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[(0,q.jsx)(`p`,{className:`text-sm break-words`,children:`Cancel “${e.name}”? It will never run, and it moves to Archived.`}),(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,q.jsx)(M,{variant:`danger-ghost`,"data-action":`automation-cancel-confirm`,disabled:t,onClick:r,children:`Cancel schedule`}),(0,q.jsx)(M,{ref:n,variant:`outline`,disabled:t,onClick:i,children:`Keep`})]})]})}function tr({note:e}){return(0,q.jsxs)(`p`,{role:e.tone===`error`?`alert`:`status`,className:r(`text-sm break-words`,e.tone===`error`?`text-destructive`:`text-muted-foreground`),children:[e.text,e.runId?(0,q.jsxs)(q.Fragment,{children:[` · `,(0,q.jsx)(R,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${e.runId}`,children:`Open task`})]}):null]})}function nr({automation:e,timeZone:t,note:n,busy:r,onRun:i,onToggle:a,onPreview:o,onCancel:s}){let[c,l]=(0,U.useState)(!1),u=(0,U.useRef)(null),d=(0,U.useRef)(null),f=(0,U.useRef)(null);(0,U.useEffect)(()=>{let e=f.current===`keep`?d.current:f.current===`cancel`?u.current:null;f.current=null,e?.focus()},[c]);let p=()=>{f.current=`keep`,l(!0)},m=()=>{f.current=`cancel`,l(!1)},h=e.archived;return(0,q.jsxs)(`li`,{"data-slot":`automation-card`,"data-kind":e.kind,className:`flex min-w-0 flex-col gap-2.5 rounded-xl border border-card-edge bg-card p-4 shadow-card`,children:[(0,q.jsx)(Yn,{automation:e,nextRun:h?void 0:(0,q.jsx)(Zn,{automation:e,timeZone:t})}),h?(0,q.jsx)(Xn,{automation:e,archive:h}):null,h?null:(0,q.jsx)(Qn,{automation:e,timeZone:t}),h?null:(0,q.jsx)($n,{automation:e,busy:r,confirmingCancel:c,cancelRef:u,onToggle:a,onRun:i,onPreview:o,onOpenCancel:p}),e.schedule?.type===`once`&&!h&&c?(0,q.jsx)(er,{automation:e,busy:r,keepRef:d,onConfirm:()=>{l(!1),s()},onKeep:m}):null,n?(0,q.jsx)(tr,{note:n}):null,(0,q.jsx)(kt,{automationId:e.id,automationName:e.name,timeZone:t})]})}function rr(e){let t=Te(),n=Pe(),[r,i]=(0,U.useState)(),[a,o]=(0,U.useState)(``),s=(0,U.useCallback)(t=>ie({signal:t,...e?{archived:e}:{}}).then(e=>{t?.aborted||(i(e),o(``))}).catch(e=>{t?.aborted||o(String(e))}),[e]);return(0,U.useEffect)(()=>{n&&s()},[n,s]),(0,U.useEffect)(()=>p(async e=>{n&&await s(e)}),[n,s]),(0,U.useEffect)(()=>ue((e,n)=>{if(e!==`automation-change`)return;let r=n;typeof r.project==`string`&&(t===null||r.project===t)&&s()}),[t,s]),{data:r,error:a,refresh:s}}function ir({mode:e=`list`}){let{automationId:t}=le(),n=we(),[r,i]=(0,U.useState)(!1),{data:a,error:o,refresh:s}=rr(`include`),[c,l]=(0,U.useState)(0),u=Ne();if(u===`unknown`)return(0,q.jsx)(B,{route:`automations`,density:`empty`,children:(0,q.jsx)(J,{text:`Loading automations…`})});if(u===`absent`)return(0,q.jsx)(je,{});if(u===`disabled`)return(0,q.jsx)(B,{route:`automations`,density:`empty`,children:(0,q.jsx)(Ae,{icon:(0,q.jsx)(ge,{}),tone:`neutral`,title:`Automations are off`,subtitle:`This server does not run schedules, poll GitHub or launch tasks from them. Unset CEZ_AUTOMATIONS or set it to 1 and restart Squawk to turn automations on.`,heading:`h2`})});let d=()=>{n(`/automations`),s()},f=a?.automations.find(e=>e.id===t);if(e===`list`)return(0,q.jsx)(Gn,{data:a,error:o,refresh:s,archived:r,onArchivedChange:i});if(!a)return o?(0,q.jsx)(B,{route:`automations`,density:`empty`,header:{title:`Automations`,subtitle:`Could not load automations.`},children:(0,q.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,q.jsx)(J,{text:o}),(0,q.jsx)(M,{variant:`outline`,onClick:()=>void s(),children:`Retry`})]})}):(0,q.jsx)(B,{route:`automations`,density:`empty`,children:(0,q.jsx)(J,{text:`Loading automations…`})});let p={available:a.available,...a.reason?{reason:a.reason}:{}};return e===`new`?(0,q.jsx)(Vn,{forge:p,timeZone:a.timeZone,onSaved:d}):e===`edit`?f?f.archived?(0,q.jsx)(At,{automation:f,timeZone:a.timeZone,onDeleted:d}):(0,q.jsx)(Vn,{automation:f,forge:p,timeZone:a.timeZone,onSaved:d,onReload:()=>void s().then(()=>l(e=>e+1))},`${f.id}:${c}`):(0,q.jsx)(B,{route:`automations`,density:`empty`,header:{title:`Automation not found`,subtitle:`This automation may have been removed.`},children:(0,q.jsx)(M,{asChild:!0,variant:`outline`,children:(0,q.jsx)(R,{to:`/automations`,children:`Back to automations`})})}):t?(0,q.jsx)(Ot,{automationId:t,automationName:f?.name,timeZone:a.timeZone,readOnly:!!f?.archived}):(0,q.jsx)(J,{text:`Automation not found.`})}export{ir as AutomationsRoute};