orc-ai 0.1.55 → 0.1.56
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.
- package/README.md +8 -0
- package/dist/index.js +519 -517
- package/dist/web/assets/{Agents-D70pZAkB.js → Agents-2yxnhVdq.js} +2 -2
- package/dist/web/assets/{Attention-DoTjQvwX.js → Attention-7HzVxjnr.js} +2 -2
- package/dist/web/assets/{Audit-BilD5tHL.js → Audit-B4gfepiU.js} +1 -1
- package/dist/web/assets/{Dashboard-BrpclE6i.js → Dashboard-C9VHH7Bw.js} +1 -1
- package/dist/web/assets/{DocumentWorkspace-BirLb0Py.js → DocumentWorkspace-CXhBLYZl.js} +1 -1
- package/dist/web/assets/{FileEditor-Cfl56W9G.js → FileEditor-BYg65oY4.js} +1 -1
- package/dist/web/assets/{JobWebhooks-csgdKaIu.js → JobWebhooks-KpcTAXv_.js} +1 -1
- package/dist/web/assets/{Jobs-BeDH5Nqx.js → Jobs-Bp1I-ltH.js} +1 -1
- package/dist/web/assets/Knowledge-BPUBPeLD.js +1 -0
- package/dist/web/assets/{Markdown-cNY95m5f.js → Markdown-DLhioXL1.js} +2 -2
- package/dist/web/assets/{MarkdownEditor-CPlYZ0ux.js → MarkdownEditor-CVlZh0ne.js} +2 -2
- package/dist/web/assets/{MarkdownRenderer-C4od8dIW.js → MarkdownRenderer-C3V6dF9x.js} +4 -4
- package/dist/web/assets/{PackageCatalog-rIC8EqCV.js → PackageCatalog-BgcR5roL.js} +2 -2
- package/dist/web/assets/PackageRunDialog-DqyBBb62.js +105 -0
- package/dist/web/assets/{Pager-Bc666Oa5.js → Pager-BzhZAMGm.js} +1 -1
- package/dist/web/assets/Projects-CrqgZTvD.js +3 -0
- package/dist/web/assets/{ResumeActions-Xi3gsryf.js → ResumeActions-DX6Sq1Hj.js} +1 -1
- package/dist/web/assets/{Rules-u4Yt3UWU.js → Rules-C9u9kghC.js} +1 -1
- package/dist/web/assets/{ScratchpadDiagramEditor-CEZLGEOO.js → ScratchpadDiagramEditor-CHuShgwC.js} +6 -6
- package/dist/web/assets/Scratchpads-BFbBe_OY.js +10 -0
- package/dist/web/assets/{Sessions-xflxxp3f.js → Sessions-C8jEzYA5.js} +3 -3
- package/dist/web/assets/{Settings-C5tS2MvS.js → Settings-D3w2C1pH.js} +5 -5
- package/dist/web/assets/{Skills-QaW-IPD1.js → Skills-BAYdBjBy.js} +2 -2
- package/dist/web/assets/{SourceEditor-BXHhVnEe.js → SourceEditor-C53cgIzH.js} +1 -1
- package/dist/web/assets/TaskDetailSheet-Cy1ARmWP.js +1 -0
- package/dist/web/assets/{Tasks-CsBS5O9A.js → Tasks-xj6ryc6x.js} +5 -5
- package/dist/web/assets/Terminals-D3S17pE-.js +3 -0
- package/dist/web/assets/{ViewHeader-Ce5HQRJu.js → ViewHeader-BUk4Owsd.js} +1 -1
- package/dist/web/assets/{Webhooks-BCKPHvAT.js → Webhooks-C3r2nWXL.js} +1 -1
- package/dist/web/assets/{ar-SA-G6X2FPQ2-Dxcs6bnC.js → ar-SA-G6X2FPQ2-StjSH8Ce.js} +1 -1
- package/dist/web/assets/{az-AZ-76LH7QW2-DzTRmo_5.js → az-AZ-76LH7QW2-DMeT_rzu.js} +1 -1
- package/dist/web/assets/{bg-BG-XCXSNQG7-GVnVbOJF.js → bg-BG-XCXSNQG7-B9FjKIQK.js} +1 -1
- package/dist/web/assets/{bn-BD-2XOGV67Q-CBnLWZsm.js → bn-BD-2XOGV67Q-DCtJUb-k.js} +1 -1
- package/dist/web/assets/{ca-ES-6MX7JW3Y-nF87CFCd.js → ca-ES-6MX7JW3Y-C0MW6BIS.js} +1 -1
- package/dist/web/assets/{chunk-EIO257PC-C5HXDKyY.js → chunk-EIO257PC-Dm2AhYth.js} +1 -1
- package/dist/web/assets/{cs-CZ-2BRQDIVT-Cz5r5OEj.js → cs-CZ-2BRQDIVT-DFWsiwws.js} +1 -1
- package/dist/web/assets/{da-DK-5WZEPLOC-B2TNmBRb.js → da-DK-5WZEPLOC-CvdXrR_O.js} +1 -1
- package/dist/web/assets/{de-DE-XR44H4JA-BNOqSnix.js → de-DE-XR44H4JA-CzCzokeu.js} +1 -1
- package/dist/web/assets/{el-GR-BZB4AONW-BzwJhjCV.js → el-GR-BZB4AONW-C1tHfh2N.js} +1 -1
- package/dist/web/assets/{en-B4ZKOASM-qumcDTz5.js → en-B4ZKOASM-BxNq_83e.js} +1 -1
- package/dist/web/assets/{es-ES-U4NZUMDT-CYNwXzvM.js → es-ES-U4NZUMDT-BnLO4i_z.js} +1 -1
- package/dist/web/assets/{eu-ES-A7QVB2H4-Bt_WsfwK.js → eu-ES-A7QVB2H4-DHg6EoOY.js} +1 -1
- package/dist/web/assets/{fa-IR-HGAKTJCU-TG6ul0gf.js → fa-IR-HGAKTJCU-Dz3G0X81.js} +1 -1
- package/dist/web/assets/{fi-FI-Z5N7JZ37-BEmxMqCH.js → fi-FI-Z5N7JZ37-CxHs1LFS.js} +1 -1
- package/dist/web/assets/{fr-FR-RHASNOE6-DVlOJmrm.js → fr-FR-RHASNOE6-BgHnhTUQ.js} +1 -1
- package/dist/web/assets/{gl-ES-HMX3MZ6V-C51CVUC3.js → gl-ES-HMX3MZ6V-PHDdUi1o.js} +1 -1
- package/dist/web/assets/{he-IL-6SHJWFNN-BaHbjpvX.js → he-IL-6SHJWFNN-Dgp1qV9h.js} +1 -1
- package/dist/web/assets/{hi-IN-IWLTKZ5I-BnsUhtYU.js → hi-IN-IWLTKZ5I-DD9fuJz_.js} +1 -1
- package/dist/web/assets/{highlighted-body-JLMTFACH-CCL_Oa2N.js → highlighted-body-JLMTFACH-B366lM_z.js} +1 -1
- package/dist/web/assets/{hu-HU-A5ZG7DT2-DJAd0DXQ.js → hu-HU-A5ZG7DT2-CJPfBrX8.js} +1 -1
- package/dist/web/assets/{id-ID-SAP4L64H-D_Sp4hWt.js → id-ID-SAP4L64H-F1GT6epL.js} +1 -1
- package/dist/web/assets/{image-GAAHSSAO-uTNUnk7Z.js → image-GAAHSSAO-aSpfuUDe.js} +1 -1
- package/dist/web/assets/{index-C60WCVxH.js → index-B8heHbQj.js} +22 -22
- package/dist/web/assets/index-rYKGiHai.css +1 -0
- package/dist/web/assets/{it-IT-JPQ66NNP-B2VOtgAl.js → it-IT-JPQ66NNP-B9Jcqjo7.js} +1 -1
- package/dist/web/assets/{ja-JP-DBVTYXUO-D8n4LcP-.js → ja-JP-DBVTYXUO-DM8Z0Br0.js} +1 -1
- package/dist/web/assets/{kaa-6HZHGXH3-BvK7fQHB.js → kaa-6HZHGXH3-DMcVa6UB.js} +1 -1
- package/dist/web/assets/{kab-KAB-ZGHBKWFO-CBS-7rLX.js → kab-KAB-ZGHBKWFO-CDCDMjhG.js} +1 -1
- package/dist/web/assets/{kk-KZ-P5N5QNE5-D6rLwfEb.js → kk-KZ-P5N5QNE5-DtGGXrwt.js} +1 -1
- package/dist/web/assets/{km-KH-HSX4SM5Z-DQKGOVey.js → km-KH-HSX4SM5Z-C4b3qZob.js} +1 -1
- package/dist/web/assets/{ko-KR-MTYHY66A-D-mh0Zog.js → ko-KR-MTYHY66A-rr326_4q.js} +1 -1
- package/dist/web/assets/{ku-TR-6OUDTVRD-02Q4uBGz.js → ku-TR-6OUDTVRD-B-9PzNgR.js} +1 -1
- package/dist/web/assets/{lt-LT-XHIRWOB4-DLL22EcK.js → lt-LT-XHIRWOB4-tltV7-rY.js} +1 -1
- package/dist/web/assets/{lv-LV-5QDEKY6T-D3GBaG3q.js → lv-LV-5QDEKY6T-CnZ-Vcu3.js} +1 -1
- package/dist/web/assets/mermaid-WFAXDIZX-CzMMoxBt.js +1 -0
- package/dist/web/assets/{mr-IN-CRQNXWMA--HI3GWMp.js → mr-IN-CRQNXWMA-BuSJww3b.js} +1 -1
- package/dist/web/assets/{my-MM-5M5IBNSE-BzpoSrEn.js → my-MM-5M5IBNSE-C0SPdyz-.js} +1 -1
- package/dist/web/assets/{nb-NO-T6EIAALU-BpE3Sd7f.js → nb-NO-T6EIAALU-DAr4ipc6.js} +1 -1
- package/dist/web/assets/{nl-NL-IS3SIHDZ-CVXeRx8i.js → nl-NL-IS3SIHDZ-BroBShmh.js} +1 -1
- package/dist/web/assets/{nn-NO-6E72VCQL-c6qBqD3x.js → nn-NO-6E72VCQL-DAZfghZF.js} +1 -1
- package/dist/web/assets/{oc-FR-POXYY2M6-Cau2e1RB.js → oc-FR-POXYY2M6-CgnF6cNo.js} +1 -1
- package/dist/web/assets/{pa-IN-N4M65BXN-BZBndxoR.js → pa-IN-N4M65BXN-C6DaEQNL.js} +1 -1
- package/dist/web/assets/{percentages-BXMCSKIN-D3Fw5F9S.js → percentages-BXMCSKIN-DKn3LlG1.js} +1 -1
- package/dist/web/assets/{pl-PL-T2D74RX3-Z_GpAanN.js → pl-PL-T2D74RX3-CEI_8yzI.js} +1 -1
- package/dist/web/assets/{pt-BR-5N22H2LF-BlVpEHGK.js → pt-BR-5N22H2LF-BYXxlXMo.js} +1 -1
- package/dist/web/assets/{pt-PT-UZXXM6DQ-QuQH0hsZ.js → pt-PT-UZXXM6DQ-BPERnUo8.js} +1 -1
- package/dist/web/assets/{ro-RO-JPDTUUEW-BGlQpI3X.js → ro-RO-JPDTUUEW-B7MvFTc9.js} +1 -1
- package/dist/web/assets/{ru-RU-B4JR7IUQ-CHU0e8TZ.js → ru-RU-B4JR7IUQ-CCrkWZEJ.js} +1 -1
- package/dist/web/assets/{scratchpad-routes-Dbj7u895.js → scratchpad-routes-BZ1FFIDw.js} +1 -1
- package/dist/web/assets/{si-LK-N5RQ5JYF-9PXfGp8N.js → si-LK-N5RQ5JYF-C0ICDEoA.js} +1 -1
- package/dist/web/assets/{sk-SK-C5VTKIMK-CuzZf_b9.js → sk-SK-C5VTKIMK-EzM1V-Y7.js} +1 -1
- package/dist/web/assets/{sl-SI-NN7IZMDC-DrOH-WzJ.js → sl-SI-NN7IZMDC-DT6fu4w-.js} +1 -1
- package/dist/web/assets/subset-shared.chunk-B7nZY03G.js +1 -0
- package/dist/web/assets/{subset-worker.chunk-C1uKhPt9.js → subset-worker.chunk-ZvAeJWaw.js} +1 -1
- package/dist/web/assets/{sv-SE-XGPEYMSR-BhIUxUn8.js → sv-SE-XGPEYMSR-m-3DaaJB.js} +1 -1
- package/dist/web/assets/{ta-IN-2NMHFXQM-DxBax1RW.js → ta-IN-2NMHFXQM-5gE4gUmT.js} +1 -1
- package/dist/web/assets/{th-TH-HPSO5L25-DA8qp-YV.js → th-TH-HPSO5L25-B9rD_0kV.js} +1 -1
- package/dist/web/assets/{tr-TR-DEFEU3FU-3u6WSMcx.js → tr-TR-DEFEU3FU-CFfzrv-A.js} +1 -1
- package/dist/web/assets/{uk-UA-QMV73CPH-BbCm-sIk.js → uk-UA-QMV73CPH-BTdATlL7.js} +1 -1
- package/dist/web/assets/{vi-VN-M7AON7JQ-DgsVZ_V1.js → vi-VN-M7AON7JQ-BiM0whRR.js} +1 -1
- package/dist/web/assets/{zh-CN-LNUGB5OW-DOVvsMem.js → zh-CN-LNUGB5OW-IIFWcK2y.js} +1 -1
- package/dist/web/assets/{zh-HK-E62DVLB3-BuhcmxhT.js → zh-HK-E62DVLB3-6bWTGYt9.js} +1 -1
- package/dist/web/assets/{zh-TW-RAJ6MFWO-DieBH0AH.js → zh-TW-RAJ6MFWO-C3juzgqu.js} +1 -1
- package/dist/web/index.html +4 -4
- package/package.json +1 -1
- package/dist/web/assets/Knowledge-Bhe2osQ9.js +0 -1
- package/dist/web/assets/PackageRunDialog-BPLlcUBW.js +0 -105
- package/dist/web/assets/Projects-C5tjWMiN.js +0 -3
- package/dist/web/assets/Scratchpads-BINR8pcN.js +0 -10
- package/dist/web/assets/TaskDetailSheet-BIMcgJGc.js +0 -1
- package/dist/web/assets/Terminals-D3Yo-p_A.js +0 -3
- package/dist/web/assets/arrow-left-vCG_8rdy.js +0 -1
- package/dist/web/assets/folder-open-BQI4k9Xd.js +0 -1
- package/dist/web/assets/index-ghfkdpY-.css +0 -1
- package/dist/web/assets/mermaid-WFAXDIZX-B8XO7yhf.js +0 -1
- package/dist/web/assets/subset-shared.chunk-CNd4ljrr.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{n as r}from"./QueryClientProvider-DlPztvhd.js";import{n as i,t as a}from"./useMutation-HX90wI4L.js";import{t as o,u as s}from"./chunk-OB3PAWPO-1IihCzFx.js";import{t as c}from"./button-CXYVslgR.js";import{t as l}from"./label-wk_QKooL.js";import{n as u}from"./client-nzMXason.js";import{a as d,n as f,o as p,t as m}from"./dialog-Juth7dP_.js";import{Ft as h,G as g,
|
|
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,u as s}from"./chunk-OB3PAWPO-1IihCzFx.js";import{t as c}from"./button-CXYVslgR.js";import{t as l}from"./label-wk_QKooL.js";import{n as u}from"./client-nzMXason.js";import{a as d,n as f,o as p,t as m}from"./dialog-Juth7dP_.js";import{Ft as h,G as g,K as _,Mt as v,Nt as y,Pt as b,W as x,X as S,Y as C,ct as w,fn as T,p as E}from"./index-B8heHbQj.js";import{i as D,n as O,t as k}from"./PackageRunDialog-DqyBBb62.js";import{t as A}from"./ConfirmDialog-Cyd60q9b.js";import{t as j}from"./ErrorState-BrKz7Mii.js";import{t as M}from"./ViewHeader-BUk4Owsd.js";import{t as N}from"./useDetailRoute-DOhAbdV7.js";import{t as P}from"./view-params-DD7i9s5g.js";var F=e(t(),1),I={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 z(e,t,n){let r=R(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 B(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 V(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 H(e,t){let n=R(e);D(n.document.get(`tools`,!0))||n.document.set(`tools`,{});let r=n.document.get(`tools`,!0);if(D(r))for(let{name:e}of V(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 U=n();function W(e){return V(e).map(e=>({...e,key:crypto.randomUUID()}))}function G({agent:e,pending:t,error:n,onSave:r}){let[i,a]=(0,F.useState)(e?.id??``),[o,s]=(0,F.useState)(e?.raw??I.specialist),[u,m]=(0,F.useState)(`fields`),[h,g]=(0,F.useState)(()=>e?W(e.fields):[]),[v,y]=(0,F.useState)(),b=(0,F.useMemo)(()=>{try{return{value:R(o),error:void 0}}catch(e){return{value:void 0,error:e.message}}},[o]),x=b.value?.fields,S;h.some(e=>!e.name.trim())?S=`Enter a name for every tool.`:new Set(h.map(e=>e.name.trim())).size!==h.length&&(S=`Tool names must be unique.`);let C=e?`Save changes`:`Create agent`;function T(e){g(e),e.every(e=>e.name.trim())&&new Set(e.map(e=>e.name.trim())).size===e.length&&s(H(o,e.map(e=>({...e,name:e.name.trim()}))))}function E(){if(y(void 0),u===`fields`){if(S)return;m(`source`)}else try{let e=R(o);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.`);g(W(e.fields)),m(`fields`)}catch(e){y(e.message)}}return(0,U.jsxs)(f,{className:`max-w-3xl max-h-[90vh] overflow-y-auto`,children:[(0,U.jsx)(d,{children:(0,U.jsx)(p,{children:e?`Edit ${e.name}`:`New shared agent`})}),(0,U.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e.preventDefault(),r(i,o)},children:[(0,U.jsxs)(`fieldset`,{disabled:t,className:`space-y-4`,children:[!e&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(l,{htmlFor:`agent-template`,children:`Starting template`}),(0,U.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=I[e.target.value];s(t),g(W(R(t).fields)),y(void 0)},children:[(0,U.jsx)(`option`,{value:`specialist`,children:`General specialist`}),(0,U.jsx)(`option`,{value:`reviewer`,children:`Reviewer`}),(0,U.jsx)(`option`,{value:`builder`,children:`Builder`})]})]}),(0,U.jsx)(l,{htmlFor:`agent-id`,children:`Agent ID`}),(0,U.jsx)(_,{id:`agent-id`,"data-testid":`agent-id-input`,value:i,disabled:!!e,onChange:e=>a(e.target.value),placeholder:`security-review`}),(0,U.jsx)(c,{type:`button`,variant:`outline`,"data-testid":`agent-editor-mode`,onClick:E,disabled:u===`fields`&&!!S,children:u===`fields`?`Edit YAML + Markdown`:`Edit fields`}),u===`source`?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(l,{htmlFor:`agent-definition`,children:`YAML configuration + Markdown instructions`}),(0,U.jsx)(w,{id:`agent-definition`,testId:`agent-content-input`,path:`agent.agent.md`,readOnly:t,height:400,value:o,onChange:e=>{s(e),y(void 0)}})]}):x&&(0,U.jsxs)(U.Fragment,{children:[[[`name`,`Name`],[`description`,`Description`],[`model`,`Model (optional)`],[`color`,`Color (optional)`]].map(([e,t])=>(0,U.jsxs)(`div`,{className:`space-y-1`,children:[(0,U.jsx)(l,{htmlFor:`agent-${e}`,children:t}),(0,U.jsx)(_,{id:`agent-${e}`,"data-testid":`agent-${e}-input`,value:typeof x[e]==`string`?x[e]:``,onChange:t=>s(z(o,e,t.target.value||(e===`description`?``:void 0)))})]},e)),(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,U.jsx)(`input`,{"data-testid":`agent-custom-tools`,type:`checkbox`,checked:x.tools!==void 0,onChange:e=>{g([]),s(z(o,`tools`,e.target.checked?{}:void 0))}}),` `,`Customize tool access`]}),(0,U.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,U.jsxs)(U.Fragment,{children:[h.map((e,t)=>(0,U.jsxs)(`div`,{"data-testid":`agent-tool-row`,className:`flex items-center gap-2`,children:[(0,U.jsx)(_,{"data-testid":`agent-tool-name`,"aria-label":`Tool ${t+1} name`,value:e.name,list:`agent-tool-suggestions`,onChange:e=>T(h.map((n,r)=>r===t?{...n,name:e.target.value}:n))}),(0,U.jsxs)(`label`,{className:`flex items-center gap-1 text-sm`,children:[(0,U.jsx)(`input`,{"data-testid":`agent-tool-allowed`,type:`checkbox`,checked:e.allowed,onChange:e=>T(h.map((n,r)=>r===t?{...n,allowed:e.target.checked}:n))}),` `,`Allowed`]}),(0,U.jsx)(c,{"data-testid":`agent-tool-remove`,type:`button`,variant:`outline`,onClick:()=>T(h.filter((e,n)=>n!==t)),children:`Remove`})]},e.key)),(0,U.jsx)(`datalist`,{id:`agent-tool-suggestions`,children:[`Read`,`Grep`,`Glob`,`Edit`,`Write`,`Bash`].map(e=>(0,U.jsx)(`option`,{value:e},e))}),(0,U.jsx)(c,{"data-testid":`agent-tool-add`,type:`button`,variant:`outline`,onClick:()=>T([...h,{key:crypto.randomUUID(),name:``,allowed:!0}]),children:`Add tool`})]})]}),(0,U.jsx)(l,{htmlFor:`agent-instructions`,children:`Instructions`}),(0,U.jsx)(w,{id:`agent-instructions`,testId:`agent-instructions-input`,path:`instructions.md`,readOnly:t,height:240,value:b.value?.body??``,onChange:e=>s(B(o,e))}),(0,U.jsx)(`p`,{className:`text-xs text-outline`,children:`Use YAML + Markdown to edit handoffs and additional configuration. Custom fields are preserved.`})]})]}),(n||b.error||v||u===`fields`&&S)&&(0,U.jsx)(`p`,{"data-testid":`agent-editor-error`,role:`alert`,className:`text-destructive`,children:n||b.error||v||S}),(0,U.jsx)(c,{"data-testid":`agent-submit`,type:`submit`,disabled:t||!i.trim()||!o.trim()||!!b.error||u===`fields`&&!!S,children:t?`Saving...`:C})]})]})}function K({embedded:e=!1}){let t=s(),n=new URLSearchParams(t.search).get(`project`)??`all`,[l,d]=P(`editorMode`,`read`,[`read`,`edit`,`split`]),[f,p]=P(`agentQuery`,``),D=r(),O=i({queryKey:[`agents`],queryFn:()=>u.agents.list()}),{selectedId:I,openDetail:L,closeDetail:R}=N(e?`/packages/agents`:`/agents`,`agentId`),z=i({queryKey:[`agent`,I],queryFn:()=>u.agents.get(I),enabled:!!I}),[B,V]=(0,F.useState)(!1),[H,W]=(0,F.useState)(),[K,q]=(0,F.useState)(!1),[J,Y]=(0,F.useState)(),X=a({mutationFn:u.agents.create,onSuccess:()=>{D.invalidateQueries({queryKey:[`agents`]}),V(!1)}}),Z=a({mutationFn:u.agents.delete,onSuccess:()=>{q(!1),R(),D.invalidateQueries({queryKey:[`agents`]}),D.invalidateQueries({queryKey:[`agent-packages`]}),D.invalidateQueries({queryKey:[`agent`]})}}),Q=a({mutationFn:({profile:e,content:t})=>u.agents.update(e.id,{content:t,expectedRaw:e.raw,expectedPath:e.path}),onSuccess:e=>{D.setQueryData([`agent`,e.id],e),D.invalidateQueries({queryKey:[`agents`]}),D.invalidateQueries({queryKey:[`agent-packages`]}),W(void 0)}});if(O.error)return(0,U.jsx)(j,{message:O.error.message,onRetry:()=>void O.refetch()});let $=(O.data?.agents??[]).filter(e=>`${e.name} ${e.id} ${e.description}`.toLowerCase().includes(f.toLowerCase()));return(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsx)(M,{title:e?`Agent definitions`:`Agents`,level:e?2:1,meta:O.data?.agents.length??0,help:`Shared specialist instructions, models and tools for connected coding agents. Add definitions to packages for reuse.`,action:(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,U.jsxs)(y,{children:[(0,U.jsx)(h,{asChild:!0,children:(0,U.jsx)(c,{variant:`ghost`,size:`icon`,"data-testid":`agent-actions-menu`,"aria-label":`Agent resources`,children:(0,U.jsx)(T,{size:16})})}),(0,U.jsxs)(b,{"aria-label":`Agent resources`,align:`end`,className:`w-60 space-y-1 p-1`,children:[(0,U.jsx)(c,{asChild:!0,variant:`ghost`,className:`w-full justify-start`,children:(0,U.jsx)(o,{to:E(`/packages`,n,t.search),"data-testid":`agents-packages-link`,children:`Manage packages`})}),(0,U.jsx)(`a`,{className:`block rounded-md px-3 py-2 text-xs text-muted-foreground hover:bg-surface focus-visible:outline focus-visible:outline-2 focus-visible:outline-focus`,href:`https://microsoft.github.io/apm/producer/author-primitives/instructions-and-agents/`,target:`_blank`,rel:`noreferrer`,children:`APM agent format`})]})]}),(0,U.jsx)(c,{"data-testid":`new-agent-button`,onClick:()=>{X.reset(),V(!0)},children:`New agent`})]})}),(O.data?.broken??[]).map(e=>(0,U.jsxs)(`p`,{role:`alert`,className:`text-destructive`,children:[e.path,`: `,e.error]},e.path)),(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,U.jsx)(_,{className:`min-w-[180px] max-w-lg flex-1`,"aria-label":`Find an agent`,placeholder:`Find an agent by name or purpose…`,value:f,onChange:e=>p(e.target.value,{replace:!0})}),f&&(0,U.jsx)(c,{variant:`ghost`,onClick:()=>p(``),children:`Clear`})]}),(0,U.jsxs)(`div`,{className:`space-y-2`,children:[O.isLoading&&(0,U.jsx)(`p`,{role:`status`,"data-testid":`page-loading`,children:`Loading agents…`}),$.map(e=>(0,U.jsxs)(`button`,{type:`button`,"data-testid":`agent-row`,"data-agent-id":e.id,onClick:()=>L(e.id),className:`grid w-full gap-x-6 gap-y-1 border-b border-outline-variant px-2 py-3 text-left hover:bg-surface-low sm:grid-cols-[minmax(0,1fr)_minmax(0,2fr)]`,children:[(0,U.jsx)(`span`,{className:`block wrap-break-word text-sm font-medium`,children:e.name}),(0,U.jsxs)(`span`,{className:`block truncate text-xs text-muted-foreground sm:col-start-1 sm:row-start-2`,title:`${e.id} · ${e.source}`,children:[e.id,` · `,e.source]}),(0,U.jsx)(`p`,{className:`line-clamp-2 wrap-break-word text-sm leading-relaxed text-muted-foreground sm:col-start-2 sm:row-start-1 sm:row-span-2`,children:e.description})]},e.id)),!O.isLoading&&!$.length&&(0,U.jsx)(`p`,{"data-testid":`page-empty`,className:`text-sm text-muted-foreground`,children:f?`No agents match this search. Try another name or clear the filter.`:`Create an agent or import specialists from Packages.`})]}),(0,U.jsx)(x,{open:!!I,onOpenChange:e=>!e&&R(),children:(0,U.jsxs)(v,{defaultWidth:860,resizeKey:`agents`,"data-testid":`agent-detail-sheet`,children:[(0,U.jsx)(C,{children:(0,U.jsx)(S,{children:z.data?.name??`Agent profile`})}),(0,U.jsx)(g,{children:z.error?(0,U.jsx)(j,{message:z.error.message,onRetry:()=>void z.refetch()}):z.data?(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsx)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:z.data.description}),(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 border-b border-outline-variant pb-3`,"data-testid":`agent-actions`,children:[(0,U.jsx)(c,{size:`sm`,"data-testid":`agent-launch`,onClick:()=>z.data&&Y({name:`agent-launch`,packages:[],backend:z.data.fields.tools===void 0?`codex`:`claude`,tool:`apm`,cwd:``,agent:z.data.id,prompt:``}),children:`Launch agent`}),(0,U.jsx)(c,{size:`sm`,"data-testid":`agent-edit`,variant:`ghost`,onClick:async()=>{Q.reset();let e=await z.refetch();e.data&&W(e.data)},children:`Edit agent`}),(0,U.jsx)(c,{size:`sm`,"data-testid":`agent-delete`,variant:`ghost`,className:`ml-auto text-error`,onClick:()=>{Z.reset(),q(!0)},disabled:Z.isPending,children:`Delete`})]}),Z.error&&(0,U.jsx)(`p`,{"data-testid":`agent-delete-error`,role:`alert`,className:`text-destructive`,children:Z.error.message}),(0,U.jsxs)(`dl`,{className:`grid grid-cols-2 gap-4 text-sm`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Model`}),(0,U.jsx)(`dd`,{className:`mt-1 wrap-break-word`,children:z.data.fields.model??`Coding-agent default`})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Tools`}),(0,U.jsx)(`dd`,{className:`mt-1`,children:z.data.fields.tools===void 0?`Coding-agent default`:`Defined by this agent; requires Claude`})]})]}),(0,U.jsx)(`h4`,{className:`text-sm font-medium`,children:`Instructions`}),(0,U.jsx)(w,{path:`agent.agent.md`,mode:l,onModeChange:d,value:z.data.raw,readOnly:!0,layout:`page`,hideFrontmatter:!0,pageTitle:z.data.name,testId:`agent-content`}),(0,U.jsxs)(`details`,{className:`border-t border-outline-variant pt-3 text-sm`,children:[(0,U.jsx)(`summary`,{className:`cursor-pointer text-muted-foreground`,children:`Source and configuration`}),(0,U.jsxs)(`p`,{className:`my-3 text-xs text-muted-foreground break-all`,children:[z.data.id,` · `,z.data.source,` definition`]}),(0,U.jsx)(`pre`,{"data-testid":`agent-fields`,className:`max-h-80 overflow-auto rounded bg-background p-3 text-xs`,children:JSON.stringify(z.data.fields,null,2)}),(0,U.jsxs)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:[`To use this agent in a flow, set `,(0,U.jsxs)(`code`,{children:[`"agent": "`,z.data.id,`"`]}),` on its agent node.`]})]})]}):(0,U.jsx)(`p`,{children:`Loading...`})})]})}),(0,U.jsx)(A,{open:K,title:`Delete ${z.data?.name??`agent`}?`,description:`This permanently deletes the agent definition "${I}". Other agents and package resources are kept. Flows referencing this agent will need another profile.`,isPending:Z.isPending,onCancel:()=>!Z.isPending&&q(!1),onConfirm:()=>{I&&Z.mutate(I,{onError:()=>q(!1)})}}),J&&(0,U.jsx)(k,{initial:J,onClose:()=>Y(void 0)}),(0,U.jsx)(m,{open:B,onOpenChange:e=>!X.isPending&&V(e),children:B&&(0,U.jsx)(G,{pending:X.isPending,error:X.error?.message,onSave:(e,t)=>X.mutate({id:e,content:t})})}),(0,U.jsx)(m,{open:!!H,onOpenChange:e=>!e&&!Q.isPending&&W(void 0),children:H&&(0,U.jsx)(G,{agent:H,pending:Q.isPending,error:Q.error?.message,onSave:(e,t)=>Q.mutate({profile:H,content:t})},H.id)})]})}export{K as default};
|
|
34
|
+
`}${t}`}function V(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 H(e,t){let n=R(e);D(n.document.get(`tools`,!0))||n.document.set(`tools`,{});let r=n.document.get(`tools`,!0);if(D(r))for(let{name:e}of V(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 U=n();function W(e){return V(e).map(e=>({...e,key:crypto.randomUUID()}))}function G({agent:e,pending:t,error:n,onSave:r}){let[i,a]=(0,F.useState)(e?.id??``),[o,s]=(0,F.useState)(e?.raw??I.specialist),[u,m]=(0,F.useState)(`fields`),[g,_]=(0,F.useState)(()=>e?W(e.fields):[]),[v,y]=(0,F.useState)(),b=(0,F.useMemo)(()=>{try{return{value:R(o),error:void 0}}catch(e){return{value:void 0,error:e.message}}},[o]),x=b.value?.fields,S;g.some(e=>!e.name.trim())?S=`Enter a name for every tool.`:new Set(g.map(e=>e.name.trim())).size!==g.length&&(S=`Tool names must be unique.`);let C=e?`Save changes`:`Create agent`;function T(e){_(e),e.every(e=>e.name.trim())&&new Set(e.map(e=>e.name.trim())).size===e.length&&s(H(o,e.map(e=>({...e,name:e.name.trim()}))))}function E(){if(y(void 0),u===`fields`){if(S)return;m(`source`)}else try{let e=R(o);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.`);_(W(e.fields)),m(`fields`)}catch(e){y(e.message)}}return(0,U.jsxs)(f,{className:`max-w-3xl max-h-[90vh] overflow-y-auto`,children:[(0,U.jsx)(d,{children:(0,U.jsx)(p,{children:e?`Edit ${e.name}`:`New shared agent`})}),(0,U.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e.preventDefault(),r(i,o)},children:[(0,U.jsxs)(`fieldset`,{disabled:t,className:`space-y-4`,children:[!e&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(l,{htmlFor:`agent-template`,children:`Starting template`}),(0,U.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=I[e.target.value];s(t),_(W(R(t).fields)),y(void 0)},children:[(0,U.jsx)(`option`,{value:`specialist`,children:`General specialist`}),(0,U.jsx)(`option`,{value:`reviewer`,children:`Reviewer`}),(0,U.jsx)(`option`,{value:`builder`,children:`Builder`})]})]}),(0,U.jsx)(l,{htmlFor:`agent-id`,children:`Agent ID`}),(0,U.jsx)(h,{id:`agent-id`,"data-testid":`agent-id-input`,value:i,disabled:!!e,onChange:e=>a(e.target.value),placeholder:`security-review`}),(0,U.jsx)(c,{type:`button`,variant:`outline`,"data-testid":`agent-editor-mode`,onClick:E,disabled:u===`fields`&&!!S,children:u===`fields`?`Edit YAML + Markdown`:`Edit fields`}),u===`source`?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(l,{htmlFor:`agent-definition`,children:`YAML configuration + Markdown instructions`}),(0,U.jsx)(w,{id:`agent-definition`,testId:`agent-content-input`,path:`agent.agent.md`,readOnly:t,height:400,value:o,onChange:e=>{s(e),y(void 0)}})]}):x&&(0,U.jsxs)(U.Fragment,{children:[[[`name`,`Name`],[`description`,`Description`],[`model`,`Model (optional)`],[`color`,`Color (optional)`]].map(([e,t])=>(0,U.jsxs)(`div`,{className:`space-y-1`,children:[(0,U.jsx)(l,{htmlFor:`agent-${e}`,children:t}),(0,U.jsx)(h,{id:`agent-${e}`,"data-testid":`agent-${e}-input`,value:typeof x[e]==`string`?x[e]:``,onChange:t=>s(z(o,e,t.target.value||(e===`description`?``:void 0)))})]},e)),(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,U.jsx)(`input`,{"data-testid":`agent-custom-tools`,type:`checkbox`,checked:x.tools!==void 0,onChange:e=>{_([]),s(z(o,`tools`,e.target.checked?{}:void 0))}}),` `,`Customize tool access`]}),(0,U.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,U.jsxs)(U.Fragment,{children:[g.map((e,t)=>(0,U.jsxs)(`div`,{"data-testid":`agent-tool-row`,className:`flex items-center gap-2`,children:[(0,U.jsx)(h,{"data-testid":`agent-tool-name`,"aria-label":`Tool ${t+1} name`,value:e.name,list:`agent-tool-suggestions`,onChange:e=>T(g.map((n,r)=>r===t?{...n,name:e.target.value}:n))}),(0,U.jsxs)(`label`,{className:`flex items-center gap-1 text-sm`,children:[(0,U.jsx)(`input`,{"data-testid":`agent-tool-allowed`,type:`checkbox`,checked:e.allowed,onChange:e=>T(g.map((n,r)=>r===t?{...n,allowed:e.target.checked}:n))}),` `,`Allowed`]}),(0,U.jsx)(c,{"data-testid":`agent-tool-remove`,type:`button`,variant:`outline`,onClick:()=>T(g.filter((e,n)=>n!==t)),children:`Remove`})]},e.key)),(0,U.jsx)(`datalist`,{id:`agent-tool-suggestions`,children:[`Read`,`Grep`,`Glob`,`Edit`,`Write`,`Bash`].map(e=>(0,U.jsx)(`option`,{value:e},e))}),(0,U.jsx)(c,{"data-testid":`agent-tool-add`,type:`button`,variant:`outline`,onClick:()=>T([...g,{key:crypto.randomUUID(),name:``,allowed:!0}]),children:`Add tool`})]})]}),(0,U.jsx)(l,{htmlFor:`agent-instructions`,children:`Instructions`}),(0,U.jsx)(w,{id:`agent-instructions`,testId:`agent-instructions-input`,path:`instructions.md`,readOnly:t,height:240,value:b.value?.body??``,onChange:e=>s(B(o,e))}),(0,U.jsx)(`p`,{className:`text-xs text-outline`,children:`Use YAML + Markdown to edit handoffs and additional configuration. Custom fields are preserved.`})]})]}),(n||b.error||v||u===`fields`&&S)&&(0,U.jsx)(`p`,{"data-testid":`agent-editor-error`,role:`alert`,className:`text-destructive`,children:n||b.error||v||S}),(0,U.jsx)(c,{"data-testid":`agent-submit`,type:`submit`,disabled:t||!i.trim()||!o.trim()||!!b.error||u===`fields`&&!!S,children:t?`Saving...`:C})]})]})}function K({embedded:e=!1}){let t=s(),n=new URLSearchParams(t.search).get(`project`)??`all`,[l,d]=P(`editorMode`,`read`,[`read`,`edit`,`split`]),[f,p]=P(`agentQuery`,``),D=r(),O=i({queryKey:[`agents`],queryFn:()=>u.agents.list()}),{selectedId:I,openDetail:L,closeDetail:R}=N(e?`/packages/agents`:`/agents`,`agentId`),z=i({queryKey:[`agent`,I],queryFn:()=>u.agents.get(I),enabled:!!I}),[B,V]=(0,F.useState)(!1),[H,W]=(0,F.useState)(),[K,q]=(0,F.useState)(!1),[J,Y]=(0,F.useState)(),X=a({mutationFn:u.agents.create,onSuccess:()=>{D.invalidateQueries({queryKey:[`agents`]}),V(!1)}}),Z=a({mutationFn:u.agents.delete,onSuccess:()=>{q(!1),R(),D.invalidateQueries({queryKey:[`agents`]}),D.invalidateQueries({queryKey:[`agent-packages`]}),D.invalidateQueries({queryKey:[`agent`]})}}),Q=a({mutationFn:({profile:e,content:t})=>u.agents.update(e.id,{content:t,expectedRaw:e.raw,expectedPath:e.path}),onSuccess:e=>{D.setQueryData([`agent`,e.id],e),D.invalidateQueries({queryKey:[`agents`]}),D.invalidateQueries({queryKey:[`agent-packages`]}),W(void 0)}});if(O.error)return(0,U.jsx)(j,{message:O.error.message,onRetry:()=>void O.refetch()});let $=(O.data?.agents??[]).filter(e=>`${e.name} ${e.id} ${e.description}`.toLowerCase().includes(f.toLowerCase()));return(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsx)(M,{title:e?`Agent definitions`:`Agents`,level:e?2:1,meta:O.data?.agents.length??0,help:`Shared specialist instructions, models and tools for connected coding agents. Add definitions to packages for reuse.`,action:(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,U.jsxs)(v,{children:[(0,U.jsx)(b,{asChild:!0,children:(0,U.jsx)(c,{variant:`ghost`,size:`icon`,"data-testid":`agent-actions-menu`,"aria-label":`Agent resources`,children:(0,U.jsx)(T,{size:16})})}),(0,U.jsxs)(y,{"aria-label":`Agent resources`,align:`end`,className:`w-60 space-y-1 p-1`,children:[(0,U.jsx)(c,{asChild:!0,variant:`ghost`,className:`w-full justify-start`,children:(0,U.jsx)(o,{to:E(`/packages`,n,t.search),"data-testid":`agents-packages-link`,children:`Manage packages`})}),(0,U.jsx)(`a`,{className:`block rounded-md px-3 py-2 text-xs text-muted-foreground hover:bg-surface focus-visible:outline focus-visible:outline-2 focus-visible:outline-focus`,href:`https://microsoft.github.io/apm/producer/author-primitives/instructions-and-agents/`,target:`_blank`,rel:`noreferrer`,children:`APM agent format`})]})]}),(0,U.jsx)(c,{"data-testid":`new-agent-button`,onClick:()=>{X.reset(),V(!0)},children:`New agent`})]})}),(O.data?.broken??[]).map(e=>(0,U.jsxs)(`p`,{role:`alert`,className:`text-destructive`,children:[e.path,`: `,e.error]},e.path)),(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,U.jsx)(h,{className:`min-w-[180px] max-w-lg flex-1`,"aria-label":`Find an agent`,placeholder:`Find an agent by name or purpose…`,value:f,onChange:e=>p(e.target.value,{replace:!0})}),f&&(0,U.jsx)(c,{variant:`ghost`,onClick:()=>p(``),children:`Clear`})]}),(0,U.jsxs)(`div`,{className:`space-y-2`,children:[O.isLoading&&(0,U.jsx)(`p`,{role:`status`,"data-testid":`page-loading`,children:`Loading agents…`}),$.map(e=>(0,U.jsxs)(`button`,{type:`button`,"data-testid":`agent-row`,"data-agent-id":e.id,onClick:()=>L(e.id),className:`grid w-full gap-x-6 gap-y-1 border-b border-outline-variant px-2 py-3 text-left hover:bg-surface-low sm:grid-cols-[minmax(0,1fr)_minmax(0,2fr)]`,children:[(0,U.jsx)(`span`,{className:`block wrap-break-word text-sm font-medium`,children:e.name}),(0,U.jsxs)(`span`,{className:`block truncate text-xs text-muted-foreground sm:col-start-1 sm:row-start-2`,title:`${e.id} · ${e.source}`,children:[e.id,` · `,e.source]}),(0,U.jsx)(`p`,{className:`line-clamp-2 wrap-break-word text-sm leading-relaxed text-muted-foreground sm:col-start-2 sm:row-start-1 sm:row-span-2`,children:e.description})]},e.id)),!O.isLoading&&!$.length&&(0,U.jsx)(`p`,{"data-testid":`page-empty`,className:`text-sm text-muted-foreground`,children:f?`No agents match this search. Try another name or clear the filter.`:`Create an agent or import specialists from Packages.`})]}),(0,U.jsx)(x,{open:!!I,onOpenChange:e=>!e&&R(),children:(0,U.jsxs)(_,{defaultWidth:860,resizeKey:`agents`,"data-testid":`agent-detail-sheet`,children:[(0,U.jsx)(C,{children:(0,U.jsx)(S,{children:z.data?.name??`Agent profile`})}),(0,U.jsx)(g,{children:z.error?(0,U.jsx)(j,{message:z.error.message,onRetry:()=>void z.refetch()}):z.data?(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsx)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:z.data.description}),(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 border-b border-outline-variant pb-3`,"data-testid":`agent-actions`,children:[(0,U.jsx)(c,{size:`sm`,"data-testid":`agent-launch`,onClick:()=>z.data&&Y({name:`agent-launch`,packages:[],backend:z.data.fields.tools===void 0?`codex`:`claude`,tool:`apm`,cwd:``,agent:z.data.id,prompt:``}),children:`Launch agent`}),(0,U.jsx)(c,{size:`sm`,"data-testid":`agent-edit`,variant:`ghost`,onClick:async()=>{Q.reset();let e=await z.refetch();e.data&&W(e.data)},children:`Edit agent`}),(0,U.jsx)(c,{size:`sm`,"data-testid":`agent-delete`,variant:`ghost`,className:`ml-auto text-error`,onClick:()=>{Z.reset(),q(!0)},disabled:Z.isPending,children:`Delete`})]}),Z.error&&(0,U.jsx)(`p`,{"data-testid":`agent-delete-error`,role:`alert`,className:`text-destructive`,children:Z.error.message}),(0,U.jsxs)(`dl`,{className:`grid grid-cols-2 gap-4 text-sm`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Model`}),(0,U.jsx)(`dd`,{className:`mt-1 wrap-break-word`,children:z.data.fields.model??`Coding-agent default`})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Tools`}),(0,U.jsx)(`dd`,{className:`mt-1`,children:z.data.fields.tools===void 0?`Coding-agent default`:`Defined by this agent; requires Claude`})]})]}),(0,U.jsx)(`h4`,{className:`text-sm font-medium`,children:`Instructions`}),(0,U.jsx)(w,{path:`agent.agent.md`,mode:l,onModeChange:d,value:z.data.raw,readOnly:!0,layout:`page`,hideFrontmatter:!0,pageTitle:z.data.name,testId:`agent-content`}),(0,U.jsxs)(`details`,{className:`border-t border-outline-variant pt-3 text-sm`,children:[(0,U.jsx)(`summary`,{className:`cursor-pointer text-muted-foreground`,children:`Source and configuration`}),(0,U.jsxs)(`p`,{className:`my-3 text-xs text-muted-foreground break-all`,children:[z.data.id,` · `,z.data.source,` definition`]}),(0,U.jsx)(`pre`,{"data-testid":`agent-fields`,className:`max-h-80 overflow-auto rounded bg-background p-3 text-xs`,children:JSON.stringify(z.data.fields,null,2)}),(0,U.jsxs)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:[`To use this agent in a flow, set `,(0,U.jsxs)(`code`,{children:[`"agent": "`,z.data.id,`"`]}),` on its agent node.`]})]})]}):(0,U.jsx)(`p`,{children:`Loading...`})})]})}),(0,U.jsx)(A,{open:K,title:`Delete ${z.data?.name??`agent`}?`,description:`This permanently deletes the agent definition "${I}". Other agents and package resources are kept. Flows referencing this agent will need another profile.`,isPending:Z.isPending,onCancel:()=>!Z.isPending&&q(!1),onConfirm:()=>{I&&Z.mutate(I,{onError:()=>q(!1)})}}),J&&(0,U.jsx)(k,{initial:J,onClose:()=>Y(void 0)}),(0,U.jsx)(m,{open:B,onOpenChange:e=>!X.isPending&&V(e),children:B&&(0,U.jsx)(G,{pending:X.isPending,error:X.error?.message,onSave:(e,t)=>X.mutate({id:e,content:t})})}),(0,U.jsx)(m,{open:!!H,onOpenChange:e=>!e&&!Q.isPending&&W(void 0),children:H&&(0,U.jsx)(G,{agent:H,pending:Q.isPending,error:Q.error?.message,onSave:(e,t)=>Q.mutate({profile:H,content:t})},H.id)})]})}export{K as default};
|
|
@@ -1,2 +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{f as a,m as o}from"./chunk-OB3PAWPO-1IihCzFx.js";import{t as s}from"./button-CXYVslgR.js";import{n as c}from"./client-nzMXason.js";import{t as l}from"./textarea-Bt1FBmGL.js";import{F as u,It as d,Rt as f,d as p,en as m,f as h,nn as g,u as _,un as v}from"./index-C60WCVxH.js";import{t as y}from"./ViewHeader-Ce5HQRJu.js";import{c as b}from"./live-sessions-D07BClP7.js";import{i as x,n as S}from"./terminal-links-B3ce99i1.js";var C=e(t(),1),w=n();function T({request:e,actions:t}){let n=e.input.command,[a,o]=(0,C.useState)(e.response?.kind===`command`?e.response.script??n?.script??``:n?.script??``),[f,p]=(0,C.useState)({}),[m,h]=(0,C.useState)(!1),g=r(),_=i({mutationFn:async()=>{let t=f;return p({}),c.humanRequests.run(e.id,e.version,a,t)},onSettled:()=>g.invalidateQueries({queryKey:[`human-requests`]})});if(!n)return null;let v=e.status===`pending`&&!_.isPending;return(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsxs)(`dl`,{className:`flex min-w-0 flex-wrap gap-x-4 gap-y-1 text-xs text-muted-foreground`,children:[(0,w.jsxs)(`div`,{className:`flex min-w-0 gap-1`,children:[(0,w.jsx)(`dt`,{children:`Host:`}),(0,w.jsx)(`dd`,{className:`wrap-anywhere`,children:n.host??`Local`})]}),(0,w.jsxs)(`div`,{className:`flex min-w-0 gap-1`,children:[(0,w.jsx)(`dt`,{children:`Folder:`}),(0,w.jsx)(`dd`,{className:`wrap-anywhere`,children:n.cwd})]})]}),(0,w.jsxs)(`form`,{className:`space-y-2`,onSubmit:e=>{e.preventDefault(),v&&_.mutate()},children:[(0,w.jsxs)(`div`,{children:[(0,w.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,w.jsx)(`span`,{className:`text-xs font-medium`,children:`Command to run`}),v&&(0,w.jsx)(s,{type:`button`,size:`sm`,variant:`ghost`,"data-testid":`attention-edit-command`,"aria-expanded":m,"aria-controls":`command-${e.id}`,onClick:()=>h(!m),children:m?`Done editing`:`Edit command`})]}),m&&v?(0,w.jsxs)(`label`,{htmlFor:`command-${e.id}`,className:`block`,children:[(0,w.jsx)(`span`,{className:`sr-only`,children:`Command to run`}),(0,w.jsx)(l,{id:`command-${e.id}`,"data-testid":`attention-command`,value:e.response?.kind===`command`?e.response.script??a:a,onChange:e=>o(e.target.value),disabled:!v,maxLength:16e3,className:`min-h-20 font-mono text-xs`})]}):(0,w.jsx)(`section`,{"aria-label":`Command to run`,tabIndex:0,"data-testid":`attention-command-preview`,className:`max-h-40 overflow-auto rounded-sm bg-surface px-2 py-1.5 focus-visible:outline-2 focus-visible:outline-focus`,children:(0,w.jsx)(`pre`,{className:`whitespace-pre-wrap wrap-anywhere font-mono text-xs`,children:e.response?.kind===`command`?e.response.script??a:a})})]}),(0,w.jsx)(`div`,{className:`grid gap-x-3 gap-y-2 sm:grid-cols-2`,children:v&&n.arguments.map(t=>(0,w.jsxs)(`label`,{htmlFor:`argument-${e.id}-${t.name}`,className:`block min-w-0 space-y-1 text-xs`,children:[(0,w.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,w.jsxs)(`span`,{children:[t.label,t.required?``:` (optional)`]}),(0,w.jsx)(`code`,{"data-testid":`attention-argument-name-${t.name}`,className:`break-all font-mono text-xs text-muted-foreground`,children:`ORC_INPUT_${t.name}`})]}),(0,w.jsx)(d,{id:`argument-${e.id}-${t.name}`,type:`password`,autoComplete:`off`,"data-testid":`attention-argument-${t.name}`,value:f[t.name]??``,required:t.required,maxLength:16e3,"aria-describedby":t.description?`argument-help-${e.id}-${t.name}`:void 0,onChange:e=>p(n=>({...n,[t.name]:e.target.value}))}),t.description&&(0,w.jsx)(`span`,{id:`argument-help-${e.id}-${t.name}`,className:`block text-muted-foreground`,children:t.description})]},t.name))}),(v||_.isPending||e.status===`running`)&&(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,w.jsx)(s,{"data-testid":`attention-run`,type:`submit`,size:`sm`,disabled:!v||!a.trim()||n.arguments.some(e=>e.required&&!f[e.name]),children:_.isPending||e.status===`running`?`Running…`:`Run command`}),v&&t,(0,w.jsx)(u,{label:`Secure input handling`,testId:`attention-input-help`,children:`All entered values are used only for this run and redacted from its output. The agent receives the result without the raw inputs.`})]}),_.error&&(0,w.jsx)(`p`,{role:`alert`,children:`Could not confirm completion. Refresh the request before trying again.`})]}),e.response?.kind===`command`&&(0,w.jsxs)(`div`,{"data-testid":`attention-command-result`,className:`space-y-2`,children:[(0,w.jsxs)(`p`,{children:[`Exit code: `,e.response.exit_code]}),(0,w.jsxs)(`pre`,{className:`whitespace-pre-wrap break-all text-xs`,children:[e.response.stdout,e.response.stderr]}),e.response.truncated&&(0,w.jsx)(`p`,{children:`Output was truncated.`})]})]})}var E={pending:`Needs reply`,running:`Running`,unavailable:`Agent unavailable`,answered:`Waiting for delivery`,delivered:`Delivered`,cancelled:`Cancelled`,expired:`Expired`};function D(e){return e.input.kind===`command`?e.input.command?.host??`Local`:e.input.action?e.input.action.host:e.input.origin.execution_host===void 0?null:e.input.origin.execution_host??`Local`}function O({session:e}){let t=a(),[n]=o(),{terminals:r}=f(),i=S(r,e.id);return(0,w.jsxs)(`article`,{"data-testid":`attention-session-${e.id}`,className:`grid min-w-0 gap-2 border-b border-border py-3 @xl/attention:grid-cols-[minmax(0,1fr)_auto] @xl/attention:items-center`,children:[(0,w.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,w.jsx)(`h2`,{className:`text-sm font-medium wrap-break-word`,children:e.name??`Coding session`}),(0,w.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 text-xs text-muted-foreground`,children:[(0,w.jsx)(`span`,{className:`text-warning`,children:`Question`}),(0,w.jsx)(`span`,{children:e.agent}),(0,w.jsx)(`span`,{children:e.host??`Local`}),(0,w.jsx)(`span`,{children:`Reply in the original session`})]})]}),(0,w.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[i&&(0,w.jsx)(s,{size:`sm`,variant:`ghost`,onClick:()=>t(b(x(i.id),n.get(`project`))),children:`Open terminal`}),(0,w.jsx)(s,{size:`sm`,variant:`ghost`,onClick:()=>{let r=new URLSearchParams(n);r.set(`session`,e.id),t({pathname:`/sessions`,search:r.toString()})},children:`View session`})]})]})}function k({request:e,expanded:t,onToggle:n}){let[d,f]=(0,C.useState)(``),[p,h]=(0,C.useState)([]),[_,y]=(0,C.useState)(e.input.choices.length===0),b=r(),x=a(),[S]=o(),O=i({mutationFn:t=>c.humanRequests.respond(e.id,e.version,t),onSettled:()=>b.invalidateQueries({queryKey:[`human-requests`]})}),k=i({mutationFn:()=>c.humanRequests.cancel(e.id,e.version),onSettled:()=>b.invalidateQueries({queryKey:[`human-requests`]})}),A=e.status===`pending`,j=E[e.status],M=D(e),N=O.isPending||k.isPending,P=(0,w.jsxs)(w.Fragment,{children:[e.input.origin.chat_thread_id&&(0,w.jsxs)(s,{"data-testid":`attention-open-chat`,size:`sm`,variant:`ghost`,type:`button`,onClick:()=>{let t=new URLSearchParams(S);t.set(`chat`,`open`),t.set(`chatThread`,e.input.origin.chat_thread_id??``),x({search:t.toString()})},children:[(0,w.jsx)(g,{size:14}),` Open chat`]}),(A||e.status===`unavailable`)&&(0,w.jsx)(s,{"data-testid":`attention-cancel`,size:`sm`,variant:`ghost`,type:`button`,disabled:N,onClick:()=>k.mutate(),children:k.isPending?A?`Cancelling…`:`Dismissing…`:A?`Cancel request`:`Dismiss`})]}),F=e.input.action?.input,I=F?.item&&typeof F.item==`object`?F.item:void 0,L=typeof F?.threadId==`string`,R=L?{...Object.fromEntries(Object.entries(F??{}).filter(([e])=>![`threadId`,`turnId`,`itemId`,`startedAtMs`,`item`,`availableDecisions`,`proposedExecpolicyAmendment`,`commandActions`,`kind`].includes(e))),...I?.changes?{changes:I.changes}:{}}:F;return(0,w.jsxs)(`article`,{"data-testid":`attention-request-${e.id}`,className:`min-w-0 border-b border-border`,children:[(0,w.jsxs)(`div`,{className:`flex min-h-11 items-center gap-3 py-1`,children:[(0,w.jsx)(`h2`,{className:`min-w-0 flex-1`,children:(0,w.jsxs)(`button`,{type:`button`,"data-testid":`attention-review`,"aria-expanded":t,"aria-controls":`request-details-${e.id}`,onClick:n,className:`flex min-h-11 w-full min-w-0 items-center gap-2 rounded-sm py-1 text-left focus-visible:outline-2 focus-visible:outline-focus sm:min-h-9 [@media(pointer:coarse)]:min-h-11`,children:[(0,w.jsx)(v,{"aria-hidden":`true`,size:14,className:`shrink-0 text-muted-foreground ${t?`rotate-90`:``}`}),(0,w.jsxs)(`span`,{className:`min-w-0`,children:[(0,w.jsx)(`span`,{className:`block text-sm font-medium wrap-anywhere ${t?`whitespace-pre-wrap`:`line-clamp-1`}`,children:e.input.title??e.input.prompt}),(0,w.jsxs)(`span`,{className:`block truncate text-xs font-normal text-muted-foreground`,children:[e.input.origin.session_title??e.input.origin.backend,M&&` · ${M}`]})]})]})}),(0,w.jsx)(`span`,{className:`shrink-0 text-xs ${A?`text-warning`:`text-muted-foreground`}`,children:j})]}),(0,w.jsxs)(`div`,{id:`request-details-${e.id}`,hidden:!t,className:t?`max-w-3xl space-y-3 pb-3 pl-6`:`hidden`,children:[(0,w.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[e.input.title&&(0,w.jsx)(`p`,{className:`text-sm whitespace-pre-wrap wrap-anywhere`,children:e.input.prompt}),(0,w.jsxs)(`details`,{className:`text-xs text-muted-foreground`,children:[(0,w.jsx)(`summary`,{"data-testid":`attention-details-toggle`,className:`min-h-8 cursor-pointer py-1 [@media(pointer:coarse)]:min-h-11`,children:`Request details`}),(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted-foreground`,children:[(0,w.jsxs)(`span`,{className:A?`text-warning`:void 0,children:[e.input.kind===`command`?`Command`:e.input.kind===`question`?`Question`:`Approval`,` `,`· `,e.input.origin.backend]}),(e.input.rule_binding||e.input.rule_bindings?.length)&&(0,w.jsx)(`span`,{children:`ORC rule`})]}),(0,w.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground`,children:[(0,w.jsxs)(`span`,{className:`min-w-0 max-w-full truncate`,title:e.input.origin.session_title??e.input.origin.session_id,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`}`]}),(0,w.jsxs)(`span`,{className:`flex flex-wrap gap-x-2`,"data-testid":`attention-date`,children:[(0,w.jsxs)(`span`,{children:[`Created`,` `,(0,w.jsx)(`time`,{dateTime:new Date(e.created_at).toISOString(),title:new Date(e.created_at).toLocaleString(),children:new Date(e.created_at).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`})})]}),e.responded_at!==null&&(0,w.jsxs)(`span`,{children:[`Answered`,` `,(0,w.jsx)(`time`,{dateTime:new Date(e.responded_at).toISOString(),title:new Date(e.responded_at).toLocaleString(),children:new Date(e.responded_at).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`})})]})]})]})]}),e.input.kind===`command`&&(0,w.jsx)(T,{request:e,actions:P}),e.input.action&&(0,w.jsxs)(`div`,{className:`min-w-0 space-y-2 text-sm`,children:[(0,w.jsxs)(`dl`,{className:`flex min-w-0 flex-wrap gap-x-4 gap-y-1 text-xs`,children:[(0,w.jsxs)(`div`,{className:`flex min-w-0 gap-1`,children:[(0,w.jsx)(`dt`,{className:`text-muted-foreground`,children:`Host:`}),(0,w.jsx)(`dd`,{className:`wrap-anywhere`,children:e.input.action.host})]}),(0,w.jsxs)(`div`,{className:`flex min-w-0 gap-1`,children:[(0,w.jsx)(`dt`,{className:`text-muted-foreground`,children:`Folder:`}),(0,w.jsx)(`dd`,{className:`wrap-anywhere`,children:e.input.action.cwd})]})]}),(0,w.jsx)(`section`,{"aria-label":`Requested action`,tabIndex:0,className:`max-h-64 overflow-auto whitespace-pre-wrap wrap-anywhere rounded-md border border-border p-2 font-mono text-xs focus-visible:outline-2 focus-visible:outline-focus`,children:(0,w.jsxs)(`pre`,{"data-testid":`attention-action`,className:`whitespace-pre-wrap wrap-anywhere`,children:[e.input.action.tool,`
|
|
2
|
-
`,JSON.stringify(R&&Object.keys(R).length?R:F,null,2)]})}),L&&(0,w.jsxs)(`details`,{className:`text-xs text-outline`,children:[(0,w.jsx)(`summary`,{className:`min-h-11 cursor-pointer py-1 sm:min-h-8 [@media(pointer:coarse)]:min-h-11`,children:`Full request details`}),(0,w.jsx)(`pre`,{className:`whitespace-pre-wrap break-all mt-2`,children:JSON.stringify(F,null,2)})]})]})]}),(0,w.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[A&&e.input.kind===`question`&&(0,w.jsxs)(`form`,{className:`space-y-2`,onSubmit:e=>{e.preventDefault(),O.mutate({kind:`question`,answer:d,...p.length?{selected_choices:p}:{}})},children:[(0,w.jsx)(`div`,{className:`grid gap-1 @xl/attention:grid-cols-2 @4xl/attention:grid-cols-1`,children:e.input.choices.map(t=>(0,w.jsxs)(`label`,{className:`flex min-h-11 min-w-0 cursor-pointer items-start gap-2 rounded-md px-2 py-1.5 text-sm sm:min-h-8 [@media(pointer:coarse)]:min-h-11 hover:bg-surface ${(e.input.multi_select?p.includes(t):d===t)?`bg-surface-highest`:``}`,"data-testid":`attention-choice-${t}`,children:[(0,w.jsx)(`input`,{type:e.input.multi_select?`checkbox`:`radio`,name:`choice-${e.id}`,checked:e.input.multi_select?p.includes(t):d===t,disabled:N,className:`mt-1 size-3.5 shrink-0 accent-primary`,onChange:()=>{if(e.input.multi_select){let e=p.includes(t)?p.filter(e=>e!==t):[...p,t];
|
|
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{f as a,m as o}from"./chunk-OB3PAWPO-1IihCzFx.js";import{t as s}from"./button-CXYVslgR.js";import{n as c}from"./client-nzMXason.js";import{t as l}from"./textarea-Bt1FBmGL.js";import{F as u,Ft as d,Lt as f,d as p,f as m,in as h,nn as g,pn as _,u as v}from"./index-B8heHbQj.js";import{t as y}from"./ViewHeader-BUk4Owsd.js";import{c as b}from"./live-sessions-D07BClP7.js";import{i as x,n as S}from"./terminal-links-B3ce99i1.js";var C=e(t(),1),w=n();function T({request:e,actions:t}){let n=e.input.command,[a,o]=(0,C.useState)(e.response?.kind===`command`?e.response.script??n?.script??``:n?.script??``),[f,p]=(0,C.useState)({}),[m,h]=(0,C.useState)(!1),g=r(),_=i({mutationFn:async()=>{let t=f;return p({}),c.humanRequests.run(e.id,e.version,a,t)},onSettled:()=>g.invalidateQueries({queryKey:[`human-requests`]})});if(!n)return null;let v=e.status===`pending`&&!_.isPending;return(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsxs)(`dl`,{className:`flex min-w-0 flex-wrap gap-x-4 gap-y-1 text-xs text-muted-foreground`,children:[(0,w.jsxs)(`div`,{className:`flex min-w-0 gap-1`,children:[(0,w.jsx)(`dt`,{children:`Host:`}),(0,w.jsx)(`dd`,{className:`wrap-anywhere`,children:n.host??`Local`})]}),(0,w.jsxs)(`div`,{className:`flex min-w-0 gap-1`,children:[(0,w.jsx)(`dt`,{children:`Folder:`}),(0,w.jsx)(`dd`,{className:`wrap-anywhere`,children:n.cwd})]})]}),(0,w.jsxs)(`form`,{className:`space-y-2`,onSubmit:e=>{e.preventDefault(),v&&_.mutate()},children:[(0,w.jsxs)(`div`,{children:[(0,w.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,w.jsx)(`span`,{className:`text-xs font-medium`,children:`Command to run`}),v&&(0,w.jsx)(s,{type:`button`,size:`sm`,variant:`ghost`,"data-testid":`attention-edit-command`,"aria-expanded":m,"aria-controls":`command-${e.id}`,onClick:()=>h(!m),children:m?`Done editing`:`Edit command`})]}),m&&v?(0,w.jsxs)(`label`,{htmlFor:`command-${e.id}`,className:`block`,children:[(0,w.jsx)(`span`,{className:`sr-only`,children:`Command to run`}),(0,w.jsx)(l,{id:`command-${e.id}`,"data-testid":`attention-command`,value:e.response?.kind===`command`?e.response.script??a:a,onChange:e=>o(e.target.value),disabled:!v,maxLength:16e3,className:`min-h-20 font-mono text-xs`})]}):(0,w.jsx)(`section`,{"aria-label":`Command to run`,tabIndex:0,"data-testid":`attention-command-preview`,className:`max-h-40 overflow-auto rounded-sm bg-surface px-2 py-1.5 focus-visible:outline-2 focus-visible:outline-focus`,children:(0,w.jsx)(`pre`,{className:`whitespace-pre-wrap wrap-anywhere font-mono text-xs`,children:e.response?.kind===`command`?e.response.script??a:a})})]}),(0,w.jsx)(`div`,{className:`grid gap-x-3 gap-y-2 sm:grid-cols-2`,children:v&&n.arguments.map(t=>(0,w.jsxs)(`label`,{htmlFor:`argument-${e.id}-${t.name}`,className:`block min-w-0 space-y-1 text-xs`,children:[(0,w.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,w.jsxs)(`span`,{children:[t.label,t.required?``:` (optional)`]}),(0,w.jsx)(`code`,{"data-testid":`attention-argument-name-${t.name}`,className:`break-all font-mono text-xs text-muted-foreground`,children:`ORC_INPUT_${t.name}`})]}),(0,w.jsx)(d,{id:`argument-${e.id}-${t.name}`,type:`password`,autoComplete:`off`,"data-testid":`attention-argument-${t.name}`,value:f[t.name]??``,required:t.required,maxLength:16e3,"aria-describedby":t.description?`argument-help-${e.id}-${t.name}`:void 0,onChange:e=>p(n=>({...n,[t.name]:e.target.value}))}),t.description&&(0,w.jsx)(`span`,{id:`argument-help-${e.id}-${t.name}`,className:`block text-muted-foreground`,children:t.description})]},t.name))}),(v||_.isPending||e.status===`running`)&&(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,w.jsx)(s,{"data-testid":`attention-run`,type:`submit`,size:`sm`,disabled:!v||!a.trim()||n.arguments.some(e=>e.required&&!f[e.name]),children:_.isPending||e.status===`running`?`Running…`:`Run command`}),v&&t,(0,w.jsx)(u,{label:`Secure input handling`,testId:`attention-input-help`,children:`All entered values are used only for this run and redacted from its output. The agent receives the result without the raw inputs.`})]}),_.error&&(0,w.jsx)(`p`,{role:`alert`,children:`Could not confirm completion. Refresh the request before trying again.`})]}),e.response?.kind===`command`&&(0,w.jsxs)(`div`,{"data-testid":`attention-command-result`,className:`space-y-2`,children:[(0,w.jsxs)(`p`,{children:[`Exit code: `,e.response.exit_code]}),(0,w.jsxs)(`pre`,{className:`whitespace-pre-wrap break-all text-xs`,children:[e.response.stdout,e.response.stderr]}),e.response.truncated&&(0,w.jsx)(`p`,{children:`Output was truncated.`})]})]})}var E={pending:`Needs reply`,running:`Running`,unavailable:`Agent unavailable`,answered:`Waiting for delivery`,delivered:`Delivered`,cancelled:`Cancelled`,expired:`Expired`};function D(e){return e.input.kind===`command`?e.input.command?.host??`Local`:e.input.action?e.input.action.host:e.input.origin.execution_host===void 0?null:e.input.origin.execution_host??`Local`}function O({session:e}){let t=a(),[n]=o(),{terminals:r}=f(),i=S(r,e.id);return(0,w.jsxs)(`article`,{"data-testid":`attention-session-${e.id}`,className:`grid min-w-0 gap-2 border-b border-border py-3 @xl/attention:grid-cols-[minmax(0,1fr)_auto] @xl/attention:items-center`,children:[(0,w.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,w.jsx)(`h2`,{className:`text-sm font-medium wrap-break-word`,children:e.name??`Coding session`}),(0,w.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 text-xs text-muted-foreground`,children:[(0,w.jsx)(`span`,{className:`text-warning`,children:`Question`}),(0,w.jsx)(`span`,{children:e.agent}),(0,w.jsx)(`span`,{children:e.host??`Local`}),(0,w.jsx)(`span`,{children:`Reply in the original session`})]})]}),(0,w.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[i&&(0,w.jsx)(s,{size:`sm`,variant:`ghost`,onClick:()=>t(b(x(i.id),n.get(`project`))),children:`Open terminal`}),(0,w.jsx)(s,{size:`sm`,variant:`ghost`,onClick:()=>{let r=new URLSearchParams(n);r.set(`session`,e.id),t({pathname:`/sessions`,search:r.toString()})},children:`View session`})]})]})}function k({request:e,expanded:t,onToggle:n}){let[d,f]=(0,C.useState)(``),[p,m]=(0,C.useState)([]),[v,y]=(0,C.useState)(e.input.choices.length===0),b=r(),x=a(),[S]=o(),O=i({mutationFn:t=>c.humanRequests.respond(e.id,e.version,t),onSettled:()=>b.invalidateQueries({queryKey:[`human-requests`]})}),k=i({mutationFn:()=>c.humanRequests.cancel(e.id,e.version),onSettled:()=>b.invalidateQueries({queryKey:[`human-requests`]})}),A=e.status===`pending`,j=E[e.status],M=D(e),N=O.isPending||k.isPending,P=(0,w.jsxs)(w.Fragment,{children:[e.input.origin.chat_thread_id&&(0,w.jsxs)(s,{"data-testid":`attention-open-chat`,size:`sm`,variant:`ghost`,type:`button`,onClick:()=>{let t=new URLSearchParams(S);t.set(`chat`,`open`),t.set(`chatThread`,e.input.origin.chat_thread_id??``),x({search:t.toString()})},children:[(0,w.jsx)(h,{size:14}),` Open chat`]}),(A||e.status===`unavailable`)&&(0,w.jsx)(s,{"data-testid":`attention-cancel`,size:`sm`,variant:`ghost`,type:`button`,disabled:N,onClick:()=>k.mutate(),children:k.isPending?A?`Cancelling…`:`Dismissing…`:A?`Cancel request`:`Dismiss`})]}),F=e.input.action?.input,I=F?.item&&typeof F.item==`object`?F.item:void 0,L=typeof F?.threadId==`string`,R=L?{...Object.fromEntries(Object.entries(F??{}).filter(([e])=>![`threadId`,`turnId`,`itemId`,`startedAtMs`,`item`,`availableDecisions`,`proposedExecpolicyAmendment`,`commandActions`,`kind`].includes(e))),...I?.changes?{changes:I.changes}:{}}:F;return(0,w.jsxs)(`article`,{"data-testid":`attention-request-${e.id}`,className:`min-w-0 border-b border-border`,children:[(0,w.jsxs)(`div`,{className:`flex min-h-11 items-center gap-3 py-1`,children:[(0,w.jsx)(`h2`,{className:`min-w-0 flex-1`,children:(0,w.jsxs)(`button`,{type:`button`,"data-testid":`attention-review`,"aria-expanded":t,"aria-controls":`request-details-${e.id}`,onClick:n,className:`flex min-h-11 w-full min-w-0 items-center gap-2 rounded-sm py-1 text-left focus-visible:outline-2 focus-visible:outline-focus sm:min-h-9 [@media(pointer:coarse)]:min-h-11`,children:[(0,w.jsx)(_,{"aria-hidden":`true`,size:14,className:`shrink-0 text-muted-foreground ${t?`rotate-90`:``}`}),(0,w.jsxs)(`span`,{className:`min-w-0`,children:[(0,w.jsx)(`span`,{className:`block text-sm font-medium wrap-anywhere ${t?`whitespace-pre-wrap`:`line-clamp-1`}`,children:e.input.title??e.input.prompt}),(0,w.jsxs)(`span`,{className:`block truncate text-xs font-normal text-muted-foreground`,children:[e.input.origin.session_title??e.input.origin.backend,M&&` · ${M}`]})]})]})}),(0,w.jsx)(`span`,{className:`shrink-0 text-xs ${A?`text-warning`:`text-muted-foreground`}`,children:j})]}),(0,w.jsxs)(`div`,{id:`request-details-${e.id}`,hidden:!t,className:t?`max-w-3xl space-y-3 pb-3 pl-6`:`hidden`,children:[(0,w.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[e.input.title&&(0,w.jsx)(`p`,{className:`text-sm whitespace-pre-wrap wrap-anywhere`,children:e.input.prompt}),(0,w.jsxs)(`details`,{className:`text-xs text-muted-foreground`,children:[(0,w.jsx)(`summary`,{"data-testid":`attention-details-toggle`,className:`min-h-8 cursor-pointer py-1 [@media(pointer:coarse)]:min-h-11`,children:`Request details`}),(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted-foreground`,children:[(0,w.jsxs)(`span`,{className:A?`text-warning`:void 0,children:[e.input.kind===`command`?`Command`:e.input.kind===`question`?`Question`:`Approval`,` `,`· `,e.input.origin.backend]}),(e.input.rule_binding||e.input.rule_bindings?.length)&&(0,w.jsx)(`span`,{children:`ORC rule`})]}),(0,w.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground`,children:[(0,w.jsxs)(`span`,{className:`min-w-0 max-w-full truncate`,title:e.input.origin.session_title??e.input.origin.session_id,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`}`]}),(0,w.jsxs)(`span`,{className:`flex flex-wrap gap-x-2`,"data-testid":`attention-date`,children:[(0,w.jsxs)(`span`,{children:[`Created`,` `,(0,w.jsx)(`time`,{dateTime:new Date(e.created_at).toISOString(),title:new Date(e.created_at).toLocaleString(),children:new Date(e.created_at).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`})})]}),e.responded_at!==null&&(0,w.jsxs)(`span`,{children:[`Answered`,` `,(0,w.jsx)(`time`,{dateTime:new Date(e.responded_at).toISOString(),title:new Date(e.responded_at).toLocaleString(),children:new Date(e.responded_at).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`})})]})]})]})]}),e.input.kind===`command`&&(0,w.jsx)(T,{request:e,actions:P}),e.input.action&&(0,w.jsxs)(`div`,{className:`min-w-0 space-y-2 text-sm`,children:[(0,w.jsxs)(`dl`,{className:`flex min-w-0 flex-wrap gap-x-4 gap-y-1 text-xs`,children:[(0,w.jsxs)(`div`,{className:`flex min-w-0 gap-1`,children:[(0,w.jsx)(`dt`,{className:`text-muted-foreground`,children:`Host:`}),(0,w.jsx)(`dd`,{className:`wrap-anywhere`,children:e.input.action.host})]}),(0,w.jsxs)(`div`,{className:`flex min-w-0 gap-1`,children:[(0,w.jsx)(`dt`,{className:`text-muted-foreground`,children:`Folder:`}),(0,w.jsx)(`dd`,{className:`wrap-anywhere`,children:e.input.action.cwd})]})]}),(0,w.jsx)(`section`,{"aria-label":`Requested action`,tabIndex:0,className:`max-h-64 overflow-auto whitespace-pre-wrap wrap-anywhere rounded-md border border-border p-2 font-mono text-xs focus-visible:outline-2 focus-visible:outline-focus`,children:(0,w.jsxs)(`pre`,{"data-testid":`attention-action`,className:`whitespace-pre-wrap wrap-anywhere`,children:[e.input.action.tool,`
|
|
2
|
+
`,JSON.stringify(R&&Object.keys(R).length?R:F,null,2)]})}),L&&(0,w.jsxs)(`details`,{className:`text-xs text-outline`,children:[(0,w.jsx)(`summary`,{className:`min-h-11 cursor-pointer py-1 sm:min-h-8 [@media(pointer:coarse)]:min-h-11`,children:`Full request details`}),(0,w.jsx)(`pre`,{className:`whitespace-pre-wrap break-all mt-2`,children:JSON.stringify(F,null,2)})]})]})]}),(0,w.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[A&&e.input.kind===`question`&&(0,w.jsxs)(`form`,{className:`space-y-2`,onSubmit:e=>{e.preventDefault(),O.mutate({kind:`question`,answer:d,...p.length?{selected_choices:p}:{}})},children:[(0,w.jsx)(`div`,{className:`grid gap-1 @xl/attention:grid-cols-2 @4xl/attention:grid-cols-1`,children:e.input.choices.map(t=>(0,w.jsxs)(`label`,{className:`flex min-h-11 min-w-0 cursor-pointer items-start gap-2 rounded-md px-2 py-1.5 text-sm sm:min-h-8 [@media(pointer:coarse)]:min-h-11 hover:bg-surface ${(e.input.multi_select?p.includes(t):d===t)?`bg-surface-highest`:``}`,"data-testid":`attention-choice-${t}`,children:[(0,w.jsx)(`input`,{type:e.input.multi_select?`checkbox`:`radio`,name:`choice-${e.id}`,checked:e.input.multi_select?p.includes(t):d===t,disabled:N,className:`mt-1 size-3.5 shrink-0 accent-primary`,onChange:()=>{if(e.input.multi_select){let e=p.includes(t)?p.filter(e=>e!==t):[...p,t];m(e),f(e.join(`, `))}else f(t)}}),(0,w.jsxs)(`span`,{className:`min-w-0 wrap-anywhere`,children:[(0,w.jsx)(`span`,{children:t}),Object.keys(e.input.choice_descriptions).includes(t)&&e.input.choice_descriptions[t]&&(0,w.jsx)(`span`,{className:`block text-xs font-normal text-muted-foreground`,children:e.input.choice_descriptions[t]})]})]},t))}),e.input.choices.length>0&&(0,w.jsxs)(s,{type:`button`,size:`sm`,variant:`ghost`,"data-testid":`attention-edit-answer`,"aria-expanded":v,"aria-controls":`answer-editor-${e.id}`,disabled:N,onClick:()=>y(!v),children:[(0,w.jsx)(g,{size:14}),` `,v?`Hide editor`:`Write an answer`]}),(0,w.jsxs)(`label`,{id:`answer-editor-${e.id}`,htmlFor:`answer-${e.id}`,hidden:!v,className:v?`block text-sm space-y-1`:`hidden`,children:[(0,w.jsx)(`span`,{children:`Your answer`}),(0,w.jsx)(l,{id:`answer-${e.id}`,"data-testid":`attention-answer`,value:d,onChange:e=>{f(e.target.value),m([])},maxLength:16e3,disabled:N,rows:2,className:`min-h-20 max-h-48 resize-y`})]}),(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,w.jsx)(s,{size:`sm`,"data-testid":`attention-send`,type:`submit`,disabled:!d.trim()||N,children:O.isPending?`Sending…`:`Send answer`}),P]})]}),A&&e.input.kind===`approval`&&(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,w.jsx)(s,{size:`sm`,"data-testid":`attention-approve`,disabled:N,onClick:()=>O.mutate({kind:`approval`,approved:!0}),children:`Approve`}),(0,w.jsx)(s,{size:`sm`,"data-testid":`attention-deny`,variant:`outline`,disabled:N,onClick:()=>O.mutate({kind:`approval`,approved:!1}),children:`Deny`}),(0,w.jsx)(u,{label:`Approval permissions`,testId:`attention-approval-help`,children:`Your approval lets this agent continue with its existing permissions.`}),P]}),e.response&&e.response.kind!==`command`&&(0,w.jsx)(`p`,{"data-testid":`attention-response`,className:`text-sm whitespace-pre-wrap wrap-anywhere`,children:e.response.kind===`question`?e.response.answer:e.response.approved?`Approved`:`Denied`}),!A&&(0,w.jsx)(`div`,{className:`flex flex-wrap items-center gap-1`,children:P})]})]}),e.delivery_error&&(0,w.jsx)(`p`,{role:`status`,className:`pb-2 pl-6 text-sm text-error`,children:e.delivery_error}),k.error&&(0,w.jsx)(`p`,{role:`alert`,children:k.error.message}),O.error&&(0,w.jsx)(`p`,{role:`alert`,"data-testid":`attention-error`,className:`text-sm text-destructive`,children:O.error.message})]})}function A(){let[e,t]=(0,C.useState)(null),n=m(),r=v(),i=p(),c=a(),[l]=o();return(0,w.jsxs)(`div`,{"data-testid":`attention-view`,className:`@container/attention min-w-0`,children:[(0,w.jsx)(y,{title:`Attention needed`,meta:n.data?n.data.length+r.data.length+i.data.length:void 0,help:`Questions and approvals from your agents. 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.`}),n.isLoading&&(0,w.jsx)(`p`,{role:`status`,children:`Loading requests…`}),n.error&&(0,w.jsx)(`p`,{role:`alert`,children:n.error.message}),r.error&&(0,w.jsxs)(`p`,{role:`alert`,children:[`Could not check waiting sessions: `,r.error.message]}),i.error&&(0,w.jsxs)(`p`,{role:`alert`,children:[`Could not check waiting chats: `,i.error.message]}),n.data?.length===0&&!n.error&&!r.isLoading&&!r.error&&!i.isLoading&&!i.error&&r.data.length===0&&i.data.length===0&&(0,w.jsx)(`p`,{"data-testid":`attention-empty`,className:`grid min-h-[min(40dvh,20rem)] place-items-center text-sm text-muted-foreground`,children:`Nothing needs your attention.`}),n.data?.length===100&&(0,w.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,w.jsxs)(`div`,{children:[i.data.map(e=>(0,w.jsxs)(`article`,{"data-testid":`attention-chat-${e.thread_id}`,className:`grid min-w-0 gap-2 border-b border-border py-3 @xl/attention:grid-cols-[minmax(0,1fr)_auto] @xl/attention:items-center`,children:[(0,w.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,w.jsx)(`h2`,{className:`text-sm font-medium wrap-break-word`,children:e.title}),(0,w.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 text-xs text-muted-foreground`,children:[(0,w.jsx)(`span`,{className:`text-warning`,children:e.kind===`question`?`Question`:`Approval`}),(0,w.jsx)(`span`,{children:e.agent}),(0,w.jsx)(`span`,{children:e.host??`Local`}),(0,w.jsx)(`span`,{children:`Chat`})]})]}),(0,w.jsx)(s,{size:`sm`,variant:`ghost`,className:`justify-self-start @xl/attention:justify-self-end`,onClick:()=>{let t=new URLSearchParams(l);t.set(`chat`,`open`),t.set(`chatThread`,e.thread_id),c({search:t.toString()})},children:`Open chat`})]},`${e.thread_id}:${e.request_key}`)),r.data.map(e=>(0,w.jsx)(O,{session:e},e.id)),n.data?.map(n=>(0,w.jsx)(k,{request:n,expanded:e===n.id,onToggle:()=>t(e=>e===n.id?null:n.id)},n.id))]})]})}export{A 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-D0FZFdju.js";import{t as i}from"./chevron-down-hj6o3_QU.js";import{t as a}from"./Markdown-
|
|
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-D0FZFdju.js";import{t as i}from"./chevron-down-hj6o3_QU.js";import{t as a}from"./Markdown-DLhioXL1.js";import{Et as o,G as s,K as c,U as l,W as u,X as d,Y as f,pn as p,st as m}from"./index-B8heHbQj.js";import{t as h}from"./ErrorState-BrKz7Mii.js";import{t as g}from"./ViewHeader-BUk4Owsd.js";import{t as _}from"./useDetailRoute-DOhAbdV7.js";import{t as v}from"./view-params-DD7i9s5g.js";import{t as y}from"./EmptyState-YM4VSLR9.js";import{t as b}from"./Pager-BzhZAMGm.js";import{i as x,r as S}from"./useSessions-BNSlPToV.js";import{a as C,i as w,n as T,o as E,r as D,t as O}from"./table-Cri9EUoE.js";import{t as k}from"./useProjectScope-DtEj9j-P.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:o,error:p,refetch:g}=x(e??``);return(0,j.jsx)(u,{open:t,onOpenChange:e=>!e&&n(),children:(0,j.jsxs)(c,{side:`right`,defaultWidth:540,resizeKey:`sessions`,children:[(0,j.jsx)(f,{children:(0,j.jsx)(d,{children:o?`Loading...`:i?`${i.agent??`Session`} ${i.agent_version?`v${i.agent_version}`:``}`:`Session Detail`})}),(0,j.jsxs)(s,{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()}):o?(0,j.jsx)(`div`,{className:`space-y-4`,children:[...[,,,,]].map((e,t)=>(0,j.jsx)(l,{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=o(`xl`),[n,r]=v(`order`,`desc`,[`asc`,`desc`]),[i,a]=(0,A.useState)({order:n,page:0}),s=i.order===n?i.page:0,c=e=>a({order:n,page:e}),{selectedId:u,openDetail:d,closeDetail:f}=_(`/audit`,`sessionId`),{data:p,isLoading:m,error:g,refetch:x}=S({...e===`all`?{}:{project_id:e},limit:R,offset:s*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.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center justify-between gap-2`,children:[(0,j.jsxs)(`span`,{className:`text-xs text-outline`,children:[M,` records`]}),(0,j.jsxs)(`select`,{"aria-label":`Sort audit by date`,"data-testid":`audit-date-sort`,value:n,onChange:e=>{c(0),r(e.target.value)},className:`form-control form-control-single w-auto max-w-full`,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)(l,{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:()=>d(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(),d(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-3 space-y-2`,children:[(0,j.jsx)(`button`,{type:`button`,className:`min-h-8 text-sm text-left font-medium text-primary wrap-break-word`,onClick:()=>d(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:s,pageSize:R,total:M,onPage:c})]}),(0,j.jsx)(F,{sessionId:u,open:!!u,onClose:f})]})}function V({projectId:e}){let t=k(e);return(0,j.jsxs)(`div`,{children:[(0,j.jsx)(g,{title:`Audit`,help:`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{f as t}from"./chunk-OB3PAWPO-1IihCzFx.js";import{t as n}from"./button-CXYVslgR.js";import{Et as r,M as i,S as a,U as o,_t as s}from"./index-
|
|
1
|
+
import{t as e}from"./jsx-runtime-CVMpzJz9.js";import{f as t}from"./chunk-OB3PAWPO-1IihCzFx.js";import{t as n}from"./button-CXYVslgR.js";import{Et as r,M as i,S as a,U as o,_t as s}from"./index-B8heHbQj.js";import{t as c}from"./ErrorState-BrKz7Mii.js";import{t as l}from"./ViewHeader-BUk4Owsd.js";import{a as u,t as d}from"./live-sessions-D07BClP7.js";import{n as f}from"./useSessions-BNSlPToV.js";import{a as p,i as m,n as h,o as g,r as _,t as v}from"./table-Cri9EUoE.js";import{t as y}from"./useProjectScope-DtEj9j-P.js";import{t as b}from"./PriorityBadge-Ccw4iVk7.js";import{t as x}from"./ResumeActions-DX6Sq1Hj.js";import{t as S}from"./StatusBadge-ia651_Df.js";import{o as C}from"./useJobs-B2da-s4n.js";import{r as w}from"./useMemories-UaTju2A_.js";var T=e();function E(e,t){return e.isLoading?`…`:e.error?`—`:t}function D({projectId:e}){let D=t(),O=y(e),k=r(`sm`),A=e=>{let t=new URL(e,window.location.origin);t.searchParams.set(`project`,O),D({pathname:t.pathname,search:t.search,hash:t.hash})},j=O===`all`?void 0:{project_id:O},M=i(j),{data:N,isLoading:P}=M,F=C(j),{data:I}=F,L=w({project_id:j?.project_id,limit:1},{enabled:O!==`unassigned`}),R=O===`unassigned`?0:L.data?.total??0,{data:z}=s(),B=f(!0,j?.project_id),V=(B.data??[]).filter(e=>O===`all`||(O===`unassigned`?e.project_id===null:e.project_id===O)),H=O===`unassigned`?(I??[]).filter(e=>e.project_id===null):I??[],U=O===`unassigned`?(N??[]).filter(e=>e.project_id===null):N??[],W=U.reduce((e,t)=>(e[t.status]=(e[t.status]??0)+1,e),{}),G=[...U].sort((e,t)=>new Date(t.updated_at).getTime()-new Date(e.updated_at).getTime()).slice(0,8),K=H.filter(e=>e.enabled),q=O===`all`?`All Projects`:O===`unassigned`?`Unassigned`:z?.find(e=>e.id===O)?.name??``,J=[{label:`Doing`,value:E(M,W.doing??0),sub:`in progress`,path:`/tasks?view=table&status=doing`},{label:`Review`,value:E(M,W.review??0),sub:`awaiting review`,path:`/tasks?view=table&status=review`},{label:`Blocked`,value:E(M,W.blocked??0),sub:`needs attention`,path:`/tasks?view=table&status=blocked`},{label:`Todo`,value:E(M,(W.todo??0)+(W.queued??0)),sub:`pending`,path:`/tasks?view=board`},{label:`Done`,value:E(M,W.done??0),sub:`completed`,path:`/tasks?view=table&status=done`}],Y=[{label:`Active jobs`,value:E(F,K.length),sub:`of ${H.length} total`,path:`/jobs`},{label:`Memories`,value:E(L,R),sub:`in this scope`,path:a},{label:`Projects`,value:(z??[]).filter(e=>e.status===`active`).length,sub:`active across workspace`,path:`/projects`}];return(0,T.jsxs)(`div`,{"data-activity-preview":!0,"data-testid":`activity-preview`,className:`activity-preview`,children:[(0,T.jsx)(l,{title:`Activity`,meta:q||`All projects`,action:(0,T.jsx)(n,{onClick:()=>A(`/tasks`),children:`View tasks`})}),[M,F,L,B].some(e=>e.isLoading)&&(0,T.jsx)(`p`,{role:`status`,className:`activity-muted mb-4`,children:`Loading activity…`}),[{name:`Tasks`,query:M},{name:`Jobs`,query:F},{name:`Memories`,query:L},{name:`Sessions`,query:B}].filter(({query:e})=>e.error).map(({name:e,query:t})=>(0,T.jsx)(c,{message:`${e}: ${t.error?.message??`Could not load activity`}`,onRetry:()=>t.refetch()},e)),(0,T.jsx)(`section`,{className:`activity-metrics`,"aria-label":`Task summary`,children:J.map(e=>(0,T.jsxs)(`button`,{type:`button`,"data-testid":`stat-card`,"data-stat-label":e.label,className:`activity-metric`,onClick:()=>A(e.path),children:[(0,T.jsx)(`span`,{className:`activity-metric-label`,children:e.label}),(0,T.jsx)(`span`,{"data-testid":`stat-card-value`,className:`activity-metric-value`,children:e.value}),(0,T.jsx)(`span`,{className:`activity-metric-sub`,children:e.sub})]},e.label))}),(0,T.jsx)(`section`,{className:`activity-resources`,"aria-label":`Workspace summary`,children:Y.map(e=>(0,T.jsxs)(`button`,{type:`button`,"data-testid":`stat-card`,"data-stat-label":e.label,onClick:()=>A(e.path),children:[(0,T.jsx)(`span`,{children:e.label}),(0,T.jsx)(`span`,{"data-testid":`stat-card-value`,className:`activity-resource-value`,children:e.value}),(0,T.jsx)(`span`,{className:`activity-resource-sub`,children:e.sub})]},e.label))}),(0,T.jsxs)(`section`,{className:`activity-section`,children:[(0,T.jsxs)(`div`,{className:`activity-section-heading`,children:[(0,T.jsx)(`h2`,{children:`Recent tasks`}),(0,T.jsx)(`button`,{type:`button`,className:`activity-text-action`,onClick:()=>A(`/tasks`),children:`View all`})]}),P?(0,T.jsx)(`div`,{className:`space-y-2`,children:[0,1,2,3].map(e=>(0,T.jsx)(o,{className:`h-10 w-full`},e))}):G.length===0?(0,T.jsx)(`p`,{className:`activity-empty`,children:`No tasks`}):k?(0,T.jsxs)(v,{className:`activity-task-table`,children:[(0,T.jsx)(p,{children:(0,T.jsxs)(g,{children:[(0,T.jsx)(m,{children:`Task`}),(0,T.jsx)(m,{className:`w-36`,children:`Status`}),(0,T.jsx)(m,{className:`w-28`,children:`Priority`}),(0,T.jsx)(m,{className:`w-28`,children:`Updated`})]})}),(0,T.jsx)(h,{children:G.map(e=>(0,T.jsxs)(g,{onClick:()=>A(`/tasks/${e.id}`),children:[(0,T.jsx)(_,{children:(0,T.jsx)(`button`,{type:`button`,className:`activity-task-title`,onClick:t=>{t.stopPropagation(),A(`/tasks/${e.id}`)},children:e.title})}),(0,T.jsx)(_,{children:(0,T.jsx)(`span`,{className:`activity-status`,"data-status":e.status,children:(0,T.jsx)(S,{status:e.status})})}),(0,T.jsx)(_,{children:(0,T.jsx)(`span`,{className:`activity-priority`,children:(0,T.jsx)(b,{priority:e.priority})})}),(0,T.jsx)(_,{className:`activity-muted`,children:new Date(e.updated_at).toLocaleDateString()})]},e.id))})]}):(0,T.jsx)(`div`,{className:`activity-task-list`,children:G.map(e=>(0,T.jsxs)(`article`,{className:`activity-task-mobile`,children:[(0,T.jsx)(`button`,{type:`button`,className:`activity-task-title`,onClick:()=>A(`/tasks/${e.id}`),children:e.title}),(0,T.jsxs)(`div`,{className:`activity-task-meta`,children:[(0,T.jsx)(`span`,{className:`activity-status`,"data-status":e.status,children:(0,T.jsx)(S,{status:e.status})}),(0,T.jsx)(`span`,{className:`activity-priority`,children:(0,T.jsx)(b,{priority:e.priority})}),(0,T.jsx)(`span`,{children:new Date(e.updated_at).toLocaleDateString()})]})]},e.id))})]}),(0,T.jsxs)(`div`,{className:`activity-secondary`,children:[K.length>0&&(0,T.jsxs)(`section`,{className:`activity-section`,children:[(0,T.jsxs)(`div`,{className:`activity-section-heading`,children:[(0,T.jsx)(`h2`,{children:`Active jobs`}),(0,T.jsx)(`button`,{type:`button`,className:`activity-text-action`,onClick:()=>A(`/jobs`),children:`View all`})]}),(0,T.jsx)(`div`,{className:`activity-row-list`,children:K.slice(0,5).map(e=>(0,T.jsxs)(`button`,{type:`button`,className:`activity-row`,onClick:()=>A(`/jobs/${e.id}`),children:[(0,T.jsxs)(`span`,{className:`activity-row-heading`,children:[(0,T.jsx)(`span`,{children:e.name}),(0,T.jsx)(`span`,{className:`activity-muted`,children:e.trigger_type})]}),e.last_run_at&&(0,T.jsxs)(`span`,{className:`activity-row-description`,children:[`Last run `,new Date(e.last_run_at).toLocaleString()]})]},e.id))})]}),V.length>0&&(0,T.jsxs)(`section`,{className:`activity-section`,children:[(0,T.jsxs)(`div`,{className:`activity-section-heading`,children:[(0,T.jsx)(`h2`,{children:`Agent sessions`}),(0,T.jsx)(`button`,{type:`button`,className:`activity-text-action`,onClick:()=>A(`/sessions`),children:`View all`})]}),(0,T.jsx)(`div`,{className:`activity-row-list`,children:V.slice(0,5).map(e=>(0,T.jsxs)(`div`,{className:`activity-row`,children:[(0,T.jsxs)(`button`,{type:`button`,className:`w-full text-left`,"data-testid":`activity-session-link`,"data-session-id":e.id,onClick:()=>A(`/sessions?session=${encodeURIComponent(e.id)}`),children:[(0,T.jsxs)(`span`,{className:`activity-row-heading`,children:[(0,T.jsx)(`span`,{children:e.name??e.agent}),(0,T.jsx)(`span`,{className:`activity-muted`,children:u(e.last_activity_at)})]}),(0,T.jsxs)(`span`,{className:`activity-row-description inline-flex items-center gap-2`,children:[(0,T.jsx)(`span`,{className:`size-1.5 rounded-full ${d[e.status].dot}`}),e.agent,` · `,d[e.status].label,e.task?` · ${e.task.title}`:``]})]}),(0,T.jsx)(x,{session:e})]},e.id))})]})]}),O===`all`&&(z??[]).length>0&&(0,T.jsxs)(`section`,{className:`activity-section`,children:[(0,T.jsxs)(`div`,{className:`activity-section-heading`,children:[(0,T.jsx)(`h2`,{children:`Projects`}),(0,T.jsx)(`button`,{type:`button`,className:`activity-text-action`,onClick:()=>A(`/projects`),children:`View all`})]}),(0,T.jsx)(`div`,{className:`activity-projects`,children:(z??[]).filter(e=>e.status===`active`).slice(0,6).map(e=>(0,T.jsxs)(`button`,{type:`button`,className:`activity-row`,onClick:()=>A(`/projects/${e.id}`),children:[(0,T.jsx)(`span`,{className:`activity-row-heading`,children:e.name}),e.description&&(0,T.jsx)(`span`,{className:`activity-row-description`,children:e.description})]},e.id))})]})]})}export{D 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{f as r,m as i}from"./chunk-OB3PAWPO-1IihCzFx.js";import{t as a}from"./button-CXYVslgR.js";import{t as o}from"./MarkdownEditor-
|
|
1
|
+
import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{f as r,m as i}from"./chunk-OB3PAWPO-1IihCzFx.js";import{t as a}from"./button-CXYVslgR.js";import{t as o}from"./MarkdownEditor-CVlZh0ne.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,compact:x}){let[S]=i(),C=r(),w=S.get(`editorMode`),T=w===`edit`||w===`split`?w:`read`,E=(0,s.useRef)(l.get(e)??{original:t,content:t}),[D,O]=(0,s.useState)(E.current.content),[k,A]=(0,s.useState)(E.current.original),[j,M]=(0,s.useState)(!1),[N,P]=(0,s.useState)(null),F=(0,s.useRef)(!1),I=(0,s.useRef)(E.current.content),L=D!==k;(0,s.useEffect)(()=>{l.has(e)||(O(t),I.current=t,A(t))},[t,e]);function R(t){I.current=t,O(t),t===k?l.delete(e):l.set(e,{original:k,content:t})}async function z(){if(!f||!L||F.current)return;F.current=!0,u.add(e),M(!0),P(null);let t=I.current;try{let n=await f(t,k),r=typeof n==`string`?n:t;A(r),I.current===t?(l.delete(e),I.current=r,O(r)):l.set(e,{original:r,content:I.current})}catch(e){P(e instanceof Error?e.message:`Could not save document`)}finally{F.current=!1,u.delete(e),M(!1)}}function B(e){let t=new URLSearchParams(window.location.search);t.set(`editorMode`,e),t.toString()!==new URLSearchParams(window.location.search).toString()&&C({search:t.toString(),hash:window.location.hash})}function V(){d(e)&&(O(t),A(t),I.current=t,P(null))}let H=f?j?`Saving…`:L?`Unsaved changes`:`Saved`:`Read-only`,U=(0,c.jsxs)(c.Fragment,{children:[N&&(0,c.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[N,` Your draft has been kept.`]}),L&&t!==k&&(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)(o,{path:n,value:D,onChange:R,onSave:()=>void z(),readOnly:!f||j,testId:p,wikiLinks:m,initialMode:`read`,mode:T,onModeChange:B,expanded:g,onExpandedChange:_,layout:`page`,pageTitle:y,hideFrontmatter:b,compact:x,notice:N||L&&t!==k?U:void 0,actions:(T!==`read`||L||j)&&(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(`span`,{"data-testid":`document-save-status`,role:`status`,className:`text-xs text-outline`,children:H}),f&&(L||j)&&(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(a,{type:`button`,size:`sm`,variant:`ghost`,"data-testid":`document-discard`,disabled:j,onClick:V,children:`Discard`}),(0,c.jsx)(a,{type:`button`,size:`sm`,"data-testid":`document-save`,disabled:j,onClick:()=>void z(),children:`Save`})]})]})})}):(0,c.jsx)(`div`,{className:`min-w-0 space-y-3`,"data-testid":`document-workspace`,children:(0,c.jsx)(o,{path:n,value:D,onChange:R,onSave:()=>void z(),readOnly:!f||j,testId:p,wikiLinks:m,initialMode:`read`,mode:T,onModeChange:B,expanded:g,onExpandedChange:_,layout:v,compact:x,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:H}),f&&(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(a,{type:`button`,variant:`ghost`,"data-testid":`document-discard`,disabled:!L||j,onClick:V,children:`Discard changes`}),(0,c.jsx)(a,{type:`button`,"data-testid":`document-save`,disabled:!L||j,onClick:()=>void z(),children:`Save changes`})]})]}),U]})})})}export{d as n,f as t};
|
|
@@ -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{n as r}from"./QueryClientProvider-DlPztvhd.js";import{m as i}from"./chunk-OB3PAWPO-1IihCzFx.js";import{n as a}from"./client-nzMXason.js";import{t as o}from"./MarkdownEditor-
|
|
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{m as i}from"./chunk-OB3PAWPO-1IihCzFx.js";import{n as a}from"./client-nzMXason.js";import{t as o}from"./MarkdownEditor-CVlZh0ne.js";import{t as s}from"./save-CMSSgXiS.js";import{t as c}from"./file-kind-BYU1kv95.js";import{ct as l}from"./index-B8heHbQj.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]=i(),_=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 a.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?`)&&a.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)(s,{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:[!c(t)&&z,(0,d.jsx)(`div`,{"data-testid":`file-preview`,className:`min-h-0 flex-1 overflow-hidden`,children:c(t)?(0,d.jsx)(o,{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};
|
|
@@ -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{n as r}from"./QueryClientProvider-DlPztvhd.js";import{n as i,t as a}from"./useMutation-HX90wI4L.js";import{t as o}from"./chunk-OB3PAWPO-1IihCzFx.js";import{t as s}from"./button-CXYVslgR.js";import{t as c}from"./label-wk_QKooL.js";import{a as l,n as u}from"./client-nzMXason.js";import{It as d}from"./index-C60WCVxH.js";import{t as f}from"./ErrorState-BrKz7Mii.js";import{l as p}from"./useJobs-B2da-s4n.js";var m=e(t(),1);function h(e){return i({queryKey:[`webhooks`,e],queryFn:()=>u.webhooks.list(e),select:e=>e.webhooks})}function g(e){return i({queryKey:[`webhook-deliveries`,e],queryFn:()=>u.webhooks.deliveries(e),select:e=>e.deliveries,enabled:!!e,refetchInterval:3e3})}function _(){let e=r();return a({mutationFn:e=>u.webhooks.create(e),onSuccess:()=>e.invalidateQueries({queryKey:[`webhooks`]})})}function v(){let e=r();return a({mutationFn:({id:e,...t})=>u.webhooks.update(e,t),onSuccess:()=>e.invalidateQueries({queryKey:[`webhooks`]})})}function y(){let e=r();return a({mutationFn:e=>u.webhooks.delete(e),onSuccess:()=>e.invalidateQueries({queryKey:[`webhooks`]})})}function b(){return a({mutationFn:e=>u.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,o]=(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)(s,{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)(c,{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)(c,{htmlFor:`${f}-provider`,children:`Provider`}),(0,w.jsxs)(`select`,{id:`${f}-provider`,"data-testid":`webhook-provider`,className:`w-full min-h-8 rounded-md border border-control-border bg-background px-3 text-sm`,value:a,onChange:e=>o(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)(s,{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:o}=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:()=>o()}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(c,{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-8 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)(s,{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)(c,{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)(c,{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)(s,{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)(s,{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)(o,{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,o]=(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)(s,{type:`button`,size:`sm`,variant:`outline`,"aria-label":`Copy ${e}`,onClick:async()=>{try{await navigator.clipboard.writeText(t),i(!0),o(!1)}catch{o(!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,showInstructions:n=!0,instructionsId:r}){let i=S(e.token,l(),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:i}),C(i)&&(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.`}),n&&(0,w.jsxs)(`div`,{id:r,"data-testid":`webhook-setup-instructions`,className:`space-y-3`,children:[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 a test event, then open Recent deliveries for this webhook.`})]}):(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,c]=(0,m.useState)(!1),[l,u]=(0,m.useState)(!1),[d,f]=(0,m.useState)(),p=(0,m.useId)();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)(s,{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)(o,{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)):null]}),(0,w.jsx)(A,{hook:e,secret:d,showInstructions:a,instructionsId:p}),(0,w.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,w.jsx)(s,{type:`button`,variant:`outline`,size:`sm`,"data-testid":`webhook-deliveries-toggle`,onClick:()=>i(!r),children:r?`Hide deliveries`:`Recent deliveries`}),(0,w.jsx)(s,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`webhook-setup-toggle`,"aria-expanded":a,"aria-controls":a?p:void 0,disabled:n.isPending,onClick:()=>{a&&f(void 0),c(!a),u(!1)},children:a?d?`I've copied the setup details`:`Hide setup`:`Setup instructions`})]}),a&&(0,w.jsx)(s,{type:`button`,variant:`ghost`,size:`sm`,disabled:n.isPending,onClick:()=>u(!l),children:`New signing secret`}),a&&l&&(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)(s,{type:`button`,variant:`outline`,size:`sm`,disabled:n.isPending,onClick:()=>n.mutate(e.id,{onSuccess:e=>{f(e.secret),c(!0),u(!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)(o,{className:`underline`,to:`/jobs/${e.job_id}?project=all`,children:[`Job run: `,e.status]}),e.task_id&&(0,w.jsx)(o,{className:`underline`,to:`/tasks/${e.task_id}?project=all`,children:`Created task`}),e.session_id&&(0,w.jsx)(o,{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};
|
|
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"./chunk-OB3PAWPO-1IihCzFx.js";import{t as s}from"./button-CXYVslgR.js";import{t as c}from"./label-wk_QKooL.js";import{a as l,n as u}from"./client-nzMXason.js";import{Ft as d}from"./index-B8heHbQj.js";import{t as f}from"./ErrorState-BrKz7Mii.js";import{l as p}from"./useJobs-B2da-s4n.js";var m=e(t(),1);function h(e){return i({queryKey:[`webhooks`,e],queryFn:()=>u.webhooks.list(e),select:e=>e.webhooks})}function g(e){return i({queryKey:[`webhook-deliveries`,e],queryFn:()=>u.webhooks.deliveries(e),select:e=>e.deliveries,enabled:!!e,refetchInterval:3e3})}function _(){let e=r();return a({mutationFn:e=>u.webhooks.create(e),onSuccess:()=>e.invalidateQueries({queryKey:[`webhooks`]})})}function v(){let e=r();return a({mutationFn:({id:e,...t})=>u.webhooks.update(e,t),onSuccess:()=>e.invalidateQueries({queryKey:[`webhooks`]})})}function y(){let e=r();return a({mutationFn:e=>u.webhooks.delete(e),onSuccess:()=>e.invalidateQueries({queryKey:[`webhooks`]})})}function b(){return a({mutationFn:e=>u.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,o]=(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)(s,{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)(c,{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)(c,{htmlFor:`${f}-provider`,children:`Provider`}),(0,w.jsxs)(`select`,{id:`${f}-provider`,"data-testid":`webhook-provider`,className:`w-full min-h-8 rounded-md border border-control-border bg-background px-3 text-sm`,value:a,onChange:e=>o(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)(s,{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:o}=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:()=>o()}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(c,{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-8 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)(s,{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)(c,{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)(c,{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)(s,{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)(s,{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)(o,{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,o]=(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)(s,{type:`button`,size:`sm`,variant:`outline`,"aria-label":`Copy ${e}`,onClick:async()=>{try{await navigator.clipboard.writeText(t),i(!0),o(!1)}catch{o(!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,showInstructions:n=!0,instructionsId:r}){let i=S(e.token,l(),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:i}),C(i)&&(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.`}),n&&(0,w.jsxs)(`div`,{id:r,"data-testid":`webhook-setup-instructions`,className:`space-y-3`,children:[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 a test event, then open Recent deliveries for this webhook.`})]}):(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,c]=(0,m.useState)(!1),[l,u]=(0,m.useState)(!1),[d,f]=(0,m.useState)(),p=(0,m.useId)();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)(s,{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)(o,{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)):null]}),(0,w.jsx)(A,{hook:e,secret:d,showInstructions:a,instructionsId:p}),(0,w.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,w.jsx)(s,{type:`button`,variant:`outline`,size:`sm`,"data-testid":`webhook-deliveries-toggle`,onClick:()=>i(!r),children:r?`Hide deliveries`:`Recent deliveries`}),(0,w.jsx)(s,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`webhook-setup-toggle`,"aria-expanded":a,"aria-controls":a?p:void 0,disabled:n.isPending,onClick:()=>{a&&f(void 0),c(!a),u(!1)},children:a?d?`I've copied the setup details`:`Hide setup`:`Setup instructions`})]}),a&&(0,w.jsx)(s,{type:`button`,variant:`ghost`,size:`sm`,disabled:n.isPending,onClick:()=>u(!l),children:`New signing secret`}),a&&l&&(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)(s,{type:`button`,variant:`outline`,size:`sm`,disabled:n.isPending,onClick:()=>n.mutate(e.id,{onSuccess:e=>{f(e.secret),c(!0),u(!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)(o,{className:`underline`,to:`/jobs/${e.job_id}?project=all`,children:[`Job run: `,e.status]}),e.task_id&&(0,w.jsx)(o,{className:`underline`,to:`/tasks/${e.task_id}?project=all`,children:`Created task`}),e.session_id&&(0,w.jsx)(o,{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};
|
|
@@ -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"./chunk-OB3PAWPO-1IihCzFx.js";import{t as i}from"./button-CXYVslgR.js";import{t as a}from"./label-wk_QKooL.js";import{t as o}from"./scroll-area-D0FZFdju.js";import{a as s,i as c,n as l,r as u,t as d}from"./select-Cj-m0J9A.js";import{d as f}from"./client-nzMXason.js";import{t as p}from"./chevron-down-hj6o3_QU.js";import{t as m}from"./ResponsiveFilters-DAeezpA-.js";import{t as h}from"./textarea-Bt1FBmGL.js";import{a as g,i as _,o as v}from"./dialog-Juth7dP_.js";import{$t as y,Ct as b,Et as x,G as S,It as C,J as w,K as T,P as E,St as D,U as O,W as k,X as A,Y as j,Zt as M,_t as N,bt as P,en as F,ft as I,qt as L,st as R,un as z,wt as B,xt as V}from"./index-C60WCVxH.js";import{t as H}from"./ConfirmDialog-Cyd60q9b.js";import{t as U}from"./ErrorState-BrKz7Mii.js";import{t as W}from"./ViewHeader-Ce5HQRJu.js";import{t as ee}from"./useDetailRoute-DOhAbdV7.js";import{t as G}from"./view-params-DD7i9s5g.js";import{t as K}from"./EmptyState-YM4VSLR9.js";import{a as te,i as q,n as ne,o as re,r as J,t as ie}from"./table-Cri9EUoE.js";import{t as ae}from"./useProjectScope-DtEj9j-P.js";import{t as oe}from"./StatusBadge-ia651_Df.js";import{a as se,c as ce,i as le,l as Y,n as ue,o as de,r as fe,s as pe,t as me}from"./useJobs-B2da-s4n.js";import{n as he,t as ge}from"./useListSelection-ZreW_5e4.js";import{i as _e,t as ve}from"./JobWebhooks-csgdKaIu.js";var ye={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`}]]};ye.node;var X=f(ye),be={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`}]]};be.node;var xe=f(be),Z=e(t(),1),Q=n();function Se(e){return e.type===`command`?!!e.command.trim():e.type===`agent`?!!(e.prompt.trim()&&e.backend.trim()):!!e.title.trim()}function Ce({value:e,onChange:t}){let n=(0,Z.useId)(),{data:r}=I();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)(a,{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-8 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)(a,{htmlFor:`${n}-command`,children:`Command`}),(0,Q.jsx)(h,{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)(a,{htmlFor:`${n}-backend`,children:`Agent backend`}),(0,Q.jsx)(C,{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)(a,{htmlFor:`${n}-model`,children:`Model (optional)`}),(0,Q.jsx)(C,{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)(a,{htmlFor:`${n}-prompt`,children:`Instructions`}),(0,Q.jsx)(h,{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)(a,{htmlFor:`${n}-title`,children:`Task title`}),(0,Q.jsx)(C,{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.jsx)(E,{label:`Task instructions`,id:`${n}-body`,"data-testid":`job-task-body`,value:e.body,onChange:n=>t({...e,body:n}),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)(a,{htmlFor:`${n}-flow`,children:`Flow (blank uses the configured default)`}),(0,Q.jsx)(C,{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 we({jobId:e,open:t,onClose:n,onEdit:r,projectScope:a=`all`}){let{data:o,isLoading:s,error:c,refetch:l}=fe(e),u=o&&(a===`all`||(a===`unassigned`?o.project_id===null:o.project_id===a)),d=u?o:void 0;(0,Z.useEffect)(()=>{t&&o&&!u&&n()},[t,o,u,n]);let{data:f,isLoading:p,error:m,refetch:h}=se(d?.id??null),g=ce(),_=Y(),[v,y]=(0,Z.useState)(null);return(0,Q.jsx)(k,{open:t,onOpenChange:e=>!e&&n(),children:(0,Q.jsxs)(T,{"data-testid":`job-detail-sheet`,children:[(0,Q.jsxs)(j,{children:[(0,Q.jsx)(A,{children:d?.name??`Job details`}),d?.description&&(0,Q.jsx)(`p`,{className:`font-body text-xs text-outline mt-1`,children:d.description})]}),(0,Q.jsx)(S,{children:c?(0,Q.jsx)(U,{message:c.message,onRetry:()=>l()}):s?(0,Q.jsx)(`div`,{className:`space-y-3`,children:[...[,,,,,,]].map((e,t)=>(0,Q.jsx)(O,{className:`h-8 w-full bg-surface-highest`},t))}):d?(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(R,{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:d.action?.type===`agent`?`Run agent (${d.action.backend}): ${d.action.prompt}`:d.action?.type===`task`?`Create task: ${d.action.title}`:d.command})}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-4`,children:[(0,Q.jsx)(R,{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:d.trigger_type})}),(0,Q.jsx)(R,{label:`Enabled`,children:(0,Q.jsx)(`span`,{className:`font-label text-xs font-bold ${d.enabled?`text-secondary`:`text-outline`}`,children:d.enabled?`● ON`:`○ OFF`})})]}),d.cron_expr&&(0,Q.jsx)(R,{label:`Cron Expression`,children:(0,Q.jsx)(`code`,{className:`font-mono text-xs`,children:d.cron_expr})}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-3 gap-4`,children:[(0,Q.jsxs)(R,{label:`Timeout`,children:[d.timeout_secs,`s`]}),(0,Q.jsx)(R,{label:`Max Retries`,children:d.max_retries}),(0,Q.jsx)(R,{label:`Overlap`,children:d.overlap})]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-4`,children:[(0,Q.jsx)(R,{label:`Notify On`,children:d.notify_on}),(0,Q.jsx)(R,{label:`Run Count`,children:d.run_count})]}),d.next_run_at&&(0,Q.jsx)(R,{label:`Next Run`,children:new Date(d.next_run_at).toLocaleString()})]}),!d.command.startsWith(`__`)&&(0,Q.jsx)(ve,{job:d},d.id),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`font-label text-xs font-medium text-outline mb-3`,children:`Recent runs`}),m?(0,Q.jsx)(U,{message:m.message,onRetry:()=>h()}):p?(0,Q.jsx)(`div`,{className:`space-y-2`,children:[...[,,,]].map((e,t)=>(0,Q.jsx)(O,{className:`h-8 w-full bg-surface-highest`},t))}):f?.length?(0,Q.jsx)(`div`,{className:`space-y-1`,children:f.map(t=>(0,Q.jsx)(Te,{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)(w,{className:`flex-wrap`,children:[(_.error||g.error)&&(0,Q.jsx)(`p`,{role:`alert`,className:`w-full text-sm text-error`,children:(_.error??g.error)?.message}),d&&r&&(0,Q.jsxs)(i,{"data-testid":`job-detail-edit`,size:`sm`,variant:`outline`,onClick:()=>r(d),children:[(0,Q.jsx)(F,{size:16}),`Edit job`]}),d&&(0,Q.jsxs)(i,{size:`sm`,variant:`ghost`,disabled:_.isPending,onClick:()=>_.mutate({id:d.id,enabled:!d.enabled}),className:`font-label text-xs font-medium`,children:[(0,Q.jsx)(xe,{size:12,className:`mr-1.5`}),d.enabled?`Disable`:`Enable`]}),d&&(0,Q.jsxs)(i,{variant:`ghost`,size:`sm`,disabled:g.isPending,onClick:()=>g.mutate(d.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`}),g.isPending?`Triggering...`:`Trigger run`]})]})]})})}function Te({run:e,jobId:t,expanded:n,onToggle:i}){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:i,"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)(p,{size:12,className:`text-outline shrink-0`}):(0,Q.jsx)(z,{size:12,className:`text-outline shrink-0`}),(0,Q.jsx)(oe,{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)(r,{className:`underline`,"data-testid":`job-run-task-link`,to:`/tasks/${e.task_id}?project=all`,children:`Created task`}),e.session_id&&(0,Q.jsx)(r,{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)(Ee,{jobId:t,runId:e.id})]})}function Ee({jobId:e,runId:t}){let{data:n,isLoading:r,error:i,refetch:a}=le(e,t);return i?(0,Q.jsx)(U,{message:i.message,onRetry:()=>a()}):r?(0,Q.jsx)(`div`,{className:`px-3 pb-3`,children:(0,Q.jsx)(O,{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)(o,{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 $=[`one-shot`,`cron`,`watch`,`webhook`,`manual`,`bridge-msg`],De=[`skip`,`queue`,`kill`],Oe=[`never`,`failure`,`always`];function ke({projectId:e}){let t=x(`xl`),[n,r]=G(`jobQuery`,``),[a,o]=G(`jobStatus`,`all`,[`all`,`enabled`,`disabled`]),[s,c]=G(`jobTrigger`,`all`,[`all`,...$]),l=ae(e),u=l===`all`||l===`unassigned`?void 0:l,{data:d,isLoading:f,error:p,refetch:h}=de({project_id:l===`all`?void 0:l,limit:100}),g=(l===`unassigned`?d?.filter(e=>e.project_id===null):d)?.filter(e=>(!n||`${e.name} ${e.description??``} ${e.command??``}`.toLowerCase().includes(n.toLowerCase()))&&(a===`all`||e.enabled===(a===`enabled`))&&(s===`all`||e.trigger_type===s)),_=JSON.stringify([l,n,a,s]),v=ce(),b=ue(),S=Y(),w=pe(),T=w.data?.scope===_?w.data:void 0,E=ge((g??[]).map(e=>e.id),_);async function D(e){let t=await w.mutateAsync({ids:E.selectedIds,enabled:e,scope:_});E.select(t.failed.map(e=>e.id))}let{selectedId:k,openDetail:A,closeDetail:j}=ee(`/jobs`,`jobId`),[N,P]=(0,Z.useState)(!1),[I,R]=(0,Z.useState)(null),[z,B]=(0,Z.useState)(null);if(p)return(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(W,{title:`Jobs`}),(0,Q.jsx)(U,{message:p.message,onRetry:()=>h()})]});let V=(g??[]).filter(e=>e.enabled).length;return(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(W,{title:`Jobs`,compact:!0,meta:`${V}/${(g??[]).length} enabled`,action:(0,Q.jsxs)(i,{"data-testid":`new-job-button`,size:`sm`,onClick:()=>P(!0),className:`font-label text-xs font-medium bg-primary text-primary-foreground hover:bg-primary/90`,children:[(0,Q.jsx)(y,{size:12,className:`mr-1`}),` New job`]})}),(0,Q.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-2`,children:[(0,Q.jsxs)(`div`,{className:`relative min-w-0 flex-1 lg:max-w-md`,children:[(0,Q.jsx)(M,{size:14,className:`absolute left-3 top-1/2 -translate-y-1/2 text-outline`}),(0,Q.jsx)(C,{type:`search`,"aria-label":`Search jobs`,"data-testid":`job-search`,placeholder:`Search jobs…`,value:n,onChange:e=>r(e.target.value,{replace:!0}),className:`h-11 pl-9 text-base lg:h-9 lg:text-sm`})]}),(0,Q.jsxs)(m,{activeCount:Number(a!==`all`)+Number(s!==`all`),children:[(0,Q.jsxs)(`select`,{"aria-label":`Job status`,"data-testid":`job-status-filter`,value:a,onChange:e=>o(e.target.value),className:`form-control form-control-single max-w-full`,children:[(0,Q.jsx)(`option`,{value:`all`,children:`All statuses`}),(0,Q.jsx)(`option`,{value:`enabled`,children:`Enabled`}),(0,Q.jsx)(`option`,{value:`disabled`,children:`Disabled`})]}),(0,Q.jsxs)(`select`,{"aria-label":`Job trigger`,"data-testid":`job-trigger-filter`,value:s,onChange:e=>c(e.target.value),className:`form-control form-control-single max-w-full`,children:[(0,Q.jsx)(`option`,{value:`all`,children:`All triggers`}),$.map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))]})]})]}),(v.error||b.error||S.error)&&(0,Q.jsx)(`p`,{role:`alert`,className:`mb-4 text-sm text-error`,children:(v.error??b.error??S.error)?.message}),!!g?.length&&(0,Q.jsxs)(he,{resourceLabel:`jobs`,count:E.selectedIds.length,allSelected:E.allSelected,someSelected:E.someSelected,onSelectAll:E.selectAll,onClear:E.clear,disabled:w.isPending,children:[(0,Q.jsx)(i,{type:`button`,variant:`outline`,size:`sm`,"data-testid":`jobs-bulk-enable`,disabled:w.isPending||S.isPending,onClick:()=>void D(!0),children:`Enable selected`}),(0,Q.jsx)(i,{type:`button`,variant:`outline`,size:`sm`,"data-testid":`jobs-bulk-disable`,disabled:w.isPending||S.isPending,onClick:()=>void D(!1),children:`Disable selected`})]}),w.isPending&&(0,Q.jsx)(`p`,{role:`status`,className:`mb-3 text-sm text-outline`,children:`Updating selected jobs…`}),!w.isPending&&T&&(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:[T.succeeded.length,` jobs `,T.enabled?`enabled`:`disabled`,`.`]}),T.failed.map(e=>(0,Q.jsxs)(`p`,{className:`text-error`,children:[g?.find(t=>t.id===e.id)?.name??e.id,`: `,e.error,`. Still selected for retry.`]},e.id))]}),f?(0,Q.jsx)(`div`,{role:`status`,"aria-label":`Loading jobs`,className:`space-y-2`,children:[...[,,,]].map((e,t)=>(0,Q.jsx)(O,{className:`h-12 w-full bg-surface-highest`},t))}):(g??[]).length===0?(0,Q.jsx)(K,{message:n||a!==`all`||s!==`all`?`No jobs match`:`No jobs configured`}):t?(0,Q.jsx)(`div`,{className:`min-w-0 overflow-hidden`,children:(0,Q.jsxs)(ie,{children:[(0,Q.jsx)(te,{children:(0,Q.jsxs)(re,{className:`border-b border-border hover:bg-transparent`,children:[(0,Q.jsx)(q,{className:`w-11`,children:(0,Q.jsx)(`span`,{className:`sr-only`,children:`Select jobs`})}),(0,Q.jsx)(q,{className:`font-label text-xs font-medium text-outline`,children:`Name`}),(0,Q.jsx)(q,{className:`font-label text-xs font-medium text-outline w-24`,children:`Trigger`}),(0,Q.jsx)(q,{className:`font-label text-xs font-medium text-outline w-48`,children:`Action`}),(0,Q.jsx)(q,{className:`font-label text-xs font-medium text-outline w-16`,children:`Enabled`}),(0,Q.jsx)(q,{className:`font-label text-xs font-medium text-outline w-36`,children:`Last Run`}),(0,Q.jsx)(q,{className:`font-label text-xs font-medium text-outline w-16`,children:`Runs`}),(0,Q.jsx)(q,{className:`font-label text-xs font-medium text-outline w-36`,children:`Next Run`}),(0,Q.jsx)(q,{className:`w-28`})]})}),(0,Q.jsx)(ne,{children:(g??[]).map(e=>(0,Q.jsxs)(re,{"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:()=>A(e.id),children:[(0,Q.jsx)(J,{children:(0,Q.jsx)(`input`,{type:`checkbox`,className:`size-4 accent-primary`,"aria-label":`Select ${e.name}`,"data-testid":`job-select`,checked:E.selectedIds.includes(e.id),disabled:w.isPending,onClick:e=>e.stopPropagation(),onChange:()=>E.toggle(e.id)})}),(0,Q.jsxs)(J,{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(),A(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)(J,{children:(0,Q.jsx)(`span`,{className:`font-label text-xs text-on-surface-variant inline-flex`,children:e.trigger_type})}),(0,Q.jsx)(J,{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)(J,{children:(0,Q.jsx)(i,{type:`button`,"data-testid":`job-toggle-enabled`,variant:`outline`,size:`sm`,"aria-label":`${e.enabled?`Disable`:`Enable`} ${e.name}`,"aria-pressed":e.enabled,disabled:S.isPending||w.isPending,onClick:t=>{t.stopPropagation(),S.mutate({id:e.id,enabled:!e.enabled})},children:e.enabled?`Disable`:`Enable`})}),(0,Q.jsx)(J,{className:`font-label text-xs text-outline`,children:e.last_run_at?new Date(e.last_run_at).toLocaleString():`—`}),(0,Q.jsx)(J,{className:`font-label text-xs text-outline`,children:e.run_count}),(0,Q.jsx)(J,{className:`font-label text-xs text-outline`,children:e.next_run_at?new Date(e.next_run_at).toLocaleString():`—`}),(0,Q.jsx)(J,{children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,onClick:e=>e.stopPropagation(),children:[(0,Q.jsxs)(i,{variant:`ghost`,"data-testid":`job-trigger`,size:`sm`,disabled:v.isPending,onClick:()=>v.mutate(e.id),className:`font-label text-sm min-h-8 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)(i,{type:`button`,"data-testid":`job-edit`,variant:`ghost`,size:`icon`,"aria-label":`Edit ${e.name}`,onClick:()=>R(e),className:`inline-flex min-h-8 min-w-8 items-center justify-center rounded-md text-outline hover:text-primary hover:bg-surface-highest`,children:(0,Q.jsx)(F,{size:16})}),(0,Q.jsx)(i,{type:`button`,"data-testid":`job-delete`,variant:`ghost`,size:`icon`,"aria-label":`Delete ${e.name}`,onClick:()=>B(e),className:`inline-flex min-h-8 min-w-8 items-center justify-center rounded-md text-outline hover:text-error hover:bg-error/10`,children:(0,Q.jsx)(L,{size:12})})]})})]},e.id))})]})}):(0,Q.jsx)(`div`,{className:`divide-y divide-border`,children:(g??[]).map(e=>(0,Q.jsxs)(`article`,{"data-testid":`job-row`,"data-job-id":e.id,"data-job-name":e.name,className:`py-3 space-y-2`,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:E.selectedIds.includes(e.id),disabled:w.isPending,onChange:()=>E.toggle(e.id)}),(0,Q.jsx)(`button`,{type:`button`,className:`min-w-0 flex-1 text-left font-medium text-sm text-on-surface wrap-break-word hover:text-primary`,"data-testid":`job-open-detail`,onClick:()=>A(e.id),children:e.name}),(0,Q.jsx)(i,{type:`button`,"data-testid":`job-toggle-enabled`,variant:`outline`,size:`sm`,"aria-label":`${e.enabled?`Disable`:`Enable`} ${e.name}`,"aria-pressed":e.enabled,disabled:S.isPending||w.isPending,onClick:()=>S.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`,children:[(0,Q.jsxs)(i,{"data-testid":`job-edit`,variant:`ghost`,size:`sm`,onClick:()=>R(e),children:[(0,Q.jsx)(F,{}),`Edit`]}),(0,Q.jsxs)(i,{"data-testid":`job-trigger`,variant:`ghost`,size:`sm`,disabled:v.isPending,onClick:()=>v.mutate(e.id),children:[(0,Q.jsx)(X,{}),`Run`]}),(0,Q.jsx)(i,{"data-testid":`job-delete`,"aria-label":`Delete ${e.name}`,variant:`ghost`,size:`icon`,onClick:()=>B(e),children:(0,Q.jsx)(L,{})})]})]},e.id))}),(0,Q.jsx)(we,{projectScope:l,jobId:k,open:!!k,onClose:j,onEdit:e=>{j(),R(e)}}),N&&(0,Q.jsx)(Ae,{defaultProjectId:u,open:N,onClose:()=>P(!1)}),I&&(0,Q.jsx)(je,{job:I,open:!!I,onClose:()=>R(null)}),z&&(0,Q.jsx)(H,{open:!!z,title:`Delete Job`,description:`Delete job "${z.name}"? This cannot be undone.`,confirmLabel:`Delete`,variant:`destructive`,isPending:b.isPending,onConfirm:()=>{b.mutate(z.id,{onSuccess:()=>B(null)})},onCancel:()=>B(null)})]})}function Ae({defaultProjectId:e,open:t,onClose:n}){let{data:r}=N(),o=b([{id:`details`,label:`Details`},{id:`execution`,label:`Execution`},{id:`automation`,label:`Automation`}],t),[f,p]=(0,Z.useState)(``),[m,h]=(0,Z.useState)(``),[y,x]=(0,Z.useState)({type:`command`,command:``}),[S,w]=(0,Z.useState)([]),[T,E]=(0,Z.useState)(`manual`),[O,k]=(0,Z.useState)(``),[A,j]=(0,Z.useState)(`300`),[M,F]=(0,Z.useState)(`0`),[I,L]=(0,Z.useState)(`skip`),[R,z]=(0,Z.useState)(`failure`),[H,U]=(0,Z.useState)(``),[W,ee]=(0,Z.useState)(e??``),G=me(),[K,te]=(0,Z.useState)(!1),q=(e,t=n)=>{if(e.preventDefault(),T===`webhook`&&!S.length){o.invalid(`automation`,`Select at least one webhook for this trigger.`);return}if(!f.trim()||!Se(y))return;let r={name:f.trim(),description:m.trim(),action:y,webhooks:T===`webhook`?S:[],trigger_type:T,enabled:K,cron_expr:T===`cron`&&O.trim()||void 0,timeout_secs:Number.parseInt(A,10)||void 0,max_retries:Number.parseInt(M,10),overlap:I,notify_on:R,project_id:W||void 0,working_dir:H.trim()||void 0};G.mutate(r,{onSuccess:t})};return(0,Q.jsx)(B,{open:t,onClose:n,busy:G.isPending,dirty:JSON.stringify([f,m,y,S,T,O,A,M,I,R,H,W,K])!==JSON.stringify([``,``,{type:`command`,command:``},[],`manual`,``,`300`,`0`,`skip`,`failure`,``,e??``,!1]),children:(e,t)=>(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(g,{children:(0,Q.jsx)(v,{className:`font-headline text-sm font-medium text-on-surface`,children:`New job`})}),(0,Q.jsx)(`form`,{noValidate:!0,ref:o.form,onSubmit:e=>o.submit(e,()=>q(e,t)),className:`min-h-0`,children:(0,Q.jsxs)(D,{steps:o,children:[(0,Q.jsxs)(`div`,{className:`work-form-body space-y-4`,children:[(0,Q.jsxs)(V,{steps:o,id:`details`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(a,{className:`font-label text-xs font-medium text-outline`,children:`Name *`}),(0,Q.jsx)(C,{required:!0,"aria-label":`Name`,"data-testid":`job-name-input`,value:f,onChange:e=>p(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)(a,{className:`font-label text-xs font-medium text-outline`,children:`Description`}),(0,Q.jsx)(C,{"aria-label":`Description`,value:m,onChange:e=>h(e.target.value),placeholder:`Optional description...`,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)(a,{className:`font-label text-xs font-medium text-outline`,children:`Project`}),(0,Q.jsxs)(d,{value:W||`__none__`,onValueChange:e=>{ee(e===`__none__`?``:e),w([])},children:[(0,Q.jsx)(c,{"aria-label":`Project`,"data-testid":`job-project-select`,className:`bg-background border-control-border text-on-surface font-body text-sm min-h-8`,children:(0,Q.jsx)(s,{})}),(0,Q.jsxs)(l,{className:`bg-surface border-border`,children:[(0,Q.jsx)(u,{value:`__none__`,className:`font-body text-sm`,children:`None`}),r?.map(e=>(0,Q.jsx)(u,{value:e.id,className:`font-body text-sm`,children:e.name},e.id))]})]})]})]}),(0,Q.jsxs)(V,{steps:o,id:`execution`,children:[(0,Q.jsx)(Ce,{value:y,onChange:x}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(a,{className:`font-label text-xs font-medium text-outline`,children:`Working Dir`}),(0,Q.jsx)(C,{"aria-label":`Working directory`,value:H,onChange:e=>U(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:`grid grid-cols-1 gap-4 sm:grid-cols-3 md:col-span-2`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(a,{className:`font-label text-xs font-medium text-outline`,children:`Timeout (s)`}),(0,Q.jsx)(C,{"aria-label":`Timeout in seconds`,type:`number`,min:1,required:!0,value:A,onChange:e=>j(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)(a,{className:`font-label text-xs font-medium text-outline`,children:`Retries`}),(0,Q.jsx)(C,{"aria-label":`Maximum retries`,type:`number`,min:0,required:!0,value:M,onChange:e=>F(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)(a,{className:`font-label text-xs font-medium text-outline`,children:`Overlap`}),(0,Q.jsxs)(d,{value:I,onValueChange:e=>L(e),children:[(0,Q.jsx)(c,{"aria-label":`Overlap`,className:`bg-background border-control-border text-on-surface font-body text-sm min-h-8`,children:(0,Q.jsx)(s,{})}),(0,Q.jsx)(l,{className:`bg-surface border-border`,children:De.map(e=>(0,Q.jsx)(u,{value:e,className:`font-body text-sm`,children:e},e))})]})]})]})]}),(0,Q.jsxs)(V,{steps:o,id:`automation`,children:[(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2 md:col-span-2`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(a,{className:`font-label text-xs font-medium text-outline`,children:`Trigger`}),(0,Q.jsxs)(d,{value:T,onValueChange:e=>E(e),children:[(0,Q.jsx)(c,{"aria-label":`Trigger type`,"data-testid":`job-trigger-type`,className:`bg-background border-control-border text-on-surface font-body text-sm min-h-8`,children:(0,Q.jsx)(s,{})}),(0,Q.jsx)(l,{className:`bg-surface border-border`,children:$.map(e=>(0,Q.jsx)(u,{value:e,"data-testid":`job-trigger-${e}`,className:`font-body text-sm`,children:e},e))})]})]}),T===`webhook`&&(0,Q.jsx)(`div`,{className:`sm:col-span-2`,children:(0,Q.jsx)(_e,{value:S,onChange:w,projectId:W||void 0})}),T===`cron`&&(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(a,{className:`font-label text-xs font-medium text-outline`,children:`Cron expression`}),(0,Q.jsx)(C,{required:!0,"aria-label":`Cron expression`,value:O,onChange:e=>k(e.target.value),placeholder:`*/5 * * * *`,className:`bg-background border-control-border text-on-surface font-mono text-xs`})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(a,{className:`font-label text-xs font-medium text-outline`,children:`Notify On`}),(0,Q.jsxs)(d,{value:R,onValueChange:e=>z(e),children:[(0,Q.jsx)(c,{"aria-label":`Notify on`,className:`bg-background border-control-border text-on-surface font-body text-sm min-h-8`,children:(0,Q.jsx)(s,{})}),(0,Q.jsx)(l,{className:`bg-surface border-border`,children:Oe.map(e=>(0,Q.jsx)(u,{value:e,className:`font-body text-sm`,children:e},e))})]})]}),(0,Q.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm md:col-span-2`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,"data-testid":`job-create-enabled`,checked:K,onChange:e=>te(e.target.checked),className:`size-4 accent-primary`}),`Enable this job immediately`]}),(0,Q.jsx)(`p`,{className:`text-xs text-outline md:col-span-2`,children:`Created disabled unless you enable it above.`})]}),(0,Q.jsx)(`div`,{className:`md:col-span-2`,children:G.error&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-error`,children:G.error.message})}),o.error&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-error`,children:o.error})]}),(0,Q.jsxs)(_,{className:`work-form-footer`,children:[(0,Q.jsx)(i,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`form-cancel`,onClick:e,className:`font-label text-xs text-outline`,children:`Cancel`}),(0,Q.jsx)(P,{steps:o,busy:G.isPending,children:(0,Q.jsx)(i,{"data-testid":`job-submit`,type:`submit`,size:`sm`,disabled:G.isPending,className:`font-label text-xs bg-primary text-primary-foreground hover:bg-primary/90`,children:G.isPending?`Creating...`:T===`webhook`?`Create job`:`Create`})})]})]})})]})})}function je({job:e,open:t,onClose:n}){let r=b([{id:`details`,label:`Details`},{id:`execution`,label:`Execution`},{id:`automation`,label:`Automation`}],t),[o,f]=(0,Z.useState)(e.name),[p,m]=(0,Z.useState)(e.description??``),[h,y]=(0,Z.useState)(e.action??{type:`command`,command:e.command}),[x,S]=(0,Z.useState)(e.webhooks??[]),[w,T]=(0,Z.useState)(e.trigger_type),[E,O]=(0,Z.useState)(e.cron_expr??``),[k,A]=(0,Z.useState)(String(e.timeout_secs)),[j,M]=(0,Z.useState)(String(e.max_retries)),[N,F]=(0,Z.useState)(e.overlap),[I,L]=(0,Z.useState)(e.notify_on),[R,z]=(0,Z.useState)(e.enabled),H=Y(),U=(t,i=n)=>{if(t.preventDefault(),w===`webhook`&&!x.length){r.invalid(`automation`,`Select at least one webhook for this trigger.`);return}if(!o.trim()||!Se(h))return;let a={id:e.id,name:o.trim(),description:p.trim(),action:h,webhooks:w===`webhook`?x:[],trigger_type:w,cron_expr:w===`cron`&&E.trim()||void 0,timeout_secs:Number.parseInt(k,10)||void 0,max_retries:Number.parseInt(j,10),overlap:N,notify_on:I,enabled:R};H.mutate(a,{onSuccess:i})};return(0,Q.jsx)(B,{open:t,onClose:n,busy:H.isPending,dirty:JSON.stringify([o,p,h,x,w,E,k,j,N,I,R])!==JSON.stringify([e.name,e.description??``,e.action??{type:`command`,command:e.command},e.webhooks??[],e.trigger_type,e.cron_expr??``,String(e.timeout_secs),String(e.max_retries),e.overlap,e.notify_on,e.enabled]),children:(t,n)=>(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(g,{children:(0,Q.jsx)(v,{className:`font-headline text-sm font-medium text-on-surface`,children:`Edit job`})}),(0,Q.jsx)(`form`,{noValidate:!0,ref:r.form,id:`edit-job-form`,onSubmit:e=>r.submit(e,()=>U(e,n)),className:`min-h-0`,children:(0,Q.jsxs)(D,{steps:r,children:[(0,Q.jsxs)(`div`,{className:`work-form-body space-y-4`,children:[(0,Q.jsxs)(V,{steps:r,id:`details`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(a,{className:`font-label text-xs font-medium text-outline`,children:`Name *`}),(0,Q.jsx)(C,{required:!0,"aria-label":`Name`,value:o,onChange:e=>f(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)(a,{className:`font-label text-xs font-medium text-outline`,children:`Description`}),(0,Q.jsx)(C,{"aria-label":`Description`,value:p,onChange:e=>m(e.target.value),className:`bg-background border-control-border text-on-surface font-body text-sm`})]})]}),(0,Q.jsxs)(V,{steps:r,id:`execution`,children:[(0,Q.jsx)(Ce,{value:h,onChange:y}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-3 md:col-span-2`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(a,{className:`font-label text-xs font-medium text-outline`,children:`Timeout (s)`}),(0,Q.jsx)(C,{"aria-label":`Timeout in seconds`,type:`number`,min:1,required:!0,value:k,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)(a,{className:`font-label text-xs font-medium text-outline`,children:`Retries`}),(0,Q.jsx)(C,{"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)(a,{className:`font-label text-xs font-medium text-outline`,children:`Overlap`}),(0,Q.jsxs)(d,{value:N,onValueChange:e=>F(e),children:[(0,Q.jsx)(c,{"aria-label":`Overlap`,className:`bg-background border-control-border text-on-surface font-body text-sm min-h-8`,children:(0,Q.jsx)(s,{})}),(0,Q.jsx)(l,{className:`bg-surface border-border`,children:De.map(e=>(0,Q.jsx)(u,{value:e,className:`font-body text-sm`,children:e},e))})]})]})]})]}),(0,Q.jsxs)(V,{steps:r,id:`automation`,children:[(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2 md:col-span-2`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(a,{className:`font-label text-xs font-medium text-outline`,children:`Trigger`}),(0,Q.jsxs)(d,{value:w,onValueChange:e=>T(e),children:[(0,Q.jsx)(c,{"aria-label":`Trigger type`,"data-testid":`job-trigger-type`,className:`bg-background border-control-border text-on-surface font-body text-sm min-h-8`,children:(0,Q.jsx)(s,{})}),(0,Q.jsx)(l,{className:`bg-surface border-border`,children:$.map(e=>(0,Q.jsx)(u,{value:e,"data-testid":`job-trigger-${e}`,className:`font-body text-sm`,children:e},e))})]})]}),w===`webhook`&&(0,Q.jsx)(`div`,{className:`sm:col-span-2`,children:(0,Q.jsx)(_e,{value:x,onChange:S,projectId:e.project_id??void 0})}),w===`cron`&&(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(a,{className:`font-label text-xs font-medium text-outline`,children:`Cron expression`}),(0,Q.jsx)(C,{required:!0,"aria-label":`Cron expression`,value:E,onChange:e=>O(e.target.value),placeholder:`*/5 * * * *`,className:`bg-background border-control-border text-on-surface font-mono text-xs`})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(a,{className:`font-label text-xs font-medium text-outline`,children:`Notify On`}),(0,Q.jsxs)(d,{value:I,onValueChange:e=>L(e),children:[(0,Q.jsx)(c,{"aria-label":`Notify on`,className:`bg-background border-control-border text-on-surface font-body text-sm min-h-8`,children:(0,Q.jsx)(s,{})}),(0,Q.jsx)(l,{className:`bg-surface border-border`,children:Oe.map(e=>(0,Q.jsx)(u,{value:e,className:`font-body text-sm`,children:e},e))})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(a,{className:`font-label text-xs font-medium text-outline`,children:`Enabled`}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>z(!R),className:`w-full min-h-11 rounded-md flex items-center justify-center border font-label text-xs font-medium transition-colors ${R?`bg-surface-highest text-on-surface border-border`:`bg-background text-outline border-border`}`,children:R?`● Enabled`:`○ Disabled`})]})]}),(0,Q.jsx)(`div`,{className:`md:col-span-2`,children:H.error&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-error`,children:H.error.message})}),r.error&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-error`,children:r.error})]}),(0,Q.jsxs)(_,{className:`work-form-footer`,children:[(0,Q.jsx)(i,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`form-cancel`,onClick:t,className:`font-label text-xs text-outline`,children:`Cancel`}),(0,Q.jsx)(P,{steps:r,busy:H.isPending,children:(0,Q.jsx)(i,{"data-testid":`job-edit-submit`,form:`edit-job-form`,type:`submit`,size:`sm`,disabled:H.isPending,className:`font-label text-xs bg-primary text-primary-foreground hover:bg-primary/90`,children:H.isPending?`Saving...`:`Save`})})]})]})})]})})}export{ke 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"./chunk-OB3PAWPO-1IihCzFx.js";import{t as i}from"./button-CXYVslgR.js";import{t as a}from"./label-wk_QKooL.js";import{t as o}from"./scroll-area-D0FZFdju.js";import{a as s,i as c,n as l,r as u,t as d}from"./select-Cj-m0J9A.js";import{d as f}from"./client-nzMXason.js";import{t as p}from"./chevron-down-hj6o3_QU.js";import{t as m}from"./ResponsiveFilters-DAeezpA-.js";import{t as h}from"./textarea-Bt1FBmGL.js";import{a as g,i as _,o as v}from"./dialog-Juth7dP_.js";import{Ct as y,Et as b,Ft as x,G as S,J as C,Jt as w,K as T,P as E,Qt as D,St as O,U as k,W as A,X as j,Y as M,_t as N,bt as P,ft as F,nn as I,pn as L,st as R,tn as z,wt as B,xt as V}from"./index-B8heHbQj.js";import{t as H}from"./ConfirmDialog-Cyd60q9b.js";import{t as U}from"./ErrorState-BrKz7Mii.js";import{t as W}from"./ViewHeader-BUk4Owsd.js";import{t as ee}from"./useDetailRoute-DOhAbdV7.js";import{t as G}from"./view-params-DD7i9s5g.js";import{t as K}from"./EmptyState-YM4VSLR9.js";import{a as te,i as q,n as ne,o as re,r as J,t as ie}from"./table-Cri9EUoE.js";import{t as ae}from"./useProjectScope-DtEj9j-P.js";import{t as oe}from"./StatusBadge-ia651_Df.js";import{a as se,c as ce,i as le,l as Y,n as ue,o as de,r as fe,s as pe,t as me}from"./useJobs-B2da-s4n.js";import{n as he,t as ge}from"./useListSelection-ZreW_5e4.js";import{i as _e,t as ve}from"./JobWebhooks-KpcTAXv_.js";var ye={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`}]]};ye.node;var X=f(ye),be={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`}]]};be.node;var xe=f(be),Z=e(t(),1),Q=n();function Se(e){return e.type===`command`?!!e.command.trim():e.type===`agent`?!!(e.prompt.trim()&&e.backend.trim()):!!e.title.trim()}function Ce({value:e,onChange:t}){let n=(0,Z.useId)(),{data:r}=F();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)(a,{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-8 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)(a,{htmlFor:`${n}-command`,children:`Command`}),(0,Q.jsx)(h,{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)(a,{htmlFor:`${n}-backend`,children:`Agent backend`}),(0,Q.jsx)(x,{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)(a,{htmlFor:`${n}-model`,children:`Model (optional)`}),(0,Q.jsx)(x,{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)(a,{htmlFor:`${n}-prompt`,children:`Instructions`}),(0,Q.jsx)(h,{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)(a,{htmlFor:`${n}-title`,children:`Task title`}),(0,Q.jsx)(x,{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.jsx)(E,{label:`Task instructions`,id:`${n}-body`,"data-testid":`job-task-body`,value:e.body,onChange:n=>t({...e,body:n}),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)(a,{htmlFor:`${n}-flow`,children:`Flow (blank uses the configured default)`}),(0,Q.jsx)(x,{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 we({jobId:e,open:t,onClose:n,onEdit:r,projectScope:a=`all`}){let{data:o,isLoading:s,error:c,refetch:l}=fe(e),u=o&&(a===`all`||(a===`unassigned`?o.project_id===null:o.project_id===a)),d=u?o:void 0;(0,Z.useEffect)(()=>{t&&o&&!u&&n()},[t,o,u,n]);let{data:f,isLoading:p,error:m,refetch:h}=se(d?.id??null),g=ce(),_=Y(),[v,y]=(0,Z.useState)(null);return(0,Q.jsx)(A,{open:t,onOpenChange:e=>!e&&n(),children:(0,Q.jsxs)(T,{"data-testid":`job-detail-sheet`,children:[(0,Q.jsxs)(M,{children:[(0,Q.jsx)(j,{children:d?.name??`Job details`}),d?.description&&(0,Q.jsx)(`p`,{className:`font-body text-xs text-outline mt-1`,children:d.description})]}),(0,Q.jsx)(S,{children:c?(0,Q.jsx)(U,{message:c.message,onRetry:()=>l()}):s?(0,Q.jsx)(`div`,{className:`space-y-3`,children:[...[,,,,,,]].map((e,t)=>(0,Q.jsx)(k,{className:`h-8 w-full bg-surface-highest`},t))}):d?(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(R,{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:d.action?.type===`agent`?`Run agent (${d.action.backend}): ${d.action.prompt}`:d.action?.type===`task`?`Create task: ${d.action.title}`:d.command})}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-4`,children:[(0,Q.jsx)(R,{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:d.trigger_type})}),(0,Q.jsx)(R,{label:`Enabled`,children:(0,Q.jsx)(`span`,{className:`font-label text-xs font-bold ${d.enabled?`text-secondary`:`text-outline`}`,children:d.enabled?`● ON`:`○ OFF`})})]}),d.cron_expr&&(0,Q.jsx)(R,{label:`Cron Expression`,children:(0,Q.jsx)(`code`,{className:`font-mono text-xs`,children:d.cron_expr})}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-3 gap-4`,children:[(0,Q.jsxs)(R,{label:`Timeout`,children:[d.timeout_secs,`s`]}),(0,Q.jsx)(R,{label:`Max Retries`,children:d.max_retries}),(0,Q.jsx)(R,{label:`Overlap`,children:d.overlap})]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-4`,children:[(0,Q.jsx)(R,{label:`Notify On`,children:d.notify_on}),(0,Q.jsx)(R,{label:`Run Count`,children:d.run_count})]}),d.next_run_at&&(0,Q.jsx)(R,{label:`Next Run`,children:new Date(d.next_run_at).toLocaleString()})]}),!d.command.startsWith(`__`)&&(0,Q.jsx)(ve,{job:d},d.id),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`font-label text-xs font-medium text-outline mb-3`,children:`Recent runs`}),m?(0,Q.jsx)(U,{message:m.message,onRetry:()=>h()}):p?(0,Q.jsx)(`div`,{className:`space-y-2`,children:[...[,,,]].map((e,t)=>(0,Q.jsx)(k,{className:`h-8 w-full bg-surface-highest`},t))}):f?.length?(0,Q.jsx)(`div`,{className:`space-y-1`,children:f.map(t=>(0,Q.jsx)(Te,{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)(C,{className:`flex-wrap`,children:[(_.error||g.error)&&(0,Q.jsx)(`p`,{role:`alert`,className:`w-full text-sm text-error`,children:(_.error??g.error)?.message}),d&&r&&(0,Q.jsxs)(i,{"data-testid":`job-detail-edit`,size:`sm`,variant:`outline`,onClick:()=>r(d),children:[(0,Q.jsx)(I,{size:16}),`Edit job`]}),d&&(0,Q.jsxs)(i,{size:`sm`,variant:`ghost`,disabled:_.isPending,onClick:()=>_.mutate({id:d.id,enabled:!d.enabled}),className:`font-label text-xs font-medium`,children:[(0,Q.jsx)(xe,{size:12,className:`mr-1.5`}),d.enabled?`Disable`:`Enable`]}),d&&(0,Q.jsxs)(i,{variant:`ghost`,size:`sm`,disabled:g.isPending,onClick:()=>g.mutate(d.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`}),g.isPending?`Triggering...`:`Trigger run`]})]})]})})}function Te({run:e,jobId:t,expanded:n,onToggle:i}){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:i,"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)(p,{size:12,className:`text-outline shrink-0`}):(0,Q.jsx)(L,{size:12,className:`text-outline shrink-0`}),(0,Q.jsx)(oe,{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)(r,{className:`underline`,"data-testid":`job-run-task-link`,to:`/tasks/${e.task_id}?project=all`,children:`Created task`}),e.session_id&&(0,Q.jsx)(r,{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)(Ee,{jobId:t,runId:e.id})]})}function Ee({jobId:e,runId:t}){let{data:n,isLoading:r,error:i,refetch:a}=le(e,t);return i?(0,Q.jsx)(U,{message:i.message,onRetry:()=>a()}):r?(0,Q.jsx)(`div`,{className:`px-3 pb-3`,children:(0,Q.jsx)(k,{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)(o,{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 $=[`one-shot`,`cron`,`watch`,`webhook`,`manual`,`bridge-msg`],De=[`skip`,`queue`,`kill`],Oe=[`never`,`failure`,`always`];function ke({projectId:e}){let t=b(`xl`),[n,r]=G(`jobQuery`,``),[a,o]=G(`jobStatus`,`all`,[`all`,`enabled`,`disabled`]),[s,c]=G(`jobTrigger`,`all`,[`all`,...$]),l=ae(e),u=l===`all`||l===`unassigned`?void 0:l,{data:d,isLoading:f,error:p,refetch:h}=de({project_id:l===`all`?void 0:l,limit:100}),g=(l===`unassigned`?d?.filter(e=>e.project_id===null):d)?.filter(e=>(!n||`${e.name} ${e.description??``} ${e.command??``}`.toLowerCase().includes(n.toLowerCase()))&&(a===`all`||e.enabled===(a===`enabled`))&&(s===`all`||e.trigger_type===s)),_=JSON.stringify([l,n,a,s]),v=ce(),y=ue(),S=Y(),C=pe(),T=C.data?.scope===_?C.data:void 0,E=ge((g??[]).map(e=>e.id),_);async function O(e){let t=await C.mutateAsync({ids:E.selectedIds,enabled:e,scope:_});E.select(t.failed.map(e=>e.id))}let{selectedId:A,openDetail:j,closeDetail:M}=ee(`/jobs`,`jobId`),[N,P]=(0,Z.useState)(!1),[F,L]=(0,Z.useState)(null),[R,B]=(0,Z.useState)(null);if(p)return(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(W,{title:`Jobs`}),(0,Q.jsx)(U,{message:p.message,onRetry:()=>h()})]});let V=(g??[]).filter(e=>e.enabled).length;return(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(W,{title:`Jobs`,compact:!0,meta:`${V}/${(g??[]).length} enabled`,action:(0,Q.jsxs)(i,{"data-testid":`new-job-button`,size:`sm`,onClick:()=>P(!0),className:`font-label text-xs font-medium bg-primary text-primary-foreground hover:bg-primary/90`,children:[(0,Q.jsx)(z,{size:12,className:`mr-1`}),` New job`]})}),(0,Q.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-2`,children:[(0,Q.jsxs)(`div`,{className:`relative min-w-0 flex-1 lg:max-w-md`,children:[(0,Q.jsx)(D,{size:14,className:`absolute left-3 top-1/2 -translate-y-1/2 text-outline`}),(0,Q.jsx)(x,{type:`search`,"aria-label":`Search jobs`,"data-testid":`job-search`,placeholder:`Search jobs…`,value:n,onChange:e=>r(e.target.value,{replace:!0}),className:`h-11 pl-9 text-base lg:h-9 lg:text-sm`})]}),(0,Q.jsxs)(m,{activeCount:Number(a!==`all`)+Number(s!==`all`),children:[(0,Q.jsxs)(`select`,{"aria-label":`Job status`,"data-testid":`job-status-filter`,value:a,onChange:e=>o(e.target.value),className:`form-control form-control-single max-w-full`,children:[(0,Q.jsx)(`option`,{value:`all`,children:`All statuses`}),(0,Q.jsx)(`option`,{value:`enabled`,children:`Enabled`}),(0,Q.jsx)(`option`,{value:`disabled`,children:`Disabled`})]}),(0,Q.jsxs)(`select`,{"aria-label":`Job trigger`,"data-testid":`job-trigger-filter`,value:s,onChange:e=>c(e.target.value),className:`form-control form-control-single max-w-full`,children:[(0,Q.jsx)(`option`,{value:`all`,children:`All triggers`}),$.map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))]})]})]}),(v.error||y.error||S.error)&&(0,Q.jsx)(`p`,{role:`alert`,className:`mb-4 text-sm text-error`,children:(v.error??y.error??S.error)?.message}),!!g?.length&&(0,Q.jsxs)(he,{resourceLabel:`jobs`,count:E.selectedIds.length,allSelected:E.allSelected,someSelected:E.someSelected,onSelectAll:E.selectAll,onClear:E.clear,disabled:C.isPending,children:[(0,Q.jsx)(i,{type:`button`,variant:`outline`,size:`sm`,"data-testid":`jobs-bulk-enable`,disabled:C.isPending||S.isPending,onClick:()=>void O(!0),children:`Enable selected`}),(0,Q.jsx)(i,{type:`button`,variant:`outline`,size:`sm`,"data-testid":`jobs-bulk-disable`,disabled:C.isPending||S.isPending,onClick:()=>void O(!1),children:`Disable selected`})]}),C.isPending&&(0,Q.jsx)(`p`,{role:`status`,className:`mb-3 text-sm text-outline`,children:`Updating selected jobs…`}),!C.isPending&&T&&(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:[T.succeeded.length,` jobs `,T.enabled?`enabled`:`disabled`,`.`]}),T.failed.map(e=>(0,Q.jsxs)(`p`,{className:`text-error`,children:[g?.find(t=>t.id===e.id)?.name??e.id,`: `,e.error,`. Still selected for retry.`]},e.id))]}),f?(0,Q.jsx)(`div`,{role:`status`,"aria-label":`Loading jobs`,className:`space-y-2`,children:[...[,,,]].map((e,t)=>(0,Q.jsx)(k,{className:`h-12 w-full bg-surface-highest`},t))}):(g??[]).length===0?(0,Q.jsx)(K,{message:n||a!==`all`||s!==`all`?`No jobs match`:`No jobs configured`}):t?(0,Q.jsx)(`div`,{className:`min-w-0 overflow-hidden`,children:(0,Q.jsxs)(ie,{children:[(0,Q.jsx)(te,{children:(0,Q.jsxs)(re,{className:`border-b border-border hover:bg-transparent`,children:[(0,Q.jsx)(q,{className:`w-11`,children:(0,Q.jsx)(`span`,{className:`sr-only`,children:`Select jobs`})}),(0,Q.jsx)(q,{className:`font-label text-xs font-medium text-outline`,children:`Name`}),(0,Q.jsx)(q,{className:`font-label text-xs font-medium text-outline w-24`,children:`Trigger`}),(0,Q.jsx)(q,{className:`font-label text-xs font-medium text-outline w-48`,children:`Action`}),(0,Q.jsx)(q,{className:`font-label text-xs font-medium text-outline w-16`,children:`Enabled`}),(0,Q.jsx)(q,{className:`font-label text-xs font-medium text-outline w-36`,children:`Last Run`}),(0,Q.jsx)(q,{className:`font-label text-xs font-medium text-outline w-16`,children:`Runs`}),(0,Q.jsx)(q,{className:`font-label text-xs font-medium text-outline w-36`,children:`Next Run`}),(0,Q.jsx)(q,{className:`w-28`})]})}),(0,Q.jsx)(ne,{children:(g??[]).map(e=>(0,Q.jsxs)(re,{"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:()=>j(e.id),children:[(0,Q.jsx)(J,{children:(0,Q.jsx)(`input`,{type:`checkbox`,className:`size-4 accent-primary`,"aria-label":`Select ${e.name}`,"data-testid":`job-select`,checked:E.selectedIds.includes(e.id),disabled:C.isPending,onClick:e=>e.stopPropagation(),onChange:()=>E.toggle(e.id)})}),(0,Q.jsxs)(J,{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(),j(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)(J,{children:(0,Q.jsx)(`span`,{className:`font-label text-xs text-on-surface-variant inline-flex`,children:e.trigger_type})}),(0,Q.jsx)(J,{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)(J,{children:(0,Q.jsx)(i,{type:`button`,"data-testid":`job-toggle-enabled`,variant:`outline`,size:`sm`,"aria-label":`${e.enabled?`Disable`:`Enable`} ${e.name}`,"aria-pressed":e.enabled,disabled:S.isPending||C.isPending,onClick:t=>{t.stopPropagation(),S.mutate({id:e.id,enabled:!e.enabled})},children:e.enabled?`Disable`:`Enable`})}),(0,Q.jsx)(J,{className:`font-label text-xs text-outline`,children:e.last_run_at?new Date(e.last_run_at).toLocaleString():`—`}),(0,Q.jsx)(J,{className:`font-label text-xs text-outline`,children:e.run_count}),(0,Q.jsx)(J,{className:`font-label text-xs text-outline`,children:e.next_run_at?new Date(e.next_run_at).toLocaleString():`—`}),(0,Q.jsx)(J,{children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,onClick:e=>e.stopPropagation(),children:[(0,Q.jsxs)(i,{variant:`ghost`,"data-testid":`job-trigger`,size:`sm`,disabled:v.isPending,onClick:()=>v.mutate(e.id),className:`font-label text-sm min-h-8 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)(i,{type:`button`,"data-testid":`job-edit`,variant:`ghost`,size:`icon`,"aria-label":`Edit ${e.name}`,onClick:()=>L(e),className:`inline-flex min-h-8 min-w-8 items-center justify-center rounded-md text-outline hover:text-primary hover:bg-surface-highest`,children:(0,Q.jsx)(I,{size:16})}),(0,Q.jsx)(i,{type:`button`,"data-testid":`job-delete`,variant:`ghost`,size:`icon`,"aria-label":`Delete ${e.name}`,onClick:()=>B(e),className:`inline-flex min-h-8 min-w-8 items-center justify-center rounded-md text-outline hover:text-error hover:bg-error/10`,children:(0,Q.jsx)(w,{size:12})})]})})]},e.id))})]})}):(0,Q.jsx)(`div`,{className:`divide-y divide-border`,children:(g??[]).map(e=>(0,Q.jsxs)(`article`,{"data-testid":`job-row`,"data-job-id":e.id,"data-job-name":e.name,className:`py-3 space-y-2`,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:E.selectedIds.includes(e.id),disabled:C.isPending,onChange:()=>E.toggle(e.id)}),(0,Q.jsx)(`button`,{type:`button`,className:`min-w-0 flex-1 text-left font-medium text-sm text-on-surface wrap-break-word hover:text-primary`,"data-testid":`job-open-detail`,onClick:()=>j(e.id),children:e.name}),(0,Q.jsx)(i,{type:`button`,"data-testid":`job-toggle-enabled`,variant:`outline`,size:`sm`,"aria-label":`${e.enabled?`Disable`:`Enable`} ${e.name}`,"aria-pressed":e.enabled,disabled:S.isPending||C.isPending,onClick:()=>S.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`,children:[(0,Q.jsxs)(i,{"data-testid":`job-edit`,variant:`ghost`,size:`sm`,onClick:()=>L(e),children:[(0,Q.jsx)(I,{}),`Edit`]}),(0,Q.jsxs)(i,{"data-testid":`job-trigger`,variant:`ghost`,size:`sm`,disabled:v.isPending,onClick:()=>v.mutate(e.id),children:[(0,Q.jsx)(X,{}),`Run`]}),(0,Q.jsx)(i,{"data-testid":`job-delete`,"aria-label":`Delete ${e.name}`,variant:`ghost`,size:`icon`,onClick:()=>B(e),children:(0,Q.jsx)(w,{})})]})]},e.id))}),(0,Q.jsx)(we,{projectScope:l,jobId:A,open:!!A,onClose:M,onEdit:e=>{M(),L(e)}}),N&&(0,Q.jsx)(Ae,{defaultProjectId:u,open:N,onClose:()=>P(!1)}),F&&(0,Q.jsx)(je,{job:F,open:!!F,onClose:()=>L(null)}),R&&(0,Q.jsx)(H,{open:!!R,title:`Delete Job`,description:`Delete job "${R.name}"? This cannot be undone.`,confirmLabel:`Delete`,variant:`destructive`,isPending:y.isPending,onConfirm:()=>{y.mutate(R.id,{onSuccess:()=>B(null)})},onCancel:()=>B(null)})]})}function Ae({defaultProjectId:e,open:t,onClose:n}){let{data:r}=N(),o=y([{id:`details`,label:`Details`},{id:`execution`,label:`Execution`},{id:`automation`,label:`Automation`}],t),[f,p]=(0,Z.useState)(``),[m,h]=(0,Z.useState)(``),[b,S]=(0,Z.useState)({type:`command`,command:``}),[C,w]=(0,Z.useState)([]),[T,E]=(0,Z.useState)(`manual`),[D,k]=(0,Z.useState)(``),[A,j]=(0,Z.useState)(`300`),[M,F]=(0,Z.useState)(`0`),[I,L]=(0,Z.useState)(`skip`),[R,z]=(0,Z.useState)(`failure`),[H,U]=(0,Z.useState)(``),[W,ee]=(0,Z.useState)(e??``),G=me(),[K,te]=(0,Z.useState)(!1),q=(e,t=n)=>{if(e.preventDefault(),T===`webhook`&&!C.length){o.invalid(`automation`,`Select at least one webhook for this trigger.`);return}if(!f.trim()||!Se(b))return;let r={name:f.trim(),description:m.trim(),action:b,webhooks:T===`webhook`?C:[],trigger_type:T,enabled:K,cron_expr:T===`cron`&&D.trim()||void 0,timeout_secs:Number.parseInt(A,10)||void 0,max_retries:Number.parseInt(M,10),overlap:I,notify_on:R,project_id:W||void 0,working_dir:H.trim()||void 0};G.mutate(r,{onSuccess:t})};return(0,Q.jsx)(B,{open:t,onClose:n,busy:G.isPending,dirty:JSON.stringify([f,m,b,C,T,D,A,M,I,R,H,W,K])!==JSON.stringify([``,``,{type:`command`,command:``},[],`manual`,``,`300`,`0`,`skip`,`failure`,``,e??``,!1]),children:(e,t)=>(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(g,{children:(0,Q.jsx)(v,{className:`font-headline text-sm font-medium text-on-surface`,children:`New job`})}),(0,Q.jsx)(`form`,{noValidate:!0,ref:o.form,onSubmit:e=>o.submit(e,()=>q(e,t)),className:`min-h-0`,children:(0,Q.jsxs)(O,{steps:o,children:[(0,Q.jsxs)(`div`,{className:`work-form-body space-y-4`,children:[(0,Q.jsxs)(V,{steps:o,id:`details`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(a,{className:`font-label text-xs font-medium text-outline`,children:`Name *`}),(0,Q.jsx)(x,{required:!0,"aria-label":`Name`,"data-testid":`job-name-input`,value:f,onChange:e=>p(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)(a,{className:`font-label text-xs font-medium text-outline`,children:`Description`}),(0,Q.jsx)(x,{"aria-label":`Description`,value:m,onChange:e=>h(e.target.value),placeholder:`Optional description...`,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)(a,{className:`font-label text-xs font-medium text-outline`,children:`Project`}),(0,Q.jsxs)(d,{value:W||`__none__`,onValueChange:e=>{ee(e===`__none__`?``:e),w([])},children:[(0,Q.jsx)(c,{"aria-label":`Project`,"data-testid":`job-project-select`,className:`bg-background border-control-border text-on-surface font-body text-sm min-h-8`,children:(0,Q.jsx)(s,{})}),(0,Q.jsxs)(l,{className:`bg-surface border-border`,children:[(0,Q.jsx)(u,{value:`__none__`,className:`font-body text-sm`,children:`None`}),r?.map(e=>(0,Q.jsx)(u,{value:e.id,className:`font-body text-sm`,children:e.name},e.id))]})]})]})]}),(0,Q.jsxs)(V,{steps:o,id:`execution`,children:[(0,Q.jsx)(Ce,{value:b,onChange:S}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(a,{className:`font-label text-xs font-medium text-outline`,children:`Working Dir`}),(0,Q.jsx)(x,{"aria-label":`Working directory`,value:H,onChange:e=>U(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:`grid grid-cols-1 gap-4 sm:grid-cols-3 md:col-span-2`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(a,{className:`font-label text-xs font-medium text-outline`,children:`Timeout (s)`}),(0,Q.jsx)(x,{"aria-label":`Timeout in seconds`,type:`number`,min:1,required:!0,value:A,onChange:e=>j(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)(a,{className:`font-label text-xs font-medium text-outline`,children:`Retries`}),(0,Q.jsx)(x,{"aria-label":`Maximum retries`,type:`number`,min:0,required:!0,value:M,onChange:e=>F(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)(a,{className:`font-label text-xs font-medium text-outline`,children:`Overlap`}),(0,Q.jsxs)(d,{value:I,onValueChange:e=>L(e),children:[(0,Q.jsx)(c,{"aria-label":`Overlap`,className:`bg-background border-control-border text-on-surface font-body text-sm min-h-8`,children:(0,Q.jsx)(s,{})}),(0,Q.jsx)(l,{className:`bg-surface border-border`,children:De.map(e=>(0,Q.jsx)(u,{value:e,className:`font-body text-sm`,children:e},e))})]})]})]})]}),(0,Q.jsxs)(V,{steps:o,id:`automation`,children:[(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2 md:col-span-2`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(a,{className:`font-label text-xs font-medium text-outline`,children:`Trigger`}),(0,Q.jsxs)(d,{value:T,onValueChange:e=>E(e),children:[(0,Q.jsx)(c,{"aria-label":`Trigger type`,"data-testid":`job-trigger-type`,className:`bg-background border-control-border text-on-surface font-body text-sm min-h-8`,children:(0,Q.jsx)(s,{})}),(0,Q.jsx)(l,{className:`bg-surface border-border`,children:$.map(e=>(0,Q.jsx)(u,{value:e,"data-testid":`job-trigger-${e}`,className:`font-body text-sm`,children:e},e))})]})]}),T===`webhook`&&(0,Q.jsx)(`div`,{className:`sm:col-span-2`,children:(0,Q.jsx)(_e,{value:C,onChange:w,projectId:W||void 0})}),T===`cron`&&(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(a,{className:`font-label text-xs font-medium text-outline`,children:`Cron expression`}),(0,Q.jsx)(x,{required:!0,"aria-label":`Cron expression`,value:D,onChange:e=>k(e.target.value),placeholder:`*/5 * * * *`,className:`bg-background border-control-border text-on-surface font-mono text-xs`})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(a,{className:`font-label text-xs font-medium text-outline`,children:`Notify On`}),(0,Q.jsxs)(d,{value:R,onValueChange:e=>z(e),children:[(0,Q.jsx)(c,{"aria-label":`Notify on`,className:`bg-background border-control-border text-on-surface font-body text-sm min-h-8`,children:(0,Q.jsx)(s,{})}),(0,Q.jsx)(l,{className:`bg-surface border-border`,children:Oe.map(e=>(0,Q.jsx)(u,{value:e,className:`font-body text-sm`,children:e},e))})]})]}),(0,Q.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm md:col-span-2`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,"data-testid":`job-create-enabled`,checked:K,onChange:e=>te(e.target.checked),className:`size-4 accent-primary`}),`Enable this job immediately`]}),(0,Q.jsx)(`p`,{className:`text-xs text-outline md:col-span-2`,children:`Created disabled unless you enable it above.`})]}),(0,Q.jsx)(`div`,{className:`md:col-span-2`,children:G.error&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-error`,children:G.error.message})}),o.error&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-error`,children:o.error})]}),(0,Q.jsxs)(_,{className:`work-form-footer`,children:[(0,Q.jsx)(i,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`form-cancel`,onClick:e,className:`font-label text-xs text-outline`,children:`Cancel`}),(0,Q.jsx)(P,{steps:o,busy:G.isPending,children:(0,Q.jsx)(i,{"data-testid":`job-submit`,type:`submit`,size:`sm`,disabled:G.isPending,className:`font-label text-xs bg-primary text-primary-foreground hover:bg-primary/90`,children:G.isPending?`Creating...`:T===`webhook`?`Create job`:`Create`})})]})]})})]})})}function je({job:e,open:t,onClose:n}){let r=y([{id:`details`,label:`Details`},{id:`execution`,label:`Execution`},{id:`automation`,label:`Automation`}],t),[o,f]=(0,Z.useState)(e.name),[p,m]=(0,Z.useState)(e.description??``),[h,b]=(0,Z.useState)(e.action??{type:`command`,command:e.command}),[S,C]=(0,Z.useState)(e.webhooks??[]),[w,T]=(0,Z.useState)(e.trigger_type),[E,D]=(0,Z.useState)(e.cron_expr??``),[k,A]=(0,Z.useState)(String(e.timeout_secs)),[j,M]=(0,Z.useState)(String(e.max_retries)),[N,F]=(0,Z.useState)(e.overlap),[I,L]=(0,Z.useState)(e.notify_on),[R,z]=(0,Z.useState)(e.enabled),H=Y(),U=(t,i=n)=>{if(t.preventDefault(),w===`webhook`&&!S.length){r.invalid(`automation`,`Select at least one webhook for this trigger.`);return}if(!o.trim()||!Se(h))return;let a={id:e.id,name:o.trim(),description:p.trim(),action:h,webhooks:w===`webhook`?S:[],trigger_type:w,cron_expr:w===`cron`&&E.trim()||void 0,timeout_secs:Number.parseInt(k,10)||void 0,max_retries:Number.parseInt(j,10),overlap:N,notify_on:I,enabled:R};H.mutate(a,{onSuccess:i})};return(0,Q.jsx)(B,{open:t,onClose:n,busy:H.isPending,dirty:JSON.stringify([o,p,h,S,w,E,k,j,N,I,R])!==JSON.stringify([e.name,e.description??``,e.action??{type:`command`,command:e.command},e.webhooks??[],e.trigger_type,e.cron_expr??``,String(e.timeout_secs),String(e.max_retries),e.overlap,e.notify_on,e.enabled]),children:(t,n)=>(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(g,{children:(0,Q.jsx)(v,{className:`font-headline text-sm font-medium text-on-surface`,children:`Edit job`})}),(0,Q.jsx)(`form`,{noValidate:!0,ref:r.form,id:`edit-job-form`,onSubmit:e=>r.submit(e,()=>U(e,n)),className:`min-h-0`,children:(0,Q.jsxs)(O,{steps:r,children:[(0,Q.jsxs)(`div`,{className:`work-form-body space-y-4`,children:[(0,Q.jsxs)(V,{steps:r,id:`details`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(a,{className:`font-label text-xs font-medium text-outline`,children:`Name *`}),(0,Q.jsx)(x,{required:!0,"aria-label":`Name`,value:o,onChange:e=>f(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)(a,{className:`font-label text-xs font-medium text-outline`,children:`Description`}),(0,Q.jsx)(x,{"aria-label":`Description`,value:p,onChange:e=>m(e.target.value),className:`bg-background border-control-border text-on-surface font-body text-sm`})]})]}),(0,Q.jsxs)(V,{steps:r,id:`execution`,children:[(0,Q.jsx)(Ce,{value:h,onChange:b}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-3 md:col-span-2`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(a,{className:`font-label text-xs font-medium text-outline`,children:`Timeout (s)`}),(0,Q.jsx)(x,{"aria-label":`Timeout in seconds`,type:`number`,min:1,required:!0,value:k,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)(a,{className:`font-label text-xs font-medium text-outline`,children:`Retries`}),(0,Q.jsx)(x,{"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)(a,{className:`font-label text-xs font-medium text-outline`,children:`Overlap`}),(0,Q.jsxs)(d,{value:N,onValueChange:e=>F(e),children:[(0,Q.jsx)(c,{"aria-label":`Overlap`,className:`bg-background border-control-border text-on-surface font-body text-sm min-h-8`,children:(0,Q.jsx)(s,{})}),(0,Q.jsx)(l,{className:`bg-surface border-border`,children:De.map(e=>(0,Q.jsx)(u,{value:e,className:`font-body text-sm`,children:e},e))})]})]})]})]}),(0,Q.jsxs)(V,{steps:r,id:`automation`,children:[(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2 md:col-span-2`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(a,{className:`font-label text-xs font-medium text-outline`,children:`Trigger`}),(0,Q.jsxs)(d,{value:w,onValueChange:e=>T(e),children:[(0,Q.jsx)(c,{"aria-label":`Trigger type`,"data-testid":`job-trigger-type`,className:`bg-background border-control-border text-on-surface font-body text-sm min-h-8`,children:(0,Q.jsx)(s,{})}),(0,Q.jsx)(l,{className:`bg-surface border-border`,children:$.map(e=>(0,Q.jsx)(u,{value:e,"data-testid":`job-trigger-${e}`,className:`font-body text-sm`,children:e},e))})]})]}),w===`webhook`&&(0,Q.jsx)(`div`,{className:`sm:col-span-2`,children:(0,Q.jsx)(_e,{value:S,onChange:C,projectId:e.project_id??void 0})}),w===`cron`&&(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(a,{className:`font-label text-xs font-medium text-outline`,children:`Cron expression`}),(0,Q.jsx)(x,{required:!0,"aria-label":`Cron expression`,value:E,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:`space-y-1.5`,children:[(0,Q.jsx)(a,{className:`font-label text-xs font-medium text-outline`,children:`Notify On`}),(0,Q.jsxs)(d,{value:I,onValueChange:e=>L(e),children:[(0,Q.jsx)(c,{"aria-label":`Notify on`,className:`bg-background border-control-border text-on-surface font-body text-sm min-h-8`,children:(0,Q.jsx)(s,{})}),(0,Q.jsx)(l,{className:`bg-surface border-border`,children:Oe.map(e=>(0,Q.jsx)(u,{value:e,className:`font-body text-sm`,children:e},e))})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(a,{className:`font-label text-xs font-medium text-outline`,children:`Enabled`}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>z(!R),className:`w-full min-h-11 rounded-md flex items-center justify-center border font-label text-xs font-medium transition-colors ${R?`bg-surface-highest text-on-surface border-border`:`bg-background text-outline border-border`}`,children:R?`● Enabled`:`○ Disabled`})]})]}),(0,Q.jsx)(`div`,{className:`md:col-span-2`,children:H.error&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-error`,children:H.error.message})}),r.error&&(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-error`,children:r.error})]}),(0,Q.jsxs)(_,{className:`work-form-footer`,children:[(0,Q.jsx)(i,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`form-cancel`,onClick:t,className:`font-label text-xs text-outline`,children:`Cancel`}),(0,Q.jsx)(P,{steps:r,busy:H.isPending,children:(0,Q.jsx)(i,{"data-testid":`job-edit-submit`,form:`edit-job-form`,type:`submit`,size:`sm`,disabled:H.isPending,className:`font-label text-xs bg-primary text-primary-foreground hover:bg-primary/90`,children:H.isPending?`Saving...`:`Save`})})]})]})})]})})}export{ke as default};
|