factory-factory 0.5.6 → 0.5.7

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 (106) hide show
  1. package/dist/client/assets/{DotsThree.es-Dx8TXzzQ.js → DotsThree.es-6Y3ru9Fr.js} +1 -1
  2. package/dist/client/assets/{abnfDiagram-WEYOIA3C-D-WiX0ND.js → abnfDiagram-WEYOIA3C-Bz-2NjrY.js} +1 -1
  3. package/dist/client/assets/{admin-page-BdYXlEfi.js → admin-page-N8bqsl_U.js} +1 -1
  4. package/dist/client/assets/{agent-authoring-CzgCC7xn.js → agent-authoring-C33uSQgC.js} +1 -1
  5. package/dist/client/assets/{agents-CIGVR3Yk.js → agents-BNAsXKbn.js} +1 -1
  6. package/dist/client/assets/{agents-B6BxITMg.js → agents-MwqMFVNs.js} +1 -1
  7. package/dist/client/assets/{architectureDiagram-ZHVYKT53-D-Nk4IRx.js → architectureDiagram-ZHVYKT53-CpoGyKeM.js} +1 -1
  8. package/dist/client/assets/{chat-BsZewCkt.js → chat-B7u27d-i.js} +5 -5
  9. package/dist/client/assets/{chunk-2E7WHVMD-DsLW-8KW.js → chunk-2E7WHVMD-Baod-BdE.js} +1 -1
  10. package/dist/client/assets/{chunk-NQOKRVIF-CMnJ0k4D.js → chunk-NQOKRVIF-LCflra3k.js} +1 -1
  11. package/dist/client/assets/{classDiagram-v2-4MYWR3UA-BRoc4t8Q.js → classDiagram-v2-4MYWR3UA-MRjV_MIA.js} +1 -1
  12. package/dist/client/assets/client-modules.json +1 -1
  13. package/dist/client/assets/{codex-accounts-C8imj_4P.js → codex-accounts-DP-Tb-tZ.js} +1 -1
  14. package/dist/client/assets/{cynefinDiagram-WF24UDRP-6T3PH0XT.js → cynefinDiagram-WF24UDRP-bzsiqTUL.js} +1 -1
  15. package/dist/client/assets/{data-import-button-BH9f-Pg6.js → data-import-button-BqRlwClc.js} +1 -1
  16. package/dist/client/assets/{detail-C4NZBe6t.js → detail-BXmaqHTp.js} +2 -2
  17. package/dist/client/assets/{diagram-CBK3MWTC-YepopftI.js → diagram-CBK3MWTC-DjtO1Qi7.js} +1 -1
  18. package/dist/client/assets/{diagram-I5XIIV2D-BJli7Wmv.js → diagram-I5XIIV2D-EW0H2MNl.js} +1 -1
  19. package/dist/client/assets/{diagram-ODIL2UCW-CSqmCku9.js → diagram-ODIL2UCW-DSWSmg75.js} +1 -1
  20. package/dist/client/assets/{diagram-RJA3I4VV-Din95BTu.js → diagram-RJA3I4VV-DGCPPXy9.js} +1 -1
  21. package/dist/client/assets/{diagram-TYUNFSNR-DDVwAmk7.js → diagram-TYUNFSNR-BRE0O5UU.js} +1 -1
  22. package/dist/client/assets/{diff-viewer-DNUPJg_G.js → diff-viewer-B2pMcSUo.js} +1 -1
  23. package/dist/client/assets/{ebnfDiagram-V4P3TTPT-Bt8SCelN.js → ebnfDiagram-V4P3TTPT-LN1BHyLk.js} +1 -1
  24. package/dist/client/assets/{erDiagram-KYQIGQAA-BDYCjid-.js → erDiagram-KYQIGQAA-BagoNO7h.js} +1 -1
  25. package/dist/client/assets/{event-agent-workspace-form-CWmktyXd.js → event-agent-workspace-form-D6EZQxOA.js} +1 -1
  26. package/dist/client/assets/{file-viewer-CbXNMHbC.js → file-viewer-ByqeZE0U.js} +1 -1
  27. package/dist/client/assets/{flowDiagram-IUGLLWBU-CJN9xdYn.js → flowDiagram-IUGLLWBU-D263u80I.js} +1 -1
  28. package/dist/client/assets/{highlighted-body-JLMTFACH-Dy-R6Y8r.js → highlighted-body-JLMTFACH-CMb21a0T.js} +1 -1
  29. package/dist/client/assets/{home-pNFIyVOJ.js → home-9nWsYf3c.js} +1 -1
  30. package/dist/client/assets/index-ClP2IiKy.css +2 -0
  31. package/dist/client/assets/index-GmSorqXd.js +12 -0
  32. package/dist/client/assets/{infoDiagram-MVDRKAX5-CZx5KLLZ.js → infoDiagram-MVDRKAX5-DqtZTfKx.js} +1 -1
  33. package/dist/client/assets/{inline-workspace-form-DvVz3qgr.js → inline-workspace-form-DTOd1_IQ.js} +1 -1
  34. package/dist/client/assets/{ishikawaDiagram-HPEHV2GE-C0ax8nAT.js → ishikawaDiagram-HPEHV2GE-S--AK0b5.js} +1 -1
  35. package/dist/client/assets/{issue-launch-sheet-Cvig-i15.js → issue-launch-sheet-Cmq9AmXu.js} +1 -1
  36. package/dist/client/assets/{kanban-CWhDBIAX.js → kanban-DFqdaBrr.js} +1 -1
  37. package/dist/client/assets/{kanban-card-xzqAUkmg.js → kanban-card-CKNGUrJa.js} +1 -1
  38. package/dist/client/assets/{kanban-definition-FNSA4HC5-FG4uAvnN.js → kanban-definition-FNSA4HC5-BstZV_2x.js} +1 -1
  39. package/dist/client/assets/{legacy-COQTLf7j.js → legacy-BK7U5o2y.js} +1 -1
  40. package/dist/client/assets/{legacy-xGT-esX6.js → legacy-D010j6qa.js} +1 -1
  41. package/dist/client/assets/{list-DhQWjiv0.js → list-C2HYpkqg.js} +1 -1
  42. package/dist/client/assets/{list-sOGdiDXi.js → list-DG7Grxw5.js} +1 -1
  43. package/dist/client/assets/{logs-DOOyulI5.js → logs-C5_FYDNK.js} +1 -1
  44. package/dist/client/assets/mermaid-WFAXDIZX-ClIEnuTo.js +1 -0
  45. package/dist/client/assets/{mermaid-diagram-DHR-LEin.js → mermaid-diagram-7d3eG33H.js} +4 -4
  46. package/dist/client/assets/{mindmap-definition-6OY57UG3-B3bdhe56.js → mindmap-definition-6OY57UG3-flOx3ZeG.js} +1 -1
  47. package/dist/client/assets/{mobile-baseline-C2AnUNW1.js → mobile-baseline-oXH_VGTz.js} +1 -1
  48. package/dist/client/assets/new-C8WYrcew.js +1 -0
  49. package/dist/client/assets/{new-BJg9Bigj.js → new-COoW_By1.js} +1 -1
  50. package/dist/client/assets/{pegDiagram-ECIUJNBX-DOYkHKRd.js → pegDiagram-ECIUJNBX-BrDIK58N.js} +1 -1
  51. package/dist/client/assets/{pieDiagram-GNMPY74T-8JeV6xrB.js → pieDiagram-GNMPY74T-BMzBw5t-.js} +1 -1
  52. package/dist/client/assets/{pr-inbox-item-BGuMexFr.js → pr-inbox-item-vHdTaoxd.js} +1 -1
  53. package/dist/client/assets/project-CBrecHcv.js +1 -0
  54. package/dist/client/assets/project-header-BG9_VlHh.js +1 -0
  55. package/dist/client/assets/{project-repo-form-8h-x4Jm-.js → project-repo-form-6aODqQni.js} +1 -1
  56. package/dist/client/assets/{provider-cli-warning-B6YVtj_C.js → provider-cli-warning-Bcg15rKf.js} +1 -1
  57. package/dist/client/assets/{query-state-DeXwsPfq.js → query-state-BVQj0phN.js} +1 -1
  58. package/dist/client/assets/{railroadDiagram-Y72NRBL7-D6nXF23_.js → railroadDiagram-Y72NRBL7-3Eck62Bi.js} +1 -1
  59. package/dist/client/assets/{requirementDiagram-EQYSW5RA-CjjGJH_A.js → requirementDiagram-EQYSW5RA-rbuIMTLU.js} +1 -1
  60. package/dist/client/assets/{reviews-r5Fft2S9.js → reviews-Dbotug95.js} +1 -1
  61. package/dist/client/assets/{right-panel-BUm-IUuW.js → right-panel-DaLnLjFu.js} +2 -2
  62. package/dist/client/assets/{sequenceDiagram-BLEHNHQU-X8vRIVgX.js → sequenceDiagram-BLEHNHQU-CvP7tfWl.js} +1 -1
  63. package/dist/client/assets/{settings-page-layout-Cyc2QcuG.js → settings-page-layout-DWVd1wTJ.js} +1 -1
  64. package/dist/client/assets/{setup-terminal-modal-CRZrWgCt.js → setup-terminal-modal--e19kzCo.js} +2 -2
  65. package/dist/client/assets/{startup-script-form-edXnfByI.js → startup-script-form-BX-97uzx.js} +1 -1
  66. package/dist/client/assets/{stateDiagram-v2-A6IESKWZ-Bum1zshG.js → stateDiagram-v2-A6IESKWZ-DPQNuXMb.js} +1 -1
  67. package/dist/client/assets/{swimlanesDiagram-AYQRV4AK-DBKC7Yfq.js → swimlanesDiagram-AYQRV4AK-DBayrG3m.js} +1 -1
  68. package/dist/client/assets/{terminal-instance-Y05XGV6V.js → terminal-instance-Bhh6-6sl.js} +1 -1
  69. package/dist/client/assets/{timeline-definition-JXYKGLGB-CLF-s_Xn.js → timeline-definition-JXYKGLGB-C14nrPRo.js} +1 -1
  70. package/dist/client/assets/{transcript-scroll-fixture-DNVPzw5t.js → transcript-scroll-fixture-CLt6Bmfz.js} +1 -1
  71. package/dist/client/assets/use-project-header-navigation-D_Gx1LQ9.js +1 -0
  72. package/dist/client/assets/{use-workspace-creation-draft-Bl2dlNzf.js → use-workspace-creation-draft-BcIClFw-.js} +1 -1
  73. package/dist/client/assets/{use-workspace-project-navigation-B0LZj578.js → use-workspace-project-navigation-D6kEMUHY.js} +1 -1
  74. package/dist/client/assets/{usecaseDiagram-WPOLBNNX-CUYfjlrO.js → usecaseDiagram-WPOLBNNX-CC_KUwpc.js} +1 -1
  75. package/dist/client/assets/{vennDiagram-Q3Y3IDCW-B9Upmplw.js → vennDiagram-Q3Y3IDCW-BKPUQxLZ.js} +1 -1
  76. package/dist/client/assets/{wardleyDiagram-IVAIDKWA-C9_DfFfF.js → wardleyDiagram-IVAIDKWA-pZxWIAfq.js} +1 -1
  77. package/dist/client/assets/{websocket-BT8C-OBP.js → websocket-Q9XnceTt.js} +1 -1
  78. package/dist/client/assets/{workspace-creation-drop-drain-BcuDXdq-.js → workspace-creation-drop-drain-6HaYe14j.js} +1 -1
  79. package/dist/client/assets/{xychartDiagram-4URNHDU4-wRTlHEa4.js → xychartDiagram-4URNHDU4-v1OTdqDZ.js} +1 -1
  80. package/dist/client/index.html +2 -2
  81. package/dist/src/backend/services/workspace/service/query/workspace-query.service.d.ts +4 -0
  82. package/dist/src/backend/services/workspace/service/query/workspace-query.service.d.ts.map +1 -1
  83. package/dist/src/backend/services/workspace/service/query/workspace-query.service.js +7 -0
  84. package/dist/src/backend/services/workspace/service/query/workspace-query.service.js.map +1 -1
  85. package/dist/src/backend/services/workspace/service/query/workspace-query.service.test.js +15 -0
  86. package/dist/src/backend/services/workspace/service/query/workspace-query.service.test.js.map +1 -1
  87. package/dist/src/backend/testing/npm-publish-workflow.test.js +8 -9
  88. package/dist/src/backend/testing/npm-publish-workflow.test.js.map +1 -1
  89. package/dist/src/backend/trpc/index.d.ts +10 -8
  90. package/dist/src/backend/trpc/index.d.ts.map +1 -1
  91. package/dist/src/backend/trpc/project.router.test.js +34 -0
  92. package/dist/src/backend/trpc/project.router.test.js.map +1 -1
  93. package/dist/src/backend/trpc/project.trpc.d.ts +10 -8
  94. package/dist/src/backend/trpc/project.trpc.d.ts.map +1 -1
  95. package/dist/src/backend/trpc/project.trpc.js +19 -1
  96. package/dist/src/backend/trpc/project.trpc.js.map +1 -1
  97. package/dist/tsconfig.backend.tsbuildinfo +1 -1
  98. package/package.json +46 -46
  99. package/scripts/postinstall.mjs +16 -50
  100. package/dist/client/assets/index-BHTworEd.js +0 -12
  101. package/dist/client/assets/index-sK2DBc7b.css +0 -2
  102. package/dist/client/assets/mermaid-WFAXDIZX-Bb-EeuSh.js +0 -1
  103. package/dist/client/assets/new-DUJNL_Jv.js +0 -1
  104. package/dist/client/assets/project-CTLOJEoH.js +0 -1
  105. package/dist/client/assets/project-header-cDqQN0Dp.js +0 -1
  106. package/dist/client/assets/use-project-header-navigation-CGIZMabH.js +0 -1
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{n as t,t as n}from"./jsx-runtime-CldxteV5.js";import{l as r}from"./hooks-CZYZW9i_.js";import{t as i}from"./lib-D-JAPasO.js";import{n as a}from"./trpc-D9WuCSM1.js";import{t as o}from"./background-task-2TNZSSC3.js";import{t as s}from"./utils-DQeSPVda.js";import{t as c}from"./spinner-BxeSV-Bb.js";import{t as l}from"./button-Dslj7pht.js";import{t as u}from"./loading-SklnwAL1.js";import{T as d,_ as f,b as p,d as m,l as h,o as g,p as _,r as v,s as y,w as b,x,y as S}from"./schemas-cLRPP1ma.js";import{J as C,M as w,N as T,et as E,j as ee,k as te}from"./workspace-cache-reconciler-TKQHxUsu.js";import{t as D}from"./input-uo3fNc4V.js";import{t as O}from"./Plus.es-wnPcLFe1.js";import{n as k,r as A}from"./date-time-DaFd7tnC.js";import{$ as j,Mt as ne,O as M,Ot as re,Q as ie,Z as ae,ct as oe,dt as se,k as N,kt as ce}from"./index-BHTworEd.js";import{i as le,n as ue,r as de,t as fe}from"./agents-CIGVR3Yk.js";import{o as pe}from"./SlidersHorizontal.es-DWmgkQAH.js";import{a as P,i as F,n as me,o as he,r as I,s as L,t as R}from"./agent-definition.schema-DaZC-6OB.js";import{r as ge,t as _e}from"./inline-workspace-form-DvVz3qgr.js";import{r as ve,t as ye}from"./use-workspace-creation-draft-Bl2dlNzf.js";import{r as be}from"./agent-authoring-CzgCC7xn.js";import{t as xe}from"./Calendar.es-Cz1jIR6Y.js";import{t as Se}from"./query-state-DeXwsPfq.js";var z=n();function Ce({agent:e,onEdit:t,onToggle:n,onDelete:r,pending:i,error:a,children:o}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`space-y-4`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,z.jsx)(`div`,{className:`min-w-0`,children:(0,z.jsx)(`h2`,{className:`break-words text-xl font-semibold tracking-tight`,children:e.name})}),(0,z.jsx)(se,{variant:`secondary`,children:e.isEnabled?`Active`:`Paused`})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,z.jsx)(l,{variant:`outline`,size:`sm`,onClick:t,disabled:i,children:`Edit agent`}),(0,z.jsx)(l,{variant:`outline`,size:`sm`,onClick:n,disabled:i,children:e.isEnabled?`Pause`:`Resume`}),(0,z.jsx)(l,{variant:`ghost`,size:`sm`,className:`text-destructive hover:text-destructive`,onClick:r,disabled:i,children:`Delete`})]}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Pause affects future runs. A running workspace continues unchanged.`}),a&&(0,z.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:a})]}),(0,z.jsxs)(`section`,{className:`space-y-3 border-t pt-6`,children:[(0,z.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Instructions`}),(0,z.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm leading-relaxed text-muted-foreground`,children:e.prompt})]}),(0,z.jsxs)(`section`,{className:`space-y-3 rounded-lg border bg-muted/15 p-4`,children:[(0,z.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold`,children:[(0,z.jsx)(xe,{className:`size-4 text-muted-foreground`}),`Schedule`]}),(0,z.jsx)(`p`,{className:`break-words text-sm`,children:ue(e)}),(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-x-6 gap-y-2 text-xs text-muted-foreground`,children:[(0,z.jsxs)(`span`,{children:[`Last run:`,` `,e.lastRunAt?(0,z.jsx)(`time`,{dateTime:A(e.lastRunAt),title:k(e.lastRunAt,{precision:`second`}),children:k(e.lastRunAt)}):`No runs yet`]}),(0,z.jsxs)(`span`,{children:[`Next run:`,` `,e.isEnabled?(0,z.jsx)(`time`,{dateTime:A(e.nextRunAt),title:k(e.nextRunAt,{precision:`second`}),children:k(e.nextRunAt)}):`Paused`]})]})]}),(0,z.jsx)(`div`,{className:`border-t pt-6`,children:o})]})}var B=e(t(),1),we=`Name and instructions are required.`;function Te({initialValues:e,onSave:t,onCancel:n}){let r=(0,B.useId)(),i=(0,B.useRef)(e).current,[a,o]=(0,B.useState)(i?.name??``),[s,c]=(0,B.useState)(i?.prompt??``),[u,d]=(0,B.useState)(i?.cadence??`DAILY`),[f,p]=(0,B.useState)(i?.scheduledTime??``),[m,h]=(0,B.useState)(!1),g=(0,B.useRef)(!1),[_,v]=(0,B.useState)(null),y=()=>v(e=>e===we?null:e),b=async()=>{if(!g.current){if(!(a.trim()&&s.trim()))v(we);else{g.current=!0,h(!0),v(null);try{await t({name:a.trim(),prompt:s.trim(),cadence:u,...de({cadence:u,scheduledTime:f},i)})}catch(e){v(e instanceof Error?e.message:`Couldn't save agent. Please try again.`)}finally{g.current=!1,h(!1)}}}};return(0,z.jsxs)(`form`,{className:`space-y-6`,onSubmit:e=>{e.preventDefault(),b()},children:[(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(N,{htmlFor:`${r}-name`,children:`Name`}),(0,z.jsx)(D,{id:`${r}-name`,name:`name`,autoFocus:!0,value:a,onChange:e=>{o(e.target.value),y()},disabled:m,required:!0,placeholder:`Review recent changes`})]}),(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(N,{htmlFor:`${r}-instructions`,children:`Instructions`}),(0,z.jsx)(M,{id:`${r}-instructions`,name:`instructions`,className:`min-h-44 resize-y`,value:s,onChange:e=>{c(e.target.value),y()},disabled:m,required:!0,placeholder:`Describe what this agent should do on each run…`}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Each run creates a workspace and works toward a pull request.`})]}),(0,z.jsx)(fe,{cadence:u,scheduledTime:f,onCadenceChange:d,onScheduledTimeChange:p,disabled:m}),(0,z.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[i?`Changes apply to future runs. A running workspace continues unchanged.`:`The first run starts shortly after creation, then follows this schedule.`,le(u)&&f&&` Clock times use the selected schedule timezone; changing the time uses your browser timezone.`]}),_&&(0,z.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:_}),(0,z.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2 border-t pt-4`,children:[(0,z.jsx)(l,{type:`button`,variant:`outline`,onClick:n,disabled:m,children:`Cancel`}),(0,z.jsx)(l,{type:`submit`,disabled:m,children:m?`Saving…`:i?`Save changes`:`Create agent`})]})]})}function Ee({onCreate:e,disabled:t,outline:n=!1}){let r=(0,B.useRef)(null);return(0,z.jsxs)(ae,{children:[(0,z.jsx)(oe,{asChild:!0,children:(0,z.jsxs)(l,{size:`sm`,variant:n?`outline`:`default`,disabled:t,children:[(0,z.jsx)(O,{className:`size-4`,"aria-hidden":`true`}),`Create agent`]})}),(0,z.jsxs)(ie,{align:`end`,onCloseAutoFocus:t=>{let n=r.current;r.current=null,n&&(t.preventDefault(),e(n))},children:[(0,z.jsx)(j,{onSelect:()=>{r.current=`scheduled`},children:`Scheduled agent`}),(0,z.jsx)(j,{onSelect:()=>{r.current=`event`},children:`Event agent`})]})]})}function De(e,t,n){e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||n?.(t)}function Oe({agent:e,projectSlug:t,selected:n,onAgentSelect:r}){return(0,z.jsxs)(i,{to:ne(t,e.id,e.kind),state:{revealAgentEditor:!0},onClick:t=>De(t,e.id,r),"aria-current":n?`page`:void 0,className:s(`mb-1 block min-w-0 rounded-md border border-transparent p-3 outline-none transition-colors hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring`,n&&`border-border bg-background shadow-sm`),children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,z.jsx)(ce,{className:`size-4 shrink-0 text-muted-foreground`}),(0,z.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e.name})]}),e.kind!==`event`&&(0,z.jsx)(`p`,{className:`mt-2 line-clamp-2 break-words text-xs leading-relaxed text-muted-foreground`,children:e.prompt}),(0,z.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-muted-foreground`,children:[(0,z.jsx)(`span`,{className:s(`size-1.5 rounded-full`,e.isEnabled?`bg-primary`:`bg-muted-foreground/40`)}),(0,z.jsx)(`span`,{children:e.isEnabled?e.kind===`event`?`Definition enabled`:`Active`:`Paused`}),(0,z.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,z.jsx)(`span`,{children:e.kind===`event`?`Event`:ue(e)})]})]})}function ke({projectSlug:e,agents:t,selectedAgentId:n,selectedKind:r=`scheduled`,revealEditorOnMount:i=!1,continuation:a,isLoading:o,error:s,onRetry:c,onCreate:d,onAgentSelect:f,createDisabled:p,children:m}){let h=(0,B.useRef)(null),g=(0,B.useRef)(null),[_,v]=(0,B.useState)(+!!i),y=(0,B.useRef)(0),b=(0,B.useRef)(n);(0,B.useLayoutEffect)(()=>{let e=b.current!==n;b.current=n,(_>y.current||e)&&!o&&h.current&&g.current&&(y.current=_,getComputedStyle(h.current).flexDirection===`column`&&(g.current.contains(document.activeElement)||g.current.focus({preventScroll:!0}),g.current.scrollIntoView({block:`start`,behavior:`auto`})))},[_,n,o]);let x=e=>{f?.(e),v(e=>e+1)},S=(...e)=>{d(...e),v(e=>e+1)};return(0,z.jsxs)(`div`,{className:`@container/agents flex h-full min-h-0 min-w-0 flex-col overflow-hidden`,children:[(0,z.jsxs)(`header`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-3 border-b px-4 py-4 sm:px-6`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight`,children:`Agents`}),(0,z.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Scheduled and event agents in this project.`})]}),(0,z.jsx)(Ee,{onCreate:S,disabled:p})]}),(0,z.jsxs)(`div`,{ref:h,className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-y-auto @[48rem]/agents:flex-row @[48rem]/agents:overflow-hidden`,children:[(0,z.jsx)(`aside`,{className:`flex shrink-0 flex-col border-b bg-muted/15 @[48rem]/agents:max-h-none @[48rem]/agents:w-72 @[48rem]/agents:border-r @[48rem]/agents:border-b-0 @[64rem]/agents:w-80`,children:(0,z.jsxs)(`nav`,{"aria-label":`Agents`,className:`min-h-0 overflow-visible p-2 @[48rem]/agents:overflow-y-auto`,children:[s&&(0,z.jsxs)(`div`,{role:`alert`,className:`space-y-2 p-2 text-xs`,children:[(0,z.jsx)(`p`,{className:`break-words text-destructive`,children:s}),c&&(0,z.jsx)(l,{variant:`outline`,size:`sm`,onClick:c,children:`Retry agents`})]}),o&&(0,z.jsx)(u,{size:`compact`,message:`Loading agents…`}),!(s||o)&&t?.length===0&&(0,z.jsx)(re,{size:`compact`,icon:ce,title:`No agents yet`,description:`Schedule recurring work or prepare an event agent.`,action:(0,z.jsx)(Ee,{onCreate:S,disabled:p,outline:!0})}),(!!t?.length||a)&&[`scheduled`,`event`].map(i=>(0,z.jsxs)(`section`,{"aria-label":i===`scheduled`?`Scheduled`:`Event`,className:`mb-3`,children:[(0,z.jsx)(`h2`,{className:`px-3 py-2 text-xs font-semibold text-muted-foreground`,children:i===`scheduled`?`Scheduled`:`Event`}),t?.filter(e=>(e.kind??`scheduled`)===i).map(t=>(0,z.jsx)(Oe,{agent:t,projectSlug:e,onAgentSelect:x,selected:t.id===n&&i===r},`${e}:${i}:${t.id}`)),i===`event`&&a]},i))]})}),(0,z.jsx)(`main`,{ref:g,tabIndex:-1,"aria-label":`Agent details`,className:`min-h-0 min-w-0 flex-none overflow-visible @[48rem]/agents:flex-1 @[48rem]/agents:overflow-y-auto`,children:(0,z.jsx)(`div`,{className:`mx-auto w-full max-w-4xl space-y-7 p-4 sm:p-6 lg:p-8`,children:m})})]})]})}function Ae({children:e}){return(0,z.jsxs)(`section`,{className:`min-w-0 space-y-4`,"aria-label":`Create event agent`,children:[(0,z.jsx)(`h2`,{className:`text-xl font-semibold`,children:`Create event agent`}),(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Start a workspace to describe the event and instructions. Your agent will discover available sources and prepare a proposal for you to review before creating a paused definition. Listening and automatic event runs are not yet available.`}),e]})}function V({trigger:e}){return(0,z.jsxs)(`article`,{className:`min-w-0 space-y-2 rounded-lg border p-3 text-sm`,children:[(0,z.jsx)(`h4`,{className:`break-words font-medium`,children:e.configuration?.description??`Configuration unavailable`}),(0,z.jsx)(`p`,{className:`break-words text-xs text-muted-foreground`,children:e.id}),(0,z.jsxs)(`p`,{children:[e.isConfigured===!0?`Configured`:e.isConfigured===!1?`Removed`:`Unknown membership`,` `,`· `,e.activationState,` · `,e.isEnabled?`Enabled`:`Disabled`]}),(0,z.jsxs)(`p`,{children:[`Trigger revision `,e.triggerRevision,` · Activation generation`,` `,e.activationGeneration]}),(0,z.jsxs)(`p`,{children:[e.capability.status,`: `,e.capability.explanation]}),(0,z.jsxs)(`p`,{className:`break-words`,children:[`Source: `,e.sourceName??`Name unavailable`]}),(0,z.jsxs)(`p`,{children:[`Source health:`,` `,e.sourceHealth?`${e.sourceHealth.state}${e.sourceHealth.reasonCode?` · ${e.sourceHealth.reasonCode}`:``}`:`Unavailable`]}),e.configuration&&(0,z.jsxs)(`details`,{children:[(0,z.jsx)(`summary`,{className:`cursor-pointer`,children:`Stored event configuration`}),(0,z.jsx)(`pre`,{className:`mt-2 whitespace-pre-wrap break-words text-xs`,children:JSON.stringify(e.configuration,null,2)})]})]})}function je({agent:e}){return(0,z.jsxs)(`div`,{className:`min-w-0 space-y-5`,children:[(0,z.jsxs)(`section`,{className:`space-y-2`,children:[(0,z.jsx)(`h3`,{className:`font-medium`,children:`Instructions`}),(0,z.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm`,children:e.instructions})]}),(0,z.jsxs)(`section`,{className:`space-y-2`,children:[(0,z.jsx)(`h3`,{className:`font-medium`,children:`Saved execution settings`}),e.executionConfig?(0,z.jsx)(`pre`,{className:`whitespace-pre-wrap break-words text-xs`,children:JSON.stringify(e.executionConfig,null,2)}):(0,z.jsx)(`p`,{className:`text-sm`,children:`Execution configuration unavailable. A complete replacement is required.`})]}),(0,z.jsxs)(`section`,{className:`space-y-3`,children:[(0,z.jsx)(`h3`,{className:`font-medium`,children:`Configured triggers`}),e.configurationMembership===`UNKNOWN`&&(0,z.jsx)(`p`,{className:`text-sm`,children:`Exact membership is unknown, including records beyond the retained page. Inspection cannot reconstruct an editable specification.`}),e.configuredTriggers.map(e=>(0,z.jsx)(V,{trigger:e},e.id)),e.configurationMembership===`KNOWN`&&e.configuredTriggers.length===0&&(0,z.jsx)(`p`,{className:`text-sm`,children:`No configured triggers`})]}),(0,z.jsxs)(`section`,{className:`space-y-3`,children:[(0,z.jsx)(`h3`,{className:`font-medium`,children:`Retained trigger inspection`}),e.retainedTriggers.map(e=>(0,z.jsx)(V,{trigger:e},e.id)),e.retainedTriggers.length===0&&(0,z.jsx)(`p`,{className:`text-sm`,children:`No retained records on this page`})]})]})}function Me({agent:e,onEdit:t,archived:n=!1,saved:r=!1,children:i}){let a=e.configuredTriggers.some(e=>e.activationState===`PAUSED`||!e.isEnabled);return(0,z.jsxs)(`div`,{className:`min-w-0 space-y-6`,children:[(0,z.jsxs)(`header`,{className:`space-y-3`,children:[(0,z.jsx)(`h2`,{className:`break-words text-xl font-semibold`,children:e.name}),(0,z.jsxs)(`p`,{className:`text-sm`,children:[`Event agent · Definition `,e.isEnabled?`enabled`:`paused`,` · Management revision`,` `,e.managementRevision]}),(0,z.jsx)(l,{onClick:t,disabled:n,children:`Edit agent`}),n&&(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Archived project: saved details are readable; editing and previews require an active project.`})]}),r&&(0,z.jsxs)(`p`,{role:`status`,className:`text-sm`,children:[`Configuration saved.`,a?` Triggers are paused; re-enabling is needed before they can listen. Re-enabling is not available on this page.`:` Existing trigger runtime state is shown below.`]}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Definition state, trigger activation, capability and source health are separate facts. Supported configuration does not prove a trigger is listening.`}),(0,z.jsx)(je,{agent:e}),i]})}function Ne({preview:e}){let t=e.execution;return(0,z.jsxs)(`section`,{"aria-label":`Draft preview`,className:`min-w-0 space-y-2 rounded-lg border p-3 text-sm`,children:[(0,z.jsx)(`h3`,{className:`font-medium`,children:`Draft preview`}),(0,z.jsx)(`p`,{children:`This preview grants no activation, execution or account authority.`}),e.triggers.map(e=>(0,z.jsxs)(`p`,{children:[`Event `,e.index+1,`: `,e.capability.status,` · `,e.capability.explanation]},e.index)),t.status===`VALIDATED`?(0,z.jsxs)(`dl`,{className:`space-y-1 break-words`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{children:`Provider`}),(0,z.jsxs)(`dd`,{children:[t.intent.provider,` · `,t.intent.providerIntent]})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{children:`Requested model`}),(0,z.jsxs)(`dd`,{children:[t.intent.requestedModel,` · `,t.intent.modelIntent]})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{children:`Confirmed model`}),(0,z.jsx)(`dd`,{children:t.intent.model})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{children:`Resolved effort`}),(0,z.jsxs)(`dd`,{children:[t.intent.reasoningEffort??`None (null)`,` · `,t.intent.effortIntent]})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{children:`Effort normalization`}),(0,z.jsx)(`dd`,{children:t.intent.effortNormalization})]})]}):(0,z.jsxs)(`p`,{role:`status`,children:[t.status,`: `,t.explanation,t.status===`UNAVAILABLE`?` Retry validation when discovery is available.`:``]})]})}function Pe({sources:e}){return(0,z.jsxs)(`section`,{"aria-label":`Project sources`,className:`min-w-0 space-y-2 rounded-lg border p-3 text-sm`,children:[(0,z.jsx)(`h3`,{className:`font-medium`,children:`Project sources`}),`error`in e.github?(0,z.jsxs)(`p`,{children:[`GitHub: `,e.github.error]}):(0,z.jsxs)(`p`,{className:`break-words`,children:[`GitHub: `,e.github.repository.name,` ·`,` `,e.github.repository.labels.join(`, `)||`No labels`]}),e.slack.connections.map(e=>(0,z.jsxs)(`p`,{className:`break-words`,children:[`Slack: `,e.name,` · `,e.id]},e.id)),e.slack.channels?.map(e=>(0,z.jsxs)(`p`,{children:[e.name,` · `,e.id]},e.id)),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Names and stored IDs do not prove access. Validate the current complete draft explicitly.`})]})}var H=x().min(1).max(256),U=f().int().nonnegative().max(2147483647),Fe=f().int().positive().max(2147483647),Ie=p({id:H,fixedHeadEventId:H,previousBoundaryEventId:H.nullable(),phase:v([`CAPTURE`,`VERIFY`,`FINALIZE`]),nextPage:Fe,observationCount:U,verifiedCount:U,finalizedCount:U,resumePage:Fe,resumeIds:g(H).max(100),overlapOffset:U.nullable(),verifyResumeCount:U,verifySeekingOverlap:y().default(!1)});p({version:_(1),provider:_(`GITHUB`),committedHeadEventId:H.nullable(),scan:Ie.nullable()}),p({ids:g(H).max(100),entries:g(p({providerEventId:H,eventId:H.nullable()})).max(100)});var W=x().trim().min(1).max(256),G=I,K=R,q=E(),J=x().regex(/^\d{1,20}\.\d{1,20}$/),Le=x().regex(/^[A-Z][A-Z0-9_]{0,99}$/),Re=v(te);v(T);var ze=v(ee),Be=v(w),Ve={version:_(1),occurredAt:q,observedAt:q,sourceUrl:d().max(2048),actorId:W},He=h(`provider`,[p({...Ve,provider:_(`GITHUB`),repositoryId:W,repositoryFullName:W,action:x().min(1).max(64),creatorId:W,issue:p({number:f().int().positive(),title:x().max(4096),body:x().max(1e5),addedLabel:x().max(256).nullable()})}),p({...Ve,provider:_(`SLACK`),workspaceId:W,appId:W,channelId:W,action:_(`message`),eventTs:J,threadTs:J.nullable(),actorType:v([`HUMAN`,`BOT`,`SYSTEM`]),subtype:x().max(100).nullable(),text:x().max(1e5)})]);p({connectionId:W,providerEventId:W,payload:He}),p({connectionId:W,eventIds:g(W).min(1).max(1e3).refine(e=>new Set(e).size===e.length,`Event identities must be unique`)}),h(`provider`,[p({provider:_(`GITHUB`),headEventId:W.nullable(),sourceOrder:K}).refine(e=>e.headEventId!==null||e.sourceOrder===0,`An empty baseline has ordinal zero`),p({provider:_(`SLACK`),workspaceId:W,appId:W,channels:g(p({channelId:W,eventTs:J})).min(1).max(100).refine(e=>new Set(e.map(e=>e.channelId)).size===e.length,`Channel boundaries must be unique`)})]),p({version:_(1),activationGeneration:G,definitionRevision:G,triggerRevision:L,connectionId:W,nonce:W,expiresAt:q,channels:g(p({channelId:W,eventTs:J.nullable()})).max(100)}),h(`provider`,[p({version:_(1),provider:_(`GITHUB`),committedHeadEventId:W.nullable(),scan:Ie.nullable()}),p({version:_(1),provider:_(`SLACK`),gaps:g(p({from:q,to:q.nullable()})).max(100)})]);var Ue=p({state:v([`READY`,`STARTING`,`CATCHING_UP`,`DISCONNECTED`,`ERROR`,`RECOVERY_REQUIRED`]),reasonCode:Le.nullable(),updatedAt:q}),We=F.safeExtend({provider:v(C),model:W}),Ge=p({provider:v(C),model:W,promptVersion:W,inputHash:x().regex(/^[a-f0-9]{64}$/)});p({definition:me,trigger:he,executionConfig:We,input:P}),p({version:_(1),kind:_(`NON_DISPATCHING`),definition:p({name:x(),instructions:x(),isEnabled:y(),executionConfig:m()}),trigger:m(),input:P}),p({eventId:W,agentDefinitionId:W,triggerId:W,definitionRevision:G,triggerRevision:L,activationGeneration:K,status:Be,reasonCode:Le,explanation:x().max(2e3),executionConfig:F,input:P,classifier:Ge.optional()}).superRefine((e,t)=>{e.status===`MATCHED`&&!We.safeParse(e.executionConfig).success&&t.addIssue({code:`custom`,message:`Matches require resolved execution settings`})}),p({evaluationId:W,definitionRevision:G,triggerRevision:L,activationGeneration:K});var Y={reason:v([`NOT_FOUND`,`OWNERSHIP_MISMATCH`,`STALE_REVISION`,`STALE_EVENT_COHORT`,`ACTIVATION_STARTING`,`SOURCE_ORDER_PENDING`,`BEFORE_ACTIVATION`,`SOURCE_IDENTITY_MISMATCH`,`DEFINITION_DISABLED`,`TRIGGER_DISABLED`,`CONNECTION_UNAVAILABLE`,`SOURCE_RECOVERY_REQUIRED`,`UNSUPPORTED_TRIGGER`,`PROJECT_ARCHIVED`,`EVENT_EXPIRED`,`INVALID_STORED_DATA`,`NOT_MATCHED`,`EARLIER_EVALUATION_PENDING`,`EARLIER_EVALUATION_ERROR`,`QUEUE_OVERFLOW`,`QUEUE_EXPIRED`,`CAPACITY`,`WAITING`,`EMPTY`])};h(`status`,[p({status:_(`RECORDED`),evaluationId:W}),p({status:_(`DUPLICATE`),evaluationId:W}),p({status:_(`DEFERRED`),...Y}),p({status:_(`REJECTED`),...Y})]),h(`status`,[p({status:_(`ADMITTED`),runId:W}),p({status:_(`COALESCED`),runId:W}),p({status:_(`DEFERRED`),...Y}),p({status:_(`REJECTED`),...Y})]),h(`status`,[p({status:_(`CLAIMED`),runId:W,workerGeneration:G,attemptGeneration:G,reservedWorkspaceId:W,reservedSessionId:W,initialMessageId:W}),p({status:_(`DEFERRED`),...Y})]),p({version:_(1),summary:x().max(2e3),pullRequests:g(p({url:d().max(2048),number:f().int().positive()})).max(20)}),p({runId:W,state:ze,attemptGeneration:G,sendAttemptId:W,messageId:W,providerTurnId:W.nullable(),sendingAt:q.nullable(),acceptedAt:q.nullable(),finishedAt:q.nullable()});var X=x().min(1).max(256),Z=pe(256),Q=p({projectId:X,agentId:X}),Ke={limit:f().int().min(1).max(100).default(50),cursor:x().max(2e3).optional()};p({projectId:X,...Ke}),Q.extend(Ke),Q.extend({retainedCursor:x().max(2e3).optional()}),Q.extend({expectedManagementRevision:I,specification:Z});var qe=p({status:v([`SUPPORTED`,`UNSUPPORTED`,`UNAVAILABLE`]),reasonCode:v([`SUPPORTED`,`UNKNOWN_MEMBERSHIP`,`REMOVED_TRIGGER`,`INVALID_STORED_DATA`,`UNSUPPORTED_SCHEDULE`,`SLACK_INTAKE_UNAVAILABLE`,`UNSUPPORTED_GITHUB_ACTION`,`UNSUPPORTED_SEMANTIC_FILTER`,`UNSUPPORTED_ACTOR_FILTER`,`SOURCE_UNVERIFIED`,`SOURCE_UNAVAILABLE`]),explanation:x().max(500)}),Je=p({id:X,isConfigured:y().nullable(),triggerRevision:I,activationGeneration:R,activationState:Re,isEnabled:y(),configuration:he.nullable(),capability:qe,sourceName:x().max(500).nullable(),sourceHealth:Ue.nullable()}),$=p({id:X,projectId:X,name:x().max(200),managementRevision:I,definitionRevision:I,isEnabled:y(),createdAt:E(),updatedAt:E()}),Ye=$.extend({configurationMembership:v([`KNOWN`,`UNKNOWN`]),instructions:x().max(5e4),executionConfig:F.nullable(),specification:Z.nullable(),configuredTriggers:g(Je).max(20),retainedTriggers:g(Je).max(100),retainedNextCursor:x().nullable()});p({items:g($).max(100),nextCursor:x().nullable()}),p({totalCount:f().int().nonnegative(),failedCount:f().int().nonnegative()}),p({project:p({id:X,githubOwner:x().nullable(),githubRepo:x().nullable()}),connections:g(p({id:X,provider:v([`GITHUB`,`SLACK`]),externalId:x().min(1)})).max(20),sourceNames:S(x(),x().max(500))});function Xe(e){return{name:e.name,instructions:e.instructions,executionConfig:JSON.stringify(e.executionConfig,null,2),triggers:e.triggers.map(({id:e,description:t,filterInstructions:n,isEnabled:r,...i})=>({key:crypto.randomUUID(),savedId:e,description:t,filterInstructions:n??``,event:JSON.stringify(i,null,2)}))}}function Ze(e){let t=JSON.parse(e.executionConfig);return Z.parse({name:e.name,instructions:e.instructions,executionConfig:t,triggers:e.triggers.map(e=>({...S(x(),b()).parse(JSON.parse(e.event)),...e.savedId?{id:e.savedId}:{},description:e.description,filterInstructions:e.filterInstructions.trim()||null,isEnabled:!1}))})}function Qe(e){let t=JSON.parse(e);return Z.parse(t)}function $e(e,t,n){if(!n)return t;let r=new Map([...e?.slack.channels??[],...t.slack.channels??[]].map(e=>[e.id,e]));return{...t,slack:{...t.slack,channels:[...r.values()]}}}function et(e){let[t,n]=(0,B.useState)(e.agent),[r,i]=(0,B.useState)(()=>e.agent.specification?Xe(e.agent.specification):null),[a,o]=(0,B.useState)(e.initialReplacement??!1),[s,c]=(0,B.useState)(``),[l,u]=(0,B.useState)(),[d,f]=(0,B.useState)(),[p,m]=(0,B.useState)(),[h,g]=(0,B.useState)(!1),[_,v]=(0,B.useState)(null),y=(0,B.useRef)(!1),b=(0,B.useRef)(0),x=(0,B.useRef)(0),S=(0,B.useRef)(0),C=(0,B.useRef)(0),w=(0,B.useRef)(!0);(0,B.useEffect)(()=>(w.current=!0,()=>{w.current=!1}),[]);let T=()=>{b.current+=1,y.current||(S.current+=1,v(null)),f(void 0),m(void 0),g(!1),u(void 0)},E=e=>{T(),i(e)},ee=e=>{T(),c(e)},te=()=>a?Qe(s):r?Ze(r):null,D=e=>w.current&&b.current===e,O=(e,t)=>{D(t)&&u(e instanceof Error?e.message:`Couldn't complete this request. Try again.`)},k=e=>{let t={version:b.current,request:++S.current};return v(e),u(void 0),t},A=e=>{D(e.version)&&S.current===e.request&&v(null)},j=()=>{try{let e=te();if(!e)throw Error(`A complete replacement is required.`);return e}catch{return u(`Check the complete configuration: name, instructions, execution settings and event JSON must be valid. Supply the whole intended specification for replacement.`),null}},ne=async n=>{y.current=!0,C.current+=1;let r=k(`save`);try{await e.onSave(n,t.managementRevision)}catch(e){O(e,r.version)}finally{y.current=!1,A(r)}},M=async t=>{let n=++C.current,r=k(`validate`);try{let i=await e.onValidate(t);D(r.version)&&C.current===n&&f(i)}catch(e){C.current===n&&O(e,r.version)}finally{A(r)}},re=async t=>{let n=++x.current;g(!1);let r=k(`sources`);try{let i=await e.onSources(t);D(r.version)&&x.current===n&&m(e=>$e(e,i,!!t.cursor))}catch(e){x.current===n&&D(r.version)&&(g(!0),O(e,r.version))}finally{A(r)}},ie=(e,t={})=>{if(y.current)return;if(e===`sources`)return re(t);let n=j();if(n)return e===`save`?ne(n):M(n)},ae=e=>{T(),n(e),i(e.specification?Xe(e.specification):null),o(!1),c(``)};return{baseline:t,draft:r,updateDraft:E,replacementMode:a,replacement:s,updateReplacement:ee,startReplacement:()=>{T(),o(!0),c(``)},sourceSelectionChanged:T,error:l,preview:d,sources:p,sourceError:h,busy:_,attempt:ie,stale:t.managementRevision!==e.agent.managementRevision,reload:async()=>{if(!e.onReload||y.current)return;let t=k(`reload`);try{let n=await e.onReload();D(t.version)&&S.current===t.request&&ae(n)}catch(e){S.current===t.request&&O(e,t.version)}finally{A(t)}}}}function tt(e){let t=et(e),{draft:n}=t,r=(0,B.useId)(),i=!(n||t.replacementMode);return(0,z.jsxs)(`section`,{className:`min-w-0 space-y-5`,"aria-label":`Saved event editor`,children:[(0,z.jsx)(`h2`,{className:`text-xl font-semibold`,children:`Edit agent`}),(0,z.jsxs)(`p`,{className:`text-sm break-words`,children:[t.baseline.name,` · Saved management revision `,t.baseline.managementRevision]}),(i||t.replacementMode)&&(0,z.jsx)(je,{agent:t.baseline}),i?(0,z.jsxs)(`div`,{className:`space-y-3`,children:[(0,z.jsx)(`p`,{className:`text-sm`,children:`The exact saved specification is unavailable. Review existing facts, then explicitly replace the whole configuration. Retained records are inspection data.`}),(0,z.jsx)(l,{onClick:t.startReplacement,children:`Replace complete specification`}),(0,z.jsx)(l,{variant:`outline`,onClick:e.onCancel,children:`Cancel`})]}):(0,z.jsx)(`form`,{className:`min-w-0 space-y-5`,onSubmit:e=>{e.preventDefault(),t.attempt(`save`)},children:(0,z.jsxs)(`fieldset`,{disabled:t.busy===`save`||t.busy===`reload`,className:`min-w-0 space-y-4`,children:[t.replacementMode?(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(N,{htmlFor:`${r}-replacement`,children:`Full saved specification JSON`}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Supply the complete intended name, instructions, executionConfig and triggers. This blank input does not infer membership or repair stored fields automatically.`}),(0,z.jsx)(M,{id:`${r}-replacement`,"aria-label":`Full saved specification JSON`,className:`max-w-full font-mono text-xs`,rows:16,value:t.replacement,onChange:e=>t.updateReplacement(e.target.value)})]}):n&&(0,z.jsx)(nt,{editor:t,id:r}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Name-only edits preserve activation for known unchanged members. Task or execution edits pause triggers. Changed, reintroduced or unknown members pause and advance trigger revisions. Unclaimed queued work is cancelled; claimed snapshots continue. Re-enabling is needed for paused triggers and is not available here.`}),(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,z.jsx)(l,{type:`submit`,children:t.busy===`save`?`Saving…`:`Save changes`}),(0,z.jsx)(l,{type:`button`,variant:`outline`,onClick:()=>void t.attempt(`validate`),children:`Validate draft`}),(0,z.jsx)(l,{type:`button`,variant:`outline`,onClick:e.onCancel,children:`Cancel`})]})]})}),!i&&(0,z.jsx)(rt,{editor:t,id:r}),(0,z.jsx)(it,{editor:t,reloadAvailable:!!e.onReload})]})}function nt({editor:e,id:t}){let{draft:n,updateDraft:r}=e;return n?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(N,{htmlFor:`${t}-name`,children:`Name`}),(0,z.jsx)(D,{id:`${t}-name`,name:`name`,value:n.name,onChange:e=>r({...n,name:e.target.value})})]}),(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(N,{htmlFor:`${t}-instructions`,children:`Instructions`}),(0,z.jsx)(M,{id:`${t}-instructions`,"aria-label":`Instructions`,rows:5,value:n.instructions,onChange:e=>r({...n,instructions:e.target.value})})]}),n.triggers.map((i,a)=>(0,z.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,z.jsx)(be,{id:t,trigger:i,original:e.baseline.specification?.triggers.find(e=>e.id===i.savedId),index:a,sourceNames:{},onChange:(e,t)=>r({...n,triggers:n.triggers.map((n,r)=>r===a?{...n,[e]:t}:n)})}),(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,z.jsxs)(l,{type:`button`,variant:`outline`,size:`sm`,disabled:a===0,onClick:()=>{let e=[...n.triggers],t=e[a-1],i=e[a];t&&i&&([e[a-1],e[a]]=[i,t],r({...n,triggers:e}))},children:[`Move event `,a+1,` up`]}),(0,z.jsxs)(l,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>r({...n,triggers:n.triggers.filter(e=>e.key!==i.key)}),children:[`Remove event `,a+1]})]})]},i.key)),(0,z.jsx)(l,{type:`button`,variant:`outline`,onClick:()=>r({...n,triggers:[...n.triggers,{key:crypto.randomUUID(),savedId:void 0,description:``,filterInstructions:``,event:`{}`}]}),children:`Add event`}),(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(N,{htmlFor:`${t}-execution`,children:`Execution settings JSON`}),(0,z.jsx)(M,{id:`${t}-execution`,"aria-label":`Execution settings`,className:`max-w-full font-mono text-xs`,rows:5,value:n.executionConfig,onChange:e=>r({...n,executionConfig:e.target.value})}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Omitted provider, model and reasoningEffort stay inherited. Preview does not write discovered defaults into this draft.`})]})]}):null}function rt({editor:e,id:t}){let[n,r]=(0,B.useState)(``);return(0,z.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,z.jsx)(N,{htmlFor:`${t}-connection`,children:`Slack connection ID (optional)`}),(0,z.jsx)(D,{id:`${t}-connection`,disabled:e.busy===`save`||e.busy===`reload`,value:n,onChange:t=>{e.sourceSelectionChanged(),r(t.target.value)}}),(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,z.jsx)(l,{type:`button`,variant:`outline`,disabled:e.busy===`save`,onClick:()=>void e.attempt(`sources`,n?{connectionId:n}:{}),children:e.sourceError&&!e.sources?`Retry project sources`:`Refresh project sources`}),e.sources?.slack.nextCursor&&(0,z.jsx)(l,{type:`button`,variant:`outline`,disabled:e.busy===`sources`||e.busy===`save`,onClick:()=>void e.attempt(`sources`,{...n?{connectionId:n}:{},cursor:e.sources?.slack.nextCursor??void 0}),children:e.sourceError?`Retry more Slack channels`:`More Slack channels`})]})]})}function it({editor:e,reloadAvailable:t}){return(0,z.jsxs)(z.Fragment,{children:[` `,e.error&&(0,z.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive break-words`,children:e.error}),e.stale&&(0,z.jsx)(`p`,{role:`status`,className:`text-sm`,children:`The saved definition changed. Your entered fields and original save token are preserved. Review or copy your edits before reloading.`}),t&&(0,z.jsx)(l,{type:`button`,variant:`outline`,disabled:e.busy===`save`,onClick:()=>void e.reload(),children:`Discard edits and reload saved configuration`}),e.busy&&e.busy!==`save`&&(0,z.jsxs)(`p`,{role:`status`,className:`inline-flex items-center gap-2 text-sm`,children:[(0,z.jsx)(c,{className:`size-3`,"aria-hidden":`true`}),e.busy===`validate`?`Validating current draft…`:e.busy===`sources`?`Loading project sources…`:`Reloading saved configuration…`]}),e.preview&&(0,z.jsx)(Ne,{preview:e.preview}),e.sources&&(0,z.jsx)(Pe,{sources:e.sources})]})}function at({projectId:e,projectSlug:t,onCancel:n}){let i=r(),s=`event-agent:${e}`,c=ge(s),d=ye(s),[f,p]=(0,B.useState)(!1),m=(0,B.useRef)(void 0),h=a.workspace.listForProject.useQuery({projectId:e});return f?(0,z.jsx)(u,{size:`compact`,message:`Canceling event agent draft…`}):(0,z.jsxs)(z.Fragment,{children:[c.isPending&&(0,z.jsx)(u,{size:`compact`,message:`Creating event agent workspace…`}),(0,z.jsx)(Se,{query:h,errorTitle:`Couldn't load workspace names`,loadingMessage:`Loading workspace names…`,size:`compact`,children:r=>(0,z.jsx)(_e,{projectId:e,purpose:`event-agent`,existingNames:r.workspaces.map(e=>e.name),onCancel:n,onCreated:e=>{i(`/projects/${encodeURIComponent(t)}/workspaces/${encodeURIComponent(e)}`)}},e)}),!(h.data||c.isPending)&&(0,z.jsx)(l,{variant:`outline`,onClick:()=>{if(c.isPending||d.isRestoring||f)return;m.current??=d.hasDraft?d.draft.revision:void 0,p(!0);let e=m.current?d.clearSubmittedDraft(m.current):d.discardDraft();o(e.then(()=>{m.current=void 0,ve(s).draft===null&&n()}).finally(()=>p(!1)),`Couldn't clear canceled event agent draft.`)},disabled:d.isRestoring,children:`Cancel`})]})}export{Ye as a,V as c,Te as d,Ce as f,X as i,Ae as l,tt as n,Z as o,qe as r,Me as s,at as t,ke as u};
1
+ import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{n as t,t as n}from"./jsx-runtime-CldxteV5.js";import{l as r}from"./hooks-CZYZW9i_.js";import{t as i}from"./lib-D-JAPasO.js";import{n as a}from"./trpc-D9WuCSM1.js";import{t as o}from"./background-task-2TNZSSC3.js";import{t as s}from"./utils-DQeSPVda.js";import{t as c}from"./spinner-BxeSV-Bb.js";import{t as l}from"./button-Dslj7pht.js";import{t as u}from"./loading-SklnwAL1.js";import{T as d,_ as f,b as p,d as m,l as h,o as g,p as _,r as v,s as y,w as b,x,y as S}from"./schemas-cLRPP1ma.js";import{J as C,M as w,N as T,et as E,j as ee,k as te}from"./workspace-cache-reconciler-TKQHxUsu.js";import{t as D}from"./input-uo3fNc4V.js";import{t as O}from"./Plus.es-wnPcLFe1.js";import{n as k,r as A}from"./date-time-DaFd7tnC.js";import{$ as j,Mt as ne,O as M,Ot as re,Q as ie,Z as ae,ct as oe,dt as se,k as N,kt as ce}from"./index-GmSorqXd.js";import{i as le,n as ue,r as de,t as fe}from"./agents-BNAsXKbn.js";import{o as pe}from"./SlidersHorizontal.es-DWmgkQAH.js";import{a as P,i as F,n as me,o as he,r as I,s as L,t as R}from"./agent-definition.schema-DaZC-6OB.js";import{r as ge,t as _e}from"./inline-workspace-form-DTOd1_IQ.js";import{r as ve,t as ye}from"./use-workspace-creation-draft-BcIClFw-.js";import{r as be}from"./agent-authoring-C33uSQgC.js";import{t as xe}from"./Calendar.es-Cz1jIR6Y.js";import{t as Se}from"./query-state-BVQj0phN.js";var z=n();function Ce({agent:e,onEdit:t,onToggle:n,onDelete:r,pending:i,error:a,children:o}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`space-y-4`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,z.jsx)(`div`,{className:`min-w-0`,children:(0,z.jsx)(`h2`,{className:`break-words text-xl font-semibold tracking-tight`,children:e.name})}),(0,z.jsx)(se,{variant:`secondary`,children:e.isEnabled?`Active`:`Paused`})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,z.jsx)(l,{variant:`outline`,size:`sm`,onClick:t,disabled:i,children:`Edit agent`}),(0,z.jsx)(l,{variant:`outline`,size:`sm`,onClick:n,disabled:i,children:e.isEnabled?`Pause`:`Resume`}),(0,z.jsx)(l,{variant:`ghost`,size:`sm`,className:`text-destructive hover:text-destructive`,onClick:r,disabled:i,children:`Delete`})]}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Pause affects future runs. A running workspace continues unchanged.`}),a&&(0,z.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:a})]}),(0,z.jsxs)(`section`,{className:`space-y-3 border-t pt-6`,children:[(0,z.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Instructions`}),(0,z.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm leading-relaxed text-muted-foreground`,children:e.prompt})]}),(0,z.jsxs)(`section`,{className:`space-y-3 rounded-lg border bg-muted/15 p-4`,children:[(0,z.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold`,children:[(0,z.jsx)(xe,{className:`size-4 text-muted-foreground`}),`Schedule`]}),(0,z.jsx)(`p`,{className:`break-words text-sm`,children:ue(e)}),(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-x-6 gap-y-2 text-xs text-muted-foreground`,children:[(0,z.jsxs)(`span`,{children:[`Last run:`,` `,e.lastRunAt?(0,z.jsx)(`time`,{dateTime:A(e.lastRunAt),title:k(e.lastRunAt,{precision:`second`}),children:k(e.lastRunAt)}):`No runs yet`]}),(0,z.jsxs)(`span`,{children:[`Next run:`,` `,e.isEnabled?(0,z.jsx)(`time`,{dateTime:A(e.nextRunAt),title:k(e.nextRunAt,{precision:`second`}),children:k(e.nextRunAt)}):`Paused`]})]})]}),(0,z.jsx)(`div`,{className:`border-t pt-6`,children:o})]})}var B=e(t(),1),we=`Name and instructions are required.`;function Te({initialValues:e,onSave:t,onCancel:n}){let r=(0,B.useId)(),i=(0,B.useRef)(e).current,[a,o]=(0,B.useState)(i?.name??``),[s,c]=(0,B.useState)(i?.prompt??``),[u,d]=(0,B.useState)(i?.cadence??`DAILY`),[f,p]=(0,B.useState)(i?.scheduledTime??``),[m,h]=(0,B.useState)(!1),g=(0,B.useRef)(!1),[_,v]=(0,B.useState)(null),y=()=>v(e=>e===we?null:e),b=async()=>{if(!g.current){if(!(a.trim()&&s.trim()))v(we);else{g.current=!0,h(!0),v(null);try{await t({name:a.trim(),prompt:s.trim(),cadence:u,...de({cadence:u,scheduledTime:f},i)})}catch(e){v(e instanceof Error?e.message:`Couldn't save agent. Please try again.`)}finally{g.current=!1,h(!1)}}}};return(0,z.jsxs)(`form`,{className:`space-y-6`,onSubmit:e=>{e.preventDefault(),b()},children:[(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(N,{htmlFor:`${r}-name`,children:`Name`}),(0,z.jsx)(D,{id:`${r}-name`,name:`name`,autoFocus:!0,value:a,onChange:e=>{o(e.target.value),y()},disabled:m,required:!0,placeholder:`Review recent changes`})]}),(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(N,{htmlFor:`${r}-instructions`,children:`Instructions`}),(0,z.jsx)(M,{id:`${r}-instructions`,name:`instructions`,className:`min-h-44 resize-y`,value:s,onChange:e=>{c(e.target.value),y()},disabled:m,required:!0,placeholder:`Describe what this agent should do on each run…`}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Each run creates a workspace and works toward a pull request.`})]}),(0,z.jsx)(fe,{cadence:u,scheduledTime:f,onCadenceChange:d,onScheduledTimeChange:p,disabled:m}),(0,z.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[i?`Changes apply to future runs. A running workspace continues unchanged.`:`The first run starts shortly after creation, then follows this schedule.`,le(u)&&f&&` Clock times use the selected schedule timezone; changing the time uses your browser timezone.`]}),_&&(0,z.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:_}),(0,z.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2 border-t pt-4`,children:[(0,z.jsx)(l,{type:`button`,variant:`outline`,onClick:n,disabled:m,children:`Cancel`}),(0,z.jsx)(l,{type:`submit`,disabled:m,children:m?`Saving…`:i?`Save changes`:`Create agent`})]})]})}function Ee({onCreate:e,disabled:t,outline:n=!1}){let r=(0,B.useRef)(null);return(0,z.jsxs)(ae,{children:[(0,z.jsx)(oe,{asChild:!0,children:(0,z.jsxs)(l,{size:`sm`,variant:n?`outline`:`default`,disabled:t,children:[(0,z.jsx)(O,{className:`size-4`,"aria-hidden":`true`}),`Create agent`]})}),(0,z.jsxs)(ie,{align:`end`,onCloseAutoFocus:t=>{let n=r.current;r.current=null,n&&(t.preventDefault(),e(n))},children:[(0,z.jsx)(j,{onSelect:()=>{r.current=`scheduled`},children:`Scheduled agent`}),(0,z.jsx)(j,{onSelect:()=>{r.current=`event`},children:`Event agent`})]})]})}function De(e,t,n){e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||n?.(t)}function Oe({agent:e,projectSlug:t,selected:n,onAgentSelect:r}){return(0,z.jsxs)(i,{to:ne(t,e.id,e.kind),state:{revealAgentEditor:!0},onClick:t=>De(t,e.id,r),"aria-current":n?`page`:void 0,className:s(`mb-1 block min-w-0 rounded-md border border-transparent p-3 outline-none transition-colors hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring`,n&&`border-border bg-background shadow-sm`),children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,z.jsx)(ce,{className:`size-4 shrink-0 text-muted-foreground`}),(0,z.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e.name})]}),e.kind!==`event`&&(0,z.jsx)(`p`,{className:`mt-2 line-clamp-2 break-words text-xs leading-relaxed text-muted-foreground`,children:e.prompt}),(0,z.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-muted-foreground`,children:[(0,z.jsx)(`span`,{className:s(`size-1.5 rounded-full`,e.isEnabled?`bg-primary`:`bg-muted-foreground/40`)}),(0,z.jsx)(`span`,{children:e.isEnabled?e.kind===`event`?`Definition enabled`:`Active`:`Paused`}),(0,z.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,z.jsx)(`span`,{children:e.kind===`event`?`Event`:ue(e)})]})]})}function ke({projectSlug:e,agents:t,selectedAgentId:n,selectedKind:r=`scheduled`,revealEditorOnMount:i=!1,continuation:a,isLoading:o,error:s,onRetry:c,onCreate:d,onAgentSelect:f,createDisabled:p,children:m}){let h=(0,B.useRef)(null),g=(0,B.useRef)(null),[_,v]=(0,B.useState)(+!!i),y=(0,B.useRef)(0),b=(0,B.useRef)(n);(0,B.useLayoutEffect)(()=>{let e=b.current!==n;b.current=n,(_>y.current||e)&&!o&&h.current&&g.current&&(y.current=_,getComputedStyle(h.current).flexDirection===`column`&&(g.current.contains(document.activeElement)||g.current.focus({preventScroll:!0}),g.current.scrollIntoView({block:`start`,behavior:`auto`})))},[_,n,o]);let x=e=>{f?.(e),v(e=>e+1)},S=(...e)=>{d(...e),v(e=>e+1)};return(0,z.jsxs)(`div`,{className:`@container/agents flex h-full min-h-0 min-w-0 flex-col overflow-hidden`,children:[(0,z.jsxs)(`header`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-3 border-b px-4 py-4 sm:px-6`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight`,children:`Agents`}),(0,z.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Scheduled and event agents in this project.`})]}),(0,z.jsx)(Ee,{onCreate:S,disabled:p})]}),(0,z.jsxs)(`div`,{ref:h,className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-y-auto @[48rem]/agents:flex-row @[48rem]/agents:overflow-hidden`,children:[(0,z.jsx)(`aside`,{className:`flex shrink-0 flex-col border-b bg-muted/15 @[48rem]/agents:max-h-none @[48rem]/agents:w-72 @[48rem]/agents:border-r @[48rem]/agents:border-b-0 @[64rem]/agents:w-80`,children:(0,z.jsxs)(`nav`,{"aria-label":`Agents`,className:`min-h-0 overflow-visible p-2 @[48rem]/agents:overflow-y-auto`,children:[s&&(0,z.jsxs)(`div`,{role:`alert`,className:`space-y-2 p-2 text-xs`,children:[(0,z.jsx)(`p`,{className:`break-words text-destructive`,children:s}),c&&(0,z.jsx)(l,{variant:`outline`,size:`sm`,onClick:c,children:`Retry agents`})]}),o&&(0,z.jsx)(u,{size:`compact`,message:`Loading agents…`}),!(s||o)&&t?.length===0&&(0,z.jsx)(re,{size:`compact`,icon:ce,title:`No agents yet`,description:`Schedule recurring work or prepare an event agent.`,action:(0,z.jsx)(Ee,{onCreate:S,disabled:p,outline:!0})}),(!!t?.length||a)&&[`scheduled`,`event`].map(i=>(0,z.jsxs)(`section`,{"aria-label":i===`scheduled`?`Scheduled`:`Event`,className:`mb-3`,children:[(0,z.jsx)(`h2`,{className:`px-3 py-2 text-xs font-semibold text-muted-foreground`,children:i===`scheduled`?`Scheduled`:`Event`}),t?.filter(e=>(e.kind??`scheduled`)===i).map(t=>(0,z.jsx)(Oe,{agent:t,projectSlug:e,onAgentSelect:x,selected:t.id===n&&i===r},`${e}:${i}:${t.id}`)),i===`event`&&a]},i))]})}),(0,z.jsx)(`main`,{ref:g,tabIndex:-1,"aria-label":`Agent details`,className:`min-h-0 min-w-0 flex-none overflow-visible @[48rem]/agents:flex-1 @[48rem]/agents:overflow-y-auto`,children:(0,z.jsx)(`div`,{className:`mx-auto w-full max-w-4xl space-y-7 p-4 sm:p-6 lg:p-8`,children:m})})]})]})}function Ae({children:e}){return(0,z.jsxs)(`section`,{className:`min-w-0 space-y-4`,"aria-label":`Create event agent`,children:[(0,z.jsx)(`h2`,{className:`text-xl font-semibold`,children:`Create event agent`}),(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Start a workspace to describe the event and instructions. Your agent will discover available sources and prepare a proposal for you to review before creating a paused definition. Listening and automatic event runs are not yet available.`}),e]})}function V({trigger:e}){return(0,z.jsxs)(`article`,{className:`min-w-0 space-y-2 rounded-lg border p-3 text-sm`,children:[(0,z.jsx)(`h4`,{className:`break-words font-medium`,children:e.configuration?.description??`Configuration unavailable`}),(0,z.jsx)(`p`,{className:`break-words text-xs text-muted-foreground`,children:e.id}),(0,z.jsxs)(`p`,{children:[e.isConfigured===!0?`Configured`:e.isConfigured===!1?`Removed`:`Unknown membership`,` `,`· `,e.activationState,` · `,e.isEnabled?`Enabled`:`Disabled`]}),(0,z.jsxs)(`p`,{children:[`Trigger revision `,e.triggerRevision,` · Activation generation`,` `,e.activationGeneration]}),(0,z.jsxs)(`p`,{children:[e.capability.status,`: `,e.capability.explanation]}),(0,z.jsxs)(`p`,{className:`break-words`,children:[`Source: `,e.sourceName??`Name unavailable`]}),(0,z.jsxs)(`p`,{children:[`Source health:`,` `,e.sourceHealth?`${e.sourceHealth.state}${e.sourceHealth.reasonCode?` · ${e.sourceHealth.reasonCode}`:``}`:`Unavailable`]}),e.configuration&&(0,z.jsxs)(`details`,{children:[(0,z.jsx)(`summary`,{className:`cursor-pointer`,children:`Stored event configuration`}),(0,z.jsx)(`pre`,{className:`mt-2 whitespace-pre-wrap break-words text-xs`,children:JSON.stringify(e.configuration,null,2)})]})]})}function je({agent:e}){return(0,z.jsxs)(`div`,{className:`min-w-0 space-y-5`,children:[(0,z.jsxs)(`section`,{className:`space-y-2`,children:[(0,z.jsx)(`h3`,{className:`font-medium`,children:`Instructions`}),(0,z.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm`,children:e.instructions})]}),(0,z.jsxs)(`section`,{className:`space-y-2`,children:[(0,z.jsx)(`h3`,{className:`font-medium`,children:`Saved execution settings`}),e.executionConfig?(0,z.jsx)(`pre`,{className:`whitespace-pre-wrap break-words text-xs`,children:JSON.stringify(e.executionConfig,null,2)}):(0,z.jsx)(`p`,{className:`text-sm`,children:`Execution configuration unavailable. A complete replacement is required.`})]}),(0,z.jsxs)(`section`,{className:`space-y-3`,children:[(0,z.jsx)(`h3`,{className:`font-medium`,children:`Configured triggers`}),e.configurationMembership===`UNKNOWN`&&(0,z.jsx)(`p`,{className:`text-sm`,children:`Exact membership is unknown, including records beyond the retained page. Inspection cannot reconstruct an editable specification.`}),e.configuredTriggers.map(e=>(0,z.jsx)(V,{trigger:e},e.id)),e.configurationMembership===`KNOWN`&&e.configuredTriggers.length===0&&(0,z.jsx)(`p`,{className:`text-sm`,children:`No configured triggers`})]}),(0,z.jsxs)(`section`,{className:`space-y-3`,children:[(0,z.jsx)(`h3`,{className:`font-medium`,children:`Retained trigger inspection`}),e.retainedTriggers.map(e=>(0,z.jsx)(V,{trigger:e},e.id)),e.retainedTriggers.length===0&&(0,z.jsx)(`p`,{className:`text-sm`,children:`No retained records on this page`})]})]})}function Me({agent:e,onEdit:t,archived:n=!1,saved:r=!1,children:i}){let a=e.configuredTriggers.some(e=>e.activationState===`PAUSED`||!e.isEnabled);return(0,z.jsxs)(`div`,{className:`min-w-0 space-y-6`,children:[(0,z.jsxs)(`header`,{className:`space-y-3`,children:[(0,z.jsx)(`h2`,{className:`break-words text-xl font-semibold`,children:e.name}),(0,z.jsxs)(`p`,{className:`text-sm`,children:[`Event agent · Definition `,e.isEnabled?`enabled`:`paused`,` · Management revision`,` `,e.managementRevision]}),(0,z.jsx)(l,{onClick:t,disabled:n,children:`Edit agent`}),n&&(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Archived project: saved details are readable; editing and previews require an active project.`})]}),r&&(0,z.jsxs)(`p`,{role:`status`,className:`text-sm`,children:[`Configuration saved.`,a?` Triggers are paused; re-enabling is needed before they can listen. Re-enabling is not available on this page.`:` Existing trigger runtime state is shown below.`]}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Definition state, trigger activation, capability and source health are separate facts. Supported configuration does not prove a trigger is listening.`}),(0,z.jsx)(je,{agent:e}),i]})}function Ne({preview:e}){let t=e.execution;return(0,z.jsxs)(`section`,{"aria-label":`Draft preview`,className:`min-w-0 space-y-2 rounded-lg border p-3 text-sm`,children:[(0,z.jsx)(`h3`,{className:`font-medium`,children:`Draft preview`}),(0,z.jsx)(`p`,{children:`This preview grants no activation, execution or account authority.`}),e.triggers.map(e=>(0,z.jsxs)(`p`,{children:[`Event `,e.index+1,`: `,e.capability.status,` · `,e.capability.explanation]},e.index)),t.status===`VALIDATED`?(0,z.jsxs)(`dl`,{className:`space-y-1 break-words`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{children:`Provider`}),(0,z.jsxs)(`dd`,{children:[t.intent.provider,` · `,t.intent.providerIntent]})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{children:`Requested model`}),(0,z.jsxs)(`dd`,{children:[t.intent.requestedModel,` · `,t.intent.modelIntent]})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{children:`Confirmed model`}),(0,z.jsx)(`dd`,{children:t.intent.model})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{children:`Resolved effort`}),(0,z.jsxs)(`dd`,{children:[t.intent.reasoningEffort??`None (null)`,` · `,t.intent.effortIntent]})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`dt`,{children:`Effort normalization`}),(0,z.jsx)(`dd`,{children:t.intent.effortNormalization})]})]}):(0,z.jsxs)(`p`,{role:`status`,children:[t.status,`: `,t.explanation,t.status===`UNAVAILABLE`?` Retry validation when discovery is available.`:``]})]})}function Pe({sources:e}){return(0,z.jsxs)(`section`,{"aria-label":`Project sources`,className:`min-w-0 space-y-2 rounded-lg border p-3 text-sm`,children:[(0,z.jsx)(`h3`,{className:`font-medium`,children:`Project sources`}),`error`in e.github?(0,z.jsxs)(`p`,{children:[`GitHub: `,e.github.error]}):(0,z.jsxs)(`p`,{className:`break-words`,children:[`GitHub: `,e.github.repository.name,` ·`,` `,e.github.repository.labels.join(`, `)||`No labels`]}),e.slack.connections.map(e=>(0,z.jsxs)(`p`,{className:`break-words`,children:[`Slack: `,e.name,` · `,e.id]},e.id)),e.slack.channels?.map(e=>(0,z.jsxs)(`p`,{children:[e.name,` · `,e.id]},e.id)),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Names and stored IDs do not prove access. Validate the current complete draft explicitly.`})]})}var H=x().min(1).max(256),U=f().int().nonnegative().max(2147483647),Fe=f().int().positive().max(2147483647),Ie=p({id:H,fixedHeadEventId:H,previousBoundaryEventId:H.nullable(),phase:v([`CAPTURE`,`VERIFY`,`FINALIZE`]),nextPage:Fe,observationCount:U,verifiedCount:U,finalizedCount:U,resumePage:Fe,resumeIds:g(H).max(100),overlapOffset:U.nullable(),verifyResumeCount:U,verifySeekingOverlap:y().default(!1)});p({version:_(1),provider:_(`GITHUB`),committedHeadEventId:H.nullable(),scan:Ie.nullable()}),p({ids:g(H).max(100),entries:g(p({providerEventId:H,eventId:H.nullable()})).max(100)});var W=x().trim().min(1).max(256),G=I,K=R,q=E(),J=x().regex(/^\d{1,20}\.\d{1,20}$/),Le=x().regex(/^[A-Z][A-Z0-9_]{0,99}$/),Re=v(te);v(T);var ze=v(ee),Be=v(w),Ve={version:_(1),occurredAt:q,observedAt:q,sourceUrl:d().max(2048),actorId:W},He=h(`provider`,[p({...Ve,provider:_(`GITHUB`),repositoryId:W,repositoryFullName:W,action:x().min(1).max(64),creatorId:W,issue:p({number:f().int().positive(),title:x().max(4096),body:x().max(1e5),addedLabel:x().max(256).nullable()})}),p({...Ve,provider:_(`SLACK`),workspaceId:W,appId:W,channelId:W,action:_(`message`),eventTs:J,threadTs:J.nullable(),actorType:v([`HUMAN`,`BOT`,`SYSTEM`]),subtype:x().max(100).nullable(),text:x().max(1e5)})]);p({connectionId:W,providerEventId:W,payload:He}),p({connectionId:W,eventIds:g(W).min(1).max(1e3).refine(e=>new Set(e).size===e.length,`Event identities must be unique`)}),h(`provider`,[p({provider:_(`GITHUB`),headEventId:W.nullable(),sourceOrder:K}).refine(e=>e.headEventId!==null||e.sourceOrder===0,`An empty baseline has ordinal zero`),p({provider:_(`SLACK`),workspaceId:W,appId:W,channels:g(p({channelId:W,eventTs:J})).min(1).max(100).refine(e=>new Set(e.map(e=>e.channelId)).size===e.length,`Channel boundaries must be unique`)})]),p({version:_(1),activationGeneration:G,definitionRevision:G,triggerRevision:L,connectionId:W,nonce:W,expiresAt:q,channels:g(p({channelId:W,eventTs:J.nullable()})).max(100)}),h(`provider`,[p({version:_(1),provider:_(`GITHUB`),committedHeadEventId:W.nullable(),scan:Ie.nullable()}),p({version:_(1),provider:_(`SLACK`),gaps:g(p({from:q,to:q.nullable()})).max(100)})]);var Ue=p({state:v([`READY`,`STARTING`,`CATCHING_UP`,`DISCONNECTED`,`ERROR`,`RECOVERY_REQUIRED`]),reasonCode:Le.nullable(),updatedAt:q}),We=F.safeExtend({provider:v(C),model:W}),Ge=p({provider:v(C),model:W,promptVersion:W,inputHash:x().regex(/^[a-f0-9]{64}$/)});p({definition:me,trigger:he,executionConfig:We,input:P}),p({version:_(1),kind:_(`NON_DISPATCHING`),definition:p({name:x(),instructions:x(),isEnabled:y(),executionConfig:m()}),trigger:m(),input:P}),p({eventId:W,agentDefinitionId:W,triggerId:W,definitionRevision:G,triggerRevision:L,activationGeneration:K,status:Be,reasonCode:Le,explanation:x().max(2e3),executionConfig:F,input:P,classifier:Ge.optional()}).superRefine((e,t)=>{e.status===`MATCHED`&&!We.safeParse(e.executionConfig).success&&t.addIssue({code:`custom`,message:`Matches require resolved execution settings`})}),p({evaluationId:W,definitionRevision:G,triggerRevision:L,activationGeneration:K});var Y={reason:v([`NOT_FOUND`,`OWNERSHIP_MISMATCH`,`STALE_REVISION`,`STALE_EVENT_COHORT`,`ACTIVATION_STARTING`,`SOURCE_ORDER_PENDING`,`BEFORE_ACTIVATION`,`SOURCE_IDENTITY_MISMATCH`,`DEFINITION_DISABLED`,`TRIGGER_DISABLED`,`CONNECTION_UNAVAILABLE`,`SOURCE_RECOVERY_REQUIRED`,`UNSUPPORTED_TRIGGER`,`PROJECT_ARCHIVED`,`EVENT_EXPIRED`,`INVALID_STORED_DATA`,`NOT_MATCHED`,`EARLIER_EVALUATION_PENDING`,`EARLIER_EVALUATION_ERROR`,`QUEUE_OVERFLOW`,`QUEUE_EXPIRED`,`CAPACITY`,`WAITING`,`EMPTY`])};h(`status`,[p({status:_(`RECORDED`),evaluationId:W}),p({status:_(`DUPLICATE`),evaluationId:W}),p({status:_(`DEFERRED`),...Y}),p({status:_(`REJECTED`),...Y})]),h(`status`,[p({status:_(`ADMITTED`),runId:W}),p({status:_(`COALESCED`),runId:W}),p({status:_(`DEFERRED`),...Y}),p({status:_(`REJECTED`),...Y})]),h(`status`,[p({status:_(`CLAIMED`),runId:W,workerGeneration:G,attemptGeneration:G,reservedWorkspaceId:W,reservedSessionId:W,initialMessageId:W}),p({status:_(`DEFERRED`),...Y})]),p({version:_(1),summary:x().max(2e3),pullRequests:g(p({url:d().max(2048),number:f().int().positive()})).max(20)}),p({runId:W,state:ze,attemptGeneration:G,sendAttemptId:W,messageId:W,providerTurnId:W.nullable(),sendingAt:q.nullable(),acceptedAt:q.nullable(),finishedAt:q.nullable()});var X=x().min(1).max(256),Z=pe(256),Q=p({projectId:X,agentId:X}),Ke={limit:f().int().min(1).max(100).default(50),cursor:x().max(2e3).optional()};p({projectId:X,...Ke}),Q.extend(Ke),Q.extend({retainedCursor:x().max(2e3).optional()}),Q.extend({expectedManagementRevision:I,specification:Z});var qe=p({status:v([`SUPPORTED`,`UNSUPPORTED`,`UNAVAILABLE`]),reasonCode:v([`SUPPORTED`,`UNKNOWN_MEMBERSHIP`,`REMOVED_TRIGGER`,`INVALID_STORED_DATA`,`UNSUPPORTED_SCHEDULE`,`SLACK_INTAKE_UNAVAILABLE`,`UNSUPPORTED_GITHUB_ACTION`,`UNSUPPORTED_SEMANTIC_FILTER`,`UNSUPPORTED_ACTOR_FILTER`,`SOURCE_UNVERIFIED`,`SOURCE_UNAVAILABLE`]),explanation:x().max(500)}),Je=p({id:X,isConfigured:y().nullable(),triggerRevision:I,activationGeneration:R,activationState:Re,isEnabled:y(),configuration:he.nullable(),capability:qe,sourceName:x().max(500).nullable(),sourceHealth:Ue.nullable()}),$=p({id:X,projectId:X,name:x().max(200),managementRevision:I,definitionRevision:I,isEnabled:y(),createdAt:E(),updatedAt:E()}),Ye=$.extend({configurationMembership:v([`KNOWN`,`UNKNOWN`]),instructions:x().max(5e4),executionConfig:F.nullable(),specification:Z.nullable(),configuredTriggers:g(Je).max(20),retainedTriggers:g(Je).max(100),retainedNextCursor:x().nullable()});p({items:g($).max(100),nextCursor:x().nullable()}),p({totalCount:f().int().nonnegative(),failedCount:f().int().nonnegative()}),p({project:p({id:X,githubOwner:x().nullable(),githubRepo:x().nullable()}),connections:g(p({id:X,provider:v([`GITHUB`,`SLACK`]),externalId:x().min(1)})).max(20),sourceNames:S(x(),x().max(500))});function Xe(e){return{name:e.name,instructions:e.instructions,executionConfig:JSON.stringify(e.executionConfig,null,2),triggers:e.triggers.map(({id:e,description:t,filterInstructions:n,isEnabled:r,...i})=>({key:crypto.randomUUID(),savedId:e,description:t,filterInstructions:n??``,event:JSON.stringify(i,null,2)}))}}function Ze(e){let t=JSON.parse(e.executionConfig);return Z.parse({name:e.name,instructions:e.instructions,executionConfig:t,triggers:e.triggers.map(e=>({...S(x(),b()).parse(JSON.parse(e.event)),...e.savedId?{id:e.savedId}:{},description:e.description,filterInstructions:e.filterInstructions.trim()||null,isEnabled:!1}))})}function Qe(e){let t=JSON.parse(e);return Z.parse(t)}function $e(e,t,n){if(!n)return t;let r=new Map([...e?.slack.channels??[],...t.slack.channels??[]].map(e=>[e.id,e]));return{...t,slack:{...t.slack,channels:[...r.values()]}}}function et(e){let[t,n]=(0,B.useState)(e.agent),[r,i]=(0,B.useState)(()=>e.agent.specification?Xe(e.agent.specification):null),[a,o]=(0,B.useState)(e.initialReplacement??!1),[s,c]=(0,B.useState)(``),[l,u]=(0,B.useState)(),[d,f]=(0,B.useState)(),[p,m]=(0,B.useState)(),[h,g]=(0,B.useState)(!1),[_,v]=(0,B.useState)(null),y=(0,B.useRef)(!1),b=(0,B.useRef)(0),x=(0,B.useRef)(0),S=(0,B.useRef)(0),C=(0,B.useRef)(0),w=(0,B.useRef)(!0);(0,B.useEffect)(()=>(w.current=!0,()=>{w.current=!1}),[]);let T=()=>{b.current+=1,y.current||(S.current+=1,v(null)),f(void 0),m(void 0),g(!1),u(void 0)},E=e=>{T(),i(e)},ee=e=>{T(),c(e)},te=()=>a?Qe(s):r?Ze(r):null,D=e=>w.current&&b.current===e,O=(e,t)=>{D(t)&&u(e instanceof Error?e.message:`Couldn't complete this request. Try again.`)},k=e=>{let t={version:b.current,request:++S.current};return v(e),u(void 0),t},A=e=>{D(e.version)&&S.current===e.request&&v(null)},j=()=>{try{let e=te();if(!e)throw Error(`A complete replacement is required.`);return e}catch{return u(`Check the complete configuration: name, instructions, execution settings and event JSON must be valid. Supply the whole intended specification for replacement.`),null}},ne=async n=>{y.current=!0,C.current+=1;let r=k(`save`);try{await e.onSave(n,t.managementRevision)}catch(e){O(e,r.version)}finally{y.current=!1,A(r)}},M=async t=>{let n=++C.current,r=k(`validate`);try{let i=await e.onValidate(t);D(r.version)&&C.current===n&&f(i)}catch(e){C.current===n&&O(e,r.version)}finally{A(r)}},re=async t=>{let n=++x.current;g(!1);let r=k(`sources`);try{let i=await e.onSources(t);D(r.version)&&x.current===n&&m(e=>$e(e,i,!!t.cursor))}catch(e){x.current===n&&D(r.version)&&(g(!0),O(e,r.version))}finally{A(r)}},ie=(e,t={})=>{if(y.current)return;if(e===`sources`)return re(t);let n=j();if(n)return e===`save`?ne(n):M(n)},ae=e=>{T(),n(e),i(e.specification?Xe(e.specification):null),o(!1),c(``)};return{baseline:t,draft:r,updateDraft:E,replacementMode:a,replacement:s,updateReplacement:ee,startReplacement:()=>{T(),o(!0),c(``)},sourceSelectionChanged:T,error:l,preview:d,sources:p,sourceError:h,busy:_,attempt:ie,stale:t.managementRevision!==e.agent.managementRevision,reload:async()=>{if(!e.onReload||y.current)return;let t=k(`reload`);try{let n=await e.onReload();D(t.version)&&S.current===t.request&&ae(n)}catch(e){S.current===t.request&&O(e,t.version)}finally{A(t)}}}}function tt(e){let t=et(e),{draft:n}=t,r=(0,B.useId)(),i=!(n||t.replacementMode);return(0,z.jsxs)(`section`,{className:`min-w-0 space-y-5`,"aria-label":`Saved event editor`,children:[(0,z.jsx)(`h2`,{className:`text-xl font-semibold`,children:`Edit agent`}),(0,z.jsxs)(`p`,{className:`text-sm break-words`,children:[t.baseline.name,` · Saved management revision `,t.baseline.managementRevision]}),(i||t.replacementMode)&&(0,z.jsx)(je,{agent:t.baseline}),i?(0,z.jsxs)(`div`,{className:`space-y-3`,children:[(0,z.jsx)(`p`,{className:`text-sm`,children:`The exact saved specification is unavailable. Review existing facts, then explicitly replace the whole configuration. Retained records are inspection data.`}),(0,z.jsx)(l,{onClick:t.startReplacement,children:`Replace complete specification`}),(0,z.jsx)(l,{variant:`outline`,onClick:e.onCancel,children:`Cancel`})]}):(0,z.jsx)(`form`,{className:`min-w-0 space-y-5`,onSubmit:e=>{e.preventDefault(),t.attempt(`save`)},children:(0,z.jsxs)(`fieldset`,{disabled:t.busy===`save`||t.busy===`reload`,className:`min-w-0 space-y-4`,children:[t.replacementMode?(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(N,{htmlFor:`${r}-replacement`,children:`Full saved specification JSON`}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Supply the complete intended name, instructions, executionConfig and triggers. This blank input does not infer membership or repair stored fields automatically.`}),(0,z.jsx)(M,{id:`${r}-replacement`,"aria-label":`Full saved specification JSON`,className:`max-w-full font-mono text-xs`,rows:16,value:t.replacement,onChange:e=>t.updateReplacement(e.target.value)})]}):n&&(0,z.jsx)(nt,{editor:t,id:r}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Name-only edits preserve activation for known unchanged members. Task or execution edits pause triggers. Changed, reintroduced or unknown members pause and advance trigger revisions. Unclaimed queued work is cancelled; claimed snapshots continue. Re-enabling is needed for paused triggers and is not available here.`}),(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,z.jsx)(l,{type:`submit`,children:t.busy===`save`?`Saving…`:`Save changes`}),(0,z.jsx)(l,{type:`button`,variant:`outline`,onClick:()=>void t.attempt(`validate`),children:`Validate draft`}),(0,z.jsx)(l,{type:`button`,variant:`outline`,onClick:e.onCancel,children:`Cancel`})]})]})}),!i&&(0,z.jsx)(rt,{editor:t,id:r}),(0,z.jsx)(it,{editor:t,reloadAvailable:!!e.onReload})]})}function nt({editor:e,id:t}){let{draft:n,updateDraft:r}=e;return n?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(N,{htmlFor:`${t}-name`,children:`Name`}),(0,z.jsx)(D,{id:`${t}-name`,name:`name`,value:n.name,onChange:e=>r({...n,name:e.target.value})})]}),(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(N,{htmlFor:`${t}-instructions`,children:`Instructions`}),(0,z.jsx)(M,{id:`${t}-instructions`,"aria-label":`Instructions`,rows:5,value:n.instructions,onChange:e=>r({...n,instructions:e.target.value})})]}),n.triggers.map((i,a)=>(0,z.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,z.jsx)(be,{id:t,trigger:i,original:e.baseline.specification?.triggers.find(e=>e.id===i.savedId),index:a,sourceNames:{},onChange:(e,t)=>r({...n,triggers:n.triggers.map((n,r)=>r===a?{...n,[e]:t}:n)})}),(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,z.jsxs)(l,{type:`button`,variant:`outline`,size:`sm`,disabled:a===0,onClick:()=>{let e=[...n.triggers],t=e[a-1],i=e[a];t&&i&&([e[a-1],e[a]]=[i,t],r({...n,triggers:e}))},children:[`Move event `,a+1,` up`]}),(0,z.jsxs)(l,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>r({...n,triggers:n.triggers.filter(e=>e.key!==i.key)}),children:[`Remove event `,a+1]})]})]},i.key)),(0,z.jsx)(l,{type:`button`,variant:`outline`,onClick:()=>r({...n,triggers:[...n.triggers,{key:crypto.randomUUID(),savedId:void 0,description:``,filterInstructions:``,event:`{}`}]}),children:`Add event`}),(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(N,{htmlFor:`${t}-execution`,children:`Execution settings JSON`}),(0,z.jsx)(M,{id:`${t}-execution`,"aria-label":`Execution settings`,className:`max-w-full font-mono text-xs`,rows:5,value:n.executionConfig,onChange:e=>r({...n,executionConfig:e.target.value})}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Omitted provider, model and reasoningEffort stay inherited. Preview does not write discovered defaults into this draft.`})]})]}):null}function rt({editor:e,id:t}){let[n,r]=(0,B.useState)(``);return(0,z.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,z.jsx)(N,{htmlFor:`${t}-connection`,children:`Slack connection ID (optional)`}),(0,z.jsx)(D,{id:`${t}-connection`,disabled:e.busy===`save`||e.busy===`reload`,value:n,onChange:t=>{e.sourceSelectionChanged(),r(t.target.value)}}),(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,z.jsx)(l,{type:`button`,variant:`outline`,disabled:e.busy===`save`,onClick:()=>void e.attempt(`sources`,n?{connectionId:n}:{}),children:e.sourceError&&!e.sources?`Retry project sources`:`Refresh project sources`}),e.sources?.slack.nextCursor&&(0,z.jsx)(l,{type:`button`,variant:`outline`,disabled:e.busy===`sources`||e.busy===`save`,onClick:()=>void e.attempt(`sources`,{...n?{connectionId:n}:{},cursor:e.sources?.slack.nextCursor??void 0}),children:e.sourceError?`Retry more Slack channels`:`More Slack channels`})]})]})}function it({editor:e,reloadAvailable:t}){return(0,z.jsxs)(z.Fragment,{children:[` `,e.error&&(0,z.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive break-words`,children:e.error}),e.stale&&(0,z.jsx)(`p`,{role:`status`,className:`text-sm`,children:`The saved definition changed. Your entered fields and original save token are preserved. Review or copy your edits before reloading.`}),t&&(0,z.jsx)(l,{type:`button`,variant:`outline`,disabled:e.busy===`save`,onClick:()=>void e.reload(),children:`Discard edits and reload saved configuration`}),e.busy&&e.busy!==`save`&&(0,z.jsxs)(`p`,{role:`status`,className:`inline-flex items-center gap-2 text-sm`,children:[(0,z.jsx)(c,{className:`size-3`,"aria-hidden":`true`}),e.busy===`validate`?`Validating current draft…`:e.busy===`sources`?`Loading project sources…`:`Reloading saved configuration…`]}),e.preview&&(0,z.jsx)(Ne,{preview:e.preview}),e.sources&&(0,z.jsx)(Pe,{sources:e.sources})]})}function at({projectId:e,projectSlug:t,onCancel:n}){let i=r(),s=`event-agent:${e}`,c=ge(s),d=ye(s),[f,p]=(0,B.useState)(!1),m=(0,B.useRef)(void 0),h=a.workspace.listForProject.useQuery({projectId:e});return f?(0,z.jsx)(u,{size:`compact`,message:`Canceling event agent draft…`}):(0,z.jsxs)(z.Fragment,{children:[c.isPending&&(0,z.jsx)(u,{size:`compact`,message:`Creating event agent workspace…`}),(0,z.jsx)(Se,{query:h,errorTitle:`Couldn't load workspace names`,loadingMessage:`Loading workspace names…`,size:`compact`,children:r=>(0,z.jsx)(_e,{projectId:e,purpose:`event-agent`,existingNames:r.workspaces.map(e=>e.name),onCancel:n,onCreated:e=>{i(`/projects/${encodeURIComponent(t)}/workspaces/${encodeURIComponent(e)}`)}},e)}),!(h.data||c.isPending)&&(0,z.jsx)(l,{variant:`outline`,onClick:()=>{if(c.isPending||d.isRestoring||f)return;m.current??=d.hasDraft?d.draft.revision:void 0,p(!0);let e=m.current?d.clearSubmittedDraft(m.current):d.discardDraft();o(e.then(()=>{m.current=void 0,ve(s).draft===null&&n()}).finally(()=>p(!1)),`Couldn't clear canceled event agent draft.`)},disabled:d.isRestoring,children:`Cancel`})]})}export{Ye as a,V as c,Te as d,Ce as f,X as i,Ae as l,tt as n,Z as o,qe as r,Me as s,at as t,ke as u};
@@ -1,4 +1,4 @@
1
- import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{n as t,t as n}from"./jsx-runtime-CldxteV5.js";import{n as r}from"./dist-DxBCWJgX.js";import{n as i}from"./trpc-D9WuCSM1.js";import{t as a}from"./Warning.es-BRY0GI4S.js";import{t as o}from"./WarningCircle.es-D-X961df.js";import{t as s}from"./button-Dslj7pht.js";import{t as c}from"./loading-SklnwAL1.js";import{d as l,t as u}from"./use-persistent-scroll-DMRAfhA7.js";import{t as d}from"./formatters-CbVS7bYs.js";import{L as f,x as p}from"./chat-BsZewCkt.js";import{$t as m,Dt as h,Ot as g}from"./index-BHTworEd.js";import{n as _}from"./use-diff-highlighting-CLJSy52c.js";var v=e(t(),1),y=32768;function b(e){return e.length>32768?!1:e.length*3<=32768||new TextEncoder().encode(e).byteLength<=y}var x=n(),S=new Set([`text`,`plain`,`plaintext`,`txt`]);function C(e,t){let n=e.ownerDocument,r=()=>{let i=n.getSelection();i&&!i.isCollapsed&&i.rangeCount>0&&i.getRangeAt(0).intersectsNode(e)||(n.removeEventListener(`selectionchange`,r),t())};return n.addEventListener(`selectionchange`,r),r(),()=>n.removeEventListener(`selectionchange`,r)}function w({block:e,tokens:t,language:n}){let r=(0,v.useRef)(null),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(()=>({block:e,tokens:null})),c=o.block===e?o.tokens:null;(0,v.useEffect)(()=>{let n=i?t:null;if(o.block===e&&o.tokens===n)return;let a=r.current;if(a)return C(a,()=>s(t=>t.block===e&&t.tokens===n?t:{block:e,tokens:n}))},[e,t,i,o]),(0,v.useEffect)(()=>{if(!r.current||typeof IntersectionObserver>`u`)return;let e=r.current,t,n=new IntersectionObserver(([n])=>{t?.(),t=C(e,()=>a(n?.isIntersecting??!1))},{rootMargin:`300px`});return n.observe(r.current),()=>{n.disconnect(),t?.()}},[]);let l=e=>{let t=0;return e.map(e=>{let n=t;return t+=e.content.length,(0,x.jsx)(`span`,{className:e.className,children:e.content},n)})};return(0,x.jsxs)(`div`,{ref:r,style:{display:`flex`,minHeight:`${e.lines.length*1.5}em`},children:[(0,x.jsx)(`span`,{"aria-hidden":`true`,className:`react-syntax-highlighter-line-number select-none text-muted-foreground`,style:{flexShrink:0,width:`4em`,paddingRight:`1em`,textAlign:`right`},children:e.lines.map((t,n)=>e.firstLine+n).join(`
1
+ import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{n as t,t as n}from"./jsx-runtime-CldxteV5.js";import{n as r}from"./dist-DxBCWJgX.js";import{n as i}from"./trpc-D9WuCSM1.js";import{t as a}from"./Warning.es-BRY0GI4S.js";import{t as o}from"./WarningCircle.es-D-X961df.js";import{t as s}from"./button-Dslj7pht.js";import{t as c}from"./loading-SklnwAL1.js";import{d as l,t as u}from"./use-persistent-scroll-DMRAfhA7.js";import{t as d}from"./formatters-CbVS7bYs.js";import{L as f,x as p}from"./chat-B7u27d-i.js";import{$t as m,Dt as h,Ot as g}from"./index-GmSorqXd.js";import{n as _}from"./use-diff-highlighting-CLJSy52c.js";var v=e(t(),1),y=32768;function b(e){return e.length>32768?!1:e.length*3<=32768||new TextEncoder().encode(e).byteLength<=y}var x=n(),S=new Set([`text`,`plain`,`plaintext`,`txt`]);function C(e,t){let n=e.ownerDocument,r=()=>{let i=n.getSelection();i&&!i.isCollapsed&&i.rangeCount>0&&i.getRangeAt(0).intersectsNode(e)||(n.removeEventListener(`selectionchange`,r),t())};return n.addEventListener(`selectionchange`,r),r(),()=>n.removeEventListener(`selectionchange`,r)}function w({block:e,tokens:t,language:n}){let r=(0,v.useRef)(null),[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(()=>({block:e,tokens:null})),c=o.block===e?o.tokens:null;(0,v.useEffect)(()=>{let n=i?t:null;if(o.block===e&&o.tokens===n)return;let a=r.current;if(a)return C(a,()=>s(t=>t.block===e&&t.tokens===n?t:{block:e,tokens:n}))},[e,t,i,o]),(0,v.useEffect)(()=>{if(!r.current||typeof IntersectionObserver>`u`)return;let e=r.current,t,n=new IntersectionObserver(([n])=>{t?.(),t=C(e,()=>a(n?.isIntersecting??!1))},{rootMargin:`300px`});return n.observe(r.current),()=>{n.disconnect(),t?.()}},[]);let l=e=>{let t=0;return e.map(e=>{let n=t;return t+=e.content.length,(0,x.jsx)(`span`,{className:e.className,children:e.content},n)})};return(0,x.jsxs)(`div`,{ref:r,style:{display:`flex`,minHeight:`${e.lines.length*1.5}em`},children:[(0,x.jsx)(`span`,{"aria-hidden":`true`,className:`react-syntax-highlighter-line-number select-none text-muted-foreground`,style:{flexShrink:0,width:`4em`,paddingRight:`1em`,textAlign:`right`},children:e.lines.map((t,n)=>e.firstLine+n).join(`
2
2
  `)}),(0,x.jsx)(`code`,{className:`language-${n}`,style:{fontFamily:`var(--font-mono)`},children:e.withinByteBudget&&c?.has(e.firstLine-1)?e.lines.map((t,n)=>{let r=e.firstLine+n,i=c.get(r-1);return(0,x.jsxs)(`span`,{children:[i?l(i):t,n<e.lines.length-1||e.hasNext?`
3
3
  `:``]},r)}):e.content})]})}function T({content:e,language:t,theme:n}){let r=(0,v.useMemo)(()=>{let t=e.split(`
4
4
  `),n=[];for(let e=0;e<t.length;e+=128){let r=t.slice(e,e+128),i=r.join(`
@@ -1 +1 @@
1
- import"./src-BWF7jMDv.js";import"./chunk-DSNLSHJZ-CSSZ0uRv.js";import"./chunk-7S6XSTFO-v9BVbuJB.js";import"./chunk-YZO67HFG-DrH1RXFI.js";import"./chunk-AQDTSKZB-Bh2e4nVN.js";import"./chunk-UHW7PFBP-FWZD9983.js";import"./chunk-HAGFOTED-CTCHAkn7.js";import"./chunk-ZAUX2LTX-slbBeHT4.js";import"./chunk-WQQL4CDK-V1ZC59EX.js";import"./chunk-55XCU76K-BdizGL-z.js";import"./chunk-XXDRQBXY-CnbRkih_.js";import"./chunk-VQ5W62QI-BxZNPUPp.js";import"./chunk-HNE4Q36P-SXol6mIL.js";export{n as diagram}from"./chunk-NQOKRVIF-CMnJ0k4D.js";import"./mermaid-diagram-DHR-LEin.js";
1
+ import"./src-BWF7jMDv.js";import"./chunk-DSNLSHJZ-CSSZ0uRv.js";import"./chunk-7S6XSTFO-v9BVbuJB.js";import"./chunk-YZO67HFG-DrH1RXFI.js";import"./chunk-AQDTSKZB-Bh2e4nVN.js";import"./chunk-UHW7PFBP-FWZD9983.js";import"./chunk-HAGFOTED-CTCHAkn7.js";import"./chunk-ZAUX2LTX-slbBeHT4.js";import"./chunk-WQQL4CDK-V1ZC59EX.js";import"./chunk-55XCU76K-BdizGL-z.js";import"./chunk-XXDRQBXY-CnbRkih_.js";import"./chunk-VQ5W62QI-BxZNPUPp.js";import"./chunk-HNE4Q36P-SXol6mIL.js";export{n as diagram}from"./chunk-NQOKRVIF-LCflra3k.js";import"./mermaid-diagram-7d3eG33H.js";
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{n as t,t as n}from"./jsx-runtime-CldxteV5.js";import{J as r,K as i,q as a}from"./chat-BsZewCkt.js";var o=e(t(),1),s=n(),c=({code:e,isIncomplete:t=!1,language:n,maxHeight:c,raw:l,className:u,startLine:d,lineNumbers:f,...p})=>{let{shikiTheme:m}=(0,o.useContext)(a),h=r(),[g,_]=(0,o.useState)(l);return(0,o.useEffect)(()=>{if(!h){_(l);return}let r=!0,i=h.highlight({code:e,isIncomplete:t,language:n,themes:m},e=>{r&&_(e)});return i&&_(i),()=>{r=!1}},[e,t,n,m,h,l]),(0,s.jsx)(i,{className:u,language:n,lineNumbers:f,maxHeight:c,result:g,startLine:d,...p})};export{c as HighlightedCodeBlockBody};
1
+ import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{n as t,t as n}from"./jsx-runtime-CldxteV5.js";import{J as r,K as i,q as a}from"./chat-B7u27d-i.js";var o=e(t(),1),s=n(),c=({code:e,isIncomplete:t=!1,language:n,maxHeight:c,raw:l,className:u,startLine:d,lineNumbers:f,...p})=>{let{shikiTheme:m}=(0,o.useContext)(a),h=r(),[g,_]=(0,o.useState)(l);return(0,o.useEffect)(()=>{if(!h){_(l);return}let r=!0,i=h.highlight({code:e,isIncomplete:t,language:n,themes:m},e=>{r&&_(e)});return i&&_(i),()=>{r=!1}},[e,t,n,m,h,l]),(0,s.jsx)(i,{className:u,language:n,lineNumbers:f,maxHeight:c,result:g,startLine:d,...p})};export{c as HighlightedCodeBlockBody};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{n as t,t as n}from"./jsx-runtime-CldxteV5.js";import{l as r}from"./hooks-CZYZW9i_.js";import{n as i}from"./trpc-D9WuCSM1.js";import{t as a}from"./loading-SklnwAL1.js";import{_t as o}from"./index-BHTworEd.js";var s=e(t(),1),c=n();function l(){let e=r(),{data:t,isLoading:n,error:l}=i.project.list.useQuery({isArchived:!1});return(0,s.useEffect)(()=>{if(!n){if(l)e(`/projects`,{replace:!0});else if(t&&t.length>0){let n=o(t);if(!n)return;e(`/projects/${n}`,{replace:!0})}else e(`/projects/new`,{replace:!0})}},[n,t,l,e]),(0,c.jsx)(a,{message:l?`Opening projects…`:`Loading projects…`})}export{l as default};
1
+ import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{n as t,t as n}from"./jsx-runtime-CldxteV5.js";import{l as r}from"./hooks-CZYZW9i_.js";import{n as i}from"./trpc-D9WuCSM1.js";import{t as a}from"./loading-SklnwAL1.js";import{_t as o}from"./index-GmSorqXd.js";var s=e(t(),1),c=n();function l(){let e=r(),{data:t,isLoading:n,error:l}=i.project.list.useQuery({isArchived:!1});return(0,s.useEffect)(()=>{if(!n){if(l)e(`/projects`,{replace:!0});else if(t&&t.length>0){let n=o(t);if(!n)return;e(`/projects/${n}`,{replace:!0})}else e(`/projects/new`,{replace:!0})}},[n,t,l,e]),(0,c.jsx)(a,{message:l?`Opening projects…`:`Loading projects…`})}export{l as default};