orc-ai 0.1.47 → 0.1.49
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 +2 -2
- package/dist/index.js +568 -521
- package/dist/skills/orc-platform/references/setup.md +2 -2
- package/dist/web/apple-touch-icon.png +0 -0
- package/dist/web/assets/{Agents-DD4xAdLQ.js → Agents-C8dJX8px.js} +3 -3
- package/dist/web/assets/{Attention-V6qCS20I.js → Attention-BHYo8Lwr.js} +2 -2
- package/dist/web/assets/{Audit-bBVclx9F.js → Audit-CS_DZkbJ.js} +1 -1
- package/dist/web/assets/ConfirmDialog-CrSa87VF.js +1 -0
- package/dist/web/assets/Dashboard-V813oIhq.js +1 -0
- package/dist/web/assets/{DocumentWorkspace-PsD0kzUF.js → DocumentWorkspace-CNyVQTjg.js} +1 -1
- package/dist/web/assets/EmptyState-Ctm7L70B.js +1 -0
- package/dist/web/assets/ErrorState-BPTepwiG.js +1 -0
- package/dist/web/assets/{FileEditor-RVlQIVWn.js → FileEditor-Dh29_xCL.js} +1 -1
- package/dist/web/assets/JobWebhooks-TvAY8p1V.js +1 -0
- package/dist/web/assets/{Jobs-DjI_YMAA.js → Jobs-C5ggSs2T.js} +3 -3
- package/dist/web/assets/{Knowledge-DMAOn0iH.js → Knowledge-BpiN3iVE.js} +3 -3
- package/dist/web/assets/{PackageCatalog-X1ZZB-P7.js → PackageCatalog-B1U3vfhW.js} +5 -5
- package/dist/web/assets/{Pager-CMh30dp4.js → Pager-ClYYU9et.js} +1 -1
- package/dist/web/assets/PriorityBadge-BW-A50LE.js +1 -0
- package/dist/web/assets/Projects-DRao5Qpk.js +3 -0
- package/dist/web/assets/ResumeActions-DHTOr6GQ.js +11 -0
- package/dist/web/assets/{Rules-BNiDiUnr.js → Rules-DGKsAbTf.js} +2 -2
- package/dist/web/assets/{Sessions-N3CCkXrg.js → Sessions-CWHU6sYy.js} +3 -3
- package/dist/web/assets/Settings-yW1S2q4F.js +30 -0
- package/dist/web/assets/Skills-BwdXE5nT.js +16 -0
- package/dist/web/assets/SourceEditor-ft02z20v.js +43 -0
- package/dist/web/assets/StatusBadge-C5G1fdZh.js +1 -0
- package/dist/web/assets/TaskDetailSheet-fUSHPFB-.js +11 -0
- package/dist/web/assets/{Tasks-wCQWVIFY.js → Tasks-uRqvmLz7.js} +9 -9
- package/dist/web/assets/Terminals-W5nszLI1.js +120 -0
- package/dist/web/assets/ViewHeader-DXR0ZaMO.js +1 -0
- package/dist/web/assets/Webhooks-lXLoKWdt.js +1 -0
- package/dist/web/assets/{abnfDiagram-VCTEODGH-D6z8wrMR.js → abnfDiagram-VCTEODGH-K8P_VxLi.js} +1 -1
- package/dist/web/assets/{arc-BG4KWrJo.js → arc-BOl9BKfD.js} +1 -1
- package/dist/web/assets/{architectureDiagram-5GKGNRK7-Cl_LN0pI.js → architectureDiagram-5GKGNRK7-DIZ15fO5.js} +2 -2
- package/dist/web/assets/{blockDiagram-I7D4REHJ-DDcSWANX.js → blockDiagram-I7D4REHJ-DMrufypV.js} +1 -1
- package/dist/web/assets/{c4Diagram-7LVT6UL2-1TklobpM.js → c4Diagram-7LVT6UL2-BUUxjwvU.js} +1 -1
- package/dist/web/assets/channel-CQFNQIhG.js +1 -0
- package/dist/web/assets/{chunk-2Q5K7J3B-1ZXhRK9s.js → chunk-2Q5K7J3B-wRIxA2_q.js} +1 -1
- package/dist/web/assets/{chunk-5VM5RSS4--PtYqixL.js → chunk-5VM5RSS4-B6lAVcgQ.js} +1 -1
- package/dist/web/assets/{chunk-F27PBJKO-CnodLCYk.js → chunk-F27PBJKO-DVuei-Pl.js} +1 -1
- package/dist/web/assets/{chunk-IMKFNOWR-Dtujfpt3.js → chunk-IMKFNOWR-CwyogA-y.js} +1 -1
- package/dist/web/assets/{chunk-JWPE2WC7-BhzEb4oh.js → chunk-JWPE2WC7-zdsOarNZ.js} +1 -1
- package/dist/web/assets/{chunk-POPQ4Y6H-CCRH8Odz.js → chunk-POPQ4Y6H-D3ieeKih.js} +1 -1
- package/dist/web/assets/{chunk-SVP7TREG-DvO1oor5.js → chunk-SVP7TREG-CmiQdvOH.js} +1 -1
- package/dist/web/assets/{chunk-TICWLB2K-HSsE-7e0.js → chunk-TICWLB2K-CieIpfOy.js} +1 -1
- package/dist/web/assets/{chunk-XXDRQBXY-CyZDfwNW.js → chunk-XXDRQBXY-BoTHwisB.js} +1 -1
- package/dist/web/assets/classDiagram-ZZMXUADV-B5yD90Df.js +1 -0
- package/dist/web/assets/classDiagram-v2-VYDZK3BY-B5yD90Df.js +1 -0
- package/dist/web/assets/{cose-bilkent-JH36ORCC-COSptbUK.js → cose-bilkent-JH36ORCC-CtGsuuTW.js} +1 -1
- package/dist/web/assets/{cynefin-OW5HDTMX-BjeQd0nx.js → cynefin-OW5HDTMX-vMXgcpgg.js} +1 -1
- package/dist/web/assets/{cynefinDiagram-5FMLGOSQ-D2tfpg5R.js → cynefinDiagram-5FMLGOSQ-kMbm5D7e.js} +1 -1
- package/dist/web/assets/{dagre-GXQ25YYZ-LPFS53FJ.js → dagre-GXQ25YYZ-xmoviGlr.js} +1 -1
- package/dist/web/assets/{diagram-S7CK7UJ4-CJfymrr7.js → diagram-S7CK7UJ4-CguQzzXs.js} +1 -1
- package/dist/web/assets/{diagram-UQ7AKVKN-BxKvn9Ur.js → diagram-UQ7AKVKN-CMX0u7Gf.js} +1 -1
- package/dist/web/assets/{diagram-VSXAHHWV-Nqep4NOh.js → diagram-VSXAHHWV-cuhv3Fvj.js} +1 -1
- package/dist/web/assets/{diagram-VX7I27RA-DLNoOSxD.js → diagram-VX7I27RA-Bp_JbX0e.js} +1 -1
- package/dist/web/assets/{diagram-Z3DM3KII-CY3P-ZPA.js → diagram-Z3DM3KII-oZ6jRSCd.js} +1 -1
- package/dist/web/assets/{download-zED8Kwne.js → download-UgMvjBjR.js} +1 -1
- package/dist/web/assets/{ebnfDiagram-PWID7BFC-ChViZVtc.js → ebnfDiagram-PWID7BFC-DbxnEjb0.js} +1 -1
- package/dist/web/assets/{erDiagram-RLTQ6QDP-ul1XVJVK.js → erDiagram-RLTQ6QDP-Cl5kXPho.js} +1 -1
- package/dist/web/assets/{flowDiagram-HODETNUW-CP6v5LZZ.js → flowDiagram-HODETNUW-DueO0Ju6.js} +1 -1
- package/dist/web/assets/{folder-open-BUB_WGMS.js → folder-open-DojCP5NP.js} +1 -1
- package/dist/web/assets/{ganttDiagram-EL5Y4UJY-DL4TffYj.js → ganttDiagram-EL5Y4UJY-DNjT4iVH.js} +4 -4
- package/dist/web/assets/{gitGraphDiagram-WWUBYQGX-D6vY0fsS.js → gitGraphDiagram-WWUBYQGX-B4aUQ9gY.js} +1 -1
- package/dist/web/assets/{highlighted-body-KPVGNVTW-Cu3NJ2kc.js → highlighted-body-KPVGNVTW-gt1u8RcC.js} +1 -1
- package/dist/web/assets/index-C_jtMgr7.js +412 -0
- package/dist/web/assets/index-CyjfnRiI.css +1 -0
- package/dist/web/assets/{infoDiagram-27XIBGKW-BlFz7M9s.js → infoDiagram-27XIBGKW-CWcOvNAB.js} +1 -1
- package/dist/web/assets/{ishikawaDiagram-5VMMS53U-DmwD3lCC.js → ishikawaDiagram-5VMMS53U-ccIPCUs4.js} +1 -1
- package/dist/web/assets/{journeyDiagram-3NMN7TZE-S4Kc25zO.js → journeyDiagram-3NMN7TZE-rRe3uTLu.js} +1 -1
- package/dist/web/assets/{kanban-definition-UXKFOSKX-CjO1NhtQ.js → kanban-definition-UXKFOSKX-tAKCWntJ.js} +1 -1
- package/dist/web/assets/{layout-Dq9Y2uvt.js → layout-7xCiQ5Mn.js} +1 -1
- package/dist/web/assets/{linear-nLdM3nNe.js → linear-WCNhc07o.js} +1 -1
- package/dist/web/assets/{list-CE13IgiY.js → list-BL4eRkIg.js} +1 -1
- package/dist/web/assets/{mermaid-HWGCJPDP-pjgtNVt2.js → mermaid-HWGCJPDP-C8QwWdo5.js} +6 -6
- package/dist/web/assets/{mindmap-definition-YA3MSWOX-DsxpW-uk.js → mindmap-definition-YA3MSWOX-Cj5-j6a7.js} +1 -1
- package/dist/web/assets/{pegDiagram-XKGWAZYB-DOKdX_Ft.js → pegDiagram-XKGWAZYB-BYB3oVZ_.js} +1 -1
- package/dist/web/assets/{pencil-CKDsHvse.js → pencil-gxvh59uO.js} +1 -1
- package/dist/web/assets/{pieDiagram-E7YTZNPT-iifNLjuz.js → pieDiagram-E7YTZNPT-CSbpzXas.js} +1 -1
- package/dist/web/assets/{quadrantDiagram-AXDQQJYC-Ca9EdnrG.js → quadrantDiagram-AXDQQJYC-DKTP6jS5.js} +1 -1
- package/dist/web/assets/{railroadDiagram-O6MQD6OU-DNcc2r4p.js → railroadDiagram-O6MQD6OU-Ct8aPeLX.js} +1 -1
- package/dist/web/assets/{refresh-cw-CBpDF1Q6.js → refresh-cw-BQRdbjy6.js} +1 -1
- package/dist/web/assets/{requirementDiagram-BXWQKSXE-Bo2W4Z-S.js → requirementDiagram-BXWQKSXE-B9hH69zu.js} +1 -1
- package/dist/web/assets/{sankeyDiagram-P5KCCOFB-BX_lnGu7.js → sankeyDiagram-P5KCCOFB-CDqNONxU.js} +1 -1
- package/dist/web/assets/{save-BK4gikTj.js → save-CYoz3QKB.js} +1 -1
- package/dist/web/assets/scroll-area-CU4DGUBA.js +1 -0
- package/dist/web/assets/{sequenceDiagram-WJ2MYXX4-pXgbZI8i.js → sequenceDiagram-WJ2MYXX4-BF77J63J.js} +1 -1
- package/dist/web/assets/{sizeCapture-INFHLROL-Cc-w7K4o.js → sizeCapture-INFHLROL-Dpubco_U.js} +1 -1
- package/dist/web/assets/{stateDiagram-D77RDMKH-BRg29_UM.js → stateDiagram-D77RDMKH-CzslKEYw.js} +1 -1
- package/dist/web/assets/stateDiagram-v2-MP3YSRHH-DKbNjyV-.js +1 -0
- package/dist/web/assets/{swimlanes-42K2YHIH-D1YPvrQr.js → swimlanes-42K2YHIH-bD_tUjo6.js} +1 -1
- package/dist/web/assets/swimlanesDiagram-VR7AAH4N-0wAluWQF.js +8 -0
- package/dist/web/assets/table-D3N_5Wee.js +1 -0
- package/dist/web/assets/tabs-CSlEXoxD.js +1 -0
- package/dist/web/assets/{timeline-definition-24CTP7MA-CvilnfxW.js → timeline-definition-24CTP7MA-owGoHn8z.js} +1 -1
- package/dist/web/assets/trash-2-D3Ey4I09.js +6 -0
- package/dist/web/assets/{upload-BKVutGgF.js → upload-DhVOCWST.js} +1 -1
- package/dist/web/assets/useDetailRoute-j9nlwack.js +1 -0
- package/dist/web/assets/{useJobs-DSLKgV8L.js → useJobs-Dcl-Vim3.js} +1 -1
- package/dist/web/assets/{useKnowledge-BbtBJLNm.js → useKnowledge-gIjk0_I1.js} +1 -1
- package/dist/web/assets/useListSelection-CSQd_Hmx.js +1 -0
- package/dist/web/assets/{useMemories-CPw6917_.js → useMemories-B8Zpz0Qz.js} +1 -1
- package/dist/web/assets/useProjectScope-Dk0mjyHf.js +1 -0
- package/dist/web/assets/useSessions-BrdK-12R.js +1 -0
- package/dist/web/assets/{vennDiagram-4TSXK5OY-yNMm3LJf.js → vennDiagram-4TSXK5OY-D0_6bldW.js} +1 -1
- package/dist/web/assets/view-params-Bm1Qf6KC.js +1 -0
- package/dist/web/assets/{wardleyDiagram-VM6X3IG4-CMCWNcNe.js → wardleyDiagram-VM6X3IG4-D9GbTBKy.js} +1 -1
- package/dist/web/assets/{xychartDiagram-S5SC5T6Z-CMMtcXgw.js → xychartDiagram-S5SC5T6Z-BFqPF2Hl.js} +1 -1
- package/dist/web/badge-96.png +0 -0
- package/dist/web/icon-192.png +0 -0
- package/dist/web/icon-512.png +0 -0
- package/dist/web/icon-maskable-512.png +0 -0
- package/dist/web/index.html +9 -2
- package/dist/web/manifest.webmanifest +36 -0
- package/dist/web/sw.js +123 -0
- package/package.json +1 -1
- package/dist/checksums.txt +0 -5
- package/dist/web/assets/Dashboard-CIh2K0FF.js +0 -1
- package/dist/web/assets/JobWebhooks-CoFraeFc.js +0 -1
- package/dist/web/assets/Settings-C_-DKk-Q.js +0 -20
- package/dist/web/assets/Skills-BpRge1yJ.js +0 -16
- package/dist/web/assets/SourceEditor-DcZduN5g.js +0 -14
- package/dist/web/assets/Terminals-BX77_gra.js +0 -120
- package/dist/web/assets/Webhooks-2tiGvHyx.js +0 -1
- package/dist/web/assets/channel-6li7uxlb.js +0 -1
- package/dist/web/assets/classDiagram-ZZMXUADV-DQx2YVEE.js +0 -1
- package/dist/web/assets/classDiagram-v2-VYDZK3BY-DQx2YVEE.js +0 -1
- package/dist/web/assets/index-CVKguVuJ.js +0 -468
- package/dist/web/assets/index-yWuNUmdj.css +0 -1
- package/dist/web/assets/scroll-area-BrMwE434.js +0 -1
- package/dist/web/assets/stateDiagram-v2-MP3YSRHH-IRoE1WuW.js +0 -1
- package/dist/web/assets/swimlanesDiagram-VR7AAH4N-C2iXhtwv.js +0 -8
- package/dist/web/assets/useProjectScope-Gvzzt8hR.js +0 -1
|
@@ -97,8 +97,8 @@ environment. Protocol output belongs on stdout and diagnostics on stderr. For
|
|
|
97
97
|
HTTP MCP use `<origin>/mcp` and the configured auth header; do not append `/api`
|
|
98
98
|
to that MCP endpoint. Preserve other MCP servers when editing client config.
|
|
99
99
|
|
|
100
|
-
|
|
101
|
-
`/mcp?mode=meta`
|
|
100
|
+
Stdio `orc mcp` defaults to meta mode; pass `--mode full` to list every domain
|
|
101
|
+
tool directly. HTTP `/mcp` defaults to full; `/mcp?mode=meta` matches stdio. Meta mode exposes `tool_search`, `tool_describe`, `tool_invoke`:
|
|
102
102
|
search by intent, describe unknown arguments, then invoke the selected tool.
|
|
103
103
|
Reach `context` and other named tools through `tool_invoke` in meta mode.
|
|
104
104
|
Connectors, loaded skills and installed hooks do not establish equal enforcement
|
|
Binary file
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as b,j as e,
|
|
1
|
+
import{r as b,j as e,m as J,n as X,o as Z,p as M,I,B as k,W as B,O as ee,a as te,u as Y,b as T,L as ae,a7 as ne,a8 as se,a9 as re,aa as ie,ab as oe,ac as de,D as U,d as D}from"./index-C_jtMgr7.js";import{p as le,i as q}from"./public-api-BvD4z7ja.js";import{C as ce}from"./ConfirmDialog-CrSa87VF.js";import{E as G}from"./ErrorState-BPTepwiG.js";import{V as ue}from"./ViewHeader-DXR0ZaMO.js";import{u as me}from"./useDetailRoute-j9nlwack.js";import{u as W}from"./view-params-Bm1Qf6KC.js";const z={specialist:`---
|
|
2
2
|
name: Specialist
|
|
3
3
|
description: Describe when to use this specialist
|
|
4
4
|
---
|
|
@@ -25,10 +25,10 @@ tools:
|
|
|
25
25
|
---
|
|
26
26
|
|
|
27
27
|
Implement the requested change, preserve unrelated work, and run relevant checks. Report the result and any remaining issues.
|
|
28
|
-
`};function
|
|
28
|
+
`};function ge(r){const a=le(r,{stringKeys:!0});if(a.errors.length)throw new Error(a.errors[0].message);if(a.warnings.length)throw new Error(a.warnings[0].message);if(!q(a.contents))throw new Error("YAML configuration must be a mapping.");const n=a.toJS({maxAliasCount:100});if(!n||typeof n!="object"||Array.isArray(n))throw new Error("YAML configuration must be a mapping.");return JSON.stringify(n),{document:a,fields:n}}function L(r){const a=r.replace(/^\uFEFF/,"").match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n([\s\S]*))?$/);if(!a)throw new Error("Add YAML configuration between --- lines, followed by instructions.");return{...ge(a[1]),body:a[2]??"",newline:r.includes(`\r
|
|
29
29
|
`)?`\r
|
|
30
30
|
`:`
|
|
31
31
|
`,bom:r.startsWith("\uFEFF")?"\uFEFF":""}}function H(r,a,n){const o=L(r);n===void 0?o.document.delete(a):o.document.set(a,n);const u=o.document.toString().trimEnd().replace(/\n/g,o.newline);return`${o.bom}---${o.newline}${u}${o.newline}---${o.newline}${o.body}`}function he(r,a){var o;const n=(o=r.match(/^((?:\uFEFF)?---\r?\n[\s\S]*?\r?\n---)(?:\r?\n[\s\S]*)?$/))==null?void 0:o[1];if(!n)throw new Error("Missing YAML configuration.");return`${n}${r.includes(`\r
|
|
32
32
|
`)?`\r
|
|
33
33
|
`:`
|
|
34
|
-
`}${a}`}function W(r){const a=r.tools;if(a===void 0)return[];if(typeof a=="string")return a.split(/[\s,]+/).filter(Boolean).map(n=>({name:n,allowed:!0}));if(Array.isArray(a)&&a.every(n=>typeof n=="string"))return a.map(n=>({name:n,allowed:!0}));if(a&&typeof a=="object"&&!Array.isArray(a))return Object.entries(a).map(([n,o])=>{if(typeof o!="boolean")throw new Error(`Tool "${n}" must be true or false.`);return{name:n,allowed:o}});throw new Error("Tools must be a mapping of names to true/false, a list, or a string.")}function pe(r,a){const n=L(r);q(n.document.get("tools",!0))||n.document.set("tools",{});const o=n.document.get("tools",!0);if(q(o))for(const{name:u}of W(n.fields))a.some(C=>C.name===u)||n.document.deleteIn(["tools",u]);for(const u of a)n.document.setIn(["tools",u.name],u.allowed);return`${n.bom}---${n.newline}${n.document.toString().trimEnd().replace(/\n/g,n.newline)}${n.newline}---${n.newline}${n.body}`}function P(r){return W(r).map(a=>({...a,key:crypto.randomUUID()}))}function V({agent:r,pending:a,error:n,onSave:o}){var v,S;const[u,C]=b.useState((r==null?void 0:r.id)??""),[g,l]=b.useState((r==null?void 0:r.raw)??z.specialist),[d,p]=b.useState("fields"),[f,E]=b.useState(()=>r?P(r.fields):[]),[c,A]=b.useState(),x=b.useMemo(()=>{try{return{value:L(g),error:void 0}}catch(t){return{value:void 0,error:t.message}}},[g]),m=(v=x.value)==null?void 0:v.fields;let h;f.some(t=>!t.name.trim())?h="Enter a name for every tool.":new Set(f.map(t=>t.name.trim())).size!==f.length&&(h="Tool names must be unique.");const R=r?"Save changes":"Create agent";function w(t){E(t),t.every(i=>i.name.trim())&&new Set(t.map(i=>i.name.trim())).size===t.length&&l(pe(g,t.map(i=>({...i,name:i.name.trim()}))))}function N(){if(A(void 0),d==="fields"){if(h)return;p("source");return}try{const t=L(g);for(const i of["name","description","model","color"])if(t.fields[i]!==void 0&&typeof t.fields[i]!="string")throw new Error(`${i} must be a string to edit it in the form.`);E(P(t.fields)),p("fields")}catch(t){A(t.message)}}return e.jsxs(J,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsx(X,{children:e.jsx(Z,{children:r?`Edit ${r.name}`:"New shared agent"})}),e.jsxs("form",{className:"space-y-4",onSubmit:t=>{t.preventDefault(),o(u,g)},children:[e.jsxs("fieldset",{disabled:a,className:"space-y-4",children:[!r&&e.jsxs(e.Fragment,{children:[e.jsx(M,{htmlFor:"agent-template",children:"Starting template"}),e.jsxs("select",{id:"agent-template","data-testid":"agent-template",className:"w-full border rounded-sm p-2 bg-surface",defaultValue:"specialist",onChange:t=>{const i=z[t.target.value];l(i),E(P(L(i).fields)),A(void 0)},children:[e.jsx("option",{value:"specialist",children:"General specialist"}),e.jsx("option",{value:"reviewer",children:"Reviewer"}),e.jsx("option",{value:"builder",children:"Builder"})]})]}),e.jsx(M,{htmlFor:"agent-id",children:"Agent ID"}),e.jsx(B,{id:"agent-id","data-testid":"agent-id-input",value:u,disabled:!!r,onChange:t=>C(t.target.value),placeholder:"security-review"}),e.jsx(k,{type:"button",variant:"outline","data-testid":"agent-editor-mode",onClick:N,disabled:d==="fields"&&!!h,children:d==="fields"?"Edit YAML + Markdown":"Edit fields"}),d==="source"?e.jsxs(e.Fragment,{children:[e.jsx(M,{htmlFor:"agent-definition",children:"YAML configuration + Markdown instructions"}),e.jsx(I,{id:"agent-definition",testId:"agent-content-input",path:"agent.agent.md",readOnly:a,height:400,value:g,onChange:t=>{l(t),A(void 0)}})]}):m&&e.jsxs(e.Fragment,{children:[[["name","Name"],["description","Description"],["model","Model (optional)"],["color","Color (optional)"]].map(([t,i])=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(M,{htmlFor:`agent-${t}`,children:i}),e.jsx(B,{id:`agent-${t}`,"data-testid":`agent-${t}-input`,value:typeof m[t]=="string"?m[t]:"",onChange:y=>l(H(g,t,y.target.value||(t==="description"?"":void 0)))})]},t)),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx("input",{"data-testid":"agent-custom-tools",type:"checkbox",checked:m.tools!==void 0,onChange:t=>{E([]),l(H(g,"tools",t.target.checked?{}:void 0))}})," ","Customize tool access"]}),e.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."}),m.tools!==void 0&&e.jsxs(e.Fragment,{children:[f.map((t,i)=>e.jsxs("div",{"data-testid":"agent-tool-row",className:"flex items-center gap-2",children:[e.jsx(B,{"data-testid":"agent-tool-name","aria-label":`Tool ${i+1} name`,value:t.name,list:"agent-tool-suggestions",onChange:y=>w(f.map((j,$)=>$===i?{...j,name:y.target.value}:j))}),e.jsxs("label",{className:"flex items-center gap-1 text-sm",children:[e.jsx("input",{"data-testid":"agent-tool-allowed",type:"checkbox",checked:t.allowed,onChange:y=>w(f.map((j,$)=>$===i?{...j,allowed:y.target.checked}:j))})," ","Allowed"]}),e.jsx(k,{"data-testid":"agent-tool-remove",type:"button",variant:"outline",onClick:()=>w(f.filter((y,j)=>j!==i)),children:"Remove"})]},t.key)),e.jsx("datalist",{id:"agent-tool-suggestions",children:["Read","Grep","Glob","Edit","Write","Bash"].map(t=>e.jsx("option",{value:t},t))}),e.jsx(k,{"data-testid":"agent-tool-add",type:"button",variant:"outline",onClick:()=>w([...f,{key:crypto.randomUUID(),name:"",allowed:!0}]),children:"Add tool"})]})]}),e.jsx(M,{htmlFor:"agent-instructions",children:"Instructions"}),e.jsx(I,{id:"agent-instructions",testId:"agent-instructions-input",path:"instructions.md",readOnly:a,height:240,value:((S=x.value)==null?void 0:S.body)??"",onChange:t=>l(he(g,t))}),e.jsx("p",{className:"text-xs text-outline",children:"Use YAML + Markdown to edit handoffs and additional configuration. Custom fields are preserved."})]})]}),(n||x.error||c||d==="fields"&&h)&&e.jsx("p",{"data-testid":"agent-editor-error",role:"alert",className:"text-destructive",children:n||x.error||c||h}),e.jsx(k,{"data-testid":"agent-submit",type:"submit",disabled:a||!u.trim()||!g.trim()||!!x.error||d==="fields"&&!!h,children:a?"Saving...":R})]})]})}function ve({embedded:r=!1}){var i,y,j,$,O,Q,Y;const a=ee(),n=new URLSearchParams(a.search).get("project")??"all",[o,u]=K("editorMode","read",["read","edit","split"]),[C,g]=K("agentQuery",""),l=te(),d=U({queryKey:["agents"],queryFn:()=>D.agents.list()}),{selectedId:p,openDetail:f,closeDetail:E}=ae(r?"/packages/agents":"/agents","agentId"),c=U({queryKey:["agent",p],queryFn:()=>D.agents.get(p),enabled:!!p}),[A,x]=b.useState(!1),[m,h]=b.useState(),[R,w]=b.useState(!1),N=T({mutationFn:D.agents.create,onSuccess:()=>{l.invalidateQueries({queryKey:["agents"]}),x(!1)}}),v=T({mutationFn:D.agents.delete,onSuccess:()=>{w(!1),E(),l.invalidateQueries({queryKey:["agents"]}),l.invalidateQueries({queryKey:["agent-packages"]}),l.invalidateQueries({queryKey:["agent"]})}}),S=T({mutationFn:({profile:s,content:F})=>D.agents.update(s.id,{content:F,expectedRaw:s.raw,expectedPath:s.path}),onSuccess:s=>{l.setQueryData(["agent",s.id],s),l.invalidateQueries({queryKey:["agents"]}),l.invalidateQueries({queryKey:["agent-packages"]}),h(void 0)}});if(d.error)return e.jsx(G,{message:d.error.message,onRetry:()=>void d.refetch()});const t=(((i=d.data)==null?void 0:i.agents)??[]).filter(s=>`${s.name} ${s.id} ${s.description}`.toLowerCase().includes(C.toLowerCase()));return e.jsxs("div",{className:"space-y-5",children:[r?e.jsxs("div",{className:"flex flex-wrap justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-medium",children:"Agent definitions"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage specialist instructions, models and tools. Add them to APM packages for reuse."})]}),e.jsx(k,{"data-testid":"new-agent-button",onClick:()=>{N.reset(),x(!0)},children:"New agent"})]}):e.jsx(ne,{title:"Agents",meta:`${((y=d.data)==null?void 0:y.agents.length)??0} shared profiles`,action:e.jsx("div",{className:"flex flex-wrap gap-2",children:e.jsx(k,{"data-testid":"new-agent-button",onClick:()=>{N.reset(),x(!0)},children:"New agent"})})}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Shared specialist definitions for every connected coding agent."," ",e.jsx("a",{className:"text-primary underline",href:"https://microsoft.github.io/apm/producer/author-primitives/instructions-and-agents/",target:"_blank",rel:"noreferrer",children:"APM agent format"})]}),!r&&e.jsx(se,{to:re("/packages",n,a.search),"data-testid":"agents-packages-link",className:"text-primary underline",children:"Manage packages and reusable launch setups"}),(((j=d.data)==null?void 0:j.broken)??[]).map(s=>e.jsxs("p",{role:"alert",className:"text-destructive",children:[s.path,": ",s.error]},s.path)),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(B,{className:"min-w-[180px] max-w-lg flex-1","aria-label":"Find an agent",placeholder:"Find an agent by name or purpose…",value:C,onChange:s=>g(s.target.value,{replace:!0})}),C&&e.jsx(k,{variant:"ghost",onClick:()=>g(""),children:"Clear"})]}),e.jsxs("div",{className:"space-y-2",children:[d.isLoading&&e.jsx("p",{role:"status","data-testid":"page-loading",children:"Loading agents…"}),t.map(s=>e.jsxs("button",{type:"button","data-testid":"agent-row","data-agent-id":s.id,onClick:()=>f(s.id),className:"w-full text-left border-b border-outline-variant p-4 hover:bg-surface-low",children:[e.jsx("span",{className:"block break-words text-base font-medium",children:s.name}),e.jsxs("span",{className:"mt-1 block break-all text-xs text-muted-foreground",children:[s.id," · ",s.source]}),e.jsx("p",{className:"mt-2 break-words text-sm leading-relaxed text-muted-foreground",children:s.description})]},s.id)),!d.isLoading&&!t.length&&e.jsx("p",{"data-testid":"page-empty",className:"text-sm text-muted-foreground",children:C?"No agents match this search. Try another name or clear the filter.":"Create an agent or import specialists from Packages."})]}),e.jsx(ie,{open:!!p,onOpenChange:s=>!s&&E(),children:e.jsxs(oe,{children:[e.jsx(de,{children:e.jsx(le,{children:(($=c.data)==null?void 0:$.name)??"Agent profile"})}),e.jsx(ce,{children:c.error?e.jsx(G,{message:c.error.message,onRetry:()=>void c.refetch()}):c.data?e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm",children:c.data.description}),e.jsx(k,{"data-testid":"agent-edit",variant:"outline",onClick:async()=>{S.reset();const s=await c.refetch();s.data&&h(s.data)},children:"Edit agent"}),e.jsx(k,{"data-testid":"agent-delete",variant:"destructive",onClick:()=>{v.reset(),w(!0)},disabled:v.isPending,children:"Delete agent"}),v.error&&e.jsx("p",{"data-testid":"agent-delete-error",role:"alert",className:"text-destructive",children:v.error.message}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Use this profile in a flow agent node with ",e.jsxs("code",{children:['"agent": "',c.data.id,'"']})," ","and choose the coding backend independently."]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Model and tool restrictions depend on backend support. ORC refuses to launch when it cannot honor a declared restriction. Handoffs remain declarations; flow edges choose execution."}),e.jsx(I,{path:"metadata.json",value:JSON.stringify(c.data.fields,null,2),readOnly:!0,height:180,testId:"agent-fields"}),e.jsx(I,{path:"agent.agent.md",mode:o,onModeChange:u,value:c.data.raw,readOnly:!0,height:400,testId:"agent-content"})]}):e.jsx("p",{children:"Loading..."})})]})}),e.jsx(ue,{open:R,title:`Delete ${((O=c.data)==null?void 0:O.name)??"agent"}?`,description:`This permanently deletes the agent definition "${p}". Other agents and package resources are kept. Flows referencing this agent will need another profile.`,isPending:v.isPending,onCancel:()=>!v.isPending&&w(!1),onConfirm:()=>{p&&v.mutate(p,{onError:()=>w(!1)})}}),e.jsx(_,{open:A,onOpenChange:s=>!N.isPending&&x(s),children:A&&e.jsx(V,{pending:N.isPending,error:(Q=N.error)==null?void 0:Q.message,onSave:(s,F)=>N.mutate({id:s,content:F})})}),e.jsx(_,{open:!!m,onOpenChange:s=>!s&&!S.isPending&&h(void 0),children:m&&e.jsx(V,{agent:m,pending:S.isPending,error:(Y=S.error)==null?void 0:Y.message,onSave:(s,F)=>S.mutate({profile:m,content:F})},m.id)})]})}export{ve as default};
|
|
34
|
+
`}${a}`}function _(r){const a=r.tools;if(a===void 0)return[];if(typeof a=="string")return a.split(/[\s,]+/).filter(Boolean).map(n=>({name:n,allowed:!0}));if(Array.isArray(a)&&a.every(n=>typeof n=="string"))return a.map(n=>({name:n,allowed:!0}));if(a&&typeof a=="object"&&!Array.isArray(a))return Object.entries(a).map(([n,o])=>{if(typeof o!="boolean")throw new Error(`Tool "${n}" must be true or false.`);return{name:n,allowed:o}});throw new Error("Tools must be a mapping of names to true/false, a list, or a string.")}function pe(r,a){const n=L(r);q(n.document.get("tools",!0))||n.document.set("tools",{});const o=n.document.get("tools",!0);if(q(o))for(const{name:u}of _(n.fields))a.some(C=>C.name===u)||n.document.deleteIn(["tools",u]);for(const u of a)n.document.setIn(["tools",u.name],u.allowed);return`${n.bom}---${n.newline}${n.document.toString().trimEnd().replace(/\n/g,n.newline)}${n.newline}---${n.newline}${n.body}`}function P(r){return _(r).map(a=>({...a,key:crypto.randomUUID()}))}function V({agent:r,pending:a,error:n,onSave:o}){var v,S;const[u,C]=b.useState((r==null?void 0:r.id)??""),[m,l]=b.useState((r==null?void 0:r.raw)??z.specialist),[d,p]=b.useState("fields"),[f,E]=b.useState(()=>r?P(r.fields):[]),[c,A]=b.useState(),x=b.useMemo(()=>{try{return{value:L(m),error:void 0}}catch(t){return{value:void 0,error:t.message}}},[m]),g=(v=x.value)==null?void 0:v.fields;let h;f.some(t=>!t.name.trim())?h="Enter a name for every tool.":new Set(f.map(t=>t.name.trim())).size!==f.length&&(h="Tool names must be unique.");const R=r?"Save changes":"Create agent";function w(t){E(t),t.every(i=>i.name.trim())&&new Set(t.map(i=>i.name.trim())).size===t.length&&l(pe(m,t.map(i=>({...i,name:i.name.trim()}))))}function N(){if(A(void 0),d==="fields"){if(h)return;p("source");return}try{const t=L(m);for(const i of["name","description","model","color"])if(t.fields[i]!==void 0&&typeof t.fields[i]!="string")throw new Error(`${i} must be a string to edit it in the form.`);E(P(t.fields)),p("fields")}catch(t){A(t.message)}}return e.jsxs(J,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsx(X,{children:e.jsx(Z,{children:r?`Edit ${r.name}`:"New shared agent"})}),e.jsxs("form",{className:"space-y-4",onSubmit:t=>{t.preventDefault(),o(u,m)},children:[e.jsxs("fieldset",{disabled:a,className:"space-y-4",children:[!r&&e.jsxs(e.Fragment,{children:[e.jsx(M,{htmlFor:"agent-template",children:"Starting template"}),e.jsxs("select",{id:"agent-template","data-testid":"agent-template",className:"w-full border rounded-sm p-2 bg-surface",defaultValue:"specialist",onChange:t=>{const i=z[t.target.value];l(i),E(P(L(i).fields)),A(void 0)},children:[e.jsx("option",{value:"specialist",children:"General specialist"}),e.jsx("option",{value:"reviewer",children:"Reviewer"}),e.jsx("option",{value:"builder",children:"Builder"})]})]}),e.jsx(M,{htmlFor:"agent-id",children:"Agent ID"}),e.jsx(I,{id:"agent-id","data-testid":"agent-id-input",value:u,disabled:!!r,onChange:t=>C(t.target.value),placeholder:"security-review"}),e.jsx(k,{type:"button",variant:"outline","data-testid":"agent-editor-mode",onClick:N,disabled:d==="fields"&&!!h,children:d==="fields"?"Edit YAML + Markdown":"Edit fields"}),d==="source"?e.jsxs(e.Fragment,{children:[e.jsx(M,{htmlFor:"agent-definition",children:"YAML configuration + Markdown instructions"}),e.jsx(B,{id:"agent-definition",testId:"agent-content-input",path:"agent.agent.md",readOnly:a,height:400,value:m,onChange:t=>{l(t),A(void 0)}})]}):g&&e.jsxs(e.Fragment,{children:[[["name","Name"],["description","Description"],["model","Model (optional)"],["color","Color (optional)"]].map(([t,i])=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(M,{htmlFor:`agent-${t}`,children:i}),e.jsx(I,{id:`agent-${t}`,"data-testid":`agent-${t}-input`,value:typeof g[t]=="string"?g[t]:"",onChange:y=>l(H(m,t,y.target.value||(t==="description"?"":void 0)))})]},t)),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx("input",{"data-testid":"agent-custom-tools",type:"checkbox",checked:g.tools!==void 0,onChange:t=>{E([]),l(H(m,"tools",t.target.checked?{}:void 0))}})," ","Customize tool access"]}),e.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."}),g.tools!==void 0&&e.jsxs(e.Fragment,{children:[f.map((t,i)=>e.jsxs("div",{"data-testid":"agent-tool-row",className:"flex items-center gap-2",children:[e.jsx(I,{"data-testid":"agent-tool-name","aria-label":`Tool ${i+1} name`,value:t.name,list:"agent-tool-suggestions",onChange:y=>w(f.map((j,F)=>F===i?{...j,name:y.target.value}:j))}),e.jsxs("label",{className:"flex items-center gap-1 text-sm",children:[e.jsx("input",{"data-testid":"agent-tool-allowed",type:"checkbox",checked:t.allowed,onChange:y=>w(f.map((j,F)=>F===i?{...j,allowed:y.target.checked}:j))})," ","Allowed"]}),e.jsx(k,{"data-testid":"agent-tool-remove",type:"button",variant:"outline",onClick:()=>w(f.filter((y,j)=>j!==i)),children:"Remove"})]},t.key)),e.jsx("datalist",{id:"agent-tool-suggestions",children:["Read","Grep","Glob","Edit","Write","Bash"].map(t=>e.jsx("option",{value:t},t))}),e.jsx(k,{"data-testid":"agent-tool-add",type:"button",variant:"outline",onClick:()=>w([...f,{key:crypto.randomUUID(),name:"",allowed:!0}]),children:"Add tool"})]})]}),e.jsx(M,{htmlFor:"agent-instructions",children:"Instructions"}),e.jsx(B,{id:"agent-instructions",testId:"agent-instructions-input",path:"instructions.md",readOnly:a,height:240,value:((S=x.value)==null?void 0:S.body)??"",onChange:t=>l(he(m,t))}),e.jsx("p",{className:"text-xs text-outline",children:"Use YAML + Markdown to edit handoffs and additional configuration. Custom fields are preserved."})]})]}),(n||x.error||c||d==="fields"&&h)&&e.jsx("p",{"data-testid":"agent-editor-error",role:"alert",className:"text-destructive",children:n||x.error||c||h}),e.jsx(k,{"data-testid":"agent-submit",type:"submit",disabled:a||!u.trim()||!m.trim()||!!x.error||d==="fields"&&!!h,children:a?"Saving...":R})]})]})}function ke({embedded:r=!1}){var i,y,j,F,O,Q,K;const a=ee(),n=new URLSearchParams(a.search).get("project")??"all",[o,u]=W("editorMode","read",["read","edit","split"]),[C,m]=W("agentQuery",""),l=te(),d=Y({queryKey:["agents"],queryFn:()=>D.agents.list()}),{selectedId:p,openDetail:f,closeDetail:E}=me(r?"/packages/agents":"/agents","agentId"),c=Y({queryKey:["agent",p],queryFn:()=>D.agents.get(p),enabled:!!p}),[A,x]=b.useState(!1),[g,h]=b.useState(),[R,w]=b.useState(!1),N=T({mutationFn:D.agents.create,onSuccess:()=>{l.invalidateQueries({queryKey:["agents"]}),x(!1)}}),v=T({mutationFn:D.agents.delete,onSuccess:()=>{w(!1),E(),l.invalidateQueries({queryKey:["agents"]}),l.invalidateQueries({queryKey:["agent-packages"]}),l.invalidateQueries({queryKey:["agent"]})}}),S=T({mutationFn:({profile:s,content:$})=>D.agents.update(s.id,{content:$,expectedRaw:s.raw,expectedPath:s.path}),onSuccess:s=>{l.setQueryData(["agent",s.id],s),l.invalidateQueries({queryKey:["agents"]}),l.invalidateQueries({queryKey:["agent-packages"]}),h(void 0)}});if(d.error)return e.jsx(G,{message:d.error.message,onRetry:()=>void d.refetch()});const t=(((i=d.data)==null?void 0:i.agents)??[]).filter(s=>`${s.name} ${s.id} ${s.description}`.toLowerCase().includes(C.toLowerCase()));return e.jsxs("div",{className:"space-y-5",children:[r?e.jsxs("div",{className:"flex flex-wrap justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-medium",children:"Agent definitions"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage specialist instructions, models and tools. Add them to APM packages for reuse."})]}),e.jsx(k,{"data-testid":"new-agent-button",onClick:()=>{N.reset(),x(!0)},children:"New agent"})]}):e.jsx(ue,{title:"Agents",meta:`${((y=d.data)==null?void 0:y.agents.length)??0} shared profiles`,action:e.jsx("div",{className:"flex flex-wrap gap-2",children:e.jsx(k,{"data-testid":"new-agent-button",onClick:()=>{N.reset(),x(!0)},children:"New agent"})})}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Shared specialist definitions for every connected coding agent."," ",e.jsx("a",{className:"text-primary underline",href:"https://microsoft.github.io/apm/producer/author-primitives/instructions-and-agents/",target:"_blank",rel:"noreferrer",children:"APM agent format"})]}),!r&&e.jsx(ae,{to:ne("/packages",n,a.search),"data-testid":"agents-packages-link",className:"text-primary underline",children:"Manage packages and reusable launch setups"}),(((j=d.data)==null?void 0:j.broken)??[]).map(s=>e.jsxs("p",{role:"alert",className:"text-destructive",children:[s.path,": ",s.error]},s.path)),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(I,{className:"min-w-[180px] max-w-lg flex-1","aria-label":"Find an agent",placeholder:"Find an agent by name or purpose…",value:C,onChange:s=>m(s.target.value,{replace:!0})}),C&&e.jsx(k,{variant:"ghost",onClick:()=>m(""),children:"Clear"})]}),e.jsxs("div",{className:"space-y-2",children:[d.isLoading&&e.jsx("p",{role:"status","data-testid":"page-loading",children:"Loading agents…"}),t.map(s=>e.jsxs("button",{type:"button","data-testid":"agent-row","data-agent-id":s.id,onClick:()=>f(s.id),className:"w-full text-left border-b border-outline-variant p-4 hover:bg-surface-low",children:[e.jsx("span",{className:"block break-words text-base font-medium",children:s.name}),e.jsxs("span",{className:"mt-1 block break-all text-xs text-muted-foreground",children:[s.id," · ",s.source]}),e.jsx("p",{className:"mt-2 break-words text-sm leading-relaxed text-muted-foreground",children:s.description})]},s.id)),!d.isLoading&&!t.length&&e.jsx("p",{"data-testid":"page-empty",className:"text-sm text-muted-foreground",children:C?"No agents match this search. Try another name or clear the filter.":"Create an agent or import specialists from Packages."})]}),e.jsx(se,{open:!!p,onOpenChange:s=>!s&&E(),children:e.jsxs(re,{children:[e.jsx(ie,{children:e.jsx(oe,{children:((F=c.data)==null?void 0:F.name)??"Agent profile"})}),e.jsx(de,{children:c.error?e.jsx(G,{message:c.error.message,onRetry:()=>void c.refetch()}):c.data?e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm",children:c.data.description}),e.jsx(k,{"data-testid":"agent-edit",variant:"outline",onClick:async()=>{S.reset();const s=await c.refetch();s.data&&h(s.data)},children:"Edit agent"}),e.jsx(k,{"data-testid":"agent-delete",variant:"destructive",onClick:()=>{v.reset(),w(!0)},disabled:v.isPending,children:"Delete agent"}),v.error&&e.jsx("p",{"data-testid":"agent-delete-error",role:"alert",className:"text-destructive",children:v.error.message}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Use this profile in a flow agent node with ",e.jsxs("code",{children:['"agent": "',c.data.id,'"']})," ","and choose the coding backend independently."]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Model and tool restrictions depend on backend support. ORC refuses to launch when it cannot honor a declared restriction. Handoffs remain declarations; flow edges choose execution."}),e.jsx(B,{path:"metadata.json",value:JSON.stringify(c.data.fields,null,2),readOnly:!0,height:180,testId:"agent-fields"}),e.jsx(B,{path:"agent.agent.md",mode:o,onModeChange:u,value:c.data.raw,readOnly:!0,height:400,testId:"agent-content"})]}):e.jsx("p",{children:"Loading..."})})]})}),e.jsx(ce,{open:R,title:`Delete ${((O=c.data)==null?void 0:O.name)??"agent"}?`,description:`This permanently deletes the agent definition "${p}". Other agents and package resources are kept. Flows referencing this agent will need another profile.`,isPending:v.isPending,onCancel:()=>!v.isPending&&w(!1),onConfirm:()=>{p&&v.mutate(p,{onError:()=>w(!1)})}}),e.jsx(U,{open:A,onOpenChange:s=>!N.isPending&&x(s),children:A&&e.jsx(V,{pending:N.isPending,error:(Q=N.error)==null?void 0:Q.message,onSave:(s,$)=>N.mutate({id:s,content:$})})}),e.jsx(U,{open:!!g,onOpenChange:s=>!s&&!S.isPending&&h(void 0),children:g&&e.jsx(V,{agent:g,pending:S.isPending,error:(K=S.error)==null?void 0:K.message,onSave:(s,$)=>S.mutate({profile:g,content:$})},g.id)})]})}export{ke as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`,JSON.stringify(x&&Object.keys(x).length?x:a,null,2)]}),h&&t.jsxs("details",{className:"text-xs text-outline",children:[t.jsx("summary",{className:"cursor-pointer",children:"Full request details"}),t.jsx("pre",{className:"whitespace-pre-wrap break-all mt-2",children:JSON.stringify(a,null,2)})]}),t.jsx("p",{className:"text-outline",children:"Your approval lets this agent continue with its existing permissions."})]}),o&&e.input.kind==="question"&&t.jsxs("form",{className:"space-y-3",onSubmit:s=>{s.preventDefault(),n.mutate({kind:"question",answer:r,...i.length?{selected_choices:i}:{}})},children:[t.jsx("div",{className:"flex flex-wrap gap-2",children:e.input.choices.map(s=>t.jsxs(c,{variant:(e.input.multi_select?i.includes(s):r===s)?"default":"outline",type:"button",className:"h-auto min-h-9 flex-col items-start whitespace-normal text-left",disabled:n.isPending,"data-testid":`attention-choice-${s}`,onClick:()=>{if(e.input.multi_select){const j=i.includes(s)?i.filter(w=>w!==s):[...i,s];l(j),d(j.join(", "))}else d(s)},children:[t.jsx("span",{children:s}),Object.keys(e.input.choice_descriptions).includes(s)&&e.input.choice_descriptions[s]&&t.jsx("span",{className:"text-xs font-normal opacity-75 max-w-sm",children:e.input.choice_descriptions[s]})]},s))}),t.jsxs("label",{htmlFor:`answer-${e.id}`,className:"block text-sm space-y-2",children:[t.jsx("span",{children:"Your answer"}),t.jsx(
|
|
1
|
+
import{F as y,j as t,r as v,a as N,b,d as f,B as c,T as k}from"./index-C_jtMgr7.js";import{V as S}from"./ViewHeader-DXR0ZaMO.js";function A({request:e}){var g;const[r,d]=v.useState(""),[i,l]=v.useState([]),u=N(),n=b({mutationFn:s=>f.humanRequests.respond(e.id,e.version,s),onSettled:()=>u.invalidateQueries({queryKey:["human-requests"]})}),p=b({mutationFn:()=>f.humanRequests.cancel(e.id,e.version),onSettled:()=>u.invalidateQueries({queryKey:["human-requests"]})}),o=e.status==="pending",a=(g=e.input.action)==null?void 0:g.input,m=a!=null&&a.item&&typeof a.item=="object"?a.item:void 0,h=typeof(a==null?void 0:a.threadId)=="string",x=h?{...Object.fromEntries(Object.entries(a??{}).filter(([s])=>!["threadId","turnId","itemId","startedAtMs","item","availableDecisions","proposedExecpolicyAmendment","commandActions","kind"].includes(s))),...m!=null&&m.changes?{changes:m.changes}:{}}:a;return t.jsxs("article",{"data-testid":`attention-request-${e.id}`,className:"rounded-lg border border-border bg-surface p-5 space-y-4",children:[t.jsxs("div",{className:"flex flex-wrap justify-between gap-2 text-xs text-outline",children:[t.jsxs("span",{children:[e.input.kind==="question"?"Question":"Approval"," ·"," ",e.input.origin.backend]}),t.jsx("span",{children:o?"Waiting for you":e.status==="unavailable"?"Agent unavailable":"Answered · waiting for agent delivery"})]}),t.jsx("h2",{className:"text-base font-medium whitespace-pre-wrap",children:e.input.prompt}),t.jsxs("p",{className:"text-xs text-outline break-all",children:["Session ",e.input.origin.session_id]}),e.input.action&&t.jsxs("div",{className:"space-y-2 text-sm",children:[t.jsxs("p",{children:["Host: ",t.jsx("strong",{children:e.input.action.host})," · Folder: ",e.input.action.cwd]}),t.jsxs("pre",{"data-testid":"attention-action",className:"whitespace-pre-wrap break-all rounded-md bg-background p-3 text-xs",children:[e.input.action.tool,`
|
|
2
|
+
`,JSON.stringify(x&&Object.keys(x).length?x:a,null,2)]}),h&&t.jsxs("details",{className:"text-xs text-outline",children:[t.jsx("summary",{className:"cursor-pointer",children:"Full request details"}),t.jsx("pre",{className:"whitespace-pre-wrap break-all mt-2",children:JSON.stringify(a,null,2)})]}),t.jsx("p",{className:"text-outline",children:"Your approval lets this agent continue with its existing permissions."})]}),o&&e.input.kind==="question"&&t.jsxs("form",{className:"space-y-3",onSubmit:s=>{s.preventDefault(),n.mutate({kind:"question",answer:r,...i.length?{selected_choices:i}:{}})},children:[t.jsx("div",{className:"flex flex-wrap gap-2",children:e.input.choices.map(s=>t.jsxs(c,{variant:(e.input.multi_select?i.includes(s):r===s)?"default":"outline",type:"button",className:"h-auto min-h-9 flex-col items-start whitespace-normal text-left",disabled:n.isPending,"data-testid":`attention-choice-${s}`,onClick:()=>{if(e.input.multi_select){const j=i.includes(s)?i.filter(w=>w!==s):[...i,s];l(j),d(j.join(", "))}else d(s)},children:[t.jsx("span",{children:s}),Object.keys(e.input.choice_descriptions).includes(s)&&e.input.choice_descriptions[s]&&t.jsx("span",{className:"text-xs font-normal opacity-75 max-w-sm",children:e.input.choice_descriptions[s]})]},s))}),t.jsxs("label",{htmlFor:`answer-${e.id}`,className:"block text-sm space-y-2",children:[t.jsx("span",{children:"Your answer"}),t.jsx(k,{id:`answer-${e.id}`,"data-testid":"attention-answer",value:r,onChange:s=>{d(s.target.value),l([])},maxLength:16e3,disabled:n.isPending})]}),t.jsx(c,{"data-testid":"attention-send",type:"submit",disabled:!r.trim()||n.isPending,children:n.isPending?"Sending…":"Send answer"})]}),o&&e.input.kind==="approval"&&t.jsxs("div",{className:"flex gap-3",children:[t.jsx(c,{"data-testid":"attention-approve",disabled:n.isPending,onClick:()=>n.mutate({kind:"approval",approved:!0}),children:"Approve"}),t.jsx(c,{"data-testid":"attention-deny",variant:"outline",disabled:n.isPending,onClick:()=>n.mutate({kind:"approval",approved:!1}),children:"Deny"})]}),e.response&&t.jsx("p",{"data-testid":"attention-response",className:"text-sm whitespace-pre-wrap",children:e.response.kind==="question"?e.response.answer:e.response.approved?"Approved":"Denied"}),e.delivery_error&&t.jsx("p",{role:"status",className:"text-sm text-error",children:e.delivery_error}),(o||e.status==="unavailable")&&t.jsx(c,{"data-testid":"attention-cancel",variant:"ghost",disabled:n.isPending||p.isPending,onClick:()=>p.mutate(),children:o?"Cancel request":"Dismiss"}),p.error&&t.jsx("p",{role:"alert",children:p.error.message}),n.error&&t.jsx("p",{role:"alert","data-testid":"attention-error",className:"text-sm text-destructive",children:n.error.message})]})}function P(){var r,d,i;const e=y();return t.jsxs("div",{"data-testid":"attention-view",className:"max-w-4xl",children:[t.jsx(S,{title:"Attention needed",meta:"Questions and approvals from your agents"}),e.isLoading&&t.jsx("p",{role:"status",children:"Loading requests…"}),e.error&&t.jsx("p",{role:"alert",children:e.error.message}),((r=e.data)==null?void 0:r.length)===0&&t.jsx("p",{"data-testid":"attention-empty",className:"text-outline",children:"Nothing needs your attention."}),((d=e.data)==null?void 0:d.length)===100&&t.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."}),t.jsx("div",{className:"space-y-4",children:(i=e.data)==null?void 0:i.map(l=>t.jsx(A,{request:l},l.id))})]})}export{P as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{j as e,a8 as T,a9 as L,aa as P,ab as R,ac as $,S,ae as O,y as h,r as w,af as A,E as I,X as V}from"./index-C_jtMgr7.js";import{E as H}from"./EmptyState-Ctm7L70B.js";import{E as k}from"./ErrorState-BPTepwiG.js";import{P as z}from"./Pager-ClYYU9et.js";import{S as y}from"./scroll-area-CU4DGUBA.js";import{a as B,b as U}from"./useSessions-BrdK-12R.js";import{T as F,a as J,b as v,c,d as G,e as x}from"./table-D3N_5Wee.js";import{u as M}from"./useDetailRoute-j9nlwack.js";import{u as X}from"./view-params-Bm1Qf6KC.js";import{V as Y}from"./ViewHeader-DXR0ZaMO.js";import{u as Z}from"./useProjectScope-Dk0mjyHf.js";const q={file:"text-outline",task:"text-outline",decision:"text-outline",error:"text-error",git:"text-outline",rule:"text-outline",plan:"text-outline"},K="text-outline";function Q(n){return q[n]??K}function W({sessionId:n,open:a,onClose:r}){const{data:t,isLoading:u,error:p,refetch:j}=B(n??"");return e.jsx(T,{open:a,onOpenChange:o=>!o&&r(),children:e.jsxs(L,{side:"right",className:"w-[540px] max-w-[90vw]",children:[e.jsx(P,{children:e.jsx(R,{children:u?"Loading...":t?`${t.agent??"Session"} ${t.agent_version?`v${t.agent_version}`:""}`:"Session Detail"})}),e.jsxs($,{children:[e.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?e.jsx(k,{message:p.message,onRetry:()=>j()}):u?e.jsx("div",{className:"space-y-4",children:[...Array(4)].map((o,i)=>e.jsx(S,{className:"h-8 w-full bg-surface-highest"},i))}):t?e.jsxs("div",{className:"space-y-6",children:[t.summary&&e.jsx("div",{className:"font-body text-xs text-on-surface leading-relaxed",children:e.jsx(O,{children:t.summary})}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(h,{label:"ID",children:e.jsx("span",{className:"font-mono text-xs break-all",children:t.id})}),e.jsx(h,{label:"Project ID",children:t.project_id??"—"}),e.jsx(h,{label:"Job Run ID",children:t.job_run_id??"—"}),e.jsx(h,{label:"Tokens Used",children:t.tokens_used!=null?t.tokens_used.toLocaleString():"—"}),e.jsx(h,{label:"Created",children:new Date(t.created_at).toLocaleString()})]}),t.events.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"font-label text-xs font-medium text-outline mb-3",children:["Events (",t.events.length,")"]}),e.jsx(y,{className:"h-[300px]",children:e.jsx("div",{className:"space-y-1",children:[...t.events].sort((o,i)=>new Date(o.created_at).getTime()-new Date(i.created_at).getTime()).map(o=>e.jsx(ee,{event:o},o.id))})})]}),t.snapshot&&e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-xs font-medium text-outline mb-3",children:"Snapshot"}),e.jsx(y,{className:"h-[200px]",children:e.jsx("pre",{className:"font-mono text-xs text-on-surface-variant whitespace-pre-wrap break-words bg-background border-l border-border p-3",children:t.snapshot})})]})]}):e.jsx("div",{className:"font-body text-xs text-outline py-8 text-center",children:"Session not found"})]})]})})}function ee({event:n}){const[a,r]=w.useState(!1),t=n.data!=null;return e.jsxs("div",{className:"border-b border-border/65",children:[e.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:()=>t&&r(!a),"aria-expanded":t?a:void 0,children:[t?a?e.jsx(A,{size:10,className:"text-outline flex-shrink-0"}):e.jsx(I,{size:10,className:"text-outline flex-shrink-0"}):e.jsx("span",{className:"w-[10px] flex-shrink-0"}),e.jsx("span",{className:`inline-flex items-center px-1.5 py-0.5 text-[10px] font-label font-medium ${Q(n.type)}`,children:n.type}),e.jsx("span",{className:"flex-1 font-body text-xs text-outline truncate",children:se(n.data)}),e.jsx("span",{className:"font-label text-[10px] text-outline flex-shrink-0",children:new Date(n.created_at).toLocaleTimeString()})]}),a&&t&&e.jsx("div",{className:"px-3 pb-2",children:e.jsx("pre",{className:"font-mono text-xs text-on-surface-variant whitespace-pre-wrap break-words bg-background border-l border-border/65 p-2 max-h-48 overflow-auto",children:JSON.stringify(n.data,null,2)})})]})}function se(n){if(n==null)return"";if(typeof n=="string")return n;if(typeof n=="object"){const a=n;if(typeof a.path=="string")return a.path;if(typeof a.content=="string")return a.content.length>80?`${a.content.slice(0,80)}...`:a.content;if(typeof a.message=="string")return a.message;if(typeof a.summary=="string")return a.summary;const r=Object.keys(a);return r.length<=3?r.join(", "):`${r.length} fields`}return String(n)}const b=25,m="font-label text-xs font-medium text-outline";function te({projectId:n}){const a=V("sm"),[r,t]=X("order","desc",["asc","desc"]),[u,p]=w.useState({order:r,page:0}),j=u.order===r?u.page:0,o=s=>p({order:r,page:s}),{selectedId:i,openDetail:f,closeDetail:_}=M("/audit","sessionId"),{data:l,isLoading:E,error:N,refetch:D}=U({...n==="all"?{}:{project_id:n},limit:b,offset:j*b,order:r});if(N)return e.jsx(k,{message:N.message,onRetry:()=>D()});const g=(l==null?void 0:l.sessions)??[],C=(l==null?void 0:l.total)??0;return e.jsxs("section",{"data-testid":"logged-sessions",children:[e.jsx("div",{className:"mb-4 flex justify-end",children:e.jsxs("select",{"aria-label":"Sort audit by date","data-testid":"audit-date-sort",value:r,onChange:s=>{o(0),t(s.target.value)},className:"min-h-11 rounded-md border border-control-border bg-background px-3 text-sm text-on-surface",children:[e.jsx("option",{value:"desc",children:"Created: newest first"}),e.jsx("option",{value:"asc",children:"Created: oldest first"})]})}),E?e.jsx("div",{className:"space-y-2",children:[...Array(5)].map((s,d)=>e.jsx(S,{className:"h-10 w-full bg-surface-highest"},d))}):g.length===0?e.jsx(H,{message:"No audit records"}):e.jsxs("div",{className:"min-w-0 overflow-hidden",children:[a?e.jsxs(F,{children:[e.jsx(J,{children:e.jsxs(v,{className:"border-b border-border hover:bg-transparent",children:[e.jsx(c,{className:m,children:"Agent"}),e.jsx(c,{className:`${m} w-24`,children:"Version"}),e.jsx(c,{className:m,children:"Summary"}),e.jsx(c,{className:`${m} w-24`,children:"Project"}),e.jsx(c,{className:`${m} w-28`,children:"Tokens Used"}),e.jsx(c,{className:`${m} w-36`,children:"Created"})]})}),e.jsx(G,{children:g.map(s=>e.jsxs(v,{"data-testid":"session-row","data-session-id":s.id,className:"border-b border-border/65 hover:bg-surface-high cursor-pointer",onClick:()=>f(s.id),children:[e.jsx(x,{className:"font-label text-xs text-primary",children:e.jsx("button",{type:"button",className:"text-left font-medium hover:underline",onClick:d=>{d.stopPropagation(),f(s.id)},children:s.agent??"Session"})}),e.jsx(x,{className:"font-label text-xs text-outline",children:s.agent_version??"—"}),e.jsx(x,{className:"font-body text-xs text-on-surface-variant max-w-sm truncate",children:s.summary??"—"}),e.jsx(x,{className:"font-label text-xs text-outline",children:s.project_id?s.project_id.slice(-6):"—"}),e.jsx(x,{className:"font-label text-xs text-outline text-right",children:s.tokens_used!=null?s.tokens_used.toLocaleString():"—"}),e.jsx(x,{className:"font-label text-xs text-outline",children:new Date(s.created_at).toLocaleString()})]},s.id))})]}):e.jsx("div",{className:"divide-y divide-border",children:g.map(s=>{var d;return e.jsxs("article",{"data-testid":"session-row","data-session-id":s.id,className:"py-4 space-y-3",children:[e.jsx("button",{type:"button",className:"min-h-11 text-sm text-left font-medium text-primary break-words",onClick:()=>f(s.id),children:s.agent??"Session"}),e.jsx("p",{className:"text-sm leading-relaxed text-on-surface break-words",children:s.summary??"No summary recorded"}),e.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-2 text-xs text-outline",children:[e.jsxs("span",{children:["Version ",s.agent_version??"—"]}),e.jsxs("span",{children:[((d=s.tokens_used)==null?void 0:d.toLocaleString())??"—"," tokens"]}),e.jsx("span",{children:s.project_id?`Project ${s.project_id.slice(-6)}`:"Unassigned"}),e.jsx("span",{children:new Date(s.created_at).toLocaleString()})]})]},s.id)})}),e.jsx(z,{page:j,pageSize:b,total:C,onPage:o})]}),e.jsx(W,{sessionId:i,open:!!i,onClose:_})]})}function he({projectId:n}){const a=Z(n);return e.jsxs("div",{children:[e.jsx(Y,{title:"Audit"}),e.jsx("p",{className:"mb-4 text-sm text-outline",children:"Recorded summaries and events. Open Sessions to read conversations or resume a coding agent."}),e.jsx(te,{projectId:a},a)]})}export{he as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e,D as d,m,n as b,o as g,U as h,x as f,B as s}from"./index-C_jtMgr7.js";function j({open:a,onConfirm:o,onCancel:t,title:i,description:l,confirmLabel:n="Delete",variant:c="destructive",isPending:r}){return e.jsx(d,{open:a,onOpenChange:x=>!x&&t(),children:e.jsxs(m,{className:"bg-surface border-surface-highest max-w-sm",children:[e.jsxs(b,{children:[e.jsx(g,{className:"font-headline text-sm text-on-surface",children:i}),e.jsx(h,{className:"font-body text-xs text-outline mt-2",children:l})]}),e.jsxs(f,{className:"mt-4",children:[e.jsx(s,{"data-testid":"confirm-dialog-cancel",type:"button",variant:"ghost",size:"sm",onClick:t,className:"font-label text-xs text-outline",children:"Cancel"}),e.jsx(s,{"data-testid":"confirm-dialog-confirm",type:"button",size:"sm",onClick:o,disabled:r,className:c==="destructive"?"font-label text-xs bg-error/15 text-error border border-error/30 hover:bg-error/25":"font-label text-xs bg-tertiary/15 text-tertiary border border-tertiary/30 hover:bg-tertiary/25",children:r?"...":n})]})]})})}export{j as C};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{H as E,X as U,Y as V,e as H,M as I,j as t,S as J}from"./index-C_jtMgr7.js";import{E as Q}from"./ErrorState-BPTepwiG.js";import{P as T}from"./PriorityBadge-BW-A50LE.js";import{f as q,S,R as W}from"./ResumeActions-DHTOr6GQ.js";import{S as L}from"./StatusBadge-C5G1fdZh.js";import{T as z,a as O,b as $,c as h,d as X,e as p}from"./table-D3N_5Wee.js";import{u as Y}from"./useJobs-Dcl-Vim3.js";import{u as F}from"./useMemories-B8Zpz0Qz.js";import{u as G}from"./useProjectScope-Dk0mjyHf.js";import{u as K}from"./useSessions-BrdK-12R.js";function l(d,v){return d.isLoading?"…":d.error?"—":v}function os({projectId:d}){var f,_;const v=E(),a=G(d),D=U("sm"),i=s=>{const e=new URL(s,window.location.origin);e.searchParams.set("project",a),v({pathname:e.pathname,search:e.search,hash:e.hash})},o=a==="all"||a==="unassigned"?void 0:{project_id:a},c=V(o),{data:b,isLoading:P}=c,u=Y(o),{data:N}=u,m=F({project_id:o==null?void 0:o.project_id,limit:1},{enabled:a!=="unassigned"}),R=a==="unassigned"?0:((f=m.data)==null?void 0:f.total)??0,{data:n}=H(),j=K(!0),g=(j.data??[]).filter(s=>a==="all"||(a==="unassigned"?s.project_id===null:s.project_id===a)),w=a==="unassigned"?(N??[]).filter(s=>s.project_id===null):N??[],k=a==="unassigned"?(b??[]).filter(s=>s.project_id===null):b??[],r=k.reduce((s,e)=>(s[e.status]=(s[e.status]??0)+1,s),{}),y=[...k].sort((s,e)=>new Date(e.updated_at).getTime()-new Date(s.updated_at).getTime()).slice(0,8),x=w.filter(s=>s.enabled),A=a==="all"?"All Projects":a==="unassigned"?"Unassigned":((_=n==null?void 0:n.find(s=>s.id===a))==null?void 0:_.name)??"",M=[{label:"Doing",value:l(c,r.doing??0),sub:"in progress",path:"/tasks?view=table&status=doing"},{label:"Review",value:l(c,r.review??0),sub:"awaiting review",path:"/tasks?view=table&status=review"},{label:"Blocked",value:l(c,r.blocked??0),sub:"needs attention",path:"/tasks?view=table&status=blocked"},{label:"Todo",value:l(c,(r.todo??0)+(r.queued??0)),sub:"pending",path:"/tasks?view=board"},{label:"Done",value:l(c,r.done??0),sub:"completed",path:"/tasks?view=table&status=done"}],B=[{label:"Active jobs",value:l(u,x.length),sub:`of ${w.length} total`,path:"/jobs"},{label:"Memories",value:l(m,R),sub:"in this scope",path:I},{label:"Projects",value:(n??[]).filter(s=>s.status==="active").length,sub:"active across workspace",path:"/projects"}];return t.jsxs("div",{"data-activity-preview":!0,"data-testid":"activity-preview",className:"activity-preview",children:[t.jsxs("div",{className:"activity-heading",children:[t.jsxs("div",{children:[t.jsx("h1",{"data-testid":"view-title",children:"Activity"}),t.jsx("p",{"data-testid":"view-meta",children:A||"All projects"})]}),t.jsx("button",{type:"button",className:"activity-primary",onClick:()=>i("/tasks"),children:"View tasks"})]}),[c,u,m,j].some(s=>s.isLoading)&&t.jsx("p",{role:"status",className:"activity-muted mb-4",children:"Loading activity…"}),[{name:"Tasks",query:c},{name:"Jobs",query:u},{name:"Memories",query:m},{name:"Sessions",query:j}].filter(({query:s})=>s.error).map(({name:s,query:e})=>{var C;return t.jsx(Q,{message:`${s}: ${((C=e.error)==null?void 0:C.message)??"Could not load activity"}`,onRetry:()=>e.refetch()},s)}),t.jsx("section",{className:"activity-metrics","aria-label":"Task summary",children:M.map(s=>t.jsxs("button",{type:"button","data-testid":"stat-card","data-stat-label":s.label,className:"activity-metric",onClick:()=>i(s.path),children:[t.jsx("span",{className:"activity-metric-label",children:s.label}),t.jsx("span",{"data-testid":"stat-card-value",className:"activity-metric-value",children:s.value}),t.jsx("span",{className:"activity-metric-sub",children:s.sub})]},s.label))}),t.jsx("section",{className:"activity-resources","aria-label":"Workspace summary",children:B.map(s=>t.jsxs("button",{type:"button","data-testid":"stat-card","data-stat-label":s.label,onClick:()=>i(s.path),children:[t.jsx("span",{children:s.label}),t.jsx("span",{"data-testid":"stat-card-value",className:"activity-resource-value",children:s.value}),t.jsx("span",{className:"activity-resource-sub",children:s.sub})]},s.label))}),t.jsxs("section",{className:"activity-section",children:[t.jsxs("div",{className:"activity-section-heading",children:[t.jsx("h2",{children:"Recent tasks"}),t.jsx("button",{type:"button",className:"activity-text-action",onClick:()=>i("/tasks"),children:"View all"})]}),P?t.jsx("div",{className:"space-y-2",children:[0,1,2,3].map(s=>t.jsx(J,{className:"h-10 w-full"},s))}):y.length===0?t.jsx("p",{className:"activity-empty",children:"No tasks"}):D?t.jsxs(z,{className:"activity-task-table",children:[t.jsx(O,{children:t.jsxs($,{children:[t.jsx(h,{children:"Task"}),t.jsx(h,{className:"w-36",children:"Status"}),t.jsx(h,{className:"w-28",children:"Priority"}),t.jsx(h,{className:"w-28",children:"Updated"})]})}),t.jsx(X,{children:y.map(s=>t.jsxs($,{onClick:()=>i(`/tasks/${s.id}`),children:[t.jsx(p,{children:t.jsx("button",{type:"button",className:"activity-task-title",onClick:e=>{e.stopPropagation(),i(`/tasks/${s.id}`)},children:s.title})}),t.jsx(p,{children:t.jsx("span",{className:"activity-status","data-status":s.status,children:t.jsx(L,{status:s.status})})}),t.jsx(p,{children:t.jsx("span",{className:"activity-priority",children:t.jsx(T,{priority:s.priority})})}),t.jsx(p,{className:"activity-muted",children:new Date(s.updated_at).toLocaleDateString()})]},s.id))})]}):t.jsx("div",{className:"activity-task-list",children:y.map(s=>t.jsxs("article",{className:"activity-task-mobile",children:[t.jsx("button",{type:"button",className:"activity-task-title",onClick:()=>i(`/tasks/${s.id}`),children:s.title}),t.jsxs("div",{className:"activity-task-meta",children:[t.jsx("span",{className:"activity-status","data-status":s.status,children:t.jsx(L,{status:s.status})}),t.jsx("span",{className:"activity-priority",children:t.jsx(T,{priority:s.priority})}),t.jsx("span",{children:new Date(s.updated_at).toLocaleDateString()})]})]},s.id))})]}),t.jsxs("div",{className:"activity-secondary",children:[x.length>0&&t.jsxs("section",{className:"activity-section",children:[t.jsxs("div",{className:"activity-section-heading",children:[t.jsx("h2",{children:"Active jobs"}),t.jsx("button",{type:"button",className:"activity-text-action",onClick:()=>i("/jobs"),children:"View all"})]}),t.jsx("div",{className:"activity-row-list",children:x.slice(0,5).map(s=>t.jsxs("button",{type:"button",className:"activity-row",onClick:()=>i(`/jobs/${s.id}`),children:[t.jsxs("span",{className:"activity-row-heading",children:[t.jsx("span",{children:s.name}),t.jsx("span",{className:"activity-muted",children:s.trigger_type})]}),s.last_run_at&&t.jsxs("span",{className:"activity-row-description",children:["Last run ",new Date(s.last_run_at).toLocaleString()]})]},s.id))})]}),g.length>0&&t.jsxs("section",{className:"activity-section",children:[t.jsxs("div",{className:"activity-section-heading",children:[t.jsx("h2",{children:"Agent sessions"}),t.jsx("button",{type:"button",className:"activity-text-action",onClick:()=>i("/sessions"),children:"View all"})]}),t.jsx("div",{className:"activity-row-list",children:g.slice(0,5).map(s=>t.jsxs("div",{className:"activity-row",children:[t.jsxs("button",{type:"button",className:"w-full text-left","data-testid":"activity-session-link","data-session-id":s.id,onClick:()=>i(`/sessions?session=${encodeURIComponent(s.id)}`),children:[t.jsxs("span",{className:"activity-row-heading",children:[t.jsx("span",{children:s.name??s.agent}),t.jsx("span",{className:"activity-muted",children:q(s.last_activity_at)})]}),t.jsxs("span",{className:"activity-row-description inline-flex items-center gap-2",children:[t.jsx("span",{className:`size-1.5 rounded-full ${S[s.status].dot}`}),s.agent," · ",S[s.status].label,s.task?` · ${s.task.title}`:""]})]}),t.jsx(W,{session:s})]},s.id))})]})]}),a==="all"&&(n??[]).length>0&&t.jsxs("section",{className:"activity-section",children:[t.jsxs("div",{className:"activity-section-heading",children:[t.jsx("h2",{children:"Projects"}),t.jsx("button",{type:"button",className:"activity-text-action",onClick:()=>i("/projects"),children:"View all"})]}),t.jsx("div",{className:"activity-projects",children:(n??[]).filter(s=>s.status==="active").slice(0,6).map(s=>t.jsxs("button",{type:"button",className:"activity-row",onClick:()=>i(`/projects/${s.id}`),children:[t.jsx("span",{className:"activity-row-heading",children:s.name}),s.description&&t.jsx("span",{className:"activity-row-description",children:s.description})]},s.id))})]})]})}export{os as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{G as T,H as V,r as o,j as e,J as Y,B as g}from"./index-C_jtMgr7.js";const i=new Map,D=new Set;typeof window<"u"&&window.addEventListener("beforeunload",t=>{i.size&&(t.preventDefault(),t.returnValue="")});function W(t){return D.has(t)?!1:i.has(t)?window.confirm("Discard unsaved changes to this document?")?(i.delete(t),!0):!1:!0}function K({documentId:t,content:s,path:M,onSave:d,testId:N,wikiLinks:C,navigation:k,expanded:R,onExpandedChange:E,layout:F,pageTitle:q,hideFrontmatter:G}){const[H]=T(),J=V(),v=H.get("editorMode"),x=v==="edit"||v==="split"?v:"read",p=o.useRef(i.get(t)??{original:s,content:s}),[w,f]=o.useState(p.current.content),[u,j]=o.useState(p.current.original),[r,z]=o.useState(!1),[y,b]=o.useState(null),S=o.useRef(!1),l=o.useRef(p.current.content),c=w!==u;o.useEffect(()=>{i.has(t)||(f(s),l.current=s,j(s))},[s,t]);function O(a){l.current=a,f(a),a===u?i.delete(t):i.set(t,{original:u,content:a})}async function h(){if(!d||!c||S.current)return;S.current=!0,D.add(t),z(!0),b(null);const a=l.current;try{const n=await d(a,u),m=typeof n=="string"?n:a;j(m),l.current===a?(i.delete(t),l.current=m,f(m)):i.set(t,{original:m,content:l.current})}catch(n){b(n instanceof Error?n.message:"Could not save document")}finally{S.current=!1,D.delete(t),z(!1)}}function P(a){const n=new URLSearchParams(window.location.search);n.set("editorMode",a),n.toString()!==new URLSearchParams(window.location.search).toString()&&J({search:n.toString(),hash:window.location.hash})}function U(){W(t)&&(f(s),j(s),l.current=s,b(null))}const B=d?r?"Saving…":c?"Unsaved changes":"Saved":"Read-only",L=e.jsxs(e.Fragment,{children:[y&&e.jsxs("p",{role:"alert",className:"text-sm text-destructive",children:[y," Your draft has been kept."]}),c&&s!==u&&e.jsx("p",{role:"status",className:"text-sm text-outline",children:"The document changed elsewhere. Your draft is preserved; saving will check for conflicts."})]});return F==="page"?e.jsx("div",{className:"min-w-0","data-testid":"document-workspace",children:e.jsx(Y,{path:M,value:w,onChange:O,onSave:()=>void h(),readOnly:!d||r,testId:N,wikiLinks:C,initialMode:"read",mode:x,onModeChange:P,expanded:R,onExpandedChange:E,layout:"page",pageTitle:q,hideFrontmatter:G,notice:y||c&&s!==u?L:void 0,actions:(x!=="read"||c||r)&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"data-testid":"document-save-status",role:"status",className:"text-xs text-outline",children:B}),d&&(c||r)&&e.jsxs(e.Fragment,{children:[e.jsx(g,{type:"button",size:"sm",variant:"ghost","data-testid":"document-discard",disabled:r,onClick:U,children:"Discard"}),e.jsx(g,{type:"button",size:"sm","data-testid":"document-save",disabled:r,onClick:()=>void h(),children:"Save"})]})]})})}):e.jsx("div",{className:"min-w-0 space-y-3","data-testid":"document-workspace",children:e.jsx(Y,{path:M,value:w,onChange:O,onSave:()=>void h(),readOnly:!d||r,testId:N,wikiLinks:C,initialMode:"read",mode:x,onModeChange:P,expanded:R,onExpandedChange:E,layout:F,header:e.jsxs("div",{className:"space-y-2",children:[k&&e.jsx("div",{className:"mb-3 min-w-0",children:k}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{"data-testid":"document-save-status",role:"status",className:"min-w-0 flex-1 text-sm text-outline",children:B}),d&&e.jsxs(e.Fragment,{children:[e.jsx(g,{type:"button",variant:"ghost","data-testid":"document-discard",disabled:!c||r,onClick:U,children:"Discard changes"}),e.jsx(g,{type:"button","data-testid":"document-save",disabled:!c||r,onClick:()=>void h(),children:"Save changes"})]})]}),L]})})})}export{K as D,W as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./index-C_jtMgr7.js";function a({message:t="No data"}){return e.jsx("div",{"data-testid":"empty-state",className:"flex items-center justify-center py-16 text-outline font-body text-sm",children:t})}export{a as E};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e,B as s}from"./index-C_jtMgr7.js";function i({message:r,onRetry:t}){return e.jsxs("div",{"data-testid":"error-state",className:"flex flex-col items-center justify-center gap-3 px-4 py-16",children:[e.jsx("p",{role:"alert",className:"max-w-prose break-words text-center text-sm text-error",children:r}),t&&e.jsx(s,{"data-testid":"error-retry",variant:"outline",size:"sm",onClick:t,children:"Retry"})]})}export{i as E};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{G as U,r as t,a as V,j as n,V as K,J as $,W as A,d as P}from"./index-C_jtMgr7.js";import{S as G}from"./save-CYoz3QKB.js";const c=new Map;typeof window<"u"&&window.addEventListener("beforeunload",s=>{c.size!==0&&(s.preventDefault(),s.returnValue="")});function W({terminalId:s,path:i,content:u,readOnly:v,onDirty:w}){const[Q,z]=U(),p=Q.get("editorMode"),D=p==="read"||p==="split"?p:"edit",a=`${s}:${i}`,d=t.useRef(c.get(a)??{original:u,content:u}),o=t.useRef(d.current.original),l=t.useRef(d.current.content),[S,g]=t.useState(d.current.content!==d.current.original),[C,j]=t.useState(!1),[E,x]=t.useState(null),[R,b]=t.useState(d.current.content),k=V(),y=t.useRef(()=>{}),h=t.useRef(!1),m=t.useRef(!1),f=t.useRef(w);f.current=w;async function M(){if(h.current||v||l.current===o.current)return;h.current=!0,j(!0),x(null);const e=l.current;try{await P.git.saveFile(s,i,e,o.current),o.current=e;const r=l.current!==e;g(r),m.current&&f.current(r),r?c.set(a,{original:e,content:l.current}):c.delete(a),k.invalidateQueries({queryKey:["checkout-files",s,i]}),k.invalidateQueries({queryKey:["git",s]})}catch(r){x(r instanceof Error?r.message:"Could not save file")}finally{h.current=!1,j(!1)}}y.current=()=>void M(),t.useEffect(()=>(m.current=!0,f.current(d.current.content!==d.current.original),()=>{m.current=!1}),[]),t.useEffect(()=>{h.current||c.has(a)||u===o.current||(o.current=u,l.current=u,b(u),g(!1),m.current&&f.current(!1))},[u,a]);function N(e){l.current=e,b(e);const r=e!==o.current;g(r),f.current(r),r?c.set(a,{original:o.current,content:e}):c.delete(a)}function L(){window.confirm("Discard your edits and reload the file from disk?")&&P.git.files(s,i).then(e=>{if(e.content===null||e.binary||e.truncated)throw new Error("File is no longer editable");o.current=e.content,l.current=e.content,c.delete(a),b(e.content),g(!1),f.current(!1),x(null)}).catch(e=>x(e instanceof Error?e.message:"Could not reload file"))}const F=n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-surface-highest px-2 py-1",children:[n.jsxs("button",{type:"button","data-testid":"file-save",disabled:!S||C||v,onClick:()=>void M(),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:[n.jsx(G,{size:14}),C?"Saving…":"Save"]}),n.jsx("span",{"data-testid":"file-save-status",className:"min-w-0 flex-1 truncate text-sm text-on-surface-variant",children:v?"Read-only preview":S?"Unsaved changes":"Saved"})]}),E&&n.jsxs("div",{role:"alert",className:"shrink-0 border-b border-error/30 p-2 text-xs text-error",children:[E,n.jsx("button",{type:"button","data-testid":"file-reload",onClick:L,className:"ml-2 underline",children:"Reload from disk"})]})]});return n.jsxs("div",{className:"flex min-h-0 flex-1 flex-col","data-testid":"file-editor",children:[!K(i)&&F,n.jsx("div",{"data-testid":"file-preview",className:"min-h-0 flex-1 overflow-hidden",children:K(i)?n.jsx($,{path:i,value:R,onChange:N,onSave:()=>y.current(),readOnly:v,height:"100%",testId:"file-editor-input",header:F,mode:D,onModeChange:e=>z(r=>{const q=new URLSearchParams(r);return q.set("editorMode",e),q})}):n.jsx(A,{path:i,value:R,onChange:N,onSave:()=>y.current(),readOnly:v,height:"100%",testId:"file-editor-input"})})]})}export{W as FileEditor};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as S,a as f,b as v,d as j,r as h,j as e,B as b,p as w,I as _,L as k,ad as F}from"./index-C_jtMgr7.js";import{E as R}from"./ErrorState-BPTepwiG.js";import{a as $}from"./useJobs-Dcl-Vim3.js";function L(t){return S({queryKey:["webhooks",t],queryFn:()=>j.webhooks.list(t),select:s=>s.webhooks})}function D(t){return S({queryKey:["webhook-deliveries",t],queryFn:()=>j.webhooks.deliveries(t),select:s=>s.deliveries,enabled:!!t,refetchInterval:3e3})}function U(){const t=f();return v({mutationFn:s=>j.webhooks.create(s),onSuccess:()=>t.invalidateQueries({queryKey:["webhooks"]})})}function E(){const t=f();return v({mutationFn:({id:s,...a})=>j.webhooks.update(s,a),onSuccess:()=>t.invalidateQueries({queryKey:["webhooks"]})})}function K(){const t=f();return v({mutationFn:s=>j.webhooks.delete(s),onSuccess:()=>t.invalidateQueries({queryKey:["webhooks"]})})}function I(){return v({mutationFn:t=>j.webhooks.rotate(t)})}function P(t){return[...new Set(t.split(",").map(s=>s.trim()).filter(Boolean))]}function q(t,s,a){return new URL(`/webhooks/${encodeURIComponent(t)}`,new URL(s,a)).href}function z(t){return["localhost","127.0.0.1","[::1]"].includes(new URL(t).hostname)}function N({id:t,testId:s,value:a,onChange:i,placeholder:d}){const[n,r]=h.useState(a.join(", "));return e.jsx(_,{id:t,"data-testid":s,value:n,placeholder:d,onChange:l=>{r(l.target.value),i(l.target.value)}})}function J({projectId:t,onCreated:s}){const a=U(),[i,d]=h.useState(""),[n,r]=h.useState("github"),[l,m]=h.useState(null),u=h.useId();return l?e.jsxs("div",{"data-testid":"webhook-created",className:"space-y-3",children:[e.jsx(W,{hook:l,secret:l.secret}),e.jsx(b,{type:"button",variant:"outline","data-testid":"webhook-setup-done",onClick:()=>{s==null||s(l),m(null),d("")},children:"I've copied the setup details"})]}):e.jsxs("div",{className:"space-y-3","data-testid":"webhook-create-form",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(w,{htmlFor:`${u}-name`,children:"Webhook name"}),e.jsx(_,{id:`${u}-name`,"data-testid":"webhook-name",value:i,onChange:c=>d(c.target.value),maxLength:100,placeholder:"GitHub repository events"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(w,{htmlFor:`${u}-provider`,children:"Provider"}),e.jsxs("select",{id:`${u}-provider`,"data-testid":"webhook-provider",className:"w-full min-h-11 rounded-md border border-control-border bg-background px-3 text-sm",value:n,onChange:c=>r(c.target.value),children:[e.jsx("option",{value:"github",children:"GitHub"}),e.jsx("option",{value:"generic",children:"Other service (HMAC)"})]})]}),e.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."}),a.error&&e.jsx("p",{role:"alert",className:"text-sm text-error",children:a.error.message}),e.jsx(b,{type:"button","data-testid":"webhook-create",disabled:!i.trim()||a.isPending,onClick:()=>a.mutate({name:i.trim(),provider:n,project_id:t??null},{onSuccess:m}),children:a.isPending?"Creating...":"Create webhook"})]})}function A({value:t,onChange:s,projectId:a}){const{data:i,error:d,isLoading:n,refetch:r}=L(a),l=i==null?void 0:i.filter(o=>o.project_id===null||o.project_id===a),[m,u]=h.useState(!1);function c(o){t.some(p=>p.webhook_id===o)||s([...t,{webhook_id:o,events:[],actions:[]}])}function y(o,p,x){s(t.map(g=>g.webhook_id===o?{...g,[p]:P(x)}:g))}return e.jsxs("section",{className:"space-y-3 border-y border-border py-4","data-testid":"job-webhook-picker",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Which webhook should trigger this job?"}),d?e.jsx(R,{message:d.message,onRetry:()=>r()}):e.jsxs(e.Fragment,{children:[e.jsx(w,{htmlFor:"job-webhook-source",children:"Configured webhooks"}),e.jsxs("select",{id:"job-webhook-source","data-testid":"job-webhook-select",className:"w-full min-h-11 rounded-md border border-control-border bg-background px-3 text-sm",value:"",disabled:n,onChange:o=>{o.target.value&&c(o.target.value)},children:[e.jsx("option",{value:"",children:n?"Loading webhooks...":"Select an existing webhook"}),(l??[]).filter(o=>!t.some(p=>p.webhook_id===o.id)).map(o=>e.jsxs("option",{value:o.id,children:[o.name,o.enabled?"":" (disabled)"]},o.id))]}),!n&&!(l!=null&&l.length)&&e.jsx("p",{className:"text-xs text-outline",children:"No webhooks configured for this project yet. Create one below or on the Webhooks page."})]}),t.map(o=>{var p;return e.jsxs("div",{className:"space-y-2 border-t border-border pt-3","data-testid":"job-webhook-binding","data-webhook-id":o.webhook_id,children:[e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsx("span",{className:"text-sm font-medium",children:((p=l==null?void 0:l.find(x=>x.id===o.webhook_id))==null?void 0:p.name)??o.webhook_id}),e.jsx(b,{type:"button",variant:"ghost",size:"sm","data-testid":"job-webhook-remove",onClick:()=>s(t.filter(x=>x.webhook_id!==o.webhook_id)),children:"Disconnect"})]}),e.jsx(w,{htmlFor:`events-${o.webhook_id}`,children:"Events for this job"}),e.jsx(N,{id:`events-${o.webhook_id}`,testId:"webhook-events",value:o.events,onChange:x=>y(o.webhook_id,"events",x),placeholder:"pull_request, push (blank accepts all)"}),e.jsx(w,{htmlFor:`actions-${o.webhook_id}`,children:"Actions for this job (optional)"}),e.jsx(N,{id:`actions-${o.webhook_id}`,testId:"webhook-actions",value:o.actions,onChange:x=>y(o.webhook_id,"actions",x),placeholder:"opened, synchronize (blank accepts all)"})]},o.webhook_id)}),e.jsx(b,{type:"button",size:"sm",variant:"outline","data-testid":"webhook-add",onClick:()=>u(!m),children:m?"Close new webhook":"Create a webhook"}),m&&e.jsx(J,{projectId:a,onCreated:o=>{c(o.id),u(!1)}})]})}function Q({job:t}){const s=$(),[a,i]=h.useState(t.webhooks??[]);return e.jsxs("section",{className:"space-y-3","data-testid":"job-webhooks",children:[!t.enabled&&e.jsx("p",{className:"text-sm text-outline",children:"Job disabled. Configure connections now and enable it from Jobs when ready."}),e.jsx(A,{value:a,onChange:i,projectId:t.project_id??void 0}),s.error&&e.jsx("p",{role:"alert",className:"text-sm text-error",children:s.error.message}),e.jsx(b,{type:"button",size:"sm","data-testid":"job-webhooks-save",disabled:s.isPending,onClick:()=>s.mutate({id:t.id,webhooks:a,trigger_type:"webhook"}),children:"Save connections"}),s.isSuccess&&e.jsx("p",{role:"status",className:"text-xs text-outline",children:"Connections saved."}),e.jsx(k,{className:"inline-block text-sm underline",to:`/webhooks?project=${encodeURIComponent(t.project_id??"all")}`,children:"Manage configured webhooks and deliveries"})]})}function C({label:t,value:s,secret:a=!1}){const[i,d]=h.useState(!1),[n,r]=h.useState(!1);return e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-outline",children:t}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("code",{className:"min-w-0 flex-1 break-all text-xs","data-testid":a?"webhook-secret":"webhook-url",children:s}),e.jsx(b,{type:"button",size:"sm",variant:"outline","aria-label":`Copy ${t}`,onClick:async()=>{try{await navigator.clipboard.writeText(s),d(!0),r(!1)}catch{r(!0)}},children:i?"Copied":"Copy"})]}),n&&e.jsx("p",{role:"alert",className:"text-xs text-error",children:"Select and copy the value above; clipboard access is unavailable."})]})}function W({hook:t,secret:s}){const a=q(t.token,F(),window.location.origin);return e.jsxs("div",{className:"space-y-3","data-testid":"webhook-setup",children:[e.jsx(C,{label:"Payload URL",value:a}),z(a)&&e.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."}),s?e.jsxs(e.Fragment,{children:[e.jsx(C,{label:"Signing secret",value:s,secret:!0}),e.jsx("p",{className:"text-xs text-outline",children:"Copy the signing secret before leaving. It is shown once."})]}):e.jsx("p",{className:"text-xs text-outline",children:"The signing secret is hidden. Generate a replacement only if you need to reconnect the sender."}),t.provider==="github"?e.jsxs("ol",{className:"list-decimal space-y-1 pl-5 text-sm text-outline",children:[e.jsx("li",{children:"In your repository, open GitHub Settings - Webhooks - Add webhook."}),e.jsx("li",{children:"Paste the Payload URL, select application/json, and enter the signing secret."}),e.jsx("li",{children:"Select the events needed by your connected jobs. Each job has its own filters."}),e.jsx("li",{children:"Send an event and inspect Recent deliveries below."})]}):e.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 M({hook:t}){var u;const s=E(),a=I(),[i,d]=h.useState(!1),[n,r]=h.useState(!1),[l,m]=h.useState();return e.jsxs("article",{className:"space-y-3 border-b border-border pb-5","data-testid":"webhook-endpoint","data-webhook-id":t.id,children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("h3",{className:"text-sm font-medium",children:t.name}),e.jsxs("span",{className:"text-xs text-outline",children:[t.provider," - ",t.enabled?"Enabled":"Disabled"]}),e.jsx(b,{type:"button",variant:"outline",size:"sm",disabled:s.isPending,onClick:()=>s.mutate({id:t.id,enabled:!t.enabled}),children:t.enabled?"Disable":"Enable"})]}),e.jsxs("div",{className:"space-y-1","data-testid":"webhook-connected-jobs",children:[e.jsxs("p",{className:"text-xs text-outline",children:["Connected jobs (",t.subscriptions.length,")"]}),t.subscriptions.length?t.subscriptions.map(c=>e.jsxs("div",{className:"text-sm",children:[e.jsx(k,{className:"underline","data-testid":"webhook-job-link",to:`/jobs/${c.job_id}?project=all`,children:c.name}),e.jsxs("span",{className:"text-xs text-outline",children:[" ","- ",c.enabled?"Enabled":"Disabled","; events:"," ",c.events.join(", ")||"all","; actions: ",c.actions.join(", ")||"all"]})]},c.job_id)):e.jsx("p",{className:"text-sm text-outline",children:"No connected jobs. Select this webhook when creating or editing a job."})]}),e.jsx(W,{hook:t,secret:l}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(b,{type:"button",variant:"outline",size:"sm","data-testid":"webhook-deliveries-toggle",onClick:()=>d(!i),children:i?"Hide deliveries":"Recent deliveries"}),e.jsx(b,{type:"button",variant:"ghost",size:"sm",onClick:()=>r(!n),children:"New signing secret"})]}),n&&e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsx("p",{children:"The sender's existing secret will stop working. Update it after generating the replacement."}),e.jsx(b,{type:"button",variant:"outline",size:"sm",disabled:a.isPending,onClick:()=>a.mutate(t.id,{onSuccess:c=>{m(c.secret),r(!1)}}),children:"Generate replacement secret"})]}),(s.error||a.error)&&e.jsx("p",{role:"alert",className:"text-sm text-error",children:(u=s.error??a.error)==null?void 0:u.message}),i&&e.jsx(H,{id:t.id})]})}function H({id:t}){const{data:s,isLoading:a,error:i,refetch:d}=D(t);return e.jsxs("section",{className:"space-y-2","data-testid":"webhook-deliveries",children:[e.jsx("h4",{className:"text-sm font-medium",children:"Recent deliveries"}),i?e.jsx(R,{message:i.message,onRetry:()=>d()}):a?e.jsx("p",{role:"status",children:"Loading deliveries..."}):s!=null&&s.length?s.map(n=>e.jsxs("div",{className:"space-y-1 border-t border-border py-2 text-xs","data-testid":"webhook-delivery",children:[e.jsxs("div",{className:"flex flex-wrap justify-between gap-2",children:[e.jsxs("span",{children:[n.event,n.action?` / ${n.action}`:""]}),e.jsx("span",{children:n.status})]}),e.jsxs("p",{className:"text-outline",children:[n.repository," ",new Date(n.created_at).toLocaleString()]}),n.status==="ignored"&&e.jsx("p",{className:"text-outline",children:"No enabled connected job matched this event."}),n.error&&e.jsx("p",{className:"text-error",children:n.error}),n.runs.map(r=>e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsxs(k,{className:"underline",to:`/jobs/${r.job_id}?project=all`,children:["Job run: ",r.status]}),r.task_id&&e.jsx(k,{className:"underline",to:`/tasks/${r.task_id}?project=all`,children:"Created task"}),r.session_id&&e.jsx(k,{className:"underline",to:`/audit/${r.session_id}?project=all`,children:"Agent session"})]},r.job_run_id))]},n.id)):e.jsx("p",{className:"text-sm text-outline",children:"No events received yet. Register the endpoint with your provider, then send an event."})]})}export{Q as J,J as W,K as a,M as b,A as c,L as u};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import{c as ae,r as o,
|
|
1
|
+
import{c as ae,r as o,ak as ge,j as e,p as d,T as G,I as j,a8 as pe,a9 as fe,aa as je,ab as Ne,ac as ye,S as H,y as P,al as ve,B as g,af as ke,E as _e,L as Z,X as we,P as Se,e as Ce,D as ne,m as re,n as le,o as ie,q as V,s as q,t as M,v as W,w as B,x as oe}from"./index-C_jtMgr7.js";import{u as Te,B as De}from"./useListSelection-CSQd_Hmx.js";import{C as $e}from"./ConfirmDialog-CrSa87VF.js";import{E as Pe}from"./EmptyState-Ctm7L70B.js";import{E as U}from"./ErrorState-BPTepwiG.js";import{J as Ee,c as de}from"./JobWebhooks-TvAY8p1V.js";import{S as Re}from"./StatusBadge-C5G1fdZh.js";import{S as Je}from"./scroll-area-CU4DGUBA.js";import{b as ze,c as Ie,d as ce,a as Q,e as Le,u as Oe,f as Ae,g as Fe,h as Be}from"./useJobs-Dcl-Vim3.js";import{P as X}from"./pencil-gxvh59uO.js";import{T as Ve,a as qe,b as ee,c as L,d as Me,e as O}from"./table-D3N_5Wee.js";import{V as te}from"./ViewHeader-DXR0ZaMO.js";import{u as We}from"./useDetailRoute-j9nlwack.js";import{u as He}from"./useProjectScope-Dk0mjyHf.js";import{T as se}from"./trash-2-D3Ey4I09.js";/**
|
|
2
2
|
* @license lucide-react v1.27.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const Ue=[["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"}]],
|
|
6
|
+
*/const Ue=[["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"}]],K=ae("play",Ue);/**
|
|
7
7
|
* @license lucide-react v1.27.0 - ISC
|
|
8
8
|
*
|
|
9
9
|
* This source code is licensed under the ISC license.
|
|
10
10
|
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const Ye=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],Ge=ae("power",Ye);function Y(a){return a.type==="command"?!!a.command.trim():a.type==="agent"?!!(a.prompt.trim()&&a.backend.trim()):!!a.title.trim()}function me({value:a,onChange:c}){const n=o.useId(),{data:x}=ge();return e.jsxs("section",{className:"space-y-3 border-y border-border py-4","data-testid":"job-action-fields",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{htmlFor:`${n}-type`,children:"What should this job do?"}),e.jsxs("select",{id:`${n}-type`,"data-testid":"job-action-type",className:"w-full min-h-11 rounded-md border border-control-border bg-background px-3 text-sm",value:a.type,onChange:s=>{s.target.value==="command"&&c({type:"command",command:""}),s.target.value==="agent"&&c({type:"agent",backend:"codex-cli",prompt:"",auto_approve:!1}),s.target.value==="task"&&c({type:"task",title:"",body:"",start_automatically:!1})},children:[e.jsx("option",{value:"command",children:"Run command"}),e.jsx("option",{value:"agent",children:"Run agent"}),e.jsx("option",{value:"task",children:"Create task"})]})]}),a.type==="command"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{htmlFor:`${n}-command`,children:"Command"}),e.jsx(G,{id:`${n}-command`,"aria-label":"Command","data-testid":"job-command-input",value:a.command,onChange:s=>c({...a,command:s.target.value}),rows:3,placeholder:"bun run build",required:!0})]}),a.type==="agent"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{htmlFor:`${n}-backend`,children:"Agent backend"}),e.jsx(f,{id:`${n}-backend`,"data-testid":"job-agent-backend",value:a.backend,list:`${n}-backends`,onChange:s=>c({...a,backend:s.target.value}),required:!0}),e.jsx("datalist",{id:`${n}-backends`,children:x==null?void 0:x.backends.map(s=>e.jsx("option",{value:s.name,children:s.available?"Available":"Unavailable"},s.name))})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{htmlFor:`${n}-model`,children:"Model (optional)"}),e.jsx(f,{id:`${n}-model`,"data-testid":"job-agent-model",value:a.model??"",onChange:s=>c({...a,model:s.target.value||void 0})})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{htmlFor:`${n}-prompt`,children:"Instructions"}),e.jsx(G,{id:`${n}-prompt`,"data-testid":"job-agent-prompt",value:a.prompt,onChange:s=>c({...a,prompt:s.target.value}),required:!0,rows:4})]}),e.jsxs("label",{className:"flex min-h-11 items-center gap-2 text-sm",children:[e.jsx("input",{type:"checkbox",checked:a.auto_approve,onChange:s=>c({...a,auto_approve:s.target.checked})}),"Allow agent tools automatically"]}),e.jsx("p",{className:"text-xs text-outline",children:"Starts a tracked agent session. When automatic tool approval is off, permission requests are denied."})]}),a.type==="task"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{htmlFor:`${n}-title`,children:"Task title"}),e.jsx(f,{id:`${n}-title`,"data-testid":"job-task-title",value:a.title,onChange:s=>c({...a,title:s.target.value}),required:!0,maxLength:200})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{htmlFor:`${n}-body`,children:"Task instructions"}),e.jsx(G,{id:`${n}-body`,"data-testid":"job-task-body",value:a.body,onChange:s=>c({...a,body:s.target.value}),rows:4})]}),e.jsxs("label",{className:"flex min-h-11 items-center gap-2 text-sm",children:[e.jsx("input",{type:"checkbox","data-testid":"job-task-autostart",checked:a.start_automatically,onChange:s=>c({...a,start_automatically:s.target.checked})}),"Start the task flow automatically"]}),a.start_automatically&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{htmlFor:`${n}-flow`,children:"Flow (blank uses the configured default)"}),e.jsx(f,{id:`${n}-flow`,"data-testid":"job-task-flow",value:a.flow_name??"",onChange:s=>c({...a,flow_name:s.target.value||void 0})})]}),e.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 Xe({jobId:a,open:c,onClose:n,onEdit:x}){var T,k,$;const{data:s,isLoading:C,error:N,refetch:D}=Ae(a),{data:m,isLoading:p,error:y,refetch:u}=Fe(a),i=ce(),v=K(),[b,E]=o.useState(null);return e.jsx(pe,{open:c,onOpenChange:h=>!h&&n(),children:e.jsxs(je,{"data-testid":"job-detail-sheet",children:[e.jsxs(fe,{children:[e.jsx(Ne,{children:(s==null?void 0:s.name)??"Job details"}),(s==null?void 0:s.description)&&e.jsx("p",{className:"font-body text-xs text-outline mt-1",children:s.description})]}),e.jsx(ye,{children:N?e.jsx(H,{message:N.message,onRetry:()=>D()}):C?e.jsx("div",{className:"space-y-3",children:[...Array(6)].map((h,_)=>e.jsx(U,{className:"h-8 w-full bg-surface-highest"},_))}):s?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx(P,{label:"Action",children:e.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:((T=s.action)==null?void 0:T.type)==="agent"?`Run agent (${s.action.backend}): ${s.action.prompt}`:((k=s.action)==null?void 0:k.type)==="task"?`Create task: ${s.action.title}`:s.command})}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(P,{label:"Trigger Type",children:e.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:s.trigger_type})}),e.jsx(P,{label:"Enabled",children:e.jsx("span",{className:`font-label text-xs font-bold ${s.enabled?"text-secondary":"text-outline"}`,children:s.enabled?"● ON":"○ OFF"})})]}),s.cron_expr&&e.jsx(P,{label:"Cron Expression",children:e.jsx("code",{className:"font-mono text-xs",children:s.cron_expr})}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs(P,{label:"Timeout",children:[s.timeout_secs,"s"]}),e.jsx(P,{label:"Max Retries",children:s.max_retries}),e.jsx(P,{label:"Overlap",children:s.overlap})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(P,{label:"Notify On",children:s.notify_on}),e.jsx(P,{label:"Run Count",children:s.run_count})]}),s.next_run_at&&e.jsx(P,{label:"Next Run",children:new Date(s.next_run_at).toLocaleString()})]}),!s.command.startsWith("__")&&e.jsx(Le,{job:s},s.id),e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-xs font-medium text-outline mb-3",children:"Recent runs"}),y?e.jsx(H,{message:y.message,onRetry:()=>u()}):p?e.jsx("div",{className:"space-y-2",children:[...Array(3)].map((h,_)=>e.jsx(U,{className:"h-8 w-full bg-surface-highest"},_))}):m!=null&&m.length?e.jsx("div",{className:"space-y-1",children:m.map(h=>e.jsx(Ze,{run:h,jobId:a,expanded:b===h.id,onToggle:()=>E(b===h.id?null:h.id)},h.id))}):e.jsx("div",{className:"font-label text-xs text-outline py-4 text-center",children:"No runs yet"})]})]}):e.jsx("p",{className:"text-sm text-outline",children:"Job not found"})}),e.jsxs(ve,{className:"flex-wrap",children:[(v.error||i.error)&&e.jsx("p",{role:"alert",className:"w-full text-sm text-error",children:($=v.error??i.error)==null?void 0:$.message}),s&&x&&e.jsxs(g,{"data-testid":"job-detail-edit",size:"sm",variant:"outline",onClick:()=>x(s),children:[e.jsx(X,{size:16}),"Edit job"]}),s&&e.jsxs(g,{size:"sm",variant:"ghost",disabled:v.isPending,onClick:()=>v.mutate({id:s.id,enabled:!s.enabled}),className:"font-label text-xs font-medium",children:[e.jsx(Ge,{size:12,className:"mr-1.5"}),s.enabled?"Disable":"Enable"]}),s&&e.jsxs(g,{size:"sm",disabled:i.isPending,onClick:()=>i.mutate(s.id),className:"font-label text-xs font-medium bg-transparent text-on-surface border border-control-border hover:bg-surface",children:[e.jsx(Z,{size:12,className:"mr-1.5"}),i.isPending?"Triggering...":"Trigger run"]})]})]})})}function Ze({run:a,jobId:c,expanded:n,onToggle:x}){return e.jsxs("div",{className:"min-w-0 border-y border-border overflow-hidden bg-background",children:[e.jsxs("button",{type:"button",onClick:x,"aria-expanded":n,className:"w-full flex items-center gap-3 px-3 py-2 hover:bg-surface transition-colors text-left",children:[n?e.jsx(ke,{size:12,className:"text-outline shrink-0"}):e.jsx(_e,{size:12,className:"text-outline shrink-0"}),e.jsx(we,{status:a.status,type:"job"}),e.jsxs("span",{className:"font-label text-xs text-outline flex-1",children:[a.started_at?new Date(a.started_at).toLocaleString():"—",a.ended_at&&e.jsxs("span",{className:"ml-2",children:["\\u2192 ",new Date(a.ended_at).toLocaleString()]})]}),a.exit_code!==null&&e.jsxs("span",{className:`font-mono text-xs ${a.exit_code===0?"text-secondary":"text-error"}`,children:["exit ",a.exit_code]})]}),(a.task_id||a.session_id)&&e.jsxs("div",{className:"flex gap-3 px-3 py-2 text-xs",children:[a.task_id&&e.jsx(Q,{className:"underline","data-testid":"job-run-task-link",to:`/tasks/${a.task_id}?project=all`,children:"Created task"}),a.session_id&&e.jsx(Q,{className:"underline","data-testid":"job-run-session-link",to:`/audit/${a.session_id}?project=all`,children:"Agent session"})]}),a.error_msg&&e.jsx("div",{className:"px-3 pb-2",children:e.jsx("span",{className:"font-body text-xs text-error",children:a.error_msg})}),n&&e.jsx(Ke,{jobId:c,runId:a.id})]})}function Ke({jobId:a,runId:c}){const{data:n,isLoading:x,error:s,refetch:C}=Be(a,c);return s?e.jsx(H,{message:s.message,onRetry:()=>C()}):x?e.jsx("div",{className:"px-3 pb-3",children:e.jsx(U,{className:"h-24 w-full bg-surface-highest"})}):n!=null&&n.length?e.jsx("div",{className:"mx-3 mb-3 rounded-lg overflow-hidden border border-surface-highest",children:e.jsx(Oe,{className:"h-[240px]",children:e.jsx("pre",{className:"font-mono text-xs leading-relaxed bg-background p-3",children:n.map(N=>e.jsx("div",{className:N.stream==="stderr"?"text-error":"text-on-surface",children:N.line},N.id))})})}):e.jsx("div",{className:"px-3 pb-3 font-label text-xs text-outline",children:"No log output"})}const xe=["one-shot","cron","watch","webhook","manual","bridge-msg"],ue=["skip","queue","kill"],be=["never","failure","always"];function it({projectId:a}){var F,l;const c=Se("sm"),n=He(a),x=n==="all"||n==="unassigned"?void 0:n,{data:s,isLoading:C,error:N,refetch:D}=Ve({project_id:x,limit:100}),m=n==="unassigned"?s==null?void 0:s.filter(t=>t.project_id===null):s,p=ce(),y=qe(),u=K(),i=Me(),v=((F=i.data)==null?void 0:F.scope)===n?i.data:void 0,b=Ce((m??[]).map(t=>t.id),n);async function E(t){const j=await i.mutateAsync({ids:b.selectedIds,enabled:t,scope:n});b.select(j.failed.map(S=>S.id))}const{selectedId:T,openDetail:k,closeDetail:$}=De("/jobs","jobId"),[h,_]=o.useState(!1),[A,R]=o.useState(null),[w,J]=o.useState(null);if(N)return e.jsxs("div",{children:[e.jsx(ee,{title:"Jobs"}),e.jsx(H,{message:N.message,onRetry:()=>D()})]});const z=(m??[]).filter(t=>t.enabled).length;return e.jsxs("div",{children:[e.jsx(ee,{title:"Jobs",meta:`${z}/${(m??[]).length} enabled`,action:e.jsxs(g,{"data-testid":"new-job-button",size:"sm",onClick:()=>_(!0),className:"font-label text-xs font-medium bg-primary text-primary-foreground hover:bg-primary/90",children:[e.jsx(Te,{size:12,className:"mr-1"})," New job"]})}),(p.error||y.error||u.error)&&e.jsx("p",{role:"alert",className:"mb-4 text-sm text-error",children:(l=p.error??y.error??u.error)==null?void 0:l.message}),!!(m!=null&&m.length)&&e.jsxs($e,{resourceLabel:"jobs",count:b.selectedIds.length,allSelected:b.allSelected,someSelected:b.someSelected,onSelectAll:b.selectAll,onClear:b.clear,disabled:i.isPending,children:[e.jsx(g,{type:"button",variant:"outline",size:"sm","data-testid":"jobs-bulk-enable",disabled:i.isPending||u.isPending,onClick:()=>void E(!0),children:"Enable selected"}),e.jsx(g,{type:"button",variant:"outline",size:"sm","data-testid":"jobs-bulk-disable",disabled:i.isPending||u.isPending,onClick:()=>void E(!1),children:"Disable selected"})]}),i.isPending&&e.jsx("p",{role:"status",className:"mb-3 text-sm text-outline",children:"Updating selected jobs…"}),!i.isPending&&v&&e.jsxs("div",{className:"mb-3 space-y-1 text-sm","data-testid":"jobs-bulk-result",role:"status",children:[e.jsxs("p",{children:[v.succeeded.length," jobs ",v.enabled?"enabled":"disabled","."]}),v.failed.map(t=>{var j;return e.jsxs("p",{className:"text-error",children:[((j=m==null?void 0:m.find(S=>S.id===t.id))==null?void 0:j.name)??t.id,": ",t.error,". Still selected for retry."]},t.id)})]}),C?e.jsx("div",{role:"status","aria-label":"Loading jobs",className:"space-y-2",children:[...Array(3)].map((t,j)=>e.jsx(U,{className:"h-12 w-full bg-surface-highest"},j))}):(m??[]).length===0?e.jsx(Pe,{message:"No jobs configured"}):c?e.jsx("div",{className:"min-w-0 overflow-hidden",children:e.jsxs(Ee,{children:[e.jsx(Re,{children:e.jsxs(se,{className:"border-b border-border hover:bg-transparent",children:[e.jsx(L,{className:"w-11",children:e.jsx("span",{className:"sr-only",children:"Select jobs"})}),e.jsx(L,{className:"font-label text-xs font-medium text-outline",children:"Name"}),e.jsx(L,{className:"font-label text-xs font-medium text-outline w-24",children:"Trigger"}),e.jsx(L,{className:"font-label text-xs font-medium text-outline w-48",children:"Action"}),e.jsx(L,{className:"font-label text-xs font-medium text-outline w-16",children:"Enabled"}),e.jsx(L,{className:"font-label text-xs font-medium text-outline w-36",children:"Last Run"}),e.jsx(L,{className:"font-label text-xs font-medium text-outline w-16",children:"Runs"}),e.jsx(L,{className:"font-label text-xs font-medium text-outline w-36",children:"Next Run"}),e.jsx(L,{className:"w-28"})]})}),e.jsx(Je,{children:(m??[]).map(t=>{var j,S;return e.jsxs(se,{"data-testid":"job-row","data-job-id":t.id,"data-job-name":t.name,className:"border-b border-border/65 hover:bg-surface-high cursor-pointer",onClick:()=>k(t.id),children:[e.jsx(O,{children:e.jsx("input",{type:"checkbox",className:"size-4 accent-primary","aria-label":`Select ${t.name}`,"data-testid":"job-select",checked:b.selectedIds.includes(t.id),disabled:i.isPending,onClick:I=>I.stopPropagation(),onChange:()=>b.toggle(t.id)})}),e.jsxs(O,{children:[e.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:I=>{I.stopPropagation(),k(t.id)},children:t.name}),t.description&&e.jsx("div",{className:"font-body text-sm text-outline mt-0.5 truncate max-w-[200px]",children:t.description})]}),e.jsx(O,{children:e.jsx("span",{className:"font-label text-xs text-on-surface-variant inline-flex",children:t.trigger_type})}),e.jsx(O,{children:e.jsx("code",{className:"font-mono text-xs text-outline truncate block max-w-[180px]",children:((j=t.action)==null?void 0:j.type)==="agent"?`Agent: ${t.action.backend}`:((S=t.action)==null?void 0:S.type)==="task"?`Task: ${t.action.title}`:t.command})}),e.jsx(O,{children:e.jsx(g,{type:"button","data-testid":"job-toggle-enabled",variant:"outline",size:"sm","aria-label":`${t.enabled?"Disable":"Enable"} ${t.name}`,"aria-pressed":t.enabled,disabled:u.isPending||i.isPending,onClick:I=>{I.stopPropagation(),u.mutate({id:t.id,enabled:!t.enabled})},children:t.enabled?"Disable":"Enable"})}),e.jsx(O,{className:"font-label text-xs text-outline",children:t.last_run_at?new Date(t.last_run_at).toLocaleString():"—"}),e.jsx(O,{className:"font-label text-xs text-outline",children:t.run_count}),e.jsx(O,{className:"font-label text-xs text-outline",children:t.next_run_at?new Date(t.next_run_at).toLocaleString():"—"}),e.jsx(O,{children:e.jsxs("div",{className:"flex items-center gap-2",onClick:I=>I.stopPropagation(),children:[e.jsxs(g,{"data-testid":"job-trigger",size:"sm",disabled:p.isPending,onClick:()=>p.mutate(t.id),className:"font-label text-sm min-h-11 px-3 bg-transparent text-on-surface border border-border hover:bg-surface-high",children:[e.jsx(Z,{size:10,className:"mr-1"})," Run"]}),e.jsx("button",{type:"button","data-testid":"job-edit","aria-label":`Edit ${t.name}`,onClick:()=>R(t),className:"inline-flex min-h-11 min-w-11 items-center justify-center rounded-md text-outline hover:text-primary hover:bg-surface-highest",children:e.jsx(X,{size:16})}),e.jsx("button",{type:"button","data-testid":"job-delete","aria-label":`Delete ${t.name}`,onClick:()=>J(t),className:"inline-flex min-h-11 min-w-11 items-center justify-center rounded-md text-outline hover:text-error hover:bg-error/10",children:e.jsx(te,{size:12})})]})})]},t.id)})})]})}):e.jsx("div",{className:"space-y-3",children:(m??[]).map(t=>{var j,S;return e.jsxs("article",{"data-testid":"job-row","data-job-id":t.id,"data-job-name":t.name,className:"border-b border-border/65 py-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx("input",{type:"checkbox",className:"size-4 accent-primary shrink-0 mt-1","aria-label":`Select ${t.name}`,"data-testid":"job-select",checked:b.selectedIds.includes(t.id),disabled:i.isPending,onChange:()=>b.toggle(t.id)}),e.jsx("button",{type:"button",className:"min-w-0 text-left font-medium text-sm text-on-surface break-words hover:text-primary","data-testid":"job-open-detail",onClick:()=>k(t.id),children:t.name}),e.jsx(g,{type:"button","data-testid":"job-toggle-enabled",variant:"outline",size:"sm","aria-label":`${t.enabled?"Disable":"Enable"} ${t.name}`,"aria-pressed":t.enabled,disabled:u.isPending||i.isPending,onClick:()=>u.mutate({id:t.id,enabled:!t.enabled}),children:t.enabled?"Disable":"Enable"})]}),t.description&&e.jsx("p",{className:"text-sm text-outline break-words",children:t.description}),e.jsx("code",{className:"block whitespace-pre-wrap break-all text-xs text-on-surface-variant",children:((j=t.action)==null?void 0:j.type)==="agent"?`Agent: ${t.action.backend}`:((S=t.action)==null?void 0:S.type)==="task"?`Task: ${t.action.title}`:t.command}),e.jsxs("p",{className:"text-xs text-outline",children:[t.trigger_type," · ",t.run_count," runs",t.next_run_at?` · Next: ${new Date(t.next_run_at).toLocaleString()}`:""]}),e.jsxs("div",{className:"flex flex-wrap gap-2 border-t border-border pt-3",children:[e.jsxs(g,{"data-testid":"job-edit",variant:"outline",size:"sm",onClick:()=>R(t),children:[e.jsx(X,{}),"Edit"]}),e.jsxs(g,{"data-testid":"job-trigger",variant:"outline",size:"sm",disabled:p.isPending,onClick:()=>p.mutate(t.id),children:[e.jsx(Z,{}),"Run"]}),e.jsx(g,{"data-testid":"job-delete","aria-label":`Delete ${t.name}`,variant:"ghost",size:"icon",onClick:()=>J(t),children:e.jsx(te,{})})]})]},t.id)})}),e.jsx(Xe,{jobId:T,open:!!T,onClose:$,onEdit:t=>{$(),R(t)}}),h&&e.jsx(Qe,{defaultProjectId:x,open:h,onClose:()=>_(!1)}),A&&e.jsx(et,{job:A,open:!!A,onClose:()=>R(null)}),w&&e.jsx(ze,{open:!!w,title:"Delete Job",description:`Delete job "${w.name}"? This cannot be undone.`,confirmLabel:"Delete",variant:"destructive",isPending:y.isPending,onConfirm:()=>{y.mutate(w.id,{onSuccess:()=>J(null)})},onCancel:()=>J(null)})]})}function Qe({defaultProjectId:a,open:c,onClose:n}){const{data:x}=Ie(),[s,C]=o.useState(""),[N,D]=o.useState(""),[m,p]=o.useState({type:"command",command:""}),[y,u]=o.useState([]),[i,v]=o.useState("manual"),[b,E]=o.useState(""),[T,k]=o.useState("300"),[$,h]=o.useState("0"),[_,A]=o.useState("skip"),[R,w]=o.useState("failure"),[J,z]=o.useState(""),[F,l]=o.useState(a??""),t=We(),[j,S]=o.useState(!1),I=r=>{if(r.preventDefault(),!s.trim()||!Y(m)||i==="webhook"&&!y.length)return;const he={name:s.trim(),description:N.trim(),action:m,webhooks:i==="webhook"?y:[],trigger_type:i,enabled:j,cron_expr:i==="cron"&&b.trim()||void 0,timeout_secs:Number.parseInt(T,10)||void 0,max_retries:Number.parseInt($,10),overlap:_,notify_on:R,project_id:F||void 0,working_dir:J.trim()||void 0};t.mutate(he,{onSuccess:n})};return e.jsx(ne,{open:c,onOpenChange:r=>!r&&n(),children:e.jsxs(re,{className:"bg-surface border-border max-w-lg max-h-[85dvh] overflow-y-auto",children:[e.jsx(le,{children:e.jsx(ie,{className:"font-headline text-sm font-medium text-on-surface",children:"New job"})}),e.jsxs("form",{onSubmit:I,className:"space-y-3 mt-2",children:[e.jsxs("label",{className:"flex min-h-11 items-center gap-3 text-sm",children:[e.jsx("input",{type:"checkbox","data-testid":"job-create-enabled",checked:j,onChange:r=>S(r.target.checked),className:"size-4 accent-primary"}),"Enable this job immediately"]}),e.jsx("p",{className:"text-xs text-outline",children:"New jobs stay disabled until you enable them. You can configure their webhook first."}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{className:"font-label text-xs font-medium text-outline",children:"Name *"}),e.jsx(f,{"aria-label":"Name","data-testid":"job-name-input",value:s,onChange:r=>C(r.target.value),placeholder:"Job name...",className:"bg-background border-control-border text-on-surface font-body text-sm",autoFocus:!0})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{className:"font-label text-xs font-medium text-outline",children:"Description"}),e.jsx(f,{"aria-label":"Description",value:N,onChange:r=>D(r.target.value),placeholder:"Optional description...",className:"bg-background border-control-border text-on-surface font-body text-sm"})]}),e.jsx(me,{value:m,onChange:p}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{className:"font-label text-xs font-medium text-outline",children:"Trigger Type"}),e.jsxs(V,{value:i,onValueChange:r=>v(r),children:[e.jsx(q,{"aria-label":"Trigger type","data-testid":"job-trigger-type",className:"bg-background border-control-border text-on-surface font-body text-sm min-h-11",children:e.jsx(M,{})}),e.jsx(W,{className:"bg-surface border-border",children:xe.map(r=>e.jsx(B,{value:r,"data-testid":`job-trigger-${r}`,className:"font-body text-sm",children:r},r))})]})]}),i==="webhook"&&e.jsx("div",{className:"sm:col-span-2",children:e.jsx(de,{value:y,onChange:u,projectId:F||void 0})}),i==="cron"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{className:"font-label text-xs font-medium text-outline",children:"Cron Expression"}),e.jsx(f,{"aria-label":"Cron expression",value:b,onChange:r=>E(r.target.value),placeholder:"*/5 * * * *",className:"bg-background border-control-border text-on-surface font-mono text-xs"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{className:"font-label text-xs font-medium text-outline",children:"Timeout (s)"}),e.jsx(f,{"aria-label":"Timeout in seconds",type:"number",min:1,required:!0,value:T,onChange:r=>k(r.target.value),className:"bg-background border-control-border text-on-surface font-body text-sm"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{className:"font-label text-xs font-medium text-outline",children:"Max Retries"}),e.jsx(f,{"aria-label":"Maximum retries",type:"number",min:0,required:!0,value:$,onChange:r=>h(r.target.value),className:"bg-background border-control-border text-on-surface font-body text-sm"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{className:"font-label text-xs font-medium text-outline",children:"Overlap"}),e.jsxs(V,{value:_,onValueChange:r=>A(r),children:[e.jsx(q,{"aria-label":"Overlap",className:"bg-background border-control-border text-on-surface font-body text-sm min-h-11",children:e.jsx(M,{})}),e.jsx(W,{className:"bg-surface border-border",children:ue.map(r=>e.jsx(B,{value:r,className:"font-body text-sm",children:r},r))})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{className:"font-label text-xs font-medium text-outline",children:"Notify On"}),e.jsxs(V,{value:R,onValueChange:r=>w(r),children:[e.jsx(q,{"aria-label":"Notify on",className:"bg-background border-control-border text-on-surface font-body text-sm min-h-11",children:e.jsx(M,{})}),e.jsx(W,{className:"bg-surface border-border",children:be.map(r=>e.jsx(B,{value:r,className:"font-body text-sm",children:r},r))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{className:"font-label text-xs font-medium text-outline",children:"Working Dir"}),e.jsx(f,{"aria-label":"Working directory",value:J,onChange:r=>z(r.target.value),placeholder:"/path/to/dir",className:"bg-background border-control-border text-on-surface font-body text-sm"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{className:"font-label text-xs font-medium text-outline",children:"Project"}),e.jsxs(V,{value:F||"__none__",onValueChange:r=>{l(r==="__none__"?"":r),u([])},children:[e.jsx(q,{"aria-label":"Project","data-testid":"job-project-select",className:"bg-background border-control-border text-on-surface font-body text-sm min-h-11",children:e.jsx(M,{})}),e.jsxs(W,{className:"bg-surface border-border",children:[e.jsx(B,{value:"__none__",className:"font-body text-sm",children:"None"}),x==null?void 0:x.map(r=>e.jsx(B,{value:r.id,className:"font-body text-sm",children:r.name},r.id))]})]})]}),e.jsxs(oe,{children:[e.jsx(g,{type:"button",variant:"ghost",size:"sm",onClick:n,className:"font-label text-xs text-outline",children:"Cancel"}),e.jsx(g,{"data-testid":"job-submit",type:"submit",size:"sm",disabled:t.isPending||!s.trim()||!Y(m)||i==="webhook"&&!y.length,className:"font-label text-xs bg-primary text-primary-foreground hover:bg-primary/90",children:t.isPending?"Creating...":i==="webhook"?"Create job":"Create"})]}),t.error&&e.jsx("p",{role:"alert",className:"text-sm text-error",children:t.error.message})]})]})})}function et({job:a,open:c,onClose:n}){const[x,s]=o.useState(a.name),[C,N]=o.useState(a.description??""),[D,m]=o.useState(a.action??{type:"command",command:a.command}),[p,y]=o.useState(a.webhooks??[]),[u,i]=o.useState(a.trigger_type),[v,b]=o.useState(a.cron_expr??""),[E,T]=o.useState(String(a.timeout_secs)),[k,$]=o.useState(String(a.max_retries)),[h,_]=o.useState(a.overlap),[A,R]=o.useState(a.notify_on),[w,J]=o.useState(a.enabled),z=K(),F=l=>{if(l.preventDefault(),!x.trim()||!Y(D)||u==="webhook"&&!p.length)return;const t={id:a.id,name:x.trim(),description:C.trim(),action:D,webhooks:u==="webhook"?p:[],trigger_type:u,cron_expr:u==="cron"&&v.trim()||void 0,timeout_secs:Number.parseInt(E,10)||void 0,max_retries:Number.parseInt(k,10),overlap:h,notify_on:A,enabled:w};z.mutate(t,{onSuccess:n})};return e.jsx(ne,{open:c,onOpenChange:l=>!l&&n(),children:e.jsxs(re,{className:"bg-surface border-border max-w-lg max-h-[85dvh] overflow-y-auto",children:[e.jsx(le,{children:e.jsx(ie,{className:"font-headline text-sm font-medium text-on-surface",children:"Edit job"})}),e.jsxs("form",{id:"edit-job-form",onSubmit:F,className:"space-y-3 mt-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{className:"font-label text-xs font-medium text-outline",children:"Name *"}),e.jsx(f,{"aria-label":"Name",value:x,onChange:l=>s(l.target.value),className:"bg-background border-control-border text-on-surface font-body text-sm"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{className:"font-label text-xs font-medium text-outline",children:"Description"}),e.jsx(f,{"aria-label":"Description",value:C,onChange:l=>N(l.target.value),className:"bg-background border-control-border text-on-surface font-body text-sm"})]}),e.jsx(me,{value:D,onChange:m}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{className:"font-label text-xs font-medium text-outline",children:"Trigger Type"}),e.jsxs(V,{value:u,onValueChange:l=>i(l),children:[e.jsx(q,{"aria-label":"Trigger type","data-testid":"job-trigger-type",className:"bg-background border-control-border text-on-surface font-body text-sm min-h-11",children:e.jsx(M,{})}),e.jsx(W,{className:"bg-surface border-border",children:xe.map(l=>e.jsx(B,{value:l,"data-testid":`job-trigger-${l}`,className:"font-body text-sm",children:l},l))})]})]}),u==="webhook"&&e.jsx("div",{className:"sm:col-span-2",children:e.jsx(de,{value:p,onChange:y,projectId:a.project_id??void 0})}),u==="cron"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{className:"font-label text-xs font-medium text-outline",children:"Cron Expression"}),e.jsx(f,{"aria-label":"Cron expression",value:v,onChange:l=>b(l.target.value),placeholder:"*/5 * * * *",className:"bg-background border-control-border text-on-surface font-mono text-xs"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{className:"font-label text-xs font-medium text-outline",children:"Timeout (s)"}),e.jsx(f,{"aria-label":"Timeout in seconds",type:"number",min:1,required:!0,value:E,onChange:l=>T(l.target.value),className:"bg-background border-control-border text-on-surface font-body text-sm"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{className:"font-label text-xs font-medium text-outline",children:"Max Retries"}),e.jsx(f,{"aria-label":"Maximum retries",type:"number",min:0,required:!0,value:k,onChange:l=>$(l.target.value),className:"bg-background border-control-border text-on-surface font-body text-sm"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{className:"font-label text-xs font-medium text-outline",children:"Overlap"}),e.jsxs(V,{value:h,onValueChange:l=>_(l),children:[e.jsx(q,{"aria-label":"Overlap",className:"bg-background border-control-border text-on-surface font-body text-sm min-h-11",children:e.jsx(M,{})}),e.jsx(W,{className:"bg-surface border-border",children:ue.map(l=>e.jsx(B,{value:l,className:"font-body text-sm",children:l},l))})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{className:"font-label text-xs font-medium text-outline",children:"Notify On"}),e.jsxs(V,{value:A,onValueChange:l=>R(l),children:[e.jsx(q,{"aria-label":"Notify on",className:"bg-background border-control-border text-on-surface font-body text-sm min-h-11",children:e.jsx(M,{})}),e.jsx(W,{className:"bg-surface border-border",children:be.map(l=>e.jsx(B,{value:l,className:"font-body text-sm",children:l},l))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{className:"font-label text-xs font-medium text-outline",children:"Enabled"}),e.jsx("button",{type:"button",onClick:()=>J(!w),className:`w-full min-h-11 rounded-md flex items-center justify-center border font-label text-xs font-medium transition-colors ${w?"bg-surface-highest text-on-surface border-border":"bg-background text-outline border-border"}`,children:w?"● Enabled":"○ Disabled"})]})]})]}),e.jsxs(oe,{children:[e.jsx(g,{type:"button",variant:"ghost",size:"sm",onClick:n,className:"font-label text-xs text-outline",children:"Cancel"}),e.jsx(g,{"data-testid":"job-edit-submit",form:"edit-job-form",type:"submit",size:"sm",disabled:z.isPending||!x.trim()||!Y(D)||u==="webhook"&&!p.length,className:"font-label text-xs bg-primary text-primary-foreground hover:bg-primary/90",children:z.isPending?"Saving...":"Save"})]}),z.error&&e.jsx("p",{role:"alert",className:"text-sm text-error",children:z.error.message})]})})}export{it as default};
|
|
11
|
+
*/const Ye=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],Ge=ae("power",Ye);function Y(a){return a.type==="command"?!!a.command.trim():a.type==="agent"?!!(a.prompt.trim()&&a.backend.trim()):!!a.title.trim()}function me({value:a,onChange:c}){const n=o.useId(),{data:x}=ge();return e.jsxs("section",{className:"space-y-3 border-y border-border py-4","data-testid":"job-action-fields",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{htmlFor:`${n}-type`,children:"What should this job do?"}),e.jsxs("select",{id:`${n}-type`,"data-testid":"job-action-type",className:"w-full min-h-11 rounded-md border border-control-border bg-background px-3 text-sm",value:a.type,onChange:s=>{s.target.value==="command"&&c({type:"command",command:""}),s.target.value==="agent"&&c({type:"agent",backend:"codex-cli",prompt:"",auto_approve:!1}),s.target.value==="task"&&c({type:"task",title:"",body:"",start_automatically:!1})},children:[e.jsx("option",{value:"command",children:"Run command"}),e.jsx("option",{value:"agent",children:"Run agent"}),e.jsx("option",{value:"task",children:"Create task"})]})]}),a.type==="command"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{htmlFor:`${n}-command`,children:"Command"}),e.jsx(G,{id:`${n}-command`,"aria-label":"Command","data-testid":"job-command-input",value:a.command,onChange:s=>c({...a,command:s.target.value}),rows:3,placeholder:"bun run build",required:!0})]}),a.type==="agent"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{htmlFor:`${n}-backend`,children:"Agent backend"}),e.jsx(j,{id:`${n}-backend`,"data-testid":"job-agent-backend",value:a.backend,list:`${n}-backends`,onChange:s=>c({...a,backend:s.target.value}),required:!0}),e.jsx("datalist",{id:`${n}-backends`,children:x==null?void 0:x.backends.map(s=>e.jsx("option",{value:s.name,children:s.available?"Available":"Unavailable"},s.name))})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{htmlFor:`${n}-model`,children:"Model (optional)"}),e.jsx(j,{id:`${n}-model`,"data-testid":"job-agent-model",value:a.model??"",onChange:s=>c({...a,model:s.target.value||void 0})})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{htmlFor:`${n}-prompt`,children:"Instructions"}),e.jsx(G,{id:`${n}-prompt`,"data-testid":"job-agent-prompt",value:a.prompt,onChange:s=>c({...a,prompt:s.target.value}),required:!0,rows:4})]}),e.jsxs("label",{className:"flex min-h-11 items-center gap-2 text-sm",children:[e.jsx("input",{type:"checkbox",checked:a.auto_approve,onChange:s=>c({...a,auto_approve:s.target.checked})}),"Allow agent tools automatically"]}),e.jsx("p",{className:"text-xs text-outline",children:"Starts a tracked agent session. When automatic tool approval is off, permission requests are denied."})]}),a.type==="task"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{htmlFor:`${n}-title`,children:"Task title"}),e.jsx(j,{id:`${n}-title`,"data-testid":"job-task-title",value:a.title,onChange:s=>c({...a,title:s.target.value}),required:!0,maxLength:200})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{htmlFor:`${n}-body`,children:"Task instructions"}),e.jsx(G,{id:`${n}-body`,"data-testid":"job-task-body",value:a.body,onChange:s=>c({...a,body:s.target.value}),rows:4})]}),e.jsxs("label",{className:"flex min-h-11 items-center gap-2 text-sm",children:[e.jsx("input",{type:"checkbox","data-testid":"job-task-autostart",checked:a.start_automatically,onChange:s=>c({...a,start_automatically:s.target.checked})}),"Start the task flow automatically"]}),a.start_automatically&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{htmlFor:`${n}-flow`,children:"Flow (blank uses the configured default)"}),e.jsx(j,{id:`${n}-flow`,"data-testid":"job-task-flow",value:a.flow_name??"",onChange:s=>c({...a,flow_name:s.target.value||void 0})})]}),e.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 Xe({jobId:a,open:c,onClose:n,onEdit:x}){var D,k,$;const{data:s,isLoading:C,error:N,refetch:T}=ze(a),{data:m,isLoading:p,error:y,refetch:u}=Ie(a),i=ce(),v=Q(),[b,E]=o.useState(null);return e.jsx(pe,{open:c,onOpenChange:h=>!h&&n(),children:e.jsxs(fe,{"data-testid":"job-detail-sheet",children:[e.jsxs(je,{children:[e.jsx(Ne,{children:(s==null?void 0:s.name)??"Job details"}),(s==null?void 0:s.description)&&e.jsx("p",{className:"font-body text-xs text-outline mt-1",children:s.description})]}),e.jsx(ye,{children:N?e.jsx(U,{message:N.message,onRetry:()=>T()}):C?e.jsx("div",{className:"space-y-3",children:[...Array(6)].map((h,_)=>e.jsx(H,{className:"h-8 w-full bg-surface-highest"},_))}):s?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx(P,{label:"Action",children:e.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=s.action)==null?void 0:D.type)==="agent"?`Run agent (${s.action.backend}): ${s.action.prompt}`:((k=s.action)==null?void 0:k.type)==="task"?`Create task: ${s.action.title}`:s.command})}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(P,{label:"Trigger Type",children:e.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:s.trigger_type})}),e.jsx(P,{label:"Enabled",children:e.jsx("span",{className:`font-label text-xs font-bold ${s.enabled?"text-secondary":"text-outline"}`,children:s.enabled?"● ON":"○ OFF"})})]}),s.cron_expr&&e.jsx(P,{label:"Cron Expression",children:e.jsx("code",{className:"font-mono text-xs",children:s.cron_expr})}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs(P,{label:"Timeout",children:[s.timeout_secs,"s"]}),e.jsx(P,{label:"Max Retries",children:s.max_retries}),e.jsx(P,{label:"Overlap",children:s.overlap})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(P,{label:"Notify On",children:s.notify_on}),e.jsx(P,{label:"Run Count",children:s.run_count})]}),s.next_run_at&&e.jsx(P,{label:"Next Run",children:new Date(s.next_run_at).toLocaleString()})]}),!s.command.startsWith("__")&&e.jsx(Ee,{job:s},s.id),e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-xs font-medium text-outline mb-3",children:"Recent runs"}),y?e.jsx(U,{message:y.message,onRetry:()=>u()}):p?e.jsx("div",{className:"space-y-2",children:[...Array(3)].map((h,_)=>e.jsx(H,{className:"h-8 w-full bg-surface-highest"},_))}):m!=null&&m.length?e.jsx("div",{className:"space-y-1",children:m.map(h=>e.jsx(Ke,{run:h,jobId:a,expanded:b===h.id,onToggle:()=>E(b===h.id?null:h.id)},h.id))}):e.jsx("div",{className:"font-label text-xs text-outline py-4 text-center",children:"No runs yet"})]})]}):e.jsx("p",{className:"text-sm text-outline",children:"Job not found"})}),e.jsxs(ve,{className:"flex-wrap",children:[(v.error||i.error)&&e.jsx("p",{role:"alert",className:"w-full text-sm text-error",children:($=v.error??i.error)==null?void 0:$.message}),s&&x&&e.jsxs(g,{"data-testid":"job-detail-edit",size:"sm",variant:"outline",onClick:()=>x(s),children:[e.jsx(X,{size:16}),"Edit job"]}),s&&e.jsxs(g,{size:"sm",variant:"ghost",disabled:v.isPending,onClick:()=>v.mutate({id:s.id,enabled:!s.enabled}),className:"font-label text-xs font-medium",children:[e.jsx(Ge,{size:12,className:"mr-1.5"}),s.enabled?"Disable":"Enable"]}),s&&e.jsxs(g,{size:"sm",disabled:i.isPending,onClick:()=>i.mutate(s.id),className:"font-label text-xs font-medium bg-transparent text-on-surface border border-control-border hover:bg-surface",children:[e.jsx(K,{size:12,className:"mr-1.5"}),i.isPending?"Triggering...":"Trigger run"]})]})]})})}function Ke({run:a,jobId:c,expanded:n,onToggle:x}){return e.jsxs("div",{className:"min-w-0 border-y border-border overflow-hidden bg-background",children:[e.jsxs("button",{type:"button",onClick:x,"aria-expanded":n,className:"w-full flex items-center gap-3 px-3 py-2 hover:bg-surface transition-colors text-left",children:[n?e.jsx(ke,{size:12,className:"text-outline shrink-0"}):e.jsx(_e,{size:12,className:"text-outline shrink-0"}),e.jsx(Re,{status:a.status,type:"job"}),e.jsxs("span",{className:"font-label text-xs text-outline flex-1",children:[a.started_at?new Date(a.started_at).toLocaleString():"—",a.ended_at&&e.jsxs("span",{className:"ml-2",children:["\\u2192 ",new Date(a.ended_at).toLocaleString()]})]}),a.exit_code!==null&&e.jsxs("span",{className:`font-mono text-xs ${a.exit_code===0?"text-secondary":"text-error"}`,children:["exit ",a.exit_code]})]}),(a.task_id||a.session_id)&&e.jsxs("div",{className:"flex gap-3 px-3 py-2 text-xs",children:[a.task_id&&e.jsx(Z,{className:"underline","data-testid":"job-run-task-link",to:`/tasks/${a.task_id}?project=all`,children:"Created task"}),a.session_id&&e.jsx(Z,{className:"underline","data-testid":"job-run-session-link",to:`/audit/${a.session_id}?project=all`,children:"Agent session"})]}),a.error_msg&&e.jsx("div",{className:"px-3 pb-2",children:e.jsx("span",{className:"font-body text-xs text-error",children:a.error_msg})}),n&&e.jsx(Qe,{jobId:c,runId:a.id})]})}function Qe({jobId:a,runId:c}){const{data:n,isLoading:x,error:s,refetch:C}=Le(a,c);return s?e.jsx(U,{message:s.message,onRetry:()=>C()}):x?e.jsx("div",{className:"px-3 pb-3",children:e.jsx(H,{className:"h-24 w-full bg-surface-highest"})}):n!=null&&n.length?e.jsx("div",{className:"mx-3 mb-3 rounded-lg overflow-hidden border border-surface-highest",children:e.jsx(Je,{className:"h-[240px]",children:e.jsx("pre",{className:"font-mono text-xs leading-relaxed bg-background p-3",children:n.map(N=>e.jsx("div",{className:N.stream==="stderr"?"text-error":"text-on-surface",children:N.line},N.id))})})}):e.jsx("div",{className:"px-3 pb-3 font-label text-xs text-outline",children:"No log output"})}const xe=["one-shot","cron","watch","webhook","manual","bridge-msg"],ue=["skip","queue","kill"],be=["never","failure","always"];function gt({projectId:a}){var F,l;const c=we("sm"),n=He(a),x=n==="all"||n==="unassigned"?void 0:n,{data:s,isLoading:C,error:N,refetch:T}=Oe({project_id:x,limit:100}),m=n==="unassigned"?s==null?void 0:s.filter(t=>t.project_id===null):s,p=ce(),y=Ae(),u=Q(),i=Fe(),v=((F=i.data)==null?void 0:F.scope)===n?i.data:void 0,b=Te((m??[]).map(t=>t.id),n);async function E(t){const f=await i.mutateAsync({ids:b.selectedIds,enabled:t,scope:n});b.select(f.failed.map(S=>S.id))}const{selectedId:D,openDetail:k,closeDetail:$}=We("/jobs","jobId"),[h,_]=o.useState(!1),[A,R]=o.useState(null),[w,J]=o.useState(null);if(N)return e.jsxs("div",{children:[e.jsx(te,{title:"Jobs"}),e.jsx(U,{message:N.message,onRetry:()=>T()})]});const z=(m??[]).filter(t=>t.enabled).length;return e.jsxs("div",{children:[e.jsx(te,{title:"Jobs",meta:`${z}/${(m??[]).length} enabled`,action:e.jsxs(g,{"data-testid":"new-job-button",size:"sm",onClick:()=>_(!0),className:"font-label text-xs font-medium bg-primary text-primary-foreground hover:bg-primary/90",children:[e.jsx(Se,{size:12,className:"mr-1"})," New job"]})}),(p.error||y.error||u.error)&&e.jsx("p",{role:"alert",className:"mb-4 text-sm text-error",children:(l=p.error??y.error??u.error)==null?void 0:l.message}),!!(m!=null&&m.length)&&e.jsxs(De,{resourceLabel:"jobs",count:b.selectedIds.length,allSelected:b.allSelected,someSelected:b.someSelected,onSelectAll:b.selectAll,onClear:b.clear,disabled:i.isPending,children:[e.jsx(g,{type:"button",variant:"outline",size:"sm","data-testid":"jobs-bulk-enable",disabled:i.isPending||u.isPending,onClick:()=>void E(!0),children:"Enable selected"}),e.jsx(g,{type:"button",variant:"outline",size:"sm","data-testid":"jobs-bulk-disable",disabled:i.isPending||u.isPending,onClick:()=>void E(!1),children:"Disable selected"})]}),i.isPending&&e.jsx("p",{role:"status",className:"mb-3 text-sm text-outline",children:"Updating selected jobs…"}),!i.isPending&&v&&e.jsxs("div",{className:"mb-3 space-y-1 text-sm","data-testid":"jobs-bulk-result",role:"status",children:[e.jsxs("p",{children:[v.succeeded.length," jobs ",v.enabled?"enabled":"disabled","."]}),v.failed.map(t=>{var f;return e.jsxs("p",{className:"text-error",children:[((f=m==null?void 0:m.find(S=>S.id===t.id))==null?void 0:f.name)??t.id,": ",t.error,". Still selected for retry."]},t.id)})]}),C?e.jsx("div",{role:"status","aria-label":"Loading jobs",className:"space-y-2",children:[...Array(3)].map((t,f)=>e.jsx(H,{className:"h-12 w-full bg-surface-highest"},f))}):(m??[]).length===0?e.jsx(Pe,{message:"No jobs configured"}):c?e.jsx("div",{className:"min-w-0 overflow-hidden",children:e.jsxs(Ve,{children:[e.jsx(qe,{children:e.jsxs(ee,{className:"border-b border-border hover:bg-transparent",children:[e.jsx(L,{className:"w-11",children:e.jsx("span",{className:"sr-only",children:"Select jobs"})}),e.jsx(L,{className:"font-label text-xs font-medium text-outline",children:"Name"}),e.jsx(L,{className:"font-label text-xs font-medium text-outline w-24",children:"Trigger"}),e.jsx(L,{className:"font-label text-xs font-medium text-outline w-48",children:"Action"}),e.jsx(L,{className:"font-label text-xs font-medium text-outline w-16",children:"Enabled"}),e.jsx(L,{className:"font-label text-xs font-medium text-outline w-36",children:"Last Run"}),e.jsx(L,{className:"font-label text-xs font-medium text-outline w-16",children:"Runs"}),e.jsx(L,{className:"font-label text-xs font-medium text-outline w-36",children:"Next Run"}),e.jsx(L,{className:"w-28"})]})}),e.jsx(Me,{children:(m??[]).map(t=>{var f,S;return e.jsxs(ee,{"data-testid":"job-row","data-job-id":t.id,"data-job-name":t.name,className:"border-b border-border/65 hover:bg-surface-high cursor-pointer",onClick:()=>k(t.id),children:[e.jsx(O,{children:e.jsx("input",{type:"checkbox",className:"size-4 accent-primary","aria-label":`Select ${t.name}`,"data-testid":"job-select",checked:b.selectedIds.includes(t.id),disabled:i.isPending,onClick:I=>I.stopPropagation(),onChange:()=>b.toggle(t.id)})}),e.jsxs(O,{children:[e.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:I=>{I.stopPropagation(),k(t.id)},children:t.name}),t.description&&e.jsx("div",{className:"font-body text-sm text-outline mt-0.5 truncate max-w-[200px]",children:t.description})]}),e.jsx(O,{children:e.jsx("span",{className:"font-label text-xs text-on-surface-variant inline-flex",children:t.trigger_type})}),e.jsx(O,{children:e.jsx("code",{className:"font-mono text-xs text-outline truncate block max-w-[180px]",children:((f=t.action)==null?void 0:f.type)==="agent"?`Agent: ${t.action.backend}`:((S=t.action)==null?void 0:S.type)==="task"?`Task: ${t.action.title}`:t.command})}),e.jsx(O,{children:e.jsx(g,{type:"button","data-testid":"job-toggle-enabled",variant:"outline",size:"sm","aria-label":`${t.enabled?"Disable":"Enable"} ${t.name}`,"aria-pressed":t.enabled,disabled:u.isPending||i.isPending,onClick:I=>{I.stopPropagation(),u.mutate({id:t.id,enabled:!t.enabled})},children:t.enabled?"Disable":"Enable"})}),e.jsx(O,{className:"font-label text-xs text-outline",children:t.last_run_at?new Date(t.last_run_at).toLocaleString():"—"}),e.jsx(O,{className:"font-label text-xs text-outline",children:t.run_count}),e.jsx(O,{className:"font-label text-xs text-outline",children:t.next_run_at?new Date(t.next_run_at).toLocaleString():"—"}),e.jsx(O,{children:e.jsxs("div",{className:"flex items-center gap-2",onClick:I=>I.stopPropagation(),children:[e.jsxs(g,{"data-testid":"job-trigger",size:"sm",disabled:p.isPending,onClick:()=>p.mutate(t.id),className:"font-label text-sm min-h-11 px-3 bg-transparent text-on-surface border border-border hover:bg-surface-high",children:[e.jsx(K,{size:10,className:"mr-1"})," Run"]}),e.jsx("button",{type:"button","data-testid":"job-edit","aria-label":`Edit ${t.name}`,onClick:()=>R(t),className:"inline-flex min-h-11 min-w-11 items-center justify-center rounded-md text-outline hover:text-primary hover:bg-surface-highest",children:e.jsx(X,{size:16})}),e.jsx("button",{type:"button","data-testid":"job-delete","aria-label":`Delete ${t.name}`,onClick:()=>J(t),className:"inline-flex min-h-11 min-w-11 items-center justify-center rounded-md text-outline hover:text-error hover:bg-error/10",children:e.jsx(se,{size:12})})]})})]},t.id)})})]})}):e.jsx("div",{className:"space-y-3",children:(m??[]).map(t=>{var f,S;return e.jsxs("article",{"data-testid":"job-row","data-job-id":t.id,"data-job-name":t.name,className:"border-b border-border/65 py-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx("input",{type:"checkbox",className:"size-4 accent-primary shrink-0 mt-1","aria-label":`Select ${t.name}`,"data-testid":"job-select",checked:b.selectedIds.includes(t.id),disabled:i.isPending,onChange:()=>b.toggle(t.id)}),e.jsx("button",{type:"button",className:"min-w-0 text-left font-medium text-sm text-on-surface break-words hover:text-primary","data-testid":"job-open-detail",onClick:()=>k(t.id),children:t.name}),e.jsx(g,{type:"button","data-testid":"job-toggle-enabled",variant:"outline",size:"sm","aria-label":`${t.enabled?"Disable":"Enable"} ${t.name}`,"aria-pressed":t.enabled,disabled:u.isPending||i.isPending,onClick:()=>u.mutate({id:t.id,enabled:!t.enabled}),children:t.enabled?"Disable":"Enable"})]}),t.description&&e.jsx("p",{className:"text-sm text-outline break-words",children:t.description}),e.jsx("code",{className:"block whitespace-pre-wrap break-all text-xs text-on-surface-variant",children:((f=t.action)==null?void 0:f.type)==="agent"?`Agent: ${t.action.backend}`:((S=t.action)==null?void 0:S.type)==="task"?`Task: ${t.action.title}`:t.command}),e.jsxs("p",{className:"text-xs text-outline",children:[t.trigger_type," · ",t.run_count," runs",t.next_run_at?` · Next: ${new Date(t.next_run_at).toLocaleString()}`:""]}),e.jsxs("div",{className:"flex flex-wrap gap-2 border-t border-border pt-3",children:[e.jsxs(g,{"data-testid":"job-edit",variant:"outline",size:"sm",onClick:()=>R(t),children:[e.jsx(X,{}),"Edit"]}),e.jsxs(g,{"data-testid":"job-trigger",variant:"outline",size:"sm",disabled:p.isPending,onClick:()=>p.mutate(t.id),children:[e.jsx(K,{}),"Run"]}),e.jsx(g,{"data-testid":"job-delete","aria-label":`Delete ${t.name}`,variant:"ghost",size:"icon",onClick:()=>J(t),children:e.jsx(se,{})})]})]},t.id)})}),e.jsx(Xe,{jobId:D,open:!!D,onClose:$,onEdit:t=>{$(),R(t)}}),h&&e.jsx(Ze,{defaultProjectId:x,open:h,onClose:()=>_(!1)}),A&&e.jsx(et,{job:A,open:!!A,onClose:()=>R(null)}),w&&e.jsx($e,{open:!!w,title:"Delete Job",description:`Delete job "${w.name}"? This cannot be undone.`,confirmLabel:"Delete",variant:"destructive",isPending:y.isPending,onConfirm:()=>{y.mutate(w.id,{onSuccess:()=>J(null)})},onCancel:()=>J(null)})]})}function Ze({defaultProjectId:a,open:c,onClose:n}){const{data:x}=Ce(),[s,C]=o.useState(""),[N,T]=o.useState(""),[m,p]=o.useState({type:"command",command:""}),[y,u]=o.useState([]),[i,v]=o.useState("manual"),[b,E]=o.useState(""),[D,k]=o.useState("300"),[$,h]=o.useState("0"),[_,A]=o.useState("skip"),[R,w]=o.useState("failure"),[J,z]=o.useState(""),[F,l]=o.useState(a??""),t=Be(),[f,S]=o.useState(!1),I=r=>{if(r.preventDefault(),!s.trim()||!Y(m)||i==="webhook"&&!y.length)return;const he={name:s.trim(),description:N.trim(),action:m,webhooks:i==="webhook"?y:[],trigger_type:i,enabled:f,cron_expr:i==="cron"&&b.trim()||void 0,timeout_secs:Number.parseInt(D,10)||void 0,max_retries:Number.parseInt($,10),overlap:_,notify_on:R,project_id:F||void 0,working_dir:J.trim()||void 0};t.mutate(he,{onSuccess:n})};return e.jsx(ne,{open:c,onOpenChange:r=>!r&&n(),children:e.jsxs(re,{className:"bg-surface border-border max-w-lg max-h-[85dvh] overflow-y-auto",children:[e.jsx(le,{children:e.jsx(ie,{className:"font-headline text-sm font-medium text-on-surface",children:"New job"})}),e.jsxs("form",{onSubmit:I,className:"space-y-3 mt-2",children:[e.jsxs("label",{className:"flex min-h-11 items-center gap-3 text-sm",children:[e.jsx("input",{type:"checkbox","data-testid":"job-create-enabled",checked:f,onChange:r=>S(r.target.checked),className:"size-4 accent-primary"}),"Enable this job immediately"]}),e.jsx("p",{className:"text-xs text-outline",children:"New jobs stay disabled until you enable them. You can configure their webhook first."}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{className:"font-label text-xs font-medium text-outline",children:"Name *"}),e.jsx(j,{"aria-label":"Name","data-testid":"job-name-input",value:s,onChange:r=>C(r.target.value),placeholder:"Job name...",className:"bg-background border-control-border text-on-surface font-body text-sm",autoFocus:!0})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{className:"font-label text-xs font-medium text-outline",children:"Description"}),e.jsx(j,{"aria-label":"Description",value:N,onChange:r=>T(r.target.value),placeholder:"Optional description...",className:"bg-background border-control-border text-on-surface font-body text-sm"})]}),e.jsx(me,{value:m,onChange:p}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{className:"font-label text-xs font-medium text-outline",children:"Trigger Type"}),e.jsxs(V,{value:i,onValueChange:r=>v(r),children:[e.jsx(q,{"aria-label":"Trigger type","data-testid":"job-trigger-type",className:"bg-background border-control-border text-on-surface font-body text-sm min-h-11",children:e.jsx(M,{})}),e.jsx(W,{className:"bg-surface border-border",children:xe.map(r=>e.jsx(B,{value:r,"data-testid":`job-trigger-${r}`,className:"font-body text-sm",children:r},r))})]})]}),i==="webhook"&&e.jsx("div",{className:"sm:col-span-2",children:e.jsx(de,{value:y,onChange:u,projectId:F||void 0})}),i==="cron"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{className:"font-label text-xs font-medium text-outline",children:"Cron Expression"}),e.jsx(j,{"aria-label":"Cron expression",value:b,onChange:r=>E(r.target.value),placeholder:"*/5 * * * *",className:"bg-background border-control-border text-on-surface font-mono text-xs"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{className:"font-label text-xs font-medium text-outline",children:"Timeout (s)"}),e.jsx(j,{"aria-label":"Timeout in seconds",type:"number",min:1,required:!0,value:D,onChange:r=>k(r.target.value),className:"bg-background border-control-border text-on-surface font-body text-sm"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{className:"font-label text-xs font-medium text-outline",children:"Max Retries"}),e.jsx(j,{"aria-label":"Maximum retries",type:"number",min:0,required:!0,value:$,onChange:r=>h(r.target.value),className:"bg-background border-control-border text-on-surface font-body text-sm"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{className:"font-label text-xs font-medium text-outline",children:"Overlap"}),e.jsxs(V,{value:_,onValueChange:r=>A(r),children:[e.jsx(q,{"aria-label":"Overlap",className:"bg-background border-control-border text-on-surface font-body text-sm min-h-11",children:e.jsx(M,{})}),e.jsx(W,{className:"bg-surface border-border",children:ue.map(r=>e.jsx(B,{value:r,className:"font-body text-sm",children:r},r))})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{className:"font-label text-xs font-medium text-outline",children:"Notify On"}),e.jsxs(V,{value:R,onValueChange:r=>w(r),children:[e.jsx(q,{"aria-label":"Notify on",className:"bg-background border-control-border text-on-surface font-body text-sm min-h-11",children:e.jsx(M,{})}),e.jsx(W,{className:"bg-surface border-border",children:be.map(r=>e.jsx(B,{value:r,className:"font-body text-sm",children:r},r))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{className:"font-label text-xs font-medium text-outline",children:"Working Dir"}),e.jsx(j,{"aria-label":"Working directory",value:J,onChange:r=>z(r.target.value),placeholder:"/path/to/dir",className:"bg-background border-control-border text-on-surface font-body text-sm"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{className:"font-label text-xs font-medium text-outline",children:"Project"}),e.jsxs(V,{value:F||"__none__",onValueChange:r=>{l(r==="__none__"?"":r),u([])},children:[e.jsx(q,{"aria-label":"Project","data-testid":"job-project-select",className:"bg-background border-control-border text-on-surface font-body text-sm min-h-11",children:e.jsx(M,{})}),e.jsxs(W,{className:"bg-surface border-border",children:[e.jsx(B,{value:"__none__",className:"font-body text-sm",children:"None"}),x==null?void 0:x.map(r=>e.jsx(B,{value:r.id,className:"font-body text-sm",children:r.name},r.id))]})]})]}),e.jsxs(oe,{children:[e.jsx(g,{type:"button",variant:"ghost",size:"sm",onClick:n,className:"font-label text-xs text-outline",children:"Cancel"}),e.jsx(g,{"data-testid":"job-submit",type:"submit",size:"sm",disabled:t.isPending||!s.trim()||!Y(m)||i==="webhook"&&!y.length,className:"font-label text-xs bg-primary text-primary-foreground hover:bg-primary/90",children:t.isPending?"Creating...":i==="webhook"?"Create job":"Create"})]}),t.error&&e.jsx("p",{role:"alert",className:"text-sm text-error",children:t.error.message})]})]})})}function et({job:a,open:c,onClose:n}){const[x,s]=o.useState(a.name),[C,N]=o.useState(a.description??""),[T,m]=o.useState(a.action??{type:"command",command:a.command}),[p,y]=o.useState(a.webhooks??[]),[u,i]=o.useState(a.trigger_type),[v,b]=o.useState(a.cron_expr??""),[E,D]=o.useState(String(a.timeout_secs)),[k,$]=o.useState(String(a.max_retries)),[h,_]=o.useState(a.overlap),[A,R]=o.useState(a.notify_on),[w,J]=o.useState(a.enabled),z=Q(),F=l=>{if(l.preventDefault(),!x.trim()||!Y(T)||u==="webhook"&&!p.length)return;const t={id:a.id,name:x.trim(),description:C.trim(),action:T,webhooks:u==="webhook"?p:[],trigger_type:u,cron_expr:u==="cron"&&v.trim()||void 0,timeout_secs:Number.parseInt(E,10)||void 0,max_retries:Number.parseInt(k,10),overlap:h,notify_on:A,enabled:w};z.mutate(t,{onSuccess:n})};return e.jsx(ne,{open:c,onOpenChange:l=>!l&&n(),children:e.jsxs(re,{className:"bg-surface border-border max-w-lg max-h-[85dvh] overflow-y-auto",children:[e.jsx(le,{children:e.jsx(ie,{className:"font-headline text-sm font-medium text-on-surface",children:"Edit job"})}),e.jsxs("form",{id:"edit-job-form",onSubmit:F,className:"space-y-3 mt-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{className:"font-label text-xs font-medium text-outline",children:"Name *"}),e.jsx(j,{"aria-label":"Name",value:x,onChange:l=>s(l.target.value),className:"bg-background border-control-border text-on-surface font-body text-sm"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{className:"font-label text-xs font-medium text-outline",children:"Description"}),e.jsx(j,{"aria-label":"Description",value:C,onChange:l=>N(l.target.value),className:"bg-background border-control-border text-on-surface font-body text-sm"})]}),e.jsx(me,{value:T,onChange:m}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{className:"font-label text-xs font-medium text-outline",children:"Trigger Type"}),e.jsxs(V,{value:u,onValueChange:l=>i(l),children:[e.jsx(q,{"aria-label":"Trigger type","data-testid":"job-trigger-type",className:"bg-background border-control-border text-on-surface font-body text-sm min-h-11",children:e.jsx(M,{})}),e.jsx(W,{className:"bg-surface border-border",children:xe.map(l=>e.jsx(B,{value:l,"data-testid":`job-trigger-${l}`,className:"font-body text-sm",children:l},l))})]})]}),u==="webhook"&&e.jsx("div",{className:"sm:col-span-2",children:e.jsx(de,{value:p,onChange:y,projectId:a.project_id??void 0})}),u==="cron"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{className:"font-label text-xs font-medium text-outline",children:"Cron Expression"}),e.jsx(j,{"aria-label":"Cron expression",value:v,onChange:l=>b(l.target.value),placeholder:"*/5 * * * *",className:"bg-background border-control-border text-on-surface font-mono text-xs"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{className:"font-label text-xs font-medium text-outline",children:"Timeout (s)"}),e.jsx(j,{"aria-label":"Timeout in seconds",type:"number",min:1,required:!0,value:E,onChange:l=>D(l.target.value),className:"bg-background border-control-border text-on-surface font-body text-sm"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{className:"font-label text-xs font-medium text-outline",children:"Max Retries"}),e.jsx(j,{"aria-label":"Maximum retries",type:"number",min:0,required:!0,value:k,onChange:l=>$(l.target.value),className:"bg-background border-control-border text-on-surface font-body text-sm"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{className:"font-label text-xs font-medium text-outline",children:"Overlap"}),e.jsxs(V,{value:h,onValueChange:l=>_(l),children:[e.jsx(q,{"aria-label":"Overlap",className:"bg-background border-control-border text-on-surface font-body text-sm min-h-11",children:e.jsx(M,{})}),e.jsx(W,{className:"bg-surface border-border",children:ue.map(l=>e.jsx(B,{value:l,className:"font-body text-sm",children:l},l))})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{className:"font-label text-xs font-medium text-outline",children:"Notify On"}),e.jsxs(V,{value:A,onValueChange:l=>R(l),children:[e.jsx(q,{"aria-label":"Notify on",className:"bg-background border-control-border text-on-surface font-body text-sm min-h-11",children:e.jsx(M,{})}),e.jsx(W,{className:"bg-surface border-border",children:be.map(l=>e.jsx(B,{value:l,className:"font-body text-sm",children:l},l))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(d,{className:"font-label text-xs font-medium text-outline",children:"Enabled"}),e.jsx("button",{type:"button",onClick:()=>J(!w),className:`w-full min-h-11 rounded-md flex items-center justify-center border font-label text-xs font-medium transition-colors ${w?"bg-surface-highest text-on-surface border-border":"bg-background text-outline border-border"}`,children:w?"● Enabled":"○ Disabled"})]})]})]}),e.jsxs(oe,{children:[e.jsx(g,{type:"button",variant:"ghost",size:"sm",onClick:n,className:"font-label text-xs text-outline",children:"Cancel"}),e.jsx(g,{"data-testid":"job-edit-submit",form:"edit-job-form",type:"submit",size:"sm",disabled:z.isPending||!x.trim()||!Y(T)||u==="webhook"&&!p.length,className:"font-label text-xs bg-primary text-primary-foreground hover:bg-primary/90",children:z.isPending?"Saving...":"Save"})]}),z.error&&e.jsx("p",{role:"alert",className:"text-sm text-error",children:z.error.message})]})})}export{gt as default};
|