@hearsay-tools/squawk 0.19.0-dev.8946 → 0.19.0-dev.8956

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 (64) hide show
  1. package/dist/delegation/routes.d.ts +65 -65
  2. package/dist/server/models-routes.d.ts +12 -12
  3. package/dist/server/projects-routes.d.ts +45 -45
  4. package/dist/server/providers-routes.d.ts +57 -57
  5. package/dist/server/repo-routes.d.ts +34 -34
  6. package/dist/server/reports-api.d.ts +2 -2
  7. package/dist/server/runner-install-routes.d.ts +10 -10
  8. package/dist/server/runs-routes.d.ts +278 -278
  9. package/dist/server/workspace-routes.d.ts +85 -85
  10. package/package.json +4 -4
  11. package/web/dist/assets/{accounts-section-WIehcyGw.js → accounts-section-DQNWKGdd.js} +1 -1
  12. package/web/dist/assets/{activity-motion-C6MkKVNw.js → activity-motion-dg8xQovm.js} +1 -1
  13. package/web/dist/assets/{activity-route-DnkJg2yC.js → activity-route-pAplJbQ-.js} +1 -1
  14. package/web/dist/assets/{agent-config-section-D9CmEBGB.js → agent-config-section-DXLK8TWx.js} +1 -1
  15. package/web/dist/assets/{agent-defaults-section-Dpo7uqt7.js → agent-defaults-section-CHo6SV_E.js} +1 -1
  16. package/web/dist/assets/{appearance-C4ZeV0d7.js → appearance-BBm_1-0d.js} +1 -1
  17. package/web/dist/assets/{archive-on-merge-field-CLz5wdcX.js → archive-on-merge-field-BpxWzA-s.js} +1 -1
  18. package/web/dist/assets/automations-route-Bgz1q3d_.js +2 -0
  19. package/web/dist/assets/{commit-list-BBOPi-5c.js → commit-list-DsQ8tZV9.js} +1 -1
  20. package/web/dist/assets/{diff-o1vDSmjJ.js → diff-H-hamhtW.js} +2 -2
  21. package/web/dist/assets/{diff-controls-RoNLKGo8.js → diff-controls-BvvrHTu_.js} +1 -1
  22. package/web/dist/assets/{diff-view--upGtYuH.js → diff-view-Deq7mb3J.js} +1 -1
  23. package/web/dist/assets/{discard-changes-dialog-C4edQj7U.js → discard-changes-dialog-C06t2BR5.js} +1 -1
  24. package/web/dist/assets/{file-preview-Ba2kwvIA.js → file-preview-D8pCQdne.js} +1 -1
  25. package/web/dist/assets/{git-toolbar-DXDZQtTO.js → git-toolbar-DvMZegJ7.js} +1 -1
  26. package/web/dist/assets/{github-CZrdkYl7.js → github-BDRo8fXv.js} +1 -1
  27. package/web/dist/assets/{global-activity-route-H0_KUbFo.js → global-activity-route-Dm_kAVcm.js} +1 -1
  28. package/web/dist/assets/{index-BdwJdyhu.js → index-Byw2yW7N.js} +4 -4
  29. package/web/dist/assets/{markdown-BrCnMalC.js → markdown-BQab8jF1.js} +1 -1
  30. package/web/dist/assets/{option-select-DYOZPdHh.js → option-select-JTiDFrqF.js} +1 -1
  31. package/web/dist/assets/{preferences-section-DAHLqdBx.js → preferences-section-C-j7m5yZ.js} +1 -1
  32. package/web/dist/assets/{preview-pane-connected-CZ8K6fgu.js → preview-pane-connected-BnuUrbmD.js} +1 -1
  33. package/web/dist/assets/{project-location-BtpH7PdN.js → project-location-Dyn7zI6j.js} +1 -1
  34. package/web/dist/assets/{projects-section-C3uSUuUa.js → projects-section-DzIrNvrh.js} +1 -1
  35. package/web/dist/assets/{prompt-templates-section-BqTyw9qv.js → prompt-templates-section-DtNo6kjG.js} +1 -1
  36. package/web/dist/assets/{remote-settings-notice-C8ISDWAZ.js → remote-settings-notice-C7V8JZt9.js} +1 -1
  37. package/web/dist/assets/{repo-git-op-Z42-r.js → repo-git-DBnTvj5D.js} +1 -1
  38. package/web/dist/assets/{report-reader-Czn67eDi.js → report-reader-C7MtQlUw.js} +1 -1
  39. package/web/dist/assets/{reports-CUTmDw8a.js → reports-BfqPAwGI.js} +1 -1
  40. package/web/dist/assets/{resources-section-CrFBkbzV.js → resources-section-C2Dw4VR6.js} +1 -1
  41. package/web/dist/assets/{review-panel-DnKKu0ED.js → review-panel--h2qOZ5y.js} +1 -1
  42. package/web/dist/assets/{run-header-BuWI-Izb.js → run-header-D_xptiSf.js} +1 -1
  43. package/web/dist/assets/{select-BNkI-J23.js → select-1ZfHanpO.js} +1 -1
  44. package/web/dist/assets/{session-context-section-Cbnd7mET.js → session-context-section-CD_o7uNM.js} +1 -1
  45. package/web/dist/assets/{settings-agent-picker-Cc9EbxOn.js → settings-agent-picker-CaGxQRTa.js} +1 -1
  46. package/web/dist/assets/{settings-save-bar-CXPbykSw.js → settings-save-bar-BA6YnLcP.js} +1 -1
  47. package/web/dist/assets/{settings-shell-he41aRWc.js → settings-shell-CG1-kWWp.js} +1 -1
  48. package/web/dist/assets/{sidebar-section-DnBL1i6S.js → sidebar-section-kWgmwFom.js} +1 -1
  49. package/web/dist/assets/{skills-C0ExMlKn.js → skills-D-ZXx_Db.js} +1 -1
  50. package/web/dist/assets/{task-changes-CkZAXYzq.js → task-changes-CIrkn5L8.js} +1 -1
  51. package/web/dist/assets/{task-commits-DvbEh5Ej.js → task-commits-BZj5bFmc.js} +1 -1
  52. package/web/dist/assets/{task-file-scope-u9ReDUkm.js → task-file-scope-CkTckRi_.js} +1 -1
  53. package/web/dist/assets/{task-files-_ViDE2KM.js → task-files-CVija0D3.js} +1 -1
  54. package/web/dist/assets/{task-github-item-D6HlV5w7.js → task-github-item-C_7h7vWI.js} +1 -1
  55. package/web/dist/assets/{task-thread-DufVSXBG.js → task-thread-B5wy_92u.js} +1 -1
  56. package/web/dist/assets/{thread-state-DyL-5CT_.js → thread-state-c_QiK_1p.js} +1 -1
  57. package/web/dist/assets/{use-hand-to-agent-state-Bbno11XR.js → use-hand-to-agent-state-D7BytpdB.js} +1 -1
  58. package/web/dist/assets/use-path-bases-B7RXNQ5t.js +1 -0
  59. package/web/dist/assets/{workflows-OsxhDzG9.js → workflows-DUFAcnv8.js} +1 -1
  60. package/web/dist/assets/{workspace-tools-D6uFs3zu.js → workspace-tools-C7-39mKv.js} +1 -1
  61. package/web/dist/assets/{worktrees-section-CzM3pU2A.js → worktrees-section-B9ifd22S.js} +1 -1
  62. package/web/dist/index.html +1 -1
  63. package/web/dist/assets/automations-route-dvKhqCE2.js +0 -2
  64. package/web/dist/assets/use-path-bases-DqgqcOdM.js +0 -1
@@ -1,2 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{o as r}from"./dist-C_rn70hE.js";import{A as i,_ as a,nn as o,rn as s,sn as c,tn as l}from"./queries-CIeJg62Y.js";import{B as u,Fn as d,H as f,Ur as p,V as m,_ as h,ar as g,c as ee,d as _,g as v,ir as y,ni as b,nr as x,o as te,s as ne,sr as re,ti as ie,v as ae,z as oe}from"./toaster-D0HMoto5.js";import{B as S,G as se,H as ce,I as C,K as le,N as w,P as T,V as ue,W as E,j as D,z as O}from"./live-protocol-DMhTnCmf.js";import{h as de,n as fe}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{r as pe,t as k}from"./label-CV8tuTOO.js";import{L as me,X as he,Y as ge,at as _e,b as ve,dt as ye,mt as be,tt as xe,u as Se}from"./design-icons-BZt8Kqs9.js";import{t as Ce}from"./check-OP-CVgZG.js";import{t as A}from"./button-C8jUIs8Q.js";import{n as we,r as Te,t as Ee}from"./collapsible-Bx2vViFx.js";import{a as j,i as M,n as N,r as P,t as F}from"./select-BNkI-J23.js";import{t as De}from"./switch-CAKeV99j.js";import{c as Oe,s as ke,t as I}from"./project-router-BHFXTx5l.js";import{c as L,d as R,f as Ae,l as je,n as Me,o as Ne}from"./page-shell-Dky5crRl.js";import{r as Pe}from"./agents-settings-path-7X6_cvUg.js";import{t as Fe}from"./centered-state-BgSV4e79.js";import{Bn as Ie,D as Le,K as Re,O as ze,P as Be,Tn as Ve,Vn as He,Y as Ue,_n as We,k as Ge,mr as Ke,q as qe,r as Je,t as Ye,tr as z,xn as Xe}from"./index-BdwJdyhu.js";import{t as Ze}from"./textarea-vEsJAUAV.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 B,u as pt,v as mt}from"./automation-format-DB34jUyF.js";var V=e(t(),1),H=D([`pull_request.opened`,`issue.opened`,`issue.labeled`,`issue.unlabeled`]),ht=S({includeExisting:T().optional(),authors:w(E()).optional(),assignees:w(E()).optional(),requireCurrentLabels:T().optional(),allLabels:w(E()).optional(),anyLabels:w(E()).optional(),excludeLabels:w(E()).optional(),changedLabels:w(E()).optional(),lookbackDays:O(),maxRecords:O()}),gt=D([`github`,`schedule`]),_t=x.omit({task:!0,images:!0,systemPrompt:!0}).extend({prompt:E(),variants:se([C(1),C(2),C(3)]).optional(),systemPrompt:E().optional()}),vt=S({at:E(),outcome:D([`launched`,`cancelled`]),runId:E().optional(),receiptId:E().optional(),trigger:D([`schedule`,`late`,`manual`,`retry`]).optional()}),U=S({id:E(),revision:O(),name:E(),description:E().optional(),enabled:T(),kind:gt,events:w(H).optional(),intervalSeconds:O().optional(),filters:ht.optional(),schedule:et.optional(),task:_t,archived:vt.optional(),createdAt:E(),updatedAt:E()}),W=S({timestamp:E(),tieBreaker:E().optional()}),yt=S({since:E().datetime(),until:E().datetime(),source:O().int().min(0).max(2),page:O().int().min(1).max(10),item:O().int().min(0).max(100),event:O().int().min(0).max(1e3),cursor:W.optional()}),bt={lastError:E().max(1e3).optional(),lastErrorAt:E().datetime().optional()},xt=S({revision:O().optional(),baselineAt:E().optional(),armedAt:E().optional(),historyScan:yt.optional(),cursor:W.optional(),frozenHighWatermark:W.extend({tieBreaker:E()}).optional(),backlogAfter:W.extend({tieBreaker:E()}).optional(),nextCheckAt:E().optional(),lastSuccessAt:E().optional(),nextRunAt:E().optional(),lastRunAt:E().optional(),etags:ce(E(),E()).optional(),backoffUntil:E().optional(),consecutiveFailures:O().optional(),...bt,onceOutcome:D([`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=D([`launched`,`no-match`,`duplicate`,`rate-limited`,`error`,`baseline`,`preview`,`skipped`,`manual`,`catch-up`,`failed`,`missed`]),wt=S({seq:O(),ts:E(),automationId:E(),revision:O(),event:H.optional(),result:Ct,reason:E().optional(),durationMs:O().optional(),receiptId:E().optional(),runId:E().optional(),githubNumber:O().optional(),githubTitle:E().optional(),githubUrl:E().optional(),rateLimit:S({bucket:D([`core`,`search`]),remaining:O().optional(),resetAt:E().optional()}).optional()}),Tt=S({matches:O(),launched:O(),duplicates:O(),errors:O()}),Et=U.extend({state:xt.optional(),latestLog:wt.optional(),counts:Tt,nextRunAt:E().optional(),onceStatus:ut.optional()});S({available:T(),reason:E().optional(),timeZone:E(),scheduler:S({state:D([`scheduled`,`idle`]),nextDue:E().optional()}),automations:w(Et)}),S({automation:U}).extend({once:S({dueAt:E(),timeZone:E(),resolvedInstant:E(),note:E()}).optional()}),S({automation:U,state:xt.optional(),latestLog:wt.optional(),onceStatus:ut.optional()}),S({id:E(),automationId:E(),mode:D([`preview`,`execute`]),status:D([`queued`,`running`,`complete`,`error`]),createdAt:E(),completedAt:E().optional(),matches:O().optional(),truncated:T().optional(),error:E().optional()}),S({checkId:E()}),S({records:w(wt)}),S({receiptId:E(),runId:E()}),S({runId:E()}),U.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:T().optional()}).omit({enable:!0}).extend({enabled:T().optional(),expectedRevision:O()}),S({archived:D([`include`,`only`]).optional()}),S({mode:D([`preview`,`execute`])});var G=n();function K({text:e}){return(0,G.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,V.useState)(),[r,i]=(0,V.useState)(``),a=(0,V.useCallback)(t=>h(e,{signal:t}).then(({records:e})=>{t?.aborted||(n(e),i(``))}).catch(e=>{t?.aborted||i(String(e))}),[e]);return(0,V.useEffect)(()=>{a()},[a]),(0,V.useEffect)(()=>p(a),[a]),(0,V.useEffect)(()=>pe((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,V.useState)(),[c,l]=(0,V.useState)(),u=Date.now(),d=async e=>{s(e),l(void 0);try{await oe(e),r()}catch(t){l({receiptId:e,message:t instanceof Error?t.message:String(t)})}finally{s(void 0)}};return(0,G.jsx)(`ol`,{className:`grid gap-3`,"aria-label":`Automation execution log`,children:e.map(e=>(0,G.jsxs)(`li`,{className:`min-w-0 rounded-xl border border-card-edge bg-card p-4 shadow-card`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,G.jsx)(Je,{dot:Dt[e.result],children:Ot[e.result]}),(0,G.jsx)(`time`,{className:`text-xs text-muted-foreground`,dateTime:e.ts,title:e.ts,children:ct(e.ts,n,u)})]}),e.reason?(0,G.jsx)(`p`,{className:`mt-2 text-sm break-words text-muted-foreground`,children:e.reason}):null,e.githubUrl||e.runId||a(e)?(0,G.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-4 gap-y-2 text-sm`,children:[e.githubUrl?(0,G.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,G.jsx)(I,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${e.runId}`,children:`Open task`}):null,a(e)?(0,G.jsx)(A,{variant:`outline`,disabled:o===e.receiptId,onClick:()=>void d(e.receiptId),children:`Retry task`}):null]}):null,c&&c.receiptId===e.receiptId?(0,G.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm break-words text-destructive`,children:c.message}):null]},e.seq))})}var q=`all`;function Mt({label:e,value:t,onChange:n,options:r}){return(0,G.jsxs)(F,{value:t,onValueChange:n,children:[(0,G.jsx)(M,{"aria-label":e,className:`w-full sm:w-52`,children:(0,G.jsx)(j,{})}),(0,G.jsx)(N,{children:r.map(e=>(0,G.jsx)(P,{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,V.useState)(q),[l,u]=(0,V.useState)(q),d=(0,V.useMemo)(()=>(i??[]).filter(e=>(s===q||e.result===s)&&(l===q||e.event===l)),[i,s,l]),f=(i??[]).some(e=>e.event);return(0,G.jsx)(je,{route:`automations`,density:i?Ae(d.length):`full`,header:{title:`Execution log`,subtitle:t??`Automation activity`,secondaryActions:(0,G.jsx)(L,{variant:`outline`,asChild:!0,children:(0,G.jsx)(I,{to:`/automations`,children:`Back to automations`})})},children:a&&!i?(0,G.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,G.jsx)(K,{text:a}),(0,G.jsx)(A,{variant:`outline`,onClick:()=>void o(),children:`Retry`})]}):i?i.length===0?(0,G.jsx)(K,{text:`Nothing has run yet.`}):(0,G.jsxs)(`div`,{className:`grid gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,G.jsx)(Mt,{label:`Result`,value:s,onChange:c,options:[{value:q,label:`All results`},...Ct.options.map(e=>({value:e,label:Ot[e]}))]}),f?(0,G.jsx)(Mt,{label:`Event`,value:l,onChange:u,options:[{value:q,label:`All events`},...H.options.map(e=>({value:e,label:e}))]}):null]}),d.length===0?(0,G.jsx)(K,{text:`No rows match these filters.`}):(0,G.jsx)(jt,{records:d,all:i,timeZone:n,onRetried:()=>void o(),readOnly:r})]}):(0,G.jsx)(K,{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,G.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,G.jsx)(`h3`,{className:`font-medium text-foreground`,children:c}),(0,G.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,G.jsx)(`p`,{children:`Nothing has run yet.`})]}):(0,G.jsxs)(`section`,{"data-slot":`automation-inline-log`,className:`min-w-0 border-t border-border pt-2.5`,children:[(0,G.jsx)(`h3`,{className:`mb-1.5 text-xs font-medium text-muted-foreground`,children:c}),o&&!a?(0,G.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[(0,G.jsx)(K,{text:o}),(0,G.jsx)(A,{variant:`outline`,onClick:()=>void s(),children:`Retry`})]}):a?(0,G.jsx)(jt,{records:a.slice(0,5),all:a,timeZone:n,onRetried:()=>void s(),readOnly:i}):(0,G.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,V.useState)(!1),[c,l]=(0,V.useState)(!1),[u,d]=(0,V.useState)(``),f=(0,V.useRef)(null),p=(0,V.useRef)(null),m=(0,V.useRef)(null);(0,V.useEffect)(()=>{let e=m.current===`keep`?p.current:m.current===`delete`?f.current:null;m.current=null,e?.focus()},[o]);let h=async()=>{l(!0);try{await _(e.id),n()}catch(e){d(e instanceof Error?e.message:String(e)),l(!1)}},g=[[`Workflow`,e.task.workflow],[`Runner`,e.task.runner],[`Model`,e.task.model],[`Effort`,e.task.effort]];return(0,G.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,G.jsxs)(`div`,{className:`grid min-w-0 gap-5`,children:[(0,G.jsxs)(`section`,{className:`min-w-0 rounded-xl border border-card-edge bg-card shadow-card p-4`,children:[(0,G.jsxs)(`p`,{className:`text-sm break-words`,children:[(0,G.jsx)(`span`,{children:r.outcome===`launched`?`Started its task.`:`Cancelled — no task was started.`}),r.runId?(0,G.jsxs)(G.Fragment,{children:[` · `,(0,G.jsx)(I,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${r.runId}`,children:`Open task`})]}):null]}),(0,G.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Archived ${B(r.at,t)} (${t}).`}),a&&i?.timeZone?(0,G.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Was due ${a.date} ${a.time} (${i.timeZone}).`}):null]}),(0,G.jsxs)(`section`,{"aria-labelledby":`archived-inputs`,className:`min-w-0 rounded-xl border border-card-edge bg-card shadow-card p-4`,children:[(0,G.jsx)(`h2`,{id:`archived-inputs`,className:`mb-3 text-[15px] font-medium`,children:`What it ran with`}),(0,G.jsxs)(`dl`,{className:`grid gap-3 text-sm`,children:[(0,G.jsxs)(`div`,{className:`grid gap-1`,children:[(0,G.jsx)(`dt`,{className:`text-muted-foreground`,children:`Prompt`}),(0,G.jsx)(`dd`,{className:`break-words whitespace-pre-wrap`,children:e.task.prompt})]}),g.filter(([,e])=>e).map(([e,t])=>(0,G.jsxs)(`div`,{className:`grid gap-1`,children:[(0,G.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,G.jsx)(`dd`,{className:`break-words`,children:t})]},e))]})]}),(0,G.jsxs)(`section`,{className:`min-w-0`,children:[(0,G.jsx)(Pt,{automationId:e.id,automationName:e.name,timeZone:t,readOnly:!0}),(0,G.jsx)(A,{variant:`outline`,asChild:!0,className:`mt-3`,children:(0,G.jsx)(I,{to:`/automations/${e.id}/log`,children:`Execution log`})})]}),(0,G.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[o?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`p`,{className:`text-sm break-words`,children:`Delete “${e.name}”? Its record and log are removed; the task stays.`}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,G.jsx)(A,{variant:`danger-ghost`,"data-action":`automation-delete-confirm`,disabled:c,onClick:()=>void h(),children:`Delete schedule`}),(0,G.jsx)(A,{ref:p,variant:`outline`,disabled:c,onClick:()=>{m.current=`delete`,s(!1)},children:`Keep`})]})]}):(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,G.jsx)(A,{ref:f,variant:`outline`,"data-action":`automation-delete`,onClick:()=>{m.current=`keep`,s(!0)},children:`Delete`}),(0,G.jsx)(A,{variant:`outline`,asChild:!0,children:(0,G.jsx)(I,{to:`/automations`,children:`Back to automations`})})]}),u?(0,G.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:u}):null]})]})})}var It=D([`pull_request.opened`,`issue.opened`,`issue.labeled`,`issue.unlabeled`]),J=w(E().trim().min(1).max(200)).max(100).optional(),Lt=S({includeExisting:T().optional(),requireCurrentLabels:T().optional(),authors:J,assignees:J,allLabels:J,anyLabels:J,excludeLabels:J,changedLabels:J,lookbackDays:O().int().min(1).max(90).default(7),maxRecords:O().int().min(1).max(100).default(25)}).passthrough(),Rt=S({prompt:E().min(1).max(1e5),workflow:E().trim().min(1).max(200).optional(),steps:w(y).min(1).max(100).optional(),runner:ie.optional(),model:E().trim().min(1).max(200).optional(),effort:E().trim().min(1).max(32).optional(),variants:se([C(1),C(2),C(3)]).optional(),worktree:T().optional(),autonomous:T().optional(),...g,...re,systemPrompt:E().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)))}ue(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??{}}},S({id:E().min(1).max(100),revision:O().int().positive(),name:E().trim().min(1).max(200),description:E().max(2e3).optional(),enabled:T().default(!1),kind:gt.default(`github`),events:w(It).min(1).max(4).optional(),intervalSeconds:O().int().min(60).max(86400).optional(),filters:Lt.optional(),schedule:et.passthrough().optional(),task:Rt,archived:S({at:E().datetime(),outcome:D([`launched`,`cancelled`]),runId:E().optional(),receiptId:E().optional(),trigger:D([`schedule`,`late`,`manual`,`retry`]).optional()}).passthrough().optional(),createdAt:E().datetime(),updatedAt:E().datetime()}).passthrough().superRefine((e,t)=>{if(e.kind===`schedule`){e.schedule||t.addIssue({code:b.custom,path:[`schedule`],message:`a scheduled automation needs a schedule`});return}e.events?.length||t.addIssue({code:b.custom,path:[`events`],message:`a GitHub automation needs at least one event`}),e.intervalSeconds===void 0&&t.addIssue({code:b.custom,path:[`intervalSeconds`],message:`a GitHub automation needs a poll interval`}),e.filters||t.addIssue({code:b.custom,path:[`filters`],message:`a GitHub automation needs its bounded filter`}),e.events?.some(e=>e===`issue.labeled`||e===`issue.unlabeled`)&&!e.filters?.changedLabels?.length&&t.addIssue({code:b.custom,path:[`filters`,`changedLabels`],message:`changedLabels is required for issue label events`})})),S({version:C(1).default(1),automations:w(le()).default([]),tombstones:ce(E(),E().datetime()).optional()}).passthrough();var Y=S({timestamp:E().datetime(),tieBreaker:E().optional()}).passthrough(),Vt=yt.extend({cursor:Y.optional()}),Ht=S({revision:O().int().positive().optional(),baselineAt:E().datetime().optional(),armedAt:E().datetime().optional(),historyScan:Vt.optional(),cursor:Y.optional(),frozenHighWatermark:Y.extend({tieBreaker:E()}).optional(),backlogAfter:Y.extend({tieBreaker:E()}).optional(),nextCheckAt:E().datetime().optional(),lastSuccessAt:E().datetime().optional(),nextRunAt:E().datetime().optional(),lastRunAt:E().datetime().optional(),etags:ce(E(),E()).optional(),backoffUntil:E().datetime().optional(),consecutiveFailures:O().int().nonnegative().optional(),...bt,onceOutcome:D([`failed`,`missed`]).optional()}).passthrough();S({version:C(1).default(1),states:ce(E(),Ht).default({})}).passthrough(),S({receiptId:E().min(1),receiptKey:E().min(1),eventId:E().min(1),automationId:E().min(1),revision:O().int().positive(),status:D([`reserved`,`launched`,`launch-error`,`released`]),runId:E().optional(),observedAt:E().datetime(),updatedAt:E().datetime(),error:E().max(2e3).optional(),occurrenceAt:E().datetime().optional(),candidate:S({eventId:E(),event:It,timestamp:E().datetime(),tieBreaker:E(),repo:E(),nodeId:E(),number:O().int().positive(),title:E().max(500),url:E().url(),author:E().max(200),assignees:w(E().max(200)).max(100),labels:w(E().max(200)).max(100),changedLabel:E().max(200).optional()}).passthrough().optional()}).passthrough();var Ut=D([`launched`,`no-match`,`duplicate`,`rate-limited`,`error`,`baseline`,`preview`,`skipped`,`manual`,`catch-up`,`failed`,`missed`]);S({seq:O().int().positive(),ts:E().datetime(),automationId:E().min(1),revision:O().int().positive(),event:It.optional(),result:Ut,reason:E().max(2e3).optional(),durationMs:O().int().nonnegative().optional(),receiptId:E().optional(),runId:E().optional(),githubNumber:O().int().positive().optional(),githubTitle:E().max(500).optional(),githubUrl:E().url().optional(),rateLimit:S({bucket:D([`core`,`search`]),remaining:O().int().nonnegative().optional(),resetAt:E().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??[H.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 X(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 Z(e,t){return t.startsWith(`-`)?`--${e}=${X(t)}`:`--${e} ${X(t)}`}function nn(e){let t=[`${We()} automation add`,Z(`name`,e.name)];if(e.schedule?.type===`once`)t.push(Z(`at`,e.schedule.at),Z(`tz`,e.schedule.timeZone)),e.schedule.latestStartMinutes!==void 0&&t.push(Z(`latest-start`,tn(e.schedule.latestStartMinutes)));else if(e.kind===`schedule`)t.push(Z(`cron`,ot(e.schedule)));else{t.push(Z(`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(Z(`label`,n));for(let n of e.filters?.authors??[])t.push(Z(`author`,n));for(let n of e.filters?.changedLabels??[])t.push(Z(`changed-label`,n))}return t.push(...rn(e.task)),e.enable===!0&&t.push(`--enable`),t.push(Z(`prompt`,e.task.prompt)),t.join(` `)}function rn(e){let t=[];return e.workflow&&t.push(Z(`workflow`,e.workflow)),e.runner&&t.push(Z(`runner`,e.runner)),e.model&&t.push(Z(`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 ${X(JSON.stringify(n))}`;return t?`CEZ_COCKPIT_URL=${X(t.origin)} CEZ_PROJECT_ID=${X(t.projectId)} HSQ_COCKPIT_URL=${X(t.origin)} HSQ_PROJECT_ID=${X(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
- `)}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}){let t=ke(),n=window.location.origin,i=(0,V.useMemo)(()=>{let r=an(e);return t?`HSQ_COCKPIT_URL=${X(n)} HSQ_PROJECT_ID=${X(t)} ${r}`:r},[e,n,t]),a=(0,V.useMemo)(()=>on(i),[i]),[o,s]=(0,V.useState)(`idle`),[c,l]=(0,V.useState)(!1),u=(0,V.useId)(),d=(0,V.useRef)(void 0);(0,V.useEffect)(()=>()=>clearTimeout(d.current),[]),(0,V.useEffect)(()=>s(`idle`),[i]);let f=async()=>{clearTimeout(d.current);try{await navigator.clipboard.writeText(a),s(`copied`),d.current=setTimeout(()=>s(`idle`),1600)}catch{s(`failed`)}};return(0,G.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,G.jsxs)(`div`,{className:`flex min-h-8 min-w-0 flex-nowrap items-center justify-between gap-x-2`,children:[(0,G.jsx)(`h2`,{id:`copy-as-cli-heading`,className:`shrink-0 text-[13px] font-medium text-muted-foreground`,children:`Copy as CLI`}),(0,G.jsxs)(A,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`copy-as-cli-toggle`,"aria-expanded":c,"aria-controls":u,"aria-label":c?`Hide command`:`Show command`,className:`min-w-0 shrink gap-1 px-1.5 text-[12px] font-medium max-md:h-11 no-hover:h-11`,onClick:()=>l(e=>!e),children:[(0,G.jsx)(`span`,{className:`truncate`,children:c?`Hide`:`Show`}),(0,G.jsx)(Se,{"aria-hidden":`true`,className:r(`size-3.5 transition-transform`,c&&`rotate-180`)})]}),(0,G.jsxs)(A,{type:`button`,variant:`outline`,size:`sm`,className:`ms-auto gap-1.5 px-2 text-[12px] font-medium max-md:h-11 no-hover:h-11`,onClick:()=>void f(),children:[o===`copied`?(0,G.jsx)(Ce,{"aria-hidden":`true`,className:`size-3.5`}):(0,G.jsx)(Ke,{"aria-hidden":`true`,className:`size-3.5`}),o===`copied`?`Copied`:`Copy`]})]}),(0,G.jsx)(`div`,{id:u,hidden:!c,className:`mbs-2 max-w-full rounded-lg border border-border bg-muted has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-ring`,children:(0,G.jsx)(`pre`,{"data-slot":`copy-as-cli-line`,tabIndex:0,"aria-label":`Command line`,className:`m-0 max-w-full px-3 pt-2.5 pb-3 font-mono text-xs leading-5 break-all whitespace-pre-wrap text-muted-foreground outline-none`,children:a})}),(0,G.jsx)(`p`,{role:`status`,className:`mbs-2 text-xs break-words text-muted-foreground`,children:o===`failed`?`Could not copy — select the line and copy it by hand.`:(0,G.jsxs)(G.Fragment,{children:[`The definition Save paused would create. `,(0,G.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:i}){return(0,G.jsx)(`button`,{type:`button`,"aria-pressed":e,disabled:n,onClick:t,className:r(`inline-flex min-h-11 items-center justify-center rounded-md border px-3.5 text-[13px] font-medium transition-colors outline-hidden focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50`,e?`border-border bg-card font-semibold text-foreground shadow-xs`:`border-transparent bg-transparent text-muted-foreground hover:text-foreground`),children:i})}var 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=H.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,G.jsxs)(`div`,{className:`grid gap-4`,children:[n?(0,G.jsx)(`p`,{className:`text-xs text-pending-strong`,children:`GitHub unavailable · ${n}`}):null,(0,G.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,G.jsx)(ln,{pressed:e.events.includes(t),onClick:()=>r(t),children:dn[t]},t))}),(0,G.jsxs)(`div`,{className:`grid gap-2`,children:[(0,G.jsx)(k,{htmlFor:`automation-interval`,children:`Check every`}),(0,G.jsxs)(F,{value:String(e.intervalSeconds),onValueChange:e=>t({intervalSeconds:Number(e)}),children:[(0,G.jsx)(M,{id:`automation-interval`,className:`w-full sm:w-48`,"aria-label":`Check every`,children:(0,G.jsx)(j,{})}),(0,G.jsx)(N,{children:o.map(e=>(0,G.jsx)(P,{value:String(e.seconds),children:e.label},e.seconds))})]})]}),(0,G.jsxs)(`div`,{className:`grid gap-2`,children:[(0,G.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm`,children:[(0,G.jsx)(De,{"aria-label":`Include existing items`,"aria-describedby":`automation-history-hint`,checked:e.filters.includeExisting??!1,onCheckedChange:e=>i({includeExisting:e})}),(0,G.jsx)(`span`,{children:`Include existing items`})]}),(0,G.jsx)(`p`,{id:`automation-history-hint`,className:`text-xs text-muted-foreground`,children:vn(e.filters.includeExisting)})]}),(0,G.jsxs)(Ee,{children:[(0,G.jsxs)(Te,{className:`group flex min-h-11 items-center gap-2 text-sm font-medium`,children:[`Filters`,(0,G.jsx)(Se,{"aria-hidden":`true`,className:`size-4 text-soft-foreground transition-transform motion-reduce:transition-none group-data-[state=open]:rotate-180`})]}),(0,G.jsx)(we,{children:(0,G.jsxs)(`div`,{className:`grid gap-4 pt-2 sm:grid-cols-2`,children:[hn.map(t=>(0,G.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,G.jsx)(k,{htmlFor:`automation-filter-${t.key}`,children:t.label}),(0,G.jsx)(z,{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,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.hint}):null]},t.key)),(0,G.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,G.jsx)(k,{htmlFor:`automation-filter-lookback`,children:`Look back (days)`}),(0,G.jsx)(z,{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,G.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,G.jsx)(k,{htmlFor:`automation-filter-max`,children:`Max records per check`}),(0,G.jsx)(z,{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 Q({label:e,value:t,max:n,onCommit:r}){let[i,a]=(0,V.useState)(xn(t)),o=(0,V.useRef)(null),s=!(/^\d{1,2}$/.test(i)&&Number(i)===t),c=`${e} must be 00–${xn(n)}.`,l=(0,V.useId)();return(0,V.useEffect)(()=>{o.current?.setCustomValidity(s?c:``)},[s,c]),(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(z,{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,G.jsx)(`p`,{id:l,className:`order-last basis-full text-xs text-destructive`,children:c}):null]})}var Sn=[{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`}],Cn=`none`,wn=e=>String(e).padStart(2,`0`);function Tn(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()}-${wn(r.getUTCMonth()+1)}-${wn(r.getUTCDate())}T09:00`}function En(){let e=typeof Intl.supportedValuesOf==`function`?Intl.supportedValuesOf(`timeZone`):[];return e.includes(`UTC`)?e:[`UTC`,...e]}function Dn({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${wn(t)}:${wn(n)}`}),l=(0,V.useRef)(null),u=(0,V.useId)(),d=nt(e),f=!(t?.type===`once`&&t.at===e.at&&t.timeZone===e.timeZone)&&d!==null&&d<=Date.now();(0,V.useEffect)(()=>{l.current?.setCustomValidity(f?$e:``)},[f]);let p=dt(e);return(0,G.jsxs)(`div`,{className:`grid gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-end gap-x-4 gap-y-3`,children:[(0,G.jsxs)(`div`,{className:`grid gap-2`,children:[(0,G.jsx)(k,{htmlFor:`automation-once-date`,children:`Date`}),(0,G.jsx)(z,{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,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`at`}),(0,G.jsx)(Q,{label:`Hour`,value:o,max:23,onCommit:e=>c(a,e,s)}),(0,G.jsx)(`span`,{"aria-hidden":`true`,children:`:`}),(0,G.jsx)(Q,{label:`Minute`,value:s,max:59,onCommit:e=>c(a,o,e)})]})]}),f?(0,G.jsx)(`p`,{id:u,className:`text-xs text-destructive`,children:$e}):null,(0,G.jsx)(kn,{value:e.timeZone??``,onCommit:e=>r({timeZone:e})}),(0,G.jsx)(An,{value:e.latestStartMinutes,onChange:t=>n(On(e,t))}),p?(0,G.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 On(e,t){let{latestStartMinutes:n,...r}=e;return t===void 0?r:{...r,latestStartMinutes:t}}function kn({value:e,onCommit:t}){let[n,r]=(0,V.useState)(e),i=(0,V.useRef)(null),a=(0,V.useId)(),o=(0,V.useId)(),[s]=(0,V.useState)(En),c=n!==e||!Qe(n),l=rt(n);return(0,V.useEffect)(()=>{i.current?.setCustomValidity(c?l:``)},[c,l]),(0,G.jsxs)(`div`,{className:`grid gap-2`,children:[(0,G.jsx)(k,{htmlFor:`automation-once-zone`,children:`Time zone`}),(0,G.jsx)(z,{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,G.jsx)(`datalist`,{id:a,children:s.map(e=>(0,G.jsx)(`option`,{value:e},e))}),c?(0,G.jsx)(`p`,{id:o,className:`text-xs break-words text-destructive`,children:l}):null]})}function An({value:e,onChange:t}){let n=Sn.some(t=>t.minutes===e)||e===void 0?Sn:[...Sn,{minutes:e,label:`${e} minutes`}];return(0,G.jsxs)(`div`,{className:`grid gap-2`,children:[(0,G.jsx)(k,{htmlFor:`automation-once-latest`,children:`Latest start`}),(0,G.jsxs)(F,{value:e===void 0?Cn:String(e),onValueChange:e=>t(e===Cn?void 0:Number(e)),children:[(0,G.jsx)(M,{id:`automation-once-latest`,className:`w-full sm:w-48`,"aria-label":`Latest start`,children:(0,G.jsx)(j,{})}),(0,G.jsx)(N,{children:n.map(e=>(0,G.jsx)(P,{value:e.minutes===void 0?Cn:String(e.minutes),children:e.label},e.label))})]}),(0,G.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 jn=[{type:`daily`,label:`Every day`},{type:`weekdays`,label:`Weekdays`},{type:`weekly`,label:`Weekly`},{type:`hours`,label:`Every N hours`},{type:`once`,label:`Once`}];function Mn({value:e,stored:t,onChange:n,timeZone:r}){let i=t=>n({...e,...t}),a=t=>i(t===`once`?{type:t,at:e.at??Tn(r),timeZone:e.timeZone??r}:{type:t});return(0,G.jsxs)(`div`,{className:`grid gap-4`,children:[(0,G.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:jn.map(t=>(0,G.jsx)(ln,{pressed:e.type===t.type,onClick:()=>a(t.type),children:t.label},t.type))}),e.type===`once`?(0,G.jsx)(Dn,{value:e,stored:t,onChange:n}):null,e.type===`weekly`?(0,G.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,G.jsx)(ln,{pressed:e.day===n+1,onClick:()=>i({day:n+1}),children:t},t))}):null,e.type===`once`?null:e.type===`hours`?(0,G.jsxs)(`div`,{className:`grid gap-2`,children:[(0,G.jsx)(k,{htmlFor:`automation-every`,children:`Run every`}),(0,G.jsxs)(F,{value:String(e.every),onValueChange:e=>i({every:Number(e)}),children:[(0,G.jsx)(M,{id:`automation-every`,className:`w-full sm:w-48`,"aria-label":`Run every`,children:(0,G.jsx)(j,{})}),(0,G.jsx)(N,{children:lt.map(e=>(0,G.jsx)(P,{value:String(e),children:e===1?`hour`:`${e} hours`},e))})]}),(0,G.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,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`at`}),(0,G.jsx)(Q,{label:`Hour`,value:e.hour,max:23,onCommit:e=>i({hour:e})}),(0,G.jsx)(`span`,{"aria-hidden":`true`,children:`:`}),(0,G.jsx)(Q,{label:`Minute`,value:e.minute,max:59,onCommit:e=>i({minute:e})}),(0,G.jsx)(`span`,{className:`text-sm break-all text-muted-foreground`,children:r})]}),e.type===`once`?null:(0,G.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Cron: `,(0,G.jsx)(`code`,{className:`font-mono text-foreground`,children:ot(e)})]})]})}var Nn=40*864e5,Pn=5;function Fn({schedule:e,timeZone:t,now:n=Date.now()}){if(e.type===`once`)return(0,G.jsx)(In,{schedule:e,now:n});let r=tt(e,n+1,n+Nn,t,Pn);return(0,G.jsxs)(`section`,{"aria-labelledby":`next-runs-heading`,"data-slot":`next-runs`,className:`min-w-0 rounded-xl border bg-card p-5`,children:[(0,G.jsx)(`h2`,{id:`next-runs-heading`,className:`mb-2 text-base font-semibold`,children:`Next 5 runs`}),r.length===0?(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No runs in the next 40 days.`}):(0,G.jsx)(`ol`,{"aria-label":`Next 5 runs`,className:`grid divide-y divide-border text-sm`,children:r.map((e,r)=>(0,G.jsxs)(`li`,{className:`flex min-h-10 items-center justify-between gap-3 py-1.5`,children:[(0,G.jsx)(`span`,{className:r===0?`font-semibold tabular-nums text-foreground`:`font-medium tabular-nums`,children:B(new Date(e).toISOString(),t)}),(0,G.jsx)(`span`,{className:r===0?`font-medium text-accent-text`:`text-muted-foreground`,children:at(n,e)})]},e))}),(0,G.jsxs)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:[`Times are in `,t,`, the zone this Squawk runs in.`]})]})}function In({schedule:e,now:t}){let n=nt(e),r=dt(e);return(0,G.jsxs)(`section`,{"aria-labelledby":`next-runs-heading`,"data-slot":`next-runs`,className:`min-w-0 rounded-xl border bg-card p-5`,children:[(0,G.jsx)(`h2`,{id:`next-runs-heading`,className:`mb-3 text-base font-semibold`,children:`Runs once`}),n===null||!r?(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Pick a date, a time and a time zone.`}):(0,G.jsxs)(`p`,{className:`flex flex-wrap items-baseline justify-between gap-x-3 text-sm`,children:[(0,G.jsx)(`span`,{className:`font-medium tabular-nums`,children:`${r.date} ${r.time}`}),n>t?(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:at(t,n)}):null]}),r?.note?(0,G.jsx)(`p`,{className:`mt-2 text-sm break-words`,children:r.note}):null,n!==null&&n<=t?(0,G.jsx)(`p`,{className:`mt-2 text-sm text-destructive`,children:`The due time has passed.`}):null,(0,G.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 Ln={schedule:`On a schedule`,github:`When GitHub changes`};function Rn(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 zn({title:e,icon:t,hideLegend:n=!1,failure:r,section:i,children:a}){let o=(0,V.useId)();return(0,G.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,G.jsxs)(`h2`,{id:o,className:`flex items-center gap-2 text-base font-semibold text-foreground`,children:[t,e]}):(0,G.jsx)(`h2`,{id:o,className:`text-sm font-semibold text-foreground`,children:e}),a,r?.section===i&&!r.conflict?(0,G.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:r.message}):null]})}function Bn({draft:e,patch:t,forge:n,automation:r}){return(0,G.jsx)(G.Fragment,{children:r?(0,G.jsxs)(`p`,{className:`text-sm`,children:[(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`Trigger · `}),Ln[e.kind]]}):(0,G.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[(0,G.jsx)(Ye,{slot:`automation-kind`,label:`Trigger`,size:`touch`,value:e.kind,onChange:e=>t({kind:e}),options:[{value:`schedule`,label:Ln.schedule},{value:`github`,label:Ln.github,disabled:!n.available,...n.available?{}:{title:n.reason??`GitHub is unavailable`}}]}),n.available?null:(0,G.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:`GitHub unavailable · ${n.reason??`no GitHub access`}`})]})})}function Vn({draft:e,patch:t,forge:n,timeZone:r,automation:i}){return e.kind===`schedule`?(0,G.jsx)(Mn,{value:e.schedule,stored:i?.schedule,onChange:e=>t({schedule:e}),timeZone:r}):(0,G.jsx)(bn,{draft:e,onChange:t,...n.available?{}:{disabledReason:n.reason??`no GitHub access`}})}function Hn({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,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,G.jsx)(k,{htmlFor:`automation-prompt`,children:`Prompt`}),(0,G.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,G.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:e.kind===`schedule`?(0,G.jsxs)(G.Fragment,{children:[`Available: `,`{{date}}`,` `,`{{time}}`,` `,`{{project}}`,` `,`{{automation}}`,`. A run-context block is appended automatically.`]}):(0,G.jsxs)(G.Fragment,{children:[`Available: `,`{{github.number}}`,` `,`{{github.title}}`,` `,`{{github.url}}`,` `,`{{github.labels}}`,`. GitHub content is appended as untrusted context.`]})})]}),r.length?(0,G.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:`Unavailable for this trigger: ${r.map(e=>`{{${e}}}`).join(`, `)}`}):null,(0,G.jsx)(Yn,{draft:e,patch:t})]})}function Un({label:e,help:t,checked:n,onChange:r}){let i=(0,V.useId)();return(0,G.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,G.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,G.jsx)(`span`,{id:`${i}-label`,children:e}),(0,G.jsx)(`span`,{id:`${i}-help`,className:`completion-control-help`,children:t})]}),(0,G.jsx)(De,{id:i,className:`completion-switch shrink-0`,checked:n,"aria-labelledby":`${i}-label`,"aria-describedby":`${i}-help`,onCheckedChange:r})]})}function Wn({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,G.jsxs)(G.Fragment,{children:[(0,G.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,G.jsxs)(`div`,{"data-embedded":``,className:`grid min-w-0`,children:[(0,G.jsx)(Un,{label:`Autonomous`,help:`Runs without waiting for answers.`,checked:e.autonomous,onChange:e=>t({autonomous:e})}),(0,G.jsx)(Ge,{embedded:!0,archiveWhenDone:e.archiveWhenDone,autoMergePr:e.autoMergePr,onChange:t,disabled:n}),(0,G.jsx)(ze,{embedded:!0,allowWorkers:e.allowWorkers,allowMessaging:e.allowMessaging,onChange:t,disabled:n}),(0,G.jsx)(Un,{label:a,help:o,checked:e.enabled,onChange:e=>t({enabled:e})})]}),r?(0,G.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:`These settings apply to future tasks. Existing tasks keep their settings.`}):null]})}function Gn({automation:e,forge:t,timeZone:n,onSaved:r,onReload:i}){let[a,o]=(0,V.useState)(()=>Gt(e)),[s,c]=(0,V.useState)(e?.revision),[l,u]=(0,V.useState)(),[p,h]=(0,V.useState)(!1),g=e=>o(t=>({...t,...e})),_=async t=>{if(t.preventDefault(),p)return;let n=t.currentTarget;if(n instanceof HTMLFormElement&&!n.checkValidity()){n.reportValidity();return}h(!0),u(void 0);let i=`save`;try{if(e&&s!==void 0){let{automation:t}=await f(e.id,Xt({...a,enabled:e.enabled},s));c(t.revision),a.enabled!==e.enabled&&(i=`enable`,await m(e.id,a.enabled))}else await ee(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`:Rn(n),message:n})}finally{h(!1)}},v=(0,V.useId)(),y=(0,V.useId)(),b=a.kind===`schedule`;return(0,G.jsx)(Ne,{route:`automations`,density:a.name.trim()===``&&a.prompt.trim()===``?`sparse`:`full`,header:Jn({automation:e,draft:a,formId:v,saveHintId:y,saving:p}),children:(0,G.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,G.jsxs)(`div`,{className:`grid min-w-0 gap-3.5`,children:[(0,G.jsx)(zn,{title:`Name`,hideLegend:!0,section:`name`,failure:l,children:(0,G.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,G.jsx)(k,{htmlFor:`automation-name`,className:`text-sm font-semibold text-foreground`,children:`Name`}),(0,G.jsx)(z,{id:`automation-name`,className:`border-border`,value:a.name,placeholder:`Daily dependency audit`,onChange:e=>g({name:e.target.value}),required:!0})]})}),(0,G.jsxs)(zn,{title:`When`,section:`when`,failure:l,children:[(0,G.jsx)(Bn,{draft:a,patch:g,forge:t,automation:e}),(0,G.jsx)(Vn,{draft:a,patch:g,forge:t,timeZone:n,automation:e})]}),(0,G.jsx)(zn,{title:`What to run`,section:`run`,failure:l,children:(0,G.jsx)(Hn,{draft:a,patch:g})})]}),(0,G.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,G.jsx)(zn,{title:`Execution settings`,icon:(0,G.jsx)(xe,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),section:`execution`,failure:l,children:(0,G.jsx)(Wn,{draft:a,patch:g,saving:p,automation:e})}),b?(0,G.jsx)(Fn,{schedule:a.schedule,timeZone:n}):(0,G.jsxs)(`section`,{className:`min-w-0 rounded-xl border border-card-edge bg-card shadow-card p-5`,children:[(0,G.jsx)(`h2`,{className:`mb-2 text-base font-semibold`,children:`How it polls`}),(0,G.jsx)(`p`,{className:`text-sm break-words text-muted-foreground`,children:yn(a)})]}),(0,G.jsx)(cn,{draft:a})]}),l?.section===`form`||e?(0,G.jsxs)(`div`,{className:`grid min-w-0 gap-3.5 md:col-start-1`,children:[l?.section===`form`?(0,G.jsxs)(`div`,{role:`alert`,className:`flex flex-wrap items-center gap-3 text-sm text-destructive`,children:[(0,G.jsx)(`span`,{className:`break-words`,children:l.message}),l.conflict&&i?(0,G.jsx)(A,{type:`button`,variant:`outline`,onClick:i,children:`Reload`}):null]}):null,e?(0,G.jsx)(Kn,{automation:e,onDeleted:r}):null]}):null]})})}function Kn({automation:e,onDeleted:t}){let[n,r]=(0,V.useState)(!1),[i,a]=(0,V.useState)(!1),[o,s]=(0,V.useState)(``),c=async()=>{if(!i){a(!0),s(``);try{await _(e.id),t()}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(!1)}}};return(0,G.jsxs)(`div`,{className:`grid justify-items-start gap-2 border-t pt-4`,children:[n?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`p`,{className:`text-sm break-words`,children:`Delete “${e.name}”? It will stop running and cannot be restored.`}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,G.jsx)(A,{type:`button`,variant:`danger-ghost`,"data-action":`automation-delete-confirm`,disabled:i,onClick:()=>void c(),children:`Delete automation`}),(0,G.jsx)(A,{type:`button`,variant:`outline`,disabled:i,onClick:()=>{r(!1),s(``)},children:`Keep`})]})]}):(0,G.jsx)(A,{type:`button`,variant:`outline`,"data-action":`automation-delete`,onClick:()=>r(!0),children:`Delete`}),o?(0,G.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:o}):null]})}function qn(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 Jn({automation:e,draft:t,formId:n,saveHintId:r,saving:i}){let a=t.name.trim()?t.prompt.trim()?``:`Prompt`:`Name`,o=qn(t),s=e?`Save changes`:t.enabled?`Save and enable`:`Save paused`;return{title:e?`Edit automation`:`New automation`,subtitle:`Define when it runs and the ordinary task it launches.`,status:(0,G.jsx)(`p`,{id:r,"data-slot":`automation-save-hint`,className:`min-h-[1lh] text-xs text-muted-foreground`,children:o}),secondaryActions:(0,G.jsx)(L,{type:`button`,variant:`outline`,asChild:!0,children:(0,G.jsx)(I,{to:`/automations`,children:`Cancel`})}),primaryAction:(0,G.jsx)(L,{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 Yn({draft:e,patch:t}){let n=i(),r=Xe(),{runners:u,signedOut:d}=r.runnersOn(e=>r.repoAccount?.[e]),f=a(),p=s(),{runner:m,ready:h}=o(e.runner??f.data?.defaultRunner??`claude`),g=c(m,h,r.repoAccount?.[m]),ee=[...new Set([...(n.data?.workflows??[]).map(e=>e.name),...e.workflow?[e.workflow]:[]])],_=[...new Set([...u,...e.runner?[e.runner]:[]])],v=Be(m,p.data,g.data,[e.model]),y=v.find(t=>t.id===(e.model??``))?.label??e.model??`Runner default`,b=e=>(0,G.jsx)(e,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`});return(0,G.jsx)(qe,{children:(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,G.jsx)(Re,{slot:`automation-workflow-pill`,icon:b(ye),fieldLabel:!0,ariaLabel:`Workflow`,label:e.workflow??`inline steps`,value:e.workflow??``,disabled:e.workflow===void 0,disabledHint:`This automation carries its own steps.`,options:ee.map(e=>({value:e,label:e})),onPick:e=>t({workflow:e})}),(0,G.jsx)(Re,{slot:`automation-runner-pill`,icon:b(_e),fieldLabel:!0,ariaLabel:`Runner`,label:e.runner?l(p.data,e.runner):`default`,value:e.runner??``,disabled:!p.data,options:[{value:``,label:`default`,desc:`The project’s default runner`},..._.map(e=>({value:e,label:l(p.data,e)}))],footer:(0,G.jsx)(Ue,{uninstalled:r.uninstalled,signedOut:d.filter(t=>t!==e.runner)}),onPick:e=>{t({runner:e||void 0,model:void 0})}}),(0,G.jsx)(Re,{slot:`automation-model-pill`,icon:b(ve),fieldLabel:!0,ariaLabel:`Model`,label:y,value:e.model??``,options:v.map(e=>({value:e.id,label:e.label,desc:e.desc})),onPick:e=>t({model:e||void 0})})]})})}function Xn(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 Zn({data:e,error:t,refresh:n,archived:i=!1,onArchivedChange:a}){let[o,s]=(0,V.useState)({}),[c,l]=(0,V.useState)({}),d=(e,t)=>s(n=>{let{[e]:r,...i}=n;return t?{...i,[e]:t}:i}),f=async(e,t,n=!1)=>{l(t=>({...t,[e]:!0}));try{await t()}catch(t){let r=t instanceof Error?t.message:String(t);d(e,n?Xn(r):{text:r,tone:`error`})}finally{l(t=>({...t,[e]:!1}))}},p=e=>f(e.id,async()=>{d(e.id,{text:`Starting…`,tone:`info`});let{runId:t}=await u(e.id);d(e.id,{text:`Started task`,tone:`info`,runId:t}),n()}),h=e=>f(e.id,async()=>{d(e.id,void 0),await m(e.id,!e.enabled),await n()}),g=e=>f(e.id,async()=>{d(e.id,void 0),await te(e.id),await n()}),ee=e=>f(e.id,async()=>{d(e.id,{text:`Checking…`,tone:`info`});let{checkId:t}=await ne(e.id,`preview`);for(let r=0;r<60;r+=1){let r=await v(t);if(r.status===`complete`){d(e.id,{text:`${r.matches??0} filter match${r.matches===1?``:`es`} found; no tasks launched. Counts can include closed items and previously processed events.`,tone:`info`}),n();return}if(r.status===`error`){let t=r.error??`Preview failed`;d(e.id,Xn(t));return}await new Promise(e=>setTimeout(e,500))}throw Error(`Preview is still running`)},!0),_=e?.automations??[],y=_.filter(e=>!e.archived),b=_.filter(e=>!!e.archived),x=i?b:y;return(0,G.jsx)(R,{route:`automations`,density:e?Ae(x.length):`full`,headerSpacing:`compact`,header:{title:`Automations`,subtitle:`Schedules and GitHub checks run while Squawk is open.`,primaryAction:(0,G.jsx)(L,{variant:`primary`,asChild:!0,children:(0,G.jsxs)(I,{to:`/automations/new`,children:[(0,G.jsx)(ge,{"aria-hidden":`true`,className:`size-4`}),`New automation`]})})},sparseFooter:e&&x.length>0&&!i?(0,G.jsx)(Me,{summary:`${x.length} active ${x.length===1?`automation`:`automations`} configured. New automations start paused so you can test filters before enabling them.`,actions:(0,G.jsx)(A,{variant:`outline`,size:`sm`,asChild:!0,className:`max-md:min-h-11`,children:(0,G.jsx)(I,{to:`/automations/new`,children:`Add another`})})}):void 0,children:t&&!e?(0,G.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,G.jsx)(K,{text:t}),(0,G.jsx)(A,{variant:`outline`,onClick:()=>void n(),children:`Retry`})]}):e?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-end justify-between gap-3 border-b border-border`,children:[a?(0,G.jsxs)(`div`,{className:`flex gap-6`,role:`group`,"aria-label":`Filter automations`,children:[(0,G.jsxs)(`button`,{type:`button`,"data-slot":`automations-tab`,"data-view":`active`,"aria-pressed":!i,onClick:()=>a(!1),className:r(`-mb-px flex min-h-11 items-center justify-center gap-1.5 border-b-2 border-transparent text-[13px] font-medium text-muted-foreground transition-colors hover:text-foreground`,!i&&`border-accent-text text-foreground`),children:[`Current`,(0,G.jsx)(Qn,{count:y.length})]}),(0,G.jsxs)(`button`,{type:`button`,"data-slot":`automations-tab`,"data-view":`archived`,"aria-pressed":i,onClick:()=>a(!0),className:r(`-mb-px flex min-h-11 items-center justify-center gap-1.5 border-b-2 border-transparent text-[13px] font-medium text-muted-foreground transition-colors hover:text-foreground`,i&&`border-accent-text text-foreground`),children:[`Archived`,(0,G.jsx)(Qn,{count:b.length})]})]}):(0,G.jsx)(`span`,{}),(0,G.jsx)(`div`,{className:`pb-2.5`,children:(0,G.jsx)($n,{data:e})})]}),i&&x.length===0?(0,G.jsx)(K,{text:`No archived automations.`}):x.length===0?(0,G.jsx)(Fe,{icon:(0,G.jsx)(be,{}),tone:`neutral`,title:`No automations yet`,subtitle:`Create one paused, preview it, then enable it.`,heading:`h2`,actions:(0,G.jsx)(A,{variant:`primary`,asChild:!0,children:(0,G.jsxs)(I,{to:`/automations/new`,children:[(0,G.jsx)(ge,{"aria-hidden":`true`,className:`size-4`}),`New automation`]})})}):(0,G.jsx)(`ul`,{className:`grid gap-3`,"aria-label":`Automations`,children:x.map(t=>(0,G.jsx)(cr,{automation:t,timeZone:e.timeZone,note:o[t.id],busy:c[t.id]===!0,onRun:()=>void p(t),onToggle:()=>void h(t),onPreview:()=>void ee(t),onCancel:()=>void g(t)},t.id))})]}):(0,G.jsx)(K,{text:`Loading automations…`})})}function Qn({count:e}){return e===0?null:(0,G.jsx)(`span`,{"data-slot":`automations-tab-count`,className:`tabular-nums text-muted-foreground`,children:`· ${e}`})}function $n({data:e}){return(0,G.jsx)(`p`,{"data-slot":`automation-scheduler`,className:r(`text-xs break-words`,e.scheduler.state===`scheduled`?`text-success`:`text-muted-foreground`),children:`Scheduler ${e.scheduler.state===`scheduled`?`running`:`idle`} · GitHub ${e.available?`available`:`unavailable`}${e.reason?` · ${e.reason}`:``} · ${e.timeZone}`})}function er(e){return e.kind===`schedule`&&e.schedule?it(e.schedule):`${fn(e.events??[])} · every ${Math.round((e.intervalSeconds??300)/60)} min`}function tr({automation:e,nextRun:t}){let n=e.kind===`schedule`?he:me,r=Ve(e);return(0,G.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`h2`,{className:`flex items-center gap-2 font-semibold break-words`,children:[(0,G.jsx)(n,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`}),e.name]}),(0,G.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,G.jsx)(`span`,{children:er(e)}),t?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),t]}):null]})]}),(0,G.jsx)(Je,{dot:r.tone,shape:r.shape,pulse:r.pulse,children:r.label})]})}function nr({automation:e,archive:t}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`p`,{className:`text-sm break-words`,children:[t.outcome===`launched`?`Started its task.`:`Cancelled — no task was started.`,t.runId?(0,G.jsxs)(G.Fragment,{children:[` · `,(0,G.jsx)(I,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${t.runId}`,children:`Open task`})]}):null]}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,G.jsx)(A,{variant:`outline`,asChild:!0,children:(0,G.jsx)(I,{to:`/automations/${e.id}`,children:`Details`})})})]})}function rr({automation:e,timeZone:t}){let n=e.kind===`schedule`,r=e.enabled&&n?e.nextRunAt:void 0;return!n&&e.enabled?(0,G.jsx)(`span`,{children:`continuous`}):r?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`text-foreground`,children:`Next run: ${B(r,t)}`}),(0,G.jsx)(`span`,{children:`· ${at(Date.now(),Date.parse(r))}`})]}):(0,G.jsx)(`span`,{children:`Next run: —`})}function ir({automation:e,timeZone:t}){let n=e.enabled?St(e.state):void 0;return n?(0,G.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,G.jsx)(`span`,{className:`text-muted-foreground`,children:` · Next try ${B(n.retryAt,t)}`}):null]}):null}var $=`h-8 px-3 max-md:h-11 no-hover:h-11`;function ar({automation:e,busy:t,confirmingCancel:n,cancelRef:i,onToggle:a,onRun:o,onPreview:s,onOpenCancel:c}){let l=e.kind===`schedule`,u=e.schedule?.type===`once`;return(0,G.jsxs)(`div`,{"data-slot":`automation-actions`,className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(A,{variant:`outline`,size:`sm`,className:$,"data-action":`automation-toggle`,disabled:t,onClick:a,children:e.enabled?`Pause`:`Enable`}),l?(0,G.jsx)(A,{variant:`outline`,size:`sm`,className:$,"data-action":`automation-run`,disabled:t,onClick:o,children:`Run now`}):(0,G.jsx)(A,{variant:`outline`,size:`sm`,className:$,"data-action":`automation-preview`,disabled:t,onClick:s,children:`Test filter`}),(0,G.jsx)(A,{variant:`outline`,size:`sm`,className:$,asChild:!0,children:(0,G.jsx)(I,{to:`/automations/${e.id}`,children:`Edit`})}),u&&!n?(0,G.jsx)(A,{variant:`outline`,size:`sm`,className:r($,`text-destructive`),ref:i,"data-action":`automation-cancel`,disabled:t,onClick:c,children:`Cancel`}):null,(0,G.jsx)(A,{variant:`outline`,size:`sm`,className:r($,`sm:ms-auto`),asChild:!0,children:(0,G.jsx)(I,{to:`/automations/${e.id}/log`,children:`Execution log`})})]})}function or({automation:e,busy:t,keepRef:n,onConfirm:r,onKeep:i}){return(0,G.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[(0,G.jsx)(`p`,{className:`text-sm break-words`,children:`Cancel “${e.name}”? It will never run, and it moves to Archived.`}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,G.jsx)(A,{variant:`danger-ghost`,"data-action":`automation-cancel-confirm`,disabled:t,onClick:r,children:`Cancel schedule`}),(0,G.jsx)(A,{ref:n,variant:`outline`,disabled:t,onClick:i,children:`Keep`})]})]})}function sr({note:e}){return(0,G.jsxs)(`div`,{role:e.tone===`error`?`alert`:`status`,className:r(`text-sm break-words`,e.tone===`error`?`text-destructive`:`text-muted-foreground`),children:[e.text,e.details?(0,G.jsxs)(G.Fragment,{children:[` · `,(0,G.jsx)(fe,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:Pe(`gh`),children:`Set up`}),(0,G.jsxs)(`details`,{children:[(0,G.jsx)(`summary`,{className:`min-h-11 cursor-pointer`,children:`Command details`}),(0,G.jsx)(`pre`,{className:`whitespace-pre-wrap break-words`,children:e.details})]})]}):null,e.runId?(0,G.jsxs)(G.Fragment,{children:[` · `,(0,G.jsx)(I,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${e.runId}`,children:`Open task`})]}):null]})}function cr({automation:e,timeZone:t,note:n,busy:r,onRun:i,onToggle:a,onPreview:o,onCancel:s}){let[c,l]=(0,V.useState)(!1),u=(0,V.useRef)(null),d=(0,V.useRef)(null),f=(0,V.useRef)(null);(0,V.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,G.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,G.jsx)(tr,{automation:e,nextRun:h?void 0:(0,G.jsx)(rr,{automation:e,timeZone:t})}),h?(0,G.jsx)(nr,{automation:e,archive:h}):null,h?null:(0,G.jsx)(ir,{automation:e,timeZone:t}),h?null:(0,G.jsx)(ar,{automation:e,busy:r,confirmingCancel:c,cancelRef:u,onToggle:a,onRun:i,onPreview:o,onOpenCancel:p}),e.schedule?.type===`once`&&!h&&c?(0,G.jsx)(or,{automation:e,busy:r,keepRef:d,onConfirm:()=>{l(!1),s()},onKeep:m}):null,n?(0,G.jsx)(sr,{note:n}):null,(0,G.jsx)(Pt,{automationId:e.id,automationName:e.name,timeZone:t})]})}function lr(e){let t=ke(),n=He(),[r,i]=(0,V.useState)(),[a,o]=(0,V.useState)(``),s=(0,V.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,V.useEffect)(()=>{n&&s()},[n,s]),(0,V.useEffect)(()=>p(async e=>{n&&await s(e)}),[n,s]),(0,V.useEffect)(()=>pe((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 ur({mode:e=`list`}){let{automationId:t}=de(),n=Oe(),[r,i]=(0,V.useState)(!1),{data:a,error:o,refresh:s}=lr(`include`),[c,l]=(0,V.useState)(0),u=Ie();if(u===`unknown`)return(0,G.jsx)(R,{route:`automations`,density:`empty`,children:(0,G.jsx)(K,{text:`Loading automations…`})});if(u===`absent`)return(0,G.jsx)(Le,{});if(u===`disabled`)return(0,G.jsx)(R,{route:`automations`,density:`empty`,children:(0,G.jsx)(Fe,{icon:(0,G.jsx)(be,{}),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,G.jsx)(Zn,{data:a,error:o,refresh:s,archived:r,onArchivedChange:i});if(!a)return o?(0,G.jsx)(R,{route:`automations`,density:`empty`,header:{title:`Automations`,subtitle:`Could not load automations.`},children:(0,G.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,G.jsx)(K,{text:o}),(0,G.jsx)(A,{variant:`outline`,onClick:()=>void s(),children:`Retry`})]})}):(0,G.jsx)(R,{route:`automations`,density:`empty`,children:(0,G.jsx)(K,{text:`Loading automations…`})});let p={available:a.available,...a.reason?{reason:a.reason}:{}};return e===`new`?(0,G.jsx)(Gn,{forge:p,timeZone:a.timeZone,onSaved:d}):e===`edit`?f?f.archived?(0,G.jsx)(Ft,{automation:f,timeZone:a.timeZone,onDeleted:d}):(0,G.jsx)(Gn,{automation:f,forge:p,timeZone:a.timeZone,onSaved:d,onReload:()=>void s().then(()=>l(e=>e+1))},`${f.id}:${c}`):(0,G.jsx)(R,{route:`automations`,density:`empty`,header:{title:`Automation not found`,subtitle:`This automation may have been removed.`},children:(0,G.jsx)(A,{asChild:!0,variant:`outline`,children:(0,G.jsx)(I,{to:`/automations`,children:`Back to automations`})})}):t?(0,G.jsx)(Nt,{automationId:t,automationName:f?.name,timeZone:a.timeZone,readOnly:!!f?.archived}):(0,G.jsx)(K,{text:`Automation not found.`})}export{ur as AutomationsRoute};
@@ -1 +0,0 @@
1
- import{It as e}from"./queries-CIeJg62Y.js";import{n as t}from"./project-location-BtpH7PdN.js";function n(){return{home:e().data?.homeDir??null,root:t()}}export{n as t};