specrails-desktop 2.55.1 → 2.56.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/cli/dist/args.js +1 -8
  2. package/cli/dist/help.js +1 -7
  3. package/client/dist/assets/{ActivityFeedPage-DmJcQpNe.js → ActivityFeedPage-DdMNmVBk.js} +1 -1
  4. package/client/dist/assets/{AgentBrowserCapture-NxBHrU-V.js → AgentBrowserCapture-CeerUf--.js} +1 -1
  5. package/client/dist/assets/{AgentModeAnalyticsPane-CGAKTJfU.js → AgentModeAnalyticsPane-BjGb-8rh.js} +2 -2
  6. package/client/dist/assets/{AgentModeCodePane-DNSs5_oe.js → AgentModeCodePane-8XRkQEo_.js} +2 -2
  7. package/client/dist/assets/{AgentModeJobsPane-DLoVYDnG.js → AgentModeJobsPane-BN3dgJOA.js} +1 -1
  8. package/client/dist/assets/{AgentsPage-CAzMn9Gg.js → AgentsPage-DfHWgP_x.js} +1 -1
  9. package/client/dist/assets/{AnalyticsPage-C06KT4Y0.js → AnalyticsPage-CyfhYiBn.js} +1 -1
  10. package/client/dist/assets/{CodePage-aX1mxGyT.js → CodePage-C2Nf-Q5W.js} +1 -1
  11. package/client/dist/assets/{DesktopAnalyticsPage-BtscfiQD.js → DesktopAnalyticsPage-tc0p4jJW.js} +1 -1
  12. package/client/dist/assets/{DocsDialog-CNOcXhp-.js → DocsDialog-Br3bczCp.js} +1 -1
  13. package/client/dist/assets/{DocsPage-C2BugxaI.js → DocsPage-BcDr2cBm.js} +1 -1
  14. package/client/dist/assets/{InteractiveJobComposer-CCncBqNu.js → InteractiveJobComposer-DFPpdg2D.js} +1 -1
  15. package/client/dist/assets/{JobDetailModal-Cn_k3-RM.js → JobDetailModal-BdOv-l-M.js} +1 -1
  16. package/client/dist/assets/{JobDetailPage-BogJFBsk.js → JobDetailPage-vBbNeRuz.js} +1 -1
  17. package/client/dist/assets/{JobsPage-DL4E8ZyU.js → JobsPage-CJCtPhIz.js} +1 -1
  18. package/client/dist/assets/{LoopBuilderPage-9L6URQLY.js → LoopBuilderPage-BemvUOxy.js} +1 -1
  19. package/client/dist/assets/{LoopPreviewModal-CAPqTIgL.js → LoopPreviewModal-C6hNAeYN.js} +1 -1
  20. package/client/dist/assets/{LoopsPage-aU8dYw7L.js → LoopsPage-BZr0quvh.js} +1 -1
  21. package/client/dist/assets/{PluginsPage-D_tsW9B5.js → PluginsPage-DOpTV75p.js} +1 -1
  22. package/client/dist/assets/{ProjectSettingsDialog-_ZbNuspP.js → ProjectSettingsDialog-Dkwrn0z1.js} +1 -1
  23. package/client/dist/assets/{ReviewPacketPage-CG-Dv0El.js → ReviewPacketPage-DcOq-UTA.js} +1 -1
  24. package/client/dist/assets/{TemplatePreviewModal-C19H2b2o.js → TemplatePreviewModal-Cejcquah.js} +1 -1
  25. package/client/dist/assets/{index-BcligJ3-.js → index-Cxb288Rj.js} +8 -8
  26. package/client/dist/index.html +1 -1
  27. package/docs/internals/adding-a-provider.md +7 -0
  28. package/docs/internals/core-runtime-updates.md +5 -0
  29. package/docs/internals/programmatic-agent-runtime.md +66 -0
  30. package/docs/internals/source-map.md +3 -1
  31. package/package.json +1 -1
  32. package/server/dist/core-compat.js +7 -10
  33. package/server/dist/mcp/guide.js +16 -2
  34. package/server/dist/mcp/tools/catalog.js +2 -0
  35. package/server/dist/mcp/tools/jobs.js +22 -4
  36. package/server/dist/mcp/tools/recovery.js +35 -0
  37. package/server/dist/mcp/tools/support.js +4 -1
  38. package/server/dist/modules/accounting/runtime/pricing.js +9 -2
  39. package/server/dist/modules/agent-runtime/runtime/agent-runtime-controls-router.js +16 -0
  40. package/server/dist/modules/agent-runtime/runtime/agent-runtime-controls.js +93 -1
  41. package/server/dist/modules/agent-runtime/runtime/agent-runtime-recovery.js +53 -0
  42. package/server/dist/modules/missions/runtime/agent-failure-briefing.js +4 -2
  43. package/server/dist/modules/missions/runtime/agent-operator-prompt.js +58 -5
  44. package/server/dist/modules/missions/runtime/mission-run-notify.js +4 -1
  45. package/server/dist/providers/claude-adapter.js +3 -2
  46. package/.claude/commands/specrails/compat-check.md +0 -271
  47. package/.claude/commands/specrails/doctor.md +0 -62
  48. package/.claude/commands/specrails/enrich.md +0 -1635
  49. package/.claude/commands/specrails/explore-spec.md +0 -173
  50. package/.claude/commands/specrails/health-check.md +0 -527
  51. package/.claude/commands/specrails/memory-inspect.md +0 -259
  52. package/.claude/commands/specrails/opsx-diff.md +0 -419
  53. package/.claude/commands/specrails/propose-spec.md +0 -102
  54. package/.claude/commands/specrails/reconfig.md +0 -89
  55. package/.claude/commands/specrails/refactor-recommender.md +0 -212
  56. package/.claude/commands/specrails/telemetry.md +0 -552
  57. package/.claude/commands/specrails/why.md +0 -96
package/cli/dist/args.js CHANGED
@@ -9,14 +9,7 @@ exports.DEFAULT_PORT = 4200;
9
9
  exports.KNOWN_VERBS = new Set([
10
10
  'implement',
11
11
  'batch-implement',
12
- 'why',
13
- 'get-backlog-specs',
14
- 'auto-propose-backlog-specs',
15
- 'propose-spec',
16
- 'refactor-recommender',
17
- 'health-check',
18
- 'compat-check',
19
- 'enrich',
12
+ 'retry',
20
13
  ]);
21
14
  function parseArgs(argv) {
22
15
  // argv is process.argv.slice(2)
package/cli/dist/help.js CHANGED
@@ -45,13 +45,7 @@ ${(0, output_1.bold)('Project Required:')}
45
45
  ${(0, output_1.bold)('Usage:')}
46
46
  specrails-desktop implement #42 Run a known specrails verb (prepends /specrails:)
47
47
  specrails-desktop batch-implement #40 #41 Batch implementation across issues
48
- specrails-desktop why Explain recent changes
49
- specrails-desktop get-backlog-specs View prioritized spec backlog
50
- specrails-desktop auto-propose-backlog-specs Generate new spec ideas
51
- specrails-desktop propose-spec Explore an idea and produce a spec
52
- specrails-desktop refactor-recommender Find refactoring opportunities
53
- specrails-desktop health-check Run codebase health check
54
- specrails-desktop compat-check Check for breaking API changes
48
+ specrails-desktop retry Resume the saved implementation run
55
49
  specrails-desktop "any raw prompt" Pass a raw prompt directly to claude
56
50
  specrails-desktop --status Print manager status and exit
57
51
  specrails-desktop --jobs Print recent job history and exit
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{h as r,r as i}from"./useSharedWebSocket-Dz-HI6De.js";import{n as a}from"./createLucideIcon-Bjbbp_KS.js";import{a as o,r as s}from"./useDesktop-QogiN0zR.js";import{n as c,t as l}from"./zap-CUOlvtT1.js";import{t as u}from"./circle-x-CMYsN4ZH.js";import{t as d}from"./loader-circle-DcygOQpC.js";import{Ft as f,Gt as p}from"./index-BcligJ3-.js";var m=e(t(),1);function h(e){let t=new Set;return e.filter(e=>{let n=`${e.type}:${e.jobId}`;return t.has(n)?!1:(t.add(n),!0)})}function g({activeProjectId:e,limit:t=50}){let[n,a]=(0,m.useState)([]),[s,c]=(0,m.useState)(!1),[l,u]=(0,m.useState)(!0),d=(0,m.useRef)(e);(0,m.useEffect)(()=>{d.current=e},[e]);let{registerHandler:f,unregisterHandler:p}=i();(0,m.useEffect)(()=>{if(!e){a([]),u(!0);return}let n=!1;c(!0),a([]),u(!0);async function r(){let e=o();try{let r=await fetch(`${e}/activity?limit=${t}`);if(!r.ok||n)return;let i=await r.json();if(n)return;a(i),u(i.length===t)}catch{}finally{n||c(!1)}}return r(),()=>{n=!0}},[e,t]);let g=(0,m.useCallback)(async()=>{if(s||!l)return;c(!0);let e=o(),n=d.current;try{a(r=>{let i=r[r.length-1];if(!i)return r;let o=encodeURIComponent(i.timestamp);return fetch(`${e}/activity?limit=${t}&before=${o}`).then(e=>e.json()).then(e=>{if(d.current!==n){c(!1);return}a(t=>h([...t,...e])),u(e.length===t),c(!1)}).catch(()=>c(!1)),r})}catch{c(!1)}},[s,l,t]),_=(0,m.useCallback)(e=>{let t=e,n=d.current;if(!(!t||typeof t.type!=`string`)&&!(t.projectId&&t.projectId!==n)){if(t.type===`queue`&&Array.isArray(t.jobs)){let e=[];for(let n of t.jobs){let t=n.status===`completed`?`job_completed`:n.status===`failed`?`job_failed`:n.status===`canceled`?`job_canceled`:`job_started`;e.push({id:`${t}:${n.id}`,type:t,jobId:n.id,jobCommand:n.command??``,timestamp:n.startedAt??new Date().toISOString(),summary:`${t.replace(`_`,` `)}: ${n.command??``}`,costUsd:null})}e.length>0&&a(t=>h([...e,...t]))}if(t.type===`phase`&&t.phase&&t.state&&t.timestamp){let e={id:`phase:${t.phase}:${t.state}:${t.timestamp}`,type:`job_started`,jobId:`phase-${t.phase}`,jobCommand:r.t(`activity:feed.phaseCommand`,{phase:t.phase,state:t.state}),timestamp:t.timestamp,summary:`Phase ${t.phase} is ${t.state}`,costUsd:null};a(t=>h([e,...t]))}}},[]);return(0,m.useLayoutEffect)(()=>(f(`activity`,_),()=>p(`activity`)),[_,f,p]),{items:n,loading:s,hasMore:l,loadMore:g}}var _=n();function v(e,t){let n=Date.now()-new Date(e).getTime(),r=Math.floor(n/1e3);if(r<60)return t(`feed.relativeTime.seconds`,{value:r});let i=Math.floor(r/60);if(i<60)return t(`feed.relativeTime.minutes`,{value:i});let a=Math.floor(i/60);return a<24?t(`feed.relativeTime.hours`,{value:a}):t(`feed.relativeTime.days`,{value:Math.floor(a/24)})}function y({type:e}){switch(e){case`job_completed`:return(0,_.jsx)(f,{className:`w-4 h-4 text-green-500 aurora-light:text-accent-success flex-shrink-0`});case`job_failed`:return(0,_.jsx)(u,{className:`w-4 h-4 text-red-500 aurora-light:text-destructive flex-shrink-0`});case`job_canceled`:return(0,_.jsx)(c,{className:`w-4 h-4 text-muted-foreground flex-shrink-0`});default:return(0,_.jsx)(l,{className:`w-4 h-4 text-blue-500 aurora-light:text-accent-info flex-shrink-0`})}}function b(e,t){switch(e){case`job_completed`:return t(`common:status.completed`);case`job_failed`:return t(`common:status.failed`);case`job_canceled`:return t(`common:status.canceled`);default:return t(`feed.typeStarted`)}}function x(e){switch(e){case`job_completed`:return`text-green-500 aurora-light:text-accent-success`;case`job_failed`:return`text-red-500 aurora-light:text-destructive`;case`job_canceled`:return`text-muted-foreground`;default:return`text-blue-500 aurora-light:text-accent-info`}}function S(){let{t:e}=a(`activity`),{activeProjectId:t}=s(),{items:n,loading:r,hasMore:i,loadMore:o}=g({activeProjectId:t}),c=(0,m.useRef)(null);return(0,m.useEffect)(()=>{let e=c.current;if(!e)return;let t=new IntersectionObserver(e=>{e[0].isIntersecting&&i&&!r&&o()},{threshold:.1});return t.observe(e),()=>t.disconnect()},[i,r,o]),(0,_.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-3 border-b border-border bg-background/50`,children:[(0,_.jsx)(p,{className:`w-4 h-4 text-muted-foreground`}),(0,_.jsx)(`h1`,{className:`text-sm font-medium`,children:e(`feed.title`)})]}),(0,_.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[r&&n.length===0?(0,_.jsx)(`div`,{className:`flex items-center justify-center h-32`,children:(0,_.jsx)(d,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):n.length===0?(0,_.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-48 gap-2 text-muted-foreground`,children:[(0,_.jsx)(p,{className:`w-8 h-8 opacity-40`}),(0,_.jsx)(`p`,{className:`text-sm`,children:e(`feed.emptyTitle`)}),(0,_.jsx)(`p`,{className:`text-xs opacity-70`,children:e(`feed.emptyHint`)})]}):(0,_.jsx)(`ul`,{className:`divide-y divide-border/50`,children:n.map(t=>(0,_.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-2.5 hover:bg-accent/30 transition-colors`,children:[(0,_.jsx)(y,{type:t.type}),(0,_.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,_.jsx)(`p`,{className:`text-xs text-foreground truncate`,title:t.jobCommand,children:t.jobCommand}),(0,_.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5`,children:[(0,_.jsx)(`span`,{className:`text-xs font-medium ${x(t.type)}`,children:b(t.type,e)}),t.costUsd!=null&&(0,_.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`$`,t.costUsd.toFixed(4)]})]})]}),(0,_.jsx)(`span`,{className:`text-xs text-muted-foreground flex-shrink-0 tabular-nums`,children:v(t.timestamp,e)})]},`${t.type}:${t.jobId}`))}),(0,_.jsx)(`div`,{ref:c,className:`h-1`}),r&&n.length>0&&(0,_.jsx)(`div`,{className:`flex justify-center py-3`,children:(0,_.jsx)(d,{className:`w-4 h-4 animate-spin text-muted-foreground`})}),!i&&n.length>0&&(0,_.jsx)(`p`,{className:`text-center text-xs text-muted-foreground py-3`,children:e(`feed.allLoaded`)})]})]})}export{S as default};
1
+ import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{h as r,r as i}from"./useSharedWebSocket-Dz-HI6De.js";import{n as a}from"./createLucideIcon-Bjbbp_KS.js";import{a as o,r as s}from"./useDesktop-QogiN0zR.js";import{n as c,t as l}from"./zap-CUOlvtT1.js";import{t as u}from"./circle-x-CMYsN4ZH.js";import{t as d}from"./loader-circle-DcygOQpC.js";import{Ft as f,Gt as p}from"./index-Cxb288Rj.js";var m=e(t(),1);function h(e){let t=new Set;return e.filter(e=>{let n=`${e.type}:${e.jobId}`;return t.has(n)?!1:(t.add(n),!0)})}function g({activeProjectId:e,limit:t=50}){let[n,a]=(0,m.useState)([]),[s,c]=(0,m.useState)(!1),[l,u]=(0,m.useState)(!0),d=(0,m.useRef)(e);(0,m.useEffect)(()=>{d.current=e},[e]);let{registerHandler:f,unregisterHandler:p}=i();(0,m.useEffect)(()=>{if(!e){a([]),u(!0);return}let n=!1;c(!0),a([]),u(!0);async function r(){let e=o();try{let r=await fetch(`${e}/activity?limit=${t}`);if(!r.ok||n)return;let i=await r.json();if(n)return;a(i),u(i.length===t)}catch{}finally{n||c(!1)}}return r(),()=>{n=!0}},[e,t]);let g=(0,m.useCallback)(async()=>{if(s||!l)return;c(!0);let e=o(),n=d.current;try{a(r=>{let i=r[r.length-1];if(!i)return r;let o=encodeURIComponent(i.timestamp);return fetch(`${e}/activity?limit=${t}&before=${o}`).then(e=>e.json()).then(e=>{if(d.current!==n){c(!1);return}a(t=>h([...t,...e])),u(e.length===t),c(!1)}).catch(()=>c(!1)),r})}catch{c(!1)}},[s,l,t]),_=(0,m.useCallback)(e=>{let t=e,n=d.current;if(!(!t||typeof t.type!=`string`)&&!(t.projectId&&t.projectId!==n)){if(t.type===`queue`&&Array.isArray(t.jobs)){let e=[];for(let n of t.jobs){let t=n.status===`completed`?`job_completed`:n.status===`failed`?`job_failed`:n.status===`canceled`?`job_canceled`:`job_started`;e.push({id:`${t}:${n.id}`,type:t,jobId:n.id,jobCommand:n.command??``,timestamp:n.startedAt??new Date().toISOString(),summary:`${t.replace(`_`,` `)}: ${n.command??``}`,costUsd:null})}e.length>0&&a(t=>h([...e,...t]))}if(t.type===`phase`&&t.phase&&t.state&&t.timestamp){let e={id:`phase:${t.phase}:${t.state}:${t.timestamp}`,type:`job_started`,jobId:`phase-${t.phase}`,jobCommand:r.t(`activity:feed.phaseCommand`,{phase:t.phase,state:t.state}),timestamp:t.timestamp,summary:`Phase ${t.phase} is ${t.state}`,costUsd:null};a(t=>h([e,...t]))}}},[]);return(0,m.useLayoutEffect)(()=>(f(`activity`,_),()=>p(`activity`)),[_,f,p]),{items:n,loading:s,hasMore:l,loadMore:g}}var _=n();function v(e,t){let n=Date.now()-new Date(e).getTime(),r=Math.floor(n/1e3);if(r<60)return t(`feed.relativeTime.seconds`,{value:r});let i=Math.floor(r/60);if(i<60)return t(`feed.relativeTime.minutes`,{value:i});let a=Math.floor(i/60);return a<24?t(`feed.relativeTime.hours`,{value:a}):t(`feed.relativeTime.days`,{value:Math.floor(a/24)})}function y({type:e}){switch(e){case`job_completed`:return(0,_.jsx)(f,{className:`w-4 h-4 text-green-500 aurora-light:text-accent-success flex-shrink-0`});case`job_failed`:return(0,_.jsx)(u,{className:`w-4 h-4 text-red-500 aurora-light:text-destructive flex-shrink-0`});case`job_canceled`:return(0,_.jsx)(c,{className:`w-4 h-4 text-muted-foreground flex-shrink-0`});default:return(0,_.jsx)(l,{className:`w-4 h-4 text-blue-500 aurora-light:text-accent-info flex-shrink-0`})}}function b(e,t){switch(e){case`job_completed`:return t(`common:status.completed`);case`job_failed`:return t(`common:status.failed`);case`job_canceled`:return t(`common:status.canceled`);default:return t(`feed.typeStarted`)}}function x(e){switch(e){case`job_completed`:return`text-green-500 aurora-light:text-accent-success`;case`job_failed`:return`text-red-500 aurora-light:text-destructive`;case`job_canceled`:return`text-muted-foreground`;default:return`text-blue-500 aurora-light:text-accent-info`}}function S(){let{t:e}=a(`activity`),{activeProjectId:t}=s(),{items:n,loading:r,hasMore:i,loadMore:o}=g({activeProjectId:t}),c=(0,m.useRef)(null);return(0,m.useEffect)(()=>{let e=c.current;if(!e)return;let t=new IntersectionObserver(e=>{e[0].isIntersecting&&i&&!r&&o()},{threshold:.1});return t.observe(e),()=>t.disconnect()},[i,r,o]),(0,_.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-3 border-b border-border bg-background/50`,children:[(0,_.jsx)(p,{className:`w-4 h-4 text-muted-foreground`}),(0,_.jsx)(`h1`,{className:`text-sm font-medium`,children:e(`feed.title`)})]}),(0,_.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[r&&n.length===0?(0,_.jsx)(`div`,{className:`flex items-center justify-center h-32`,children:(0,_.jsx)(d,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):n.length===0?(0,_.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-48 gap-2 text-muted-foreground`,children:[(0,_.jsx)(p,{className:`w-8 h-8 opacity-40`}),(0,_.jsx)(`p`,{className:`text-sm`,children:e(`feed.emptyTitle`)}),(0,_.jsx)(`p`,{className:`text-xs opacity-70`,children:e(`feed.emptyHint`)})]}):(0,_.jsx)(`ul`,{className:`divide-y divide-border/50`,children:n.map(t=>(0,_.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-2.5 hover:bg-accent/30 transition-colors`,children:[(0,_.jsx)(y,{type:t.type}),(0,_.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,_.jsx)(`p`,{className:`text-xs text-foreground truncate`,title:t.jobCommand,children:t.jobCommand}),(0,_.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5`,children:[(0,_.jsx)(`span`,{className:`text-xs font-medium ${x(t.type)}`,children:b(t.type,e)}),t.costUsd!=null&&(0,_.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`$`,t.costUsd.toFixed(4)]})]})]}),(0,_.jsx)(`span`,{className:`text-xs text-muted-foreground flex-shrink-0 tabular-nums`,children:v(t.timestamp,e)})]},`${t.type}:${t.jobId}`))}),(0,_.jsx)(`div`,{ref:c,className:`h-1`}),r&&n.length>0&&(0,_.jsx)(`div`,{className:`flex justify-center py-3`,children:(0,_.jsx)(d,{className:`w-4 h-4 animate-spin text-muted-foreground`})}),!i&&n.length>0&&(0,_.jsx)(`p`,{className:`text-center text-xs text-muted-foreground py-3`,children:e(`feed.allLoaded`)})]})]})}export{S as default};
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{d as r,f as i,m as a,u as o}from"./TicketDetailModalContext-DAK-NoK6.js";import{n as s}from"./createLucideIcon-Bjbbp_KS.js";import{s as c}from"./useDesktop-QogiN0zR.js";import{Jt as l,Kt as u,N as d,U as f,et as p,rt as m,y as h}from"./index-BcligJ3-.js";var g=e(t(),1),_=n();function v({projectId:e,conversationId:t}){let{t:n}=s(`agent`),{error:v}=l(),y=m(t??`__new-mission__`),{closeBrowser:b,queueCapture:x,browserOwnerId:S,browserUrl:C,setBrowserUrl:w}=f(),{materializeDraftConversation:T}=d(),[E,D]=(0,g.useState)(!1),[O,k]=(0,g.useState)(!1),[A,j]=(0,g.useState)(`probing`);(0,g.useEffect)(()=>{if(t&&(E||O||A===`screencast`))return p(t)},[t,E,O,A]);let M=(0,g.useMemo)(()=>{if(C)return C;try{return i(localStorage.getItem(`specrails-desktop:agent-browser-url:${e}`)??``)??`about:blank`}catch{return`about:blank`}},[e]);(0,g.useEffect)(()=>{let e=!0;return r().then(t=>{e&&j(t?`native`:`screencast`)}),()=>{e=!1}},[]);let N=(0,g.useMemo)(()=>`agent-${t??`home`}-${Math.round(performance.now())}`,[t]),P=async e=>{k(!0);try{let r=await u(t??(await T()).id,a(e.screenshotDataUrl,`capture-${Date.now()}.png`));x(r),c.success(n(`workspace.browserCaptured`)),b()}catch(e){throw c.error(n(`workspace.uploadFailed`),{description:e instanceof Error?e.message:void 0}),e}finally{k(!1)}};return A===`probing`?null:A===`native`?(0,_.jsx)(o,{ownerId:S??void 0,leaseRevision:y,onBusyChange:D,transferError:v,url:M,onClose:b,onFallback:()=>j(`screencast`),onUrlChange:t=>{if(w(t),i(t)&&t!==`about:blank`)try{localStorage.setItem(`specrails-desktop:agent-browser-url:${e}`,t)}catch{}},confirmLabel:n(`workspace.browserConfirm`),selectLabel:n(`workspace.browserSelectStart`),onCaptured:P}):(0,_.jsx)(h,{open:!0,onClose:b,projectId:e,pendingSpecId:N,confirmLabel:n(`workspace.browserConfirm`),selectLabel:n(`workspace.browserSelectStart`),onCaptured:P})}export{v as AgentBrowserCapture};
1
+ import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{d as r,f as i,m as a,u as o}from"./TicketDetailModalContext-DAK-NoK6.js";import{n as s}from"./createLucideIcon-Bjbbp_KS.js";import{s as c}from"./useDesktop-QogiN0zR.js";import{Jt as l,Kt as u,N as d,U as f,et as p,rt as m,y as h}from"./index-Cxb288Rj.js";var g=e(t(),1),_=n();function v({projectId:e,conversationId:t}){let{t:n}=s(`agent`),{error:v}=l(),y=m(t??`__new-mission__`),{closeBrowser:b,queueCapture:x,browserOwnerId:S,browserUrl:C,setBrowserUrl:w}=f(),{materializeDraftConversation:T}=d(),[E,D]=(0,g.useState)(!1),[O,k]=(0,g.useState)(!1),[A,j]=(0,g.useState)(`probing`);(0,g.useEffect)(()=>{if(t&&(E||O||A===`screencast`))return p(t)},[t,E,O,A]);let M=(0,g.useMemo)(()=>{if(C)return C;try{return i(localStorage.getItem(`specrails-desktop:agent-browser-url:${e}`)??``)??`about:blank`}catch{return`about:blank`}},[e]);(0,g.useEffect)(()=>{let e=!0;return r().then(t=>{e&&j(t?`native`:`screencast`)}),()=>{e=!1}},[]);let N=(0,g.useMemo)(()=>`agent-${t??`home`}-${Math.round(performance.now())}`,[t]),P=async e=>{k(!0);try{let r=await u(t??(await T()).id,a(e.screenshotDataUrl,`capture-${Date.now()}.png`));x(r),c.success(n(`workspace.browserCaptured`)),b()}catch(e){throw c.error(n(`workspace.uploadFailed`),{description:e instanceof Error?e.message:void 0}),e}finally{k(!1)}};return A===`probing`?null:A===`native`?(0,_.jsx)(o,{ownerId:S??void 0,leaseRevision:y,onBusyChange:D,transferError:v,url:M,onClose:b,onFallback:()=>j(`screencast`),onUrlChange:t=>{if(w(t),i(t)&&t!==`about:blank`)try{localStorage.setItem(`specrails-desktop:agent-browser-url:${e}`,t)}catch{}},confirmLabel:n(`workspace.browserConfirm`),selectLabel:n(`workspace.browserSelectStart`),onCaptured:P}):(0,_.jsx)(h,{open:!0,onClose:b,projectId:e,pendingSpecId:N,confirmLabel:n(`workspace.browserConfirm`),selectLabel:n(`workspace.browserSelectStart`),onCaptured:P})}export{v as AgentBrowserCapture};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/AnalyticsPage-C06KT4Y0.js","assets/rolldown-runtime-CNC7AqOf.js","assets/jsx-runtime-zu2_FqZY.js","assets/chunk-KS7C4IRE-DEKu087k.js","assets/preload-helper-Czpn1I53.js","assets/useSharedWebSocket-Dz-HI6De.js","assets/activity-DiyjsgQV.js","assets/addspec-BOvgmcgk.js","assets/agent-aiVhqFW1.js","assets/agentRuntime-bAAjw1vw.js","assets/agents-CTwbx-fb.js","assets/agentstudio-CN2pokQu.js","assets/aiedit-iIjz2_Qk.js","assets/analytics-BlypLLR6.js","assets/attachments-B53PG733.js","assets/browser-CG0PE1j_.js","assets/builder-BTiGnPT0.js","assets/chat-BGD7MXAy.js","assets/code-DaZ-ZwCT.js","assets/commands-BAWSYHjQ.js","assets/common-BrlwEnL7.js","assets/dashboard-BV4vOZkR.js","assets/explore-DgBACn39.js","assets/integrations-mB-7zoyT.js","assets/jira-CKJg3HZd.js","assets/jobs-C9j2PuwW.js","assets/loops-B7YpGizO.js","assets/mcp-CUAN6ORK.js","assets/narration-n3hOA7LY.js","assets/nav-DhPb-Isc.js","assets/packet-B0H15elv.js","assets/settings-HZSu-K4l.js","assets/setup-DpqzaEEA.js","assets/specs-DfIdoU5L.js","assets/terminal-BAzpHtpY.js","assets/tickets-D41ZMQpf.js","assets/createLucideIcon-Bjbbp_KS.js","assets/Trans-DEbgkuAY.js","assets/useDesktop-QogiN0zR.js","assets/react-dom-DiWzBDP9.js","assets/provider-capabilities-Vi1ZGvAK.js","assets/spending-T5GM7wpn.js","assets/clsx-CjueKrWZ.js","assets/formatDistanceToNow-Cc2u5FwQ.js","assets/getTimezoneOffsetInMilliseconds-BHm2U-w1.js","assets/index-BcligJ3-.js","assets/TicketDetailModalContext-DAK-NoK6.js","assets/save-B6wGWwBR.js","assets/MinimizedChatsContext-D3QzgV0B.js","assets/sparkles-DrY8hb0X.js","assets/x-CBMI9ejn.js","assets/zap-CUOlvtT1.js","assets/circle-x-CMYsN4ZH.js","assets/download-CFHyyHcw.js","assets/file-text-CFT-xXKN.js","assets/git-branch-BRM0F5GN.js","assets/layers-eDMjG41I.js","assets/loader-circle-DcygOQpC.js","assets/pencil-C9RkrIPZ.js","assets/square-Ci-PFcFe.js","assets/plus-CsnjfkmX.js","assets/rotate-ccw-Wh4id13q.js","assets/search-Cq_gE3Ik.js","assets/trash-2-BOU3WdZZ.js","assets/triangle-alert-H9T4jAmh.js","assets/wrench-BfmNO9Vw.js","assets/dialog-xXB2q5HJ.js","assets/utils-BC4DHlz2.js","assets/lib-CGdyxIWg.js","assets/button-Ccc9Dc-D.js","assets/jira-api-DrGxiD9p.js","assets/RepositoryScopeSelector-hPGZNRBm.js","assets/project-repositories-9Wzs0coQ.js","assets/core-B3mKBIh5.js","assets/RepositoryDeliveries-Du2UCf1a.js","assets/useRuntimeRuns-Dqmz9fS9.js","assets/event-Bt7f3wXe.js","assets/index-C51x61Bz.css","assets/ExportDropdown-BVGKEgkd.js","assets/BarChart-nBOMNfiy.js","assets/value-s-gzBeyF.js"])))=>i.map(i=>d[i]);
2
- import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{t as r}from"./preload-helper-Czpn1I53.js";import{n as i}from"./createLucideIcon-Bjbbp_KS.js";import{t as a}from"./loader-circle-DcygOQpC.js";import{t as o}from"./x-CBMI9ejn.js";import{t as s}from"./utils-BC4DHlz2.js";import{U as c,bt as l,xt as u}from"./index-BcligJ3-.js";var d=e(t(),1),f=n(),p=(0,d.lazy)(()=>r(()=>import(`./AnalyticsPage-C06KT4Y0.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80]))),m=420,h=560;function g(){let{t:e}=i(`agent`),{closeAnalyticsPane:t}=c(),[n,r]=(0,d.useState)(h),[g,_]=(0,d.useState)(!1),v=(0,d.useCallback)(e=>{let t=e.clientX,i=n,a=window.innerWidth-m;try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}let o=e=>{let n=Math.min(Math.max(i+(t-e.clientX),m),a);r(n)},s=()=>{window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,s)},[n]);return(0,f.jsxs)(`div`,{className:s(`flex h-full flex-col overflow-hidden border-l border-border bg-background`,g&&`absolute inset-0 z-30 border-l-0`),style:g?void 0:{width:n,flexShrink:0},"data-testid":`agent-analytics-pane`,children:[(0,f.jsx)(`div`,{className:`relative flex items-center`,children:!g&&(0,f.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,onPointerDown:v,className:`absolute left-0 top-0 h-full w-1.5 -translate-x-full cursor-col-resize select-none touch-none hover:bg-accent-primary/20`,title:e(`workspace.resizeAnalytics`)})}),(0,f.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/60 bg-surface/40 px-3 py-1.5`,children:[(0,f.jsx)(`span`,{className:`text-xs font-medium text-foreground/70`,children:e(`workspace.analytics`)}),(0,f.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,f.jsx)(`button`,{type:`button`,onClick:()=>_(e=>!e),"aria-label":e(g?`restore`:`maximize`),title:e(g?`restore`:`maximize`),className:`rounded-md p-1 text-foreground/60 hover:bg-surface hover:text-foreground`,children:g?(0,f.jsx)(l,{className:`h-4 w-4`}):(0,f.jsx)(u,{className:`h-4 w-4`})}),(0,f.jsx)(`button`,{type:`button`,onClick:t,"aria-label":e(`workspace.closeAnalytics`),title:e(`workspace.closeAnalytics`),className:`rounded-md p-1 text-foreground/60 hover:bg-surface hover:text-foreground`,children:(0,f.jsx)(o,{className:`h-4 w-4`})})]})]}),(0,f.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,f.jsx)(d.Suspense,{fallback:(0,f.jsx)(`div`,{className:`flex h-24 items-center justify-center text-muted-foreground`,children:(0,f.jsx)(a,{className:`h-4 w-4 animate-spin`})}),children:(0,f.jsx)(p,{})})})]})}export{g as AgentModeAnalyticsPane};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/AnalyticsPage-CyfhYiBn.js","assets/rolldown-runtime-CNC7AqOf.js","assets/jsx-runtime-zu2_FqZY.js","assets/chunk-KS7C4IRE-DEKu087k.js","assets/preload-helper-Czpn1I53.js","assets/useSharedWebSocket-Dz-HI6De.js","assets/activity-DiyjsgQV.js","assets/addspec-BOvgmcgk.js","assets/agent-aiVhqFW1.js","assets/agentRuntime-bAAjw1vw.js","assets/agents-CTwbx-fb.js","assets/agentstudio-CN2pokQu.js","assets/aiedit-iIjz2_Qk.js","assets/analytics-BlypLLR6.js","assets/attachments-B53PG733.js","assets/browser-CG0PE1j_.js","assets/builder-BTiGnPT0.js","assets/chat-BGD7MXAy.js","assets/code-DaZ-ZwCT.js","assets/commands-BAWSYHjQ.js","assets/common-BrlwEnL7.js","assets/dashboard-BV4vOZkR.js","assets/explore-DgBACn39.js","assets/integrations-mB-7zoyT.js","assets/jira-CKJg3HZd.js","assets/jobs-C9j2PuwW.js","assets/loops-B7YpGizO.js","assets/mcp-CUAN6ORK.js","assets/narration-n3hOA7LY.js","assets/nav-DhPb-Isc.js","assets/packet-B0H15elv.js","assets/settings-HZSu-K4l.js","assets/setup-DpqzaEEA.js","assets/specs-DfIdoU5L.js","assets/terminal-BAzpHtpY.js","assets/tickets-D41ZMQpf.js","assets/createLucideIcon-Bjbbp_KS.js","assets/Trans-DEbgkuAY.js","assets/useDesktop-QogiN0zR.js","assets/react-dom-DiWzBDP9.js","assets/provider-capabilities-Vi1ZGvAK.js","assets/spending-T5GM7wpn.js","assets/clsx-CjueKrWZ.js","assets/formatDistanceToNow-Cc2u5FwQ.js","assets/getTimezoneOffsetInMilliseconds-BHm2U-w1.js","assets/index-Cxb288Rj.js","assets/TicketDetailModalContext-DAK-NoK6.js","assets/save-B6wGWwBR.js","assets/MinimizedChatsContext-D3QzgV0B.js","assets/sparkles-DrY8hb0X.js","assets/x-CBMI9ejn.js","assets/zap-CUOlvtT1.js","assets/circle-x-CMYsN4ZH.js","assets/download-CFHyyHcw.js","assets/file-text-CFT-xXKN.js","assets/git-branch-BRM0F5GN.js","assets/layers-eDMjG41I.js","assets/loader-circle-DcygOQpC.js","assets/pencil-C9RkrIPZ.js","assets/square-Ci-PFcFe.js","assets/plus-CsnjfkmX.js","assets/rotate-ccw-Wh4id13q.js","assets/search-Cq_gE3Ik.js","assets/trash-2-BOU3WdZZ.js","assets/triangle-alert-H9T4jAmh.js","assets/wrench-BfmNO9Vw.js","assets/dialog-xXB2q5HJ.js","assets/utils-BC4DHlz2.js","assets/lib-CGdyxIWg.js","assets/button-Ccc9Dc-D.js","assets/jira-api-DrGxiD9p.js","assets/RepositoryScopeSelector-hPGZNRBm.js","assets/project-repositories-9Wzs0coQ.js","assets/core-B3mKBIh5.js","assets/RepositoryDeliveries-Du2UCf1a.js","assets/useRuntimeRuns-Dqmz9fS9.js","assets/event-Bt7f3wXe.js","assets/index-C51x61Bz.css","assets/ExportDropdown-BVGKEgkd.js","assets/BarChart-nBOMNfiy.js","assets/value-s-gzBeyF.js"])))=>i.map(i=>d[i]);
2
+ import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{t as r}from"./preload-helper-Czpn1I53.js";import{n as i}from"./createLucideIcon-Bjbbp_KS.js";import{t as a}from"./loader-circle-DcygOQpC.js";import{t as o}from"./x-CBMI9ejn.js";import{t as s}from"./utils-BC4DHlz2.js";import{U as c,bt as l,xt as u}from"./index-Cxb288Rj.js";var d=e(t(),1),f=n(),p=(0,d.lazy)(()=>r(()=>import(`./AnalyticsPage-CyfhYiBn.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80]))),m=420,h=560;function g(){let{t:e}=i(`agent`),{closeAnalyticsPane:t}=c(),[n,r]=(0,d.useState)(h),[g,_]=(0,d.useState)(!1),v=(0,d.useCallback)(e=>{let t=e.clientX,i=n,a=window.innerWidth-m;try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}let o=e=>{let n=Math.min(Math.max(i+(t-e.clientX),m),a);r(n)},s=()=>{window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,s)},[n]);return(0,f.jsxs)(`div`,{className:s(`flex h-full flex-col overflow-hidden border-l border-border bg-background`,g&&`absolute inset-0 z-30 border-l-0`),style:g?void 0:{width:n,flexShrink:0},"data-testid":`agent-analytics-pane`,children:[(0,f.jsx)(`div`,{className:`relative flex items-center`,children:!g&&(0,f.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,onPointerDown:v,className:`absolute left-0 top-0 h-full w-1.5 -translate-x-full cursor-col-resize select-none touch-none hover:bg-accent-primary/20`,title:e(`workspace.resizeAnalytics`)})}),(0,f.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/60 bg-surface/40 px-3 py-1.5`,children:[(0,f.jsx)(`span`,{className:`text-xs font-medium text-foreground/70`,children:e(`workspace.analytics`)}),(0,f.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,f.jsx)(`button`,{type:`button`,onClick:()=>_(e=>!e),"aria-label":e(g?`restore`:`maximize`),title:e(g?`restore`:`maximize`),className:`rounded-md p-1 text-foreground/60 hover:bg-surface hover:text-foreground`,children:g?(0,f.jsx)(l,{className:`h-4 w-4`}):(0,f.jsx)(u,{className:`h-4 w-4`})}),(0,f.jsx)(`button`,{type:`button`,onClick:t,"aria-label":e(`workspace.closeAnalytics`),title:e(`workspace.closeAnalytics`),className:`rounded-md p-1 text-foreground/60 hover:bg-surface hover:text-foreground`,children:(0,f.jsx)(o,{className:`h-4 w-4`})})]})]}),(0,f.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,f.jsx)(d.Suspense,{fallback:(0,f.jsx)(`div`,{className:`flex h-24 items-center justify-center text-muted-foreground`,children:(0,f.jsx)(a,{className:`h-4 w-4 animate-spin`})}),children:(0,f.jsx)(p,{})})})]})}export{g as AgentModeAnalyticsPane};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/CodePage-aX1mxGyT.js","assets/rolldown-runtime-CNC7AqOf.js","assets/jsx-runtime-zu2_FqZY.js","assets/react-dom-DiWzBDP9.js","assets/preload-helper-Czpn1I53.js","assets/chunk-KS7C4IRE-DEKu087k.js","assets/TicketDetailModalContext-DAK-NoK6.js","assets/useSharedWebSocket-Dz-HI6De.js","assets/activity-DiyjsgQV.js","assets/addspec-BOvgmcgk.js","assets/agent-aiVhqFW1.js","assets/agentRuntime-bAAjw1vw.js","assets/agents-CTwbx-fb.js","assets/agentstudio-CN2pokQu.js","assets/aiedit-iIjz2_Qk.js","assets/analytics-BlypLLR6.js","assets/attachments-B53PG733.js","assets/browser-CG0PE1j_.js","assets/builder-BTiGnPT0.js","assets/chat-BGD7MXAy.js","assets/code-DaZ-ZwCT.js","assets/commands-BAWSYHjQ.js","assets/common-BrlwEnL7.js","assets/dashboard-BV4vOZkR.js","assets/explore-DgBACn39.js","assets/integrations-mB-7zoyT.js","assets/jira-CKJg3HZd.js","assets/jobs-C9j2PuwW.js","assets/loops-B7YpGizO.js","assets/mcp-CUAN6ORK.js","assets/narration-n3hOA7LY.js","assets/nav-DhPb-Isc.js","assets/packet-B0H15elv.js","assets/settings-HZSu-K4l.js","assets/setup-DpqzaEEA.js","assets/specs-DfIdoU5L.js","assets/terminal-BAzpHtpY.js","assets/tickets-D41ZMQpf.js","assets/createLucideIcon-Bjbbp_KS.js","assets/Trans-DEbgkuAY.js","assets/useDesktop-QogiN0zR.js","assets/provider-capabilities-Vi1ZGvAK.js","assets/save-B6wGWwBR.js","assets/spending-T5GM7wpn.js","assets/MinimizedChatsContext-D3QzgV0B.js","assets/sparkles-DrY8hb0X.js","assets/x-CBMI9ejn.js","assets/zap-CUOlvtT1.js","assets/circle-x-CMYsN4ZH.js","assets/download-CFHyyHcw.js","assets/file-text-CFT-xXKN.js","assets/git-branch-BRM0F5GN.js","assets/layers-eDMjG41I.js","assets/loader-circle-DcygOQpC.js","assets/pencil-C9RkrIPZ.js","assets/square-Ci-PFcFe.js","assets/plus-CsnjfkmX.js","assets/rotate-ccw-Wh4id13q.js","assets/search-Cq_gE3Ik.js","assets/trash-2-BOU3WdZZ.js","assets/triangle-alert-H9T4jAmh.js","assets/wrench-BfmNO9Vw.js","assets/dialog-xXB2q5HJ.js","assets/utils-BC4DHlz2.js","assets/clsx-CjueKrWZ.js","assets/lib-CGdyxIWg.js","assets/formatDistanceToNow-Cc2u5FwQ.js","assets/getTimezoneOffsetInMilliseconds-BHm2U-w1.js","assets/button-Ccc9Dc-D.js","assets/jira-api-DrGxiD9p.js","assets/RepositoryScopeSelector-hPGZNRBm.js","assets/project-repositories-9Wzs0coQ.js","assets/index-BcligJ3-.js","assets/core-B3mKBIh5.js","assets/RepositoryDeliveries-Du2UCf1a.js","assets/useRuntimeRuns-Dqmz9fS9.js","assets/event-Bt7f3wXe.js","assets/index-C51x61Bz.css"])))=>i.map(i=>d[i]);
2
- import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{t as r}from"./preload-helper-Czpn1I53.js";import{n as i}from"./createLucideIcon-Bjbbp_KS.js";import{t as a}from"./x-CBMI9ejn.js";import{U as o,bt as s,nt as c,tt as l,xt as u}from"./index-BcligJ3-.js";var d=e(t(),1),f=n(),p=(0,d.lazy)(()=>r(()=>import(`./CodePage-aX1mxGyT.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77]))),m=420,h=560;function g({projectId:e,conversationId:t}){let{t:n}=i(`agent`),{closeCodePane:r}=o(),[g,_]=(0,d.useState)(h),[v,y]=(0,d.useState)(()=>window.innerWidth),[b,x]=(0,d.useState)(!1),S=(0,d.useRef)(null),C=(0,d.useRef)(null),w=Math.max(0,v-Math.min(m,v/2)),T=Math.min(m,w),E=Math.min(w,Math.max(T,g)),D=(0,d.useCallback)(e=>Math.min(w,Math.max(T,e)),[w,T]),O=`${e}:${t}`,k=(0,d.useCallback)(n=>{c(e,t,{path:n})},[e,t]);(0,d.useLayoutEffect)(()=>{let e=S.current,t=e?.parentElement;if(!e||!t)return;let n=()=>{let n=t.getBoundingClientRect().width||t.clientWidth||window.innerWidth,r=0;for(let n of t.children){if(n===e||!(n instanceof HTMLElement))continue;let t=getComputedStyle(n);t.display===`none`||t.position===`absolute`||t.position===`fixed`||Number(t.flexGrow)>0||(r+=n.getBoundingClientRect().width)}y(Math.max(0,n-r))},r=new ResizeObserver(n),i=()=>{r.disconnect(),r.observe(t);for(let n of t.children)n!==e&&r.observe(n);n()},a=new MutationObserver(i);return a.observe(t,{childList:!0}),i(),window.addEventListener(`resize`,n),()=>{r.disconnect(),a.disconnect(),window.removeEventListener(`resize`,n)}},[O]),(0,d.useEffect)(()=>()=>{C.current?.()},[O,b,w]);let A=(0,d.useCallback)(e=>{if(e.button!==0)return;e.preventDefault(),C.current?.();let t=e.clientX,n=E,r=e.pointerId,i=e.currentTarget;try{i.setPointerCapture(r)}catch{}let a=e=>{e.pointerId===r&&_(D(n+t-e.clientX))},o=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s),window.removeEventListener(`blur`,o),i.removeEventListener(`lostpointercapture`,o);try{i.hasPointerCapture(r)&&i.releasePointerCapture(r)}catch{}C.current=null},s=e=>{e.pointerId===r&&o()};C.current=o,window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,s),window.addEventListener(`blur`,o),i.addEventListener(`lostpointercapture`,o)},[E,D]);return(0,f.jsxs)(`div`,{ref:S,className:`flex h-full min-w-0 flex-col overflow-hidden border-l border-border bg-background${b?` absolute inset-0 z-30 border-l-0`:` relative`}`,style:b?void 0:{width:E,maxWidth:`100%`,flexShrink:0},"data-testid":`agent-code-pane`,children:[!b&&(0,f.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,onPointerDown:A,tabIndex:0,"aria-label":n(`workspace.resizeCode`),"aria-valuemin":Math.round(T),"aria-valuemax":Math.round(w),"aria-valuenow":Math.round(E),onKeyDown:e=>{let t=e.key===`ArrowLeft`?E+32:e.key===`ArrowRight`?E-32:e.key===`Home`?T:e.key===`End`?w:null;t!==null&&(e.preventDefault(),_(D(t)))},className:`absolute inset-y-0 left-0 z-20 w-1.5 cursor-col-resize select-none touch-none hover:bg-accent-primary/20 focus-visible:bg-accent-primary/30 focus-visible:outline-none`,title:n(`workspace.resizeCode`)}),(0,f.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/60 bg-surface/40 px-3 py-1.5`,children:[(0,f.jsx)(`span`,{className:`text-xs font-medium text-foreground/70`,children:n(`workspace.files`)}),(0,f.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,f.jsx)(`button`,{type:`button`,onClick:()=>{C.current?.(),x(e=>!e)},"aria-label":n(b?`restore`:`maximize`),title:n(b?`restore`:`maximize`),className:`rounded-md p-1 text-foreground/60 hover:bg-surface hover:text-foreground`,children:b?(0,f.jsx)(s,{className:`h-4 w-4`}):(0,f.jsx)(u,{className:`h-4 w-4`})}),(0,f.jsx)(`button`,{type:`button`,onClick:()=>{C.current?.(),r()},"aria-label":n(`workspace.closeFiles`),title:n(`workspace.closeFiles`),className:`rounded-md p-1 text-foreground/60 hover:bg-surface hover:text-foreground`,children:(0,f.jsx)(a,{className:`h-4 w-4`})})]})]}),(0,f.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,f.jsx)(d.Suspense,{fallback:(0,f.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`…`}),children:(0,f.jsx)(p,{embedded:!0,initialRepositoryId:l(e,t).repositoryId,onRepositoryChange:n=>c(e,t,{repositoryId:n}),initialPath:l(e,t).path,onSelectedPathChange:k},O)})})]},O)}export{g as AgentModeCodePane};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/CodePage-C2Nf-Q5W.js","assets/rolldown-runtime-CNC7AqOf.js","assets/jsx-runtime-zu2_FqZY.js","assets/react-dom-DiWzBDP9.js","assets/preload-helper-Czpn1I53.js","assets/chunk-KS7C4IRE-DEKu087k.js","assets/TicketDetailModalContext-DAK-NoK6.js","assets/useSharedWebSocket-Dz-HI6De.js","assets/activity-DiyjsgQV.js","assets/addspec-BOvgmcgk.js","assets/agent-aiVhqFW1.js","assets/agentRuntime-bAAjw1vw.js","assets/agents-CTwbx-fb.js","assets/agentstudio-CN2pokQu.js","assets/aiedit-iIjz2_Qk.js","assets/analytics-BlypLLR6.js","assets/attachments-B53PG733.js","assets/browser-CG0PE1j_.js","assets/builder-BTiGnPT0.js","assets/chat-BGD7MXAy.js","assets/code-DaZ-ZwCT.js","assets/commands-BAWSYHjQ.js","assets/common-BrlwEnL7.js","assets/dashboard-BV4vOZkR.js","assets/explore-DgBACn39.js","assets/integrations-mB-7zoyT.js","assets/jira-CKJg3HZd.js","assets/jobs-C9j2PuwW.js","assets/loops-B7YpGizO.js","assets/mcp-CUAN6ORK.js","assets/narration-n3hOA7LY.js","assets/nav-DhPb-Isc.js","assets/packet-B0H15elv.js","assets/settings-HZSu-K4l.js","assets/setup-DpqzaEEA.js","assets/specs-DfIdoU5L.js","assets/terminal-BAzpHtpY.js","assets/tickets-D41ZMQpf.js","assets/createLucideIcon-Bjbbp_KS.js","assets/Trans-DEbgkuAY.js","assets/useDesktop-QogiN0zR.js","assets/provider-capabilities-Vi1ZGvAK.js","assets/save-B6wGWwBR.js","assets/spending-T5GM7wpn.js","assets/MinimizedChatsContext-D3QzgV0B.js","assets/sparkles-DrY8hb0X.js","assets/x-CBMI9ejn.js","assets/zap-CUOlvtT1.js","assets/circle-x-CMYsN4ZH.js","assets/download-CFHyyHcw.js","assets/file-text-CFT-xXKN.js","assets/git-branch-BRM0F5GN.js","assets/layers-eDMjG41I.js","assets/loader-circle-DcygOQpC.js","assets/pencil-C9RkrIPZ.js","assets/square-Ci-PFcFe.js","assets/plus-CsnjfkmX.js","assets/rotate-ccw-Wh4id13q.js","assets/search-Cq_gE3Ik.js","assets/trash-2-BOU3WdZZ.js","assets/triangle-alert-H9T4jAmh.js","assets/wrench-BfmNO9Vw.js","assets/dialog-xXB2q5HJ.js","assets/utils-BC4DHlz2.js","assets/clsx-CjueKrWZ.js","assets/lib-CGdyxIWg.js","assets/formatDistanceToNow-Cc2u5FwQ.js","assets/getTimezoneOffsetInMilliseconds-BHm2U-w1.js","assets/button-Ccc9Dc-D.js","assets/jira-api-DrGxiD9p.js","assets/RepositoryScopeSelector-hPGZNRBm.js","assets/project-repositories-9Wzs0coQ.js","assets/index-Cxb288Rj.js","assets/core-B3mKBIh5.js","assets/RepositoryDeliveries-Du2UCf1a.js","assets/useRuntimeRuns-Dqmz9fS9.js","assets/event-Bt7f3wXe.js","assets/index-C51x61Bz.css"])))=>i.map(i=>d[i]);
2
+ import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{t as r}from"./preload-helper-Czpn1I53.js";import{n as i}from"./createLucideIcon-Bjbbp_KS.js";import{t as a}from"./x-CBMI9ejn.js";import{U as o,bt as s,nt as c,tt as l,xt as u}from"./index-Cxb288Rj.js";var d=e(t(),1),f=n(),p=(0,d.lazy)(()=>r(()=>import(`./CodePage-C2Nf-Q5W.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77]))),m=420,h=560;function g({projectId:e,conversationId:t}){let{t:n}=i(`agent`),{closeCodePane:r}=o(),[g,_]=(0,d.useState)(h),[v,y]=(0,d.useState)(()=>window.innerWidth),[b,x]=(0,d.useState)(!1),S=(0,d.useRef)(null),C=(0,d.useRef)(null),w=Math.max(0,v-Math.min(m,v/2)),T=Math.min(m,w),E=Math.min(w,Math.max(T,g)),D=(0,d.useCallback)(e=>Math.min(w,Math.max(T,e)),[w,T]),O=`${e}:${t}`,k=(0,d.useCallback)(n=>{c(e,t,{path:n})},[e,t]);(0,d.useLayoutEffect)(()=>{let e=S.current,t=e?.parentElement;if(!e||!t)return;let n=()=>{let n=t.getBoundingClientRect().width||t.clientWidth||window.innerWidth,r=0;for(let n of t.children){if(n===e||!(n instanceof HTMLElement))continue;let t=getComputedStyle(n);t.display===`none`||t.position===`absolute`||t.position===`fixed`||Number(t.flexGrow)>0||(r+=n.getBoundingClientRect().width)}y(Math.max(0,n-r))},r=new ResizeObserver(n),i=()=>{r.disconnect(),r.observe(t);for(let n of t.children)n!==e&&r.observe(n);n()},a=new MutationObserver(i);return a.observe(t,{childList:!0}),i(),window.addEventListener(`resize`,n),()=>{r.disconnect(),a.disconnect(),window.removeEventListener(`resize`,n)}},[O]),(0,d.useEffect)(()=>()=>{C.current?.()},[O,b,w]);let A=(0,d.useCallback)(e=>{if(e.button!==0)return;e.preventDefault(),C.current?.();let t=e.clientX,n=E,r=e.pointerId,i=e.currentTarget;try{i.setPointerCapture(r)}catch{}let a=e=>{e.pointerId===r&&_(D(n+t-e.clientX))},o=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s),window.removeEventListener(`blur`,o),i.removeEventListener(`lostpointercapture`,o);try{i.hasPointerCapture(r)&&i.releasePointerCapture(r)}catch{}C.current=null},s=e=>{e.pointerId===r&&o()};C.current=o,window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,s),window.addEventListener(`blur`,o),i.addEventListener(`lostpointercapture`,o)},[E,D]);return(0,f.jsxs)(`div`,{ref:S,className:`flex h-full min-w-0 flex-col overflow-hidden border-l border-border bg-background${b?` absolute inset-0 z-30 border-l-0`:` relative`}`,style:b?void 0:{width:E,maxWidth:`100%`,flexShrink:0},"data-testid":`agent-code-pane`,children:[!b&&(0,f.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,onPointerDown:A,tabIndex:0,"aria-label":n(`workspace.resizeCode`),"aria-valuemin":Math.round(T),"aria-valuemax":Math.round(w),"aria-valuenow":Math.round(E),onKeyDown:e=>{let t=e.key===`ArrowLeft`?E+32:e.key===`ArrowRight`?E-32:e.key===`Home`?T:e.key===`End`?w:null;t!==null&&(e.preventDefault(),_(D(t)))},className:`absolute inset-y-0 left-0 z-20 w-1.5 cursor-col-resize select-none touch-none hover:bg-accent-primary/20 focus-visible:bg-accent-primary/30 focus-visible:outline-none`,title:n(`workspace.resizeCode`)}),(0,f.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/60 bg-surface/40 px-3 py-1.5`,children:[(0,f.jsx)(`span`,{className:`text-xs font-medium text-foreground/70`,children:n(`workspace.files`)}),(0,f.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,f.jsx)(`button`,{type:`button`,onClick:()=>{C.current?.(),x(e=>!e)},"aria-label":n(b?`restore`:`maximize`),title:n(b?`restore`:`maximize`),className:`rounded-md p-1 text-foreground/60 hover:bg-surface hover:text-foreground`,children:b?(0,f.jsx)(s,{className:`h-4 w-4`}):(0,f.jsx)(u,{className:`h-4 w-4`})}),(0,f.jsx)(`button`,{type:`button`,onClick:()=>{C.current?.(),r()},"aria-label":n(`workspace.closeFiles`),title:n(`workspace.closeFiles`),className:`rounded-md p-1 text-foreground/60 hover:bg-surface hover:text-foreground`,children:(0,f.jsx)(a,{className:`h-4 w-4`})})]})]}),(0,f.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,f.jsx)(d.Suspense,{fallback:(0,f.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`…`}),children:(0,f.jsx)(p,{embedded:!0,initialRepositoryId:l(e,t).repositoryId,onRepositoryChange:n=>c(e,t,{repositoryId:n}),initialPath:l(e,t).path,onSelectedPathChange:k},O)})})]},O)}export{g as AgentModeCodePane};
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{m as r,r as i}from"./useSharedWebSocket-Dz-HI6De.js";import{n as a}from"./createLucideIcon-Bjbbp_KS.js";import{i as o,r as s}from"./useDesktop-QogiN0zR.js";import{t as c}from"./loader-circle-DcygOQpC.js";import{t as l}from"./x-CBMI9ejn.js";import{t as u}from"./utils-BC4DHlz2.js";import{t as d}from"./formatDistanceToNow-Cc2u5FwQ.js";import{n as f}from"./project-repositories-9Wzs0coQ.js";import{Bt as p,U as m,b as h,bt as g,xt as _}from"./index-BcligJ3-.js";import{t as v}from"./format-command-C0D9IPmV.js";import{n as y,t as b}from"./job-time-BCL7wee9.js";import{JobDetailModal as x}from"./JobDetailModal-Cn_k3-RM.js";var S=e(t(),1),C=n(),w=360,T=480,E={running:`running`,completed:`success`,failed:`failed`,canceled:`canceled`,queued:`queued`};function D({projectId:e}){let{t}=a(`agent`),{t:n}=a(`jobs`),{closeJobsPane:D,requestedJobId:O,clearRequestedJob:k}=m(),{projects:A}=s(),j=A.find(t=>t.id===e)?.provider,[M,N]=(0,S.useState)(T),[P,F]=(0,S.useState)(!1),[I,L]=(0,S.useState)(null);(0,S.useEffect)(()=>{O&&(L(O),k())},[O,k]);let{data:R,isFirstLoad:z,refresh:B}=o({namespace:`agent-jobs`,projectId:e,initialValue:[],fetcher:async()=>{let t=await fetch(`${f(e)}/jobs?limit=50`);return t.ok?(await t.json()).jobs:[]},pollInterval:5e3}),{registerHandler:V,unregisterHandler:H}=i(),U=(0,S.useRef)(e);U.current=e;let W=(0,S.useRef)(B);W.current=B,(0,S.useEffect)(()=>(V(`agent-jobs-pane`,e=>{let t=e;t.type===`queue`&&(t.projectId&&t.projectId!==U.current||W.current())}),()=>H(`agent-jobs-pane`)),[V,H]);let G=(0,S.useCallback)(e=>{let t=e.clientX,n=M,r=window.innerWidth-w;try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}let i=e=>{let i=Math.min(Math.max(n+(t-e.clientX),w),r);N(i)},a=()=>{window.removeEventListener(`pointermove`,i),window.removeEventListener(`pointerup`,a),window.removeEventListener(`pointercancel`,a)};window.addEventListener(`pointermove`,i),window.addEventListener(`pointerup`,a),window.addEventListener(`pointercancel`,a)},[M]);return(0,C.jsxs)(`div`,{className:u(`flex h-full flex-col overflow-hidden border-l border-border bg-background`,P&&`absolute inset-0 z-30 border-l-0`),style:P?void 0:{width:M,flexShrink:0},children:[(0,C.jsx)(`div`,{className:`relative flex items-center`,children:!P&&(0,C.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,onPointerDown:G,className:`absolute left-0 top-0 h-full w-1.5 -translate-x-full cursor-col-resize select-none touch-none hover:bg-accent-primary/20`,title:t(`workspace.resizeJobs`)})}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/60 bg-surface/40 px-3 py-1.5`,children:[(0,C.jsx)(`span`,{className:`text-xs font-medium text-foreground/70`,children:t(`workspace.jobs`)}),(0,C.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,C.jsx)(`button`,{type:`button`,onClick:()=>F(e=>!e),"aria-label":t(P?`restore`:`maximize`),title:t(P?`restore`:`maximize`),className:`rounded-md p-1 text-foreground/60 hover:bg-surface hover:text-foreground`,children:P?(0,C.jsx)(g,{className:`h-4 w-4`}):(0,C.jsx)(_,{className:`h-4 w-4`})}),(0,C.jsx)(`button`,{type:`button`,onClick:D,"aria-label":t(`workspace.closeJobs`),title:t(`workspace.closeJobs`),className:`rounded-md p-1 text-foreground/60 hover:bg-surface hover:text-foreground`,children:(0,C.jsx)(l,{className:`h-4 w-4`})})]})]}),(0,C.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-2`,children:z?(0,C.jsx)(`div`,{className:`flex h-24 items-center justify-center text-muted-foreground`,children:(0,C.jsx)(c,{className:`h-4 w-4 animate-spin`})}):R.length===0?(0,C.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 text-center text-muted-foreground`,children:[(0,C.jsx)(p,{className:`h-6 w-6 opacity-40`}),(0,C.jsx)(`p`,{className:`text-xs`,children:t(`workspace.noJobs`)})]}):(0,C.jsx)(`ul`,{className:`space-y-1`,children:R.map(e=>(0,C.jsx)(`li`,{children:(0,C.jsxs)(`button`,{type:`button`,onClick:()=>L(e.id),className:u(`flex w-full flex-col gap-1 rounded-lg border border-border/50 bg-surface/30 px-2.5 py-2 text-left transition-colors`,`hover:border-accent-primary/40 hover:bg-surface/60`),children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(h,{variant:E[e.status]??`queued`,children:n(`statusLabel.${e.status in E?e.status:`queued`}`)}),e.status===`running`&&(0,C.jsx)(c,{className:`h-3 w-3 animate-spin text-accent-primary`}),(0,C.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:(()=>{let t=y(b(e));return t?d(t,{addSuffix:!0,locale:r()}):`—`})()})]}),(0,C.jsx)(`code`,{className:`truncate font-mono text-xs text-foreground/85`,children:v(e.command,j)})]})},e.id))})}),I&&(0,C.jsx)(x,{jobId:I,projectId:e,onClose:()=>L(null)})]})}export{D as AgentModeJobsPane};
1
+ import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{m as r,r as i}from"./useSharedWebSocket-Dz-HI6De.js";import{n as a}from"./createLucideIcon-Bjbbp_KS.js";import{i as o,r as s}from"./useDesktop-QogiN0zR.js";import{t as c}from"./loader-circle-DcygOQpC.js";import{t as l}from"./x-CBMI9ejn.js";import{t as u}from"./utils-BC4DHlz2.js";import{t as d}from"./formatDistanceToNow-Cc2u5FwQ.js";import{n as f}from"./project-repositories-9Wzs0coQ.js";import{Bt as p,U as m,b as h,bt as g,xt as _}from"./index-Cxb288Rj.js";import{t as v}from"./format-command-C0D9IPmV.js";import{n as y,t as b}from"./job-time-BCL7wee9.js";import{JobDetailModal as x}from"./JobDetailModal-BdOv-l-M.js";var S=e(t(),1),C=n(),w=360,T=480,E={running:`running`,completed:`success`,failed:`failed`,canceled:`canceled`,queued:`queued`};function D({projectId:e}){let{t}=a(`agent`),{t:n}=a(`jobs`),{closeJobsPane:D,requestedJobId:O,clearRequestedJob:k}=m(),{projects:A}=s(),j=A.find(t=>t.id===e)?.provider,[M,N]=(0,S.useState)(T),[P,F]=(0,S.useState)(!1),[I,L]=(0,S.useState)(null);(0,S.useEffect)(()=>{O&&(L(O),k())},[O,k]);let{data:R,isFirstLoad:z,refresh:B}=o({namespace:`agent-jobs`,projectId:e,initialValue:[],fetcher:async()=>{let t=await fetch(`${f(e)}/jobs?limit=50`);return t.ok?(await t.json()).jobs:[]},pollInterval:5e3}),{registerHandler:V,unregisterHandler:H}=i(),U=(0,S.useRef)(e);U.current=e;let W=(0,S.useRef)(B);W.current=B,(0,S.useEffect)(()=>(V(`agent-jobs-pane`,e=>{let t=e;t.type===`queue`&&(t.projectId&&t.projectId!==U.current||W.current())}),()=>H(`agent-jobs-pane`)),[V,H]);let G=(0,S.useCallback)(e=>{let t=e.clientX,n=M,r=window.innerWidth-w;try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}let i=e=>{let i=Math.min(Math.max(n+(t-e.clientX),w),r);N(i)},a=()=>{window.removeEventListener(`pointermove`,i),window.removeEventListener(`pointerup`,a),window.removeEventListener(`pointercancel`,a)};window.addEventListener(`pointermove`,i),window.addEventListener(`pointerup`,a),window.addEventListener(`pointercancel`,a)},[M]);return(0,C.jsxs)(`div`,{className:u(`flex h-full flex-col overflow-hidden border-l border-border bg-background`,P&&`absolute inset-0 z-30 border-l-0`),style:P?void 0:{width:M,flexShrink:0},children:[(0,C.jsx)(`div`,{className:`relative flex items-center`,children:!P&&(0,C.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,onPointerDown:G,className:`absolute left-0 top-0 h-full w-1.5 -translate-x-full cursor-col-resize select-none touch-none hover:bg-accent-primary/20`,title:t(`workspace.resizeJobs`)})}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/60 bg-surface/40 px-3 py-1.5`,children:[(0,C.jsx)(`span`,{className:`text-xs font-medium text-foreground/70`,children:t(`workspace.jobs`)}),(0,C.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,C.jsx)(`button`,{type:`button`,onClick:()=>F(e=>!e),"aria-label":t(P?`restore`:`maximize`),title:t(P?`restore`:`maximize`),className:`rounded-md p-1 text-foreground/60 hover:bg-surface hover:text-foreground`,children:P?(0,C.jsx)(g,{className:`h-4 w-4`}):(0,C.jsx)(_,{className:`h-4 w-4`})}),(0,C.jsx)(`button`,{type:`button`,onClick:D,"aria-label":t(`workspace.closeJobs`),title:t(`workspace.closeJobs`),className:`rounded-md p-1 text-foreground/60 hover:bg-surface hover:text-foreground`,children:(0,C.jsx)(l,{className:`h-4 w-4`})})]})]}),(0,C.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-2`,children:z?(0,C.jsx)(`div`,{className:`flex h-24 items-center justify-center text-muted-foreground`,children:(0,C.jsx)(c,{className:`h-4 w-4 animate-spin`})}):R.length===0?(0,C.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 text-center text-muted-foreground`,children:[(0,C.jsx)(p,{className:`h-6 w-6 opacity-40`}),(0,C.jsx)(`p`,{className:`text-xs`,children:t(`workspace.noJobs`)})]}):(0,C.jsx)(`ul`,{className:`space-y-1`,children:R.map(e=>(0,C.jsx)(`li`,{children:(0,C.jsxs)(`button`,{type:`button`,onClick:()=>L(e.id),className:u(`flex w-full flex-col gap-1 rounded-lg border border-border/50 bg-surface/30 px-2.5 py-2 text-left transition-colors`,`hover:border-accent-primary/40 hover:bg-surface/60`),children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(h,{variant:E[e.status]??`queued`,children:n(`statusLabel.${e.status in E?e.status:`queued`}`)}),e.status===`running`&&(0,C.jsx)(c,{className:`h-3 w-3 animate-spin text-accent-primary`}),(0,C.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:(()=>{let t=y(b(e));return t?d(t,{addSuffix:!0,locale:r()}):`—`})()})]}),(0,C.jsx)(`code`,{className:`truncate font-mono text-xs text-foreground/85`,children:v(e.command,j)})]})},e.id))})}),I&&(0,C.jsx)(x,{jobId:I,projectId:e,onClose:()=>L(null)})]})}export{D as AgentModeJobsPane};
@@ -1,4 +1,4 @@
1
- import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{t as r}from"./react-dom-DiWzBDP9.js";import{h as i,r as a}from"./useSharedWebSocket-Dz-HI6De.js";import{t as o}from"./Trans-DEbgkuAY.js";import{n as s,t as c}from"./createLucideIcon-Bjbbp_KS.js";import{a as l,r as u,s as d}from"./useDesktop-QogiN0zR.js";import{c as f,s as p}from"./provider-capabilities-Vi1ZGvAK.js";import{n as m,t as h}from"./save-B6wGWwBR.js";import{c as g,d as _,n as v,r as y,u as b}from"./MinimizedChatsContext-D3QzgV0B.js";import{t as x}from"./file-text-CFT-xXKN.js";import{t as S}from"./loader-circle-DcygOQpC.js";import{t as C}from"./pencil-C9RkrIPZ.js";import{t as w}from"./plus-CsnjfkmX.js";import{t as ee}from"./search-Cq_gE3Ik.js";import{t as T}from"./sparkles-DrY8hb0X.js";import{t as E}from"./trash-2-BOU3WdZZ.js";import{t as D}from"./triangle-alert-H9T4jAmh.js";import{t as O}from"./x-CBMI9ejn.js";import{M as k,a as A,i as j,j as M,l as N,o as P,r as F,t as I}from"./dialog-xXB2q5HJ.js";import{t as L}from"./button-Ccc9Dc-D.js";import{A as R,C as z,D as B,Dt as V,E as H,Et as U,It as te,Lt as W,M as G,Nt as K,O as ne,P as re,Rt as ie,S as ae,T as oe,V as se,Wt as ce,X as le,at as ue,ct as de,ht as fe,j as q,k as pe,u as J,v as me,vt as Y,w as he,x as ge,yt as _e}from"./index-BcligJ3-.js";import{t as ve}from"./format-command-C0D9IPmV.js";var ye=c(`flask-conical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),X=e(t(),1),Z=n(),be=/^[a-z0-9][a-z0-9-]*$/;function xe({open:e,mode:t=`add`,initial:n,chainAgents:r,onConfirm:i,onCancel:a}){let{t:c}=s(`agents`),[l,u]=(0,X.useState)(``),[d,f]=(0,X.useState)(r[0]??``);(0,X.useEffect)(()=>{e&&(t===`edit`&&n?(u(n.tags.join(`, `)),f(r.includes(n.agent)?n.agent:r[0]??``)):(u(``),f(r[0]??``)))},[e,t,n,r]);let p=l.split(`,`).map(e=>e.trim()).filter(Boolean),m=p.filter(e=>!be.test(e)),h=p.length>0&&m.length===0&&r.includes(d);return(0,Z.jsx)(I,{open:e,onOpenChange:e=>{e||a()},children:(0,Z.jsxs)(F,{movableResizable:!0,className:`max-w-md`,children:[(0,Z.jsxs)(P,{children:[(0,Z.jsx)(N,{children:c(t===`edit`?`routingRule.editTitle`:`routingRule.addTitle`)}),(0,Z.jsx)(j,{children:c(t===`edit`?`routingRule.editDescription`:`routingRule.addDescription`)})]}),(0,Z.jsxs)(`div`,{className:`py-2 space-y-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground mb-1`,children:c(`routingRule.tagsLabel`)}),(0,Z.jsx)(re,{autoFocus:!0,value:l,onChange:e=>u(e.target.value),placeholder:`frontend, ui`,"aria-label":c(`routingRule.tagsLabel`),className:`text-sm font-mono`}),(0,Z.jsx)(`p`,{className:`text-[11px] text-muted-foreground mt-1`,children:(0,Z.jsx)(o,{t:c,i18nKey:`routingRule.tagsHint`,components:{code:(0,Z.jsx)(`code`,{})}})}),m.length>0&&(0,Z.jsx)(`p`,{className:`text-[11px] text-red-400 aurora-light:text-destructive mt-1`,children:c(`routingRule.invalidTags`,{count:m.length,tags:m.join(`, `)})})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground mb-1`,children:c(`routingRule.routeToLabel`)}),(0,Z.jsx)(`select`,{value:d,onChange:e=>f(e.target.value),"aria-label":c(`routingRule.routeToLabel`),className:`w-full h-9 px-2 text-sm rounded-md border border-border bg-background`,children:r.map(e=>(0,Z.jsx)(`option`,{value:e,children:e},e))}),(0,Z.jsx)(`p`,{className:`text-[11px] text-muted-foreground mt-1`,children:c(`routingRule.routeToHint`)})]})]}),(0,Z.jsxs)(A,{children:[(0,Z.jsx)(L,{variant:`ghost`,size:`sm`,onClick:a,children:c(`common:actions.cancel`)}),(0,Z.jsx)(L,{size:`sm`,onClick:()=>i(p,d),disabled:!h,children:c(t===`edit`?`routingRule.saveChanges`:`routingRule.addRule`)})]})]})})}var Se=new Set([`sr-architect`,`sr-developer`,`sr-reviewer`,`sr-merge-resolver`]),Ce=[`sonnet`,`fable`,`opus`,`haiku`],we=/^[a-z0-9][a-z0-9-]*$/,Te=Ce.map(e=>({value:e,label:e})),Ee=[...Se];function De({profile:e,onChange:t,footer:n,provider:r=e.provider??`claude`,modelCatalog:i=Te,defaultModel:a=i[0]?.value??``,customModelAliases:c=!1,baselineAgents:u=Ee,onValidityChange:d,onSoftWarningsChange:f}){let{t:p}=s(`agentstudio`),[m,h]=(0,X.useState)([]),[g,_]=(0,X.useState)(!1),[v,y]=(0,X.useState)(!1),[b,x]=(0,X.useState)(null),S=(0,X.useMemo)(()=>new Set(u),[u]);(0,X.useEffect)(()=>{let e=!1;return fetch(`${l()}/profiles/catalog?provider=${encodeURIComponent(r)}`).then(e=>e.ok?e.json():{agents:[]}).then(t=>{e||h(t.agents)}).catch(()=>{e||h([])}),()=>{e=!0}},[r]);let C=n=>{let r=JSON.parse(JSON.stringify(e));n(r),t(r)},ee=new Set(e.agents.map(e=>e.id)),T=m.filter(e=>!ee.has(e.id)),E=(0,X.useMemo)(()=>{let t=[];for(let n of S)e.agents.some(e=>e.id===n)||t.push(p(`profileEditor.validation.missingBaseline`,{agent:n}));let n=e.routing.filter(e=>`default`in e&&e.default===!0);if(n.length>1&&t.push(p(`profileEditor.validation.multipleDefaultRules`,{found:n.length})),n.length===1){let n=e.routing[e.routing.length-1];`default`in n&&n.default===!0||t.push(p(`profileEditor.validation.defaultRuleNotLast`))}for(let n of e.routing)if(e.agents.some(e=>e.id===n.agent)||t.push(p(`profileEditor.validation.unknownRoutingAgent`,{agent:n.agent})),`tags`in n){let e=n.tags.filter(e=>!we.test(e));e.length>0&&t.push(p(`profileEditor.validation.invalidTags`,{agent:n.agent,tags:e.join(`, `)}))}return t},[e,S,p]),D=(0,X.useMemo)(()=>{if(e.routing.length===0)return[];let t=new Set(e.routing.map(e=>e.agent));return e.agents.filter(e=>!S.has(e.id)&&!t.has(e.id)).map(e=>e.id)},[e,S]),k=(0,X.useMemo)(()=>e.routing.some(e=>`default`in e&&e.default===!0),[e.routing]);(0,X.useEffect)(()=>{d&&d(E)},[E,d]),(0,X.useEffect)(()=>{f&&f({agentsMissingRouting:D})},[D,f]);let A=e=>{C(t=>{let n={id:e,model:a},r=t.agents.findIndex(e=>e.id===`sr-merge-resolver`);r>=0?t.agents.splice(r,0,n):t.agents.push(n)}),_(!1)},j=t=>{let n=e.agents[t];S.has(n.id)||C(e=>{e.agents.splice(t,1),e.routing=e.routing.filter(e=>e.agent!==n.id)})},M=(t,n)=>{if(t===n)return;let r=e.agents.findIndex(e=>e.id===t),i=e.agents.findIndex(e=>e.id===n);if(r<0||i<0)return;let a=ae(e.agents,r,i),o=a.findIndex(e=>e.id===`sr-architect`);if(o>0){let[e]=a.splice(o,1);a.unshift(e)}let s=a.findIndex(e=>e.id===`sr-merge-resolver`);if(s>=0&&s!==a.length-1){let[e]=a.splice(s,1);a.push(e)}C(e=>{e.agents=a})},N=q(R(ne,{activationConstraint:{distance:4}}),R(B,{coordinateGetter:z})),P=e=>{let{active:t,over:n}=e;n&&M(String(t.id),String(n.id))},F=(e,t)=>{C(n=>{n.agents[e].model=t})},I=(e,t)=>{C(n=>{let r={tags:e,agent:t},i=n.routing.findIndex(e=>`default`in e&&e.default===!0);i>=0?n.routing.splice(i,0,r):n.routing.push(r)}),y(!1)},V=()=>{C(e=>{e.routing.some(e=>`default`in e&&e.default===!0)||e.agents.some(e=>e.id===`sr-developer`)&&e.routing.push({default:!0,agent:`sr-developer`})})},U=e=>`default`in e&&e.default===!0,te=(e,t)=>{C(n=>{let r=n.routing[e];r&&(U(r)||(r.agent=t))})},W=(e,t,n)=>{C(r=>{let i=r.routing[e];i&&(U(i)||(i.tags=t,i.agent=n))})},G=e=>{C(t=>{let n=t.routing[e];n&&(U(n)||t.routing.splice(e,1))})},K=(t,n)=>{let r=t+n;if(r<0||r>=e.routing.length)return;let i=e.routing[t],a=e.routing[r];U(i)||U(a)||C(e=>{let[n]=e.routing.splice(t,1);e.routing.splice(r,0,n)})};return(0,Z.jsxs)(`div`,{className:`p-6 space-y-6 max-w-3xl`,children:[(0,Z.jsx)(xe,{open:v,mode:`add`,chainAgents:e.agents.map(e=>e.id),onConfirm:I,onCancel:()=>y(!1)}),(0,Z.jsx)(xe,{open:b!==null,mode:`edit`,initial:b!==null&&e.routing[b]&&!(`default`in e.routing[b])?{tags:e.routing[b].tags,agent:e.routing[b].agent}:void 0,chainAgents:e.agents.map(e=>e.id),onConfirm:(e,t)=>{b!==null&&(W(b,e,t),x(null))},onCancel:()=>x(null)}),E.length>0&&(0,Z.jsxs)(`div`,{className:`px-3 py-2 text-xs rounded-md border border-yellow-500/30 aurora-light:border-accent-warning/30 bg-yellow-500/10 aurora-light:bg-accent-warning/10 text-yellow-500 aurora-light:text-accent-warning`,children:[(0,Z.jsx)(`div`,{className:`font-medium mb-1`,children:p(`profileEditor.validationSummary`,{count:E.length})}),(0,Z.jsx)(`ul`,{className:`list-disc list-inside space-y-0.5`,children:E.map((e,t)=>(0,Z.jsx)(`li`,{children:e},t))})]}),(0,Z.jsxs)(`section`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground mb-1`,children:p(`profileEditor.nameLabel`)}),(0,Z.jsx)(re,{value:e.name,disabled:!0,className:`text-sm`})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground mb-1`,children:p(`profileEditor.descriptionLabel`)}),(0,Z.jsx)(re,{value:e.description??``,onChange:e=>C(t=>{t.description=e.target.value}),className:`text-sm`,placeholder:p(`profileEditor.descriptionPlaceholder`)})]})]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide mb-2`,children:p(`profileEditor.orchestrator.heading`)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 p-3 rounded-md border border-border`,children:[(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`text-sm font-mono text-foreground truncate`,children:[ve(`/specrails:implement`,r),` ·`,` `,ve(`/specrails:batch-implement`,r)]}),(0,Z.jsx)(`div`,{className:`text-[11px] text-muted-foreground mt-0.5`,children:p(`profileEditor.orchestrator.description`)})]}),(0,Z.jsx)(Q,{value:e.orchestrator.model,models:i,customModelAliases:c,testId:`profile-orchestrator-model`,onChange:e=>C(t=>{t.orchestrator.model=e})})]})]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,Z.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:p(`profileEditor.agentChain.heading`,{n:e.agents.length})}),(0,Z.jsxs)(L,{size:`sm`,variant:`ghost`,onClick:()=>_(e=>!e),disabled:T.length===0,title:T.length===0?p(`profileEditor.agentChain.addDisabledTitle`):p(`profileEditor.agentChain.addTitle`),children:[(0,Z.jsx)(w,{className:`w-3.5 h-3.5 mr-1`}),` `,p(`common:actions.add`)]})]}),g&&(0,Z.jsxs)(`div`,{className:`mb-2 p-2 rounded-md border border-border bg-muted/30`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5 px-1`,children:[(0,Z.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:p(`profileEditor.agentChain.pickFromCatalog`,{n:T.length})}),(0,Z.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,onClick:()=>_(!1),title:p(`common:actions.close`),children:(0,Z.jsx)(O,{className:`w-3 h-3`})})]}),T.length===0?(0,Z.jsx)(`div`,{className:`px-2 py-3 text-xs text-muted-foreground text-center`,children:p(`profileEditor.agentChain.emptyCatalog`)}):(0,Z.jsx)(`div`,{className:`space-y-0.5 max-h-64 overflow-auto`,children:T.map(e=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>A(e.id),className:`w-full flex items-center justify-between gap-2 px-2 py-1.5 text-left rounded hover:bg-accent transition-colors`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-mono`,children:e.id}),(0,Z.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded `+(e.kind===`custom`?`bg-purple-500/15 aurora-light:bg-accent-secondary/15 text-purple-400 aurora-light:text-accent-secondary`:`bg-muted text-muted-foreground`),children:p(`profileEditor.agentChain.kind.${e.kind}`)})]},e.id))})]}),(0,Z.jsx)(H,{sensors:N,collisionDetection:pe,onDragEnd:P,children:(0,Z.jsx)(ge,{items:e.agents.map(e=>e.id),strategy:oe,children:(0,Z.jsx)(`div`,{className:`space-y-1.5`,children:e.agents.map((e,t)=>(0,Z.jsx)(Oe,{agent:e,required:S.has(e.id),canRemove:!S.has(e.id),models:i,defaultModel:a,customModelAliases:c,onModel:e=>F(t,e),onRemove:()=>j(t)},e.id))})})})]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,Z.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:p(`profileEditor.routing.heading`,{n:e.routing.length})}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[!k&&(0,Z.jsxs)(L,{size:`sm`,variant:`ghost`,onClick:V,disabled:e.agents.length===0,title:e.agents.length===0?p(`profileEditor.routing.needAgentsTitle`):void 0,children:[(0,Z.jsx)(w,{className:`w-3.5 h-3.5 mr-1`}),` `,p(`profileEditor.routing.addDefault`)]}),(0,Z.jsxs)(L,{size:`sm`,variant:`ghost`,onClick:()=>y(!0),disabled:e.agents.length===0,title:e.agents.length===0?p(`profileEditor.routing.needAgentsTitle`):void 0,children:[(0,Z.jsx)(w,{className:`w-3.5 h-3.5 mr-1`}),` `,p(`profileEditor.routing.addRule`)]})]})]}),(0,Z.jsx)(`p`,{className:`text-[11px] text-muted-foreground mb-2`,children:p(`profileEditor.routing.explainer`)}),D.length>0&&(0,Z.jsxs)(`div`,{className:`mb-2 px-3 py-2 text-xs rounded-md border border-yellow-500/30 aurora-light:border-accent-warning/30 bg-yellow-500/10 aurora-light:bg-accent-warning/10 text-yellow-500 aurora-light:text-accent-warning`,children:[(0,Z.jsx)(`div`,{className:`font-medium mb-1`,children:p(`profileEditor.routing.untargetedTitle`)}),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(o,{t:p,i18nKey:`profileEditor.routing.untargetedDetail`,values:{agents:D.join(`, `)},components:{mono:(0,Z.jsx)(`span`,{className:`font-mono`})}})})]}),(0,Z.jsx)(`div`,{className:`space-y-1.5`,children:e.routing.map((t,n)=>{let r=`default`in t&&t.default===!0;return(0,Z.jsx)(ke,{rule:t,ordinal:n+1,isLast:n===e.routing.length-1,canMove:!r,canRemove:!r,canEdit:!r,chainAgents:e.agents.map(e=>e.id),onAgentChange:e=>te(n,e),onEdit:()=>x(n),onUp:()=>K(n,-1),onDown:()=>K(n,1),onRemove:()=>G(n)},n)})})]}),n&&(0,Z.jsx)(`div`,{className:`pt-3 border-t border-border`,children:n})]})}function Oe({agent:e,required:t,canRemove:n,models:r,defaultModel:i,customModelAliases:a,onModel:o,onRemove:c}){let{t:l}=s(`agentstudio`),u=t,d=e.id===`sr-architect`,f=e.id===`sr-merge-resolver`,{attributes:p,listeners:m,setNodeRef:h,transform:g,transition:_,isDragging:v}=he({id:e.id});return(0,Z.jsxs)(`div`,{ref:h,style:{transform:G.Transform.toString(g),transition:_,opacity:v?.5:void 0,zIndex:v?10:void 0},className:`flex items-center gap-2 px-2 py-1.5 rounded-md border border-border group hover:bg-accent/30 transition-colors bg-background`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`flex-shrink-0 p-0.5 rounded text-muted-foreground cursor-grab active:cursor-grabbing hover:text-foreground`,title:l(`profileEditor.agentRow.dragTitle`),"aria-label":l(`profileEditor.agentRow.dragHandleAria`),...p,...m,children:(0,Z.jsx)(V,{className:`w-3.5 h-3.5`})}),(0,Z.jsx)(`span`,{className:`text-sm font-mono flex-1 truncate`,children:e.id}),d&&(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-accent-primary/15 text-accent-primary`,title:l(`profileEditor.agentRow.pinnedFirstTitle`),children:[(0,Z.jsx)(Y,{className:`w-2.5 h-2.5 rotate-[135deg]`}),` `,l(`profileEditor.agentRow.pinnedFirst`)]}),f&&(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-accent-primary/15 text-accent-primary`,title:l(`profileEditor.agentRow.pinnedLastTitle`),children:[(0,Z.jsx)(Y,{className:`w-2.5 h-2.5 rotate-45`}),` `,l(`profileEditor.agentRow.pinnedLast`)]}),u&&!d&&!f&&(0,Z.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,children:l(`profileEditor.agentRow.required`)}),(0,Z.jsx)(Q,{value:e.model??i,models:r,customModelAliases:a,testId:`profile-agent-model-${e.id}`,onChange:o}),(0,Z.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-red-500/20 aurora-light:hover:bg-destructive/15 text-red-400 aurora-light:text-destructive rounded disabled:opacity-30 disabled:cursor-not-allowed opacity-0 group-hover:opacity-100 transition-opacity`,onClick:c,disabled:!n,title:l(n?`common:actions.remove`:`profileEditor.agentRow.requiredRemoveTitle`),children:(0,Z.jsx)(O,{className:`w-3 h-3`})})]})}function ke({rule:e,ordinal:t,isLast:n,canMove:r,canRemove:i,canEdit:a,chainAgents:o,onAgentChange:c,onEdit:l,onUp:u,onDown:d,onRemove:f}){let{t:p}=s(`agentstudio`),m=`default`in e&&e.default===!0;return(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 rounded-md border border-border group hover:bg-accent/30 transition-colors`,children:[(0,Z.jsxs)(`span`,{className:`text-[10px] font-mono text-muted-foreground w-5 text-center flex-shrink-0`,children:[t,`.`]}),m?(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground flex-1`,children:p(`profileEditor.routingRow.everythingElse`)}):(0,Z.jsx)(`span`,{className:`text-xs flex-1 flex gap-1 flex-wrap items-center`,children:e.tags.map(e=>(0,Z.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-muted font-mono text-[11px]`,children:e},e))}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`→`}),m?(0,Z.jsx)(`span`,{className:`h-7 max-w-[15rem] px-2 text-xs font-mono rounded border border-border bg-muted/40 text-muted-foreground inline-flex items-center`,"aria-label":p(`profileEditor.routingRow.defaultTargetAria`),title:p(`profileEditor.routingRow.defaultTargetTitle`),children:e.agent}):(0,Z.jsx)(`select`,{value:e.agent,onChange:e=>c(e.target.value),"aria-label":p(`profileEditor.routingRow.targetAria`,{ordinal:t}),className:`h-7 max-w-[15rem] px-2 text-xs font-mono rounded border border-border bg-background`,children:o.map(e=>(0,Z.jsx)(`option`,{value:e,children:e},e))}),(0,Z.jsxs)(`div`,{className:`flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity`,children:[a&&(0,Z.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,onClick:l,title:p(`profileEditor.routingRow.editTitle`),"aria-label":p(`profileEditor.routingRow.editAria`,{ordinal:t}),children:(0,Z.jsx)(C,{className:`w-3 h-3`})}),r&&!n&&(0,Z.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,onClick:d,title:p(`profileEditor.routingRow.moveDown`),children:(0,Z.jsx)(ce,{className:`w-3 h-3`})}),r&&t>1&&(0,Z.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,onClick:u,title:p(`profileEditor.routingRow.moveUp`),children:(0,Z.jsx)(_,{className:`w-3 h-3`})}),i&&(0,Z.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-red-500/20 aurora-light:hover:bg-destructive/15 text-red-400 aurora-light:text-destructive rounded`,onClick:f,title:p(`common:actions.remove`),children:(0,Z.jsx)(O,{className:`w-3 h-3`})})]}),m&&(0,Z.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,title:p(`profileEditor.routingRow.coreDefaultTitle`),children:p(`profileEditor.routingRow.coreDefaultBadge`)})]})}function Q({value:e,models:t,customModelAliases:n,testId:r,onChange:i}){return n?(0,Z.jsx)(se,{value:e,options:t,ariaLabel:`Model alias`,testId:r,className:`h-7 w-52 bg-background px-2 text-xs`,onCommit:i}):(0,Z.jsx)(`select`,{value:e,onChange:e=>i(e.target.value),className:`h-7 px-2 text-xs rounded border border-border bg-background`,children:(t.some(t=>t.value===e)?t:[...t,{value:e,label:e}]).map(e=>(0,Z.jsx)(`option`,{value:e.value,children:e.label},e.value))})}function Ae({open:e,title:t,description:n,placeholder:r,initialValue:i=``,confirmLabel:a,inputPattern:o,inputInvalidHint:c,onConfirm:l,onCancel:u}){let{t:d}=s(),[f,p]=(0,X.useState)(i);(0,X.useEffect)(()=>{e&&p(i)},[e,i]);let m=f.trim(),h=!o||o.test(m),g=m.length>0&&h;return(0,Z.jsx)(I,{open:e,onOpenChange:e=>{e||u()},children:(0,Z.jsxs)(F,{movableResizable:!0,className:`max-w-md`,children:[(0,Z.jsx)(P,{children:(0,Z.jsx)(N,{children:t})}),(0,Z.jsxs)(`div`,{className:`py-2 space-y-2`,children:[n&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n}),(0,Z.jsx)(re,{autoFocus:!0,value:f,placeholder:r,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&g&&l(m)},className:`text-sm font-mono`}),m.length>0&&!h&&c&&(0,Z.jsx)(`p`,{className:`text-[11px] text-yellow-500 aurora-light:text-accent-warning`,children:c})]}),(0,Z.jsxs)(A,{children:[(0,Z.jsx)(L,{variant:`ghost`,size:`sm`,onClick:u,children:d(`actions.cancel`)}),(0,Z.jsx)(L,{size:`sm`,onClick:()=>l(m),disabled:!g,children:a??d(`actions.confirm`)})]})]})})}function je({open:e,title:t,description:n,confirmLabel:r,destructive:i=!1,onConfirm:a,onCancel:o}){let{t:c}=s();return(0,Z.jsx)(I,{open:e,onOpenChange:e=>{e||o()},children:(0,Z.jsxs)(F,{movableResizable:!0,className:`max-w-md`,children:[(0,Z.jsx)(P,{children:(0,Z.jsx)(N,{children:t})}),n&&(0,Z.jsx)(`div`,{className:`py-2`,children:(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n})}),(0,Z.jsxs)(A,{children:[(0,Z.jsx)(L,{variant:`ghost`,size:`sm`,onClick:o,children:c(`actions.cancel`)}),(0,Z.jsx)(L,{size:`sm`,onClick:a,className:i?`bg-red-500 hover:bg-red-600 text-white`:void 0,children:r??c(`actions.confirm`)})]})]})})}var Me={models:Ce.map(e=>({value:e,label:e})),defaultModel:`sonnet`,baselineAgents:[...Se],customModelAliases:!1},Ne={primaryProvider:`claude`,providers:[`claude`],catalogs:{claude:Me}};function Pe(e,t,n){return{schemaVersion:1,name:e,description:``,provider:t,orchestrator:{model:n.defaultModel},agents:n.baselineAgents.map(e=>({id:e,model:n.defaultModel,required:!0})),routing:[{default:!0,agent:`sr-developer`}]}}function Fe(){let{t:e}=s(`agents`),[t,n]=(0,X.useState)([]),[r,i]=(0,X.useState)(Ne),[a,c]=(0,X.useState)(``),[u,f]=(0,X.useState)(null),[m,g]=(0,X.useState)(null),[_,v]=(0,X.useState)(!0),[y,b]=(0,X.useState)(null),[x,S]=(0,X.useState)(!1),[C,ee]=(0,X.useState)([]),[T,D]=(0,X.useState)([]),[O,k]=(0,X.useState)(!1),[A,j]=(0,X.useState)(null),[M,N]=(0,X.useState)(null),P=a,F=r.catalogs[P]??Me;(0,X.useEffect)(()=>{let e=!1;return fetch(`${l()}/profiles/context`).then(e=>{if(!e.ok)throw Error(`profile context unavailable`);return e.json()}).then(t=>{if(e)return;let n=Array.isArray(t.providers)&&t.providers.length>0?t.providers:[t.primaryProvider||`claude`],r=n.includes(t.primaryProvider)?t.primaryProvider:n[0];i({...t,providers:n,primaryProvider:r}),c(r)}).catch(()=>{e||(i(Ne),c(Ne.primaryProvider))}),()=>{e=!0}},[]);let I=(0,X.useCallback)(async()=>{if(P){v(!0),b(null);try{let t=await fetch(`${l()}/profiles?provider=${encodeURIComponent(P)}`);if(!t.ok)throw Error(e(`profiles.errors.listFailed`,{status:t.status}));let r=await t.json();n(r.profiles),f(e=>e&&r.profiles.some(t=>t.name===e)?e:r.profiles[0]?.name??null)}catch(e){b(e.message)}finally{v(!1)}}},[P,e]);(0,X.useEffect)(()=>{P&&I()},[P,I]),(0,X.useEffect)(()=>{if(!u){g(null);return}let t=!1;return fetch(`${l()}/profiles/${encodeURIComponent(u)}?provider=${encodeURIComponent(P)}`).then(t=>{if(!t.ok)throw Error(e(`profiles.errors.loadFailed`,{status:t.status}));return t.json()}).then(e=>{t||g(e.profile)}).catch(e=>{t||b(e.message)}),()=>{t=!0}},[P,u,e]);let R=(0,X.useCallback)(async()=>{S(!0),b(null);try{let t=await fetch(`${l()}/profiles/migrate-from-settings?provider=${encodeURIComponent(P)}`,{method:`POST`});if(!t.ok){let n=await t.json().catch(()=>({}));throw Error(n.error??e(`profiles.errors.migrationFailed`,{status:t.status}))}await I(),f(`default`),d.success(e(`profiles.toasts.migrated`),{description:e(`profiles.toasts.migratedDescription`)})}catch(t){let n=t.message;b(n),d.error(e(`profiles.toasts.migrationFailed`),{description:n})}finally{S(!1)}},[P,I,e]),z=(0,X.useCallback)(async t=>{k(!1),S(!0),b(null);try{let n=Pe(t,P,F),r=await fetch(`${l()}/profiles?provider=${encodeURIComponent(P)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});if(!r.ok){let t=await r.json().catch(()=>({}));throw Error(t.error??e(`profiles.errors.createFailed`,{status:r.status}))}await I(),f(t),d.success(e(`profiles.toasts.created`),{description:t})}catch(t){let n=t.message;b(n),d.error(e(`profiles.toasts.createFailed`),{description:n})}finally{S(!1)}},[F,P,I,e]),B=(0,X.useCallback)(async(t,n)=>{j(null),S(!0),b(null);try{let r=await fetch(`${l()}/profiles/${encodeURIComponent(t)}/duplicate?provider=${encodeURIComponent(P)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:n,provider:P})});if(!r.ok){let t=await r.json().catch(()=>({}));throw Error(t.error??e(`profiles.errors.duplicateFailed`,{status:r.status}))}await I(),f(n),d.success(e(`profiles.toasts.duplicated`),{description:e(`profiles.toasts.duplicatedDescription`,{from:t,to:n})})}catch(t){let n=t.message;b(n),d.error(e(`profiles.toasts.duplicateFailed`),{description:n})}finally{S(!1)}},[P,I,e]),V=(0,X.useCallback)(async t=>{N(null),S(!0),b(null);try{let n=await fetch(`${l()}/profiles/${encodeURIComponent(t)}?provider=${encodeURIComponent(P)}`,{method:`DELETE`});if(!n.ok){let t=await n.json().catch(()=>({}));throw Error(t.error??e(`profiles.errors.deleteFailed`,{status:n.status}))}f(e=>e===t?null:e),await I(),d.success(e(`profiles.toasts.deleted`),{description:t})}catch(t){let n=t.message;b(n),d.error(e(`profiles.toasts.deleteFailed`),{description:n})}finally{S(!1)}},[P,I,e]),H=(0,X.useCallback)(()=>k(!0),[]),U=(0,X.useCallback)(e=>j({from:e}),[]),te=(0,X.useCallback)(e=>N({name:e}),[]),W=(0,X.useCallback)(async(t,n)=>{S(!0),b(null);try{let r=await fetch(`${l()}/profiles/${encodeURIComponent(t.name)}?provider=${encodeURIComponent(P)}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...t,provider:P})});if(!r.ok){let t=await r.json().catch(()=>({}));throw Error(t.error??e(`profiles.errors.saveFailed`,{status:r.status}))}g(t),n.length>0?d.warning(e(`profiles.toasts.savedWithUntargeted`),{description:e(`profiles.toasts.savedWithUntargetedDescription`,{agents:n.join(`, `)}),duration:6e3}):d.success(e(`profiles.toasts.saved`),{description:t.name})}catch(t){let n=t.message;b(n),d.error(e(`profiles.toasts.saveFailed`),{description:n})}finally{S(!1)}},[P,e]),G=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Ae,{open:O,title:e(`profiles.createDialog.title`),description:e(`profiles.createDialog.description`),placeholder:`my-profile`,confirmLabel:e(`profiles.createDialog.confirmLabel`),inputPattern:/^[a-z0-9][a-z0-9-]*$/,inputInvalidHint:e(`profiles.createDialog.invalidHint`),onConfirm:e=>void z(e),onCancel:()=>k(!1)}),A&&(0,Z.jsx)(Ae,{open:!0,title:e(`profiles.duplicateDialog.title`,{name:A.from}),description:e(`profiles.duplicateDialog.description`),placeholder:`${A.from}-copy`,initialValue:`${A.from}-copy`,confirmLabel:e(`common:actions.duplicate`),inputPattern:/^[a-z0-9][a-z0-9-]*$/,inputInvalidHint:e(`profiles.duplicateDialog.invalidHint`),onConfirm:e=>void B(A.from,e),onCancel:()=>j(null)}),M&&(0,Z.jsx)(je,{open:!0,title:e(`profiles.deleteDialog.title`,{name:M.name}),description:e(`profiles.deleteDialog.description`),confirmLabel:e(`common:actions.delete`),destructive:!0,onConfirm:()=>void V(M.name),onCancel:()=>N(null)})]});return _?(0,Z.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`profiles.loading`)})}):t.length===0?(0,Z.jsxs)(Z.Fragment,{children:[G,(0,Z.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,Z.jsxs)(`div`,{className:`text-center max-w-md`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:e(`profiles.empty.title`)}),(0,Z.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1 mb-4`,children:e(`profiles.empty.body`)}),r.providers.length>1&&(0,Z.jsx)(`select`,{value:P,"aria-label":e(`profiles.providerLabel`),onChange:e=>{f(null),g(null),c(e.target.value)},className:`mb-4 h-8 w-full rounded border border-border bg-background px-2 text-xs`,children:r.providers.map(e=>(0,Z.jsx)(`option`,{value:e,children:p(e)},e))}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 justify-center`,children:[(0,Z.jsxs)(L,{size:`sm`,onClick:R,disabled:x,children:[(0,Z.jsx)(ue,{className:`w-3.5 h-3.5 mr-1.5`}),` `,e(`profiles.empty.migrateButton`)]}),(0,Z.jsxs)(L,{size:`sm`,variant:`ghost`,onClick:H,disabled:x,children:[(0,Z.jsx)(w,{className:`w-3.5 h-3.5 mr-1.5`}),` `,e(`profiles.empty.blankButton`)]})]}),(0,Z.jsx)(`div`,{className:`text-[11px] text-muted-foreground/70 mt-3`,children:(0,Z.jsx)(o,{t:e,i18nKey:`profiles.empty.migrateExplainer`,components:{code:(0,Z.jsx)(`code`,{className:`text-foreground`})}})}),y&&(0,Z.jsx)(`div`,{className:`mt-3 text-xs text-red-400 aurora-light:text-destructive`,children:y})]})})]}):(0,Z.jsxs)(`div`,{className:`flex flex-col h-full`,children:[G,(0,Z.jsxs)(`div`,{className:`flex flex-1 min-h-0`,children:[(0,Z.jsxs)(`aside`,{className:`w-64 flex-shrink-0 border-r border-border flex flex-col`,children:[(0,Z.jsxs)(`div`,{className:`p-3 space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e(`profiles.sidebar.title`)}),(0,Z.jsx)(L,{size:`sm`,variant:`ghost`,onClick:H,disabled:x,children:(0,Z.jsx)(w,{className:`w-3.5 h-3.5`})})]}),r.providers.length>1&&(0,Z.jsx)(`select`,{value:P,"aria-label":e(`profiles.providerLabel`),onChange:e=>{f(null),g(null),c(e.target.value)},className:`h-7 w-full rounded border border-border bg-background px-2 text-xs`,children:r.providers.map(e=>(0,Z.jsx)(`option`,{value:e,children:p(e)},e))})]}),(0,Z.jsx)(`div`,{className:`flex-1 overflow-auto px-2 pb-3`,children:t.map(t=>(0,Z.jsxs)(`div`,{className:`group mb-1 rounded-md px-2 py-1.5 text-xs cursor-pointer transition-colors flex items-center justify-between `+(t.name===u?`bg-accent text-foreground`:`text-muted-foreground hover:bg-accent/50 hover:text-foreground`),onClick:()=>f(t.name),role:`button`,tabIndex:0,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&f(t.name)},children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,Z.jsx)(`span`,{className:`truncate font-medium`,children:t.name}),t.isDefault&&(0,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:e(`profiles.sidebar.teamDefault`)})]}),(0,Z.jsxs)(`div`,{className:`flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,title:e(`common:actions.duplicate`),onClick:e=>{e.stopPropagation(),U(t.name)},children:(0,Z.jsx)(K,{className:`w-3 h-3`})}),!t.isDefault&&(0,Z.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-red-500/20 text-red-400 aurora-light:text-destructive rounded`,title:e(`common:actions.delete`),onClick:e=>{e.stopPropagation(),te(t.name)},children:(0,Z.jsx)(E,{className:`w-3 h-3`})})]})]},t.name))})]}),(0,Z.jsxs)(`main`,{className:`flex-1 overflow-auto`,children:[y&&(0,Z.jsx)(`div`,{className:`mx-4 mt-4 px-3 py-2 text-xs rounded border border-red-500/30 aurora-light:border-destructive/30 bg-red-500/10 aurora-light:bg-destructive/10 text-red-400 aurora-light:text-destructive`,children:y}),m?(0,Z.jsx)(De,{profile:m,provider:P,modelCatalog:F.models,defaultModel:F.defaultModel,customModelAliases:F.customModelAliases===!0,baselineAgents:F.baselineAgents,onChange:g,onValidityChange:ee,onSoftWarningsChange:e=>D(e.agentsMissingRouting),footer:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsxs)(L,{size:`sm`,onClick:()=>void W(m,T),disabled:x||C.length>0,title:C.length>0?e(`profiles.editorFooter.fixValidationIssues`):void 0,children:[(0,Z.jsx)(h,{className:`w-3.5 h-3.5 mr-1.5`}),e(`common:actions.save`)]}),x&&(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`common:states.saving`)}),C.length>0&&(0,Z.jsx)(`span`,{className:`text-xs text-yellow-500 aurora-light:text-accent-warning`,children:e(`profiles.editorFooter.issuesToResolve`,{count:C.length})})]})},`${P}:${m.name}`):(0,Z.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`profiles.selectPrompt`)})})]})]})]})}function $(e){let t=e.workflow.map((e,t)=>`${t+1}. ${e}`).join(`
1
+ import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{t as r}from"./react-dom-DiWzBDP9.js";import{h as i,r as a}from"./useSharedWebSocket-Dz-HI6De.js";import{t as o}from"./Trans-DEbgkuAY.js";import{n as s,t as c}from"./createLucideIcon-Bjbbp_KS.js";import{a as l,r as u,s as d}from"./useDesktop-QogiN0zR.js";import{c as f,s as p}from"./provider-capabilities-Vi1ZGvAK.js";import{n as m,t as h}from"./save-B6wGWwBR.js";import{c as g,d as _,n as v,r as y,u as b}from"./MinimizedChatsContext-D3QzgV0B.js";import{t as x}from"./file-text-CFT-xXKN.js";import{t as S}from"./loader-circle-DcygOQpC.js";import{t as C}from"./pencil-C9RkrIPZ.js";import{t as w}from"./plus-CsnjfkmX.js";import{t as ee}from"./search-Cq_gE3Ik.js";import{t as T}from"./sparkles-DrY8hb0X.js";import{t as E}from"./trash-2-BOU3WdZZ.js";import{t as D}from"./triangle-alert-H9T4jAmh.js";import{t as O}from"./x-CBMI9ejn.js";import{M as k,a as A,i as j,j as M,l as N,o as P,r as F,t as I}from"./dialog-xXB2q5HJ.js";import{t as L}from"./button-Ccc9Dc-D.js";import{A as R,C as z,D as B,Dt as V,E as H,Et as U,It as te,Lt as W,M as G,Nt as K,O as ne,P as re,Rt as ie,S as ae,T as oe,V as se,Wt as ce,X as le,at as ue,ct as de,ht as fe,j as q,k as pe,u as J,v as me,vt as Y,w as he,x as ge,yt as _e}from"./index-Cxb288Rj.js";import{t as ve}from"./format-command-C0D9IPmV.js";var ye=c(`flask-conical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),X=e(t(),1),Z=n(),be=/^[a-z0-9][a-z0-9-]*$/;function xe({open:e,mode:t=`add`,initial:n,chainAgents:r,onConfirm:i,onCancel:a}){let{t:c}=s(`agents`),[l,u]=(0,X.useState)(``),[d,f]=(0,X.useState)(r[0]??``);(0,X.useEffect)(()=>{e&&(t===`edit`&&n?(u(n.tags.join(`, `)),f(r.includes(n.agent)?n.agent:r[0]??``)):(u(``),f(r[0]??``)))},[e,t,n,r]);let p=l.split(`,`).map(e=>e.trim()).filter(Boolean),m=p.filter(e=>!be.test(e)),h=p.length>0&&m.length===0&&r.includes(d);return(0,Z.jsx)(I,{open:e,onOpenChange:e=>{e||a()},children:(0,Z.jsxs)(F,{movableResizable:!0,className:`max-w-md`,children:[(0,Z.jsxs)(P,{children:[(0,Z.jsx)(N,{children:c(t===`edit`?`routingRule.editTitle`:`routingRule.addTitle`)}),(0,Z.jsx)(j,{children:c(t===`edit`?`routingRule.editDescription`:`routingRule.addDescription`)})]}),(0,Z.jsxs)(`div`,{className:`py-2 space-y-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground mb-1`,children:c(`routingRule.tagsLabel`)}),(0,Z.jsx)(re,{autoFocus:!0,value:l,onChange:e=>u(e.target.value),placeholder:`frontend, ui`,"aria-label":c(`routingRule.tagsLabel`),className:`text-sm font-mono`}),(0,Z.jsx)(`p`,{className:`text-[11px] text-muted-foreground mt-1`,children:(0,Z.jsx)(o,{t:c,i18nKey:`routingRule.tagsHint`,components:{code:(0,Z.jsx)(`code`,{})}})}),m.length>0&&(0,Z.jsx)(`p`,{className:`text-[11px] text-red-400 aurora-light:text-destructive mt-1`,children:c(`routingRule.invalidTags`,{count:m.length,tags:m.join(`, `)})})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground mb-1`,children:c(`routingRule.routeToLabel`)}),(0,Z.jsx)(`select`,{value:d,onChange:e=>f(e.target.value),"aria-label":c(`routingRule.routeToLabel`),className:`w-full h-9 px-2 text-sm rounded-md border border-border bg-background`,children:r.map(e=>(0,Z.jsx)(`option`,{value:e,children:e},e))}),(0,Z.jsx)(`p`,{className:`text-[11px] text-muted-foreground mt-1`,children:c(`routingRule.routeToHint`)})]})]}),(0,Z.jsxs)(A,{children:[(0,Z.jsx)(L,{variant:`ghost`,size:`sm`,onClick:a,children:c(`common:actions.cancel`)}),(0,Z.jsx)(L,{size:`sm`,onClick:()=>i(p,d),disabled:!h,children:c(t===`edit`?`routingRule.saveChanges`:`routingRule.addRule`)})]})]})})}var Se=new Set([`sr-architect`,`sr-developer`,`sr-reviewer`,`sr-merge-resolver`]),Ce=[`sonnet`,`fable`,`opus`,`haiku`],we=/^[a-z0-9][a-z0-9-]*$/,Te=Ce.map(e=>({value:e,label:e})),Ee=[...Se];function De({profile:e,onChange:t,footer:n,provider:r=e.provider??`claude`,modelCatalog:i=Te,defaultModel:a=i[0]?.value??``,customModelAliases:c=!1,baselineAgents:u=Ee,onValidityChange:d,onSoftWarningsChange:f}){let{t:p}=s(`agentstudio`),[m,h]=(0,X.useState)([]),[g,_]=(0,X.useState)(!1),[v,y]=(0,X.useState)(!1),[b,x]=(0,X.useState)(null),S=(0,X.useMemo)(()=>new Set(u),[u]);(0,X.useEffect)(()=>{let e=!1;return fetch(`${l()}/profiles/catalog?provider=${encodeURIComponent(r)}`).then(e=>e.ok?e.json():{agents:[]}).then(t=>{e||h(t.agents)}).catch(()=>{e||h([])}),()=>{e=!0}},[r]);let C=n=>{let r=JSON.parse(JSON.stringify(e));n(r),t(r)},ee=new Set(e.agents.map(e=>e.id)),T=m.filter(e=>!ee.has(e.id)),E=(0,X.useMemo)(()=>{let t=[];for(let n of S)e.agents.some(e=>e.id===n)||t.push(p(`profileEditor.validation.missingBaseline`,{agent:n}));let n=e.routing.filter(e=>`default`in e&&e.default===!0);if(n.length>1&&t.push(p(`profileEditor.validation.multipleDefaultRules`,{found:n.length})),n.length===1){let n=e.routing[e.routing.length-1];`default`in n&&n.default===!0||t.push(p(`profileEditor.validation.defaultRuleNotLast`))}for(let n of e.routing)if(e.agents.some(e=>e.id===n.agent)||t.push(p(`profileEditor.validation.unknownRoutingAgent`,{agent:n.agent})),`tags`in n){let e=n.tags.filter(e=>!we.test(e));e.length>0&&t.push(p(`profileEditor.validation.invalidTags`,{agent:n.agent,tags:e.join(`, `)}))}return t},[e,S,p]),D=(0,X.useMemo)(()=>{if(e.routing.length===0)return[];let t=new Set(e.routing.map(e=>e.agent));return e.agents.filter(e=>!S.has(e.id)&&!t.has(e.id)).map(e=>e.id)},[e,S]),k=(0,X.useMemo)(()=>e.routing.some(e=>`default`in e&&e.default===!0),[e.routing]);(0,X.useEffect)(()=>{d&&d(E)},[E,d]),(0,X.useEffect)(()=>{f&&f({agentsMissingRouting:D})},[D,f]);let A=e=>{C(t=>{let n={id:e,model:a},r=t.agents.findIndex(e=>e.id===`sr-merge-resolver`);r>=0?t.agents.splice(r,0,n):t.agents.push(n)}),_(!1)},j=t=>{let n=e.agents[t];S.has(n.id)||C(e=>{e.agents.splice(t,1),e.routing=e.routing.filter(e=>e.agent!==n.id)})},M=(t,n)=>{if(t===n)return;let r=e.agents.findIndex(e=>e.id===t),i=e.agents.findIndex(e=>e.id===n);if(r<0||i<0)return;let a=ae(e.agents,r,i),o=a.findIndex(e=>e.id===`sr-architect`);if(o>0){let[e]=a.splice(o,1);a.unshift(e)}let s=a.findIndex(e=>e.id===`sr-merge-resolver`);if(s>=0&&s!==a.length-1){let[e]=a.splice(s,1);a.push(e)}C(e=>{e.agents=a})},N=q(R(ne,{activationConstraint:{distance:4}}),R(B,{coordinateGetter:z})),P=e=>{let{active:t,over:n}=e;n&&M(String(t.id),String(n.id))},F=(e,t)=>{C(n=>{n.agents[e].model=t})},I=(e,t)=>{C(n=>{let r={tags:e,agent:t},i=n.routing.findIndex(e=>`default`in e&&e.default===!0);i>=0?n.routing.splice(i,0,r):n.routing.push(r)}),y(!1)},V=()=>{C(e=>{e.routing.some(e=>`default`in e&&e.default===!0)||e.agents.some(e=>e.id===`sr-developer`)&&e.routing.push({default:!0,agent:`sr-developer`})})},U=e=>`default`in e&&e.default===!0,te=(e,t)=>{C(n=>{let r=n.routing[e];r&&(U(r)||(r.agent=t))})},W=(e,t,n)=>{C(r=>{let i=r.routing[e];i&&(U(i)||(i.tags=t,i.agent=n))})},G=e=>{C(t=>{let n=t.routing[e];n&&(U(n)||t.routing.splice(e,1))})},K=(t,n)=>{let r=t+n;if(r<0||r>=e.routing.length)return;let i=e.routing[t],a=e.routing[r];U(i)||U(a)||C(e=>{let[n]=e.routing.splice(t,1);e.routing.splice(r,0,n)})};return(0,Z.jsxs)(`div`,{className:`p-6 space-y-6 max-w-3xl`,children:[(0,Z.jsx)(xe,{open:v,mode:`add`,chainAgents:e.agents.map(e=>e.id),onConfirm:I,onCancel:()=>y(!1)}),(0,Z.jsx)(xe,{open:b!==null,mode:`edit`,initial:b!==null&&e.routing[b]&&!(`default`in e.routing[b])?{tags:e.routing[b].tags,agent:e.routing[b].agent}:void 0,chainAgents:e.agents.map(e=>e.id),onConfirm:(e,t)=>{b!==null&&(W(b,e,t),x(null))},onCancel:()=>x(null)}),E.length>0&&(0,Z.jsxs)(`div`,{className:`px-3 py-2 text-xs rounded-md border border-yellow-500/30 aurora-light:border-accent-warning/30 bg-yellow-500/10 aurora-light:bg-accent-warning/10 text-yellow-500 aurora-light:text-accent-warning`,children:[(0,Z.jsx)(`div`,{className:`font-medium mb-1`,children:p(`profileEditor.validationSummary`,{count:E.length})}),(0,Z.jsx)(`ul`,{className:`list-disc list-inside space-y-0.5`,children:E.map((e,t)=>(0,Z.jsx)(`li`,{children:e},t))})]}),(0,Z.jsxs)(`section`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground mb-1`,children:p(`profileEditor.nameLabel`)}),(0,Z.jsx)(re,{value:e.name,disabled:!0,className:`text-sm`})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground mb-1`,children:p(`profileEditor.descriptionLabel`)}),(0,Z.jsx)(re,{value:e.description??``,onChange:e=>C(t=>{t.description=e.target.value}),className:`text-sm`,placeholder:p(`profileEditor.descriptionPlaceholder`)})]})]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide mb-2`,children:p(`profileEditor.orchestrator.heading`)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 p-3 rounded-md border border-border`,children:[(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`text-sm font-mono text-foreground truncate`,children:[ve(`/specrails:implement`,r),` ·`,` `,ve(`/specrails:batch-implement`,r)]}),(0,Z.jsx)(`div`,{className:`text-[11px] text-muted-foreground mt-0.5`,children:p(`profileEditor.orchestrator.description`)})]}),(0,Z.jsx)(Q,{value:e.orchestrator.model,models:i,customModelAliases:c,testId:`profile-orchestrator-model`,onChange:e=>C(t=>{t.orchestrator.model=e})})]})]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,Z.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:p(`profileEditor.agentChain.heading`,{n:e.agents.length})}),(0,Z.jsxs)(L,{size:`sm`,variant:`ghost`,onClick:()=>_(e=>!e),disabled:T.length===0,title:T.length===0?p(`profileEditor.agentChain.addDisabledTitle`):p(`profileEditor.agentChain.addTitle`),children:[(0,Z.jsx)(w,{className:`w-3.5 h-3.5 mr-1`}),` `,p(`common:actions.add`)]})]}),g&&(0,Z.jsxs)(`div`,{className:`mb-2 p-2 rounded-md border border-border bg-muted/30`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5 px-1`,children:[(0,Z.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:p(`profileEditor.agentChain.pickFromCatalog`,{n:T.length})}),(0,Z.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,onClick:()=>_(!1),title:p(`common:actions.close`),children:(0,Z.jsx)(O,{className:`w-3 h-3`})})]}),T.length===0?(0,Z.jsx)(`div`,{className:`px-2 py-3 text-xs text-muted-foreground text-center`,children:p(`profileEditor.agentChain.emptyCatalog`)}):(0,Z.jsx)(`div`,{className:`space-y-0.5 max-h-64 overflow-auto`,children:T.map(e=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>A(e.id),className:`w-full flex items-center justify-between gap-2 px-2 py-1.5 text-left rounded hover:bg-accent transition-colors`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-mono`,children:e.id}),(0,Z.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded `+(e.kind===`custom`?`bg-purple-500/15 aurora-light:bg-accent-secondary/15 text-purple-400 aurora-light:text-accent-secondary`:`bg-muted text-muted-foreground`),children:p(`profileEditor.agentChain.kind.${e.kind}`)})]},e.id))})]}),(0,Z.jsx)(H,{sensors:N,collisionDetection:pe,onDragEnd:P,children:(0,Z.jsx)(ge,{items:e.agents.map(e=>e.id),strategy:oe,children:(0,Z.jsx)(`div`,{className:`space-y-1.5`,children:e.agents.map((e,t)=>(0,Z.jsx)(Oe,{agent:e,required:S.has(e.id),canRemove:!S.has(e.id),models:i,defaultModel:a,customModelAliases:c,onModel:e=>F(t,e),onRemove:()=>j(t)},e.id))})})})]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,Z.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:p(`profileEditor.routing.heading`,{n:e.routing.length})}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[!k&&(0,Z.jsxs)(L,{size:`sm`,variant:`ghost`,onClick:V,disabled:e.agents.length===0,title:e.agents.length===0?p(`profileEditor.routing.needAgentsTitle`):void 0,children:[(0,Z.jsx)(w,{className:`w-3.5 h-3.5 mr-1`}),` `,p(`profileEditor.routing.addDefault`)]}),(0,Z.jsxs)(L,{size:`sm`,variant:`ghost`,onClick:()=>y(!0),disabled:e.agents.length===0,title:e.agents.length===0?p(`profileEditor.routing.needAgentsTitle`):void 0,children:[(0,Z.jsx)(w,{className:`w-3.5 h-3.5 mr-1`}),` `,p(`profileEditor.routing.addRule`)]})]})]}),(0,Z.jsx)(`p`,{className:`text-[11px] text-muted-foreground mb-2`,children:p(`profileEditor.routing.explainer`)}),D.length>0&&(0,Z.jsxs)(`div`,{className:`mb-2 px-3 py-2 text-xs rounded-md border border-yellow-500/30 aurora-light:border-accent-warning/30 bg-yellow-500/10 aurora-light:bg-accent-warning/10 text-yellow-500 aurora-light:text-accent-warning`,children:[(0,Z.jsx)(`div`,{className:`font-medium mb-1`,children:p(`profileEditor.routing.untargetedTitle`)}),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(o,{t:p,i18nKey:`profileEditor.routing.untargetedDetail`,values:{agents:D.join(`, `)},components:{mono:(0,Z.jsx)(`span`,{className:`font-mono`})}})})]}),(0,Z.jsx)(`div`,{className:`space-y-1.5`,children:e.routing.map((t,n)=>{let r=`default`in t&&t.default===!0;return(0,Z.jsx)(ke,{rule:t,ordinal:n+1,isLast:n===e.routing.length-1,canMove:!r,canRemove:!r,canEdit:!r,chainAgents:e.agents.map(e=>e.id),onAgentChange:e=>te(n,e),onEdit:()=>x(n),onUp:()=>K(n,-1),onDown:()=>K(n,1),onRemove:()=>G(n)},n)})})]}),n&&(0,Z.jsx)(`div`,{className:`pt-3 border-t border-border`,children:n})]})}function Oe({agent:e,required:t,canRemove:n,models:r,defaultModel:i,customModelAliases:a,onModel:o,onRemove:c}){let{t:l}=s(`agentstudio`),u=t,d=e.id===`sr-architect`,f=e.id===`sr-merge-resolver`,{attributes:p,listeners:m,setNodeRef:h,transform:g,transition:_,isDragging:v}=he({id:e.id});return(0,Z.jsxs)(`div`,{ref:h,style:{transform:G.Transform.toString(g),transition:_,opacity:v?.5:void 0,zIndex:v?10:void 0},className:`flex items-center gap-2 px-2 py-1.5 rounded-md border border-border group hover:bg-accent/30 transition-colors bg-background`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`flex-shrink-0 p-0.5 rounded text-muted-foreground cursor-grab active:cursor-grabbing hover:text-foreground`,title:l(`profileEditor.agentRow.dragTitle`),"aria-label":l(`profileEditor.agentRow.dragHandleAria`),...p,...m,children:(0,Z.jsx)(V,{className:`w-3.5 h-3.5`})}),(0,Z.jsx)(`span`,{className:`text-sm font-mono flex-1 truncate`,children:e.id}),d&&(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-accent-primary/15 text-accent-primary`,title:l(`profileEditor.agentRow.pinnedFirstTitle`),children:[(0,Z.jsx)(Y,{className:`w-2.5 h-2.5 rotate-[135deg]`}),` `,l(`profileEditor.agentRow.pinnedFirst`)]}),f&&(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-accent-primary/15 text-accent-primary`,title:l(`profileEditor.agentRow.pinnedLastTitle`),children:[(0,Z.jsx)(Y,{className:`w-2.5 h-2.5 rotate-45`}),` `,l(`profileEditor.agentRow.pinnedLast`)]}),u&&!d&&!f&&(0,Z.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,children:l(`profileEditor.agentRow.required`)}),(0,Z.jsx)(Q,{value:e.model??i,models:r,customModelAliases:a,testId:`profile-agent-model-${e.id}`,onChange:o}),(0,Z.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-red-500/20 aurora-light:hover:bg-destructive/15 text-red-400 aurora-light:text-destructive rounded disabled:opacity-30 disabled:cursor-not-allowed opacity-0 group-hover:opacity-100 transition-opacity`,onClick:c,disabled:!n,title:l(n?`common:actions.remove`:`profileEditor.agentRow.requiredRemoveTitle`),children:(0,Z.jsx)(O,{className:`w-3 h-3`})})]})}function ke({rule:e,ordinal:t,isLast:n,canMove:r,canRemove:i,canEdit:a,chainAgents:o,onAgentChange:c,onEdit:l,onUp:u,onDown:d,onRemove:f}){let{t:p}=s(`agentstudio`),m=`default`in e&&e.default===!0;return(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 rounded-md border border-border group hover:bg-accent/30 transition-colors`,children:[(0,Z.jsxs)(`span`,{className:`text-[10px] font-mono text-muted-foreground w-5 text-center flex-shrink-0`,children:[t,`.`]}),m?(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground flex-1`,children:p(`profileEditor.routingRow.everythingElse`)}):(0,Z.jsx)(`span`,{className:`text-xs flex-1 flex gap-1 flex-wrap items-center`,children:e.tags.map(e=>(0,Z.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-muted font-mono text-[11px]`,children:e},e))}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`→`}),m?(0,Z.jsx)(`span`,{className:`h-7 max-w-[15rem] px-2 text-xs font-mono rounded border border-border bg-muted/40 text-muted-foreground inline-flex items-center`,"aria-label":p(`profileEditor.routingRow.defaultTargetAria`),title:p(`profileEditor.routingRow.defaultTargetTitle`),children:e.agent}):(0,Z.jsx)(`select`,{value:e.agent,onChange:e=>c(e.target.value),"aria-label":p(`profileEditor.routingRow.targetAria`,{ordinal:t}),className:`h-7 max-w-[15rem] px-2 text-xs font-mono rounded border border-border bg-background`,children:o.map(e=>(0,Z.jsx)(`option`,{value:e,children:e},e))}),(0,Z.jsxs)(`div`,{className:`flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity`,children:[a&&(0,Z.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,onClick:l,title:p(`profileEditor.routingRow.editTitle`),"aria-label":p(`profileEditor.routingRow.editAria`,{ordinal:t}),children:(0,Z.jsx)(C,{className:`w-3 h-3`})}),r&&!n&&(0,Z.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,onClick:d,title:p(`profileEditor.routingRow.moveDown`),children:(0,Z.jsx)(ce,{className:`w-3 h-3`})}),r&&t>1&&(0,Z.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,onClick:u,title:p(`profileEditor.routingRow.moveUp`),children:(0,Z.jsx)(_,{className:`w-3 h-3`})}),i&&(0,Z.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-red-500/20 aurora-light:hover:bg-destructive/15 text-red-400 aurora-light:text-destructive rounded`,onClick:f,title:p(`common:actions.remove`),children:(0,Z.jsx)(O,{className:`w-3 h-3`})})]}),m&&(0,Z.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,title:p(`profileEditor.routingRow.coreDefaultTitle`),children:p(`profileEditor.routingRow.coreDefaultBadge`)})]})}function Q({value:e,models:t,customModelAliases:n,testId:r,onChange:i}){return n?(0,Z.jsx)(se,{value:e,options:t,ariaLabel:`Model alias`,testId:r,className:`h-7 w-52 bg-background px-2 text-xs`,onCommit:i}):(0,Z.jsx)(`select`,{value:e,onChange:e=>i(e.target.value),className:`h-7 px-2 text-xs rounded border border-border bg-background`,children:(t.some(t=>t.value===e)?t:[...t,{value:e,label:e}]).map(e=>(0,Z.jsx)(`option`,{value:e.value,children:e.label},e.value))})}function Ae({open:e,title:t,description:n,placeholder:r,initialValue:i=``,confirmLabel:a,inputPattern:o,inputInvalidHint:c,onConfirm:l,onCancel:u}){let{t:d}=s(),[f,p]=(0,X.useState)(i);(0,X.useEffect)(()=>{e&&p(i)},[e,i]);let m=f.trim(),h=!o||o.test(m),g=m.length>0&&h;return(0,Z.jsx)(I,{open:e,onOpenChange:e=>{e||u()},children:(0,Z.jsxs)(F,{movableResizable:!0,className:`max-w-md`,children:[(0,Z.jsx)(P,{children:(0,Z.jsx)(N,{children:t})}),(0,Z.jsxs)(`div`,{className:`py-2 space-y-2`,children:[n&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n}),(0,Z.jsx)(re,{autoFocus:!0,value:f,placeholder:r,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&g&&l(m)},className:`text-sm font-mono`}),m.length>0&&!h&&c&&(0,Z.jsx)(`p`,{className:`text-[11px] text-yellow-500 aurora-light:text-accent-warning`,children:c})]}),(0,Z.jsxs)(A,{children:[(0,Z.jsx)(L,{variant:`ghost`,size:`sm`,onClick:u,children:d(`actions.cancel`)}),(0,Z.jsx)(L,{size:`sm`,onClick:()=>l(m),disabled:!g,children:a??d(`actions.confirm`)})]})]})})}function je({open:e,title:t,description:n,confirmLabel:r,destructive:i=!1,onConfirm:a,onCancel:o}){let{t:c}=s();return(0,Z.jsx)(I,{open:e,onOpenChange:e=>{e||o()},children:(0,Z.jsxs)(F,{movableResizable:!0,className:`max-w-md`,children:[(0,Z.jsx)(P,{children:(0,Z.jsx)(N,{children:t})}),n&&(0,Z.jsx)(`div`,{className:`py-2`,children:(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n})}),(0,Z.jsxs)(A,{children:[(0,Z.jsx)(L,{variant:`ghost`,size:`sm`,onClick:o,children:c(`actions.cancel`)}),(0,Z.jsx)(L,{size:`sm`,onClick:a,className:i?`bg-red-500 hover:bg-red-600 text-white`:void 0,children:r??c(`actions.confirm`)})]})]})})}var Me={models:Ce.map(e=>({value:e,label:e})),defaultModel:`sonnet`,baselineAgents:[...Se],customModelAliases:!1},Ne={primaryProvider:`claude`,providers:[`claude`],catalogs:{claude:Me}};function Pe(e,t,n){return{schemaVersion:1,name:e,description:``,provider:t,orchestrator:{model:n.defaultModel},agents:n.baselineAgents.map(e=>({id:e,model:n.defaultModel,required:!0})),routing:[{default:!0,agent:`sr-developer`}]}}function Fe(){let{t:e}=s(`agents`),[t,n]=(0,X.useState)([]),[r,i]=(0,X.useState)(Ne),[a,c]=(0,X.useState)(``),[u,f]=(0,X.useState)(null),[m,g]=(0,X.useState)(null),[_,v]=(0,X.useState)(!0),[y,b]=(0,X.useState)(null),[x,S]=(0,X.useState)(!1),[C,ee]=(0,X.useState)([]),[T,D]=(0,X.useState)([]),[O,k]=(0,X.useState)(!1),[A,j]=(0,X.useState)(null),[M,N]=(0,X.useState)(null),P=a,F=r.catalogs[P]??Me;(0,X.useEffect)(()=>{let e=!1;return fetch(`${l()}/profiles/context`).then(e=>{if(!e.ok)throw Error(`profile context unavailable`);return e.json()}).then(t=>{if(e)return;let n=Array.isArray(t.providers)&&t.providers.length>0?t.providers:[t.primaryProvider||`claude`],r=n.includes(t.primaryProvider)?t.primaryProvider:n[0];i({...t,providers:n,primaryProvider:r}),c(r)}).catch(()=>{e||(i(Ne),c(Ne.primaryProvider))}),()=>{e=!0}},[]);let I=(0,X.useCallback)(async()=>{if(P){v(!0),b(null);try{let t=await fetch(`${l()}/profiles?provider=${encodeURIComponent(P)}`);if(!t.ok)throw Error(e(`profiles.errors.listFailed`,{status:t.status}));let r=await t.json();n(r.profiles),f(e=>e&&r.profiles.some(t=>t.name===e)?e:r.profiles[0]?.name??null)}catch(e){b(e.message)}finally{v(!1)}}},[P,e]);(0,X.useEffect)(()=>{P&&I()},[P,I]),(0,X.useEffect)(()=>{if(!u){g(null);return}let t=!1;return fetch(`${l()}/profiles/${encodeURIComponent(u)}?provider=${encodeURIComponent(P)}`).then(t=>{if(!t.ok)throw Error(e(`profiles.errors.loadFailed`,{status:t.status}));return t.json()}).then(e=>{t||g(e.profile)}).catch(e=>{t||b(e.message)}),()=>{t=!0}},[P,u,e]);let R=(0,X.useCallback)(async()=>{S(!0),b(null);try{let t=await fetch(`${l()}/profiles/migrate-from-settings?provider=${encodeURIComponent(P)}`,{method:`POST`});if(!t.ok){let n=await t.json().catch(()=>({}));throw Error(n.error??e(`profiles.errors.migrationFailed`,{status:t.status}))}await I(),f(`default`),d.success(e(`profiles.toasts.migrated`),{description:e(`profiles.toasts.migratedDescription`)})}catch(t){let n=t.message;b(n),d.error(e(`profiles.toasts.migrationFailed`),{description:n})}finally{S(!1)}},[P,I,e]),z=(0,X.useCallback)(async t=>{k(!1),S(!0),b(null);try{let n=Pe(t,P,F),r=await fetch(`${l()}/profiles?provider=${encodeURIComponent(P)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});if(!r.ok){let t=await r.json().catch(()=>({}));throw Error(t.error??e(`profiles.errors.createFailed`,{status:r.status}))}await I(),f(t),d.success(e(`profiles.toasts.created`),{description:t})}catch(t){let n=t.message;b(n),d.error(e(`profiles.toasts.createFailed`),{description:n})}finally{S(!1)}},[F,P,I,e]),B=(0,X.useCallback)(async(t,n)=>{j(null),S(!0),b(null);try{let r=await fetch(`${l()}/profiles/${encodeURIComponent(t)}/duplicate?provider=${encodeURIComponent(P)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:n,provider:P})});if(!r.ok){let t=await r.json().catch(()=>({}));throw Error(t.error??e(`profiles.errors.duplicateFailed`,{status:r.status}))}await I(),f(n),d.success(e(`profiles.toasts.duplicated`),{description:e(`profiles.toasts.duplicatedDescription`,{from:t,to:n})})}catch(t){let n=t.message;b(n),d.error(e(`profiles.toasts.duplicateFailed`),{description:n})}finally{S(!1)}},[P,I,e]),V=(0,X.useCallback)(async t=>{N(null),S(!0),b(null);try{let n=await fetch(`${l()}/profiles/${encodeURIComponent(t)}?provider=${encodeURIComponent(P)}`,{method:`DELETE`});if(!n.ok){let t=await n.json().catch(()=>({}));throw Error(t.error??e(`profiles.errors.deleteFailed`,{status:n.status}))}f(e=>e===t?null:e),await I(),d.success(e(`profiles.toasts.deleted`),{description:t})}catch(t){let n=t.message;b(n),d.error(e(`profiles.toasts.deleteFailed`),{description:n})}finally{S(!1)}},[P,I,e]),H=(0,X.useCallback)(()=>k(!0),[]),U=(0,X.useCallback)(e=>j({from:e}),[]),te=(0,X.useCallback)(e=>N({name:e}),[]),W=(0,X.useCallback)(async(t,n)=>{S(!0),b(null);try{let r=await fetch(`${l()}/profiles/${encodeURIComponent(t.name)}?provider=${encodeURIComponent(P)}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...t,provider:P})});if(!r.ok){let t=await r.json().catch(()=>({}));throw Error(t.error??e(`profiles.errors.saveFailed`,{status:r.status}))}g(t),n.length>0?d.warning(e(`profiles.toasts.savedWithUntargeted`),{description:e(`profiles.toasts.savedWithUntargetedDescription`,{agents:n.join(`, `)}),duration:6e3}):d.success(e(`profiles.toasts.saved`),{description:t.name})}catch(t){let n=t.message;b(n),d.error(e(`profiles.toasts.saveFailed`),{description:n})}finally{S(!1)}},[P,e]),G=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Ae,{open:O,title:e(`profiles.createDialog.title`),description:e(`profiles.createDialog.description`),placeholder:`my-profile`,confirmLabel:e(`profiles.createDialog.confirmLabel`),inputPattern:/^[a-z0-9][a-z0-9-]*$/,inputInvalidHint:e(`profiles.createDialog.invalidHint`),onConfirm:e=>void z(e),onCancel:()=>k(!1)}),A&&(0,Z.jsx)(Ae,{open:!0,title:e(`profiles.duplicateDialog.title`,{name:A.from}),description:e(`profiles.duplicateDialog.description`),placeholder:`${A.from}-copy`,initialValue:`${A.from}-copy`,confirmLabel:e(`common:actions.duplicate`),inputPattern:/^[a-z0-9][a-z0-9-]*$/,inputInvalidHint:e(`profiles.duplicateDialog.invalidHint`),onConfirm:e=>void B(A.from,e),onCancel:()=>j(null)}),M&&(0,Z.jsx)(je,{open:!0,title:e(`profiles.deleteDialog.title`,{name:M.name}),description:e(`profiles.deleteDialog.description`),confirmLabel:e(`common:actions.delete`),destructive:!0,onConfirm:()=>void V(M.name),onCancel:()=>N(null)})]});return _?(0,Z.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`profiles.loading`)})}):t.length===0?(0,Z.jsxs)(Z.Fragment,{children:[G,(0,Z.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,Z.jsxs)(`div`,{className:`text-center max-w-md`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:e(`profiles.empty.title`)}),(0,Z.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1 mb-4`,children:e(`profiles.empty.body`)}),r.providers.length>1&&(0,Z.jsx)(`select`,{value:P,"aria-label":e(`profiles.providerLabel`),onChange:e=>{f(null),g(null),c(e.target.value)},className:`mb-4 h-8 w-full rounded border border-border bg-background px-2 text-xs`,children:r.providers.map(e=>(0,Z.jsx)(`option`,{value:e,children:p(e)},e))}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 justify-center`,children:[(0,Z.jsxs)(L,{size:`sm`,onClick:R,disabled:x,children:[(0,Z.jsx)(ue,{className:`w-3.5 h-3.5 mr-1.5`}),` `,e(`profiles.empty.migrateButton`)]}),(0,Z.jsxs)(L,{size:`sm`,variant:`ghost`,onClick:H,disabled:x,children:[(0,Z.jsx)(w,{className:`w-3.5 h-3.5 mr-1.5`}),` `,e(`profiles.empty.blankButton`)]})]}),(0,Z.jsx)(`div`,{className:`text-[11px] text-muted-foreground/70 mt-3`,children:(0,Z.jsx)(o,{t:e,i18nKey:`profiles.empty.migrateExplainer`,components:{code:(0,Z.jsx)(`code`,{className:`text-foreground`})}})}),y&&(0,Z.jsx)(`div`,{className:`mt-3 text-xs text-red-400 aurora-light:text-destructive`,children:y})]})})]}):(0,Z.jsxs)(`div`,{className:`flex flex-col h-full`,children:[G,(0,Z.jsxs)(`div`,{className:`flex flex-1 min-h-0`,children:[(0,Z.jsxs)(`aside`,{className:`w-64 flex-shrink-0 border-r border-border flex flex-col`,children:[(0,Z.jsxs)(`div`,{className:`p-3 space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e(`profiles.sidebar.title`)}),(0,Z.jsx)(L,{size:`sm`,variant:`ghost`,onClick:H,disabled:x,children:(0,Z.jsx)(w,{className:`w-3.5 h-3.5`})})]}),r.providers.length>1&&(0,Z.jsx)(`select`,{value:P,"aria-label":e(`profiles.providerLabel`),onChange:e=>{f(null),g(null),c(e.target.value)},className:`h-7 w-full rounded border border-border bg-background px-2 text-xs`,children:r.providers.map(e=>(0,Z.jsx)(`option`,{value:e,children:p(e)},e))})]}),(0,Z.jsx)(`div`,{className:`flex-1 overflow-auto px-2 pb-3`,children:t.map(t=>(0,Z.jsxs)(`div`,{className:`group mb-1 rounded-md px-2 py-1.5 text-xs cursor-pointer transition-colors flex items-center justify-between `+(t.name===u?`bg-accent text-foreground`:`text-muted-foreground hover:bg-accent/50 hover:text-foreground`),onClick:()=>f(t.name),role:`button`,tabIndex:0,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&f(t.name)},children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,Z.jsx)(`span`,{className:`truncate font-medium`,children:t.name}),t.isDefault&&(0,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:e(`profiles.sidebar.teamDefault`)})]}),(0,Z.jsxs)(`div`,{className:`flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,title:e(`common:actions.duplicate`),onClick:e=>{e.stopPropagation(),U(t.name)},children:(0,Z.jsx)(K,{className:`w-3 h-3`})}),!t.isDefault&&(0,Z.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-red-500/20 text-red-400 aurora-light:text-destructive rounded`,title:e(`common:actions.delete`),onClick:e=>{e.stopPropagation(),te(t.name)},children:(0,Z.jsx)(E,{className:`w-3 h-3`})})]})]},t.name))})]}),(0,Z.jsxs)(`main`,{className:`flex-1 overflow-auto`,children:[y&&(0,Z.jsx)(`div`,{className:`mx-4 mt-4 px-3 py-2 text-xs rounded border border-red-500/30 aurora-light:border-destructive/30 bg-red-500/10 aurora-light:bg-destructive/10 text-red-400 aurora-light:text-destructive`,children:y}),m?(0,Z.jsx)(De,{profile:m,provider:P,modelCatalog:F.models,defaultModel:F.defaultModel,customModelAliases:F.customModelAliases===!0,baselineAgents:F.baselineAgents,onChange:g,onValidityChange:ee,onSoftWarningsChange:e=>D(e.agentsMissingRouting),footer:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsxs)(L,{size:`sm`,onClick:()=>void W(m,T),disabled:x||C.length>0,title:C.length>0?e(`profiles.editorFooter.fixValidationIssues`):void 0,children:[(0,Z.jsx)(h,{className:`w-3.5 h-3.5 mr-1.5`}),e(`common:actions.save`)]}),x&&(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`common:states.saving`)}),C.length>0&&(0,Z.jsx)(`span`,{className:`text-xs text-yellow-500 aurora-light:text-accent-warning`,children:e(`profiles.editorFooter.issuesToResolve`,{count:C.length})})]})},`${P}:${m.name}`):(0,Z.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`profiles.selectPrompt`)})})]})]})]})}function $(e){let t=e.workflow.map((e,t)=>`${t+1}. ${e}`).join(`
2
2
  `);return`---
3
3
  name: ${e.id}
4
4
  description: "${e.descriptionOneLine}"