orc-ai 0.1.52 → 0.1.53

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 (161) hide show
  1. package/dist/index.js +477 -477
  2. package/dist/web/assets/{Agents-DLu7phP7.js → Agents-D71JHI2H.js} +2 -2
  3. package/dist/web/assets/Attention-C_LKxdwf.js +2 -0
  4. package/dist/web/assets/{Audit-nUBNwvkU.js → Audit-BWh52YwS.js} +1 -1
  5. package/dist/web/assets/{ConfirmDialog-BGZ6sd6E.js → ConfirmDialog-D25Wf6Nc.js} +1 -1
  6. package/dist/web/assets/{Dashboard-Bhsm-LF4.js → Dashboard-DmYJjKna.js} +1 -1
  7. package/dist/web/assets/{DocumentWorkspace-C1HAVy0v.js → DocumentWorkspace-CW6S2i4-.js} +1 -1
  8. package/dist/web/assets/{ErrorState-B0KI2D4y.js → ErrorState-BoQqdsym.js} +1 -1
  9. package/dist/web/assets/FileEditor-_z3t0Dbd.js +1 -0
  10. package/dist/web/assets/JobWebhooks-Z4MXZNvH.js +1 -0
  11. package/dist/web/assets/Jobs-B-7i16mV.js +1 -0
  12. package/dist/web/assets/Knowledge-DX3nwzng.js +1 -0
  13. package/dist/web/assets/Markdown-BYChkZ3Z.js +2 -0
  14. package/dist/web/assets/{MarkdownEditor-BM9COcIb.js → MarkdownEditor-BMQq1cAY.js} +2 -2
  15. package/dist/web/assets/{MarkdownRenderer-C3UcCxdl.js → MarkdownRenderer-B5esWp7J.js} +96 -96
  16. package/dist/web/assets/PackageCatalog-CYF3tX8J.js +8 -0
  17. package/dist/web/assets/{PackageRunDialog-D3kvHk8o.js → PackageRunDialog-DxUs3Qnc.js} +2 -2
  18. package/dist/web/assets/{Pager-CMsNCI1_.js → Pager-DQCWHQWA.js} +1 -1
  19. package/dist/web/assets/PriorityBadge-ADp-pD5B.js +1 -0
  20. package/dist/web/assets/{Projects-BmfdCEv3.js → Projects-C2Ei5Q8Q.js} +2 -2
  21. package/dist/web/assets/QueryClientProvider-DlPztvhd.js +1 -0
  22. package/dist/web/assets/{RemoteFolderBrowser-ClOOMU0_.js → RemoteFolderBrowser-Btryj6gG.js} +1 -1
  23. package/dist/web/assets/{ResumeActions-gVze1Xjw.js → ResumeActions-1gJa3nsX.js} +1 -1
  24. package/dist/web/assets/{Rules-BMqF79Mt.js → Rules-CZvA-Eis.js} +4 -4
  25. package/dist/web/assets/ScratchpadDiagramEditor-D44NiVP_.js +159 -0
  26. package/dist/web/assets/Scratchpads-DP_v2hc8.js +10 -0
  27. package/dist/web/assets/Sessions-Ctd49sC9.js +3 -0
  28. package/dist/web/assets/{Settings-Dh7H43-p.js → Settings-BmbdT6Mp.js} +5 -5
  29. package/dist/web/assets/Skills-C_bBvy92.js +8 -0
  30. package/dist/web/assets/{SourceEditor-DlC3qNcT.js → SourceEditor-B5CtJBt0.js} +1 -1
  31. package/dist/web/assets/StatusBadge-CTFDUHuw.js +1 -0
  32. package/dist/web/assets/TagInput-T6rDuQ7O.js +1 -0
  33. package/dist/web/assets/TaskDetailSheet-BiIQ82AG.js +1 -0
  34. package/dist/web/assets/Tasks-OQmOaNqh.js +24 -0
  35. package/dist/web/assets/Terminals-DVu5OtGU.js +3 -0
  36. package/dist/web/assets/{ViewHeader-CX02p2eb.js → ViewHeader-DHM9SSkD.js} +1 -1
  37. package/dist/web/assets/{Webhooks-DUB9var7.js → Webhooks-CDNv5fUD.js} +1 -1
  38. package/dist/web/assets/{ar-SA-G6X2FPQ2-Br_n6QDe.js → ar-SA-G6X2FPQ2-9uLW-Aib.js} +1 -1
  39. package/dist/web/assets/{az-AZ-76LH7QW2-QyHk3dvA.js → az-AZ-76LH7QW2-DOqqo97y.js} +1 -1
  40. package/dist/web/assets/{bg-BG-XCXSNQG7-C6nlcNp_.js → bg-BG-XCXSNQG7-BHUaosi9.js} +1 -1
  41. package/dist/web/assets/{bn-BD-2XOGV67Q-4ptCYf5W.js → bn-BD-2XOGV67Q-_-LDSkWx.js} +1 -1
  42. package/dist/web/assets/button-BHKbOsmj.js +1 -0
  43. package/dist/web/assets/{ca-ES-6MX7JW3Y-Cgoa8y8g.js → ca-ES-6MX7JW3Y-D00wQc68.js} +1 -1
  44. package/dist/web/assets/{chunk-EIO257PC-D5rz2EHY.js → chunk-EIO257PC-BfeJ3EDs.js} +1 -1
  45. package/dist/web/assets/{client-BEiLQQ-F.js → client-BwhkVepQ.js} +1 -1
  46. package/dist/web/assets/{cs-CZ-2BRQDIVT-TiBX7ffm.js → cs-CZ-2BRQDIVT-EB-m3ztC.js} +1 -1
  47. package/dist/web/assets/{da-DK-5WZEPLOC-qeFhKopb.js → da-DK-5WZEPLOC-DWYR6cGM.js} +1 -1
  48. package/dist/web/assets/{de-DE-XR44H4JA-m_mVoRik.js → de-DE-XR44H4JA-Ck6sMUnJ.js} +1 -1
  49. package/dist/web/assets/{dist-EENe35AZ.js → dist-B9K53eWS.js} +1 -1
  50. package/dist/web/assets/{dist-BqZPrSfD.js → dist-ClOxCp9t.js} +1 -1
  51. package/dist/web/assets/{dist-C5yPNRzG.js → dist-D3PXSw6Q.js} +1 -1
  52. package/dist/web/assets/{dist-DcKneJwp.js → dist-HH469UWY.js} +1 -1
  53. package/dist/web/assets/{el-GR-BZB4AONW-BkZEWwVO.js → el-GR-BZB4AONW-DTkIqoGp.js} +1 -1
  54. package/dist/web/assets/{en-B4ZKOASM-DZ61I4Io.js → en-B4ZKOASM-Boq12EIA.js} +1 -1
  55. package/dist/web/assets/{es-ES-U4NZUMDT-N6PHqPGp.js → es-ES-U4NZUMDT-DY7ipP7c.js} +1 -1
  56. package/dist/web/assets/{eu-ES-A7QVB2H4-B0v57KpC.js → eu-ES-A7QVB2H4-D4Y6LEUc.js} +1 -1
  57. package/dist/web/assets/{fa-IR-HGAKTJCU-DRM3hyQI.js → fa-IR-HGAKTJCU-BlO1bnpc.js} +1 -1
  58. package/dist/web/assets/{fi-FI-Z5N7JZ37-BBhjlkHm.js → fi-FI-Z5N7JZ37-CQlPsyFJ.js} +1 -1
  59. package/dist/web/assets/{fr-FR-RHASNOE6-C6Ekm99g.js → fr-FR-RHASNOE6-DsyF_chP.js} +1 -1
  60. package/dist/web/assets/{gl-ES-HMX3MZ6V-BVrGslVP.js → gl-ES-HMX3MZ6V-BGAJPW2y.js} +1 -1
  61. package/dist/web/assets/{he-IL-6SHJWFNN-GiN2vY9l.js → he-IL-6SHJWFNN-BCFUF5Bi.js} +1 -1
  62. package/dist/web/assets/{hi-IN-IWLTKZ5I-tPRQ0szT.js → hi-IN-IWLTKZ5I-CWKeCfbn.js} +1 -1
  63. package/dist/web/assets/{highlighted-body-JLMTFACH-R4J_nfqS.js → highlighted-body-JLMTFACH-CYOy6uZ1.js} +1 -1
  64. package/dist/web/assets/{hu-HU-A5ZG7DT2-CkV1DDWQ.js → hu-HU-A5ZG7DT2-fqogn_m9.js} +1 -1
  65. package/dist/web/assets/{id-ID-SAP4L64H-DpzooQVd.js → id-ID-SAP4L64H-XFT4nLO5.js} +1 -1
  66. package/dist/web/assets/{image-GAAHSSAO-D7XRYD-a.js → image-GAAHSSAO-CtqEtsMw.js} +1 -1
  67. package/dist/web/assets/index-BCGI8JzG.css +1 -0
  68. package/dist/web/assets/{index-Ck-SDgTR.js → index-CMRGRbC9.js} +27 -28
  69. package/dist/web/assets/{it-IT-JPQ66NNP-C6oBozob.js → it-IT-JPQ66NNP-CjvUp5j1.js} +1 -1
  70. package/dist/web/assets/{ja-JP-DBVTYXUO-BG7OaLPP.js → ja-JP-DBVTYXUO-WaxwOOp1.js} +1 -1
  71. package/dist/web/assets/{kaa-6HZHGXH3-oYKKAQ51.js → kaa-6HZHGXH3-BABl6rMV.js} +1 -1
  72. package/dist/web/assets/{kab-KAB-ZGHBKWFO-B7LjxWHx.js → kab-KAB-ZGHBKWFO-vrrKDhKa.js} +1 -1
  73. package/dist/web/assets/{kk-KZ-P5N5QNE5-BjKAAAQx.js → kk-KZ-P5N5QNE5-DV0HT-Fa.js} +1 -1
  74. package/dist/web/assets/{km-KH-HSX4SM5Z-CP5JVtE5.js → km-KH-HSX4SM5Z-CMzRvYB5.js} +1 -1
  75. package/dist/web/assets/{ko-KR-MTYHY66A-skmsixpS.js → ko-KR-MTYHY66A-7XqecPXy.js} +1 -1
  76. package/dist/web/assets/{ku-TR-6OUDTVRD-BQGbWbVU.js → ku-TR-6OUDTVRD-D8O0bwyA.js} +1 -1
  77. package/dist/web/assets/label-BQ1Lr4sA.js +1 -0
  78. package/dist/web/assets/{lt-LT-XHIRWOB4-jPcUmdv0.js → lt-LT-XHIRWOB4-DrK90jMT.js} +1 -1
  79. package/dist/web/assets/{lv-LV-5QDEKY6T-BJimFBjM.js → lv-LV-5QDEKY6T-D7Xl2RRC.js} +1 -1
  80. package/dist/web/assets/mermaid-WFAXDIZX-CiFtUZlz.js +1 -0
  81. package/dist/web/assets/{mr-IN-CRQNXWMA-BJCZe-ef.js → mr-IN-CRQNXWMA-CjH1Q3x7.js} +1 -1
  82. package/dist/web/assets/{my-MM-5M5IBNSE-CzqI7mKR.js → my-MM-5M5IBNSE-CvdwmXcF.js} +1 -1
  83. package/dist/web/assets/{nb-NO-T6EIAALU-DOipNzcK.js → nb-NO-T6EIAALU-BWMKi1Br.js} +1 -1
  84. package/dist/web/assets/{nl-NL-IS3SIHDZ-m_uDUlnM.js → nl-NL-IS3SIHDZ-D5A6sC_f.js} +1 -1
  85. package/dist/web/assets/{nn-NO-6E72VCQL-ChLlN8eQ.js → nn-NO-6E72VCQL-D-p6QrsB.js} +1 -1
  86. package/dist/web/assets/{oc-FR-POXYY2M6-BJLoLhGq.js → oc-FR-POXYY2M6-6fyqLMv5.js} +1 -1
  87. package/dist/web/assets/{pa-IN-N4M65BXN-uYfxnmgm.js → pa-IN-N4M65BXN-D99Vs_Tb.js} +1 -1
  88. package/dist/web/assets/{percentages-BXMCSKIN--kwJevql.js → percentages-BXMCSKIN-B0BZzQvB.js} +1 -1
  89. package/dist/web/assets/{pl-PL-T2D74RX3-CDCLDsvJ.js → pl-PL-T2D74RX3-cl5WZaGT.js} +1 -1
  90. package/dist/web/assets/{pt-BR-5N22H2LF-CIrdrTZX.js → pt-BR-5N22H2LF-T6l12jm6.js} +1 -1
  91. package/dist/web/assets/{pt-PT-UZXXM6DQ-4Aps73mI.js → pt-PT-UZXXM6DQ-DnxUMvhO.js} +1 -1
  92. package/dist/web/assets/{ro-RO-JPDTUUEW-fgJWBuSP.js → ro-RO-JPDTUUEW-w6wCZHtR.js} +1 -1
  93. package/dist/web/assets/{ru-RU-B4JR7IUQ-D98t4_hW.js → ru-RU-B4JR7IUQ-DMaA4CQ-.js} +1 -1
  94. package/dist/web/assets/scratchpad-routes-B75DnNPp.js +1 -0
  95. package/dist/web/assets/scroll-area-DMjOmHf5.js +1 -0
  96. package/dist/web/assets/select-CBHDS40x.js +1 -0
  97. package/dist/web/assets/{si-LK-N5RQ5JYF-DNwP7Qip.js → si-LK-N5RQ5JYF-Coe9-5Yb.js} +1 -1
  98. package/dist/web/assets/{sk-SK-C5VTKIMK-BfncC8rh.js → sk-SK-C5VTKIMK-Bq23BXvP.js} +1 -1
  99. package/dist/web/assets/{sl-SI-NN7IZMDC-IXH265Xx.js → sl-SI-NN7IZMDC-WZEKy1qu.js} +1 -1
  100. package/dist/web/assets/subset-shared.chunk-CAD0Eg6H.js +1 -0
  101. package/dist/web/assets/{subset-worker.chunk-BNdMWEQD.js → subset-worker.chunk-CAbfOFrS.js} +1 -1
  102. package/dist/web/assets/{sv-SE-XGPEYMSR-CWjE7XZA.js → sv-SE-XGPEYMSR-p1gc_GrE.js} +1 -1
  103. package/dist/web/assets/{ta-IN-2NMHFXQM-mzDgApaO.js → ta-IN-2NMHFXQM-o8J0vNj1.js} +1 -1
  104. package/dist/web/assets/table-ByS-sgsb.js +1 -0
  105. package/dist/web/assets/tabs-DltQVo38.js +1 -0
  106. package/dist/web/assets/{th-TH-HPSO5L25-sCRbUk4w.js → th-TH-HPSO5L25-pt7Zt9xm.js} +1 -1
  107. package/dist/web/assets/{tr-TR-DEFEU3FU-BJVVhuUn.js → tr-TR-DEFEU3FU-BENdvVvp.js} +1 -1
  108. package/dist/web/assets/{uk-UA-QMV73CPH-CoaqtD6Z.js → uk-UA-QMV73CPH-CenI2hX1.js} +1 -1
  109. package/dist/web/assets/useDetailRoute-C8xQeILG.js +1 -0
  110. package/dist/web/assets/useJobs-CCQUWZt3.js +1 -0
  111. package/dist/web/assets/useKnowledge-DbjT1a0E.js +1 -0
  112. package/dist/web/assets/{useListSelection-DcULI867.js → useListSelection-CgpNqqAb.js} +1 -1
  113. package/dist/web/assets/useMemories-D0tEN20z.js +1 -0
  114. package/dist/web/assets/useMutation-HX90wI4L.js +1 -0
  115. package/dist/web/assets/useProjectScope-CZEfU9mq.js +1 -0
  116. package/dist/web/assets/useSessions-C2GU4FkG.js +1 -0
  117. package/dist/web/assets/{vi-VN-M7AON7JQ-C_1RRSxn.js → vi-VN-M7AON7JQ-REgvRLzg.js} +1 -1
  118. package/dist/web/assets/{view-params-DNioxw0G.js → view-params-BqRwdnv0.js} +1 -1
  119. package/dist/web/assets/{x-CtXhMM9g.js → x-BKorzD7S.js} +1 -1
  120. package/dist/web/assets/{zh-CN-LNUGB5OW-BRsIz_fP.js → zh-CN-LNUGB5OW-Ceo4z5r5.js} +1 -1
  121. package/dist/web/assets/{zh-HK-E62DVLB3-DwjC6Cwv.js → zh-HK-E62DVLB3-CFQOn9E1.js} +1 -1
  122. package/dist/web/assets/{zh-TW-RAJ6MFWO-DrD43hHv.js → zh-TW-RAJ6MFWO-GpxYPogk.js} +1 -1
  123. package/dist/web/index.html +16 -16
  124. package/package.json +1 -1
  125. package/dist/web/assets/Attention-D80Q2fL4.js +0 -2
  126. package/dist/web/assets/FileEditor-B1pLaZil.js +0 -1
  127. package/dist/web/assets/JobWebhooks-DIfKugwY.js +0 -1
  128. package/dist/web/assets/Jobs-0VP8O03Z.js +0 -1
  129. package/dist/web/assets/Knowledge-DCsSHLqC.js +0 -1
  130. package/dist/web/assets/Markdown-CenDHcGi.js +0 -2
  131. package/dist/web/assets/PackageCatalog-oQ9U4WEt.js +0 -8
  132. package/dist/web/assets/PriorityBadge-_KMVnMst.js +0 -1
  133. package/dist/web/assets/ScratchpadDiagramEditor-BtuYQvFc.js +0 -159
  134. package/dist/web/assets/Scratchpads-D98SMUv3.js +0 -10
  135. package/dist/web/assets/Sessions-CLDdpR36.js +0 -3
  136. package/dist/web/assets/Skills-B5OEYsYx.js +0 -8
  137. package/dist/web/assets/StatusBadge-CZQsVLgL.js +0 -1
  138. package/dist/web/assets/TagInput-D7ZsM-Dr.js +0 -1
  139. package/dist/web/assets/TaskDetailSheet-0hZx_-me.js +0 -1
  140. package/dist/web/assets/Tasks-c1HlLJhH.js +0 -24
  141. package/dist/web/assets/Terminals-DQ8HWVlI.js +0 -3
  142. package/dist/web/assets/button-PNx108iL.js +0 -1
  143. package/dist/web/assets/index-Bpb-AzH6.css +0 -1
  144. package/dist/web/assets/label-Ce3QFsX5.js +0 -1
  145. package/dist/web/assets/mermaid-WFAXDIZX-DmWpYePv.js +0 -1
  146. package/dist/web/assets/pencil-BPI6pWhy.js +0 -1
  147. package/dist/web/assets/scratchpad-routes-BwYHUs6J.js +0 -1
  148. package/dist/web/assets/scroll-area-Alw_ieLV.js +0 -1
  149. package/dist/web/assets/select-Cg0xEvji.js +0 -1
  150. package/dist/web/assets/subset-shared.chunk-BJl1UMhd.js +0 -1
  151. package/dist/web/assets/table-DC8IBMHg.js +0 -1
  152. package/dist/web/assets/tabs-DWq5oObc.js +0 -1
  153. package/dist/web/assets/trash-D7o9t0-a.js +0 -1
  154. package/dist/web/assets/useDetailRoute-1i4Z0-d5.js +0 -1
  155. package/dist/web/assets/useJobs-B2MCCWKa.js +0 -1
  156. package/dist/web/assets/useKnowledge-oAVI1FoA.js +0 -1
  157. package/dist/web/assets/useMemories-CcDhzt2Y.js +0 -1
  158. package/dist/web/assets/useMutation-DDLZlpLS.js +0 -1
  159. package/dist/web/assets/useProjectScope-C7yZQa4i.js +0 -1
  160. package/dist/web/assets/useSessions-Bx-Bw75y.js +0 -1
  161. package/dist/web/assets/utils-Q1DAuYRG.js +0 -1
@@ -1,4 +1,4 @@
1
- import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{l as r,t as i}from"./button-PNx108iL.js";import{n as a,t as o}from"./useMutation-DDLZlpLS.js";import{t as s}from"./label-Ce3QFsX5.js";import{n as c}from"./client-BEiLQQ-F.js";import{At as l,En as u,Et as d,G as f,K as p,Tt as m,W as h,X as g,Y as _,ct as v,h as y,kt as b,wn as x,wt as S}from"./index-Ck-SDgTR.js";import{i as C,n as w,t as T}from"./PackageRunDialog-D3kvHk8o.js";import{t as E}from"./ConfirmDialog-BGZ6sd6E.js";import{t as D}from"./ErrorState-B0KI2D4y.js";import{t as O}from"./ViewHeader-CX02p2eb.js";import{t as k}from"./useDetailRoute-1i4Z0-d5.js";import{t as A}from"./view-params-DNioxw0G.js";var j=e(t(),1),M={specialist:`---
1
+ import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{n as r}from"./QueryClientProvider-DlPztvhd.js";import{n as i,t as a}from"./useMutation-HX90wI4L.js";import{t as o}from"./button-BHKbOsmj.js";import{t as s}from"./label-BQ1Lr4sA.js";import{n as c}from"./client-BwhkVepQ.js";import{At as l,Dn as u,Et as d,G as f,K as p,Tn as m,Tt as h,W as g,X as _,Y as v,ct as y,h as b,kt as x,wt as S}from"./index-CMRGRbC9.js";import{i as C,n as w,t as T}from"./PackageRunDialog-DxUs3Qnc.js";import{t as E}from"./ConfirmDialog-D25Wf6Nc.js";import{t as D}from"./ErrorState-BoQqdsym.js";import{t as O}from"./ViewHeader-DHM9SSkD.js";import{t as k}from"./useDetailRoute-C8xQeILG.js";import{t as A}from"./view-params-BqRwdnv0.js";var j=e(t(),1),M={specialist:`---
2
2
  name: Specialist
3
3
  description: Describe when to use this specialist
4
4
  ---
@@ -31,4 +31,4 @@ Implement the requested change, preserve unrelated work, and run relevant checks
31
31
  `,bom:e.startsWith(``)?``:``}}function F(e,t,n){let r=P(e);n===void 0?r.document.delete(t):r.document.set(t,n);let i=r.document.toString().trimEnd().replace(/\n/g,r.newline);return`${r.bom}---${r.newline}${i}${r.newline}---${r.newline}${r.body}`}function I(e,t){let n=e.match(/^((?:\uFEFF)?---\r?\n[\s\S]*?\r?\n---)(?:\r?\n[\s\S]*)?$/)?.[1];if(!n)throw Error(`Missing YAML configuration.`);return`${n}${e.includes(`\r
32
32
  `)?`\r
33
33
  `:`
34
- `}${t}`}function L(e){let t=e.tools;if(t===void 0)return[];if(typeof t==`string`)return t.split(/[\s,]+/).filter(Boolean).map(e=>({name:e,allowed:!0}));if(Array.isArray(t)&&t.every(e=>typeof e==`string`))return t.map(e=>({name:e,allowed:!0}));if(t&&typeof t==`object`&&!Array.isArray(t))return Object.entries(t).map(([e,t])=>{if(typeof t!=`boolean`)throw Error(`Tool "${e}" must be true or false.`);return{name:e,allowed:t}});throw Error(`Tools must be a mapping of names to true/false, a list, or a string.`)}function R(e,t){let n=P(e);C(n.document.get(`tools`,!0))||n.document.set(`tools`,{});let r=n.document.get(`tools`,!0);if(C(r))for(let{name:e}of L(n.fields))t.some(t=>t.name===e)||n.document.deleteIn([`tools`,e]);for(let e of t)n.document.setIn([`tools`,e.name],e.allowed);return`${n.bom}---${n.newline}${n.document.toString().trimEnd().replace(/\n/g,n.newline)}${n.newline}---${n.newline}${n.body}`}var z=n();function B(e){return L(e).map(e=>({...e,key:crypto.randomUUID()}))}function V({agent:e,pending:t,error:n,onSave:r}){let[a,o]=(0,j.useState)(e?.id??``),[c,u]=(0,j.useState)(e?.raw??M.specialist),[f,p]=(0,j.useState)(`fields`),[m,h]=(0,j.useState)(()=>e?B(e.fields):[]),[g,_]=(0,j.useState)(),y=(0,j.useMemo)(()=>{try{return{value:P(c),error:void 0}}catch(e){return{value:void 0,error:e.message}}},[c]),x=y.value?.fields,C;m.some(e=>!e.name.trim())?C=`Enter a name for every tool.`:new Set(m.map(e=>e.name.trim())).size!==m.length&&(C=`Tool names must be unique.`);let w=e?`Save changes`:`Create agent`;function T(e){h(e),e.every(e=>e.name.trim())&&new Set(e.map(e=>e.name.trim())).size===e.length&&u(R(c,e.map(e=>({...e,name:e.name.trim()}))))}function E(){if(_(void 0),f===`fields`){if(C)return;p(`source`)}else try{let e=P(c);for(let t of[`name`,`description`,`model`,`color`])if(e.fields[t]!==void 0&&typeof e.fields[t]!=`string`)throw Error(`${t} must be a string to edit it in the form.`);h(B(e.fields)),p(`fields`)}catch(e){_(e.message)}}return(0,z.jsxs)(d,{className:`max-w-3xl max-h-[90vh] overflow-y-auto`,children:[(0,z.jsx)(b,{children:(0,z.jsx)(l,{children:e?`Edit ${e.name}`:`New shared agent`})}),(0,z.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e.preventDefault(),r(a,c)},children:[(0,z.jsxs)(`fieldset`,{disabled:t,className:`space-y-4`,children:[!e&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(s,{htmlFor:`agent-template`,children:`Starting template`}),(0,z.jsxs)(`select`,{id:`agent-template`,"data-testid":`agent-template`,className:`w-full border rounded-xs p-2 bg-surface`,defaultValue:`specialist`,onChange:e=>{let t=M[e.target.value];u(t),h(B(P(t).fields)),_(void 0)},children:[(0,z.jsx)(`option`,{value:`specialist`,children:`General specialist`}),(0,z.jsx)(`option`,{value:`reviewer`,children:`Reviewer`}),(0,z.jsx)(`option`,{value:`builder`,children:`Builder`})]})]}),(0,z.jsx)(s,{htmlFor:`agent-id`,children:`Agent ID`}),(0,z.jsx)(S,{id:`agent-id`,"data-testid":`agent-id-input`,value:a,disabled:!!e,onChange:e=>o(e.target.value),placeholder:`security-review`}),(0,z.jsx)(i,{type:`button`,variant:`outline`,"data-testid":`agent-editor-mode`,onClick:E,disabled:f===`fields`&&!!C,children:f===`fields`?`Edit YAML + Markdown`:`Edit fields`}),f===`source`?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(s,{htmlFor:`agent-definition`,children:`YAML configuration + Markdown instructions`}),(0,z.jsx)(v,{id:`agent-definition`,testId:`agent-content-input`,path:`agent.agent.md`,readOnly:t,height:400,value:c,onChange:e=>{u(e),_(void 0)}})]}):x&&(0,z.jsxs)(z.Fragment,{children:[[[`name`,`Name`],[`description`,`Description`],[`model`,`Model (optional)`],[`color`,`Color (optional)`]].map(([e,t])=>(0,z.jsxs)(`div`,{className:`space-y-1`,children:[(0,z.jsx)(s,{htmlFor:`agent-${e}`,children:t}),(0,z.jsx)(S,{id:`agent-${e}`,"data-testid":`agent-${e}-input`,value:typeof x[e]==`string`?x[e]:``,onChange:t=>u(F(c,e,t.target.value||(e===`description`?``:void 0)))})]},e)),(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,z.jsx)(`input`,{"data-testid":`agent-custom-tools`,type:`checkbox`,checked:x.tools!==void 0,onChange:e=>{h([]),u(F(c,`tools`,e.target.checked?{}:void 0))}}),` `,`Customize tool access`]}),(0,z.jsx)(`p`,{className:`text-xs text-outline`,children:`Use the tool names supported by your chosen backend. With customization off, the backend's default tools apply. An empty custom list allows no tools.`}),x.tools!==void 0&&(0,z.jsxs)(z.Fragment,{children:[m.map((e,t)=>(0,z.jsxs)(`div`,{"data-testid":`agent-tool-row`,className:`flex items-center gap-2`,children:[(0,z.jsx)(S,{"data-testid":`agent-tool-name`,"aria-label":`Tool ${t+1} name`,value:e.name,list:`agent-tool-suggestions`,onChange:e=>T(m.map((n,r)=>r===t?{...n,name:e.target.value}:n))}),(0,z.jsxs)(`label`,{className:`flex items-center gap-1 text-sm`,children:[(0,z.jsx)(`input`,{"data-testid":`agent-tool-allowed`,type:`checkbox`,checked:e.allowed,onChange:e=>T(m.map((n,r)=>r===t?{...n,allowed:e.target.checked}:n))}),` `,`Allowed`]}),(0,z.jsx)(i,{"data-testid":`agent-tool-remove`,type:`button`,variant:`outline`,onClick:()=>T(m.filter((e,n)=>n!==t)),children:`Remove`})]},e.key)),(0,z.jsx)(`datalist`,{id:`agent-tool-suggestions`,children:[`Read`,`Grep`,`Glob`,`Edit`,`Write`,`Bash`].map(e=>(0,z.jsx)(`option`,{value:e},e))}),(0,z.jsx)(i,{"data-testid":`agent-tool-add`,type:`button`,variant:`outline`,onClick:()=>T([...m,{key:crypto.randomUUID(),name:``,allowed:!0}]),children:`Add tool`})]})]}),(0,z.jsx)(s,{htmlFor:`agent-instructions`,children:`Instructions`}),(0,z.jsx)(v,{id:`agent-instructions`,testId:`agent-instructions-input`,path:`instructions.md`,readOnly:t,height:240,value:y.value?.body??``,onChange:e=>u(I(c,e))}),(0,z.jsx)(`p`,{className:`text-xs text-outline`,children:`Use YAML + Markdown to edit handoffs and additional configuration. Custom fields are preserved.`})]})]}),(n||y.error||g||f===`fields`&&C)&&(0,z.jsx)(`p`,{"data-testid":`agent-editor-error`,role:`alert`,className:`text-destructive`,children:n||y.error||g||C}),(0,z.jsx)(i,{"data-testid":`agent-submit`,type:`submit`,disabled:t||!a.trim()||!c.trim()||!!y.error||f===`fields`&&!!C,children:t?`Saving...`:w})]})]})}function H({embedded:e=!1}){let t=u(),n=new URLSearchParams(t.search).get(`project`)??`all`,[s,l]=A(`editorMode`,`read`,[`read`,`edit`,`split`]),[d,b]=A(`agentQuery`,``),C=r(),w=a({queryKey:[`agents`],queryFn:()=>c.agents.list()}),{selectedId:M,openDetail:N,closeDetail:P}=k(e?`/packages/agents`:`/agents`,`agentId`),F=a({queryKey:[`agent`,M],queryFn:()=>c.agents.get(M),enabled:!!M}),[I,L]=(0,j.useState)(!1),[R,B]=(0,j.useState)(),[H,U]=(0,j.useState)(!1),[W,G]=(0,j.useState)(),K=o({mutationFn:c.agents.create,onSuccess:()=>{C.invalidateQueries({queryKey:[`agents`]}),L(!1)}}),q=o({mutationFn:c.agents.delete,onSuccess:()=>{U(!1),P(),C.invalidateQueries({queryKey:[`agents`]}),C.invalidateQueries({queryKey:[`agent-packages`]}),C.invalidateQueries({queryKey:[`agent`]})}}),J=o({mutationFn:({profile:e,content:t})=>c.agents.update(e.id,{content:t,expectedRaw:e.raw,expectedPath:e.path}),onSuccess:e=>{C.setQueryData([`agent`,e.id],e),C.invalidateQueries({queryKey:[`agents`]}),C.invalidateQueries({queryKey:[`agent-packages`]}),B(void 0)}});if(w.error)return(0,z.jsx)(D,{message:w.error.message,onRetry:()=>void w.refetch()});let Y=(w.data?.agents??[]).filter(e=>`${e.name} ${e.id} ${e.description}`.toLowerCase().includes(d.toLowerCase()));return(0,z.jsxs)(`div`,{className:`space-y-5`,children:[e?(0,z.jsxs)(`div`,{className:`flex flex-wrap justify-between gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h2`,{className:`font-medium`,children:`Agent definitions`}),(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Manage specialist instructions, models and tools. Add them to APM packages for reuse.`})]}),(0,z.jsx)(i,{"data-testid":`new-agent-button`,onClick:()=>{K.reset(),L(!0)},children:`New agent`})]}):(0,z.jsx)(O,{title:`Agents`,meta:`${w.data?.agents.length??0} shared profiles`,action:(0,z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,z.jsx)(i,{"data-testid":`new-agent-button`,onClick:()=>{K.reset(),L(!0)},children:`New agent`})})}),(0,z.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Shared specialist definitions for every connected coding agent.`,` `,(0,z.jsx)(`a`,{className:`text-primary underline`,href:`https://microsoft.github.io/apm/producer/author-primitives/instructions-and-agents/`,target:`_blank`,rel:`noreferrer`,children:`APM agent format`})]}),!e&&(0,z.jsx)(x,{to:y(`/packages`,n,t.search),"data-testid":`agents-packages-link`,className:`text-primary underline`,children:`Manage packages and reusable launch setups`}),(w.data?.broken??[]).map(e=>(0,z.jsxs)(`p`,{role:`alert`,className:`text-destructive`,children:[e.path,`: `,e.error]},e.path)),(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,z.jsx)(S,{className:`min-w-[180px] max-w-lg flex-1`,"aria-label":`Find an agent`,placeholder:`Find an agent by name or purpose…`,value:d,onChange:e=>b(e.target.value,{replace:!0})}),d&&(0,z.jsx)(i,{variant:`ghost`,onClick:()=>b(``),children:`Clear`})]}),(0,z.jsxs)(`div`,{className:`space-y-2`,children:[w.isLoading&&(0,z.jsx)(`p`,{role:`status`,"data-testid":`page-loading`,children:`Loading agents…`}),Y.map(e=>(0,z.jsxs)(`button`,{type:`button`,"data-testid":`agent-row`,"data-agent-id":e.id,onClick:()=>N(e.id),className:`w-full text-left border-b border-outline-variant p-4 hover:bg-surface-low`,children:[(0,z.jsx)(`span`,{className:`block wrap-break-word text-base font-medium`,children:e.name}),(0,z.jsxs)(`span`,{className:`mt-1 block break-all text-xs text-muted-foreground`,children:[e.id,` · `,e.source]}),(0,z.jsx)(`p`,{className:`mt-2 wrap-break-word text-sm leading-relaxed text-muted-foreground`,children:e.description})]},e.id)),!w.isLoading&&!Y.length&&(0,z.jsx)(`p`,{"data-testid":`page-empty`,className:`text-sm text-muted-foreground`,children:d?`No agents match this search. Try another name or clear the filter.`:`Create an agent or import specialists from Packages.`})]}),(0,z.jsx)(h,{open:!!M,onOpenChange:e=>!e&&P(),children:(0,z.jsxs)(p,{defaultWidth:860,resizeKey:`agents`,"data-testid":`agent-detail-sheet`,children:[(0,z.jsx)(_,{children:(0,z.jsx)(g,{children:F.data?.name??`Agent profile`})}),(0,z.jsx)(f,{children:F.error?(0,z.jsx)(D,{message:F.error.message,onRetry:()=>void F.refetch()}):F.data?(0,z.jsxs)(`div`,{className:`space-y-4`,children:[(0,z.jsx)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:F.data.description}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 border-b border-outline-variant pb-3`,"data-testid":`agent-actions`,children:[(0,z.jsx)(i,{size:`sm`,"data-testid":`agent-launch`,onClick:()=>F.data&&G({name:`agent-launch`,packages:[],backend:F.data.fields.tools===void 0?`codex`:`claude`,tool:`apm`,cwd:``,agent:F.data.id,prompt:``}),children:`Launch agent`}),(0,z.jsx)(i,{size:`sm`,"data-testid":`agent-edit`,variant:`ghost`,onClick:async()=>{J.reset();let e=await F.refetch();e.data&&B(e.data)},children:`Edit agent`}),(0,z.jsx)(i,{size:`sm`,"data-testid":`agent-delete`,variant:`ghost`,className:`ml-auto text-error`,onClick:()=>{q.reset(),U(!0)},disabled:q.isPending,children:`Delete`})]}),q.error&&(0,z.jsx)(`p`,{"data-testid":`agent-delete-error`,role:`alert`,className:`text-destructive`,children:q.error.message}),(0,z.jsxs)(`dl`,{className:`grid grid-cols-2 gap-4 text-sm`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Model`}),(0,z.jsx)(`dd`,{className:`mt-1 wrap-break-word`,children:F.data.fields.model??`Coding-agent default`})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Tools`}),(0,z.jsx)(`dd`,{className:`mt-1`,children:F.data.fields.tools===void 0?`Coding-agent default`:`Defined by this agent; requires Claude`})]})]}),(0,z.jsx)(`h4`,{className:`text-sm font-medium`,children:`Instructions`}),(0,z.jsx)(v,{path:`agent.agent.md`,mode:s,onModeChange:l,value:F.data.raw,readOnly:!0,layout:`page`,hideFrontmatter:!0,pageTitle:F.data.name,testId:`agent-content`}),(0,z.jsxs)(`details`,{className:`border-t border-outline-variant pt-3 text-sm`,children:[(0,z.jsx)(`summary`,{className:`cursor-pointer text-muted-foreground`,children:`Source and configuration`}),(0,z.jsxs)(`p`,{className:`my-3 text-xs text-muted-foreground break-all`,children:[F.data.id,` · `,F.data.source,` definition`]}),(0,z.jsx)(`pre`,{"data-testid":`agent-fields`,className:`max-h-80 overflow-auto rounded bg-background p-3 text-xs`,children:JSON.stringify(F.data.fields,null,2)}),(0,z.jsxs)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:[`To use this agent in a flow, set `,(0,z.jsxs)(`code`,{children:[`"agent": "`,F.data.id,`"`]}),` on its agent node.`]})]})]}):(0,z.jsx)(`p`,{children:`Loading...`})})]})}),(0,z.jsx)(E,{open:H,title:`Delete ${F.data?.name??`agent`}?`,description:`This permanently deletes the agent definition "${M}". Other agents and package resources are kept. Flows referencing this agent will need another profile.`,isPending:q.isPending,onCancel:()=>!q.isPending&&U(!1),onConfirm:()=>{M&&q.mutate(M,{onError:()=>U(!1)})}}),W&&(0,z.jsx)(T,{initial:W,onClose:()=>G(void 0)}),(0,z.jsx)(m,{open:I,onOpenChange:e=>!K.isPending&&L(e),children:I&&(0,z.jsx)(V,{pending:K.isPending,error:K.error?.message,onSave:(e,t)=>K.mutate({id:e,content:t})})}),(0,z.jsx)(m,{open:!!R,onOpenChange:e=>!e&&!J.isPending&&B(void 0),children:R&&(0,z.jsx)(V,{agent:R,pending:J.isPending,error:J.error?.message,onSave:(e,t)=>J.mutate({profile:R,content:t})},R.id)})]})}export{H as default};
34
+ `}${t}`}function L(e){let t=e.tools;if(t===void 0)return[];if(typeof t==`string`)return t.split(/[\s,]+/).filter(Boolean).map(e=>({name:e,allowed:!0}));if(Array.isArray(t)&&t.every(e=>typeof e==`string`))return t.map(e=>({name:e,allowed:!0}));if(t&&typeof t==`object`&&!Array.isArray(t))return Object.entries(t).map(([e,t])=>{if(typeof t!=`boolean`)throw Error(`Tool "${e}" must be true or false.`);return{name:e,allowed:t}});throw Error(`Tools must be a mapping of names to true/false, a list, or a string.`)}function R(e,t){let n=P(e);C(n.document.get(`tools`,!0))||n.document.set(`tools`,{});let r=n.document.get(`tools`,!0);if(C(r))for(let{name:e}of L(n.fields))t.some(t=>t.name===e)||n.document.deleteIn([`tools`,e]);for(let e of t)n.document.setIn([`tools`,e.name],e.allowed);return`${n.bom}---${n.newline}${n.document.toString().trimEnd().replace(/\n/g,n.newline)}${n.newline}---${n.newline}${n.body}`}var z=n();function B(e){return L(e).map(e=>({...e,key:crypto.randomUUID()}))}function V({agent:e,pending:t,error:n,onSave:r}){let[i,a]=(0,j.useState)(e?.id??``),[c,u]=(0,j.useState)(e?.raw??M.specialist),[f,p]=(0,j.useState)(`fields`),[m,h]=(0,j.useState)(()=>e?B(e.fields):[]),[g,_]=(0,j.useState)(),v=(0,j.useMemo)(()=>{try{return{value:P(c),error:void 0}}catch(e){return{value:void 0,error:e.message}}},[c]),b=v.value?.fields,C;m.some(e=>!e.name.trim())?C=`Enter a name for every tool.`:new Set(m.map(e=>e.name.trim())).size!==m.length&&(C=`Tool names must be unique.`);let w=e?`Save changes`:`Create agent`;function T(e){h(e),e.every(e=>e.name.trim())&&new Set(e.map(e=>e.name.trim())).size===e.length&&u(R(c,e.map(e=>({...e,name:e.name.trim()}))))}function E(){if(_(void 0),f===`fields`){if(C)return;p(`source`)}else try{let e=P(c);for(let t of[`name`,`description`,`model`,`color`])if(e.fields[t]!==void 0&&typeof e.fields[t]!=`string`)throw Error(`${t} must be a string to edit it in the form.`);h(B(e.fields)),p(`fields`)}catch(e){_(e.message)}}return(0,z.jsxs)(d,{className:`max-w-3xl max-h-[90vh] overflow-y-auto`,children:[(0,z.jsx)(x,{children:(0,z.jsx)(l,{children:e?`Edit ${e.name}`:`New shared agent`})}),(0,z.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e.preventDefault(),r(i,c)},children:[(0,z.jsxs)(`fieldset`,{disabled:t,className:`space-y-4`,children:[!e&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(s,{htmlFor:`agent-template`,children:`Starting template`}),(0,z.jsxs)(`select`,{id:`agent-template`,"data-testid":`agent-template`,className:`w-full border rounded-xs p-2 bg-surface`,defaultValue:`specialist`,onChange:e=>{let t=M[e.target.value];u(t),h(B(P(t).fields)),_(void 0)},children:[(0,z.jsx)(`option`,{value:`specialist`,children:`General specialist`}),(0,z.jsx)(`option`,{value:`reviewer`,children:`Reviewer`}),(0,z.jsx)(`option`,{value:`builder`,children:`Builder`})]})]}),(0,z.jsx)(s,{htmlFor:`agent-id`,children:`Agent ID`}),(0,z.jsx)(S,{id:`agent-id`,"data-testid":`agent-id-input`,value:i,disabled:!!e,onChange:e=>a(e.target.value),placeholder:`security-review`}),(0,z.jsx)(o,{type:`button`,variant:`outline`,"data-testid":`agent-editor-mode`,onClick:E,disabled:f===`fields`&&!!C,children:f===`fields`?`Edit YAML + Markdown`:`Edit fields`}),f===`source`?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(s,{htmlFor:`agent-definition`,children:`YAML configuration + Markdown instructions`}),(0,z.jsx)(y,{id:`agent-definition`,testId:`agent-content-input`,path:`agent.agent.md`,readOnly:t,height:400,value:c,onChange:e=>{u(e),_(void 0)}})]}):b&&(0,z.jsxs)(z.Fragment,{children:[[[`name`,`Name`],[`description`,`Description`],[`model`,`Model (optional)`],[`color`,`Color (optional)`]].map(([e,t])=>(0,z.jsxs)(`div`,{className:`space-y-1`,children:[(0,z.jsx)(s,{htmlFor:`agent-${e}`,children:t}),(0,z.jsx)(S,{id:`agent-${e}`,"data-testid":`agent-${e}-input`,value:typeof b[e]==`string`?b[e]:``,onChange:t=>u(F(c,e,t.target.value||(e===`description`?``:void 0)))})]},e)),(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,z.jsx)(`input`,{"data-testid":`agent-custom-tools`,type:`checkbox`,checked:b.tools!==void 0,onChange:e=>{h([]),u(F(c,`tools`,e.target.checked?{}:void 0))}}),` `,`Customize tool access`]}),(0,z.jsx)(`p`,{className:`text-xs text-outline`,children:`Use the tool names supported by your chosen backend. With customization off, the backend's default tools apply. An empty custom list allows no tools.`}),b.tools!==void 0&&(0,z.jsxs)(z.Fragment,{children:[m.map((e,t)=>(0,z.jsxs)(`div`,{"data-testid":`agent-tool-row`,className:`flex items-center gap-2`,children:[(0,z.jsx)(S,{"data-testid":`agent-tool-name`,"aria-label":`Tool ${t+1} name`,value:e.name,list:`agent-tool-suggestions`,onChange:e=>T(m.map((n,r)=>r===t?{...n,name:e.target.value}:n))}),(0,z.jsxs)(`label`,{className:`flex items-center gap-1 text-sm`,children:[(0,z.jsx)(`input`,{"data-testid":`agent-tool-allowed`,type:`checkbox`,checked:e.allowed,onChange:e=>T(m.map((n,r)=>r===t?{...n,allowed:e.target.checked}:n))}),` `,`Allowed`]}),(0,z.jsx)(o,{"data-testid":`agent-tool-remove`,type:`button`,variant:`outline`,onClick:()=>T(m.filter((e,n)=>n!==t)),children:`Remove`})]},e.key)),(0,z.jsx)(`datalist`,{id:`agent-tool-suggestions`,children:[`Read`,`Grep`,`Glob`,`Edit`,`Write`,`Bash`].map(e=>(0,z.jsx)(`option`,{value:e},e))}),(0,z.jsx)(o,{"data-testid":`agent-tool-add`,type:`button`,variant:`outline`,onClick:()=>T([...m,{key:crypto.randomUUID(),name:``,allowed:!0}]),children:`Add tool`})]})]}),(0,z.jsx)(s,{htmlFor:`agent-instructions`,children:`Instructions`}),(0,z.jsx)(y,{id:`agent-instructions`,testId:`agent-instructions-input`,path:`instructions.md`,readOnly:t,height:240,value:v.value?.body??``,onChange:e=>u(I(c,e))}),(0,z.jsx)(`p`,{className:`text-xs text-outline`,children:`Use YAML + Markdown to edit handoffs and additional configuration. Custom fields are preserved.`})]})]}),(n||v.error||g||f===`fields`&&C)&&(0,z.jsx)(`p`,{"data-testid":`agent-editor-error`,role:`alert`,className:`text-destructive`,children:n||v.error||g||C}),(0,z.jsx)(o,{"data-testid":`agent-submit`,type:`submit`,disabled:t||!i.trim()||!c.trim()||!!v.error||f===`fields`&&!!C,children:t?`Saving...`:w})]})]})}function H({embedded:e=!1}){let t=u(),n=new URLSearchParams(t.search).get(`project`)??`all`,[s,l]=A(`editorMode`,`read`,[`read`,`edit`,`split`]),[d,x]=A(`agentQuery`,``),C=r(),w=i({queryKey:[`agents`],queryFn:()=>c.agents.list()}),{selectedId:M,openDetail:N,closeDetail:P}=k(e?`/packages/agents`:`/agents`,`agentId`),F=i({queryKey:[`agent`,M],queryFn:()=>c.agents.get(M),enabled:!!M}),[I,L]=(0,j.useState)(!1),[R,B]=(0,j.useState)(),[H,U]=(0,j.useState)(!1),[W,G]=(0,j.useState)(),K=a({mutationFn:c.agents.create,onSuccess:()=>{C.invalidateQueries({queryKey:[`agents`]}),L(!1)}}),q=a({mutationFn:c.agents.delete,onSuccess:()=>{U(!1),P(),C.invalidateQueries({queryKey:[`agents`]}),C.invalidateQueries({queryKey:[`agent-packages`]}),C.invalidateQueries({queryKey:[`agent`]})}}),J=a({mutationFn:({profile:e,content:t})=>c.agents.update(e.id,{content:t,expectedRaw:e.raw,expectedPath:e.path}),onSuccess:e=>{C.setQueryData([`agent`,e.id],e),C.invalidateQueries({queryKey:[`agents`]}),C.invalidateQueries({queryKey:[`agent-packages`]}),B(void 0)}});if(w.error)return(0,z.jsx)(D,{message:w.error.message,onRetry:()=>void w.refetch()});let Y=(w.data?.agents??[]).filter(e=>`${e.name} ${e.id} ${e.description}`.toLowerCase().includes(d.toLowerCase()));return(0,z.jsxs)(`div`,{className:`space-y-5`,children:[e?(0,z.jsxs)(`div`,{className:`flex flex-wrap justify-between gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h2`,{className:`font-medium`,children:`Agent definitions`}),(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Manage specialist instructions, models and tools. Add them to APM packages for reuse.`})]}),(0,z.jsx)(o,{"data-testid":`new-agent-button`,onClick:()=>{K.reset(),L(!0)},children:`New agent`})]}):(0,z.jsx)(O,{title:`Agents`,meta:`${w.data?.agents.length??0} shared profiles`,action:(0,z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,z.jsx)(o,{"data-testid":`new-agent-button`,onClick:()=>{K.reset(),L(!0)},children:`New agent`})})}),(0,z.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Shared specialist definitions for every connected coding agent.`,` `,(0,z.jsx)(`a`,{className:`text-primary underline`,href:`https://microsoft.github.io/apm/producer/author-primitives/instructions-and-agents/`,target:`_blank`,rel:`noreferrer`,children:`APM agent format`})]}),!e&&(0,z.jsx)(m,{to:b(`/packages`,n,t.search),"data-testid":`agents-packages-link`,className:`text-primary underline`,children:`Manage packages and reusable launch setups`}),(w.data?.broken??[]).map(e=>(0,z.jsxs)(`p`,{role:`alert`,className:`text-destructive`,children:[e.path,`: `,e.error]},e.path)),(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,z.jsx)(S,{className:`min-w-[180px] max-w-lg flex-1`,"aria-label":`Find an agent`,placeholder:`Find an agent by name or purpose…`,value:d,onChange:e=>x(e.target.value,{replace:!0})}),d&&(0,z.jsx)(o,{variant:`ghost`,onClick:()=>x(``),children:`Clear`})]}),(0,z.jsxs)(`div`,{className:`space-y-2`,children:[w.isLoading&&(0,z.jsx)(`p`,{role:`status`,"data-testid":`page-loading`,children:`Loading agents…`}),Y.map(e=>(0,z.jsxs)(`button`,{type:`button`,"data-testid":`agent-row`,"data-agent-id":e.id,onClick:()=>N(e.id),className:`w-full text-left border-b border-outline-variant p-4 hover:bg-surface-low`,children:[(0,z.jsx)(`span`,{className:`block wrap-break-word text-base font-medium`,children:e.name}),(0,z.jsxs)(`span`,{className:`mt-1 block break-all text-xs text-muted-foreground`,children:[e.id,` · `,e.source]}),(0,z.jsx)(`p`,{className:`mt-2 wrap-break-word text-sm leading-relaxed text-muted-foreground`,children:e.description})]},e.id)),!w.isLoading&&!Y.length&&(0,z.jsx)(`p`,{"data-testid":`page-empty`,className:`text-sm text-muted-foreground`,children:d?`No agents match this search. Try another name or clear the filter.`:`Create an agent or import specialists from Packages.`})]}),(0,z.jsx)(g,{open:!!M,onOpenChange:e=>!e&&P(),children:(0,z.jsxs)(p,{defaultWidth:860,resizeKey:`agents`,"data-testid":`agent-detail-sheet`,children:[(0,z.jsx)(v,{children:(0,z.jsx)(_,{children:F.data?.name??`Agent profile`})}),(0,z.jsx)(f,{children:F.error?(0,z.jsx)(D,{message:F.error.message,onRetry:()=>void F.refetch()}):F.data?(0,z.jsxs)(`div`,{className:`space-y-4`,children:[(0,z.jsx)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:F.data.description}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 border-b border-outline-variant pb-3`,"data-testid":`agent-actions`,children:[(0,z.jsx)(o,{size:`sm`,"data-testid":`agent-launch`,onClick:()=>F.data&&G({name:`agent-launch`,packages:[],backend:F.data.fields.tools===void 0?`codex`:`claude`,tool:`apm`,cwd:``,agent:F.data.id,prompt:``}),children:`Launch agent`}),(0,z.jsx)(o,{size:`sm`,"data-testid":`agent-edit`,variant:`ghost`,onClick:async()=>{J.reset();let e=await F.refetch();e.data&&B(e.data)},children:`Edit agent`}),(0,z.jsx)(o,{size:`sm`,"data-testid":`agent-delete`,variant:`ghost`,className:`ml-auto text-error`,onClick:()=>{q.reset(),U(!0)},disabled:q.isPending,children:`Delete`})]}),q.error&&(0,z.jsx)(`p`,{"data-testid":`agent-delete-error`,role:`alert`,className:`text-destructive`,children:q.error.message}),(0,z.jsxs)(`dl`,{className:`grid grid-cols-2 gap-4 text-sm`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Model`}),(0,z.jsx)(`dd`,{className:`mt-1 wrap-break-word`,children:F.data.fields.model??`Coding-agent default`})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Tools`}),(0,z.jsx)(`dd`,{className:`mt-1`,children:F.data.fields.tools===void 0?`Coding-agent default`:`Defined by this agent; requires Claude`})]})]}),(0,z.jsx)(`h4`,{className:`text-sm font-medium`,children:`Instructions`}),(0,z.jsx)(y,{path:`agent.agent.md`,mode:s,onModeChange:l,value:F.data.raw,readOnly:!0,layout:`page`,hideFrontmatter:!0,pageTitle:F.data.name,testId:`agent-content`}),(0,z.jsxs)(`details`,{className:`border-t border-outline-variant pt-3 text-sm`,children:[(0,z.jsx)(`summary`,{className:`cursor-pointer text-muted-foreground`,children:`Source and configuration`}),(0,z.jsxs)(`p`,{className:`my-3 text-xs text-muted-foreground break-all`,children:[F.data.id,` · `,F.data.source,` definition`]}),(0,z.jsx)(`pre`,{"data-testid":`agent-fields`,className:`max-h-80 overflow-auto rounded bg-background p-3 text-xs`,children:JSON.stringify(F.data.fields,null,2)}),(0,z.jsxs)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:[`To use this agent in a flow, set `,(0,z.jsxs)(`code`,{children:[`"agent": "`,F.data.id,`"`]}),` on its agent node.`]})]})]}):(0,z.jsx)(`p`,{children:`Loading...`})})]})}),(0,z.jsx)(E,{open:H,title:`Delete ${F.data?.name??`agent`}?`,description:`This permanently deletes the agent definition "${M}". Other agents and package resources are kept. Flows referencing this agent will need another profile.`,isPending:q.isPending,onCancel:()=>!q.isPending&&U(!1),onConfirm:()=>{M&&q.mutate(M,{onError:()=>U(!1)})}}),W&&(0,z.jsx)(T,{initial:W,onClose:()=>G(void 0)}),(0,z.jsx)(h,{open:I,onOpenChange:e=>!K.isPending&&L(e),children:I&&(0,z.jsx)(V,{pending:K.isPending,error:K.error?.message,onSave:(e,t)=>K.mutate({id:e,content:t})})}),(0,z.jsx)(h,{open:!!R,onOpenChange:e=>!e&&!J.isPending&&B(void 0),children:R&&(0,z.jsx)(V,{agent:R,pending:J.isPending,error:J.error?.message,onSave:(e,t)=>J.mutate({profile:R,content:t})},R.id)})]})}export{H as default};
@@ -0,0 +1,2 @@
1
+ import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{n as r}from"./QueryClientProvider-DlPztvhd.js";import{t as i}from"./useMutation-HX90wI4L.js";import{t as a}from"./button-BHKbOsmj.js";import{n as o}from"./client-BwhkVepQ.js";import{An as s,Nt as c,On as l,Pt as u,f as d,m as f,p}from"./index-CMRGRbC9.js";import{t as m}from"./ViewHeader-DHM9SSkD.js";import{c as h}from"./live-sessions-D07BClP7.js";import{i as g,n as _}from"./terminal-links-B3ce99i1.js";var v=e(t(),1),y=n();function b({session:e}){let t=l(),[n]=s(),{terminals:r}=u(),i=_(r,e.id);return(0,y.jsxs)(`article`,{"data-testid":`attention-session-${e.id}`,className:`rounded-lg border border-border bg-surface p-5 space-y-4`,children:[(0,y.jsxs)(`p`,{className:`text-xs text-outline`,children:[`Question · `,e.agent,` · `,e.host??`Local`,` · Observed session`]}),(0,y.jsx)(`h2`,{className:`text-base font-medium`,children:e.name??`Coding session`}),(0,y.jsx)(`p`,{className:`text-sm text-outline`,children:`Waiting for your answer. Answer in the original session.`}),(0,y.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[i&&(0,y.jsx)(a,{variant:`outline`,onClick:()=>t(h(g(i.id),n.get(`project`))),children:`Open terminal`}),(0,y.jsx)(a,{variant:`outline`,onClick:()=>{let r=new URLSearchParams(n);r.set(`session`,e.id),t({pathname:`/sessions`,search:r.toString()})},children:`View session`})]})]})}function x({request:e}){let[t,n]=(0,v.useState)(``),[u,d]=(0,v.useState)([]),f=r(),p=l(),[m]=s(),h=i({mutationFn:t=>o.humanRequests.respond(e.id,e.version,t),onSettled:()=>f.invalidateQueries({queryKey:[`human-requests`]})}),g=i({mutationFn:()=>o.humanRequests.cancel(e.id,e.version),onSettled:()=>f.invalidateQueries({queryKey:[`human-requests`]})}),_=e.status===`pending`,b=e.input.action?.input,x=b?.item&&typeof b.item==`object`?b.item:void 0,S=typeof b?.threadId==`string`,C=S?{...Object.fromEntries(Object.entries(b??{}).filter(([e])=>![`threadId`,`turnId`,`itemId`,`startedAtMs`,`item`,`availableDecisions`,`proposedExecpolicyAmendment`,`commandActions`,`kind`].includes(e))),...x?.changes?{changes:x.changes}:{}}:b;return(0,y.jsxs)(`article`,{"data-testid":`attention-request-${e.id}`,className:`rounded-lg border border-border bg-surface p-5 space-y-4`,children:[(0,y.jsxs)(`div`,{className:`flex flex-wrap justify-between gap-2 text-xs text-outline`,children:[(0,y.jsxs)(`span`,{children:[e.input.kind===`question`?`Question`:`Approval`,` ·`,` `,e.input.origin.backend,` ·`,` `,e.input.rule_binding||e.input.rule_bindings?.length?`ORC rule`:`Agent request`]}),(0,y.jsx)(`span`,{children:_?`Waiting for you`:e.status===`unavailable`?`Agent unavailable`:`Answered · waiting for agent delivery`})]}),(0,y.jsx)(`h2`,{className:`text-base font-medium whitespace-pre-wrap`,children:e.input.prompt}),(0,y.jsxs)(`p`,{className:`text-xs text-outline break-all`,children:[e.input.origin.session_title??`Session ${e.input.origin.session_id}`,e.input.origin.execution_host!==void 0&&` · ${e.input.origin.execution_host??`Local`}`]}),e.input.origin.chat_thread_id&&(0,y.jsx)(a,{"data-testid":`attention-open-chat`,variant:`outline`,onClick:()=>{let t=new URLSearchParams(m);t.set(`chat`,`open`),t.set(`chatThread`,e.input.origin.chat_thread_id??``),p({search:t.toString()})},children:`Open chat`}),e.input.action&&(0,y.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[(0,y.jsxs)(`p`,{children:[`Host: `,(0,y.jsx)(`strong`,{children:e.input.action.host}),` · Folder: `,e.input.action.cwd]}),(0,y.jsxs)(`pre`,{"data-testid":`attention-action`,className:`whitespace-pre-wrap break-all rounded-md bg-background p-3 text-xs`,children:[e.input.action.tool,`
2
+ `,JSON.stringify(C&&Object.keys(C).length?C:b,null,2)]}),S&&(0,y.jsxs)(`details`,{className:`text-xs text-outline`,children:[(0,y.jsx)(`summary`,{className:`cursor-pointer`,children:`Full request details`}),(0,y.jsx)(`pre`,{className:`whitespace-pre-wrap break-all mt-2`,children:JSON.stringify(b,null,2)})]}),(0,y.jsx)(`p`,{className:`text-outline`,children:`Your approval lets this agent continue with its existing permissions.`})]}),_&&e.input.kind===`question`&&(0,y.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),h.mutate({kind:`question`,answer:t,...u.length?{selected_choices:u}:{}})},children:[(0,y.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.input.choices.map(r=>(0,y.jsxs)(a,{variant:(e.input.multi_select?u.includes(r):t===r)?`default`:`outline`,type:`button`,className:`h-auto min-h-9 flex-col items-start whitespace-normal text-left`,disabled:h.isPending,"data-testid":`attention-choice-${r}`,onClick:()=>{if(e.input.multi_select){let e=u.includes(r)?u.filter(e=>e!==r):[...u,r];d(e),n(e.join(`, `))}else n(r)},children:[(0,y.jsx)(`span`,{children:r}),Object.keys(e.input.choice_descriptions).includes(r)&&e.input.choice_descriptions[r]&&(0,y.jsx)(`span`,{className:`text-xs font-normal opacity-75 max-w-sm`,children:e.input.choice_descriptions[r]})]},r))}),(0,y.jsxs)(`label`,{htmlFor:`answer-${e.id}`,className:`block text-sm space-y-2`,children:[(0,y.jsx)(`span`,{children:`Your answer`}),(0,y.jsx)(c,{id:`answer-${e.id}`,"data-testid":`attention-answer`,value:t,onChange:e=>{n(e.target.value),d([])},maxLength:16e3,disabled:h.isPending})]}),(0,y.jsx)(a,{"data-testid":`attention-send`,type:`submit`,disabled:!t.trim()||h.isPending,children:h.isPending?`Sending…`:`Send answer`})]}),_&&e.input.kind===`approval`&&(0,y.jsxs)(`div`,{className:`flex gap-3`,children:[(0,y.jsx)(a,{"data-testid":`attention-approve`,disabled:h.isPending,onClick:()=>h.mutate({kind:`approval`,approved:!0}),children:`Approve`}),(0,y.jsx)(a,{"data-testid":`attention-deny`,variant:`outline`,disabled:h.isPending,onClick:()=>h.mutate({kind:`approval`,approved:!1}),children:`Deny`})]}),e.response&&(0,y.jsx)(`p`,{"data-testid":`attention-response`,className:`text-sm whitespace-pre-wrap`,children:e.response.kind===`question`?e.response.answer:e.response.approved?`Approved`:`Denied`}),e.delivery_error&&(0,y.jsx)(`p`,{role:`status`,className:`text-sm text-error`,children:e.delivery_error}),(_||e.status===`unavailable`)&&(0,y.jsx)(a,{"data-testid":`attention-cancel`,variant:`ghost`,disabled:h.isPending||g.isPending,onClick:()=>g.mutate(),children:_?`Cancel request`:`Dismiss`}),g.error&&(0,y.jsx)(`p`,{role:`alert`,children:g.error.message}),h.error&&(0,y.jsx)(`p`,{role:`alert`,"data-testid":`attention-error`,className:`text-sm text-destructive`,children:h.error.message})]})}function S(){let e=f(),t=d(),n=p(),r=l(),[i]=s();return(0,y.jsxs)(`div`,{"data-testid":`attention-view`,className:`max-w-4xl`,children:[(0,y.jsx)(m,{title:`Attention needed`,meta:`Questions and approvals from your agents`}),(0,y.jsx)(`p`,{className:`mb-4 text-sm text-outline`,children:`Live Codex questions can also appear as session notices. Direct responses require an ORC connection or a supported hook; ACPX CLI does not expose pending approvals to ORC.`}),e.isLoading&&(0,y.jsx)(`p`,{role:`status`,children:`Loading requests…`}),e.error&&(0,y.jsx)(`p`,{role:`alert`,children:e.error.message}),t.error&&(0,y.jsxs)(`p`,{role:`alert`,children:[`Could not check waiting sessions: `,t.error.message]}),n.error&&(0,y.jsxs)(`p`,{role:`alert`,children:[`Could not check waiting chats: `,n.error.message]}),e.data?.length===0&&!t.isLoading&&!t.error&&!n.isLoading&&!n.error&&t.data.length===0&&n.data.length===0&&(0,y.jsx)(`p`,{"data-testid":`attention-empty`,className:`text-outline`,children:`Nothing needs your attention.`}),e.data?.length===100&&(0,y.jsx)(`p`,{className:`text-sm text-outline mb-4`,children:`Showing the first 100 requests, with pending requests first. Resolving or dismissing entries reveals more.`}),(0,y.jsxs)(`div`,{className:`space-y-4`,children:[n.data.map(e=>(0,y.jsxs)(`article`,{"data-testid":`attention-chat-${e.thread_id}`,className:`rounded-lg border border-border bg-surface p-5 space-y-4`,children:[(0,y.jsxs)(`p`,{className:`text-xs text-outline`,children:[e.kind===`question`?`Question`:`Approval`,` · `,e.agent,` ·`,` `,e.host??`Local`,` · Chat`]}),(0,y.jsx)(`h2`,{className:`text-base font-medium`,children:e.title}),(0,y.jsx)(`p`,{className:`text-sm text-outline`,children:`Waiting for your response in chat.`}),(0,y.jsx)(a,{variant:`outline`,onClick:()=>{let t=new URLSearchParams(i);t.set(`chat`,`open`),t.set(`chatThread`,e.thread_id),r({search:t.toString()})},children:`Open chat`})]},`${e.thread_id}:${e.request_key}`)),t.data.map(e=>(0,y.jsx)(b,{session:e},e.id)),e.data?.map(e=>(0,y.jsx)(x,{request:e},e.id))]})]})}export{S as default};
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{t as r}from"./scroll-area-Alw_ieLV.js";import{t as i}from"./chevron-down-D2sszSv3.js";import{t as a}from"./Markdown-CenDHcGi.js";import{G as o,K as s,U as c,W as l,X as u,Y as d,fn as f,l as p,st as m}from"./index-Ck-SDgTR.js";import{t as h}from"./ErrorState-B0KI2D4y.js";import{t as g}from"./ViewHeader-CX02p2eb.js";import{t as _}from"./useDetailRoute-1i4Z0-d5.js";import{t as v}from"./view-params-DNioxw0G.js";import{t as y}from"./EmptyState-YM4VSLR9.js";import{t as b}from"./Pager-CMsNCI1_.js";import{i as x,r as S}from"./useSessions-Bx-Bw75y.js";import{a as C,i as w,n as T,o as E,r as D,t as O}from"./table-DC8IBMHg.js";import{t as k}from"./useProjectScope-C7yZQa4i.js";var A=e(t(),1),j=n(),M={file:`text-outline`,task:`text-outline`,decision:`text-outline`,error:`text-error`,git:`text-outline`,rule:`text-outline`,plan:`text-outline`},N=`text-outline`;function P(e){return M[e]??N}function F({sessionId:e,open:t,onClose:n}){let{data:i,isLoading:f,error:p,refetch:g}=x(e??``);return(0,j.jsx)(l,{open:t,onOpenChange:e=>!e&&n(),children:(0,j.jsxs)(s,{side:`right`,defaultWidth:540,resizeKey:`sessions`,children:[(0,j.jsx)(d,{children:(0,j.jsx)(u,{children:f?`Loading...`:i?`${i.agent??`Session`} ${i.agent_version?`v${i.agent_version}`:``}`:`Session Detail`})}),(0,j.jsxs)(o,{children:[(0,j.jsx)(`p`,{className:`mb-4 text-sm text-outline`,children:`This audit record contains summaries and events. Open Sessions to read native agent conversations or resume them.`}),p?(0,j.jsx)(h,{message:p.message,onRetry:()=>g()}):f?(0,j.jsx)(`div`,{className:`space-y-4`,children:[...[,,,,]].map((e,t)=>(0,j.jsx)(c,{className:`h-8 w-full bg-surface-highest`},t))}):i?(0,j.jsxs)(`div`,{className:`space-y-6`,children:[i.summary&&(0,j.jsx)(`div`,{className:`font-body text-xs text-on-surface leading-relaxed`,children:(0,j.jsx)(a,{children:i.summary})}),(0,j.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-4`,children:[(0,j.jsx)(m,{label:`ID`,children:(0,j.jsx)(`span`,{className:`font-mono text-xs break-all`,children:i.id})}),(0,j.jsx)(m,{label:`Project ID`,children:i.project_id??`—`}),(0,j.jsx)(m,{label:`Job Run ID`,children:i.job_run_id??`—`}),(0,j.jsx)(m,{label:`Tokens Used`,children:i.tokens_used==null?`—`:i.tokens_used.toLocaleString()}),(0,j.jsx)(m,{label:`Created`,children:new Date(i.created_at).toLocaleString()})]}),i.events.length>0&&(0,j.jsxs)(`div`,{children:[(0,j.jsxs)(`div`,{className:`font-label text-xs font-medium text-outline mb-3`,children:[`Events (`,i.events.length,`)`]}),(0,j.jsx)(r,{className:`h-[300px]`,children:(0,j.jsx)(`div`,{className:`space-y-1`,children:[...i.events].sort((e,t)=>new Date(e.created_at).getTime()-new Date(t.created_at).getTime()).map(e=>(0,j.jsx)(I,{event:e},e.id))})})]}),i.snapshot&&(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:`font-label text-xs font-medium text-outline mb-3`,children:`Snapshot`}),(0,j.jsx)(r,{className:`h-[200px]`,children:(0,j.jsx)(`pre`,{className:`font-mono text-xs text-on-surface-variant whitespace-pre-wrap wrap-break-word bg-background border-l border-border p-3`,children:i.snapshot})})]})]}):(0,j.jsx)(`div`,{className:`font-body text-xs text-outline py-8 text-center`,children:`Session not found`})]})]})})}function I({event:e}){let[t,n]=(0,A.useState)(!1),r=e.data!=null;return(0,j.jsxs)(`div`,{className:`border-b border-border/65`,children:[(0,j.jsxs)(`button`,{type:`button`,className:`w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-surface-high transition-colors`,onClick:()=>r&&n(!t),"aria-expanded":r?t:void 0,children:[r?t?(0,j.jsx)(i,{size:10,className:`text-outline shrink-0`}):(0,j.jsx)(f,{size:10,className:`text-outline shrink-0`}):(0,j.jsx)(`span`,{className:`w-[10px] shrink-0`}),(0,j.jsx)(`span`,{className:`inline-flex items-center px-1.5 py-0.5 text-[10px] font-label font-medium ${P(e.type)}`,children:e.type}),(0,j.jsx)(`span`,{className:`flex-1 font-body text-xs text-outline truncate`,children:L(e.data)}),(0,j.jsx)(`span`,{className:`font-label text-[10px] text-outline shrink-0`,children:new Date(e.created_at).toLocaleTimeString()})]}),t&&r&&(0,j.jsx)(`div`,{className:`px-3 pb-2`,children:(0,j.jsx)(`pre`,{className:`font-mono text-xs text-on-surface-variant whitespace-pre-wrap wrap-break-word bg-background border-l border-border/65 p-2 max-h-48 overflow-auto`,children:JSON.stringify(e.data,null,2)})})]})}function L(e){if(e==null)return``;if(typeof e==`string`)return e;if(typeof e==`object`){let t=e;if(typeof t.path==`string`)return t.path;if(typeof t.content==`string`)return t.content.length>80?`${t.content.slice(0,80)}...`:t.content;if(typeof t.message==`string`)return t.message;if(typeof t.summary==`string`)return t.summary;let n=Object.keys(t);return n.length<=3?n.join(`, `):`${n.length} fields`}return String(e)}var R=25,z=`font-label text-xs font-medium text-outline`;function B({projectId:e}){let t=p(`sm`),[n,r]=v(`order`,`desc`,[`asc`,`desc`]),[i,a]=(0,A.useState)({order:n,page:0}),o=i.order===n?i.page:0,s=e=>a({order:n,page:e}),{selectedId:l,openDetail:u,closeDetail:d}=_(`/audit`,`sessionId`),{data:f,isLoading:m,error:g,refetch:x}=S({...e===`all`?{}:{project_id:e},limit:R,offset:o*R,order:n});if(g)return(0,j.jsx)(h,{message:g.message,onRetry:()=>x()});let k=f?.sessions??[],M=f?.total??0;return(0,j.jsxs)(`section`,{"data-testid":`logged-sessions`,children:[(0,j.jsx)(`div`,{className:`mb-4 flex justify-end`,children:(0,j.jsxs)(`select`,{"aria-label":`Sort audit by date`,"data-testid":`audit-date-sort`,value:n,onChange:e=>{s(0),r(e.target.value)},className:`min-h-11 rounded-md border border-control-border bg-background px-3 text-sm text-on-surface`,children:[(0,j.jsx)(`option`,{value:`desc`,children:`Created: newest first`}),(0,j.jsx)(`option`,{value:`asc`,children:`Created: oldest first`})]})}),m?(0,j.jsx)(`div`,{className:`space-y-2`,children:[...[,,,,,]].map((e,t)=>(0,j.jsx)(c,{className:`h-10 w-full bg-surface-highest`},t))}):k.length===0?(0,j.jsx)(y,{message:`No audit records`}):(0,j.jsxs)(`div`,{className:`min-w-0 overflow-hidden`,children:[t?(0,j.jsxs)(O,{children:[(0,j.jsx)(C,{children:(0,j.jsxs)(E,{className:`border-b border-border hover:bg-transparent`,children:[(0,j.jsx)(w,{className:z,children:`Agent`}),(0,j.jsx)(w,{className:`${z} w-24`,children:`Version`}),(0,j.jsx)(w,{className:z,children:`Summary`}),(0,j.jsx)(w,{className:`${z} w-24`,children:`Project`}),(0,j.jsx)(w,{className:`${z} w-28`,children:`Tokens Used`}),(0,j.jsx)(w,{className:`${z} w-36`,children:`Created`})]})}),(0,j.jsx)(T,{children:k.map(e=>(0,j.jsxs)(E,{"data-testid":`session-row`,"data-session-id":e.id,className:`border-b border-border/65 hover:bg-surface-high cursor-pointer`,onClick:()=>u(e.id),children:[(0,j.jsx)(D,{className:`font-label text-xs text-primary`,children:(0,j.jsx)(`button`,{type:`button`,className:`text-left font-medium hover:underline`,onClick:t=>{t.stopPropagation(),u(e.id)},children:e.agent??`Session`})}),(0,j.jsx)(D,{className:`font-label text-xs text-outline`,children:e.agent_version??`—`}),(0,j.jsx)(D,{className:`font-body text-xs text-on-surface-variant max-w-sm truncate`,children:e.summary??`—`}),(0,j.jsx)(D,{className:`font-label text-xs text-outline`,children:e.project_id?e.project_id.slice(-6):`—`}),(0,j.jsx)(D,{className:`font-label text-xs text-outline text-right`,children:e.tokens_used==null?`—`:e.tokens_used.toLocaleString()}),(0,j.jsx)(D,{className:`font-label text-xs text-outline`,children:new Date(e.created_at).toLocaleString()})]},e.id))})]}):(0,j.jsx)(`div`,{className:`divide-y divide-border`,children:k.map(e=>(0,j.jsxs)(`article`,{"data-testid":`session-row`,"data-session-id":e.id,className:`py-4 space-y-3`,children:[(0,j.jsx)(`button`,{type:`button`,className:`min-h-11 text-sm text-left font-medium text-primary wrap-break-word`,onClick:()=>u(e.id),children:e.agent??`Session`}),(0,j.jsx)(`p`,{className:`text-sm leading-relaxed text-on-surface wrap-break-word`,children:e.summary??`No summary recorded`}),(0,j.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-2 text-xs text-outline`,children:[(0,j.jsxs)(`span`,{children:[`Version `,e.agent_version??`—`]}),(0,j.jsxs)(`span`,{children:[e.tokens_used?.toLocaleString()??`—`,` tokens`]}),(0,j.jsx)(`span`,{children:e.project_id?`Project ${e.project_id.slice(-6)}`:`Unassigned`}),(0,j.jsx)(`span`,{children:new Date(e.created_at).toLocaleString()})]})]},e.id))}),(0,j.jsx)(b,{page:o,pageSize:R,total:M,onPage:s})]}),(0,j.jsx)(F,{sessionId:l,open:!!l,onClose:d})]})}function V({projectId:e}){let t=k(e);return(0,j.jsxs)(`div`,{children:[(0,j.jsx)(g,{title:`Audit`}),(0,j.jsx)(`p`,{className:`mb-4 text-sm text-outline`,children:`Recorded summaries and events. Open Sessions to read conversations or resume a coding agent.`}),(0,j.jsx)(B,{projectId:t},t)]})}export{V as default};
1
+ import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{t as r}from"./scroll-area-DMjOmHf5.js";import{t as i}from"./chevron-down-D2sszSv3.js";import{t as a}from"./Markdown-BYChkZ3Z.js";import{G as o,K as s,U as c,W as l,X as u,Y as d,l as f,mn as p,st as m}from"./index-CMRGRbC9.js";import{t as h}from"./ErrorState-BoQqdsym.js";import{t as g}from"./ViewHeader-DHM9SSkD.js";import{t as _}from"./useDetailRoute-C8xQeILG.js";import{t as v}from"./view-params-BqRwdnv0.js";import{t as y}from"./EmptyState-YM4VSLR9.js";import{t as b}from"./Pager-DQCWHQWA.js";import{i as x,r as S}from"./useSessions-C2GU4FkG.js";import{a as C,i as w,n as T,o as E,r as D,t as O}from"./table-ByS-sgsb.js";import{t as k}from"./useProjectScope-CZEfU9mq.js";var A=e(t(),1),j=n(),M={file:`text-outline`,task:`text-outline`,decision:`text-outline`,error:`text-error`,git:`text-outline`,rule:`text-outline`,plan:`text-outline`},N=`text-outline`;function P(e){return M[e]??N}function F({sessionId:e,open:t,onClose:n}){let{data:i,isLoading:f,error:p,refetch:g}=x(e??``);return(0,j.jsx)(l,{open:t,onOpenChange:e=>!e&&n(),children:(0,j.jsxs)(s,{side:`right`,defaultWidth:540,resizeKey:`sessions`,children:[(0,j.jsx)(d,{children:(0,j.jsx)(u,{children:f?`Loading...`:i?`${i.agent??`Session`} ${i.agent_version?`v${i.agent_version}`:``}`:`Session Detail`})}),(0,j.jsxs)(o,{children:[(0,j.jsx)(`p`,{className:`mb-4 text-sm text-outline`,children:`This audit record contains summaries and events. Open Sessions to read native agent conversations or resume them.`}),p?(0,j.jsx)(h,{message:p.message,onRetry:()=>g()}):f?(0,j.jsx)(`div`,{className:`space-y-4`,children:[...[,,,,]].map((e,t)=>(0,j.jsx)(c,{className:`h-8 w-full bg-surface-highest`},t))}):i?(0,j.jsxs)(`div`,{className:`space-y-6`,children:[i.summary&&(0,j.jsx)(`div`,{className:`font-body text-xs text-on-surface leading-relaxed`,children:(0,j.jsx)(a,{children:i.summary})}),(0,j.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-4`,children:[(0,j.jsx)(m,{label:`ID`,children:(0,j.jsx)(`span`,{className:`font-mono text-xs break-all`,children:i.id})}),(0,j.jsx)(m,{label:`Project ID`,children:i.project_id??`—`}),(0,j.jsx)(m,{label:`Job Run ID`,children:i.job_run_id??`—`}),(0,j.jsx)(m,{label:`Tokens Used`,children:i.tokens_used==null?`—`:i.tokens_used.toLocaleString()}),(0,j.jsx)(m,{label:`Created`,children:new Date(i.created_at).toLocaleString()})]}),i.events.length>0&&(0,j.jsxs)(`div`,{children:[(0,j.jsxs)(`div`,{className:`font-label text-xs font-medium text-outline mb-3`,children:[`Events (`,i.events.length,`)`]}),(0,j.jsx)(r,{className:`h-[300px]`,children:(0,j.jsx)(`div`,{className:`space-y-1`,children:[...i.events].sort((e,t)=>new Date(e.created_at).getTime()-new Date(t.created_at).getTime()).map(e=>(0,j.jsx)(I,{event:e},e.id))})})]}),i.snapshot&&(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:`font-label text-xs font-medium text-outline mb-3`,children:`Snapshot`}),(0,j.jsx)(r,{className:`h-[200px]`,children:(0,j.jsx)(`pre`,{className:`font-mono text-xs text-on-surface-variant whitespace-pre-wrap wrap-break-word bg-background border-l border-border p-3`,children:i.snapshot})})]})]}):(0,j.jsx)(`div`,{className:`font-body text-xs text-outline py-8 text-center`,children:`Session not found`})]})]})})}function I({event:e}){let[t,n]=(0,A.useState)(!1),r=e.data!=null;return(0,j.jsxs)(`div`,{className:`border-b border-border/65`,children:[(0,j.jsxs)(`button`,{type:`button`,className:`w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-surface-high transition-colors`,onClick:()=>r&&n(!t),"aria-expanded":r?t:void 0,children:[r?t?(0,j.jsx)(i,{size:10,className:`text-outline shrink-0`}):(0,j.jsx)(p,{size:10,className:`text-outline shrink-0`}):(0,j.jsx)(`span`,{className:`w-[10px] shrink-0`}),(0,j.jsx)(`span`,{className:`inline-flex items-center px-1.5 py-0.5 text-[10px] font-label font-medium ${P(e.type)}`,children:e.type}),(0,j.jsx)(`span`,{className:`flex-1 font-body text-xs text-outline truncate`,children:L(e.data)}),(0,j.jsx)(`span`,{className:`font-label text-[10px] text-outline shrink-0`,children:new Date(e.created_at).toLocaleTimeString()})]}),t&&r&&(0,j.jsx)(`div`,{className:`px-3 pb-2`,children:(0,j.jsx)(`pre`,{className:`font-mono text-xs text-on-surface-variant whitespace-pre-wrap wrap-break-word bg-background border-l border-border/65 p-2 max-h-48 overflow-auto`,children:JSON.stringify(e.data,null,2)})})]})}function L(e){if(e==null)return``;if(typeof e==`string`)return e;if(typeof e==`object`){let t=e;if(typeof t.path==`string`)return t.path;if(typeof t.content==`string`)return t.content.length>80?`${t.content.slice(0,80)}...`:t.content;if(typeof t.message==`string`)return t.message;if(typeof t.summary==`string`)return t.summary;let n=Object.keys(t);return n.length<=3?n.join(`, `):`${n.length} fields`}return String(e)}var R=25,z=`font-label text-xs font-medium text-outline`;function B({projectId:e}){let t=f(`sm`),[n,r]=v(`order`,`desc`,[`asc`,`desc`]),[i,a]=(0,A.useState)({order:n,page:0}),o=i.order===n?i.page:0,s=e=>a({order:n,page:e}),{selectedId:l,openDetail:u,closeDetail:d}=_(`/audit`,`sessionId`),{data:p,isLoading:m,error:g,refetch:x}=S({...e===`all`?{}:{project_id:e},limit:R,offset:o*R,order:n});if(g)return(0,j.jsx)(h,{message:g.message,onRetry:()=>x()});let k=p?.sessions??[],M=p?.total??0;return(0,j.jsxs)(`section`,{"data-testid":`logged-sessions`,children:[(0,j.jsx)(`div`,{className:`mb-4 flex justify-end`,children:(0,j.jsxs)(`select`,{"aria-label":`Sort audit by date`,"data-testid":`audit-date-sort`,value:n,onChange:e=>{s(0),r(e.target.value)},className:`min-h-11 rounded-md border border-control-border bg-background px-3 text-sm text-on-surface`,children:[(0,j.jsx)(`option`,{value:`desc`,children:`Created: newest first`}),(0,j.jsx)(`option`,{value:`asc`,children:`Created: oldest first`})]})}),m?(0,j.jsx)(`div`,{className:`space-y-2`,children:[...[,,,,,]].map((e,t)=>(0,j.jsx)(c,{className:`h-10 w-full bg-surface-highest`},t))}):k.length===0?(0,j.jsx)(y,{message:`No audit records`}):(0,j.jsxs)(`div`,{className:`min-w-0 overflow-hidden`,children:[t?(0,j.jsxs)(O,{children:[(0,j.jsx)(C,{children:(0,j.jsxs)(E,{className:`border-b border-border hover:bg-transparent`,children:[(0,j.jsx)(w,{className:z,children:`Agent`}),(0,j.jsx)(w,{className:`${z} w-24`,children:`Version`}),(0,j.jsx)(w,{className:z,children:`Summary`}),(0,j.jsx)(w,{className:`${z} w-24`,children:`Project`}),(0,j.jsx)(w,{className:`${z} w-28`,children:`Tokens Used`}),(0,j.jsx)(w,{className:`${z} w-36`,children:`Created`})]})}),(0,j.jsx)(T,{children:k.map(e=>(0,j.jsxs)(E,{"data-testid":`session-row`,"data-session-id":e.id,className:`border-b border-border/65 hover:bg-surface-high cursor-pointer`,onClick:()=>u(e.id),children:[(0,j.jsx)(D,{className:`font-label text-xs text-primary`,children:(0,j.jsx)(`button`,{type:`button`,className:`text-left font-medium hover:underline`,onClick:t=>{t.stopPropagation(),u(e.id)},children:e.agent??`Session`})}),(0,j.jsx)(D,{className:`font-label text-xs text-outline`,children:e.agent_version??`—`}),(0,j.jsx)(D,{className:`font-body text-xs text-on-surface-variant max-w-sm truncate`,children:e.summary??`—`}),(0,j.jsx)(D,{className:`font-label text-xs text-outline`,children:e.project_id?e.project_id.slice(-6):`—`}),(0,j.jsx)(D,{className:`font-label text-xs text-outline text-right`,children:e.tokens_used==null?`—`:e.tokens_used.toLocaleString()}),(0,j.jsx)(D,{className:`font-label text-xs text-outline`,children:new Date(e.created_at).toLocaleString()})]},e.id))})]}):(0,j.jsx)(`div`,{className:`divide-y divide-border`,children:k.map(e=>(0,j.jsxs)(`article`,{"data-testid":`session-row`,"data-session-id":e.id,className:`py-4 space-y-3`,children:[(0,j.jsx)(`button`,{type:`button`,className:`min-h-11 text-sm text-left font-medium text-primary wrap-break-word`,onClick:()=>u(e.id),children:e.agent??`Session`}),(0,j.jsx)(`p`,{className:`text-sm leading-relaxed text-on-surface wrap-break-word`,children:e.summary??`No summary recorded`}),(0,j.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-2 text-xs text-outline`,children:[(0,j.jsxs)(`span`,{children:[`Version `,e.agent_version??`—`]}),(0,j.jsxs)(`span`,{children:[e.tokens_used?.toLocaleString()??`—`,` tokens`]}),(0,j.jsx)(`span`,{children:e.project_id?`Project ${e.project_id.slice(-6)}`:`Unassigned`}),(0,j.jsx)(`span`,{children:new Date(e.created_at).toLocaleString()})]})]},e.id))}),(0,j.jsx)(b,{page:o,pageSize:R,total:M,onPage:s})]}),(0,j.jsx)(F,{sessionId:l,open:!!l,onClose:d})]})}function V({projectId:e}){let t=k(e);return(0,j.jsxs)(`div`,{children:[(0,j.jsx)(g,{title:`Audit`}),(0,j.jsx)(`p`,{className:`mb-4 text-sm text-outline`,children:`Recorded summaries and events. Open Sessions to read conversations or resume a coding agent.`}),(0,j.jsx)(B,{projectId:t},t)]})}export{V as default};
@@ -1 +1 @@
1
- import{t as e}from"./jsx-runtime-CVMpzJz9.js";import{t}from"./button-PNx108iL.js";import{At as n,Dt as r,Et as i,Ot as a,Tt as o,kt as s}from"./index-Ck-SDgTR.js";var c=e();function l({open:e,onConfirm:l,onCancel:u,title:d,description:f,confirmLabel:p=`Delete`,variant:m=`destructive`,isPending:h}){return(0,c.jsx)(o,{open:e,onOpenChange:e=>!e&&u(),children:(0,c.jsxs)(i,{className:`bg-surface border-surface-highest max-w-sm`,children:[(0,c.jsxs)(s,{children:[(0,c.jsx)(n,{className:`font-headline text-sm text-on-surface`,children:d}),(0,c.jsx)(r,{className:`font-body text-xs text-outline mt-2`,children:f})]}),(0,c.jsxs)(a,{className:`mt-4`,children:[(0,c.jsx)(t,{"data-testid":`confirm-dialog-cancel`,type:`button`,variant:`ghost`,size:`sm`,onClick:u,className:`font-label text-xs text-outline`,children:`Cancel`}),(0,c.jsx)(t,{"data-testid":`confirm-dialog-confirm`,type:`button`,size:`sm`,onClick:l,disabled:h,className:m===`destructive`?`font-label text-xs bg-error/15 text-error border border-error/30 hover:bg-error/25`:`font-label text-xs bg-tertiary/15 text-tertiary border border-tertiary/30 hover:bg-tertiary/25`,children:h?`...`:p})]})]})})}export{l as t};
1
+ import{t as e}from"./jsx-runtime-CVMpzJz9.js";import{t}from"./button-BHKbOsmj.js";import{At as n,Dt as r,Et as i,Ot as a,Tt as o,kt as s}from"./index-CMRGRbC9.js";var c=e();function l({open:e,onConfirm:l,onCancel:u,title:d,description:f,confirmLabel:p=`Delete`,variant:m=`destructive`,isPending:h}){return(0,c.jsx)(o,{open:e,onOpenChange:e=>!e&&u(),children:(0,c.jsxs)(i,{className:`bg-surface border-surface-highest max-w-sm`,children:[(0,c.jsxs)(s,{children:[(0,c.jsx)(n,{className:`font-headline text-sm text-on-surface`,children:d}),(0,c.jsx)(r,{className:`font-body text-xs text-outline mt-2`,children:f})]}),(0,c.jsxs)(a,{className:`mt-4`,children:[(0,c.jsx)(t,{"data-testid":`confirm-dialog-cancel`,type:`button`,variant:`ghost`,size:`sm`,onClick:u,className:`font-label text-xs text-outline`,children:`Cancel`}),(0,c.jsx)(t,{"data-testid":`confirm-dialog-confirm`,type:`button`,size:`sm`,onClick:l,disabled:h,className:m===`destructive`?`font-label text-xs bg-error/15 text-error border border-error/30 hover:bg-error/25`:`font-label text-xs bg-tertiary/15 text-tertiary border border-tertiary/30 hover:bg-tertiary/25`,children:h?`...`:p})]})]})})}export{l as t};
@@ -1 +1 @@
1
- import{t as e}from"./jsx-runtime-CVMpzJz9.js";import{Dn as t,P as n,U as r,_t as i,l as a,w as o}from"./index-Ck-SDgTR.js";import{t as s}from"./ErrorState-B0KI2D4y.js";import{a as c,t as l}from"./live-sessions-D07BClP7.js";import{n as u}from"./useSessions-Bx-Bw75y.js";import{a as d,i as f,n as p,o as m,r as h,t as g}from"./table-DC8IBMHg.js";import{t as _}from"./useProjectScope-C7yZQa4i.js";import{t as v}from"./PriorityBadge-_KMVnMst.js";import{t as y}from"./ResumeActions-gVze1Xjw.js";import{t as b}from"./StatusBadge-CZQsVLgL.js";import{o as x}from"./useJobs-B2MCCWKa.js";import{r as S}from"./useMemories-CcDhzt2Y.js";var C=e();function w(e,t){return e.isLoading?`…`:e.error?`—`:t}function T({projectId:e}){let T=t(),E=_(e),D=a(`sm`),O=e=>{let t=new URL(e,window.location.origin);t.searchParams.set(`project`,E),T({pathname:t.pathname,search:t.search,hash:t.hash})},k=E===`all`||E===`unassigned`?void 0:{project_id:E},A=n(k),{data:j,isLoading:M}=A,N=x(k),{data:P}=N,F=S({project_id:k?.project_id,limit:1},{enabled:E!==`unassigned`}),I=E===`unassigned`?0:F.data?.total??0,{data:L}=i(),R=u(!0),z=(R.data??[]).filter(e=>E===`all`||(E===`unassigned`?e.project_id===null:e.project_id===E)),B=E===`unassigned`?(P??[]).filter(e=>e.project_id===null):P??[],V=E===`unassigned`?(j??[]).filter(e=>e.project_id===null):j??[],H=V.reduce((e,t)=>(e[t.status]=(e[t.status]??0)+1,e),{}),U=[...V].sort((e,t)=>new Date(t.updated_at).getTime()-new Date(e.updated_at).getTime()).slice(0,8),W=B.filter(e=>e.enabled),G=E===`all`?`All Projects`:E===`unassigned`?`Unassigned`:L?.find(e=>e.id===E)?.name??``,K=[{label:`Doing`,value:w(A,H.doing??0),sub:`in progress`,path:`/tasks?view=table&status=doing`},{label:`Review`,value:w(A,H.review??0),sub:`awaiting review`,path:`/tasks?view=table&status=review`},{label:`Blocked`,value:w(A,H.blocked??0),sub:`needs attention`,path:`/tasks?view=table&status=blocked`},{label:`Todo`,value:w(A,(H.todo??0)+(H.queued??0)),sub:`pending`,path:`/tasks?view=board`},{label:`Done`,value:w(A,H.done??0),sub:`completed`,path:`/tasks?view=table&status=done`}],q=[{label:`Active jobs`,value:w(N,W.length),sub:`of ${B.length} total`,path:`/jobs`},{label:`Memories`,value:w(F,I),sub:`in this scope`,path:o},{label:`Projects`,value:(L??[]).filter(e=>e.status===`active`).length,sub:`active across workspace`,path:`/projects`}];return(0,C.jsxs)(`div`,{"data-activity-preview":!0,"data-testid":`activity-preview`,className:`activity-preview`,children:[(0,C.jsxs)(`div`,{className:`activity-heading`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h1`,{"data-testid":`view-title`,children:`Activity`}),(0,C.jsx)(`p`,{"data-testid":`view-meta`,children:G||`All projects`})]}),(0,C.jsx)(`button`,{type:`button`,className:`activity-primary`,onClick:()=>O(`/tasks`),children:`View tasks`})]}),[A,N,F,R].some(e=>e.isLoading)&&(0,C.jsx)(`p`,{role:`status`,className:`activity-muted mb-4`,children:`Loading activity…`}),[{name:`Tasks`,query:A},{name:`Jobs`,query:N},{name:`Memories`,query:F},{name:`Sessions`,query:R}].filter(({query:e})=>e.error).map(({name:e,query:t})=>(0,C.jsx)(s,{message:`${e}: ${t.error?.message??`Could not load activity`}`,onRetry:()=>t.refetch()},e)),(0,C.jsx)(`section`,{className:`activity-metrics`,"aria-label":`Task summary`,children:K.map(e=>(0,C.jsxs)(`button`,{type:`button`,"data-testid":`stat-card`,"data-stat-label":e.label,className:`activity-metric`,onClick:()=>O(e.path),children:[(0,C.jsx)(`span`,{className:`activity-metric-label`,children:e.label}),(0,C.jsx)(`span`,{"data-testid":`stat-card-value`,className:`activity-metric-value`,children:e.value}),(0,C.jsx)(`span`,{className:`activity-metric-sub`,children:e.sub})]},e.label))}),(0,C.jsx)(`section`,{className:`activity-resources`,"aria-label":`Workspace summary`,children:q.map(e=>(0,C.jsxs)(`button`,{type:`button`,"data-testid":`stat-card`,"data-stat-label":e.label,onClick:()=>O(e.path),children:[(0,C.jsx)(`span`,{children:e.label}),(0,C.jsx)(`span`,{"data-testid":`stat-card-value`,className:`activity-resource-value`,children:e.value}),(0,C.jsx)(`span`,{className:`activity-resource-sub`,children:e.sub})]},e.label))}),(0,C.jsxs)(`section`,{className:`activity-section`,children:[(0,C.jsxs)(`div`,{className:`activity-section-heading`,children:[(0,C.jsx)(`h2`,{children:`Recent tasks`}),(0,C.jsx)(`button`,{type:`button`,className:`activity-text-action`,onClick:()=>O(`/tasks`),children:`View all`})]}),M?(0,C.jsx)(`div`,{className:`space-y-2`,children:[0,1,2,3].map(e=>(0,C.jsx)(r,{className:`h-10 w-full`},e))}):U.length===0?(0,C.jsx)(`p`,{className:`activity-empty`,children:`No tasks`}):D?(0,C.jsxs)(g,{className:`activity-task-table`,children:[(0,C.jsx)(d,{children:(0,C.jsxs)(m,{children:[(0,C.jsx)(f,{children:`Task`}),(0,C.jsx)(f,{className:`w-36`,children:`Status`}),(0,C.jsx)(f,{className:`w-28`,children:`Priority`}),(0,C.jsx)(f,{className:`w-28`,children:`Updated`})]})}),(0,C.jsx)(p,{children:U.map(e=>(0,C.jsxs)(m,{onClick:()=>O(`/tasks/${e.id}`),children:[(0,C.jsx)(h,{children:(0,C.jsx)(`button`,{type:`button`,className:`activity-task-title`,onClick:t=>{t.stopPropagation(),O(`/tasks/${e.id}`)},children:e.title})}),(0,C.jsx)(h,{children:(0,C.jsx)(`span`,{className:`activity-status`,"data-status":e.status,children:(0,C.jsx)(b,{status:e.status})})}),(0,C.jsx)(h,{children:(0,C.jsx)(`span`,{className:`activity-priority`,children:(0,C.jsx)(v,{priority:e.priority})})}),(0,C.jsx)(h,{className:`activity-muted`,children:new Date(e.updated_at).toLocaleDateString()})]},e.id))})]}):(0,C.jsx)(`div`,{className:`activity-task-list`,children:U.map(e=>(0,C.jsxs)(`article`,{className:`activity-task-mobile`,children:[(0,C.jsx)(`button`,{type:`button`,className:`activity-task-title`,onClick:()=>O(`/tasks/${e.id}`),children:e.title}),(0,C.jsxs)(`div`,{className:`activity-task-meta`,children:[(0,C.jsx)(`span`,{className:`activity-status`,"data-status":e.status,children:(0,C.jsx)(b,{status:e.status})}),(0,C.jsx)(`span`,{className:`activity-priority`,children:(0,C.jsx)(v,{priority:e.priority})}),(0,C.jsx)(`span`,{children:new Date(e.updated_at).toLocaleDateString()})]})]},e.id))})]}),(0,C.jsxs)(`div`,{className:`activity-secondary`,children:[W.length>0&&(0,C.jsxs)(`section`,{className:`activity-section`,children:[(0,C.jsxs)(`div`,{className:`activity-section-heading`,children:[(0,C.jsx)(`h2`,{children:`Active jobs`}),(0,C.jsx)(`button`,{type:`button`,className:`activity-text-action`,onClick:()=>O(`/jobs`),children:`View all`})]}),(0,C.jsx)(`div`,{className:`activity-row-list`,children:W.slice(0,5).map(e=>(0,C.jsxs)(`button`,{type:`button`,className:`activity-row`,onClick:()=>O(`/jobs/${e.id}`),children:[(0,C.jsxs)(`span`,{className:`activity-row-heading`,children:[(0,C.jsx)(`span`,{children:e.name}),(0,C.jsx)(`span`,{className:`activity-muted`,children:e.trigger_type})]}),e.last_run_at&&(0,C.jsxs)(`span`,{className:`activity-row-description`,children:[`Last run `,new Date(e.last_run_at).toLocaleString()]})]},e.id))})]}),z.length>0&&(0,C.jsxs)(`section`,{className:`activity-section`,children:[(0,C.jsxs)(`div`,{className:`activity-section-heading`,children:[(0,C.jsx)(`h2`,{children:`Agent sessions`}),(0,C.jsx)(`button`,{type:`button`,className:`activity-text-action`,onClick:()=>O(`/sessions`),children:`View all`})]}),(0,C.jsx)(`div`,{className:`activity-row-list`,children:z.slice(0,5).map(e=>(0,C.jsxs)(`div`,{className:`activity-row`,children:[(0,C.jsxs)(`button`,{type:`button`,className:`w-full text-left`,"data-testid":`activity-session-link`,"data-session-id":e.id,onClick:()=>O(`/sessions?session=${encodeURIComponent(e.id)}`),children:[(0,C.jsxs)(`span`,{className:`activity-row-heading`,children:[(0,C.jsx)(`span`,{children:e.name??e.agent}),(0,C.jsx)(`span`,{className:`activity-muted`,children:c(e.last_activity_at)})]}),(0,C.jsxs)(`span`,{className:`activity-row-description inline-flex items-center gap-2`,children:[(0,C.jsx)(`span`,{className:`size-1.5 rounded-full ${l[e.status].dot}`}),e.agent,` · `,l[e.status].label,e.task?` · ${e.task.title}`:``]})]}),(0,C.jsx)(y,{session:e})]},e.id))})]})]}),E===`all`&&(L??[]).length>0&&(0,C.jsxs)(`section`,{className:`activity-section`,children:[(0,C.jsxs)(`div`,{className:`activity-section-heading`,children:[(0,C.jsx)(`h2`,{children:`Projects`}),(0,C.jsx)(`button`,{type:`button`,className:`activity-text-action`,onClick:()=>O(`/projects`),children:`View all`})]}),(0,C.jsx)(`div`,{className:`activity-projects`,children:(L??[]).filter(e=>e.status===`active`).slice(0,6).map(e=>(0,C.jsxs)(`button`,{type:`button`,className:`activity-row`,onClick:()=>O(`/projects/${e.id}`),children:[(0,C.jsx)(`span`,{className:`activity-row-heading`,children:e.name}),e.description&&(0,C.jsx)(`span`,{className:`activity-row-description`,children:e.description})]},e.id))})]})]})}export{T as default};
1
+ import{t as e}from"./jsx-runtime-CVMpzJz9.js";import{On as t,P as n,U as r,_t as i,l as a,w as o}from"./index-CMRGRbC9.js";import{t as s}from"./ErrorState-BoQqdsym.js";import{a as c,t as l}from"./live-sessions-D07BClP7.js";import{n as u}from"./useSessions-C2GU4FkG.js";import{a as d,i as f,n as p,o as m,r as h,t as g}from"./table-ByS-sgsb.js";import{t as _}from"./useProjectScope-CZEfU9mq.js";import{t as v}from"./PriorityBadge-ADp-pD5B.js";import{t as y}from"./ResumeActions-1gJa3nsX.js";import{t as b}from"./StatusBadge-CTFDUHuw.js";import{o as x}from"./useJobs-CCQUWZt3.js";import{r as S}from"./useMemories-D0tEN20z.js";var C=e();function w(e,t){return e.isLoading?`…`:e.error?`—`:t}function T({projectId:e}){let T=t(),E=_(e),D=a(`sm`),O=e=>{let t=new URL(e,window.location.origin);t.searchParams.set(`project`,E),T({pathname:t.pathname,search:t.search,hash:t.hash})},k=E===`all`||E===`unassigned`?void 0:{project_id:E},A=n(k),{data:j,isLoading:M}=A,N=x(k),{data:P}=N,F=S({project_id:k?.project_id,limit:1},{enabled:E!==`unassigned`}),I=E===`unassigned`?0:F.data?.total??0,{data:L}=i(),R=u(!0),z=(R.data??[]).filter(e=>E===`all`||(E===`unassigned`?e.project_id===null:e.project_id===E)),B=E===`unassigned`?(P??[]).filter(e=>e.project_id===null):P??[],V=E===`unassigned`?(j??[]).filter(e=>e.project_id===null):j??[],H=V.reduce((e,t)=>(e[t.status]=(e[t.status]??0)+1,e),{}),U=[...V].sort((e,t)=>new Date(t.updated_at).getTime()-new Date(e.updated_at).getTime()).slice(0,8),W=B.filter(e=>e.enabled),G=E===`all`?`All Projects`:E===`unassigned`?`Unassigned`:L?.find(e=>e.id===E)?.name??``,K=[{label:`Doing`,value:w(A,H.doing??0),sub:`in progress`,path:`/tasks?view=table&status=doing`},{label:`Review`,value:w(A,H.review??0),sub:`awaiting review`,path:`/tasks?view=table&status=review`},{label:`Blocked`,value:w(A,H.blocked??0),sub:`needs attention`,path:`/tasks?view=table&status=blocked`},{label:`Todo`,value:w(A,(H.todo??0)+(H.queued??0)),sub:`pending`,path:`/tasks?view=board`},{label:`Done`,value:w(A,H.done??0),sub:`completed`,path:`/tasks?view=table&status=done`}],q=[{label:`Active jobs`,value:w(N,W.length),sub:`of ${B.length} total`,path:`/jobs`},{label:`Memories`,value:w(F,I),sub:`in this scope`,path:o},{label:`Projects`,value:(L??[]).filter(e=>e.status===`active`).length,sub:`active across workspace`,path:`/projects`}];return(0,C.jsxs)(`div`,{"data-activity-preview":!0,"data-testid":`activity-preview`,className:`activity-preview`,children:[(0,C.jsxs)(`div`,{className:`activity-heading`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h1`,{"data-testid":`view-title`,children:`Activity`}),(0,C.jsx)(`p`,{"data-testid":`view-meta`,children:G||`All projects`})]}),(0,C.jsx)(`button`,{type:`button`,className:`activity-primary`,onClick:()=>O(`/tasks`),children:`View tasks`})]}),[A,N,F,R].some(e=>e.isLoading)&&(0,C.jsx)(`p`,{role:`status`,className:`activity-muted mb-4`,children:`Loading activity…`}),[{name:`Tasks`,query:A},{name:`Jobs`,query:N},{name:`Memories`,query:F},{name:`Sessions`,query:R}].filter(({query:e})=>e.error).map(({name:e,query:t})=>(0,C.jsx)(s,{message:`${e}: ${t.error?.message??`Could not load activity`}`,onRetry:()=>t.refetch()},e)),(0,C.jsx)(`section`,{className:`activity-metrics`,"aria-label":`Task summary`,children:K.map(e=>(0,C.jsxs)(`button`,{type:`button`,"data-testid":`stat-card`,"data-stat-label":e.label,className:`activity-metric`,onClick:()=>O(e.path),children:[(0,C.jsx)(`span`,{className:`activity-metric-label`,children:e.label}),(0,C.jsx)(`span`,{"data-testid":`stat-card-value`,className:`activity-metric-value`,children:e.value}),(0,C.jsx)(`span`,{className:`activity-metric-sub`,children:e.sub})]},e.label))}),(0,C.jsx)(`section`,{className:`activity-resources`,"aria-label":`Workspace summary`,children:q.map(e=>(0,C.jsxs)(`button`,{type:`button`,"data-testid":`stat-card`,"data-stat-label":e.label,onClick:()=>O(e.path),children:[(0,C.jsx)(`span`,{children:e.label}),(0,C.jsx)(`span`,{"data-testid":`stat-card-value`,className:`activity-resource-value`,children:e.value}),(0,C.jsx)(`span`,{className:`activity-resource-sub`,children:e.sub})]},e.label))}),(0,C.jsxs)(`section`,{className:`activity-section`,children:[(0,C.jsxs)(`div`,{className:`activity-section-heading`,children:[(0,C.jsx)(`h2`,{children:`Recent tasks`}),(0,C.jsx)(`button`,{type:`button`,className:`activity-text-action`,onClick:()=>O(`/tasks`),children:`View all`})]}),M?(0,C.jsx)(`div`,{className:`space-y-2`,children:[0,1,2,3].map(e=>(0,C.jsx)(r,{className:`h-10 w-full`},e))}):U.length===0?(0,C.jsx)(`p`,{className:`activity-empty`,children:`No tasks`}):D?(0,C.jsxs)(g,{className:`activity-task-table`,children:[(0,C.jsx)(d,{children:(0,C.jsxs)(m,{children:[(0,C.jsx)(f,{children:`Task`}),(0,C.jsx)(f,{className:`w-36`,children:`Status`}),(0,C.jsx)(f,{className:`w-28`,children:`Priority`}),(0,C.jsx)(f,{className:`w-28`,children:`Updated`})]})}),(0,C.jsx)(p,{children:U.map(e=>(0,C.jsxs)(m,{onClick:()=>O(`/tasks/${e.id}`),children:[(0,C.jsx)(h,{children:(0,C.jsx)(`button`,{type:`button`,className:`activity-task-title`,onClick:t=>{t.stopPropagation(),O(`/tasks/${e.id}`)},children:e.title})}),(0,C.jsx)(h,{children:(0,C.jsx)(`span`,{className:`activity-status`,"data-status":e.status,children:(0,C.jsx)(b,{status:e.status})})}),(0,C.jsx)(h,{children:(0,C.jsx)(`span`,{className:`activity-priority`,children:(0,C.jsx)(v,{priority:e.priority})})}),(0,C.jsx)(h,{className:`activity-muted`,children:new Date(e.updated_at).toLocaleDateString()})]},e.id))})]}):(0,C.jsx)(`div`,{className:`activity-task-list`,children:U.map(e=>(0,C.jsxs)(`article`,{className:`activity-task-mobile`,children:[(0,C.jsx)(`button`,{type:`button`,className:`activity-task-title`,onClick:()=>O(`/tasks/${e.id}`),children:e.title}),(0,C.jsxs)(`div`,{className:`activity-task-meta`,children:[(0,C.jsx)(`span`,{className:`activity-status`,"data-status":e.status,children:(0,C.jsx)(b,{status:e.status})}),(0,C.jsx)(`span`,{className:`activity-priority`,children:(0,C.jsx)(v,{priority:e.priority})}),(0,C.jsx)(`span`,{children:new Date(e.updated_at).toLocaleDateString()})]})]},e.id))})]}),(0,C.jsxs)(`div`,{className:`activity-secondary`,children:[W.length>0&&(0,C.jsxs)(`section`,{className:`activity-section`,children:[(0,C.jsxs)(`div`,{className:`activity-section-heading`,children:[(0,C.jsx)(`h2`,{children:`Active jobs`}),(0,C.jsx)(`button`,{type:`button`,className:`activity-text-action`,onClick:()=>O(`/jobs`),children:`View all`})]}),(0,C.jsx)(`div`,{className:`activity-row-list`,children:W.slice(0,5).map(e=>(0,C.jsxs)(`button`,{type:`button`,className:`activity-row`,onClick:()=>O(`/jobs/${e.id}`),children:[(0,C.jsxs)(`span`,{className:`activity-row-heading`,children:[(0,C.jsx)(`span`,{children:e.name}),(0,C.jsx)(`span`,{className:`activity-muted`,children:e.trigger_type})]}),e.last_run_at&&(0,C.jsxs)(`span`,{className:`activity-row-description`,children:[`Last run `,new Date(e.last_run_at).toLocaleString()]})]},e.id))})]}),z.length>0&&(0,C.jsxs)(`section`,{className:`activity-section`,children:[(0,C.jsxs)(`div`,{className:`activity-section-heading`,children:[(0,C.jsx)(`h2`,{children:`Agent sessions`}),(0,C.jsx)(`button`,{type:`button`,className:`activity-text-action`,onClick:()=>O(`/sessions`),children:`View all`})]}),(0,C.jsx)(`div`,{className:`activity-row-list`,children:z.slice(0,5).map(e=>(0,C.jsxs)(`div`,{className:`activity-row`,children:[(0,C.jsxs)(`button`,{type:`button`,className:`w-full text-left`,"data-testid":`activity-session-link`,"data-session-id":e.id,onClick:()=>O(`/sessions?session=${encodeURIComponent(e.id)}`),children:[(0,C.jsxs)(`span`,{className:`activity-row-heading`,children:[(0,C.jsx)(`span`,{children:e.name??e.agent}),(0,C.jsx)(`span`,{className:`activity-muted`,children:c(e.last_activity_at)})]}),(0,C.jsxs)(`span`,{className:`activity-row-description inline-flex items-center gap-2`,children:[(0,C.jsx)(`span`,{className:`size-1.5 rounded-full ${l[e.status].dot}`}),e.agent,` · `,l[e.status].label,e.task?` · ${e.task.title}`:``]})]}),(0,C.jsx)(y,{session:e})]},e.id))})]})]}),E===`all`&&(L??[]).length>0&&(0,C.jsxs)(`section`,{className:`activity-section`,children:[(0,C.jsxs)(`div`,{className:`activity-section-heading`,children:[(0,C.jsx)(`h2`,{children:`Projects`}),(0,C.jsx)(`button`,{type:`button`,className:`activity-text-action`,onClick:()=>O(`/projects`),children:`View all`})]}),(0,C.jsx)(`div`,{className:`activity-projects`,children:(L??[]).filter(e=>e.status===`active`).slice(0,6).map(e=>(0,C.jsxs)(`button`,{type:`button`,className:`activity-row`,onClick:()=>O(`/projects/${e.id}`),children:[(0,C.jsx)(`span`,{className:`activity-row-heading`,children:e.name}),e.description&&(0,C.jsx)(`span`,{className:`activity-row-description`,children:e.description})]},e.id))})]})]})}export{T as default};
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{t as r}from"./button-PNx108iL.js";import{t as i}from"./MarkdownEditor-BM9COcIb.js";import{Dn as a,kn as o}from"./index-Ck-SDgTR.js";var s=e(t(),1),c=n(),l=new Map,u=new Set;typeof window<`u`&&window.addEventListener(`beforeunload`,e=>{l.size&&(e.preventDefault(),e.returnValue=``)});function d(e){return u.has(e)?!1:l.has(e)?window.confirm(`Discard unsaved changes to this document?`)?(l.delete(e),!0):!1:!0}function f({documentId:e,content:t,path:n,onSave:f,testId:p,wikiLinks:m,navigation:h,expanded:g,onExpandedChange:_,layout:v,pageTitle:y,hideFrontmatter:b}){let[x]=o(),S=a(),C=x.get(`editorMode`),w=C===`edit`||C===`split`?C:`read`,T=(0,s.useRef)(l.get(e)??{original:t,content:t}),[E,D]=(0,s.useState)(T.current.content),[O,k]=(0,s.useState)(T.current.original),[A,j]=(0,s.useState)(!1),[M,N]=(0,s.useState)(null),P=(0,s.useRef)(!1),F=(0,s.useRef)(T.current.content),I=E!==O;(0,s.useEffect)(()=>{l.has(e)||(D(t),F.current=t,k(t))},[t,e]);function L(t){F.current=t,D(t),t===O?l.delete(e):l.set(e,{original:O,content:t})}async function R(){if(!f||!I||P.current)return;P.current=!0,u.add(e),j(!0),N(null);let t=F.current;try{let n=await f(t,O),r=typeof n==`string`?n:t;k(r),F.current===t?(l.delete(e),F.current=r,D(r)):l.set(e,{original:r,content:F.current})}catch(e){N(e instanceof Error?e.message:`Could not save document`)}finally{P.current=!1,u.delete(e),j(!1)}}function z(e){let t=new URLSearchParams(window.location.search);t.set(`editorMode`,e),t.toString()!==new URLSearchParams(window.location.search).toString()&&S({search:t.toString(),hash:window.location.hash})}function B(){d(e)&&(D(t),k(t),F.current=t,N(null))}let V=f?A?`Saving…`:I?`Unsaved changes`:`Saved`:`Read-only`,H=(0,c.jsxs)(c.Fragment,{children:[M&&(0,c.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[M,` Your draft has been kept.`]}),I&&t!==O&&(0,c.jsx)(`p`,{role:`status`,className:`text-sm text-outline`,children:`The document changed elsewhere. Your draft is preserved; saving will check for conflicts.`})]});return v===`page`?(0,c.jsx)(`div`,{className:`min-w-0`,"data-testid":`document-workspace`,children:(0,c.jsx)(i,{path:n,value:E,onChange:L,onSave:()=>void R(),readOnly:!f||A,testId:p,wikiLinks:m,initialMode:`read`,mode:w,onModeChange:z,expanded:g,onExpandedChange:_,layout:`page`,pageTitle:y,hideFrontmatter:b,notice:M||I&&t!==O?H:void 0,actions:(w!==`read`||I||A)&&(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(`span`,{"data-testid":`document-save-status`,role:`status`,className:`text-xs text-outline`,children:V}),f&&(I||A)&&(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(r,{type:`button`,size:`sm`,variant:`ghost`,"data-testid":`document-discard`,disabled:A,onClick:B,children:`Discard`}),(0,c.jsx)(r,{type:`button`,size:`sm`,"data-testid":`document-save`,disabled:A,onClick:()=>void R(),children:`Save`})]})]})})}):(0,c.jsx)(`div`,{className:`min-w-0 space-y-3`,"data-testid":`document-workspace`,children:(0,c.jsx)(i,{path:n,value:E,onChange:L,onSave:()=>void R(),readOnly:!f||A,testId:p,wikiLinks:m,initialMode:`read`,mode:w,onModeChange:z,expanded:g,onExpandedChange:_,layout:v,header:(0,c.jsxs)(`div`,{className:`space-y-2`,children:[h&&(0,c.jsx)(`div`,{className:`mb-3 min-w-0`,children:h}),(0,c.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,c.jsx)(`span`,{"data-testid":`document-save-status`,role:`status`,className:`min-w-0 flex-1 text-sm text-outline`,children:V}),f&&(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(r,{type:`button`,variant:`ghost`,"data-testid":`document-discard`,disabled:!I||A,onClick:B,children:`Discard changes`}),(0,c.jsx)(r,{type:`button`,"data-testid":`document-save`,disabled:!I||A,onClick:()=>void R(),children:`Save changes`})]})]}),H]})})})}export{d as n,f as t};
1
+ import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{t as r}from"./button-BHKbOsmj.js";import{t as i}from"./MarkdownEditor-BMQq1cAY.js";import{An as a,On as o}from"./index-CMRGRbC9.js";var s=e(t(),1),c=n(),l=new Map,u=new Set;typeof window<`u`&&window.addEventListener(`beforeunload`,e=>{l.size&&(e.preventDefault(),e.returnValue=``)});function d(e){return u.has(e)?!1:l.has(e)?window.confirm(`Discard unsaved changes to this document?`)?(l.delete(e),!0):!1:!0}function f({documentId:e,content:t,path:n,onSave:f,testId:p,wikiLinks:m,navigation:h,expanded:g,onExpandedChange:_,layout:v,pageTitle:y,hideFrontmatter:b}){let[x]=a(),S=o(),C=x.get(`editorMode`),w=C===`edit`||C===`split`?C:`read`,T=(0,s.useRef)(l.get(e)??{original:t,content:t}),[E,D]=(0,s.useState)(T.current.content),[O,k]=(0,s.useState)(T.current.original),[A,j]=(0,s.useState)(!1),[M,N]=(0,s.useState)(null),P=(0,s.useRef)(!1),F=(0,s.useRef)(T.current.content),I=E!==O;(0,s.useEffect)(()=>{l.has(e)||(D(t),F.current=t,k(t))},[t,e]);function L(t){F.current=t,D(t),t===O?l.delete(e):l.set(e,{original:O,content:t})}async function R(){if(!f||!I||P.current)return;P.current=!0,u.add(e),j(!0),N(null);let t=F.current;try{let n=await f(t,O),r=typeof n==`string`?n:t;k(r),F.current===t?(l.delete(e),F.current=r,D(r)):l.set(e,{original:r,content:F.current})}catch(e){N(e instanceof Error?e.message:`Could not save document`)}finally{P.current=!1,u.delete(e),j(!1)}}function z(e){let t=new URLSearchParams(window.location.search);t.set(`editorMode`,e),t.toString()!==new URLSearchParams(window.location.search).toString()&&S({search:t.toString(),hash:window.location.hash})}function B(){d(e)&&(D(t),k(t),F.current=t,N(null))}let V=f?A?`Saving…`:I?`Unsaved changes`:`Saved`:`Read-only`,H=(0,c.jsxs)(c.Fragment,{children:[M&&(0,c.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[M,` Your draft has been kept.`]}),I&&t!==O&&(0,c.jsx)(`p`,{role:`status`,className:`text-sm text-outline`,children:`The document changed elsewhere. Your draft is preserved; saving will check for conflicts.`})]});return v===`page`?(0,c.jsx)(`div`,{className:`min-w-0`,"data-testid":`document-workspace`,children:(0,c.jsx)(i,{path:n,value:E,onChange:L,onSave:()=>void R(),readOnly:!f||A,testId:p,wikiLinks:m,initialMode:`read`,mode:w,onModeChange:z,expanded:g,onExpandedChange:_,layout:`page`,pageTitle:y,hideFrontmatter:b,notice:M||I&&t!==O?H:void 0,actions:(w!==`read`||I||A)&&(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(`span`,{"data-testid":`document-save-status`,role:`status`,className:`text-xs text-outline`,children:V}),f&&(I||A)&&(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(r,{type:`button`,size:`sm`,variant:`ghost`,"data-testid":`document-discard`,disabled:A,onClick:B,children:`Discard`}),(0,c.jsx)(r,{type:`button`,size:`sm`,"data-testid":`document-save`,disabled:A,onClick:()=>void R(),children:`Save`})]})]})})}):(0,c.jsx)(`div`,{className:`min-w-0 space-y-3`,"data-testid":`document-workspace`,children:(0,c.jsx)(i,{path:n,value:E,onChange:L,onSave:()=>void R(),readOnly:!f||A,testId:p,wikiLinks:m,initialMode:`read`,mode:w,onModeChange:z,expanded:g,onExpandedChange:_,layout:v,header:(0,c.jsxs)(`div`,{className:`space-y-2`,children:[h&&(0,c.jsx)(`div`,{className:`mb-3 min-w-0`,children:h}),(0,c.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,c.jsx)(`span`,{"data-testid":`document-save-status`,role:`status`,className:`min-w-0 flex-1 text-sm text-outline`,children:V}),f&&(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(r,{type:`button`,variant:`ghost`,"data-testid":`document-discard`,disabled:!I||A,onClick:B,children:`Discard changes`}),(0,c.jsx)(r,{type:`button`,"data-testid":`document-save`,disabled:!I||A,onClick:()=>void R(),children:`Save changes`})]})]}),H]})})})}export{d as n,f as t};
@@ -1 +1 @@
1
- import{t as e}from"./jsx-runtime-CVMpzJz9.js";import{t}from"./button-PNx108iL.js";var n=e();function r({message:e,onRetry:r}){return(0,n.jsxs)(`div`,{"data-testid":`error-state`,className:`flex flex-col items-center justify-center gap-3 px-4 py-16`,children:[(0,n.jsx)(`p`,{role:`alert`,className:`max-w-prose wrap-break-word text-center text-sm text-error`,children:e}),r&&(0,n.jsx)(t,{"data-testid":`error-retry`,variant:`outline`,size:`sm`,onClick:r,children:`Retry`})]})}export{r as t};
1
+ import{t as e}from"./jsx-runtime-CVMpzJz9.js";import{t}from"./button-BHKbOsmj.js";var n=e();function r({message:e,onRetry:r}){return(0,n.jsxs)(`div`,{"data-testid":`error-state`,className:`flex flex-col items-center justify-center gap-3 px-4 py-16`,children:[(0,n.jsx)(`p`,{role:`alert`,className:`max-w-prose wrap-break-word text-center text-sm text-error`,children:e}),r&&(0,n.jsx)(t,{"data-testid":`error-retry`,variant:`outline`,size:`sm`,onClick:r,children:`Retry`})]})}export{r as t};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{n as r}from"./QueryClientProvider-DlPztvhd.js";import{t as i}from"./MarkdownEditor-BMQq1cAY.js";import{t as a}from"./save-3DxWVsBU.js";import{n as o}from"./client-BwhkVepQ.js";import{t as s}from"./file-kind-BYU1kv95.js";import{An as c,ct as l}from"./index-CMRGRbC9.js";var u=e(t(),1),d=n(),f=new Map;typeof window<`u`&&window.addEventListener(`beforeunload`,e=>{f.size!==0&&(e.preventDefault(),e.returnValue=``)});function p({terminalId:e,path:t,content:n,readOnly:p,onDirty:m}){let[h,g]=c(),_=h.get(`editorMode`),v=_===`read`||_===`split`?_:`edit`,y=`${e}:${t}`,b=(0,u.useRef)(f.get(y)??{original:n,content:n}),x=(0,u.useRef)(b.current.original),S=(0,u.useRef)(b.current.content),[C,w]=(0,u.useState)(b.current.content!==b.current.original),[T,E]=(0,u.useState)(!1),[D,O]=(0,u.useState)(null),[k,A]=(0,u.useState)(b.current.content),j=r(),M=(0,u.useRef)(()=>{}),N=(0,u.useRef)(!1),P=(0,u.useRef)(!1),F=(0,u.useRef)(m);F.current=m;async function I(){if(N.current||p||S.current===x.current)return;N.current=!0,E(!0),O(null);let n=S.current;try{await o.git.saveFile(e,t,n,x.current),x.current=n;let r=S.current!==n;w(r),P.current&&F.current(r),r?f.set(y,{original:n,content:S.current}):f.delete(y),j.invalidateQueries({queryKey:[`checkout-files`,e,t]}),j.invalidateQueries({queryKey:[`git`,e]})}catch(e){O(e instanceof Error?e.message:`Could not save file`)}finally{N.current=!1,E(!1)}}M.current=()=>void I(),(0,u.useEffect)(()=>(P.current=!0,F.current(b.current.content!==b.current.original),()=>{P.current=!1}),[]),(0,u.useEffect)(()=>{N.current||f.has(y)||n===x.current||(x.current=n,S.current=n,A(n),w(!1),P.current&&F.current(!1))},[n,y]);function L(e){S.current=e,A(e);let t=e!==x.current;w(t),F.current(t),t?f.set(y,{original:x.current,content:e}):f.delete(y)}function R(){window.confirm(`Discard your edits and reload the file from disk?`)&&o.git.files(e,t).then(e=>{if(e.content===null||e.binary||e.truncated)throw Error(`File is no longer editable`);x.current=e.content,S.current=e.content,f.delete(y),A(e.content),w(!1),F.current(!1),O(null)}).catch(e=>O(e instanceof Error?e.message:`Could not reload file`))}let z=(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 border-b border-surface-highest px-2 py-1`,children:[(0,d.jsxs)(`button`,{type:`button`,"data-testid":`file-save`,disabled:!C||T||p,onClick:()=>void I(),className:`flex min-h-11 items-center gap-1 rounded px-2 py-1 text-sm text-primary hover:bg-surface-highest disabled:opacity-40`,title:`Save (Ctrl/Cmd+S)`,children:[(0,d.jsx)(a,{size:14}),T?`Saving…`:`Save`]}),(0,d.jsx)(`span`,{"data-testid":`file-save-status`,className:`min-w-0 flex-1 truncate text-sm text-on-surface-variant`,children:p?`Read-only preview`:C?`Unsaved changes`:`Saved`})]}),D&&(0,d.jsxs)(`div`,{role:`alert`,className:`shrink-0 border-b border-error/30 p-2 text-xs text-error`,children:[D,(0,d.jsx)(`button`,{type:`button`,"data-testid":`file-reload`,onClick:R,className:`ml-2 underline`,children:`Reload from disk`})]})]});return(0,d.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,"data-testid":`file-editor`,children:[!s(t)&&z,(0,d.jsx)(`div`,{"data-testid":`file-preview`,className:`min-h-0 flex-1 overflow-hidden`,children:s(t)?(0,d.jsx)(i,{path:t,value:k,onChange:L,onSave:()=>M.current(),readOnly:p,height:`100%`,testId:`file-editor-input`,header:z,mode:v,onModeChange:e=>g(t=>{let n=new URLSearchParams(t);return n.set(`editorMode`,e),n})}):(0,d.jsx)(l,{path:t,value:k,onChange:L,onSave:()=>M.current(),readOnly:p,height:`100%`,testId:`file-editor-input`})})]})}export{p as FileEditor};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{n as r}from"./QueryClientProvider-DlPztvhd.js";import{n as i,t as a}from"./useMutation-HX90wI4L.js";import{t as o}from"./button-BHKbOsmj.js";import{t as s}from"./label-BQ1Lr4sA.js";import{a as c,n as l}from"./client-BwhkVepQ.js";import{Tn as u,wt as d}from"./index-CMRGRbC9.js";import{t as f}from"./ErrorState-BoQqdsym.js";import{l as p}from"./useJobs-CCQUWZt3.js";var m=e(t(),1);function h(e){return i({queryKey:[`webhooks`,e],queryFn:()=>l.webhooks.list(e),select:e=>e.webhooks})}function g(e){return i({queryKey:[`webhook-deliveries`,e],queryFn:()=>l.webhooks.deliveries(e),select:e=>e.deliveries,enabled:!!e,refetchInterval:3e3})}function _(){let e=r();return a({mutationFn:e=>l.webhooks.create(e),onSuccess:()=>e.invalidateQueries({queryKey:[`webhooks`]})})}function v(){let e=r();return a({mutationFn:({id:e,...t})=>l.webhooks.update(e,t),onSuccess:()=>e.invalidateQueries({queryKey:[`webhooks`]})})}function y(){let e=r();return a({mutationFn:e=>l.webhooks.delete(e),onSuccess:()=>e.invalidateQueries({queryKey:[`webhooks`]})})}function b(){return a({mutationFn:e=>l.webhooks.rotate(e)})}function x(e){return[...new Set(e.split(`,`).map(e=>e.trim()).filter(Boolean))]}function S(e,t,n){return new URL(`/webhooks/${encodeURIComponent(e)}`,new URL(t,n)).href}function C(e){return[`localhost`,`127.0.0.1`,`[::1]`].includes(new URL(e).hostname)}var w=n();function T({id:e,testId:t,value:n,onChange:r,placeholder:i}){let[a,o]=(0,m.useState)(n.join(`, `));return(0,w.jsx)(d,{id:e,"data-testid":t,value:a,placeholder:i,onChange:e=>{o(e.target.value),r(e.target.value)}})}function E({projectId:e,onCreated:t}){let n=_(),[r,i]=(0,m.useState)(``),[a,c]=(0,m.useState)(`github`),[l,u]=(0,m.useState)(null),f=(0,m.useId)();return l?(0,w.jsxs)(`div`,{"data-testid":`webhook-created`,className:`space-y-3`,children:[(0,w.jsx)(A,{hook:l,secret:l.secret}),(0,w.jsx)(o,{type:`button`,variant:`outline`,"data-testid":`webhook-setup-done`,onClick:()=>{t?.(l),u(null),i(``)},children:`I've copied the setup details`})]}):(0,w.jsxs)(`div`,{className:`space-y-3`,"data-testid":`webhook-create-form`,children:[(0,w.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,w.jsx)(s,{htmlFor:`${f}-name`,children:`Webhook name`}),(0,w.jsx)(d,{id:`${f}-name`,"data-testid":`webhook-name`,value:r,onChange:e=>i(e.target.value),maxLength:100,placeholder:`GitHub repository events`})]}),(0,w.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,w.jsx)(s,{htmlFor:`${f}-provider`,children:`Provider`}),(0,w.jsxs)(`select`,{id:`${f}-provider`,"data-testid":`webhook-provider`,className:`w-full min-h-11 rounded-md border border-control-border bg-background px-3 text-sm`,value:a,onChange:e=>c(e.target.value),children:[(0,w.jsx)(`option`,{value:`github`,children:`GitHub`}),(0,w.jsx)(`option`,{value:`generic`,children:`Other service (HMAC)`})]})]}),(0,w.jsx)(`p`,{className:`text-xs text-outline`,children:`Create the event source here. Connect jobs and choose their event filters in Jobs. No job is required to create a webhook.`}),n.error&&(0,w.jsx)(`p`,{role:`alert`,className:`text-sm text-error`,children:n.error.message}),(0,w.jsx)(o,{type:`button`,"data-testid":`webhook-create`,disabled:!r.trim()||n.isPending,onClick:()=>n.mutate({name:r.trim(),provider:a,project_id:e??null},{onSuccess:u}),children:n.isPending?`Creating...`:`Create webhook`})]})}function D({value:e,onChange:t,projectId:n}){let{data:r,error:i,isLoading:a,refetch:c}=h(n),l=r?.filter(e=>e.project_id===null||e.project_id===n),[u,d]=(0,m.useState)(!1);function p(n){e.some(e=>e.webhook_id===n)||t([...e,{webhook_id:n,events:[],actions:[]}])}function g(n,r,i){t(e.map(e=>e.webhook_id===n?{...e,[r]:x(i)}:e))}return(0,w.jsxs)(`section`,{className:`space-y-3 border-y border-border py-4`,"data-testid":`job-webhook-picker`,children:[(0,w.jsx)(`h3`,{className:`text-sm font-medium`,children:`Which webhook should trigger this job?`}),i?(0,w.jsx)(f,{message:i.message,onRetry:()=>c()}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(s,{htmlFor:`job-webhook-source`,children:`Configured webhooks`}),(0,w.jsxs)(`select`,{id:`job-webhook-source`,"data-testid":`job-webhook-select`,className:`w-full min-h-11 rounded-md border border-control-border bg-background px-3 text-sm`,value:``,disabled:a,onChange:e=>{e.target.value&&p(e.target.value)},children:[(0,w.jsx)(`option`,{value:``,children:a?`Loading webhooks...`:`Select an existing webhook`}),(l??[]).filter(t=>!e.some(e=>e.webhook_id===t.id)).map(e=>(0,w.jsxs)(`option`,{value:e.id,children:[e.name,e.enabled?``:` (disabled)`]},e.id))]}),!a&&!l?.length&&(0,w.jsx)(`p`,{className:`text-xs text-outline`,children:`No webhooks configured for this project yet. Create one below or on the Webhooks page.`})]}),e.map(n=>(0,w.jsxs)(`div`,{className:`space-y-2 border-t border-border pt-3`,"data-testid":`job-webhook-binding`,"data-webhook-id":n.webhook_id,children:[(0,w.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,w.jsx)(`span`,{className:`text-sm font-medium`,children:l?.find(e=>e.id===n.webhook_id)?.name??n.webhook_id}),(0,w.jsx)(o,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`job-webhook-remove`,onClick:()=>t(e.filter(e=>e.webhook_id!==n.webhook_id)),children:`Disconnect`})]}),(0,w.jsx)(s,{htmlFor:`events-${n.webhook_id}`,children:`Events for this job`}),(0,w.jsx)(T,{id:`events-${n.webhook_id}`,testId:`webhook-events`,value:n.events,onChange:e=>g(n.webhook_id,`events`,e),placeholder:`pull_request, push (blank accepts all)`}),(0,w.jsx)(s,{htmlFor:`actions-${n.webhook_id}`,children:`Actions for this job (optional)`}),(0,w.jsx)(T,{id:`actions-${n.webhook_id}`,testId:`webhook-actions`,value:n.actions,onChange:e=>g(n.webhook_id,`actions`,e),placeholder:`opened, synchronize (blank accepts all)`})]},n.webhook_id)),(0,w.jsx)(o,{type:`button`,size:`sm`,variant:`outline`,"data-testid":`webhook-add`,onClick:()=>d(!u),children:u?`Close new webhook`:`Create a webhook`}),u&&(0,w.jsx)(E,{projectId:n,onCreated:e=>{p(e.id),d(!1)}})]})}function O({job:e}){let t=p(),[n,r]=(0,m.useState)(e.webhooks??[]);return(0,w.jsxs)(`section`,{className:`space-y-3`,"data-testid":`job-webhooks`,children:[!e.enabled&&(0,w.jsx)(`p`,{className:`text-sm text-outline`,children:`Job disabled. Configure connections now and enable it from Jobs when ready.`}),(0,w.jsx)(D,{value:n,onChange:r,projectId:e.project_id??void 0}),t.error&&(0,w.jsx)(`p`,{role:`alert`,className:`text-sm text-error`,children:t.error.message}),(0,w.jsx)(o,{type:`button`,size:`sm`,"data-testid":`job-webhooks-save`,disabled:t.isPending,onClick:()=>t.mutate({id:e.id,webhooks:n,trigger_type:`webhook`}),children:`Save connections`}),t.isSuccess&&(0,w.jsx)(`p`,{role:`status`,className:`text-xs text-outline`,children:`Connections saved.`}),(0,w.jsx)(u,{className:`inline-block text-sm underline`,to:`/webhooks?project=${encodeURIComponent(e.project_id??`all`)}`,children:`Manage configured webhooks and deliveries`})]})}function k({label:e,value:t,secret:n=!1}){let[r,i]=(0,m.useState)(!1),[a,s]=(0,m.useState)(!1);return(0,w.jsxs)(`div`,{className:`space-y-1`,children:[(0,w.jsx)(`p`,{className:`text-xs text-outline`,children:e}),(0,w.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,w.jsx)(`code`,{className:`min-w-0 flex-1 break-all text-xs`,"data-testid":n?`webhook-secret`:`webhook-url`,children:t}),(0,w.jsx)(o,{type:`button`,size:`sm`,variant:`outline`,"aria-label":`Copy ${e}`,onClick:async()=>{try{await navigator.clipboard.writeText(t),i(!0),s(!1)}catch{s(!0)}},children:r?`Copied`:`Copy`})]}),a&&(0,w.jsx)(`p`,{role:`alert`,className:`text-xs text-error`,children:`Select and copy the value above; clipboard access is unavailable.`})]})}function A({hook:e,secret:t}){let n=S(e.token,c(),window.location.origin);return(0,w.jsxs)(`div`,{className:`space-y-3`,"data-testid":`webhook-setup`,children:[(0,w.jsx)(k,{label:`Payload URL`,value:n}),C(n)&&(0,w.jsx)(`p`,{className:`text-sm text-warning`,children:`This address is local. For external providers, use your publicly reachable ORC address with the same /webhooks/ path.`}),t?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(k,{label:`Signing secret`,value:t,secret:!0}),(0,w.jsx)(`p`,{className:`text-xs text-outline`,children:`Copy the signing secret before leaving. It is shown once.`})]}):(0,w.jsx)(`p`,{className:`text-xs text-outline`,children:`The signing secret is hidden. Generate a replacement only if you need to reconnect the sender.`}),e.provider===`github`?(0,w.jsxs)(`ol`,{className:`list-decimal space-y-1 pl-5 text-sm text-outline`,children:[(0,w.jsx)(`li`,{children:`In your repository, open GitHub Settings - Webhooks - Add webhook.`}),(0,w.jsx)(`li`,{children:`Paste the Payload URL, select application/json, and enter the signing secret.`}),(0,w.jsx)(`li`,{children:`Select the events needed by your connected jobs. Each job has its own filters.`}),(0,w.jsx)(`li`,{children:`Send an event and inspect Recent deliveries below.`})]}):(0,w.jsx)(`p`,{className:`text-sm text-outline`,children:`Send JSON, signed with HMAC-SHA256 of the raw body. Set X-Orc-Signature-256 to sha256=<hex signature>, X-Orc-Event to the event name and X-Orc-Delivery to a unique delivery ID.`})]})}function j({hook:e}){let t=v(),n=b(),[r,i]=(0,m.useState)(!1),[a,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)();return(0,w.jsxs)(`article`,{className:`space-y-3 border-b border-border pb-5`,"data-testid":`webhook-endpoint`,"data-webhook-id":e.id,children:[(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,w.jsx)(`h3`,{className:`text-sm font-medium`,children:e.name}),(0,w.jsxs)(`span`,{className:`text-xs text-outline`,children:[e.provider,` - `,e.enabled?`Enabled`:`Disabled`]}),(0,w.jsx)(o,{type:`button`,variant:`outline`,size:`sm`,disabled:t.isPending,onClick:()=>t.mutate({id:e.id,enabled:!e.enabled}),children:e.enabled?`Disable`:`Enable`})]}),(0,w.jsxs)(`div`,{className:`space-y-1`,"data-testid":`webhook-connected-jobs`,children:[(0,w.jsxs)(`p`,{className:`text-xs text-outline`,children:[`Connected jobs (`,e.subscriptions.length,`)`]}),e.subscriptions.length?e.subscriptions.map(e=>(0,w.jsxs)(`div`,{className:`text-sm`,children:[(0,w.jsx)(u,{className:`underline`,"data-testid":`webhook-job-link`,to:`/jobs/${e.job_id}?project=all`,children:e.name}),(0,w.jsxs)(`span`,{className:`text-xs text-outline`,children:[` `,`- `,e.enabled?`Enabled`:`Disabled`,`; events:`,` `,e.events.join(`, `)||`all`,`; actions: `,e.actions.join(`, `)||`all`]})]},e.job_id)):(0,w.jsx)(`p`,{className:`text-sm text-outline`,children:`No connected jobs. Select this webhook when creating or editing a job.`})]}),(0,w.jsx)(A,{hook:e,secret:c}),(0,w.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,w.jsx)(o,{type:`button`,variant:`outline`,size:`sm`,"data-testid":`webhook-deliveries-toggle`,onClick:()=>i(!r),children:r?`Hide deliveries`:`Recent deliveries`}),(0,w.jsx)(o,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>s(!a),children:`New signing secret`})]}),a&&(0,w.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[(0,w.jsx)(`p`,{children:`The sender's existing secret will stop working. Update it after generating the replacement.`}),(0,w.jsx)(o,{type:`button`,variant:`outline`,size:`sm`,disabled:n.isPending,onClick:()=>n.mutate(e.id,{onSuccess:e=>{l(e.secret),s(!1)}}),children:`Generate replacement secret`})]}),(t.error||n.error)&&(0,w.jsx)(`p`,{role:`alert`,className:`text-sm text-error`,children:(t.error??n.error)?.message}),r&&(0,w.jsx)(M,{id:e.id})]})}function M({id:e}){let{data:t,isLoading:n,error:r,refetch:i}=g(e);return(0,w.jsxs)(`section`,{className:`space-y-2`,"data-testid":`webhook-deliveries`,children:[(0,w.jsx)(`h4`,{className:`text-sm font-medium`,children:`Recent deliveries`}),r?(0,w.jsx)(f,{message:r.message,onRetry:()=>i()}):n?(0,w.jsx)(`p`,{role:`status`,children:`Loading deliveries...`}):t?.length?t.map(e=>(0,w.jsxs)(`div`,{className:`space-y-1 border-t border-border py-2 text-xs`,"data-testid":`webhook-delivery`,children:[(0,w.jsxs)(`div`,{className:`flex flex-wrap justify-between gap-2`,children:[(0,w.jsxs)(`span`,{children:[e.event,e.action?` / ${e.action}`:``]}),(0,w.jsx)(`span`,{children:e.status})]}),(0,w.jsxs)(`p`,{className:`text-outline`,children:[e.repository,` `,new Date(e.created_at).toLocaleString()]}),e.status===`ignored`&&(0,w.jsx)(`p`,{className:`text-outline`,children:`No enabled connected job matched this event.`}),e.error&&(0,w.jsx)(`p`,{className:`text-error`,children:e.error}),e.runs.map(e=>(0,w.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,w.jsxs)(u,{className:`underline`,to:`/jobs/${e.job_id}?project=all`,children:[`Job run: `,e.status]}),e.task_id&&(0,w.jsx)(u,{className:`underline`,to:`/tasks/${e.task_id}?project=all`,children:`Created task`}),e.session_id&&(0,w.jsx)(u,{className:`underline`,to:`/audit/${e.session_id}?project=all`,children:`Agent session`})]},e.job_run_id))]},e.id)):(0,w.jsx)(`p`,{className:`text-sm text-outline`,children:`No events received yet. Register the endpoint with your provider, then send an event.`})]})}export{y as a,D as i,E as n,h as o,j as r,O as t};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{t as r}from"./button-BHKbOsmj.js";import{a as i,i as a,n as o,r as s,t as c}from"./select-CBHDS40x.js";import{t as l}from"./label-BQ1Lr4sA.js";import{t as u}from"./scroll-area-DMjOmHf5.js";import{t as d}from"./createLucideIcon-jLuHkL03.js";import{t as f}from"./chevron-down-D2sszSv3.js";import{At as p,Et as m,G as h,J as g,K as _,Nt as v,Ot as y,Tn as b,Tt as x,U as S,W as C,X as w,Y as T,_t as E,en as D,ft as O,kt as k,l as A,mn as j,on as M,sn as N,st as P,wt as F}from"./index-CMRGRbC9.js";import{t as I}from"./ConfirmDialog-D25Wf6Nc.js";import{t as L}from"./ErrorState-BoQqdsym.js";import{t as R}from"./ViewHeader-DHM9SSkD.js";import{t as z}from"./useDetailRoute-C8xQeILG.js";import{t as B}from"./EmptyState-YM4VSLR9.js";import{a as V,i as H,n as U,o as W,r as G,t as ee}from"./table-ByS-sgsb.js";import{t as te}from"./useProjectScope-CZEfU9mq.js";import{t as ne}from"./StatusBadge-CTFDUHuw.js";import{a as re,c as K,i as ie,l as q,n as ae,o as oe,r as se,s as ce,t as le}from"./useJobs-CCQUWZt3.js";import{n as ue,t as de}from"./useListSelection-CgpNqqAb.js";import{i as J,t as fe}from"./JobWebhooks-Z4MXZNvH.js";var Y={name:`play`,size:24,node:[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]};Y.node;var X=d(Y),pe={name:`power`,size:24,node:[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]};pe.node;var me=d(pe),Z=e(t(),1),Q=n();function $(e){return e.type===`command`?!!e.command.trim():e.type===`agent`?!!(e.prompt.trim()&&e.backend.trim()):!!e.title.trim()}function he({value:e,onChange:t}){let n=(0,Z.useId)(),{data:r}=O();return(0,Q.jsxs)(`section`,{className:`space-y-3 border-y border-border py-4`,"data-testid":`job-action-fields`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(l,{htmlFor:`${n}-type`,children:`What should this job do?`}),(0,Q.jsxs)(`select`,{id:`${n}-type`,"data-testid":`job-action-type`,className:`w-full min-h-11 rounded-md border border-control-border bg-background px-3 text-sm`,value:e.type,onChange:e=>{e.target.value===`command`&&t({type:`command`,command:``}),e.target.value===`agent`&&t({type:`agent`,backend:`codex-cli`,prompt:``,auto_approve:!1}),e.target.value===`task`&&t({type:`task`,title:``,body:``,start_automatically:!1})},children:[(0,Q.jsx)(`option`,{value:`command`,children:`Run command`}),(0,Q.jsx)(`option`,{value:`agent`,children:`Run agent`}),(0,Q.jsx)(`option`,{value:`task`,children:`Create task`})]})]}),e.type===`command`&&(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(l,{htmlFor:`${n}-command`,children:`Command`}),(0,Q.jsx)(v,{id:`${n}-command`,"aria-label":`Command`,"data-testid":`job-command-input`,value:e.command,onChange:n=>t({...e,command:n.target.value}),rows:3,placeholder:`bun run build`,required:!0})]}),e.type===`agent`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(l,{htmlFor:`${n}-backend`,children:`Agent backend`}),(0,Q.jsx)(F,{id:`${n}-backend`,"data-testid":`job-agent-backend`,value:e.backend,list:`${n}-backends`,onChange:n=>t({...e,backend:n.target.value}),required:!0}),(0,Q.jsx)(`datalist`,{id:`${n}-backends`,children:r?.backends.map(e=>(0,Q.jsx)(`option`,{value:e.name,children:e.available?`Available`:`Unavailable`},e.name))})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(l,{htmlFor:`${n}-model`,children:`Model (optional)`}),(0,Q.jsx)(F,{id:`${n}-model`,"data-testid":`job-agent-model`,value:e.model??``,onChange:n=>t({...e,model:n.target.value||void 0})})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(l,{htmlFor:`${n}-prompt`,children:`Instructions`}),(0,Q.jsx)(v,{id:`${n}-prompt`,"data-testid":`job-agent-prompt`,value:e.prompt,onChange:n=>t({...e,prompt:n.target.value}),required:!0,rows:4})]}),(0,Q.jsxs)(`label`,{className:`flex min-h-11 items-center gap-2 text-sm`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:e.auto_approve,onChange:n=>t({...e,auto_approve:n.target.checked})}),`Allow agent tools automatically`]}),(0,Q.jsx)(`p`,{className:`text-xs text-outline`,children:`Starts a tracked agent session. When automatic tool approval is off, permission requests are denied.`})]}),e.type===`task`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(l,{htmlFor:`${n}-title`,children:`Task title`}),(0,Q.jsx)(F,{id:`${n}-title`,"data-testid":`job-task-title`,value:e.title,onChange:n=>t({...e,title:n.target.value}),required:!0,maxLength:200})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(l,{htmlFor:`${n}-body`,children:`Task instructions`}),(0,Q.jsx)(v,{id:`${n}-body`,"data-testid":`job-task-body`,value:e.body,onChange:n=>t({...e,body:n.target.value}),rows:4})]}),(0,Q.jsxs)(`label`,{className:`flex min-h-11 items-center gap-2 text-sm`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,"data-testid":`job-task-autostart`,checked:e.start_automatically,onChange:n=>t({...e,start_automatically:n.target.checked})}),`Start the task flow automatically`]}),e.start_automatically&&(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(l,{htmlFor:`${n}-flow`,children:`Flow (blank uses the configured default)`}),(0,Q.jsx)(F,{id:`${n}-flow`,"data-testid":`job-task-flow`,value:e.flow_name??``,onChange:n=>t({...e,flow_name:n.target.value||void 0})})]}),(0,Q.jsx)(`p`,{className:`text-xs text-outline`,children:`Creates a task in this job's project. Automatic start is off by default; the task waits for a manual flow start.`})]})]})}function ge({jobId:e,open:t,onClose:n,onEdit:i}){let{data:a,isLoading:o,error:s,refetch:c}=se(e),{data:l,isLoading:u,error:d,refetch:f}=re(e),p=K(),m=q(),[v,y]=(0,Z.useState)(null);return(0,Q.jsx)(C,{open:t,onOpenChange:e=>!e&&n(),children:(0,Q.jsxs)(_,{"data-testid":`job-detail-sheet`,children:[(0,Q.jsxs)(T,{children:[(0,Q.jsx)(w,{children:a?.name??`Job details`}),a?.description&&(0,Q.jsx)(`p`,{className:`font-body text-xs text-outline mt-1`,children:a.description})]}),(0,Q.jsx)(h,{children:s?(0,Q.jsx)(L,{message:s.message,onRetry:()=>c()}):o?(0,Q.jsx)(`div`,{className:`space-y-3`,children:[...[,,,,,,]].map((e,t)=>(0,Q.jsx)(S,{className:`h-8 w-full bg-surface-highest`},t))}):a?(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(P,{label:`Action`,children:(0,Q.jsx)(`pre`,{className:`font-mono text-xs bg-background p-2 rounded-lg border border-surface-highest overflow-x-auto whitespace-pre-wrap break-all`,children:a.action?.type===`agent`?`Run agent (${a.action.backend}): ${a.action.prompt}`:a.action?.type===`task`?`Create task: ${a.action.title}`:a.command})}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-4`,children:[(0,Q.jsx)(P,{label:`Trigger Type`,children:(0,Q.jsx)(`span`,{className:`font-label text-xs px-2 py-0.5 bg-surface-highest text-on-surface-variant border border-surface-highest/50 inline-flex`,children:a.trigger_type})}),(0,Q.jsx)(P,{label:`Enabled`,children:(0,Q.jsx)(`span`,{className:`font-label text-xs font-bold ${a.enabled?`text-secondary`:`text-outline`}`,children:a.enabled?`● ON`:`○ OFF`})})]}),a.cron_expr&&(0,Q.jsx)(P,{label:`Cron Expression`,children:(0,Q.jsx)(`code`,{className:`font-mono text-xs`,children:a.cron_expr})}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-3 gap-4`,children:[(0,Q.jsxs)(P,{label:`Timeout`,children:[a.timeout_secs,`s`]}),(0,Q.jsx)(P,{label:`Max Retries`,children:a.max_retries}),(0,Q.jsx)(P,{label:`Overlap`,children:a.overlap})]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-4`,children:[(0,Q.jsx)(P,{label:`Notify On`,children:a.notify_on}),(0,Q.jsx)(P,{label:`Run Count`,children:a.run_count})]}),a.next_run_at&&(0,Q.jsx)(P,{label:`Next Run`,children:new Date(a.next_run_at).toLocaleString()})]}),!a.command.startsWith(`__`)&&(0,Q.jsx)(fe,{job:a},a.id),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`font-label text-xs font-medium text-outline mb-3`,children:`Recent runs`}),d?(0,Q.jsx)(L,{message:d.message,onRetry:()=>f()}):u?(0,Q.jsx)(`div`,{className:`space-y-2`,children:[...[,,,]].map((e,t)=>(0,Q.jsx)(S,{className:`h-8 w-full bg-surface-highest`},t))}):l?.length?(0,Q.jsx)(`div`,{className:`space-y-1`,children:l.map(t=>(0,Q.jsx)(_e,{run:t,jobId:e,expanded:v===t.id,onToggle:()=>y(v===t.id?null:t.id)},t.id))}):(0,Q.jsx)(`div`,{className:`font-label text-xs text-outline py-4 text-center`,children:`No runs yet`})]})]}):(0,Q.jsx)(`p`,{className:`text-sm text-outline`,children:`Job not found`})}),(0,Q.jsxs)(g,{className:`flex-wrap`,children:[(m.error||p.error)&&(0,Q.jsx)(`p`,{role:`alert`,className:`w-full text-sm text-error`,children:(m.error??p.error)?.message}),a&&i&&(0,Q.jsxs)(r,{"data-testid":`job-detail-edit`,size:`sm`,variant:`outline`,onClick:()=>i(a),children:[(0,Q.jsx)(N,{size:16}),`Edit job`]}),a&&(0,Q.jsxs)(r,{size:`sm`,variant:`ghost`,disabled:m.isPending,onClick:()=>m.mutate({id:a.id,enabled:!a.enabled}),className:`font-label text-xs font-medium`,children:[(0,Q.jsx)(me,{size:12,className:`mr-1.5`}),a.enabled?`Disable`:`Enable`]}),a&&(0,Q.jsxs)(r,{size:`sm`,disabled:p.isPending,onClick:()=>p.mutate(a.id),className:`font-label text-xs font-medium bg-transparent text-on-surface border border-control-border hover:bg-surface`,children:[(0,Q.jsx)(X,{size:12,className:`mr-1.5`}),p.isPending?`Triggering...`:`Trigger run`]})]})]})})}function _e({run:e,jobId:t,expanded:n,onToggle:r}){return(0,Q.jsxs)(`div`,{className:`min-w-0 border-y border-border overflow-hidden bg-background`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:r,"aria-expanded":n,className:`w-full flex items-center gap-3 px-3 py-2 hover:bg-surface transition-colors text-left`,children:[n?(0,Q.jsx)(f,{size:12,className:`text-outline shrink-0`}):(0,Q.jsx)(j,{size:12,className:`text-outline shrink-0`}),(0,Q.jsx)(ne,{status:e.status,type:`job`}),(0,Q.jsxs)(`span`,{className:`font-label text-xs text-outline flex-1`,children:[e.started_at?new Date(e.started_at).toLocaleString():`—`,e.ended_at&&(0,Q.jsxs)(`span`,{className:`ml-2`,children:[`\\u2192 `,new Date(e.ended_at).toLocaleString()]})]}),e.exit_code!==null&&(0,Q.jsxs)(`span`,{className:`font-mono text-xs ${e.exit_code===0?`text-secondary`:`text-error`}`,children:[`exit `,e.exit_code]})]}),(e.task_id||e.session_id)&&(0,Q.jsxs)(`div`,{className:`flex gap-3 px-3 py-2 text-xs`,children:[e.task_id&&(0,Q.jsx)(b,{className:`underline`,"data-testid":`job-run-task-link`,to:`/tasks/${e.task_id}?project=all`,children:`Created task`}),e.session_id&&(0,Q.jsx)(b,{className:`underline`,"data-testid":`job-run-session-link`,to:`/audit/${e.session_id}?project=all`,children:`Agent session`})]}),e.error_msg&&(0,Q.jsx)(`div`,{className:`px-3 pb-2`,children:(0,Q.jsx)(`span`,{className:`font-body text-xs text-error`,children:e.error_msg})}),n&&(0,Q.jsx)(ve,{jobId:t,runId:e.id})]})}function ve({jobId:e,runId:t}){let{data:n,isLoading:r,error:i,refetch:a}=ie(e,t);return i?(0,Q.jsx)(L,{message:i.message,onRetry:()=>a()}):r?(0,Q.jsx)(`div`,{className:`px-3 pb-3`,children:(0,Q.jsx)(S,{className:`h-24 w-full bg-surface-highest`})}):n?.length?(0,Q.jsx)(`div`,{className:`mx-3 mb-3 rounded-lg overflow-hidden border border-surface-highest`,children:(0,Q.jsx)(u,{className:`h-[240px]`,children:(0,Q.jsx)(`pre`,{className:`font-mono text-xs leading-relaxed bg-background p-3`,children:n.map(e=>(0,Q.jsx)(`div`,{className:e.stream===`stderr`?`text-error`:`text-on-surface`,children:e.line},e.id))})})}):(0,Q.jsx)(`div`,{className:`px-3 pb-3 font-label text-xs text-outline`,children:`No log output`})}var ye=[`one-shot`,`cron`,`watch`,`webhook`,`manual`,`bridge-msg`],be=[`skip`,`queue`,`kill`],xe=[`never`,`failure`,`always`];function Se({projectId:e}){let t=A(`sm`),n=te(e),i=n===`all`||n===`unassigned`?void 0:n,{data:a,isLoading:o,error:s,refetch:c}=oe({project_id:i,limit:100}),l=n===`unassigned`?a?.filter(e=>e.project_id===null):a,u=K(),d=ae(),f=q(),p=ce(),m=p.data?.scope===n?p.data:void 0,h=de((l??[]).map(e=>e.id),n);async function g(e){let t=await p.mutateAsync({ids:h.selectedIds,enabled:e,scope:n});h.select(t.failed.map(e=>e.id))}let{selectedId:_,openDetail:v,closeDetail:y}=z(`/jobs`,`jobId`),[b,x]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(null),[T,E]=(0,Z.useState)(null);if(s)return(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{title:`Jobs`}),(0,Q.jsx)(L,{message:s.message,onRetry:()=>c()})]});let O=(l??[]).filter(e=>e.enabled).length;return(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(R,{title:`Jobs`,meta:`${O}/${(l??[]).length} enabled`,action:(0,Q.jsxs)(r,{"data-testid":`new-job-button`,size:`sm`,onClick:()=>x(!0),className:`font-label text-xs font-medium bg-primary text-primary-foreground hover:bg-primary/90`,children:[(0,Q.jsx)(M,{size:12,className:`mr-1`}),` New job`]})}),(u.error||d.error||f.error)&&(0,Q.jsx)(`p`,{role:`alert`,className:`mb-4 text-sm text-error`,children:(u.error??d.error??f.error)?.message}),!!l?.length&&(0,Q.jsxs)(ue,{resourceLabel:`jobs`,count:h.selectedIds.length,allSelected:h.allSelected,someSelected:h.someSelected,onSelectAll:h.selectAll,onClear:h.clear,disabled:p.isPending,children:[(0,Q.jsx)(r,{type:`button`,variant:`outline`,size:`sm`,"data-testid":`jobs-bulk-enable`,disabled:p.isPending||f.isPending,onClick:()=>void g(!0),children:`Enable selected`}),(0,Q.jsx)(r,{type:`button`,variant:`outline`,size:`sm`,"data-testid":`jobs-bulk-disable`,disabled:p.isPending||f.isPending,onClick:()=>void g(!1),children:`Disable selected`})]}),p.isPending&&(0,Q.jsx)(`p`,{role:`status`,className:`mb-3 text-sm text-outline`,children:`Updating selected jobs…`}),!p.isPending&&m&&(0,Q.jsxs)(`div`,{className:`mb-3 space-y-1 text-sm`,"data-testid":`jobs-bulk-result`,role:`status`,children:[(0,Q.jsxs)(`p`,{children:[m.succeeded.length,` jobs `,m.enabled?`enabled`:`disabled`,`.`]}),m.failed.map(e=>(0,Q.jsxs)(`p`,{className:`text-error`,children:[l?.find(t=>t.id===e.id)?.name??e.id,`: `,e.error,`. Still selected for retry.`]},e.id))]}),o?(0,Q.jsx)(`div`,{role:`status`,"aria-label":`Loading jobs`,className:`space-y-2`,children:[...[,,,]].map((e,t)=>(0,Q.jsx)(S,{className:`h-12 w-full bg-surface-highest`},t))}):(l??[]).length===0?(0,Q.jsx)(B,{message:`No jobs configured`}):t?(0,Q.jsx)(`div`,{className:`min-w-0 overflow-hidden`,children:(0,Q.jsxs)(ee,{children:[(0,Q.jsx)(V,{children:(0,Q.jsxs)(W,{className:`border-b border-border hover:bg-transparent`,children:[(0,Q.jsx)(H,{className:`w-11`,children:(0,Q.jsx)(`span`,{className:`sr-only`,children:`Select jobs`})}),(0,Q.jsx)(H,{className:`font-label text-xs font-medium text-outline`,children:`Name`}),(0,Q.jsx)(H,{className:`font-label text-xs font-medium text-outline w-24`,children:`Trigger`}),(0,Q.jsx)(H,{className:`font-label text-xs font-medium text-outline w-48`,children:`Action`}),(0,Q.jsx)(H,{className:`font-label text-xs font-medium text-outline w-16`,children:`Enabled`}),(0,Q.jsx)(H,{className:`font-label text-xs font-medium text-outline w-36`,children:`Last Run`}),(0,Q.jsx)(H,{className:`font-label text-xs font-medium text-outline w-16`,children:`Runs`}),(0,Q.jsx)(H,{className:`font-label text-xs font-medium text-outline w-36`,children:`Next Run`}),(0,Q.jsx)(H,{className:`w-28`})]})}),(0,Q.jsx)(U,{children:(l??[]).map(e=>(0,Q.jsxs)(W,{"data-testid":`job-row`,"data-job-id":e.id,"data-job-name":e.name,className:`border-b border-border/65 hover:bg-surface-high cursor-pointer`,onClick:()=>v(e.id),children:[(0,Q.jsx)(G,{children:(0,Q.jsx)(`input`,{type:`checkbox`,className:`size-4 accent-primary`,"aria-label":`Select ${e.name}`,"data-testid":`job-select`,checked:h.selectedIds.includes(e.id),disabled:p.isPending,onClick:e=>e.stopPropagation(),onChange:()=>h.toggle(e.id)})}),(0,Q.jsxs)(G,{children:[(0,Q.jsx)(`button`,{type:`button`,className:`font-body text-sm font-medium text-on-surface text-left hover:text-primary`,"data-testid":`job-open-detail`,onClick:t=>{t.stopPropagation(),v(e.id)},children:e.name}),e.description&&(0,Q.jsx)(`div`,{className:`font-body text-sm text-outline mt-0.5 truncate max-w-[200px]`,children:e.description})]}),(0,Q.jsx)(G,{children:(0,Q.jsx)(`span`,{className:`font-label text-xs text-on-surface-variant inline-flex`,children:e.trigger_type})}),(0,Q.jsx)(G,{children:(0,Q.jsx)(`code`,{className:`font-mono text-xs text-outline truncate block max-w-[180px]`,children:e.action?.type===`agent`?`Agent: ${e.action.backend}`:e.action?.type===`task`?`Task: ${e.action.title}`:e.command})}),(0,Q.jsx)(G,{children:(0,Q.jsx)(r,{type:`button`,"data-testid":`job-toggle-enabled`,variant:`outline`,size:`sm`,"aria-label":`${e.enabled?`Disable`:`Enable`} ${e.name}`,"aria-pressed":e.enabled,disabled:f.isPending||p.isPending,onClick:t=>{t.stopPropagation(),f.mutate({id:e.id,enabled:!e.enabled})},children:e.enabled?`Disable`:`Enable`})}),(0,Q.jsx)(G,{className:`font-label text-xs text-outline`,children:e.last_run_at?new Date(e.last_run_at).toLocaleString():`—`}),(0,Q.jsx)(G,{className:`font-label text-xs text-outline`,children:e.run_count}),(0,Q.jsx)(G,{className:`font-label text-xs text-outline`,children:e.next_run_at?new Date(e.next_run_at).toLocaleString():`—`}),(0,Q.jsx)(G,{children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,onClick:e=>e.stopPropagation(),children:[(0,Q.jsxs)(r,{"data-testid":`job-trigger`,size:`sm`,disabled:u.isPending,onClick:()=>u.mutate(e.id),className:`font-label text-sm min-h-11 px-3 bg-transparent text-on-surface border border-border hover:bg-surface-high`,children:[(0,Q.jsx)(X,{size:10,className:`mr-1`}),` Run`]}),(0,Q.jsx)(`button`,{type:`button`,"data-testid":`job-edit`,"aria-label":`Edit ${e.name}`,onClick:()=>w(e),className:`inline-flex min-h-11 min-w-11 items-center justify-center rounded-md text-outline hover:text-primary hover:bg-surface-highest`,children:(0,Q.jsx)(N,{size:16})}),(0,Q.jsx)(`button`,{type:`button`,"data-testid":`job-delete`,"aria-label":`Delete ${e.name}`,onClick:()=>E(e),className:`inline-flex min-h-11 min-w-11 items-center justify-center rounded-md text-outline hover:text-error hover:bg-error/10`,children:(0,Q.jsx)(D,{size:12})})]})})]},e.id))})]})}):(0,Q.jsx)(`div`,{className:`space-y-3`,children:(l??[]).map(e=>(0,Q.jsxs)(`article`,{"data-testid":`job-row`,"data-job-id":e.id,"data-job-name":e.name,className:`border-b border-border/65 py-4 space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,className:`size-4 accent-primary shrink-0 mt-1`,"aria-label":`Select ${e.name}`,"data-testid":`job-select`,checked:h.selectedIds.includes(e.id),disabled:p.isPending,onChange:()=>h.toggle(e.id)}),(0,Q.jsx)(`button`,{type:`button`,className:`min-w-0 text-left font-medium text-sm text-on-surface wrap-break-word hover:text-primary`,"data-testid":`job-open-detail`,onClick:()=>v(e.id),children:e.name}),(0,Q.jsx)(r,{type:`button`,"data-testid":`job-toggle-enabled`,variant:`outline`,size:`sm`,"aria-label":`${e.enabled?`Disable`:`Enable`} ${e.name}`,"aria-pressed":e.enabled,disabled:f.isPending||p.isPending,onClick:()=>f.mutate({id:e.id,enabled:!e.enabled}),children:e.enabled?`Disable`:`Enable`})]}),e.description&&(0,Q.jsx)(`p`,{className:`text-sm text-outline wrap-break-word`,children:e.description}),(0,Q.jsx)(`code`,{className:`block whitespace-pre-wrap break-all text-xs text-on-surface-variant`,children:e.action?.type===`agent`?`Agent: ${e.action.backend}`:e.action?.type===`task`?`Task: ${e.action.title}`:e.command}),(0,Q.jsxs)(`p`,{className:`text-xs text-outline`,children:[e.trigger_type,` · `,e.run_count,` runs`,e.next_run_at?` · Next: ${new Date(e.next_run_at).toLocaleString()}`:``]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2 border-t border-border pt-3`,children:[(0,Q.jsxs)(r,{"data-testid":`job-edit`,variant:`outline`,size:`sm`,onClick:()=>w(e),children:[(0,Q.jsx)(N,{}),`Edit`]}),(0,Q.jsxs)(r,{"data-testid":`job-trigger`,variant:`outline`,size:`sm`,disabled:u.isPending,onClick:()=>u.mutate(e.id),children:[(0,Q.jsx)(X,{}),`Run`]}),(0,Q.jsx)(r,{"data-testid":`job-delete`,"aria-label":`Delete ${e.name}`,variant:`ghost`,size:`icon`,onClick:()=>E(e),children:(0,Q.jsx)(D,{})})]})]},e.id))}),(0,Q.jsx)(ge,{jobId:_,open:!!_,onClose:y,onEdit:e=>{y(),w(e)}}),b&&(0,Q.jsx)(Ce,{defaultProjectId:i,open:b,onClose:()=>x(!1)}),C&&(0,Q.jsx)(we,{job:C,open:!!C,onClose:()=>w(null)}),T&&(0,Q.jsx)(I,{open:!!T,title:`Delete Job`,description:`Delete job "${T.name}"? This cannot be undone.`,confirmLabel:`Delete`,variant:`destructive`,isPending:d.isPending,onConfirm:()=>{d.mutate(T.id,{onSuccess:()=>E(null)})},onCancel:()=>E(null)})]})}function Ce({defaultProjectId:e,open:t,onClose:n}){let{data:u}=E(),[d,f]=(0,Z.useState)(``),[h,g]=(0,Z.useState)(``),[_,v]=(0,Z.useState)({type:`command`,command:``}),[b,S]=(0,Z.useState)([]),[C,w]=(0,Z.useState)(`manual`),[T,D]=(0,Z.useState)(``),[O,A]=(0,Z.useState)(`300`),[j,M]=(0,Z.useState)(`0`),[N,P]=(0,Z.useState)(`skip`),[I,L]=(0,Z.useState)(`failure`),[R,z]=(0,Z.useState)(``),[B,V]=(0,Z.useState)(e??``),H=le(),[U,W]=(0,Z.useState)(!1);return(0,Q.jsx)(x,{open:t,onOpenChange:e=>!e&&n(),children:(0,Q.jsxs)(m,{className:`bg-surface border-border max-w-lg max-h-[85dvh] overflow-y-auto`,children:[(0,Q.jsx)(k,{children:(0,Q.jsx)(p,{className:`font-headline text-sm font-medium text-on-surface`,children:`New job`})}),(0,Q.jsxs)(`form`,{onSubmit:e=>{if(e.preventDefault(),!d.trim()||!$(_)||C===`webhook`&&!b.length)return;let t={name:d.trim(),description:h.trim(),action:_,webhooks:C===`webhook`?b:[],trigger_type:C,enabled:U,cron_expr:C===`cron`&&T.trim()||void 0,timeout_secs:Number.parseInt(O,10)||void 0,max_retries:Number.parseInt(j,10),overlap:N,notify_on:I,project_id:B||void 0,working_dir:R.trim()||void 0};H.mutate(t,{onSuccess:n})},className:`space-y-3 mt-2`,children:[(0,Q.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,"data-testid":`job-create-enabled`,checked:U,onChange:e=>W(e.target.checked),className:`size-4 accent-primary`}),`Enable this job immediately`]}),(0,Q.jsx)(`p`,{className:`text-xs text-outline`,children:`New jobs stay disabled until you enable them. You can configure their webhook first.`}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(l,{className:`font-label text-xs font-medium text-outline`,children:`Name *`}),(0,Q.jsx)(F,{"aria-label":`Name`,"data-testid":`job-name-input`,value:d,onChange:e=>f(e.target.value),placeholder:`Job name...`,className:`bg-background border-control-border text-on-surface font-body text-sm`,autoFocus:!0})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(l,{className:`font-label text-xs font-medium text-outline`,children:`Description`}),(0,Q.jsx)(F,{"aria-label":`Description`,value:h,onChange:e=>g(e.target.value),placeholder:`Optional description...`,className:`bg-background border-control-border text-on-surface font-body text-sm`})]}),(0,Q.jsx)(he,{value:_,onChange:v}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(l,{className:`font-label text-xs font-medium text-outline`,children:`Trigger Type`}),(0,Q.jsxs)(c,{value:C,onValueChange:e=>w(e),children:[(0,Q.jsx)(a,{"aria-label":`Trigger type`,"data-testid":`job-trigger-type`,className:`bg-background border-control-border text-on-surface font-body text-sm min-h-11`,children:(0,Q.jsx)(i,{})}),(0,Q.jsx)(o,{className:`bg-surface border-border`,children:ye.map(e=>(0,Q.jsx)(s,{value:e,"data-testid":`job-trigger-${e}`,className:`font-body text-sm`,children:e},e))})]})]}),C===`webhook`&&(0,Q.jsx)(`div`,{className:`sm:col-span-2`,children:(0,Q.jsx)(J,{value:b,onChange:S,projectId:B||void 0})}),C===`cron`&&(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(l,{className:`font-label text-xs font-medium text-outline`,children:`Cron Expression`}),(0,Q.jsx)(F,{"aria-label":`Cron expression`,value:T,onChange:e=>D(e.target.value),placeholder:`*/5 * * * *`,className:`bg-background border-control-border text-on-surface font-mono text-xs`})]})]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-3 gap-3`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(l,{className:`font-label text-xs font-medium text-outline`,children:`Timeout (s)`}),(0,Q.jsx)(F,{"aria-label":`Timeout in seconds`,type:`number`,min:1,required:!0,value:O,onChange:e=>A(e.target.value),className:`bg-background border-control-border text-on-surface font-body text-sm`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(l,{className:`font-label text-xs font-medium text-outline`,children:`Max Retries`}),(0,Q.jsx)(F,{"aria-label":`Maximum retries`,type:`number`,min:0,required:!0,value:j,onChange:e=>M(e.target.value),className:`bg-background border-control-border text-on-surface font-body text-sm`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(l,{className:`font-label text-xs font-medium text-outline`,children:`Overlap`}),(0,Q.jsxs)(c,{value:N,onValueChange:e=>P(e),children:[(0,Q.jsx)(a,{"aria-label":`Overlap`,className:`bg-background border-control-border text-on-surface font-body text-sm min-h-11`,children:(0,Q.jsx)(i,{})}),(0,Q.jsx)(o,{className:`bg-surface border-border`,children:be.map(e=>(0,Q.jsx)(s,{value:e,className:`font-body text-sm`,children:e},e))})]})]})]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(l,{className:`font-label text-xs font-medium text-outline`,children:`Notify On`}),(0,Q.jsxs)(c,{value:I,onValueChange:e=>L(e),children:[(0,Q.jsx)(a,{"aria-label":`Notify on`,className:`bg-background border-control-border text-on-surface font-body text-sm min-h-11`,children:(0,Q.jsx)(i,{})}),(0,Q.jsx)(o,{className:`bg-surface border-border`,children:xe.map(e=>(0,Q.jsx)(s,{value:e,className:`font-body text-sm`,children:e},e))})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(l,{className:`font-label text-xs font-medium text-outline`,children:`Working Dir`}),(0,Q.jsx)(F,{"aria-label":`Working directory`,value:R,onChange:e=>z(e.target.value),placeholder:`/path/to/dir`,className:`bg-background border-control-border text-on-surface font-body text-sm`})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(l,{className:`font-label text-xs font-medium text-outline`,children:`Project`}),(0,Q.jsxs)(c,{value:B||`__none__`,onValueChange:e=>{V(e===`__none__`?``:e),S([])},children:[(0,Q.jsx)(a,{"aria-label":`Project`,"data-testid":`job-project-select`,className:`bg-background border-control-border text-on-surface font-body text-sm min-h-11`,children:(0,Q.jsx)(i,{})}),(0,Q.jsxs)(o,{className:`bg-surface border-border`,children:[(0,Q.jsx)(s,{value:`__none__`,className:`font-body text-sm`,children:`None`}),u?.map(e=>(0,Q.jsx)(s,{value:e.id,className:`font-body text-sm`,children:e.name},e.id))]})]})]}),(0,Q.jsxs)(y,{children:[(0,Q.jsx)(r,{type:`button`,variant:`ghost`,size:`sm`,onClick:n,className:`font-label text-xs text-outline`,children:`Cancel`}),(0,Q.jsx)(r,{"data-testid":`job-submit`,type:`submit`,size:`sm`,disabled:H.isPending||!d.trim()||!$(_)||C===`webhook`&&!b.length,className:`font-label text-xs bg-primary text-primary-foreground hover:bg-primary/90`,children:H.isPending?`Creating...`:C===`webhook`?`Create job`:`Create`})]}),H.error&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-error`,children:H.error.message})]})]})})}function we({job:e,open:t,onClose:n}){let[u,d]=(0,Z.useState)(e.name),[f,h]=(0,Z.useState)(e.description??``),[g,_]=(0,Z.useState)(e.action??{type:`command`,command:e.command}),[v,b]=(0,Z.useState)(e.webhooks??[]),[S,C]=(0,Z.useState)(e.trigger_type),[w,T]=(0,Z.useState)(e.cron_expr??``),[E,D]=(0,Z.useState)(String(e.timeout_secs)),[O,A]=(0,Z.useState)(String(e.max_retries)),[j,M]=(0,Z.useState)(e.overlap),[N,P]=(0,Z.useState)(e.notify_on),[I,L]=(0,Z.useState)(e.enabled),R=q();return(0,Q.jsx)(x,{open:t,onOpenChange:e=>!e&&n(),children:(0,Q.jsxs)(m,{className:`bg-surface border-border max-w-lg max-h-[85dvh] overflow-y-auto`,children:[(0,Q.jsx)(k,{children:(0,Q.jsx)(p,{className:`font-headline text-sm font-medium text-on-surface`,children:`Edit job`})}),(0,Q.jsxs)(`form`,{id:`edit-job-form`,onSubmit:t=>{if(t.preventDefault(),!u.trim()||!$(g)||S===`webhook`&&!v.length)return;let r={id:e.id,name:u.trim(),description:f.trim(),action:g,webhooks:S===`webhook`?v:[],trigger_type:S,cron_expr:S===`cron`&&w.trim()||void 0,timeout_secs:Number.parseInt(E,10)||void 0,max_retries:Number.parseInt(O,10),overlap:j,notify_on:N,enabled:I};R.mutate(r,{onSuccess:n})},className:`space-y-3 mt-2`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(l,{className:`font-label text-xs font-medium text-outline`,children:`Name *`}),(0,Q.jsx)(F,{"aria-label":`Name`,value:u,onChange:e=>d(e.target.value),className:`bg-background border-control-border text-on-surface font-body text-sm`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(l,{className:`font-label text-xs font-medium text-outline`,children:`Description`}),(0,Q.jsx)(F,{"aria-label":`Description`,value:f,onChange:e=>h(e.target.value),className:`bg-background border-control-border text-on-surface font-body text-sm`})]}),(0,Q.jsx)(he,{value:g,onChange:_}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(l,{className:`font-label text-xs font-medium text-outline`,children:`Trigger Type`}),(0,Q.jsxs)(c,{value:S,onValueChange:e=>C(e),children:[(0,Q.jsx)(a,{"aria-label":`Trigger type`,"data-testid":`job-trigger-type`,className:`bg-background border-control-border text-on-surface font-body text-sm min-h-11`,children:(0,Q.jsx)(i,{})}),(0,Q.jsx)(o,{className:`bg-surface border-border`,children:ye.map(e=>(0,Q.jsx)(s,{value:e,"data-testid":`job-trigger-${e}`,className:`font-body text-sm`,children:e},e))})]})]}),S===`webhook`&&(0,Q.jsx)(`div`,{className:`sm:col-span-2`,children:(0,Q.jsx)(J,{value:v,onChange:b,projectId:e.project_id??void 0})}),S===`cron`&&(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(l,{className:`font-label text-xs font-medium text-outline`,children:`Cron Expression`}),(0,Q.jsx)(F,{"aria-label":`Cron expression`,value:w,onChange:e=>T(e.target.value),placeholder:`*/5 * * * *`,className:`bg-background border-control-border text-on-surface font-mono text-xs`})]})]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-3 gap-3`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(l,{className:`font-label text-xs font-medium text-outline`,children:`Timeout (s)`}),(0,Q.jsx)(F,{"aria-label":`Timeout in seconds`,type:`number`,min:1,required:!0,value:E,onChange:e=>D(e.target.value),className:`bg-background border-control-border text-on-surface font-body text-sm`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(l,{className:`font-label text-xs font-medium text-outline`,children:`Max Retries`}),(0,Q.jsx)(F,{"aria-label":`Maximum retries`,type:`number`,min:0,required:!0,value:O,onChange:e=>A(e.target.value),className:`bg-background border-control-border text-on-surface font-body text-sm`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(l,{className:`font-label text-xs font-medium text-outline`,children:`Overlap`}),(0,Q.jsxs)(c,{value:j,onValueChange:e=>M(e),children:[(0,Q.jsx)(a,{"aria-label":`Overlap`,className:`bg-background border-control-border text-on-surface font-body text-sm min-h-11`,children:(0,Q.jsx)(i,{})}),(0,Q.jsx)(o,{className:`bg-surface border-border`,children:be.map(e=>(0,Q.jsx)(s,{value:e,className:`font-body text-sm`,children:e},e))})]})]})]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(l,{className:`font-label text-xs font-medium text-outline`,children:`Notify On`}),(0,Q.jsxs)(c,{value:N,onValueChange:e=>P(e),children:[(0,Q.jsx)(a,{"aria-label":`Notify on`,className:`bg-background border-control-border text-on-surface font-body text-sm min-h-11`,children:(0,Q.jsx)(i,{})}),(0,Q.jsx)(o,{className:`bg-surface border-border`,children:xe.map(e=>(0,Q.jsx)(s,{value:e,className:`font-body text-sm`,children:e},e))})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(l,{className:`font-label text-xs font-medium text-outline`,children:`Enabled`}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>L(!I),className:`w-full min-h-11 rounded-md flex items-center justify-center border font-label text-xs font-medium transition-colors ${I?`bg-surface-highest text-on-surface border-border`:`bg-background text-outline border-border`}`,children:I?`● Enabled`:`○ Disabled`})]})]})]}),(0,Q.jsxs)(y,{children:[(0,Q.jsx)(r,{type:`button`,variant:`ghost`,size:`sm`,onClick:n,className:`font-label text-xs text-outline`,children:`Cancel`}),(0,Q.jsx)(r,{"data-testid":`job-edit-submit`,form:`edit-job-form`,type:`submit`,size:`sm`,disabled:R.isPending||!u.trim()||!$(g)||S===`webhook`&&!v.length,className:`font-label text-xs bg-primary text-primary-foreground hover:bg-primary/90`,children:R.isPending?`Saving...`:`Save`})]}),R.error&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-error`,children:R.error.message})]})})}export{Se as default};