@hearsay-tools/squawk 0.19.0-dev.9229.2 → 0.19.0-dev.9235

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 (135) hide show
  1. package/dist/activity/read-model.js +5 -2
  2. package/dist/activity/read-model.js.map +1 -1
  3. package/dist/contract/index.d.ts +1 -0
  4. package/dist/contract/index.js +2250 -1940
  5. package/dist/contract/runs.d.ts +117 -0
  6. package/dist/contract/task-result.d.ts +1075 -0
  7. package/dist/delegation/readiness.d.ts +8 -5
  8. package/dist/delegation/readiness.js +23 -9
  9. package/dist/delegation/readiness.js.map +1 -1
  10. package/dist/delegation/routes.d.ts +4 -4
  11. package/dist/delegation/service.js +4 -2
  12. package/dist/delegation/service.js.map +1 -1
  13. package/dist/delegation/worker-cleanup.js +1 -1
  14. package/dist/delegation/worker-cleanup.js.map +1 -1
  15. package/dist/project-migration/journal.d.ts +2 -0
  16. package/dist/project-migration/journal.js +1 -1
  17. package/dist/project-migration/journal.js.map +1 -1
  18. package/dist/project-migration/plan.js +2 -0
  19. package/dist/project-migration/plan.js.map +1 -1
  20. package/dist/runs/legacy-run-rows.d.ts +1 -1
  21. package/dist/runs/legacy-run-rows.js +7 -3
  22. package/dist/runs/legacy-run-rows.js.map +1 -1
  23. package/dist/runs/ports.d.ts +16 -1
  24. package/dist/runs/project-run-connection.d.ts +3 -0
  25. package/dist/runs/project-run-connection.js +57 -10
  26. package/dist/runs/project-run-connection.js.map +1 -1
  27. package/dist/runs/project-run-sources.d.ts +6 -0
  28. package/dist/runs/project-run-sources.js +20 -0
  29. package/dist/runs/project-run-sources.js.map +1 -1
  30. package/dist/runs/run-archive.d.ts +19 -0
  31. package/dist/runs/run-decode.d.ts +58 -0
  32. package/dist/runs/run-decode.js +10 -0
  33. package/dist/runs/run-decode.js.map +1 -1
  34. package/dist/runs/run-exits.d.ts +114 -0
  35. package/dist/runs/run-retention.d.ts +2 -0
  36. package/dist/runs/run-retention.js +11 -2
  37. package/dist/runs/run-retention.js.map +1 -1
  38. package/dist/runs/store.d.ts +3 -0
  39. package/dist/runs/store.js +11 -5
  40. package/dist/runs/store.js.map +1 -1
  41. package/dist/runs/task-result-commit.d.ts +24 -0
  42. package/dist/runs/task-result-commit.js +114 -0
  43. package/dist/runs/task-result-commit.js.map +1 -0
  44. package/dist/runs/task-results.d.ts +61 -0
  45. package/dist/runs/task-results.js +220 -0
  46. package/dist/runs/task-results.js.map +1 -0
  47. package/dist/runs/worker-result-commit.d.ts +12 -12
  48. package/dist/runs/worker-result-commit.js +77 -55
  49. package/dist/runs/worker-result-commit.js.map +1 -1
  50. package/dist/runs/worker-results.d.ts +10 -26
  51. package/dist/runs/worker-results.js +11 -73
  52. package/dist/runs/worker-results.js.map +1 -1
  53. package/dist/server/runs-routes.d.ts +205 -34
  54. package/dist/server/server.d.ts +1660 -1318
  55. package/dist/workflows/continuation-admission.d.ts +91 -72
  56. package/dist/workflows/input-acknowledgement.d.ts +24 -24
  57. package/dist/workflows/run/completion-gate.js +10 -4
  58. package/dist/workflows/run/completion-gate.js.map +1 -1
  59. package/dist/workflows/run/wait-engine.d.ts +91 -72
  60. package/package.json +4 -4
  61. package/web/dist/assets/{accounts-section-lnMwvHTo.js → accounts-section-BOZ9JyE6.js} +1 -1
  62. package/web/dist/assets/{activity-motion-DBxIOskd.js → activity-motion-D48R7Vry.js} +1 -1
  63. package/web/dist/assets/{activity-route-BYf5OD8Y.js → activity-route-jcGRtnMT.js} +1 -1
  64. package/web/dist/assets/{agent-accounts-BzD14qLU.js → agent-accounts-CUthX0Yh.js} +1 -1
  65. package/web/dist/assets/{agent-config-section-BwmBjoad.js → agent-config-section-BvwoyNZb.js} +1 -1
  66. package/web/dist/assets/{agent-defaults-section-BbFvw0IO.js → agent-defaults-section-Hb-jy4TN.js} +1 -1
  67. package/web/dist/assets/{appearance-CkohbKAs.js → appearance-EXKzoghV.js} +1 -1
  68. package/web/dist/assets/{archive-on-merge-field-CQ8DBqiG.js → archive-on-merge-field-Ni7bKGkG.js} +1 -1
  69. package/web/dist/assets/{ask-card-Bli7vYif.js → ask-card-CkE44gm3.js} +1 -1
  70. package/web/dist/assets/{automations-route-BNYFQeuu.js → automations-route-3bhtdTy3.js} +1 -1
  71. package/web/dist/assets/{commit-list-CJZtpbaw.js → commit-list-DSw7qvVY.js} +1 -1
  72. package/web/dist/assets/{diff-DPSOaO5_.js → diff-BidPzsVK.js} +2 -2
  73. package/web/dist/assets/{diff-controls-rfNgY_Dd.js → diff-controls-DeMSGYln.js} +1 -1
  74. package/web/dist/assets/{diff-view-CswchTTd.js → diff-view-BqU4sJld.js} +1 -1
  75. package/web/dist/assets/{discard-changes-dialog-BMT0YtWx.js → discard-changes-dialog-B1AO0GSt.js} +1 -1
  76. package/web/dist/assets/{file-preview-DoaMlVS3.js → file-preview-BIZXTzkp.js} +1 -1
  77. package/web/dist/assets/{folder-browser-D_q7aPq-.js → folder-browser-C9Phl0rS.js} +1 -1
  78. package/web/dist/assets/{git-toolbar-BCqNvkr5.js → git-toolbar-BBon1yHh.js} +1 -1
  79. package/web/dist/assets/{github-Bv1h-3dP.js → github-QOB5Qi4v.js} +1 -1
  80. package/web/dist/assets/{global-activity-route-CrAG-ji7.js → global-activity-route-lSnYAZE9.js} +1 -1
  81. package/web/dist/assets/{hosts-pzCm30ta.js → hosts-DDwDUxT9.js} +1 -1
  82. package/web/dist/assets/{index-D9hyWO4C.js → index-BuR9xHfb.js} +5 -5
  83. package/web/dist/assets/{label-DEZnEIpB.js → label-D6vgq5lF.js} +1 -1
  84. package/web/dist/assets/{markdown-BRE9fTUI.js → markdown-A6dvDky9.js} +1 -1
  85. package/web/dist/assets/{open-in-menu-DomSOC26.js → open-in-menu-Bb_jc7pm.js} +1 -1
  86. package/web/dist/assets/{option-select-Cqnmt-CB.js → option-select-CCpypHbW.js} +1 -1
  87. package/web/dist/assets/{preferences-section-CC4m45tb.js → preferences-section-B75Zx0mY.js} +1 -1
  88. package/web/dist/assets/{preview-DFL4D2C_.js → preview-DiBpgf-5.js} +1 -1
  89. package/web/dist/assets/{preview-pane-connected-CvF3zJ9A.js → preview-pane-connected-BVu2oO0V.js} +1 -1
  90. package/web/dist/assets/{project-location-D6-Lo1vY.js → project-location-D1etWKHg.js} +1 -1
  91. package/web/dist/assets/{project-router-CARDbdMX.js → project-router-yoWCTDaT.js} +1 -1
  92. package/web/dist/assets/project-scope-context-hfRzPMZ4.js +4 -0
  93. package/web/dist/assets/{projects-section-zeGtqnI3.js → projects-section-BRnIJ47e.js} +1 -1
  94. package/web/dist/assets/{prompt-templates-section--ygct2zC.js → prompt-templates-section-D7JLM5BM.js} +1 -1
  95. package/web/dist/assets/{queries-D7W-eGim.js → queries-ChH9ctc-.js} +1 -1
  96. package/web/dist/assets/{reference-chip-D8ckcrda.js → reference-chip-BPRZm7Kb.js} +1 -1
  97. package/web/dist/assets/{remote-settings-notice-MxDxNXXw.js → remote-settings-notice-Ip6H5hLU.js} +1 -1
  98. package/web/dist/assets/{repo-git-VfTEbVO3.js → repo-git-Wf30akEt.js} +1 -1
  99. package/web/dist/assets/{report-reader-DLCLUfdH.js → report-reader-DhcZcNql.js} +1 -1
  100. package/web/dist/assets/{report-selection-BcsbTczw.js → report-selection-CwPw7vbG.js} +1 -1
  101. package/web/dist/assets/{reports-QoDlngjL.js → reports-DPKDwzxY.js} +1 -1
  102. package/web/dist/assets/{resources-section-CBL0htm5.js → resources-section-DaWcyqur.js} +1 -1
  103. package/web/dist/assets/{review-notes-drafts-DJDQNemf.js → review-notes-drafts-D7QuBuTL.js} +1 -1
  104. package/web/dist/assets/{review-panel-BY05CuXd.js → review-panel-Bpxl4TvO.js} +1 -1
  105. package/web/dist/assets/{review-strip-BWhQ5CIC.js → review-strip-Da5n1k8s.js} +1 -1
  106. package/web/dist/assets/{run-detail-refresh-CecZhU-h.js → run-detail-refresh-CVSK_VKG.js} +1 -1
  107. package/web/dist/assets/{run-diff-CpwwrpXO.js → run-diff-CPuNFD3X.js} +1 -1
  108. package/web/dist/assets/{run-header-CZU3e9Xk.js → run-header-B8EAOHFc.js} +1 -1
  109. package/web/dist/assets/{select-C72KGfnK.js → select-xjUzLrk9.js} +1 -1
  110. package/web/dist/assets/{session-context-section-D8v30mSp.js → session-context-section-C7OTexKU.js} +1 -1
  111. package/web/dist/assets/{settings-agent-picker-DGhJwDIY.js → settings-agent-picker-mESK-hj4.js} +1 -1
  112. package/web/dist/assets/{settings-save-bar-Dp-eEIEF.js → settings-save-bar-BUaa1kHw.js} +1 -1
  113. package/web/dist/assets/{settings-shell-DZzgCmSz.js → settings-shell-BKSsBxqQ.js} +1 -1
  114. package/web/dist/assets/{sidebar-section-B94mdYUS.js → sidebar-section-BFBZlQ-x.js} +1 -1
  115. package/web/dist/assets/{skills-B6jO_f1w.js → skills-BSqszv5g.js} +1 -1
  116. package/web/dist/assets/{status-dot-B5MkhHDP.js → status-dot-Fp5SnPHI.js} +1 -1
  117. package/web/dist/assets/{tab-link-zXPa9LIz.js → tab-link-j06AaWSU.js} +1 -1
  118. package/web/dist/assets/{task-changes-B_2BDWIf.js → task-changes-B4KFHxVa.js} +1 -1
  119. package/web/dist/assets/{task-commits-kxDG4T81.js → task-commits-D-UAUoZ5.js} +1 -1
  120. package/web/dist/assets/{task-file-scope-DVACyrij.js → task-file-scope-BhWG35a8.js} +1 -1
  121. package/web/dist/assets/{task-files-4CxXkPOx.js → task-files-BOCx_Lp0.js} +1 -1
  122. package/web/dist/assets/{task-github-item-C8hMZej3.js → task-github-item-CZqaaxNv.js} +1 -1
  123. package/web/dist/assets/{task-thread-Bv_Fjceh.js → task-thread-D3d419VX.js} +1 -1
  124. package/web/dist/assets/{thread-state-CufNf_fC.js → thread-state-B0pz2Y8K.js} +1 -1
  125. package/web/dist/assets/{use-finish-run-CjYc6ovQ.js → use-finish-run-TX3pIPCS.js} +1 -1
  126. package/web/dist/assets/{use-hand-to-agent-state-B_j_e1kD.js → use-hand-to-agent-state-D2oChRzw.js} +1 -1
  127. package/web/dist/assets/use-path-bases-DFxEHoyU.js +1 -0
  128. package/web/dist/assets/use-workspace-config-save-DR8brU5p.js +1 -0
  129. package/web/dist/assets/{workflows-iMfDerlK.js → workflows-BwzNhxT0.js} +1 -1
  130. package/web/dist/assets/{workspace-tools-CgYFRggf.js → workspace-tools-Be_j9oke.js} +1 -1
  131. package/web/dist/assets/{worktrees-section-CtT9bwKK.js → worktrees-section-cnibWU5-.js} +1 -1
  132. package/web/dist/index.html +14 -14
  133. package/web/dist/assets/project-scope-context-Bz7AAyJ4.js +0 -4
  134. package/web/dist/assets/use-path-bases-BfjK7tem.js +0 -1
  135. package/web/dist/assets/use-workspace-config-save-toCmvqtz.js +0 -1
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{B as r,b as i,bt as a,gt as o,h as s,in as c,m as l,mt as u}from"./queries-D7W-eGim.js";import{Cn as d,Qi as f,a as p}from"./project-scope-context-Bz7AAyJ4.js";import{o as m}from"./dist-CCX8mhHc.js";import{t as h}from"./button-BV_AiLj2.js";import{t as g}from"./badge-DAnkqD7i.js";import{t as _}from"./centered-state-N8vWM_Hw.js";import{F as v,Hn as y,Rn as b,br as x}from"./index-D9hyWO4C.js";import{n as S,r as C,t as w}from"./remote-settings-notice-MxDxNXXw.js";import{t as T}from"./use-path-bases-BfjK7tem.js";import{t as E}from"./code-editor-DZMD1guX.js";import{t as D}from"./discard-changes-dialog-BMT0YtWx.js";import{r as O}from"./settings-save-bar-Dp-eEIEF.js";var k=e(t(),1);function A(e){return t=>t.runners.includes(e)}function j(e,t){let n=A(e);return e=>n(e)&&e.kind===t}function M(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:j(e.id,t)}))}}function N(e){return u(e).map(M)}var P=n();function F(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 I(){let e=l(),t=C(),n=r(),i=a(),s=i.data,c=(0,k.useMemo)(()=>N(s),[s]),u=(0,k.useMemo)(()=>n.data?v(n.data.checks,s):o(s),[n.data,s]);return i.isError?(0,P.jsx)(_,{icon:(0,P.jsx)(x,{}),tone:`danger`,title:`Runners did not load`,subtitle:i.error.message,heading:`h2`}):e.isError?(0,P.jsx)(_,{icon:(0,P.jsx)(x,{}),tone:`danger`,title:`Agent config did not load`,subtitle:e.error.message,heading:`h2`}):e.isPending||s===void 0?(0,P.jsx)(`p`,{"data-slot":`agent-config-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading agent config…`}):(0,P.jsx)(L,{listing:e.data,descriptors:c,installed:u,onOpenFile:t})}function L({listing:e,descriptors:t,installed:n,onOpenFile:r}){let[i,a]=(0,k.useState)(`claude`),[o,s]=(0,k.useState)(null),[c,l]=(0,k.useState)(!1),[u,d]=(0,k.useState)(null),f=t.find(e=>e.id===i)??t[0];if(f===void 0)return null;let p=R(f,e),h=p.find(e=>e.id===o)??z(p),_=e=>{c?d(()=>e):e()},v=e=>{e!==f.id&&_(()=>{a(e),s(null)})};return(0,P.jsxs)(`div`,{"data-slot":`agent-config`,className:`flex flex-col gap-5 p-4 md:p-6`,children:[(0,P.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Edit project, local, and user-wide config files for each coding agent.`}),!e.editable&&(0,P.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,P.jsx)(`code`,{children:w}),`.`]}),(0,P.jsx)(S,{risk:`Agent config can define hooks and MCP servers that run commands on the machine running Squawk`}),(0,P.jsx)(`div`,{"data-slot":`agent-config-agents`,role:`tablist`,className:`flex flex-wrap gap-1`,children:t.map(e=>(0,P.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":e.id===f.id,"data-slot":`agent-config-agent`,"data-agent":e.id,"data-selected":e.id===f.id,onClick:()=>v(e.id),className:m(`flex min-w-11 items-center justify-center gap-2 rounded-md px-3 py-1.5 text-[13px] transition-colors`,e.id===f.id?`bg-background font-semibold shadow-sm`:`hover:bg-muted/60`),children:[e.label,!n.includes(e.id)&&(0,P.jsx)(g,{variant:`outline`,className:`text-xs text-soft-foreground`,children:`Not installed`})]},e.id))}),f.note&&(0,P.jsx)(`p`,{"data-slot":`agent-config-agent-note`,className:`text-xs text-muted-foreground`,children:f.note}),(0,P.jsxs)(`div`,{className:`grid min-w-0 gap-6 lg:grid-cols-[minmax(17rem,24rem)_minmax(0,1fr)]`,children:[(0,P.jsx)(`nav`,{"data-slot":`agent-config-nav`,className:`flex min-w-0 flex-col gap-5`,children:(0,P.jsx)(V,{agent:f,listing:e,selectedId:h?.id??null,onSelect:e=>{if(e===h?.id){r();return}_(()=>{s(e),r()})}})}),(0,P.jsx)(`div`,{"data-slot":`agent-config-editor-pane`,className:`min-w-0`,children:h?(0,P.jsx)(U,{file:h,onDirtyChange:l},h.id):(0,P.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.`})})]}),(0,P.jsx)(D,{open:u!==null,subject:h?.label??`this file`,onKeep:()=>d(null),onDiscard:()=>{let e=u;d(null),l(!1),e?.()}})]})}function R(e,t){return e.groups.flatMap(e=>t.files.filter(e.files))}function z(e){return e.find(e=>e.scope===`project`)??e[0]??null}var B={project:`Project scope`,local:`Local scope`,user:`User scope`};function V({agent:e,listing:t,selectedId:n,onSelect:r}){let i=T();return(0,P.jsx)(P.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,P.jsxs)(`section`,{"data-slot":`agent-config-group`,"data-group":a.id,"data-agent":e.id,children:[(0,P.jsx)(`p`,{className:`mb-1 text-xs font-medium uppercase tracking-wide text-soft-foreground`,children:a.label}),a.note&&(0,P.jsx)(`p`,{className:`mb-2 text-xs text-muted-foreground`,children:a.note}),o.length===0&&a.empty&&(0,P.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,P.jsx)(`ul`,{className:`flex flex-col gap-1`,children:o.map(e=>(0,P.jsx)(`li`,{children:(0,P.jsxs)(`button`,{type:`button`,"data-slot":`agent-config-file`,"data-selected":e.id===n,onClick:()=>r(e.id),title:e.label,className:m(`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,P.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,P.jsxs)(`span`,{"data-slot":`agent-config-file-meta`,className:`flex flex-wrap items-center gap-1.5`,children:[e.seeded&&(0,P.jsx)(g,{variant:`outline`,className:`text-xs`,children:`Default template`}),!e.exists&&(0,P.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Not created`})]}):null]})},e.id))}),s&&(0,P.jsx)(H,{userMcp:s,path:y(s.path,i)})]},a.id)})})}function H({userMcp:e,path:t}){return(0,P.jsxs)(`div`,{"data-slot":`agent-config-user-mcp`,className:`mt-3`,children:[(0,P.jsx)(`h4`,{className:`mb-1 text-[12px] font-semibold`,children:`User & local scopes`}),(0,P.jsxs)(`p`,{className:`mb-2 text-xs text-muted-foreground`,children:[`Managed by `,(0,P.jsx)(`code`,{"data-slot":`agent-config-user-mcp-command`,className:`whitespace-nowrap font-mono`,children:`claude mcp add`}),` in`,` `,(0,P.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,P.jsx)(`ul`,{className:`flex flex-wrap gap-1`,children:e.servers.map(e=>(0,P.jsx)(`li`,{children:(0,P.jsx)(g,{variant:`outline`,className:`font-mono text-xs`,children:e})},e))}):(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No user-scoped MCP servers.`}):(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Could not read the file.`})]})}function U({file:e,onDirtyChange:t}){let n=s(e.id),r=T(),[i,a]=(0,k.useState)(null),[o,c]=(0,k.useState)(!1),[l,u]=(0,k.useState)(null),d=n.data?.version??null,f=i??n.data?.content??``,p=n.data?f!==n.data.content:!1,m=e.writable,h=e.kind===`mcp`||e.holdsMcp,_=m&&p;(0,k.useEffect)(()=>{t?.(_)},[_,t]),(0,k.useEffect)(()=>()=>t?.(!1),[t]);let{save:v}=J({file:e,content:f,loadedVersion:d,setDraft:a,setConflict:c,setFormatError:u});return O({dirty:m&&p,save:v,discard:()=>a(null)}),(0,k.useEffect)(()=>{n.data&&(a(n.data.content),c(!1),u(null))},[n.data?.version,n.data]),(0,P.jsxs)(`div`,{"data-slot":`settings-config-editor`,"data-reports-dirty":``,className:`flex flex-col gap-3`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(`h3`,{className:`text-sm`,children:`Configuration file`}),(0,P.jsx)(g,{variant:`outline`,"data-slot":`agent-config-scope`,"data-scope":e.scope,className:`text-[12px]`,children:B[e.scope]})]}),(0,P.jsx)(b,{"data-slot":`agent-config-path`,value:e.path,bases:r,className:`text-xs text-foreground`}),(0,P.jsxs)(`div`,{className:`settings-readout flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(`span`,{className:`font-mono text-[13px]`,children:e.label}),(0,P.jsx)(g,{variant:`outline`,className:`text-[12px] uppercase`,children:e.format}),(0,P.jsx)(`a`,{href:e.docsUrl,target:`_blank`,rel:`noreferrer`,className:`text-[12px] text-soft-foreground underline hover:text-foreground`,children:`docs`})]}),(0,P.jsxs)(`div`,{className:`settings-config-content-heading`,children:[(0,P.jsx)(`h3`,{children:h?`MCP configuration`:`File contents`}),h&&(0,P.jsx)(`p`,{children:`Review server commands before saving. MCP servers execute locally.`})]}),n.isPending?(0,P.jsx)(`p`,{className:`text-[13px] text-soft-foreground`,children:`Loading file…`}):n.isError?(0,P.jsx)(`p`,{className:`text-[13px] text-destructive`,children:n.error.message}):(0,P.jsx)(W,{file:e,content:f,isMcp:h,onChange:a}),(0,P.jsx)(K,{formatError:l,conflict:o,onReload:()=>void n.refetch()}),m&&!e.exists&&!p?(0,P.jsx)(`p`,{"data-slot":`agent-config-save-cue`,className:`text-xs text-muted-foreground`,children:`Enter content above to create this file.`}):null,(0,P.jsxs)(`div`,{className:`settings-config-save-help`,children:[(0,P.jsx)(`p`,{"data-slot":`agent-config-precedence`,className:`text-xs text-muted-foreground`,children:e.precedence}),(0,P.jsxs)(`p`,{"data-slot":`agent-config-effect`,className:`text-xs text-foreground`,children:[F(e),e.hotReload?` ${e.hotReload}`:``]}),(0,P.jsx)(q,{reason:e.readOnlyReason})]})]})}function W({file:e,content:t,isMcp:n,onChange:r}){return(0,P.jsxs)(`div`,{"data-slot":`agent-config-editor-frame`,className:`relative`,children:[(0,P.jsx)(E,{value:t,language:e.format,readOnly:!e.writable,onChange:r,"aria-label":`${e.label} contents`,className:`h-[210px]`}),!e.exists&&t===``&&(0,P.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:G(e,n)})]})}function G(e,t){switch(e.format){case`json`:case`jsonc`:return`// File not created yet — example:\n${t?`{
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{B as r,b as i,bt as a,gt as o,h as s,in as c,m as l,mt as u}from"./queries-ChH9ctc-.js";import{Cn as d,Qi as f,a as p}from"./project-scope-context-hfRzPMZ4.js";import{o as m}from"./dist-CCX8mhHc.js";import{t as h}from"./button-BV_AiLj2.js";import{t as g}from"./badge-DAnkqD7i.js";import{t as _}from"./centered-state-N8vWM_Hw.js";import{F as v,Hn as y,Rn as b,br as x}from"./index-BuR9xHfb.js";import{n as S,r as C,t as w}from"./remote-settings-notice-Ip6H5hLU.js";import{t as T}from"./use-path-bases-DFxEHoyU.js";import{t as E}from"./code-editor-DZMD1guX.js";import{t as D}from"./discard-changes-dialog-B1AO0GSt.js";import{r as O}from"./settings-save-bar-BUaa1kHw.js";var k=e(t(),1);function A(e){return t=>t.runners.includes(e)}function j(e,t){let n=A(e);return e=>n(e)&&e.kind===t}function M(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:j(e.id,t)}))}}function N(e){return u(e).map(M)}var P=n();function F(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 I(){let e=l(),t=C(),n=r(),i=a(),s=i.data,c=(0,k.useMemo)(()=>N(s),[s]),u=(0,k.useMemo)(()=>n.data?v(n.data.checks,s):o(s),[n.data,s]);return i.isError?(0,P.jsx)(_,{icon:(0,P.jsx)(x,{}),tone:`danger`,title:`Runners did not load`,subtitle:i.error.message,heading:`h2`}):e.isError?(0,P.jsx)(_,{icon:(0,P.jsx)(x,{}),tone:`danger`,title:`Agent config did not load`,subtitle:e.error.message,heading:`h2`}):e.isPending||s===void 0?(0,P.jsx)(`p`,{"data-slot":`agent-config-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading agent config…`}):(0,P.jsx)(L,{listing:e.data,descriptors:c,installed:u,onOpenFile:t})}function L({listing:e,descriptors:t,installed:n,onOpenFile:r}){let[i,a]=(0,k.useState)(`claude`),[o,s]=(0,k.useState)(null),[c,l]=(0,k.useState)(!1),[u,d]=(0,k.useState)(null),f=t.find(e=>e.id===i)??t[0];if(f===void 0)return null;let p=R(f,e),h=p.find(e=>e.id===o)??z(p),_=e=>{c?d(()=>e):e()},v=e=>{e!==f.id&&_(()=>{a(e),s(null)})};return(0,P.jsxs)(`div`,{"data-slot":`agent-config`,className:`flex flex-col gap-5 p-4 md:p-6`,children:[(0,P.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Edit project, local, and user-wide config files for each coding agent.`}),!e.editable&&(0,P.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,P.jsx)(`code`,{children:w}),`.`]}),(0,P.jsx)(S,{risk:`Agent config can define hooks and MCP servers that run commands on the machine running Squawk`}),(0,P.jsx)(`div`,{"data-slot":`agent-config-agents`,role:`tablist`,className:`flex flex-wrap gap-1`,children:t.map(e=>(0,P.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":e.id===f.id,"data-slot":`agent-config-agent`,"data-agent":e.id,"data-selected":e.id===f.id,onClick:()=>v(e.id),className:m(`flex min-w-11 items-center justify-center gap-2 rounded-md px-3 py-1.5 text-[13px] transition-colors`,e.id===f.id?`bg-background font-semibold shadow-sm`:`hover:bg-muted/60`),children:[e.label,!n.includes(e.id)&&(0,P.jsx)(g,{variant:`outline`,className:`text-xs text-soft-foreground`,children:`Not installed`})]},e.id))}),f.note&&(0,P.jsx)(`p`,{"data-slot":`agent-config-agent-note`,className:`text-xs text-muted-foreground`,children:f.note}),(0,P.jsxs)(`div`,{className:`grid min-w-0 gap-6 lg:grid-cols-[minmax(17rem,24rem)_minmax(0,1fr)]`,children:[(0,P.jsx)(`nav`,{"data-slot":`agent-config-nav`,className:`flex min-w-0 flex-col gap-5`,children:(0,P.jsx)(V,{agent:f,listing:e,selectedId:h?.id??null,onSelect:e=>{if(e===h?.id){r();return}_(()=>{s(e),r()})}})}),(0,P.jsx)(`div`,{"data-slot":`agent-config-editor-pane`,className:`min-w-0`,children:h?(0,P.jsx)(U,{file:h,onDirtyChange:l},h.id):(0,P.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.`})})]}),(0,P.jsx)(D,{open:u!==null,subject:h?.label??`this file`,onKeep:()=>d(null),onDiscard:()=>{let e=u;d(null),l(!1),e?.()}})]})}function R(e,t){return e.groups.flatMap(e=>t.files.filter(e.files))}function z(e){return e.find(e=>e.scope===`project`)??e[0]??null}var B={project:`Project scope`,local:`Local scope`,user:`User scope`};function V({agent:e,listing:t,selectedId:n,onSelect:r}){let i=T();return(0,P.jsx)(P.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,P.jsxs)(`section`,{"data-slot":`agent-config-group`,"data-group":a.id,"data-agent":e.id,children:[(0,P.jsx)(`p`,{className:`mb-1 text-xs font-medium uppercase tracking-wide text-soft-foreground`,children:a.label}),a.note&&(0,P.jsx)(`p`,{className:`mb-2 text-xs text-muted-foreground`,children:a.note}),o.length===0&&a.empty&&(0,P.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,P.jsx)(`ul`,{className:`flex flex-col gap-1`,children:o.map(e=>(0,P.jsx)(`li`,{children:(0,P.jsxs)(`button`,{type:`button`,"data-slot":`agent-config-file`,"data-selected":e.id===n,onClick:()=>r(e.id),title:e.label,className:m(`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,P.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,P.jsxs)(`span`,{"data-slot":`agent-config-file-meta`,className:`flex flex-wrap items-center gap-1.5`,children:[e.seeded&&(0,P.jsx)(g,{variant:`outline`,className:`text-xs`,children:`Default template`}),!e.exists&&(0,P.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Not created`})]}):null]})},e.id))}),s&&(0,P.jsx)(H,{userMcp:s,path:y(s.path,i)})]},a.id)})})}function H({userMcp:e,path:t}){return(0,P.jsxs)(`div`,{"data-slot":`agent-config-user-mcp`,className:`mt-3`,children:[(0,P.jsx)(`h4`,{className:`mb-1 text-[12px] font-semibold`,children:`User & local scopes`}),(0,P.jsxs)(`p`,{className:`mb-2 text-xs text-muted-foreground`,children:[`Managed by `,(0,P.jsx)(`code`,{"data-slot":`agent-config-user-mcp-command`,className:`whitespace-nowrap font-mono`,children:`claude mcp add`}),` in`,` `,(0,P.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,P.jsx)(`ul`,{className:`flex flex-wrap gap-1`,children:e.servers.map(e=>(0,P.jsx)(`li`,{children:(0,P.jsx)(g,{variant:`outline`,className:`font-mono text-xs`,children:e})},e))}):(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No user-scoped MCP servers.`}):(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Could not read the file.`})]})}function U({file:e,onDirtyChange:t}){let n=s(e.id),r=T(),[i,a]=(0,k.useState)(null),[o,c]=(0,k.useState)(!1),[l,u]=(0,k.useState)(null),d=n.data?.version??null,f=i??n.data?.content??``,p=n.data?f!==n.data.content:!1,m=e.writable,h=e.kind===`mcp`||e.holdsMcp,_=m&&p;(0,k.useEffect)(()=>{t?.(_)},[_,t]),(0,k.useEffect)(()=>()=>t?.(!1),[t]);let{save:v}=J({file:e,content:f,loadedVersion:d,setDraft:a,setConflict:c,setFormatError:u});return O({dirty:m&&p,save:v,discard:()=>a(null)}),(0,k.useEffect)(()=>{n.data&&(a(n.data.content),c(!1),u(null))},[n.data?.version,n.data]),(0,P.jsxs)(`div`,{"data-slot":`settings-config-editor`,"data-reports-dirty":``,className:`flex flex-col gap-3`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(`h3`,{className:`text-sm`,children:`Configuration file`}),(0,P.jsx)(g,{variant:`outline`,"data-slot":`agent-config-scope`,"data-scope":e.scope,className:`text-[12px]`,children:B[e.scope]})]}),(0,P.jsx)(b,{"data-slot":`agent-config-path`,value:e.path,bases:r,className:`text-xs text-foreground`}),(0,P.jsxs)(`div`,{className:`settings-readout flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(`span`,{className:`font-mono text-[13px]`,children:e.label}),(0,P.jsx)(g,{variant:`outline`,className:`text-[12px] uppercase`,children:e.format}),(0,P.jsx)(`a`,{href:e.docsUrl,target:`_blank`,rel:`noreferrer`,className:`text-[12px] text-soft-foreground underline hover:text-foreground`,children:`docs`})]}),(0,P.jsxs)(`div`,{className:`settings-config-content-heading`,children:[(0,P.jsx)(`h3`,{children:h?`MCP configuration`:`File contents`}),h&&(0,P.jsx)(`p`,{children:`Review server commands before saving. MCP servers execute locally.`})]}),n.isPending?(0,P.jsx)(`p`,{className:`text-[13px] text-soft-foreground`,children:`Loading file…`}):n.isError?(0,P.jsx)(`p`,{className:`text-[13px] text-destructive`,children:n.error.message}):(0,P.jsx)(W,{file:e,content:f,isMcp:h,onChange:a}),(0,P.jsx)(K,{formatError:l,conflict:o,onReload:()=>void n.refetch()}),m&&!e.exists&&!p?(0,P.jsx)(`p`,{"data-slot":`agent-config-save-cue`,className:`text-xs text-muted-foreground`,children:`Enter content above to create this file.`}):null,(0,P.jsxs)(`div`,{className:`settings-config-save-help`,children:[(0,P.jsx)(`p`,{"data-slot":`agent-config-precedence`,className:`text-xs text-muted-foreground`,children:e.precedence}),(0,P.jsxs)(`p`,{"data-slot":`agent-config-effect`,className:`text-xs text-foreground`,children:[F(e),e.hotReload?` ${e.hotReload}`:``]}),(0,P.jsx)(q,{reason:e.readOnlyReason})]})]})}function W({file:e,content:t,isMcp:n,onChange:r}){return(0,P.jsxs)(`div`,{"data-slot":`agent-config-editor-frame`,className:`relative`,children:[(0,P.jsx)(E,{value:t,language:e.format,readOnly:!e.writable,onChange:r,"aria-label":`${e.label} contents`,className:`h-[210px]`}),!e.exists&&t===``&&(0,P.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:G(e,n)})]})}function G(e,t){switch(e.format){case`json`:case`jsonc`:return`// File not created yet — example:\n${t?`{
2
2
  "mcpServers": {}
3
3
  }`:`{
4
4
  "permissions": {}
@@ -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{K as r,M as i,Q as a,S as o,St as s,U as c,W as l,Z as u,_r as d,an as f,bt as p,g as m,gt as h,in as g,mt as _,pt as v,xt as y}from"./queries-D7W-eGim.js";import{Cn as b,I as x,Qi as S,Rn as C,Zt as ee,a as w,r as T,vn as E}from"./project-scope-context-Bz7AAyJ4.js";import{c as D}from"./design-icons-QbNMZniQ.js";import{t as O}from"./button-BV_AiLj2.js";import{t as k}from"./switch-B9OfOEzC.js";import{t as A}from"./status-dot-B5MkhHDP.js";import{n as j}from"./agent-accounts-BzD14qLU.js";import{t as M}from"./centered-state-N8vWM_Hw.js";import{I as N,Mn as P,P as F,R as I}from"./index-D9hyWO4C.js";import{t as te}from"./textarea-BGp28xFr.js";import{t as L}from"./option-select-Cqnmt-CB.js";import{a as ne,i as R,n as z,r as B,t as V}from"./settings-agent-picker-DGhJwDIY.js";import{n as H,t as U}from"./save-cue-CpHgT93o.js";import{n as W}from"./settings-field-AyinSFR_.js";import{r as G}from"./settings-save-bar-Dp-eEIEF.js";import{n as K}from"./saved-draft-BwzBc-_Y.js";var q=e(t(),1),J=n(),Y={connected:P(`connected`),disconnected:P(`disconnected`),"not-installed":P(`not-installed`),unknown:P(`unknown`)};function X(e,t,n){return{providers:e.providers.map(e=>e.provider===t?{...e,enabled:n}:e)}}function re(e,t){return e?Y[e]:t?{label:`Checking…`,tone:`neutral`}:Y.unknown}function ie(e,t){return e===`unknown`||t&&!e}function ae({provider:e,state:t,current:n,statusIsError:r}){return t===`not-installed`?(0,J.jsxs)(`p`,{className:`mt-1.5 text-xs text-soft-foreground`,children:[`Install `,e.displayName,`, then run `,(0,J.jsx)(`code`,{children:e.loginCommand}),`.`]}):ie(t,r)?(0,J.jsx)(`p`,{className:`mt-1.5 text-xs text-soft-foreground`,children:`Verification failed. Check again when the provider is available.`}):n?.hint?(0,J.jsx)(`p`,{className:`mt-1.5 text-xs text-soft-foreground`,children:n.hint}):null}function oe({provider:e,state:t,current:n,isConnecting:r,incidentId:i,refresh:a,connect:o,retry:s,queueToggle:c}){let l=t===`disconnected`||t===`unknown`,u=H();return(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t===`not-installed`?null:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(U,{saved:u.saved}),(0,J.jsx)(k,{checked:n?.enabled??!0,"aria-label":`Use ${e.displayName}`,onCheckedChange:t=>c(e.id,t,u.flash)})]}),l?(0,J.jsx)(O,{type:`button`,variant:`ghost`,size:`sm`,disabled:a.isPending,onClick:()=>a.mutate(void 0,{onError:e=>w(e.message,{tone:`danger`})}),children:`Check again`}):null,t===`disconnected`&&e.browserLogin?(0,J.jsx)(z,{provider:e.id,label:e.displayName}):null,t===`disconnected`&&e.terminalLogin!==!1?(0,J.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,disabled:o.isPending,onClick:()=>o.mutate(e.id),children:r?`Opening…`:`Connect`}):null,i===void 0?null:(0,J.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,disabled:s.isPending,onClick:()=>s.mutate({provider:e.id,authFailureId:i},{onSuccess:()=>w(`${e.displayName} can be tried again.`),onError:e=>w(e.message,{tone:`danger`})}),children:`Try again`})]})}function se({manual:e,provider:t,connected:n,onCopy:r}){return e===null||e.provider!==t||n?null:(0,J.jsxs)(`div`,{role:`region`,"aria-label":`${e.label} manual sign-in`,className:`rounded-md border border-pending/40 bg-pending/5 px-3.5 py-3`,children:[(0,J.jsx)(`p`,{className:`text-[13px] text-foreground`,children:e.message}),(0,J.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(`code`,{className:`min-w-0 flex-1 overflow-x-auto rounded-sm bg-muted px-2 py-1.5 text-xs`,children:e.command}),(0,J.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void r(e.command),children:`Copy command`})]})]})}function ce(){let e=p(),t=l(),n=r(),i=u(),a=S(),[o,s]=(0,q.useState)(null),c=(0,q.useRef)(Promise.resolve()),m=(0,q.useRef)({}),h=(0,q.useRef)({}),g=(0,q.useRef)(t.data);(0,q.useEffect)(()=>{o&&C(t.data,o.provider)?.status===`connected`&&s(null)},[o,t.data]),(0,q.useEffect)(()=>{if(t.data){if(Object.values(h.current).every(e=>e===0)||!g.current){g.current=t.data;return}g.current={providers:t.data.providers.map(e=>({...e,enabled:(h.current[e.provider]??0)>0?C(g.current,e.provider)?.enabled??e.enabled:e.enabled}))}}},[t.data]);let x=(0,q.useCallback)((e,t,n)=>{let r=f.providerStatus,i=a.getQueryData(r);if(!i)return;g.current||=i;let o=X(i,e,t);h.current[e]=(h.current[e]??0)+1,a.setQueryData(r,o);let s=(m.current[e]??0)+1;m.current[e]=s,c.current=c.current.then(async()=>{try{let i=await E(e,t),o=C(i,e)?.enabled;if(o===void 0)return;if(g.current=X(g.current??i,e,o),s===m.current[e]){let t=a.getQueryData(r);a.setQueryData(r,t?X(t,e,o):i),n()}}catch(t){if(s===m.current[e]){let n=C(g.current,e)?.enabled,i=a.getQueryData(r);i&&n!==void 0?a.setQueryData(r,X(i,e,n)):g.current?a.setQueryData(r,g.current):a.removeQueries({queryKey:r,exact:!0}),w(t instanceof Error?t.message:String(t),{tone:`danger`})}}finally{h.current[e]=(h.current[e]??0)-1}})},[a]),T=d({mutationFn:e=>ee(e),onSuccess:async(e,t)=>{s(null),w(e.opened?`Finish signing in in the terminal, then check again.`:`Provider is already connected.`),await a.invalidateQueries({queryKey:f.providerStatus}),await y(a,t,`none`)},onError:(t,n)=>{if(t instanceof b&&t.command){let r=v(e.data,n);s({provider:n,label:r,message:t.message,command:t.command});return}w(t.message,{tone:`danger`})}}),D=async e=>{try{await navigator.clipboard.writeText(e),w(`Command copied`)}catch{w(`Could not copy the command`,{tone:`danger`})}};return(0,J.jsxs)(`section`,{id:`providers`,"data-slot":`provider-settings`,className:`scroll-mt-20`,children:[(0,J.jsxs)(`div`,{className:`mb-2`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Providers`}),(0,J.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Connect the coding agents available on this computer.`})]}),t.isError?(0,J.jsxs)(`div`,{role:`alert`,className:`mb-3 flex flex-wrap items-center justify-between gap-2 rounded-md border border-danger/30 bg-danger/5 px-3 py-2.5`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`p`,{className:`text-[13px] font-medium text-foreground`,children:`Provider status could not be loaded`}),(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.error.message})]}),(0,J.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,disabled:t.isFetching,onClick:()=>void t.refetch(),children:`Retry`})]}):null,(0,J.jsx)(`div`,{className:`flex flex-col gap-2`,children:_(e.data).map(e=>{let r=C(t.data,e.id),a=r?.status,s=re(a,t.isPending),c=T.isPending&&T.variables===e.id,l=r?.authFailureId;return(0,J.jsxs)(q.Fragment,{children:[(0,J.jsxs)(`div`,{"data-slot":`provider-card`,"data-provider":e.id,className:`rounded-md border border-border bg-card px-3.5 py-3`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`h3`,{className:`text-[13px] font-semibold text-foreground`,children:e.displayName}),(0,J.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,J.jsx)(A,{tone:s.tone,pulse:t.isPending}),(0,J.jsx)(`span`,{children:s.label}),r?.enabled===!1?(0,J.jsx)(`span`,{children:`Disabled`}):null]}),(0,J.jsx)(ae,{provider:e,state:a,current:r,statusIsError:t.isError})]}),(0,J.jsx)(oe,{provider:e,state:a,current:r,isConnecting:c,incidentId:l,refresh:n,connect:T,retry:i,queueToggle:x})]}),l===void 0?null:(0,J.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`Use this after completing the provider sign-in flow. Squawk cannot validate the credential without a task/model request; it will verify it on the next task.`})]}),(0,J.jsx)(se,{manual:o,provider:e.id,connected:a===`connected`,onCopy:D})]},e.id)})})]})}var Z=2e4;function le(){let e=m(),t=p(),n=s(h(t.data)),r=l();return e.isPending?(0,J.jsx)(`p`,{"data-slot":`agents-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading agent settings…`}):e.isError?(0,J.jsx)(M,{icon:(0,J.jsx)(D,{}),tone:`danger`,title:`Agent settings did not load`,subtitle:e.error.message,heading:`h2`}):(0,J.jsx)(ue,{config:e.data,catalogs:n,providerStatus:r,runners:t.data})}function ue({config:e,catalogs:t,providerStatus:n,runners:r}){let i=o(),a=S(),s=d({mutationFn:e=>x(e),onSuccess:e=>{a.setQueryData(g.config,e),a.invalidateQueries({queryKey:g.health}),a.invalidateQueries({queryKey:g.repo})},onError:e=>w(e.message,{tone:`danger`})}),[c,l]=K(e.systemPrompt??``),u=c.trim(),f=u===(e.systemPrompt??``),p=u.length>Z;G({dirty:!f,invalid:p,busy:s.isPending,save:()=>s.mutateAsync({systemPrompt:u===``?null:u}),discard:()=>l(e.systemPrompt??``)});let m=H(),h=H(),v=H(),y=H(),b=H(),C=(e,t)=>s.mutate(e,{onSuccess:t});return(0,J.jsxs)(`div`,{"data-slot":`agent-defaults-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,J.jsx)(Q,{defaultRunner:e.defaultRunner,providerStatus:n,saving:s.isPending,saved:m.saved,onSaved:m.flash,onPick:e=>C({defaultRunner:e},m.flash)}),(0,J.jsx)(W,{wide:!0,title:`Default model`,hint:e.modelsLocked?`Models are locked to the defaults configured in the native coding-agent settings.`:`The model preselected in the composer for each runner. Runner default lets the runner decide per task.`,saved:e.modelsLocked?void 0:h.saved,children:(0,J.jsx)(`div`,{"data-slot":`agents-model-rows`,className:`flex flex-col gap-2.5`,children:_(r).map(i=>{let{providerConnected:a,providerReason:o}=ne(n,i.id),c=t[i.id],l=N(i.id,r,c),u=I(i.id,r,c?.data,[e.defaultModels[i.id]]),d=e.defaultModels[i.id]??``,f=u.find(e=>e.id===d)?.label??d??`Runner default`;return(0,J.jsxs)(`label`,{className:`settings-option-row`,children:[(0,J.jsx)(`div`,{children:(0,J.jsx)(`h3`,{children:i.displayName})}),e.modelsLocked?(0,J.jsx)(`output`,{"aria-label":`Default model for ${i.pickerLabel}`,"data-slot":`agents-model`,"data-runner":i.id,title:`Model selection is locked to native coding-agent settings.`,className:`block rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs`,children:f}):(0,J.jsx)(L,{"aria-label":`Default model for ${i.pickerLabel}`,"data-slot":`agents-model`,"data-runner":i.id,value:d,title:o??i.pickerDescription,disabled:s.isPending||!a,onValueChange:e=>C({defaultModels:{[i.id]:e||null}},h.flash),className:`settings-select max-w-full bg-card`,options:[...u.map(e=>({value:e.id,label:e.label})),...l?[{value:F,label:l,disabled:!0}]:[]]})]},i.id)})})}),(0,J.jsxs)(W,{wide:!0,title:`System prompt`,hint:`Extra instructions for every run in this project.`,reportsDirty:!0,children:[(0,J.jsx)(te,{"aria-label":`System prompt`,"data-slot":`agents-system-prompt`,value:c,onChange:e=>l(e.target.value),placeholder:`Extra rules for every agent run — conventions, tone, review requirements…`,className:`min-h-48 w-full`}),(0,J.jsx)(de,{length:u.length,overLimit:p})]}),(0,J.jsxs)(`section`,{"data-slot":`agents-task-runs`,className:`settings-field flex flex-col gap-5`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Task runs`}),(0,J.jsx)($,{title:`Live title updates`,hint:`Refresh a task's short title through the namer model as the run progresses. A manual rename always wins and stops updates for that task.`,saved:v.saved,children:(0,J.jsxs)(`label`,{className:`flex w-fit items-center gap-3`,children:[(0,J.jsx)(k,{"aria-label":`Live title updates`,"data-slot":`agents-live-title-updates`,checked:e.liveTitleUpdates??!0,disabled:s.isPending,onCheckedChange:e=>C({liveTitleUpdates:e},v.flash)}),(0,J.jsxs)(`span`,{className:`text-[13px] text-muted-foreground`,children:[e.liveTitleUpdates??!0?`On`:`Off`,e.liveTitleUpdates===null&&` (default)`]})]})}),(0,J.jsx)($,{title:`Review changes before finishing`,hint:`When on, a task with changes pauses so you can Accept, Send back, or open a Draft PR. Autonomous tasks always skip this and finish on their own. Default: off — tasks finish without asking.`,saved:y.saved,children:(0,J.jsxs)(`label`,{className:`flex w-fit items-center gap-3`,children:[(0,J.jsx)(k,{"aria-label":`Review changes before finishing`,"data-slot":`agents-review-gate`,checked:e.reviewGate??!1,disabled:s.isPending,onCheckedChange:e=>C({reviewGate:e},y.flash)}),(0,J.jsxs)(`span`,{className:`text-[13px] text-muted-foreground`,children:[e.reviewGate??!1?`On`:`Off`,e.reviewGate===null&&` (default)`]})]})}),(0,J.jsx)($,{title:`Base branch`,hint:`New task worktrees branch from this and draft PRs target it. Also settable from the Git view.`,saved:b.saved,children:i.data?.info?(0,J.jsx)(L,{"aria-label":`Base branch`,"data-slot":`agents-base-branch`,value:e.baseBranch??``,disabled:s.isPending,onValueChange:e=>C({baseBranch:e||null},b.flash),className:`settings-select max-w-full bg-card`,options:[{value:``,label:`follow checked-out branch (default)`},...i.data.branches.map(e=>({value:e,label:e}))]}):(0,J.jsx)(`p`,{"data-slot":`agents-base-branch-unavailable`,className:`text-[13px] text-soft-foreground`,children:i.isPending?`Loading branches…`:`Not a git repository — tasks run in place, no branching.`})})]}),(0,J.jsxs)(`details`,{className:`settings-disclosure`,children:[(0,J.jsx)(`summary`,{children:`Provider connections`}),(0,J.jsx)(ce,{})]})]})}function Q({defaultRunner:e,providerStatus:t,saving:n,saved:r,onSaved:s,onPick:l}){let u=i(),d=c(),f=T(),m=o(),h=a(),g=f.projectId??`default`,_=m.data?.info?.root,v=j(u.data,f.projectId,_),y=p().data,b=B(u.data?.profiles??[],y),x=R(b,y);return(0,J.jsxs)(W,{title:`Default runner`,hint:`Project defaults. A task can override these choices.`,saved:r,children:[(0,J.jsx)(V,{rows:b,runner:e,accountFor:e=>v?.[e]??null,providerStatus:t,disabled:n,accountDisabled:h.isPending||d.data===void 0,onPick:(t,n,r)=>{t!==e&&l(t),r&&h.mutate({projectId:g,provider:t,profileId:n},{onSuccess:s,onError:e=>w(e.message,{tone:`danger`})})}}),!t.isPending&&!t.isError&&C(t.data,e)?.enabled===!1?(0,J.jsx)(`p`,{"data-slot":`agents-runner-disabled`,className:`text-[13px] text-muted-foreground`,children:`This provider is disabled. Enable it above or choose another provider.`}):null,x?(0,J.jsx)(`p`,{className:`max-w-md text-[13px] text-muted-foreground`,children:`The account is personal and never committed. Tasks already started under another account can’t be resumed here — their sessions live in that account’s folder.`}):null]})}function $({title:e,hint:t,saved:n,children:r}){return(0,J.jsxs)(`section`,{className:`settings-option-row`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h3`,{children:e}),(0,J.jsxs)(`p`,{children:[t,` `,(0,J.jsx)(U,{saved:n})]})]}),r]})}function de({length:e,overLimit:t}){return(0,J.jsx)(J.Fragment,{children:t?(0,J.jsxs)(`p`,{"data-slot":`agents-prompt-limit`,className:`text-xs text-danger`,children:[e.toLocaleString(),` characters — the limit is `,Z.toLocaleString(),`.`]}):(0,J.jsx)(`p`,{"data-slot":`agents-prompt-help`,className:`text-xs text-muted-foreground`,children:`Leave empty and save to clear. Applied to new runs only.`})})}export{le as AgentDefaultsSection};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{K as r,M as i,Q as a,S as o,St as s,U as c,W as l,Z as u,_r as d,an as f,bt as p,g as m,gt as h,in as g,mt as _,pt as v,xt as y}from"./queries-ChH9ctc-.js";import{Cn as b,I as x,Qi as S,Rn as C,Zt as ee,a as w,r as T,vn as E}from"./project-scope-context-hfRzPMZ4.js";import{c as D}from"./design-icons-QbNMZniQ.js";import{t as O}from"./button-BV_AiLj2.js";import{t as k}from"./switch-B9OfOEzC.js";import{t as A}from"./status-dot-Fp5SnPHI.js";import{n as j}from"./agent-accounts-CUthX0Yh.js";import{t as M}from"./centered-state-N8vWM_Hw.js";import{I as N,Mn as P,P as F,R as I}from"./index-BuR9xHfb.js";import{t as te}from"./textarea-BGp28xFr.js";import{t as L}from"./option-select-CCpypHbW.js";import{a as ne,i as R,n as z,r as B,t as V}from"./settings-agent-picker-mESK-hj4.js";import{n as H,t as U}from"./save-cue-CpHgT93o.js";import{n as W}from"./settings-field-AyinSFR_.js";import{r as G}from"./settings-save-bar-BUaa1kHw.js";import{n as K}from"./saved-draft-BwzBc-_Y.js";var q=e(t(),1),J=n(),Y={connected:P(`connected`),disconnected:P(`disconnected`),"not-installed":P(`not-installed`),unknown:P(`unknown`)};function X(e,t,n){return{providers:e.providers.map(e=>e.provider===t?{...e,enabled:n}:e)}}function re(e,t){return e?Y[e]:t?{label:`Checking…`,tone:`neutral`}:Y.unknown}function ie(e,t){return e===`unknown`||t&&!e}function ae({provider:e,state:t,current:n,statusIsError:r}){return t===`not-installed`?(0,J.jsxs)(`p`,{className:`mt-1.5 text-xs text-soft-foreground`,children:[`Install `,e.displayName,`, then run `,(0,J.jsx)(`code`,{children:e.loginCommand}),`.`]}):ie(t,r)?(0,J.jsx)(`p`,{className:`mt-1.5 text-xs text-soft-foreground`,children:`Verification failed. Check again when the provider is available.`}):n?.hint?(0,J.jsx)(`p`,{className:`mt-1.5 text-xs text-soft-foreground`,children:n.hint}):null}function oe({provider:e,state:t,current:n,isConnecting:r,incidentId:i,refresh:a,connect:o,retry:s,queueToggle:c}){let l=t===`disconnected`||t===`unknown`,u=H();return(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t===`not-installed`?null:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(U,{saved:u.saved}),(0,J.jsx)(k,{checked:n?.enabled??!0,"aria-label":`Use ${e.displayName}`,onCheckedChange:t=>c(e.id,t,u.flash)})]}),l?(0,J.jsx)(O,{type:`button`,variant:`ghost`,size:`sm`,disabled:a.isPending,onClick:()=>a.mutate(void 0,{onError:e=>w(e.message,{tone:`danger`})}),children:`Check again`}):null,t===`disconnected`&&e.browserLogin?(0,J.jsx)(z,{provider:e.id,label:e.displayName}):null,t===`disconnected`&&e.terminalLogin!==!1?(0,J.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,disabled:o.isPending,onClick:()=>o.mutate(e.id),children:r?`Opening…`:`Connect`}):null,i===void 0?null:(0,J.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,disabled:s.isPending,onClick:()=>s.mutate({provider:e.id,authFailureId:i},{onSuccess:()=>w(`${e.displayName} can be tried again.`),onError:e=>w(e.message,{tone:`danger`})}),children:`Try again`})]})}function se({manual:e,provider:t,connected:n,onCopy:r}){return e===null||e.provider!==t||n?null:(0,J.jsxs)(`div`,{role:`region`,"aria-label":`${e.label} manual sign-in`,className:`rounded-md border border-pending/40 bg-pending/5 px-3.5 py-3`,children:[(0,J.jsx)(`p`,{className:`text-[13px] text-foreground`,children:e.message}),(0,J.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(`code`,{className:`min-w-0 flex-1 overflow-x-auto rounded-sm bg-muted px-2 py-1.5 text-xs`,children:e.command}),(0,J.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void r(e.command),children:`Copy command`})]})]})}function ce(){let e=p(),t=l(),n=r(),i=u(),a=S(),[o,s]=(0,q.useState)(null),c=(0,q.useRef)(Promise.resolve()),m=(0,q.useRef)({}),h=(0,q.useRef)({}),g=(0,q.useRef)(t.data);(0,q.useEffect)(()=>{o&&C(t.data,o.provider)?.status===`connected`&&s(null)},[o,t.data]),(0,q.useEffect)(()=>{if(t.data){if(Object.values(h.current).every(e=>e===0)||!g.current){g.current=t.data;return}g.current={providers:t.data.providers.map(e=>({...e,enabled:(h.current[e.provider]??0)>0?C(g.current,e.provider)?.enabled??e.enabled:e.enabled}))}}},[t.data]);let x=(0,q.useCallback)((e,t,n)=>{let r=f.providerStatus,i=a.getQueryData(r);if(!i)return;g.current||=i;let o=X(i,e,t);h.current[e]=(h.current[e]??0)+1,a.setQueryData(r,o);let s=(m.current[e]??0)+1;m.current[e]=s,c.current=c.current.then(async()=>{try{let i=await E(e,t),o=C(i,e)?.enabled;if(o===void 0)return;if(g.current=X(g.current??i,e,o),s===m.current[e]){let t=a.getQueryData(r);a.setQueryData(r,t?X(t,e,o):i),n()}}catch(t){if(s===m.current[e]){let n=C(g.current,e)?.enabled,i=a.getQueryData(r);i&&n!==void 0?a.setQueryData(r,X(i,e,n)):g.current?a.setQueryData(r,g.current):a.removeQueries({queryKey:r,exact:!0}),w(t instanceof Error?t.message:String(t),{tone:`danger`})}}finally{h.current[e]=(h.current[e]??0)-1}})},[a]),T=d({mutationFn:e=>ee(e),onSuccess:async(e,t)=>{s(null),w(e.opened?`Finish signing in in the terminal, then check again.`:`Provider is already connected.`),await a.invalidateQueries({queryKey:f.providerStatus}),await y(a,t,`none`)},onError:(t,n)=>{if(t instanceof b&&t.command){let r=v(e.data,n);s({provider:n,label:r,message:t.message,command:t.command});return}w(t.message,{tone:`danger`})}}),D=async e=>{try{await navigator.clipboard.writeText(e),w(`Command copied`)}catch{w(`Could not copy the command`,{tone:`danger`})}};return(0,J.jsxs)(`section`,{id:`providers`,"data-slot":`provider-settings`,className:`scroll-mt-20`,children:[(0,J.jsxs)(`div`,{className:`mb-2`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Providers`}),(0,J.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Connect the coding agents available on this computer.`})]}),t.isError?(0,J.jsxs)(`div`,{role:`alert`,className:`mb-3 flex flex-wrap items-center justify-between gap-2 rounded-md border border-danger/30 bg-danger/5 px-3 py-2.5`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`p`,{className:`text-[13px] font-medium text-foreground`,children:`Provider status could not be loaded`}),(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.error.message})]}),(0,J.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,disabled:t.isFetching,onClick:()=>void t.refetch(),children:`Retry`})]}):null,(0,J.jsx)(`div`,{className:`flex flex-col gap-2`,children:_(e.data).map(e=>{let r=C(t.data,e.id),a=r?.status,s=re(a,t.isPending),c=T.isPending&&T.variables===e.id,l=r?.authFailureId;return(0,J.jsxs)(q.Fragment,{children:[(0,J.jsxs)(`div`,{"data-slot":`provider-card`,"data-provider":e.id,className:`rounded-md border border-border bg-card px-3.5 py-3`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`h3`,{className:`text-[13px] font-semibold text-foreground`,children:e.displayName}),(0,J.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,J.jsx)(A,{tone:s.tone,pulse:t.isPending}),(0,J.jsx)(`span`,{children:s.label}),r?.enabled===!1?(0,J.jsx)(`span`,{children:`Disabled`}):null]}),(0,J.jsx)(ae,{provider:e,state:a,current:r,statusIsError:t.isError})]}),(0,J.jsx)(oe,{provider:e,state:a,current:r,isConnecting:c,incidentId:l,refresh:n,connect:T,retry:i,queueToggle:x})]}),l===void 0?null:(0,J.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`Use this after completing the provider sign-in flow. Squawk cannot validate the credential without a task/model request; it will verify it on the next task.`})]}),(0,J.jsx)(se,{manual:o,provider:e.id,connected:a===`connected`,onCopy:D})]},e.id)})})]})}var Z=2e4;function le(){let e=m(),t=p(),n=s(h(t.data)),r=l();return e.isPending?(0,J.jsx)(`p`,{"data-slot":`agents-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading agent settings…`}):e.isError?(0,J.jsx)(M,{icon:(0,J.jsx)(D,{}),tone:`danger`,title:`Agent settings did not load`,subtitle:e.error.message,heading:`h2`}):(0,J.jsx)(ue,{config:e.data,catalogs:n,providerStatus:r,runners:t.data})}function ue({config:e,catalogs:t,providerStatus:n,runners:r}){let i=o(),a=S(),s=d({mutationFn:e=>x(e),onSuccess:e=>{a.setQueryData(g.config,e),a.invalidateQueries({queryKey:g.health}),a.invalidateQueries({queryKey:g.repo})},onError:e=>w(e.message,{tone:`danger`})}),[c,l]=K(e.systemPrompt??``),u=c.trim(),f=u===(e.systemPrompt??``),p=u.length>Z;G({dirty:!f,invalid:p,busy:s.isPending,save:()=>s.mutateAsync({systemPrompt:u===``?null:u}),discard:()=>l(e.systemPrompt??``)});let m=H(),h=H(),v=H(),y=H(),b=H(),C=(e,t)=>s.mutate(e,{onSuccess:t});return(0,J.jsxs)(`div`,{"data-slot":`agent-defaults-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,J.jsx)(Q,{defaultRunner:e.defaultRunner,providerStatus:n,saving:s.isPending,saved:m.saved,onSaved:m.flash,onPick:e=>C({defaultRunner:e},m.flash)}),(0,J.jsx)(W,{wide:!0,title:`Default model`,hint:e.modelsLocked?`Models are locked to the defaults configured in the native coding-agent settings.`:`The model preselected in the composer for each runner. Runner default lets the runner decide per task.`,saved:e.modelsLocked?void 0:h.saved,children:(0,J.jsx)(`div`,{"data-slot":`agents-model-rows`,className:`flex flex-col gap-2.5`,children:_(r).map(i=>{let{providerConnected:a,providerReason:o}=ne(n,i.id),c=t[i.id],l=N(i.id,r,c),u=I(i.id,r,c?.data,[e.defaultModels[i.id]]),d=e.defaultModels[i.id]??``,f=u.find(e=>e.id===d)?.label??d??`Runner default`;return(0,J.jsxs)(`label`,{className:`settings-option-row`,children:[(0,J.jsx)(`div`,{children:(0,J.jsx)(`h3`,{children:i.displayName})}),e.modelsLocked?(0,J.jsx)(`output`,{"aria-label":`Default model for ${i.pickerLabel}`,"data-slot":`agents-model`,"data-runner":i.id,title:`Model selection is locked to native coding-agent settings.`,className:`block rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs`,children:f}):(0,J.jsx)(L,{"aria-label":`Default model for ${i.pickerLabel}`,"data-slot":`agents-model`,"data-runner":i.id,value:d,title:o??i.pickerDescription,disabled:s.isPending||!a,onValueChange:e=>C({defaultModels:{[i.id]:e||null}},h.flash),className:`settings-select max-w-full bg-card`,options:[...u.map(e=>({value:e.id,label:e.label})),...l?[{value:F,label:l,disabled:!0}]:[]]})]},i.id)})})}),(0,J.jsxs)(W,{wide:!0,title:`System prompt`,hint:`Extra instructions for every run in this project.`,reportsDirty:!0,children:[(0,J.jsx)(te,{"aria-label":`System prompt`,"data-slot":`agents-system-prompt`,value:c,onChange:e=>l(e.target.value),placeholder:`Extra rules for every agent run — conventions, tone, review requirements…`,className:`min-h-48 w-full`}),(0,J.jsx)(de,{length:u.length,overLimit:p})]}),(0,J.jsxs)(`section`,{"data-slot":`agents-task-runs`,className:`settings-field flex flex-col gap-5`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Task runs`}),(0,J.jsx)($,{title:`Live title updates`,hint:`Refresh a task's short title through the namer model as the run progresses. A manual rename always wins and stops updates for that task.`,saved:v.saved,children:(0,J.jsxs)(`label`,{className:`flex w-fit items-center gap-3`,children:[(0,J.jsx)(k,{"aria-label":`Live title updates`,"data-slot":`agents-live-title-updates`,checked:e.liveTitleUpdates??!0,disabled:s.isPending,onCheckedChange:e=>C({liveTitleUpdates:e},v.flash)}),(0,J.jsxs)(`span`,{className:`text-[13px] text-muted-foreground`,children:[e.liveTitleUpdates??!0?`On`:`Off`,e.liveTitleUpdates===null&&` (default)`]})]})}),(0,J.jsx)($,{title:`Review changes before finishing`,hint:`When on, a task with changes pauses so you can Accept, Send back, or open a Draft PR. Autonomous tasks always skip this and finish on their own. Default: off — tasks finish without asking.`,saved:y.saved,children:(0,J.jsxs)(`label`,{className:`flex w-fit items-center gap-3`,children:[(0,J.jsx)(k,{"aria-label":`Review changes before finishing`,"data-slot":`agents-review-gate`,checked:e.reviewGate??!1,disabled:s.isPending,onCheckedChange:e=>C({reviewGate:e},y.flash)}),(0,J.jsxs)(`span`,{className:`text-[13px] text-muted-foreground`,children:[e.reviewGate??!1?`On`:`Off`,e.reviewGate===null&&` (default)`]})]})}),(0,J.jsx)($,{title:`Base branch`,hint:`New task worktrees branch from this and draft PRs target it. Also settable from the Git view.`,saved:b.saved,children:i.data?.info?(0,J.jsx)(L,{"aria-label":`Base branch`,"data-slot":`agents-base-branch`,value:e.baseBranch??``,disabled:s.isPending,onValueChange:e=>C({baseBranch:e||null},b.flash),className:`settings-select max-w-full bg-card`,options:[{value:``,label:`follow checked-out branch (default)`},...i.data.branches.map(e=>({value:e,label:e}))]}):(0,J.jsx)(`p`,{"data-slot":`agents-base-branch-unavailable`,className:`text-[13px] text-soft-foreground`,children:i.isPending?`Loading branches…`:`Not a git repository — tasks run in place, no branching.`})})]}),(0,J.jsxs)(`details`,{className:`settings-disclosure`,children:[(0,J.jsx)(`summary`,{children:`Provider connections`}),(0,J.jsx)(ce,{})]})]})}function Q({defaultRunner:e,providerStatus:t,saving:n,saved:r,onSaved:s,onPick:l}){let u=i(),d=c(),f=T(),m=o(),h=a(),g=f.projectId??`default`,_=m.data?.info?.root,v=j(u.data,f.projectId,_),y=p().data,b=B(u.data?.profiles??[],y),x=R(b,y);return(0,J.jsxs)(W,{title:`Default runner`,hint:`Project defaults. A task can override these choices.`,saved:r,children:[(0,J.jsx)(V,{rows:b,runner:e,accountFor:e=>v?.[e]??null,providerStatus:t,disabled:n,accountDisabled:h.isPending||d.data===void 0,onPick:(t,n,r)=>{t!==e&&l(t),r&&h.mutate({projectId:g,provider:t,profileId:n},{onSuccess:s,onError:e=>w(e.message,{tone:`danger`})})}}),!t.isPending&&!t.isError&&C(t.data,e)?.enabled===!1?(0,J.jsx)(`p`,{"data-slot":`agents-runner-disabled`,className:`text-[13px] text-muted-foreground`,children:`This provider is disabled. Enable it above or choose another provider.`}):null,x?(0,J.jsx)(`p`,{className:`max-w-md text-[13px] text-muted-foreground`,children:`The account is personal and never committed. Tasks already started under another account can’t be resumed here — their sessions live in that account’s folder.`}):null]})}function $({title:e,hint:t,saved:n,children:r}){return(0,J.jsxs)(`section`,{className:`settings-option-row`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h3`,{children:e}),(0,J.jsxs)(`p`,{children:[t,` `,(0,J.jsx)(U,{saved:n})]})]}),r]})}function de({length:e,overLimit:t}){return(0,J.jsx)(J.Fragment,{children:t?(0,J.jsxs)(`p`,{"data-slot":`agents-prompt-limit`,className:`text-xs text-danger`,children:[e.toLocaleString(),` characters — the limit is `,Z.toLocaleString(),`.`]}):(0,J.jsx)(`p`,{"data-slot":`agents-prompt-help`,className:`text-xs text-muted-foreground`,children:`Leave empty and save to clear. Applied to new runs only.`})})}export{le as AgentDefaultsSection};
@@ -1 +1 @@
1
- import{t as e}from"./react-runtime-CCIEwYL0.js";import{U as t}from"./queries-D7W-eGim.js";import{o as n}from"./dist-CCX8mhHc.js";import{t as r}from"./createLucideIcon-BHp8sXmF.js";import{n as i,t as a}from"./moon-CRE9nU5R.js";import{t as o}from"./button-BV_AiLj2.js";import{En as s,_t as c,rr as l}from"./index-D9hyWO4C.js";import{n as u}from"./save-cue-CpHgT93o.js";import{n as d}from"./settings-field-AyinSFR_.js";var f=r(`sun`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]),p=e(),m=[{value:`system`,label:`System`,icon:i},{value:`light`,label:`Light`,icon:f},{value:`dark`,label:`Dark`,icon:a}],h=[{value:`cezarion`,label:`Squawk`,swatch:`var(--accent-strong)`}],g=[{value:`comfortable`,label:`Comfortable`},{value:`compact`,label:`Compact`},{value:`ultra`,label:`Ultra-compact`}],_=[{value:`narrow`,label:`Narrow`},{value:`wide`,label:`Wide`}];function v({slot:e,label:t,value:r,options:i,onChange:a}){return(0,p.jsx)(`div`,{role:`radiogroup`,"aria-label":t,"data-slot":e,className:`inline-flex w-fit gap-0.5 rounded-lg border border-border bg-muted/60 p-1 max-md:max-w-full max-md:flex-wrap`,children:i.map(e=>{let t=e.value===r;return(0,p.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t,"data-value":e.value,onClick:()=>a(e.value),className:n(`flex min-h-11 items-center gap-2 whitespace-nowrap rounded-md border border-transparent px-3 py-1.5 text-[13px] font-medium transition-colors`,t?`border border-border bg-card text-foreground shadow-xs`:`text-muted-foreground hover:text-foreground`),children:[e.icon?(0,p.jsx)(e.icon,{"aria-hidden":`true`,className:`size-3.5`}):null,e.swatch?(0,p.jsx)(`span`,{"aria-hidden":`true`,className:`size-3 rounded-full border border-border`,style:{background:e.swatch}}):null,e.label]},e.value)})})}function y(){let e=t(),{order:n,canReorder:r,reset:i}=s();return!((e.data?.projects.length??0)>1)||n.length===0?null:(0,p.jsx)(d,{title:`Project order`,hint:`The project rail is in the order you dragged it into. Reset puts it back in the order the projects were added. Saved with your workspace, so every browser sees it.`,children:(0,p.jsx)(o,{type:`button`,variant:`outline`,size:`sm`,"data-slot":`appearance-project-order-reset`,disabled:!r,onClick:i,className:`w-fit`,children:`Reset order`})})}function b(){let{theme:e,setTheme:t}=l(),{accent:n,density:r,width:i,setAccent:a,setDensity:o,setWidth:s}=c(),f=u(),b=u(),x=u(),S=u(),C=e=>t=>{t&&e()};return(0,p.jsxs)(`div`,{"data-slot":`appearance-section`,className:`flex w-full flex-col gap-7 rounded-lg border border-border bg-card p-5`,children:[(0,p.jsx)(d,{title:`Theme`,hint:`System follows your OS preference. Applies to this browser.`,saved:f.saved,children:(0,p.jsx)(v,{slot:`appearance-theme`,label:`Theme`,value:e,options:m,onChange:e=>{t(e)&&f.flash()}})}),h.length>1?(0,p.jsx)(d,{title:`Accent`,hint:`The cockpit brand accent. Saved with your workspace appearance.`,saved:b.saved,children:(0,p.jsx)(v,{slot:`appearance-accent`,label:`Accent`,value:n,options:h,onChange:e=>void a(e).then(C(b.flash))})}):null,(0,p.jsx)(d,{title:`Density`,hint:`Compact tightens spacing across the cockpit — text stays the same size.`,saved:x.saved,children:(0,p.jsx)(v,{slot:`appearance-density`,label:`Density`,value:r,options:g,onChange:e=>void o(e).then(C(x.flash))})}),(0,p.jsx)(d,{title:`Reading width`,hint:`Wide lets a task's session and commits use more of the screen. Narrow keeps a comfortable reading column. The Changes tab is always full-width.`,saved:S.saved,children:(0,p.jsx)(v,{slot:`appearance-width`,label:`Reading width`,value:i,options:_,onChange:e=>void s(e).then(C(S.flash))})}),(0,p.jsx)(y,{}),(0,p.jsxs)(`div`,{className:`settings-appearance-preview settings-readout`,children:[(0,p.jsx)(`span`,{className:`text-[12px] text-soft-foreground`,children:`PREVIEW`}),(0,p.jsx)(`p`,{className:`mt-3 text-base`,children:`Review finalization retries`}),(0,p.jsxs)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:[`Needs you · Squawk · Task `,`#`,`227`]}),(0,p.jsx)(`span`,{className:`mt-3 inline-flex rounded-md border border-border bg-card px-4 py-3 text-xs text-foreground shadow-xs`,children:`Open task`})]}),(0,p.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:`Changes apply immediately. Theme is browser-local; density and reading width are saved with your workspace.`})]})}export{b as AppearanceSection};
1
+ import{t as e}from"./react-runtime-CCIEwYL0.js";import{U as t}from"./queries-ChH9ctc-.js";import{o as n}from"./dist-CCX8mhHc.js";import{t as r}from"./createLucideIcon-BHp8sXmF.js";import{n as i,t as a}from"./moon-CRE9nU5R.js";import{t as o}from"./button-BV_AiLj2.js";import{En as s,_t as c,rr as l}from"./index-BuR9xHfb.js";import{n as u}from"./save-cue-CpHgT93o.js";import{n as d}from"./settings-field-AyinSFR_.js";var f=r(`sun`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]),p=e(),m=[{value:`system`,label:`System`,icon:i},{value:`light`,label:`Light`,icon:f},{value:`dark`,label:`Dark`,icon:a}],h=[{value:`cezarion`,label:`Squawk`,swatch:`var(--accent-strong)`}],g=[{value:`comfortable`,label:`Comfortable`},{value:`compact`,label:`Compact`},{value:`ultra`,label:`Ultra-compact`}],_=[{value:`narrow`,label:`Narrow`},{value:`wide`,label:`Wide`}];function v({slot:e,label:t,value:r,options:i,onChange:a}){return(0,p.jsx)(`div`,{role:`radiogroup`,"aria-label":t,"data-slot":e,className:`inline-flex w-fit gap-0.5 rounded-lg border border-border bg-muted/60 p-1 max-md:max-w-full max-md:flex-wrap`,children:i.map(e=>{let t=e.value===r;return(0,p.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t,"data-value":e.value,onClick:()=>a(e.value),className:n(`flex min-h-11 items-center gap-2 whitespace-nowrap rounded-md border border-transparent px-3 py-1.5 text-[13px] font-medium transition-colors`,t?`border border-border bg-card text-foreground shadow-xs`:`text-muted-foreground hover:text-foreground`),children:[e.icon?(0,p.jsx)(e.icon,{"aria-hidden":`true`,className:`size-3.5`}):null,e.swatch?(0,p.jsx)(`span`,{"aria-hidden":`true`,className:`size-3 rounded-full border border-border`,style:{background:e.swatch}}):null,e.label]},e.value)})})}function y(){let e=t(),{order:n,canReorder:r,reset:i}=s();return!((e.data?.projects.length??0)>1)||n.length===0?null:(0,p.jsx)(d,{title:`Project order`,hint:`The project rail is in the order you dragged it into. Reset puts it back in the order the projects were added. Saved with your workspace, so every browser sees it.`,children:(0,p.jsx)(o,{type:`button`,variant:`outline`,size:`sm`,"data-slot":`appearance-project-order-reset`,disabled:!r,onClick:i,className:`w-fit`,children:`Reset order`})})}function b(){let{theme:e,setTheme:t}=l(),{accent:n,density:r,width:i,setAccent:a,setDensity:o,setWidth:s}=c(),f=u(),b=u(),x=u(),S=u(),C=e=>t=>{t&&e()};return(0,p.jsxs)(`div`,{"data-slot":`appearance-section`,className:`flex w-full flex-col gap-7 rounded-lg border border-border bg-card p-5`,children:[(0,p.jsx)(d,{title:`Theme`,hint:`System follows your OS preference. Applies to this browser.`,saved:f.saved,children:(0,p.jsx)(v,{slot:`appearance-theme`,label:`Theme`,value:e,options:m,onChange:e=>{t(e)&&f.flash()}})}),h.length>1?(0,p.jsx)(d,{title:`Accent`,hint:`The cockpit brand accent. Saved with your workspace appearance.`,saved:b.saved,children:(0,p.jsx)(v,{slot:`appearance-accent`,label:`Accent`,value:n,options:h,onChange:e=>void a(e).then(C(b.flash))})}):null,(0,p.jsx)(d,{title:`Density`,hint:`Compact tightens spacing across the cockpit — text stays the same size.`,saved:x.saved,children:(0,p.jsx)(v,{slot:`appearance-density`,label:`Density`,value:r,options:g,onChange:e=>void o(e).then(C(x.flash))})}),(0,p.jsx)(d,{title:`Reading width`,hint:`Wide lets a task's session and commits use more of the screen. Narrow keeps a comfortable reading column. The Changes tab is always full-width.`,saved:S.saved,children:(0,p.jsx)(v,{slot:`appearance-width`,label:`Reading width`,value:i,options:_,onChange:e=>void s(e).then(C(S.flash))})}),(0,p.jsx)(y,{}),(0,p.jsxs)(`div`,{className:`settings-appearance-preview settings-readout`,children:[(0,p.jsx)(`span`,{className:`text-[12px] text-soft-foreground`,children:`PREVIEW`}),(0,p.jsx)(`p`,{className:`mt-3 text-base`,children:`Review finalization retries`}),(0,p.jsxs)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:[`Needs you · Squawk · Task `,`#`,`227`]}),(0,p.jsx)(`span`,{className:`mt-3 inline-flex rounded-md border border-border bg-card px-4 py-3 text-xs text-foreground shadow-xs`,children:`Open task`})]}),(0,p.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:`Changes apply immediately. Theme is browser-local; density and reading width are saved with your workspace.`})]})}export{b as AppearanceSection};
@@ -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{_r as r,an as i,g as a,in as o,rt as s}from"./queries-D7W-eGim.js";import{I as c,Qi as l,un as u}from"./project-scope-context-Bz7AAyJ4.js";import{t as d}from"./option-select-Cqnmt-CB.js";import{n as f,t as p}from"./save-cue-CpHgT93o.js";var m=e(t(),1),h=n();function g(){let e=a();return e.isPending?(0,h.jsx)(`p`,{role:`status`,children:`Loading task settings…`}):e.isError?(0,h.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[`Task settings did not load: `,e.error.message]}):(0,h.jsx)(v,{config:e.data,scope:`project`})}function _(){let e=s();return e.isPending?(0,h.jsx)(`p`,{role:`status`,className:`text-sm`,children:`Loading task settings…`}):e.isError?(0,h.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[`Task settings did not load: `,e.error.message]}):(0,h.jsx)(v,{config:e.data,scope:`global`})}function v({config:e,scope:t}){let n=(0,m.useId)(),a=l(),s=f(),g=r({mutationFn:async({archiveOnMerge:e,projectKey:n})=>t===`project`?c({archiveOnMerge:e},n[0]):u({archiveOnMerge:e}),onSuccess:(e,{projectKey:n})=>{t===`project`?a.setQueryData(n,e):(a.setQueryData(i.config,e),a.invalidateQueries({predicate:e=>e.queryKey.at(-1)===`config`&&e.queryKey!==i.config})),s.flash()}});return(0,h.jsxs)(`section`,{"data-slot":`archive-on-merge-field`,className:`settings-field flex min-w-0 flex-col gap-3`,children:[(0,h.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,h.jsx)(`label`,{htmlFor:n,className:`text-sm font-semibold text-foreground`,children:`Archive tasks after PRs merge`}),(0,h.jsxs)(`p`,{id:`${n}-hint`,className:`text-[13px] text-muted-foreground`,children:[`Automatically archive a settled task and its workers once all their associated pull requests merge. History stays available in Archived. `,(0,h.jsx)(p,{saved:s.saved})]})]}),(0,h.jsx)(d,{id:n,"aria-describedby":`${n}-hint ${n}-effective`,className:`settings-select w-64 max-w-full bg-background`,value:e.archiveOnMerge===null?`inherit`:e.archiveOnMerge?`enabled`:`disabled`,disabled:g.isPending,onValueChange:e=>g.mutate({archiveOnMerge:e===`inherit`?null:e===`enabled`,projectKey:o.config}),options:[{value:`inherit`,label:t===`project`?`Inherit global setting`:`Use default`},{value:`enabled`,label:`Enabled`},{value:`disabled`,label:`Disabled`}]}),(0,h.jsxs)(`p`,{id:`${n}-effective`,className:`text-[13px] text-muted-foreground`,children:[`Currently `,e.effectiveArchiveOnMerge?`enabled`:`disabled`,` · `,e.archiveOnMergeSource,` setting.`]}),(0,h.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Unarchive restores the task. It stays visible until a later associated PR merges.`}),g.isPending?(0,h.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Saving…`}):null,g.isError?(0,h.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[`Could not save: `,g.error.message]}):null]})}export{_ as n,g as t};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{_r as r,an as i,g as a,in as o,rt as s}from"./queries-ChH9ctc-.js";import{I as c,Qi as l,un as u}from"./project-scope-context-hfRzPMZ4.js";import{t as d}from"./option-select-CCpypHbW.js";import{n as f,t as p}from"./save-cue-CpHgT93o.js";var m=e(t(),1),h=n();function g(){let e=a();return e.isPending?(0,h.jsx)(`p`,{role:`status`,children:`Loading task settings…`}):e.isError?(0,h.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[`Task settings did not load: `,e.error.message]}):(0,h.jsx)(v,{config:e.data,scope:`project`})}function _(){let e=s();return e.isPending?(0,h.jsx)(`p`,{role:`status`,className:`text-sm`,children:`Loading task settings…`}):e.isError?(0,h.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[`Task settings did not load: `,e.error.message]}):(0,h.jsx)(v,{config:e.data,scope:`global`})}function v({config:e,scope:t}){let n=(0,m.useId)(),a=l(),s=f(),g=r({mutationFn:async({archiveOnMerge:e,projectKey:n})=>t===`project`?c({archiveOnMerge:e},n[0]):u({archiveOnMerge:e}),onSuccess:(e,{projectKey:n})=>{t===`project`?a.setQueryData(n,e):(a.setQueryData(i.config,e),a.invalidateQueries({predicate:e=>e.queryKey.at(-1)===`config`&&e.queryKey!==i.config})),s.flash()}});return(0,h.jsxs)(`section`,{"data-slot":`archive-on-merge-field`,className:`settings-field flex min-w-0 flex-col gap-3`,children:[(0,h.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,h.jsx)(`label`,{htmlFor:n,className:`text-sm font-semibold text-foreground`,children:`Archive tasks after PRs merge`}),(0,h.jsxs)(`p`,{id:`${n}-hint`,className:`text-[13px] text-muted-foreground`,children:[`Automatically archive a settled task and its workers once all their associated pull requests merge. History stays available in Archived. `,(0,h.jsx)(p,{saved:s.saved})]})]}),(0,h.jsx)(d,{id:n,"aria-describedby":`${n}-hint ${n}-effective`,className:`settings-select w-64 max-w-full bg-background`,value:e.archiveOnMerge===null?`inherit`:e.archiveOnMerge?`enabled`:`disabled`,disabled:g.isPending,onValueChange:e=>g.mutate({archiveOnMerge:e===`inherit`?null:e===`enabled`,projectKey:o.config}),options:[{value:`inherit`,label:t===`project`?`Inherit global setting`:`Use default`},{value:`enabled`,label:`Enabled`},{value:`disabled`,label:`Disabled`}]}),(0,h.jsxs)(`p`,{id:`${n}-effective`,className:`text-[13px] text-muted-foreground`,children:[`Currently `,e.effectiveArchiveOnMerge?`enabled`:`disabled`,` · `,e.archiveOnMergeSource,` setting.`]}),(0,h.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Unarchive restores the task. It stays visible until a later associated PR merges.`}),g.isPending?(0,h.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Saving…`}):null,g.isError?(0,h.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[`Could not save: `,g.error.message]}):null]})}export{_ as n,g as t};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Dt as r,bt as i,pt as a}from"./queries-D7W-eGim.js";import{_ as o}from"./host-context-KsSKxKbI.js";import{mr as s,oi as c,xr as l}from"./project-scope-context-Bz7AAyJ4.js";import{m as u,n as d,p as f}from"./chunk-KS7C4IRE-BdLLx37K.js";import{o as p}from"./dist-CCX8mhHc.js";import{J as m,Q as h,V as g,c as _,d as v,f as y,mt as b,pt as x,st as S,u as C,y as w}from"./design-icons-QbNMZniQ.js";import{t as T}from"./createLucideIcon-BHp8sXmF.js";import{t as E}from"./check-OP-CVgZG.js";import{t as D}from"./chevron-right-BENZ-1ZN.js";import{n as ee}from"./smartphone-Lr8Ug2z_.js";import{t as O}from"./loader-circle-CPBhhDbB.js";import{t as te}from"./message-square-B-MD-8rD.js";import{n as ne,t as re}from"./tool-display-CTbToGmi.js";import{t as k}from"./square-terminal-B6RYYieR.js";import{t as A}from"./button-BV_AiLj2.js";import{n as j,r as M,t as N}from"./collapsible-D5i3hm2L.js";import{t as P}from"./project-router-CARDbdMX.js";import{a as ie,c as ae,i as oe,l as se,o as ce,s as le,t as ue}from"./report-selection-BcsbTczw.js";import{r as de}from"./html-report-BX3msvci.js";import{S as fe,pr as pe,un as me,vr as F,wn as he,wr as ge,x as _e}from"./index-D9hyWO4C.js";import{t as ve}from"./zoomable-image-Dv85Vr4A.js";import{t as I}from"./textarea-BGp28xFr.js";import{t as L}from"./markdown-BRE9fTUI.js";import{t as ye}from"./task-file-scope-DVACyrij.js";import{t as be}from"./report-title-D4Mbu2Er.js";var xe=T(`anchor`,[[`path`,{d:`M12 6v16`,key:`nqf5sj`}],[`path`,{d:`m19 13 2-1a9 9 0 0 1-18 0l2 1`,key:`y7qv08`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}],[`circle`,{cx:`12`,cy:`4`,r:`2`,key:`muu5ef`}]]),Se=T(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),Ce=T(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),we=T(`locate-fixed`,[[`line`,{x1:`2`,x2:`5`,y1:`12`,y2:`12`,key:`bvdh0s`}],[`line`,{x1:`19`,x2:`22`,y1:`12`,y2:`12`,key:`1tbv5k`}],[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`5`,key:`11lu5j`}],[`line`,{x1:`12`,x2:`12`,y1:`19`,y2:`22`,key:`x3vr5v`}],[`circle`,{cx:`12`,cy:`12`,r:`7`,key:`fim9np`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),R=T(`message-square-text`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]),Te=T(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),z=e(t(),1),B=n();function Ee(e,t){if(e.length===1)return[t.replace(RegExp(`^${De(e[0].header)}: ?`),``)];let n=t,r=[];for(let[t,i]of e.entries()){let a=`${i.header}: `;if(!n.startsWith(a))return;n=n.slice(a.length);let o=e[t+1],s=o?n.indexOf(`\n${o.header}: `):n.length;if(s<0)return;r.push(n.slice(0,s)),n=n.slice(s+1)}return r}function De(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Oe(e,t){if(t===void 0)return[];let n=e.options??[];if(!e.multiSelect)return n.filter(e=>e.label===t).map(e=>e.label);let r=[];function i(e,t){for(let{label:a}of n)t.includes(a)||(e===a?r.push([...t,a]):e.startsWith(`${a}, `)&&i(e.slice(a.length+2),[...t,a]))}return i(t,[]),r.length===1?r[0]:[]}var ke=`
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Dt as r,bt as i,pt as a}from"./queries-ChH9ctc-.js";import{_ as o}from"./host-context-KsSKxKbI.js";import{mr as s,oi as c,xr as l}from"./project-scope-context-hfRzPMZ4.js";import{m as u,n as d,p as f}from"./chunk-KS7C4IRE-BdLLx37K.js";import{o as p}from"./dist-CCX8mhHc.js";import{J as m,Q as h,V as g,c as _,d as v,f as y,mt as b,pt as x,st as S,u as C,y as w}from"./design-icons-QbNMZniQ.js";import{t as T}from"./createLucideIcon-BHp8sXmF.js";import{t as E}from"./check-OP-CVgZG.js";import{t as D}from"./chevron-right-BENZ-1ZN.js";import{n as ee}from"./smartphone-Lr8Ug2z_.js";import{t as O}from"./loader-circle-CPBhhDbB.js";import{t as te}from"./message-square-B-MD-8rD.js";import{n as ne,t as re}from"./tool-display-CTbToGmi.js";import{t as k}from"./square-terminal-B6RYYieR.js";import{t as A}from"./button-BV_AiLj2.js";import{n as j,r as M,t as N}from"./collapsible-D5i3hm2L.js";import{t as P}from"./project-router-yoWCTDaT.js";import{a as ie,c as ae,i as oe,l as se,o as ce,s as le,t as ue}from"./report-selection-CwPw7vbG.js";import{r as de}from"./html-report-BX3msvci.js";import{S as fe,pr as pe,un as me,vr as F,wn as he,wr as ge,x as _e}from"./index-BuR9xHfb.js";import{t as ve}from"./zoomable-image-Dv85Vr4A.js";import{t as I}from"./textarea-BGp28xFr.js";import{t as L}from"./markdown-A6dvDky9.js";import{t as ye}from"./task-file-scope-BhWG35a8.js";import{t as be}from"./report-title-D4Mbu2Er.js";var xe=T(`anchor`,[[`path`,{d:`M12 6v16`,key:`nqf5sj`}],[`path`,{d:`m19 13 2-1a9 9 0 0 1-18 0l2 1`,key:`y7qv08`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}],[`circle`,{cx:`12`,cy:`4`,r:`2`,key:`muu5ef`}]]),Se=T(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),Ce=T(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),we=T(`locate-fixed`,[[`line`,{x1:`2`,x2:`5`,y1:`12`,y2:`12`,key:`bvdh0s`}],[`line`,{x1:`19`,x2:`22`,y1:`12`,y2:`12`,key:`1tbv5k`}],[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`5`,key:`11lu5j`}],[`line`,{x1:`12`,x2:`12`,y1:`19`,y2:`22`,key:`x3vr5v`}],[`circle`,{cx:`12`,cy:`12`,r:`7`,key:`fim9np`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),R=T(`message-square-text`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]),Te=T(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),z=e(t(),1),B=n();function Ee(e,t){if(e.length===1)return[t.replace(RegExp(`^${De(e[0].header)}: ?`),``)];let n=t,r=[];for(let[t,i]of e.entries()){let a=`${i.header}: `;if(!n.startsWith(a))return;n=n.slice(a.length);let o=e[t+1],s=o?n.indexOf(`\n${o.header}: `):n.length;if(s<0)return;r.push(n.slice(0,s)),n=n.slice(s+1)}return r}function De(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Oe(e,t){if(t===void 0)return[];let n=e.options??[];if(!e.multiSelect)return n.filter(e=>e.label===t).map(e=>e.label);let r=[];function i(e,t){for(let{label:a}of n)t.includes(a)||(e===a?r.push([...t,a]):e.startsWith(`${a}, `)&&i(e.slice(a.length+2),[...t,a]))}return i(t,[]),r.length===1?r[0]:[]}var ke=`
2
2
 
3
3
  Additional comments:
4
4
  `;function Ae(e){let t=e.indexOf(ke);if(t<0)return{body:e,comment:void 0};let n=e.slice(t+23).trim();return{body:e.slice(0,t),comment:n||void 0}}function je({ask:e}){let t=e.answer===void 0?void 0:Ae(e.answer),n=t===void 0?void 0:Ee(e.questions,t.body);return(0,B.jsxs)(`div`,{"data-slot":`ask-answers`,className:`flex flex-col gap-4 text-sm`,children:[e.questions.map((t,r)=>{let i=n?.[r],a=Oe(t,i),o=i!==void 0&&a.length===0;return(0,B.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-label":t.question,children:[(0,B.jsxs)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:[t.header,` · Question `,r+1,` of `,e.questions.length]}),(0,B.jsx)(`p`,{className:`break-words font-semibold`,children:t.question}),t.options?(0,B.jsxs)(`ul`,{className:`flex list-none flex-col gap-1.5`,children:[t.options.map(e=>(0,B.jsxs)(`li`,{"data-selected":a.includes(e.label),className:`flex items-start gap-2 rounded-md border border-border px-3 py-2 data-[selected=true]:border-message-user-border data-[selected=true]:bg-message-user-accent/5`,children:[(0,B.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0 text-message-user-accent`,children:a.includes(e.label)?`✓`:`○`}),(0,B.jsxs)(`span`,{className:`min-w-0 flex-1 break-words`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:e.label}),e.description?(0,B.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:e.description}):null]}),a.includes(e.label)?(0,B.jsx)(`span`,{className:`shrink-0 text-xs text-message-user-accent`,children:`Selected`}):null]},e.label)),(0,B.jsxs)(`li`,{"data-selected":o,className:`rounded-md border border-border px-3 py-2 data-[selected=true]:border-message-user-border`,children:[(0,B.jsxs)(`p`,{className:`flex items-start gap-2 font-medium`,children:[(0,B.jsx)(`span`,{"aria-hidden":!0,className:`text-message-user-accent`,children:o?`✓`:`○`}),(0,B.jsx)(`span`,{className:`flex-1`,children:`Other`}),o?(0,B.jsx)(`span`,{className:`text-xs text-message-user-accent`,children:`Selected`}):null]}),o?(0,B.jsx)(V,{text:i}):null]})]}):i===void 0?null:(0,B.jsx)(V,{text:i})]},t.id??r)}),n&&t?.comment?(0,B.jsxs)(`section`,{className:`flex flex-col gap-1`,"aria-label":`Additional comments`,children:[(0,B.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:`Additional comments`}),(0,B.jsx)(V,{text:t.comment})]}):null,!n&&e.answer!==void 0?(0,B.jsx)(V,{text:e.answer}):null]})}function V({text:e}){return(0,B.jsx)(`blockquote`,{className:`[margin-block-start:0.5rem] border-s-2 border-message-user-accent ps-3 break-words whitespace-pre-wrap`,children:e})}function H(e,t,n){let r=n[e];return r===void 0?(t[e]?.length??0)>0:r.trim().length>0}function Me(e,t,n){let r=n[e]?.trim();if(r)return r;let i=t[e]??[];return i.length>0?i.join(`, `):`Not answered yet`}function Ne({stepped:e,mode:t,onModeChange:n,showModeSwitch:r,stepLabel:i,hasSheetContext:a,showContextButtonRef:o,onOpenContext:s,onShowOrigin:c,onFold:l}){let u=l!==void 0,d=a?(0,B.jsxs)(A,{ref:o,type:`button`,variant:`ghost`,size:`sm`,"data-slot":`ask-show-context`,"aria-label":u?`Show context`:void 0,className:p(`px-2 text-xs font-medium text-link-foreground underline underline-offset-4`,u&&`ms-auto`),onClick:s,children:[(0,B.jsx)(F,{"aria-hidden":`true`,className:`size-3.5`}),u?`Context`:`Show context`]}):c&&u?(0,B.jsx)(A,{type:`button`,variant:`ghost`,size:`icon-sm`,"data-slot":`ask-show-origin`,"aria-label":`Show where it was asked`,title:`Show where it was asked`,className:`ms-auto shrink-0 text-link-foreground`,onClick:c,children:(0,B.jsx)(we,{"aria-hidden":`true`,className:`size-4`})}):c?(0,B.jsx)(He,{onShowOrigin:c}):null,f=r?(0,B.jsx)(Pe,{mode:t,onModeChange:n}):null;return u?(0,B.jsxs)(`div`,{"data-slot":`ask-header`,"data-compact":`true`,className:`flex shrink-0 items-center gap-1.5 border-b border-border/70 py-1 ps-1.5 pe-1`,children:[(0,B.jsx)(`span`,{className:`sr-only`,children:`Needs your answer`}),e&&t===`options`?(0,B.jsx)(`span`,{"data-slot":`ask-step-indicator`,className:`sr-only`,children:i}):null,f,d,(0,B.jsx)(A,{type:`button`,variant:`ghost`,size:`icon-sm`,"data-slot":`ask-fold`,"aria-label":`Fold the question`,"aria-expanded":`true`,className:p(`shrink-0 text-muted-foreground`,!d&&`ms-auto`),onClick:l,children:(0,B.jsx)(C,{"aria-hidden":`true`,className:`size-4`})})]}):(0,B.jsxs)(`div`,{"data-slot":`ask-header`,className:`flex shrink-0 flex-wrap items-center gap-x-2 gap-y-1 border-b border-border/70 px-2.5 py-1.5 md:px-3 md:py-2`,children:[(0,B.jsx)(`span`,{className:`text-xs font-semibold text-link-foreground`,children:`Needs your answer`}),e&&t===`options`?(0,B.jsx)(`span`,{"data-slot":`ask-step-indicator`,className:`rounded-full bg-accent-strong/15 px-2 py-0.5 text-xs font-semibold text-foreground tabular-nums`,children:i}):null,(0,B.jsxs)(`div`,{className:`ms-auto flex flex-wrap items-center gap-1.5`,children:[d,f]})]})}function Pe({mode:e,onModeChange:t}){return(0,B.jsxs)(`div`,{"data-slot":`ask-mode-switch`,role:`group`,"aria-label":`Reply mode`,className:`inline-flex shrink-0 items-center rounded-lg border border-border bg-card p-0.5`,children:[(0,B.jsx)(`button`,{type:`button`,"data-slot":`ask-mode-options`,"aria-pressed":e===`options`,onClick:()=>t(`options`),className:p(`min-h-11 rounded-md px-2.5 text-xs font-medium transition-colors focus-visible:outline-2 focus-visible:outline-ring md:min-h-7`,e===`options`?`bg-accent-strong text-accent-strong-foreground`:`text-foreground hover:bg-muted/60`),children:`Options`}),(0,B.jsx)(`button`,{type:`button`,"data-slot":`ask-mode-reply`,"aria-pressed":e===`reply`,onClick:()=>t(`reply`),className:p(`min-h-11 rounded-md px-2.5 text-xs font-medium transition-colors focus-visible:outline-2 focus-visible:outline-ring md:min-h-7`,e===`reply`?`bg-accent-strong text-accent-strong-foreground`:`text-foreground hover:bg-muted/60`),children:`Write a reply`})]})}function Fe({tag:e,text:t,position:n,onOpen:r}){return(0,B.jsxs)(`button`,{type:`button`,"data-slot":`ask-folded-row`,"aria-expanded":`false`,onClick:r,className:`flex min-h-11 w-full min-w-0 items-center gap-2 rounded-xl px-2.5 py-1.5 text-start focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,B.jsx)(`span`,{className:`shrink-0 rounded-md bg-accent-strong px-1.5 py-0.5 text-xs font-semibold uppercase tracking-wide text-accent-strong-foreground`,children:e}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-foreground`,children:t}),n===void 0?null:(0,B.jsx)(`span`,{"data-slot":`ask-folded-position`,className:`shrink-0 text-xs text-muted-foreground tabular-nums`,children:n}),(0,B.jsx)(`span`,{className:`sr-only`,children:`Open the question`}),(0,B.jsx)(y,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`})]})}function Ie({questions:e,stepIndex:t,selections:n,otherAnswers:r,hasComment:i,onSelectStep:a}){let o=e.length;return(0,B.jsxs)(`div`,{"data-slot":`ask-step-pills`,role:`group`,"aria-label":`Question steps`,className:`hidden shrink-0 flex-wrap items-center gap-1.5 border-b border-border/60 px-3 py-1.5 md:flex`,children:[e.map((e,i)=>{let o=t===i,s=H(i,n,r);return(0,B.jsxs)(`button`,{type:`button`,"aria-current":o?`step`:void 0,onClick:()=>a(i),className:p(`inline-flex min-h-8 items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs font-medium transition-colors focus-visible:outline-2 focus-visible:outline-ring`,o?`border-accent-strong bg-accent-strong/15 text-foreground`:s?`border-border bg-card text-foreground hover:border-accent-strong/50`:`border-border bg-transparent text-muted-foreground hover:text-foreground`),children:[(0,B.jsx)(`span`,{className:`tabular-nums text-xs font-semibold`,children:s?(0,B.jsx)(E,{"aria-hidden":`true`,className:`size-3 text-semantic-green`}):`${i+1}.`}),(0,B.jsx)(`span`,{className:`max-w-[140px] truncate`,children:e.header})]},e.id??i)}),(0,B.jsxs)(`button`,{type:`button`,"aria-current":t===o?`step`:void 0,onClick:()=>a(o),className:p(`inline-flex min-h-8 items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs font-medium transition-colors focus-visible:outline-2 focus-visible:outline-ring`,t===o?`border-accent-strong bg-accent-strong/15 text-foreground`:i?`border-border bg-card text-foreground hover:border-accent-strong/50`:`border-dashed border-border bg-transparent text-muted-foreground hover:text-foreground`),children:[(0,B.jsx)(R,{"aria-hidden":`true`,className:`size-3`}),(0,B.jsx)(`span`,{children:`Comment`})]})]})}function Le({questions:e,selections:t,otherAnswers:n,comment:r,disabled:i,onCommentChange:a,onJumpToQuestion:o}){let s=(0,z.useId)();return(0,B.jsxs)(`div`,{"data-slot":`ask-comment-step`,className:`flex flex-col gap-2.5`,children:[(0,B.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-2.5`,children:[(0,B.jsx)(`p`,{className:`mb-1.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:`Selected answers`}),(0,B.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.map((e,r)=>{let i=H(r,t,n);return(0,B.jsxs)(`li`,{className:`flex items-baseline justify-between gap-2 text-xs`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:()=>o(r),className:`min-h-11 text-start font-medium text-link-foreground underline-offset-4 hover:underline md:min-h-6`,children:e.header}),(0,B.jsx)(`span`,{className:p(`min-w-0 truncate text-end`,i?`text-foreground`:`text-semantic-red`),children:Me(r,t,n)})]},e.id??r)})})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`label`,{htmlFor:s,className:`mb-1 block text-xs font-medium text-foreground`,children:`Additional comments (optional)`}),(0,B.jsx)(I,{id:s,"data-slot":`ask-additional-comment`,rows:2,value:r,disabled:i,placeholder:`Optional extra notes to send with your selections…`,onChange:e=>a(e.target.value),className:`bg-card text-base md:text-[13px]`})]})]})}function Re({value:e,onValueChange:t,disabled:n,renderFreeTextReply:r}){let i=(0,z.useId)();return r?(0,B.jsx)(`div`,{"data-slot":`ask-free-text`,children:r({value:e,onValueChange:t,disabled:n})}):(0,B.jsxs)(`div`,{"data-slot":`ask-free-text`,className:`flex flex-col gap-2`,children:[(0,B.jsx)(`label`,{htmlFor:i,className:`text-xs font-medium text-foreground`,children:`Reply to the agent`}),(0,B.jsx)(I,{id:i,rows:2,value:e,disabled:n,placeholder:`Write a free-text reply…`,onChange:e=>t(e.target.value),className:`bg-card text-base md:text-[13px]`})]})}function ze({stepIndex:e,questionCount:t,answeredCount:n,allAnswered:r,hasComment:i,resuming:a,disabled:o,onBack:s,onNext:c,onOpenComment:l,onSend:u,questions:d,selections:f,otherAnswers:m,stopControl:h,compact:g=!1}){let _=e===t-1,v=e===t,y=a?`Send answer & reopen`:`Send answer`,b=a?(0,B.jsx)(`span`,{"data-slot":`ask-resume-hint`,className:`text-xs text-soft-foreground`,children:`Reopens the closed session.`}):null,x=!_&&!v?(0,B.jsxs)(A,{type:`button`,variant:`outline`,size:`sm`,className:`px-3`,onClick:c,children:[`Next`,(0,B.jsx)(D,{"aria-hidden":`true`,className:`size-4`})]}):null,S=_?(0,B.jsx)(A,{type:`button`,variant:`outline`,size:`sm`,className:`px-3`,onClick:l,children:i?`Edit comment`:`+ Comment`}):null,C=_||v||r?(0,B.jsx)(A,{type:`button`,size:`sm`,className:`px-3.5`,disabled:o||!r,onClick:u,children:y}):null;return(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e>0?(0,B.jsxs)(A,{type:`button`,variant:`outline`,size:`sm`,className:`px-3`,onClick:s,children:[(0,B.jsx)(ge,{"aria-hidden":`true`,className:`size-4`}),`Back`]}):null,(0,B.jsxs)(`span`,{"data-slot":`ask-progress-dots`,"aria-hidden":`true`,className:`flex items-center gap-1.5 px-1 md:hidden`,children:[d.map((t,n)=>{let r=n===e,i=H(n,f,m);return(0,B.jsx)(`span`,{className:p(`size-2 rounded-full motion-safe:transition-colors`,r?`bg-accent-strong`:i?`bg-success`:`bg-border`)},t.id??n)}),(0,B.jsx)(`span`,{className:p(`size-2 rounded-full motion-safe:transition-colors`,v?`bg-accent-strong`:i?`bg-success`:`bg-border/60`)})]}),(0,B.jsxs)(`span`,{"data-slot":`ask-progress-summary`,className:`hidden text-xs text-soft-foreground tabular-nums sm:inline`,children:[n,` of `,t,` answered`]}),g?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{"data-slot":`ask-step-actions`,className:`ms-auto flex items-center gap-2`,children:[x,C]}),S||h?(0,B.jsxs)(`div`,{"data-slot":`ask-secondary-actions`,className:`ms-auto flex items-center gap-2`,children:[S,h]}):null,b]}):(0,B.jsxs)(B.Fragment,{children:[b,(0,B.jsxs)(`div`,{className:`ms-auto flex flex-wrap items-center gap-2`,children:[h,x,S,C]})]})]})}function Be({oneTap:e,hasOtherAnswer:t,allowComment:n,commentOpen:r,hasComment:i,resuming:a,disabled:o,onToggleComment:s,onSend:c,stopControl:l,compact:u=!1}){return(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[n?(0,B.jsxs)(A,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`ask-add-comment`,className:`px-2 text-xs text-muted-foreground hover:text-foreground`,onClick:s,children:[(0,B.jsx)(R,{"aria-hidden":`true`,className:`size-3.5`}),r?`Hide comment`:i?`Edit comment`:`+ Add comment`]}):null,u&&!a?null:(0,B.jsx)(`span`,{"data-slot":a?`ask-resume-hint`:`ask-hint`,className:`text-xs text-soft-foreground`,children:a?`Reopens the closed session.`:e?`Tap an option to send.`:`Choose an answer, then send.`}),(0,B.jsxs)(`div`,{className:`ms-auto flex items-center gap-2`,children:[l,!e||t||r||i?(0,B.jsx)(A,{type:`button`,size:`sm`,className:`px-3.5`,disabled:o,onClick:c,children:a?`Send answer & reopen`:`Send answer`}):null]})]})}function Ve({blockedBy:e,reason:t,error:n}){return(0,B.jsxs)(B.Fragment,{children:[t?(0,B.jsxs)(`p`,{"data-slot":`ask-blocked-reason`,className:`text-xs text-muted-foreground`,children:[t,` `,e===`provider`?(0,B.jsx)(P,{to:`/settings/agent-defaults#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`}):null]}):null,n?(0,B.jsx)(`p`,{role:`alert`,className:`text-xs text-semantic-red`,children:n}):null]})}function He({onShowOrigin:e,className:t}){return(0,B.jsx)(A,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`ask-show-origin`,onClick:e,className:p(`px-2 text-xs font-medium text-link-foreground underline underline-offset-4`,t),children:`Show where it was asked`})}function Ue({open:e,onOpenChange:t,runId:n,context:r,onShowOrigin:i,returnFocusRef:a}){let o=(0,z.useRef)(!1);return(0,B.jsx)(oe,{open:e,onOpenChange:t,children:(0,B.jsxs)(ce,{side:`right`,showCloseButton:!1,"data-slot":`ask-context-sheet`,className:`flex w-full max-w-[540px] flex-col gap-0 p-0 sm:max-w-[540px]`,onCloseAutoFocus:e=>{if(e.preventDefault(),o.current){o.current=!1,i?.();return}a?.current?.focus()},children:[(0,B.jsxs)(ae,{className:`relative shrink-0 border-b border-border px-5 py-4 pr-14`,children:[(0,B.jsx)(se,{children:`Question context`}),(0,B.jsx)(le,{children:`Your selections and drafts stay intact while you read.`}),(0,B.jsx)(ie,{asChild:!0,children:(0,B.jsx)(A,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Close`,className:`absolute inset-bs-2 end-2`,children:(0,B.jsx)(b,{"aria-hidden":`true`,className:`size-4`})})})]}),(0,B.jsx)(`div`,{"data-slot":`ask-context`,role:`region`,"aria-label":`Context`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain break-words px-5 py-4 text-sm text-foreground`,children:(0,B.jsx)(ye,{runId:n,children:(0,B.jsx)(L,{breaks:!0,children:r})})}),i?(0,B.jsx)(`div`,{className:`flex shrink-0 items-center justify-end border-t border-border px-5 py-3`,children:(0,B.jsx)(A,{type:`button`,variant:`outline`,size:`sm`,"data-slot":`ask-show-origin`,onClick:()=>{o.current=!0,t(!1),i()},children:`Show where it was asked`})}):null]})})}function We(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Ge=/^[A-Za-z0-9_./:=+,@%-]+$/;function Ke(e){return e.replaceAll(`'`,`'\\''`)}function qe(e){return e===``?`''`:Ge.test(e)?e:`\u0027${Ke(e)}\u0027`}function Je(e){if(!We(e))return;let t=e.command;if(typeof t==`string`&&t!==``)return t;if(Array.isArray(t)){let e=t.filter(e=>typeof e==`string`);if(e.length>0)return e.map(qe).join(` `)}}function Ye(e){let t="`".repeat(3),n=`~`.repeat(3);return e.split(t).filter((e,t)=>t%2==0).join(` `).split(n).filter((e,t)=>t%2==0).join(` `).split("`").filter((e,t)=>t%2==0).join(` `)}function Xe(e){return e.replace(/!\[(?:\\.|[^\]\\])*\]\([^)\s]*(?:\s+"[^"]*")?\)/g,` `)}function Ze(e){return e.replace(/(?<!\\)(?:\*\*|\*|__|~~|`)/g,``).replace(/\\([!"#$%&'()*+,\-./:;<=>?@[\]\\^_`{|}~])/g,`$1`)}function U(e){let t=e.trim();return t===``||t.startsWith(`#`)||/^(https?:|mailto:)/i.test(t)?!0:!/^[a-z][a-z0-9+.-]*:/i.test(t)}function Qe(e){let t=Ye(Xe(e)),n=new Map;for(let e of t.matchAll(/^\s*\[([^\]]+)\]:\s*(\S+)/gm))U(e[2])&&n.set(e[1].toLowerCase(),e[2]);let r=t.replace(/^\s*\[[^\]]+\]:\s*\S+.*$/gm,` `),i=[];for(let e of r.matchAll(/(?<!!)\[((?:\\.|[^\]\\])+)\](?:\(((?:[^()\s]|\([^)]*\))+)(?:\s+"[^"]*")?\)|\[([^\]]*)\])|<(https?:\/\/[^>\s]+)>|(https?:\/\/[^\s<]+)/g)){if(e[2]){U(e[2])&&i.push({label:Ze(e[1]),href:e[2]});continue}if(e[1]!==void 0&&e[3]!==void 0){let t=(e[3].length>0?e[3]:e[1]).toLowerCase(),r=n.get(t);r&&i.push({label:Ze(e[1]),href:r});continue}let t=(e[4]??e[5])?.replace(/[.,;:!?]+$/,``);t&&U(t)&&i.push({label:t,href:t})}return i}var $e=(0,z.createContext)(void 0),et=(0,z.createContext)(void 0);function tt(e,t){let n=new Map;for(let r of Qe(e)){let e=fe(r.href,t);if(!e)continue;let i=new URL(e,`https://cockpit.invalid`),a=/^\/p\/([^/]+)\/tasks\/([^/]+)\/report$/.exec(i.pathname),o=/^\/tasks\/([^/]+)\/report$/.exec(i.pathname),s=i.searchParams.get(`artifact`);if(!s||(a?decodeURIComponent(a[1])!==t.projectId:!o))continue;let c=decodeURIComponent(a?a[2]:o[1]),l=`${c}:${s}`;n.has(l)||n.set(l,{runId:c,artifactId:s,label:r.label,href:e})}return[...n.values()]}function W(e,t){return`report-card-${encodeURIComponent(e)}-${t}`}function nt({text:e,messageKey:t}){let n=(0,z.useContext)(_e),r=(0,z.useContext)(et),i=t??r;if(!n||i===void 0)return null;let a=tt(e,n);return a.length===0?null:(0,B.jsx)(`div`,{"data-slot":`report-cards`,className:`flex flex-col gap-3 [margin-block-start:1rem]`,children:a.map(e=>(0,B.jsx)(rt,{reference:e,messageKey:i},`${e.runId}:${e.artifactId}`))})}function rt({reference:e,messageKey:t}){let{artifactId:n,runId:i,label:a,href:o}=e,s=(0,z.useContext)($e),c=(0,z.useContext)(ue);(0,z.useLayoutEffect)(()=>c?.register(n,i),[c,n,i]);let l=r(i,n),p=f(),m=u();if(l.isError)return(0,B.jsx)(d,{id:W(t,n),"data-slot":`report-card-fallback`,to:o,state:{readerFrom:p.pathname+p.search},children:a});let h=l.data?.artifact;if(h&&!de(h.name))return null;let g=new URLSearchParams(p.search);g.set(`report`,n),g.set(`card`,t);let _=new URLSearchParams(p.search).has(`report`)?p.state:null,v=new URLSearchParams(p.search);v.delete(`report`),v.delete(`card`);let y=`${p.pathname}${v.size?`?${v}`:``}`,b=window.navigation,x={reportCardEntry:!0,reportReturnTo:_?.reportReturnTo??y,reportReturnKey:_?.reportReturnKey??b?.currentEntry?.key,reportScrollTop:_?.reportScrollTop},S={pathname:p.pathname,search:`?${g}`,hash:new URL(o,`https://cockpit.invalid`).hash};return(0,B.jsxs)(`section`,{"data-slot":`report-card`,"data-artifact-id":n,"data-report-run-id":i,"aria-busy":l.isPending,className:`flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-card p-3 text-foreground`,children:[(0,B.jsx)(`h3`,{className:`break-words text-sm font-medium`,children:h?be(h):a}),(0,B.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:`HTML report`}),(0,B.jsx)(d,{id:W(t,n),to:S,state:x,onClick:e=>{if(e.button!==0||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault(),s?.(t);let n=x.reportScrollTop??(document.querySelector(`[data-slot="thread-transcript"]`)??document.querySelector(`[data-slot="main"]`))?.scrollTop;m(S,{state:{...x,reportScrollTop:n}})},className:`inline-flex min-h-11 min-w-11 items-center self-start rounded-md border border-border px-3 text-sm active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring ${l.isPending?`text-soft-foreground`:`text-accent-text`}`,children:`Read report`})]})}var it={message:!0,reasoning:!0,tool:!0,hook:!0};function at(e){return Object.hasOwn(it,e)&&it[e]}var G=e=>e.kind===`tool`,ot=e=>e.kind===`conversation`,st=e=>(e.toolKind===`read`||e.toolKind===`search`)&&e.status===`completed`,ct=(e,t,n)=>`${e} ${e===1?t:n}`;function lt(e,t){let n=[];return e>0&&n.push(ct(e,`file`,`files`)),t>0&&n.push(ct(t,`search`,`searches`)),`Explored ${n.join(` · `)}`}function ut(e){return`${e} earlier tool call${e===1?``:`s`}`}var dt=[`Web search`,`Ran`,`Edit`,`Write`,`Read`,`Search`,`Fetch`,`Task:`];function ft(e){for(let t of dt)if(e.startsWith(`${t} `)&&e.length>t.length+1)return{verb:t===`Task:`?`Task`:t,detail:e.slice(t.length+1)};return{verb:e}}var pt=new WeakMap;function mt(e){let t=pt.get(e);if(t)return t;let n=ht(e);return pt.set(e,n),n}function ht(e){let t=e.filter(e=>!(e.kind===`tool`&&e.toolKind===`plan`)&&!((e.kind===`reasoning`||e.kind===`message`)&&e.text.trim()===``)),n=new Set(t.filter(G).map(e=>e.id)),r=new Map,i=[];for(let e of t){let t=at(e.kind)&&`parentItemId`in e&&e.parentItemId!==void 0&&e.parentItemId!==e.id&&n.has(e.parentItemId)?e.parentItemId:void 0;if(t===void 0)i.push(e);else{let n=r.get(t);n?n.push(e):r.set(t,[e])}}let a=[],o=[],s=()=>{if(o.length>=2){let e=o.filter(e=>e.toolKind===`read`).length;a.push({kind:`context-group`,id:`group:${o[0].id}`,tools:o,files:e,searches:o.length-e,label:lt(e,o.length-e)})}else for(let e of o)a.push({kind:`tool-card`,id:e.id,item:e,children:r.get(e.id)??[]});o=[]},c=[],l=()=>{if(c.length!==0){for(let e of gt(c).batches)a.push({kind:`worker-conversation`,id:`worker:${e.messages[0].id}`,batches:[e]});c=[]}};for(let e of i){if(ot(e)){s(),c.push(e);continue}l(),G(e)&&st(e)&&!r.has(e.id)?o.push(e):(s(),G(e)?a.push({kind:`tool-card`,id:e.id,item:e,children:r.get(e.id)??[]}):a.push({kind:`entry`,id:e.id,entry:e}))}s(),l();let u=e=>e.kind===`context-group`||e.kind===`tool-card`&&e.item.status===`completed`,d=e=>e.kind===`context-group`?e.tools.length:1,f=[],p=[],m=()=>{if(p.length>3){let e=p.slice(0,p.length-3);f.push({kind:`streak`,id:`streak:${e[0].id}`,count:e.reduce((e,t)=>e+d(t),0),blocks:e}),f.push(...p.slice(p.length-3))}else f.push(...p);p=[]};for(let e of a)u(e)?p.push(e):(m(),f.push(e));return m(),f}function gt(e){let t=[];for(let n of e){let e=t.at(-1);n.messageKind===`request`&&e?.kind===`request`&&e.senderRunId===n.senderRunId&&e.text===n.text&&e.messages[0].relationship===`peer`==(n.relationship===`peer`)&&!e.messages.some(e=>e.recipientRunId===n.recipientRunId)?e.messages.push(n):t.push({id:`worker-batch:${n.messageId}`,kind:n.messageKind,text:n.text,senderRunId:n.senderRunId,messages:[n]})}return{kind:`worker-conversation`,id:`worker:${e[0].id}`,batches:t}}var K=new Map,_t=(0,z.createContext)(null);function q(){return(0,z.useContext)(_t)}function vt({runId:e,children:t}){let n=(0,z.useMemo)(()=>({get:t=>K.get(e)?.get(t),set:(t,n)=>{let r=K.get(e)??new Map;r.set(t,n),K.set(e,r)}}),[e]);return(0,B.jsx)(_t.Provider,{value:n,children:t})}function yt(e){return e.scrollTop<Math.max(600,e.clientHeight)}function bt(e,t){let n=t.find(({bottom:t})=>t>e);return n===void 0?void 0:{key:n.key,offset:n.top-e}}function xt(e,t,n,r,i){if(n===void 0)return i;let a=r.find(({key:e})=>e===n.key);return a===void 0?i:e+(a.top-t-n.offset)}function St(e,t=24){return e.scrollHeight-e.scrollTop-e.clientHeight<t}function Ct(e,t){let n=new URLSearchParams(e).get(`thread`);return n===`flat`||n===`virtual`?n:t>300?`virtual`:`flat`}var wt=new Map;function Tt(e,t){wt.set(e,t)}function Et(e){return wt.get(e)}var J=new Map;function Dt(e,t){J.set(e,{...t,...t.rowKeys?{rowKeys:[...t.rowKeys]}:{}})}function Ot(e){return J.get(e)}function kt(e,t,n){let r=J.get(e);if(!r||r.rows!==t)return;let i=r.rowKeys;if(!(n&&i&&(n.length!==t||i.length!==t||!n.every((e,t)=>e===i[t]))))return r.cache}var At=new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}),jt=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`medium`}),Mt=new Intl.DateTimeFormat(void 0,{weekday:`short`,month:`short`,day:`numeric`}),Nt=new Intl.DateTimeFormat(void 0,{weekday:`short`,year:`numeric`,month:`short`,day:`numeric`}),Pt=new Intl.DateTimeFormat(void 0,{dateStyle:`full`});function Y(e){if(typeof e!=`string`||e===``)return;let t=new Date(e);return Number.isFinite(t.getTime())?t:void 0}function X(e){let t=Y(e);return t===void 0?void 0:At.format(t)}function Ft(e){let t=Y(e);return t===void 0?void 0:jt.format(t)}var Z=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`;function It(e){let t=Y(e);return t===void 0?void 0:Z(t)}function Lt(e,t=new Date){let n=Y(e);if(n===void 0)return;let r=Z(n);return r===Z(t)?`Today`:r===Z(new Date(t.getFullYear(),t.getMonth(),t.getDate()-1))?`Yesterday`:(n.getFullYear()===t.getFullYear()?Mt:Nt).format(n)}function Rt(e,t){let n=Y(e),r=Y(t);if(n===void 0||r===void 0)return;let i=Math.round((r.getTime()-n.getTime())/1e3);if(i<0)return;if(i<60)return`${i}s`;let a=Math.floor(i/60);return a<60?`${a}m ${String(i%60).padStart(2,`0`)}s`:`${Math.floor(a/60)}h ${String(a%60).padStart(2,`0`)}m`}function zt({ts:e}){let t=X(e);return t===void 0?null:(0,B.jsx)(`time`,{"data-slot":`message-time`,dateTime:e,title:Ft(e),className:`text-xs leading-none text-soft-foreground`,children:t})}function Bt({startedAt:e,completedAt:t}){let n=X(t);if(n===void 0)return null;let r=Rt(e,t);return(0,B.jsxs)(`div`,{"data-slot":`turn-time`,className:`flex items-center gap-1.5 px-0.5 text-xs leading-none text-soft-foreground`,children:[(0,B.jsx)(`time`,{dateTime:t,title:Ft(t),children:n}),r===void 0?null:(0,B.jsxs)(`span`,{title:`Replied in ${r}`,children:[`· `,r]})]})}function Vt({ts:e}){let t=Lt(e),n=Y(e);if(t===void 0||n===void 0)return null;let r=Pt.format(n);return(0,B.jsxs)(`div`,{"data-slot":`day-separator`,role:`separator`,"aria-label":t===`Today`||t===`Yesterday`?`${t}, ${r}`:r,className:`flex items-center gap-3 py-1 text-xs font-medium text-soft-foreground`,children:[(0,B.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`}),(0,B.jsx)(`time`,{dateTime:It(e),title:r,children:t}),(0,B.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`})]})}var Ht={assistant:`Agent message`,error:`Runner error`,"session.error":`Session error`,"step-end":`Step status`,lifecycle:`Run status`};function Ut({note:e}){return e.icon===`handoff`?(0,B.jsxs)(`div`,{"data-slot":`note-line`,"data-tone":e.tone,"data-icon":`handoff`,className:`flex items-start gap-2 px-0.5 text-xs text-muted-foreground`,children:[(0,B.jsx)(`span`,{"aria-hidden":`true`,className:`mt-[-1px] flex size-5 shrink-0 items-center justify-center rounded-full border border-border text-success`,children:(0,B.jsx)(pe,{className:`size-3`})}),(0,B.jsx)(`span`,{className:`min-w-0 break-words`,children:e.text})]}):e.details&&e.details.length>0?(0,B.jsxs)(N,{"data-slot":`note-line`,"data-tone":e.tone,className:`group/failure min-w-0 px-0.5 text-xs`,children:[(0,B.jsxs)(`div`,{className:p(`flex items-start gap-2`,e.tone===`danger`?`text-semantic-red`:`text-soft-foreground`),children:[(0,B.jsxs)(`span`,{className:`min-w-0 flex-1 whitespace-pre-wrap wrap-anywhere`,children:[e.tone===`danger`?`✗ `:null,e.text]}),(0,B.jsxs)(M,{"data-slot":`note-details-toggle`,className:`inline-flex shrink-0 items-center gap-1 rounded-sm px-1.5 py-0.5 text-xs font-medium text-muted-foreground hover:bg-muted/50 hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:min-h-11 max-md:min-w-11 max-md:justify-center pointer-coarse:min-h-11 pointer-coarse:min-w-11 pointer-coarse:justify-center`,children:[(0,B.jsx)(v,{"aria-hidden":`true`,className:`size-3 shrink-0 motion-safe:transition-transform group-data-[state=open]/failure:rotate-90`}),`Details`]})]}),(0,B.jsx)(j,{children:(0,B.jsx)(`ul`,{"data-slot":`note-details`,className:`mbs-1.5 flex flex-col gap-1 border-s border-border ps-3 font-mono text-xs text-muted-foreground`,children:e.details.map((e,t)=>(0,B.jsxs)(`li`,{className:`min-w-0 whitespace-pre-wrap wrap-anywhere`,children:[(0,B.jsxs)(`span`,{className:`font-sans font-medium text-foreground`,children:[Ht[e.source],`:`,` `]}),e.text]},`${e.source}:${t}`))})})]}):(0,B.jsxs)(`div`,{"data-slot":`note-line`,"data-tone":e.tone,className:p(`px-0.5 text-xs`,e.tone===`danger`?`text-semantic-red`:`text-soft-foreground`),children:[e.tone===`danger`?`✗ `:null,e.text]})}var Wt={user:{label:`YOUR MESSAGE`,speaker:`Your message`,classes:`border-message-user-border bg-message-user-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-user-accent`,accent:`text-message-user-accent`,body:`max-md:text-[12px]`},agent:{label:`AGENT RESPONSE`,speaker:`Agent response`,classes:`border-message-agent-border bg-message-agent-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-agent-accent`,accent:`text-message-agent-accent`,body:`text-[15px] md:text-[14px]`}};function Q({role:e,children:t,className:n,ts:r,headerActions:i,...a}){let o=Wt[e],s=r===void 0?void 0:X(r);return(0,B.jsxs)(`article`,{...a,"data-role":e,"aria-label":o.speaker,className:p(`flex w-full min-w-0 flex-col gap-2 self-stretch rounded-[8px] border p-3 md:px-4 md:py-[14px]`,o.classes,n),children:[(0,B.jsxs)(`p`,{className:p(`m-0 flex w-full min-w-0 items-start gap-2 text-xs leading-[1.2] font-semibold tracking-[0.6px] uppercase`,o.accent),children:[(0,B.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-1 normal-case tracking-normal`,children:[(0,B.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2 uppercase tracking-[0.6px]`,children:[(0,B.jsx)(te,{"aria-hidden":`true`,className:`size-4 shrink-0`}),o.label]}),i]}),s===void 0?null:(0,B.jsx)(`span`,{className:`shrink-0 font-normal tracking-normal normal-case`,children:(0,B.jsx)(zt,{ts:r})})]}),(0,B.jsx)(`div`,{className:p(`min-w-0 break-words text-[14px] text-foreground select-text [overflow-wrap:anywhere]`,o.body,`leading-[1.6]`),children:t})]})}var Gt=[],Kt=(0,z.memo)(function({text:e,imageCount:t=0,images:n=Gt,ts:r,onEdit:i,onRemove:a,editLabel:s=`Edit message`,removeLabel:l=`Remove message`,children:u}){let d=t-n.length,[f,p]=(0,z.useState)(!1),[h,g]=(0,z.useState)(e),[_,v]=(0,z.useState)(!1),[y,b]=(0,z.useState)(),x=()=>{g(e),b(void 0),p(!0)},C=async()=>{let t=h.trim();if(!t||t===e){p(!1);return}v(!0),b(void 0);try{await i?.(t),p(!1)}catch(e){b(e instanceof Error?e.message:`Could not save the message`)}finally{v(!1)}},w=async()=>{v(!0),b(void 0);try{await a?.()}catch(e){b(e instanceof Error?e.message:`Could not remove the message`)}finally{v(!1)}};return f?(0,B.jsxs)(Q,{role:`user`,ts:r,"data-slot":`user-bubble`,"data-editing":`true`,children:[(0,B.jsx)(`textarea`,{autoFocus:!0,"aria-label":`Edit the message`,value:h,onChange:e=>g(e.target.value),onKeyDown:e=>{e.key===`Escape`?(e.stopPropagation(),p(!1)):e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),C())},className:`block max-h-[220px] min-h-[60px] w-full resize-none rounded-md bg-background px-2 py-1.5 text-[14px] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`}),(0,B.jsxs)(`span`,{className:`mt-1.5 flex justify-end gap-1.5`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:()=>p(!1),disabled:_,className:`inline-flex min-h-11 min-w-11 items-center justify-center rounded-sm px-2 text-xs font-medium text-muted-foreground hover:bg-background hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:`Cancel`}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>void C(),disabled:_,className:`inline-flex min-h-11 min-w-11 items-center justify-center rounded-sm bg-action px-2 text-xs font-semibold text-action-foreground hover:brightness-[0.96] focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:_?(0,B.jsx)(O,{className:`size-3.5 animate-spin`}):`Save`})]}),y?(0,B.jsx)(`p`,{role:`alert`,className:`mt-1.5 text-xs text-danger`,children:y}):null]}):(0,B.jsxs)(Q,{role:`user`,ts:r,"data-slot":`user-bubble`,className:`group`,children:[i||a?(0,B.jsxs)(`span`,{"data-slot":`bubble-actions`,className:`mb-1 flex justify-end gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100`,children:[i?(0,B.jsx)(`button`,{type:`button`,"aria-label":s,onClick:x,disabled:_,className:`inline-flex size-11 items-center justify-center rounded-sm text-soft-foreground hover:bg-background hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,B.jsx)(Te,{className:`size-3.5`})}):null,a?(0,B.jsx)(`button`,{type:`button`,"aria-label":l,onClick:()=>void w(),disabled:_,className:`inline-flex size-11 items-center justify-center rounded-sm text-soft-foreground hover:bg-background hover:text-danger focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,B.jsx)(S,{className:`size-3.5`})}):null]}):null,y?(0,B.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:y}):null,u??(0,B.jsx)(L,{breaks:!0,children:e}),n.length>0?(0,B.jsx)(`span`,{"data-slot":`user-images`,className:`mt-2 flex flex-wrap items-center justify-end gap-1.5`,children:n.map(e=>c(e.split(`/`).pop()??``)?(0,B.jsx)(ve,{src:e,alt:`attached`,className:`max-h-40 max-w-[220px] rounded-md border border-border object-contain`},e):(0,B.jsxs)(`a`,{href:o(e),download:!0,"data-slot":`user-file`,className:`inline-flex min-h-11 min-w-11 max-w-[220px] items-center gap-1.5 rounded-md border border-border bg-background/60 px-2 py-1 text-xs text-muted-foreground hover:text-foreground`,children:[(0,B.jsx)(m,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,B.jsx)(`span`,{className:`truncate`,children:e.split(`/`).pop()})]},e))}):null,d>0?(0,B.jsxs)(`span`,{className:`mt-1 block text-xs text-soft-foreground`,children:[d,` image`,d>1?`s`:``,` attached`]}):null]})}),qt=`inline-flex h-11 min-w-11 items-center justify-center gap-1 rounded-sm px-2 text-xs font-medium text-soft-foreground hover:bg-background hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,Jt=[`[data-streamdown="code-block-actions"]`,`[data-streamdown="code-copy-button"]`,`[data-streamdown="code-block-copy-button"]`,`[data-streamdown="code-block-header"]`].join(`,`);function Yt(e,t){let n=e.cloneNode(!0);n.querySelectorAll(Jt).forEach(e=>e.remove());let r=Qe(t);return[...n.querySelectorAll(`button[data-streamdown="link"]`)].forEach(e=>{let t=e.textContent??``,i=r.findIndex(e=>e.label===t);if(i<0)return;let a=r.splice(i,1)[0];if(!a||!U(a.href))return;let o=n.ownerDocument.createElement(`a`);o.setAttribute(`href`,a.href),o.setAttribute(`data-streamdown`,`link`),o.textContent=e.textContent,e.replaceWith(o)}),n.innerHTML}async function Xt(e,t,n){if(e===`markdown`){if(!navigator.clipboard?.writeText)throw Error(`Clipboard unavailable`);await navigator.clipboard.writeText(t);return}if(!navigator.clipboard?.write||typeof ClipboardItem>`u`||!n)throw Error(`Clipboard unavailable`);let r=Yt(n,t);await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([r],{type:`text/html`}),"text/plain":new Blob([t],{type:`text/plain`})})])}var Zt=(0,z.memo)(function({text:e,ts:t,messageKey:n}){let r=(0,z.useRef)(null),[i,a]=(0,z.useState)(null),[o,s]=(0,z.useState)(null),c=(0,z.useRef)(null);(0,z.useEffect)(()=>()=>{c.current!==null&&clearTimeout(c.current)},[]);let l=async t=>{c.current!==null&&clearTimeout(c.current),a(null),s(null);try{await Xt(t,e,r.current),a(t),c.current=setTimeout(()=>a(null),2e3)}catch{s(`Couldn't copy to the clipboard`)}};return(0,B.jsxs)(Q,{role:`agent`,ts:t,"data-slot":`assistant-message`,headerActions:(0,B.jsxs)(`span`,{"data-slot":`bubble-actions`,className:`flex items-center gap-0.5`,children:[(0,B.jsxs)(`button`,{type:`button`,"aria-label":`Copy reply`,onClick:()=>void l(`html`),className:qt,children:[(0,B.jsx)(w,{className:`size-3.5`,"aria-hidden":`true`}),(0,B.jsx)(`span`,{"aria-live":`polite`,children:i===`html`?`Copied`:`Copy`})]}),(0,B.jsxs)(`button`,{type:`button`,"aria-label":`Copy reply as markdown`,onClick:()=>void l(`markdown`),className:qt,children:[(0,B.jsx)(F,{className:`size-3.5`,"aria-hidden":`true`}),(0,B.jsx)(`span`,{"aria-live":`polite`,children:i===`markdown`?`Copied`:`Copy markdown`})]})]}),children:[o?(0,B.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:o}):null,(0,B.jsx)(`div`,{ref:r,children:(0,B.jsx)(L,{breaks:!0,children:e})}),(0,B.jsx)(nt,{text:e,messageKey:n})]})});function Qt({incident:e}){let t=i().data;if(!t)return null;let n=a(t,e.provider);return(0,B.jsxs)(`div`,{role:`alert`,"data-slot":`provider-auth-required`,className:`rounded-md border border-danger/30 bg-danger/5 px-3.5 py-3`,children:[(0,B.jsxs)(`p`,{className:`text-[13px] font-semibold text-foreground`,children:[`This run needed `,n,` authorization`]}),(0,B.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[`Review `,n,` settings before retrying.`]}),(0,B.jsx)(P,{to:`/settings/agent-defaults#providers`,className:`mt-2 inline-flex text-xs font-medium text-foreground underline-offset-2 hover:underline`,children:`Open provider settings`})]})}var $t=(0,z.memo)(function({text:e}){let t=(0,z.useId)();if(e.trim()===``)return null;let n=e.split(`
@@ -1,2 +1,2 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Ct as r,bt as i,g as a,k as o,vt as s,yt as c}from"./queries-D7W-eGim.js";import{d as l}from"./host-context-KsSKxKbI.js";import{$r as u,Cn as d,H as f,Ri as p,U as m,V as h,W as g,Zr as _,_ as v,c as y,d as b,ei as x,g as ee,ni as te,nr as ne,o as re,s as ie,v as ae,zi as S}from"./project-scope-context-Bz7AAyJ4.js";import{B as C,G as oe,H as se,I as w,K as ce,N as T,P as E,V as le,W as D,j as O,z as k}from"./live-protocol-CNUmr-VT.js";import{g as ue,n as de}from"./chunk-KS7C4IRE-BdLLx37K.js";import{r as fe,t as A}from"./label-DEZnEIpB.js";import{o as j}from"./dist-CCX8mhHc.js";import{L as pe,X as me,Z as he,b as ge,ft as _e,ht as ve,nt as ye,ot as be,u as xe}from"./design-icons-QbNMZniQ.js";import{t as Se}from"./check-OP-CVgZG.js";import{t as M}from"./button-BV_AiLj2.js";import{n as Ce,r as we,t as Te}from"./collapsible-D5i3hm2L.js";import{a as N,i as P,n as F,r as I,t as L}from"./select-C72KGfnK.js";import{t as Ee}from"./switch-B9OfOEzC.js";import{c as De,s as Oe,t as R}from"./project-router-CARDbdMX.js";import{c as ke,d as z,f as Ae,l as je,n as Me,o as Ne}from"./page-shell-BdjH5hyc.js";import{a as Pe}from"./agent-accounts-BzD14qLU.js";import{r as Fe}from"./agents-settings-path-7X6_cvUg.js";import{t as Ie}from"./centered-state-N8vWM_Hw.js";import{$ as Le,Gn as Re,Kn as ze,M as Be,N as Ve,R as He,Sr as Ue,Tn as We,X as Ge,Z as Ke,ir as qe,j as Je,kn as Ye,lr as B,t as Xe}from"./index-D9hyWO4C.js";import{t as Ze}from"./textarea-BGp28xFr.js";import{_ as Qe,a as $e,c as et,d as tt,f as nt,g as rt,h as it,i as at,l as ot,m as st,n as ct,o as lt,p as ut,r as dt,s as ft,t as V,u as pt,v as mt}from"./automation-format-jKMOXcHS.js";var H=e(t(),1),U=O([`pull_request.opened`,`issue.opened`,`issue.labeled`,`issue.unlabeled`]),ht=C({includeExisting:E().optional(),authors:T(D()).optional(),assignees:T(D()).optional(),requireCurrentLabels:E().optional(),allLabels:T(D()).optional(),anyLabels:T(D()).optional(),excludeLabels:T(D()).optional(),changedLabels:T(D()).optional(),lookbackDays:k(),maxRecords:k()}),gt=O([`github`,`schedule`]),_t=_.omit({task:!0,images:!0,systemPrompt:!0}).extend({prompt:D(),variants:oe([w(1),w(2),w(3)]).optional(),systemPrompt:D().optional()}),vt=C({at:D(),outcome:O([`launched`,`cancelled`]),runId:D().optional(),receiptId:D().optional(),trigger:O([`schedule`,`late`,`manual`,`retry`]).optional()}),W=C({id:D(),revision:k(),name:D(),description:D().optional(),enabled:E(),kind:gt,events:T(U).optional(),intervalSeconds:k().optional(),filters:ht.optional(),schedule:et.optional(),task:_t,archived:vt.optional(),createdAt:D(),updatedAt:D()}),G=C({timestamp:D(),tieBreaker:D().optional()}),yt=C({since:D().datetime(),until:D().datetime(),source:k().int().min(0).max(2),page:k().int().min(1).max(10),item:k().int().min(0).max(100),event:k().int().min(0).max(1e3),cursor:G.optional()}),bt={lastError:D().max(1e3).optional(),lastErrorAt:D().datetime().optional()},xt=C({revision:k().optional(),baselineAt:D().optional(),armedAt:D().optional(),historyScan:yt.optional(),cursor:G.optional(),frozenHighWatermark:G.extend({tieBreaker:D()}).optional(),backlogAfter:G.extend({tieBreaker:D()}).optional(),nextCheckAt:D().optional(),lastSuccessAt:D().optional(),nextRunAt:D().optional(),lastRunAt:D().optional(),etags:se(D(),D()).optional(),backoffUntil:D().optional(),consecutiveFailures:k().optional(),...bt,onceOutcome:O([`failed`,`missed`]).optional()});function St(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 Ct=O([`launched`,`no-match`,`duplicate`,`rate-limited`,`error`,`baseline`,`preview`,`skipped`,`manual`,`catch-up`,`failed`,`missed`]),wt=C({seq:k(),ts:D(),automationId:D(),revision:k(),event:U.optional(),result:Ct,reason:D().optional(),durationMs:k().optional(),receiptId:D().optional(),runId:D().optional(),githubNumber:k().optional(),githubTitle:D().optional(),githubUrl:D().optional(),rateLimit:C({bucket:O([`core`,`search`]),remaining:k().optional(),resetAt:D().optional()}).optional()}),Tt=C({matches:k(),launched:k(),duplicates:k(),errors:k()}),Et=W.extend({state:xt.optional(),latestLog:wt.optional(),counts:Tt,nextRunAt:D().optional(),onceStatus:ut.optional()});C({available:E(),reason:D().optional(),timeZone:D(),scheduler:C({state:O([`scheduled`,`idle`]),nextDue:D().optional()}),automations:T(Et)}),C({automation:W}).extend({once:C({dueAt:D(),timeZone:D(),resolvedInstant:D(),note:D()}).optional()}),C({automation:W,state:xt.optional(),latestLog:wt.optional(),onceStatus:ut.optional()}),C({id:D(),automationId:D(),mode:O([`preview`,`execute`]),status:O([`queued`,`running`,`complete`,`error`]),createdAt:D(),completedAt:D().optional(),matches:k().optional(),truncated:E().optional(),error:D().optional()}),C({checkId:D()}),C({records:T(wt)}),C({receiptId:D(),runId:D()}),C({runId:D()}),W.omit({id:!0,revision:!0,createdAt:!0,updatedAt:!0,enabled:!0,kind:!0,archived:!0}).extend({kind:gt.optional(),task:_t.omit({variants:!0}).strict(),enable:E().optional()}).omit({enable:!0}).extend({enabled:E().optional(),expectedRevision:k()}),C({archived:O([`include`,`only`]).optional()}),C({mode:O([`preview`,`execute`])});var K=n();function q({text:e}){return(0,K.jsx)(`div`,{role:`status`,className:`rounded-xl border border-border bg-card p-6 text-sm text-muted-foreground`,children:e})}var Dt={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`},Ot={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 kt(e){let[t,n]=(0,H.useState)(),[r,i]=(0,H.useState)(``),a=(0,H.useCallback)(t=>v(e,{signal:t}).then(({records:e})=>{t?.aborted||(n(e),i(``))}).catch(e=>{t?.aborted||i(String(e))}),[e]);return(0,H.useEffect)(()=>{a()},[a]),(0,H.useEffect)(()=>ne(a),[a]),(0,H.useEffect)(()=>fe((t,n)=>{t===`automation-change`&&n.automationId===e&&a()}),[e,a]),{records:t,error:r,refresh:a}}function At(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 jt({records:e,all:t,timeZone:n,onRetried:r,readOnly:i=!1}){let a=e=>!i&&At(e,t),[o,s]=(0,H.useState)(),[c,l]=(0,H.useState)(),u=Date.now(),d=async e=>{s(e),l(void 0);try{await h(e),r()}catch(t){l({receiptId:e,message:t instanceof Error?t.message:String(t)})}finally{s(void 0)}};return(0,K.jsx)(`ol`,{className:`grid gap-3`,"aria-label":`Automation execution log`,children:e.map(e=>(0,K.jsxs)(`li`,{className:`min-w-0 rounded-xl border border-card-edge bg-card p-4 shadow-card`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,K.jsx)(qe,{dot:Dt[e.result],children:Ot[e.result]}),(0,K.jsx)(`time`,{className:`text-xs text-muted-foreground`,dateTime:e.ts,title:e.ts,children:ct(e.ts,n,u)})]}),e.reason?(0,K.jsx)(`p`,{className:`mt-2 text-sm break-words text-muted-foreground`,children:e.reason}):null,e.githubUrl||e.runId||a(e)?(0,K.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-4 gap-y-2 text-sm`,children:[e.githubUrl?(0,K.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,K.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,K.jsx)(M,{variant:`outline`,disabled:o===e.receiptId,onClick:()=>void d(e.receiptId),children:`Retry task`}):null]}):null,c&&c.receiptId===e.receiptId?(0,K.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm break-words text-destructive`,children:c.message}):null]},e.seq))})}var J=`all`;function Mt({label:e,value:t,onChange:n,options:r}){return(0,K.jsxs)(L,{value:t,onValueChange:n,children:[(0,K.jsx)(P,{"aria-label":e,className:`w-full sm:w-52`,children:(0,K.jsx)(N,{})}),(0,K.jsx)(F,{children:r.map(e=>(0,K.jsx)(I,{value:e.value,children:e.label},e.value))})]})}function Nt({automationId:e,automationName:t,timeZone:n,readOnly:r=!1}){let{records:i,error:a,refresh:o}=kt(e),[s,c]=(0,H.useState)(J),[l,u]=(0,H.useState)(J),d=(0,H.useMemo)(()=>(i??[]).filter(e=>(s===J||e.result===s)&&(l===J||e.event===l)),[i,s,l]),f=(i??[]).some(e=>e.event);return(0,K.jsx)(je,{route:`automations`,density:i?Ae(d.length):`full`,header:{title:`Execution log`,subtitle:t??`Automation activity`,secondaryActions:(0,K.jsx)(ke,{variant:`outline`,asChild:!0,children:(0,K.jsx)(R,{to:`/automations`,children:`Back to automations`})})},children:a&&!i?(0,K.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,K.jsx)(q,{text:a}),(0,K.jsx)(M,{variant:`outline`,onClick:()=>void o(),children:`Retry`})]}):i?i.length===0?(0,K.jsx)(q,{text:`Nothing has run yet.`}):(0,K.jsxs)(`div`,{className:`grid gap-4`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(Mt,{label:`Result`,value:s,onChange:c,options:[{value:J,label:`All results`},...Ct.options.map(e=>({value:e,label:Ot[e]}))]}),f?(0,K.jsx)(Mt,{label:`Event`,value:l,onChange:u,options:[{value:J,label:`All events`},...U.options.map(e=>({value:e,label:e}))]}):null]}),d.length===0?(0,K.jsx)(q,{text:`No rows match these filters.`}):(0,K.jsx)(jt,{records:d,all:i,timeZone:n,onRetried:()=>void o(),readOnly:r})]}):(0,K.jsx)(q,{text:`Loading execution log…`})})}function Pt({automationId:e,automationName:t,timeZone:n,showName:r=!1,readOnly:i=!1}){let{records:a,error:o,refresh:s}=kt(e),c=`Recent activity${r&&t?` · ${t}`:``}`;return!o&&a&&a.length===0?(0,K.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,K.jsx)(`h3`,{className:`font-medium text-foreground`,children:c}),(0,K.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,K.jsx)(`p`,{children:`Nothing has run yet.`})]}):(0,K.jsxs)(`section`,{"data-slot":`automation-inline-log`,className:`min-w-0 border-t border-border pt-2.5`,children:[(0,K.jsx)(`h3`,{className:`mb-1.5 text-xs font-medium text-muted-foreground`,children:c}),o&&!a?(0,K.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[(0,K.jsx)(q,{text:o}),(0,K.jsx)(M,{variant:`outline`,onClick:()=>void s(),children:`Retry`})]}):a?(0,K.jsx)(jt,{records:a.slice(0,5),all:a,timeZone:n,onRetried:()=>void s(),readOnly:i}):(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Loading activity…`})]})}function Ft({automation:e,timeZone:t,onDeleted:n}){let r=e.archived,i=e.schedule,a=i?dt(i):null,[o,s]=(0,H.useState)(!1),[c,l]=(0,H.useState)(!1),[u,d]=(0,H.useState)(``),f=(0,H.useRef)(null),p=(0,H.useRef)(null),m=(0,H.useRef)(null);(0,H.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 b(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,K.jsx)(je,{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,K.jsxs)(`div`,{className:`grid min-w-0 gap-5`,children:[(0,K.jsxs)(`section`,{className:`min-w-0 rounded-xl border border-card-edge bg-card shadow-card p-4`,children:[(0,K.jsxs)(`p`,{className:`text-sm break-words`,children:[(0,K.jsx)(`span`,{children:r.outcome===`launched`?`Started its task.`:`Cancelled — no task was started.`}),r.runId?(0,K.jsxs)(K.Fragment,{children:[` · `,(0,K.jsx)(R,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${r.runId}`,children:`Open task`})]}):null]}),(0,K.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Archived ${V(r.at,t)} (${t}).`}),a&&i?.timeZone?(0,K.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Was due ${a.date} ${a.time} (${i.timeZone}).`}):null]}),(0,K.jsxs)(`section`,{"aria-labelledby":`archived-inputs`,className:`min-w-0 rounded-xl border border-card-edge bg-card shadow-card p-4`,children:[(0,K.jsx)(`h2`,{id:`archived-inputs`,className:`mb-3 text-[15px] font-medium`,children:`What it ran with`}),(0,K.jsxs)(`dl`,{className:`grid gap-3 text-sm`,children:[(0,K.jsxs)(`div`,{className:`grid gap-1`,children:[(0,K.jsx)(`dt`,{className:`text-muted-foreground`,children:`Prompt`}),(0,K.jsx)(`dd`,{className:`break-words whitespace-pre-wrap`,children:e.task.prompt})]}),g.filter(([,e])=>e).map(([e,t])=>(0,K.jsxs)(`div`,{className:`grid gap-1`,children:[(0,K.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,K.jsx)(`dd`,{className:`break-words`,children:t})]},e))]})]}),(0,K.jsxs)(`section`,{className:`min-w-0`,children:[(0,K.jsx)(Pt,{automationId:e.id,automationName:e.name,timeZone:t,readOnly:!0}),(0,K.jsx)(M,{variant:`outline`,asChild:!0,className:`mt-3`,children:(0,K.jsx)(R,{to:`/automations/${e.id}/log`,children:`Execution log`})})]}),(0,K.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[o?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`text-sm break-words`,children:`Delete “${e.name}”? Its record and log are removed; the task stays.`}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(M,{variant:`danger-ghost`,"data-action":`automation-delete-confirm`,disabled:c,onClick:()=>void h(),children:`Delete schedule`}),(0,K.jsx)(M,{ref:p,variant:`outline`,disabled:c,onClick:()=>{m.current=`delete`,s(!1)},children:`Keep`})]})]}):(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(M,{ref:f,variant:`outline`,"data-action":`automation-delete`,onClick:()=>{m.current=`keep`,s(!0)},children:`Delete`}),(0,K.jsx)(M,{variant:`outline`,asChild:!0,children:(0,K.jsx)(R,{to:`/automations`,children:`Back to automations`})})]}),u?(0,K.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:u}):null]})]})})}var It=O([`pull_request.opened`,`issue.opened`,`issue.labeled`,`issue.unlabeled`]),Y=T(D().trim().min(1).max(200)).max(100).optional(),Lt=C({includeExisting:E().optional(),requireCurrentLabels:E().optional(),authors:Y,assignees:Y,allLabels:Y,anyLabels:Y,excludeLabels:Y,changedLabels:Y,lookbackDays:k().int().min(1).max(90).default(7),maxRecords:k().int().min(1).max(100).default(25)}).passthrough(),Rt=C({prompt:D().min(1).max(1e5),workflow:D().trim().min(1).max(200).optional(),steps:T(u).min(1).max(100).optional(),runner:p.optional(),model:D().trim().min(1).max(200).optional(),effort:D().trim().min(1).max(32).optional(),variants:oe([w(1),w(2),w(3)]).optional(),worktree:E().optional(),autonomous:E().optional(),...x,...te,systemPrompt:D().max(1e5).optional()}).passthrough().refine(e=>!(e.workflow&&e.steps),{message:`task selects either a named workflow or inline steps, not both`}),zt=new Set(Object.keys(Rt.shape).filter(e=>e!==`variants`));function Bt(e){return Object.fromEntries(Object.entries(e).filter(([e])=>zt.has(e)))}le(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:D().min(1).max(100),revision:k().int().positive(),name:D().trim().min(1).max(200),description:D().max(2e3).optional(),enabled:E().default(!1),kind:gt.default(`github`),events:T(It).min(1).max(4).optional(),intervalSeconds:k().int().min(60).max(86400).optional(),filters:Lt.optional(),schedule:et.passthrough().optional(),task:Rt,archived:C({at:D().datetime(),outcome:O([`launched`,`cancelled`]),runId:D().optional(),receiptId:D().optional(),trigger:O([`schedule`,`late`,`manual`,`retry`]).optional()}).passthrough().optional(),createdAt:D().datetime(),updatedAt:D().datetime()}).passthrough().superRefine((e,t)=>{if(e.kind===`schedule`){e.schedule||t.addIssue({code:S.custom,path:[`schedule`],message:`a scheduled automation needs a schedule`});return}e.events?.length||t.addIssue({code:S.custom,path:[`events`],message:`a GitHub automation needs at least one event`}),e.intervalSeconds===void 0&&t.addIssue({code:S.custom,path:[`intervalSeconds`],message:`a GitHub automation needs a poll interval`}),e.filters||t.addIssue({code:S.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:S.custom,path:[`filters`,`changedLabels`],message:`changedLabels is required for issue label events`})})),C({version:w(1).default(1),automations:T(ce()).default([]),tombstones:se(D(),D().datetime()).optional()}).passthrough();var X=C({timestamp:D().datetime(),tieBreaker:D().optional()}).passthrough(),Vt=yt.extend({cursor:X.optional()}),Ht=C({revision:k().int().positive().optional(),baselineAt:D().datetime().optional(),armedAt:D().datetime().optional(),historyScan:Vt.optional(),cursor:X.optional(),frozenHighWatermark:X.extend({tieBreaker:D()}).optional(),backlogAfter:X.extend({tieBreaker:D()}).optional(),nextCheckAt:D().datetime().optional(),lastSuccessAt:D().datetime().optional(),nextRunAt:D().datetime().optional(),lastRunAt:D().datetime().optional(),etags:se(D(),D()).optional(),backoffUntil:D().datetime().optional(),consecutiveFailures:k().int().nonnegative().optional(),...bt,onceOutcome:O([`failed`,`missed`]).optional()}).passthrough();C({version:w(1).default(1),states:se(D(),Ht).default({})}).passthrough(),C({receiptId:D().min(1),receiptKey:D().min(1),eventId:D().min(1),automationId:D().min(1),revision:k().int().positive(),status:O([`reserved`,`launched`,`launch-error`,`released`]),runId:D().optional(),observedAt:D().datetime(),updatedAt:D().datetime(),error:D().max(2e3).optional(),occurrenceAt:D().datetime().optional(),candidate:C({eventId:D(),event:It,timestamp:D().datetime(),tieBreaker:D(),repo:D(),nodeId:D(),number:k().int().positive(),title:D().max(500),url:D().url(),author:D().max(200),assignees:T(D().max(200)).max(100),labels:T(D().max(200)).max(100),changedLabel:D().max(200).optional()}).passthrough().optional()}).passthrough();var Ut=O([`launched`,`no-match`,`duplicate`,`rate-limited`,`error`,`baseline`,`preview`,`skipped`,`manual`,`catch-up`,`failed`,`missed`]);C({seq:k().int().positive(),ts:D().datetime(),automationId:D().min(1),revision:k().int().positive(),event:It.optional(),result:Ut,reason:D().max(2e3).optional(),durationMs:k().int().nonnegative().optional(),receiptId:D().optional(),runId:D().optional(),githubNumber:k().int().positive().optional(),githubTitle:D().max(500).optional(),githubUrl:D().url().optional(),rateLimit:C({bucket:O([`core`,`search`]),remaining:k().int().nonnegative().optional(),resetAt:D().datetime().optional()}).passthrough().optional()}).passthrough();var Wt=`quick-task`;function Gt(e={}){let{prompt:t,workflow:n,runner:r,model:i,autonomous:a,archiveWhenDone:o,autoMergePr:s,allowWorkers:c,allowMessaging:l,...u}=Bt(e.task??{prompt:``}),d=e.task===void 0;return{name:e.name??``,description:e.description??``,kind:e.kind??`schedule`,schedule:pt(e.schedule??{type:`daily`}),events:e.events??[U.options[0]],intervalSeconds:e.intervalSeconds??300,filters:e.filters??{lookbackDays:7,maxRecords:25},prompt:t,...n===void 0?d?{workflow:Wt}:{}:{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 Kt(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 qt(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 Jt(e){return{name:e.name.trim(),...e.description.trim()?{description:e.description.trim()}:{},kind:e.kind,...e.kind===`schedule`?{schedule:Kt(e.schedule)}:{events:e.events,intervalSeconds:e.intervalSeconds,filters:e.filters},task:qt(e)}}function Yt(e){return{...Jt(e),enable:e.enabled}}function Xt(e,t){return{...Jt(e),task:{...qt(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 Zt=new Set([`prompt`,`workflow`,`runner`,`model`,`autonomous`,`worktree`,`archiveWhenDone`,`autoMergePr`,`allowWorkers`,`allowMessaging`]),Qt=new Set([`anyLabels`,`authors`,`changedLabels`]);function $t(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=>!Zt.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||Qt.has(e)&&Array.isArray(t)&&t.length>0)}function en(e){return e%3600==0?`${e/3600}h`:e%60==0?`${e/60}m`:`${e}s`}function tn(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 nn(e){let t=[`${We()} 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`,tn(e.schedule.latestStartMinutes)));else if(e.kind===`schedule`)t.push(Q(`cron`,ot(e.schedule)));else{t.push(Q(`on`,e.events.join(`,`)),`--every ${en(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(...rn(e.task)),e.enable===!0&&t.push(`--enable`),t.push(Q(`prompt`,e.task.prompt)),t.join(` `)}function rn(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 an(e,t){let n=Yt(e),r=$t(n)?nn(n):`${We()} 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 on(e){let t=[],n=!1;for(let r of sn(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(` \\
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Ct as r,bt as i,g as a,k as o,vt as s,yt as c}from"./queries-ChH9ctc-.js";import{d as l}from"./host-context-KsSKxKbI.js";import{$r as u,Cn as d,H as f,Ri as p,U as m,V as h,W as g,Zr as _,_ as v,c as y,d as b,ei as x,g as ee,ni as te,nr as ne,o as re,s as ie,v as ae,zi as S}from"./project-scope-context-hfRzPMZ4.js";import{B as C,G as oe,H as se,I as w,K as ce,N as T,P as E,V as le,W as D,j as O,z as k}from"./live-protocol-CNUmr-VT.js";import{g as ue,n as de}from"./chunk-KS7C4IRE-BdLLx37K.js";import{r as fe,t as A}from"./label-D6vgq5lF.js";import{o as j}from"./dist-CCX8mhHc.js";import{L as pe,X as me,Z as he,b as ge,ft as _e,ht as ve,nt as ye,ot as be,u as xe}from"./design-icons-QbNMZniQ.js";import{t as Se}from"./check-OP-CVgZG.js";import{t as M}from"./button-BV_AiLj2.js";import{n as Ce,r as we,t as Te}from"./collapsible-D5i3hm2L.js";import{a as N,i as P,n as F,r as I,t as L}from"./select-xjUzLrk9.js";import{t as Ee}from"./switch-B9OfOEzC.js";import{c as De,s as Oe,t as R}from"./project-router-yoWCTDaT.js";import{c as ke,d as z,f as Ae,l as je,n as Me,o as Ne}from"./page-shell-BdjH5hyc.js";import{a as Pe}from"./agent-accounts-CUthX0Yh.js";import{r as Fe}from"./agents-settings-path-7X6_cvUg.js";import{t as Ie}from"./centered-state-N8vWM_Hw.js";import{$ as Le,Gn as Re,Kn as ze,M as Be,N as Ve,R as He,Sr as Ue,Tn as We,X as Ge,Z as Ke,ir as qe,j as Je,kn as Ye,lr as B,t as Xe}from"./index-BuR9xHfb.js";import{t as Ze}from"./textarea-BGp28xFr.js";import{_ as Qe,a as $e,c as et,d as tt,f as nt,g as rt,h as it,i as at,l as ot,m as st,n as ct,o as lt,p as ut,r as dt,s as ft,t as V,u as pt,v as mt}from"./automation-format-jKMOXcHS.js";var H=e(t(),1),U=O([`pull_request.opened`,`issue.opened`,`issue.labeled`,`issue.unlabeled`]),ht=C({includeExisting:E().optional(),authors:T(D()).optional(),assignees:T(D()).optional(),requireCurrentLabels:E().optional(),allLabels:T(D()).optional(),anyLabels:T(D()).optional(),excludeLabels:T(D()).optional(),changedLabels:T(D()).optional(),lookbackDays:k(),maxRecords:k()}),gt=O([`github`,`schedule`]),_t=_.omit({task:!0,images:!0,systemPrompt:!0}).extend({prompt:D(),variants:oe([w(1),w(2),w(3)]).optional(),systemPrompt:D().optional()}),vt=C({at:D(),outcome:O([`launched`,`cancelled`]),runId:D().optional(),receiptId:D().optional(),trigger:O([`schedule`,`late`,`manual`,`retry`]).optional()}),W=C({id:D(),revision:k(),name:D(),description:D().optional(),enabled:E(),kind:gt,events:T(U).optional(),intervalSeconds:k().optional(),filters:ht.optional(),schedule:et.optional(),task:_t,archived:vt.optional(),createdAt:D(),updatedAt:D()}),G=C({timestamp:D(),tieBreaker:D().optional()}),yt=C({since:D().datetime(),until:D().datetime(),source:k().int().min(0).max(2),page:k().int().min(1).max(10),item:k().int().min(0).max(100),event:k().int().min(0).max(1e3),cursor:G.optional()}),bt={lastError:D().max(1e3).optional(),lastErrorAt:D().datetime().optional()},xt=C({revision:k().optional(),baselineAt:D().optional(),armedAt:D().optional(),historyScan:yt.optional(),cursor:G.optional(),frozenHighWatermark:G.extend({tieBreaker:D()}).optional(),backlogAfter:G.extend({tieBreaker:D()}).optional(),nextCheckAt:D().optional(),lastSuccessAt:D().optional(),nextRunAt:D().optional(),lastRunAt:D().optional(),etags:se(D(),D()).optional(),backoffUntil:D().optional(),consecutiveFailures:k().optional(),...bt,onceOutcome:O([`failed`,`missed`]).optional()});function St(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 Ct=O([`launched`,`no-match`,`duplicate`,`rate-limited`,`error`,`baseline`,`preview`,`skipped`,`manual`,`catch-up`,`failed`,`missed`]),wt=C({seq:k(),ts:D(),automationId:D(),revision:k(),event:U.optional(),result:Ct,reason:D().optional(),durationMs:k().optional(),receiptId:D().optional(),runId:D().optional(),githubNumber:k().optional(),githubTitle:D().optional(),githubUrl:D().optional(),rateLimit:C({bucket:O([`core`,`search`]),remaining:k().optional(),resetAt:D().optional()}).optional()}),Tt=C({matches:k(),launched:k(),duplicates:k(),errors:k()}),Et=W.extend({state:xt.optional(),latestLog:wt.optional(),counts:Tt,nextRunAt:D().optional(),onceStatus:ut.optional()});C({available:E(),reason:D().optional(),timeZone:D(),scheduler:C({state:O([`scheduled`,`idle`]),nextDue:D().optional()}),automations:T(Et)}),C({automation:W}).extend({once:C({dueAt:D(),timeZone:D(),resolvedInstant:D(),note:D()}).optional()}),C({automation:W,state:xt.optional(),latestLog:wt.optional(),onceStatus:ut.optional()}),C({id:D(),automationId:D(),mode:O([`preview`,`execute`]),status:O([`queued`,`running`,`complete`,`error`]),createdAt:D(),completedAt:D().optional(),matches:k().optional(),truncated:E().optional(),error:D().optional()}),C({checkId:D()}),C({records:T(wt)}),C({receiptId:D(),runId:D()}),C({runId:D()}),W.omit({id:!0,revision:!0,createdAt:!0,updatedAt:!0,enabled:!0,kind:!0,archived:!0}).extend({kind:gt.optional(),task:_t.omit({variants:!0}).strict(),enable:E().optional()}).omit({enable:!0}).extend({enabled:E().optional(),expectedRevision:k()}),C({archived:O([`include`,`only`]).optional()}),C({mode:O([`preview`,`execute`])});var K=n();function q({text:e}){return(0,K.jsx)(`div`,{role:`status`,className:`rounded-xl border border-border bg-card p-6 text-sm text-muted-foreground`,children:e})}var Dt={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`},Ot={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 kt(e){let[t,n]=(0,H.useState)(),[r,i]=(0,H.useState)(``),a=(0,H.useCallback)(t=>v(e,{signal:t}).then(({records:e})=>{t?.aborted||(n(e),i(``))}).catch(e=>{t?.aborted||i(String(e))}),[e]);return(0,H.useEffect)(()=>{a()},[a]),(0,H.useEffect)(()=>ne(a),[a]),(0,H.useEffect)(()=>fe((t,n)=>{t===`automation-change`&&n.automationId===e&&a()}),[e,a]),{records:t,error:r,refresh:a}}function At(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 jt({records:e,all:t,timeZone:n,onRetried:r,readOnly:i=!1}){let a=e=>!i&&At(e,t),[o,s]=(0,H.useState)(),[c,l]=(0,H.useState)(),u=Date.now(),d=async e=>{s(e),l(void 0);try{await h(e),r()}catch(t){l({receiptId:e,message:t instanceof Error?t.message:String(t)})}finally{s(void 0)}};return(0,K.jsx)(`ol`,{className:`grid gap-3`,"aria-label":`Automation execution log`,children:e.map(e=>(0,K.jsxs)(`li`,{className:`min-w-0 rounded-xl border border-card-edge bg-card p-4 shadow-card`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,K.jsx)(qe,{dot:Dt[e.result],children:Ot[e.result]}),(0,K.jsx)(`time`,{className:`text-xs text-muted-foreground`,dateTime:e.ts,title:e.ts,children:ct(e.ts,n,u)})]}),e.reason?(0,K.jsx)(`p`,{className:`mt-2 text-sm break-words text-muted-foreground`,children:e.reason}):null,e.githubUrl||e.runId||a(e)?(0,K.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-4 gap-y-2 text-sm`,children:[e.githubUrl?(0,K.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,K.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,K.jsx)(M,{variant:`outline`,disabled:o===e.receiptId,onClick:()=>void d(e.receiptId),children:`Retry task`}):null]}):null,c&&c.receiptId===e.receiptId?(0,K.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm break-words text-destructive`,children:c.message}):null]},e.seq))})}var J=`all`;function Mt({label:e,value:t,onChange:n,options:r}){return(0,K.jsxs)(L,{value:t,onValueChange:n,children:[(0,K.jsx)(P,{"aria-label":e,className:`w-full sm:w-52`,children:(0,K.jsx)(N,{})}),(0,K.jsx)(F,{children:r.map(e=>(0,K.jsx)(I,{value:e.value,children:e.label},e.value))})]})}function Nt({automationId:e,automationName:t,timeZone:n,readOnly:r=!1}){let{records:i,error:a,refresh:o}=kt(e),[s,c]=(0,H.useState)(J),[l,u]=(0,H.useState)(J),d=(0,H.useMemo)(()=>(i??[]).filter(e=>(s===J||e.result===s)&&(l===J||e.event===l)),[i,s,l]),f=(i??[]).some(e=>e.event);return(0,K.jsx)(je,{route:`automations`,density:i?Ae(d.length):`full`,header:{title:`Execution log`,subtitle:t??`Automation activity`,secondaryActions:(0,K.jsx)(ke,{variant:`outline`,asChild:!0,children:(0,K.jsx)(R,{to:`/automations`,children:`Back to automations`})})},children:a&&!i?(0,K.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,K.jsx)(q,{text:a}),(0,K.jsx)(M,{variant:`outline`,onClick:()=>void o(),children:`Retry`})]}):i?i.length===0?(0,K.jsx)(q,{text:`Nothing has run yet.`}):(0,K.jsxs)(`div`,{className:`grid gap-4`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(Mt,{label:`Result`,value:s,onChange:c,options:[{value:J,label:`All results`},...Ct.options.map(e=>({value:e,label:Ot[e]}))]}),f?(0,K.jsx)(Mt,{label:`Event`,value:l,onChange:u,options:[{value:J,label:`All events`},...U.options.map(e=>({value:e,label:e}))]}):null]}),d.length===0?(0,K.jsx)(q,{text:`No rows match these filters.`}):(0,K.jsx)(jt,{records:d,all:i,timeZone:n,onRetried:()=>void o(),readOnly:r})]}):(0,K.jsx)(q,{text:`Loading execution log…`})})}function Pt({automationId:e,automationName:t,timeZone:n,showName:r=!1,readOnly:i=!1}){let{records:a,error:o,refresh:s}=kt(e),c=`Recent activity${r&&t?` · ${t}`:``}`;return!o&&a&&a.length===0?(0,K.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,K.jsx)(`h3`,{className:`font-medium text-foreground`,children:c}),(0,K.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,K.jsx)(`p`,{children:`Nothing has run yet.`})]}):(0,K.jsxs)(`section`,{"data-slot":`automation-inline-log`,className:`min-w-0 border-t border-border pt-2.5`,children:[(0,K.jsx)(`h3`,{className:`mb-1.5 text-xs font-medium text-muted-foreground`,children:c}),o&&!a?(0,K.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[(0,K.jsx)(q,{text:o}),(0,K.jsx)(M,{variant:`outline`,onClick:()=>void s(),children:`Retry`})]}):a?(0,K.jsx)(jt,{records:a.slice(0,5),all:a,timeZone:n,onRetried:()=>void s(),readOnly:i}):(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Loading activity…`})]})}function Ft({automation:e,timeZone:t,onDeleted:n}){let r=e.archived,i=e.schedule,a=i?dt(i):null,[o,s]=(0,H.useState)(!1),[c,l]=(0,H.useState)(!1),[u,d]=(0,H.useState)(``),f=(0,H.useRef)(null),p=(0,H.useRef)(null),m=(0,H.useRef)(null);(0,H.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 b(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,K.jsx)(je,{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,K.jsxs)(`div`,{className:`grid min-w-0 gap-5`,children:[(0,K.jsxs)(`section`,{className:`min-w-0 rounded-xl border border-card-edge bg-card shadow-card p-4`,children:[(0,K.jsxs)(`p`,{className:`text-sm break-words`,children:[(0,K.jsx)(`span`,{children:r.outcome===`launched`?`Started its task.`:`Cancelled — no task was started.`}),r.runId?(0,K.jsxs)(K.Fragment,{children:[` · `,(0,K.jsx)(R,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${r.runId}`,children:`Open task`})]}):null]}),(0,K.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Archived ${V(r.at,t)} (${t}).`}),a&&i?.timeZone?(0,K.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Was due ${a.date} ${a.time} (${i.timeZone}).`}):null]}),(0,K.jsxs)(`section`,{"aria-labelledby":`archived-inputs`,className:`min-w-0 rounded-xl border border-card-edge bg-card shadow-card p-4`,children:[(0,K.jsx)(`h2`,{id:`archived-inputs`,className:`mb-3 text-[15px] font-medium`,children:`What it ran with`}),(0,K.jsxs)(`dl`,{className:`grid gap-3 text-sm`,children:[(0,K.jsxs)(`div`,{className:`grid gap-1`,children:[(0,K.jsx)(`dt`,{className:`text-muted-foreground`,children:`Prompt`}),(0,K.jsx)(`dd`,{className:`break-words whitespace-pre-wrap`,children:e.task.prompt})]}),g.filter(([,e])=>e).map(([e,t])=>(0,K.jsxs)(`div`,{className:`grid gap-1`,children:[(0,K.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,K.jsx)(`dd`,{className:`break-words`,children:t})]},e))]})]}),(0,K.jsxs)(`section`,{className:`min-w-0`,children:[(0,K.jsx)(Pt,{automationId:e.id,automationName:e.name,timeZone:t,readOnly:!0}),(0,K.jsx)(M,{variant:`outline`,asChild:!0,className:`mt-3`,children:(0,K.jsx)(R,{to:`/automations/${e.id}/log`,children:`Execution log`})})]}),(0,K.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[o?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`text-sm break-words`,children:`Delete “${e.name}”? Its record and log are removed; the task stays.`}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(M,{variant:`danger-ghost`,"data-action":`automation-delete-confirm`,disabled:c,onClick:()=>void h(),children:`Delete schedule`}),(0,K.jsx)(M,{ref:p,variant:`outline`,disabled:c,onClick:()=>{m.current=`delete`,s(!1)},children:`Keep`})]})]}):(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(M,{ref:f,variant:`outline`,"data-action":`automation-delete`,onClick:()=>{m.current=`keep`,s(!0)},children:`Delete`}),(0,K.jsx)(M,{variant:`outline`,asChild:!0,children:(0,K.jsx)(R,{to:`/automations`,children:`Back to automations`})})]}),u?(0,K.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:u}):null]})]})})}var It=O([`pull_request.opened`,`issue.opened`,`issue.labeled`,`issue.unlabeled`]),Y=T(D().trim().min(1).max(200)).max(100).optional(),Lt=C({includeExisting:E().optional(),requireCurrentLabels:E().optional(),authors:Y,assignees:Y,allLabels:Y,anyLabels:Y,excludeLabels:Y,changedLabels:Y,lookbackDays:k().int().min(1).max(90).default(7),maxRecords:k().int().min(1).max(100).default(25)}).passthrough(),Rt=C({prompt:D().min(1).max(1e5),workflow:D().trim().min(1).max(200).optional(),steps:T(u).min(1).max(100).optional(),runner:p.optional(),model:D().trim().min(1).max(200).optional(),effort:D().trim().min(1).max(32).optional(),variants:oe([w(1),w(2),w(3)]).optional(),worktree:E().optional(),autonomous:E().optional(),...x,...te,systemPrompt:D().max(1e5).optional()}).passthrough().refine(e=>!(e.workflow&&e.steps),{message:`task selects either a named workflow or inline steps, not both`}),zt=new Set(Object.keys(Rt.shape).filter(e=>e!==`variants`));function Bt(e){return Object.fromEntries(Object.entries(e).filter(([e])=>zt.has(e)))}le(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:D().min(1).max(100),revision:k().int().positive(),name:D().trim().min(1).max(200),description:D().max(2e3).optional(),enabled:E().default(!1),kind:gt.default(`github`),events:T(It).min(1).max(4).optional(),intervalSeconds:k().int().min(60).max(86400).optional(),filters:Lt.optional(),schedule:et.passthrough().optional(),task:Rt,archived:C({at:D().datetime(),outcome:O([`launched`,`cancelled`]),runId:D().optional(),receiptId:D().optional(),trigger:O([`schedule`,`late`,`manual`,`retry`]).optional()}).passthrough().optional(),createdAt:D().datetime(),updatedAt:D().datetime()}).passthrough().superRefine((e,t)=>{if(e.kind===`schedule`){e.schedule||t.addIssue({code:S.custom,path:[`schedule`],message:`a scheduled automation needs a schedule`});return}e.events?.length||t.addIssue({code:S.custom,path:[`events`],message:`a GitHub automation needs at least one event`}),e.intervalSeconds===void 0&&t.addIssue({code:S.custom,path:[`intervalSeconds`],message:`a GitHub automation needs a poll interval`}),e.filters||t.addIssue({code:S.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:S.custom,path:[`filters`,`changedLabels`],message:`changedLabels is required for issue label events`})})),C({version:w(1).default(1),automations:T(ce()).default([]),tombstones:se(D(),D().datetime()).optional()}).passthrough();var X=C({timestamp:D().datetime(),tieBreaker:D().optional()}).passthrough(),Vt=yt.extend({cursor:X.optional()}),Ht=C({revision:k().int().positive().optional(),baselineAt:D().datetime().optional(),armedAt:D().datetime().optional(),historyScan:Vt.optional(),cursor:X.optional(),frozenHighWatermark:X.extend({tieBreaker:D()}).optional(),backlogAfter:X.extend({tieBreaker:D()}).optional(),nextCheckAt:D().datetime().optional(),lastSuccessAt:D().datetime().optional(),nextRunAt:D().datetime().optional(),lastRunAt:D().datetime().optional(),etags:se(D(),D()).optional(),backoffUntil:D().datetime().optional(),consecutiveFailures:k().int().nonnegative().optional(),...bt,onceOutcome:O([`failed`,`missed`]).optional()}).passthrough();C({version:w(1).default(1),states:se(D(),Ht).default({})}).passthrough(),C({receiptId:D().min(1),receiptKey:D().min(1),eventId:D().min(1),automationId:D().min(1),revision:k().int().positive(),status:O([`reserved`,`launched`,`launch-error`,`released`]),runId:D().optional(),observedAt:D().datetime(),updatedAt:D().datetime(),error:D().max(2e3).optional(),occurrenceAt:D().datetime().optional(),candidate:C({eventId:D(),event:It,timestamp:D().datetime(),tieBreaker:D(),repo:D(),nodeId:D(),number:k().int().positive(),title:D().max(500),url:D().url(),author:D().max(200),assignees:T(D().max(200)).max(100),labels:T(D().max(200)).max(100),changedLabel:D().max(200).optional()}).passthrough().optional()}).passthrough();var Ut=O([`launched`,`no-match`,`duplicate`,`rate-limited`,`error`,`baseline`,`preview`,`skipped`,`manual`,`catch-up`,`failed`,`missed`]);C({seq:k().int().positive(),ts:D().datetime(),automationId:D().min(1),revision:k().int().positive(),event:It.optional(),result:Ut,reason:D().max(2e3).optional(),durationMs:k().int().nonnegative().optional(),receiptId:D().optional(),runId:D().optional(),githubNumber:k().int().positive().optional(),githubTitle:D().max(500).optional(),githubUrl:D().url().optional(),rateLimit:C({bucket:O([`core`,`search`]),remaining:k().int().nonnegative().optional(),resetAt:D().datetime().optional()}).passthrough().optional()}).passthrough();var Wt=`quick-task`;function Gt(e={}){let{prompt:t,workflow:n,runner:r,model:i,autonomous:a,archiveWhenDone:o,autoMergePr:s,allowWorkers:c,allowMessaging:l,...u}=Bt(e.task??{prompt:``}),d=e.task===void 0;return{name:e.name??``,description:e.description??``,kind:e.kind??`schedule`,schedule:pt(e.schedule??{type:`daily`}),events:e.events??[U.options[0]],intervalSeconds:e.intervalSeconds??300,filters:e.filters??{lookbackDays:7,maxRecords:25},prompt:t,...n===void 0?d?{workflow:Wt}:{}:{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 Kt(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 qt(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 Jt(e){return{name:e.name.trim(),...e.description.trim()?{description:e.description.trim()}:{},kind:e.kind,...e.kind===`schedule`?{schedule:Kt(e.schedule)}:{events:e.events,intervalSeconds:e.intervalSeconds,filters:e.filters},task:qt(e)}}function Yt(e){return{...Jt(e),enable:e.enabled}}function Xt(e,t){return{...Jt(e),task:{...qt(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 Zt=new Set([`prompt`,`workflow`,`runner`,`model`,`autonomous`,`worktree`,`archiveWhenDone`,`autoMergePr`,`allowWorkers`,`allowMessaging`]),Qt=new Set([`anyLabels`,`authors`,`changedLabels`]);function $t(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=>!Zt.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||Qt.has(e)&&Array.isArray(t)&&t.length>0)}function en(e){return e%3600==0?`${e/3600}h`:e%60==0?`${e/60}m`:`${e}s`}function tn(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 nn(e){let t=[`${We()} 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`,tn(e.schedule.latestStartMinutes)));else if(e.kind===`schedule`)t.push(Q(`cron`,ot(e.schedule)));else{t.push(Q(`on`,e.events.join(`,`)),`--every ${en(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(...rn(e.task)),e.enable===!0&&t.push(`--enable`),t.push(Q(`prompt`,e.task.prompt)),t.join(` `)}function rn(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 an(e,t){let n=Yt(e),r=$t(n)?nn(n):`${We()} 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 on(e){let t=[],n=!1;for(let r of sn(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
2
  `)}function sn(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 cn({draft:e,saveLabel:t,editing:n}){let r=Oe(),i=l(),a=window.location.origin,o=(0,H.useMemo)(()=>{let t=an(e);return r?`HSQ_COCKPIT_URL=${Z(a)} HSQ_PROJECT_ID=${Z(r)} ${t}`:t},[e,a,r]),s=(0,H.useMemo)(()=>on(o),[o]),[c,u]=(0,H.useState)(`idle`),[d,f]=(0,H.useState)(!1),p=(0,H.useId)(),m=(0,H.useRef)(void 0);if((0,H.useEffect)(()=>()=>clearTimeout(m.current),[]),(0,H.useEffect)(()=>u(`idle`),[o]),i)return(0,K.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,K.jsx)(`h2`,{id:`copy-as-cli-heading`,className:`text-[13px] font-medium text-muted-foreground`,children:`Copy as CLI`}),(0,K.jsx)(`p`,{"data-slot":`copy-as-cli-remote-note`,className:`mbs-2 text-xs break-words text-muted-foreground`,children:`Run automation CLI commands on that machine.`})]});let h=async()=>{clearTimeout(m.current);try{await navigator.clipboard.writeText(s),u(`copied`),m.current=setTimeout(()=>u(`idle`),1600)}catch{u(`failed`)}};return(0,K.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,K.jsxs)(`div`,{className:`flex min-h-8 min-w-0 flex-nowrap items-center justify-between gap-x-2`,children:[(0,K.jsx)(`h2`,{id:`copy-as-cli-heading`,className:`shrink-0 text-[13px] font-medium text-muted-foreground`,children:`Copy as CLI`}),(0,K.jsxs)(M,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`copy-as-cli-toggle`,"aria-expanded":d,"aria-controls":p,"aria-label":d?`Hide command`:`Show command`,className:`min-w-0 shrink gap-1 px-1.5 text-[12px] font-medium`,onClick:()=>f(e=>!e),children:[(0,K.jsx)(`span`,{className:`truncate`,children:d?`Hide`:`Show`}),(0,K.jsx)(xe,{"aria-hidden":`true`,className:j(`size-3.5 transition-transform`,d&&`rotate-180`)})]}),(0,K.jsxs)(M,{type:`button`,variant:`outline`,size:`sm`,className:`ms-auto gap-1.5 px-2 text-[12px] font-medium`,onClick:()=>void h(),children:[c===`copied`?(0,K.jsx)(Se,{"aria-hidden":`true`,className:`size-3.5`}):(0,K.jsx)(Ue,{"aria-hidden":`true`,className:`size-3.5`}),c===`copied`?`Copied`:`Copy`]})]}),(0,K.jsx)(`div`,{id:p,hidden:!d,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,K.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:s})}),(0,K.jsx)(`p`,{role:`status`,className:`mbs-2 text-xs break-words text-muted-foreground`,children:c===`failed`?`Could not copy — select the line and copy it by hand.`:(0,K.jsxs)(K.Fragment,{children:[`The definition ${t} would ${n?`save`:`create`}.`,` `,(0,K.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-px font-mono text-xs whitespace-nowrap text-foreground [word-spacing:-0.2em]`,children:`${We()} automation schema`}),` prints its shape.`]})})]})}function ln({pressed:e,onClick:t,disabled:n,children:r}){return(0,K.jsx)(`button`,{type:`button`,"aria-pressed":e,disabled:n,onClick:t,className:j(`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:r})}var un={"pull_request.opened":`a pull request opens`,"issue.opened":`an issue opens`,"issue.labeled":`an issue is labeled`,"issue.unlabeled":`an issue is unlabeled`},dn={"pull_request.opened":`Pull request opened`,"issue.opened":`Issue opened`,"issue.labeled":`Issue labeled`,"issue.unlabeled":`Issue unlabeled`};function fn(e){let t=e.map(e=>un[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 pn=U.options,mn=[{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`}],hn=[{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.`}],gn=e=>(e??[]).join(`, `),_n=e=>e.split(`,`).map(e=>e.trim()).filter(Boolean);function vn(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 yn(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`}. ${vn(e.filters.includeExisting)}`}function bn({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=_n(r),{[n]:a,...o}=e.filters;t({filters:i.length?{...o,[n]:i}:o})},o=mn.some(t=>t.seconds===e.intervalSeconds)?mn:[...mn,{seconds:e.intervalSeconds,label:`${Math.round(e.intervalSeconds/60)} minutes`}].sort((e,t)=>e.seconds-t.seconds);return(0,K.jsxs)(`div`,{className:`grid gap-4`,children:[n?(0,K.jsx)(`p`,{className:`text-xs text-pending-strong`,children:`GitHub unavailable · ${n}`}):null,(0,K.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:pn.map(t=>(0,K.jsx)(ln,{pressed:e.events.includes(t),onClick:()=>r(t),children:dn[t]},t))}),(0,K.jsxs)(`div`,{className:`grid gap-2`,children:[(0,K.jsx)(A,{htmlFor:`automation-interval`,children:`Check every`}),(0,K.jsxs)(L,{value:String(e.intervalSeconds),onValueChange:e=>t({intervalSeconds:Number(e)}),children:[(0,K.jsx)(P,{id:`automation-interval`,className:`w-full sm:w-48`,"aria-label":`Check every`,children:(0,K.jsx)(N,{})}),(0,K.jsx)(F,{children:o.map(e=>(0,K.jsx)(I,{value:String(e.seconds),children:e.label},e.seconds))})]})]}),(0,K.jsxs)(`div`,{className:`grid gap-2`,children:[(0,K.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm`,children:[(0,K.jsx)(Ee,{"aria-label":`Include existing items`,"aria-describedby":`automation-history-hint`,checked:e.filters.includeExisting??!1,onCheckedChange:e=>i({includeExisting:e})}),(0,K.jsx)(`span`,{children:`Include existing items`})]}),(0,K.jsx)(`p`,{id:`automation-history-hint`,className:`text-xs text-muted-foreground`,children:vn(e.filters.includeExisting)})]}),(0,K.jsxs)(Te,{children:[(0,K.jsxs)(we,{className:`group flex min-h-11 items-center gap-2 text-sm font-medium`,children:[`Filters`,(0,K.jsx)(xe,{"aria-hidden":`true`,className:`size-4 text-soft-foreground transition-transform motion-reduce:transition-none group-data-[state=open]:rotate-180`})]}),(0,K.jsx)(Ce,{children:(0,K.jsxs)(`div`,{className:`grid gap-4 pt-2 sm:grid-cols-2`,children:[hn.map(t=>(0,K.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,K.jsx)(A,{htmlFor:`automation-filter-${t.key}`,children:t.label}),(0,K.jsx)(B,{id:`automation-filter-${t.key}`,className:`border-border`,placeholder:`comma separated`,value:gn(e.filters[t.key]),onChange:e=>a(t.key,e.target.value)}),t.hint?(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.hint}):null]},t.key)),(0,K.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,K.jsx)(A,{htmlFor:`automation-filter-lookback`,children:`Look back (days)`}),(0,K.jsx)(B,{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,K.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,K.jsx)(A,{htmlFor:`automation-filter-max`,children:`Max records per check`}),(0,K.jsx)(B,{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 xn=e=>String(e).padStart(2,`0`);function Sn({label:e,value:t,max:n,onCommit:r}){let[i,a]=(0,H.useState)(xn(t)),o=(0,H.useRef)(null),s=!(/^\d{1,2}$/.test(i)&&Number(i)===t),c=`${e} must be 00–${xn(n)}.`,l=(0,H.useId)();return(0,H.useEffect)(()=>{o.current?.setCustomValidity(s?c:``)},[s,c]),(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(B,{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(xn(t))}),s?(0,K.jsx)(`p`,{id:l,className:`order-last basis-full text-xs text-destructive`,children:c}):null]})}var Cn=[{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`}],wn=`none`,Tn=e=>String(e).padStart(2,`0`);function En(e,t=Date.now()){let n=mt(t,e)??mt(t,`UTC`),r=new Date(Date.UTC(n.year,n.month-1,n.day+1));return`${r.getUTCFullYear()}-${Tn(r.getUTCMonth()+1)}-${Tn(r.getUTCDate())}T09:00`}function Dn(){let e=typeof Intl.supportedValuesOf==`function`?Intl.supportedValuesOf(`timeZone`):[];return e.includes(`UTC`)?e:[`UTC`,...e]}function On({value:e,stored:t,onChange:n}){let r=t=>n({...e,...t}),i=e.at?st(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${Tn(t)}:${Tn(n)}`}),l=(0,H.useRef)(null),u=(0,H.useId)(),d=nt(e),f=!(t?.type===`once`&&t.at===e.at&&t.timeZone===e.timeZone)&&d!==null&&d<=Date.now();(0,H.useEffect)(()=>{l.current?.setCustomValidity(f?$e:``)},[f]);let p=dt(e);return(0,K.jsxs)(`div`,{className:`grid gap-4`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-end gap-x-4 gap-y-3`,children:[(0,K.jsxs)(`div`,{className:`grid gap-2`,children:[(0,K.jsx)(A,{htmlFor:`automation-once-date`,children:`Date`}),(0,K.jsx)(B,{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,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`at`}),(0,K.jsx)(Sn,{label:`Hour`,value:o,max:23,onCommit:e=>c(a,e,s)}),(0,K.jsx)(`span`,{"aria-hidden":`true`,children:`:`}),(0,K.jsx)(Sn,{label:`Minute`,value:s,max:59,onCommit:e=>c(a,o,e)})]})]}),f?(0,K.jsx)(`p`,{id:u,className:`text-xs text-destructive`,children:$e}):null,(0,K.jsx)(An,{value:e.timeZone??``,onCommit:e=>r({timeZone:e})}),(0,K.jsx)(jn,{value:e.latestStartMinutes,onChange:t=>n(kn(e,t))}),p?(0,K.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 kn(e,t){let{latestStartMinutes:n,...r}=e;return t===void 0?r:{...r,latestStartMinutes:t}}function An({value:e,onCommit:t}){let[n,r]=(0,H.useState)(e),i=(0,H.useRef)(null),a=(0,H.useId)(),o=(0,H.useId)(),[s]=(0,H.useState)(Dn),c=n!==e||!Qe(n),l=rt(n);return(0,H.useEffect)(()=>{i.current?.setCustomValidity(c?l:``)},[c,l]),(0,K.jsxs)(`div`,{className:`grid gap-2`,children:[(0,K.jsx)(A,{htmlFor:`automation-once-zone`,children:`Time zone`}),(0,K.jsx)(B,{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,K.jsx)(`datalist`,{id:a,children:s.map(e=>(0,K.jsx)(`option`,{value:e},e))}),c?(0,K.jsx)(`p`,{id:o,className:`text-xs break-words text-destructive`,children:l}):null]})}function jn({value:e,onChange:t}){let n=Cn.some(t=>t.minutes===e)||e===void 0?Cn:[...Cn,{minutes:e,label:`${e} minutes`}];return(0,K.jsxs)(`div`,{className:`grid gap-2`,children:[(0,K.jsx)(A,{htmlFor:`automation-once-latest`,children:`Latest start`}),(0,K.jsxs)(L,{value:e===void 0?wn:String(e),onValueChange:e=>t(e===wn?void 0:Number(e)),children:[(0,K.jsx)(P,{id:`automation-once-latest`,className:`w-full sm:w-48`,"aria-label":`Latest start`,children:(0,K.jsx)(N,{})}),(0,K.jsx)(F,{children:n.map(e=>(0,K.jsx)(I,{value:e.minutes===void 0?wn:String(e.minutes),children:e.label},e.label))})]}),(0,K.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 Mn=[{type:`daily`,label:`Every day`},{type:`weekdays`,label:`Weekdays`},{type:`weekly`,label:`Weekly`},{type:`hours`,label:`Every N hours`},{type:`once`,label:`Once`}];function Nn({value:e,stored:t,onChange:n,timeZone:r}){let i=t=>n({...e,...t}),a=t=>i(t===`once`?{type:t,at:e.at??En(r),timeZone:e.timeZone??r}:{type:t});return(0,K.jsxs)(`div`,{className:`grid gap-4`,children:[(0,K.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:Mn.map(t=>(0,K.jsx)(ln,{pressed:e.type===t.type,onClick:()=>a(t.type),children:t.label},t.type))}),e.type===`once`?(0,K.jsx)(On,{value:e,stored:t,onChange:n}):null,e.type===`weekly`?(0,K.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:ft.map((t,n)=>(0,K.jsx)(ln,{pressed:e.day===n+1,onClick:()=>i({day:n+1}),children:t},t))}):null,e.type===`once`?null:e.type===`hours`?(0,K.jsxs)(`div`,{className:`grid gap-2`,children:[(0,K.jsx)(A,{htmlFor:`automation-every`,children:`Run every`}),(0,K.jsxs)(L,{value:String(e.every),onValueChange:e=>i({every:Number(e)}),children:[(0,K.jsx)(P,{id:`automation-every`,className:`w-full sm:w-48`,"aria-label":`Run every`,children:(0,K.jsx)(N,{})}),(0,K.jsx)(F,{children:lt.map(e=>(0,K.jsx)(I,{value:String(e),children:e===1?`hour`:`${e} hours`},e))})]}),(0,K.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,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`at`}),(0,K.jsx)(Sn,{label:`Hour`,value:e.hour,max:23,onCommit:e=>i({hour:e})}),(0,K.jsx)(`span`,{"aria-hidden":`true`,children:`:`}),(0,K.jsx)(Sn,{label:`Minute`,value:e.minute,max:59,onCommit:e=>i({minute:e})}),(0,K.jsx)(`span`,{className:`text-sm break-all text-muted-foreground`,children:r})]}),e.type===`once`?null:(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Cron: `,(0,K.jsx)(`code`,{className:`font-mono text-foreground`,children:ot(e)})]})]})}var Pn=40*864e5,Fn=5;function In({schedule:e,timeZone:t,now:n=Date.now()}){if(e.type===`once`)return(0,K.jsx)(Ln,{schedule:e,now:n});let r=tt(e,n+1,n+Pn,t,Fn);return(0,K.jsxs)(`section`,{"aria-labelledby":`next-runs-heading`,"data-slot":`next-runs`,className:`min-w-0 rounded-xl border bg-card p-5`,children:[(0,K.jsx)(`h2`,{id:`next-runs-heading`,className:`mb-2 text-base font-semibold`,children:`Next 5 runs`}),r.length===0?(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No runs in the next 40 days.`}):(0,K.jsx)(`ol`,{"aria-label":`Next 5 runs`,className:`grid divide-y divide-border text-sm`,children:r.map((e,r)=>(0,K.jsxs)(`li`,{className:`flex min-h-10 items-center justify-between gap-3 py-1.5`,children:[(0,K.jsx)(`span`,{className:r===0?`font-semibold tabular-nums text-foreground`:`font-medium tabular-nums`,children:V(new Date(e).toISOString(),t)}),(0,K.jsx)(`span`,{className:r===0?`font-medium text-accent-text`:`text-muted-foreground`,children:at(n,e)})]},e))}),(0,K.jsxs)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:[`Times are in `,t,`, the zone this Squawk runs in.`]})]})}function Ln({schedule:e,now:t}){let n=nt(e),r=dt(e);return(0,K.jsxs)(`section`,{"aria-labelledby":`next-runs-heading`,"data-slot":`next-runs`,className:`min-w-0 rounded-xl border bg-card p-5`,children:[(0,K.jsx)(`h2`,{id:`next-runs-heading`,className:`mb-3 text-base font-semibold`,children:`Runs once`}),n===null||!r?(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Pick a date, a time and a time zone.`}):(0,K.jsxs)(`p`,{className:`flex flex-wrap items-baseline justify-between gap-x-3 text-sm`,children:[(0,K.jsx)(`span`,{className:`font-medium tabular-nums`,children:`${r.date} ${r.time}`}),n>t?(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:at(t,n)}):null]}),r?.note?(0,K.jsx)(`p`,{className:`mt-2 text-sm break-words`,children:r.note}):null,n!==null&&n<=t?(0,K.jsx)(`p`,{className:`mt-2 text-sm text-destructive`,children:`The due time has passed.`}):null,(0,K.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 Rn={schedule:`On a schedule`,github:`When GitHub changes`};function zn(e){return/time zone|due time/i.test(e)?`when`:/autonomous/i.test(e)?`execution`:/placeholder|prompt|workflow|runner|model|task/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 Bn({title:e,icon:t,hideLegend:n=!1,failure:r,section:i,children:a}){let o=(0,H.useId)();return(0,K.jsxs)(`section`,{role:n?void 0:`group`,"aria-labelledby":n?void 0:o,className:`grid min-w-0 gap-3.5 rounded-xl border border-card-edge bg-card shadow-card p-5`,children:[n?null:t?(0,K.jsxs)(`h2`,{id:o,className:`flex items-center gap-2 text-base font-semibold text-foreground`,children:[t,e]}):(0,K.jsx)(`h2`,{id:o,className:`text-sm font-semibold text-foreground`,children:e}),a,r?.section===i&&!r.conflict?(0,K.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:r.message}):null]})}function Vn({draft:e,patch:t,forge:n,automation:r}){return(0,K.jsx)(K.Fragment,{children:r?(0,K.jsxs)(`p`,{className:`text-sm`,children:[(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:`Trigger · `}),Rn[e.kind]]}):(0,K.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[(0,K.jsx)(Xe,{slot:`automation-kind`,label:`Trigger`,size:`touch`,value:e.kind,onChange:e=>t({kind:e}),options:[{value:`schedule`,label:Rn.schedule},{value:`github`,label:Rn.github,disabled:!n.available,...n.available?{}:{title:n.reason??`GitHub is unavailable`}}]}),n.available?null:(0,K.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:`GitHub unavailable · ${n.reason??`no GitHub access`}`})]})})}function Hn({draft:e,patch:t,forge:n,timeZone:r,automation:i}){return e.kind===`schedule`?(0,K.jsx)(Nn,{value:e.schedule,stored:i?.schedule,onChange:e=>t({schedule:e}),timeZone:r}):(0,K.jsx)(bn,{draft:e,onChange:t,...n.available?{}:{disabledReason:n.reason??`no GitHub access`}})}function Un({draft:e,patch:t}){let n=e.kind===`schedule`?[`date`,`time`,`project`,`automation`]:[`github.kind`,`github.number`,`github.title`,`github.url`,`github.author`,`github.assignees`,`github.labels`,`github.event`],r=[...new Set([...e.prompt.matchAll(/\{\{([^{}]+)\}\}/g)].map(e=>e[1]))].filter(e=>!n.includes(e));return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,K.jsx)(A,{htmlFor:`automation-prompt`,children:`Prompt`}),(0,K.jsx)(Ze,{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,K.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:e.kind===`schedule`?(0,K.jsxs)(K.Fragment,{children:[`Available: `,`{{date}}`,` `,`{{time}}`,` `,`{{project}}`,` `,`{{automation}}`,`. A run-context block is appended automatically.`]}):(0,K.jsxs)(K.Fragment,{children:[`Available: `,`{{github.number}}`,` `,`{{github.title}}`,` `,`{{github.url}}`,` `,`{{github.labels}}`,`. GitHub content is appended as untrusted context.`]})})]}),r.length?(0,K.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:`Unavailable for this trigger: ${r.map(e=>`{{${e}}}`).join(`, `)}`}):null,(0,K.jsx)(Zn,{draft:e,patch:t})]})}function Wn({label:e,help:t,checked:n,onChange:r}){let i=(0,H.useId)();return(0,K.jsxs)(`label`,{htmlFor:i,className:`completion-control flex min-h-11 min-w-0 items-center justify-between gap-3 rounded-md text-sm`,children:[(0,K.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,K.jsx)(`span`,{id:`${i}-label`,children:e}),(0,K.jsx)(`span`,{id:`${i}-help`,className:`completion-control-help`,children:t})]}),(0,K.jsx)(Ee,{id:i,className:`completion-switch shrink-0`,checked:n,"aria-labelledby":`${i}-label`,"aria-describedby":`${i}-help`,onCheckedChange:r})]})}function Gn({draft:e,patch:t,saving:n,automation:r}){let i=e.kind===`schedule`,a=r?`Enabled`:`Enable after saving`,o=i&&e.schedule.type===`once`?`It runs once at the time set under When, then moves to Archived with its task.`:i?`The first run is the next occurrence in Next 5 runs.`:vn(e.filters.includeExisting);return(0,K.jsxs)(K.Fragment,{children:[(0,K.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,K.jsxs)(`div`,{"data-embedded":``,className:`grid min-w-0`,children:[(0,K.jsx)(Wn,{label:`Autonomous`,help:`Runs without waiting for answers.`,checked:e.autonomous,onChange:e=>t({autonomous:e})}),(0,K.jsx)(Ve,{embedded:!0,archiveWhenDone:e.archiveWhenDone,autoMergePr:e.autoMergePr,onChange:t,disabled:n}),(0,K.jsx)(Be,{embedded:!0,allowWorkers:e.allowWorkers,allowMessaging:e.allowMessaging,onChange:t,disabled:n}),(0,K.jsx)(Wn,{label:a,help:o,checked:e.enabled,onChange:e=>t({enabled:e})})]}),r?(0,K.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:`These settings apply to future tasks. Existing tasks keep their settings.`}):null]})}function Kn({automation:e,forge:t,timeZone:n,onSaved:r,onReload:i}){let[a,o]=(0,H.useState)(()=>Gt(e)),[s,c]=(0,H.useState)(e?.revision),[l,u]=(0,H.useState)(),[f,p]=(0,H.useState)(!1),h=e=>o(t=>({...t,...e})),_=async t=>{if(t.preventDefault(),f)return;let n=t.currentTarget;if(n instanceof HTMLFormElement&&!n.checkValidity()){n.reportValidity();return}p(!0),u(void 0);let i=`save`;try{if(e&&s!==void 0){let{automation:t}=await g(e.id,Xt({...a,enabled:e.enabled},s));c(t.revision),a.enabled!==e.enabled&&(i=`enable`,await m(e.id,a.enabled))}else await y(Yt(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`?`execution`:zn(n),message:n})}finally{p(!1)}},v=(0,H.useId)(),b=(0,H.useId)(),x=a.kind===`schedule`;return(0,K.jsx)(Ne,{route:`automations`,density:a.name.trim()===``&&a.prompt.trim()===``?`sparse`:`full`,header:Xn({automation:e,draft:a,formId:v,saveHintId:b,saving:f}),children:(0,K.jsxs)(`form`,{id:v,className:`automation-editor grid min-w-0 gap-4 md:grid-cols-[minmax(0,1fr)_320px] md:grid-rows-[auto_1fr] md:items-start`,onSubmit:_,children:[(0,K.jsxs)(`div`,{className:`grid min-w-0 gap-3.5`,children:[(0,K.jsx)(Bn,{title:`Name`,hideLegend:!0,section:`name`,failure:l,children:(0,K.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,K.jsx)(A,{htmlFor:`automation-name`,className:`text-sm font-semibold text-foreground`,children:`Name`}),(0,K.jsx)(B,{id:`automation-name`,className:`border-border`,value:a.name,placeholder:`Daily dependency audit`,onChange:e=>h({name:e.target.value}),required:!0})]})}),(0,K.jsxs)(Bn,{title:`When`,section:`when`,failure:l,children:[(0,K.jsx)(Vn,{draft:a,patch:h,forge:t,automation:e}),(0,K.jsx)(Hn,{draft:a,patch:h,forge:t,timeZone:n,automation:e})]}),(0,K.jsx)(Bn,{title:`What to run`,section:`run`,failure:l,children:(0,K.jsx)(Un,{draft:a,patch:h})})]}),(0,K.jsxs)(`aside`,{className:`grid min-w-0 max-w-full grid-cols-[minmax(0,1fr)] gap-4 md:sticky md:top-4 md:col-start-2 md:row-span-2 md:row-start-1`,children:[(0,K.jsx)(Bn,{title:`Execution settings`,icon:(0,K.jsx)(ye,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),section:`execution`,failure:l,children:(0,K.jsx)(Gn,{draft:a,patch:h,saving:f,automation:e})}),x?(0,K.jsx)(In,{schedule:a.schedule,timeZone:n}):(0,K.jsxs)(`section`,{className:`min-w-0 rounded-xl border border-card-edge bg-card shadow-card p-5`,children:[(0,K.jsx)(`h2`,{className:`mb-2 text-base font-semibold`,children:`How it polls`}),(0,K.jsx)(`p`,{className:`text-sm break-words text-muted-foreground`,children:yn(a)})]}),(0,K.jsx)(cn,{draft:a,saveLabel:Jn(e,a),editing:e!==void 0})]}),l?.section===`form`||e?(0,K.jsxs)(`div`,{className:`grid min-w-0 gap-3.5 md:col-start-1`,children:[l?.section===`form`?(0,K.jsxs)(`div`,{role:`alert`,className:`flex flex-wrap items-center gap-3 text-sm text-destructive`,children:[(0,K.jsx)(`span`,{className:`break-words`,children:l.message}),l.conflict&&i?(0,K.jsx)(M,{type:`button`,variant:`outline`,onClick:i,children:`Reload`}):null]}):null,e?(0,K.jsx)(qn,{automation:e,onDeleted:r}):null]}):null]})})}function qn({automation:e,onDeleted:t}){let[n,r]=(0,H.useState)(!1),[i,a]=(0,H.useState)(!1),[o,s]=(0,H.useState)(``),c=async()=>{if(!i){a(!0),s(``);try{await b(e.id),t()}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(!1)}}};return(0,K.jsxs)(`div`,{className:`grid justify-items-start gap-2 border-t pt-4`,children:[n?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`text-sm break-words`,children:`Delete “${e.name}”? It will stop running and cannot be restored.`}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(M,{type:`button`,variant:`danger-ghost`,"data-action":`automation-delete-confirm`,disabled:i,onClick:()=>void c(),children:`Delete automation`}),(0,K.jsx)(M,{type:`button`,variant:`outline`,disabled:i,onClick:()=>{r(!1),s(``)},children:`Keep`})]})]}):(0,K.jsx)(M,{type:`button`,variant:`outline`,"data-action":`automation-delete`,onClick:()=>r(!0),children:`Delete`}),o?(0,K.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:o}):null]})}function Jn(e,t){return e?`Save changes`:t.enabled?`Save and enable`:`Save paused`}function Yn(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 Xn({automation:e,draft:t,formId:n,saveHintId:r,saving:i}){let a=t.name.trim()?t.prompt.trim()?``:`Prompt`:`Name`,o=Yn(t),s=Jn(e,t);return{title:e?`Edit automation`:`New automation`,subtitle:`Define when it runs and the ordinary task it launches.`,status:(0,K.jsx)(`p`,{id:r,"data-slot":`automation-save-hint`,className:`min-h-[1lh] text-xs text-muted-foreground`,children:o}),secondaryActions:(0,K.jsx)(ke,{type:`button`,variant:`outline`,asChild:!0,children:(0,K.jsx)(R,{to:`/automations`,children:`Cancel`})}),primaryAction:(0,K.jsx)(ke,{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 Zn({draft:e,patch:t}){let n=o(),l=Pe(),{runners:u,signedOut:d}=l.runnersOn(e=>l.repoAccount?.[e]),f=a(),p=i(),{runner:m,ready:h}=c(e.runner??f.data?.defaultRunner??`claude`),g=r(m,h,l.repoAccount?.[m]),_=[...new Set([...(n.data?.workflows??[]).map(e=>e.name),...e.workflow?[e.workflow]:[]])],v=[...new Set([...u,...e.runner?[e.runner]:[]])],y=He(m,p.data,g.data,[e.model]),b=y.find(t=>t.id===(e.model??``))?.label??e.model??`Runner default`,x=e=>(0,K.jsx)(e,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`});return(0,K.jsx)(Ke,{children:(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(Ge,{slot:`automation-workflow-pill`,icon:x(_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:_.map(e=>({value:e,label:e})),onPick:e=>t({workflow:e})}),(0,K.jsx)(Ge,{slot:`automation-runner-pill`,icon:x(be),fieldLabel:!0,ariaLabel:`Runner`,label:e.runner?s(p.data,e.runner):`default`,value:e.runner??``,disabled:!p.data,options:[{value:``,label:`default`,desc:`The project’s default runner`},...v.map(e=>({value:e,label:s(p.data,e)}))],footer:(0,K.jsx)(Le,{uninstalled:l.uninstalled,signedOut:d.filter(t=>t!==e.runner)}),onPick:e=>{t({runner:e||void 0,model:void 0})}}),(0,K.jsx)(Ge,{slot:`automation-model-pill`,icon:x(ge),fieldLabel:!0,ariaLabel:`Model`,label:b,value:e.model??``,options:y.map(e=>({value:e.id,label:e.label,desc:e.desc})),onPick:e=>t({model:e||void 0})})]})})}function Qn(e){return{text:/\bauth\b|sign.?in|\blogin\b|\btoken\b|credentials|HTTP 401/i.test(e)?`GitHub CLI is not signed in`:/ENOENT|not found.*gh|gh.*not found/i.test(e)?`GitHub CLI is not installed`:`GitHub filter check failed`,tone:`error`,details:e}}function $n({data:e,error:t,refresh:n,archived:r=!1,onArchivedChange:i}){let[a,o]=(0,H.useState)({}),[s,c]=(0,H.useState)({}),l=(e,t)=>o(n=>{let{[e]:r,...i}=n;return t?{...i,[e]:t}:i}),u=async(e,t,n=!1)=>{c(t=>({...t,[e]:!0}));try{await t()}catch(t){let r=t instanceof Error?t.message:String(t);l(e,n?Qn(r):{text:r,tone:`error`})}finally{c(t=>({...t,[e]:!1}))}},d=e=>u(e.id,async()=>{l(e.id,{text:`Starting…`,tone:`info`});let{runId:t}=await f(e.id);l(e.id,{text:`Started task`,tone:`info`,runId:t}),n()}),p=e=>u(e.id,async()=>{l(e.id,void 0),await m(e.id,!e.enabled),await n()}),h=e=>u(e.id,async()=>{l(e.id,void 0),await re(e.id),await n()}),g=e=>u(e.id,async()=>{l(e.id,{text:`Checking…`,tone:`info`});let{checkId:t}=await ie(e.id,`preview`);for(let r=0;r<60;r+=1){let r=await ee(t);if(r.status===`complete`){l(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`){let t=r.error??`Preview failed`;l(e.id,Qn(t));return}await new Promise(e=>setTimeout(e,500))}throw Error(`Preview is still running`)},!0),_=e?.automations??[],v=_.filter(e=>!e.archived),y=_.filter(e=>!!e.archived),b=r?y:v;return(0,K.jsx)(z,{route:`automations`,density:e?Ae(b.length):`full`,headerSpacing:`compact`,header:{title:`Automations`,subtitle:`Schedules and GitHub checks run while Squawk is open.`,primaryAction:(0,K.jsx)(ke,{variant:`primary`,asChild:!0,children:(0,K.jsxs)(R,{to:`/automations/new`,children:[(0,K.jsx)(me,{"aria-hidden":`true`,className:`size-4`}),`New automation`]})})},sparseFooter:e&&b.length>0&&!r?(0,K.jsx)(Me,{summary:`${b.length} active ${b.length===1?`automation`:`automations`} configured. New automations start paused so you can test filters before enabling them.`,actions:(0,K.jsx)(M,{variant:`outline`,size:`sm`,asChild:!0,children:(0,K.jsx)(R,{to:`/automations/new`,children:`Add another`})})}):void 0,children:t&&!e?(0,K.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,K.jsx)(q,{text:t}),(0,K.jsx)(M,{variant:`outline`,onClick:()=>void n(),children:`Retry`})]}):e?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-end justify-between gap-3 border-b border-border`,children:[i?(0,K.jsxs)(`div`,{className:`flex gap-6`,role:`group`,"aria-label":`Filter automations`,children:[(0,K.jsxs)(`button`,{type:`button`,"data-slot":`automations-tab`,"data-view":`active`,"aria-pressed":!r,onClick:()=>i(!1),className:j(`-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`,!r&&`border-accent-text text-foreground`),children:[`Current`,(0,K.jsx)(er,{count:v.length})]}),(0,K.jsxs)(`button`,{type:`button`,"data-slot":`automations-tab`,"data-view":`archived`,"aria-pressed":r,onClick:()=>i(!0),className:j(`-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`,r&&`border-accent-text text-foreground`),children:[`Archived`,(0,K.jsx)(er,{count:y.length})]})]}):(0,K.jsx)(`span`,{}),(0,K.jsx)(`div`,{className:`pb-2.5`,children:(0,K.jsx)(tr,{data:e})})]}),r&&b.length===0?(0,K.jsx)(q,{text:`No archived automations.`}):b.length===0?(0,K.jsx)(Ie,{icon:(0,K.jsx)(ve,{}),tone:`neutral`,title:`No automations yet`,subtitle:`Create one paused, preview it, then enable it.`,heading:`h2`,actions:(0,K.jsx)(M,{variant:`primary`,asChild:!0,children:(0,K.jsxs)(R,{to:`/automations/new`,children:[(0,K.jsx)(me,{"aria-hidden":`true`,className:`size-4`}),`New automation`]})})}):(0,K.jsx)(`ul`,{className:`grid gap-3`,"aria-label":`Automations`,children:b.map(t=>(0,K.jsx)(ur,{automation:t,timeZone:e.timeZone,note:a[t.id],busy:s[t.id]===!0,onRun:()=>void d(t),onToggle:()=>void p(t),onPreview:()=>void g(t),onCancel:()=>void h(t)},t.id))})]}):(0,K.jsx)(q,{text:`Loading automations…`})})}function er({count:e}){return e===0?null:(0,K.jsx)(`span`,{"data-slot":`automations-tab-count`,className:`tabular-nums text-muted-foreground`,children:`· ${e}`})}function tr({data:e}){return(0,K.jsx)(`p`,{"data-slot":`automation-scheduler`,className:j(`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 nr(e){return e.kind===`schedule`&&e.schedule?it(e.schedule):`${fn(e.events??[])} · every ${Math.round((e.intervalSeconds??300)/60)} min`}function rr({automation:e,nextRun:t}){let n=e.kind===`schedule`?he:pe,r=Ye(e);return(0,K.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsxs)(`h2`,{className:`flex items-center gap-2 font-semibold break-words`,children:[(0,K.jsx)(n,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`}),e.name]}),(0,K.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,K.jsx)(`span`,{children:nr(e)}),t?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),t]}):null]})]}),(0,K.jsx)(qe,{dot:r.tone,shape:r.shape,pulse:r.pulse,children:r.label})]})}function ir({automation:e,archive:t}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`p`,{className:`text-sm break-words`,children:[t.outcome===`launched`?`Started its task.`:`Cancelled — no task was started.`,t.runId?(0,K.jsxs)(K.Fragment,{children:[` · `,(0,K.jsx)(R,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${t.runId}`,children:`Open task`})]}):null]}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,K.jsx)(M,{variant:`outline`,asChild:!0,children:(0,K.jsx)(R,{to:`/automations/${e.id}`,children:`Details`})})})]})}function ar({automation:e,timeZone:t}){let n=e.kind===`schedule`,r=e.enabled&&n?e.nextRunAt:void 0;return!n&&e.enabled?(0,K.jsx)(`span`,{children:`continuous`}):r?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`text-foreground`,children:`Next run: ${V(r,t)}`}),(0,K.jsx)(`span`,{children:`· ${at(Date.now(),Date.parse(r))}`})]}):(0,K.jsx)(`span`,{children:`Next run: —`})}function or({automation:e,timeZone:t}){let n=e.enabled?St(e.state):void 0;return n?(0,K.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,K.jsx)(`span`,{className:`text-muted-foreground`,children:` · Next try ${V(n.retryAt,t)}`}):null]}):null}var $=`px-3`;function sr({automation:e,busy:t,confirmingCancel:n,cancelRef:r,onToggle:i,onRun:a,onPreview:o,onOpenCancel:s}){let c=e.kind===`schedule`,l=e.schedule?.type===`once`;return(0,K.jsxs)(`div`,{"data-slot":`automation-actions`,className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(M,{variant:`outline`,size:`sm`,className:$,"data-action":`automation-toggle`,disabled:t,onClick:i,children:e.enabled?`Pause`:`Enable`}),c?(0,K.jsx)(M,{variant:`outline`,size:`sm`,className:$,"data-action":`automation-run`,disabled:t,onClick:a,children:`Run now`}):(0,K.jsx)(M,{variant:`outline`,size:`sm`,className:$,"data-action":`automation-preview`,disabled:t,onClick:o,children:`Test filter`}),(0,K.jsx)(M,{variant:`outline`,size:`sm`,className:$,asChild:!0,children:(0,K.jsx)(R,{to:`/automations/${e.id}`,children:`Edit`})}),l&&!n?(0,K.jsx)(M,{variant:`outline`,size:`sm`,className:j($,`text-destructive`),ref:r,"data-action":`automation-cancel`,disabled:t,onClick:s,children:`Cancel`}):null,(0,K.jsx)(M,{variant:`outline`,size:`sm`,className:j($,`sm:ms-auto`),asChild:!0,children:(0,K.jsx)(R,{to:`/automations/${e.id}/log`,children:`Execution log`})})]})}function cr({automation:e,busy:t,keepRef:n,onConfirm:r,onKeep:i}){return(0,K.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[(0,K.jsx)(`p`,{className:`text-sm break-words`,children:`Cancel “${e.name}”? It will never run, and it moves to Archived.`}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(M,{variant:`danger-ghost`,"data-action":`automation-cancel-confirm`,disabled:t,onClick:r,children:`Cancel schedule`}),(0,K.jsx)(M,{ref:n,variant:`outline`,disabled:t,onClick:i,children:`Keep`})]})]})}function lr({note:e}){return(0,K.jsxs)(`div`,{role:e.tone===`error`?`alert`:`status`,className:j(`text-sm break-words`,e.tone===`error`?`text-destructive`:`text-muted-foreground`),children:[e.text,e.details?(0,K.jsxs)(K.Fragment,{children:[` · `,(0,K.jsx)(de,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:Fe(`gh`),children:`Set up`}),(0,K.jsxs)(`details`,{children:[(0,K.jsx)(`summary`,{className:`min-h-11 cursor-pointer`,children:`Command details`}),(0,K.jsx)(`pre`,{className:`whitespace-pre-wrap break-words`,children:e.details})]})]}):null,e.runId?(0,K.jsxs)(K.Fragment,{children:[` · `,(0,K.jsx)(R,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${e.runId}`,children:`Open task`})]}):null]})}function ur({automation:e,timeZone:t,note:n,busy:r,onRun:i,onToggle:a,onPreview:o,onCancel:s}){let[c,l]=(0,H.useState)(!1),u=(0,H.useRef)(null),d=(0,H.useRef)(null),f=(0,H.useRef)(null);(0,H.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,K.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,K.jsx)(rr,{automation:e,nextRun:h?void 0:(0,K.jsx)(ar,{automation:e,timeZone:t})}),h?(0,K.jsx)(ir,{automation:e,archive:h}):null,h?null:(0,K.jsx)(or,{automation:e,timeZone:t}),h?null:(0,K.jsx)(sr,{automation:e,busy:r,confirmingCancel:c,cancelRef:u,onToggle:a,onRun:i,onPreview:o,onOpenCancel:p}),e.schedule?.type===`once`&&!h&&c?(0,K.jsx)(cr,{automation:e,busy:r,keepRef:d,onConfirm:()=>{l(!1),s()},onKeep:m}):null,n?(0,K.jsx)(lr,{note:n}):null,(0,K.jsx)(Pt,{automationId:e.id,automationName:e.name,timeZone:t})]})}function dr(e){let t=Oe(),n=ze(),[r,i]=(0,H.useState)(),[a,o]=(0,H.useState)(``),s=(0,H.useCallback)(t=>ae({signal:t,...e?{archived:e}:{}}).then(e=>{t?.aborted||(i(e),o(``))}).catch(e=>{t?.aborted||o(String(e))}),[e]);return(0,H.useEffect)(()=>{n&&s()},[n,s]),(0,H.useEffect)(()=>ne(async e=>{n&&await s(e)}),[n,s]),(0,H.useEffect)(()=>fe((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 fr({mode:e=`list`}){let{automationId:t}=ue(),n=De(),[r,i]=(0,H.useState)(!1),{data:a,error:o,refresh:s}=dr(`include`),[c,l]=(0,H.useState)(0),u=Re();if(u===`unknown`)return(0,K.jsx)(z,{route:`automations`,density:`empty`,children:(0,K.jsx)(q,{text:`Loading automations…`})});if(u===`absent`)return(0,K.jsx)(Je,{});if(u===`disabled`)return(0,K.jsx)(z,{route:`automations`,density:`empty`,children:(0,K.jsx)(Ie,{icon:(0,K.jsx)(ve,{}),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,K.jsx)($n,{data:a,error:o,refresh:s,archived:r,onArchivedChange:i});if(!a)return o?(0,K.jsx)(z,{route:`automations`,density:`empty`,header:{title:`Automations`,subtitle:`Could not load automations.`},children:(0,K.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,K.jsx)(q,{text:o}),(0,K.jsx)(M,{variant:`outline`,onClick:()=>void s(),children:`Retry`})]})}):(0,K.jsx)(z,{route:`automations`,density:`empty`,children:(0,K.jsx)(q,{text:`Loading automations…`})});let p={available:a.available,...a.reason?{reason:a.reason}:{}};return e===`new`?(0,K.jsx)(Kn,{forge:p,timeZone:a.timeZone,onSaved:d}):e===`edit`?f?f.archived?(0,K.jsx)(Ft,{automation:f,timeZone:a.timeZone,onDeleted:d}):(0,K.jsx)(Kn,{automation:f,forge:p,timeZone:a.timeZone,onSaved:d,onReload:()=>void s().then(()=>l(e=>e+1))},`${f.id}:${c}`):(0,K.jsx)(z,{route:`automations`,density:`empty`,header:{title:`Automation not found`,subtitle:`This automation may have been removed.`},children:(0,K.jsx)(M,{asChild:!0,variant:`outline`,children:(0,K.jsx)(R,{to:`/automations`,children:`Back to automations`})})}):t?(0,K.jsx)(Nt,{automationId:t,automationName:f?.name,timeZone:a.timeZone,readOnly:!!f?.archived}):(0,K.jsx)(q,{text:`Automation not found.`})}export{fr as AutomationsRoute};
@@ -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{Cn as r}from"./project-scope-context-Bz7AAyJ4.js";import{o as i}from"./dist-CCX8mhHc.js";import{M as a,Q as o,ct as s,r as c}from"./design-icons-QbNMZniQ.js";import{n as l,r as u}from"./diff-controls-rfNgY_Dd.js";import{t as d}from"./search-x-I9Q8pgUa.js";import{t as f}from"./button-BV_AiLj2.js";import{t as p}from"./project-router-CARDbdMX.js";import{m}from"./page-shell-BdjH5hyc.js";import{t as h}from"./centered-state-N8vWM_Hw.js";import{Bn as g,Ln as _,Xt as v,Zt as y,lr as b,o as x}from"./index-D9hyWO4C.js";import{t as S}from"./diff-DPSOaO5_.js";var C=e(t(),1),w=n();function T({commit:e,sha:t,slot:n,heading:o=`h2`,diffRef:c,loadFileText:f,className:p}){let y=m(),[b,x]=(0,C.useState)(`unified`),[T,D]=(0,C.useState)(!0),O=(0,C.useRef)(null);E(O,t);let k=e.isError&&e.error instanceof r&&e.error.status===409;return(0,w.jsx)(`section`,{ref:O,"data-slot":n,"data-sha":t,"aria-label":`Selected commit`,className:i(`min-w-0 flex-1 scroll-mt-4 overflow-clip rounded-xl border border-border bg-card`,p),children:e.isPending?(0,w.jsx)(`p`,{"data-slot":`commit-loading`,className:`px-4 py-8 text-center text-xs text-muted-foreground`,children:`Loading commit diff…`}):e.isError?(0,w.jsx)(h,{icon:k?(0,w.jsx)(d,{}):(0,w.jsx)(s,{size:16}),tone:k?`neutral`:`danger`,heading:`h2`,title:k?`Commit not found`:`Could not load commit diff`,subtitle:e.error.message}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`div`,{"data-slot":`commit-meta`,className:`flex flex-wrap items-start gap-x-3 gap-y-2 border-b border-border px-4 py-3`,children:[(0,w.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,w.jsx)(o,{className:`break-words text-sm leading-snug font-semibold text-foreground`,children:e.data.subject}),(0,w.jsxs)(`p`,{className:`mt-0.5 flex flex-wrap items-center gap-x-1.5 text-xs text-muted-foreground`,children:[(0,w.jsx)(`span`,{children:e.data.author}),(0,w.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,w.jsx)(`span`,{title:e.data.when,children:v(e.data.when)}),(0,w.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,w.jsx)(g,{sha:e.data.sha,variant:`inline`}),(0,w.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,w.jsx)(`span`,{"data-slot":`commit-stat`,children:(0,w.jsx)(_,{stat:e.data.stat})})]})]}),(0,w.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,w.jsx)(u,{mode:b,wrap:T,onModeChange:x,onWrapChange:D}),(0,w.jsx)(l,{wrap:T,onWrapChange:D})]})]}),e.data.files.length===0?(0,w.jsx)(h,{icon:(0,w.jsx)(a,{size:16}),tone:`neutral`,heading:`h2`,title:`No file changes`,subtitle:`This commit carries no diff of its own — a merge commit's changes live on the commits it merged.`}):(0,w.jsx)(`div`,{className:`p-4 [--diff-sticky-top:0px]`,children:(0,w.jsx)(S,{...c?{viewRef:c}:{},...f?{loadFileText:f}:{},files:e.data.files,mode:y?b:`unified`,wrap:T,totals:!1,className:`min-w-0`},t)})]})})}function E(e,t){let n=(0,C.useRef)(t);(0,C.useLayoutEffect)(()=>{if(n.current===t)return;n.current=``;let r=e.current,i=r?.closest(`[data-slot="main"]`);if(!(!r||!i)&&r.getBoundingClientRect().top<i.getBoundingClientRect().top){let e=typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;r.scrollIntoView?.({block:`start`,behavior:e?`auto`:`smooth`})}},[e,t])}function D({commit:e,sha:t,backTo:n,backLabel:r,slot:i,loadFileText:a,diffRef:o}){return(0,w.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,w.jsx)(`div`,{className:`mx-4 border-b border-border py-2`,children:(0,w.jsx)(f,{asChild:!0,variant:`ghost`,size:`sm`,"data-slot":`commit-back`,children:(0,w.jsxs)(p,{to:n,children:[(0,w.jsx)(c,{size:16,"aria-hidden":`true`}),r]})})}),(0,w.jsx)(T,{commit:e,sha:t,slot:i,loadFileText:a,...o?{diffRef:o}:{},className:`rounded-none border-0 bg-transparent`})]})}var O=56;function k({slot:e,commits:t,selectedSha:n,className:r,heading:a}){let[s,c]=(0,C.useState)(``),l=s.trim().toLowerCase(),u=l?t.filter(e=>e.subject.toLowerCase().includes(l)):t,d=u.length>150,f=(0,C.useRef)(null),p=(0,C.useRef)(null),[m,h]=(0,C.useState)(0);(0,C.useLayoutEffect)(()=>{if(!d)return;let e=()=>{let e=f.current,t=p.current;!e||!t||h(Math.max(0,Math.round(e.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop)))};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[d]);let g=u.map(e=>(0,w.jsx)(A,{commit:e,selected:n!==void 0&&e.sha===n},e.sha));return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`label`,{className:`relative mb-3 block`,children:[(0,w.jsx)(o,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute top-3 left-3 size-4 text-muted-foreground`}),(0,w.jsx)(b,{"aria-label":`Search commit messages`,placeholder:`Search commit messages…`,value:s,onChange:e=>c(e.target.value),className:`h-10 rounded-lg border-border bg-card pl-10`})]}),(0,w.jsxs)(`div`,{ref:e=>{f.current=e,e&&(p.current=e.closest(`[data-slot="main"]`))},"data-slot":e,"data-virtualized":d,className:i(`flex flex-col divide-y divide-border rounded-xl border border-border bg-card px-3 py-1 md:px-4`,r),children:[a?(0,w.jsx)(`div`,{className:`flex min-h-11 flex-wrap items-center gap-2 py-2.5`,children:a}):null,u.length===0?(0,w.jsx)(`p`,{role:`status`,className:`py-5 text-sm text-muted-foreground`,children:`No loaded commits match your search.`}):null,d?(0,w.jsx)(x,{scrollRef:p,startMargin:m,itemSize:O,children:g}):g]})]})}function A({commit:e,selected:t}){return(0,w.jsx)(`div`,{className:`[contain-intrinsic-block-size:auto_56px] [content-visibility:auto]`,children:(0,w.jsxs)(p,{"data-slot":`commit-row`,"data-sha":e.sha,"data-selected":t?`true`:void 0,"aria-current":t?`true`:void 0,to:e.href,className:i(`flex min-h-11 min-w-0 items-start gap-2.5 rounded-md px-2 py-2.5 transition-colors hover:bg-muted`,t&&`bg-muted/70`),children:[(0,w.jsx)(a,{size:16,"aria-hidden":`true`,className:`mt-px size-4 shrink-0 text-accent-text`}),(0,w.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,w.jsx)(`span`,{"data-slot":`commit-row-subject`,title:e.subject,className:`line-clamp-2 text-[13px] leading-snug font-medium break-words text-foreground`,children:e.subject}),(0,w.jsxs)(`span`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-muted-foreground`,children:[(0,w.jsx)(j,{sha:e.sha}),(0,w.jsxs)(`span`,{className:`min-w-0 truncate`,children:[e.author,` · `,(0,w.jsx)(`span`,{title:y(e.when,e.at),children:v(e.when,e.at)})]}),e.stat?(0,w.jsx)(_,{stat:e.stat}):null]})]})]})})}function j({sha:e}){return(0,w.jsx)(g,{"data-slot":`commit-sha`,sha:e,variant:`chip`})}export{T as i,j as n,D as r,k as t};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Cn as r}from"./project-scope-context-hfRzPMZ4.js";import{o as i}from"./dist-CCX8mhHc.js";import{M as a,Q as o,ct as s,r as c}from"./design-icons-QbNMZniQ.js";import{n as l,r as u}from"./diff-controls-DeMSGYln.js";import{t as d}from"./search-x-I9Q8pgUa.js";import{t as f}from"./button-BV_AiLj2.js";import{t as p}from"./project-router-yoWCTDaT.js";import{m}from"./page-shell-BdjH5hyc.js";import{t as h}from"./centered-state-N8vWM_Hw.js";import{Bn as g,Ln as _,Xt as v,Zt as y,lr as b,o as x}from"./index-BuR9xHfb.js";import{t as S}from"./diff-BidPzsVK.js";var C=e(t(),1),w=n();function T({commit:e,sha:t,slot:n,heading:o=`h2`,diffRef:c,loadFileText:f,className:p}){let y=m(),[b,x]=(0,C.useState)(`unified`),[T,D]=(0,C.useState)(!0),O=(0,C.useRef)(null);E(O,t);let k=e.isError&&e.error instanceof r&&e.error.status===409;return(0,w.jsx)(`section`,{ref:O,"data-slot":n,"data-sha":t,"aria-label":`Selected commit`,className:i(`min-w-0 flex-1 scroll-mt-4 overflow-clip rounded-xl border border-border bg-card`,p),children:e.isPending?(0,w.jsx)(`p`,{"data-slot":`commit-loading`,className:`px-4 py-8 text-center text-xs text-muted-foreground`,children:`Loading commit diff…`}):e.isError?(0,w.jsx)(h,{icon:k?(0,w.jsx)(d,{}):(0,w.jsx)(s,{size:16}),tone:k?`neutral`:`danger`,heading:`h2`,title:k?`Commit not found`:`Could not load commit diff`,subtitle:e.error.message}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`div`,{"data-slot":`commit-meta`,className:`flex flex-wrap items-start gap-x-3 gap-y-2 border-b border-border px-4 py-3`,children:[(0,w.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,w.jsx)(o,{className:`break-words text-sm leading-snug font-semibold text-foreground`,children:e.data.subject}),(0,w.jsxs)(`p`,{className:`mt-0.5 flex flex-wrap items-center gap-x-1.5 text-xs text-muted-foreground`,children:[(0,w.jsx)(`span`,{children:e.data.author}),(0,w.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,w.jsx)(`span`,{title:e.data.when,children:v(e.data.when)}),(0,w.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,w.jsx)(g,{sha:e.data.sha,variant:`inline`}),(0,w.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,w.jsx)(`span`,{"data-slot":`commit-stat`,children:(0,w.jsx)(_,{stat:e.data.stat})})]})]}),(0,w.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,w.jsx)(u,{mode:b,wrap:T,onModeChange:x,onWrapChange:D}),(0,w.jsx)(l,{wrap:T,onWrapChange:D})]})]}),e.data.files.length===0?(0,w.jsx)(h,{icon:(0,w.jsx)(a,{size:16}),tone:`neutral`,heading:`h2`,title:`No file changes`,subtitle:`This commit carries no diff of its own — a merge commit's changes live on the commits it merged.`}):(0,w.jsx)(`div`,{className:`p-4 [--diff-sticky-top:0px]`,children:(0,w.jsx)(S,{...c?{viewRef:c}:{},...f?{loadFileText:f}:{},files:e.data.files,mode:y?b:`unified`,wrap:T,totals:!1,className:`min-w-0`},t)})]})})}function E(e,t){let n=(0,C.useRef)(t);(0,C.useLayoutEffect)(()=>{if(n.current===t)return;n.current=``;let r=e.current,i=r?.closest(`[data-slot="main"]`);if(!(!r||!i)&&r.getBoundingClientRect().top<i.getBoundingClientRect().top){let e=typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;r.scrollIntoView?.({block:`start`,behavior:e?`auto`:`smooth`})}},[e,t])}function D({commit:e,sha:t,backTo:n,backLabel:r,slot:i,loadFileText:a,diffRef:o}){return(0,w.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,w.jsx)(`div`,{className:`mx-4 border-b border-border py-2`,children:(0,w.jsx)(f,{asChild:!0,variant:`ghost`,size:`sm`,"data-slot":`commit-back`,children:(0,w.jsxs)(p,{to:n,children:[(0,w.jsx)(c,{size:16,"aria-hidden":`true`}),r]})})}),(0,w.jsx)(T,{commit:e,sha:t,slot:i,loadFileText:a,...o?{diffRef:o}:{},className:`rounded-none border-0 bg-transparent`})]})}var O=56;function k({slot:e,commits:t,selectedSha:n,className:r,heading:a}){let[s,c]=(0,C.useState)(``),l=s.trim().toLowerCase(),u=l?t.filter(e=>e.subject.toLowerCase().includes(l)):t,d=u.length>150,f=(0,C.useRef)(null),p=(0,C.useRef)(null),[m,h]=(0,C.useState)(0);(0,C.useLayoutEffect)(()=>{if(!d)return;let e=()=>{let e=f.current,t=p.current;!e||!t||h(Math.max(0,Math.round(e.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop)))};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[d]);let g=u.map(e=>(0,w.jsx)(A,{commit:e,selected:n!==void 0&&e.sha===n},e.sha));return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`label`,{className:`relative mb-3 block`,children:[(0,w.jsx)(o,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute top-3 left-3 size-4 text-muted-foreground`}),(0,w.jsx)(b,{"aria-label":`Search commit messages`,placeholder:`Search commit messages…`,value:s,onChange:e=>c(e.target.value),className:`h-10 rounded-lg border-border bg-card pl-10`})]}),(0,w.jsxs)(`div`,{ref:e=>{f.current=e,e&&(p.current=e.closest(`[data-slot="main"]`))},"data-slot":e,"data-virtualized":d,className:i(`flex flex-col divide-y divide-border rounded-xl border border-border bg-card px-3 py-1 md:px-4`,r),children:[a?(0,w.jsx)(`div`,{className:`flex min-h-11 flex-wrap items-center gap-2 py-2.5`,children:a}):null,u.length===0?(0,w.jsx)(`p`,{role:`status`,className:`py-5 text-sm text-muted-foreground`,children:`No loaded commits match your search.`}):null,d?(0,w.jsx)(x,{scrollRef:p,startMargin:m,itemSize:O,children:g}):g]})]})}function A({commit:e,selected:t}){return(0,w.jsx)(`div`,{className:`[contain-intrinsic-block-size:auto_56px] [content-visibility:auto]`,children:(0,w.jsxs)(p,{"data-slot":`commit-row`,"data-sha":e.sha,"data-selected":t?`true`:void 0,"aria-current":t?`true`:void 0,to:e.href,className:i(`flex min-h-11 min-w-0 items-start gap-2.5 rounded-md px-2 py-2.5 transition-colors hover:bg-muted`,t&&`bg-muted/70`),children:[(0,w.jsx)(a,{size:16,"aria-hidden":`true`,className:`mt-px size-4 shrink-0 text-accent-text`}),(0,w.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,w.jsx)(`span`,{"data-slot":`commit-row-subject`,title:e.subject,className:`line-clamp-2 text-[13px] leading-snug font-medium break-words text-foreground`,children:e.subject}),(0,w.jsxs)(`span`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-muted-foreground`,children:[(0,w.jsx)(j,{sha:e.sha}),(0,w.jsxs)(`span`,{className:`min-w-0 truncate`,children:[e.author,` · `,(0,w.jsx)(`span`,{title:y(e.when,e.at),children:v(e.when,e.at)})]}),e.stat?(0,w.jsx)(_,{stat:e.stat}):null]})]})]})})}function j({sha:e}){return(0,w.jsx)(g,{"data-slot":`commit-sha`,sha:e,variant:`chip`})}export{T as i,j as n,D as r,k as t};