@sapienx/agentos 0.1.2 → 0.1.4

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 (132) hide show
  1. package/README.md +3 -0
  2. package/bin/agentos.js +214 -1
  3. package/bundle/.next/BUILD_ID +1 -1
  4. package/bundle/.next/app-path-routes-manifest.json +9 -8
  5. package/bundle/.next/build-manifest.json +2 -2
  6. package/bundle/.next/routes-manifest.json +6 -0
  7. package/bundle/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  8. package/bundle/.next/server/app/_global-error.html +2 -2
  9. package/bundle/.next/server/app/_global-error.rsc +1 -1
  10. package/bundle/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  11. package/bundle/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  12. package/bundle/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  13. package/bundle/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  14. package/bundle/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  15. package/bundle/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  16. package/bundle/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  17. package/bundle/.next/server/app/_not-found.html +1 -1
  18. package/bundle/.next/server/app/_not-found.rsc +2 -2
  19. package/bundle/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  20. package/bundle/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  21. package/bundle/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
  22. package/bundle/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  23. package/bundle/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  24. package/bundle/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  25. package/bundle/.next/server/app/api/agents/route.js.nft.json +1 -1
  26. package/bundle/.next/server/app/api/agents/route_client-reference-manifest.js +1 -1
  27. package/bundle/.next/server/app/api/diagnostics/route.js.nft.json +1 -1
  28. package/bundle/.next/server/app/api/diagnostics/route_client-reference-manifest.js +1 -1
  29. package/bundle/.next/server/app/api/files/reveal/route_client-reference-manifest.js +1 -1
  30. package/bundle/.next/server/app/api/gateway/control/route.js.nft.json +1 -1
  31. package/bundle/.next/server/app/api/gateway/control/route_client-reference-manifest.js +1 -1
  32. package/bundle/.next/server/app/api/mission/route.js.nft.json +1 -1
  33. package/bundle/.next/server/app/api/mission/route_client-reference-manifest.js +1 -1
  34. package/bundle/.next/server/app/api/onboarding/models/route.js.nft.json +1 -1
  35. package/bundle/.next/server/app/api/onboarding/models/route_client-reference-manifest.js +1 -1
  36. package/bundle/.next/server/app/api/onboarding/route.js.nft.json +1 -1
  37. package/bundle/.next/server/app/api/onboarding/route_client-reference-manifest.js +1 -1
  38. package/bundle/.next/server/app/api/planner/[planId]/deploy/route.js.nft.json +1 -1
  39. package/bundle/.next/server/app/api/planner/[planId]/deploy/route_client-reference-manifest.js +1 -1
  40. package/bundle/.next/server/app/api/planner/[planId]/route.js.nft.json +1 -1
  41. package/bundle/.next/server/app/api/planner/[planId]/route_client-reference-manifest.js +1 -1
  42. package/bundle/.next/server/app/api/planner/[planId]/simulate/route.js.nft.json +1 -1
  43. package/bundle/.next/server/app/api/planner/[planId]/simulate/route_client-reference-manifest.js +1 -1
  44. package/bundle/.next/server/app/api/planner/[planId]/turn/route.js.nft.json +1 -1
  45. package/bundle/.next/server/app/api/planner/[planId]/turn/route_client-reference-manifest.js +1 -1
  46. package/bundle/.next/server/app/api/planner/route.js.nft.json +1 -1
  47. package/bundle/.next/server/app/api/planner/route_client-reference-manifest.js +1 -1
  48. package/bundle/.next/server/app/api/reset/route.js +3 -0
  49. package/bundle/.next/server/app/api/reset/route.js.nft.json +1 -0
  50. package/bundle/.next/server/app/api/reset/route_client-reference-manifest.js +1 -0
  51. package/bundle/.next/server/app/api/runtimes/[runtimeId]/route.js.nft.json +1 -1
  52. package/bundle/.next/server/app/api/runtimes/[runtimeId]/route_client-reference-manifest.js +1 -1
  53. package/bundle/.next/server/app/api/settings/gateway/route.js.nft.json +1 -1
  54. package/bundle/.next/server/app/api/settings/gateway/route_client-reference-manifest.js +1 -1
  55. package/bundle/.next/server/app/api/settings/workspace-root/route.js.nft.json +1 -1
  56. package/bundle/.next/server/app/api/settings/workspace-root/route_client-reference-manifest.js +1 -1
  57. package/bundle/.next/server/app/api/snapshot/route.js.nft.json +1 -1
  58. package/bundle/.next/server/app/api/snapshot/route_client-reference-manifest.js +1 -1
  59. package/bundle/.next/server/app/api/stream/route.js.nft.json +1 -1
  60. package/bundle/.next/server/app/api/stream/route_client-reference-manifest.js +1 -1
  61. package/bundle/.next/server/app/api/system/open-terminal/route_client-reference-manifest.js +1 -1
  62. package/bundle/.next/server/app/api/update/route.js.nft.json +1 -1
  63. package/bundle/.next/server/app/api/update/route_client-reference-manifest.js +1 -1
  64. package/bundle/.next/server/app/api/workspaces/route.js.nft.json +1 -1
  65. package/bundle/.next/server/app/api/workspaces/route_client-reference-manifest.js +1 -1
  66. package/bundle/.next/server/app/page.js +11 -8
  67. package/bundle/.next/server/app/page.js.nft.json +1 -1
  68. package/bundle/.next/server/app/page_client-reference-manifest.js +1 -1
  69. package/bundle/.next/server/app-paths-manifest.json +9 -8
  70. package/bundle/.next/server/chunks/907.js +22 -22
  71. package/bundle/.next/server/functions-config-manifest.json +1 -0
  72. package/bundle/.next/server/pages/404.html +1 -1
  73. package/bundle/.next/server/pages/500.html +2 -2
  74. package/bundle/.next/static/chunks/632-05d72f27d1a1075e.js +13 -0
  75. package/bundle/.next/static/chunks/app/{_not-found/page-0d1d1bc0507fcf1d.js → _global-error/page-b01b0a6fdf60f7fe.js} +1 -1
  76. package/bundle/.next/static/chunks/app/{api/agents/route-0d1d1bc0507fcf1d.js → _not-found/page-b01b0a6fdf60f7fe.js} +1 -1
  77. package/bundle/.next/static/chunks/app/api/{diagnostics/route-0d1d1bc0507fcf1d.js → agents/route-b01b0a6fdf60f7fe.js} +1 -1
  78. package/bundle/.next/static/chunks/app/{_global-error/page-0d1d1bc0507fcf1d.js → api/diagnostics/route-b01b0a6fdf60f7fe.js} +1 -1
  79. package/bundle/.next/static/chunks/app/api/files/reveal/route-b01b0a6fdf60f7fe.js +1 -0
  80. package/bundle/.next/static/chunks/app/api/gateway/control/route-b01b0a6fdf60f7fe.js +1 -0
  81. package/bundle/.next/static/chunks/app/api/mission/route-b01b0a6fdf60f7fe.js +1 -0
  82. package/bundle/.next/static/chunks/app/api/onboarding/models/route-b01b0a6fdf60f7fe.js +1 -0
  83. package/bundle/.next/static/chunks/app/api/onboarding/route-b01b0a6fdf60f7fe.js +1 -0
  84. package/bundle/.next/static/chunks/app/api/planner/[planId]/deploy/route-b01b0a6fdf60f7fe.js +1 -0
  85. package/bundle/.next/static/chunks/app/api/planner/[planId]/route-b01b0a6fdf60f7fe.js +1 -0
  86. package/bundle/.next/static/chunks/app/api/planner/[planId]/simulate/route-b01b0a6fdf60f7fe.js +1 -0
  87. package/bundle/.next/static/chunks/app/api/planner/[planId]/turn/route-b01b0a6fdf60f7fe.js +1 -0
  88. package/bundle/.next/static/chunks/app/api/planner/route-b01b0a6fdf60f7fe.js +1 -0
  89. package/bundle/.next/static/chunks/app/api/reset/route-b01b0a6fdf60f7fe.js +1 -0
  90. package/bundle/.next/static/chunks/app/api/runtimes/[runtimeId]/route-b01b0a6fdf60f7fe.js +1 -0
  91. package/bundle/.next/static/chunks/app/api/settings/gateway/route-b01b0a6fdf60f7fe.js +1 -0
  92. package/bundle/.next/static/chunks/app/api/settings/workspace-root/route-b01b0a6fdf60f7fe.js +1 -0
  93. package/bundle/.next/static/chunks/app/api/snapshot/route-b01b0a6fdf60f7fe.js +1 -0
  94. package/bundle/.next/static/chunks/app/api/stream/route-b01b0a6fdf60f7fe.js +1 -0
  95. package/bundle/.next/static/chunks/app/api/system/open-terminal/route-b01b0a6fdf60f7fe.js +1 -0
  96. package/bundle/.next/static/chunks/app/api/update/route-b01b0a6fdf60f7fe.js +1 -0
  97. package/bundle/.next/static/chunks/app/api/workspaces/route-b01b0a6fdf60f7fe.js +1 -0
  98. package/bundle/.next/static/chunks/app/not-found-b01b0a6fdf60f7fe.js +1 -0
  99. package/bundle/.next/static/chunks/app/page-2cb34a431e05ffbc.js +14 -0
  100. package/bundle/.next/static/chunks/next/dist/client/components/builtin/app-error-b01b0a6fdf60f7fe.js +1 -0
  101. package/bundle/.next/static/chunks/next/dist/client/components/builtin/forbidden-b01b0a6fdf60f7fe.js +1 -0
  102. package/bundle/.next/static/chunks/next/dist/client/components/builtin/unauthorized-b01b0a6fdf60f7fe.js +1 -0
  103. package/bundle/.next/static/css/b437564fd435ab82.css +3 -0
  104. package/bundle/.next/static/vVu-6A-oCIV07uAZGrTop/_buildManifest.js +1 -0
  105. package/package.json +1 -1
  106. package/bundle/.next/static/VOlzZmzuIhPpxC4007UHA/_buildManifest.js +0 -1
  107. package/bundle/.next/static/chunks/329-1f8436466b6b9b86.js +0 -13
  108. package/bundle/.next/static/chunks/app/api/files/reveal/route-0d1d1bc0507fcf1d.js +0 -1
  109. package/bundle/.next/static/chunks/app/api/gateway/control/route-0d1d1bc0507fcf1d.js +0 -1
  110. package/bundle/.next/static/chunks/app/api/mission/route-0d1d1bc0507fcf1d.js +0 -1
  111. package/bundle/.next/static/chunks/app/api/onboarding/models/route-0d1d1bc0507fcf1d.js +0 -1
  112. package/bundle/.next/static/chunks/app/api/onboarding/route-0d1d1bc0507fcf1d.js +0 -1
  113. package/bundle/.next/static/chunks/app/api/planner/[planId]/deploy/route-0d1d1bc0507fcf1d.js +0 -1
  114. package/bundle/.next/static/chunks/app/api/planner/[planId]/route-0d1d1bc0507fcf1d.js +0 -1
  115. package/bundle/.next/static/chunks/app/api/planner/[planId]/simulate/route-0d1d1bc0507fcf1d.js +0 -1
  116. package/bundle/.next/static/chunks/app/api/planner/[planId]/turn/route-0d1d1bc0507fcf1d.js +0 -1
  117. package/bundle/.next/static/chunks/app/api/planner/route-0d1d1bc0507fcf1d.js +0 -1
  118. package/bundle/.next/static/chunks/app/api/runtimes/[runtimeId]/route-0d1d1bc0507fcf1d.js +0 -1
  119. package/bundle/.next/static/chunks/app/api/settings/gateway/route-0d1d1bc0507fcf1d.js +0 -1
  120. package/bundle/.next/static/chunks/app/api/settings/workspace-root/route-0d1d1bc0507fcf1d.js +0 -1
  121. package/bundle/.next/static/chunks/app/api/snapshot/route-0d1d1bc0507fcf1d.js +0 -1
  122. package/bundle/.next/static/chunks/app/api/stream/route-0d1d1bc0507fcf1d.js +0 -1
  123. package/bundle/.next/static/chunks/app/api/system/open-terminal/route-0d1d1bc0507fcf1d.js +0 -1
  124. package/bundle/.next/static/chunks/app/api/update/route-0d1d1bc0507fcf1d.js +0 -1
  125. package/bundle/.next/static/chunks/app/api/workspaces/route-0d1d1bc0507fcf1d.js +0 -1
  126. package/bundle/.next/static/chunks/app/not-found-0d1d1bc0507fcf1d.js +0 -1
  127. package/bundle/.next/static/chunks/app/page-9b9885753576b25c.js +0 -11
  128. package/bundle/.next/static/chunks/next/dist/client/components/builtin/app-error-0d1d1bc0507fcf1d.js +0 -1
  129. package/bundle/.next/static/chunks/next/dist/client/components/builtin/forbidden-0d1d1bc0507fcf1d.js +0 -1
  130. package/bundle/.next/static/chunks/next/dist/client/components/builtin/unauthorized-0d1d1bc0507fcf1d.js +0 -1
  131. package/bundle/.next/static/css/fafac7874e0b1aad.css +0 -3
  132. /package/bundle/.next/static/{VOlzZmzuIhPpxC4007UHA → vVu-6A-oCIV07uAZGrTop}/_ssgManifest.js +0 -0
@@ -1,11 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[974],{1219:(e,t,a)=>{"use strict";a.d(t,{MissionControlShell:()=>sp});var s=a(9227),r=a(6036),n=a(5642),i=a(909),l=a(5923),o=a(8219),d=a(1627),c=a(8433),p=a(6281),m=a(3035),u=a(2998);a(8646);var h=a(3564),x=a(7446),g=a(1052),b=a(9540),f=a(3587);function w(...e){return(0,f.QP)((0,b.$)(e))}function y({tone:e,pulse:t=!1,className:a}){return(0,s.jsxs)("span",{className:w("relative inline-flex h-2.5 w-2.5 items-center justify-center",a),children:[t?(0,s.jsx)(g.P.span,{className:w("absolute inset-0 rounded-full",e),animate:{opacity:[.4,0],scale:[1,2.2]},transition:{duration:1.8,repeat:1/0,ease:"easeOut"}}):null,(0,s.jsx)("span",{className:w("relative inline-flex h-2.5 w-2.5 rounded-full",e)})]})}var v=a(1094);let j=(0,v.F)("inline-flex items-center rounded-full border px-2.5 py-0.5 text-[11px] font-medium tracking-[0.14em] uppercase transition-colors",{variants:{variant:{default:"border-cyan-400/30 bg-cyan-400/10 text-cyan-200",muted:"border-white/10 bg-white/5 text-slate-300",success:"border-emerald-400/25 bg-emerald-400/10 text-emerald-200",warning:"border-amber-400/25 bg-amber-400/10 text-amber-100",danger:"border-rose-400/30 bg-rose-400/10 text-rose-100"}},defaultVariants:{variant:"default"}});function k({className:e,variant:t,...a}){return(0,s.jsx)("div",{className:w(j({variant:t}),e),...a})}var N=a(6966);function C(e){return e?`${(0,N.B)(e,{addSuffix:!0})}`:"No activity"}function S(e){return e?e>=1e3?`${Math.round(e/1e3)}k`:String(e):"n/a"}function A(e){return"number"!=typeof e?"0":e>=1e3?`${(e/1e3).toFixed(e>=1e4?0:1)}k`:String(e)}function I(e){return e.split("/").at(1)||e}function T(e){switch(e){case"active":return"default";case"completed":return"success";case"partial":return"warning";case"error":return"danger";default:return"muted"}}function $(e,t=8){return e?e.length<=t?e:e.slice(0,t):"n/a"}function _(e){return e.replace(/^\/Users\/[^/]+/,"~")}function O({label:e,onClick:t,danger:a=!1}){return(0,s.jsx)("button",{type:"button",className:w("flex w-full items-center rounded-[10px] px-2.5 py-2 text-left text-[11px] transition-colors",a?"text-rose-200 hover:bg-rose-400/10 hover:text-rose-100":"text-slate-200 hover:bg-white/[0.06] hover:text-white"),onClick:t,children:(0,s.jsx)("span",{children:e})})}var R=a(4040),M=a(4331),P=a(764),E=a(6238),D=a(9718);function L({icon:e,label:t,onClick:a}){return(0,s.jsxs)("button",{type:"button",className:"flex w-full items-center gap-2 rounded-[10px] px-2.5 py-2 text-left text-[11px] text-slate-200 transition-colors hover:bg-white/[0.06] hover:text-white",onClick:a,children:[(0,s.jsx)(e,{className:"h-3.5 w-3.5 text-cyan-300"}),(0,s.jsx)("span",{children:t})]})}var U=a(1455),z=a(1807),F=a(2271);function W({icon:e,label:t,value:a}){return(0,s.jsxs)("div",{className:"inline-flex items-center gap-1.5 rounded-full border border-white/[0.06] bg-slate-950/65 px-2.5 py-1 text-slate-300",children:[(0,s.jsx)(e,{className:"h-3 w-3 text-slate-400"}),(0,s.jsx)("span",{className:"workspace-node__metric-label text-[9px] uppercase tracking-[0.16em] text-slate-500",children:t}),(0,s.jsx)("span",{className:"font-display text-[12px] text-white",children:a})]})}let B={workspace:function({data:e,selected:t}){return(0,s.jsx)(g.P.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},className:w("workspace-node h-full rounded-[26px] border border-white/[0.04] bg-[linear-gradient(180deg,rgba(4,11,22,0.18),rgba(4,9,18,0.06))] p-3 text-white backdrop-blur-[2px]",e.emphasis?"opacity-100":"opacity-75",t&&"border-cyan-300/[0.16]"),children:(0,s.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,s.jsxs)("div",{className:"min-w-0 space-y-1.5",children:[(0,s.jsxs)("div",{className:"inline-flex items-center gap-2 rounded-full border border-white/[0.08] bg-slate-950/75 px-2.5 py-1.5 shadow-[0_14px_28px_rgba(0,0,0,0.2)]",children:[(0,s.jsx)("div",{className:"rounded-full border border-white/10 bg-white/[0.06] p-1.5",children:(0,s.jsx)(U.A,{className:"h-3 w-3 text-cyan-200"})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"font-display text-[12px] tracking-[0.04em] text-white",children:e.workspace.name}),(0,s.jsx)("p",{className:"workspace-node__slug text-[9px] uppercase tracking-[0.22em] text-slate-500",children:e.workspace.slug})]})]}),(0,s.jsx)("p",{className:"workspace-node__path max-w-[300px] truncate pl-1 text-[9px] uppercase tracking-[0.16em] text-slate-600",children:_(e.workspace.path)})]}),(0,s.jsxs)("div",{className:"flex shrink-0 max-w-[48%] flex-wrap items-center justify-end gap-1.5",children:[(0,s.jsx)(k,{variant:"muted","data-health":e.workspace.health,className:w("workspace-node__health",function(e){switch(e){case"engaged":return"border-cyan-300/30 bg-cyan-300/14 text-cyan-50";case"monitoring":return"border-emerald-300/30 bg-emerald-300/14 text-emerald-50";case"ready":return"border-amber-300/30 bg-amber-300/14 text-amber-50";case"offline":return"border-rose-300/30 bg-rose-300/14 text-rose-50";default:return"border-white/12 bg-white/[0.07] text-slate-100"}}(e.workspace.health)),children:e.workspace.health}),(0,s.jsxs)("div",{className:"flex flex-wrap justify-end gap-1.5",children:[(0,s.jsx)(W,{icon:z.A,label:"Agents",value:String(e.workspace.agentIds.length)}),(0,s.jsx)(W,{icon:F.A,label:"Models",value:String(e.workspace.modelIds.length)}),(0,s.jsx)(W,{icon:D.A,label:"Runs",value:String(e.workspace.activeRuntimeIds.length)})]})]})]})})},agent:function({data:e,selected:t}){let[a,r]=(0,m.useState)(!1),n=(0,m.useRef)(null),i=function(e){switch(e){case"engaged":return"text-cyan-300";case"monitoring":return"text-emerald-300";case"ready":return"text-amber-200";case"offline":return"text-rose-200";default:return"text-slate-400"}}(e.agent.status),l="engaged"===e.agent.status?"bg-cyan-300":"monitoring"===e.agent.status?"bg-emerald-300":"ready"===e.agent.status?"bg-amber-200":"offline"===e.agent.status?"bg-rose-300":"bg-slate-500";return(0,m.useEffect)(()=>{if(!a)return;let e=e=>{n.current?.contains(e.target)||r(!1)};return window.addEventListener("pointerdown",e),()=>window.removeEventListener("pointerdown",e)},[a]),(0,s.jsxs)(g.P.div,{initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},className:w("w-[212px] rounded-[16px] border border-white/[0.1] bg-[linear-gradient(180deg,rgba(15,24,40,0.94),rgba(8,13,24,0.94))] px-3 py-2.5 shadow-[0_16px_28px_rgba(0,0,0,0.26)] backdrop-blur-xl",e.emphasis?"opacity-100":"opacity-72",t&&"border-cyan-300/[0.45] shadow-[0_18px_42px_rgba(34,211,238,0.16)]"),children:[(0,s.jsx)(u.h7,{type:"source",id:"source-right",position:h.yX.Right,className:"!h-2.5 !w-2.5 !border-0 !bg-cyan-300/90 shadow-[0_0_14px_rgba(103,232,249,0.42)]"}),(0,s.jsxs)("div",{className:"flex items-start justify-between gap-2.5",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5 text-[9px] uppercase tracking-[0.22em] text-slate-500",children:[(0,s.jsx)(y,{tone:l,pulse:"engaged"===e.agent.status||"monitoring"===e.agent.status}),"Agent"]}),(0,s.jsx)("p",{className:"mt-1.5 truncate font-display text-[0.96rem] text-white",children:e.agent.name}),(0,s.jsx)("p",{className:"mt-0.5 truncate text-[10px] uppercase tracking-[0.16em] text-slate-500",children:e.agent.identity.theme??"OpenClaw operator"})]}),(0,s.jsxs)("div",{className:"relative",ref:n,children:[(0,s.jsx)("button",{type:"button","aria-label":`${e.agent.name} actions`,onClick:e=>{e.stopPropagation(),r(e=>!e)},onPointerDown:e=>e.stopPropagation(),className:"inline-flex rounded-full border border-white/[0.08] bg-white/[0.05] p-1.5 text-slate-300 transition-colors hover:bg-white/[0.1] hover:text-white",children:(0,s.jsx)(x.A,{className:"h-3.5 w-3.5"})}),a?(0,s.jsxs)("div",{className:"absolute right-0 top-[calc(100%+8px)] z-30 min-w-[136px] rounded-[14px] border border-white/[0.1] bg-slate-950/96 p-1.5 shadow-[0_20px_44px_rgba(0,0,0,0.42)] backdrop-blur-xl",onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:[(0,s.jsx)(O,{label:"Edit",onClick:()=>{e.onEdit?.(e.agent.id),r(!1)}}),(0,s.jsx)(O,{label:"Delete",danger:!0,onClick:()=>{e.onDelete?.(e.agent.id),r(!1)}})]}):null]})]}),(0,s.jsxs)("div",{className:"mt-2.5 flex flex-wrap items-center gap-1.5",children:[(0,s.jsx)(k,{variant:"engaged"===e.agent.status?"default":"monitoring"===e.agent.status?"success":"warning",children:e.agent.status}),(0,s.jsx)(k,{variant:"muted",className:"max-w-[132px] truncate",children:I(e.agent.modelId)})]}),(0,s.jsxs)("div",{className:"mt-2.5 border-t border-white/[0.08] pt-2.5",children:[(0,s.jsx)("p",{className:"text-[12px] leading-4 text-slate-100",children:e.agent.currentAction}),(0,s.jsx)("p",{className:w("mt-1.5 text-[9px] uppercase tracking-[0.2em]",i),children:e.agent.id})]})]})},runtime:function({data:e,selected:t}){let a=function(e){switch(e){case"active":return"text-cyan-300";case"completed":return"text-emerald-300";case"partial":case"queued":return"text-amber-200";case"error":return"text-rose-200";default:return"text-slate-400"}}(e.runtime.status),r="turn"===e.runtime.source?$(e.runtime.runId,10):$(e.runtime.taskId||e.runtime.sessionId),n=!!e.pendingCreation,i=!!e.justCreated,[l,o]=(0,m.useState)(!1),d=(0,m.useRef)(null),c=n?"warning":T(e.runtime.status);return(0,m.useEffect)(()=>{if(!l)return;let e=e=>{d.current?.contains(e.target)||o(!1)};return window.addEventListener("pointerdown",e),()=>window.removeEventListener("pointerdown",e)},[l]),(0,s.jsxs)(g.P.div,{initial:n?{opacity:0,scale:.9,y:-10}:i?{opacity:0,scale:.95,y:10}:{opacity:0,x:8},animate:n?{opacity:1,scale:1,y:0}:i?{opacity:1,scale:[1,1.015,1],y:0}:{opacity:1,x:0},transition:i?{duration:.7,times:[0,.45,1]}:void 0,className:w("relative w-[212px] overflow-hidden rounded-[16px] border border-white/[0.1] bg-[linear-gradient(180deg,rgba(15,24,40,0.94),rgba(8,13,24,0.94))] px-3 py-2.5 shadow-[0_16px_28px_rgba(0,0,0,0.26)] backdrop-blur-xl",e.emphasis?"opacity-100":"opacity-72",t&&"border-cyan-300/[0.45] shadow-[0_18px_42px_rgba(34,211,238,0.16)]",n&&"border-cyan-300/30 bg-[linear-gradient(180deg,rgba(17,31,52,0.98),rgba(8,16,30,0.98))] shadow-[0_24px_54px_rgba(34,211,238,0.22)]",i&&"border-cyan-200/40 bg-[linear-gradient(180deg,rgba(20,28,43,0.98),rgba(10,15,28,0.98))] shadow-[0_22px_52px_rgba(125,211,252,0.18)]","completed"===e.runtime.status&&!n&&!i&&"border-white/[0.06] bg-[linear-gradient(180deg,rgba(13,18,30,0.88),rgba(8,12,22,0.88))] opacity-[0.86]"),children:[n?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(g.P.div,{className:"pointer-events-none absolute inset-[-18px] rounded-[24px] border border-cyan-200/18",animate:{opacity:[.18,.42,.18],scale:[.98,1.03,.98]},transition:{duration:1.7,repeat:1/0,ease:"easeInOut"}}),(0,s.jsx)("div",{className:"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_top_left,rgba(125,211,252,0.22),transparent_44%),linear-gradient(180deg,rgba(15,23,42,0.18),rgba(15,23,42,0))]"}),(0,s.jsx)(g.P.div,{className:"pointer-events-none absolute left-[-28%] top-0 h-px w-[44%] bg-[linear-gradient(90deg,transparent,rgba(186,230,253,0.85),transparent)] blur-[1px]",animate:{x:["0%","320%"]},transition:{duration:1.6,repeat:1/0,ease:"linear"}})]}):null,i?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(g.P.div,{className:"pointer-events-none absolute inset-[-14px] rounded-[22px] border border-cyan-100/16",animate:{opacity:[.1,.34,.1],scale:[.985,1.02,.985]},transition:{duration:2.2,repeat:1/0,ease:"easeInOut"}}),(0,s.jsx)("div",{className:"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_top,rgba(186,230,253,0.18),transparent_36%)]"})]}):null,(0,s.jsx)(u.h7,{type:"target",id:"target-left",position:h.yX.Left,className:"!h-2.5 !w-2.5 !border-0 !bg-white/35"}),(0,s.jsxs)("div",{className:"relative flex items-start justify-between gap-2.5",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5 text-[9px] uppercase tracking-[0.22em] text-slate-500",children:[(0,s.jsx)(y,{tone:n?"bg-cyan-300":"partial"===e.runtime.status?"bg-amber-200":"completed"===e.runtime.status?"bg-emerald-300":"active"===e.runtime.status?"bg-cyan-300":"bg-amber-200"}),n?"Creating task":"turn"===e.runtime.source?"Run":"Task / Run"]}),(0,s.jsx)("p",{className:"mt-1.5 truncate font-display text-[0.95rem] text-white",children:e.runtime.title}),(0,s.jsx)("p",{className:"mt-0.5 truncate text-[10px] uppercase tracking-[0.16em] text-slate-500",children:r})]}),n?(0,s.jsx)("div",{className:"rounded-full border border-cyan-200/16 bg-cyan-100/8 p-1.5 text-cyan-100",children:(0,s.jsx)(R.A,{className:"h-3 w-3"})}):(0,s.jsxs)("div",{className:"relative",ref:d,children:[(0,s.jsx)("button",{type:"button","aria-label":"Run actions",onClick:e=>{e.stopPropagation(),o(e=>!e)},onPointerDown:e=>e.stopPropagation(),className:"inline-flex rounded-full border border-white/[0.08] bg-white/[0.05] p-1.5 text-slate-300 transition-colors hover:bg-white/[0.1] hover:text-white",children:(0,s.jsx)(x.A,{className:"h-3 w-3"})}),l?(0,s.jsxs)("div",{className:"absolute right-0 top-[calc(100%+8px)] z-30 min-w-[136px] rounded-[14px] border border-white/[0.1] bg-slate-950/96 p-1.5 shadow-[0_20px_44px_rgba(0,0,0,0.42)] backdrop-blur-xl",onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:[(0,s.jsx)(L,{icon:M.A,label:"Reply",onClick:()=>{e.onReply?.(e.runtime),o(!1)}}),(0,s.jsx)(L,{icon:P.A,label:"Copy prompt",onClick:()=>{e.onCopyPrompt?.(e.runtime),o(!1)}}),(0,s.jsx)(L,{icon:E.A,label:"Hide",onClick:()=>{e.onHide?.(e.runtime.id),o(!1)}})]}):null]})]}),(0,s.jsxs)("div",{className:"relative mt-2.5 flex flex-wrap items-center gap-1.5",children:[(0,s.jsx)(k,{variant:c,children:n?"materializing":e.runtime.status}),i?(0,s.jsxs)(k,{variant:"default",className:"gap-1 border-cyan-100/20 bg-cyan-100/12 text-cyan-50",children:[(0,s.jsx)(D.A,{className:"h-3 w-3"}),"new"]}):null,(0,s.jsxs)("span",{className:w("text-[9px] uppercase tracking-[0.18em]",a),children:[A(e.runtime.tokenUsage?.total)," tokens"]})]}),(0,s.jsxs)("div",{className:"relative mt-2.5 border-t border-white/[0.08] pt-2.5",children:[(0,s.jsx)("p",{className:"text-[12px] leading-4 text-slate-100",children:e.runtime.subtitle}),(0,s.jsx)("p",{className:"mt-1.5 text-[9px] uppercase tracking-[0.2em] text-slate-500",children:n?"Launching on the canvas":i?"Just created":e.runtime.ageMs?`${Math.round(e.runtime.ageMs/6e4)}m active`:"live"})]})]})}};function V({snapshot:e,activeWorkspaceId:t,selectedNodeId:a,pendingMission:r,hiddenRuntimeIds:n,onEditAgent:i,onDeleteAgent:l,onReplyRuntime:o,onCopyRuntimePrompt:d,onHideRuntime:c,onSelectNode:p,className:h}){let x=(0,m.useRef)(null),g=(0,m.useRef)(null),b=(0,m.useRef)(null),f=(0,m.useRef)(new Set),y=(0,m.useRef)(new Map),[v,j]=(0,m.useState)([]),[k,N]=(0,m.useState)(null),C=q(e,t,r,v,n,i,l,o,d,c),[S,A,I]=(0,u.ck)(C.nodes),[T,$,_]=(0,u.fM)(C.edges);return(0,m.useEffect)(()=>{let a=q(e,t,r,v,n,i,l,o,d,c);A(e=>{var t,s;let r;return t=e,s=a.nodes,r=new Map(t.map(e=>[e.id,e])),s.map(e=>{let t=r.get(e.id);return t&&t.type===e.type&&"workspace"!==e.type?{...e,position:t.position,width:t.width,height:t.height}:e})}),$(a.edges)},[e,t,r,v,n,i,l,o,d,c,$,A]),(0,m.useEffect)(()=>{A(e=>e.map(e=>{var t,s;return{...e,selected:e.id===a,zIndex:(t=e,s=a,"workspace"===t.type?0:"agent"===t.type?10:t.id===s?60:t.data.pendingCreation?40:t.data.justCreated?28:10)}}))},[a,A]),(0,m.useEffect)(()=>{r&&(b.current=r)},[r]),(0,m.useEffect)(()=>{var t,a,s,i;let l,o,d=r??b.current;if(!d||f.current.has(d.id))return;let c=e.runtimes.filter(e=>!n.includes(e.id)&&e.agentId===d.agentId&&(e.updatedAt??0)>=d.submittedAt-1500).sort((e,t)=>(t.updatedAt??0)-(e.updatedAt??0))[0];c&&(f.current.add(d.id),b.current=null,t=c.id,a=j,s=y,i=N,a(e=>e.includes(t)?e:[...e,t]),i(t),(l=s.current.get(t))&&clearTimeout(l),o=setTimeout(()=>{a(e=>e.filter(e=>e!==t)),s.current.delete(t)},12e3),s.current.set(t,o),p(c.id))},[e.runtimes,r,n,p]),(0,m.useEffect)(()=>{let e=y.current;return()=>{e.forEach(e=>{clearTimeout(e)}),e.clear()}},[]),(0,m.useEffect)(()=>{if(!k||!g.current)return;let e=S.find(e=>e.id===k);if(!e)return;g.current.setCenter(e.position.x+(e.width??212)/2,e.position.y+(e.height??148)/2,{zoom:Math.max(g.current.getZoom(),.9),duration:650});let t=setTimeout(()=>{N(e=>e===k?null:e)},900);return()=>clearTimeout(t)},[k,S]),(0,m.useEffect)(()=>{let e=x.current;if(!e||"u"<typeof ResizeObserver)return;let t=null,a=new ResizeObserver(()=>{g.current&&0!==S.length&&(t&&clearTimeout(t),t=setTimeout(()=>{g.current?.fitView({padding:.14,duration:260,maxZoom:.9})},90))});return a.observe(e),()=>{a.disconnect(),t&&clearTimeout(t)}},[S.length]),(0,s.jsx)("div",{ref:x,className:w("h-full w-full",h),children:(0,s.jsx)(u.Gc,{nodes:S,edges:T,nodeTypes:B,onInit:e=>{g.current=e},elevateNodesOnSelect:!1,onNodesChange:I,onEdgesChange:_,onNodeClick:(e,t)=>{t.id.startsWith("pending-runtime:")||p(t.id)},fitView:!0,fitViewOptions:{padding:.14,duration:700,maxZoom:.9},minZoom:.42,maxZoom:1.2,defaultEdgeOptions:{type:"simplebezier",style:{stroke:"rgba(148, 163, 184, 0.34)",strokeWidth:1.15}},proOptions:{hideAttribution:!0},className:"h-full w-full rounded-[inherit]"})})}function q(e,t,a,s,r,n,i,l,o,d){let c=t?e.workspaces.filter(e=>e.id===t):[...e.workspaces].sort((e,t)=>t.activeRuntimeIds.length-e.activeRuntimeIds.length),p=[],m=[],u=e.runtimes.filter(e=>!r.includes(e.id));c.forEach((c,h)=>{let x=e.agents.filter(e=>e.workspaceId===c.id),g=e.runtimes.filter(e=>e.workspaceId===c.id&&!r.includes(e.id)),b=h%2*1140+44,f=760*Math.floor(h/2)+42,w=b+52,y=b+372,v=f+118;x.forEach((e,r)=>{var p,h,x,b;let f,j=g.filter(t=>t.agentId===e.id).sort((e,t)=>(t.updatedAt??0)-(e.updatedAt??0)),k=a&&a.agentId===e.id&&(!a.workspaceId||a.workspaceId===c.id)?(p=a,h=c.id,x=e.modelId,{id:`pending-runtime:${p.id}`,source:"turn",key:`pending:${p.id}`,title:(b=p.mission,(f=b.replace(/\s+/g," ").trim()).length<=36?f:`${f.slice(0,Math.max(35,1)).trimEnd()}…`),subtitle:"Materializing on the OpenClaw canvas…",status:"queued",updatedAt:p.submittedAt,ageMs:0,agentId:p.agentId,workspaceId:h,modelId:x,runId:p.id,metadata:{pendingCreation:!0}}):null,N=k?[k,...j]:j,C=v+4*r;m.push({id:e.id,type:"agent",draggable:!0,position:{x:w,y:C},zIndex:10,selected:!1,data:{agent:e,emphasis:!t||t===c.id,onEdit:n,onDelete:i}}),k&&u.unshift(k),N.forEach((e,a)=>{let r=e.id.startsWith("pending-runtime:"),n=s.includes(e.id);m.push({id:e.id,type:"runtime",draggable:!r,selectable:!r,position:{x:y,y:C+88*a+10},zIndex:r?40:n?28:10,selected:!1,data:{runtime:e,emphasis:!t||t===c.id,pendingCreation:r,justCreated:n,onReply:l,onCopyPrompt:o,onHide:d}})}),v+=Math.max(138,88*N.length+36)}),p.push({id:c.id,type:"workspace",draggable:!1,position:{x:b,y:f},zIndex:0,style:{width:1020,height:Math.max(v-f+104,640)},selectable:!0,selected:!1,data:{workspace:c,emphasis:!t||t===c.id}})});let h=[...p,...m];return{nodes:h,edges:function(e,t){let a=[],s=new Map(t.map(e=>[e.id,e]));for(let t of e){if(!t.agentId)continue;let e=s.get(t.agentId),r=s.get(t.id);e&&r&&a.push({id:`edge:${t.agentId}:${t.id}`,source:t.agentId,target:t.id,sourceHandle:"source-right",targetHandle:"target-left",type:"simplebezier",zIndex:4,animated:"active"===t.status,style:{stroke:"active"===t.status?"rgba(107, 190, 255, 0.85)":"rgba(148, 163, 184, 0.28)",strokeWidth:"active"===t.status?1.45:1.05}})}return a}(u,h)}}var K=a(3638),J=a(1835),G=a(2070),H=a(3440),Z=a(7763),Q=a(9311),Y=a(8186);let X=(0,v.F)("inline-flex items-center justify-center whitespace-nowrap rounded-2xl text-sm font-medium transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-cyan-400 text-slate-950 shadow-lg shadow-cyan-400/20 hover:bg-cyan-300",secondary:"border border-white/10 bg-white/5 text-slate-100 hover:bg-white/10 hover:text-white",ghost:"text-slate-200 hover:bg-white/[0.08] hover:text-white",destructive:"bg-rose-500 text-white shadow-lg shadow-rose-500/20 hover:bg-rose-400"},size:{default:"h-11 px-4 py-2",sm:"h-9 rounded-xl px-3",lg:"h-12 rounded-2xl px-5",icon:"h-11 w-11"}},defaultVariants:{variant:"default",size:"default"}}),ee=m.forwardRef(({className:e,variant:t,size:a,asChild:r=!1,...n},i)=>{let l=r?Y.DX:"button";return(0,s.jsx)(l,{className:w(X({variant:t,size:a,className:e})),ref:i,...n})});ee.displayName="Button";var et=a(8551);let ea=et.bL,es=et.l9,er=et.ZL;et.bm;let en=m.forwardRef(({className:e,...t},a)=>(0,s.jsx)(et.hJ,{ref:a,className:w("fixed inset-0 z-50 bg-slate-950/75 backdrop-blur-md",e),...t}));en.displayName=et.hJ.displayName;let ei=m.forwardRef(({className:e,children:t,...a},r)=>(0,s.jsxs)(er,{children:[(0,s.jsx)(en,{}),(0,s.jsxs)(et.UC,{ref:r,className:w("fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 rounded-[28px] border border-white/10 bg-slate-950/90 p-6 shadow-panel backdrop-blur-xl duration-200",e),...a,children:[t,(0,s.jsxs)(et.bm,{className:"absolute right-4 top-4 rounded-full p-2 text-slate-400 transition-colors hover:bg-white/5 hover:text-white",children:[(0,s.jsx)(J.A,{className:"h-4 w-4"}),(0,s.jsx)("span",{className:"sr-only",children:"Close"})]})]})]}));ei.displayName=et.UC.displayName;let el=({className:e,...t})=>(0,s.jsx)("div",{className:w("flex flex-col space-y-2 text-left",e),...t}),eo=({className:e,...t})=>(0,s.jsx)("div",{className:w("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t}),ed=m.forwardRef(({className:e,...t},a)=>(0,s.jsx)(et.hE,{ref:a,className:w("font-display text-xl text-white",e),...t}));ed.displayName=et.hE.displayName;let ec=m.forwardRef(({className:e,...t},a)=>(0,s.jsx)(et.VY,{ref:a,className:w("text-sm text-slate-400",e),...t}));ec.displayName=et.VY.displayName;let ep=m.forwardRef(({className:e,type:t,...a},r)=>(0,s.jsx)("input",{type:t,className:w("flex h-11 w-full rounded-2xl border border-white/10 bg-white/5 px-4 py-2 text-sm text-white placeholder:text-slate-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-cyan-400/60 disabled:cursor-not-allowed disabled:opacity-50",e),ref:r,...a}));ep.displayName="Input";var em=a(9389);let eu=(0,v.F)("text-xs font-medium uppercase tracking-[0.18em] text-slate-400"),eh=m.forwardRef(({className:e,...t},a)=>(0,s.jsx)(em.b,{ref:a,className:w(eu(),e),...t}));eh.displayName=em.b.displayName;var ex=a(2629);let eg={worker:{label:"Worker",description:"Delivers code, docs, research, review, or analysis without mutating the system.",defaultName:"Worker",defaultEmoji:"\uD83D\uDEE0️",defaultTheme:"slate",badgeVariant:"default"},setup:{label:"Setup / Operator",description:"Prepares the environment, installs dependencies, and unblocks other agents.",defaultName:"Setup Operator",defaultEmoji:"\uD83E\uDDF0",defaultTheme:"amber",badgeVariant:"warning"},browser:{label:"Browser",description:"Captures browser evidence, screenshots, and user-path validation inside the workspace.",defaultName:"Browser Agent",defaultEmoji:"\uD83C\uDF10",defaultTheme:"blue",badgeVariant:"success"},monitoring:{label:"Monitoring",description:"Periodically checks workspace health, drift, and blockers, then leaves triage handoffs.",defaultName:"Monitoring Agent",defaultEmoji:"\uD83D\uDEF0️",defaultTheme:"teal",badgeVariant:"warning"},custom:{label:"Custom",description:"Starts from a safe default policy but leaves room for manual overrides.",defaultName:"Custom Agent",defaultEmoji:"\uD83E\uDDE9",defaultTheme:"violet",badgeVariant:"muted"}},eb={worker:{missingToolBehavior:"fallback",installScope:"none",fileAccess:"workspace-only",networkAccess:"enabled"},setup:{missingToolBehavior:"allow-install",installScope:"workspace",fileAccess:"workspace-only",networkAccess:"enabled"},browser:{missingToolBehavior:"ask-setup",installScope:"none",fileAccess:"workspace-only",networkAccess:"enabled"},monitoring:{missingToolBehavior:"fallback",installScope:"none",fileAccess:"workspace-only",networkAccess:"enabled"},custom:{missingToolBehavior:"fallback",installScope:"none",fileAccess:"workspace-only",networkAccess:"enabled"}},ef=Object.entries(eg).map(([e,t])=>({value:e,label:t.label,description:t.description})),ew=[{value:"fallback",label:"Fallback",description:"Produce the nearest viable output format instead of failing the task."},{value:"ask-setup",label:"Ask for setup",description:"Stop before environment changes and report the missing capability clearly."},{value:"route-setup",label:"Route to setup agent",description:"Leave an explicit setup handoff instead of attempting installs directly."},{value:"allow-install",label:"Allow install",description:"Install missing tooling when policy allows it and the task truly depends on it."}],ey=[{value:"none",label:"None",description:"Do not install workspace or system dependencies."},{value:"workspace",label:"Workspace only",description:"Only install dependencies inside the project or workspace environment."},{value:"system",label:"System",description:"Permit system-wide installs when they are necessary and intentional."}],ev=[{value:"workspace-only",label:"Workspace only",description:"Keep file work grounded inside the attached workspace."},{value:"extended",label:"Extended",description:"Allow broader file access when the task explicitly needs it."}],ej=[{value:"restricted",label:"Off",description:"Avoid network access unless the task explicitly depends on it."},{value:"enabled",label:"On",description:"Use network access when the task needs external information or downloads."}];function ek(e="worker",t){return{...eb[e],...t??{},preset:e}}function eN(e){return eg[e].label}function eC(e){return ew.find(t=>t.value===e)?.label??e}function eS(e){return ey.find(t=>t.value===e)?.label??e}function eA(e){return ev.find(t=>t.value===e)?.label??e}function eI(e){return ej.find(t=>t.value===e)?.label??e}let eT=[{value:"15m",label:"15 min"},{value:"30m",label:"30 min"},{value:"60m",label:"1 hour"},{value:"240m",label:"4 hours"}];function e$(e){return"monitoring"===e?{enabled:!0,every:"30m"}:{enabled:!1,every:"30m"}}function e_(e,t){let a=e$(e),s="string"==typeof t?.every&&t.every.trim()&&"disabled"!==t.every?t.every.trim():a.every;return"boolean"==typeof t?.enabled?{enabled:t.enabled,every:s}:t?.every==="disabled"?{enabled:!1,every:s}:a}function eO(e,t,a){let s=e$(t);return e.enabled!==s.enabled||e.every!==s.every?e:e$(a)}function eR({snapshot:e,defaultWorkspaceId:t,onRefresh:a,onAgentCreated:r,trigger:n}){var i,l;let o,d,[c,p]=(0,m.useState)(!1),[u,h]=(0,m.useState)(!1),[x,g]=(0,m.useState)(!1),[b,f]=(0,m.useState)(!1),[y,v]=(0,m.useState)(!1),[j,k]=(0,m.useState)(()=>eL(t??e.workspaces[0]?.id??"")),N=e.workspaces.find(e=>e.id===j.workspaceId)??e.workspaces[0]??null,C=(i=N?.slug,l=j.name||eg[j.policy.preset].defaultName,o=eU(i??""),d=eU(l)||"agent",o?`${o}-${d}`:d),S=eU(j.id),A=S.length>0?e.agents.find(e=>e.id===S)??null:null,I=A?e.workspaces.find(e=>e.id===A.workspaceId)?.name??A.workspacePath:null,T=!!(S&&j.workspaceId)&&!b&&null===A,$=x||"monitoring"===j.policy.preset;(0,m.useEffect)(()=>{p(!0)},[]),(0,m.useEffect)(()=>{u||(k(eL(t??e.workspaces[0]?.id??"")),g(!1),v(!1))},[u,t,e.workspaces]),(0,m.useEffect)(()=>{u&&!y&&C&&k(e=>e.id===C?e:{...e,id:C})},[u,y,C]);let _=async()=>{if(S&&!A){f(!0);try{let e=await fetch("/api/agents",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...j,id:S})}),t=await e.json();if(!e.ok||t.error||!t.agentId)throw Error(t.error||"OpenClaw could not create the agent.");ex.o.success("Agent created in OpenClaw.",{description:t.agentId}),h(!1),await a(),r?.(t.agentId)}catch(e){ex.o.error("Agent creation failed.",{description:e instanceof Error?e.message:"Unknown agent error."})}finally{f(!1)}}};return c?(0,s.jsxs)(ea,{open:u,onOpenChange:h,children:[(0,s.jsx)(es,{asChild:!0,children:n}),(0,s.jsxs)(ei,{className:"max-h-[90vh] overflow-y-auto sm:max-w-3xl",children:[(0,s.jsxs)(el,{children:[(0,s.jsx)(ed,{children:"Create a new OpenClaw agent"}),(0,s.jsx)(ec,{children:"This creates a real isolated agent bound to an existing workspace with a preset policy."})]}),(0,s.jsxs)("div",{className:"space-y-5",children:[(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)("p",{className:"text-[11px] uppercase tracking-[0.18em] text-slate-400",children:"Agent preset"}),(0,s.jsx)("div",{className:"grid gap-3 sm:grid-cols-2",children:ef.map(e=>(0,s.jsx)(eP,{label:e.label,description:e.description,active:j.policy.preset===e.value,badgeVariant:eg[e.value].badgeVariant,onClick:()=>k(t=>{var a,s;let r,n,i;return a=t,s=e.value,r=eg[a.policy.preset],n=eg[s],i=ek(s),{...a,name:a.name&&a.name!==r.defaultName?a.name:n.defaultName,emoji:a.emoji&&a.emoji!==r.defaultEmoji?a.emoji:n.defaultEmoji,theme:a.theme&&a.theme!==r.defaultTheme?a.theme:n.defaultTheme,policy:i,heartbeat:eO(a.heartbeat,a.policy.preset,s)}})},e.value))})]}),(0,s.jsx)(eE,{policy:j.policy}),(0,s.jsxs)(eM,{label:"Agent id",htmlFor:"create-agent-id",children:[(0,s.jsx)(ep,{id:"create-agent-id",value:j.id,onChange:e=>{let t=e.target.value,a=eU(t);v(!!a&&a!==C),k(e=>({...e,id:t}))},placeholder:C||"workspace-agent"}),(0,s.jsx)("p",{className:w("text-[12px]",A?"text-rose-300":"text-slate-500"),children:A?`ID "${S}" is already used by ${A.name} in ${I}.`:S&&S!==j.id.trim()?`Saved as ${S}. Suggested workspace-scoped id: ${C}.`:`Workspace-scoped id: ${C}.`})]}),(0,s.jsx)(eM,{label:"Display name",htmlFor:"create-agent-name",children:(0,s.jsx)(ep,{id:"create-agent-name",value:j.name,onChange:e=>k(t=>({...t,name:e.target.value})),placeholder:eg[j.policy.preset].defaultName})}),(0,s.jsx)(eM,{label:"Workspace",htmlFor:"create-agent-workspace",children:(0,s.jsx)("select",{id:"create-agent-workspace",value:j.workspaceId,onChange:e=>k(t=>({...t,workspaceId:e.target.value})),className:"flex h-11 w-full rounded-2xl border border-white/10 bg-white/5 px-4 py-2 text-sm text-white outline-none",children:e.workspaces.map(e=>(0,s.jsx)("option",{value:e.id,children:e.name},e.id))})}),(0,s.jsx)(eM,{label:"Model",htmlFor:"create-agent-model",children:(0,s.jsxs)("select",{id:"create-agent-model",value:j.modelId,onChange:e=>k(t=>({...t,modelId:e.target.value})),className:"flex h-11 w-full rounded-2xl border border-white/10 bg-white/5 px-4 py-2 text-sm text-white outline-none",children:[(0,s.jsx)("option",{value:"",children:"Use OpenClaw default"}),e.models.map(e=>(0,s.jsx)("option",{value:e.id,children:e.id},e.id))]})}),(0,s.jsxs)("div",{className:"grid gap-4 sm:grid-cols-2",children:[(0,s.jsx)(eM,{label:"Emoji",htmlFor:"create-agent-emoji",children:(0,s.jsx)(ep,{id:"create-agent-emoji",value:j.emoji,onChange:e=>k(t=>({...t,emoji:e.target.value})),placeholder:eg[j.policy.preset].defaultEmoji})}),(0,s.jsx)(eM,{label:"Theme",htmlFor:"create-agent-theme",children:(0,s.jsx)(ep,{id:"create-agent-theme",value:j.theme,onChange:e=>k(t=>({...t,theme:e.target.value})),placeholder:eg[j.policy.preset].defaultTheme})})]}),(0,s.jsx)(eM,{label:"Avatar URL",htmlFor:"create-agent-avatar",children:(0,s.jsx)(ep,{id:"create-agent-avatar",value:j.avatar,onChange:e=>k(t=>({...t,avatar:e.target.value})),placeholder:"https://example.com/avatar.png"})}),(0,s.jsxs)("div",{className:"rounded-[20px] border border-white/10 bg-white/[0.03] p-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium text-white",children:"Advanced policy"}),(0,s.jsx)("p",{className:"mt-1 text-xs leading-5 text-slate-400",children:"Override missing-tool behavior, install scope, file access, and network posture."})]}),(0,s.jsx)(ee,{type:"button",variant:"secondary",size:"sm",className:"h-8 rounded-full px-3 text-[11px]",onClick:()=>g(e=>!e),children:x?"Hide":"Show"})]}),$?(0,s.jsxs)("div",{className:"mt-4 rounded-[18px] border border-white/10 bg-slate-950/40 p-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium text-white",children:"Heartbeat"}),(0,s.jsx)("p",{className:"mt-1 text-xs leading-5 text-slate-400",children:"Use this only for periodic watch or triage agents. Leave it off for normal task execution."})]}),(0,s.jsx)(ee,{type:"button",variant:j.heartbeat.enabled?"default":"secondary",size:"sm",className:"h-8 rounded-full px-3 text-[11px]",onClick:()=>k(e=>({...e,heartbeat:e.heartbeat.enabled?{...e.heartbeat,enabled:!1}:{...e.heartbeat,enabled:!0,every:e.heartbeat.every||e$(e.policy.preset).every}})),children:j.heartbeat.enabled?"On":"Off"})]}),j.heartbeat.enabled?(0,s.jsx)("div",{className:"mt-3",children:(0,s.jsx)(eM,{label:"Interval",htmlFor:"create-agent-heartbeat-every",children:(0,s.jsx)("select",{id:"create-agent-heartbeat-every",value:j.heartbeat.every,onChange:e=>k(t=>({...t,heartbeat:{...t.heartbeat,every:e.target.value}})),className:"flex h-11 w-full rounded-2xl border border-white/10 bg-white/5 px-4 py-2 text-sm text-white outline-none",children:eT.map(e=>(0,s.jsx)("option",{value:e.value,children:e.label},e.value))})})}):null]}):null,x?(0,s.jsxs)("div",{className:"mt-4 grid gap-4 sm:grid-cols-2",children:[(0,s.jsx)(eD,{label:"Missing tool behavior",htmlFor:"create-agent-missing-tools",value:j.policy.missingToolBehavior,options:ew,onChange:e=>k(t=>({...t,policy:{...t.policy,missingToolBehavior:e}}))}),(0,s.jsx)(eD,{label:"Install scope",htmlFor:"create-agent-install-scope",value:j.policy.installScope,options:ey,onChange:e=>k(t=>({...t,policy:{...t.policy,installScope:e}}))}),(0,s.jsx)(eD,{label:"File access",htmlFor:"create-agent-file-access",value:j.policy.fileAccess,options:ev,onChange:e=>k(t=>({...t,policy:{...t.policy,fileAccess:e}}))}),(0,s.jsx)(eD,{label:"Network access",htmlFor:"create-agent-network-access",value:j.policy.networkAccess,options:ej,onChange:e=>k(t=>({...t,policy:{...t.policy,networkAccess:e}}))})]}):null]})]}),(0,s.jsxs)(eo,{children:[(0,s.jsx)(ee,{variant:"secondary",onClick:()=>h(!1),children:"Cancel"}),(0,s.jsx)(ee,{onClick:_,disabled:!T,children:b?"Creating...":"Create agent"})]})]})]}):(0,s.jsx)(s.Fragment,{children:n})}function eM({label:e,htmlFor:t,children:a}){return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(eh,{htmlFor:t,className:"text-[11px] uppercase tracking-[0.18em] text-slate-400",children:e}),a]})}function eP({label:e,description:t,active:a,badgeVariant:r,onClick:n}){return(0,s.jsx)("button",{type:"button",onClick:n,className:w("rounded-[20px] border p-4 text-left transition-colors",a?"border-cyan-300/30 bg-cyan-400/10":"border-white/10 bg-white/[0.03]"),children:(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)("p",{className:"text-sm font-medium text-white",children:e}),(0,s.jsx)("p",{className:"text-xs leading-5 text-slate-400",children:t})]}),(0,s.jsx)(k,{variant:r,children:a?"selected":"preset"})]})})}function eE({policy:e}){let t=eg[e.preset];return(0,s.jsxs)("div",{className:"rounded-[20px] border border-white/10 bg-slate-950/50 p-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium text-white",children:t.label}),(0,s.jsx)("p",{className:"mt-1 text-xs leading-5 text-slate-400",children:t.description})]}),(0,s.jsx)(k,{variant:t.badgeVariant,children:t.label})]}),(0,s.jsxs)("div",{className:"mt-4 flex flex-wrap gap-2",children:[(0,s.jsx)(k,{variant:"muted",children:eC(e.missingToolBehavior)}),(0,s.jsx)(k,{variant:"muted",children:eS(e.installScope)}),(0,s.jsx)(k,{variant:"muted",children:eA(e.fileAccess)}),(0,s.jsxs)(k,{variant:"muted",children:["Network ",eI(e.networkAccess)]})]})]})}function eD({label:e,htmlFor:t,value:a,options:r,onChange:n}){return(0,s.jsx)(eM,{label:e,htmlFor:t,children:(0,s.jsx)("select",{id:t,value:a,onChange:e=>n(e.target.value),className:"flex h-11 w-full rounded-2xl border border-white/10 bg-white/5 px-4 py-2 text-sm text-white outline-none",children:r.map(e=>(0,s.jsxs)("option",{value:e.value,children:[e.label," - ",e.description]},e.value))})})}function eL(e,t={}){let a=ek(t.policy?.preset??"worker",t.policy),s=eg[a.preset],r=e_(a.preset,t.heartbeat);return{id:t.id??"",workspaceId:e,modelId:t.modelId??"",name:t.name??s.defaultName,emoji:t.emoji??s.defaultEmoji,theme:t.theme??s.defaultTheme,avatar:t.avatar??"",policy:a,heartbeat:r}}function eU(e){return e.toLowerCase().normalize("NFKD").replace(/[\u0300-\u036f]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}let ez=m.forwardRef(({className:e,...t},a)=>(0,s.jsx)("textarea",{className:w("flex min-h-[96px] w-full rounded-2xl border border-white/10 bg-white/5 px-4 py-3 text-sm text-white placeholder:text-slate-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-cyan-400/60 disabled:cursor-not-allowed disabled:opacity-50",e),ref:a,...t}));ez.displayName="Textarea";let eF="mission-control-recent-prompts";function eW({snapshot:e,activeWorkspaceId:t,selectedNodeId:a,composeIntent:r,onRefresh:n,onOpenWorkspaceCreate:l,onOpenWorkspacePlanner:o,onMissionResponse:d,onMissionDispatchStart:c,onMissionDispatchComplete:p}){var u,h;let x,b,f,[y,v]=(0,m.useState)(""),[j,k]=(0,m.useState)(""),[N,C]=(0,m.useState)("medium"),[S,A]=(0,m.useState)(!1),[I,T]=(0,m.useState)(!1),[$,_]=(0,m.useState)(!1),[O,R]=(0,m.useState)(!1),[M,P]=(0,m.useState)(!1),[E,L]=(0,m.useState)(!1),[U,z]=(0,m.useState)([]),[F,W]=(0,m.useState)(null),B=(0,m.useRef)(null),V=(0,m.useRef)(null),q=(0,m.useRef)(null),Z=(0,m.useRef)(null),Y=(0,m.useRef)(!1),X=(0,m.useRef)(null),et=e.workspaces.find(e=>e.id===t)??e.workspaces[0],ea=e.agents.filter(e=>!et||e.workspaceId===et.id),es=ea.find(e=>e.id===j)??ea[0]??null,er=es?.id??null,en=ea.map(e=>({label:e.name,value:e.id})),ei=eG(et?.id??t??null,er),el=!!(y.trim()&&er&&!S),eo=es?`Compose for ${es.name}...`:"Compose a mission...",ed=(u=es,h=U,(x=[]).push({id:"workspace-create",label:"Create workspace",action:"open-workspace-create"}),x.push({id:"workspace-planner",label:"Architect mode",action:"open-workspace-planner"}),u&&(x.push({id:"link-agent",label:`Link ${u.name}`,mission:`Link ${u.name} into the mission plan and define its first handoff.`}),x.push({id:"raise-priority",label:"Raise priority",mission:"Prioritize the mission and define the critical path.",thinking:"high"})),(b=h[0])&&x.push({id:`recent-${b.id}`,label:"Reuse recent",mission:b.mission}),f=new Set,x.filter(e=>{let t=`${e.action||"mission"}:${e.mission?.trim().toLowerCase()||e.label.toLowerCase()}`;return!f.has(t)&&(f.add(t),!0)}).slice(0,3)),ec=ed.length>0,ep=M&&!E&&!O&&!$&&!S&&0===y.trim().length&&null===F;(0,m.useEffect)(()=>{let s=`${t??"all"}:${a??"none"}:${ea.map(e=>e.id).join(",")}`,r=function(e,t,a){let s=e.agents.find(e=>e.id===a);if(s)return s.id;let r=e.runtimes.find(e=>e.id===a);if(r?.agentId)return r.agentId;let n=e.agents.filter(e=>t?e.workspaceId===t:e.isDefault);return n.find(e=>e.isDefault)?.id||n[0]?.id||e.agents[0]?.id}(e,t,a),n=q.current;if(n&&ea.some(e=>e.id===n)){j!==n&&k(n),q.current=null;return}V.current!==s&&(V.current=s,r&&ea.some(e=>e.id===r))?k(r):ea.some(e=>e.id===j)||k(r&&ea.some(e=>e.id===r)?r:ea[0]?.id??"")},[e,t,a,j,ea]),(0,m.useEffect)(()=>{void 0!==globalThis.localStorage&&z(eH())},[]),(0,m.useEffect)(()=>{let e=globalThis.matchMedia("(min-width: 1024px)"),t=()=>{P(e.matches),e.matches||L(!1)};return t(),e.addEventListener("change",t),()=>{e.removeEventListener("change",t)}},[]),(0,m.useEffect)(()=>{var e;(e=B.current)&&(e.style.height="0px",e.style.height=`${Math.min(e.scrollHeight,150)}px`)},[y]),(0,m.useEffect)(()=>{if(!ei||void 0===globalThis.localStorage)return;if(X.current===ei){X.current=null;return}let e=function(e){try{var t;let a=globalThis.localStorage.getItem(e);if(!a)return null;let s=JSON.parse(a);if("string"!=typeof s.mission)return null;return{mission:s.mission,thinking:(t=s.thinking,"off"===t||"minimal"===t||"low"===t||"medium"===t||"high"===t)?s.thinking:"medium"}}catch{return null}}(ei);Y.current=!0,v(e?.mission??""),C(e?.thinking??"medium"),W(null)},[ei]),(0,m.useEffect)(()=>{if(ei&&void 0!==globalThis.localStorage){if(Y.current){Y.current=!1;return}!function(e,t){try{if(!t.mission.trim()&&"medium"===t.thinking)return void globalThis.localStorage.removeItem(e);globalThis.localStorage.setItem(e,JSON.stringify(t))}catch{}}(ei,{mission:y,thinking:N})}},[ei,y,N]),(0,m.useEffect)(()=>{if(!r||Z.current===r.id)return;Z.current=r.id;let e=r.mission.trim();if(!e)return;let a=eG(et?.id??t??null,r.agentId??er);a&&(X.current=a);let s=0===y.trim().length||y.trim()===e;W({id:r.id,mission:e,sourceKind:r.sourceKind??"copy",sourceLabel:r.sourceLabel??"selected runtime"}),s&&v(e),r.agentId&&k(r.agentId),requestAnimationFrame(()=>{B.current?.focus(),s&&B.current?.setSelectionRange(e.length,e.length)})},[r,y,t,er,et?.id]);let em=async e=>{A(!0);let a=e.agentId||er,s=globalThis.crypto?.randomUUID?.()||`dispatch-${Date.now()}`,r=Date.now();a&&c({id:s,mission:e.mission,agentId:a,workspaceId:e.workspaceId??t,submittedAt:r});try{let s=e.mission.trim(),i=await fetch("/api/mission",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),l=await i.json();if(!i.ok||l.error)throw Error(l.error||"OpenClaw rejected the mission.");if(d(l),p("success"),v(""),W(null),_(!1),Y.current=!0,ei&&void 0!==globalThis.localStorage&&globalThis.localStorage.removeItem(ei),a){let e=function(e){let t=[e,...eH().filter(t=>t.mission.trim()!==e.mission.trim()||t.agentId!==e.agentId||t.workspaceId!==e.workspaceId)].slice(0,6);try{globalThis.localStorage.setItem(eF,JSON.stringify(t))}catch{}return t}({id:globalThis.crypto?.randomUUID?.()||`${r}`,mission:s,agentId:a,agentName:es?.name??"Agent",workspaceId:et?.id??t,workspaceName:et?.name??null,submittedAt:r});z(e)}ex.o.success("Mission dispatched to OpenClaw.",{description:"string"==typeof l.meta?.outputDirRelative?`Run ${l.runId.slice(0,8)} via ${l.agentId} \xb7 ${l.meta.outputDirRelative}`:`Run ${l.runId.slice(0,8)} via ${l.agentId}`}),await n()}catch(e){p("error"),ex.o.error("Mission dispatch failed.",{description:e instanceof Error?e.message:"Unknown mission error."})}finally{A(!1)}},eu=(e,t={})=>{t.thinking&&C(t.thinking),v(a=>{var s,r;let n,i;return"replace"===t.mode?e:(s=a,r=e,n=s.trim(),i=r.trim(),n?i?`${n}
2
-
3
- ${i}`:n:i)}),requestAnimationFrame(()=>{B.current?.focus();let e=B.current?.value??"";B.current?.setSelectionRange(e.length,e.length)})};return(0,s.jsx)("div",{className:w("mx-auto w-full transition-[width] duration-300",ep&&"lg:w-[360px]"),onMouseEnter:()=>{M&&L(!0)},onMouseLeave:()=>{M&&L(!1)},children:(0,s.jsx)(Q.N,{initial:!1,mode:"wait",children:ep?(0,s.jsx)(g.P.button,{type:"button",initial:{opacity:0,y:8,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:8,scale:.98},onFocus:()=>L(!0),onClick:()=>{L(!0),requestAnimationFrame(()=>{B.current?.focus()})},className:"w-full rounded-full border border-white/[0.08] bg-[rgba(9,14,22,0.58)] p-2 text-left shadow-[0_24px_72px_rgba(0,0,0,0.22)] backdrop-blur-[28px]",children:(0,s.jsxs)("div",{className:"flex items-center gap-2 rounded-full border border-white/[0.07] bg-[linear-gradient(180deg,rgba(255,255,255,0.05),rgba(255,255,255,0.025))] px-3 py-2",children:[(0,s.jsx)("span",{className:"inline-flex h-7 items-center rounded-full border border-white/[0.08] bg-white/[0.04] px-2.5 text-[11px] text-slate-300",children:es?.name||"No agent"}),(0,s.jsx)("p",{className:"min-w-0 flex-1 truncate text-[13px] text-[#f6eee5]/58",children:eo}),(0,s.jsxs)("span",{className:"inline-flex h-8 items-center rounded-full bg-white px-3 text-[12px] font-medium text-slate-950",children:[(0,s.jsx)(K.A,{className:"mr-1.5 h-3.5 w-3.5"}),"Send"]})]})},"collapsed"):(0,s.jsxs)(g.P.div,{initial:{opacity:0,y:8,scale:.985},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:8,scale:.985},className:"rounded-[26px] border border-white/[0.08] bg-[rgba(9,14,22,0.58)] p-2.5 shadow-[0_24px_72px_rgba(0,0,0,0.26)] backdrop-blur-[28px]",children:[(0,s.jsx)(Q.N,{initial:!1,children:F?(0,s.jsxs)(g.P.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},className:"mb-2 flex flex-wrap items-center gap-2 px-1 text-[12px] text-slate-400",children:[(0,s.jsxs)("span",{className:"truncate",children:["From ",F.sourceLabel]}),(0,s.jsx)("button",{type:"button",className:"text-slate-200 transition-colors hover:text-white",onClick:()=>eu(F.mission,{mode:"replace"}),children:"Replace"}),(0,s.jsx)("button",{type:"button",className:"text-slate-200 transition-colors hover:text-white",onClick:()=>eu(F.mission),children:"Append"}),(0,s.jsx)("button",{type:"button",className:"inline-flex h-6 w-6 items-center justify-center rounded-full text-slate-400 transition-colors hover:bg-white/[0.06] hover:text-white",onClick:()=>W(null),"aria-label":"Dismiss runtime suggestion",children:(0,s.jsx)(J.A,{className:"h-3.5 w-3.5"})})]}):null}),(0,s.jsxs)("div",{className:w("rounded-[22px] border border-white/[0.07] bg-[linear-gradient(180deg,rgba(255,255,255,0.06),rgba(255,255,255,0.03))] transition-all duration-200",O&&"border-white/[0.14] bg-[linear-gradient(180deg,rgba(255,255,255,0.08),rgba(255,255,255,0.04))]"),onFocusCapture:()=>R(!0),onBlurCapture:e=>{let t=e.relatedTarget;t instanceof Node&&e.currentTarget.contains(t)||R(!1)},children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 px-2.5 pb-1 pt-2.5",children:[es?(0,s.jsx)(eB,{value:j,options:en,onChange:e=>{k(e)}}):(0,s.jsx)(eJ,{children:"No agent"}),et?(0,s.jsx)(eR,{snapshot:e,defaultWorkspaceId:et.id,onRefresh:n,onAgentCreated:e=>{q.current=e,k(e)},trigger:(0,s.jsx)("button",{type:"button",className:"inline-flex h-8 items-center rounded-full border border-white/[0.08] bg-white/[0.04] px-3 text-[12px] text-slate-300 transition-all hover:bg-white/[0.08] hover:text-white",children:"+ Create Agent"})}):null,(0,s.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[(0,s.jsx)(eq,{label:"Refresh mission control",onClick:async()=>{T(!0),await n(),T(!1)},children:I?(0,s.jsx)(i.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,s.jsx)(G.A,{className:"h-3.5 w-3.5"})}),(0,s.jsx)(eq,{label:"Create workspace",onClick:l,children:(0,s.jsx)(D.A,{className:"h-3.5 w-3.5"})}),(0,s.jsx)(eq,{label:"Composer settings",onClick:()=>_(e=>!e),active:$||"medium"!==N,children:(0,s.jsxs)("span",{className:"relative inline-flex",children:[(0,s.jsx)(H.A,{className:"h-3.5 w-3.5"}),"medium"!==N?(0,s.jsx)("span",{className:"absolute -right-1 -top-1 h-1.5 w-1.5 rounded-full bg-white/80"}):null]})})]})]}),(0,s.jsx)("div",{className:"px-2.5 pt-0.5",children:(0,s.jsx)(ez,{ref:B,value:y,onChange:e=>v(e.target.value),onKeyDown:async e=>{(e.metaKey||e.ctrlKey)&&"Enter"===e.key&&(e.preventDefault(),el&&er&&await em({mission:y,agentId:er,workspaceId:t??void 0,thinking:N}))},placeholder:eo,className:"min-h-[50px] max-h-[150px] resize-none overflow-y-auto border-0 bg-transparent px-0 py-0.5 text-[15px] leading-[1.6] text-white placeholder:text-[#f6eee5]/60 focus-visible:ring-0 focus-visible:ring-offset-0"})}),(0,s.jsxs)("div",{className:"flex items-end justify-between gap-2.5 px-2.5 pb-2.5 pt-1.5",children:[(0,s.jsx)(Q.N,{initial:!1,children:ec?(0,s.jsx)(g.P.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:4},className:"flex min-w-0 flex-wrap items-center gap-1.5",children:ed.map(e=>(0,s.jsx)(eK,{label:e.label,onClick:()=>{"open-workspace-create"===e.action?l():"open-workspace-planner"===e.action?o():e.mission&&eu(e.mission,{thinking:e.thinking})}},e.id))}):(0,s.jsx)("div",{})}),(0,s.jsxs)(ee,{className:"h-9 rounded-full bg-white px-3.5 text-slate-950 shadow-none hover:bg-white/92",disabled:!el,onClick:async()=>{er&&await em({mission:y,agentId:er,workspaceId:t??void 0,thinking:N})},children:[S?(0,s.jsx)(i.A,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):(0,s.jsx)(K.A,{className:"mr-1.5 h-3.5 w-3.5"}),"Send"]})]})]}),(0,s.jsx)(Q.N,{initial:!1,children:$?(0,s.jsx)(g.P.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},className:"mt-2 flex justify-end",children:(0,s.jsxs)("div",{className:"w-full max-w-[232px] rounded-[20px] border border-white/[0.08] bg-[rgba(12,17,27,0.9)] p-3 shadow-[0_16px_32px_rgba(0,0,0,0.22)]",children:[(0,s.jsx)("p",{className:"text-[11px] text-slate-300",children:"Thinking"}),(0,s.jsx)("div",{className:"mt-2",children:(0,s.jsx)(eV,{ariaLabel:"Select thinking level",value:N,options:[{label:"off",value:"off"},{label:"minimal",value:"minimal"},{label:"low",value:"low"},{label:"medium",value:"medium"},{label:"high",value:"high"}],onChange:e=>C(e)})}),(0,s.jsx)("button",{type:"button",className:"mt-3 text-[12px] text-slate-400 transition-colors hover:text-white",onClick:()=>{v(""),C("medium"),W(null),Y.current=!0,ei&&void 0!==globalThis.localStorage&&globalThis.localStorage.removeItem(ei)},children:"Clear draft"})]})}):null})]},"expanded")})})}function eB({value:e,options:t,onChange:a}){let r=t.find(t=>t.value===e)??t[0],n=t.length>1;return(0,s.jsxs)("div",{className:"relative inline-flex items-center rounded-full border border-white/[0.08] bg-white/[0.04] text-slate-100",children:[n?(0,s.jsx)("select",{"aria-label":"Select mission agent",value:r?.value??"",onChange:e=>a(e.target.value),className:"h-8 appearance-none bg-transparent pl-3 pr-8 text-[12px] outline-none",children:t.map(e=>(0,s.jsx)("option",{value:e.value,children:e.label},e.value))}):(0,s.jsx)("span",{className:"px-3 text-[12px]",children:r?.label||"No agent"}),n?(0,s.jsx)(Z.A,{className:"pointer-events-none absolute right-3 h-3.5 w-3.5 text-slate-400"}):null]})}function eV({ariaLabel:e,value:t,options:a,onChange:r}){let n=a.find(e=>e.value===t)??a[0];return(0,s.jsxs)("div",{className:"relative inline-flex w-full items-center rounded-full border border-white/[0.08] bg-white/[0.04] text-slate-100",children:[(0,s.jsx)("select",{"aria-label":e,value:n?.value??"",onChange:e=>r(e.target.value),className:"h-9 w-full appearance-none bg-transparent pl-3 pr-9 text-[12px] outline-none",children:a.map(e=>(0,s.jsx)("option",{value:e.value,children:e.label},e.value))}),(0,s.jsx)(Z.A,{className:"pointer-events-none absolute right-3 h-3.5 w-3.5 text-slate-400"})]})}function eq({label:e,active:t=!1,onClick:a,children:r}){return(0,s.jsx)("button",{type:"button","aria-label":e,title:e,onClick:a,className:w("inline-flex h-8 w-8 items-center justify-center rounded-full border border-transparent text-slate-400 transition-all hover:border-white/[0.08] hover:bg-white/[0.06] hover:text-white",t&&"border-white/[0.08] bg-white/[0.06] text-white"),children:r})}function eK({label:e,onClick:t}){return(0,s.jsx)("button",{type:"button",onClick:t,className:"inline-flex h-8 items-center rounded-full border border-white/[0.08] bg-white/[0.04] px-3 text-[12px] text-slate-300 transition-all hover:bg-white/[0.08] hover:text-white",children:e})}function eJ({children:e}){return(0,s.jsx)("div",{className:"inline-flex h-8 items-center rounded-full border border-white/[0.08] bg-white/[0.04] px-3 text-[12px] text-slate-300",children:e})}function eG(e,t){return e||t?`mission-control-composer-draft:${e??"global"}:${t??"unassigned"}`:null}function eH(){try{let e=globalThis.localStorage.getItem(eF);if(!e)return[];let t=JSON.parse(e);if(!Array.isArray(t))return[];return t.filter(e=>"object"==typeof e&&null!==e&&"string"==typeof e.id&&"string"==typeof e.mission&&"string"==typeof e.agentId&&"string"==typeof e.agentName&&"number"==typeof e.submittedAt).slice(0,6)}catch{return[]}}var eZ=a(9682),eQ=a(6605),eY=a(4708),eX=a(9114),e0=a(8443),e1=a(4935),e2=a(2589),e5=a(9379),e3=a(2273);function e4(e){return(0,s.jsx)(e8,{...e},e.selectedNodeId??"overview")}function e8({snapshot:e,selectedNodeId:t,lastMission:a,collapsed:r,onToggleCollapsed:n}){let i=e.workspaces.find(e=>e.id===t),l=e.agents.find(e=>e.id===t),o=e.runtimes.find(e=>e.id===t),d=e.models.find(e=>e.id===t),c=i||l||o||d||null,p=o?.id??null,[u,h]=(0,m.useState)("overview"),[x,b]=(0,m.useState)(null),[f,y]=(0,m.useState)(!!p),[v,j]=(0,m.useState)(null),N=!!o,S="output"!==u||N?u:"overview",A=i?.name||l?.name||o?.title||d?.name||"Gateway overview",I=i?"workspace focus":l?"agent focus":o?"run focus":d?"model focus":"live selection",T=(0,m.useMemo)(()=>[{id:"overview",label:"Overview",icon:eZ.A,enabled:!0},{id:"output",label:"Output",icon:eQ.A,enabled:N},{id:"raw",label:"Raw",icon:eY.A,enabled:!0}],[N]);return(0,m.useEffect)(()=>{if(!p)return;let e=new AbortController;return fetch(`/api/runtimes/${encodeURIComponent(p)}`,{signal:e.signal}).then(async e=>{let t=await e.json();if(!e.ok)throw Error(t.error||"Unable to load runtime output.");b(t)}).catch(t=>{e.signal.aborted||(b(null),j(t instanceof Error?t.message:"Unable to load runtime output."))}).finally(()=>{e.signal.aborted||y(!1)}),()=>e.abort()},[p]),(0,s.jsxs)("div",{className:"panel-surface panel-glow flex h-full flex-row-reverse overflow-hidden rounded-[30px] border border-white/[0.08] bg-[#04070e]/88 shadow-[0_28px_90px_rgba(0,0,0,0.42)] backdrop-blur-2xl",children:[(0,s.jsxs)("div",{className:w("flex h-full shrink-0 flex-col items-center bg-[linear-gradient(180deg,rgba(7,10,18,0.98),rgba(3,6,12,0.98))] px-3 py-4",r?"w-full":"w-[78px] border-l border-white/[0.08]"),children:[(0,s.jsx)("button",{type:"button","aria-label":r?"Expand inspector":"Collapse inspector",onClick:n,className:"flex h-12 w-12 items-center justify-center rounded-[18px] border border-cyan-300/20 bg-cyan-400/[0.12] shadow-[0_10px_24px_rgba(34,211,238,0.18)] transition-all hover:border-cyan-200/30 hover:bg-cyan-400/[0.16]",children:(0,s.jsx)(eQ.A,{className:"h-5 w-5 text-cyan-200"})}),(0,s.jsx)("button",{type:"button","aria-label":r?"Expand inspector":"Collapse inspector",onClick:n,className:"mt-4 inline-flex h-11 w-11 items-center justify-center rounded-[16px] border border-white/10 bg-white/[0.04] text-slate-300 transition-all hover:border-cyan-300/18 hover:bg-white/[0.08] hover:text-white",children:r?(0,s.jsx)(eX.A,{className:"h-4 w-4"}):(0,s.jsx)(e0.A,{className:"h-4 w-4"})}),(0,s.jsx)("div",{className:"mt-6 flex flex-1 flex-col items-center gap-2",children:T.map(e=>(0,s.jsx)(ts,{icon:e.icon,label:e.label,active:S===e.id,disabled:!e.enabled,onClick:()=>{e.enabled&&(h(e.id),r&&n())}},e.id))}),(0,s.jsxs)("div",{className:"mt-4 flex flex-col items-center gap-2",children:[(0,s.jsx)(k,{variant:"muted",children:c?"live":"idle"}),r?(0,s.jsx)("p",{className:"max-w-[56px] truncate text-center text-[9px] uppercase tracking-[0.16em] text-slate-500",children:I}):null]})]}),r?null:(0,s.jsx)("div",{className:"min-w-0 flex-1 bg-[linear-gradient(180deg,rgba(6,10,18,0.96),rgba(3,6,14,0.98))]",children:(0,s.jsxs)("div",{className:"mission-scroll flex h-full min-h-0 flex-col overflow-y-auto overscroll-contain",children:[(0,s.jsxs)("div",{className:"shrink-0 border-b border-white/[0.08] px-5 pb-4 pt-5",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"text-[11px] uppercase tracking-[0.28em] text-slate-500",children:"Inspector"}),(0,s.jsx)("h2",{className:"mt-2 font-display text-[1.38rem] leading-tight text-white",children:A}),(0,s.jsx)("p",{className:"mt-2 text-[12px] leading-5 text-slate-400",children:c?"Live OpenClaw-backed details for the selected entity.":"Local gateway health, recent presence, and last mission response."})]}),(0,s.jsx)("div",{className:"rounded-[18px] border border-white/10 bg-white/[0.04] p-2.5 shadow-[inset_0_1px_0_rgba(255,255,255,0.05)]",children:(0,s.jsx)(eQ.A,{className:"h-4 w-4 text-cyan-200"})})]}),(0,s.jsxs)("div",{className:"mt-4 rounded-[22px] border border-white/[0.08] bg-[linear-gradient(180deg,rgba(13,20,34,0.98),rgba(6,10,18,0.96))] p-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-[0.2em] text-slate-500",children:"Selected entity"}),(0,s.jsx)("p",{className:"mt-1.5 text-[14px] text-white",children:A})]}),(0,s.jsx)(k,{variant:"muted",children:I})]}),o?(0,s.jsxs)("p",{className:"mt-3 text-[12px] leading-5 text-slate-400",children:["Run ",$(o.runId||o.id,10)," \xb7 ",o.status," \xb7 ",C(o.updatedAt)]}):null]}),(0,s.jsx)("div",{className:"mt-4 flex flex-wrap gap-2",children:T.filter(e=>e.enabled).map(e=>(0,s.jsx)(tr,{label:e.label,active:S===e.id,onClick:()=>h(e.id)},e.id))})]}),(0,s.jsx)("div",{className:"flex-1 p-4",children:(0,s.jsx)(Q.N,{mode:"wait",children:(0,s.jsxs)(g.P.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:-8},className:"space-y-3.5",children:["overview"===S?(0,s.jsxs)(s.Fragment,{children:[i?(0,s.jsx)(e9,{snapshot:e,workspaceId:i.id}):null,l?(0,s.jsx)(e7,{snapshot:e,agentId:l.id}):null,o?(0,s.jsx)(te,{snapshot:e,runtimeId:o.id,runtimeOutput:x,runtimeOutputLoading:f,runtimeOutputError:v}):null,d?(0,s.jsx)(ta,{snapshot:e,modelId:d.id}):null,c?null:(0,s.jsx)(e6,{snapshot:e,lastMission:a})]}):null,"output"===S&&o?(0,s.jsx)(tt,{runtime:o,runtimeOutput:x,runtimeOutputLoading:f,runtimeOutputError:v}):null,"raw"===S?(0,s.jsx)("pre",{className:"overflow-x-auto rounded-[18px] border border-white/[0.08] bg-slate-950/[0.72] p-3 text-[11px] leading-5 text-slate-300",children:JSON.stringify(o&&x?{runtime:o,output:x}:c||e,null,2)}):null]},`${t||"overview"}:${S}`)})}),(0,s.jsx)("div",{className:"shrink-0 border-t border-white/[0.08] p-4",children:(0,s.jsx)("div",{className:"rounded-[22px] border border-cyan-300/10 bg-[linear-gradient(180deg,rgba(7,22,31,0.95),rgba(5,13,22,0.95))] p-4 shadow-[0_16px_40px_rgba(0,0,0,0.22)]",children:(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"flex h-11 w-11 items-center justify-center rounded-full border border-cyan-300/15 bg-cyan-400/[0.12] text-cyan-200",children:(0,s.jsx)(e1.A,{className:"h-4 w-4"})}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"truncate font-display text-[15px] text-white",children:A}),(0,s.jsx)("p",{className:"mt-1 text-[12px] text-slate-400",children:o?`${x?.items.length??0} transcript entries`:l?`${l.activeRuntimeIds.length} tracked runs`:i?`${i.agentIds.length} agents attached`:`${e.presence.length} live beacons`})]})]})})})]})})]})}function e6({snapshot:e,lastMission:t}){return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(tn,{icon:e1.A,title:"Gateway health",value:e.diagnostics.health,children:[(0,s.jsx)("p",{children:e.diagnostics.gatewayUrl}),(0,s.jsx)("p",{children:e.diagnostics.dashboardUrl})]}),(0,s.jsxs)(tn,{icon:eQ.A,title:"Presence beacons",value:String(e.presence.length),children:[0===e.presence.length?(0,s.jsx)("p",{children:"No live presence payloads."}):null,e.presence.map(e=>(0,s.jsxs)("div",{className:"rounded-[14px] border border-white/[0.08] bg-[linear-gradient(180deg,rgba(11,18,32,0.86),rgba(8,13,24,0.82))] px-3 py-2",children:[(0,s.jsx)("div",{className:"text-[13px] text-white",children:e.host}),(0,s.jsxs)("div",{className:"mt-1 text-xs text-slate-400",children:[e.ip," \xb7 ",e.platform," \xb7 ",e.version]})]},e.ts))]}),t?(0,s.jsxs)(tn,{icon:e2.A,title:"Last mission",value:t.status,children:[(0,s.jsx)("p",{className:"text-sm text-white",children:t.summary}),(0,s.jsxs)("p",{className:"font-mono text-xs text-slate-500",children:["Run ",t.runId]}),"string"==typeof t.meta?.outputDirRelative?(0,s.jsx)("p",{className:"font-mono text-xs text-slate-400",children:t.meta.outputDirRelative}):null,t.payloads[0]?.text?(0,s.jsx)("div",{className:"rounded-[14px] border border-cyan-400/15 bg-cyan-400/8 px-3 py-2 text-[13px] text-cyan-50",children:t.payloads[0].text}):null]}):null]})}function e9({snapshot:e,workspaceId:t}){let a=e.workspaces.find(e=>e.id===t),r=e.agents.filter(e=>e.workspaceId===t),n=a?a.modelIds.map(t=>e.models.find(e=>e.id===t)?.name||t):[],i=e.runtimes.filter(e=>e.workspaceId===t||a?.activeRuntimeIds.includes(e.id)).sort((e,t)=>(t.updatedAt??0)-(e.updatedAt??0));if(!a)return null;let l=i.filter(e=>"active"===e.status||"queued"===e.status||"idle"===e.status),o=i[0]??null,d=tm(i.flatMap(tp)).slice(0,8),c=a.bootstrap.coreFiles.every(e=>e.present)&&a.bootstrap.projectShell.every(e=>e.present)?"ready":a.bootstrap.coreFiles.some(e=>e.present)||a.bootstrap.projectShell.some(e=>e.present)?"partial":"thin",p=0===r.length?"no agents":a.capabilities.workspaceOnlyAgentCount===r.length?"workspace-only":0===a.capabilities.workspaceOnlyAgentCount?"open":"mixed";return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(tn,{icon:e5.A,title:"Overview",value:a.health,children:[(0,s.jsx)("p",{className:"font-mono text-xs text-slate-400",children:_(a.path)}),(0,s.jsx)(tl,{items:[{label:"Agents",value:String(r.length)},{label:"Models",value:String(a.modelIds.length)},{label:"Runs",value:String(i.length)},{label:"Sessions",value:String(a.totalSessions)}]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"mb-2 text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Models"}),(0,s.jsx)(td,{emptyLabel:"No models attached",items:n,emptyVariant:"muted",itemVariant:"muted"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"mb-2 text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Team"}),(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:r.map(e=>(0,s.jsx)(k,{variant:e.isDefault?"default":"muted",children:e.name},e.id))})]})]}),(0,s.jsxs)(tn,{icon:e2.A,title:"Bootstrap",value:c,children:[(0,s.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,s.jsx)(k,{variant:a.bootstrap.template?"default":"muted",children:a.bootstrap.template||"template unknown"}),(0,s.jsx)(k,{variant:a.bootstrap.sourceMode?"muted":"warning",children:a.bootstrap.sourceMode||"source unknown"}),a.bootstrap.agentTemplate?(0,s.jsx)(k,{variant:"muted",children:a.bootstrap.agentTemplate}):null]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"mb-2 text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Core files"}),(0,s.jsx)(to,{items:a.bootstrap.coreFiles,missingVariant:"warning"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"mb-2 text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Optional scaffold"}),(0,s.jsx)(to,{items:[...a.bootstrap.optionalFiles,...a.bootstrap.folders]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"mb-2 text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Project shell"}),(0,s.jsx)(to,{items:a.bootstrap.projectShell})]})]}),(0,s.jsxs)(tn,{icon:e2.A,title:"Capabilities",value:p,children:[(0,s.jsxs)("p",{children:[a.capabilities.workspaceOnlyAgentCount,"/",r.length," agents are configured with"," ",(0,s.jsx)("span",{className:"font-mono text-xs text-slate-300",children:"fs.workspaceOnly"}),"."]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"mb-2 text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Skills"}),(0,s.jsx)(td,{emptyLabel:"No explicit skills",items:a.capabilities.skills,emptyVariant:"muted",itemVariant:"muted"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"mb-2 text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Local workspace skills"}),(0,s.jsx)(td,{emptyLabel:"No local SKILL.md scaffolds",items:a.bootstrap.localSkillIds,emptyVariant:"muted",itemVariant:"success"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"mb-2 text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Tools"}),(0,s.jsx)(td,{emptyLabel:"No explicit tools",items:a.capabilities.tools,emptyVariant:"muted",itemVariant:"warning"})]})]}),(0,s.jsxs)(tn,{icon:eQ.A,title:"Activity",value:`${l.length} live`,children:[(0,s.jsxs)("p",{children:[i.length," tracked runs across ",a.totalSessions," recorded sessions."]}),(0,s.jsx)("p",{children:o?`Latest update ${C(o.updatedAt)}`:"No runtime activity has been recorded yet."}),i.length>0?(0,s.jsx)("div",{className:"space-y-2 pt-1",children:i.slice(0,3).map(e=>(0,s.jsxs)("div",{className:"flex items-center justify-between rounded-[14px] border border-white/[0.08] bg-[linear-gradient(180deg,rgba(11,18,32,0.86),rgba(8,13,24,0.82))] px-3 py-2",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"truncate text-[13px] text-white",children:e.title}),(0,s.jsxs)("p",{className:"truncate text-[10px] uppercase tracking-[0.18em] text-slate-500",children:[e.subtitle," \xb7 ",$(e.runId||e.id,10)]})]}),(0,s.jsx)(k,{variant:T(e.status),children:e.status})]},e.id))}):null,(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"mb-2 text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Agent posture"}),(0,s.jsx)("div",{className:"space-y-2",children:r.map(e=>(0,s.jsxs)("div",{className:"flex items-center justify-between rounded-[14px] border border-white/[0.08] bg-[linear-gradient(180deg,rgba(11,18,32,0.86),rgba(8,13,24,0.82))] px-3 py-2",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"truncate text-[13px] text-white",children:e.name}),(0,s.jsx)("p",{className:"truncate text-[10px] uppercase tracking-[0.18em] text-slate-500",children:e.currentAction})]}),(0,s.jsx)(k,{variant:"engaged"===e.status?"default":"offline"===e.status?"danger":"muted",children:e.status})]},e.id))})]})]}),(0,s.jsx)(tn,{icon:eY.A,title:"Created files",value:String(d.length),children:(0,s.jsx)(ti,{files:d,emptyLabel:"No file artifacts have been detected in recent workspace runs."})})]})}function e7({snapshot:e,agentId:t}){let a=e.agents.find(e=>e.id===t),r=e.workspaces.find(e=>e.id===a?.workspaceId),n=e.models.find(e=>e.id===a?.modelId),i=e.runtimes.filter(e=>a?.activeRuntimeIds.includes(e.id)).sort((e,t)=>(t.updatedAt??0)-(e.updatedAt??0)),l=tm(i.flatMap(tp)).slice(0,8);return a?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(tn,{icon:e2.A,title:"Agent identity",value:a.id,children:[(0,s.jsx)("p",{children:a.name}),(0,s.jsx)("p",{children:a.identity.emoji?`${a.identity.emoji} \xb7 ${a.identity.theme??"theme unset"}`:"No identity emoji"}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-2",children:[a.isDefault?(0,s.jsx)(k,{variant:"default",children:"default agent"}):null,(0,s.jsx)(k,{variant:eg[a.policy.preset].badgeVariant,children:eN(a.policy.preset)}),a.identity.source?(0,s.jsx)(k,{variant:"muted",children:a.identity.source}):null]})]}),(0,s.jsxs)(tn,{icon:e5.A,title:"Workspace",value:r?.name||"n/a",children:[(0,s.jsx)("p",{className:"font-mono text-xs text-slate-400",children:_(a.workspacePath)}),(0,s.jsxs)("p",{children:[a.sessionCount," recorded sessions"]})]}),(0,s.jsxs)(tn,{icon:e2.A,title:"Model assignment",value:n?.name||a.modelId,children:[(0,s.jsx)("p",{children:n?`${n.provider} \xb7 ${S(n.contextWindow)} ctx`:"Model metadata unavailable"}),(0,s.jsx)("p",{children:n?.available===!1?"Currently unavailable":n?.local?"Local model route":"Remote model route"})]}),(0,s.jsxs)(tn,{icon:e2.A,title:"Agent profile",value:a.profile.purpose||"Profile not declared",children:[(0,s.jsx)("p",{children:a.profile.purpose||"No explicit purpose was found in the workspace bootstrap files."}),(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:a.profile.sourceFiles.length>0?a.profile.sourceFiles.map(e=>(0,s.jsx)(k,{variant:"muted",children:e},e)):(0,s.jsx)(k,{variant:"warning",children:"derived from config"})})]}),(0,s.jsx)(tn,{icon:eQ.A,title:"Operating style",value:`${a.profile.operatingInstructions.length} rules`,children:(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"mb-2 text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Operating instructions"}),(0,s.jsx)(tc,{emptyLabel:"No workspace bootstrap instructions were found.",items:a.profile.operatingInstructions})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"mb-2 text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Response style"}),(0,s.jsx)(td,{emptyLabel:"No explicit response style",items:a.profile.responseStyle,emptyVariant:"muted",itemVariant:"muted"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"mb-1 text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Output preference"}),(0,s.jsx)("p",{children:a.profile.outputPreference||"No explicit output preference was found."})]})]})}),(0,s.jsxs)(tn,{icon:e1.A,title:"Runtime posture",value:a.status,children:[(0,s.jsx)("p",{children:a.currentAction}),(0,s.jsxs)("p",{children:["Last active ",C(a.lastActiveAt)]}),(0,s.jsx)("p",{children:a.heartbeat.enabled?`Heartbeat ${a.heartbeat.every}`:"Heartbeat disabled"}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,s.jsx)(k,{variant:a.heartbeat.enabled?"success":"muted",children:a.heartbeat.enabled?"heartbeat on":"heartbeat off"}),"number"==typeof a.heartbeat.everyMs?(0,s.jsxs)(k,{variant:"muted",children:[Math.round(a.heartbeat.everyMs/1e3),"s interval"]}):null]})]}),(0,s.jsxs)(tn,{icon:eQ.A,title:"Operating policy",value:eN(a.policy.preset),children:[(0,s.jsx)("p",{children:eg[a.policy.preset].description}),(0,s.jsxs)("div",{className:"mt-3 grid gap-2 text-[13px] text-slate-300",children:[(0,s.jsxs)("p",{children:["Missing tools: ",(0,s.jsx)("span",{className:"text-white",children:eC(a.policy.missingToolBehavior)})]}),(0,s.jsxs)("p",{children:["Install scope: ",(0,s.jsx)("span",{className:"text-white",children:eS(a.policy.installScope)})]}),(0,s.jsxs)("p",{children:["File access: ",(0,s.jsx)("span",{className:"text-white",children:eA(a.policy.fileAccess)})]}),(0,s.jsxs)("p",{children:["Network: ",(0,s.jsx)("span",{className:"text-white",children:eI(a.policy.networkAccess)})]})]})]}),(0,s.jsxs)(tn,{icon:eQ.A,title:"Run history",value:String(i.length),children:[0===i.length?(0,s.jsx)("p",{children:"No runtime history has been recorded for this agent yet."}):null,i.map(e=>(0,s.jsxs)("div",{className:"flex items-center justify-between rounded-[14px] border border-white/[0.08] bg-[linear-gradient(180deg,rgba(11,18,32,0.86),rgba(8,13,24,0.82))] px-3 py-2",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"truncate text-[13px] text-white",children:e.title}),(0,s.jsx)("p",{className:"truncate text-[10px] uppercase tracking-[0.18em] text-slate-500",children:e.subtitle})]}),(0,s.jsx)(k,{variant:T(e.status),children:e.status})]},e.id))]}),(0,s.jsx)(tn,{icon:eY.A,title:"Created files",value:String(l.length),children:(0,s.jsx)(ti,{files:l,emptyLabel:"No file artifacts have been detected for this agent yet."})}),(0,s.jsxs)(tn,{icon:e2.A,title:"Capabilities",value:`${a.skills.length} skills`,children:[(0,s.jsx)(td,{emptyLabel:"No explicit skills",items:a.skills,emptyVariant:"muted",itemVariant:"muted"}),(0,s.jsxs)("div",{className:"pt-1",children:[(0,s.jsx)("p",{className:"mb-2 text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Tools"}),(0,s.jsx)(td,{emptyLabel:"No explicit tools",items:a.tools,emptyVariant:"muted",itemVariant:"warning"})]})]})]}):null}function te({snapshot:e,runtimeId:t,runtimeOutput:a,runtimeOutputLoading:r,runtimeOutputError:n}){let i,l=e.runtimes.find(e=>e.id===t),o=tm(a?.createdFiles??(l?tp(l):[])),d=a?.warnings??(l&&Array.isArray(i=l.metadata.warnings)?i.filter(e=>"string"==typeof e&&e.trim().length>0):[]),c=a?.warningSummary??d[0]??null;return l?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(tn,{icon:eQ.A,title:"Runtime key",value:l.status,children:[(0,s.jsx)("p",{className:"font-mono text-xs text-slate-400",children:l.key}),(0,s.jsxs)("p",{children:["Session ",$(l.sessionId,12)]}),l.taskId?(0,s.jsxs)("p",{children:["Task ",$(l.taskId,12)]}):null,l.runId?(0,s.jsxs)("p",{children:["Run ",$(l.runId,12)]}):null]}),(0,s.jsxs)(tn,{icon:e1.A,title:"Activity",value:C(l.updatedAt),children:[(0,s.jsx)("p",{children:l.subtitle}),(0,s.jsxs)("p",{children:[A(l.tokenUsage?.total)," tokens"]})]}),(0,s.jsxs)(tn,{icon:e2.A,title:"Latest output",value:a?.stopReason||(r?"loading":"no transcript"),children:[r?(0,s.jsx)("p",{children:"Loading transcript output…"}):null,n?(0,s.jsx)("p",{children:n}):null,r||n?null:(0,s.jsx)("p",{className:"whitespace-pre-wrap text-[13px] leading-5 text-slate-100",children:a?.finalText||a?.errorMessage||"No assistant output has been recorded for this runtime yet."}),c?(0,s.jsxs)("p",{className:"mt-3 rounded-[12px] border border-amber-400/20 bg-amber-400/10 px-3 py-2 text-[12px] leading-5 text-amber-100",children:["Fallback used: ",c]}):null,a?.finalTimestamp?(0,s.jsxs)("p",{className:"text-[11px] uppercase tracking-[0.18em] text-slate-500",children:["Updated ",C(new Date(a.finalTimestamp).getTime())]}):null]}),(0,s.jsx)(tn,{icon:eY.A,title:"Created files",value:String(o.length),children:(0,s.jsx)(ti,{files:o,emptyLabel:"This runtime has not produced a detectable file artifact."})})]}):null}function tt({runtime:e,runtimeOutput:t,runtimeOutputLoading:a,runtimeOutputError:r}){return a?(0,s.jsx)(tn,{icon:eQ.A,title:"Runtime output",value:"loading",children:(0,s.jsxs)("p",{children:["Loading transcript output for ",e.title,"…"]})}):r?(0,s.jsx)(tn,{icon:eQ.A,title:"Runtime output",value:"error",children:(0,s.jsx)("p",{children:r})}):t?(0,s.jsxs)("div",{className:"space-y-3.5",children:[t.warningSummary?(0,s.jsx)(tn,{icon:e1.A,title:"Warnings",value:String(t.warnings.length),children:(0,s.jsx)("p",{children:t.warningSummary})}):null,(0,s.jsx)(tn,{icon:eY.A,title:"Created files",value:String(t.createdFiles.length),children:(0,s.jsx)(ti,{files:t.createdFiles,emptyLabel:"This runtime transcript does not include a successful file creation."})}),(0,s.jsxs)(tn,{icon:eQ.A,title:"Final response",value:t.stopReason||t.status,children:[(0,s.jsx)("p",{className:"whitespace-pre-wrap text-[13px] leading-5 text-slate-100",children:t.finalText||t.errorMessage||"No assistant output has been recorded for this runtime yet."}),t.finalTimestamp?(0,s.jsx)("p",{className:"text-[11px] uppercase tracking-[0.18em] text-slate-500",children:new Date(t.finalTimestamp).toLocaleString()}):null]}),(0,s.jsxs)(tn,{icon:e1.A,title:"Transcript trail",value:String(t.items.length),children:[0===t.items.length?(0,s.jsx)("p",{children:"No transcript entries were found."}):null,(0,s.jsx)("div",{className:"space-y-2",children:t.items.map(e=>(0,s.jsxs)("div",{className:"rounded-[14px] border border-white/[0.08] bg-[linear-gradient(180deg,rgba(11,18,32,0.86),rgba(8,13,24,0.82))] px-3 py-2.5",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(k,{variant:"assistant"===e.role?e.isError?"danger":"default":"toolResult"===e.role?"warning":"muted",children:e.role}),e.toolName?(0,s.jsx)(k,{variant:"muted",children:e.toolName}):null]}),(0,s.jsx)("span",{className:"text-[10px] uppercase tracking-[0.18em] text-slate-500",children:C(new Date(e.timestamp).getTime())})]}),(0,s.jsx)("p",{className:"mt-2 whitespace-pre-wrap text-[12.5px] leading-5 text-slate-100",children:e.text})]},e.id))})]})]}):(0,s.jsx)(tn,{icon:eQ.A,title:"Runtime output",value:"missing",children:(0,s.jsx)("p",{children:"No transcript data is available for this runtime."})})}function ta({snapshot:e,modelId:t}){let a=e.models.find(e=>e.id===t);return a?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(tn,{icon:e2.A,title:"Model routing",value:a.provider,children:[(0,s.jsx)("p",{children:a.name}),(0,s.jsx)("p",{children:a.local?"Local model":"Remote model"})]}),(0,s.jsxs)(tn,{icon:e1.A,title:"Capacity",value:`${S(a.contextWindow)} ctx`,children:[(0,s.jsx)("p",{children:a.input}),(0,s.jsx)("p",{children:!1===a.available?"Unavailable":"Available"}),(0,s.jsxs)("p",{children:[a.usageCount," attached agents"]})]})]}):null}function ts({icon:e,label:t,active:a,disabled:r=!1,onClick:n}){return(0,s.jsx)("button",{type:"button",title:t,disabled:r,onClick:n,className:w("inline-flex h-11 w-11 items-center justify-center rounded-[16px] border transition-all",r?"border-white/5 bg-white/[0.02] text-slate-600":a?"border-cyan-300/20 bg-cyan-400 text-slate-950 shadow-[0_12px_28px_rgba(96,165,250,0.35)]":"border-white/10 bg-white/[0.03] text-slate-400 hover:border-white/15 hover:bg-white/[0.08] hover:text-white"),children:(0,s.jsx)(e,{className:"h-4 w-4"})})}function tr({label:e,active:t,onClick:a}){return(0,s.jsx)("button",{type:"button",onClick:a,className:w("inline-flex items-center rounded-full border px-3 py-2 text-[11px] uppercase tracking-[0.18em] transition-all",t?"border-cyan-300/20 bg-cyan-400 text-slate-950 shadow-[0_10px_24px_rgba(96,165,250,0.28)]":"border-white/[0.08] bg-white/[0.03] text-slate-300 hover:bg-white/[0.07] hover:text-white"),children:e})}function tn({icon:e,title:t,value:a,children:r}){return(0,s.jsxs)("section",{className:"rounded-[18px] border border-white/[0.08] bg-[linear-gradient(180deg,rgba(12,19,34,0.86),rgba(8,13,24,0.82))] p-3.5",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-[0.24em] text-slate-500",children:t}),(0,s.jsx)("p",{className:"font-display text-[1rem] text-white",children:a})]}),(0,s.jsx)("div",{className:"rounded-[14px] border border-white/[0.08] bg-white/5 p-2 text-slate-300",children:(0,s.jsx)(e,{className:"h-3.5 w-3.5"})})]}),(0,s.jsx)("div",{className:"mt-3 space-y-1.5 text-[12.5px] leading-5 text-slate-300",children:r})]})}function ti({files:e,emptyLabel:t}){return 0===e.length?(0,s.jsx)("p",{className:"text-[12px] text-slate-400",children:t}):(0,s.jsx)("div",{className:"space-y-2",children:e.map(e=>(0,s.jsx)("button",{type:"button",onClick:()=>void tu(e.path),className:"w-full rounded-[14px] border border-cyan-300/12 bg-[linear-gradient(180deg,rgba(11,18,32,0.86),rgba(8,13,24,0.82))] px-3 py-2 text-left transition-all hover:border-cyan-300/28 hover:bg-cyan-400/[0.08]",children:(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"truncate font-mono text-[12px] text-cyan-100",children:e.displayPath}),(0,s.jsx)("p",{className:"truncate text-[11px] text-slate-400",children:_(e.path)})]}),(0,s.jsx)(k,{variant:"muted",children:"reveal"})]})},e.path))})}function tl({items:e}){return(0,s.jsx)("div",{className:"grid grid-cols-2 gap-2",children:e.map(e=>(0,s.jsxs)("div",{className:"rounded-[14px] border border-white/[0.08] bg-[linear-gradient(180deg,rgba(11,18,32,0.86),rgba(8,13,24,0.82))] px-3 py-2",children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-[0.18em] text-slate-500",children:e.label}),(0,s.jsx)("p",{className:"mt-1 text-[13px] text-white",children:e.value})]},e.label))})}function to({items:e,missingVariant:t="muted"}){return(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:e.map(e=>(0,s.jsx)(k,{variant:e.present?"success":t,children:e.label},e.id))})}function td({items:e,emptyLabel:t,itemVariant:a,emptyVariant:r}){return 0===e.length?(0,s.jsx)(k,{variant:r,children:t}):(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:e.map(e=>(0,s.jsx)(k,{variant:a,children:e},e))})}function tc({items:e,emptyLabel:t}){return 0===e.length?(0,s.jsx)("p",{className:"text-[12px] text-slate-400",children:t}):(0,s.jsx)("div",{className:"space-y-2",children:e.map(e=>(0,s.jsx)("div",{className:"rounded-[14px] border border-white/[0.08] bg-[linear-gradient(180deg,rgba(11,18,32,0.86),rgba(8,13,24,0.82))] px-3 py-2",children:(0,s.jsx)("p",{className:"text-[12px] leading-5 text-slate-200",children:e})},e))})}function tp(e){let t=e.metadata.createdFiles;return Array.isArray(t)?t.flatMap(e=>{if(!e||"object"!=typeof e)return[];let t="path"in e&&"string"==typeof e.path?e.path:null,a="displayPath"in e&&"string"==typeof e.displayPath?e.displayPath:t;return t&&a?[{path:t,displayPath:a}]:[]}):[]}function tm(e){let t=new Set,a=[];for(let s of e)!s.path||t.has(s.path)||(t.add(s.path),a.push(s));return a}async function tu(e){try{let t=await fetch("/api/files/reveal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})}),a=await t.json();if(!t.ok)throw Error(a.error||"Unable to reveal file.");e3.oR.success("Revealed file.",{description:_(e)})}catch(e){e3.oR.error("Could not reveal file.",{description:e instanceof Error?e.message:"Unknown file reveal error."})}}var th=a(7111),tx=a(144),tg=a(4545);function tb({snapshot:e,surfaceTheme:t,stage:a,systemActionLabel:r,systemActionDescription:n,systemPhase:l,modelPhase:o,systemRun:d,modelRun:c,selectedModelId:p,discoveredModels:m,onSelectedModelIdChange:u,onRunSystemSetup:h,onRunModelAutoSetup:x,onRunModelDiscover:b,onRunModelRefresh:f,onRunModelSetDefault:y,onContinueToModels:v,onBackToSystem:j,onDismiss:k,canDismiss:N}){var C,S,A,I,T,$,_,O,R,M,P,E,L,U,z,F,W;let B,V,q,K,J=e.diagnostics.installed&&e.diagnostics.rpcOk,G=J&&e.diagnostics.modelReadiness.ready,H=(C=a,S=J,A=G,[{id:"system",order:1,label:"System setup",description:"CLI, gateway service, live RPC",state:tj(S,"system"===C&&!S)},{id:"models",order:2,label:"Model setup",description:"Default model, provider auth, usable route",state:tj(A,"models"===C&&!A)}]),Z=(I=e,T=l,B=I.diagnostics.rpcOk&&!I.diagnostics.loaded,V=I.diagnostics.installed||"installing-gateway"===T||"starting-gateway"===T||"verifying"===T||"ready"===T,q=I.diagnostics.loaded||B||"starting-gateway"===T||"verifying"===T||"ready"===T,K=I.diagnostics.rpcOk||"ready"===T,[{id:"cli",label:"OpenClaw CLI",description:I.diagnostics.installed?`Installed${I.diagnostics.version?` \xb7 v${I.diagnostics.version}`:""}`:"Install the OpenClaw CLI on this machine.",state:tj(V,!V&&("detecting"===T||"installing-cli"===T))},{id:"gateway",label:"Gateway service",description:I.diagnostics.loaded?"The local gateway service is already registered on this machine.":B?"Gateway is live via direct run.":"Register the gateway service once so Mission Control can start it reliably.",state:tj(q,!q&&("installing-gateway"===T||V&&"detecting"===T))},{id:"runtime",label:"Live connection",description:I.diagnostics.rpcOk?"Mission Control is connected to a live OpenClaw gateway.":"Start the gateway and wait for RPC health to turn online.",state:tj(K,!K&&("starting-gateway"===T||"verifying"===T||q&&"detecting"===T))}]),Q=e.models.filter(e=>!1!==e.available&&!e.missing),Y=m.filter(e=>!Q.some(t=>t.id===e.modelId)),X="system"===a?d:c,et=X.statusMessage||X.resultMessage||($=a,_=n,"system"===$?_:"Choose or connect a usable model route so the product is actually ready."),ea="system"===a?(O=l,(R=e).diagnostics.rpcOk?"ready":R.diagnostics.loaded&&!R.diagnostics.rpcOk?"verifying"===O?"connecting":"starting gateway":O?O.replace("-"," "):"waiting"):(M=o,e.diagnostics.modelReadiness.ready?"ready":M?M.replace("-"," "):"waiting"),es="idle"!==X.runState||!!X.manualCommand||X.log.trim().length>0,er=(P=X.runState,E=a,L=G,"running"===P?"Running":L?"Ready":"success"===P?"models"===E?"Updated":"Step complete":"error"===P?"Needs attention":"system"===E?"Step 1":"Step 2"),en="system"===(U={stage:a,systemReady:J,modelReady:G,systemActionLabel:r,selectedModelId:p,availableModelIds:Q.map(e=>e.id)}).stage?U.systemReady&&U.modelReady?{kind:"dismiss",label:"Enter Mission Control"}:U.systemReady?{kind:"continue",label:"Continue to model setup"}:{kind:"system",label:U.systemActionLabel}:U.modelReady?{kind:"dismiss",label:"Enter Mission Control"}:U.selectedModelId&&U.availableModelIds.includes(U.selectedModelId)||U.selectedModelId?{kind:"set-default",label:"Use selected model"}:{kind:"auto",label:"Auto configure models"};return(0,s.jsx)(g.P.div,{initial:{opacity:0,backdropFilter:"blur(0px)"},animate:{opacity:1,backdropFilter:"blur(12px)"},exit:{opacity:0,backdropFilter:"blur(0px)"},className:w("absolute inset-0 z-[80] pointer-events-auto flex items-center justify-center overflow-y-auto px-3 py-4 sm:px-4 sm:py-6","light"===t?"bg-[radial-gradient(circle_at_top,rgba(255,255,255,0.94),rgba(247,239,232,0.88)_46%,rgba(242,230,220,0.92))]":"bg-[radial-gradient(circle_at_top,rgba(17,24,39,0.9),rgba(3,7,18,0.92)_48%,rgba(2,6,23,0.96))]"),children:(0,s.jsxs)(g.P.div,{initial:{opacity:0,y:18,scale:.985},animate:{opacity:1,y:0,scale:1},className:w("my-auto flex w-full max-w-[420px] flex-col overflow-hidden rounded-[16px] border shadow-[0_18px_46px_rgba(0,0,0,0.18)] backdrop-blur-2xl max-h-[min(80vh,560px)]","light"===t?"border-[#dccabd]/90 bg-[rgba(255,250,246,0.92)] text-[#47362b] shadow-[0_18px_50px_rgba(161,125,101,0.15)]":"border-white/10 bg-[rgba(6,10,18,0.84)] text-slate-100"),children:[(0,s.jsxs)("div",{className:"overflow-y-auto px-2.5 py-2.5 sm:px-3 sm:py-3",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,s.jsxs)("span",{className:w("inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[8px] uppercase tracking-[0.18em]","light"===t?"border-[#d8c0b0] bg-[#f3e7dc] text-[#8d725f]":"border-white/10 bg-white/[0.06] text-slate-300"),children:[(0,s.jsx)(D.A,{className:"h-2 w-2"}),"Welcome"]}),(0,s.jsx)("span",{className:w("rounded-full border px-1.5 py-0.5 text-[8px] uppercase tracking-[0.16em]",(z=X.runState,F=G,W=t,"error"===z?"light"===W?"border-rose-300 bg-rose-50 text-rose-700":"border-rose-300/25 bg-rose-300/10 text-rose-200":"success"===z||F?"light"===W?"border-emerald-300 bg-emerald-50 text-emerald-700":"border-emerald-300/25 bg-emerald-300/10 text-emerald-200":"running"===z?"light"===W?"border-[#d8c0b0] bg-white/80 text-[#8d725f]":"border-white/10 bg-white/[0.04] text-slate-300":"light"===W?"border-[#d8c0b0] bg-white/80 text-[#8d725f]":"border-white/10 bg-white/[0.04] text-slate-400")),children:er})]}),(0,s.jsxs)("div",{className:"mt-3",children:[(0,s.jsx)("p",{className:w("text-[7px] uppercase tracking-[0.18em]","light"===t?"text-[#977b69]":"text-slate-500"),children:"OpenClaw Mission Control"}),(0,s.jsx)("h1",{className:w("mt-1 font-display text-[1.12rem] leading-[1.25rem]","light"===t?"text-[#33251c]":"text-white"),children:"Bring your local OpenClaw online."}),(0,s.jsx)("p",{className:w("mt-1.5 text-[11px] leading-[1.05rem]","light"===t?"text-[#705b4d]":"text-slate-300"),children:"Finish the system layer first, then lock a usable default model so the product is ready for real work."})]}),(0,s.jsx)("div",{className:"mt-3 grid gap-1.5 sm:grid-cols-2",children:H.map(e=>(0,s.jsx)("div",{className:w("rounded-[14px] border px-2.5 py-2",tC(e.state,t)),children:(0,s.jsxs)("div",{className:"flex items-center justify-between gap-1.5",children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,s.jsx)("span",{className:w("inline-flex h-5 w-5 items-center justify-center rounded-full border text-[9px] font-medium",tS(e.state,t)),children:"complete"===e.state?(0,s.jsx)(th.A,{className:"h-2.5 w-2.5"}):e.order}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:w("text-[11px]","light"===t?"text-[#3e2f24]":"text-white"),children:e.label}),(0,s.jsx)("p",{className:w("mt-0.5 text-[8px] leading-[0.85rem]","light"===t?"text-[#8f7664]":"text-slate-500"),children:e.description})]})]}),(0,s.jsx)("span",{className:w("rounded-full px-1.5 py-0.5 text-[6px] uppercase tracking-[0.14em]",tA(e.state,t)),children:"complete"===e.state?"Ready":"current"===e.state?"Active":"Pending"})]})},e.id))}),"system"===a?(0,s.jsx)(tf,{steps:Z,surfaceTheme:t,statusCopy:et,showDetails:es,phaseLabel:ea,run:X}):(0,s.jsx)(tw,{snapshot:e,surfaceTheme:t,statusCopy:et,showDetails:es,phaseLabel:ea,run:X,selectedModelId:p,availableModels:Q.map(e=>({id:e.id,name:e.name,provider:e.provider})),discoveredModels:Y,onSelectedModelIdChange:u,onRunModelDiscover:b,onRunModelRefresh:f,onRunModelSetDefault:y})]}),(0,s.jsxs)("div",{className:w("mt-auto flex flex-wrap items-center justify-between gap-1.5 border-t px-2.5 py-2 sm:px-3","light"===t?"border-[#ebddd2]":"border-white/8"),children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:["models"===a?(0,s.jsxs)(ee,{type:"button",variant:"ghost",size:"sm",onClick:j,disabled:"running"===X.runState,className:"light"===t?"border border-[#d7bca7] bg-[#f8ede4] text-[#5a4131] hover:bg-[#eedbcc] hover:text-[#3f2d21]":"text-slate-500 hover:bg-white/[0.08] hover:text-slate-200",children:[(0,s.jsx)(tx.A,{className:"mr-1.5 h-3.5 w-3.5"}),"Back"]}):null,N?(0,s.jsx)("button",{type:"button",onClick:k,className:w("text-[9px] uppercase tracking-[0.16em] transition-colors","light"===t?"text-[#8f7664] hover:text-[#6f5949]":"text-slate-500 hover:text-slate-300"),children:"Open demo surface"}):null]}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:["models"!==a||G?null:(0,s.jsx)(ee,{type:"button",variant:"secondary",size:"sm",onClick:x,disabled:"running"===c.runState,className:tk(t),children:"running"===c.runState?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.A,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}),"Working..."]}):"Auto configure"}),(0,s.jsx)(ee,{type:"button",onClick:()=>{"system"===a?J&&G?k():J?v():h():G?k():"set-default"===en.kind?y():x()},disabled:"running"===X.runState,className:w("h-8 min-w-[156px] rounded-full px-3 text-[11px]","light"===t?"bg-[#c8946f] text-white shadow-[0_14px_34px_rgba(200,148,111,0.24)] hover:bg-[#b88461]":"bg-white text-slate-950 hover:bg-white/92"),children:"running"===X.runState?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.A,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Working..."]}):(0,s.jsxs)(s.Fragment,{children:[en.label,(0,s.jsx)(tg.A,{className:"ml-1.5 h-3 w-3"})]})})]})]})]})})}function tf({steps:e,surfaceTheme:t,statusCopy:a,showDetails:r,phaseLabel:n,run:i}){return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"mt-3",children:[(0,s.jsx)("p",{className:w("text-[7px] uppercase tracking-[0.18em]","light"===t?"text-[#977b69]":"text-slate-500"),children:"Step 1"}),(0,s.jsx)("h2",{className:w("mt-1 text-[13px] font-medium","light"===t?"text-[#33251c]":"text-white"),children:"System setup"}),(0,s.jsx)("p",{className:w("mt-1 text-[10px] leading-[0.95rem]","light"===t?"text-[#705b4d]":"text-slate-400"),children:"Install the CLI if needed, make sure the gateway service exists, and verify a live RPC connection."})]}),(0,s.jsx)("div",{className:"mt-2.5 space-y-1.5",children:e.map((e,a)=>(0,s.jsxs)("div",{className:w("flex items-center gap-1.5 rounded-[12px] border px-2 py-1.5",tC(e.state,t)),children:[(0,s.jsx)("span",{className:w("mt-0.5 inline-flex h-5 w-5 items-center justify-center rounded-full border text-[9px] font-medium",tS(e.state,t)),children:"complete"===e.state?(0,s.jsx)(th.A,{className:"h-2.5 w-2.5"}):a+1}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-1.5",children:[(0,s.jsx)("p",{className:w("text-[11px]","light"===t?"text-[#3e2f24]":"text-white"),children:e.label}),(0,s.jsx)("span",{className:w("rounded-full px-1.5 py-0.5 text-[6px] uppercase tracking-[0.14em]",tA(e.state,t)),children:"complete"===e.state?"Ready":"current"===e.state?"Active":"Pending"})]}),(0,s.jsx)("p",{className:w("mt-0.5 text-[8px] leading-[0.82rem]","light"===t?"text-[#8f7664]":"text-slate-500"),children:e.description})]})]},e.id))}),(0,s.jsx)(ty,{surfaceTheme:t,statusCopy:a,showDetails:r,phaseLabel:n,run:i})]})}function tw({snapshot:e,surfaceTheme:t,statusCopy:a,showDetails:r,phaseLabel:n,run:i,selectedModelId:l,availableModels:o,discoveredModels:d,onSelectedModelIdChange:c,onRunModelDiscover:m,onRunModelRefresh:u,onRunModelSetDefault:h}){let x=e.diagnostics.modelReadiness;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"mt-3",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:w("text-[7px] uppercase tracking-[0.18em]","light"===t?"text-[#977b69]":"text-slate-500"),children:"Step 2"}),(0,s.jsx)("h2",{className:w("mt-1 text-[13px] font-medium","light"===t?"text-[#33251c]":"text-white"),children:"Model setup"})]}),(0,s.jsxs)(ee,{type:"button",variant:"secondary",size:"sm",onClick:u,disabled:"running"===i.runState,className:tk(t),children:[(0,s.jsx)(p.A,{className:"mr-1.5 h-3.5 w-3.5"}),"Refresh"]})]}),(0,s.jsx)("p",{className:w("mt-1 text-[10px] leading-[0.95rem]","light"===t?"text-[#705b4d]":"text-slate-400"),children:"Lock a usable default model before handing the user into the live product."})]}),(0,s.jsxs)("div",{className:"mt-2.5 grid gap-1.5 sm:grid-cols-3",children:[(0,s.jsx)(tv,{surfaceTheme:t,label:"Default model",value:x.resolvedDefaultModel||x.defaultModel||"Not set"}),(0,s.jsx)(tv,{surfaceTheme:t,label:"Available routes",value:`${x.availableModelCount}/${x.totalModelCount}`}),(0,s.jsx)(tv,{surfaceTheme:t,label:"Connected providers",value:String(x.authProviders.filter(e=>e.connected).length)})]}),(0,s.jsxs)("div",{className:w("mt-2.5 rounded-[12px] border px-2.5 py-2.5","light"===t?"border-[#e5d5c9] bg-[#fffaf6]":"border-white/8 bg-[rgba(255,255,255,0.02)]"),children:[(0,s.jsxs)("div",{className:"grid gap-2.5 sm:grid-cols-[minmax(0,1fr)_auto] sm:items-end",children:[(0,s.jsxs)("label",{className:"block",children:[(0,s.jsx)("span",{className:w("text-[7px] uppercase tracking-[0.16em]","light"===t?"text-[#977b69]":"text-slate-500"),children:"Default model"}),(0,s.jsxs)("select",{value:l,onChange:e=>c(e.target.value),className:w("mt-1.5 h-9 w-full rounded-[12px] border px-2.5 text-[11px] outline-none","light"===t?"border-[#dccabd] bg-white text-[#33251c]":"border-white/10 bg-white/[0.04] text-slate-100"),children:[(0,s.jsx)("option",{value:"",children:"Auto choose"}),o.map(e=>(0,s.jsxs)("option",{value:e.id,children:[e.name," \xb7 ",e.provider]},e.id))]})]}),(0,s.jsxs)("div",{className:w("rounded-[12px] border px-2.5 py-1.5 text-[10px]","light"===t?"border-[#eadcd0] bg-[#fff7f2] text-[#705b4d]":"border-white/10 bg-white/[0.03] text-slate-400"),children:[x.localModelCount," local \xb7 ",x.remoteModelCount," remote"]})]}),(0,s.jsx)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:(0,s.jsx)(ee,{type:"button",variant:"secondary",size:"sm",onClick:m,disabled:"running"===i.runState,className:tk(t),children:d.length>0?"Scan again":"Discover models"})}),x.issues.length>0?(0,s.jsx)("div",{className:"mt-2.5 space-y-1",children:x.issues.map(e=>(0,s.jsx)("p",{className:w("rounded-[10px] border px-2 py-1.5 text-[9px] leading-[0.85rem]","light"===t?"border-amber-200 bg-amber-50 text-amber-800":"border-amber-300/20 bg-amber-300/10 text-amber-100"),children:e},e))}):null,e.diagnostics.modelReadiness.authProviders.length>0?(0,s.jsx)("div",{className:"mt-2.5 flex flex-wrap gap-1.5",children:e.diagnostics.modelReadiness.authProviders.map(e=>(0,s.jsxs)("span",{className:w("rounded-full border px-2 py-0.5 text-[9px]",e.connected?"light"===t?"border-emerald-200 bg-emerald-50 text-emerald-700":"border-emerald-300/20 bg-emerald-300/10 text-emerald-200":"light"===t?"border-[#dccabd] bg-white text-[#705b4d]":"border-white/10 bg-white/[0.04] text-slate-300"),children:[tN(e.provider),e.detail?` \xb7 ${e.detail}`:""]},e.provider))}):null,d.length>0?(0,s.jsxs)("div",{className:"mt-2.5 space-y-1.5",children:[(0,s.jsx)("p",{className:w("text-[7px] uppercase tracking-[0.16em]","light"===t?"text-[#977b69]":"text-slate-500"),children:"Discovered routes"}),(0,s.jsx)("div",{className:"space-y-1.5",children:d.slice(0,3).map(e=>(0,s.jsxs)("div",{className:w("flex items-center justify-between gap-2 rounded-[12px] border px-2 py-1.5","light"===t?"border-[#eadcd0] bg-[#fff7f2]":"border-white/10 bg-white/[0.03]"),children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:w("truncate text-[10px]","light"===t?"text-[#3e2f24]":"text-white"),children:e.name}),(0,s.jsxs)("p",{className:w("mt-0.5 text-[8px] leading-[0.85rem]","light"===t?"text-[#8f7664]":"text-slate-500"),children:[tN(e.provider),e.isFree?" \xb7 free":"",e.supportsTools?" \xb7 tools":""]})]}),(0,s.jsx)(ee,{type:"button",variant:"secondary",size:"sm",onClick:()=>h(e.modelId),disabled:"running"===i.runState,className:tk(t),children:"Use"})]},e.modelId))}),(0,s.jsx)("p",{className:w("text-[9px] leading-[0.95rem]","light"===t?"text-[#705b4d]":"text-slate-500"),children:"The dropdown only shows routes that are already configured. Use a discovered route here to add it first; if credentials are missing, Mission Control will hand you off to OpenClaw."})]}):null]}),(0,s.jsx)(ty,{surfaceTheme:t,statusCopy:a,showDetails:r,phaseLabel:n,run:i})]})}function ty({surfaceTheme:e,statusCopy:t,showDetails:a,phaseLabel:r,run:n}){let[l,o]=(0,m.useState)(!1),d=!!n.manualCommand?.trim().startsWith("openclaw "),c=async()=>{if(n.manualCommand)try{await navigator.clipboard.writeText(n.manualCommand),ex.o.success("Command copied.",{description:"Open Terminal and paste the command to continue setup."})}catch(e){ex.o.error("Could not copy command.",{description:e instanceof Error?e.message:"Clipboard access is unavailable."})}},p=async()=>{if(n.manualCommand&&d){o(!0);try{let e=await fetch("/api/system/open-terminal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:n.manualCommand})}),t=await e.json().catch(()=>null);if(!e.ok||t?.error)throw Error(t?.error||"Unable to open Terminal.");ex.o.success("Terminal opened.",{description:"Finish the OpenClaw auth flow there, then return and refresh setup."})}catch(e){ex.o.error("Could not open Terminal.",{description:e instanceof Error?e.message:"Open Terminal manually and run the command below."})}finally{o(!1)}}};return(0,s.jsxs)("div",{className:w("mt-2.5 rounded-[12px] border","light"===e?"border-[#e5d5c9] bg-[#fffaf6]":"border-white/8 bg-[rgba(255,255,255,0.02)]"),children:[(0,s.jsxs)("div",{className:"px-2.5 py-2",children:[(0,s.jsx)("p",{className:w("text-[7px] uppercase tracking-[0.16em]","light"===e?"text-[#977b69]":"text-slate-500"),children:"Current status"}),(0,s.jsx)("p",{className:w("mt-1 text-[11px] leading-[1rem]","light"===e?"text-[#5f4b3e]":"text-slate-300"),children:t})]}),a?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:w("flex items-center justify-between border-y px-2.5 py-1.5","light"===e?"border-[#ebddd2]":"border-white/8"),children:[(0,s.jsx)("p",{className:w("text-[8px] uppercase tracking-[0.16em]","light"===e?"text-[#977b69]":"text-slate-500"),children:"Setup log"}),(0,s.jsx)("span",{className:"light"===e?"text-[10px] text-[#8c7362]":"text-[10px] text-slate-400",children:r})]}),(0,s.jsx)("pre",{className:w("max-h-[120px] min-h-[68px] overflow-auto whitespace-pre-wrap break-words px-2.5 py-2 font-mono text-[8px] leading-[0.82rem]","light"===e?"text-[#4f3d31]":"text-slate-200"),children:n.log||"No command output yet.\n\nStart this step and Mission Control will stream each action here."}),n.manualCommand?(0,s.jsxs)("div",{className:w("border-t px-2.5 py-2","light"===e?"border-[#ebddd2]":"border-white/8"),children:[(0,s.jsx)("p",{className:w("text-[8px] uppercase tracking-[0.16em]","light"===e?"text-[#977b69]":"text-slate-500"),children:d?"Run in terminal":"Manual fallback"}),d?(0,s.jsx)("p",{className:w("mt-1 text-[9px] leading-[0.95rem]","light"===e?"text-[#705b4d]":"text-slate-400"),children:"Open Terminal and run this command to continue setup."}):null,(0,s.jsx)("p",{className:w("mt-1 break-all font-mono text-[9px] leading-[0.92rem]","light"===e?"text-[#4f3d31]":"text-slate-200"),children:n.manualCommand}),(0,s.jsxs)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[(0,s.jsxs)(ee,{type:"button",variant:"secondary",size:"sm",onClick:c,className:tk(e),children:[(0,s.jsx)(P.A,{className:"mr-1.5 h-3 w-3"}),"Copy command"]}),d?(0,s.jsx)(ee,{type:"button",variant:"secondary",size:"sm",onClick:p,disabled:l,className:tk(e),children:l?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.A,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Opening..."]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(eQ.A,{className:"mr-1.5 h-3 w-3"}),"Open Terminal"]})}):null]}),n.docsUrl?(0,s.jsxs)("a",{href:n.docsUrl,target:"_blank",rel:"noreferrer",className:w("mt-2 inline-flex items-center gap-1 text-[9px] underline underline-offset-4","light"===e?"text-[#7f6554]":"text-slate-300"),children:["Setup docs",(0,s.jsx)(tg.A,{className:"h-2.5 w-2.5"})]}):null]}):null]}):null]})}function tv({surfaceTheme:e,label:t,value:a}){return(0,s.jsxs)("div",{className:w("rounded-[12px] border px-2.5 py-2","light"===e?"border-[#e5d5c9] bg-[#fffaf6]":"border-white/8 bg-[rgba(255,255,255,0.02)]"),children:[(0,s.jsx)("p",{className:w("text-[7px] uppercase tracking-[0.16em]","light"===e?"text-[#977b69]":"text-slate-500"),children:t}),(0,s.jsx)("p",{className:w("mt-1 text-[11px] leading-[0.92rem]","light"===e?"text-[#3e2f24]":"text-white"),children:a})]})}function tj(e,t){return e?"complete":t?"current":"pending"}function tk(e){return"light"===e?"border-[#b89374] bg-[#ecd4c1] text-[#4a3426] shadow-[inset_0_1px_0_rgba(255,255,255,0.55)] hover:bg-[#e4c6af] hover:text-[#38261b]":"border-white/10 bg-white/[0.05] text-slate-200 hover:bg-white/[0.1]"}function tN(e){let t=e.trim().toLowerCase();return"openrouter"===t?"OpenRouter":"openai-codex"===t?"OpenAI Codex":"openai"===t?"OpenAI":"anthropic"===t?"Anthropic":"ollama"===t?"Ollama":e.split("-").map(e=>e?e[0].toUpperCase()+e.slice(1):e).join(" ")}function tC(e,t){return"complete"===e?"light"===t?"border-emerald-200 bg-emerald-50/60":"border-emerald-400/20 bg-emerald-400/8":"current"===e?"light"===t?"border-[#d9c2b3] bg-white/70":"border-white/12 bg-white/[0.05]":"light"===t?"border-[#eadcd0] bg-[#fffaf6]/80":"border-white/6 bg-white/[0.02]"}function tS(e,t){return"complete"===e?"light"===t?"border-emerald-300 bg-emerald-100 text-emerald-700":"border-emerald-300/25 bg-emerald-300/10 text-emerald-200":"current"===e?"light"===t?"border-[#d5b9a5] bg-[#f5ebe3] text-[#8b6d5a]":"border-white/12 bg-white/[0.06] text-white":"light"===t?"border-[#e1ccc0] bg-white text-[#9a7f6c]":"border-white/8 bg-white/[0.03] text-slate-400"}function tA(e,t){return"complete"===e?"light"===t?"bg-emerald-100 text-emerald-700":"bg-emerald-300/10 text-emerald-200":"current"===e?"light"===t?"bg-[#efe1d4] text-[#876c5a]":"bg-white/[0.06] text-slate-300":"light"===t?"bg-[#f6ece4] text-[#a08471]":"bg-white/[0.04] text-slate-500"}var tI=a(6607),tT=a(8574),t$=a(6780);function t_({snapshot:e,activeWorkspaceId:t,requestedAgentAction:a,connectionState:r,collapsed:i,onToggleCollapsed:l,onSelectWorkspace:o,onRefresh:d}){let c=function(e){switch(e){case"healthy":return"text-emerald-300";case"degraded":return"text-amber-200";default:return"text-rose-200"}}(e.diagnostics.health),p="healthy"===e.diagnostics.health?"bg-emerald-300":"degraded"===e.diagnostics.health?"bg-amber-200":"bg-rose-300",u=e.diagnostics.gatewayUrl.replace(/^wss?:\/\//,"").replace(/\/$/,""),[h,x]=(0,m.useState)(!1),[g,b]=(0,m.useState)(!1),[f,v]=(0,m.useState)(!1),[j,N]=(0,m.useState)(!1),[C,A]=(0,m.useState)(!1),[T,$]=(0,m.useState)(!1),[O,R]=(0,m.useState)(!1),[M,P]=(0,m.useState)(!1),[E,D]=(0,m.useState)(null),[L,z]=(0,m.useState)(null),[F,W]=(0,m.useState)(null),[B,V]=(0,m.useState)(""),[q,K]=(0,m.useState)(null),[J,G]=(0,m.useState)(""),[H,Z]=(0,m.useState)("workspaces"),Q=(0,m.useRef)(null),Y=(0,m.useMemo)(()=>e.agents.filter(e=>!t||e.workspaceId===t).sort((e,t)=>e.workspaceId!==t.workspaceId?e.workspaceId.localeCompare(t.workspaceId):e.name.localeCompare(t.name)),[e.agents,t]),X=e.workspaces.find(e=>e.id===t)??e.workspaces[0]??null,et=!!E&&(g||"monitoring"===E.policy.preset),es=[{id:"overview",label:"Overview",icon:tI.A},{id:"workspaces",label:"Workspaces",icon:U.A,badge:String(e.workspaces.length)},{id:"agents",label:"Agents",icon:tT.A,badge:String(Y.length)},{id:"models",label:"Models",icon:e2.A,badge:String(e.models.length)}],er=(0,m.useMemo)(()=>F?e.agents.filter(e=>e.workspaceId===F.id):[],[F,e.agents]),en=(0,m.useMemo)(()=>er.filter(e=>"engaged"===e.status||"monitoring"===e.status||"ready"===e.status),[er]),em=(0,m.useMemo)(()=>F?e.runtimes.filter(e=>e.workspaceId===F.id):[],[F,e.runtimes]),eu=(0,m.useMemo)(()=>q?e.runtimes.filter(e=>e.agentId===q.id):[],[q,e.runtimes]),eh=q?e.workspaces.find(e=>e.id===q.workspaceId)??null:null,eb=!!q&&("engaged"===q.status||"monitoring"===q.status||"ready"===q.status),eC=e=>{K(e),G(""),R(!0)};(0,m.useEffect)(()=>{if(!a||Q.current===a.requestId)return;let t=e.agents.find(e=>e.id===a.agentId);if(t){if(Q.current=a.requestId,"edit"===a.kind)return void eS(t);eC(t)}},[a,e.agents]);let eS=e=>{D({...function(e,t={}){let a=ek(t.policy?.preset??"worker",t.policy),s=eg[a.preset],r=e_(a.preset,t.heartbeat);return{id:t.id??"",workspaceId:e,modelId:t.modelId??"",name:t.name??s.defaultName,emoji:t.emoji??s.defaultEmoji,theme:t.theme??s.defaultTheme,avatar:t.avatar??"",policy:a,heartbeat:r}}(e.workspaceId,{id:e.id,modelId:"unassigned"===e.modelId?"":e.modelId,name:e.name,emoji:e.identity.emoji??"",theme:e.identity.theme??"",avatar:e.identity.avatar??"",policy:e.policy,heartbeat:e_(e.policy.preset,{enabled:e.heartbeat.enabled,every:e.heartbeat.every??void 0})})}),b(!1),x(!0)},eA=async()=>{if(E){v(!0);try{let e=await fetch("/api/agents",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(E)}),t=await e.json();if(!e.ok||t.error)throw Error(t.error||"OpenClaw could not update the agent.");ex.o.success("Agent updated in OpenClaw.",{description:E.id}),x(!1),await d()}catch(e){ex.o.error("Agent update failed.",{description:e instanceof Error?e.message:"Unknown agent error."})}finally{v(!1)}}},eI=async()=>{if(L){$(!0);try{let e=await fetch("/api/workspaces",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceId:L.workspaceId,name:L.name.trim()||void 0,directory:L.directory.trim()||void 0})}),t=await e.json();if(!e.ok||t.error)throw Error(t.error||"OpenClaw could not update the workspace.");ex.o.success("Workspace updated in OpenClaw.",{description:t.workspacePath||L.currentPath}),N(!1),await d(),o(t.workspaceId??L.workspaceId)}catch(e){ex.o.error("Workspace update failed.",{description:e instanceof Error?e.message:"Unknown workspace error."})}finally{$(!1)}}},eM=async()=>{if(F){$(!0);try{let e=await fetch("/api/workspaces",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceId:F.id})}),a=await e.json();if(!e.ok||a.error)throw Error(a.error||"OpenClaw could not delete the workspace.");ex.o.success("Workspace deleted from OpenClaw.",{description:a.workspacePath||F.path}),A(!1),W(null),V(""),o(t===F.id?null:t),await d()}catch(e){ex.o.error("Workspace deletion failed.",{description:e instanceof Error?e.message:"Unknown workspace error."})}finally{$(!1)}}},eP=async()=>{if(q){P(!0);try{let e=await fetch("/api/agents",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentId:q.id})}),t=await e.json();if(!e.ok||t.error)throw Error(t.error||"OpenClaw could not delete the agent.");ex.o.success("Agent deleted from OpenClaw.",{description:t.agentId||q.id}),E?.id===q.id&&(x(!1),D(null)),R(!1),K(null),G(""),await d()}catch(e){ex.o.error("Agent deletion failed.",{description:e instanceof Error?e.message:"Unknown agent error."})}finally{P(!1)}}};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"panel-surface panel-glow flex h-full overflow-hidden rounded-[30px] border border-white/[0.08] bg-[#04070e]/88 shadow-[0_28px_90px_rgba(0,0,0,0.42)] backdrop-blur-2xl",children:[(0,s.jsxs)("div",{className:w("flex h-full shrink-0 flex-col items-center bg-[linear-gradient(180deg,rgba(7,10,18,0.98),rgba(3,6,12,0.98))] px-3 py-4",i?"w-full":"w-[78px] border-r border-white/[0.08]"),children:[(0,s.jsx)("button",{type:"button","aria-label":i?"Expand mission control":"Collapse mission control",onClick:l,className:"flex h-12 w-12 items-center justify-center rounded-[18px] border border-cyan-300/20 bg-cyan-400/[0.12] shadow-[0_10px_24px_rgba(34,211,238,0.18)] transition-all hover:border-cyan-200/30 hover:bg-cyan-400/[0.16]",children:(0,s.jsx)(t$.A,{className:"h-5 w-5 text-cyan-200"})}),(0,s.jsx)("button",{type:"button","aria-label":i?"Expand mission control":"Collapse mission control",onClick:l,className:"mt-4 inline-flex h-11 w-11 items-center justify-center rounded-[16px] border border-white/10 bg-white/[0.04] text-slate-300 transition-all hover:border-cyan-300/18 hover:bg-white/[0.08] hover:text-white",children:i?(0,s.jsx)(e0.A,{className:"h-4 w-4"}):(0,s.jsx)(eX.A,{className:"h-4 w-4"})}),(0,s.jsx)("div",{className:"mt-6 flex flex-1 flex-col items-center gap-2",children:es.map(e=>(0,s.jsx)(tO,{icon:e.icon,label:e.label,active:H===e.id,onClick:()=>{Z(e.id),i&&l()}},e.id))}),(0,s.jsxs)("div",{className:"mt-4 flex flex-col items-center gap-2",children:[(0,s.jsx)(y,{tone:p,pulse:"healthy"===e.diagnostics.health}),i?(0,s.jsx)("p",{className:"text-[9px] uppercase tracking-[0.18em] text-slate-500",children:e.mode}):null]})]}),i?null:(0,s.jsx)("div",{className:"min-w-0 flex-1 bg-[linear-gradient(180deg,rgba(6,10,18,0.96),rgba(3,6,14,0.98))]",children:(0,s.jsxs)("div",{className:"mission-scroll flex h-full min-h-0 flex-col overflow-y-auto overscroll-contain",children:[(0,s.jsxs)("div",{className:"shrink-0 border-b border-white/[0.08] px-5 pb-4 pt-5",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"text-[11px] uppercase tracking-[0.28em] text-slate-500",children:"OpenClaw"}),(0,s.jsx)("h1",{className:"mt-2 font-display text-[1.38rem] text-white",children:"Mission Control"}),(0,s.jsx)("p",{className:"mt-2 text-[12px] leading-5 text-slate-400",children:"Classic operations rail for live workspaces, agents, and model routing."})]}),(0,s.jsx)("div",{className:"rounded-[18px] border border-white/10 bg-white/[0.04] p-2.5 shadow-[inset_0_1px_0_rgba(255,255,255,0.05)]",children:(0,s.jsx)(t$.A,{className:"h-4 w-4 text-cyan-200"})})]}),(0,s.jsxs)("div",{className:"mt-4 rounded-[22px] border border-white/[0.08] bg-[linear-gradient(180deg,rgba(13,20,34,0.98),rgba(6,10,18,0.96))] p-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)(y,{tone:p,pulse:"healthy"===e.diagnostics.health}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:w("text-[13px] font-medium capitalize",c),children:e.diagnostics.health}),(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-[0.2em] text-slate-500",children:"live"===r?"stream online":r})]})]}),(0,s.jsx)(k,{variant:"muted",children:e.mode})]}),(0,s.jsxs)("div",{className:"mt-3 rounded-[16px] border border-white/[0.06] bg-white/[0.03] px-3 py-2.5",children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-[0.18em] text-slate-500",children:"Gateway"}),(0,s.jsx)("p",{className:"mt-1.5 text-[13px] text-white",children:u})]}),e.diagnostics.issues.length>0?(0,s.jsx)("div",{className:"mt-3 rounded-[16px] border border-amber-400/15 bg-amber-400/[0.08] px-3 py-2 text-xs text-amber-100",children:e.diagnostics.issues[0]}):null]}),(0,s.jsx)("div",{className:"mt-4 flex flex-wrap gap-2",children:es.map(e=>(0,s.jsx)(tR,{label:e.label,badge:e.badge,active:H===e.id,onClick:()=>Z(e.id)},e.id))})]}),(0,s.jsxs)("div",{className:"flex-1 space-y-6 p-4",children:["overview"===H?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(tM,{eyebrow:"Overview",title:"System summary",detail:"Current health, active focus, and runtime inventory."}),(0,s.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,s.jsx)(tP,{label:"Workspaces",value:String(e.workspaces.length)}),(0,s.jsx)(tP,{label:"Agents",value:String(e.agents.length)}),(0,s.jsx)(tP,{label:"Models",value:String(e.models.length)}),(0,s.jsx)(tP,{label:"Runs",value:String(e.runtimes.length)})]}),X?(0,s.jsxs)("div",{className:"rounded-[22px] border border-white/[0.08] bg-[linear-gradient(180deg,rgba(11,18,32,0.9),rgba(6,10,18,0.88))] p-4",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"truncate font-display text-[15px] text-white",children:X.name}),(0,s.jsx)("p",{className:"mt-1 truncate text-[10px] uppercase tracking-[0.22em] text-slate-500",children:X.slug})]}),(0,s.jsx)(k,{variant:"muted",children:X.health})]}),(0,s.jsxs)("div",{className:"mt-3 flex flex-wrap gap-2 text-[10px] uppercase tracking-[0.16em] text-slate-400",children:[(0,s.jsxs)("span",{children:[X.agentIds.length," agents"]}),(0,s.jsxs)("span",{children:[X.modelIds.length," models"]}),(0,s.jsxs)("span",{children:[X.activeRuntimeIds.length," runs"]})]}),(0,s.jsx)("p",{className:"mt-3 text-[12px] text-slate-400",children:function(e){let t=_(e),a=t.split("/").filter(Boolean).filter(e=>{var t;return t=e,!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t)});if(a.length<=3)return t;let s="~"===a[0]?"~/":"/";return`${s}…/${a.slice(-2).join("/")}`}(X.path)})]}):null]}):null,"workspaces"===H?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(tM,{eyebrow:"Home",title:"Workspaces",detail:"Select, rename, or remove real OpenClaw workspaces.",action:(0,s.jsx)(ee,{variant:"ghost",size:"sm",className:"h-8 rounded-full px-3 text-[11px]",onClick:()=>o(null),children:"All"})}),(0,s.jsx)("div",{className:"space-y-3",children:e.workspaces.map(e=>{let a=e.id===t;return(0,s.jsxs)("div",{className:w("rounded-[20px] border p-3.5 transition-all",a?"border-cyan-300/[0.35] bg-cyan-400/[0.08] shadow-[0_14px_40px_rgba(34,211,238,0.12)]":"border-white/[0.08] bg-white/[0.03] hover:bg-white/[0.05]"),children:[(0,s.jsx)("button",{type:"button",onClick:()=>o(a?null:e.id),className:"w-full text-left",children:(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"truncate font-display text-[15px] text-white",children:e.name}),(0,s.jsx)("p",{className:"mt-1 truncate text-[10px] uppercase tracking-[0.22em] text-slate-500",children:e.slug})]}),(0,s.jsx)(k,{variant:a?"default":"muted",children:e.health})]})}),(0,s.jsxs)("div",{className:"mt-3 flex flex-wrap gap-2 text-[10px] uppercase tracking-[0.16em] text-slate-400",children:[(0,s.jsxs)("span",{children:[e.agentIds.length," agents"]}),(0,s.jsxs)("span",{children:[e.modelIds.length," models"]}),(0,s.jsxs)("span",{children:[e.activeRuntimeIds.length," runs"]})]}),(0,s.jsxs)("div",{className:"mt-3 flex items-center gap-2",children:[(0,s.jsx)(ee,{variant:"secondary",size:"sm",className:"h-8 rounded-full px-3 text-[11px]",onClick:()=>{z({workspaceId:e.id,name:e.name,directory:"",currentPath:e.path}),N(!0)},children:"Edit"}),(0,s.jsx)(ee,{variant:"ghost",size:"sm",className:"h-8 rounded-full px-3 text-[11px] text-rose-200 hover:bg-rose-400/10 hover:text-rose-100",onClick:()=>{W(e),V(""),A(!0)},children:"Delete"})]})]},e.id)})})]}):null,"agents"===H?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(tM,{eyebrow:"Apps",title:"Agents",detail:"Create and tune live isolated OpenClaw operators.",action:(0,s.jsx)(eR,{snapshot:e,defaultWorkspaceId:t??e.workspaces[0]?.id??null,onRefresh:d,trigger:(0,s.jsx)(ee,{variant:"secondary",size:"sm",className:"h-8 rounded-full px-3 text-[11px]",disabled:0===e.workspaces.length,children:"Add"})})}),(0,s.jsxs)("div",{className:"space-y-3",children:[0===Y.length?(0,s.jsx)("div",{className:"rounded-[18px] border border-white/[0.08] bg-white/[0.03] px-3.5 py-3 text-[12px] text-slate-400",children:"No agents are attached to this workspace yet."}):null,Y.map(a=>(0,s.jsxs)("div",{className:"rounded-[18px] border border-white/[0.08] bg-[linear-gradient(180deg,rgba(11,18,32,0.9),rgba(8,13,24,0.84))] p-3.5",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsxs)("p",{className:"truncate text-[13px] font-medium text-white",children:[a.identity.emoji?`${a.identity.emoji} `:"",a.name]}),(0,s.jsx)("p",{className:"mt-1 truncate text-[10px] uppercase tracking-[0.22em] text-slate-500",children:a.id}),(0,s.jsxs)("div",{className:"mt-2 flex flex-wrap gap-2",children:[(0,s.jsx)(k,{variant:eg[a.policy.preset].badgeVariant,children:eN(a.policy.preset)}),(0,s.jsx)(k,{variant:"engaged"===a.status?"default":"muted",children:a.status})]})]}),(0,s.jsx)(tz,{agentName:a.name,onEdit:()=>eS(a),onDelete:()=>eC(a)})]}),(0,s.jsx)("div",{className:"mt-3 flex items-center gap-2",children:(0,s.jsx)("div",{className:"min-w-0 flex-1 rounded-full border border-white/[0.08] bg-white/[0.03] px-3 py-2 text-[10px] uppercase tracking-[0.16em] text-slate-400",children:(0,s.jsx)("span",{className:"truncate",children:"unassigned"===a.modelId?"default model":I(a.modelId)})})}),t?null:(0,s.jsx)("p",{className:"mt-2 truncate text-[10px] uppercase tracking-[0.18em] text-slate-500",children:e.workspaces.find(e=>e.id===a.workspaceId)?.name||"Workspace"})]},a.id))]})]}):null,"models"===H?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(tM,{eyebrow:"Models",title:"Model deck",detail:"Available routing targets and current usage across agents."}),(0,s.jsx)("div",{className:"space-y-3",children:e.models.slice(0,8).map(e=>(0,s.jsxs)("div",{className:"rounded-[18px] border border-white/[0.08] bg-[linear-gradient(180deg,rgba(11,18,32,0.9),rgba(8,13,24,0.84))] px-3.5 py-3",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"truncate text-[13px] font-medium text-white",children:I(e.id)}),(0,s.jsx)("p",{className:"mt-1 text-[10px] uppercase tracking-[0.22em] text-slate-500",children:e.provider})]}),(0,s.jsx)(k,{variant:e.local?"success":e.missing?"danger":"muted",children:e.local?"local":e.missing?"missing":"remote"})]}),(0,s.jsxs)("div",{className:"mt-3 flex items-center justify-between text-[11px] text-slate-400",children:[(0,s.jsxs)("span",{children:[S(e.contextWindow)," ctx"]}),(0,s.jsxs)("span",{children:[e.usageCount," agents"]})]})]},e.id))})]}):null]}),(0,s.jsx)("div",{className:"shrink-0 border-t border-white/[0.08] p-4",children:(0,s.jsx)("div",{className:"rounded-[22px] border border-cyan-300/10 bg-[linear-gradient(180deg,rgba(7,22,31,0.95),rgba(5,13,22,0.95))] p-4 shadow-[0_16px_40px_rgba(0,0,0,0.22)]",children:(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"flex h-11 w-11 items-center justify-center rounded-full border border-cyan-300/15 bg-cyan-400/[0.12] text-cyan-200",children:(0,s.jsx)(t$.A,{className:"h-4 w-4"})}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"truncate font-display text-[15px] text-white",children:X?.name||"No active workspace"}),(0,s.jsx)("p",{className:"mt-1 text-[12px] text-slate-400",children:X?`${X.agentIds.length} agents \xb7 ${X.activeRuntimeIds.length} runs`:`${e.agents.length} agents \xb7 ${e.runtimes.length} runs`})]})]})})})]})})]}),(0,s.jsx)(ea,{open:j,onOpenChange:N,children:(0,s.jsxs)(ei,{children:[(0,s.jsxs)(el,{children:[(0,s.jsx)(ed,{children:"Edit OpenClaw workspace"}),(0,s.jsx)(ec,{children:"Renaming a workspace moves the real directory and updates every attached agent binding."})]}),L?(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)(tE,{label:"Workspace name",htmlFor:"edit-workspace-name",children:(0,s.jsx)(ep,{id:"edit-workspace-name",value:L.name,onChange:e=>z(t=>t?{...t,name:e.target.value}:t),placeholder:"Workspace name"})}),(0,s.jsxs)("div",{className:"rounded-[18px] border border-white/10 bg-white/[0.03] px-3.5 py-3",children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-[0.2em] text-slate-500",children:"Current path"}),(0,s.jsx)("p",{className:"mt-1.5 break-all font-mono text-xs text-slate-300",children:L.currentPath})]}),(0,s.jsx)(tE,{label:"Directory override",htmlFor:"edit-workspace-directory",children:(0,s.jsx)(ep,{id:"edit-workspace-directory",value:L.directory,onChange:e=>z(t=>t?{...t,directory:e.target.value}:t),placeholder:"Leave blank to rename in the same parent folder"})})]}):null,(0,s.jsxs)(eo,{children:[(0,s.jsx)(ee,{variant:"secondary",onClick:()=>N(!1),children:"Cancel"}),(0,s.jsx)(ee,{onClick:eI,disabled:T||!L?.name.trim(),children:T?"Saving…":"Save workspace"})]})]})}),(0,s.jsx)(ea,{open:C,onOpenChange:A,children:(0,s.jsxs)(ei,{children:[(0,s.jsxs)(el,{children:[(0,s.jsx)(ed,{children:"Delete OpenClaw workspace"}),(0,s.jsx)(ec,{children:"This permanently removes the workspace directory and all OpenClaw agents bound to it."})]}),F?(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)("div",{className:"rounded-[20px] border border-rose-400/20 bg-rose-500/[0.08] px-4 py-3.5",children:(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)("div",{className:"mt-0.5 rounded-full border border-rose-300/20 bg-rose-400/10 p-2 text-rose-200",children:(0,s.jsx)(n.A,{className:"h-4 w-4"})}),(0,s.jsxs)("div",{className:"space-y-1.5 text-sm text-rose-50",children:[(0,s.jsx)("p",{className:"font-medium",children:"This action cannot be undone."}),(0,s.jsx)("p",{className:"text-rose-100/80",children:"OpenClaw will remove the workspace folder from disk and prune the attached agents/state."})]})]})}),(0,s.jsxs)("div",{className:"grid gap-3 sm:grid-cols-3",children:[(0,s.jsx)(tW,{label:"Agents",value:String(er.length)}),(0,s.jsx)(tW,{label:"Runs",value:String(em.length)}),(0,s.jsx)(tW,{label:"Live agents",value:String(en.length),danger:en.length>0})]}),(0,s.jsxs)("div",{className:"rounded-[18px] border border-white/10 bg-white/[0.03] px-3.5 py-3",children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-[0.2em] text-slate-500",children:"Workspace path"}),(0,s.jsx)("p",{className:"mt-1.5 break-all font-mono text-xs text-slate-300",children:F.path})]}),en.length>0||em.length>0?(0,s.jsx)("div",{className:"rounded-[18px] border border-amber-400/15 bg-amber-400/[0.08] px-3.5 py-3 text-sm text-amber-100",children:en.length>0?`${en.length} active or recently engaged agents are still attached to this workspace.`:`${em.length} runtime records are still associated with this workspace.`}):null,(0,s.jsx)(tE,{label:`Type ${F.slug} to confirm`,htmlFor:"delete-workspace-confirm",children:(0,s.jsx)(ep,{id:"delete-workspace-confirm",value:B,onChange:e=>V(e.target.value),placeholder:F.slug})})]}):null,(0,s.jsxs)(eo,{children:[(0,s.jsx)(ee,{variant:"secondary",onClick:()=>{A(!1),W(null),V("")},children:"Cancel"}),(0,s.jsx)(ee,{variant:"destructive",onClick:eM,disabled:T||!F||B.trim()!==F.slug,children:T?"Deleting…":"Delete workspace"})]})]})}),(0,s.jsx)(ea,{open:O,onOpenChange:R,children:(0,s.jsxs)(ei,{children:[(0,s.jsxs)(el,{children:[(0,s.jsx)(ed,{children:"Delete OpenClaw agent"}),(0,s.jsx)(ec,{children:"This removes the selected agent from OpenClaw and detaches its workspace binding."})]}),q?(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)("div",{className:"rounded-[20px] border border-rose-400/20 bg-rose-500/[0.08] px-4 py-3.5",children:(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)("div",{className:"mt-0.5 rounded-full border border-rose-300/20 bg-rose-400/10 p-2 text-rose-200",children:(0,s.jsx)(n.A,{className:"h-4 w-4"})}),(0,s.jsxs)("div",{className:"space-y-1.5 text-sm text-rose-50",children:[(0,s.jsx)("p",{className:"font-medium",children:"This action cannot be undone."}),(0,s.jsx)("p",{className:"text-rose-100/80",children:"OpenClaw will delete this agent, remove its config entry, remove its manifest record, and clean up agent-specific policy/state files. Shared workspace docs and files will remain."})]})]})}),(0,s.jsxs)("div",{className:"grid gap-3 sm:grid-cols-3",children:[(0,s.jsx)(tW,{label:"Status",value:q.status,danger:eb}),(0,s.jsx)(tW,{label:"Runs",value:String(eu.length)}),(0,s.jsx)(tW,{label:"Workspace",value:eh?.name??"Unknown"})]}),(0,s.jsxs)("div",{className:"rounded-[18px] border border-white/10 bg-white/[0.03] px-3.5 py-3",children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-[0.2em] text-slate-500",children:"Agent id"}),(0,s.jsx)("p",{className:"mt-1.5 break-all font-mono text-xs text-slate-300",children:q.id})]}),eb||eu.length>0?(0,s.jsx)("div",{className:"rounded-[18px] border border-amber-400/15 bg-amber-400/[0.08] px-3.5 py-3 text-sm text-amber-100",children:eb?"This agent is still active or recently engaged. Delete it only if you want to stop using it entirely.":`${eu.length} runtime records are still associated with this agent.`}):null,(0,s.jsx)(tE,{label:`Type ${q.id} to confirm`,htmlFor:"delete-agent-confirm",children:(0,s.jsx)(ep,{id:"delete-agent-confirm",value:J,onChange:e=>G(e.target.value),placeholder:q.id})})]}):null,(0,s.jsxs)(eo,{children:[(0,s.jsx)(ee,{variant:"secondary",onClick:()=>{R(!1),K(null),G("")},children:"Cancel"}),(0,s.jsx)(ee,{variant:"destructive",onClick:eP,disabled:M||!q||J.trim()!==q.id,children:M?"Deleting…":"Delete agent"})]})]})}),(0,s.jsx)(ea,{open:h,onOpenChange:x,children:(0,s.jsxs)(ei,{className:"max-h-[90vh] overflow-y-auto sm:max-w-3xl",children:[(0,s.jsxs)(el,{children:[(0,s.jsx)(ed,{children:"Edit OpenClaw agent"}),(0,s.jsx)(ec,{children:"Update the selected agent identity, preset, and operating policy."})]}),E?(0,s.jsxs)("div",{className:"space-y-5",children:[(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)("p",{className:"text-[11px] uppercase tracking-[0.18em] text-slate-400",children:"Agent preset"}),(0,s.jsx)("div",{className:"grid gap-3 sm:grid-cols-2",children:ef.map(e=>(0,s.jsx)(tD,{label:e.label,description:e.description,active:E.policy.preset===e.value,badgeVariant:eg[e.value].badgeVariant,onClick:()=>D(t=>{var a,s;let r,n,i;return t?(a=t,s=e.value,r=eg[a.policy.preset],n=eg[s],i=ek(s),{...a,name:a.name&&a.name!==r.defaultName?a.name:n.defaultName,emoji:a.emoji&&a.emoji!==r.defaultEmoji?a.emoji:n.defaultEmoji,theme:a.theme&&a.theme!==r.defaultTheme?a.theme:n.defaultTheme,policy:i,heartbeat:eO(a.heartbeat,a.policy.preset,s)}):t})},e.value))})]}),(0,s.jsx)(tL,{policy:E.policy}),(0,s.jsx)(tE,{label:"Agent id",htmlFor:"edit-agent-id",children:(0,s.jsx)(ep,{id:"edit-agent-id",value:E.id,disabled:!0})}),(0,s.jsx)(tE,{label:"Display name",htmlFor:"edit-agent-name",children:(0,s.jsx)(ep,{id:"edit-agent-name",value:E.name,onChange:e=>D(t=>t?{...t,name:e.target.value}:t),placeholder:eg[E.policy.preset].defaultName})}),(0,s.jsx)(tE,{label:"Workspace",htmlFor:"edit-agent-workspace",children:(0,s.jsx)(ep,{id:"edit-agent-workspace",value:e.workspaces.find(e=>e.id===E.workspaceId)?.name||E.workspaceId,disabled:!0})}),(0,s.jsx)(tE,{label:"Model",htmlFor:"edit-agent-model",children:(0,s.jsxs)("select",{id:"edit-agent-model",value:E.modelId,onChange:e=>D(t=>t?{...t,modelId:e.target.value}:t),className:"flex h-11 w-full rounded-2xl border border-white/10 bg-white/5 px-4 py-2 text-sm text-white outline-none",children:[(0,s.jsx)("option",{value:"",children:"Use OpenClaw default"}),e.models.map(e=>(0,s.jsx)("option",{value:e.id,children:e.id},e.id))]})}),(0,s.jsxs)("div",{className:"grid gap-4 sm:grid-cols-2",children:[(0,s.jsx)(tE,{label:"Emoji",htmlFor:"edit-agent-emoji",children:(0,s.jsx)(ep,{id:"edit-agent-emoji",value:E.emoji,onChange:e=>D(t=>t?{...t,emoji:e.target.value}:t),placeholder:eg[E.policy.preset].defaultEmoji})}),(0,s.jsx)(tE,{label:"Theme",htmlFor:"edit-agent-theme",children:(0,s.jsx)(ep,{id:"edit-agent-theme",value:E.theme,onChange:e=>D(t=>t?{...t,theme:e.target.value}:t),placeholder:eg[E.policy.preset].defaultTheme})})]}),(0,s.jsx)(tE,{label:"Avatar URL",htmlFor:"edit-agent-avatar",children:(0,s.jsx)(ep,{id:"edit-agent-avatar",value:E.avatar,onChange:e=>D(t=>t?{...t,avatar:e.target.value}:t),placeholder:"https://example.com/avatar.png"})}),(0,s.jsxs)("div",{className:"rounded-[20px] border border-white/10 bg-white/[0.03] p-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium text-white",children:"Advanced policy"}),(0,s.jsx)("p",{className:"mt-1 text-xs leading-5 text-slate-400",children:"Override how this agent handles missing tools, installs, file scope, and network usage."})]}),(0,s.jsx)(ee,{type:"button",variant:"secondary",size:"sm",className:"h-8 rounded-full px-3 text-[11px]",onClick:()=>b(e=>!e),children:g?"Hide":"Show"})]}),et?(0,s.jsxs)("div",{className:"mt-4 rounded-[18px] border border-white/10 bg-slate-950/40 p-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium text-white",children:"Heartbeat"}),(0,s.jsx)("p",{className:"mt-1 text-xs leading-5 text-slate-400",children:"Use this only for periodic watch or triage agents. Leave it off for normal task execution."})]}),(0,s.jsx)(ee,{type:"button",variant:E.heartbeat.enabled?"default":"secondary",size:"sm",className:"h-8 rounded-full px-3 text-[11px]",onClick:()=>D(e=>e?{...e,heartbeat:e.heartbeat.enabled?{...e.heartbeat,enabled:!1}:{...e.heartbeat,enabled:!0,every:e.heartbeat.every||e$(e.policy.preset).every}}:e),children:E.heartbeat.enabled?"On":"Off"})]}),E.heartbeat.enabled?(0,s.jsx)("div",{className:"mt-3",children:(0,s.jsx)(tE,{label:"Interval",htmlFor:"edit-agent-heartbeat-every",children:(0,s.jsx)("select",{id:"edit-agent-heartbeat-every",value:E.heartbeat.every,onChange:e=>D(t=>t?{...t,heartbeat:{...t.heartbeat,every:e.target.value}}:t),className:"flex h-11 w-full rounded-2xl border border-white/10 bg-white/5 px-4 py-2 text-sm text-white outline-none",children:eT.map(e=>(0,s.jsx)("option",{value:e.value,children:e.label},e.value))})})}):null]}):null,g?(0,s.jsxs)("div",{className:"mt-4 grid gap-4 sm:grid-cols-2",children:[(0,s.jsx)(tU,{label:"Missing tool behavior",htmlFor:"edit-agent-missing-tools",value:E.policy.missingToolBehavior,options:ew,onChange:e=>D(t=>t?{...t,policy:{...t.policy,missingToolBehavior:e}}:t)}),(0,s.jsx)(tU,{label:"Install scope",htmlFor:"edit-agent-install-scope",value:E.policy.installScope,options:ey,onChange:e=>D(t=>t?{...t,policy:{...t.policy,installScope:e}}:t)}),(0,s.jsx)(tU,{label:"File access",htmlFor:"edit-agent-file-access",value:E.policy.fileAccess,options:ev,onChange:e=>D(t=>t?{...t,policy:{...t.policy,fileAccess:e}}:t)}),(0,s.jsx)(tU,{label:"Network access",htmlFor:"edit-agent-network-access",value:E.policy.networkAccess,options:ej,onChange:e=>D(t=>t?{...t,policy:{...t.policy,networkAccess:e}}:t)})]}):null]})]}):null,(0,s.jsxs)(eo,{children:[(0,s.jsx)(ee,{variant:"secondary",onClick:()=>x(!1),children:"Cancel"}),(0,s.jsx)(ee,{onClick:eA,disabled:f||!E,children:f?"Saving…":"Save changes"})]})]})})]})}function tO({icon:e,label:t,active:a,onClick:r}){return(0,s.jsx)("button",{type:"button",onClick:r,title:t,className:w("inline-flex h-11 w-11 items-center justify-center rounded-[16px] border transition-all",a?"border-cyan-300/20 bg-cyan-400 text-slate-950 shadow-[0_12px_28px_rgba(96,165,250,0.35)]":"border-white/10 bg-white/[0.03] text-slate-400 hover:border-white/15 hover:bg-white/[0.08] hover:text-white"),children:(0,s.jsx)(e,{className:"h-4 w-4"})})}function tR({label:e,badge:t,active:a,onClick:r}){return(0,s.jsxs)("button",{type:"button",onClick:r,className:w("inline-flex items-center gap-2 rounded-full border px-3 py-2 text-[11px] uppercase tracking-[0.18em] transition-all",a?"border-cyan-300/20 bg-cyan-400 text-slate-950 shadow-[0_10px_24px_rgba(96,165,250,0.28)]":"border-white/[0.08] bg-white/[0.03] text-slate-300 hover:bg-white/[0.07] hover:text-white"),children:[(0,s.jsx)("span",{children:e}),t?(0,s.jsx)("span",{className:w("rounded-full px-1.5 py-0.5 text-[10px] tracking-normal",a?"bg-slate-950/14 text-slate-950":"bg-white/[0.08] text-slate-400"),children:t}):null]})}function tM({eyebrow:e,title:t,detail:a,action:r}){return(0,s.jsxs)("div",{className:"flex items-end justify-between gap-4",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-[0.22em] text-slate-500",children:e}),(0,s.jsx)("h2",{className:"mt-1.5 font-display text-[1.02rem] text-white",children:t}),(0,s.jsx)("p",{className:"mt-1.5 text-[12px] leading-5 text-slate-400",children:a})]}),r?(0,s.jsx)("div",{className:"shrink-0",children:r}):null]})}function tP({label:e,value:t}){return(0,s.jsxs)("div",{className:"rounded-[18px] border border-white/[0.08] bg-[linear-gradient(180deg,rgba(11,18,32,0.88),rgba(7,12,22,0.82))] px-3.5 py-3",children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-[0.2em] text-slate-500",children:e}),(0,s.jsx)("p",{className:"mt-1.5 font-display text-[1.2rem] text-white",children:t})]})}function tE({label:e,htmlFor:t,children:a}){return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(eh,{htmlFor:t,className:"text-[11px] uppercase tracking-[0.18em] text-slate-400",children:e}),a]})}function tD({label:e,description:t,active:a,badgeVariant:r,onClick:n}){return(0,s.jsx)("button",{type:"button",onClick:n,className:w("rounded-[20px] border p-4 text-left transition-colors",a?"border-cyan-300/30 bg-cyan-400/10":"border-white/10 bg-white/[0.03]"),children:(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)("p",{className:"text-sm font-medium text-white",children:e}),(0,s.jsx)("p",{className:"text-xs leading-5 text-slate-400",children:t})]}),(0,s.jsx)(k,{variant:r,children:a?"selected":"preset"})]})})}function tL({policy:e}){let t=eg[e.preset];return(0,s.jsxs)("div",{className:"rounded-[20px] border border-white/10 bg-slate-950/50 p-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium text-white",children:t.label}),(0,s.jsx)("p",{className:"mt-1 text-xs leading-5 text-slate-400",children:t.description})]}),(0,s.jsx)(k,{variant:t.badgeVariant,children:t.label})]}),(0,s.jsxs)("div",{className:"mt-4 flex flex-wrap gap-2",children:[(0,s.jsx)(k,{variant:"muted",children:eC(e.missingToolBehavior)}),(0,s.jsx)(k,{variant:"muted",children:eS(e.installScope)}),(0,s.jsx)(k,{variant:"muted",children:eA(e.fileAccess)}),(0,s.jsxs)(k,{variant:"muted",children:["Network ",eI(e.networkAccess)]})]})]})}function tU({label:e,htmlFor:t,value:a,options:r,onChange:n}){return(0,s.jsx)(tE,{label:e,htmlFor:t,children:(0,s.jsx)("select",{id:t,value:a,onChange:e=>n(e.target.value),className:"flex h-11 w-full rounded-2xl border border-white/10 bg-white/5 px-4 py-2 text-sm text-white outline-none",children:r.map(e=>(0,s.jsxs)("option",{value:e.value,children:[e.label," - ",e.description]},e.value))})})}function tz({agentName:e,onEdit:t,onDelete:a}){let[r,n]=(0,m.useState)(!1),i=(0,m.useRef)(null);return(0,m.useEffect)(()=>{if(!r)return;let e=e=>{i.current?.contains(e.target)||n(!1)};return window.addEventListener("pointerdown",e),()=>window.removeEventListener("pointerdown",e)},[r]),(0,s.jsxs)("div",{className:"relative",ref:i,children:[(0,s.jsx)("button",{type:"button","aria-label":`${e} actions`,onClick:()=>n(e=>!e),className:"inline-flex rounded-full border border-white/[0.08] bg-white/[0.05] p-1.5 text-slate-300 transition-colors hover:bg-white/[0.1] hover:text-white",children:(0,s.jsx)(x.A,{className:"h-3.5 w-3.5"})}),r?(0,s.jsxs)("div",{className:"absolute right-0 top-[calc(100%+8px)] z-30 min-w-[136px] rounded-[14px] border border-white/[0.1] bg-slate-950/96 p-1.5 shadow-[0_20px_44px_rgba(0,0,0,0.42)] backdrop-blur-xl",children:[(0,s.jsx)(tF,{label:"Edit",onClick:()=>{n(!1),t()}}),(0,s.jsx)(tF,{label:"Delete",danger:!0,onClick:()=>{n(!1),a()}})]}):null]})}function tF({label:e,onClick:t,danger:a=!1}){return(0,s.jsx)("button",{type:"button",className:w("flex w-full items-center rounded-[10px] px-2.5 py-2 text-left text-[11px] transition-colors",a?"text-rose-200 hover:bg-rose-400/10 hover:text-rose-100":"text-slate-200 hover:bg-white/[0.06] hover:text-white"),onClick:t,children:(0,s.jsx)("span",{children:e})})}function tW({label:e,value:t,danger:a=!1}){return(0,s.jsxs)("div",{className:w("rounded-[18px] border px-3.5 py-3",a?"border-amber-300/20 bg-amber-400/[0.08]":"border-white/10 bg-white/[0.03]"),children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-[0.2em] text-slate-500",children:e}),(0,s.jsx)("p",{className:w("mt-1.5 font-display text-lg",a?"text-amber-100":"text-white"),children:t})]})}var tB=a(2235);function tV({progress:e,className:t}){return(0,s.jsxs)("div",{className:w("rounded-[18px] border border-white/10 bg-slate-950/50 p-4",t),children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,s.jsxs)("div",{className:"max-w-2xl",children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-[0.22em] text-slate-500",children:e.title}),(0,s.jsx)("p",{className:"mt-2 text-sm text-slate-200",children:e.description})]}),(0,s.jsxs)("div",{className:"shrink-0 text-right",children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Progress"}),(0,s.jsxs)("p",{className:"mt-1 text-lg font-semibold text-white",children:[e.percent,"%"]})]})]}),(0,s.jsx)("div",{className:"mt-4 h-2 overflow-hidden rounded-full bg-white/8",children:(0,s.jsx)("div",{className:"h-full rounded-full bg-cyan-300/85 transition-[width] duration-500 ease-out",style:{width:`${e.percent}%`}})}),(0,s.jsx)("div",{className:"mt-4 space-y-2.5",children:e.steps.map((e,t)=>{let a="done"===e.status?"border-emerald-400/20 bg-emerald-400/10":"active"===e.status?"border-cyan-400/25 bg-cyan-400/10":"error"===e.status?"border-amber-400/25 bg-amber-400/10":"border-white/10 bg-white/[0.03]",r="done"===e.status?"border-emerald-300/30 bg-emerald-300/15 text-emerald-100":"active"===e.status?"border-cyan-300/30 bg-cyan-300/15 text-cyan-100":"error"===e.status?"border-amber-300/30 bg-amber-300/15 text-amber-100":"border-white/10 bg-slate-950/65 text-slate-400",l="done"===e.status?"bg-emerald-300/85":"active"===e.status?"bg-cyan-300/85":"error"===e.status?"bg-amber-300/85":"bg-transparent";return(0,s.jsx)("div",{className:w("rounded-[14px] border px-3 py-2.5 transition-colors",a),children:(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)("span",{className:w("mt-0.5 inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full border text-[10px] font-medium",r),children:"done"===e.status?(0,s.jsx)(th.A,{className:"h-3.5 w-3.5"}):"active"===e.status?(0,s.jsx)(i.A,{className:"h-3.5 w-3.5 animate-spin"}):"error"===e.status?(0,s.jsx)(n.A,{className:"h-3.5 w-3.5"}):t+1}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[(0,s.jsx)("p",{className:"text-sm text-white",children:e.label}),(0,s.jsxs)("span",{className:"text-xs tabular-nums text-slate-400",children:[e.percent,"%"]})]}),(0,s.jsx)("p",{className:"mt-0.5 text-xs leading-5 text-slate-400",children:e.detail||e.description}),(0,s.jsx)("div",{className:"mt-2 h-1.5 overflow-hidden rounded-full bg-white/8",children:(0,s.jsx)("div",{className:w("h-full rounded-full transition-[width] duration-500 ease-out",l),style:{width:`${e.percent}%`}})}),e.activities.length>0?(0,s.jsx)("div",{className:"mt-2.5 space-y-1.5",children:e.activities.map(e=>(0,s.jsxs)("div",{className:"flex items-start gap-2 text-[11px] leading-5 text-slate-300",children:[(0,s.jsx)("span",{className:w("mt-[7px] h-1.5 w-1.5 shrink-0 rounded-full","done"===e.status&&"bg-emerald-300","active"===e.status&&"bg-cyan-300","error"===e.status&&"bg-amber-300","pending"===e.status&&"bg-slate-500")}),(0,s.jsx)("span",{className:"min-w-0",children:e.message})]},e.id))}):null]})]})},e.id)})})]})}var tq=a(1266),tK=a(4294),tJ=a(9560),tG=a(3201),tH=a(5809);let tZ=m.forwardRef(({className:e,children:t,...a},r)=>(0,s.jsxs)(tH.bL,{ref:r,className:w("relative overflow-hidden",e),...a,children:[(0,s.jsx)(tH.LM,{className:"mission-scroll h-full w-full rounded-[inherit] [&>div]:!block [&>div]:!w-full [&>div]:!min-w-0",children:t}),(0,s.jsx)(tQ,{}),(0,s.jsx)(tH.OK,{})]}));tZ.displayName=tH.bL.displayName;let tQ=m.forwardRef(({className:e,orientation:t="vertical",...a},r)=>(0,s.jsx)(tH.VM,{ref:r,orientation:t,className:w("flex touch-none select-none transition-colors","vertical"===t&&"h-full w-2.5 border-l border-l-transparent p-[1px]","horizontal"===t&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...a,children:(0,s.jsx)(tH.lr,{className:"relative flex-1 rounded-full bg-white/[0.12]"})}));tQ.displayName=tH.VM.displayName;var tY=a(8074),tX=a(4448),t0=a(9182);let t1=[{id:"company",label:"Company",icon:tY.A},{id:"product",label:"Product",icon:tX.A},{id:"workspace",label:"Workspace",icon:t0.A},{id:"team",label:"Team",icon:tT.A},{id:"operations",label:"Operations",icon:t$.A},{id:"deploy",label:"Deploy",icon:tG.A}],t2=[{id:"intake",label:"Intake",section:"company"},{id:"context-harvest",label:"Context",section:"workspace"},{id:"team-synthesis",label:"Team",section:"team"},{id:"pressure-test",label:"Review",section:"operations"},{id:"decision-lock",label:"Lock",section:"deploy"},{id:"ready",label:"Ready",section:"deploy"},{id:"deploying",label:"Deploying",section:"deploy"},{id:"deployed",label:"Live",section:"deploy"}];function t5(e){return t2.find(t=>t.id===e)?.section??"company"}function t3(e){return t2.find(t=>t.id===e)?.label??"Draft"}function t4(e,t){switch(t){case"company":{let t=[e.company.name,e.company.mission,e.company.targetCustomer].filter(e=>!e.trim()).length;return 0===t?{label:"Ready to review",variant:"success"}:{label:`${t} core field${1===t?"":"s"} missing`,variant:"warning"}}case"product":{let t=[+!e.product.offer.trim(),e.product.scopeV1.length>0?0:1,e.product.launchPriority.length>0?0:1].reduce((e,t)=>e+t,0);return 0===t?{label:"Scope is defined",variant:"success"}:{label:`${t} product decision${1===t?"":"s"} pending`,variant:"warning"}}case"workspace":{let t=+!e.workspace.name.trim();return"clone"!==e.workspace.sourceMode||e.workspace.repoUrl?.trim()||(t+=1),"existing"!==e.workspace.sourceMode||e.workspace.existingPath?.trim()||(t+=1),0===t?{label:"Provisioning path set",variant:"success"}:{label:`${t} workspace input${1===t?"":"s"} missing`,variant:"warning"}}case"team":{let t=e.team.persistentAgents.filter(e=>e.enabled).length,a=e.team.persistentAgents.some(e=>e.enabled&&e.isPrimary);if(0===t)return{label:"Add at least one agent",variant:"danger"};if(!a)return{label:"Primary agent missing",variant:"warning"};return{label:`${t} active agent${1===t?"":"s"}`,variant:"success"}}case"operations":{let t=e.operations.workflows.filter(e=>e.enabled).length,a=e.operations.automations.filter(e=>e.enabled).length;if(0===t&&0===a)return{label:"No runtime loops yet",variant:"warning"};return{label:`${t} workflows, ${a} automations`,variant:"success"}}default:if(!e.intake.reviewRequested&&"deploying"!==e.status&&"deployed"!==e.status)return{label:"Review not opened yet",variant:"muted"};if(e.deploy.blockers.length>0)return{label:`${e.deploy.blockers.length} blocker${1===e.deploy.blockers.length?"":"s"}`,variant:"danger"};if(e.deploy.warnings.length>0)return{label:`${e.deploy.warnings.length} warning${1===e.deploy.warnings.length?"":"s"}`,variant:"warning"};return{label:"Ready to deploy",variant:"success"}}}function t8(e,t){switch(t){case"company":return e.company.name?`${e.company.name}${e.company.mission?` \xb7 ${e.company.mission}`:""}`:"Mission and audience are still being shaped.";case"product":return e.product.offer||"Offer and V1 scope are still being drafted.";case"workspace":return`${t6(e.workspace.template)} \xb7 ${t6(e.workspace.sourceMode)}`;case"team":return`${e.team.persistentAgents.filter(e=>e.enabled).length} agents drafted`;case"operations":return`${e.operations.workflows.filter(e=>e.enabled).length} workflows \xb7 ${e.operations.automations.filter(e=>e.enabled).length} automations`;default:return e.intake.reviewRequested?"Deploy review is open.":"Review not started."}}function t6(e){return e.split(/[-_]/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}let t9={software:[{id:"builder",role:"Builder",name:"Builder",emoji:"\uD83D\uDEE0️",theme:"amber",skillId:"project-builder",isPrimary:!0,description:"Implements requested changes and drives delivery forward."},{id:"reviewer",role:"Reviewer",name:"Reviewer",emoji:"\uD83D\uDD0D",theme:"rose",skillId:"project-reviewer",description:"Reviews work for correctness, regressions, and product risk."},{id:"tester",role:"Tester",name:"Tester",emoji:"\uD83E\uDDEA",theme:"emerald",skillId:"project-tester",description:"Validates behavior, tests, and environment assumptions."},{id:"learner",role:"Learner",name:"Learner",emoji:"\uD83E\uDDE0",theme:"cyan",skillId:"project-learner",description:"Consolidates durable project knowledge and memory."}],frontend:[{id:"builder",role:"Builder",name:"Builder",emoji:"\uD83D\uDEE0️",theme:"amber",skillId:"project-builder",isPrimary:!0,description:"Implements UI and frontend product work."},{id:"reviewer",role:"Reviewer",name:"Reviewer",emoji:"\uD83D\uDD0D",theme:"rose",skillId:"project-reviewer",description:"Reviews interaction, correctness, and regression risk."},{id:"tester",role:"Tester",name:"Tester",emoji:"\uD83E\uDDEA",theme:"emerald",skillId:"project-tester",description:"Checks behavior, responsive states, and verification gaps."},{id:"learner",role:"Learner",name:"Learner",emoji:"\uD83E\uDDE0",theme:"cyan",skillId:"project-learner",description:"Maintains stable product and implementation knowledge."},{id:"browser",role:"Browser Agent",name:"Browser Agent",emoji:"\uD83C\uDF10",theme:"blue",skillId:"project-browser",description:"Exercises browser flows, captures UI evidence, and validates user paths."}],backend:[{id:"builder",role:"Builder",name:"Builder",emoji:"\uD83D\uDEE0️",theme:"amber",skillId:"project-builder",isPrimary:!0,description:"Implements service, API, and infrastructure changes."},{id:"reviewer",role:"Reviewer",name:"Reviewer",emoji:"\uD83D\uDD0D",theme:"rose",skillId:"project-reviewer",description:"Catches correctness, data handling, and operational risks."},{id:"tester",role:"Tester",name:"Tester",emoji:"\uD83E\uDDEA",theme:"emerald",skillId:"project-tester",description:"Validates APIs, background jobs, migrations, and failure paths."},{id:"learner",role:"Learner",name:"Learner",emoji:"\uD83E\uDDE0",theme:"cyan",skillId:"project-learner",description:"Maintains architecture notes and durable operational memory."}],research:[{id:"researcher",role:"Research Lead",name:"Research Lead",emoji:"\uD83D\uDD2C",theme:"violet",skillId:"project-researcher",isPrimary:!0,description:"Runs investigations, frames questions, and synthesizes findings."},{id:"reviewer",role:"Reviewer",name:"Reviewer",emoji:"\uD83D\uDD0D",theme:"rose",skillId:"project-reviewer",description:"Pressure-tests claims, assumptions, and interpretation quality."},{id:"learner",role:"Archivist",name:"Archivist",emoji:"\uD83E\uDDE0",theme:"cyan",skillId:"project-learner",description:"Distills durable research notes, memory, and takeaways."}],content:[{id:"strategist",role:"Strategist",name:"Strategist",emoji:"\uD83D\uDCE3",theme:"orange",skillId:"project-strategist",isPrimary:!0,description:"Frames audience, goals, positioning, and campaign direction."},{id:"writer",role:"Writer",name:"Writer",emoji:"✍️",theme:"sky",skillId:"project-writer",description:"Drafts content, messaging, and campaign assets."},{id:"reviewer",role:"Reviewer",name:"Reviewer",emoji:"\uD83D\uDD0D",theme:"rose",skillId:"project-reviewer",description:"Edits for clarity, quality, and consistency."},{id:"analyst",role:"Analyst",name:"Analyst",emoji:"\uD83D\uDCC8",theme:"emerald",skillId:"project-analyst",description:"Tracks results, experiments, and performance insights."}]},t7=Object.fromEntries([{value:"software",label:"Software project",description:"Balanced software delivery setup for product and engineering work."},{value:"frontend",label:"Frontend app",description:"UI-focused team with browser coverage and product-facing documentation."},{value:"backend",label:"Backend/API",description:"Service and API template with strong testing and delivery defaults."},{value:"research",label:"Research",description:"Exploration-first workspace for investigation, synthesis, and durable notes."},{value:"content",label:"Content/Growth",description:"Campaign and content setup for strategy, writing, review, and analytics."}].map(e=>[e.value,e.label]));function ae({className:e,surfaceTheme:t,mode:a,snapshot:r,plan:n,resolvedName:i,resolvedTemplate:l,sourceAnalysis:o,workspacePath:d,notice:c,progress:p}){let u="light"===t,h=(0,m.useRef)({}),x=(0,m.useRef)(null),[g,b]=(0,m.useState)(null),f=(0,m.useMemo)(()=>(function({mode:e,plan:t,notice:a,progress:s,resolvedName:r,resolvedTemplate:n,sourceAnalysis:i,workspacePath:l}){return{mode:e,noticeSignature:a?`${a.tone}:${a.title}:${a.description}`:"",progressSignature:s?JSON.stringify(s):"",basic:{architectSignature:t?`${t.architectSummary}:${t.intake.confirmations.join("|")}`:"",nameSignature:r,sourceSignature:`${i.kind}:${i.label}:${i.hint}:${i.repoUrl??""}:${i.existingPath??""}:${i.websiteUrl??""}`,templateSignature:n,pathSignature:l},advanced:{stage:t?.stage??null,readinessSignature:t?`${t.readinessScore}:${t.architectSummary}`:"",deploySignature:t?`${t.intake.reviewRequested}:${t.deploy.blockers.join("|")}:${t.deploy.warnings.join("|")}`:"",sectionSignatures:Object.fromEntries(t1.map(e=>[e.id,t?`${t4(t,e.id).label}:${t4(t,e.id).variant}:${t8(t,e.id)}`:""]))}}})({mode:a,plan:n,notice:c,progress:p,resolvedName:i,resolvedTemplate:l,sourceAnalysis:o,workspacePath:d}),[a,c,n,p,i,l,o,d]);return(0,m.useEffect)(()=>{let e=x.current;if(x.current=f,!e)return;let t=function(e,t){if(e.mode!==t.mode)return"basic"===t.mode?t.basic.architectSignature?"architect-readout":"name":t.advanced.stage?`section-${t5(t.advanced.stage)}`:"readiness";if(e.noticeSignature!==t.noticeSignature&&t.noticeSignature)return"notice";if(e.progressSignature!==t.progressSignature&&t.progressSignature)return"progress";if("basic"===t.mode)return e.basic.architectSignature!==t.basic.architectSignature&&t.basic.architectSignature?"architect-readout":e.basic.nameSignature!==t.basic.nameSignature?"name":e.basic.sourceSignature!==t.basic.sourceSignature?"source":e.basic.templateSignature!==t.basic.templateSignature?"template":e.basic.pathSignature!==t.basic.pathSignature?"path":null;if(e.advanced.deploySignature!==t.advanced.deploySignature&&t.advanced.deploySignature)return"deploy-review";if(e.advanced.stage!==t.advanced.stage&&t.advanced.stage)return`section-${t5(t.advanced.stage)}`;if(e.advanced.readinessSignature!==t.advanced.readinessSignature&&t.advanced.readinessSignature)return"readiness";for(let a of t1)if(e.advanced.sectionSignatures[a.id]!==t.advanced.sectionSignatures[a.id])return`section-${a.id}`;return null}(e,f);t&&b(t)},[f]),(0,m.useEffect)(()=>{if(!g)return;let e=h.current[g];e&&globalThis.requestAnimationFrame(()=>{e.scrollIntoView({behavior:"smooth",block:"center"})});let t=globalThis.setTimeout(()=>{b(e=>e===g?null:e)},2200);return()=>{globalThis.clearTimeout(t)}},[g]),(0,s.jsx)("aside",{className:w("min-h-0 border-t lg:border-l lg:border-t-0",u?"border-[#ebe5dd] bg-[#f7f2eb]":"border-white/10 bg-[rgba(5,9,18,0.92)]",e),children:(0,s.jsx)(tZ,{className:"h-full",children:(0,s.jsxs)("div",{className:"space-y-4 p-4 md:p-5",children:[(0,s.jsx)(aa,{surfaceTheme:t,title:"basic"===a?"Workspace draft":"Workspace blueprint",subtitle:"basic"===a?"Architect is filling this live while the fast create path stays available.":"Live structured view of what Architect is shaping through conversation."}),c?(0,s.jsx)(at,{sectionKey:"notice",activeSection:g,surfaceTheme:t,register:e=>{h.current.notice=e},children:(0,s.jsxs)("div",{className:w("rounded-[18px] border px-4 py-3","warning"===c.tone?u?"border-amber-200 bg-amber-50 text-amber-900":"border-amber-400/25 bg-amber-400/10 text-amber-100":u?"border-[#e3ddd4] bg-white text-[#3f3933]":"border-white/10 bg-white/[0.04] text-slate-200"),children:[(0,s.jsx)("p",{className:w("text-[11px] uppercase tracking-[0.18em]",u?"text-[#9c9389]":"text-slate-500"),children:c.title}),(0,s.jsx)("p",{className:"mt-1 text-[13px] leading-6",children:c.description})]})}):null,p?(0,s.jsx)(at,{sectionKey:"progress",activeSection:g,surfaceTheme:t,register:e=>{h.current.progress=e},children:(0,s.jsx)(tV,{progress:p,className:w(u?"border-[#e5ded3] bg-white text-slate-900 [&_p]:text-inherit":"border-white/10 bg-slate-950/50")})}):null,"basic"===a?(0,s.jsxs)("div",{className:"space-y-3",children:[n?(0,s.jsx)(at,{sectionKey:"architect-readout",activeSection:g,surfaceTheme:t,register:e=>{h.current["architect-readout"]=e},children:(0,s.jsx)("div",{className:w("rounded-[22px] border p-4",u?"border-[#e5ddd2] bg-white":"border-white/10 bg-white/[0.04]"),children:(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)("span",{className:w("inline-flex size-9 shrink-0 items-center justify-center rounded-full border",u?"border-[#e7e0d6] bg-[#faf6f1] text-[#5e5750]":"border-white/10 bg-white/[0.05] text-slate-300"),children:(0,s.jsx)(tT.A,{className:"h-4 w-4"})}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("p",{className:w("text-[11px] uppercase tracking-[0.18em]",u?"text-[#a0978b]":"text-slate-500"),children:"Architect readout"}),(0,s.jsx)("p",{className:w("mt-1 text-[13px] leading-6",u?"text-[#171410]":"text-white"),children:n.architectSummary}),n.intake.confirmations.length>0?(0,s.jsxs)("div",{className:"mt-3 space-y-2",children:[(0,s.jsx)("p",{className:w("text-[11px] uppercase tracking-[0.16em]",u?"text-[#8d8276]":"text-slate-500"),children:"Next decisions"}),n.intake.confirmations.slice(0,2).map(e=>(0,s.jsx)("div",{className:w("rounded-[16px] border px-3 py-2 text-[12px] leading-5",u?"border-[#e8e0d6] bg-[#faf6f1] text-[#5d554d]":"border-white/10 bg-white/[0.05] text-slate-300"),children:e},e))]}):null]})]})})}):null,(0,s.jsx)(at,{sectionKey:"name",activeSection:g,surfaceTheme:t,register:e=>{h.current.name=e},children:(0,s.jsx)(as,{surfaceTheme:t,icon:D.A,title:"Name",value:i,subtitle:n?"Updated from Architect's latest read of the conversation.":"Resolved from your quick setup."})}),(0,s.jsx)(at,{sectionKey:"source",activeSection:g,surfaceTheme:t,register:e=>{h.current.source=e},children:(0,s.jsx)(as,{surfaceTheme:t,icon:"clone"===o.kind?tq.A:"website"===o.kind?tK.A:tJ.A,title:"Source",value:o.label,subtitle:n?"Source context Architect is currently using.":o.hint})}),(0,s.jsx)(at,{sectionKey:"template",activeSection:g,surfaceTheme:t,register:e=>{h.current.template=e},children:(0,s.jsx)(as,{surfaceTheme:t,icon:D.A,title:"Template",value:t7[l],subtitle:"Inferred from the live conversation and source context."})}),(0,s.jsx)(at,{sectionKey:"path",activeSection:g,surfaceTheme:t,register:e=>{h.current.path=e},children:(0,s.jsx)(as,{surfaceTheme:t,icon:tJ.A,title:"Path",value:d,subtitle:`Root: ${r.diagnostics.workspaceRoot}`,mono:!0})}),(0,s.jsx)(at,{sectionKey:"defaults",activeSection:g,surfaceTheme:t,register:e=>{h.current.defaults=e},children:(0,s.jsxs)("div",{className:w("rounded-[22px] border p-4",u?"border-[#e5ddd2] bg-white":"border-white/10 bg-white/[0.04]"),children:[(0,s.jsx)("p",{className:w("text-[11px] uppercase tracking-[0.18em]",u?"text-[#a0978b]":"text-slate-500"),children:"Fast-path defaults"}),(0,s.jsxs)("div",{className:"mt-3 flex flex-wrap gap-2",children:[(0,s.jsx)(ar,{surfaceTheme:t,label:"Solo team"}),(0,s.jsx)(ar,{surfaceTheme:t,label:"Balanced model"}),(0,s.jsx)(ar,{surfaceTheme:t,label:"Kickoff mission"})]}),(0,s.jsx)("p",{className:w("mt-3 text-[13px] leading-6",u?"text-[#70685f]":"text-slate-300"),children:"Need more control? Switch to Advanced and keep the same draft while Architect expands team, workflows, and deploy readiness."})]})})]}):n?(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)(at,{sectionKey:"readiness",activeSection:g,surfaceTheme:t,register:e=>{h.current.readiness=e},children:(0,s.jsx)("div",{className:w("rounded-[22px] border p-4",u?"border-[#e5ddd2] bg-white":"border-white/10 bg-white/[0.04]"),children:(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:w("text-[11px] uppercase tracking-[0.18em]",u?"text-[#a0978b]":"text-slate-500"),children:"Readiness"}),(0,s.jsxs)("p",{className:w("mt-1 text-[28px] font-semibold tracking-[-0.03em]",u?"text-[#181612]":"text-white"),children:[n.readinessScore,"%"]}),(0,s.jsx)("p",{className:w("text-[13px] leading-6",u?"text-[#6e665d]":"text-slate-300"),children:n.architectSummary})]}),(0,s.jsx)("span",{className:w("inline-flex size-10 items-center justify-center rounded-full border",u?"border-[#e5ddd2] bg-[#f5f0e8] text-[#6a635b]":"border-white/10 bg-white/[0.05] text-slate-300"),children:(0,s.jsx)(tT.A,{className:"h-4 w-4"})})]})})}),t1.map(e=>{let a=t4(n,e.id),r=e.icon,i=`section-${e.id}`;return(0,s.jsx)(at,{sectionKey:i,activeSection:g,surfaceTheme:t,register:e=>{h.current[i]=e},children:(0,s.jsx)("div",{className:w("rounded-[22px] border p-4",u?"border-[#e5ddd2] bg-white":"border-white/10 bg-white/[0.04]"),children:(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)("span",{className:w("inline-flex size-9 shrink-0 items-center justify-center rounded-full border",u?"border-[#e7e0d6] bg-[#faf6f1] text-[#5e5750]":"border-white/10 bg-white/[0.05] text-slate-300"),children:(0,s.jsx)(r,{className:"h-4 w-4"})}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,s.jsx)("p",{className:w("text-[14px] font-semibold",u?"text-[#171410]":"text-white"),children:e.label}),(0,s.jsx)(an,{surfaceTheme:t,tone:a.variant,label:a.label})]}),(0,s.jsx)("p",{className:w("mt-1 text-[13px] leading-6",u?"text-[#70685f]":"text-slate-300"),children:t8(n,e.id)})]})]})})},e.id)}),(0,s.jsx)(at,{sectionKey:"deploy-review",activeSection:g,surfaceTheme:t,register:e=>{h.current["deploy-review"]=e},children:(0,s.jsxs)("div",{className:w("rounded-[22px] border p-4",u?"border-[#e5ddd2] bg-white":"border-white/10 bg-white/[0.04]"),children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(tG.A,{className:w("h-4 w-4",u?"text-[#5f5952]":"text-slate-300")}),(0,s.jsx)("p",{className:w("text-[14px] font-semibold",u?"text-[#171410]":"text-white"),children:"Deploy review"})]}),n.deploy.blockers.length>0?(0,s.jsx)(ai,{surfaceTheme:t,title:"Blockers",tone:"danger",items:n.deploy.blockers}):null,n.deploy.warnings.length>0?(0,s.jsx)(ai,{surfaceTheme:t,title:"Warnings",tone:"warning",items:n.deploy.warnings}):null,0===n.deploy.blockers.length&&0===n.deploy.warnings.length?(0,s.jsx)("p",{className:w("mt-3 text-[13px] leading-6",u?"text-[#70685f]":"text-slate-300"),children:"Architect has not surfaced blockers or warnings yet. Request review when the blueprint feels directionally right."}):null]})})]}):(0,s.jsxs)("div",{className:w("rounded-[22px] border border-dashed p-5",u?"border-[#ddd5ca] bg-white/80":"border-white/10 bg-white/[0.04]"),children:[(0,s.jsx)("p",{className:w("text-[14px] font-medium",u?"text-[#211d19]":"text-white"),children:"Architect is preparing the blueprint."}),(0,s.jsx)("p",{className:w("mt-1 text-[13px] leading-6",u?"text-[#776f65]":"text-slate-300"),children:"Once the first plan is ready, this pane will start reflecting the structured workspace draft."})]})]})})})}function at({sectionKey:e,activeSection:t,surfaceTheme:a,register:r,children:n}){return(0,s.jsx)("div",{ref:r,className:w("scroll-mt-6 rounded-[26px] transition-all duration-500",t===e&&("light"===a?"ring-2 ring-[#d8b184]/70 shadow-[0_0_0_1px_rgba(216,177,132,0.18),0_18px_36px_rgba(102,78,47,0.16)]":"ring-2 ring-cyan-300/45 shadow-[0_0_0_1px_rgba(103,232,249,0.14),0_18px_36px_rgba(6,182,212,0.16)]")),children:n})}function aa({surfaceTheme:e,title:t,subtitle:a}){let r="light"===e;return(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:w("text-[11px] uppercase tracking-[0.18em]",r?"text-[#8b7262]":"text-slate-500"),children:t}),(0,s.jsx)("p",{className:w("mt-1 text-[13px] leading-6",r?"text-[#705b4d]":"text-slate-300"),children:a})]})}function as({surfaceTheme:e,icon:t,title:a,value:r,subtitle:n,mono:i=!1}){let l="light"===e;return(0,s.jsx)("div",{className:w("rounded-[22px] border p-4",l?"border-[#e5ddd2] bg-white":"border-white/10 bg-white/[0.04]"),children:(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)("span",{className:w("inline-flex size-9 shrink-0 items-center justify-center rounded-full border",l?"border-[#e7e0d6] bg-[#faf6f1] text-[#5e5750]":"border-white/10 bg-white/[0.05] text-slate-300"),children:(0,s.jsx)(t,{className:"h-4 w-4"})}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:w("text-[11px] uppercase tracking-[0.18em]",l?"text-[#a0978b]":"text-slate-500"),children:a}),(0,s.jsx)("p",{className:w("mt-1 truncate text-[14px] font-medium",l?"text-[#171410]":"text-white",i&&"font-mono text-[12px]"),children:r}),(0,s.jsx)("p",{className:w("mt-1 text-[12px] leading-5",l?"text-[#776f65]":"text-slate-400"),children:n})]})]})})}function ar({surfaceTheme:e,label:t}){return(0,s.jsx)("span",{className:w("inline-flex items-center rounded-full border px-3 py-1 text-[10px] uppercase tracking-[0.16em]","light"===e?"border-[#e4ddd3] bg-[#f6f1ea] text-[#6c645b]":"border-white/10 bg-white/[0.05] text-slate-300"),children:t})}function an({surfaceTheme:e,tone:t,label:a}){return(0,s.jsx)("span",{className:w("inline-flex items-center rounded-full border px-2.5 py-1 text-[10px] uppercase tracking-[0.16em]","muted"===t&&("light"===e?"border-[#e4ddd3] bg-[#f7f2eb] text-[#746b61]":"border-white/10 bg-white/[0.05] text-slate-300"),"success"===t&&"border-emerald-200 bg-emerald-50 text-emerald-700","warning"===t&&"border-amber-200 bg-amber-50 text-amber-700","danger"===t&&"border-rose-200 bg-rose-50 text-rose-700"),children:a})}function ai({surfaceTheme:e,title:t,tone:a,items:r}){let i="light"===e;return(0,s.jsxs)("div",{className:w("mt-3 rounded-[18px] border px-4 py-3","danger"===a?i?"border-rose-200 bg-rose-50":"border-rose-400/25 bg-rose-400/10":i?"border-amber-200 bg-amber-50":"border-amber-400/25 bg-amber-400/10"),children:[(0,s.jsx)("p",{className:w("text-[11px] uppercase tracking-[0.18em]",i?"text-[#9f958a]":"text-slate-500"),children:t}),(0,s.jsx)("div",{className:"mt-2 space-y-2",children:r.map(e=>(0,s.jsxs)("div",{className:w("flex items-start gap-2 text-[13px] leading-6",i?"text-[#403934]":"text-slate-200"),children:[(0,s.jsx)(n.A,{className:"mt-1 h-3.5 w-3.5 shrink-0"}),(0,s.jsx)("span",{children:e})]},e))})]})}var al=a(6613);function ao({surfaceTheme:e,mode:t,onModeChange:a,onNewDraft:r,badges:n}){let i="light"===e;return(0,s.jsxs)("div",{className:w("relative z-[1] border-b px-4 py-3 md:px-5",i?"border-[#e7e1d8] bg-[linear-gradient(180deg,rgba(255,255,255,0.96),rgba(248,244,237,0.94))]":"border-white/10 bg-[linear-gradient(180deg,rgba(10,16,29,0.96),rgba(6,11,21,0.94))]"),children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[(0,s.jsx)("div",{className:"min-w-0",children:(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("span",{className:w("inline-flex size-10 shrink-0 items-center justify-center rounded-full border shadow-[0_8px_24px_rgba(56,47,38,0.08)]",i?"border-[#e3ddd4] bg-white text-[#4c4640]":"border-white/10 bg-white/[0.05] text-slate-200 shadow-[0_16px_36px_rgba(0,0,0,0.28)]"),children:(0,s.jsx)(tT.A,{className:"h-4 w-4"})}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:w("text-[11px] uppercase tracking-[0.22em]",i?"text-[#7f6554]":"text-slate-500"),children:"Architect"}),(0,s.jsx)("h2",{className:w("truncate text-[18px] font-semibold tracking-[-0.02em]",i?"text-[#2d2118]":"text-white"),children:"Create workspace"}),(0,s.jsx)("p",{className:w("text-[13px]",i?"text-[#604c3f]":"text-slate-300"),children:"Talk to Architect once. Stay on the fast path or open the full blueprint without losing the draft."})]})]})}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsxs)("div",{className:w("inline-flex rounded-full border p-1",i?"border-[#e4ddd3] bg-[#f4efe7]":"border-white/10 bg-white/[0.04]"),children:[(0,s.jsx)(ad,{surfaceTheme:e,active:"basic"===t,label:"Basic",onClick:()=>a("basic")}),(0,s.jsx)(ad,{surfaceTheme:e,active:"advanced"===t,label:"Advanced",onClick:()=>a("advanced")})]}),(0,s.jsxs)("button",{type:"button",onClick:r,className:w("inline-flex h-9 items-center gap-2 rounded-full border px-3 text-[13px] transition-colors",i?"border-[#dfd8ce] bg-white text-[#38322d] hover:bg-[#f5f1ea]":"border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]"),children:[(0,s.jsx)(al.A,{className:"h-3.5 w-3.5"}),"New draft"]})]})]}),n.length>0?(0,s.jsx)("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:n.map(e=>(0,s.jsx)("span",{className:w("inline-flex items-center rounded-full border px-2.5 py-1 text-[10px] font-medium uppercase tracking-[0.16em]","success"===e.tone&&"border-emerald-200 bg-emerald-50 text-emerald-700","warning"===e.tone&&"border-amber-200 bg-amber-50 text-amber-700","danger"===e.tone&&"border-rose-200 bg-rose-50 text-rose-700",(!e.tone||"muted"===e.tone)&&(i?"border-[#e4ddd3] bg-white text-[#5f5348]":"border-white/10 bg-white/[0.05] text-slate-300")),children:e.label},e.id))}):null]})}function ad({surfaceTheme:e,active:t,label:a,onClick:r}){let n="light"===e;return(0,s.jsx)("button",{type:"button",onClick:r,className:w("inline-flex min-w-[92px] items-center justify-center rounded-full px-3 py-1.5 text-[13px] transition-colors",t?n?"bg-white text-[#151310] shadow-sm":"bg-[#0f1726] text-white shadow-[0_8px_18px_rgba(0,0,0,0.28)]":n?"text-[#6d584a] hover:text-[#2d2824]":"text-slate-400 hover:text-slate-100"),children:a})}var ac=a(9436);function ap({surfaceTheme:e,value:t,placeholder:a,onChange:r,onSubmit:n,disabled:l=!1,isBusy:o=!1,helperText:d,toolbar:c,className:p}){let u=(0,m.useRef)(null),h=!!t.trim()&&!l;(0,m.useEffect)(()=>{let e=u.current;e&&(e.style.height="0px",e.style.height=`${Math.min(e.scrollHeight,200)}px`)},[t]);let x=async e=>{e.preventDefault(),h&&await n()},g=async e=>{"Enter"!==e.key||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),h&&await n())},b="light"===e;return(0,s.jsxs)("form",{onSubmit:x,className:w("rounded-[24px] border p-3",b?"border-[#dfd9d1] bg-white shadow-[0_24px_80px_rgba(56,47,38,0.08)]":"border-white/10 bg-[rgba(7,12,22,0.92)] shadow-[0_24px_80px_rgba(0,0,0,0.38)]",p),children:[(0,s.jsx)("textarea",{ref:u,value:t,onChange:e=>r(e.target.value),onKeyDown:g,placeholder:a,className:w("min-h-[44px] max-h-[200px] w-full resize-none overflow-y-auto border-0 bg-transparent px-2 py-1 text-[15px] leading-6 outline-none",b?"text-[#191714] placeholder:text-[#9b948c]":"text-slate-100 placeholder:text-slate-500")}),(0,s.jsxs)("div",{className:"mt-2 flex flex-wrap items-center justify-between gap-3",children:[(0,s.jsxs)("div",{className:"flex min-h-8 items-center gap-2",children:[c,d?(0,s.jsx)("p",{className:w("text-[11px]",b?"text-[#8b837a]":"text-slate-400"),children:d}):null]}),(0,s.jsx)("button",{type:"submit",disabled:!h,className:w("inline-flex size-8 items-center justify-center rounded-full transition-colors disabled:cursor-not-allowed",b?"bg-[#161514] text-white hover:bg-[#26231f] disabled:bg-[#d5cec5] disabled:text-[#8d857c]":"bg-cyan-300 text-slate-950 hover:bg-cyan-200 disabled:bg-white/[0.08] disabled:text-slate-500"),children:o?(0,s.jsx)(i.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,s.jsx)(ac.A,{className:"h-3.5 w-3.5"})})]})]})}function am({surfaceTheme:e,messages:t,isTyping:a=!1,typingLabel:r="Typing…",emptyState:n,auxiliary:i,className:l}){let o=(0,m.useRef)(null);return(0,m.useEffect)(()=>{o.current?.scrollIntoView({block:"end"})},[a,t]),(0,s.jsx)(tZ,{className:w("h-full",l),children:(0,s.jsxs)("div",{className:"mx-auto flex min-h-full w-full max-w-4xl flex-col gap-5 px-2 py-4 md:gap-6 md:px-4",children:[n,i,t.map(t=>(0,s.jsx)(au,{message:t,surfaceTheme:e},t.id)),a?(0,s.jsx)(ah,{surfaceTheme:e,label:r}):null,(0,s.jsx)("div",{ref:o,className:"h-6 w-full shrink-0"})]})})}function au({message:e,surfaceTheme:t}){let a="light"===t;if("system"===e.role)return(0,s.jsxs)("div",{className:w("mx-auto w-full max-w-3xl rounded-[18px] border px-4 py-3 text-[13px] leading-6",a?"border-[#e3ddd4] bg-[#f5f0e8] text-[#5b544d]":"border-white/10 bg-white/[0.05] text-slate-300"),children:[(0,s.jsx)("p",{className:w("text-[11px] uppercase tracking-[0.18em]",a?"text-[#8b8074]":"text-slate-500"),children:e.author||"Workspace Wizard"}),(0,s.jsx)("p",{className:"mt-1",children:e.text})]});let r="user"===e.role,n="pending"===e.status;return(0,s.jsxs)("div",{className:w("flex w-full items-start gap-3",r?"justify-end":"justify-start"),children:[r?null:(0,s.jsx)("div",{className:w("mt-0.5 inline-flex size-8 shrink-0 items-center justify-center rounded-full border",a?"border-[#e6dfd4] bg-white text-[#5f5a53]":"border-white/10 bg-white/[0.05] text-slate-300"),children:"Architect"===e.author?(0,s.jsx)(tT.A,{className:"h-3.5 w-3.5"}):(0,s.jsx)(D.A,{className:"h-3.5 w-3.5"})}),(0,s.jsxs)("div",{className:w("max-w-[min(100%,720px)]",r?a?"rounded-[22px] bg-[#191714] px-4 py-2.5 text-white":"rounded-[22px] bg-cyan-300 px-4 py-2.5 text-slate-950":a?"px-0 py-0 text-[#1b1815]":"px-0 py-0 text-slate-100",n&&"opacity-75"),children:[!r&&e.author?(0,s.jsx)("p",{className:w("mb-1 text-[11px] uppercase tracking-[0.18em]",a?"text-[#8f857a]":"text-slate-500"),children:e.author}):null,(0,s.jsx)("p",{className:w("whitespace-pre-wrap text-[15px] leading-7",r&&"leading-6"),children:e.text})]})]})}function ah({surfaceTheme:e,label:t}){let a="light"===e;return(0,s.jsxs)("div",{className:"flex w-full items-start gap-3",children:[(0,s.jsx)("div",{className:w("mt-0.5 inline-flex size-8 shrink-0 items-center justify-center rounded-full border",a?"border-[#e6dfd4] bg-white text-[#5f5a53]":"border-white/10 bg-white/[0.05] text-slate-300"),children:(0,s.jsx)(tT.A,{className:"h-3.5 w-3.5"})}),(0,s.jsxs)("div",{className:"max-w-[min(100%,720px)]",children:[(0,s.jsx)("p",{className:w("mb-1 text-[11px] uppercase tracking-[0.18em]",a?"text-[#8f857a]":"text-slate-500"),children:"Architect"}),(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsxs)("div",{className:w("inline-flex items-center gap-1.5 rounded-full border px-3 py-2",a?"border-[#e6dfd5] bg-white text-[#5a534c]":"border-white/10 bg-white/[0.05] text-slate-300"),children:[(0,s.jsx)("span",{className:w("inline-flex size-1.5 animate-pulse rounded-full",a?"bg-[#5a534c]":"bg-slate-300")}),(0,s.jsx)("span",{className:w("inline-flex size-1.5 animate-pulse rounded-full [animation-delay:120ms]",a?"bg-[#5a534c]":"bg-slate-300")}),(0,s.jsx)("span",{className:w("inline-flex size-1.5 animate-pulse rounded-full [animation-delay:240ms]",a?"bg-[#5a534c]":"bg-slate-300")})]}),(0,s.jsx)("p",{className:w("text-[13px] leading-6",a?"text-[#6f685f]":"text-slate-400"),children:t})]})]})]})}function ax({surfaceTheme:e,chips:t,onSelect:a,disabled:r=!1,className:n}){if(0===t.length)return null;let i="light"===e;return(0,s.jsx)("div",{className:w("flex flex-wrap items-center gap-2",n),children:t.map(e=>(0,s.jsx)("button",{type:"button",onClick:()=>a(e),disabled:r,className:w("inline-flex min-h-8 items-center rounded-full border px-4 py-1.5 text-left text-[12px] transition-colors disabled:cursor-not-allowed disabled:opacity-50",i?"border-[#ddd7cf] bg-white text-[#4a443f] hover:border-[#cfc7bc] hover:bg-[#f3efe8]":"border-white/10 bg-white/[0.05] text-slate-200 hover:bg-white/[0.08] hover:text-white"),children:e.label},e.id))})}async function ag(e,t){if(!e.body)throw Error("The server did not return a readable stream.");let a=e.body.getReader(),s=new TextDecoder,r="";for(;;){let{value:e,done:n}=await a.read();if(n)break;let i=(r+=s.decode(e,{stream:!0})).indexOf("\n");for(;i>=0;){let e=r.slice(0,i).trim();r=r.slice(i+1),e&&await t(JSON.parse(e)),i=r.indexOf("\n")}}let n=r.trim();n&&await t(JSON.parse(n))}let ab={founder:"Founder",product:"Product Lead",architect:"System Architect",ops:"Operations",growth:"Growth",reviewer:"Reviewer"},af={small:{label:"Small",agentCount:1,workflowCount:1,automationCount:0,externalChannelCount:0,confirmationLimit:1,suggestedReplyLimit:2},medium:{label:"Medium",agentCount:3,workflowCount:3,automationCount:1,externalChannelCount:0,confirmationLimit:2,suggestedReplyLimit:3},large:{label:"Large",agentCount:5,workflowCount:4,automationCount:2,externalChannelCount:1,confirmationLimit:3,suggestedReplyLimit:4}};function aw(e){return af[e]??af.medium}let ay={internal:{label:"Internal",requiresCredentials:!1,credentials:[]},slack:{label:"Slack",requiresCredentials:!0,credentials:[{key:"botToken",label:"Bot token",placeholder:"xoxb-...",secret:!0}]},telegram:{label:"Telegram",requiresCredentials:!0,credentials:[{key:"token",label:"Bot token",placeholder:"123456:ABC...",secret:!0}]},discord:{label:"Discord",requiresCredentials:!0,credentials:[{key:"token",label:"Bot token",placeholder:"Discord bot token",secret:!0}]},googlechat:{label:"Google Chat",requiresCredentials:!0,credentials:[{key:"webhookUrl",label:"Webhook URL",placeholder:"https://chat.googleapis.com/...",secret:!0}]}};function av(){return globalThis.crypto?.randomUUID?.()??`plan-${Date.now()}`}function aj(e,t,a){return{id:av(),role:e,author:t,text:a,createdAt:new Date().toISOString()}}function ak(e){return{id:e.id?.trim()||av(),kind:e.kind,label:e.label.trim(),summary:e.summary.trim(),details:aV(e.details),status:e.status??"ready",createdAt:e.createdAt??new Date().toISOString(),url:aB(e.url),error:aB(e.error)}}function aN(e){return{id:e.id?.trim()||av(),section:e.section,label:e.label.trim(),value:e.value.trim(),confidence:Math.max(0,Math.min(100,Math.round(e.confidence??72))),status:e.status??"inferred",rationale:aW(e.rationale??""),sourceLabels:aV(e.sourceLabels)}}function aC(e){let t=aJ(e?.id||e?.name||"operator")||"operator",a=e?.role?.trim()||"Operator",s=e?.name?.trim()||aG(t);return{id:t,role:a,name:s,purpose:e?.purpose?.trim()||`${s} owns ${a.toLowerCase()} execution and handoffs.`,enabled:e?.enabled!==!1,isPrimary:!!e?.isPrimary,emoji:e?.emoji?.trim(),theme:e?.theme?.trim(),skillId:e?.skillId?.trim(),modelId:e?.modelId?.trim(),policy:e?.policy??ek("worker"),heartbeat:e?.heartbeat??{enabled:!1},responsibilities:aV(e?.responsibilities),outputs:aV(e?.outputs)}}function aS(e){return{id:aJ(e?.id||e?.name||`workflow-${Date.now()}`)||`workflow-${Date.now()}`,name:e?.name?.trim()||"New workflow",goal:e?.goal?.trim()||"",trigger:e?.trigger??"manual",ownerAgentId:e?.ownerAgentId?.trim(),collaboratorAgentIds:aV(e?.collaboratorAgentIds),successDefinition:e?.successDefinition?.trim()||"",outputs:aV(e?.outputs),channelIds:aV(e?.channelIds),enabled:e?.enabled!==!1}}function aA(e="internal",t){let a=ay[e];return{id:aJ(t?.id||t?.name||`${e}-${Date.now()}`)||`${e}-${Date.now()}`,type:e,name:t?.name?.trim()||a.label,purpose:t?.purpose?.trim()||"",target:t?.target?.trim(),enabled:t?.enabled!==!1,announce:!!t?.announce,requiresCredentials:a.requiresCredentials,credentials:t?.credentials?.map(e=>({...e,value:e.value??""}))??a.credentials.map(e=>({...e,value:""}))}}function aI(e){return{id:aJ(e?.id||e?.name||`automation-${Date.now()}`)||`automation-${Date.now()}`,name:e?.name?.trim()||"New automation",description:e?.description?.trim()||"",enabled:e?.enabled!==!1,scheduleKind:e?.scheduleKind??"every",scheduleValue:e?.scheduleValue?.trim()||"24h",agentId:e?.agentId?.trim(),mission:e?.mission?.trim()||"",thinking:e?.thinking??"medium",announce:!!e?.announce,channelId:e?.channelId?.trim()}}function aT(e){return(function(e,t){let a=t9[e];if("solo"===t){let e=a.find(e=>e.isPrimary)??a[0];return[{...e,name:"Builder"===e.role?"Default Agent":e.name,policy:ek("browser"===e.id?"browser":"worker"),enabled:!0}]}return a.map(e=>({id:e.id,role:e.role,name:e.name,emoji:e.emoji,theme:e.theme,skillId:e.skillId,modelId:e.modelId,isPrimary:!!e.isPrimary,policy:ek("browser"===e.id?"browser":"worker"),enabled:!0}))})(e,"core").map(t=>{var a,s,r,n,i,l,o;return aC({id:t.id,role:t.role,name:t.name,purpose:(a=t.id,s=t.role,r=e,/review/i.test(a)||/review/i.test(s)?`Pressure-test ${r} work for correctness, regression risk, and missing validation.`:/test/i.test(a)||/test/i.test(s)?`Validate behavior, environment assumptions, and release confidence for this ${r} workspace.`:/learn/i.test(a)||/learn/i.test(s)?"Keep the workspace memory, conventions, and durable decisions coherent over time.":/browser/i.test(a)||/browser/i.test(s)?"Exercise real UI flows and collect evidence for browser-facing work.":`Own hands-on delivery and keep the ${r} workspace moving.`),enabled:t.enabled,isPrimary:t.isPrimary,emoji:t.emoji,theme:t.theme,skillId:t.skillId,modelId:t.modelId,policy:t.policy??ek("worker"),heartbeat:t.heartbeat??{enabled:!1},responsibilities:(n=t.id,i=e,/review/i.test(n)?["Review active work","Call out regressions","Protect launch quality"]:/test/i.test(n)?["Run verification loops","Capture evidence","Surface failing assumptions"]:/learn/i.test(n)?["Update durable memory","Track decisions","Reduce restart friction"]:/browser/i.test(n)?["Exercise flows","Capture screenshots","Validate responsive states"]:"content"===i?["Drive content production","Coordinate handoffs","Prepare launch artifacts"]:["Implement the next increment","Coordinate specialists","Keep execution momentum"]),outputs:(l=t.id,o=e,/review/i.test(l)?["review notes","risk checklist"]:/test/i.test(l)?["verification report","repro steps"]:/learn/i.test(l)?["memory updates","decision log entries"]:/browser/i.test(l)?["screenshots","browser validation notes"]:"research"===o?["research summary","evidence log"]:["implementation artifacts","handoff summary"])})})}function a$(e,t){let a=t.find(e=>e.enabled&&e.isPrimary)?.id,s=az(t,"review"),r=az(t,"test"),n=az(t,"learn"),i=az(t,"browser");if("research"===e)return[aS({id:"research-loop",name:"Research loop",goal:"Turn the main question into evidence-backed findings and explicit unknowns.",trigger:"manual",ownerAgentId:a,collaboratorAgentIds:[n,s].filter(Boolean),successDefinition:"Question, evidence, synthesis, and next-step recommendations are documented.",outputs:["docs/research-plan.md","deliverables/<run>/research-summary.md"]}),aS({id:"finding-review",name:"Finding review",goal:"Pressure-test claims before publishing or acting on them.",trigger:"manual",ownerAgentId:s??a,collaboratorAgentIds:[a].filter(Boolean),successDefinition:"Assumptions, risks, and evidence gaps are explicit.",outputs:["deliverables/<run>/review-notes.md"]})];if("content"===e)return[aS({id:"strategy",name:"Strategy and briefing",goal:"Clarify audience, offer, channels, and campaign bets before production.",trigger:"manual",ownerAgentId:a,collaboratorAgentIds:[s,n].filter(Boolean),successDefinition:"The team agrees on brief, priorities, and success signals.",outputs:["docs/content-brief.md","deliverables/<run>/campaign-brief.md"]}),aS({id:"production",name:"Production and QA",goal:"Create assets, review them, and prepare a launch package.",trigger:"manual",ownerAgentId:a,collaboratorAgentIds:[s].filter(Boolean),successDefinition:"Assets are approved and delivery-ready.",outputs:["deliverables/<run>/drafts/","deliverables/<run>/launch-package.md"]}),aS({id:"performance-loop",name:"Performance loop",goal:"Review outcomes, learn from results, and feed the next iteration.",trigger:"cron",ownerAgentId:n??s??a,collaboratorAgentIds:[a].filter(Boolean),successDefinition:"Measured results and next changes are documented.",outputs:["deliverables/<run>/performance-review.md"]})];let l=i&&"frontend"===e?i:a;return[aS({id:"scope-v1",name:"V1 shaping",goal:"Turn the product goal into a constrained first delivery batch.",trigger:"manual",ownerAgentId:a,collaboratorAgentIds:[n,s].filter(Boolean),successDefinition:"Scope, non-goals, and critical path are documented.",outputs:["docs/brief.md","memory/blueprint.md"]}),aS({id:"delivery",name:"Delivery loop",goal:"Implement, validate, and hand off the next meaningful increment.",trigger:"manual",ownerAgentId:l,collaboratorAgentIds:[r,s].filter(Boolean),successDefinition:"A tested increment ships with review notes and clear handoff.",outputs:["deliverables/<run>/release-notes.md","deliverables/<run>/verification.md"]}),aS({id:"launch-readiness",name:"Launch readiness",goal:"Check blockers, rollback posture, and communication before launch.",trigger:"launch",ownerAgentId:s??a,collaboratorAgentIds:[r,n].filter(Boolean),successDefinition:"Launch risks, open blockers, and go/no-go signal are explicit.",outputs:["deliverables/<run>/launch-checklist.md"]})]}function a_(){return[aA("internal",{id:"internal-ops",name:"Internal ops",purpose:"Default internal coordination surface for planner outputs and deploy notes.",announce:!1})]}function aO(e){var t,a,s,r,n,i,l,o,d,c,p,m,u,h,x,g,b,f,w,y,v,j,k,N,C,S,A;let I,T,$,_,O,R,M,P,E,D,L,U,z,F,W,B,V,q,K,J,G=aK(e);if(G.runtime=(t=G.id,a=G.runtime,F=a?.architectSessionId?.trim()||`planner-${t}-architect`,W=Object.fromEntries(Object.entries(a?.advisorAgentIds??{}).filter(([,e])=>"string"==typeof e&&e.trim())),B=Object.fromEntries(Object.entries(ab).map(([e])=>[e,a?.advisorSessionIds?.[e]?.trim()||`planner-${t}-${e}`])),{mode:a?.mode==="fallback"?"fallback":"agent",status:a?.status==="error"?"error":a?.status==="ready"?"ready":"pending",workspaceId:aB(a?.workspaceId),workspacePath:aB(a?.workspacePath),architectAgentId:aB(a?.architectAgentId),architectSessionId:F,advisorAgentIds:W,advisorSessionIds:B,lastArchitectRunId:aB(a?.lastArchitectRunId),lastAdvisorRunIds:aV(a?.lastAdvisorRunIds),lastError:aB(a?.lastError)}),G.intake=(s={...G.intake,started:!!G.intake?.started||G.conversation.some(e=>"user"===e.role)},{started:!!s?.started,initialPrompt:aW(s?.initialPrompt??""),latestPrompt:aW(s?.latestPrompt??""),sources:(s?.sources??[]).map(e=>ak(e)),confirmations:aV(s?.confirmations).map(e=>e.trim()).filter(Boolean).slice(0,3),mode:s?.mode==="advanced"?"advanced":"guided",size:s?.size==="small"||s?.size==="large"?s.size:"medium",reviewRequested:!!s?.reviewRequested,turnCount:Math.max(0,Math.floor(s?.turnCount??0)),inferences:(s?.inferences??[]).map(e=>aN(e)),suggestedReplies:aV(s?.suggestedReplies).slice(0,4)}),G.company.name=aW(G.company.name),G.company.mission=aW(G.company.mission),G.company.targetCustomer=aW(G.company.targetCustomer),G.company.constraints=aV(G.company.constraints),G.company.successSignals=aV(G.company.successSignals),G.product.offer=aW(G.product.offer),G.product.scopeV1=aV(G.product.scopeV1),G.product.nonGoals=aV(G.product.nonGoals),G.product.revenueModel=aW(G.product.revenueModel),G.product.launchPriority=aV(G.product.launchPriority),G.workspace.name=aW(G.workspace.name),G.workspace.directory=aB(G.workspace.directory),G.workspace.repoUrl=aB(G.workspace.repoUrl),G.workspace.existingPath=aB(G.workspace.existingPath),G.workspace.stackDecisions=aV(G.workspace.stackDecisions),G.workspace.docs=aq(aV(G.workspace.docs).concat((r=G.workspace.template,n=G.workspace.rules,V=["AGENTS.md","SOUL.md","IDENTITY.md","TOOLS.md","HEARTBEAT.md"],n.generateMemory&&V.push("MEMORY.md","memory/blueprint.md","memory/decisions.md"),n.generateStarterDocs&&V.push("docs/brief.md","docs/architecture.md","deliverables/README.md"),"frontend"===r&&V.push("docs/ux-notes.md"),"backend"===r&&V.push("docs/service-map.md"),"research"===r&&V.push("docs/research-plan.md"),"content"===r&&V.push("docs/content-brief.md"),V))),G.team.persistentAgents=G.team.persistentAgents.map(e=>aC({...e,id:e.id,role:e.role,name:e.name,purpose:e.purpose,enabled:e.enabled,isPrimary:e.isPrimary,emoji:e.emoji,theme:e.theme,skillId:e.skillId,modelId:e.modelId,policy:e.policy,heartbeat:e.heartbeat,responsibilities:e.responsibilities,outputs:e.outputs})).filter((e,t,a)=>a.findIndex(t=>t.id===e.id)===t),0===G.team.persistentAgents.length&&(G.team.persistentAgents=aT(G.workspace.template)),!G.team.persistentAgents.some(e=>e.enabled&&e.isPrimary)){let e=G.team.persistentAgents.find(e=>e.enabled);e&&(e.isPrimary=!0)}if(G.operations.channels=G.operations.channels.map(e=>aA(e.type,e)).filter((e,t,a)=>a.findIndex(t=>t.id===e.id)===t),0===G.operations.channels.length&&(G.operations.channels=a_()),G.operations.workflows=G.operations.workflows.map(e=>aS(e)).filter((e,t,a)=>a.findIndex(t=>t.id===e.id)===t),0===G.operations.workflows.length&&(G.operations.workflows=a$(G.workspace.template,G.team.persistentAgents)),G.operations.automations=G.operations.automations.map(e=>aI(e)).filter((e,t,a)=>a.findIndex(t=>t.id===e.id)===t),K=aw((q=aK(G)).intake.size),q.team.persistentAgents=function(e,t,a){var s;let r,n;if(a<=0)return[];return aF((n=(s=[...t,...aT(e),...(r=aC({id:"ops-lead",role:"Operations Lead",name:"Operations Lead",purpose:"Own automations, reporting cadence, and cross-agent handoffs for the workspace.",responsibilities:["Maintain the operating cadence","Wire recurring automations","Keep handoffs durable"],outputs:["ops brief","automation notes"]}),"research"===e?[aC({id:"analyst",role:"Analyst",name:"Analyst",purpose:"Turn gathered evidence into patterns, themes, and decision-ready summaries.",responsibilities:["Cluster findings","Spot repeated signals","Prepare concise summaries"],outputs:["insight summary","theme map"]}),r]:[r])]).find(e=>e.isPrimary)??s[0])?[n,...s.filter(e=>e.id!==n.id)]:s).slice(0,a).map((e,t)=>aC({...e,enabled:!0,isPrimary:e.isPrimary||0===t}))}(q.workspace.template,q.team.persistentAgents,K.agentCount),q.operations.channels=function(e,t,a){let s=t.find(e=>"internal"===e.type)??a_()[0],r=[...t.filter(e=>"internal"!==e.type),...("content"===e?["telegram","discord","slack"]:["slack","discord","telegram"]).map(t=>aA(t,{id:`${t}-ops`,purpose:"content"===e?"Optional distribution or community surface for a larger operating setup.":"Optional external operating surface for a larger workspace.",enabled:!1,announce:!0}))].filter((e,t,a)=>a.findIndex(t=>t.type===e.type)===t);return[aA("internal",{...s,enabled:!0}),...r.slice(0,a)]}(q.workspace.template,q.operations.channels,K.externalChannelCount),q.operations.workflows=function(e,t,a,s){let r,n,i,l;return s<=0?[]:aF([...t,...a$(e,a),...(r=a.find(e=>e.enabled&&e.isPrimary)?.id,n=az(a,"review"),i=az(a,"learn"),l=az(a,"ops"),[aS({id:"context-sync",name:"research"===e?"Evidence sync":"Context sync",goal:"Pull new context from linked sources and keep the blueprint aligned with reality.",trigger:"manual",ownerAgentId:i??r,collaboratorAgentIds:[r,n].filter(Boolean),successDefinition:"New context is reflected in durable docs, scope, and decision notes.",outputs:["memory/blueprint.md","deliverables/<run>/context-sync.md"]}),aS({id:"ops-rhythm",name:"Operating rhythm",goal:"Review handoffs, automations, and next-step ownership on a repeatable cadence.",trigger:"cron",ownerAgentId:l??n??i??r,collaboratorAgentIds:[r].filter(Boolean),successDefinition:"The workspace has a fresh operator brief and an explicit next batch of work.",outputs:["deliverables/<run>/ops-rhythm.md"]})])]).slice(0,s).map(e=>{var t,s;let r,n,i,l,o;return t=e,r=new Set((s=a).filter(e=>e.enabled).map(e=>e.id)),n=s.find(e=>e.enabled&&e.isPrimary)?.id,i=az(s,"review"),l=az(s,"learn"),o=t.ownerAgentId&&r.has(t.ownerAgentId)?t.ownerAgentId:i??l??n,aS({...t,ownerAgentId:o,collaboratorAgentIds:t.collaboratorAgentIds.filter(e=>r.has(e)&&e!==o),enabled:!0})})}(q.workspace.template,q.operations.workflows,q.team.persistentAgents,K.workflowCount),q.operations.automations=function(e,t,a,s,r){let n,i,l;return r<=0?[]:aF([...t,...(n=az(a,"review")??a.find(e=>e.enabled)?.id,i=az(a,"learn")??n,[aI({id:"daily-triage",name:"Daily triage",description:"Review drift, blockers, and next handoffs every day.",scheduleKind:"every",scheduleValue:"24h",agentId:n,mission:"content"===e?"Review active campaigns, blockers, and next content handoffs. Leave a concise operator brief.":"Inspect the workspace, surface blockers, and leave a concise next-step handoff for the team.",thinking:"medium",channelId:l=s[0]?.id}),aI({id:"weekly-review",name:"Weekly review",description:"Capture progress, decisions, and next bets once per week.",scheduleKind:"every",scheduleValue:"168h",agentId:i,mission:"research"===e?"Summarize evidence gathered this week, open questions, and the next investigation batch.":"Summarize progress, major decisions, and the next delivery batch for this workspace.",thinking:"high",channelId:l})].filter(e=>e.agentId))]).slice(0,r).map(e=>{var t,r,n;let i,l,o,d,c;return t=e,r=a,n=s,i=new Set(r.filter(e=>e.enabled).map(e=>e.id)),l=new Set(n.map(e=>e.id)),o=r.find(e=>e.enabled&&e.isPrimary)?.id,d=az(r,"review"),c=az(r,"learn"),aI({...t,agentId:t.agentId&&i.has(t.agentId)?t.agentId:d??c??o,channelId:t.channelId&&l.has(t.channelId)?t.channelId:n[0]?.id,enabled:!0})})}(q.workspace.template,q.operations.automations,q.team.persistentAgents,q.operations.channels,K.automationCount),(G=q).operations.hooks=G.operations.hooks.map(e=>({id:aJ(e?.id||e?.name||`hook-${Date.now()}`)||`hook-${Date.now()}`,name:e?.name?.trim()||"New hook",source:e?.source?.trim()||"",enabled:e?.enabled!==!1,notes:e?.notes?.trim()||""})).filter((e,t,a)=>a.findIndex(t=>t.id===e.id)===t),G.operations.sandbox=(i=G.operations.sandbox,{workspaceOnly:i?.workspaceOnly??!0,mode:i?.mode??"default",notes:aV(i?.notes)}),G.deploy.firstMissions=(J=(l=G).team.persistentAgents.find(e=>e.enabled&&e.isPrimary),aq([J?"Inspect the new workspace, refine docs to match the blueprint, and break the first delivery batch into concrete tasks.":"",l.team.persistentAgents.find(e=>/review/i.test(e.role)&&e.enabled)?"Review the blueprint against the created workspace, call out execution risks, and leave a launch-readiness checklist.":"",l.team.persistentAgents.find(e=>/learn/i.test(e.role)&&e.enabled)?"Capture durable facts, decisions, and conventions in memory files so the team can continue without drift.":""].filter(Boolean))),!G.company.name&&G.workspace.name&&(G.company.name=G.workspace.name),!G.workspace.name&&G.company.name&&(G.workspace.name=G.company.name),!G.intake.started)return G.deploy.blockers=[],G.deploy.warnings=[],G.intake.confirmations=[],G.intake.inferences=[],G.intake.suggestedReplies=[],G.readinessScore=0,G.architectSummary="Start with one prompt. Paste the project goal, website URL, repo, or existing folder and the architect will draft the workspace for you.",G.stage="intake",G.status="draft",G.updatedAt=new Date().toISOString(),G;let H=function(e){var t;let a,s,r=aR(e),n=[],i=aw(e.intake.size),l=e.intake.sources.some(e=>"website"===e.kind&&"ready"===e.status),o=aM(e),d=!!(e.company.mission&&e.company.targetCustomer&&(e.product.offer||e.product.scopeV1.length>0));for(let i of(e.company.name||n.push("tr"===r?"Şirkete ya da workspace'e ne ad verelim?":"What should I call the company or workspace?"),e.company.mission||n.push("tr"===r?"Bu workspace \xf6nce tam olarak hangi \xe7ıktıyı optimize etmeli?":"What exact outcome should this workspace optimize for first?"),e.company.targetCustomer||n.push((a=aR(t=e),(s=aP(t))?"tr"===a?`İlk hedef kitleyi ${s} olarak okuyorum. Bunu koruyalım mı, yoksa daha doğru segmenti sen mi g\xf6stereceksin?`:`I can read the first audience as ${s}. Keep that, or point me to the better segment?`:"content"===t.workspace.template?t.operations.channels.some(e=>"telegram"===e.type&&e.enabled)?"tr"===a?"İlk kullanıcı topluluk y\xf6neticileri, moderat\xf6rler ya da Telegram \xfcyeleri mi olmalı?":"Should the first user be community managers, moderators, or Telegram members?":"tr"===a?"Bu i\xe7erik ya da topluluk workspace'i \xf6nce kime hizmet etmeli?":"Who should this content or community workspace serve first?":"research"===t.workspace.template?"tr"===a?"Bu araştırma workspace'i i\xe7in ilk karar verici ya da hedef kitle kim?":"Who is the first decision-maker or audience for this research workspace?":"tr"===a?"İlk kullanıcı ya da m\xfcşteri segmenti kim?":"Who is the first user or customer segment?")),e.workspace.repoUrl||e.workspace.existingPath||!(e.intake.turnCount<=1)||aE(e.intake.latestPrompt||e.intake.initialPrompt)||n.push("tr"===r?"Buna sıfırdan mı başlayalım, bir repo mu klonlayalım, yoksa mevcut bir klas\xf6r\xfc m\xfc bağlayalım?":"Should this start from scratch, clone a repo, or attach an existing folder?"),e.company.mission&&e.company.targetCustomer&&0===e.product.scopeV1.length?n.push("tr"===r?"İlk \xe7ıkaracağımız en k\xfc\xe7\xfck V1 sonucu ne olmalı?":"What is the smallest V1 outcome we should launch first?"):0===e.product.nonGoals.length&&d&&e.product.scopeV1.length>0&&("advanced"===e.intake.mode||e.intake.reviewRequested||e.intake.turnCount>=4)&&n.push("tr"===r?"V1 i\xe7in neleri \xf6zellikle kapsam dışında bırakalım?":"What should stay explicitly out of scope for V1?"),e.company.mission&&(e.product.scopeV1.length>0||l||o.length>0)&&0===e.company.successSignals.length&&("advanced"===e.intake.mode||e.intake.reviewRequested||e.intake.turnCount>=3)&&n.push("tr"===r?"Bu workspace'in işe yaradığını bize hangi sinyal g\xf6stermeli?":"What signal should tell us this workspace is working?"),e.intake.sources.filter(e=>"error"===e.status)))n.push("tr"===r?`${i.label} kaynağını inceleyemedim. Bu kaynak \xf6nemliyse şirket bağlamını manuel olarak doğrula.`:`I could not inspect ${i.label}. Confirm the company context manually if this source matters.`);return aq(n).slice(0,Math.min(l?2:3,i.confirmationLimit))}(G),Z=function(e){let t=[];for(let a of(e.company.name||t.push("Company or workspace name is missing."),e.company.mission||t.push("Mission is missing."),e.company.targetCustomer||t.push("Target customer is missing."),e.workspace.name||t.push("Workspace name is missing."),"clone"!==e.workspace.sourceMode||e.workspace.repoUrl||t.push("Clone mode needs a repository URL."),"existing"!==e.workspace.sourceMode||e.workspace.existingPath||t.push("Existing-folder mode needs a folder path."),e.team.persistentAgents.some(e=>e.enabled)||t.push("At least one persistent agent must be enabled."),e.team.persistentAgents.some(e=>e.enabled&&e.isPrimary)||t.push("One enabled agent must be marked as primary."),e.operations.workflows.some(e=>e.enabled)||t.push("At least one enabled workflow is required."),e.operations.workflows.filter(e=>e.enabled)))a.name&&a.goal&&a.successDefinition||t.push(`Workflow "${a.name||a.id}" is incomplete.`),a.ownerAgentId&&!e.team.persistentAgents.some(e=>e.id===a.ownerAgentId&&e.enabled)&&t.push(`Workflow "${a.name}" points to a missing or disabled owner agent.`);for(let a of e.operations.automations.filter(e=>e.enabled))a.mission&&a.scheduleValue||t.push(`Automation "${a.name}" is incomplete.`),a.agentId&&!e.team.persistentAgents.some(e=>e.id===a.agentId&&e.enabled)&&t.push(`Automation "${a.name}" points to a missing or disabled agent.`);for(let a of e.operations.channels.filter(e=>e.enabled&&e.requiresCredentials))a.credentials.filter(e=>!e.value.trim()).length>0&&t.push(`Channel "${a.name}" is missing required credentials.`);return aq(t)}(G),Q=(I=[],T=aw((o=G).intake.size),0===o.product.nonGoals.length&&I.push("No non-goals are defined for V1."),0===o.product.launchPriority.length&&I.push("Launch priorities are not ordered yet."),0===o.company.successSignals.length&&I.push("Success signals are still empty."),0===o.workspace.stackDecisions.length&&"content"!==o.workspace.template&&I.push("Critical stack decisions are not captured yet."),T.automationCount>0&&!o.operations.automations.some(e=>e.enabled)&&I.push("No automation loops are enabled."),T.externalChannelCount>0&&!o.operations.channels.some(e=>"internal"!==e.type)&&I.push("Only internal channels are configured."),T.agentCount>=3&&o.team.maxParallelRuns<2&&I.push("Parallel run limit is conservative for a multi-agent workspace."),aq(I)),Y=(d=G).intake.reviewRequested||"deploying"===d.status||"deployed"===d.status;return G.intake.confirmations=H,G.intake.inferences=($=[],_=(c=G).intake.sources.filter(e=>"ready"===e.status).map(e=>e.label),O=c.intake.confirmations.join(" ").toLowerCase(),c.company.name&&$.push(aN({section:"company",label:"Company",value:c.company.name,confidence:aD(c,"company-name"),status:aL(O,"company"),rationale:_.length>0?"Derived from linked context and the current brief.":"Derived from the current brief.",sourceLabels:_})),c.company.mission&&$.push(aN({section:"company",label:"Mission",value:c.company.mission,confidence:aD(c,"mission"),status:aL(O,"outcome"),rationale:"Architect condensed the first business outcome from the request.",sourceLabels:_})),c.company.targetCustomer&&$.push(aN({section:"company",label:"First audience",value:c.company.targetCustomer,confidence:aD(c,"target-customer"),status:aL(O,"audience"),rationale:"This is the current best guess for the first user or buyer segment.",sourceLabels:_})),$.push(aN({section:"workspace",label:"Workspace type",value:aG(c.workspace.template),confidence:aD(c,"template"),status:"inferred",rationale:"Template is inferred from the requested operating model and linked context.",sourceLabels:_})),$.push(aN({section:"workspace",label:"Starting point",value:"clone"===c.workspace.sourceMode?c.workspace.repoUrl||"Clone an existing repository":"existing"===c.workspace.sourceMode?c.workspace.existingPath||"Attach an existing folder":"Start from scratch",confidence:aD(c,"source-mode"),status:aL(O,"start"),rationale:"This is how the workspace will be materialized when you deploy.",sourceLabels:_})),c.product.offer&&$.push(aN({section:"product",label:"Offer",value:c.product.offer,confidence:aD(c,"offer"),status:"inferred",rationale:"Architect turned the brief into a concrete operator-facing offer.",sourceLabels:_})),(R=c.operations.channels.filter(e=>e.enabled&&"internal"!==e.type)).length>0&&$.push(aN({section:"operations",label:"External channels",value:R.map(e=>e.name).join(", "),confidence:aD(c,"channels"),status:"inferred",rationale:"The request implies these operating channels should exist after deploy.",sourceLabels:_})),(M=c.team.persistentAgents.find(e=>e.enabled&&e.isPrimary))&&$.push(aN({section:"team",label:"Primary operator",value:`${M.name} (${M.role})`,confidence:aD(c,"team"),status:"inferred",rationale:"Architect drafted a primary agent to own the first delivery loop.",sourceLabels:_})),(P=c.operations.workflows.find(e=>e.enabled))&&$.push(aN({section:"operations",label:"First workflow",value:P.name,confidence:aD(c,"workflow"),status:"inferred",rationale:"This is the first operational loop the company would run after deploy.",sourceLabels:_})),$.slice(0,8)),G.intake.suggestedReplies=(p=G,m=H,E=aR(p),D=[],L=aw(p.intake.size),U=aP(p),p.company.targetCustomer||(U&&D.push("tr"===E?`İlk hedef kitle ${aU(U)} gibi g\xf6r\xfcn\xfcyor.`:`The first audience looks like ${aU(U)}.`),"content"===p.workspace.template?(D.push("tr"===E?"İlk kullanıcılar topluluk y\xf6neticileri ve moderat\xf6rler.":"The first users are community managers and moderators."),D.push("tr"===E?"İlk kullanıcılar daha hızlı moderasyon ve onboarding isteyen Telegram \xfcyeleri.":"The first users are Telegram members who need faster moderation and onboarding.")):D.push("tr"===E?"İlk kullanıcılar bu iş akışını her g\xfcn y\xfcr\xfcten operat\xf6rler.":"The first users are the operators running this workflow every day.")),p.company.mission||D.push("tr"===E?"İlk hedef, hacmi en y\xfcksek manuel iş akışını otomatikleştirmek.":"The first outcome is automating the highest-volume manual workflow."),!p.product.scopeV1.length&&p.company.mission&&p.company.targetCustomer&&D.push("tr"===E?"V1, genişlemeden \xf6nce en dar ama faydalı d\xf6ng\xfcy\xfc u\xe7tan uca \xe7\xf6zmeli.":"V1 should handle the narrowest useful loop end to end before we expand."),p.workspace.repoUrl||p.workspace.existingPath||aE(p.intake.latestPrompt||p.intake.initialPrompt)||(D.push("tr"===E?"Şimdilik sıfırdan başlayalım.":"Start from scratch for now."),D.push("tr"===E?"İyi bir temel bulursak mevcut bir repository klonlayabiliriz.":"Clone an existing repository if you find a good base.")),0===p.company.successSignals.length&&p.intake.turnCount>=2&&D.push("tr"===E?"Başarı; daha az manuel iş, daha hızlı yanıt s\xfcreleri ve daha net bir operasyon ritmi demek.":"Success means less manual work, faster response times, and a clearer operating cadence."),0===m.length&&(D.push("tr"===E?"Gelişmiş edit\xf6r\xfc a\xe7.":"Open the advanced editor."),D.push("tr"===E?"Deploy review aşamasına ge\xe7.":"Move into deploy review.")),aq(D).slice(0,L.suggestedReplyLimit)),G.deploy.blockers=Y?Z:[],G.deploy.warnings=Y?Q:[],G.readinessScore=(u=G,h=Z,x=Q,g=Y,z=14,u.company.name&&(z+=10),u.company.mission&&(z+=15),u.company.targetCustomer&&(z+=15),u.product.offer&&(z+=10),u.product.scopeV1.length>0&&(z+=10),u.workspace.name&&(z+=10),u.intake.sources.length>0&&(z+=6),u.team.persistentAgents.some(e=>e.enabled&&e.isPrimary)&&(z+=10),u.operations.workflows.some(e=>e.enabled)&&(z+=10),u.operations.automations.some(e=>e.enabled)&&(z+=5),g?(z-=12*h.length,z-=3*x.length):z-=4*Math.max(0,u.intake.confirmations.length-1),Math.max(0,Math.min(100,z))),G.architectSummary=function(e,t,a,s){let r=aR(e),n=aw(e.intake.size);if(!e.intake.started)return"tr"===r?`Tek bir mesajla başla. ${n.label} modunda sohbet yalın kalır; Architect ise arka planda proje bağlamını toplar, ekibi taslaklar ve workspace blueprint'ini hazırlar.`:`Start with one prompt. ${n.label} mode keeps the chat lean while the architect still harvests full project context, drafts the team, and prepares the workspace blueprint.`;let i=e.team.persistentAgents.filter(e=>e.enabled).length,l=e.operations.workflows.filter(e=>e.enabled).length,o=e.operations.automations.filter(e=>e.enabled).length,d=e.intake.confirmations.length;return s?"tr"===r?[e.company.mission?`${e.company.name||e.workspace.name||"Bu şirket"} ${e.company.mission} hedefi etrafında konumlandı.`:"Şirket misyonu i\xe7in h\xe2l\xe2 kısa ve net bir c\xfcmle gerekiyor.",e.company.targetCustomer?`Birincil hedef kitle: ${e.company.targetCustomer}.`:"Hedef m\xfcşteri h\xe2l\xe2 eksik.",`${i} agent, ${l} g\xf6rev ve ${o} automation yapılandırıldı.`,d>0?`Senden ${d} doğrulama daha gerekiyor.`:t.length>0?`Deploy \xf6ncesi ${t.length} blocker kaldı.`:a.length>0?`G\xf6zden ge\xe7irilmesi gereken ${a.length} warning var.`:"Kritik blocker kalmadı."].join(" "):[e.company.mission?`${e.company.name||e.workspace.name||"This company"} is pointed at ${e.company.mission}.`:"The company mission still needs a concise sentence.",e.company.targetCustomer?`Primary audience: ${e.company.targetCustomer}.`:"Target customer is still missing.",`${i} agents, ${l} tasks, and ${o} automations are configured.`,d>0?`${d} confirmation item${1===d?"":"s"} still need your input.`:t.length>0?`${t.length} blocker${1===t.length?"":"s"} remain before deploy.`:a.length>0?`${a.length} warning${1===a.length?"":"s"} remain to review.`:"No hard blockers remain."].join(" "):"tr"===r?[e.company.mission?`${e.company.name||e.workspace.name||"Bu workspace"} i\xe7in odak alanı ${e.company.mission}.`:e.company.name||e.workspace.name?`${e.company.name||e.workspace.name} i\xe7in ilk operasyonel \xe7ıktıyı şekillendiriyorum.`:"Bu workspace i\xe7in ilk somut \xe7ıktıyı h\xe2l\xe2 netleştiriyorum.",e.company.targetCustomer?`İlk hedef kitle: ${e.company.targetCustomer}.`:"İlk kullanıcı ya da hedef segmenti h\xe2l\xe2 netleştirmem gerekiyor.",e.intake.sources.length>0?`${e.intake.sources.length} bağlam kaynağını zaten topladım.`:"Bir website, repo ya da kısa bir brief ver; ilk taslağı \xe7ıkarayım.",`${n.label.toLowerCase()} mod i\xe7in ${i} agent, ${l} g\xf6rev ve ${o} automation taslağı hazır.`,d>0?`Senden sadece ${d} kritik karar daha gerekiyor.`:"Taslak tutarlı g\xf6r\xfcn\xfcyor. İstersen full blueprint'i a\xe7abilir ya da deploy review'a ge\xe7ebilirim."].join(" "):[e.company.mission?`${e.company.name||e.workspace.name||"This workspace"} looks like a ${aG(e.workspace.template).toLowerCase()} company focused on ${e.company.mission}.`:e.company.name||e.workspace.name?`I am shaping the first operating outcome for ${e.company.name||e.workspace.name}.`:"I am still shaping the first concrete outcome for this workspace.",e.company.targetCustomer?`First audience: ${e.company.targetCustomer}.`:"I still need the first audience or user segment.",e.intake.sources.length>0?`I already harvested ${e.intake.sources.length} context source${1===e.intake.sources.length?"":"s"}.`:"Give me a website, repo, or short brief and I will infer the first draft.",`${i} agents, ${l} tasks, and ${o} automations are drafted for ${n.label.toLowerCase()} mode.`,d>0?`Only ${d} high-value decision${1===d?"":"s"} still need your input.`:"The draft is coherent. I can open the full blueprint or move into deploy review."].join(" ")}(G,Z,Q,Y),G.stage=(b=G,f=Z,w=Q,y=H,v=Y,b.intake.started?"deploying"===b.status?"deploying":"deployed"===b.status?"deployed":(j=b).company.mission||j.product.offer||j.workspace.name||j.intake.sources.length>0?((k=b).company.name||k.workspace.name)&&k.company.mission&&k.team.persistentAgents.some(e=>e.enabled)&&k.operations.workflows.some(e=>e.enabled)?v?f.length>0?"pressure-test":w.length>0||b.readinessScore<90?"decision-lock":"ready":y.length>0?"team-synthesis":"decision-lock":"team-synthesis":b.intake.turnCount>1?"context-harvest":"intake":"intake"),G.status=(N=G,C=Z,S=H,A=Y,N.intake.started?"deploying"===N.status||"deployed"===N.status?N.status:A?"blocked"===N.status&&C.length>0||C.length>0?"blocked":N.readinessScore>=90?"ready":"review":S.length>0?"draft":"review":"draft"),G.updatedAt=new Date().toISOString(),G}function aR(e,t){for(let a of[t,...e.conversation.slice().reverse().filter(e=>"user"===e.role).map(e=>e.text),e.intake.latestPrompt,e.intake.initialPrompt])if(function(e){let t=e?.trim();if(!t)return!1;if(/[çğıöşüÇĞİÖŞÜ]/.test(t))return!0;let a=t.toLowerCase().match(/\b(ve|bir|bu|şu|için|ile|olarak|olan|mı|mi|mu|mü|ne|nasıl|hangi|neden|hedef|ilk|müşteri|kullanıcı|oluştur|gerekli|alanları|yardımcı)\b/g);return!!(a&&a.length>=2)}(a))return"tr";return"en"}function aM(e){return e.intake.sources.filter(e=>"ready"===e.status).flatMap(e=>[e.label,e.summary,...e.details]).join(" ").toLowerCase()}function aP(e){let t=aM(e);if(!t)return;let a=/\bweb3|onchain|crypto|blockchain|token\b/.test(t),s=/\bstartup|startups|founder|founders|business(?:es)?\b/.test(t),r=/\bcommunity|communities|member|members|holder|holders|nft|dao|governance\b/.test(t),n=/\bdeveloper|developers|builder|builders|engineer|engineers\b/.test(t),i=/\boperator|operators|moderator|moderators|admin|admins|ops\b/.test(t);return s&&r?a?"Web3 startups and token-led communities":"startups and their communities":s?a?"Web3 startups and founders":"startups and founders":r?a?"DAO, NFT, and Web3 communities":"community leads and members":n&&i?"developers and internal operators":n?"developers and technical teams":i?"internal operators and moderators":void 0}function aE(e){return/\b(from scratch|greenfield|empty workspace|clone|repo|existing folder|existing workspace|s[ıi]f[ıi]rdan|mevcut klas[oö]r|mevcut repo|bo[sş])\b/i.test(e)}function aD(e,t){let a=`${e.intake.initialPrompt} ${e.intake.latestPrompt}`.toLowerCase(),s=e.intake.sources.filter(e=>"ready"===e.status),r=66;return s.length>0&&(r+=8),e.intake.turnCount>1&&(r+=6),("template"===t&&/\b(telegram|discord|community|topluluk|grup|content|marketing|research|frontend|backend)\b/.test(a)||"source-mode"===t&&aE(a)||"channels"===t&&/\b(slack|telegram|discord|google chat)\b/.test(a))&&(r+=10),"company-name"===t&&s.some(e=>"website"===e.kind)&&(r+=6),"target-customer"!==t||e.company.targetCustomer||(r-=18),("workflow"===t||"team"===t)&&(r-=4),Math.max(52,Math.min(96,r))}function aL(e,t){return e.includes(t)?"needs-confirmation":"inferred"}function aU(e){return e?e.charAt(0).toLowerCase()+e.slice(1):e}function az(e,t){return e.find(e=>RegExp(t,"i").test(`${e.id} ${e.role} ${e.name}`))?.id}function aF(e){return e.filter((e,t,a)=>a.findIndex(t=>t.id===e.id)===t)}function aW(e){return e.trim()}function aB(e){return e?.trim()||void 0}function aV(e){return aq((e??[]).flatMap(e=>e.split(/\r?\n|,/g).map(e=>e.trim()).filter(Boolean)).map(e=>e.trim()).filter(Boolean))}function aq(e){return Array.from(new Set(e.filter(Boolean)))}function aK(e){return structuredClone(e)}function aJ(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function aG(e){return e.split(/[-_]/g).filter(Boolean).map(e=>e[0].toUpperCase()+e.slice(1)).join(" ")}function aH(e){let t="clone"===e.sourceMode?{label:"Cloning repository",description:"The repository is being cloned before workspace files are added."}:"existing"===e.sourceMode?{label:"Attaching existing folder",description:"Mission Control is validating the existing directory and preparing it for bootstrap."}:{label:"Preparing workspace folder",description:"A fresh workspace directory is being created inside the configured workspace root."};return{title:"Provisioning workspace",description:"Mission Control is creating the workspace and reporting each real bootstrap step as it finishes.",steps:[{id:"validate",label:"Checking input and target path",description:"Workspace input, agent ids, and the destination directory are being validated."},{id:"source",label:t.label,description:t.description},{id:"scaffold",label:"Scaffolding workspace files",description:"Core docs, local state, starter memory, and shared workspace metadata are being written."},{id:"agents",label:1===e.agentCount?"Creating the first agent":"Creating workspace agents",description:1===e.agentCount?"The primary agent is being provisioned and linked to the workspace.":"Each enabled agent is being provisioned and linked to the workspace."},{id:"kickoff",label:e.kickoffMission?"Running kickoff mission":"Finalizing workspace",description:e.kickoffMission?"The primary agent is inspecting the new workspace and refining the initial setup.":"Workspace bootstrap is wrapping up without a kickoff mission."}]}}function aZ(e){return{title:e.title,description:e.description,percent:0,steps:e.steps.map(e=>({...e,status:"pending",percent:0,activities:[]}))}}let aQ=new Set(["a","an","and","autonomous","automate","automated","automation","build","create","for","from","in","launch","new","of","on","project","run","runs","set","setup","start","that","the","to","up","workspace","adı","agent","ajan","asistan","benim","bide","bir","birde","de","diye","ekleyelim","gibi","i\xe7in","olarak","olsun","proje","şahsi","verelim","yeni"]);function aY(){return{name:"",goal:"",source:""}}function aX(e){let t=e.trim();if(!t)return{kind:"empty",createSourceMode:"empty",label:"Fresh workspace",hint:"Mission Control will scaffold a new project folder."};if(a5(t))return{kind:"existing",createSourceMode:"existing",label:"Existing folder",hint:t,existingPath:t};if(a3(t))return{kind:"clone",createSourceMode:"clone",label:"Clone repository",hint:t,repoUrl:t};let a=a4(t);return a?a8(a)?{kind:"clone",createSourceMode:"clone",label:"Clone repository",hint:a,repoUrl:a}:{kind:"website",createSourceMode:"empty",label:"Fresh workspace + website",hint:a,websiteUrl:a}:{kind:"context",createSourceMode:"empty",label:"Fresh workspace + context",hint:"The pasted source will be attached to the brief.",contextText:t}}function a0(e){let t=e.toLowerCase();return/\b(telegram|discord|community|channel automation|campaign|content|marketing|growth|seo|newsletter)\b/.test(t)?"content":/\b(frontend|ui|website|landing page|design system|dashboard)\b/.test(t)?"frontend":/\b(backend|api|service|microservice|worker|cron|queue|sdk)\b/.test(t)?"backend":/\b(research|investigation|analysis|benchmark|thesis)\b/.test(t)?"research":"software"}function a1(e){return e.name.trim()||function(e,t){let a=function(e){let t=e.trim();if(!t)return;if(a3(t))return a6(t.split(":").at(-1)??"");let a=a4(t);return a?a8(a)?a6(new URL(a).pathname):function(e){try{let[t]=new URL(e).hostname.replace(/^www\./,"").split(".");if(!t)return;return t.split(/[-_]+/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}catch{return}}(a):a5(t)?a6(t):void 0}(e);if(a)return a;let s=function(e){let t=e.match(/["“]([^"”]+)["”]/)?.[1]?.trim();if(t)return t;for(let t of[/\b(?:adı|ismi|name)\s*(?:olarak|:|=)?\s*([\p{L}\p{N}][\p{L}\p{N}._-]{1,40}(?:\s+[\p{L}\p{N}][\p{L}\p{N}._-]{1,40}){0,2})(?=\s+(?:olsun|olacak|diyelim|verelim|koyalım|olarak|için)\b|[.!?,]|$)/iu,/\b([\p{L}\p{N}][\p{L}\p{N}._-]{1,40}(?:\s+[\p{L}\p{N}][\p{L}\p{N}._-]{1,40}){0,2})\s+diye\b/iu]){let a=(e.match(t)?.[1]??"").replace(/\b(yeni|bir|workspace|project|proje|ekleyelim|kuralım|başlatalım|oluşturalım)\b/giu," ").replace(/\b(diye|olarak|benim|bide|bir de)\b.*$/iu,"").replace(/\s+/g," ").trim();if(a)return a}}(t);if(s)return s;let r=t.toLowerCase().replace(/[^a-z0-9\s-]+/g," ").split(/\s+/).map(e=>e.trim()).filter(e=>e&&!aQ.has(e)).slice(0,4);return 0===r.length?"":r.map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}(e.source,e.goal)||"New Workspace"}function a2(e){let t=e.workspace.repoUrl?.trim()||e.workspace.existingPath?.trim()||e.intake.sources.find(e=>"website"===e.kind)?.url||e.intake.sources.find(e=>"prompt"===e.kind)?.summary||"";return{name:e.workspace.name||"",goal:e.company.mission||e.product.offer||e.intake.latestPrompt||"",source:t}}function a5(e){return e.startsWith("/")||e.startsWith("./")||e.startsWith("../")}function a3(e){return/^git@[^:]+:[^/].+/.test(e)}function a4(e){if(e.includes("@"))return null;let t=e.replace(/[),.;!?]+$/g,""),a=/^https?:\/\//i.test(t)?t:`https://${t}`;try{let e=new URL(a);return e.hostname.includes(".")?e.toString():null}catch{return null}}function a8(e){try{let t=new URL(e),a=t.hostname.toLowerCase(),s=t.pathname.toLowerCase();return"github.com"===a||"gitlab.com"===a||"bitbucket.org"===a||s.endsWith(".git")}catch{return!1}}function a6(e){let t=e.replace(/\\/g,"/").replace(/\/+$/g,"").split("/").filter(Boolean).at(-1)?.replace(/\.git$/i,"");if(t)return t.split(/[-_]+/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}let a9="workspace-wizard-basic-source",a7="Imported quick setup assumptions:",se={workspaceOnly:!0,generateStarterDocs:!0,generateMemory:!0,kickoffMission:!0,workspaceOnly:!0,generateStarterDocs:!0,generateMemory:!0,kickoffMission:!0};function st(e,t){let a=structuredClone(e),s=aX(t.source),r=a1(t),n=t.goal.trim();return a.intake.mode=a.intake.mode||"guided",a.intake.started=!!(n||t.source.trim()),n&&(a.intake.initialPrompt||(a.intake.initialPrompt=n),a.intake.latestPrompt=n,a.company.mission=n,a.product.offer.trim()||(a.product.offer=n)),a.workspace.name=r,a.workspace.sourceMode=s.createSourceMode,a.workspace.repoUrl=s.repoUrl,a.workspace.existingPath=s.existingPath,a.workspace.template=a0(`${n}
4
- ${t.source}`),a.workspace.modelProfile=a.workspace.modelProfile||"balanced",a.intake.sources=a.intake.sources.filter(e=>e.id!==a9),"empty"!==s.kind&&a.intake.sources.unshift(ak({id:a9,kind:"clone"===s.kind?"repo":"existing"===s.kind?"folder":"website"===s.kind?"website":"prompt",label:s.label,summary:s.hint,details:[s.hint],url:s.repoUrl??s.websiteUrl})),aO(a)}let sa="mission-control-workspace-plan-id",ss=[{id:"software",label:"Ship a software workspace",prompt:"Create a software workspace to ship product work, review changes, and keep durable project context."},{id:"frontend",label:"Spin up a frontend squad",prompt:"Create a frontend workspace for rapid UI delivery, QA, and release-ready product handoffs."},{id:"content",label:"Run a content engine",prompt:"Create a content workspace to plan campaigns, produce copy, and keep publishing operations organized."},{id:"research",label:"Start a research pod",prompt:"Create a research workspace for investigation, synthesis, benchmarking, and note capture."}];function sr({open:e,onOpenChange:t,initialMode:a="basic",surfaceTheme:r,snapshot:n,onRefresh:l,onWorkspaceCreated:o}){let d=function({open:e,initialMode:t,onRefresh:a,onWorkspaceCreated:s}){let[r,n]=(0,m.useState)(t),[i,l]=(0,m.useState)(null),[o,d]=(0,m.useState)(null),[c,p]=(0,m.useState)(aY),[u,h]=(0,m.useState)(null),[x,g]=(0,m.useState)(!1),[b,f]=(0,m.useState)(!1),[w,y]=(0,m.useState)(!1),[v,j]=(0,m.useState)(!1),[k,N]=(0,m.useState)(!1),[C,S]=(0,m.useState)(!1),[A,I]=(0,m.useState)(null),[T,$]=(0,m.useState)(null),[_,O]=(0,m.useState)(0),[R,M]=(0,m.useState)(null),P=(0,m.useRef)(null),E=(0,m.useMemo)(()=>aX(c.source),[c.source]),D=(0,m.useMemo)(()=>(function({initialTurn:e,step:t,active:a}){return a?e?t>=2?{title:"Still working",description:"The first turn is the slowest. The planner is usually inspecting links and provisioning the hidden architect runtime."}:t>=1?{title:"Collecting context",description:"The architect is reading the prompt, inspecting websites or repos, and drafting the first workspace blueprint."}:{title:"Starting planner",description:"The architect is opening the planning session and preparing the first draft."}:t>=2?{title:"Still working",description:"The architect is waiting on the planner runtime. This can happen when linked context or advisor runs take longer."}:t>=1?{title:"Updating draft",description:"Refreshing context, specialist notes, and the current workspace plan."}:{title:"Architect thinking",description:"Applying your latest direction to the workspace draft."}:null})({initialTurn:!i?.intake.started,step:_,active:b}),[b,i?.intake.started,_]);(0,m.useEffect)(()=>{if(!b)return void O(0);O(0);let e=globalThis.setTimeout(()=>O(1),1800),t=globalThis.setTimeout(()=>O(2),6200);return()=>{globalThis.clearTimeout(e),globalThis.clearTimeout(t)}},[b]);let L=(0,m.useCallback)(e=>{l(t=>t?aO(e(structuredClone(t))):t)},[]),U=(0,m.useCallback)(()=>{globalThis.localStorage?.removeItem(sa)},[]),z=(0,m.useCallback)(e=>(l(e),e)?(d(e.id),p(a2(e)),globalThis.localStorage?.setItem(sa,e.id),e):(d(null),null),[]),F=(0,m.useCallback)(async({resumeStored:e})=>{let t=e?globalThis.localStorage?.getItem(sa):null;if(t){let e=await fetch(`/api/planner/${t}`,{cache:"no-store"});if(e.ok)return(await e.json()).plan}let a=await fetch("/api/planner",{method:"POST"}),s=await a.json();if(!a.ok||!s.plan)throw Error(s.error||"Unable to create planner workspace.");return s.plan},[]),W=(0,m.useCallback)(async({resumeStored:e,draftOverride:t})=>{if(i)return i;if(P.current)return P.current;let a=(async()=>{g(!0);try{let a=await F({resumeStored:e}),s=t??c,r=s.goal.trim()||s.source.trim()||s.name.trim()?st(a,s):a;return z(r)}catch(e){return ex.o.error("Workspace architect could not start.",{description:e instanceof Error?e.message:"Unknown planner error."}),null}finally{g(!1),P.current=null}})();return P.current=a,a},[c,z,i,F]),B=(0,m.useCallback)(async()=>{if(h(null),I(null),$(null),f(!1),y(!1),j(!1),N(!1),S(!1),M(null),P.current=null,"basic"===r){U(),l(null),d(null),p(aY());return}U(),l(null),d(null);let e=aY();p(e),await W({resumeStored:!1,draftOverride:e})&&n("advanced")},[U,W,r]),V=(0,m.useCallback)(async()=>{if(!i||!o)return!1;y(!0);try{let e=await fetch(`/api/planner/${o}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({plan:i})}),t=await e.json();if(!e.ok||!t.plan)throw Error(t.error||"Unable to save planner workspace.");return z(t.plan),ex.o.success("Planner draft saved."),!0}catch(e){return ex.o.error("Planner draft could not be saved.",{description:e instanceof Error?e.message:"Unknown planner save error."}),!1}finally{y(!1)}},[z,i,o]),q=(0,m.useCallback)(async()=>{if(!i||!o)return!1;j(!0);try{let e=await fetch(`/api/planner/${o}/simulate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({plan:i})}),t=await e.json();if(!e.ok||!t.plan)throw Error(t.error||"Unable to simulate planner team.");return z(t.plan),ex.o.success("Planner team simulated."),!0}catch(e){return ex.o.error("Planner simulation failed.",{description:e instanceof Error?e.message:"Unknown planner simulation error."}),!1}finally{j(!1)}},[z,i,o]),K=(0,m.useCallback)(()=>{L(e=>(e.intake.mode="advanced",e.intake.reviewRequested=!0,e.advisorNotes=[],e.conversation.push(aj("assistant","Workspace Architect","Deploy review is open now. I am surfacing the real blockers and warnings that matter before launch.")),e))},[L]),J=(0,m.useCallback)(async()=>{let e=await W({resumeStored:!1,draftOverride:c})??i;if(!e)return null;let t=st(e,c);z(t),S(!0),$(aZ(aH({sourceMode:t.workspace.sourceMode,agentCount:1,kickoffMission:!0})));try{var r;let e=await fetch("/api/workspaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...{name:t.workspace.name,brief:[(r=t).company.mission.trim()||r.product.offer.trim(),r.company.name.trim()?`Company: ${r.company.name.trim()}`:null,r.product.scopeV1.length>0?`Scope: ${r.product.scopeV1.join(", ")}`:null,...r.intake.sources.flatMap(e=>e.id!==a9?[]:"repo"===e.kind&&e.url?[`Bootstrap source: clone ${e.url}`]:"folder"===e.kind?[`Bootstrap source: existing folder ${e.summary}`]:"website"===e.kind&&e.url?[`Reference website: ${e.url}`]:"prompt"===e.kind?[`Additional context: ${e.summary}`]:[])].filter(e=>!!e?.trim()).join("\n"),directory:t.workspace.directory,modelId:t.workspace.modelId,sourceMode:t.workspace.sourceMode,repoUrl:t.workspace.repoUrl,existingPath:t.workspace.existingPath,template:t.workspace.template,teamPreset:"solo",modelProfile:t.workspace.modelProfile||"balanced",rules:se},stream:!0})});if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error||"OpenClaw could not create the workspace.")}let n=null,i=null;if(await ag(e,async e=>{"progress"===e.type?$(e.progress):(e.progress&&$(e.progress),e.ok?n=e.result:i=e.error)}),i||!n)throw Error(i||"OpenClaw could not create the workspace.");let l=n;return U(),await a(),s(l.workspaceId),ex.o.success("Workspace created.",{description:`${l.agentIds.length} agent${1===l.agentIds.length?"":"s"} created at ${l.workspacePath}`}),l.kickoffError&&ex.o.message("Workspace created, but kickoff needs attention.",{description:l.kickoffError}),l}catch(e){return ex.o.error("Workspace creation failed.",{description:e instanceof Error?e.message:"Unknown workspace error."}),null}finally{S(!1)}},[c,U,z,W,a,s,i]),G=(0,m.useCallback)(async()=>{var e;if(!i||!o)return null;N(!0),I(aZ({title:"Deploying workspace",description:"The planner is turning the blueprint into a live workspace and streaming each deploy stage.",steps:[{id:"plan",label:"Locking deploy plan",description:"Deploy blockers are being checked and the planner state is being locked for launch."},...aH({sourceMode:(e={sourceMode:i.workspace.sourceMode??"empty",agentCount:i.team.persistentAgents.filter(e=>e.enabled).length,kickoffMission:i.workspace.rules.kickoffMission??!0,hasChannels:!!i.operations.channels.some(e=>e.enabled&&"internal"!==e.type),hasAutomations:!!i.operations.automations.some(e=>e.enabled),hasPlannerKickoffs:!!i.deploy.firstMissions.some(e=>e.trim().length>0)}).sourceMode,agentCount:e.agentCount,kickoffMission:e.kickoffMission}).steps,{id:"blueprint",label:"Writing planner files",description:"Planner blueprint, company notes, and workflow docs are being written into the workspace."},{id:"channels",label:e.hasChannels?"Provisioning channels":"Checking channels",description:e.hasChannels?"Enabled external channels are being provisioned and connected.":"No external channels are enabled, so this stage will pass quickly."},{id:"automations",label:e.hasAutomations?"Provisioning automations":"Checking automation loops",description:e.hasAutomations?"Enabled recurring loops are being attached to their target agents.":"No recurring automations are enabled, so this stage is mostly validation."},{id:"planner-kickoff",label:e.hasPlannerKickoffs?"Running planner kickoff missions":"Finalizing deploy",description:e.hasPlannerKickoffs?"The first missions are being dispatched so the new workspace starts with clear momentum.":"The workspace is being finalized and the deploy request is wrapping up."}]}));try{let e=await fetch(`/api/planner/${o}/deploy`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({plan:i,stream:!0})});if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error||"Unable to deploy planner workspace.")}let t=null,r=null;if(await ag(e,async e=>{"progress"===e.type?I(e.progress):(e.progress&&I(e.progress),e.ok?t=e.result:r=e.error)}),r||!t)throw Error(r||"Unable to deploy planner workspace.");let n=t;return z(n.plan),U(),await a(),s(n.workspaceId),ex.o.success("Workspace deployed.",{description:n.workspacePath}),n}catch(e){return ex.o.error("Planner deploy failed.",{description:e instanceof Error?e.message:"Unknown deploy error."}),null}finally{N(!1)}},[U,z,a,s,i,o]),H=(0,m.useCallback)(async e=>{if(!e.trim())return!1;f(!0),M(e.trim());try{let a="advanced"===t&&!i&&!c.goal.trim()&&!c.source.trim()&&!c.name.trim(),s=await W({resumeStored:a,draftOverride:c})??i;if(!s)return!1;let r=await fetch(`/api/planner/${s.id}/turn`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:e,plan:s})}),n=await r.json();if(!r.ok||!n.plan)throw Error(n.error||"Unable to process planner turn.");return z(n.plan),h(null),!0}catch(e){return ex.o.error("Planner turn failed.",{description:e instanceof Error?e.message:"Unknown planner turn error."}),!1}finally{M(null),f(!1)}},[c,z,W,t,i]),Z=(0,m.useCallback)(async e=>{if(e!==r){if("advanced"===e){let e=await W({resumeStored:!1,draftOverride:c});if(!e)return;let t=st(e,c),a=!t.intake.started&&t.conversation.filter(e=>"system"!==e.role).length<=1?function(e,t){let a=structuredClone(e),s=t.goal.trim(),r=t.source.trim();if(a.conversation=a.conversation.filter(e=>!("system"===e.role&&"Workspace Wizard"===e.author&&e.text.startsWith(a7))),!s&&!r)return aO(a);let n=[s?`goal: ${s}`:null,r?`source: ${r}`:null,`fast-path name: ${a1(t)}`].filter(Boolean);return a.conversation.push(aj("system","Workspace Wizard",`${a7} ${n.join(" \xb7 ")}`)),aO(a)}(t,c):t;z(a),h(a.intake.started||c.goal.trim()||c.source.trim()?{tone:"muted",title:"Same draft, deeper controls",description:"Architect will keep extending the exact same conversation and blueprint as you move into Advanced."}:null),n("advanced");return}if(i)p(a2(i)),h(i&&(i.team.persistentAgents.filter(e=>e.enabled).length>1||i.operations.workflows.some(e=>e.enabled)||i.operations.automations.some(e=>e.enabled)||i.operations.channels.some(e=>e.enabled&&"internal"!==e.type)||i.operations.hooks.some(e=>e.enabled))?{tone:"warning",title:"Advanced details preserved",description:"Basic mode will keep showing the fast path, but the richer blueprint remains in memory if you switch back."}:null);else h(null);n("basic")}},[c,z,W,r,i]),Q=(0,m.useCallback)(e=>{p(t=>{let a={...t,goal:e};return"basic"===r&&l(e=>e?st(e,a):e),a})},[r]),Y=(0,m.useCallback)(e=>{p(t=>{let a={...t,source:e};return"basic"===r&&l(e=>e?st(e,a):e),a})},[r]),X=(0,m.useCallback)(e=>{p(t=>{let a={...t,name:e};return"basic"===r&&l(e=>e?st(e,a):e),a})},[r]);return(0,m.useEffect)(()=>{if(!e){n(t),l(null),d(null),p(aY()),h(null),$(null),I(null),M(null),P.current=null;return}if(n(t),p(aY()),h(null),$(null),I(null),M(null),P.current=null,"advanced"===t){let e=(async()=>{g(!0);try{let e=await F({resumeStored:!0});return z(e)}catch(e){return ex.o.error("Workspace architect could not start.",{description:e instanceof Error?e.message:"Unknown planner error."}),null}finally{g(!1),P.current=null}})();P.current=e}else l(null),d(null)},[z,t,e,F]),{mode:r,plan:i,planId:o,notice:u,sourceAnalysis:E,basicDraft:c,isPlanLoading:x,isSending:b,isSaving:w,isSimulating:v,isDeploying:k,isCreating:C,createProgress:T,deployProgress:A,architectBusyStatus:D,pendingUserMessage:R,setBasicGoal:Q,setBasicSource:Y,setBasicName:X,setNotice:h,updatePlan:L,switchMode:Z,startFreshDraft:B,savePlan:V,simulatePlan:q,requestReview:K,createWorkspace:J,deployPlan:G,submitArchitectTurn:H}}({open:e,initialMode:a,onRefresh:l,onWorkspaceCreated:o}),[c,p]=(0,m.useState)(""),[u,h]=(0,m.useState)(!1),x="light"===r,g=e=>{e||(p(""),h(!1)),t(e)},b=a1(d.basicDraft),f=a0(`${d.basicDraft.goal}
5
- ${d.basicDraft.source}`),w=function(e,t,a=aX(t.source)){if("existing"===a.kind&&a.existingPath)return a.existingPath;let s=a1(t).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");return`${_(e)}/${s||"workspace"}`}(n.diagnostics.workspaceRoot,d.basicDraft,d.sourceAnalysis),y=(0,m.useMemo)(()=>{var e,t;let a;return e=d.mode,t=d.plan,a=[{id:"surface",label:"basic"===e?"Architect-assisted fast path":"Architect co-design",tone:"muted"}],t&&(t.intake.confirmations.length>0&&a.push({id:"confirmations",label:`${t.intake.confirmations.length} decision${1===t.intake.confirmations.length?"":"s"} needed`,tone:t.intake.confirmations.length>1?"warning":"muted"}),a.push({id:"stage",label:`Stage \xb7 ${t3(t.stage)}`,tone:"muted"}),a.push({id:"readiness",label:`${t.readinessScore}% drafted`,tone:t.readinessScore>=85?"success":t.readinessScore>=45?"warning":"muted"}),a.push({id:"status",label:`Status \xb7 ${t.status}`,tone:"blocked"===t.status?"danger":"ready"===t.status||"deployed"===t.status?"success":"review"===t.status?"warning":"muted"})),a},[d.mode,d.plan]),v=(0,m.useMemo)(()=>{var e,t;let a;return e=d.plan,t=d.pendingUserMessage,a=e?.conversation.map(e=>({id:e.id,role:e.role,author:"assistant"===e.role?"Architect":"system"===e.role?"Workspace Wizard":e.author,text:e.text}))??[],t?.trim()&&a.push({id:"pending-user-message",role:"user",text:t.trim(),status:"pending"}),a},[d.pendingUserMessage,d.plan]),j=(0,m.useMemo)(()=>{let e=(d.plan?.intake.suggestedReplies??[]).filter(e=>e.trim().length>0).map((e,t)=>({id:`reply-${t}`,label:e,prompt:e})).slice(0,4);return e.length>0?e:d.plan?.intake.started?[]:ss},[d.plan?.intake.started,d.plan?.intake.suggestedReplies]),k=d.isCreating?d.createProgress:d.isDeploying?d.deployProgress:null,N=d.isSending||d.isPlanLoading||d.isDeploying||d.isCreating,C=!!(d.plan?.intake.started||d.basicDraft.goal.trim()||c.trim()),S=async e=>{let t=(e??c).trim();if(!t)return!1;let a=void 0===e;a&&p("");let s=await d.submitArchitectTurn(t);return!s&&a&&p(c),s},A=async()=>{(!c.trim()||await S())&&await d.createWorkspace()&&g(!1)},I=async()=>{await d.deployPlan()&&g(!1)};return(0,s.jsx)(ea,{open:e,onOpenChange:g,children:(0,s.jsxs)(ei,{className:x?"h-[92vh] max-w-[min(1380px,96vw)] gap-0 overflow-hidden border-[#e7dfd4] bg-[#fcfaf6] p-0 text-[#161411] shadow-[0_40px_140px_rgba(16,12,8,0.45)]":"h-[92vh] max-w-[min(1380px,96vw)] gap-0 overflow-hidden border-white/10 bg-[rgba(4,8,15,0.96)] p-0 text-white shadow-[0_40px_140px_rgba(0,0,0,0.58)]",children:[(0,s.jsx)(ed,{className:"sr-only",children:"Create workspace"}),(0,s.jsx)(ec,{className:"sr-only",children:"Create a workspace in Basic or Advanced mode using the Architect wizard."}),(0,s.jsxs)("div",{className:"relative flex h-full min-h-0 flex-col overflow-hidden",children:[(0,s.jsx)("div",{className:x?"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_top,rgba(255,255,255,0.86),transparent_34%),linear-gradient(180deg,rgba(248,244,237,0.92),rgba(252,250,246,0.86)_24%,rgba(244,238,230,0.82)_100%)]":"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_top,rgba(59,130,246,0.14),transparent_28%),radial-gradient(circle_at_80%_18%,rgba(56,189,248,0.12),transparent_24%),linear-gradient(180deg,rgba(9,15,27,0.98),rgba(4,8,15,0.96)_28%,rgba(2,6,13,0.98)_100%)]"}),(0,s.jsx)(ao,{surfaceTheme:r,mode:d.mode,onModeChange:e=>{d.switchMode(e)},onNewDraft:()=>{p(""),h(!1),d.startFreshDraft()},badges:y}),(0,s.jsxs)("div",{className:"relative z-[1] grid min-h-0 flex-1 lg:grid-cols-[minmax(0,1fr),390px] xl:grid-cols-[minmax(0,1fr),420px]",children:[(0,s.jsxs)("div",{className:x?"flex min-h-0 flex-col bg-[linear-gradient(180deg,rgba(252,250,246,0.7),rgba(247,242,235,0.92))]":"flex min-h-0 flex-col bg-[linear-gradient(180deg,rgba(8,13,24,0.2),rgba(6,10,18,0.42))]",children:[(0,s.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[d.architectBusyStatus?(0,s.jsx)("div",{className:x?"border-b border-[#ece5db] px-4 py-3 md:px-5":"border-b border-white/10 px-4 py-3 md:px-5",children:(0,s.jsxs)("div",{className:x?"rounded-[18px] border border-[#e6dfd5] bg-white px-4 py-3":"rounded-[18px] border border-white/10 bg-white/[0.04] px-4 py-3",children:[(0,s.jsx)("p",{className:x?"text-[11px] uppercase tracking-[0.18em] text-[#8b7262]":"text-[11px] uppercase tracking-[0.18em] text-slate-500",children:d.architectBusyStatus.title}),(0,s.jsx)("p",{className:x?"mt-1 text-[13px] leading-6 text-[#6d665e]":"mt-1 text-[13px] leading-6 text-slate-300",children:d.architectBusyStatus.description})]})}):null,(0,s.jsx)("div",{className:"min-h-0 flex-1",children:(0,s.jsx)(am,{surfaceTheme:r,messages:v,isTyping:d.isSending,typingLabel:"Architect is shaping the next pass...",emptyState:d.isPlanLoading&&0===v.length?(0,s.jsx)(sl,{surfaceTheme:r}):0===v.length&&"basic"===d.mode?(0,s.jsx)(sn,{surfaceTheme:r}):0===v.length?(0,s.jsx)(si,{surfaceTheme:r}):null,auxiliary:k?(0,s.jsx)("div",{className:"mx-auto w-full max-w-3xl",children:(0,s.jsx)(tV,{progress:k,className:x?"border-[#e6dfd5] bg-white":"border-white/10 bg-slate-950/50"})}):"basic"!==d.mode||d.plan?.intake.started||d.pendingUserMessage?null:(0,s.jsx)(so,{surfaceTheme:r,name:d.basicDraft.name,source:d.basicDraft.source,onNameChange:d.setBasicName,onSourceChange:d.setBasicSource})})})]}),(0,s.jsx)("div",{className:x?"border-t border-[#ece5db] bg-[linear-gradient(180deg,rgba(252,250,246,0.7),rgba(247,242,235,0.92))] px-4 py-4 md:px-5":"border-t border-white/10 bg-[linear-gradient(180deg,rgba(5,9,18,0.68),rgba(4,8,15,0.94))] px-4 py-4 md:px-5",children:(0,s.jsxs)("div",{className:"mx-auto w-full max-w-4xl",children:[(0,s.jsx)(ax,{surfaceTheme:r,chips:j.map(e=>({id:e.id,label:e.label})),disabled:N,onSelect:e=>{let t=j.find(t=>t.id===e.id);t&&S(t.prompt)},className:"mb-3"}),(0,s.jsx)(ap,{surfaceTheme:r,value:c,onChange:p,onSubmit:async()=>{await S()},placeholder:"basic"===d.mode?"Tell Architect what this workspace should do first...":"Keep shaping the workspace with Architect...",disabled:N,isBusy:d.isSending,helperText:"basic"===d.mode?"Architect fills the draft live. Create the workspace as soon as the fast path looks right.":"Architect updates the same structured draft with every turn.",toolbar:"basic"!==d.mode||d.plan?d.plan?(0,s.jsxs)("span",{className:x?"inline-flex items-center rounded-full border border-[#e3ddd4] bg-[#f6f1ea] px-3 py-1 text-[11px] uppercase tracking-[0.16em] text-[#6c645b]":"inline-flex items-center rounded-full border border-white/10 bg-white/[0.05] px-3 py-1 text-[11px] uppercase tracking-[0.16em] text-slate-300",children:["Stage \xb7 ",t3(d.plan.stage)]}):null:(0,s.jsx)("span",{className:x?"inline-flex items-center rounded-full border border-[#e3ddd4] bg-[#f6f1ea] px-3 py-1 text-[11px] uppercase tracking-[0.16em] text-[#6c645b]":"inline-flex items-center rounded-full border border-white/10 bg-white/[0.05] px-3 py-1 text-[11px] uppercase tracking-[0.16em] text-slate-300",children:"Architect live"})})]})})]}),(0,s.jsx)(ae,{className:"hidden lg:block",surfaceTheme:r,mode:d.mode,snapshot:n,plan:d.plan,resolvedName:b,resolvedTemplate:f,sourceAnalysis:d.sourceAnalysis,workspacePath:w,notice:d.notice,progress:"basic"===d.mode?d.createProgress:d.isDeploying?d.deployProgress:null})]}),u?(0,s.jsxs)("div",{className:x?"absolute inset-0 z-20 flex flex-col bg-[rgba(22,18,14,0.18)] backdrop-blur-sm lg:hidden":"absolute inset-0 z-20 flex flex-col bg-[rgba(2,6,13,0.56)] backdrop-blur-sm lg:hidden",children:[(0,s.jsxs)("div",{className:x?"flex items-center justify-between border-b border-[#e7dfd4] bg-[#fcfaf6] px-4 py-3":"flex items-center justify-between border-b border-white/10 bg-[rgba(4,8,15,0.96)] px-4 py-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:x?"text-[11px] uppercase tracking-[0.18em] text-[#9f958a]":"text-[11px] uppercase tracking-[0.18em] text-slate-500",children:"basic"===d.mode?"Workspace draft":"Workspace blueprint"}),(0,s.jsx)("p",{className:x?"text-[13px] text-[#6f675e]":"text-[13px] text-slate-300",children:"Review the structured side of the same wizard."})]}),(0,s.jsx)("button",{type:"button",onClick:()=>h(!1),className:x?"inline-flex size-9 items-center justify-center rounded-full border border-[#e4ddd3] bg-white text-[#4f4943] transition-colors hover:bg-[#f4efe7]":"inline-flex size-9 items-center justify-center rounded-full border border-white/10 bg-white/[0.05] text-slate-200 transition-colors hover:bg-white/[0.08]",children:(0,s.jsx)(J.A,{className:"h-4 w-4"})})]}),(0,s.jsx)(ae,{className:"min-h-0 flex-1 border-t-0 lg:hidden",surfaceTheme:r,mode:d.mode,snapshot:n,plan:d.plan,resolvedName:b,resolvedTemplate:f,sourceAnalysis:d.sourceAnalysis,workspacePath:w,notice:d.notice,progress:"basic"===d.mode?d.createProgress:d.isDeploying?d.deployProgress:null})]}):null,(0,s.jsx)("div",{className:x?"relative z-[1] border-t border-[#e7dfd4] bg-white/90 px-4 py-3 backdrop-blur-sm md:px-5":"relative z-[1] border-t border-white/10 bg-[rgba(4,8,15,0.88)] px-4 py-3 backdrop-blur-sm md:px-5",children:(0,s.jsxs)("div",{className:"flex flex-col gap-3 md:flex-row md:items-center md:justify-between",children:[(0,s.jsx)("p",{className:x?"text-[13px] text-[#776f65]":"text-[13px] text-slate-300",children:"basic"===d.mode?"Basic stays fast, but the same Architect conversation keeps filling the draft underneath.":"Advanced keeps the conversation and blueprint aligned through review and deploy."}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsxs)(ee,{variant:"secondary",size:"sm",className:x?"rounded-full border-[#dfd8ce] bg-[#f7f2eb] text-[#403934] hover:bg-[#f1ebe3] lg:hidden":"rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08] lg:hidden",onClick:()=>h(!0),children:[(0,s.jsx)(tB.A,{className:"mr-2 h-4 w-4"}),"View blueprint"]}),"basic"===d.mode?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(ee,{variant:"secondary",size:"sm",className:x?"rounded-full border-[#dfd8ce] bg-[#f7f2eb] text-[#403934] hover:bg-[#f1ebe3]":"rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]",onClick:()=>{d.switchMode("advanced")},disabled:d.isCreating||d.isSending||d.isPlanLoading,children:"Open full blueprint"}),(0,s.jsxs)(ee,{size:"sm",className:x?"rounded-full bg-[#161514] text-white hover:bg-[#26231f]":"rounded-full bg-cyan-300 text-slate-950 hover:bg-cyan-200",onClick:()=>void A(),disabled:d.isCreating||d.isSending||d.isPlanLoading||!C,children:[d.isCreating?(0,s.jsx)(i.A,{className:"mr-2 h-4 w-4 animate-spin"}):(0,s.jsx)(D.A,{className:"mr-2 h-4 w-4"}),"Create from this draft"]})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(ee,{variant:"secondary",size:"sm",className:x?"rounded-full border-[#dfd8ce] bg-[#f7f2eb] text-[#403934] hover:bg-[#f1ebe3]":"rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]",onClick:()=>void d.savePlan(),disabled:!d.plan||d.isSaving||d.isPlanLoading,children:[d.isSaving?(0,s.jsx)(i.A,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save"]}),(0,s.jsxs)(ee,{variant:"secondary",size:"sm",className:x?"rounded-full border-[#dfd8ce] bg-[#f7f2eb] text-[#403934] hover:bg-[#f1ebe3]":"rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]",onClick:()=>void d.simulatePlan(),disabled:!d.plan||d.isSimulating||d.isPlanLoading||d.isDeploying,children:[d.isSimulating?(0,s.jsx)(i.A,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Simulate"]}),d.plan?.intake.reviewRequested?(0,s.jsxs)(ee,{size:"sm",className:x?"rounded-full bg-[#161514] text-white hover:bg-[#26231f]":"rounded-full bg-cyan-300 text-slate-950 hover:bg-cyan-200",onClick:()=>void I(),disabled:!d.plan||d.plan.deploy.blockers.length>0||d.isDeploying||d.isPlanLoading,children:[d.isDeploying?(0,s.jsx)(i.A,{className:"mr-2 h-4 w-4 animate-spin"}):(0,s.jsx)(tT.A,{className:"mr-2 h-4 w-4"}),"Deploy workspace"]}):(0,s.jsx)(ee,{size:"sm",className:x?"rounded-full bg-[#161514] text-white hover:bg-[#26231f]":"rounded-full bg-cyan-300 text-slate-950 hover:bg-cyan-200",onClick:()=>d.requestReview(),disabled:!d.plan||d.isSending||d.isDeploying,children:"Request review"})]})]})]})})]})]})})}function sn({surfaceTheme:e}){let t="light"===e;return(0,s.jsxs)("div",{className:"mx-auto mt-4 flex w-full max-w-3xl flex-col justify-center px-4 md:mt-16 md:px-8",children:[(0,s.jsx)("p",{className:t?"text-[28px] font-semibold tracking-[-0.03em] text-[#181612]":"text-[28px] font-semibold tracking-[-0.03em] text-white",children:"Talk to Architect, then create fast."}),(0,s.jsx)("p",{className:t?"mt-2 text-[28px] tracking-[-0.03em] text-[#7f756b]":"mt-2 text-[28px] tracking-[-0.03em] text-slate-400",children:"Describe the outcome, paste a source, and let Architect fill the draft while keeping the fast path open."})]})}function si({surfaceTheme:e}){let t="light"===e;return(0,s.jsxs)("div",{className:"mx-auto mt-4 flex w-full max-w-3xl flex-col justify-center px-4 md:mt-16 md:px-8",children:[(0,s.jsx)("p",{className:t?"text-[28px] font-semibold tracking-[-0.03em] text-[#181612]":"text-[28px] font-semibold tracking-[-0.03em] text-white",children:"Design the workspace with Architect."}),(0,s.jsx)("p",{className:t?"mt-2 text-[28px] tracking-[-0.03em] text-[#7f756b]":"mt-2 text-[28px] tracking-[-0.03em] text-slate-400",children:"Describe the operating model, and the blueprint will update alongside the conversation."})]})}function sl({surfaceTheme:e}){return(0,s.jsxs)("div",{className:"light"===e?"mx-auto mt-10 flex w-full max-w-3xl items-center gap-3 rounded-[22px] border border-[#e6dfd5] bg-white px-5 py-4 text-[14px] text-[#6d665e]":"mx-auto mt-10 flex w-full max-w-3xl items-center gap-3 rounded-[22px] border border-white/10 bg-white/[0.04] px-5 py-4 text-[14px] text-slate-300",children:[(0,s.jsx)(i.A,{className:"h-4 w-4 animate-spin"}),"Architect is opening the planning session and loading the latest blueprint."]})}function so({surfaceTheme:e,name:t,source:a,onNameChange:r,onSourceChange:n}){let i="light"===e;return(0,s.jsx)("div",{className:i?"mx-auto w-full max-w-3xl rounded-[24px] border border-[#e4ddd3] bg-white p-4 shadow-[0_24px_80px_rgba(56,47,38,0.06)]":"mx-auto w-full max-w-3xl rounded-[24px] border border-white/10 bg-white/[0.04] p-4 shadow-[0_24px_80px_rgba(0,0,0,0.28)]",children:(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)("span",{className:i?"inline-flex size-9 shrink-0 items-center justify-center rounded-full border border-[#e4ddd3] bg-[#faf6f1] text-[#5e5750]":"inline-flex size-9 shrink-0 items-center justify-center rounded-full border border-white/10 bg-white/[0.05] text-slate-300",children:(0,s.jsx)(D.A,{className:"h-4 w-4"})}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("p",{className:i?"text-[11px] uppercase tracking-[0.18em] text-[#8b7262]":"text-[11px] uppercase tracking-[0.18em] text-slate-500",children:"Quick setup"}),(0,s.jsx)("p",{className:i?"mt-1 text-[13px] leading-6 text-[#70685f]":"mt-1 text-[13px] leading-6 text-slate-300",children:"Keep the fast path lightweight. Optional name and source live here; the main goal still comes through the composer."}),(0,s.jsxs)("div",{className:"mt-4 grid gap-3 md:grid-cols-2",children:[(0,s.jsx)(sd,{surfaceTheme:e,label:"Workspace name",children:(0,s.jsx)(ep,{value:t,onChange:e=>r(e.target.value),placeholder:"Optional. Architect can infer it.",className:i?"border-[#e4ddd3] bg-[#fcfaf6] text-[#1c1916] placeholder:text-[#9b948c] focus-visible:ring-[#b8ada1]":"border-white/10 bg-[rgba(4,8,15,0.64)] text-slate-100 placeholder:text-slate-500 focus-visible:ring-cyan-300/60"})}),(0,s.jsx)(sd,{surfaceTheme:e,label:"Source",children:(0,s.jsx)(ep,{value:a,onChange:e=>n(e.target.value),placeholder:"Repo URL, website URL, or existing folder path",className:i?"border-[#e4ddd3] bg-[#fcfaf6] text-[#1c1916] placeholder:text-[#9b948c] focus-visible:ring-[#b8ada1]":"border-white/10 bg-[rgba(4,8,15,0.64)] text-slate-100 placeholder:text-slate-500 focus-visible:ring-cyan-300/60"})})]})]})]})})}function sd({surfaceTheme:e,label:t,children:a}){return(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)("p",{className:"light"===e?"text-[11px] uppercase tracking-[0.16em] text-[#8d8276]":"text-[11px] uppercase tracking-[0.16em] text-slate-500",children:t}),a]})}let sc="mission-control-surface-theme";function sp({initialSnapshot:e}){var t,a,l,o,d,c,p;let{snapshot:u,connectionState:h,refresh:x,refreshSnapshot:g,setSnapshot:b}=function(e){let[t,a]=(0,m.useState)(e),[s,r]=(0,m.useState)("connecting");(0,m.useEffect)(()=>{let e=new EventSource("/api/stream");return e.addEventListener("snapshot",e=>{let t=JSON.parse(e.data);(0,m.startTransition)(()=>{a(t),r("live")})}),e.addEventListener("error",()=>{r("retrying")}),e.addEventListener("ready",()=>{r("live")}),e.onerror=()=>{r("retrying")},()=>{e.close()}},[]);let n=async()=>{let e=await fetch("/api/snapshot",{cache:"no-store"}),t=await e.json();return(0,m.startTransition)(()=>{a(t),r("live")}),t};return{snapshot:t,connectionState:s,refresh:async()=>{await n()},refreshSnapshot:n,setSnapshot:a}}(e),[f,y]=(0,m.useState)(e.workspaces[0]?.id??null),[v,j]=(0,m.useState)(e.workspaces[0]?.id??null),[k,N]=(0,m.useState)(null),[C,S]=(0,m.useState)(null),[A,I]=(0,m.useState)(null),[T,$]=(0,m.useState)([]),[O,R]=(0,m.useState)(null),[M,P]=(0,m.useState)(!1),[E,D]=(0,m.useState)(!1),[L,U]=(0,m.useState)(!1),[z,F]=(0,m.useState)(!1),[W,B]=(0,m.useState)(()=>sx(e)),[q,K]=(0,m.useState)(()=>sg(e)),[J,G]=(0,m.useState)(!1),[H,Z]=(0,m.useState)(!1),[Q,Y]=(0,m.useState)(!1),[X,et]=(0,m.useState)("idle"),[es,er]=(0,m.useState)(null),[en,ep]=(0,m.useState)(null),[em,eu]=(0,m.useState)(""),[eh,eg]=(0,m.useState)("idle"),[eb,ef]=(0,m.useState)(null),[ew,ey]=(0,m.useState)(null),[ev,ej]=(0,m.useState)(null),[ek,eN]=(0,m.useState)(""),[eC,eS]=(0,m.useState)(null),[eA,eI]=(0,m.useState)(null),[eT,e$]=(0,m.useState)("system"),[e_,eO]=(0,m.useState)(""),[eR,eM]=(0,m.useState)([]),[eP,eE]=(0,m.useState)("idle"),[eD,eL]=(0,m.useState)(null),[eU,ez]=(0,m.useState)(null),[eF,eB]=(0,m.useState)(null),[eV,eq]=(0,m.useState)(""),[eK,eJ]=(0,m.useState)(null),[eG,eH]=(0,m.useState)(null),[eZ,eQ]=(0,m.useState)(!1),[eY,eX]=(0,m.useState)(!1),[e0,e1]=(0,m.useState)(!1),[e2,e5]=(0,m.useState)(null),[e3,e8]=(0,m.useState)(null),[e6,e9]=(0,m.useState)("dark"),[e7,te]=(0,m.useState)(!1),[tt,ta]=(0,m.useState)("basic"),ts=(0,m.useRef)(null),tr=(0,m.useRef)(null),tn=u.runtimes.filter(e=>"active"===e.status||"queued"===e.status).length,ti=u.diagnostics.installed&&u.diagnostics.rpcOk,tl=ti&&u.diagnostics.modelReadiness.ready,to=[u.diagnostics.updatePackageManager,u.diagnostics.updateInstallKind].filter(Boolean).join(" \xb7 "),td="running"===X,tc="success"===X||"error"===X,tp="running"===(t=X)?"Updating OpenClaw":"success"===t?"Update complete":"error"===t?"Update failed":"Update OpenClaw",tm="running"===(a=X)?"OpenClaw is being updated now. Local gateway activity may pause briefly while the CLI is replaced.":"success"===a?"The CLI update finished. Review the result below, then close this panel when you are done.":"error"===a?"The update did not complete cleanly. Review the result and captured output before trying again.":"This runs openclaw update against the installed CLI and may briefly interrupt local gateway activity.",tu=(l=u).diagnostics.installed?l.diagnostics.rpcOk?{label:"Enter Mission Control",description:"OpenClaw is online."}:l.diagnostics.loaded?(!l.diagnostics.rpcOk,{label:"Start OpenClaw",description:"Start the local gateway service and wait for a live RPC connection."}):{label:"Prepare local gateway",description:"OpenClaw CLI is already ready. Mission Control will register the local gateway service once, then start it."}:{label:"Install OpenClaw",description:"Download the OpenClaw CLI and prepare this machine for Mission Control."},th=!tl&&!eZ||e0||eY;(0,m.useEffect)(()=>{!f||u.workspaces.some(e=>e.id===f)||y(u.workspaces[0]?.id??null)},[u.workspaces,f]),(0,m.useEffect)(()=>{!v||u.workspaces.some(e=>e.id===v)||u.agents.some(e=>e.id===v)||u.runtimes.some(e=>e.id===v)||u.models.some(e=>e.id===v)||j(f||u.workspaces[0]?.id||null)},[u,v,f]),(0,m.useEffect)(()=>{v&&T.includes(v)&&j(f||u.workspaces[0]?.id||null)},[v,T,f,u.workspaces]),(0,m.useEffect)(()=>{!C||u.runtimes.some(e=>e.agentId===C.agentId&&(e.updatedAt??0)>=C.submittedAt-1500)&&S(null)},[u.runtimes,C]),(0,m.useEffect)(()=>{let e=globalThis.localStorage?.getItem(sc);("dark"===e||"light"===e)&&e9(e)},[]),(0,m.useEffect)(()=>{globalThis.localStorage?.setItem(sc,e6)},[e6]),(0,m.useEffect)(()=>{L||J||H||(B(sx(u)),K(sg(u)))},[u,L,J,H]),(0,m.useEffect)(()=>{tl&&eQ(!1)},[tl]),(0,m.useEffect)(()=>{eO(e=>{let t=u.models.filter(e=>!1!==e.available&&!e.missing).map(e=>e.id),a=u.diagnostics.modelReadiness.recommendedModelId;return e&&t.includes(e)?e:a&&t.includes(a)?a:t[0]||""})},[u.models,u.diagnostics.modelReadiness.recommendedModelId]),(0,m.useEffect)(()=>{ti?e$("models"):e$("system")},[ti]),(0,m.useEffect)(()=>{(tr.current&&(globalThis.clearTimeout(tr.current),tr.current=null),tl)?"idle"!==eh||"idle"!==eP?(eg("success"),ef("ready"),ey(null),ej("OpenClaw and a usable default model are ready. Entering Mission Control..."),eE("success"),eL("ready"),ez(null),eB("A usable default model is ready."),e$("models"),e1(!0),tr.current=globalThis.setTimeout(()=>{e1(!1)},1100)):e1(!1):e1(!1)},[tl,eh,eP]),(0,m.useEffect)(()=>()=>{tr.current&&globalThis.clearTimeout(tr.current)},[]);let tx=()=>{"running"!==X&&(et("idle"),er(null),ep(null),eu(""))},tg=e=>{eu(t=>{let a=`${t}${e}`;return a.length>4e4?a.slice(a.length-4e4):a})},tf=e=>{eN(t=>{let a=`${t}${e}`;return a.length>4e4?a.slice(a.length-4e4):a})},tw=e=>{eq(t=>{let a=`${t}${e}`;return a.length>4e4?a.slice(a.length-4e4):a})},ty=e=>{e&&eM(e)};(0,m.useEffect)(()=>{if(!L)return;let e=e=>{ts.current?.contains(e.target)||U(!1)},t=e=>{"Escape"===e.key&&U(!1)};return window.addEventListener("pointerdown",e),window.addEventListener("keydown",t),()=>{window.removeEventListener("pointerdown",e),window.removeEventListener("keydown",t)}},[L]);let tv=async()=>{Y(!0),et("running"),er("Starting OpenClaw update..."),ep(null),eu("");try{let e=await fetch("/api/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({confirmed:!0})});if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error||"OpenClaw update request failed.")}if(!e.body)throw Error("OpenClaw update did not return a readable stream.");let t=e.body.getReader(),a=new TextDecoder,s="",r=!1;for(;;){let{value:e,done:n}=await t.read();if(n)break;let i=(s+=a.decode(e,{stream:!0})).indexOf("\n");for(;i>=0;){let e=s.slice(0,i).trim();if(s=s.slice(i+1),e){let t=JSON.parse(e);"status"===t.type?(er(t.message),tg(`
6
- > ${t.message}
7
- `)):"log"===t.type?tg(t.text):(r=!0,er(null),ep(t.message),et(t.ok?"success":"error"),t.snapshot&&b(t.snapshot),t.ok?ex.o.success("OpenClaw updated.",{description:t.message}):ex.o.error("OpenClaw update failed.",{description:t.message}))}i=s.indexOf("\n")}}let n=s.trim();if(n){let e=JSON.parse(n);"done"===e.type&&(r=!0,er(null),ep(e.message),et(e.ok?"success":"error"),e.snapshot&&b(e.snapshot))}if(!r)throw Error("OpenClaw update stream ended unexpectedly.")}catch(e){et("error"),er(null),ep(e instanceof Error?e.message:"OpenClaw update failed."),ex.o.error("OpenClaw update failed.",{description:e instanceof Error?e.message:"Unknown update error."})}},tj=async()=>{eQ(!1),e$("system"),eg("running"),ef("detecting"),ey("Checking local OpenClaw status..."),ej(null),eS(null),eI(null),eN("");try{let e=await fetch("/api/onboarding",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({intent:"auto"})});if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error||"OpenClaw onboarding request failed.")}if(!e.body)throw Error("OpenClaw onboarding did not return a readable stream.");let t=e.body.getReader(),a=new TextDecoder,s="",r=!1;for(;;){let{value:e,done:n}=await t.read();if(n)break;let i=(s+=a.decode(e,{stream:!0})).indexOf("\n");for(;i>=0;){let e=s.slice(0,i).trim();if(s=s.slice(i+1),e){let t=JSON.parse(e);"status"===t.type?(ef(t.phase),ey(t.message),tf(`
8
- > ${t.message}
9
- `)):"log"===t.type?tf(t.text):(r=!0,ef(t.phase),ey(null),ej(t.message),eS(t.manualCommand??null),eI(t.docsUrl??null),eg(t.ok?"success":"error"),t.snapshot&&b(t.snapshot),t.ok?ex.o.success("System setup ready.",{description:t.message}):ex.o.error("OpenClaw onboarding failed.",{description:t.message}))}i=s.indexOf("\n")}}let n=s.trim();if(n){let e=JSON.parse(n);"done"===e.type&&(r=!0,ef(e.phase),ey(null),ej(e.message),eS(e.manualCommand??null),eI(e.docsUrl??null),eg(e.ok?"success":"error"),e.snapshot&&b(e.snapshot))}if(!r)throw Error("OpenClaw onboarding stream ended unexpectedly.")}catch(e){eg("error"),ey(null),ej(e instanceof Error?e.message:"OpenClaw onboarding failed."),ex.o.error("OpenClaw onboarding failed.",{description:e instanceof Error?e.message:"Unknown onboarding error."})}},tk=async e=>{var t,a;let s="discover"===(t=e.intent)?{statusMessage:"Scanning remote model routes...",successTitle:"Models discovered.",errorTitle:"Model discovery failed."}:"login-provider"===t?{statusMessage:"Preparing provider auth...",successTitle:"Provider connected.",errorTitle:"Provider auth needs attention."}:"refresh"===t?{statusMessage:"Refreshing model status...",successTitle:"Model setup refreshed.",errorTitle:"Model refresh failed."}:{statusMessage:"Checking available models and provider auth...",successTitle:"Model setup ready.",errorTitle:"Model setup failed."};eQ(!1),e$("models"),eE("running"),eL("refresh"===(a=e.intent)?"refreshing":"discover"===a?"discovering":"detecting"),ez(s.statusMessage),eB(null),eJ(null),eH(null),eq("");try{let t=await fetch("/api/onboarding/models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.error||"Model onboarding request failed.")}if(!t.body)throw Error("Model onboarding did not return a readable stream.");let a=t.body.getReader(),r=new TextDecoder,n="",i=!1;for(;;){let{value:e,done:t}=await a.read();if(t)break;let l=(n+=r.decode(e,{stream:!0})).indexOf("\n");for(;l>=0;){let e=n.slice(0,l).trim();if(n=n.slice(l+1),e){let t=JSON.parse(e);"status"===t.type?(eL(t.phase),ez(t.message),tw(`
10
- > ${t.message}
11
- `)):"log"===t.type?tw(t.text):(i=!0,eL(t.phase),ez(null),eB(t.message),eJ(t.manualCommand??null),eH(t.docsUrl??null),eE(t.ok?"success":"error"),ty(t.discoveredModels),t.snapshot&&b(t.snapshot),t.ok?ex.o.success(s.successTitle,{description:t.message}):"authenticating"===t.phase&&t.manualCommand?ex.o.message("Continue in terminal.",{description:t.message}):ex.o.error(s.errorTitle,{description:t.message}))}l=n.indexOf("\n")}}let l=n.trim();if(l){let e=JSON.parse(l);"done"===e.type&&(i=!0,eL(e.phase),ez(null),eB(e.message),eJ(e.manualCommand??null),eH(e.docsUrl??null),eE(e.ok?"success":"error"),ty(e.discoveredModels),e.snapshot&&b(e.snapshot))}if(!i)throw Error("Model onboarding stream ended unexpectedly.")}catch(e){eE("error"),ez(null),eB(e instanceof Error?e.message:"Model onboarding failed."),ex.o.error(s.errorTitle,{description:e instanceof Error?e.message:"Unknown model onboarding error."})}},tN=async()=>{await tk({intent:"auto",modelId:e_||void 0})},tC=async()=>{await tk({intent:"refresh"})},tS=async()=>{await tk({intent:"discover"})},tA=async e=>{let t=e||e_;t?await tk({intent:"set-default",modelId:t}):await tN()},tI=async e=>{e5(e);try{let t=await fetch("/api/gateway/control",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:e})}),a=await t.json();if(!t.ok||a.error||!a.snapshot)throw Error(a.error||"Gateway control request failed.");b(a.snapshot),ex.o.success("Gateway updated.",{description:a.message||"Gateway state changed."})}catch(e){ex.o.error("Gateway action failed.",{description:e instanceof Error?e.message:"Unknown gateway control error."})}finally{e5(null)}},tT=async()=>{F(!0);try{let e=await g(),t=Date.now(),a=e.diagnostics.updateInfo?.trim();if(e8(t),!e.diagnostics.installed)return void ex.o.message("OpenClaw is unavailable.",{description:e.diagnostics.issues[0]||"Mission Control is running in fallback mode."});if(e.diagnostics.updateAvailable)return void ex.o.message("Update available.",{description:a||`v${e.diagnostics.latestVersion} is available. Current version: v${e.diagnostics.version||"unknown"}.`});if(e.diagnostics.latestVersion&&!e.diagnostics.version)return void ex.o.message("Update status refreshed.",{description:a||`Latest available version: v${e.diagnostics.latestVersion}.`});if(e.diagnostics.updateError)return void ex.o.error("Update check could not reach the registry.",{description:a||e.diagnostics.updateError});ex.o.success("OpenClaw is up to date.",{description:a||`Current version: v${e.diagnostics.version||"unknown"}. No newer release was reported.`})}catch(e){ex.o.error("Update check failed.",{description:e instanceof Error?e.message:"Unable to refresh OpenClaw status."})}finally{F(!1)}},t$=async e=>{G(!0);try{let t=await fetch("/api/settings/gateway",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({gatewayUrl:e})});if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.error||"Gateway settings could not be updated.")}let a=await t.json();b(a.snapshot),B(sx(a.snapshot)),ex.o.success("Gateway updated.",{description:e?.trim()?`Mission Control now targets ${a.snapshot.diagnostics.configuredGatewayUrl||a.snapshot.diagnostics.gatewayUrl}.`:"Mission Control reverted to the local default gateway."})}catch(e){ex.o.error("Gateway update failed.",{description:e instanceof Error?e.message:"Unable to update the OpenClaw gateway."})}finally{G(!1)}},tO=async e=>{Z(!0);try{let t=await fetch("/api/settings/workspace-root",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceRoot:e})});if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.error||"Workspace root could not be updated.")}let a=await t.json();b(a.snapshot),K(sg(a.snapshot)),ex.o.success("Workspace root updated.",{description:e?.trim()?`New workspaces will default to ${_(a.snapshot.diagnostics.workspaceRoot)}. Existing workspaces stay where they are.`:"Mission Control reverted to the default workspace root. Existing workspaces were not moved."})}catch(e){ex.o.error("Workspace root update failed.",{description:e instanceof Error?e.message:"Unable to update the default workspace root."})}finally{Z(!1)}};return(0,s.jsxs)("div",{className:w("mission-shell relative min-h-screen overflow-hidden","light"===e6&&"mission-shell--light"),children:[(0,s.jsxs)("div",{className:"mission-canvas-backdrop absolute inset-0 z-0",children:[(0,s.jsx)("div",{"aria-hidden":"true",className:"mission-canvas-pattern absolute inset-0 z-0"}),(0,s.jsx)("div",{className:"absolute inset-0 z-10",children:(0,s.jsx)(V,{snapshot:u,activeWorkspaceId:f,selectedNodeId:v,pendingMission:C,hiddenRuntimeIds:T,className:"rounded-none",onEditAgent:e=>{j(e),R({requestId:`edit:${e}:${Date.now()}`,kind:"edit",agentId:e})},onDeleteAgent:e=>{j(e),R({requestId:`delete:${e}:${Date.now()}`,kind:"delete",agentId:e})},onReplyRuntime:e=>{I({id:`reply:${e.id}:${Date.now()}`,mission:sh(e),agentId:e.agentId,sourceKind:"reply",sourceLabel:e.title.trim()||e.subtitle.trim()||e.id})},onCopyRuntimePrompt:async e=>{let t=sh(e);I({id:`copy:${e.id}:${Date.now()}`,mission:t,agentId:e.agentId,sourceKind:"copy",sourceLabel:e.title.trim()||e.subtitle.trim()||e.id});try{await navigator.clipboard.writeText(t),ex.o.success("Prompt copied to clipboard.",{description:"The mission input was also populated."})}catch{ex.o.message("Prompt moved into mission input.",{description:"Clipboard access was not available."})}},onHideRuntime:e=>{$(t=>t.includes(e)?t:[...t,e])},onSelectNode:j})})]}),(0,s.jsx)("div",{className:w("pointer-events-none absolute top-0 z-40 hidden lg:block",M?"lg:left-[442px]":"lg:left-[118px]",E?"lg:right-[442px]":"lg:right-[118px]"),children:(0,s.jsx)(su,{snapshot:u,surfaceTheme:e6,settingsRef:ts,isSettingsOpen:L,gatewayDraft:W,workspaceRootDraft:q,isSavingGateway:J,isSavingWorkspaceRoot:H,isCheckingForUpdates:z,selectedModelId:e_,modelOnboardingRunState:eP,gatewayControlAction:e2,lastCheckedAt:e3,onToggleTheme:()=>e9(e=>"light"===e?"dark":"light"),onToggleSettings:()=>U(e=>!e),onGatewayDraftChange:B,onWorkspaceRootDraftChange:K,onSelectedModelIdChange:eO,onSaveGatewaySettings:t$,onSaveWorkspaceRootSettings:tO,onCheckForUpdates:tT,onControlGateway:tI,onOpenSetupWizard:(e=ti?"models":"system")=>{U(!1),e$(e),eQ(!1),e1(!1),eX(!0)},onRunModelRefresh:tC,onRunModelSetDefault:tA,onOpenUpdateDialog:()=>{tx(),Y(!0)}})}),(0,s.jsxs)("div",{className:"relative z-20 min-h-screen pointer-events-none lg:h-screen",children:[(0,s.jsx)("div",{className:"pointer-events-none absolute left-1/2 top-4 z-30 -translate-x-1/2 lg:hidden",children:(0,s.jsx)(sm,{surfaceTheme:e6})}),(0,s.jsx)("div",{className:w("pointer-events-auto absolute left-4 top-4 z-30",M?"bottom-[calc(env(safe-area-inset-bottom)+124px)] w-[calc(100vw-112px)] max-w-[300px] lg:bottom-[244px] lg:top-6 lg:w-[394px] lg:max-w-none":"w-[78px] lg:bottom-[244px] lg:top-6"),children:(0,s.jsx)(t_,{snapshot:u,activeWorkspaceId:f,requestedAgentAction:O,connectionState:h,collapsed:!M,onToggleCollapsed:()=>P(e=>!e),onSelectWorkspace:e=>{y(e),j(e)},onRefresh:x})}),(0,s.jsx)("div",{className:w("pointer-events-auto absolute right-4 top-4 z-30",E?"bottom-[calc(env(safe-area-inset-bottom)+124px)] w-[calc(100vw-112px)] max-w-[300px] lg:bottom-[244px] lg:top-6 lg:w-[394px] lg:max-w-none":"w-[78px] lg:bottom-[244px] lg:top-6"),children:(0,s.jsx)(e4,{snapshot:u,selectedNodeId:v,lastMission:k,collapsed:!E,onToggleCollapsed:()=>D(e=>!e)})}),(0,s.jsx)("div",{className:"pointer-events-auto absolute bottom-[calc(env(safe-area-inset-bottom)+12px)] left-4 right-4 z-40 lg:bottom-6 lg:left-1/2 lg:right-auto lg:w-[min(800px,calc(100vw-320px))] lg:-translate-x-1/2",children:(0,s.jsx)(eW,{snapshot:u,activeWorkspaceId:f,selectedNodeId:v,composeIntent:A,onRefresh:x,onOpenWorkspaceCreate:()=>{ta("basic"),te(!0)},onOpenWorkspacePlanner:()=>{ta("advanced"),te(!0)},onMissionResponse:N,onMissionDispatchStart:S,onMissionDispatchComplete:e=>{"error"===e&&S(null)}})}),th?(0,s.jsx)(tb,{snapshot:u,surfaceTheme:e6,stage:eT,systemActionLabel:tu.label,systemActionDescription:tu.description,systemPhase:eb,modelPhase:eD,systemRun:{runState:eh,statusMessage:ew,resultMessage:ev,log:ek,manualCommand:eC,docsUrl:eA},modelRun:{runState:eP,statusMessage:eU,resultMessage:eF,log:eV,manualCommand:eK,docsUrl:eG},selectedModelId:e_,discoveredModels:eR,onSelectedModelIdChange:eO,onRunSystemSetup:tj,onRunModelAutoSetup:tN,onRunModelDiscover:tS,onRunModelRefresh:tC,onRunModelSetDefault:tA,onContinueToModels:()=>e$("models"),onBackToSystem:()=>e$("system"),onDismiss:()=>{eX(!1),e1(!1),tl||eQ(!0)},canDismiss:!e0&&"running"!==eh&&"running"!==eP}):null,(0,s.jsx)(sr,{open:e7,onOpenChange:te,initialMode:tt,surfaceTheme:e6,snapshot:u,onRefresh:x,onWorkspaceCreated:e=>{y(e),j(e)}}),(0,s.jsxs)("div",{className:w("pointer-events-auto absolute bottom-3 right-4 z-30 text-[11px] tracking-[0.04em] lg:bottom-4 lg:right-6","light"===e6?"text-[#8f7664]":"text-slate-500"),children:["Built on"," ",(0,s.jsx)("a",{href:"https://openclaw.ai/",target:"_blank",rel:"noreferrer",className:w("transition-colors","light"===e6?"text-[#6f5a4b] hover:text-[#4f3d31]":"text-slate-300 hover:text-slate-100"),children:"OpenClaw"})," ","by"," ",(0,s.jsx)("a",{href:"https://sapienx.app/",target:"_blank",rel:"noreferrer",className:w("transition-colors","light"===e6?"text-[#6f5a4b] hover:text-[#4f3d31]":"text-slate-300 hover:text-slate-100"),children:"SapienX"})]}),(0,s.jsx)(ea,{open:Q,onOpenChange:e=>{"running"!==X&&(Y(e),e||tx())},children:(0,s.jsxs)(ei,{className:w("max-w-[468px] gap-5 p-5 sm:p-6","light"===e6?"border-[#d7c5b7] bg-[rgba(252,247,241,0.98)] text-[#4a382c] shadow-[0_30px_80px_rgba(161,125,101,0.2)]":"border-white/10 bg-slate-950/94 text-slate-100"),children:[(0,s.jsxs)(el,{children:[(0,s.jsx)(ed,{className:"light"===e6?"text-[#3f2f24]":"text-white",children:tp}),(0,s.jsx)(ec,{className:"light"===e6?"text-[#7e6555]":"text-slate-400",children:tm})]}),tc?(0,s.jsxs)("div",{className:w("space-y-4","light"===e6?"text-[#4f3d31]":"text-slate-200"),children:[(0,s.jsxs)("div",{className:w("rounded-[24px] border px-4 py-5",(o=X,d=e6,"success"===o?"light"===d?"border-emerald-300 bg-emerald-50/80 text-emerald-950":"border-emerald-300/25 bg-emerald-300/10 text-emerald-50":"light"===d?"border-rose-300 bg-rose-50/90 text-rose-950":"border-rose-300/25 bg-rose-300/10 text-rose-50")),children:[(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)("div",{className:w("flex h-11 w-11 shrink-0 items-center justify-center rounded-2xl border",(c=X,p=e6,"success"===c?"light"===p?"border-emerald-300 bg-white/80 text-emerald-700":"border-emerald-300/25 bg-emerald-300/10 text-emerald-200":"light"===p?"border-rose-300 bg-white/80 text-rose-700":"border-rose-300/25 bg-rose-300/10 text-rose-200")),children:"success"===X?(0,s.jsx)(r.A,{className:"h-5 w-5"}):(0,s.jsx)(n.A,{className:"h-5 w-5"})}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("p",{className:"font-display text-[1.05rem] leading-6",children:"success"===X?"OpenClaw is up to date":"Update needs attention"}),(0,s.jsx)("p",{className:"mt-1 text-sm leading-6",children:en||("success"===X?"The update finished successfully.":"The update did not finish cleanly.")})]})]}),(0,s.jsxs)("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:[(0,s.jsxs)("div",{className:w("rounded-[18px] border px-3 py-3","light"===e6?"border-white/70 bg-white/70":"border-white/10 bg-slate-950/30"),children:[(0,s.jsx)("p",{className:"light"===e6?"text-[10px] uppercase tracking-[0.22em] text-[#8d725f]":"text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Installed version"}),(0,s.jsxs)("p",{className:"mt-2 font-display text-lg text-inherit",children:["v",u.diagnostics.version||u.diagnostics.latestVersion||"unknown"]})]}),(0,s.jsxs)("div",{className:w("rounded-[18px] border px-3 py-3","light"===e6?"border-white/70 bg-white/70":"border-white/10 bg-slate-950/30"),children:[(0,s.jsx)("p",{className:"light"===e6?"text-[10px] uppercase tracking-[0.22em] text-[#8d725f]":"text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Install mode"}),(0,s.jsx)("p",{className:"mt-2 text-sm font-medium text-inherit",children:to||"unknown"})]})]})]}),(0,s.jsxs)("div",{className:w("rounded-[20px] border","light"===e6?"border-[#e3d4c8] bg-[#fffaf6]":"border-white/8 bg-white/[0.03]"),children:[(0,s.jsxs)("div",{className:w("flex items-center justify-between border-b px-4 py-3","light"===e6?"border-[#eadccf]":"border-white/8"),children:[(0,s.jsx)("p",{className:w("text-[10px] uppercase tracking-[0.24em]","light"===e6?"text-[#9a7f6c]":"text-slate-500"),children:"Update log"}),(0,s.jsx)("span",{className:"light"===e6?"text-xs text-[#8b7262]":"text-xs text-slate-400",children:"success"===X?"Completed":"Failed"})]}),(0,s.jsx)("pre",{className:w("max-h-[180px] overflow-auto whitespace-pre-wrap break-words px-4 py-3 font-mono text-[11px] leading-5","light"===e6?"text-[#4f3d31]":"text-slate-200"),children:em||"No command output was captured."})]})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:w("grid gap-3 sm:grid-cols-2","light"===e6?"text-[#4f3d31]":"text-slate-200"),children:[(0,s.jsxs)("div",{className:w("rounded-[20px] border px-4 py-4","light"===e6?"border-[#e3d4c8] bg-[#fffaf6]":"border-white/8 bg-white/[0.03]"),children:[(0,s.jsx)("p",{className:w("text-[10px] uppercase tracking-[0.24em]","light"===e6?"text-[#9a7f6c]":"text-slate-500"),children:"Version target"}),(0,s.jsxs)("p",{className:"mt-2 font-display text-[1.1rem] leading-6 text-inherit",children:["v",u.diagnostics.latestVersion||u.diagnostics.version||"unknown"]}),(0,s.jsxs)("p",{className:"light"===e6?"mt-1 text-xs text-[#8b7262]":"mt-1 text-xs text-slate-400",children:["Current: v",u.diagnostics.version||"unknown"]})]}),(0,s.jsxs)("div",{className:w("rounded-[20px] border px-4 py-4","light"===e6?"border-[#e3d4c8] bg-[#fffaf6]":"border-white/8 bg-white/[0.03]"),children:[(0,s.jsx)("p",{className:w("text-[10px] uppercase tracking-[0.24em]","light"===e6?"text-[#9a7f6c]":"text-slate-500"),children:"Install mode"}),(0,s.jsx)("p",{className:"mt-2 text-sm font-medium leading-6 text-inherit",children:to||"unknown"}),(0,s.jsx)("p",{className:"light"===e6?"mt-1 text-xs text-[#8b7262]":"mt-1 text-xs text-slate-400",children:_(u.diagnostics.updateRoot||"")||"Install root unavailable"})]})]}),(0,s.jsx)("div",{className:w("rounded-[20px] border px-4 py-3 text-sm",tn>0?"light"===e6?"border-rose-300/80 bg-rose-50 text-rose-800":"border-rose-300/25 bg-rose-300/10 text-rose-100":"light"===e6?"border-[#e3d4c8] bg-[#fffaf6] text-[#745e4f]":"border-white/8 bg-white/[0.03] text-slate-300"),children:tn>0?`${tn} active or queued runtime${1===tn?"":"s"} may be interrupted during the update.`:"No active runtimes are currently tracked, so the update risk is lower."}),td?(0,s.jsxs)("div",{className:w("rounded-[20px] border","light"===e6?"border-[#e3d4c8] bg-[#fffaf6]":"border-white/8 bg-white/[0.03]"),children:[(0,s.jsxs)("div",{className:w("flex items-center gap-3 border-b px-4 py-3","light"===e6?"border-[#eadccf]":"border-white/8"),children:[(0,s.jsx)("div",{className:w("flex h-9 w-9 items-center justify-center rounded-2xl border","light"===e6?"border-[#dcc6b6] bg-[#f4e8dd] text-[#7b6453]":"border-white/10 bg-white/[0.05] text-slate-200"),children:(0,s.jsx)(i.A,{className:"h-4 w-4 animate-spin"})}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("p",{className:"light"===e6?"text-sm font-medium text-[#4a382c]":"text-sm font-medium text-white",children:"Update in progress"}),(0,s.jsx)("p",{className:"light"===e6?"text-xs text-[#8b7262]":"text-xs text-slate-400",children:es||"Streaming OpenClaw output..."})]})]}),(0,s.jsx)("pre",{className:w("max-h-[180px] min-h-[120px] overflow-auto whitespace-pre-wrap break-words px-4 py-3 font-mono text-[11px] leading-5","light"===e6?"text-[#4f3d31]":"text-slate-200"),children:em||"Waiting for command output..."})]}):null]}),(0,s.jsxs)(eo,{children:[(0,s.jsx)(ee,{type:"button",variant:"secondary",onClick:()=>{Y(!1),tx()},disabled:td,className:"light"===e6?"border-[#d9c9bc] bg-[#f5ebe3] text-[#6c5647] hover:bg-[#eddccf]":"",children:tc?"Done":"Cancel"}),tc?null:(0,s.jsx)(ee,{type:"button",onClick:tv,disabled:td,className:w(u.diagnostics.updateAvailable?"bg-amber-400 text-slate-950 shadow-lg shadow-amber-400/20 hover:bg-amber-300":"","light"!==e6||u.diagnostics.updateAvailable?"":"bg-[#c8946f] text-white shadow-[0_12px_28px_rgba(200,148,111,0.24)] hover:bg-[#b88461]"),children:td?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.A,{className:"mr-2 h-4 w-4 animate-spin"}),"Updating..."]}):"Update now"})]})]})})]})]})}function sm({surfaceTheme:e}){return(0,s.jsxs)("div",{className:w("flex h-11 items-center gap-3 rounded-full border px-4 shadow-[0_18px_50px_rgba(0,0,0,0.24)] backdrop-blur-xl","light"===e?"border-[#d9c9bc]/90 bg-[#f8f5f0]/86 shadow-[0_18px_42px_rgba(161,125,101,0.14)]":"border-cyan-300/10 bg-slate-950/45"),children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:w("inline-flex h-7 w-7 items-center justify-center overflow-hidden rounded-[8px] border","light"===e?"border-[#d1bcad] bg-[#f5ece4]":"border-white/[0.08] bg-white/[0.03]"),children:(0,s.jsx)("video",{"aria-hidden":"true",autoPlay:!0,loop:!0,muted:!0,playsInline:!0,preload:"auto",className:"h-full w-full scale-[1.15] object-cover",children:(0,s.jsx)("source",{src:"/assets/logo.webm",type:"video/webm"})})}),(0,s.jsx)("p",{className:w("text-[10px] tracking-[0.18em]","light"===e?"text-[#8a7261]":"text-slate-500"),children:"AgentOS"})]}),(0,s.jsx)("span",{"aria-hidden":"true",className:w("h-4 w-px","light"===e?"bg-[#cdb7a8]/80":"bg-white/[0.08]")}),(0,s.jsx)("h2",{className:w("font-display text-[0.88rem]","light"===e?"text-[#816958]/80":"text-slate-400/75"),children:"Mission Control"})]})}function su({snapshot:e,surfaceTheme:t,settingsRef:a,isSettingsOpen:r,gatewayDraft:n,workspaceRootDraft:m,isSavingGateway:u,isSavingWorkspaceRoot:h,isCheckingForUpdates:x,selectedModelId:g,modelOnboardingRunState:b,gatewayControlAction:f,lastCheckedAt:y,onToggleTheme:v,onToggleSettings:j,onGatewayDraftChange:k,onWorkspaceRootDraftChange:N,onSelectedModelIdChange:C,onSaveGatewaySettings:S,onSaveWorkspaceRootSettings:A,onCheckForUpdates:I,onControlGateway:T,onOpenSetupWizard:$,onRunModelRefresh:O,onRunModelSetDefault:R,onOpenUpdateDialog:M}){let P=e.diagnostics.installed&&e.diagnostics.rpcOk&&e.diagnostics.modelReadiness.ready,E=null!==f,D="running"===b,L=sb(t,"secondary"),U=sb(t,"primary"),z=sb(t,"warning"),F=sb(t,"warningSolid"),W=w("inline-flex h-8 w-8 items-center justify-center rounded-full border transition-[background-color,border-color,color,transform] duration-150 active:scale-[0.96]","light"===t?"border-[#d0bcae] bg-[#efe5dc] text-[#7f6554] shadow-[inset_0_1px_0_rgba(255,255,255,0.55)] hover:bg-[#e7d9ce] hover:border-[#c8b09f] hover:text-[#5f4a3d] active:bg-[#ddcdbf]":"border-white/12 bg-white/[0.08] text-slate-200 hover:bg-white/[0.12] hover:border-white/16 hover:text-slate-100 active:bg-white/[0.16]"),B=w("relative inline-flex h-7 w-14 items-center rounded-full border transition-[background-color,border-color,transform] duration-150 active:scale-[0.98]","light"===t?"border-[#d0bcae] bg-[#eaded3] shadow-[inset_0_1px_0_rgba(255,255,255,0.55)] hover:bg-[#e3d5c8] hover:border-[#c8b09f] active:bg-[#d9c8ba]":"border-white/12 bg-white/[0.08] hover:bg-white/[0.12] hover:border-white/16 active:bg-white/[0.16]"),V=w("absolute left-1 inline-flex h-5 w-5 items-center justify-center rounded-full shadow-[0_4px_12px_rgba(0,0,0,0.18)] transition-[transform,background-color,color] duration-150","light"===t?"translate-x-7 bg-[#c8946f] text-white":"translate-x-0 bg-cyan-300 text-slate-950");return(0,s.jsxs)("div",{className:"flex w-full items-center justify-between px-0 pt-6",children:[(0,s.jsx)(sm,{surfaceTheme:t}),(0,s.jsxs)("div",{ref:a,className:"pointer-events-auto relative",children:[(0,s.jsxs)("div",{className:w("flex h-11 items-center gap-3 rounded-full border px-4 shadow-[0_18px_50px_rgba(0,0,0,0.24)] backdrop-blur-xl","light"===t?"border-[#d9c9bc]/90 bg-[#f8f5f0]/86 shadow-[0_18px_42px_rgba(161,125,101,0.14)]":"border-cyan-300/10 bg-slate-950/45"),children:[(0,s.jsxs)("div",{className:"flex items-baseline gap-[3px]",children:[(0,s.jsx)("span",{className:w("text-[10px] uppercase tracking-[0.3em]","light"===t?"text-[#8a7261]":"text-slate-500"),children:"OPENCLAW"}),(0,s.jsxs)("span",{className:w("font-mono text-[8px] tracking-[0.04em]","light"===t?"text-[#6f5a4b]/85":"text-slate-300/80"),children:["v",e.diagnostics.version||"unknown"]})]}),(0,s.jsxs)("span",{className:w("inline-flex items-center gap-2 rounded-full border px-2.5 py-1 text-[10px] font-medium uppercase tracking-[0.22em]",function(e,t){switch(e){case"healthy":return"light"===t?"border-emerald-300/80 bg-emerald-50 text-emerald-700":"border-emerald-400/25 bg-emerald-400/10 text-emerald-200";case"degraded":return"light"===t?"border-amber-300/90 bg-amber-50 text-amber-700":"border-amber-300/25 bg-amber-300/10 text-amber-200";default:return"light"===t?"border-rose-300/80 bg-rose-50 text-rose-700":"border-rose-300/25 bg-rose-300/10 text-rose-200"}}(e.diagnostics.health,t)),children:[(0,s.jsx)("span",{"aria-hidden":"true",className:w("h-2 w-2 rounded-full shadow-[0_0_12px_currentColor]",function(e){switch(e){case"healthy":return"bg-emerald-400";case"degraded":return"bg-amber-300";default:return"bg-rose-300"}}(e.diagnostics.health))}),function(e){switch(e){case"healthy":return"Online";case"degraded":return"Degraded";default:return"Offline"}}(e.diagnostics.health)]}),(0,s.jsx)("button",{type:"button",role:"switch","aria-label":"light"===t?"Switch to dark theme":"Switch to light theme","aria-checked":"light"===t,onClick:v,className:B,children:(0,s.jsx)("span",{className:V,children:"light"===t?(0,s.jsx)(l.A,{className:"h-3 w-3"}):(0,s.jsx)(o.A,{className:"h-3 w-3"})})}),(0,s.jsx)("button",{type:"button","aria-label":"Open settings","aria-expanded":r,"aria-haspopup":"menu",onClick:j,className:W,children:(0,s.jsx)(d.A,{className:"h-3.5 w-3.5"})})]}),r?(0,s.jsxs)("div",{role:"menu","aria-label":"OpenClaw settings",className:w("absolute right-0 top-[calc(100%+12px)] z-[70] max-h-[min(82vh,calc(100svh-96px))] w-[300px] overflow-y-auto overscroll-contain rounded-[20px] border p-3 shadow-[0_22px_64px_rgba(0,0,0,0.24)] backdrop-blur-2xl","light"===t?"border-[#dbc9bc]/90 bg-[rgba(252,247,241,0.95)] text-[#4a382c] shadow-[0_24px_60px_rgba(161,125,101,0.18)]":"border-cyan-300/12 bg-[rgba(10,16,28,0.9)] text-slate-100"),children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:w("text-[8px] uppercase tracking-[0.24em]","light"===t?"text-[#9a7f6c]":"text-slate-500"),children:"Settings"}),(0,s.jsx)("h3",{className:w("mt-0.5 font-display text-[14px]","light"===t?"text-[#3f2f24]":"text-white"),children:"OpenClaw surface"})]}),(0,s.jsx)("span",{className:w("rounded-full border px-1.5 py-0.5 text-[8px] uppercase tracking-[0.18em]","light"===t?"border-[#d6c0b0] bg-[#f3e7dc] text-[#8a7261]":"border-white/10 bg-white/[0.06] text-slate-400"),children:e.mode})]}),e.diagnostics.updateAvailable&&e.diagnostics.latestVersion?(0,s.jsxs)("div",{className:w("mt-2.5 rounded-[18px] border px-3 py-3","light"===t?"border-amber-300/90 bg-[linear-gradient(135deg,rgba(255,247,237,0.98),rgba(252,231,214,0.94))] shadow-[0_16px_36px_rgba(194,120,55,0.16)]":"border-amber-300/30 bg-[linear-gradient(135deg,rgba(71,35,8,0.62),rgba(33,20,8,0.82))] shadow-[0_18px_42px_rgba(245,158,11,0.14)]"),children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-2.5",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:w("text-[8px] uppercase tracking-[0.18em]","light"===t?"text-amber-800/70":"text-amber-200/80"),children:"Update available"}),(0,s.jsxs)("div",{className:"mt-1.5 flex items-baseline gap-1.5",children:[(0,s.jsxs)("p",{className:w("font-display text-[0.98rem]","light"===t?"text-amber-950":"text-amber-50"),children:["v",e.diagnostics.latestVersion]}),(0,s.jsxs)("p",{className:w("text-[9px]","light"===t?"text-amber-900/70":"text-amber-100/70"),children:["from v",e.diagnostics.version||"unknown"]})]})]}),(0,s.jsx)(c.A,{className:w("mt-0.5 h-4 w-4","light"===t?"text-amber-700":"text-amber-300")})]}),(0,s.jsx)("p",{className:w("mt-1.5 text-[10px] leading-[1.05rem]","light"===t?"text-amber-950/80":"text-amber-50/85"),children:"A newer OpenClaw release was detected. You can update directly from Mission Control."}),(0,s.jsx)("button",{type:"button",onClick:M,className:w("mt-2.5 inline-flex items-center justify-center py-1",F),children:"Update now"})]}):null,(0,s.jsxs)("div",{className:w("mt-2.5 rounded-[16px] border px-2.5 py-2","light"===t?"border-[#e6d7cb] bg-[#fffaf6]":"border-white/8 bg-white/[0.03]"),children:[(0,s.jsx)("p",{className:w("text-[8px] uppercase tracking-[0.18em]","light"===t?"text-[#9a7f6c]":"text-slate-500"),children:"OpenClaw version"}),(0,s.jsxs)("div",{className:"mt-1.5 flex items-center justify-between gap-2",children:[(0,s.jsx)("p",{className:w("font-display text-[0.88rem]","light"===t?"text-[#3f2f24]":"text-white"),children:e.diagnostics.version||"Unavailable"}),e.diagnostics.updateChannel?(0,s.jsx)("span",{className:w("rounded-full border px-1.5 py-0.5 text-[8px] uppercase tracking-[0.18em]","light"===t?"border-[#dcc6b6] bg-[#f4e8dd] text-[#876c5a]":"border-cyan-400/14 bg-cyan-400/8 text-cyan-100"),children:e.diagnostics.updateChannel}):null]}),(0,s.jsx)("p",{className:w("mt-1.5 text-[10px] leading-[1.05rem]","light"===t?"text-[#816958]":"text-slate-400"),children:e.diagnostics.updateInfo?.trim()||"No additional update message was returned in the latest OpenClaw status snapshot."}),(0,s.jsxs)("div",{className:"mt-3",children:[(0,s.jsx)(ee,{type:"button",size:"sm",variant:"secondary",onClick:()=>{I()},disabled:x,className:w("w-full disabled:cursor-wait",e.diagnostics.updateAvailable?z:L),children:x?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.A,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}),"Checking..."]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(p.A,{className:"mr-1.5 h-3.5 w-3.5"}),"Check for updates"]})}),y?(0,s.jsxs)("p",{className:w("mt-2 text-center text-[9px]","light"===t?"text-[#8f7664]":"text-slate-500"),children:["Last checked at"," ",new Date(y).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})]}):null]})]}),(0,s.jsxs)("div",{className:w("mt-2 rounded-[16px] border px-2.5 py-2.5","light"===t?"border-[#e6d7cb] bg-[#fffaf6]":"border-white/8 bg-white/[0.03]"),children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:w("text-[8px] uppercase tracking-[0.18em]","light"===t?"text-[#9a7f6c]":"text-slate-500"),children:"Setup center"}),(0,s.jsx)("p",{className:w("mt-1 text-[10px] leading-[1.05rem]","light"===t?"text-[#816958]":"text-slate-400"),children:"Reopen the wizard, control the gateway, and manage the minimum model setup from one place."})]}),(0,s.jsx)("span",{className:w("rounded-full border px-1.5 py-0.5 text-[8px] uppercase tracking-[0.18em]",P?"light"===t?"border-emerald-300 bg-emerald-50 text-emerald-700":"border-emerald-300/25 bg-emerald-300/10 text-emerald-200":"light"===t?"border-amber-300 bg-amber-50 text-amber-700":"border-amber-300/25 bg-amber-300/10 text-amber-200"),children:P?"Ready":"Needs attention"})]}),(0,s.jsxs)("div",{className:"mt-3 flex items-center gap-2",children:[(0,s.jsx)(ee,{type:"button",size:"sm",variant:"secondary",onClick:()=>$(e.diagnostics.rpcOk?"models":"system"),className:L,children:"Open wizard"}),(0,s.jsx)(ee,{type:"button",size:"sm",variant:"secondary",disabled:D,onClick:()=>{O()},className:L,children:"Refresh setup"})]}),(0,s.jsxs)("div",{className:w("mt-3 rounded-[14px] border px-2.5 py-2.5","light"===t?"border-[#eadcd0] bg-white":"border-white/10 bg-white/[0.03]"),children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:w("text-[11px]","light"===t?"text-[#9a7f6c]":"text-slate-400"),children:"Gateway control"}),(0,s.jsx)("p",{className:w("mt-0.5 text-[10px] leading-[1.05rem]","light"===t?"text-[#816958]":"text-slate-500"),children:e.diagnostics.rpcOk?"Live RPC connection is online.":e.diagnostics.loaded?"Service is loaded but Mission Control cannot verify RPC yet.":"Service is not loaded on this machine yet."})]}),(0,s.jsx)("span",{className:w("rounded-full border px-1.5 py-0.5 text-[8px] uppercase tracking-[0.18em]",e.diagnostics.rpcOk?"light"===t?"border-emerald-300 bg-emerald-50 text-emerald-700":"border-emerald-300/25 bg-emerald-300/10 text-emerald-200":"light"===t?"border-amber-300 bg-amber-50 text-amber-700":"border-amber-300/25 bg-amber-300/10 text-amber-200"),children:e.diagnostics.rpcOk?"Online":e.diagnostics.loaded?"Service only":"Offline"})]}),(0,s.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[(0,s.jsx)(ee,{type:"button",size:"sm",variant:"secondary",disabled:E||e.diagnostics.rpcOk,onClick:()=>{T("start")},className:L,children:"start"===f?"Starting...":"Start"}),(0,s.jsx)(ee,{type:"button",size:"sm",variant:"secondary",disabled:E||!e.diagnostics.loaded,onClick:()=>{T("restart")},className:L,children:"restart"===f?"Restarting...":"Restart"}),(0,s.jsx)(ee,{type:"button",size:"sm",variant:"secondary",disabled:E||!e.diagnostics.loaded,onClick:()=>{T("stop")},className:L,children:"stop"===f?"Stopping...":"Stop"})]})]}),(0,s.jsxs)("div",{className:w("mt-2 rounded-[14px] border px-2.5 py-2.5","light"===t?"border-[#eadcd0] bg-white":"border-white/10 bg-white/[0.03]"),children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:w("text-[11px]","light"===t?"text-[#9a7f6c]":"text-slate-400"),children:"Model setup"}),(0,s.jsxs)("p",{className:w("mt-0.5 text-[10px] leading-[1.05rem]","light"===t?"text-[#816958]":"text-slate-500"),children:["Default model: ",e.diagnostics.modelReadiness.resolvedDefaultModel||e.diagnostics.modelReadiness.defaultModel||"Not set"]})]}),(0,s.jsxs)("span",{className:w("rounded-full border px-1.5 py-0.5 text-[8px] uppercase tracking-[0.18em]",e.diagnostics.modelReadiness.ready?"light"===t?"border-emerald-300 bg-emerald-50 text-emerald-700":"border-emerald-300/25 bg-emerald-300/10 text-emerald-200":"light"===t?"border-amber-300 bg-amber-50 text-amber-700":"border-amber-300/25 bg-amber-300/10 text-amber-200"),children:[e.diagnostics.modelReadiness.availableModelCount,"/",e.diagnostics.modelReadiness.totalModelCount]})]}),(0,s.jsxs)("select",{value:g,onChange:e=>C(e.target.value),disabled:D,className:w("mt-2.5 h-9 w-full rounded-[14px] border px-2.5 text-[11px]","light"===t?"border-[#d9c9bc] bg-[#fffdfb] text-[#4f3d31]":"border-white/10 bg-white/[0.04] text-slate-100"),children:[(0,s.jsx)("option",{value:"",children:"Auto choose"}),e.models.filter(e=>!1!==e.available&&!e.missing).map(e=>(0,s.jsxs)("option",{value:e.id,children:[e.name," \xb7 ",e.provider]},e.id))]}),(0,s.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[(0,s.jsx)(ee,{type:"button",size:"sm",variant:"secondary",disabled:D,onClick:()=>{R()},className:L,children:D?"Working...":"Use selected"}),(0,s.jsx)(ee,{type:"button",size:"sm",variant:"secondary",disabled:D,onClick:()=>{$("models")},className:L,children:"+Add more"})]})]})]}),(0,s.jsxs)("div",{className:w("mt-2 rounded-[16px] border px-2.5 py-2.5","light"===t?"border-[#e6d7cb] bg-[#fffaf6]":"border-white/8 bg-white/[0.03]"),children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)(eh,{htmlFor:"workspace-root",className:w("text-[11px]","light"===t?"text-[#9a7f6c]":"text-slate-500"),children:"Workspace root"}),(0,s.jsx)("p",{className:w("mt-0.5 text-[10px] leading-[1.05rem]","light"===t?"text-[#816958]":"text-slate-400"),children:"Default parent path for newly created workspaces. Existing workspaces stay at their current paths."})]}),(0,s.jsx)("span",{className:w("rounded-full border px-1.5 py-0.5 text-[8px] uppercase tracking-[0.18em]","light"===t?"border-[#dcc6b6] bg-[#f4e8dd] text-[#876c5a]":"border-white/10 bg-white/[0.05] text-slate-300"),children:"New only"})]}),(0,s.jsx)(ep,{id:"workspace-root",value:m,onChange:e=>N(e.target.value),placeholder:"~/Documents/Shared/projects",disabled:h,style:"light"===t?{colorScheme:"light"}:void 0,className:w("mt-2.5 h-9 rounded-[14px] px-2.5 text-[11px]","light"===t?"border-[#d9c9bc] bg-[#fffdfb] text-[#4f3d31] caret-[#7c5a46] placeholder:text-[#b29b8b] shadow-[inset_0_0_0_1000px_#fffdfb] [-webkit-text-fill-color:#4f3d31] focus-visible:ring-[#c8946f]/45":"border-white/10 bg-white/[0.04] text-slate-100 placeholder:text-slate-500")}),(0,s.jsxs)("p",{className:w("mt-1.5 break-all font-mono text-[9px] leading-[1rem]","light"===t?"text-[#6f5a4b]":"text-slate-300"),children:["Configured root: ",e.diagnostics.configuredWorkspaceRoot?_(e.diagnostics.configuredWorkspaceRoot):"default"]}),(0,s.jsxs)("p",{className:w("mt-1 break-all font-mono text-[9px] leading-[1rem]","light"===t?"text-[#6f5a4b]":"text-slate-300"),children:["Effective root: ",_(e.diagnostics.workspaceRoot)]}),(0,s.jsxs)("div",{className:"mt-3 flex items-center gap-2",children:[(0,s.jsx)(ee,{type:"button",size:"sm",variant:"secondary",disabled:h,onClick:()=>{A(null)},className:L,children:"Use default"}),(0,s.jsx)(ee,{type:"button",size:"sm",disabled:h,onClick:()=>{A(m)},className:U,children:h?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.A,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}),"Saving..."]}):"Save root"})]})]}),(0,s.jsxs)("div",{className:w("mt-2 rounded-[16px] border px-2.5 py-2.5","light"===t?"border-[#e6d7cb] bg-[#fffaf6]":"border-white/8 bg-white/[0.03]"),children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)(eh,{htmlFor:"gateway-url",className:w("text-[11px]","light"===t?"text-[#9a7f6c]":"text-slate-500"),children:"OpenClaw gateway"}),(0,s.jsx)("p",{className:w("mt-0.5 text-[10px] leading-[1.05rem]","light"===t?"text-[#816958]":"text-slate-400"),children:"Enter a `ws://` or `wss://` endpoint. Leave it empty to use the local default gateway."})]}),(0,s.jsx)("span",{className:w("rounded-full border px-1.5 py-0.5 text-[8px] uppercase tracking-[0.18em]","light"===t?"border-[#dcc6b6] bg-[#f4e8dd] text-[#876c5a]":"border-white/10 bg-white/[0.05] text-slate-300"),children:e.diagnostics.bindMode||"default"})]}),(0,s.jsx)(ep,{id:"gateway-url",value:n,onChange:e=>k(e.target.value),placeholder:"ws://127.0.0.1:18789",disabled:u,style:"light"===t?{colorScheme:"light"}:void 0,className:w("mt-2.5 h-9 rounded-[14px] px-2.5 text-[11px]","light"===t?"border-[#d9c9bc] bg-[#fffdfb] text-[#4f3d31] caret-[#7c5a46] placeholder:text-[#b29b8b] shadow-[inset_0_0_0_1000px_#fffdfb] [-webkit-text-fill-color:#4f3d31] focus-visible:ring-[#c8946f]/45":"border-white/10 bg-white/[0.04] text-slate-100 placeholder:text-slate-500")}),(0,s.jsxs)("p",{className:w("mt-1.5 break-all font-mono text-[9px] leading-[1rem]","light"===t?"text-[#6f5a4b]":"text-slate-300"),children:["Configured endpoint: ",e.diagnostics.configuredGatewayUrl||"local default"]}),(0,s.jsxs)("p",{className:w("mt-1 break-all font-mono text-[9px] leading-[1rem]","light"===t?"text-[#6f5a4b]":"text-slate-300"),children:["Effective endpoint: ",e.diagnostics.gatewayUrl]}),(0,s.jsxs)("div",{className:"mt-3 flex items-center gap-2",children:[(0,s.jsx)(ee,{type:"button",size:"sm",variant:"secondary",disabled:u,onClick:()=>{S(null)},className:L,children:"Use local"}),(0,s.jsx)(ee,{type:"button",size:"sm",disabled:u,onClick:()=>{S(n)},className:U,children:u?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.A,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}),"Saving..."]}):"Save gateway"})]})]})]}):null]})]})}function sh(e){let t="string"==typeof e.metadata.turnPrompt&&e.metadata.turnPrompt.trim().length>0?e.metadata.turnPrompt.trim():null;return t||(e.title?.trim()?e.title.trim():e.subtitle.trim()||"Continue this run.")}function sx(e){return(e.diagnostics.configuredGatewayUrl||e.diagnostics.gatewayUrl).replace(/\/$/,"")}function sg(e){return _(e.diagnostics.configuredWorkspaceRoot||e.diagnostics.workspaceRoot)}function sb(e,t){let a="h-8 rounded-[12px] border px-2.5 text-[9px] uppercase tracking-[0.18em] transition-[background-color,border-color,color,box-shadow,transform] duration-150 active:scale-[0.985]";return"primary"===t?w(a,"light"===e?"border-[#c8946f] bg-[#c8946f] text-white shadow-[0_12px_28px_rgba(200,148,111,0.24)] hover:bg-[#b88461] hover:border-[#b88461] hover:text-white active:bg-[#a97553] active:border-[#a97553]":"border-cyan-300/30 bg-cyan-300 text-slate-950 shadow-[0_12px_28px_rgba(34,211,238,0.2)] hover:bg-cyan-200 hover:border-cyan-200 hover:text-slate-950 active:bg-cyan-100 active:border-cyan-100"):"warning"===t?w(a,"light"===e?"border-amber-400/90 bg-amber-100 text-amber-900 shadow-[inset_0_1px_0_rgba(255,255,255,0.55)] hover:bg-amber-200 hover:border-amber-400 hover:text-amber-900 active:bg-amber-300":"border-amber-300/35 bg-amber-300/16 text-amber-100 shadow-[inset_0_1px_0_rgba(255,255,255,0.05)] hover:bg-amber-300/24 hover:border-amber-300/45 hover:text-amber-50 active:bg-amber-300/30"):"warningSolid"===t?w(a,"light"===e?"border-amber-900 bg-amber-900 text-amber-50 shadow-[0_12px_28px_rgba(146,64,14,0.18)] hover:bg-amber-800 hover:border-amber-800 hover:text-amber-50 active:bg-amber-700 active:border-amber-700":"border-amber-300 bg-amber-300 text-slate-950 shadow-[0_12px_28px_rgba(245,158,11,0.18)] hover:bg-amber-200 hover:border-amber-200 hover:text-slate-950 active:bg-amber-100 active:border-amber-100"):w(a,"light"===e?"border-[#d3bba9] bg-[#f1e3d7] text-[#6f5949] shadow-[inset_0_1px_0_rgba(255,255,255,0.55)] hover:bg-[#ead8ca] hover:border-[#caa98f] hover:text-[#5f4a3d] active:bg-[#dfc9b7] active:border-[#bf9c82]":"border-white/12 bg-white/[0.05] text-slate-200 shadow-[inset_0_1px_0_rgba(255,255,255,0.04)] hover:bg-white/[0.1] hover:border-white/16 hover:text-slate-100 active:bg-white/[0.14] active:border-white/20")}},2629:(e,t,a)=>{"use strict";a.d(t,{Toaster:()=>s.l$,o:()=>s.oR});var s=a(2273)},4245:(e,t,a)=>{Promise.resolve().then(a.bind(a,1219))}},e=>{e.O(0,[119,708,273,329,881,26,358],()=>e(e.s=4245)),_N_E=e.O()}]);