orc-ai 0.1.67 → 0.1.68
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/dist/index.js +882 -842
- package/dist/skills/orc-platform/references/html-kit.md +3 -3
- package/dist/web/assets/Agents-DywRmYEM.js +34 -0
- package/dist/web/assets/Audit-Bwj_b97K.js +1 -0
- package/dist/web/assets/Bar-BEUEq4ZT.js +3 -0
- package/dist/web/assets/BarChart-DJZEJEg6.js +1 -0
- package/dist/web/assets/Chart-BMFNlgbS.js +1 -0
- package/dist/web/assets/ChatAnalyticsCharts-iTBR2Iod.js +1 -0
- package/dist/web/assets/ChatUiRenderer-C_zxzai1.js +4 -0
- package/dist/web/assets/ConfirmDialog-TrdcniMK.js +1 -0
- package/dist/web/assets/Dashboard-BgBJ-gaW.js +1 -0
- package/dist/web/assets/Dashboard-R9DrLwVP.css +1 -0
- package/dist/web/assets/DocumentWorkspace-LHgC6hHQ.js +1 -0
- package/dist/web/assets/FileEditor-dfjyLTPe.js +1 -0
- package/dist/web/assets/IntegrationCallback-DqJyQK0S.js +1 -0
- package/dist/web/assets/JobWebhooks-CKOr3jed.js +1 -0
- package/dist/web/assets/Jobs-DSxiN8po.js +3 -0
- package/dist/web/assets/Knowledge-BD44kGtr.js +1 -0
- package/dist/web/assets/Line-BwNoqzSJ.js +1 -0
- package/dist/web/assets/Markdown-wp7JBOSy.js +2 -0
- package/dist/web/assets/MarkdownEditor-C7LnwPSG.js +2 -0
- package/dist/web/assets/MarkdownRenderer-BSMKIlhI.js +155 -0
- package/dist/web/assets/{NativeFolderField-D-0kw2x4.js → NativeFolderField-Dhv4RPD1.js} +1 -1
- package/dist/web/assets/{Notifications-8mf4wQSZ.js → Notifications-DXEO3YYr.js} +1 -1
- package/dist/web/assets/PackageCatalog-B0iUVqDT.js +8 -0
- package/dist/web/assets/{PackageRunDialog-C4MAbUYz.js → PackageRunDialog-CLHkQ8eX.js} +47 -47
- package/dist/web/assets/{PriorityBadge-CzL7cjTr.js → PriorityBadge-CMPd6WIn.js} +1 -1
- package/dist/web/assets/Projects-DspRZmEB.js +3 -0
- package/dist/web/assets/{ResponsiveFilters-BDHgHwbe.js → ResponsiveFilters-DvvXTUvm.js} +1 -1
- package/dist/web/assets/ResumeActions-Cri_ELlT.js +1 -0
- package/dist/web/assets/Rules-DIEUqjom.js +18 -0
- package/dist/web/assets/ScratchpadDiagramEditor-DrhudDAR.js +1 -0
- package/dist/web/assets/Scratchpads-Dx63kejq.js +10 -0
- package/dist/web/assets/{SessionContextChart-CfkrwDME.js → SessionContextChart-DUt9FMyB.js} +1 -1
- package/dist/web/assets/Settings-mBKGeMDZ.js +14 -0
- package/dist/web/assets/Skills-DxA4iJbU.js +3 -0
- package/dist/web/assets/{SourceEditor-DGpMMbEA.js → SourceEditor-D6REoj6r.js} +4 -4
- package/dist/web/assets/TaskDetailSheet-gmBq89hq.js +1 -0
- package/dist/web/assets/Tasks-K21Wd_dl.js +22 -0
- package/dist/web/assets/Terminals-C6dIWjNm.js +1 -0
- package/dist/web/assets/UsageSettings-CCV85_v_.js +1 -0
- package/dist/web/assets/ViewHeader-B2ixMGCg.js +1 -0
- package/dist/web/assets/Webhooks-D7QgOM_f.js +1 -0
- package/dist/web/assets/{badge-DkZMrS1S.js → badge-Cq37de8d.js} +1 -1
- package/dist/web/assets/{button-DeTgVWBh.js → button-DaSTTBls.js} +1 -1
- package/dist/web/assets/chat-DGhEIqmi.js +69 -0
- package/dist/web/assets/chat-ui-chart-CdwnX81S.js +1 -0
- package/dist/web/assets/check-qe2BJPmy.js +1 -0
- package/dist/web/assets/chevron-down-BRt1smOS.js +1 -0
- package/dist/web/assets/{client-C0cF5m6-.js → client-BD4crXth.js} +1 -1
- package/dist/web/assets/coding-agents-UkijH6GA.js +1 -0
- package/dist/web/assets/dialog-CSqhD8HZ.js +1 -0
- package/dist/web/assets/{dist-DxPLB3GS.js → dist-BJbQo-dr.js} +1 -1
- package/dist/web/assets/dist-D8Wfxh48.js +1 -0
- package/dist/web/assets/{dist-CG7sCn9m.js → dist-DWfyUCyc.js} +1 -1
- package/dist/web/assets/{download-vwV9XGjB.js → download-CNL1ZoL6.js} +1 -1
- package/dist/web/assets/file-kind-BYU1kv95.js +1 -0
- package/dist/web/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
- package/dist/web/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
- package/dist/web/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
- package/dist/web/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
- package/dist/web/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
- package/dist/web/assets/highlighted-body-JLMTFACH-Du_UMrf_.js +1 -0
- package/dist/web/assets/index-BHal5gcw.css +1 -0
- package/dist/web/assets/index-Q_RymVqx.js +236 -0
- package/dist/web/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
- package/dist/web/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
- package/dist/web/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
- package/dist/web/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
- package/dist/web/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
- package/dist/web/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
- package/dist/web/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
- package/dist/web/assets/label-dQSF_SAL.js +1 -0
- package/dist/web/assets/{maximize-2-DkkQv64-.js → maximize-2-BAy-8JsG.js} +1 -1
- package/dist/web/assets/mermaid-WFAXDIZX-DSr9ZJx6.js +1 -0
- package/dist/web/assets/{orc-kit-BZEVA3Qv.js → orc-kit-TFHF-l0v.js} +32 -3
- package/dist/web/assets/scroll-area-BnIPAyIC.js +1 -0
- package/dist/web/assets/select-BJy2oop5.js +1 -0
- package/dist/web/assets/{table-BghcPb3T.js → table-CVtwh2DT.js} +1 -1
- package/dist/web/assets/tabs-BvxkGUc3.js +1 -0
- package/dist/web/assets/textarea-Cf2b0PUV.js +1 -0
- package/dist/web/assets/{upload-DM_myzsG.js → upload-DdD8zkeP.js} +1 -1
- package/dist/web/assets/useBackends-wj1KheAL.js +1 -0
- package/dist/web/assets/{useIntegrations-CwksniBf.js → useIntegrations-CsGP9sio.js} +1 -1
- package/dist/web/assets/{useJobs-CLj3jAlx.js → useJobs-DJfPRESN.js} +1 -1
- package/dist/web/assets/{useListSelection-BCmeXReo.js → useListSelection-DUGh7MfO.js} +1 -1
- package/dist/web/assets/{x-BbZ0euHI.js → x-Cli9YXXI.js} +1 -1
- package/dist/web/geist-LICENSE.txt +93 -0
- package/dist/web/index.html +50 -21
- package/dist/web/{ibm-plex-sans-LICENSE.txt → inter-LICENSE.txt} +1 -1
- package/package.json +1 -1
- package/dist/web/assets/Agents-Btw9GSoH.js +0 -34
- package/dist/web/assets/Audit-BrzyRS5i.js +0 -1
- package/dist/web/assets/BarChart-DAz5P98C.js +0 -3
- package/dist/web/assets/Chart-BNguc0T2.js +0 -1
- package/dist/web/assets/ChatAnalyticsCharts-B8DCNbHq.js +0 -1
- package/dist/web/assets/ChatUiRenderer-BR3sfc-Z.js +0 -4
- package/dist/web/assets/ConfirmDialog-CtTOXkX8.js +0 -1
- package/dist/web/assets/Dashboard-BKr-jp7s.css +0 -1
- package/dist/web/assets/Dashboard-C5mM9PJs.js +0 -1
- package/dist/web/assets/DocumentWorkspace-BbG32kAW.js +0 -1
- package/dist/web/assets/FileEditor-BCD6enuO.js +0 -1
- package/dist/web/assets/IntegrationCallback-Bik_7SCS.js +0 -1
- package/dist/web/assets/JobWebhooks-RIKnoQh3.js +0 -1
- package/dist/web/assets/Jobs-CsSOIqGB.js +0 -3
- package/dist/web/assets/Knowledge-DKb5Bndb.js +0 -1
- package/dist/web/assets/MarkdownRenderer-BCh_ruCd.js +0 -313
- package/dist/web/assets/PackageCatalog-DhD3xXBL.js +0 -8
- package/dist/web/assets/Projects-CvtUb494.js +0 -3
- package/dist/web/assets/ResumeActions-CIHfpmTC.js +0 -1
- package/dist/web/assets/Rules-D1bQTlzi.js +0 -18
- package/dist/web/assets/ScratchpadDiagramEditor-DukGReMq.js +0 -1
- package/dist/web/assets/Scratchpads-BPiujcq_.js +0 -10
- package/dist/web/assets/Settings-CM3tx3Gz.js +0 -14
- package/dist/web/assets/Skills-CwHwz6Er.js +0 -3
- package/dist/web/assets/TagInput-FeirXeiF.js +0 -1
- package/dist/web/assets/TaskDetailSheet-CK2rs3F0.js +0 -1
- package/dist/web/assets/Tasks-Dbxfmfm1.js +0 -22
- package/dist/web/assets/Terminals-CeK7rAIg.js +0 -1
- package/dist/web/assets/ViewHeader-CdTYgjcL.js +0 -1
- package/dist/web/assets/Webhooks-1EQvtBPS.js +0 -1
- package/dist/web/assets/check-LRl-dSYs.js +0 -1
- package/dist/web/assets/chevron-down-DtC3kwL9.js +0 -1
- package/dist/web/assets/circle-check-DmFYS6qN.js +0 -1
- package/dist/web/assets/highlighted-body-JLMTFACH-DBFcem9W.js +0 -1
- package/dist/web/assets/ibm-plex-sans-cyrillic-400-normal-BTotfTJu.woff +0 -0
- package/dist/web/assets/ibm-plex-sans-cyrillic-400-normal-DZqxrq2p.woff2 +0 -0
- package/dist/web/assets/ibm-plex-sans-cyrillic-500-normal-ByOcLdNv.woff +0 -0
- package/dist/web/assets/ibm-plex-sans-cyrillic-500-normal-CocWQlwt.woff2 +0 -0
- package/dist/web/assets/ibm-plex-sans-cyrillic-600-normal-71GNu3SW.woff2 +0 -0
- package/dist/web/assets/ibm-plex-sans-cyrillic-600-normal-BGq0mW3O.woff +0 -0
- package/dist/web/assets/ibm-plex-sans-cyrillic-700-normal-D_uavGvn.woff2 +0 -0
- package/dist/web/assets/ibm-plex-sans-cyrillic-700-normal-RFb1v-CK.woff +0 -0
- package/dist/web/assets/ibm-plex-sans-cyrillic-ext-400-normal-Dsrv2Tcn.woff +0 -0
- package/dist/web/assets/ibm-plex-sans-cyrillic-ext-400-normal-g30qAdWV.woff2 +0 -0
- package/dist/web/assets/ibm-plex-sans-cyrillic-ext-500-normal-Cs5J6C77.woff2 +0 -0
- package/dist/web/assets/ibm-plex-sans-cyrillic-ext-500-normal-DB5PtV2g.woff +0 -0
- package/dist/web/assets/ibm-plex-sans-cyrillic-ext-600-normal-Bz0x94Yp.woff +0 -0
- package/dist/web/assets/ibm-plex-sans-cyrillic-ext-600-normal-DUMzJB7m.woff2 +0 -0
- package/dist/web/assets/ibm-plex-sans-cyrillic-ext-700-normal-BmRLXWpJ.woff2 +0 -0
- package/dist/web/assets/ibm-plex-sans-cyrillic-ext-700-normal-DCQwxkRk.woff +0 -0
- package/dist/web/assets/ibm-plex-sans-greek-400-normal-D9ESIMu3.woff +0 -0
- package/dist/web/assets/ibm-plex-sans-greek-400-normal-_efipK4i.woff2 +0 -0
- package/dist/web/assets/ibm-plex-sans-greek-500-normal-CuWXN6rf.woff +0 -0
- package/dist/web/assets/ibm-plex-sans-greek-500-normal-JMMifIXV.woff2 +0 -0
- package/dist/web/assets/ibm-plex-sans-greek-600-normal-D-CqTdkO.woff +0 -0
- package/dist/web/assets/ibm-plex-sans-greek-600-normal-DzTrcv_p.woff2 +0 -0
- package/dist/web/assets/ibm-plex-sans-greek-700-normal-CkZN0sRy.woff +0 -0
- package/dist/web/assets/ibm-plex-sans-greek-700-normal-wyJ6jzdA.woff2 +0 -0
- package/dist/web/assets/ibm-plex-sans-latin-400-normal-CDDApCn2.woff2 +0 -0
- package/dist/web/assets/ibm-plex-sans-latin-400-normal-CYLoc0-x.woff +0 -0
- package/dist/web/assets/ibm-plex-sans-latin-500-normal-6ng42L7E.woff2 +0 -0
- package/dist/web/assets/ibm-plex-sans-latin-500-normal-BgVn5rGT.woff +0 -0
- package/dist/web/assets/ibm-plex-sans-latin-600-normal-Cu4Hd6ag.woff +0 -0
- package/dist/web/assets/ibm-plex-sans-latin-600-normal-CuJfVYMP.woff2 +0 -0
- package/dist/web/assets/ibm-plex-sans-latin-700-normal-Bth3BMcD.woff +0 -0
- package/dist/web/assets/ibm-plex-sans-latin-700-normal-Bxkt5Cjx.woff2 +0 -0
- package/dist/web/assets/ibm-plex-sans-latin-ext-400-normal-C5H60-Va.woff2 +0 -0
- package/dist/web/assets/ibm-plex-sans-latin-ext-400-normal-RBey6euL.woff +0 -0
- package/dist/web/assets/ibm-plex-sans-latin-ext-500-normal-D0aIdm-b.woff +0 -0
- package/dist/web/assets/ibm-plex-sans-latin-ext-500-normal-DakdToA3.woff2 +0 -0
- package/dist/web/assets/ibm-plex-sans-latin-ext-600-normal-DIrixKbi.woff +0 -0
- package/dist/web/assets/ibm-plex-sans-latin-ext-600-normal-DOrvGEcy.woff2 +0 -0
- package/dist/web/assets/ibm-plex-sans-latin-ext-700-normal-DZH6Xh-4.woff +0 -0
- package/dist/web/assets/ibm-plex-sans-latin-ext-700-normal-aMgXseD4.woff2 +0 -0
- package/dist/web/assets/ibm-plex-sans-vietnamese-400-normal-DG4YqDda.woff2 +0 -0
- package/dist/web/assets/ibm-plex-sans-vietnamese-400-normal-fK1oJ5dG.woff +0 -0
- package/dist/web/assets/ibm-plex-sans-vietnamese-500-normal-BEb3_waV.woff +0 -0
- package/dist/web/assets/ibm-plex-sans-vietnamese-500-normal-e4dixQRQ.woff2 +0 -0
- package/dist/web/assets/ibm-plex-sans-vietnamese-600-normal-DgdngZtN.woff +0 -0
- package/dist/web/assets/ibm-plex-sans-vietnamese-600-normal-DpPYBSTl.woff2 +0 -0
- package/dist/web/assets/ibm-plex-sans-vietnamese-700-normal-BV5B8Are.woff +0 -0
- package/dist/web/assets/ibm-plex-sans-vietnamese-700-normal-CkEo6LDy.woff2 +0 -0
- package/dist/web/assets/index-BoyulwgO.js +0 -137
- package/dist/web/assets/index-CMgQ_c5f.css +0 -1
- package/dist/web/assets/mermaid-WFAXDIZX-DX9Leemp.js +0 -1
- package/dist/web/assets/scroll-area-Bz4B8g7w.js +0 -1
- package/dist/web/assets/useMemories-xytUq8G9.js +0 -1
|
@@ -19,7 +19,7 @@ pad, needs no network fetch, and costs the page zero bytes.
|
|
|
19
19
|
Every kit pad starts with a pin so old pads keep their look when the kit evolves:
|
|
20
20
|
|
|
21
21
|
```html
|
|
22
|
-
<meta name="orc-kit" content="
|
|
22
|
+
<meta name="orc-kit" content="2">
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
The dashboard bundles every retired version and renders a pad with exactly the version
|
|
@@ -46,7 +46,7 @@ Bump the `content` only when you intentionally re-style an old pad.
|
|
|
46
46
|
<!doctype html>
|
|
47
47
|
<html>
|
|
48
48
|
<head>
|
|
49
|
-
<meta name="orc-kit" content="
|
|
49
|
+
<meta name="orc-kit" content="2">
|
|
50
50
|
<title>Release status</title>
|
|
51
51
|
</head>
|
|
52
52
|
<body>
|
|
@@ -95,7 +95,7 @@ so your CSS and scripts can inspect them.
|
|
|
95
95
|
|
|
96
96
|
```html
|
|
97
97
|
<!doctype html>
|
|
98
|
-
<html><head><meta name="orc-kit" content="
|
|
98
|
+
<html><head><meta name="orc-kit" content="2"><title>Release status</title></head>
|
|
99
99
|
<body>
|
|
100
100
|
<orc-page>
|
|
101
101
|
<h1>Release status</h1>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{n as r}from"./QueryClientProvider-DlPztvhd.js";import{n as i,t as a}from"./useMutation-CRAWY7v2.js";import{t as o,u as s}from"./chunk-OB3PAWPO-BD6ylT0A.js";import{t as c}from"./button-DaSTTBls.js";import{n as l}from"./client-BD4crXth.js";import{t as u}from"./label-dQSF_SAL.js";import{a as d,n as f,o as p,t as m}from"./dialog-CSqhD8HZ.js";import{Ct as h,Er as g,Ft as _,L as v,Nr as y,Or as b,Pr as x,St as S,X as C,bt as w,kr as T,pi as E,vt as D,yt as O}from"./index-Q_RymVqx.js";import{t as k}from"./ConfirmDialog-TrdcniMK.js";import{i as A,n as j,t as M}from"./PackageRunDialog-CLHkQ8eX.js";import{t as N}from"./ViewHeader-B2ixMGCg.js";import{t as P}from"./useDetailRoute-B-xjWsyW.js";import{t as F}from"./view-params-YEmeZppw.js";var I=e(t(),1),L={specialist:`---
|
|
2
|
+
name: Specialist
|
|
3
|
+
description: Describe when to use this specialist
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
You are a specialist. Define your role, scope, and expected output.
|
|
7
|
+
`,reviewer:`---
|
|
8
|
+
name: Reviewer
|
|
9
|
+
description: Review changes and report actionable findings
|
|
10
|
+
tools:
|
|
11
|
+
Read: true
|
|
12
|
+
Grep: true
|
|
13
|
+
Bash: false
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
Review the working diff. Check correctness, security, and tests. Cite file paths and explain each finding.
|
|
17
|
+
`,builder:`---
|
|
18
|
+
name: Builder
|
|
19
|
+
description: Implement changes and verify the result
|
|
20
|
+
tools:
|
|
21
|
+
Read: true
|
|
22
|
+
Edit: true
|
|
23
|
+
Write: true
|
|
24
|
+
Bash: true
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
Implement the requested change, preserve unrelated work, and run relevant checks. Report the result and any remaining issues.
|
|
28
|
+
`};function R(e){let t=j(e,{stringKeys:!0});if(t.errors.length)throw Error(t.errors[0].message);if(t.warnings.length)throw Error(t.warnings[0].message);if(!A(t.contents))throw Error(`YAML configuration must be a mapping.`);let n=t.toJS({maxAliasCount:100});if(!n||typeof n!=`object`||Array.isArray(n))throw Error(`YAML configuration must be a mapping.`);return JSON.stringify(n),{document:t,fields:n}}function z(e){let t=e.replace(/^\uFEFF/,``).match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n([\s\S]*))?$/);if(!t)throw Error(`Add YAML configuration between --- lines, followed by instructions.`);return{...R(t[1]),body:t[2]??``,newline:e.includes(`\r
|
|
29
|
+
`)?`\r
|
|
30
|
+
`:`
|
|
31
|
+
`,bom:e.startsWith(``)?``:``}}function B(e,t,n){let r=z(e);n===void 0?r.document.delete(t):r.document.set(t,n);let i=r.document.toString().trimEnd().replace(/\n/g,r.newline);return`${r.bom}---${r.newline}${i}${r.newline}---${r.newline}${r.body}`}function V(e,t){let n=e.match(/^((?:\uFEFF)?---\r?\n[\s\S]*?\r?\n---)(?:\r?\n[\s\S]*)?$/)?.[1];if(!n)throw Error(`Missing YAML configuration.`);return`${n}${e.includes(`\r
|
|
32
|
+
`)?`\r
|
|
33
|
+
`:`
|
|
34
|
+
`}${t}`}function H(e){let t=e.tools;if(t===void 0)return[];if(typeof t==`string`)return t.split(/[\s,]+/).filter(Boolean).map(e=>({name:e,allowed:!0}));if(Array.isArray(t)&&t.every(e=>typeof e==`string`))return t.map(e=>({name:e,allowed:!0}));if(t&&typeof t==`object`&&!Array.isArray(t))return Object.entries(t).map(([e,t])=>{if(typeof t!=`boolean`)throw Error(`Tool "${e}" must be true or false.`);return{name:e,allowed:t}});throw Error(`Tools must be a mapping of names to true/false, a list, or a string.`)}function U(e,t){let n=z(e);A(n.document.get(`tools`,!0))||n.document.set(`tools`,{});let r=n.document.get(`tools`,!0);if(A(r))for(let{name:e}of H(n.fields))t.some(t=>t.name===e)||n.document.deleteIn([`tools`,e]);for(let e of t)n.document.setIn([`tools`,e.name],e.allowed);return`${n.bom}---${n.newline}${n.document.toString().trimEnd().replace(/\n/g,n.newline)}${n.newline}---${n.newline}${n.body}`}var W=n();function G(e){return H(e).map(e=>({...e,key:crypto.randomUUID()}))}function K({agent:e,pending:t,error:n,onSave:r}){let[i,a]=(0,I.useState)(e?.id??``),[o,s]=(0,I.useState)(e?.raw??L.specialist),[l,m]=(0,I.useState)(`fields`),[h,g]=(0,I.useState)(()=>e?G(e.fields):[]),[v,b]=(0,I.useState)(),S=(0,I.useMemo)(()=>{try{return{value:z(o),error:void 0}}catch(e){return{value:void 0,error:e.message}}},[o]),C=S.value?.fields,w;h.some(e=>!e.name.trim())?w=`Enter a name for every tool.`:new Set(h.map(e=>e.name.trim())).size!==h.length&&(w=`Tool names must be unique.`);let T=e?`Save changes`:`Create agent`;function E(e){g(e),e.every(e=>e.name.trim())&&new Set(e.map(e=>e.name.trim())).size===e.length&&s(U(o,e.map(e=>({...e,name:e.name.trim()}))))}function D(){if(b(void 0),l===`fields`){if(w)return;m(`source`)}else try{let e=z(o);for(let t of[`name`,`description`,`model`,`color`])if(e.fields[t]!==void 0&&typeof e.fields[t]!=`string`)throw Error(`${t} must be a string to edit it in the form.`);g(G(e.fields)),m(`fields`)}catch(e){b(e.message)}}return(0,W.jsxs)(f,{className:`max-w-3xl max-h-[90vh] overflow-y-auto`,children:[(0,W.jsx)(d,{children:(0,W.jsx)(p,{children:e?`Edit ${e.name}`:`New shared agent`})}),(0,W.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e.preventDefault(),r(i,o)},children:[(0,W.jsxs)(`fieldset`,{disabled:t,className:`space-y-4`,children:[!e&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(u,{htmlFor:`agent-template`,children:`Starting template`}),(0,W.jsxs)(`select`,{id:`agent-template`,"data-testid":`agent-template`,className:`w-full border rounded-xs p-2 bg-surface`,defaultValue:`specialist`,onChange:e=>{let t=L[e.target.value];s(t),g(G(z(t).fields)),b(void 0)},children:[(0,W.jsx)(`option`,{value:`specialist`,children:`General specialist`}),(0,W.jsx)(`option`,{value:`reviewer`,children:`Reviewer`}),(0,W.jsx)(`option`,{value:`builder`,children:`Builder`})]})]}),(0,W.jsx)(u,{htmlFor:`agent-id`,children:`Agent ID`}),(0,W.jsx)(y,{id:`agent-id`,"data-testid":`agent-id-input`,value:i,disabled:!!e,onChange:e=>a(e.target.value),placeholder:`security-review`}),(0,W.jsx)(c,{type:`button`,variant:`outline`,"data-testid":`agent-editor-mode`,onClick:D,disabled:l===`fields`&&!!w,children:l===`fields`?`Edit YAML + Markdown`:`Edit fields`}),l===`source`?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(u,{htmlFor:`agent-definition`,children:`YAML configuration + Markdown instructions`}),(0,W.jsx)(_,{id:`agent-definition`,testId:`agent-content-input`,path:`agent.agent.md`,readOnly:t,height:400,value:o,onChange:e=>{s(e),b(void 0)}})]}):C&&(0,W.jsxs)(W.Fragment,{children:[[[`name`,`Name`],[`description`,`Description`],[`model`,`Model (optional)`],[`color`,`Color (optional)`]].map(([e,t])=>(0,W.jsxs)(`div`,{className:`space-y-1`,children:[(0,W.jsx)(u,{htmlFor:`agent-${e}`,children:t}),(0,W.jsx)(y,{id:`agent-${e}`,"data-testid":`agent-${e}-input`,value:typeof C[e]==`string`?C[e]:``,onChange:t=>s(B(o,e,t.target.value||(e===`description`?``:void 0)))})]},e)),(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,W.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,W.jsx)(`input`,{"data-testid":`agent-custom-tools`,type:`checkbox`,checked:C.tools!==void 0,onChange:e=>{g([]),s(B(o,`tools`,e.target.checked?{}:void 0))}}),` `,`Customize tool access`]}),(0,W.jsx)(x,{label:`Customize tool access`,testId:`agent-custom-tools-help`,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.`})]}),C.tools!==void 0&&(0,W.jsxs)(W.Fragment,{children:[h.map((e,t)=>(0,W.jsxs)(`div`,{"data-testid":`agent-tool-row`,className:`flex items-center gap-2`,children:[(0,W.jsx)(y,{"data-testid":`agent-tool-name`,"aria-label":`Tool ${t+1} name`,value:e.name,list:`agent-tool-suggestions`,onChange:e=>E(h.map((n,r)=>r===t?{...n,name:e.target.value}:n))}),(0,W.jsxs)(`label`,{className:`flex items-center gap-1 text-sm`,children:[(0,W.jsx)(`input`,{"data-testid":`agent-tool-allowed`,type:`checkbox`,checked:e.allowed,onChange:e=>E(h.map((n,r)=>r===t?{...n,allowed:e.target.checked}:n))}),` `,`Allowed`]}),(0,W.jsx)(c,{"data-testid":`agent-tool-remove`,type:`button`,variant:`outline`,onClick:()=>E(h.filter((e,n)=>n!==t)),children:`Remove`})]},e.key)),(0,W.jsx)(`datalist`,{id:`agent-tool-suggestions`,children:[`Read`,`Grep`,`Glob`,`Edit`,`Write`,`Bash`].map(e=>(0,W.jsx)(`option`,{value:e},e))}),(0,W.jsx)(c,{"data-testid":`agent-tool-add`,type:`button`,variant:`outline`,onClick:()=>E([...h,{key:crypto.randomUUID(),name:``,allowed:!0}]),children:`Add tool`})]})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,W.jsx)(u,{htmlFor:`agent-instructions`,children:`Instructions`}),(0,W.jsx)(x,{label:`Instructions`,testId:`agent-instructions-help`,children:`Use YAML + Markdown to edit handoffs and additional configuration. Custom fields are preserved.`})]}),(0,W.jsx)(_,{id:`agent-instructions`,testId:`agent-instructions-input`,path:`instructions.md`,readOnly:t,height:240,value:S.value?.body??``,onChange:e=>s(V(o,e))})]})]}),(n||S.error||v||l===`fields`&&w)&&(0,W.jsx)(`p`,{"data-testid":`agent-editor-error`,role:`alert`,className:`text-destructive`,children:n||S.error||v||w}),(0,W.jsx)(c,{"data-testid":`agent-submit`,type:`submit`,disabled:t||!i.trim()||!o.trim()||!!S.error||l===`fields`&&!!w,children:t?`Saving...`:T})]})]})}function q(){let e=s(),t=new URLSearchParams(e.search).get(`project`)??`all`,[n,u]=F(`editorMode`,`read`,[`read`,`edit`,`split`]),[d,f]=F(`agentQuery`,``),p=r(),A=i({queryKey:[`agents`],queryFn:()=>l.agents.list()}),{selectedId:j,openDetail:L,closeDetail:R}=P(`/packages/agents`,`agentId`),z=i({queryKey:[`agent`,j],queryFn:()=>l.agents.get(j),enabled:!!j}),[B,V]=(0,I.useState)(!1),[H,U]=(0,I.useState)(),[G,q]=(0,I.useState)(!1),[J,Y]=(0,I.useState)(),X=a({mutationFn:l.agents.create,onSuccess:()=>{p.invalidateQueries({queryKey:[`agents`]}),V(!1)}}),Z=a({mutationFn:l.agents.delete,onSuccess:()=>{q(!1),R(),p.invalidateQueries({queryKey:[`agents`]}),p.invalidateQueries({queryKey:[`agent-packages`]}),p.invalidateQueries({queryKey:[`agent`]})}}),Q=a({mutationFn:({profile:e,content:t})=>l.agents.update(e.id,{content:t,expectedRaw:e.raw,expectedPath:e.path}),onSuccess:e=>{p.setQueryData([`agent`,e.id],e),p.invalidateQueries({queryKey:[`agents`]}),p.invalidateQueries({queryKey:[`agent-packages`]}),U(void 0)}});if(A.error)return(0,W.jsx)(C,{message:A.error.message,onRetry:()=>void A.refetch()});let $=(A.data?.agents??[]).filter(e=>`${e.name} ${e.id} ${e.description}`.toLowerCase().includes(d.toLowerCase()));return(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsx)(N,{title:`Agents`,level:1,meta:A.data?.agents.length??0,help:`Shared specialist instructions, models and tools for connected coding agents. Add definitions to packages for reuse.`,action:(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,W.jsxs)(g,{children:[(0,W.jsx)(T,{asChild:!0,children:(0,W.jsx)(c,{variant:`ghost`,size:`icon`,"data-testid":`agent-actions-menu`,"aria-label":`Agent resources`,children:(0,W.jsx)(E,{size:16})})}),(0,W.jsxs)(b,{"aria-label":`Agent resources`,align:`end`,className:`w-60 space-y-1 p-1`,children:[(0,W.jsx)(c,{asChild:!0,variant:`ghost`,className:`w-full justify-start`,children:(0,W.jsx)(o,{to:v(`/packages`,t,e.search),"data-testid":`agents-packages-link`,children:`Manage packages`})}),(0,W.jsx)(`a`,{className:`block rounded-md px-3 py-2 text-xs text-muted-foreground hover:bg-surface focus-visible:outline focus-visible:outline-2 focus-visible:outline-focus`,href:`https://microsoft.github.io/apm/producer/author-primitives/instructions-and-agents/`,target:`_blank`,rel:`noreferrer`,children:`APM agent format`})]})]}),(0,W.jsx)(c,{"data-testid":`new-agent-button`,onClick:()=>{X.reset(),V(!0)},children:`New agent`})]})}),(A.data?.broken??[]).map(e=>(0,W.jsxs)(`p`,{role:`alert`,className:`text-destructive`,children:[e.path,`: `,e.error]},e.path)),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,W.jsx)(y,{className:`min-w-[180px] max-w-lg flex-1`,"aria-label":`Find an agent`,placeholder:`Find an agent by name or purpose…`,value:d,onChange:e=>f(e.target.value,{replace:!0})}),d&&(0,W.jsx)(c,{variant:`ghost`,onClick:()=>f(``),children:`Clear`})]}),(0,W.jsxs)(`div`,{className:`space-y-2`,children:[A.isLoading&&(0,W.jsx)(`p`,{role:`status`,"data-testid":`page-loading`,children:`Loading agents…`}),$.map(e=>(0,W.jsxs)(`button`,{type:`button`,"data-testid":`agent-row`,"data-agent-id":e.id,onClick:()=>L(e.id),className:`grid w-full gap-x-6 gap-y-1 border-b border-outline-variant px-2 py-3 text-left hover:bg-surface-low sm:grid-cols-[minmax(0,1fr)_minmax(0,2fr)]`,children:[(0,W.jsx)(`span`,{className:`block wrap-break-word text-sm font-medium`,children:e.name}),(0,W.jsxs)(`span`,{className:`block truncate text-xs text-muted-foreground sm:col-start-1 sm:row-start-2`,title:`${e.id} · ${e.source}`,children:[e.id,` · `,e.source]}),(0,W.jsx)(`p`,{className:`line-clamp-2 wrap-break-word text-sm leading-relaxed text-muted-foreground sm:col-start-2 sm:row-start-1 sm:row-span-2`,children:e.description})]},e.id)),!A.isLoading&&!$.length&&(0,W.jsx)(`p`,{"data-testid":`page-empty`,className:`text-sm text-muted-foreground`,children:d?`No agents match this search. Try another name or clear the filter.`:`Create an agent or import specialists from Packages.`})]}),(0,W.jsx)(D,{open:!!j,onOpenChange:e=>!e&&R(),children:(0,W.jsxs)(w,{defaultWidth:860,resizeKey:`agents`,"data-testid":`agent-detail-sheet`,children:[(0,W.jsx)(S,{children:(0,W.jsx)(h,{children:z.data?.name??`Agent profile`})}),(0,W.jsx)(O,{children:z.error?(0,W.jsx)(C,{message:z.error.message,onRetry:()=>void z.refetch()}):z.data?(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsx)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:z.data.description}),(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 border-b border-outline-variant pb-3`,"data-testid":`agent-actions`,children:[(0,W.jsx)(c,{size:`sm`,"data-testid":`agent-launch`,onClick:()=>z.data&&Y({name:`agent-launch`,packages:[],backend:z.data.fields.tools===void 0?`codex`:`claude`,tool:`apm`,cwd:``,agent:z.data.id,prompt:``}),children:`Launch agent`}),(0,W.jsx)(c,{size:`sm`,"data-testid":`agent-edit`,variant:`ghost`,onClick:async()=>{Q.reset();let e=await z.refetch();e.data&&U(e.data)},children:`Edit agent`}),(0,W.jsx)(c,{size:`sm`,"data-testid":`agent-delete`,variant:`ghost`,className:`ml-auto text-error`,onClick:()=>{Z.reset(),q(!0)},disabled:Z.isPending,children:`Delete`})]}),Z.error&&(0,W.jsx)(`p`,{"data-testid":`agent-delete-error`,role:`alert`,className:`text-destructive`,children:Z.error.message}),(0,W.jsxs)(`dl`,{className:`grid grid-cols-2 gap-4 text-sm`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Model`}),(0,W.jsx)(`dd`,{className:`mt-1 wrap-break-word`,children:z.data.fields.model??`Coding-agent default`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Tools`}),(0,W.jsx)(`dd`,{className:`mt-1`,children:z.data.fields.tools===void 0?`Coding-agent default`:`Defined by this agent; requires Claude`})]})]}),(0,W.jsx)(`h4`,{className:`text-sm font-medium`,children:`Instructions`}),(0,W.jsx)(_,{path:`agent.agent.md`,mode:n,onModeChange:u,value:z.data.raw,readOnly:!0,layout:`page`,hideFrontmatter:!0,pageTitle:z.data.name,testId:`agent-content`}),(0,W.jsxs)(`details`,{className:`border-t border-outline-variant pt-3 text-sm`,children:[(0,W.jsx)(`summary`,{className:`cursor-pointer text-muted-foreground`,children:`Source and configuration`}),(0,W.jsxs)(`div`,{className:`my-3 flex items-center gap-1`,children:[(0,W.jsxs)(`p`,{className:`text-xs text-muted-foreground break-all`,children:[z.data.id,` · `,z.data.source,` definition`]}),(0,W.jsxs)(x,{label:`Using this agent in a flow`,testId:`agent-flow-help`,children:[`To use this agent in a flow, set `,(0,W.jsxs)(`code`,{children:[`"agent": "`,z.data.id,`"`]}),` on its agent node.`]})]}),(0,W.jsx)(`pre`,{"data-testid":`agent-fields`,className:`max-h-80 overflow-auto rounded bg-background p-3 text-xs`,children:JSON.stringify(z.data.fields,null,2)})]})]}):(0,W.jsx)(`p`,{children:`Loading...`})})]})}),(0,W.jsx)(k,{open:G,title:`Delete ${z.data?.name??`agent`}?`,description:`This permanently deletes the agent definition "${j}". Other agents and package resources are kept. Flows referencing this agent will need another profile.`,isPending:Z.isPending,onCancel:()=>!Z.isPending&&q(!1),onConfirm:()=>{j&&Z.mutate(j,{onError:()=>q(!1)})}}),J&&(0,W.jsx)(M,{initial:J,onClose:()=>Y(void 0)}),(0,W.jsx)(m,{open:B,onOpenChange:e=>!X.isPending&&V(e),children:B&&(0,W.jsx)(K,{pending:X.isPending,error:X.error?.message,onSave:(e,t)=>X.mutate({id:e,content:t})})}),(0,W.jsx)(m,{open:!!H,onOpenChange:e=>!e&&!Q.isPending&&U(void 0),children:H&&(0,W.jsx)(K,{agent:H,pending:Q.isPending,error:Q.error?.message,onSave:(e,t)=>Q.mutate({profile:H,content:t})},H.id)})]})}export{q as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{n as r}from"./useMutation-CRAWY7v2.js";import{u as i}from"./chunk-OB3PAWPO-BD6ylT0A.js";import{t as a}from"./button-DaSTTBls.js";import{n as o}from"./client-BD4crXth.js";import{t as s}from"./chevron-down-BRt1smOS.js";import{t as c}from"./ResponsiveFilters-DvvXTUvm.js";import{t as l}from"./scroll-area-BnIPAyIC.js";import{t as u}from"./Markdown-wp7JBOSy.js";import{Ct as d,Gr as f,Jt as p,Pt as m,St as h,X as g,Yt as _,_t as v,bi as y,bt as ee,dr as b,vt as x,xi as S,yt as C}from"./index-Q_RymVqx.js";import{t as w}from"./ViewHeader-B2ixMGCg.js";import{t as T}from"./useDetailRoute-B-xjWsyW.js";import{t as E}from"./view-params-YEmeZppw.js";import{t as D}from"./EmptyState-YM4VSLR9.js";import{a as O,i as k,n as te,o as A,r as j,t as M}from"./table-CVtwh2DT.js";import{t as N}from"./useProjectScope-DpgzthH7.js";var P=e(t(),1),F=n(),I=[`all`,`notification`,`human_request`,`job_run`,`task`,`settings`,`job`,`rule`,`terminal`,`auth`,`memory`,`skill`,`kb`],L={all:`All events`,notification:`Notifications`,human_request:`Human requests`,job_run:`Job runs`,task:`Tasks`,settings:`Settings`,job:`Jobs`,rule:`Rules`,terminal:`Terminals`,auth:`Sign-ins`,memory:`Memories`,skill:`Skills`,kb:`Knowledge`},R=100;function z(e){let t=e.replace(/[._-]/g,` `);return t.charAt(0).toUpperCase()+t.slice(1)}function B(e,t=0){return typeof e==`string`?e.length>500?`${e.slice(0,500)}…`:e:!e||typeof e!=`object`?e:t>=3?`…`:Array.isArray(e)?e.slice(0,10).map(e=>B(e,t+1)):Object.fromEntries(Object.entries(e).slice(0,12).map(([e,n])=>[e,B(n,t+1)]))}function V(e){let t=JSON.stringify(B(e),null,2);return t.length>4e3?`${t.slice(0,4e3)}\n…`:t}function H({entry:e}){let[t,n]=(0,P.useState)(!1),r=new Date(e.created_at*1e3),i=e.subject_ids.slice(0,3).join(`, `)||`Workspace`;return(0,F.jsx)(`li`,{children:(0,F.jsxs)(`details`,{"data-testid":`audit-event`,className:`group py-1`,onToggle:e=>n(e.currentTarget.open),children:[(0,F.jsxs)(`summary`,{className:`grid min-h-11 cursor-pointer list-inside grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 gap-y-1 rounded py-2 text-sm focus-visible:outline-2 focus-visible:outline-focus md:min-h-9 md:grid-cols-[minmax(12rem,1fr)_minmax(0,1fr)_auto]`,children:[(0,F.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1 font-medium`,children:[(0,F.jsx)(y,{className:`size-3 shrink-0 transition-transform group-open:rotate-90`}),z(e.action)]}),(0,F.jsx)(`span`,{className:`col-start-1 min-w-0 truncate text-xs text-outline md:col-start-auto`,title:i,children:i}),(0,F.jsx)(`time`,{dateTime:r.toISOString(),className:`col-start-2 row-start-1 whitespace-nowrap text-xs text-outline md:col-start-auto md:row-start-auto`,children:r.toLocaleString()})]}),t&&(0,F.jsxs)(`div`,{className:`space-y-2 pb-3 pl-3 text-xs text-outline`,children:[(0,F.jsxs)(`p`,{children:[`Project: `,e.project_id??`Unassigned`,` · Actor: `,e.actor??`Not recorded`]}),e.session_id&&(0,F.jsxs)(`p`,{className:`break-all`,children:[`Session: `,e.session_id]}),e.result_ids.length>0&&(0,F.jsxs)(`p`,{className:`break-all`,children:[`Results: `,e.result_ids.slice(0,10).join(`, `)]}),e.note&&(0,F.jsx)(`p`,{className:`whitespace-pre-wrap break-words`,children:e.note.slice(0,1e3)}),e.snapshot!==null&&e.snapshot!==void 0&&(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`p`,{className:`mb-1`,children:`Metadata preview`}),(0,F.jsx)(`pre`,{"data-testid":`audit-event-metadata`,className:`max-h-56 overflow-auto whitespace-pre-wrap break-all text-xs text-on-surface`,children:V(e.snapshot)})]})]})]})})}function U({projectId:e}){let[t,n]=E(`auditEntity`,`all`,I),i=r({queryKey:[`audit`,`events`,e,t],queryFn:()=>o.audit.list({...e===`all`?{scope:`all`}:e===`unassigned`?{scope:`global`}:{project_id:e},...t===`all`?{}:{entity_type:t},limit:R,snapshot:`preview`}),retry:!1});return(0,F.jsxs)(`section`,{"aria-label":`Audit events`,"data-testid":`audit-events`,className:`min-w-0`,children:[(0,F.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center justify-between gap-2`,children:[(0,F.jsxs)(`p`,{className:`text-xs text-outline`,children:[`Up to `,R,` newest events`]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(c,{activeCount:t===`all`?0:1,children:(0,F.jsx)(`select`,{"aria-label":`Audit event type`,"data-testid":`audit-event-filter`,className:`form-control form-control-single`,value:t,onChange:e=>n(e.target.value),children:I.map(e=>(0,F.jsx)(`option`,{value:e,children:L[e]},e))})}),(0,F.jsxs)(a,{variant:`ghost`,size:`sm`,onClick:()=>void i.refetch(),disabled:i.isFetching,"data-testid":`audit-events-refresh`,children:[(0,F.jsx)(f,{className:`size-4`}),`Refresh`]})]})]}),i.isLoading&&(0,F.jsx)(`p`,{role:`status`,className:`py-4 text-sm text-outline`,children:`Loading events…`}),i.error&&(0,F.jsxs)(`p`,{role:`alert`,className:`py-3 text-sm text-error`,children:[`Could not load audit events: `,i.error.message]}),!i.isLoading&&!i.error&&i.data?.entries.length===0&&(0,F.jsx)(`p`,{className:`py-6 text-sm text-outline`,children:`No audit events in this scope.`}),i.data&&(0,F.jsx)(`ol`,{className:`divide-y divide-border`,children:i.data.entries.map(e=>(0,F.jsx)(H,{entry:e},e.id))})]})}var W=`inline-flex min-h-11 items-center gap-1 font-label text-xs text-primary hover:text-on-surface disabled:opacity-40 disabled:hover:text-primary`;function G({page:e,pageSize:t,total:n,onPage:r}){let i=Math.max(1,Math.ceil(n/t));if(n<=t)return null;let a=e*t+1,o=Math.min(n,(e+1)*t);return(0,F.jsxs)(`div`,{"data-testid":`pager`,className:`flex flex-wrap gap-2 items-center justify-between border-t border-surface-highest px-3 py-2`,children:[(0,F.jsxs)(`span`,{className:`font-label text-xs text-outline`,children:[a,`–`,o,` of `,n]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,F.jsxs)(`button`,{type:`button`,"data-testid":`pager-prev`,className:W,disabled:e===0,onClick:()=>r(e-1),children:[(0,F.jsx)(S,{className:`h-3 w-3`}),`Prev`]}),(0,F.jsxs)(`span`,{className:`font-label text-xs text-outline`,children:[`Page `,e+1,` / `,i]}),(0,F.jsxs)(`button`,{type:`button`,"data-testid":`pager-next`,className:W,disabled:e>=i-1,onClick:()=>r(e+1),children:[`Next`,(0,F.jsx)(y,{className:`h-3 w-3`})]})]})]})}var K={file:`text-outline`,task:`text-outline`,decision:`text-outline`,error:`text-error`,git:`text-outline`,rule:`text-outline`,plan:`text-outline`},q=`text-outline`;function J(e){return K[e]??q}function Y({sessionId:e,open:t,onClose:n}){let{data:r,isLoading:i,error:a,refetch:o}=_(e??``);return(0,F.jsx)(x,{open:t,onOpenChange:e=>!e&&n(),children:(0,F.jsxs)(ee,{side:`right`,defaultWidth:540,resizeKey:`sessions`,children:[(0,F.jsx)(h,{children:(0,F.jsx)(d,{children:i?`Loading...`:r?`${r.agent??`Session`} ${r.agent_version?`v${r.agent_version}`:``}`:`Session Detail`})}),(0,F.jsxs)(C,{children:[(0,F.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.`}),a?(0,F.jsx)(g,{message:a.message,onRetry:()=>o()}):i?(0,F.jsx)(`div`,{className:`space-y-4`,children:[...[,,,,]].map((e,t)=>(0,F.jsx)(v,{className:`h-8 w-full bg-surface-highest`},t))}):r?(0,F.jsxs)(`div`,{className:`space-y-6`,children:[r.summary&&(0,F.jsx)(`div`,{className:`font-body text-xs text-on-surface leading-relaxed`,children:(0,F.jsx)(u,{children:r.summary})}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-4`,children:[(0,F.jsx)(m,{label:`ID`,children:(0,F.jsx)(`span`,{className:`font-mono text-xs break-all`,children:r.id})}),(0,F.jsx)(m,{label:`Project ID`,children:r.project_id??`—`}),(0,F.jsx)(m,{label:`Job Run ID`,children:r.job_run_id??`—`}),(0,F.jsx)(m,{label:`Tokens Used`,children:r.tokens_used==null?`—`:r.tokens_used.toLocaleString()}),(0,F.jsx)(m,{label:`Created`,children:new Date(r.created_at).toLocaleString()})]}),r.events.length>0&&(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`font-label text-xs font-medium text-outline mb-3`,children:[`Events (`,r.events.length,`)`]}),(0,F.jsx)(l,{className:`h-[300px]`,children:(0,F.jsx)(`div`,{className:`space-y-1`,children:[...r.events].sort((e,t)=>new Date(e.created_at).getTime()-new Date(t.created_at).getTime()).map(e=>(0,F.jsx)(X,{event:e},e.id))})})]}),r.snapshot&&(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{className:`font-label text-xs font-medium text-outline mb-3`,children:`Snapshot`}),(0,F.jsx)(l,{className:`h-[200px]`,children:(0,F.jsx)(`pre`,{className:`font-mono text-xs text-on-surface-variant whitespace-pre-wrap wrap-break-word bg-background border-l border-border p-3`,children:r.snapshot})})]})]}):(0,F.jsx)(`div`,{className:`font-body text-xs text-outline py-8 text-center`,children:`Session not found`})]})]})})}function X({event:e}){let[t,n]=(0,P.useState)(!1),r=e.data!=null;return(0,F.jsxs)(`div`,{className:`border-b border-border/65`,children:[(0,F.jsxs)(`button`,{type:`button`,className:`w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-surface-high transition-colors`,onClick:()=>r&&n(!t),"aria-expanded":r?t:void 0,children:[r?t?(0,F.jsx)(s,{size:10,className:`text-outline shrink-0`}):(0,F.jsx)(y,{size:10,className:`text-outline shrink-0`}):(0,F.jsx)(`span`,{className:`w-[10px] shrink-0`}),(0,F.jsx)(`span`,{className:`inline-flex items-center px-1.5 py-0.5 text-[10px] font-label font-medium ${J(e.type)}`,children:e.type}),(0,F.jsx)(`span`,{className:`flex-1 font-body text-xs text-outline truncate`,children:Z(e.data)}),(0,F.jsx)(`span`,{className:`font-label text-[10px] text-outline shrink-0`,children:new Date(e.created_at).toLocaleTimeString()})]}),t&&r&&(0,F.jsx)(`div`,{className:`px-3 pb-2`,children:(0,F.jsx)(`pre`,{className:`font-mono text-xs text-on-surface-variant whitespace-pre-wrap wrap-break-word bg-background border-l border-border/65 p-2 max-h-48 overflow-auto`,children:JSON.stringify(e.data,null,2)})})]})}function Z(e){if(e==null)return``;if(typeof e==`string`)return e;if(typeof e==`object`){let t=e;if(typeof t.path==`string`)return t.path;if(typeof t.content==`string`)return t.content.length>80?`${t.content.slice(0,80)}...`:t.content;if(typeof t.message==`string`)return t.message;if(typeof t.summary==`string`)return t.summary;let n=Object.keys(t);return n.length<=3?n.join(`, `):`${n.length} fields`}return String(e)}var Q=25,$=`font-label text-xs font-medium text-outline`;function ne({projectId:e}){let t=b(`xl`),[n,r]=E(`order`,`desc`,[`asc`,`desc`]),[i,a]=(0,P.useState)({order:n,page:0}),o=i.order===n?i.page:0,s=e=>a({order:n,page:e}),{selectedId:c,openDetail:l,closeDetail:u}=T(`/audit`,`sessionId`),{data:d,isLoading:f,error:m,refetch:h}=p({...e===`all`?{}:{project_id:e},limit:Q,offset:o*Q,order:n});if(m)return(0,F.jsx)(g,{message:m.message,onRetry:()=>h()});let _=d?.sessions??[],y=d?.total??0;return(0,F.jsxs)(`section`,{"data-testid":`logged-sessions`,children:[(0,F.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center justify-between gap-2`,children:[(0,F.jsxs)(`span`,{className:`text-xs text-outline`,children:[y,` records`]}),(0,F.jsxs)(`select`,{"aria-label":`Sort audit by date`,"data-testid":`audit-date-sort`,value:n,onChange:e=>{s(0),r(e.target.value)},className:`form-control form-control-single w-auto max-w-full`,children:[(0,F.jsx)(`option`,{value:`desc`,children:`Created: newest first`}),(0,F.jsx)(`option`,{value:`asc`,children:`Created: oldest first`})]})]}),f?(0,F.jsx)(`div`,{className:`space-y-2`,children:[...[,,,,,]].map((e,t)=>(0,F.jsx)(v,{className:`h-10 w-full bg-surface-highest`},t))}):_.length===0?(0,F.jsx)(D,{message:`No audit records`}):(0,F.jsxs)(`div`,{className:`min-w-0 overflow-hidden`,children:[t?(0,F.jsxs)(M,{children:[(0,F.jsx)(O,{children:(0,F.jsxs)(A,{className:`border-b border-border hover:bg-transparent`,children:[(0,F.jsx)(k,{className:$,children:`Agent`}),(0,F.jsx)(k,{className:`${$} w-24`,children:`Version`}),(0,F.jsx)(k,{className:$,children:`Summary`}),(0,F.jsx)(k,{className:`${$} w-24`,children:`Project`}),(0,F.jsx)(k,{className:`${$} w-28`,children:`Tokens used`}),(0,F.jsx)(k,{className:`${$} w-36`,children:`Created`})]})}),(0,F.jsx)(te,{children:_.map(e=>(0,F.jsxs)(A,{"data-testid":`session-row`,"data-session-id":e.id,className:`border-b border-border/65 hover:bg-surface-high cursor-pointer`,onClick:()=>l(e.id),children:[(0,F.jsx)(j,{className:`font-label text-xs text-primary`,children:(0,F.jsx)(`button`,{type:`button`,className:`text-left font-medium hover:underline`,onClick:t=>{t.stopPropagation(),l(e.id)},children:e.agent??`Session`})}),(0,F.jsx)(j,{className:`font-label text-xs text-outline`,children:e.agent_version??`-`}),(0,F.jsx)(j,{className:`font-body text-xs text-on-surface-variant max-w-sm truncate`,children:e.summary??`-`}),(0,F.jsx)(j,{className:`font-label text-xs text-outline`,children:e.project_id?e.project_id.slice(-6):`-`}),(0,F.jsx)(j,{className:`font-label text-xs text-outline text-right`,children:e.tokens_used==null?`-`:e.tokens_used.toLocaleString()}),(0,F.jsx)(j,{className:`font-label text-xs text-outline`,children:new Date(e.created_at).toLocaleString()})]},e.id))})]}):(0,F.jsx)(`div`,{className:`divide-y divide-border`,children:_.map(e=>(0,F.jsxs)(`article`,{"data-testid":`session-row`,"data-session-id":e.id,className:`py-3 space-y-2`,children:[(0,F.jsx)(`button`,{type:`button`,className:`min-h-8 text-sm text-left font-medium text-primary wrap-break-word`,onClick:()=>l(e.id),children:e.agent??`Session`}),(0,F.jsx)(`p`,{className:`text-sm leading-relaxed text-on-surface wrap-break-word`,children:e.summary??`No summary recorded`}),(0,F.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-2 text-xs text-outline`,children:[(0,F.jsxs)(`span`,{children:[`Version `,e.agent_version??`-`]}),(0,F.jsxs)(`span`,{children:[e.tokens_used?.toLocaleString()??`-`,` tokens`]}),(0,F.jsx)(`span`,{children:e.project_id?`Project ${e.project_id.slice(-6)}`:`Unassigned`}),(0,F.jsx)(`span`,{children:new Date(e.created_at).toLocaleString()})]})]},e.id))}),(0,F.jsx)(G,{page:o,pageSize:Q,total:y,onPage:s})]}),(0,F.jsx)(Y,{sessionId:c,open:!!c,onClose:u})]})}function re({projectId:e}){let t=N(e),n=i(),r=n.pathname.startsWith(`/audit/`)||n.hash===`#records`||new URLSearchParams(n.search).has(`agent`)||new URLSearchParams(n.search).has(`order`),[a,o]=(0,P.useState)(r);return(0,P.useEffect)(()=>{r&&o(!0)},[r]),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(w,{title:`Audit`,help:`Meaningful workspace changes, request and job outcomes, and notification history. Events remain until the configured audit retention expires.`}),(0,F.jsx)(U,{projectId:t},t),(0,F.jsxs)(`details`,{open:a,onToggle:e=>o(e.currentTarget.open),"data-testid":`audit-session-history`,className:`mt-6 border-t border-border pt-3`,children:[(0,F.jsx)(`summary`,{className:`min-h-11 cursor-pointer py-2 text-sm font-medium md:min-h-8`,children:`Logged session history`}),(0,F.jsx)(ne,{projectId:t},t)]})]})}export{re as default};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t}from"./jsx-runtime-CVMpzJz9.js";import{t as n}from"./clsx-DB0hHKMi.js";import{$ as r,A as i,At as a,B as o,C as s,Ct as c,D as l,Dt as u,E as d,Et as f,Ft as p,G as m,Ht as h,I as g,It as _,K as v,L as ee,Lt as y,Mt as te,Nt as b,O as x,Ot as S,Q as C,R as w,S as T,T as E,Tt as D,U as O,V as k,Vt as A,W as j,X as M,Z as N,_t as ne,at as P,b as re,bt as ie,ct as F,et as ae,ft as oe,gt as se,ht as ce,j as le,jt as I,kt as ue,l as de,lt as fe,mt as pe,nt as me,o as L,pt as he,q as R,rt as ge,s as z,st as _e,tt as ve,u as ye,wt as B,x as be,xt as xe,y as Se,yt as Ce,z as we,zt as V}from"./AreaChart-DcUZ3SzF.js";var H=e=>null;H.displayName=`Cell`;var Te=(e,t,n)=>{var r=f();return(i,a)=>o=>{e?.(i,a,o),r(k({activeIndex:String(a),activeDataKey:t,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}},Ee=e=>{var t=f();return(n,r)=>i=>{e?.(n,r,i),t(we())}},De=(e,t,n)=>{var r=f();return(i,a)=>s=>{e?.(i,a,s),r(o({activeIndex:String(a),activeDataKey:t,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function Oe(e,t){return Ne(e)||Me(e,t)||Ae(e,t)||ke()}function ke(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ae(e,t){if(e){if(typeof e==`string`)return je(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?je(e,t):void 0}}function je(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Me(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function Ne(e){if(Array.isArray(e))return e}var Pe=(e,t,n)=>{var r=n??e;if(!b(r))return a(r,t,0)},Fe=(e,t,n)=>{var r={},i=e.filter(M),a=e.filter(e=>e.stackId==null),o=i.reduce((e,t)=>{var n=e[t.stackId];return n??=[],n.push(t),e[t.stackId]=n,e},r),s=Object.entries(o).map(e=>{var r=Oe(e,2),i=r[0],a=r[1];return{stackId:i,dataKeys:a.map(e=>e.dataKey),barSize:Pe(t,n,a[0]?.barSize)}}),c=a.map(e=>({stackId:void 0,dataKeys:[e.dataKey].filter(e=>e!=null),barSize:Pe(t,n,e.barSize)}));return[...s,...c]};function Ie(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function U(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Ie(Object(n),!0).forEach(function(t){Le(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ie(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Le(e,t,n){return(t=Re(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Re(e){var t=ze(e,`string`);return typeof t==`symbol`?t:t+``}function ze(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Be(e,t,n,r,i){var o=r.length;if(!(o<1)){var s=a(e,n,0,!0),c,l=[];if(B(r[0]?.barSize)){var u=!1,d=n/o,f=r.reduce((e,t)=>e+(t.barSize||0),0);f+=(o-1)*s,f>=n&&(f-=(o-1)*s,s=0),f>=n&&d>0&&(u=!0,d*=.9,f=o*d);var p={offset:Math.round((n-f)/2)-s,size:0};c=r.reduce((e,t)=>{var n={stackId:t.stackId,dataKeys:t.dataKeys,position:{offset:p.offset+p.size+s,size:u?d:t.barSize??0}},r=[...e,n];return p=n.position,r},l)}else{var m=a(t,n,0,!0);n-2*m-(o-1)*s<=0&&(s=0);var h=(n-2*m-(o-1)*s)/o;h>1&&(h=Math.round(h));var g=B(i)?Math.min(h,i):h;c=r.reduce((e,t,n)=>[...e,{stackId:t.stackId,dataKeys:t.dataKeys,position:{offset:m+o*(h-g)/2+(g+s)*n,size:g}}],l)}return c}}var Ve=(e,t,n,r,i,a,o)=>{var s=b(o)?t:o,c=Be(n,r,i===a?a:i,e,s);return i!==a&&c!=null&&(c=c.map(e=>U(U({},e),{},{position:U(U({},e.position),{},{offset:e.position.offset-i/2})}))),c},He=(e,t)=>{var n=N(t);if(e&&n!=null&&t!=null){var r=t.stackId;if(r!=null){var i=e[r];if(i){var a=i.stackedData;if(a)return a.find(e=>e.key===n)}}}},Ue=(e,t)=>{if(e!=null&&t!=null){var n=e.find(e=>e.stackId===t.stackId&&t.dataKey!=null&&e.dataKeys.includes(t.dataKey));if(n!=null)return n.position}};function We(e,t){return e&&typeof e==`object`&&`zIndex`in e&&typeof e.zIndex==`number`&&B(e.zIndex)?e.zIndex:t}var W=e(t()),Ge=[`children`];function Ke(e,t){if(e==null)return{};var n,r,i=qe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function qe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var Je=(0,W.createContext)({data:[],xAxisId:`xAxis-0`,yAxisId:`yAxis-0`,dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0});function G(e){var t=e.children,n=Ke(e,Ge);return W.createElement(Je.Provider,{value:n},t)}var Ye=`Invariant failed`;function Xe(e,t){if(!e)throw Error(Ye)}var Ze=[`option`];function Qe(e,t){if(e==null)return{};var n,r,i=$e(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function $e(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var K=P;function q(e){var t=e.option,n=Qe(e,Ze);return W.createElement(l,{option:t,DefaultShape:K,shapeProps:n,activeClassName:`recharts-active-bar`,inActiveClassName:`recharts-inactive-bar`})}var et=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(n,r)=>{if(p(e))return e;var i=p(n)||b(n);return i?e(n,r):(!i&&Xe(!1,`minPointSize callback function received a value with type of ${typeof n}. Currently only numbers or null/undefined are supported.`),t)}},tt=(e,t,n)=>n,J=D([R,(e,t)=>t],(e,t)=>e.filter(e=>e.type===`bar`).find(e=>e.id===t)),nt=D([J],e=>e?.maxBarSize),rt=(e,t,n,r)=>r,it=D([F,R,L,z,tt],(e,t,n,r,i)=>t.filter(t=>e===`horizontal`?t.xAxisId===n:t.yAxisId===r).filter(e=>e.isPanorama===i).filter(e=>e.hide===!1).filter(e=>e.type===`bar`)),at=(e,t,n)=>{var r=F(e),i=L(e,t),a=z(e,t);if(i!=null&&a!=null)return r===`horizontal`?m(e,`yAxis`,a,n):m(e,`xAxis`,i,n)},ot=D([it,ve,(e,t)=>{var n=F(e),r=L(e,t),i=z(e,t);if(r!=null&&i!=null)return n===`horizontal`?j(e,`xAxis`,r):j(e,`yAxis`,i)}],Fe),st=(e,t,n)=>{var r=J(e,t);if(r==null)return 0;var i=L(e,t),a=z(e,t);if(i==null||a==null)return 0;var o=F(e),s=me(e),c=r.maxBarSize,l=b(c)?s:c,u,d;return o===`horizontal`?(u=O(e,`xAxis`,i,n),d=v(e,`xAxis`,i,n)):(u=O(e,`yAxis`,a,n),d=v(e,`yAxis`,a,n)),ce(u,d,!0)??l??0},ct=(e,t,n)=>{var r=F(e),i=L(e,t),a=z(e,t);if(i!=null&&a!=null){var o,s;return r===`horizontal`?(o=O(e,`xAxis`,i,n),s=v(e,`xAxis`,i,n)):(o=O(e,`yAxis`,a,n),s=v(e,`yAxis`,a,n)),ce(o,s)}},lt=D([ot,me,ae,r,st,ct,nt],Ve),ut=(e,t,n)=>{var r=L(e,t);if(r!=null)return O(e,`xAxis`,r,n)},dt=(e,t,n)=>{var r=z(e,t);if(r!=null)return O(e,`yAxis`,r,n)},ft=(e,t,n)=>{var r=L(e,t);if(r!=null)return v(e,`xAxis`,r,n)},pt=(e,t,n)=>{var r=z(e,t);if(r!=null)return v(e,`yAxis`,r,n)},mt=D([lt,J],Ue),ht=D([at,J],He),gt=D([pe,he,ut,dt,ft,pt,mt,F,ge,ct,ht,J,rt],(e,t,n,r,i,a,o,s,c,l,u,d,f)=>{var p=c.chartData,m=c.dataStartIndex,h=c.dataEndIndex;if(!(d==null||o==null||t==null||s!==`horizontal`&&s!==`vertical`||n==null||r==null||i==null||a==null||l==null)){var g=d.data,_=g!=null&&g.length>0?g:p?.slice(m,h+1);if(_!=null)return tn({layout:s,barSettings:d,pos:o,parentViewBox:t,bandSize:l,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,stackedData:u,displayedData:_,offset:e,cells:f,dataStartIndex:m})}}),_t=[`index`];function Y(){return Y=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Y.apply(null,arguments)}function vt(e,t){if(e==null)return{};var n,r,i=yt(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function yt(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var bt=(0,W.createContext)(void 0),xt=e=>{var t=(0,W.useContext)(bt);if(t!=null)return t.stackId;if(e!=null)return Ce(e)},St=(e,t)=>`recharts-bar-stack-clip-path-${e}-${t}`,Ct=e=>{var t=(0,W.useContext)(bt);if(t!=null){var n=t.stackId;return`url(#${St(n,e)})`}},wt=e=>{var t=e.index,n=vt(e,_t),r=Ct(t);return W.createElement(V,Y({className:`recharts-bar-stack-layer`,clipPath:r},n))},Tt=[`onMouseEnter`,`onMouseLeave`,`onClick`],Et=[`value`,`background`,`tooltipPosition`],Dt=[`id`],Ot=[`onMouseEnter`,`onClick`,`onMouseLeave`];function kt(e,t){return Pt(e)||Nt(e,t)||jt(e,t)||At()}function At(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
3
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function jt(e,t){if(e){if(typeof e==`string`)return Mt(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Mt(e,t):void 0}}function Mt(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Nt(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function Pt(e){if(Array.isArray(e))return e}function X(){return X=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},X.apply(null,arguments)}function Ft(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Z(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Ft(Object(n),!0).forEach(function(t){It(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ft(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function It(e,t,n){return(t=Lt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Lt(e){var t=Rt(e,`string`);return typeof t==`symbol`?t:t+``}function Rt(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Q(e,t){if(e==null)return{};var n,r,i=zt(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function zt(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var Bt=e=>{var t=e.dataKey,n=e.name,r=e.fill,i=e.legendType;return[{inactive:e.hide,dataKey:t,type:i,color:r,value:ie(n,t),payload:e}]},Vt=W.memo(e=>{var t=e.dataKey,n=e.stroke,r=e.strokeWidth,i=e.fill,a=e.name,o=e.hide,s=e.unit,c=e.formatter,l=e.tooltipType,u=e.id,f={dataDefinedOnItem:void 0,getPosition:y,settings:{stroke:n,strokeWidth:r,fill:i,dataKey:t,nameKey:void 0,name:ie(a,t),hide:o,type:l,color:i,unit:s,formatter:c,graphicalItemId:u}};return W.createElement(d,{tooltipEntrySettings:f})});function Ht(e){var t=u(w),n=e.data,r=e.dataKey,i=e.background,a=e.allOtherBarProps,o=a.onMouseEnter,s=a.onMouseLeave,c=a.onClick,l=Q(a,Tt),d=Te(o,r,a.id),f=Ee(s),p=De(c,r,a.id);if(!i||n==null)return null;var m=h(i);return W.createElement(g,{zIndex:We(i,C.barBackground)},n.map((e,n)=>{e.value;var a=e.background;e.tooltipPosition;var o=Q(e,Et);if(!a)return null;var s=d(e,e.originalDataIndex),c=f(e,e.originalDataIndex),u=p(e,e.originalDataIndex),h=Z(Z(Z(Z(Z({option:i,isActive:String(e.originalDataIndex)===t},o),{},{fill:`#eee`},a),m),ue(l,e,n)),{},{onMouseEnter:s,onMouseLeave:c,onClick:u,dataKey:r,index:n,className:`recharts-bar-background-rectangle`});return W.createElement(q,X({key:`background-bar-${n}`},h))}))}function Ut(e){var t=e.showLabels,n=e.children,r=e.rects?.map(e=>{var t={x:e.x,y:e.y,width:e.width,lowerWidth:e.width,upperWidth:e.width,height:e.height};return Z(Z({},t),{},{value:e.value,payload:e.payload,parentViewBox:e.parentViewBox,viewBox:t,fill:e.fill})});return W.createElement(i,{value:t?r:void 0},n)}function Wt(e){var t=e.shape,n=e.activeBar,r=e.baseProps,i=e.entry,a=e.index,o=e.dataKey,s=u(w),c=u(ee),l=n&&String(i.originalDataIndex)===s&&(c==null||o===c),d=s!=null&&(String(i.originalDataIndex)!==s||c!=null&&o!==c),f=kt((0,W.useState)(!1),2),p=f[0],m=f[1],h=kt((0,W.useState)(!1),2),_=h[0],v=h[1];(0,W.useEffect)(()=>{var e;return l?(m(!0),e=requestAnimationFrame(()=>{v(!0)})):(v(!1),d&&m(!1)),()=>{cancelAnimationFrame(e)}},[l,d]);var y=(0,W.useCallback)(()=>{l||m(!1)},[l]),te=l&&_,b=l||p,x=l?n===!0?t:n:t,S=W.createElement(q,X({},r,{name:String(r.name)},i,{isActive:te,option:x,index:a,dataKey:o,animationElapsedTime:e.animationElapsedTime,isAnimating:e.isAnimating,isEntrance:e.isEntrance,onTransitionEnd:y}));return b?W.createElement(g,{zIndex:C.activeBar},W.createElement(wt,{index:i.originalDataIndex},S)):S}function Gt(e){var t=e.shape,n=e.baseProps,r=e.entry,i=e.index,a=e.dataKey;return W.createElement(q,X({},n,{name:String(n.name)},r,{isActive:!1,option:t,index:i,dataKey:a,animationElapsedTime:e.animationElapsedTime,isAnimating:e.isAnimating,isEntrance:e.isEntrance}))}function Kt(e){var t=e.data,n=e.props,r=e.animationElapsedTime,i=e.isAnimating,a=e.isEntrance,o=A(n)??{},s=o.id,c=Q(o,Dt),l=n.shape,u=n.dataKey,d=n.activeBar,f=n.onMouseEnter,p=n.onClick,m=n.onMouseLeave,h=Q(n,Ot),g=Te(f,u,s),_=Ee(m),v=De(p,u,s);return t?W.createElement(W.Fragment,null,t.map((e,t)=>W.createElement(wt,X({index:e.originalDataIndex,key:`rectangle-${e?.x}-${e?.y}-${e?.value}-${t}`,className:`recharts-bar-rectangle`},ue(h,e,t),{onMouseEnter:g(e,e.originalDataIndex),onMouseLeave:_(e,e.originalDataIndex),onClick:v(e,e.originalDataIndex)}),d?W.createElement(Wt,{shape:l,activeBar:d,baseProps:c,entry:e,index:t,dataKey:u,animationElapsedTime:r,isAnimating:i,isEntrance:a}):W.createElement(Gt,{shape:l,baseProps:c,entry:e,index:t,dataKey:u,animationElapsedTime:r,isAnimating:i,isEntrance:a})))):null}var qt=(e,t,n)=>e==null?[]:t===1?e.flatMap(e=>e.status===`removed`?[]:[e.next]):e.flatMap(e=>{if(e.status===`removed`)return n===`horizontal`?[Z(Z({},e.prev),{},{height:I(e.prev.height,0,t),y:I(e.prev.y,e.prev.y+e.prev.height,t)})]:[Z(Z({},e.prev),{},{width:I(e.prev.width,0,t)})];if(e.status===`matched`)return[Z(Z({},e.next),{},{x:I(e.prev.x,e.next.x,t),y:I(e.prev.y,e.next.y,t),width:I(e.prev.width,e.next.width,t),height:I(e.prev.height,e.next.height,t)})];var r=e.next;return n===`horizontal`?[Z(Z({},r),{},{height:I(0,r.height,t),y:I(r.stackedBarStart,r.y,t)})]:[Z(Z({},r),{},{width:I(0,r.width,t),x:I(r.stackedBarStart,r.x,t)})]});function Jt(e){var t=e.props,n=e.previousRectanglesRef,r=t.data,i=t.isAnimationActive,a=t.animationBegin,o=t.animationDuration,s=t.animationEasing,c=t.animationInterpolateFn,l=t.layout,u=T(t.onAnimationStart,t.onAnimationEnd),d=u.isAnimating,f=u.handleAnimationStart,p=u.handleAnimationEnd;return W.createElement(Ut,{showLabels:!d,rects:r},W.createElement(be,{animationInput:r,animationIdPrefix:`recharts-bar-`,items:r,previousItemsRef:n,isAnimationActive:i,animationBegin:a,animationDuration:o,animationEasing:s,onAnimationStart:f,onAnimationEnd:p,animationInterpolateFn:c,animationMatchBy:t.animationMatchBy,layout:l},(e,n,r)=>W.createElement(V,null,W.createElement(Kt,{props:t,data:e,animationElapsedTime:n,isAnimating:d||n<1,isEntrance:r}))),W.createElement(le,{label:t.label}),t.children)}function Yt(e){var t=(0,W.useRef)(null);return W.createElement(Jt,{previousRectanglesRef:t,props:e})}var Xt=0,Zt=(e,t)=>{var n=Array.isArray(e.value)?e.value[1]:e.value;return{x:e.x,y:e.y,value:n,errorVal:xe(e,t)}},Qt=class extends W.PureComponent{render(){var e=this.props,t=e.hide,r=e.data,i=e.dataKey,a=e.className,o=e.xAxisId,s=e.yAxisId,c=e.needClip,l=e.background,u=e.id;if(t||r==null)return null;var d=n(`recharts-bar`,a),f=u;return W.createElement(V,{className:d,id:u},c&&W.createElement(`defs`,null,W.createElement(de,{clipPathId:f,xAxisId:o,yAxisId:s})),W.createElement(V,{className:`recharts-bar-rectangles`,clipPath:c?`url(#clipPath-${f})`:void 0},W.createElement(Ht,{data:r,dataKey:i,background:l,allOtherBarProps:this.props}),W.createElement(Yt,this.props)))}},$t={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:`ease`,animationInterpolateFn:qt,animationMatchBy:s,background:!1,hide:!1,isAnimationActive:`auto`,label:!1,legendType:`rect`,minPointSize:Xt,shape:K,xAxisId:0,yAxisId:0,zIndex:C.bar};function en(e){var t=e.xAxisId,n=e.yAxisId,r=e.hide,i=e.legendType,a=e.minPointSize,o=e.activeBar,s=e.animationBegin,c=e.animationDuration,l=e.animationEasing,d=e.isAnimationActive,f=ye(t,n).needClip,p=fe(),m=oe(),h=x(e.children,H),g=u(t=>gt(t,e.id,m,h));if(p!==`vertical`&&p!==`horizontal`)return null;var _,v=g?.[0];return _=v==null||v.height==null||v.width==null?0:p===`vertical`?v.height/2:v.width/2,W.createElement(G,{xAxisId:t,yAxisId:n,data:g,dataPointFormatter:Zt,errorBarOffset:_},W.createElement(Qt,X({},e,{layout:p,needClip:f,data:g,xAxisId:t,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:o,animationBegin:s,animationDuration:c,animationEasing:l,isAnimationActive:d})))}function tn(e){var t=e.layout,n=e.barSettings,r=n.dataKey,i=n.minPointSize,a=n.hasCustomShape,o=e.pos,s=e.bandSize,l=e.xAxis,u=e.yAxis,d=e.xAxisTicks,f=e.yAxisTicks,p=e.stackedData,m=e.displayedData,h=e.offset,g=e.cells,v=e.parentViewBox,ee=e.dataStartIndex,y=t===`horizontal`?u:l,b=p?y.scale.domain():null,x=se({numericAxis:y}),S=y.scale.map(x);return m.map((e,n)=>{var m,y,C,w,T,E;if(p){var D=p[n+ee];if(D==null)return null;m=c(D,b)}else m=xe(e,r),Array.isArray(m)||(m=[x,m]);var O=et(i,Xt)(m[1],n);if(t===`horizontal`){var k=u.scale.map(m[0]),A=u.scale.map(m[1]);if(k==null||A==null)return null;y=ne({axis:l,ticks:d,bandSize:s,offset:o.offset,entry:e,index:n}),C=A??k??void 0,w=o.size;var j=k-A;if(T=te(j)?0:j,E={x:y,y:h.top,width:w,height:h.height},Math.abs(O)>0&&Math.abs(T)<Math.abs(O)){var M=_(T||O)*(Math.abs(O)-Math.abs(T));C-=M,T+=M}}else{var N=l.scale.map(m[0]),P=l.scale.map(m[1]);if(N==null||P==null)return null;if(y=N,C=ne({axis:u,ticks:f,bandSize:s,offset:o.offset,entry:e,index:n}),w=P-N,T=o.size,E={x:h.left,y:C,width:h.width,height:T},Math.abs(O)>0&&Math.abs(w)<Math.abs(O)){var re=_(w||O)*(Math.abs(O)-Math.abs(w));w+=re}}return y==null||C==null||w==null||T==null||!a&&(w===0||T===0)?null:Z(Z({},e),{},{stackedBarStart:S,x:y,y:C,width:w,height:T,value:p?m:m[1],payload:e,background:E,tooltipPosition:{x:y+w/2,y:C+T/2},parentViewBox:v,originalDataIndex:n},g&&g[n]&&g[n].props)}).filter(Boolean)}function nn(e){var t=S(e,$t),n=xt(t.stackId),r=oe();return W.createElement(re,{id:t.id,type:`bar`},e=>W.createElement(W.Fragment,null,W.createElement(E,{legendPayload:Bt(t)}),W.createElement(Vt,{dataKey:t.dataKey,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,formatter:t.formatter,tooltipType:t.tooltipType,id:e}),W.createElement(Se,{type:`bar`,id:e,data:void 0,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,stackId:n,hide:t.hide,barSize:t.barSize,minPointSize:t.minPointSize,maxBarSize:t.maxBarSize,isPanorama:r,hasCustomShape:t.shape!=null&&t.shape!==K}),W.createElement(g,{zIndex:t.zIndex},W.createElement(en,X({},t,{id:e})))))}var $=W.memo(nn,_e);$.displayName=`Bar`;export{G as n,H as r,$ as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t}from"./jsx-runtime-CVMpzJz9.js";import{F as n,n as r}from"./AreaChart-DcUZ3SzF.js";var i=e(t()),a=[`axis`,`item`],o=(0,i.forwardRef)((e,t)=>i.createElement(r,{chartName:`BarChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:a,tooltipPayloadSearcher:n,categoricalChartProps:e,ref:t}));export{o as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{fr as r}from"./index-Q_RymVqx.js";import{F as i,P as a,a as o,d as s,dt as c,i as l,n as u,r as d,t as f}from"./AreaChart-DcUZ3SzF.js";import{t as p}from"./Bar-BEUEq4ZT.js";import{t as m}from"./Line-BwNoqzSJ.js";import{t as h}from"./BarChart-DJZEJEg6.js";import{a as g,c as _,i as v,l as y,n as b,o as x,r as S,s as C,t as w,u as T}from"./chat-ui-chart-CdwnX81S.js";var E=e(t()),D=[`axis`],O=(0,E.forwardRef)((e,t)=>E.createElement(u,{chartName:`LineChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:D,tooltipPayloadSearcher:i,categoricalChartProps:e,ref:t})),k=n(),A=`(prefers-reduced-motion: reduce)`,j={fill:`var(--color-muted-foreground)`,fontSize:10},M={stroke:`var(--color-border)`},N={top:8,right:8,bottom:0,left:0};function P({active:e,payload:t,label:n}){return!e||!t?.length?null:(0,k.jsxs)(`div`,{className:`max-w-64 rounded-md border border-border bg-surface px-2 py-1.5 text-xs tabular-nums shadow-sm`,children:[n!==void 0&&(0,k.jsx)(`p`,{className:`font-medium text-on-surface`,children:String(n)}),t.map(e=>(0,k.jsxs)(`p`,{className:`flex items-center gap-1.5 text-on-surface-variant`,children:[(0,k.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 shrink-0 rounded-sm`,style:{backgroundColor:e.color}}),(0,k.jsx)(`span`,{className:`min-w-0 truncate`,children:e.name}),(0,k.jsx)(`span`,{className:`ml-auto pl-2 text-on-surface`,children:g(Number(e.value))})]},String(e.name)))]})}function F(){return[(0,k.jsx)(s,{vertical:!1,stroke:`var(--color-border)`},`grid`),(0,k.jsx)(l,{dataKey:`label`,tick:j,tickLine:!1,axisLine:M,minTickGap:16,interval:`preserveStartEnd`},`x`),(0,k.jsx)(d,{width:44,tick:j,tickLine:!1,axisLine:!1,tickFormatter:v},`y`),(0,k.jsx)(a,{cursor:{stroke:`var(--color-muted-foreground)`},content:(0,k.jsx)(P,{})},`tooltip`)]}function I({kind:e=`line`,labels:t,series:n,title:i}){let a=r(A),s=b(t,n);if(!x(t,n))return(0,k.jsxs)(`div`,{"data-testid":`chat-ui-chart-empty`,className:`min-w-0`,children:[i&&(0,k.jsx)(`p`,{className:`mb-1 truncate text-sm font-medium text-on-surface`,children:i}),(0,k.jsx)(`p`,{className:`rounded-md border border-outline-variant px-3 py-6 text-center text-xs text-on-surface-variant`,children:`No data recorded for this chart yet.`})]});let l=S({title:i,kind:e,labels:t,series:n});return(0,k.jsxs)(`figure`,{"data-testid":`chat-ui-chart`,"data-kind":e,className:`min-w-0`,children:[i&&(0,k.jsx)(`figcaption`,{className:`mb-1 truncate text-sm font-medium text-on-surface`,children:i}),(0,k.jsx)(`ul`,{className:`mb-1 flex flex-wrap gap-x-4 gap-y-1 text-xs text-on-surface-variant`,children:n.map((e,t)=>(0,k.jsxs)(`li`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,k.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 shrink-0 rounded-sm`,style:{backgroundColor:w[t]}}),(0,k.jsx)(`span`,{className:`truncate`,children:e.name})]},e.name))}),(0,k.jsx)(`div`,{className:`h-56 w-full`,role:`img`,"aria-label":l,children:(0,k.jsx)(c,{width:`100%`,height:`100%`,children:e===`bar`?(0,k.jsxs)(h,{data:s,margin:N,children:[F(),n.map((e,t)=>(0,k.jsx)(p,{dataKey:C(t),name:e.name,fill:w[t],radius:[2,2,0,0],isAnimationActive:!a,animationDuration:300},e.name))]}):e===`area`?(0,k.jsxs)(f,{data:s,margin:N,children:[F(),n.map((e,t)=>(0,k.jsx)(o,{type:`monotone`,dataKey:C(t),name:e.name,stroke:w[t],fill:w[t],fillOpacity:.15,strokeWidth:2,isAnimationActive:!a,animationDuration:300},e.name))]}):(0,k.jsxs)(O,{data:s,margin:N,children:[F(),n.map((e,t)=>(0,k.jsx)(m,{type:`monotone`,dataKey:C(t),name:e.name,stroke:w[t],strokeWidth:2,dot:!1,isAnimationActive:!a,animationDuration:300},e.name))]})})})]})}function L({values:e,label:t}){let n=r(A),i=T(e),o=t??`Series`;return(0,k.jsxs)(`figure`,{"data-testid":`chat-ui-sparkline`,className:`min-w-0`,children:[(0,k.jsxs)(`figcaption`,{className:`flex min-w-0 items-baseline gap-2 text-xs text-on-surface-variant`,children:[t&&(0,k.jsx)(`span`,{className:`truncate`,children:t}),(0,k.jsx)(`span`,{className:`shrink-0 tabular-nums text-on-surface`,children:g(i.last)})]}),(0,k.jsx)(`div`,{className:`h-8 w-40 max-w-full`,role:`img`,"aria-label":`${o}: ${_(i)}, low ${g(i.min)}, high ${g(i.max)}`,children:(0,k.jsx)(c,{width:`100%`,height:`100%`,children:(0,k.jsxs)(O,{data:y(e),margin:{top:2,right:2,bottom:2,left:2},children:[(0,k.jsx)(l,{dataKey:`index`,hide:!0}),(0,k.jsx)(d,{hide:!0,domain:[`dataMin`,`dataMax`]}),(0,k.jsx)(a,{cursor:{stroke:`var(--color-muted-foreground)`},content:(0,k.jsx)(R,{name:o})}),(0,k.jsx)(m,{type:`monotone`,dataKey:`value`,stroke:`var(--color-series-1)`,strokeWidth:1.5,dot:!1,isAnimationActive:!n,animationDuration:300})]})})})]})}function R({name:e,active:t,payload:n}){let r=t?n?.[0]:void 0;return r?(0,k.jsxs)(`div`,{className:`rounded-md border border-border bg-surface px-2 py-1 text-xs tabular-nums shadow-sm`,children:[(0,k.jsxs)(`span`,{className:`text-on-surface-variant`,children:[e,` `]}),(0,k.jsx)(`span`,{className:`text-on-surface`,children:g(Number(r.value))})]}):null}export{L as Sparkline,I as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./jsx-runtime-CVMpzJz9.js";import{Rn as t,an as n}from"./index-Q_RymVqx.js";import{P as r,a as i,d as a,dt as o,i as s,r as c,t as l}from"./AreaChart-DcUZ3SzF.js";import{r as u,t as d}from"./Bar-BEUEq4ZT.js";import{t as f}from"./ReferenceLine-BPBQytfV.js";import{t as p}from"./BarChart-DJZEJEg6.js";var m=e(),h=new Intl.NumberFormat,g=`var(--color-series-1)`,_=`var(--color-series-3)`,v=`var(--color-series-1)`,y=`var(--color-error)`,b={completed:`var(--color-series-1)`,stopped:`var(--color-series-4)`,failed:`var(--color-error)`,running:`var(--color-series-3)`};function x({color:e,label:t,dashed:n}){return(0,m.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,m.jsx)(`span`,{"aria-hidden":`true`,className:`w-4`,style:n?{borderTop:`1.5px dashed ${e}`}:{height:2,borderRadius:1,background:e}}),t]})}function S({context:e}){let t=e.usage.timeline??[];if(t.length<2)return null;let u=t.map(e=>({...e,fresh:Math.max(0,e.context_tokens-e.cached_input_tokens)})),d=e.usage.compactions??[],p=[];for(let e of d){let r=e.recorded_at,i=r&&t.find(e=>e.recorded_at&&e.recorded_at>=r);if(!i||p.some(e=>e.request===i.request))continue;let a=e.pre_tokens!==null&&e.post_tokens!==null?`${n(e.pre_tokens,!1)} → ${n(e.post_tokens,!1)}`:null;p.push({request:i.request,drop:a})}return(0,m.jsxs)(`figure`,{"data-testid":`chat-context-chart`,className:`w-full`,children:[(0,m.jsxs)(`figcaption`,{className:`mb-1 flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground`,children:[(0,m.jsx)(x,{color:g,label:`Reused from cache`}),(0,m.jsx)(x,{color:_,label:`New input`}),p.length>0&&(0,m.jsx)(x,{color:`var(--color-series-2)`,label:`Compacted`,dashed:!0})]}),(0,m.jsx)(`div`,{className:`h-40 w-full`,children:(0,m.jsx)(o,{width:`100%`,height:`100%`,children:(0,m.jsxs)(l,{data:u,margin:{top:8,right:8,bottom:0,left:0},children:[(0,m.jsx)(a,{vertical:!1,stroke:`var(--color-border)`}),(0,m.jsx)(s,{dataKey:`request`,tick:{fill:`var(--color-muted-foreground)`,fontSize:10},tickLine:!1,axisLine:{stroke:`var(--color-border)`},minTickGap:24}),(0,m.jsx)(c,{width:40,tick:{fill:`var(--color-muted-foreground)`,fontSize:10},tickLine:!1,axisLine:!1,tickFormatter:e=>n(e,!1)}),(0,m.jsx)(r,{cursor:{stroke:`var(--color-muted-foreground)`},content:({active:e,payload:t})=>{let n=e?t?.[0]?.payload:void 0;if(!n)return null;let r=p.find(e=>e.request===n.request);return(0,m.jsxs)(`div`,{className:`rounded-md border border-border bg-surface px-2 py-1.5 text-xs tabular-nums shadow-sm`,children:[(0,m.jsxs)(`p`,{className:`font-medium text-on-surface`,children:[`Request `,h.format(n.request),n.recorded_at&&(0,m.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[` `,`· `,new Date(n.recorded_at).toLocaleString()]})]}),(0,m.jsxs)(`p`,{children:[`Context `,h.format(n.context_tokens)]}),(0,m.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Reused `,h.format(n.cached_input_tokens),` · new`,` `,h.format(n.fresh)]}),n.output_tokens!==null&&(0,m.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Output `,h.format(n.output_tokens)]}),r&&(0,m.jsxs)(`p`,{className:`text-on-surface`,children:[`Compacted`,r.drop&&` ${r.drop}`]})]})}}),p.map(e=>(0,m.jsx)(f,{x:e.request,label:e.drop?{value:e.drop,position:`insideTopLeft`,fill:`var(--color-muted-foreground)`,fontSize:10}:void 0,stroke:`var(--color-series-2)`,strokeDasharray:`4 3`,strokeWidth:1.5},e.request)),(0,m.jsx)(i,{type:`linear`,dataKey:`cached_input_tokens`,stackId:`context`,stroke:g,strokeWidth:2,fill:g,fillOpacity:.18,isAnimationActive:!1}),(0,m.jsx)(i,{type:`linear`,dataKey:`fresh`,stackId:`context`,stroke:_,strokeWidth:2,fill:_,fillOpacity:.18,isAnimationActive:!1})]})})})]})}function C({tools:e}){let t=e.slice(0,8).map(e=>({...e,label:e.name}));return t.length?(0,m.jsxs)(`figure`,{"data-testid":`chat-tool-chart`,className:`w-full`,children:[(0,m.jsxs)(`figcaption`,{className:`mb-1 flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground`,children:[(0,m.jsx)(x,{color:v,label:`Calls`}),(0,m.jsx)(x,{color:y,label:`Failures`})]}),(0,m.jsx)(`div`,{className:`w-full`,style:{height:Math.max(120,t.length*34)},children:(0,m.jsx)(o,{width:`100%`,height:`100%`,children:(0,m.jsxs)(p,{data:t,layout:`vertical`,margin:{top:0,right:12,bottom:0,left:0},barGap:2,children:[(0,m.jsx)(a,{horizontal:!1,stroke:`var(--color-border)`}),(0,m.jsx)(s,{type:`number`,allowDecimals:!1,tick:{fill:`var(--color-muted-foreground)`,fontSize:10},tickLine:!1,axisLine:{stroke:`var(--color-border)`}}),(0,m.jsx)(c,{type:`category`,dataKey:`name`,width:96,tick:{fill:`var(--color-on-surface-variant)`,fontSize:11},tickLine:!1,axisLine:!1}),(0,m.jsx)(r,{cursor:{fill:`var(--color-surface-high)`},content:({active:e,payload:t})=>{let n=e?t?.[0]?.payload:void 0;return n?(0,m.jsxs)(`div`,{className:`rounded-md border border-border bg-surface px-2 py-1.5 text-xs tabular-nums shadow-sm`,children:[(0,m.jsx)(`p`,{className:`font-medium text-on-surface`,children:n.name}),(0,m.jsxs)(`p`,{children:[h.format(n.calls),` calls`]}),(0,m.jsx)(`p`,{className:`text-muted-foreground`,children:n.failures?`${h.format(n.failures)} failed`:`No failures`})]}):null}}),(0,m.jsx)(d,{dataKey:`calls`,fill:v,radius:[0,2,2,0],isAnimationActive:!1}),(0,m.jsx)(d,{dataKey:`failures`,fill:y,isAnimationActive:!1})]})})})]}):null}function w({turns:e}){let n=e.filter(e=>e.durationMs!==null);if(n.length<2)return null;let i=Math.round(n.reduce((e,t)=>e+(t.durationMs??0),0)/n.length);return(0,m.jsxs)(`figure`,{"data-testid":`chat-turn-chart`,className:`w-full`,children:[(0,m.jsxs)(`figcaption`,{className:`mb-1 flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground`,children:[(0,m.jsx)(x,{color:b.completed,label:`Completed`}),(0,m.jsx)(x,{color:b.stopped,label:`Stopped`}),(0,m.jsx)(x,{color:b.failed,label:`Failed`}),(0,m.jsx)(x,{color:b.running,label:`Running`})]}),(0,m.jsx)(`div`,{className:`h-40 w-full`,children:(0,m.jsx)(o,{width:`100%`,height:`100%`,children:(0,m.jsxs)(p,{data:n,margin:{top:8,right:8,bottom:0,left:0},children:[(0,m.jsx)(a,{vertical:!1,stroke:`var(--color-border)`}),(0,m.jsx)(s,{dataKey:`index`,tick:{fill:`var(--color-muted-foreground)`,fontSize:10},tickLine:!1,axisLine:{stroke:`var(--color-border)`},minTickGap:24}),(0,m.jsx)(c,{width:40,tick:{fill:`var(--color-muted-foreground)`,fontSize:10},tickLine:!1,axisLine:!1,tickFormatter:e=>t(e)}),(0,m.jsx)(r,{cursor:{fill:`var(--color-surface-high)`},content:({active:e,payload:n})=>{let r=e?n?.[0]?.payload:void 0;return r?(0,m.jsxs)(`div`,{className:`rounded-md border border-border bg-surface px-2 py-1.5 text-xs tabular-nums shadow-sm`,children:[(0,m.jsxs)(`p`,{className:`font-medium text-on-surface`,children:[`Turn `,h.format(r.index),` · `,r.outcome]}),(0,m.jsx)(`p`,{children:r.durationMs===null?`No timing`:t(r.durationMs)}),(0,m.jsxs)(`p`,{className:`text-muted-foreground`,children:[h.format(r.toolCalls),` tool`,r.toolCalls===1?``:`s`,r.toolFailures?` · ${h.format(r.toolFailures)} failed`:``]})]}):null}}),(0,m.jsx)(f,{y:i,stroke:`var(--color-muted-foreground)`,strokeDasharray:`4 3`,label:{value:`avg ${t(i)}`,position:`insideTopRight`,fill:`var(--color-muted-foreground)`,fontSize:10}}),(0,m.jsx)(d,{dataKey:`durationMs`,isAnimationActive:!1,radius:[2,2,0,0],children:n.map(e=>(0,m.jsx)(u,{fill:b[e.outcome]},e.index))})]})})})]})}export{S as ChatContextChart,C as ChatToolChart,w as ChatTurnChart};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ScratchpadDiagramPreview-CICRpF10.js","assets/rolldown-runtime-DSDNlrLa.js","assets/jsx-runtime-CVMpzJz9.js","assets/prod-C5uPTMUm.js","assets/react-dom-DTbwZiiP.js","assets/es2015-w69PgVrA.js","assets/floating-ui.react-dom-BDMgcqWu.js","assets/preload-helper-BLdHbfdN.js","assets/with-selector-DSvXfKhy.js","assets/Chart-BMFNlgbS.js","assets/index-Q_RymVqx.js","assets/QueryClientProvider-DlPztvhd.js","assets/useMutation-CRAWY7v2.js","assets/chunk-OB3PAWPO-BD6ylT0A.js","assets/button-DaSTTBls.js","assets/clsx-DB0hHKMi.js","assets/bundle-mjs-Dvhef5Db.js","assets/x-Cli9YXXI.js","assets/client-BD4crXth.js","assets/dist-BJbQo-dr.js","assets/check-qe2BJPmy.js","assets/chevron-down-BRt1smOS.js","assets/select-BJy2oop5.js","assets/dist-DWfyUCyc.js","assets/dist-Ct6061MC.js","assets/dist-D8Wfxh48.js","assets/maximize-2-BAy-8JsG.js","assets/MarkdownEditor-C7LnwPSG.js","assets/Markdown-wp7JBOSy.js","assets/document-display-BQ5dM8QT.js","assets/file-kind-BYU1kv95.js","assets/textarea-Cf2b0PUV.js","assets/tabs-BvxkGUc3.js","assets/label-dQSF_SAL.js","assets/schemas-BQZhekae.js","assets/chat-DGhEIqmi.js","assets/bulk-actions-C8S1Gt4W.js","assets/coding-agents-UkijH6GA.js","assets/dialog-CSqhD8HZ.js","assets/useBackends-wj1KheAL.js","assets/index-BHal5gcw.css","assets/AreaChart-DcUZ3SzF.js","assets/linear-jUOPAx5A.js","assets/isArguments-2ZchtnyI.js","assets/defaultLocale-BFoDCU3G.js","assets/init-ZlXS9mIS.js","assets/ordinal-CNdcxYwv.js","assets/time-B49d1LAz.js","assets/band-Dy_5MQ5S.js","assets/Bar-BEUEq4ZT.js","assets/Line-BwNoqzSJ.js","assets/BarChart-DJZEJEg6.js","assets/chat-ui-chart-CdwnX81S.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{n as r}from"./QueryClientProvider-DlPztvhd.js";import{n as i}from"./useMutation-CRAWY7v2.js";import{f as a,t as o,u as s}from"./chunk-OB3PAWPO-BD6ylT0A.js";import{s as c,t as l}from"./button-DaSTTBls.js";import{P as u,n as d}from"./client-BD4crXth.js";import{t as f}from"./maximize-2-BAy-8JsG.js";import{A as p,C as m,D as h,E as g,F as _,I as v,M as y,N as b,O as ee,P as x,S as te,T as S,_ as C,b as w,g as T,h as E,j as D,k as ne,v as O,w as k,x as A,y as j}from"./chat-DGhEIqmi.js";import{t as M}from"./preload-helper-BLdHbfdN.js";import{t as N}from"./Markdown-wp7JBOSy.js";import{n as P,o as F,r as I,s as L,t as re}from"./dialog-CSqhD8HZ.js";import{Ar as ie,Bt as R,Fr as ae,J as oe,M as se,Pr as ce,U as le,Vt as ue,Z as de,_ as fe,an as pe,ct as me,et as he,gi as ge,it as _e,jr as ve,ni as ye,nr as be,nt as xe,pr as Se,tn as Ce,v as we,vi as Te,yr as Ee}from"./index-Q_RymVqx.js";import{a as De}from"./chat-ui-chart-CdwnX81S.js";import{t as Oe}from"./ConfirmDialog-TrdcniMK.js";import{c as ke,l as Ae,r as je}from"./useJobs-DJfPRESN.js";import{t as Me}from"./PriorityBadge-CMPd6WIn.js";import{t as Ne}from"./orc-kit-TFHF-l0v.js";var Pe={name:`minus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]};Pe.node;var Fe=u(Pe),Ie={name:`sticky-note`,size:24,node:[[`path`,{d:`M21 9a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 15 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2z`,key:`1dfntj`}],[`path`,{d:`M15 3v5a1 1 0 0 0 1 1h5`,key:`6s6qgf`}]]};Ie.node;var Le=u(Ie),Re={name:`trending-down`,size:24,node:[[`path`,{d:`M16 17h6v-6`,key:`t6n2it`}],[`path`,{d:`m22 17-8.5-8.5-5 5L2 7`,key:`x473p`}]]};Re.node;var ze=u(Re),Be={name:`trending-up`,size:24,node:[[`path`,{d:`M16 7h6v6`,key:`box55l`}],[`path`,{d:`m22 7-8.5 8.5-5-5L2 17`,key:`1t1m79`}]]};Be.node;var Ve=u(Be),z=e(t(),1),B=n(),He=(0,z.createContext)(null);function Ue(e,t){return e?null:Object.keys(t).length===0?{}:b(t)}function We({store:e,initialState:t={},onStateChange:n,children:r}){let i=(0,z.useRef)(void 0);!e&&!i.current&&(i.current=y(t));let a=e??i.current,o=(0,z.useRef)(a);o.current=a;let s=(0,z.useRef)(!!e);s.current=!!e,(0,z.useRef)(e?`controlled`:`uncontrolled`),(0,z.useRef)(!1);let c=(0,z.useRef)(t),l=(0,z.useRef)(Ue(!!e,t));(0,z.useEffect)(()=>{if(e||t===c.current)return;c.current=t;let n=t&&Object.keys(t).length>0?b(t):{},r=l.current??{},i=new Set([...Object.keys(r),...Object.keys(n)]),o={};for(let e of i)r[e]!==n[e]&&(o[e]=e in n?n[e]:void 0);l.current=n,Object.keys(o).length>0&&a.update(o)},[e,t,a]);let u=(0,z.useSyncExternalStore)(a.subscribe,a.getSnapshot,a.getServerSnapshot??a.getSnapshot),d=(0,z.useRef)(n);d.current=n;let f=(0,z.useCallback)((e,t)=>{let n=o.current,r=n.getSnapshot();n.set(e,t),!s.current&&n.getSnapshot()!==r&&d.current?.([{path:e,value:t}])},[]),p=(0,z.useCallback)(e=>{let t=o.current,n=t.getSnapshot();if(t.update(e),!s.current&&t.getSnapshot()!==n){let t=[];for(let[r,i]of Object.entries(e))x(n,r)!==i&&t.push({path:r,value:i});t.length>0&&d.current?.(t)}},[]),m=(0,z.useCallback)(e=>o.current.get(e),[]),h=(0,z.useCallback)(()=>o.current.getSnapshot(),[]),g=(0,z.useMemo)(()=>({state:u,get:m,set:f,update:p,getSnapshot:h}),[u,m,f,p,h]);return(0,B.jsx)(He.Provider,{value:g,children:r})}function V(){let e=(0,z.useContext)(He);if(!e)throw Error(`useStateStore must be used within a StateProvider`);return e}var Ge=(0,z.createContext)(null);function Ke({children:e}){let{state:t}=V(),n=(0,z.useMemo)(()=>({stateModel:t}),[t]),r=(0,z.useMemo)(()=>e=>j(e,n),[n]),i=(0,z.useMemo)(()=>({isVisible:r,ctx:n}),[r,n]);return(0,B.jsx)(Ge.Provider,{value:i,children:e})}function qe(){let e=(0,z.useContext)(Ge);if(!e)throw Error(`useVisibility must be used within a VisibilityProvider`);return e}var Je=(0,z.createContext)(null),Ye={};function Xe(e,t){if(e===t)return!0;if(!e||!t)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n){let n=e[r],i=t[r];if(n!==i){if(typeof n==`object`&&n&&typeof i==`object`&&i){let e=n.$state,t=i.$state;if(typeof e==`string`&&e===t)continue}return!1}}return!0}function Ze(e,t){if(e===t)return!0;if(e.validateOn!==t.validateOn)return!1;let n=e.checks??[],r=t.checks??[];if(n.length!==r.length)return!1;for(let e=0;e<n.length;e++){let t=n[e],i=r[e];if(t.type!==i.type||t.message!==i.message||!Xe(t.args,i.args))return!1}return!0}function Qe({customFunctions:e=Ye,children:t}){let{state:n,getSnapshot:r}=V(),[i,a]=(0,z.useState)({}),o=(0,z.useRef)({}),[s,c]=(0,z.useState)({}),l=(0,z.useCallback)((e,t)=>{c(n=>{let r=n[e];return r&&Ze(r,t)?n:{...n,[e]:t}})},[]),u=(0,z.useCallback)((t,n)=>{let i=r(),s=t.split(`/`).filter(Boolean),c=i;for(let e of s)if(typeof c==`object`&&c)c=c[e];else{c=void 0;break}let l=ne(n,{value:c,stateModel:i,customFunctions:e}),u={touched:o.current[t]?.touched??!0,validated:!0,result:l};return o.current={...o.current,[t]:u},a(o.current),l},[e,r]),d=(0,z.useCallback)(e=>{o.current={...o.current,[e]:{...o.current[e],touched:!0,validated:o.current[e]?.validated??!1,result:o.current[e]?.result??null}},a(o.current)},[]),f=(0,z.useCallback)(e=>{let{[e]:t,...n}=o.current;o.current=n,a(n)},[]),p=(0,z.useCallback)(()=>{let e=!0;for(let[t,n]of Object.entries(s))u(t,n).valid||(e=!1);return e},[s,u]),m=(0,z.useMemo)(()=>({customFunctions:e,get fieldStates(){return o.current},validate:u,touch:d,clear:f,validateAll:p,registerField:l}),[e,i,u,d,f,p,l]);return(0,B.jsx)(Je.Provider,{value:m,children:t})}function $e(){return(0,z.useContext)(Je)}var et=0;function tt(){return et+=1,`${Date.now()}-${et}`}function H(e,t){if(e==null)return e;if(e===`$id`)return tt();if(typeof e==`object`&&!Array.isArray(e)){let n=e,r=Object.keys(n);if(r.length===1&&typeof n.$state==`string`)return t(n.$state);if(r.length===1&&`$id`in n)return tt()}if(Array.isArray(e))return e.map(e=>H(e,t));if(typeof e==`object`){let n={};for(let[r,i]of Object.entries(e))n[r]=H(i,t);return n}return e}var nt=(0,z.createContext)(null);function rt({handlers:e={},navigate:t,children:n}){let{get:r,set:i,getSnapshot:a}=V(),o=$e(),[s,c]=(0,z.useState)(e),[l,u]=(0,z.useState)(new Set),[d,f]=(0,z.useState)(null),p=(0,z.useCallback)((e,t)=>{c(n=>({...n,[e]:t}))},[]),h=(0,z.useCallback)(async e=>{let n=S(e,a()),c=te(),l=Date.now();m({id:c,name:n.action,params:n.params,at:l});let d=!0,p;try{if(n.action===`setState`&&n.params){let e=n.params.statePath,t=n.params.value;e&&i(e,t);return}if(n.action===`pushState`&&n.params){let e=n.params.statePath,t=n.params.value;if(e){let a=H(t,r),o=r(e)??[];i(e,[...o,a]);let s=n.params.clearStatePath;s&&i(s,``)}return}if(n.action===`removeState`&&n.params){let e=n.params.statePath,t=n.params.index;if(e!==void 0&&t!==void 0){let n=r(e)??[];i(e,n.filter((e,n)=>n!==t))}return}if(n.action===`push`&&n.params){let e=n.params.screen;if(e){let t=r(`/currentScreen`),n=r(`/navStack`)??[];t?i(`/navStack`,[...n,t]):i(`/navStack`,[...n,``]),i(`/currentScreen`,e)}return}if(n.action===`pop`){let e=r(`/navStack`)??[];if(e.length>0){let t=e[e.length-1];i(`/navStack`,e.slice(0,-1)),t?i(`/currentScreen`,t):i(`/currentScreen`,void 0)}return}if(n.action===`validateForm`){let e=o?.validateAll;if(!e){console.warn(`validateForm action was dispatched but no ValidationProvider is connected. Ensure ValidationProvider is rendered inside the provider tree.`);return}let t=e(),r={};for(let[e,t]of Object.entries(o.fieldStates))t.result&&!t.result.valid&&(r[e]=t.result.errors);let a=n.params?.statePath||`/formValidation`;i(a,{valid:t,errors:r});return}let e=s[n.action];if(!e){console.warn(`No handler registered for action: ${n.action}`);return}if(n.confirm)return new Promise((t,r)=>{f({action:n,handler:e,resolve:()=>{f(null),t()},reject:()=>{f(null),r(Error(`Action cancelled`))}})}).then(async()=>{u(e=>new Set(e).add(n.action));try{await w({action:n,handler:e,setState:i,navigate:t,executeAction:async e=>{await h(e)}})}finally{u(e=>{let t=new Set(e);return t.delete(n.action),t})}});u(e=>new Set(e).add(n.action));try{await w({action:n,handler:e,setState:i,navigate:t,executeAction:async e=>{await h(e)}})}finally{u(e=>{let t=new Set(e);return t.delete(n.action),t})}}catch(e){throw d=!1,p=e,e}finally{let e=Date.now();k({id:c,name:n.action,ok:d,at:e,durationMs:e-l,error:p})}},[s,r,i,a,t,o]),g=(0,z.useCallback)(()=>{d?.resolve()},[d]),_=(0,z.useCallback)(()=>{d?.reject()},[d]),v=(0,z.useMemo)(()=>({handlers:s,loadingActions:l,pendingConfirmation:d,execute:h,confirm:g,cancel:_,registerHandler:p}),[s,l,d,h,g,_,p]);return(0,B.jsx)(nt.Provider,{value:v,children:n})}function it(){let e=(0,z.useContext)(nt);if(!e)throw Error(`useActions must be used within an ActionProvider`);return e}function at({confirm:e,onConfirm:t,onCancel:n}){let r=e.variant===`danger`;return(0,B.jsx)(`div`,{style:{position:`fixed`,inset:0,backgroundColor:`rgba(0, 0, 0, 0.5)`,display:`flex`,alignItems:`center`,justifyContent:`center`,zIndex:50},onClick:n,children:(0,B.jsxs)(`div`,{style:{backgroundColor:`white`,borderRadius:`8px`,padding:`24px`,maxWidth:`400px`,width:`100%`,boxShadow:`0 20px 25px -5px rgba(0, 0, 0, 0.1)`},onClick:e=>e.stopPropagation(),children:[(0,B.jsx)(`h3`,{style:{margin:`0 0 8px 0`,fontSize:`18px`,fontWeight:600},children:e.title}),(0,B.jsx)(`p`,{style:{margin:`0 0 24px 0`,color:`#6b7280`},children:e.message}),(0,B.jsxs)(`div`,{style:{display:`flex`,gap:`12px`,justifyContent:`flex-end`},children:[(0,B.jsx)(`button`,{onClick:n,style:{padding:`8px 16px`,borderRadius:`6px`,border:`1px solid #d1d5db`,backgroundColor:`white`,cursor:`pointer`},children:e.cancelLabel??`Cancel`}),(0,B.jsx)(`button`,{onClick:t,style:{padding:`8px 16px`,borderRadius:`6px`,border:`none`,backgroundColor:r?`#dc2626`:`#3b82f6`,color:`white`,cursor:`pointer`},children:e.confirmLabel??`Confirm`})]})]})})}var ot=(0,z.createContext)(null);function st({item:e,index:t,basePath:n,children:r}){return(0,B.jsx)(ot.Provider,{value:{item:e,index:t,basePath:n},children:r})}function ct(){return(0,z.useContext)(ot)}var lt=new WeakMap,ut={},dt=class extends z.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,t){console.error(`[json-render] Rendering error in <${this.props.elementType}>:`,e,t.componentStack)}componentDidUpdate(e){this.state.hasError&&e.resetKey!==this.props.resetKey&&this.setState({hasError:!1})}render(){return this.state.hasError?null:this.props.children}},ft={},pt=z.createContext(ft);function mt(){return z.useContext(pt)}var ht=z.createContext(void 0);function gt(){return z.useContext(ht)}function _t(e,t){let n=t.current;if(n===e)return n;if(n&&e){let t=Object.keys(e);if(t.length===Object.keys(n).length&&t.every(t=>Object.prototype.hasOwnProperty.call(n,t)&&n[t]===e[t]))return n}return t.current=e,e}function vt(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function U(e,t){if(Object.is(e,t))return!0;let n=Array.isArray(e);if(n!==Array.isArray(t)||!n&&(e===null||t===null||typeof e!=`object`||typeof t!=`object`))return!1;let r=e,i=t,a=Object.keys(i);return n&&e.length!==t.length||a.length!==Object.keys(r).length?!1:a.every(e=>Object.prototype.hasOwnProperty.call(r,e)&&U(r[e],i[e]))}function yt(e){if(typeof e!=`object`||!e)return e;let t=Array.isArray(e)?Array(e.length):{};for(let n of Object.keys(e))t[n]=yt(e[n]);return t}function bt(e,t){if(Object.is(e,t))return e;let n=Array.isArray(e);if(n!==Array.isArray(t)||!n&&(!vt(e)||!vt(t)))return t;let r=e,i=t,a=Object.keys(i),o=n?Array(t.length):{},s=(!n||e.length===t.length)&&a.length===Object.keys(r).length;for(let e of a){let t=i[e];Object.prototype.hasOwnProperty.call(r,e)?(t=bt(r[e],t),Object.is(r[e],t)||(s=!1)):s=!1,o[e]=t}return s?e:o}function xt(e){let t=(0,z.useRef)({}),n=(0,z.useRef)(0);if(!e)return{};let r=t.current,i={},a={},o=new Set;for(let t of Object.keys(e.elements)){if(a[t]!==void 0)continue;let s=e.elements[t];if(!s)continue;o.add(t);let c=[{key:t,element:s,children:[...s.children??[],...Object.values(s.slots??{}).flat()],childIndex:0,childVersions:[]}];for(;c.length>0;){let t=c[c.length-1],s=t.children[t.childIndex];if(s!==void 0){let n=a[s];if(n!==void 0){t.childVersions.push([s,n]),t.childIndex+=1;continue}let r=e.elements[s];if(!r||o.has(s)){t.childVersions.push([s,-1]),t.childIndex+=1;continue}o.add(s),c.push({key:s,element:r,children:[...r.children??[],...Object.values(r.slots??{}).flat()],childIndex:0,childVersions:[]});continue}let l=r[t.key],u=l&&U(l.own,t.element)&&U(l.children,t.childVersions)?l.version:++n.current;o.delete(t.key),i[t.key]={own:yt(t.element),children:t.childVersions,version:u},a[t.key]=u,c.pop()}}return t.current=i,a}var St=z.memo(function({Component:e,element:t,slots:n,emit:r,on:i,bindings:a,loading:o,children:s}){return(0,B.jsx)(e,{element:t,slots:n,emit:r,on:i,bindings:a,loading:o,children:s})},(e,t)=>e.Component===t.Component&&e.signature===t.signature&&e.execute===t.execute&&e.actionContext?.item===t.actionContext?.item&&e.actionContext?.index===t.actionContext?.index&&e.actionContext?.basePath===t.actionContext?.basePath&&e.functions===t.functions&&e.directives===t.directives&&e.element.props===t.element.props&&e.bindings===t.bindings&&e.loading===t.loading);function Ct(){return z.useSyncExternalStore(D,A,()=>!1)}function wt({element:e,elementKey:t,spec:n,registry:r,loading:i,fallback:a,signatures:o}){let s=Ct(),c=ct(),{ctx:l}=qe(),{execute:u}=it(),{getSnapshot:d,state:f}=V(),m=mt(),_=gt(),v=(0,z.useMemo)(()=>{let e=c?{...l,repeatItem:c.item,repeatIndex:c.index,repeatBasePath:c.basePath}:{...l};return e.functions=m,e.directives=_,e},[l,c,m,_]),y=e.repeat!==void 0&&c==null?p(e.visible):{container:e.visible,itemFilter:void 0},b=y.itemFilter,te=y.container===void 0||j(y.container,v),S=e.on,C=(0,z.useCallback)(async e=>{let t=S?.[e];if(!t)return;let n=Array.isArray(t)?t:[t];for(let e of n){if(!e.params){await u(e);continue}let t={...v,stateModel:d()},n={};for(let[r,i]of Object.entries(e.params))n[r]=g(i,t);await u({...e,params:n})}},[S,u,v,d]),w=(0,z.useCallback)(e=>{let t=S?.[e];return t?{emit:()=>C(e),shouldPreventDefault:(Array.isArray(t)?t:[t]).some(e=>e.preventDefault),bound:!0}:{emit:()=>{},shouldPreventDefault:!1,bound:!1}},[S,C]),T=e.watch,E=(0,z.useRef)(null),D=(0,z.useRef)(void 0),ne=(0,z.useRef)(void 0),O=(0,z.useRef)({}),k=(0,z.useMemo)(()=>{if(!T)return;let e={};for(let t of Object.keys(T))e[t]=x(f,t);let t=D.current;if(t){let n=Object.keys(e);if(n.length===Object.keys(t).length&&n.every(n=>e[n]===t[n]))return t}return D.current=e,e},[T,f]);if((0,z.useEffect)(()=>{if(!T||!k)return;let e=Object.keys(T);if(e.length===0)return;let t=E.current;if(E.current=k,t===null)return;let n=!1;return(async()=>{for(let r of e){if(n)break;if(k[r]!==t[r]){let e=T[r];if(!e)continue;let t=Array.isArray(e)?e:[e];for(let e of t){if(n)break;if(!e.params){if(await u(e),n)break;continue}let t={...v,stateModel:d()},r={};for(let[n,i]of Object.entries(e.params))r[n]=g(i,t);if(await u({...e,params:r}),n)break}}}})().catch(console.error),()=>{n=!0}},[T,k,u,v,d]),!te)return null;let A=e.props??ut,M=_t(h(A,v),ne),N=bt(O.current,ee(A,v));O.current=N;let P=N===e.props?e:{...e,props:N},F=r[P.type]??a;if(!F)return console.warn(`No renderer for component type: ${P.type}`),null;let I=lt.get(r)?.[P.type];if(P.slots&&I?.slots){let e=new Set(I.slots);for(let t of Object.keys(P.slots))t==="default"?console.warn(`[json-render] Component "${P.type}" uses slots.default. Use "children" for default slot content.`):e.has(t)||console.warn(`[json-render] Unknown slot "${t}" on component "${P.type}". Available slots: ${I.slots.join(`, `)}`)}let L=(e,t)=>e.map(e=>{let s=n.elements[e];if(!s){if(!i){let n=t?`in slot "${t}" of "${P.type}"`:`as child of "${P.type}"`;console.warn(`[json-render] Missing element "${e}" referenced ${n}. This element will not render.`)}return null}return(0,B.jsx)(W,{element:s,elementKey:e,spec:n,registry:r,loading:i,fallback:a,signatures:o},e)}),re=P.repeat?(0,B.jsx)(Tt,{element:P,spec:n,registry:r,loading:i,fallback:a,itemFilter:b,signatures:o}):P.children?L(P.children):void 0,ie=P.slots?Object.fromEntries(Object.entries(P.slots).map(([e,t])=>[e,L(t,e)])):void 0,R=(0,B.jsx)(St,{Component:F,signature:o[t??``],execute:u,actionContext:c,functions:m,directives:_,element:P,slots:ie,emit:C,on:w,bindings:M,loading:i,children:re}),ae=s&&t?(0,B.jsx)(`span`,{"data-jr-key":t,style:{display:`contents`},children:R}):R;return(0,B.jsx)(dt,{elementType:P.type,resetKey:o[t??``],children:ae})}var W=z.memo(function(e){return(0,B.jsx)(wt,{...e})},(e,t)=>e.elementKey===t.elementKey&&e.signatures[e.elementKey??``]===t.signatures[t.elementKey??``]&&e.registry===t.registry&&e.loading===t.loading&&e.fallback===t.fallback);function Tt({element:e,spec:t,registry:n,loading:r,fallback:i,signatures:a,itemFilter:o}){let{state:s}=V(),{ctx:c}=qe(),l=ct(),u=e.repeat,d=v(u.statePath,l?.basePath);if(d===void 0)return console.warn(`[json-render] $item in repeat.statePath used outside of a repeat scope`),null;let f=(x(s,d)??[]).map((e,t)=>({itemValue:e,index:t})).filter(({itemValue:e,index:t})=>o===void 0||j(o,{...c,repeatItem:e,repeatIndex:t}));return(0,B.jsx)(B.Fragment,{children:f.map(({itemValue:o,index:s})=>{let c=u.key&&typeof o==`object`&&o?String(o[u.key]??s):String(s);return(0,B.jsx)(st,{item:o,index:s,basePath:_(d,s),children:e.children?.map(o=>{let s=t.elements[o];return s?(0,B.jsx)(W,{element:s,elementKey:o,spec:t,registry:n,loading:r,fallback:i,signatures:a},o):(r||console.warn(`[json-render] Missing element "${o}" referenced as child of "${e.type}" (repeat). This element will not render.`),null)})},c)})})}function Et({spec:e,registry:t,loading:n,fallback:r}){let i=xt(e);if(!e||!e.root)return null;let a=e.elements[e.root];return a?(0,B.jsx)(W,{element:a,elementKey:e.root,spec:e,registry:t,loading:n,fallback:r,signatures:i}):null}function Dt({registry:e,store:t,initialState:n,handlers:r,navigate:i,validationFunctions:a,functions:o,directives:s,onStateChange:c,children:l}){let u=(0,z.useMemo)(()=>s?O(s):void 0,[s]);return(0,B.jsx)(We,{store:t,initialState:n,onStateChange:c,children:(0,B.jsx)(Ke,{children:(0,B.jsx)(Qe,{customFunctions:a,children:(0,B.jsx)(rt,{handlers:r,navigate:i,children:(0,B.jsx)(pt.Provider,{value:o??ft,children:(0,B.jsxs)(ht.Provider,{value:u,children:[l,(0,B.jsx)(Ot,{})]})})})})})})}function Ot(){let{pendingConfirmation:e,confirm:t,cancel:n}=it();return e?.action.confirm?(0,B.jsx)(at,{confirm:e.action.confirm,onConfirm:t,onCancel:n}):null}function kt(e,t){let n={};if(t.components)for(let[e,r]of Object.entries(t.components))n[e]=({element:e,children:t,slots:n,emit:i,on:a,bindings:o,loading:s})=>r({props:e.props,children:t,slots:n,emit:i,on:a,bindings:o,loading:s});let r=e.data.components;r&<.set(n,r);let i=t.actions?Object.entries(t.actions):[];return{registry:n,handlers:(e,t)=>{let n={};for(let[r,a]of i)n[r]=async n=>{let r=e()??(()=>void 0),i=t();await a(n,r,i)};return n},executeAction:async(e,t,n,r={})=>{let a=i.find(([t])=>t===e);a?await a[1](t,n,r):console.warn(`Unknown action: ${e}`)}}}var At={"task.delete":{title:`Delete this task?`,description:`This permanently deletes the task. It cannot be undone.`,label:`Delete`,destructive:!0},"job.run":{title:`Run this job now?`,description:`The job starts immediately with its saved command and settings.`,label:`Run now`,destructive:!1}},jt=(0,z.createContext)(null);function G(){let e=(0,z.useContext)(jt);if(!e)throw Error(`useChatUiAction must be used inside ChatUiActionProvider`);return e}function Mt(){let{outcome:e}=G();return e?(0,B.jsx)(`p`,{role:e.tone===`error`?`alert`:`status`,"data-testid":`chat-ui-action-result`,className:`mt-1.5 text-xs ${e.tone===`error`?`text-error`:`text-on-surface-variant`}`,children:e.text}):null}function Nt({children:e}){let t=r(),n=me(),i=xe(),a=he(),o=ke(),s=Ae(),[c,l]=(0,z.useState)(new Set),[u,d]=(0,z.useState)(null),[f,p]=(0,z.useState)(null),m=(0,z.useRef)(null),h=(0,z.useCallback)((e,t)=>new Promise(n=>{m.current?.(!1),m.current=n,p({name:e,id:t})}),[]),g=e=>{m.current?.(e),m.current=null,p(null)},_=(0,z.useCallback)(async(e,r)=>{let c=r.id;switch(e){case`task.update`:{let{id:e,...t}=r;return await n.mutateAsync({id:c,...t}),`Task updated`}case`task.comment`:return await a.mutateAsync({id:c,content:r.content}),`Comment added`;case`task.delete`:return await i.mutateAsync(c),await t.invalidateQueries({queryKey:[`task`,c]}),`Task deleted`;case`job.run`:return await o.mutateAsync(c),await t.invalidateQueries({queryKey:[`job`,c]}),`Job run started`;case`job.setEnabled`:return await s.mutateAsync({id:c,enabled:r.enabled}),r.enabled?`Job enabled`:`Job disabled`}},[t,n,a,i,o,s]),v=(0,z.useCallback)(async(e,t)=>{let n=T.data.actions[e];if(!n){d({tone:`error`,text:`Unknown action: ${e}`});return}let r=e,i=n.params.safeParse(t??{});if(!i.success){d({tone:`error`,text:`Invalid ${r} parameters`});return}let a=i.data;if(E.has(r)&&!await h(r,a.id))return;let o=`${r}:${a.id}`;l(e=>new Set(e).add(o)),d(null);try{d({tone:`success`,text:await _(r,a)})}catch(e){d({tone:`error`,text:e instanceof Error?e.message:String(e)})}finally{l(e=>{let t=new Set(e);return t.delete(o),t})}},[h,_]),y=(0,z.useMemo)(()=>({run:v,pending:c,outcome:u}),[v,c,u]),b=f?At[f.name]:void 0;return(0,B.jsxs)(jt.Provider,{value:y,children:[e,(0,B.jsx)(Mt,{}),(0,B.jsx)(Oe,{open:!!f,title:b?.title??`Confirm action`,description:f&&b?`${b.description} Target ${f.name===`task.delete`?`task`:`job`}: ${f.id}.`:`This runs as you through the ORC API.`,confirmLabel:b?.label??`Confirm`,variant:b?.destructive===!1?`warning`:`destructive`,onConfirm:()=>g(!0),onCancel:()=>g(!1)})]})}function Pt(){let{run:e}=G();return(0,z.useMemo)(()=>Object.fromEntries(Object.keys(T.data.actions).map(t=>[t,n=>e(t,n)])),[e])}var Ft={neutral:`bg-muted-foreground`,progress:`bg-progress`,success:`bg-secondary`,warning:`bg-tertiary`,error:`bg-error`};function It(e,t){if(!e.startsWith(`/`))return e;let n=new URLSearchParams(t);if(n.get(`chat`)!==`open`)return e;let r=new URL(e,`http://orc.local`),i=r.searchParams;i.set(`chat`,`open`);let a=n.get(`chatThread`);return a&&i.set(`chatThread`,a),`${r.pathname}?${i}${r.hash}`}function K({href:e,children:t,className:n,testId:r}){let i=s(),a=c(`inline-flex min-w-0 items-center text-on-surface underline decoration-outline-variant underline-offset-4 hover:decoration-current focus-visible:outline-2 focus-visible:outline-focus`,n);return e.startsWith(`/`)?(0,B.jsx)(o,{"data-testid":r,to:It(e,i.search),className:a,children:t}):(0,B.jsx)(`a`,{"data-testid":r,href:e,target:`_blank`,rel:`noopener noreferrer`,className:a,children:t})}function Lt({tone:e,className:t}){return(0,B.jsx)(`span`,{"aria-hidden":`true`,className:c(`size-1.5 shrink-0 rounded-full`,Ft[e],t)})}function q({children:e,className:t,testId:n}){return(0,B.jsx)(`section`,{"data-testid":n,className:c(`min-w-0 rounded-lg border border-outline-variant px-3 py-2.5`,t),children:e})}function J({children:e}){return(0,B.jsx)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs text-on-surface-variant`,children:e})}function Y({label:e}){return(0,B.jsx)(`div`,{role:`status`,"aria-label":e,className:`h-14 animate-pulse rounded-lg border border-outline-variant bg-surface`})}function X({label:e,error:t}){let n=t instanceof Error?t.message:String(t);return(0,B.jsxs)(`div`,{role:`alert`,"data-testid":`chat-ui-entity-error`,className:`rounded-lg border border-outline-variant px-3 py-2 text-xs text-on-surface-variant`,children:[(0,B.jsx)(`span`,{className:`text-error`,children:e}),` `,n]})}function Rt({children:e,testId:t}){return(0,B.jsx)(`ul`,{"data-testid":t,className:`min-w-0 divide-y divide-outline-variant`,children:e})}function zt({children:e}){return(0,B.jsx)(`p`,{className:`py-2 text-xs text-on-surface-variant`,children:e})}function Bt({value:e,label:t}){let n=Math.max(0,Math.min(100,e));return(0,B.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,B.jsx)(`div`,{role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":n,"aria-label":t??`Progress`,className:`h-1 flex-1 overflow-hidden rounded-full bg-selected`,children:(0,B.jsx)(`div`,{className:`h-full rounded-full bg-progress`,style:{width:`${n}%`}})}),(0,B.jsxs)(`span`,{className:`shrink-0 text-xs tabular-nums text-on-surface-variant`,children:[t?`${t} · `:``,n,`%`]})]})}function Z(e){if(e==null)return`-`;let t=new Date(typeof e==`number`?e*1e3:e);return Number.isNaN(t.getTime())?`-`:t.toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function Q({title:e,heading:t,testId:n,canExpand:r,children:i}){let[a,o]=(0,z.useState)(!1),[s,c]=(0,z.useState)(!1),l=(0,z.useRef)(null);return(0,B.jsxs)(re,{open:s,onOpenChange:c,children:[(0,B.jsxs)(q,{testId:n,className:`space-y-2`,children:[(0,B.jsxs)(`header`,{className:`flex min-w-0 items-center gap-2`,children:[(0,B.jsx)(`div`,{className:`min-w-0 flex-1 text-sm font-medium`,children:t??e}),r&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`button`,{type:`button`,"data-testid":`chat-ui-expand`,"aria-label":`${a?`Collapse`:`Expand`} ${e}`,"aria-expanded":a,className:`min-h-11 shrink-0 rounded px-2 text-xs text-muted-foreground hover:bg-surface focus-visible:outline-2 focus-visible:outline-focus sm:min-h-8`,onClick:()=>o(e=>!e),children:a?`Collapse`:`Expand`}),(0,B.jsx)(L,{asChild:!0,children:(0,B.jsx)(`button`,{type:`button`,"data-testid":`chat-ui-fullscreen`,"aria-label":`View ${e} fullscreen`,className:`flex size-11 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-surface focus-visible:outline-2 focus-visible:outline-focus sm:size-8`,children:(0,B.jsx)(f,{size:15,"aria-hidden":`true`})})})]})]}),!s&&i(a,!1)]}),(0,B.jsxs)(P,{ref:l,"data-testid":`chat-ui-fullscreen-dialog`,className:`left-0 flex w-screen max-w-none max-h-none translate-x-0 translate-y-0 flex-col gap-3 overflow-hidden rounded-none p-4 sm:rounded-none sm:p-6 [&>button]:size-11`,style:{top:`var(--app-top, 0px)`,height:`var(--app-height, 100dvh)`},onOpenAutoFocus:e=>{e.preventDefault(),l.current?.focus()},onClick:e=>{if(!(e.target instanceof Element))return;let t=e.target.closest(`a`)?.getAttribute(`href`);t?.startsWith(`/`)&&!t.startsWith(`//`)&&c(!1)},children:[(0,B.jsx)(F,{className:`min-w-0 pr-12 break-words`,children:t??e}),(0,B.jsx)(I,{className:`sr-only`,children:`Full current content. Press Escape or Close to return to chat.`}),(0,B.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-auto overscroll-contain`,"data-testid":`chat-ui-fullscreen-content`,children:s&&i(!0,!0)}),s&&(0,B.jsx)(Mt,{})]})]})}var Vt=`default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src data: blob:; font-src data:; connect-src 'none'; form-action 'none'; base-uri 'none'`;function Ht(e){let t=`<meta http-equiv="Content-Security-Policy" content="${Vt}">`,n=/^\s*<!doctype[^>]*>/i.exec(e);return n?`${n[0]}${t}${e.slice(n[0].length)}`:`${t}${e}`}var Ut=(0,z.lazy)(()=>M(()=>import(`./ScratchpadDiagramPreview-CICRpF10.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8])));function Wt({pad:e,expanded:t,fullscreen:n=!1}){let{theme:r}=we(),{darkBackground:i}=fe();return e.kind===`html`?(0,B.jsx)(`iframe`,{"data-testid":`chat-ui-scratchpad-html`,title:`${e.title} preview`,sandbox:`allow-scripts`,referrerPolicy:`no-referrer`,srcDoc:Ht(Ne(e.content,r,i)),className:c(`w-full border border-outline-variant bg-white`,n?`h-full min-h-0`:t?`h-[70vh] min-h-80`:`h-72`)}):e.kind===`diagram`?(0,B.jsx)(z.Suspense,{fallback:(0,B.jsx)(`p`,{role:`status`,children:`Loading diagram…`}),children:(0,B.jsx)(Ut,{content:e.content,title:e.title,expanded:t,fullscreen:n},e.content)}):n&&e.kind!==`doc`?(0,B.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:(0,B.jsx)(N,{readable:!0,children:e.content})}):t?(0,B.jsx)(N,{readable:!0,children:e.content}):(0,B.jsx)(`p`,{className:`line-clamp-4 whitespace-pre-wrap break-words text-xs`,children:e.content})}var Gt=[`todo`,`queued`,`doing`,`review`,`changes_requested`,`blocked`,`done`,`paused`,`cancelled`],Kt=10,$=`text-sm font-medium no-underline hover:underline`,qt=e=>e.charAt(0).toUpperCase()+e.slice(1).replace(/_/g,` `);function Jt({id:e}){let{data:t}=Ee(e);return e?(0,B.jsx)(K,{href:`/projects/${e}`,children:t?.name??`Project`}):null}function Yt({id:e}){let{data:t,isLoading:n,error:r}=_e(e),{run:i,pending:a}=G();if(n)return(0,B.jsx)(Y,{label:`Loading task`});if(r||!t)return(0,B.jsx)(X,{label:`Task unavailable.`,error:r??`Not found`});let o=a.has(`task.update:${e}`)||a.has(`task.delete:${e}`);return(0,B.jsx)(Q,{testId:`chat-ui-task`,title:t.title,heading:(0,B.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-2`,children:[(0,B.jsx)(K,{href:`/tasks/${t.id}`,className:c($,`break-words`),children:t.title}),(0,B.jsx)(Me,{priority:t.priority,className:`shrink-0`})]}),canExpand:!!(t.body&&(t.body.length>120||t.body.split(`
|
|
3
|
+
`).length>2)),children:n=>(0,B.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,B.jsxs)(J,{children:[(0,B.jsx)(de,{status:t.status,className:`px-0`}),(0,B.jsx)(Jt,{id:t.project_id}),(0,B.jsxs)(`span`,{children:[`Updated `,Ce(t.updated_at)]})]}),t.progress>0&&(0,B.jsx)(Bt,{value:t.progress}),t.body&&(0,B.jsx)(`p`,{className:c(`whitespace-pre-wrap break-words text-on-surface-variant`,n?`text-base leading-relaxed`:`line-clamp-2 text-xs`),children:t.body}),(0,B.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-on-surface-variant`,children:[`Status`,(0,B.jsx)(`select`,{"data-testid":`chat-ui-task-status`,"aria-label":`Task status`,className:`form-control form-control-single w-auto min-w-36`,value:t.status,disabled:o,onChange:t=>i(`task.update`,{id:e,status:t.target.value}),children:Gt.map(e=>(0,B.jsx)(`option`,{value:e,children:qt(e)},e))})]})]})})}function Xt({task:e}){return(0,B.jsxs)(`li`,{className:`flex min-w-0 items-center justify-between gap-3 py-2`,children:[(0,B.jsx)(K,{href:`/tasks/${e.id}`,className:`min-w-0 truncate text-sm no-underline hover:underline`,children:(0,B.jsx)(`span`,{className:`truncate`,children:e.title})}),(0,B.jsx)(de,{status:e.status,className:`shrink-0 px-0`})]})}function Zt({projectId:e,status:t,limit:n=Kt}){let r={project_id:e,status:t,limit:n},{data:a,isLoading:o,error:s}=i({queryKey:[`tasks`,`chat-ui`,r],queryFn:()=>d.tasks.list(r)});return o?(0,B.jsx)(Y,{label:`Loading tasks`}):s||!a?(0,B.jsx)(X,{label:`Tasks unavailable.`,error:s}):(0,B.jsxs)(q,{testId:`chat-ui-task-list`,children:[a.tasks.length?(0,B.jsx)(Rt,{children:a.tasks.map(e=>(0,B.jsx)(Xt,{task:e},e.id))}):(0,B.jsx)(zt,{children:`No matching tasks.`}),a.total>a.tasks.length&&(0,B.jsxs)(`p`,{className:`pt-1 text-xs text-on-surface-variant`,children:[a.tasks.length,` of `,a.total,` ·`,` `,(0,B.jsx)(K,{href:e?`/projects/${e}`:`/tasks`,children:`View all`})]})]})}function Qt(e){return e.trigger_type===`cron`&&e.cron_expr?e.cron_expr:qt(e.trigger_type)}function $t({id:e}){let{data:t,isLoading:n,error:r}=je(e),{run:i,pending:a}=G();return n?(0,B.jsx)(Y,{label:`Loading job`}):r||!t?(0,B.jsx)(X,{label:`Job unavailable.`,error:r??`Not found`}):(0,B.jsxs)(q,{testId:`chat-ui-job`,className:`flex flex-col gap-2`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-2`,children:[(0,B.jsx)(K,{href:`/jobs/${t.id}`,className:c($,`break-words`),children:t.name}),(0,B.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-on-surface-variant`,children:[(0,B.jsx)(Lt,{tone:t.enabled?`success`:`neutral`}),t.enabled?`Enabled`:`Disabled`]})]}),t.description&&(0,B.jsx)(`p`,{className:`text-xs text-on-surface-variant`,children:t.description}),(0,B.jsxs)(J,{children:[(0,B.jsx)(`span`,{className:`font-mono`,children:Qt(t)}),(0,B.jsxs)(`span`,{children:[`Last `,Z(t.last_run_at)]}),t.enabled&&t.next_run_at&&(0,B.jsxs)(`span`,{children:[`Next `,Z(t.next_run_at)]}),(0,B.jsxs)(`span`,{children:[t.run_count,` runs`]}),(0,B.jsx)(Jt,{id:t.project_id})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,B.jsx)(l,{"data-testid":`chat-ui-job-run`,size:`sm`,variant:`outline`,disabled:a.has(`job.run:${e}`),onClick:()=>i(`job.run`,{id:e}),children:`Run now`}),(0,B.jsx)(l,{"data-testid":`chat-ui-job-toggle`,size:`sm`,variant:`ghost`,disabled:a.has(`job.setEnabled:${e}`),onClick:()=>i(`job.setEnabled`,{id:e,enabled:!t.enabled}),children:t.enabled?`Disable`:`Enable`})]})]})}function en({projectId:e,limit:t=Kt}){let n={project_id:e,limit:t},{data:r,isLoading:a,error:o}=i({queryKey:[`sessions`,`live`,`chat-ui`,n],queryFn:()=>d.sessions.live(n)});if(a)return(0,B.jsx)(Y,{label:`Loading sessions`});if(o||!r)return(0,B.jsx)(X,{label:`Sessions unavailable.`,error:o});let s=r.sessions.length>3||r.sessions.some(e=>(e.summary?.length??0)>100);return(0,B.jsx)(Q,{testId:`chat-ui-session-list`,title:`Sessions`,canExpand:s,children:e=>(0,B.jsxs)(B.Fragment,{children:[r.sessions.length?(0,B.jsx)(Rt,{children:(e?r.sessions:r.sessions.slice(0,3)).map(t=>(0,B.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-1 py-2`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,B.jsx)(K,{href:`/chat?sessionLive=${encodeURIComponent(t.id)}`,className:`min-w-0 text-sm no-underline hover:underline`,children:(0,B.jsx)(`span`,{className:e?`break-words`:`truncate`,children:t.name??t.agent})}),(0,B.jsx)(ie,{state:ve(t),className:`shrink-0`})]}),t.summary&&(0,B.jsx)(`p`,{className:c(`whitespace-pre-wrap break-words text-on-surface-variant`,e?`text-sm leading-relaxed`:`line-clamp-2 text-xs`),children:t.summary}),(0,B.jsxs)(J,{children:[(0,B.jsx)(`span`,{children:t.agent}),(0,B.jsx)(`span`,{children:Ce(t.last_activity_at)}),t.task&&(0,B.jsx)(K,{href:`/tasks/${t.task.id}`,children:t.task.title})]})]},t.id))}):(0,B.jsx)(zt,{children:`No sessions yet.`}),!e&&r.sessions.length>3&&(0,B.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`3 of `,r.sessions.length,` loaded sessions`]})]})})}function tn(e){return e.length>240||e.split(`
|
|
4
|
+
`).length>4}function nn({id:e}){let{data:t,isLoading:n,error:r}=oe(e);return n?(0,B.jsx)(Y,{label:`Loading scratchpad`}):r||!t?(0,B.jsx)(X,{label:`Scratchpad unavailable.`,error:r??`Not found`}):(0,B.jsx)(Q,{testId:`chat-ui-scratchpad`,title:t.title,heading:(0,B.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,B.jsxs)(K,{href:le(t.id),className:c($,`min-w-0 gap-1.5 break-words`),children:[(0,B.jsx)(Le,{"aria-hidden":`true`,size:14,className:`shrink-0 text-on-surface-variant`}),(0,B.jsx)(`span`,{className:`sr-only`,children:`Scratchpad: `}),(0,B.jsx)(`span`,{className:`min-w-0 break-words`,children:t.title})]}),(0,B.jsx)(`span`,{className:`shrink-0 text-[10px] font-normal uppercase tracking-wide text-on-surface-variant`,children:`Scratchpad`})]}),canExpand:t.kind!==`doc`||tn(t.content),children:(e,n)=>{let r=n&&t.kind!==`doc`;return(0,B.jsxs)(`div`,{className:c(`space-y-1.5`,r&&`flex min-h-0 flex-1 flex-col`),children:[(0,B.jsx)(`div`,{"data-testid":`chat-ui-scratchpad-content`,className:c(r&&`min-h-0 flex-1`),children:(0,B.jsx)(Wt,{pad:t,expanded:e,fullscreen:n})}),(0,B.jsxs)(J,{children:[(0,B.jsx)(`span`,{children:qt(t.kind)}),t.tags.map(e=>(0,B.jsxs)(`span`,{children:[`#`,e]},e)),(0,B.jsxs)(`span`,{children:[`Updated `,Z(t.updated_at)]})]})]})}})}function rn({html:e,title:t,height:n=`short`}){let{theme:r}=we(),{darkBackground:i}=fe();return(0,B.jsx)(`iframe`,{"data-testid":`chat-ui-html`,title:t??`Inline HTML content`,sandbox:`allow-scripts`,referrerPolicy:`no-referrer`,loading:`lazy`,srcDoc:Ht(Ne(e,r,i)),className:c(`w-full rounded-md border border-outline-variant bg-background`,n===`tall`?`h-[26rem]`:`h-60`)})}var an={up:Ve,down:ze,flat:Fe},on={up:`Trending up`,down:`Trending down`,flat:`Flat`};function sn({label:e,value:t,unit:n,hint:r,trend:i}){let a=i?an[i]:null;return(0,B.jsxs)(`div`,{"data-testid":`chat-ui-metric`,className:`min-w-0`,children:[(0,B.jsx)(`p`,{className:`break-words text-xs text-on-surface-variant`,title:e,children:e}),(0,B.jsxs)(`p`,{className:`mt-0.5 flex min-w-0 items-baseline gap-1`,children:[(0,B.jsx)(`span`,{className:`text-2xl font-medium tabular-nums break-words text-on-surface`,children:typeof t==`number`?De(t):t}),n&&(0,B.jsx)(`span`,{className:`text-sm text-on-surface-variant`,children:n})]}),(r||i)&&(0,B.jsxs)(`p`,{className:`mt-0.5 flex items-center gap-1 text-xs text-on-surface-variant`,children:[a&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(a,{"data-testid":`chat-ui-metric-trend`,size:12,"aria-hidden":`true`}),(0,B.jsxs)(`span`,{className:`sr-only`,children:[on[i??`flat`],`: `]})]}),r&&(0,B.jsx)(`span`,{className:`min-w-0 break-words`,children:r})]})]})}function cn({value:e,label:t}){return(0,B.jsx)(`div`,{"data-testid":`chat-ui-progress`,className:`min-w-0 max-w-md`,children:(0,B.jsx)(Bt,{value:e,label:t})})}function ln(e){return e.map((e,t)=>({key:`${t}:${e}`,value:e}))}function un({columns:e,rows:t,caption:n}){let r=ln(e),i=t.map((e,t)=>({key:`row-${t}`,cells:ln(e)}));return(0,B.jsxs)(`figure`,{"data-testid":`chat-ui-table`,className:`min-w-0`,children:[n&&(0,B.jsx)(`figcaption`,{className:`mb-1 break-words text-xs text-on-surface-variant`,title:n,children:n}),(0,B.jsx)(`section`,{"aria-label":n??`Table`,tabIndex:0,"data-testid":`chat-ui-table-scroll`,className:`max-w-full overflow-x-auto overscroll-x-contain rounded-sm focus-visible:outline-2 focus-visible:outline-focus`,children:(0,B.jsxs)(`table`,{className:`w-full border-collapse text-sm`,children:[(0,B.jsx)(`thead`,{children:(0,B.jsx)(`tr`,{className:`border-b border-outline-variant text-left text-xs text-on-surface-variant`,children:r.map(e=>(0,B.jsx)(`th`,{scope:`col`,className:`whitespace-nowrap py-1.5 pr-4 font-normal last:pr-0`,children:e.value},e.key))})}),i.length===0?(0,B.jsx)(`tbody`,{children:(0,B.jsx)(`tr`,{children:(0,B.jsx)(`td`,{"data-testid":`chat-ui-table-empty`,colSpan:r.length,className:`py-1.5 text-xs text-on-surface-variant`,children:`No rows`})})}):(0,B.jsx)(`tbody`,{className:`divide-y divide-outline-variant`,children:i.map(e=>(0,B.jsx)(`tr`,{children:e.cells.map(e=>(0,B.jsx)(`td`,{title:e.value.length>32?e.value:void 0,className:`min-w-24 max-w-none break-words py-1.5 pr-4 align-top text-on-surface last:pr-0 md:max-w-56`,children:e.value},e.key))},e.key))})]})})]})}function dn({items:e,title:t}){let n=e.map((e,t)=>({...e,key:`${t}:${e.label}`}));return(0,B.jsxs)(`div`,{"data-testid":`chat-ui-key-value`,className:`min-w-0`,children:[t&&(0,B.jsx)(`p`,{className:`truncate text-xs text-on-surface-variant`,children:t}),(0,B.jsx)(`dl`,{className:`grid grid-cols-[minmax(0,auto)_minmax(0,1fr)] gap-x-4 gap-y-1 text-sm`,children:n.map(e=>(0,B.jsxs)(`div`,{className:`contents`,children:[(0,B.jsx)(`dt`,{className:`min-w-0 break-words text-on-surface-variant`,children:e.label}),(0,B.jsx)(`dd`,{className:`min-w-0 break-words text-on-surface`,children:e.value})]},e.key))})]})}var fn={info:{Icon:ye,color:`text-progress`},warn:{Icon:ae,color:`text-tertiary`},error:{Icon:ge,color:`text-error`},done:{Icon:Te,color:`text-secondary`}},pn={info:`Info`,warn:`Warning`,error:`Error`,done:`Done`};function mn({tone:e,text:t,title:n}){let{Icon:r,color:i}=fn[e];return(0,B.jsxs)(`div`,{"data-testid":`chat-ui-callout`,"data-tone":e,className:`flex min-w-0 gap-2 rounded-md border border-outline-variant px-3 py-2`,children:[(0,B.jsx)(r,{"aria-hidden":`true`,size:16,className:c(`mt-0.5 shrink-0`,i)}),(0,B.jsxs)(`div`,{className:`min-w-0 text-sm`,children:[(0,B.jsxs)(`span`,{className:`sr-only`,children:[pn[e],`: `]}),n&&(0,B.jsx)(`p`,{className:`break-words font-medium text-on-surface`,children:n}),(0,B.jsx)(`p`,{className:`break-words text-on-surface`,children:t})]})]})}function hn({sessionId:e}){let t=Se().thread?.sourceId===e,{data:n,isLoading:r,error:i}=ue(e,t);if(r)return(0,B.jsx)(Y,{label:`Loading session usage`});if(i)return(0,B.jsx)(X,{label:`Session usage unavailable.`,error:i});let a=R(n?.latest),o=n?.compactions?.length??0,s=a?se(a.tokens,a.percent,o):null;return(0,B.jsxs)(q,{testId:`chat-ui-session-usage`,className:`space-y-1`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[(0,B.jsx)(`p`,{className:`min-w-0 flex-1 text-xs text-on-surface-variant`,children:`Session usage`}),s&&(0,B.jsxs)(ce,{label:`session usage`,testId:`chat-ui-session-usage-help`,children:[(0,B.jsx)(`p`,{children:s.explanation}),(0,B.jsx)(`p`,{className:`mt-2`,children:s.note})]})]}),a?(0,B.jsxs)(`p`,{"data-testid":`chat-ui-session-usage-figure`,className:`text-sm tabular-nums text-on-surface`,title:`${pe(a.tokens,!1)} tokens in the latest request, ${a.percent}% served from cache`,children:[pe(a.tokens,!1),` input tokens`,(0,B.jsxs)(`span`,{className:`text-on-surface-variant`,children:[` · `,a.percent,`% cached`]})]}):(0,B.jsx)(`p`,{"data-testid":`chat-ui-session-usage-empty`,className:`text-xs text-on-surface-variant`,children:`This session has no recorded usage yet.`})]})}var gn=(0,z.lazy)(()=>M(()=>import(`./Chart-BMFNlgbS.js`),__vite__mapDeps([9,1,2,10,11,12,4,13,14,6,15,16,17,18,5,19,20,21,22,23,24,25,26,27,7,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,8,49,50,51,52]))),_n=(0,z.lazy)(()=>M(()=>import(`./Chart-BMFNlgbS.js`).then(e=>({default:e.Sparkline})),__vite__mapDeps([9,1,2,10,11,12,4,13,14,6,15,16,17,18,5,19,20,21,22,23,24,25,26,27,7,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,8,49,50,51,52]))),vn=()=>(0,B.jsx)(`div`,{className:`h-56 w-full`,"aria-hidden":`true`}),yn=()=>(0,B.jsxs)(`div`,{className:`min-w-0`,"aria-hidden":`true`,children:[(0,B.jsx)(`div`,{className:`h-4 w-24`}),(0,B.jsx)(`div`,{className:`h-8 w-40 max-w-full`})]}),bn={sm:`gap-1.5`,md:`gap-3`,lg:`gap-5`},xn={primary:`default`,secondary:`outline`,destructive:`destructive`},{registry:Sn}=kt(T,{components:{Stack:({props:e,children:t})=>(0,B.jsx)(`div`,{className:c(`flex min-w-0`,e.direction===`horizontal`?`flex-row flex-wrap items-center`:`flex-col`,bn[e.gap??`md`]),children:t}),Button:({props:e,emit:t,loading:n})=>(0,B.jsx)(l,{type:`button`,size:`sm`,className:`w-fit`,"data-testid":`chat-ui-button`,variant:xn[e.variant??`secondary`],disabled:n,onClick:()=>t(`press`),children:e.label}),Task:({props:e})=>(0,B.jsx)(Yt,{id:e.id}),TaskList:({props:e})=>(0,B.jsx)(Zt,{projectId:e.projectId,status:e.status,limit:e.limit}),Job:({props:e})=>(0,B.jsx)($t,{id:e.id}),SessionList:({props:e})=>(0,B.jsx)(en,{projectId:e.projectId,limit:e.limit}),Scratchpad:({props:e})=>(0,B.jsx)(nn,{id:e.id}),Metric:({props:e})=>(0,B.jsx)(sn,{label:e.label,value:e.value,unit:e.unit,hint:e.hint,trend:e.trend}),Progress:({props:e})=>(0,B.jsx)(cn,{value:e.value,label:e.label}),Table:({props:e})=>(0,B.jsx)(un,{columns:e.columns,rows:e.rows,caption:e.caption}),Sparkline:({props:e})=>(0,B.jsx)(z.Suspense,{fallback:(0,B.jsx)(yn,{}),children:(0,B.jsx)(_n,{values:e.values,label:e.label})}),Chart:({props:e})=>(0,B.jsx)(z.Suspense,{fallback:(0,B.jsx)(vn,{}),children:(0,B.jsx)(gn,{kind:e.kind,labels:e.labels,series:e.series,title:e.title})}),KeyValue:({props:e})=>(0,B.jsx)(dn,{items:e.items,title:e.title}),Callout:({props:e})=>(0,B.jsx)(mn,{tone:e.tone,text:e.text,title:e.title}),Html:({props:e})=>(0,B.jsx)(rn,{html:e.html,title:e.title,height:e.height}),SessionUsage:({props:e})=>(0,B.jsx)(hn,{sessionId:e.sessionId})}});function Cn({spec:e}){let t=Pt(),n=a();return(0,B.jsx)(Dt,{registry:Sn,handlers:t,navigate:n,initialState:e.state,children:(0,B.jsx)(Et,{spec:e,registry:Sn})})}function wn({source:e}){let t=(0,z.useMemo)(()=>C(e),[e]);return t.ok?(0,B.jsx)(`div`,{"data-testid":`chat-ui-block`,className:`my-2 min-w-0`,children:(0,B.jsx)(Nt,{children:(0,B.jsx)(Cn,{spec:t.spec})})}):(0,B.jsx)(be,{source:e,error:t.error})}export{wn as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./jsx-runtime-CVMpzJz9.js";import{t}from"./button-DaSTTBls.js";import{a as n,i as r,n as i,o as a,r as o,t as s}from"./dialog-CSqhD8HZ.js";var c=e();function l({open:e,onConfirm:l,onCancel:u,title:d,description:f,confirmLabel:p=`Delete`,variant:m=`destructive`,isPending:h}){return(0,c.jsx)(s,{open:e,onOpenChange:e=>!e&&u(),children:(0,c.jsxs)(i,{className:`bg-surface border-surface-highest max-w-sm`,children:[(0,c.jsxs)(n,{children:[(0,c.jsx)(a,{className:`font-headline text-sm text-on-surface`,children:d}),(0,c.jsx)(o,{className:`font-body text-xs text-outline mt-2`,children:f})]}),(0,c.jsxs)(r,{className:`mt-4`,children:[(0,c.jsx)(t,{"data-testid":`confirm-dialog-cancel`,type:`button`,variant:`ghost`,size:`sm`,onClick:u,className:`font-label text-xs text-outline`,children:`Cancel`}),(0,c.jsx)(t,{"data-testid":`confirm-dialog-confirm`,variant:`ghost`,type:`button`,size:`sm`,onClick:l,disabled:h,className:m===`destructive`?`font-label text-xs bg-error/15 text-error border border-error/30 hover:bg-error/25`:`font-label text-xs bg-tertiary/15 text-tertiary border border-tertiary/30 hover:bg-tertiary/25`,children:h?`...`:p})]})]})})}export{l as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{n as r}from"./useMutation-CRAWY7v2.js";import{f as i}from"./chunk-OB3PAWPO-BD6ylT0A.js";import{t as a}from"./button-DaSTTBls.js";import{n as o}from"./client-BD4crXth.js";import{t as s}from"./ResumeActions-Cri_ELlT.js";import{Ar as c,X as l,Z as u,_t as d,dr as f,en as p,jr as m,qt as h,st as g,tn as _,xr as v}from"./index-Q_RymVqx.js";import{F as y,P as b,dt as x,i as S,n as C,r as w}from"./AreaChart-DcUZ3SzF.js";import{t as T}from"./Bar-BEUEq4ZT.js";import{t as E}from"./Line-BwNoqzSJ.js";import{i as D}from"./chat-ui-chart-CdwnX81S.js";import{o as O}from"./useJobs-DJfPRESN.js";import{t as k}from"./PriorityBadge-CMPd6WIn.js";import{t as A}from"./ViewHeader-B2ixMGCg.js";import{a as j,i as M,n as N,o as P,r as F,t as I}from"./table-CVtwh2DT.js";import{t as L}from"./useProjectScope-DpgzthH7.js";import{n as R}from"./UsageSettings-CCV85_v_.js";var z=e(t()),B=[`axis`],V=(0,z.forwardRef)((e,t)=>z.createElement(C,{chartName:`ComposedChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:B,tooltipPayloadSearcher:y,categoricalChartProps:e,ref:t})),H=n();function U(e,t){let n=new Map;for(let r of e){let e=t.find(e=>e.id===r.project_id),i=e?e.id:`cwd:${r.cwd??``}`,a=n.get(i)??{key:i,name:e?.name??r.cwd?.split(/[\\/]/).filter(Boolean).pop()??`No folder`,detail:e?e.git_remote_url?.replace(/\.git$/,``).split(/[:/]/).slice(-2).join(`/`)??null:r.cwd,projectId:e?.id??null,sessions:[]};a.sessions.push(r),n.set(i,a)}return[...n.values()]}function W({projectId:e}){let t=i(),n=L(e),s=f(`sm`),c=e=>{let r=new URL(e,window.location.origin);r.searchParams.set(`project`,n),t({pathname:r.pathname,search:r.search,hash:r.hash})},p=n===`all`?void 0:{project_id:n},m=g(p),{data:_,isLoading:y}=m,b=O(p),{data:x}=b,{data:S}=v(),C=h(!1,p?.project_id),w=r({queryKey:[`usage-report`,`30`,`day`,``,``,n],queryFn:()=>o.settings.usageReport({days:`30`,granularity:`day`,...p??{}}),staleTime:3e4}),T=U((C.data??[]).filter(e=>n===`all`||(n===`unassigned`?e.project_id===null:e.project_id===n)).filter((e,t)=>t<20||e.status!==`stopped`),S??[]).map(e=>({...e,sessions:e.sessions.slice(0,5)})),E=n===`unassigned`?(x??[]).filter(e=>e.project_id===null):x??[],D=[...n===`unassigned`?(_??[]).filter(e=>e.project_id===null):_??[]].sort((e,t)=>new Date(t.updated_at).getTime()-new Date(e.updated_at).getTime()).slice(0,8),R=E.filter(e=>e.enabled),z=n===`all`?`All Projects`:n===`unassigned`?`Unassigned`:S?.find(e=>e.id===n)?.name??``;return(0,H.jsxs)(`div`,{"data-activity-preview":!0,"data-testid":`activity-preview`,className:`activity-preview`,children:[(0,H.jsx)(A,{title:`Activity`,meta:z||`All projects`,action:(0,H.jsx)(a,{onClick:()=>c(`/tasks`),children:`View tasks`})}),[{name:`Sessions`,query:C},{name:`Usage`,query:w},{name:`Tasks`,query:m},{name:`Jobs`,query:b}].filter(({query:e})=>e.error).map(({name:e,query:t})=>(0,H.jsx)(l,{message:`${e}: ${t.error?.message??`Could not load activity`}`,onRetry:()=>t.refetch()},e)),(0,H.jsx)(G,{report:w.data}),(0,H.jsx)(K,{groups:T,loading:C.isLoading,onNavigate:c}),(0,H.jsxs)(`section`,{className:`activity-section`,children:[(0,H.jsxs)(`div`,{className:`activity-section-heading`,children:[(0,H.jsx)(`h2`,{children:`Recent tasks`}),(0,H.jsx)(`button`,{type:`button`,className:`activity-text-action`,onClick:()=>c(`/tasks`),children:`View all`})]}),y?(0,H.jsx)(`div`,{className:`space-y-2`,children:[0,1,2,3].map(e=>(0,H.jsx)(d,{className:`h-10 w-full`},e))}):D.length===0?(0,H.jsx)(`p`,{className:`activity-empty`,children:`No tasks`}):s?(0,H.jsxs)(I,{className:`activity-task-table`,children:[(0,H.jsx)(j,{children:(0,H.jsxs)(P,{children:[(0,H.jsx)(M,{children:`Task`}),(0,H.jsx)(M,{className:`w-36`,children:`Status`}),(0,H.jsx)(M,{className:`w-28`,children:`Priority`}),(0,H.jsx)(M,{className:`w-28`,children:`Updated`})]})}),(0,H.jsx)(N,{children:D.map(e=>(0,H.jsxs)(P,{onClick:()=>c(`/tasks/${e.id}`),children:[(0,H.jsx)(F,{children:(0,H.jsx)(`button`,{type:`button`,className:`activity-task-title`,onClick:t=>{t.stopPropagation(),c(`/tasks/${e.id}`)},children:e.title})}),(0,H.jsx)(F,{children:(0,H.jsx)(`span`,{className:`activity-status`,"data-status":e.status,children:(0,H.jsx)(u,{status:e.status})})}),(0,H.jsx)(F,{children:(0,H.jsx)(`span`,{className:`activity-priority`,children:(0,H.jsx)(k,{priority:e.priority})})}),(0,H.jsx)(F,{className:`activity-muted`,children:new Date(e.updated_at).toLocaleDateString()})]},e.id))})]}):(0,H.jsx)(`div`,{className:`activity-task-list`,children:D.map(e=>(0,H.jsxs)(`article`,{className:`activity-task-mobile`,children:[(0,H.jsx)(`button`,{type:`button`,className:`activity-task-title`,onClick:()=>c(`/tasks/${e.id}`),children:e.title}),(0,H.jsxs)(`div`,{className:`activity-task-meta`,children:[(0,H.jsx)(`span`,{className:`activity-status`,"data-status":e.status,children:(0,H.jsx)(u,{status:e.status})}),(0,H.jsx)(`span`,{className:`activity-priority`,children:(0,H.jsx)(k,{priority:e.priority})}),(0,H.jsx)(`span`,{children:new Date(e.updated_at).toLocaleDateString()})]})]},e.id))})]}),(0,H.jsx)(`div`,{className:`activity-secondary`,children:R.length>0&&(0,H.jsxs)(`section`,{className:`activity-section`,children:[(0,H.jsxs)(`div`,{className:`activity-section-heading`,children:[(0,H.jsx)(`h2`,{children:`Active jobs`}),(0,H.jsx)(`button`,{type:`button`,className:`activity-text-action`,onClick:()=>c(`/jobs`),children:`View all`})]}),(0,H.jsx)(`div`,{className:`activity-row-list`,children:R.slice(0,5).map(e=>(0,H.jsxs)(`button`,{type:`button`,className:`activity-row`,onClick:()=>c(`/jobs/${e.id}`),children:[(0,H.jsxs)(`span`,{className:`activity-row-heading`,children:[(0,H.jsx)(`span`,{children:e.name}),(0,H.jsx)(`span`,{className:`activity-muted`,children:e.trigger_type})]}),e.last_run_at&&(0,H.jsxs)(`span`,{className:`activity-row-description`,children:[`Last run `,new Date(e.last_run_at).toLocaleString()]})]},e.id))})]})})]})}function G({report:e}){let t=R(e),n=t.reduce((e,t)=>e+t.total_tokens,0);return(0,H.jsxs)(`figure`,{className:`activity-chart`,"data-testid":`activity-chart`,children:[(0,H.jsxs)(`figcaption`,{children:[(0,H.jsxs)(`span`,{className:`activity-chart-legend`,children:[(0,H.jsxs)(`span`,{children:[(0,H.jsx)(`i`,{style:{background:`var(--color-series-1)`}}),`Tokens`]}),(0,H.jsxs)(`span`,{children:[(0,H.jsx)(`i`,{style:{background:`var(--color-series-2)`}}),`Sessions`]})]}),(0,H.jsxs)(`span`,{className:`activity-muted`,children:[D(n),` tokens in 30 days`]})]}),(0,H.jsx)(`div`,{className:`activity-chart-plot`,children:t.length===0?(0,H.jsx)(`p`,{className:`activity-empty`,children:`No usage recorded`}):(0,H.jsx)(x,{width:`100%`,height:`100%`,children:(0,H.jsxs)(V,{data:t,margin:{top:4,right:0,bottom:0,left:0},children:[(0,H.jsx)(S,{dataKey:`label`,tick:{fill:`var(--color-muted-foreground)`,fontSize:10},tickLine:!1,axisLine:{stroke:`var(--color-border)`},minTickGap:24}),(0,H.jsx)(w,{yAxisId:`tokens`,hide:!0}),(0,H.jsx)(w,{yAxisId:`sessions`,orientation:`right`,hide:!0}),(0,H.jsx)(b,{cursor:{fill:`var(--color-border)`,opacity:.4},content:({active:e,payload:t})=>{let n=e?t?.[0]?.payload:void 0;return n?(0,H.jsxs)(`div`,{className:`rounded-md border border-border bg-surface px-2 py-1.5 text-xs tabular-nums shadow-sm`,children:[(0,H.jsx)(`p`,{className:`font-medium`,children:n.label}),(0,H.jsxs)(`p`,{children:[D(n.total_tokens),` tokens`]}),(0,H.jsxs)(`p`,{children:[n.sessions,` sessions`]})]}):null}}),(0,H.jsx)(T,{yAxisId:`tokens`,dataKey:`total_tokens`,fill:`var(--color-series-1)`,radius:[2,2,0,0],isAnimationActive:!1}),(0,H.jsx)(E,{yAxisId:`sessions`,dataKey:`sessions`,type:`monotone`,stroke:`var(--color-series-2)`,strokeWidth:2,dot:!1,isAnimationActive:!1})]})})})]})}function K({groups:e,loading:t,onNavigate:n}){return(0,H.jsxs)(`section`,{className:`activity-section`,"aria-label":`Recent sessions`,children:[(0,H.jsxs)(`div`,{className:`activity-section-heading`,children:[(0,H.jsx)(`h2`,{children:`Sessions`}),(0,H.jsx)(`button`,{type:`button`,className:`activity-text-action`,onClick:()=>n(`/chat?sessionList=show`),children:`View all`})]}),t?(0,H.jsx)(`div`,{className:`space-y-2`,children:[0,1,2].map(e=>(0,H.jsx)(d,{className:`h-12 w-full`},e))}):e.length===0?(0,H.jsx)(`p`,{className:`activity-empty`,children:`No sessions yet`}):(0,H.jsx)(`div`,{className:`activity-session-groups`,children:e.map(e=>{let t=e.sessions.filter(e=>e.status!==`stopped`).length,r=e.sessions.reduce((e,t)=>e+(t.tokens_used??0),0);return(0,H.jsxs)(`div`,{className:`activity-session-group`,"data-testid":`activity-session-group`,children:[(0,H.jsxs)(`div`,{className:`activity-session-group-heading`,children:[(0,H.jsxs)(`span`,{className:`min-w-0 truncate`,children:[e.projectId?(0,H.jsx)(`button`,{type:`button`,className:`activity-group-name`,onClick:()=>n(`/projects/${e.projectId}`),children:e.name}):(0,H.jsx)(`span`,{className:`activity-group-name`,children:e.name}),e.detail&&(0,H.jsx)(`span`,{className:`activity-group-detail`,title:e.detail,children:e.detail})]}),(0,H.jsxs)(`span`,{className:`activity-muted shrink-0 tabular-nums`,children:[t>0?`${t} live · `:``,D(r),` tokens`]})]}),e.sessions.map(e=>(0,H.jsxs)(`div`,{className:`activity-session`,"data-stopped":e.status===`stopped`||void 0,children:[(0,H.jsxs)(`button`,{type:`button`,className:`activity-session-main`,"data-testid":`activity-session-link`,"data-session-id":e.id,onClick:()=>n(`/chat?sessionLive=${encodeURIComponent(e.id)}`),children:[(0,H.jsx)(c,{state:m(e),compact:!0}),(0,H.jsx)(`span`,{className:`activity-session-title`,children:e.name??e.summary??e.agent}),(0,H.jsxs)(`span`,{className:`activity-session-meta`,children:[(0,H.jsx)(`span`,{children:e.agent}),(0,H.jsx)(`span`,{className:`tabular-nums`,children:p(e)}),(0,H.jsx)(`span`,{children:_(e.last_activity_at)}),e.task&&(0,H.jsx)(`span`,{className:`activity-session-task`,title:e.task.title,children:e.task.title})]})]}),(0,H.jsx)(s,{session:e})]},e.id))]},e.key)})})]})}export{W as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.activity-preview{color:rgb(var(--foreground));font-size:14px;line-height:1.5}.activity-heading,.activity-section-heading{justify-content:space-between;align-items:center;gap:16px;display:flex}.activity-heading{margin-bottom:28px}.activity-heading h1{letter-spacing:-.02em;font-size:22px;font-weight:500;line-height:1.3}.activity-heading p{color:rgb(var(--muted-foreground));margin-top:4px;font-size:13px}.activity-primary{background:rgb(var(--primary));color:rgb(var(--primary-foreground));border-radius:6px;flex-shrink:0;padding:8px 14px;font-size:13px;font-weight:500}.activity-primary:hover{opacity:.9}.activity-row:hover,.activity-session:hover{background:rgb(var(--surface))}.activity-section{min-width:0;margin-bottom:32px}.activity-section-heading{margin-bottom:12px}.activity-section h2{font-size:16px;font-weight:500}.activity-text-action{color:rgb(var(--muted-foreground));padding:8px 0 8px 12px;font-size:13px}.activity-text-action:hover,.activity-task-title:hover{color:rgb(var(--foreground));text-underline-offset:4px;text-decoration:underline}.activity-task-table tr{border-color:rgb(var(--border) / .65)}.activity-task-table th{height:36px;color:rgb(var(--muted-foreground));font-size:12px;font-weight:400}.activity-task-table th:first-child,.activity-task-table td:first-child{padding-left:0}.activity-task-table td{padding-top:9px;padding-bottom:9px;font-size:12px}.activity-task-table tbody tr:hover{background:rgb(var(--surface));cursor:pointer}.activity-task-title{min-height:28px;color:rgb(var(--foreground));text-align:left;overflow-wrap:anywhere;font-size:14px;font-weight:400}.activity-status>span,.activity-priority>span{color:rgb(var(--muted-foreground));background:0 0;border:0;border-radius:0;padding:0;font-size:12px;font-weight:400}.activity-status>span>span{background:rgb(var(--muted-foreground));opacity:1;border-radius:50%;flex-shrink:0;width:6px;height:6px}.activity-status[data-status=doing]>span>span,.activity-status[data-status=queued]>span>span{background:rgb(var(--progress))}.activity-status[data-status=blocked]>span>span,.activity-status[data-status=changes_requested]>span>span{background:rgb(var(--error))}.activity-status[data-status=review]>span>span{background:rgb(var(--warning))}.activity-status[data-status=done]>span>span{background:rgb(var(--success))}.activity-priority>.text-error{color:rgb(var(--error))}.activity-priority>.text-tertiary{color:rgb(var(--warning))}.activity-secondary{grid-template-columns:repeat(2,minmax(0,1fr));gap:32px;display:grid}.activity-row{border-bottom:1px solid rgb(var(--border) / .65);text-align:left;flex-direction:column;gap:4px;width:100%;min-width:0;padding:12px 0;display:flex}.activity-row-heading{overflow-wrap:anywhere;flex-wrap:wrap;justify-content:space-between;align-items:baseline;gap:8px;font-size:13px;font-weight:400;display:flex}.activity-row-description{-webkit-line-clamp:2;color:rgb(var(--muted-foreground));-webkit-box-orient:vertical;font-size:13px;line-height:1.5;display:-webkit-box;overflow:hidden}.activity-muted,.activity-empty{color:rgb(var(--muted-foreground))}.activity-empty{padding:24px 0;font-size:14px}.activity-task-mobile{border-bottom:1px solid rgb(var(--border) / .65);padding:12px 0}.activity-task-meta{color:rgb(var(--muted-foreground));flex-wrap:wrap;gap:8px 16px;margin-top:4px;font-size:12px;display:flex}@media (width<=639px){.activity-heading{margin-bottom:20px}.activity-secondary{grid-template-columns:minmax(0,1fr);gap:0}}@media (width<=767px),(any-pointer:coarse){.activity-task-title{min-height:44px}}.activity-chart{margin-bottom:28px}.activity-chart-legend{gap:14px;display:inline-flex}.activity-chart-legend span{align-items:center;gap:6px;display:inline-flex}.activity-chart-legend i{border-radius:50%;width:8px;height:8px}.activity-chart figcaption{justify-content:space-between;gap:8px;font-size:13px;display:flex}.activity-chart-plot{height:110px;margin-top:6px}.activity-chart-plot .activity-empty{padding:32px 0;font-size:12px}.activity-session-groups{flex-direction:column;gap:20px;display:flex}.activity-session-group-heading{border-bottom:1px solid rgb(var(--border));justify-content:space-between;align-items:baseline;gap:12px;padding-bottom:6px;font-size:12px;display:flex}.activity-group-name{color:rgb(var(--foreground));font-size:13px;font-weight:500}button.activity-group-name:hover{text-underline-offset:4px;text-decoration:underline}.activity-group-detail{color:rgb(var(--muted-foreground));font-family:var(--font-mono,ui-monospace, monospace);margin-left:8px;font-size:11px}.activity-session{border-bottom:1px solid rgb(var(--border) / .5);border-radius:4px;align-items:center;gap:8px;min-width:0;padding:2px 6px 2px 0;display:flex}@media (hover:hover) and (pointer:fine){.activity-session{position:relative}.activity-session>:last-child{opacity:0;background:rgb(var(--surface));border-radius:6px;position:absolute;right:0}.activity-session:hover>:last-child,.activity-session:focus-within>:last-child{opacity:1}}.activity-session[data-stopped] .activity-session-main{opacity:.65}.activity-session-main{text-align:left;flex:1;align-items:center;gap:8px;min-width:0;min-height:36px;display:flex}.activity-session-title{text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0;font-size:13px;overflow:hidden}.activity-session-meta{color:rgb(var(--muted-foreground));flex-shrink:0;align-items:center;gap:12px;font-size:12px;display:flex}.activity-session-task{text-overflow:ellipsis;white-space:nowrap;background:rgb(var(--surface));border-radius:4px;max-width:180px;padding:0 6px;overflow:hidden}@media (width<=639px){.activity-group-detail{display:none}.activity-session-main{flex-wrap:wrap;padding:6px 0}.activity-session-title{flex-basis:calc(100% - 32px)}.activity-session-meta{flex-wrap:wrap;flex-shrink:1;flex-basis:100%;gap:4px 10px;padding-left:28px}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{f as r,h as i}from"./chunk-OB3PAWPO-BD6ylT0A.js";import{t as a}from"./button-DaSTTBls.js";import{t as o}from"./MarkdownEditor-C7LnwPSG.js";var s=e(t(),1),c=n(),l=new Map,u=new Set;typeof window<`u`&&window.addEventListener(`beforeunload`,e=>{l.size&&(e.preventDefault(),e.returnValue=``)});function d(e){return u.has(e)?!1:l.has(e)?window.confirm(`Discard unsaved changes to this document?`)?(l.delete(e),!0):!1:!0}function f({documentId:e,content:t,path:n,onSave:f,testId:p,wikiLinks:m,navigation:h,expanded:g,onExpandedChange:_,layout:v,pageTitle:y,hideFrontmatter:b,compact:x}){let[S]=i(),C=r(),w=S.get(`editorMode`),T=w===`edit`||w===`split`?w:`read`,E=(0,s.useRef)(l.get(e)??{original:t,content:t}),[D,O]=(0,s.useState)(E.current.content),[k,A]=(0,s.useState)(E.current.original),[j,M]=(0,s.useState)(!1),[N,P]=(0,s.useState)(null),F=(0,s.useRef)(!1),I=(0,s.useRef)(E.current.content),L=D!==k;(0,s.useEffect)(()=>{l.has(e)||(O(t),I.current=t,A(t))},[t,e]);function R(t){I.current=t,O(t),t===k?l.delete(e):l.set(e,{original:k,content:t})}async function z(){if(!f||!L||F.current)return;F.current=!0,u.add(e),M(!0),P(null);let t=I.current;try{let n=await f(t,k),r=typeof n==`string`?n:t;A(r),I.current===t?(l.delete(e),I.current=r,O(r)):l.set(e,{original:r,content:I.current})}catch(e){P(e instanceof Error?e.message:`Could not save document`)}finally{F.current=!1,u.delete(e),M(!1)}}function B(e){let t=new URLSearchParams(window.location.search);t.set(`editorMode`,e),t.toString()!==new URLSearchParams(window.location.search).toString()&&C({search:t.toString(),hash:window.location.hash})}function V(){d(e)&&(O(t),A(t),I.current=t,P(null))}let H=f?j?`Saving…`:L?`Unsaved changes`:`Saved`:`Read-only`,U=(0,c.jsxs)(c.Fragment,{children:[N&&(0,c.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[N,` Your draft has been kept.`]}),L&&t!==k&&(0,c.jsx)(`p`,{role:`status`,className:`text-sm text-outline`,children:`The document changed elsewhere. Your draft is preserved; saving will check for conflicts.`})]});return v===`page`?(0,c.jsx)(`div`,{className:`min-w-0`,"data-testid":`document-workspace`,children:(0,c.jsx)(o,{path:n,value:D,onChange:R,onSave:()=>void z(),readOnly:!f||j,testId:p,wikiLinks:m,initialMode:`read`,mode:T,onModeChange:B,expanded:g,onExpandedChange:_,layout:`page`,pageTitle:y,hideFrontmatter:b,compact:x,notice:N||L&&t!==k?U:void 0,actions:(T!==`read`||L||j)&&(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(`span`,{"data-testid":`document-save-status`,role:`status`,className:`text-xs text-outline`,children:H}),f&&(L||j)&&(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(a,{type:`button`,size:`sm`,variant:`ghost`,"data-testid":`document-discard`,disabled:j,onClick:V,children:`Discard`}),(0,c.jsx)(a,{type:`button`,size:`sm`,"data-testid":`document-save`,disabled:j,onClick:()=>void z(),children:`Save`})]})]})})}):(0,c.jsx)(`div`,{className:`min-w-0 space-y-3`,"data-testid":`document-workspace`,children:(0,c.jsx)(o,{path:n,value:D,onChange:R,onSave:()=>void z(),readOnly:!f||j,testId:p,wikiLinks:m,initialMode:`read`,mode:T,onModeChange:B,expanded:g,onExpandedChange:_,layout:v,compact:x,header:(0,c.jsxs)(`div`,{className:`space-y-2`,children:[h&&(0,c.jsx)(`div`,{className:`mb-3 min-w-0`,children:h}),(0,c.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,c.jsx)(`span`,{"data-testid":`document-save-status`,role:`status`,className:`min-w-0 flex-1 text-sm text-outline`,children:H}),f&&(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(a,{type:`button`,variant:`ghost`,"data-testid":`document-discard`,disabled:!L||j,onClick:V,children:`Discard changes`}),(0,c.jsx)(a,{type:`button`,"data-testid":`document-save`,disabled:!L||j,onClick:()=>void z(),children:`Save changes`})]})]}),U]})})})}export{d as n,f as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{n as r}from"./QueryClientProvider-DlPztvhd.js";import{h as i}from"./chunk-OB3PAWPO-BD6ylT0A.js";import{n as a}from"./client-BD4crXth.js";import{t as o}from"./MarkdownEditor-C7LnwPSG.js";import{t as s}from"./file-kind-BYU1kv95.js";import{Ft as c,Ur as l}from"./index-Q_RymVqx.js";var u=e(t(),1),d=n(),f=new Map;typeof window<`u`&&window.addEventListener(`beforeunload`,e=>{f.size!==0&&(e.preventDefault(),e.returnValue=``)});function p({terminalId:e,path:t,content:n,readOnly:p,onDirty:m}){let[h,g]=i(),_=h.get(`editorMode`),v=_===`read`||_===`split`?_:`edit`,y=`${e}:${t}`,b=(0,u.useRef)(f.get(y)??{original:n,content:n}),x=(0,u.useRef)(b.current.original),S=(0,u.useRef)(b.current.content),[C,w]=(0,u.useState)(b.current.content!==b.current.original),[T,E]=(0,u.useState)(!1),[D,O]=(0,u.useState)(null),[k,A]=(0,u.useState)(b.current.content),j=r(),M=(0,u.useRef)(()=>{}),N=(0,u.useRef)(!1),P=(0,u.useRef)(!1),F=(0,u.useRef)(m);F.current=m;async function I(){if(N.current||p||S.current===x.current)return;N.current=!0,E(!0),O(null);let n=S.current;try{await a.git.saveFile(e,t,n,x.current),x.current=n;let r=S.current!==n;w(r),P.current&&F.current(r),r?f.set(y,{original:n,content:S.current}):f.delete(y),j.invalidateQueries({queryKey:[`checkout-files`,e,t]}),j.invalidateQueries({queryKey:[`git`,e]})}catch(e){O(e instanceof Error?e.message:`Could not save file`)}finally{N.current=!1,E(!1)}}M.current=()=>void I(),(0,u.useEffect)(()=>(P.current=!0,F.current(b.current.content!==b.current.original),()=>{P.current=!1}),[]),(0,u.useEffect)(()=>{N.current||f.has(y)||n===x.current||(x.current=n,S.current=n,A(n),w(!1),P.current&&F.current(!1))},[n,y]);function L(e){S.current=e,A(e);let t=e!==x.current;w(t),F.current(t),t?f.set(y,{original:x.current,content:e}):f.delete(y)}function R(){window.confirm(`Discard your edits and reload the file from disk?`)&&a.git.files(e,t).then(e=>{if(e.content===null||e.binary||e.truncated)throw Error(`File is no longer editable`);x.current=e.content,S.current=e.content,f.delete(y),A(e.content),w(!1),F.current(!1),O(null)}).catch(e=>O(e instanceof Error?e.message:`Could not reload file`))}let z=(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 border-b border-surface-highest px-2 py-1`,children:[(0,d.jsxs)(`button`,{type:`button`,"data-testid":`file-save`,disabled:!C||T||p,onClick:()=>void I(),className:`flex min-h-11 items-center gap-1 rounded px-2 py-1 text-sm text-primary hover:bg-surface-highest disabled:opacity-40`,title:`Save (Ctrl/Cmd+S)`,children:[(0,d.jsx)(l,{size:14}),T?`Saving…`:`Save`]}),(0,d.jsx)(`span`,{"data-testid":`file-save-status`,className:`min-w-0 flex-1 truncate text-sm text-on-surface-variant`,children:p?`Read-only preview`:C?`Unsaved changes`:`Saved`})]}),D&&(0,d.jsxs)(`div`,{role:`alert`,className:`shrink-0 border-b border-error/30 p-2 text-xs text-error`,children:[D,(0,d.jsx)(`button`,{type:`button`,"data-testid":`file-reload`,onClick:R,className:`ml-2 underline`,children:`Reload from disk`})]})]});return(0,d.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,"data-testid":`file-editor`,children:[!s(t)&&z,(0,d.jsx)(`div`,{"data-testid":`file-preview`,className:`min-h-0 flex-1 overflow-hidden`,children:s(t)?(0,d.jsx)(o,{path:t,value:k,onChange:L,onSave:()=>M.current(),readOnly:p,height:`100%`,testId:`file-editor-input`,header:z,mode:v,onModeChange:e=>g(t=>{let n=new URLSearchParams(t);return n.set(`editorMode`,e),n})}):(0,d.jsx)(c,{path:t,value:k,onChange:L,onSave:()=>M.current(),readOnly:p,height:`100%`,testId:`file-editor-input`})})]})}export{p as FileEditor};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{h as r,p as i,t as a}from"./chunk-OB3PAWPO-BD6ylT0A.js";import{vi as o,yi as s}from"./index-Q_RymVqx.js";import{c}from"./useIntegrations-CsGP9sio.js";var l=e(t(),1),u=n(),d=`/settings?settingsSection=connections&connectionsTab=integrations&integrationsTab=connections`;function f(){let{name:e=``}=i(),[t]=r(),n=c(),f=t.get(`code`),p=t.get(`state`),m=t.get(`error_description`)??t.get(`error`),h=(0,l.useRef)(!1);(0,l.useEffect)(()=>{!h.current&&f&&p&&(h.current=!0,n.mutate({name:e,code:f,state:p}))},[n,e,f,p]);let g=m??(!f||!p?`The sign-in response is missing its code.`:n.error?.message);return(0,u.jsxs)(`main`,{className:`mx-auto max-w-md p-6`,"data-testid":`integration-callback`,children:[(0,u.jsxs)(`h1`,{className:`mb-3 font-headline text-base`,children:[`Sign in to `,e]}),g?(0,u.jsxs)(`p`,{role:`alert`,className:`flex gap-2 text-sm text-error`,children:[(0,u.jsx)(s,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),(0,u.jsx)(`span`,{className:`min-w-0 wrap-break-word`,children:g})]}):n.isSuccess?(0,u.jsxs)(`p`,{role:`status`,className:`flex gap-2 text-sm`,children:[(0,u.jsx)(o,{className:`mt-0.5 size-4 shrink-0 text-success`,"aria-hidden":!0}),`Signed in. ORC and the `,(0,u.jsx)(`code`,{children:`spec`}),` CLI now use this connection's tokens.`]}):(0,u.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Finishing sign-in…`}),(0,u.jsx)(a,{to:d,className:`mt-4 inline-block text-sm text-primary underline`,children:`Back to connections`})]})}export{f as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{n as r}from"./QueryClientProvider-DlPztvhd.js";import{n as i,t as a}from"./useMutation-CRAWY7v2.js";import{t as o}from"./chunk-OB3PAWPO-BD6ylT0A.js";import{t as s}from"./button-DaSTTBls.js";import{i as c,n as l}from"./client-BD4crXth.js";import{t as u}from"./label-dQSF_SAL.js";import{Nr as d,Pr as f,X as p}from"./index-Q_RymVqx.js";import{l as m}from"./useJobs-DJfPRESN.js";var h=e(t(),1);function g(e){return i({queryKey:[`webhooks`,e],queryFn:()=>l.webhooks.list(e),select:e=>e.webhooks})}function _(e){return i({queryKey:[`webhook-deliveries`,e],queryFn:()=>l.webhooks.deliveries(e),select:e=>e.deliveries,enabled:!!e,refetchInterval:3e3})}function v(){let e=r();return a({mutationFn:e=>l.webhooks.create(e),onSuccess:()=>e.invalidateQueries({queryKey:[`webhooks`]})})}function y(){let e=r();return a({mutationFn:({id:e,...t})=>l.webhooks.update(e,t),onSuccess:()=>e.invalidateQueries({queryKey:[`webhooks`]})})}function b(){let e=r();return a({mutationFn:e=>l.webhooks.delete(e),onSuccess:()=>e.invalidateQueries({queryKey:[`webhooks`]})})}function x(){return a({mutationFn:e=>l.webhooks.rotate(e)})}function S(e){return[...new Set(e.split(`,`).map(e=>e.trim()).filter(Boolean))]}function C(e,t,n){return new URL(`/webhooks/${encodeURIComponent(e)}`,new URL(t,n)).href}function w(e){return[`localhost`,`127.0.0.1`,`[::1]`].includes(new URL(e).hostname)}var T=n();function E({id:e,testId:t,value:n,onChange:r,placeholder:i}){let[a,o]=(0,h.useState)(n.join(`, `));return(0,T.jsx)(d,{id:e,"data-testid":t,value:a,placeholder:i,onChange:e=>{o(e.target.value),r(e.target.value)}})}function D({projectId:e,onCreated:t}){let n=v(),[r,i]=(0,h.useState)(``),[a,o]=(0,h.useState)(`github`),[c,l]=(0,h.useState)(null),p=(0,h.useId)();return c?(0,T.jsxs)(`div`,{"data-testid":`webhook-created`,className:`space-y-3`,children:[(0,T.jsx)(j,{hook:c,secret:c.secret}),(0,T.jsx)(s,{type:`button`,variant:`outline`,"data-testid":`webhook-setup-done`,onClick:()=>{t?.(c),l(null),i(``)},children:`I've copied the setup details`})]}):(0,T.jsxs)(`div`,{className:`space-y-3`,"data-testid":`webhook-create-form`,children:[(0,T.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,T.jsx)(u,{htmlFor:`${p}-name`,children:`Webhook name`}),(0,T.jsx)(f,{label:`Webhook name`,testId:`webhook-create-help`,children:`Create the event source here. Connect jobs and choose their event filters in Jobs. No job is required to create a webhook.`})]}),(0,T.jsx)(d,{id:`${p}-name`,"data-testid":`webhook-name`,value:r,onChange:e=>i(e.target.value),maxLength:100,placeholder:`GitHub repository events`})]}),(0,T.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,T.jsx)(u,{htmlFor:`${p}-provider`,children:`Provider`}),(0,T.jsxs)(`select`,{id:`${p}-provider`,"data-testid":`webhook-provider`,className:`w-full min-h-8 rounded-md border border-control-border bg-background px-3 text-sm`,value:a,onChange:e=>o(e.target.value),children:[(0,T.jsx)(`option`,{value:`github`,children:`GitHub`}),(0,T.jsx)(`option`,{value:`generic`,children:`Other service (HMAC)`})]})]}),n.error&&(0,T.jsx)(`p`,{role:`alert`,className:`text-sm text-error`,children:n.error.message}),(0,T.jsx)(s,{type:`button`,"data-testid":`webhook-create`,disabled:!r.trim()||n.isPending,onClick:()=>n.mutate({name:r.trim(),provider:a,project_id:e??null},{onSuccess:l}),children:n.isPending?`Creating...`:`Create webhook`})]})}function O({value:e,onChange:t,projectId:n}){let{data:r,error:i,isLoading:a,refetch:o}=g(n),c=r?.filter(e=>e.project_id===null||e.project_id===n),[l,d]=(0,h.useState)(!1),f=(0,h.useId)();function m(n){e.some(e=>e.webhook_id===n)||t([...e,{webhook_id:n,events:[],actions:[]}])}function _(n,r,i){t(e.map(e=>e.webhook_id===n?{...e,[r]:S(i)}:e))}return(0,T.jsxs)(`section`,{className:`space-y-3 border-y border-border py-4`,"data-testid":`job-webhook-picker`,children:[(0,T.jsx)(`h3`,{className:`text-sm font-medium`,children:`Which webhook should trigger this job?`}),i?(0,T.jsx)(p,{message:i.message,onRetry:()=>o()}):(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(u,{htmlFor:`${f}-source`,children:`Configured webhooks`}),(0,T.jsxs)(`select`,{id:`${f}-source`,"data-testid":`job-webhook-select`,className:`w-full min-h-8 rounded-md border border-control-border bg-background px-3 text-sm`,value:``,disabled:a,onChange:e=>{e.target.value&&m(e.target.value)},children:[(0,T.jsx)(`option`,{value:``,children:a?`Loading webhooks...`:`Select an existing webhook`}),(c??[]).filter(t=>!e.some(e=>e.webhook_id===t.id)).map(e=>(0,T.jsxs)(`option`,{value:e.id,children:[e.name,e.enabled?``:` (disabled)`]},e.id))]}),!a&&!c?.length&&(0,T.jsx)(`p`,{className:`text-xs text-outline`,children:`No webhooks configured for this project yet. Create one below or on the Webhooks page.`})]}),e.map(n=>(0,T.jsxs)(`div`,{className:`space-y-2 border-t border-border pt-3`,"data-testid":`job-webhook-binding`,"data-webhook-id":n.webhook_id,children:[(0,T.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,T.jsx)(`span`,{className:`text-sm font-medium`,children:c?.find(e=>e.id===n.webhook_id)?.name??n.webhook_id}),(0,T.jsx)(s,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`job-webhook-remove`,onClick:()=>t(e.filter(e=>e.webhook_id!==n.webhook_id)),children:`Disconnect`})]}),(0,T.jsx)(u,{htmlFor:`${f}-events-${n.webhook_id}`,children:`Events for this job`}),(0,T.jsx)(E,{id:`${f}-events-${n.webhook_id}`,testId:`webhook-events`,value:n.events,onChange:e=>_(n.webhook_id,`events`,e),placeholder:`pull_request, push (blank accepts all)`}),(0,T.jsx)(u,{htmlFor:`${f}-actions-${n.webhook_id}`,children:`Actions for this job (optional)`}),(0,T.jsx)(E,{id:`${f}-actions-${n.webhook_id}`,testId:`webhook-actions`,value:n.actions,onChange:e=>_(n.webhook_id,`actions`,e),placeholder:`opened, synchronize (blank accepts all)`})]},n.webhook_id)),(0,T.jsx)(s,{type:`button`,size:`sm`,variant:`outline`,"data-testid":`webhook-add`,onClick:()=>d(!l),children:l?`Close new webhook`:`Create a webhook`}),l&&(0,T.jsx)(D,{projectId:n,onCreated:e=>{m(e.id),d(!1)}})]})}function k({job:e}){let t=m(),[n,r]=(0,h.useState)(e.webhooks??[]);return(0,T.jsxs)(`section`,{className:`space-y-3`,"data-testid":`job-webhooks`,children:[!e.enabled&&(0,T.jsx)(`p`,{className:`text-sm text-outline`,children:`Job disabled. Configure connections now and enable it from Jobs when ready.`}),(0,T.jsx)(O,{value:n,onChange:r,projectId:e.project_id??void 0}),t.error&&(0,T.jsx)(`p`,{role:`alert`,className:`text-sm text-error`,children:t.error.message}),(0,T.jsx)(s,{type:`button`,size:`sm`,"data-testid":`job-webhooks-save`,disabled:t.isPending,onClick:()=>t.mutate({id:e.id,webhooks:n,trigger_type:`webhook`}),children:`Save connections`}),t.isSuccess&&(0,T.jsx)(`p`,{role:`status`,className:`text-xs text-outline`,children:`Connections saved.`}),(0,T.jsx)(o,{className:`inline-block text-sm underline`,to:`/webhooks?project=${encodeURIComponent(e.project_id??`all`)}`,children:`Manage configured webhooks and deliveries`})]})}function A({label:e,value:t,secret:n=!1}){let[r,i]=(0,h.useState)(!1),[a,o]=(0,h.useState)(!1);return(0,T.jsxs)(`div`,{className:`space-y-1`,children:[(0,T.jsx)(`p`,{className:`text-xs text-outline`,children:e}),(0,T.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,T.jsx)(`code`,{className:`min-w-0 flex-1 break-all text-xs`,"data-testid":n?`webhook-secret`:`webhook-url`,children:t}),(0,T.jsx)(s,{type:`button`,size:`sm`,variant:`outline`,"aria-label":`Copy ${e}`,onClick:async()=>{try{await navigator.clipboard.writeText(t),i(!0),o(!1)}catch{o(!0)}},children:r?`Copied`:`Copy`})]}),a&&(0,T.jsx)(`p`,{role:`alert`,className:`text-xs text-error`,children:`Select and copy the value above; clipboard access is unavailable.`})]})}function j({hook:e,secret:t,showInstructions:n=!0,instructionsId:r}){let i=C(e.token,c(),window.location.origin);return(0,T.jsxs)(`div`,{className:`space-y-3`,"data-testid":`webhook-setup`,children:[(0,T.jsx)(A,{label:`Payload URL`,value:i}),w(i)&&(0,T.jsx)(`p`,{className:`text-sm text-warning`,children:`This address is local. For external providers, use your publicly reachable ORC address with the same /webhooks/ path.`}),n&&(0,T.jsxs)(`div`,{id:r,"data-testid":`webhook-setup-instructions`,className:`space-y-3`,children:[t?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(A,{label:`Signing secret`,value:t,secret:!0}),(0,T.jsx)(`p`,{className:`text-xs text-outline`,children:`Copy the signing secret before leaving. It is shown once.`})]}):(0,T.jsx)(`p`,{className:`text-xs text-outline`,children:`The signing secret is hidden. Generate a replacement only if you need to reconnect the sender.`}),e.provider===`github`?(0,T.jsxs)(`ol`,{className:`list-decimal space-y-1 pl-5 text-sm text-outline`,children:[(0,T.jsx)(`li`,{children:`In your repository, open GitHub Settings - Webhooks - Add webhook.`}),(0,T.jsx)(`li`,{children:`Paste the Payload URL, select application/json, and enter the signing secret.`}),(0,T.jsx)(`li`,{children:`Select the events needed by your connected jobs. Each job has its own filters.`}),(0,T.jsx)(`li`,{children:`Send a test event, then open Recent deliveries for this webhook.`})]}):(0,T.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:e}){let t=y(),n=x(),[r,i]=(0,h.useState)(!1),[a,c]=(0,h.useState)(!1),[l,u]=(0,h.useState)(!1),[d,f]=(0,h.useState)(),p=(0,h.useId)();return(0,T.jsxs)(`article`,{className:`space-y-3 border-b border-border pb-5`,"data-testid":`webhook-endpoint`,"data-webhook-id":e.id,children:[(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,T.jsx)(`h3`,{className:`text-sm font-medium`,children:e.name}),(0,T.jsxs)(`span`,{className:`text-xs text-outline`,children:[e.provider,` - `,e.enabled?`Enabled`:`Disabled`]}),(0,T.jsx)(s,{type:`button`,variant:`outline`,size:`sm`,disabled:t.isPending,onClick:()=>t.mutate({id:e.id,enabled:!e.enabled}),children:e.enabled?`Disable`:`Enable`})]}),(0,T.jsxs)(`div`,{className:`space-y-1`,"data-testid":`webhook-connected-jobs`,children:[(0,T.jsxs)(`p`,{className:`text-xs text-outline`,children:[`Connected jobs (`,e.subscriptions.length,`)`]}),e.subscriptions.length?e.subscriptions.map(e=>(0,T.jsxs)(`div`,{className:`text-sm`,children:[(0,T.jsx)(o,{className:`underline`,"data-testid":`webhook-job-link`,to:`/jobs/${e.job_id}?project=all`,children:e.name}),(0,T.jsxs)(`span`,{className:`text-xs text-outline`,children:[` `,`- `,e.enabled?`Enabled`:`Disabled`,`; events:`,` `,e.events.join(`, `)||`all`,`; actions:`,` `,e.actions.join(`, `)||`all`]})]},e.job_id)):null]}),(0,T.jsx)(j,{hook:e,secret:d,showInstructions:a,instructionsId:p}),(0,T.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,T.jsx)(s,{type:`button`,variant:`outline`,size:`sm`,"data-testid":`webhook-deliveries-toggle`,onClick:()=>i(!r),children:r?`Hide deliveries`:`Recent deliveries`}),(0,T.jsx)(s,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`webhook-setup-toggle`,"aria-expanded":a,"aria-controls":a?p:void 0,disabled:n.isPending,onClick:()=>{a&&f(void 0),c(!a),u(!1)},children:a?d?`I've copied the setup details`:`Hide setup`:`Setup instructions`})]}),a&&(0,T.jsx)(s,{type:`button`,variant:`ghost`,size:`sm`,disabled:n.isPending,onClick:()=>u(!l),children:`New signing secret`}),a&&l&&(0,T.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[(0,T.jsx)(`p`,{children:`The sender's existing secret will stop working. Update it after generating the replacement.`}),(0,T.jsx)(s,{type:`button`,variant:`outline`,size:`sm`,disabled:n.isPending,onClick:()=>n.mutate(e.id,{onSuccess:e=>{f(e.secret),c(!0),u(!1)}}),children:`Generate replacement secret`})]}),(t.error||n.error)&&(0,T.jsx)(`p`,{role:`alert`,className:`text-sm text-error`,children:(t.error??n.error)?.message}),r&&(0,T.jsx)(N,{id:e.id})]})}function N({id:e}){let{data:t,isLoading:n,error:r,refetch:i}=_(e);return(0,T.jsxs)(`section`,{className:`space-y-2`,"data-testid":`webhook-deliveries`,children:[(0,T.jsx)(`h4`,{className:`text-sm font-medium`,children:`Recent deliveries`}),r?(0,T.jsx)(p,{message:r.message,onRetry:()=>i()}):n?(0,T.jsx)(`p`,{role:`status`,children:`Loading deliveries...`}):t?.length?t.map(e=>(0,T.jsxs)(`div`,{className:`space-y-1 border-t border-border py-2 text-xs`,"data-testid":`webhook-delivery`,children:[(0,T.jsxs)(`div`,{className:`flex flex-wrap justify-between gap-2`,children:[(0,T.jsxs)(`span`,{children:[e.event,e.action?` / ${e.action}`:``]}),(0,T.jsx)(`span`,{children:e.status})]}),(0,T.jsxs)(`p`,{className:`text-outline`,children:[e.repository,` `,new Date(e.created_at).toLocaleString()]}),e.status===`ignored`&&(0,T.jsx)(`p`,{className:`text-outline`,children:`No enabled connected job matched this event.`}),e.error&&(0,T.jsx)(`p`,{className:`text-error`,children:e.error}),e.runs.map(e=>(0,T.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,T.jsxs)(o,{className:`underline`,to:`/jobs/${e.job_id}?project=all`,children:[`Job run: `,e.status]}),e.task_id&&(0,T.jsx)(o,{className:`underline`,to:`/tasks/${e.task_id}?project=all`,children:`Created task`}),e.session_id&&(0,T.jsx)(o,{className:`underline`,to:`/audit/${e.session_id}?project=all`,children:`Agent session`})]},e.job_run_id))]},e.id)):(0,T.jsx)(`p`,{className:`text-sm text-outline`,children:`No events received yet. Register the endpoint with your provider, then send an event.`})]})}export{b as a,O as i,D as n,g as o,M as r,k as t};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{n as r}from"./useMutation-CRAWY7v2.js";import{f as i,h as a,t as o}from"./chunk-OB3PAWPO-BD6ylT0A.js";import{t as s}from"./button-DaSTTBls.js";import{P as c,n as l}from"./client-BD4crXth.js";import{t as u}from"./chevron-down-BRt1smOS.js";import{t as d}from"./ResponsiveFilters-DvvXTUvm.js";import{t as f}from"./textarea-Cf2b0PUV.js";import{t as p}from"./label-dQSF_SAL.js";import{t as m}from"./scroll-area-BnIPAyIC.js";import{a as h,c as g,d as _,i as v,m as y,o as b}from"./schemas-BQZhekae.js";import{L as x,n as S}from"./chat-DGhEIqmi.js";import{a as C,i as w,o as T}from"./dialog-CSqhD8HZ.js";import{Ct as E,Fn as D,Hr as ee,Ir as te,Jr as O,Kr as ne,Mn as k,Nr as A,On as j,Pn as M,Pr as N,Pt as P,St as F,X as I,Z as L,_t as R,bi as re,bn as ie,bt as ae,dn as z,dr as oe,fn as se,hn as ce,ln as le,lt as ue,pn as de,un as fe,vt as pe,xr as me,xt as he,yn as ge,yt as _e}from"./index-Q_RymVqx.js";import{t as ve}from"./ConfirmDialog-TrdcniMK.js";import{a as ye,c as B,i as be,l as V,n as xe,o as Se,r as Ce,s as we,t as Te}from"./useJobs-DJfPRESN.js";import{t as H}from"./ViewHeader-B2ixMGCg.js";import{t as Ee}from"./useDetailRoute-B-xjWsyW.js";import{t as U}from"./view-params-YEmeZppw.js";import{t as De}from"./EmptyState-YM4VSLR9.js";import{a as Oe,i as W,n as ke,o as G,r as K,t as Ae}from"./table-CVtwh2DT.js";import{t as je}from"./useProjectScope-DpgzthH7.js";import{n as Me,t as Ne}from"./useListSelection-DUGh7MfO.js";import{i as Pe,t as Fe}from"./JobWebhooks-CKOr3jed.js";var q={name:`play`,size:24,node:[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]};q.node;var J=c(q),Y={name:`power`,size:24,node:[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]};Y.node;var Ie=c(Y),X=e(t(),1),Z=n();function Le({jobId:e,open:t,onClose:n,onEdit:r,projectScope:i=`all`}){let{data:o,isLoading:c,error:l,refetch:u}=Ce(e),d=o&&(i===`all`||(i===`unassigned`?o.project_id===null:o.project_id===i)),f=d?o:void 0;(0,X.useEffect)(()=>{t&&o&&!d&&n()},[t,o,d,n]);let{data:p,isLoading:m,error:h,refetch:g}=ye(f?.id??null),_=B(),v=V(),[y]=a(),[b,x]=(0,X.useState)(()=>y.get(`run`));return(0,Z.jsx)(pe,{open:t,onOpenChange:e=>!e&&n(),children:(0,Z.jsxs)(ae,{"data-testid":`job-detail-sheet`,children:[(0,Z.jsxs)(F,{children:[(0,Z.jsx)(E,{children:f?.name??`Job details`}),f?.description&&(0,Z.jsx)(`p`,{className:`font-body text-xs text-outline mt-1`,children:f.description})]}),(0,Z.jsx)(_e,{children:l?(0,Z.jsx)(I,{message:l.message,onRetry:()=>u()}):c?(0,Z.jsx)(`div`,{className:`space-y-3`,children:[...[,,,,,,]].map((e,t)=>(0,Z.jsx)(R,{className:`h-8 w-full bg-surface-highest`},t))}):f?(0,Z.jsxs)(`div`,{className:`space-y-6`,children:[(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(P,{label:`Action`,children:(0,Z.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:f.action?.type===`agent`?`Run agent (${f.action.backend}): ${f.action.prompt}`:f.action?.type===`task`?`Create task: ${f.action.title}`:f.command})}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,Z.jsx)(P,{label:`Trigger Type`,children:(0,Z.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:f.trigger_type})}),(0,Z.jsx)(P,{label:`Enabled`,children:(0,Z.jsx)(`span`,{className:`font-label text-xs font-bold ${f.enabled?`text-secondary`:`text-outline`}`,children:f.enabled?`● ON`:`○ OFF`})})]}),f.cron_expr&&(0,Z.jsx)(P,{label:`Cron Expression`,children:(0,Z.jsx)(`code`,{className:`font-mono text-xs`,children:f.cron_expr})}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,Z.jsxs)(P,{label:`Timeout`,children:[f.timeout_secs,`s`]}),(0,Z.jsx)(P,{label:`Max Retries`,children:f.max_retries}),(0,Z.jsx)(P,{label:`Overlap`,children:f.overlap})]}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,Z.jsx)(P,{label:`Notify On`,children:f.notify_on}),(0,Z.jsx)(P,{label:`Run Count`,children:f.run_count})]}),f.next_run_at&&(0,Z.jsx)(P,{label:`Next Run`,children:new Date(f.next_run_at).toLocaleString()})]}),!f.command.startsWith(`__`)&&(0,Z.jsxs)(`details`,{className:`border-y border-border py-2`,children:[(0,Z.jsxs)(`summary`,{className:`min-h-8 cursor-pointer text-sm`,children:[`Webhook connections (`,f.webhooks?.length??0,`)`]}),(0,Z.jsx)(Fe,{job:f},f.id)]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`font-label text-xs font-medium text-outline mb-3`,children:`Recent runs`}),h?(0,Z.jsx)(I,{message:h.message,onRetry:()=>g()}):m?(0,Z.jsx)(`div`,{className:`space-y-2`,children:[...[,,,]].map((e,t)=>(0,Z.jsx)(R,{className:`h-8 w-full bg-surface-highest`},t))}):p?.length?(0,Z.jsx)(`div`,{className:`space-y-1`,children:p.map(t=>(0,Z.jsx)(Re,{run:t,jobId:e,expanded:b===t.id,onToggle:()=>x(b===t.id?null:t.id)},t.id))}):(0,Z.jsx)(`div`,{className:`font-label text-xs text-outline py-4 text-center`,children:`No runs yet`})]})]}):(0,Z.jsx)(`p`,{className:`text-sm text-outline`,children:`Job not found`})}),(0,Z.jsxs)(he,{className:`flex-wrap`,children:[(v.error||_.error)&&(0,Z.jsx)(`p`,{role:`alert`,className:`w-full text-sm text-error`,children:(v.error??_.error)?.message}),f&&r&&(0,Z.jsxs)(s,{"data-testid":`job-detail-edit`,size:`sm`,variant:`outline`,onClick:()=>r(f),children:[(0,Z.jsx)(O,{size:16}),`Edit job`]}),f&&(0,Z.jsxs)(s,{size:`sm`,variant:`ghost`,disabled:v.isPending,onClick:()=>v.mutate({id:f.id,enabled:!f.enabled}),className:`font-label text-xs font-medium`,children:[(0,Z.jsx)(Ie,{size:12,className:`mr-1.5`}),f.enabled?`Disable`:`Enable`]}),f&&(0,Z.jsxs)(s,{variant:`ghost`,size:`sm`,disabled:_.isPending,onClick:()=>_.mutate(f.id,{onSuccess:e=>x(e.run_id)}),className:`font-label text-xs font-medium bg-transparent text-on-surface border border-control-border hover:bg-surface`,children:[(0,Z.jsx)(J,{size:12,className:`mr-1.5`}),_.isPending?`Triggering...`:`Trigger run`]})]})]})})}function Re({run:e,jobId:t,expanded:n,onToggle:r}){let a=i(),[c,d]=(0,X.useState)(!1),[f,p]=(0,X.useState)(``);async function m(){d(!0),p(``);try{let n=await l.jobs.nativeSession(t,e.id);n.session_id?a(`/chat?project=all&sessionLive=${encodeURIComponent(n.session_id)}`):p(`The native conversation is not available yet. The saved result is still available below.`)}catch(e){p(e instanceof Error?e.message:`Could not open this conversation.`)}finally{d(!1)}}return(0,Z.jsxs)(`div`,{className:`min-w-0 border-y border-border overflow-hidden bg-background`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:r,"aria-expanded":n,"data-testid":`job-run-result`,className:`w-full flex flex-wrap items-center gap-x-3 gap-y-1 px-3 py-2 hover:bg-surface transition-colors text-left`,children:[n?(0,Z.jsx)(u,{size:12,className:`text-outline shrink-0`}):(0,Z.jsx)(re,{size:12,className:`text-outline shrink-0`}),(0,Z.jsx)(L,{status:e.status,type:`job`}),(0,Z.jsxs)(`span`,{className:`order-last basis-full min-w-0 font-label text-xs text-outline sm:order-none sm:basis-auto sm:flex-1`,children:[e.started_at?new Date(e.started_at).toLocaleString():`—`,e.ended_at&&(0,Z.jsxs)(`span`,{className:`ml-2`,children:[`→`,` `,new Date(e.ended_at).toLocaleTimeString()]})]}),(0,Z.jsx)(`span`,{className:`ml-auto whitespace-nowrap text-xs underline sm:ml-0`,children:n?`Hide result`:`View result`}),e.exit_code!==null&&(0,Z.jsxs)(`span`,{className:`font-mono text-xs ${e.exit_code===0?`text-secondary`:`text-error`}`,children:[`exit `,e.exit_code]})]}),(e.task_id||e.session_id)&&(0,Z.jsxs)(`div`,{className:`flex gap-3 px-3 py-2 text-xs`,children:[e.task_id&&(0,Z.jsx)(o,{className:`underline`,"data-testid":`job-run-task-link`,to:`/tasks/${e.task_id}?project=all`,children:`Created task`}),e.native_session_id&&(0,Z.jsx)(s,{variant:`outline`,size:`sm`,"data-testid":`job-run-open-session`,disabled:c,onClick:()=>void m(),children:c?`Opening…`:`Open agent session`}),e.session_id&&(0,Z.jsx)(o,{className:`underline`,"data-testid":`job-run-session-link`,to:`/audit/${e.session_id}?project=all`,children:`Session summary`})]}),f&&(0,Z.jsx)(`p`,{role:`alert`,className:`px-3 pb-2 text-sm text-error`,children:f}),e.error_msg&&(0,Z.jsx)(`div`,{className:`px-3 pb-2`,children:(0,Z.jsx)(`span`,{className:`font-body text-xs text-error`,children:e.error_msg})}),n&&(0,Z.jsx)(ze,{jobId:t,runId:e.id,live:[`pending`,`running`].includes(e.status)})]})}function ze({jobId:e,runId:t,live:n}){let{data:r,isLoading:i,error:a,refetch:o}=be(e,t,n);return a?(0,Z.jsx)(I,{message:a.message,onRetry:()=>o()}):i?(0,Z.jsx)(`div`,{className:`px-3 pb-3`,children:(0,Z.jsx)(R,{className:`h-24 w-full bg-surface-highest`})}):r?.length?(0,Z.jsx)(`div`,{className:`mx-3 mb-3 rounded-lg overflow-hidden border border-surface-highest`,children:(0,Z.jsx)(m,{className:`h-[240px]`,children:(0,Z.jsx)(`pre`,{className:`font-mono text-xs leading-relaxed bg-background p-3`,children:r.map(e=>(0,Z.jsx)(`div`,{className:e.stream===`stderr`?`text-error`:`text-on-surface`,children:e.line},e.id))})})}):(0,Z.jsx)(`div`,{className:`px-3 pb-3 font-label text-xs text-outline`,children:`No log output`})}var Be=b(`type`,[_({type:g(`command`),command:y().trim().min(1)}).strict(),_({type:g(`agent`),prompt:y().trim().min(1).max(1e5),backend:y().trim().min(1).max(64),options:x.optional(),model:S.refine(e=>e.length>0).optional(),auto_approve:h().default(!1)}).strict().superRefine((e,t)=>{if(!e.options)return;[`claude-cli`,`a2a`,`agentapi`].includes(e.backend)&&t.addIssue({code:`custom`,path:[`options`],message:`This backend does not support job launch options. Choose Claude SDK, Codex CLI or ACPX.`});let n=e.backend===`claude`?`claude-sdk`:e.backend===`pi`?`pi`:e.backend===`codex-cli`?`codex`:`acpx`;e.options.runtime!==n&&t.addIssue({code:`custom`,path:[`options`],message:`Launch options do not match this backend`}),!e.auto_approve&&(e.options.runtime===`claude-sdk`&&[`acceptEdits`,`bypassPermissions`].includes(e.options.options.permissionMode??``)||e.options.runtime===`acpx`&&e.options.args.some(e=>[`--approve-all`,`--approve-reads`].includes(e)))&&t.addIssue({code:`custom`,path:[`options`],message:`Automatic tool approval must be enabled explicitly`})}),_({type:g(`task`),title:y().trim().min(1).max(200),body:y().max(1e5).default(``),start_automatically:h().default(!1),flow_name:y().trim().min(1).max(100).optional()}).strict()]);_({webhook_id:y().min(1).max(128),events:v(y().trim().min(1).max(128)).max(50).default([]),actions:v(y().trim().min(1).max(128)).max(50).default([])}).strict();function Ve({value:e,onChange:t,host:n,cwd:i}){let a=e.backend===`codex-cli`?`codex`:e.backend,{data:o}=j(),s=Array.from(new Set([...k(),a])),c=r({queryKey:[`job-models`,a,n===void 0?o?.host:n,i],queryFn:()=>l.chat.models(a,void 0,n,i),staleTime:12e4,retry:!1}),u=new Map((c.data?.models??[]).map(e=>[e.id,e.label]));e.model&&!u.has(e.model)&&u.set(e.model,e.model);let d=M(a)?.modelSelection===!1;return(0,Z.jsx)(D,{testIdPrefix:`job`,agent:a,selectedModel:e.model??``,agents:s,choices:u,fetching:c.isFetching,modelsDisabled:d,warning:c.isError?`Models could not be loaded. Saved and custom models are available.`:c.data?.warning,note:d?`This agent picks its own model.`:void 0,onAgent:n=>(n!==a&&t({...e,backend:n===`codex`?`codex-cli`:n,model:void 0,options:void 0}),!1),onModel:n=>t({...e,model:n||void 0})})}function He(e){return e.type===`command`?!!e.command.trim():e.type===`agent`?!!(e.prompt.trim()&&e.backend.trim()):!!e.title.trim()}function Ue({value:e,onChange:t,executionHost:n,cwd:r}){let i=(0,X.useId)();return(0,Z.jsxs)(`section`,{className:`space-y-3 border-y border-border py-4`,"data-testid":`job-action-fields`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(p,{htmlFor:`${i}-type`,children:`What should this job do?`}),(0,Z.jsxs)(`select`,{id:`${i}-type`,"data-testid":`job-action-type`,className:`w-full min-h-8 rounded-md border border-control-border bg-background px-3 text-sm`,value:e.type,onChange:e=>{e.target.value===`command`&&t({type:`command`,command:``}),e.target.value===`agent`&&t({type:`agent`,backend:`codex-cli`,prompt:``,auto_approve:!1}),e.target.value===`task`&&t({type:`task`,title:``,body:``,start_automatically:!1})},children:[(0,Z.jsx)(`option`,{value:`command`,children:`Run command`}),(0,Z.jsx)(`option`,{value:`agent`,children:`Run agent`}),(0,Z.jsx)(`option`,{value:`task`,children:`Create task`})]})]}),e.type===`command`&&(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(p,{htmlFor:`${i}-command`,children:`Command`}),(0,Z.jsx)(f,{id:`${i}-command`,"aria-label":`Command`,"data-testid":`job-command-input`,value:e.command,onChange:n=>t({...e,command:n.target.value}),rows:3,placeholder:`bun run build`,required:!0})]}),e.type===`agent`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(p,{children:`Agent and model`}),(0,Z.jsx)(Ve,{value:e,onChange:t,host:n,cwd:r})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(p,{htmlFor:`${i}-prompt`,children:`Instructions`}),(0,Z.jsx)(f,{id:`${i}-prompt`,"data-testid":`job-agent-prompt`,value:e.prompt,onChange:n=>t({...e,prompt:n.target.value}),required:!0,rows:4})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Z.jsxs)(`label`,{className:`flex min-h-11 items-center gap-2 text-sm`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:e.auto_approve,onChange:n=>t({...e,auto_approve:n.target.checked})}),`Allow agent tools automatically`]}),(0,Z.jsx)(N,{label:`Agent tool approval`,testId:`job-agent-approval-help`,children:`Starts a tracked agent session. When automatic tool approval is off, permission requests are denied.`})]})]}),e.type===`task`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(p,{htmlFor:`${i}-title`,children:`Task title`}),(0,Z.jsx)(A,{id:`${i}-title`,"data-testid":`job-task-title`,value:e.title,onChange:n=>t({...e,title:n.target.value}),required:!0,maxLength:200})]}),(0,Z.jsx)(ue,{label:`Task instructions`,id:`${i}-body`,"data-testid":`job-task-body`,value:e.body,onChange:n=>t({...e,body:n}),rows:4}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Z.jsxs)(`label`,{className:`flex min-h-11 items-center gap-2 text-sm`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,"data-testid":`job-task-autostart`,checked:e.start_automatically,onChange:n=>t({...e,start_automatically:n.target.checked})}),`Start the task flow automatically`]}),(0,Z.jsx)(N,{label:`Automatic task start`,testId:`job-task-autostart-help`,children:`Creates a task in this job's project. Automatic start is off by default; the task waits for a manual flow start.`})]}),e.start_automatically&&(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(p,{htmlFor:`${i}-flow`,children:`Flow (blank uses the configured default)`}),(0,Z.jsx)(A,{id:`${i}-flow`,"data-testid":`job-task-flow`,value:e.flow_name??``,onChange:n=>t({...e,flow_name:n.target.value||void 0})})]})]})]})}var Q=[{name:`Host default`,executable:``,args:[]},...[`sh`,`bash`,`zsh`,`fish`].map(e=>({name:e,executable:e,args:[`-c`]})),{name:`PowerShell 7 (pwsh)`,executable:`pwsh`,args:[`-NoProfile`,`-NonInteractive`,`-Command`]},{name:`Windows PowerShell`,executable:`powershell.exe`,args:[`-NoProfile`,`-NonInteractive`,`-Command`]},{name:`cmd`,executable:`cmd.exe`,args:[`/d`,`/s`,`/c`]}];function We({settings:e,onChange:t,action:n}){let{data:r}=j(),i=e.shell,[a,o]=(0,X.useState)(!(!i||Q.some(e=>e.executable===i.executable&&JSON.stringify(e.args)===JSON.stringify(i.args)))),s=a?`Custom`:i?Q.find(e=>e.executable===i.executable&&JSON.stringify(e.args)===JSON.stringify(i.args))?.name??`Custom`:`Host default`,c=`min-h-11 w-full rounded-md border border-control-border bg-background px-3 text-sm sm:min-h-8`;return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[n.type!==`task`&&(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(p,{htmlFor:`job-host`,children:`Runs on`}),(0,Z.jsxs)(`select`,{id:`job-host`,"data-testid":`job-host`,className:c,value:e.host===void 0?`__inherit__`:e.host??`__local__`,onChange:n=>{let r={...e};n.target.value===`__inherit__`?delete r.host:r.host=n.target.value===`__local__`?null:n.target.value,t(r)},children:[(0,Z.jsxs)(`option`,{value:`__inherit__`,children:[`Use selected execution host`,r?.host?` (${r.host})`:` (local)`]}),(0,Z.jsx)(`option`,{value:`__local__`,children:`Local API host`}),Array.from(new Set([...r?.hosts??[],...e.host?[e.host]:[]])).map(e=>(0,Z.jsx)(`option`,{value:e,children:e},e))]})]}),n.type===`command`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Z.jsx)(p,{htmlFor:`job-shell`,children:`Shell`}),(0,Z.jsx)(N,{label:`Shell`,testId:`job-shell-help`,children:`The script is passed as the final argument. The interpreter must be installed on the selected host.`})]}),(0,Z.jsxs)(`select`,{id:`job-shell`,"data-testid":`job-shell`,className:c,value:s,onChange:n=>{o(n.target.value===`Custom`);let r=Q.find(e=>e.name===n.target.value),i={...e};r?.executable?i.shell={executable:r.executable,args:r.args}:r?delete i.shell:i.shell={executable:``,args:[`-c`]},t(i)},children:[Q.map(e=>(0,Z.jsx)(`option`,{children:e.name},e.name)),(0,Z.jsx)(`option`,{children:`Custom`})]})]}),s===`Custom`&&(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(p,{htmlFor:`job-shell-executable`,children:`Executable or path`}),(0,Z.jsx)(A,{id:`job-shell-executable`,value:i?.executable??``,required:!0,onChange:n=>t({...e,shell:{executable:n.target.value,args:i?.args??[]}})})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(p,{htmlFor:`job-shell-args`,children:`Arguments (one per line)`}),(0,Z.jsx)(`textarea`,{id:`job-shell-args`,className:`${c} py-2`,value:i?.args.join(`
|
|
2
|
+
`)??``,onChange:n=>t({...e,shell:{executable:i?.executable??``,args:n.target.value.split(`
|
|
3
|
+
`).filter(Boolean)}})})]})]})]}),n.type===`agent`&&(0,Z.jsxs)(`div`,{className:`space-y-3 border-t border-border pt-4`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(p,{htmlFor:`job-workspace`,children:`Workspace`}),(0,Z.jsxs)(`select`,{id:`job-workspace`,className:c,value:e.workspace?.mode??`directory`,onChange:n=>t({...e,workspace:{mode:n.target.value===`worktree`?`worktree`:`directory`,base_ref:e.workspace?.base_ref??`HEAD`,cleanup_on_success:e.workspace?.cleanup_on_success??!1}}),children:[(0,Z.jsx)(`option`,{value:`worktree`,children:`New worktree for each run`}),(0,Z.jsx)(`option`,{value:`directory`,children:`Use working directory`})]})]}),e.workspace?.mode===`worktree`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Z.jsx)(p,{htmlFor:`job-base-ref`,children:`Base branch or ref`}),(0,Z.jsx)(N,{label:`Base branch or ref`,testId:`job-base-ref-help`,children:`HEAD inherits the project checkout’s current commit. Override with a local branch or remote-tracking ref. Each run gets an isolated, detached worktree.`})]}),(0,Z.jsx)(A,{id:`job-base-ref`,"data-testid":`job-base-ref`,required:!0,value:e.workspace.base_ref,onChange:n=>t({...e,workspace:{mode:`worktree`,cleanup_on_success:e.workspace?.cleanup_on_success??!1,base_ref:n.target.value}})})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Z.jsxs)(`label`,{className:`flex min-h-11 items-center gap-2 text-sm`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,"data-testid":`job-cleanup`,checked:e.workspace.cleanup_on_success,onChange:n=>t({...e,workspace:{mode:`worktree`,base_ref:e.workspace?.base_ref??`HEAD`,cleanup_on_success:n.target.checked}})}),`Clean up worktree after a successful run`]}),(0,Z.jsx)(N,{label:`Worktree cleanup`,testId:`job-cleanup-help`,children:`Failed runs, files (including ignored files), and commits absent from the base are kept. Run history records the worktree path.`})]})]})]})]})}function $(e,t){let[n,r]=e.split(`:`).map(Number);return`${r} ${n} * * ${[...t].sort().join(`,`)}`}function Ge(e){let t=/^(\d{1,2}) (\d{1,2}) \* \* (\*|[0-6](?:,[0-6])*)$/.exec(e);return!t||Number(t[1])>59||Number(t[2])>23?null:{time:`${t[2].padStart(2,`0`)}:${t[1].padStart(2,`0`)}`,days:t[3]===`*`?[0,1,2,3,4,5,6]:t[3].split(`,`).map(Number)}}function Ke({cron:e,timezone:t,onChange:n,onTimezone:r}){let i=Ge(e),[a,o]=(0,X.useState)(!(!e||i)),[s,c]=(0,X.useState)(i?.time??`09:00`),[l,u]=(0,X.useState)(i?.days??[1,2,3,4,5]);return(0,Z.jsxs)(`div`,{className:`space-y-4`,"data-testid":`job-schedule-fields`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsx)(p,{children:`Schedule`}),(0,Z.jsxs)(`label`,{className:`flex min-h-11 items-center gap-2 text-sm`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:a,onChange:t=>{if(o(t.target.checked),t.target.checked)e||n($(s,l));else{let t=Ge(e);t?(c(t.time),u(t.days)):n($(s,l))}}}),`Advanced cron`]})]}),a?(0,Z.jsx)(A,{"aria-label":`Cron expression`,required:!0,value:e,onChange:e=>n(e.target.value),placeholder:`0 9 * * 1,2,3,4,5`,className:`font-mono`}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[8rem_12rem] sm:items-center`,children:[(0,Z.jsx)(p,{htmlFor:`job-schedule-time`,children:`Run at`}),(0,Z.jsx)(A,{id:`job-schedule-time`,type:`time`,required:!0,value:s,onChange:e=>{c(e.target.value),n($(e.target.value,l))}})]}),(0,Z.jsx)(`fieldset`,{"aria-label":`Days of the week`,className:`flex flex-wrap gap-1`,children:[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`].map((e,t)=>(0,Z.jsx)(`button`,{type:`button`,"aria-pressed":l.includes(t),className:`min-h-11 min-w-11 rounded-md border px-2 text-sm ${l.includes(t)?`border-control-border bg-surface-highest text-on-surface`:`border-border text-outline`}`,onClick:()=>{let e=l.includes(t)?l.filter(e=>e!==t):[...l,t];u(e),n(e.length?$(s,e):``)},children:e},e))}),!l.length&&(0,Z.jsx)(`p`,{role:`alert`,className:`text-sm text-error`,children:`Select at least one day.`}),(0,Z.jsxs)(`p`,{className:`text-xs text-outline`,children:[`Cron: `,(0,Z.jsx)(`code`,{children:e||`Select days`})]})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Z.jsx)(p,{htmlFor:`job-timezone`,children:`Timezone`}),(0,Z.jsx)(N,{label:`Timezone`,testId:`job-timezone-help`,children:`Uses this timezone, including daylight saving changes.`})]}),(0,Z.jsx)(A,{id:`job-timezone`,required:!0,value:t,onChange:e=>r(e.target.value),placeholder:`Asia/Jerusalem`})]})]})}function qe({job:e,defaultProjectId:t,open:n,onClose:r}){let i=Te(),a=V(),{data:o}=me(),c=de([{id:`trigger`,label:`Trigger`},{id:`destination`,label:`Destination`},{id:`settings`,label:`Settings`}],n),l={name:e?.name??``,description:e?.description??``,project_id:e?.project_id??t??``,working_dir:e?.working_dir??``,action:e?.action??{type:`command`,command:e?.command??``},trigger_type:e?.trigger_type??`manual`,cron_expr:e?.cron_expr??``,timeout_secs:e?.timeout_secs??300,max_retries:e?.max_retries??0,overlap:e?.overlap??`skip`,notify_on:e?.notify_on??`failure`,enabled:e?.enabled??!1,webhooks:e?.webhooks??[],environment:e?.environment??[],settings:e?.settings??{timezone:e?.schedule_timezone??Intl.DateTimeFormat().resolvedOptions().timeZone,...e?{shell:{executable:`sh`,args:[`-c`]},inherit_project_directory:!1}:{}}},[u,d]=(0,X.useState)(l),f=e?.action?.type===`agent`&&e.action.options?JSON.stringify(e.action.options.runtime===`claude-sdk`||e.action.options.runtime===`pi`?e.action.options.options:`args`in e.action.options?e.action.options.args:e.action.options.options,null,2):``,[m,h]=(0,X.useState)(f),g=i.isPending||a.isPending;function _(e,t){d(n=>({...n,[e]:t}))}function v(t){if(!He(u.action)){c.invalid(`destination`,`Complete the job action.`);return}if(u.trigger_type===`cron`&&!u.cron_expr){c.invalid(`trigger`,`Choose a schedule or enter a cron expression.`);return}if(u.trigger_type===`webhook`&&!u.webhooks.length){c.invalid(`trigger`,`Select at least one webhook.`);return}let n=ie.safeParse(u.settings);if(!n.success){c.invalid(n.error.issues[0].path[0]===`timezone`?`trigger`:`destination`,n.error.issues[0].message);return}let r=ge.safeParse(u.environment);if(!r.success){c.invalid(`settings`,r.error.issues[0].message);return}let o=u.action;if(o.type===`agent`&&!m.trim()){let{options:e,...t}=o;o=t}if(o.type===`agent`&&m.trim()){let e=o.backend===`claude`?`claude-sdk`:o.backend===`pi`?`pi`:o.backend===`codex-cli`?`codex`:o.backend===`opencode`?`opencode`:`acpx`;try{let t=JSON.parse(m),n=x.parse(e===`claude-sdk`||e===`pi`||e===`opencode`?{runtime:e,options:t}:{runtime:e,args:t});o={...o,options:n}}catch{c.invalid(`destination`,`Enter valid supported agent launch options as JSON.`);return}}let s=Be.safeParse(o);if(!s.success){c.invalid(`destination`,s.error.issues[0].message);return}let l={...u,action:o,name:u.name.trim(),project_id:u.project_id||null,working_dir:u.working_dir.trim(),settings:n.data,environment:r.data,cron_expr:u.trigger_type===`cron`?u.cron_expr.trim():void 0,webhooks:u.trigger_type===`webhook`?u.webhooks:[]};e?a.mutate({...l,id:e.id},{onSuccess:t}):i.mutate(l,{onSuccess:t})}let y=`min-h-11 w-full rounded-md border border-control-border bg-background px-3 text-sm sm:min-h-8`;return(0,Z.jsx)(ce,{open:n,onClose:r,busy:g,dirty:JSON.stringify(u)!==JSON.stringify(l)||m!==f,children:(t,n)=>(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(C,{children:(0,Z.jsx)(T,{children:e?`Edit job`:`New job`})}),(0,Z.jsx)(`form`,{ref:c.form,noValidate:!0,className:`min-h-0`,onSubmit:e=>c.submit(e,()=>v(n)),children:(0,Z.jsxs)(se,{steps:c,children:[(0,Z.jsxs)(`div`,{className:`work-form-body space-y-4`,children:[(0,Z.jsxs)(z,{steps:c,id:`trigger`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(p,{htmlFor:`job-name`,children:`Name`}),(0,Z.jsx)(A,{id:`job-name`,"aria-label":`Name`,"data-testid":`job-name-input`,required:!0,maxLength:100,value:u.name,onChange:e=>_(`name`,e.target.value),autoFocus:!0,placeholder:`Check for Sentry issues`})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(p,{htmlFor:`job-trigger-type`,children:`Trigger`}),(0,Z.jsxs)(`select`,{id:`job-trigger-type`,"data-testid":`job-trigger-type`,className:y,value:u.trigger_type,onChange:e=>{let t=e.target.value;d({...u,trigger_type:t,cron_expr:t===`cron`?u.cron_expr||`0 9 * * 1,2,3,4,5`:u.cron_expr})},children:[(0,Z.jsx)(`option`,{value:`manual`,children:`Manual`}),(0,Z.jsx)(`option`,{value:`cron`,children:`Schedule`}),(0,Z.jsx)(`option`,{value:`webhook`,children:`Webhook`}),![`manual`,`cron`,`webhook`].includes(u.trigger_type)&&(0,Z.jsxs)(`option`,{value:u.trigger_type,children:[u.trigger_type,` (existing)`]})]})]}),u.trigger_type===`cron`&&(0,Z.jsxs)(`div`,{className:`md:col-span-2`,children:[(0,Z.jsx)(Ke,{cron:u.cron_expr,timezone:u.settings.timezone??`UTC`,onChange:e=>_(`cron_expr`,e),onTimezone:e=>_(`settings`,{...u.settings,timezone:e})}),e?.next_run_at&&(0,Z.jsxs)(`p`,{className:`mt-3 text-xs text-outline`,children:[`Saved schedule’s next run:`,` `,new Date(e.next_run_at).toLocaleString(void 0,{timeZone:e.schedule_timezone}),` `,`(`,e.schedule_timezone,`)`]})]}),u.trigger_type===`webhook`&&(0,Z.jsx)(`div`,{className:`md:col-span-2`,children:(0,Z.jsx)(Pe,{value:u.webhooks,onChange:e=>_(`webhooks`,e),projectId:u.project_id||void 0})}),(0,Z.jsxs)(`div`,{className:`space-y-1.5 md:col-span-2`,children:[(0,Z.jsx)(p,{htmlFor:`job-description`,children:`Description (optional)`}),(0,Z.jsx)(A,{id:`job-description`,"data-testid":`job-description`,value:u.description,onChange:e=>_(`description`,e.target.value)})]})]}),(0,Z.jsxs)(z,{steps:c,id:`destination`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(p,{htmlFor:`job-project`,children:`Project`}),(0,Z.jsxs)(`select`,{id:`job-project`,"data-testid":`job-project-select`,className:y,value:u.project_id,onChange:e=>d({...u,project_id:e.target.value,webhooks:[]}),children:[(0,Z.jsx)(`option`,{value:``,children:`None`}),o?.map(e=>(0,Z.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),u.action.type!==`task`&&(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Z.jsx)(p,{htmlFor:`job-directory`,children:`Working directory`}),(0,Z.jsx)(N,{label:`Working directory`,testId:`job-directory-help`,children:`A path on the selected host. Worktrees use this repository as their source.`})]}),(0,Z.jsx)(A,{id:`job-directory`,"aria-label":`Working directory`,value:u.working_dir,onChange:e=>_(`working_dir`,e.target.value),placeholder:u.action.type===`command`&&u.settings.inherit_project_directory===!1?`Use host working directory (existing job)`:`Use project directory`})]}),(0,Z.jsx)(`div`,{className:`md:col-span-2`,children:(0,Z.jsx)(Ue,{value:u.action,executionHost:u.settings.host,cwd:u.working_dir||o?.find(e=>e.id===u.project_id)?.scope||void 0,onChange:t=>{t.type===`agent`&&u.action.type===`agent`&&t.backend!==u.action.backend&&h(``),d({...u,action:t,settings:!e&&t.type===`agent`&&!u.settings.workspace?{...u.settings,workspace:{mode:`worktree`,base_ref:`HEAD`,cleanup_on_success:!1}}:u.settings})}})}),u.action.type===`agent`&&(0,Z.jsxs)(`details`,{className:`md:col-span-2 space-y-2`,children:[(0,Z.jsx)(`summary`,{className:`min-h-11 cursor-pointer text-sm`,children:`Advanced agent options`}),(0,Z.jsx)(p,{htmlFor:`job-agent-options`,children:u.action.backend===`pi`?`Pi options (JSON object)`:u.action.backend===`claude`?`SDK options (JSON object)`:`Launch arguments (JSON array)`}),(0,Z.jsx)(`textarea`,{id:`job-agent-options`,"data-testid":`job-agent-options`,rows:4,maxLength:2e4,className:`w-full rounded-md border border-control-border bg-background p-3 font-mono text-xs`,value:m,onChange:e=>h(e.target.value)}),(0,Z.jsxs)(N,{label:`Agent launch options`,testId:`job-agent-options-help`,children:[`Uses the same supported options as Chat. Set the model above; keep credentials in environment variables. Unsupported options are rejected.`,u.action.backend===`pi`?` Pi queue, retry and compaction changes are saved to Pi's own settings on the execution host.`:``]})]}),(0,Z.jsx)(`div`,{className:`md:col-span-2`,children:(0,Z.jsx)(We,{action:u.action,settings:u.settings,onChange:e=>_(`settings`,e)})})]}),(0,Z.jsxs)(z,{steps:c,id:`settings`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1 md:col-span-2`,children:[(0,Z.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,"data-testid":e?`job-edit-enabled`:`job-create-enabled`,checked:u.enabled,onChange:e=>_(`enabled`,e.target.checked)}),`Enable this job`]}),(0,Z.jsx)(N,{label:`Enabled job`,testId:`job-enabled-help`,children:`Disabled jobs stay saved. You can still run them manually.`})]}),u.action.type!==`task`&&(0,Z.jsx)(`div`,{className:`md:col-span-2`,children:(0,Z.jsx)(le,{value:u.environment,onChange:e=>_(`environment`,e)})}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(p,{htmlFor:`job-timeout`,children:`Timeout (seconds)`}),(0,Z.jsx)(A,{id:`job-timeout`,type:`number`,required:!0,min:1,value:u.timeout_secs,onChange:e=>_(`timeout_secs`,Number(e.target.value))})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(p,{htmlFor:`job-retries`,children:`Maximum retries`}),(0,Z.jsx)(A,{id:`job-retries`,type:`number`,required:!0,min:0,value:u.max_retries,onChange:e=>_(`max_retries`,Number(e.target.value))})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(p,{htmlFor:`job-overlap`,children:`When a run is already active`}),(0,Z.jsxs)(`select`,{id:`job-overlap`,className:y,value:u.overlap,onChange:e=>_(`overlap`,e.target.value),children:[(0,Z.jsx)(`option`,{value:`skip`,children:`Skip new run`}),(0,Z.jsx)(`option`,{value:`queue`,children:`Queue`}),(0,Z.jsx)(`option`,{value:`kill`,children:`Stop previous run`})]})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(p,{htmlFor:`job-notify`,children:`Notify on`}),(0,Z.jsxs)(`select`,{id:`job-notify`,className:y,value:u.notify_on,onChange:e=>_(`notify_on`,e.target.value),children:[(0,Z.jsx)(`option`,{value:`never`,children:`Never`}),(0,Z.jsx)(`option`,{value:`failure`,children:`Failure`}),(0,Z.jsx)(`option`,{value:`always`,children:`Every run`})]})]})]}),(c.error||i.error||a.error)&&(0,Z.jsx)(`p`,{role:`alert`,className:`text-sm text-error md:col-span-2`,children:c.error||i.error?.message||a.error?.message})]}),(0,Z.jsxs)(w,{className:`work-form-footer gap-2`,children:[(0,Z.jsx)(s,{type:`button`,variant:`ghost`,disabled:g,onClick:t,children:`Cancel`}),(0,Z.jsx)(fe,{steps:c,busy:g,children:(0,Z.jsx)(s,{type:`submit`,"data-testid":e?`job-edit-submit`:`job-submit`,disabled:g,children:g?`Saving…`:e?`Save changes`:`Create job`})})]})]})})]})})}var Je=[`one-shot`,`cron`,`watch`,`webhook`,`manual`,`bridge-msg`];function Ye({projectId:e}){let t=oe(`xl`),[n,r]=U(`jobQuery`,``),[i,a]=U(`jobStatus`,`all`,[`all`,`enabled`,`disabled`]),[o,c]=U(`jobTrigger`,`all`,[`all`,...Je]),l=je(e),u=l===`all`||l===`unassigned`?void 0:l,{data:f,isLoading:p,error:m,refetch:h}=Se({project_id:l===`all`?void 0:l,limit:100}),g=(l===`unassigned`?f?.filter(e=>e.project_id===null):f)?.filter(e=>(!n||`${e.name} ${e.description??``} ${e.command??``}`.toLowerCase().includes(n.toLowerCase()))&&(i===`all`||e.enabled===(i===`enabled`))&&(o===`all`||e.trigger_type===o)),_=JSON.stringify([l,n,i,o]),v=B(),y=xe(),b=V(),x=we(),S=x.data?.scope===_?x.data:void 0,C=Ne((g??[]).map(e=>e.id),_);async function w(e){let t=await x.mutateAsync({ids:C.selectedIds,enabled:e,scope:_});C.select(t.failed.map(e=>e.id))}let{selectedId:T,openDetail:E,closeDetail:D}=Ee(`/jobs`,`jobId`),[k,j]=(0,X.useState)(!1),[M,N]=(0,X.useState)(null),[P,F]=(0,X.useState)(null);if(m)return(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(H,{title:`Jobs`}),(0,Z.jsx)(I,{message:m.message,onRetry:()=>h()})]});let L=(g??[]).filter(e=>e.enabled).length;return(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(H,{title:`Jobs`,compact:!0,meta:`${L}/${(g??[]).length} enabled`,action:(0,Z.jsxs)(s,{"data-testid":`new-job-button`,size:`sm`,onClick:()=>j(!0),className:`font-label text-xs font-medium bg-primary text-primary-foreground hover:bg-primary/90`,children:[(0,Z.jsx)(ne,{size:12,className:`mr-1`}),` New job`]})}),(0,Z.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(`div`,{className:`relative min-w-0 flex-1 lg:max-w-md`,children:[(0,Z.jsx)(ee,{size:14,className:`absolute left-3 top-1/2 -translate-y-1/2 text-outline`}),(0,Z.jsx)(A,{type:`search`,"aria-label":`Search jobs`,"data-testid":`job-search`,placeholder:`Search jobs…`,value:n,onChange:e=>r(e.target.value,{replace:!0}),className:`h-11 pl-9 text-base lg:h-9 lg:text-sm`})]}),(0,Z.jsxs)(d,{activeCount:Number(i!==`all`)+Number(o!==`all`),children:[(0,Z.jsxs)(`select`,{"aria-label":`Job status`,"data-testid":`job-status-filter`,value:i,onChange:e=>a(e.target.value),className:`form-control form-control-single max-w-full`,children:[(0,Z.jsx)(`option`,{value:`all`,children:`All statuses`}),(0,Z.jsx)(`option`,{value:`enabled`,children:`Enabled`}),(0,Z.jsx)(`option`,{value:`disabled`,children:`Disabled`})]}),(0,Z.jsxs)(`select`,{"aria-label":`Job trigger`,"data-testid":`job-trigger-filter`,value:o,onChange:e=>c(e.target.value),className:`form-control form-control-single max-w-full`,children:[(0,Z.jsx)(`option`,{value:`all`,children:`All triggers`}),Je.map(e=>(0,Z.jsx)(`option`,{value:e,children:e},e))]})]})]}),(v.error||y.error||b.error)&&(0,Z.jsx)(`p`,{role:`alert`,className:`mb-4 text-sm text-error`,children:(v.error??y.error??b.error)?.message}),!!g?.length&&(0,Z.jsxs)(Me,{resourceLabel:`jobs`,count:C.selectedIds.length,allSelected:C.allSelected,someSelected:C.someSelected,onSelectAll:C.selectAll,onClear:C.clear,disabled:x.isPending,children:[(0,Z.jsx)(s,{type:`button`,variant:`outline`,size:`sm`,"data-testid":`jobs-bulk-enable`,disabled:x.isPending||b.isPending,onClick:()=>void w(!0),children:`Enable selected`}),(0,Z.jsx)(s,{type:`button`,variant:`outline`,size:`sm`,"data-testid":`jobs-bulk-disable`,disabled:x.isPending||b.isPending,onClick:()=>void w(!1),children:`Disable selected`})]}),x.isPending&&(0,Z.jsx)(`p`,{role:`status`,className:`mb-3 text-sm text-outline`,children:`Updating selected jobs…`}),!x.isPending&&S&&(0,Z.jsxs)(`div`,{className:`mb-3 space-y-1 text-sm`,"data-testid":`jobs-bulk-result`,role:`status`,children:[(0,Z.jsxs)(`p`,{children:[S.succeeded.length,` jobs `,S.enabled?`enabled`:`disabled`,`.`]}),S.failed.map(e=>(0,Z.jsxs)(`p`,{className:`text-error`,children:[g?.find(t=>t.id===e.id)?.name??e.id,`: `,e.error,`. Still selected for retry.`]},e.id))]}),p?(0,Z.jsx)(`div`,{role:`status`,"aria-label":`Loading jobs`,className:`space-y-2`,children:[...[,,,]].map((e,t)=>(0,Z.jsx)(R,{className:`h-12 w-full bg-surface-highest`},t))}):(g??[]).length===0?(0,Z.jsx)(De,{message:n||i!==`all`||o!==`all`?`No jobs match`:`No jobs configured`}):t?(0,Z.jsx)(`div`,{className:`min-w-0 overflow-hidden`,children:(0,Z.jsxs)(Ae,{children:[(0,Z.jsx)(Oe,{children:(0,Z.jsxs)(G,{className:`border-b border-border hover:bg-transparent`,children:[(0,Z.jsx)(W,{className:`w-11`,children:(0,Z.jsx)(`span`,{className:`sr-only`,children:`Select jobs`})}),(0,Z.jsx)(W,{className:`font-label text-xs font-medium text-outline`,children:`Name`}),(0,Z.jsx)(W,{className:`font-label text-xs font-medium text-outline w-24`,children:`Trigger`}),(0,Z.jsx)(W,{className:`font-label text-xs font-medium text-outline w-48`,children:`Action`}),(0,Z.jsx)(W,{className:`font-label text-xs font-medium text-outline w-16`,children:`Enabled`}),(0,Z.jsx)(W,{className:`font-label text-xs font-medium text-outline w-36`,children:`Last Run`}),(0,Z.jsx)(W,{className:`font-label text-xs font-medium text-outline w-16`,children:`Runs`}),(0,Z.jsx)(W,{className:`font-label text-xs font-medium text-outline w-36`,children:`Next Run`}),(0,Z.jsx)(W,{className:`w-28`})]})}),(0,Z.jsx)(ke,{children:(g??[]).map(e=>(0,Z.jsxs)(G,{"data-testid":`job-row`,"data-job-id":e.id,"data-job-name":e.name,className:`border-b border-border/65 hover:bg-surface-high cursor-pointer`,onClick:()=>E(e.id),children:[(0,Z.jsx)(K,{children:(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-4 accent-primary`,"aria-label":`Select ${e.name}`,"data-testid":`job-select`,checked:C.selectedIds.includes(e.id),disabled:x.isPending,onClick:e=>e.stopPropagation(),onChange:()=>C.toggle(e.id)})}),(0,Z.jsxs)(K,{children:[(0,Z.jsx)(`button`,{type:`button`,className:`font-body text-sm font-medium text-on-surface text-left hover:text-primary`,"data-testid":`job-open-detail`,onClick:t=>{t.stopPropagation(),E(e.id)},children:e.name}),e.description&&(0,Z.jsx)(`div`,{className:`font-body text-sm text-outline mt-0.5 truncate max-w-[200px]`,children:e.description})]}),(0,Z.jsx)(K,{children:(0,Z.jsx)(`span`,{className:`font-label text-xs text-on-surface-variant inline-flex`,children:e.trigger_type})}),(0,Z.jsx)(K,{children:(0,Z.jsx)(`code`,{className:`font-mono text-xs text-outline truncate block max-w-[180px]`,children:e.action?.type===`agent`?`Agent: ${e.action.backend}`:e.action?.type===`task`?`Task: ${e.action.title}`:e.command})}),(0,Z.jsx)(K,{children:(0,Z.jsx)(s,{type:`button`,"data-testid":`job-toggle-enabled`,variant:`outline`,size:`sm`,"aria-label":`${e.enabled?`Disable`:`Enable`} ${e.name}`,"aria-pressed":e.enabled,disabled:b.isPending||x.isPending,onClick:t=>{t.stopPropagation(),b.mutate({id:e.id,enabled:!e.enabled})},children:e.enabled?`Disable`:`Enable`})}),(0,Z.jsx)(K,{className:`font-label text-xs text-outline`,children:e.last_run_at?new Date(e.last_run_at).toLocaleString():`—`}),(0,Z.jsx)(K,{className:`font-label text-xs text-outline`,children:e.run_count}),(0,Z.jsx)(K,{className:`font-label text-xs text-outline`,children:e.next_run_at?new Date(e.next_run_at).toLocaleString():`—`}),(0,Z.jsx)(K,{children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(s,{variant:`ghost`,"data-testid":`job-trigger`,size:`sm`,disabled:v.isPending,onClick:()=>v.mutate(e.id,{onSuccess:()=>E(e.id)}),className:`font-label text-sm min-h-8 px-3 bg-transparent text-on-surface border border-border hover:bg-surface-high`,children:[(0,Z.jsx)(J,{size:10,className:`mr-1`}),` Run`]}),(0,Z.jsx)(s,{type:`button`,"data-testid":`job-edit`,variant:`ghost`,size:`icon`,"aria-label":`Edit ${e.name}`,onClick:()=>N(e),className:`inline-flex min-h-8 min-w-8 items-center justify-center rounded-md text-outline hover:text-primary hover:bg-surface-highest`,children:(0,Z.jsx)(O,{size:16})}),(0,Z.jsx)(s,{type:`button`,"data-testid":`job-delete`,variant:`ghost`,size:`icon`,"aria-label":`Delete ${e.name}`,onClick:()=>F(e),className:`inline-flex min-h-8 min-w-8 items-center justify-center rounded-md text-outline hover:text-error hover:bg-error/10`,children:(0,Z.jsx)(te,{size:12})})]})})]},e.id))})]})}):(0,Z.jsx)(`div`,{className:`divide-y divide-border`,children:(g??[]).map(e=>(0,Z.jsxs)(`article`,{"data-testid":`job-row`,"data-job-id":e.id,"data-job-name":e.name,className:`py-3 space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-4 accent-primary shrink-0 mt-1`,"aria-label":`Select ${e.name}`,"data-testid":`job-select`,checked:C.selectedIds.includes(e.id),disabled:x.isPending,onChange:()=>C.toggle(e.id)}),(0,Z.jsx)(`button`,{type:`button`,className:`min-w-0 flex-1 text-left font-medium text-sm text-on-surface wrap-break-word hover:text-primary`,"data-testid":`job-open-detail`,onClick:()=>E(e.id),children:e.name}),(0,Z.jsx)(s,{type:`button`,"data-testid":`job-toggle-enabled`,variant:`outline`,size:`sm`,"aria-label":`${e.enabled?`Disable`:`Enable`} ${e.name}`,"aria-pressed":e.enabled,disabled:b.isPending||x.isPending,onClick:()=>b.mutate({id:e.id,enabled:!e.enabled}),children:e.enabled?`Disable`:`Enable`})]}),e.description&&(0,Z.jsx)(`p`,{className:`text-sm text-outline wrap-break-word`,children:e.description}),(0,Z.jsx)(`code`,{className:`block whitespace-pre-wrap break-all text-xs text-on-surface-variant`,children:e.action?.type===`agent`?`Agent: ${e.action.backend}`:e.action?.type===`task`?`Task: ${e.action.title}`:e.command}),(0,Z.jsxs)(`p`,{className:`text-xs text-outline`,children:[e.trigger_type,` · `,e.run_count,` runs`,e.next_run_at?` · Next: ${new Date(e.next_run_at).toLocaleString()}`:``]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsxs)(s,{"data-testid":`job-edit`,variant:`ghost`,size:`sm`,onClick:()=>N(e),children:[(0,Z.jsx)(O,{}),`Edit`]}),(0,Z.jsxs)(s,{"data-testid":`job-trigger`,variant:`ghost`,size:`sm`,disabled:v.isPending,onClick:()=>v.mutate(e.id,{onSuccess:()=>E(e.id)}),children:[(0,Z.jsx)(J,{}),`Run`]}),(0,Z.jsx)(s,{"data-testid":`job-delete`,"aria-label":`Delete ${e.name}`,variant:`ghost`,size:`icon`,onClick:()=>F(e),children:(0,Z.jsx)(te,{})})]})]},e.id))}),(0,Z.jsx)(Le,{projectScope:l,jobId:T,open:!!T,onClose:D,onEdit:e=>{D(),N(e)}}),k&&(0,Z.jsx)(qe,{defaultProjectId:u,open:k,onClose:()=>j(!1)}),M&&(0,Z.jsx)(qe,{job:M,open:!!M,onClose:()=>N(null)}),P&&(0,Z.jsx)(ve,{open:!!P,title:`Delete Job`,description:`Delete job "${P.name}"? This cannot be undone.`,confirmLabel:`Delete`,variant:`destructive`,isPending:y.isPending,onConfirm:()=>{y.mutate(P.id,{onSuccess:()=>F(null)})},onCancel:()=>F(null)})]})}export{Ye as default};
|