@xopcai/xopc 0.0.147 → 0.0.149
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/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-DXeSSlw1.js → activity-store-B4s0ipx2.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-CFdJKSjY.js → agent-avatar-dicebear-BSccACje.js} +1 -1
- package/dist/gateway/static/root/assets/agents-DZDOcgz5.js +2 -0
- package/dist/gateway/static/root/assets/{api-Bs69B5zA.js → api-BMdUsNCV.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-ag1ViXT_.js → app-management-settings-panel-DrLGhYkI.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-C6iMpwOM.js → appearance-settings-BNasnY9D.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-Cmr-Hvm9.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-Dwi3mIBy.js → archive-plugin-BQ17IK9x.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-BaCDoq40.js → attachment-load-HXvgWHXu.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-suggestion-card-CwqtFgnw.js → automation-suggestion-card-CjIWpsch.js} +1 -1
- package/dist/gateway/static/root/assets/automations-page-TWgUAI8t.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-DoAYhsxa.js → binary-plugins-DifWJzNZ.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-Bw72pO7S.js → block-editor-DtRzIkPU.js} +4 -4
- package/dist/gateway/static/root/assets/browser-settings-page-DBsFItW_.js +8 -0
- package/dist/gateway/static/root/assets/{capability-presets-api-vdbAR65Q.js → capability-presets-api-DazKjWW1.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-presets-settings-panel-BAsKbJgm.js → capability-presets-settings-panel-Cvrw4fD1.js} +2 -2
- package/dist/gateway/static/root/assets/{channel-recipient-api-rTG26jpV.js → channel-recipient-api-Bea6if_6.js} +1 -1
- package/dist/gateway/static/root/assets/channels-settings-BBkzrBYy.js +1 -0
- package/dist/gateway/static/root/assets/channels-status-swr-CuU6ez3y.js +1 -0
- package/dist/gateway/static/root/assets/{connector-logo-DIMP4NWY.js → connector-logo-BjbYbJjQ.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-DLsZCAw7.js +2 -0
- package/dist/gateway/static/root/assets/{desktop-pet-kQq2e0BN.js → desktop-pet-C6V-PHwi.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-B6vtozMY.js → desktop-pet-settings-5Fcz47XQ.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-Dn5-e3v4.js → directory-picker-path-field-C8zZNUzC.js} +1 -1
- package/dist/gateway/static/root/assets/{dreaming-settings-BzwIujPG.js → dreaming-settings-gJSw7Adk.js} +3 -3
- package/dist/gateway/static/root/assets/{extension-debug-page-D_e_hsEy.js → extension-debug-page-DFE5ADJ0.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-D15CWHBd.js → extension-page-CfR-aW8G.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-D4P0n1om.js → extension-settings-page-CFIEbs2L.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-B4qZctjG.js → gateway-config-api-B6M_ra8U.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-settings-BrxzyVW2.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-BpgMunEb.js → gateway-startup-retry-DNA3OOzV.js} +1 -1
- package/dist/gateway/static/root/assets/{goal-create-dialog-DrVHKXHq.js → goal-create-dialog-DRVRLc5Z.js} +1 -1
- package/dist/gateway/static/root/assets/goal-detail-page-8F7NElzP.js +4 -0
- package/dist/gateway/static/root/assets/{goals-config-api-B6YJB_ct.js → goals-config-api-D88opgcs.js} +1 -1
- package/dist/gateway/static/root/assets/goals-page-BaoLiV8G.js +2 -0
- package/dist/gateway/static/root/assets/{goals-settings-BROWCIcL.js → goals-settings-D07UL8Jo.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-CoCwIOIg.js → heartbeat-settings-YCSNOcXC.js} +1 -1
- package/dist/gateway/static/root/assets/{index-CxkNzw3e.js → index-CH7XN6KY.js} +43 -43
- package/dist/gateway/static/root/assets/index-Dfnl9tp_.css +1 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-Bm_AIYQ7.js → keyboard-shortcuts-settings-BHnh5OoY.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-Boe8n4zH.js +2 -0
- package/dist/gateway/static/root/assets/local-apps-page-CKvtLzsF.js +1 -0
- package/dist/gateway/static/root/assets/{locale-store-Bp8joZck.js → locale-store-BneNAR8R.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-Cb4Uptct.js +7 -0
- package/dist/gateway/static/root/assets/{markdown-split-Dy7QpaAz.js → markdown-split-BVSFG99p.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-3Lxliy9D.js → media-plugins-DdOjIVk3.js} +1 -1
- package/dist/gateway/static/root/assets/{messages-CQGpD-dC.js → messages-t1yPaVCt.js} +5 -5
- package/dist/gateway/static/root/assets/models-hub-panel-CNiUKZUV.js +2 -0
- package/dist/gateway/static/root/assets/{notes-page-BJtT4vSf.js → notes-page-ZbLR3awn.js} +1 -1
- package/dist/gateway/static/root/assets/notes-workbench-C9__VkD6.js +4 -0
- package/dist/gateway/static/root/assets/{page-tabs-DKB6RDre.js → page-tabs-DMlQERNg.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-Br_YhYHp.js → preview-open-alternatives-CbiJRPxK.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-CZhuB5kO.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-BOq4WVdR.js +1 -0
- package/dist/gateway/static/root/assets/remote-access-hub-BxGq0ebQ.js +1 -0
- package/dist/gateway/static/root/assets/{save-bar-controls-BgIE9BBh.js → save-bar-controls-BZTj3hxl.js} +1 -1
- package/dist/gateway/static/root/assets/{schedule-field-BXDP-oMz.js → schedule-field-CxYDObjT.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-Dhv-SmjG.js → schema-form-CBbXgpKQ.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-B6gSU_Au.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-DwuBL834.js +1 -0
- package/dist/gateway/static/root/assets/{settings-collapsible-section-CUTExnlK.js → settings-collapsible-section-BySKZ8rp.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-form-section-CmnDhsf0.js → settings-form-section-CjINay6t.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-B79dq-XY.js → settings-loading-skeleton-vitElc-n.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-Db8uAv3X.js → settings-page-BNrVwuL7.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-DaFwstQw.js → settings-page-layout-HdlQOOqp.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-BJeA4mmk.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-Bi00uXzV.js → share-preview-page-DC-eQONB.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-DB2KYA2_.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-DQtZiejw.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-Pm0fNe_p.js +2 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-Cxaph7hW.js → system-settings-panel-CVa90q2f.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-eCTN1RpG.js → theme-store-D1cOpgsy.js} +1 -1
- package/dist/gateway/static/root/assets/{typed-models-lib-CcZ_tyFY.js → typed-models-lib-DIKF9vpz.js} +1 -1
- package/dist/gateway/static/root/assets/{use-channel-catalog-C4PWbNoi.js → use-channel-catalog-DnvpI0Ys.js} +1 -1
- package/dist/gateway/static/root/assets/user-context-page-DnLqQyRG.js +1 -0
- package/dist/gateway/static/root/assets/{user-profile-fields-editor-CPOO9Jz5.js → user-profile-fields-editor-y8gTmkPX.js} +1 -1
- package/dist/gateway/static/root/assets/{user-profile-settings-panel-C8cgtSF7.js → user-profile-settings-panel-C3pvqe28.js} +1 -1
- package/dist/gateway/static/root/assets/{utils-CiZK2KwH.js → utils-BK2vwu_3.js} +1 -1
- package/dist/gateway/static/root/assets/voice-api-key-field-BiFIIWC4.js +1 -0
- package/dist/gateway/static/root/assets/work-discovery-page-D2-_bC0J.js +1 -0
- package/dist/gateway/static/root/assets/work-item-detail-page-B0FPG4eJ.js +1 -0
- package/dist/gateway/static/root/assets/work-page-BDeVxts_.js +1 -0
- package/dist/gateway/static/root/assets/workflow-run-setup-panel-BPzS67fU.js +3 -0
- package/dist/gateway/static/root/assets/workflows-page-xPhmrRLs.js +11 -0
- package/dist/gateway/static/root/index.html +7 -7
- package/dist/package.js +1 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/gateway/hono/routes/work-discovery.js +32 -0
- package/dist/src/gateway/hono/routes/work-discovery.js.map +1 -1
- package/dist/src/storage/sqlite/migrations/046_work_discovery_feedback.sql +13 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +3 -3
- package/dist/src/storage/sqlite/migrations/runner.js.map +1 -1
- package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/work-discovery/analyzer.js +23 -4
- package/dist/src/work-discovery/analyzer.js.map +1 -1
- package/dist/src/work-discovery/index.js +2 -2
- package/dist/src/work-discovery/probe.d.ts +6 -0
- package/dist/src/work-discovery/probe.js +12 -1
- package/dist/src/work-discovery/probe.js.map +1 -1
- package/dist/src/work-discovery/repository.d.ts +7 -1
- package/dist/src/work-discovery/repository.js +35 -2
- package/dist/src/work-discovery/repository.js.map +1 -1
- package/dist/src/work-discovery/service.d.ts +6 -1
- package/dist/src/work-discovery/service.js +64 -5
- package/dist/src/work-discovery/service.js.map +1 -1
- package/dist/src/work-discovery/types.d.ts +21 -0
- package/dist/src/workflows/service/workflow-run-service.js +1 -1
- package/package.json +1 -1
- package/dist/gateway/static/root/assets/agents-DKjbRpbA.js +0 -2
- package/dist/gateway/static/root/assets/apps-page-CpX3lBFF.js +0 -1
- package/dist/gateway/static/root/assets/automations-page-DlupOxFQ.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-BwLoUBcZ.js +0 -8
- package/dist/gateway/static/root/assets/channels-settings-CxFWy0cE.js +0 -1
- package/dist/gateway/static/root/assets/channels-status-swr-OKlqTtKJ.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-BjQQwX62.js +0 -2
- package/dist/gateway/static/root/assets/gateway-settings-BvndV7TP.js +0 -1
- package/dist/gateway/static/root/assets/goal-detail-page-PHlCwv68.js +0 -4
- package/dist/gateway/static/root/assets/goals-page-Hg9uyO6e.js +0 -2
- package/dist/gateway/static/root/assets/index-DjCSOyaN.css +0 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-BJWFcxwG.js +0 -2
- package/dist/gateway/static/root/assets/local-apps-page-BsiZMrEf.js +0 -1
- package/dist/gateway/static/root/assets/logs-page-DOmK61ey.js +0 -7
- package/dist/gateway/static/root/assets/models-hub-panel-DGCZom4o.js +0 -2
- package/dist/gateway/static/root/assets/notes-workbench-B_bN7cOR.js +0 -4
- package/dist/gateway/static/root/assets/project-detail-page-Dq8JouJj.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-DvfL7fSe.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-DqwMXSXP.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-B_mOZkQk.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BHGmH6YS.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-BUSEj0KK.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-DzsTYfuX.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-DSsdU081.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-DeB1tQZL.js +0 -2
- package/dist/gateway/static/root/assets/user-context-page-QTVMx_hG.js +0 -1
- package/dist/gateway/static/root/assets/voice-api-key-field-b-YZtvUu.js +0 -1
- package/dist/gateway/static/root/assets/work-discovery-page-4zVDOl2G.js +0 -1
- package/dist/gateway/static/root/assets/work-item-detail-page-CHe2tfkc.js +0 -1
- package/dist/gateway/static/root/assets/workflow-run-setup-panel-8SLCYeXE.js +0 -3
- package/dist/gateway/static/root/assets/workflows-page-DEOFqiWn.js +0 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./cn-BQ_8x0bT.js";import{t as i}from"./messages-CQGpD-dC.js";import{n as ee}from"./locale-store-Bp8joZck.js";import{Ao as a,As as o,Cc as s,Fr as c,Go as l,Ir as u,Ko as d,Mo as f,No as p,Nt as m,Oo as h,Po as g,Wo as _,Ws as v,Zs as y,eu as b,jo as x,mc as S,ms as C,st as w,vs as T}from"./index-CxkNzw3e.js";var E=e(t(),1),D=n();function O(){return{title:``,objective:``,description:``,attachments:[],checklist:[``],scopeBoundary:``,evidencePlan:[``],priority:`normal`,deadlineMode:`none`,deadline:``,maxTurns:`10`,agentId:``,judgeModelRef:``}}function k(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function A(e){let t=e=>String(e).padStart(2,`0`);return[e.getFullYear(),`-`,t(e.getMonth()+1),`-`,t(e.getDate()),`T`,t(e.getHours()),`:`,t(e.getMinutes())].join(``)}function j(e){let t=new Date;return t.setDate(t.getDate()+e),t.setHours(23,59,0,0),A(t)}function M(){let e=new Date,t=e.getDay(),n=t<=5?5-t:7-t+5;return e.setDate(e.getDate()+n),e.setHours(23,59,0,0),A(e)}function N(e){if(e===`today`)return j(0);if(e===`tomorrow`)return j(1);if(e===`friday`)return M();if(e===`custom`){let e=new Date;return e.setHours(e.getHours()+1,0,0,0),A(e)}return``}function P(e){let t=new Set,n=[];for(let r of e){let e=r.trim();!e||t.has(e.toLowerCase())||(t.add(e.toLowerCase()),n.push(e))}return n}function F({open:e,t,chat:n,busy:A,options:j,onClose:M,onCreate:F,onDraftContract:I}){let L=i(ee(e=>e.language)).agentsSettings,[R,z]=(0,E.useState)(()=>O()),[B,V]=(0,E.useState)(!1),[H,U]=(0,E.useState)(!1),[W,G]=(0,E.useState)(null),[K,q]=(0,E.useState)(!1),J=w({chat:n});(0,E.useEffect)(()=>{e||(z(O()),V(!1),U(!1),G(null),q(!1),J.clearAttachments())},[J.clearAttachments,e]),(0,E.useEffect)(()=>{!e||!j.defaultAgentId||z(e=>e.agentId?e:{...e,agentId:j.defaultAgentId})},[e,j.defaultAgentId]);let Y=e=>z(t=>({...t,...e})),X=j.agents.length?j.agents:[{id:j.defaultAgentId||`main`,workspace:``,profileDir:``,typedModels:{defaultRole:`deep`,preset:[],effective:[]},extends:[],isDefault:!0,skills:{preset:[]},tools:{presetDenied:[],entryDisable:[],effectiveDisable:[]}}],Z=X.find(e=>e.id===R.agentId)??X.find(e=>e.id===j.defaultAgentId)??X[0],Q=Z?c(Z,L):``,te=R.agentId||Z?.id||`main`,$=[...Z?.typedModels.effective??[]].sort((e,t)=>e.id===`judge`?-1:t.id===`judge`?1:e.id.localeCompare(t.id)),ne=j.models.filter((e,t,n)=>n.findIndex(t=>t.id===e.id)===t),re=e=>{Y({deadlineMode:e,deadline:N(e)})},ie=(e,t)=>{z(n=>({...n,checklist:n.checklist.map((n,r)=>r===e?t:n)}))},ae=e=>{z(t=>({...t,checklist:t.checklist.filter((t,n)=>n!==e)}))},oe=(e,t)=>{z(n=>({...n,evidencePlan:n.evidencePlan.map((n,r)=>r===e?t:n)}))},se=e=>{z(t=>({...t,evidencePlan:t.evidencePlan.filter((t,n)=>n!==e)}))},ce=async()=>{G(null),q(!0);try{Y(I?await I({...R,attachments:J.wireAttachmentsPayload()}):{objective:R.objective||R.title,scopeBoundary:R.scopeBoundary,evidencePlan:P(R.evidencePlan).length?R.evidencePlan:[...t.createDialog.defaultEvidencePlan],checklist:R.checklist}),V(!0)}catch(e){G(e instanceof Error?e.message:t.createDialog.draftFailed)}finally{q(!1)}},le=async()=>{if(G(null),!R.title.trim()){G(t.createDialog.titleRequired);return}try{await F({...R,attachments:J.wireAttachmentsPayload(),checklist:P(R.checklist)}),M()}catch(e){G(e instanceof Error?e.message:t.errors.create)}};return(0,D.jsx)(h,{open:e,onOpenChange:e=>!e&&M(),children:(0,D.jsxs)(p,{children:[(0,D.jsx)(f,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,D.jsxs)(a,{className:`fixed left-1/2 top-1/2 z-66 flex h-[min(92vh,46rem)] w-[min(100%-2rem,44rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`,children:[(0,D.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-5 py-4`,children:[(0,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsx)(g,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.createDialog.title}),(0,D.jsx)(x,{className:`mt-1 truncate text-sm text-fg-muted`,children:t.createDialog.description})]}),(0,D.jsx)(C,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":t.closeDetails,onClick:M,children:(0,D.jsx)(T,{className:`size-5`,"aria-hidden":!0})})]}),(0,D.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:(0,D.jsxs)(`div`,{className:`grid gap-4`,children:[(0,D.jsx)(`section`,{className:`rounded-lg border border-accent/25 bg-accent-soft/50 px-3 py-3`,children:(0,D.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.createDialog.simpleStartTitle}),(0,D.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.createDialog.simpleStartHint})]}),(0,D.jsxs)(C,{type:`button`,variant:`secondary`,className:`h-8 shrink-0 rounded-lg text-xs`,onClick:()=>void ce(),disabled:K||!R.title.trim()&&!R.description.trim(),children:[(0,D.jsx)(v,{className:`size-3.5`,"aria-hidden":!0}),K?t.createDialog.drafting:t.createDialog.aiDraft]})]})}),(0,D.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.goalTitle}),(0,D.jsx)(`input`,{value:R.title,onChange:e=>Y({title:e.target.value}),placeholder:t.newGoalPlaceholder,className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,autoFocus:!0})]}),(0,D.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.goalDescription}),(0,D.jsxs)(C,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg text-xs`,onClick:()=>J.fileInputRef.current?.click(),children:[(0,D.jsx)(s,{className:`size-3.5`,"aria-hidden":!0}),t.createDialog.addAttachment]})]}),(0,D.jsx)(`textarea`,{value:R.description,onChange:e=>Y({description:e.target.value}),placeholder:t.createDialog.descriptionPlaceholder,rows:4,className:`resize-none rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`}),(0,D.jsx)(`input`,{ref:J.fileInputRef,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{let t=Array.from(e.currentTarget.files??[]);e.currentTarget.value=``,J.processFiles(t)}}),(0,D.jsx)(m,{attachments:J.attachments,topPadded:!1,onRemove:J.removeAttachment})]}),(0,D.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base/60`,children:[(0,D.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between gap-3 px-4 py-3 text-left`,onClick:()=>V(e=>!e),children:[(0,D.jsxs)(`span`,{className:`min-w-0`,children:[(0,D.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:t.createDialog.completionPlan}),(0,D.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:t.createDialog.completionPlanHint})]}),(0,D.jsx)(b,{className:r(`size-4 shrink-0 text-fg-muted transition-transform`,B&&`rotate-180`),"aria-hidden":!0})]}),B?(0,D.jsxs)(`div`,{className:`grid gap-4 border-t border-edge-subtle p-4`,children:[(0,D.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-panel/70 p-3`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.createDialog.criteriaTitle}),(0,D.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.createDialog.criteriaHint}),(0,D.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:j.checklistDecomposePolicy===`supplement_existing`?t.createDialog.checklistPolicySupplementExisting:t.createDialog.checklistPolicyEmptyOnly})]}),(0,D.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[R.checklist.map((e,n)=>(0,D.jsxs)(`div`,{className:`flex gap-2`,children:[(0,D.jsx)(`input`,{value:e,onChange:e=>ie(n,e.target.value),placeholder:k(t.createDialog.criteriaPlaceholder,{index:n+1}),className:`min-w-0 flex-1 rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`}),(0,D.jsx)(C,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 rounded-lg p-0`,"aria-label":t.createDialog.removeCriteria,onClick:()=>ae(n),children:(0,D.jsx)(o,{className:`size-4`,"aria-hidden":!0})})]},n)),(0,D.jsxs)(C,{type:`button`,variant:`ghost`,className:`h-8 justify-start rounded-lg text-xs`,onClick:()=>Y({checklist:[...R.checklist,``]}),children:[(0,D.jsx)(S,{className:`size-3.5`,"aria-hidden":!0}),t.createDialog.addCriteria]})]})]}),(0,D.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-panel/70 p-3`,children:[(0,D.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.createDialog.contractTitle}),(0,D.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.createDialog.contractHint}),(0,D.jsxs)(`label`,{className:`mt-3 grid gap-1.5`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.objective}),(0,D.jsx)(`textarea`,{value:R.objective,onChange:e=>Y({objective:e.target.value}),placeholder:t.createDialog.objectivePlaceholder,rows:2,className:`resize-none rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`})]}),(0,D.jsxs)(`label`,{className:`mt-3 grid gap-1.5`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.scopeBoundary}),(0,D.jsx)(`textarea`,{value:R.scopeBoundary,onChange:e=>Y({scopeBoundary:e.target.value}),placeholder:t.createDialog.scopeBoundaryPlaceholder,rows:2,className:`resize-none rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`})]}),(0,D.jsxs)(`div`,{className:`mt-3 grid gap-1.5`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.evidencePlan}),(0,D.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.createDialog.evidencePlanHint}),R.evidencePlan.map((e,n)=>(0,D.jsxs)(`div`,{className:`flex gap-2`,children:[(0,D.jsx)(`input`,{value:e,onChange:e=>oe(n,e.target.value),placeholder:k(t.createDialog.evidencePlanPlaceholder,{index:n+1}),className:`min-w-0 flex-1 rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`}),(0,D.jsx)(C,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 rounded-lg p-0`,"aria-label":t.createDialog.removeEvidence,onClick:()=>se(n),children:(0,D.jsx)(o,{className:`size-4`,"aria-hidden":!0})})]},n)),(0,D.jsxs)(C,{type:`button`,variant:`ghost`,className:`h-8 justify-start rounded-lg text-xs`,onClick:()=>Y({evidencePlan:[...R.evidencePlan,``]}),children:[(0,D.jsx)(S,{className:`size-3.5`,"aria-hidden":!0}),t.createDialog.addEvidence]})]})]})]}):null]}),(0,D.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base/60`,children:[(0,D.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between gap-3 px-4 py-3 text-left`,onClick:()=>U(e=>!e),children:[(0,D.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,D.jsx)(y,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),t.createDialog.advanced]}),(0,D.jsx)(b,{className:r(`size-4 text-fg-muted transition-transform`,H&&`rotate-180`),"aria-hidden":!0})]}),H?(0,D.jsxs)(`div`,{className:`grid gap-3 border-t border-edge-subtle p-4 sm:grid-cols-2`,children:[(0,D.jsxs)(`label`,{className:`grid gap-1.5 sm:col-span-2`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.agentId}),(0,D.jsx)(_,{value:te,onChange:e=>Y({agentId:e.target.value}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,children:X.map(e=>(0,D.jsx)(d,{value:e.id,children:u(e,L)+(e.isDefault?` · ${t.createDialog.defaultAgent}`:` · ${e.id}`)},e.id))}),Q?(0,D.jsx)(`span`,{className:`line-clamp-2 text-xs text-fg-muted`,children:Q}):Z?.model?.primary?(0,D.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:k(t.createDialog.agentPrimaryModel,{model:Z.model.primary})}):null]}),(0,D.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.priority}),(0,D.jsxs)(_,{value:R.priority,onChange:e=>Y({priority:e.target.value}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,children:[(0,D.jsx)(d,{value:`normal`,children:t.priorities.normal}),(0,D.jsx)(d,{value:`high`,children:t.priorities.high}),(0,D.jsx)(d,{value:`low`,children:t.priorities.low})]})]}),(0,D.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.deadline}),(0,D.jsxs)(_,{value:R.deadlineMode,onChange:e=>re(e.target.value),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,children:[(0,D.jsx)(d,{value:`none`,children:t.createDialog.deadlineNone}),(0,D.jsx)(d,{value:`today`,children:t.createDialog.deadlineToday}),(0,D.jsx)(d,{value:`tomorrow`,children:t.createDialog.deadlineTomorrow}),(0,D.jsx)(d,{value:`friday`,children:t.createDialog.deadlineFriday}),(0,D.jsx)(d,{value:`custom`,children:t.createDialog.deadlineCustom})]})]}),R.deadlineMode===`none`?null:(0,D.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.deadlineAt}),(0,D.jsx)(`input`,{type:`datetime-local`,value:R.deadline,onChange:e=>Y({deadline:e.target.value,deadlineMode:`custom`}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`})]}),(0,D.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.maxTurns}),(0,D.jsx)(`input`,{type:`number`,min:1,max:500,value:R.maxTurns,onChange:e=>Y({maxTurns:e.target.value}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`})]}),(0,D.jsxs)(`label`,{className:`grid gap-1.5 sm:col-span-2`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.judgeModel}),(0,D.jsxs)(_,{value:R.judgeModelRef,onChange:e=>Y({judgeModelRef:e.target.value}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,children:[(0,D.jsx)(d,{value:``,children:t.createDialog.judgeModelPlaceholder}),$.length?(0,D.jsx)(l,{label:t.createDialog.agentModelRoles,children:$.map(e=>(0,D.jsxs)(d,{value:e.model,children:[e.id===`judge`?t.createDialog.judgeRole:e.id,` · `,e.model]},`${e.id}:${e.model}`))}):null,(0,D.jsx)(l,{label:t.createDialog.configuredModels,children:ne.map(e=>(0,D.jsxs)(d,{value:e.id,children:[e.name,` · `,e.id]},e.id))})]})]})]}):null]}),W?(0,D.jsx)(`p`,{className:`rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:W}):null]})}),(0,D.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,D.jsx)(C,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:M,children:t.createDialog.cancel}),(0,D.jsxs)(C,{type:`button`,variant:`primary`,className:`rounded-lg`,disabled:A||!R.title.trim(),onClick:()=>void le(),children:[(0,D.jsx)(S,{className:`size-4`,"aria-hidden":!0}),t.createDialog.create]})]})]})]})})}export{P as n,F as t};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./cn-BQ_8x0bT.js";import{t as i}from"./messages-t1yPaVCt.js";import{n as a}from"./locale-store-BneNAR8R.js";import{Fo as o,Go as s,Gs as ee,Ir as c,Ko as l,Lr as u,Mo as d,No as f,Nt as p,Po as m,Qs as h,hc as g,hs as _,jo as v,js as y,ko as b,qo as x,st as S,tu as C,wc as w,ys as T}from"./index-CH7XN6KY.js";var E=e(t(),1),D=n();function O(){return{title:``,objective:``,description:``,attachments:[],checklist:[``],scopeBoundary:``,evidencePlan:[``],priority:`normal`,deadlineMode:`none`,deadline:``,maxTurns:`10`,agentId:``,judgeModelRef:``}}function k(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function A(e){let t=e=>String(e).padStart(2,`0`);return[e.getFullYear(),`-`,t(e.getMonth()+1),`-`,t(e.getDate()),`T`,t(e.getHours()),`:`,t(e.getMinutes())].join(``)}function j(e){let t=new Date;return t.setDate(t.getDate()+e),t.setHours(23,59,0,0),A(t)}function M(){let e=new Date,t=e.getDay(),n=t<=5?5-t:7-t+5;return e.setDate(e.getDate()+n),e.setHours(23,59,0,0),A(e)}function N(e){if(e===`today`)return j(0);if(e===`tomorrow`)return j(1);if(e===`friday`)return M();if(e===`custom`){let e=new Date;return e.setHours(e.getHours()+1,0,0,0),A(e)}return``}function P(e){let t=new Set,n=[];for(let r of e){let e=r.trim();!e||t.has(e.toLowerCase())||(t.add(e.toLowerCase()),n.push(e))}return n}function F({open:e,t,chat:n,busy:A,options:j,onClose:M,onCreate:F,onDraftContract:I}){let L=i(a(e=>e.language)).agentsSettings,[R,z]=(0,E.useState)(()=>O()),[B,V]=(0,E.useState)(!1),[H,U]=(0,E.useState)(!1),[W,G]=(0,E.useState)(null),[K,q]=(0,E.useState)(!1),J=S({chat:n});(0,E.useEffect)(()=>{e||(z(O()),V(!1),U(!1),G(null),q(!1),J.clearAttachments())},[J.clearAttachments,e]),(0,E.useEffect)(()=>{!e||!j.defaultAgentId||z(e=>e.agentId?e:{...e,agentId:j.defaultAgentId})},[e,j.defaultAgentId]);let Y=e=>z(t=>({...t,...e})),X=j.agents.length?j.agents:[{id:j.defaultAgentId||`main`,workspace:``,profileDir:``,typedModels:{defaultRole:`deep`,preset:[],effective:[]},extends:[],isDefault:!0,skills:{preset:[]},tools:{presetDenied:[],entryDisable:[],effectiveDisable:[]}}],Z=X.find(e=>e.id===R.agentId)??X.find(e=>e.id===j.defaultAgentId)??X[0],Q=Z?c(Z,L):``,te=R.agentId||Z?.id||`main`,$=[...Z?.typedModels.effective??[]].sort((e,t)=>e.id===`judge`?-1:t.id===`judge`?1:e.id.localeCompare(t.id)),ne=j.models.filter((e,t,n)=>n.findIndex(t=>t.id===e.id)===t),re=e=>{Y({deadlineMode:e,deadline:N(e)})},ie=(e,t)=>{z(n=>({...n,checklist:n.checklist.map((n,r)=>r===e?t:n)}))},ae=e=>{z(t=>({...t,checklist:t.checklist.filter((t,n)=>n!==e)}))},oe=(e,t)=>{z(n=>({...n,evidencePlan:n.evidencePlan.map((n,r)=>r===e?t:n)}))},se=e=>{z(t=>({...t,evidencePlan:t.evidencePlan.filter((t,n)=>n!==e)}))},ce=async()=>{G(null),q(!0);try{Y(I?await I({...R,attachments:J.wireAttachmentsPayload()}):{objective:R.objective||R.title,scopeBoundary:R.scopeBoundary,evidencePlan:P(R.evidencePlan).length?R.evidencePlan:[...t.createDialog.defaultEvidencePlan],checklist:R.checklist}),V(!0)}catch(e){G(e instanceof Error?e.message:t.createDialog.draftFailed)}finally{q(!1)}},le=async()=>{if(G(null),!R.title.trim()){G(t.createDialog.titleRequired);return}try{await F({...R,attachments:J.wireAttachmentsPayload(),checklist:P(R.checklist)}),M()}catch(e){G(e instanceof Error?e.message:t.errors.create)}};return(0,D.jsx)(b,{open:e,onOpenChange:e=>!e&&M(),children:(0,D.jsxs)(m,{children:[(0,D.jsx)(f,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,D.jsxs)(v,{className:`fixed left-1/2 top-1/2 z-66 flex h-[min(92vh,46rem)] w-[min(100%-2rem,44rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`,children:[(0,D.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-5 py-4`,children:[(0,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsx)(o,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.createDialog.title}),(0,D.jsx)(d,{className:`mt-1 truncate text-sm text-fg-muted`,children:t.createDialog.description})]}),(0,D.jsx)(_,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":t.closeDetails,onClick:M,children:(0,D.jsx)(T,{className:`size-5`,"aria-hidden":!0})})]}),(0,D.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:(0,D.jsxs)(`div`,{className:`grid gap-4`,children:[(0,D.jsx)(`section`,{className:`rounded-lg border border-accent/25 bg-accent-soft/50 px-3 py-3`,children:(0,D.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.createDialog.simpleStartTitle}),(0,D.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.createDialog.simpleStartHint})]}),(0,D.jsxs)(_,{type:`button`,variant:`secondary`,className:`h-8 shrink-0 rounded-lg text-xs`,onClick:()=>void ce(),disabled:K||!R.title.trim()&&!R.description.trim(),children:[(0,D.jsx)(ee,{className:`size-3.5`,"aria-hidden":!0}),K?t.createDialog.drafting:t.createDialog.aiDraft]})]})}),(0,D.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.goalTitle}),(0,D.jsx)(`input`,{value:R.title,onChange:e=>Y({title:e.target.value}),placeholder:t.newGoalPlaceholder,className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,autoFocus:!0})]}),(0,D.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.goalDescription}),(0,D.jsxs)(_,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg text-xs`,onClick:()=>J.fileInputRef.current?.click(),children:[(0,D.jsx)(w,{className:`size-3.5`,"aria-hidden":!0}),t.createDialog.addAttachment]})]}),(0,D.jsx)(`textarea`,{value:R.description,onChange:e=>Y({description:e.target.value}),placeholder:t.createDialog.descriptionPlaceholder,rows:4,className:`resize-none rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`}),(0,D.jsx)(`input`,{ref:J.fileInputRef,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{let t=Array.from(e.currentTarget.files??[]);e.currentTarget.value=``,J.processFiles(t)}}),(0,D.jsx)(p,{attachments:J.attachments,topPadded:!1,onRemove:J.removeAttachment})]}),(0,D.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base/60`,children:[(0,D.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between gap-3 px-4 py-3 text-left`,onClick:()=>V(e=>!e),children:[(0,D.jsxs)(`span`,{className:`min-w-0`,children:[(0,D.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:t.createDialog.completionPlan}),(0,D.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:t.createDialog.completionPlanHint})]}),(0,D.jsx)(C,{className:r(`size-4 shrink-0 text-fg-muted transition-transform`,B&&`rotate-180`),"aria-hidden":!0})]}),B?(0,D.jsxs)(`div`,{className:`grid gap-4 border-t border-edge-subtle p-4`,children:[(0,D.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-panel/70 p-3`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.createDialog.criteriaTitle}),(0,D.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.createDialog.criteriaHint}),(0,D.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:j.checklistDecomposePolicy===`supplement_existing`?t.createDialog.checklistPolicySupplementExisting:t.createDialog.checklistPolicyEmptyOnly})]}),(0,D.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[R.checklist.map((e,n)=>(0,D.jsxs)(`div`,{className:`flex gap-2`,children:[(0,D.jsx)(`input`,{value:e,onChange:e=>ie(n,e.target.value),placeholder:k(t.createDialog.criteriaPlaceholder,{index:n+1}),className:`min-w-0 flex-1 rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`}),(0,D.jsx)(_,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 rounded-lg p-0`,"aria-label":t.createDialog.removeCriteria,onClick:()=>ae(n),children:(0,D.jsx)(y,{className:`size-4`,"aria-hidden":!0})})]},n)),(0,D.jsxs)(_,{type:`button`,variant:`ghost`,className:`h-8 justify-start rounded-lg text-xs`,onClick:()=>Y({checklist:[...R.checklist,``]}),children:[(0,D.jsx)(g,{className:`size-3.5`,"aria-hidden":!0}),t.createDialog.addCriteria]})]})]}),(0,D.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-panel/70 p-3`,children:[(0,D.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.createDialog.contractTitle}),(0,D.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.createDialog.contractHint}),(0,D.jsxs)(`label`,{className:`mt-3 grid gap-1.5`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.objective}),(0,D.jsx)(`textarea`,{value:R.objective,onChange:e=>Y({objective:e.target.value}),placeholder:t.createDialog.objectivePlaceholder,rows:2,className:`resize-none rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`})]}),(0,D.jsxs)(`label`,{className:`mt-3 grid gap-1.5`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.scopeBoundary}),(0,D.jsx)(`textarea`,{value:R.scopeBoundary,onChange:e=>Y({scopeBoundary:e.target.value}),placeholder:t.createDialog.scopeBoundaryPlaceholder,rows:2,className:`resize-none rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`})]}),(0,D.jsxs)(`div`,{className:`mt-3 grid gap-1.5`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.evidencePlan}),(0,D.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.createDialog.evidencePlanHint}),R.evidencePlan.map((e,n)=>(0,D.jsxs)(`div`,{className:`flex gap-2`,children:[(0,D.jsx)(`input`,{value:e,onChange:e=>oe(n,e.target.value),placeholder:k(t.createDialog.evidencePlanPlaceholder,{index:n+1}),className:`min-w-0 flex-1 rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`}),(0,D.jsx)(_,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 rounded-lg p-0`,"aria-label":t.createDialog.removeEvidence,onClick:()=>se(n),children:(0,D.jsx)(y,{className:`size-4`,"aria-hidden":!0})})]},n)),(0,D.jsxs)(_,{type:`button`,variant:`ghost`,className:`h-8 justify-start rounded-lg text-xs`,onClick:()=>Y({evidencePlan:[...R.evidencePlan,``]}),children:[(0,D.jsx)(g,{className:`size-3.5`,"aria-hidden":!0}),t.createDialog.addEvidence]})]})]})]}):null]}),(0,D.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base/60`,children:[(0,D.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between gap-3 px-4 py-3 text-left`,onClick:()=>U(e=>!e),children:[(0,D.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,D.jsx)(h,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),t.createDialog.advanced]}),(0,D.jsx)(C,{className:r(`size-4 text-fg-muted transition-transform`,H&&`rotate-180`),"aria-hidden":!0})]}),H?(0,D.jsxs)(`div`,{className:`grid gap-3 border-t border-edge-subtle p-4 sm:grid-cols-2`,children:[(0,D.jsxs)(`label`,{className:`grid gap-1.5 sm:col-span-2`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.agentId}),(0,D.jsx)(s,{value:te,onChange:e=>Y({agentId:e.target.value}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,children:X.map(e=>(0,D.jsx)(x,{value:e.id,children:u(e,L)+(e.isDefault?` · ${t.createDialog.defaultAgent}`:` · ${e.id}`)},e.id))}),Q?(0,D.jsx)(`span`,{className:`line-clamp-2 text-xs text-fg-muted`,children:Q}):Z?.model?.primary?(0,D.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:k(t.createDialog.agentPrimaryModel,{model:Z.model.primary})}):null]}),(0,D.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.priority}),(0,D.jsxs)(s,{value:R.priority,onChange:e=>Y({priority:e.target.value}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,children:[(0,D.jsx)(x,{value:`normal`,children:t.priorities.normal}),(0,D.jsx)(x,{value:`high`,children:t.priorities.high}),(0,D.jsx)(x,{value:`low`,children:t.priorities.low})]})]}),(0,D.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.deadline}),(0,D.jsxs)(s,{value:R.deadlineMode,onChange:e=>re(e.target.value),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,children:[(0,D.jsx)(x,{value:`none`,children:t.createDialog.deadlineNone}),(0,D.jsx)(x,{value:`today`,children:t.createDialog.deadlineToday}),(0,D.jsx)(x,{value:`tomorrow`,children:t.createDialog.deadlineTomorrow}),(0,D.jsx)(x,{value:`friday`,children:t.createDialog.deadlineFriday}),(0,D.jsx)(x,{value:`custom`,children:t.createDialog.deadlineCustom})]})]}),R.deadlineMode===`none`?null:(0,D.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.deadlineAt}),(0,D.jsx)(`input`,{type:`datetime-local`,value:R.deadline,onChange:e=>Y({deadline:e.target.value,deadlineMode:`custom`}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`})]}),(0,D.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.maxTurns}),(0,D.jsx)(`input`,{type:`number`,min:1,max:500,value:R.maxTurns,onChange:e=>Y({maxTurns:e.target.value}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`})]}),(0,D.jsxs)(`label`,{className:`grid gap-1.5 sm:col-span-2`,children:[(0,D.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.judgeModel}),(0,D.jsxs)(s,{value:R.judgeModelRef,onChange:e=>Y({judgeModelRef:e.target.value}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,children:[(0,D.jsx)(x,{value:``,children:t.createDialog.judgeModelPlaceholder}),$.length?(0,D.jsx)(l,{label:t.createDialog.agentModelRoles,children:$.map(e=>(0,D.jsxs)(x,{value:e.model,children:[e.id===`judge`?t.createDialog.judgeRole:e.id,` · `,e.model]},`${e.id}:${e.model}`))}):null,(0,D.jsx)(l,{label:t.createDialog.configuredModels,children:ne.map(e=>(0,D.jsxs)(x,{value:e.id,children:[e.name,` · `,e.id]},e.id))})]})]})]}):null]}),W?(0,D.jsx)(`p`,{className:`rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:W}):null]})}),(0,D.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,D.jsx)(_,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:M,children:t.createDialog.cancel}),(0,D.jsxs)(_,{type:`button`,variant:`primary`,className:`rounded-lg`,disabled:A||!R.title.trim(),onClick:()=>void le(),children:[(0,D.jsx)(g,{className:`size-4`,"aria-hidden":!0}),t.createDialog.create]})]})]})]})})}export{P as n,F as t};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,l as a,t as o,u as s}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as c}from"./cn-BQ_8x0bT.js";import{t as l}from"./messages-t1yPaVCt.js";import{d as u,i as d,n as f}from"./locale-store-BneNAR8R.js";import{$l as p,As as m,Cl as h,Ct as g,Fs as _,Go as v,Io as y,Kc as b,Ll as x,Ol as S,Ps as C,Sl as w,Ul as T,Wl as E,Xl as D,Yl as ee,Zl as te,_ as O,ao as k,bt as A,cc as j,ct as M,cu as N,gu as P,hc as F,hl as I,hs as L,ht as ne,js as re,ml as R,mt as z,nc as B,qo as V,xu as ie,y as ae,yu as oe}from"./index-CH7XN6KY.js";import{t as se}from"./automation-suggestion-card-CjIWpsch.js";var ce=n(),H=e(t(),1),U=r();function le(e){return e.split(`
|
|
2
|
+
`).map(e=>e.trim()).filter(Boolean)}function ue(){let e=(0,ce.c)(7),t,n,r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,U.jsx)(k,{className:`h-5 w-20 rounded-full`}),(0,U.jsx)(k,{className:`h-4 w-28`}),(0,U.jsx)(k,{className:`h-4 w-24`})]}),n=(0,U.jsx)(k,{className:`mt-4 h-4 w-full max-w-3xl`}),r=(0,U.jsx)(k,{className:`mt-2 h-4 w-2/3 max-w-2xl`}),e[0]=t,e[1]=n,e[2]=r):(t=e[0],n=e[1],r=e[2]);let i;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,U.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[t,n,r,(0,U.jsxs)(`div`,{className:`mt-4 grid gap-3 md:grid-cols-3`,children:[(0,U.jsx)(k,{className:`h-16 rounded-md`}),(0,U.jsx)(k,{className:`h-16 rounded-md`}),(0,U.jsx)(k,{className:`h-16 rounded-md`})]})]}),e[3]=i):i=e[3];let a;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,U.jsx)(k,{className:`h-4 w-32`}),e[4]=a):a=e[4];let o;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,U.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[a,(0,U.jsx)(`div`,{className:`mt-4 grid gap-3`,children:Array.from({length:5}).map(W)})]}),e[5]=o):o=e[5];let s;return e[6]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,U.jsxs)(`div`,{className:`grid gap-4`,"aria-hidden":`true`,children:[i,(0,U.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-[minmax(0,1fr)_22rem]`,children:[o,(0,U.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,U.jsx)(k,{className:`h-4 w-28`}),(0,U.jsx)(k,{className:`mt-4 h-24 rounded-md`}),(0,U.jsx)(k,{className:`mt-3 h-24 rounded-md`})]})]})]}),e[6]=s):s=e[6],s}function W(e,t){return(0,U.jsx)(k,{className:`h-14 rounded-md`},t)}var G=`min-w-0 rounded-md border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,de=[`message`,`link`,`file`,`diff`,`command`,`test`,`artifact`];function fe(e){return e===`command`||e===`test`?C:e===`diff`?x:e===`file`||e===`artifact`?w:e===`link`?S:B}function pe(e){return e.data&&typeof e.data==`object`&&!Array.isArray(e.data)?e.data:{}}function me(e,t){let n=e[t];return typeof n==`string`&&n.trim()?n:void 0}function K(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function he(e){let t=(0,ce.c)(57),{item:n,language:r,t:i}=e,a;t[0]===n.kind?a=t[1]:(a=fe(n.kind),t[0]=n.kind,t[1]=a);let o=a,s,c,l,u,d,f,p,m,h;if(t[2]!==o||t[3]!==n||t[4]!==r||t[5]!==i){let e=pe(n),a=me(e,`command`),g=K(e,`exitCode`),_=me(e,`path`)||n.uri,v=K(e,`outputBytes`);s=e.fuzzyMatchUsed===!0,f=`rounded-md bg-surface-muted/40 px-2.5 py-2`;let y;t[15]===o?y=t[16]:(y=(0,U.jsx)(o,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}),t[15]=o,t[16]=y);let b;t[17]===n.title?b=t[18]:(b=(0,U.jsx)(`p`,{className:`break-words font-medium text-fg`,children:n.title}),t[17]=n.title,t[18]=b);let x=_?(0,U.jsx)(`p`,{className:`mt-1 break-all text-xs text-fg-muted`,children:_}):null,S;t[19]!==b||t[20]!==x?(S=(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[b,x]}),t[19]=b,t[20]=x,t[21]=S):S=t[21];let C;t[22]!==y||t[23]!==S?(C=(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-2`,children:[y,S]}),t[22]=y,t[23]=S,t[24]=C):C=t[24];let w;t[25]!==n.kind||t[26]!==i?(w=De(n.kind,i),t[25]=n.kind,t[26]=i,t[27]=w):w=t[27];let T;t[28]===w?T=t[29]:(T=(0,U.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:w}),t[28]=w,t[29]=T),t[30]!==C||t[31]!==T?(p=(0,U.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[C,T]}),t[30]=C,t[31]=T,t[32]=p):p=t[32],m=a?(0,U.jsx)(`pre`,{className:`mt-2 overflow-x-auto rounded-md bg-surface-panel px-2 py-1.5 text-xs text-fg`,children:(0,U.jsx)(`code`,{children:a})}):null,t[33]!==n.kind||t[34]!==n.summary?(h=n.summary?n.kind===`diff`?(0,U.jsx)(`pre`,{className:`mt-2 max-h-56 overflow-auto whitespace-pre-wrap rounded-md bg-surface-panel px-2 py-1.5 text-xs text-fg-muted`,children:(0,U.jsx)(`code`,{children:n.summary})}):(0,U.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap break-words text-xs text-fg-muted`,children:n.summary}):null,t[33]=n.kind,t[34]=n.summary,t[35]=h):h=t[35],c=`mt-2 flex flex-wrap items-center gap-2 text-xs text-fg-muted`;let E;t[36]!==n.createdAt||t[37]!==r||t[38]!==i?(E=be(n.createdAt,r,i),t[36]=n.createdAt,t[37]=r,t[38]=i,t[39]=E):E=t[39],t[40]===E?l=t[41]:(l=(0,U.jsx)(`time`,{children:E}),t[40]=E,t[41]=l),u=g==null?null:(0,U.jsx)(`span`,{children:q(i.exitCode,{code:g})}),d=v==null?null:(0,U.jsx)(`span`,{children:q(i.outputBytes,{bytes:v})}),t[2]=o,t[3]=n,t[4]=r,t[5]=i,t[6]=s,t[7]=c,t[8]=l,t[9]=u,t[10]=d,t[11]=f,t[12]=p,t[13]=m,t[14]=h}else s=t[6],c=t[7],l=t[8],u=t[9],d=t[10],f=t[11],p=t[12],m=t[13],h=t[14];let g;t[42]!==s||t[43]!==i?(g=s?(0,U.jsx)(`span`,{children:i.fuzzyMatch}):null,t[42]=s,t[43]=i,t[44]=g):g=t[44];let _;t[45]!==g||t[46]!==c||t[47]!==l||t[48]!==u||t[49]!==d?(_=(0,U.jsxs)(`div`,{className:c,children:[l,u,d,g]}),t[45]=g,t[46]=c,t[47]=l,t[48]=u,t[49]=d,t[50]=_):_=t[50];let v;return t[51]!==_||t[52]!==f||t[53]!==p||t[54]!==m||t[55]!==h?(v=(0,U.jsxs)(`li`,{className:f,children:[p,m,h,_]}),t[51]=_,t[52]=f,t[53]=p,t[54]=m,t[55]=h,t[56]=v):v=t[56],v}function ge(e){return e===`active`?`border-accent/40 bg-accent-soft text-accent-fg`:e===`done`?`border-edge bg-surface-muted text-fg-muted`:e===`blocked`||e===`needs_input`?`border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-300`:`border-edge bg-surface-panel text-fg-muted`}function _e(e){return e===`succeeded`?`border-emerald-500/40 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`failed`||e===`timeout`?`border-destructive/40 bg-destructive/10 text-destructive`:e===`cancelled`?`border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-300`:`border-accent/40 bg-accent-soft text-accent-fg`}function ve(e){return e===`workflow_run`?R:e===`goal_run`?N:e===`queue`?ee:e===`evidence`?w:ie}function q(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function ye(e){return e===`zh`?`zh-CN`:`en-US`}function be(e,t,n){return e?new Intl.DateTimeFormat(ye(t),{dateStyle:`medium`,timeStyle:`short`}).format(new Date(e)):n.notSet}function xe(e,t,n){return e?new Intl.DateTimeFormat(ye(t),{dateStyle:`medium`}).format(new Date(e)):n.noDeadline}function Se(e,t){return e===`blocked`||e===`needs_input`?t.primaryActions.resolveBlocker:e===`paused`?t.primaryActions.resume:e===`done`?t.primaryActions.completed:e===`archived`?t.primaryActions.archived:t.primaryActions.continue}function Ce(e){return e===`completed`?`✓`:e===`impossible`?`!`:`○`}function we(e){return e===`all`||e===`queue`||e===`goal_run`||e===`workflow_run`||e===`event`||e===`evidence`}function Te(e,t){return e?t.statuses[e]??e:``}function Ee(e,t){return t.priorities[e]??e}function De(e,t){return t.evidenceKinds[e]??e}function Oe(e){return!e||e.currentValue==null?!1:e.direction===`increase`?e.currentValue>=e.targetValue:e.currentValue<=e.targetValue}function J(e){if(!e.trim())return;let t=Number(e);return Number.isFinite(t)?t:void 0}function ke(e,t,n){let r=e.evidenceRequirements.some(e=>e.status!==`approved`),i=!!(e.contract?.outcomeMetric&&!Oe(e.contract.outcomeMetric));if(e.status===`done`&&(r||i||t?.verdict===`continue`))return{title:n.progressPanel.executionFinishedTitle,body:n.progressPanel.executionFinishedFallback,tone:`attention`,needsReview:!0};if(e.status===`blocked`)return{title:n.progressPanel.blockedTitle,body:e.blockedReason||n.progressPanel.blockedFallback,tone:`attention`,needsReview:!1};if(e.status===`needs_input`){let t=e.blockedReason?.startsWith(`Completion review required`);return{title:t?n.progressPanel.executionFinishedTitle:n.progressPanel.needsInputTitle,body:t?n.progressPanel.executionFinishedFallback:e.blockedReason||e.nextAction||n.progressPanel.needsInputFallback,tone:`attention`,needsReview:!!t}}return e.status===`paused`?{title:n.progressPanel.pausedTitle,body:e.blockedReason||n.progressPanel.pausedFallback,tone:`normal`,needsReview:!1}:e.status===`done`?{title:n.progressPanel.doneTitle,body:n.progressPanel.doneFallback,tone:`done`,needsReview:!1}:e.status===`archived`?{title:n.progressPanel.archivedTitle,body:n.progressPanel.archivedFallback,tone:`normal`,needsReview:!1}:{title:n.progressPanel.activeTitle,body:e.nextAction||n.noNextAction,tone:`normal`,needsReview:!1}}function Ae(e,t){return t<=0?0:Math.min(100,Math.max(0,Math.round(e/t*100)))}function je(e){let t=(0,ce.c)(210),{goal:n,latestRun:r,done:i,total:a,evidence:o,language:s,t:l,busy:u,primaryActionDisabled:d,onContinue:f,onOpenChat:h,onPause:g,onConfigureOutcome:v,onReviewEvidence:y}=e,b;t[0]!==n||t[1]!==r||t[2]!==l?(b=ke(n,r,l),t[0]=n,t[1]=r,t[2]=l,t[3]=b):b=t[3];let x=b,C,w,T,E,O,k,A,j,M,N,P,F,ne,re;if(t[4]!==i||t[5]!==o||t[6]!==n.contract?.outcomeMetric||t[7]!==n.deadlineAt||t[8]!==n.evidenceRequirements||t[9]!==n.priority||t[10]!==n.status||t[11]!==s||t[12]!==r||t[13]!==y||t[14]!==x.body||t[15]!==x.needsReview||t[16]!==x.title||t[17]!==x.tone||t[18]!==l||t[19]!==a){let e=n.evidenceRequirements.filter(Pe).length,u=n.evidenceRequirements.length,d,f,h,g,_;if(t[34]!==i||t[35]!==n.contract?.outcomeMetric||t[36]!==n.deadlineAt||t[37]!==n.evidenceRequirements||t[38]!==n.priority||t[39]!==n.status||t[40]!==s||t[41]!==r||t[42]!==x.body||t[43]!==x.needsReview||t[44]!==x.title||t[45]!==x.tone||t[46]!==l||t[47]!==a){w=n.evidenceRequirements.filter(Ne).slice(0,2);let e;t[58]!==i||t[59]!==a?(e=Ae(i,a),t[58]=i,t[59]=a,t[60]=e):e=t[60],d=e,C=n.contract?.outcomeMetric,T=Oe(C);let o=x.tone===`attention`?m:x.tone===`done`?te:ee;k=`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,E=`grid gap-5`,f=`min-w-0`;let u;t[61]!==n.status||t[62]!==x.needsReview?(u=c(`rounded-full border px-2 py-0.5 text-xs`,ge(x.needsReview?`needs_input`:n.status)),t[61]=n.status,t[62]=x.needsReview,t[63]=u):u=t[63];let p;t[64]!==n.status||t[65]!==x.needsReview||t[66]!==l?(p=x.needsReview?l.progressPanel.reviewPendingLabel:Te(n.status,l),t[64]=n.status,t[65]=x.needsReview,t[66]=l,t[67]=p):p=t[67];let v;t[68]!==u||t[69]!==p?(v=(0,U.jsx)(`span`,{className:u,children:p}),t[68]=u,t[69]=p,t[70]=v):v=t[70];let y;t[71]!==n.priority||t[72]!==l?(y=q(l.prioritySummary,{priority:Ee(n.priority,l)}),t[71]=n.priority,t[72]=l,t[73]=y):y=t[73];let b;t[74]===y?b=t[75]:(b=(0,U.jsx)(`span`,{className:`text-xs text-fg-muted`,children:y}),t[74]=y,t[75]=b);let S;t[76]!==n.deadlineAt||t[77]!==s||t[78]!==l?(S=n.deadlineAt?xe(n.deadlineAt,s,l):l.noDeadline,t[76]=n.deadlineAt,t[77]=s,t[78]=l,t[79]=S):S=t[79];let D;t[80]===S?D=t[81]:(D=(0,U.jsx)(`span`,{className:`text-xs text-fg-muted`,children:S}),t[80]=S,t[81]=D),t[82]!==v||t[83]!==b||t[84]!==D?(h=(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[v,b,D]}),t[82]=v,t[83]=b,t[84]=D,t[85]=h):h=t[85];let O=x.tone===`attention`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:x.tone===`done`?`bg-success-soft text-success`:`bg-accent-soft text-accent-fg`,A;t[86]===O?A=t[87]:(A=c(`mt-0.5 flex size-9 shrink-0 items-center justify-center rounded-lg`,O),t[86]=O,t[87]=A);let j;t[88]===o?j=t[89]:(j=(0,U.jsx)(o,{className:`size-5`,"aria-hidden":!0}),t[88]=o,t[89]=j);let M;t[90]!==A||t[91]!==j?(M=(0,U.jsx)(`div`,{className:A,children:j}),t[90]=A,t[91]=j,t[92]=M):M=t[92];let N;t[93]===x.title?N=t[94]:(N=(0,U.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:x.title}),t[93]=x.title,t[94]=N);let P;t[95]===x.body?P=t[96]:(P=(0,U.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap break-words text-sm text-fg-muted`,children:x.body}),t[95]=x.body,t[96]=P);let F;t[97]!==s||t[98]!==r||t[99]!==l?(F=r?.reason?(0,U.jsx)(`p`,{className:`mt-2 line-clamp-2 break-words text-xs text-fg-subtle`,children:q(l.progressPanel.lastCheck,{time:be(r.finishedAt??r.startedAt,s,l),reason:r.reason})}):null,t[97]=s,t[98]=r,t[99]=l,t[100]=F):F=t[100];let I;t[101]!==N||t[102]!==P||t[103]!==F?(I=(0,U.jsxs)(`div`,{className:`min-w-0`,children:[N,P,F]}),t[101]=N,t[102]=P,t[103]=F,t[104]=I):I=t[104],t[105]!==M||t[106]!==I?(g=(0,U.jsxs)(`div`,{className:`mt-3 flex items-start gap-3`,children:[M,I]}),t[105]=M,t[106]=I,t[107]=g):g=t[107],_=w.length?(0,U.jsxs)(`div`,{className:`mt-4 rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2`,children:[(0,U.jsx)(`p`,{className:`text-xs font-medium text-amber-800 dark:text-amber-200`,children:l.progressPanel.evidenceNeeded}),(0,U.jsx)(`ul`,{className:`mt-1 grid gap-1 text-xs text-amber-800 dark:text-amber-200`,children:w.map(Me)})]}):null,t[34]=i,t[35]=n.contract?.outcomeMetric,t[36]=n.deadlineAt,t[37]=n.evidenceRequirements,t[38]=n.priority,t[39]=n.status,t[40]=s,t[41]=r,t[42]=x.body,t[43]=x.needsReview,t[44]=x.title,t[45]=x.tone,t[46]=l,t[47]=a,t[48]=d,t[49]=C,t[50]=w,t[51]=T,t[52]=E,t[53]=k,t[54]=f,t[55]=h,t[56]=g,t[57]=_}else d=t[48],C=t[49],w=t[50],T=t[51],E=t[52],k=t[53],f=t[54],h=t[55],g=t[56],_=t[57];t[108]!==f||t[109]!==h||t[110]!==g||t[111]!==_?(O=(0,U.jsxs)(`div`,{className:f,children:[h,g,_]}),t[108]=f,t[109]=h,t[110]=g,t[111]=_,t[112]=O):O=t[112],ne=`grid gap-3 md:grid-cols-3`;let v;t[113]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,U.jsx)(I,{className:`size-4`,"aria-hidden":!0}),t[113]=v):v=t[113];let b;t[114]===l.progressPanel.execution?b=t[115]:(b=(0,U.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[v,l.progressPanel.execution]}),t[114]=l.progressPanel.execution,t[115]=b);let S;t[116]!==i||t[117]!==l.checklistProgress||t[118]!==l.notSet||t[119]!==a?(S=a?q(l.checklistProgress,{done:i,total:a}):l.notSet,t[116]=i,t[117]=l.checklistProgress,t[118]=l.notSet,t[119]=a,t[120]=S):S=t[120];let D;t[121]===S?D=t[122]:(D=(0,U.jsx)(`p`,{className:`mt-2 text-lg font-semibold tabular-nums text-fg`,children:S}),t[121]=S,t[122]=D);let L=`${d}%`,R;t[123]===L?R=t[124]:(R=(0,U.jsx)(`div`,{className:`mt-2 h-1.5 overflow-hidden rounded-full bg-surface-hover`,children:(0,U.jsx)(`div`,{className:`h-full rounded-full bg-accent`,style:{width:L}})}),t[123]=L,t[124]=R),t[125]!==b||t[126]!==D||t[127]!==R?(re=(0,U.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-panel/70 p-3`,children:[b,D,R]}),t[125]=b,t[126]=D,t[127]=R,t[128]=re):re=t[128],M=`button`,N=`rounded-lg border border-edge-subtle bg-surface-panel/70 p-3 text-left transition-colors hover:bg-surface-hover`,P=y;let z;t[129]===l.progressPanel.evidence?z=t[130]:(z=(0,U.jsx)(`span`,{children:l.progressPanel.evidence}),t[129]=l.progressPanel.evidence,t[130]=z);let B;t[131]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,U.jsx)(p,{className:`size-4`,"aria-hidden":!0}),t[131]=B):B=t[131],t[132]===z?F=t[133]:(F=(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-xs font-medium text-fg-muted`,children:[z,B]}),t[132]=z,t[133]=F),A=`mt-2 text-lg font-semibold tabular-nums text-fg`,j=u?q(l.evidenceRequirementProgress,{approved:e,total:u}):q(l.progressPanel.evidenceCount,{count:o.length}),t[4]=i,t[5]=o,t[6]=n.contract?.outcomeMetric,t[7]=n.deadlineAt,t[8]=n.evidenceRequirements,t[9]=n.priority,t[10]=n.status,t[11]=s,t[12]=r,t[13]=y,t[14]=x.body,t[15]=x.needsReview,t[16]=x.title,t[17]=x.tone,t[18]=l,t[19]=a,t[20]=C,t[21]=w,t[22]=T,t[23]=E,t[24]=O,t[25]=k,t[26]=A,t[27]=j,t[28]=M,t[29]=N,t[30]=P,t[31]=F,t[32]=ne,t[33]=re}else C=t[20],w=t[21],T=t[22],E=t[23],O=t[24],k=t[25],A=t[26],j=t[27],M=t[28],N=t[29],P=t[30],F=t[31],ne=t[32],re=t[33];let R;t[134]!==A||t[135]!==j?(R=(0,U.jsx)(`p`,{className:A,children:j}),t[134]=A,t[135]=j,t[136]=R):R=t[136];let z=w.length?l.progressPanel.reviewNeeded:l.progressPanel.reviewComplete,B;t[137]===z?B=t[138]:(B=(0,U.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:z}),t[137]=z,t[138]=B);let V;t[139]!==R||t[140]!==B||t[141]!==M||t[142]!==N||t[143]!==P||t[144]!==F?(V=(0,U.jsxs)(`button`,{type:M,className:N,onClick:P,children:[F,R,B]}),t[139]=R,t[140]=B,t[141]=M,t[142]=N,t[143]=P,t[144]=F,t[145]=V):V=t[145];let ie=C&&T?`border-success/30 bg-success-soft/40`:`border-edge-subtle bg-surface-panel/70`,ae;t[146]===ie?ae=t[147]:(ae=c(`rounded-lg border p-3 text-left transition-colors hover:bg-surface-hover`,ie),t[146]=ie,t[147]=ae);let oe;t[148]===Symbol.for(`react.memo_cache_sentinel`)?(oe=(0,U.jsx)(_,{className:`size-4`,"aria-hidden":!0}),t[148]=oe):oe=t[148];let se;t[149]===l.progressPanel.outcome?se=t[150]:(se=(0,U.jsxs)(`span`,{className:`flex items-center gap-2`,children:[oe,l.progressPanel.outcome]}),t[149]=l.progressPanel.outcome,t[150]=se);let H;t[151]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,U.jsx)(p,{className:`size-4`,"aria-hidden":!0}),t[151]=H):H=t[151];let le;t[152]===se?le=t[153]:(le=(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-xs font-medium text-fg-muted`,children:[se,H]}),t[152]=se,t[153]=le);let ue;t[154]!==C||t[155]!==l.progressPanel.currentMissing||t[156]!==l.progressPanel.outcomeNotSet||t[157]!==l.progressPanel.outcomeSummary?(ue=C?q(l.progressPanel.outcomeSummary,{baseline:C.baselineValue,current:C.currentValue??l.progressPanel.currentMissing,target:C.targetValue,unit:C.unit?` ${C.unit}`:``}):l.progressPanel.outcomeNotSet,t[154]=C,t[155]=l.progressPanel.currentMissing,t[156]=l.progressPanel.outcomeNotSet,t[157]=l.progressPanel.outcomeSummary,t[158]=ue):ue=t[158];let W;t[159]===ue?W=t[160]:(W=(0,U.jsx)(`p`,{className:`mt-2 truncate text-lg font-semibold tabular-nums text-fg`,children:ue}),t[159]=ue,t[160]=W);let G=C?C.name:l.progressPanel.outcomeNotSetHint,de;t[161]===G?de=t[162]:(de=(0,U.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:G}),t[161]=G,t[162]=de);let fe;t[163]!==v||t[164]!==ae||t[165]!==le||t[166]!==W||t[167]!==de?(fe=(0,U.jsxs)(`button`,{type:`button`,className:ae,onClick:v,children:[le,W,de]}),t[163]=v,t[164]=ae,t[165]=le,t[166]=W,t[167]=de,t[168]=fe):fe=t[168];let pe;t[169]!==V||t[170]!==fe||t[171]!==ne||t[172]!==re?(pe=(0,U.jsxs)(`div`,{className:ne,children:[re,V,fe]}),t[169]=V,t[170]=fe,t[171]=ne,t[172]=re,t[173]=pe):pe=t[173];let me;t[174]===Symbol.for(`react.memo_cache_sentinel`)?(me=(0,U.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),t[174]=me):me=t[174];let K;t[175]!==n.nextAction||t[176]!==n.status||t[177]!==x.needsReview||t[178]!==l?(K=x.needsReview&&n.nextAction?l.progressPanel.continueExecution:Se(n.status,l),t[175]=n.nextAction,t[176]=n.status,t[177]=x.needsReview,t[178]=l,t[179]=K):K=t[179];let he;t[180]!==f||t[181]!==d||t[182]!==K?(he=(0,U.jsxs)(L,{type:`button`,variant:`primary`,className:`h-9 flex-1 rounded-lg`,disabled:d,onClick:f,children:[me,K]}),t[180]=f,t[181]=d,t[182]=K,t[183]=he):he=t[183];let _e;t[184]!==w.length||t[185]!==y||t[186]!==l.progressPanel.reviewEvidenceAction?(_e=w.length?(0,U.jsx)(L,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg`,onClick:y,children:l.progressPanel.reviewEvidenceAction}):null,t[184]=w.length,t[185]=y,t[186]=l.progressPanel.reviewEvidenceAction,t[187]=_e):_e=t[187];let ve;t[188]!==n.activeSessionKey||t[189]!==h||t[190]!==l.chat?(ve=n.activeSessionKey?(0,U.jsx)(L,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg px-2.5`,"aria-label":l.chat,onClick:h,children:(0,U.jsx)(S,{className:`size-4`,"aria-hidden":!0})}):null,t[188]=n.activeSessionKey,t[189]=h,t[190]=l.chat,t[191]=ve):ve=t[191];let ye=u!=null||n.status!==`active`,Ce;t[192]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=(0,U.jsx)(D,{className:`size-4`,"aria-hidden":!0}),t[192]=Ce):Ce=t[192];let we;t[193]!==g||t[194]!==l.pause||t[195]!==ye?(we=(0,U.jsx)(L,{type:`button`,variant:`ghost`,className:`h-9 rounded-lg px-2.5`,"aria-label":l.pause,disabled:ye,onClick:g,children:Ce}),t[193]=g,t[194]=l.pause,t[195]=ye,t[196]=we):we=t[196];let De;t[197]!==he||t[198]!==_e||t[199]!==ve||t[200]!==we?(De=(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-t border-edge-subtle pt-4`,children:[he,_e,ve,we]}),t[197]=he,t[198]=_e,t[199]=ve,t[200]=we,t[201]=De):De=t[201];let J;t[202]!==E||t[203]!==O||t[204]!==pe||t[205]!==De?(J=(0,U.jsxs)(`div`,{className:E,children:[O,pe,De]}),t[202]=E,t[203]=O,t[204]=pe,t[205]=De,t[206]=J):J=t[206];let je;return t[207]!==k||t[208]!==J?(je=(0,U.jsx)(`section`,{className:k,children:J}),t[207]=k,t[208]=J,t[209]=je):je=t[209],je}function Me(e){return(0,U.jsxs)(`li`,{className:`break-words`,children:[`- `,e.text]},e.id)}function Ne(e){return e.status!==`approved`}function Pe(e){return e.status===`approved`}function Fe(e){let t=e?.trim();return!t||!t.startsWith(`/projects/`)||t.startsWith(`//`)||t.includes(`://`)?`/goals`:t}async function Ie(e){return(await d(u(`/api/goals/${encodeURIComponent(e)}`))).goal}async function Le(e){return(await d(u(`/api/goals/${encodeURIComponent(e)}/runs?limit=100`))).runs}async function Re(e){return(await d(u(`/api/goals/${encodeURIComponent(e)}/evidence?limit=100`))).evidence}async function ze(e){return(await d(u(`/api/goals/${encodeURIComponent(e)}/activity?limit=120`))).activities}async function Be(e){return(await d(u(`/api/goals/${encodeURIComponent(e)}/workflow-suggestions`))).suggestions}function Ve(){let{goalId:e=``}=s(),t=a(),n=f(e=>e.language),r=l(n).goalDetailPage,m=l(n).automations.suggestions,x=y(e=>e.setPageHeader),C=y(e=>e.clearPageHeader),[w,D]=i(),[N,I]=(0,H.useState)(null),[B,ce]=(0,H.useState)([]),[W,fe]=(0,H.useState)([]),[K,ge]=(0,H.useState)([]),[ye,Se]=(0,H.useState)([]),[Ee,Ae]=(0,H.useState)([]),[Me,Ne]=(0,H.useState)([]),[Pe,Ve]=(0,H.useState)(``),[He,Ue]=(0,H.useState)(`message`),[We,Ge]=(0,H.useState)(``),[Ke,qe]=(0,H.useState)(``),[Je,Ye]=(0,H.useState)(``),[Xe,Ze]=(0,H.useState)(``),[Qe,$e]=(0,H.useState)(``),[et,tt]=(0,H.useState)(``),[nt,rt]=(0,H.useState)(`normal`),[it,at]=(0,H.useState)(``),[ot,st]=(0,H.useState)(`10`),[ct,lt]=(0,H.useState)(``),[ut,dt]=(0,H.useState)(``),[ft,pt]=(0,H.useState)(``),[mt,ht]=(0,H.useState)(``),[gt,_t]=(0,H.useState)(``),[vt,yt]=(0,H.useState)(``),[bt,xt]=(0,H.useState)(``),[St,Ct]=(0,H.useState)(``),[wt,Tt]=(0,H.useState)(``),[Et,Dt]=(0,H.useState)(``),[Ot,kt]=(0,H.useState)(``),[At,jt]=(0,H.useState)(``),[Mt,Nt]=(0,H.useState)(``),[Pt,Ft]=(0,H.useState)(``),[It,Lt]=(0,H.useState)(``),[Rt,zt]=(0,H.useState)(!0),[Y,X]=(0,H.useState)(null),[Bt,Z]=(0,H.useState)(null),Vt=(0,H.useMemo)(()=>Fe(w.get(`returnTo`)),[w]),Ht=(0,H.useCallback)(async()=>{if(e){zt(!0),Z(null);try{let[t,n,r]=await Promise.all([Ie(e),Le(e),Re(e)]);I(t),ce(n);let[i,a]=await Promise.all([z(e,50),ze(e)]);ge(i),Ne(a),Se(await Be(e)),Ae(r)}catch(e){Z(e instanceof Error?e.message:r.errors.load)}finally{zt(!1)}}},[e,r.errors.load]);(0,H.useEffect)(()=>{Ht()},[Ht]),(0,H.useEffect)(()=>{let e=!1;return ne().then(t=>{e||(fe(t),Ft(e=>e||t[0]?.id||``))}).catch(t=>{e||Z(t instanceof Error?t.message:r.errors.loadWorkflows)}),()=>{e=!0}},[r.errors.loadWorkflows]),(0,H.useEffect)(()=>{if(!N)return;$e(N.title),tt(N.description??``),rt(N.priority),at(N.deadlineAt?new Date(N.deadlineAt).toISOString().slice(0,10):``),st(String(N.maxTurns)),lt(N.judgeModelRef??``),dt(N.nextAction??``),pt(N.blockedReason??``),ht(N.contract?.objective??N.title),_t(N.contract?.scopeBoundary??``),yt(N.checklist.map(e=>e.text).join(`
|
|
3
|
+
`)),xt(N.contract?.evidencePlan.join(`
|
|
4
|
+
`)??``);let e=N.contract?.outcomeMetric;Ct(e?.name??``),Tt(e?String(e.baselineValue):``),Dt(e?String(e.targetValue):``),kt(e?.currentValue==null?``:String(e.currentValue)),jt(e?.unit??``),Nt(e?.sourceUrl??``),Ze(e=>N.evidenceRequirements.some(t=>t.id===e)?e:N.evidenceRequirements[0]?.id??``),Lt(e=>e||N.nextAction||N.title)},[N?.id,N?.updatedAt]);let Ut=async()=>{if(N){X(`continue`);try{N.status===`done`&&await d(u(`/api/goals/${encodeURIComponent(N.id)}/reopen`),{method:`POST`,body:JSON.stringify({})});let e=await d(u(`/api/goals/${encodeURIComponent(N.id)}/continue`),{method:`POST`,body:JSON.stringify({})});if(e.sessionKey){t(`/chat/${encodeURIComponent(e.sessionKey)}`);return}await Ht()}catch(e){Z(e instanceof Error?e.message:r.errors.continue)}finally{X(null)}}},Wt=async e=>{if(e.preventDefault(),!N)return;let t=Qe.trim();if(t){X(`details:save`),Z(null);try{let e=Number.parseInt(ot,10);I((await d(u(`/api/goals/${encodeURIComponent(N.id)}`),{method:`PATCH`,body:JSON.stringify({title:t,description:et.trim()||void 0,priority:nt,deadlineAt:it?new Date(`${it}T23:59:59`).getTime():void 0,maxTurns:Number.isFinite(e)?e:N.maxTurns,judgeModelRef:ct.trim()||void 0,nextAction:ut.trim()||void 0,blockedReason:ft.trim()||void 0})})).goal),await Q(N.id)}catch(e){Z(e instanceof Error?e.message:r.errors.save)}finally{X(null)}}},Gt=async e=>{if(e.preventDefault(),!N)return;let t=mt.trim();if(t){X(`contract:save`),Z(null);try{I((await d(u(`/api/goals/${encodeURIComponent(N.id)}/contract`),{method:`PUT`,body:JSON.stringify({objective:t,scopeBoundary:gt.trim()||void 0,criteria:le(vt),evidencePlan:le(bt)})})).goal),await Q(N.id)}catch(e){Z(e instanceof Error?e.message:r.errors.save)}finally{X(null)}}},Kt=async e=>{if(e.preventDefault(),!N)return;let t=J(wt),n=J(Et),i=J(Ot);if(!(!St.trim()||t==null||n==null)){X(`outcome:save`),Z(null);try{I((await d(u(`/api/goals/${encodeURIComponent(N.id)}/contract`),{method:`PUT`,body:JSON.stringify({objective:N.contract?.objective??N.title,scopeBoundary:N.contract?.scopeBoundary,criteria:N.checklist.map(e=>e.text),evidencePlan:N.contract?.evidencePlan??[],outcomeMetric:{name:St.trim(),baselineValue:t,targetValue:n,currentValue:i,unit:At.trim()||void 0,sourceUrl:Mt.trim()||void 0,measuredAt:i==null?void 0:Date.now()}})})).goal),await Q(N.id)}catch(e){Z(e instanceof Error?e.message:r.errors.save)}finally{X(null)}}},qt=async()=>{if(N){X(`outcome:clear`),Z(null);try{I((await d(u(`/api/goals/${encodeURIComponent(N.id)}/contract`),{method:`PUT`,body:JSON.stringify({objective:N.contract?.objective??N.title,scopeBoundary:N.contract?.scopeBoundary,criteria:N.checklist.map(e=>e.text),evidencePlan:N.contract?.evidencePlan??[],outcomeMetric:null})})).goal),await Q(N.id)}catch(e){Z(e instanceof Error?e.message:r.errors.save)}finally{X(null)}}},Jt=async e=>{if(N){X(e);try{await d(u(`/api/goals/${encodeURIComponent(N.id)}/${e}`),{method:`POST`,body:JSON.stringify({})}),await Ht()}catch(e){Z(e instanceof Error?e.message:r.errors.action)}finally{X(null)}}},Yt=async()=>{if(!(!N||!Pt)){X(`workflow:run`),Z(null);try{let e=await g({goalId:N.id,definitionId:Pt,goal:It.trim()||N.nextAction||N.title});await Ht(),t(`/chat/${encodeURIComponent(e.sessionKey)}`)}catch(e){Z(e instanceof Error?e.message:r.errors.startWorkflow)}finally{X(null)}}},Q=async e=>{try{Ne(await ze(e))}catch{}},Xt=async e=>{try{let[t,n,r]=await Promise.all([z(e,50),ze(e),Be(e)]);ge(t),Ne(n),Se(r)}catch{}},Zt=async e=>{if(N){X(`workflow:${e.id}:cancel`),Z(null);try{await M(e.id,{ownerAgentId:N.agentId}),await Xt(N.id)}catch(e){Z(e instanceof Error?e.message:r.errors.cancelWorkflow)}finally{X(null)}}},Qt=async e=>{if(N){X(`workflow:${e.id}:retry`),Z(null);try{let n=await A(e.id,{ownerAgentId:N.agentId});await Xt(N.id),t(`/chat/${encodeURIComponent(n.sessionKey)}`)}catch(e){Z(e instanceof Error?e.message:r.errors.retryWorkflow)}finally{X(null)}}},$t=async e=>{if(e.preventDefault(),!N)return;let t=Pe.trim();if(t){X(`checklist:add`),Z(null);try{I((await d(u(`/api/goals/${encodeURIComponent(N.id)}/checklist`),{method:`POST`,body:JSON.stringify({text:t})})).goal),Ve(``),await Q(N.id)}catch(e){Z(e instanceof Error?e.message:r.errors.addChecklist)}finally{X(null)}}},en=async(e,t)=>{if(N){X(`checklist:${e}:${t}`),Z(null);try{I((await d(u(`/api/goals/${encodeURIComponent(N.id)}/checklist/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({status:t})})).goal),await Q(N.id)}catch(e){Z(e instanceof Error?e.message:r.errors.updateChecklist)}finally{X(null)}}},tn=async e=>{if(N){X(`checklist:${e}:delete`),Z(null);try{I((await d(u(`/api/goals/${encodeURIComponent(N.id)}/checklist/${encodeURIComponent(e)}`),{method:`DELETE`})).goal),await Q(N.id)}catch(e){Z(e instanceof Error?e.message:r.errors.deleteChecklist)}finally{X(null)}}},nn=async e=>{if(e.preventDefault(),!N)return;let t=We.trim();if(t){X(`evidence:add`),Z(null);try{let e=await d(u(`/api/goals/${encodeURIComponent(N.id)}/evidence`),{method:`POST`,body:JSON.stringify({kind:He,title:t,summary:Ke.trim()||void 0,uri:Je.trim()||void 0,requirementId:Xe||void 0})});Ae(t=>[e.evidence,...t]),I(await Ie(N.id)),Ge(``),qe(``),Ye(``),await Q(N.id)}catch(e){Z(e instanceof Error?e.message:r.errors.addEvidence)}finally{X(null)}}},rn=async e=>{if(N){X(`requirement:${e}:review`),Z(null);try{await d(u(`/api/goals/${encodeURIComponent(N.id)}/evidence-requirements/${encodeURIComponent(e)}/review`),{method:`POST`,body:JSON.stringify({modelRef:N.judgeModelRef})}),I(await Ie(N.id)),await Q(N.id)}catch(e){Z(e instanceof Error?e.message:r.errors.addEvidence)}finally{X(null)}}},an=async e=>{if(N){X(`requirement:${e}:approve`),Z(null);try{await d(u(`/api/goals/${encodeURIComponent(N.id)}/evidence-requirements/${encodeURIComponent(e)}/approve`),{method:`POST`,body:JSON.stringify({})}),I(await Ie(N.id)),await Q(N.id)}catch(e){Z(e instanceof Error?e.message:r.errors.addEvidence)}finally{X(null)}}},on=async e=>{if(!N||!e.summary)return;Z(null);let t=l(n).automations,r=await d(u(`/api/goals/${encodeURIComponent(N.id)}/evidence`),{method:`POST`,body:JSON.stringify({kind:`message`,title:ae(t.feedback.insightEvidenceTitle,{name:e.automationName}),summary:e.summary,data:{source:`automation`,automationRunId:e.id,automationId:e.automationId,automationName:e.automationName,sessionKey:e.sessionKey,workflowRunId:e.workflowRunId}})});Ae(e=>[r.evidence,...e]),await Q(N.id)},sn=N?.checklist.filter(e=>e.status===`completed`||e.status===`impossible`).length??0,cn=N?.checklist.length??0,ln=(0,H.useMemo)(()=>{let e=new Set;for(let t of Ee){let n=me(pe(t),`automationRunId`);n&&e.add(n)}return e},[Ee]),un=(0,H.useMemo)(()=>{let e=new Set;return Ee.filter(t=>{if(t.title.trim().toLowerCase().startsWith(`missing evidence:`))return!1;let n=`${t.kind}\u0000${t.title.trim()}\u0000${t.summary?.trim()??``}`;return e.has(n)?!1:(e.add(n),!0)})},[Ee]),dn=K.filter(e=>e.status===`failed`||e.status===`timeout`||e.status===`cancelled`),$=B[0],fn=we(w.get(`timeline`))?w.get(`timeline`):`all`,pn=fn===`all`?Me:Me.filter(e=>e.kind===fn),mn=K.filter(e=>e.status===`queued`||e.status===`running`),hn=N?ke(N,$,r):null,gn=N?.status===`done`&&!hn?.needsReview,_n=Y!=null||N?.status===`archived`||gn,vn=(0,H.useMemo)(()=>N?(0,U.jsxs)(U.Fragment,{children:[N.activeSessionKey?(0,U.jsxs)(L,{type:`button`,variant:`secondary`,className:`h-9 gap-2 rounded-lg px-2.5 md:px-3`,"aria-label":r.chat,onClick:()=>t(`/chat/${encodeURIComponent(N.activeSessionKey)}`),children:[(0,U.jsx)(S,{className:`size-4`,"aria-hidden":!0}),(0,U.jsx)(`span`,{className:`hidden md:inline`,children:r.chat})]}):null,(0,U.jsxs)(L,{type:`button`,variant:`ghost`,className:`h-9 gap-2 rounded-lg px-2.5 md:px-3`,"aria-label":r.archive,disabled:Y!=null||N.status===`archived`,onClick:()=>{window.confirm(r.archiveConfirm)&&Jt(`archive`)},children:[(0,U.jsx)(oe,{className:`size-4`,"aria-hidden":!0}),(0,U.jsx)(`span`,{className:`hidden md:inline`,children:r.archive})]})]}):null,[Y,N,t,r]);(0,H.useLayoutEffect)(()=>(x({startExtra:(0,U.jsx)(o,{to:Vt,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":r.back,children:(0,U.jsx)(P,{className:`size-4`,"aria-hidden":!0})}),main:(0,U.jsxs)(`div`,{className:`min-w-0`,children:[Rt?(0,U.jsx)(k,{className:`h-5 w-48 max-w-full`}):(0,U.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:N?.title??r.notFound}),N?(0,U.jsxs)(`p`,{className:`truncate text-xs text-fg-muted`,children:[hn?.title??Te(N.status,r),` · `,q(r.agent,{agentId:N.agentId})]}):null]}),end:vn}),()=>C()),[Vt,C,N,vn,Rt,x,hn?.title,r]);let yn=e=>{let t=new URLSearchParams(w);e===`all`?t.delete(`timeline`):t.set(`timeline`,e),D(t,{replace:!0})};return(0,U.jsx)(`main`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto bg-surface-panel`,children:(0,U.jsxs)(`div`,{className:`flex w-full flex-1 flex-col gap-4 px-3 py-5 sm:px-5 xl:px-6`,children:[Bt?(0,U.jsx)(`p`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:Bt}):null,!Rt&&!N?(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.notFound}):null,Rt?(0,U.jsx)(ue,{}):N?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(je,{goal:N,latestRun:$,done:sn,total:cn,evidence:Ee,language:n,t:r,busy:Y,primaryActionDisabled:_n,onContinue:()=>void Ut(),onOpenChat:()=>N.activeSessionKey&&t(`/chat/${encodeURIComponent(N.activeSessionKey)}`),onPause:()=>void Jt(`pause`),onConfigureOutcome:()=>document.getElementById(`goal-outcome-metric`)?.scrollIntoView({behavior:`smooth`,block:`center`}),onReviewEvidence:()=>document.getElementById(`goal-verification`)?.scrollIntoView({behavior:`smooth`,block:`start`})}),(0,U.jsxs)(`section`,{id:`goal-outcome-metric`,className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,U.jsx)(_,{className:`size-4 text-accent`,"aria-hidden":!0}),r.outcomeMetric.title]}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.outcomeMetric.hint})]}),N.contract?.outcomeMetric?(0,U.jsx)(`span`,{className:c(`rounded-full border px-2 py-0.5 text-xs font-medium`,Oe(N.contract.outcomeMetric)?`border-success/30 bg-success-soft text-success`:`border-amber-500/30 bg-amber-500/10 text-amber-800 dark:text-amber-200`),children:Oe(N.contract.outcomeMetric)?r.outcomeMetric.achieved:r.outcomeMetric.notAchieved}):null]}),(0,U.jsxs)(`form`,{className:`mt-4 grid gap-3`,onSubmit:Kt,children:[(0,U.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-[minmax(12rem,1.4fr)_repeat(3,minmax(7rem,0.7fr))]`,children:[(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.outcomeMetric.name,(0,U.jsx)(`input`,{value:St,onChange:e=>Ct(e.target.value),className:G,placeholder:r.outcomeMetric.namePlaceholder})]}),(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.outcomeMetric.baseline,(0,U.jsx)(`input`,{value:wt,onChange:e=>Tt(e.target.value),className:G,type:`number`,step:`any`,inputMode:`decimal`})]}),(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.outcomeMetric.current,(0,U.jsx)(`input`,{value:Ot,onChange:e=>kt(e.target.value),className:G,type:`number`,step:`any`,inputMode:`decimal`})]}),(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.outcomeMetric.target,(0,U.jsx)(`input`,{value:Et,onChange:e=>Dt(e.target.value),className:G,type:`number`,step:`any`,inputMode:`decimal`})]})]}),(0,U.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-[10rem_minmax(0,1fr)_auto] md:items-end`,children:[(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.outcomeMetric.unit,(0,U.jsx)(`input`,{value:At,onChange:e=>jt(e.target.value),className:G,placeholder:r.outcomeMetric.unitPlaceholder})]}),(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.outcomeMetric.source,(0,U.jsx)(`input`,{value:Mt,onChange:e=>Nt(e.target.value),className:G,placeholder:r.outcomeMetric.sourcePlaceholder})]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[N.contract?.outcomeMetric?(0,U.jsx)(L,{type:`button`,variant:`ghost`,className:`h-9`,disabled:Y!=null,onClick:()=>void qt(),children:r.outcomeMetric.clear}):null,(0,U.jsx)(L,{type:`submit`,variant:`secondary`,className:`h-9`,disabled:Y!=null||!St.trim()||J(wt)==null||J(Et)==null,children:r.outcomeMetric.save})]})]})]})]}),(0,U.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,U.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r.goalBrief}),N.description?(0,U.jsx)(`p`,{className:`mt-3 whitespace-pre-wrap break-words text-sm text-fg-muted`,children:N.description}):null,N.contract?(0,U.jsxs)(`div`,{className:`mt-3 rounded-md border border-edge-subtle bg-surface-muted/40 px-3 py-3`,children:[(0,U.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:r.goalContract}),(0,U.jsx)(`p`,{className:`mt-1 break-words text-sm text-fg`,children:N.contract.objective}),N.contract.scopeBoundary?(0,U.jsxs)(`div`,{className:`mt-3`,children:[(0,U.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:r.scopeBoundary}),(0,U.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap break-words text-sm text-fg-muted`,children:N.contract.scopeBoundary})]}):null,N.contract.evidencePlan.length?(0,U.jsxs)(`div`,{className:`mt-3`,children:[(0,U.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:r.completionEvidence}),(0,U.jsx)(`ul`,{className:`mt-1 grid gap-1 text-sm text-fg-muted`,children:N.contract.evidencePlan.map(e=>(0,U.jsxs)(`li`,{children:[`• `,e]},e))})]}):null,(0,U.jsxs)(`details`,{className:`mt-3 rounded-md bg-surface-base/70 px-3 py-2`,children:[(0,U.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:r.editContract}),(0,U.jsxs)(`form`,{className:`mt-3 grid gap-3`,onSubmit:Gt,children:[(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.contractObjective,(0,U.jsx)(`textarea`,{value:mt,onChange:e=>ht(e.target.value),name:`contractObjective`,autoComplete:`off`,className:c(G,`resize-y`),rows:2,placeholder:r.contractObjectivePlaceholder})]}),(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.scopeBoundary,(0,U.jsx)(`textarea`,{value:gt,onChange:e=>_t(e.target.value),name:`contractScopeBoundary`,autoComplete:`off`,className:c(G,`resize-y`),rows:2,placeholder:r.scopeBoundaryPlaceholder})]}),(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.acceptanceCriteria,(0,U.jsx)(`textarea`,{value:vt,onChange:e=>yt(e.target.value),name:`contractCriteria`,autoComplete:`off`,className:c(G,`resize-y`),rows:3,placeholder:r.contractLinesHint})]}),(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.completionEvidence,(0,U.jsx)(`textarea`,{value:bt,onChange:e=>xt(e.target.value),name:`contractEvidencePlan`,autoComplete:`off`,className:c(G,`resize-y`),rows:3,placeholder:r.contractLinesHint})]}),(0,U.jsx)(L,{type:`submit`,variant:`secondary`,className:`h-9 w-fit`,disabled:Y!=null||!mt.trim(),children:r.saveContract})]})]})]}):null]}),(0,U.jsxs)(`section`,{className:`grid gap-4 xl:grid-cols-[minmax(0,1fr)_22rem]`,children:[(0,U.jsxs)(`div`,{className:`grid min-w-0 gap-4`,children:[(0,U.jsxs)(`section`,{id:`goal-verification`,className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,U.jsx)(b,{className:`size-4 text-accent`,"aria-hidden":!0}),r.acceptance]}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.acceptanceHint})]}),(0,U.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[sn,`/`,cn]})]}),$?(0,U.jsxs)(`div`,{className:`mt-3 rounded-md bg-surface-muted/40 px-3 py-2`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 text-xs text-fg-muted`,children:[(0,U.jsx)(`span`,{children:q(r.latestJudgement,{status:Te($.verdict??$.status,r)})}),(0,U.jsx)(`time`,{children:be($.finishedAt??$.startedAt,n,r)})]}),$.reason?(0,U.jsx)(`p`,{className:`mt-1 break-words text-sm text-fg`,children:$.reason}):null,$.nextAction?(0,U.jsx)(`p`,{className:`mt-1 break-words text-xs text-fg-muted`,children:q(r.latestNext,{next:$.nextAction})}):null]}):null,(0,U.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,U.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,U.jsx)(b,{className:`size-4 text-accent`,"aria-hidden":!0}),r.checklist]}),(0,U.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[sn,`/`,cn]})]}),(0,U.jsxs)(`form`,{className:`mb-3 flex flex-col gap-2 sm:flex-row`,onSubmit:$t,children:[(0,U.jsx)(`input`,{value:Pe,onChange:e=>Ve(e.target.value),name:`checklistText`,"aria-label":r.addAcceptancePlaceholder,autoComplete:`off`,placeholder:r.addAcceptancePlaceholder,className:c(G,`flex-1`)}),(0,U.jsxs)(L,{type:`submit`,variant:`secondary`,className:`h-9 gap-2`,disabled:Y!=null||!Pe.trim(),children:[(0,U.jsx)(F,{className:`size-4`,"aria-hidden":!0}),r.add]})]}),N.checklist.length?(0,U.jsx)(`ul`,{className:`space-y-2 text-sm`,children:N.checklist.map(e=>(0,U.jsx)(`li`,{className:`rounded-md bg-surface-muted/40 px-2.5 py-2`,children:(0,U.jsxs)(`div`,{className:`flex flex-wrap items-start gap-2`,children:[(0,U.jsx)(`span`,{className:`mt-1 w-5 shrink-0 text-center text-fg-muted`,children:Ce(e.status)}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`p`,{className:`break-words text-fg`,children:e.text}),e.evidenceSummary?(0,U.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.evidenceSummary}):null]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,U.jsx)(L,{type:`button`,variant:`ghost`,className:`size-8 p-0`,title:r.markPending,"aria-label":r.markPending,disabled:Y!=null||e.status===`pending`,onClick:()=>void en(e.id,`pending`),children:(0,U.jsx)(T,{className:`size-4`,"aria-hidden":!0})}),(0,U.jsx)(L,{type:`button`,variant:`ghost`,className:`size-8 p-0`,title:r.markCompleted,"aria-label":r.markCompleted,disabled:Y!=null||e.status===`completed`,onClick:()=>void en(e.id,`completed`),children:(0,U.jsx)(te,{className:`size-4`,"aria-hidden":!0})}),(0,U.jsx)(L,{type:`button`,variant:`ghost`,className:`size-8 p-0`,title:r.markImpossible,"aria-label":r.markImpossible,disabled:Y!=null||e.status===`impossible`,onClick:()=>void en(e.id,`impossible`),children:(0,U.jsx)(E,{className:`size-4`,"aria-hidden":!0})}),(0,U.jsx)(L,{type:`button`,variant:`ghost`,className:`size-8 p-0 text-destructive hover:text-destructive`,title:r.deleteChecklistItem,"aria-label":r.deleteChecklistItem,disabled:Y!=null,onClick:()=>void tn(e.id),children:(0,U.jsx)(re,{className:`size-4`,"aria-hidden":!0})})]})]})},e.id))}):(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.noChecklist}),(0,U.jsxs)(`div`,{className:`mt-4 border-t border-edge pt-4`,children:[(0,U.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,U.jsx)(h,{className:`size-4 text-accent`,"aria-hidden":!0}),r.evidence]}),N.evidenceRequirements.length?(0,U.jsxs)(`div`,{className:`mb-4 grid gap-2 rounded-md border border-edge-subtle bg-surface-muted/40 p-3`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,U.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:r.evidenceRequirements}),(0,U.jsx)(`span`,{className:`text-xs text-fg-muted`,children:q(r.evidenceRequirementProgress,{approved:N.evidenceRequirements.filter(e=>e.status===`approved`).length,total:N.evidenceRequirements.length})})]}),N.evidenceRequirements.map(e=>(0,U.jsx)(`div`,{className:`rounded-md bg-surface-base px-2.5 py-2`,children:(0,U.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`p`,{className:`break-words text-sm text-fg`,children:e.text}),(0,U.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[q(r.linkedEvidenceCount,{count:e.evidenceIds.length}),` · `,r.evidenceRequirementStatuses[e.status]]}),e.reviewReason?(0,U.jsx)(`p`,{className:`mt-1 break-words text-xs text-fg-muted`,children:e.reviewReason}):null]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-1.5`,children:[(0,U.jsx)(L,{type:`button`,variant:`ghost`,className:`h-7 text-xs`,disabled:Y!=null||e.evidenceIds.length===0,onClick:()=>void rn(e.id),children:r.reviewEvidence}),(0,U.jsx)(L,{type:`button`,variant:`secondary`,className:`h-7 text-xs`,disabled:Y!=null||e.evidenceIds.length===0||e.status===`approved`,onClick:()=>void an(e.id),children:r.approveEvidence})]})]})},e.id))]}):null,(0,U.jsxs)(`form`,{className:`mb-3 grid gap-2`,onSubmit:nn,children:[(0,U.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[9rem_minmax(0,1fr)]`,children:[(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.kind,(0,U.jsx)(v,{value:He,onChange:e=>Ue(e.target.value),className:G,name:`evidenceKind`,children:de.map(e=>(0,U.jsx)(V,{value:e,children:De(e,r)},e))})]}),(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.title,(0,U.jsx)(`input`,{value:We,onChange:e=>Ge(e.target.value),name:`evidenceTitle`,autoComplete:`off`,placeholder:r.evidenceTitlePlaceholder,className:G})]})]}),N.evidenceRequirements.length?(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.provesRequirement,(0,U.jsx)(v,{value:Xe,onChange:e=>Ze(e.target.value),name:`evidenceRequirement`,className:G,children:N.evidenceRequirements.map(e=>(0,U.jsx)(V,{value:e.id,children:e.text},e.id))})]}):null,(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.uriOrPath,(0,U.jsx)(`input`,{value:Je,onChange:e=>Ye(e.target.value),name:`evidenceUri`,autoComplete:`off`,placeholder:r.uriOrPathPlaceholder,className:G})]}),(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.summary,(0,U.jsx)(`textarea`,{value:Ke,onChange:e=>qe(e.target.value),name:`evidenceSummary`,autoComplete:`off`,placeholder:r.summaryPlaceholder,rows:3,className:c(G,`resize-y`)})]}),(0,U.jsxs)(L,{type:`submit`,variant:`secondary`,className:`h-9 w-fit gap-2`,disabled:Y!=null||!We.trim(),children:[(0,U.jsx)(F,{className:`size-4`,"aria-hidden":!0}),r.addEvidence]})]}),un.length?(0,U.jsx)(`ul`,{className:`space-y-2 text-sm`,children:un.slice(0,6).map(e=>(0,U.jsx)(he,{item:e,language:n,t:r},e.id))}):(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.noEvidence})]})]}),(0,U.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,U.jsx)(ie,{className:`size-4 text-accent`,"aria-hidden":!0}),r.timeline]}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.timelineHint})]}),(0,U.jsxs)(L,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5`,onClick:()=>void Ht(),children:[(0,U.jsx)(j,{className:`size-3.5`,"aria-hidden":!0}),r.refresh]})]}),B.length?(0,U.jsx)(`ol`,{className:`mt-4 grid gap-2`,children:B.slice(0,6).map((e,t)=>(0,U.jsx)(`li`,{children:(0,U.jsxs)(`details`,{open:t===0&&e.verdict!==`done`,className:`group rounded-lg border border-edge-subtle bg-surface-muted/40 px-3 py-2`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 marker:hidden`,children:[(0,U.jsxs)(`span`,{className:`min-w-0`,children:[(0,U.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:q(r.executionProgress.runTitle,{number:B.length-t})}),(0,U.jsx)(`time`,{className:`mt-0.5 block text-xs text-fg-muted`,children:be(e.finishedAt??e.startedAt,n,r)})]}),(0,U.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 text-xs text-fg-muted`,children:[Te(e.verdict??e.status,r),(0,U.jsx)(p,{className:`size-4 transition-transform group-open:rotate-90`,"aria-hidden":!0})]})]}),(0,U.jsxs)(`div`,{className:`mt-3 border-t border-edge-subtle pt-3`,children:[e.reason?(0,U.jsx)(`p`,{className:`text-sm text-fg`,children:e.reason}):null,e.assistantPreview?(0,U.jsx)(`p`,{className:`mt-2 line-clamp-5 whitespace-pre-wrap text-xs text-fg-muted`,children:e.assistantPreview}):null,e.nextAction?(0,U.jsxs)(`div`,{className:`mt-3 rounded-md bg-surface-base px-3 py-2`,children:[(0,U.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:r.nextAction}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:e.nextAction})]}):null]})]})},e.id))}):(0,U.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:r.executionProgress.noRuns}),(0,U.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-3`,children:[(0,U.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted hover:text-fg`,children:q(r.executionProgress.systemActivity,{count:Me.length})}),(0,U.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[`all`,`goal_run`,`workflow_run`,`evidence`,`queue`,`event`].map(e=>(0,U.jsx)(`button`,{type:`button`,className:c(`rounded-md border px-2.5 py-1 text-xs font-medium`,fn===e?`border-accent bg-accent-soft text-accent-fg`:`border-edge bg-surface-panel text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>yn(e),children:r.timelineFilters[e]},e))}),pn.length?(0,U.jsx)(`ul`,{className:`mt-3 space-y-2 text-sm`,children:pn.map(e=>(0,U.jsx)(`li`,{className:`rounded-md bg-surface-muted/50 px-2.5 py-2`,children:(0,U.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-2`,children:[(0,U.jsx)(ve(e.kind),{className:`mt-0.5 size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[(0,U.jsx)(`span`,{children:r.timelineFilters[e.kind]}),e.status?(0,U.jsx)(`span`,{children:Te(e.status,r)}):null]}),(0,U.jsx)(`p`,{className:`mt-1 break-words font-medium text-fg`,children:e.title}),e.summary?(0,U.jsx)(`p`,{className:`mt-1 line-clamp-3 break-words text-xs text-fg-muted`,children:e.summary}):null]})]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1 text-xs text-fg-muted`,children:[(0,U.jsx)(`time`,{children:be(e.createdAt,n,r)}),e.link?.type===`chat`?(0,U.jsxs)(L,{type:`button`,variant:`ghost`,className:`h-7 gap-1.5`,onClick:()=>t(`/chat/${encodeURIComponent(e.link.value)}`),children:[(0,U.jsx)(S,{className:`size-3.5`,"aria-hidden":!0}),r.chat]}):null,e.link?.type===`workflow_run`?(0,U.jsxs)(L,{type:`button`,variant:`ghost`,className:`h-7 gap-1.5`,onClick:()=>t(`/workflows?run=${encodeURIComponent(e.link.value)}`),children:[(0,U.jsx)(S,{className:`size-3.5`,"aria-hidden":!0}),r.run]}):null]})]})},e.id))}):(0,U.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:r.noTimeline})]})]})]}),(0,U.jsxs)(`aside`,{className:`grid h-fit gap-4`,children:[(0,U.jsxs)(`section`,{className:`rounded-lg border border-accent/25 bg-accent-soft/30 p-4`,children:[(0,U.jsx)(`p`,{className:`text-xs font-medium text-accent-fg`,children:r.actionRail.nextTitle}),(0,U.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap break-words text-sm font-medium text-fg`,children:gn?r.progressPanel.doneFallback:N.nextAction||r.noNextAction}),(0,U.jsxs)(L,{type:`button`,variant:`primary`,className:`mt-3 h-9 w-full gap-2`,disabled:Y!=null||N.status===`archived`,onClick:()=>{if(gn){window.confirm(r.archiveConfirm)&&Jt(`archive`);return}Ut()},children:[gn?(0,U.jsx)(oe,{className:`size-4`,"aria-hidden":!0}):(0,U.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),gn?r.archive:r.actionRail.continueAction]})]}),N.evidenceRequirements.some(e=>e.status!==`approved`)||N.contract?.outcomeMetric&&!Oe(N.contract.outcomeMetric)||$?.verdict===`continue`?(0,U.jsxs)(`section`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 p-4`,children:[(0,U.jsx)(`h2`,{className:`text-sm font-semibold text-amber-900 dark:text-amber-100`,children:r.actionRail.needsYou}),(0,U.jsxs)(`ul`,{className:`mt-3 grid gap-2 text-sm text-amber-900 dark:text-amber-100`,children:[N.contract?.outcomeMetric&&!Oe(N.contract.outcomeMetric)?(0,U.jsxs)(`li`,{children:[`• `,r.outcomeMetric.notAchieved]}):null,N.evidenceRequirements.some(e=>e.status!==`approved`)?(0,U.jsxs)(`li`,{children:[`• `,q(r.actionRail.reviewEvidenceCount,{count:N.evidenceRequirements.filter(e=>e.status!==`approved`).length})]}):null,$?.verdict===`continue`?(0,U.jsxs)(`li`,{children:[`• `,r.actionRail.latestCheckContinue]}):null]}),(0,U.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[N.contract?.outcomeMetric&&!Oe(N.contract.outcomeMetric)?(0,U.jsx)(L,{type:`button`,variant:`secondary`,className:`h-8`,onClick:()=>document.getElementById(`goal-outcome-metric`)?.scrollIntoView({behavior:`smooth`,block:`center`}),children:r.actionRail.setOutcome}):null,N.evidenceRequirements.some(e=>e.status!==`approved`)?(0,U.jsx)(L,{type:`button`,variant:`secondary`,className:`h-8`,onClick:()=>document.getElementById(`goal-verification`)?.scrollIntoView({behavior:`smooth`,block:`start`}),children:r.actionRail.reviewEvidence}):null]})]}):null,(0,U.jsxs)(`details`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,U.jsx)(`summary`,{className:`cursor-pointer text-sm font-semibold text-fg`,children:r.actionRail.automation}),(0,U.jsxs)(`div`,{className:`mt-3 grid gap-3`,children:[(0,U.jsx)(O,{eventType:`goal.status_changed`,source:`goals`,payloadKey:`goalId`,payloadValue:N.id,onSaveInsight:on,isInsightSaved:e=>ln.has(e.id)}),(0,U.jsx)(O,{eventType:`goal.created`,source:`goals`,payloadKey:`goalId`,payloadValue:N.id,onSaveInsight:on,isInsightSaved:e=>ln.has(e.id)}),N.status===`blocked`||N.blockedReason?(0,U.jsx)(se,{title:m.goalBlockedTitle,description:m.goalBlockedDescription,prompt:q(m.goalBlockedPrompt,{title:N.title}),coverage:{eventType:`goal.status_changed`,source:`goals`,eventPayload:{goalId:N.id,status:`blocked`}}}):null]})]}),(0,U.jsxs)(`details`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,U.jsx)(`summary`,{className:`cursor-pointer text-sm font-semibold text-fg`,children:r.goalSettings}),(0,U.jsxs)(`dl`,{className:`mt-3 grid gap-2 text-sm`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsx)(`dt`,{className:`text-fg-muted`,children:r.deadline}),(0,U.jsx)(`dd`,{className:`text-right text-fg`,children:xe(N.deadlineAt,n,r)})]}),(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsx)(`dt`,{className:`text-fg-muted`,children:r.judgeModel}),(0,U.jsx)(`dd`,{className:`min-w-0 truncate text-right text-fg`,children:N.judgeModelRef||r.default})]}),(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsx)(`dt`,{className:`text-fg-muted`,children:r.created}),(0,U.jsx)(`dd`,{className:`text-right text-fg`,children:xe(N.createdAt,n,r)})]}),(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsx)(`dt`,{className:`text-fg-muted`,children:r.updated}),(0,U.jsx)(`dd`,{className:`text-right text-fg`,children:be(N.updatedAt,n,r)})]})]}),(0,U.jsxs)(`details`,{className:`mt-4 rounded-md bg-surface-muted/40 px-3 py-2`,children:[(0,U.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:r.editDetails}),(0,U.jsxs)(`form`,{className:`mt-3 grid gap-3`,onSubmit:Wt,children:[(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.title,(0,U.jsx)(`input`,{value:Qe,onChange:e=>$e(e.target.value),name:`goalTitle`,autoComplete:`off`,className:G,placeholder:`${r.title}…`})]}),(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.description,(0,U.jsx)(`textarea`,{value:et,onChange:e=>tt(e.target.value),name:`goalDescription`,autoComplete:`off`,className:c(G,`resize-y`),rows:3,placeholder:`${r.description}…`})]}),(0,U.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3 xl:grid-cols-1`,children:[(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.priority,(0,U.jsxs)(v,{value:nt,onChange:e=>rt(e.target.value),name:`goalPriority`,className:G,children:[(0,U.jsx)(V,{value:`low`,children:r.priorities.low}),(0,U.jsx)(V,{value:`normal`,children:r.priorities.normal}),(0,U.jsx)(V,{value:`high`,children:r.priorities.high})]})]}),(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.deadline,(0,U.jsx)(`input`,{value:it,onChange:e=>at(e.target.value),name:`goalDeadline`,className:G,type:`date`})]}),(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.maxTurns,(0,U.jsx)(`input`,{value:ot,onChange:e=>st(e.target.value),name:`goalMaxTurns`,className:G,type:`number`,min:1,max:500,inputMode:`numeric`,placeholder:`${r.maxTurns}…`})]})]}),(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.judgeModel,(0,U.jsx)(`input`,{value:ct,onChange:e=>lt(e.target.value),name:`goalJudgeModel`,autoComplete:`off`,className:G,placeholder:`${r.judgeModel}…`})]}),(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.nextAction,(0,U.jsx)(`textarea`,{value:ut,onChange:e=>dt(e.target.value),name:`goalNextAction`,autoComplete:`off`,className:c(G,`resize-y`),rows:2,placeholder:`${r.nextAction}…`})]}),(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.blockedReason,(0,U.jsx)(`textarea`,{value:ft,onChange:e=>pt(e.target.value),name:`goalBlockedReason`,autoComplete:`off`,className:c(G,`resize-y`),rows:2,placeholder:`${r.blockedReason}…`})]}),(0,U.jsx)(L,{type:`submit`,variant:`secondary`,className:`h-9 w-fit`,disabled:Y!=null||!Qe.trim(),children:r.saveDetails})]})]})]}),(0,U.jsxs)(`details`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 text-sm font-semibold text-fg marker:hidden`,children:[(0,U.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(R,{className:`size-4 text-accent`,"aria-hidden":!0}),r.workflow]}),mn.length?(0,U.jsx)(`span`,{className:`rounded-full border border-accent/40 bg-accent-soft px-2 py-0.5 text-xs text-accent-fg`,children:q(r.activeCount,{count:mn.length})}):null]}),(0,U.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:r.workflowHint}),ye.length?(0,U.jsx)(`div`,{className:`mt-3 grid gap-2`,children:ye.slice(0,2).map(e=>(0,U.jsxs)(`button`,{type:`button`,className:c(`min-w-0 rounded-md bg-surface-muted/40 px-2.5 py-2 text-left hover:bg-accent-soft/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,Pt===e.definitionId&&`bg-accent-soft/60 ring-1 ring-accent/30`),onClick:()=>{Ft(e.definitionId),Lt(N.nextAction||N.title)},children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.title}),(0,U.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e.score})]}),(0,U.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs text-fg-muted`,children:e.description})]},e.definitionId))}):null,(0,U.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.definition,(0,U.jsxs)(v,{value:Pt,onChange:e=>Ft(e.target.value),className:G,name:`workflowDefinition`,disabled:W.length===0,children:[W.length===0?(0,U.jsx)(V,{value:``,children:r.noWorkflows}):null,W.map(e=>(0,U.jsx)(V,{value:e.id,children:e.title||e.name},e.id))]})]}),(0,U.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.workflowGoal,(0,U.jsx)(`input`,{value:It,onChange:e=>Lt(e.target.value),name:`workflowGoal`,autoComplete:`off`,className:G,placeholder:`${r.workflowGoal}…`})]}),(0,U.jsxs)(L,{type:`button`,variant:`secondary`,className:`h-9 w-fit gap-2`,disabled:Y!=null||!Pt||N.status===`done`||N.status===`archived`,onClick:()=>void Yt(),children:[(0,U.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),r.runWorkflow]})]}),K.length?(0,U.jsxs)(`div`,{className:`mt-4 border-t border-edge pt-3`,children:[(0,U.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:r.recentWorkflowRuns}),(0,U.jsx)(`button`,{type:`button`,className:`text-xs text-fg-muted hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>yn(`workflow_run`),children:r.viewTimeline})]}),(0,U.jsx)(`ul`,{className:`grid gap-2`,children:K.slice(0,3).map(e=>{let i=e.metadata?.sessionKey,a=e.status===`queued`||e.status===`running`,o=e.status===`failed`||e.status===`timeout`||e.status===`cancelled`;return(0,U.jsxs)(`li`,{className:`rounded-md bg-surface-muted/40 px-2.5 py-2 text-sm`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 text-xs text-fg-muted`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:e.definitionId}),(0,U.jsx)(`span`,{className:c(`shrink-0 rounded-full border px-2 py-0.5`,_e(e.status)),children:Te(e.status,r)})]}),(0,U.jsx)(`p`,{className:`mt-1 truncate text-fg`,children:e.title}),(0,U.jsx)(`time`,{className:`mt-1 block text-xs text-fg-muted`,children:be(e.completedAtMs??e.startedAtMs??e.createdAtMs,n,r)}),(0,U.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[i?(0,U.jsxs)(L,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5`,onClick:()=>t(`/chat/${encodeURIComponent(i)}`),children:[(0,U.jsx)(S,{className:`size-3.5`,"aria-hidden":!0}),r.chat]}):null,a?(0,U.jsxs)(L,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 text-destructive hover:text-destructive`,disabled:Y!=null,onClick:()=>void Zt(e),children:[(0,U.jsx)(E,{className:`size-3.5`,"aria-hidden":!0}),r.cancel]}):null,o?(0,U.jsxs)(L,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5`,disabled:Y!=null,onClick:()=>void Qt(e),children:[(0,U.jsx)(j,{className:`size-3.5`,"aria-hidden":!0}),r.retry]}):null]})]},e.id)})})]}):null,dn.length?(0,U.jsxs)(`div`,{className:`mt-4 rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-amber-800 dark:text-amber-200`,children:r.recoveryNeeded}),(0,U.jsx)(`span`,{className:`text-xs text-amber-700 dark:text-amber-300`,children:q(r.failedCount,{count:dn.length})})]}),(0,U.jsx)(`ul`,{className:`mt-2 grid gap-2`,children:dn.slice(0,3).map(e=>(0,U.jsxs)(`li`,{className:`grid gap-2 text-sm`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`p`,{className:`truncate text-fg`,children:e.title}),(0,U.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[e.definitionId,` · `,Te(e.status,r)]})]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[(0,U.jsxs)(L,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5`,onClick:()=>t(`/workflows?run=${encodeURIComponent(e.id)}`),children:[(0,U.jsx)(S,{className:`size-3.5`,"aria-hidden":!0}),r.run]}),(0,U.jsxs)(L,{type:`button`,variant:`secondary`,className:`h-8 gap-1.5`,disabled:Y!=null,onClick:()=>void Qt(e),children:[(0,U.jsx)(j,{className:`size-3.5`,"aria-hidden":!0}),r.retry]})]})]},e.id))})]}):null]})]})]})]}):null]})})}export{Ve as GoalDetailPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as e,i as t}from"./locale-store-
|
|
1
|
+
import{d as e,i as t}from"./locale-store-BneNAR8R.js";import{ro as n}from"./index-CH7XN6KY.js";var r={maxTurns:20,judgeModelRef:``,checklistMode:!0,checklistDecomposePolicy:`empty_only`,maxConsecutiveParseFailures:3,judgeTimeoutSec:60,checklistHistoryChars:24e3,notifications:{enabled:!1,includeLinkedSessions:!0,channels:[`telegram`,`weixin`],events:[`done`,`blocked`,`needs_input`,`queue_failed`,`queue_retry`],targets:[]}};function i(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function a(e){let t=i(e)?e:{},n=i(t.goals)?t.goals:{},a=i(n.notifications)?n.notifications:{};return{maxTurns:typeof n.maxTurns==`number`&&Number.isFinite(n.maxTurns)?Math.max(1,Math.min(500,Math.floor(n.maxTurns))):r.maxTurns,judgeModelRef:typeof n.judgeModelRef==`string`?n.judgeModelRef:``,checklistMode:n.checklistMode!==!1,checklistDecomposePolicy:n.checklistDecomposePolicy===`supplement_existing`?`supplement_existing`:r.checklistDecomposePolicy,maxConsecutiveParseFailures:typeof n.maxConsecutiveParseFailures==`number`&&Number.isFinite(n.maxConsecutiveParseFailures)?Math.max(1,Math.min(20,Math.floor(n.maxConsecutiveParseFailures))):r.maxConsecutiveParseFailures,judgeTimeoutSec:typeof n.judgeTimeoutMs==`number`&&Number.isFinite(n.judgeTimeoutMs)?Math.max(5,Math.min(120,Math.round(n.judgeTimeoutMs/1e3))):r.judgeTimeoutSec,checklistHistoryChars:typeof n.checklistHistoryChars==`number`&&Number.isFinite(n.checklistHistoryChars)?Math.max(0,Math.min(1e5,Math.floor(n.checklistHistoryChars))):r.checklistHistoryChars,notifications:{enabled:a.enabled===!0,includeLinkedSessions:a.includeLinkedSessions!==!1,channels:Array.isArray(a.channels)?a.channels.filter(e=>typeof e==`string`&&e.trim().length>0):r.notifications.channels,events:Array.isArray(a.events)?a.events.filter(e=>typeof e==`string`&&e.trim().length>0):r.notifications.events,targets:Array.isArray(a.targets)?a.targets.filter(i).map(e=>({channel:typeof e.channel==`string`?e.channel:``,chatId:typeof e.chatId==`string`?e.chatId:``,accountId:typeof e.accountId==`string`?e.accountId:void 0,threadId:typeof e.threadId==`string`||typeof e.threadId==`number`?e.threadId:void 0,silent:e.silent===!0,events:Array.isArray(e.events)?e.events.filter(e=>typeof e==`string`&&e.trim().length>0):void 0})).filter(e=>e.channel.trim()&&e.chatId.trim()):[]}}}async function o(r){let i=r.notifications.targets.map(e=>({...e,chatId:e.chatId.trim(),channel:e.channel.trim(),accountId:e.accountId?.trim()||void 0})).filter(e=>e.channel&&e.chatId&&e.chatId!==`__custom__`);await t(e(`/api/config`),{method:`PATCH`,body:JSON.stringify({goals:{maxTurns:r.maxTurns,...r.judgeModelRef.trim()?{judgeModelRef:r.judgeModelRef.trim()}:{judgeModelRef:null},checklistMode:r.checklistMode,checklistDecomposePolicy:r.checklistDecomposePolicy,maxConsecutiveParseFailures:r.maxConsecutiveParseFailures,judgeTimeoutMs:r.judgeTimeoutSec*1e3,checklistHistoryChars:r.checklistHistoryChars,notifications:{enabled:r.notifications.enabled,includeLinkedSessions:r.notifications.includeLinkedSessions,channels:r.notifications.channels,events:r.notifications.events,targets:i}}})}),n()}export{o as n,a as t};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{l as i,t as a}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as o}from"./cn-BQ_8x0bT.js";import{t as s}from"./circle-alert-RzVebuX2.js";import{t as c}from"./messages-t1yPaVCt.js";import{d as l,i as u,n as d}from"./locale-store-BneNAR8R.js";import{Bl as f,Fo as p,Go as m,Io as h,Kc as g,Mo as _,No as v,Ol as y,Po as b,Wr as x,Xl as S,Yl as C,Zl as w,Zn as T,ao as E,bu as D,hc as O,hs as k,jo as A,ko as j,ls as M,no as N,oc as P,qo as F,rl as I,sa as L,sl as R,tc as z,ys as ee,yu as B}from"./index-CH7XN6KY.js";import{t as te}from"./page-tabs-DMlQERNg.js";import{t as ne}from"./goals-config-api-D88opgcs.js";import{n as re,t as ie}from"./goal-create-dialog-DRVRLc5Z.js";var V=e(t(),1),ae=n(),H=[`active`,`paused`,`blocked`,`needs_input`,`done`,`archived`],oe=[`attention`,`running`,`ready`,`later`];function se(e){let t=e.checklist.length;return{done:e.checklist.filter(e=>e.status===`completed`||e.status===`impossible`).length,total:t}}function U(e){return e.nextRunAt??e.finishedAt??e.startedAt??e.enqueuedAt}function ce(e){let t=new Map;for(let n of e){let e=t.get(n.goalId);(!e||U(n)>U(e))&&t.set(n.goalId,n)}return t}function W(e){return e===`running`||e===`queued`||e===`retry_waiting`}function le(e,t){return e.status===`done`||e.status===`archived`?null:e.status===`blocked`||e.status===`needs_input`||t?.status===`failed`?`attention`:t&&W(t.status)?`running`:e.status===`active`?`ready`:e.status===`paused`?`later`:null}function G(e){return e===`high`?3:e===`normal`?2:1}function ue(e,t,n){let r=n.get(e.id),i=n.get(t.id),a=r&&W(r.status)?1:0,o=i&&W(i.status)?1:0;if(a!==o)return o-a;let s=G(t.priority)-G(e.priority);if(s!==0)return s;let c=e.deadlineAt??1/0,l=t.deadlineAt??1/0;return c===l?t.updatedAt-e.updatedAt:c-l}function de(e,t){let n=t.trim().toLowerCase();return n?[e.title,e.description,e.nextAction,e.blockedReason,e.latestRun?.reason,e.agentId,...e.checklist.map(e=>e.text)].filter(Boolean).join(`
|
|
2
|
+
`).toLowerCase().includes(n):!0}function fe(e,t){let n={attention:0,running:0,ready:0,later:0,history:0};for(let r of e){if(r.status===`done`||r.status===`archived`){n.history+=1;continue}let e=le(r,t.get(r.id));e&&(n[e]+=1)}return n}var K=r();function q(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function pe(e,t){return new Intl.DateTimeFormat(t===`zh`?`zh-CN`:`en-US`,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(e))}function J(e,t){let n=Math.round((e-Date.now())/1e3),r=Math.abs(n),i=new Intl.RelativeTimeFormat(t===`zh`?`zh-CN`:`en-US`,{numeric:`auto`});return r<60?i.format(n,`second`):r<3600?i.format(Math.round(n/60),`minute`):r<86400?i.format(Math.round(n/3600),`hour`):r<2592e3?i.format(Math.round(n/86400),`day`):pe(e,t)}function me(e,t){return t.statuses[e]??e}function he(e,t,n){return e.status===`blocked`?{label:n.workbench.status.blocked,tone:`attention`}:e.status===`needs_input`?{label:n.workbench.status.needsInput,tone:`attention`}:t?.status===`failed`?{label:n.workbench.status.executionFailed,tone:`attention`}:t?.status===`running`?{label:n.workbench.status.running,tone:`running`}:t?.status===`queued`?{label:n.workbench.status.queued,tone:`running`}:t?.status===`retry_waiting`?{label:n.workbench.status.retryWaiting,tone:`running`}:e.status===`active`?{label:n.workbench.status.ready,tone:`ready`}:e.status===`paused`?{label:n.workbench.status.paused,tone:`neutral`}:e.status===`done`?{label:n.workbench.status.done,tone:`done`}:{label:n.workbench.status.archived,tone:`neutral`}}function ge(e){return e===`attention`?`bg-warning-soft text-amber-800 dark:text-amber-200`:e===`running`?`bg-accent-soft text-accent-fg`:e===`ready`?`bg-surface-active text-fg`:e===`done`?`bg-success-soft text-emerald-800 dark:text-emerald-200`:`bg-surface-hover text-fg-muted`}function _e(e,t){return e.status===`done`?`review`:e.status===`archived`?`unarchive`:e.status===`blocked`||e.status===`needs_input`?`details`:t?.status===`running`||t?.status===`queued`||t?.status===`retry_waiting`?`execution`:`continue`}function Y(e,t){return e===`details`?t.workbench.actions.handle:e===`review`?t.workbench.actions.review:e===`execution`?t.workbench.actions.viewExecution:e===`continue`?t.workbench.actions.continueExecution:t.actions[e]}function X(e){return e===`details`?s:e===`review`?g:e===`execution`?f:e===`pause`?S:e===`archive`?B:e===`unarchive`?D:e===`reopen`?P:e===`complete`?w:C}function ve(e,t,n){return e.status===`needs_input`?e.blockedReason||e.nextAction||n.workbench.row.inputNeeded:e.status===`blocked`?e.blockedReason||n.workbench.row.reviewBlocker:t?.status===`failed`?t.error||n.workbench.row.executionFailed:t&&W(t.status)?e.nextAction||t.userTurn?.text||n.workbench.row.executionInProgress:e.status===`paused`?e.blockedReason&&e.blockedReason!==`user-paused`?e.blockedReason:n.workbench.row.pausedByUser:e.status===`done`?n.workbench.row.completedReview:e.status===`archived`?n.workbench.row.archived:e.nextAction||n.noNextAction}function Z(e,t,n){if(!e||W(e.status))return null;let r=J(U(e),t);return e.status===`succeeded`?q(n.workbench.row.lastSucceeded,{time:r}):e.status===`failed`?q(n.workbench.row.lastFailed,{time:r}):q(n.workbench.row.lastFinished,{time:r})}function Q(e){return e===`completed`?`✓`:e===`impossible`?`!`:`○`}function ye(e){return e===`archive`?`unarchive`:e===`unarchive`?`archive`:e===`complete`?`reopen`:`complete`}async function be(){return(await u(l(`/api/goals?${new URLSearchParams({status:H.join(`,`),limit:`500`}).toString()}`))).goals}async function xe(){return(await u(l(`/api/goals/queue`))).queue??[]}async function Se(e){return(await u(l(`/api/goals`),{method:`POST`,body:JSON.stringify({...e,source:`api`})})).goal}async function Ce(e,t){let n=await u(l(`/api/goals/contract/draft`),{method:`POST`,body:JSON.stringify({title:e.title,context:e.description,criteria:e.checklist,judgeModelRef:e.judgeModelRef||void 0,uiLocale:t})});return{objective:n.contract.objective??e.objective,scopeBoundary:n.contract.scopeBoundary??e.scopeBoundary,evidencePlan:n.contract.evidencePlan??e.evidencePlan,checklist:n.contract.criteria??e.checklist}}async function we(e,t){await u(l(`/api/goals/${encodeURIComponent(e)}/${t}`),{method:`POST`,body:JSON.stringify({})})}async function Te(e){return(await u(l(`/api/goals/${encodeURIComponent(e)}/continue`),{method:`POST`,body:JSON.stringify({})})).sessionKey}function Ee(e){let t=(0,ae.c)(51),{goal:n,queueItem:r,intent:i,t:s,busy:c,onAction:l}=e,u;t[0]===i?u=t[1]:(u=X(i),t[0]=i,t[1]=u);let d=u,f=c===`${n.id}:${i}`,p=i===`continue`?`primary`:`secondary`;if(i===`details`||i===`review`){let e=`/goals/${encodeURIComponent(n.id)}`,r;t[2]===d?r=t[3]:(r=(0,K.jsx)(d,{className:`size-4`,"aria-hidden":!0}),t[2]=d,t[3]=r);let o;t[4]!==i||t[5]!==s?(o=Y(i,s),t[4]=i,t[5]=s,t[6]=o):o=t[6];let c;t[7]!==e||t[8]!==r||t[9]!==o?(c=(0,K.jsxs)(a,{to:e,children:[r,o]}),t[7]=e,t[8]=r,t[9]=o,t[10]=c):c=t[10];let l;return t[11]!==c||t[12]!==p?(l=(0,K.jsx)(k,{asChild:!0,type:`button`,variant:p,className:`h-11 rounded-lg px-3.5`,children:c}),t[11]=c,t[12]=p,t[13]=l):l=t[13],l}if(i===`execution`){if(r?.sessionKey){let e=`/chat/${encodeURIComponent(r.sessionKey)}`,n;t[14]===d?n=t[15]:(n=(0,K.jsx)(d,{className:`size-4`,"aria-hidden":!0}),t[14]=d,t[15]=n);let o;t[16]!==i||t[17]!==s?(o=Y(i,s),t[16]=i,t[17]=s,t[18]=o):o=t[18];let c;return t[19]!==e||t[20]!==n||t[21]!==o?(c=(0,K.jsx)(k,{asChild:!0,type:`button`,variant:`secondary`,className:`h-11 rounded-lg px-3.5`,children:(0,K.jsxs)(a,{to:e,children:[n,o]})}),t[19]=e,t[20]=n,t[21]=o,t[22]=c):c=t[22],c}let e=`/goals/${encodeURIComponent(n.id)}`,o;t[23]===d?o=t[24]:(o=(0,K.jsx)(d,{className:`size-4`,"aria-hidden":!0}),t[23]=d,t[24]=o);let c;t[25]!==i||t[26]!==s?(c=Y(i,s),t[25]=i,t[26]=s,t[27]=c):c=t[27];let l;return t[28]!==e||t[29]!==o||t[30]!==c?(l=(0,K.jsx)(k,{asChild:!0,type:`button`,variant:`secondary`,className:`h-11 rounded-lg px-3.5`,children:(0,K.jsxs)(a,{to:e,children:[o,c]})}),t[28]=e,t[29]=o,t[30]=c,t[31]=l):l=t[31],l}let m;t[32]!==n.id||t[33]!==i||t[34]!==l?(m=()=>l(n.id,i),t[32]=n.id,t[33]=i,t[34]=l,t[35]=m):m=t[35];let h=f&&`animate-pulse`,g;t[36]===h?g=t[37]:(g=o(`size-4`,h),t[36]=h,t[37]=g);let _;t[38]!==d||t[39]!==g?(_=(0,K.jsx)(d,{className:g,"aria-hidden":!0}),t[38]=d,t[39]=g,t[40]=_):_=t[40];let v;t[41]!==i||t[42]!==f||t[43]!==s?(v=f?s.workbench.actions.working:Y(i,s),t[41]=i,t[42]=f,t[43]=s,t[44]=v):v=t[44];let y;return t[45]!==f||t[46]!==m||t[47]!==_||t[48]!==v||t[49]!==p?(y=(0,K.jsxs)(k,{type:`button`,variant:p,className:`h-11 rounded-lg px-3.5`,disabled:f,onClick:m,children:[_,v]}),t[45]=f,t[46]=m,t[47]=_,t[48]=v,t[49]=p,t[50]=y):y=t[50],y}function De(e){let t=(0,ae.c)(126),{goal:n,queueItem:r,t:i,language:a,busy:s,actionError:c,onOpen:l,onAction:u}=e,d,f,p,m,h,g,_,v,b,x,S,C,w,T,E;if(t[0]!==n||t[1]!==a||t[2]!==l||t[3]!==r||t[4]!==i){let e=he(n,r,i),s;t[20]!==n||t[21]!==r?(s=_e(n,r),t[20]=n,t[21]=r,t[22]=s):s=t[22],d=s;let c=se(n),u;t[23]!==n.latestRun?.finishedAt||t[24]!==n.updatedAt||t[25]!==r?(u=r&&W(r.status)?U(r):n.latestRun?.finishedAt??n.updatedAt,t[23]=n.latestRun?.finishedAt,t[24]=n.updatedAt,t[25]=r,t[26]=u):u=t[26];let y=u,D;t[27]!==a||t[28]!==r||t[29]!==i?(D=Z(r,a,i),t[27]=a,t[28]=r,t[29]=i,t[30]=D):D=t[30],f=D,_=`group border-b border-edge-subtle py-4 last:border-b-0 sm:py-5`,g=`flex flex-col gap-4 lg:flex-row lg:items-center`,S=`button`,t[31]===Symbol.for(`react.memo_cache_sentinel`)?(C=o(`min-w-0 flex-1 rounded-lg text-left`,M.focusRingPanel),t[31]=C):C=t[31],w=`${i.openDetails}: ${n.title}`,t[32]!==n||t[33]!==l?(T=()=>l(n),t[32]=n,t[33]=l,t[34]=T):T=t[34];let O=o(`rounded-full px-2.5 py-1 text-xs font-semibold`,ge(e.tone)),k;t[35]!==e||t[36]!==O?(k=(0,K.jsx)(`span`,{className:O,children:e.label}),t[35]=e,t[36]=O,t[37]=k):k=t[37];let A;t[38]!==n.priority||t[39]!==i.workbench?(A=n.priority===`high`?(0,K.jsx)(`span`,{className:`text-xs font-semibold text-fg`,children:i.workbench.row.highPriority}):null,t[38]=n.priority,t[39]=i.workbench,t[40]=A):A=t[40];let j;t[41]===n.agentId?j=t[42]:(j=(0,K.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.agentId}),t[41]=n.agentId,t[42]=j),t[43]!==k||t[44]!==A||t[45]!==j?(E=(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[k,A,j]}),t[43]=k,t[44]=A,t[45]=j,t[46]=E):E=t[46],t[47]===n.title?m=t[48]:(m=(0,K.jsx)(`h3`,{className:`mt-2.5 text-base font-semibold leading-6 text-fg`,children:n.title}),t[47]=n.title,t[48]=m);let N=e.tone===`attention`?`text-amber-800 dark:text-amber-200`:`text-fg-muted`,P;t[49]===N?P=t[50]:(P=o(`mt-1 max-w-[70ch] text-sm leading-6`,N),t[49]=N,t[50]=P);let F;t[51]!==n||t[52]!==r||t[53]!==i?(F=ve(n,r,i),t[51]=n,t[52]=r,t[53]=i,t[54]=F):F=t[54],t[55]!==P||t[56]!==F?(h=(0,K.jsx)(`p`,{className:P,children:F}),t[55]=P,t[56]=F,t[57]=h):h=t[57],p=`mt-2.5 flex flex-wrap items-center gap-x-2.5 gap-y-1 text-xs text-fg-subtle`;let I;t[58]!==a||t[59]!==y?(I=pe(y,a),t[58]=a,t[59]=y,t[60]=I):I=t[60];let L;t[61]!==a||t[62]!==y?(L=J(y,a),t[61]=a,t[62]=y,t[63]=L):L=t[63],t[64]!==I||t[65]!==L?(v=(0,K.jsx)(`span`,{title:I,children:L}),t[64]=I,t[65]=L,t[66]=v):v=t[66];let R;t[67]!==n.maxTurns||t[68]!==n.turnsUsed||t[69]!==i.turns?(R=q(i.turns,{used:n.turnsUsed,max:n.maxTurns}),t[67]=n.maxTurns,t[68]=n.turnsUsed,t[69]=i.turns,t[70]=R):R=t[70],t[71]===R?b=t[72]:(b=(0,K.jsx)(`span`,{children:R}),t[71]=R,t[72]=b),x=c.total?(0,K.jsx)(`span`,{children:q(i.checklistProgress,{done:c.done,total:c.total})}):null,t[0]=n,t[1]=a,t[2]=l,t[3]=r,t[4]=i,t[5]=d,t[6]=f,t[7]=p,t[8]=m,t[9]=h,t[10]=g,t[11]=_,t[12]=v,t[13]=b,t[14]=x,t[15]=S,t[16]=C,t[17]=w,t[18]=T,t[19]=E}else d=t[5],f=t[6],p=t[7],m=t[8],h=t[9],g=t[10],_=t[11],v=t[12],b=t[13],x=t[14],S=t[15],C=t[16],w=t[17],T=t[18],E=t[19];let D;t[73]!==n.deadlineAt||t[74]!==a||t[75]!==i.deadlineSummary?(D=n.deadlineAt?(0,K.jsx)(`span`,{children:q(i.deadlineSummary,{deadline:pe(n.deadlineAt,a)})}):null,t[73]=n.deadlineAt,t[74]=a,t[75]=i.deadlineSummary,t[76]=D):D=t[76];let O;t[77]===f?O=t[78]:(O=f?(0,K.jsx)(`span`,{children:f}):null,t[77]=f,t[78]=O);let A;t[79]!==r||t[80]!==i.attempt?(A=r&&W(r.status)?(0,K.jsx)(`span`,{children:q(i.attempt,{attempts:r.attempts,max:r.maxRetries+1})}):null,t[79]=r,t[80]=i.attempt,t[81]=A):A=t[81];let j;t[82]!==p||t[83]!==D||t[84]!==O||t[85]!==A||t[86]!==v||t[87]!==b||t[88]!==x?(j=(0,K.jsxs)(`div`,{className:p,children:[v,b,x,D,O,A]}),t[82]=p,t[83]=D,t[84]=O,t[85]=A,t[86]=v,t[87]=b,t[88]=x,t[89]=j):j=t[89];let N;t[90]!==m||t[91]!==h||t[92]!==j||t[93]!==S||t[94]!==C||t[95]!==w||t[96]!==T||t[97]!==E?(N=(0,K.jsxs)(`button`,{type:S,className:C,"aria-label":w,onClick:T,children:[E,m,h,j]}),t[90]=m,t[91]=h,t[92]=j,t[93]=S,t[94]=C,t[95]=w,t[96]=T,t[97]=E,t[98]=N):N=t[98];let P;t[99]!==s||t[100]!==n||t[101]!==d||t[102]!==u||t[103]!==r||t[104]!==i?(P=(0,K.jsx)(Ee,{goal:n,queueItem:r,intent:d,t:i,busy:s,onAction:u}),t[99]=s,t[100]=n,t[101]=d,t[102]=u,t[103]=r,t[104]=i,t[105]=P):P=t[105];let F;t[106]!==n||t[107]!==l?(F=()=>l(n),t[106]=n,t[107]=l,t[108]=F):F=t[108];let I;t[109]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,K.jsx)(y,{className:`size-4`,"aria-hidden":!0}),t[109]=I):I=t[109];let L;t[110]!==i.openDetails||t[111]!==F?(L=(0,K.jsx)(k,{type:`button`,variant:`ghost`,className:`size-11 shrink-0 rounded-lg p-0`,"aria-label":i.openDetails,onClick:F,children:I}),t[110]=i.openDetails,t[111]=F,t[112]=L):L=t[112];let R;t[113]!==P||t[114]!==L?(R=(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 lg:justify-end`,children:[P,L]}),t[113]=P,t[114]=L,t[115]=R):R=t[115];let z;t[116]!==g||t[117]!==N||t[118]!==R?(z=(0,K.jsxs)(`div`,{className:g,children:[N,R]}),t[116]=g,t[117]=N,t[118]=R,t[119]=z):z=t[119];let ee;t[120]===c?ee=t[121]:(ee=c?(0,K.jsx)(`p`,{className:`mt-3 rounded-lg bg-danger-soft px-3 py-2 text-sm text-danger`,role:`alert`,children:c}):null,t[120]=c,t[121]=ee);let B;return t[122]!==_||t[123]!==z||t[124]!==ee?(B=(0,K.jsxs)(`article`,{className:_,children:[z,ee]}),t[122]=_,t[123]=z,t[124]=ee,t[125]=B):B=t[125],B}function Oe(){let e=(0,ae.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,K.jsx)(`div`,{"aria-hidden":`true`,children:Array.from({length:3}).map(ke)}),e[0]=t):t=e[0],t}function ke(e,t){return(0,K.jsx)(`div`,{className:`border-b border-edge-subtle py-5 last:border-b-0`,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-4 lg:flex-row lg:items-center`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(E,{className:`h-6 w-24 rounded-full`}),(0,K.jsx)(E,{className:`h-4 w-16`})]}),(0,K.jsx)(E,{className:`mt-3 h-5 w-2/3`}),(0,K.jsx)(E,{className:`mt-2 h-4 w-full max-w-2xl`}),(0,K.jsx)(E,{className:`mt-3 h-3 w-72 max-w-full`})]}),(0,K.jsx)(E,{className:`h-11 w-32 rounded-lg`})]})},t)}function Ae(e){let t=(0,ae.c)(36),{title:n,description:r,goals:i,queueByGoal:a,t:o,language:s,busy:c,actionError:l,onOpen:u,onAction:d}=e,f=`goal-section-${n}`,p=`goal-section-${n}`,m;t[0]!==p||t[1]!==n?(m=(0,K.jsx)(`h2`,{id:p,className:`text-base font-semibold text-fg`,children:n}),t[0]=p,t[1]=n,t[2]=m):m=t[2];let h;t[3]===r?h=t[4]:(h=(0,K.jsx)(`p`,{className:`mt-1 text-sm leading-5 text-fg-muted`,children:r}),t[3]=r,t[4]=h);let g;t[5]!==m||t[6]!==h?(g=(0,K.jsxs)(`div`,{className:`min-w-0`,children:[m,h]}),t[5]=m,t[6]=h,t[7]=g):g=t[7];let _;t[8]===i.length?_=t[9]:(_=(0,K.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-hover px-2.5 py-1 text-xs font-semibold tabular-nums text-fg-muted`,children:i.length}),t[8]=i.length,t[9]=_);let v;t[10]!==g||t[11]!==_?(v=(0,K.jsxs)(`header`,{className:`flex items-start justify-between gap-4 pb-1`,children:[g,_]}),t[10]=g,t[11]=_,t[12]=v):v=t[12];let y;if(t[13]!==l||t[14]!==c||t[15]!==i||t[16]!==s||t[17]!==d||t[18]!==u||t[19]!==a||t[20]!==o){let e;t[22]!==l||t[23]!==c||t[24]!==s||t[25]!==d||t[26]!==u||t[27]!==a||t[28]!==o?(e=e=>(0,K.jsx)(De,{goal:e,queueItem:a.get(e.id),t:o,language:s,busy:c,actionError:l?.goalId===e.id?l.message:void 0,onOpen:u,onAction:d},e.id),t[22]=l,t[23]=c,t[24]=s,t[25]=d,t[26]=u,t[27]=a,t[28]=o,t[29]=e):e=t[29],y=i.map(e),t[13]=l,t[14]=c,t[15]=i,t[16]=s,t[17]=d,t[18]=u,t[19]=a,t[20]=o,t[21]=y}else y=t[21];let b;t[30]===y?b=t[31]:(b=(0,K.jsx)(`div`,{className:`mt-2`,children:y}),t[30]=y,t[31]=b);let x;return t[32]!==f||t[33]!==v||t[34]!==b?(x=(0,K.jsxs)(`section`,{"aria-labelledby":f,children:[v,b]}),t[32]=f,t[33]=v,t[34]=b,t[35]=x):x=t[35],x}function je(e){let t=(0,ae.c)(140),{goal:n,queueItem:r,t:i,language:s,busy:c,onClose:l,onAction:u}=e;if(!n)return null;let d,f,m,h,x,C,w,T,E,D,O,M,N,P,F,I,L;if(t[0]!==n||t[1]!==l||t[2]!==r||t[3]!==i){let e=se(n);x=he(n,r,i);let a;t[21]!==n||t[22]!==r?(a=_e(n,r),t[21]=n,t[22]=r,t[23]=a):a=t[23],h=a,m=j,T=!0,t[24]===l?E=t[25]:(E=e=>!e&&l(),t[24]=l,t[25]=E),f=b,t[26]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,K.jsx)(v,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),t[26]=w):w=t[26],d=A,I=`fixed left-1/2 top-1/2 z-66 flex h-[min(90vh,48rem)] w-[min(100%-2rem,56rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`;let s;t[27]===n.title?s=t[28]:(s=(0,K.jsx)(p,{className:`text-base font-semibold leading-6 text-fg`,children:n.title}),t[27]=n.title,t[28]=s);let c;t[29]!==n||t[30]!==r||t[31]!==i?(c=ve(n,r,i),t[29]=n,t[30]=r,t[31]=i,t[32]=c):c=t[32];let u;t[33]===c?u=t[34]:(u=(0,K.jsx)(_,{className:`mt-1 text-sm text-fg-muted`,children:c}),t[33]=c,t[34]=u);let g;t[35]!==s||t[36]!==u?(g=(0,K.jsxs)(`div`,{className:`min-w-0`,children:[s,u]}),t[35]=s,t[36]=u,t[37]=g):g=t[37];let y;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,K.jsx)(ee,{className:`size-5`,"aria-hidden":!0}),t[38]=y):y=t[38];let S;t[39]!==l||t[40]!==i.closeDetails?(S=(0,K.jsx)(k,{type:`button`,variant:`ghost`,className:`size-11 shrink-0 rounded-lg p-0`,"aria-label":i.closeDetails,onClick:l,children:y}),t[39]=l,t[40]=i.closeDetails,t[41]=S):S=t[41],t[42]!==g||t[43]!==S?(L=(0,K.jsxs)(`header`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[g,S]}),t[42]=g,t[43]=S,t[44]=L):L=t[44],F=`min-h-0 flex-1 overflow-y-auto p-5`,P=`flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between`,O=`flex flex-wrap items-center gap-2`;let R=o(`rounded-full px-2.5 py-1 text-xs font-semibold`,ge(x.tone));t[45]!==x.label||t[46]!==R?(M=(0,K.jsx)(`span`,{className:R,children:x.label}),t[45]=x.label,t[46]=R,t[47]=M):M=t[47],t[48]===n.agentId?N=t[49]:(N=(0,K.jsx)(`span`,{className:`text-xs text-fg-muted`,children:n.agentId}),t[48]=n.agentId,t[49]=N),C=`text-xs text-fg-muted`,D=q(i.checklistProgress,{done:e.done,total:e.total}),t[0]=n,t[1]=l,t[2]=r,t[3]=i,t[4]=d,t[5]=f,t[6]=m,t[7]=h,t[8]=x,t[9]=C,t[10]=w,t[11]=T,t[12]=E,t[13]=D,t[14]=O,t[15]=M,t[16]=N,t[17]=P,t[18]=F,t[19]=I,t[20]=L}else d=t[4],f=t[5],m=t[6],h=t[7],x=t[8],C=t[9],w=t[10],T=t[11],E=t[12],D=t[13],O=t[14],M=t[15],N=t[16],P=t[17],F=t[18],I=t[19],L=t[20];let R;t[50]!==C||t[51]!==D?(R=(0,K.jsx)(`span`,{className:C,children:D}),t[50]=C,t[51]=D,t[52]=R):R=t[52];let z;t[53]!==R||t[54]!==O||t[55]!==M||t[56]!==N?(z=(0,K.jsxs)(`div`,{className:O,children:[M,N,R]}),t[53]=R,t[54]=O,t[55]=M,t[56]=N,t[57]=z):z=t[57];let te;t[58]!==c||t[59]!==n||t[60]!==h||t[61]!==u||t[62]!==r||t[63]!==i?(te=(0,K.jsx)(Ee,{goal:n,queueItem:r,intent:h,t:i,busy:c,onAction:u}),t[58]=c,t[59]=n,t[60]=h,t[61]=u,t[62]=r,t[63]=i,t[64]=te):te=t[64];let ne;t[65]!==z||t[66]!==te||t[67]!==P?(ne=(0,K.jsxs)(`div`,{className:P,children:[z,te]}),t[65]=z,t[66]=te,t[67]=P,t[68]=ne):ne=t[68];let re;t[69]===n.description?re=t[70]:(re=n.description?(0,K.jsx)(`p`,{className:`mt-6 max-w-[70ch] whitespace-pre-wrap break-words text-sm leading-6 text-fg-muted`,children:n.description}):null,t[69]=n.description,t[70]=re);let ie=n.blockedReason?i.currentBlocker:i.nextAction,V;t[71]===ie?V=t[72]:(V=(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:ie}),t[71]=ie,t[72]=V);let H=x.tone===`attention`?`text-amber-800 dark:text-amber-200`:`text-fg-muted`,oe;t[73]===H?oe=t[74]:(oe=o(`mt-2 text-sm leading-6`,H),t[73]=H,t[74]=oe);let ce;t[75]!==n||t[76]!==r||t[77]!==i?(ce=ve(n,r,i),t[75]=n,t[76]=r,t[77]=i,t[78]=ce):ce=t[78];let W;t[79]!==oe||t[80]!==ce?(W=(0,K.jsx)(`p`,{className:oe,children:ce}),t[79]=oe,t[80]=ce,t[81]=W):W=t[81];let le;t[82]!==V||t[83]!==W?(le=(0,K.jsxs)(`section`,{className:`mt-7 border-t border-edge-subtle pt-5`,children:[V,W]}),t[82]=V,t[83]=W,t[84]=le):le=t[84];let G;t[85]!==s||t[86]!==r||t[87]!==i?(G=r?(0,K.jsxs)(`section`,{className:`mt-6 border-t border-edge-subtle pt-5`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.workbench.row.latestExecution}),(0,K.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:me(r.status,i)})]}),(0,K.jsxs)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:[q(i.attempt,{attempts:r.attempts,max:r.maxRetries+1}),` · `,pe(U(r),s)]}),r.error?(0,K.jsx)(`p`,{className:`mt-2 text-sm text-danger`,children:r.error}):null]}):null,t[85]=s,t[86]=r,t[87]=i,t[88]=G):G=t[88];let ue;t[89]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,K.jsx)(g,{className:`size-4 text-accent`,"aria-hidden":!0}),t[89]=ue):ue=t[89];let de;t[90]===i.checklist?de=t[91]:(de=(0,K.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[ue,i.checklist]}),t[90]=i.checklist,t[91]=de);let fe;t[92]!==n.checklist||t[93]!==i.noChecklist?(fe=n.checklist.length?(0,K.jsx)(`ul`,{className:`mt-3 grid gap-2 text-sm leading-6 text-fg-muted`,children:n.checklist.map($)}):(0,K.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:i.noChecklist}),t[92]=n.checklist,t[93]=i.noChecklist,t[94]=fe):fe=t[94];let J;t[95]!==de||t[96]!==fe?(J=(0,K.jsxs)(`section`,{className:`mt-6 border-t border-edge-subtle pt-5`,children:[de,fe]}),t[95]=de,t[96]=fe,t[97]=J):J=t[97];let Y;t[98]!==ne||t[99]!==re||t[100]!==le||t[101]!==G||t[102]!==J||t[103]!==F?(Y=(0,K.jsxs)(`div`,{className:F,children:[ne,re,le,G,J]}),t[98]=ne,t[99]=re,t[100]=le,t[101]=G,t[102]=J,t[103]=F,t[104]=Y):Y=t[104];let X;t[105]!==n.id||t[106]!==n.status||t[107]!==u||t[108]!==i.actions?(X=n.status===`active`?(0,K.jsxs)(k,{type:`button`,variant:`ghost`,className:`h-11 rounded-lg`,onClick:()=>u(n.id,`pause`),children:[(0,K.jsx)(S,{className:`size-4`,"aria-hidden":!0}),i.actions.pause]}):null,t[105]=n.id,t[106]=n.status,t[107]=u,t[108]=i.actions,t[109]=X):X=t[109];let Z;t[110]!==n.id||t[111]!==n.status||t[112]!==u||t[113]!==i.actions?(Z=n.status===`archived`?null:(0,K.jsxs)(k,{type:`button`,variant:`ghost`,className:`h-11 rounded-lg`,onClick:()=>u(n.id,`archive`),children:[(0,K.jsx)(B,{className:`size-4`,"aria-hidden":!0}),i.actions.archive]}),t[110]=n.id,t[111]=n.status,t[112]=u,t[113]=i.actions,t[114]=Z):Z=t[114];let Q;t[115]!==X||t[116]!==Z?(Q=(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[X,Z]}),t[115]=X,t[116]=Z,t[117]=Q):Q=t[117];let ye=`/goals/${encodeURIComponent(n.id)}`,be;t[118]===Symbol.for(`react.memo_cache_sentinel`)?(be=(0,K.jsx)(y,{className:`size-4`,"aria-hidden":!0}),t[118]=be):be=t[118];let xe;t[119]!==i.fullDetails||t[120]!==ye?(xe=(0,K.jsx)(k,{asChild:!0,type:`button`,variant:`secondary`,className:`h-11 rounded-lg`,children:(0,K.jsxs)(a,{to:ye,children:[be,i.fullDetails]})}),t[119]=i.fullDetails,t[120]=ye,t[121]=xe):xe=t[121];let Se;t[122]!==Q||t[123]!==xe?(Se=(0,K.jsxs)(`footer`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2 border-t border-edge px-5 py-3`,children:[Q,xe]}),t[122]=Q,t[123]=xe,t[124]=Se):Se=t[124];let Ce;t[125]!==d||t[126]!==Y||t[127]!==Se||t[128]!==I||t[129]!==L?(Ce=(0,K.jsxs)(d,{className:I,children:[L,Y,Se]}),t[125]=d,t[126]=Y,t[127]=Se,t[128]=I,t[129]=L,t[130]=Ce):Ce=t[130];let we;t[131]!==f||t[132]!==w||t[133]!==Ce?(we=(0,K.jsxs)(f,{children:[w,Ce]}),t[131]=f,t[132]=w,t[133]=Ce,t[134]=we):we=t[134];let Te;return t[135]!==m||t[136]!==T||t[137]!==E||t[138]!==we?(Te=(0,K.jsx)(m,{open:T,onOpenChange:E,children:we}),t[135]=m,t[136]=T,t[137]=E,t[138]=we,t[139]=Te):Te=t[139],Te}function $(e){return(0,K.jsxs)(`li`,{className:`flex gap-2`,children:[(0,K.jsx)(`span`,{className:`w-5 shrink-0 text-center`,children:Q(e.status)}),(0,K.jsx)(`span`,{className:`break-words`,children:e.text})]},e.id)}function Me(){let e=i(),t=d(e=>e.language),n=c(t).goalsPage,r=h(e=>e.setPageHeader),a=h(e=>e.clearPageHeader),[o,s]=(0,V.useState)([]),[l,u]=(0,V.useState)([]),[f,p]=(0,V.useState)(``),[_,v]=(0,V.useState)(`workbench`),[y,b]=(0,V.useState)(``),[S,C]=(0,V.useState)(``),[E,D]=(0,V.useState)(``),[A,j]=(0,V.useState)(!0),[M,P]=(0,V.useState)(null),[B,ae]=(0,V.useState)(null),[H,se]=(0,V.useState)(null),[U,W]=(0,V.useState)(null),[G,pe]=(0,V.useState)(!1),[J,me]=(0,V.useState)(null),[he,ge]=(0,V.useState)({defaultAgentId:``,agents:[],models:[],checklistDecomposePolicy:`empty_only`}),Y=(0,V.useCallback)(async()=>{j(!0),P(null);try{let[e,t]=await Promise.all([be(),xe()]);s(e),u(t)}catch(e){P(e instanceof Error?e.message:n.errors.load)}finally{j(!1)}},[n.errors.load]);(0,V.useEffect)(()=>{Y()},[Y]),(0,V.useEffect)(()=>{let e=!1;async function t(){let[t,n,r]=await Promise.allSettled([x(),T(),N()]);e||ge(e=>{let i=t.status===`fulfilled`?t.value.defaultId:e.defaultAgentId,a=t.status===`fulfilled`?t.value.agents:e.agents;return{defaultAgentId:i,agents:a.length?a:[{id:i||`main`,workspace:``,profileDir:``,typedModels:{defaultRole:`deep`,preset:[],effective:[]},extends:[],isDefault:!0,skills:{preset:[]},tools:{presetDenied:[],entryDisable:[],effectiveDisable:[]}}],models:n.status===`fulfilled`?n.value:e.models,checklistDecomposePolicy:r.status===`fulfilled`?ne(r.value.payload?.config).checklistDecomposePolicy:e.checklistDecomposePolicy}})}return t(),()=>{e=!0}},[]),(0,V.useEffect)(()=>{let e=()=>{Y()};return window.addEventListener(`goal-queue-updated`,e),window.addEventListener(`goal-status-updated`,e),()=>{window.removeEventListener(`goal-queue-updated`,e),window.removeEventListener(`goal-status-updated`,e)}},[Y]),(0,V.useEffect)(()=>{if(!U)return;let e=window.setTimeout(()=>W(null),8e3);return()=>window.clearTimeout(e)},[U]);let X=(0,V.useMemo)(()=>ce(l),[l]),ve=(0,V.useMemo)(()=>o.filter(e=>de(e,f)),[o,f]),Z=(0,V.useMemo)(()=>fe(o,X),[o,X]),Q=(0,V.useMemo)(()=>o.find(e=>e.id===J)??null,[o,J]),ke=(0,V.useMemo)(()=>[...new Set(o.map(e=>e.agentId))].sort(),[o]),$=(0,V.useMemo)(()=>{let e=new Map(oe.map(e=>[e,[]]));for(let t of ve){let n=le(t,X.get(t.id));n&&e.get(n)?.push(t)}for(let t of oe)e.get(t)?.sort((e,t)=>ue(e,t,X));return e},[X,ve]),Me=(0,V.useMemo)(()=>ve.filter(e=>e.status!==`done`&&e.status!==`archived`).filter(e=>!y||e.agentId===y).filter(e=>!S||e.status===S).filter(e=>!E||e.priority===E).sort((e,t)=>ue(e,t,X)),[y,E,X,ve,S]),Ne=(0,V.useMemo)(()=>ve.filter(e=>e.status===`done`||e.status===`archived`).sort((e,t)=>t.updatedAt-e.updatedAt),[ve]),Pe=$.get(`attention`)?.[0]??$.get(`running`)?.[0]??$.get(`ready`)?.[0]??null,Fe=Z.attention>0?{title:Z.attention===1?n.workbench.hero.attentionOne:q(n.workbench.hero.attentionMany,{count:Z.attention}),description:n.workbench.hero.attentionDescription}:Z.running>0?{title:Z.running===1?n.workbench.hero.runningOne:q(n.workbench.hero.runningMany,{count:Z.running}),description:n.workbench.hero.runningDescription}:Z.ready>0?{title:Z.ready===1?n.workbench.hero.readyOne:q(n.workbench.hero.readyMany,{count:Z.ready}),description:n.workbench.hero.readyDescription}:{title:n.workbench.hero.calm,description:Z.later>0?q(n.workbench.hero.calmDescriptionWithPaused,{paused:Z.later}):n.workbench.hero.calmDescription},Ie=(0,V.useCallback)(async(t,r,i)=>{let a=o.find(e=>e.id===t);se(`${t}:${r}`),ae(null);try{if(r===`continue`){let n=await Te(t);if(n){e(`/chat/${encodeURIComponent(n)}`);return}}else await we(t,r),!i?.skipUndo&&a&&(r===`archive`||r===`unarchive`||r===`complete`||r===`reopen`)&&W({goalId:t,action:r,title:a.title});await Y()}catch(e){ae({goalId:t,message:e instanceof Error?e.message:n.errors.action})}finally{se(null)}},[o,e,Y,n.errors.action]),Le=(0,V.useCallback)(async e=>{let t=Number.parseInt(e.maxTurns,10),r=e.deadline?new Date(e.deadline).getTime():void 0;se(`create`),P(null);try{let n=await Se({title:e.title.trim(),contextMessage:{text:e.description.trim(),attachments:e.attachments.length?e.attachments:void 0},priority:e.priority,deadlineAt:Number.isFinite(r)?r:void 0,maxTurns:Number.isFinite(t)?t:void 0,agentId:e.agentId.trim()||void 0,judgeModelRef:e.judgeModelRef.trim()||void 0,contract:{objective:e.objective.trim()||e.title.trim(),scopeBoundary:e.scopeBoundary.trim()||void 0,evidencePlan:re(e.evidencePlan),criteria:re(e.checklist)}});await Y(),me(n.id)}catch(e){throw P(e instanceof Error?e.message:n.errors.create),e}finally{se(null)}},[Y,n.errors.create]),Re=(0,V.useMemo)(()=>(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`label`,{className:`relative min-w-0`,children:[(0,K.jsx)(z,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,"aria-hidden":!0}),(0,K.jsx)(`input`,{value:f,onChange:e=>p(e.target.value),"aria-label":n.searchPlaceholder,autoComplete:`off`,placeholder:n.searchPlaceholder,className:`h-10 w-36 rounded-lg border border-edge bg-surface-muted py-2 pl-9 pr-3 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent sm:w-56 lg:w-72`})]}),(0,K.jsx)(L,{className:`size-10 shrink-0 p-0`,loading:A,label:n.refresh,onClick:Y}),(0,K.jsxs)(k,{type:`button`,variant:`primary`,className:`h-10 rounded-lg`,disabled:H===`create`,onClick:()=>pe(!0),children:[(0,K.jsx)(O,{className:`size-4`,"aria-hidden":!0}),n.create]})]}),[H,A,f,Y,n.create,n.refresh,n.searchPlaceholder]);(0,V.useLayoutEffect)(()=>(r({startExtra:null,main:(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:n.title}),(0,K.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:n.workbench.pageDescription})]}),end:Re}),()=>a()),[a,Re,r,n.title,n.workbench.pageDescription]);let ze=[{id:`workbench`,label:n.workbench.tabs.workbench,icon:I,count:Z.attention+Z.running+Z.ready},{id:`all`,label:n.workbench.tabs.all,icon:g,count:o.length-Z.history},{id:`history`,label:n.workbench.tabs.history,icon:R,count:Z.history}],Be=n.workbench.sections;return(0,K.jsxs)(`main`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden bg-surface-panel`,children:[(0,K.jsxs)(`div`,{className:`mx-auto flex min-h-0 w-full max-w-6xl flex-1 flex-col px-3 py-5 sm:px-6 lg:px-8`,children:[(0,K.jsx)(`section`,{className:`rounded-xl border border-edge bg-surface-base px-4 py-5 sm:px-6 sm:py-6`,"aria-labelledby":`goals-now-title`,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-5 lg:flex-row lg:items-center lg:justify-between`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 max-w-2xl`,children:[(0,K.jsx)(`p`,{className:`text-sm font-medium text-fg-muted`,children:n.workbench.hero.eyebrow}),(0,K.jsx)(`h2`,{id:`goals-now-title`,className:`mt-1.5 text-xl font-semibold tracking-tight text-fg sm:text-2xl`,children:Fe.title}),(0,K.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:Fe.description})]}),Pe?(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3 border-t border-edge-subtle pt-4 lg:max-w-md lg:border-l lg:border-t-0 lg:pl-6 lg:pt-0`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-fg-subtle`,children:n.workbench.hero.nextFocus}),(0,K.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm font-semibold leading-5 text-fg`,children:Pe.title})]}),(0,K.jsx)(Ee,{goal:Pe,queueItem:X.get(Pe.id),intent:_e(Pe,X.get(Pe.id)),t:n,busy:H,onAction:(e,t)=>void Ie(e,t)})]}):null]})}),(0,K.jsx)(`div`,{className:`mt-5 border-b border-edge-subtle`,children:(0,K.jsx)(te,{items:ze,activeTab:_,onChange:v,ariaLabel:n.workbench.tabs.label,tabIdPrefix:`goals-tab`,panelIdPrefix:`goals-panel`,className:`pb-2`,selectedClassName:`bg-surface-active text-fg`})}),M?(0,K.jsxs)(`div`,{className:`mt-4 flex flex-col gap-3 rounded-lg bg-danger-soft px-4 py-3 text-sm text-danger sm:flex-row sm:items-center sm:justify-between`,role:`alert`,children:[(0,K.jsx)(`span`,{children:M}),(0,K.jsx)(k,{type:`button`,variant:`secondary`,className:`h-10 rounded-lg`,onClick:()=>void Y(),children:n.workbench.actions.retryLoad})]}):null,(0,K.jsxs)(`section`,{id:`goals-panel-${_}`,role:`tabpanel`,"aria-labelledby":`goals-tab-${_}`,className:`min-h-0 flex-1 overflow-y-auto pb-12 pt-5`,children:[A&&o.length===0?(0,K.jsx)(Oe,{}):null,!A&&_===`workbench`?(0,K.jsxs)(`div`,{className:`grid gap-9`,children:[[`attention`,`running`,`ready`].map(e=>{let r=$.get(e)??[];return r.length===0?null:(0,K.jsx)(Ae,{...Be[e],goals:r,queueByGoal:X,t:n,language:t,busy:H,actionError:B,onOpen:e=>me(e.id),onAction:(e,t)=>void Ie(e,t)},e)}),($.get(`attention`)?.length??0)+($.get(`running`)?.length??0)+($.get(`ready`)?.length??0)===0?(0,K.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-base px-5 py-8 text-center`,children:[(0,K.jsx)(w,{className:`mx-auto size-6 text-success`,"aria-hidden":!0}),(0,K.jsx)(`h2`,{className:`mt-3 text-base font-semibold text-fg`,children:n.workbench.empty.healthyTitle}),(0,K.jsx)(`p`,{className:`mx-auto mt-2 max-w-xl text-sm leading-6 text-fg-muted`,children:Z.later>0?q(n.workbench.empty.healthyDescriptionWithPaused,{paused:Z.later}):n.workbench.empty.healthyDescription})]}):null,($.get(`later`)?.length??0)>0?(0,K.jsxs)(`details`,{className:`group border-t border-edge-subtle pt-5`,children:[(0,K.jsxs)(`summary`,{className:`flex min-h-11 cursor-pointer list-none items-center justify-between gap-3 rounded-lg px-1 text-sm font-semibold text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,K.jsx)(`span`,{children:Be.later.title}),(0,K.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2.5 py-1 text-xs tabular-nums text-fg-muted`,children:$.get(`later`)?.length})]}),(0,K.jsx)(`p`,{className:`mt-1 px-1 text-sm text-fg-muted`,children:Be.later.description}),(0,K.jsx)(`div`,{className:`mt-2`,children:($.get(`later`)??[]).map(e=>(0,K.jsx)(De,{goal:e,queueItem:X.get(e.id),t:n,language:t,busy:H,actionError:B?.goalId===e.id?B.message:void 0,onOpen:e=>me(e.id),onAction:(e,t)=>void Ie(e,t)},e.id))})]}):null]}):null,!A&&_===`all`?(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2 border-b border-edge-subtle pb-4`,children:[(0,K.jsxs)(m,{value:y,onChange:e=>b(e.target.value),className:`w-full sm:w-44`,"aria-label":n.workbench.filters.agent,children:[(0,K.jsx)(F,{value:``,children:n.workbench.filters.allAgents}),ke.map(e=>(0,K.jsx)(F,{value:e,children:e},e))]}),(0,K.jsxs)(m,{value:S,onChange:e=>C(e.target.value),className:`w-full sm:w-44`,"aria-label":n.workbench.filters.status,children:[(0,K.jsx)(F,{value:``,children:n.workbench.filters.allStatuses}),[`active`,`paused`,`blocked`,`needs_input`].map(e=>(0,K.jsx)(F,{value:e,children:n.statuses[e]},e))]}),(0,K.jsxs)(m,{value:E,onChange:e=>D(e.target.value),className:`w-full sm:w-44`,"aria-label":n.workbench.filters.priority,children:[(0,K.jsx)(F,{value:``,children:n.workbench.filters.allPriorities}),[`high`,`normal`,`low`].map(e=>(0,K.jsx)(F,{value:e,children:n.priorities[e]},e))]}),y||S||E?(0,K.jsx)(k,{type:`button`,variant:`ghost`,className:`h-10 rounded-lg`,onClick:()=>{b(``),C(``),D(``)},children:n.workbench.filters.clear}):null]}),Me.length?Me.map(e=>(0,K.jsx)(De,{goal:e,queueItem:X.get(e.id),t:n,language:t,busy:H,actionError:B?.goalId===e.id?B.message:void 0,onOpen:e=>me(e.id),onAction:(e,t)=>void Ie(e,t)},e.id)):(0,K.jsxs)(`div`,{className:`py-14 text-center`,children:[(0,K.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.workbench.empty.noOpenTitle}),(0,K.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:n.workbench.empty.noOpenDescription})]})]}):null,!A&&_===`history`?(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`header`,{className:`border-b border-edge-subtle pb-4`,children:[(0,K.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.workbench.history.title}),(0,K.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.workbench.history.description})]}),Ne.length?Ne.map(e=>(0,K.jsx)(De,{goal:e,queueItem:X.get(e.id),t:n,language:t,busy:H,actionError:B?.goalId===e.id?B.message:void 0,onOpen:e=>me(e.id),onAction:(e,t)=>void Ie(e,t)},e.id)):(0,K.jsxs)(`div`,{className:`py-14 text-center`,children:[(0,K.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.workbench.empty.noHistoryTitle}),(0,K.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:n.workbench.empty.noHistoryDescription})]})]}):null]})]}),U?(0,K.jsxs)(`div`,{className:`fixed bottom-5 right-5 z-50 flex max-w-[calc(100%-2rem)] items-center gap-3 rounded-xl border border-edge bg-surface-panel px-4 py-3 shadow-popover`,role:`status`,"aria-live":`polite`,children:[(0,K.jsx)(`p`,{className:`min-w-0 text-sm text-fg`,children:q(n.workbench.undo.message,{title:U.title})}),(0,K.jsx)(k,{type:`button`,variant:`ghost`,className:`h-10 shrink-0 rounded-lg text-accent-fg`,onClick:()=>{let e=U;W(null),Ie(e.goalId,ye(e.action),{skipUndo:!0})},children:n.workbench.undo.action}),(0,K.jsx)(k,{type:`button`,variant:`ghost`,className:`size-10 shrink-0 rounded-lg p-0`,"aria-label":n.workbench.undo.dismiss,onClick:()=>W(null),children:(0,K.jsx)(ee,{className:`size-4`,"aria-hidden":!0})})]}):null,(0,K.jsx)(ie,{open:G,t:n,chat:c(t).chat,busy:H===`create`,options:he,onClose:()=>pe(!1),onCreate:Le,onDraftContract:e=>Ce(e,t)}),(0,K.jsx)(je,{goal:Q,queueItem:Q?X.get(Q.id):void 0,t:n,language:t,busy:H,onClose:()=>me(null),onAction:(e,t)=>void Ie(e,t)})]})}export{Me as GoalsPage};
|
package/dist/gateway/static/root/assets/{goals-settings-BROWCIcL.js → goals-settings-D07UL8Jo.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as a}from"./cn-BQ_8x0bT.js";import{t as o}from"./messages-CQGpD-dC.js";import{d as s,i as c,n as l,o as u}from"./locale-store-Bp8joZck.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{As as f,Ko as p,Mt as m,Ps as h,Rc as g,Wo as _,du as v,mc as y,ms as b,pa as x,ps as S,ro as C}from"./index-CxkNzw3e.js";import{n as w,r as T,t as E}from"./settings-page-layout-DaFwstQw.js";import{t as D}from"./page-tabs-DKB6RDre.js";import{t as O}from"./use-channel-catalog-C4PWbNoi.js";import{n as k,t as A}from"./goals-config-api-B6YJB_ct.js";import{n as j,t as M}from"./save-bar-controls-BgIE9BBh.js";var N=n(),P=e(t(),1),F=r();function I(){return a(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,S,`dark:border-edge`)}var L=[`done`,`blocked`,`needs_input`,`queue_failed`,`queue_retry`,`queue_succeeded`,`queue_skipped`],R=[`judge`,`notifications`],z={judge:h,notifications:v};function B(e){return e&&R.includes(e)?e:`judge`}function V(e,t){return t===`judge`?e.tabJudge:e.tabNotifications}function H(e,t){return t===`judge`?e.tabJudgeHint:e.tabNotificationsHint}var U=[{id:`telegram`,label:`Telegram`},{id:`weixin`,label:`Weixin`},{id:`feishu`,label:`Feishu`}],W=`__custom__`;function G(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function K(e,t){let n=G(e)?e:{},r=G(n.channels)?n.channels:{},i=G(r[t])?r[t]:{},a=G(i.config)?i.config:i,o=G(a.accounts)?a.accounts:null;if(!o)return[`default`];let s=Object.entries(o).filter(([,e])=>!G(e)||e.enabled!==!1).map(([e])=>e).filter(Boolean).sort();return s.length?s:[`default`]}function q(e,t){let n=e.split(`:`),r=n.indexOf(t);return r<0?null:n[r+1]||null}function J(e,t){let n=e.split(`:`),r=n.indexOf(t);return r<0?null:n[r+2+1]||null}async function Y(e,t){let n=new URLSearchParams({account:t||`default`});return(await c(s(`/api/channels/${encodeURIComponent(e)}/pairing?${n.toString()}`))).payload??{}}function X(e){let t=(0,N.c)(81),{target:n,index:r,config:i,channelOptions:a,labels:o,inputClass:s,onChange:c,onRemove:l}=e,u=n.channel||a[0]?.id||`telegram`,m;t[0]!==u||t[1]!==i?(m=K(i,u),t[0]=u,t[1]=i,t[2]=m):m=t[2];let h=m,g=n.accountId||h[0]||`default`,v;t[3]===u?v=t[4]:(v=u?[`goal-notification-sessions`,u]:null,t[3]=u,t[4]=v);let y;t[5]===u?y=t[6]:(y=()=>x({channel:u,limit:200}),t[5]=u,t[6]=y);let S;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(S={revalidateOnFocus:!1},t[7]=S):S=t[7];let{data:C}=d(v,y,S),w;t[8]!==g||t[9]!==u?(w=u&&g?[`goal-notification-pairing`,u,g]:null,t[8]=g,t[9]=u,t[10]=w):w=t[10];let T;t[11]!==g||t[12]!==u?(T=()=>Y(u,g),t[11]=g,t[12]=u,t[13]=T):T=t[13];let E;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(E={revalidateOnFocus:!1},t[14]=E):E=t[14];let{data:D}=d(w,T,E),O;if(t[15]!==g||t[16]!==u||t[17]!==o.notificationsPaired||t[18]!==D?.paired?.fromConfig||t[19]!==D?.paired?.fromCredentials||t[20]!==C?.items){let e=new Map;for(let t of C?.items??[]){let n=q(t.key,u);if(n&&g&&n!==g)continue;let r=t.sourceChatId||J(t.key,u);r&&e.set(r,t.name?.trim()?`${t.name} (${r})`:r)}for(let t of D?.paired?.fromConfig??[])t&&e.set(t,e.get(t)??`${t} (${o.notificationsPaired})`);for(let t of D?.paired?.fromCredentials??[])t&&e.set(t,e.get(t)??`${t} (${o.notificationsPaired})`);O=[...e.entries()].map(ne),t[15]=g,t[16]=u,t[17]=o.notificationsPaired,t[18]=D?.paired?.fromConfig,t[19]=D?.paired?.fromCredentials,t[20]=C?.items,t[21]=O}else O=t[21];let k=O,A;t[22]!==k||t[23]!==n.chatId?(A=n.chatId&&k.some(e=>e.id===n.chatId),t[22]=k,t[23]=n.chatId,t[24]=A):A=t[24];let j=A,M=k.length===0||n.chatId===W||n.chatId&&!j,P;t[25]!==i||t[26]!==r||t[27]!==c||t[28]!==n?(P=e=>{let t=e.target.value,a=K(i,t);c(r,{...n,channel:t,accountId:a[0]||`default`,chatId:``})},t[25]=i,t[26]=r,t[27]=c,t[28]=n,t[29]=P):P=t[29];let I;t[30]===a?I=t[31]:(I=a.map(te),t[30]=a,t[31]=I);let L;t[32]!==u||t[33]!==s||t[34]!==P||t[35]!==I?(L=(0,F.jsx)(_,{className:s,value:u,onChange:P,children:I}),t[32]=u,t[33]=s,t[34]=P,t[35]=I,t[36]=L):L=t[36];let R;t[37]!==r||t[38]!==c||t[39]!==n?(R=e=>c(r,{...n,accountId:e.target.value,chatId:``}),t[37]=r,t[38]=c,t[39]=n,t[40]=R):R=t[40];let z;t[41]===h?z=t[42]:(z=h.map(ee),t[41]=h,t[42]=z);let B;t[43]!==g||t[44]!==s||t[45]!==R||t[46]!==z?(B=(0,F.jsx)(_,{className:s,value:g,onChange:R,children:z}),t[43]=g,t[44]=s,t[45]=R,t[46]=z,t[47]=B):B=t[47];let V;t[48]!==k||t[49]!==r||t[50]!==s||t[51]!==o.notificationsChatId||t[52]!==o.notificationsChooseChat||t[53]!==o.notificationsCustomChat||t[54]!==c||t[55]!==n||t[56]!==M?(V=M?(0,F.jsx)(`input`,{className:s,value:n.chatId===W?``:n.chatId,placeholder:o.notificationsChatId,onChange:e=>c(r,{...n,chatId:e.target.value})}):(0,F.jsxs)(_,{className:s,value:n.chatId||k[0]?.id||``,onChange:e=>c(r,{...n,chatId:e.target.value===W?W:e.target.value}),children:[n.chatId?null:(0,F.jsx)(p,{value:``,children:o.notificationsChooseChat}),k.map(Z),(0,F.jsx)(p,{value:W,children:o.notificationsCustomChat})]}),t[48]=k,t[49]=r,t[50]=s,t[51]=o.notificationsChatId,t[52]=o.notificationsChooseChat,t[53]=o.notificationsCustomChat,t[54]=c,t[55]=n,t[56]=M,t[57]=V):V=t[57];let H;t[58]!==r||t[59]!==l?(H=()=>l(r),t[58]=r,t[59]=l,t[60]=H):H=t[60];let U;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,F.jsx)(f,{className:`size-4`,"aria-hidden":!0}),t[61]=U):U=t[61];let G;t[62]!==o.notificationsRemoveTarget||t[63]!==H?(G=(0,F.jsx)(b,{type:`button`,variant:`ghost`,className:`size-9 p-0 text-destructive hover:text-destructive`,title:o.notificationsRemoveTarget,onClick:H,children:U}),t[62]=o.notificationsRemoveTarget,t[63]=H,t[64]=G):G=t[64];let X;t[65]!==L||t[66]!==B||t[67]!==V||t[68]!==G?(X=(0,F.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[10rem_10rem_minmax(0,1fr)_2rem]`,children:[L,B,V,G]}),t[65]=L,t[66]=B,t[67]=V,t[68]=G,t[69]=X):X=t[69];let Q;t[70]!==k[0]?.id||t[71]!==k.length||t[72]!==r||t[73]!==o.notificationsUseKnownChat||t[74]!==c||t[75]!==n||t[76]!==M?(Q=k.length>0&&M?(0,F.jsx)(`button`,{type:`button`,className:`w-fit text-xs text-accent hover:underline`,onClick:()=>c(r,{...n,chatId:k[0]?.id??``}),children:o.notificationsUseKnownChat}):null,t[70]=k[0]?.id,t[71]=k.length,t[72]=r,t[73]=o.notificationsUseKnownChat,t[74]=c,t[75]=n,t[76]=M,t[77]=Q):Q=t[77];let $;return t[78]!==X||t[79]!==Q?($=(0,F.jsxs)(`div`,{className:`grid gap-2 rounded-lg bg-surface-panel/80 p-3 shadow-surface`,children:[X,Q]}),t[78]=X,t[79]=Q,t[80]=$):$=t[80],$}function Z(e){return(0,F.jsx)(p,{value:e.id,children:e.label},e.id)}function ee(e){return(0,F.jsx)(p,{value:e,children:e},e)}function te(e){return(0,F.jsxs)(p,{value:e.id,children:[e.label,` (`,e.id,`)`]},e.id)}function ne(e){let[t,n]=e;return{id:t,label:n}}function Q(e){let t=(0,N.c)(7),{t:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=R.map(e=>({id:e,label:V(n,e),icon:z[e]})),t[0]=n,t[1]=a);let o=a,s;return t[2]!==r||t[3]!==o||t[4]!==i||t[5]!==n.tabsAriaLabel?(s=(0,F.jsx)(D,{items:o,activeTab:r,onChange:i,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`goals-settings-tab`,panelIdPrefix:`goals-settings-panel`}),t[2]=r,t[3]=o,t[4]=i,t[5]=n.tabsAriaLabel,t[6]=s):s=t[6],s}function $(e){let t=(0,N.c)(14),{t:n,id:r,activeTab:i,children:a}=e,o;t[0]!==r||t[1]!==n?(o=V(n,r),t[0]=r,t[1]=n,t[2]=o):o=t[2];let s;t[3]!==r||t[4]!==n?(s=H(n,r),t[3]=r,t[4]=n,t[5]=s):s=t[5];let c;t[6]===a?c=t[7]:(c=(0,F.jsx)(`div`,{className:`space-y-4`,children:a}),t[6]=a,t[7]=c);let l;return t[8]!==i||t[9]!==r||t[10]!==o||t[11]!==s||t[12]!==c?(l=(0,F.jsx)(T,{id:r,activeTab:i,tabIdPrefix:`goals-settings-tab`,panelIdPrefix:`goals-settings-panel`,title:o,hint:s,children:c}),t[8]=i,t[9]=r,t[10]=o,t[11]=s,t[12]=c,t[13]=l):l=t[13],l}function re(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}case`patch`:return{...e,form:e.form?{...e.form,...t.patch}:null};case`discard`:return e.baseline?{form:structuredClone(e.baseline),baseline:e.baseline}:e;case`saved`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}}}function ie({hasToken:e}){let t=l(e=>e.language),n=o(t).goalsSettings,r=o(t).chat,[s,c]=i(),u=B(s.get(`tab`)),d=(0,P.useCallback)(e=>{c(t=>{let n=new URLSearchParams(t);return e===`judge`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[c]),{data:f,isLoading:h}=C(e),{entries:v}=O(e,t),x=(0,P.useMemo)(()=>f?.payload?.config===void 0?null:A(f.payload.config),[f]),[S,w]=(0,P.useReducer)(re,{form:null,baseline:null}),T=S.form,E=S.baseline,[D,M]=(0,P.useState)(!1),[N,R]=(0,P.useState)(null),z=(0,P.useRef)(!1),V=(0,P.useRef)(null);e?x!==null&&!z.current&&V.current!==x&&(V.current=x,w({type:`sync`,value:x})):V.current!==null&&(V.current=null,w({type:`reset`}),z.current=!1);let H=!!(T&&E&&JSON.stringify(T)!==JSON.stringify(E)),W=(0,P.useCallback)(e=>{z.current=!0,w({type:`patch`,patch:e})},[]),G=(0,P.useCallback)(()=>{w({type:`discard`}),z.current=!1,R(null)},[]);j({id:`goals`,dirty:H,saving:D,save:(0,P.useCallback)(async()=>{if(!(!T||D)){M(!0),R(null);try{await k(T),z.current=!1,w({type:`saved`,value:T})}catch(e){let t=e instanceof Error?e.message:n.saveError;throw R(t),Error(t)}finally{M(!1)}}},[T,D,n.saveError]),discard:G});let q=(0,P.useCallback)(e=>{T&&W({notifications:{...T.notifications,...e}})},[T,W]),J=(0,P.useMemo)(()=>{let e=new Map;for(let t of v)e.set(t.id,{id:t.id,label:t.label||t.id,configured:t.configured,enabled:t.enabled});for(let t of U)e.has(t.id)||e.set(t.id,t);for(let t of T?.notifications.channels??[])e.has(t)||e.set(t,{id:t,label:t});return[...e.values()].sort((e,t)=>{let n=e.enabled?0:e.configured?1:2,r=t.enabled?0:t.configured?1:2;return n===r?e.label.localeCompare(t.label):n-r})},[v,T?.notifications.channels]);return!e||!T?h?(0,F.jsx)(`div`,{className:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,children:(0,F.jsx)(g,{className:`size-4 animate-spin text-fg-muted`})}):null:(0,F.jsxs)(F.Fragment,{children:[N?(0,F.jsx)(`p`,{className:`mb-3 text-sm text-red-600 dark:text-red-400`,children:N}):null,(0,F.jsx)(Q,{t:n,activeTab:u,onChange:d}),(0,F.jsx)($,{t:n,id:`judge`,activeTab:u,children:(0,F.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:n.maxTurns}),(0,F.jsx)(`input`,{type:`number`,min:1,max:500,className:I(),value:T.maxTurns,onChange:e=>W({maxTurns:Number(e.target.value)||20})})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:n.judgeModelRef}),(0,F.jsx)(m,{value:T.judgeModelRef,placeholder:n.judgeModelRefPlaceholder,searchPlaceholder:r.modelSearchPlaceholder,noMatches:r.modelNoMatches,className:`w-full max-w-none min-w-0`,onChange:e=>W({judgeModelRef:e})}),T.judgeModelRef.trim()?(0,F.jsx)(`button`,{type:`button`,className:`mt-1 text-xs text-accent hover:underline`,onClick:()=>W({judgeModelRef:``}),children:n.judgeModelRefUseDefault}):(0,F.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.judgeModelRefHint})]}),(0,F.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg sm:col-span-2`,children:[(0,F.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:T.checklistMode,onChange:e=>W({checklistMode:e.target.checked})}),n.checklistMode]}),(0,F.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,F.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:n.checklistDecomposePolicy}),(0,F.jsxs)(_,{className:I(),value:T.checklistDecomposePolicy,disabled:!T.checklistMode,onChange:e=>W({checklistDecomposePolicy:e.target.value===`supplement_existing`?`supplement_existing`:`empty_only`}),children:[(0,F.jsx)(p,{value:`empty_only`,children:n.checklistDecomposePolicyEmptyOnly}),(0,F.jsx)(p,{value:`supplement_existing`,children:n.checklistDecomposePolicySupplementExisting})]}),(0,F.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.checklistDecomposePolicyHint})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:n.parseFailures}),(0,F.jsx)(`input`,{type:`number`,min:1,max:20,className:I(),value:T.maxConsecutiveParseFailures,onChange:e=>W({maxConsecutiveParseFailures:Number(e.target.value)||3})})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:n.judgeTimeoutSec}),(0,F.jsx)(`input`,{type:`number`,min:5,max:120,className:I(),value:T.judgeTimeoutSec,onChange:e=>W({judgeTimeoutSec:Number(e.target.value)||60})})]}),(0,F.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,F.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:n.checklistHistoryChars}),(0,F.jsx)(`input`,{type:`number`,min:0,max:1e5,className:I(),value:T.checklistHistoryChars,onChange:e=>W({checklistHistoryChars:Math.max(0,Math.min(1e5,Math.floor(Number(e.target.value)||0)))})}),(0,F.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.checklistHistoryCharsHint})]})]})}),(0,F.jsx)($,{t:n,id:`notifications`,activeTab:u,children:(0,F.jsxs)(`div`,{className:`grid gap-3`,children:[(0,F.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,F.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:T.notifications.enabled,onChange:e=>q({enabled:e.target.checked})}),n.notificationsEnabled]}),(0,F.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,F.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:T.notifications.includeLinkedSessions,onChange:e=>q({includeLinkedSessions:e.target.checked})}),n.notificationsLinkedSessions]}),(0,F.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:n.notificationsChannels}),(0,F.jsx)(`div`,{className:`rounded-lg bg-surface-panel/80 p-2 shadow-surface`,children:(0,F.jsx)(`div`,{className:`grid max-h-40 gap-1 overflow-y-auto pr-1`,children:J.map(e=>(0,F.jsxs)(`label`,{className:`flex min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-sm text-fg hover:bg-surface-hover`,children:[(0,F.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:T.notifications.channels.includes(e.id),onChange:t=>{q({channels:t.target.checked?[...T.notifications.channels,e.id]:T.notifications.channels.filter(t=>t!==e.id)})}}),(0,F.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),(0,F.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:e.id}),e.enabled?(0,F.jsx)(`span`,{className:`shrink-0 rounded-full bg-accent-soft px-1.5 py-0.5 text-[11px] text-accent-fg`,children:n.notificationsChannelEnabled}):e.configured?(0,F.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:n.notificationsChannelConfigured}):null]},e.id))})})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:n.notificationsEvents}),(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:L.map(e=>{let t=T.notifications.events.includes(e);return(0,F.jsx)(`button`,{type:`button`,className:a(`rounded-md px-2 py-1 text-xs transition-colors`,t?`bg-accent-soft text-accent-fg`:`bg-surface-panel text-fg-muted hover:bg-surface-hover`),onClick:()=>{q({events:t?T.notifications.events.filter(t=>t!==e):[...T.notifications.events,e]})},children:e},e)})})]})]}),(0,F.jsxs)(`div`,{className:`grid gap-2`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,F.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.notificationsTargets}),(0,F.jsxs)(b,{type:`button`,variant:`secondary`,className:`h-8 gap-1.5 px-2.5 text-xs`,onClick:()=>q({targets:[...T.notifications.targets,{channel:J[0]?.id??`telegram`,accountId:K(f?.payload?.config,J[0]?.id??`telegram`)[0]??`default`,chatId:``}]}),children:[(0,F.jsx)(y,{className:`size-3.5`,"aria-hidden":!0}),n.notificationsAddTarget]})]}),T.notifications.targets.length?(0,F.jsx)(`div`,{className:`grid gap-2`,children:T.notifications.targets.map((e,t)=>(0,F.jsx)(X,{target:e,index:t,config:f?.payload?.config,channelOptions:J,labels:n,inputClass:I(),onChange:(e,t)=>{let n=[...T.notifications.targets];n[e]=t,q({targets:n})},onRemove:e=>q({targets:T.notifications.targets.filter((t,n)=>n!==e)})},t))}):(0,F.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.notificationsNoTargets})]})]})})]})}function ae(){let e=(0,N.c)(11),t=l(se),n;e[0]===t?n=e[1]:(n=o(t),e[0]=t,e[1]=n);let r=n.goalsSettingsPage,i=!!u(oe),a;e[2]!==r.subtitle||e[3]!==r.title?(a=(0,F.jsx)(w,{title:r.title,subtitle:r.subtitle}),e[2]=r.subtitle,e[3]=r.title,e[4]=a):a=e[4];let s;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,F.jsx)(M,{}),e[5]=s):s=e[5];let c;e[6]===i?c=e[7]:(c=(0,F.jsx)(ie,{hasToken:i}),e[6]=i,e[7]=c);let d;return e[8]!==a||e[9]!==c?(d=(0,F.jsxs)(E,{gap:`gap-4`,children:[a,s,c]}),e[8]=a,e[9]=c,e[10]=d):d=e[10],d}function oe(e){return e.token}function se(e){return e.language}export{ae as GoalsSettingsPanel};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as a}from"./cn-BQ_8x0bT.js";import{t as o}from"./messages-t1yPaVCt.js";import{d as s,i as c,n as l,o as u}from"./locale-store-BneNAR8R.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{Fs as f,Go as p,Mt as m,fu as h,hc as g,hs as _,io as v,js as y,ma as b,ms as x,qo as S,zc as C}from"./index-CH7XN6KY.js";import{n as w,r as T,t as E}from"./settings-page-layout-HdlQOOqp.js";import{t as D}from"./page-tabs-DMlQERNg.js";import{t as O}from"./use-channel-catalog-DnvpI0Ys.js";import{n as k,t as A}from"./goals-config-api-D88opgcs.js";import{n as j,t as M}from"./save-bar-controls-BZTj3hxl.js";var N=n(),P=e(t(),1),F=r();function I(){return a(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,x,`dark:border-edge`)}var L=[`done`,`blocked`,`needs_input`,`queue_failed`,`queue_retry`,`queue_succeeded`,`queue_skipped`],R=[`judge`,`notifications`],z={judge:f,notifications:h};function B(e){return e&&R.includes(e)?e:`judge`}function V(e,t){return t===`judge`?e.tabJudge:e.tabNotifications}function H(e,t){return t===`judge`?e.tabJudgeHint:e.tabNotificationsHint}var U=[{id:`telegram`,label:`Telegram`},{id:`weixin`,label:`Weixin`},{id:`feishu`,label:`Feishu`}],W=`__custom__`;function G(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function K(e,t){let n=G(e)?e:{},r=G(n.channels)?n.channels:{},i=G(r[t])?r[t]:{},a=G(i.config)?i.config:i,o=G(a.accounts)?a.accounts:null;if(!o)return[`default`];let s=Object.entries(o).filter(([,e])=>!G(e)||e.enabled!==!1).map(([e])=>e).filter(Boolean).sort();return s.length?s:[`default`]}function q(e,t){let n=e.split(`:`),r=n.indexOf(t);return r<0?null:n[r+1]||null}function J(e,t){let n=e.split(`:`),r=n.indexOf(t);return r<0?null:n[r+2+1]||null}async function Y(e,t){let n=new URLSearchParams({account:t||`default`});return(await c(s(`/api/channels/${encodeURIComponent(e)}/pairing?${n.toString()}`))).payload??{}}function X(e){let t=(0,N.c)(81),{target:n,index:r,config:i,channelOptions:a,labels:o,inputClass:s,onChange:c,onRemove:l}=e,u=n.channel||a[0]?.id||`telegram`,f;t[0]!==u||t[1]!==i?(f=K(i,u),t[0]=u,t[1]=i,t[2]=f):f=t[2];let m=f,h=n.accountId||m[0]||`default`,g;t[3]===u?g=t[4]:(g=u?[`goal-notification-sessions`,u]:null,t[3]=u,t[4]=g);let v;t[5]===u?v=t[6]:(v=()=>b({channel:u,limit:200}),t[5]=u,t[6]=v);let x;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(x={revalidateOnFocus:!1},t[7]=x):x=t[7];let{data:C}=d(g,v,x),w;t[8]!==h||t[9]!==u?(w=u&&h?[`goal-notification-pairing`,u,h]:null,t[8]=h,t[9]=u,t[10]=w):w=t[10];let T;t[11]!==h||t[12]!==u?(T=()=>Y(u,h),t[11]=h,t[12]=u,t[13]=T):T=t[13];let E;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(E={revalidateOnFocus:!1},t[14]=E):E=t[14];let{data:D}=d(w,T,E),O;if(t[15]!==h||t[16]!==u||t[17]!==o.notificationsPaired||t[18]!==D?.paired?.fromConfig||t[19]!==D?.paired?.fromCredentials||t[20]!==C?.items){let e=new Map;for(let t of C?.items??[]){let n=q(t.key,u);if(n&&h&&n!==h)continue;let r=t.sourceChatId||J(t.key,u);r&&e.set(r,t.name?.trim()?`${t.name} (${r})`:r)}for(let t of D?.paired?.fromConfig??[])t&&e.set(t,e.get(t)??`${t} (${o.notificationsPaired})`);for(let t of D?.paired?.fromCredentials??[])t&&e.set(t,e.get(t)??`${t} (${o.notificationsPaired})`);O=[...e.entries()].map(ne),t[15]=h,t[16]=u,t[17]=o.notificationsPaired,t[18]=D?.paired?.fromConfig,t[19]=D?.paired?.fromCredentials,t[20]=C?.items,t[21]=O}else O=t[21];let k=O,A;t[22]!==k||t[23]!==n.chatId?(A=n.chatId&&k.some(e=>e.id===n.chatId),t[22]=k,t[23]=n.chatId,t[24]=A):A=t[24];let j=A,M=k.length===0||n.chatId===W||n.chatId&&!j,P;t[25]!==i||t[26]!==r||t[27]!==c||t[28]!==n?(P=e=>{let t=e.target.value,a=K(i,t);c(r,{...n,channel:t,accountId:a[0]||`default`,chatId:``})},t[25]=i,t[26]=r,t[27]=c,t[28]=n,t[29]=P):P=t[29];let I;t[30]===a?I=t[31]:(I=a.map(te),t[30]=a,t[31]=I);let L;t[32]!==u||t[33]!==s||t[34]!==P||t[35]!==I?(L=(0,F.jsx)(p,{className:s,value:u,onChange:P,children:I}),t[32]=u,t[33]=s,t[34]=P,t[35]=I,t[36]=L):L=t[36];let R;t[37]!==r||t[38]!==c||t[39]!==n?(R=e=>c(r,{...n,accountId:e.target.value,chatId:``}),t[37]=r,t[38]=c,t[39]=n,t[40]=R):R=t[40];let z;t[41]===m?z=t[42]:(z=m.map(ee),t[41]=m,t[42]=z);let B;t[43]!==h||t[44]!==s||t[45]!==R||t[46]!==z?(B=(0,F.jsx)(p,{className:s,value:h,onChange:R,children:z}),t[43]=h,t[44]=s,t[45]=R,t[46]=z,t[47]=B):B=t[47];let V;t[48]!==k||t[49]!==r||t[50]!==s||t[51]!==o.notificationsChatId||t[52]!==o.notificationsChooseChat||t[53]!==o.notificationsCustomChat||t[54]!==c||t[55]!==n||t[56]!==M?(V=M?(0,F.jsx)(`input`,{className:s,value:n.chatId===W?``:n.chatId,placeholder:o.notificationsChatId,onChange:e=>c(r,{...n,chatId:e.target.value})}):(0,F.jsxs)(p,{className:s,value:n.chatId||k[0]?.id||``,onChange:e=>c(r,{...n,chatId:e.target.value===W?W:e.target.value}),children:[n.chatId?null:(0,F.jsx)(S,{value:``,children:o.notificationsChooseChat}),k.map(Z),(0,F.jsx)(S,{value:W,children:o.notificationsCustomChat})]}),t[48]=k,t[49]=r,t[50]=s,t[51]=o.notificationsChatId,t[52]=o.notificationsChooseChat,t[53]=o.notificationsCustomChat,t[54]=c,t[55]=n,t[56]=M,t[57]=V):V=t[57];let H;t[58]!==r||t[59]!==l?(H=()=>l(r),t[58]=r,t[59]=l,t[60]=H):H=t[60];let U;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,F.jsx)(y,{className:`size-4`,"aria-hidden":!0}),t[61]=U):U=t[61];let G;t[62]!==o.notificationsRemoveTarget||t[63]!==H?(G=(0,F.jsx)(_,{type:`button`,variant:`ghost`,className:`size-9 p-0 text-destructive hover:text-destructive`,title:o.notificationsRemoveTarget,onClick:H,children:U}),t[62]=o.notificationsRemoveTarget,t[63]=H,t[64]=G):G=t[64];let X;t[65]!==L||t[66]!==B||t[67]!==V||t[68]!==G?(X=(0,F.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[10rem_10rem_minmax(0,1fr)_2rem]`,children:[L,B,V,G]}),t[65]=L,t[66]=B,t[67]=V,t[68]=G,t[69]=X):X=t[69];let Q;t[70]!==k[0]?.id||t[71]!==k.length||t[72]!==r||t[73]!==o.notificationsUseKnownChat||t[74]!==c||t[75]!==n||t[76]!==M?(Q=k.length>0&&M?(0,F.jsx)(`button`,{type:`button`,className:`w-fit text-xs text-accent hover:underline`,onClick:()=>c(r,{...n,chatId:k[0]?.id??``}),children:o.notificationsUseKnownChat}):null,t[70]=k[0]?.id,t[71]=k.length,t[72]=r,t[73]=o.notificationsUseKnownChat,t[74]=c,t[75]=n,t[76]=M,t[77]=Q):Q=t[77];let $;return t[78]!==X||t[79]!==Q?($=(0,F.jsxs)(`div`,{className:`grid gap-2 rounded-lg bg-surface-panel/80 p-3 shadow-surface`,children:[X,Q]}),t[78]=X,t[79]=Q,t[80]=$):$=t[80],$}function Z(e){return(0,F.jsx)(S,{value:e.id,children:e.label},e.id)}function ee(e){return(0,F.jsx)(S,{value:e,children:e},e)}function te(e){return(0,F.jsxs)(S,{value:e.id,children:[e.label,` (`,e.id,`)`]},e.id)}function ne(e){let[t,n]=e;return{id:t,label:n}}function Q(e){let t=(0,N.c)(7),{t:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=R.map(e=>({id:e,label:V(n,e),icon:z[e]})),t[0]=n,t[1]=a);let o=a,s;return t[2]!==r||t[3]!==o||t[4]!==i||t[5]!==n.tabsAriaLabel?(s=(0,F.jsx)(D,{items:o,activeTab:r,onChange:i,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`goals-settings-tab`,panelIdPrefix:`goals-settings-panel`}),t[2]=r,t[3]=o,t[4]=i,t[5]=n.tabsAriaLabel,t[6]=s):s=t[6],s}function $(e){let t=(0,N.c)(14),{t:n,id:r,activeTab:i,children:a}=e,o;t[0]!==r||t[1]!==n?(o=V(n,r),t[0]=r,t[1]=n,t[2]=o):o=t[2];let s;t[3]!==r||t[4]!==n?(s=H(n,r),t[3]=r,t[4]=n,t[5]=s):s=t[5];let c;t[6]===a?c=t[7]:(c=(0,F.jsx)(`div`,{className:`space-y-4`,children:a}),t[6]=a,t[7]=c);let l;return t[8]!==i||t[9]!==r||t[10]!==o||t[11]!==s||t[12]!==c?(l=(0,F.jsx)(T,{id:r,activeTab:i,tabIdPrefix:`goals-settings-tab`,panelIdPrefix:`goals-settings-panel`,title:o,hint:s,children:c}),t[8]=i,t[9]=r,t[10]=o,t[11]=s,t[12]=c,t[13]=l):l=t[13],l}function re(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}case`patch`:return{...e,form:e.form?{...e.form,...t.patch}:null};case`discard`:return e.baseline?{form:structuredClone(e.baseline),baseline:e.baseline}:e;case`saved`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}}}function ie({hasToken:e}){let t=l(e=>e.language),n=o(t).goalsSettings,r=o(t).chat,[s,c]=i(),u=B(s.get(`tab`)),d=(0,P.useCallback)(e=>{c(t=>{let n=new URLSearchParams(t);return e===`judge`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[c]),{data:f,isLoading:h}=v(e),{entries:y}=O(e,t),b=(0,P.useMemo)(()=>f?.payload?.config===void 0?null:A(f.payload.config),[f]),[x,w]=(0,P.useReducer)(re,{form:null,baseline:null}),T=x.form,E=x.baseline,[D,M]=(0,P.useState)(!1),[N,R]=(0,P.useState)(null),z=(0,P.useRef)(!1),V=(0,P.useRef)(null);e?b!==null&&!z.current&&V.current!==b&&(V.current=b,w({type:`sync`,value:b})):V.current!==null&&(V.current=null,w({type:`reset`}),z.current=!1);let H=!!(T&&E&&JSON.stringify(T)!==JSON.stringify(E)),W=(0,P.useCallback)(e=>{z.current=!0,w({type:`patch`,patch:e})},[]),G=(0,P.useCallback)(()=>{w({type:`discard`}),z.current=!1,R(null)},[]);j({id:`goals`,dirty:H,saving:D,save:(0,P.useCallback)(async()=>{if(!(!T||D)){M(!0),R(null);try{await k(T),z.current=!1,w({type:`saved`,value:T})}catch(e){let t=e instanceof Error?e.message:n.saveError;throw R(t),Error(t)}finally{M(!1)}}},[T,D,n.saveError]),discard:G});let q=(0,P.useCallback)(e=>{T&&W({notifications:{...T.notifications,...e}})},[T,W]),J=(0,P.useMemo)(()=>{let e=new Map;for(let t of y)e.set(t.id,{id:t.id,label:t.label||t.id,configured:t.configured,enabled:t.enabled});for(let t of U)e.has(t.id)||e.set(t.id,t);for(let t of T?.notifications.channels??[])e.has(t)||e.set(t,{id:t,label:t});return[...e.values()].sort((e,t)=>{let n=e.enabled?0:e.configured?1:2,r=t.enabled?0:t.configured?1:2;return n===r?e.label.localeCompare(t.label):n-r})},[y,T?.notifications.channels]);return!e||!T?h?(0,F.jsx)(`div`,{className:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,children:(0,F.jsx)(C,{className:`size-4 animate-spin text-fg-muted`})}):null:(0,F.jsxs)(F.Fragment,{children:[N?(0,F.jsx)(`p`,{className:`mb-3 text-sm text-red-600 dark:text-red-400`,children:N}):null,(0,F.jsx)(Q,{t:n,activeTab:u,onChange:d}),(0,F.jsx)($,{t:n,id:`judge`,activeTab:u,children:(0,F.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:n.maxTurns}),(0,F.jsx)(`input`,{type:`number`,min:1,max:500,className:I(),value:T.maxTurns,onChange:e=>W({maxTurns:Number(e.target.value)||20})})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:n.judgeModelRef}),(0,F.jsx)(m,{value:T.judgeModelRef,placeholder:n.judgeModelRefPlaceholder,searchPlaceholder:r.modelSearchPlaceholder,noMatches:r.modelNoMatches,className:`w-full max-w-none min-w-0`,onChange:e=>W({judgeModelRef:e})}),T.judgeModelRef.trim()?(0,F.jsx)(`button`,{type:`button`,className:`mt-1 text-xs text-accent hover:underline`,onClick:()=>W({judgeModelRef:``}),children:n.judgeModelRefUseDefault}):(0,F.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.judgeModelRefHint})]}),(0,F.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg sm:col-span-2`,children:[(0,F.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:T.checklistMode,onChange:e=>W({checklistMode:e.target.checked})}),n.checklistMode]}),(0,F.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,F.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:n.checklistDecomposePolicy}),(0,F.jsxs)(p,{className:I(),value:T.checklistDecomposePolicy,disabled:!T.checklistMode,onChange:e=>W({checklistDecomposePolicy:e.target.value===`supplement_existing`?`supplement_existing`:`empty_only`}),children:[(0,F.jsx)(S,{value:`empty_only`,children:n.checklistDecomposePolicyEmptyOnly}),(0,F.jsx)(S,{value:`supplement_existing`,children:n.checklistDecomposePolicySupplementExisting})]}),(0,F.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.checklistDecomposePolicyHint})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:n.parseFailures}),(0,F.jsx)(`input`,{type:`number`,min:1,max:20,className:I(),value:T.maxConsecutiveParseFailures,onChange:e=>W({maxConsecutiveParseFailures:Number(e.target.value)||3})})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:n.judgeTimeoutSec}),(0,F.jsx)(`input`,{type:`number`,min:5,max:120,className:I(),value:T.judgeTimeoutSec,onChange:e=>W({judgeTimeoutSec:Number(e.target.value)||60})})]}),(0,F.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,F.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:n.checklistHistoryChars}),(0,F.jsx)(`input`,{type:`number`,min:0,max:1e5,className:I(),value:T.checklistHistoryChars,onChange:e=>W({checklistHistoryChars:Math.max(0,Math.min(1e5,Math.floor(Number(e.target.value)||0)))})}),(0,F.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.checklistHistoryCharsHint})]})]})}),(0,F.jsx)($,{t:n,id:`notifications`,activeTab:u,children:(0,F.jsxs)(`div`,{className:`grid gap-3`,children:[(0,F.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,F.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:T.notifications.enabled,onChange:e=>q({enabled:e.target.checked})}),n.notificationsEnabled]}),(0,F.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,F.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:T.notifications.includeLinkedSessions,onChange:e=>q({includeLinkedSessions:e.target.checked})}),n.notificationsLinkedSessions]}),(0,F.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:n.notificationsChannels}),(0,F.jsx)(`div`,{className:`rounded-lg bg-surface-panel/80 p-2 shadow-surface`,children:(0,F.jsx)(`div`,{className:`grid max-h-40 gap-1 overflow-y-auto pr-1`,children:J.map(e=>(0,F.jsxs)(`label`,{className:`flex min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-sm text-fg hover:bg-surface-hover`,children:[(0,F.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:T.notifications.channels.includes(e.id),onChange:t=>{q({channels:t.target.checked?[...T.notifications.channels,e.id]:T.notifications.channels.filter(t=>t!==e.id)})}}),(0,F.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),(0,F.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:e.id}),e.enabled?(0,F.jsx)(`span`,{className:`shrink-0 rounded-full bg-accent-soft px-1.5 py-0.5 text-[11px] text-accent-fg`,children:n.notificationsChannelEnabled}):e.configured?(0,F.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:n.notificationsChannelConfigured}):null]},e.id))})})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:n.notificationsEvents}),(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:L.map(e=>{let t=T.notifications.events.includes(e);return(0,F.jsx)(`button`,{type:`button`,className:a(`rounded-md px-2 py-1 text-xs transition-colors`,t?`bg-accent-soft text-accent-fg`:`bg-surface-panel text-fg-muted hover:bg-surface-hover`),onClick:()=>{q({events:t?T.notifications.events.filter(t=>t!==e):[...T.notifications.events,e]})},children:e},e)})})]})]}),(0,F.jsxs)(`div`,{className:`grid gap-2`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,F.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.notificationsTargets}),(0,F.jsxs)(_,{type:`button`,variant:`secondary`,className:`h-8 gap-1.5 px-2.5 text-xs`,onClick:()=>q({targets:[...T.notifications.targets,{channel:J[0]?.id??`telegram`,accountId:K(f?.payload?.config,J[0]?.id??`telegram`)[0]??`default`,chatId:``}]}),children:[(0,F.jsx)(g,{className:`size-3.5`,"aria-hidden":!0}),n.notificationsAddTarget]})]}),T.notifications.targets.length?(0,F.jsx)(`div`,{className:`grid gap-2`,children:T.notifications.targets.map((e,t)=>(0,F.jsx)(X,{target:e,index:t,config:f?.payload?.config,channelOptions:J,labels:n,inputClass:I(),onChange:(e,t)=>{let n=[...T.notifications.targets];n[e]=t,q({targets:n})},onRemove:e=>q({targets:T.notifications.targets.filter((t,n)=>n!==e)})},t))}):(0,F.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.notificationsNoTargets})]})]})})]})}function ae(){let e=(0,N.c)(11),t=l(se),n;e[0]===t?n=e[1]:(n=o(t),e[0]=t,e[1]=n);let r=n.goalsSettingsPage,i=!!u(oe),a;e[2]!==r.subtitle||e[3]!==r.title?(a=(0,F.jsx)(w,{title:r.title,subtitle:r.subtitle}),e[2]=r.subtitle,e[3]=r.title,e[4]=a):a=e[4];let s;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,F.jsx)(M,{}),e[5]=s):s=e[5];let c;e[6]===i?c=e[7]:(c=(0,F.jsx)(ie,{hasToken:i}),e[6]=i,e[7]=c);let d;return e[8]!==a||e[9]!==c?(d=(0,F.jsxs)(E,{gap:`gap-4`,children:[a,s,c]}),e[8]=a,e[9]=c,e[10]=d):d=e[10],d}function oe(e){return e.token}function se(e){return e.language}export{ae as GoalsSettingsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as a}from"./cn-BQ_8x0bT.js";import{t as o}from"./messages-CQGpD-dC.js";import{d as s,i as c,n as l,o as u}from"./locale-store-Bp8joZck.js";import{i as d,o as f}from"./vendor-swr-BIWyz7Rc.js";import{Do as p,Ko as m,Mc as h,Rc as g,Rl as _,Wo as v,ds as y,fs as b,gc as x,kt as S,ms as C,no as w,ps as T,ro as E,sc as D,sl as O,xl as k,zo as A}from"./index-CxkNzw3e.js";import{n as j,r as M,t as N}from"./settings-page-layout-DaFwstQw.js";import{n as ee}from"./settings-loading-skeleton-B79dq-XY.js";import{t as P}from"./page-tabs-DKB6RDre.js";import{r as te,t as F}from"./channel-recipient-api-rTG26jpV.js";import{n as ne,t as re}from"./channels-status-swr-OKlqTtKJ.js";import{t as I}from"./schedule-field-BXDP-oMz.js";import{n as ie,t as ae}from"./save-bar-controls-BgIE9BBh.js";var L=e(t(),1),R=n();function z(){return s(`/api/workspace/heartbeat-md`)}async function oe(){let e=await c(z());return typeof e.payload?.content==`string`?e.payload.content:``}function B(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function se(e){let t=B(e)?e:{},n=B(t.gateway)?t.gateway:{},r=B(n.heartbeat)?n.heartbeat:{},i=r.activeHours,a=B(i)?i:null,o=a&&typeof a.start==`string`&&typeof a.end==`string`&&a.start&&a.end?{start:a.start,end:a.end,timezone:typeof a.timezone==`string`?a.timezone:``}:null;return{enabled:!!(r.enabled??!0),intervalMs:typeof r.intervalMs==`number`&&Number.isFinite(r.intervalMs)?r.intervalMs:18e5,includeSystemPromptSection:r.includeSystemPromptSection===!0,target:typeof r.target==`string`?r.target:``,targetChatId:typeof r.targetChatId==`string`?r.targetChatId:``,prompt:typeof r.prompt==`string`?r.prompt:``,ackMaxChars:typeof r.ackMaxChars==`number`&&Number.isFinite(r.ackMaxChars)?r.ackMaxChars:``,isolatedSession:!!r.isolatedSession,activeHours:o}}function V(e){let t={enabled:e.enabled,intervalMs:e.intervalMs,includeSystemPromptSection:e.includeSystemPromptSection};return e.target.trim()?t.target=e.target.trim():t.target=null,e.targetChatId.trim()?t.targetChatId=e.targetChatId.trim():t.targetChatId=null,e.prompt.trim()?t.prompt=e.prompt.trim():t.prompt=null,e.ackMaxChars===``||e.ackMaxChars===void 0?t.ackMaxChars=null:t.ackMaxChars=e.ackMaxChars,e.isolatedSession?t.isolatedSession=!0:t.isolatedSession=null,e.activeHours?.start?.trim()&&e.activeHours?.end?.trim()?t.activeHours={start:e.activeHours.start.trim(),end:e.activeHours.end.trim(),...e.activeHours.timezone.trim()?{timezone:e.activeHours.timezone.trim()}:{}}:t.activeHours=null,t}async function ce(e){await c(s(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{heartbeat:V(e)}})}),w()}async function le(e){await c(s(`/api/workspace/heartbeat-md`),{method:`PUT`,body:JSON.stringify({content:e})}),f(z())}async function ue(e){await c(s(`/api/heartbeat/trigger`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e?{reason:e}:{})})}var H=r();function U(){return a(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,T,`dark:border-edge`)}function de(){return a(b,y)}var W=[`schedule`,`delivery`,`prompt`,`document`],G={schedule:_,delivery:h,prompt:O,document:k};function fe(e){return e&&W.includes(e)?e:`schedule`}function K(e,t){return t===`schedule`?e.tabSchedule:t===`delivery`?e.tabDelivery:t===`prompt`?e.tabPrompt:e.tabDocument}function pe(e,t){return t===`schedule`?e.scheduleTabHint:t===`delivery`?e.deliveryTabHint:t===`prompt`?e.promptTabHint:e.documentTabHint}function me(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}case`patch`:return{...e,form:e.form?{...e.form,...t.patch}:null};case`discard`:return e.baseline?{form:structuredClone(e.baseline),baseline:e.baseline}:e;case`saved`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}}}function he(e,t){switch(t.type){case`reset`:return{doc:``,baseline:``};case`sync`:return{doc:t.value,baseline:t.value};case`set`:return{...e,doc:t.value};case`discard`:return{...e,doc:e.baseline};case`saved`:return{doc:t.value,baseline:t.value}}}function ge(e){if(!e||typeof e!=`object`||Array.isArray(e))return``;let t=e.agents;if(!t||typeof t!=`object`||Array.isArray(t))return``;let n=t;if(!Array.isArray(n.list))return``;let r=typeof n.default==`string`?n.default:``,i=n.list.find(e=>!e||typeof e!=`object`||Array.isArray(e)?!1:r?e.id===r:!0)??n.list[0];if(!i||typeof i!=`object`||Array.isArray(i))return``;let a=i.workspace;if(!a||typeof a!=`object`||Array.isArray(a))return``;let o=a.root;return typeof o==`string`?o:``}var _e={saving:!1,error:null,triggerLoading:!1,triggerOk:!1,triggerError:null};function q(){let e=l(e=>e.language),t=o(e),n=t.heartbeatSettings,r=!!u(e=>e.token),[s,c]=i(),f=fe(s.get(`tab`)),m=(0,L.useCallback)(e=>{c(t=>{let n=new URLSearchParams(t);return e===`schedule`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[c]),[h,_]=(0,L.useReducer)(me,{form:null,baseline:null}),v=h.form,y=h.baseline,[b,w]=(0,L.useReducer)(he,{doc:``,baseline:``}),T=b.doc,D=b.baseline,[O,k]=(0,L.useReducer)(S,_e),{saving:M,error:P,triggerLoading:F,triggerOk:I,triggerError:R}=O,B=(0,L.useRef)(!1),V=(0,L.useRef)(!1),{data:W,error:G,isLoading:K,mutate:pe}=E(r),{data:q,error:Y,isLoading:xe,mutate:Ce}=d(r?z():null,oe,{revalidateOnFocus:!1}),{data:we=[]}=d(r?re():null,ne,{revalidateOnFocus:!1}),Te=(0,L.useMemo)(()=>ge(W?.payload?.config),[W]),Ee=(0,L.useMemo)(()=>se(W?.payload?.config??{}),[W]),X=(0,L.useMemo)(()=>!v||!y?!1:JSON.stringify(v)!==JSON.stringify(y),[v,y]),Z=T!==D;(0,L.useEffect)(()=>{if(!r){_({type:`reset`}),B.current=!1;return}W!==void 0&&(B.current||_({type:`sync`,value:Ee}))},[r,W,Ee]),(0,L.useEffect)(()=>{if(!r){w({type:`reset`}),V.current=!1;return}q!==void 0&&(V.current||w({type:`sync`,value:q}))},[r,q]);let De=G instanceof Error?G.message:G?String(G):Y instanceof Error?Y.message:Y?String(Y):null,Oe=!!(r&&(W===void 0||q===void 0)&&!De&&(K||xe)),Q=v?.target.trim()??``,{data:ke,setData:Ae}=p(()=>te(Q),[r,Q],{enabled:r&&Q.length>0,initial:[],errorData:[]}),je=(0,L.useCallback)(()=>{Q&&te(Q).then(Ae)},[Q,Ae]),Me=(0,L.useCallback)(async()=>{k({type:`patch`,patch:{triggerLoading:!0,triggerOk:!1,triggerError:null}});try{await ue(),k({type:`patch`,patch:{triggerOk:!0}}),window.setTimeout(()=>k({type:`patch`,patch:{triggerOk:!1}}),3e3)}catch(e){k({type:`patch`,patch:{triggerError:e instanceof Error?e.message:n.triggerError}})}finally{k({type:`patch`,patch:{triggerLoading:!1}})}},[n.triggerError]),$=(0,L.useCallback)(e=>{B.current=!0,_({type:`patch`,patch:e})},[]),Ne=X||Z,Pe=(0,L.useCallback)(()=>{_({type:`discard`}),w({type:`discard`}),B.current=!1,V.current=!1,k({type:`patch`,patch:{error:null}})},[]);return ie({id:`heartbeat`,dirty:Ne,saving:M,save:(0,L.useCallback)(async()=>{if(!(!v||M)){k({type:`patch`,patch:{saving:!0,error:null}});try{X&&(await ce(v),_({type:`saved`,value:v}),B.current=!1),Z&&(await le(T),w({type:`saved`,value:T}),V.current=!1)}catch(e){let t=X?n.saveConfigError:n.saveDocError,r=e instanceof Error?e.message:t;throw k({type:`patch`,patch:{error:r}}),Error(r)}finally{k({type:`patch`,patch:{saving:!1}})}}},[X,Z,T,v,n.saveConfigError,n.saveDocError,M]),discard:Pe}),r?Oe?(0,H.jsx)(N,{gap:`gap-6`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,H.jsx)(ee,{sections:3})}):v?(0,H.jsxs)(N,{"aria-busy":M,"data-has-baseline":y?`1`:`0`,children:[(0,H.jsx)(j,{title:t.settingsSections.heartbeat,subtitle:n.subtitle,docsLink:A(e,`heartbeat`),docsLabel:n.docsLink,actions:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(C,{type:`button`,variant:`secondary`,className:`inline-flex items-center gap-2`,disabled:F,onClick:()=>void Me(),children:[F?(0,H.jsx)(g,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,H.jsx)(x,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),F?n.triggering:n.triggerNow]}),I?(0,H.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.triggered}):null]})}),(0,H.jsx)(ae,{}),Te?(0,H.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[n.workspaceLabel,`: `,(0,H.jsx)(`span`,{className:`font-mono text-fg-muted`,children:Te})]}):null,P?(0,H.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:P}):null,R?(0,H.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:R}):null,(0,H.jsx)(ve,{h:n,activeTab:f,onChange:m}),(0,H.jsx)(J,{h:n,id:`schedule`,activeTab:f,children:(0,H.jsx)(ye,{h:n,form:v,update:$})}),(0,H.jsx)(J,{h:n,id:`delivery`,activeTab:f,children:(0,H.jsx)(be,{h:n,cron:t.cron,form:v,channels:we,sessionChatIds:ke,onRefreshChatIds:je,update:$,inputClassName:U,selectClassName:de})}),(0,H.jsx)(J,{h:n,id:`prompt`,activeTab:f,children:(0,H.jsx)(Se,{h:n,form:v,update:$,inputClassName:U})}),(0,H.jsxs)(J,{h:n,id:`document`,activeTab:f,children:[(0,H.jsx)(`p`,{className:`mb-3 text-xs text-fg-subtle`,children:n.docHint}),(0,H.jsx)(`textarea`,{className:a(U(),`min-h-72 resize-y font-mono text-xs leading-relaxed`),value:T,onChange:e=>{V.current=!0,w({type:`set`,value:e.target.value})},spellCheck:!1,"aria-label":n.docSection,"data-doc-in-sync":T===D?`true`:`false`})]})]}):(0,H.jsxs)(N,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:P??De??n.loadError}),(0,H.jsx)(C,{type:`button`,variant:`secondary`,onClick:()=>{pe(),Ce()},children:n.retry})]}):(0,H.jsxs)(N,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,H.jsx)(j,{title:t.settingsSections.heartbeat}),(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})]})}function ve(e){let t=(0,R.c)(7),{h:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=W.map(e=>({id:e,label:K(n,e),icon:G[e]})),t[0]=n,t[1]=a);let o=a,s;return t[2]!==r||t[3]!==n.tabsAriaLabel||t[4]!==o||t[5]!==i?(s=(0,H.jsx)(P,{items:o,activeTab:r,onChange:i,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`heartbeat-settings-tab`,panelIdPrefix:`heartbeat-settings-panel`}),t[2]=r,t[3]=n.tabsAriaLabel,t[4]=o,t[5]=i,t[6]=s):s=t[6],s}function J(e){let t=(0,R.c)(14),{h:n,id:r,activeTab:i,children:a}=e,o;t[0]!==n||t[1]!==r?(o=K(n,r),t[0]=n,t[1]=r,t[2]=o):o=t[2];let s;t[3]!==n||t[4]!==r?(s=pe(n,r),t[3]=n,t[4]=r,t[5]=s):s=t[5];let c;t[6]===a?c=t[7]:(c=(0,H.jsx)(`div`,{className:`space-y-4`,children:a}),t[6]=a,t[7]=c);let l;return t[8]!==i||t[9]!==r||t[10]!==o||t[11]!==s||t[12]!==c?(l=(0,H.jsx)(M,{id:r,activeTab:i,tabIdPrefix:`heartbeat-settings-tab`,panelIdPrefix:`heartbeat-settings-panel`,title:o,hint:s,children:c}),t[8]=i,t[9]=r,t[10]=o,t[11]=s,t[12]=c,t[13]=l):l=t[13],l}function ye(e){let t=(0,R.c)(37),{h:n,form:r,update:i}=e,a;t[0]===i?a=t[1]:(a=e=>i({enabled:e.target.checked}),t[0]=i,t[1]=a);let o;t[2]!==r.enabled||t[3]!==a?(o=(0,H.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.enabled,onChange:a}),t[2]=r.enabled,t[3]=a,t[4]=o):o=t[4];let s;t[5]!==n.enable||t[6]!==o?(s=(0,H.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[o,n.enable]}),t[5]=n.enable,t[6]=o,t[7]=s):s=t[7];let c;t[8]===i?c=t[9]:(c=e=>i({intervalMs:e}),t[8]=i,t[9]=c);let l;t[10]!==n.intervalPresets||t[11]!==n.intervalSecondsLabel?(l={secondsLabel:n.intervalSecondsLabel,presets:n.intervalPresets},t[10]=n.intervalPresets,t[11]=n.intervalSecondsLabel,t[12]=l):l=t[12];let u=`${n.intervalHintPreset} ${n.intervalHint}`,d;t[13]!==r.intervalMs||t[14]!==n.interval||t[15]!==c||t[16]!==l||t[17]!==u?(d=(0,H.jsx)(I,{kind:`interval`,label:n.interval,valueMs:r.intervalMs,onChangeMs:c,labels:l,hint:u}),t[13]=r.intervalMs,t[14]=n.interval,t[15]=c,t[16]=l,t[17]=u,t[18]=d):d=t[18];let f;t[19]===i?f=t[20]:(f=e=>i({activeHours:e}),t[19]=i,t[20]=f);let p;t[21]!==n.activeEnd||t[22]!==n.activeStart||t[23]!==n.activeTimezone||t[24]!==n.addActiveHours||t[25]!==n.clearActiveHours?(p={start:n.activeStart,end:n.activeEnd,timezone:n.activeTimezone,add:n.addActiveHours,clear:n.clearActiveHours},t[21]=n.activeEnd,t[22]=n.activeStart,t[23]=n.activeTimezone,t[24]=n.addActiveHours,t[25]=n.clearActiveHours,t[26]=p):p=t[26];let m;t[27]!==r.activeHours||t[28]!==n.activeHoursHint||t[29]!==n.activeHoursTitle||t[30]!==f||t[31]!==p?(m=(0,H.jsx)(I,{kind:`active-hours`,label:n.activeHoursTitle,value:r.activeHours,onChange:f,labels:p,hint:n.activeHoursHint}),t[27]=r.activeHours,t[28]=n.activeHoursHint,t[29]=n.activeHoursTitle,t[30]=f,t[31]=p,t[32]=m):m=t[32];let h;return t[33]!==m||t[34]!==s||t[35]!==d?(h=(0,H.jsxs)(H.Fragment,{children:[s,d,m]}),t[33]=m,t[34]=s,t[35]=d,t[36]=h):h=t[36],h}function be(e){let t=(0,R.c)(51),{h:n,cron:r,form:i,channels:o,sessionChatIds:s,onRefreshChatIds:c,update:l,inputClassName:u,selectClassName:d}=e,f;t[0]===o?f=t[1]:(f=new Set(o.map(xe)),t[0]=o,t[1]=f);let p=f,h;t[2]===i.target?h=t[3]:(h=i.target.trim(),t[2]=i.target,t[3]=h);let g=h,_=!!(g&&!p.has(g)),y;t[4]===n.deliveryHint?y=t[5]:(y=(0,H.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.deliveryHint}),t[4]=n.deliveryHint,t[5]=y);let b;t[6]===r.channel?b=t[7]:(b=(0,H.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:r.channel}),t[6]=r.channel,t[7]=b);let x;t[8]===d?x=t[9]:(x=d(),t[8]=d,t[9]=x);let S;t[10]===l?S=t[11]:(S=e=>{l({target:e.target.value.trim(),targetChatId:``})},t[10]=l,t[11]=S);let w;t[12]===n.channelNone?w=t[13]:(w=(0,H.jsx)(m,{value:``,children:n.channelNone}),t[12]=n.channelNone,t[13]=w);let T;t[14]!==n.customChannelSuffix||t[15]!==_||t[16]!==g?(T=_?(0,H.jsxs)(m,{value:g,children:[g,` (`,n.customChannelSuffix,`)`]}):null,t[14]=n.customChannelSuffix,t[15]=_,t[16]=g,t[17]=T):T=t[17];let E;t[18]===o?E=t[19]:(E=o.map(Y),t[18]=o,t[19]=E);let O;t[20]!==x||t[21]!==S||t[22]!==w||t[23]!==T||t[24]!==E||t[25]!==g?(O=(0,H.jsxs)(v,{className:x,value:g,onChange:S,children:[w,T,E]}),t[20]=x,t[21]=S,t[22]=w,t[23]=T,t[24]=E,t[25]=g,t[26]=O):O=t[26];let k;t[27]!==O||t[28]!==b?(k=(0,H.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[b,O]}),t[27]=O,t[28]=b,t[29]=k):k=t[29];let A;t[30]!==r.enterManuallyOrSelect||t[31]!==r.lastActiveLabels||t[32]!==r.noRecentChats||t[33]!==r.noRecentChatsOption||t[34]!==r.recipient||t[35]!==r.recipientPlaceholder||t[36]!==r.refreshList||t[37]!==r.refreshRecipientHint||t[38]!==r.selectRecipient||t[39]!==i.targetChatId||t[40]!==u||t[41]!==c||t[42]!==d||t[43]!==s||t[44]!==g||t[45]!==l?(A=g?(0,H.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,H.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:r.recipient}),(0,H.jsxs)(C,{type:`button`,variant:`ghost`,className:`h-7 gap-1 px-2 text-xs`,title:r.refreshRecipientHint,onClick:c,children:[(0,H.jsx)(D,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),r.refreshList]})]}),(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsx)(`input`,{type:`text`,className:a(u(),`min-w-0 flex-1`),value:i.targetChatId,onChange:e=>l({targetChatId:e.target.value}),placeholder:r.recipientPlaceholder,autoComplete:`off`}),(0,H.jsxs)(v,{className:a(d(),`max-w-40 shrink-0 text-xs`),value:i.targetChatId,onChange:e=>{let t=e.target.value;t&&l({targetChatId:t})},children:[(0,H.jsx)(m,{value:``,children:r.selectRecipient}),s.length>0?s.map(e=>(0,H.jsx)(m,{value:e.chatId,children:F(e,r.lastActiveLabels)},`${e.channel}-${e.chatId}`)):(0,H.jsx)(m,{value:``,disabled:!0,children:r.noRecentChatsOption})]})]}),(0,H.jsx)(`p`,{className:`text-xs text-fg-muted`,children:s.length>0?r.enterManuallyOrSelect:r.noRecentChats})]}):null,t[30]=r.enterManuallyOrSelect,t[31]=r.lastActiveLabels,t[32]=r.noRecentChats,t[33]=r.noRecentChatsOption,t[34]=r.recipient,t[35]=r.recipientPlaceholder,t[36]=r.refreshList,t[37]=r.refreshRecipientHint,t[38]=r.selectRecipient,t[39]=i.targetChatId,t[40]=u,t[41]=c,t[42]=d,t[43]=s,t[44]=g,t[45]=l,t[46]=A):A=t[46];let j;return t[47]!==k||t[48]!==A||t[49]!==y?(j=(0,H.jsxs)(H.Fragment,{children:[y,k,A]}),t[47]=k,t[48]=A,t[49]=y,t[50]=j):j=t[50],j}function Y(e){return(0,H.jsxs)(m,{value:e.name,disabled:!e.enabled,children:[e.name,` `,e.enabled?``:`(disabled)`]},e.name)}function xe(e){return e.name}function Se(e){let t=(0,R.c)(65),{h:n,form:r,update:i,inputClassName:o}=e,s;t[0]===i?s=t[1]:(s=e=>i({includeSystemPromptSection:e.target.checked}),t[0]=i,t[1]=s);let c;t[2]!==r.includeSystemPromptSection||t[3]!==s?(c=(0,H.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.includeSystemPromptSection,onChange:s}),t[2]=r.includeSystemPromptSection,t[3]=s,t[4]=c):c=t[4];let l;t[5]===n.includeSystemPromptSectionHint?l=t[6]:(l=(0,H.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:n.includeSystemPromptSectionHint}),t[5]=n.includeSystemPromptSectionHint,t[6]=l);let u;t[7]!==n.includeSystemPromptSection||t[8]!==l?(u=(0,H.jsxs)(`span`,{children:[n.includeSystemPromptSection,l]}),t[7]=n.includeSystemPromptSection,t[8]=l,t[9]=u):u=t[9];let d;t[10]!==c||t[11]!==u?(d=(0,H.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[c,u]}),t[10]=c,t[11]=u,t[12]=d):d=t[12];let f;t[13]===n.prompt?f=t[14]:(f=(0,H.jsx)(`div`,{className:`mb-1 text-sm font-medium text-fg`,children:n.prompt}),t[13]=n.prompt,t[14]=f);let p;t[15]===o?p=t[16]:(p=a(o(),`min-h-36 resize-y font-mono text-xs`),t[15]=o,t[16]=p);let m;t[17]===i?m=t[18]:(m=e=>i({prompt:e.target.value}),t[17]=i,t[18]=m);let h;t[19]!==r.prompt||t[20]!==n.promptPlaceholder||t[21]!==p||t[22]!==m?(h=(0,H.jsx)(`textarea`,{className:p,value:r.prompt,onChange:m,placeholder:n.promptPlaceholder}),t[19]=r.prompt,t[20]=n.promptPlaceholder,t[21]=p,t[22]=m,t[23]=h):h=t[23];let g;t[24]===n.promptHint?g=t[25]:(g=(0,H.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.promptHint}),t[24]=n.promptHint,t[25]=g);let _;t[26]!==g||t[27]!==f||t[28]!==h?(_=(0,H.jsxs)(`div`,{children:[f,h,g]}),t[26]=g,t[27]=f,t[28]=h,t[29]=_):_=t[29];let v;t[30]===n.ackMaxChars?v=t[31]:(v=(0,H.jsx)(`div`,{className:`mb-1 text-sm font-medium text-fg`,children:n.ackMaxChars}),t[30]=n.ackMaxChars,t[31]=v);let y;t[32]===o?y=t[33]:(y=o(),t[32]=o,t[33]=y);let b=r.ackMaxChars===``?``:r.ackMaxChars,x;t[34]===i?x=t[35]:(x=e=>{let t=e.target.value;if(t===``){i({ackMaxChars:``});return}let n=parseInt(t,10);i({ackMaxChars:Number.isFinite(n)?n:``})},t[34]=i,t[35]=x);let S;t[36]!==n.ackDefaultPlaceholder||t[37]!==y||t[38]!==b||t[39]!==x?(S=(0,H.jsx)(`input`,{type:`number`,min:1,className:y,value:b,onChange:x,placeholder:n.ackDefaultPlaceholder}),t[36]=n.ackDefaultPlaceholder,t[37]=y,t[38]=b,t[39]=x,t[40]=S):S=t[40];let C;t[41]===n.ackMaxCharsHint?C=t[42]:(C=(0,H.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.ackMaxCharsHint}),t[41]=n.ackMaxCharsHint,t[42]=C);let w;t[43]!==v||t[44]!==S||t[45]!==C?(w=(0,H.jsxs)(`div`,{children:[v,S,C]}),t[43]=v,t[44]=S,t[45]=C,t[46]=w):w=t[46];let T;t[47]===i?T=t[48]:(T=e=>i({isolatedSession:e.target.checked}),t[47]=i,t[48]=T);let E;t[49]!==r.isolatedSession||t[50]!==T?(E=(0,H.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.isolatedSession,onChange:T}),t[49]=r.isolatedSession,t[50]=T,t[51]=E):E=t[51];let D;t[52]===n.isolatedSessionHint?D=t[53]:(D=(0,H.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:n.isolatedSessionHint}),t[52]=n.isolatedSessionHint,t[53]=D);let O;t[54]!==n.isolatedSession||t[55]!==D?(O=(0,H.jsxs)(`span`,{children:[n.isolatedSession,D]}),t[54]=n.isolatedSession,t[55]=D,t[56]=O):O=t[56];let k;t[57]!==E||t[58]!==O?(k=(0,H.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[E,O]}),t[57]=E,t[58]=O,t[59]=k):k=t[59];let A;return t[60]!==_||t[61]!==w||t[62]!==k||t[63]!==d?(A=(0,H.jsxs)(H.Fragment,{children:[d,_,w,k]}),t[60]=_,t[61]=w,t[62]=k,t[63]=d,t[64]=A):A=t[64],A}export{q as HeartbeatSettingsPanel};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as a}from"./cn-BQ_8x0bT.js";import{t as o}from"./messages-t1yPaVCt.js";import{d as s,i as c,n as l,o as u}from"./locale-store-BneNAR8R.js";import{i as d,o as f}from"./vendor-swr-BIWyz7Rc.js";import{Bo as p,Go as m,Nc as h,Oo as g,Sl as _,_c as v,cc as y,cl as b,fs as x,hs as S,io as C,kt as w,ms as T,ps as E,qo as D,ro as O,zc as k,zl as A}from"./index-CH7XN6KY.js";import{n as j,r as M,t as N}from"./settings-page-layout-HdlQOOqp.js";import{n as ee}from"./settings-loading-skeleton-vitElc-n.js";import{t as P}from"./page-tabs-DMlQERNg.js";import{r as te,t as F}from"./channel-recipient-api-Bea6if_6.js";import{n as ne,t as re}from"./channels-status-swr-CuU6ez3y.js";import{t as I}from"./schedule-field-CxYDObjT.js";import{n as ie,t as ae}from"./save-bar-controls-BZTj3hxl.js";var L=e(t(),1),R=n();function z(){return s(`/api/workspace/heartbeat-md`)}async function oe(){let e=await c(z());return typeof e.payload?.content==`string`?e.payload.content:``}function B(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function se(e){let t=B(e)?e:{},n=B(t.gateway)?t.gateway:{},r=B(n.heartbeat)?n.heartbeat:{},i=r.activeHours,a=B(i)?i:null,o=a&&typeof a.start==`string`&&typeof a.end==`string`&&a.start&&a.end?{start:a.start,end:a.end,timezone:typeof a.timezone==`string`?a.timezone:``}:null;return{enabled:!!(r.enabled??!0),intervalMs:typeof r.intervalMs==`number`&&Number.isFinite(r.intervalMs)?r.intervalMs:18e5,includeSystemPromptSection:r.includeSystemPromptSection===!0,target:typeof r.target==`string`?r.target:``,targetChatId:typeof r.targetChatId==`string`?r.targetChatId:``,prompt:typeof r.prompt==`string`?r.prompt:``,ackMaxChars:typeof r.ackMaxChars==`number`&&Number.isFinite(r.ackMaxChars)?r.ackMaxChars:``,isolatedSession:!!r.isolatedSession,activeHours:o}}function V(e){let t={enabled:e.enabled,intervalMs:e.intervalMs,includeSystemPromptSection:e.includeSystemPromptSection};return e.target.trim()?t.target=e.target.trim():t.target=null,e.targetChatId.trim()?t.targetChatId=e.targetChatId.trim():t.targetChatId=null,e.prompt.trim()?t.prompt=e.prompt.trim():t.prompt=null,e.ackMaxChars===``||e.ackMaxChars===void 0?t.ackMaxChars=null:t.ackMaxChars=e.ackMaxChars,e.isolatedSession?t.isolatedSession=!0:t.isolatedSession=null,e.activeHours?.start?.trim()&&e.activeHours?.end?.trim()?t.activeHours={start:e.activeHours.start.trim(),end:e.activeHours.end.trim(),...e.activeHours.timezone.trim()?{timezone:e.activeHours.timezone.trim()}:{}}:t.activeHours=null,t}async function ce(e){await c(s(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{heartbeat:V(e)}})}),O()}async function le(e){await c(s(`/api/workspace/heartbeat-md`),{method:`PUT`,body:JSON.stringify({content:e})}),f(z())}async function ue(e){await c(s(`/api/heartbeat/trigger`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e?{reason:e}:{})})}var H=r();function U(){return a(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,T,`dark:border-edge`)}function de(){return a(E,x)}var W=[`schedule`,`delivery`,`prompt`,`document`],G={schedule:A,delivery:h,prompt:b,document:_};function fe(e){return e&&W.includes(e)?e:`schedule`}function K(e,t){return t===`schedule`?e.tabSchedule:t===`delivery`?e.tabDelivery:t===`prompt`?e.tabPrompt:e.tabDocument}function pe(e,t){return t===`schedule`?e.scheduleTabHint:t===`delivery`?e.deliveryTabHint:t===`prompt`?e.promptTabHint:e.documentTabHint}function me(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}case`patch`:return{...e,form:e.form?{...e.form,...t.patch}:null};case`discard`:return e.baseline?{form:structuredClone(e.baseline),baseline:e.baseline}:e;case`saved`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}}}function he(e,t){switch(t.type){case`reset`:return{doc:``,baseline:``};case`sync`:return{doc:t.value,baseline:t.value};case`set`:return{...e,doc:t.value};case`discard`:return{...e,doc:e.baseline};case`saved`:return{doc:t.value,baseline:t.value}}}function ge(e){if(!e||typeof e!=`object`||Array.isArray(e))return``;let t=e.agents;if(!t||typeof t!=`object`||Array.isArray(t))return``;let n=t;if(!Array.isArray(n.list))return``;let r=typeof n.default==`string`?n.default:``,i=n.list.find(e=>!e||typeof e!=`object`||Array.isArray(e)?!1:r?e.id===r:!0)??n.list[0];if(!i||typeof i!=`object`||Array.isArray(i))return``;let a=i.workspace;if(!a||typeof a!=`object`||Array.isArray(a))return``;let o=a.root;return typeof o==`string`?o:``}var _e={saving:!1,error:null,triggerLoading:!1,triggerOk:!1,triggerError:null};function q(){let e=l(e=>e.language),t=o(e),n=t.heartbeatSettings,r=!!u(e=>e.token),[s,c]=i(),f=fe(s.get(`tab`)),m=(0,L.useCallback)(e=>{c(t=>{let n=new URLSearchParams(t);return e===`schedule`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[c]),[h,_]=(0,L.useReducer)(me,{form:null,baseline:null}),y=h.form,b=h.baseline,[x,T]=(0,L.useReducer)(he,{doc:``,baseline:``}),E=x.doc,D=x.baseline,[O,A]=(0,L.useReducer)(w,_e),{saving:M,error:P,triggerLoading:F,triggerOk:I,triggerError:R}=O,B=(0,L.useRef)(!1),V=(0,L.useRef)(!1),{data:W,error:G,isLoading:K,mutate:pe}=C(r),{data:q,error:Y,isLoading:xe,mutate:Ce}=d(r?z():null,oe,{revalidateOnFocus:!1}),{data:we=[]}=d(r?re():null,ne,{revalidateOnFocus:!1}),Te=(0,L.useMemo)(()=>ge(W?.payload?.config),[W]),Ee=(0,L.useMemo)(()=>se(W?.payload?.config??{}),[W]),X=(0,L.useMemo)(()=>!y||!b?!1:JSON.stringify(y)!==JSON.stringify(b),[y,b]),Z=E!==D;(0,L.useEffect)(()=>{if(!r){_({type:`reset`}),B.current=!1;return}W!==void 0&&(B.current||_({type:`sync`,value:Ee}))},[r,W,Ee]),(0,L.useEffect)(()=>{if(!r){T({type:`reset`}),V.current=!1;return}q!==void 0&&(V.current||T({type:`sync`,value:q}))},[r,q]);let De=G instanceof Error?G.message:G?String(G):Y instanceof Error?Y.message:Y?String(Y):null,Oe=!!(r&&(W===void 0||q===void 0)&&!De&&(K||xe)),Q=y?.target.trim()??``,{data:ke,setData:Ae}=g(()=>te(Q),[r,Q],{enabled:r&&Q.length>0,initial:[],errorData:[]}),je=(0,L.useCallback)(()=>{Q&&te(Q).then(Ae)},[Q,Ae]),Me=(0,L.useCallback)(async()=>{A({type:`patch`,patch:{triggerLoading:!0,triggerOk:!1,triggerError:null}});try{await ue(),A({type:`patch`,patch:{triggerOk:!0}}),window.setTimeout(()=>A({type:`patch`,patch:{triggerOk:!1}}),3e3)}catch(e){A({type:`patch`,patch:{triggerError:e instanceof Error?e.message:n.triggerError}})}finally{A({type:`patch`,patch:{triggerLoading:!1}})}},[n.triggerError]),$=(0,L.useCallback)(e=>{B.current=!0,_({type:`patch`,patch:e})},[]),Ne=X||Z,Pe=(0,L.useCallback)(()=>{_({type:`discard`}),T({type:`discard`}),B.current=!1,V.current=!1,A({type:`patch`,patch:{error:null}})},[]);return ie({id:`heartbeat`,dirty:Ne,saving:M,save:(0,L.useCallback)(async()=>{if(!(!y||M)){A({type:`patch`,patch:{saving:!0,error:null}});try{X&&(await ce(y),_({type:`saved`,value:y}),B.current=!1),Z&&(await le(E),T({type:`saved`,value:E}),V.current=!1)}catch(e){let t=X?n.saveConfigError:n.saveDocError,r=e instanceof Error?e.message:t;throw A({type:`patch`,patch:{error:r}}),Error(r)}finally{A({type:`patch`,patch:{saving:!1}})}}},[X,Z,E,y,n.saveConfigError,n.saveDocError,M]),discard:Pe}),r?Oe?(0,H.jsx)(N,{gap:`gap-6`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,H.jsx)(ee,{sections:3})}):y?(0,H.jsxs)(N,{"aria-busy":M,"data-has-baseline":b?`1`:`0`,children:[(0,H.jsx)(j,{title:t.settingsSections.heartbeat,subtitle:n.subtitle,docsLink:p(e,`heartbeat`),docsLabel:n.docsLink,actions:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(S,{type:`button`,variant:`secondary`,className:`inline-flex items-center gap-2`,disabled:F,onClick:()=>void Me(),children:[F?(0,H.jsx)(k,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,H.jsx)(v,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),F?n.triggering:n.triggerNow]}),I?(0,H.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.triggered}):null]})}),(0,H.jsx)(ae,{}),Te?(0,H.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[n.workspaceLabel,`: `,(0,H.jsx)(`span`,{className:`font-mono text-fg-muted`,children:Te})]}):null,P?(0,H.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:P}):null,R?(0,H.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:R}):null,(0,H.jsx)(ve,{h:n,activeTab:f,onChange:m}),(0,H.jsx)(J,{h:n,id:`schedule`,activeTab:f,children:(0,H.jsx)(ye,{h:n,form:y,update:$})}),(0,H.jsx)(J,{h:n,id:`delivery`,activeTab:f,children:(0,H.jsx)(be,{h:n,cron:t.cron,form:y,channels:we,sessionChatIds:ke,onRefreshChatIds:je,update:$,inputClassName:U,selectClassName:de})}),(0,H.jsx)(J,{h:n,id:`prompt`,activeTab:f,children:(0,H.jsx)(Se,{h:n,form:y,update:$,inputClassName:U})}),(0,H.jsxs)(J,{h:n,id:`document`,activeTab:f,children:[(0,H.jsx)(`p`,{className:`mb-3 text-xs text-fg-subtle`,children:n.docHint}),(0,H.jsx)(`textarea`,{className:a(U(),`min-h-72 resize-y font-mono text-xs leading-relaxed`),value:E,onChange:e=>{V.current=!0,T({type:`set`,value:e.target.value})},spellCheck:!1,"aria-label":n.docSection,"data-doc-in-sync":E===D?`true`:`false`})]})]}):(0,H.jsxs)(N,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:P??De??n.loadError}),(0,H.jsx)(S,{type:`button`,variant:`secondary`,onClick:()=>{pe(),Ce()},children:n.retry})]}):(0,H.jsxs)(N,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,H.jsx)(j,{title:t.settingsSections.heartbeat}),(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})]})}function ve(e){let t=(0,R.c)(7),{h:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=W.map(e=>({id:e,label:K(n,e),icon:G[e]})),t[0]=n,t[1]=a);let o=a,s;return t[2]!==r||t[3]!==n.tabsAriaLabel||t[4]!==o||t[5]!==i?(s=(0,H.jsx)(P,{items:o,activeTab:r,onChange:i,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`heartbeat-settings-tab`,panelIdPrefix:`heartbeat-settings-panel`}),t[2]=r,t[3]=n.tabsAriaLabel,t[4]=o,t[5]=i,t[6]=s):s=t[6],s}function J(e){let t=(0,R.c)(14),{h:n,id:r,activeTab:i,children:a}=e,o;t[0]!==n||t[1]!==r?(o=K(n,r),t[0]=n,t[1]=r,t[2]=o):o=t[2];let s;t[3]!==n||t[4]!==r?(s=pe(n,r),t[3]=n,t[4]=r,t[5]=s):s=t[5];let c;t[6]===a?c=t[7]:(c=(0,H.jsx)(`div`,{className:`space-y-4`,children:a}),t[6]=a,t[7]=c);let l;return t[8]!==i||t[9]!==r||t[10]!==o||t[11]!==s||t[12]!==c?(l=(0,H.jsx)(M,{id:r,activeTab:i,tabIdPrefix:`heartbeat-settings-tab`,panelIdPrefix:`heartbeat-settings-panel`,title:o,hint:s,children:c}),t[8]=i,t[9]=r,t[10]=o,t[11]=s,t[12]=c,t[13]=l):l=t[13],l}function ye(e){let t=(0,R.c)(37),{h:n,form:r,update:i}=e,a;t[0]===i?a=t[1]:(a=e=>i({enabled:e.target.checked}),t[0]=i,t[1]=a);let o;t[2]!==r.enabled||t[3]!==a?(o=(0,H.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.enabled,onChange:a}),t[2]=r.enabled,t[3]=a,t[4]=o):o=t[4];let s;t[5]!==n.enable||t[6]!==o?(s=(0,H.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[o,n.enable]}),t[5]=n.enable,t[6]=o,t[7]=s):s=t[7];let c;t[8]===i?c=t[9]:(c=e=>i({intervalMs:e}),t[8]=i,t[9]=c);let l;t[10]!==n.intervalPresets||t[11]!==n.intervalSecondsLabel?(l={secondsLabel:n.intervalSecondsLabel,presets:n.intervalPresets},t[10]=n.intervalPresets,t[11]=n.intervalSecondsLabel,t[12]=l):l=t[12];let u=`${n.intervalHintPreset} ${n.intervalHint}`,d;t[13]!==r.intervalMs||t[14]!==n.interval||t[15]!==c||t[16]!==l||t[17]!==u?(d=(0,H.jsx)(I,{kind:`interval`,label:n.interval,valueMs:r.intervalMs,onChangeMs:c,labels:l,hint:u}),t[13]=r.intervalMs,t[14]=n.interval,t[15]=c,t[16]=l,t[17]=u,t[18]=d):d=t[18];let f;t[19]===i?f=t[20]:(f=e=>i({activeHours:e}),t[19]=i,t[20]=f);let p;t[21]!==n.activeEnd||t[22]!==n.activeStart||t[23]!==n.activeTimezone||t[24]!==n.addActiveHours||t[25]!==n.clearActiveHours?(p={start:n.activeStart,end:n.activeEnd,timezone:n.activeTimezone,add:n.addActiveHours,clear:n.clearActiveHours},t[21]=n.activeEnd,t[22]=n.activeStart,t[23]=n.activeTimezone,t[24]=n.addActiveHours,t[25]=n.clearActiveHours,t[26]=p):p=t[26];let m;t[27]!==r.activeHours||t[28]!==n.activeHoursHint||t[29]!==n.activeHoursTitle||t[30]!==f||t[31]!==p?(m=(0,H.jsx)(I,{kind:`active-hours`,label:n.activeHoursTitle,value:r.activeHours,onChange:f,labels:p,hint:n.activeHoursHint}),t[27]=r.activeHours,t[28]=n.activeHoursHint,t[29]=n.activeHoursTitle,t[30]=f,t[31]=p,t[32]=m):m=t[32];let h;return t[33]!==m||t[34]!==s||t[35]!==d?(h=(0,H.jsxs)(H.Fragment,{children:[s,d,m]}),t[33]=m,t[34]=s,t[35]=d,t[36]=h):h=t[36],h}function be(e){let t=(0,R.c)(51),{h:n,cron:r,form:i,channels:o,sessionChatIds:s,onRefreshChatIds:c,update:l,inputClassName:u,selectClassName:d}=e,f;t[0]===o?f=t[1]:(f=new Set(o.map(xe)),t[0]=o,t[1]=f);let p=f,h;t[2]===i.target?h=t[3]:(h=i.target.trim(),t[2]=i.target,t[3]=h);let g=h,_=!!(g&&!p.has(g)),v;t[4]===n.deliveryHint?v=t[5]:(v=(0,H.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.deliveryHint}),t[4]=n.deliveryHint,t[5]=v);let b;t[6]===r.channel?b=t[7]:(b=(0,H.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:r.channel}),t[6]=r.channel,t[7]=b);let x;t[8]===d?x=t[9]:(x=d(),t[8]=d,t[9]=x);let C;t[10]===l?C=t[11]:(C=e=>{l({target:e.target.value.trim(),targetChatId:``})},t[10]=l,t[11]=C);let w;t[12]===n.channelNone?w=t[13]:(w=(0,H.jsx)(D,{value:``,children:n.channelNone}),t[12]=n.channelNone,t[13]=w);let T;t[14]!==n.customChannelSuffix||t[15]!==_||t[16]!==g?(T=_?(0,H.jsxs)(D,{value:g,children:[g,` (`,n.customChannelSuffix,`)`]}):null,t[14]=n.customChannelSuffix,t[15]=_,t[16]=g,t[17]=T):T=t[17];let E;t[18]===o?E=t[19]:(E=o.map(Y),t[18]=o,t[19]=E);let O;t[20]!==x||t[21]!==C||t[22]!==w||t[23]!==T||t[24]!==E||t[25]!==g?(O=(0,H.jsxs)(m,{className:x,value:g,onChange:C,children:[w,T,E]}),t[20]=x,t[21]=C,t[22]=w,t[23]=T,t[24]=E,t[25]=g,t[26]=O):O=t[26];let k;t[27]!==O||t[28]!==b?(k=(0,H.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[b,O]}),t[27]=O,t[28]=b,t[29]=k):k=t[29];let A;t[30]!==r.enterManuallyOrSelect||t[31]!==r.lastActiveLabels||t[32]!==r.noRecentChats||t[33]!==r.noRecentChatsOption||t[34]!==r.recipient||t[35]!==r.recipientPlaceholder||t[36]!==r.refreshList||t[37]!==r.refreshRecipientHint||t[38]!==r.selectRecipient||t[39]!==i.targetChatId||t[40]!==u||t[41]!==c||t[42]!==d||t[43]!==s||t[44]!==g||t[45]!==l?(A=g?(0,H.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,H.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:r.recipient}),(0,H.jsxs)(S,{type:`button`,variant:`ghost`,className:`h-7 gap-1 px-2 text-xs`,title:r.refreshRecipientHint,onClick:c,children:[(0,H.jsx)(y,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),r.refreshList]})]}),(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsx)(`input`,{type:`text`,className:a(u(),`min-w-0 flex-1`),value:i.targetChatId,onChange:e=>l({targetChatId:e.target.value}),placeholder:r.recipientPlaceholder,autoComplete:`off`}),(0,H.jsxs)(m,{className:a(d(),`max-w-40 shrink-0 text-xs`),value:i.targetChatId,onChange:e=>{let t=e.target.value;t&&l({targetChatId:t})},children:[(0,H.jsx)(D,{value:``,children:r.selectRecipient}),s.length>0?s.map(e=>(0,H.jsx)(D,{value:e.chatId,children:F(e,r.lastActiveLabels)},`${e.channel}-${e.chatId}`)):(0,H.jsx)(D,{value:``,disabled:!0,children:r.noRecentChatsOption})]})]}),(0,H.jsx)(`p`,{className:`text-xs text-fg-muted`,children:s.length>0?r.enterManuallyOrSelect:r.noRecentChats})]}):null,t[30]=r.enterManuallyOrSelect,t[31]=r.lastActiveLabels,t[32]=r.noRecentChats,t[33]=r.noRecentChatsOption,t[34]=r.recipient,t[35]=r.recipientPlaceholder,t[36]=r.refreshList,t[37]=r.refreshRecipientHint,t[38]=r.selectRecipient,t[39]=i.targetChatId,t[40]=u,t[41]=c,t[42]=d,t[43]=s,t[44]=g,t[45]=l,t[46]=A):A=t[46];let j;return t[47]!==k||t[48]!==A||t[49]!==v?(j=(0,H.jsxs)(H.Fragment,{children:[v,k,A]}),t[47]=k,t[48]=A,t[49]=v,t[50]=j):j=t[50],j}function Y(e){return(0,H.jsxs)(D,{value:e.name,disabled:!e.enabled,children:[e.name,` `,e.enabled?``:`(disabled)`]},e.name)}function xe(e){return e.name}function Se(e){let t=(0,R.c)(65),{h:n,form:r,update:i,inputClassName:o}=e,s;t[0]===i?s=t[1]:(s=e=>i({includeSystemPromptSection:e.target.checked}),t[0]=i,t[1]=s);let c;t[2]!==r.includeSystemPromptSection||t[3]!==s?(c=(0,H.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.includeSystemPromptSection,onChange:s}),t[2]=r.includeSystemPromptSection,t[3]=s,t[4]=c):c=t[4];let l;t[5]===n.includeSystemPromptSectionHint?l=t[6]:(l=(0,H.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:n.includeSystemPromptSectionHint}),t[5]=n.includeSystemPromptSectionHint,t[6]=l);let u;t[7]!==n.includeSystemPromptSection||t[8]!==l?(u=(0,H.jsxs)(`span`,{children:[n.includeSystemPromptSection,l]}),t[7]=n.includeSystemPromptSection,t[8]=l,t[9]=u):u=t[9];let d;t[10]!==c||t[11]!==u?(d=(0,H.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[c,u]}),t[10]=c,t[11]=u,t[12]=d):d=t[12];let f;t[13]===n.prompt?f=t[14]:(f=(0,H.jsx)(`div`,{className:`mb-1 text-sm font-medium text-fg`,children:n.prompt}),t[13]=n.prompt,t[14]=f);let p;t[15]===o?p=t[16]:(p=a(o(),`min-h-36 resize-y font-mono text-xs`),t[15]=o,t[16]=p);let m;t[17]===i?m=t[18]:(m=e=>i({prompt:e.target.value}),t[17]=i,t[18]=m);let h;t[19]!==r.prompt||t[20]!==n.promptPlaceholder||t[21]!==p||t[22]!==m?(h=(0,H.jsx)(`textarea`,{className:p,value:r.prompt,onChange:m,placeholder:n.promptPlaceholder}),t[19]=r.prompt,t[20]=n.promptPlaceholder,t[21]=p,t[22]=m,t[23]=h):h=t[23];let g;t[24]===n.promptHint?g=t[25]:(g=(0,H.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.promptHint}),t[24]=n.promptHint,t[25]=g);let _;t[26]!==g||t[27]!==f||t[28]!==h?(_=(0,H.jsxs)(`div`,{children:[f,h,g]}),t[26]=g,t[27]=f,t[28]=h,t[29]=_):_=t[29];let v;t[30]===n.ackMaxChars?v=t[31]:(v=(0,H.jsx)(`div`,{className:`mb-1 text-sm font-medium text-fg`,children:n.ackMaxChars}),t[30]=n.ackMaxChars,t[31]=v);let y;t[32]===o?y=t[33]:(y=o(),t[32]=o,t[33]=y);let b=r.ackMaxChars===``?``:r.ackMaxChars,x;t[34]===i?x=t[35]:(x=e=>{let t=e.target.value;if(t===``){i({ackMaxChars:``});return}let n=parseInt(t,10);i({ackMaxChars:Number.isFinite(n)?n:``})},t[34]=i,t[35]=x);let S;t[36]!==n.ackDefaultPlaceholder||t[37]!==y||t[38]!==b||t[39]!==x?(S=(0,H.jsx)(`input`,{type:`number`,min:1,className:y,value:b,onChange:x,placeholder:n.ackDefaultPlaceholder}),t[36]=n.ackDefaultPlaceholder,t[37]=y,t[38]=b,t[39]=x,t[40]=S):S=t[40];let C;t[41]===n.ackMaxCharsHint?C=t[42]:(C=(0,H.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.ackMaxCharsHint}),t[41]=n.ackMaxCharsHint,t[42]=C);let w;t[43]!==v||t[44]!==S||t[45]!==C?(w=(0,H.jsxs)(`div`,{children:[v,S,C]}),t[43]=v,t[44]=S,t[45]=C,t[46]=w):w=t[46];let T;t[47]===i?T=t[48]:(T=e=>i({isolatedSession:e.target.checked}),t[47]=i,t[48]=T);let E;t[49]!==r.isolatedSession||t[50]!==T?(E=(0,H.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.isolatedSession,onChange:T}),t[49]=r.isolatedSession,t[50]=T,t[51]=E):E=t[51];let D;t[52]===n.isolatedSessionHint?D=t[53]:(D=(0,H.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:n.isolatedSessionHint}),t[52]=n.isolatedSessionHint,t[53]=D);let O;t[54]!==n.isolatedSession||t[55]!==D?(O=(0,H.jsxs)(`span`,{children:[n.isolatedSession,D]}),t[54]=n.isolatedSession,t[55]=D,t[56]=O):O=t[56];let k;t[57]!==E||t[58]!==O?(k=(0,H.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[E,O]}),t[57]=E,t[58]=O,t[59]=k):k=t[59];let A;return t[60]!==_||t[61]!==w||t[62]!==k||t[63]!==d?(A=(0,H.jsxs)(H.Fragment,{children:[d,_,w,k]}),t[60]=_,t[61]=w,t[62]=k,t[63]=d,t[64]=A):A=t[64],A}export{q as HeartbeatSettingsPanel};
|