@hearsay-tools/squawk 0.19.0-dev.9172 → 0.19.0-dev.9182

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 (138) hide show
  1. package/dist/contract/hosts.d.ts +925 -0
  2. package/dist/contract/index.js +104 -2
  3. package/dist/core/server-hook-registry.d.ts +13 -0
  4. package/dist/core/server-hook-registry.js.map +1 -1
  5. package/dist/delegation/transport.d.ts +78 -78
  6. package/dist/features/automations/automations-routes.d.ts +150 -150
  7. package/dist/features/hosts/admission.d.ts +52 -0
  8. package/dist/features/hosts/admission.js +89 -0
  9. package/dist/features/hosts/admission.js.map +1 -0
  10. package/dist/features/hosts/gateway.d.ts +14 -3
  11. package/dist/features/hosts/gateway.js +35 -21
  12. package/dist/features/hosts/gateway.js.map +1 -1
  13. package/dist/features/hosts/index.d.ts +7 -3
  14. package/dist/features/hosts/index.js +41 -7
  15. package/dist/features/hosts/index.js.map +1 -1
  16. package/dist/features/hosts/registry-reconciler.d.ts +41 -0
  17. package/dist/features/hosts/registry-reconciler.js +168 -0
  18. package/dist/features/hosts/registry-reconciler.js.map +1 -0
  19. package/dist/features/hosts/routes.d.ts +370 -4
  20. package/dist/features/hosts/routes.js +72 -62
  21. package/dist/features/hosts/routes.js.map +1 -1
  22. package/dist/features/hosts/runs-index-events.d.ts +23 -0
  23. package/dist/features/hosts/runs-index-events.js +116 -0
  24. package/dist/features/hosts/runs-index-events.js.map +1 -0
  25. package/dist/features/hosts/runs-index-patch.d.ts +203 -0
  26. package/dist/features/hosts/runs-index-patch.js +798 -0
  27. package/dist/features/hosts/runs-index-patch.js.map +1 -0
  28. package/dist/features/hosts/runs-index.d.ts +149 -0
  29. package/dist/features/hosts/runs-index.js +762 -0
  30. package/dist/features/hosts/runs-index.js.map +1 -0
  31. package/dist/features/hosts/runs-search.d.ts +28 -0
  32. package/dist/features/hosts/runs-search.js +151 -0
  33. package/dist/features/hosts/runs-search.js.map +1 -0
  34. package/dist/features/hosts/supervisor.d.ts +4 -0
  35. package/dist/features/hosts/supervisor.js +14 -6
  36. package/dist/features/hosts/supervisor.js.map +1 -1
  37. package/dist/plugin/index.d.ts +1 -1
  38. package/dist/plugin/index.js.map +1 -1
  39. package/dist/server/repo-routes.d.ts +52 -52
  40. package/dist/server/server.js +7 -1
  41. package/dist/server/server.js.map +1 -1
  42. package/dist/server/workspace-run-feed.d.ts +4 -0
  43. package/dist/server/workspace-run-feed.js +13 -0
  44. package/dist/server/workspace-run-feed.js.map +1 -1
  45. package/package.json +4 -4
  46. package/scripts/benchmark-hosts-runs-index-probes.ts +242 -0
  47. package/scripts/benchmark-hosts-runs-index.ts +776 -0
  48. package/web/dist/assets/accounts-section-DYQC-wSh.js +1 -0
  49. package/web/dist/assets/activity-motion-XvrmbNgR.js +1 -0
  50. package/web/dist/assets/{activity-route-C2zP5vVV.js → activity-route-Dj8ltoqG.js} +1 -1
  51. package/web/dist/assets/{agent-accounts-D_ZKAmaW.js → agent-accounts-C2ILQhZy.js} +1 -1
  52. package/web/dist/assets/{agent-config-section-CwK_izpU.js → agent-config-section-D16TRCE_.js} +2 -2
  53. package/web/dist/assets/agent-defaults-section-Dm0khLjs.js +1 -0
  54. package/web/dist/assets/{appearance-DvoRcoRX.js → appearance-CP6zVctf.js} +1 -1
  55. package/web/dist/assets/{archive-on-merge-field-DWPtF9dh.js → archive-on-merge-field-BA8aUtRQ.js} +1 -1
  56. package/web/dist/assets/{ask-card-D-om0EtP.js → ask-card-CLdlwd68.js} +1 -1
  57. package/web/dist/assets/attention-C7BUdd2s.js +1 -0
  58. package/web/dist/assets/automations-route-BVDO_Kai.js +2 -0
  59. package/web/dist/assets/{commit-list-CPJLP4DU.js → commit-list-Bdekr2K7.js} +1 -1
  60. package/web/dist/assets/{diff-BQJN6jzN.js → diff-Du0FsqAK.js} +2 -2
  61. package/web/dist/assets/{diff-controls-AsSX7gfO.js → diff-controls-DTC_6oqk.js} +1 -1
  62. package/web/dist/assets/{diff-view-BW5bbiaq.js → diff-view-TKooupFV.js} +1 -1
  63. package/web/dist/assets/{discard-changes-dialog-Bv4yc0N1.js → discard-changes-dialog-Bg-3Xbox.js} +1 -1
  64. package/web/dist/assets/{file-preview-CnrFxbea.js → file-preview-DMJCprVk.js} +1 -1
  65. package/web/dist/assets/{folder-browser-CFd1U5hn.js → folder-browser-3cBLlnE9.js} +1 -1
  66. package/web/dist/assets/{git-toolbar-C7iolhIi.js → git-toolbar-COhBdctn.js} +1 -1
  67. package/web/dist/assets/github-DUTSv2Hs.js +1 -0
  68. package/web/dist/assets/{global-activity-route-Dijwg4OL.js → global-activity-route-CypEKUv_.js} +1 -1
  69. package/web/dist/assets/hosts-iUyg8S3j.js +1 -0
  70. package/web/dist/assets/index-BV3EQb9T.js +21 -0
  71. package/web/dist/assets/index-Bh7COq0B.css +1 -0
  72. package/web/dist/assets/{label-CgU9vxuM.js → label-CWlxyeC-.js} +1 -1
  73. package/web/dist/assets/{markdown-Cljq4S1h.js → markdown-0uCxcToP.js} +1 -1
  74. package/web/dist/assets/{open-in-menu-BI7mnPPf.js → open-in-menu-Bf8JA2DJ.js} +1 -1
  75. package/web/dist/assets/{option-select-BcTkv-7t.js → option-select-DQJEHmHf.js} +1 -1
  76. package/web/dist/assets/{preferences-section-CEKXGhEj.js → preferences-section-Cvl5vyfN.js} +1 -1
  77. package/web/dist/assets/{preview-EtD19mg1.js → preview-BSFJfN4s.js} +1 -1
  78. package/web/dist/assets/{preview-pane-connected-CKRBfx7t.js → preview-pane-connected-i3GJtDL3.js} +2 -2
  79. package/web/dist/assets/{project-location-hufc_p8y.js → project-location-BcjOhqun.js} +1 -1
  80. package/web/dist/assets/{project-router-Dc6KBQsv.js → project-router-CwD1firw.js} +1 -1
  81. package/web/dist/assets/{projects-section-vOFZ4lbx.js → projects-section-CAOFPkDQ.js} +1 -1
  82. package/web/dist/assets/{prompt-templates-section-Caash2nq.js → prompt-templates-section-BXTfLET4.js} +1 -1
  83. package/web/dist/assets/queries-D9mg7sFY.js +1 -0
  84. package/web/dist/assets/{read-state-BeVNfGkB.js → read-state-BsTfJki5.js} +1 -1
  85. package/web/dist/assets/{reference-chip-BjerVjzM.js → reference-chip-CZKBU_Ud.js} +1 -1
  86. package/web/dist/assets/{remote-settings-notice-fNgh5LdN.js → remote-settings-notice-CUK4ZFYF.js} +1 -1
  87. package/web/dist/assets/repo-git-Dx85MEuK.js +1 -0
  88. package/web/dist/assets/{report-reader-CK1WDtEH.js → report-reader-BDdY5kpz.js} +1 -1
  89. package/web/dist/assets/{report-selection-CZ8eb9QP.js → report-selection-Y2F9NTAs.js} +1 -1
  90. package/web/dist/assets/{reports-B-GImLAo.js → reports-DWKpm_us.js} +1 -1
  91. package/web/dist/assets/{resources-section-ApF3gXrw.js → resources-section-D9tzbv9w.js} +1 -1
  92. package/web/dist/assets/{review-notes-drafts-BdjEFs1G.js → review-notes-drafts-BSkmq3Nj.js} +1 -1
  93. package/web/dist/assets/{review-panel-D4zmYH8O.js → review-panel-C9UZjWFl.js} +1 -1
  94. package/web/dist/assets/{review-strip-BpHXklAn.js → review-strip-qTG5JaOw.js} +1 -1
  95. package/web/dist/assets/{run-detail-refresh-CE0vyYYA.js → run-detail-refresh-SYZM94ch.js} +1 -1
  96. package/web/dist/assets/{run-diff-ClfLRsHF.js → run-diff-D26PXp6r.js} +1 -1
  97. package/web/dist/assets/run-header-BrUcSJu6.js +2 -0
  98. package/web/dist/assets/{select-CwDhRDtw.js → select-BUsS7uOZ.js} +1 -1
  99. package/web/dist/assets/{session-context-section-C87jx7RB.js → session-context-section-Bgzou-NG.js} +1 -1
  100. package/web/dist/assets/{settings-agent-picker-Dk8yJ57U.js → settings-agent-picker-CH3CQhOh.js} +1 -1
  101. package/web/dist/assets/{settings-save-bar-cu8BKCGT.js → settings-save-bar-cyvALSgW.js} +1 -1
  102. package/web/dist/assets/{settings-shell-mhQfQKf1.js → settings-shell-Cl-cu4r5.js} +1 -1
  103. package/web/dist/assets/{sidebar-section-DOQ5N1L6.js → sidebar-section-Cj2fDrhV.js} +1 -1
  104. package/web/dist/assets/{skills-DXJ1gQBD.js → skills-DLMbRR_5.js} +1 -1
  105. package/web/dist/assets/{status-dot-Bmn4xhch.js → status-dot-DTU7afRv.js} +1 -1
  106. package/web/dist/assets/{tab-link-6TltE1jl.js → tab-link-BJDe5cT4.js} +1 -1
  107. package/web/dist/assets/{task-changes-D9Sdmpmw.js → task-changes-ito4fOGh.js} +2 -2
  108. package/web/dist/assets/{task-commits-A0UIqxpL.js → task-commits-BYOIU9zy.js} +1 -1
  109. package/web/dist/assets/{task-file-scope-ID220XKo.js → task-file-scope-B8EEJyHp.js} +1 -1
  110. package/web/dist/assets/{task-files-Id2tuAAG.js → task-files-CF0QKnm-.js} +1 -1
  111. package/web/dist/assets/{task-github-item-YKUcwp2o.js → task-github-item-C6Fu8MvM.js} +1 -1
  112. package/web/dist/assets/{task-groups-DCg4iOB9.js → task-groups-BvVfsQKd.js} +1 -1
  113. package/web/dist/assets/{task-thread-A_vkygGX.js → task-thread-BWrvepxB.js} +2 -2
  114. package/web/dist/assets/{thread-state-6-BzRrJ_.js → thread-state-8E0eYXGu.js} +1 -1
  115. package/web/dist/assets/toaster-2ud_VdfV.js +4 -0
  116. package/web/dist/assets/{use-finish-run-DO-nnAaa.js → use-finish-run-a2qZy6zr.js} +1 -1
  117. package/web/dist/assets/{use-hand-to-agent-state-CADaL8U8.js → use-hand-to-agent-state-DT1ngmHe.js} +1 -1
  118. package/web/dist/assets/use-path-bases-CZ6F93wt.js +1 -0
  119. package/web/dist/assets/use-workspace-config-save-DDI7_WtK.js +1 -0
  120. package/web/dist/assets/{workflows-DOLG-Rns.js → workflows-2e0Sm6F1.js} +2 -2
  121. package/web/dist/assets/{workspace-tools-DTCJVDTE.js → workspace-tools-D4DO9w12.js} +1 -1
  122. package/web/dist/assets/{worktrees-section-BOHDbywt.js → worktrees-section-8-d6zWQ-.js} +5 -5
  123. package/web/dist/index.html +20 -20
  124. package/web/dist/assets/accounts-section-Bnr89jmC.js +0 -1
  125. package/web/dist/assets/activity-motion-BW0tAmYF.js +0 -1
  126. package/web/dist/assets/agent-defaults-section-RyEogH0g.js +0 -1
  127. package/web/dist/assets/attention-BI6592lk.js +0 -1
  128. package/web/dist/assets/automations-route-DfGE4xWT.js +0 -2
  129. package/web/dist/assets/github-DGElvfMU.js +0 -1
  130. package/web/dist/assets/hosts-CpDMDiQW.js +0 -1
  131. package/web/dist/assets/index-BVRdRJAN.css +0 -1
  132. package/web/dist/assets/index-DPfg7xSB.js +0 -21
  133. package/web/dist/assets/queries-IlC9MZgh.js +0 -1
  134. package/web/dist/assets/repo-git-5MK_RAR6.js +0 -1
  135. package/web/dist/assets/run-header-BUe92WWr.js +0 -2
  136. package/web/dist/assets/toaster-DNnL8v10.js +0 -4
  137. package/web/dist/assets/use-path-bases-CFAmFn_E.js +0 -1
  138. package/web/dist/assets/use-workspace-config-save-DScW6_8J.js +0 -1
@@ -59,30 +59,30 @@
59
59
  }
60
60
  })()
61
61
  </script>
62
- <script type="module" crossorigin src="/assets/index-DPfg7xSB.js"></script>
62
+ <script type="module" crossorigin src="/assets/index-BV3EQb9T.js"></script>
63
63
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-QTnfLwEv.js">
64
64
  <link rel="modulepreload" crossorigin href="/assets/react-runtime-CCIEwYL0.js">
65
65
  <link rel="modulepreload" crossorigin href="/assets/host-context-DDbYAKpm.js">
66
66
  <link rel="modulepreload" crossorigin href="/assets/live-protocol-CNUmr-VT.js">
67
67
  <link rel="modulepreload" crossorigin href="/assets/bundle-mjs-rHxsej31.js">
68
68
  <link rel="modulepreload" crossorigin href="/assets/dist-CCX8mhHc.js">
69
- <link rel="modulepreload" crossorigin href="/assets/toaster-DNnL8v10.js">
69
+ <link rel="modulepreload" crossorigin href="/assets/toaster-2ud_VdfV.js">
70
70
  <link rel="modulepreload" crossorigin href="/assets/host-storage-B72yoDU1.js">
71
- <link rel="modulepreload" crossorigin href="/assets/queries-IlC9MZgh.js">
71
+ <link rel="modulepreload" crossorigin href="/assets/queries-D9mg7sFY.js">
72
72
  <link rel="modulepreload" crossorigin href="/assets/preload-helper-Czpn1I53.js">
73
73
  <link rel="modulepreload" crossorigin href="/assets/chunk-KS7C4IRE-BdLLx37K.js">
74
- <link rel="modulepreload" crossorigin href="/assets/cez-idle-C0drOeLs.js">
75
- <link rel="modulepreload" crossorigin href="/assets/hosts-CpDMDiQW.js">
76
- <link rel="modulepreload" crossorigin href="/assets/run-detail-refresh-CE0vyYYA.js">
77
- <link rel="modulepreload" crossorigin href="/assets/es2015-BHonSvOU.js">
78
- <link rel="modulepreload" crossorigin href="/assets/label-CgU9vxuM.js">
79
74
  <link rel="modulepreload" crossorigin href="/assets/design-icons-QbNMZniQ.js">
75
+ <link rel="modulepreload" crossorigin href="/assets/es2015-BHonSvOU.js">
80
76
  <link rel="modulepreload" crossorigin href="/assets/dist-ClMNSUvT.js">
81
77
  <link rel="modulepreload" crossorigin href="/assets/dist-Du6flkGD.js">
82
78
  <link rel="modulepreload" crossorigin href="/assets/popover-BQolmvDR.js">
83
- <link rel="modulepreload" crossorigin href="/assets/attention-BI6592lk.js">
84
- <link rel="modulepreload" crossorigin href="/assets/task-groups-DCg4iOB9.js">
85
- <link rel="modulepreload" crossorigin href="/assets/reference-chip-BjerVjzM.js">
79
+ <link rel="modulepreload" crossorigin href="/assets/attention-C7BUdd2s.js">
80
+ <link rel="modulepreload" crossorigin href="/assets/task-groups-BvVfsQKd.js">
81
+ <link rel="modulepreload" crossorigin href="/assets/reference-chip-CZKBU_Ud.js">
82
+ <link rel="modulepreload" crossorigin href="/assets/cez-idle-C0drOeLs.js">
83
+ <link rel="modulepreload" crossorigin href="/assets/hosts-iUyg8S3j.js">
84
+ <link rel="modulepreload" crossorigin href="/assets/run-detail-refresh-SYZM94ch.js">
85
+ <link rel="modulepreload" crossorigin href="/assets/label-CWlxyeC-.js">
86
86
  <link rel="modulepreload" crossorigin href="/assets/createLucideIcon-BHp8sXmF.js">
87
87
  <link rel="modulepreload" crossorigin href="/assets/bot-TkDIw4y-.js">
88
88
  <link rel="modulepreload" crossorigin href="/assets/external-link-BE6y205O.js">
@@ -93,40 +93,40 @@
93
93
  <link rel="modulepreload" crossorigin href="/assets/dist-B2_vvox1.js">
94
94
  <link rel="modulepreload" crossorigin href="/assets/dropdown-menu-NJZfnQCU.js">
95
95
  <link rel="modulepreload" crossorigin href="/assets/own-lookup-DS54wXvD.js">
96
- <link rel="modulepreload" crossorigin href="/assets/open-in-menu-BI7mnPPf.js">
96
+ <link rel="modulepreload" crossorigin href="/assets/open-in-menu-Bf8JA2DJ.js">
97
97
  <link rel="modulepreload" crossorigin href="/assets/check-OP-CVgZG.js">
98
98
  <link rel="modulepreload" crossorigin href="/assets/chevron-down-CHGyCDBH.js">
99
99
  <link rel="modulepreload" crossorigin href="/assets/nav-row-styles-CIedRn3A.js">
100
100
  <link rel="modulepreload" crossorigin href="/assets/chevron-right-BENZ-1ZN.js">
101
- <link rel="modulepreload" crossorigin href="/assets/folder-browser-CFd1U5hn.js">
101
+ <link rel="modulepreload" crossorigin href="/assets/folder-browser-3cBLlnE9.js">
102
102
  <link rel="modulepreload" crossorigin href="/assets/eye-B8okNWXU.js">
103
103
  <link rel="modulepreload" crossorigin href="/assets/loader-circle-CPBhhDbB.js">
104
104
  <link rel="modulepreload" crossorigin href="/assets/play-CmVAj_fu.js">
105
105
  <link rel="modulepreload" crossorigin href="/assets/search-x-I9Q8pgUa.js">
106
- <link rel="modulepreload" crossorigin href="/assets/preview-EtD19mg1.js">
106
+ <link rel="modulepreload" crossorigin href="/assets/preview-BSFJfN4s.js">
107
107
  <link rel="modulepreload" crossorigin href="/assets/dist-CyFJ-9Ex.js">
108
108
  <link rel="modulepreload" crossorigin href="/assets/dist-Czz3Y5qH.js">
109
109
  <link rel="modulepreload" crossorigin href="/assets/switch-B9OfOEzC.js">
110
110
  <link rel="modulepreload" crossorigin href="/assets/badge-DAnkqD7i.js">
111
111
  <link rel="modulepreload" crossorigin href="/assets/dialog-DKr-j9S6.js">
112
- <link rel="modulepreload" crossorigin href="/assets/project-router-Dc6KBQsv.js">
113
- <link rel="modulepreload" crossorigin href="/assets/read-state-BeVNfGkB.js">
114
- <link rel="modulepreload" crossorigin href="/assets/status-dot-Bmn4xhch.js">
112
+ <link rel="modulepreload" crossorigin href="/assets/project-router-CwD1firw.js">
113
+ <link rel="modulepreload" crossorigin href="/assets/read-state-BsTfJki5.js">
114
+ <link rel="modulepreload" crossorigin href="/assets/status-dot-DTU7afRv.js">
115
115
  <link rel="modulepreload" crossorigin href="/assets/use-search-params-writer-DD5PEEZw.js">
116
- <link rel="modulepreload" crossorigin href="/assets/report-selection-CZ8eb9QP.js">
116
+ <link rel="modulepreload" crossorigin href="/assets/report-selection-Y2F9NTAs.js">
117
117
  <link rel="modulepreload" crossorigin href="/assets/page-shell-BdjH5hyc.js">
118
118
  <link rel="modulepreload" crossorigin href="/assets/diff-stat-DCO_BkZB.js">
119
119
  <link rel="modulepreload" crossorigin href="/assets/format-BU7D3IfE.js">
120
120
  <link rel="modulepreload" crossorigin href="/assets/command-4D8sPZJy.js">
121
121
  <link rel="modulepreload" crossorigin href="/assets/project-order-AcHI4Dcl.js">
122
122
  <link rel="modulepreload" crossorigin href="/assets/skills-pM_PouEs.js">
123
- <link rel="modulepreload" crossorigin href="/assets/agent-accounts-D_ZKAmaW.js">
123
+ <link rel="modulepreload" crossorigin href="/assets/agent-accounts-C2ILQhZy.js">
124
124
  <link rel="modulepreload" crossorigin href="/assets/control-locations-kCPVEtOM.js">
125
125
  <link rel="modulepreload" crossorigin href="/assets/agents-settings-path-7X6_cvUg.js">
126
126
  <link rel="modulepreload" crossorigin href="/assets/centered-state-N8vWM_Hw.js">
127
127
  <link rel="modulepreload" crossorigin href="/assets/html-report-BX3msvci.js">
128
128
  <link rel="stylesheet" crossorigin href="/assets/page-shell-CEIoW56O.css">
129
- <link rel="stylesheet" crossorigin href="/assets/index-BVRdRJAN.css">
129
+ <link rel="stylesheet" crossorigin href="/assets/index-Bh7COq0B.css">
130
130
  </head>
131
131
  <body>
132
132
  <div id="root"></div>
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Ct as r,Et as i,Ft as a,Kt as o,Mt as s,St as c,Xt as l,Yt as u,en as d,ft as f,lt as p,pt as m,qt as h,rn as g,un as _,ut as v,vt as y}from"./queries-IlC9MZgh.js";import{Fi as b,Xn as x,Yn as S,_r as ee,er as C,n as w,wi as T}from"./toaster-DNnL8v10.js";import{p as E}from"./chunk-KS7C4IRE-BdLLx37K.js";import{b as D}from"./design-icons-QbNMZniQ.js";import{t as O}from"./createLucideIcon-BHp8sXmF.js";import{t as te}from"./folder-browser-CFd1U5hn.js";import{t as k}from"./button-BV_AiLj2.js";import{t as ne}from"./badge-DAnkqD7i.js";import{a as re,i as ie,o as ae,r as oe,s as se,t as A}from"./dialog-DKr-j9S6.js";import{t as j}from"./status-dot-Bmn4xhch.js";import{n as M}from"./agents-settings-path-7X6_cvUg.js";import{t as N}from"./centered-state-N8vWM_Hw.js";import{$t as P,Hn as F,I,Mn as L,On as R,P as z,R as B,an as V,en as H,in as U,jn as W,nn as G,on as K,rn as ce,tn as le}from"./index-DPfg7xSB.js";import{t as q}from"./option-select-BcTkv-7t.js";import{n as J,r as ue,t as de}from"./settings-agent-picker-Dk8yJ57U.js";import{n as fe,r as pe,t as me}from"./remote-settings-notice-fNgh5LdN.js";import{n as he,t as ge}from"./save-cue-CpHgT93o.js";import{t as _e}from"./use-path-bases-CFAmFn_E.js";import{t as ve}from"./use-workspace-config-save-DScW6_8J.js";var ye=O(`id-card`,[[`path`,{d:`M16 10h2`,key:`8sgtl7`}],[`path`,{d:`M16 14h2`,key:`epxaof`}],[`path`,{d:`M6.17 15a3 3 0 0 1 5.66 0`,key:`n6f512`}],[`circle`,{cx:`9`,cy:`11`,r:`2`,key:`yxgjnd`}],[`rect`,{x:`2`,y:`5`,width:`20`,height:`14`,rx:`2`,key:`qneu4z`}]]),Y=e(t(),1),X=n(),be=`~/.claude-second`;function xe({open:e,onOpenChange:t,providers:n,initialProvider:r}){let i=d().data,[a,o]=(0,Y.useState)(null),[s,c]=(0,Y.useState)(null),[l,f]=(0,Y.useState)(r??n[0]??`claude`),[p,g]=(0,Y.useState)(``),[_,v]=(0,Y.useState)(``),[y,b]=(0,Y.useState)(!1),x=m(),S=_.trim();return(0,X.jsx)(A,{open:e,onOpenChange:t,children:(0,X.jsxs)(oe,{"data-slot":`add-account-dialog`,className:`sm:max-w-lg`,children:[(0,X.jsxs)(ae,{children:[(0,X.jsx)(se,{children:`Add agent account`}),(0,X.jsx)(ie,{children:`The config folder this account uses. It does not have to exist yet — Connect signs in and the CLI creates it.`})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(`label`,{className:`flex items-center gap-2 text-[13px]`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:`Agent`}),(0,X.jsx)(q,{"aria-label":`Agent`,"data-slot":`add-account-provider`,value:l,onValueChange:e=>f(e),className:`settings-select max-w-full bg-card text-[13px]`,options:n.map(e=>({value:e,label:h(i,e)}))})]}),(0,X.jsxs)(`label`,{className:`flex min-w-0 flex-1 items-center gap-2 text-[13px]`,children:[(0,X.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:`Name`}),(0,X.jsx)(`input`,{type:`text`,"aria-label":`Account name`,"data-slot":`add-account-label`,value:p,placeholder:`Work`,onChange:e=>g(e.target.value),className:`min-w-0 flex-1 rounded-md border border-input bg-card px-2 py-1 text-[13px] outline-none focus-visible:border-ring`})]})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,X.jsxs)(`label`,{className:`flex min-w-0 items-center gap-2 text-[13px]`,children:[(0,X.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:`Folder`}),(0,X.jsx)(`input`,{type:`text`,spellCheck:!1,autoComplete:`off`,"aria-label":`Config folder`,"data-slot":`add-account-dir`,value:_,placeholder:u(i,l)?.accountFolderExample??be,onChange:e=>{v(e.target.value),c(null),x.reset()},className:`min-w-0 flex-1 rounded-md border border-input bg-card px-2 py-1 font-mono text-[13px] outline-none focus-visible:border-ring`}),(0,X.jsx)(k,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`add-account-browse`,"aria-expanded":y,onClick:()=>b(e=>!e),children:y?`Hide folders`:`Browse…`})]}),(0,X.jsxs)(`p`,{className:`text-xs text-soft-foreground`,children:[`A `,(0,X.jsx)(`code`,{children:`~`}),` is kept as written and expanded when the agent runs.`]})]}),y?(0,X.jsx)(te,{path:a,selected:s,onSelect:e=>{c(e),v(e.path),x.reset()},onEnter:e=>{o(e),c(null),x.reset()},showHidden:!0,emptyHint:`No subfolders here — pick this folder by typing its path above.`}):null,x.isError?(0,X.jsx)(`p`,{"data-slot":`add-account-error`,className:`min-w-0 break-words text-[13px] text-danger`,children:x.error instanceof Error?x.error.message:`could not add that folder`}):null,(0,X.jsxs)(re,{className:`min-w-0 sm:items-center sm:justify-end`,children:[(0,X.jsx)(k,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,X.jsx)(k,{"data-slot":`add-account-confirm`,disabled:S===``||x.isPending,onClick:()=>{S===``||x.isPending||x.mutate({provider:l,configDir:S,...p.trim()?{label:p.trim()}:{}},{onSuccess:()=>{t(!1),g(``),v(``),c(null),b(!1),w(`Account added — use Connect to sign in`)}})},children:x.isPending?`Adding…`:`Add account`})]})]})})}async function Se(e){return C(await x.api.v1[`runner-install`][`:runner`].$get({param:{runner:e}}),`/runner-install/:runner`)}async function Ce(e,t){return C(await x.api.v1[`runner-install`][`:runner`].$post({param:{runner:e},json:{action:t}}),`/runner-install/:runner`)}var we={idle:``,checking:`Checking for updates…`,downloading:`Downloading CLI…`,verifying:`Verifying CLI…`,extracting:`Extracting CLI…`,activating:`Activating CLI…`,removing:`Removing CLI…`,failed:``};function Te(e){let t=y().data?.capabilities?.settingsAdmin===!0,n=b(),r=[`runner-install`,e],i=T({queryKey:r,queryFn:()=>Se(e),enabled:t,retry:!1,refetchInterval:e=>{if(e.state.error)return!1;let t=e.state.data?.phase;return t&&t!==`idle`&&t!==`failed`?1e3:6e4}}),a=_({mutationFn:t=>Ce(e,t),retry:!1,onSuccess:e=>{n.setQueryData(r,e)}}),o=i.data;return{allowed:t,data:o,busy:a.isPending||!!o&&o.phase!==`idle`&&o.phase!==`failed`,error:a.error?.message??i.error?.message??o?.error,action:a,status:i}}function Ee({state:e}){let{data:t,busy:n,action:r,status:i}=e;if(t?.supported===!1)return(0,X.jsx)(`p`,{children:`This host is not supported by the CLI installer.`});let a=!!t?.installedVersion;return(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,X.jsx)(k,{className:`active:opacity-80`,disabled:n||!t,onClick:()=>r.mutate(a?`update`:`install`),children:a?`Update CLI`:`Install CLI`}),a?(0,X.jsx)(k,{className:`active:opacity-80`,variant:`outline`,disabled:n,onClick:()=>r.mutate(`remove`),children:`Remove CLI`}):null,(0,X.jsx)(k,{className:`active:opacity-80`,variant:`outline`,disabled:n,onClick:()=>{i.isError?i.refetch():r.mutate(`check`)},children:`Check for updates`})]})}function De({runner:e}){let t=Te(e),{allowed:n,data:r,busy:i,error:a}=t;return n?(0,X.jsxs)(`section`,{"aria-label":`CLI installation`,className:`grid gap-3`,children:[(0,X.jsxs)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:[r?.installedVersion?`Installed CLI ${r.installedVersion}`:`CLI not installed`,r?.latestVersion?` · Latest ${r.latestVersion}`:``,i&&r?` · ${we[r.phase]}`:``]}),a?(0,X.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:a}):null,(0,X.jsx)(Ee,{state:t}),r?.installedVersion?(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Removing the CLI keeps account data and lets running tasks finish.`}):null]}):null}var Oe={connected:L(`connected`),disconnected:L(`disconnected`),"not-installed":L(`not-installed`),unknown:L(`unknown`)};function ke(){let e=v(),t=d();if(e.isPending||t.isPending)return(0,X.jsx)(`p`,{"data-slot":`accounts-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading agents…`});let n=e.error??t.error;return n?(0,X.jsx)(N,{icon:(0,X.jsx)(ye,{}),tone:`danger`,title:`Agents did not load`,subtitle:n.message,heading:`h2`}):(0,X.jsx)(je,{data:e.data,runners:t.data})}function Z(e,t){let n=F(e,t),r=n.split(`/`);return r.length>4?`…/${r.slice(-3).join(`/`)}`:n}function Ae(){let{hash:e}=E();(0,Y.useEffect)(()=>{if(!e)return;let t=document.getElementById(decodeURIComponent(e.slice(1)));t&&(t.scrollIntoView?.({block:`start`}),t.focus({preventScroll:!0}))},[e])}function je({data:e,runners:t}){let n=y(),[r,a]=(0,Y.useState)(null),[o,s]=(0,Y.useState)(null),c=i();return Ae(),pe(),(0,X.jsxs)(`div`,{"data-slot":`accounts-section`,className:`mx-auto flex w-full max-w-2xl flex-col gap-5 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:[(0,X.jsx)(fe,{risk:`Agent accounts run each CLI with the configured host folder`}),e.editable?null:(0,X.jsxs)(`p`,{"data-slot":`accounts-hosted`,className:`text-[13px] text-muted-foreground`,children:[`Agent accounts are read-only on this remote cockpit. Run`,` `,(0,X.jsx)(`code`,{children:me}),` on the host to add, edit, or sign in to accounts here.`]}),(0,X.jsx)(`div`,{"data-slot":`agent-cards`,className:`flex flex-col gap-3`,children:t.runners.map(r=>(0,X.jsx)(Fe,{entry:r,check:n.data?.checks?.find(e=>e.name===r.id),settingsAdmin:n.data?.capabilities?.settingsAdmin===!0,runners:t,editable:e.editable,accounts:e.profiles.filter(e=>e.provider===r.id),canCarryAccounts:e.profileCapableProviders.includes(r.id),onAdd:()=>a(r.id),onRemove:s},r.id))}),(0,X.jsx)(Ie,{runners:t}),r===null?null:(0,X.jsx)(xe,{open:!0,onOpenChange:e=>!e&&a(null),providers:e.profileCapableProviders,initialProvider:r},r),(0,X.jsx)(P,{open:o!==null,onOpenChange:e=>!e&&s(null),children:(0,X.jsxs)(G,{"data-slot":`accounts-remove-confirm`,children:[(0,X.jsxs)(V,{children:[(0,X.jsxs)(K,{children:[`Remove “`,o?.label,`”?`]}),(0,X.jsxs)(ce,{children:[`This only forgets the account. Nothing in `,o?.configDir??`this account’s folder`,` is deleted — not your login, not your sessions. Projects using it fall back to the default account, and tasks that ran under it can no longer be resumed from here.`]})]}),(0,X.jsxs)(U,{children:[(0,X.jsx)(le,{children:`Cancel`}),(0,X.jsx)(H,{"data-action":`accounts-remove-confirm`,disabled:c.isPending,onClick:()=>{let e=o;e&&c.mutate(e.id,{onSuccess:()=>{s(null),w(`Removed ${e.label}`)},onError:e=>w(e.message,{tone:`danger`})})},children:`Remove`})]})]})})]})}function Me({entry:e,check:t}){return t===void 0?(0,X.jsx)(`span`,{"data-slot":`agent-installed`,children:`Checking CLI…`}):t.available?(0,X.jsxs)(`span`,{className:`whitespace-nowrap`,children:[(0,X.jsx)(`span`,{"data-slot":`agent-installed`,children:W(t.version)?`CLI simulated`:`CLI installed`}),t.version?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`settings-agent-summary-sep`,children:`·`}),(0,X.jsx)(Ne,{version:t.version})]}):null]}):(0,X.jsxs)(`span`,{"data-slot":`agent-installed`,children:[`CLI not installed`,e.installHint?(0,X.jsxs)(X.Fragment,{children:[` — `,(0,X.jsx)(`code`,{className:`break-all`,children:e.installHint})]}):null]})}function Ne({version:e}){return W(e)?(0,X.jsx)(`span`,{"data-slot":`agent-version`,"data-dry-run":``,title:e,className:`rounded-full border border-border bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground`,children:R.label}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`sr-only`,children:`, version `}),(0,X.jsx)(`span`,{"data-slot":`agent-version`,className:`text-muted-foreground`,children:e})]})}function Pe({items:e}){let t=e.filter(e=>e!=null&&e!==!1);return t.length===0?null:(0,X.jsx)(`p`,{"data-slot":`agent-summary`,className:`settings-agent-summary`,children:t.map((e,t)=>(0,X.jsxs)(`span`,{className:`settings-agent-summary-item`,children:[t>0?(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`settings-agent-summary-sep`,children:`·`}):null,e]},t))})}function Q({titleId:e,title:t,summary:n,actions:r,actionsSlot:i}){return(0,X.jsxs)(`div`,{"data-slot":`agent-head`,className:`settings-agent-head`,children:[(0,X.jsxs)(`div`,{className:`settings-agent-heading`,children:[(0,X.jsx)(`h3`,{id:e,className:`settings-account-provider-title`,children:t}),(0,X.jsx)(Pe,{items:n})]}),r?(0,X.jsx)(`div`,{"data-slot":i,className:`settings-account-actions`,children:r}):null]})}function Fe({entry:e,check:t,settingsAdmin:n,runners:r,editable:i,accounts:a,canCarryAccounts:o,onAdd:s,onRemove:c}){let l=e.id,u=e.displayName,d=e.managedInstall===!0&&n,f=a.filter(e=>e.isDefault).length,p=`${M(l)}-title`,m=i&&o?(0,X.jsx)(k,{type:`button`,variant:`outline`,size:`sm`,"data-action":`accounts-add`,"data-provider":l,onClick:s,children:`Add account`}):null,h={titleId:p,title:u,facts:[d?null:(0,X.jsx)(Me,{entry:e,check:t}),i||a.length>0?(0,X.jsxs)(`span`,{className:`settings-account-count`,title:`${f} discovered, ${a.length-f} added`,children:[a.length,` `,a.length===1?`account`:`accounts`]}):null],addButton:m},[g,..._]=a;return(0,X.jsxs)(`section`,{id:M(l),tabIndex:-1,"aria-labelledby":p,"data-slot":`accounts-provider`,"data-provider":l,className:`settings-agent-card flex flex-col rounded-lg border border-border bg-card`,children:[g===void 0?(0,X.jsx)(Q,{titleId:p,title:u,summary:h.facts,actions:m,actionsSlot:`accounts-actions`}):null,d?(0,X.jsx)(De,{runner:l}):null,g===void 0?null:(0,X.jsxs)(`ul`,{className:`settings-agent-accounts`,children:[(0,X.jsx)($,{account:g,runners:r,editable:i,onRemove:()=>c(g),agent:h}),_.map(e=>(0,X.jsx)($,{account:e,runners:r,editable:i,onRemove:()=>c(e)},e.id))]}),i&&!o?(0,X.jsxs)(`p`,{"data-slot":`accounts-single-only`,className:`settings-agent-note`,children:[`One account only: `,u,` keeps its login outside its config folder, so a second folder would change settings without changing who is billed.`]}):!i&&a.length===0&&e.browserLogin?(0,X.jsxs)(`div`,{"data-slot":`hosted-sign-in`,className:`settings-agent-note flex flex-wrap items-center gap-3`,children:[(0,X.jsx)(`span`,{children:`Discovered account`}),(0,X.jsx)(J,{provider:l,label:u})]}):null]})}function Ie({runners:e}){let[t,n]=(0,Y.useState)(null),r=a(),i=c(),s=g(l(e)),u=ve(),d=he(),f=e=>u.mutate(e,{onSuccess:d.flash});if(r.data===void 0)return null;let p=ue([],e),m=r.data.agentDefaults.runner??`claude`,h=o(t??m,l(e))??t??m,_=r.data.agentDefaults.models??{};return(0,X.jsxs)(`section`,{"data-slot":`accounts-defaults`,className:`flex flex-col gap-3 rounded-lg border border-border bg-card/40 p-3.5`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h3`,{className:`text-[13px] font-semibold text-foreground`,children:`Defaults for new projects`}),(0,X.jsxs)(`p`,{className:`text-[13px] text-muted-foreground`,children:[`What a project runs when it has not chosen for itself — set once instead of per repository. A project that has chosen keeps its own. `,(0,X.jsx)(ge,{saved:d.saved})]})]}),(0,X.jsx)(de,{rows:p,runner:m,accountFor:()=>null,providerStatus:i,disabled:u.isPending,onPick:e=>{e!==m&&f({agentDefaults:{runner:e}})}}),(0,X.jsxs)(`div`,{className:`settings-account-models flex flex-col gap-2`,children:[(0,X.jsxs)(`label`,{className:`settings-model-agent-choice`,children:[(0,X.jsx)(`span`,{children:`Default model for`}),(0,X.jsx)(q,{"aria-label":`Model agent`,className:`settings-select max-w-full`,value:h,onValueChange:e=>n(e),options:e.runners.map(e=>({value:e.id,label:e.displayName}))})]}),e.runners.filter(e=>e.id===h).map(t=>(0,X.jsxs)(`label`,{className:`settings-account-model flex flex-wrap items-center gap-3`,children:[(0,X.jsx)(D,{className:`size-4 text-accent-icon shrink-0`}),(0,X.jsx)(`span`,{className:`w-28 shrink-0 text-xs text-muted-foreground`,children:t.displayName}),(0,X.jsx)(q,{"aria-label":`Default model for ${t.pickerLabel}`,"data-slot":`accounts-default-model`,"data-runner":t.id,value:_[t.id]??``,disabled:u.isPending,onValueChange:e=>f({agentDefaults:{models:{[t.id]:e||null}}}),className:`settings-select w-64 max-w-full bg-card`,options:[...B(t.id,e,s[t.id]?.data,[_[t.id]]).map(e=>({value:e.id,label:e.label})),...Le(t.id,e,s[t.id])]})]},t.id))]})]})}function Le(e,t,n){let r=I(e,t,n);return r?[{value:z,label:r,disabled:!0}]:[]}function Re({account:e,runners:t,status:n,editable:r}){let i=f();return(0,X.jsxs)(X.Fragment,{children:[n&&n.status!==`connected`&&u(t,e.provider)?.browserLogin?(0,X.jsx)(J,{provider:e.provider,...e.isDefault?{}:{profileId:e.id},label:e.label}):null,r&&n&&n.status!==`connected`&&u(t,e.provider)?.terminalLogin!==!1?(0,X.jsx)(k,{type:`button`,size:`sm`,"data-action":`account-connect`,disabled:i.isPending,onClick:()=>i.mutate({provider:e.provider,...e.isDefault?{}:{profileId:e.id}},{onSuccess:e=>w(e.opened?`Finish signing in in the terminal, then Check again.`:`This account is already connected.`),onError:e=>w(e instanceof S&&e.command?`${e.message} — run: ${e.command}`:e.message,{tone:`danger`})}),children:`Connect`}):null]})}function ze(e,t,n,r){return!n||n.requiresAccountHome===!1?null:e.exists?!e.looksValid&&e.configDir?{slot:`account-unrecognised`,label:`Unrecognized folder`,guidance:`This folder does not look like ${h(t,e.provider)} config yet.`}:null:{slot:`account-missing`,label:`Not initialized`,guidance:r?n.status===`connected`?`Folder not created yet. Use Check again to refresh.`:`Folder not created yet. Connect will make it.`:`Folder not created on the host yet.`}}function $({account:e,runners:t,editable:n,onRemove:i,agent:a}){let o=ee(e),s=r(),c=_e(),l=p(o,e.status===void 0),u=e.status??l.data?.status,d=u?Oe[u.status]:void 0,f=ze(e,t,u,n),m=f?(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,title:d?`Sign-in: ${d.label}`:void 0,children:[(0,X.jsx)(j,{tone:`pending`}),(0,X.jsx)(`span`,{"data-slot":f.slot,className:`text-foreground`,children:f.label})]}):(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,X.jsx)(j,{tone:d?.tone??`neutral`,pulse:d===void 0}),(0,X.jsx)(`span`,{"data-slot":`account-status`,className:`text-foreground`,children:d?.label??`Checking…`})]}),h=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Re,{account:e,runners:t,status:u,editable:n}),(0,X.jsx)(k,{type:`button`,variant:`outline`,size:`sm`,"data-action":`account-recheck`,disabled:s.isPending,title:`Re-probe this account's login now, instead of waiting for the cached answer`,onClick:()=>s.mutate(o,{onError:e=>w(e.message,{tone:`danger`})}),children:`Check again`})]}),g=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`settings-account-label`,children:e.label}),e.isDefault?(0,X.jsx)(ne,{variant:`outline`,"data-slot":`account-discovered`,className:`shrink-0 text-xs font-normal text-muted-foreground`,children:`discovered`}):null]}),_=e.configDir?(0,X.jsx)(`span`,{"data-slot":`account-path`,className:`settings-account-path`,title:e.path,children:Z(e.configDir,c)}):null,v=f?(0,X.jsx)(`p`,{"data-slot":`account-folder-guidance`,className:`settings-account-hint`,children:f.guidance}):null,y=u?.hint?(0,X.jsx)(`p`,{className:`settings-account-hint`,children:u.hint}):null,b=n&&!e.isDefault?(0,X.jsx)(Be,{account:e,onRemove:i}):null,x=(0,X.jsxs)(`div`,{className:`settings-account-readout`,children:[(0,X.jsxs)(`div`,{className:`settings-account-meta-line`,children:[g,m]}),_,v,y]});return a?(0,X.jsxs)(`li`,{"data-slot":`account-row`,"data-account":e.id,"data-primary":``,className:`settings-account-primary`,children:[(0,X.jsx)(Q,{titleId:a.titleId,title:a.title,summary:a.facts,actions:(0,X.jsxs)(X.Fragment,{children:[h,a.addButton]}),actionsSlot:`account-actions`}),(0,X.jsxs)(`div`,{className:`settings-account-meta`,children:[x,b?(0,X.jsx)(`div`,{className:`settings-account-actions`,children:b}):null]})]}):(0,X.jsxs)(`li`,{"data-slot":`account-row`,"data-account":e.id,className:`settings-account-line`,children:[x,(0,X.jsxs)(`div`,{"data-slot":`account-actions`,className:`settings-account-actions`,children:[h,b]})]})}function Be({account:e,onRemove:t}){let[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(e.label),o=s();return(0,X.jsx)(X.Fragment,{children:e.isDefault?null:(0,X.jsx)(`div`,{"data-slot":`account-manage`,className:`settings-account-management`,children:n?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`input`,{type:`text`,autoFocus:!0,"aria-label":`Name for ${e.label}`,"data-slot":`account-rename-input`,value:i,onChange:e=>a(e.target.value),className:`w-48 rounded-md border border-input bg-card px-2 py-1 text-xs outline-none focus-visible:border-ring`}),(0,X.jsx)(k,{type:`button`,variant:`outline`,size:`sm`,"data-action":`account-rename-save`,disabled:o.isPending||i.trim()===``||i.trim()===e.label,onClick:()=>o.mutate({id:e.id,label:i.trim()},{onSuccess:()=>r(!1),onError:e=>w(e.message,{tone:`danger`})}),children:`Save`}),(0,X.jsx)(k,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>{a(e.label),r(!1)},children:`Cancel`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(k,{type:`button`,variant:`outline`,size:`sm`,"data-action":`account-rename`,onClick:()=>r(!0),children:`Rename`}),(0,X.jsx)(k,{type:`button`,variant:`outline`,size:`sm`,"data-action":`account-remove`,onClick:t,children:`Remove account`}),(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Renaming changes what Squawk calls this account, not its folder.`})]})})})}export{ke as GlobalAgentsSection};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{K as r,Lt as i,Vt as a,en as o,ln as s,on as c,qt as l,st as u,un as d}from"./queries-IlC9MZgh.js";import{Er as f,Fi as p,Nr as m,Tr as h,Xn as g,Xr as _,Yn as ee,Zn as te,_i as ne,ai as v,ci as y,er as b,in as x,jt as re,n as S,ni as ie,rt as C,wi as ae,wr as oe,xi as se}from"./toaster-DNnL8v10.js";import{B as w,C as ce,F as T,G as le,I as E,J as ue,N as D,P as de,T as fe,W as O,Y as pe,j as k,z as A}from"./live-protocol-CNUmr-VT.js";import{n as j}from"./chunk-KS7C4IRE-BdLLx37K.js";import{o as M}from"./dist-CCX8mhHc.js";import{r as me}from"./run-detail-refresh-CE0vyYYA.js";import{mt as he,t as ge}from"./design-icons-QbNMZniQ.js";import{t as _e}from"./createLucideIcon-BHp8sXmF.js";import{t as ve}from"./ask-card-D-om0EtP.js";import{t as ye}from"./arrow-right-Dh_Lx3um.js";import{t as be}from"./arrow-up-right-DKGzsMqY.js";import{t as xe}from"./bot-TkDIw4y-.js";import{t as Se}from"./external-link-BE6y205O.js";import{t as Ce}from"./info-DA1x_4bz.js";import{t as we}from"./message-square-B-MD-8rD.js";import{a as Te,o as Ee,r as De}from"./tool-display-CTbToGmi.js";import{t as N}from"./button-BV_AiLj2.js";import{i as Oe,r as ke,t as Ae}from"./popover-BQolmvDR.js";import{t as P}from"./project-router-Dc6KBQsv.js";import"./attention-BI6592lk.js";import{t as F}from"./status-dot-Bmn4xhch.js";import{c as je,i as Me,l as Ne,o as Pe,r as Fe,s as Ie}from"./report-selection-CZ8eb9QP.js";import"./page-shell-BdjH5hyc.js";import{An as Le,un as Re}from"./index-DPfg7xSB.js";import{t as ze}from"./textarea-BGp28xFr.js";import{t as Be}from"./use-finish-run-DO-nnAaa.js";import{t as Ve}from"./review-panel-D4zmYH8O.js";var He=_e(`folder-kanban`,[[`path`,{d:`M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z`,key:`1fr9dc`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M12 10v2`,key:`hh53o1`}],[`path`,{d:`M16 10v6`,key:`1d6xys`}]]),I=e(t(),1),L=n(),R=pe(),z=A().int().nonnegative(),B=O().min(1),Ue=w({title:O().max(160),toolKind:k([`read`,`edit`,`delete`,`move`,`search`,`execute`,`think`,`fetch`,`task`,`plan`,`other`]),status:k([`pending`,`running`,`completed`,`failed`,`declined`]),startedAt:R,endedAt:R.optional()}).strict(),We=k([`pass`,`fail`,`pending`,`skipping`,`cancel`]),Ge=w({checks:D(w({name:O().max(100),bucket:We}).strict()).max(100),counts:w({pass:z,fail:z,pending:z,skipping:z,cancel:z}).strict(),truncated:E(!0).optional()}).strict(),Ke=T(`kind`,[w({kind:E(`human`),since:R,detail:w({question:O().max(500).optional(),reason:k([`question`,`turn-end`,`budget`,`completion`]),queuedMessages:A().int().positive().optional()}).strict()}).strict(),w({kind:E(`usage-limit`),detail:w({resumeAt:O()}).strict()}).strict(),w({kind:E(`workers`),since:R,deadline:R.optional(),detail:w({owed:z,total:z,settled:z,replies:E(!0).optional(),mode:ce.optional(),recipientRunIds:D(B)}).strict()}).strict(),w({kind:E(`peers`),since:R,deadline:R,detail:w({peerRunIds:D(B)}).strict()}).strict(),w({kind:E(`subagents`),since:R,deadline:R,detail:w({running:z}).strict()}).strict(),w({kind:E(`pr`),since:R,deadline:R,detail:w({number:A().int().positive(),target:x,checks:Ge.shape.checks.optional(),counts:Ge.shape.counts.optional(),truncated:E(!0).optional()}).strict()}).strict(),w({kind:E(`process`),since:R,deadline:R,detail:w({pid:A().int(),note:O().optional()}).strict()}).strict(),w({kind:E(`plugin`),since:R,deadline:R.optional(),detail:w({pluginKind:O().min(1).max(64),summary:O().max(256)}).strict()}).strict(),w({kind:E(`timer`),since:R,deadline:R,detail:w({wakeAt:R,note:O().optional()}).strict()}).strict()]),qe={runId:B,title:O(),status:ne,rung:k(ie),runner:se.optional(),model:O().optional(),currentStepId:O().optional(),createdAt:O().optional(),startedAt:O().optional(),finishedAt:O().optional(),wait:Ke.optional(),tool:Ue.optional(),rate:D(z).length(30),error:O().max(200).optional()},Je=w({...qe,revision:z,collected:de()}).strict(),Ye=w({...qe,workers:D(Je)}).strict(),Xe=w({requestId:ue(),relationship:k([`family`,`peer`]),senderRunId:B,recipientRunId:B,text:O().max(500),senderTitle:O().optional(),recipientTitle:O().optional(),createdAt:R,deadline:R.optional()}).strict(),Ze=w({requestId:ue(),senderRunId:B,recipientRunId:B,status:fe.shape.status,observedAt:R}).strict(),Qe=w({generatedAt:R,projects:D(w({projectId:O(),name:O(),loaded:de(),unavailable:w({status:le([E(404),E(409),E(503)]),error:O()}).strict().optional(),inReview:z,tasks:D(Ye),requests:D(Xe),closed:D(Ze)}).strict())}).strict();w({project:le([E(`default`),O().regex(_)]).optional()});var $e=5e3,et=e=>[`workspace`,`activity`,e.kind===`project`?e.projectId:null],tt=e=>e.kind===`project`?`activity:project:${e.projectId}`:`activity:workspace`,nt=e=>e.kind===`project`?`/api/v1/workspace/activity?project=${encodeURIComponent(e.projectId)}`:`/api/v1/workspace/activity`,rt=`the Squawk server answered /workspace/activity with an unexpected body`;function it(e){let t=Qe.safeParse(e);if(!t.success)throw new ee(200,rt);return t.data}async function at(e,t){let n=e.kind===`project`?{project:e.projectId}:{};return it(await b(await g.api.v1.workspace.activity.$get({query:n},te(t)),`/workspace/activity`))}function ot(e,t){return e!==void 0&&Date.parse(t.generatedAt)<Date.parse(e.generatedAt)?e:t}var st=new Date(0).toISOString();function ct(e){return e!==void 0&&e!==st&&!Number.isNaN(Date.parse(e))}var lt=new Set([404,409,503]);function ut(e,t,n,r){let i=e?.projects.find(e=>e.projectId===t)?.name??t;return{generatedAt:e?.generatedAt??st,projects:[{projectId:t,name:i,loaded:!0,unavailable:{status:n,error:r},inReview:0,tasks:[],requests:[],closed:[]}]}}function dt(e,t){return new ee(Number(/^HTTP (\d+)$/.exec(t)?.[1]??0),e&&typeof e==`object`&&typeof e.error==`string`?e.error:t)}var ft=(e,t)=>e.kind===`project`&&lt.has(t.status)?t.status:void 0;function pt(e){let t=e.kind===`project`?e.projectId:void 0,n=(0,I.useMemo)(()=>t===void 0?{kind:`workspace`}:{kind:`project`,projectId:t},[t]),r=(0,I.useMemo)(()=>et(n),[n]),a=p(),o=ae({queryKey:r,queryFn:async({signal:e})=>{let t=a.getQueryData(r);try{return ot(t,await at(n,{signal:e}))}catch(e){let r=e instanceof ee?ft(n,e):void 0;if(r===void 0||n.kind!==`project`)throw e;return ut(t,n.projectId,r,e.message)}},staleTime:1/0});return(0,I.useEffect)(()=>{let e=!0,t=t=>{a.cancelQueries({queryKey:r,exact:!0}).then(()=>{if(!e)return;let i=ft(n,t);if(i!==void 0&&n.kind===`project`){a.setQueryData(r,e=>ut(e,n.projectId,i,t.message));return}let o=a.getQueryCache().find({queryKey:r,exact:!0});o?.setState({status:`error`,error:t,errorUpdatedAt:Date.now(),errorUpdateCount:o.state.errorUpdateCount+1,fetchStatus:`idle`})})},o=n=>{let i;try{i=it(n)}catch(e){t(e);return}a.cancelQueries({queryKey:r,exact:!0}).then(()=>{e&&a.setQueryData(r,e=>ot(e,i))})},s=i(tt(n),o),l=c($e),d,p=()=>{let e=oe()===`finite`&&l!==!1;e&&!d?d=u({path:nt(n),intervalMs:l},(e,n)=>{n===void 0?o(e):t(dt(e,n))}):!e&&d&&(d(),d=void 0)};p();let m=f(p);return()=>{e=!1,m(),d?.(),s()}},[a,r,n]),o}var mt=e=>String(e).padStart(2,`0`);function V(e){let t=Math.max(0,Math.floor(e/1e3)),n=Math.floor(t/3600),r=Math.floor(t/60)%60,i=t%60;return n>0?`${n}:${mt(r)}:${mt(i)}`:`${r}:${mt(i)}`}function H(e){let t=Math.max(0,Math.floor(e/1e3));if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m`;let r=Math.floor(n/60);if(r>=24)return`${Math.floor(r/24)}d`;let i=n%60;return r<6&&i>0?`${r}h ${i}m`:`${r}h`}function U(e,t){let n=e===void 0?NaN:Date.parse(e);return Number.isNaN(n)?0:t-n}var ht=new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`});function W(e){let t=Date.parse(e);return Number.isNaN(t)?e:ht.format(t)}var gt=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`}),_t=new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`});function G(e){let t=typeof e==`number`?e:Date.parse(e);return Number.isNaN(t)?String(e):`${gt.format(t)}, ${_t.format(t)} ${yt()}`}function vt(e){let t=Math.max(0,Math.floor(e/1e3));return t<60?`just now`:t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`}function yt(){return Intl.DateTimeFormat().resolvedOptions().timeZone}var bt=new Set([`queued`,`running`,`waiting`]),xt={review:`Needs review`,failed:`Failed`,done:`Done`,cancelled:`Cancelled`},St={review:`review`,failed:`failed`,done:`done`,cancelled:`cancelled`},K=e=>bt.has(e),Ct=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`,q=e=>v(e.rung).tone,wt=(e,t=`Deadline`)=>e?`${t} ${W(e)}`:void 0;function Tt(e,t,n){return t.length===1&&t[0]!==void 0?`${e} ${n.titleOf(t[0])}`:`${e} ${Ct(t.length,`task`)}`}function Et(e,t){let n=e.tool,r={verb:`Running`,tone:q(e),icon:`tool`},i=n?.endedAt!==void 0&&U(n.endedAt,t.now)>1e4;if(n===void 0)return{...r,main:`Thinking`,...e.startedAt?{since:e.startedAt}:{}};let a=`Last tool ${H(U(n.endedAt??n.startedAt,t.now))} ago`;return i?{...r,main:`Thinking`,detail:a,since:n.endedAt??n.startedAt}:{...r,main:n.title,mono:!0,detail:a,since:n.startedAt}}function Dt(e,t){let n={verb:`Needs you`,tone:q(e),icon:`user`,...t?{since:t.since}:{}};if(t?.detail.reason===`question`)return t.detail.question?{...n,main:t.detail.question,action:`answer`}:{...n,main:`Your turn`,action:`answer`};if(t?.detail.reason===`budget`){let e=t.detail.queuedMessages;return{...n,main:e?`Automatic wakes used up · ${Ct(e,`message`)} queued`:`Automatic wakes used up`,action:`open`}}return{...n,main:`Your turn`,action:`open`}}function Ot(e){return{verb:`Needs permission`,tone:q(e),icon:`user`,main:`Approval required`,action:`open`}}function kt(e,t,n){let{owed:r,total:i,settled:a,replies:o,mode:s,recipientRunIds:c}=t.detail,l=i>0?a/i:0,u={tone:q(e),since:t.since};if(o){let e=c.length>0?Tt(`From`,c,n):`Waiting for replies`;return{...u,verb:`Waiting for reply`,icon:`reply`,main:e,...J(`detail`,wt(t.deadline,`Reply due`))}}let d=c.length>0?`${r} owed · ${a} settled`:s?`${At[s]} of ${i} · ${a} settled`:`${r} owed`;return{...u,verb:`Waiting for workers`,icon:`workers`,main:d,bar:l,...J(`detail`,wt(t.deadline))}}var At={one:`One`,any:`Any`,all:`All`};function jt(e){let t=e.detail.counts;if(t===void 0)return`PR ${e.detail.number} checks`;let n=t.pass+t.fail+t.pending;return`PR ${e.detail.number} checks · ${t.pass} of ${n} passed`}var Mt=[`fail`,`pending`,`pass`,`skipping`,`cancel`];function Nt(e){let{counts:t,checks:n=[],truncated:r}=e.detail;if(!r||t===void 0)return;let i=e=>Math.max(0,t[e]-n.filter(t=>t.bucket===e).length),a=Mt.reduce((e,t)=>e+i(t),0),o=Mt.find(e=>i(e)>0);return a>0&&o?{count:a,bucket:o}:void 0}var Pt=[[`pass`,`passed`],[`fail`,`failed`],[`pending`,`pending`],[`skipping`,`skipped`],[`cancel`,`cancelled`]];function Ft(e){let{counts:t,checks:n}=e.detail,r=e=>t?t[e]:(n??[]).filter(t=>t.bucket===e).length,i=Pt.filter(([e])=>r(e)>0).map(([e,t])=>`${r(e)} ${t}`),a=Nt(e);return a&&i.push(`+${a.count} more not listed`),i.length>0?i.join(`, `):void 0}function It(e,t){let n={tone:q(e),since:t.since,...J(`detail`,wt(t.deadline))};if(t.detail.target!==`checks`)return{...n,verb:`Waiting for merge`,icon:`merge`,main:`PR ${t.detail.number}`};let r=t.detail.checks?[...t.detail.checks].sort((e,t)=>e.name.localeCompare(t.name)):void 0;return{...n,verb:`Waiting for CI`,icon:`ci`,main:jt(t),...J(`checks`,r),...J(`overflow`,Nt(t)),...J(`checkSummary`,Ft(t))}}function J(e,t){return t===void 0?{}:{[e]:t}}function Lt(e,t,n){let r=q(e);switch(t.kind){case`workers`:return kt(e,t,n);case`peers`:return{verb:`Waiting for a peer`,tone:r,icon:`peer`,since:t.since,main:Tt(`For`,t.detail.peerRunIds,n),detail:`Deadline ${W(t.deadline)}`};case`subagents`:return{verb:`Waiting for subagents`,tone:r,icon:`subagents`,since:t.since,main:Ct(t.detail.running,`native subagent`),detail:`Deadline ${W(t.deadline)}`};case`pr`:return It(e,t);case`process`:return{verb:`Waiting for command`,tone:r,icon:`command`,since:t.since,main:t.detail.note??`Process ${t.detail.pid}`,detail:`Running ${V(U(t.since,n.now))} · deadline ${W(t.deadline)}`};case`plugin`:return{verb:`Waiting`,tone:r,icon:`timer`,since:t.since,main:t.detail.summary,...J(`detail`,wt(t.deadline))};case`timer`:return{verb:`Monitoring`,tone:r,icon:`timer`,since:t.since,main:t.detail.note??`Timer`,detail:`Wakes ${W(t.detail.wakeAt)} · in ${V(-U(t.detail.wakeAt,n.now))}`};case`usage-limit`:return Rt(e,t.detail.resumeAt,n);case`human`:return}}function Rt(e,t,n){let r=Date.parse(t),i=Number.isNaN(r)?`Resumes ${t}`:`Resumes ${W(t)} · in ${V(r-n.now)}`;return{verb:`Usage limit`,tone:q(e),icon:`pause`,main:`Paused until reset`,detail:i}}function zt(e,t){let n=e.wait&&`since`in e.wait?e.wait.since:e.startedAt;return{verb:`Queued`,tone:q(e),icon:`queued`,main:`Waiting for a free slot`,...n?{since:n,detail:`Waiting ${H(U(n,t.now))}`}:{}}}function Bt(e,t){return{verb:xt[e.status]??e.status,tone:q(e),icon:St[e.status]??`done`,main:t}}function Vt(e,t){return K(e.status)?Ht(e,t):Bt(e,Ct(e.workers.filter(e=>K(e.status)).length,`live worker`))}function Ht(e,t){let n=e.wait;switch(e.rung){case`running`:return Et(e,t);case`needs-permission`:return Ot(e);case`needs-you`:return Dt(e,n?.kind===`human`?n:void 0);case`usage-limit`:return n?.kind===`usage-limit`?Rt(e,n.detail.resumeAt,t):{verb:`Usage limit`,tone:q(e),icon:`pause`,main:`Paused until reset`};case`queued`:case`waiting-for-capacity`:return zt(e,t);default:return(n&&Lt(e,n,t))??zt(e,t)}}function Ut(e,t,n){if(n!==void 0&&K(e.status))return{verb:`Asks parent`,tone:q(e),main:`“${n}”`,asks:!0};let r=Wt(e,t);return{verb:r.verb,tone:r.tone,main:r.main,...r.mono?{mono:!0}:{}}}function Wt(e,t){switch(e.status){case`done`:return Bt(e,e.collected?`Collected`:`Ready to collect`);case`review`:return Bt(e,`Waiting for the parent’s review`);case`failed`:case`cancelled`:return Bt(e,e.error??xt[e.status]??e.status);default:return Ht({...e,workers:[]},t)}}var Gt={success:`text-semantic-green`,pending:`text-semantic-amber`,danger:`text-semantic-red`,accent:`text-accent-text`,info:`text-semantic-info`,running:`text-semantic-violet`,neutral:`text-muted-foreground`};function Kt({tone:e,className:t,children:n,...r}){return(0,L.jsx)(`span`,{...r,className:M(`bg-card-2`,{"text-semantic-green":e===`success`,"text-semantic-amber":e===`pending`,"text-semantic-red":e===`danger`,"text-accent-text":e===`accent`,"text-semantic-info":e===`info`,"text-semantic-violet":e===`running`,"text-muted-foreground":e===`neutral`},t),children:n})}var qt={success:`border-success`,pending:`border-pending-strong`,danger:`border-danger`,accent:`border-accent-strong`,info:`border-info`,running:`border-status-running`,neutral:`border-soft-foreground`},Jt={success:`bg-success`,pending:`bg-pending-strong`,danger:`bg-danger`,accent:`bg-accent-strong`,info:`bg-info`,running:`bg-status-running`,neutral:`bg-soft-foreground`};function Yt(e,t){let n=v(e.rung),r=e.rung===`waiting-on-workers`&&(t===`worker`||e.wait?.kind===`peers`);return{tone:n.tone,shape:r?`ring`:n.shape,label:Qt(e,t)??Le(e.rung,n.label)}}var Xt=(e,t,n)=>`${e} ${t} ${n}${t===1?``:`s`}`;function Zt(e){return e?.kind===`workers`&&!e.detail.replies&&e.detail.owed>0}function Qt(e,t){let n=e.wait;if(e.rung===`waiting-on-workers`){if(t===`worker`&&!Zt(n))return`Waiting for parent reply`;if(n?.kind===`peers`&&n.detail.peerRunIds.length>0)return Xt(`Waiting for`,n.detail.peerRunIds.length,`task`);if(n?.kind===`workers`&&n.detail.replies)return`Waiting for replies`;if(n?.kind===`workers`&&n.detail.owed>0)return Xt(`Waiting for`,n.detail.owed,`worker`)}if(e.rung===`waiting-on-subagents`&&n?.kind===`subagents`&&n.detail.running>0)return Xt(`Waiting for`,n.detail.running,`subagent`)}function $t(e,t){if(K(e.status))return e.rung===`running`&&t===`filled`?`activity-pulse`:t===`filled`?void 0:`activity-breathe`}function en({run:e,role:t}){let{tone:n,shape:r,label:i}=Yt(e,t);return(0,L.jsx)(`span`,{"data-activity-anchor":e.runId,className:M(`inline-flex size-[12px] shrink-0 items-center justify-center`,$t(e,r)),children:(0,L.jsx)(F,{tone:n,shape:r,role:`img`,"aria-label":i})})}var tn={pass:`bg-success`,fail:`bg-danger`,pending:`bg-pending`,skipping:`border border-soft-foreground`,cancel:`border border-soft-foreground`},nn=(e,t)=>t?`activity-check-pass`:e===`pending`?`activity-breathe-fast`:void 0;function rn({checks:e,overflow:t,passed:n,className:r}){return(0,L.jsxs)(`span`,{"data-slot":`activity-checks`,"aria-hidden":`true`,className:r??M(`col-start-2 mt-[5px] flex items-center`,e.length>40?`gap-px`:`gap-[3px]`),children:[e.map(e=>(0,L.jsx)(`i`,{"data-bucket":e.bucket,"data-passed":n.has(e.name)?`true`:void 0,title:e.name,className:M(`h-[5px] min-w-px flex-1 rounded-[2px]`,tn[e.bucket],nn(e.bucket,n.has(e.name)))},e.name)),t?(0,L.jsxs)(`span`,{"data-slot":`activity-checks-overflow`,"data-bucket":t.bucket,className:`ml-1 flex shrink-0 items-center gap-1 text-xs leading-none text-muted-foreground tabular-nums`,children:[(0,L.jsx)(`i`,{className:M(`h-[5px] w-2 rounded-[2px]`,tn[t.bucket])}),`+`,t.count]}):null]})}function an({rate:e,className:t}){let n=e.reduce((e,t)=>e+t,0),r=Math.max(4,...e);return(0,L.jsxs)(`svg`,{"data-slot":`activity-heartbeat`,role:`img`,"aria-label":`${n} tool call${n===1?``:`s`} in the last ${e.length} s`,viewBox:`0 0 62 16`,className:M(`block h-4 w-[62px] shrink-0`,t),children:[n>0?(0,L.jsx)(`path`,{d:`M0 15.5h62`,className:`stroke-border`}):null,e.map((e,t)=>{if(e<=0)return null;let n=Math.max(1.5,e/r*14);return(0,L.jsx)(`rect`,{x:t*2.07,y:15-n,width:1.4,height:n,className:`fill-status-running`},t)})]})}var on=`inline-flex min-w-0 items-center rounded-md border px-3 py-1 text-[12px] font-medium focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring max-md:min-h-11 pointer-coarse:min-h-11`;function sn({scope:e,projectId:t,projectName:n,projects:r}){let i=e=>M(on,e?`border-border bg-card text-foreground shadow-xs`:`border-transparent text-muted-foreground hover:text-foreground`);return(0,L.jsxs)(`nav`,{"aria-label":`Activity scope`,"data-slot":`activity-scope`,className:`inline-flex max-w-full flex-wrap rounded-lg border border-border bg-muted/60 p-1`,children:[(r??(t===null?[]:[{id:t,name:n??t}])).map(n=>(0,L.jsx)(j,{to:`/p/${encodeURIComponent(n.id)}/activity`,"aria-current":e===`project`&&n.id===t?`page`:void 0,className:i(e===`project`&&n.id===t),children:(0,L.jsx)(`span`,{className:`max-w-40 truncate`,title:n.name,children:n.name})},n.id)),(0,L.jsx)(j,{to:`/activity`,state:{activityProjectId:t},"aria-current":e===`all`?`page`:void 0,className:i(e===`all`),children:`All projects`})]})}function cn({grouped:e,onToggle:t}){return(0,L.jsxs)(`button`,{type:`button`,"data-slot":`activity-group-toggle`,"aria-pressed":e,onClick:t,className:M(`inline-flex h-9 items-center gap-1.5 rounded-lg border px-2.5 text-[12px] font-medium transition-colors focus-visible:outline-2 focus-visible:outline-ring max-md:min-h-11 pointer-coarse:min-h-11`,e?`border-accent-text/60 bg-accent-strong/10 text-foreground`:`border-border bg-card text-muted-foreground hover:text-foreground`),children:[(0,L.jsx)(He,{"aria-hidden":`true`,className:`size-3.5`}),(0,L.jsx)(`span`,{children:`Group by project`})]})}function ln(){let e=`flex items-center gap-2`;return(0,L.jsxs)(Ae,{children:[(0,L.jsx)(Oe,{asChild:!0,children:(0,L.jsxs)(`button`,{type:`button`,"data-slot":`activity-legend`,"aria-label":`Activity legend`,className:`inline-flex h-9 items-center gap-1.5 rounded-lg border border-border bg-card px-2.5 text-[12px] font-medium text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:min-h-11 pointer-coarse:min-h-11`,children:[(0,L.jsx)(Ce,{"aria-hidden":`true`,className:`size-3.5`}),(0,L.jsx)(`span`,{children:`Legend`})]})}),(0,L.jsx)(ke,{align:`end`,className:`w-80 text-[12px] text-muted-foreground`,children:(0,L.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,L.jsx)(`p`,{className:`text-xs font-semibold tracking-[0.05em] text-foreground uppercase`,children:`Activity legend`}),(0,L.jsxs)(`div`,{className:e,children:[(0,L.jsx)(F,{tone:`pending`,"aria-hidden":`true`}),(0,L.jsxs)(`span`,{children:[(0,L.jsx)(`strong`,{className:`text-foreground`,children:`Needs answer`}),` — waiting for your reply`]})]}),(0,L.jsxs)(`div`,{className:e,children:[(0,L.jsx)(F,{tone:`info`,"aria-hidden":`true`}),(0,L.jsxs)(`span`,{children:[(0,L.jsx)(`strong`,{className:`text-foreground`,children:`Needs review`}),` — ready for diff review or PR`]})]}),(0,L.jsxs)(`div`,{className:e,children:[(0,L.jsx)(F,{tone:`danger`,"aria-hidden":`true`}),(0,L.jsxs)(`span`,{children:[(0,L.jsx)(`strong`,{className:`text-foreground`,children:`Failed`}),` — stopped with an error`]})]}),(0,L.jsxs)(`div`,{className:e,children:[(0,L.jsx)(F,{tone:`running`,"aria-hidden":`true`}),(0,L.jsxs)(`span`,{children:[(0,L.jsx)(`strong`,{className:`text-foreground`,children:`Working`}),` — running tools right now`]})]}),(0,L.jsxs)(`div`,{className:e,children:[(0,L.jsx)(F,{tone:`info`,shape:`ring`,"aria-hidden":`true`}),(0,L.jsxs)(`span`,{children:[(0,L.jsx)(`strong`,{className:`text-foreground`,children:`Ring`}),` — waiting on CI, peer, or timer`]})]}),(0,L.jsxs)(`div`,{className:e,children:[(0,L.jsx)(F,{tone:`running`,shape:`workers`,"aria-hidden":`true`}),(0,L.jsxs)(`span`,{children:[(0,L.jsx)(`strong`,{className:`text-foreground`,children:`Robot`}),` — waiting on its own workers`]})]}),(0,L.jsxs)(`div`,{className:e,children:[(0,L.jsx)(an,{rate:[0,2,5,1,3,0,4,2],className:`w-[34px]`}),(0,L.jsx)(`span`,{children:`Heartbeat: tool calls, last 30 s`})]}),(0,L.jsxs)(`div`,{className:e,children:[(0,L.jsx)(`svg`,{"aria-hidden":`true`,viewBox:`0 0 34 10`,className:`h-2.5 w-[34px] shrink-0`,children:(0,L.jsx)(`path`,{d:`M2 5h30`,strokeWidth:2,strokeDasharray:`6 4`,className:`stroke-message-peer-accent`})}),(0,L.jsx)(`span`,{children:`Open peer request (task → task)`})]}),(0,L.jsxs)(`div`,{className:e,children:[(0,L.jsxs)(`svg`,{"aria-hidden":`true`,viewBox:`0 0 34 10`,className:`h-2.5 w-[34px] shrink-0`,children:[(0,L.jsx)(`path`,{d:`M2 5h24`,strokeWidth:2.2,strokeLinecap:`round`,strokeDasharray:`0 6`,className:`stroke-message-peer-accent opacity-80`}),(0,L.jsx)(`circle`,{cx:`29.5`,cy:`5`,r:`3`,strokeWidth:1.6,className:`fill-card stroke-message-peer-accent`})]}),(0,L.jsx)(`span`,{children:`Waiting for a peer to write`})]})]})})]})}function un({scope:e,projectId:t,projectName:n,projects:r,grouped:i,onToggleGroup:a}){return(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(ln,{}),a?(0,L.jsx)(cn,{grouped:!!i,onToggle:a}):null,(0,L.jsx)(sn,{scope:e,projectId:t,projectName:n,projects:r})]})}function dn({now:e,updatedAt:t,stale:n}){let r=t!==void 0&&!Number.isNaN(Date.parse(t));return(0,L.jsxs)(`span`,{"data-slot":`activity-clock`,"data-stale":n?`true`:void 0,title:G(e),className:`inline-flex items-center gap-1.5 text-[13px] text-muted-foreground tabular-nums`,children:[(0,L.jsx)(`span`,{"data-tone":`success`,className:M(`inline-flex size-[12px] items-center justify-center`,!n&&`activity-pulse`),children:(0,L.jsx)(F,{tone:n?`neutral`:`success`,"aria-hidden":`true`})}),(0,L.jsx)(`b`,{className:M(`font-semibold`,n?`text-muted-foreground`:`text-success`),children:n?`Not updating`:`Live`}),r?(0,L.jsxs)(`span`,{children:[`· updated `,vt(U(t,e))]}):null]})}function fn({name:e,now:t,updatedAt:n,stale:r=!1,scopeSwitch:i}){return{title:`Activity`,scope:e,subtitle:t===void 0?void 0:(0,L.jsx)(dn,{now:t,updatedAt:n,stale:r}),secondaryActions:i}}function pn({primary:e=!1}){return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(N,{variant:e?`primary`:`outline`,size:`sm`,asChild:!0,className:`py-1.5`,children:(0,L.jsx)(P,{to:`/new`,children:`New task`})}),(0,L.jsx)(N,{variant:`outline`,size:`sm`,asChild:!0,className:`py-1.5`,children:(0,L.jsx)(P,{to:`/`,children:`View tasks`})})]})}function mn({value:e,bump:t}){return(0,L.jsx)(`strong`,{"data-bump":t===void 0?void 0:`true`,className:M(`font-semibold text-foreground tabular-nums`,t!==void 0&&`activity-bump`),children:e},t??`still`)}function Y({icon:e,count:t,label:n,bump:r}){return(0,L.jsxs)(`li`,{"data-slot":`activity-chip`,"data-chip":n,className:`inline-flex items-center gap-[7px] px-2 py-1 text-xs text-muted-foreground`,children:[e,(0,L.jsx)(mn,{value:t,bump:r}),` `,n]})}function hn({summary:e,tasksTo:t,bumps:n={}}){let r=e=>n[e]?.key;return(0,L.jsxs)(`ul`,{"data-slot":`activity-summary`,"aria-live":`polite`,"aria-label":`Summary`,className:`flex flex-wrap gap-2`,children:[(0,L.jsx)(Y,{icon:(0,L.jsx)(F,{tone:`pending`,"aria-hidden":`true`}),count:e.needsYou,label:`Needs you`,bump:r(`needsYou`)}),(0,L.jsx)(Y,{icon:(0,L.jsx)(F,{tone:`running`,"aria-hidden":`true`}),count:e.working,label:`Working`,bump:r(`working`)}),(0,L.jsx)(Y,{icon:(0,L.jsx)(F,{tone:`running`,shape:`ring`,"aria-hidden":`true`}),count:e.waiting,label:`Waiting`,bump:r(`waiting`)}),(0,L.jsx)(Y,{icon:(0,L.jsx)(F,{tone:`neutral`,shape:`ring`,"aria-hidden":`true`}),count:e.queued,label:`Queued`,bump:r(`queued`)}),(0,L.jsx)(Y,{icon:(0,L.jsx)(xe,{"aria-hidden":`true`,className:`size-3.5`}),count:e.activeWorkers,label:`Active workers`,bump:r(`activeWorkers`)}),(0,L.jsx)(Y,{icon:(0,L.jsx)(we,{"aria-hidden":`true`,className:`size-3.5 text-message-peer-accent`}),count:e.openRequests,label:`Open requests`,bump:r(`openRequests`)}),(0,L.jsx)(`li`,{"data-slot":`activity-chip`,"data-chip":`Needs review`,children:(0,L.jsxs)(P,{to:t,className:`inline-flex items-center gap-[7px] rounded-full border border-card-edge bg-card px-[11px] py-[5px] text-xs text-muted-foreground shadow-card transition-colors hover:border-accent-text/40 hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:min-h-11`,children:[(0,L.jsx)(F,{tone:`info`,"aria-hidden":`true`}),(0,L.jsx)(mn,{value:e.inReview,bump:r(`inReview`)}),` Needs review`,(0,L.jsx)(be,{"aria-hidden":`true`,className:`size-3 text-soft-foreground`})]})})]})}function gn(e){if(e.unavailable)return e.unavailable.error;if(!e.loaded)return`Not loaded in this cockpit`}function _n(e){let t=new Map;for(let n of e.tasks){t.set(n.runId,{title:n.title,cardId:n.runId,role:`root`});for(let e of n.workers)t.set(e.runId,{title:e.title,cardId:n.runId,role:`worker`})}return t}function X(e,t,n){return e.get(t)?.title??n??`Unreadable task`}var vn=(e,t)=>X(e,t.senderRunId,t.senderTitle),yn=(e,t)=>X(e,t.recipientRunId,t.recipientTitle),bn=(e,t)=>`wait:${e}:${t}`;function Z(e){let t=[];for(let n of e){let e=n.wait;if(!(!K(n.status)||e?.kind!==`peers`))for(let r of new Set(e.detail.peerRunIds))r!==n.runId&&t.push({id:bn(n.runId,r),waiterRunId:n.runId,peerRunId:r,since:e.since,deadline:e.deadline})}return t}function xn(e,t){let n=new Set;for(let r of t)r.waiterRunId===e&&n.add(r.peerRunId),r.peerRunId===e&&n.add(r.waiterRunId);return n}function Sn(e,t){return t.filter(t=>t.waiterRunId===e)}function Cn(e,t,n,r=[]){let i=[];for(let r of t)r.senderRunId===e&&i.push(`Waiting for a reply from ${yn(n,r)}`),r.recipientRunId===e&&i.push(`${vn(n,r)} waits for your reply`);for(let t of r)t.waiterRunId===e&&i.push(`Waiting for a message from ${X(n,t.peerRunId)}`),t.peerRunId===e&&i.push(`${X(n,t.waiterRunId)} waits for you to write`);return i}function wn(e,t,n){return n.find(n=>n.relationship===`family`&&n.senderRunId===e&&n.recipientRunId===t)}function Tn(e,t){let n=-U(e,t);return n>=1e3?`reply due in ${V(n)}`:`reply overdue`}function En(e,t){return t.filter(t=>t.relationship===`peer`&&t.senderRunId===e)}function Dn(e,t){return e.relationship===`peer`?{kind:`Request`,relation:`Peer`}:{kind:`Question`,relation:On[kn(e,t)]}}var On={worker:`Worker → parent`,parent:`Parent → worker`,unknown:`Family`};function kn(e,t){let n=t.get(e.senderRunId)?.role;if(n)return n===`worker`?`worker`:`parent`;let r=t.get(e.recipientRunId)?.role;return r?r===`root`?`worker`:`parent`:`unknown`}var An=new Set([`queued`,`waiting-for-capacity`]);function jn(e){if(K(e.status))return y(e.rung)?`needsYou`:e.rung===`running`?`working`:An.has(e.rung)?`queued`:`waiting`}function Mn(e){let t={needsYou:0,working:0,waiting:0,queued:0,activeWorkers:0,openRequests:0,inReview:0};for(let n of e){t.inReview+=n.inReview,t.openRequests+=n.requests.length;for(let e of n.tasks){let n=jn(e);n&&(t[n]+=1),t.activeWorkers+=e.workers.filter(e=>K(e.status)).length}}return t}function Nn(e,t=()=>!1){let n=0,r=0;for(let i of e.workers)t(i.runId)||((i.status===`done`||i.status===`cancelled`)&&(n+=1),i.status===`failed`&&(n+=1,r+=1));return{finished:n,failed:r}}function Pn({finished:e,failed:t}){if(e!==0)return t>0?`✓ ${e} finished · ${t} failed`:`✓ ${e} worker${e===1?``:`s`} finished`}var Q={flash:1300,cardEnter:700,cardLeave:500,workerEnter:700,workerHold:3e3,workerFold:500,comet:1100,replied:900,fade:800,bump:500,slide:450,check:800},$={flash:{},entering:{},leaving:{},workerEnter:{},workerHold:{},opening:{},closing:{},waitsClosing:{},comets:{},bumps:{},slides:{},checks:{}},Fn=(e,t)=>`${e}\n${t}`;function In(e,t){let n=Fn(t,``);return new Set(Object.keys(e.checks).filter(e=>e.startsWith(n)).map(e=>e.slice(n.length)))}var Ln=class{key;changes=[];timers=[];constructor(e){this.key=e}timed(e,t,n,r){this.changes.push({field:e,id:t,value:{...n,key:this.key}}),this.timers.push({after:r,change:{field:e,id:t,ifKey:this.key}})}later(e,t,n,r){this.timers.push({after:r,change:{field:e,id:t,value:{...n,key:this.key},ifKey:this.key}})}drop(e,t){this.changes.push({field:e,id:t})}},Rn={done:`success`,review:`success`,failed:`danger`,cancelled:`neutral`};function zn(e,t){let n=Rn[t.status]??`success`;if(t.status===`review`){e.timed(`workerHold`,t.runId,{tone:n,phase:`flash`},Q.flash);return}e.timed(`workerHold`,t.runId,{tone:n,phase:`flash`},Q.workerHold+Q.workerFold),e.later(`workerHold`,t.runId,{tone:n,phase:`fold`},Q.workerHold)}function Bn(e,t){e.drop(`closing`,t.requestId),e.timed(`opening`,t.requestId,{},Q.fade),e.timed(`comets`,`${t.requestId}:open:${e.key}`,{requestId:t.requestId,reverse:!1,tone:t.relationship},Q.comet)}function Vn(e,t,n,r){let i=n.requestId;if(e.drop(`opening`,i),!r){e.timed(`closing`,i,{projectId:t,request:n,replied:!1,phase:`fade`},Q.fade);return}let a=Q.comet+Q.replied+Q.fade;e.timed(`closing`,i,{projectId:t,request:n,replied:!0,phase:`reply`},a),e.later(`closing`,i,{projectId:t,request:n,replied:!0,phase:`replied`},Q.comet),e.later(`closing`,i,{projectId:t,request:n,replied:!0,phase:`fade`},Q.comet+Q.replied),e.timed(`comets`,`${i}:reply:${e.key}`,{requestId:i,reverse:!0,tone:`success`},Q.comet)}function Hn(e,t){switch(t.kind){case`rung-changed`:return e.timed(`flash`,t.task.runId,{tone:v(t.task.rung).tone},Q.flash);case`tool-started`:return e.timed(`slides`,t.runId,{},Q.slide);case`worker-started`:return e.timed(`workerEnter`,t.worker.runId,{},Q.workerEnter);case`worker-settled`:return zn(e,t.worker);case`card-entered`:return e.drop(`leaving`,t.task.runId),e.timed(`entering`,t.task.runId,{},Q.cardEnter);case`card-left`:return e.timed(`leaving`,t.task.runId,{projectId:t.projectId,task:t.task},Q.cardLeave);case`check-passed`:return e.timed(`checks`,Fn(t.runId,t.name),{},Q.check);case`request-opened`:return Bn(e,t.request);case`request-closed`:return Vn(e,t.projectId,t.request,t.status===`replied`);case`chip-changed`:return e.timed(`bumps`,t.chip,{},Q.bump);case`wait-opened`:return e.drop(`waitsClosing`,t.wait.id),e.timed(`opening`,t.wait.id,{},Q.fade);case`wait-closed`:return e.drop(`opening`,t.wait.id),e.timed(`waitsClosing`,t.wait.id,{projectId:t.projectId,wait:t.wait},Q.fade)}}function Un(e,t,n){let r=new Ln(t);if(!n)for(let t of e)Hn(r,t);return{changes:r.changes,timers:r.timers}}function Wn(e,t){let n=e[t.field];if(t.ifKey!==void 0&&n[t.id]?.key!==t.ifKey||t.value===void 0&&!(t.id in n))return e;let r={...n};return t.value===void 0?delete r[t.id]:r[t.id]=t.value,{...e,[t.field]:r}}function Gn(e,t){return t.reduce(Wn,e)}function Kn(e,t,n){let r=new Set(t.map(e=>e.id));return Object.values(n.waitsClosing).filter(t=>t.projectId===e&&!r.has(t.wait.id)).map(e=>e.wait)}function qn({runId:e,requests:t,waits:n,index:r,link:i,pathOf:a,className:o,linkClassName:s}){let c=En(e,t),l=Sn(e,n);return c.length===0&&l.length===0?null:(0,L.jsxs)(`ul`,{"data-slot":`activity-peer-links`,className:o,children:[c.map(e=>(0,L.jsx)(`li`,{children:(0,L.jsxs)(i,{to:a(e.recipientRunId),className:s,children:[`→ `,yn(r,e)]})},e.requestId)),l.map(e=>(0,L.jsx)(`li`,{children:(0,L.jsxs)(i,{to:a(e.peerRunId),className:s,children:[`⋯ waits on `,X(r,e.peerRunId)]})},e.id))]})}var Jn=e=>`/tasks/${encodeURIComponent(e)}`;function Yn({texts:e}){return e.length===0?null:(0,L.jsx)(`ul`,{"data-slot":`activity-line-text`,className:`sr-only`,children:e.map((e,t)=>(0,L.jsx)(`li`,{children:e},t))})}var Xn={compact:{base:`relative flex flex-wrap items-center gap-x-2 gap-y-0.5 rounded-md px-2 py-1 text-[12px] text-muted-foreground`,asks:`border-l-2 border-dashed border-message-inbound-accent bg-message-inbound-bg`,shape:void 0,title:`min-w-0 truncate text-[12px] font-medium text-foreground`,line:`truncate text-xs text-muted-foreground tabular-nums`,main:`text-foreground`},card:{base:`relative grid grid-cols-[14px_minmax(0,1fr)] items-start gap-x-2 rounded-lg py-[5px] before:absolute before:top-[13px] before:-left-3.5 before:w-2.5 before:border-t before:border-border`,asks:`-mx-1.5 bg-message-inbound-bg px-1.5`,shape:`mt-[3px]`,title:`min-w-0 truncate text-[12.5px] font-medium text-foreground`,line:`col-start-2 truncate text-xs text-muted-foreground tabular-nums`,main:void 0}};function Zn({to:e,title:t,global:n}){let r=`relative z-[1] hover:underline focus-visible:outline-2 focus-visible:outline-ring max-md:inline-flex max-md:min-h-11 max-md:items-center`;return n?(0,L.jsx)(j,{to:e,className:r,children:t}):(0,L.jsx)(P,{to:e,className:r,children:t})}function Qn({worker:e,parentId:t,requests:n,index:r,ctx:i,motion:a,href:s,global:c=!1,compact:u=!1}){let d=Ut(e,i,wn(e.runId,t,n)?.text),f=a.workerHold[e.runId],p=o().data,m=u?Xn.compact:Xn.card,h=[e.runner?l(p,e.runner):void 0,e.model].filter(Boolean).join(` · `);return(0,L.jsxs)(`li`,{"data-slot":`activity-worker`,"data-run":e.runId,"data-asks":d.asks?`true`:void 0,"data-hold":f?.phase,className:M(m.base,d.asks&&m.asks,e.runId in a.workerEnter&&`activity-row-enter`,f?.phase===`fold`&&`activity-row-fold`),children:[f?(0,L.jsx)(`span`,{"aria-hidden":`true`,className:M(`activity-row-flash`,Jt[f.tone])},f.key):null,(0,L.jsx)(`span`,{className:m.shape,children:(0,L.jsx)(en,{run:e,role:`worker`})}),(0,L.jsxs)(`span`,{className:m.title,children:[(0,L.jsx)(Zn,{to:s??Jn(e.runId),title:e.title,global:c}),h?(0,L.jsx)(`span`,{className:`ml-1.5 text-xs font-normal text-muted-foreground`,children:h}):null]}),(0,L.jsxs)(`span`,{"data-slot":`activity-worker-line`,className:m.line,children:[(0,L.jsx)(`b`,{className:M(`font-semibold`,Gt[d.tone]),children:d.verb}),` · `,(0,L.jsx)(`span`,{className:M(m.main,d.mono&&`font-mono`),children:d.main})]}),(0,L.jsx)(Yn,{texts:Cn(e.runId,n,r)})]})}function $n({workers:e}){return(0,L.jsxs)(`div`,{"data-slot":`activity-worker-dots`,className:`mt-2 ml-[18px] flex flex-wrap items-center gap-1 text-xs text-muted-foreground`,children:[e.map(e=>(0,L.jsx)(en,{run:e,role:`worker`},e.runId)),(0,L.jsxs)(`span`,{className:`ml-1`,children:[e.length,` worker`,e.length===1?``:`s`]})]})}function er({task:e,requests:t,index:n,ctx:r,dense:i=!1,motion:a,projectId:o,global:s=!1,compact:c=!1}){let l=e=>e in a.workerHold,u=e.workers.filter(e=>K(e.status)||e.status===`review`||l(e.runId)),d=Pn(Nn(e,l));if(u.length===0&&!d)return null;let f=e=>s&&o?`/p/${encodeURIComponent(o)}/tasks/${encodeURIComponent(e)}`:Jn(e);return c?(0,L.jsxs)(`div`,{className:`ml-4 border-l border-border pl-3`,children:[u.length>0?(0,L.jsx)(`ul`,{"data-slot":`activity-workers`,className:`flex flex-col gap-0.5`,children:u.map(i=>(0,L.jsx)(Qn,{worker:i,parentId:e.runId,requests:t,index:n,ctx:r,motion:a,href:f(i.runId),global:s,compact:!0},i.runId))}):null,d?(0,L.jsx)(`p`,{"data-slot":`activity-finished`,className:`mt-1 px-2 text-xs text-muted-foreground`,children:d}):null]}):(0,L.jsxs)(L.Fragment,{children:[u.length>0&&i?(0,L.jsx)($n,{workers:u}):null,u.length>0&&!i?(0,L.jsx)(`ul`,{"data-slot":`activity-workers`,className:`mt-2 ml-1 border-l border-border pl-3.5`,children:u.map(i=>(0,L.jsx)(Qn,{worker:i,parentId:e.runId,requests:t,index:n,ctx:r,motion:a},i.runId))}):null,d?(0,L.jsx)(`p`,{"data-slot":`activity-finished`,className:`mt-1.5 ml-[18px] text-xs text-muted-foreground`,children:d}):null]})}function tr(e,t){return t?{onPointerEnter:()=>t(`pointer`,e),onPointerLeave:()=>t(`pointer`,void 0),onFocus:()=>t(`focus`,e),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||t(`focus`,void 0)}}:{}}function nr({task:e,motion:t,glow:n}){let r=t.flash[e.runId];return(0,L.jsxs)(L.Fragment,{children:[n?(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`activity-glow`}):null,r?(0,L.jsx)(`span`,{"data-slot":`activity-flash`,"data-tone":r.tone,"aria-hidden":`true`,className:M(`activity-flash`,qt[r.tone])},r.key):null]})}var rr=e=>/(auto|scroll|hidden|clip)/.test(getComputedStyle(e).overflowY);function ir(e){let t=[];for(let n=e.parentElement;n&&n!==document.body&&n!==document.documentElement;n=n.parentElement)rr(n)&&t.push(n);return t}var ar=e=>({requestId:e.id,senderRunId:e.peerRunId,recipientRunId:e.waiterRunId});function or({frame:e,cancel:t,draw:n}){let r=[],i,a=t=>{i=void 0,r=r.map(e=>({...e,start:e.start??t})).filter(e=>t<e.start+e.duration),n(r,t),r.length>0&&(i=e(a))};return{launch(t){r.some(e=>e.id===t.id)||(r.push(t),i===void 0&&(i=e(a)))},stop(){i!==void 0&&t(i),i=void 0,r=[],n([],0)},running:()=>i!==void 0}}var sr=e=>e<.5?2*e*e:1-(-2*e+2)**2/2;function cr(e,t,n=0){let r=Math.min(1,Math.max(0,(t-e.start)/e.duration)),i=Math.max(0,sr(r)-n);return e.reverse?1-i:i}var lr=`http://www.w3.org/2000/svg`,ur=[0,.03,.06,.09,.12],dr=[4.5,3.5,3,2.5,2],fr={peer:`fill-message-peer-accent`,family:`fill-message-inbound-accent`,success:`fill-success`};function pr(e,t){let n=e.querySelector(`g[data-comet="${CSS.escape(t.id)}"]`);if(n)return n;let r=document.createElementNS(lr,`g`);r.setAttribute(`data-comet`,t.id);let i=document.createElementNS(lr,`circle`);return i.setAttribute(`r`,`9`),i.setAttribute(`class`,`${fr[t.tone]} opacity-35`),r.append(i),ur.forEach((e,n)=>{let i=document.createElementNS(lr,`circle`);i.setAttribute(`r`,String(dr[n])),i.setAttribute(`class`,n===0?`fill-foreground`:fr[t.tone]),i.setAttribute(`opacity`,String(1-n*.15)),r.append(i)}),e.append(r),r}function mr(e,t,n){let r=new Set(t.map(e=>e.id));for(let t of e.querySelectorAll(`g[data-comet]`))r.has(t.getAttribute(`data-comet`)??``)||t.remove();let i=e.ownerSVGElement;for(let r of t){let t=i?.querySelector(`path[data-request="${CSS.escape(r.requestId)}"]`);if(!t||typeof t.getTotalLength!=`function`)continue;let a=t.getTotalLength();pr(e,r).querySelectorAll(`circle`).forEach((e,i)=>{let o=t.getPointAtLength(cr(r,n,ur[Math.max(0,i-1)])*a);e.setAttribute(`transform`,`translate(${o.x} ${o.y})`)})}}var hr=e=>typeof requestAnimationFrame==`function`?requestAnimationFrame(e):setTimeout(()=>e(performance.now()),16),gr=e=>typeof cancelAnimationFrame==`function`?cancelAnimationFrame(e):clearTimeout(e);function _r(e,t,n){let r=I.useRef(null),i=I.useRef(void 0),a=I.useRef(new Set);return I.useEffect(()=>{let e=r.current;if(!e)return;let t=or({frame:hr,cancel:gr,draw:(t,n)=>mr(e,t,n)});return i.current=t,()=>{t.stop(),i.current=void 0}},[]),I.useEffect(()=>{if(n){i.current?.stop();return}for(let t of a.current)t in e||a.current.delete(t);for(let[n,r]of Object.entries(e))a.current.has(n)||!t.has(r.requestId)||(a.current.add(n),i.current?.launch({id:n,requestId:r.requestId,reverse:r.reverse,tone:r.tone,duration:Q.comet}))},[e,t,n]),r}var vr=`activity-layout-settled`;function yr(e,t,n,r,i,a=!1){let[o,s]=I.useState([]);return I.useLayoutEffect(()=>{let i=e.current?.parentElement;if(!i)return;let o=()=>{let e=t(i);s(t=>n(t,e)?t:e)};o();let c=a?br(i,o):void 0;i.addEventListener(vr,o);let l=typeof ResizeObserver>`u`?void 0:new ResizeObserver(o);l?.observe(i);for(let e of i.querySelectorAll(r))l?.observe(e);return()=>{l?.disconnect(),i.removeEventListener(vr,o),c?.()}},[e,t,n,r,i,a]),o}function br(e,t){let n,r=()=>{n===void 0&&(n=requestAnimationFrame(()=>{n=void 0,t()}))},i=[...ir(e),window];for(let e of i)e.addEventListener(`scroll`,r,{passive:!0});return window.addEventListener(`resize`,r),()=>{for(let e of i)e.removeEventListener(`scroll`,r);window.removeEventListener(`resize`,r),n!==void 0&&cancelAnimationFrame(n)}}function xr(e,t){if(e.deadline!==void 0)return Sr(e.createdAt,e.deadline,t)}function Sr(e,t,n){let r=Date.parse(e),i=Date.parse(t);return Number.isNaN(r)||Number.isNaN(i)||i<=r?1:Math.min(1,Math.max(0,(n-r)/(i-r)))}function Cr(e,t){if(e===`fade`)return`activity-line-out`;if(e!==`replied`)return M(`activity-march`,t&&`activity-line-in`)}function wr(e,t){return t in e.waitsClosing?`activity-line-out`:M(`activity-drift`,t in e.opening&&`activity-line-in`)}var Tr=(e,t)=>e.closing[t]?.phase??`open`;function Er(e,t){let n=e.closing[t];return n!==void 0&&n.replied&&n.phase!==`reply`}function Dr({id:e}){return(0,L.jsx)(`marker`,{id:e,viewBox:`0 0 12 12`,refX:`10`,refY:`6`,markerWidth:`5`,markerHeight:`5`,markerUnits:`strokeWidth`,orient:`auto`,children:(0,L.jsx)(`circle`,{cx:`6`,cy:`6`,r:`4`,strokeWidth:`2.4`,className:`fill-background stroke-message-peer-accent`})})}function Or(e,t){let n=new Map;for(let r of[...e?.projects??[],...t.projects])for(let[e,t]of _n(r))n.set(e,t);return n}var kr={"timed-out":`timed out`,cancelled:`was cancelled`,destroyed:`closed: the recipient was destroyed`,failed:`closed: the recipient failed`,"completed-without-reply":`closed without a reply`,"sender-closed":`was closed by its sender`,"human-fallback":`went to a human`,deleted:`closed: the recipient was deleted`};function Ar(e,t,n){let r=n(e.senderRunId,e.senderTitle),i=n(e.recipientRunId,e.recipientTitle);return t===`replied`?`${i} replied to ${r}`:`${r}’s request to ${i} ${kr[t??``]??`closed`}`}var jr={done:{tone:`success`,word:`finished`},failed:{tone:`danger`,word:`failed`},cancelled:{tone:`neutral`,word:`was cancelled`},review:{tone:`info`,word:`waits for review`}},Mr=e=>e.relationship===`peer`?`peer`:`family`;function Nr(e,t,n){let r=(e,n)=>X(t,e,n);switch(e.kind){case`request-opened`:return{tone:Mr(e.request),text:`${r(e.request.senderRunId,e.request.senderTitle)} asked ${r(e.request.recipientRunId,e.request.recipientTitle)}`};case`request-closed`:return{tone:e.status===`replied`?`success`:`neutral`,text:Ar(e.request,e.status,r)};case`rung-changed`:return{tone:v(e.task.rung).tone,text:`${e.task.title}: ${Vt(e.task,{now:n,titleOf:e=>r(e)}).verb}`};case`worker-started`:return{tone:`running`,text:`${e.worker.title} started`};case`worker-settled`:{let t=jr[e.worker.status]??{tone:`neutral`,word:`settled`};return{tone:t.tone,text:`${e.worker.title} ${t.word}`}}case`card-entered`:return{tone:v(e.task.rung).tone,text:`${e.task.title} started`};case`card-left`:return{tone:`neutral`,text:`${e.task.title} left active work`};case`check-passed`:return{tone:`success`,text:`PR ${e.pr}: check “${e.name}” passed`};default:return}}function Pr(e,t,n,r){return[...t.map((e,t)=>({...e,id:r+t,at:n})),...e].slice(0,6)}function Fr(e){return Math.max(0,Math.floor(e/1e3))<5?`now`:H(e)}var Ir=`rounded-xl border border-card-edge bg-card px-3.5 py-3 shadow-card`,Lr=`mb-2 flex gap-2 text-xs font-semibold tracking-[0.06em] text-muted-foreground uppercase`;function Rr({request:e,index:t,now:n,motion:r}){let{kind:i,relation:a}=Dn(e,t),o=xr(e,n),s=e.relationship===`peer`?`text-message-peer-accent`:`text-message-inbound-accent`;return(0,L.jsxs)(`li`,{"data-slot":r===`fold`?`activity-request-closing`:`activity-request`,"data-request":e.requestId,"aria-hidden":r===`fold`||void 0,className:M(`border-t border-border py-2.5 first:border-t-0 first:pt-0`,r===`enter`&&`activity-row-enter`,r===`fold`&&`activity-row-fold`),children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[12px] font-medium`,children:[(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:vn(t,e)}),(0,L.jsx)(ye,{"aria-label":`to`,className:`size-3 shrink-0 text-muted-foreground`}),(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:yn(t,e)}),(0,L.jsx)(`span`,{className:M(`ml-auto shrink-0 text-xs font-semibold tracking-[0.05em] uppercase`,s),children:i})]}),(0,L.jsxs)(`p`,{className:`my-1 line-clamp-3 text-[12px] text-muted-foreground`,children:[`“`,e.text,`”`]}),(0,L.jsxs)(`div`,{className:`flex gap-1.5 text-xs text-muted-foreground tabular-nums`,children:[(0,L.jsxs)(`span`,{children:[a,` · open `,V(U(e.createdAt,n))]}),e.deadline?(0,L.jsx)(`span`,{className:`ml-auto`,children:Tn(e.deadline,n)}):null]}),o===void 0?null:(0,L.jsx)(`div`,{"aria-hidden":`true`,className:`mt-1.5 h-[3px] overflow-hidden rounded-sm bg-border`,children:(0,L.jsx)(`span`,{className:M(`block h-full bg-current`,s),style:{width:`${Math.round(o*100)}%`}})})]})}var zr={...Jt,peer:`bg-message-peer-accent`,family:`bg-message-inbound-accent`};function Br({feed:e,now:t}){return(0,L.jsxs)(`section`,{"data-slot":`activity-just-now`,className:Ir,children:[(0,L.jsx)(`h2`,{className:Lr,children:`Just now`}),(0,L.jsx)(`ul`,{"data-slot":`activity-feed`,children:e.map((e,n)=>(0,L.jsxs)(`li`,{"data-slot":`activity-feed-entry`,className:M(`grid grid-cols-[10px_minmax(0,1fr)_auto] items-baseline gap-2 py-1 text-[12px] text-muted-foreground`,n===0&&`activity-feed-enter`),children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:M(`size-[7px] -translate-y-px rounded-full`,zr[e.tone])}),(0,L.jsx)(`span`,{className:`min-w-0`,children:e.text}),(0,L.jsx)(`span`,{"data-slot":`activity-feed-age`,className:`text-xs tabular-nums`,children:Fr(t-e.at)})]},e.id))})]})}function Vr({requests:e,closing:t=[],index:n,now:r,feed:i=[],motion:a=$,columnGap:o}){let s=e.length>0||t.length>0,c=i.length>0;return!s&&!c?null:(0,L.jsxs)(`aside`,{"data-slot":`activity-rail`,"aria-label":`Activity details`,style:o===void 0?void 0:{columnGap:o},className:M(`grid min-w-0 grid-cols-[minmax(0,1fr)] content-start items-start gap-4`,s&&c&&`md:grid-cols-2`),children:[s?(0,L.jsxs)(`section`,{"data-slot":`activity-open-requests`,className:Ir,children:[(0,L.jsxs)(`h2`,{className:Lr,children:[`Open requests `,(0,L.jsx)(`b`,{className:`text-foreground`,children:e.length})]}),(0,L.jsxs)(`ul`,{children:[e.map(e=>(0,L.jsx)(Rr,{request:e,index:n,now:r,motion:e.requestId in a.opening?`enter`:void 0},e.requestId)),t.map(e=>(0,L.jsx)(Rr,{request:e,index:n,now:r,motion:`fold`},e.requestId))]})]}):null,c?(0,L.jsx)(Br,{feed:i,now:r}):null]})}var Hr=new Set;function Ur(e){let[t,n]=I.useState({}),r=t.pointer??t.focus,i=I.useCallback((e,t)=>n(n=>n[e]===t?n:{...n,[e]:t}),[]);return{linked:I.useMemo(()=>r===void 0?Hr:xn(r,e),[r,e]),active:I.useMemo(()=>r===void 0?Hr:new Set(e.filter(e=>e.waiterRunId===r||e.peerRunId===r).map(e=>e.id)),[r,e]),onHover:i}}function Wr(e,t,n=Z(e.tasks)){let r=new Set(e.tasks.map(e=>e.runId)),i=new Set(e.requests.map(e=>e.requestId)),a=Object.values(t.closing).filter(t=>t.projectId===e.projectId&&!i.has(t.request.requestId));return{cards:Object.values(t.leaving).filter(t=>t.projectId===e.projectId&&!r.has(t.task.runId)).map(e=>e.task),requests:a.map(e=>e.request),waits:Kn(e.projectId,n,t),folding:a.filter(e=>e.phase===`reply`||!e.replied).map(e=>e.request)}}var Gr=36,Kr=22,qr=4,Jr=10;function Yr(e,t,n,r=$){let i=[],a=(e,t)=>{let r=n.get(e);return r!==void 0&&r===n.get(t)};for(let t of e){if(t.relationship!==`peer`||!a(t.senderRunId,t.recipientRunId))continue;let e=r.closing[t.requestId];i.push({kind:`request`,id:t.requestId,from:t.senderRunId,to:t.recipientRunId,createdAt:t.createdAt,...e?{closing:!0,replied:e.replied}:{}})}for(let e of t)a(e.peerRunId,e.waiterRunId)&&i.push({kind:`wait`,id:e.id,from:e.peerRunId,to:e.waiterRunId,since:e.since,...e.id in r.waitsClosing?{closing:!0}:{}});if(i.length===0)return{edges:i,gutterWidth:0};let o=Math.min(qr,i.length);return{edges:i,gutterWidth:Math.min(132,64+(o-1)*Kr)}}function Xr(e,t,n){let r=new Set;if(!e)return r;for(let n of t)n.relationship===`peer`&&(n.senderRunId===e||n.recipientRunId===e)&&(r.add(n.senderRunId),r.add(n.recipientRunId));for(let t of n)(t.peerRunId===e||t.waiterRunId===e)&&(r.add(t.peerRunId),r.add(t.waiterRunId));return r}function Zr(e,t){return e.map(e=>{let n=t.get(e.from),r=t.get(e.to);if(!(!n||!r))return{edge:e,start:n,end:r,span:Math.abs(r.y-n.y)}}).filter(e=>e!==void 0).sort((e,t)=>e.span-t.span).map(({edge:e,start:t,end:n},r)=>{let i=r%qr,a=Math.max(10,Math.min(t.x,n.x)-Gr-i*Kr),o=n.y-t.y,s=o>=0?1:-1,c=Math.min(Jr,Math.abs(o)/2,Math.max(2,t.x-a-2)),l=e.kind===`request`?n.x-2:n.x-6;return{edge:e,path:[`M ${t.x} ${t.y}`,`L ${a+c} ${t.y}`,`Q ${a} ${t.y} ${a} ${t.y+s*c}`,`L ${a} ${n.y-s*c}`,`Q ${a} ${n.y} ${a+c} ${n.y}`,`L ${l} ${n.y}`].join(` `),laneX:a,labelY:t.y+o*(.5+(r%2==0?-.06:.08)),endX:n.x-4,endY:n.y}})}function Qr(e){let t=new Map,n=e.getBoundingClientRect();for(let r of e.querySelectorAll(`[data-activity-row]`)){let e=r.getAttribute(`data-activity-row`);if(!e)continue;let i=r.getBoundingClientRect();t.set(e,{x:i.left-n.left,y:i.top-n.top+Math.min(i.height/2,24)})}return t}function $r({stage:e,edges:t,active:n,now:r,layoutKey:i,motion:a=$,paused:o=!1}){let s=I.useId(),[c,l]=I.useState([]);I.useLayoutEffect(()=>{if(!e||t.length===0){l([]);return}let n=()=>l(Zr(t,Qr(e)));if(n(),typeof ResizeObserver>`u`)return;let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[e,t,i]);let u=I.useMemo(()=>new Set(c.filter(e=>e.edge.kind===`request`).map(e=>e.edge.id)),[c]),d=_r(a.comets,u,o);return(0,L.jsxs)(`div`,{"data-slot":`activity-margin-arcs`,"aria-hidden":`true`,className:M(`pointer-events-none absolute inset-0 z-[5] hidden overflow-visible`,t.length>0&&`md:block`),children:[(0,L.jsxs)(`svg`,{className:`size-full overflow-visible`,children:[(0,L.jsx)(`defs`,{children:(0,L.jsx)(`marker`,{id:s,viewBox:`0 0 8 8`,refX:`7`,refY:`4`,markerWidth:`6`,markerHeight:`6`,orient:`auto`,children:(0,L.jsx)(`path`,{d:`M0 1 L7 4 L0 7 z`,className:`fill-message-peer-accent`})})}),c.map(e=>{let{edge:t}=e,r=n!==void 0&&(t.from===n||t.to===n),i=n!==void 0&&!r,a=t.kind===`request`?M(`fill-none stroke-message-peer-accent transition-opacity`,!t.closing&&`activity-march`,t.closing&&`activity-line-out`):M(`fill-none stroke-message-peer-accent transition-opacity`,!t.closing&&`activity-drift`,t.closing&&`activity-line-out`);return(0,L.jsxs)(`g`,{opacity:i?.22:r?1:.82,children:[(0,L.jsx)(`path`,{d:e.path,"data-request":t.kind===`request`?t.id:void 0,"data-wait":t.kind===`wait`?t.id:void 0,strokeWidth:r?2.4:1.8,strokeDasharray:t.kind===`request`?t.replied?void 0:`6 4`:`0 7`,strokeLinecap:t.kind===`wait`?`round`:void 0,markerEnd:t.kind===`request`?`url(#${s})`:void 0,className:a}),t.kind===`wait`?(0,L.jsx)(`circle`,{cx:e.endX,cy:e.endY,r:`3.2`,strokeWidth:`1.7`,className:`fill-card stroke-message-peer-accent`}):null]},`${t.kind}:${t.id}`)}),(0,L.jsx)(`g`,{ref:d})]}),c.map(e=>{let{edge:t}=e,i=n!==void 0&&(t.from===n||t.to===n),a=n!==void 0&&!i,o=V(U(t.kind===`request`?t.createdAt:t.since,r));return(0,L.jsx)(`span`,{style:{left:e.laneX,top:e.labelY},className:M(`absolute -translate-x-1/2 -translate-y-1/2 rounded-full border border-message-peer-accent/60 bg-card px-1.5 py-0.5 text-xs font-semibold whitespace-nowrap text-message-peer-accent tabular-nums shadow-xs transition-opacity`,t.kind===`wait`&&`border-dashed`,a&&`opacity-25`),children:t.kind===`request`?`Req · ${o}`:`Wait · ${o}`},`label:${t.kind}:${t.id}`)})]})}var ei={permission:0,answer:1,respond:2,review:3,failed:4},ti={running:0,waiting:1,queued:2,retained:3},ni=new Set([`queued`,`waiting-for-capacity`]);function ri(e){return e.status===`review`||e.status===`failed`||e.rung===`failed`||K(e.status)&&y(e.rung)}function ii(e){let{task:t}=e,n=t.wait?.kind===`human`?t.wait:void 0;if(n?.detail.reason===`question`)return{...e,kind:`answer`,stateLabel:`Needs answer`,tone:`pending`,blockingReason:n.detail.question??`The agent asked a question and is waiting for your answer.`,ageSince:n.since,actionLabel:`Answer`};if(n?.detail.reason===`budget`){let t=n.detail.queuedMessages;return{...e,kind:`respond`,stateLabel:`Needs you`,tone:`pending`,blockingReason:t?`Automatic wakes used up · ${t} queued ${t===1?`message`:`messages`} waiting.`:`Automatic wakes used up.`,ageSince:n.since,actionLabel:`Respond`}}return{...e,kind:`respond`,stateLabel:`Needs you`,tone:`pending`,blockingReason:`Your turn to reply or finish the task.`,ageSince:n?.since??t.startedAt??t.createdAt,actionLabel:`Respond`}}function ai(e,t){let n={runId:t.runId,projectId:e.projectId,projectName:e.name,task:t},r=t.finishedAt??t.startedAt??t.createdAt;if(t.rung===`needs-permission`){let e=t.wait&&`since`in t.wait?t.wait.since:void 0;return{...n,kind:`permission`,stateLabel:`Needs permission`,tone:`pending`,blockingReason:`Waiting for permission approval before continuing.`,ageSince:e??t.startedAt??t.createdAt,actionLabel:`Open task`}}return t.status===`review`||t.rung===`needs-review`?{...n,kind:`review`,stateLabel:`Needs review`,tone:`info`,blockingReason:`Changes are ready for review before anything lands.`,ageSince:r,actionLabel:`Review`}:t.status===`failed`||t.rung===`failed`?{...n,kind:`failed`,stateLabel:`Failed`,tone:`danger`,blockingReason:t.error??`Task stopped with an error.`,ageSince:r,actionLabel:`Inspect`}:ii(n)}function oi(e){return K(e.status)?e.rung===`running`?`running`:ni.has(e.rung)?`queued`:`waiting`:`retained`}var si=e=>{if(!e)return 1/0;let t=Date.parse(e);return Number.isNaN(t)?1/0:t};function ci(e){let t=[],n=[];for(let r of e)for(let e of r.tasks)ri(e)?t.push(ai(r,e)):n.push({runId:e.runId,projectId:r.projectId,projectName:r.name,task:e,tier:oi(e)});return t.sort((e,t)=>ei[e.kind]-ei[t.kind]||si(e.ageSince)-si(t.ageSince)||e.runId.localeCompare(t.runId)),n.sort((e,t)=>ti[e.tier]-ti[t.tier]),{attention:t,working:n}}function li(e,t){let n=new Map;for(let t of e){let e=n.get(t.projectId);e?e.items.push(t):n.set(t.projectId,{projectId:t.projectId,projectName:t.projectName,items:[t]})}let r=new Map(t.map((e,t)=>[e,t]));return[...n.values()].sort((e,t)=>(r.get(e.projectId)??2**53-1)-(r.get(t.projectId)??2**53-1)||e.projectName.localeCompare(t.projectName))}function ui(e,t,n,r){let i=new Map;for(let n of t)n.relationship===`peer`&&n.recipientRunId===e&&i.set(n.senderRunId,X(r,n.senderRunId,n.senderTitle));for(let t of n)t.peerRunId===e&&i.set(t.waiterRunId,X(r,t.waiterRunId));let a=[...i.values()];if(a.length!==0)return a.length===1?`Unblocks ${a[0]}`:a.length===2?`Unblocks ${a[0]} + ${a[1]}`:`Unblocks ${a[0]} + ${a.length-1} more`}function di(e,t){if(e===void 0)return;let n=t.filter(t=>!e.has(t.runId));if(n.length!==0)return n.length===1?`New item needs your decision: ${n[0].task.title}`:`${n.length} new items need your decision`}var fi={permission:`border-l-pending`,answer:`border-l-pending`,respond:`border-l-pending`,review:`border-l-info`,failed:`border-l-danger`},pi=`relative z-[1] text-[12px] text-message-peer-accent hover:underline focus-visible:outline-2 focus-visible:outline-ring max-md:inline-flex max-md:min-h-11 max-md:items-center`,mi=[],hi=[],gi=new Map;function _i(e,t,n){return n?`/p/${encodeURIComponent(e)}/tasks/${encodeURIComponent(t)}`:`/tasks/${encodeURIComponent(t)}`}function vi({items:e,grouped:t,projectOrder:n,countSuffix:r,renderItems:i}){return t?(0,L.jsx)(`div`,{className:`flex flex-col gap-3`,children:li(e,n).map(e=>(0,L.jsxs)(`div`,{"data-slot":`activity-project-group`,"data-project":e.projectId,className:`flex flex-col gap-2`,children:[(0,L.jsxs)(`h3`,{className:`flex items-center gap-2 text-[12.5px] font-semibold text-foreground`,children:[(0,L.jsx)(`span`,{children:e.projectName}),(0,L.jsxs)(`span`,{className:`text-xs font-normal text-muted-foreground tabular-nums`,children:[e.items.length,` `,r]})]}),i(e.items)]},e.projectId))}):(0,L.jsx)(L.Fragment,{children:i(e)})}var yi={permission:`text-foreground`,answer:`text-foreground`,respond:`text-foreground`,review:`text-muted-foreground`,failed:`font-mono text-[12px] text-signal-word-red`};function bi({href:e,title:t,global:n}){let r=`hover:underline focus-visible:outline-2 focus-visible:outline-ring max-md:inline-flex max-md:min-h-11 max-md:min-w-11 max-md:items-center pointer-coarse:inline-flex pointer-coarse:min-h-11 pointer-coarse:min-w-11 pointer-coarse:items-center`;return n?(0,L.jsx)(j,{to:e,className:r,children:t}):(0,L.jsx)(P,{to:e,className:r,children:t})}function xi({record:e,href:t,global:n,selected:r,onTriage:i}){return e.kind===`permission`?(0,L.jsx)(N,{asChild:!0,size:`sm`,variant:`primary`,className:`max-md:flex-1`,children:n?(0,L.jsx)(j,{to:t,children:e.actionLabel}):(0,L.jsx)(P,{to:t,children:e.actionLabel})}):(0,L.jsx)(N,{type:`button`,size:`sm`,variant:e.kind===`answer`||e.kind===`respond`?`primary`:`outline`,"data-slot":`activity-triage-trigger`,"aria-expanded":r,className:`max-md:flex-1`,onClick:t=>i(e,t.currentTarget),children:e.actionLabel})}function Si({record:e,requests:t,waits:n,index:r,now:i,global:a,selected:s,linked:c,motion:u,onHover:d,onTriage:f}){let p=o().data,{task:m}=e,h=[m.runner?l(p,m.runner):void 0,m.model,m.currentStepId?`step ${m.currentStepId}`:void 0].filter(Boolean).join(` · `),g=ui(e.runId,t,n,r),_=_i(e.projectId,e.runId,a),ee={now:i,titleOf:e=>r.get(e)?.title??`Unreadable task`},te=m.workers.length>0;return(0,L.jsxs)(`article`,{"data-activity-row":e.runId,"data-activity-card":e.runId,"data-slot":`activity-decision`,"data-decision-kind":e.kind,"data-rung":m.rung,"data-selected":s?`true`:void 0,"data-linked":c?`true`:void 0,...tr(e.runId,d),className:M(`relative grid min-w-0 grid-cols-1 items-center gap-3 rounded-xl border border-card-edge border-l-[3px] bg-card px-4 py-3 shadow-card transition-colors md:grid-cols-[minmax(0,1fr)_auto] md:gap-x-4`,fi[e.kind],s&&`border-accent-text bg-accent-strong/[0.06]`,c&&`outline-2 outline-offset-1 outline-message-peer-accent`,e.runId in u.entering&&`activity-card-enter`),children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,L.jsxs)(`span`,{className:M(`inline-flex items-center gap-1.5 text-[12px] font-semibold`,Gt[e.tone]),children:[(0,L.jsx)(en,{run:m,role:`root`}),(0,L.jsx)(`span`,{"data-slot":`activity-verb`,children:e.stateLabel})]}),(0,L.jsx)(`h3`,{className:`min-w-0 truncate text-[14px] font-semibold text-foreground`,children:(0,L.jsx)(bi,{href:_,title:m.title,global:a})}),(0,L.jsx)(`span`,{"data-slot":`activity-project-badge`,className:`inline-flex shrink-0 items-center rounded-md border border-border bg-muted px-1.5 py-0.5 text-xs font-medium text-muted-foreground`,children:e.projectName}),e.ageSince?(0,L.jsx)(`span`,{"data-slot":`activity-age`,title:G(e.ageSince),className:`text-[12px] text-muted-foreground tabular-nums`,children:H(U(e.ageSince,i))}):null]}),(0,L.jsx)(`p`,{"data-slot":`activity-main`,className:M(`break-words text-[13px] leading-relaxed`,yi[e.kind]),children:e.blockingReason}),h||g?(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-muted-foreground`,children:[h?(0,L.jsx)(`span`,{children:h}):null,g?(0,L.jsxs)(`span`,{"data-slot":`activity-unblocks`,className:`font-medium text-message-peer-accent`,children:[`· `,g]}):null]}):null,(0,L.jsx)(qn,{runId:e.runId,requests:t,waits:n,index:r,link:a?j:P,pathOf:t=>a?`/p/${encodeURIComponent(e.projectId)}/tasks/${encodeURIComponent(t)}`:`/tasks/${encodeURIComponent(t)}`,className:`mt-1 flex flex-col gap-0.5 md:hidden`,linkClassName:pi})]}),(0,L.jsx)(`div`,{className:`flex items-center gap-2 max-md:w-full`,children:(0,L.jsx)(xi,{record:e,href:_,global:a,selected:s,onTriage:f})}),te?(0,L.jsx)(`div`,{className:`min-w-0 md:col-span-2`,children:(0,L.jsx)(er,{task:m,requests:t,index:r,ctx:ee,motion:u,projectId:e.projectId,global:a,compact:!0})}):null,(0,L.jsx)(Yn,{texts:Cn(e.runId,t,r,n)})]})}function Ci({items:e,requestsByProject:t,waitsByProject:n,indexByProject:r,now:i,global:a,grouped:o,projectOrder:s,selectedRunId:c,linkedIds:l,motion:u=$,onHover:d,onTriage:f}){return e.length===0?null:(0,L.jsxs)(`section`,{"data-slot":`activity-attention`,"aria-label":`Needs your decision`,className:`flex min-w-0 flex-col gap-2.5`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(`h2`,{className:`text-[12px] font-semibold tracking-[0.06em] text-muted-foreground uppercase`,children:`Needs your decision`}),(0,L.jsx)(`span`,{"data-slot":`activity-attention-count`,className:`inline-flex items-center rounded-full bg-inbox-count px-2 py-0.5 text-xs font-semibold text-inbox-count-foreground tabular-nums`,children:e.length}),(0,L.jsx)(`span`,{className:`ml-auto hidden text-[12px] text-muted-foreground sm:inline`,children:`Resolve inline without leaving the queue`})]}),(0,L.jsx)(vi,{items:e,grouped:o,projectOrder:s,countSuffix:`waiting`,renderItems:e=>(0,L.jsx)(`div`,{className:`flex flex-col gap-2.5`,children:e.map(e=>(0,L.jsx)(Si,{record:e,requests:t.get(e.projectId)??mi,waits:n.get(e.projectId)??hi,index:r.get(e.projectId)??gi,now:i,global:a,selected:c===e.runId,linked:l.has(e.runId),motion:u,onHover:d,onTriage:f},e.runId))})})]})}function wi(e){return`/p/${encodeURIComponent(e.projectId)}/tasks/${encodeURIComponent(e.runId)}`}function Ti(e){return{...e.id===void 0?{}:{id:e.id},header:e.header,question:e.question,...e.options===void 0?{}:{options:e.options.map(e=>({label:e.label,...e.description===void 0?{}:{description:e.description}}))},...e.multiSelect===void 0?{}:{multiSelect:e.multiSelect},...e.allowFreeText===void 0?{}:{allowFreeText:e.allowFreeText}}}function Ei(e,t){let n=Te(t);if(!n)return;let r=De(n);if(r)return{kind:`ask`,id:r.id,questions:r.questions.map(Ti),...r.context===void 0?{}:{context:r.context},resolved:!1,...e.delegation?.role===`worker`?{parentRunId:e.delegation.parentRunId}:{}}}function Di({run:e,projectId:t,prompt:n,onResolved:r}){let i=Re(e,t),a=Be(e.id,{projectId:t,onSuccess:r}),[o,s]=(0,I.useState)(``),c=async()=>{let e=o.trim();e&&await i.send(e)===void 0&&(s(``),r())};return(0,L.jsxs)(`div`,{"data-slot":`activity-quick-reply`,className:`flex flex-col gap-3 rounded-lg border border-border bg-card p-3.5`,children:[(0,L.jsx)(`p`,{className:`text-[13px] text-foreground`,children:n}),(0,L.jsx)(ze,{"aria-label":`Reply to task`,placeholder:`Write your reply…`,rows:3,value:o,disabled:i.isPending||i.blockedBy!==void 0,onChange:e=>s(e.target.value),className:`bg-background text-base md:text-[13px]`}),i.reason?(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i.reason}):null,i.error?(0,L.jsx)(`p`,{role:`alert`,className:`text-xs text-semantic-red`,children:i.error}):null,(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(N,{type:`button`,size:`sm`,variant:`primary`,disabled:i.isPending||i.blockedBy!==void 0||o.trim().length===0,onClick:()=>void c(),children:`Send reply`}),e.finishBlocked===null?(0,L.jsx)(N,{type:`button`,size:`sm`,variant:`outline`,disabled:a.isPending,onClick:()=>a.mutate(),children:`Finish task`}):null]})]})}function Oi({record:e,run:t,onResolved:n}){let r=ae({queryKey:[`activity-triage`,`history-context`,e.projectId,e.runId,e.ageSince??``,e.blockingReason],queryFn:({signal:t})=>re(e.runId,{projectId:e.projectId,signal:t}),staleTime:0,gcTime:0,refetchOnMount:`always`});if(r.isPending)return(0,L.jsx)(`p`,{"data-slot":`triage-loading`,className:`text-xs text-muted-foreground`,children:`Loading question…`});let i=r.data?Ei(t,r.data.contextEvents):void 0;return i?(0,L.jsx)(ve,{ask:i,run:t,projectId:e.projectId,onAnswered:n}):(0,L.jsx)(Di,{run:t,projectId:e.projectId,prompt:e.blockingReason,onResolved:n})}function ki({record:e,run:t,onResolved:n}){let r=p(),i=Re(t,e.projectId),[o,c]=(0,I.useState)(``),l=d({mutationFn:()=>C(s(e.runId,{projectId:e.projectId}),!0),onSuccess:()=>{S(`Failed task archived.`),r.invalidateQueries({queryKey:a.runs.all}),n()},onError:e=>S(e.message,{tone:`danger`})}),u=async()=>{let e=o.trim()||`Continue and resolve the failure.`;await i.send(e)===void 0&&(S(`Task resumed.`),n())},f=t.error??e.blockingReason;return(0,L.jsxs)(`div`,{"data-slot":`activity-failed-triage`,className:`flex flex-col gap-3`,children:[(0,L.jsxs)(`div`,{className:`rounded-lg border border-danger/40 bg-card-2 p-3.5`,children:[(0,L.jsx)(`p`,{className:`text-xs font-semibold text-signal-word-red`,children:`Failure details`}),(0,L.jsx)(`pre`,{className:`mt-2 overflow-x-auto font-mono text-xs whitespace-pre-wrap text-foreground`,children:f})]}),i.mode===`unavailable`?null:(0,L.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,L.jsx)(`label`,{htmlFor:`activity-retry-note`,className:`text-xs font-medium text-foreground`,children:`Retry instruction (optional)`}),(0,L.jsx)(ze,{id:`activity-retry-note`,rows:2,placeholder:`Leave blank to continue and resolve the failure…`,value:o,disabled:i.isPending||i.blockedBy!==void 0,onChange:e=>c(e.target.value),className:`bg-card text-base md:text-[13px]`}),i.reason?(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i.reason}):null,i.error?(0,L.jsx)(`p`,{role:`alert`,className:`text-xs text-semantic-red`,children:i.error}):null]}),(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i.mode===`unavailable`?null:(0,L.jsxs)(N,{type:`button`,size:`sm`,variant:`primary`,disabled:i.isPending||i.blockedBy!==void 0,onClick:()=>void u(),children:[(0,L.jsx)(Ee,{"aria-hidden":`true`,className:`size-3.5`}),`Retry task`]}),(0,L.jsxs)(N,{type:`button`,size:`sm`,variant:`outline`,disabled:l.isPending,onClick:()=>l.mutate(),children:[(0,L.jsx)(ge,{"aria-hidden":`true`,className:`size-3.5`}),`Archive`]})]})]})}function Ai(e){let{task:t}=e,n=t.workers.map(e=>`${e.runId}:${e.status}`).join(`,`);return`${t.status}|${t.rung}|${t.finishedAt??``}|${t.error??``}|${e.ageSince??``}|${n}`}function ji({record:e,onResolved:t}){let n=p(),i=r(e.projectId,e.runId,!0,{staleTime:0,refetchOnMount:`always`}),a=Ai(e),o=(0,I.useRef)(a);if((0,I.useEffect)(()=>{if(o.current===a)return;o.current=a;let t=!1,r=[e.projectId,`runs`,`detail`,e.runId];return me(n,r),n.cancelQueries({queryKey:r,exact:!0}).then(()=>{t||n.refetchQueries({queryKey:r,exact:!0,type:`active`})}),e.kind===`review`&&n.invalidateQueries({queryKey:[e.projectId,`runs`,`diff`,e.runId],exact:!0}),()=>{t=!0}},[a,n,e.kind,e.projectId,e.runId]),(0,I.useEffect)(()=>{let t=[e.projectId,`runs`,`detail`,e.runId];return h(()=>(me(n,t),n.cancelQueries({queryKey:t,exact:!0}).then(()=>n.refetchQueries({queryKey:t,exact:!0,type:`active`}))))},[n,e.projectId,e.runId]),i.isPending)return(0,L.jsx)(`p`,{"data-slot":`triage-loading`,className:`text-xs text-muted-foreground`,children:`Loading task details…`});if(i.isError||!i.data)return(0,L.jsxs)(`div`,{role:`alert`,className:`flex flex-col gap-2 text-xs text-semantic-red`,children:[(0,L.jsxs)(`p`,{children:[`Could not load task details: `,i.error?.message??`task unavailable`,`.`]}),(0,L.jsx)(N,{type:`button`,size:`sm`,variant:`outline`,className:`self-start`,onClick:()=>void i.refetch(),children:`Retry`})]});let s=i.isFetching&&i.data.finishBlocked!==void 0?{...i.data,finishBlocked:void 0}:i.data;return e.kind===`answer`?(0,L.jsx)(Oi,{record:e,run:s,onResolved:t}):e.kind===`review`?(0,L.jsx)(Ve,{run:s,projectId:e.projectId,onResolved:t}):e.kind===`failed`?(0,L.jsx)(ki,{record:e,run:s,onResolved:t}):(0,L.jsx)(Di,{run:s,projectId:e.projectId,prompt:e.blockingReason,onResolved:t})}function Mi({record:e,selectionToken:t,resolved:n=!1,now:r,onClose:i,onResolved:a,onRestoreFocus:o}){let s=p();return(0,L.jsx)(Me,{open:e!==null,onOpenChange:e=>{e||i()},children:(0,L.jsx)(Pe,{side:`right`,showCloseButton:!1,"data-slot":`activity-triage-drawer`,onCloseAutoFocus:e=>{o&&(e.preventDefault(),o())},className:`flex h-full w-full flex-col gap-0 p-0 data-[state=closed]:duration-150 data-[state=open]:duration-200 sm:max-w-lg`,children:e?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(je,{className:`flex-row items-start justify-between gap-3 border-b border-border bg-card px-4 py-3.5`,children:[(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(`span`,{className:M(`text-xs font-semibold`,Gt[e.tone]),children:e.stateLabel}),(0,L.jsx)(`span`,{className:`inline-flex items-center rounded-md border border-border bg-muted px-1.5 py-0.5 text-xs font-medium text-muted-foreground`,children:e.projectName}),e.ageSince?(0,L.jsx)(`span`,{title:G(e.ageSince),className:`text-xs text-muted-foreground tabular-nums`,children:H(U(e.ageSince,r))}):null]}),(0,L.jsx)(Ne,{className:`mt-1 truncate text-[16px] leading-snug`,children:e.task.title}),(0,L.jsxs)(Ie,{className:`sr-only`,children:[`Resolve `,e.stateLabel.toLowerCase(),` for `,e.task.title,` without leaving Live Activity.`]})]}),(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,L.jsx)(N,{asChild:!0,size:`sm`,variant:`ghost`,className:`px-2.5 text-xs`,children:(0,L.jsxs)(j,{to:wi(e),children:[`Open task`,(0,L.jsx)(Se,{"aria-hidden":`true`,className:`size-3.5`})]})}),(0,L.jsx)(N,{type:`button`,size:`icon`,variant:`ghost`,"aria-label":`Close triage drawer`,onClick:i,children:(0,L.jsx)(he,{"aria-hidden":`true`,className:`size-4`})})]})]}),(0,L.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-4`,children:n?(0,L.jsxs)(`div`,{"data-slot":`activity-triage-resolved`,role:`status`,className:`flex flex-col gap-3 rounded-lg border border-border bg-card p-4 text-[13px] text-muted-foreground`,children:[(0,L.jsx)(`p`,{className:`text-foreground`,children:`This task no longer needs your decision.`}),(0,L.jsx)(N,{type:`button`,size:`sm`,variant:`outline`,className:`self-start`,onClick:i,children:`Close`})]}):(0,L.jsx)(ji,{record:e,onResolved:((e,t)=>()=>{s.invalidateQueries({queryKey:[`workspace`,`activity`]}),s.invalidateQueries({queryKey:[`activity-triage`,`history-context`,e.projectId,e.runId]}),s.invalidateQueries({queryKey:[e.projectId,`runs`,`detail`,e.runId],exact:!0}),a(e.runId,t)})(e,t)},`${e.projectId}:${e.runId}:${e.kind}:${t??0}`)})]}):null})})}var Ni=12,Pi=`col-start-3 row-start-1 min-w-[3.25rem] justify-self-end text-right md:col-start-5`,Fi={fail:4,pending:3,pass:2,skipping:1,cancel:0};function Ii(e,t){let n=e.slice(Ni);if(n.length===0)return t;let r=n.length+(t?.count??0),i=t?.bucket??n[0].bucket;for(let e of n)Fi[e.bucket]>Fi[i]&&(i=e.bucket);return{count:r,bucket:i}}function Li({record:e,requests:t,waits:n,index:r,ctx:i,global:a,linked:o,motion:s,onHover:c}){let{task:l}=e,u=Vt(l,i),d=_i(e.projectId,e.runId,a),f=l.startedAt??u.since??l.createdAt,p=s.slides[l.runId]?.key,m=In(s,l.runId);return(0,L.jsxs)(`article`,{"data-activity-row":e.runId,"data-activity-card":e.runId,"data-slot":`activity-working-row`,"data-rung":l.rung,"data-linked":o?`true`:void 0,...tr(e.runId,c),className:M(`relative flex min-w-0 flex-col gap-1.5 px-3.5 py-2.5 transition-colors first:rounded-t-xl last:rounded-b-xl`,o&&`bg-message-peer-bg outline-2 outline-offset-1 outline-message-peer-accent`,e.runId in s.entering&&`activity-card-enter`),children:[(0,L.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[14px_minmax(0,1fr)_auto] items-center gap-x-2.5 gap-y-1 md:grid-cols-[14px_minmax(0,1.25fr)_minmax(0,1.45fr)_auto_auto]`,children:[(0,L.jsx)(en,{run:l,role:`root`}),(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,L.jsx)(`h3`,{className:`min-w-0 truncate text-[13px] font-semibold text-foreground`,children:a?(0,L.jsx)(j,{to:d,className:`hover:underline focus-visible:outline-2 focus-visible:outline-ring max-md:inline-flex max-md:min-h-11 max-md:items-center`,children:l.title}):(0,L.jsx)(P,{to:d,className:`hover:underline focus-visible:outline-2 focus-visible:outline-ring max-md:inline-flex max-md:min-h-11 max-md:items-center`,children:l.title})}),(0,L.jsx)(`span`,{"data-slot":`activity-project-badge`,className:`inline-flex shrink-0 items-center rounded-md border border-border bg-muted px-1.5 py-0.5 text-xs font-medium text-muted-foreground`,children:e.projectName}),l.currentStepId?(0,L.jsxs)(`span`,{"data-slot":`activity-step`,className:`hidden shrink-0 text-xs text-muted-foreground sm:inline`,children:[`step `,l.currentStepId]}):null]}),(0,L.jsxs)(`div`,{className:`col-span-2 col-start-2 flex min-w-0 items-center gap-2 text-[12px] text-muted-foreground md:col-span-1 md:col-start-3`,children:[(0,L.jsx)(`span`,{"data-slot":`activity-verb`,className:M(`shrink-0 font-semibold`,Gt[u.tone]),children:u.verb}),(0,L.jsx)(`span`,{"data-slot":`activity-main`,className:M(`min-w-0 truncate text-foreground`,u.mono&&`font-mono text-xs`,p!==void 0&&`activity-slide`),children:u.main},p??`still`),u.checks&&u.checks.length>0?(0,L.jsx)(rn,{checks:u.checks.slice(0,Ni),overflow:Ii(u.checks,u.overflow),passed:m,className:`hidden w-20 shrink-0 items-center gap-[2px] sm:inline-flex`}):null,u.checkSummary?(0,L.jsx)(`span`,{"data-slot":`activity-checks-summary`,className:`sr-only`,children:u.checkSummary}):null]}),(0,L.jsx)(an,{rate:l.rate,className:`hidden h-3.5 w-[52px] md:block`}),f?(0,L.jsx)(`span`,{"data-slot":`activity-elapsed`,title:G(f),className:M(Pi,`text-[12px] text-muted-foreground tabular-nums`),children:H(U(f,i.now))}):(0,L.jsx)(`span`,{className:Pi})]}),(0,L.jsx)(Yn,{texts:Cn(e.runId,t,r,n)}),(0,L.jsx)(qn,{runId:e.runId,requests:t,waits:n,index:r,link:a?j:P,pathOf:t=>_i(e.projectId,t,a),className:`ml-6 flex flex-col gap-0.5 md:hidden`,linkClassName:pi}),(0,L.jsx)(er,{task:e.task,requests:t,index:r,ctx:i,motion:s,projectId:e.projectId,global:a,compact:!0})]})}function Ri({items:e,requestsByProject:t,waitsByProject:n,indexByProject:r,now:i,global:a,grouped:o,projectOrder:s,linkedIds:c,motion:l=$,onHover:u}){return e.length===0?null:(0,L.jsxs)(`section`,{"data-slot":`activity-working`,"aria-label":`Working and active tasks`,className:`flex min-w-0 flex-col gap-2.5`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(`h2`,{className:`text-[12px] font-semibold tracking-[0.06em] text-muted-foreground uppercase`,children:`Working & active`}),(0,L.jsx)(`span`,{"data-slot":`activity-working-count`,className:`inline-flex items-center rounded-full bg-muted px-2 py-0.5 text-xs font-semibold text-foreground tabular-nums`,children:e.length}),(0,L.jsx)(`span`,{className:`ml-auto hidden text-[12px] text-muted-foreground sm:inline`,children:`Live tool activity, waits, and worker trees`})]}),(0,L.jsx)(vi,{items:e,grouped:o,projectOrder:s,countSuffix:`active`,renderItems:e=>(0,L.jsx)(`div`,{className:`divide-y divide-border rounded-xl border border-card-edge bg-card shadow-card`,children:e.map(e=>{let o=r.get(e.projectId)??gi,s={now:i,titleOf:e=>o.get(e)?.title??`Unreadable task`};return(0,L.jsx)(Li,{record:e,requests:t.get(e.projectId)??mi,waits:n.get(e.projectId)??hi,index:o,ctx:s,global:a,linked:c.has(e.runId),motion:l,onHover:u},e.runId)})})})]})}function zi(e){let t=new Map;for(let n of e)for(let[e,r]of _n(n))t.set(e,r);return t}function Bi(e,t){let n=[],r=[],i=[];for(let a of e){let e=Wr(a,t);n.push(...e.requests),r.push(...e.folding),i.push(...Kn(a.projectId,Z(a.tasks),t))}return{requests:n,folding:r,waits:i}}function Vi(e,t){if(!e)return{activeDecision:null,resolvedExternally:!1};let n=t.find(t=>t.runId===e.runId&&t.projectId===e.projectId)??null;return{activeDecision:n??e.snapshot,resolvedExternally:n===null}}function Hi(e){return e<=0?{"data-has-arcs":void 0,style:void 0,className:`relative flex min-w-0 flex-col gap-6`}:{"data-has-arcs":`true`,style:{"--activity-arc-gutter":`${e}px`},className:`relative flex min-w-0 flex-col gap-6 md:pl-(--activity-arc-gutter)`}}function Ui(e){let[t,n]=I.useState(void 0),r=I.useRef(void 0),i=I.useRef(void 0),a=I.useRef(void 0);return I.useEffect(()=>{let t=di(r.current,e);if(r.current=new Set(e.map(e=>e.runId)),t){if(a.current!==void 0&&(window.clearTimeout(a.current),a.current=void 0),i.current!==t){i.current=t,n(t);return}n(``),a.current=window.setTimeout(()=>{a.current=void 0,i.current=t,n(t)},0)}},[e]),I.useEffect(()=>()=>{a.current!==void 0&&window.clearTimeout(a.current)},[]),t}function Wi(e,t,n){if(e&&e.isConnected){e.focus({preventScroll:!0});return}(t?.querySelector(`[data-slot="activity-triage-trigger"]`)??n)?.focus({preventScroll:!0})}function Gi({projects:e,now:t,global:n,grouped:r,projectOrder:i,motion:a=$,feed:o=[],still:s=!1,paused:c=!1,emptyMessage:l}){let u=I.useRef(null),[d,f]=I.useState(null),p=I.useRef(0),[m,h]=I.useState(null),g=I.useRef(null),[_,ee]=I.useState({}),te=I.useMemo(()=>zi(e),[e]),ne=I.useMemo(()=>new Map(e.map(e=>[e.projectId,_n(e)])),[e]),v=I.useMemo(()=>new Map(e.map(e=>[e.projectId,e.requests])),[e]),y=I.useMemo(()=>new Map(e.map(e=>[e.projectId,Z(e.tasks)])),[e]),{attention:b,working:x}=I.useMemo(()=>ci(e),[e]),re=Ui(b),S=I.useMemo(()=>e.flatMap(e=>e.requests),[e]),ie=I.useMemo(()=>e.flatMap(e=>Z(e.tasks)),[e]),C=I.useMemo(()=>Bi(e,a),[e,a]),ae=I.useMemo(()=>[...S,...C.requests],[S,C.requests]),oe=I.useMemo(()=>[...ie,...C.waits],[ie,C.waits]),se=I.useMemo(()=>new Map([...b.map(e=>[e.runId,e.projectId]),...x.map(e=>[e.runId,e.projectId])]),[b,x]),{edges:w,gutterWidth:ce}=I.useMemo(()=>Yr(ae,oe,se,a),[ae,oe,se,a]),T=_.pointer??_.focus,le=I.useMemo(()=>{let e=T?se.get(T):void 0;return e&&T?Xr(T,v.get(e)??[],y.get(e)??[]):new Set},[T,v,se,y]),E=I.useCallback((e,t)=>{ee(n=>{if(n[e]===t)return n;let r={...n};return t===void 0?delete r[e]:r[e]=t,r})},[]),{activeDecision:ue,resolvedExternally:D}=I.useMemo(()=>Vi(m,b),[b,m]),de=I.useCallback((e,t)=>{g.current=t,h({token:++p.current,projectId:e.projectId,runId:e.runId,snapshot:e})},[]),fe=I.useCallback(()=>Wi(g.current,d,u.current),[d]),O=I.useCallback(()=>h(null),[]),pe=I.useCallback((e,t)=>{h(e=>e&&(t===void 0||e.token===t)?null:e)},[]),k=`${r}:${b.map(e=>e.runId).join(`,`)}:${x.map(e=>e.runId).join(`,`)}:${w.map(e=>e.id).join(`,`)}`,A=b.length===0&&x.length===0;return(0,L.jsxs)(`div`,{ref:u,tabIndex:-1,className:`flex min-w-0 flex-col gap-5 outline-none`,children:[(0,L.jsx)(`p`,{"data-slot":`activity-announcement`,role:`status`,"aria-live":`polite`,className:`sr-only`,children:re??``}),A&&l?(0,L.jsx)(`p`,{"data-slot":`activity-empty`,className:`py-6 text-[13px] text-muted-foreground`,children:l}):null,A?null:(0,L.jsxs)(`div`,{ref:f,"data-slot":`activity-stage`,...Hi(ce),children:[(0,L.jsx)($r,{stage:d,edges:w,active:T,now:t,layoutKey:k,motion:a,paused:c||s}),(0,L.jsx)(Ci,{items:b,requestsByProject:v,waitsByProject:y,indexByProject:ne,now:t,global:n,grouped:r,projectOrder:i,selectedRunId:ue?.runId,linkedIds:le,motion:a,onHover:E,onTriage:de}),(0,L.jsx)(Ri,{items:x,requestsByProject:v,waitsByProject:y,indexByProject:ne,now:t,global:n,grouped:r,projectOrder:i,linkedIds:le,motion:a,onHover:E})]}),(0,L.jsx)(Vr,{requests:S,closing:C.folding,index:te,now:t,feed:o,motion:a}),(0,L.jsx)(Mi,{record:ue,selectionToken:m?.token,resolved:D,now:t,onClose:O,onResolved:pe,onRestoreFocus:fe})]})}var Ki=e=>new Map(e.map(e=>[e.runId,e])),qi=e=>e!==void 0&&gn(e)===void 0;function Ji(e,t,n,r){let i=Ki(t.workers);for(let t of n.workers){let a=i.get(t.runId);!a&&K(t.status)&&r({kind:`worker-started`,projectId:e,parentId:n.runId,worker:t}),a&&K(a.status)&&!K(t.status)&&r({kind:`worker-settled`,projectId:e,parentId:n.runId,worker:t})}}function Yi(e,t,n,r){if(t.wait?.kind!==`pr`||n.wait?.kind!==`pr`||t.wait.detail.number!==n.wait.detail.number)return;let i=new Set((t.wait.detail.checks??[]).filter(e=>e.bucket===`pending`).map(e=>e.name));for(let t of n.wait.detail.checks??[])t.bucket===`pass`&&i.has(t.name)&&r({kind:`check-passed`,projectId:e,runId:n.runId,pr:n.wait.detail.number,name:t.name})}var Xi=(e,t)=>t.tool!==void 0&&(t.tool.startedAt!==e.tool?.startedAt||t.tool.title!==e.tool?.title);function Zi(e,t,n,r){t.rung!==n.rung&&r({kind:`rung-changed`,projectId:e,task:n,from:t.rung}),Xi(t,n)&&r({kind:`tool-started`,projectId:e,runId:n.runId}),Ji(e,t,n,r),Yi(e,t,n,r)}function Qi(e,t,n){let r=Ki(e.tasks),i=Ki(t.tasks);for(let e of t.tasks){let i=r.get(e.runId);i?Zi(t.projectId,i,e,n):n({kind:`card-entered`,projectId:t.projectId,task:e})}for(let r of e.tasks)i.has(r.runId)||n({kind:`card-left`,projectId:t.projectId,task:r})}function $i(e,t,n){let r=new Set(e.requests.map(e=>e.requestId)),i=new Set(t.requests.map(e=>e.requestId)),a=new Map(t.closed.map(e=>[e.requestId,e.status]));for(let e of t.requests)r.has(e.requestId)||n({kind:`request-opened`,projectId:t.projectId,request:e});for(let r of e.requests){if(i.has(r.requestId))continue;let e=a.get(r.requestId);n({kind:`request-closed`,projectId:t.projectId,request:r,...e?{status:e}:{}})}}function ea(e,t,n){let r=Z(e.tasks),i=Z(t.tasks),a=new Set(r.map(e=>e.id)),o=new Set(i.map(e=>e.id));for(let e of i)a.has(e.id)||n({kind:`wait-opened`,projectId:t.projectId,wait:e});for(let e of r)o.has(e.id)||n({kind:`wait-closed`,projectId:t.projectId,wait:e})}var ta=[`needsYou`,`working`,`waiting`,`queued`,`activeWorkers`,`openRequests`,`inReview`];function na(e,t,n){let r=Mn(e),i=Mn(t);for(let e of ta)r[e]!==i[e]&&n({kind:`chip-changed`,chip:e,from:r[e],to:i[e]})}function ra(e,t){if(e===void 0)return[];let n=[],r=e=>n.push(e),i=new Map(e.projects.map(e=>[e.projectId,e]));for(let e of t.projects){let t=i.get(e.projectId);!qi(t)||!qi(e)||(Qi(t,e,r),$i(t,e,r),ea(t,e,r))}return na(e.projects,t.projects,r),n}function ia(e){return{input:e,reconcile:!1,seq:0,motion:$,feed:[],epoch:0,...e.snapshot?{seen:e.snapshot}:{}}}function aa(e){let{plan:t,...n}=e;return{...n,motion:$,epoch:e.epoch+1}}function oa(e,t,n){let r=ra(t,n);if(r.length===0)return e;let i=Date.parse(n.generatedAt),a=Or(t,n),o=r.flatMap(e=>Nr(e,a,i)??[]),s=e.seq+o.length+1,c=Un(r,s,e.input.reduced);return{...e,seq:s,feed:o.length>0?Pr(e.feed,o,i,e.seq+1):e.feed,motion:Gn(e.motion,c.changes),...c.timers.length>0?{plan:{key:s,timers:c.timers}}:{}}}function sa(e,t){let n=e.seen;if(!t||t===n)return e;let r={...e,seen:t};return!n||!e.input.active?r:e.reconcile?{...r,reconcile:!1}:oa(r,n,t)}function ca(e,t){let n=e.input;if(t.scope!==n.scope)return{...ia(t),seq:e.seq,epoch:e.epoch+1};if(t.snapshot===n.snapshot&&t.active===n.active&&t.reduced===n.reduced)return e;let r={...e,input:t};return n.active&&!t.active&&(r={...aa(r),reconcile:!0}),!n.reduced&&t.reduced&&(r=aa(r)),sa(r,t.snapshot)}var la=`(prefers-reduced-motion: reduce)`,ua=()=>typeof window<`u`&&typeof window.matchMedia==`function`?window.matchMedia(la):void 0;function da(e){let t=ua();return t?.addEventListener?.(`change`,e),()=>t?.removeEventListener?.(`change`,e)}function fa(){return ua()?.matches??!1}function pa(){return(0,I.useSyncExternalStore)(da,fa,()=>!1)}function ma(e,t){let n=I.useRef(new Set);I.useEffect(()=>{let e=n.current;return()=>{for(let t of e)clearTimeout(t);e.clear()}},[e.epoch]),I.useEffect(()=>{for(let{after:r,change:i}of e.plan?.timers??[]){let e=setTimeout(()=>{n.current.delete(e),t(e=>({...e,motion:Gn(e.motion,[i])}))},r);n.current.add(e)}},[e.plan?.key])}function ha(e,t){let n=pa(),r=m(),i={snapshot:e,scope:t,active:r,reduced:n},[a,o]=I.useState(()=>ia(i)),s=ca(a,i);return s!==a&&o(s),ma(s,o),{motion:s.motion,feed:s.feed,reduced:n,paused:!r}}function ga(e,t){let n=Fe(1e3),[r,i]=I.useState({offset:0}),a=r.offset;return ct(e)&&e!==r.generatedAt&&t!==0&&(a=Date.parse(e)-t,i({generatedAt:e,offset:a})),n+a}export{en as A,_n as C,hn as D,pn as E,G as F,U as I,H as L,K as M,Vt as N,fn as O,V as P,pt as R,gn as S,un as T,$ as _,Dr as a,X as b,Er as c,_r as d,ar as f,qn as g,tr as h,Ur as i,Kt as j,an as k,wr as l,Yn as m,ha as n,Cr as o,nr as p,Gi as r,Tr as s,ga as t,yr as u,Kn as v,Mn as w,Z as x,Cn as y};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{At as r,Ht as i,Jt as a,S as o,St as s,Vt as c,Xt as l,en as u,g as d,kt as f,nn as p,qt as m,rn as h,un as g,ut as _,wt as v,xt as y}from"./queries-IlC9MZgh.js";import{Cn as b,Fi as x,I as S,Wn as C,Yn as w,a as T,n as E,sr as D}from"./toaster-DNnL8v10.js";import{c as O}from"./design-icons-QbNMZniQ.js";import{t as k}from"./button-BV_AiLj2.js";import{t as A}from"./switch-B9OfOEzC.js";import{t as ee}from"./status-dot-Bmn4xhch.js";import{n as j}from"./agent-accounts-D_ZKAmaW.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-DPfg7xSB.js";import{t as L}from"./textarea-BGp28xFr.js";import{t as R}from"./option-select-BcTkv-7t.js";import{a as te,i as ne,n as z,r as B,t as V}from"./settings-agent-picker-Dk8yJ57U.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-cu8BKCGT.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)(A,{checked:n?.enabled??!0,"aria-label":`Use ${e.displayName}`,onCheckedChange:t=>c(e.id,t,u.flash)})]}),l?(0,J.jsx)(k,{type:`button`,variant:`ghost`,size:`sm`,disabled:a.isPending,onClick:()=>a.mutate(void 0,{onError:e=>E(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)(k,{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)(k,{type:`button`,variant:`outline`,size:`sm`,disabled:s.isPending,onClick:()=>s.mutate({provider:e.id,authFailureId:i},{onSuccess:()=>E(`${e.displayName} can be tried again.`),onError:e=>E(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)(k,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void r(e.command),children:`Copy command`})]})]})}function ce(){let e=u(),t=s(),n=v(),r=f(),o=x(),[c,l]=(0,q.useState)(null),d=(0,q.useRef)(Promise.resolve()),h=(0,q.useRef)({}),_=(0,q.useRef)({}),y=(0,q.useRef)(t.data);(0,q.useEffect)(()=>{c&&D(t.data,c.provider)?.status===`connected`&&l(null)},[c,t.data]),(0,q.useEffect)(()=>{if(t.data){if(Object.values(_.current).every(e=>e===0)||!y.current){y.current=t.data;return}y.current={providers:t.data.providers.map(e=>({...e,enabled:(_.current[e.provider]??0)>0?D(y.current,e.provider)?.enabled??e.enabled:e.enabled}))}}},[t.data]);let S=(0,q.useCallback)((e,t,n)=>{let r=i.providerStatus,a=o.getQueryData(r);if(!a)return;y.current||=a;let s=X(a,e,t);_.current[e]=(_.current[e]??0)+1,o.setQueryData(r,s);let c=(h.current[e]??0)+1;h.current[e]=c,d.current=d.current.then(async()=>{try{let i=await C(e,t),a=D(i,e)?.enabled;if(a===void 0)return;if(y.current=X(y.current??i,e,a),c===h.current[e]){let t=o.getQueryData(r);o.setQueryData(r,t?X(t,e,a):i),n()}}catch(t){if(c===h.current[e]){let n=D(y.current,e)?.enabled,i=o.getQueryData(r);i&&n!==void 0?o.setQueryData(r,X(i,e,n)):y.current?o.setQueryData(r,y.current):o.removeQueries({queryKey:r,exact:!0}),E(t instanceof Error?t.message:String(t),{tone:`danger`})}}finally{_.current[e]=(_.current[e]??0)-1}})},[o]),T=g({mutationFn:e=>b(e),onSuccess:async(e,t)=>{l(null),E(e.opened?`Finish signing in in the terminal, then check again.`:`Provider is already connected.`),await o.invalidateQueries({queryKey:i.providerStatus}),await p(o,t,`none`)},onError:(t,n)=>{if(t instanceof w&&t.command){let r=m(e.data,n);l({provider:n,label:r,message:t.message,command:t.command});return}E(t.message,{tone:`danger`})}}),O=async e=>{try{await navigator.clipboard.writeText(e),E(`Command copied`)}catch{E(`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)(k,{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:a(e.data).map(e=>{let i=D(t.data,e.id),a=i?.status,o=re(a,t.isPending),s=T.isPending&&T.variables===e.id,l=i?.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)(ee,{tone:o.tone,pulse:t.isPending}),(0,J.jsx)(`span`,{children:o.label}),i?.enabled===!1?(0,J.jsx)(`span`,{children:`Disabled`}):null]}),(0,J.jsx)(ae,{provider:e,state:a,current:i,statusIsError:t.isError})]}),(0,J.jsx)(oe,{provider:e,state:a,current:i,isConnecting:s,incidentId:l,refresh:n,connect:T,retry:r,queueToggle:S})]}),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:c,provider:e.id,connected:a===`connected`,onCopy:O})]},e.id)})})]})}var Z=2e4;function le(){let e=d(),t=u(),n=h(l(t.data)),r=s();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)(O,{}),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(),s=x(),l=g({mutationFn:e=>S(e),onSuccess:e=>{s.setQueryData(c.config,e),s.invalidateQueries({queryKey:c.health}),s.invalidateQueries({queryKey:c.repo})},onError:e=>E(e.message,{tone:`danger`})}),[u,d]=K(e.systemPrompt??``),f=u.trim(),p=f===(e.systemPrompt??``),m=f.length>Z;G({dirty:!p,invalid:m,busy:l.isPending,save:()=>l.mutateAsync({systemPrompt:f===``?null:f}),discard:()=>d(e.systemPrompt??``)});let h=H(),_=H(),v=H(),y=H(),b=H(),C=(e,t)=>l.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:l.isPending,saved:h.saved,onSaved:h.flash,onPick:e=>C({defaultRunner:e},h.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:_.saved,children:(0,J.jsx)(`div`,{"data-slot":`agents-model-rows`,className:`flex flex-col gap-2.5`,children:a(r).map(i=>{let{providerConnected:a,providerReason:o}=te(n,i.id),s=t[i.id],c=N(i.id,r,s),u=I(i.id,r,s?.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)(R,{"aria-label":`Default model for ${i.pickerLabel}`,"data-slot":`agents-model`,"data-runner":i.id,value:d,title:o??i.pickerDescription,disabled:l.isPending||!a,onValueChange:e=>C({defaultModels:{[i.id]:e||null}},_.flash),className:`settings-select max-w-full bg-card`,options:[...u.map(e=>({value:e.id,label:e.label})),...c?[{value:F,label:c,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)(L,{"aria-label":`System prompt`,"data-slot":`agents-system-prompt`,value:u,onChange:e=>d(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:f.length,overLimit:m})]}),(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)(A,{"aria-label":`Live title updates`,"data-slot":`agents-live-title-updates`,checked:e.liveTitleUpdates??!0,disabled:l.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)(A,{"aria-label":`Review changes before finishing`,"data-slot":`agents-review-gate`,checked:e.reviewGate??!1,disabled:l.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)(R,{"aria-label":`Base branch`,"data-slot":`agents-base-branch`,value:e.baseBranch??``,disabled:l.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:i,onSaved:a,onPick:s}){let c=_(),l=y(),d=T(),f=o(),p=r(),m=d.projectId??`default`,h=f.data?.info?.root,g=j(c.data,d.projectId,h),v=u().data,b=B(c.data?.profiles??[],v),x=ne(b,v);return(0,J.jsxs)(W,{title:`Default runner`,hint:`Project defaults. A task can override these choices.`,saved:i,children:[(0,J.jsx)(V,{rows:b,runner:e,accountFor:e=>g?.[e]??null,providerStatus:t,disabled:n,accountDisabled:p.isPending||l.data===void 0,onPick:(t,n,r)=>{t!==e&&s(t),r&&p.mutate({projectId:m,provider:t,profileId:n},{onSuccess:a,onError:e=>E(e.message,{tone:`danger`})})}}),!t.isPending&&!t.isError&&D(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 +0,0 @@
1
- import{oi as e,ti as t}from"./toaster-DNnL8v10.js";function n(n){return t[e(n).bucket]<=t.waiting}export{n as t};
@@ -1,2 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{$t as r,Qt as i,en as a,g as o,in as s,k as c}from"./queries-IlC9MZgh.js";import{c as l}from"./host-context-DDbYAKpm.js";import{H as u,Si as d,Tr as f,U as p,V as m,W as h,Yn as g,_,an as v,c as y,cn as b,d as x,g as ee,o as te,s as ne,sn as re,un as ie,v as ae,xi as oe}from"./toaster-DNnL8v10.js";import{B as S,G as se,H as C,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-CgU9vxuM.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-CwDhRDtw.js";import{t as Ee}from"./switch-B9OfOEzC.js";import{c as De,s as Oe,t as R}from"./project-router-Dc6KBQsv.js";import{c as z,d as B,f as ke,l as Ae,n as je,o as Me}from"./page-shell-BdjH5hyc.js";import{a as Ne}from"./agent-accounts-D_ZKAmaW.js";import{r as Pe}from"./agents-settings-path-7X6_cvUg.js";import{t as Fe}from"./centered-state-N8vWM_Hw.js";import{$ as Ie,Gn as Le,Kn as Re,M as ze,N as Be,R as Ve,Sr as He,Tn as Ue,X as We,Z as Ge,ir as Ke,j as qe,kn as Je,lr as V,t as Ye}from"./index-DPfg7xSB.js";import{t as Xe}from"./textarea-BGp28xFr.js";import{_ as Ze,a as Qe,c as $e,d as et,f as tt,g as nt,h as rt,i as it,l as at,m as ot,n as st,o as ct,p as lt,r as ut,s as dt,t as H,u as ft,v as pt}from"./automation-format-jKMOXcHS.js";var U=e(t(),1),W=O([`pull_request.opened`,`issue.opened`,`issue.labeled`,`issue.unlabeled`]),mt=S({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()}),ht=O([`github`,`schedule`]),gt=v.omit({task:!0,images:!0,systemPrompt:!0}).extend({prompt:D(),variants:se([w(1),w(2),w(3)]).optional(),systemPrompt:D().optional()}),_t=S({at:D(),outcome:O([`launched`,`cancelled`]),runId:D().optional(),receiptId:D().optional(),trigger:O([`schedule`,`late`,`manual`,`retry`]).optional()}),G=S({id:D(),revision:k(),name:D(),description:D().optional(),enabled:E(),kind:ht,events:T(W).optional(),intervalSeconds:k().optional(),filters:mt.optional(),schedule:$e.optional(),task:gt,archived:_t.optional(),createdAt:D(),updatedAt:D()}),K=S({timestamp:D(),tieBreaker:D().optional()}),vt=S({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:K.optional()}),yt={lastError:D().max(1e3).optional(),lastErrorAt:D().datetime().optional()},bt=S({revision:k().optional(),baselineAt:D().optional(),armedAt:D().optional(),historyScan:vt.optional(),cursor:K.optional(),frozenHighWatermark:K.extend({tieBreaker:D()}).optional(),backlogAfter:K.extend({tieBreaker:D()}).optional(),nextCheckAt:D().optional(),lastSuccessAt:D().optional(),nextRunAt:D().optional(),lastRunAt:D().optional(),etags:C(D(),D()).optional(),backoffUntil:D().optional(),consecutiveFailures:k().optional(),...yt,onceOutcome:O([`failed`,`missed`]).optional()});function xt(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 St=O([`launched`,`no-match`,`duplicate`,`rate-limited`,`error`,`baseline`,`preview`,`skipped`,`manual`,`catch-up`,`failed`,`missed`]),Ct=S({seq:k(),ts:D(),automationId:D(),revision:k(),event:W.optional(),result:St,reason:D().optional(),durationMs:k().optional(),receiptId:D().optional(),runId:D().optional(),githubNumber:k().optional(),githubTitle:D().optional(),githubUrl:D().optional(),rateLimit:S({bucket:O([`core`,`search`]),remaining:k().optional(),resetAt:D().optional()}).optional()}),wt=S({matches:k(),launched:k(),duplicates:k(),errors:k()}),Tt=G.extend({state:bt.optional(),latestLog:Ct.optional(),counts:wt,nextRunAt:D().optional(),onceStatus:lt.optional()});S({available:E(),reason:D().optional(),timeZone:D(),scheduler:S({state:O([`scheduled`,`idle`]),nextDue:D().optional()}),automations:T(Tt)}),S({automation:G}).extend({once:S({dueAt:D(),timeZone:D(),resolvedInstant:D(),note:D()}).optional()}),S({automation:G,state:bt.optional(),latestLog:Ct.optional(),onceStatus:lt.optional()}),S({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()}),S({checkId:D()}),S({records:T(Ct)}),S({receiptId:D(),runId:D()}),S({runId:D()}),G.omit({id:!0,revision:!0,createdAt:!0,updatedAt:!0,enabled:!0,kind:!0,archived:!0}).extend({kind:ht.optional(),task:gt.omit({variants:!0}).strict(),enable:E().optional()}).omit({enable:!0}).extend({enabled:E().optional(),expectedRevision:k()}),S({archived:O([`include`,`only`]).optional()}),S({mode:O([`preview`,`execute`])});var q=n();function J({text:e}){return(0,q.jsx)(`div`,{role:`status`,className:`rounded-xl border border-border bg-card p-6 text-sm text-muted-foreground`,children:e})}var Et={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`},Dt={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 Ot(e){let[t,n]=(0,U.useState)(),[r,i]=(0,U.useState)(``),a=(0,U.useCallback)(t=>_(e,{signal:t}).then(({records:e})=>{t?.aborted||(n(e),i(``))}).catch(e=>{t?.aborted||i(String(e))}),[e]);return(0,U.useEffect)(()=>{a()},[a]),(0,U.useEffect)(()=>f(a),[a]),(0,U.useEffect)(()=>fe((t,n)=>{t===`automation-change`&&n.automationId===e&&a()}),[e,a]),{records:t,error:r,refresh:a}}function kt(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 At({records:e,all:t,timeZone:n,onRetried:r,readOnly:i=!1}){let a=e=>!i&&kt(e,t),[o,s]=(0,U.useState)(),[c,l]=(0,U.useState)(),u=Date.now(),d=async e=>{s(e),l(void 0);try{await m(e),r()}catch(t){l({receiptId:e,message:t instanceof Error?t.message:String(t)})}finally{s(void 0)}};return(0,q.jsx)(`ol`,{className:`grid gap-3`,"aria-label":`Automation execution log`,children:e.map(e=>(0,q.jsxs)(`li`,{className:`min-w-0 rounded-xl border border-card-edge bg-card p-4 shadow-card`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,q.jsx)(Ke,{dot:Et[e.result],children:Dt[e.result]}),(0,q.jsx)(`time`,{className:`text-xs text-muted-foreground`,dateTime:e.ts,title:e.ts,children:st(e.ts,n,u)})]}),e.reason?(0,q.jsx)(`p`,{className:`mt-2 text-sm break-words text-muted-foreground`,children:e.reason}):null,e.githubUrl||e.runId||a(e)?(0,q.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-4 gap-y-2 text-sm`,children:[e.githubUrl?(0,q.jsx)(`a`,{className:`inline-flex min-h-11 items-center underline underline-offset-4 break-all`,href:e.githubUrl,target:`_blank`,rel:`noreferrer`,children:e.githubTitle??`GitHub #${e.githubNumber??``}`}):null,e.runId?(0,q.jsx)(R,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${e.runId}`,children:`Open task`}):null,a(e)?(0,q.jsx)(M,{variant:`outline`,disabled:o===e.receiptId,onClick:()=>void d(e.receiptId),children:`Retry task`}):null]}):null,c&&c.receiptId===e.receiptId?(0,q.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm break-words text-destructive`,children:c.message}):null]},e.seq))})}var Y=`all`;function jt({label:e,value:t,onChange:n,options:r}){return(0,q.jsxs)(L,{value:t,onValueChange:n,children:[(0,q.jsx)(P,{"aria-label":e,className:`w-full sm:w-52`,children:(0,q.jsx)(N,{})}),(0,q.jsx)(F,{children:r.map(e=>(0,q.jsx)(I,{value:e.value,children:e.label},e.value))})]})}function Mt({automationId:e,automationName:t,timeZone:n,readOnly:r=!1}){let{records:i,error:a,refresh:o}=Ot(e),[s,c]=(0,U.useState)(Y),[l,u]=(0,U.useState)(Y),d=(0,U.useMemo)(()=>(i??[]).filter(e=>(s===Y||e.result===s)&&(l===Y||e.event===l)),[i,s,l]),f=(i??[]).some(e=>e.event);return(0,q.jsx)(Ae,{route:`automations`,density:i?ke(d.length):`full`,header:{title:`Execution log`,subtitle:t??`Automation activity`,secondaryActions:(0,q.jsx)(z,{variant:`outline`,asChild:!0,children:(0,q.jsx)(R,{to:`/automations`,children:`Back to automations`})})},children:a&&!i?(0,q.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,q.jsx)(J,{text:a}),(0,q.jsx)(M,{variant:`outline`,onClick:()=>void o(),children:`Retry`})]}):i?i.length===0?(0,q.jsx)(J,{text:`Nothing has run yet.`}):(0,q.jsxs)(`div`,{className:`grid gap-4`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,q.jsx)(jt,{label:`Result`,value:s,onChange:c,options:[{value:Y,label:`All results`},...St.options.map(e=>({value:e,label:Dt[e]}))]}),f?(0,q.jsx)(jt,{label:`Event`,value:l,onChange:u,options:[{value:Y,label:`All events`},...W.options.map(e=>({value:e,label:e}))]}):null]}),d.length===0?(0,q.jsx)(J,{text:`No rows match these filters.`}):(0,q.jsx)(At,{records:d,all:i,timeZone:n,onRetried:()=>void o(),readOnly:r})]}):(0,q.jsx)(J,{text:`Loading execution log…`})})}function Nt({automationId:e,automationName:t,timeZone:n,showName:r=!1,readOnly:i=!1}){let{records:a,error:o,refresh:s}=Ot(e),c=`Recent activity${r&&t?` · ${t}`:``}`;return!o&&a&&a.length===0?(0,q.jsxs)(`section`,{"data-slot":`automation-inline-log`,className:`flex flex-wrap items-center gap-x-2 border-t border-border pt-2.5 text-xs text-muted-foreground`,children:[(0,q.jsx)(`h3`,{className:`font-medium text-foreground`,children:c}),(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,q.jsx)(`p`,{children:`Nothing has run yet.`})]}):(0,q.jsxs)(`section`,{"data-slot":`automation-inline-log`,className:`min-w-0 border-t border-border pt-2.5`,children:[(0,q.jsx)(`h3`,{className:`mb-1.5 text-xs font-medium text-muted-foreground`,children:c}),o&&!a?(0,q.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[(0,q.jsx)(J,{text:o}),(0,q.jsx)(M,{variant:`outline`,onClick:()=>void s(),children:`Retry`})]}):a?(0,q.jsx)(At,{records:a.slice(0,5),all:a,timeZone:n,onRetried:()=>void s(),readOnly:i}):(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Loading activity…`})]})}function Pt({automation:e,timeZone:t,onDeleted:n}){let r=e.archived,i=e.schedule,a=i?ut(i):null,[o,s]=(0,U.useState)(!1),[c,l]=(0,U.useState)(!1),[u,d]=(0,U.useState)(``),f=(0,U.useRef)(null),p=(0,U.useRef)(null),m=(0,U.useRef)(null);(0,U.useEffect)(()=>{let e=m.current===`keep`?p.current:m.current===`delete`?f.current:null;m.current=null,e?.focus()},[o]);let h=async()=>{l(!0);try{await x(e.id),n()}catch(e){d(e instanceof Error?e.message:String(e)),l(!1)}},g=[[`Workflow`,e.task.workflow],[`Runner`,e.task.runner],[`Model`,e.task.model],[`Effort`,e.task.effort]];return(0,q.jsx)(Ae,{route:`automations`,density:`sparse`,header:{title:e.name,subtitle:`Archived one-time schedule. It cannot change; delete it when you no longer need the record.`},children:(0,q.jsxs)(`div`,{className:`grid min-w-0 gap-5`,children:[(0,q.jsxs)(`section`,{className:`min-w-0 rounded-xl border border-card-edge bg-card shadow-card p-4`,children:[(0,q.jsxs)(`p`,{className:`text-sm break-words`,children:[(0,q.jsx)(`span`,{children:r.outcome===`launched`?`Started its task.`:`Cancelled — no task was started.`}),r.runId?(0,q.jsxs)(q.Fragment,{children:[` · `,(0,q.jsx)(R,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${r.runId}`,children:`Open task`})]}):null]}),(0,q.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Archived ${H(r.at,t)} (${t}).`}),a&&i?.timeZone?(0,q.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Was due ${a.date} ${a.time} (${i.timeZone}).`}):null]}),(0,q.jsxs)(`section`,{"aria-labelledby":`archived-inputs`,className:`min-w-0 rounded-xl border border-card-edge bg-card shadow-card p-4`,children:[(0,q.jsx)(`h2`,{id:`archived-inputs`,className:`mb-3 text-[15px] font-medium`,children:`What it ran with`}),(0,q.jsxs)(`dl`,{className:`grid gap-3 text-sm`,children:[(0,q.jsxs)(`div`,{className:`grid gap-1`,children:[(0,q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Prompt`}),(0,q.jsx)(`dd`,{className:`break-words whitespace-pre-wrap`,children:e.task.prompt})]}),g.filter(([,e])=>e).map(([e,t])=>(0,q.jsxs)(`div`,{className:`grid gap-1`,children:[(0,q.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,q.jsx)(`dd`,{className:`break-words`,children:t})]},e))]})]}),(0,q.jsxs)(`section`,{className:`min-w-0`,children:[(0,q.jsx)(Nt,{automationId:e.id,automationName:e.name,timeZone:t,readOnly:!0}),(0,q.jsx)(M,{variant:`outline`,asChild:!0,className:`mt-3`,children:(0,q.jsx)(R,{to:`/automations/${e.id}/log`,children:`Execution log`})})]}),(0,q.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[o?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`text-sm break-words`,children:`Delete “${e.name}”? Its record and log are removed; the task stays.`}),(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,q.jsx)(M,{variant:`danger-ghost`,"data-action":`automation-delete-confirm`,disabled:c,onClick:()=>void h(),children:`Delete schedule`}),(0,q.jsx)(M,{ref:p,variant:`outline`,disabled:c,onClick:()=>{m.current=`delete`,s(!1)},children:`Keep`})]})]}):(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,q.jsx)(M,{ref:f,variant:`outline`,"data-action":`automation-delete`,onClick:()=>{m.current=`keep`,s(!0)},children:`Delete`}),(0,q.jsx)(M,{variant:`outline`,asChild:!0,children:(0,q.jsx)(R,{to:`/automations`,children:`Back to automations`})})]}),u?(0,q.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:u}):null]})]})})}var Ft=O([`pull_request.opened`,`issue.opened`,`issue.labeled`,`issue.unlabeled`]),X=T(D().trim().min(1).max(200)).max(100).optional(),It=S({includeExisting:E().optional(),requireCurrentLabels:E().optional(),authors:X,assignees:X,allLabels:X,anyLabels:X,excludeLabels:X,changedLabels:X,lookbackDays:k().int().min(1).max(90).default(7),maxRecords:k().int().min(1).max(100).default(25)}).passthrough(),Lt=S({prompt:D().min(1).max(1e5),workflow:D().trim().min(1).max(200).optional(),steps:T(re).min(1).max(100).optional(),runner:oe.optional(),model:D().trim().min(1).max(200).optional(),effort:D().trim().min(1).max(32).optional(),variants:se([w(1),w(2),w(3)]).optional(),worktree:E().optional(),autonomous:E().optional(),...b,...ie,systemPrompt:D().max(1e5).optional()}).passthrough().refine(e=>!(e.workflow&&e.steps),{message:`task selects either a named workflow or inline steps, not both`}),Rt=new Set(Object.keys(Lt.shape).filter(e=>e!==`variants`));function zt(e){return Object.fromEntries(Object.entries(e).filter(([e])=>Rt.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??{}}},S({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:ht.default(`github`),events:T(Ft).min(1).max(4).optional(),intervalSeconds:k().int().min(60).max(86400).optional(),filters:It.optional(),schedule:$e.passthrough().optional(),task:Lt,archived:S({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:d.custom,path:[`schedule`],message:`a scheduled automation needs a schedule`});return}e.events?.length||t.addIssue({code:d.custom,path:[`events`],message:`a GitHub automation needs at least one event`}),e.intervalSeconds===void 0&&t.addIssue({code:d.custom,path:[`intervalSeconds`],message:`a GitHub automation needs a poll interval`}),e.filters||t.addIssue({code:d.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:d.custom,path:[`filters`,`changedLabels`],message:`changedLabels is required for issue label events`})})),S({version:w(1).default(1),automations:T(ce()).default([]),tombstones:C(D(),D().datetime()).optional()}).passthrough();var Bt=S({timestamp:D().datetime(),tieBreaker:D().optional()}).passthrough(),Vt=vt.extend({cursor:Bt.optional()}),Ht=S({revision:k().int().positive().optional(),baselineAt:D().datetime().optional(),armedAt:D().datetime().optional(),historyScan:Vt.optional(),cursor:Bt.optional(),frozenHighWatermark:Bt.extend({tieBreaker:D()}).optional(),backlogAfter:Bt.extend({tieBreaker:D()}).optional(),nextCheckAt:D().datetime().optional(),lastSuccessAt:D().datetime().optional(),nextRunAt:D().datetime().optional(),lastRunAt:D().datetime().optional(),etags:C(D(),D()).optional(),backoffUntil:D().datetime().optional(),consecutiveFailures:k().int().nonnegative().optional(),...yt,onceOutcome:O([`failed`,`missed`]).optional()}).passthrough();S({version:w(1).default(1),states:C(D(),Ht).default({})}).passthrough(),S({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:S({eventId:D(),event:Ft,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`]);S({seq:k().int().positive(),ts:D().datetime(),automationId:D().min(1),revision:k().int().positive(),event:Ft.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:S({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}=zt(e.task??{prompt:``}),d=e.task===void 0;return{name:e.name??``,description:e.description??``,kind:e.kind??`schedule`,schedule:ft(e.schedule??{type:`daily`}),events:e.events??[W.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=[`${Ue()} 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`,at(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):`${Ue()} 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
- `)}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,U.useMemo)(()=>{let t=an(e);return r?`HSQ_COCKPIT_URL=${Z(a)} HSQ_PROJECT_ID=${Z(r)} ${t}`:t},[e,a,r]),s=(0,U.useMemo)(()=>on(o),[o]),[c,u]=(0,U.useState)(`idle`),[d,f]=(0,U.useState)(!1),p=(0,U.useId)(),m=(0,U.useRef)(void 0);if((0,U.useEffect)(()=>()=>clearTimeout(m.current),[]),(0,U.useEffect)(()=>u(`idle`),[o]),i)return(0,q.jsxs)(`section`,{"aria-labelledby":`copy-as-cli-heading`,"data-slot":`copy-as-cli`,className:`min-w-0 max-w-full overflow-hidden rounded-xl border border-card-edge bg-card shadow-card px-4 py-3.5`,children:[(0,q.jsx)(`h2`,{id:`copy-as-cli-heading`,className:`text-[13px] font-medium text-muted-foreground`,children:`Copy as CLI`}),(0,q.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,q.jsxs)(`section`,{"aria-labelledby":`copy-as-cli-heading`,"data-slot":`copy-as-cli`,className:`min-w-0 max-w-full overflow-hidden rounded-xl border border-card-edge bg-card shadow-card px-4 py-3.5`,children:[(0,q.jsxs)(`div`,{className:`flex min-h-8 min-w-0 flex-nowrap items-center justify-between gap-x-2`,children:[(0,q.jsx)(`h2`,{id:`copy-as-cli-heading`,className:`shrink-0 text-[13px] font-medium text-muted-foreground`,children:`Copy as CLI`}),(0,q.jsxs)(M,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`copy-as-cli-toggle`,"aria-expanded":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,q.jsx)(`span`,{className:`truncate`,children:d?`Hide`:`Show`}),(0,q.jsx)(xe,{"aria-hidden":`true`,className:j(`size-3.5 transition-transform`,d&&`rotate-180`)})]}),(0,q.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,q.jsx)(Se,{"aria-hidden":`true`,className:`size-3.5`}):(0,q.jsx)(He,{"aria-hidden":`true`,className:`size-3.5`}),c===`copied`?`Copied`:`Copy`]})]}),(0,q.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,q.jsx)(`pre`,{"data-slot":`copy-as-cli-line`,tabIndex:0,"aria-label":`Command line`,className:`m-0 max-w-full px-3 pt-2.5 pb-3 font-mono text-xs leading-5 break-all whitespace-pre-wrap text-muted-foreground outline-none`,children:s})}),(0,q.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,q.jsxs)(q.Fragment,{children:[`The definition ${t} would ${n?`save`:`create`}.`,` `,(0,q.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-px font-mono text-xs whitespace-nowrap text-foreground [word-spacing:-0.2em]`,children:`${Ue()} automation schema`}),` prints its shape.`]})})]})}function ln({pressed:e,onClick:t,disabled:n,children:r}){return(0,q.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=W.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,q.jsxs)(`div`,{className:`grid gap-4`,children:[n?(0,q.jsx)(`p`,{className:`text-xs text-pending-strong`,children:`GitHub unavailable · ${n}`}):null,(0,q.jsx)(`div`,{role:`group`,"aria-label":`GitHub events`,className:`inline-flex w-fit max-w-full flex-wrap gap-1 rounded-lg border border-border bg-muted/60 p-1`,children:pn.map(t=>(0,q.jsx)(ln,{pressed:e.events.includes(t),onClick:()=>r(t),children:dn[t]},t))}),(0,q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,q.jsx)(A,{htmlFor:`automation-interval`,children:`Check every`}),(0,q.jsxs)(L,{value:String(e.intervalSeconds),onValueChange:e=>t({intervalSeconds:Number(e)}),children:[(0,q.jsx)(P,{id:`automation-interval`,className:`w-full sm:w-48`,"aria-label":`Check every`,children:(0,q.jsx)(N,{})}),(0,q.jsx)(F,{children:o.map(e=>(0,q.jsx)(I,{value:String(e.seconds),children:e.label},e.seconds))})]})]}),(0,q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,q.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm`,children:[(0,q.jsx)(Ee,{"aria-label":`Include existing items`,"aria-describedby":`automation-history-hint`,checked:e.filters.includeExisting??!1,onCheckedChange:e=>i({includeExisting:e})}),(0,q.jsx)(`span`,{children:`Include existing items`})]}),(0,q.jsx)(`p`,{id:`automation-history-hint`,className:`text-xs text-muted-foreground`,children:vn(e.filters.includeExisting)})]}),(0,q.jsxs)(Te,{children:[(0,q.jsxs)(we,{className:`group flex min-h-11 items-center gap-2 text-sm font-medium`,children:[`Filters`,(0,q.jsx)(xe,{"aria-hidden":`true`,className:`size-4 text-soft-foreground transition-transform motion-reduce:transition-none group-data-[state=open]:rotate-180`})]}),(0,q.jsx)(Ce,{children:(0,q.jsxs)(`div`,{className:`grid gap-4 pt-2 sm:grid-cols-2`,children:[hn.map(t=>(0,q.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,q.jsx)(A,{htmlFor:`automation-filter-${t.key}`,children:t.label}),(0,q.jsx)(V,{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,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.hint}):null]},t.key)),(0,q.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,q.jsx)(A,{htmlFor:`automation-filter-lookback`,children:`Look back (days)`}),(0,q.jsx)(V,{id:`automation-filter-lookback`,className:`border-border`,type:`number`,min:1,value:e.filters.lookbackDays,onChange:e=>i({lookbackDays:Math.max(1,Number(e.target.value)||1)})})]}),(0,q.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,q.jsx)(A,{htmlFor:`automation-filter-max`,children:`Max records per check`}),(0,q.jsx)(V,{id:`automation-filter-max`,className:`border-border`,type:`number`,min:1,value:e.filters.maxRecords,onChange:e=>i({maxRecords:Math.max(1,Number(e.target.value)||1)})})]})]})})]})]})}var xn=e=>String(e).padStart(2,`0`);function Sn({label:e,value:t,max:n,onCommit:r}){let[i,a]=(0,U.useState)(xn(t)),o=(0,U.useRef)(null),s=!(/^\d{1,2}$/.test(i)&&Number(i)===t),c=`${e} must be 00–${xn(n)}.`,l=(0,U.useId)();return(0,U.useEffect)(()=>{o.current?.setCustomValidity(s?c:``)},[s,c]),(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(V,{ref:o,"aria-label":e,"aria-invalid":s||void 0,"aria-describedby":s?l:void 0,inputMode:`numeric`,maxLength:2,className:`w-20 border-border text-center tabular-nums`,value:i,onChange:e=>{a(e.target.value),/^\d{1,2}$/.test(e.target.value)&&Number(e.target.value)<=n&&r(Number(e.target.value))},onBlur:()=>a(xn(t))}),s?(0,q.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=pt(t,e)??pt(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?ot(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,U.useRef)(null),u=(0,U.useId)(),d=tt(e),f=!(t?.type===`once`&&t.at===e.at&&t.timeZone===e.timeZone)&&d!==null&&d<=Date.now();(0,U.useEffect)(()=>{l.current?.setCustomValidity(f?Qe:``)},[f]);let p=ut(e);return(0,q.jsxs)(`div`,{className:`grid gap-4`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-end gap-x-4 gap-y-3`,children:[(0,q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,q.jsx)(A,{htmlFor:`automation-once-date`,children:`Date`}),(0,q.jsx)(V,{ref:l,id:`automation-once-date`,type:`date`,className:`w-44 max-w-full border-border`,value:a,"aria-invalid":f||void 0,"aria-describedby":f?u:void 0,onChange:e=>{/^\d{4}-\d{2}-\d{2}$/.test(e.target.value)&&c(e.target.value,o,s)},required:!0})]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`at`}),(0,q.jsx)(Sn,{label:`Hour`,value:o,max:23,onCommit:e=>c(a,e,s)}),(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`:`}),(0,q.jsx)(Sn,{label:`Minute`,value:s,max:59,onCommit:e=>c(a,o,e)})]})]}),f?(0,q.jsx)(`p`,{id:u,className:`text-xs text-destructive`,children:Qe}):null,(0,q.jsx)(An,{value:e.timeZone??``,onCommit:e=>r({timeZone:e})}),(0,q.jsx)(jn,{value:e.latestStartMinutes,onChange:t=>n(kn(e,t))}),p?(0,q.jsx)(`p`,{className:`text-sm break-words`,children:`Runs once at ${p.time} on ${p.date} (${e.timeZone}). ${p.note?`${p.note} `:``}Squawk must be running then.`}):null]})}function 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,U.useState)(e),i=(0,U.useRef)(null),a=(0,U.useId)(),o=(0,U.useId)(),[s]=(0,U.useState)(Dn),c=n!==e||!Ze(n),l=nt(n);return(0,U.useEffect)(()=>{i.current?.setCustomValidity(c?l:``)},[c,l]),(0,q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,q.jsx)(A,{htmlFor:`automation-once-zone`,children:`Time zone`}),(0,q.jsx)(V,{ref:i,id:`automation-once-zone`,list:a,autoComplete:`off`,spellCheck:!1,className:`w-full border-border sm:w-72`,value:n,"aria-invalid":c||void 0,"aria-describedby":c?o:void 0,onChange:e=>{r(e.target.value),Ze(e.target.value)&&t(e.target.value)}}),(0,q.jsx)(`datalist`,{id:a,children:s.map(e=>(0,q.jsx)(`option`,{value:e},e))}),c?(0,q.jsx)(`p`,{id:o,className:`text-xs break-words text-destructive`,children:l}):null]})}function 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,q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,q.jsx)(A,{htmlFor:`automation-once-latest`,children:`Latest start`}),(0,q.jsxs)(L,{value:e===void 0?wn:String(e),onValueChange:e=>t(e===wn?void 0:Number(e)),children:[(0,q.jsx)(P,{id:`automation-once-latest`,className:`w-full sm:w-48`,"aria-label":`Latest start`,children:(0,q.jsx)(N,{})}),(0,q.jsx)(F,{children:n.map(e=>(0,q.jsx)(I,{value:e.minutes===void 0?wn:String(e.minutes),children:e.label},e.label))})]}),(0,q.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:`If Squawk was not running at the time, it still starts the task this long afterwards; later, the schedule is marked missed.`})]})}var 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,q.jsxs)(`div`,{className:`grid gap-4`,children:[(0,q.jsx)(`div`,{role:`group`,"aria-label":`Repeat`,className:`inline-flex w-fit max-w-full flex-wrap gap-1 rounded-lg border border-border bg-muted/60 p-1`,children:Mn.map(t=>(0,q.jsx)(ln,{pressed:e.type===t.type,onClick:()=>a(t.type),children:t.label},t.type))}),e.type===`once`?(0,q.jsx)(On,{value:e,stored:t,onChange:n}):null,e.type===`weekly`?(0,q.jsx)(`div`,{role:`group`,"aria-label":`Day of the week`,className:`inline-flex w-fit max-w-full flex-wrap gap-1 rounded-lg border border-border bg-muted/60 p-1`,children:dt.map((t,n)=>(0,q.jsx)(ln,{pressed:e.day===n+1,onClick:()=>i({day:n+1}),children:t},t))}):null,e.type===`once`?null:e.type===`hours`?(0,q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,q.jsx)(A,{htmlFor:`automation-every`,children:`Run every`}),(0,q.jsxs)(L,{value:String(e.every),onValueChange:e=>i({every:Number(e)}),children:[(0,q.jsx)(P,{id:`automation-every`,className:`w-full sm:w-48`,"aria-label":`Run every`,children:(0,q.jsx)(N,{})}),(0,q.jsx)(F,{children:ct.map(e=>(0,q.jsx)(I,{value:String(e),children:e===1?`hour`:`${e} hours`},e))})]}),(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Counted from midnight, so “every 6 hours” runs at 00:00, 06:00, 12:00 and 18:00.`})]}):(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`at`}),(0,q.jsx)(Sn,{label:`Hour`,value:e.hour,max:23,onCommit:e=>i({hour:e})}),(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`:`}),(0,q.jsx)(Sn,{label:`Minute`,value:e.minute,max:59,onCommit:e=>i({minute:e})}),(0,q.jsx)(`span`,{className:`text-sm break-all text-muted-foreground`,children:r})]}),e.type===`once`?null:(0,q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Cron: `,(0,q.jsx)(`code`,{className:`font-mono text-foreground`,children:at(e)})]})]})}var Pn=40*864e5,Fn=5;function In({schedule:e,timeZone:t,now:n=Date.now()}){if(e.type===`once`)return(0,q.jsx)(Ln,{schedule:e,now:n});let r=et(e,n+1,n+Pn,t,Fn);return(0,q.jsxs)(`section`,{"aria-labelledby":`next-runs-heading`,"data-slot":`next-runs`,className:`min-w-0 rounded-xl border bg-card p-5`,children:[(0,q.jsx)(`h2`,{id:`next-runs-heading`,className:`mb-2 text-base font-semibold`,children:`Next 5 runs`}),r.length===0?(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No runs in the next 40 days.`}):(0,q.jsx)(`ol`,{"aria-label":`Next 5 runs`,className:`grid divide-y divide-border text-sm`,children:r.map((e,r)=>(0,q.jsxs)(`li`,{className:`flex min-h-10 items-center justify-between gap-3 py-1.5`,children:[(0,q.jsx)(`span`,{className:r===0?`font-semibold tabular-nums text-foreground`:`font-medium tabular-nums`,children:H(new Date(e).toISOString(),t)}),(0,q.jsx)(`span`,{className:r===0?`font-medium text-accent-text`:`text-muted-foreground`,children:it(n,e)})]},e))}),(0,q.jsxs)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:[`Times are in `,t,`, the zone this Squawk runs in.`]})]})}function Ln({schedule:e,now:t}){let n=tt(e),r=ut(e);return(0,q.jsxs)(`section`,{"aria-labelledby":`next-runs-heading`,"data-slot":`next-runs`,className:`min-w-0 rounded-xl border bg-card p-5`,children:[(0,q.jsx)(`h2`,{id:`next-runs-heading`,className:`mb-3 text-base font-semibold`,children:`Runs once`}),n===null||!r?(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Pick a date, a time and a time zone.`}):(0,q.jsxs)(`p`,{className:`flex flex-wrap items-baseline justify-between gap-x-3 text-sm`,children:[(0,q.jsx)(`span`,{className:`font-medium tabular-nums`,children:`${r.date} ${r.time}`}),n>t?(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:it(t,n)}):null]}),r?.note?(0,q.jsx)(`p`,{className:`mt-2 text-sm break-words`,children:r.note}):null,n!==null&&n<=t?(0,q.jsx)(`p`,{className:`mt-2 text-sm text-destructive`,children:`The due time has passed.`}):null,(0,q.jsx)(`p`,{className:`mt-3 text-xs break-words text-muted-foreground`,children:`Times are in ${e.timeZone??`UTC`}. Squawk must be running then; afterwards the schedule is archived with its task.`})]})}var 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,U.useId)();return(0,q.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,q.jsxs)(`h2`,{id:o,className:`flex items-center gap-2 text-base font-semibold text-foreground`,children:[t,e]}):(0,q.jsx)(`h2`,{id:o,className:`text-sm font-semibold text-foreground`,children:e}),a,r?.section===i&&!r.conflict?(0,q.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,q.jsx)(q.Fragment,{children:r?(0,q.jsxs)(`p`,{className:`text-sm`,children:[(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:`Trigger · `}),Rn[e.kind]]}):(0,q.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[(0,q.jsx)(Ye,{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,q.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,q.jsx)(Nn,{value:e.schedule,stored:i?.schedule,onChange:e=>t({schedule:e}),timeZone:r}):(0,q.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,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,q.jsx)(A,{htmlFor:`automation-prompt`,children:`Prompt`}),(0,q.jsx)(Xe,{id:`automation-prompt`,value:e.prompt,onChange:e=>t({prompt:e.target.value}),rows:3,className:`[field-sizing:fixed] min-h-[88px] resize-none border-border bg-background`,required:!0}),(0,q.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:e.kind===`schedule`?(0,q.jsxs)(q.Fragment,{children:[`Available: `,`{{date}}`,` `,`{{time}}`,` `,`{{project}}`,` `,`{{automation}}`,`. A run-context block is appended automatically.`]}):(0,q.jsxs)(q.Fragment,{children:[`Available: `,`{{github.number}}`,` `,`{{github.title}}`,` `,`{{github.url}}`,` `,`{{github.labels}}`,`. GitHub content is appended as untrusted context.`]})})]}),r.length?(0,q.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:`Unavailable for this trigger: ${r.map(e=>`{{${e}}}`).join(`, `)}`}):null,(0,q.jsx)(Zn,{draft:e,patch:t})]})}function Wn({label:e,help:t,checked:n,onChange:r}){let i=(0,U.useId)();return(0,q.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,q.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,q.jsx)(`span`,{id:`${i}-label`,children:e}),(0,q.jsx)(`span`,{id:`${i}-help`,className:`completion-control-help`,children:t})]}),(0,q.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,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:`Each run is an ordinary task in its own worktree, queued behind the parallel cap.`}),(0,q.jsxs)(`div`,{"data-embedded":``,className:`grid min-w-0`,children:[(0,q.jsx)(Wn,{label:`Autonomous`,help:`Runs without waiting for answers.`,checked:e.autonomous,onChange:e=>t({autonomous:e})}),(0,q.jsx)(Be,{embedded:!0,archiveWhenDone:e.archiveWhenDone,autoMergePr:e.autoMergePr,onChange:t,disabled:n}),(0,q.jsx)(ze,{embedded:!0,allowWorkers:e.allowWorkers,allowMessaging:e.allowMessaging,onChange:t,disabled:n}),(0,q.jsx)(Wn,{label:a,help:o,checked:e.enabled,onChange:e=>t({enabled:e})})]}),r?(0,q.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,U.useState)(()=>Gt(e)),[s,c]=(0,U.useState)(e?.revision),[l,u]=(0,U.useState)(),[d,f]=(0,U.useState)(!1),m=e=>o(t=>({...t,...e})),_=async t=>{if(t.preventDefault(),d)return;let n=t.currentTarget;if(n instanceof HTMLFormElement&&!n.checkValidity()){n.reportValidity();return}f(!0),u(void 0);let i=`save`;try{if(e&&s!==void 0){let{automation:t}=await h(e.id,Xt({...a,enabled:e.enabled},s));c(t.revision),a.enabled!==e.enabled&&(i=`enable`,await p(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 g&&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{f(!1)}},v=(0,U.useId)(),b=(0,U.useId)(),x=a.kind===`schedule`;return(0,q.jsx)(Me,{route:`automations`,density:a.name.trim()===``&&a.prompt.trim()===``?`sparse`:`full`,header:Xn({automation:e,draft:a,formId:v,saveHintId:b,saving:d}),children:(0,q.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,q.jsxs)(`div`,{className:`grid min-w-0 gap-3.5`,children:[(0,q.jsx)(Bn,{title:`Name`,hideLegend:!0,section:`name`,failure:l,children:(0,q.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,q.jsx)(A,{htmlFor:`automation-name`,className:`text-sm font-semibold text-foreground`,children:`Name`}),(0,q.jsx)(V,{id:`automation-name`,className:`border-border`,value:a.name,placeholder:`Daily dependency audit`,onChange:e=>m({name:e.target.value}),required:!0})]})}),(0,q.jsxs)(Bn,{title:`When`,section:`when`,failure:l,children:[(0,q.jsx)(Vn,{draft:a,patch:m,forge:t,automation:e}),(0,q.jsx)(Hn,{draft:a,patch:m,forge:t,timeZone:n,automation:e})]}),(0,q.jsx)(Bn,{title:`What to run`,section:`run`,failure:l,children:(0,q.jsx)(Un,{draft:a,patch:m})})]}),(0,q.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,q.jsx)(Bn,{title:`Execution settings`,icon:(0,q.jsx)(ye,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),section:`execution`,failure:l,children:(0,q.jsx)(Gn,{draft:a,patch:m,saving:d,automation:e})}),x?(0,q.jsx)(In,{schedule:a.schedule,timeZone:n}):(0,q.jsxs)(`section`,{className:`min-w-0 rounded-xl border border-card-edge bg-card shadow-card p-5`,children:[(0,q.jsx)(`h2`,{className:`mb-2 text-base font-semibold`,children:`How it polls`}),(0,q.jsx)(`p`,{className:`text-sm break-words text-muted-foreground`,children:yn(a)})]}),(0,q.jsx)(cn,{draft:a,saveLabel:Jn(e,a),editing:e!==void 0})]}),l?.section===`form`||e?(0,q.jsxs)(`div`,{className:`grid min-w-0 gap-3.5 md:col-start-1`,children:[l?.section===`form`?(0,q.jsxs)(`div`,{role:`alert`,className:`flex flex-wrap items-center gap-3 text-sm text-destructive`,children:[(0,q.jsx)(`span`,{className:`break-words`,children:l.message}),l.conflict&&i?(0,q.jsx)(M,{type:`button`,variant:`outline`,onClick:i,children:`Reload`}):null]}):null,e?(0,q.jsx)(qn,{automation:e,onDeleted:r}):null]}):null]})})}function qn({automation:e,onDeleted:t}){let[n,r]=(0,U.useState)(!1),[i,a]=(0,U.useState)(!1),[o,s]=(0,U.useState)(``),c=async()=>{if(!i){a(!0),s(``);try{await x(e.id),t()}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(!1)}}};return(0,q.jsxs)(`div`,{className:`grid justify-items-start gap-2 border-t pt-4`,children:[n?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`text-sm break-words`,children:`Delete “${e.name}”? It will stop running and cannot be restored.`}),(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,q.jsx)(M,{type:`button`,variant:`danger-ghost`,"data-action":`automation-delete-confirm`,disabled:i,onClick:()=>void c(),children:`Delete automation`}),(0,q.jsx)(M,{type:`button`,variant:`outline`,disabled:i,onClick:()=>{r(!1),s(``)},children:`Keep`})]})]}):(0,q.jsx)(M,{type:`button`,variant:`outline`,"data-action":`automation-delete`,onClick:()=>r(!0),children:`Delete`}),o?(0,q.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,q.jsx)(`p`,{id:r,"data-slot":`automation-save-hint`,className:`min-h-[1lh] text-xs text-muted-foreground`,children:o}),secondaryActions:(0,q.jsx)(z,{type:`button`,variant:`outline`,asChild:!0,children:(0,q.jsx)(R,{to:`/automations`,children:`Cancel`})}),primaryAction:(0,q.jsx)(z,{type:`submit`,form:n,variant:`primary`,disabled:i||a!==``,title:a?`${a} is required`:void 0,"aria-describedby":o?r:void 0,children:i?`Saving…`:s})}}function Zn({draft:e,patch:t}){let n=c(),l=Ne(),{runners:u,signedOut:d}=l.runnersOn(e=>l.repoAccount?.[e]),f=o(),p=a(),{runner:m,ready:h}=r(e.runner??f.data?.defaultRunner??`claude`),g=s(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=Ve(m,p.data,g.data,[e.model]),b=y.find(t=>t.id===(e.model??``))?.label??e.model??`Runner default`,x=e=>(0,q.jsx)(e,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`});return(0,q.jsx)(Ge,{children:(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,q.jsx)(We,{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,q.jsx)(We,{slot:`automation-runner-pill`,icon:x(be),fieldLabel:!0,ariaLabel:`Runner`,label:e.runner?i(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:i(p.data,e)}))],footer:(0,q.jsx)(Ie,{uninstalled:l.uninstalled,signedOut:d.filter(t=>t!==e.runner)}),onPick:e=>{t({runner:e||void 0,model:void 0})}}),(0,q.jsx)(We,{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,U.useState)({}),[s,c]=(0,U.useState)({}),l=(e,t)=>o(n=>{let{[e]:r,...i}=n;return t?{...i,[e]:t}:i}),d=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}))}},f=e=>d(e.id,async()=>{l(e.id,{text:`Starting…`,tone:`info`});let{runId:t}=await u(e.id);l(e.id,{text:`Started task`,tone:`info`,runId:t}),n()}),m=e=>d(e.id,async()=>{l(e.id,void 0),await p(e.id,!e.enabled),await n()}),h=e=>d(e.id,async()=>{l(e.id,void 0),await te(e.id),await n()}),g=e=>d(e.id,async()=>{l(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 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,q.jsx)(B,{route:`automations`,density:e?ke(b.length):`full`,headerSpacing:`compact`,header:{title:`Automations`,subtitle:`Schedules and GitHub checks run while Squawk is open.`,primaryAction:(0,q.jsx)(z,{variant:`primary`,asChild:!0,children:(0,q.jsxs)(R,{to:`/automations/new`,children:[(0,q.jsx)(me,{"aria-hidden":`true`,className:`size-4`}),`New automation`]})})},sparseFooter:e&&b.length>0&&!r?(0,q.jsx)(je,{summary:`${b.length} active ${b.length===1?`automation`:`automations`} configured. New automations start paused so you can test filters before enabling them.`,actions:(0,q.jsx)(M,{variant:`outline`,size:`sm`,asChild:!0,children:(0,q.jsx)(R,{to:`/automations/new`,children:`Add another`})})}):void 0,children:t&&!e?(0,q.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,q.jsx)(J,{text:t}),(0,q.jsx)(M,{variant:`outline`,onClick:()=>void n(),children:`Retry`})]}):e?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-end justify-between gap-3 border-b border-border`,children:[i?(0,q.jsxs)(`div`,{className:`flex gap-6`,role:`group`,"aria-label":`Filter automations`,children:[(0,q.jsxs)(`button`,{type:`button`,"data-slot":`automations-tab`,"data-view":`active`,"aria-pressed":!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,q.jsx)(er,{count:v.length})]}),(0,q.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,q.jsx)(er,{count:y.length})]})]}):(0,q.jsx)(`span`,{}),(0,q.jsx)(`div`,{className:`pb-2.5`,children:(0,q.jsx)(tr,{data:e})})]}),r&&b.length===0?(0,q.jsx)(J,{text:`No archived automations.`}):b.length===0?(0,q.jsx)(Fe,{icon:(0,q.jsx)(ve,{}),tone:`neutral`,title:`No automations yet`,subtitle:`Create one paused, preview it, then enable it.`,heading:`h2`,actions:(0,q.jsx)(M,{variant:`primary`,asChild:!0,children:(0,q.jsxs)(R,{to:`/automations/new`,children:[(0,q.jsx)(me,{"aria-hidden":`true`,className:`size-4`}),`New automation`]})})}):(0,q.jsx)(`ul`,{className:`grid gap-3`,"aria-label":`Automations`,children:b.map(t=>(0,q.jsx)(ur,{automation:t,timeZone:e.timeZone,note:a[t.id],busy:s[t.id]===!0,onRun:()=>void f(t),onToggle:()=>void m(t),onPreview:()=>void g(t),onCancel:()=>void h(t)},t.id))})]}):(0,q.jsx)(J,{text:`Loading automations…`})})}function er({count:e}){return e===0?null:(0,q.jsx)(`span`,{"data-slot":`automations-tab-count`,className:`tabular-nums text-muted-foreground`,children:`· ${e}`})}function tr({data:e}){return(0,q.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?rt(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=Je(e);return(0,q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsxs)(`h2`,{className:`flex items-center gap-2 font-semibold break-words`,children:[(0,q.jsx)(n,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`}),e.name]}),(0,q.jsxs)(`p`,{"data-slot":`automation-meta`,className:`mt-1 flex flex-wrap items-baseline gap-x-1.5 ps-6 text-xs break-words text-muted-foreground`,children:[(0,q.jsx)(`span`,{children:nr(e)}),t?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),t]}):null]})]}),(0,q.jsx)(Ke,{dot:r.tone,shape:r.shape,pulse:r.pulse,children:r.label})]})}function ir({automation:e,archive:t}){return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`p`,{className:`text-sm break-words`,children:[t.outcome===`launched`?`Started its task.`:`Cancelled — no task was started.`,t.runId?(0,q.jsxs)(q.Fragment,{children:[` · `,(0,q.jsx)(R,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${t.runId}`,children:`Open task`})]}):null]}),(0,q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,q.jsx)(M,{variant:`outline`,asChild:!0,children:(0,q.jsx)(R,{to:`/automations/${e.id}`,children:`Details`})})})]})}function ar({automation:e,timeZone:t}){let n=e.kind===`schedule`,r=e.enabled&&n?e.nextRunAt:void 0;return!n&&e.enabled?(0,q.jsx)(`span`,{children:`continuous`}):r?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`text-foreground`,children:`Next run: ${H(r,t)}`}),(0,q.jsx)(`span`,{children:`· ${it(Date.now(),Date.parse(r))}`})]}):(0,q.jsx)(`span`,{children:`Next run: —`})}function or({automation:e,timeZone:t}){let n=e.enabled?xt(e.state):void 0;return n?(0,q.jsxs)(`p`,{role:`alert`,"data-slot":`automation-failing`,className:`text-sm break-words text-destructive`,children:[`The last ${n.consecutiveFailures} checks failed: ${n.lastError}`,n.retryAt?(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:` · Next try ${H(n.retryAt,t)}`}):null]}):null}var $=`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,q.jsxs)(`div`,{"data-slot":`automation-actions`,className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(M,{variant:`outline`,size:`sm`,className:$,"data-action":`automation-toggle`,disabled:t,onClick:i,children:e.enabled?`Pause`:`Enable`}),c?(0,q.jsx)(M,{variant:`outline`,size:`sm`,className:$,"data-action":`automation-run`,disabled:t,onClick:a,children:`Run now`}):(0,q.jsx)(M,{variant:`outline`,size:`sm`,className:$,"data-action":`automation-preview`,disabled:t,onClick:o,children:`Test filter`}),(0,q.jsx)(M,{variant:`outline`,size:`sm`,className:$,asChild:!0,children:(0,q.jsx)(R,{to:`/automations/${e.id}`,children:`Edit`})}),l&&!n?(0,q.jsx)(M,{variant:`outline`,size:`sm`,className:j($,`text-destructive`),ref:r,"data-action":`automation-cancel`,disabled:t,onClick:s,children:`Cancel`}):null,(0,q.jsx)(M,{variant:`outline`,size:`sm`,className:j($,`sm:ms-auto`),asChild:!0,children:(0,q.jsx)(R,{to:`/automations/${e.id}/log`,children:`Execution log`})})]})}function cr({automation:e,busy:t,keepRef:n,onConfirm:r,onKeep:i}){return(0,q.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[(0,q.jsx)(`p`,{className:`text-sm break-words`,children:`Cancel “${e.name}”? It will never run, and it moves to Archived.`}),(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,q.jsx)(M,{variant:`danger-ghost`,"data-action":`automation-cancel-confirm`,disabled:t,onClick:r,children:`Cancel schedule`}),(0,q.jsx)(M,{ref:n,variant:`outline`,disabled:t,onClick:i,children:`Keep`})]})]})}function lr({note:e}){return(0,q.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,q.jsxs)(q.Fragment,{children:[` · `,(0,q.jsx)(de,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:Pe(`gh`),children:`Set up`}),(0,q.jsxs)(`details`,{children:[(0,q.jsx)(`summary`,{className:`min-h-11 cursor-pointer`,children:`Command details`}),(0,q.jsx)(`pre`,{className:`whitespace-pre-wrap break-words`,children:e.details})]})]}):null,e.runId?(0,q.jsxs)(q.Fragment,{children:[` · `,(0,q.jsx)(R,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${e.runId}`,children:`Open task`})]}):null]})}function ur({automation:e,timeZone:t,note:n,busy:r,onRun:i,onToggle:a,onPreview:o,onCancel:s}){let[c,l]=(0,U.useState)(!1),u=(0,U.useRef)(null),d=(0,U.useRef)(null),f=(0,U.useRef)(null);(0,U.useEffect)(()=>{let e=f.current===`keep`?d.current:f.current===`cancel`?u.current:null;f.current=null,e?.focus()},[c]);let p=()=>{f.current=`keep`,l(!0)},m=()=>{f.current=`cancel`,l(!1)},h=e.archived;return(0,q.jsxs)(`li`,{"data-slot":`automation-card`,"data-kind":e.kind,className:`flex min-w-0 flex-col gap-2.5 rounded-xl border border-card-edge bg-card p-4 shadow-card`,children:[(0,q.jsx)(rr,{automation:e,nextRun:h?void 0:(0,q.jsx)(ar,{automation:e,timeZone:t})}),h?(0,q.jsx)(ir,{automation:e,archive:h}):null,h?null:(0,q.jsx)(or,{automation:e,timeZone:t}),h?null:(0,q.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,q.jsx)(cr,{automation:e,busy:r,keepRef:d,onConfirm:()=>{l(!1),s()},onKeep:m}):null,n?(0,q.jsx)(lr,{note:n}):null,(0,q.jsx)(Nt,{automationId:e.id,automationName:e.name,timeZone:t})]})}function dr(e){let t=Oe(),n=Re(),[r,i]=(0,U.useState)(),[a,o]=(0,U.useState)(``),s=(0,U.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,U.useEffect)(()=>{n&&s()},[n,s]),(0,U.useEffect)(()=>f(async e=>{n&&await s(e)}),[n,s]),(0,U.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,U.useState)(!1),{data:a,error:o,refresh:s}=dr(`include`),[c,l]=(0,U.useState)(0),u=Le();if(u===`unknown`)return(0,q.jsx)(B,{route:`automations`,density:`empty`,children:(0,q.jsx)(J,{text:`Loading automations…`})});if(u===`absent`)return(0,q.jsx)(qe,{});if(u===`disabled`)return(0,q.jsx)(B,{route:`automations`,density:`empty`,children:(0,q.jsx)(Fe,{icon:(0,q.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,q.jsx)($n,{data:a,error:o,refresh:s,archived:r,onArchivedChange:i});if(!a)return o?(0,q.jsx)(B,{route:`automations`,density:`empty`,header:{title:`Automations`,subtitle:`Could not load automations.`},children:(0,q.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,q.jsx)(J,{text:o}),(0,q.jsx)(M,{variant:`outline`,onClick:()=>void s(),children:`Retry`})]})}):(0,q.jsx)(B,{route:`automations`,density:`empty`,children:(0,q.jsx)(J,{text:`Loading automations…`})});let p={available:a.available,...a.reason?{reason:a.reason}:{}};return e===`new`?(0,q.jsx)(Kn,{forge:p,timeZone:a.timeZone,onSaved:d}):e===`edit`?f?f.archived?(0,q.jsx)(Pt,{automation:f,timeZone:a.timeZone,onDeleted:d}):(0,q.jsx)(Kn,{automation:f,forge:p,timeZone:a.timeZone,onSaved:d,onReload:()=>void s().then(()=>l(e=>e+1))},`${f.id}:${c}`):(0,q.jsx)(B,{route:`automations`,density:`empty`,header:{title:`Automation not found`,subtitle:`This automation may have been removed.`},children:(0,q.jsx)(M,{asChild:!0,variant:`outline`,children:(0,q.jsx)(R,{to:`/automations`,children:`Back to automations`})})}):t?(0,q.jsx)(Mt,{automationId:t,automationName:f?.name,timeZone:a.timeZone,readOnly:!!f?.archived}):(0,q.jsx)(J,{text:`Automation not found.`})}export{fr as AutomationsRoute};